@fairmint/canton-node-sdk 0.0.259 → 0.0.260

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.
Files changed (37) hide show
  1. package/build/src/utils/parsers/event-parser.d.ts +46 -0
  2. package/build/src/utils/parsers/event-parser.d.ts.map +1 -1
  3. package/build/src/utils/parsers/event-parser.js +137 -4
  4. package/build/src/utils/parsers/event-parser.js.map +1 -1
  5. package/build/src/utils/token-standard/index.d.ts +1 -0
  6. package/build/src/utils/token-standard/index.d.ts.map +1 -1
  7. package/build/src/utils/token-standard/index.js +1 -0
  8. package/build/src/utils/token-standard/index.js.map +1 -1
  9. package/build/src/utils/token-standard/v1/allocation.d.ts +34 -0
  10. package/build/src/utils/token-standard/v1/allocation.d.ts.map +1 -0
  11. package/build/src/utils/token-standard/v1/allocation.js +67 -0
  12. package/build/src/utils/token-standard/v1/allocation.js.map +1 -0
  13. package/build/src/utils/token-standard/v1/burn-mint.d.ts +43 -0
  14. package/build/src/utils/token-standard/v1/burn-mint.d.ts.map +1 -0
  15. package/build/src/utils/token-standard/v1/burn-mint.js +54 -0
  16. package/build/src/utils/token-standard/v1/burn-mint.js.map +1 -0
  17. package/build/src/utils/token-standard/v1/constants.d.ts +54 -0
  18. package/build/src/utils/token-standard/v1/constants.d.ts.map +1 -0
  19. package/build/src/utils/token-standard/v1/constants.js +66 -0
  20. package/build/src/utils/token-standard/v1/constants.js.map +1 -0
  21. package/build/src/utils/token-standard/v1/errors.d.ts +12 -0
  22. package/build/src/utils/token-standard/v1/errors.d.ts.map +1 -0
  23. package/build/src/utils/token-standard/v1/errors.js +17 -0
  24. package/build/src/utils/token-standard/v1/errors.js.map +1 -0
  25. package/build/src/utils/token-standard/v1/index.d.ts +7 -0
  26. package/build/src/utils/token-standard/v1/index.d.ts.map +1 -0
  27. package/build/src/utils/token-standard/v1/index.js +23 -0
  28. package/build/src/utils/token-standard/v1/index.js.map +1 -0
  29. package/build/src/utils/token-standard/v1/result.d.ts +27 -0
  30. package/build/src/utils/token-standard/v1/result.d.ts.map +1 -0
  31. package/build/src/utils/token-standard/v1/result.js +79 -0
  32. package/build/src/utils/token-standard/v1/result.js.map +1 -0
  33. package/build/src/utils/token-standard/v1/transfer.d.ts +27 -0
  34. package/build/src/utils/token-standard/v1/transfer.d.ts.map +1 -0
  35. package/build/src/utils/token-standard/v1/transfer.js +51 -0
  36. package/build/src/utils/token-standard/v1/transfer.js.map +1 -0
  37. package/package.json +1 -1
