Skip to content

Commit

Permalink
CU-86a6av7kx - BSEthereum - Throw last error if no transfer is succes…
Browse files Browse the repository at this point in the history
…sful
  • Loading branch information
raulduartep committed Jan 22, 2025
1 parent 98c8e5f commit b1a1532
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@cityofzion/bs-ethereum",
"comment": "Throw last error if no transfer is successful",
"type": "patch"
}
],
"packageName": "@cityofzion/bs-ethereum"
}
10 changes: 8 additions & 2 deletions packages/bs-ethereum/src/BSEthereum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ export class BSEthereum<BSName extends string = string>
const signer = await this.#generateSigner(param.senderAccount)

const sentTransactionHashes: string[] = []
let error: Error | undefined

for (const intent of param.intents) {
let transactionHash = ''
Expand All @@ -247,14 +248,19 @@ export class BSEthereum<BSName extends string = string>
maxPriorityFeePerGas: gasPrice,
maxFeePerGas: gasPrice,
})

transactionHash = transaction.hash
} catch {
/* empty */
} catch (err: any) {
error = err
}

sentTransactionHashes.push(transactionHash)
}

if (error && sentTransactionHashes.every(hash => !hash)) {
throw error
}

return sentTransactionHashes
}

Expand Down

0 comments on commit b1a1532

Please sign in to comment.