diff --git a/modules/sdk-coin-ada/CHANGELOG.md b/modules/sdk-coin-ada/CHANGELOG.md index 90631050fc..53a0b9f165 100644 --- a/modules/sdk-coin-ada/CHANGELOG.md +++ b/modules/sdk-coin-ada/CHANGELOG.md @@ -5,221 +5,119 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline # [4.21.0](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.20.8...@bitgo/sdk-coin-ada@4.21.0) (2026-01-22) - ### Features -* **sdk-coin-ada:** support for sponsored txns ([cb75eda](https://github.com/BitGo/BitGoJS/commit/cb75edad4850135a92e0c5ea41156491977edf73)) -* **sdk-coin-ada:** token sponsorship support ([12e0c78](https://github.com/BitGo/BitGoJS/commit/12e0c78cef2d763d0e6de4bea94973d7b0e1788a)) - - - - +- **sdk-coin-ada:** support for sponsored txns ([cb75eda](https://github.com/BitGo/BitGoJS/commit/cb75edad4850135a92e0c5ea41156491977edf73)) +- **sdk-coin-ada:** token sponsorship support ([12e0c78](https://github.com/BitGo/BitGoJS/commit/12e0c78cef2d763d0e6de4bea94973d7b0e1788a)) ## [4.20.8](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.20.7...@bitgo/sdk-coin-ada@4.20.8) (2026-01-19) - ### Bug Fixes -* **sdk-coin-ada:** use derivedFromParentWithSeed in address verification ([852137d](https://github.com/BitGo/BitGoJS/commit/852137d53e5813aaaccc0590379f81aafd708892)) - - - - +- **sdk-coin-ada:** use derivedFromParentWithSeed in address verification ([852137d](https://github.com/BitGo/BitGoJS/commit/852137d53e5813aaaccc0590379f81aafd708892)) ## [4.20.7](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.20.6...@bitgo/sdk-coin-ada@4.20.7) (2026-01-19) **Note:** Version bump only for package @bitgo/sdk-coin-ada - - - - ## [4.20.6](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.20.5...@bitgo/sdk-coin-ada@4.20.6) (2026-01-14) **Note:** Version bump only for package @bitgo/sdk-coin-ada - - - - ## [4.20.5](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.20.4...@bitgo/sdk-coin-ada@4.20.5) (2026-01-07) **Note:** Version bump only for package @bitgo/sdk-coin-ada - - - - ## [4.20.4](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.20.3...@bitgo/sdk-coin-ada@4.20.4) (2025-12-23) **Note:** Version bump only for package @bitgo/sdk-coin-ada - - - - ## [4.20.3](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.20.2...@bitgo/sdk-coin-ada@4.20.3) (2025-12-17) **Note:** Version bump only for package @bitgo/sdk-coin-ada - - - - ## [4.20.2](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.20.1...@bitgo/sdk-coin-ada@4.20.2) (2025-12-11) **Note:** Version bump only for package @bitgo/sdk-coin-ada - - - - ## [4.20.1](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.20.0...@bitgo/sdk-coin-ada@4.20.1) (2025-12-05) **Note:** Version bump only for package @bitgo/sdk-coin-ada - - - - # [4.20.0](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.19.0...@bitgo/sdk-coin-ada@4.20.0) (2025-12-04) - ### Features -* address verification for ada ([b4ed3c5](https://github.com/BitGo/BitGoJS/commit/b4ed3c56739ad94471b3ccd417217ac91ecb573d)) - - - - +- address verification for ada ([b4ed3c5](https://github.com/BitGo/BitGoJS/commit/b4ed3c56739ad94471b3ccd417217ac91ecb573d)) # [4.19.0](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.18.3...@bitgo/sdk-coin-ada@4.19.0) (2025-11-26) - ### Features -* **sdk-coin-ada:** add build logs and modify token policy id ([8d8482a](https://github.com/BitGo/BitGoJS/commit/8d8482afa50d707bfa69caa6ccbab750a32c76ef)) - - - - +- **sdk-coin-ada:** add build logs and modify token policy id ([8d8482a](https://github.com/BitGo/BitGoJS/commit/8d8482afa50d707bfa69caa6ccbab750a32c76ef)) ## [4.18.3](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.18.2...@bitgo/sdk-coin-ada@4.18.3) (2025-11-19) **Note:** Version bump only for package @bitgo/sdk-coin-ada - - - - ## [4.18.2](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.18.1...@bitgo/sdk-coin-ada@4.18.2) (2025-11-13) **Note:** Version bump only for package @bitgo/sdk-coin-ada - - - - ## [4.18.1](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.18.0...@bitgo/sdk-coin-ada@4.18.1) (2025-11-12) - ### Bug Fixes -* **sdk-coin-ada:** shouldn't throw insufficient qty for total token spend ([6820999](https://github.com/BitGo/BitGoJS/commit/6820999b2d8ce47110d894875db15a0569f31cba)) - - - - +- **sdk-coin-ada:** shouldn't throw insufficient qty for total token spend ([6820999](https://github.com/BitGo/BitGoJS/commit/6820999b2d8ce47110d894875db15a0569f31cba)) # [4.18.0](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.17.4...@bitgo/sdk-coin-ada@4.18.0) (2025-11-06) - ### Features -* deserialize signed CIP-8 message hex ([66b973a](https://github.com/BitGo/BitGoJS/commit/66b973a4708e1b96c53c3785c65654a63b0d43bb)) - - - - +- deserialize signed CIP-8 message hex ([66b973a](https://github.com/BitGo/BitGoJS/commit/66b973a4708e1b96c53c3785c65654a63b0d43bb)) ## [4.17.4](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.17.3...@bitgo/sdk-coin-ada@4.17.4) (2025-10-31) **Note:** Version bump only for package @bitgo/sdk-coin-ada - - - - ## [4.17.3](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.17.2...@bitgo/sdk-coin-ada@4.17.3) (2025-10-29) **Note:** Version bump only for package @bitgo/sdk-coin-ada - - - - ## [4.17.2](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.17.1...@bitgo/sdk-coin-ada@4.17.2) (2025-10-24) **Note:** Version bump only for package @bitgo/sdk-coin-ada - - - - ## [4.17.1](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.17.0...@bitgo/sdk-coin-ada@4.17.1) (2025-10-21) **Note:** Version bump only for package @bitgo/sdk-coin-ada - - - - # [4.17.0](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.16.2...@bitgo/sdk-coin-ada@4.17.0) (2025-10-16) - ### Features -* **sdk-coin-ada:** fix ada build signature handling ([34dacbc](https://github.com/BitGo/BitGoJS/commit/34dacbcc1a2e4619503f5a93410b611f55bbc847)) -* **sdk-coin-ada:** remove fallback logic for token fee calculation ([daef78e](https://github.com/BitGo/BitGoJS/commit/daef78ea58e9c93c4f1b4e0d78a0249ca6c5f524)) - - - - +- **sdk-coin-ada:** fix ada build signature handling ([34dacbc](https://github.com/BitGo/BitGoJS/commit/34dacbcc1a2e4619503f5a93410b611f55bbc847)) +- **sdk-coin-ada:** remove fallback logic for token fee calculation ([daef78e](https://github.com/BitGo/BitGoJS/commit/daef78ea58e9c93c4f1b4e0d78a0249ca6c5f524)) ## [4.16.2](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.16.1...@bitgo/sdk-coin-ada@4.16.2) (2025-10-13) **Note:** Version bump only for package @bitgo/sdk-coin-ada - - - - ## [4.16.1](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.16.0...@bitgo/sdk-coin-ada@4.16.1) (2025-10-09) - ### Bug Fixes -* run check-fmt on code files only ([9745196](https://github.com/BitGo/BitGoJS/commit/9745196b02b9678c740d290a4638ceb153a8fd75)) - - - - +- run check-fmt on code files only ([9745196](https://github.com/BitGo/BitGoJS/commit/9745196b02b9678c740d290a4638ceb153a8fd75)) # [4.16.0](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.15.2...@bitgo/sdk-coin-ada@4.16.0) (2025-10-08) - ### Bug Fixes -* add explicit 'files' in package json ([3b00373](https://github.com/BitGo/BitGoJS/commit/3b0037396f6ac16bb9380bd85bf37f2b133068f4)) - +- add explicit 'files' in package json ([3b00373](https://github.com/BitGo/BitGoJS/commit/3b0037396f6ac16bb9380bd85bf37f2b133068f4)) ### Features -* **sdk-coin-ada:** use 1 ada as min fees ([558f621](https://github.com/BitGo/BitGoJS/commit/558f6213131e75aac3d0cefb12ac7633fe7c9419)) - - - - +- **sdk-coin-ada:** use 1 ada as min fees ([558f621](https://github.com/BitGo/BitGoJS/commit/558f6213131e75aac3d0cefb12ac7633fe7c9419)) ## [4.15.2](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.15.1...@bitgo/sdk-coin-ada@4.15.2) (2025-10-02) diff --git a/modules/sdk-coin-ada/src/ada.ts b/modules/sdk-coin-ada/src/ada.ts index b55e8cc12c..f20480a4b1 100644 --- a/modules/sdk-coin-ada/src/ada.ts +++ b/modules/sdk-coin-ada/src/ada.ts @@ -382,10 +382,10 @@ export class Ada extends BaseCoin { seed: params.seed, }; const { address: senderAddr, accountId } = await this.getAdaAddressAndAccountId(addressParams); - const isUnsignedSweep = !params.userKey && !params.backupKey && !params.walletPassphrase; + const isUnsignedSweep = !params.walletPassphrase; const { balance, utxoSet } = await this.getAddressInfo(senderAddr); if (balance <= 0) { - throw new Error('Did not find address with funds to recover'); + throw new Error('Did not find address with funds to recover.'); } // first build the unsigned txn @@ -407,7 +407,8 @@ export class Ada extends BaseCoin { (acc: BigNumber, output: { amount: string }) => new BigNumber(acc).plus(output.amount), new BigNumber(0) ); - if (amount.isLessThan(10000000)) { + + if (amount.isLessThan(1000000)) { throw new Error( 'Insufficient funds to recover, minimum required is 1 ADA plus fees, got ' + amount.toString() + @@ -556,7 +557,10 @@ export class Ada extends BaseCoin { try { recoveryTransaction = await this.recover(recoverParams); } catch (e) { - if (e.message === 'Did not find address with funds to recover') { + if ( + e.message === 'Did not find address with funds to recover.' || + e.message.startsWith('Insufficient funds to recover') + ) { lastScanIndex = i; continue; } @@ -572,7 +576,7 @@ export class Ada extends BaseCoin { } if (consolidationTransactions.length == 0) { - throw new Error('Did not find an address with funds to recover'); + throw new Error('Did not find an address with funds to recover.'); } if (isUnsignedSweep) { diff --git a/modules/sdk-coin-ada/test/resources/index.ts b/modules/sdk-coin-ada/test/resources/index.ts index 960e864d1a..930252d7a8 100644 --- a/modules/sdk-coin-ada/test/resources/index.ts +++ b/modules/sdk-coin-ada/test/resources/index.ts @@ -373,7 +373,7 @@ export const testnetUTXO = { UTXO_3: { tx_hash: '87f6e905a5796277ffb256265fd18d16f84ddb54ec8a841f7d467360c1c9fc2f', tx_index: 0, - value: 10000000, + value: 1000000, }, }; diff --git a/modules/sdk-coin-ada/test/unit/ada.ts b/modules/sdk-coin-ada/test/unit/ada.ts index f5d657f39a..7496490766 100644 --- a/modules/sdk-coin-ada/test/unit/ada.ts +++ b/modules/sdk-coin-ada/test/unit/ada.ts @@ -734,7 +734,7 @@ describe('ADA', function () { startingScanIndex: 1, endingScanIndex: 2, }) - .should.rejectedWith('Did not find an address with funds to recover'); + .should.rejectedWith('Did not find an address with funds to recover.'); }); it('should throw if startingScanIndex is not ge to 1', async () => { @@ -763,6 +763,77 @@ describe('ADA', function () { 'Invalid starting or ending index to scan for addresses. startingScanIndex: 1, endingScanIndex: 300.' ); }); + + it('should build unsigned consolidation recoveries', async function () { + const res = await basecoin.recoverConsolidations({ + userKey: consolidationWrwUser.userKey, + backupKey: consolidationWrwUser.backupKey, + bitgoKey: consolidationWrwUser.bitgoKey, + walletPassphrase: consolidationWrwUser.walletPassphrase, + startingScanIndex: 1, + endingScanIndex: 4, + }); + res.should.not.be.empty(); + res.transactions.length.should.equal(2); + }); + + it('should throw error if all addresses have balance less than 1 ADA', async function () { + sandBox.restore(); + const callBack = sandBox.stub(Ada.prototype, 'getDataFromNode' as keyof Ada); + callBack.withArgs('address_info', sinon.match.has('_addresses')).resolves({ + status: 200, + body: [ + { + balance: 500000, + utxo_set: [ + { + tx_hash: '8df8d41207980f9e21de698bd5d6c395c39e420f7de27f8539052dd34e3a28d6', + tx_index: 0, + value: 500000, + }, + ], + }, + ], + }); + callBack.withArgs('tip').resolves(endpointResponses.tipInfoResponse); + + await basecoin + .recoverConsolidations({ + userKey: consolidationWrwUser.userKey, + backupKey: consolidationWrwUser.backupKey, + bitgoKey: consolidationWrwUser.bitgoKey, + walletPassphrase: consolidationWrwUser.walletPassphrase, + startingScanIndex: 1, + endingScanIndex: 4, + }) + .should.be.rejectedWith('Did not find an address with funds to recover.'); + }); + + it('should build even if single address has no funds', async function () { + const res = await basecoin.recoverConsolidations({ + userKey: consolidationWrwUser.userKey, + backupKey: consolidationWrwUser.backupKey, + bitgoKey: consolidationWrwUser.bitgoKey, + walletPassphrase: consolidationWrwUser.walletPassphrase, + startingScanIndex: 1, + endingScanIndex: 4, + }); + res.should.not.be.empty(); + res.transactions.length.should.equal(2); + }); + + it('should build even if single address has insufficient funds', async function () { + const res = await basecoin.recoverConsolidations({ + userKey: consolidationWrwUser.userKey, + backupKey: consolidationWrwUser.backupKey, + bitgoKey: consolidationWrwUser.bitgoKey, + walletPassphrase: consolidationWrwUser.walletPassphrase, + startingScanIndex: 1, + endingScanIndex: 4, + }); + res.should.not.be.empty(); + res.transactions.length.should.equal(2); + }); }); describe('Recover Transactions Failure:', () => { @@ -787,7 +858,7 @@ describe('ADA', function () { walletPassphrase: wrwUser.walletPassphrase, recoveryDestination: destAddr, }) - .should.rejectedWith('Did not find address with funds to recover'); + .should.rejectedWith('Did not find address with funds to recover.'); sandBox.assert.calledOnce(basecoin.getDataFromNode); }); @@ -806,7 +877,7 @@ describe('ADA', function () { recoveryDestination: destAddr, }) .should.rejectedWith( - 'Insufficient funds to recover, minimum required is 1 ADA plus fees, got 9834455 fees: 165545' + 'Insufficient funds to recover, minimum required is 1 ADA plus fees, got 834455 fees: 165545' ); sandBox.assert.calledTwice(basecoin.getDataFromNode); });