@canton-network/core-token-standard-service 2.1.0 → 2.3.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.
@@ -27,6 +27,7 @@ export declare class CoreService {
27
27
  limit?: number;
28
28
  offset?: number;
29
29
  continueUntilCompletion?: boolean;
30
+ excludeCids?: ReadonlySet<string>;
30
31
  }): Promise<string[]>;
31
32
  getInputHoldingsCids(options: {
32
33
  sender: 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,EACpC,MAAM,wCAAwC,CAAA;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAEzD,OAAO,EAGH,KAAK,cAAc,EAEnB,KAAK,SAAS,EACd,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAChB,KAAK,cAAc,EAEtB,MAAM,gCAAgC,CAAA;AACvC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAA;AAC3E,OAAO,KAAK,EACR,sBAAsB,EAEzB,MAAM,sCAAsC,CAAA;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,KAAK,EACR,UAAU,EACV,0BAA0B,EAC1B,6BAA6B,EAE7B,mBAAmB,EACnB,oBAAoB,EAIvB,MAAM,YAAY,CAAA;AAInB,qBAAa,WAAW;IAQhB,OAAO,CAAC,cAAc;IACtB,OAAO,CAAC,mBAAmB;IAC3B,OAAO,CAAC,QAAQ,CAAC,YAAY;IATjC,OAAO,CAAC,MAAM,CAIZ;IAEF,YACY,cAAc,EAAE,sBAAsB,EACtC,mBAAmB,EAAE,mBA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AmB,EACtC,OAAO,EAAE,OAAO,GACjB,OAAO,CAAC,cAAc,EAAE,CAAC,CAS3B;IAED,OAAO,CAAC,wBAAwB;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
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region \0rolldown/runtime.js
2
+ // \0rolldown/runtime.js
3
3
  var __create = Object.create;
4
4
  var __defProp = Object.defineProperty;
5
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -20,7 +20,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
20
20
  value: mod,
21
21
  enumerable: true
22
22
  }) : target, mod));
23
- //#endregion
24
23
  let _canton_network_core_token_standard = require("@canton-network/core-token-standard");
25
24
  let _canton_network_core_ledger_client_types = require("@canton-network/core-ledger-client-types");
26
25
  let _canton_network_core_tx_parser = require("@canton-network/core-tx-parser");
@@ -29,7 +28,7 @@ decimal_js = __toESM(decimal_js, 1);
29
28
  let _canton_network_core_token_standard_v2 = require("@canton-network/core-token-standard-v2");
30
29
  let _logtape_logtape = require("@logtape/logtape");
31
30
  let _canton_network_core_acs_reader = require("@canton-network/core-acs-reader");
32
- //#region src/types.ts
31
+ // src/types.ts
33
32
  const REQUESTED_AT_SKEW_MS = 6e4;
34
33
  const EMPTY_META = { values: {} };
35
34
  const SUPPORTED_VERSIONS = ["v1", "v2"];
@@ -40,8 +39,7 @@ const KEY_MAPPING = {
40
39
  "allocation-instruction": "allocationInstruction",
41
40
  "allocation-request": "allocationRequest"
42
41
  };
43
- //#endregion
44
- //#region \0@oxc-project+runtime@0.154.0/helpers/esm/typeof.js
42
+ // \0@oxc-project+runtime@0.156.0/helpers/esm/typeof.js
45
43
  function _typeof(o) {
46
44
  "@babel/helpers - typeof";
47
45
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -50,8 +48,7 @@ function _typeof(o) {
50
48
  return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
51
49
  }, _typeof(o);
52
50
  }
53
- //#endregion
54
- //#region \0@oxc-project+runtime@0.154.0/helpers/esm/toPrimitive.js
51
+ // \0@oxc-project+runtime@0.156.0/helpers/esm/toPrimitive.js
55
52
  function toPrimitive(t, r) {
56
53
  if ("object" != _typeof(t) || !t) return t;
57
54
  var e = t[Symbol.toPrimitive];
@@ -62,14 +59,12 @@ function toPrimitive(t, r) {
62
59
  }
63
60
  return ("string" === r ? String : Number)(t);
64
61
  }
65
- //#endregion
66
- //#region \0@oxc-project+runtime@0.154.0/helpers/esm/toPropertyKey.js
62
+ // \0@oxc-project+runtime@0.156.0/helpers/esm/toPropertyKey.js
67
63
  function toPropertyKey(t) {
68
64
  var i = toPrimitive(t, "string");
69
65
  return "symbol" == _typeof(i) ? i : i + "";
70
66
  }
