@ledgerhq/coin-xrp 7.6.0-nightly.7 → 7.6.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 -61
- package/lib/api/index.integ.test.d.ts +2 -0
- package/lib/api/index.integ.test.d.ts.map +1 -0
- package/lib/api/index.integ.test.js +332 -0
- package/lib/api/index.integ.test.js.map +1 -0
- package/lib/api/index.test.d.ts +2 -0
- package/lib/api/index.test.d.ts.map +1 -0
- package/lib/api/index.test.js +347 -0
- package/lib/api/index.test.js.map +1 -0
- package/lib/logic/broadcast.test.d.ts +2 -0
- package/lib/logic/broadcast.test.d.ts.map +1 -0
- package/lib/logic/broadcast.test.js +46 -0
- package/lib/logic/broadcast.test.js.map +1 -0
- package/lib/logic/craftRawTransaction.test.d.ts +2 -0
- package/lib/logic/craftRawTransaction.test.d.ts.map +1 -0
- package/lib/logic/craftRawTransaction.test.js +304 -0
- package/lib/logic/craftRawTransaction.test.js.map +1 -0
- package/lib/logic/craftTransaction.test.d.ts +2 -0
- package/lib/logic/craftTransaction.test.d.ts.map +1 -0
- package/lib/logic/craftTransaction.test.js +75 -0
- package/lib/logic/craftTransaction.test.js.map +1 -0
- package/lib/logic/estimateFees.test.d.ts +2 -0
- package/lib/logic/estimateFees.test.d.ts.map +1 -0
- package/lib/logic/estimateFees.test.js +51 -0
- package/lib/logic/estimateFees.test.js.map +1 -0
- package/lib/logic/getBalance.test.d.ts +2 -0
- package/lib/logic/getBalance.test.d.ts.map +1 -0
- package/lib/logic/getBalance.test.js +63 -0
- package/lib/logic/getBalance.test.js.map +1 -0
- package/lib/logic/listOperations.test.d.ts +2 -0
- package/lib/logic/listOperations.test.d.ts.map +1 -0
- package/lib/logic/listOperations.test.js +275 -0
- package/lib/logic/listOperations.test.js.map +1 -0
- package/lib/logic/utils.test.d.ts +2 -0
- package/lib/logic/utils.test.d.ts.map +1 -0
- package/lib/logic/utils.test.js +115 -0
- package/lib/logic/utils.test.js.map +1 -0
- package/lib/logic/validateIntent.test.d.ts +2 -0
- package/lib/logic/validateIntent.test.d.ts.map +1 -0
- package/lib/logic/validateIntent.test.js +266 -0
- package/lib/logic/validateIntent.test.js.map +1 -0
- package/lib/network/index.test.d.ts +2 -0
- package/lib/network/index.test.d.ts.map +1 -0
- package/lib/network/index.test.js +105 -0
- package/lib/network/index.test.js.map +1 -0
- package/lib-es/api/index.integ.test.d.ts +2 -0
- package/lib-es/api/index.integ.test.d.ts.map +1 -0
- package/lib-es/api/index.integ.test.js +330 -0
- package/lib-es/api/index.integ.test.js.map +1 -0
- package/lib-es/api/index.test.d.ts +2 -0
- package/lib-es/api/index.test.d.ts.map +1 -0
- package/lib-es/api/index.test.js +322 -0
- package/lib-es/api/index.test.js.map +1 -0
- package/lib-es/logic/broadcast.test.d.ts +2 -0
- package/lib-es/logic/broadcast.test.d.ts.map +1 -0
- package/lib-es/logic/broadcast.test.js +44 -0
- package/lib-es/logic/broadcast.test.js.map +1 -0
- package/lib-es/logic/craftRawTransaction.test.d.ts +2 -0
- package/lib-es/logic/craftRawTransaction.test.d.ts.map +1 -0
- package/lib-es/logic/craftRawTransaction.test.js +302 -0
- package/lib-es/logic/craftRawTransaction.test.js.map +1 -0
- package/lib-es/logic/craftTransaction.test.d.ts +2 -0
- package/lib-es/logic/craftTransaction.test.d.ts.map +1 -0
- package/lib-es/logic/craftTransaction.test.js +73 -0
- package/lib-es/logic/craftTransaction.test.js.map +1 -0
- package/lib-es/logic/estimateFees.test.d.ts +2 -0
- package/lib-es/logic/estimateFees.test.d.ts.map +1 -0
- package/lib-es/logic/estimateFees.test.js +46 -0
- package/lib-es/logic/estimateFees.test.js.map +1 -0
- package/lib-es/logic/getBalance.test.d.ts +2 -0
- package/lib-es/logic/getBalance.test.d.ts.map +1 -0
- package/lib-es/logic/getBalance.test.js +61 -0
- package/lib-es/logic/getBalance.test.js.map +1 -0
- package/lib-es/logic/listOperations.test.d.ts +2 -0
- package/lib-es/logic/listOperations.test.d.ts.map +1 -0
- package/lib-es/logic/listOperations.test.js +273 -0
- package/lib-es/logic/listOperations.test.js.map +1 -0
- package/lib-es/logic/utils.test.d.ts +2 -0
- package/lib-es/logic/utils.test.d.ts.map +1 -0
- package/lib-es/logic/utils.test.js +113 -0
- package/lib-es/logic/utils.test.js.map +1 -0
- package/lib-es/logic/validateIntent.test.d.ts +2 -0
- package/lib-es/logic/validateIntent.test.d.ts.map +1 -0
- package/lib-es/logic/validateIntent.test.js +241 -0
- package/lib-es/logic/validateIntent.test.js.map +1 -0
- package/lib-es/network/index.test.d.ts +2 -0
- package/lib-es/network/index.test.d.ts.map +1 -0
- package/lib-es/network/index.test.js +100 -0
- package/lib-es/network/index.test.js.map +1 -0
- package/package.json +8 -8
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import { decode } from "ripple-binary-codec";
|
|
2
|
+
import { createApi } from ".";
|
|
3
|
+
//import { decode, encodeForSigning } from "ripple-binary-codec";
|
|
4
|
+
//import { sign } from "ripple-keypairs";
|
|
5
|
+
describe("Xrp Api (testnet)", () => {
|
|
6
|
+
const SENDER = "rh1HPuRVsYYvThxG2Bs1MfjmrVC73S16Fb";
|
|
7
|
+
const api = createApi({ node: "https://s.altnet.rippletest.net:51234" });
|
|
8
|
+
describe("estimateFees", () => {
|
|
9
|
+
it("returns a default value", async () => {
|
|
10
|
+
// Given
|
|
11
|
+
const amount = BigInt(100);
|
|
12
|
+
// When
|
|
13
|
+
const result = await api.estimateFees({
|
|
14
|
+
intentType: "transaction",
|
|
15
|
+
asset: { type: "native" },
|
|
16
|
+
type: "send",
|
|
17
|
+
sender: SENDER,
|
|
18
|
+
amount,
|
|
19
|
+
recipient: "rKtXXTVno77jhu6tto1MAXjepyuaKaLcqB",
|
|
20
|
+
memo: {
|
|
21
|
+
type: "map",
|
|
22
|
+
memos: new Map(),
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
// Then
|
|
26
|
+
expect(result.value).toEqual(BigInt(10));
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
describe("listOperations", () => {
|
|
30
|
+
it.skip("returns a list regarding address parameter", async () => {
|
|
31
|
+
// When
|
|
32
|
+
const [tx, _] = await api.listOperations(SENDER, { minHeight: 200, order: "asc" });
|
|
33
|
+
// https://blockexplorer.one/xrp/testnet/address/rh1HPuRVsYYvThxG2Bs1MfjmrVC73S16Fb
|
|
34
|
+
// as of 2025-03-18, the address has 287 transactions
|
|
35
|
+
expect(tx.length).toBeGreaterThanOrEqual(287);
|
|
36
|
+
tx.forEach(operation => {
|
|
37
|
+
const isSenderOrReceipt = operation.senders.includes(SENDER) || operation.recipients.includes(SENDER);
|
|
38
|
+
expect(isSenderOrReceipt).toBeTruthy();
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
// TO FIX, ops length is 0 for some reason
|
|
42
|
+
it.skip("returns all operations", async () => {
|
|
43
|
+
// An account with more that 4000 txs
|
|
44
|
+
const SENDER_WITH_TRANSACTIONS = "rUxSkt6hQpWxXQwTNRUCYYRQ7BC2yRA3F8";
|
|
45
|
+
// When
|
|
46
|
+
const [ops, _] = await api.listOperations(SENDER_WITH_TRANSACTIONS, {
|
|
47
|
+
minHeight: 0,
|
|
48
|
+
order: "asc",
|
|
49
|
+
});
|
|
50
|
+
// Then
|
|
51
|
+
const checkSet = new Set(ops.map(elt => elt.tx.hash));
|
|
52
|
+
expect(checkSet.size).toEqual(ops.length);
|
|
53
|
+
// the first transaction is returned
|
|
54
|
+
expect(ops[0].tx.block.height).toEqual(73126713);
|
|
55
|
+
expect(ops[0].tx.hash.toUpperCase).toEqual("0FC3792449E5B1E431D45E3606017D10EC1FECC8EDF988A98E36B8FE0C33ACAE");
|
|
56
|
+
// 200 is the default XRP explorer hard limit,
|
|
57
|
+
// so here we are checking that this limit is bypassed
|
|
58
|
+
expect(ops.length).toBeGreaterThan(200);
|
|
59
|
+
});
|
|
60
|
+
it("returns operations from latest, but in asc order", async () => {
|
|
61
|
+
// When
|
|
62
|
+
const SENDER_WITH_TRANSACTIONS = "rUxSkt6hQpWxXQwTNRUCYYRQ7BC2yRA3F8";
|
|
63
|
+
const [txDesc] = await api.listOperations(SENDER_WITH_TRANSACTIONS, {
|
|
64
|
+
minHeight: 200,
|
|
65
|
+
order: "desc",
|
|
66
|
+
});
|
|
67
|
+
expect(txDesc.length).toBeGreaterThanOrEqual(200);
|
|
68
|
+
// Then
|
|
69
|
+
// Check if the result is sorted in ascending order
|
|
70
|
+
expect(txDesc[0].tx.block.height).toBeGreaterThanOrEqual(txDesc[txDesc.length - 1].tx.block.height);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
describe("lastBlock", () => {
|
|
74
|
+
it("returns last block info", async () => {
|
|
75
|
+
// When
|
|
76
|
+
const result = await api.lastBlock();
|
|
77
|
+
// Then
|
|
78
|
+
expect(result.hash).toBeDefined();
|
|
79
|
+
expect(result.height).toBeDefined();
|
|
80
|
+
expect(result.time).toBeInstanceOf(Date);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
describe("getBalance", () => {
|
|
84
|
+
// Account with no transaction (at the time of this writing)
|
|
85
|
+
const SENDER_WITH_NO_TRANSACTION = "rKtXXTVno77jhu6tto1MAXjepyuaKaLcqB";
|
|
86
|
+
it("returns a balance", async () => {
|
|
87
|
+
// When
|
|
88
|
+
const result = await api.getBalance(SENDER);
|
|
89
|
+
// Then
|
|
90
|
+
expect(result[0].asset).toEqual({ type: "native" });
|
|
91
|
+
expect(result[0].value).toBeGreaterThanOrEqual(BigInt(0));
|
|
92
|
+
});
|
|
93
|
+
it("returns 0 when address has no transaction", async () => {
|
|
94
|
+
// When
|
|
95
|
+
const result = await api.getBalance(SENDER_WITH_NO_TRANSACTION);
|
|
96
|
+
// Then
|
|
97
|
+
expect(result).toEqual([{ value: BigInt(0), asset: { type: "native" }, locked: 0n }]);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
describe("craftTransaction", () => {
|
|
101
|
+
const RECIPIENT = "rKRtUG15iBsCQRgrkeUEg5oX4Ae2zWZ89z";
|
|
102
|
+
it("returns a raw transaction", async () => {
|
|
103
|
+
// When
|
|
104
|
+
const { transaction: result } = await api.craftTransaction({
|
|
105
|
+
intentType: "transaction",
|
|
106
|
+
asset: { type: "native" },
|
|
107
|
+
type: "send",
|
|
108
|
+
sender: SENDER,
|
|
109
|
+
recipient: RECIPIENT,
|
|
110
|
+
amount: BigInt(10),
|
|
111
|
+
memo: {
|
|
112
|
+
type: "map",
|
|
113
|
+
memos: new Map([["memos", ["testdata"]]]),
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
// Then
|
|
117
|
+
expect(result.length).toEqual(178);
|
|
118
|
+
});
|
|
119
|
+
it("should use default fees when user does not provide them for crafting a transaction", async () => {
|
|
120
|
+
const { transaction: result } = await api.craftTransaction({
|
|
121
|
+
intentType: "transaction",
|
|
122
|
+
asset: { type: "native" },
|
|
123
|
+
type: "send",
|
|
124
|
+
sender: SENDER,
|
|
125
|
+
recipient: RECIPIENT,
|
|
126
|
+
amount: BigInt(10),
|
|
127
|
+
memo: {
|
|
128
|
+
type: "map",
|
|
129
|
+
memos: new Map(),
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
expect(decode(result)).toMatchObject({
|
|
133
|
+
Fee: "10",
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
it("should use custom user fees when user provides it for crafting a transaction", async () => {
|
|
137
|
+
const customFees = 99n;
|
|
138
|
+
const { transaction: result } = await api.craftTransaction({
|
|
139
|
+
intentType: "transaction",
|
|
140
|
+
asset: { type: "native" },
|
|
141
|
+
type: "send",
|
|
142
|
+
sender: SENDER,
|
|
143
|
+
recipient: RECIPIENT,
|
|
144
|
+
amount: BigInt(10),
|
|
145
|
+
memo: {
|
|
146
|
+
type: "map",
|
|
147
|
+
memos: new Map(),
|
|
148
|
+
},
|
|
149
|
+
}, { value: customFees });
|
|
150
|
+
expect(decode(result)).toMatchObject({
|
|
151
|
+
Fee: customFees.toString(),
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
describe("Xrp Api (mainnet)", () => {
|
|
157
|
+
const SENDER = "rn5BQvhksnPfbo277LtFks4iyYStPKGrnJ";
|
|
158
|
+
const api = createApi({ node: "https://xrp.coin.ledger.com" });
|
|
159
|
+
describe("estimateFees", () => {
|
|
160
|
+
it("returns a default value", async () => {
|
|
161
|
+
// Given
|
|
162
|
+
const amount = BigInt(100);
|
|
163
|
+
// When
|
|
164
|
+
const result = await api.estimateFees({
|
|
165
|
+
intentType: "transaction",
|
|
166
|
+
asset: { type: "native" },
|
|
167
|
+
type: "send",
|
|
168
|
+
sender: SENDER,
|
|
169
|
+
amount,
|
|
170
|
+
recipient: "r9m6MwViR4GnUNqoGXGa8eroBrZ9FAPHFS",
|
|
171
|
+
memo: {
|
|
172
|
+
type: "map",
|
|
173
|
+
memos: new Map(),
|
|
174
|
+
},
|
|
175
|
+
});
|
|
176
|
+
// Then
|
|
177
|
+
expect(result.value).toEqual(BigInt(10));
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
describe("listOperations", () => {
|
|
181
|
+
let ops;
|
|
182
|
+
beforeAll(async () => {
|
|
183
|
+
const resp = await api.listOperations(SENDER, { minHeight: 0 });
|
|
184
|
+
ops = resp[0];
|
|
185
|
+
});
|
|
186
|
+
it("returns operations", async () => {
|
|
187
|
+
// https://xrpscan.com/account/rn5BQvhksnPfbo277LtFks4iyYStPKGrnJ
|
|
188
|
+
expect(ops.length).toBeGreaterThanOrEqual(200);
|
|
189
|
+
const checkSet = new Set(ops.map(elt => elt.tx.hash));
|
|
190
|
+
expect(checkSet.size).toEqual(ops.length);
|
|
191
|
+
ops.forEach(operation => {
|
|
192
|
+
const isSenderOrReceipt = operation.senders.includes(SENDER) || operation.recipients.includes(SENDER);
|
|
193
|
+
expect(isSenderOrReceipt).toBeTruthy();
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
it("returns IN operation", async () => {
|
|
197
|
+
// https://xrpscan.com/tx/805E371FDA0223E8910F831802EE93DBA1A4CA40AC8C1337F26F566CD67788F5
|
|
198
|
+
const inTx = {
|
|
199
|
+
hash: "9E5141DCAE8158E51ED612333FF3EC2D60A3D2DCD2F6DD5E4F92E4A6704C3CE9",
|
|
200
|
+
amount: 7.5,
|
|
201
|
+
recipient: SENDER,
|
|
202
|
+
sender: "rnXQmrXk9HSKdNwkut1k9dpAMVYuBsJV49",
|
|
203
|
+
type: "IN",
|
|
204
|
+
fees: 0.00001,
|
|
205
|
+
};
|
|
206
|
+
const op = ops.find(o => o.tx.hash === inTx.hash);
|
|
207
|
+
expect(op.tx.hash).toEqual(inTx.hash);
|
|
208
|
+
expect(op.value).toEqual(BigInt(inTx.amount * 1e6));
|
|
209
|
+
expect(op.recipients).toContain(inTx.recipient);
|
|
210
|
+
expect(op.senders).toContain(inTx.sender);
|
|
211
|
+
expect(op.type).toEqual(inTx.type);
|
|
212
|
+
expect(op.tx.fees).toEqual(BigInt(inTx.fees * 1e6));
|
|
213
|
+
});
|
|
214
|
+
it("returns OUT operation", async () => {
|
|
215
|
+
// https://xrpscan.com/tx/8D13FD7EE0D28B615905903D033A3DC3839FBAA2F545417E3DE51A1A745C1688
|
|
216
|
+
const outTx = {
|
|
217
|
+
hash: "8D13FD7EE0D28B615905903D033A3DC3839FBAA2F545417E3DE51A1A745C1688",
|
|
218
|
+
amount: 0.1,
|
|
219
|
+
recipient: "r3XzsqzQCC6r4ZzifWnwa32sFR2H9exkew",
|
|
220
|
+
sender: SENDER,
|
|
221
|
+
type: "OUT",
|
|
222
|
+
fees: 0.00001,
|
|
223
|
+
};
|
|
224
|
+
const op = ops.find(o => o.tx.hash === outTx.hash);
|
|
225
|
+
expect(op.tx.hash).toEqual(outTx.hash);
|
|
226
|
+
expect(op.value).toEqual(BigInt(outTx.amount * 1e6));
|
|
227
|
+
expect(op.recipients).toContain(outTx.recipient);
|
|
228
|
+
expect(op.senders).toContain(outTx.sender);
|
|
229
|
+
expect(op.type).toEqual(outTx.type);
|
|
230
|
+
expect(op.tx.fees).toEqual(BigInt(outTx.fees * 1e6));
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
describe("lastBlock", () => {
|
|
234
|
+
it("returns last block info", async () => {
|
|
235
|
+
const result = await api.lastBlock();
|
|
236
|
+
expect(result.hash).toBeDefined();
|
|
237
|
+
expect(result.height).toBeDefined();
|
|
238
|
+
expect(result.time).toBeInstanceOf(Date);
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
describe("getBalance", () => {
|
|
242
|
+
it("returns an amount", async () => {
|
|
243
|
+
const result = await api.getBalance(SENDER);
|
|
244
|
+
expect(result[0].asset).toEqual({ type: "native" });
|
|
245
|
+
expect(result[0].value).toBeGreaterThanOrEqual(BigInt(0));
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
describe("craftTransaction", () => {
|
|
249
|
+
const RECIPIENT = "r9m6MwViR4GnUNqoGXGa8eroBrZ9FAPHFS";
|
|
250
|
+
it("returns a raw transaction", async () => {
|
|
251
|
+
const { transaction: result } = await api.craftTransaction({
|
|
252
|
+
intentType: "transaction",
|
|
253
|
+
asset: { type: "native" },
|
|
254
|
+
type: "send",
|
|
255
|
+
sender: SENDER,
|
|
256
|
+
recipient: RECIPIENT,
|
|
257
|
+
amount: BigInt(10),
|
|
258
|
+
memo: {
|
|
259
|
+
type: "map",
|
|
260
|
+
memos: new Map([["memos", ["testdata"]]]),
|
|
261
|
+
},
|
|
262
|
+
});
|
|
263
|
+
expect(result.length).toEqual(178);
|
|
264
|
+
});
|
|
265
|
+
it("should use default fees when user does not provide them for crafting a transaction", async () => {
|
|
266
|
+
const { transaction: result } = await api.craftTransaction({
|
|
267
|
+
intentType: "transaction",
|
|
268
|
+
asset: { type: "native" },
|
|
269
|
+
type: "send",
|
|
270
|
+
sender: SENDER,
|
|
271
|
+
recipient: RECIPIENT,
|
|
272
|
+
amount: BigInt(10),
|
|
273
|
+
memo: {
|
|
274
|
+
type: "map",
|
|
275
|
+
memos: new Map(),
|
|
276
|
+
},
|
|
277
|
+
});
|
|
278
|
+
expect(decode(result)).toMatchObject({
|
|
279
|
+
Fee: "10",
|
|
280
|
+
});
|
|
281
|
+
});
|
|
282
|
+
it("should use custom user fees when user provides it for crafting a transaction", async () => {
|
|
283
|
+
const customFees = 99n;
|
|
284
|
+
const { transaction: result } = await api.craftTransaction({
|
|
285
|
+
intentType: "transaction",
|
|
286
|
+
asset: { type: "native" },
|
|
287
|
+
type: "send",
|
|
288
|
+
sender: SENDER,
|
|
289
|
+
recipient: RECIPIENT,
|
|
290
|
+
amount: BigInt(10),
|
|
291
|
+
memo: {
|
|
292
|
+
type: "map",
|
|
293
|
+
memos: new Map(),
|
|
294
|
+
},
|
|
295
|
+
}, { value: customFees });
|
|
296
|
+
expect(decode(result)).toMatchObject({
|
|
297
|
+
Fee: customFees.toString(),
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
});
|
|
302
|
+
// To enable this test, you need to fill an `.env` file at the root of this package. Example can be found in `.env.integ.test.example`.
|
|
303
|
+
// The value hardcoded here depends on the value filled in the `.env` file.
|
|
304
|
+
/*describe.skip("combine", () => {
|
|
305
|
+
//const xrpPubKey = process.env["PUB_KEY"]!;
|
|
306
|
+
//const xrpSecretKey = process.env["SECRET_KEY"]!;
|
|
307
|
+
it("returns a signed raw transaction", async () => {
|
|
308
|
+
// Given
|
|
309
|
+
const rawTx =
|
|
310
|
+
"120000228000000024001BCDA6201B001F018161400000000000000A6840000000000000018114CF30F590D7A9067B2604D80D46090FBF342EBE988314CA26FB6B0EF6859436C2037BA0A9913208A59B98";
|
|
311
|
+
const signedTx = sign(
|
|
312
|
+
encodeForSigning({
|
|
313
|
+
...decode(rawTx),
|
|
314
|
+
SigningPubKey: xrpPubKey,
|
|
315
|
+
}),
|
|
316
|
+
xrpSecretKey,
|
|
317
|
+
);
|
|
318
|
+
|
|
319
|
+
// When
|
|
320
|
+
const result = await module.combine(rawTx, signedTx);
|
|
321
|
+
|
|
322
|
+
// Then
|
|
323
|
+
expect(result).toEqual(
|
|
324
|
+
"120000228000000024001BCDA6201B001F018161400000000000000A68400000000000000174473045022100D3B9B37F40961A8DBDE48535F9EF333E87F9D98BE90F7141E133541874826BDB0220065E9CA4D218F16087656BC30D66672F6103B03717A59FFC04C837A2157CE47C8114CF30F590D7A9067B2604D80D46090FBF342EBE988314CA26FB6B0EF6859436C2037BA0A9913208A59B98",
|
|
325
|
+
);
|
|
326
|
+
});
|
|
327
|
+
});
|
|
328
|
+
});
|
|
329
|
+
*/
|
|
330
|
+
//# sourceMappingURL=index.integ.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.integ.test.js","sourceRoot":"","sources":["../../src/api/index.integ.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,GAAG,CAAC;AAE9B,iEAAiE;AACjE,yCAAyC;AAEzC,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,MAAM,MAAM,GAAG,oCAAoC,CAAC;IACpD,MAAM,GAAG,GAAG,SAAS,CAAC,EAAE,IAAI,EAAE,uCAAuC,EAAE,CAAC,CAAC;IAEzE,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;QAC5B,EAAE,CAAC,yBAAyB,EAAE,KAAK,IAAI,EAAE;YACvC,QAAQ;YACR,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;YAE3B,OAAO;YACP,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,YAAY,CAAC;gBACpC,UAAU,EAAE,aAAa;gBACzB,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACzB,IAAI,EAAE,MAAM;gBACZ,MAAM,EAAE,MAAM;gBACd,MAAM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AAM,CAAC,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC;gBACnC,GAAG,EAAE,UAAU,CAAC,QAAQ,EAAE;aAC3B,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,uIAAuI;AACvI,2EAA2E;AAC3E;;;;;;;;;;;;;;;;;;;;;;;;;IAyBI"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../src/api/index.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
import * as LogicFunctions from "../logic";
|
|
2
|
+
import { createApi } from "./index";
|
|
3
|
+
const mockGetServerInfos = jest.fn().mockResolvedValue({
|
|
4
|
+
info: {
|
|
5
|
+
complete_ledgers: "1-2",
|
|
6
|
+
},
|
|
7
|
+
});
|
|
8
|
+
const mockGetTransactions = jest.fn();
|
|
9
|
+
jest.mock("../network", () => ({
|
|
10
|
+
getServerInfos: () => mockGetServerInfos(),
|
|
11
|
+
getTransactions: (address, options) => mockGetTransactions(address, options),
|
|
12
|
+
}));
|
|
13
|
+
describe("listOperations", () => {
|
|
14
|
+
const api = createApi({ node: "https://localhost" });
|
|
15
|
+
afterEach(() => {
|
|
16
|
+
mockGetServerInfos.mockClear();
|
|
17
|
+
mockGetTransactions.mockClear();
|
|
18
|
+
});
|
|
19
|
+
const defaultMarker = { ledger: 1, seq: 1 };
|
|
20
|
+
function mockNetworkTxs(txs, marker) {
|
|
21
|
+
return {
|
|
22
|
+
account: "account",
|
|
23
|
+
ledger_index_max: 1,
|
|
24
|
+
ledger_index_min: 1,
|
|
25
|
+
limit: 1,
|
|
26
|
+
validated: false,
|
|
27
|
+
transactions: txs,
|
|
28
|
+
marker: marker,
|
|
29
|
+
error: "",
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function givenTxs(fee, deliveredAmount, opSender, opDestination) {
|
|
33
|
+
return [
|
|
34
|
+
{
|
|
35
|
+
ledger_hash: "HASH_VALUE_BLOCK",
|
|
36
|
+
hash: "HASH_VALUE",
|
|
37
|
+
close_time_iso: "2000-01-01T00:00:01Z",
|
|
38
|
+
meta: { delivered_amount: deliveredAmount.toString() },
|
|
39
|
+
tx_json: {
|
|
40
|
+
TransactionType: "Payment",
|
|
41
|
+
Fee: fee.toString(),
|
|
42
|
+
ledger_index: 1,
|
|
43
|
+
date: 1000,
|
|
44
|
+
Account: opSender,
|
|
45
|
+
Destination: opDestination,
|
|
46
|
+
Sequence: 1,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
ledger_hash: "HASH_VALUE_BLOCK",
|
|
51
|
+
hash: "HASH_VALUE",
|
|
52
|
+
close_time_iso: "2000-01-01T00:00:01Z",
|
|
53
|
+
meta: { delivered_amount: deliveredAmount.toString() },
|
|
54
|
+
tx_json: {
|
|
55
|
+
TransactionType: "Payment",
|
|
56
|
+
Fee: fee.toString(),
|
|
57
|
+
ledger_index: 1,
|
|
58
|
+
date: 1000,
|
|
59
|
+
Account: opSender,
|
|
60
|
+
Destination: opDestination,
|
|
61
|
+
DestinationTag: 509555,
|
|
62
|
+
Sequence: 1,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
ledger_hash: "HASH_VALUE_BLOCK",
|
|
67
|
+
hash: "HASH_VALUE",
|
|
68
|
+
close_time_iso: "2000-01-01T00:00:01Z",
|
|
69
|
+
meta: { delivered_amount: deliveredAmount.toString() },
|
|
70
|
+
tx_json: {
|
|
71
|
+
TransactionType: "Payment",
|
|
72
|
+
Fee: fee.toString(),
|
|
73
|
+
ledger_index: 1,
|
|
74
|
+
date: 1000,
|
|
75
|
+
Account: opSender,
|
|
76
|
+
Destination: opDestination,
|
|
77
|
+
Memos: [
|
|
78
|
+
{
|
|
79
|
+
Memo: {
|
|
80
|
+
MemoType: "687474703a2f2f6578616d706c652e636f6d2f6d656d6f2f67656e65726963",
|
|
81
|
+
MemoData: "72656e74",
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
Sequence: 1,
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
];
|
|
89
|
+
}
|
|
90
|
+
it("should kill the loop after 10 iterations", async () => {
|
|
91
|
+
const txs = givenTxs(BigInt(10), BigInt(10), "src", "dest");
|
|
92
|
+
// each time it's called it returns a marker, so in theory it would loop forever
|
|
93
|
+
mockGetTransactions.mockResolvedValue(mockNetworkTxs(txs, defaultMarker));
|
|
94
|
+
const [results, _] = await api.listOperations("src", { minHeight: 0, order: "asc" });
|
|
95
|
+
// called 1 times because the client is expected to do the pagination itself
|
|
96
|
+
expect(mockGetServerInfos).toHaveBeenCalledTimes(1);
|
|
97
|
+
expect(mockGetTransactions).toHaveBeenCalledTimes(1);
|
|
98
|
+
expect(results.length).toBe(txs.length);
|
|
99
|
+
});
|
|
100
|
+
it("should pass the token returned by previous calls", async () => {
|
|
101
|
+
const txs = givenTxs(BigInt(10), BigInt(10), "src", "dest");
|
|
102
|
+
mockGetTransactions
|
|
103
|
+
.mockReturnValueOnce(mockNetworkTxs(txs, defaultMarker))
|
|
104
|
+
.mockReturnValueOnce(mockNetworkTxs(txs, undefined));
|
|
105
|
+
const [results, token] = await api.listOperations("src", { minHeight: 0, order: "asc" });
|
|
106
|
+
expect(mockGetServerInfos).toHaveBeenCalledTimes(1);
|
|
107
|
+
expect(mockGetTransactions).toHaveBeenCalledTimes(1);
|
|
108
|
+
// check tokens are passed
|
|
109
|
+
const baseOptions = {
|
|
110
|
+
ledger_index_min: 1,
|
|
111
|
+
limit: 200,
|
|
112
|
+
forward: true,
|
|
113
|
+
};
|
|
114
|
+
expect(mockGetTransactions).toHaveBeenNthCalledWith(1, "src", baseOptions);
|
|
115
|
+
await api.listOperations("src", { minHeight: 0, order: "asc", lastPagingToken: token });
|
|
116
|
+
const optionsWithToken = {
|
|
117
|
+
...baseOptions,
|
|
118
|
+
marker: defaultMarker,
|
|
119
|
+
};
|
|
120
|
+
expect(mockGetTransactions).toHaveBeenNthCalledWith(2, "src", optionsWithToken);
|
|
121
|
+
expect(results.length).toBe(txs.length);
|
|
122
|
+
});
|
|
123
|
+
it.each([
|
|
124
|
+
{
|
|
125
|
+
address: "WHATEVER_ADDRESS",
|
|
126
|
+
opSender: "account_addr",
|
|
127
|
+
opDestination: "WHATEVER_ADDRESS",
|
|
128
|
+
expectedType: "IN",
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
address: "WHATEVER_ADDRESS",
|
|
132
|
+
opSender: "WHATEVER_ADDRESS",
|
|
133
|
+
opDestination: "destination_addr",
|
|
134
|
+
expectedType: "OUT",
|
|
135
|
+
},
|
|
136
|
+
])(`should return the list of operations associated to an account when expected type is %s`, async ({ address, opSender, opDestination, expectedType }) => {
|
|
137
|
+
// Givem
|
|
138
|
+
const deliveredAmount = BigInt(100);
|
|
139
|
+
const fee = BigInt(10);
|
|
140
|
+
mockGetTransactions.mockResolvedValueOnce(mockNetworkTxs(givenTxs(fee, deliveredAmount, opSender, opDestination), defaultMarker));
|
|
141
|
+
// second call to kill the loop
|
|
142
|
+
mockGetTransactions.mockResolvedValue(mockNetworkTxs([], undefined));
|
|
143
|
+
// When
|
|
144
|
+
const [results, _] = await api.listOperations(address, { minHeight: 0, order: "asc" });
|
|
145
|
+
// Then
|
|
146
|
+
expect(mockGetServerInfos).toHaveBeenCalledTimes(1);
|
|
147
|
+
expect(mockGetTransactions).toHaveBeenCalledTimes(1);
|
|
148
|
+
// the order is reversed so that the result is always sorted by newest tx first element of the list
|
|
149
|
+
expect(results).toEqual([
|
|
150
|
+
{
|
|
151
|
+
id: "HASH_VALUE",
|
|
152
|
+
asset: { type: "native" },
|
|
153
|
+
tx: {
|
|
154
|
+
hash: "HASH_VALUE",
|
|
155
|
+
fees: fee,
|
|
156
|
+
date: new Date(1000000 + LogicFunctions.RIPPLE_EPOCH * 1000),
|
|
157
|
+
block: {
|
|
158
|
+
hash: "HASH_VALUE_BLOCK",
|
|
159
|
+
height: 1,
|
|
160
|
+
time: new Date("2000-01-01T00:00:01Z"),
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
type: expectedType,
|
|
164
|
+
value: deliveredAmount,
|
|
165
|
+
senders: [opSender],
|
|
166
|
+
recipients: [opDestination],
|
|
167
|
+
details: {
|
|
168
|
+
sequence: 1,
|
|
169
|
+
xrpTxType: "Payment",
|
|
170
|
+
memos: [
|
|
171
|
+
{
|
|
172
|
+
type: "687474703a2f2f6578616d706c652e636f6d2f6d656d6f2f67656e65726963",
|
|
173
|
+
data: "72656e74",
|
|
174
|
+
},
|
|
175
|
+
],
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
id: "HASH_VALUE",
|
|
180
|
+
asset: { type: "native" },
|
|
181
|
+
tx: {
|
|
182
|
+
hash: "HASH_VALUE",
|
|
183
|
+
fees: fee,
|
|
184
|
+
date: new Date(1000000 + LogicFunctions.RIPPLE_EPOCH * 1000),
|
|
185
|
+
block: {
|
|
186
|
+
hash: "HASH_VALUE_BLOCK",
|
|
187
|
+
height: 1,
|
|
188
|
+
time: new Date("2000-01-01T00:00:01Z"),
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
type: expectedType,
|
|
192
|
+
value: deliveredAmount,
|
|
193
|
+
senders: [opSender],
|
|
194
|
+
recipients: [opDestination],
|
|
195
|
+
details: {
|
|
196
|
+
sequence: 1,
|
|
197
|
+
xrpTxType: "Payment",
|
|
198
|
+
destinationTag: 509555,
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
id: "HASH_VALUE",
|
|
203
|
+
asset: { type: "native" },
|
|
204
|
+
tx: {
|
|
205
|
+
hash: "HASH_VALUE",
|
|
206
|
+
fees: fee,
|
|
207
|
+
date: new Date(1000000 + LogicFunctions.RIPPLE_EPOCH * 1000),
|
|
208
|
+
block: {
|
|
209
|
+
hash: "HASH_VALUE_BLOCK",
|
|
210
|
+
height: 1,
|
|
211
|
+
time: new Date("2000-01-01T00:00:01Z"),
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
type: expectedType,
|
|
215
|
+
value: deliveredAmount,
|
|
216
|
+
senders: [opSender],
|
|
217
|
+
recipients: [opDestination],
|
|
218
|
+
details: {
|
|
219
|
+
xrpTxType: "Payment",
|
|
220
|
+
sequence: 1,
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
]);
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
describe("Testing craftTransaction function", () => {
|
|
227
|
+
const DEFAULT_ESTIMATED_FEES = 100n;
|
|
228
|
+
const api = createApi({ node: "https://localhost" });
|
|
229
|
+
const logicCraftTransactionSpy = jest
|
|
230
|
+
.spyOn(LogicFunctions, "craftTransaction")
|
|
231
|
+
.mockImplementation((_address, _transaction, _publicKey) => {
|
|
232
|
+
return Promise.resolve({ xrplTransaction: {}, serializedTransaction: "" });
|
|
233
|
+
});
|
|
234
|
+
beforeAll(() => {
|
|
235
|
+
jest
|
|
236
|
+
.spyOn(LogicFunctions, "getNextValidSequence")
|
|
237
|
+
.mockImplementation(_address => Promise.resolve(0));
|
|
238
|
+
jest.spyOn(LogicFunctions, "estimateFees").mockImplementation(_networkInfo => {
|
|
239
|
+
return Promise.resolve({
|
|
240
|
+
networkInfo: {},
|
|
241
|
+
fees: DEFAULT_ESTIMATED_FEES,
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
it("should use custom user fees when user provides it for crafting a transaction", async () => {
|
|
246
|
+
const customFees = 99n;
|
|
247
|
+
await api.craftTransaction({ intentType: "transaction", sender: "foo" }, {
|
|
248
|
+
value: customFees,
|
|
249
|
+
});
|
|
250
|
+
expect(logicCraftTransactionSpy).toHaveBeenCalledWith(expect.any(Object), expect.objectContaining({
|
|
251
|
+
fees: customFees,
|
|
252
|
+
}), undefined);
|
|
253
|
+
});
|
|
254
|
+
it("should use default fees when user does not provide them for crafting a transaction", async () => {
|
|
255
|
+
await api.craftTransaction({
|
|
256
|
+
intentType: "transaction",
|
|
257
|
+
sender: "foo",
|
|
258
|
+
});
|
|
259
|
+
expect(logicCraftTransactionSpy).toHaveBeenCalledWith(expect.any(Object), expect.objectContaining({
|
|
260
|
+
fees: DEFAULT_ESTIMATED_FEES,
|
|
261
|
+
}), undefined);
|
|
262
|
+
});
|
|
263
|
+
it("should pass signing pub key when user provides it for crafting a transaction", async () => {
|
|
264
|
+
await api.craftTransaction({
|
|
265
|
+
intentType: "transaction",
|
|
266
|
+
sender: "foo",
|
|
267
|
+
senderPublicKey: "bar",
|
|
268
|
+
});
|
|
269
|
+
expect(logicCraftTransactionSpy).toHaveBeenCalledWith(expect.any(Object), expect.any(Object), "bar");
|
|
270
|
+
});
|
|
271
|
+
it("should pass memos when user provides it for crafting a transaction", async () => {
|
|
272
|
+
await api.craftTransaction({
|
|
273
|
+
intentType: "transaction",
|
|
274
|
+
sender: "foo",
|
|
275
|
+
memo: {
|
|
276
|
+
type: "map",
|
|
277
|
+
memos: new Map([["memos", ["testdata"]]]),
|
|
278
|
+
},
|
|
279
|
+
});
|
|
280
|
+
expect(logicCraftTransactionSpy).toHaveBeenCalledWith(expect.any(Object), expect.objectContaining({
|
|
281
|
+
// NOTE: before
|
|
282
|
+
// memos: [{ data: "testdata", format: "testformat", type: "testtype" }],
|
|
283
|
+
memos: [{ data: "testdata", type: "memo" }],
|
|
284
|
+
}), undefined);
|
|
285
|
+
});
|
|
286
|
+
it("should not pass memos when user does not provide it for crafting a transaction", async () => {
|
|
287
|
+
await api.craftTransaction({
|
|
288
|
+
intentType: "transaction",
|
|
289
|
+
sender: "foo",
|
|
290
|
+
});
|
|
291
|
+
expect(logicCraftTransactionSpy).toHaveBeenCalledWith(expect.any(Object), expect.objectContaining({
|
|
292
|
+
memos: undefined,
|
|
293
|
+
}), undefined);
|
|
294
|
+
});
|
|
295
|
+
it("should not pass memos when user provides an empty memo list it for crafting a transaction", async () => {
|
|
296
|
+
await api.craftTransaction({
|
|
297
|
+
intentType: "transaction",
|
|
298
|
+
sender: "foo",
|
|
299
|
+
memo: {
|
|
300
|
+
type: "map",
|
|
301
|
+
memos: new Map(),
|
|
302
|
+
},
|
|
303
|
+
});
|
|
304
|
+
expect(logicCraftTransactionSpy).toHaveBeenCalledWith(expect.any(Object), expect.objectContaining({
|
|
305
|
+
memos: undefined,
|
|
306
|
+
}), undefined);
|
|
307
|
+
});
|
|
308
|
+
it("should pass destination tag when user provides it for crafting a transaction", async () => {
|
|
309
|
+
await api.craftTransaction({
|
|
310
|
+
intentType: "transaction",
|
|
311
|
+
sender: "foo",
|
|
312
|
+
memo: {
|
|
313
|
+
type: "map",
|
|
314
|
+
memos: new Map([["destinationTag", "1337"]]),
|
|
315
|
+
},
|
|
316
|
+
});
|
|
317
|
+
expect(logicCraftTransactionSpy).toHaveBeenCalledWith(expect.any(Object), expect.objectContaining({
|
|
318
|
+
destinationTag: 1337, // logic should convert `value: string` -> `number`
|
|
319
|
+
}), undefined);
|
|
320
|
+
});
|
|
321
|
+
});
|
|
322
|
+
//# sourceMappingURL=index.test.js.map
|