@layerzerolabs/common-canton 0.2.107 → 0.2.109

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 (43) hide show
  1. package/.turbo/turbo-build.log +602 -603
  2. package/.turbo/turbo-test.log +14 -12
  3. package/dist/5PRNJEPB.js +70 -0
  4. package/dist/5PRNJEPB.js.map +1 -0
  5. package/dist/{NO5PBPQH.js → GXJEEYPP.js} +42 -35
  6. package/dist/GXJEEYPP.js.map +1 -0
  7. package/dist/{3YCNHEVD.js → PSB6BQFH.js} +44 -70
  8. package/dist/PSB6BQFH.js.map +1 -0
  9. package/dist/{KEGAENCF.js → X66QZBHT.js} +11 -2
  10. package/dist/X66QZBHT.js.map +1 -0
  11. package/dist/deferredValue.d.ts +46 -0
  12. package/dist/deferredValue.d.ts.map +1 -0
  13. package/dist/deferredValue.js +4 -0
  14. package/dist/deferredValue.js.map +1 -0
  15. package/dist/events.d.ts +21 -15
  16. package/dist/events.d.ts.map +1 -1
  17. package/dist/events.js +2 -2
  18. package/dist/index.d.ts +1 -1
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +4 -4
  21. package/dist/sdk/canton-sdk.d.ts +7 -0
  22. package/dist/sdk/canton-sdk.d.ts.map +1 -1
  23. package/dist/sdk/canton-sdk.js +1 -1
  24. package/dist/sdk/index.js +1 -1
  25. package/dist/transaction.d.ts +79 -83
  26. package/dist/transaction.d.ts.map +1 -1
  27. package/dist/transaction.js +1 -1
  28. package/package.json +12 -12
  29. package/src/deferredValue.ts +81 -0
  30. package/src/events.ts +93 -74
  31. package/src/index.ts +1 -1
  32. package/src/sdk/canton-sdk.ts +10 -0
  33. package/src/transaction.ts +52 -96
  34. package/dist/3YCNHEVD.js.map +0 -1
  35. package/dist/KEGAENCF.js.map +0 -1
  36. package/dist/NO5PBPQH.js.map +0 -1
  37. package/dist/YVZO3C4U.js +0 -41
  38. package/dist/YVZO3C4U.js.map +0 -1
  39. package/dist/senderPlaceholder.d.ts +0 -41
  40. package/dist/senderPlaceholder.d.ts.map +0 -1
  41. package/dist/senderPlaceholder.js +0 -4
  42. package/dist/senderPlaceholder.js.map +0 -1
  43. package/src/senderPlaceholder.ts +0 -119
