@canton-network/core-token-standard-service 2.2.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.
@@ -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;
@@ -27,6 +26,7 @@ export declare class CoreService {
27
26
  limit?: number;
28
27
  offset?: number;
29
28
  continueUntilCompletion?: boolean;
29
+ excludeCids?: ReadonlySet<string>;
30
30
  }): Promise<string[]>;
31
31
  getInputHoldingsCids(options: {
32
32
  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,oBA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,OAAO,EAAE,OAAO,GACjB,OAAO,CAAC,kBAAkB,CAAC,CA0D7B;IAEK,mBAAmB,CACrB,iBAAiB,EAAE,mBAAmB,EACtC,OAAO,EAAE,OAAO,GACjB,OAAO,CAAC,WAAW,CAAC,CAUtB;IAEK,uBAAuB,CACzB,iBAAiB,EAAE,mBAAmB,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
@@ -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.155.0/helpers/esm/typeof.js
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.155.0/helpers/esm/toPrimitive.js
52
- function toPrimitive(t, r) {
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 e = t[Symbol.toPrimitive];
55
- if (void 0 !== e) {
56
- var i = e.call(t, r || "default");
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" === r ? String : Number)(t);
60
+ return ("string" === e ? String : Number)(t);
61
61
  }
62
- // \0@oxc-project+runtime@0.155.0/helpers/esm/toPropertyKey.js
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.155.0/helpers/esm/defineProperty.js
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("#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));
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) {
@@ -757,7 +754,8 @@ var AllocationService = class AllocationService {
757
754
  account: spec.authorizer,
758
755
  instrumentAdmin: admin,
759
756
  instrumentId,
760
- amount
757
+ amount,
758
+ excludeCids: used
761
759
  });
762
760
  cids.forEach((c) => used.add(c));
763
761
  inputHoldingCids.push(...cids);
@@ -803,10 +801,15 @@ var AllocationService = class AllocationService {
803
801
  return this.createAllocationChoiceFromContext(action, allocationCid, actors, ctx);
804
802
  }
805
803
  createAllocationRequestChoice(action, allocationRequestCid, actors) {
804
+ const choice = {
805
+ accept: "AllocationRequest_Accept",
806
+ reject: "AllocationRequest_Reject",
807
+ withdraw: "AllocationRequest_Withdraw"
808
+ }[action];
806
809
  return [{
807
810
  templateId: _canton_network_core_token_standard_v2.ALLOCATION_REQUEST_INTERFACE_ID_V2,
808
811
  contractId: allocationRequestCid,
809
- choice: action === "reject" ? "AllocationRequest_Reject" : "AllocationRequest_Withdraw",
812
+ choice,
810
813
  choiceArgument: {
811
814
  actors,
812
815
  extraArgs: EMPTY_EXTRA_ARGS()
@@ -848,12 +851,36 @@ var AllocationService = class AllocationService {
848
851
  choiceArgument: choiceArgs
849
852
  }, choiceContext.disclosedContracts];
850
853
  }
854
+ async fetchAllocationInstructionChoiceContext(action, allocationInstructionCid, registryUrl, excludeDebugFields = true) {
855
+ return this.core.getTokenStandardClientV2(registryUrl).post(`/registry/allocation-instruction/v2/{allocationInstructionId}/choice-contexts/${action}`, { excludeDebugFields }, { path: { allocationInstructionId: allocationInstructionCid } });
856
+ }
857
+ async createAllocationInstructionChoice(action, allocationInstructionCid, actors, registryUrl, excludeDebugFields = true, prefetched) {
858
+ const ctx = prefetched ?? await this.fetchAllocationInstructionChoiceContext(action, allocationInstructionCid, registryUrl, excludeDebugFields);
859
+ return [{
860
+ templateId: _canton_network_core_token_standard_v2.ALLOCATION_INSTRUCTION_INTERFACE_ID_V2,
861
+ contractId: allocationInstructionCid,
862
+ choice: action === "accept" ? _canton_network_core_token_standard_v2.AllocationInstruction.AllocationInstruction_Accept.choiceName : _canton_network_core_token_standard_v2.AllocationInstruction.AllocationInstruction_Withdraw.choiceName,
863
+ choiceArgument: {
864
+ actors,
865
+ extraArgs: {
866
+ context: ctx.choiceContextData,
867
+ meta: { values: {} }
868
+ }
869
+ }
870
+ }, ctx.disclosedContracts ?? []];
871
+ }
851
872
  async fetchSettlementFactory(args, registryUrl) {
852
873
  return this.core.getTokenStandardClientV2(registryUrl).post("/registry/allocation/v2/settlement-factory", {
853
874
  choiceArguments: args,
854
875
  excludeDebugFields: true
855
876
  });
856
877
  }
878
+ /**
879
+ *
880
+ * @deprecated Use {@link createAllocationsForRequestForLoggedInParty}
881
+ * instead, which creates only the allocations owned by a given party and
882
+ * reports allocations whose registry could not be resolved
883
+ */
857
884
  async createAllocationsForRequest(opts) {
858
885
  const used = /* @__PURE__ */ new Set();
859
886
  const results = [];
@@ -882,6 +909,60 @@ var AllocationService = class AllocationService {
882
909
  const dcs = new Map(results.flatMap(([, d]) => d).filter((d) => d.contractId !== void 0).map((d) => [d.contractId, d]));
883
910
  return [results.map(([c]) => c), [...dcs.values()]];
884
911
  }
912
+ /**
913
+ * Prepares the commands for a party to accept an allocation request.
914
+ *
915
+ * Creates one `AllocationFactory_Allocate` command for each allocation in the
916
+ * request that the party owns, followed by an `AllocationRequest_Accept`
917
+ * command. Holdings used as inputs by one allocation are excluded from later
918
+ * allocations, so no holding is spent twice within the same request.
919
+ *
920
+ * If no registry serves an allocation's instrument admin, that allocation is
921
+ * skipped and its admin is added to `skipped`. In that case `accept` is
922
+ * `null`, because the request cannot be accepted until every allocation
923
+ * exists.
924
+ *
925
+ * @param opts.requestCid - Contract ID of the allocation request.
926
+ * @param opts.request - The allocation request's interface view.
927
+ * @param opts.registry - Resolves an instrument admin to its registry URL,
928
+ * or `null` if no registry serves that admin.
929
+ * @param opts.partyId - The party accepting the request. Only allocations
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).
932
+ * @returns The allocate commands with their disclosed contracts, the accept
933
+ * command with its disclosed contracts (or `null` if any allocation was
934
+ * skipped), and the admins whose allocations were skipped.
935
+ * @throws If the request contains no allocations owned by `partyId`.
936
+ */
937
+ async createAllocationsForRequestForLoggedInParty(opts) {
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;
941
+ const used = /* @__PURE__ */ new Set();
942
+ const allocate = [];
943
+ const skipped = [];
944
+ for (const spec of specs) {
945
+ const registryUrl = await opts.registry(spec.admin);
946
+ if (!registryUrl) {
947
+ if (!skipped.includes(spec.admin)) skipped.push(spec.admin);
948
+ continue;
949
+ }
950
+ const [cmd, dcs] = await this.createAllocation({
951
+ settlement: opts.request.settlement,
952
+ spec,
953
+ admin: spec.admin,
954
+ actors: [opts.partyId],
955
+ excludeCids: used
956
+ }, registryUrl);
957
+ for (const cid of cmd.choiceArgument.inputHoldingCids) used.add(cid);
958
+ allocate.push([cmd, dcs]);
959
+ }
960
+ return {
961
+ allocate,
962
+ accept: skipped.length === 0 ? this.createAllocationRequestChoice("accept", opts.requestCid, [opts.partyId]) : null,
963
+ skipped
964
+ };
965
+ }
885
966
  };
886
967
  // src/token-standard-service.ts
887
968
  function isApiVersion(v) {
@@ -907,7 +988,7 @@ function resolveCapabilities(opts) {
907
988
  for (const key in resolvedCapabilities) resolvedCapabilities[key].sort();
908
989
  return resolvedCapabilities;
909
990
  }
910
- var TokenStandardService = class {
991
+ var TokenStandardService = class TokenStandardService {
911
992
  constructor(ledgerProvider, accessTokenProvider, isMasterUser) {
912
993
  this.ledgerProvider = ledgerProvider;
913
994
  this.accessTokenProvider = accessTokenProvider;
@@ -1118,13 +1199,12 @@ var TokenStandardService = class {
1118
1199
  }
1119
1200
  }, disclosedContracts];
1120
1201
  }
1121
- static isHoldingLocked(holding, currentTime = /* @__PURE__ */ new Date()) {
1122
- const lock = holding.interfaceViewValue.lock;
1202
+ static checkLock(lock, createdAtTime, currentTime = /* @__PURE__ */ new Date()) {
1123
1203
  if (!lock) return false;
1124
1204
  let expiresAtAbsolute = null;
1125
1205
  let expiresAtRelative = null;
1126
1206
  if (lock.expiresAfter) {
1127
- const createdAt = new Date(holding.activeContract.createdEvent.createdAt);
1207
+ const createdAt = new Date(createdAtTime);
1128
1208
  const msToAdd = parseInt(lock.expiresAfter.microseconds) / 1e3;
1129
1209
  expiresAtRelative = new Date(createdAt.getTime() + msToAdd);
1130
1210
  }
@@ -1136,6 +1216,10 @@ var TokenStandardService = class {
1136
1216
  else return true;
1137
1217
  return currentTime < expiresAt;
1138
1218
  }
1219
+ static isHoldingLocked(holding, currentTime = /* @__PURE__ */ new Date()) {
1220
+ const lock = holding.interfaceViewValue.lock;
1221
+ return TokenStandardService.checkLock(lock, holding.activeContract.createdEvent.createdAt, currentTime);
1222
+ }
1139
1223
  };
1140
1224
  _defineProperty(TokenStandardService, "MEMO_KEY", "splice.lfdecentralizedtrust.org/reason");
1141
1225
  exports.EMPTY_META = EMPTY_META;