From 62a7ae1b8d6fc215ab8d57278eaa505c5d50f268 Mon Sep 17 00:00:00 2001 From: Joel Smith Date: Wed, 2 Oct 2024 15:11:52 -0500 Subject: [PATCH] Ensure Wasm Bytecode Length --- wormchain/contracts/tools/deploy_wormchain.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/wormchain/contracts/tools/deploy_wormchain.ts b/wormchain/contracts/tools/deploy_wormchain.ts index d2bdc6d777..bd57b55662 100644 --- a/wormchain/contracts/tools/deploy_wormchain.ts +++ b/wormchain/contracts/tools/deploy_wormchain.ts @@ -147,10 +147,20 @@ async function main() { }; vaa.signatures = sign(VAA_SIGNERS, vaa as unknown as VAA); 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)), } });