added metaplex metadata program to solana local validator
This commit is contained in:
parent
e8315122fd
commit
869d0750c2
|
@ -32,4 +32,9 @@ filename = "./token/emitter_eth.json"
|
|||
address = "BmRvjCA2cQ1qUNAMVAnPgmjATSBPa2pxE3Q7bRoSGFED"
|
||||
filename = "./token/emitter_bsc.json"
|
||||
|
||||
# METAPLEX Metadata Account
|
||||
[[test.genesis]]
|
||||
address = "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"
|
||||
filename = "./thirdparty/mpl_token_metadata.so"
|
||||
|
||||
# NFT BRIDGE
|
|
@ -14,4 +14,5 @@ npx pm2 start "solana-test-validator" --name solana -- -r \
|
|||
--bpf-program B6RHG3mfcckmrYN1UhmJzyS1XX3fZKbkeUcpJe9Sy3FE ./solana-accounts/token/token_bridge.so \
|
||||
--account 3GwVs8GSLdo4RUsoXTkGQhojauQ1sXcDNjm7LSDicw19 ./solana-accounts/token/token_config.json \
|
||||
--account 7UqWgfVW1TrjrqauMfDoNMcw8kEStSsQXWNoT2BbhDS5 ./solana-accounts/token/emitter_eth.json \
|
||||
--account BmRvjCA2cQ1qUNAMVAnPgmjATSBPa2pxE3Q7bRoSGFED ./solana-accounts/token/emitter_bsc.json
|
||||
--account BmRvjCA2cQ1qUNAMVAnPgmjATSBPa2pxE3Q7bRoSGFED ./solana-accounts/token/emitter_bsc.json \
|
||||
--bpf-program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s ./solana-accoutns/thirdaprty/mpl_token_metadata.so
|
||||
|
|
|
@ -166,7 +166,7 @@ export async function attest(src: string, target: string, address:string = null)
|
|||
// in this context the target is network we're attesting *from* so it's the network the vaa comes from (hence being placed as the 'source')
|
||||
// The emitter for this is PORTAL, not our contract, so we set portal=true in fetchVaa
|
||||
const attestVaa = await fetchVaa(src, tx, true);
|
||||
|
||||
console.log(`Creating wrapped on ${target}`);
|
||||
switch(targetNetwork.type){
|
||||
case "evm":
|
||||
await createWrapped(target, src, attestVaa)
|
||||
|
|
|
@ -12,6 +12,7 @@ import {
|
|||
getEmitterAddressSolana,
|
||||
getForeignAssetSolana,
|
||||
parseSequenceFromLogSolana,
|
||||
postVaaSolanaWithRetry,
|
||||
setDefaultWasm,
|
||||
tryNativeToUint8Array
|
||||
} from '@certusone/wormhole-sdk';
|
||||
|
@ -155,7 +156,6 @@ async function fetchVaa(src:string, tx:string, portal:boolean=false):Promise<str
|
|||
}
|
||||
console.log(`VAA from TX(${tx}) found in ${timeElapsed}s`);
|
||||
const seq = parseSequenceFromLogSolana(transaction);
|
||||
console.log("Seq", seq);
|
||||
await new Promise((r) => setTimeout(r, 5000)); //wait for gaurdian to pick up messsage
|
||||
console.log(
|
||||
"Searching for: ",
|
||||
|
@ -185,6 +185,20 @@ export async function createWrapped(src:string, target:string, vaa:string){
|
|||
)));
|
||||
const connection = new anchor.web3.Connection(srcNetwork.rpc);
|
||||
|
||||
setDefaultWasm("node");
|
||||
//Have to Post the VAA first before we can use it
|
||||
await postVaaSolanaWithRetry(
|
||||
connection,
|
||||
async (transaction) => {
|
||||
transaction.partialSign(srcKey);
|
||||
return transaction;
|
||||
},
|
||||
srcNetwork.bridgeAddress,
|
||||
srcKey.publicKey.toString(),
|
||||
Buffer.from(vaa, "base64"),
|
||||
10
|
||||
);
|
||||
|
||||
const tx = await createWrappedOnSolana(
|
||||
connection,
|
||||
srcNetwork.bridgeAddress,
|
||||
|
@ -192,9 +206,11 @@ export async function createWrapped(src:string, target:string, vaa:string){
|
|||
srcKey.publicKey.toString(),
|
||||
Buffer.from(vaa, "base64")
|
||||
);
|
||||
tx.partialSign(srcKey);
|
||||
const txid = await connection.sendRawTransaction(tx.serialize());
|
||||
console.log("TXID: ", txid);
|
||||
|
||||
await new Promise((r) => setTimeout(r, 5000)); // wait for blocks to advance before fetching new foreign address
|
||||
|
||||
const foreignAddress = await getForeignAssetSolana(
|
||||
connection,
|
||||
srcNetwork.tokenBridgeAddress,
|
||||
|
@ -212,7 +228,6 @@ export async function registerApp(src:string, target:string){
|
|||
const srcKey = anchor.web3.Keypair.fromSecretKey(Uint8Array.from(JSON.parse((fs.readFileSync(`keypairs/${src}.key`).toString())
|
||||
)));
|
||||
const connection = new anchor.web3.Connection(srcNetwork.rpc);
|
||||
|
||||
let targetEmitter;
|
||||
switch (targetNetwork.type){
|
||||
case 'evm':
|
||||
|
@ -236,12 +251,18 @@ export async function registerApp(src:string, target:string){
|
|||
byteify.serializeUint16(targetNetwork.wormholeChainId)
|
||||
], xmint.programId);
|
||||
|
||||
const [configAcc, _] = findProgramAddressSync([
|
||||
Buffer.from("config")
|
||||
], xmint.programId);
|
||||
|
||||
|
||||
const tx = await xmint.methods
|
||||
.registerChain(
|
||||
targetNetwork.wormholeChainId,
|
||||
targetEmitter
|
||||
)
|
||||
.accounts({
|
||||
config: configAcc,
|
||||
emitterAcc: emitterAcc,
|
||||
owner: xmint.provider.publicKey,
|
||||
systemProgram: anchor.web3.SystemProgram.programId
|
||||
|
|
|
@ -163,4 +163,10 @@ xmint
|
|||
console.log(`Balance of ${src} key for ${target} tokens is ${balance}`);
|
||||
})
|
||||
|
||||
xmint
|
||||
.command("debug")
|
||||
.action(async () => {
|
||||
solana.createWrapped('sol0', 'evm0', 'AQAAAAABAN/Tvs+PQEPxFJzlILkIPBNCEZSDYRmLKAOdJ3ve8ddlL9ZsDFuxKYDdGYg4JvT2F+UghSCBNlWrh+DH8M1yiD4BYw0WejBGAQAAAgAAAAAAAAAAAAAAAAKQ+xZyCK9FW7E3eAFjt7epoQwWAAAAAAAAAAABAgAAAAAAAAAAAAAAAO6i/B0lX9KKoVxsIyStQLAyZ/nFAAISRVZNMFQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABFVk0wLVRPS0VOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==')
|
||||
})
|
||||
|
||||
xmint.parse();
|
|
@ -1,5 +1,5 @@
|
|||
# Rerun solana validator
|
||||
cd ../wormhole-local-validator && npm run solana && cd ../xmint
|
||||
cd ../wormhole-local-validator && npm run evm && npm run solana && npm run wormhole && cd ../xmint
|
||||
|
||||
# Deploy the code on EVM0 and SOL0
|
||||
ts-node orchestrator.ts deploy evm0
|
||||
|
|
Loading…
Reference in New Issue