@@ -1,41 +0,0 @@
1
- /**
2
- * Sentinel emitted in place of the sender `Party` when the sender is unknown at
3
- * create time; substituted for the real party at sign time.
4
- */
5
- export declare const CANTON_SENDER_PLACEHOLDER = "<<CANTON_SENDER_PLACEHOLDER>>";
6
- /**
7
- * Returns true if `value` is the Canton sender placeholder.
8
- */
9
- export declare const isCantonSenderPlaceholder: (value: string) => boolean;
10
- /** Replace every {@link CANTON_SENDER_PLACEHOLDER} in a command tree with the actual sender party ID. */
11
- export declare const replaceCantonSenderPlaceholders: <T>(value: T, senderParty: string) => T;
12
- /** Returns true if the command tree contains the sender placeholder anywhere. */
13
- export declare const containsCantonSenderPlaceholder: (value: unknown) => boolean;
14
- /**
15
- * Sentinel emitted as the sole element of the `amuletCids` array
16
- * (`amuletCids: [CANTON_AMULET_CIDS_PLACEHOLDER]`); substituted for the resolved
17
- * sender's Amulet contract IDs at sign time.
18
- */
19
- export declare const CANTON_AMULET_CIDS_PLACEHOLDER = "<<CANTON_AMULET_CIDS_PLACEHOLDER>>";
20
- /**
21
- * Returns true if the command tree contains an amulet-cids placeholder array
22
- * anywhere — i.e. an array `[CANTON_AMULET_CIDS_PLACEHOLDER]`.
23
- */
24
- export declare const containsCantonAmuletCidsPlaceholder: (value: unknown) => boolean;
25
- /**
26
- * Recursively walks a JSON-serializable value and replaces every
27
- * `[CANTON_AMULET_CIDS_PLACEHOLDER]` array with the supplied list of resolved
28
- * Amulet contract IDs.
29
- */
30
- export declare const replaceCantonAmuletCidsPlaceholder: <T>(value: T, amuletCids: string[]) => T;
31
- /** Sentinel for a choice's `extraArgs.context`, replaced with the freshly-fetched
32
- * amulet choice context at sign time. */
33
- export declare const CANTON_AMULET_CONTEXT_PLACEHOLDER = "<<CANTON_AMULET_CONTEXT_PLACEHOLDER>>";
34
- /** Sentinel for the exercised ExternalPartyAmuletRules contract id, re-pinned to the
35
- * freshly-fetched amulet fee bundle at sign time. */
36
- export declare const CANTON_AMULET_RULES_CID_PLACEHOLDER = "<<CANTON_AMULET_RULES_CID_PLACEHOLDER>>";
37
- /** Returns true if any scalar leaf in the tree equals `placeholder`. */
38
- export declare const containsPlaceholderValue: (value: unknown, placeholder: string) => boolean;
39
- /** Replace every scalar sentinel leaf equal to `placeholder` with `replacement`. */
40
- export declare const replacePlaceholderValue: <T>(value: T, placeholder: string, replacement: unknown) => T;
41
- //# sourceMappingURL=senderPlaceholder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"senderPlaceholder.d.ts","sourceRoot":"","sources":["../src/senderPlaceholder.ts"],"names":[],"mappings":"AAwCA;;;GAGG;AACH,eAAO,MAAM,yBAAyB,kCAAkC,CAAC;AAEzE;;GAEG;AACH,eAAO,MAAM,yBAAyB,GAAI,OAAO,MAAM,KAAG,OACnB,CAAC;AAExC,yGAAyG;AACzG,eAAO,MAAM,+BAA+B,GAAI,CAAC,EAAE,OAAO,CAAC,EAAE,aAAa,MAAM,KAAG,CAG9E,CAAC;AAEN,iFAAiF;AACjF,eAAO,MAAM,+BAA+B,GAAI,OAAO,OAAO,KAAG,OACI,CAAC;AAMtE;;;;GAIG;AACH,eAAO,MAAM,8BAA8B,uCAAuC,CAAC;AAKnF;;;GAGG;AACH,eAAO,MAAM,mCAAmC,GAAI,OAAO,OAAO,KAAG,OAChB,CAAC;AAEtD;;;;GAIG;AACH,eAAO,MAAM,kCAAkC,GAAI,CAAC,EAAE,OAAO,CAAC,EAAE,YAAY,MAAM,EAAE,KAAG,CAGlF,CAAC;AAEN;0CAC0C;AAC1C,eAAO,MAAM,iCAAiC,0CAA0C,CAAC;AAEzF;sDACsD;AACtD,eAAO,MAAM,mCAAmC,4CAA4C,CAAC;AAU7F,wEAAwE;AACxE,eAAO,MAAM,wBAAwB,GAAI,OAAO,OAAO,EAAE,aAAa,MAAM,KAAG,OACxB,CAAC;AAExD,oFAAoF;AACpF,eAAO,MAAM,uBAAuB,GAAI,CAAC,EACrC,OAAO,CAAC,EACR,aAAa,MAAM,EACnB,aAAa,OAAO,KACrB,CAAwF,CAAC"}
@@ -1,4 +0,0 @@
1
- export { CANTON_AMULET_CIDS_PLACEHOLDER, CANTON_AMULET_CONTEXT_PLACEHOLDER, CANTON_AMULET_RULES_CID_PLACEHOLDER, CANTON_SENDER_PLACEHOLDER, containsCantonAmuletCidsPlaceholder, containsCantonSenderPlaceholder, containsPlaceholderValue, isCantonSenderPlaceholder, replaceCantonAmuletCidsPlaceholder, replaceCantonSenderPlaceholders, replacePlaceholderValue } from './YVZO3C4U.js';
2
- import './VUOMXK5T.js';
3
- //# sourceMappingURL=senderPlaceholder.js.map
4
- //# sourceMappingURL=senderPlaceholder.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"senderPlaceholder.js"}
@@ -1,119 +0,0 @@
1
- import { mapValues } from 'es-toolkit';
2
-
3
- // ─────────────────────────────────────────────────────────────────────────────
4
- // Generic JSON-tree visitors
5
- // ─────────────────────────────────────────────────────────────────────────────
6
-
7
- /**
8
- * Result of a leaf check: either the leaf has been replaced (with `value`),
9
- * or `undefined` to leave it alone and recurse into its children.
10
- */
11
- type LeafResult = { value: unknown } | undefined;
12
-
13
- /** Walk a JSON value and rewrite leaves matched by `replace`; recursion stops at a swapped leaf. */
14
- const visit = <T>(value: T, replace: (leaf: unknown) => LeafResult): T => {
15
- const result = replace(value);
16
- if (result) return result.value as T;
17
- if (Array.isArray(value)) {
18
- return value.map((item) => visit(item, replace)) as T;
19
- }
20
- if (value !== null && typeof value === 'object') {
21
- return mapValues(value as Record<string, unknown>, (item) => visit(item, replace)) as T;
22
- }
23
- return value;
24
- };
25
-
26
- /** True if `predicate` matches any leaf or sub-value in the tree. */
27
- const containsLeaf = (value: unknown, predicate: (leaf: unknown) => boolean): boolean => {
28
- if (predicate(value)) return true;
29
- if (Array.isArray(value)) return value.some((item) => containsLeaf(item, predicate));
30
- return (
31
- value !== null &&
32
- typeof value === 'object' &&
33
- Object.values(value).some((item) => containsLeaf(item, predicate))
34
- );
35
- };
36
-
37
- // ─────────────────────────────────────────────────────────────────────────────
38
- // Sender placeholder
39
- // ─────────────────────────────────────────────────────────────────────────────
40
-
41
- /**
42
- * Sentinel emitted in place of the sender `Party` when the sender is unknown at
43
- * create time; substituted for the real party at sign time.
44
- */
45
- export const CANTON_SENDER_PLACEHOLDER = '<<CANTON_SENDER_PLACEHOLDER>>';
46
-
47
- /**
48
- * Returns true if `value` is the Canton sender placeholder.
49
- */
50
- export const isCantonSenderPlaceholder = (value: string): boolean =>
51
- value === CANTON_SENDER_PLACEHOLDER;
52
-
53
- /** Replace every {@link CANTON_SENDER_PLACEHOLDER} in a command tree with the actual sender party ID. */
54
- export const replaceCantonSenderPlaceholders = <T>(value: T, senderParty: string): T =>
55
- visit(value, (leaf) =>
56
- leaf === CANTON_SENDER_PLACEHOLDER ? { value: senderParty } : undefined,
57
- );
58
-
59
- /** Returns true if the command tree contains the sender placeholder anywhere. */
60
- export const containsCantonSenderPlaceholder = (value: unknown): boolean =>
61
- containsLeaf(value, (leaf) => leaf === CANTON_SENDER_PLACEHOLDER);
62
-
63
- // ─────────────────────────────────────────────────────────────────────────────
64
- // AmuletCids placeholder
65
- // ─────────────────────────────────────────────────────────────────────────────
66
-
67
- /**
68
- * Sentinel emitted as the sole element of the `amuletCids` array
69
- * (`amuletCids: [CANTON_AMULET_CIDS_PLACEHOLDER]`); substituted for the resolved
70
- * sender's Amulet contract IDs at sign time.
71
- */
72
- export const CANTON_AMULET_CIDS_PLACEHOLDER = '<<CANTON_AMULET_CIDS_PLACEHOLDER>>';
73
-
74
- const isAmuletCidsPlaceholderArray = (value: unknown): value is [string] =>
75
- Array.isArray(value) && value.length === 1 && value[0] === CANTON_AMULET_CIDS_PLACEHOLDER;
76
-
77
- /**
78
- * Returns true if the command tree contains an amulet-cids placeholder array
79
- * anywhere — i.e. an array `[CANTON_AMULET_CIDS_PLACEHOLDER]`.
80
- */
81
- export const containsCantonAmuletCidsPlaceholder = (value: unknown): boolean =>
82
- containsLeaf(value, isAmuletCidsPlaceholderArray);
83
-
84
- /**
85
- * Recursively walks a JSON-serializable value and replaces every
86
- * `[CANTON_AMULET_CIDS_PLACEHOLDER]` array with the supplied list of resolved
87
- * Amulet contract IDs.
88
- */
89
- export const replaceCantonAmuletCidsPlaceholder = <T>(value: T, amuletCids: string[]): T =>
90
- visit(value, (leaf) =>
91
- isAmuletCidsPlaceholderArray(leaf) ? { value: amuletCids } : undefined,
92
- );
93
-
94
- /** Sentinel for a choice's `extraArgs.context`, replaced with the freshly-fetched
95
- * amulet choice context at sign time. */
96
- export const CANTON_AMULET_CONTEXT_PLACEHOLDER = '<<CANTON_AMULET_CONTEXT_PLACEHOLDER>>';
97
-
98
- /** Sentinel for the exercised ExternalPartyAmuletRules contract id, re-pinned to the
99
- * freshly-fetched amulet fee bundle at sign time. */
100
- export const CANTON_AMULET_RULES_CID_PLACEHOLDER = '<<CANTON_AMULET_RULES_CID_PLACEHOLDER>>';
101
-
102
- // ─────────────────────────────────────────────────────────────────────────────
103
- // Generic placeholder helpers (sentinel-agnostic)
104
- //
105
- // Used by the sign-time refresh executor, which receives the sentinel to match as
106
- // data (from the transaction's refreshSpec, or a known amulet sentinel) instead of
107
- // hardcoding it here — keeping these helpers free of any contract knowledge.
108
- // ─────────────────────────────────────────────────────────────────────────────
109
-
110
- /** Returns true if any scalar leaf in the tree equals `placeholder`. */
111
- export const containsPlaceholderValue = (value: unknown, placeholder: string): boolean =>
112
- containsLeaf(value, (leaf) => leaf === placeholder);
113
-
114
- /** Replace every scalar sentinel leaf equal to `placeholder` with `replacement`. */
115
- export const replacePlaceholderValue = <T>(
116
- value: T,
117
- placeholder: string,
118
- replacement: unknown,
119
- ): T => visit(value, (leaf) => (leaf === placeholder ? { value: replacement } : undefined));