clients/js: Add support for parsing payload3 + test parser
commit-id:d9fb5d95
This commit is contained in:
parent
33fce26f35
commit
1b4c97cd67
|
@ -136,7 +136,7 @@ export async function getImplementation(
|
|||
return (await getStorageAt(rpc, contract_address, _IMPLEMENTATION_SLOT, ["address"]))[0]
|
||||
}
|
||||
|
||||
export async function execute_governance_evm(
|
||||
export async function execute_evm(
|
||||
payload: Payload,
|
||||
vaa: Buffer,
|
||||
network: "MAINNET" | "TESTNET" | "DEVNET",
|
||||
|
@ -243,8 +243,17 @@ export async function execute_governance_evm(
|
|||
console.log("Registering chain")
|
||||
console.log("Hash: " + (await tb.registerChain(vaa, overrides)).hash)
|
||||
break
|
||||
case "Transfer":
|
||||
console.log("Completing transfer")
|
||||
console.log("Hash: " + (await tb.completeTransfer(vaa, overrides)).hash)
|
||||
break
|
||||
case "TransferWithPayload":
|
||||
console.log("Completing transfer with payload")
|
||||
console.log("Hash: " + (await tb.completeTransferWithPayload(vaa, overrides)).hash)
|
||||
break
|
||||
default:
|
||||
throw Error(`VAA is of type ${payload.type}, which is not a governance action`)
|
||||
impossible(payload)
|
||||
break
|
||||
|
||||
}
|
||||
break
|
||||
|
|
|
@ -5,9 +5,9 @@ import { hideBin } from "yargs/helpers";
|
|||
|
||||
import { Bech32, fromBech32, toHex } from "@cosmjs/encoding";
|
||||
import { isTerraChain, assertEVMChain, CONTRACTS, setDefaultWasm } from "@certusone/wormhole-sdk";
|
||||
import { execute_governance_solana } from "./solana";
|
||||
import { execute_governance_evm, getImplementation, hijack_evm, query_contract_evm, setStorageAt } from "./evm";
|
||||
import { execute_governance_terra } from "./terra";
|
||||
import { execute_solana } from "./solana";
|
||||
import { execute_evm, getImplementation, hijack_evm, query_contract_evm, setStorageAt } from "./evm";
|
||||
import { execute_terra } from "./terra";
|
||||
import * as vaa from "./vaa";
|
||||
import { impossible, Payload, serialiseVAA, VAA } from "./vaa";
|
||||
import {
|
||||
|
@ -177,7 +177,18 @@ yargs(hideBin(process.argv))
|
|||
});
|
||||
},
|
||||
async (argv) => {
|
||||
const buf = Buffer.from(String(argv.vaa), "hex");
|
||||
let buf: Buffer;
|
||||
try {
|
||||
buf = Buffer.from(String(argv.vaa), "hex")
|
||||
if (buf.length == 0) {
|
||||
throw Error("Couldn't parse VAA as hex")
|
||||
}
|
||||
} catch (e) {
|
||||
buf = Buffer.from(String(argv.vaa), "base64")
|
||||
if (buf.length == 0) {
|
||||
throw Error("Couldn't parse VAA as base64 or hex")
|
||||
}
|
||||
}
|
||||
const parsed_vaa = vaa.parse(buf);
|
||||
let parsed_vaa_with_digest = parsed_vaa;
|
||||
parsed_vaa_with_digest['digest'] = vaa.vaaDigest(parsed_vaa);
|
||||
|
@ -495,11 +506,11 @@ yargs(hideBin(process.argv))
|
|||
"This VAA does not specify the target chain, please provide it by hand using the '--chain' flag."
|
||||
);
|
||||
} else if (isEVMChain(chain)) {
|
||||
await execute_governance_evm(parsed_vaa.payload, buf, network, chain, argv["contract-address"], argv["rpc"]);
|
||||
await execute_evm(parsed_vaa.payload, buf, network, chain, argv["contract-address"], argv["rpc"]);
|
||||
} else if (isTerraChain(chain)) {
|
||||
await execute_governance_terra(parsed_vaa.payload, buf, network, chain);
|
||||
await execute_terra(parsed_vaa.payload, buf, network, chain);
|
||||
} else if (chain === "solana") {
|
||||
await execute_governance_solana(parsed_vaa, buf, network);
|
||||
await execute_solana(parsed_vaa, buf, network);
|
||||
} else if (chain === "algorand") {
|
||||
throw Error("Algorand is not supported yet");
|
||||
} else if (chain === "near") {
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"@celo-tools/celo-ethers-wrapper": "^0.1.0",
|
||||
"@certusone/wormhole-sdk": "^0.4.4",
|
||||
"@certusone/wormhole-sdk": "^0.4.5",
|
||||
"@cosmjs/encoding": "^0.26.2",
|
||||
"@solana/web3.js": "^1.22.0",
|
||||
"@terra-money/terra.js": "^3.1.3",
|
||||
|
@ -543,9 +543,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@certusone/wormhole-sdk": {
|
||||
"version": "0.4.4",
|
||||
"resolved": "https://registry.npmjs.org/@certusone/wormhole-sdk/-/wormhole-sdk-0.4.4.tgz",
|
||||
"integrity": "sha512-3/7nuNEMWIZU0LnjvMqRxcoVKo34Cw9VFt/QE9fWRtVFY3PFrYGmdBSAIYjH6JZ73jQj/CawKFCoRr0SLjrPxw==",
|
||||
"version": "0.4.5",
|
||||
"resolved": "https://registry.npmjs.org/@certusone/wormhole-sdk/-/wormhole-sdk-0.4.5.tgz",
|
||||
"integrity": "sha512-Wx726yI7zTIaDM2h/Ffrz3tjCKh4ZO5PDvwq/m5iVv6HqnL6xjrS6g8Qnq/K68cOMIJcxrqLW2SNl3vLUMLT7w==",
|
||||
"dependencies": {
|
||||
"@improbable-eng/grpc-web": "^0.14.0",
|
||||
"@solana/spl-token": "^0.1.8",
|
||||
|
@ -10949,9 +10949,9 @@
|
|||
"requires": {}
|
||||
},
|
||||
"@certusone/wormhole-sdk": {
|
||||
"version": "0.4.4",
|
||||
"resolved": "https://registry.npmjs.org/@certusone/wormhole-sdk/-/wormhole-sdk-0.4.4.tgz",
|
||||
"integrity": "sha512-3/7nuNEMWIZU0LnjvMqRxcoVKo34Cw9VFt/QE9fWRtVFY3PFrYGmdBSAIYjH6JZ73jQj/CawKFCoRr0SLjrPxw==",
|
||||
"version": "0.4.5",
|
||||
"resolved": "https://registry.npmjs.org/@certusone/wormhole-sdk/-/wormhole-sdk-0.4.5.tgz",
|
||||
"integrity": "sha512-Wx726yI7zTIaDM2h/Ffrz3tjCKh4ZO5PDvwq/m5iVv6HqnL6xjrS6g8Qnq/K68cOMIJcxrqLW2SNl3vLUMLT7w==",
|
||||
"requires": {
|
||||
"@improbable-eng/grpc-web": "^0.14.0",
|
||||
"@solana/spl-token": "^0.1.8",
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"@celo-tools/celo-ethers-wrapper": "^0.1.0",
|
||||
"@certusone/wormhole-sdk": "^0.4.4",
|
||||
"@certusone/wormhole-sdk": "^0.4.5",
|
||||
"@solana/web3.js": "^1.22.0",
|
||||
"@cosmjs/encoding": "^0.26.2",
|
||||
"@terra-money/terra.js": "^3.1.3",
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
{
|
||||
version: 1,
|
||||
guardianSetIndex: 1,
|
||||
signatures: [
|
||||
{
|
||||
guardianSetIndex: 2,
|
||||
signature: '73af3c2f55989041b0068a4eaeba8f8825106021996de6143954c06fc4cfad5c3f1aba6ca951188e962f11251c25ca98628685e2fc2b65ec609450cfc4e6511200'
|
||||
},
|
||||
{
|
||||
guardianSetIndex: 3,
|
||||
signature: '00c62eb0de7ab3d028920f18e10df7f2a04d00eb88b8940a27bbce8ce66c67526882c96cc50dd381bdbff30bb65b9347cadff09676729043af60d652a0b9063000'
|
||||
},
|
||||
{
|
||||
guardianSetIndex: 4,
|
||||
signature: 'f07b0fe6cab18be7ae827fe11ca8992ff0b5a2a32d65be958231bf84cf6b14fb5eeb8a51ade1c70aa5b8b8cf83afe3c22d3471481bda3896ea2a70469f9692b800'
|
||||
},
|
||||
{
|
||||
guardianSetIndex: 5,
|
||||
signature: '74d496729dde6e190959a17945e87cd95e23c10047ab2eef5c7d0ec6f91208c7279d8a1b1f4a60069d25932a67d655f2d0b42059003de75fd3ca7992fdd1b0d401'
|
||||
},
|
||||
{
|
||||
guardianSetIndex: 6,
|
||||
signature: '51f06ab6fdfd42f323840a818b38cfd1c99d22366c877903b98df40bdaf2a2042eb8cd0e59c4637e6a80a199b1108cd7659ba8370f6f9476b479839854d8c1a600'
|
||||
},
|
||||
{
|
||||
guardianSetIndex: 7,
|
||||
signature: '784b37c6103c752cd97a586be8e1ceff22a6e488433284ff31cd908b5c7d87e244da7516d07a0fa692684f826e5e6c8b452004206d6fe5bae46afb1c218cf50d00'
|
||||
},
|
||||
{
|
||||
guardianSetIndex: 9,
|
||||
signature: '0b6ccce67ed501cb20fb06de76b9083f1329ad78d384517a94ab8e9aa601be7a0f00bb603b36504a74ddc367359c8ea07f5ccd5022772cc157e00f54156371e401'
|
||||
},
|
||||
{
|
||||
guardianSetIndex: 11,
|
||||
signature: 'e1e6b712a2353e4907929c4057d5babef80dc09febb3dc2934f44048795eef954e99106cb29b1a8d935369daecbb8bae45192efc3cedbc57315d67ec9ea8000a00'
|
||||
},
|
||||
{
|
||||
guardianSetIndex: 13,
|
||||
signature: 'dcc04cd7556a94e8b418dc3a8a00efb128d4f76f71431247a92e7a19a833fc02215d1fd69e0e596da531ea587ae2ac2f36d20f3b1933060ad6ef3e9d7d8475ba01'
|
||||
},
|
||||
{
|
||||
guardianSetIndex: 14,
|
||||
signature: 'c76216494906aed8d8310c31a5e4a545ea2af8dbe38eeb74a3d14f0734dd2b1a21b9850ea20e6c2ca42248788bfb17439d37abda25d705b568b265b113b976c500'
|
||||
},
|
||||
{
|
||||
guardianSetIndex: 16,
|
||||
signature: 'c61fe6ebea61f2cae895c334965070487d39ab6bf04428340af0f7699fddd3c01e0c86daea9eb449701248a24fa4c0ff75fb600b2c0134bd721791f667116e4200'
|
||||
},
|
||||
{
|
||||
guardianSetIndex: 17,
|
||||
signature: '19b79caa250e75da1482c7f412687308d13ef700f726b99417bb75ae6dd143fc619f8c9c29c73f9949affd1629cc286a61917ed7853754a46702920b76cf90eb00'
|
||||
},
|
||||
{
|
||||
guardianSetIndex: 18,
|
||||
signature: 'b0bab5e1a8b321e92f9d3df92430183e4843e57c6f8c15c22d62b2f8e4b8cdc2759f2854b8d122acdb4b4d8928b87df4199cc683011d2e9b7d41a96d8b480ccc01'
|
||||
}
|
||||
],
|
||||
timestamp: 0,
|
||||
nonce: 969194102,
|
||||
emitterChain: 1,
|
||||
emitterAddress: '0x0000000000000000000000000000000000000000000000000000000000000004',
|
||||
sequence: 2694510404604284400n,
|
||||
consistencyLevel: 32,
|
||||
payload: {
|
||||
module: 'TokenBridge',
|
||||
type: 'ContractUpgrade',
|
||||
chain: 3,
|
||||
address: '0x0000000000000000000000000000000000000000000000000000000000000983'
|
||||
},
|
||||
digest: '0x1eb0950bc47db17fbf95bf5476a83445cf5bee90fcd14ae4d8ac851c2cbd824d'
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
AQAAAAENAnOvPC9VmJBBsAaKTq66j4glEGAhmW3mFDlUwG/Ez61cPxq6bKlRGI6WLxElHCXKmGKGheL8K2XsYJRQz8TmURIAAwDGLrDeerPQKJIPGOEN9/KgTQDriLiUCie7zozmbGdSaILJbMUN04G9v/MLtluTR8rf8JZ2cpBDr2DWUqC5BjAABPB7D+bKsYvnroJ/4RyomS/wtaKjLWW+lYIxv4TPaxT7XuuKUa3hxwqluLjPg6/jwi00cUgb2jiW6ipwRp+WkrgABXTUlnKd3m4ZCVmheUXofNleI8EAR6su71x9Dsb5EgjHJ52KGx9KYAadJZMqZ9ZV8tC0IFkAPedf08p5kv3RsNQBBlHwarb9/ULzI4QKgYs4z9HJnSI2bId5A7mN9Ava8qIELrjNDlnEY35qgKGZsRCM12WbqDcPb5R2tHmDmFTYwaYAB3hLN8YQPHUs2XpYa+jhzv8ipuSIQzKE/zHNkItcfYfiRNp1FtB6D6aSaE+Cbl5si0UgBCBtb+W65Gr7HCGM9Q0ACQtszOZ+1QHLIPsG3na5CD8TKa1404RRepSrjpqmAb56DwC7YDs2UEp03cNnNZyOoH9czVAidyzBV+APVBVjceQBC+HmtxKiNT5JB5KcQFfVur74DcCf67PcKTT0QEh5Xu+VTpkQbLKbGo2TU2na7LuLrkUZLvw87bxXMV1n7J6oAAoADdzATNdVapTotBjcOooA77Eo1PdvcUMSR6kuehmoM/wCIV0f1p4OWW2lMepYeuKsLzbSDzsZMwYK1u8+nX2EdboBDsdiFklJBq7Y2DEMMaXkpUXqKvjb447rdKPRTwc03SsaIbmFDqIObCykIkh4i/sXQ503q9ol1wW1aLJlsRO5dsUAEMYf5uvqYfLK6JXDNJZQcEh9Oatr8EQoNArw92mf3dPAHgyG2uqetElwEkiiT6TA/3X7YAssATS9cheR9mcRbkIAERm3nKolDnXaFILH9BJocwjRPvcA9ya5lBe7da5t0UP8YZ+MnCnHP5lJr/0WKcwoamGRfteFN1SkZwKSC3bPkOsAErC6teGosyHpL509+SQwGD5IQ+V8b4wVwi1isvjkuM3CdZ8oVLjRIqzbS02JKLh99BmcxoMBHS6bfUGpbYtIDMwBAAAAADnEunYAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEJWTS79YITfAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAVG9rZW5CcmlkZ2UCAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJgw==
|
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
version: 1,
|
||||
guardianSetIndex: 0,
|
||||
signatures: [
|
||||
{
|
||||
guardianSetIndex: 0,
|
||||
signature: 'fd4cdd0e5a1afd9eb6555770fb132bf03ed8fa1f9e92c6adcec7881ace2ba4ba4c1b350f79da4110d3307053ceb217e4398eaf02be5474a90bd694b0d2ccbdcc01'
|
||||
}
|
||||
],
|
||||
timestamp: 0,
|
||||
nonce: 3131396565,
|
||||
emitterChain: 1,
|
||||
emitterAddress: '0x0000000000000000000000000000000000000000000000000000000000000004',
|
||||
sequence: 11817436337286722732n,
|
||||
consistencyLevel: 32,
|
||||
payload: {
|
||||
module: 'TokenBridge',
|
||||
type: 'TransferWithPayload',
|
||||
amount: 1000000n,
|
||||
tokenAddress: '0x165809739240a0ac03b98440fe8985548e3aa683cd0d4d9df5b5659669faa301',
|
||||
tokenChain: 1,
|
||||
toAddress: '0x0000000000000000000000007c4dfd6be62406e7f5a05eec96300da4048e70ff',
|
||||
chain: 2,
|
||||
fromAddress: '0x0000000000000000000000000000000000000000000000000000000000000000',
|
||||
payload: '0x00000000000005de4c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e73656374657475722061646970697363696e6720656c69742e204375726162697475722074656d7075732c206e6571756520656765742068656e64726572697420626962656e64756d2c20616e746520616e7465206469676e697373696d2065782c207175697320616363756d73616e20656c6974206175677565206e6563206c656f2e2050726f696e207669746165206a7573746f207669746165206c6163757320706f737565726520706f72747469746f722e204d61757269732073656420736167697474697320697073756d2e204d6f726269206d61737361206d61676e612c20706f7375657265206e6f6e20696163756c697320656765742c20756c74726963696573206174206c6967756c612e20446f6e656320756c74726963696573206e697369206573742c206574206c6f626f727469732073656d2073616769747469732073697420616d65742e20446f6e6563206665756769617420646f6c6f722061206f64696f2064696374756d2c20736564206c616f72656574206d61676e6120656765737461732e205175697371756520756c7472696369657320666163696c69736973206172637520617420616363756d73616e2e20496e20696163756c697320617420707572757320696e207472697374697175652e204d616563656e617320706f72747469746f722c206e69736c20612073656d706572206d616c6573756164612c2074656c6c7573206e65717565206d616c657375616461206c656f2c2071756973206d6f6c65737469652066656c6973206e69626820696e2065726f732e20446f6e656320766976657272612061726375206e6563206e756e63207072657469756d2c206567657420756c6c616d636f7270657220707572757320706f73756572652e2053757370656e646973736520706f74656e74692e204e616d2067726176696461206c656f206e6563207175616d2074696e636964756e7420766976657272612e205072616573656e74206163207375736369706974206f7263692e20566976616d757320736f64616c6573206d6178696d757320626c616e6469742e2050656c6c656e74657371756520696d706572646965742075726e61206174206e756e63206d616c6573756164612c20696e20617563746f72206d6173736120616c697175616d2e2050656c6c656e746573717565207363656c6572697371756520657569736d6f64206f64696f20612074656d706f722e204e756c6c612073656420706f7274612070757275732c20657520706f727461206f64696f2e20457469616d207175697320706c616365726174206e756c6c612e204e756e6320696e20636f6d6d6f646f206d692c20657520736f64616c6573206e756e632e20416c697175616d206c7563747573206c6f72656d2065742074696e636964756e74206c6163696e69612e20447569732076656c20697073756d206e69736c2e205072616573656e7420636f6e76616c6c697320656c6974206c6967756c612c206e656320706f72746120657374206d6178696d75732061632e204e756c6c61207072657469756d206c696265726f206567657420616e746520756c6c616d636f72706572206d61747469732e204e756c6c616d20766f6c75747061742c2074656c6c757320736564207363656c65726973717565206566666963697475722c206e69736c2061756775652070686172657472612066656c69732c2076656c2067726176696461206d61676e612075726e6120736564207175616d2e2044756973206964207072657469756d206475692e20496e74656765722072686f6e637573206d6174746973206a7573746f20612068656e6472657269742e20467573636520646f6c6f72206d61676e612c20706f72747469746f7220616320707572757320736f64616c65732c20657569736d6f6420766573746962756c756d20746f72746f722e20416c697175616d2070686172657472612065726174206a7573746f2c20696e20756c6c616d636f72706572207175616d2e'
|
||||
},
|
||||
digest: '0xfc3ce17da88ca9085135a7180b5da44808f04fd9b55b26ed14b45cbec96a0e58'
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
01000000000100fd4cdd0e5a1afd9eb6555770fb132bf03ed8fa1f9e92c6adcec7881ace2ba4ba4c1b350f79da4110d3307053ceb217e4398eaf02be5474a90bd694b0d2ccbdcc0100000000baa551d500010000000000000000000000000000000000000000000000000000000000000004a3fff7bcbfc4b4ac200300000000000000000000000000000000000000000000000000000000000f4240165809739240a0ac03b98440fe8985548e3aa683cd0d4d9df5b5659669faa30100010000000000000000000000007c4dfd6be62406e7f5a05eec96300da4048e70ff0002000000000000000000000000000000000000000000000000000000000000000000000000000005de4c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e73656374657475722061646970697363696e6720656c69742e204375726162697475722074656d7075732c206e6571756520656765742068656e64726572697420626962656e64756d2c20616e746520616e7465206469676e697373696d2065782c207175697320616363756d73616e20656c6974206175677565206e6563206c656f2e2050726f696e207669746165206a7573746f207669746165206c6163757320706f737565726520706f72747469746f722e204d61757269732073656420736167697474697320697073756d2e204d6f726269206d61737361206d61676e612c20706f7375657265206e6f6e20696163756c697320656765742c20756c74726963696573206174206c6967756c612e20446f6e656320756c74726963696573206e697369206573742c206574206c6f626f727469732073656d2073616769747469732073697420616d65742e20446f6e6563206665756769617420646f6c6f722061206f64696f2064696374756d2c20736564206c616f72656574206d61676e6120656765737461732e205175697371756520756c7472696369657320666163696c69736973206172637520617420616363756d73616e2e20496e20696163756c697320617420707572757320696e207472697374697175652e204d616563656e617320706f72747469746f722c206e69736c20612073656d706572206d616c6573756164612c2074656c6c7573206e65717565206d616c657375616461206c656f2c2071756973206d6f6c65737469652066656c6973206e69626820696e2065726f732e20446f6e656320766976657272612061726375206e6563206e756e63207072657469756d2c206567657420756c6c616d636f7270657220707572757320706f73756572652e2053757370656e646973736520706f74656e74692e204e616d2067726176696461206c656f206e6563207175616d2074696e636964756e7420766976657272612e205072616573656e74206163207375736369706974206f7263692e20566976616d757320736f64616c6573206d6178696d757320626c616e6469742e2050656c6c656e74657371756520696d706572646965742075726e61206174206e756e63206d616c6573756164612c20696e20617563746f72206d6173736120616c697175616d2e2050656c6c656e746573717565207363656c6572697371756520657569736d6f64206f64696f20612074656d706f722e204e756c6c612073656420706f7274612070757275732c20657520706f727461206f64696f2e20457469616d207175697320706c616365726174206e756c6c612e204e756e6320696e20636f6d6d6f646f206d692c20657520736f64616c6573206e756e632e20416c697175616d206c7563747573206c6f72656d2065742074696e636964756e74206c6163696e69612e20447569732076656c20697073756d206e69736c2e205072616573656e7420636f6e76616c6c697320656c6974206c6967756c612c206e656320706f72746120657374206d6178696d75732061632e204e756c6c61207072657469756d206c696265726f206567657420616e746520756c6c616d636f72706572206d61747469732e204e756c6c616d20766f6c75747061742c2074656c6c757320736564207363656c65726973717565206566666963697475722c206e69736c2061756775652070686172657472612066656c69732c2076656c2067726176696461206d61676e612075726e6120736564207175616d2e2044756973206964207072657469756d206475692e20496e74656765722072686f6e637573206d6174746973206a7573746f20612068656e6472657269742e20467573636520646f6c6f72206d61676e612c20706f72747469746f7220616320707572757320736f64616c65732c20657569736d6f6420766573746962756c756d20746f72746f722e20416c697175616d2070686172657472612065726174206a7573746f2c20696e20756c6c616d636f72706572207175616d2e
|
|
@ -0,0 +1,45 @@
|
|||
{
|
||||
version: 1,
|
||||
guardianSetIndex: 0,
|
||||
signatures: [
|
||||
{
|
||||
guardianSetIndex: 0,
|
||||
signature: '7ac31b282c2aeeeb37f3385ee0de5f8e421d30b9e5ae8ba3d4375c1c77a86e77159bb697d9c456d6f8c02d22a94b1279b65b0d6a9957e7d3857423845ac758e300'
|
||||
}
|
||||
],
|
||||
timestamp: 1628094930,
|
||||
nonce: 3,
|
||||
emitterChain: 1,
|
||||
emitterAddress: '0x0000000000000000000000000000000000000000000000000000000000000004',
|
||||
sequence: 1337n,
|
||||
consistencyLevel: 0,
|
||||
payload: {
|
||||
module: 'Core',
|
||||
type: 'GuardianSetUpgrade',
|
||||
chain: 0,
|
||||
newGuardianSetIndex: 1,
|
||||
newGuardianSetLength: 19,
|
||||
newGuardianSet: [
|
||||
'58cc3ae5c097b213ce3c81979e1b9f9570746aa5',
|
||||
'ff6cb952589bde862c25ef4392132fb9d4a42157',
|
||||
'114de8460193bdf3a2fcf81f86a09765f4762fd1',
|
||||
'107a0086b32d7a0977926a205131d8731d39cbeb',
|
||||
'8c82b2fd82faed2711d59af0f2499d16e726f6b2',
|
||||
'11b39756c042441be6d8650b69b54ebe715e2343',
|
||||
'54ce5b4d348fb74b958e8966e2ec3dbd4958a7cd',
|
||||
'eb5f7389fa26941519f0863349c223b73a6ddee7',
|
||||
'74a3bf913953d695260d88bc1aa25a4eee363ef0',
|
||||
'000ac0076727b35fbea2dac28fee5ccb0fea768e',
|
||||
'af45ced136b9d9e24903464ae889f5c8a723fc14',
|
||||
'f93124b7c738843cbb89e864c862c38cddcccf95',
|
||||
'd2cc37a4dc036a8d232b48f62cdd4731412f4890',
|
||||
'da798f6896a3331f64b48c12d1d57fd9cbe70811',
|
||||
'71aa1be1d36cafe3867910f99c09e347899c19c3',
|
||||
'8192b6e7387ccd768277c17dab1b7a5027c0b3cf',
|
||||
'178e21ad2e77ae06711549cfbb1f9c7a9d8096e8',
|
||||
'5e1487f35515d02a92753504a8d75471b9f49edb',
|
||||
'6fbebc898f403e4773e95feb15e80c9a99c8348d'
|
||||
]
|
||||
},
|
||||
digest: '0xed3a5600d44b9dcc889daf0178dd69ab1e9356308194ba3628a7b720ae48a8d5'
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
010000000001007ac31b282c2aeeeb37f3385ee0de5f8e421d30b9e5ae8ba3d4375c1c77a86e77159bb697d9c456d6f8c02d22a94b1279b65b0d6a9957e7d3857423845ac758e300610ac1d2000000030001000000000000000000000000000000000000000000000000000000000000000400000000000005390000000000000000000000000000000000000000000000000000000000436f7265020000000000011358cc3ae5c097b213ce3c81979e1b9f9570746aa5ff6cb952589bde862c25ef4392132fb9d4a42157114de8460193bdf3a2fcf81f86a09765f4762fd1107a0086b32d7a0977926a205131d8731d39cbeb8c82b2fd82faed2711d59af0f2499d16e726f6b211b39756c042441be6d8650b69b54ebe715e234354ce5b4d348fb74b958e8966e2ec3dbd4958a7cdeb5f7389fa26941519f0863349c223b73a6ddee774a3bf913953d695260d88bc1aa25a4eee363ef0000ac0076727b35fbea2dac28fee5ccb0fea768eaf45ced136b9d9e24903464ae889f5c8a723fc14f93124b7c738843cbb89e864c862c38cddcccf95d2cc37a4dc036a8d232b48f62cdd4731412f4890da798f6896a3331f64b48c12d1d57fd9cbe7081171aa1be1d36cafe3867910f99c09e347899c19c38192b6e7387ccd768277c17dab1b7a5027c0b3cf178e21ad2e77ae06711549cfbb1f9c7a9d8096e85e1487f35515d02a92753504a8d75471b9f49edb6fbebc898f403e4773e95feb15e80c9a99c8348d
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
version: 1,
|
||||
guardianSetIndex: 0,
|
||||
signatures: [
|
||||
{
|
||||
guardianSetIndex: 0,
|
||||
signature: '1890714264dbbc8022a58df0c12b436d588b20b6304b38c383bda1d7fc101bb2443081e6d42719bce602116a1491b10d4666967da9f8d922079759c972ed37b401'
|
||||
}
|
||||
],
|
||||
timestamp: 0,
|
||||
nonce: 420751607,
|
||||
emitterChain: 1,
|
||||
emitterAddress: '0x0000000000000000000000000000000000000000000000000000000000000004',
|
||||
sequence: 17854666897793422727n,
|
||||
consistencyLevel: 32,
|
||||
payload: {
|
||||
module: 'TokenBridge',
|
||||
type: 'RegisterChain',
|
||||
chain: 0,
|
||||
emitterChain: 1,
|
||||
emitterAddress: '0x95f83a27e90c622a98c037353f271fd8f5f57b4dc18ebf5ff75a934724bd0491'
|
||||
},
|
||||
digest: '0xe596e88c14b9cd45c350bb4811b9a29bc1fc7069300e4204e034b1ab7c23d820'
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
010000000001001890714264dbbc8022a58df0c12b436d588b20b6304b38c383bda1d7fc101bb2443081e6d42719bce602116a1491b10d4666967da9f8d922079759c972ed37b40100000000191428f700010000000000000000000000000000000000000000000000000000000000000004f7c884f209e7158720000000000000000000000000000000000000000000546f6b656e427269646765010000000195f83a27e90c622a98c037353f271fd8f5f57b4dc18ebf5ff75a934724bd0491
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
version: 1,
|
||||
guardianSetIndex: 0,
|
||||
signatures: [
|
||||
{
|
||||
guardianSetIndex: 0,
|
||||
signature: '7d204ad9447c4dfd6be62406e7f5a05eec96300da4048e70ff530cfb52aec44807e98194990710ff166eb1b2eac942d38bc1cd6018f93662a6578d985e87c8d001'
|
||||
}
|
||||
],
|
||||
timestamp: 1646343275,
|
||||
nonce: 47293,
|
||||
emitterChain: 1,
|
||||
emitterAddress: '0xc69a1b1a65dd336bf1df6a77afb501fc25db7fc0938cb08595a9ef473265cb4f',
|
||||
sequence: 3n,
|
||||
consistencyLevel: 32,
|
||||
payload: {
|
||||
module: 'TokenBridge',
|
||||
type: 'Transfer',
|
||||
amount: 10000000000n,
|
||||
tokenAddress: '0x165809739240a0ac03b98440fe8985548e3aa683cd0d4d9df5b5659669faa301',
|
||||
tokenChain: 1,
|
||||
toAddress: '0x000000000000000000000000c10820983f33456ce7beb3a046f5a83fa34f027d',
|
||||
chain: 2,
|
||||
fee: 0n
|
||||
},
|
||||
digest: '0x2862e5873955ea104bb3e122831bdc43bbcb413da5b1123514640b950d038967'
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
010000000001007d204ad9447c4dfd6be62406e7f5a05eec96300da4048e70ff530cfb52aec44807e98194990710ff166eb1b2eac942d38bc1cd6018f93662a6578d985e87c8d0016221346b0000b8bd0001c69a1b1a65dd336bf1df6a77afb501fc25db7fc0938cb08595a9ef473265cb4f0000000000000003200100000000000000000000000000000000000000000000000000000002540be400165809739240a0ac03b98440fe8985548e3aa683cd0d4d9df5b5659669faa3010001000000000000000000000000c10820983f33456ce7beb3a046f5a83fa34f027d00020000000000000000000000000000000000000000000000000000000000000000
|
|
@ -0,0 +1,75 @@
|
|||
{
|
||||
version: 1,
|
||||
guardianSetIndex: 1,
|
||||
signatures: [
|
||||
{
|
||||
guardianSetIndex: 0,
|
||||
signature: '78588270e30e3b4cf74572b6ad4270cdd7932079692170fddaf369c7574722b75defcecf5d372cdd8fdba0f275c6b902434259b5d7da8402e25ca852ca5affaa00'
|
||||
},
|
||||
{
|
||||
guardianSetIndex: 3,
|
||||
signature: 'a8888cf66158970861329efa69ff2461d847078cec22fd7f62606b17a1ae283127712fa50dc365faa1e6db339fefce57b13c74c2dce7d14b79051676c74bb68500'
|
||||
},
|
||||
{
|
||||
guardianSetIndex: 4,
|
||||
signature: '87272398eb59763bb1e2466f9ebdea4e75c290b6c0386f07c20e1296b1976cb814547378922dbc5490b7fcf7279eafc0c08bd59ca97c4dbbcbd478967e17aa2d00'
|
||||
},
|
||||
{
|
||||
guardianSetIndex: 6,
|
||||
signature: 'dd38ecb6233f1cd872a75cc0627ded36aa8f89095436f7dbe32e6655e27f217459fda35a3d7f1d656962160bfeee4e5fc6d2e1447559e7bc3ba760416317b86c01'
|
||||
},
|
||||
{
|
||||
guardianSetIndex: 7,
|
||||
signature: '92d27a749b398dc5f085e7bcd2e0f18d6262a1ba1916787ec01854c0ccde0a8247f8892e6dff83fad6839fc054f32734255e9037ff9adc33499514e2300ba43901'
|
||||
},
|
||||
{
|
||||
guardianSetIndex: 9,
|
||||
signature: '89f08688ae363783bfe3f25a5960a0791ce327bab7e7593393f91395e06fe50e3f7e13862ac86b9fd1f9720669bc4504e918f7e481c395f17a2fa131da05b9e701'
|
||||
},
|
||||
{
|
||||
guardianSetIndex: 10,
|
||||
signature: '097d187970710297d188a2ebaedff0ad13efd16872566bae8a56377e28466b2c3c4e47853c60fe716109e55f8b453fb03a34bb1929c96f74ebd796a476ec7ab600'
|
||||
},
|
||||
{
|
||||
guardianSetIndex: 11,
|
||||
signature: '68a19d198350b3caebd3c0159b8bbce022e0f026d013a1c83e40d6100c87e8bb0d692baca89cb77f4b6832dd7aaf3f2f7c482fd50be7221c046ae668228ec01300'
|
||||
},
|
||||
{
|
||||
guardianSetIndex: 12,
|
||||
signature: 'd6f464a174d7e34797e2869785feb5f05ab614be989d238c9bd55259dbdbab2568c14f316d1820ac766e513bf5225185f16d30f0f01a092af5fb6b072ad577f001'
|
||||
},
|
||||
{
|
||||
guardianSetIndex: 13,
|
||||
signature: '663f2f3ad62baa8ad541b9c38bb9df805d2cfa7072894526505b654293bacdee5e9e8c4ded7be92a3338b964482b3ce6d5275817d6a4b6a0663e1e84dcd1de3500'
|
||||
},
|
||||
{
|
||||
guardianSetIndex: 16,
|
||||
signature: '5f773ea1d7e74770e78c4779abe4594b6a46f9131304948265bc185dcb1cdba8114915e3b1d864f48e4c694c9578524e22752e2d898af4b8e67383d72a11856700'
|
||||
},
|
||||
{
|
||||
guardianSetIndex: 17,
|
||||
signature: '8bdbd5b5a820ecd215faf134b698402da04cc698e64464dd8df6692342e8c44314e1ae53bfde71fb2b00cd5691dae4f9b310c6150bdb551645a72863f4ff965c01'
|
||||
},
|
||||
{
|
||||
guardianSetIndex: 18,
|
||||
signature: '86c673c4f2213969d273b939318f93a5b50c665efa8c9e245a3b8823522dafec209b1be127e74a6d5c924831e339f8bffb769f7b0f5772ed16231700bf7eece200'
|
||||
}
|
||||
],
|
||||
timestamp: 1648399073,
|
||||
nonce: 62485,
|
||||
emitterChain: 1,
|
||||
emitterAddress: '0xec7372995d5cc8732397fb0ad35c0121e0eaa90d26f828a534cab54391b3a4f5',
|
||||
sequence: 110277n,
|
||||
consistencyLevel: 32,
|
||||
payload: {
|
||||
module: 'TokenBridge',
|
||||
type: 'Transfer',
|
||||
amount: 4100000000n,
|
||||
tokenAddress: '0x069b8857feab8184fb687f634618c035dac439dc1aeb3b5598a0f00000000001',
|
||||
tokenChain: 1,
|
||||
toAddress: '0x000000000000000000000000efd4aa8f954ebdea82b8757c029fc8475a45e9cd',
|
||||
chain: 2,
|
||||
fee: 0n
|
||||
},
|
||||
digest: '0xc90519b2bdfacac401d2d2c15a329d4e33e8ca15862685f0220ddc6074d7def5'
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
01000000010d0078588270e30e3b4cf74572b6ad4270cdd7932079692170fddaf369c7574722b75defcecf5d372cdd8fdba0f275c6b902434259b5d7da8402e25ca852ca5affaa0003a8888cf66158970861329efa69ff2461d847078cec22fd7f62606b17a1ae283127712fa50dc365faa1e6db339fefce57b13c74c2dce7d14b79051676c74bb685000487272398eb59763bb1e2466f9ebdea4e75c290b6c0386f07c20e1296b1976cb814547378922dbc5490b7fcf7279eafc0c08bd59ca97c4dbbcbd478967e17aa2d0006dd38ecb6233f1cd872a75cc0627ded36aa8f89095436f7dbe32e6655e27f217459fda35a3d7f1d656962160bfeee4e5fc6d2e1447559e7bc3ba760416317b86c010792d27a749b398dc5f085e7bcd2e0f18d6262a1ba1916787ec01854c0ccde0a8247f8892e6dff83fad6839fc054f32734255e9037ff9adc33499514e2300ba439010989f08688ae363783bfe3f25a5960a0791ce327bab7e7593393f91395e06fe50e3f7e13862ac86b9fd1f9720669bc4504e918f7e481c395f17a2fa131da05b9e7010a097d187970710297d188a2ebaedff0ad13efd16872566bae8a56377e28466b2c3c4e47853c60fe716109e55f8b453fb03a34bb1929c96f74ebd796a476ec7ab6000b68a19d198350b3caebd3c0159b8bbce022e0f026d013a1c83e40d6100c87e8bb0d692baca89cb77f4b6832dd7aaf3f2f7c482fd50be7221c046ae668228ec013000cd6f464a174d7e34797e2869785feb5f05ab614be989d238c9bd55259dbdbab2568c14f316d1820ac766e513bf5225185f16d30f0f01a092af5fb6b072ad577f0010d663f2f3ad62baa8ad541b9c38bb9df805d2cfa7072894526505b654293bacdee5e9e8c4ded7be92a3338b964482b3ce6d5275817d6a4b6a0663e1e84dcd1de3500105f773ea1d7e74770e78c4779abe4594b6a46f9131304948265bc185dcb1cdba8114915e3b1d864f48e4c694c9578524e22752e2d898af4b8e67383d72a11856700118bdbd5b5a820ecd215faf134b698402da04cc698e64464dd8df6692342e8c44314e1ae53bfde71fb2b00cd5691dae4f9b310c6150bdb551645a72863f4ff965c011286c673c4f2213969d273b939318f93a5b50c665efa8c9e245a3b8823522dafec209b1be127e74a6d5c924831e339f8bffb769f7b0f5772ed16231700bf7eece200624092e10000f4150001ec7372995d5cc8732397fb0ad35c0121e0eaa90d26f828a534cab54391b3a4f5000000000001aec5200100000000000000000000000000000000000000000000000000000000f4610900069b8857feab8184fb687f634618c035dac439dc1aeb3b5598a0f000000000010001000000000000000000000000efd4aa8f954ebdea82b8757c029fc8475a45e9cd00020000000000000000000000000000000000000000000000000000000000000000
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
version: 1,
|
||||
guardianSetIndex: 0,
|
||||
signatures: [
|
||||
{
|
||||
guardianSetIndex: 0,
|
||||
signature: '8638e51dd86542e6e225023d292aa05c086f3e509a431dcaeb0236c56ef41b41395806d9fcceaae5703c023f7b7b9248974f4f8884b7b73e5bcb8bc7d112566800'
|
||||
}
|
||||
],
|
||||
timestamp: 0,
|
||||
nonce: 76223656,
|
||||
emitterChain: 1,
|
||||
emitterAddress: '0xec7372995d5cc8732397fb0ad35c0121e0eaa90d26f828a534cab54391b3a4f5',
|
||||
sequence: 15670011184149708652n,
|
||||
consistencyLevel: 32,
|
||||
payload: {
|
||||
module: 'TokenBridge',
|
||||
type: 'Transfer',
|
||||
amount: 10000000n,
|
||||
tokenAddress: '0x165809739240a0ac03b98440fe8985548e3aa683cd0d4d9df5b5659669faa301',
|
||||
tokenChain: 1,
|
||||
toAddress: '0x000000000000000000000000c10820983f33456ce7beb3a046f5a83fa34f027d',
|
||||
chain: 3104,
|
||||
fee: 0n
|
||||
},
|
||||
digest: '0x52c4fa770f59ca51b1c1a49c423e76faa8001025a3ed1bfac9984b8d38554590'
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
010000000001008638e51dd86542e6e225023d292aa05c086f3e509a431dcaeb0236c56ef41b41395806d9fcceaae5703c023f7b7b9248974f4f8884b7b73e5bcb8bc7d11256680000000000048b14a80001ec7372995d5cc8732397fb0ad35c0121e0eaa90d26f828a534cab54391b3a4f5d977102611a43f6c20010000000000000000000000000000000000000000000000000000000000989680165809739240a0ac03b98440fe8985548e3aa683cd0d4d9df5b5659669faa3010001000000000000000000000000c10820983f33456ce7beb3a046f5a83fa34f027d0c200000000000000000000000000000000000000000000000000000000000000000
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
version: 1,
|
||||
guardianSetIndex: 0,
|
||||
signatures: [
|
||||
{
|
||||
guardianSetIndex: 0,
|
||||
signature: '1565b62bbf9978b1f9183ae985eb34f664fd4c850ec4ad8a38533281aec75eba2456f91c9a967cf4a70901aa0afed17ba39f1d779089b32eb88a47f7ea405e4b00'
|
||||
}
|
||||
],
|
||||
timestamp: 0,
|
||||
nonce: 637912343,
|
||||
emitterChain: 1,
|
||||
emitterAddress: '0x95f83a27e90c622a98c037353f271fd8f5f57b4dc18ebf5ff75a934724bd0491',
|
||||
sequence: 5642641510889746365n,
|
||||
consistencyLevel: 32,
|
||||
payload: {
|
||||
module: 'TokenBridge',
|
||||
type: 'Transfer',
|
||||
amount: 100000n,
|
||||
tokenAddress: '0x165809739240a0ac03b98440fe8985548e3aa683cd0d4d9df5b5659669faa301',
|
||||
tokenChain: 1,
|
||||
toAddress: '0x000000000000000000000000c10820983f33456ce7beb3a046f5a83fa34f027d',
|
||||
chain: 3104,
|
||||
fee: 0n
|
||||
},
|
||||
digest: '0x559318082f6abb8b0fcf360d2a98be84a0ccf6602044882cc0d6764a374ae44d'
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
010000000001001565b62bbf9978b1f9183ae985eb34f664fd4c850ec4ad8a38533281aec75eba2456f91c9a967cf4a70901aa0afed17ba39f1d779089b32eb88a47f7ea405e4b00000000002605c517000195f83a27e90c622a98c037353f271fd8f5f57b4dc18ebf5ff75a934724bd04914e4eb08ee374efbd200100000000000000000000000000000000000000000000000000000000000186a0165809739240a0ac03b98440fe8985548e3aa683cd0d4d9df5b5659669faa3010001000000000000000000000000c10820983f33456ce7beb3a046f5a83fa34f027d0c200000000000000000000000000000000000000000000000000000000000000000
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
version: 1,
|
||||
guardianSetIndex: 0,
|
||||
signatures: [
|
||||
{
|
||||
guardianSetIndex: 0,
|
||||
signature: 'e3db309303b712a562e6aa2adc68bc10ff22328ab31ddb6a83706943a9da97bf11ba6e3b96395515868786898dc19ecd737d197b0d1a1f3f3c6aead5c1fe700900'
|
||||
}
|
||||
],
|
||||
timestamp: 1,
|
||||
nonce: 1,
|
||||
emitterChain: 1,
|
||||
emitterAddress: '0x0000000000000000000000000000000000000000000000000000000000000004',
|
||||
sequence: 80072794n,
|
||||
consistencyLevel: 0,
|
||||
payload: {
|
||||
module: 'TokenBridge',
|
||||
type: 'ContractUpgrade',
|
||||
chain: 10,
|
||||
address: '0x0000000000000000000000000046da7a0320dd999438b4435dac82bf1dac13d2'
|
||||
},
|
||||
digest: '0xf5725025d1d3f69d77d189e88b9be290618f1ceae355c1b116cb2d97d63f6029'
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
01000000000100e3db309303b712a562e6aa2adc68bc10ff22328ab31ddb6a83706943a9da97bf11ba6e3b96395515868786898dc19ecd737d197b0d1a1f3f3c6aead5c1fe7009000000000100000001000100000000000000000000000000000000000000000000000000000000000000040000000004c5d05a00000000000000000000000000000000000000000000546f6b656e42726964676502000a0000000000000000000000000046da7a0320dd999438b4435dac82bf1dac13d2
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
version: 1,
|
||||
guardianSetIndex: 1,
|
||||
signatures: [],
|
||||
timestamp: 0,
|
||||
nonce: 1544861923,
|
||||
emitterChain: 1,
|
||||
emitterAddress: '0x0000000000000000000000000000000000000000000000000000000000000004',
|
||||
sequence: 18267094531749757526n,
|
||||
consistencyLevel: 32,
|
||||
payload: {
|
||||
module: 'TokenBridge',
|
||||
type: 'ContractUpgrade',
|
||||
chain: 3,
|
||||
address: '0x0000000000000000000000000000000000000000000000000000000000000fb2'
|
||||
},
|
||||
digest: '0x7c8bd53e23a704a5476810d36335d2b9d65e4182e4863af3b27bd6a1ac8825e4'
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
010000000100000000005c14b8e300010000000000000000000000000000000000000000000000000000000000000004fd81c1b1836cc25620000000000000000000000000000000000000000000546f6b656e4272696467650200030000000000000000000000000000000000000000000000000000000000000fb2
|
|
@ -0,0 +1,67 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -uo pipefail
|
||||
|
||||
test_directory="parse_tests"
|
||||
|
||||
function usage() {
|
||||
cat <<EOF >&2
|
||||
Usage:
|
||||
|
||||
$(basename "$0") [-h] [-a] -- Run golden parser golden tests in $test_directory
|
||||
|
||||
where:
|
||||
-h show this help text
|
||||
-a accept new results (override test files)
|
||||
EOF
|
||||
exit 1
|
||||
}
|
||||
|
||||
accept=false
|
||||
while getopts ':ha' option; do
|
||||
case "$option" in
|
||||
h) usage
|
||||
;;
|
||||
a) accept=true
|
||||
;;
|
||||
:) printf "missing argument for -%s\n" "$OPTARG" >&2
|
||||
usage
|
||||
;;
|
||||
\?) printf "illegal option: -%s\n" "$OPTARG" >&2
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND - 1))
|
||||
|
||||
test_files=$(find "$test_directory" -type f | grep "\.test$")
|
||||
|
||||
failed_tests=0
|
||||
for test in ${test_files[@]}; do
|
||||
test_name="${test%.*}"
|
||||
expected="$test_name.expected"
|
||||
|
||||
result=$(mktemp)
|
||||
worm parse $(cat "$test") > "$result" 2>&1
|
||||
if [ $accept = true ]; then
|
||||
echo "Updating $test_name"
|
||||
cat "$result" > "$expected"
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ ! -f "$expected" ]; then
|
||||
echo "Missing '$expected' (re-run with -a flag to create)"
|
||||
failed_tests=$(($failed_tests + 1))
|
||||
else
|
||||
echo "Testing $test_name"
|
||||
git --no-pager diff --no-index "$expected" "$result"
|
||||
failed_tests=$(($failed_tests + $?))
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! $failed_tests = 0 ]; then
|
||||
echo "$failed_tests failed test(s)"
|
||||
exit 1
|
||||
else
|
||||
echo "All tests passed"
|
||||
fi
|
|
@ -2,11 +2,11 @@ import * as web3s from '@solana/web3.js'
|
|||
import { NETWORKS } from "./networks";
|
||||
import { impossible, Payload, VAA } from "./vaa";
|
||||
import base58 from "bs58";
|
||||
import { importCoreWasm, importNftWasm, importTokenWasm, ixFromRust } from "@certusone/wormhole-sdk";
|
||||
import { CHAIN_ID_SOLANA, importCoreWasm, importNftWasm, importTokenWasm, ixFromRust } from "@certusone/wormhole-sdk";
|
||||
import { CONTRACTS } from "@certusone/wormhole-sdk"
|
||||
import { postVaaSolanaWithRetry } from "@certusone/wormhole-sdk"
|
||||
|
||||
export async function execute_governance_solana(
|
||||
export async function execute_solana(
|
||||
v: VAA<Payload>,
|
||||
vaa: Buffer,
|
||||
network: "MAINNET" | "TESTNET" | "DEVNET"
|
||||
|
@ -53,7 +53,8 @@ export async function execute_governance_solana(
|
|||
break
|
||||
case "TokenBridge":
|
||||
const token_bridge = await importTokenWasm()
|
||||
switch (v.payload.type) {
|
||||
const payload = v.payload;
|
||||
switch (payload.type) {
|
||||
case "ContractUpgrade":
|
||||
console.log("Upgrading contract")
|
||||
ix = token_bridge.upgrade_contract_ix(token_bridge_id.toString(), bridge_id.toString(), from.publicKey.toString(), from.publicKey.toString(), vaa)
|
||||
|
@ -62,8 +63,19 @@ export async function execute_governance_solana(
|
|||
console.log("Registering chain")
|
||||
ix = token_bridge.register_chain_ix(token_bridge_id.toString(), bridge_id.toString(), from.publicKey.toString(), vaa)
|
||||
break
|
||||
case "Transfer":
|
||||
console.log("Completing transfer")
|
||||
if (payload.tokenChain === CHAIN_ID_SOLANA) {
|
||||
ix = token_bridge.complete_transfer_native_ix(token_bridge_id.toString(), bridge_id.toString(), from.publicKey.toString(), vaa)
|
||||
} else {
|
||||
ix = token_bridge.complete_transfer_wrapped_ix(token_bridge_id.toString(), bridge_id.toString(), from.publicKey.toString(), vaa)
|
||||
}
|
||||
break
|
||||
case "TransferWithPayload":
|
||||
throw Error("Can't complete payload 3 transfer from CLI")
|
||||
default:
|
||||
throw Error(`VAA is of type ${v.payload.type}, which is not a governance action`)
|
||||
impossible(payload)
|
||||
break
|
||||
|
||||
}
|
||||
break
|
||||
|
|
|
@ -8,7 +8,7 @@ import { impossible, Payload } from "./vaa";
|
|||
import { NETWORKS } from "./networks";
|
||||
import { CONTRACTS, TerraChainName } from "@certusone/wormhole-sdk";
|
||||
|
||||
export async function execute_governance_terra(
|
||||
export async function execute_terra(
|
||||
payload: Payload,
|
||||
vaa: Buffer,
|
||||
network: "MAINNET" | "TESTNET" | "DEVNET",
|
||||
|
@ -90,8 +90,15 @@ export async function execute_governance_terra(
|
|||
case "RegisterChain":
|
||||
console.log("Registering chain");
|
||||
break;
|
||||
case "Transfer":
|
||||
console.log("Completing transfer");
|
||||
break;
|
||||
case "TransferWithPayload":
|
||||
console.log("Completing transfer");
|
||||
break;
|
||||
default:
|
||||
throw Error(`VAA is of type ${payload.type}, which is not a governance action`)
|
||||
impossible(payload)
|
||||
break
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -61,6 +61,7 @@ export type Payload =
|
|||
| PortalRegisterChain<"TokenBridge">
|
||||
| PortalRegisterChain<"NFTBridge">
|
||||
| TokenBridgeTransfer
|
||||
| TokenBridgeTransferWithPayload
|
||||
// TODO: add other types of payloads
|
||||
|
||||
export function parse(buffer: Buffer): VAA<Payload | null> {
|
||||
|
@ -72,6 +73,7 @@ export function parse(buffer: Buffer): VAA<Payload | null> {
|
|||
.or(portalRegisterChainParser("TokenBridge"))
|
||||
.or(portalRegisterChainParser("NFTBridge"))
|
||||
.or(tokenBridgeTransferParser())
|
||||
.or(tokenBridgeTransferWithPayloadParser())
|
||||
const payload = parser.parse(vaa.payload)
|
||||
var myVAA = { ...vaa, payload }
|
||||
|
||||
|
@ -195,6 +197,9 @@ function vaaBody(vaa: VAA<Payload>) {
|
|||
case "Transfer":
|
||||
payload_str = serialiseTokenBridgeTransfer(payload)
|
||||
break
|
||||
case "TransferWithPayload":
|
||||
payload_str = serialiseTokenBridgeTransferWithPayload(payload)
|
||||
break
|
||||
default:
|
||||
impossible(payload)
|
||||
break
|
||||
|
@ -499,6 +504,74 @@ function serialiseTokenBridgeTransfer(payload: TokenBridgeTransfer): string {
|
|||
return body.join("")
|
||||
}
|
||||
|
||||
export interface TokenBridgeTransferWithPayload {
|
||||
module: "TokenBridge"
|
||||
type: "TransferWithPayload"
|
||||
amount: bigint
|
||||
tokenAddress: string
|
||||
tokenChain: number
|
||||
toAddress: string
|
||||
chain: number
|
||||
fromAddress: string,
|
||||
payload: string
|
||||
}
|
||||
|
||||
function tokenBridgeTransferWithPayloadParser(): P<TokenBridgeTransferWithPayload> {
|
||||
return new P(new Parser()
|
||||
.endianess("big")
|
||||
.string("module", {
|
||||
length: (_) => 0,
|
||||
formatter: (_) => "TokenBridge"
|
||||
})
|
||||
.uint8("type", {
|
||||
assert: 3,
|
||||
formatter: (_action) => "TransferWithPayload"
|
||||
})
|
||||
.array("amount", {
|
||||
type: "uint8",
|
||||
lengthInBytes: 32,
|
||||
formatter: (bytes) => BigNumber.from(bytes).toBigInt()
|
||||
})
|
||||
.array("tokenAddress", {
|
||||
type: "uint8",
|
||||
lengthInBytes: 32,
|
||||
formatter: (arr) => "0x" + Buffer.from(arr).toString("hex")
|
||||
})
|
||||
.uint16("tokenChain")
|
||||
.array("toAddress", {
|
||||
type: "uint8",
|
||||
lengthInBytes: 32,
|
||||
formatter: (arr) => "0x" + Buffer.from(arr).toString("hex")
|
||||
})
|
||||
.uint16("chain")
|
||||
.array("fromAddress", {
|
||||
type: "uint8",
|
||||
lengthInBytes: 32,
|
||||
formatter: (arr) => "0x" + Buffer.from(arr).toString("hex")
|
||||
}).
|
||||
array("payload", {
|
||||
type: "uint8",
|
||||
greedy: true,
|
||||
readUntil: "eof",
|
||||
formatter: (arr) => "0x" + Buffer.from(arr).toString("hex")
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
function serialiseTokenBridgeTransferWithPayload(payload: TokenBridgeTransferWithPayload): string {
|
||||
const body = [
|
||||
encode("uint8", 3),
|
||||
encode("uint256", payload.amount),
|
||||
encode("bytes32", hex(payload.tokenAddress)),
|
||||
encode("uint16", payload.tokenChain),
|
||||
encode("bytes32", hex(payload.toAddress)),
|
||||
encode("uint16", payload.chain),
|
||||
encode("bytes32", hex(payload.fromAddress)),
|
||||
payload.payload.substring(2)
|
||||
]
|
||||
return body.join("")
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// NFT bridge
|
||||
|
||||
|
|
Loading…
Reference in New Issue