@layerzerolabs/common-canton 1.2.62 → 1.2.64

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.
@@ -1,13 +1,21 @@
1
1
  import { CANTON_DEFERRED_VALUE_SUFFIX, isCantonDeferredSentinel } from './QSQZYJB6.js';
2
2
  import { __name } from './VUOMXK5T.js';
3
- import { trim0x } from '@layerzerolabs/common-encoding-utils';
3
+ import { hexZeroPad, trim0x } from '@layerzerolabs/common-encoding-utils';
4
4
 
5
5
  var CANTON_PARTY_ID_REGEX = /^(.+)::([0-9a-fA-F]+)$/;
6
6
  var CANTON_CONTRACT_ID_HEX_LENGTH = 138;
7
7
  var CANTON_PARTY_ADDRESS_PREFIX = "<<CANTON_PARTY::";
8
8
  var CANTON_CID_ADDRESS_PREFIX = "<<CANTON_CID::";
9
+ var CANTON_GLOBAL_ADDRESS_PREFIX = "<<CANTON_GLOBAL::";
9
10
  var cantonPartyAddress = /* @__PURE__ */ __name((hint, fingerprint) => `${CANTON_PARTY_ADDRESS_PREFIX}${hint}::${fingerprint}${CANTON_DEFERRED_VALUE_SUFFIX}`, "cantonPartyAddress");
10
11
  var cantonCidAddress = /* @__PURE__ */ __name((contractId) => `${CANTON_CID_ADDRESS_PREFIX}${contractId}${CANTON_DEFERRED_VALUE_SUFFIX}`, "cantonCidAddress");
12
+ var cantonGlobalAddress = /* @__PURE__ */ __name((address) => {
13
+ if (!/^(?:0x)?[0-9a-fA-F]{1,64}$/.test(address)) {
14
+ throw new Error(`Invalid Canton global bytes32 address: ${address}`);
15
+ }
16
+ return `${CANTON_GLOBAL_ADDRESS_PREFIX}${hexZeroPad(address, 32).toLowerCase()}${CANTON_DEFERRED_VALUE_SUFFIX}`;
17
+ }, "cantonGlobalAddress");
18
+ var isCantonGlobalAddress = /* @__PURE__ */ __name((value) => /^<<CANTON_GLOBAL::0x[0-9a-fA-F]{64}>>$/.test(value), "isCantonGlobalAddress");
11
19
  var cantonDeferredAddress = /* @__PURE__ */ __name((sentinel) => sentinel, "cantonDeferredAddress");
