From 90a8f17420205b9149b4c35ae15e439fabcecf62 Mon Sep 17 00:00:00 2001 From: stephenson080 Date: Wed, 16 Oct 2024 02:33:15 -0700 Subject: [PATCH] tracking error --- backend-wbtc/src/routes/sign.ts | 2 +- backend-wbtc/src/services/blockchain.ts | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/backend-wbtc/src/routes/sign.ts b/backend-wbtc/src/routes/sign.ts index 8093fd1..932b157 100644 --- a/backend-wbtc/src/routes/sign.ts +++ b/backend-wbtc/src/routes/sign.ts @@ -9,7 +9,7 @@ export default (): Resource => ({ try { const { fromBridgeAddress, toBridgeAssistAddress, fromChain, fromUser, index } = req.query - + console.log(fromBridgeAddress, toBridgeAssistAddress, fromBridgeAddress, fromChain, index, 'tracking param') if (!fromBridgeAddress) return res.status(400).send('fromBridgeAddress not specified') if (!toBridgeAssistAddress) diff --git a/backend-wbtc/src/services/blockchain.ts b/backend-wbtc/src/services/blockchain.ts index 0bb8b3b..e47d86e 100644 --- a/backend-wbtc/src/services/blockchain.ts +++ b/backend-wbtc/src/services/blockchain.ts @@ -14,6 +14,7 @@ export const getWalletEVM = () => new Wallet(process.env.PRIVATE_KEY!) const getWallet = (signerIndex: number) => { if (signerIndex === 0) { + console.log(process.env.PRIVATE_KEY, signerIndex, 'pk') return new Wallet(process.env.PRIVATE_KEY, getProvider(config.DEFAULT_CHAINID)) } return new Wallet(process.env.PRIVATE_KEY2!, getProvider(config.DEFAULT_CHAINID)) @@ -26,6 +27,7 @@ async function signHashedTransaction( signerIndex: number ) { const wallet = getWallet(signerIndex) + console.log('sign hash', wallet, signerIndex) const domain = { name: EIP712DOMAIN_NAME, version: EIP712DOMAIN_VERSION, @@ -35,8 +37,9 @@ async function signHashedTransaction( const types = { [eip712Transaction.name]: eip712Transaction.fields, } - + console.log('sign hash 2', domain) const sign = await wallet._signTypedData(domain, types, transaction) + console.log('sign hash 3', sign) return sign } @@ -58,18 +61,28 @@ export const signTransaction = async ( index: string ) => { let tx: TransactionContract + console.log('helllo1') if (fromChain.startsWith('evm.')) { + console.log('helllo2') const { bridgeAssist } = useContracts(undefined, fromChain.slice(4) as ChainId) + console.log('helllo3', bridgeAssist) tx = await bridgeAssist(fromBridgeAddress).transactions(fromUser, index) + console.log('helllo4', tx) } else { throw Error('bad arguments') } + console.log('helllo5') const provider = getProvider(fromChain.slice(4) as ChainId) + console.log('helllo6') const currentBlock = await safeRead(provider.getBlockNumber(), 0) + console.log('helllo7', currentBlock) if (currentBlock === 0 || tx.block.gt(currentBlock)) throw Error('waiting for confirmations') + console.log('helllo8') if (tx.toChain.startsWith('evm.')) { + console.log('helllo9') const chainId = tx.toChain.replace('evm.', '') + console.log('helllo10', chainId) let signatures = [] const signer0 = await signHashedTransaction( extractFulfillTransaction(tx), @@ -77,6 +90,7 @@ export const signTransaction = async ( toBridgeAddress, 0 ) + console.log('helllo11', signer0) signatures.push(signer0) if (process.env.PRIVATE_KEY2){ const signer1 = await signHashedTransaction( @@ -87,6 +101,7 @@ export const signTransaction = async ( ) signatures.push(signer1) } + console.log('helllo12', signatures) return signatures } else { throw Error('bad contract params')