clients/solana: allow submitting VAAs to mainnet
This commit is contained in:
parent
1fd6e14885
commit
5a316207dd
|
@ -1,10 +1,11 @@
|
||||||
import yargs from "yargs";
|
import yargs from "yargs";
|
||||||
|
|
||||||
const {hideBin} = require('yargs/helpers')
|
import { hideBin } from 'yargs/helpers';
|
||||||
import * as web3 from '@solana/web3.js';
|
import * as web3 from '@solana/web3.js';
|
||||||
import {PublicKey, Transaction, TransactionInstruction, AccountMeta, Keypair, Connection} from "@solana/web3.js";
|
import { PublicKey, TransactionInstruction, Keypair, Connection } from "@solana/web3.js";
|
||||||
|
import { base58 } from "ethers/lib/utils";
|
||||||
|
|
||||||
import {setDefaultWasm, importCoreWasm, ixFromRust} from '@certusone/wormhole-sdk'
|
import { setDefaultWasm, importCoreWasm, ixFromRust } from '@certusone/wormhole-sdk'
|
||||||
setDefaultWasm("node")
|
setDefaultWasm("node")
|
||||||
|
|
||||||
yargs(hideBin(process.argv))
|
yargs(hideBin(process.argv))
|
||||||
|
@ -41,7 +42,7 @@ yargs(hideBin(process.argv))
|
||||||
);
|
);
|
||||||
await connection.confirmTransaction(airdropSignature);
|
await connection.confirmTransaction(airdropSignature);
|
||||||
|
|
||||||
let fee_acc = await bridge.fee_collector_address(bridge_id.toString());
|
let fee_acc = bridge.fee_collector_address(bridge_id.toString());
|
||||||
let bridge_state = await get_bridge_state(connection, bridge_id);
|
let bridge_state = await get_bridge_state(connection, bridge_id);
|
||||||
let transferIx = web3.SystemProgram.transfer({
|
let transferIx = web3.SystemProgram.transfer({
|
||||||
fromPubkey: from.publicKey,
|
fromPubkey: from.publicKey,
|
||||||
|
@ -103,13 +104,17 @@ yargs(hideBin(process.argv))
|
||||||
let connection = setupConnection(argv);
|
let connection = setupConnection(argv);
|
||||||
let bridge_id = new PublicKey(argv.bridge);
|
let bridge_id = new PublicKey(argv.bridge);
|
||||||
|
|
||||||
// Generate a new random public key
|
var from: web3.Keypair;
|
||||||
let from = web3.Keypair.generate();
|
if (argv.key) {
|
||||||
let airdropSignature = await connection.requestAirdrop(
|
from = web3.Keypair.fromSecretKey(base58.decode(argv.key));
|
||||||
from.publicKey,
|
} else {
|
||||||
web3.LAMPORTS_PER_SOL,
|
from = web3.Keypair.generate();
|
||||||
);
|
let airdropSignature = await connection.requestAirdrop(
|
||||||
await connection.confirmTransaction(airdropSignature);
|
from.publicKey,
|
||||||
|
web3.LAMPORTS_PER_SOL,
|
||||||
|
);
|
||||||
|
await connection.confirmTransaction(airdropSignature);
|
||||||
|
}
|
||||||
|
|
||||||
let vaa = Buffer.from(argv.vaa, "hex");
|
let vaa = Buffer.from(argv.vaa, "hex");
|
||||||
await post_vaa(connection, bridge_id, from, vaa);
|
await post_vaa(connection, bridge_id, from, vaa);
|
||||||
|
@ -161,6 +166,12 @@ yargs(hideBin(process.argv))
|
||||||
description: 'Bridge address',
|
description: 'Bridge address',
|
||||||
default: "Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o"
|
default: "Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o"
|
||||||
})
|
})
|
||||||
|
.option('key', {
|
||||||
|
alias: 'k',
|
||||||
|
type: 'string',
|
||||||
|
description: 'Private key of the wallet',
|
||||||
|
required: false
|
||||||
|
})
|
||||||
.argv;
|
.argv;
|
||||||
|
|
||||||
async function post_vaa(connection: Connection, bridge_id: PublicKey, payer: Keypair, vaa: Buffer) {
|
async function post_vaa(connection: Connection, bridge_id: PublicKey, payer: Keypair, vaa: Buffer) {
|
||||||
|
@ -246,4 +257,4 @@ interface BridgeConfig {
|
||||||
|
|
||||||
// Amount of lamports that needs to be paid to the protocol to post a message
|
// Amount of lamports that needs to be paid to the protocol to post a message
|
||||||
fee: number,
|
fee: number,
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "tsc && node main.js",
|
"start": "tsc && node main.js",
|
||||||
|
"build": "tsc",
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import yargs from "yargs";
|
import yargs from "yargs";
|
||||||
|
|
||||||
const {hideBin} = require('yargs/helpers')
|
import { hideBin } from 'yargs/helpers';
|
||||||
|
|
||||||
import * as elliptic from "elliptic";
|
import * as elliptic from "elliptic";
|
||||||
import * as ethers from "ethers";
|
import * as ethers from "ethers";
|
||||||
|
@ -9,7 +9,7 @@ import * as web3s from '@solana/web3.js';
|
||||||
import {fromUint8Array} from "js-base64";
|
import {fromUint8Array} from "js-base64";
|
||||||
import {LCDClient, MnemonicKey} from '@terra-money/terra.js';
|
import {LCDClient, MnemonicKey} from '@terra-money/terra.js';
|
||||||
import {MsgExecuteContract} from "@terra-money/terra.js";
|
import {MsgExecuteContract} from "@terra-money/terra.js";
|
||||||
import {PublicKey, TransactionInstruction, AccountMeta, Keypair, Connection} from "@solana/web3.js";
|
import {PublicKey, TransactionInstruction, Keypair, Connection} from "@solana/web3.js";
|
||||||
import {base58, solidityKeccak256} from "ethers/lib/utils";
|
import {base58, solidityKeccak256} from "ethers/lib/utils";
|
||||||
|
|
||||||
import {setDefaultWasm, importCoreWasm, importTokenWasm, ixFromRust, BridgeImplementation__factory} from '@certusone/wormhole-sdk'
|
import {setDefaultWasm, importCoreWasm, importTokenWasm, ixFromRust, BridgeImplementation__factory} from '@certusone/wormhole-sdk'
|
||||||
|
|
Loading…
Reference in New Issue