Skip to content

Commit

Permalink
Ensure Wasm Bytecode Length
Browse files Browse the repository at this point in the history
  • Loading branch information
joelsmith-2019 committed Oct 2, 2024
1 parent e08f0c1 commit 62a7ae1
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion wormchain/contracts/tools/deploy_wormchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,20 @@ async function main() {
};
vaa.signatures = sign(VAA_SIGNERS, vaa as unknown as VAA<Payload>);
console.log("uploading", file);

let bytes = new Uint8Array(contract_bytes);
// ensure bytes array is a multiple of 4
if (bytes.length % 4 !== 0) {
const extraBytes = 4 - (bytes.length % 4);
const newBytes = new Uint8Array(bytes.length + extraBytes);
newBytes.set(bytes, extraBytes);
bytes = newBytes;
}

const msg = client.core.msgStoreCode({
value: {
signer,
wasmByteCode: new Uint8Array(contract_bytes),
wasmByteCode: bytes,
vaa: hexToUint8Array(serialiseVAA(vaa as unknown as VAA<Payload>)),
}
});
Expand Down

0 comments on commit 62a7ae1

Please sign in to comment.