@ledgerhq/coin-xrp 7.1.0-nightly.2 → 7.1.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/.unimportedrc.json +1 -3
- package/CHANGELOG.md +19 -20
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +6 -19
- package/lib/api/index.js.map +1 -1
- package/lib/api/index.test.js +1 -1
- package/lib/api/index.test.js.map +1 -1
- package/lib/logic/craftTransaction.d.ts +1 -1
- package/lib/logic/craftTransaction.d.ts.map +1 -1
- package/lib/logic/craftTransaction.js +1 -1
- package/lib/logic/craftTransaction.js.map +1 -1
- package/lib/logic/craftTransaction.test.js +2 -2
- package/lib/logic/craftTransaction.test.js.map +1 -1
- package/lib/logic/estimateFees.d.ts +1 -1
- package/lib/logic/estimateFees.d.ts.map +1 -1
- package/lib/logic/estimateFees.js +1 -1
- package/lib/logic/estimateFees.js.map +1 -1
- package/lib/logic/estimateFees.test.js +2 -2
- package/lib/logic/estimateFees.test.js.map +1 -1
- package/lib/logic/getTransactionStatus.d.ts +2 -3
- package/lib/logic/getTransactionStatus.d.ts.map +1 -1
- package/lib/logic/getTransactionStatus.js +24 -34
- package/lib/logic/getTransactionStatus.js.map +1 -1
- package/lib/logic/getTransactionStatus.test.js +27 -108
- package/lib/logic/getTransactionStatus.test.js.map +1 -1
- package/lib/logic/listOperations.js +4 -4
- package/lib/logic/listOperations.js.map +1 -1
- package/lib/logic/listOperations.test.js +5 -5
- package/lib/logic/listOperations.test.js.map +1 -1
- package/lib/test/bridgeDatasetTest.js +4 -4
- package/lib/test/bridgeDatasetTest.js.map +1 -1
- package/lib/test/cli.js +1 -1
- package/lib/test/cli.js.map +1 -1
- package/lib/transaction.d.ts +2 -2
- package/lib/transaction.d.ts.map +1 -1
- package/lib/transaction.js +5 -5
- package/lib/transaction.js.map +1 -1
- package/lib/types/bridge.d.ts +2 -2
- package/lib/types/bridge.d.ts.map +1 -1
- package/lib-es/api/index.d.ts.map +1 -1
- package/lib-es/api/index.js +6 -19
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/api/index.test.js +1 -1
- package/lib-es/api/index.test.js.map +1 -1
- package/lib-es/logic/craftTransaction.d.ts +1 -1
- package/lib-es/logic/craftTransaction.d.ts.map +1 -1
- package/lib-es/logic/craftTransaction.js +1 -1
- package/lib-es/logic/craftTransaction.js.map +1 -1
- package/lib-es/logic/craftTransaction.test.js +2 -2
- package/lib-es/logic/craftTransaction.test.js.map +1 -1
- package/lib-es/logic/estimateFees.d.ts +1 -1
- package/lib-es/logic/estimateFees.d.ts.map +1 -1
- package/lib-es/logic/estimateFees.js +1 -1
- package/lib-es/logic/estimateFees.js.map +1 -1
- package/lib-es/logic/estimateFees.test.js +2 -2
- package/lib-es/logic/estimateFees.test.js.map +1 -1
- package/lib-es/logic/getTransactionStatus.d.ts +2 -3
- package/lib-es/logic/getTransactionStatus.d.ts.map +1 -1
- package/lib-es/logic/getTransactionStatus.js +24 -34
- package/lib-es/logic/getTransactionStatus.js.map +1 -1
- package/lib-es/logic/getTransactionStatus.test.js +27 -108
- package/lib-es/logic/getTransactionStatus.test.js.map +1 -1
- package/lib-es/logic/listOperations.js +4 -4
- package/lib-es/logic/listOperations.js.map +1 -1
- package/lib-es/logic/listOperations.test.js +5 -5
- package/lib-es/logic/listOperations.test.js.map +1 -1
- package/lib-es/test/bridgeDatasetTest.js +4 -4
- package/lib-es/test/bridgeDatasetTest.js.map +1 -1
- package/lib-es/test/cli.js +1 -1
- package/lib-es/test/cli.js.map +1 -1
- package/lib-es/transaction.d.ts +2 -2
- package/lib-es/transaction.d.ts.map +1 -1
- package/lib-es/transaction.js +5 -5
- package/lib-es/transaction.js.map +1 -1
- package/lib-es/types/bridge.d.ts +2 -2
- package/lib-es/types/bridge.d.ts.map +1 -1
- package/package.json +7 -7
- package/src/api/index.test.ts +1 -1
- package/src/api/index.ts +9 -20
- package/src/logic/craftTransaction.test.ts +2 -2
- package/src/logic/craftTransaction.ts +2 -2
- package/src/logic/estimateFees.test.ts +2 -2
- package/src/logic/estimateFees.ts +2 -2
- package/src/logic/getTransactionStatus.test.ts +28 -94
- package/src/logic/getTransactionStatus.ts +26 -37
- package/src/logic/listOperations.test.ts +5 -5
- package/src/logic/listOperations.ts +4 -4
- package/src/test/bridgeDatasetTest.ts +4 -4
- package/src/test/cli.ts +1 -1
- package/src/transaction.ts +5 -5
- package/src/types/bridge.ts +2 -2
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import { getTransactionStatus } from "./getTransactionStatus";
|
|
2
2
|
import * as utils from "./utils";
|
|
3
3
|
|
|
4
|
-
const mockGetBalance = jest.fn();
|
|
5
|
-
|
|
6
4
|
const mockGetServerInfos = jest.fn();
|
|
7
5
|
|
|
8
|
-
jest.mock("./getBalance", () => ({
|
|
9
|
-
getBalance: () => mockGetBalance(),
|
|
10
|
-
}));
|
|
11
|
-
|
|
12
6
|
jest.mock("../network", () => ({
|
|
13
7
|
getServerInfos: () => mockGetServerInfos(),
|
|
14
8
|
}));
|
|
@@ -26,9 +20,21 @@ const SENDER = "rPSCfmnX3t9jQJG5RNcZtSaP5UhExZDue4";
|
|
|
26
20
|
const RECIPIENT = "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe";
|
|
27
21
|
const RECIPIENT_NEW = "rDKsbvy9uaNpPtvVFraJyNGfjvTw8xivgK";
|
|
28
22
|
|
|
23
|
+
const account = {
|
|
24
|
+
address: SENDER,
|
|
25
|
+
balance: 50_000_000n,
|
|
26
|
+
currencyUnit: {
|
|
27
|
+
code: "XRP",
|
|
28
|
+
magnitude: 6,
|
|
29
|
+
name: "XRP",
|
|
30
|
+
symbol: "XRP",
|
|
31
|
+
},
|
|
32
|
+
currencyName: "XRP",
|
|
33
|
+
};
|
|
34
|
+
|
|
29
35
|
describe("getTransactionStatus", () => {
|
|
30
36
|
afterEach(() => {
|
|
31
|
-
|
|
37
|
+
mockGetServerInfos.mockReset();
|
|
32
38
|
});
|
|
33
39
|
|
|
34
40
|
it("returns no errors on valid transaction", async () => {
|
|
@@ -39,22 +45,13 @@ describe("getTransactionStatus", () => {
|
|
|
39
45
|
},
|
|
40
46
|
},
|
|
41
47
|
});
|
|
42
|
-
mockGetBalance.mockResolvedValue([
|
|
43
|
-
{
|
|
44
|
-
value: 50_000_000n,
|
|
45
|
-
asset: { type: "native" },
|
|
46
|
-
locked: 0n,
|
|
47
|
-
},
|
|
48
|
-
]);
|
|
49
48
|
|
|
50
49
|
const result = await getTransactionStatus(
|
|
51
|
-
|
|
50
|
+
account as any,
|
|
52
51
|
{
|
|
53
|
-
sender: SENDER,
|
|
54
52
|
amount: 20_000_000n,
|
|
55
|
-
|
|
53
|
+
fee: 10_000n,
|
|
56
54
|
recipient: RECIPIENT,
|
|
57
|
-
asset: { unit: { code: "XRP", magnitude: 6 } },
|
|
58
55
|
} as any,
|
|
59
56
|
);
|
|
60
57
|
|
|
@@ -71,22 +68,13 @@ describe("getTransactionStatus", () => {
|
|
|
71
68
|
},
|
|
72
69
|
},
|
|
73
70
|
});
|
|
74
|
-
mockGetBalance.mockResolvedValue([
|
|
75
|
-
{
|
|
76
|
-
value: 50_000_000n,
|
|
77
|
-
asset: { type: "native" },
|
|
78
|
-
locked: 0n,
|
|
79
|
-
},
|
|
80
|
-
]);
|
|
81
71
|
|
|
82
72
|
const result = await getTransactionStatus(
|
|
83
|
-
|
|
73
|
+
account as any,
|
|
84
74
|
{
|
|
85
|
-
sender: SENDER,
|
|
86
75
|
amount: 1_000_000n,
|
|
87
|
-
|
|
76
|
+
fee: 200_000n, // 20%
|
|
88
77
|
recipient: RECIPIENT,
|
|
89
|
-
asset: { unit: { code: "XRP", magnitude: 6 } },
|
|
90
78
|
} as any,
|
|
91
79
|
);
|
|
92
80
|
|
|
@@ -102,21 +90,12 @@ describe("getTransactionStatus", () => {
|
|
|
102
90
|
},
|
|
103
91
|
},
|
|
104
92
|
});
|
|
105
|
-
mockGetBalance.mockResolvedValue([
|
|
106
|
-
{
|
|
107
|
-
value: 30_000_000n,
|
|
108
|
-
asset: { type: "native" },
|
|
109
|
-
locked: 0n,
|
|
110
|
-
},
|
|
111
|
-
]);
|
|
112
93
|
|
|
113
94
|
const result = await getTransactionStatus(
|
|
114
|
-
|
|
95
|
+
account as any,
|
|
115
96
|
{
|
|
116
|
-
sender: SENDER,
|
|
117
97
|
amount: 10_000_000n,
|
|
118
98
|
recipient: RECIPIENT,
|
|
119
|
-
asset: { unit: { code: "XRP", magnitude: 6 } },
|
|
120
99
|
} as any,
|
|
121
100
|
);
|
|
122
101
|
|
|
@@ -131,22 +110,13 @@ describe("getTransactionStatus", () => {
|
|
|
131
110
|
},
|
|
132
111
|
},
|
|
133
112
|
});
|
|
134
|
-
mockGetBalance.mockResolvedValue([
|
|
135
|
-
{
|
|
136
|
-
value: 50_000_000n,
|
|
137
|
-
asset: { type: "native" },
|
|
138
|
-
locked: 0n,
|
|
139
|
-
},
|
|
140
|
-
]);
|
|
141
113
|
|
|
142
114
|
const result = await getTransactionStatus(
|
|
143
|
-
|
|
115
|
+
account as any,
|
|
144
116
|
{
|
|
145
|
-
sender: SENDER,
|
|
146
117
|
amount: 10_000_000n,
|
|
147
|
-
|
|
118
|
+
fee: 10_000n,
|
|
148
119
|
recipient: SENDER,
|
|
149
|
-
asset: { unit: { code: "XRP", magnitude: 6 } },
|
|
150
120
|
} as any,
|
|
151
121
|
);
|
|
152
122
|
|
|
@@ -161,22 +131,13 @@ describe("getTransactionStatus", () => {
|
|
|
161
131
|
},
|
|
162
132
|
},
|
|
163
133
|
});
|
|
164
|
-
mockGetBalance.mockResolvedValue([
|
|
165
|
-
{
|
|
166
|
-
value: 50_000_000n,
|
|
167
|
-
asset: { type: "native" },
|
|
168
|
-
locked: 0n,
|
|
169
|
-
},
|
|
170
|
-
]);
|
|
171
134
|
|
|
172
135
|
const result = await getTransactionStatus(
|
|
173
|
-
|
|
136
|
+
account as any,
|
|
174
137
|
{
|
|
175
|
-
sender: SENDER,
|
|
176
138
|
amount: 5_000_000n,
|
|
177
|
-
|
|
139
|
+
fee: 10_000n,
|
|
178
140
|
recipient: RECIPIENT_NEW,
|
|
179
|
-
asset: { unit: { code: "XRP", magnitude: 6 } },
|
|
180
141
|
} as any,
|
|
181
142
|
);
|
|
182
143
|
|
|
@@ -191,22 +152,13 @@ describe("getTransactionStatus", () => {
|
|
|
191
152
|
},
|
|
192
153
|
},
|
|
193
154
|
});
|
|
194
|
-
mockGetBalance.mockResolvedValue([
|
|
195
|
-
{
|
|
196
|
-
value: 50_000_000n,
|
|
197
|
-
asset: { type: "native" },
|
|
198
|
-
locked: 0n,
|
|
199
|
-
},
|
|
200
|
-
]);
|
|
201
155
|
|
|
202
156
|
const result = await getTransactionStatus(
|
|
203
|
-
|
|
157
|
+
account as any,
|
|
204
158
|
{
|
|
205
|
-
sender: SENDER,
|
|
206
159
|
amount: 0n,
|
|
207
|
-
|
|
160
|
+
fee: 10_000n,
|
|
208
161
|
recipient: RECIPIENT,
|
|
209
|
-
asset: { unit: { code: "XRP", magnitude: 6 } },
|
|
210
162
|
} as any,
|
|
211
163
|
);
|
|
212
164
|
|
|
@@ -221,21 +173,12 @@ describe("getTransactionStatus", () => {
|
|
|
221
173
|
},
|
|
222
174
|
},
|
|
223
175
|
});
|
|
224
|
-
mockGetBalance.mockResolvedValue([
|
|
225
|
-
{
|
|
226
|
-
value: 50_000_000n,
|
|
227
|
-
asset: { type: "native" },
|
|
228
|
-
locked: 0n,
|
|
229
|
-
},
|
|
230
|
-
]);
|
|
231
176
|
|
|
232
177
|
const result = await getTransactionStatus(
|
|
233
|
-
|
|
178
|
+
account as any,
|
|
234
179
|
{
|
|
235
|
-
sender: SENDER,
|
|
236
|
-
asset: { unit: { code: "XRP", magnitude: 6 } },
|
|
237
180
|
amount: 1_000_000n,
|
|
238
|
-
|
|
181
|
+
fee: 10_000n,
|
|
239
182
|
recipient: "not-an-address",
|
|
240
183
|
} as any,
|
|
241
184
|
);
|
|
@@ -251,21 +194,12 @@ describe("getTransactionStatus", () => {
|
|
|
251
194
|
},
|
|
252
195
|
},
|
|
253
196
|
});
|
|
254
|
-
mockGetBalance.mockResolvedValue([
|
|
255
|
-
{
|
|
256
|
-
value: 50_000_000n,
|
|
257
|
-
asset: { type: "native" },
|
|
258
|
-
locked: 0n,
|
|
259
|
-
},
|
|
260
|
-
]);
|
|
261
197
|
|
|
262
198
|
const result = await getTransactionStatus(
|
|
263
|
-
|
|
199
|
+
account as any,
|
|
264
200
|
{
|
|
265
|
-
sender: SENDER,
|
|
266
|
-
asset: { unit: { code: "XRP", magnitude: 6 } },
|
|
267
201
|
amount: 1_000_000n,
|
|
268
|
-
|
|
202
|
+
fee: 10_000n,
|
|
269
203
|
recipient: "",
|
|
270
204
|
} as any,
|
|
271
205
|
);
|
|
@@ -14,12 +14,11 @@ import { formatCurrencyUnit } from "@ledgerhq/coin-framework/currencies/index";
|
|
|
14
14
|
import { getServerInfos } from "../network";
|
|
15
15
|
import { cachedRecipientIsNew } from "./utils";
|
|
16
16
|
import { parseAPIValue } from "./common";
|
|
17
|
-
import { TransactionValidation,
|
|
18
|
-
import { XrpMapMemo } from "../types";
|
|
19
|
-
import { getBalance } from "./getBalance";
|
|
17
|
+
import { Transaction, TransactionValidation, Account } from "@ledgerhq/coin-framework/api/types";
|
|
20
18
|
|
|
21
19
|
export const getTransactionStatus = async (
|
|
22
|
-
|
|
20
|
+
account: Account,
|
|
21
|
+
transaction: Transaction,
|
|
23
22
|
): Promise<TransactionValidation> => {
|
|
24
23
|
const errors: Record<string, Error> = {};
|
|
25
24
|
const warnings: Record<string, Error> = {};
|
|
@@ -27,57 +26,47 @@ export const getTransactionStatus = async (
|
|
|
27
26
|
const reserveBaseXRP = parseAPIValue(
|
|
28
27
|
serverInfos.info.validated_ledger.reserve_base_xrp.toString(),
|
|
29
28
|
);
|
|
30
|
-
const estimatedFees =
|
|
31
|
-
const totalSpent =
|
|
32
|
-
const amount =
|
|
29
|
+
const estimatedFees = transaction.fee || 0n;
|
|
30
|
+
const totalSpent = transaction.amount + estimatedFees;
|
|
31
|
+
const amount = transaction.amount;
|
|
33
32
|
|
|
34
33
|
if (amount > 0 && estimatedFees * 10n > amount) {
|
|
35
34
|
warnings.feeTooHigh = new FeeTooHigh();
|
|
36
35
|
}
|
|
37
36
|
|
|
38
|
-
|
|
39
|
-
const nativeBalance = balances.find(b => b.asset.type === "native");
|
|
40
|
-
if (nativeBalance === undefined) {
|
|
41
|
-
throw Error("Shouldn't happen");
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (!transactionIntent.fees) {
|
|
37
|
+
if (!transaction.fee) {
|
|
45
38
|
errors.fee = new FeeNotLoaded();
|
|
46
|
-
} else if (
|
|
39
|
+
} else if (transaction.fee == 0n) {
|
|
47
40
|
errors.fee = new FeeRequired();
|
|
48
|
-
} else if (totalSpent >
|
|
41
|
+
} else if (totalSpent > account.balance - BigInt(reserveBaseXRP.toString())) {
|
|
49
42
|
errors.amount = new NotEnoughSpendableBalance("", {
|
|
50
|
-
minimumAmount:
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
})
|
|
56
|
-
: "Unknown unit",
|
|
43
|
+
minimumAmount: formatCurrencyUnit(account.currencyUnit, reserveBaseXRP, {
|
|
44
|
+
disableRounding: true,
|
|
45
|
+
useGrouping: false,
|
|
46
|
+
showCode: true,
|
|
47
|
+
}),
|
|
57
48
|
});
|
|
58
49
|
} else if (
|
|
59
|
-
|
|
60
|
-
(await cachedRecipientIsNew(
|
|
61
|
-
|
|
50
|
+
transaction.recipient &&
|
|
51
|
+
(await cachedRecipientIsNew(transaction.recipient)) &&
|
|
52
|
+
transaction.amount < BigInt(reserveBaseXRP.toString())
|
|
62
53
|
) {
|
|
63
54
|
errors.amount = new NotEnoughBalanceBecauseDestinationNotCreated("", {
|
|
64
|
-
minimalAmount:
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
})
|
|
70
|
-
: "Unknown unit",
|
|
55
|
+
minimalAmount: formatCurrencyUnit(account.currencyUnit, reserveBaseXRP, {
|
|
56
|
+
disableRounding: true,
|
|
57
|
+
useGrouping: false,
|
|
58
|
+
showCode: true,
|
|
59
|
+
}),
|
|
71
60
|
});
|
|
72
61
|
}
|
|
73
62
|
|
|
74
|
-
if (!
|
|
63
|
+
if (!transaction.recipient) {
|
|
75
64
|
errors.recipient = new RecipientRequired("");
|
|
76
|
-
} else if (
|
|
65
|
+
} else if (account.address === transaction.recipient) {
|
|
77
66
|
errors.recipient = new InvalidAddressBecauseDestinationIsAlsoSource();
|
|
78
|
-
} else if (!isValidClassicAddress(
|
|
67
|
+
} else if (!isValidClassicAddress(transaction.recipient)) {
|
|
79
68
|
errors.recipient = new InvalidAddress("", {
|
|
80
|
-
currencyName:
|
|
69
|
+
currencyName: account.currencyName,
|
|
81
70
|
});
|
|
82
71
|
}
|
|
83
72
|
|
|
@@ -146,7 +146,7 @@ describe("listOperations", () => {
|
|
|
146
146
|
async ({ address, opSender, opDestination, expectedType }) => {
|
|
147
147
|
// Given
|
|
148
148
|
const deliveredAmount = 100;
|
|
149
|
-
const
|
|
149
|
+
const fee = 10;
|
|
150
150
|
mockNetworkGetTransactions.mockResolvedValue(
|
|
151
151
|
mockNetworkTxs([
|
|
152
152
|
{
|
|
@@ -156,7 +156,7 @@ describe("listOperations", () => {
|
|
|
156
156
|
meta: { delivered_amount: deliveredAmount.toString() },
|
|
157
157
|
tx_json: {
|
|
158
158
|
TransactionType: "Payment",
|
|
159
|
-
Fee:
|
|
159
|
+
Fee: fee.toString(),
|
|
160
160
|
ledger_index: 1,
|
|
161
161
|
date: 1000,
|
|
162
162
|
Account: opSender,
|
|
@@ -172,7 +172,7 @@ describe("listOperations", () => {
|
|
|
172
172
|
meta: { delivered_amount: deliveredAmount.toString() },
|
|
173
173
|
tx_json: {
|
|
174
174
|
TransactionType: "Payment",
|
|
175
|
-
Fee:
|
|
175
|
+
Fee: fee.toString(),
|
|
176
176
|
ledger_index: 1,
|
|
177
177
|
date: 1000,
|
|
178
178
|
Account: opSender,
|
|
@@ -189,7 +189,7 @@ describe("listOperations", () => {
|
|
|
189
189
|
meta: { delivered_amount: deliveredAmount.toString() },
|
|
190
190
|
tx_json: {
|
|
191
191
|
TransactionType: "Payment",
|
|
192
|
-
Fee:
|
|
192
|
+
Fee: fee.toString(),
|
|
193
193
|
ledger_index: 1,
|
|
194
194
|
date: 1000,
|
|
195
195
|
Account: opSender,
|
|
@@ -217,7 +217,7 @@ describe("listOperations", () => {
|
|
|
217
217
|
expect(mockNetworkGetTransactions).toHaveBeenCalledTimes(1);
|
|
218
218
|
// if expectedType is "OUT", compute value with fees (i.e. delivered_amount + Fee)
|
|
219
219
|
const expectedValue =
|
|
220
|
-
expectedType === "IN" ? BigInt(deliveredAmount) : BigInt(deliveredAmount +
|
|
220
|
+
expectedType === "IN" ? BigInt(deliveredAmount) : BigInt(deliveredAmount + fee);
|
|
221
221
|
expect(results).toEqual([
|
|
222
222
|
{
|
|
223
223
|
id: "HASH_VALUE",
|
|
@@ -125,10 +125,10 @@ const convertToCoreOperation =
|
|
|
125
125
|
? BigInt(delivered_amount)
|
|
126
126
|
: BigInt(0);
|
|
127
127
|
|
|
128
|
-
const
|
|
128
|
+
const fee = BigInt(Fee);
|
|
129
129
|
if (type === "OUT") {
|
|
130
|
-
if (!Number.isNaN(
|
|
131
|
-
value = value +
|
|
130
|
+
if (!Number.isNaN(fee)) {
|
|
131
|
+
value = value + fee;
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
|
|
@@ -170,7 +170,7 @@ const convertToCoreOperation =
|
|
|
170
170
|
asset: { type: "native" },
|
|
171
171
|
tx: {
|
|
172
172
|
hash: hash,
|
|
173
|
-
fees:
|
|
173
|
+
fees: fee,
|
|
174
174
|
date: new Date(toEpochDate),
|
|
175
175
|
block: {
|
|
176
176
|
time: new Date(close_time_iso),
|
|
@@ -40,7 +40,7 @@ export const dataset: DatasetTest<Transaction> = {
|
|
|
40
40
|
recipient: "rB6pwovsyrFWhPYUsjj9V3CHck985QjiXi",
|
|
41
41
|
amount: "15000000",
|
|
42
42
|
tag: null,
|
|
43
|
-
|
|
43
|
+
fee: "1",
|
|
44
44
|
feeCustomUnit: null,
|
|
45
45
|
networkInfo: null,
|
|
46
46
|
}),
|
|
@@ -75,7 +75,7 @@ export const dataset: DatasetTest<Transaction> = {
|
|
|
75
75
|
recipient: newAddress1,
|
|
76
76
|
amount: "10000000",
|
|
77
77
|
tag: null,
|
|
78
|
-
|
|
78
|
+
fee: "1",
|
|
79
79
|
feeCustomUnit: null,
|
|
80
80
|
networkInfo: null
|
|
81
81
|
}),
|
|
@@ -97,7 +97,7 @@ export const dataset: DatasetTest<Transaction> = {
|
|
|
97
97
|
recipient: "rageXHB6Q4VbvvWdTzKANwjeCT4HXFCKX7",
|
|
98
98
|
amount: "10000000",
|
|
99
99
|
tag: null,
|
|
100
|
-
|
|
100
|
+
fee: "10", // NOTE: fee is not customizable, this field is ignored
|
|
101
101
|
feeCustomUnit: null,
|
|
102
102
|
networkInfo: null,
|
|
103
103
|
}),
|
|
@@ -118,7 +118,7 @@ export const dataset: DatasetTest<Transaction> = {
|
|
|
118
118
|
recipient: "rB6pwovsyrFWhPYUsjj9V3CHck985QjiXi",
|
|
119
119
|
amount: "10000000",
|
|
120
120
|
tag: 12345,
|
|
121
|
-
|
|
121
|
+
fee: "10", // NOTE: fee is not customizable, this field is ignored
|
|
122
122
|
feeCustomUnit: null,
|
|
123
123
|
networkInfo: null,
|
|
124
124
|
}),
|
package/src/test/cli.ts
CHANGED
package/src/transaction.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { getAccountCurrency } from "@ledgerhq/coin-framework/account/index";
|
|
|
12
12
|
import { formatCurrencyUnit } from "@ledgerhq/coin-framework/currencies/index";
|
|
13
13
|
|
|
14
14
|
export const formatTransaction = (
|
|
15
|
-
{ amount, recipient,
|
|
15
|
+
{ amount, recipient, fee, tag, useAllAmount }: Transaction,
|
|
16
16
|
account: Account,
|
|
17
17
|
): string => `
|
|
18
18
|
SEND ${
|
|
@@ -25,9 +25,9 @@ SEND ${
|
|
|
25
25
|
}
|
|
26
26
|
TO ${recipient}
|
|
27
27
|
with fee=${
|
|
28
|
-
!
|
|
28
|
+
!fee
|
|
29
29
|
? "?"
|
|
30
|
-
: formatCurrencyUnit(getAccountCurrency(account).units[0],
|
|
30
|
+
: formatCurrencyUnit(getAccountCurrency(account).units[0], fee, {
|
|
31
31
|
showCode: true,
|
|
32
32
|
disableRounding: true,
|
|
33
33
|
})
|
|
@@ -40,7 +40,7 @@ export const fromTransactionRaw = (tr: TransactionRaw): Transaction => {
|
|
|
40
40
|
...common,
|
|
41
41
|
family: tr.family,
|
|
42
42
|
tag: tr.tag,
|
|
43
|
-
|
|
43
|
+
fee: tr.fee ? new BigNumber(tr.fee) : null,
|
|
44
44
|
feeCustomUnit: tr.feeCustomUnit,
|
|
45
45
|
// FIXME remove this field. this is not good.. we're dereferencing here. we should instead store an index (to lookup in currency.units on UI)
|
|
46
46
|
networkInfo: networkInfo && {
|
|
@@ -58,7 +58,7 @@ export const toTransactionRaw = (t: Transaction): TransactionRaw => {
|
|
|
58
58
|
...common,
|
|
59
59
|
family: t.family,
|
|
60
60
|
tag: t.tag,
|
|
61
|
-
|
|
61
|
+
fee: t.fee ? t.fee.toString() : null,
|
|
62
62
|
feeCustomUnit: t.feeCustomUnit,
|
|
63
63
|
// FIXME remove this field. this is not good.. we're dereferencing here. we should instead store an index (to lookup in currency.units on UI)
|
|
64
64
|
networkInfo: networkInfo && {
|
package/src/types/bridge.ts
CHANGED
|
@@ -21,7 +21,7 @@ export type NetworkInfoRaw = {
|
|
|
21
21
|
|
|
22
22
|
export type Transaction = TransactionCommon & {
|
|
23
23
|
family: "xrp";
|
|
24
|
-
|
|
24
|
+
fee: BigNumber | null | undefined;
|
|
25
25
|
networkInfo: NetworkInfo | null | undefined;
|
|
26
26
|
tag: number | null | undefined;
|
|
27
27
|
feeCustomUnit: Unit | null | undefined;
|
|
@@ -29,7 +29,7 @@ export type Transaction = TransactionCommon & {
|
|
|
29
29
|
|
|
30
30
|
export type TransactionRaw = TransactionCommonRaw & {
|
|
31
31
|
family: "xrp";
|
|
32
|
-
|
|
32
|
+
fee: string | null | undefined;
|
|
33
33
|
networkInfo: NetworkInfoRaw | null | undefined;
|
|
34
34
|
tag: number | null | undefined;
|
|
35
35
|
feeCustomUnit: Unit | null | undefined;
|