diff --git a/x/programs/cmd/simulator/cmd/plan.go b/x/programs/cmd/simulator/cmd/plan.go index fc06804bd7..b548acbeff 100644 --- a/x/programs/cmd/simulator/cmd/plan.go +++ b/x/programs/cmd/simulator/cmd/plan.go @@ -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 @@ -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"` @@ -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 { diff --git a/x/programs/rust/examples/multisig/src/lib.rs b/x/programs/rust/examples/multisig/src/lib.rs index 1e20ab59cf..46094529b5 100644 --- a/x/programs/rust/examples/multisig/src/lib.rs +++ b/x/programs/rust/examples/multisig/src/lib.rs @@ -114,7 +114,6 @@ pub fn vote(context: Context, id: u32, yea: bool) -> Result<(), Propo let actor = context.actor(); let voters: Vec<_> = (0..proposal.voters_len) - .into_iter() .map(|i| { program .state() @@ -536,8 +535,7 @@ mod tests { .unwrap() .unwrap(); - let id_serialized: Vec = res.deserialize().unwrap(); - let id: u32 = borsh::from_slice(&id_serialized).unwrap(); + let id: u32 = res.deserialize().unwrap(); assert_eq!(id, 1); } diff --git a/x/programs/rust/wasmlanche-sdk/src/program.rs b/x/programs/rust/wasmlanche-sdk/src/program.rs index 7490b1ca9d..f4f3ea7929 100644 --- a/x/programs/rust/wasmlanche-sdk/src/program.rs +++ b/x/programs/rust/wasmlanche-sdk/src/program.rs @@ -12,7 +12,6 @@ use thiserror::Error; /// Defer deserialization from bytes ///
It is possible that this type performs multiple allocations during deserialization. It should be used sparingly.
#[cfg_attr(feature = "debug", derive(Debug))] -#[derive(BorshSerialize)] pub struct DeferDeserialize(Vec); impl DeferDeserialize { @@ -24,6 +23,13 @@ impl DeferDeserialize { } } +impl BorshSerialize for DeferDeserialize { + fn serialize(&self, writer: &mut W) -> std::io::Result<()> { + writer.write_all(&self.0)?; + Ok(()) + } +} + impl BorshDeserialize for DeferDeserialize { fn deserialize_reader(reader: &mut R) -> std::io::Result { let mut inner = Vec::new();