@ledgerhq/coin-xrp 7.4.0-nightly.5 → 7.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +20 -33
- package/lib/logic/getBalance.d.ts.map +1 -1
- package/lib/logic/getBalance.js +1 -7
- package/lib/logic/getBalance.js.map +1 -1
- package/lib/logic/getBalance.test.js +2 -24
- package/lib/logic/getBalance.test.js.map +1 -1
- package/lib-es/logic/getBalance.d.ts.map +1 -1
- package/lib-es/logic/getBalance.js +1 -4
- package/lib-es/logic/getBalance.js.map +1 -1
- package/lib-es/logic/getBalance.test.js +2 -24
- package/lib-es/logic/getBalance.test.js.map +1 -1
- package/package.json +6 -6
- package/src/logic/getBalance.test.ts +2 -26
- package/src/logic/getBalance.ts +1 -5
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
> @ledgerhq/coin-xrp@7.4.0
|
|
2
|
+
> @ledgerhq/coin-xrp@7.4.0 build /home/runner/work/ledger-live/ledger-live/libs/coin-modules/coin-xrp
|
|
3
3
|
> tsc && tsc -m esnext --moduleResolution bundler --outDir lib-es
|
|
4
4
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,57 +1,44 @@
|
|
|
1
1
|
# @ledgerhq/coin-xrp
|
|
2
2
|
|
|
3
|
-
## 7.4.0
|
|
3
|
+
## 7.4.0
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
7
|
-
- [#
|
|
7
|
+
- [#11635](https://github.com/LedgerHQ/ledger-live/pull/11635) [`8e79bfb`](https://github.com/LedgerHQ/ledger-live/commit/8e79bfb5ab1189f27c031f775d7378319774570c) Thanks [@estrauser-ledger](https://github.com/estrauser-ledger)! - fix xrp operations pagination
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
### Patch Changes
|
|
12
|
-
|
|
13
|
-
- Updated dependencies [[`9b8689a`](https://github.com/LedgerHQ/ledger-live/commit/9b8689ae2c44bdeccae26378e05cbf6899b83aec), [`6941aac`](https://github.com/LedgerHQ/ledger-live/commit/6941aac638dcc8d4fb03aa92f42d2a71d4089202)]:
|
|
14
|
-
- @ledgerhq/types-live@6.84.0-nightly.1
|
|
15
|
-
- @ledgerhq/coin-framework@6.4.0-nightly.4
|
|
16
|
-
|
|
17
|
-
## 7.4.0-nightly.3
|
|
18
|
-
|
|
19
|
-
### Patch Changes
|
|
9
|
+
- [#11699](https://github.com/LedgerHQ/ledger-live/pull/11699) [`2b896f9`](https://github.com/LedgerHQ/ledger-live/commit/2b896f94d6fc53ef965ed567489ad96d913466d4) Thanks [@jnicoulaud-ledger](https://github.com/jnicoulaud-ledger)! - feat(BACK-9645): add support for returning details in AlpacaApi.craftTransaction
|
|
20
10
|
|
|
21
|
-
-
|
|
22
|
-
- @ledgerhq/cryptoassets@13.28.0-nightly.2
|
|
23
|
-
- @ledgerhq/coin-framework@6.4.0-nightly.3
|
|
24
|
-
- @ledgerhq/types-live@6.83.1-nightly.0
|
|
11
|
+
- [#11273](https://github.com/LedgerHQ/ledger-live/pull/11273) [`2482195`](https://github.com/LedgerHQ/ledger-live/commit/24821957c838a304be60ff6e16798ef3cac987cd) Thanks [@estrauser-ledger](https://github.com/estrauser-ledger)! - add cursor to pagintion api
|
|
25
12
|
|
|
26
|
-
|
|
13
|
+
- [#11560](https://github.com/LedgerHQ/ledger-live/pull/11560) [`0432d2a`](https://github.com/LedgerHQ/ledger-live/commit/0432d2aca30d74eb00abdc8427c4c34725f34b13) Thanks [@hedi-edelbloute](https://github.com/hedi-edelbloute)! - Integ tests xrp mainnet + value fix for xrp ops
|
|
27
14
|
|
|
28
15
|
### Patch Changes
|
|
29
16
|
|
|
30
|
-
- Updated dependencies [[`
|
|
31
|
-
- @ledgerhq/
|
|
32
|
-
- @ledgerhq/
|
|
33
|
-
- @ledgerhq/
|
|
34
|
-
- @ledgerhq/live-network@2.0.17
|
|
17
|
+
- Updated dependencies [[`2b896f9`](https://github.com/LedgerHQ/ledger-live/commit/2b896f94d6fc53ef965ed567489ad96d913466d4), [`338d979`](https://github.com/LedgerHQ/ledger-live/commit/338d979bae349b185c52b1d8c9f6718a3d142526), [`2482195`](https://github.com/LedgerHQ/ledger-live/commit/24821957c838a304be60ff6e16798ef3cac987cd), [`228ed30`](https://github.com/LedgerHQ/ledger-live/commit/228ed3030601644e807e85a1693276b788b5cd2a), [`89fc31e`](https://github.com/LedgerHQ/ledger-live/commit/89fc31e8ecfc5e2fd679a2694b3514f8fb19d7b7), [`ff22728`](https://github.com/LedgerHQ/ledger-live/commit/ff22728a61ab2cde6835991bf8ed115d4a39a1d0), [`c190e2b`](https://github.com/LedgerHQ/ledger-live/commit/c190e2b104a9dd0dd693c2d72433b98115f4089f), [`a87922d`](https://github.com/LedgerHQ/ledger-live/commit/a87922dc99e4f2e4b40a46fd52ad08a71012fe94), [`80a109a`](https://github.com/LedgerHQ/ledger-live/commit/80a109a5f8ecdbb22cf6fb3ec084398a7e54dcfb), [`3489203`](https://github.com/LedgerHQ/ledger-live/commit/34892030dcfbd1a19a0eb0a8fcae9f8f01d3d2a9)]:
|
|
18
|
+
- @ledgerhq/coin-framework@6.4.0
|
|
19
|
+
- @ledgerhq/cryptoassets@13.28.0
|
|
20
|
+
- @ledgerhq/types-live@6.84.0
|
|
21
|
+
- @ledgerhq/live-network@2.0.17
|
|
35
22
|
|
|
36
|
-
## 7.4.0-
|
|
23
|
+
## 7.4.0-next.0
|
|
37
24
|
|
|
38
25
|
### Minor Changes
|
|
39
26
|
|
|
40
|
-
- [#
|
|
27
|
+
- [#11635](https://github.com/LedgerHQ/ledger-live/pull/11635) [`8e79bfb`](https://github.com/LedgerHQ/ledger-live/commit/8e79bfb5ab1189f27c031f775d7378319774570c) Thanks [@estrauser-ledger](https://github.com/estrauser-ledger)! - fix xrp operations pagination
|
|
41
28
|
|
|
42
|
-
|
|
29
|
+
- [#11699](https://github.com/LedgerHQ/ledger-live/pull/11699) [`2b896f9`](https://github.com/LedgerHQ/ledger-live/commit/2b896f94d6fc53ef965ed567489ad96d913466d4) Thanks [@jnicoulaud-ledger](https://github.com/jnicoulaud-ledger)! - feat(BACK-9645): add support for returning details in AlpacaApi.craftTransaction
|
|
43
30
|
|
|
44
|
-
-
|
|
45
|
-
- @ledgerhq/coin-framework@6.4.0-nightly.1
|
|
46
|
-
- @ledgerhq/cryptoassets@13.28.0-nightly.0
|
|
47
|
-
- @ledgerhq/live-network@2.0.17-nightly.0
|
|
31
|
+
- [#11273](https://github.com/LedgerHQ/ledger-live/pull/11273) [`2482195`](https://github.com/LedgerHQ/ledger-live/commit/24821957c838a304be60ff6e16798ef3cac987cd) Thanks [@estrauser-ledger](https://github.com/estrauser-ledger)! - add cursor to pagintion api
|
|
48
32
|
|
|
49
|
-
|
|
33
|
+
- [#11560](https://github.com/LedgerHQ/ledger-live/pull/11560) [`0432d2a`](https://github.com/LedgerHQ/ledger-live/commit/0432d2aca30d74eb00abdc8427c4c34725f34b13) Thanks [@hedi-edelbloute](https://github.com/hedi-edelbloute)! - Integ tests xrp mainnet + value fix for xrp ops
|
|
50
34
|
|
|
51
35
|
### Patch Changes
|
|
52
36
|
|
|
53
|
-
- Updated dependencies [[`c190e2b`](https://github.com/LedgerHQ/ledger-live/commit/c190e2b104a9dd0dd693c2d72433b98115f4089f)]:
|
|
54
|
-
- @ledgerhq/coin-framework@6.4.0-
|
|
37
|
+
- Updated dependencies [[`2b896f9`](https://github.com/LedgerHQ/ledger-live/commit/2b896f94d6fc53ef965ed567489ad96d913466d4), [`338d979`](https://github.com/LedgerHQ/ledger-live/commit/338d979bae349b185c52b1d8c9f6718a3d142526), [`2482195`](https://github.com/LedgerHQ/ledger-live/commit/24821957c838a304be60ff6e16798ef3cac987cd), [`228ed30`](https://github.com/LedgerHQ/ledger-live/commit/228ed3030601644e807e85a1693276b788b5cd2a), [`89fc31e`](https://github.com/LedgerHQ/ledger-live/commit/89fc31e8ecfc5e2fd679a2694b3514f8fb19d7b7), [`ff22728`](https://github.com/LedgerHQ/ledger-live/commit/ff22728a61ab2cde6835991bf8ed115d4a39a1d0), [`c190e2b`](https://github.com/LedgerHQ/ledger-live/commit/c190e2b104a9dd0dd693c2d72433b98115f4089f), [`a87922d`](https://github.com/LedgerHQ/ledger-live/commit/a87922dc99e4f2e4b40a46fd52ad08a71012fe94), [`80a109a`](https://github.com/LedgerHQ/ledger-live/commit/80a109a5f8ecdbb22cf6fb3ec084398a7e54dcfb), [`3489203`](https://github.com/LedgerHQ/ledger-live/commit/34892030dcfbd1a19a0eb0a8fcae9f8f01d3d2a9)]:
|
|
38
|
+
- @ledgerhq/coin-framework@6.4.0-next.0
|
|
39
|
+
- @ledgerhq/cryptoassets@13.28.0-next.0
|
|
40
|
+
- @ledgerhq/types-live@6.84.0-next.0
|
|
41
|
+
- @ledgerhq/live-network@2.0.17-next.0
|
|
55
42
|
|
|
56
43
|
## 7.3.0
|
|
57
44
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBalance.d.ts","sourceRoot":"","sources":["../../src/logic/getBalance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"getBalance.d.ts","sourceRoot":"","sources":["../../src/logic/getBalance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAI7D,wBAAsB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAkBpE"}
|
package/lib/logic/getBalance.js
CHANGED
|
@@ -1,21 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.getBalance = getBalance;
|
|
7
4
|
const network_1 = require("../network");
|
|
8
5
|
const common_1 = require("./common");
|
|
9
|
-
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
10
6
|
async function getBalance(address) {
|
|
11
7
|
const accountInfo = await (0, network_1.getAccountInfo)(address);
|
|
12
8
|
const serverInfo = await (0, network_1.getServerInfos)();
|
|
13
9
|
const reserveMinXRP = (0, common_1.parseAPIValue)(serverInfo.info.validated_ledger.reserve_base_xrp.toString());
|
|
14
10
|
const reservePerTrustline = (0, common_1.parseAPIValue)(serverInfo.info.validated_ledger.reserve_inc_xrp.toString());
|
|
15
11
|
const trustlines = accountInfo.ownerCount;
|
|
16
|
-
const locked =
|
|
17
|
-
? new bignumber_js_1.default(0)
|
|
18
|
-
: reserveMinXRP.plus(reservePerTrustline.times(trustlines));
|
|
12
|
+
const locked = reserveMinXRP.plus(reservePerTrustline.times(trustlines));
|
|
19
13
|
return [
|
|
20
14
|
{
|
|
21
15
|
value: BigInt(accountInfo.balance),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBalance.js","sourceRoot":"","sources":["../../src/logic/getBalance.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getBalance.js","sourceRoot":"","sources":["../../src/logic/getBalance.ts"],"names":[],"mappings":";;AAIA,gCAkBC;AArBD,wCAA4D;AAC5D,qCAAyC;AAElC,KAAK,UAAU,UAAU,CAAC,OAAe;IAC9C,MAAM,WAAW,GAAG,MAAM,IAAA,wBAAc,EAAC,OAAO,CAAC,CAAC;IAClD,MAAM,UAAU,GAAG,MAAM,IAAA,wBAAc,GAAE,CAAC;IAE1C,MAAM,aAAa,GAAG,IAAA,sBAAa,EAAC,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAC,CAAC;IAClG,MAAM,mBAAmB,GAAG,IAAA,sBAAa,EACvC,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC,eAAe,CAAC,QAAQ,EAAE,CAC5D,CAAC;IACF,MAAM,UAAU,GAAG,WAAW,CAAC,UAAU,CAAC;IAE1C,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;IACzE,OAAO;QACL;YACE,KAAK,EAAE,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC;YAClC,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACzB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;SAClC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const faker_1 = require("@faker-js/faker");
|
|
4
4
|
const getBalance_1 = require("./getBalance");
|
|
5
|
-
const address = "ACCOUNT_ADDRESS";
|
|
6
5
|
const mockGetAccountInfo = jest.fn();
|
|
7
6
|
const mockGetServerInfos = jest.fn();
|
|
8
7
|
jest.mock("../network", () => ({
|
|
@@ -25,8 +24,9 @@ describe("getBalance", () => {
|
|
|
25
24
|
});
|
|
26
25
|
// Given
|
|
27
26
|
const balance = faker_1.faker.number.bigInt(100_000_000);
|
|
27
|
+
const address = "ACCOUNT_ADDRESS";
|
|
28
28
|
mockGetAccountInfo.mockResolvedValue({
|
|
29
|
-
balance
|
|
29
|
+
balance,
|
|
30
30
|
ownerCount: 0,
|
|
31
31
|
});
|
|
32
32
|
// When
|
|
@@ -37,27 +37,5 @@ describe("getBalance", () => {
|
|
|
37
37
|
expect(mockGetAccountInfo.mock.lastCall[0]).toEqual(address);
|
|
38
38
|
expect(result).toEqual([{ value: balance, asset: { type: "native" }, locked: 23000000n }]);
|
|
39
39
|
});
|
|
40
|
-
it("returns from account with empty balance", async () => {
|
|
41
|
-
mockGetServerInfos.mockResolvedValue({
|
|
42
|
-
info: {
|
|
43
|
-
validated_ledger: {
|
|
44
|
-
reserve_base_xrp: 23,
|
|
45
|
-
reserve_inc_xrp: 5,
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
// Given
|
|
50
|
-
mockGetAccountInfo.mockResolvedValue({
|
|
51
|
-
balance: "0",
|
|
52
|
-
ownerCount: 0,
|
|
53
|
-
});
|
|
54
|
-
// When
|
|
55
|
-
const result = await (0, getBalance_1.getBalance)(address);
|
|
56
|
-
// Then
|
|
57
|
-
expect(mockGetAccountInfo).toHaveBeenCalledTimes(1);
|
|
58
|
-
expect(mockGetServerInfos).toHaveBeenCalledTimes(1);
|
|
59
|
-
expect(mockGetAccountInfo.mock.lastCall[0]).toEqual(address);
|
|
60
|
-
expect(result).toEqual([{ value: 0n, asset: { type: "native" }, locked: 0n }]);
|
|
61
|
-
});
|
|
62
40
|
});
|
|
63
41
|
//# sourceMappingURL=getBalance.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBalance.test.js","sourceRoot":"","sources":["../../src/logic/getBalance.test.ts"],"names":[],"mappings":";;AAAA,2CAAwC;AACxC,6CAA0C;AAE1C,MAAM,
|
|
1
|
+
{"version":3,"file":"getBalance.test.js","sourceRoot":"","sources":["../../src/logic/getBalance.test.ts"],"names":[],"mappings":";;AAAA,2CAAwC;AACxC,6CAA0C;AAE1C,MAAM,kBAAkB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AACrC,MAAM,kBAAkB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AACrC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,GAAG,EAAE,CAAC,CAAC;IAC7B,cAAc,EAAE,CAAC,OAAe,EAAE,EAAE,CAAC,kBAAkB,CAAC,OAAO,CAAC;IAChE,cAAc,EAAE,GAAG,EAAE,CAAC,kBAAkB,EAAE;CAC3C,CAAC,CAAC,CAAC;AAEJ,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,SAAS,CAAC,GAAG,EAAE;QACb,kBAAk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,CAAC;
|
|
1
|
+
{"version":3,"file":"getBalance.d.ts","sourceRoot":"","sources":["../../src/logic/getBalance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAI7D,wBAAsB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAkBpE"}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { getAccountInfo, getServerInfos } from "../network";
|
|
2
2
|
import { parseAPIValue } from "./common";
|
|
3
|
-
import BigNumber from "bignumber.js";
|
|
4
3
|
export async function getBalance(address) {
|
|
5
4
|
const accountInfo = await getAccountInfo(address);
|
|
6
5
|
const serverInfo = await getServerInfos();
|
|
7
6
|
const reserveMinXRP = parseAPIValue(serverInfo.info.validated_ledger.reserve_base_xrp.toString());
|
|
8
7
|
const reservePerTrustline = parseAPIValue(serverInfo.info.validated_ledger.reserve_inc_xrp.toString());
|
|
9
8
|
const trustlines = accountInfo.ownerCount;
|
|
10
|
-
const locked =
|
|
11
|
-
? new BigNumber(0)
|
|
12
|
-
: reserveMinXRP.plus(reservePerTrustline.times(trustlines));
|
|
9
|
+
const locked = reserveMinXRP.plus(reservePerTrustline.times(trustlines));
|
|
13
10
|
return [
|
|
14
11
|
{
|
|
15
12
|
value: BigInt(accountInfo.balance),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBalance.js","sourceRoot":"","sources":["../../src/logic/getBalance.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"getBalance.js","sourceRoot":"","sources":["../../src/logic/getBalance.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,OAAe;IAC9C,MAAM,WAAW,GAAG,MAAM,cAAc,CAAC,OAAO,CAAC,CAAC;IAClD,MAAM,UAAU,GAAG,MAAM,cAAc,EAAE,CAAC;IAE1C,MAAM,aAAa,GAAG,aAAa,CAAC,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAC,CAAC;IAClG,MAAM,mBAAmB,GAAG,aAAa,CACvC,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC,eAAe,CAAC,QAAQ,EAAE,CAC5D,CAAC;IACF,MAAM,UAAU,GAAG,WAAW,CAAC,UAAU,CAAC;IAE1C,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;IACzE,OAAO;QACL;YACE,KAAK,EAAE,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC;YAClC,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACzB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;SAClC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { faker } from "@faker-js/faker";
|
|
2
2
|
import { getBalance } from "./getBalance";
|
|
3
|
-
const address = "ACCOUNT_ADDRESS";
|
|
4
3
|
const mockGetAccountInfo = jest.fn();
|
|
5
4
|
const mockGetServerInfos = jest.fn();
|
|
6
5
|
jest.mock("../network", () => ({
|
|
@@ -23,8 +22,9 @@ describe("getBalance", () => {
|
|
|
23
22
|
});
|
|
24
23
|
// Given
|
|
25
24
|
const balance = faker.number.bigInt(100_000_000);
|
|
25
|
+
const address = "ACCOUNT_ADDRESS";
|
|
26
26
|
mockGetAccountInfo.mockResolvedValue({
|
|
27
|
-
balance
|
|
27
|
+
balance,
|
|
28
28
|
ownerCount: 0,
|
|
29
29
|
});
|
|
30
30
|
// When
|
|
@@ -35,27 +35,5 @@ describe("getBalance", () => {
|
|
|
35
35
|
expect(mockGetAccountInfo.mock.lastCall[0]).toEqual(address);
|
|
36
36
|
expect(result).toEqual([{ value: balance, asset: { type: "native" }, locked: 23000000n }]);
|
|
37
37
|
});
|
|
38
|
-
it("returns from account with empty balance", async () => {
|
|
39
|
-
mockGetServerInfos.mockResolvedValue({
|
|
40
|
-
info: {
|
|
41
|
-
validated_ledger: {
|
|
42
|
-
reserve_base_xrp: 23,
|
|
43
|
-
reserve_inc_xrp: 5,
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
});
|
|
47
|
-
// Given
|
|
48
|
-
mockGetAccountInfo.mockResolvedValue({
|
|
49
|
-
balance: "0",
|
|
50
|
-
ownerCount: 0,
|
|
51
|
-
});
|
|
52
|
-
// When
|
|
53
|
-
const result = await getBalance(address);
|
|
54
|
-
// Then
|
|
55
|
-
expect(mockGetAccountInfo).toHaveBeenCalledTimes(1);
|
|
56
|
-
expect(mockGetServerInfos).toHaveBeenCalledTimes(1);
|
|
57
|
-
expect(mockGetAccountInfo.mock.lastCall[0]).toEqual(address);
|
|
58
|
-
expect(result).toEqual([{ value: 0n, asset: { type: "native" }, locked: 0n }]);
|
|
59
|
-
});
|
|
60
38
|
});
|
|
61
39
|
//# sourceMappingURL=getBalance.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBalance.test.js","sourceRoot":"","sources":["../../src/logic/getBalance.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,MAAM,
|
|
1
|
+
{"version":3,"file":"getBalance.test.js","sourceRoot":"","sources":["../../src/logic/getBalance.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,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AAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC7D,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;IAC7F,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/coin-xrp",
|
|
3
|
-
"version": "7.4.0
|
|
3
|
+
"version": "7.4.0",
|
|
4
4
|
"description": "Ledger XRP Coin integration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ledger",
|
|
@@ -103,12 +103,12 @@
|
|
|
103
103
|
"invariant": "^2.2.4",
|
|
104
104
|
"ripple-address-codec": "^5.0.0",
|
|
105
105
|
"ripple-binary-codec": "^1.3.0",
|
|
106
|
-
"@ledgerhq/coin-framework": "^6.4.0
|
|
107
|
-
"@ledgerhq/cryptoassets": "^13.28.0
|
|
106
|
+
"@ledgerhq/coin-framework": "^6.4.0",
|
|
107
|
+
"@ledgerhq/cryptoassets": "^13.28.0",
|
|
108
108
|
"@ledgerhq/devices": "8.5.1",
|
|
109
109
|
"@ledgerhq/errors": "^6.25.0",
|
|
110
|
-
"@ledgerhq/live-network": "^2.0.17
|
|
111
|
-
"@ledgerhq/types-live": "^6.84.0
|
|
110
|
+
"@ledgerhq/live-network": "^2.0.17",
|
|
111
|
+
"@ledgerhq/types-live": "^6.84.0",
|
|
112
112
|
"@ledgerhq/logs": "^6.13.0"
|
|
113
113
|
},
|
|
114
114
|
"devDependencies": {
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
"ts-jest": "^29.1.1",
|
|
123
123
|
"typescript": "^5.4.5",
|
|
124
124
|
"@ledgerhq/disable-network-setup": "^0.0.0",
|
|
125
|
-
"@ledgerhq/types-cryptoassets": "^7.
|
|
125
|
+
"@ledgerhq/types-cryptoassets": "^7.26.0"
|
|
126
126
|
},
|
|
127
127
|
"scripts": {
|
|
128
128
|
"clean": "rimraf lib lib-es",
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { faker } from "@faker-js/faker";
|
|
2
2
|
import { getBalance } from "./getBalance";
|
|
3
3
|
|
|
4
|
-
const address = "ACCOUNT_ADDRESS";
|
|
5
4
|
const mockGetAccountInfo = jest.fn();
|
|
6
5
|
const mockGetServerInfos = jest.fn();
|
|
7
6
|
jest.mock("../network", () => ({
|
|
@@ -26,8 +25,9 @@ describe("getBalance", () => {
|
|
|
26
25
|
});
|
|
27
26
|
// Given
|
|
28
27
|
const balance = faker.number.bigInt(100_000_000);
|
|
28
|
+
const address = "ACCOUNT_ADDRESS";
|
|
29
29
|
mockGetAccountInfo.mockResolvedValue({
|
|
30
|
-
balance
|
|
30
|
+
balance,
|
|
31
31
|
ownerCount: 0,
|
|
32
32
|
});
|
|
33
33
|
|
|
@@ -40,28 +40,4 @@ describe("getBalance", () => {
|
|
|
40
40
|
expect(mockGetAccountInfo.mock.lastCall[0]).toEqual(address);
|
|
41
41
|
expect(result).toEqual([{ value: balance, asset: { type: "native" }, locked: 23000000n }]);
|
|
42
42
|
});
|
|
43
|
-
|
|
44
|
-
it("returns from account with empty balance", async () => {
|
|
45
|
-
mockGetServerInfos.mockResolvedValue({
|
|
46
|
-
info: {
|
|
47
|
-
validated_ledger: {
|
|
48
|
-
reserve_base_xrp: 23,
|
|
49
|
-
reserve_inc_xrp: 5,
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
// Given
|
|
54
|
-
mockGetAccountInfo.mockResolvedValue({
|
|
55
|
-
balance: "0",
|
|
56
|
-
ownerCount: 0,
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
// When
|
|
60
|
-
const result = await getBalance(address);
|
|
61
|
-
// Then
|
|
62
|
-
expect(mockGetAccountInfo).toHaveBeenCalledTimes(1);
|
|
63
|
-
expect(mockGetServerInfos).toHaveBeenCalledTimes(1);
|
|
64
|
-
expect(mockGetAccountInfo.mock.lastCall[0]).toEqual(address);
|
|
65
|
-
expect(result).toEqual([{ value: 0n, asset: { type: "native" }, locked: 0n }]);
|
|
66
|
-
});
|
|
67
43
|
});
|
package/src/logic/getBalance.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Balance } from "@ledgerhq/coin-framework/api/types";
|
|
2
2
|
import { getAccountInfo, getServerInfos } from "../network";
|
|
3
3
|
import { parseAPIValue } from "./common";
|
|
4
|
-
import BigNumber from "bignumber.js";
|
|
5
4
|
|
|
6
5
|
export async function getBalance(address: string): Promise<Balance[]> {
|
|
7
6
|
const accountInfo = await getAccountInfo(address);
|
|
@@ -13,10 +12,7 @@ export async function getBalance(address: string): Promise<Balance[]> {
|
|
|
13
12
|
);
|
|
14
13
|
const trustlines = accountInfo.ownerCount;
|
|
15
14
|
|
|
16
|
-
const locked =
|
|
17
|
-
accountInfo.balance === "0"
|
|
18
|
-
? new BigNumber(0)
|
|
19
|
-
: reserveMinXRP.plus(reservePerTrustline.times(trustlines));
|
|
15
|
+
const locked = reserveMinXRP.plus(reservePerTrustline.times(trustlines));
|
|
20
16
|
return [
|
|
21
17
|
{
|
|
22
18
|
value: BigInt(accountInfo.balance),
|