From 78c5d343da7cdaed9fe64f3e131919ae98389a05 Mon Sep 17 00:00:00 2001 From: Hendrik Hofstadt Date: Mon, 9 Aug 2021 21:33:08 +0200 Subject: [PATCH] Adapt transfer code for new message accounts Change-Id: I11178c5ce1cb6c00f67eb815b67660f976c89067 --- bridge_ui/src/utils/attestFrom.ts | 12 +++++------- bridge_ui/src/utils/transferFrom.ts | 6 +++++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/bridge_ui/src/utils/attestFrom.ts b/bridge_ui/src/utils/attestFrom.ts index b1f4ae893..8abf7b8fd 100644 --- a/bridge_ui/src/utils/attestFrom.ts +++ b/bridge_ui/src/utils/attestFrom.ts @@ -1,6 +1,6 @@ import Wallet from "@project-serum/sol-wallet-adapter"; import { - Connection, + Connection, Keypair, PublicKey, SystemProgram, Transaction, @@ -99,24 +99,22 @@ export async function attestFromSolana( // TODO: pass in connection // Add transfer instruction to transaction const { attest_ix, emitter_address } = await import("token-bridge"); + const messageKey = Keypair.generate(); const ix = ixFromRust( attest_ix( SOL_TOKEN_BRIDGE_ADDRESS, SOL_BRIDGE_ADDRESS, payerAddress, - mintAddress, - decimals, + messageKey.publicKey.toString(), mintAddress, // TODO: mint_metadata: what address is this supposed to be? - mintAddress, // TODO: spl_metadata: what address is this supposed to be? - "", // TODO: lookup symbol - "", //: TODO: lookup name - nonce + nonce, ) ); const transaction = new Transaction().add(transferIx, ix); const { blockhash } = await connection.getRecentBlockhash(); transaction.recentBlockhash = blockhash; transaction.feePayer = new PublicKey(payerAddress); + transaction.partialSign(messageKey); // Sign transaction, broadcast, and confirm const signed = await wallet.signTransaction(transaction); console.log("SIGNED", signed); diff --git a/bridge_ui/src/utils/transferFrom.ts b/bridge_ui/src/utils/transferFrom.ts index abcd37da3..8d4e08d65 100644 --- a/bridge_ui/src/utils/transferFrom.ts +++ b/bridge_ui/src/utils/transferFrom.ts @@ -1,7 +1,7 @@ import Wallet from "@project-serum/sol-wallet-adapter"; import { Token, TOKEN_PROGRAM_ID } from "@solana/spl-token"; import { - Connection, + Connection, Keypair, PublicKey, SystemProgram, Transaction, @@ -163,11 +163,14 @@ export async function transferFromSolana( [], Number(amountParsed) ); + + let messageKey = Keypair.generate(); const ix = ixFromRust( transfer_native_ix( SOL_TOKEN_BRIDGE_ADDRESS, SOL_BRIDGE_ADDRESS, payerAddress, + messageKey.publicKey.toString(), fromAddress, mintAddress, nonce, @@ -181,6 +184,7 @@ export async function transferFromSolana( const { blockhash } = await connection.getRecentBlockhash(); transaction.recentBlockhash = blockhash; transaction.feePayer = new PublicKey(payerAddress); + transaction.partialSign(messageKey); // Sign transaction, broadcast, and confirm const signed = await wallet.signTransaction(transaction); console.log("SIGNED", signed);