@ledgerhq/coin-xrp 6.2.0-next.0 → 6.2.0-next.1
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/.unimportedrc.json +1 -3
- package/CHANGELOG.md +11 -0
- package/lib/api/index.d.ts +11 -2
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.integ.test.js +7 -24
- package/lib/api/index.integ.test.js.map +1 -1
- package/lib/api/index.js +5 -15
- package/lib/api/index.js.map +1 -1
- package/lib/api/index.test.js +9 -18
- package/lib/api/index.test.js.map +1 -1
- package/lib/bridge/broadcast.d.ts +4 -0
- package/lib/bridge/broadcast.d.ts.map +1 -0
- package/lib/bridge/broadcast.js +11 -0
- package/lib/bridge/broadcast.js.map +1 -0
- package/lib/bridge/createTransaction.d.ts +4 -0
- package/lib/bridge/createTransaction.d.ts.map +1 -0
- package/lib/bridge/createTransaction.js +18 -0
- package/lib/bridge/createTransaction.js.map +1 -0
- package/lib/bridge/estimateMaxSpendable.d.ts +4 -0
- package/lib/bridge/estimateMaxSpendable.d.ts.map +1 -0
- package/lib/bridge/estimateMaxSpendable.js +26 -0
- package/lib/bridge/estimateMaxSpendable.js.map +1 -0
- package/lib/bridge/getTransactionStatus.d.ts +4 -0
- package/lib/bridge/getTransactionStatus.d.ts.map +1 -0
- package/lib/{logic → bridge}/getTransactionStatus.js +19 -15
- package/lib/bridge/getTransactionStatus.js.map +1 -0
- package/lib/bridge/index.d.ts +11 -0
- package/lib/bridge/index.d.ts.map +1 -0
- package/lib/bridge/index.js +47 -0
- package/lib/bridge/index.js.map +1 -0
- package/lib/bridge/prepareTransaction.d.ts +4 -0
- package/lib/bridge/prepareTransaction.d.ts.map +1 -0
- package/lib/bridge/prepareTransaction.js +14 -0
- package/lib/bridge/prepareTransaction.js.map +1 -0
- package/lib/bridge/signOperation.d.ts +5 -0
- package/lib/bridge/signOperation.d.ts.map +1 -0
- package/lib/bridge/signOperation.js +76 -0
- package/lib/bridge/signOperation.js.map +1 -0
- package/lib/bridge/synchronization.d.ts +3 -0
- package/lib/bridge/synchronization.d.ts.map +1 -0
- package/lib/bridge/synchronization.js +85 -0
- package/lib/bridge/synchronization.js.map +1 -0
- package/lib/bridge/synchronization.test.d.ts +2 -0
- package/lib/bridge/synchronization.test.d.ts.map +1 -0
- package/lib/bridge/synchronization.test.js +140 -0
- package/lib/bridge/synchronization.test.js.map +1 -0
- package/lib/{transaction.d.ts → bridge/transaction.d.ts} +1 -1
- package/lib/bridge/transaction.d.ts.map +1 -0
- package/lib/bridge/transaction.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -1
- package/lib/logic/combine.d.ts.map +1 -1
- package/lib/logic/combine.js +3 -8
- package/lib/logic/combine.js.map +1 -1
- package/lib/logic/getBalance.d.ts.map +1 -1
- package/lib/logic/getBalance.js +1 -13
- package/lib/logic/getBalance.js.map +1 -1
- package/lib/logic/getBalance.test.js +1 -14
- package/lib/logic/getBalance.test.js.map +1 -1
- package/lib/logic/index.d.ts +1 -2
- package/lib/logic/index.d.ts.map +1 -1
- package/lib/logic/index.js +2 -3
- package/lib/logic/index.js.map +1 -1
- package/lib/logic/utils.d.ts +1 -0
- package/lib/logic/utils.d.ts.map +1 -1
- package/lib/logic/utils.js +10 -14
- package/lib/logic/utils.js.map +1 -1
- package/lib/test/bridgeDatasetTest.d.ts.map +1 -1
- package/lib/test/bridgeDatasetTest.js +7 -7
- package/lib/test/bridgeDatasetTest.js.map +1 -1
- package/lib/types/model.d.ts +0 -7
- package/lib/types/model.d.ts.map +1 -1
- package/lib-es/api/index.d.ts +11 -2
- package/lib-es/api/index.d.ts.map +1 -1
- package/lib-es/api/index.integ.test.js +7 -24
- package/lib-es/api/index.integ.test.js.map +1 -1
- package/lib-es/api/index.js +6 -16
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/api/index.test.js +9 -18
- package/lib-es/api/index.test.js.map +1 -1
- package/lib-es/bridge/broadcast.d.ts +4 -0
- package/lib-es/bridge/broadcast.d.ts.map +1 -0
- package/lib-es/bridge/broadcast.js +7 -0
- package/lib-es/bridge/broadcast.js.map +1 -0
- package/lib-es/bridge/createTransaction.d.ts +4 -0
- package/lib-es/bridge/createTransaction.d.ts.map +1 -0
- package/lib-es/bridge/createTransaction.js +11 -0
- package/lib-es/bridge/createTransaction.js.map +1 -0
- package/lib-es/bridge/estimateMaxSpendable.d.ts +4 -0
- package/lib-es/bridge/estimateMaxSpendable.d.ts.map +1 -0
- package/lib-es/bridge/estimateMaxSpendable.js +19 -0
- package/lib-es/bridge/estimateMaxSpendable.js.map +1 -0
- package/lib-es/bridge/getTransactionStatus.d.ts +4 -0
- package/lib-es/bridge/getTransactionStatus.d.ts.map +1 -0
- package/lib-es/{logic → bridge}/getTransactionStatus.js +14 -13
- package/lib-es/bridge/getTransactionStatus.js.map +1 -0
- package/lib-es/bridge/index.d.ts +11 -0
- package/lib-es/bridge/index.d.ts.map +1 -0
- package/lib-es/bridge/index.js +41 -0
- package/lib-es/bridge/index.js.map +1 -0
- package/lib-es/bridge/prepareTransaction.d.ts +4 -0
- package/lib-es/bridge/prepareTransaction.d.ts.map +1 -0
- package/lib-es/bridge/prepareTransaction.js +10 -0
- package/lib-es/bridge/prepareTransaction.js.map +1 -0
- package/lib-es/bridge/signOperation.d.ts +5 -0
- package/lib-es/bridge/signOperation.d.ts.map +1 -0
- package/lib-es/bridge/signOperation.js +72 -0
- package/lib-es/bridge/signOperation.js.map +1 -0
- package/lib-es/bridge/synchronization.d.ts +3 -0
- package/lib-es/bridge/synchronization.d.ts.map +1 -0
- package/lib-es/bridge/synchronization.js +78 -0
- package/lib-es/bridge/synchronization.js.map +1 -0
- package/lib-es/bridge/synchronization.test.d.ts +2 -0
- package/lib-es/bridge/synchronization.test.d.ts.map +1 -0
- package/lib-es/bridge/synchronization.test.js +135 -0
- package/lib-es/bridge/synchronization.test.js.map +1 -0
- package/lib-es/{transaction.d.ts → bridge/transaction.d.ts} +1 -1
- package/lib-es/bridge/transaction.d.ts.map +1 -0
- package/lib-es/bridge/transaction.js.map +1 -0
- package/lib-es/index.d.ts +1 -0
- package/lib-es/index.d.ts.map +1 -1
- package/lib-es/index.js +1 -0
- package/lib-es/index.js.map +1 -1
- package/lib-es/logic/combine.d.ts.map +1 -1
- package/lib-es/logic/combine.js +3 -8
- package/lib-es/logic/combine.js.map +1 -1
- package/lib-es/logic/getBalance.d.ts.map +1 -1
- package/lib-es/logic/getBalance.js +2 -14
- package/lib-es/logic/getBalance.js.map +1 -1
- package/lib-es/logic/getBalance.test.js +1 -14
- package/lib-es/logic/getBalance.test.js.map +1 -1
- package/lib-es/logic/index.d.ts +1 -2
- package/lib-es/logic/index.d.ts.map +1 -1
- package/lib-es/logic/index.js +1 -2
- package/lib-es/logic/index.js.map +1 -1
- package/lib-es/logic/utils.d.ts +1 -0
- package/lib-es/logic/utils.d.ts.map +1 -1
- package/lib-es/logic/utils.js +8 -13
- package/lib-es/logic/utils.js.map +1 -1
- package/lib-es/test/bridgeDatasetTest.d.ts.map +1 -1
- package/lib-es/test/bridgeDatasetTest.js +7 -7
- package/lib-es/test/bridgeDatasetTest.js.map +1 -1
- package/lib-es/types/model.d.ts +0 -7
- package/lib-es/types/model.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/api/index.integ.test.ts +8 -24
- package/src/api/index.test.ts +22 -23
- package/src/api/index.ts +19 -28
- package/src/bridge/broadcast.ts +11 -0
- package/src/bridge/createTransaction.ts +13 -0
- package/src/bridge/estimateMaxSpendable.ts +25 -0
- package/src/{logic → bridge}/getTransactionStatus.ts +21 -18
- package/src/bridge/index.ts +59 -0
- package/src/bridge/prepareTransaction.ts +18 -0
- package/src/bridge/signOperation.ts +100 -0
- package/src/bridge/synchronization.test.ts +153 -0
- package/src/bridge/synchronization.ts +108 -0
- package/src/{transaction.ts → bridge/transaction.ts} +1 -1
- package/src/index.ts +1 -0
- package/src/logic/combine.ts +3 -10
- package/src/logic/getBalance.test.ts +1 -14
- package/src/logic/getBalance.ts +2 -18
- package/src/logic/index.ts +6 -2
- package/src/logic/utils.ts +8 -24
- package/src/test/bridgeDatasetTest.ts +7 -8
- package/src/types/model.ts +0 -11
- package/lib/logic/getTransactionStatus.d.ts +0 -3
- package/lib/logic/getTransactionStatus.d.ts.map +0 -1
- package/lib/logic/getTransactionStatus.js.map +0 -1
- package/lib/logic/getTransactionStatus.test.d.ts +0 -2
- package/lib/logic/getTransactionStatus.test.d.ts.map +0 -1
- package/lib/logic/getTransactionStatus.test.js +0 -184
- package/lib/logic/getTransactionStatus.test.js.map +0 -1
- package/lib/transaction.d.ts.map +0 -1
- package/lib/transaction.js.map +0 -1
- package/lib-es/logic/getTransactionStatus.d.ts +0 -3
- package/lib-es/logic/getTransactionStatus.d.ts.map +0 -1
- package/lib-es/logic/getTransactionStatus.js.map +0 -1
- package/lib-es/logic/getTransactionStatus.test.d.ts +0 -2
- package/lib-es/logic/getTransactionStatus.test.d.ts.map +0 -1
- package/lib-es/logic/getTransactionStatus.test.js +0 -159
- package/lib-es/logic/getTransactionStatus.test.js.map +0 -1
- package/lib-es/transaction.d.ts.map +0 -1
- package/lib-es/transaction.js.map +0 -1
- package/src/logic/getTransactionStatus.test.ts +0 -215
- /package/lib/{transaction.js → bridge/transaction.js} +0 -0
- /package/lib-es/{transaction.js → bridge/transaction.js} +0 -0
|
@@ -1,39 +1,26 @@
|
|
|
1
1
|
import { faker } from "@faker-js/faker";
|
|
2
2
|
import { getBalance } from "./getBalance";
|
|
3
3
|
const mockGetAccountInfo = jest.fn();
|
|
4
|
-
const mockGetServerInfos = jest.fn();
|
|
5
4
|
jest.mock("../network", () => ({
|
|
6
5
|
getAccountInfo: (address) => mockGetAccountInfo(address),
|
|
7
|
-
getServerInfos: () => mockGetServerInfos(),
|
|
8
6
|
}));
|
|
9
7
|
describe("getBalance", () => {
|
|
10
8
|
afterEach(() => {
|
|
11
9
|
mockGetAccountInfo.mockClear();
|
|
12
|
-
mockGetServerInfos.mockClear();
|
|
13
10
|
});
|
|
14
11
|
it("returns the balance from Explorer", async () => {
|
|
15
|
-
mockGetServerInfos.mockResolvedValue({
|
|
16
|
-
info: {
|
|
17
|
-
validated_ledger: {
|
|
18
|
-
reserve_base_xrp: 23,
|
|
19
|
-
reserve_inc_xrp: 5,
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
12
|
// Given
|
|
24
13
|
const balance = faker.number.bigInt(100_000_000);
|
|
25
14
|
const address = "ACCOUNT_ADDRESS";
|
|
26
15
|
mockGetAccountInfo.mockResolvedValue({
|
|
27
16
|
balance,
|
|
28
|
-
ownerCount: 0,
|
|
29
17
|
});
|
|
30
18
|
// When
|
|
31
19
|
const result = await getBalance(address);
|
|
32
20
|
// Then
|
|
33
21
|
expect(mockGetAccountInfo).toHaveBeenCalledTimes(1);
|
|
34
|
-
expect(mockGetServerInfos).toHaveBeenCalledTimes(1);
|
|
35
22
|
expect(mockGetAccountInfo.mock.lastCall[0]).toEqual(address);
|
|
36
|
-
expect(result).toEqual([{ value: balance, asset: { type: "native" }
|
|
23
|
+
expect(result).toEqual([{ value: balance, asset: { type: "native" } }]);
|
|
37
24
|
});
|
|
38
25
|
});
|
|
39
26
|
//# 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,kBAAkB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AACrC,
|
|
1
|
+
{"version":3,"file":"getBalance.test.js","sourceRoot":"","sources":["../../src/logic/getBalance.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAA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ance } from "./getBalance";
|
|
7
7
|
export { lastBlock } from "./lastBlock";
|
|
8
8
|
export { listOperations } from "./listOperations";
|
|
9
|
-
export {
|
|
10
|
-
export { RIPPLE_EPOCH, cachedRecipientIsNew, getNextValidSequence } from "./utils";
|
|
9
|
+
export { RIPPLE_EPOCH, cachedRecipientIsNew, getNextValidSequence, removeCachedRecipientIsNew, } from "./utils";
|
|
11
10
|
export { parseAPIValue } from "./common";
|
|
12
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/logic/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/logic/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,oBAAoB,EACpB,0BAA0B,GAC3B,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC"}
|
package/lib-es/logic/index.js
CHANGED
|
@@ -5,7 +5,6 @@ export { estimateFees } from "./estimateFees";
|
|
|
5
5
|
export { getBalance } from "./getBalance";
|
|
6
6
|
export { lastBlock } from "./lastBlock";
|
|
7
7
|
export { listOperations } from "./listOperations";
|
|
8
|
-
export {
|
|
9
|
-
export { RIPPLE_EPOCH, cachedRecipientIsNew, getNextValidSequence } from "./utils";
|
|
8
|
+
export { RIPPLE_EPOCH, cachedRecipientIsNew, getNextValidSequence, removeCachedRecipientIsNew, } from "./utils";
|
|
10
9
|
export { parseAPIValue } from "./common";
|
|
11
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/logic/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/logic/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,oBAAoB,EACpB,0BAA0B,GAC3B,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC"}
|
package/lib-es/logic/utils.d.ts
CHANGED
|
@@ -5,4 +5,5 @@ export declare const RIPPLE_EPOCH = 946684800;
|
|
|
5
5
|
export declare const validateTag: (tag: BigNumber) => boolean;
|
|
6
6
|
export declare const getNextValidSequence: (address: string) => Promise<number>;
|
|
7
7
|
export declare const cachedRecipientIsNew: (recipient: string) => Promise<boolean>;
|
|
8
|
+
export declare const removeCachedRecipientIsNew: (recipient: string) => void;
|
|
8
9
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/logic/utils.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AAIrC,eAAO,MAAM,UAAU,WAAoC,CAAC;AAE5D,kEAAkE;AAClE,eAAO,MAAM,YAAY,YAAY,CAAC;AAEtC,eAAO,MAAM,WAAW,QAAS,SAAS,YAIzC,CAAC;AAEF,eAAO,MAAM,oBAAoB,YAAmB,MAAM,oBAGzD,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/logic/utils.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AAIrC,eAAO,MAAM,UAAU,WAAoC,CAAC;AAE5D,kEAAkE;AAClE,eAAO,MAAM,YAAY,YAAY,CAAC;AAEtC,eAAO,MAAM,WAAW,QAAS,SAAS,YAIzC,CAAC;AAEF,eAAO,MAAM,oBAAoB,YAAmB,MAAM,oBAGzD,CAAC;AAcF,eAAO,MAAM,oBAAoB,cAAqB,MAAM,qBAI3D,CAAC;AACF,eAAO,MAAM,0BAA0B,cAAe,MAAM,SAE3D,CAAC"}
|
package/lib-es/logic/utils.js
CHANGED
|
@@ -14,25 +14,20 @@ export const getNextValidSequence = async (address) => {
|
|
|
14
14
|
function isRecipientValid(recipient) {
|
|
15
15
|
return isValidClassicAddress(recipient);
|
|
16
16
|
}
|
|
17
|
-
const recipientCache = new Map();
|
|
18
|
-
const TTL = 10 * 1000; // 10 seconds
|
|
19
17
|
const recipientIsNew = async (recipient) => {
|
|
20
18
|
if (!isRecipientValid(recipient))
|
|
21
19
|
return false;
|
|
22
20
|
const info = await getAccountInfo(recipient);
|
|
23
21
|
return info.isNewAccount;
|
|
24
22
|
};
|
|
23
|
+
const cacheRecipientsNew = {};
|
|
25
24
|
export const cachedRecipientIsNew = async (recipient) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
value: isNew,
|
|
34
|
-
expiresAt: now + TTL,
|
|
35
|
-
});
|
|
36
|
-
return isNew;
|
|
25
|
+
if (recipient in cacheRecipientsNew)
|
|
26
|
+
return cacheRecipientsNew[recipient];
|
|
27
|
+
cacheRecipientsNew[recipient] = await recipientIsNew(recipient);
|
|
28
|
+
return cacheRecipientsNew[recipient];
|
|
29
|
+
};
|
|
30
|
+
export const removeCachedRecipientIsNew = (recipient) => {
|
|
31
|
+
delete cacheRecipientsNew[recipient];
|
|
37
32
|
};
|
|
38
33
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/logic/utils.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,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,EAAE,EAAE;IAC9D,OAAO,kBAAkB,CAAC,SAAS,CAAC,CAAC;AACvC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridgeDatasetTest.d.ts","sourceRoot":"","sources":["../../src/test/bridgeDatasetTest.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGnD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,eAAO,MAAM,WAAW,sCAAsC,CAAC;AAE/D,eAAO,MAAM,OAAO,EAAE,WAAW,CAAC,WAAW,
|
|
1
|
+
{"version":3,"file":"bridgeDatasetTest.d.ts","sourceRoot":"","sources":["../../src/test/bridgeDatasetTest.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGnD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,eAAO,MAAM,WAAW,sCAAsC,CAAC;AAE/D,eAAO,MAAM,OAAO,EAAE,WAAW,CAAC,WAAW,CAgJ5C,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import BigNumber from "bignumber.js";
|
|
2
2
|
import { InvalidAddressBecauseDestinationIsAlsoSource } from "@ledgerhq/errors";
|
|
3
|
-
import { fromTransactionRaw } from "../transaction";
|
|
3
|
+
import { fromTransactionRaw } from "../bridge/transaction";
|
|
4
4
|
export const newAddress1 = "rZvBc5e2YR1A9otS3r9DyGh3NDP8XLLp4";
|
|
5
5
|
export const dataset = {
|
|
6
6
|
implementations: ["mock", "ripplejs"],
|
|
@@ -91,18 +91,18 @@ export const dataset = {
|
|
|
91
91
|
recipient: "rageXHB6Q4VbvvWdTzKANwjeCT4HXFCKX7",
|
|
92
92
|
amount: "10000000",
|
|
93
93
|
tag: null,
|
|
94
|
-
fee: "
|
|
94
|
+
fee: "1",
|
|
95
95
|
feeCustomUnit: null,
|
|
96
96
|
networkInfo: null,
|
|
97
97
|
}),
|
|
98
98
|
expectedStatus: {
|
|
99
99
|
amount: new BigNumber("10000000"),
|
|
100
|
-
estimatedFees: new BigNumber("
|
|
100
|
+
estimatedFees: new BigNumber("1"),
|
|
101
101
|
errors: {
|
|
102
102
|
recipient: new InvalidAddressBecauseDestinationIsAlsoSource(),
|
|
103
103
|
},
|
|
104
104
|
warnings: {},
|
|
105
|
-
totalSpent: new BigNumber("
|
|
105
|
+
totalSpent: new BigNumber("10000001"),
|
|
106
106
|
},
|
|
107
107
|
},
|
|
108
108
|
{
|
|
@@ -112,16 +112,16 @@ export const dataset = {
|
|
|
112
112
|
recipient: "rB6pwovsyrFWhPYUsjj9V3CHck985QjiXi",
|
|
113
113
|
amount: "10000000",
|
|
114
114
|
tag: 12345,
|
|
115
|
-
fee: "
|
|
115
|
+
fee: "1",
|
|
116
116
|
feeCustomUnit: null,
|
|
117
117
|
networkInfo: null,
|
|
118
118
|
}),
|
|
119
119
|
expectedStatus: {
|
|
120
120
|
amount: new BigNumber("10000000"),
|
|
121
|
-
estimatedFees: new BigNumber("
|
|
121
|
+
estimatedFees: new BigNumber("1"),
|
|
122
122
|
errors: {},
|
|
123
123
|
warnings: {},
|
|
124
|
-
totalSpent: new BigNumber("
|
|
124
|
+
totalSpent: new BigNumber("10000001"),
|
|
125
125
|
},
|
|
126
126
|
},
|
|
127
127
|
],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridgeDatasetTest.js","sourceRoot":"","sources":["../../src/test/bridgeDatasetTest.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,OAAO,EAAE,4CAA4C,EAAE,MAAM,kBAAkB,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"bridgeDatasetTest.js","sourceRoot":"","sources":["../../src/test/bridgeDatasetTest.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,OAAO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,UAAU;gCAClB,GAAG,EAAE,KAAK;gCACV,GAAG,EAAE,GAAG;gCACR,aAAa,EAAE,IAAI;gCACnB,WAAW,EAAE,IAAI;6BAClB,CAAC;4BACF,cAAc,EAAE;gCACd,MAAM,EAAE,IAAI,SAAS,CAAC,UAAU,CAAC;gCACjC,aAAa,EAAE,IAAI,SAAS,CAAC,GAAG,CAAC;gCACjC,MAAM,EAAE,EAAE;gCACV,QAAQ,EAAE,EAAE;gCACZ,UAAU,EAAE,IAAI,SAAS,CAAC,UAAU,CAAC;6BACtC;yBACF;qBACF;oBACD,GAAG,EAAE;wBACH,EAAE,EAAE,uDAAuD;wBAC3D,cAAc,EAAE,oCAAoC;wBACpD,IAAI,EAAE,OAAO;wBACb,cAAc,EAAE,EAAE;wBAClB,KAAK,EAAE,CAAC;wBACR,YAAY,EAAE,oCAAoC;wBAClD,gBAAgB,EAAE,iBAAiB;wBACnC,WAAW,EAAE,CAAC;wBACd,UAAU,EAAE,EAAE;wBACd,iBAAiB,EAAE,EAAE;wBACrB,UAAU,EAAE,QAAQ;wBACpB,YAAY,EAAE,EAAE;wBAChB,OAAO,EAAE,UAAU;qBACpB;iBACF;aACF;SACF;KACF;CACF,CAAC"}
|
package/lib-es/types/model.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { TypedMapMemo } from "@ledgerhq/coin-framework/api/types";
|
|
2
1
|
export type AccountInfo = {
|
|
3
2
|
isNewAccount: boolean;
|
|
4
3
|
balance: string;
|
|
@@ -10,12 +9,6 @@ export type XrpMemo = {
|
|
|
10
9
|
format?: string;
|
|
11
10
|
type?: string;
|
|
12
11
|
};
|
|
13
|
-
export type XrpMemoKind = "destinationTag" | "memo";
|
|
14
|
-
export type XrpMemoValueMap = {
|
|
15
|
-
destinationTag: string;
|
|
16
|
-
memos: string[];
|
|
17
|
-
};
|
|
18
|
-
export type XrpMapMemo = TypedMapMemo<XrpMemoValueMap>;
|
|
19
12
|
type Order = "asc" | "desc";
|
|
20
13
|
export type ListOperationsOptions = {
|
|
21
14
|
limit?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/types/model.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/types/model.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG;IACxB,YAAY,EAAE,OAAO,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,KAAK,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC;AAC5B,MAAM,MAAM,qBAAqB,GAAG;IAElC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,KAAK,CAAC;IAEd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/coin-xrp",
|
|
3
|
-
"version": "6.2.0-next.
|
|
3
|
+
"version": "6.2.0-next.1",
|
|
4
4
|
"description": "Ledger XRP Coin integration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ledger",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"lib/test/bot-specs"
|
|
42
42
|
],
|
|
43
43
|
"transaction": [
|
|
44
|
-
"lib/transaction"
|
|
44
|
+
"lib/bridge/transaction"
|
|
45
45
|
],
|
|
46
46
|
"types": [
|
|
47
47
|
"lib/types/index"
|
|
@@ -80,8 +80,8 @@
|
|
|
80
80
|
"default": "./lib-es/test/bot-specs.js"
|
|
81
81
|
},
|
|
82
82
|
"./transaction": {
|
|
83
|
-
"require": "./lib/transaction.js",
|
|
84
|
-
"default": "./lib-es/transaction.js"
|
|
83
|
+
"require": "./lib/bridge/transaction.js",
|
|
84
|
+
"default": "./lib-es/bridge/transaction.js"
|
|
85
85
|
},
|
|
86
86
|
"./types": {
|
|
87
87
|
"require": "./lib/types/index.js",
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"ripple-address-codec": "^5.0.0",
|
|
105
105
|
"ripple-binary-codec": "^1.3.0",
|
|
106
106
|
"rxjs": "^7.8.1",
|
|
107
|
-
"@ledgerhq/coin-framework": "^5.3.0-next.
|
|
107
|
+
"@ledgerhq/coin-framework": "^5.3.0-next.1",
|
|
108
108
|
"@ledgerhq/cryptoassets": "^13.18.1-next.0",
|
|
109
109
|
"@ledgerhq/devices": "8.4.6",
|
|
110
110
|
"@ledgerhq/errors": "^6.21.0",
|
|
@@ -4,7 +4,7 @@ import { createApi } from ".";
|
|
|
4
4
|
//import { sign } from "ripple-keypairs";
|
|
5
5
|
|
|
6
6
|
describe("Xrp Api", () => {
|
|
7
|
-
const SENDER = "rh1HPuRVsYYvThxG2Bs1MfjmrVC73S16Fb";
|
|
7
|
+
const SENDER = { address: "rh1HPuRVsYYvThxG2Bs1MfjmrVC73S16Fb" };
|
|
8
8
|
const api = createApi({ node: "https://s.altnet.rippletest.net:51234" });
|
|
9
9
|
|
|
10
10
|
describe("estimateFees", () => {
|
|
@@ -19,10 +19,6 @@ describe("Xrp Api", () => {
|
|
|
19
19
|
sender: SENDER,
|
|
20
20
|
amount,
|
|
21
21
|
recipient: "rKtXXTVno77jhu6tto1MAXjepyuaKaLcqB",
|
|
22
|
-
memo: {
|
|
23
|
-
type: "map",
|
|
24
|
-
memos: new Map(),
|
|
25
|
-
},
|
|
26
22
|
});
|
|
27
23
|
|
|
28
24
|
// Then
|
|
@@ -33,14 +29,15 @@ describe("Xrp Api", () => {
|
|
|
33
29
|
describe("listOperations", () => {
|
|
34
30
|
it.skip("returns a list regarding address parameter", async () => {
|
|
35
31
|
// When
|
|
36
|
-
const [tx, _] = await api.listOperations(SENDER, { minHeight: 200 });
|
|
32
|
+
const [tx, _] = await api.listOperations(SENDER.address, { minHeight: 200 });
|
|
37
33
|
|
|
38
34
|
// https://blockexplorer.one/xrp/testnet/address/rh1HPuRVsYYvThxG2Bs1MfjmrVC73S16Fb
|
|
39
35
|
// as of 2025-03-18, the address has 287 transactions
|
|
40
36
|
expect(tx.length).toBeGreaterThanOrEqual(287);
|
|
41
37
|
tx.forEach(operation => {
|
|
42
38
|
const isSenderOrReceipt =
|
|
43
|
-
operation.senders.includes(SENDER) ||
|
|
39
|
+
operation.senders.includes(SENDER.address) ||
|
|
40
|
+
operation.recipients.includes(SENDER.address);
|
|
44
41
|
expect(isSenderOrReceipt).toBeTruthy();
|
|
45
42
|
});
|
|
46
43
|
});
|
|
@@ -84,7 +81,7 @@ describe("Xrp Api", () => {
|
|
|
84
81
|
|
|
85
82
|
it("returns an amount above 0 when address has transactions", async () => {
|
|
86
83
|
// When
|
|
87
|
-
const result = await api.getBalance(SENDER);
|
|
84
|
+
const result = await api.getBalance(SENDER.address);
|
|
88
85
|
|
|
89
86
|
// Then
|
|
90
87
|
expect(result[0].asset).toEqual({ type: "native" });
|
|
@@ -96,9 +93,7 @@ describe("Xrp Api", () => {
|
|
|
96
93
|
const result = await api.getBalance(SENDER_WITH_NO_TRANSACTION);
|
|
97
94
|
|
|
98
95
|
// Then
|
|
99
|
-
expect(result).toEqual([
|
|
100
|
-
{ locked: BigInt(1000000n), value: BigInt(0), asset: { type: "native" } },
|
|
101
|
-
]);
|
|
96
|
+
expect(result).toEqual([{ value: BigInt(0), asset: { type: "native" } }]);
|
|
102
97
|
});
|
|
103
98
|
});
|
|
104
99
|
|
|
@@ -113,13 +108,10 @@ describe("Xrp Api", () => {
|
|
|
113
108
|
sender: SENDER,
|
|
114
109
|
recipient: RECIPIENT,
|
|
115
110
|
amount: BigInt(10),
|
|
116
|
-
memo: {
|
|
117
|
-
type: "map",
|
|
118
|
-
memos: new Map([["memos", ["testdata"]]]),
|
|
119
|
-
},
|
|
120
111
|
});
|
|
112
|
+
|
|
121
113
|
// Then
|
|
122
|
-
expect(result.length).toEqual(
|
|
114
|
+
expect(result.length).toEqual(162);
|
|
123
115
|
});
|
|
124
116
|
|
|
125
117
|
it("should use default fees when user does not provide them for crafting a transaction", async () => {
|
|
@@ -129,10 +121,6 @@ describe("Xrp Api", () => {
|
|
|
129
121
|
sender: SENDER,
|
|
130
122
|
recipient: RECIPIENT,
|
|
131
123
|
amount: BigInt(10),
|
|
132
|
-
memo: {
|
|
133
|
-
type: "map",
|
|
134
|
-
memos: new Map(),
|
|
135
|
-
},
|
|
136
124
|
});
|
|
137
125
|
|
|
138
126
|
const decodedTransaction = decode(result) as { Fee: string };
|
|
@@ -148,10 +136,6 @@ describe("Xrp Api", () => {
|
|
|
148
136
|
sender: SENDER,
|
|
149
137
|
recipient: RECIPIENT,
|
|
150
138
|
amount: BigInt(10),
|
|
151
|
-
memo: {
|
|
152
|
-
type: "map",
|
|
153
|
-
memos: new Map(),
|
|
154
|
-
},
|
|
155
139
|
},
|
|
156
140
|
customFees,
|
|
157
141
|
);
|
package/src/api/index.test.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Operation, TransactionIntent } from "@ledgerhq/coin-framework/api/types";
|
|
2
2
|
import * as LogicFunctions from "../logic";
|
|
3
3
|
import { GetTransactionsOptions } from "../network";
|
|
4
|
-
import { NetworkInfo, XrpAsset
|
|
5
|
-
import { createApi } from "./index";
|
|
4
|
+
import { NetworkInfo, XrpAsset } from "../types";
|
|
5
|
+
import { createApi, TransactionIntentExtra, XrpSender } from "./index";
|
|
6
6
|
|
|
7
7
|
const mockGetServerInfos = jest.fn().mockResolvedValue({
|
|
8
8
|
info: {
|
|
@@ -285,7 +285,11 @@ describe("Testing craftTransaction function", () => {
|
|
|
285
285
|
it("should use custom user fees when user provides it for crafting a transaction", async () => {
|
|
286
286
|
const customFees = 99n;
|
|
287
287
|
await api.craftTransaction(
|
|
288
|
-
{ sender: "foo" } as TransactionIntent<
|
|
288
|
+
{ sender: { address: "foo" } } as TransactionIntent<
|
|
289
|
+
XrpAsset,
|
|
290
|
+
TransactionIntentExtra,
|
|
291
|
+
XrpSender
|
|
292
|
+
>,
|
|
289
293
|
customFees,
|
|
290
294
|
);
|
|
291
295
|
|
|
@@ -299,7 +303,11 @@ describe("Testing craftTransaction function", () => {
|
|
|
299
303
|
});
|
|
300
304
|
|
|
301
305
|
it("should use default fees when user does not provide them for crafting a transaction", async () => {
|
|
302
|
-
await api.craftTransaction({ sender: "foo" } as TransactionIntent<
|
|
306
|
+
await api.craftTransaction({ sender: { address: "foo" } } as TransactionIntent<
|
|
307
|
+
XrpAsset,
|
|
308
|
+
TransactionIntentExtra,
|
|
309
|
+
XrpSender
|
|
310
|
+
>);
|
|
303
311
|
|
|
304
312
|
expect(logicCraftTransactionSpy).toHaveBeenCalledWith(
|
|
305
313
|
expect.any(Object),
|
|
@@ -312,9 +320,8 @@ describe("Testing craftTransaction function", () => {
|
|
|
312
320
|
|
|
313
321
|
it("should pass signing pub key when user provides it for crafting a transaction", async () => {
|
|
314
322
|
await api.craftTransaction({
|
|
315
|
-
sender: "foo",
|
|
316
|
-
|
|
317
|
-
} as TransactionIntent<XrpAsset, XrpMapMemo>);
|
|
323
|
+
sender: { address: "foo", publicKey: "bar" },
|
|
324
|
+
} as TransactionIntent<XrpAsset, TransactionIntentExtra, XrpSender>);
|
|
318
325
|
|
|
319
326
|
expect(logicCraftTransactionSpy).toHaveBeenCalledWith(
|
|
320
327
|
expect.any(Object),
|
|
@@ -325,19 +332,14 @@ describe("Testing craftTransaction function", () => {
|
|
|
325
332
|
|
|
326
333
|
it("should pass memos when user provides it for crafting a transaction", async () => {
|
|
327
334
|
await api.craftTransaction({
|
|
328
|
-
sender: "foo",
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
memos: new Map([["memos", ["testdata"]]]),
|
|
332
|
-
},
|
|
333
|
-
} as TransactionIntent<XrpAsset, XrpMapMemo>);
|
|
335
|
+
sender: { address: "foo" },
|
|
336
|
+
memos: [{ data: "testdata", format: "testformat", type: "testtype" }],
|
|
337
|
+
} as TransactionIntent<XrpAsset, TransactionIntentExtra, XrpSender>);
|
|
334
338
|
|
|
335
339
|
expect(logicCraftTransactionSpy).toHaveBeenCalledWith(
|
|
336
340
|
expect.any(Object),
|
|
337
341
|
expect.objectContaining({
|
|
338
|
-
|
|
339
|
-
// memos: [{ data: "testdata", format: "testformat", type: "testtype" }],
|
|
340
|
-
memos: [{ data: "testdata", type: "memo" }],
|
|
342
|
+
memos: [{ data: "testdata", format: "testformat", type: "testtype" }],
|
|
341
343
|
}),
|
|
342
344
|
undefined,
|
|
343
345
|
);
|
|
@@ -345,17 +347,14 @@ describe("Testing craftTransaction function", () => {
|
|
|
345
347
|
|
|
346
348
|
it("should pass destination tag when user provides it for crafting a transaction", async () => {
|
|
347
349
|
await api.craftTransaction({
|
|
348
|
-
sender: "foo",
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
memos: new Map([["destinationTag", "1337"]]),
|
|
352
|
-
},
|
|
353
|
-
} as TransactionIntent<XrpAsset, XrpMapMemo>);
|
|
350
|
+
sender: { address: "foo" },
|
|
351
|
+
destinationTag: 1337,
|
|
352
|
+
} as TransactionIntent<XrpAsset, TransactionIntentExtra, XrpSender>);
|
|
354
353
|
|
|
355
354
|
expect(logicCraftTransactionSpy).toHaveBeenCalledWith(
|
|
356
355
|
expect.any(Object),
|
|
357
356
|
expect.objectContaining({
|
|
358
|
-
destinationTag: 1337,
|
|
357
|
+
destinationTag: 1337,
|
|
359
358
|
}),
|
|
360
359
|
undefined,
|
|
361
360
|
);
|
package/src/api/index.ts
CHANGED
|
@@ -16,11 +16,11 @@ import {
|
|
|
16
16
|
getNextValidSequence,
|
|
17
17
|
lastBlock,
|
|
18
18
|
listOperations,
|
|
19
|
-
|
|
19
|
+
MemoInput,
|
|
20
20
|
} from "../logic";
|
|
21
|
-
import { ListOperationsOptions, XrpAsset
|
|
21
|
+
import { ListOperationsOptions, XrpAsset } from "../types";
|
|
22
22
|
|
|
23
|
-
export function createApi(config: XrpConfig): Api<XrpAsset,
|
|
23
|
+
export function createApi(config: XrpConfig): Api<XrpAsset, TransactionIntentExtra, XrpSender> {
|
|
24
24
|
coinConfig.setCoinConfig(() => ({ ...config, status: { type: "active" } }));
|
|
25
25
|
|
|
26
26
|
return {
|
|
@@ -31,45 +31,36 @@ export function createApi(config: XrpConfig): Api<XrpAsset, XrpMapMemo> {
|
|
|
31
31
|
getBalance,
|
|
32
32
|
lastBlock,
|
|
33
33
|
listOperations: operations,
|
|
34
|
-
validateIntent: getTransactionStatus,
|
|
35
34
|
};
|
|
36
35
|
}
|
|
37
36
|
|
|
37
|
+
export type TransactionIntentExtra = {
|
|
38
|
+
destinationTag?: number | null | undefined;
|
|
39
|
+
memos?: MemoInput[];
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export type XrpSender = {
|
|
43
|
+
address: string;
|
|
44
|
+
publicKey?: string;
|
|
45
|
+
};
|
|
46
|
+
|
|
38
47
|
async function craft(
|
|
39
|
-
transactionIntent: TransactionIntent<XrpAsset,
|
|
48
|
+
transactionIntent: TransactionIntent<XrpAsset, TransactionIntentExtra, XrpSender>,
|
|
40
49
|
customFees?: bigint,
|
|
41
50
|
): Promise<string> {
|
|
42
|
-
const nextSequenceNumber = await getNextValidSequence(transactionIntent.sender);
|
|
51
|
+
const nextSequenceNumber = await getNextValidSequence(transactionIntent.sender.address);
|
|
43
52
|
const estimatedFees = customFees !== undefined ? customFees : (await estimateFees()).fee;
|
|
44
|
-
|
|
45
|
-
const memosMap =
|
|
46
|
-
transactionIntent.memo?.type === "map" ? transactionIntent.memo.memos : new Map();
|
|
47
|
-
|
|
48
|
-
const destinationTagValue = memosMap.get("destinationTag");
|
|
49
|
-
const destinationTag =
|
|
50
|
-
typeof destinationTagValue === "string" ? Number(destinationTagValue) : undefined;
|
|
51
|
-
|
|
52
|
-
const memoStrings = memosMap.get("memos") as string[] | undefined;
|
|
53
|
-
|
|
54
|
-
let memoEntries: { type: string; data: string }[] = [];
|
|
55
|
-
|
|
56
|
-
if (Array.isArray(memoStrings) && memoStrings.length > 0) {
|
|
57
|
-
memoEntries = memoStrings.map(value => ({ type: "memo", data: value }));
|
|
58
|
-
}
|
|
59
|
-
|
|
60
53
|
const tx = await craftTransaction(
|
|
61
|
-
{ address: transactionIntent.sender, nextSequenceNumber },
|
|
54
|
+
{ address: transactionIntent.sender.address, nextSequenceNumber },
|
|
62
55
|
{
|
|
63
56
|
recipient: transactionIntent.recipient,
|
|
64
57
|
amount: transactionIntent.amount,
|
|
65
58
|
fee: estimatedFees,
|
|
66
|
-
destinationTag,
|
|
67
|
-
|
|
68
|
-
memos: memoEntries,
|
|
59
|
+
destinationTag: transactionIntent.destinationTag,
|
|
60
|
+
memos: transactionIntent.memos,
|
|
69
61
|
},
|
|
70
|
-
transactionIntent.
|
|
62
|
+
transactionIntent.sender.publicKey,
|
|
71
63
|
);
|
|
72
|
-
|
|
73
64
|
return tx.serializedTransaction;
|
|
74
65
|
}
|
|
75
66
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AccountBridge } from "@ledgerhq/types-live";
|
|
2
|
+
import { patchOperationWithHash } from "@ledgerhq/coin-framework/operation";
|
|
3
|
+
import { broadcast as broadcastLogic } from "../logic";
|
|
4
|
+
import { Transaction } from "../types";
|
|
5
|
+
|
|
6
|
+
export const broadcast: AccountBridge<Transaction>["broadcast"] = async ({
|
|
7
|
+
signedOperation: { signature, operation },
|
|
8
|
+
}) => {
|
|
9
|
+
const hash = await broadcastLogic(signature);
|
|
10
|
+
return patchOperationWithHash(operation, hash);
|
|
11
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
|
+
import { Transaction } from "../types";
|
|
3
|
+
import { AccountBridge } from "@ledgerhq/types-live";
|
|
4
|
+
|
|
5
|
+
export const createTransaction: AccountBridge<Transaction>["createTransaction"] = () => ({
|
|
6
|
+
family: "xrp",
|
|
7
|
+
amount: new BigNumber(0),
|
|
8
|
+
recipient: "",
|
|
9
|
+
fee: null,
|
|
10
|
+
tag: undefined,
|
|
11
|
+
networkInfo: null,
|
|
12
|
+
feeCustomUnit: null,
|
|
13
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
|
+
import { AccountBridge } from "@ledgerhq/types-live";
|
|
3
|
+
import { getMainAccount } from "@ledgerhq/coin-framework/account/index";
|
|
4
|
+
import { getAbandonSeedAddress } from "@ledgerhq/cryptoassets/abandonseed";
|
|
5
|
+
import { getTransactionStatus } from "./getTransactionStatus";
|
|
6
|
+
import { prepareTransaction } from "./prepareTransaction";
|
|
7
|
+
import { createTransaction } from "./createTransaction";
|
|
8
|
+
import { Transaction } from "../types";
|
|
9
|
+
|
|
10
|
+
export const estimateMaxSpendable: AccountBridge<Transaction>["estimateMaxSpendable"] = async ({
|
|
11
|
+
account,
|
|
12
|
+
parentAccount,
|
|
13
|
+
transaction,
|
|
14
|
+
}) => {
|
|
15
|
+
const mainAccount = getMainAccount(account, parentAccount);
|
|
16
|
+
const newTransaction = await prepareTransaction(mainAccount, {
|
|
17
|
+
...createTransaction(account),
|
|
18
|
+
...transaction,
|
|
19
|
+
recipient: transaction?.recipient || getAbandonSeedAddress("ripple"),
|
|
20
|
+
// public testing seed abandonx11,about
|
|
21
|
+
amount: new BigNumber(0),
|
|
22
|
+
});
|
|
23
|
+
const status = await getTransactionStatus(mainAccount, newTransaction);
|
|
24
|
+
return BigNumber.max(0, account.spendableBalance.minus(status.estimatedFees));
|
|
25
|
+
};
|