@canton-network/core-token-standard-service 1.14.0 → 2.0.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/dist/core-service.d.ts +3 -3
- package/dist/core-service.d.ts.map +1 -1
- package/dist/index.cjs +88 -64
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +88 -64
- package/dist/index.js.map +1 -1
- package/dist/token-standard-service.d.ts +3 -3
- package/dist/token-standard-service.d.ts.map +1 -1
- package/dist/v1/allocation-service.d.ts +2 -3
- package/dist/v1/allocation-service.d.ts.map +1 -1
- package/dist/v1/transfer-service.d.ts +3 -3
- package/dist/v1/transfer-service.d.ts.map +1 -1
- package/dist/v2/allocation-service.d.ts +3 -3
- package/dist/v2/allocation-service.d.ts.map +1 -1
- package/dist/v2/transfer-service.d.ts +3 -3
- package/dist/v2/transfer-service.d.ts.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { EventFilterBySetup } from "@canton-network/core-ledger-client-types";
|
|
|
3
3
|
import { TokenStandardTransactionInterfaces, TransactionParser, ensureInterfaceViewIsPresent, renderTransaction } from "@canton-network/core-tx-parser";
|
|
4
4
|
import Decimal$1, { Decimal } from "decimal.js";
|
|
5
5
|
import { ALLOCATION_FACTORY_INTERFACE_ID_V2, ALLOCATION_INSTRUCTION_INTERFACE_ID_V2, ALLOCATION_INTERFACE_ID_V2, ALLOCATION_REQUEST_INTERFACE_ID_V2, TRANSFER_FACTORY_INTERFACE_ID_V2, TRANSFER_INSTRUCTION_INTERFACE_ID_V2, TokenStandardClient as TokenStandardClient$1, TransferInstruction as TransferInstruction$1 } from "@canton-network/core-token-standard-v2";
|
|
6
|
+
import { getLogger } from "@logtape/logtape";
|
|
6
7
|
import { ACSReader } from "@canton-network/core-acs-reader";
|
|
7
8
|
//#region src/types.ts
|
|
8
9
|
const REQUESTED_AT_SKEW_MS = 6e4;
|
|
@@ -16,11 +17,53 @@ const KEY_MAPPING = {
|
|
|
16
17
|
"allocation-request": "allocationRequest"
|
|
17
18
|
};
|
|
18
19
|
//#endregion
|
|
20
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
|
|
21
|
+
function _typeof(o) {
|
|
22
|
+
"@babel/helpers - typeof";
|
|
23
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
24
|
+
return typeof o;
|
|
25
|
+
} : function(o) {
|
|
26
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
27
|
+
}, _typeof(o);
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
|
|
31
|
+
function toPrimitive(t, r) {
|
|
32
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
33
|
+
var e = t[Symbol.toPrimitive];
|
|
34
|
+
if (void 0 !== e) {
|
|
35
|
+
var i = e.call(t, r || "default");
|
|
36
|
+
if ("object" != _typeof(i)) return i;
|
|
37
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
38
|
+
}
|
|
39
|
+
return ("string" === r ? String : Number)(t);
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
|
|
43
|
+
function toPropertyKey(t) {
|
|
44
|
+
var i = toPrimitive(t, "string");
|
|
45
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
|
|
49
|
+
function _defineProperty(e, r, t) {
|
|
50
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
51
|
+
value: t,
|
|
52
|
+
enumerable: !0,
|
|
53
|
+
configurable: !0,
|
|
54
|
+
writable: !0
|
|
55
|
+
}) : e[r] = t, e;
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
19
58
|
//#region src/v2/transfer-service.ts
|
|
20
59
|
var TransferServiceV2 = class {
|
|
21
|
-
constructor(core
|
|
60
|
+
constructor(core) {
|
|
22
61
|
this.core = core;
|
|
23
|
-
this
|
|
62
|
+
_defineProperty(this, "logger", getLogger([
|
|
63
|
+
"core",
|
|
64
|
+
"token-standard-service",
|
|
65
|
+
"TransferServiceV2"
|
|
66
|
+
]));
|
|
24
67
|
}
|
|
25
68
|
async buildTransferChoiceArgs(opts) {
|
|
26
69
|
const inputHoldingCids = await this.core.getInputHoldingCidsForAccount({
|
|
@@ -125,9 +168,13 @@ var TransferServiceV2 = class {
|
|
|
125
168
|
//#endregion
|
|
126
169
|
//#region src/v1/transfer-service.ts
|
|
127
170
|
var TransferService = class {
|
|
128
|
-
constructor(core
|
|
171
|
+
constructor(core) {
|
|
129
172
|
this.core = core;
|
|
130
|
-
this
|
|
173
|
+
_defineProperty(this, "logger", getLogger([
|
|
174
|
+
"core",
|
|
175
|
+
"token-standard-service",
|
|
176
|
+
"TransferService"
|
|
177
|
+
]));
|
|
131
178
|
}
|
|
132
179
|
async buildTransferChoiceArgs(sender, receiver, amount, instrumentAdmin, instrumentId, inputUtxos, memo, expiryDate, meta, continueUntilCompletion) {
|
|
133
180
|
const inputHoldingCids = await this.core.getInputHoldingsCids({
|
|
@@ -188,7 +235,7 @@ var TransferService = class {
|
|
|
188
235
|
const { factoryId, choiceContext } = await this.fetchTransferFactoryChoiceContext(registryUrl, choiceArgs);
|
|
189
236
|
return this.createTransferFromContext(factoryId, choiceArgs, choiceContext);
|
|
190
237
|
} catch (e) {
|
|
191
|
-
this.logger.
|
|
238
|
+
this.logger.warn("Failed to execute transfer:", { error: e });
|
|
192
239
|
throw e;
|
|
193
240
|
}
|
|
194
241
|
}
|
|
@@ -211,7 +258,7 @@ var TransferService = class {
|
|
|
211
258
|
} }
|
|
212
259
|
}, choiceContext.disclosedContracts];
|
|
213
260
|
} catch (e) {
|
|
214
|
-
this.logger.
|
|
261
|
+
this.logger.warn("Failed to create accept transfer instruction:", { error: e });
|
|
215
262
|
throw e;
|
|
216
263
|
}
|
|
217
264
|
}
|
|
@@ -294,7 +341,7 @@ var TransferService = class {
|
|
|
294
341
|
} }
|
|
295
342
|
}, choiceContext.disclosedContracts];
|
|
296
343
|
} catch (e) {
|
|
297
|
-
this.logger.
|
|
344
|
+
this.logger.warn("Failed to create reject transfer instruction:", { error: e });
|
|
298
345
|
throw e;
|
|
299
346
|
}
|
|
300
347
|
}
|
|
@@ -325,7 +372,7 @@ var TransferService = class {
|
|
|
325
372
|
} }
|
|
326
373
|
}, choiceContext.disclosedContracts];
|
|
327
374
|
} catch (e) {
|
|
328
|
-
this.logger.
|
|
375
|
+
this.logger.warn("Failed to create withdraw transfer instruction:", { error: e });
|
|
329
376
|
throw e;
|
|
330
377
|
}
|
|
331
378
|
}
|
|
@@ -348,9 +395,8 @@ var TransferService = class {
|
|
|
348
395
|
//#endregion
|
|
349
396
|
//#region src/v1/allocation-service.ts
|
|
350
397
|
var AllocationService$1 = class {
|
|
351
|
-
constructor(core
|
|
398
|
+
constructor(core) {
|
|
352
399
|
this.core = core;
|
|
353
|
-
this.logger = logger;
|
|
354
400
|
}
|
|
355
401
|
async buildAllocationFactoryChoiceArgs(allocationSpecification, expectedAdmin, inputUtxos, requestedAt) {
|
|
356
402
|
const allocationSpecificationNormalized = {
|
|
@@ -503,11 +549,15 @@ var AllocationService$1 = class {
|
|
|
503
549
|
//#endregion
|
|
504
550
|
//#region src/core-service.ts
|
|
505
551
|
var CoreService = class CoreService {
|
|
506
|
-
constructor(ledgerProvider,
|
|
552
|
+
constructor(ledgerProvider, accessTokenProvider, isMasterUser) {
|
|
507
553
|
this.ledgerProvider = ledgerProvider;
|
|
508
|
-
this.logger = logger;
|
|
509
554
|
this.accessTokenProvider = accessTokenProvider;
|
|
510
555
|
this.isMasterUser = isMasterUser;
|
|
556
|
+
_defineProperty(this, "logger", getLogger([
|
|
557
|
+
"core",
|
|
558
|
+
"token-standard-service",
|
|
559
|
+
"CoreService"
|
|
560
|
+
]));
|
|
511
561
|
}
|
|
512
562
|
getTokenStandardClientWithVersion(registryUrl, version) {
|
|
513
563
|
if (!isApiVersion(version)) throw new Error(`Unsupported token standard api version.`);
|
|
@@ -595,12 +645,15 @@ var CoreService = class CoreService {
|
|
|
595
645
|
continueUntilCompletion: Boolean(continueUntilCompletion)
|
|
596
646
|
};
|
|
597
647
|
if (limit !== void 0) options.limit = limit;
|
|
598
|
-
this.logger.
|
|
648
|
+
this.logger.debug("Continue to completion: {continueUntilCompletion}", { continueUntilCompletion: Boolean(continueUntilCompletion) });
|
|
599
649
|
const acsResponses = await new ACSReader(this.ledgerProvider).raw.read(options);
|
|
600
650
|
const isActiveContractEntry = (acsResponse) => acsResponse.contractEntry != null && "JsActiveContract" in acsResponse.contractEntry && acsResponse.contractEntry.JsActiveContract != null && acsResponse.contractEntry.JsActiveContract.createdEvent != null;
|
|
601
651
|
return acsResponses.filter(isActiveContractEntry).map((response) => this.toPrettyContract(interfaceId, response, ledgerEnd));
|
|
602
652
|
} catch (err) {
|
|
603
|
-
this.logger.error(`Failed to list contracts of interface
|
|
653
|
+
this.logger.error(`Failed to list contracts of interface {interfaceId}`, {
|
|
654
|
+
interfaceId,
|
|
655
|
+
err
|
|
656
|
+
});
|
|
604
657
|
throw err;
|
|
605
658
|
}
|
|
606
659
|
}
|
|
@@ -659,9 +712,14 @@ const EMPTY_EXTRA_ARGS = () => ({
|
|
|
659
712
|
meta: { values: {} }
|
|
660
713
|
});
|
|
661
714
|
var AllocationService = class AllocationService {
|
|
662
|
-
constructor(core
|
|
715
|
+
constructor(core) {
|
|
663
716
|
this.core = core;
|
|
664
|
-
this
|
|
717
|
+
_defineProperty(this, "logger", getLogger([
|
|
718
|
+
"core",
|
|
719
|
+
"token-standard-service",
|
|
720
|
+
"v2",
|
|
721
|
+
"allocation-service"
|
|
722
|
+
]));
|
|
665
723
|
}
|
|
666
724
|
static fundingNeeds(spec) {
|
|
667
725
|
const needs = /* @__PURE__ */ new Map();
|
|
@@ -801,44 +859,6 @@ var AllocationService = class AllocationService {
|
|
|
801
859
|
}
|
|
802
860
|
};
|
|
803
861
|
//#endregion
|
|
804
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
|
|
805
|
-
function _typeof(o) {
|
|
806
|
-
"@babel/helpers - typeof";
|
|
807
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
808
|
-
return typeof o;
|
|
809
|
-
} : function(o) {
|
|
810
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
811
|
-
}, _typeof(o);
|
|
812
|
-
}
|
|
813
|
-
//#endregion
|
|
814
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
|
|
815
|
-
function toPrimitive(t, r) {
|
|
816
|
-
if ("object" != _typeof(t) || !t) return t;
|
|
817
|
-
var e = t[Symbol.toPrimitive];
|
|
818
|
-
if (void 0 !== e) {
|
|
819
|
-
var i = e.call(t, r || "default");
|
|
820
|
-
if ("object" != _typeof(i)) return i;
|
|
821
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
822
|
-
}
|
|
823
|
-
return ("string" === r ? String : Number)(t);
|
|
824
|
-
}
|
|
825
|
-
//#endregion
|
|
826
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
|
|
827
|
-
function toPropertyKey(t) {
|
|
828
|
-
var i = toPrimitive(t, "string");
|
|
829
|
-
return "symbol" == _typeof(i) ? i : i + "";
|
|
830
|
-
}
|
|
831
|
-
//#endregion
|
|
832
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
|
|
833
|
-
function _defineProperty(e, r, t) {
|
|
834
|
-
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
835
|
-
value: t,
|
|
836
|
-
enumerable: !0,
|
|
837
|
-
configurable: !0,
|
|
838
|
-
writable: !0
|
|
839
|
-
}) : e[r] = t, e;
|
|
840
|
-
}
|
|
841
|
-
//#endregion
|
|
842
862
|
//#region src/token-standard-service.ts
|
|
843
863
|
function isApiVersion(v) {
|
|
844
864
|
return SUPPORTED_VERSIONS.includes(v);
|
|
@@ -864,21 +884,25 @@ function resolveCapabilities(opts) {
|
|
|
864
884
|
return resolvedCapabilities;
|
|
865
885
|
}
|
|
866
886
|
var TokenStandardService = class {
|
|
867
|
-
constructor(ledgerProvider,
|
|
887
|
+
constructor(ledgerProvider, accessTokenProvider, isMasterUser) {
|
|
868
888
|
this.ledgerProvider = ledgerProvider;
|
|
869
|
-
this.logger = logger;
|
|
870
889
|
this.accessTokenProvider = accessTokenProvider;
|
|
871
890
|
this.isMasterUser = isMasterUser;
|
|
891
|
+
_defineProperty(this, "logger", getLogger([
|
|
892
|
+
"core",
|
|
893
|
+
"token-standard-service",
|
|
894
|
+
"TokenStandardService"
|
|
895
|
+
]));
|
|
872
896
|
_defineProperty(this, "core", void 0);
|
|
873
897
|
_defineProperty(this, "allocation", void 0);
|
|
874
898
|
_defineProperty(this, "transfer", void 0);
|
|
875
899
|
_defineProperty(this, "v2", void 0);
|
|
876
|
-
this.core = new CoreService(ledgerProvider,
|
|
877
|
-
this.allocation = new AllocationService$1(this.core
|
|
878
|
-
this.transfer = new TransferService(this.core
|
|
900
|
+
this.core = new CoreService(ledgerProvider, accessTokenProvider, isMasterUser);
|
|
901
|
+
this.allocation = new AllocationService$1(this.core);
|
|
902
|
+
this.transfer = new TransferService(this.core);
|
|
879
903
|
this.v2 = {
|
|
880
|
-
transfer: new TransferServiceV2(this.core
|
|
881
|
-
allocation: new AllocationService(this.core
|
|
904
|
+
transfer: new TransferServiceV2(this.core),
|
|
905
|
+
allocation: new AllocationService(this.core)
|
|
882
906
|
};
|
|
883
907
|
}
|
|
884
908
|
async resolveCapabilitiesFromRegistryByInstrumentId(registryUrl, instrumentId) {
|
|
@@ -889,7 +913,7 @@ var TokenStandardService = class {
|
|
|
889
913
|
const params = { path: { instrumentId } };
|
|
890
914
|
return await this.core.getTokenStandardClient(registryUrl).get("/registry/metadata/v1/instruments/{instrumentId}", params);
|
|
891
915
|
} catch (e) {
|
|
892
|
-
this.logger.error
|
|
916
|
+
this.logger.warn("An error occurred while fetching the instrument by ID.", { error: e });
|
|
893
917
|
throw new Error(`Instrument id ${instrumentId} does not exist for this instrument admin.`, { cause: e });
|
|
894
918
|
}
|
|
895
919
|
}
|
|
@@ -948,7 +972,7 @@ var TokenStandardService = class {
|
|
|
948
972
|
query: {}
|
|
949
973
|
}
|
|
950
974
|
})).offset;
|
|
951
|
-
this.logger.debug(
|
|
975
|
+
this.logger.debug("Using offset", { afterOffsetOrLatest });
|
|
952
976
|
const updatesResponse = await this.ledgerProvider.request({
|
|
953
977
|
method: "ledgerApi",
|
|
954
978
|
params: {
|
|
@@ -972,7 +996,7 @@ var TokenStandardService = class {
|
|
|
972
996
|
});
|
|
973
997
|
return this.core.toPrettyTransactions(updatesResponse, partyId);
|
|
974
998
|
} catch (err) {
|
|
975
|
-
this.logger.
|
|
999
|
+
this.logger.warn("Failed to list holding transactions.", { error: err });
|
|
976
1000
|
throw err;
|
|
977
1001
|
}
|
|
978
1002
|
}
|