@canton-network/core-token-standard-service 2.0.0 → 2.2.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/index.js CHANGED
@@ -5,7 +5,7 @@ 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
6
  import { getLogger } from "@logtape/logtape";
7
7
  import { ACSReader } from "@canton-network/core-acs-reader";
8
- //#region src/types.ts
8
+ // src/types.ts
9
9
  const REQUESTED_AT_SKEW_MS = 6e4;
10
10
  const EMPTY_META = { values: {} };
11
11
  const SUPPORTED_VERSIONS = ["v1", "v2"];
@@ -16,8 +16,7 @@ const KEY_MAPPING = {
16
16
  "allocation-instruction": "allocationInstruction",
17
17
  "allocation-request": "allocationRequest"
18
18
  };
19
- //#endregion
20
- //#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
19
+ // \0@oxc-project+runtime@0.155.0/helpers/esm/typeof.js
21
20
  function _typeof(o) {
22
21
  "@babel/helpers - typeof";
23
22
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -26,8 +25,7 @@ function _typeof(o) {
26
25
  return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
27
26
  }, _typeof(o);
28
27
  }
29
- //#endregion
30
- //#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
28
+ // \0@oxc-project+runtime@0.155.0/helpers/esm/toPrimitive.js
31
29
  function toPrimitive(t, r) {
32
30
  if ("object" != _typeof(t) || !t) return t;
33
31
  var e = t[Symbol.toPrimitive];
@@ -38,14 +36,12 @@ function toPrimitive(t, r) {
38
36
  }
39
37
  return ("string" === r ? String : Number)(t);
40
38
  }
41
- //#endregion
42
- //#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
39
+ // \0@oxc-project+runtime@0.155.0/helpers/esm/toPropertyKey.js
43
40
  function toPropertyKey(t) {
44
41
  var i = toPrimitive(t, "string");
45
42
  return "symbol" == _typeof(i) ? i : i + "";
46
43
  }
47
- //#endregion
48
- //#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
44
+ // \0@oxc-project+runtime@0.155.0/helpers/esm/defineProperty.js
49
45
  function _defineProperty(e, r, t) {
50
46
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
51
47
  value: t,
@@ -54,8 +50,7 @@ function _defineProperty(e, r, t) {
54
50
  writable: !0
55
51
  }) : e[r] = t, e;
56
52
  }
57
- //#endregion
58
- //#region src/v2/transfer-service.ts
53
+ // src/v2/transfer-service.ts
59
54
  var TransferServiceV2 = class {
60
55
  constructor(core) {
61
56
  this.core = core;
@@ -165,8 +160,7 @@ var TransferServiceV2 = class {
165
160
  }, ctx.disclosedContracts ?? []];
166
161
  }
167
162
  };
168
- //#endregion
169
- //#region src/v1/transfer-service.ts
163
+ // src/v1/transfer-service.ts
170
164
  var TransferService = class {
171
165
  constructor(core) {
172
166
  this.core = core;
@@ -392,8 +386,7 @@ var TransferService = class {
392
386
  }
393
387
  }
394
388
  };
395
- //#endregion
396
- //#region src/v1/allocation-service.ts
389
+ // src/v1/allocation-service.ts
397
390
  var AllocationService$1 = class {
398
391
  constructor(core) {
399
392
  this.core = core;
@@ -546,8 +539,7 @@ var AllocationService$1 = class {
546
539
  }, []];
547
540
  }
548
541
  };
549
- //#endregion
550
- //#region src/core-service.ts
542
+ // src/core-service.ts
551
543
  var CoreService = class CoreService {
552
544
  constructor(ledgerProvider, accessTokenProvider, isMasterUser) {
553
545
  this.ledgerProvider = ledgerProvider;
@@ -623,7 +615,7 @@ var CoreService = class CoreService {
623
615
  currentSum = currentSum.plus(currentHoldingAmount);
624
616
  cIds.push(h.contractId);
625
617
  }
626
- if (currentSum.lessThan(amount)) throw new Error(`Sender doesn't have sufficient funds for this transfer. Missing amount: ${amount.minus(currentSum)}`);
618
+ if (currentSum.lessThan(amount)) throw new Error(`Sender doesn't have sufficient funds for this transfer. Missing amount: ${amount.minus(currentSum).toString()}`);
627
619
  if (cIds.length > 100) throw new Error(`Exceeded the maximum of 100 utxos in 1 transaction`);
628
620
  return cIds;
629
621
  }
@@ -705,8 +697,7 @@ var CoreService = class CoreService {
705
697
  return /^(PAR|MED)::/.test(memberId) ? memberId : `PAR::${memberId}`;
706
698
  }
707
699
  };
708
- //#endregion
709
- //#region src/v2/allocation-service.ts
700
+ // src/v2/allocation-service.ts
710
701
  const EMPTY_EXTRA_ARGS = () => ({
711
702
  context: { values: {} },
712
703
  meta: { values: {} }
@@ -810,6 +801,17 @@ var AllocationService = class AllocationService {
810
801
  }
811
802
  }, []];
812
803
  }
804
+ createAcceptAllocationInstruction(acceptCid, actors) {
805
+ return [{
806
+ templateId: ALLOCATION_INSTRUCTION_INTERFACE_ID_V2,
807
+ contractId: acceptCid,
808
+ choice: "AllocationInstruction_Accept",
809
+ choiceArgument: {
810
+ actors,
811
+ extraArgs: EMPTY_EXTRA_ARGS()
812
+ }
813
+ }, []];
814
+ }
813
815
  async createAllocationFromContext(factoryId, choiceArgs, choiceContext) {
814
816
  this.logger.debug("Creating transfer from pre-fetched context...");
815
817
  choiceArgs.extraArgs.context = {
@@ -858,8 +860,7 @@ var AllocationService = class AllocationService {
858
860
  return [results.map(([c]) => c), [...dcs.values()]];
859
861
  }
860
862
  };
861
- //#endregion
862
- //#region src/token-standard-service.ts
863
+ // src/token-standard-service.ts
863
864
  function isApiVersion(v) {
864
865
  return SUPPORTED_VERSIONS.includes(v);
865
866
  }
@@ -1114,7 +1115,6 @@ var TokenStandardService = class {
1114
1115
  }
1115
1116
  };
1116
1117
  _defineProperty(TokenStandardService, "MEMO_KEY", "splice.lfdecentralizedtrust.org/reason");
1117
- //#endregion
1118
1118
  export { EMPTY_META, KEY_MAPPING, REQUESTED_AT_SKEW_MS, SUPPORTED_VERSIONS, TokenStandardService, isApiVersion, resolveCapabilities };
1119
1119
 
1120
1120
  //# sourceMappingURL=index.js.map