Skip to content

Commit

Permalink
remove unused params
Browse files Browse the repository at this point in the history
  • Loading branch information
iFrostizz committed Jul 11, 2024
1 parent 44c962b commit c5dd019
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
5 changes: 3 additions & 2 deletions x/programs/cmd/simulator/cmd/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func (c *runCmd) RunStep(ctx context.Context, db *state.SimpleMutable) (*Respons
zap.Any("params", step.Params),
)

params, err := c.createCallParams(ctx, db, step.Params, step.Endpoint)
params, err := c.createCallParams(step.Params)
if err != nil {
c.log.Error(fmt.Sprintf("simulation call: %s", err))
return newResponse(0), err
Expand Down Expand Up @@ -286,6 +286,7 @@ func resultToOutput(result []byte, err error) runtime.Result[runtime.RawBytes, r

type SimulatorTestContext struct {
ProgramID uint64 `json:"programId"`
// TODO can we not just use the Address type ?
ActorAddr []byte `json:"actor"`
Height uint64 `json:"height"`
Timestamp uint64 `json:"timestamp"`
Expand Down Expand Up @@ -314,7 +315,7 @@ func AddressToString(pk ed25519.PublicKey) string {
}

// createCallParams converts a slice of Parameters to a slice of runtime.CallParams.
func (c *runCmd) createCallParams(ctx context.Context, db state.Immutable, params []Parameter, endpoint Endpoint) ([]Parameter, error) {
func (c *runCmd) createCallParams(params []Parameter) ([]Parameter, error) {
cp := make([]Parameter, 0, len(params))
for _, param := range params {
switch param.Type {
Expand Down
4 changes: 1 addition & 3 deletions x/programs/rust/examples/multisig/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ pub fn vote(context: Context<StateKeys>, id: u32, yea: bool) -> Result<(), Propo

let actor = context.actor();
let voters: Vec<_> = (0..proposal.voters_len)
.into_iter()
.map(|i| {
program
.state()
Expand Down Expand Up @@ -536,8 +535,7 @@ mod tests {
.unwrap()
.unwrap();

let id_serialized: Vec<u8> = res.deserialize().unwrap();
let id: u32 = borsh::from_slice(&id_serialized).unwrap();
let id: u32 = res.deserialize().unwrap();

assert_eq!(id, 1);
}
Expand Down
8 changes: 7 additions & 1 deletion x/programs/rust/wasmlanche-sdk/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use thiserror::Error;
/// Defer deserialization from bytes
/// <div class="warning">It is possible that this type performs multiple allocations during deserialization. It should be used sparingly.</div>
#[cfg_attr(feature = "debug", derive(Debug))]
#[derive(BorshSerialize)]
pub struct DeferDeserialize(Vec<u8>);

impl DeferDeserialize {
Expand All @@ -24,6 +23,13 @@ impl DeferDeserialize {
}
}

impl BorshSerialize for DeferDeserialize {
fn serialize<W: std::io::prelude::Write>(&self, writer: &mut W) -> std::io::Result<()> {
writer.write_all(&self.0)?;
Ok(())
}
}

impl BorshDeserialize for DeferDeserialize {
fn deserialize_reader<R: Read>(reader: &mut R) -> std::io::Result<Self> {
let mut inner = Vec::new();
Expand Down

0 comments on commit c5dd019

Please sign in to comment.