@ledgerhq/coin-canton 0.4.0-nightly.0 → 0.4.0-nightly.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +14 -0
- 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/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/network/gateway.d.ts +23 -18
- package/lib/network/gateway.d.ts.map +1 -1
- package/lib/network/gateway.js +2 -1
- package/lib/network/gateway.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/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/network/gateway.d.ts +23 -18
- package/lib-es/network/gateway.d.ts.map +1 -1
- package/lib-es/network/gateway.js +2 -1
- package/lib-es/network/gateway.js.map +1 -1
- package/package.json +3 -3
- package/src/api/listOperations.integ.test.ts +27 -0
- package/src/common-logic/history/listOperations.ts +43 -52
- package/src/network/gateway.ts +27 -18
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
> @ledgerhq/coin-canton@0.
|
|
2
|
+
> @ledgerhq/coin-canton@0.4.0-nightly.0 build /home/runner/work/ledger-live/ledger-live/libs/coin-modules/coin-canton
|
|
3
3
|
> tsc && tsc -m esnext --moduleResolution bundler --outDir lib-es
|
|
4
4
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @ledgerhq/coin-canton
|
|
2
2
|
|
|
3
|
+
## 0.4.0-nightly.1
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#11273](https://github.com/LedgerHQ/ledger-live/pull/11273) [`2482195`](https://github.com/LedgerHQ/ledger-live/commit/24821957c838a304be60ff6e16798ef3cac987cd) Thanks [@estrauser-ledger](https://github.com/estrauser-ledger)! - add cursor to pagintion api
|
|
8
|
+
|
|
9
|
+
- [#11554](https://github.com/LedgerHQ/ledger-live/pull/11554) [`e8a0185`](https://github.com/LedgerHQ/ledger-live/commit/e8a01854e07d313659f9740843731e97601cf41d) Thanks [@hedi-edelbloute](https://github.com/hedi-edelbloute)! - List operations canton
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`2482195`](https://github.com/LedgerHQ/ledger-live/commit/24821957c838a304be60ff6e16798ef3cac987cd), [`228ed30`](https://github.com/LedgerHQ/ledger-live/commit/228ed3030601644e807e85a1693276b788b5cd2a), [`89fc31e`](https://github.com/LedgerHQ/ledger-live/commit/89fc31e8ecfc5e2fd679a2694b3514f8fb19d7b7), [`544edf6`](https://github.com/LedgerHQ/ledger-live/commit/544edf6bb461d48e743dc410c6bc95dc35b5fa70)]:
|
|
14
|
+
- @ledgerhq/coin-framework@6.3.0-nightly.1
|
|
15
|
+
- @ledgerhq/types-live@6.83.0-nightly.0
|
|
16
|
+
|
|
3
17
|
## 0.4.0-nightly.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listOperations.integ.test.d.ts","sourceRoot":"","sources":["../../src/api/listOperations.integ.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const _1 = require(".");
|
|
4
|
+
let api;
|
|
5
|
+
describe("devnet", () => {
|
|
6
|
+
beforeAll(() => {
|
|
7
|
+
api = (0, _1.createApi)({
|
|
8
|
+
nodeUrl: "https://wallet-validator-devnet-canton.ledger-test.com/v2",
|
|
9
|
+
networkType: "devnet",
|
|
10
|
+
gatewayUrl: "https://canton-gateway.api.live.ledger-test.com",
|
|
11
|
+
useGateway: true,
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
describe("listOperations", () => {
|
|
15
|
+
it("should return ops", async () => {
|
|
16
|
+
const ops = await api.listOperations("party-4f2e1485107adf5f::122027c6dbbbdbffe0fa3122ae05175f3b9328e879e9ce96b670354deb64a45683c1", {
|
|
17
|
+
minHeight: 0,
|
|
18
|
+
});
|
|
19
|
+
expect(ops.length).toBeGreaterThan(0);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=listOperations.integ.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listOperations.integ.test.js","sourceRoot":"","sources":["../../src/api/listOperations.integ.test.ts"],"names":[],"mappings":";;AACA,wBAA8B;AAE9B,IAAI,GAAc,CAAC;AAEnB,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IACtB,SAAS,CAAC,GAAG,EAAE;QACb,GAAG,GAAG,IAAA,YAAS,EAAC;YACd,OAAO,EAAE,2DAA2D;YACpE,WAAW,EAAE,QAAQ;YACrB,UAAU,EAAE,iDAAiD;YAC7D,UAAU,EAAE,IAAI;SACjB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;QAC9B,EAAE,CAAC,mBAAmB,EAAE,KAAK,IAAI,EAAE;YACjC,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,cAAc,CAClC,8FAA8F,EAC9F;gBACE,SAAS,EAAE,CAAC;aACb,CACF,CAAC;YACF,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;QACxC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import type { Operation, Pagination } from "@ledgerhq/coin-framework/api/index";
|
|
2
2
|
/**
|
|
3
3
|
* Returns list of operations associated to an account.
|
|
4
|
-
* @param
|
|
4
|
+
* @param partyId Account partyId
|
|
5
5
|
* @param pagination Pagination options
|
|
6
6
|
* @returns Operations found and the next "id" or "index" to use for pagination (i.e. `start` property).\
|
|
7
|
-
*
|
|
8
|
-
* This "id" or "index" value, thus it has functional meaning, is different for each blockchain.
|
|
7
|
+
* Impl to finalize when backend is ready
|
|
9
8
|
*/
|
|
10
|
-
export declare function listOperations(
|
|
9
|
+
export declare function listOperations(partyId: string, page: Pagination): Promise<[Operation[], string]>;
|
|
11
10
|
//# sourceMappingURL=listOperations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listOperations.d.ts","sourceRoot":"","sources":["../../../src/common-logic/history/listOperations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"listOperations.d.ts","sourceRoot":"","sources":["../../../src/common-logic/history/listOperations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAShF;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,UAAU,GACf,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE,MAAM,CAAC,CAAC,CAmChC"}
|
|
@@ -1,52 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.listOperations = listOperations;
|
|
4
|
-
const
|
|
7
|
+
const gateway_1 = require("../../network/gateway");
|
|
8
|
+
const config_1 = __importDefault(require("../../config"));
|
|
9
|
+
const getNativeContractId = () => config_1.default.getCoinConfig().nativeInstrumentId !== undefined
|
|
10
|
+
? config_1.default.getCoinConfig().nativeInstrumentId?.split(".")[0]
|
|
11
|
+
: "";
|
|
5
12
|
/**
|
|
6
13
|
* Returns list of operations associated to an account.
|
|
7
|
-
* @param
|
|
14
|
+
* @param partyId Account partyId
|
|
8
15
|
* @param pagination Pagination options
|
|
9
16
|
* @returns Operations found and the next "id" or "index" to use for pagination (i.e. `start` property).\
|
|
10
|
-
*
|
|
11
|
-
* This "id" or "index" value, thus it has functional meaning, is different for each blockchain.
|
|
17
|
+
* Impl to finalize when backend is ready
|
|
12
18
|
*/
|
|
13
|
-
async function listOperations(
|
|
14
|
-
const transactions = await (0,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
async function listOperations(partyId, page) {
|
|
20
|
+
const { transactions, next } = await (0, gateway_1.getTransactions)(partyId, {
|
|
21
|
+
cursor: page.pagingToken !== undefined ? parseInt(page.pagingToken) : undefined,
|
|
22
|
+
minOffset: page.minHeight,
|
|
23
|
+
limit: page.limit,
|
|
24
|
+
});
|
|
25
|
+
const ops = [];
|
|
26
|
+
for (const tx of transactions) {
|
|
27
|
+
for (let i = 0; i < tx.events.length; i++) {
|
|
28
|
+
const event = tx.events[i]["CantonCreatedEvent"];
|
|
29
|
+
if (event && event.template_id.module_name === "Splice.Amulet") {
|
|
30
|
+
ops.push({
|
|
31
|
+
id: tx.update_id + "-" + i,
|
|
32
|
+
type: event.signatories.includes(partyId) ? "OUT" : "IN",
|
|
33
|
+
value: BigInt(0), // to be finalized when details are available on backend
|
|
34
|
+
senders: event.signatories.includes(partyId) ? [partyId] : [],
|
|
35
|
+
recipients: event.signatories.includes(partyId) ? [] : [partyId],
|
|
36
|
+
asset: event.contract_id === getNativeContractId()
|
|
37
|
+
? { type: "native" }
|
|
38
|
+
: { type: "token", assetReference: event.contract_id },
|
|
39
|
+
tx: {
|
|
40
|
+
hash: tx.update_id,
|
|
41
|
+
fees: BigInt(0), // to be finalized when details are available on backend
|
|
42
|
+
date: new Date(tx.record_time.seconds),
|
|
43
|
+
block: {
|
|
44
|
+
height: tx.offset,
|
|
45
|
+
time: new Date(tx.effective_at.seconds),
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
}
|
|
27
50
|
}
|
|
28
51
|
}
|
|
29
|
-
return
|
|
30
|
-
|
|
31
|
-
* Note: The operation ID must be concatenated with another
|
|
32
|
-
* value if the transaction hash is not enough to identify it
|
|
33
|
-
*/
|
|
34
|
-
id: hash,
|
|
35
|
-
asset: { type: "native" },
|
|
36
|
-
tx: {
|
|
37
|
-
hash,
|
|
38
|
-
fees: feeValue,
|
|
39
|
-
date: new Date(date),
|
|
40
|
-
block: {
|
|
41
|
-
height: inLedger,
|
|
42
|
-
hash,
|
|
43
|
-
time: new Date(date),
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
type,
|
|
47
|
-
value,
|
|
48
|
-
senders: [Account],
|
|
49
|
-
recipients: [Destination],
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
+
return [ops, next + ""];
|
|
53
|
+
}
|
|
52
54
|
//# sourceMappingURL=listOperations.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listOperations.js","sourceRoot":"","sources":["../../../src/common-logic/history/listOperations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,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QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;oBACxD,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,wDAAwD;oBAC1E,OAAO,EAAE,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE;oBAC7D,UAAU,EAAE,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;oBAChE,KAAK,EACH,KAAK,CAAC,WAAW,KAAK,mBAAmB,EAAE;wBACzC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE;wBACpB,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,cAAc,EAAE,KAAK,CAAC,WAAW,EAAE;oBAC1D,EAAE,EAAE;wBACF,IAAI,EAAE,EAAE,CAAC,SAAS;wBAClB,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,wDAAwD;wBACzE,IAAI,EAAE,IAAI,IAAI,CAAC,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC;wBACtC,KAAK,EAAE;4BACL,MAAM,EAAE,EAAE,CAAC,MAAM;4BACjB,IAAI,EAAE,IAAI,IAAI,CAAC,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC;yBACxC;qBACF;iBACF,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,CAAC,GAAG,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;AAC1B,CAAC"}
|
package/lib/network/gateway.d.ts
CHANGED
|
@@ -29,46 +29,51 @@ type Timestamp = {
|
|
|
29
29
|
};
|
|
30
30
|
type BaseEvent = {
|
|
31
31
|
type: string;
|
|
32
|
-
|
|
32
|
+
contract_id: string;
|
|
33
33
|
details: string;
|
|
34
34
|
};
|
|
35
|
-
type CreatedEvent = BaseEvent & {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
export type CreatedEvent = BaseEvent & {
|
|
36
|
+
template_id: {
|
|
37
|
+
package_id: string;
|
|
38
|
+
module_name: string;
|
|
39
|
+
entity_name: string;
|
|
40
40
|
};
|
|
41
41
|
signatories: string[];
|
|
42
42
|
observers: string[];
|
|
43
43
|
};
|
|
44
44
|
type ExercisedEvent = BaseEvent & {
|
|
45
|
-
|
|
45
|
+
template_id: {
|
|
46
46
|
packageId: string;
|
|
47
47
|
moduleName: string;
|
|
48
48
|
entityName: string;
|
|
49
49
|
};
|
|
50
50
|
choice: string;
|
|
51
51
|
consuming: boolean;
|
|
52
|
-
|
|
52
|
+
acting_parties: string[];
|
|
53
53
|
};
|
|
54
54
|
type Event = BaseEvent | CreatedEvent | ExercisedEvent;
|
|
55
|
-
type TxInfo = {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
export type TxInfo = {
|
|
56
|
+
update_id: string;
|
|
57
|
+
command_id: string;
|
|
58
|
+
workflow_id: string;
|
|
59
|
+
effective_at: Timestamp;
|
|
60
60
|
offset: number;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
events: Event[];
|
|
64
|
-
|
|
61
|
+
synchronizer_id: string;
|
|
62
|
+
record_time: Timestamp;
|
|
63
|
+
events: Record<string, Event>[];
|
|
64
|
+
trace_context: string;
|
|
65
65
|
};
|
|
66
66
|
export declare function prepareOnboarding(pubKey: string, pubKeyType: string): Promise<OnboardingPrepareResponse>;
|
|
67
67
|
export declare function submitOnboarding(prepareRequest: OnboardingPrepareRequest, prepareResponse: OnboardingPrepareResponse, signature: string): Promise<OnboardingSubmitResponse>;
|
|
68
68
|
export declare function getBalance(partyId: string): Promise<InstrumentBalance[]>;
|
|
69
69
|
export declare function getPartyById(partyId: string): Promise<PartyInfo>;
|
|
70
70
|
export declare function getPartyByPubKey(pubKey: string): Promise<PartyInfo>;
|
|
71
|
-
export declare function getTransactions(partyId: string
|
|
71
|
+
export declare function getTransactions(partyId: string, options?: {
|
|
72
|
+
cursor?: number | undefined;
|
|
73
|
+
minOffset?: number | undefined;
|
|
74
|
+
maxOffset?: number | undefined;
|
|
75
|
+
limit?: number | undefined;
|
|
76
|
+
}): Promise<{
|
|
72
77
|
next: number;
|
|
73
78
|
transactions: TxInfo[];
|
|
74
79
|
}>;
|
|
@@ -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;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,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,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,KAAK,SAAS,GAAG;IACf,IAAI,EAAE,MAAM,CAAC;IACb,
|
|
1
|
+
{"version":3,"file":"gateway.d.ts","sourceRoot":"","sources":["../../src/network/gateway.ts"],"names":[],"mappings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,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"}
|
package/lib/network/gateway.js
CHANGED
|
@@ -60,10 +60,11 @@ async function getParty(identifier, by) {
|
|
|
60
60
|
});
|
|
61
61
|
return data;
|
|
62
62
|
}
|
|
63
|
-
async function getTransactions(partyId) {
|
|
63
|
+
async function getTransactions(partyId, options) {
|
|
64
64
|
const { data } = await (0, live_network_1.default)({
|
|
65
65
|
method: "GET",
|
|
66
66
|
url: `${getGatewayUrl()}/v1/node/${getNodeId()}/party/${partyId}/transactions`,
|
|
67
|
+
data: options,
|
|
67
68
|
});
|
|
68
69
|
return data;
|
|
69
70
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gateway.js","sourceRoot":"","sources":["../../src/network/gateway.ts"],"names":[],"mappings":";;;;;AAwFA,8CAaC;AAED,4CAeC;AAED,gCAMC;AAED,oCAEC;AAED,4CAEC;AAaD,
|
|
1
|
+
{"version":3,"file":"gateway.js","sourceRoot":"","sources":["../../src/network/gateway.ts"],"names":[],"mappings":";;;;;AAwFA,8CAaC;AAED,4CAeC;AAED,gCAMC;AAED,oCAEC;AAED,4CAEC;AAaD,0CAqBC;AAED,oCAMC;AAhLD,0EAA6C;AAC7C,uDAAmC;AAoFnC,MAAM,aAAa,GAAG,GAAG,EAAE,CAAC,gBAAU,CAAC,aAAa,EAAE,CAAC,UAAU,CAAC;AAClE,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,gBAAU,CAAC,aAAa,EAAE,CAAC,MAAM,IAAI,wBAAwB,CAAC;AAE/E,KAAK,UAAU,iBAAiB,CACrC,MAAc,EACd,UAAkB;IAElB,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAA,sBAAO,EAA4B;QACx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AE;QACpE,IAAI,EAAE;YACJ,EAAE;SACH;KACF,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC;AAEM,KAAK,UAAU,eAAe,CACnC,OAAe,EACf,OAKC;IAKD,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAA,sBAAO,EAG3B;QACD,MAAM,EAAE,KAAK;QACb,GAAG,EAAE,GAAG,aAAa,EAAE,YAAY,SAAS,EAAE,UAAU,OAAO,eAAe;QAC9E,IAAI,EAAE,OAAO;KACd,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC;AAEM,KAAK,UAAU,YAAY;IAChC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAA,sBAAO,EAAS;QACrC,MAAM,EAAE,KAAK;QACb,GAAG,EAAE,GAAG,aAAa,EAAE,YAAY,SAAS,EAAE,aAAa;KAC5D,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listOperations.integ.test.d.ts","sourceRoot":"","sources":["../../src/api/listOperations.integ.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createApi } from ".";
|
|
2
|
+
let api;
|
|
3
|
+
describe("devnet", () => {
|
|
4
|
+
beforeAll(() => {
|
|
5
|
+
api = createApi({
|
|
6
|
+
nodeUrl: "https://wallet-validator-devnet-canton.ledger-test.com/v2",
|
|
7
|
+
networkType: "devnet",
|
|
8
|
+
gatewayUrl: "https://canton-gateway.api.live.ledger-test.com",
|
|
9
|
+
useGateway: true,
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
describe("listOperations", () => {
|
|
13
|
+
it("should return ops", async () => {
|
|
14
|
+
const ops = await api.listOperations("party-4f2e1485107adf5f::122027c6dbbbdbffe0fa3122ae05175f3b9328e879e9ce96b670354deb64a45683c1", {
|
|
15
|
+
minHeight: 0,
|
|
16
|
+
});
|
|
17
|
+
expect(ops.length).toBeGreaterThan(0);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
//# sourceMappingURL=listOperations.integ.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listOperations.integ.test.js","sourceRoot":"","sources":["../../src/api/listOperations.integ.test.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,GAAG,CAAC;AAE9B,IAAI,GAAc,CAAC;AAEnB,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IACtB,SAAS,CAAC,GAAG,EAAE;QACb,GAAG,GAAG,SAAS,CAAC;YACd,OAAO,EAAE,2DAA2D;YACpE,WAAW,EAAE,QAAQ;YACrB,UAAU,EAAE,iDAAiD;YAC7D,UAAU,EAAE,IAAI;SACjB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;QAC9B,EAAE,CAAC,mBAAmB,EAAE,KAAK,IAAI,EAAE;YACjC,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,cAAc,CAClC,8FAA8F,EAC9F;gBACE,SAAS,EAAE,CAAC;aACb,CACF,CAAC;YACF,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;QACxC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import type { Operation, Pagination } from "@ledgerhq/coin-framework/api/index";
|
|
2
2
|
/**
|
|
3
3
|
* Returns list of operations associated to an account.
|
|
4
|
-
* @param
|
|
4
|
+
* @param partyId Account partyId
|
|
5
5
|
* @param pagination Pagination options
|
|
6
6
|
* @returns Operations found and the next "id" or "index" to use for pagination (i.e. `start` property).\
|
|
7
|
-
*
|
|
8
|
-
* This "id" or "index" value, thus it has functional meaning, is different for each blockchain.
|
|
7
|
+
* Impl to finalize when backend is ready
|
|
9
8
|
*/
|
|
10
|
-
export declare function listOperations(
|
|
9
|
+
export declare function listOperations(partyId: string, page: Pagination): Promise<[Operation[], string]>;
|
|
11
10
|
//# sourceMappingURL=listOperations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listOperations.d.ts","sourceRoot":"","sources":["../../../src/common-logic/history/listOperations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"listOperations.d.ts","sourceRoot":"","sources":["../../../src/common-logic/history/listOperations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAShF;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,UAAU,GACf,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE,MAAM,CAAC,CAAC,CAmChC"}
|
|
@@ -1,49 +1,48 @@
|
|
|
1
|
-
import { getTransactions } from "../../network/
|
|
1
|
+
import { getTransactions } from "../../network/gateway";
|
|
2
|
+
import coinConfig from "../../config";
|
|
3
|
+
const getNativeContractId = () => coinConfig.getCoinConfig().nativeInstrumentId !== undefined
|
|
4
|
+
? coinConfig.getCoinConfig().nativeInstrumentId?.split(".")[0]
|
|
5
|
+
: "";
|
|
2
6
|
/**
|
|
3
7
|
* Returns list of operations associated to an account.
|
|
4
|
-
* @param
|
|
8
|
+
* @param partyId Account partyId
|
|
5
9
|
* @param pagination Pagination options
|
|
6
10
|
* @returns Operations found and the next "id" or "index" to use for pagination (i.e. `start` property).\
|
|
7
|
-
*
|
|
8
|
-
* This "id" or "index" value, thus it has functional meaning, is different for each blockchain.
|
|
11
|
+
* Impl to finalize when backend is ready
|
|
9
12
|
*/
|
|
10
|
-
export async function listOperations(
|
|
11
|
-
const transactions = await getTransactions(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
export async function listOperations(partyId, page) {
|
|
14
|
+
const { transactions, next } = await getTransactions(partyId, {
|
|
15
|
+
cursor: page.pagingToken !== undefined ? parseInt(page.pagingToken) : undefined,
|
|
16
|
+
minOffset: page.minHeight,
|
|
17
|
+
limit: page.limit,
|
|
18
|
+
});
|
|
19
|
+
const ops = [];
|
|
20
|
+
for (const tx of transactions) {
|
|
21
|
+
for (let i = 0; i < tx.events.length; i++) {
|
|
22
|
+
const event = tx.events[i]["CantonCreatedEvent"];
|
|
23
|
+
if (event && event.template_id.module_name === "Splice.Amulet") {
|
|
24
|
+
ops.push({
|
|
25
|
+
id: tx.update_id + "-" + i,
|
|
26
|
+
type: event.signatories.includes(partyId) ? "OUT" : "IN",
|
|
27
|
+
value: BigInt(0), // to be finalized when details are available on backend
|
|
28
|
+
senders: event.signatories.includes(partyId) ? [partyId] : [],
|
|
29
|
+
recipients: event.signatories.includes(partyId) ? [] : [partyId],
|
|
30
|
+
asset: event.contract_id === getNativeContractId()
|
|
31
|
+
? { type: "native" }
|
|
32
|
+
: { type: "token", assetReference: event.contract_id },
|
|
33
|
+
tx: {
|
|
34
|
+
hash: tx.update_id,
|
|
35
|
+
fees: BigInt(0), // to be finalized when details are available on backend
|
|
36
|
+
date: new Date(tx.record_time.seconds),
|
|
37
|
+
block: {
|
|
38
|
+
height: tx.offset,
|
|
39
|
+
time: new Date(tx.effective_at.seconds),
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
}
|
|
24
44
|
}
|
|
25
45
|
}
|
|
26
|
-
return
|
|
27
|
-
|
|
28
|
-
* Note: The operation ID must be concatenated with another
|
|
29
|
-
* value if the transaction hash is not enough to identify it
|
|
30
|
-
*/
|
|
31
|
-
id: hash,
|
|
32
|
-
asset: { type: "native" },
|
|
33
|
-
tx: {
|
|
34
|
-
hash,
|
|
35
|
-
fees: feeValue,
|
|
36
|
-
date: new Date(date),
|
|
37
|
-
block: {
|
|
38
|
-
height: inLedger,
|
|
39
|
-
hash,
|
|
40
|
-
time: new Date(date),
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
type,
|
|
44
|
-
value,
|
|
45
|
-
senders: [Account],
|
|
46
|
-
recipients: [Destination],
|
|
47
|
-
};
|
|
48
|
-
};
|
|
46
|
+
return [ops, next + ""];
|
|
47
|
+
}
|
|
49
48
|
//# sourceMappingURL=listOperations.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listOperations.js","sourceRoot":"","sources":["../../../src/common-logic/history/listOperations.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"listOperations.js","sourceRoot":"","sources":["../../../src/common-logic/history/listOperations.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,eAAe,EAAU,MAAM,uBAAuB,CAAC;AAC9E,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC,MAAM,mBAAmB,GAAG,GAAG,EAAE,CAC/B,UAAU,CAAC,aAAa,EAAE,CAAC,kBAAkB,KAAK,SAAS;IACzD,CAAC,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC,kBAAkB,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAC9D,CAAC,CAAC,EAAE,CAAC;AAET;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,OAAe,EACf,IAAgB;IAEhB,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,GAAG,MAAM,eAAe,CAAC,OAAO,EAAE;QAC5D,MAAM,EAAE,IAAI,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS;QAC/E,SAAS,EAAE,IAAI,CAAC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M,CAAC,CAAC,CAAC,EAAE,wDAAwD;wBACzE,IAAI,EAAE,IAAI,IAAI,CAAC,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC;wBACtC,KAAK,EAAE;4BACL,MAAM,EAAE,EAAE,CAAC,MAAM;4BACjB,IAAI,EAAE,IAAI,IAAI,CAAC,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC;yBACxC;qBACF;iBACF,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,CAAC,GAAG,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -29,46 +29,51 @@ type Timestamp = {
|
|
|
29
29
|
};
|
|
30
30
|
type BaseEvent = {
|
|
31
31
|
type: string;
|
|
32
|
-
|
|
32
|
+
contract_id: string;
|
|
33
33
|
details: string;
|
|
34
34
|
};
|
|
35
|
-
type CreatedEvent = BaseEvent & {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
export type CreatedEvent = BaseEvent & {
|
|
36
|
+
template_id: {
|
|
37
|
+
package_id: string;
|
|
38
|
+
module_name: string;
|
|
39
|
+
entity_name: string;
|
|
40
40
|
};
|
|
41
41
|
signatories: string[];
|
|
42
42
|
observers: string[];
|
|
43
43
|
};
|
|
44
44
|
type ExercisedEvent = BaseEvent & {
|
|
45
|
-
|
|
45
|
+
template_id: {
|
|
46
46
|
packageId: string;
|
|
47
47
|
moduleName: string;
|
|
48
48
|
entityName: string;
|
|
49
49
|
};
|
|
50
50
|
choice: string;
|
|
51
51
|
consuming: boolean;
|
|
52
|
-
|
|
52
|
+
acting_parties: string[];
|
|
53
53
|
};
|
|
54
54
|
type Event = BaseEvent | CreatedEvent | ExercisedEvent;
|
|
55
|
-
type TxInfo = {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
export type TxInfo = {
|
|
56
|
+
update_id: string;
|
|
57
|
+
command_id: string;
|
|
58
|
+
workflow_id: string;
|
|
59
|
+
effective_at: Timestamp;
|
|
60
60
|
offset: number;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
events: Event[];
|
|
64
|
-
|
|
61
|
+
synchronizer_id: string;
|
|
62
|
+
record_time: Timestamp;
|
|
63
|
+
events: Record<string, Event>[];
|
|
64
|
+
trace_context: string;
|
|
65
65
|
};
|
|
66
66
|
export declare function prepareOnboarding(pubKey: string, pubKeyType: string): Promise<OnboardingPrepareResponse>;
|
|
67
67
|
export declare function submitOnboarding(prepareRequest: OnboardingPrepareRequest, prepareResponse: OnboardingPrepareResponse, signature: string): Promise<OnboardingSubmitResponse>;
|
|
68
68
|
export declare function getBalance(partyId: string): Promise<InstrumentBalance[]>;
|
|
69
69
|
export declare function getPartyById(partyId: string): Promise<PartyInfo>;
|
|
70
70
|
export declare function getPartyByPubKey(pubKey: string): Promise<PartyInfo>;
|
|
71
|
-
export declare function getTransactions(partyId: string
|
|
71
|
+
export declare function getTransactions(partyId: string, options?: {
|
|
72
|
+
cursor?: number | undefined;
|
|
73
|
+
minOffset?: number | undefined;
|
|
74
|
+
maxOffset?: number | undefined;
|
|
75
|
+
limit?: number | undefined;
|
|
76
|
+
}): Promise<{
|
|
72
77
|
next: number;
|
|
73
78
|
transactions: TxInfo[];
|
|
74
79
|
}>;
|
|
@@ -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;QAC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ACxC,eAAe,EAAE,yBAAyB,EAC1C,SAAS,EAAE,MAAM,qCAYlB;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAM9E;AAED,wBAAsB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAEtE;AAED,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAEzE;AAaD,wBAAsB,eAAe,CACnC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;IACR,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,GAAG,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"}
|
|
@@ -48,10 +48,11 @@ async function getParty(identifier, by) {
|
|
|
48
48
|
});
|
|
49
49
|
return data;
|
|
50
50
|
}
|
|
51
|
-
export async function getTransactions(partyId) {
|
|
51
|
+
export async function getTransactions(partyId, options) {
|
|
52
52
|
const { data } = await network({
|
|
53
53
|
method: "GET",
|
|
54
54
|
url: `${getGatewayUrl()}/v1/node/${getNodeId()}/party/${partyId}/transactions`,
|
|
55
|
+
data: options,
|
|
55
56
|
});
|
|
56
57
|
return data;
|
|
57
58
|
}
|
|
@@ -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,CA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AAe;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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/coin-canton",
|
|
3
|
-
"version": "0.4.0-nightly.
|
|
3
|
+
"version": "0.4.0-nightly.1",
|
|
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.
|
|
104
|
+
"@ledgerhq/coin-framework": "^6.3.0-nightly.1",
|
|
105
105
|
"@ledgerhq/cryptoassets": "^13.27.0-nightly.0",
|
|
106
106
|
"@ledgerhq/devices": "8.5.1-nightly.0",
|
|
107
107
|
"@ledgerhq/errors": "^6.25.0-nightly.0",
|
|
108
108
|
"@ledgerhq/live-env": "^2.15.0-nightly.1",
|
|
109
109
|
"@ledgerhq/live-network": "^2.0.16-nightly.1",
|
|
110
|
-
"@ledgerhq/types-live": "^6.
|
|
110
|
+
"@ledgerhq/types-live": "^6.83.0-nightly.0"
|
|
111
111
|
},
|
|
112
112
|
"devDependencies": {
|
|
113
113
|
"@types/invariant": "^2.2.37",
|
|
@@ -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,64 +1,55 @@
|
|
|
1
1
|
import type { Operation, Pagination } from "@ledgerhq/coin-framework/api/index";
|
|
2
|
-
import { getTransactions } from "../../network/
|
|
3
|
-
import
|
|
2
|
+
import { CreatedEvent, getTransactions, TxInfo } from "../../network/gateway";
|
|
3
|
+
import coinConfig from "../../config";
|
|
4
|
+
|
|
5
|
+
const getNativeContractId = () =>
|
|
6
|
+
coinConfig.getCoinConfig().nativeInstrumentId !== undefined
|
|
7
|
+
? coinConfig.getCoinConfig().nativeInstrumentId?.split(".")[0]
|
|
8
|
+
: "";
|
|
4
9
|
|
|
5
10
|
/**
|
|
6
11
|
* Returns list of operations associated to an account.
|
|
7
|
-
* @param
|
|
12
|
+
* @param partyId Account partyId
|
|
8
13
|
* @param pagination Pagination options
|
|
9
14
|
* @returns Operations found and the next "id" or "index" to use for pagination (i.e. `start` property).\
|
|
10
|
-
*
|
|
11
|
-
* This "id" or "index" value, thus it has functional meaning, is different for each blockchain.
|
|
15
|
+
* Impl to finalize when backend is ready
|
|
12
16
|
*/
|
|
13
17
|
export async function listOperations(
|
|
14
|
-
|
|
18
|
+
partyId: string,
|
|
15
19
|
page: Pagination,
|
|
16
20
|
): Promise<[Operation[], string]> {
|
|
17
|
-
const transactions = await getTransactions(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
21
|
+
const { transactions, next } = await getTransactions(partyId, {
|
|
22
|
+
cursor: page.pagingToken !== undefined ? parseInt(page.pagingToken) : undefined,
|
|
23
|
+
minOffset: page.minHeight,
|
|
24
|
+
limit: page.limit,
|
|
25
|
+
});
|
|
26
|
+
const ops: Operation[] = [];
|
|
27
|
+
for (const tx of transactions) {
|
|
28
|
+
for (let i = 0; i < tx.events.length; i++) {
|
|
29
|
+
const event: CreatedEvent = tx.events[i]["CantonCreatedEvent"] as CreatedEvent;
|
|
30
|
+
if (event && event.template_id.module_name === "Splice.Amulet") {
|
|
31
|
+
ops.push({
|
|
32
|
+
id: tx.update_id + "-" + i,
|
|
33
|
+
type: event.signatories.includes(partyId) ? "OUT" : "IN",
|
|
34
|
+
value: BigInt(0), // to be finalized when details are available on backend
|
|
35
|
+
senders: event.signatories.includes(partyId) ? [partyId] : [],
|
|
36
|
+
recipients: event.signatories.includes(partyId) ? [] : [partyId],
|
|
37
|
+
asset:
|
|
38
|
+
event.contract_id === getNativeContractId()
|
|
39
|
+
? { type: "native" }
|
|
40
|
+
: { type: "token", assetReference: event.contract_id },
|
|
41
|
+
tx: {
|
|
42
|
+
hash: tx.update_id,
|
|
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
|
+
});
|
|
39
51
|
}
|
|
40
52
|
}
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
};
|
|
53
|
+
}
|
|
54
|
+
return [ops, next + ""];
|
|
55
|
+
}
|
package/src/network/gateway.ts
CHANGED
|
@@ -44,43 +44,43 @@ type Timestamp = {
|
|
|
44
44
|
|
|
45
45
|
type BaseEvent = {
|
|
46
46
|
type: string;
|
|
47
|
-
|
|
47
|
+
contract_id: string;
|
|
48
48
|
details: string;
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
type CreatedEvent = BaseEvent & {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
export type CreatedEvent = BaseEvent & {
|
|
52
|
+
template_id: {
|
|
53
|
+
package_id: string;
|
|
54
|
+
module_name: string;
|
|
55
|
+
entity_name: string;
|
|
56
56
|
};
|
|
57
57
|
signatories: string[];
|
|
58
58
|
observers: string[];
|
|
59
59
|
};
|
|
60
60
|
|
|
61
61
|
type ExercisedEvent = BaseEvent & {
|
|
62
|
-
|
|
62
|
+
template_id: {
|
|
63
63
|
packageId: string;
|
|
64
64
|
moduleName: string;
|
|
65
65
|
entityName: string;
|
|
66
66
|
};
|
|
67
67
|
choice: string;
|
|
68
68
|
consuming: boolean;
|
|
69
|
-
|
|
69
|
+
acting_parties: string[];
|
|
70
70
|
};
|
|
71
71
|
|
|
72
72
|
type Event = BaseEvent | CreatedEvent | ExercisedEvent;
|
|
73
73
|
|
|
74
|
-
type TxInfo = {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
export type TxInfo = {
|
|
75
|
+
update_id: string;
|
|
76
|
+
command_id: string;
|
|
77
|
+
workflow_id: string;
|
|
78
|
+
effective_at: Timestamp;
|
|
79
79
|
offset: number;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
events: Event[];
|
|
83
|
-
|
|
80
|
+
synchronizer_id: string;
|
|
81
|
+
record_time: Timestamp;
|
|
82
|
+
events: Record<string, Event>[];
|
|
83
|
+
trace_context: string;
|
|
84
84
|
};
|
|
85
85
|
|
|
86
86
|
const getGatewayUrl = () => coinConfig.getCoinConfig().gatewayUrl;
|
|
@@ -145,7 +145,15 @@ async function getParty(identifier: string, by: "ID" | "PK"): Promise<PartyInfo>
|
|
|
145
145
|
return data;
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
export async function getTransactions(
|
|
148
|
+
export async function getTransactions(
|
|
149
|
+
partyId: string,
|
|
150
|
+
options?: {
|
|
151
|
+
cursor?: number | undefined;
|
|
152
|
+
minOffset?: number | undefined;
|
|
153
|
+
maxOffset?: number | undefined;
|
|
154
|
+
limit?: number | undefined;
|
|
155
|
+
},
|
|
156
|
+
): Promise<{
|
|
149
157
|
next: number;
|
|
150
158
|
transactions: TxInfo[];
|
|
151
159
|
}> {
|
|
@@ -155,6 +163,7 @@ export async function getTransactions(partyId: string): Promise<{
|
|
|
155
163
|
}>({
|
|
156
164
|
method: "GET",
|
|
157
165
|
url: `${getGatewayUrl()}/v1/node/${getNodeId()}/party/${partyId}/transactions`,
|
|
166
|
+
data: options,
|
|
158
167
|
});
|
|
159
168
|
return data;
|
|
160
169
|
}
|