@ledgerhq/coin-stellar 1.1.2 → 1.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.
- package/CHANGELOG.md +11 -0
- package/lib/api/index.d.ts +2 -1
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.integ.test.js +19 -20
- package/lib/api/index.integ.test.js.map +1 -1
- package/lib/api/index.js +12 -15
- package/lib/api/index.js.map +1 -1
- package/lib/api/index.test.js +10 -10
- package/lib/api/index.test.js.map +1 -1
- package/lib/logic/estimateFees.js +2 -2
- package/lib/logic/estimateFees.js.map +1 -1
- package/lib/logic/listOperations.d.ts +3 -17
- package/lib/logic/listOperations.d.ts.map +1 -1
- package/lib/logic/listOperations.js +13 -12
- package/lib/logic/listOperations.js.map +1 -1
- package/lib/types/assets.d.ts +5 -0
- package/lib/types/assets.d.ts.map +1 -0
- package/lib/types/assets.js +3 -0
- package/lib/types/assets.js.map +1 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js +1 -0
- package/lib/types/index.js.map +1 -1
- package/lib-es/api/index.d.ts +2 -1
- package/lib-es/api/index.d.ts.map +1 -1
- package/lib-es/api/index.integ.test.js +19 -20
- package/lib-es/api/index.integ.test.js.map +1 -1
- package/lib-es/api/index.js +12 -15
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/api/index.test.js +10 -10
- package/lib-es/api/index.test.js.map +1 -1
- package/lib-es/logic/estimateFees.js +2 -2
- package/lib-es/logic/estimateFees.js.map +1 -1
- package/lib-es/logic/listOperations.d.ts +3 -17
- package/lib-es/logic/listOperations.d.ts.map +1 -1
- package/lib-es/logic/listOperations.js +13 -12
- package/lib-es/logic/listOperations.js.map +1 -1
- package/lib-es/types/assets.d.ts +5 -0
- package/lib-es/types/assets.d.ts.map +1 -0
- package/lib-es/types/assets.js +2 -0
- package/lib-es/types/assets.js.map +1 -0
- package/lib-es/types/index.d.ts +1 -0
- package/lib-es/types/index.d.ts.map +1 -1
- package/lib-es/types/index.js +1 -0
- package/lib-es/types/index.js.map +1 -1
- package/package.json +2 -2
- package/src/api/index.integ.test.ts +24 -28
- package/src/api/index.test.ts +10 -10
- package/src/api/index.ts +18 -26
- package/src/logic/estimateFees.ts +2 -2
- package/src/logic/listOperations.ts +16 -30
- package/src/types/assets.ts +4 -0
- package/src/types/index.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @ledgerhq/coin-stellar
|
|
2
2
|
|
|
3
|
+
## 1.2.0-nightly.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#9466](https://github.com/LedgerHQ/ledger-live/pull/9466) [`e2630cb`](https://github.com/LedgerHQ/ledger-live/commit/e2630cbec8d94ae037b2bf85cfa200a277ae739f) Thanks [@qperrot](https://github.com/qperrot)! - Tron craftTransaction alpaca implementation
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`e2630cb`](https://github.com/LedgerHQ/ledger-live/commit/e2630cbec8d94ae037b2bf85cfa200a277ae739f)]:
|
|
12
|
+
- @ledgerhq/coin-framework@2.4.0-nightly.0
|
|
13
|
+
|
|
3
14
|
## 1.1.2
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
package/lib/api/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Api } from "@ledgerhq/coin-framework/api/index";
|
|
2
2
|
import { type StellarConfig } from "../config";
|
|
3
|
-
|
|
3
|
+
import { StellarToken } from "../types";
|
|
4
|
+
export declare function createApi(config: StellarConfig): Api<StellarToken>;
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/api/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,GAAG,EAIJ,MAAM,oCAAoC,CAAC;AAC5C,OAAmB,EAAE,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,GAAG,EAIJ,MAAM,oCAAoC,CAAC;AAC5C,OAAmB,EAAE,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAW3D,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,wBAAgB,SAAS,CAAC,MAAM,EAAE,aAAa,GAAG,GAAG,CAAC,YAAY,CAAC,CAYlE"}
|
|
@@ -19,30 +19,32 @@ describe("Stellar Api", () => {
|
|
|
19
19
|
// Given
|
|
20
20
|
const amount = BigInt(100_000);
|
|
21
21
|
// When
|
|
22
|
-
const result = await module.estimateFees(
|
|
22
|
+
const result = await module.estimateFees({
|
|
23
|
+
type: "send",
|
|
24
|
+
sender: address,
|
|
25
|
+
recipient: "address",
|
|
26
|
+
amount: amount,
|
|
27
|
+
});
|
|
23
28
|
// Then
|
|
24
29
|
expect(result).toEqual(BigInt(100));
|
|
25
30
|
});
|
|
26
31
|
});
|
|
27
|
-
describe
|
|
32
|
+
describe("listOperations", () => {
|
|
33
|
+
let txs;
|
|
34
|
+
beforeAll(async () => {
|
|
35
|
+
[txs] = await module.listOperations(address, { minHeight: 0 });
|
|
36
|
+
}, 20 * 1000); // 20s
|
|
28
37
|
it("returns a list regarding address parameter", async () => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
// Then
|
|
32
|
-
expect(tx.length).toBeGreaterThanOrEqual(100);
|
|
33
|
-
tx.forEach(operation => {
|
|
34
|
-
expect(operation.address).toEqual(address);
|
|
38
|
+
expect(txs.length).toBeGreaterThanOrEqual(100);
|
|
39
|
+
txs.forEach(operation => {
|
|
35
40
|
const isSenderOrReceipt = operation.senders.includes(address) || operation.recipients.includes(address);
|
|
36
41
|
expect(isSenderOrReceipt).toBeTruthy();
|
|
37
42
|
});
|
|
38
43
|
});
|
|
39
44
|
it("returns all operations", async () => {
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
expect(tx.length).toBeGreaterThanOrEqual(100);
|
|
44
|
-
const checkSet = new Set(tx.map(elt => elt.hash));
|
|
45
|
-
expect(checkSet.size).toEqual(tx.length);
|
|
45
|
+
expect(txs.length).toBeGreaterThanOrEqual(100);
|
|
46
|
+
const checkSet = new Set(txs.map(elt => elt.tx.hash));
|
|
47
|
+
expect(checkSet.size).toEqual(txs.length);
|
|
46
48
|
});
|
|
47
49
|
});
|
|
48
50
|
describe("lastBlock", () => {
|
|
@@ -65,16 +67,13 @@ describe("Stellar Api", () => {
|
|
|
65
67
|
});
|
|
66
68
|
describe("craftTransaction", () => {
|
|
67
69
|
it("returns a raw transaction", async () => {
|
|
68
|
-
|
|
69
|
-
const result = await module.craftTransaction(address, {
|
|
70
|
+
const result = await module.craftTransaction({
|
|
70
71
|
type: "send",
|
|
72
|
+
sender: address,
|
|
71
73
|
recipient: "GD6QELUZPSKPRWVXOQ3F6GBF4OBRMCHO5PHREXH4ZRTPJAG7V5MD7JGX",
|
|
72
74
|
amount: BigInt(1_000_000),
|
|
73
|
-
fee: BigInt(100),
|
|
74
75
|
});
|
|
75
|
-
|
|
76
|
-
expect(result.slice(0, 67)).toEqual("AAAAAgAAAAD9Ai6ZfJT42rd0Nl8YJeODFgju688SXPzMZvSA369YPwAAAGQAAHloAAA");
|
|
77
|
-
expect(result.slice(70)).toEqual("AAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAD9Ai6ZfJT42rd0Nl8YJeODFgju688SXPzMZvSA369YPwAAAAAAAAAAAA9CQAAAAAAAAAAA");
|
|
76
|
+
expect(result.length).toEqual(188);
|
|
78
77
|
});
|
|
79
78
|
});
|
|
80
79
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.integ.test.js","sourceRoot":"","sources":["../../src/api/index.integ.test.ts"],"names":[],"mappings":";;AACA,wBAA8B;
|
|
1
|
+
{"version":3,"file":"index.integ.test.js","sourceRoot":"","sources":["../../src/api/index.integ.test.ts"],"names":[],"mappings":";;AACA,wBAA8B;AAG9B;;GAEG;AACH,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,IAAI,MAAyB,CAAC;IAC9B,MAAM,OAAO,GAAG,0DAA0D,CAAC;IAE3E,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,GAAG,IAAA,YAAS,EAAC;YACjB,QAAQ,EAAE;gBACR,GAAG,EAAE,sCAAsC;aAC5C;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;QAC5B,EAAE,CAAC,yBAAyB,EAAE,KAAK,IAAI,EAAE;YACvC,QAAQ;YACR,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;YAE/B,OAAO;YACP,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC;gBACvC,IAAI,EAAE,MAAM;gBACZ,MAAM,EAAE,OAAO;gBACf,SAAS,EAAE,SAAS;gBACpB,MAAM,EAAE,MAAM;aACf,CAAC,CAAC;YAEH,OAAO;YACP,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;QAC9B,IAAI,GAA8B,CAAC;QAEnC,SAAS,CAAC,KAAK,IAAI,EAAE;YACnB,CAAC,GAAG,CAAC,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC;QACjE,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,M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C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;QAC1B,EAAE,CAAC,4CAA4C,EAAE,KAAK,IAAI,EAAE;YAC1D,OAAO;YACP,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;YAEhD,OAAO;YACP,MAAM,CAAC,MAAM,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;QACpC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,EAAE,CAAC,2BAA2B,EAAE,KAAK,IAAI,EAAE;YACzC,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,gBAAgB,CAAC;gBAC3C,IAAI,EAAE,MAAM;gBACZ,MAAM,EAAE,OAAO;gBACf,SAAS,EAAE,0DAA0D;gBACrE,MAAM,EAAE,MAAM,CAAC,SAAS,CAAC;aAC1B,CAAC,CAAC;YAEH,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/lib/api/index.js
CHANGED
|
@@ -12,31 +12,28 @@ function createApi(config) {
|
|
|
12
12
|
broadcast: logic_1.broadcast,
|
|
13
13
|
combine: compose,
|
|
14
14
|
craftTransaction: craft,
|
|
15
|
-
estimateFees: logic_1.estimateFees,
|
|
15
|
+
estimateFees: () => (0, logic_1.estimateFees)(),
|
|
16
16
|
getBalance: logic_1.getBalance,
|
|
17
17
|
lastBlock: logic_1.lastBlock,
|
|
18
18
|
listOperations: operations,
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
exports.createApi = createApi;
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
async function craft(address, transaction) {
|
|
26
|
-
const supplement = isSupplement(transaction.supplement)
|
|
22
|
+
async function craft(transactionIntent) {
|
|
23
|
+
const fees = await (0, logic_1.estimateFees)();
|
|
24
|
+
const supplement = transactionIntent.asset
|
|
27
25
|
? {
|
|
28
|
-
assetCode:
|
|
29
|
-
assetIssuer:
|
|
30
|
-
memoType: transaction.supplement?.memoType,
|
|
31
|
-
memoValue: transaction.supplement?.memoValue,
|
|
26
|
+
assetCode: transactionIntent.asset.assetCode,
|
|
27
|
+
assetIssuer: transactionIntent.asset.assetIssuer,
|
|
32
28
|
}
|
|
33
29
|
: {};
|
|
34
|
-
const tx = await (0, logic_1.craftTransaction)({ address }, {
|
|
35
|
-
|
|
30
|
+
const tx = await (0, logic_1.craftTransaction)({ address: transactionIntent.sender }, {
|
|
31
|
+
type: transactionIntent.type,
|
|
32
|
+
recipient: transactionIntent.recipient,
|
|
33
|
+
amount: transactionIntent.amount,
|
|
34
|
+
fee: fees,
|
|
36
35
|
assetCode: supplement?.assetCode,
|
|
37
36
|
assetIssuer: supplement?.assetIssuer,
|
|
38
|
-
memoType: supplement?.memoType,
|
|
39
|
-
memoValue: supplement?.memoValue,
|
|
40
37
|
});
|
|
41
38
|
return tx.xdr;
|
|
42
39
|
}
|
|
@@ -65,7 +62,7 @@ async function operationsFromHeight(address, minHeight) {
|
|
|
65
62
|
options.cursor = state.apiNextCursor;
|
|
66
63
|
}
|
|
67
64
|
const [operations, nextCursor] = await (0, logic_1.listOperations)(address, options);
|
|
68
|
-
const filteredOperations = operations.filter(op => op.block.height >= state.heightLimit);
|
|
65
|
+
const filteredOperations = operations.filter(op => op.tx.block.height >= state.heightLimit);
|
|
69
66
|
state.accumulator.push(...filteredOperations);
|
|
70
67
|
state.apiNextCursor = nextCursor;
|
|
71
68
|
state.continueIterations = operations.length === filteredOperations.length && nextCursor !== "";
|
package/lib/api/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings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;QACjC,KAAK,CAAC,kBAAkB,GAAG,UAAU,CAAC,MAAM,KAAK,kBAAkB,CAAC,MAAM,IAAI,UAAU,KAAK,EAAE,CAAC;IAClG,CAAC;IAED,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAC7E,CAAC"}
|
package/lib/api/index.test.js
CHANGED
|
@@ -19,20 +19,20 @@ describe("operations", () => {
|
|
|
19
19
|
jest.clearAllMocks();
|
|
20
20
|
});
|
|
21
21
|
const mockOperation = {
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
tx: {
|
|
23
|
+
hash: "e035a56c32003e3b0e4c9c5499b0750d71d98233ae6ae94323ff0a458b05a30b",
|
|
24
|
+
fees: 0.0291,
|
|
25
|
+
block: {
|
|
26
|
+
hash: "hash",
|
|
27
|
+
time: new Date("2024-03-20T10:00:00Z"),
|
|
28
|
+
height: 10,
|
|
29
|
+
},
|
|
30
|
+
date: new Date("2024-03-20T10:00:00Z"),
|
|
31
|
+
},
|
|
24
32
|
type: "Operation",
|
|
25
33
|
value: 200,
|
|
26
|
-
fee: 0.0291,
|
|
27
|
-
block: {
|
|
28
|
-
hash: "hash",
|
|
29
|
-
time: new Date("2024-03-20T10:00:00Z"),
|
|
30
|
-
height: 10,
|
|
31
|
-
},
|
|
32
34
|
senders: ["addr"],
|
|
33
35
|
recipients: ["recipient"],
|
|
34
|
-
date: new Date("2024-03-20T10:00:00Z"),
|
|
35
|
-
transactionSequenceNumber: 2,
|
|
36
36
|
};
|
|
37
37
|
it("should return 0 operations for a valid account", async () => {
|
|
38
38
|
mockGetOperations.mockResolvedValue([[], ""]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../src/api/index.test.ts"],"names":[],"mappings":";;AAAA,mCAAoC;AAEpC,MAAM,iBAAiB,GAAG,IAAI,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AAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wEAAwE,EAAE,KAAK,IAAI,EAAE;QACtF,iBAAiB,CAAC,iBAAiB,CAAC,CAAC,CAAC,aAAa,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QAE3D,OAAO;QACP,MAAM,UAAU,GAAG,MAAM,GAAG,CAAC,cAAc,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC;QAExE,OAAO;QACP,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2CAA2C,EAAE,KAAK,IAAI,EAAE;QACzD,iBAAiB;aACd,qBAAqB,CAAC,CAAC,CAAC,aAAa,CAAC,EAAE,IAAI,CAAC,CAAC;aAC9C,qBAAqB,CAAC,CAAC,CAAC,aAAa,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QAEhD,OAAO;QACP,MAAM,UAAU,GAAG,MAAM,GAAG,CAAC,cAAc,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;QAEjE,OAAO;QACP,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,aAAa,EAAE,aAAa,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QACjE,MAAM,CAAC,iBAAiB,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -7,8 +7,8 @@ const network_1 = require("../network");
|
|
|
7
7
|
* @see {@link https://developers.stellar.org/docs/learn/fundamentals/fees-resource-limits-metering#inclusion-fee}
|
|
8
8
|
*/
|
|
9
9
|
async function estimateFees() {
|
|
10
|
-
const
|
|
11
|
-
return BigInt(
|
|
10
|
+
const baseFee = await (0, network_1.fetchBaseFee)();
|
|
11
|
+
return BigInt(baseFee.recommendedFee);
|
|
12
12
|
}
|
|
13
13
|
exports.estimateFees = estimateFees;
|
|
14
14
|
//# sourceMappingURL=estimateFees.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"estimateFees.js","sourceRoot":"","sources":["../../src/logic/estimateFees.ts"],"names":[],"mappings":";;;AAAA,wCAA0C;AAE1C;;;GAGG;AACI,KAAK,UAAU,YAAY;IAChC,MAAM,
|
|
1
|
+
{"version":3,"file":"estimateFees.js","sourceRoot":"","sources":["../../src/logic/estimateFees.ts"],"names":[],"mappings":";;;AAAA,wCAA0C;AAE1C;;;GAGG;AACI,KAAK,UAAU,YAAY;IAChC,MAAM,OAAO,GAAG,MAAM,IAAA,sBAAY,GAAE,CAAC;IACrC,OAAO,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;AACxC,CAAC;AAHD,oCAGC"}
|
|
@@ -1,23 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
address: string;
|
|
4
|
-
type: string;
|
|
5
|
-
value: bigint;
|
|
6
|
-
fee: bigint;
|
|
7
|
-
block: {
|
|
8
|
-
hash?: string;
|
|
9
|
-
time?: Date;
|
|
10
|
-
height: number;
|
|
11
|
-
};
|
|
12
|
-
senders: string[];
|
|
13
|
-
recipients: string[];
|
|
14
|
-
date: Date;
|
|
15
|
-
transactionSequenceNumber: number;
|
|
16
|
-
};
|
|
1
|
+
import { Operation } from "@ledgerhq/coin-framework/api/types";
|
|
2
|
+
import { StellarToken } from "../types";
|
|
17
3
|
export type ListOperationsOptions = {
|
|
18
4
|
limit?: number;
|
|
19
5
|
cursor?: string;
|
|
20
6
|
order: "asc" | "desc";
|
|
21
7
|
};
|
|
22
|
-
export declare function listOperations(address: string, { limit, cursor, order }: ListOperationsOptions): Promise<[Operation[], string]>;
|
|
8
|
+
export declare function listOperations(address: string, { limit, cursor, order }: ListOperationsOptions): Promise<[Operation<StellarToken>[], string]>;
|
|
23
9
|
//# sourceMappingURL=listOperations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listOperations.d.ts","sourceRoot":"","sources":["../../src/logic/listOperations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"listOperations.d.ts","sourceRoot":"","sources":["../../src/logic/listOperations.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,KAAK,GAAG,MAAM,CAAC;CACvB,CAAC;AAEF,wBAAsB,cAAc,CAClC,OAAO,EAAE,MAAM,EACf,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,qBAAqB,GAC9C,OAAO,CAAC,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAY9C"}
|
|
@@ -12,25 +12,26 @@ async function listOperations(address, { limit, cursor, order }) {
|
|
|
12
12
|
limit,
|
|
13
13
|
cursor: cursor,
|
|
14
14
|
});
|
|
15
|
-
return [operations.map(convertToCoreOperation(
|
|
15
|
+
return [operations.map(op => convertToCoreOperation(op)), nextCursor];
|
|
16
16
|
}
|
|
17
17
|
exports.listOperations = listOperations;
|
|
18
|
-
const convertToCoreOperation = (
|
|
18
|
+
const convertToCoreOperation = (operation) => {
|
|
19
19
|
return {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
tx: {
|
|
21
|
+
hash: operation.hash,
|
|
22
|
+
block: {
|
|
23
|
+
hash: operation.blockHash,
|
|
24
|
+
time: operation.extra.blockTime,
|
|
25
|
+
height: operation.blockHeight,
|
|
26
|
+
},
|
|
27
|
+
fees: BigInt(operation.fee.toString()),
|
|
28
|
+
date: operation.date,
|
|
29
|
+
},
|
|
30
|
+
operationIndex: 0,
|
|
22
31
|
type: operation.type,
|
|
23
32
|
value: BigInt(operation.value.toString()),
|
|
24
|
-
fee: BigInt(operation.fee.toString()),
|
|
25
|
-
block: {
|
|
26
|
-
hash: operation.blockHash,
|
|
27
|
-
time: operation.extra.blockTime,
|
|
28
|
-
height: operation.blockHeight,
|
|
29
|
-
},
|
|
30
33
|
senders: operation.senders,
|
|
31
34
|
recipients: operation.recipients,
|
|
32
|
-
date: operation.date,
|
|
33
|
-
transactionSequenceNumber: operation.transactionSequenceNumber ?? 0,
|
|
34
35
|
};
|
|
35
36
|
};
|
|
36
37
|
//# sourceMappingURL=listOperations.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listOperations.js","sourceRoot":"","sources":["../../src/logic/listOperations.ts"],"names":[],"mappings":";;;AACA,wCAA6C;
|
|
1
|
+
{"version":3,"file":"listOperations.js","sourceRoot":"","sources":["../../src/logic/listOperations.ts"],"names":[],"mappings":";;;AACA,wCAA6C;AAUtC,KAAK,UAAU,cAAc,CAClC,OAAe,EACf,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAyB;IAE/C,iBAAiB;IACjB,MAAM,SAAS,GAAG,EAAE,CAAC;IACrB,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC,GAAG,MAAM,IAAA,yBAAe,EAAC;QACrD,SAAS;QACT,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,KAAK;QACZ,KAAK;QACL,MAAM,EAAE,MAAM;KACf,CAAC,CAAC;IAEH,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,sBAAsB,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;AACxE,CAAC;AAfD,wCAeC;AAED,MAAM,sBAAsB,GAAG,CAAC,SAA2B,EAAE,EAAE;IAC7D,OAAO;QACL,EAAE,EAAE;YACF,IAAI,EAAE,SAAS,CAAC,IAAI;YACpB,KAAK,EAAE;gBACL,IAAI,EAAE,SAAS,CAAC,SAAU;gBAC1B,IAAI,EAAE,SAAS,CAAC,KAAK,CAAC,SAAS;gBAC/B,MAAM,EAAE,SAAS,CAAC,WAAY;aAC/B;YACD,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;YACtC,IAAI,EAAE,SAAS,CAAC,IAAI;SACrB;QACD,cAAc,EAAE,CAAC;QACjB,IAAI,EAAE,SAAS,CAAC,IAAI;QACpB,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QACzC,OAAO,EAAE,SAAS,CAAC,OAAO;QAC1B,UAAU,EAAE,SAAS,CAAC,UAAU;KACjC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../../src/types/assets.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assets.js","sourceRoot":"","sources":["../../src/types/assets.ts"],"names":[],"mappings":""}
|
package/lib/types/index.d.ts
CHANGED
package/lib/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC"}
|
package/lib/types/index.js
CHANGED
|
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./bridge"), exports);
|
|
18
18
|
__exportStar(require("./errors"), exports);
|
|
19
19
|
__exportStar(require("./signer"), exports);
|
|
20
|
+
__exportStar(require("./assets"), exports);
|
|
20
21
|
//# sourceMappingURL=index.js.map
|
package/lib/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,2CAAyB;AACzB,2CAAyB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,2CAAyB;AACzB,2CAAyB;AACzB,2CAAyB"}
|
package/lib-es/api/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Api } from "@ledgerhq/coin-framework/api/index";
|
|
2
2
|
import { type StellarConfig } from "../config";
|
|
3
|
-
|
|
3
|
+
import { StellarToken } from "../types";
|
|
4
|
+
export declare function createApi(config: StellarConfig): Api<StellarToken>;
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,GAAG,EAIJ,MAAM,oCAAoC,CAAC;AAC5C,OAAmB,EAAE,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,GAAG,EAIJ,MAAM,oCAAoC,CAAC;AAC5C,OAAmB,EAAE,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAW3D,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,wBAAgB,SAAS,CAAC,MAAM,EAAE,aAAa,GAAG,GAAG,CAAC,YAAY,CAAC,CAYlE"}
|
|
@@ -17,30 +17,32 @@ describe("Stellar Api", () => {
|
|
|
17
17
|
// Given
|
|
18
18
|
const amount = BigInt(100_000);
|
|
19
19
|
// When
|
|
20
|
-
const result = await module.estimateFees(
|
|
20
|
+
const result = await module.estimateFees({
|
|
21
|
+
type: "send",
|
|
22
|
+
sender: address,
|
|
23
|
+
recipient: "address",
|
|
24
|
+
amount: amount,
|
|
25
|
+
});
|
|
21
26
|
// Then
|
|
22
27
|
expect(result).toEqual(BigInt(100));
|
|
23
28
|
});
|
|
24
29
|
});
|
|
25
|
-
describe
|
|
30
|
+
describe("listOperations", () => {
|
|
31
|
+
let txs;
|
|
32
|
+
beforeAll(async () => {
|
|
33
|
+
[txs] = await module.listOperations(address, { minHeight: 0 });
|
|
34
|
+
}, 20 * 1000); // 20s
|
|
26
35
|
it("returns a list regarding address parameter", async () => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
// Then
|
|
30
|
-
expect(tx.length).toBeGreaterThanOrEqual(100);
|
|
31
|
-
tx.forEach(operation => {
|
|
32
|
-
expect(operation.address).toEqual(address);
|
|
36
|
+
expect(txs.length).toBeGreaterThanOrEqual(100);
|
|
37
|
+
txs.forEach(operation => {
|
|
33
38
|
const isSenderOrReceipt = operation.senders.includes(address) || operation.recipients.includes(address);
|
|
34
39
|
expect(isSenderOrReceipt).toBeTruthy();
|
|
35
40
|
});
|
|
36
41
|
});
|
|
37
42
|
it("returns all operations", async () => {
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
expect(tx.length).toBeGreaterThanOrEqual(100);
|
|
42
|
-
const checkSet = new Set(tx.map(elt => elt.hash));
|
|
43
|
-
expect(checkSet.size).toEqual(tx.length);
|
|
43
|
+
expect(txs.length).toBeGreaterThanOrEqual(100);
|
|
44
|
+
const checkSet = new Set(txs.map(elt => elt.tx.hash));
|
|
45
|
+
expect(checkSet.size).toEqual(txs.length);
|
|
44
46
|
});
|
|
45
47
|
});
|
|
46
48
|
describe("lastBlock", () => {
|
|
@@ -63,16 +65,13 @@ describe("Stellar Api", () => {
|
|
|
63
65
|
});
|
|
64
66
|
describe("craftTransaction", () => {
|
|
65
67
|
it("returns a raw transaction", async () => {
|
|
66
|
-
|
|
67
|
-
const result = await module.craftTransaction(address, {
|
|
68
|
+
const result = await module.craftTransaction({
|
|
68
69
|
type: "send",
|
|
70
|
+
sender: address,
|
|
69
71
|
recipient: "GD6QELUZPSKPRWVXOQ3F6GBF4OBRMCHO5PHREXH4ZRTPJAG7V5MD7JGX",
|
|
70
72
|
amount: BigInt(1_000_000),
|
|
71
|
-
fee: BigInt(100),
|
|
72
73
|
});
|
|
73
|
-
|
|
74
|
-
expect(result.slice(0, 67)).toEqual("AAAAAgAAAAD9Ai6ZfJT42rd0Nl8YJeODFgju688SXPzMZvSA369YPwAAAGQAAHloAAA");
|
|
75
|
-
expect(result.slice(70)).toEqual("AAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAD9Ai6ZfJT42rd0Nl8YJeODFgju688SXPzMZvSA369YPwAAAAAAAAAAAA9CQAAAAAAAAAAA");
|
|
74
|
+
expect(result.length).toEqual(188);
|
|
76
75
|
});
|
|
77
76
|
});
|
|
78
77
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.integ.test.js","sourceRoot":"","sources":["../../src/api/index.integ.test.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"index.integ.test.js","sourceRoot":"","sources":["../../src/api/index.integ.test.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,GAAG,CAAC;AAG9B;;GAEG;AACH,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,IAAI,MAAyB,CAAC;IAC9B,MAAM,OAAO,G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CAAC;QACpC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,EAAE,CAAC,2BAA2B,EAAE,KAAK,IAAI,EAAE;YACzC,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,gBAAgB,CAAC;gBAC3C,IAAI,EAAE,MAAM;gBACZ,MAAM,EAAE,OAAO;gBACf,SAAS,EAAE,0DAA0D;gBACrE,MAAM,EAAE,MAAM,CAAC,SAAS,CAAC;aAC1B,CAAC,CAAC;YAEH,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/lib-es/api/index.js
CHANGED
|
@@ -6,30 +6,27 @@ export function createApi(config) {
|
|
|
6
6
|
broadcast,
|
|
7
7
|
combine: compose,
|
|
8
8
|
craftTransaction: craft,
|
|
9
|
-
estimateFees,
|
|
9
|
+
estimateFees: () => estimateFees(),
|
|
10
10
|
getBalance,
|
|
11
11
|
lastBlock,
|
|
12
12
|
listOperations: operations,
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
async function craft(address, transaction) {
|
|
19
|
-
const supplement = isSupplement(transaction.supplement)
|
|
15
|
+
async function craft(transactionIntent) {
|
|
16
|
+
const fees = await estimateFees();
|
|
17
|
+
const supplement = transactionIntent.asset
|
|
20
18
|
? {
|
|
21
|
-
assetCode:
|
|
22
|
-
assetIssuer:
|
|
23
|
-
memoType: transaction.supplement?.memoType,
|
|
24
|
-
memoValue: transaction.supplement?.memoValue,
|
|
19
|
+
assetCode: transactionIntent.asset.assetCode,
|
|
20
|
+
assetIssuer: transactionIntent.asset.assetIssuer,
|
|
25
21
|
}
|
|
26
22
|
: {};
|
|
27
|
-
const tx = await craftTransaction({ address }, {
|
|
28
|
-
|
|
23
|
+
const tx = await craftTransaction({ address: transactionIntent.sender }, {
|
|
24
|
+
type: transactionIntent.type,
|
|
25
|
+
recipient: transactionIntent.recipient,
|
|
26
|
+
amount: transactionIntent.amount,
|
|
27
|
+
fee: fees,
|
|
29
28
|
assetCode: supplement?.assetCode,
|
|
30
29
|
assetIssuer: supplement?.assetIssuer,
|
|
31
|
-
memoType: supplement?.memoType,
|
|
32
|
-
memoValue: supplement?.memoValue,
|
|
33
30
|
});
|
|
34
31
|
return tx.xdr;
|
|
35
32
|
}
|
|
@@ -58,7 +55,7 @@ async function operationsFromHeight(address, minHeight) {
|
|
|
58
55
|
options.cursor = state.apiNextCursor;
|
|
59
56
|
}
|
|
60
57
|
const [operations, nextCursor] = await listOperations(address, options);
|
|
61
|
-
const filteredOperations = operations.filter(op => op.block.height >= state.heightLimit);
|
|
58
|
+
const filteredOperations = operations.filter(op => op.tx.block.height >= state.heightLimit);
|
|
62
59
|
state.accumulator.push(...filteredOperations);
|
|
63
60
|
state.apiNextCursor = nextCursor;
|
|
64
61
|
state.continueIterations = operations.length === filteredOperations.length && nextCursor !== "";
|
package/lib-es/api/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAMA,OAAO,UAAkC,MAAM,WAAW,CAAC;AAC3D,OAAO,EACL,SAAS,EACT,OAAO,EACP,gBAAgB,EAChB,YAAY,EACZ,UAAU,EACV,cAAc,EACd,SAAS,GACV,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAMA,OAAO,UAAkC,MAAM,WAAW,CAAC;AAC3D,OAAO,EACL,SAAS,EACT,OAAO,EACP,gBAAgB,EAChB,YAAY,EACZ,UAAU,EACV,cAAc,EACd,SAAS,GACV,MAAM,UAAU,CAAC;AAIlB,MAAM,UAAU,SAAS,CAAC,MAAq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|
package/lib-es/api/index.test.js
CHANGED
|
@@ -17,20 +17,20 @@ describe("operations", () => {
|
|
|
17
17
|
jest.clearAllMocks();
|
|
18
18
|
});
|
|
19
19
|
const mockOperation = {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
tx: {
|
|
21
|
+
hash: "e035a56c32003e3b0e4c9c5499b0750d71d98233ae6ae94323ff0a458b05a30b",
|
|
22
|
+
fees: 0.0291,
|
|
23
|
+
block: {
|
|
24
|
+
hash: "hash",
|
|
25
|
+
time: new Date("2024-03-20T10:00:00Z"),
|
|
26
|
+
height: 10,
|
|
27
|
+
},
|
|
28
|
+
date: new Date("2024-03-20T10:00:00Z"),
|
|
29
|
+
},
|
|
22
30
|
type: "Operation",
|
|
23
31
|
value: 200,
|
|
24
|
-
fee: 0.0291,
|
|
25
|
-
block: {
|
|
26
|
-
hash: "hash",
|
|
27
|
-
time: new Date("2024-03-20T10:00:00Z"),
|
|
28
|
-
height: 10,
|
|
29
|
-
},
|
|
30
32
|
senders: ["addr"],
|
|
31
33
|
recipients: ["recipient"],
|
|
32
|
-
date: new Date("2024-03-20T10:00:00Z"),
|
|
33
|
-
transactionSequenceNumber: 2,
|
|
34
34
|
};
|
|
35
35
|
it("should return 0 operations for a valid account", async () => {
|
|
36
36
|
mockGetOperations.mockResolvedValue([[], ""]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../src/api/index.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,MAAM,iBAAiB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AAEpC,IAAI,CAAC,IAAI,CAAC,yBAAyB,EAAE,GAAG,EAAE,CAAC,CAAC;IAC1C,cAAc,EAAE,GAAG,EAAE,CAAC,iBAAiB,EAAE;CAC1C,CAAC,CAAC,CAAC;AAEJ,MAAM,GAAG,GAAG,SAAS,CAAC;IACpB,QAAQ,EAAE;QACR,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QACP,MAAM,UAAU,GAAG,MAAM,GAAG,CAAC,cAAc,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC;QAExE,OAAO;QACP,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2CAA2C,EAAE,KAAK,IAAI,EAAE;QACzD,iBAAiB;aACd,qBAAqB,CAAC,CAAC,CAAC,aAAa,CAAC,EAAE,IAAI,CAAC,CAAC;aAC9C,qBAAqB,CAAC,CAAC,CAAC,aAAa,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QAEhD,OAAO;QACP,MAAM,UAAU,GAAG,MAAM,GAAG,CAAC,cAAc,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;QAEjE,OAAO;QACP,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,aAAa,EAAE,aAAa,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QACjE,MAAM,CAAC,iBAAiB,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -4,7 +4,7 @@ import { fetchBaseFee } from "../network";
|
|
|
4
4
|
* @see {@link https://developers.stellar.org/docs/learn/fundamentals/fees-resource-limits-metering#inclusion-fee}
|
|
5
5
|
*/
|
|
6
6
|
export async function estimateFees() {
|
|
7
|
-
const
|
|
8
|
-
return BigInt(
|
|
7
|
+
const baseFee = await fetchBaseFee();
|
|
8
|
+
return BigInt(baseFee.recommendedFee);
|
|
9
9
|
}
|
|
10
10
|
//# sourceMappingURL=estimateFees.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"estimateFees.js","sourceRoot":"","sources":["../../src/logic/estimateFees.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY;IAChC,MAAM,
|
|
1
|
+
{"version":3,"file":"estimateFees.js","sourceRoot":"","sources":["../../src/logic/estimateFees.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY;IAChC,MAAM,OAAO,GAAG,MAAM,YAAY,EAAE,CAAC;IACrC,OAAO,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -1,23 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
address: string;
|
|
4
|
-
type: string;
|
|
5
|
-
value: bigint;
|
|
6
|
-
fee: bigint;
|
|
7
|
-
block: {
|
|
8
|
-
hash?: string;
|
|
9
|
-
time?: Date;
|
|
10
|
-
height: number;
|
|
11
|
-
};
|
|
12
|
-
senders: string[];
|
|
13
|
-
recipients: string[];
|
|
14
|
-
date: Date;
|
|
15
|
-
transactionSequenceNumber: number;
|
|
16
|
-
};
|
|
1
|
+
import { Operation } from "@ledgerhq/coin-framework/api/types";
|
|
2
|
+
import { StellarToken } from "../types";
|
|
17
3
|
export type ListOperationsOptions = {
|
|
18
4
|
limit?: number;
|
|
19
5
|
cursor?: string;
|
|
20
6
|
order: "asc" | "desc";
|
|
21
7
|
};
|
|
22
|
-
export declare function listOperations(address: string, { limit, cursor, order }: ListOperationsOptions): Promise<[Operation[], string]>;
|
|
8
|
+
export declare function listOperations(address: string, { limit, cursor, order }: ListOperationsOptions): Promise<[Operation<StellarToken>[], string]>;
|
|
23
9
|
//# sourceMappingURL=listOperations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listOperations.d.ts","sourceRoot":"","sources":["../../src/logic/listOperations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"listOperations.d.ts","sourceRoot":"","sources":["../../src/logic/listOperations.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,KAAK,GAAG,MAAM,CAAC;CACvB,CAAC;AAEF,wBAAsB,cAAc,CAClC,OAAO,EAAE,MAAM,EACf,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,qBAAqB,GAC9C,OAAO,CAAC,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAY9C"}
|
|
@@ -9,24 +9,25 @@ export async function listOperations(address, { limit, cursor, order }) {
|
|
|
9
9
|
limit,
|
|
10
10
|
cursor: cursor,
|
|
11
11
|
});
|
|
12
|
-
return [operations.map(convertToCoreOperation(
|
|
12
|
+
return [operations.map(op => convertToCoreOperation(op)), nextCursor];
|
|
13
13
|
}
|
|
14
|
-
const convertToCoreOperation = (
|
|
14
|
+
const convertToCoreOperation = (operation) => {
|
|
15
15
|
return {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
tx: {
|
|
17
|
+
hash: operation.hash,
|
|
18
|
+
block: {
|
|
19
|
+
hash: operation.blockHash,
|
|
20
|
+
time: operation.extra.blockTime,
|
|
21
|
+
height: operation.blockHeight,
|
|
22
|
+
},
|
|
23
|
+
fees: BigInt(operation.fee.toString()),
|
|
24
|
+
date: operation.date,
|
|
25
|
+
},
|
|
26
|
+
operationIndex: 0,
|
|
18
27
|
type: operation.type,
|
|
19
28
|
value: BigInt(operation.value.toString()),
|
|
20
|
-
fee: BigInt(operation.fee.toString()),
|
|
21
|
-
block: {
|
|
22
|
-
hash: operation.blockHash,
|
|
23
|
-
time: operation.extra.blockTime,
|
|
24
|
-
height: operation.blockHeight,
|
|
25
|
-
},
|
|
26
29
|
senders: operation.senders,
|
|
27
30
|
recipients: operation.recipients,
|
|
28
|
-
date: operation.date,
|
|
29
|
-
transactionSequenceNumber: operation.transactionSequenceNumber ?? 0,
|
|
30
31
|
};
|
|
31
32
|
};
|
|
32
33
|
//# sourceMappingURL=listOperations.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listOperations.js","sourceRoot":"","sources":["../../src/logic/listOperations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"listOperations.js","sourceRoot":"","sources":["../../src/logic/listOperations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAU7C,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,OAAe,EACf,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAyB;IAE/C,iBAAiB;IACjB,MAAM,SAAS,GAAG,EAAE,CAAC;IACrB,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC,GAAG,MAAM,eAAe,CAAC;QACrD,SAAS;QACT,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,KAAK;QACZ,KAAK;QACL,MAAM,EAAE,MAAM;KACf,CAAC,CAAC;IAEH,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,sBAAsB,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;AACxE,CAAC;AAED,MAAM,sBAAsB,GAAG,CAAC,SAA2B,EAAE,EAAE;IAC7D,OAAO;QACL,EAAE,EAAE;YACF,IAAI,EAAE,SAAS,CAAC,IAAI;YACpB,KAAK,EAAE;gBACL,IAAI,EAAE,SAAS,CAAC,SAAU;gBAC1B,IAAI,EAAE,SAAS,CAAC,KAAK,CAAC,SAAS;gBAC/B,MAAM,EAAE,SAAS,CAAC,WAAY;aAC/B;YACD,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;YACtC,IAAI,EAAE,SAAS,CAAC,IAAI;SACrB;QACD,cAAc,EAAE,CAAC;QACjB,IAAI,EAAE,SAAS,CAAC,IAAI;QACpB,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QACzC,OAAO,EAAE,SAAS,CAAC,OAAO;QAC1B,UAAU,EAAE,SAAS,CAAC,UAAU;KACjC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../../src/types/assets.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assets.js","sourceRoot":"","sources":["../../src/types/assets.ts"],"names":[],"mappings":""}
|
package/lib-es/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC"}
|
package/lib-es/types/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/coin-stellar",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0-nightly.0",
|
|
4
4
|
"description": "Ledger Stellar Coin integration",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": [
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"expect": "^27.4.6",
|
|
108
108
|
"invariant": "^2.2.2",
|
|
109
109
|
"rxjs": "^7.8.1",
|
|
110
|
-
"@ledgerhq/coin-framework": "^2.
|
|
110
|
+
"@ledgerhq/coin-framework": "^2.4.0-nightly.0",
|
|
111
111
|
"@ledgerhq/cryptoassets": "^13.13.0",
|
|
112
112
|
"@ledgerhq/devices": "8.4.4",
|
|
113
113
|
"@ledgerhq/errors": "^6.19.1",
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import type { Api } from "@ledgerhq/coin-framework/api/index";
|
|
1
|
+
import type { Api, Operation } from "@ledgerhq/coin-framework/api/index";
|
|
2
2
|
import { createApi } from ".";
|
|
3
|
+
import { StellarToken } from "../types";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Testnet scan: https://testnet.lumenscan.io/
|
|
6
7
|
*/
|
|
7
8
|
describe("Stellar Api", () => {
|
|
8
|
-
let module: Api
|
|
9
|
+
let module: Api<StellarToken>;
|
|
9
10
|
const address = "GBAUZBDXMVV7HII4JWBGFMLVKVJ6OLQAKOCGXM5E2FM4TAZB6C7JO2L7";
|
|
10
11
|
|
|
11
12
|
beforeAll(() => {
|
|
@@ -22,22 +23,28 @@ describe("Stellar Api", () => {
|
|
|
22
23
|
const amount = BigInt(100_000);
|
|
23
24
|
|
|
24
25
|
// When
|
|
25
|
-
const result = await module.estimateFees(
|
|
26
|
+
const result = await module.estimateFees({
|
|
27
|
+
type: "send",
|
|
28
|
+
sender: address,
|
|
29
|
+
recipient: "address",
|
|
30
|
+
amount: amount,
|
|
31
|
+
});
|
|
26
32
|
|
|
27
33
|
// Then
|
|
28
34
|
expect(result).toEqual(BigInt(100));
|
|
29
35
|
});
|
|
30
36
|
});
|
|
31
37
|
|
|
32
|
-
describe
|
|
33
|
-
|
|
34
|
-
// When
|
|
35
|
-
const [tx, _] = await module.listOperations(address, { minHeight: 0 });
|
|
38
|
+
describe("listOperations", () => {
|
|
39
|
+
let txs: Operation<StellarToken>[];
|
|
36
40
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
beforeAll(async () => {
|
|
42
|
+
[txs] = await module.listOperations(address, { minHeight: 0 });
|
|
43
|
+
}, 20 * 1000); // 20s
|
|
44
|
+
|
|
45
|
+
it("returns a list regarding address parameter", async () => {
|
|
46
|
+
expect(txs.length).toBeGreaterThanOrEqual(100);
|
|
47
|
+
txs.forEach(operation => {
|
|
41
48
|
const isSenderOrReceipt =
|
|
42
49
|
operation.senders.includes(address) || operation.recipients.includes(address);
|
|
43
50
|
expect(isSenderOrReceipt).toBeTruthy();
|
|
@@ -45,13 +52,9 @@ describe("Stellar Api", () => {
|
|
|
45
52
|
});
|
|
46
53
|
|
|
47
54
|
it("returns all operations", async () => {
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
// Then
|
|
52
|
-
expect(tx.length).toBeGreaterThanOrEqual(100);
|
|
53
|
-
const checkSet = new Set(tx.map(elt => elt.hash));
|
|
54
|
-
expect(checkSet.size).toEqual(tx.length);
|
|
55
|
+
expect(txs.length).toBeGreaterThanOrEqual(100);
|
|
56
|
+
const checkSet = new Set(txs.map(elt => elt.tx.hash));
|
|
57
|
+
expect(checkSet.size).toEqual(txs.length);
|
|
55
58
|
});
|
|
56
59
|
});
|
|
57
60
|
|
|
@@ -79,21 +82,14 @@ describe("Stellar Api", () => {
|
|
|
79
82
|
|
|
80
83
|
describe("craftTransaction", () => {
|
|
81
84
|
it("returns a raw transaction", async () => {
|
|
82
|
-
|
|
83
|
-
const result = await module.craftTransaction(address, {
|
|
85
|
+
const result = await module.craftTransaction({
|
|
84
86
|
type: "send",
|
|
87
|
+
sender: address,
|
|
85
88
|
recipient: "GD6QELUZPSKPRWVXOQ3F6GBF4OBRMCHO5PHREXH4ZRTPJAG7V5MD7JGX",
|
|
86
89
|
amount: BigInt(1_000_000),
|
|
87
|
-
fee: BigInt(100),
|
|
88
90
|
});
|
|
89
91
|
|
|
90
|
-
|
|
91
|
-
expect(result.slice(0, 67)).toEqual(
|
|
92
|
-
"AAAAAgAAAAD9Ai6ZfJT42rd0Nl8YJeODFgju688SXPzMZvSA369YPwAAAGQAAHloAAA",
|
|
93
|
-
);
|
|
94
|
-
expect(result.slice(70)).toEqual(
|
|
95
|
-
"AAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAD9Ai6ZfJT42rd0Nl8YJeODFgju688SXPzMZvSA369YPwAAAAAAAAAAAA9CQAAAAAAAAAAA",
|
|
96
|
-
);
|
|
92
|
+
expect(result.length).toEqual(188);
|
|
97
93
|
});
|
|
98
94
|
});
|
|
99
95
|
});
|
package/src/api/index.test.ts
CHANGED
|
@@ -23,20 +23,20 @@ describe("operations", () => {
|
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
const mockOperation = {
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
tx: {
|
|
27
|
+
hash: "e035a56c32003e3b0e4c9c5499b0750d71d98233ae6ae94323ff0a458b05a30b",
|
|
28
|
+
fees: 0.0291,
|
|
29
|
+
block: {
|
|
30
|
+
hash: "hash",
|
|
31
|
+
time: new Date("2024-03-20T10:00:00Z"),
|
|
32
|
+
height: 10,
|
|
33
|
+
},
|
|
34
|
+
date: new Date("2024-03-20T10:00:00Z"),
|
|
35
|
+
},
|
|
28
36
|
type: "Operation",
|
|
29
37
|
value: 200,
|
|
30
|
-
fee: 0.0291,
|
|
31
|
-
block: {
|
|
32
|
-
hash: "hash",
|
|
33
|
-
time: new Date("2024-03-20T10:00:00Z"),
|
|
34
|
-
height: 10,
|
|
35
|
-
},
|
|
36
38
|
senders: ["addr"],
|
|
37
39
|
recipients: ["recipient"],
|
|
38
|
-
date: new Date("2024-03-20T10:00:00Z"),
|
|
39
|
-
transactionSequenceNumber: 2,
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
it("should return 0 operations for a valid account", async () => {
|
package/src/api/index.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type {
|
|
|
2
2
|
Api,
|
|
3
3
|
Operation,
|
|
4
4
|
Pagination,
|
|
5
|
-
|
|
5
|
+
TransactionIntent,
|
|
6
6
|
} from "@ledgerhq/coin-framework/api/index";
|
|
7
7
|
import coinConfig, { type StellarConfig } from "../config";
|
|
8
8
|
import {
|
|
@@ -15,47 +15,39 @@ import {
|
|
|
15
15
|
lastBlock,
|
|
16
16
|
} from "../logic";
|
|
17
17
|
import { ListOperationsOptions } from "../logic/listOperations";
|
|
18
|
+
import { StellarToken } from "../types";
|
|
18
19
|
|
|
19
|
-
export function createApi(config: StellarConfig): Api {
|
|
20
|
+
export function createApi(config: StellarConfig): Api<StellarToken> {
|
|
20
21
|
coinConfig.setCoinConfig(() => ({ ...config, status: { type: "active" } }));
|
|
21
22
|
|
|
22
23
|
return {
|
|
23
24
|
broadcast,
|
|
24
25
|
combine: compose,
|
|
25
26
|
craftTransaction: craft,
|
|
26
|
-
estimateFees,
|
|
27
|
+
estimateFees: () => estimateFees(),
|
|
27
28
|
getBalance,
|
|
28
29
|
lastBlock,
|
|
29
30
|
listOperations: operations,
|
|
30
31
|
};
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
memoType?: string | null | undefined;
|
|
37
|
-
memoValue?: string | null | undefined;
|
|
38
|
-
};
|
|
39
|
-
function isSupplement(supplement: unknown): supplement is Supplement {
|
|
40
|
-
return typeof supplement === "object";
|
|
41
|
-
}
|
|
42
|
-
async function craft(address: string, transaction: ApiTransaction): Promise<string> {
|
|
43
|
-
const supplement = isSupplement(transaction.supplement)
|
|
34
|
+
async function craft(transactionIntent: TransactionIntent<StellarToken>): Promise<string> {
|
|
35
|
+
const fees = await estimateFees();
|
|
36
|
+
const supplement = transactionIntent.asset
|
|
44
37
|
? {
|
|
45
|
-
assetCode:
|
|
46
|
-
assetIssuer:
|
|
47
|
-
memoType: transaction.supplement?.memoType,
|
|
48
|
-
memoValue: transaction.supplement?.memoValue,
|
|
38
|
+
assetCode: transactionIntent.asset.assetCode,
|
|
39
|
+
assetIssuer: transactionIntent.asset.assetIssuer,
|
|
49
40
|
}
|
|
50
41
|
: {};
|
|
51
42
|
const tx = await craftTransaction(
|
|
52
|
-
{ address },
|
|
43
|
+
{ address: transactionIntent.sender },
|
|
53
44
|
{
|
|
54
|
-
|
|
45
|
+
type: transactionIntent.type,
|
|
46
|
+
recipient: transactionIntent.recipient,
|
|
47
|
+
amount: transactionIntent.amount,
|
|
48
|
+
fee: fees,
|
|
55
49
|
assetCode: supplement?.assetCode,
|
|
56
50
|
assetIssuer: supplement?.assetIssuer,
|
|
57
|
-
memoType: supplement?.memoType,
|
|
58
|
-
memoValue: supplement?.memoValue,
|
|
59
51
|
},
|
|
60
52
|
);
|
|
61
53
|
return tx.xdr;
|
|
@@ -71,7 +63,7 @@ function compose(tx: string, signature: string, pubkey?: string): string {
|
|
|
71
63
|
async function operations(
|
|
72
64
|
address: string,
|
|
73
65
|
{ minHeight }: Pagination,
|
|
74
|
-
): Promise<[Operation[], string]> {
|
|
66
|
+
): Promise<[Operation<StellarToken>[], string]> {
|
|
75
67
|
return operationsFromHeight(address, minHeight);
|
|
76
68
|
}
|
|
77
69
|
|
|
@@ -80,13 +72,13 @@ type PaginationState = {
|
|
|
80
72
|
readonly heightLimit: number;
|
|
81
73
|
continueIterations: boolean;
|
|
82
74
|
apiNextCursor?: string;
|
|
83
|
-
accumulator: Operation[];
|
|
75
|
+
accumulator: Operation<StellarToken>[];
|
|
84
76
|
};
|
|
85
77
|
|
|
86
78
|
async function operationsFromHeight(
|
|
87
79
|
address: string,
|
|
88
80
|
minHeight: number,
|
|
89
|
-
): Promise<[Operation[], string]> {
|
|
81
|
+
): Promise<[Operation<StellarToken>[], string]> {
|
|
90
82
|
const state: PaginationState = {
|
|
91
83
|
pageSize: 200,
|
|
92
84
|
heightLimit: minHeight,
|
|
@@ -103,7 +95,7 @@ async function operationsFromHeight(
|
|
|
103
95
|
options.cursor = state.apiNextCursor;
|
|
104
96
|
}
|
|
105
97
|
const [operations, nextCursor] = await listOperations(address, options);
|
|
106
|
-
const filteredOperations = operations.filter(op => op.block.height >= state.heightLimit);
|
|
98
|
+
const filteredOperations = operations.filter(op => op.tx.block.height >= state.heightLimit);
|
|
107
99
|
state.accumulator.push(...filteredOperations);
|
|
108
100
|
state.apiNextCursor = nextCursor;
|
|
109
101
|
state.continueIterations = operations.length === filteredOperations.length && nextCursor !== "";
|
|
@@ -5,6 +5,6 @@ import { fetchBaseFee } from "../network";
|
|
|
5
5
|
* @see {@link https://developers.stellar.org/docs/learn/fundamentals/fees-resource-limits-metering#inclusion-fee}
|
|
6
6
|
*/
|
|
7
7
|
export async function estimateFees(): Promise<bigint> {
|
|
8
|
-
const
|
|
9
|
-
return BigInt(
|
|
8
|
+
const baseFee = await fetchBaseFee();
|
|
9
|
+
return BigInt(baseFee.recommendedFee);
|
|
10
10
|
}
|
|
@@ -1,22 +1,7 @@
|
|
|
1
1
|
import type { StellarOperation } from "../types/bridge";
|
|
2
2
|
import { fetchOperations } from "../network";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
hash: string;
|
|
6
|
-
address: string;
|
|
7
|
-
type: string;
|
|
8
|
-
value: bigint;
|
|
9
|
-
fee: bigint;
|
|
10
|
-
block: {
|
|
11
|
-
hash?: string;
|
|
12
|
-
time?: Date;
|
|
13
|
-
height: number;
|
|
14
|
-
};
|
|
15
|
-
senders: string[];
|
|
16
|
-
recipients: string[];
|
|
17
|
-
date: Date;
|
|
18
|
-
transactionSequenceNumber: number;
|
|
19
|
-
};
|
|
3
|
+
import { Operation } from "@ledgerhq/coin-framework/api/types";
|
|
4
|
+
import { StellarToken } from "../types";
|
|
20
5
|
|
|
21
6
|
export type ListOperationsOptions = {
|
|
22
7
|
limit?: number;
|
|
@@ -27,7 +12,7 @@ export type ListOperationsOptions = {
|
|
|
27
12
|
export async function listOperations(
|
|
28
13
|
address: string,
|
|
29
14
|
{ limit, cursor, order }: ListOperationsOptions,
|
|
30
|
-
): Promise<[Operation[], string]> {
|
|
15
|
+
): Promise<[Operation<StellarToken>[], string]> {
|
|
31
16
|
// Fake accountId
|
|
32
17
|
const accountId = "";
|
|
33
18
|
const [operations, nextCursor] = await fetchOperations({
|
|
@@ -38,24 +23,25 @@ export async function listOperations(
|
|
|
38
23
|
cursor: cursor,
|
|
39
24
|
});
|
|
40
25
|
|
|
41
|
-
return [operations.map(convertToCoreOperation(
|
|
26
|
+
return [operations.map(op => convertToCoreOperation(op)), nextCursor];
|
|
42
27
|
}
|
|
43
28
|
|
|
44
|
-
const convertToCoreOperation = (
|
|
29
|
+
const convertToCoreOperation = (operation: StellarOperation) => {
|
|
45
30
|
return {
|
|
46
|
-
|
|
47
|
-
|
|
31
|
+
tx: {
|
|
32
|
+
hash: operation.hash,
|
|
33
|
+
block: {
|
|
34
|
+
hash: operation.blockHash!,
|
|
35
|
+
time: operation.extra.blockTime,
|
|
36
|
+
height: operation.blockHeight!,
|
|
37
|
+
},
|
|
38
|
+
fees: BigInt(operation.fee.toString()),
|
|
39
|
+
date: operation.date,
|
|
40
|
+
},
|
|
41
|
+
operationIndex: 0,
|
|
48
42
|
type: operation.type,
|
|
49
43
|
value: BigInt(operation.value.toString()),
|
|
50
|
-
fee: BigInt(operation.fee.toString()),
|
|
51
|
-
block: {
|
|
52
|
-
hash: operation.blockHash!,
|
|
53
|
-
time: operation.extra.blockTime,
|
|
54
|
-
height: operation.blockHeight!,
|
|
55
|
-
},
|
|
56
44
|
senders: operation.senders,
|
|
57
45
|
recipients: operation.recipients,
|
|
58
|
-
date: operation.date,
|
|
59
|
-
transactionSequenceNumber: operation.transactionSequenceNumber ?? 0,
|
|
60
46
|
};
|
|
61
47
|
};
|
package/src/types/index.ts
CHANGED