@ledgerhq/coin-xrp 6.2.2 → 6.3.0-nightly.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/CHANGELOG.md +20 -0
- package/lib/api/index.d.ts +2 -11
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.integ.test.js +20 -5
- package/lib/api/index.integ.test.js.map +1 -1
- package/lib/api/index.js +16 -5
- package/lib/api/index.js.map +1 -1
- package/lib/api/index.test.js +18 -9
- package/lib/api/index.test.js.map +1 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +0 -3
- package/lib/index.js.map +1 -1
- package/lib/logic/getAccountInfo.d.ts +3 -0
- package/lib/logic/getAccountInfo.d.ts.map +1 -0
- package/lib/logic/getAccountInfo.js +9 -0
- package/lib/logic/getAccountInfo.js.map +1 -0
- package/lib/logic/getBalance.d.ts.map +1 -1
- package/lib/logic/getBalance.js +13 -1
- package/lib/logic/getBalance.js.map +1 -1
- package/lib/logic/getBalance.test.js +14 -1
- package/lib/logic/getBalance.test.js.map +1 -1
- package/lib/logic/getTransactionStatus.d.ts +3 -0
- package/lib/logic/getTransactionStatus.d.ts.map +1 -0
- package/lib/{bridge → logic}/getTransactionStatus.js +15 -19
- package/lib/logic/getTransactionStatus.js.map +1 -0
- package/lib/logic/getTransactionStatus.test.d.ts +2 -0
- package/lib/logic/getTransactionStatus.test.d.ts.map +1 -0
- package/lib/logic/getTransactionStatus.test.js +184 -0
- package/lib/logic/getTransactionStatus.test.js.map +1 -0
- package/lib/logic/index.d.ts +3 -1
- package/lib/logic/index.d.ts.map +1 -1
- package/lib/logic/index.js +5 -2
- package/lib/logic/index.js.map +1 -1
- package/lib/logic/utils.d.ts +0 -1
- package/lib/logic/utils.d.ts.map +1 -1
- package/lib/logic/utils.js +14 -10
- package/lib/logic/utils.js.map +1 -1
- package/lib/test/bridgeDatasetTest.js +7 -7
- package/lib/test/bridgeDatasetTest.js.map +1 -1
- package/lib/{bridge/transaction.d.ts → transaction.d.ts} +1 -1
- package/lib/transaction.d.ts.map +1 -0
- package/lib/transaction.js.map +1 -0
- package/lib/types/model.d.ts +7 -0
- package/lib/types/model.d.ts.map +1 -1
- package/lib-es/api/index.d.ts +2 -11
- package/lib-es/api/index.d.ts.map +1 -1
- package/lib-es/api/index.integ.test.js +20 -5
- package/lib-es/api/index.integ.test.js.map +1 -1
- package/lib-es/api/index.js +17 -6
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/api/index.test.js +18 -9
- package/lib-es/api/index.test.js.map +1 -1
- package/lib-es/index.d.ts +0 -1
- package/lib-es/index.d.ts.map +1 -1
- package/lib-es/index.js +0 -1
- package/lib-es/index.js.map +1 -1
- package/lib-es/logic/getAccountInfo.d.ts +3 -0
- package/lib-es/logic/getAccountInfo.d.ts.map +1 -0
- package/lib-es/logic/getAccountInfo.js +6 -0
- package/lib-es/logic/getAccountInfo.js.map +1 -0
- package/lib-es/logic/getBalance.d.ts.map +1 -1
- package/lib-es/logic/getBalance.js +14 -2
- package/lib-es/logic/getBalance.js.map +1 -1
- package/lib-es/logic/getBalance.test.js +14 -1
- package/lib-es/logic/getBalance.test.js.map +1 -1
- package/lib-es/logic/getTransactionStatus.d.ts +3 -0
- package/lib-es/logic/getTransactionStatus.d.ts.map +1 -0
- package/lib-es/{bridge → logic}/getTransactionStatus.js +13 -14
- package/lib-es/logic/getTransactionStatus.js.map +1 -0
- package/lib-es/logic/getTransactionStatus.test.d.ts +2 -0
- package/lib-es/logic/getTransactionStatus.test.d.ts.map +1 -0
- package/lib-es/logic/getTransactionStatus.test.js +159 -0
- package/lib-es/logic/getTransactionStatus.test.js.map +1 -0
- package/lib-es/logic/index.d.ts +3 -1
- package/lib-es/logic/index.d.ts.map +1 -1
- package/lib-es/logic/index.js +3 -1
- package/lib-es/logic/index.js.map +1 -1
- package/lib-es/logic/utils.d.ts +0 -1
- package/lib-es/logic/utils.d.ts.map +1 -1
- package/lib-es/logic/utils.js +13 -8
- package/lib-es/logic/utils.js.map +1 -1
- package/lib-es/test/bridgeDatasetTest.js +7 -7
- package/lib-es/test/bridgeDatasetTest.js.map +1 -1
- package/lib-es/{bridge/transaction.d.ts → transaction.d.ts} +1 -1
- package/lib-es/transaction.d.ts.map +1 -0
- package/lib-es/transaction.js.map +1 -0
- package/lib-es/types/model.d.ts +7 -0
- package/lib-es/types/model.d.ts.map +1 -1
- package/package.json +7 -8
- package/src/api/index.integ.test.ts +20 -6
- package/src/api/index.test.ts +23 -22
- package/src/api/index.ts +30 -19
- package/src/index.ts +0 -1
- package/src/logic/getAccountInfo.ts +7 -0
- package/src/logic/getBalance.test.ts +14 -1
- package/src/logic/getBalance.ts +18 -2
- package/src/logic/getTransactionStatus.test.ts +215 -0
- package/src/{bridge → logic}/getTransactionStatus.ts +18 -21
- package/src/logic/index.ts +3 -6
- package/src/logic/utils.ts +24 -8
- package/src/test/bridgeDatasetTest.ts +7 -7
- package/src/{bridge/transaction.ts → transaction.ts} +1 -1
- package/src/types/model.ts +11 -0
- package/lib/bridge/broadcast.d.ts +0 -4
- package/lib/bridge/broadcast.d.ts.map +0 -1
- package/lib/bridge/broadcast.js +0 -11
- package/lib/bridge/broadcast.js.map +0 -1
- package/lib/bridge/createTransaction.d.ts +0 -4
- package/lib/bridge/createTransaction.d.ts.map +0 -1
- package/lib/bridge/createTransaction.js +0 -18
- package/lib/bridge/createTransaction.js.map +0 -1
- package/lib/bridge/estimateMaxSpendable.d.ts +0 -4
- package/lib/bridge/estimateMaxSpendable.d.ts.map +0 -1
- package/lib/bridge/estimateMaxSpendable.js +0 -26
- package/lib/bridge/estimateMaxSpendable.js.map +0 -1
- package/lib/bridge/getTransactionStatus.d.ts +0 -4
- package/lib/bridge/getTransactionStatus.d.ts.map +0 -1
- package/lib/bridge/getTransactionStatus.js.map +0 -1
- package/lib/bridge/index.d.ts +0 -11
- package/lib/bridge/index.d.ts.map +0 -1
- package/lib/bridge/index.js +0 -47
- package/lib/bridge/index.js.map +0 -1
- package/lib/bridge/prepareTransaction.d.ts +0 -4
- package/lib/bridge/prepareTransaction.d.ts.map +0 -1
- package/lib/bridge/prepareTransaction.js +0 -14
- package/lib/bridge/prepareTransaction.js.map +0 -1
- package/lib/bridge/signOperation.d.ts +0 -5
- package/lib/bridge/signOperation.d.ts.map +0 -1
- package/lib/bridge/signOperation.js +0 -76
- package/lib/bridge/signOperation.js.map +0 -1
- package/lib/bridge/synchronization.d.ts +0 -3
- package/lib/bridge/synchronization.d.ts.map +0 -1
- package/lib/bridge/synchronization.js +0 -85
- package/lib/bridge/synchronization.js.map +0 -1
- package/lib/bridge/synchronization.test.d.ts +0 -2
- package/lib/bridge/synchronization.test.d.ts.map +0 -1
- package/lib/bridge/synchronization.test.js +0 -140
- package/lib/bridge/synchronization.test.js.map +0 -1
- package/lib/bridge/transaction.d.ts.map +0 -1
- package/lib/bridge/transaction.js.map +0 -1
- package/lib-es/bridge/broadcast.d.ts +0 -4
- package/lib-es/bridge/broadcast.d.ts.map +0 -1
- package/lib-es/bridge/broadcast.js +0 -7
- package/lib-es/bridge/broadcast.js.map +0 -1
- package/lib-es/bridge/createTransaction.d.ts +0 -4
- package/lib-es/bridge/createTransaction.d.ts.map +0 -1
- package/lib-es/bridge/createTransaction.js +0 -11
- package/lib-es/bridge/createTransaction.js.map +0 -1
- package/lib-es/bridge/estimateMaxSpendable.d.ts +0 -4
- package/lib-es/bridge/estimateMaxSpendable.d.ts.map +0 -1
- package/lib-es/bridge/estimateMaxSpendable.js +0 -19
- package/lib-es/bridge/estimateMaxSpendable.js.map +0 -1
- package/lib-es/bridge/getTransactionStatus.d.ts +0 -4
- package/lib-es/bridge/getTransactionStatus.d.ts.map +0 -1
- package/lib-es/bridge/getTransactionStatus.js.map +0 -1
- package/lib-es/bridge/index.d.ts +0 -11
- package/lib-es/bridge/index.d.ts.map +0 -1
- package/lib-es/bridge/index.js +0 -41
- package/lib-es/bridge/index.js.map +0 -1
- package/lib-es/bridge/prepareTransaction.d.ts +0 -4
- package/lib-es/bridge/prepareTransaction.d.ts.map +0 -1
- package/lib-es/bridge/prepareTransaction.js +0 -10
- package/lib-es/bridge/prepareTransaction.js.map +0 -1
- package/lib-es/bridge/signOperation.d.ts +0 -5
- package/lib-es/bridge/signOperation.d.ts.map +0 -1
- package/lib-es/bridge/signOperation.js +0 -72
- package/lib-es/bridge/signOperation.js.map +0 -1
- package/lib-es/bridge/synchronization.d.ts +0 -3
- package/lib-es/bridge/synchronization.d.ts.map +0 -1
- package/lib-es/bridge/synchronization.js +0 -78
- package/lib-es/bridge/synchronization.js.map +0 -1
- package/lib-es/bridge/synchronization.test.d.ts +0 -2
- package/lib-es/bridge/synchronization.test.d.ts.map +0 -1
- package/lib-es/bridge/synchronization.test.js +0 -135
- package/lib-es/bridge/synchronization.test.js.map +0 -1
- package/lib-es/bridge/transaction.d.ts.map +0 -1
- package/lib-es/bridge/transaction.js.map +0 -1
- package/src/bridge/broadcast.ts +0 -11
- package/src/bridge/createTransaction.ts +0 -13
- package/src/bridge/estimateMaxSpendable.ts +0 -25
- package/src/bridge/index.ts +0 -59
- package/src/bridge/prepareTransaction.ts +0 -18
- package/src/bridge/signOperation.ts +0 -100
- package/src/bridge/synchronization.test.ts +0 -153
- package/src/bridge/synchronization.ts +0 -108
- /package/lib/{bridge/transaction.js → transaction.js} +0 -0
- /package/lib-es/{bridge/transaction.js → transaction.js} +0 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { getTransactionStatus } from "./getTransactionStatus";
|
|
2
|
+
import * as logic from "./index";
|
|
3
|
+
|
|
4
|
+
const mockGetServerInfos = jest.fn();
|
|
5
|
+
const mockCachedRecipientIsNew = jest.fn();
|
|
6
|
+
|
|
7
|
+
jest.mock("../network", () => ({
|
|
8
|
+
getServerInfos: () => mockGetServerInfos(),
|
|
9
|
+
}));
|
|
10
|
+
|
|
11
|
+
jest.spyOn(logic, "cachedRecipientIsNew").mockImplementation(addr => {
|
|
12
|
+
if (addr === RECIPIENT_NEW) {
|
|
13
|
+
return Promise.resolve(true);
|
|
14
|
+
}
|
|
15
|
+
return Promise.resolve(false);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const reserveBase = 10_000_000n; // 10 XRP (drops)
|
|
19
|
+
|
|
20
|
+
const SENDER = "rPSCfmnX3t9jQJG5RNcZtSaP5UhExZDue4";
|
|
21
|
+
const RECIPIENT = "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe";
|
|
22
|
+
const RECIPIENT_NEW = "rDKsbvy9uaNpPtvVFraJyNGfjvTw8xivgK";
|
|
23
|
+
|
|
24
|
+
const account = {
|
|
25
|
+
address: SENDER,
|
|
26
|
+
balance: 50_000_000n,
|
|
27
|
+
currencyUnit: {
|
|
28
|
+
code: "XRP",
|
|
29
|
+
magnitude: 6,
|
|
30
|
+
name: "XRP",
|
|
31
|
+
symbol: "XRP",
|
|
32
|
+
},
|
|
33
|
+
currencyName: "XRP",
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
describe("getTransactionStatus", () => {
|
|
37
|
+
afterEach(() => {
|
|
38
|
+
mockGetServerInfos.mockReset();
|
|
39
|
+
mockCachedRecipientIsNew.mockReset();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("returns no errors on valid transaction", async () => {
|
|
43
|
+
mockGetServerInfos.mockResolvedValue({
|
|
44
|
+
info: {
|
|
45
|
+
validated_ledger: {
|
|
46
|
+
reserve_base_xrp: reserveBase / 1_000_000n, // XRP value, not drops
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
mockCachedRecipientIsNew.mockResolvedValue(false);
|
|
52
|
+
|
|
53
|
+
const result = await getTransactionStatus(
|
|
54
|
+
account as any,
|
|
55
|
+
{
|
|
56
|
+
amount: 20_000_000n,
|
|
57
|
+
fee: 10_000n,
|
|
58
|
+
recipient: RECIPIENT,
|
|
59
|
+
} as any,
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
expect(result.errors).toEqual({});
|
|
63
|
+
expect(result.warnings).toEqual({});
|
|
64
|
+
expect(result.totalSpent).toBe(20_010_000n);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("throws FeeTooHigh warning when fee is >10% of amount", async () => {
|
|
68
|
+
mockGetServerInfos.mockResolvedValue({
|
|
69
|
+
info: {
|
|
70
|
+
validated_ledger: {
|
|
71
|
+
reserve_base_xrp: reserveBase / 1_000_000n,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const result = await getTransactionStatus(
|
|
77
|
+
account as any,
|
|
78
|
+
{
|
|
79
|
+
amount: 1_000_000n,
|
|
80
|
+
fee: 200_000n, // 20%
|
|
81
|
+
recipient: RECIPIENT,
|
|
82
|
+
} as any,
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
expect(result.warnings.feeTooHigh).toBeInstanceOf(Error);
|
|
86
|
+
expect(result.errors).toEqual({});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("errors when fee is missing", async () => {
|
|
90
|
+
mockGetServerInfos.mockResolvedValue({
|
|
91
|
+
info: {
|
|
92
|
+
validated_ledger: {
|
|
93
|
+
reserve_base_xrp: reserveBase / 1_000_000n,
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
const result = await getTransactionStatus(
|
|
99
|
+
account as any,
|
|
100
|
+
{
|
|
101
|
+
amount: 10_000_000n,
|
|
102
|
+
recipient: RECIPIENT,
|
|
103
|
+
} as any,
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
expect(result.errors.fee?.name).toBe("FeeNotLoaded");
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it("errors if recipient is same as sender", async () => {
|
|
110
|
+
mockGetServerInfos.mockResolvedValue({
|
|
111
|
+
info: {
|
|
112
|
+
validated_ledger: {
|
|
113
|
+
reserve_base_xrp: reserveBase / 1_000_000n,
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
const result = await getTransactionStatus(
|
|
119
|
+
account as any,
|
|
120
|
+
{
|
|
121
|
+
amount: 10_000_000n,
|
|
122
|
+
fee: 10_000n,
|
|
123
|
+
recipient: SENDER,
|
|
124
|
+
} as any,
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
expect(result.errors.recipient?.name).toBe("InvalidAddressBecauseDestinationIsAlsoSource");
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it("errors if recipient is new and amount is too low", async () => {
|
|
131
|
+
mockGetServerInfos.mockResolvedValue({
|
|
132
|
+
info: {
|
|
133
|
+
validated_ledger: {
|
|
134
|
+
reserve_base_xrp: reserveBase / 1_000_000n,
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
mockCachedRecipientIsNew.mockResolvedValue(true);
|
|
140
|
+
|
|
141
|
+
const result = await getTransactionStatus(
|
|
142
|
+
account as any,
|
|
143
|
+
{
|
|
144
|
+
amount: 5_000_000n,
|
|
145
|
+
fee: 10_000n,
|
|
146
|
+
recipient: RECIPIENT_NEW,
|
|
147
|
+
} as any,
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
expect(result.errors.amount?.name).toBe("NotEnoughBalanceBecauseDestinationNotCreated");
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it("errors if amount is zero", async () => {
|
|
154
|
+
mockGetServerInfos.mockResolvedValue({
|
|
155
|
+
info: {
|
|
156
|
+
validated_ledger: {
|
|
157
|
+
reserve_base_xrp: reserveBase / 1_000_000n,
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
const result = await getTransactionStatus(
|
|
163
|
+
account as any,
|
|
164
|
+
{
|
|
165
|
+
amount: 0n,
|
|
166
|
+
fee: 10_000n,
|
|
167
|
+
recipient: RECIPIENT,
|
|
168
|
+
} as any,
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
expect(result.errors.amount?.name).toBe("AmountRequired");
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it("errors if recipient is invalid", async () => {
|
|
175
|
+
mockGetServerInfos.mockResolvedValue({
|
|
176
|
+
info: {
|
|
177
|
+
validated_ledger: {
|
|
178
|
+
reserve_base_xrp: reserveBase / 1_000_000n,
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
const result = await getTransactionStatus(
|
|
184
|
+
account as any,
|
|
185
|
+
{
|
|
186
|
+
amount: 1_000_000n,
|
|
187
|
+
fee: 10_000n,
|
|
188
|
+
recipient: "not-an-address",
|
|
189
|
+
} as any,
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
expect(result.errors.recipient?.name).toBe("InvalidAddress");
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
it("errors if recipient is missing", async () => {
|
|
196
|
+
mockGetServerInfos.mockResolvedValue({
|
|
197
|
+
info: {
|
|
198
|
+
validated_ledger: {
|
|
199
|
+
reserve_base_xrp: reserveBase / 1_000_000n,
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
const result = await getTransactionStatus(
|
|
205
|
+
account as any,
|
|
206
|
+
{
|
|
207
|
+
amount: 1_000_000n,
|
|
208
|
+
fee: 10_000n,
|
|
209
|
+
recipient: "",
|
|
210
|
+
} as any,
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
expect(result.errors.recipient?.name).toBe("RecipientRequired");
|
|
214
|
+
});
|
|
215
|
+
});
|
|
@@ -9,40 +9,37 @@ import {
|
|
|
9
9
|
NotEnoughSpendableBalance,
|
|
10
10
|
RecipientRequired,
|
|
11
11
|
} from "@ledgerhq/errors";
|
|
12
|
-
import BigNumber from "bignumber.js";
|
|
13
12
|
import { isValidClassicAddress } from "ripple-address-codec";
|
|
14
|
-
import { Account, AccountBridge } from "@ledgerhq/types-live";
|
|
15
13
|
import { formatCurrencyUnit } from "@ledgerhq/coin-framework/currencies/index";
|
|
16
14
|
import { getServerInfos } from "../network";
|
|
17
|
-
import { cachedRecipientIsNew, parseAPIValue } from "
|
|
18
|
-
import { Transaction,
|
|
15
|
+
import { cachedRecipientIsNew, parseAPIValue } from ".";
|
|
16
|
+
import { Transaction, TransactionValidation, Account } from "@ledgerhq/coin-framework/api/types";
|
|
19
17
|
|
|
20
|
-
export const getTransactionStatus
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
>["getTransactionStatus"] = async (account, transaction) => {
|
|
18
|
+
export const getTransactionStatus = async (
|
|
19
|
+
account: Account,
|
|
20
|
+
transaction: Transaction,
|
|
21
|
+
): Promise<TransactionValidation> => {
|
|
25
22
|
const errors: Record<string, Error> = {};
|
|
26
23
|
const warnings: Record<string, Error> = {};
|
|
27
24
|
const serverInfos = await getServerInfos();
|
|
28
25
|
const reserveBaseXRP = parseAPIValue(
|
|
29
26
|
serverInfos.info.validated_ledger.reserve_base_xrp.toString(),
|
|
30
27
|
);
|
|
31
|
-
const estimatedFees =
|
|
32
|
-
const totalSpent =
|
|
33
|
-
const amount =
|
|
28
|
+
const estimatedFees = transaction.fee || 0n;
|
|
29
|
+
const totalSpent = transaction.amount + estimatedFees;
|
|
30
|
+
const amount = transaction.amount;
|
|
34
31
|
|
|
35
|
-
if (amount
|
|
32
|
+
if (amount > 0 && estimatedFees * 10n > amount) {
|
|
36
33
|
warnings.feeTooHigh = new FeeTooHigh();
|
|
37
34
|
}
|
|
38
35
|
|
|
39
36
|
if (!transaction.fee) {
|
|
40
37
|
errors.fee = new FeeNotLoaded();
|
|
41
|
-
} else if (transaction.fee
|
|
38
|
+
} else if (transaction.fee == 0n) {
|
|
42
39
|
errors.fee = new FeeRequired();
|
|
43
|
-
} else if (totalSpent
|
|
40
|
+
} else if (totalSpent > account.balance - BigInt(reserveBaseXRP.toString())) {
|
|
44
41
|
errors.amount = new NotEnoughSpendableBalance("", {
|
|
45
|
-
minimumAmount: formatCurrencyUnit(account.
|
|
42
|
+
minimumAmount: formatCurrencyUnit(account.currencyUnit, reserveBaseXRP, {
|
|
46
43
|
disableRounding: true,
|
|
47
44
|
useGrouping: false,
|
|
48
45
|
showCode: true,
|
|
@@ -51,10 +48,10 @@ export const getTransactionStatus: AccountBridge<
|
|
|
51
48
|
} else if (
|
|
52
49
|
transaction.recipient &&
|
|
53
50
|
(await cachedRecipientIsNew(transaction.recipient)) &&
|
|
54
|
-
transaction.amount.
|
|
51
|
+
transaction.amount < BigInt(reserveBaseXRP.toString())
|
|
55
52
|
) {
|
|
56
53
|
errors.amount = new NotEnoughBalanceBecauseDestinationNotCreated("", {
|
|
57
|
-
minimalAmount: formatCurrencyUnit(account.
|
|
54
|
+
minimalAmount: formatCurrencyUnit(account.currencyUnit, reserveBaseXRP, {
|
|
58
55
|
disableRounding: true,
|
|
59
56
|
useGrouping: false,
|
|
60
57
|
showCode: true,
|
|
@@ -64,15 +61,15 @@ export const getTransactionStatus: AccountBridge<
|
|
|
64
61
|
|
|
65
62
|
if (!transaction.recipient) {
|
|
66
63
|
errors.recipient = new RecipientRequired("");
|
|
67
|
-
} else if (account.
|
|
64
|
+
} else if (account.address === transaction.recipient) {
|
|
68
65
|
errors.recipient = new InvalidAddressBecauseDestinationIsAlsoSource();
|
|
69
66
|
} else if (!isValidClassicAddress(transaction.recipient)) {
|
|
70
67
|
errors.recipient = new InvalidAddress("", {
|
|
71
|
-
currencyName: account.
|
|
68
|
+
currencyName: account.currencyName,
|
|
72
69
|
});
|
|
73
70
|
}
|
|
74
71
|
|
|
75
|
-
if (!errors.amount && amount
|
|
72
|
+
if (!errors.amount && amount == 0n) {
|
|
76
73
|
errors.amount = new AmountRequired();
|
|
77
74
|
}
|
|
78
75
|
|
package/src/logic/index.ts
CHANGED
|
@@ -4,13 +4,10 @@ export { craftTransaction } from "./craftTransaction";
|
|
|
4
4
|
export type { MemoInput } from "./craftTransaction";
|
|
5
5
|
export { estimateFees } from "./estimateFees";
|
|
6
6
|
export { getBalance } from "./getBalance";
|
|
7
|
+
export { getAccountInfo } from "./getAccountInfo";
|
|
7
8
|
export { lastBlock } from "./lastBlock";
|
|
8
9
|
export { listOperations } from "./listOperations";
|
|
9
|
-
export {
|
|
10
|
-
|
|
11
|
-
cachedRecipientIsNew,
|
|
12
|
-
getNextValidSequence,
|
|
13
|
-
removeCachedRecipientIsNew,
|
|
14
|
-
} from "./utils";
|
|
10
|
+
export { getTransactionStatus } from "./getTransactionStatus";
|
|
11
|
+
export { RIPPLE_EPOCH, cachedRecipientIsNew, getNextValidSequence } from "./utils";
|
|
15
12
|
|
|
16
13
|
export { parseAPIValue } from "./common";
|
package/src/logic/utils.ts
CHANGED
|
@@ -22,6 +22,15 @@ function isRecipientValid(recipient: string): boolean {
|
|
|
22
22
|
return isValidClassicAddress(recipient);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
// --- 10-Seconds Cache Implementation ---
|
|
26
|
+
type CacheEntry = {
|
|
27
|
+
value: boolean;
|
|
28
|
+
expiresAt: number;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const recipientCache = new Map<string, CacheEntry>();
|
|
32
|
+
const TTL = 10 * 1000; // 10 seconds
|
|
33
|
+
|
|
25
34
|
const recipientIsNew = async (recipient: string): Promise<boolean> => {
|
|
26
35
|
if (!isRecipientValid(recipient)) return false;
|
|
27
36
|
|
|
@@ -29,12 +38,19 @@ const recipientIsNew = async (recipient: string): Promise<boolean> => {
|
|
|
29
38
|
return info.isNewAccount;
|
|
30
39
|
};
|
|
31
40
|
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
export const cachedRecipientIsNew = async (recipient: string): Promise<boolean> => {
|
|
42
|
+
const now = Date.now();
|
|
43
|
+
const cached = recipientCache.get(recipient);
|
|
44
|
+
|
|
45
|
+
if (cached && now < cached.expiresAt) {
|
|
46
|
+
return cached.value;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const isNew = await recipientIsNew(recipient);
|
|
50
|
+
recipientCache.set(recipient, {
|
|
51
|
+
value: isNew,
|
|
52
|
+
expiresAt: now + TTL,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
return isNew;
|
|
40
56
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import BigNumber from "bignumber.js";
|
|
2
2
|
import { DatasetTest } from "@ledgerhq/types-live";
|
|
3
3
|
import { InvalidAddressBecauseDestinationIsAlsoSource } from "@ledgerhq/errors";
|
|
4
|
-
import { fromTransactionRaw } from "../
|
|
4
|
+
import { fromTransactionRaw } from "../transaction";
|
|
5
5
|
import { Transaction } from "../types";
|
|
6
6
|
|
|
7
7
|
export const newAddress1 = "rZvBc5e2YR1A9otS3r9DyGh3NDP8XLLp4";
|
|
@@ -97,18 +97,18 @@ export const dataset: DatasetTest<Transaction> = {
|
|
|
97
97
|
recipient: "rageXHB6Q4VbvvWdTzKANwjeCT4HXFCKX7",
|
|
98
98
|
amount: "10000000",
|
|
99
99
|
tag: null,
|
|
100
|
-
fee: "
|
|
100
|
+
fee: "10", // NOTE: fee is not customizable, this field is ignored
|
|
101
101
|
feeCustomUnit: null,
|
|
102
102
|
networkInfo: null,
|
|
103
103
|
}),
|
|
104
104
|
expectedStatus: {
|
|
105
105
|
amount: new BigNumber("10000000"),
|
|
106
|
-
estimatedFees: new BigNumber("
|
|
106
|
+
estimatedFees: new BigNumber("10"),
|
|
107
107
|
errors: {
|
|
108
108
|
recipient: new InvalidAddressBecauseDestinationIsAlsoSource(),
|
|
109
109
|
},
|
|
110
110
|
warnings: {},
|
|
111
|
-
totalSpent: new BigNumber("
|
|
111
|
+
totalSpent: new BigNumber("10000010"),
|
|
112
112
|
},
|
|
113
113
|
},
|
|
114
114
|
{
|
|
@@ -118,16 +118,16 @@ export const dataset: DatasetTest<Transaction> = {
|
|
|
118
118
|
recipient: "rB6pwovsyrFWhPYUsjj9V3CHck985QjiXi",
|
|
119
119
|
amount: "10000000",
|
|
120
120
|
tag: 12345,
|
|
121
|
-
fee: "
|
|
121
|
+
fee: "10", // NOTE: fee is not customizable, this field is ignored
|
|
122
122
|
feeCustomUnit: null,
|
|
123
123
|
networkInfo: null,
|
|
124
124
|
}),
|
|
125
125
|
expectedStatus: {
|
|
126
126
|
amount: new BigNumber("10000000"),
|
|
127
|
-
estimatedFees: new BigNumber("
|
|
127
|
+
estimatedFees: new BigNumber("10"),
|
|
128
128
|
errors: {},
|
|
129
129
|
warnings: {},
|
|
130
|
-
totalSpent: new BigNumber("
|
|
130
|
+
totalSpent: new BigNumber("10000010"),
|
|
131
131
|
},
|
|
132
132
|
},
|
|
133
133
|
],
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BigNumber } from "bignumber.js";
|
|
2
|
-
import type { Transaction, TransactionRaw } from "
|
|
2
|
+
import type { Transaction, TransactionRaw } from "./types";
|
|
3
3
|
import { formatTransactionStatus } from "@ledgerhq/coin-framework/formatters";
|
|
4
4
|
import {
|
|
5
5
|
fromTransactionCommonRaw,
|
package/src/types/model.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { TypedMapMemo } from "@ledgerhq/coin-framework/api/types";
|
|
2
|
+
|
|
1
3
|
export type AccountInfo = {
|
|
2
4
|
isNewAccount: boolean;
|
|
3
5
|
balance: string;
|
|
@@ -11,7 +13,16 @@ export type XrpMemo = {
|
|
|
11
13
|
type?: string;
|
|
12
14
|
};
|
|
13
15
|
|
|
16
|
+
export type XrpMemoKind = "destinationTag" | "memo";
|
|
17
|
+
|
|
18
|
+
export type XrpMemoValueMap = {
|
|
19
|
+
destinationTag: string;
|
|
20
|
+
memos: string[];
|
|
21
|
+
};
|
|
22
|
+
export type XrpMapMemo = TypedMapMemo<XrpMemoValueMap>;
|
|
23
|
+
|
|
14
24
|
type Order = "asc" | "desc";
|
|
25
|
+
|
|
15
26
|
export type ListOperationsOptions = {
|
|
16
27
|
// pagination:
|
|
17
28
|
limit?: number;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"broadcast.d.ts","sourceRoot":"","sources":["../../src/bridge/broadcast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,eAAO,MAAM,SAAS,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC,WAAW,CAK7D,CAAC"}
|
package/lib/bridge/broadcast.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.broadcast = void 0;
|
|
4
|
-
const operation_1 = require("@ledgerhq/coin-framework/operation");
|
|
5
|
-
const logic_1 = require("../logic");
|
|
6
|
-
const broadcast = async ({ signedOperation: { signature, operation }, }) => {
|
|
7
|
-
const hash = await (0, logic_1.broadcast)(signature);
|
|
8
|
-
return (0, operation_1.patchOperationWithHash)(operation, hash);
|
|
9
|
-
};
|
|
10
|
-
exports.broadcast = broadcast;
|
|
11
|
-
//# sourceMappingURL=broadcast.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"broadcast.js","sourceRoot":"","sources":["../../src/bridge/broadcast.ts"],"names":[],"mappings":";;;AACA,kEAA4E;AAC5E,oCAAuD;AAGhD,MAAM,SAAS,GAA4C,KAAK,EAAE,EACvE,eAAe,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,GAC1C,EAAE,EAAE;IACH,MAAM,IAAI,GAAG,MAAM,IAAA,iBAAc,EAAC,SAAS,CAAC,CAAC;IAC7C,OAAO,IAAA,kCAAsB,EAAC,SAAS,EAAE,IAAI,CAAC,CAAC;AACjD,CAAC,CAAC;AALW,QAAA,SAAS,aAKpB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createTransaction.d.ts","sourceRoot":"","sources":["../../src/bridge/createTransaction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,eAAO,MAAM,iBAAiB,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC,mBAAmB,CAQ5E,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createTransaction = void 0;
|
|
7
|
-
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
8
|
-
const createTransaction = () => ({
|
|
9
|
-
family: "xrp",
|
|
10
|
-
amount: new bignumber_js_1.default(0),
|
|
11
|
-
recipient: "",
|
|
12
|
-
fee: null,
|
|
13
|
-
tag: undefined,
|
|
14
|
-
networkInfo: null,
|
|
15
|
-
feeCustomUnit: null,
|
|
16
|
-
});
|
|
17
|
-
exports.createTransaction = createTransaction;
|
|
18
|
-
//# sourceMappingURL=createTransaction.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createTransaction.js","sourceRoot":"","sources":["../../src/bridge/createTransaction.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAqC;AAI9B,MAAM,iBAAiB,GAAoD,GAAG,EAAE,CAAC,CAAC;IACvF,MAAM,EAAE,KAAK;IACb,MAAM,EAAE,IAAI,sBAAS,CAAC,CAAC,CAAC;IACxB,SAAS,EAAE,EAAE;IACb,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,SAAS;IACd,WAAW,EAAE,IAAI;IACjB,aAAa,EAAE,IAAI;CACpB,CAAC,CAAC;AARU,QAAA,iBAAiB,qBAQ3B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"estimateMaxSpendable.d.ts","sourceRoot":"","sources":["../../src/bridge/estimateMaxSpendable.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAMrD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,eAAO,MAAM,oBAAoB,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC,sBAAsB,CAenF,CAAC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.estimateMaxSpendable = void 0;
|
|
7
|
-
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
8
|
-
const index_1 = require("@ledgerhq/coin-framework/account/index");
|
|
9
|
-
const abandonseed_1 = require("@ledgerhq/cryptoassets/abandonseed");
|
|
10
|
-
const getTransactionStatus_1 = require("./getTransactionStatus");
|
|
11
|
-
const prepareTransaction_1 = require("./prepareTransaction");
|
|
12
|
-
const createTransaction_1 = require("./createTransaction");
|
|
13
|
-
const estimateMaxSpendable = async ({ account, parentAccount, transaction, }) => {
|
|
14
|
-
const mainAccount = (0, index_1.getMainAccount)(account, parentAccount);
|
|
15
|
-
const newTransaction = await (0, prepareTransaction_1.prepareTransaction)(mainAccount, {
|
|
16
|
-
...(0, createTransaction_1.createTransaction)(account),
|
|
17
|
-
...transaction,
|
|
18
|
-
recipient: transaction?.recipient || (0, abandonseed_1.getAbandonSeedAddress)("ripple"),
|
|
19
|
-
// public testing seed abandonx11,about
|
|
20
|
-
amount: new bignumber_js_1.default(0),
|
|
21
|
-
});
|
|
22
|
-
const status = await (0, getTransactionStatus_1.getTransactionStatus)(mainAccount, newTransaction);
|
|
23
|
-
return bignumber_js_1.default.max(0, account.spendableBalance.minus(status.estimatedFees));
|
|
24
|
-
};
|
|
25
|
-
exports.estimateMaxSpendable = estimateMaxSpendable;
|
|
26
|
-
//# sourceMappingURL=estimateMaxSpendable.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"estimateMaxSpendable.js","sourceRoot":"","sources":["../../src/bridge/estimateMaxSpendable.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAqC;AAErC,kEAAwE;AACxE,oEAA2E;AAC3E,iEAA8D;AAC9D,6DAA0D;AAC1D,2DAAwD;AAGjD,MAAM,oBAAoB,GAAuD,KAAK,EAAE,EAC7F,OAAO,EACP,aAAa,EACb,WAAW,GACZ,EAAE,EAAE;IACH,MAAM,WAAW,GAAG,IAAA,sBAAc,EAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IAC3D,MAAM,cAAc,GAAG,MAAM,IAAA,uCAAkB,EAAC,WAAW,EAAE;QAC3D,GAAG,IAAA,qCAAiB,EAAC,OAAO,CAAC;QAC7B,GAAG,WAAW;QACd,SAAS,EAAE,WAAW,EAAE,SAAS,IAAI,IAAA,mCAAqB,EAAC,QAAQ,CAAC;QACpE,uCAAuC;QACvC,MAAM,EAAE,IAAI,sBAAS,CAAC,CAAC,CAAC;KACzB,CAAC,CAAC;IACH,MAAM,MAAM,GAAG,MAAM,IAAA,2CAAoB,EAAC,WAAW,EAAE,cAAc,CAAC,CAAC;IACvE,OAAO,sBAAS,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC;AAChF,CAAC,CAAC;AAfW,QAAA,oBAAoB,wBAe/B"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { Account, AccountBridge } from "@ledgerhq/types-live";
|
|
2
|
-
import { Transaction, TransactionStatus } from "../types";
|
|
3
|
-
export declare const getTransactionStatus: AccountBridge<Transaction, Account, TransactionStatus>["getTransactionStatus"];
|
|
4
|
-
//# sourceMappingURL=getTransactionStatus.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getTransactionStatus.d.ts","sourceRoot":"","sources":["../../src/bridge/getTransactionStatus.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAI9D,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE1D,eAAO,MAAM,oBAAoB,EAAE,aAAa,CAC9C,WAAW,EACX,OAAO,EACP,iBAAiB,CAClB,CAAC,sBAAsB,CA8DvB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getTransactionStatus.js","sourceRoot":"","sources":["../../src/bridge/getTransactionStatus.ts"],"names":[],"mappings":";;;;;;AAAA,6CAU0B;AAC1B,gEAAqC;AACrC,+DAA6D;AAE7D,qEAA+E;AAC/E,wCAA4C;AAC5C,oCAA+D;AAGxD,MAAM,oBAAoB,GAIL,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE;IACzD,MAAM,MAAM,GAA0B,EAAE,CAAC;IACzC,MAAM,QAAQ,GAA0B,EAAE,CAAC;IAC3C,MAAM,WAAW,GAAG,MAAM,IAAA,wBAAc,GAAE,CAAC;IAC3C,MAAM,cAAc,GAAG,IAAA,qBAAa,EAClC,WAAW,CAAC,IAAI,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAC9D,CAAC;IACF,MAAM,aAAa,GAAG,IAAI,sBAAS,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IAC1D,MAAM,UAAU,GAAG,IAAI,sBAAS,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACzE,MAAM,MAAM,GAAG,IAAI,sBAAS,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAEjD,IAAI,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC;QACvD,QAAQ,CAAC,UAAU,GAAG,IAAI,mBAAU,EAAE,CAAC;IACzC,CAAC;IAED,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC;QACrB,MAAM,CAAC,GAAG,GAAG,IAAI,qBAAY,EAAE,CAAC;IAClC,CAAC;SAAM,IAAI,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACjC,MAAM,CAAC,GAAG,GAAG,IAAI,oBAAW,EAAE,CAAC;IACjC,CAAC;SAAM,IAAI,UAAU,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC;QAChE,MAAM,CAAC,MAAM,GAAG,IAAI,kCAAyB,CAAC,EAAE,EAAE;YAChD,aAAa,EAAE,IAAA,0BAAkB,EAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE;gBAC3E,eAAe,EAAE,IAAI;gBACrB,WAAW,EAAE,KAAK;gBAClB,QAAQ,EAAE,IAAI;aACf,CAAC;SACH,CAAC,CAAC;IACL,CAAC;SAAM,IACL,WAAW,CAAC,SAAS;QACrB,CAAC,MAAM,IAAA,4BAAoB,EAAC,WAAW,CAAC,SAAS,CAAC,CAAC;QACnD,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,cAAc,CAAC,EACrC,CAAC;QACD,MAAM,CAAC,MAAM,GAAG,IAAI,qDAA4C,CAAC,EAAE,EAAE;YACnE,aAAa,EAAE,IAAA,0BAAkB,EAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE;gBAC3E,eAAe,EAAE,IAAI;gBACrB,WAAW,EAAE,KAAK;gBAClB,QAAQ,EAAE,IAAI;aACf,CAAC;SACH,CAAC,CAAC;IACL,CAAC;IAED,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,CAAC;QAC3B,MAAM,CAAC,SAAS,GAAG,IAAI,0BAAiB,CAAC,EAAE,CAAC,CAAC;IAC/C,CAAC;SAAM,IAAI,OAAO,CAAC,YAAY,KAAK,WAAW,CAAC,SAAS,EAAE,CAAC;QAC1D,MAAM,CAAC,SAAS,GAAG,IAAI,qDAA4C,EAAE,CAAC;IACxE,CAAC;SAAM,IAAI,CAAC,IAAA,4CAAqB,EAAC,WAAW,CAAC,SAAS,CAAC,EAAE,CAAC;QACzD,MAAM,CAAC,SAAS,GAAG,IAAI,uBAAc,CAAC,EAAE,EAAE;YACxC,YAAY,EAAE,OAAO,CAAC,QAAQ,CAAC,IAAI;SACpC,CAAC,CAAC;IACL,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACnC,MAAM,CAAC,MAAM,GAAG,IAAI,uBAAc,EAAE,CAAC;IACvC,CAAC;IAED,OAAO;QACL,MAAM;QACN,QAAQ;QACR,aAAa;QACb,MAAM;QACN,UAAU;KACX,CAAC;AACJ,CAAC,CAAC;AAlEW,QAAA,oBAAoB,wBAkE/B"}
|
package/lib/bridge/index.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { CoinConfig } from "@ledgerhq/coin-framework/config";
|
|
2
|
-
import { SignerContext } from "@ledgerhq/coin-framework/signer";
|
|
3
|
-
import type { AccountBridge, CurrencyBridge } from "@ledgerhq/types-live";
|
|
4
|
-
import { type XrpCoinConfig } from "../config";
|
|
5
|
-
import { XrpSigner } from "../types";
|
|
6
|
-
import type { Transaction } from "../types";
|
|
7
|
-
export declare function createBridges(signerContext: SignerContext<XrpSigner>, coinConfig: CoinConfig<XrpCoinConfig>): {
|
|
8
|
-
currencyBridge: CurrencyBridge;
|
|
9
|
-
accountBridge: AccountBridge<Transaction>;
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bridge/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAsB,EAAE,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAE9D,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAS5C,wBAAgB,aAAa,CAC3B,aAAa,EAAE,aAAa,CAAC,SAAS,CAAC,EACvC,UAAU,EAAE,UAAU,CAAC,aAAa,CAAC;;;EAiCtC"}
|
package/lib/bridge/index.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createBridges = createBridges;
|
|
7
|
-
const getAddressWrapper_1 = __importDefault(require("@ledgerhq/coin-framework/bridge/getAddressWrapper"));
|
|
8
|
-
const jsHelpers_1 = require("@ledgerhq/coin-framework/bridge/jsHelpers");
|
|
9
|
-
const config_1 = __importDefault(require("../config"));
|
|
10
|
-
const signer_1 = __importDefault(require("../signer"));
|
|
11
|
-
const broadcast_1 = require("./broadcast");
|
|
12
|
-
const createTransaction_1 = require("./createTransaction");
|
|
13
|
-
const estimateMaxSpendable_1 = require("./estimateMaxSpendable");
|
|
14
|
-
const getTransactionStatus_1 = require("./getTransactionStatus");
|
|
15
|
-
const prepareTransaction_1 = require("./prepareTransaction");
|
|
16
|
-
const signOperation_1 = require("./signOperation");
|
|
17
|
-
const synchronization_1 = require("./synchronization");
|
|
18
|
-
function createBridges(signerContext, coinConfig) {
|
|
19
|
-
config_1.default.setCoinConfig(coinConfig);
|
|
20
|
-
const getAddress = (0, signer_1.default)(signerContext);
|
|
21
|
-
const scanAccounts = (0, jsHelpers_1.makeScanAccounts)({ getAccountShape: synchronization_1.getAccountShape, getAddressFn: getAddress });
|
|
22
|
-
const currencyBridge = {
|
|
23
|
-
preload: () => Promise.resolve({}),
|
|
24
|
-
hydrate: () => { },
|
|
25
|
-
scanAccounts,
|
|
26
|
-
};
|
|
27
|
-
const receive = (0, jsHelpers_1.makeAccountBridgeReceive)((0, getAddressWrapper_1.default)(getAddress));
|
|
28
|
-
const signOperation = (0, signOperation_1.buildSignOperation)(signerContext);
|
|
29
|
-
const sync = (0, jsHelpers_1.makeSync)({ getAccountShape: synchronization_1.getAccountShape });
|
|
30
|
-
const accountBridge = {
|
|
31
|
-
createTransaction: createTransaction_1.createTransaction,
|
|
32
|
-
updateTransaction: (jsHelpers_1.updateTransaction),
|
|
33
|
-
prepareTransaction: prepareTransaction_1.prepareTransaction,
|
|
34
|
-
getTransactionStatus: getTransactionStatus_1.getTransactionStatus,
|
|
35
|
-
estimateMaxSpendable: estimateMaxSpendable_1.estimateMaxSpendable,
|
|
36
|
-
sync,
|
|
37
|
-
receive,
|
|
38
|
-
signOperation,
|
|
39
|
-
broadcast: broadcast_1.broadcast,
|
|
40
|
-
getSerializedAddressParameters: jsHelpers_1.getSerializedAddressParameters,
|
|
41
|
-
};
|
|
42
|
-
return {
|
|
43
|
-
currencyBridge,
|
|
44
|
-
accountBridge,
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
//# sourceMappingURL=index.js.map
|
package/lib/bridge/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bridge/index.ts"],"names":[],"mappings":";;;;;AAuBA,sCAmCC;AA1DD,0GAAkF;AAClF,yEAMmD;AAInD,uDAA8D;AAC9D,uDAAiC;AAGjC,2CAAwC;AACxC,2DAAwD;AACxD,iEAA8D;AAC9D,iEAA8D;AAC9D,6DAA0D;AAC1D,mDAAqD;AACrD,uDAAoD;AAEpD,SAAgB,aAAa,CAC3B,aAAuC,EACvC,UAAqC;IAErC,gBAAa,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAExC,MAAM,UAAU,GAAG,IAAA,gBAAQ,EAAC,aAAa,CAAC,CAAC;IAE3C,MAAM,YAAY,GAAG,IAAA,4BAAgB,EAAC,EAAE,eAAe,EAAf,iCAAe,EAAE,YAAY,EAAE,UAAU,EAAE,CAAC,CAAC;IACrF,MAAM,cAAc,GAAmB;QACrC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QAClC,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC;QACjB,YAAY;KACb,CAAC;IAEF,MAAM,OAAO,GAAG,IAAA,oCAAwB,EAAC,IAAA,2BAAiB,EAAC,UAAU,CAAC,CAAC,CAAC;IACxE,MAAM,aAAa,GAAG,IAAA,kCAAkB,EAAC,aAAa,CAAC,CAAC;IACxD,MAAM,IAAI,GAAG,IAAA,oBAAQ,EAAC,EAAE,eAAe,EAAf,iCAAe,EAAE,CAAC,CAAC;IAC3C,MAAM,aAAa,GAA+B;QAChD,iBAAiB,EAAjB,qCAAiB;QACjB,iBAAiB,EAAE,CAAA,6BAA8B,CAAA;QACjD,kBAAkB,EAAlB,uCAAkB;QAClB,oBAAoB,EAApB,2CAAoB;QACpB,oBAAoB,EAApB,2CAAoB;QACpB,IAAI;QACJ,OAAO;QACP,aAAa;QACb,SAAS,EAAT,qBAAS;QACT,8BAA8B,EAA9B,0CAA8B;KAC/B,CAAC;IAEF,OAAO;QACL,cAAc;QACd,aAAa;KACd,CAAC;AACJ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prepareTransaction.d.ts","sourceRoot":"","sources":["../../src/bridge/prepareTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAGvC,eAAO,MAAM,kBAAkB,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC,oBAAoB,CAa/E,CAAC"}
|