12
20
  var toCantonAddress = /* @__PURE__ */ __name((raw) => {
13
21
  if (isCantonDeferredSentinel(raw)) {
@@ -24,8 +32,8 @@ var toCantonAddress = /* @__PURE__ */ __name((raw) => {
24
32
  }
25
33
  throw new Error(`Not a Canton-native address: ${raw}`);
26
34
  }, "toCantonAddress");
27
- var isCantonAddress = /* @__PURE__ */ __name((value) => value.startsWith(CANTON_PARTY_ADDRESS_PREFIX) || value.startsWith(CANTON_CID_ADDRESS_PREFIX) || isCantonDeferredSentinel(value), "isCantonAddress");
35
+ var isCantonAddress = /* @__PURE__ */ __name((value) => value.startsWith(CANTON_PARTY_ADDRESS_PREFIX) || value.startsWith(CANTON_CID_ADDRESS_PREFIX) || isCantonDeferredSentinel(value) || isCantonGlobalAddress(value), "isCantonAddress");
28
36
 
29
- export { CANTON_CID_ADDRESS_PREFIX, CANTON_PARTY_ADDRESS_PREFIX, cantonCidAddress, cantonDeferredAddress, cantonPartyAddress, isCantonAddress, toCantonAddress };
30
- //# sourceMappingURL=FADZDRWB.js.map
31
- //# sourceMappingURL=FADZDRWB.js.map
37
+ export { CANTON_CID_ADDRESS_PREFIX, CANTON_GLOBAL_ADDRESS_PREFIX, CANTON_PARTY_ADDRESS_PREFIX, cantonCidAddress, cantonDeferredAddress, cantonGlobalAddress, cantonPartyAddress, isCantonAddress, isCantonGlobalAddress, toCantonAddress };
38
+ //# sourceMappingURL=LCM7LWM5.js.map
39
+ //# sourceMappingURL=LCM7LWM5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/address.ts"],"names":["CANTON_PARTY_ID_REGEX","CANTON_CONTRACT_ID_HEX_LENGTH","CANTON_PARTY_ADDRESS_PREFIX","CANTON_CID_ADDRESS_PREFIX","CANTON_GLOBAL_ADDRESS_PREFIX","cantonPartyAddress","hint","fingerprint","CANTON_DEFERRED_VALUE_SUFFIX","cantonCidAddress","contractId","cantonGlobalAddress","address","test","Error","hexZeroPad","toLowerCase","isCantonGlobalAddress","value","cantonDeferredAddress","sentinel","toCantonAddress","raw","isCantonDeferredSentinel","partyMatch","exec","bare","trim0x","length","startsWith","isCantonAddress"],"mappings":";;;;AAKA,IAAMA,qBAAAA,GAAwB,wBAAA;AAC9B,IAAMC,6BAAAA,GAAgC,GAAA;AAE/B,IAAMC,2BAAAA,GAA8B;AACpC,IAAMC,yBAAAA,GAA4B;AAClC,IAAMC,4BAAAA,GAA+B;AAMrC,IAAMC,kBAAAA,mBAAqB,MAAA,CAAA,CAACC,IAAAA,EAAcC,WAAAA,KAC7C,CAAA,EAAGL,2BAAAA,CAAAA,EAA8BI,IAAAA,CAAAA,EAAAA,EAASC,WAAAA,CAAAA,EAAcC,4BAAAA,CAAAA,CAAAA,EAD1B,oBAAA;AAI3B,IAAMC,gBAAAA,2BAAoBC,UAAAA,KAC7B,CAAA,EAAGP,yBAAAA,CAAAA,EAA4BO,UAAAA,CAAAA,EAAaF,4BAAAA,CAAAA,CAAAA,EADhB,kBAAA;AAIzB,IAAMG,mBAAAA,2BAAuBC,OAAAA,KAAAA;AAChC,EAAA,IAAI,CAAC,4BAAA,CAA6BC,IAAAA,CAAKD,OAAAA,CAAAA,EAAU;AAC7C,IAAA,MAAM,IAAIE,KAAAA,CAAM,CAAA,uCAAA,EAA0CF,OAAAA,CAAAA,CAAS,CAAA;AACvE,EAAA;AACA,EAAA,OAAO,CAAA,EAAGR,4BAAAA,CAAAA,EAA+BW,UAAAA,CAAWH,OAAAA,EAAS,EAAA,CAAA,CAAII,WAAAA,EAAW,CAAA,EAAKR,4BAAAA,CAAAA,CAAAA;AACrF,CAAA,EALmC,qBAAA;AAO5B,IAAMS,wCAAwB,MAAA,CAAA,CAACC,KAAAA,KAClC,wCAAA,CAAyCL,IAAAA,CAAKK,KAAAA,CAAAA,EADb,uBAAA;AAI9B,IAAMC,qBAAAA,mBAAwB,MAAA,CAAA,CAACC,QAAAA,KAAoCA,QAAAA,EAArC,uBAAA;AAG9B,IAAMC,eAAAA,2BAAmBC,GAAAA,KAAAA;AAC5B,EAAA,IAAIC,wBAAAA,CAAyBD,GAAAA,CAAAA,EAAM;AAC/B,IAAA,OAAOH,sBAAsBG,GAAAA,CAAAA;AACjC,EAAA;AACA,EAAA,MAAME,UAAAA,GAAaxB,qBAAAA,CAAsByB,IAAAA,CAAKH,GAAAA,CAAAA;AAC9C,EAAA,IAAIE,UAAAA,EAAY;AACZ,IAAA,MAAM,GAAGlB,IAAAA,EAAMC,WAAAA,CAAAA,GAAeiB,UAAAA;AAC9B,IAAA,OAAOnB,kBAAAA,CAAmBC,MAAOC,WAAAA,CAAAA;AACrC,EAAA;AACA,EAAA,MAAMmB,IAAAA,GAAOC,OAAOL,GAAAA,CAAAA;AACpB,EAAA,IAAII,KAAKE,MAAAA,KAAW3B,6BAAAA,IAAiCyB,IAAAA,CAAKG,UAAAA,CAAW,IAAA,CAAA,EAAO;AACxE,IAAA,OAAOpB,iBAAiBiB,IAAAA,CAAAA;AAC5B,EAAA;AACA,EAAA,MAAM,IAAIZ,KAAAA,CAAM,CAAA,6BAAA,EAAgCQ,GAAAA,CAAAA,CAAK,CAAA;AACzD,CAAA,EAd+B,iBAAA;AAiBxB,IAAMQ,kCAAkB,MAAA,CAAA,CAACZ,KAAAA,KAC5BA,KAAAA,CAAMW,UAAAA,CAAW3B,2BAAAA,CAAAA,IACjBgB,KAAAA,CAAMW,UAAAA,CAAW1B,yBAAAA,KACjBoB,wBAAAA,CAAyBL,KAAAA,CAAAA,IACzBD,qBAAAA,CAAsBC,KAAAA,CAAAA,EAJK,iBAAA","file":"LCM7LWM5.js","sourcesContent":["import { hexZeroPad, trim0x } from '@layerzerolabs/common-encoding-utils';\nimport type { Branded } from '@layerzerolabs/typescript-utils';\n\nimport { CANTON_DEFERRED_VALUE_SUFFIX, isCantonDeferredSentinel } from './deferredValue';\n\nconst CANTON_PARTY_ID_REGEX = /^(.+)::([0-9a-fA-F]+)$/;\nconst CANTON_CONTRACT_ID_HEX_LENGTH = 138; // 69 bytes\n\nexport const CANTON_PARTY_ADDRESS_PREFIX = '<<CANTON_PARTY::';\nexport const CANTON_CID_ADDRESS_PREFIX = '<<CANTON_CID::';\nexport const CANTON_GLOBAL_ADDRESS_PREFIX = '<<CANTON_GLOBAL::';\n\n/** A Canton ledger or VER global address, with an explicit sentinel prefix. */\nexport type CantonAddress = Branded<string, 'CantonAddress'>;\n\n/** Construct a party `CantonAddress` from hint and fingerprint. */\nexport const cantonPartyAddress = (hint: string, fingerprint: string): CantonAddress =>\n `${CANTON_PARTY_ADDRESS_PREFIX}${hint}::${fingerprint}${CANTON_DEFERRED_VALUE_SUFFIX}` as CantonAddress;\n\n/** Construct a contract-ID `CantonAddress` from the raw 69-byte hex contract id. */\nexport const cantonCidAddress = (contractId: string): CantonAddress =>\n `${CANTON_CID_ADDRESS_PREFIX}${contractId}${CANTON_DEFERRED_VALUE_SUFFIX}` as CantonAddress;\n\n/** Explicitly wrap an already-derived VER global address. This does not hash the input. */\nexport const cantonGlobalAddress = (address: string): CantonAddress => {\n if (!/^(?:0x)?[0-9a-fA-F]{1,64}$/.test(address)) {\n throw new Error(`Invalid Canton global bytes32 address: ${address}`);\n }\n return `${CANTON_GLOBAL_ADDRESS_PREFIX}${hexZeroPad(address, 32).toLowerCase()}${CANTON_DEFERRED_VALUE_SUFFIX}` as CantonAddress;\n};\n\nexport const isCantonGlobalAddress = (value: string): value is CantonAddress =>\n /^<<CANTON_GLOBAL::0x[0-9a-fA-F]{64}>>$/.test(value);\n\n/** Wrap a deferred-ref sentinel (`<<CANTON_DEFERRED:{json}>>`) as a `CantonAddress`. */\nexport const cantonDeferredAddress = (sentinel: string): CantonAddress => sentinel as CantonAddress;\n\n/** Wrap a raw Canton ledger value (party id, contract id, or deferred sentinel) as `CantonAddress`. */\nexport const toCantonAddress = (raw: string): CantonAddress => {\n if (isCantonDeferredSentinel(raw)) {\n return cantonDeferredAddress(raw);\n }\n const partyMatch = CANTON_PARTY_ID_REGEX.exec(raw);\n if (partyMatch) {\n const [, hint, fingerprint] = partyMatch;\n return cantonPartyAddress(hint!, fingerprint!);\n }\n const bare = trim0x(raw);\n if (bare.length === CANTON_CONTRACT_ID_HEX_LENGTH && bare.startsWith('00')) {\n return cantonCidAddress(bare);\n }\n throw new Error(`Not a Canton-native address: ${raw}`);\n};\n\n/** Returns true if `value` is a valid `CantonAddress` sentinel string. */\nexport const isCantonAddress = (value: string): value is CantonAddress =>\n value.startsWith(CANTON_PARTY_ADDRESS_PREFIX) ||\n value.startsWith(CANTON_CID_ADDRESS_PREFIX) ||\n isCantonDeferredSentinel(value) ||\n isCantonGlobalAddress(value);\n"]}
package/dist/address.d.ts CHANGED
@@ -1,12 +1,16 @@
1
1
  import type { Branded } from '@layerzerolabs/typescript-utils';
2
2
  export declare const CANTON_PARTY_ADDRESS_PREFIX = "<<CANTON_PARTY::";
3
3
  export declare const CANTON_CID_ADDRESS_PREFIX = "<<CANTON_CID::";
4
- /** A Canton native address — a branded string with one of three sentinel-prefix forms. */
4
+ export declare const CANTON_GLOBAL_ADDRESS_PREFIX = "<<CANTON_GLOBAL::";
5
+ /** A Canton ledger or VER global address, with an explicit sentinel prefix. */
5
6
  export type CantonAddress = Branded<string, 'CantonAddress'>;
6
7
  /** Construct a party `CantonAddress` from hint and fingerprint. */
7
8
  export declare const cantonPartyAddress: (hint: string, fingerprint: string) => CantonAddress;
8
9
  /** Construct a contract-ID `CantonAddress` from the raw 69-byte hex contract id. */
9
10
  export declare const cantonCidAddress: (contractId: string) => CantonAddress;
11
+ /** Explicitly wrap an already-derived VER global address. This does not hash the input. */
12
+ export declare const cantonGlobalAddress: (address: string) => CantonAddress;
13
+ export declare const isCantonGlobalAddress: (value: string) => value is CantonAddress;
10
14
  /** Wrap a deferred-ref sentinel (`<<CANTON_DEFERRED:{json}>>`) as a `CantonAddress`. */
11
15
  export declare const cantonDeferredAddress: (sentinel: string) => CantonAddress;
12
16
  /** Wrap a raw Canton ledger value (party id, contract id, or deferred sentinel) as `CantonAddress`. */
@@ -1 +1 @@
1
- {"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../src/address.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAO/D,eAAO,MAAM,2BAA2B,qBAAqB,CAAC;AAC9D,eAAO,MAAM,yBAAyB,mBAAmB,CAAC;AAE1D,0FAA0F;AAC1F,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;AAE7D,mEAAmE;AACnE,eAAO,MAAM,kBAAkB,GAAI,MAAM,MAAM,EAAE,aAAa,MAAM,KAAG,aACoC,CAAC;AAE5G,oFAAoF;AACpF,eAAO,MAAM,gBAAgB,GAAI,YAAY,MAAM,KAAG,aACyC,CAAC;AAEhG,wFAAwF;AACxF,eAAO,MAAM,qBAAqB,GAAI,UAAU,MAAM,KAAG,aAA0C,CAAC;AAEpG,uGAAuG;AACvG,eAAO,MAAM,eAAe,GAAI,KAAK,MAAM,KAAG,aAc7C,CAAC;AAEF,0EAA0E;AAC1E,eAAO,MAAM,eAAe,GAAI,OAAO,MAAM,KAAG,KAAK,IAAI,aAGtB,CAAC"}
1
+ {"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../src/address.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAO/D,eAAO,MAAM,2BAA2B,qBAAqB,CAAC;AAC9D,eAAO,MAAM,yBAAyB,mBAAmB,CAAC;AAC1D,eAAO,MAAM,4BAA4B,sBAAsB,CAAC;AAEhE,+EAA+E;AAC/E,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;AAE7D,mEAAmE;AACnE,eAAO,MAAM,kBAAkB,GAAI,MAAM,MAAM,EAAE,aAAa,MAAM,KAAG,aACoC,CAAC;AAE5G,oFAAoF;AACpF,eAAO,MAAM,gBAAgB,GAAI,YAAY,MAAM,KAAG,aACyC,CAAC;AAEhG,2FAA2F;AAC3F,eAAO,MAAM,mBAAmB,GAAI,SAAS,MAAM,KAAG,aAKrD,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,OAAO,MAAM,KAAG,KAAK,IAAI,aACP,CAAC;AAEzD,wFAAwF;AACxF,eAAO,MAAM,qBAAqB,GAAI,UAAU,MAAM,KAAG,aAA0C,CAAC;AAEpG,uGAAuG;AACvG,eAAO,MAAM,eAAe,GAAI,KAAK,MAAM,KAAG,aAc7C,CAAC;AAEF,0EAA0E;AAC1E,eAAO,MAAM,eAAe,GAAI,OAAO,MAAM,KAAG,KAAK,IAAI,aAIzB,CAAC"}
package/dist/address.js CHANGED
@@ -1,4 +1,4 @@
1
- export { CANTON_CID_ADDRESS_PREFIX, CANTON_PARTY_ADDRESS_PREFIX, cantonCidAddress, cantonDeferredAddress, cantonPartyAddress, isCantonAddress, toCantonAddress } from './FADZDRWB.js';
1
+ export { CANTON_CID_ADDRESS_PREFIX, CANTON_GLOBAL_ADDRESS_PREFIX, CANTON_PARTY_ADDRESS_PREFIX, cantonCidAddress, cantonDeferredAddress, cantonGlobalAddress, cantonPartyAddress, isCantonAddress, isCantonGlobalAddress, toCantonAddress } from './LCM7LWM5.js';
2
2
  import './QSQZYJB6.js';
3
3
  import './VUOMXK5T.js';
4
4
  //# sourceMappingURL=address.js.map
package/dist/browser.js CHANGED
@@ -1,4 +1,4 @@
1
- export { CANTON_CID_ADDRESS_PREFIX, CANTON_PARTY_ADDRESS_PREFIX, cantonCidAddress, cantonDeferredAddress, cantonPartyAddress, isCantonAddress, toCantonAddress } from './FADZDRWB.js';
1
+ export { CANTON_CID_ADDRESS_PREFIX, CANTON_GLOBAL_ADDRESS_PREFIX, CANTON_PARTY_ADDRESS_PREFIX, cantonCidAddress, cantonDeferredAddress, cantonGlobalAddress, cantonPartyAddress, isCantonAddress, isCantonGlobalAddress, toCantonAddress } from './LCM7LWM5.js';
2
2
  export { SECP256K1_SPKI_DER_HEADER, SECP256K1_SPKI_DER_HEADER_HEX, derEncodeSignature, publicKeyToSpkiDer } from './CMDFOA7C.js';
3
3
  export { assertHexLength, codePointLength, formatDamlDecimal, intToHex, keccak256Hex, padLeft, showBool, showInt, textToHex, timeToUnixSeconds, toBigInt } from './EZIA6KIP.js';
4
4
  export { CANTON_DEFERRED_SENDER, CANTON_DEFERRED_VALUE_PREFIX, CANTON_DEFERRED_VALUE_SUFFIX, cantonActiveContractIdRef, cantonActiveContractIdsRef, cantonAmuletContextRef, cantonAmuletRulesCidRef, cantonDeferredSenderSchema, cantonDeferredValueSchema, cantonExpectedSignatoriesSchema, cantonRefreshPartyFilterSchema, cantonSenderPartyRef, encodeCantonDeferredValue, isCantonDeferredSender, isCantonDeferredSentinel, isCantonPlaceholder, parseCantonDeferredValue, parseCantonDeferredValueOrThrow } from './QSQZYJB6.js';
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
- import './5GUYLHA7.js';
2
- export { CantonSdk } from './D52OIJDY.js';
3
1
  import './AQJMQQ4W.js';
4
2
  export { buildCantonDeployedContractAddressRef, qualifiedTemplateName, templateIdMatches } from './XWKAFAGE.js';
5
3
  export { resolveCantonTransaction } from './AM6OIKMW.js';
6
4
  export { createContractAddressResolver, isConcreteActiveContractRef, isRefAlive, matchesContractStateFilter, queryLiveContractIdsForRef, queryLiveContractsForRef, resolveContractStateFilter, resolveExpectedSignatories } from './75B7Y26B.js';
7
5
  export { wrapLzSdk } from './HF5HP2EX.js';
8
6
  export { substituteCidsToRefs, substituteRefsToCids } from './WLHCBBAJ.js';
7
+ import './5GUYLHA7.js';
8
+ export { CantonSdk } from './D52OIJDY.js';
9
9
  import './7JX6NIYS.js';
10
10
  export { buildMultiTransactionSignatures, buildSignedTransaction } from './WKC6X2E3.js';
11
11
  import './IIWYAFUO.js';
@@ -309,7 +309,7 @@ import './RSV7WS7X.js';
309
309
  export { LocalTokenProvider } from './YF7P4UQM.js';
310
310
  export { ClientCredentialsTokenProvider } from './V2H2WXKE.js';
311
311
  export { parseAmuletAmount, parseAmuletDecimal } from './CXTOAS7N.js';
312
- export { CANTON_CID_ADDRESS_PREFIX, CANTON_PARTY_ADDRESS_PREFIX, cantonCidAddress, cantonDeferredAddress, cantonPartyAddress, isCantonAddress, toCantonAddress } from './FADZDRWB.js';
312
+ export { CANTON_CID_ADDRESS_PREFIX, CANTON_GLOBAL_ADDRESS_PREFIX, CANTON_PARTY_ADDRESS_PREFIX, cantonCidAddress, cantonDeferredAddress, cantonGlobalAddress, cantonPartyAddress, isCantonAddress, isCantonGlobalAddress, toCantonAddress } from './LCM7LWM5.js';
313
313
  export { SECP256K1_SPKI_DER_HEADER, SECP256K1_SPKI_DER_HEADER_HEX, derEncodeSignature, publicKeyToSpkiDer } from './CMDFOA7C.js';
314
314
  export { assertHexLength, codePointLength, formatDamlDecimal, intToHex, keccak256Hex, padLeft, showBool, showInt, textToHex, timeToUnixSeconds, toBigInt } from './EZIA6KIP.js';
315
315
  export { CANTON_DEFERRED_SENDER, CANTON_DEFERRED_VALUE_PREFIX, CANTON_DEFERRED_VALUE_SUFFIX, cantonActiveContractIdRef, cantonActiveContractIdsRef, cantonAmuletContextRef, cantonAmuletRulesCidRef, cantonDeferredSenderSchema, cantonDeferredValueSchema, cantonExpectedSignatoriesSchema, cantonRefreshPartyFilterSchema, cantonSenderPartyRef, encodeCantonDeferredValue, isCantonDeferredSender, isCantonDeferredSentinel, isCantonPlaceholder, parseCantonDeferredValue, parseCantonDeferredValueOrThrow } from './QSQZYJB6.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@layerzerolabs/common-canton",
3
- "version": "1.2.62",
3
+ "version": "1.2.64",
4
4
  "private": false,
5
5
  "description": "Canton VM client and utilities",
6
6
  "license": "MIT",
@@ -37,10 +37,10 @@
37
37
  "@protobuf-ts/runtime-rpc": "^2.11.1",
38
38
  "es-toolkit": "^1.39.10",
39
39
  "zod": "4.3.5",
40
- "@layerzerolabs/common-encoding-utils": "1.2.62",
41
- "@layerzerolabs/common-chain-model": "1.2.62",
42
- "@layerzerolabs/typescript-utils": "1.2.62",
43
- "@layerzerolabs/common-error-utils": "1.2.62"
40
+ "@layerzerolabs/common-chain-model": "1.2.64",
41
+ "@layerzerolabs/common-error-utils": "1.2.64",
42
+ "@layerzerolabs/common-encoding-utils": "1.2.64",
43
+ "@layerzerolabs/typescript-utils": "1.2.64"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@vitest/coverage-v8": "4.1.10",
@@ -48,11 +48,11 @@
48
48
  "tsup": "^8.4.0",
49
49
  "typescript": "^6.0.3",
50
50
  "vitest": "^4.1.10",
51
- "@layerzerolabs/eslint-configuration": "^1.2.62",
52
- "@layerzerolabs/typescript-configuration": "1.2.62",
53
- "@layerzerolabs/vitest-configuration": "1.2.62",
54
- "@layerzerolabs/tsup-configuration": "1.2.62",
55
- "@layerzerolabs/vm-tooling-canton": "1.2.62"
51
+ "@layerzerolabs/eslint-configuration": "^1.2.64",
52
+ "@layerzerolabs/tsup-configuration": "1.2.64",
53
+ "@layerzerolabs/vitest-configuration": "1.2.64",
54
+ "@layerzerolabs/typescript-configuration": "1.2.64",
55
+ "@layerzerolabs/vm-tooling-canton": "1.2.64"
56
56
  },
57
57
  "publishConfig": {
58
58
  "access": "public",
package/src/address.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { trim0x } from '@layerzerolabs/common-encoding-utils';
1
+ import { hexZeroPad, trim0x } from '@layerzerolabs/common-encoding-utils';
2
2
  import type { Branded } from '@layerzerolabs/typescript-utils';
3
3
 
4
4
  import { CANTON_DEFERRED_VALUE_SUFFIX, isCantonDeferredSentinel } from './deferredValue';
@@ -8,8 +8,9 @@ const CANTON_CONTRACT_ID_HEX_LENGTH = 138; // 69 bytes
8
8
 
9
9
  export const CANTON_PARTY_ADDRESS_PREFIX = '<<CANTON_PARTY::';
10
10
  export const CANTON_CID_ADDRESS_PREFIX = '<<CANTON_CID::';
11
+ export const CANTON_GLOBAL_ADDRESS_PREFIX = '<<CANTON_GLOBAL::';
11
12
 
12
- /** A Canton native address — a branded string with one of three sentinel-prefix forms. */
13
+ /** A Canton ledger or VER global address, with an explicit sentinel prefix. */
13
14
  export type CantonAddress = Branded<string, 'CantonAddress'>;
14
15
 
15
16
  /** Construct a party `CantonAddress` from hint and fingerprint. */
@@ -20,6 +21,17 @@ export const cantonPartyAddress = (hint: string, fingerprint: string): CantonAdd
20
21
  export const cantonCidAddress = (contractId: string): CantonAddress =>
21
22
  `${CANTON_CID_ADDRESS_PREFIX}${contractId}${CANTON_DEFERRED_VALUE_SUFFIX}` as CantonAddress;
22
23
 
24
+ /** Explicitly wrap an already-derived VER global address. This does not hash the input. */
25
+ export const cantonGlobalAddress = (address: string): CantonAddress => {
26
+ if (!/^(?:0x)?[0-9a-fA-F]{1,64}$/.test(address)) {
27
+ throw new Error(`Invalid Canton global bytes32 address: ${address}`);
28
+ }
29
+ return `${CANTON_GLOBAL_ADDRESS_PREFIX}${hexZeroPad(address, 32).toLowerCase()}${CANTON_DEFERRED_VALUE_SUFFIX}` as CantonAddress;
30
+ };
31
+
32
+ export const isCantonGlobalAddress = (value: string): value is CantonAddress =>
33
+ /^<<CANTON_GLOBAL::0x[0-9a-fA-F]{64}>>$/.test(value);
34
+
23
35
  /** Wrap a deferred-ref sentinel (`<<CANTON_DEFERRED:{json}>>`) as a `CantonAddress`. */
24
36
  export const cantonDeferredAddress = (sentinel: string): CantonAddress => sentinel as CantonAddress;
25
37
 
@@ -44,4 +56,5 @@ export const toCantonAddress = (raw: string): CantonAddress => {
44
56
  export const isCantonAddress = (value: string): value is CantonAddress =>
45
57
  value.startsWith(CANTON_PARTY_ADDRESS_PREFIX) ||
46
58
  value.startsWith(CANTON_CID_ADDRESS_PREFIX) ||
47
- isCantonDeferredSentinel(value);
59
+ isCantonDeferredSentinel(value) ||
60
+ isCantonGlobalAddress(value);
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/address.ts"],"names":["CANTON_PARTY_ID_REGEX","CANTON_CONTRACT_ID_HEX_LENGTH","CANTON_PARTY_ADDRESS_PREFIX","CANTON_CID_ADDRESS_PREFIX","cantonPartyAddress","hint","fingerprint","CANTON_DEFERRED_VALUE_SUFFIX","cantonCidAddress","contractId","cantonDeferredAddress","sentinel","toCantonAddress","raw","isCantonDeferredSentinel","partyMatch","exec","bare","trim0x","length","startsWith","Error","isCantonAddress","value"],"mappings":";;;;AAKA,IAAMA,qBAAAA,GAAwB,wBAAA;AAC9B,IAAMC,6BAAAA,GAAgC,GAAA;AAE/B,IAAMC,2BAAAA,GAA8B;AACpC,IAAMC,yBAAAA,GAA4B;AAMlC,IAAMC,kBAAAA,mBAAqB,MAAA,CAAA,CAACC,IAAAA,EAAcC,WAAAA,KAC7C,CAAA,EAAGJ,2BAAAA,CAAAA,EAA8BG,IAAAA,CAAAA,EAAAA,EAASC,WAAAA,CAAAA,EAAcC,4BAAAA,CAAAA,CAAAA,EAD1B,oBAAA;AAI3B,IAAMC,gBAAAA,2BAAoBC,UAAAA,KAC7B,CAAA,EAAGN,yBAAAA,CAAAA,EAA4BM,UAAAA,CAAAA,EAAaF,4BAAAA,CAAAA,CAAAA,EADhB,kBAAA;AAIzB,IAAMG,qBAAAA,mBAAwB,MAAA,CAAA,CAACC,QAAAA,KAAoCA,QAAAA,EAArC,uBAAA;AAG9B,IAAMC,eAAAA,2BAAmBC,GAAAA,KAAAA;AAC5B,EAAA,IAAIC,wBAAAA,CAAyBD,GAAAA,CAAAA,EAAM;AAC/B,IAAA,OAAOH,sBAAsBG,GAAAA,CAAAA;AACjC,EAAA;AACA,EAAA,MAAME,UAAAA,GAAaf,qBAAAA,CAAsBgB,IAAAA,CAAKH,GAAAA,CAAAA;AAC9C,EAAA,IAAIE,UAAAA,EAAY;AACZ,IAAA,MAAM,GAAGV,IAAAA,EAAMC,WAAAA,CAAAA,GAAeS,UAAAA;AAC9B,IAAA,OAAOX,kBAAAA,CAAmBC,MAAOC,WAAAA,CAAAA;AACrC,EAAA;AACA,EAAA,MAAMW,IAAAA,GAAOC,OAAOL,GAAAA,CAAAA;AACpB,EAAA,IAAII,KAAKE,MAAAA,KAAWlB,6BAAAA,IAAiCgB,IAAAA,CAAKG,UAAAA,CAAW,IAAA,CAAA,EAAO;AACxE,IAAA,OAAOZ,iBAAiBS,IAAAA,CAAAA;AAC5B,EAAA;AACA,EAAA,MAAM,IAAII,KAAAA,CAAM,CAAA,6BAAA,EAAgCR,GAAAA,CAAAA,CAAK,CAAA;AACzD,CAAA,EAd+B,iBAAA;AAiBxB,IAAMS,eAAAA,mBAAkB,MAAA,CAAA,CAACC,KAAAA,KAC5BA,KAAAA,CAAMH,UAAAA,CAAWlB,2BAAAA,CAAAA,IACjBqB,KAAAA,CAAMH,UAAAA,CAAWjB,yBAAAA,CAAAA,IACjBW,wBAAAA,CAAyBS,KAAAA,CAAAA,EAHE,iBAAA","file":"FADZDRWB.js","sourcesContent":["import { trim0x } from '@layerzerolabs/common-encoding-utils';\nimport type { Branded } from '@layerzerolabs/typescript-utils';\n\nimport { CANTON_DEFERRED_VALUE_SUFFIX, isCantonDeferredSentinel } from './deferredValue';\n\nconst CANTON_PARTY_ID_REGEX = /^(.+)::([0-9a-fA-F]+)$/;\nconst CANTON_CONTRACT_ID_HEX_LENGTH = 138; // 69 bytes\n\nexport const CANTON_PARTY_ADDRESS_PREFIX = '<<CANTON_PARTY::';\nexport const CANTON_CID_ADDRESS_PREFIX = '<<CANTON_CID::';\n\n/** A Canton native address — a branded string with one of three sentinel-prefix forms. */\nexport type CantonAddress = Branded<string, 'CantonAddress'>;\n\n/** Construct a party `CantonAddress` from hint and fingerprint. */\nexport const cantonPartyAddress = (hint: string, fingerprint: string): CantonAddress =>\n `${CANTON_PARTY_ADDRESS_PREFIX}${hint}::${fingerprint}${CANTON_DEFERRED_VALUE_SUFFIX}` as CantonAddress;\n\n/** Construct a contract-ID `CantonAddress` from the raw 69-byte hex contract id. */\nexport const cantonCidAddress = (contractId: string): CantonAddress =>\n `${CANTON_CID_ADDRESS_PREFIX}${contractId}${CANTON_DEFERRED_VALUE_SUFFIX}` as CantonAddress;\n\n/** Wrap a deferred-ref sentinel (`<<CANTON_DEFERRED:{json}>>`) as a `CantonAddress`. */\nexport const cantonDeferredAddress = (sentinel: string): CantonAddress => sentinel as CantonAddress;\n\n/** Wrap a raw Canton ledger value (party id, contract id, or deferred sentinel) as `CantonAddress`. */\nexport const toCantonAddress = (raw: string): CantonAddress => {\n if (isCantonDeferredSentinel(raw)) {\n return cantonDeferredAddress(raw);\n }\n const partyMatch = CANTON_PARTY_ID_REGEX.exec(raw);\n if (partyMatch) {\n const [, hint, fingerprint] = partyMatch;\n return cantonPartyAddress(hint!, fingerprint!);\n }\n const bare = trim0x(raw);\n if (bare.length === CANTON_CONTRACT_ID_HEX_LENGTH && bare.startsWith('00')) {\n return cantonCidAddress(bare);\n }\n throw new Error(`Not a Canton-native address: ${raw}`);\n};\n\n/** Returns true if `value` is a valid `CantonAddress` sentinel string. */\nexport const isCantonAddress = (value: string): value is CantonAddress =>\n value.startsWith(CANTON_PARTY_ADDRESS_PREFIX) ||\n value.startsWith(CANTON_CID_ADDRESS_PREFIX) ||\n isCantonDeferredSentinel(value);\n"]}