@ledgerhq/coin-canton 0.4.0-nightly.3 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +21 -34
- package/jest.config.js +0 -1
- package/lib/api/lastBlock.integ.test.js +1 -3
- package/lib/api/lastBlock.integ.test.js.map +1 -1
- 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 +5 -21
- package/lib/common-logic/account/getBalance.js.map +1 -1
- package/lib/common-logic/history/lastBlock.d.ts.map +1 -1
- package/lib/common-logic/history/lastBlock.js +1 -7
- package/lib/common-logic/history/lastBlock.js.map +1 -1
- package/lib/common-logic/history/listOperations.d.ts +4 -3
- package/lib/common-logic/history/listOperations.d.ts.map +1 -1
- package/lib/common-logic/history/listOperations.js +41 -43
- 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 +3 -11
- package/lib/common-logic/transaction/broadcast.js.map +1 -1
- 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 +3 -6
- package/lib/common-logic/transaction/combine.js.map +1 -1
- package/lib/common-logic/transaction/estimateFees.d.ts.map +1 -1
- package/lib/common-logic/transaction/estimateFees.js +15 -2
- package/lib/common-logic/transaction/estimateFees.js.map +1 -1
- package/lib/common-logic/utils.d.ts +1 -0
- package/lib/common-logic/utils.d.ts.map +1 -1
- package/lib/common-logic/utils.js +6 -1
- package/lib/common-logic/utils.js.map +1 -1
- package/lib/config.d.ts +3 -6
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js.map +1 -1
- package/lib/network/gateway.d.ts +21 -31
- package/lib/network/gateway.d.ts.map +1 -1
- package/lib/network/gateway.integ.test.js +2 -29
- package/lib/network/gateway.integ.test.js.map +1 -1
- package/lib/network/gateway.js +9 -33
- package/lib/network/gateway.js.map +1 -1
- package/lib/network/node.integ.test.js +2 -4
- package/lib/network/node.integ.test.js.map +1 -1
- package/lib/types/bridge.d.ts.map +1 -1
- package/lib-es/api/lastBlock.integ.test.js +1 -3
- package/lib-es/api/lastBlock.integ.test.js.map +1 -1
- 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 +5 -18
- package/lib-es/common-logic/account/getBalance.js.map +1 -1
- package/lib-es/common-logic/history/lastBlock.d.ts.map +1 -1
- package/lib-es/common-logic/history/lastBlock.js +2 -5
- package/lib-es/common-logic/history/lastBlock.js.map +1 -1
- package/lib-es/common-logic/history/listOperations.d.ts +4 -3
- package/lib-es/common-logic/history/listOperations.d.ts.map +1 -1
- package/lib-es/common-logic/history/listOperations.js +41 -40
- 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 +3 -8
- package/lib-es/common-logic/transaction/broadcast.js.map +1 -1
- 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 +3 -6
- package/lib-es/common-logic/transaction/combine.js.map +1 -1
- package/lib-es/common-logic/transaction/estimateFees.d.ts.map +1 -1
- package/lib-es/common-logic/transaction/estimateFees.js +15 -2
- package/lib-es/common-logic/transaction/estimateFees.js.map +1 -1
- package/lib-es/common-logic/utils.d.ts +1 -0
- package/lib-es/common-logic/utils.d.ts.map +1 -1
- package/lib-es/common-logic/utils.js +4 -0
- package/lib-es/common-logic/utils.js.map +1 -1
- package/lib-es/config.d.ts +3 -6
- package/lib-es/config.d.ts.map +1 -1
- package/lib-es/config.js.map +1 -1
- package/lib-es/network/gateway.d.ts +21 -31
- package/lib-es/network/gateway.d.ts.map +1 -1
- package/lib-es/network/gateway.integ.test.js +3 -30
- package/lib-es/network/gateway.integ.test.js.map +1 -1
- package/lib-es/network/gateway.js +8 -30
- package/lib-es/network/gateway.js.map +1 -1
- package/lib-es/network/node.integ.test.js +2 -4
- package/lib-es/network/node.integ.test.js.map +1 -1
- package/lib-es/types/bridge.d.ts.map +1 -1
- package/package.json +9 -9
- package/src/api/lastBlock.integ.test.ts +1 -3
- package/src/bridge/signOperation.ts +1 -1
- package/src/common-logic/account/getBalance.ts +5 -20
- package/src/common-logic/history/lastBlock.ts +2 -6
- package/src/common-logic/history/listOperations.ts +52 -43
- package/src/common-logic/transaction/broadcast.ts +3 -7
- package/src/common-logic/transaction/combine.ts +4 -7
- package/src/common-logic/transaction/estimateFees.ts +14 -2
- package/src/common-logic/utils.ts +5 -0
- package/src/config.ts +2 -8
- package/src/network/gateway.integ.test.ts +3 -49
- package/src/network/gateway.ts +27 -67
- package/src/network/node.integ.test.ts +2 -4
- package/src/types/bridge.ts +1 -0
- package/lib/api/getBalance.integ.test.d.ts +0 -2
- package/lib/api/getBalance.integ.test.d.ts.map +0 -1
- package/lib/api/getBalance.integ.test.js +0 -24
- package/lib/api/getBalance.integ.test.js.map +0 -1
- package/lib/api/listOperations.integ.test.d.ts +0 -2
- package/lib/api/listOperations.integ.test.d.ts.map +0 -1
- package/lib/api/listOperations.integ.test.js +0 -23
- package/lib/api/listOperations.integ.test.js.map +0 -1
- package/lib/common-logic/account/getBalance.unit.test.d.ts +0 -2
- package/lib/common-logic/account/getBalance.unit.test.d.ts.map +0 -1
- package/lib/common-logic/account/getBalance.unit.test.js +0 -88
- package/lib/common-logic/account/getBalance.unit.test.js.map +0 -1
- package/lib/common-logic/history/lastBlock.test.d.ts +0 -2
- package/lib/common-logic/history/lastBlock.test.d.ts.map +0 -1
- package/lib/common-logic/history/lastBlock.test.js +0 -43
- package/lib/common-logic/history/lastBlock.test.js.map +0 -1
- package/lib/common-logic/transaction/broadcast.test.d.ts +0 -2
- package/lib/common-logic/transaction/broadcast.test.d.ts.map +0 -1
- package/lib/common-logic/transaction/broadcast.test.js +0 -68
- package/lib/common-logic/transaction/broadcast.test.js.map +0 -1
- package/lib/common-logic/transaction/combine.test.d.ts +0 -2
- package/lib/common-logic/transaction/combine.test.d.ts.map +0 -1
- package/lib/common-logic/transaction/combine.test.js +0 -28
- package/lib/common-logic/transaction/combine.test.js.map +0 -1
- package/lib-es/api/getBalance.integ.test.d.ts +0 -2
- package/lib-es/api/getBalance.integ.test.d.ts.map +0 -1
- package/lib-es/api/getBalance.integ.test.js +0 -22
- package/lib-es/api/getBalance.integ.test.js.map +0 -1
- package/lib-es/api/listOperations.integ.test.d.ts +0 -2
- package/lib-es/api/listOperations.integ.test.d.ts.map +0 -1
- package/lib-es/api/listOperations.integ.test.js +0 -21
- package/lib-es/api/listOperations.integ.test.js.map +0 -1
- package/lib-es/common-logic/account/getBalance.unit.test.d.ts +0 -2
- package/lib-es/common-logic/account/getBalance.unit.test.d.ts.map +0 -1
- package/lib-es/common-logic/account/getBalance.unit.test.js +0 -53
- package/lib-es/common-logic/account/getBalance.unit.test.js.map +0 -1
- package/lib-es/common-logic/history/lastBlock.test.d.ts +0 -2
- package/lib-es/common-logic/history/lastBlock.test.d.ts.map +0 -1
- package/lib-es/common-logic/history/lastBlock.test.js +0 -38
- package/lib-es/common-logic/history/lastBlock.test.js.map +0 -1
- package/lib-es/common-logic/transaction/broadcast.test.d.ts +0 -2
- package/lib-es/common-logic/transaction/broadcast.test.d.ts.map +0 -1
- package/lib-es/common-logic/transaction/broadcast.test.js +0 -33
- package/lib-es/common-logic/transaction/broadcast.test.js.map +0 -1
- package/lib-es/common-logic/transaction/combine.test.d.ts +0 -2
- package/lib-es/common-logic/transaction/combine.test.d.ts.map +0 -1
- package/lib-es/common-logic/transaction/combine.test.js +0 -26
- package/lib-es/common-logic/transaction/combine.test.js.map +0 -1
- package/src/api/getBalance.integ.test.ts +0 -28
- package/src/api/listOperations.integ.test.ts +0 -27
- package/src/common-logic/account/getBalance.unit.test.ts +0 -63
- package/src/common-logic/history/lastBlock.test.ts +0 -47
- package/src/common-logic/transaction/broadcast.test.ts +0 -42
- package/src/common-logic/transaction/combine.test.ts +0 -28
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combine.js","sourceRoot":"","sources":["../../../src/common-logic/transaction/combine.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,MAAM,UAAU,OAAO,CAAC,WAAmB,EAAE,SAAiB
|
|
1
|
+
{"version":3,"file":"combine.js","sourceRoot":"","sources":["../../../src/common-logic/transaction/combine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,0CAA0C;AAC1C,MAAM,UAAU,OAAO,CAAC,WAAmB,EAAE,SAAiB,EAAE,SAAkB;IAChF,OAAO,MAAM,CAAC,WAAW,EAAE,SAAS,EAAE,SAAS,IAAI,EAAE,CAAC,CAAC;AACzD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"estimateFees.d.ts","sourceRoot":"","sources":["../../../src/common-logic/transaction/estimateFees.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"estimateFees.d.ts","sourceRoot":"","sources":["../../../src/common-logic/transaction/estimateFees.ts"],"names":[],"mappings":"AAGA,wBAAsB,YAAY,CAAC,qBAAqB,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAYjF"}
|
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
import { simulate } from "../../network/node";
|
|
2
|
+
import { SimulationError } from "../../types/errors";
|
|
2
3
|
export async function estimateFees(serializedTransaction) {
|
|
3
|
-
|
|
4
|
+
try {
|
|
5
|
+
// We call the node to do a dry run and estimate fees
|
|
6
|
+
return BigInt(await simulate(serializedTransaction));
|
|
7
|
+
}
|
|
8
|
+
catch (e) {
|
|
9
|
+
// default value is required in case of simulation error, else user will encounter an error in the flow
|
|
10
|
+
if (e instanceof SimulationError) {
|
|
11
|
+
return BigInt(1000);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
throw new Error("Unexpected error while estimating fees.");
|
|
15
|
+
}
|
|
16
|
+
}
|
|
4
17
|
}
|
|
5
18
|
//# sourceMappingURL=estimateFees.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"estimateFees.js","sourceRoot":"","sources":["../../../src/common-logic/transaction/estimateFees.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"estimateFees.js","sourceRoot":"","sources":["../../../src/common-logic/transaction/estimateFees.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,qBAA6B;IAC9D,IAAI,CAAC;QACH,qDAAqD;QACrD,OAAO,MAAM,CAAC,MAAM,QAAQ,CAAC,qBAAqB,CAAC,CAAC,CAAC;IACvD,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,uGAAuG;QACvG,IAAI,CAAC,YAAY,eAAe,EAAE,CAAC;YACjC,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -2,4 +2,5 @@ import BigNumber from "bignumber.js";
|
|
|
2
2
|
export declare const UINT32_MAX: BigNumber;
|
|
3
3
|
export declare const validateTag: (tag: BigNumber) => boolean;
|
|
4
4
|
export declare function isRecipientValid(recipient: string): boolean;
|
|
5
|
+
export declare const encode: (transaction: string, signature: string, publicKey?: string) => string;
|
|
5
6
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/common-logic/utils.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,eAAO,MAAM,UAAU,WAAoC,CAAC;AAE5D,eAAO,MAAM,WAAW,GAAI,KAAK,SAAS,YAIzC,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAE3D"}
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/common-logic/utils.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,eAAO,MAAM,UAAU,WAAoC,CAAC;AAE5D,eAAO,MAAM,WAAW,GAAI,KAAK,SAAS,YAIzC,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAE3D;AAED,eAAO,MAAM,MAAM,GAAI,aAAa,MAAM,EAAE,WAAW,MAAM,EAAE,YAAY,MAAM,WAGhF,CAAC"}
|
|
@@ -6,4 +6,8 @@ export const validateTag = (tag) => {
|
|
|
6
6
|
export function isRecipientValid(recipient) {
|
|
7
7
|
return recipient.length > 0;
|
|
8
8
|
}
|
|
9
|
+
export const encode = (transaction, signature, publicKey) => {
|
|
10
|
+
// sample encoding
|
|
11
|
+
return `${transaction}${publicKey}${signature}encodedTx`;
|
|
12
|
+
};
|
|
9
13
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/common-logic/utils.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,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CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
1
|
+
import { type CurrencyConfig } from "@ledgerhq/coin-framework/config";
|
|
3
2
|
export type CantonConfig = {
|
|
4
3
|
nodeUrl?: string;
|
|
5
|
-
nodeId?: string;
|
|
6
4
|
gatewayUrl?: string;
|
|
7
5
|
minReserve?: number;
|
|
8
6
|
networkType: "mainnet" | "devnet" | "localnet";
|
|
9
7
|
useGateway?: boolean;
|
|
10
|
-
nativeInstrumentId?: string;
|
|
11
8
|
};
|
|
12
9
|
export type CantonCoinConfig = CurrencyConfig & CantonConfig;
|
|
13
10
|
declare const coinConfig: {
|
|
14
|
-
setCoinConfig: (config: CoinConfig<CantonCoinConfig>) => void;
|
|
15
|
-
getCoinConfig: (currency?: CryptoCurrency) => CantonCoinConfig;
|
|
11
|
+
setCoinConfig: (config: import("@ledgerhq/coin-framework/config").CoinConfig<CantonCoinConfig>) => void;
|
|
12
|
+
getCoinConfig: (currency?: import("@ledgerhq/types-cryptoassets").CryptoCurrency) => CantonCoinConfig;
|
|
16
13
|
};
|
|
17
14
|
export default coinConfig;
|
|
18
15
|
//# 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,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAwB,EAAE,KAAK,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEvF,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,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;CACtB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,cAAc,GAAG,YAAY,CAAC;AAE7D,QAAA,MAAM,UAAU;;;CAAsC,CAAC;AAEvD,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,eAAwC,MAAM,iCAAiC,CAAC;AAavF,MAAM,UAAU,GAAG,eAAe,EAAoB,CAAC;AAEvD,eAAe,UAAU,CAAC"}
|
|
@@ -14,11 +14,8 @@ type OnboardingSubmitResponse = {
|
|
|
14
14
|
public_key: string;
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
|
-
type
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
export type InstrumentBalance = {
|
|
21
|
-
instrument_id: string;
|
|
17
|
+
type InstrumentBalance = {
|
|
18
|
+
instrumentId: string;
|
|
22
19
|
amount: number;
|
|
23
20
|
locked: boolean;
|
|
24
21
|
};
|
|
@@ -32,52 +29,45 @@ type Timestamp = {
|
|
|
32
29
|
};
|
|
33
30
|
type BaseEvent = {
|
|
34
31
|
type: string;
|
|
35
|
-
|
|
32
|
+
contractId: string;
|
|
36
33
|
details: string;
|
|
37
34
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
type CreatedEvent = BaseEvent & {
|
|
36
|
+
templateId: {
|
|
37
|
+
packageId: string;
|
|
38
|
+
moduleName: string;
|
|
39
|
+
entityName: string;
|
|
43
40
|
};
|
|
44
41
|
signatories: string[];
|
|
45
42
|
observers: string[];
|
|
46
43
|
};
|
|
47
44
|
type ExercisedEvent = BaseEvent & {
|
|
48
|
-
|
|
45
|
+
templateId: {
|
|
49
46
|
packageId: string;
|
|
50
47
|
moduleName: string;
|
|
51
48
|
entityName: string;
|
|
52
49
|
};
|
|
53
50
|
choice: string;
|
|
54
51
|
consuming: boolean;
|
|
55
|
-
|
|
52
|
+
actingParties: string[];
|
|
56
53
|
};
|
|
57
54
|
type Event = BaseEvent | CreatedEvent | ExercisedEvent;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
55
|
+
type TxInfo = {
|
|
56
|
+
updateId: string;
|
|
57
|
+
commandId: string;
|
|
58
|
+
workflowId: string;
|
|
59
|
+
effectiveAt: Timestamp;
|
|
63
60
|
offset: number;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
events:
|
|
67
|
-
|
|
61
|
+
synchronizerId: string;
|
|
62
|
+
recordTime: Timestamp;
|
|
63
|
+
events: Event[];
|
|
64
|
+
traceContext: string;
|
|
68
65
|
};
|
|
69
66
|
export declare function prepareOnboarding(pubKey: string, pubKeyType: string): Promise<OnboardingPrepareResponse>;
|
|
70
67
|
export declare function submitOnboarding(prepareRequest: OnboardingPrepareRequest, prepareResponse: OnboardingPrepareResponse, signature: string): Promise<OnboardingSubmitResponse>;
|
|
71
|
-
export declare function submit(serializedTx: string, signature: string): Promise<TransactionSubmitResponse>;
|
|
72
68
|
export declare function getBalance(partyId: string): Promise<InstrumentBalance[]>;
|
|
73
|
-
export declare function
|
|
74
|
-
export declare function
|
|
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<{
|
|
69
|
+
export declare function getParty(partyId: string): Promise<PartyInfo>;
|
|
70
|
+
export declare function getTransactions(partyId: string): Promise<{
|
|
81
71
|
next: number;
|
|
82
72
|
transactions: TxInfo[];
|
|
83
73
|
}>;
|
|
@@ -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;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;AAEF,KAAK,iBAAiB,GAAG;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,KAAK,SAAS,GAAG;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,KAAK,SAAS,GAAG;IACf,OAAO,EAAE,MAAM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AC1C,SAAS,EAAE,MAAM,qCAYlB;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAM9E;AAED,wBAAsB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAMlE;AAED,wBAAsB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;IAC9D,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC,CASD;AAED,wBAAsB,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC,CAMpD"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import coinConfig from "../config";
|
|
2
|
-
import { getLedgerEnd, prepareOnboarding
|
|
2
|
+
import { getLedgerEnd, prepareOnboarding } 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,
|
|
8
7
|
networkType: "devnet",
|
|
9
8
|
status: {
|
|
10
9
|
type: "active",
|
|
@@ -13,12 +12,12 @@ describe("gateway (devnet)", () => {
|
|
|
13
12
|
});
|
|
14
13
|
describe("prepareOnboarding", () => {
|
|
15
14
|
it("should prepare onboarding", async () => {
|
|
16
|
-
const response = await prepareOnboarding("
|
|
15
|
+
const response = await prepareOnboarding("0x043b462de34ec31fba274f2a381947aef26697912194312fc289c46cc1b2b4f6b00828dc1e4f96001b10463083edf85f2e0550862a3dc99ed411ca6d25f2bc19a8", "ed25519");
|
|
17
16
|
expect(response).toHaveProperty("party_id");
|
|
18
17
|
expect(response).toHaveProperty("party_name");
|
|
19
18
|
expect(response).toHaveProperty("public_key_fingerprint");
|
|
20
19
|
expect(response).toHaveProperty("topology_transactions_hash");
|
|
21
|
-
}
|
|
20
|
+
});
|
|
22
21
|
});
|
|
23
22
|
describe("getLedgerEnd", () => {
|
|
24
23
|
it("should return ledger end", async () => {
|
|
@@ -26,31 +25,5 @@ describe("gateway (devnet)", () => {
|
|
|
26
25
|
expect(end).toBeGreaterThanOrEqual(0);
|
|
27
26
|
});
|
|
28
27
|
});
|
|
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
|
-
});
|
|
55
28
|
});
|
|
56
29
|
//# sourceMappingURL=gateway.integ.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gateway.integ.test.js","sourceRoot":"","sources":["../../src/network/gateway.integ.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AC,CAAC;QACxC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,11 +1,10 @@
|
|
|
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";
|
|
5
4
|
export async function prepareOnboarding(pubKey, pubKeyType) {
|
|
6
5
|
const { data } = await network({
|
|
7
6
|
method: "POST",
|
|
8
|
-
url: `${getGatewayUrl()}/v1/node
|
|
7
|
+
url: `${getGatewayUrl()}/v1/node/0/onboarding/prepare`,
|
|
9
8
|
data: {
|
|
10
9
|
public_key: pubKey,
|
|
11
10
|
public_key_type: pubKeyType,
|
|
@@ -16,7 +15,7 @@ export async function prepareOnboarding(pubKey, pubKeyType) {
|
|
|
16
15
|
export async function submitOnboarding(prepareRequest, prepareResponse, signature) {
|
|
17
16
|
const { data } = await network({
|
|
18
17
|
method: "POST",
|
|
19
|
-
url: `${getGatewayUrl()}/v1/node
|
|
18
|
+
url: `${getGatewayUrl()}/v1/node/0/onboarding/submit`,
|
|
20
19
|
data: {
|
|
21
20
|
prepare_request: prepareRequest,
|
|
22
21
|
prepare_response: prepareResponse,
|
|
@@ -25,52 +24,31 @@ export async function submitOnboarding(prepareRequest, prepareResponse, signatur
|
|
|
25
24
|
});
|
|
26
25
|
return data;
|
|
27
26
|
}
|
|
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
|
-
}
|
|
39
27
|
export async function getBalance(partyId) {
|
|
40
28
|
const { data } = await network({
|
|
41
29
|
method: "GET",
|
|
42
|
-
url: `${getGatewayUrl()}/v1/node
|
|
30
|
+
url: `${getGatewayUrl()}/v1/node/0/party/${partyId}/balance`,
|
|
43
31
|
});
|
|
44
32
|
return data;
|
|
45
33
|
}
|
|
46
|
-
export async function
|
|
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) {
|
|
34
|
+
export async function getParty(partyId) {
|
|
53
35
|
const { data } = await network({
|
|
54
36
|
method: "GET",
|
|
55
|
-
url: `${getGatewayUrl()}/v1/node
|
|
56
|
-
data: {
|
|
57
|
-
by,
|
|
58
|
-
},
|
|
37
|
+
url: `${getGatewayUrl()}/v1/node/0/party/${partyId}`,
|
|
59
38
|
});
|
|
60
39
|
return data;
|
|
61
40
|
}
|
|
62
|
-
export async function getTransactions(partyId
|
|
41
|
+
export async function getTransactions(partyId) {
|
|
63
42
|
const { data } = await network({
|
|
64
43
|
method: "GET",
|
|
65
|
-
url: `${getGatewayUrl()}/v1/node
|
|
66
|
-
data: options,
|
|
44
|
+
url: `${getGatewayUrl()}/v1/node/0/party/${partyId}/transactions`,
|
|
67
45
|
});
|
|
68
46
|
return data;
|
|
69
47
|
}
|
|
70
48
|
export async function getLedgerEnd() {
|
|
71
49
|
const { data } = await network({
|
|
72
50
|
method: "GET",
|
|
73
|
-
url: `${getGatewayUrl()}/v1/node
|
|
51
|
+
url: `${getGatewayUrl()}/v1/node/0/ledger-end`,
|
|
74
52
|
});
|
|
75
53
|
return data;
|
|
76
54
|
}
|
|
@@ -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;
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C,MAAM,EAAE,KAAK;QACb,GAAG,EAAE,GAAG,aAAa,EAAE,oBAAoB,OAAO,EAAE;KACrD,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,OAAe;IAInD,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,OAAO,CAG3B;QACD,MAAM,EAAE,KAAK;QACb,GAAG,EAAE,GAAG,aAAa,EAAE,oBAAoB,OAAO,eAAe;KAClE,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,uBAAuB;KAC/C,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import coinConfig from "../config";
|
|
2
2
|
import { getLedgerEnd } from "./node";
|
|
3
|
-
|
|
4
|
-
describe.skip("Node (localnet)", () => {
|
|
3
|
+
describe("Node (localnet)", () => {
|
|
5
4
|
beforeAll(() => {
|
|
6
5
|
coinConfig.setCoinConfig(() => ({
|
|
7
6
|
gatewayUrl: "http://gateway.url",
|
|
@@ -17,8 +16,7 @@ describe.skip("Node (localnet)", () => {
|
|
|
17
16
|
});
|
|
18
17
|
});
|
|
19
18
|
});
|
|
20
|
-
|
|
21
|
-
describe.skip("Node (devnet)", () => {
|
|
19
|
+
describe("Node (devnet)", () => {
|
|
22
20
|
beforeAll(() => {
|
|
23
21
|
coinConfig.setCoinConfig(() => ({
|
|
24
22
|
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,M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xC,MAAM,GAAG,GAAG,MAAM,YAAY,EAAE,CAAC;YACjC,MAAM,CAAC,GAAG,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;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;AAE9C,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.0",
|
|
4
4
|
"description": "Canton coin integration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ledger",
|
|
@@ -101,13 +101,13 @@
|
|
|
101
101
|
"bignumber.js": "^9.1.2",
|
|
102
102
|
"invariant": "^2.2.4",
|
|
103
103
|
"rxjs": "^7.8.1",
|
|
104
|
-
"@ledgerhq/coin-framework": "^6.3.0
|
|
105
|
-
"@ledgerhq/cryptoassets": "^13.27.0
|
|
106
|
-
"@ledgerhq/devices": "8.5.1
|
|
107
|
-
"@ledgerhq/errors": "^6.25.0
|
|
108
|
-
"@ledgerhq/live-env": "^2.15.0
|
|
109
|
-
"@ledgerhq/live-network": "^2.0.16
|
|
110
|
-
"@ledgerhq/types-live": "^6.83.0
|
|
104
|
+
"@ledgerhq/coin-framework": "^6.3.0",
|
|
105
|
+
"@ledgerhq/cryptoassets": "^13.27.0",
|
|
106
|
+
"@ledgerhq/devices": "8.5.1",
|
|
107
|
+
"@ledgerhq/errors": "^6.25.0",
|
|
108
|
+
"@ledgerhq/live-env": "^2.15.0",
|
|
109
|
+
"@ledgerhq/live-network": "^2.0.16",
|
|
110
|
+
"@ledgerhq/types-live": "^6.83.0"
|
|
111
111
|
},
|
|
112
112
|
"devDependencies": {
|
|
113
113
|
"@types/invariant": "^2.2.37",
|
|
@@ -117,7 +117,7 @@
|
|
|
117
117
|
"jest": "^29.7.0",
|
|
118
118
|
"ts-jest": "^29.1.1",
|
|
119
119
|
"typescript": "^5.4.5",
|
|
120
|
-
"@ledgerhq/types-cryptoassets": "^7.26.0
|
|
120
|
+
"@ledgerhq/types-cryptoassets": "^7.26.0",
|
|
121
121
|
"@ledgerhq/disable-network-setup": "^0.0.0"
|
|
122
122
|
},
|
|
123
123
|
"scripts": {
|
|
@@ -4,7 +4,7 @@ import { CantonCoinConfig } from "../config";
|
|
|
4
4
|
|
|
5
5
|
let api: AlpacaApi;
|
|
6
6
|
|
|
7
|
-
describe
|
|
7
|
+
describe("localnet", () => {
|
|
8
8
|
beforeAll(() => {
|
|
9
9
|
api = createApi({
|
|
10
10
|
nodeUrl: "http://localhost:2975/v2",
|
|
@@ -25,8 +25,6 @@ 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,
|
|
30
28
|
});
|
|
31
29
|
});
|
|
32
30
|
|
|
@@ -1,23 +1,8 @@
|
|
|
1
1
|
import { Balance } from "@ledgerhq/coin-framework/api/types";
|
|
2
|
-
import {
|
|
3
|
-
import coinConfig from "../../config";
|
|
2
|
+
import { getAccountInfo } from "../../network/node";
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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");
|
|
4
|
+
// Could be getAccountInfo so it is used in both bridge and api
|
|
5
|
+
export async function getBalance(address: string): Promise<Balance[]> {
|
|
6
|
+
const accountInfo = await getAccountInfo(address);
|
|
7
|
+
return [{ asset: { type: "native" }, value: BigInt(accountInfo.account_data.Balance) }]; // TODO: add more info like spendableBalance, etc.
|
|
23
8
|
}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import type { BlockInfo } from "@ledgerhq/coin-framework/api/index";
|
|
2
|
-
import { getLedgerEnd
|
|
3
|
-
import { getLedgerEnd } from "../../network/gateway";
|
|
4
|
-
import coinConfig from "../../config";
|
|
5
|
-
|
|
6
|
-
const useGateway = () => coinConfig.getCoinConfig().useGateway === true;
|
|
2
|
+
import { getLedgerEnd } from "../../network/node";
|
|
7
3
|
|
|
8
4
|
export async function lastBlock(): Promise<BlockInfo> {
|
|
9
5
|
return {
|
|
10
|
-
height:
|
|
6
|
+
height: await getLedgerEnd(),
|
|
11
7
|
};
|
|
12
8
|
}
|
|
@@ -1,55 +1,64 @@
|
|
|
1
1
|
import type { Operation, Pagination } from "@ledgerhq/coin-framework/api/index";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
const getNativeContractId = () =>
|
|
6
|
-
coinConfig.getCoinConfig().nativeInstrumentId !== undefined
|
|
7
|
-
? coinConfig.getCoinConfig().nativeInstrumentId?.split(".")[0]
|
|
8
|
-
: "";
|
|
2
|
+
import { getTransactions } from "../../network/indexer";
|
|
3
|
+
import { BoilerplateOperation } from "../../network/types";
|
|
9
4
|
|
|
10
5
|
/**
|
|
11
6
|
* Returns list of operations associated to an account.
|
|
12
|
-
* @param
|
|
7
|
+
* @param address Account address
|
|
13
8
|
* @param pagination Pagination options
|
|
14
9
|
* @returns Operations found and the next "id" or "index" to use for pagination (i.e. `start` property).\
|
|
15
|
-
*
|
|
10
|
+
* If `0` is returns, no pagination needed.
|
|
11
|
+
* This "id" or "index" value, thus it has functional meaning, is different for each blockchain.
|
|
16
12
|
*/
|
|
17
13
|
export async function listOperations(
|
|
18
|
-
|
|
14
|
+
address: string,
|
|
19
15
|
page: Pagination,
|
|
20
16
|
): Promise<[Operation[], string]> {
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
fees: BigInt(0), // to be finalized when details are available on backend
|
|
44
|
-
date: new Date(tx.record_time.seconds),
|
|
45
|
-
block: {
|
|
46
|
-
height: tx.offset,
|
|
47
|
-
time: new Date(tx.effective_at.seconds),
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
});
|
|
17
|
+
const transactions = await getTransactions(address, { from: page.minHeight });
|
|
18
|
+
return [transactions.map(convertToCoreOperation(address)), ""];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const convertToCoreOperation =
|
|
22
|
+
(address: string) =>
|
|
23
|
+
(operation: BoilerplateOperation): Operation => {
|
|
24
|
+
const {
|
|
25
|
+
meta: { delivered_amount },
|
|
26
|
+
tx: { Fee, hash, inLedger, date, Account, Destination },
|
|
27
|
+
} = operation;
|
|
28
|
+
|
|
29
|
+
const type = Account === address ? "OUT" : "IN";
|
|
30
|
+
let value =
|
|
31
|
+
delivered_amount && typeof delivered_amount === "string"
|
|
32
|
+
? BigInt(delivered_amount)
|
|
33
|
+
: BigInt(0);
|
|
34
|
+
|
|
35
|
+
const feeValue = BigInt(Fee);
|
|
36
|
+
if (type === "OUT") {
|
|
37
|
+
if (!Number.isNaN(feeValue)) {
|
|
38
|
+
value = value + feeValue;
|
|
51
39
|
}
|
|
52
40
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
/**
|
|
44
|
+
* Note: The operation ID must be concatenated with another
|
|
45
|
+
* value if the transaction hash is not enough to identify it
|
|
46
|
+
*/
|
|
47
|
+
id: hash,
|
|
48
|
+
asset: { type: "native" },
|
|
49
|
+
tx: {
|
|
50
|
+
hash,
|
|
51
|
+
fees: feeValue,
|
|
52
|
+
date: new Date(date),
|
|
53
|
+
block: {
|
|
54
|
+
height: inLedger,
|
|
55
|
+
hash,
|
|
56
|
+
time: new Date(date),
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
type,
|
|
60
|
+
value,
|
|
61
|
+
senders: [Account],
|
|
62
|
+
recipients: [Destination],
|
|
63
|
+
};
|
|
64
|
+
};
|