@ledgerhq/coin-xrp 2.1.0 → 2.2.0-nightly.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.
Files changed (55) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/lib/api/index.d.ts +1 -1
  3. package/lib/api/index.d.ts.map +1 -1
  4. package/lib/api/index.integ.test.js +20 -17
  5. package/lib/api/index.integ.test.js.map +1 -1
  6. package/lib/api/index.js +6 -23
  7. package/lib/api/index.js.map +1 -1
  8. package/lib/api/index.test.js +44 -33
  9. package/lib/api/index.test.js.map +1 -1
  10. package/lib/bridge/prepareTransaction.js +2 -2
  11. package/lib/bridge/prepareTransaction.js.map +1 -1
  12. package/lib/bridge/synchronization.d.ts.map +1 -1
  13. package/lib/bridge/synchronization.js +13 -10
  14. package/lib/bridge/synchronization.js.map +1 -1
  15. package/lib/logic/estimateFees.test.js.map +1 -1
  16. package/lib/logic/listOperations.d.ts +3 -2
  17. package/lib/logic/listOperations.d.ts.map +1 -1
  18. package/lib/logic/listOperations.js +18 -11
  19. package/lib/logic/listOperations.js.map +1 -1
  20. package/lib/logic/listOperations.test.js +44 -30
  21. package/lib/logic/listOperations.test.js.map +1 -1
  22. package/lib/types/model.d.ts +0 -19
  23. package/lib/types/model.d.ts.map +1 -1
  24. package/lib-es/api/index.d.ts +1 -1
  25. package/lib-es/api/index.d.ts.map +1 -1
  26. package/lib-es/api/index.integ.test.js +20 -17
  27. package/lib-es/api/index.integ.test.js.map +1 -1
  28. package/lib-es/api/index.js +6 -23
  29. package/lib-es/api/index.js.map +1 -1
  30. package/lib-es/api/index.test.js +44 -33
  31. package/lib-es/api/index.test.js.map +1 -1
  32. package/lib-es/bridge/prepareTransaction.js +1 -1
  33. package/lib-es/bridge/prepareTransaction.js.map +1 -1
  34. package/lib-es/bridge/synchronization.d.ts.map +1 -1
  35. package/lib-es/bridge/synchronization.js +13 -10
  36. package/lib-es/bridge/synchronization.js.map +1 -1
  37. package/lib-es/logic/estimateFees.test.js.map +1 -1
  38. package/lib-es/logic/listOperations.d.ts +3 -2
  39. package/lib-es/logic/listOperations.d.ts.map +1 -1
  40. package/lib-es/logic/listOperations.js +18 -11
  41. package/lib-es/logic/listOperations.js.map +1 -1
  42. package/lib-es/logic/listOperations.test.js +44 -30
  43. package/lib-es/logic/listOperations.test.js.map +1 -1
  44. package/lib-es/types/model.d.ts +0 -19
  45. package/lib-es/types/model.d.ts.map +1 -1
  46. package/package.json +4 -4
  47. package/src/api/index.integ.test.ts +21 -20
  48. package/src/api/index.test.ts +46 -34
  49. package/src/api/index.ts +15 -30
  50. package/src/bridge/prepareTransaction.ts +1 -1
  51. package/src/bridge/synchronization.ts +21 -19
  52. package/src/logic/estimateFees.test.ts +1 -1
  53. package/src/logic/listOperations.test.ts +46 -31
  54. package/src/logic/listOperations.ts +24 -15
  55. package/src/types/model.ts +0 -19
@@ -2,6 +2,7 @@ import { assert } from "console";
2
2
  import { listOperations } from "./listOperations";
3
3
  import { RIPPLE_EPOCH } from "./utils";
4
4
  import { Marker } from "../network/types";
5
+ import { Operation } from "@ledgerhq/coin-framework/api/types";
5
6
 
6
7
  const maxHeight = 2;
7
8
  const minHeight = 1;
