@layerzerolabs/common-canton 0.2.122 → 0.2.124
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +659 -650
- package/.turbo/turbo-test.log +45 -13
- package/dist/{333Q6X6C.js → 5TZ63V42.js} +3 -3
- package/dist/{333Q6X6C.js.map → 5TZ63V42.js.map} +1 -1
- package/dist/{JA7BSC7C.js → M3ULJ2LD.js} +3 -3
- package/dist/{JA7BSC7C.js.map → M3ULJ2LD.js.map} +1 -1
- package/dist/{VT3WUH5Q.js → QPVJEMY5.js} +4 -4
- package/dist/{VT3WUH5Q.js.map → QPVJEMY5.js.map} +1 -1
- package/dist/client/canton-client.js +2 -2
- package/dist/client/index.js +7 -7
- package/dist/index.js +11 -11
- package/dist/provider.js +8 -8
- package/dist/refresh/index.js +3 -3
- package/dist/refresh/resolve.js +2 -2
- package/package.json +10 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/provider.ts"],"names":["parseCantonChainUri","uri","url","URL","adminApiHost","searchParams","get","Error","userId","actAsParam","actAs","split","map","party","trim","filter","length","walletUrl","tokenUrl","undefined","clientId","clientSecret","process","env","CANTON_CLIENT_SECRET","scope","audience","key","delete","jsonApiUrl","toString","replace","oauth2","createCantonChainProvider","isLocal","params","tokenProvider","createTokenProvider","configuration","Configuration","basePath","accessToken","getToken","client","CantonClient","grpcClient","CantonGrpcClient","host","LocalTokenProvider","admin","ClientCredentialsTokenProvider"],"mappings":";;;;;;;;AA6DO,SAASA,oBAAoBC,GAAAA,EAAW;AAC3C,EAAA,MAAMC,GAAAA,GAAM,IAAIC,GAAAA,CAAIF,GAAAA,CAAAA;AAEpB,EAAA,MAAMG,YAAAA,GAAeF,GAAAA,CAAIG,YAAAA,CAAaC,GAAAA,CAAI,WAAA,CAAA;AAC1C,EAAA,IAAI,CAACF,YAAAA,EAAc;AACf,IAAA,MAAM,IAAIG,MAAM,kEAAA,CAA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AO3B,MAAAA,EAAQ;AAC1DS,IAAAA,SAAAA,EAAWkB,MAAAA,CAAOlB,SAAAA;AAClBmB,IAAAA;GACJ,CAAA;AAGA,EAAA,MAAMS,UAAAA,GAAa,IAAIC,gBAAAA,CAAiB;AACpCC,IAAAA,IAAAA,EAAMZ,MAAAA,CAAO/B,YAAAA;AACbgC,IAAAA;GACJ,CAAA;AAEA,EAAA,OAAO;AACHO,IAAAA,MAAAA;AACAE,IAAAA,UAAAA;AACAT,IAAAA,aAAAA;AACAnB,IAAAA,SAAAA,EAAWkB,MAAAA,CAAOlB;AACtB,GAAA;AACJ;AA9BgBgB,MAAAA,CAAAA,yBAAAA,EAAAA,2BAAAA,CAAAA;AAgChB,SAASI,mBAAAA,CAAoBF,QAA8BD,OAAAA,EAAgB;AACvE,EAAA,IAAIA,OAAAA,EAAS;AACT,IAAA,OAAO,IAAIc,kBAAAA,CAAmB;AAC1BxC,MAAAA,MAAAA,EAAQ2B,MAAAA,CAAO3B,MAAAA;AACfE,MAAAA,KAAAA,EAAOyB,MAAAA,CAAOzB,KAAAA;MACduC,KAAAA,EAAO;KACX,CAAA;AACJ,EAAA;AAGA,EAAA,IAAI,CAACd,OAAOH,MAAAA,EAAQ;AAChB,IAAA,MAAM,IAAIzB,MACN,kHAAA,CAAA;AAER,EAAA;AAEA,EAAA,OAAO,IAAI2C,8BAAAA,CAA+Bf,MAAAA,CAAOH,MAAM,CAAA;AAC3D;AAjBSK,MAAAA,CAAAA,mBAAAA,EAAAA,qBAAAA,CAAAA","file":"VT3WUH5Q.js","sourcesContent":["import {\n ClientCredentialsTokenProvider,\n type ClientCredentialsTokenProviderConfig,\n} from './auth/client-credentials-token-provider';\nimport { LocalTokenProvider } from './auth/local-token-provider';\nimport type { TokenProvider } from './auth/token-provider';\nimport { CantonClient } from './client/canton-client';\nimport { CantonGrpcClient } from './client/grpc';\nimport type { ICantonClient } from './client/interface';\nimport { Configuration } from './open-api/runtime';\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Provider Type\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * - {@link client} — JSON Ledger API (commands, queries, updates)\n * - {@link grpcClient} — gRPC Admin API (topology transactions, namespace queries)\n * - {@link tokenProvider} — Shared Bearer-token source used by both transports\n * - {@link walletUrl} — Canton Network validator wallet (scan-proxy CIP-56 endpoints)\n */\nexport type CantonChainProvider = {\n client: ICantonClient;\n grpcClient: CantonGrpcClient;\n tokenProvider: TokenProvider;\n /** Validator wallet URL for scan-proxy CIP-56 endpoints. Required. */\n walletUrl: string;\n};\n\n// ─────────────────────────────────────────────────────────────────────────────\n// URI Parsing\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport type CantonChainUriParams = {\n /** Base URL of the JSON Ledger API (e.g. \"http://localhost:5975\") */\n jsonApiUrl: string;\n /** Host:port of the gRPC Admin API (e.g. \"localhost:5076\") */\n adminApiHost: string;\n /** Ledger API user ID (default: \"participant_admin\") */\n userId: string;\n /** Parties granted `actAs` on localnet tokens (comma-separated in the URI). */\n actAs: string[];\n /** Validator wallet URL for scan-proxy CIP-56 endpoints (e.g. \"http://localhost:7201\"). Required. */\n walletUrl: string;\n /** OAuth2 client credentials config — present only for non-local environments */\n oauth2?: ClientCredentialsTokenProviderConfig;\n};\n\n/**\n * Parse a Canton chain provider URI into its constituent parts.\n *\n * URI format:\n * `<json-api-base>?admin-api=<host:port>&user-id=<id>&wallet-url=<url>[&token-url=...&client-id=...&client-secret=...&scope=...&audience=...]`\n *\n * The base URL (everything before the query string) is the JSON Ledger API endpoint.\n * Canton-specific params are extracted and removed; any remaining query params are\n * preserved on the JSON API URL.\n *\n * When `client-secret` is omitted from the URI, `CANTON_CLIENT_SECRET` is read from the\n * environment.\n */\nexport function parseCantonChainUri(uri: string): CantonChainUriParams {\n const url = new URL(uri);\n\n const adminApiHost = url.searchParams.get('admin-api');\n if (!adminApiHost) {\n throw new Error('Canton provider URI missing required \"admin-api\" query parameter');\n }\n\n const userId = url.searchParams.get('user-id') ?? 'participant_admin';\n const actAsParam = url.searchParams.get('act-as');\n const actAs =\n actAsParam\n ?.split(',')\n .map((party) => party.trim())\n .filter((party) => party.length > 0) ?? [];\n const walletUrl = url.searchParams.get('wallet-url');\n if (!walletUrl) {\n throw new Error('Canton provider URI missing required \"wallet-url\" query parameter');\n }\n const tokenUrl = url.searchParams.get('token-url') ?? undefined;\n const clientId = url.searchParams.get('client-id') ?? undefined;\n // Prefer URI param; fall back to env so secrets are not committed in provider configs.\n const clientSecret =\n url.searchParams.get('client-secret') ??\n // eslint-disable-next-line turbo/no-undeclared-env-vars -- runtime OAuth secret, not a turbo task input\n process.env.CANTON_CLIENT_SECRET ??\n undefined;\n const scope = url.searchParams.get('scope') ?? undefined;\n const audience = url.searchParams.get('audience') ?? undefined;\n\n for (const key of [\n 'admin-api',\n 'user-id',\n 'act-as',\n 'wallet-url',\n 'sequencer-url',\n 'sequencer-validators',\n 'sequencer-quorum',\n 'token-url',\n 'client-id',\n 'client-secret',\n 'scope',\n 'audience',\n ]) {\n url.searchParams.delete(key);\n }\n\n const jsonApiUrl = url.toString().replace(/\\/$/, '');\n\n const oauth2 =\n tokenUrl && clientId && clientSecret\n ? { tokenUrl, clientId, clientSecret, scope, audience }\n : undefined;\n\n return {\n jsonApiUrl,\n adminApiHost,\n userId,\n actAs,\n walletUrl,\n oauth2,\n };\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Provider Factory\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport type CreateCantonChainProviderOptions = {\n /** Raw provider URI (from provider config) */\n uri: string;\n /** When true, uses LocalTokenProvider (self-signed JWTs) instead of OAuth2 */\n isLocal: boolean;\n};\n\n/**\n * Create a {@link CantonChainProvider} from a provider URI.\n *\n * - **isLocal=true**: Uses {@link LocalTokenProvider} with admin-level access (self-signed JWTs).\n * - **isLocal=false**: Uses {@link ClientCredentialsTokenProvider} with OAuth2 client\n * credentials extracted from the URI query parameters.\n */\nexport function createCantonChainProvider({\n uri,\n isLocal,\n}: CreateCantonChainProviderOptions): CantonChainProvider {\n const params = parseCantonChainUri(uri);\n\n const tokenProvider = createTokenProvider(params, isLocal);\n\n // ── JSON Ledger API Client ──────────────────────────────────────────\n const configuration = new Configuration({\n basePath: params.jsonApiUrl,\n accessToken: () => tokenProvider.getToken(),\n });\n const client = new CantonClient(configuration, params.userId, {\n walletUrl: params.walletUrl,\n tokenProvider,\n });\n\n // ── gRPC Admin API Client ───────────────────────────────────────────\n const grpcClient = new CantonGrpcClient({\n host: params.adminApiHost,\n tokenProvider,\n });\n\n return {\n client,\n grpcClient,\n tokenProvider,\n walletUrl: params.walletUrl,\n };\n}\n\nfunction createTokenProvider(params: CantonChainUriParams, isLocal: boolean): TokenProvider {\n if (isLocal) {\n return new LocalTokenProvider({\n userId: params.userId,\n actAs: params.actAs,\n admin: true,\n });\n }\n\n // TODO(canton): add other prod auth methods (direct JWT passthrough, etc.).\n if (!params.oauth2) {\n throw new Error(\n 'Canton provider requires OAuth2 credentials (token-url, client-id, client-secret in URI or CANTON_CLIENT_SECRET)',\n );\n }\n\n return new ClientCredentialsTokenProvider(params.oauth2);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/provider.ts"],"names":["parseCantonChainUri","uri","url","URL","adminApiHost","searchParams","get","Error","userId","actAsParam","actAs","split","map","party","trim","filter","length","walletUrl","tokenUrl","undefined","clientId","clientSecret","process","env","CANTON_CLIENT_SECRET","scope","audience","key","delete","jsonApiUrl","toString","replace","oauth2","createCantonChainProvider","isLocal","params","tokenProvider","createTokenProvider","configuration","Configuration","basePath","accessToken","getToken","client","CantonClient","grpcClient","CantonGrpcClient","host","LocalTokenProvider","admin","ClientCredentialsTokenProvider"],"mappings":";;;;;;;;AA6DO,SAASA,oBAAoBC,GAAAA,EAAW;AAC3C,EAAA,MAAMC,GAAAA,GAAM,IAAIC,GAAAA,CAAIF,GAAAA,CAAAA;AAEpB,EAAA,MAAMG,YAAAA,GAAeF,GAAAA,CAAIG,YAAAA,CAAaC,GAAAA,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,EAA5B,aAAA;GACjB,CAAA;AACA,EAAA,MAAMC,MAAAA,GAAS,IAAIC,YAAAA,CAAaN,aAAAA,EAAeH,OAAO3B,MAAAA,EAAQ;AAC1DS,IAAAA,SAAAA,EAAWkB,MAAAA,CAAOlB,SAAAA;AAClBmB,IAAAA;GACJ,CAAA;AAGA,EAAA,MAAMS,UAAAA,GAAa,IAAIC,gBAAAA,CAAiB;AACpCC,IAAAA,IAAAA,EAAMZ,MAAAA,CAAO/B,YAAAA;AACbgC,IAAAA;GACJ,CAAA;AAEA,EAAA,OAAO;AACHO,IAAAA,MAAAA;AACAE,IAAAA,UAAAA;AACAT,IAAAA,aAAAA;AACAnB,IAAAA,SAAAA,EAAWkB,MAAAA,CAAOlB;AACtB,GAAA;AACJ;AA9BgBgB,MAAAA,CAAAA,yBAAAA,EAAAA,2BAAAA,CAAAA;AAgChB,SAASI,mBAAAA,CAAoBF,QAA8BD,OAAAA,EAAgB;AACvE,EAAA,IAAIA,OAAAA,EAAS;AACT,IAAA,OAAO,IAAIc,kBAAAA,CAAmB;AAC1BxC,MAAAA,MAAAA,EAAQ2B,MAAAA,CAAO3B,MAAAA;AACfE,MAAAA,KAAAA,EAAOyB,MAAAA,CAAOzB,KAAAA;MACduC,KAAAA,EAAO;KACX,CAAA;AACJ,EAAA;AAGA,EAAA,IAAI,CAACd,OAAOH,MAAAA,EAAQ;AAChB,IAAA,MAAM,IAAIzB,MACN,kHAAA,CAAA;AAER,EAAA;AAEA,EAAA,OAAO,IAAI2C,8BAAAA,CAA+Bf,MAAAA,CAAOH,MAAM,CAAA;AAC3D;AAjBSK,MAAAA,CAAAA,mBAAAA,EAAAA,qBAAAA,CAAAA","file":"QPVJEMY5.js","sourcesContent":["import {\n ClientCredentialsTokenProvider,\n type ClientCredentialsTokenProviderConfig,\n} from './auth/client-credentials-token-provider';\nimport { LocalTokenProvider } from './auth/local-token-provider';\nimport type { TokenProvider } from './auth/token-provider';\nimport { CantonClient } from './client/canton-client';\nimport { CantonGrpcClient } from './client/grpc';\nimport type { ICantonClient } from './client/interface';\nimport { Configuration } from './open-api/runtime';\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Provider Type\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * - {@link client} — JSON Ledger API (commands, queries, updates)\n * - {@link grpcClient} — gRPC Admin API (topology transactions, namespace queries)\n * - {@link tokenProvider} — Shared Bearer-token source used by both transports\n * - {@link walletUrl} — Canton Network validator wallet (scan-proxy CIP-56 endpoints)\n */\nexport type CantonChainProvider = {\n client: ICantonClient;\n grpcClient: CantonGrpcClient;\n tokenProvider: TokenProvider;\n /** Validator wallet URL for scan-proxy CIP-56 endpoints. Required. */\n walletUrl: string;\n};\n\n// ─────────────────────────────────────────────────────────────────────────────\n// URI Parsing\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport type CantonChainUriParams = {\n /** Base URL of the JSON Ledger API (e.g. \"http://localhost:5975\") */\n jsonApiUrl: string;\n /** Host:port of the gRPC Admin API (e.g. \"localhost:5076\") */\n adminApiHost: string;\n /** Ledger API user ID (default: \"participant_admin\") */\n userId: string;\n /** Parties granted `actAs` on localnet tokens (comma-separated in the URI). */\n actAs: string[];\n /** Validator wallet URL for scan-proxy CIP-56 endpoints (e.g. \"http://localhost:7201\"). Required. */\n walletUrl: string;\n /** OAuth2 client credentials config — present only for non-local environments */\n oauth2?: ClientCredentialsTokenProviderConfig;\n};\n\n/**\n * Parse a Canton chain provider URI into its constituent parts.\n *\n * URI format:\n * `<json-api-base>?admin-api=<host:port>&user-id=<id>&wallet-url=<url>[&token-url=...&client-id=...&client-secret=...&scope=...&audience=...]`\n *\n * The base URL (everything before the query string) is the JSON Ledger API endpoint.\n * Canton-specific params are extracted and removed; any remaining query params are\n * preserved on the JSON API URL.\n *\n * When `client-secret` is omitted from the URI, `CANTON_CLIENT_SECRET` is read from the\n * environment.\n */\nexport function parseCantonChainUri(uri: string): CantonChainUriParams {\n const url = new URL(uri);\n\n const adminApiHost = url.searchParams.get('admin-api');\n if (!adminApiHost) {\n throw new Error('Canton provider URI missing required \"admin-api\" query parameter');\n }\n\n const userId = url.searchParams.get('user-id') ?? 'participant_admin';\n const actAsParam = url.searchParams.get('act-as');\n const actAs =\n actAsParam\n ?.split(',')\n .map((party) => party.trim())\n .filter((party) => party.length > 0) ?? [];\n const walletUrl = url.searchParams.get('wallet-url');\n if (!walletUrl) {\n throw new Error('Canton provider URI missing required \"wallet-url\" query parameter');\n }\n const tokenUrl = url.searchParams.get('token-url') ?? undefined;\n const clientId = url.searchParams.get('client-id') ?? undefined;\n // Prefer URI param; fall back to env so secrets are not committed in provider configs.\n const clientSecret =\n url.searchParams.get('client-secret') ??\n // eslint-disable-next-line turbo/no-undeclared-env-vars -- runtime OAuth secret, not a turbo task input\n process.env.CANTON_CLIENT_SECRET ??\n undefined;\n const scope = url.searchParams.get('scope') ?? undefined;\n const audience = url.searchParams.get('audience') ?? undefined;\n\n for (const key of [\n 'admin-api',\n 'user-id',\n 'act-as',\n 'wallet-url',\n 'sequencer-url',\n 'sequencer-validators',\n 'sequencer-quorum',\n 'token-url',\n 'client-id',\n 'client-secret',\n 'scope',\n 'audience',\n ]) {\n url.searchParams.delete(key);\n }\n\n const jsonApiUrl = url.toString().replace(/\\/$/, '');\n\n const oauth2 =\n tokenUrl && clientId && clientSecret\n ? { tokenUrl, clientId, clientSecret, scope, audience }\n : undefined;\n\n return {\n jsonApiUrl,\n adminApiHost,\n userId,\n actAs,\n walletUrl,\n oauth2,\n };\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Provider Factory\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport type CreateCantonChainProviderOptions = {\n /** Raw provider URI (from provider config) */\n uri: string;\n /** When true, uses LocalTokenProvider (self-signed JWTs) instead of OAuth2 */\n isLocal: boolean;\n};\n\n/**\n * Create a {@link CantonChainProvider} from a provider URI.\n *\n * - **isLocal=true**: Uses {@link LocalTokenProvider} with admin-level access (self-signed JWTs).\n * - **isLocal=false**: Uses {@link ClientCredentialsTokenProvider} with OAuth2 client\n * credentials extracted from the URI query parameters.\n */\nexport function createCantonChainProvider({\n uri,\n isLocal,\n}: CreateCantonChainProviderOptions): CantonChainProvider {\n const params = parseCantonChainUri(uri);\n\n const tokenProvider = createTokenProvider(params, isLocal);\n\n // ── JSON Ledger API Client ──────────────────────────────────────────\n const configuration = new Configuration({\n basePath: params.jsonApiUrl,\n accessToken: () => tokenProvider.getToken(),\n });\n const client = new CantonClient(configuration, params.userId, {\n walletUrl: params.walletUrl,\n tokenProvider,\n });\n\n // ── gRPC Admin API Client ───────────────────────────────────────────\n const grpcClient = new CantonGrpcClient({\n host: params.adminApiHost,\n tokenProvider,\n });\n\n return {\n client,\n grpcClient,\n tokenProvider,\n walletUrl: params.walletUrl,\n };\n}\n\nfunction createTokenProvider(params: CantonChainUriParams, isLocal: boolean): TokenProvider {\n if (isLocal) {\n return new LocalTokenProvider({\n userId: params.userId,\n actAs: params.actAs,\n admin: true,\n });\n }\n\n // TODO(canton): add other prod auth methods (direct JWT passthrough, etc.).\n if (!params.oauth2) {\n throw new Error(\n 'Canton provider requires OAuth2 credentials (token-url, client-id, client-secret in URI or CANTON_CLIENT_SECRET)',\n );\n }\n\n return new ClientCredentialsTokenProvider(params.oauth2);\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { CantonClient } from '../
|
|
1
|
+
export { CantonClient } from '../M3ULJ2LD.js';
|
|
2
|
+
import '../4G6A7TFX.js';
|
|
2
3
|
import '../TZTIULG5.js';
|
|
3
4
|
import '../6CPYXAOF.js';
|
|
4
5
|
import '../Q3CWBD5A.js';
|
|
@@ -283,7 +284,6 @@ import '../TVDUWBAO.js';
|
|
|
283
284
|
import '../Q7CJWR7Y.js';
|
|
284
285
|
import '../V6427LHF.js';
|
|
285
286
|
import '../KBNUN3MF.js';
|
|
286
|
-
import '../4G6A7TFX.js';
|
|
287
287
|
import '../A7Z5O57E.js';
|
|
288
288
|
import '../VUOMXK5T.js';
|
|
289
289
|
//# sourceMappingURL=canton-client.js.map
|
package/dist/client/index.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import '../7JX6NIYS.js';
|
|
2
2
|
export { buildMultiTransactionSignatures, buildSignedTransaction } from '../WKC6X2E3.js';
|
|
3
3
|
import '../IIWYAFUO.js';
|
|
4
|
-
export { CantonClient } from '../
|
|
4
|
+
export { CantonClient } from '../M3ULJ2LD.js';
|
|
5
|
+
export { AMULET_INSTRUMENT_ID, fetchAmuletContext, fetchDsoParty, injectExternalPartyAmuletRules } from '../4G6A7TFX.js';
|
|
6
|
+
export { CantonGrpcClient } from '../NRSV2VHQ.js';
|
|
7
|
+
import '../RVQWP4JU.js';
|
|
8
|
+
import '../CXQSVBVW.js';
|
|
9
|
+
export { computeDecentralizedNamespace, computeMultiTransactionHash } from '../QAKOQQ7E.js';
|
|
10
|
+
export { cantonMultihash, computeCantonFingerprint, computePublicKeyFingerprint, extractTransactions } from '../WLV6EHDB.js';
|
|
5
11
|
import '../TZTIULG5.js';
|
|
6
12
|
import '../6CPYXAOF.js';
|
|
7
13
|
import '../Q3CWBD5A.js';
|
|
@@ -286,12 +292,6 @@ import '../TVDUWBAO.js';
|
|
|
286
292
|
import '../Q7CJWR7Y.js';
|
|
287
293
|
import '../V6427LHF.js';
|
|
288
294
|
import '../KBNUN3MF.js';
|
|
289
|
-
export { AMULET_INSTRUMENT_ID, fetchAmuletContext, fetchDsoParty, injectExternalPartyAmuletRules } from '../4G6A7TFX.js';
|
|
290
|
-
export { CantonGrpcClient } from '../NRSV2VHQ.js';
|
|
291
|
-
import '../RVQWP4JU.js';
|
|
292
|
-
import '../CXQSVBVW.js';
|
|
293
|
-
export { computeDecentralizedNamespace, computeMultiTransactionHash } from '../QAKOQQ7E.js';
|
|
294
|
-
export { cantonMultihash, computeCantonFingerprint, computePublicKeyFingerprint, extractTransactions } from '../WLV6EHDB.js';
|
|
295
295
|
import '../CMDFOA7C.js';
|
|
296
296
|
import '../A7Z5O57E.js';
|
|
297
297
|
import '../VUOMXK5T.js';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import './AQJMQQ4W.js';
|
|
2
|
-
export {
|
|
2
|
+
export { buildCantonDeployedContractAddressRef, qualifiedTemplateName } from './I6Z5XG3N.js';
|
|
3
|
+
export { resolveCantonTransaction } from './5TZ63V42.js';
|
|
4
|
+
export { createContractAddressResolver, isRefAlive, matchesContractStateFilter, queryLiveContractIdsForRef, queryLiveContractsForRef } from './QRFMJ32P.js';
|
|
3
5
|
export { wrapLzSdk } from './RJSKBZMO.js';
|
|
4
6
|
export { substituteCidsToRefs, substituteRefsToCids } from './57KDDFEU.js';
|
|
5
7
|
import './5GUYLHA7.js';
|
|
@@ -7,11 +9,15 @@ export { CantonSdk } from './SLTAV2JF.js';
|
|
|
7
9
|
import './7JX6NIYS.js';
|
|
8
10
|
export { buildMultiTransactionSignatures, buildSignedTransaction } from './WKC6X2E3.js';
|
|
9
11
|
import './IIWYAFUO.js';
|
|
10
|
-
export { createContractAddressResolver, isRefAlive, matchesContractStateFilter, queryLiveContractIdsForRef, queryLiveContractsForRef } from './QRFMJ32P.js';
|
|
11
|
-
export { buildCantonDeployedContractAddressRef, qualifiedTemplateName } from './I6Z5XG3N.js';
|
|
12
12
|
export { parseMinFeeValue } from './M3GPMXME.js';
|
|
13
|
-
export { createCantonChainProvider, parseCantonChainUri } from './
|
|
14
|
-
export { CantonClient } from './
|
|
13
|
+
export { createCantonChainProvider, parseCantonChainUri } from './QPVJEMY5.js';
|
|
14
|
+
export { CantonClient } from './M3ULJ2LD.js';
|
|
15
|
+
export { AMULET_INSTRUMENT_ID, fetchAmuletContext, fetchDsoParty, injectExternalPartyAmuletRules } from './4G6A7TFX.js';
|
|
16
|
+
export { CantonGrpcClient } from './NRSV2VHQ.js';
|
|
17
|
+
import './RVQWP4JU.js';
|
|
18
|
+
import './CXQSVBVW.js';
|
|
19
|
+
export { computeDecentralizedNamespace, computeMultiTransactionHash } from './QAKOQQ7E.js';
|
|
20
|
+
export { cantonMultihash, computeCantonFingerprint, computePublicKeyFingerprint, extractTransactions } from './WLV6EHDB.js';
|
|
15
21
|
import './TZTIULG5.js';
|
|
16
22
|
import './6CPYXAOF.js';
|
|
17
23
|
import './Q3CWBD5A.js';
|
|
@@ -296,12 +302,6 @@ import './TVDUWBAO.js';
|
|
|
296
302
|
import './Q7CJWR7Y.js';
|
|
297
303
|
import './V6427LHF.js';
|
|
298
304
|
export { Configuration, ResponseError } from './KBNUN3MF.js';
|
|
299
|
-
export { AMULET_INSTRUMENT_ID, fetchAmuletContext, fetchDsoParty, injectExternalPartyAmuletRules } from './4G6A7TFX.js';
|
|
300
|
-
export { CantonGrpcClient } from './NRSV2VHQ.js';
|
|
301
|
-
import './RVQWP4JU.js';
|
|
302
|
-
import './CXQSVBVW.js';
|
|
303
|
-
export { computeDecentralizedNamespace, computeMultiTransactionHash } from './QAKOQQ7E.js';
|
|
304
|
-
export { cantonMultihash, computeCantonFingerprint, computePublicKeyFingerprint, extractTransactions } from './WLV6EHDB.js';
|
|
305
305
|
export { CommandStatus, IntLikeSchema, buildTemplateId, canonicalizeDamlDecimal, smallestUnitsToDamlDecimal } from './4WZTQJXP.js';
|
|
306
306
|
import './35ELVFTS.js';
|
|
307
307
|
export { ClientCredentialsTokenProvider } from './V2H2WXKE.js';
|
package/dist/provider.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
export { createCantonChainProvider, parseCantonChainUri } from './
|
|
2
|
-
import './
|
|
1
|
+
export { createCantonChainProvider, parseCantonChainUri } from './QPVJEMY5.js';
|
|
2
|
+
import './M3ULJ2LD.js';
|
|
3
|
+
import './4G6A7TFX.js';
|
|
4
|
+
import './NRSV2VHQ.js';
|
|
5
|
+
import './RVQWP4JU.js';
|
|
6
|
+
import './CXQSVBVW.js';
|
|
7
|
+
import './QAKOQQ7E.js';
|
|
8
|
+
import './WLV6EHDB.js';
|
|
3
9
|
import './TZTIULG5.js';
|
|
4
10
|
import './6CPYXAOF.js';
|
|
5
11
|
import './Q3CWBD5A.js';
|
|
@@ -284,12 +290,6 @@ import './TVDUWBAO.js';
|
|
|
284
290
|
import './Q7CJWR7Y.js';
|
|
285
291
|
import './V6427LHF.js';
|
|
286
292
|
import './KBNUN3MF.js';
|
|
287
|
-
import './4G6A7TFX.js';
|
|
288
|
-
import './NRSV2VHQ.js';
|
|
289
|
-
import './RVQWP4JU.js';
|
|
290
|
-
import './CXQSVBVW.js';
|
|
291
|
-
import './QAKOQQ7E.js';
|
|
292
|
-
import './WLV6EHDB.js';
|
|
293
293
|
import './V2H2WXKE.js';
|
|
294
294
|
import './SCEF7TLZ.js';
|
|
295
295
|
import './CMDFOA7C.js';
|
package/dist/refresh/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import '../AQJMQQ4W.js';
|
|
2
|
-
export {
|
|
2
|
+
export { buildCantonDeployedContractAddressRef, qualifiedTemplateName } from '../I6Z5XG3N.js';
|
|
3
|
+
export { resolveCantonTransaction } from '../5TZ63V42.js';
|
|
4
|
+
export { createContractAddressResolver, isRefAlive, matchesContractStateFilter, queryLiveContractIdsForRef, queryLiveContractsForRef } from '../QRFMJ32P.js';
|
|
3
5
|
export { wrapLzSdk } from '../RJSKBZMO.js';
|
|
4
6
|
export { substituteCidsToRefs, substituteRefsToCids } from '../57KDDFEU.js';
|
|
5
|
-
export { createContractAddressResolver, isRefAlive, matchesContractStateFilter, queryLiveContractIdsForRef, queryLiveContractsForRef } from '../QRFMJ32P.js';
|
|
6
|
-
export { buildCantonDeployedContractAddressRef, qualifiedTemplateName } from '../I6Z5XG3N.js';
|
|
7
7
|
import '../4G6A7TFX.js';
|
|
8
8
|
import '../Z35TKEFU.js';
|
|
9
9
|
import '../A7Z5O57E.js';
|
package/dist/refresh/resolve.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { resolveCantonTransaction } from '../
|
|
2
|
-
import '../57KDDFEU.js';
|
|
1
|
+
export { resolveCantonTransaction } from '../5TZ63V42.js';
|
|
3
2
|
import '../QRFMJ32P.js';
|
|
3
|
+
import '../57KDDFEU.js';
|
|
4
4
|
import '../4G6A7TFX.js';
|
|
5
5
|
import '../Z35TKEFU.js';
|
|
6
6
|
import '../A7Z5O57E.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@layerzerolabs/common-canton",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.124",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Canton VM client and utilities",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"@protobuf-ts/runtime-rpc": "^2.11.1",
|
|
33
33
|
"es-toolkit": "^1.39.10",
|
|
34
34
|
"zod": "4.3.5",
|
|
35
|
-
"@layerzerolabs/common-
|
|
36
|
-
"@layerzerolabs/common-
|
|
37
|
-
"@layerzerolabs/common-error-utils": "0.2.
|
|
38
|
-
"@layerzerolabs/typescript-utils": "0.2.
|
|
35
|
+
"@layerzerolabs/common-chain-model": "0.2.124",
|
|
36
|
+
"@layerzerolabs/common-encoding-utils": "0.2.124",
|
|
37
|
+
"@layerzerolabs/common-error-utils": "0.2.124",
|
|
38
|
+
"@layerzerolabs/typescript-utils": "0.2.124"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/node": "^22.18.6",
|
|
@@ -44,11 +44,11 @@
|
|
|
44
44
|
"tsup": "^8.4.0",
|
|
45
45
|
"typescript": "^5.8.2",
|
|
46
46
|
"vitest": "^3.2.6",
|
|
47
|
-
"@layerzerolabs/eslint-configuration": "^0.2.
|
|
48
|
-
"@layerzerolabs/tsup-configuration": "0.2.
|
|
49
|
-
"@layerzerolabs/
|
|
50
|
-
"@layerzerolabs/vitest-configuration": "0.2.
|
|
51
|
-
"@layerzerolabs/
|
|
47
|
+
"@layerzerolabs/eslint-configuration": "^0.2.124",
|
|
48
|
+
"@layerzerolabs/tsup-configuration": "0.2.124",
|
|
49
|
+
"@layerzerolabs/typescript-configuration": "0.2.124",
|
|
50
|
+
"@layerzerolabs/vitest-configuration": "0.2.124",
|
|
51
|
+
"@layerzerolabs/vm-tooling-canton": "0.2.124"
|
|
52
52
|
},
|
|
53
53
|
"publishConfig": {
|
|
54
54
|
"access": "public",
|