71
- //#endregion
72
- //#region \0@oxc-project+runtime@0.154.0/helpers/esm/defineProperty.js
67
+ // \0@oxc-project+runtime@0.156.0/helpers/esm/defineProperty.js
73
68
  function _defineProperty(e, r, t) {
74
69
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
75
70
  value: t,
@@ -78,8 +73,7 @@ function _defineProperty(e, r, t) {
78
73
  writable: !0
79
74
  }) : e[r] = t, e;
80
75
  }
81
- //#endregion
82
- //#region src/v2/transfer-service.ts
76
+ // src/v2/transfer-service.ts
83
77
  var TransferServiceV2 = class {
84
78
  constructor(core) {
85
79
  this.core = core;
@@ -189,8 +183,7 @@ var TransferServiceV2 = class {
189
183
  }, ctx.disclosedContracts ?? []];
190
184
  }
191
185
  };
192
- //#endregion
193
- //#region src/v1/transfer-service.ts
186
+ // src/v1/transfer-service.ts
194
187
  var TransferService = class {
195
188
  constructor(core) {
196
189
  this.core = core;
@@ -416,8 +409,7 @@ var TransferService = class {
416
409
  }
417
410
  }
418
411
  };
419
- //#endregion
420
- //#region src/v1/allocation-service.ts
412
+ // src/v1/allocation-service.ts
421
413
  var AllocationService$1 = class {
422
414
  constructor(core) {
423
415
  this.core = core;
@@ -570,8 +562,7 @@ var AllocationService$1 = class {
570
562
  }, []];
571
563
  }
572
564
  };