@@ -215,20 +216,24 @@ describe("listOperations", () => {
215
216
  expectedType === "IN" ? BigInt(deliveredAmount) : BigInt(deliveredAmount + fee);
216
217
  expect(results).toEqual([
217
218
  {
218
- hash: "HASH_VALUE",
219
- address,
220
- type: "Payment",
221
- simpleType: expectedType,
219
+ operationIndex: 0,
220
+ tx: {
221
+ fees: BigInt(10),
222
+ hash: "HASH_VALUE",
223
+ block: {
224
+ hash: "HASH_VALUE_BLOCK",
225
+ height: 1,
226
+ time: new Date("2000-01-01T00:00:01Z"),
227
+ },
228
+ date: new Date(1000000 + RIPPLE_EPOCH * 1000),
229
+ },
230
+ type: expectedType,
222
231
  value: expectedValue,
223
- fee: BigInt(10),
224
- blockHeight: 1,
225
- blockHash: "HASH_VALUE_BLOCK",
226
- blockTime: new Date("2000-01-01T00:00:01Z"),
227
232
  senders: [opSender],
228
233
  recipients: [opDestination],
229
- date: new Date(1000000 + RIPPLE_EPOCH * 1000),
230
- transactionSequenceNumber: 1,
231
234
  details: {
235
+ sequence: 1,
236
+ xrpTxType: "Payment",
232
237
  memos: [
233
238
  {
234
239
  type: "687474703a2f2f6578616d706c652e636f6d2f6d656d6f2f67656e65726963",
@@ -238,39 +243,49 @@ describe("listOperations", () => {
238
243
  },
239
244
  },
240
245
  {
241
- hash: "HASH_VALUE",
242
- address,
243
- type: "Payment",
244
- simpleType: expectedType,
246
+ operationIndex: 0,
247
+ tx: {
248
+ hash: "HASH_VALUE",
249
+ fees: BigInt(10),
250
+ date: new Date(1000000 + RIPPLE_EPOCH * 1000),
251
+ block: {
252
+ hash: "HASH_VALUE_BLOCK",
253
+ height: 1,
254
+ time: new Date("2000-01-01T00:00:01Z"),
255
+ },
256
+ },
257
+ type: expectedType,
245
258
  value: expectedValue,
246
- fee: BigInt(10),
247
- blockHeight: 1,
248
- blockHash: "HASH_VALUE_BLOCK",
249
- blockTime: new Date("2000-01-01T00:00:01Z"),
250
259
  senders: [opSender],
251
260
  recipients: [opDestination],
252
- date: new Date(1000000 + RIPPLE_EPOCH * 1000),
253
- transactionSequenceNumber: 1,
254
261
  details: {
262
+ sequence: 1,
255
263
  destinationTag: 509555,
264
+ xrpTxType: "Payment",
256
265
  },
257
266
  },
258
267
  {
259
- hash: "HASH_VALUE",
260
- address,
261
- type: "Payment",
262
- simpleType: expectedType,
268
+ tx: {
269
+ hash: "HASH_VALUE",
270
+ fees: BigInt(10),
271
+ block: {
272
+ hash: "HASH_VALUE_BLOCK",
273
+ height: 1,
274
+ time: new Date("2000-01-01T00:00:01Z"),
275
+ },
276
+ date: new Date(1000000 + RIPPLE_EPOCH * 1000),
277
+ },
278
+ details: {
279
+ sequence: 1,
280
+ xrpTxType: "Payment",
281
+ },
282
+ type: expectedType,
263
283
  value: expectedValue,
264
- fee: BigInt(10),
265
- blockHeight: 1,
266
- blockHash: "HASH_VALUE_BLOCK",
267
- blockTime: new Date("2000-01-01T00:00:01Z"),
268
284
  senders: [opSender],
269
285
  recipients: [opDestination],
270
- date: new Date(1000000 + RIPPLE_EPOCH * 1000),
271
- transactionSequenceNumber: 1,
286
+ operationIndex: 0,
272
287
  },
273
- ]);
288
+ ] satisfies Operation<void>[]);
274
289
  },
275
290
  );
276
291
  });
