@ledgerhq/coin-canton 0.4.0 → 0.4.1-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 +7 -0
- package/jest.config.js +1 -0
- package/lib/api/getBalance.integ.test.d.ts +2 -0
- package/lib/api/getBalance.integ.test.d.ts.map +1 -0
- package/lib/api/getBalance.integ.test.js +24 -0
- package/lib/api/getBalance.integ.test.js.map +1 -0
- package/lib/api/lastBlock.integ.test.js +3 -1
- package/lib/api/lastBlock.integ.test.js.map +1 -1
- package/lib/api/listOperations.integ.test.d.ts +2 -0
- package/lib/api/listOperations.integ.test.d.ts.map +1 -0
- package/lib/api/listOperations.integ.test.js +23 -0
- package/lib/api/listOperations.integ.test.js.map +1 -0
- package/lib/bridge/signOperation.js +1 -1
- package/lib/bridge/signOperation.js.map +1 -1
- package/lib/common-logic/account/getBalance.d.ts +1 -1
- package/lib/common-logic/account/getBalance.d.ts.map +1 -1
- package/lib/common-logic/account/getBalance.js +21 -5
- package/lib/common-logic/account/getBalance.js.map +1 -1
- package/lib/common-logic/account/getBalance.unit.test.d.ts +2 -0
- package/lib/common-logic/account/getBalance.unit.test.d.ts.map +1 -0
- package/lib/common-logic/account/getBalance.unit.test.js +88 -0
- package/lib/common-logic/account/getBalance.unit.test.js.map +1 -0
- package/lib/common-logic/history/lastBlock.d.ts.map +1 -1
- package/lib/common-logic/history/lastBlock.js +7 -1
- package/lib/common-logic/history/lastBlock.js.map +1 -1
- package/lib/common-logic/history/lastBlock.test.d.ts +2 -0
- package/lib/common-logic/history/lastBlock.test.d.ts.map +1 -0
- package/lib/common-logic/history/lastBlock.test.js +43 -0
- package/lib/common-logic/history/lastBlock.test.js.map +1 -0
- package/lib/common-logic/history/listOperations.d.ts +3 -4
- package/lib/common-logic/history/listOperations.d.ts.map +1 -1
- package/lib/common-logic/history/listOperations.js +43 -41
- package/lib/common-logic/history/listOperations.js.map +1 -1
- package/lib/common-logic/transaction/broadcast.d.ts.map +1 -1
- package/lib/common-logic/transaction/broadcast.js +11 -3
- package/lib/common-logic/transaction/broadcast.js.map +1 -1
- package/lib/common-logic/transaction/broadcast.test.d.ts +2 -0
- package/lib/common-logic/transaction/broadcast.test.d.ts.map +1 -0
- package/lib/common-logic/transaction/broadcast.test.js +68 -0
- package/lib/common-logic/transaction/broadcast.test.js.map +1 -0
- package/lib/common-logic/transaction/combine.d.ts +1 -1
- package/lib/common-logic/transaction/combine.d.ts.map +1 -1
- package/lib/common-logic/transaction/combine.js +6 -3
- package/lib/common-logic/transaction/combine.js.map +1 -1
- package/lib/common-logic/transaction/combine.test.d.ts +2 -0
- package/lib/common-logic/transaction/combine.test.d.ts.map +1 -0
- package/lib/common-logic/transaction/combine.test.js +28 -0
- package/lib/common-logic/transaction/combine.test.js.map +1 -0
- package/lib/common-logic/transaction/estimateFees.d.ts.map +1 -1
- package/lib/common-logic/transaction/estimateFees.js +2 -15
- package/lib/common-logic/transaction/estimateFees.js.map +1 -1
- package/lib/common-logic/utils.d.ts +0 -1
- package/lib/common-logic/utils.d.ts.map +1 -1
- package/lib/common-logic/utils.js +1 -6
- package/lib/common-logic/utils.js.map +1 -1
- package/lib/config.d.ts +6 -3
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js.map +1 -1
- package/lib/network/gateway.d.ts +31 -21
- package/lib/network/gateway.d.ts.map +1 -1
- package/lib/network/gateway.integ.test.js +29 -2
- package/lib/network/gateway.integ.test.js.map +1 -1
- package/lib/network/gateway.js +33 -9
- package/lib/network/gateway.js.map +1 -1
- package/lib/network/node.integ.test.js +4 -2
- package/lib/network/node.integ.test.js.map +1 -1
- package/lib/types/bridge.d.ts.map +1 -1
- package/lib-es/api/getBalance.integ.test.d.ts +2 -0
- package/lib-es/api/getBalance.integ.test.d.ts.map +1 -0
- package/lib-es/api/getBalance.integ.test.js +22 -0
- package/lib-es/api/getBalance.integ.test.js.map +1 -0
- package/lib-es/api/lastBlock.integ.test.js +3 -1
- package/lib-es/api/lastBlock.integ.test.js.map +1 -1
- package/lib-es/api/listOperations.integ.test.d.ts +2 -0
- package/lib-es/api/listOperations.integ.test.d.ts.map +1 -0
- package/lib-es/api/listOperations.integ.test.js +21 -0
- package/lib-es/api/listOperations.integ.test.js.map +1 -0
- package/lib-es/bridge/signOperation.js +1 -1
- package/lib-es/bridge/signOperation.js.map +1 -1
- package/lib-es/common-logic/account/getBalance.d.ts +1 -1
- package/lib-es/common-logic/account/getBalance.d.ts.map +1 -1
- package/lib-es/common-logic/account/getBalance.js +18 -5
- package/lib-es/common-logic/account/getBalance.js.map +1 -1
- package/lib-es/common-logic/account/getBalance.unit.test.d.ts +2 -0
- package/lib-es/common-logic/account/getBalance.unit.test.d.ts.map +1 -0
- package/lib-es/common-logic/account/getBalance.unit.test.js +53 -0
- package/lib-es/common-logic/account/getBalance.unit.test.js.map +1 -0
- package/lib-es/common-logic/history/lastBlock.d.ts.map +1 -1
- package/lib-es/common-logic/history/lastBlock.js +5 -2
- package/lib-es/common-logic/history/lastBlock.js.map +1 -1
- package/lib-es/common-logic/history/lastBlock.test.d.ts +2 -0
- package/lib-es/common-logic/history/lastBlock.test.d.ts.map +1 -0
- package/lib-es/common-logic/history/lastBlock.test.js +38 -0
- package/lib-es/common-logic/history/lastBlock.test.js.map +1 -0
- package/lib-es/common-logic/history/listOperations.d.ts +3 -4
- package/lib-es/common-logic/history/listOperations.d.ts.map +1 -1
- package/lib-es/common-logic/history/listOperations.js +40 -41
- package/lib-es/common-logic/history/listOperations.js.map +1 -1
- package/lib-es/common-logic/transaction/broadcast.d.ts.map +1 -1
- package/lib-es/common-logic/transaction/broadcast.js +8 -3
- package/lib-es/common-logic/transaction/broadcast.js.map +1 -1
- package/lib-es/common-logic/transaction/broadcast.test.d.ts +2 -0
- package/lib-es/common-logic/transaction/broadcast.test.d.ts.map +1 -0
- package/lib-es/common-logic/transaction/broadcast.test.js +33 -0
- package/lib-es/common-logic/transaction/broadcast.test.js.map +1 -0
- package/lib-es/common-logic/transaction/combine.d.ts +1 -1
- package/lib-es/common-logic/transaction/combine.d.ts.map +1 -1
- package/lib-es/common-logic/transaction/combine.js +6 -3
- package/lib-es/common-logic/transaction/combine.js.map +1 -1
- package/lib-es/common-logic/transaction/combine.test.d.ts +2 -0
- package/lib-es/common-logic/transaction/combine.test.d.ts.map +1 -0
- package/lib-es/common-logic/transaction/combine.test.js +26 -0
- package/lib-es/common-logic/transaction/combine.test.js.map +1 -0
- package/lib-es/common-logic/transaction/estimateFees.d.ts.map +1 -1
- package/lib-es/common-logic/transaction/estimateFees.js +2 -15
- package/lib-es/common-logic/transaction/estimateFees.js.map +1 -1
- package/lib-es/common-logic/utils.d.ts +0 -1
- package/lib-es/common-logic/utils.d.ts.map +1 -1
- package/lib-es/common-logic/utils.js +0 -4
- package/lib-es/common-logic/utils.js.map +1 -1
- package/lib-es/config.d.ts +6 -3
- package/lib-es/config.d.ts.map +1 -1
- package/lib-es/config.js.map +1 -1
- package/lib-es/network/gateway.d.ts +31 -21
- package/lib-es/network/gateway.d.ts.map +1 -1
- package/lib-es/network/gateway.integ.test.js +30 -3
- package/lib-es/network/gateway.integ.test.js.map +1 -1
- package/lib-es/network/gateway.js +30 -8
- package/lib-es/network/gateway.js.map +1 -1
- package/lib-es/network/node.integ.test.js +4 -2
- package/lib-es/network/node.integ.test.js.map +1 -1
- package/lib-es/types/bridge.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/api/getBalance.integ.test.ts +28 -0
- package/src/api/lastBlock.integ.test.ts +3 -1
- package/src/api/listOperations.integ.test.ts +27 -0
- package/src/bridge/signOperation.ts +1 -1
- package/src/common-logic/account/getBalance.ts +20 -5
- package/src/common-logic/account/getBalance.unit.test.ts +63 -0
- package/src/common-logic/history/lastBlock.test.ts +47 -0
- package/src/common-logic/history/lastBlock.ts +6 -2
- package/src/common-logic/history/listOperations.ts +43 -52
- package/src/common-logic/transaction/broadcast.test.ts +42 -0
- package/src/common-logic/transaction/broadcast.ts +7 -3
- package/src/common-logic/transaction/combine.test.ts +28 -0
- package/src/common-logic/transaction/combine.ts +7 -4
- package/src/common-logic/transaction/estimateFees.ts +2 -14
- package/src/common-logic/utils.ts +0 -5
- package/src/config.ts +8 -2
- package/src/network/gateway.integ.test.ts +49 -3
- package/src/network/gateway.ts +67 -27
- package/src/network/node.integ.test.ts +4 -2
- package/src/types/bridge.ts +0 -1
package/lib-es/config.d.ts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import { type CurrencyConfig } from "@ledgerhq/coin-framework/config";
|
|
1
|
+
import { CoinConfig, type CurrencyConfig } from "@ledgerhq/coin-framework/config";
|
|
2
|
+
import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
2
3
|
export type CantonConfig = {
|
|
3
4
|
nodeUrl?: string;
|
|
5
|
+
nodeId?: string;
|
|
4
6
|
gatewayUrl?: string;
|
|
5
7
|
minReserve?: number;
|
|
6
8
|
networkType: "mainnet" | "devnet" | "localnet";
|
|
7
9
|
useGateway?: boolean;
|
|
10
|
+
nativeInstrumentId?: string;
|
|
8
11
|
};
|
|
9
12
|
export type CantonCoinConfig = CurrencyConfig & CantonConfig;
|
|
10
13
|
declare const coinConfig: {
|
|
11
|
-
setCoinConfig: (config:
|
|
12
|
-
getCoinConfig: (currency?:
|
|
14
|
+
setCoinConfig: (config: CoinConfig<CantonCoinConfig>) => void;
|
|
15
|
+
getCoinConfig: (currency?: CryptoCurrency) => CantonCoinConfig;
|
|
13
16
|
};
|
|
14
17
|
export default coinConfig;
|
|
15
18
|
//# sourceMappingURL=config.d.ts.map
|
package/lib-es/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAwB,EAAE,KAAK,cAAc,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAwB,EAAE,UAAU,EAAE,KAAK,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACnG,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,SAAS,GAAG,QAAQ,GAAG,UAAU,CAAC;IAC/C,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,cAAc,GAAG,YAAY,CAAC;AAE7D,QAAA,MAAM,UAAU,EAAE;IAChB,aAAa,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IAC9D,aAAa,EAAE,CAAC,QAAQ,CAAC,EAAE,cAAc,KAAK,gBAAgB,CAAC;CAC1B,CAAC;AAExC,eAAe,UAAU,CAAC"}
|
package/lib-es/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,eAAoD,MAAM,iCAAiC,CAAC;AAgBnG,MAAM,UAAU,GAGZ,eAAe,EAAoB,CAAC;AAExC,eAAe,UAAU,CAAC"}
|
|
@@ -14,8 +14,11 @@ type OnboardingSubmitResponse = {
|
|
|
14
14
|
public_key: string;
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
|
-
type
|
|
18
|
-
|
|
17
|
+
type TransactionSubmitResponse = {
|
|
18
|
+
updateId: string;
|
|
19
|
+
};
|
|
20
|
+
export type InstrumentBalance = {
|
|
21
|
+
instrument_id: string;
|
|
19
22
|
amount: number;
|
|
20
23
|
locked: boolean;
|
|
21
24
|
};
|
|
@@ -29,45 +32,52 @@ type Timestamp = {
|
|
|
29
32
|
};
|
|
30
33
|
type BaseEvent = {
|
|
31
34
|
type: string;
|
|
32
|
-
|
|
35
|
+
contract_id: string;
|
|
33
36
|
details: string;
|
|
34
37
|
};
|
|
35
|
-
type CreatedEvent = BaseEvent & {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
export type CreatedEvent = BaseEvent & {
|
|
39
|
+
template_id: {
|
|
40
|
+
package_id: string;
|
|
41
|
+
module_name: string;
|
|
42
|
+
entity_name: string;
|
|
40
43
|
};
|
|
41
44
|
signatories: string[];
|
|
42
45
|
observers: string[];
|
|
43
46
|
};
|
|
44
47
|
type ExercisedEvent = BaseEvent & {
|
|
45
|
-
|
|
48
|
+
template_id: {
|
|
46
49
|
packageId: string;
|
|
47
50
|
moduleName: string;
|
|
48
51
|
entityName: string;
|
|
49
52
|
};
|
|
50
53
|
choice: string;
|
|
51
54
|
consuming: boolean;
|
|
52
|
-
|
|
55
|
+
acting_parties: string[];
|
|
53
56
|
};
|
|
54
57
|
type Event = BaseEvent | CreatedEvent | ExercisedEvent;
|
|
55
|
-
type TxInfo = {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
export type TxInfo = {
|
|
59
|
+
update_id: string;
|
|
60
|
+
command_id: string;
|
|
61
|
+
workflow_id: string;
|
|
62
|
+
effective_at: Timestamp;
|
|
60
63
|
offset: number;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
events: Event[];
|
|
64
|
-
|
|
64
|
+
synchronizer_id: string;
|
|
65
|
+
record_time: Timestamp;
|
|
66
|
+
events: Record<string, Event>[];
|
|
67
|
+
trace_context: string;
|
|
65
68
|
};
|
|
66
69
|
export declare function prepareOnboarding(pubKey: string, pubKeyType: string): Promise<OnboardingPrepareResponse>;
|
|
67
70
|
export declare function submitOnboarding(prepareRequest: OnboardingPrepareRequest, prepareResponse: OnboardingPrepareResponse, signature: string): Promise<OnboardingSubmitResponse>;
|
|
71
|
+
export declare function submit(serializedTx: string, signature: string): Promise<TransactionSubmitResponse>;
|
|
68
72
|
export declare function getBalance(partyId: string): Promise<InstrumentBalance[]>;
|
|
69
|
-
export declare function
|
|
70
|
-
export declare function
|
|
73
|
+
export declare function getPartyById(partyId: string): Promise<PartyInfo>;
|
|
74
|
+
export declare function getPartyByPubKey(pubKey: string): Promise<PartyInfo>;
|
|
75
|
+
export declare function getTransactions(partyId: string, options?: {
|
|
76
|
+
cursor?: number | undefined;
|
|
77
|
+
minOffset?: number | undefined;
|
|
78
|
+
maxOffset?: number | undefined;
|
|
79
|
+
limit?: number | undefined;
|
|
80
|
+
}): Promise<{
|
|
71
81
|
next: number;
|
|
72
82
|
transactions: TxInfo[];
|
|
73
83
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gateway.d.ts","sourceRoot":"","sources":["../../src/network/gateway.ts"],"names":[],"mappings":"AAGA,KAAK,yBAAyB,GAAG;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,0BAA0B,EAAE,MAAM,CAAC;CACpC,CAAC;AAEF,KAAK,wBAAwB,GAAG;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAQF,KAAK,wBAAwB,GAAG;IAC9B,KAAK,EAAE;QACL,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;CACH,CAAC;
|
|
1
|
+
{"version":3,"file":"gateway.d.ts","sourceRoot":"","sources":["../../src/network/gateway.ts"],"names":[],"mappings":"AAGA,KAAK,yBAAyB,GAAG;IAC/B,QAAQ,EAAE,MAAM,CAAC;I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AAG,SAAS,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B,GACA,OAAO,CAAC;IACT,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC,CAUD;AAED,wBAAsB,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC,CAMpD"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import coinConfig from "../config";
|
|
2
|
-
import { getLedgerEnd, prepareOnboarding } from "./gateway";
|
|
2
|
+
import { getLedgerEnd, prepareOnboarding, getBalance, getTransactions, getPartyById, getPartyByPubKey, } from "./gateway";
|
|
3
3
|
describe("gateway (devnet)", () => {
|
|
4
4
|
beforeAll(() => {
|
|
5
5
|
coinConfig.setCoinConfig(() => ({
|
|
6
6
|
gatewayUrl: "https://canton-gateway.api.live.ledger-test.com",
|
|
7
|
+
useGateway: true,
|
|
7
8
|
networkType: "devnet",
|
|
8
9
|
status: {
|
|
9
10
|
type: "active",
|
|
@@ -12,12 +13,12 @@ describe("gateway (devnet)", () => {
|
|
|
12
13
|
});
|
|
13
14
|
describe("prepareOnboarding", () => {
|
|
14
15
|
it("should prepare onboarding", async () => {
|
|
15
|
-
const response = await prepareOnboarding("
|
|
16
|
+
const response = await prepareOnboarding("c59f7f29374d24506dd6490a5db472cf00958e195e146f3dc9c97f96d5c51097", "ed25519");
|
|
16
17
|
expect(response).toHaveProperty("party_id");
|
|
17
18
|
expect(response).toHaveProperty("party_name");
|
|
18
19
|
expect(response).toHaveProperty("public_key_fingerprint");
|
|
19
20
|
expect(response).toHaveProperty("topology_transactions_hash");
|
|
20
|
-
});
|
|
21
|
+
}, 30000);
|
|
21
22
|
});
|
|
22
23
|
describe("getLedgerEnd", () => {
|
|
23
24
|
it("should return ledger end", async () => {
|
|
@@ -25,5 +26,31 @@ describe("gateway (devnet)", () => {
|
|
|
25
26
|
expect(end).toBeGreaterThanOrEqual(0);
|
|
26
27
|
});
|
|
27
28
|
});
|
|
29
|
+
describe("getBalance", () => {
|
|
30
|
+
it("should return user balance", async () => {
|
|
31
|
+
const balance = await getBalance("party-4f2e1485107adf5f::122027c6dbbbdbffe0fa3122ae05175f3b9328e879e9ce96b670354deb64a45683c1");
|
|
32
|
+
expect(balance.length).toBeGreaterThanOrEqual(1);
|
|
33
|
+
expect(balance[0].amount).toBeGreaterThanOrEqual(0);
|
|
34
|
+
expect(balance[0].instrument_id.includes("Splice")).toBe(true);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
describe("getPartyById", () => {
|
|
38
|
+
it.skip("should return party info", async () => {
|
|
39
|
+
const party = await getPartyById("4f2e1485107adf5f");
|
|
40
|
+
expect(party).toBeDefined();
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
describe("getPartyByPubKey", () => {
|
|
44
|
+
it.skip("should return party info", async () => {
|
|
45
|
+
const party = await getPartyByPubKey("122027c6dbbbdbffe0fa3122ae05175f3b9328e879e9ce96b670354deb64a45683c1");
|
|
46
|
+
expect(party).toBeDefined();
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
describe("getTransactions", () => {
|
|
50
|
+
it("should return user transactions", async () => {
|
|
51
|
+
const { transactions } = await getTransactions("party-5f29bb32e9939939::12202becd8062a1d170209956cfd977fca76fcb4d2a892d08c77a7483f35a11d6440");
|
|
52
|
+
expect(transactions.length).toBeGreaterThanOrEqual(0);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
28
55
|
});
|
|
29
56
|
//# sourceMappingURL=gateway.integ.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gateway.integ.test.js","sourceRoot":"","sources":["../../src/network/gateway.integ.test.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,WAAW,CAAC;AACnC,OAAO,
|
|
1
|
+
{"version":3,"file":"gateway.integ.test.js","sourceRoot":"","sources":["../../src/network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8FAA8F,CAC/F,CAAC;YACF,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import network from "@ledgerhq/live-network";
|
|
2
2
|
import coinConfig from "../config";
|
|
3
3
|
const getGatewayUrl = () => coinConfig.getCoinConfig().gatewayUrl;
|
|
4
|
+
const getNodeId = () => coinConfig.getCoinConfig().nodeId || "ledger-live-devnet-prd";
|
|
4
5
|
export async function prepareOnboarding(pubKey, pubKeyType) {
|
|
5
6
|
const { data } = await network({
|
|
6
7
|
method: "POST",
|
|
7
|
-
url: `${getGatewayUrl()}/v1/node/
|
|
8
|
+
url: `${getGatewayUrl()}/v1/node/${getNodeId()}/onboarding/prepare`,
|
|
8
9
|
data: {
|
|
9
10
|
public_key: pubKey,
|
|
10
11
|
public_key_type: pubKeyType,
|
|
@@ -15,7 +16,7 @@ export async function prepareOnboarding(pubKey, pubKeyType) {
|
|
|
15
16
|
export async function submitOnboarding(prepareRequest, prepareResponse, signature) {
|
|
16
17
|
const { data } = await network({
|
|
17
18
|
method: "POST",
|
|
18
|
-
url: `${getGatewayUrl()}/v1/node/
|
|
19
|
+
url: `${getGatewayUrl()}/v1/node/${getNodeId()}/onboarding/submit`,
|
|
19
20
|
data: {
|
|
20
21
|
prepare_request: prepareRequest,
|
|
21
22
|
prepare_response: prepareResponse,
|
|
@@ -24,31 +25,52 @@ export async function submitOnboarding(prepareRequest, prepareResponse, signatur
|
|
|
24
25
|
});
|
|
25
26
|
return data;
|
|
26
27
|
}
|
|
28
|
+
export async function submit(serializedTx, signature) {
|
|
29
|
+
const { data } = await network({
|
|
30
|
+
method: "POST",
|
|
31
|
+
url: `${getGatewayUrl()}/v1/node/${getNodeId()}/transaction/submit`,
|
|
32
|
+
data: {
|
|
33
|
+
serialized: serializedTx,
|
|
34
|
+
signature,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
return data;
|
|
38
|
+
}
|
|
27
39
|
export async function getBalance(partyId) {
|
|
28
40
|
const { data } = await network({
|
|
29
41
|
method: "GET",
|
|
30
|
-
url: `${getGatewayUrl()}/v1/node/
|
|
42
|
+
url: `${getGatewayUrl()}/v1/node/${getNodeId()}/party/${partyId}/balance`,
|
|
31
43
|
});
|
|
32
44
|
return data;
|
|
33
45
|
}
|
|
34
|
-
export async function
|
|
46
|
+
export async function getPartyById(partyId) {
|
|
47
|
+
return await getParty(partyId, "ID");
|
|
48
|
+
}
|
|
49
|
+
export async function getPartyByPubKey(pubKey) {
|
|
50
|
+
return await getParty(pubKey, "PK");
|
|
51
|
+
}
|
|
52
|
+
async function getParty(identifier, by) {
|
|
35
53
|
const { data } = await network({
|
|
36
54
|
method: "GET",
|
|
37
|
-
url: `${getGatewayUrl()}/v1/node/
|
|
55
|
+
url: `${getGatewayUrl()}/v1/node/${getNodeId()}/party/${identifier}`,
|
|
56
|
+
data: {
|
|
57
|
+
by,
|
|
58
|
+
},
|
|
38
59
|
});
|
|
39
60
|
return data;
|
|
40
61
|
}
|
|
41
|
-
export async function getTransactions(partyId) {
|
|
62
|
+
export async function getTransactions(partyId, options) {
|
|
42
63
|
const { data } = await network({
|
|
43
64
|
method: "GET",
|
|
44
|
-
url: `${getGatewayUrl()}/v1/node/
|
|
65
|
+
url: `${getGatewayUrl()}/v1/node/${getNodeId()}/party/${partyId}/transactions`,
|
|
66
|
+
data: options,
|
|
45
67
|
});
|
|
46
68
|
return data;
|
|
47
69
|
}
|
|
48
70
|
export async function getLedgerEnd() {
|
|
49
71
|
const { data } = await network({
|
|
50
72
|
method: "GET",
|
|
51
|
-
url: `${getGatewayUrl()}/v1/node/
|
|
73
|
+
url: `${getGatewayUrl()}/v1/node/${getNodeId()}/ledger-end`,
|
|
52
74
|
});
|
|
53
75
|
return data;
|
|
54
76
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gateway.js","sourceRoot":"","sources":["../../src/network/gateway.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,wBAAwB,CAAC;AAC7C,OAAO,UAAU,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"gateway.js","sourceRoot":"","sources":["../../src/network/gateway.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,wBAAwB,CAAC;AAC7C,OAAO,UAAU,MAAM,WAAW,CAAC;AA2FnC,MAAM,aAAa,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC,UAAU,CAAC;AAClE,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC,MAAM,IAAI,wBAAwB,CAAC;AAEtF,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAAc,EACd,UAAkB;IAElB,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,OAAO,CAA4B;QACxD,MAAM,EAAE,MAAM;QACd,GAAG,EAAE,GAAG,aAAa,EAAE,YAAY,SAAS,EAAE,qBAAqB;QACnE,IAAI,EAAE;YACJ,UAAU,EAAE,MAAM;YAClB,eAAe,EAAE,UAAU;SACO;KACrC,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,cAAwC,EACxC,eAA0C,EAC1C,SAAiB;IAEjB,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,OAAO,CAA2B;QACvD,MAAM,EAAE,MAAM;QACd,GAAG,EAAE,GAAG,aAAa,EAAE,YAAY,SAAS,EAAE,oBAAoB;QAClE,IAAI,EAAE;YACJ,eAAe,EAAE,cAAc;YAC/B,gBAAgB,EAAE,eAAe;YACjC,SAAS;SACwB;KACpC,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,YAAoB,EA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AAU,OAAO,eAAe;QAC9E,IAAI,EAAE,OAAO;KACd,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY;IAChC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,OAAO,CAAS;QACrC,MAAM,EAAE,KAAK;QACb,GAAG,EAAE,GAAG,aAAa,EAAE,YAAY,SAAS,EAAE,aAAa;KAC5D,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import coinConfig from "../config";
|
|
2
2
|
import { getLedgerEnd } from "./node";
|
|
3
|
-
|
|
3
|
+
// enable manually, as it requires a running node locally
|
|
4
|
+
describe.skip("Node (localnet)", () => {
|
|
4
5
|
beforeAll(() => {
|
|
5
6
|
coinConfig.setCoinConfig(() => ({
|
|
6
7
|
gatewayUrl: "http://gateway.url",
|
|
@@ -16,7 +17,8 @@ describe("Node (localnet)", () => {
|
|
|
16
17
|
});
|
|
17
18
|
});
|
|
18
19
|
});
|
|
19
|
-
|
|
20
|
+
// enable manually, as it requires an auth token in env variable
|
|
21
|
+
describe.skip("Node (devnet)", () => {
|
|
20
22
|
beforeAll(() => {
|
|
21
23
|
coinConfig.setCoinConfig(() => ({
|
|
22
24
|
nodeUrl: "https://wallet-validator-devnet-canton.ledger-test.com/v2",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.integ.test.js","sourceRoot":"","sources":["../../src/network/node.integ.test.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;
|
|
1
|
+
{"version":3,"file":"node.integ.test.js","sourceRoot":"","sources":["../../src/network/node.integ.test.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,WAAW,CAAC;AACnC,OAAO,EA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AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../../src/types/bridge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../../src/types/bridge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EACV,iBAAiB,EACjB,oBAAoB,EACpB,uBAAuB,EACvB,0BAA0B,EAC3B,MAAM,sBAAsB,CAAC;AAE9B,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,QAAQ,CAAC;IACjB,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,EAAE,SAAS,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,QAAQ,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,iBAAiB,GAAG;IAC5C,MAAM,EAAE,QAAQ,CAAC;IACjB,GAAG,EAAE,SAAS,GAAG,IAAI,GAAG,SAAS,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,oBAAoB,GAAG;IAClD,MAAM,EAAE,QAAQ,CAAC;IACjB,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,uBAAuB,CAAC;AACxD,MAAM,MAAM,oBAAoB,GAAG,0BAA0B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/coin-canton",
|
|
3
|
-
"version": "0.4.0",
|
|
3
|
+
"version": "0.4.1-nightly.0",
|
|
4
4
|
"description": "Canton coin integration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ledger",
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"bignumber.js": "^9.1.2",
|
|
102
102
|
"invariant": "^2.2.4",
|
|
103
103
|
"rxjs": "^7.8.1",
|
|
104
|
-
"@ledgerhq/coin-framework": "^6.
|
|
104
|
+
"@ledgerhq/coin-framework": "^6.4.0-nightly.0",
|
|
105
105
|
"@ledgerhq/cryptoassets": "^13.27.0",
|
|
106
106
|
"@ledgerhq/devices": "8.5.1",
|
|
107
107
|
"@ledgerhq/errors": "^6.25.0",
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { AlpacaApi } from "@ledgerhq/coin-framework/lib/api/types";
|
|
2
|
+
import { createApi } from ".";
|
|
3
|
+
|
|
4
|
+
let api: AlpacaApi;
|
|
5
|
+
|
|
6
|
+
describe("devnet", () => {
|
|
7
|
+
beforeAll(() => {
|
|
8
|
+
api = createApi({
|
|
9
|
+
nodeUrl: "https://wallet-validator-devnet-canton.ledger-test.com/v2",
|
|
10
|
+
networkType: "devnet",
|
|
11
|
+
gatewayUrl: "https://canton-gateway.api.live.ledger-test.com",
|
|
12
|
+
useGateway: true,
|
|
13
|
+
nativeInstrumentId:
|
|
14
|
+
"6e9fc50fb94e56751b49f09ba2dc84da53a9d7cff08115ebb4f6b7a12d0c990c:Splice.Amulet:Amulet",
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
describe("getBalance", () => {
|
|
19
|
+
it("should return user balance", async () => {
|
|
20
|
+
const balance = await api.getBalance(
|
|
21
|
+
"party-4f2e1485107adf5f::122027c6dbbbdbffe0fa3122ae05175f3b9328e879e9ce96b670354deb64a45683c1",
|
|
22
|
+
);
|
|
23
|
+
expect(balance.length).toBeGreaterThanOrEqual(1);
|
|
24
|
+
const nativeBalance = balance.find(b => b.asset.type === "native");
|
|
25
|
+
expect(nativeBalance?.value).toBeGreaterThanOrEqual(0);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -4,7 +4,7 @@ import { CantonCoinConfig } from "../config";
|
|
|
4
4
|
|
|
5
5
|
let api: AlpacaApi;
|
|
6
6
|
|
|
7
|
-
describe("localnet", () => {
|
|
7
|
+
describe.skip("localnet", () => {
|
|
8
8
|
beforeAll(() => {
|
|
9
9
|
api = createApi({
|
|
10
10
|
nodeUrl: "http://localhost:2975/v2",
|
|
@@ -25,6 +25,8 @@ describe("devnet", () => {
|
|
|
25
25
|
api = createApi({
|
|
26
26
|
nodeUrl: "https://wallet-validator-devnet-canton.ledger-test.com/v2",
|
|
27
27
|
networkType: "devnet",
|
|
28
|
+
gatewayUrl: "https://canton-gateway.api.live.ledger-test.com",
|
|
29
|
+
useGateway: true,
|
|
28
30
|
});
|
|
29
31
|
});
|
|
30
32
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AlpacaApi } from "@ledgerhq/coin-framework/lib/api/types";
|
|
2
|
+
import { createApi } from ".";
|
|
3
|
+
|
|
4
|
+
let api: AlpacaApi;
|
|
5
|
+
|
|
6
|
+
describe("devnet", () => {
|
|
7
|
+
beforeAll(() => {
|
|
8
|
+
api = createApi({
|
|
9
|
+
nodeUrl: "https://wallet-validator-devnet-canton.ledger-test.com/v2",
|
|
10
|
+
networkType: "devnet",
|
|
11
|
+
gatewayUrl: "https://canton-gateway.api.live.ledger-test.com",
|
|
12
|
+
useGateway: true,
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
describe("listOperations", () => {
|
|
17
|
+
it("should return ops", async () => {
|
|
18
|
+
const ops = await api.listOperations(
|
|
19
|
+
"party-4f2e1485107adf5f::122027c6dbbbdbffe0fa3122ae05175f3b9328e879e9ce96b670354deb64a45683c1",
|
|
20
|
+
{
|
|
21
|
+
minHeight: 0,
|
|
22
|
+
},
|
|
23
|
+
);
|
|
24
|
+
expect(ops.length).toBeGreaterThan(0);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
import { Balance } from "@ledgerhq/coin-framework/api/types";
|
|
2
|
-
import {
|
|
2
|
+
import { getBalance as gatewayGetBalance, type InstrumentBalance } from "../../network/gateway";
|
|
3
|
+
import coinConfig from "../../config";
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
const useGateway = () => coinConfig.getCoinConfig().useGateway === true;
|
|
6
|
+
const getNativeId = () => coinConfig.getCoinConfig().nativeInstrumentId;
|
|
7
|
+
|
|
8
|
+
function adaptInstrument(instrument: InstrumentBalance): Balance {
|
|
9
|
+
return {
|
|
10
|
+
value: BigInt(instrument.amount),
|
|
11
|
+
locked: instrument.locked === true ? BigInt(instrument.amount) : BigInt(0),
|
|
12
|
+
asset:
|
|
13
|
+
getNativeId() === instrument.instrument_id
|
|
14
|
+
? { type: "native" }
|
|
15
|
+
: { type: "token", assetReference: instrument.instrument_id },
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export async function getBalance(partyId: string): Promise<Balance[]> {
|
|
20
|
+
if (useGateway())
|
|
21
|
+
return (await gatewayGetBalance(partyId)).map(instrument => adaptInstrument(instrument));
|
|
22
|
+
else throw new Error("Not implemented");
|
|
8
23
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { getBalance as getBalanceFromNetwork } from "../../network/gateway";
|
|
2
|
+
import * as coinConfigModule from "../../config";
|
|
3
|
+
import { getBalance } from "./getBalance";
|
|
4
|
+
import { Balance } from "@ledgerhq/coin-framework/api/types";
|
|
5
|
+
|
|
6
|
+
jest.mock("../../network/gateway", () => ({
|
|
7
|
+
getBalance: jest.fn(),
|
|
8
|
+
}));
|
|
9
|
+
|
|
10
|
+
describe("getBalance", () => {
|
|
11
|
+
const mockGetCoinConfig = jest.spyOn(coinConfigModule.default, "getCoinConfig");
|
|
12
|
+
|
|
13
|
+
afterEach(() => {
|
|
14
|
+
jest.clearAllMocks();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("should return adapted balances when useGateway is true", async () => {
|
|
18
|
+
mockGetCoinConfig.mockReturnValue({
|
|
19
|
+
useGateway: true,
|
|
20
|
+
nativeInstrumentId: "native-id",
|
|
21
|
+
} as any);
|
|
22
|
+
|
|
23
|
+
const mockInstruments = [
|
|
24
|
+
{
|
|
25
|
+
instrument_id: "native-id",
|
|
26
|
+
amount: "1000",
|
|
27
|
+
locked: false,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
instrument_id: "token-123",
|
|
31
|
+
amount: "5000",
|
|
32
|
+
locked: true,
|
|
33
|
+
},
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
(getBalanceFromNetwork as jest.Mock).mockResolvedValue(mockInstruments);
|
|
37
|
+
|
|
38
|
+
const result = await getBalance("party-id");
|
|
39
|
+
|
|
40
|
+
expect(getBalanceFromNetwork).toHaveBeenCalledWith("party-id");
|
|
41
|
+
expect(result).toEqual<Balance[]>([
|
|
42
|
+
{
|
|
43
|
+
value: BigInt(1000),
|
|
44
|
+
locked: BigInt(0),
|
|
45
|
+
asset: { type: "native" },
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
value: BigInt(5000),
|
|
49
|
+
locked: BigInt(5000),
|
|
50
|
+
asset: { type: "token", assetReference: "token-123" },
|
|
51
|
+
},
|
|
52
|
+
]);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("should throw an error when useGateway is false (not implemented with node)", async () => {
|
|
56
|
+
mockGetCoinConfig.mockReturnValue({
|
|
57
|
+
useGateway: false,
|
|
58
|
+
} as any);
|
|
59
|
+
|
|
60
|
+
await expect(getBalance("party-id")).rejects.toThrow("Not implemented");
|
|
61
|
+
expect(getBalanceFromNetwork).not.toHaveBeenCalled();
|
|
62
|
+
});
|
|
63
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { lastBlock } from "./lastBlock";
|
|
2
|
+
import { getLedgerEnd as gatewayGetLedgerEnd } from "../../network/gateway";
|
|
3
|
+
import { getLedgerEnd as nodeGetLedgerEnd } from "../../network/node";
|
|
4
|
+
|
|
5
|
+
jest.mock("../../network/gateway", () => ({
|
|
6
|
+
getLedgerEnd: jest.fn(),
|
|
7
|
+
}));
|
|
8
|
+
jest.mock("../../network/node", () => ({
|
|
9
|
+
getLedgerEnd: jest.fn(),
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
jest.mock("../../config", () => ({
|
|
13
|
+
__esModule: true,
|
|
14
|
+
default: {
|
|
15
|
+
getCoinConfig: jest.fn(),
|
|
16
|
+
},
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
import coinConfig from "../../config";
|
|
20
|
+
|
|
21
|
+
describe("lastBlock", () => {
|
|
22
|
+
beforeEach(() => {
|
|
23
|
+
jest.clearAllMocks();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("should use gateway.getLedgerEnd when useGateway is true", async () => {
|
|
27
|
+
(coinConfig.getCoinConfig as jest.Mock).mockReturnValue({ useGateway: true });
|
|
28
|
+
(gatewayGetLedgerEnd as jest.Mock).mockResolvedValue(100);
|
|
29
|
+
|
|
30
|
+
const result = await lastBlock();
|
|
31
|
+
|
|
32
|
+
expect(result).toEqual({ height: 100 });
|
|
33
|
+
expect(gatewayGetLedgerEnd).toHaveBeenCalledTimes(1);
|
|
34
|
+
expect(nodeGetLedgerEnd).not.toHaveBeenCalled();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("should use node.getLedgerEnd when useGateway is false", async () => {
|
|
38
|
+
(coinConfig.getCoinConfig as jest.Mock).mockReturnValue({ useGateway: false });
|
|
39
|
+
(nodeGetLedgerEnd as jest.Mock).mockResolvedValue(200);
|
|
40
|
+
|
|
41
|
+
const result = await lastBlock();
|
|
42
|
+
|
|
43
|
+
expect(result).toEqual({ height: 200 });
|
|
44
|
+
expect(nodeGetLedgerEnd).toHaveBeenCalledTimes(1);
|
|
45
|
+
expect(gatewayGetLedgerEnd).not.toHaveBeenCalled();
|
|
46
|
+
});
|
|
47
|
+
});
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import type { BlockInfo } from "@ledgerhq/coin-framework/api/index";
|
|
2
|
-
import { getLedgerEnd } from "../../network/node";
|
|
2
|
+
import { getLedgerEnd as nodeGetLedgerEnd } from "../../network/node";
|
|
3
|
+
import { getLedgerEnd } from "../../network/gateway";
|
|
4
|
+
import coinConfig from "../../config";
|
|
5
|
+
|
|
6
|
+
const useGateway = () => coinConfig.getCoinConfig().useGateway === true;
|
|
3
7
|
|
|
4
8
|
export async function lastBlock(): Promise<BlockInfo> {
|
|
5
9
|
return {
|
|
6
|
-
height: await getLedgerEnd(),
|
|
10
|
+
height: useGateway() ? await getLedgerEnd() : await nodeGetLedgerEnd(),
|
|
7
11
|
};
|
|
8
12
|
}
|