573
- //#endregion
574
- //#region src/core-service.ts
565
+ // src/core-service.ts
575
566
  var CoreService = class CoreService {
576
567
  constructor(ledgerProvider, accessTokenProvider, isMasterUser) {
577
568
  this.ledgerProvider = ledgerProvider;
@@ -608,7 +599,7 @@ var CoreService = class CoreService {
608
599
  const party = opts.partyId ?? opts.account.owner;
609
600
  if (!party) throw new Error("No party to query as");
610
601
  const now = /* @__PURE__ */ new Date();
611
- const holdings = (await this.listContractsByInterface("#splice-api-token-holding-v2:Splice.Api.Token.HoldingV2:Holding", party, opts.limit, opts.offset, opts.continueUntilCompletion ?? false)).filter((h) => h.interfaceViewValue.instrumentId.admin === opts.instrumentAdmin && h.interfaceViewValue.instrumentId.id == opts.instrumentId && this.isSameAccount(opts.account, h.interfaceViewValue.account) && !TokenStandardService.isHoldingLocked(h, now));
602
+ const holdings = (await this.listContractsByInterface(_canton_network_core_token_standard_v2.HOLDING_INTERFACE_ID_V2, party, opts.limit, opts.offset, opts.continueUntilCompletion ?? true)).filter((h) => h.interfaceViewValue.instrumentId.admin === opts.instrumentAdmin && h.interfaceViewValue.instrumentId.id === opts.instrumentId && this.isSameAccount(opts.account, h.interfaceViewValue.account) && !TokenStandardService.isHoldingLocked(h, now) && !opts.excludeCids?.has(h.contractId));
612
603
  return opts.amount ? CoreService.getInputHoldingsCidsForAmount(opts.amount, holdings) : holdings.map((h) => h.contractId);
613
604
  }
614
605
  async getInputHoldingsCids(options) {
@@ -729,8 +720,7 @@ var CoreService = class CoreService {
729
720
  return /^(PAR|MED)::/.test(memberId) ? memberId : `PAR::${memberId}`;
730
721
  }
731
722
  };
732
- //#endregion
733
- //#region src/v2/allocation-service.ts
723
+ // src/v2/allocation-service.ts
734
724
  const EMPTY_EXTRA_ARGS = () => ({
735
725
  context: { values: {} },
736
726
  meta: { values: {} }
@@ -767,7 +757,8 @@ var AllocationService = class AllocationService {
767
757
  account: spec.authorizer,
768
758
  instrumentAdmin: admin,
769
759
  instrumentId,
770
- amount
760
+ amount,
761
+ excludeCids: used
771
762
  });
772
763
  cids.forEach((c) => used.add(c));
773
764
  inputHoldingCids.push(...cids);
@@ -813,10 +804,15 @@ var AllocationService = class AllocationService {
813
804
  return this.createAllocationChoiceFromContext(action, allocationCid, actors, ctx);
814
805
  }
815
806
  createAllocationRequestChoice(action, allocationRequestCid, actors) {
807
+ const choice = {
808
+ accept: "AllocationRequest_Accept",
809
+ reject: "AllocationRequest_Reject",
810
+ withdraw: "AllocationRequest_Withdraw"
811
+ }[action];
816
812
  return [{
817
813
  templateId: _canton_network_core_token_standard_v2.ALLOCATION_REQUEST_INTERFACE_ID_V2,
818
814
  contractId: allocationRequestCid,
819
- choice: action === "reject" ? "AllocationRequest_Reject" : "AllocationRequest_Withdraw",
815
+ choice,
820
816
  choiceArgument: {
821
817
  actors,
822
818
  extraArgs: EMPTY_EXTRA_ARGS()
@@ -858,12 +854,36 @@ var AllocationService = class AllocationService {
858
854
  choiceArgument: choiceArgs
859
855
  }, choiceContext.disclosedContracts];
860
856
  }
857
+ async fetchAllocationInstructionChoiceContext(action, allocationInstructionCid, registryUrl, excludeDebugFields = true) {
858
+ return this.core.getTokenStandardClientV2(registryUrl).post(`/registry/allocation-instruction/v2/{allocationInstructionId}/choice-contexts/${action}`, { excludeDebugFields }, { path: { allocationInstructionId: allocationInstructionCid } });
859
+ }
860
+ async createAllocationInstructionChoice(action, allocationInstructionCid, actors, registryUrl, excludeDebugFields = true, prefetched) {
861
+ const ctx = prefetched ?? await this.fetchAllocationInstructionChoiceContext(action, allocationInstructionCid, registryUrl, excludeDebugFields);
862
+ return [{
863
+ templateId: _canton_network_core_token_standard_v2.ALLOCATION_INSTRUCTION_INTERFACE_ID_V2,
864
+ contractId: allocationInstructionCid,
865
+ choice: action === "accept" ? _canton_network_core_token_standard_v2.AllocationInstruction.AllocationInstruction_Accept.choiceName : _canton_network_core_token_standard_v2.AllocationInstruction.AllocationInstruction_Withdraw.choiceName,
866
+ choiceArgument: {
867
+ actors,
868
+ extraArgs: {
869
+ context: ctx.choiceContextData,
870
+ meta: { values: {} }
871
+ }
872
+ }
873
+ }, ctx.disclosedContracts ?? []];
874
+ }
861
875
  async fetchSettlementFactory(args, registryUrl) {
862
876
  return this.core.getTokenStandardClientV2(registryUrl).post("/registry/allocation/v2/settlement-factory", {
863
877
  choiceArguments: args,
864
878
  excludeDebugFields: true
865
879
  });
866
880
  }
881
+ /**
882
+ *
883
+ * @deprecated Use {@link createAllocationsForRequestForLoggedInParty}
884
+ * instead, which creates only the allocations owned by a given party and
885
+ * reports allocations whose registry could not be resolved
886
+ */
867
887
  async createAllocationsForRequest(opts) {
868
888
  const used = /* @__PURE__ */ new Set();
869
889
  const results = [];
@@ -892,9 +912,60 @@ var AllocationService = class AllocationService {
892
912
  const dcs = new Map(results.flatMap(([, d]) => d).filter((d) => d.contractId !== void 0).map((d) => [d.contractId, d]));
893
913
  return [results.map(([c]) => c), [...dcs.values()]];
894
914
  }
915
+ /**
916
+ * Prepares the commands for a party to accept an allocation request.
917
+ *
918
+ * Creates one `AllocationFactory_Allocate` command for each allocation in the
919
+ * request that the party owns, followed by an `AllocationRequest_Accept`
920
+ * command. Holdings used as inputs by one allocation are excluded from later
921
+ * allocations, so no holding is spent twice within the same request.
922
+ *
923
+ * If no registry serves an allocation's instrument admin, that allocation is
924
+ * skipped and its admin is added to `skipped`. In that case `accept` is
925
+ * `null`, because the request cannot be accepted until every allocation
926
+ * exists.
927
+ *
928
+ * @param opts.requestCid - Contract ID of the allocation request.
929
+ * @param opts.request - The allocation request's interface view.
930
+ * @param opts.registry - Resolves an instrument admin to its registry URL,
931
+ * or `null` if no registry serves that admin.
932
+ * @param opts.partyId - The party accepting the request. Only allocations
933
+ * this party owns are created, and it acts on every command.
934
+ * @returns The allocate commands with their disclosed contracts, the accept
935
+ * command with its disclosed contracts (or `null` if any allocation was
936
+ * skipped), and the admins whose allocations were skipped.
937
+ * @throws If the request contains no allocations owned by `partyId`.
938
+ */
939
+ async createAllocationsForRequestForLoggedInParty(opts) {
940
+ const specs = opts.request.allocations.filter((p) => p.authorizer.owner === opts.partyId);
941
+ if (specs.length === 0) throw new Error(`Request ${opts.requestCid} has no allocation for account ${opts.partyId}`);
942
+ const used = /* @__PURE__ */ new Set();
943
+ const allocate = [];
944
+ const skipped = [];
945
+ for (const spec of specs) {
946
+ const registryUrl = await opts.registry(spec.admin);
947
+ if (!registryUrl) {
948
+ skipped.push(spec.admin);
949
+ continue;
950
+ }
951
+ const [cmd, dcs] = await this.createAllocation({
952
+ settlement: opts.request.settlement,
953
+ spec,
954
+ admin: spec.admin,
955
+ actors: [opts.partyId],
956
+ excludeCids: used
957
+ }, registryUrl);
958
+ for (const cid of cmd.choiceArgument.inputHoldingCids) used.add(cid);
959
+ allocate.push([cmd, dcs]);
960
+ }
961
+ return {
962
+ allocate,
963
+ accept: skipped.length === 0 ? this.createAllocationRequestChoice("accept", opts.requestCid, [opts.partyId]) : null,
964
+ skipped
965
+ };
966
+ }
895
967
  };
896
- //#endregion
897
- //#region src/token-standard-service.ts
968
+ // src/token-standard-service.ts
898
969
  function isApiVersion(v) {
899
970
  return SUPPORTED_VERSIONS.includes(v);
900
971
  }
@@ -918,7 +989,7 @@ function resolveCapabilities(opts) {
918
989
  for (const key in resolvedCapabilities) resolvedCapabilities[key].sort();
919
990
  return resolvedCapabilities;
920
991
  }
921
- var TokenStandardService = class {
992
+ var TokenStandardService = class TokenStandardService {
922
993
  constructor(ledgerProvider, accessTokenProvider, isMasterUser) {
923
994
  this.ledgerProvider = ledgerProvider;
924
995
  this.accessTokenProvider = accessTokenProvider;
@@ -1129,13 +1200,12 @@ var TokenStandardService = class {
1129
1200
  }
1130
1201
  }, disclosedContracts];
1131
1202
  }
1132
- static isHoldingLocked(holding, currentTime = /* @__PURE__ */ new Date()) {
1133
- const lock = holding.interfaceViewValue.lock;
1203
+ static checkLock(lock, createdAtTime, currentTime = /* @__PURE__ */ new Date()) {
1134
1204
  if (!lock) return false;
1135
1205
  let expiresAtAbsolute = null;
1136
1206
  let expiresAtRelative = null;
1137
1207
  if (lock.expiresAfter) {
1138
- const createdAt = new Date(holding.activeContract.createdEvent.createdAt);
1208
+ const createdAt = new Date(createdAtTime);
1139
1209
  const msToAdd = parseInt(lock.expiresAfter.microseconds) / 1e3;
1140
1210
  expiresAtRelative = new Date(createdAt.getTime() + msToAdd);
1141
1211
  }
@@ -1147,9 +1217,12 @@ var TokenStandardService = class {
1147
1217
  else return true;
1148
1218
  return currentTime < expiresAt;
1149
1219
  }
1220
+ static isHoldingLocked(holding, currentTime = /* @__PURE__ */ new Date()) {
1221
+ const lock = holding.interfaceViewValue.lock;
1222
+ return TokenStandardService.checkLock(lock, holding.activeContract.createdEvent.createdAt, currentTime);
1223
+ }
1150
1224
  };
1151
1225
  _defineProperty(TokenStandardService, "MEMO_KEY", "splice.lfdecentralizedtrust.org/reason");
1152
- //#endregion
1153
1226
  exports.EMPTY_META = EMPTY_META;
1154
1227
  exports.KEY_MAPPING = KEY_MAPPING;
1155
1228
  exports.REQUESTED_AT_SKEW_MS = REQUESTED_AT_SKEW_MS;