diff --git a/projects/wormhole-local-validator/solana-accounts/Anchor.toml b/projects/wormhole-local-validator/solana-accounts/Anchor.toml index 0bfae5f..609a74f 100644 --- a/projects/wormhole-local-validator/solana-accounts/Anchor.toml +++ b/projects/wormhole-local-validator/solana-accounts/Anchor.toml @@ -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 \ No newline at end of file diff --git a/projects/wormhole-local-validator/solana-binary-deploy.bash b/projects/wormhole-local-validator/solana-binary-deploy.bash index cd3679c..3d42f56 100644 --- a/projects/wormhole-local-validator/solana-binary-deploy.bash +++ b/projects/wormhole-local-validator/solana-binary-deploy.bash @@ -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 diff --git a/projects/xmint/handlers/evm.ts b/projects/xmint/handlers/evm.ts index a7301e6..f8d6a8e 100644 --- a/projects/xmint/handlers/evm.ts +++ b/projects/xmint/handlers/evm.ts @@ -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) diff --git a/projects/xmint/handlers/solana.ts b/projects/xmint/handlers/solana.ts index df77cc2..0231efa 100644 --- a/projects/xmint/handlers/solana.ts +++ b/projects/xmint/handlers/solana.ts @@ -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 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 diff --git a/projects/xmint/orchestrator.ts b/projects/xmint/orchestrator.ts index 95c3412..0378fb3 100644 --- a/projects/xmint/orchestrator.ts +++ b/projects/xmint/orchestrator.ts @@ -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(); \ No newline at end of file diff --git a/projects/xmint/tests/test.bash b/projects/xmint/tests/test.bash index 5cf8d63..ddd95f5 100644 --- a/projects/xmint/tests/test.bash +++ b/projects/xmint/tests/test.bash @@ -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