@@ -1,6 +1,7 @@
1
+ import { Operation } from "@ledgerhq/coin-framework/api/types";
1
2
  import { getServerInfos, getTransactions, GetTransactionsOptions } from "../network";
2
3
  import type { XrplOperation } from "../network/types";
3
- import { ListOperationsOptions, XrpMemo, XrpOperation } from "../types";
4
+ import { ListOperationsOptions, XrpMemo } from "../types";
4
5
  import { RIPPLE_EPOCH } from "./utils";
5
6
 
6
7
  /**
@@ -19,7 +20,7 @@ import { RIPPLE_EPOCH } from "./utils";
19
20
  export async function listOperations(
20
21
  address: string,
21
22
  { limit, minHeight, token, order }: ListOperationsOptions,
22
- ): Promise<[XrpOperation[], string]> {
23
+ ): Promise<[Operation<void>[], string]> {
23
24
  const serverInfo = await getServerInfos();
24
25
  const ledgers = serverInfo.info.complete_ledgers.split("-");
25
26
  const minLedgerVersion = Number(ledgers[0]);
@@ -98,7 +99,7 @@ export async function listOperations(
98
99
 
99
100
  const convertToCoreOperation =
100
101
  (address: string) =>
101
- (operation: XrplOperation): XrpOperation => {
102
+ (operation: XrplOperation): Operation<void> => {
102
103
  const {
103
104
  ledger_hash,
104
105
  hash,
@@ -111,9 +112,9 @@ const convertToCoreOperation =
111
112
  Account,
112
113
  Destination,
113
114
  DestinationTag,
114
- Sequence,
115
115
  Memos,
116
116
  ledger_index,
117
+ Sequence,
117
118
  },
118
119
  } = operation;
119
120
 
@@ -156,20 +157,28 @@ const convertToCoreOperation =
156
157
  };
157
158
  }
158
159
 
159
- let op: XrpOperation = {
160
- blockTime: new Date(close_time_iso),
161
- blockHash: ledger_hash,
162
- hash,
163
- address,
164
- type: TransactionType,
165
- simpleType: type,
160
+ details = {
161
+ ...details,
162
+ xrpTxType: TransactionType,
163
+ sequence: Sequence,
164
+ };
165
+
166
+ let op: Operation<void> = {
167
+ operationIndex: 0,
168
+ tx: {
169
+ hash: hash,
170
+ fees: fee,
171
+ date: new Date(toEpochDate),
172
+ block: {
173
+ time: new Date(close_time_iso),
174
+ hash: ledger_hash,
175
+ height: ledger_index,
176
+ },
177
+ },
178
+ type: type,
166
179
  value,
167
- fee,
168
- blockHeight: ledger_index,
169
180
  senders: [Account],
170
181
  recipients: [Destination],
171
- date: new Date(toEpochDate),
172
- transactionSequenceNumber: Sequence,
173
182
  };
174
183
 
175
184
  if (Object.keys(details).length != 0) {
@@ -10,25 +10,6 @@ export type XrpMemo = {
10
10
  format?: string;
11
11
  type?: string;
12
12
  };
13
- export type XrpOperation = {
14
- blockTime: Date;
15
- blockHash: string;
16
- hash: string;
17
- address: string;
18
- type: string;
19
- simpleType: "IN" | "OUT";
20
- value: bigint;
21
- fee: bigint;
22
- blockHeight: number;
23
- senders: string[];
24
- recipients: string[];
25
- date: Date;
26
- transactionSequenceNumber: number;
27
- details?: {
28
- destinationTag?: number;
29
- memos?: XrpMemo[];
30
- };
31
- };
32
13
 
33
14
  type Order = "asc" | "desc";
34
15
  export type ListOperationsOptions = {