Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions backend-all/src/services/blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,13 @@ export const signTransaction = async (
}
const _fromChain = fromChain.replace('evm.', '') as ChainId
const _provider = await _getProvider(_fromChain)
console.log('got from chain _provider')
const contract = anyBridgeAssist(fromBridgeAddress, _provider)
console.log('got from bridge address contract')
const transactionPromise = contract.transactions(fromUser, index)
// const relayerLengthPromise = contract.relayersLength()
tx = await transactionPromise
console.log('got transaction')
if (!tx || tx.block.toNumber() === 0) throw Error('Transaction not found')
if (
_fromChain === '42161' ||
Expand All @@ -102,6 +105,7 @@ export const signTransaction = async (

// const provider = getProvider(fromChain.slice(4) as ChainId)
const currentBlock = await safeRead(_provider.getBlockNumber(), 0)
console.log('got current block')
if (currentBlock === 0 || tx.block.gt(currentBlock))
throw Error(`Relayer ${relayerIndex} waiting for confirmations`)

Expand All @@ -110,8 +114,10 @@ export const signTransaction = async (

const chainId = tx.toChain.replace('evm.', '')
const toProvider = await _getProvider(chainId as ChainId)
console.log('got to provider')
const toBridgeAddressContract = anyBridgeAssist(toBridgeAddress, toProvider)
const { isFulfilled } = await fulfilledInfo(toBridgeAddressContract, tx)
console.log('got is fulfilled')
if (isFulfilled) {
if (process.env.IS_PUBLIC_RELAYER === 'true') {
await transactionRepo.update(transactionId, { fulfilled: true })
Expand All @@ -121,6 +127,7 @@ export const signTransaction = async (

const relayersLength = await toBridgeAddressContract.relayersLength()
relayers = relayersLength.toNumber()
console.log('got relayers length')

let signatures: string[] = []
const allowedIps = process.env.ALLOWED_IPS?.split(',')
Expand All @@ -136,6 +143,7 @@ export const signTransaction = async (
toBridgeAddress,
0
)
console.log('got signer0')
signatures.push(signer0)
if (process.env.IS_PUBLIC_RELAYER === 'true' && relayers > 1) {
const relayer1Url = process.env.RELAYER1_URL
Expand All @@ -148,6 +156,7 @@ export const signTransaction = async (
const results = await Promise.all(promises)
signatures = signatures.concat(results[0], results[1])
}
console.log('got signatures')
return signatures
// } else {
// throw Error('bad contract params')
Expand Down