@dynamic-labs-sdk/aleo 1.18.0 → 1.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{getNetworkByChainId-DHgeu7_R.esm.js → getNetworkByChainId-CgfjwS3y.esm.js} +12 -5
- package/dist/{getNetworkByChainId-DHgeu7_R.esm.js.map → getNetworkByChainId-CgfjwS3y.esm.js.map} +1 -1
- package/dist/{getNetworkByChainId-DA9XYFLO.cjs → getNetworkByChainId-DsbZv2dw.cjs} +12 -5
- package/dist/{getNetworkByChainId-DA9XYFLO.cjs.map → getNetworkByChainId-DsbZv2dw.cjs.map} +1 -1
- package/dist/index.cjs +44 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +44 -8
- package/dist/index.esm.js.map +1 -1
- package/dist/isAleoNetworkProvider/isAleoNetworkProvider.d.ts +11 -0
- package/dist/isAleoNetworkProvider/isAleoNetworkProvider.d.ts.map +1 -1
- package/dist/isAleoWalletAccount/isAleoWalletAccount.d.ts +10 -0
- package/dist/isAleoWalletAccount/isAleoWalletAccount.d.ts.map +1 -1
- package/dist/isAleoWalletProvider/isAleoWalletProvider.d.ts +11 -0
- package/dist/isAleoWalletProvider/isAleoWalletProvider.d.ts.map +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/utils/getAleoExplorerTxUrl/getAleoExplorerTxUrl.d.ts +11 -7
- package/dist/utils/getAleoExplorerTxUrl/getAleoExplorerTxUrl.d.ts.map +1 -1
- package/dist/utils/getNetworkByChainId/getNetworkByChainId.d.ts +10 -3
- package/dist/utils/getNetworkByChainId/getNetworkByChainId.d.ts.map +1 -1
- package/dist/walletStandard.cjs +1 -1
- package/dist/walletStandard.esm.js +1 -1
- package/package.json +4 -4
|
@@ -3,7 +3,7 @@ import { Network } from "@provablehq/aleo-types";
|
|
|
3
3
|
|
|
4
4
|
//#region package.json
|
|
5
5
|
var name = "@dynamic-labs-sdk/aleo";
|
|
6
|
-
var version = "1.
|
|
6
|
+
var version = "1.19.0";
|
|
7
7
|
|
|
8
8
|
//#endregion
|
|
9
9
|
//#region src/errors/AleoFeatureUnsupportedError/AleoFeatureUnsupportedError.ts
|
|
@@ -54,9 +54,16 @@ const ALEO_NETWORK_TO_ID_MAP = {
|
|
|
54
54
|
* chain id, the bridge between the SDK's chain ids and the on-chain
|
|
55
55
|
* network identifier the Aleo libraries expect.
|
|
56
56
|
*
|
|
57
|
-
* @
|
|
58
|
-
*
|
|
59
|
-
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* const network = getNetworkByChainId({ chainId: 0 });
|
|
60
|
+
* // → Network.MAINNET
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @param params.chainId - The numeric chain id (`0` = mainnet, `1` = testnet).
|
|
64
|
+
* @returns The matching `Network` enum value, or `undefined` when the id is not a known Aleo network.
|
|
65
|
+
* @see getAleoExplorerTxUrl
|
|
66
|
+
* @see isAleoNetworkProvider
|
|
60
67
|
* @notInstrumented
|
|
61
68
|
*/
|
|
62
69
|
const getNetworkByChainId = ({ chainId }) => {
|
|
@@ -65,4 +72,4 @@ const getNetworkByChainId = ({ chainId }) => {
|
|
|
65
72
|
|
|
66
73
|
//#endregion
|
|
67
74
|
export { MICROCREDITS_PER_CREDIT as a, version as c, ALEO_TESTNET_NETWORK_ID as i, getNetworkByChainId as n, AleoFeatureUnsupportedError as o, ALEO_MAINNET_NETWORK_ID as r, name as s, ALEO_NETWORK_TO_ID_MAP as t };
|
|
68
|
-
//# sourceMappingURL=getNetworkByChainId-
|
|
75
|
+
//# sourceMappingURL=getNetworkByChainId-CgfjwS3y.esm.js.map
|
package/dist/{getNetworkByChainId-DHgeu7_R.esm.js.map → getNetworkByChainId-CgfjwS3y.esm.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getNetworkByChainId-
|
|
1
|
+
{"version":3,"file":"getNetworkByChainId-CgfjwS3y.esm.js","names":["ALEO_NETWORK_TO_ID_MAP: Partial<Record<Network, number>>"],"sources":["../package.json","../src/errors/AleoFeatureUnsupportedError/AleoFeatureUnsupportedError.ts","../src/utils/constants.ts","../src/utils/getNetworkByChainId/getNetworkByChainId.ts"],"sourcesContent":["","import { BaseError } from '@dynamic-labs-sdk/client';\n\n/**\n * Thrown when an Aleo wallet does not advertise a feature the caller asked\n * for — e.g. a wallet that lacks `aleo:decrypt` when `decrypt(...)` is\n * invoked. Carries the feature name and the wallet display name so the\n * UI / logs can surface which wallet was missing what.\n */\nexport class AleoFeatureUnsupportedError extends BaseError {\n public readonly featureName: string;\n\n public readonly walletName: string;\n\n constructor(params: { featureName: string; walletName: string }) {\n super({\n cause: null,\n code: 'aleo_feature_unsupported_error',\n docsUrl: null,\n name: 'AleoFeatureUnsupportedError',\n shortMessage: `${params.walletName} does not support ${params.featureName}`,\n });\n\n this.featureName = params.featureName;\n this.walletName = params.walletName;\n }\n}\n","/**\n * Aleo credits are denominated in microcredits — 1 credit = 1,000,000 mc.\n * Mirrors the SUN_PER_TRX / lamports-per-sol pattern in sibling chain packages.\n */\nexport const MICROCREDITS_PER_CREDIT = 1_000_000;\n\nexport const ALEO_MAINNET_NETWORK_ID = 0;\nexport const ALEO_TESTNET_NETWORK_ID = 1;\n","import { Network } from '@provablehq/aleo-types';\n\nimport {\n ALEO_MAINNET_NETWORK_ID,\n ALEO_TESTNET_NETWORK_ID,\n} from '../constants';\n\n/**\n * Map from `@provablehq/aleo-types` Network enum to the numeric chain id used\n * everywhere else in the SDK (`0` = mainnet, `1` = testnet).\n */\nexport const ALEO_NETWORK_TO_ID_MAP: Partial<Record<Network, number>> = {\n [Network.MAINNET]: ALEO_MAINNET_NETWORK_ID,\n [Network.TESTNET]: ALEO_TESTNET_NETWORK_ID,\n};\n\ntype GetNetworkByChainIdParams = {\n chainId: number;\n};\n\n/**\n * Resolve the `@provablehq/aleo-types` Network enum value for a numeric\n * chain id, the bridge between the SDK's chain ids and the on-chain\n * network identifier the Aleo libraries expect.\n *\n * @example\n * ```ts\n * const network = getNetworkByChainId({ chainId: 0 });\n * // → Network.MAINNET\n * ```\n *\n * @param params.chainId - The numeric chain id (`0` = mainnet, `1` = testnet).\n * @returns The matching `Network` enum value, or `undefined` when the id is not a known Aleo network.\n * @see getAleoExplorerTxUrl\n * @see isAleoNetworkProvider\n * @notInstrumented\n */\nexport const getNetworkByChainId = ({\n chainId,\n}: GetNetworkByChainIdParams): Network | undefined => {\n const entry = (\n Object.entries(ALEO_NETWORK_TO_ID_MAP) as [Network, number][]\n ).find(([, id]) => id === chainId);\n return entry?.[0];\n};\n"],"mappings":";;;;;;;;;;;;;;;ACQA,IAAa,8BAAb,cAAiD,UAAU;CACzD,AAAgB;CAEhB,AAAgB;CAEhB,YAAY,QAAqD;AAC/D,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SAAS;GACT,MAAM;GACN,cAAc,GAAG,OAAO,WAAW,oBAAoB,OAAO;GAC/D,CAAC;AAEF,OAAK,cAAc,OAAO;AAC1B,OAAK,aAAa,OAAO;;;;;;;;;;ACnB7B,MAAa,0BAA0B;AAEvC,MAAa,0BAA0B;AACvC,MAAa,0BAA0B;;;;;;;;ACIvC,MAAaA,yBAA2D;EACrE,QAAQ,UAAU;EAClB,QAAQ,UAAU;CACpB;;;;;;;;;;;;;;;;;;AAuBD,MAAa,uBAAuB,EAClC,cACoD;AAIpD,QAFE,OAAO,QAAQ,uBAAuB,CACtC,MAAM,GAAG,QAAQ,OAAO,QAAQ,GACnB"}
|
|
@@ -3,7 +3,7 @@ let _provablehq_aleo_types = require("@provablehq/aleo-types");
|
|
|
3
3
|
|
|
4
4
|
//#region package.json
|
|
5
5
|
var name = "@dynamic-labs-sdk/aleo";
|
|
6
|
-
var version = "1.
|
|
6
|
+
var version = "1.19.0";
|
|
7
7
|
|
|
8
8
|
//#endregion
|
|
9
9
|
//#region src/errors/AleoFeatureUnsupportedError/AleoFeatureUnsupportedError.ts
|
|
@@ -54,9 +54,16 @@ const ALEO_NETWORK_TO_ID_MAP = {
|
|
|
54
54
|
* chain id, the bridge between the SDK's chain ids and the on-chain
|
|
55
55
|
* network identifier the Aleo libraries expect.
|
|
56
56
|
*
|
|
57
|
-
* @
|
|
58
|
-
*
|
|
59
|
-
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* const network = getNetworkByChainId({ chainId: 0 });
|
|
60
|
+
* // → Network.MAINNET
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @param params.chainId - The numeric chain id (`0` = mainnet, `1` = testnet).
|
|
64
|
+
* @returns The matching `Network` enum value, or `undefined` when the id is not a known Aleo network.
|
|
65
|
+
* @see getAleoExplorerTxUrl
|
|
66
|
+
* @see isAleoNetworkProvider
|
|
60
67
|
* @notInstrumented
|
|
61
68
|
*/
|
|
62
69
|
const getNetworkByChainId = ({ chainId }) => {
|
|
@@ -112,4 +119,4 @@ Object.defineProperty(exports, 'version', {
|
|
|
112
119
|
return version;
|
|
113
120
|
}
|
|
114
121
|
});
|
|
115
|
-
//# sourceMappingURL=getNetworkByChainId-
|
|
122
|
+
//# sourceMappingURL=getNetworkByChainId-DsbZv2dw.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getNetworkByChainId-
|
|
1
|
+
{"version":3,"file":"getNetworkByChainId-DsbZv2dw.cjs","names":["BaseError","ALEO_NETWORK_TO_ID_MAP: Partial<Record<Network, number>>","Network"],"sources":["../package.json","../src/errors/AleoFeatureUnsupportedError/AleoFeatureUnsupportedError.ts","../src/utils/constants.ts","../src/utils/getNetworkByChainId/getNetworkByChainId.ts"],"sourcesContent":["","import { BaseError } from '@dynamic-labs-sdk/client';\n\n/**\n * Thrown when an Aleo wallet does not advertise a feature the caller asked\n * for — e.g. a wallet that lacks `aleo:decrypt` when `decrypt(...)` is\n * invoked. Carries the feature name and the wallet display name so the\n * UI / logs can surface which wallet was missing what.\n */\nexport class AleoFeatureUnsupportedError extends BaseError {\n public readonly featureName: string;\n\n public readonly walletName: string;\n\n constructor(params: { featureName: string; walletName: string }) {\n super({\n cause: null,\n code: 'aleo_feature_unsupported_error',\n docsUrl: null,\n name: 'AleoFeatureUnsupportedError',\n shortMessage: `${params.walletName} does not support ${params.featureName}`,\n });\n\n this.featureName = params.featureName;\n this.walletName = params.walletName;\n }\n}\n","/**\n * Aleo credits are denominated in microcredits — 1 credit = 1,000,000 mc.\n * Mirrors the SUN_PER_TRX / lamports-per-sol pattern in sibling chain packages.\n */\nexport const MICROCREDITS_PER_CREDIT = 1_000_000;\n\nexport const ALEO_MAINNET_NETWORK_ID = 0;\nexport const ALEO_TESTNET_NETWORK_ID = 1;\n","import { Network } from '@provablehq/aleo-types';\n\nimport {\n ALEO_MAINNET_NETWORK_ID,\n ALEO_TESTNET_NETWORK_ID,\n} from '../constants';\n\n/**\n * Map from `@provablehq/aleo-types` Network enum to the numeric chain id used\n * everywhere else in the SDK (`0` = mainnet, `1` = testnet).\n */\nexport const ALEO_NETWORK_TO_ID_MAP: Partial<Record<Network, number>> = {\n [Network.MAINNET]: ALEO_MAINNET_NETWORK_ID,\n [Network.TESTNET]: ALEO_TESTNET_NETWORK_ID,\n};\n\ntype GetNetworkByChainIdParams = {\n chainId: number;\n};\n\n/**\n * Resolve the `@provablehq/aleo-types` Network enum value for a numeric\n * chain id, the bridge between the SDK's chain ids and the on-chain\n * network identifier the Aleo libraries expect.\n *\n * @example\n * ```ts\n * const network = getNetworkByChainId({ chainId: 0 });\n * // → Network.MAINNET\n * ```\n *\n * @param params.chainId - The numeric chain id (`0` = mainnet, `1` = testnet).\n * @returns The matching `Network` enum value, or `undefined` when the id is not a known Aleo network.\n * @see getAleoExplorerTxUrl\n * @see isAleoNetworkProvider\n * @notInstrumented\n */\nexport const getNetworkByChainId = ({\n chainId,\n}: GetNetworkByChainIdParams): Network | undefined => {\n const entry = (\n Object.entries(ALEO_NETWORK_TO_ID_MAP) as [Network, number][]\n ).find(([, id]) => id === chainId);\n return entry?.[0];\n};\n"],"mappings":";;;;;;;;;;;;;;;ACQA,IAAa,8BAAb,cAAiDA,mCAAU;CACzD,AAAgB;CAEhB,AAAgB;CAEhB,YAAY,QAAqD;AAC/D,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SAAS;GACT,MAAM;GACN,cAAc,GAAG,OAAO,WAAW,oBAAoB,OAAO;GAC/D,CAAC;AAEF,OAAK,cAAc,OAAO;AAC1B,OAAK,aAAa,OAAO;;;;;;;;;;ACnB7B,MAAa,0BAA0B;AAEvC,MAAa,0BAA0B;AACvC,MAAa,0BAA0B;;;;;;;;ACIvC,MAAaC,yBAA2D;EACrEC,+BAAQ,UAAU;EAClBA,+BAAQ,UAAU;CACpB;;;;;;;;;;;;;;;;;;AAuBD,MAAa,uBAAuB,EAClC,cACoD;AAIpD,QAFE,OAAO,QAAQ,uBAAuB,CACtC,MAAM,GAAG,QAAQ,OAAO,QAAQ,GACnB"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_getNetworkByChainId = require('./getNetworkByChainId-
|
|
1
|
+
const require_getNetworkByChainId = require('./getNetworkByChainId-DsbZv2dw.cjs');
|
|
2
2
|
let _dynamic_labs_sdk_assert_package_version = require("@dynamic-labs-sdk/assert-package-version");
|
|
3
3
|
let _dynamic_labs_sdk_client = require("@dynamic-labs-sdk/client");
|
|
4
4
|
|
|
@@ -52,6 +52,17 @@ var NotAleoProviderError = class extends _dynamic_labs_sdk_client.BaseError {
|
|
|
52
52
|
* Use this to filter the network-provider registry down to the Aleo
|
|
53
53
|
* network providers.
|
|
54
54
|
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* if (isAleoNetworkProvider(networkProvider)) {
|
|
58
|
+
* const network = networkProvider.getNetwork();
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* @param networkProvider - The network provider to check.
|
|
63
|
+
* @returns True if the network provider is an Aleo network provider, false otherwise.
|
|
64
|
+
* @see isAleoWalletAccount
|
|
65
|
+
* @see getNetworkByChainId
|
|
55
66
|
* @notInstrumented
|
|
56
67
|
*/
|
|
57
68
|
const isAleoNetworkProvider = (networkProvider) => networkProvider.chain === "ALEO";
|
|
@@ -63,6 +74,16 @@ const isAleoNetworkProvider = (networkProvider) => networkProvider.chain === "AL
|
|
|
63
74
|
* Use this to filter mixed-chain wallet account lists down to the Aleo
|
|
64
75
|
* accounts.
|
|
65
76
|
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```ts
|
|
79
|
+
* const accounts = getWalletAccounts();
|
|
80
|
+
* const aleoAccounts = accounts.filter(isAleoWalletAccount);
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* @param walletAccount - The wallet account to check.
|
|
84
|
+
* @returns True if the wallet account is an Aleo wallet account, false otherwise.
|
|
85
|
+
* @see isAleoNetworkProvider
|
|
86
|
+
* @see isAleoWalletProvider
|
|
66
87
|
* @notInstrumented
|
|
67
88
|
*/
|
|
68
89
|
const isAleoWalletAccount = (walletAccount) => walletAccount.chain === "ALEO";
|
|
@@ -76,6 +97,17 @@ const isAleoWalletAccount = (walletAccount) => walletAccount.chain === "ALEO";
|
|
|
76
97
|
* (Tron, Sui, Aptos) — exposes the Aleo-specific methods like
|
|
77
98
|
* `requestTransaction`, `decrypt`, and `requestRecords` to the caller.
|
|
78
99
|
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```ts
|
|
102
|
+
* if (isAleoWalletProvider(provider)) {
|
|
103
|
+
* const records = await provider.requestRecords({ program: 'credits.aleo' });
|
|
104
|
+
* }
|
|
105
|
+
* ```
|
|
106
|
+
*
|
|
107
|
+
* @param provider - The wallet provider to check.
|
|
108
|
+
* @returns True if the wallet provider is an Aleo wallet provider, false otherwise.
|
|
109
|
+
* @see isAleoWalletAccount
|
|
110
|
+
* @see isAleoNetworkProvider
|
|
79
111
|
* @notInstrumented
|
|
80
112
|
*/
|
|
81
113
|
const isAleoWalletProvider = (provider) => {
|
|
@@ -113,14 +145,18 @@ const ALEO_TX_ID_PATTERN = /^at1[a-z0-9]{1,62}$/;
|
|
|
113
145
|
/**
|
|
114
146
|
* Build the Provable explorer URL for an Aleo transaction id.
|
|
115
147
|
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```ts
|
|
150
|
+
* const url = getAleoExplorerTxUrl({ txId: 'at1abc...', networkId: 0 });
|
|
151
|
+
* // → 'https://explorer.provable.com/transaction/at1abc...'
|
|
152
|
+
* ```
|
|
121
153
|
*
|
|
122
|
-
* @
|
|
123
|
-
*
|
|
154
|
+
* @param params.txId - Aleo transaction id (`at1...`).
|
|
155
|
+
* @param [params.networkId] - `0` = mainnet, `1` = testnet.
|
|
156
|
+
* @returns The Provable explorer URL for the transaction.
|
|
157
|
+
* @throws {InvalidAleoTransactionIdError} When `txId` is not a well-formed bech32 Aleo transaction id.
|
|
158
|
+
* @see getNetworkByChainId
|
|
159
|
+
* @see isAleoWalletAccount
|
|
124
160
|
* @notInstrumented
|
|
125
161
|
*/
|
|
126
162
|
const getAleoExplorerTxUrl = ({ txId, networkId }) => {
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["BaseError","BaseError","ALEO_MAINNET_NETWORK_ID","packageName","packageVersion"],"sources":["../src/errors/InvalidAleoTransactionIdError/InvalidAleoTransactionIdError.ts","../src/errors/NotAleoProviderError/NotAleoProviderError.ts","../src/isAleoNetworkProvider/isAleoNetworkProvider.ts","../src/isAleoWalletAccount/isAleoWalletAccount.ts","../src/isAleoWalletProvider/isAleoWalletProvider.ts","../src/utils/isAleoMainnet/isAleoMainnet.ts","../src/utils/getAleoExplorerTxUrl/getAleoExplorerTxUrl.ts","../src/exports/index.ts"],"sourcesContent":["import { BaseError } from '@dynamic-labs-sdk/client';\n\n/**\n * Thrown when an input meant to be an Aleo transaction id (`at1...`) does\n * not match the bech32 pattern. Carries the offending value on `txId` for\n * inclusion in error logs / UI surfaces.\n */\nexport class InvalidAleoTransactionIdError extends BaseError {\n public readonly txId: string;\n\n constructor(params: { txId: string }) {\n super({\n cause: null,\n code: 'invalid_aleo_transaction_id_error',\n docsUrl: null,\n name: 'InvalidAleoTransactionIdError',\n shortMessage: `Invalid Aleo transaction id: ${params.txId}`,\n });\n\n this.txId = params.txId;\n }\n}\n","import { BaseError } from '@dynamic-labs-sdk/client';\n\n/**\n * Thrown by Aleo-specific top-level helpers (`signMessage`,\n * `requestTransaction`, `decrypt`, `requestRecords`) when the wallet\n * provider resolved from a wallet account is not an Aleo provider — i.e.\n * the caller passed a wallet account from a different chain. Carries the\n * offending provider's key on `providerKey`.\n */\nexport class NotAleoProviderError extends BaseError {\n public readonly providerKey: string;\n\n constructor(params: { providerKey: string }) {\n super({\n cause: null,\n code: 'not_aleo_provider_error',\n docsUrl: null,\n name: 'NotAleoProviderError',\n shortMessage: 'Provider is not an Aleo wallet provider',\n });\n\n this.providerKey = params.providerKey;\n }\n}\n","import type { NetworkProvider } from '@dynamic-labs-sdk/client';\n\nimport type { AleoNetworkProvider } from '../AleoNetworkProvider.types';\n\n/**\n * Type guard narrowing a generic `NetworkProvider` to `AleoNetworkProvider`.\n * Use this to filter the network-provider registry down to the Aleo\n * network providers.\n *\n * @notInstrumented\n */\nexport const isAleoNetworkProvider = (\n networkProvider: NetworkProvider\n): networkProvider is AleoNetworkProvider => networkProvider.chain === 'ALEO';\n","import type { WalletAccount } from '@dynamic-labs-sdk/client';\n\nimport type { AleoWalletAccount } from '../AleoWalletAccount.types';\n\n/**\n * Type guard narrowing a generic `WalletAccount` to `AleoWalletAccount`.\n * Use this to filter mixed-chain wallet account lists down to the Aleo\n * accounts.\n *\n * @notInstrumented\n */\nexport const isAleoWalletAccount = (\n walletAccount: WalletAccount\n): walletAccount is AleoWalletAccount => walletAccount.chain === 'ALEO';\n","import type { WalletProvider } from '@dynamic-labs-sdk/client/core';\n\nimport type { AleoWalletProvider } from '../AleoWalletProvider.types';\n\n/**\n * Type guard narrowing a generic `WalletProvider` to `AleoWalletProvider`.\n * Returns `true` when the provider's chain is `'ALEO'`. Mirrors the\n * `is{Chain}WalletProvider` pattern used by the sibling chain packages\n * (Tron, Sui, Aptos) — exposes the Aleo-specific methods like\n * `requestTransaction`, `decrypt`, and `requestRecords` to the caller.\n *\n * @notInstrumented\n */\n// eslint-disable-next-line custom-rules/require-single-object-param -- standard type-guard signature shared with sibling chains\nexport const isAleoWalletProvider = (\n provider: WalletProvider | AleoWalletProvider\n): provider is AleoWalletProvider => {\n return provider.chain === 'ALEO';\n};\n","import { ALEO_MAINNET_NETWORK_ID } from '../constants';\n\n/**\n * Whether a numeric/string chain id points at the Aleo mainnet (`0`)\n * rather than a testnet. Both numeric and string ids are accepted so\n * callers can pass `walletAccount.activeNetworkId` (which is stringly-\n * typed) directly. `undefined` and `null` resolve to `false` so a\n * stale or unknown id falls back to testnet behaviour at the call\n * site.\n *\n * @notInstrumented\n */\n// eslint-disable-next-line custom-rules/require-single-object-param -- single primitive arg; named-arg ceremony would not improve clarity\nexport const isAleoMainnet = (\n networkId: number | string | undefined | null\n): boolean => {\n if (networkId === undefined || networkId === null) return false;\n if (typeof networkId === 'number') {\n return networkId === ALEO_MAINNET_NETWORK_ID;\n }\n return Number(networkId) === ALEO_MAINNET_NETWORK_ID;\n};\n","import { InvalidAleoTransactionIdError } from '../../errors/InvalidAleoTransactionIdError';\nimport { isAleoMainnet } from '../isAleoMainnet';\n\n/**\n * Aleo transaction ids are bech32-encoded with the `at1` prefix and a body\n * of lowercase alphanumerics — same character set as account addresses. We\n * validate strictly before letting the id reach the URL, refusing `/`, `?`,\n * `#`, `..`, etc. so a hostile id cannot produce path traversal or an open\n * redirect when the rendered URL is opened.\n */\nconst ALEO_TX_ID_PATTERN = /^at1[a-z0-9]{1,62}$/;\n\ntype GetAleoExplorerTxUrlParams = {\n /**\n * `0` = mainnet, `1` = testnet. When omitted, defaults to testnet so a\n * stale UI never accidentally links to a mainnet explorer for a testnet\n * transaction.\n */\n networkId?: number | string;\n /** Aleo transaction id (`at1...`). */\n txId: string;\n};\n\n/**\n * Build the Provable explorer URL for an Aleo transaction id.\n *\n *
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["BaseError","BaseError","ALEO_MAINNET_NETWORK_ID","packageName","packageVersion"],"sources":["../src/errors/InvalidAleoTransactionIdError/InvalidAleoTransactionIdError.ts","../src/errors/NotAleoProviderError/NotAleoProviderError.ts","../src/isAleoNetworkProvider/isAleoNetworkProvider.ts","../src/isAleoWalletAccount/isAleoWalletAccount.ts","../src/isAleoWalletProvider/isAleoWalletProvider.ts","../src/utils/isAleoMainnet/isAleoMainnet.ts","../src/utils/getAleoExplorerTxUrl/getAleoExplorerTxUrl.ts","../src/exports/index.ts"],"sourcesContent":["import { BaseError } from '@dynamic-labs-sdk/client';\n\n/**\n * Thrown when an input meant to be an Aleo transaction id (`at1...`) does\n * not match the bech32 pattern. Carries the offending value on `txId` for\n * inclusion in error logs / UI surfaces.\n */\nexport class InvalidAleoTransactionIdError extends BaseError {\n public readonly txId: string;\n\n constructor(params: { txId: string }) {\n super({\n cause: null,\n code: 'invalid_aleo_transaction_id_error',\n docsUrl: null,\n name: 'InvalidAleoTransactionIdError',\n shortMessage: `Invalid Aleo transaction id: ${params.txId}`,\n });\n\n this.txId = params.txId;\n }\n}\n","import { BaseError } from '@dynamic-labs-sdk/client';\n\n/**\n * Thrown by Aleo-specific top-level helpers (`signMessage`,\n * `requestTransaction`, `decrypt`, `requestRecords`) when the wallet\n * provider resolved from a wallet account is not an Aleo provider — i.e.\n * the caller passed a wallet account from a different chain. Carries the\n * offending provider's key on `providerKey`.\n */\nexport class NotAleoProviderError extends BaseError {\n public readonly providerKey: string;\n\n constructor(params: { providerKey: string }) {\n super({\n cause: null,\n code: 'not_aleo_provider_error',\n docsUrl: null,\n name: 'NotAleoProviderError',\n shortMessage: 'Provider is not an Aleo wallet provider',\n });\n\n this.providerKey = params.providerKey;\n }\n}\n","import type { NetworkProvider } from '@dynamic-labs-sdk/client';\n\nimport type { AleoNetworkProvider } from '../AleoNetworkProvider.types';\n\n/**\n * Type guard narrowing a generic `NetworkProvider` to `AleoNetworkProvider`.\n * Use this to filter the network-provider registry down to the Aleo\n * network providers.\n *\n * @example\n * ```ts\n * if (isAleoNetworkProvider(networkProvider)) {\n * const network = networkProvider.getNetwork();\n * }\n * ```\n *\n * @param networkProvider - The network provider to check.\n * @returns True if the network provider is an Aleo network provider, false otherwise.\n * @see isAleoWalletAccount\n * @see getNetworkByChainId\n * @notInstrumented\n */\nexport const isAleoNetworkProvider = (\n networkProvider: NetworkProvider\n): networkProvider is AleoNetworkProvider => networkProvider.chain === 'ALEO';\n","import type { WalletAccount } from '@dynamic-labs-sdk/client';\n\nimport type { AleoWalletAccount } from '../AleoWalletAccount.types';\n\n/**\n * Type guard narrowing a generic `WalletAccount` to `AleoWalletAccount`.\n * Use this to filter mixed-chain wallet account lists down to the Aleo\n * accounts.\n *\n * @example\n * ```ts\n * const accounts = getWalletAccounts();\n * const aleoAccounts = accounts.filter(isAleoWalletAccount);\n * ```\n *\n * @param walletAccount - The wallet account to check.\n * @returns True if the wallet account is an Aleo wallet account, false otherwise.\n * @see isAleoNetworkProvider\n * @see isAleoWalletProvider\n * @notInstrumented\n */\nexport const isAleoWalletAccount = (\n walletAccount: WalletAccount\n): walletAccount is AleoWalletAccount => walletAccount.chain === 'ALEO';\n","import type { WalletProvider } from '@dynamic-labs-sdk/client/core';\n\nimport type { AleoWalletProvider } from '../AleoWalletProvider.types';\n\n/**\n * Type guard narrowing a generic `WalletProvider` to `AleoWalletProvider`.\n * Returns `true` when the provider's chain is `'ALEO'`. Mirrors the\n * `is{Chain}WalletProvider` pattern used by the sibling chain packages\n * (Tron, Sui, Aptos) — exposes the Aleo-specific methods like\n * `requestTransaction`, `decrypt`, and `requestRecords` to the caller.\n *\n * @example\n * ```ts\n * if (isAleoWalletProvider(provider)) {\n * const records = await provider.requestRecords({ program: 'credits.aleo' });\n * }\n * ```\n *\n * @param provider - The wallet provider to check.\n * @returns True if the wallet provider is an Aleo wallet provider, false otherwise.\n * @see isAleoWalletAccount\n * @see isAleoNetworkProvider\n * @notInstrumented\n */\n// eslint-disable-next-line custom-rules/require-single-object-param -- standard type-guard signature shared with sibling chains\nexport const isAleoWalletProvider = (\n provider: WalletProvider | AleoWalletProvider\n): provider is AleoWalletProvider => {\n return provider.chain === 'ALEO';\n};\n","import { ALEO_MAINNET_NETWORK_ID } from '../constants';\n\n/**\n * Whether a numeric/string chain id points at the Aleo mainnet (`0`)\n * rather than a testnet. Both numeric and string ids are accepted so\n * callers can pass `walletAccount.activeNetworkId` (which is stringly-\n * typed) directly. `undefined` and `null` resolve to `false` so a\n * stale or unknown id falls back to testnet behaviour at the call\n * site.\n *\n * @notInstrumented\n */\n// eslint-disable-next-line custom-rules/require-single-object-param -- single primitive arg; named-arg ceremony would not improve clarity\nexport const isAleoMainnet = (\n networkId: number | string | undefined | null\n): boolean => {\n if (networkId === undefined || networkId === null) return false;\n if (typeof networkId === 'number') {\n return networkId === ALEO_MAINNET_NETWORK_ID;\n }\n return Number(networkId) === ALEO_MAINNET_NETWORK_ID;\n};\n","import { InvalidAleoTransactionIdError } from '../../errors/InvalidAleoTransactionIdError';\nimport { isAleoMainnet } from '../isAleoMainnet';\n\n/**\n * Aleo transaction ids are bech32-encoded with the `at1` prefix and a body\n * of lowercase alphanumerics — same character set as account addresses. We\n * validate strictly before letting the id reach the URL, refusing `/`, `?`,\n * `#`, `..`, etc. so a hostile id cannot produce path traversal or an open\n * redirect when the rendered URL is opened.\n */\nconst ALEO_TX_ID_PATTERN = /^at1[a-z0-9]{1,62}$/;\n\ntype GetAleoExplorerTxUrlParams = {\n /**\n * `0` = mainnet, `1` = testnet. When omitted, defaults to testnet so a\n * stale UI never accidentally links to a mainnet explorer for a testnet\n * transaction.\n */\n networkId?: number | string;\n /** Aleo transaction id (`at1...`). */\n txId: string;\n};\n\n/**\n * Build the Provable explorer URL for an Aleo transaction id.\n *\n * @example\n * ```ts\n * const url = getAleoExplorerTxUrl({ txId: 'at1abc...', networkId: 0 });\n * // → 'https://explorer.provable.com/transaction/at1abc...'\n * ```\n *\n * @param params.txId - Aleo transaction id (`at1...`).\n * @param [params.networkId] - `0` = mainnet, `1` = testnet.\n * @returns The Provable explorer URL for the transaction.\n * @throws {InvalidAleoTransactionIdError} When `txId` is not a well-formed bech32 Aleo transaction id.\n * @see getNetworkByChainId\n * @see isAleoWalletAccount\n * @notInstrumented\n */\nexport const getAleoExplorerTxUrl = ({\n txId,\n networkId,\n}: GetAleoExplorerTxUrlParams): string => {\n if (!ALEO_TX_ID_PATTERN.test(txId)) {\n throw new InvalidAleoTransactionIdError({ txId });\n }\n const subdomain = isAleoMainnet(networkId) ? '' : 'testnet.';\n return `https://${subdomain}explorer.provable.com/transaction/${txId}`;\n};\n","import { assertPackageVersion } from '@dynamic-labs-sdk/assert-package-version';\n\nimport {\n name as packageName,\n version as packageVersion,\n} from '../../package.json';\nassertPackageVersion(packageName, packageVersion);\n\nexport { AleoFeatureUnsupportedError } from '../errors/AleoFeatureUnsupportedError';\nexport { InvalidAleoTransactionIdError } from '../errors/InvalidAleoTransactionIdError';\nexport { NotAleoProviderError } from '../errors/NotAleoProviderError';\nexport { isAleoNetworkProvider } from '../isAleoNetworkProvider';\nexport { isAleoWalletAccount } from '../isAleoWalletAccount';\nexport { isAleoWalletProvider } from '../isAleoWalletProvider';\nexport type { AleoNetworkProvider } from '../AleoNetworkProvider.types';\nexport type { AleoWalletAccount } from '../AleoWalletAccount.types';\nexport type {\n AleoDecryptOptions,\n AleoRequestRecordsOptions,\n AleoTransaction,\n AleoTransition,\n AleoWalletProvider,\n} from '../AleoWalletProvider.types';\nexport { getAleoExplorerTxUrl } from '../utils/getAleoExplorerTxUrl';\nexport {\n ALEO_NETWORK_TO_ID_MAP,\n getNetworkByChainId,\n} from '../utils/getNetworkByChainId';\nexport {\n ALEO_MAINNET_NETWORK_ID,\n ALEO_TESTNET_NETWORK_ID,\n MICROCREDITS_PER_CREDIT,\n} from '../utils/constants';\n"],"mappings":";;;;;;;;;;AAOA,IAAa,gCAAb,cAAmDA,mCAAU;CAC3D,AAAgB;CAEhB,YAAY,QAA0B;AACpC,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SAAS;GACT,MAAM;GACN,cAAc,gCAAgC,OAAO;GACtD,CAAC;AAEF,OAAK,OAAO,OAAO;;;;;;;;;;;;;ACVvB,IAAa,uBAAb,cAA0CC,mCAAU;CAClD,AAAgB;CAEhB,YAAY,QAAiC;AAC3C,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SAAS;GACT,MAAM;GACN,cAAc;GACf,CAAC;AAEF,OAAK,cAAc,OAAO;;;;;;;;;;;;;;;;;;;;;;;;ACC9B,MAAa,yBACX,oBAC2C,gBAAgB,UAAU;;;;;;;;;;;;;;;;;;;;;ACHvE,MAAa,uBACX,kBACuC,cAAc,UAAU;;;;;;;;;;;;;;;;;;;;;;;;ACEjE,MAAa,wBACX,aACmC;AACnC,QAAO,SAAS,UAAU;;;;;;;;;;;;;;;ACf5B,MAAa,iBACX,cACY;AACZ,KAAI,cAAc,UAAa,cAAc,KAAM,QAAO;AAC1D,KAAI,OAAO,cAAc,SACvB,QAAO,cAAcC;AAEvB,QAAO,OAAO,UAAU,KAAKA;;;;;;;;;;;;ACV/B,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;AA8B3B,MAAa,wBAAwB,EACnC,MACA,gBACwC;AACxC,KAAI,CAAC,mBAAmB,KAAK,KAAK,CAChC,OAAM,IAAI,8BAA8B,EAAE,MAAM,CAAC;AAGnD,QAAO,WADW,cAAc,UAAU,GAAG,KAAK,WACtB,oCAAoC;;;;;mEC1C7CC,kCAAaC,oCAAe"}
|
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as MICROCREDITS_PER_CREDIT, c as version, i as ALEO_TESTNET_NETWORK_ID, n as getNetworkByChainId, o as AleoFeatureUnsupportedError, r as ALEO_MAINNET_NETWORK_ID, s as name, t as ALEO_NETWORK_TO_ID_MAP } from "./getNetworkByChainId-
|
|
1
|
+
import { a as MICROCREDITS_PER_CREDIT, c as version, i as ALEO_TESTNET_NETWORK_ID, n as getNetworkByChainId, o as AleoFeatureUnsupportedError, r as ALEO_MAINNET_NETWORK_ID, s as name, t as ALEO_NETWORK_TO_ID_MAP } from "./getNetworkByChainId-CgfjwS3y.esm.js";
|
|
2
2
|
import { assertPackageVersion } from "@dynamic-labs-sdk/assert-package-version";
|
|
3
3
|
import { BaseError } from "@dynamic-labs-sdk/client";
|
|
4
4
|
|
|
@@ -52,6 +52,17 @@ var NotAleoProviderError = class extends BaseError {
|
|
|
52
52
|
* Use this to filter the network-provider registry down to the Aleo
|
|
53
53
|
* network providers.
|
|
54
54
|
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* if (isAleoNetworkProvider(networkProvider)) {
|
|
58
|
+
* const network = networkProvider.getNetwork();
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* @param networkProvider - The network provider to check.
|
|
63
|
+
* @returns True if the network provider is an Aleo network provider, false otherwise.
|
|
64
|
+
* @see isAleoWalletAccount
|
|
65
|
+
* @see getNetworkByChainId
|
|
55
66
|
* @notInstrumented
|
|
56
67
|
*/
|
|
57
68
|
const isAleoNetworkProvider = (networkProvider) => networkProvider.chain === "ALEO";
|
|
@@ -63,6 +74,16 @@ const isAleoNetworkProvider = (networkProvider) => networkProvider.chain === "AL
|
|
|
63
74
|
* Use this to filter mixed-chain wallet account lists down to the Aleo
|
|
64
75
|
* accounts.
|
|
65
76
|
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```ts
|
|
79
|
+
* const accounts = getWalletAccounts();
|
|
80
|
+
* const aleoAccounts = accounts.filter(isAleoWalletAccount);
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* @param walletAccount - The wallet account to check.
|
|
84
|
+
* @returns True if the wallet account is an Aleo wallet account, false otherwise.
|
|
85
|
+
* @see isAleoNetworkProvider
|
|
86
|
+
* @see isAleoWalletProvider
|
|
66
87
|
* @notInstrumented
|
|
67
88
|
*/
|
|
68
89
|
const isAleoWalletAccount = (walletAccount) => walletAccount.chain === "ALEO";
|
|
@@ -76,6 +97,17 @@ const isAleoWalletAccount = (walletAccount) => walletAccount.chain === "ALEO";
|
|
|
76
97
|
* (Tron, Sui, Aptos) — exposes the Aleo-specific methods like
|
|
77
98
|
* `requestTransaction`, `decrypt`, and `requestRecords` to the caller.
|
|
78
99
|
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```ts
|
|
102
|
+
* if (isAleoWalletProvider(provider)) {
|
|
103
|
+
* const records = await provider.requestRecords({ program: 'credits.aleo' });
|
|
104
|
+
* }
|
|
105
|
+
* ```
|
|
106
|
+
*
|
|
107
|
+
* @param provider - The wallet provider to check.
|
|
108
|
+
* @returns True if the wallet provider is an Aleo wallet provider, false otherwise.
|
|
109
|
+
* @see isAleoWalletAccount
|
|
110
|
+
* @see isAleoNetworkProvider
|
|
79
111
|
* @notInstrumented
|
|
80
112
|
*/
|
|
81
113
|
const isAleoWalletProvider = (provider) => {
|
|
@@ -113,14 +145,18 @@ const ALEO_TX_ID_PATTERN = /^at1[a-z0-9]{1,62}$/;
|
|
|
113
145
|
/**
|
|
114
146
|
* Build the Provable explorer URL for an Aleo transaction id.
|
|
115
147
|
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```ts
|
|
150
|
+
* const url = getAleoExplorerTxUrl({ txId: 'at1abc...', networkId: 0 });
|
|
151
|
+
* // → 'https://explorer.provable.com/transaction/at1abc...'
|
|
152
|
+
* ```
|
|
121
153
|
*
|
|
122
|
-
* @
|
|
123
|
-
*
|
|
154
|
+
* @param params.txId - Aleo transaction id (`at1...`).
|
|
155
|
+
* @param [params.networkId] - `0` = mainnet, `1` = testnet.
|
|
156
|
+
* @returns The Provable explorer URL for the transaction.
|
|
157
|
+
* @throws {InvalidAleoTransactionIdError} When `txId` is not a well-formed bech32 Aleo transaction id.
|
|
158
|
+
* @see getNetworkByChainId
|
|
159
|
+
* @see isAleoWalletAccount
|
|
124
160
|
* @notInstrumented
|
|
125
161
|
*/
|
|
126
162
|
const getAleoExplorerTxUrl = ({ txId, networkId }) => {
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","names":["packageName","packageVersion"],"sources":["../src/errors/InvalidAleoTransactionIdError/InvalidAleoTransactionIdError.ts","../src/errors/NotAleoProviderError/NotAleoProviderError.ts","../src/isAleoNetworkProvider/isAleoNetworkProvider.ts","../src/isAleoWalletAccount/isAleoWalletAccount.ts","../src/isAleoWalletProvider/isAleoWalletProvider.ts","../src/utils/isAleoMainnet/isAleoMainnet.ts","../src/utils/getAleoExplorerTxUrl/getAleoExplorerTxUrl.ts","../src/exports/index.ts"],"sourcesContent":["import { BaseError } from '@dynamic-labs-sdk/client';\n\n/**\n * Thrown when an input meant to be an Aleo transaction id (`at1...`) does\n * not match the bech32 pattern. Carries the offending value on `txId` for\n * inclusion in error logs / UI surfaces.\n */\nexport class InvalidAleoTransactionIdError extends BaseError {\n public readonly txId: string;\n\n constructor(params: { txId: string }) {\n super({\n cause: null,\n code: 'invalid_aleo_transaction_id_error',\n docsUrl: null,\n name: 'InvalidAleoTransactionIdError',\n shortMessage: `Invalid Aleo transaction id: ${params.txId}`,\n });\n\n this.txId = params.txId;\n }\n}\n","import { BaseError } from '@dynamic-labs-sdk/client';\n\n/**\n * Thrown by Aleo-specific top-level helpers (`signMessage`,\n * `requestTransaction`, `decrypt`, `requestRecords`) when the wallet\n * provider resolved from a wallet account is not an Aleo provider — i.e.\n * the caller passed a wallet account from a different chain. Carries the\n * offending provider's key on `providerKey`.\n */\nexport class NotAleoProviderError extends BaseError {\n public readonly providerKey: string;\n\n constructor(params: { providerKey: string }) {\n super({\n cause: null,\n code: 'not_aleo_provider_error',\n docsUrl: null,\n name: 'NotAleoProviderError',\n shortMessage: 'Provider is not an Aleo wallet provider',\n });\n\n this.providerKey = params.providerKey;\n }\n}\n","import type { NetworkProvider } from '@dynamic-labs-sdk/client';\n\nimport type { AleoNetworkProvider } from '../AleoNetworkProvider.types';\n\n/**\n * Type guard narrowing a generic `NetworkProvider` to `AleoNetworkProvider`.\n * Use this to filter the network-provider registry down to the Aleo\n * network providers.\n *\n * @notInstrumented\n */\nexport const isAleoNetworkProvider = (\n networkProvider: NetworkProvider\n): networkProvider is AleoNetworkProvider => networkProvider.chain === 'ALEO';\n","import type { WalletAccount } from '@dynamic-labs-sdk/client';\n\nimport type { AleoWalletAccount } from '../AleoWalletAccount.types';\n\n/**\n * Type guard narrowing a generic `WalletAccount` to `AleoWalletAccount`.\n * Use this to filter mixed-chain wallet account lists down to the Aleo\n * accounts.\n *\n * @notInstrumented\n */\nexport const isAleoWalletAccount = (\n walletAccount: WalletAccount\n): walletAccount is AleoWalletAccount => walletAccount.chain === 'ALEO';\n","import type { WalletProvider } from '@dynamic-labs-sdk/client/core';\n\nimport type { AleoWalletProvider } from '../AleoWalletProvider.types';\n\n/**\n * Type guard narrowing a generic `WalletProvider` to `AleoWalletProvider`.\n * Returns `true` when the provider's chain is `'ALEO'`. Mirrors the\n * `is{Chain}WalletProvider` pattern used by the sibling chain packages\n * (Tron, Sui, Aptos) — exposes the Aleo-specific methods like\n * `requestTransaction`, `decrypt`, and `requestRecords` to the caller.\n *\n * @notInstrumented\n */\n// eslint-disable-next-line custom-rules/require-single-object-param -- standard type-guard signature shared with sibling chains\nexport const isAleoWalletProvider = (\n provider: WalletProvider | AleoWalletProvider\n): provider is AleoWalletProvider => {\n return provider.chain === 'ALEO';\n};\n","import { ALEO_MAINNET_NETWORK_ID } from '../constants';\n\n/**\n * Whether a numeric/string chain id points at the Aleo mainnet (`0`)\n * rather than a testnet. Both numeric and string ids are accepted so\n * callers can pass `walletAccount.activeNetworkId` (which is stringly-\n * typed) directly. `undefined` and `null` resolve to `false` so a\n * stale or unknown id falls back to testnet behaviour at the call\n * site.\n *\n * @notInstrumented\n */\n// eslint-disable-next-line custom-rules/require-single-object-param -- single primitive arg; named-arg ceremony would not improve clarity\nexport const isAleoMainnet = (\n networkId: number | string | undefined | null\n): boolean => {\n if (networkId === undefined || networkId === null) return false;\n if (typeof networkId === 'number') {\n return networkId === ALEO_MAINNET_NETWORK_ID;\n }\n return Number(networkId) === ALEO_MAINNET_NETWORK_ID;\n};\n","import { InvalidAleoTransactionIdError } from '../../errors/InvalidAleoTransactionIdError';\nimport { isAleoMainnet } from '../isAleoMainnet';\n\n/**\n * Aleo transaction ids are bech32-encoded with the `at1` prefix and a body\n * of lowercase alphanumerics — same character set as account addresses. We\n * validate strictly before letting the id reach the URL, refusing `/`, `?`,\n * `#`, `..`, etc. so a hostile id cannot produce path traversal or an open\n * redirect when the rendered URL is opened.\n */\nconst ALEO_TX_ID_PATTERN = /^at1[a-z0-9]{1,62}$/;\n\ntype GetAleoExplorerTxUrlParams = {\n /**\n * `0` = mainnet, `1` = testnet. When omitted, defaults to testnet so a\n * stale UI never accidentally links to a mainnet explorer for a testnet\n * transaction.\n */\n networkId?: number | string;\n /** Aleo transaction id (`at1...`). */\n txId: string;\n};\n\n/**\n * Build the Provable explorer URL for an Aleo transaction id.\n *\n *
|
|
1
|
+
{"version":3,"file":"index.esm.js","names":["packageName","packageVersion"],"sources":["../src/errors/InvalidAleoTransactionIdError/InvalidAleoTransactionIdError.ts","../src/errors/NotAleoProviderError/NotAleoProviderError.ts","../src/isAleoNetworkProvider/isAleoNetworkProvider.ts","../src/isAleoWalletAccount/isAleoWalletAccount.ts","../src/isAleoWalletProvider/isAleoWalletProvider.ts","../src/utils/isAleoMainnet/isAleoMainnet.ts","../src/utils/getAleoExplorerTxUrl/getAleoExplorerTxUrl.ts","../src/exports/index.ts"],"sourcesContent":["import { BaseError } from '@dynamic-labs-sdk/client';\n\n/**\n * Thrown when an input meant to be an Aleo transaction id (`at1...`) does\n * not match the bech32 pattern. Carries the offending value on `txId` for\n * inclusion in error logs / UI surfaces.\n */\nexport class InvalidAleoTransactionIdError extends BaseError {\n public readonly txId: string;\n\n constructor(params: { txId: string }) {\n super({\n cause: null,\n code: 'invalid_aleo_transaction_id_error',\n docsUrl: null,\n name: 'InvalidAleoTransactionIdError',\n shortMessage: `Invalid Aleo transaction id: ${params.txId}`,\n });\n\n this.txId = params.txId;\n }\n}\n","import { BaseError } from '@dynamic-labs-sdk/client';\n\n/**\n * Thrown by Aleo-specific top-level helpers (`signMessage`,\n * `requestTransaction`, `decrypt`, `requestRecords`) when the wallet\n * provider resolved from a wallet account is not an Aleo provider — i.e.\n * the caller passed a wallet account from a different chain. Carries the\n * offending provider's key on `providerKey`.\n */\nexport class NotAleoProviderError extends BaseError {\n public readonly providerKey: string;\n\n constructor(params: { providerKey: string }) {\n super({\n cause: null,\n code: 'not_aleo_provider_error',\n docsUrl: null,\n name: 'NotAleoProviderError',\n shortMessage: 'Provider is not an Aleo wallet provider',\n });\n\n this.providerKey = params.providerKey;\n }\n}\n","import type { NetworkProvider } from '@dynamic-labs-sdk/client';\n\nimport type { AleoNetworkProvider } from '../AleoNetworkProvider.types';\n\n/**\n * Type guard narrowing a generic `NetworkProvider` to `AleoNetworkProvider`.\n * Use this to filter the network-provider registry down to the Aleo\n * network providers.\n *\n * @example\n * ```ts\n * if (isAleoNetworkProvider(networkProvider)) {\n * const network = networkProvider.getNetwork();\n * }\n * ```\n *\n * @param networkProvider - The network provider to check.\n * @returns True if the network provider is an Aleo network provider, false otherwise.\n * @see isAleoWalletAccount\n * @see getNetworkByChainId\n * @notInstrumented\n */\nexport const isAleoNetworkProvider = (\n networkProvider: NetworkProvider\n): networkProvider is AleoNetworkProvider => networkProvider.chain === 'ALEO';\n","import type { WalletAccount } from '@dynamic-labs-sdk/client';\n\nimport type { AleoWalletAccount } from '../AleoWalletAccount.types';\n\n/**\n * Type guard narrowing a generic `WalletAccount` to `AleoWalletAccount`.\n * Use this to filter mixed-chain wallet account lists down to the Aleo\n * accounts.\n *\n * @example\n * ```ts\n * const accounts = getWalletAccounts();\n * const aleoAccounts = accounts.filter(isAleoWalletAccount);\n * ```\n *\n * @param walletAccount - The wallet account to check.\n * @returns True if the wallet account is an Aleo wallet account, false otherwise.\n * @see isAleoNetworkProvider\n * @see isAleoWalletProvider\n * @notInstrumented\n */\nexport const isAleoWalletAccount = (\n walletAccount: WalletAccount\n): walletAccount is AleoWalletAccount => walletAccount.chain === 'ALEO';\n","import type { WalletProvider } from '@dynamic-labs-sdk/client/core';\n\nimport type { AleoWalletProvider } from '../AleoWalletProvider.types';\n\n/**\n * Type guard narrowing a generic `WalletProvider` to `AleoWalletProvider`.\n * Returns `true` when the provider's chain is `'ALEO'`. Mirrors the\n * `is{Chain}WalletProvider` pattern used by the sibling chain packages\n * (Tron, Sui, Aptos) — exposes the Aleo-specific methods like\n * `requestTransaction`, `decrypt`, and `requestRecords` to the caller.\n *\n * @example\n * ```ts\n * if (isAleoWalletProvider(provider)) {\n * const records = await provider.requestRecords({ program: 'credits.aleo' });\n * }\n * ```\n *\n * @param provider - The wallet provider to check.\n * @returns True if the wallet provider is an Aleo wallet provider, false otherwise.\n * @see isAleoWalletAccount\n * @see isAleoNetworkProvider\n * @notInstrumented\n */\n// eslint-disable-next-line custom-rules/require-single-object-param -- standard type-guard signature shared with sibling chains\nexport const isAleoWalletProvider = (\n provider: WalletProvider | AleoWalletProvider\n): provider is AleoWalletProvider => {\n return provider.chain === 'ALEO';\n};\n","import { ALEO_MAINNET_NETWORK_ID } from '../constants';\n\n/**\n * Whether a numeric/string chain id points at the Aleo mainnet (`0`)\n * rather than a testnet. Both numeric and string ids are accepted so\n * callers can pass `walletAccount.activeNetworkId` (which is stringly-\n * typed) directly. `undefined` and `null` resolve to `false` so a\n * stale or unknown id falls back to testnet behaviour at the call\n * site.\n *\n * @notInstrumented\n */\n// eslint-disable-next-line custom-rules/require-single-object-param -- single primitive arg; named-arg ceremony would not improve clarity\nexport const isAleoMainnet = (\n networkId: number | string | undefined | null\n): boolean => {\n if (networkId === undefined || networkId === null) return false;\n if (typeof networkId === 'number') {\n return networkId === ALEO_MAINNET_NETWORK_ID;\n }\n return Number(networkId) === ALEO_MAINNET_NETWORK_ID;\n};\n","import { InvalidAleoTransactionIdError } from '../../errors/InvalidAleoTransactionIdError';\nimport { isAleoMainnet } from '../isAleoMainnet';\n\n/**\n * Aleo transaction ids are bech32-encoded with the `at1` prefix and a body\n * of lowercase alphanumerics — same character set as account addresses. We\n * validate strictly before letting the id reach the URL, refusing `/`, `?`,\n * `#`, `..`, etc. so a hostile id cannot produce path traversal or an open\n * redirect when the rendered URL is opened.\n */\nconst ALEO_TX_ID_PATTERN = /^at1[a-z0-9]{1,62}$/;\n\ntype GetAleoExplorerTxUrlParams = {\n /**\n * `0` = mainnet, `1` = testnet. When omitted, defaults to testnet so a\n * stale UI never accidentally links to a mainnet explorer for a testnet\n * transaction.\n */\n networkId?: number | string;\n /** Aleo transaction id (`at1...`). */\n txId: string;\n};\n\n/**\n * Build the Provable explorer URL for an Aleo transaction id.\n *\n * @example\n * ```ts\n * const url = getAleoExplorerTxUrl({ txId: 'at1abc...', networkId: 0 });\n * // → 'https://explorer.provable.com/transaction/at1abc...'\n * ```\n *\n * @param params.txId - Aleo transaction id (`at1...`).\n * @param [params.networkId] - `0` = mainnet, `1` = testnet.\n * @returns The Provable explorer URL for the transaction.\n * @throws {InvalidAleoTransactionIdError} When `txId` is not a well-formed bech32 Aleo transaction id.\n * @see getNetworkByChainId\n * @see isAleoWalletAccount\n * @notInstrumented\n */\nexport const getAleoExplorerTxUrl = ({\n txId,\n networkId,\n}: GetAleoExplorerTxUrlParams): string => {\n if (!ALEO_TX_ID_PATTERN.test(txId)) {\n throw new InvalidAleoTransactionIdError({ txId });\n }\n const subdomain = isAleoMainnet(networkId) ? '' : 'testnet.';\n return `https://${subdomain}explorer.provable.com/transaction/${txId}`;\n};\n","import { assertPackageVersion } from '@dynamic-labs-sdk/assert-package-version';\n\nimport {\n name as packageName,\n version as packageVersion,\n} from '../../package.json';\nassertPackageVersion(packageName, packageVersion);\n\nexport { AleoFeatureUnsupportedError } from '../errors/AleoFeatureUnsupportedError';\nexport { InvalidAleoTransactionIdError } from '../errors/InvalidAleoTransactionIdError';\nexport { NotAleoProviderError } from '../errors/NotAleoProviderError';\nexport { isAleoNetworkProvider } from '../isAleoNetworkProvider';\nexport { isAleoWalletAccount } from '../isAleoWalletAccount';\nexport { isAleoWalletProvider } from '../isAleoWalletProvider';\nexport type { AleoNetworkProvider } from '../AleoNetworkProvider.types';\nexport type { AleoWalletAccount } from '../AleoWalletAccount.types';\nexport type {\n AleoDecryptOptions,\n AleoRequestRecordsOptions,\n AleoTransaction,\n AleoTransition,\n AleoWalletProvider,\n} from '../AleoWalletProvider.types';\nexport { getAleoExplorerTxUrl } from '../utils/getAleoExplorerTxUrl';\nexport {\n ALEO_NETWORK_TO_ID_MAP,\n getNetworkByChainId,\n} from '../utils/getNetworkByChainId';\nexport {\n ALEO_MAINNET_NETWORK_ID,\n ALEO_TESTNET_NETWORK_ID,\n MICROCREDITS_PER_CREDIT,\n} from '../utils/constants';\n"],"mappings":";;;;;;;;;;AAOA,IAAa,gCAAb,cAAmD,UAAU;CAC3D,AAAgB;CAEhB,YAAY,QAA0B;AACpC,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SAAS;GACT,MAAM;GACN,cAAc,gCAAgC,OAAO;GACtD,CAAC;AAEF,OAAK,OAAO,OAAO;;;;;;;;;;;;;ACVvB,IAAa,uBAAb,cAA0C,UAAU;CAClD,AAAgB;CAEhB,YAAY,QAAiC;AAC3C,QAAM;GACJ,OAAO;GACP,MAAM;GACN,SAAS;GACT,MAAM;GACN,cAAc;GACf,CAAC;AAEF,OAAK,cAAc,OAAO;;;;;;;;;;;;;;;;;;;;;;;;ACC9B,MAAa,yBACX,oBAC2C,gBAAgB,UAAU;;;;;;;;;;;;;;;;;;;;;ACHvE,MAAa,uBACX,kBACuC,cAAc,UAAU;;;;;;;;;;;;;;;;;;;;;;;;ACEjE,MAAa,wBACX,aACmC;AACnC,QAAO,SAAS,UAAU;;;;;;;;;;;;;;;ACf5B,MAAa,iBACX,cACY;AACZ,KAAI,cAAc,UAAa,cAAc,KAAM,QAAO;AAC1D,KAAI,OAAO,cAAc,SACvB,QAAO,cAAc;AAEvB,QAAO,OAAO,UAAU,KAAK;;;;;;;;;;;;ACV/B,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;AA8B3B,MAAa,wBAAwB,EACnC,MACA,gBACwC;AACxC,KAAI,CAAC,mBAAmB,KAAK,KAAK,CAChC,OAAM,IAAI,8BAA8B,EAAE,MAAM,CAAC;AAGnD,QAAO,WADW,cAAc,UAAU,GAAG,KAAK,WACtB,oCAAoC;;;;;AC1ClE,qBAAqBA,MAAaC,QAAe"}
|
|
@@ -5,6 +5,17 @@ import type { AleoNetworkProvider } from '../AleoNetworkProvider.types';
|
|
|
5
5
|
* Use this to filter the network-provider registry down to the Aleo
|
|
6
6
|
* network providers.
|
|
7
7
|
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* if (isAleoNetworkProvider(networkProvider)) {
|
|
11
|
+
* const network = networkProvider.getNetwork();
|
|
12
|
+
* }
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @param networkProvider - The network provider to check.
|
|
16
|
+
* @returns True if the network provider is an Aleo network provider, false otherwise.
|
|
17
|
+
* @see isAleoWalletAccount
|
|
18
|
+
* @see getNetworkByChainId
|
|
8
19
|
* @notInstrumented
|
|
9
20
|
*/
|
|
10
21
|
export declare const isAleoNetworkProvider: (networkProvider: NetworkProvider) => networkProvider is AleoNetworkProvider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isAleoNetworkProvider.d.ts","sourceRoot":"","sources":["../../src/isAleoNetworkProvider/isAleoNetworkProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAEhE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAExE
|
|
1
|
+
{"version":3,"file":"isAleoNetworkProvider.d.ts","sourceRoot":"","sources":["../../src/isAleoNetworkProvider/isAleoNetworkProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAEhE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAExE;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,qBAAqB,oBACf,eAAe,KAC/B,eAAe,IAAI,mBAAuD,CAAC"}
|
|
@@ -5,6 +5,16 @@ import type { AleoWalletAccount } from '../AleoWalletAccount.types';
|
|
|
5
5
|
* Use this to filter mixed-chain wallet account lists down to the Aleo
|
|
6
6
|
* accounts.
|
|
7
7
|
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* const accounts = getWalletAccounts();
|
|
11
|
+
* const aleoAccounts = accounts.filter(isAleoWalletAccount);
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* @param walletAccount - The wallet account to check.
|
|
15
|
+
* @returns True if the wallet account is an Aleo wallet account, false otherwise.
|
|
16
|
+
* @see isAleoNetworkProvider
|
|
17
|
+
* @see isAleoWalletProvider
|
|
8
18
|
* @notInstrumented
|
|
9
19
|
*/
|
|
10
20
|
export declare const isAleoWalletAccount: (walletAccount: WalletAccount) => walletAccount is AleoWalletAccount;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isAleoWalletAccount.d.ts","sourceRoot":"","sources":["../../src/isAleoWalletAccount/isAleoWalletAccount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAEpE
|
|
1
|
+
{"version":3,"file":"isAleoWalletAccount.d.ts","sourceRoot":"","sources":["../../src/isAleoWalletAccount/isAleoWalletAccount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAEpE;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,mBAAmB,kBACf,aAAa,KAC3B,aAAa,IAAI,iBAAmD,CAAC"}
|
|
@@ -7,6 +7,17 @@ import type { AleoWalletProvider } from '../AleoWalletProvider.types';
|
|
|
7
7
|
* (Tron, Sui, Aptos) — exposes the Aleo-specific methods like
|
|
8
8
|
* `requestTransaction`, `decrypt`, and `requestRecords` to the caller.
|
|
9
9
|
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* if (isAleoWalletProvider(provider)) {
|
|
13
|
+
* const records = await provider.requestRecords({ program: 'credits.aleo' });
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @param provider - The wallet provider to check.
|
|
18
|
+
* @returns True if the wallet provider is an Aleo wallet provider, false otherwise.
|
|
19
|
+
* @see isAleoWalletAccount
|
|
20
|
+
* @see isAleoNetworkProvider
|
|
10
21
|
* @notInstrumented
|
|
11
22
|
*/
|
|
12
23
|
export declare const isAleoWalletProvider: (provider: WalletProvider | AleoWalletProvider) => provider is AleoWalletProvider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isAleoWalletProvider.d.ts","sourceRoot":"","sources":["../../src/isAleoWalletProvider/isAleoWalletProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAEpE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEtE
|
|
1
|
+
{"version":3,"file":"isAleoWalletProvider.d.ts","sourceRoot":"","sources":["../../src/isAleoWalletProvider/isAleoWalletProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAEpE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,eAAO,MAAM,oBAAoB,aACrB,cAAc,GAAG,kBAAkB,KAC5C,QAAQ,IAAI,kBAEd,CAAC"}
|