Skip to content
5 changes: 5 additions & 0 deletions packages/sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Unreleased

### Added

- deserialize function for DeployModulePayload implemented instead of throwing an exception of not supporting deserialize


## 11.0.0

### Fixed
Expand Down
17 changes: 15 additions & 2 deletions packages/sdk/src/accountTransactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,21 @@ export class DeployModuleHandler implements AccountTransactionHandler<DeployModu
}
}

deserialize(): DeployModulePayload {
throw new Error('deserialize not supported');
deserialize(serializePayload:Cursor): DeployModulePayload {
const moduleVersion = serializePayload.read(4); // version
const moduleLength = serializePayload.read(4)?.readUInt32BE(0); // length
const moduleSource = serializePayload.read(moduleLength); // wasm module

if(moduleVersion) {
return {
source: new Uint8Array(moduleSource),
version: moduleVersion.readUInt32BE(0),
};
} else {
return {
source: new Uint8Array(moduleSource)
};
}
}

toJSON(payload: DeployModulePayload): DeployModulePayloadJSON {
Expand Down