@@ -1,3 +1,4 @@
1
+ import { CantonError, type ErrorContext } from '../../core/errors';
1
2
  export interface ParsedTemplateId {
2
3
  readonly packageId: string;
3
4
  readonly module: string;
@@ -54,8 +55,53 @@ export interface ParsedTransactionEvents {
54
55
  }
55
56
  export declare function parseTemplateId(templateId: string): ParsedTemplateId;
56
57
  export declare function hasTemplateName(templateId: string, expectedTemplateName: string): boolean;
58
+ /** The `Module:Template` part of a template id, dropping the leading package id or `#package-name`. */
59
+ export declare function qualifiedTemplateName(templateId: string): string;
60
+ /**
61
+ * Match a template id from a ledger event against a filter, ignoring the package component.
62
+ *
63
+ * A create event always names the package _id_ that produced it, which a caller cannot know in advance; a filter is
64
+ * usually written with a package _name_ (`#MyPackage:Module:Template`) or without a package at all (`Module:Template`,
65
+ * or just `Template`). All three forms match here.
66
+ */
67
+ export declare function matchesTemplateId(templateId: string, filter: string): boolean;
57
68
  export declare function parseCreatedEvent(event: unknown): ParsedCreatedEvent | null;
58
69
  export declare function parseArchivedEvent(event: unknown): ParsedArchivedEvent | null;
59
70
  export declare function parseExercisedEvent(event: unknown): ParsedExercisedEvent | null;
71
+ /**
72
+ * The raw events of a transaction in node-id order, from whichever shape the response used: a tree keyed by node id, or
73
+ * a flat event array, wrapped in `transactionTree`, in `transaction`, or on its own.
74
+ */
75
+ export declare function getTransactionEvents(transaction: unknown): readonly unknown[];
60
76
  export declare function extractEventsFromTransaction(transaction: unknown): ParsedTransactionEvents;
77
+ export declare const TransactionParseErrorCode: {
78
+ readonly EXERCISE_RESULT_NOT_FOUND: 'TRANSACTION_EXERCISE_RESULT_NOT_FOUND';
79
+ readonly UPDATE_ID_NOT_FOUND: 'TRANSACTION_UPDATE_ID_NOT_FOUND';
80
+ };
81
+ export type TransactionParseErrorCode = (typeof TransactionParseErrorCode)[keyof typeof TransactionParseErrorCode];
82
+ /** Thrown when a transaction response does not contain something the caller asserted it would. */
83
+ export declare class TransactionParseError extends CantonError {
84
+ readonly name: string;
85
+ constructor(code: TransactionParseErrorCode, message: string, context?: ErrorContext);
86
+ }
87
+ /** The update id of a transaction response, or `undefined` when it names none. */
88
+ export declare function getTransactionUpdateId(transaction: unknown): string | undefined;
89
+ /** The update id, for a caller that needs to correlate a submission with what the ledger did. */
90
+ export declare function requireTransactionUpdateId(transaction: unknown): string;
91
+ /** Every exercise of `choice` in the transaction, in node-id order. */
92
+ export declare function findExercisedEvents(transaction: unknown, choice: string): ParsedExercisedEvent[];
93
+ /** The first exercise of any of `choices`, in node-id order — the order the transaction produced them. */
94
+ export declare function findExercisedEvent(transaction: unknown, choices: string | readonly string[]): ParsedExercisedEvent | undefined;
95
+ /** The return value of the first exercise of `choice`, or `undefined` when the transaction contains none. */
96
+ export declare function findExerciseResult(transaction: unknown, choice: string | readonly string[]): unknown;
97
+ /**
98
+ * The return value of the named choice. A caller asking for it is asserting the transaction contains it, so a
99
+ * transaction without that exercise is reported rather than returned as `undefined`.
100
+ */
101
+ export declare function requireExerciseResult(transaction: unknown, choice: string | readonly string[]): unknown;
102
+ /**
103
+ * Contract ids created by the transaction, in node-id order, optionally narrowed to one template. The filter is matched
104
+ * package-agnostically by {@link matchesTemplateId}.
105
+ */
106
+ export declare function findCreatedContractIds(transaction: unknown, templateFilter?: string): string[];
61
107
  //# sourceMappingURL=event-parser.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"event-parser.d.ts","sourceRoot":"","sources":["../../../../src/utils/parsers/event-parser.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,gBAAg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WvG;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,OAAO,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAI9F"}
@@ -1,11 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TransactionParseError = exports.TransactionParseErrorCode = void 0;
3
4
  exports.parseTemplateId = parseTemplateId;
4
5
  exports.hasTemplateName = hasTemplateName;
6
+ exports.qualifiedTemplateName = qualifiedTemplateName;
7
+ exports.matchesTemplateId = matchesTemplateId;
5
8
  exports.parseCreatedEvent = parseCreatedEvent;
6
9
  exports.parseArchivedEvent = parseArchivedEvent;
7
10
  exports.parseExercisedEvent = parseExercisedEvent;
11
+ exports.getTransactionEvents = getTransactionEvents;
8
12
  exports.extractEventsFromTransaction = extractEventsFromTransaction;
13
+ exports.getTransactionUpdateId = getTransactionUpdateId;
14
+ exports.requireTransactionUpdateId = requireTransactionUpdateId;
15
+ exports.findExercisedEvents = findExercisedEvents;
16
+ exports.findExercisedEvent = findExercisedEvent;
17
+ exports.findExerciseResult = findExerciseResult;
18
+ exports.requireExerciseResult = requireExerciseResult;
19
+ exports.findCreatedContractIds = findCreatedContractIds;
20
+ const errors_1 = require("../../core/errors");
9
21
  const utils_1 = require("../../core/utils");
10
22
  const VARIANT_KEYS = {
11
23
  created: ['CreatedTreeEvent', 'CreatedEvent', 'createdEvent'],
@@ -66,6 +78,31 @@ function hasTemplateName(templateId, expectedTemplateName) {
66
78
  return false;
67
79
  }
68
80
  }
81
+ /** The `Module:Template` part of a template id, dropping the leading package id or `#package-name`. */
82
+ function qualifiedTemplateName(templateId) {
83
+ const firstColon = templateId.indexOf(':');
84
+ return firstColon === -1 ? templateId : templateId.slice(firstColon + 1);
85
+ }
86
+ /**
87
+ * Match a template id from a ledger event against a filter, ignoring the package component.
88
+ *
89
+ * A create event always names the package _id_ that produced it, which a caller cannot know in advance; a filter is
90
+ * usually written with a package _name_ (`#MyPackage:Module:Template`) or without a package at all (`Module:Template`,
91
+ * or just `Template`). All three forms match here.
92
+ */
93
+ function matchesTemplateId(templateId, filter) {
94
+ if (templateId === filter)
95
+ return true;
96
+ const idSuffix = templateId.split(':').slice(1);
97
+ if (idSuffix.length === 0)
98
+ return false;
99
+ const filterParts = filter.split(':');
100
+ const filterSuffix = filterParts.length > idSuffix.length ? filterParts.slice(1) : filterParts;
101
+ if (filterSuffix.length === 0 || filterSuffix.length > idSuffix.length)
102
+ return false;
103
+ const offset = idSuffix.length - filterSuffix.length;
104
+ return filterSuffix.every((part, index) => part === idSuffix[offset + index]);
105
+ }
69
106
  function parseCreatedEvent(event) {
70
107
  const value = unwrapVariant(event, 'created');
71
108
  if (!value)
@@ -229,12 +266,14 @@ function getEventsById(transaction) {
229
266
  ];
230
267
  for (const path of paths) {
231
268
  const eventsById = getNestedRecord(transaction, path);
232
- if (eventsById)
269
+ if (eventsById && Object.keys(eventsById).length > 0)
233
270
  return eventsById;
234
271
  }
235
272
  return null;
236
273
  }
237
274
  function getEventArray(transaction) {
275
+ if (Array.isArray(transaction))
276
+ return transaction;
238
277
  const paths = [
239
278
  ['events'],
240
279
  ['transactionTree', 'events'],
@@ -247,10 +286,29 @@ function getEventArray(transaction) {
247
286
  }
248
287
  return null;
249
288
  }
250
- function extractEventsFromTransaction(transaction) {
289
+ /** Node ids are numeric strings, but a map preserves whatever order it was built with. */
290
+ function compareNodeIds(left, right) {
291
+ const leftNumber = Number(left);
292
+ const rightNumber = Number(right);
293
+ if (Number.isFinite(leftNumber) && Number.isFinite(rightNumber))
294
+ return leftNumber - rightNumber;
295
+ return left < right ? -1 : left > right ? 1 : 0;
296
+ }
297
+ /**
298
+ * The raw events of a transaction in node-id order, from whichever shape the response used: a tree keyed by node id, or
299
+ * a flat event array, wrapped in `transactionTree`, in `transaction`, or on its own.
300
+ */
301
+ function getTransactionEvents(transaction) {
251
302
  const eventsById = getEventsById(transaction);
252
- const events = eventsById ? Object.values(eventsById) : (getEventArray(transaction) ?? []);
253
- return events.reduce((acc, event) => {
303
+ if (eventsById) {
304
+ return Object.keys(eventsById)
305
+ .sort(compareNodeIds)
306
+ .map((key) => eventsById[key]);
307
+ }
308
+ return getEventArray(transaction) ?? [];
309
+ }
310
+ function extractEventsFromTransaction(transaction) {
311
+ return getTransactionEvents(transaction).reduce((acc, event) => {
254
312
  const created = parseCreatedEvent(event);
255
313
  if (created)
256
314
  acc.created.push(created);
@@ -263,4 +321,79 @@ function extractEventsFromTransaction(transaction) {
263
321
  return acc;
264
322
  }, { created: [], archived: [], exercised: [] });
265
323
  }
324
+ exports.TransactionParseErrorCode = {
325
+ EXERCISE_RESULT_NOT_FOUND: 'TRANSACTION_EXERCISE_RESULT_NOT_FOUND',
326
+ UPDATE_ID_NOT_FOUND: 'TRANSACTION_UPDATE_ID_NOT_FOUND',
327
+ };
328
+ /** Thrown when a transaction response does not contain something the caller asserted it would. */
329
+ class TransactionParseError extends errors_1.CantonError {
330
+ constructor(code, message, context) {
331
+ super(message, code, context);
332
+ this.name = 'TransactionParseError';
333
+ }
334
+ }
335
+ exports.TransactionParseError = TransactionParseError;
336
+ /** The update id of a transaction response, or `undefined` when it names none. */
337
+ function getTransactionUpdateId(transaction) {
338
+ const paths = [
339
+ ['updateId'],
340
+ ['transactionTree', 'updateId'],
341
+ ['transaction', 'updateId'],
342
+ ];
343
+ for (const path of paths) {
344
+ let current = transaction;
345
+ for (const segment of path) {
346
+ if (!(0, utils_1.isRecord)(current)) {
347
+ current = undefined;
348
+ break;
349
+ }
350
+ current = current[segment];
351
+ }
352
+ if ((0, utils_1.isString)(current) && current.length > 0)
353
+ return current;
354
+ }
355
+ return undefined;
356
+ }
357
+ /** The update id, for a caller that needs to correlate a submission with what the ledger did. */
358
+ function requireTransactionUpdateId(transaction) {
359
+ const updateId = getTransactionUpdateId(transaction);
360
+ if (updateId === undefined) {
361
+ throw new TransactionParseError(exports.TransactionParseErrorCode.UPDATE_ID_NOT_FOUND, 'The transaction names no update id.');
362
+ }
363
+ return updateId;
364
+ }
365
+ /** Every exercise of `choice` in the transaction, in node-id order. */
366
+ function findExercisedEvents(transaction, choice) {
367
+ return extractEventsFromTransaction(transaction).exercised.filter((event) => event.choice === choice);
368
+ }
369
+ /** The first exercise of any of `choices`, in node-id order — the order the transaction produced them. */
370
+ function findExercisedEvent(transaction, choices) {
371
+ const wanted = typeof choices === 'string' ? [choices] : choices;
372
+ return extractEventsFromTransaction(transaction).exercised.find((event) => wanted.includes(event.choice));
373
+ }
374
+ /** The return value of the first exercise of `choice`, or `undefined` when the transaction contains none. */
375
+ function findExerciseResult(transaction, choice) {
376
+ return findExercisedEvent(transaction, choice)?.exerciseResult;
377
+ }
378
+ /**
379
+ * The return value of the named choice. A caller asking for it is asserting the transaction contains it, so a
380
+ * transaction without that exercise is reported rather than returned as `undefined`.
381
+ */
382
+ function requireExerciseResult(transaction, choice) {
383
+ const exercised = findExercisedEvent(transaction, choice);
384
+ if (!exercised) {
385
+ const wanted = typeof choice === 'string' ? choice : choice.join(', ');
386
+ throw new TransactionParseError(exports.TransactionParseErrorCode.EXERCISE_RESULT_NOT_FOUND, `The transaction contains no ${wanted} exercise.`, { choice: wanted, updateId: getTransactionUpdateId(transaction) });
387
+ }
388
+ return exercised.exerciseResult;
389
+ }
390
+ /**
391
+ * Contract ids created by the transaction, in node-id order, optionally narrowed to one template. The filter is matched
392
+ * package-agnostically by {@link matchesTemplateId}.
393
+ */
394
+ function findCreatedContractIds(transaction, templateFilter) {
395
+ return extractEventsFromTransaction(transaction)
396
+ .created.filter((created) => templateFilter === undefined || matchesTemplateId(created.templateId, templateFilter))
397
+ .map((created) => created.contractId);
398
+ }
266
399
  //# sourceMappingURL=event-parser.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"event-parser.js","sourceRoot":"","sources":["../../../../src/utils/parsers/event-parser.ts"],"names":[],"mappings":";;;;;;;;AAAA,4CAAsD;AAgEtD,MAAM,YAAY,GAA4C;IAC5D,OAAO,EAAE,CAA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AAC;IAC1D,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,MAAM,GAAG,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvE,MAAM,IAAI,qBAAqB,CAC7B,QAAA,yBAAyB,CAAC,yBAAyB,EACnD,+BAA+B,MAAM,YAAY,EACjD,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,sBAAsB,CAAC,WAAW,CAAC,EAAE,CAClE,CAAC;IACJ,CAAC;IACD,OAAO,SAAS,CAAC,cAAc,CAAC;AAClC,CAAC;AAED;;;GAGG;AACH,gCAAuC,WAAoB,EAAE,cAAuB;IAClF,OAAO,4BAA4B,CAAC,WAAW,CAAC;SAC7C,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,cAAc,KAAK,SAAS,IAAI,iBAAiB,CAAC,OAAO,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;SAClH,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAC1C,CAAC"}
@@ -1,2 +1,3 @@
1
+ export * from './v1';
1
2
  export * from './v2';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/token-standard/index.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/token-standard/index.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,CAAC;AACrB,cAAc,MAAM,CAAC"}
@@ -14,5 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./v1"), exports);
17
18
  __exportStar(require("./v2"), exports);
18
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utils/token-standard/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uCAAqB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utils/token-standard/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uCAAqB;AACrB,uCAAqB"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Reserving units under an allocation, and the three ways an allocation ends.
3
+ *
4
+ * `AllocationFactory_Allocate` returns an `AllocationInstructionResult`, which names the allocation when the registry
5
+ * allocates in one step. `Allocation_ExecuteTransfer`, `_Cancel` and `_Withdraw` all return holdings; the difference
6
+ * between them is who gets them.
7
+ */
8
+ import type { TokenStandardV1TransferStatus } from './transfer';
9
+ export interface TokenStandardV1AllocationResult {
10
+ readonly updateId: string;
11
+ /** A registry that allocates in one step always reports `completed`. */
12
+ readonly status: TokenStandardV1TransferStatus;
13
+ readonly senderChangeCids: string[];
14
+ /** The allocation the units are now reserved under. */
15
+ readonly allocationCid: string | undefined;
16
+ /** The pending instruction, when the allocation did not complete in this transaction. */
17
+ readonly allocationInstructionCid: string | undefined;
18
+ }
19
+ /**
20
+ * The `AllocationInstructionResult` of `AllocationFactory_Allocate`.
21
+ *
22
+ * As with a transfer, `failed` is reported only for the standard's `_Failed` output; an undefined output tag, or a
23
+ * result naming no output, is reported rather than read as a rejected allocation.
24
+ */
25
+ export declare function parseAllocationResult(transaction: unknown): TokenStandardV1AllocationResult;
26
+ export interface TokenStandardV1AllocationTransferResult {
27
+ readonly updateId: string;
28
+ /** Units returned to the sender: everything on a cancel or a withdraw, nothing on a delivery. */
29
+ readonly senderHoldingCids: string[];
30
+ readonly receiverHoldingCids: string[];
31
+ }
32
+ /** The result of the allocation exit in this transaction — `Allocation_ExecuteTransfer`, `_Cancel` or `_Withdraw`. */
33
+ export declare function parseAllocationTransferResult(transaction: unknown): TokenStandardV1AllocationTransferResult;
34
+ //# sourceMappingURL=allocation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"allocation.d.ts","sourceRoot":"","sources":["../../../../../src/utils/token-standard/v1/allocation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAiBH,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAEhE,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,wEAAwE;IACxE,QAAQ,CAAC,MAAM,EAAE,6BAA6B,CAAC;IAC/C,QAAQ,CAAC,gBAAgB,EAAE,MAAM,EAAE,CAAC;IACpC,uDAAuD;IACvD,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3C,yFAAyF;IACzF,QAAQ,CAAC,wBAAwB,EAAE,MAAM,GAAG,SAAS,CAAC;CACvD;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,OAAO,GAAG,+BAA+B,CAoC3F;AAED,MAAM,WAAW,uCAAuC;IACtD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,iGAAiG;IACjG,QAAQ,CAAC,iBAAiB,EAAE,MAAM,EAAE,CAAC;IACrC,QAAQ,CAAC,mBAAmB,EAAE,MAAM,EAAE,CAAC;CACxC;AAED,sHAAsH;AACtH,wBAAgB,6BAA6B,CAAC,WAAW,EAAE,OAAO,GAAG,uCAAuC,CAa3G"}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ /**
3
+ * Reserving units under an allocation, and the three ways an allocation ends.
4
+ *
5
+ * `AllocationFactory_Allocate` returns an `AllocationInstructionResult`, which names the allocation when the registry
6
+ * allocates in one step. `Allocation_ExecuteTransfer`, `_Cancel` and `_Withdraw` all return holdings; the difference
7
+ * between them is who gets them.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.parseAllocationResult = parseAllocationResult;
11
+ exports.parseAllocationTransferResult = parseAllocationTransferResult;
12
+ const event_parser_1 = require("../../parsers/event-parser");
13
+ const constants_1 = require("./constants");
14
+ const result_1 = require("./result");
15
+ /**
16
+ * The `AllocationInstructionResult` of `AllocationFactory_Allocate`.
17
+ *
18
+ * As with a transfer, `failed` is reported only for the standard's `_Failed` output; an undefined output tag, or a
19
+ * result naming no output, is reported rather than read as a rejected allocation.
20
+ */
21
+ function parseAllocationResult(transaction) {
22
+ const result = (0, result_1.requireResultRecord)(transaction, constants_1.TokenStandardV1Choice.allocate);
23
+ const updateId = (0, event_parser_1.requireTransactionUpdateId)(transaction);
24
+ const senderChangeCids = (0, result_1.requireContractIds)(result['senderChangeCids'], 'senderChangeCids');
25
+ const output = (0, result_1.requireKnownVariant)(result, 'output', constants_1.TOKEN_STANDARD_V1_ALLOCATION_RESULT_TAGS, 'allocation result');
26
+ if (output.tag === constants_1.TokenStandardV1AllocationResultTag.completed) {
27
+ return {
28
+ updateId,
29
+ status: 'completed',
30
+ senderChangeCids,
31
+ allocationCid: (0, result_1.requireNonEmptyString)(output.value['allocationCid'], 'allocationCid'),
32
+ allocationInstructionCid: undefined,
33
+ };
34
+ }
35
+ if (output.tag === constants_1.TokenStandardV1AllocationResultTag.pending) {
36
+ return {
37
+ updateId,
38
+ status: 'pending',
39
+ senderChangeCids,
40
+ allocationCid: undefined,
41
+ allocationInstructionCid: (0, result_1.requireNonEmptyString)(output.value['allocationInstructionCid'], 'allocationInstructionCid'),
42
+ };
43
+ }
44
+ return {
45
+ updateId,
46
+ status: 'failed',
47
+ senderChangeCids,
48
+ allocationCid: undefined,
49
+ allocationInstructionCid: undefined,
50
+ };
51
+ }
52
+ /** The result of the allocation exit in this transaction — `Allocation_ExecuteTransfer`, `_Cancel` or `_Withdraw`. */
53
+ function parseAllocationTransferResult(transaction) {
54
+ const result = (0, result_1.requireResultRecordOfAny)(transaction, constants_1.TOKEN_STANDARD_V1_ALLOCATION_EXIT_CHOICES);
55
+ const exercised = (0, event_parser_1.findExercisedEvent)(transaction, constants_1.TOKEN_STANDARD_V1_ALLOCATION_EXIT_CHOICES);
56
+ const executedTransfer = exercised?.choice === constants_1.TokenStandardV1Choice.allocationExecuteTransfer;
57
+ return {
58
+ updateId: (0, event_parser_1.requireTransactionUpdateId)(transaction),
59
+ senderHoldingCids: executedTransfer
60
+ ? (0, result_1.readContractIds)(result['senderHoldingCids'], 'senderHoldingCids')
61
+ : (0, result_1.requireContractIds)(result['senderHoldingCids'], 'senderHoldingCids'),
62
+ receiverHoldingCids: executedTransfer
63
+ ? (0, result_1.requireContractIds)(result['receiverHoldingCids'], 'receiverHoldingCids')
64
+ : (0, result_1.readContractIds)(result['receiverHoldingCids'], 'receiverHoldingCids'),
65
+ };
66
+ }
67
+ //# sourceMappingURL=allocation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"allocation.js","sourceRoot":"","sources":["../../../../../src/utils/token-standard/v1/allocation.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;AAEH,6DAA4F;AAC5F,2CAKqB;AACrB,qCAOkB;AAclB;;;;;GAKG;AACH,+BAAsC,WAAoB;IACxD,MAAM,MAAM,GAAG,IAAA,4BAAmB,EAAC,WAAW,EAAE,iCAAqB,CAAC,QAAQ,CAAC,CAAC;IAChF,MAAM,QAAQ,GAAG,IAAA,yCAA0B,EAAC,WAAW,CAAC,CAAC;IACzD,MAAM,gBAAgB,GAAG,IAAA,2BAAkB,EAAC,MAAM,CAAC,kBAAkB,CAAC,EAAE,kBAAkB,CAAC,CAAC;IAC5F,MAAM,MAAM,GAAG,IAAA,4BAAmB,EAAC,MAAM,EAAE,QAAQ,EAAE,oDAAwC,EAAE,mBAAmB,CAAC,CAAC;IAEpH,IAAI,MAAM,CAAC,GAAG,KAAK,8CAAkC,CAAC,SAAS,EAAE,CAAC;QAChE,OAAO;YACL,QAAQ;YACR,MAAM,EAAE,WAAW;YACnB,g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AAA,wBAAe,EAAC,MAAM,CAAC,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;KAC1E,CAAC;AACJ,CAAC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Reading a mint or a burn back out of the transaction that performed it.
3
+ *
4
+ * `BurnMintFactory_BurnMint` returns a record rather than contract ids, and the interesting half of a mint is in that
5
+ * record: `outputCids` names the holdings it created. The create events alone cannot say it — a mint of two holdings
6
+ * creates two contracts with nothing to distinguish which output each was — so the exercise result is read instead, and
7
+ * a registry that mints outside the factory is read from the creates only when the caller asks for it.
8
+ */
9
+ export interface TokenStandardV1BurnMintResult {
10
+ readonly updateId: string;
11
+ /** `Holding` interface contract ids, one per output, in the order the outputs were given. Empty for a pure burn. */
12
+ readonly outputHoldingCids: string[];
13
+ }
14
+ /**
15
+ * The result of the burn-mint in this transaction: a mint's new holdings, or an empty list for a burn. Also finds a
16
+ * burn-mint that was exercised as a child of another choice, which is how a redeem's burn is confirmed.
17
+ */
18
+ export declare function parseBurnMintResult(transaction: unknown): TokenStandardV1BurnMintResult;
19
+ export interface ParseMintedHoldingsOptions {
20
+ /**
21
+ * Registry-specific choices that mint without going through the burn-mint factory, such as an admin recovery's
22
+ * `BurnHoldingEnforcement`, which returns contract ids of the concrete template rather than a burn-mint result.
23
+ * Required together with `holdingTemplate` to enable the create-event fallback, which then runs only when the
24
+ * transaction exercised one of these.
25
+ */
26
+ readonly mintingChoices?: readonly string[];
27
+ /**
28
+ * Template of the concrete holding contract, narrowing the fallback's create events to it. Matched
29
+ * package-agnostically, so `Module:Template`, `Template`, or a fully qualified id all work. Required together with
30
+ * `mintingChoices` to enable the create-event fallback.
31
+ */
32
+ readonly holdingTemplate?: string;
33
+ }
34
+ /**
35
+ * The holdings a mint created, from `BurnMintFactory_BurnMint`'s `outputCids`.
36
+ *
37
+ * Create events are never read on their own: every contract a transaction happened to create is not the same thing as
38
+ * the outputs of a mint, and answering with the first would name a sender's change as minted supply. A caller whose
39
+ * registry mints outside the factory opts into the fallback by naming both `mintingChoices` and `holdingTemplate`;
40
+ * without both, a transaction carrying no burn-mint result is reported.
41
+ */
42
+ export declare function parseMintedHoldings(transaction: unknown, options?: ParseMintedHoldingsOptions): string[];
43
+ //# sourceMappingURL=burn-mint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"burn-mint.d.ts","sourceRoot":"","sources":["../../../../../src/utils/token-standard/v1/burn-mint.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAYH,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,oHAAoH;IACpH,QAAQ,CAAC,iBAAiB,EAAE,MAAM,EAAE,CAAC;CACtC;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,OAAO,GAAG,6BAA6B,CAMvF;AAED,MAAM,WAAW,0BAA0B;IACzC;;;;;OAKG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5C;;;;OAIG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;CACnC;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,OAAO,EAAE,OAAO,GAAE,0BAA+B,GAAG,MAAM,EAAE,CA4B5G"}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ /**
3
+ * Reading a mint or a burn back out of the transaction that performed it.
4
+ *
5
+ * `BurnMintFactory_BurnMint` returns a record rather than contract ids, and the interesting half of a mint is in that
6
+ * record: `outputCids` names the holdings it created. The create events alone cannot say it — a mint of two holdings
7
+ * creates two contracts with nothing to distinguish which output each was — so the exercise result is read instead, and
8
+ * a registry that mints outside the factory is read from the creates only when the caller asks for it.
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.parseBurnMintResult = parseBurnMintResult;
12
+ exports.parseMintedHoldings = parseMintedHoldings;
13
+ const event_parser_1 = require("../../parsers/event-parser");
14
+ const constants_1 = require("./constants");
15
+ const errors_1 = require("./errors");
16
+ const result_1 = require("./result");
17
+ /**
18
+ * The result of the burn-mint in this transaction: a mint's new holdings, or an empty list for a burn. Also finds a
19
+ * burn-mint that was exercised as a child of another choice, which is how a redeem's burn is confirmed.
20
+ */
21
+ function parseBurnMintResult(transaction) {
22
+ const result = (0, result_1.requireResultRecord)(transaction, constants_1.TokenStandardV1Choice.burnMint);
23
+ return {
24
+ updateId: (0, event_parser_1.requireTransactionUpdateId)(transaction),
25
+ outputHoldingCids: (0, result_1.requireContractIds)(result['outputCids'], 'outputCids'),
26
+ };
27
+ }
28
+ /**
29
+ * The holdings a mint created, from `BurnMintFactory_BurnMint`'s `outputCids`.
30
+ *
31
+ * Create events are never read on their own: every contract a transaction happened to create is not the same thing as
32
+ * the outputs of a mint, and answering with the first would name a sender's change as minted supply. A caller whose
33
+ * registry mints outside the factory opts into the fallback by naming both `mintingChoices` and `holdingTemplate`;
34
+ * without both, a transaction carrying no burn-mint result is reported.
35
+ */
36
+ function parseMintedHoldings(transaction, options = {}) {
37
+ if ((0, event_parser_1.findExercisedEvent)(transaction, constants_1.TokenStandardV1Choice.burnMint)) {
38
+ const result = (0, result_1.requireResultRecord)(transaction, constants_1.TokenStandardV1Choice.burnMint);
39
+ return (0, result_1.requireContractIds)(result['outputCids'], 'outputCids');
40
+ }
41
+ const { mintingChoices, holdingTemplate } = options;
42
+ const canFallback = Array.isArray(mintingChoices) &&
43
+ mintingChoices.length > 0 &&
44
+ typeof holdingTemplate === 'string' &&
45
+ holdingTemplate.length > 0;
46
+ if (!canFallback) {
47
+ throw new errors_1.TokenStandardV1ResultError(errors_1.TokenStandardV1ResultErrorCode.RESULT_NOT_FOUND, `The transaction contains no ${constants_1.TokenStandardV1Choice.burnMint} exercise, so it minted nothing. Name mintingChoices and holdingTemplate to read a registry-specific mint from the create events instead.`, { choice: constants_1.TokenStandardV1Choice.burnMint, updateId: (0, event_parser_1.getTransactionUpdateId)(transaction) });
48
+ }
49
+ if (!(0, event_parser_1.findExercisedEvent)(transaction, mintingChoices)) {
50
+ throw new errors_1.TokenStandardV1ResultError(errors_1.TokenStandardV1ResultErrorCode.RESULT_NOT_FOUND, `The transaction contains neither a ${constants_1.TokenStandardV1Choice.burnMint} exercise nor any of these minting choices: ${mintingChoices.join(', ')}.`, { choices: [constants_1.TokenStandardV1Choice.burnMint, ...mintingChoices], updateId: (0, event_parser_1.getTransactionUpdateId)(transaction) });
51
+ }
52
+ return (0, event_parser_1.findCreatedContractIds)(transaction, holdingTemplate);
53
+ }
54
+ //# sourceMappingURL=burn-mint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"burn-mint.js","sourceRoot":"","sources":["../../../../../src/utils/token-standard/v1/burn-mint.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;;AAEH,6DAKoC;AACpC,2CAAoD;AACpD,qCAAsF;AACtF,qCAAmE;AAQnE;;;GAGG;AACH,6BAAoC,WAAoB;IACtD,MAAM,MAAM,GAAG,IAAA,4BAAmB,EAAC,WAAW,EAAE,iCAAqB,CAAC,QAAQ,CAAC,CAAC;IAChF,OAAO;QACL,QAAQ,EAAE,IAAA,yCAA0B,EAAC,WAAW,CAAC;QACjD,iBAAiB,EAAE,IAAA,2BAAkB,EAAC,MAAM,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC;KAC1E,CAAC;AACJ,CAAC;AAkBD;;;;;;;GAOG;AACH,6BAAoC,WAAoB,EAAE,OAAO,GAA+B,EAAE;IAChG,IAAI,IAAA,iCAAkB,EAAC,WAAW,EAAE,iCAAqB,CAAC,QAAQ,CAAC,EAAE,CAAC;QACpE,MAAM,MAAM,GAAG,IAAA,4BAAmB,EAAC,WAAW,EAAE,iCAAqB,CAAC,QAAQ,CAAC,CAAC;QAChF,OAAO,IAAA,2BAAkB,EAAC,MAAM,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC,CAAC;IAChE,CAAC;IAED,MAAM,EAAE,cAAc,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC;IACpD,MAAM,WAAW,GACf,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC;QAC7B,cAAc,CAAC,MAAM,GAAG,CAAC;QACzB,OAAO,eAAe,KAAK,QAAQ;QACnC,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC;IAC7B,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,IAAI,mCAA0B,CAClC,uCAA8B,CAAC,gBAAgB,EAC/C,+BAA+B,iCAAqB,CAAC,QAAQ,2IAA2I,EACxM,EAAE,MAAM,EAAE,iCAAqB,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAA,qCAAsB,EAAC,WAAW,CAAC,EAAE,CAC1F,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,IAAA,iCAAkB,EAAC,WAAW,EAAE,cAAc,CAAC,EAAE,CAAC;QACrD,MAAM,IAAI,mCAA0B,CAClC,uCAA8B,CAAC,gBAAgB,EAC/C,sCAAsC,iCAAqB,CAAC,QAAQ,+CAA+C,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAC/I,EAAE,OAAO,EAAE,CAAC,iCAAqB,CAAC,QAAQ,EAAE,GAAG,cAAc,CAAC,EAAE,QAAQ,EAAE,IAAA,qCAAsB,EAAC,WAAW,CAAC,EAAE,CAChH,CAAC;IACJ,CAAC;IAED,OAAO,IAAA,qCAAsB,EAAC,WAAW,EAAE,eAAe,CAAC,CAAC;AAC9D,CAAC"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Interface ids and choice names of the CIP-56 token standard V1 APIs.
3
+ *
4
+ * A standard choice is exercised against the _interface_ id rather than the template id, because that is the contract
5
+ * the choice is defined on. The interface ids are package-name scoped (`#package-name:Module:Interface`), which is what
6
+ * keeps them stable across DAR upgrades.
7
+ */
8
+ export declare const TOKEN_STANDARD_V1_HOLDING_INTERFACE_ID = "#splice-api-token-holding-v1:Splice.Api.Token.HoldingV1:Holding";
9
+ /** Exercise target for `BurnMintFactory_BurnMint`, which every mint, burn and redeem goes through. */
10
+ export declare const TOKEN_STANDARD_V1_BURN_MINT_FACTORY_INTERFACE_ID = "#splice-api-token-burn-mint-v1:Splice.Api.Token.BurnMintV1:BurnMintFactory";
11
+ /** Exercise target for `TransferFactory_Transfer`. */
12
+ export declare const TOKEN_STANDARD_V1_TRANSFER_FACTORY_INTERFACE_ID = "#splice-api-token-transfer-instruction-v1:Splice.Api.Token.TransferInstructionV1:TransferFactory";
13
+ /** Exercise target for the four choices on a pending transfer offer. */
14
+ export declare const TOKEN_STANDARD_V1_TRANSFER_INSTRUCTION_INTERFACE_ID = "#splice-api-token-transfer-instruction-v1:Splice.Api.Token.TransferInstructionV1:TransferInstruction";
15
+ /** Exercise target for `AllocationFactory_Allocate`. */
16
+ export declare const TOKEN_STANDARD_V1_ALLOCATION_FACTORY_INTERFACE_ID = "#splice-api-token-allocation-instruction-v1:Splice.Api.Token.AllocationInstructionV1:AllocationFactory";
17
+ /** Exercise target for the three choices on a settled or unwinding allocation. */
18
+ export declare const TOKEN_STANDARD_V1_ALLOCATION_INTERFACE_ID = "#splice-api-token-allocation-v1:Splice.Api.Token.AllocationV1:Allocation";
19
+ /** Choice names as the Ledger JSON API spells them in an `ExerciseCommand`. */
20
+ export declare const TokenStandardV1Choice: {
21
+ readonly burnMint: 'BurnMintFactory_BurnMint';
22
+ readonly transfer: 'TransferFactory_Transfer';
23
+ readonly transferInstructionAccept: 'TransferInstruction_Accept';
24
+ readonly transferInstructionReject: 'TransferInstruction_Reject';
25
+ readonly transferInstructionWithdraw: 'TransferInstruction_Withdraw';
26
+ readonly transferInstructionUpdate: 'TransferInstruction_Update';
27
+ readonly allocate: 'AllocationFactory_Allocate';
28
+ readonly allocationExecuteTransfer: 'Allocation_ExecuteTransfer';
29
+ readonly allocationCancel: 'Allocation_Cancel';
30
+ readonly allocationWithdraw: 'Allocation_Withdraw';
31
+ };
32
+ export type TokenStandardV1ChoiceName = (typeof TokenStandardV1Choice)[keyof typeof TokenStandardV1Choice];
33
+ /**
34
+ * The five choices that return a `TransferInstructionResult`. One reader covers instructing, accepting, rejecting,
35
+ * withdrawing and expiring, because all five return the same record.
36
+ */
37
+ export declare const TOKEN_STANDARD_V1_TRANSFER_RESULT_CHOICES: readonly string[];
38
+ /** The three `TransferInstructionResult.output` variants the standard defines. */
39
+ export declare const TokenStandardV1TransferResultTag: {
40
+ readonly completed: 'TransferInstructionResult_Completed';
41
+ readonly pending: 'TransferInstructionResult_Pending';
42
+ readonly failed: 'TransferInstructionResult_Failed';
43
+ };
44
+ export declare const TOKEN_STANDARD_V1_TRANSFER_RESULT_TAGS: readonly string[];
45
+ /** The three `AllocationInstructionResult.output` variants the standard defines. */
46
+ export declare const TokenStandardV1AllocationResultTag: {
47
+ readonly completed: 'AllocationInstructionResult_Completed';
48
+ readonly pending: 'AllocationInstructionResult_Pending';
49
+ readonly failed: 'AllocationInstructionResult_Failed';
50
+ };
51
+ export declare const TOKEN_STANDARD_V1_ALLOCATION_RESULT_TAGS: readonly string[];
52
+ /** The three exits an allocation has, all returning holdings; the difference is who gets them. */
53
+ export declare const TOKEN_STANDARD_V1_ALLOCATION_EXIT_CHOICES: readonly string[];
54
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/utils/token-standard/v1/constants.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,eAAO,MAAM,sCAAsC,oEAAoE,CAAC;AAExH,sGAAsG;AACtG,eAAO,MAAM,gDAAgD,+EACiB,CAAC;AAE/E,sDAAsD;AACtD,eAAO,MAAM,+CAA+C,qGACwC,CAAC;AAErG,wEAAwE;AACxE,eAAO,MAAM,mDAAmD,yGACwC,CAAC;AAEzG,wDAAwD;AACxD,eAAO,MAAM,iDAAiD,2GAC4C,CAAC;AAE3G,kFAAkF;AAClF,eAAO,MAAM,yCAAyC,6EACsB,CAAC;AAE7E,+EAA+E;AAC/E,eAAO,MAAM,qBAAqB;aAChC,QAAQ,EAAE,0BAA0B;aACpC,QAAQ,EAAE,0BAA0B;aACpC,yBAAyB,EAAE,4BAA4B;aACvD,yBAAyB,EAAE,4BAA4B;aACvD,2BAA2B,EAAE,8BAA8B;aAC3D,yBAAyB,EAAE,4BAA4B;aACvD,QAAQ,EAAE,4BAA4B;aACtC,yBAAyB,EAAE,4BAA4B;aACvD,gBAAgB,EAAE,mBAAmB;aACrC,kBAAkB,EAAE,qBAAqB;CACjC,CAAC;AAEX,MAAM,MAAM,yBAAyB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,OAAO,qBAAqB,CAAC,CAAC;AAE3G;;;GAGG;AACH,eAAO,MAAM,yCAAyC,EAAE,SAAS,MAAM,EAMtE,CAAC;AAEF,kFAAkF;AAClF,eAAO,MAAM,gCAAgC;aAC3C,SAAS,EAAE,qCAAqC;aAChD,OAAO,EAAE,mCAAmC;aAC5C,MAAM,EAAE,kCAAkC;CAClC,CAAC;AAEX,eAAO,MAAM,sCAAsC,EAAE,SAAS,MAAM,EAEnE,CAAC;AAEF,oFAAoF;AACpF,eAAO,MAAM,kCAAkC;aAC7C,SAAS,EAAE,uCAAuC;aAClD,OAAO,EAAE,qCAAqC;aAC9C,MAAM,EAAE,oCAAoC;CACpC,CAAC;AAEX,eAAO,MAAM,wCAAwC,EAAE,SAAS,MAAM,EAErE,CAAC;AAEF,kGAAkG;AAClG,eAAO,MAAM,yCAAyC,EAAE,SAAS,MAAM,EAItE,CAAC"}
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ /**
3
+ * Interface ids and choice names of the CIP-56 token standard V1 APIs.
4
+ *
5
+ * A standard choice is exercised against the _interface_ id rather than the template id, because that is the contract
6
+ * the choice is defined on. The interface ids are package-name scoped (`#package-name:Module:Interface`), which is what
7
+ * keeps them stable across DAR upgrades.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.TOKEN_STANDARD_V1_ALLOCATION_EXIT_CHOICES = exports.TOKEN_STANDARD_V1_ALLOCATION_RESULT_TAGS = exports.TokenStandardV1AllocationResultTag = exports.TOKEN_STANDARD_V1_TRANSFER_RESULT_TAGS = exports.TokenStandardV1TransferResultTag = exports.TOKEN_STANDARD_V1_TRANSFER_RESULT_CHOICES = exports.TokenStandardV1Choice = exports.TOKEN_STANDARD_V1_ALLOCATION_INTERFACE_ID = exports.TOKEN_STANDARD_V1_ALLOCATION_FACTORY_INTERFACE_ID = exports.TOKEN_STANDARD_V1_TRANSFER_INSTRUCTION_INTERFACE_ID = exports.TOKEN_STANDARD_V1_TRANSFER_FACTORY_INTERFACE_ID = exports.TOKEN_STANDARD_V1_BURN_MINT_FACTORY_INTERFACE_ID = exports.TOKEN_STANDARD_V1_HOLDING_INTERFACE_ID = void 0;
11
+ exports.TOKEN_STANDARD_V1_HOLDING_INTERFACE_ID = '#splice-api-token-holding-v1:Splice.Api.Token.HoldingV1:Holding';
12
+ /** Exercise target for `BurnMintFactory_BurnMint`, which every mint, burn and redeem goes through. */
13
+ exports.TOKEN_STANDARD_V1_BURN_MINT_FACTORY_INTERFACE_ID = '#splice-api-token-burn-mint-v1:Splice.Api.Token.BurnMintV1:BurnMintFactory';
14
+ /** Exercise target for `TransferFactory_Transfer`. */
15
+ exports.TOKEN_STANDARD_V1_TRANSFER_FACTORY_INTERFACE_ID = '#splice-api-token-transfer-instruction-v1:Splice.Api.Token.TransferInstructionV1:TransferFactory';
16
+ /** Exercise target for the four choices on a pending transfer offer. */
17
+ exports.TOKEN_STANDARD_V1_TRANSFER_INSTRUCTION_INTERFACE_ID = '#splice-api-token-transfer-instruction-v1:Splice.Api.Token.TransferInstructionV1:TransferInstruction';
18
+ /** Exercise target for `AllocationFactory_Allocate`. */
19
+ exports.TOKEN_STANDARD_V1_ALLOCATION_FACTORY_INTERFACE_ID = '#splice-api-token-allocation-instruction-v1:Splice.Api.Token.AllocationInstructionV1:AllocationFactory';
20
+ /** Exercise target for the three choices on a settled or unwinding allocation. */
21
+ exports.TOKEN_STANDARD_V1_ALLOCATION_INTERFACE_ID = '#splice-api-token-allocation-v1:Splice.Api.Token.AllocationV1:Allocation';
22
+ /** Choice names as the Ledger JSON API spells them in an `ExerciseCommand`. */
23
+ exports.TokenStandardV1Choice = {
24
+ burnMint: 'BurnMintFactory_BurnMint',
25
+ transfer: 'TransferFactory_Transfer',
26
+ transferInstructionAccept: 'TransferInstruction_Accept',
27
+ transferInstructionReject: 'TransferInstruction_Reject',
28
+ transferInstructionWithdraw: 'TransferInstruction_Withdraw',
29
+ transferInstructionUpdate: 'TransferInstruction_Update',
30
+ allocate: 'AllocationFactory_Allocate',
31
+ allocationExecuteTransfer: 'Allocation_ExecuteTransfer',
32
+ allocationCancel: 'Allocation_Cancel',
33
+ allocationWithdraw: 'Allocation_Withdraw',
34
+ };
35
+ /**
36
+ * The five choices that return a `TransferInstructionResult`. One reader covers instructing, accepting, rejecting,
37
+ * withdrawing and expiring, because all five return the same record.
38
+ */
39
+ exports.TOKEN_STANDARD_V1_TRANSFER_RESULT_CHOICES = [
40
+ exports.TokenStandardV1Choice.transfer,
41
+ exports.TokenStandardV1Choice.transferInstructionAccept,
42
+ exports.TokenStandardV1Choice.transferInstructionReject,
43
+ exports.TokenStandardV1Choice.transferInstructionWithdraw,
44
+ exports.TokenStandardV1Choice.transferInstructionUpdate,
45
+ ];
46
+ /** The three `TransferInstructionResult.output` variants the standard defines. */
47
+ exports.TokenStandardV1TransferResultTag = {
48
+ completed: 'TransferInstructionResult_Completed',
49
+ pending: 'TransferInstructionResult_Pending',
50
+ failed: 'TransferInstructionResult_Failed',
51
+ };
52
+ exports.TOKEN_STANDARD_V1_TRANSFER_RESULT_TAGS = Object.values(exports.TokenStandardV1TransferResultTag);
53
+ /** The three `AllocationInstructionResult.output` variants the standard defines. */
54
+ exports.TokenStandardV1AllocationResultTag = {
55
+ completed: 'AllocationInstructionResult_Completed',
56
+ pending: 'AllocationInstructionResult_Pending',
57
+ failed: 'AllocationInstructionResult_Failed',
58
+ };
59
+ exports.TOKEN_STANDARD_V1_ALLOCATION_RESULT_TAGS = Object.values(exports.TokenStandardV1AllocationResultTag);
60
+ /** The three exits an allocation has, all returning holdings; the difference is who gets them. */
61
+ exports.TOKEN_STANDARD_V1_ALLOCATION_EXIT_CHOICES = [
62
+ exports.TokenStandardV1Choice.allocationExecuteTransfer,
63
+ exports.TokenStandardV1Choice.allocationCancel,
64
+ exports.TokenStandardV1Choice.allocationWithdraw,
65
+ ];
66
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/utils/token-standard/v1/constants.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEU,QAAA,sCAAsC,GAAG,iEAAiE,CAAC;AAExH,sGAAsG;AACzF,QAAA,gDAAgD,GAC3D,4EAA4E,CAAC;AAE/E,sDAAsD;AACzC,QAAA,+CAA+C,GAC1D,kGAAkG,CAAC;AAErG,wEAAwE;AAC3D,QAAA,mDAAmD,GAC9D,sGAAsG,CAAC;AAEzG,wDAAwD;AAC3C,QAAA,iDAAiD,GAC5D,wGAAwG,CAAC;AAE3G,kFAAkF;AACrE,QAAA,yCAAyC,GACpD,0EAA0E,CAAC;AAE7E,+EAA+E;AAClE,QAAA,qBAAqB,GAAG;IACnC,QAAQ,EAAE,0BAA0B;IACpC,QAAQ,EAAE,0BAA0B;IACpC,yBAAyB,EAAE,4BAA4B;IACvD,yBAAyB,EAAE,4BAA4B;IACvD,2BAA2B,EAAE,8BAA8B;IAC3D,yBAAyB,EAAE,4BAA4B;IACvD,QAAQ,EAAE,4BAA4B;IACtC,yBAAyB,EAAE,4BAA4B;IACvD,gBAAgB,EAAE,mBAAmB;IACrC,kBAAkB,EAAE,qBAAqB;CACjC,CAAC;AAIX;;;GAGG;AACU,QAAA,yCAAyC,GAAsB;IAC1E,QAAA,qBAAqB,CAAC,QAAQ;IAC9B,QAAA,qBAAqB,CAAC,yBAAyB;IAC/C,QAAA,qBAAqB,CAAC,yBAAyB;IAC/C,QAAA,qBAAqB,CAAC,2BAA2B;IACjD,QAAA,qBAAqB,CAAC,yBAAyB;CAChD,CAAC;AAEF,kFAAkF;AACrE,QAAA,gCAAgC,GAAG;IAC9C,SAAS,EAAE,qCAAqC;IAChD,OAAO,EAAE,mCAAmC;IAC5C,MAAM,EAAE,kCAAkC;CAClC,CAAC;AAEE,QAAA,sCAAsC,GAAsB,MAAM,CAAC,MAAM,CACpF,QAAA,gCAAgC,CACjC,CAAC;AAEF,oFAAoF;AACvE,QAAA,kCAAkC,GAAG;IAChD,SAAS,EAAE,uCAAuC;IAClD,OAAO,EAAE,qCAAqC;IAC9C,MAAM,EAAE,oCAAoC;CACpC,CAAC;AAEE,QAAA,wCAAwC,GAAsB,MAAM,CAAC,MAAM,CACtF,QAAA,kCAAkC,CACnC,CAAC;AAEF,kGAAkG;AACrF,QAAA,yCAAyC,GAAsB;IAC1E,QAAA,qBAAqB,CAAC,yBAAyB;IAC/C,QAAA,qBAAqB,CAAC,gBAAgB;IACtC,QAAA,qBAAqB,CAAC,kBAAkB;CACzC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { CantonError, type ErrorContext } from '../../../core/errors';
2
+ export declare const TokenStandardV1ResultErrorCode: {
3
+ readonly RESULT_NOT_FOUND: 'TOKEN_STANDARD_V1_RESULT_NOT_FOUND';
4
+ readonly RESULT_INVALID: 'TOKEN_STANDARD_V1_RESULT_INVALID';
5
+ };
6
+ export type TokenStandardV1ResultErrorCode = (typeof TokenStandardV1ResultErrorCode)[keyof typeof TokenStandardV1ResultErrorCode];
7
+ /** Thrown when a transaction does not contain the token standard V1 result a reader was asked for, or it is malformed. */
8
+ export declare class TokenStandardV1ResultError extends CantonError {
9
+ readonly name: string;
10
+ constructor(code: TokenStandardV1ResultErrorCode, message: string, context?: ErrorContext);
11
+ }
12
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../../src/utils/token-standard/v1/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEtE,eAAO,MAAM,8BAA8B;aACzC,gBAAgB,EAAE,oCAAoC;aACtD,cAAc,EAAE,kCAAkC;CAC1C,CAAC;AAEX,MAAM,MAAM,8BAA8B,GACxC,CAAC,OAAO,8BAA8B,CAAC,CAAC,MAAM,OAAO,8BAA8B,CAAC,CAAC;AAEvF,0HAA0H;AAC1H,qBAAa,0BAA2B,SAAQ,WAAW;IACzD,SAAyB,IAAI,EAAE,MAAM,CAAC;IAEtC,YAAmB,IAAI,EAAE,8BAA8B,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,EAG/F;CACF"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TokenStandardV1ResultError = exports.TokenStandardV1ResultErrorCode = void 0;
4
+ const errors_1 = require("../../../core/errors");
5
+ exports.TokenStandardV1ResultErrorCode = {
6
+ RESULT_NOT_FOUND: 'TOKEN_STANDARD_V1_RESULT_NOT_FOUND',
7
+ RESULT_INVALID: 'TOKEN_STANDARD_V1_RESULT_INVALID',
8
+ };
9
+ /** Thrown when a transaction does not contain the token standard V1 result a reader was asked for, or it is malformed. */
10
+ class TokenStandardV1ResultError extends errors_1.CantonError {
11
+ constructor(code, message, context) {
12
+ super(message, code, context);
13
+ this.name = 'TokenStandardV1ResultError';
14
+ }
15
+ }
16
+ exports.TokenStandardV1ResultError = TokenStandardV1ResultError;
17
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../../src/utils/token-standard/v1/errors.ts"],"names":[],"mappings":";;;AAAA,iDAAsE;AAEzD,QAAA,8BAA8B,GAAG;IAC5C,gBAAgB,EAAE,oCAAoC;IACtD,cAAc,EAAE,kCAAkC;CAC1C,CAAC;AAKX,0HAA0H;AAC1H,gCAAwC,SAAQ,oBAAW;IAGzD,YAAmB,IAAoC,EAAE,OAAe,EAAE,OAAsB;QAC9F,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QAC9B,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAC;IAC3C,CAAC;CACF"}
@@ -0,0 +1,7 @@
1
+ export * from './allocation';
2
+ export * from './burn-mint';
3
+ export * from './constants';
4
+ export * from './errors';
5
+ export * from './result';
6
+ export * from './transfer';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/utils/token-standard/v1/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./allocation"), exports);
18
+ __exportStar(require("./burn-mint"), exports);
19
+ __exportStar(require("./constants"), exports);
20
+ __exportStar(require("./errors"), exports);
21
+ __exportStar(require("./result"), exports);
22
+ __exportStar(require("./transfer"), exports);
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/utils/token-standard/v1/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,8CAA4B;AAC5B,8CAA4B;AAC5B,2CAAyB;AACzB,2CAAyB;AACzB,6CAA2B"}
@@ -0,0 +1,27 @@
1
+ /** The record a standard choice returned, or a failure: a caller asking for it asserts the transaction contains it. */
2
+ export declare function requireResultRecord(transaction: unknown, choice: string): Record<string, unknown>;
3
+ /** The record returned by the first of `choices` this transaction exercised. */
4
+ export declare function requireResultRecordOfAny(transaction: unknown, choices: readonly string[]): Record<string, unknown>;
5
+ /** A required non-empty string from a result record. */
6
+ export declare function requireNonEmptyString(value: unknown, field: string): string;
7
+ /** A required list of contract ids from a result record. */
8
+ export declare function requireContractIds(value: unknown, field: string): string[];
9
+ /** An optional list of contract ids, which the token standard omits rather than sending empty on some paths. */
10
+ export declare function readContractIds(value: unknown, field: string): string[];
11
+ /** `{ tag, value }`, the Daml JSON encoding of a variant. */
12
+ export declare function readVariant(value: unknown): {
13
+ readonly tag: string;
14
+ readonly value: Record<string, unknown>;
15
+ } | undefined;
16
+ /**
17
+ * A variant field of a result record, which must be one of the variants the reader knows.
18
+ *
19
+ * A missing field or an unrecognized tag is reported rather than folded into the nearest status. The standard's
20
+ * `_Failed` output means the units went back to the sender, so answering an unknown tag with it would tell a caller a
21
+ * transfer was returned when nothing here knows what happened to it.
22
+ */
23
+ export declare function requireKnownVariant(result: Record<string, unknown>, field: string, known: readonly string[], what: string): {
24
+ readonly tag: string;
25
+ readonly value: Record<string, unknown>;
26
+ };
27
+ //# sourceMappingURL=result.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../../../../../src/utils/token-standard/v1/result.ts"],"names":[],"mappings":"AAIA,uHAAuH;AACvH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEjG;AAED,gFAAgF;AAChF,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAiBlH;AAED,wDAAwD;AACxD,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAS3E;AAED,4DAA4D;AAC5D,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAoB1E;AAED,gHAAgH;AAChH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAKvE;AAED,6DAA6D;AAC7D,wBAAgB,WAAW,CACzB,KAAK,EAAE,OAAO,GACb;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GAAG,SAAS,CAG/E;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,IAAI,EAAE,MAAM,GACX;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,CAiBnE"}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.requireResultRecord = requireResultRecord;
4
+ exports.requireResultRecordOfAny = requireResultRecordOfAny;
5
+ exports.requireNonEmptyString = requireNonEmptyString;
6
+ exports.requireContractIds = requireContractIds;
7
+ exports.readContractIds = readContractIds;
8
+ exports.readVariant = readVariant;
9
+ exports.requireKnownVariant = requireKnownVariant;
10
+ const utils_1 = require("../../../core/utils");
11
+ const event_parser_1 = require("../../parsers/event-parser");
12
+ const errors_1 = require("./errors");
13
+ /** The record a standard choice returned, or a failure: a caller asking for it asserts the transaction contains it. */
14
+ function requireResultRecord(transaction, choice) {
15
+ return requireResultRecordOfAny(transaction, [choice]);
16
+ }
17
+ /** The record returned by the first of `choices` this transaction exercised. */
18
+ function requireResultRecordOfAny(transaction, choices) {
19
+ const exercised = (0, event_parser_1.findExercisedEvent)(transaction, choices);
20
+ if (!exercised) {
21
+ throw new errors_1.TokenStandardV1ResultError(errors_1.TokenStandardV1ResultErrorCode.RESULT_NOT_FOUND, `The transaction contains none of these exercises: ${choices.join(', ')}.`, { choices: [...choices], updateId: (0, event_parser_1.getTransactionUpdateId)(transaction) });
22
+ }
23
+ if (!(0, utils_1.isRecord)(exercised.exerciseResult)) {
24
+ throw new errors_1.TokenStandardV1ResultError(errors_1.TokenStandardV1ResultErrorCode.RESULT_INVALID, `The ${exercised.choice} exercise returned no result record.`, { choice: exercised.choice, updateId: (0, event_parser_1.getTransactionUpdateId)(transaction) });
25
+ }
26
+ return exercised.exerciseResult;
27
+ }
28
+ /** A required non-empty string from a result record. */
29
+ function requireNonEmptyString(value, field) {
30
+ if (typeof value !== 'string' || value.length === 0) {
31
+ throw new errors_1.TokenStandardV1ResultError(errors_1.TokenStandardV1ResultErrorCode.RESULT_INVALID, `The exercise result has no ${field}.`, { field });
32
+ }
33
+ return value;
34
+ }
35
+ /** A required list of contract ids from a result record. */
36
+ function requireContractIds(value, field) {
37
+ if (!Array.isArray(value)) {
38
+ throw new errors_1.TokenStandardV1ResultError(errors_1.TokenStandardV1ResultErrorCode.RESULT_INVALID, `The exercise result has no ${field}.`, { field });
39
+ }
40
+ const contractIds = [];
41
+ for (const entry of value) {
42
+ if (typeof entry !== 'string' || entry.length === 0) {
43
+ throw new errors_1.TokenStandardV1ResultError(errors_1.TokenStandardV1ResultErrorCode.RESULT_INVALID, `The ${field} is not a list of contract ids.`, { field });
44
+ }
45
+ contractIds.push(entry);
46
+ }
47
+ return contractIds;
48
+ }
49
+ /** An optional list of contract ids, which the token standard omits rather than sending empty on some paths. */
50
+ function readContractIds(value, field) {
51
+ if (!Array.isArray(value)) {
52
+ return [];
53
+ }
54
+ return requireContractIds(value, field);
55
+ }
56
+ /** `{ tag, value }`, the Daml JSON encoding of a variant. */
57
+ function readVariant(value) {
58
+ if (!(0, utils_1.isRecord)(value) || typeof value['tag'] !== 'string')
59
+ return undefined;
60
+ return { tag: value['tag'], value: (0, utils_1.isRecord)(value['value']) ? value['value'] : {} };
61
+ }
62
+ /**
63
+ * A variant field of a result record, which must be one of the variants the reader knows.
64
+ *
65
+ * A missing field or an unrecognized tag is reported rather than folded into the nearest status. The standard's
66
+ * `_Failed` output means the units went back to the sender, so answering an unknown tag with it would tell a caller a
67
+ * transfer was returned when nothing here knows what happened to it.
68
+ */
69
+ function requireKnownVariant(result, field, known, what) {
70
+ const variant = readVariant(result[field]);
71
+ if (!variant) {
72
+ throw new errors_1.TokenStandardV1ResultError(errors_1.TokenStandardV1ResultErrorCode.RESULT_INVALID, `The ${what} names no ${field}.`, { field });
73
+ }
74
+ if (!known.includes(variant.tag)) {
75
+ throw new errors_1.TokenStandardV1ResultError(errors_1.TokenStandardV1ResultErrorCode.RESULT_INVALID, `Unknown ${what} ${field}: ${variant.tag}.`, { field, tag: variant.tag, known: [...known] });
76
+ }
77
+ return variant;
78
+ }
79
+ //# sourceMappingURL=result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.js","sourceRoot":"","sources":["../../../../../src/utils/token-standard/v1/result.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+CAA+C;AAC/C,6DAAwF;AACxF,qCAAsF;AAEtF,uHAAuH;AACvH,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G,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,mCAA0B,CAClC,uCAA8B,CAAC,cAAc,EAC7C,OAAO,IAAI,aAAa,KAAK,GAAG,EAChC,EAAE,KAAK,EAAE,CACV,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,mCAA0B,CAClC,uCAA8B,CAAC,cAAc,EAC7C,WAAW,IAAI,IAAI,KAAK,KAAK,OAAO,CAAC,GAAG,GAAG,EAC3C,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC,EAAE,CAC/C,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * What became of a transfer: delivered, waiting on the receiver, or returned to the sender.
3
+ *
4
+ * `TransferInstructionResult.output` is the only thing that says which, and all five transfer choices return it, so one
5
+ * reader covers instructing, accepting, rejecting, withdrawing and expiring.
6
+ */
7
+ /** What became of the units: delivered, waiting on the receiver, or returned to the sender. */
8
+ export type TokenStandardV1TransferStatus = 'completed' | 'pending' | 'failed';
9
+ export interface TokenStandardV1TransferResult {
10
+ readonly updateId: string;
11
+ readonly status: TokenStandardV1TransferStatus;
12
+ /** Change back to the sender, and on a failed path the returned units themselves. */
13
+ readonly senderChangeCids: string[];
14
+ /** The receiver's new holdings, on a completed transfer. */
15
+ readonly receiverHoldingCids: string[];
16
+ /** The pending offer, when the transfer did not complete in this transaction. */
17
+ readonly transferInstructionCid: string | undefined;
18
+ }
19
+ /**
20
+ * The `TransferInstructionResult` of whichever of the five transfer choices this transaction exercised.
21
+ *
22
+ * `failed` is reported only for the standard's `_Failed` output, which says the units went back to the sender. An
23
+ * output the standard does not define, or a result naming none at all, is a failure to read the transaction rather than
24
+ * a transfer that failed.
25
+ */
26
+ export declare function parseTransferResult(transaction: unknown): TokenStandardV1TransferResult;
27
+ //# sourceMappingURL=transfer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transfer.d.ts","sourceRoot":"","sources":["../../../../../src/utils/token-standard/v1/transfer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH,+FAA+F;AAC/F,MAAM,MAAM,6BAA6B,GAAG,WAAW,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE/E,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,6BAA6B,CAAC;IAC/C,qFAAqF;IACrF,QAAQ,CAAC,gBAAgB,EAAE,MAAM,EAAE,CAAC;IACpC,4DAA4D;IAC5D,QAAQ,CAAC,mBAAmB,EAAE,MAAM,EAAE,CAAC;IACvC,iFAAiF;IACjF,QAAQ,CAAC,sBAAsB,EAAE,MAAM,GAAG,SAAS,CAAC;CACrD;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,OAAO,GAAG,6BAA6B,CAiCvF"}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ /**
3
+ * What became of a transfer: delivered, waiting on the receiver, or returned to the sender.
4
+ *
5
+ * `TransferInstructionResult.output` is the only thing that says which, and all five transfer choices return it, so one
6
+ * reader covers instructing, accepting, rejecting, withdrawing and expiring.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.parseTransferResult = parseTransferResult;
10
+ const event_parser_1 = require("../../parsers/event-parser");
11
+ const constants_1 = require("./constants");
12
+ const result_1 = require("./result");
13
+ /**
14
+ * The `TransferInstructionResult` of whichever of the five transfer choices this transaction exercised.
15
+ *
16
+ * `failed` is reported only for the standard's `_Failed` output, which says the units went back to the sender. An
17
+ * output the standard does not define, or a result naming none at all, is a failure to read the transaction rather than
18
+ * a transfer that failed.
19
+ */
20
+ function parseTransferResult(transaction) {
21
+ const result = (0, result_1.requireResultRecordOfAny)(transaction, constants_1.TOKEN_STANDARD_V1_TRANSFER_RESULT_CHOICES);
22
+ const updateId = (0, event_parser_1.requireTransactionUpdateId)(transaction);
23
+ const senderChangeCids = (0, result_1.requireContractIds)(result['senderChangeCids'], 'senderChangeCids');
24
+ const output = (0, result_1.requireKnownVariant)(result, 'output', constants_1.TOKEN_STANDARD_V1_TRANSFER_RESULT_TAGS, 'transfer result');
25
+ if (output.tag === constants_1.TokenStandardV1TransferResultTag.completed) {
26
+ return {
27
+ updateId,
28
+ status: 'completed',
29
+ senderChangeCids,
30
+ receiverHoldingCids: (0, result_1.requireContractIds)(output.value['receiverHoldingCids'], 'receiverHoldingCids'),
31
+ transferInstructionCid: undefined,
32
+ };
33
+ }
34
+ if (output.tag === constants_1.TokenStandardV1TransferResultTag.pending) {
35
+ return {
36
+ updateId,
37
+ status: 'pending',
38
+ senderChangeCids,
39
+ receiverHoldingCids: [],
40
+ transferInstructionCid: (0, result_1.requireNonEmptyString)(output.value['transferInstructionCid'], 'transferInstructionCid'),
41
+ };
42
+ }
43
+ return {
44
+ updateId,
45
+ status: 'failed',
46
+ senderChangeCids,
47
+ receiverHoldingCids: [],
48
+ transferInstructionCid: undefined,
49
+ };
50
+ }
51
+ //# sourceMappingURL=transfer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transfer.js","sourceRoot":"","sources":["../../../../../src/utils/token-standard/v1/transfer.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,6DAAwE;AACxE,2CAIqB;AACrB,qCAAoH;AAgBpH;;;;;;GAMG;AACH,6BAAoC,WAAoB;IACtD,MAAM,MAAM,GAAG,IAAA,iCAAwB,EAAC,WAAW,EAAE,qDAAyC,CAAC,CAAC;IAChG,MAAM,QAAQ,GAAG,IAAA,yCAA0B,EAAC,WAAW,CAAC,CAAC;IACzD,MAAM,gBAAgB,GAAG,IAAA,2BAAkB,EAAC,MAAM,CAAC,kBAAkB,CAAC,EAAE,kBAAkB,CAAC,CAAC;IAC5F,MAAM,MAAM,GAAG,IAAA,4BAAmB,EAAC,MAAM,EAAE,QAAQ,EAAE,kDAAsC,EAAE,iBAAiB,CAAC,CAAC;IAEhH,IAAI,MAAM,CAAC,GAAG,KAAK,4CAAgC,CAAC,SAAS,EAAE,CAAC;QAC9D,OAAO;YACL,QAAQ;YACR,MAAM,EAAE,WAAW;YACnB,gBAAgB;YAChB,mBAAmB,EAAE,IAAA,2BAAkB,EAAC,MAAM,CAAC,KAAK,CAAC,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;YACnG,sBAAsB,EAAE,SAAS;SAClC,CAAC;IACJ,CAAC;IAED,IAAI,MAAM,CAAC,GAAG,KAAK,4CAAgC,CAAC,OAAO,EAAE,CAAC;QAC5D,OAAO;YACL,QAAQ;YACR,MAAM,EAAE,SAAS;YACjB,gBAAgB;YAChB,mBAAmB,EAAE,EAAE;YACvB,sBAAsB,EAAE,IAAA,8BAAqB,EAAC,MAAM,CAAC,KAAK,CAAC,wBAAwB,CAAC,EAAE,wBAAwB,CAAC;SAChH,CAAC;IACJ,CAAC;IAED,OAAO;QACL,QAAQ;QACR,MAAM,EAAE,QAAQ;QAChB,gBAAgB;QAChB,mBAAmB,EAAE,EAAE;QACvB,sBAAsB,EAAE,SAAS;KAClC,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fairmint/canton-node-sdk",
3
- "version": "0.0.259",
3
+ "version": "0.0.260",
4
4
  "description": "Canton Node SDK",
5
5
  "keywords": [
6
6
  "canton",