@canton-network/core-token-standard-service 2.3.0 → 2.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/dist/core-service.d.ts +0 -1
- package/dist/core-service.d.ts.map +1 -1
- package/dist/index.cjs +15 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +16 -17
- package/dist/index.js.map +1 -1
- package/dist/v2/allocation-service.d.ts +2 -0
- package/dist/v2/allocation-service.d.ts.map +1 -1
- package/package.json +11 -11
package/dist/core-service.d.ts
CHANGED
|
@@ -16,7 +16,6 @@ export declare class CoreService {
|
|
|
16
16
|
getTokenStandardClient(registryUrl: URL): TokenStandardClient;
|
|
17
17
|
getTokenStandardClientV2(registryUrl: URL): TokenStandardClientV2;
|
|
18
18
|
toBasicAccount(partyId: PartyId): Account;
|
|
19
|
-
private isSameAccount;
|
|
20
19
|
getInputHoldingCidsForAccount(opts: {
|
|
21
20
|
account: Account;
|
|
22
21
|
partyId?: PartyId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-service.d.ts","sourceRoot":"","sources":["../src/core-service.ts"],"names":[],"mappings":"AAGA,OAAO,EACH,mBAAmB,EAEnB,KAAK,WAAW,EACnB,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EACH,KAAK,OAAO,EACZ,mBAAmB,IAAI,qBAAqB,EAC5C,KAAK,WAAW,IAAI,aAAa,
|
|
1
|
+
{"version":3,"file":"core-service.d.ts","sourceRoot":"","sources":["../src/core-service.ts"],"names":[],"mappings":"AAGA,OAAO,EACH,mBAAmB,EAEnB,KAAK,WAAW,EACnB,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EACH,KAAK,OAAO,EACZ,mBAAmB,IAAI,qBAAqB,EAC5C,KAAK,WAAW,IAAI,aAAa,EAGpC,MAAM,wCAAwC,CAAA;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAEzD,OAAO,EAGH,K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BAAwB;IAU1B,4BAA4B,CAC9B,OAAO,EAAE,oBAAoB,EAAE,EAC/B,OAAO,EAAE,OAAO,EAAE,GACnB,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC,CAU3C;IAID,gBAAgB,CAAC,CAAC,EACd,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,6BAA6B,EACvC,MAAM,CAAC,EAAE,MAAM,GAChB,cAAc,CAAC,CAAC,CAAC,CAanB;IAED,mBAAmB,CAAC,QAAQ,EAAE,MAAM,UAInC;CACJ"}
|
package/dist/index.cjs
CHANGED
|
@@ -39,7 +39,7 @@ const KEY_MAPPING = {
|
|
|
39
39
|
"allocation-instruction": "allocationInstruction",
|
|
40
40
|
"allocation-request": "allocationRequest"
|
|
41
41
|
};
|
|
42
|
-
// \0@oxc-project+runtime@0.
|
|
42
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/typeof.js
|
|
43
43
|
function _typeof(o) {
|
|
44
44
|
"@babel/helpers - typeof";
|
|
45
45
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -48,23 +48,23 @@ function _typeof(o) {
|
|
|
48
48
|
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
49
49
|
}, _typeof(o);
|
|
50
50
|
}
|
|
51
|
-
// \0@oxc-project+runtime@0.
|
|
52
|
-
function toPrimitive(t,
|
|
51
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/toPrimitive.js
|
|
52
|
+
function toPrimitive(t, e) {
|
|
53
53
|
if ("object" != _typeof(t) || !t) return t;
|
|
54
|
-
var
|
|
55
|
-
if (void 0 !==
|
|
56
|
-
var i =
|
|
54
|
+
var r;
|
|
55
|
+
if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
|
|
56
|
+
var i = r.call(t, e || "default");
|
|
57
57
|
if ("object" != _typeof(i)) return i;
|
|
58
58
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
59
59
|
}
|
|
60
|
-
return ("string" ===
|
|
60
|
+
return ("string" === e ? String : Number)(t);
|
|
61
61
|
}
|
|
62
|
-
// \0@oxc-project+runtime@0.
|
|
62
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/toPropertyKey.js
|
|
63
63
|
function toPropertyKey(t) {
|
|
64
64
|
var i = toPrimitive(t, "string");
|
|
65
65
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
66
66
|
}
|
|
67
|
-
// \0@oxc-project+runtime@0.
|
|
67
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/defineProperty.js
|
|
68
68
|
function _defineProperty(e, r, t) {
|
|
69
69
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
70
70
|
value: t,
|
|
@@ -591,15 +591,12 @@ var CoreService = class CoreService {
|
|
|
591
591
|
id: ""
|
|
592
592
|
};
|
|
593
593
|
}
|
|
594
|
-
isSameAccount(a, b) {
|
|
595
|
-
return a.id === b.id && a.owner === b.owner && a.provider === b.provider;
|
|
596
|
-
}
|
|
597
594
|
async getInputHoldingCidsForAccount(opts) {
|
|
598
595
|
if (opts.inputUtxos?.length) return opts.inputUtxos;
|
|
599
596
|
const party = opts.partyId ?? opts.account.owner;
|
|
600
597
|
if (!party) throw new Error("No party to query as");
|
|
601
598
|
const now = /* @__PURE__ */ new Date();
|
|
602
|
-
const holdings = (await this.listContractsByInterface(_canton_network_core_token_standard_v2.HOLDING_INTERFACE_ID_V2, party, opts.limit, opts.offset, opts.continueUntilCompletion ??
|
|
599
|
+
const holdings = (await this.listContractsByInterface(_canton_network_core_token_standard_v2.HOLDING_INTERFACE_ID_V2, party, opts.limit, opts.offset, opts.continueUntilCompletion ?? false)).filter((h) => h.interfaceViewValue.instrumentId.admin === opts.instrumentAdmin && h.interfaceViewValue.instrumentId.id === opts.instrumentId && (0, _canton_network_core_token_standard_v2.isSameAccount)(opts.account, h.interfaceViewValue.account) && !TokenStandardService.isHoldingLocked(h, now) && !opts.excludeCids?.has(h.contractId));
|
|
603
600
|
return opts.amount ? CoreService.getInputHoldingsCidsForAmount(opts.amount, holdings) : holdings.map((h) => h.contractId);
|
|
604
601
|
}
|
|
605
602
|
async getInputHoldingsCids(options) {
|
|
@@ -931,21 +928,23 @@ var AllocationService = class AllocationService {
|
|
|
931
928
|
* or `null` if no registry serves that admin.
|
|
932
929
|
* @param opts.partyId - The party accepting the request. Only allocations
|
|
933
930
|
* this party owns are created, and it acts on every command.
|
|
931
|
+
* @params opts.skipSpec Specs to leave out (e.g. already allocated by an earlier attempt).
|
|
934
932
|
* @returns The allocate commands with their disclosed contracts, the accept
|
|
935
933
|
* command with its disclosed contracts (or `null` if any allocation was
|
|
936
934
|
* skipped), and the admins whose allocations were skipped.
|
|
937
935
|
* @throws If the request contains no allocations owned by `partyId`.
|
|
938
936
|
*/
|
|
939
937
|
async createAllocationsForRequestForLoggedInParty(opts) {
|
|
940
|
-
const
|
|
941
|
-
if (
|
|
938
|
+
const ownSpecs = opts.request.allocations.filter((p) => p.authorizer.owner === opts.partyId);
|
|
939
|
+
if (ownSpecs.length === 0) throw new Error(`Request ${opts.requestCid} has no allocation for account ${opts.partyId}`);
|
|
940
|
+
const specs = opts.skipSpec ? ownSpecs.filter((spec) => !opts.skipSpec(spec)) : ownSpecs;
|
|
942
941
|
const used = /* @__PURE__ */ new Set();
|
|
943
942
|
const allocate = [];
|
|
944
943
|
const skipped = [];
|
|
945
944
|
for (const spec of specs) {
|
|
946
945
|
const registryUrl = await opts.registry(spec.admin);
|
|
947
946
|
if (!registryUrl) {
|
|
948
|
-
skipped.push(spec.admin);
|
|
947
|
+
if (!skipped.includes(spec.admin)) skipped.push(spec.admin);
|
|
949
948
|
continue;
|
|
950
949
|
}
|
|
951
950
|
const [cmd, dcs] = await this.createAllocation({
|