diff --git a/common/changes/@cityofzion/bs-ethereum/CU-86a64561q_2025-01-03-22-18.json b/common/changes/@cityofzion/bs-ethereum/CU-86a64561q_2025-01-03-22-18.json new file mode 100644 index 0000000..52f6cdd --- /dev/null +++ b/common/changes/@cityofzion/bs-ethereum/CU-86a64561q_2025-01-03-22-18.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@cityofzion/bs-ethereum", + "comment": "Fix bug where EthersLedgerSigner's signTransaction method did not sign some transaction fields", + "type": "patch" + } + ], + "packageName": "@cityofzion/bs-ethereum" +} \ No newline at end of file diff --git a/packages/bs-ethereum/src/services/ledger/EthersLedgerServiceEthereum.ts b/packages/bs-ethereum/src/services/ledger/EthersLedgerServiceEthereum.ts index d76ba83..eee8f49 100644 --- a/packages/bs-ethereum/src/services/ledger/EthersLedgerServiceEthereum.ts +++ b/packages/bs-ethereum/src/services/ledger/EthersLedgerServiceEthereum.ts @@ -41,7 +41,7 @@ export class EthersLedgerSigner extends Signer implements TypedDataSigner { } async getAddress(): Promise { - const { address } = await this.#ledgerApp.getAddress(this.#bip44Path) + const { address } = await BSEthereumHelper.retry(() => this.#ledgerApp.getAddress(this.#bip44Path)) return address } @@ -73,17 +73,10 @@ export class EthersLedgerSigner extends Signer implements TypedDataSigner { async signTransaction(transaction: ethers.utils.Deferrable): Promise { try { const tx = await ethers.utils.resolveProperties(transaction) - const unsignedTransaction: ethers.utils.UnsignedTransaction = { - chainId: tx.chainId ?? undefined, - data: tx.data ?? undefined, - gasLimit: tx.gasLimit ?? undefined, - gasPrice: tx.gasPrice ?? undefined, - nonce: tx.nonce ? ethers.BigNumber.from(tx.nonce).toNumber() : undefined, - to: tx.to ?? undefined, - value: tx.value ?? undefined, - } - const serializedUnsignedTransaction = ethers.utils.serializeTransaction(unsignedTransaction).substring(2) + const serializedUnsignedTransaction = ethers.utils + .serializeTransaction(tx) + .substring(2) const resolution = await LedgerEthereumAppService.resolveTransaction(serializedUnsignedTransaction, {}, {}) @@ -95,7 +88,7 @@ export class EthersLedgerSigner extends Signer implements TypedDataSigner { this.#emitter?.emit('getSignatureEnd') - return ethers.utils.serializeTransaction(unsignedTransaction, { + return ethers.utils.serializeTransaction(tx, { v: ethers.BigNumber.from('0x' + signature.v).toNumber(), r: '0x' + signature.r, s: '0x' + signature.s,