@dynamic-labs-sdk/aleo 0.0.0 → 0.27.2
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/README.md +21 -0
- package/dist/AleoNetworkProvider.types.d.ts +8 -0
- package/dist/AleoNetworkProvider.types.d.ts.map +1 -0
- package/dist/AleoWalletAccount.types.d.ts +8 -0
- package/dist/AleoWalletAccount.types.d.ts.map +1 -0
- package/dist/AleoWalletProvider.types.d.ts +80 -0
- package/dist/AleoWalletProvider.types.d.ts.map +1 -0
- package/dist/errors/AleoFeatureUnsupportedError/AleoFeatureUnsupportedError.d.ts +16 -0
- package/dist/errors/AleoFeatureUnsupportedError/AleoFeatureUnsupportedError.d.ts.map +1 -0
- package/dist/errors/AleoFeatureUnsupportedError/index.d.ts +2 -0
- package/dist/errors/AleoFeatureUnsupportedError/index.d.ts.map +1 -0
- package/dist/errors/InvalidAleoTransactionIdError/InvalidAleoTransactionIdError.d.ts +13 -0
- package/dist/errors/InvalidAleoTransactionIdError/InvalidAleoTransactionIdError.d.ts.map +1 -0
- package/dist/errors/InvalidAleoTransactionIdError/index.d.ts +2 -0
- package/dist/errors/InvalidAleoTransactionIdError/index.d.ts.map +1 -0
- package/dist/errors/NotAleoProviderError/NotAleoProviderError.d.ts +15 -0
- package/dist/errors/NotAleoProviderError/NotAleoProviderError.d.ts.map +1 -0
- package/dist/errors/NotAleoProviderError/index.d.ts +2 -0
- package/dist/errors/NotAleoProviderError/index.d.ts.map +1 -0
- package/dist/exports/index.d.ts +13 -0
- package/dist/exports/index.d.ts.map +1 -0
- package/dist/index.cjs +211 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.esm.js +200 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/isAleoNetworkProvider/index.d.ts +2 -0
- package/dist/isAleoNetworkProvider/index.d.ts.map +1 -0
- package/dist/isAleoNetworkProvider/isAleoNetworkProvider.d.ts +11 -0
- package/dist/isAleoNetworkProvider/isAleoNetworkProvider.d.ts.map +1 -0
- package/dist/isAleoWalletAccount/index.d.ts +2 -0
- package/dist/isAleoWalletAccount/index.d.ts.map +1 -0
- package/dist/isAleoWalletAccount/isAleoWalletAccount.d.ts +11 -0
- package/dist/isAleoWalletAccount/isAleoWalletAccount.d.ts.map +1 -0
- package/dist/isAleoWalletProvider/index.d.ts +2 -0
- package/dist/isAleoWalletProvider/index.d.ts.map +1 -0
- package/dist/isAleoWalletProvider/isAleoWalletProvider.d.ts +13 -0
- package/dist/isAleoWalletProvider/isAleoWalletProvider.d.ts.map +1 -0
- package/dist/registerAleoNetworkProviderBuilder/index.d.ts +2 -0
- package/dist/registerAleoNetworkProviderBuilder/index.d.ts.map +1 -0
- package/dist/registerAleoNetworkProviderBuilder/registerAleoNetworkProviderBuilder.d.ts +17 -0
- package/dist/registerAleoNetworkProviderBuilder/registerAleoNetworkProviderBuilder.d.ts.map +1 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -0
- package/dist/utils/constants.d.ts +8 -0
- package/dist/utils/constants.d.ts.map +1 -0
- package/dist/utils/createAleoNetworkProvider/createAleoNetworkProvider.d.ts +15 -0
- package/dist/utils/createAleoNetworkProvider/createAleoNetworkProvider.d.ts.map +1 -0
- package/dist/utils/createAleoNetworkProvider/index.d.ts +2 -0
- package/dist/utils/createAleoNetworkProvider/index.d.ts.map +1 -0
- package/dist/utils/fetchAleoBalance/fetchAleoBalance.d.ts +22 -0
- package/dist/utils/fetchAleoBalance/fetchAleoBalance.d.ts.map +1 -0
- package/dist/utils/fetchAleoBalance/index.d.ts +2 -0
- package/dist/utils/fetchAleoBalance/index.d.ts.map +1 -0
- package/dist/utils/formatMicrocreditsAsCredits/formatMicrocreditsAsCredits.d.ts +13 -0
- package/dist/utils/formatMicrocreditsAsCredits/formatMicrocreditsAsCredits.d.ts.map +1 -0
- package/dist/utils/formatMicrocreditsAsCredits/index.d.ts +2 -0
- package/dist/utils/formatMicrocreditsAsCredits/index.d.ts.map +1 -0
- package/dist/utils/getAleoExplorerTxUrl/getAleoExplorerTxUrl.d.ts +26 -0
- package/dist/utils/getAleoExplorerTxUrl/getAleoExplorerTxUrl.d.ts.map +1 -0
- package/dist/utils/getAleoExplorerTxUrl/index.d.ts +2 -0
- package/dist/utils/getAleoExplorerTxUrl/index.d.ts.map +1 -0
- package/dist/utils/getNetworkByChainId/getNetworkByChainId.d.ts +22 -0
- package/dist/utils/getNetworkByChainId/getNetworkByChainId.d.ts.map +1 -0
- package/dist/utils/getNetworkByChainId/index.d.ts +2 -0
- package/dist/utils/getNetworkByChainId/index.d.ts.map +1 -0
- package/dist/utils/isAleoMainnet/index.d.ts +2 -0
- package/dist/utils/isAleoMainnet/index.d.ts.map +1 -0
- package/dist/utils/isAleoMainnet/isAleoMainnet.d.ts +12 -0
- package/dist/utils/isAleoMainnet/isAleoMainnet.d.ts.map +1 -0
- package/dist/utils/parseAleoMicrocreditsLiteral/index.d.ts +2 -0
- package/dist/utils/parseAleoMicrocreditsLiteral/index.d.ts.map +1 -0
- package/dist/utils/parseAleoMicrocreditsLiteral/parseAleoMicrocreditsLiteral.d.ts +20 -0
- package/dist/utils/parseAleoMicrocreditsLiteral/parseAleoMicrocreditsLiteral.d.ts.map +1 -0
- package/package.json +40 -1
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { assertPackageVersion } from "@dynamic-labs-sdk/assert-package-version";
|
|
2
|
+
import { BaseError } from "@dynamic-labs-sdk/client";
|
|
3
|
+
import { Network } from "@provablehq/aleo-types";
|
|
4
|
+
|
|
5
|
+
//#region package.json
|
|
6
|
+
var name = "@dynamic-labs-sdk/aleo";
|
|
7
|
+
var version = "0.27.2";
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/errors/AleoFeatureUnsupportedError/AleoFeatureUnsupportedError.ts
|
|
11
|
+
/**
|
|
12
|
+
* Thrown when an Aleo wallet does not advertise a feature the caller asked
|
|
13
|
+
* for — e.g. a wallet that lacks `aleo:decrypt` when `decrypt(...)` is
|
|
14
|
+
* invoked. Carries the feature name and the wallet display name so the
|
|
15
|
+
* UI / logs can surface which wallet was missing what.
|
|
16
|
+
*/
|
|
17
|
+
var AleoFeatureUnsupportedError = class extends BaseError {
|
|
18
|
+
featureName;
|
|
19
|
+
walletName;
|
|
20
|
+
constructor(params) {
|
|
21
|
+
super({
|
|
22
|
+
cause: null,
|
|
23
|
+
code: "aleo_feature_unsupported_error",
|
|
24
|
+
docsUrl: null,
|
|
25
|
+
name: "AleoFeatureUnsupportedError",
|
|
26
|
+
shortMessage: `${params.walletName} does not support ${params.featureName}`
|
|
27
|
+
});
|
|
28
|
+
this.featureName = params.featureName;
|
|
29
|
+
this.walletName = params.walletName;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/errors/InvalidAleoTransactionIdError/InvalidAleoTransactionIdError.ts
|
|
35
|
+
/**
|
|
36
|
+
* Thrown when an input meant to be an Aleo transaction id (`at1...`) does
|
|
37
|
+
* not match the bech32 pattern. Carries the offending value on `txId` for
|
|
38
|
+
* inclusion in error logs / UI surfaces.
|
|
39
|
+
*/
|
|
40
|
+
var InvalidAleoTransactionIdError = class extends BaseError {
|
|
41
|
+
txId;
|
|
42
|
+
constructor(params) {
|
|
43
|
+
super({
|
|
44
|
+
cause: null,
|
|
45
|
+
code: "invalid_aleo_transaction_id_error",
|
|
46
|
+
docsUrl: null,
|
|
47
|
+
name: "InvalidAleoTransactionIdError",
|
|
48
|
+
shortMessage: `Invalid Aleo transaction id: ${params.txId}`
|
|
49
|
+
});
|
|
50
|
+
this.txId = params.txId;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/errors/NotAleoProviderError/NotAleoProviderError.ts
|
|
56
|
+
/**
|
|
57
|
+
* Thrown by Aleo-specific top-level helpers (`signMessage`,
|
|
58
|
+
* `requestTransaction`, `decrypt`, `requestRecords`) when the wallet
|
|
59
|
+
* provider resolved from a wallet account is not an Aleo provider — i.e.
|
|
60
|
+
* the caller passed a wallet account from a different chain. Carries the
|
|
61
|
+
* offending provider's key on `providerKey`.
|
|
62
|
+
*/
|
|
63
|
+
var NotAleoProviderError = class extends BaseError {
|
|
64
|
+
providerKey;
|
|
65
|
+
constructor(params) {
|
|
66
|
+
super({
|
|
67
|
+
cause: null,
|
|
68
|
+
code: "not_aleo_provider_error",
|
|
69
|
+
docsUrl: null,
|
|
70
|
+
name: "NotAleoProviderError",
|
|
71
|
+
shortMessage: "Provider is not an Aleo wallet provider"
|
|
72
|
+
});
|
|
73
|
+
this.providerKey = params.providerKey;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region src/isAleoNetworkProvider/isAleoNetworkProvider.ts
|
|
79
|
+
/**
|
|
80
|
+
* Type guard narrowing a generic `NetworkProvider` to `AleoNetworkProvider`.
|
|
81
|
+
* Use this to filter the network-provider registry down to the Aleo
|
|
82
|
+
* network providers.
|
|
83
|
+
*
|
|
84
|
+
* @not-instrumented
|
|
85
|
+
*/
|
|
86
|
+
const isAleoNetworkProvider = (networkProvider) => networkProvider.chain === "ALEO";
|
|
87
|
+
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/isAleoWalletAccount/isAleoWalletAccount.ts
|
|
90
|
+
/**
|
|
91
|
+
* Type guard narrowing a generic `WalletAccount` to `AleoWalletAccount`.
|
|
92
|
+
* Use this to filter mixed-chain wallet account lists down to the Aleo
|
|
93
|
+
* accounts.
|
|
94
|
+
*
|
|
95
|
+
* @not-instrumented
|
|
96
|
+
*/
|
|
97
|
+
const isAleoWalletAccount = (walletAccount) => walletAccount.chain === "ALEO";
|
|
98
|
+
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region src/isAleoWalletProvider/isAleoWalletProvider.ts
|
|
101
|
+
/**
|
|
102
|
+
* Type guard narrowing a generic `WalletProvider` to `AleoWalletProvider`.
|
|
103
|
+
* Returns `true` when the provider's chain is `'ALEO'`. Mirrors the
|
|
104
|
+
* `is{Chain}WalletProvider` pattern used by the sibling chain packages
|
|
105
|
+
* (Tron, Sui, Aptos) — exposes the Aleo-specific methods like
|
|
106
|
+
* `requestTransaction`, `decrypt`, and `requestRecords` to the caller.
|
|
107
|
+
*
|
|
108
|
+
* @not-instrumented
|
|
109
|
+
*/
|
|
110
|
+
const isAleoWalletProvider = (provider) => {
|
|
111
|
+
return provider.chain === "ALEO";
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
//#endregion
|
|
115
|
+
//#region src/utils/constants.ts
|
|
116
|
+
/**
|
|
117
|
+
* Aleo credits are denominated in microcredits — 1 credit = 1,000,000 mc.
|
|
118
|
+
* Mirrors the SUN_PER_TRX / lamports-per-sol pattern in sibling chain packages.
|
|
119
|
+
*/
|
|
120
|
+
const MICROCREDITS_PER_CREDIT = 1e6;
|
|
121
|
+
const ALEO_MAINNET_NETWORK_ID = 0;
|
|
122
|
+
const ALEO_TESTNET_NETWORK_ID = 1;
|
|
123
|
+
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/utils/isAleoMainnet/isAleoMainnet.ts
|
|
126
|
+
/**
|
|
127
|
+
* Whether a numeric/string chain id points at the Aleo mainnet (`0`)
|
|
128
|
+
* rather than a testnet. Both numeric and string ids are accepted so
|
|
129
|
+
* callers can pass `walletAccount.activeNetworkId` (which is stringly-
|
|
130
|
+
* typed) directly. `undefined` and `null` resolve to `false` so a
|
|
131
|
+
* stale or unknown id falls back to testnet behaviour at the call
|
|
132
|
+
* site.
|
|
133
|
+
*
|
|
134
|
+
* @not-instrumented
|
|
135
|
+
*/
|
|
136
|
+
const isAleoMainnet = (networkId) => {
|
|
137
|
+
if (networkId === void 0 || networkId === null) return false;
|
|
138
|
+
if (typeof networkId === "number") return networkId === ALEO_MAINNET_NETWORK_ID;
|
|
139
|
+
return Number(networkId) === ALEO_MAINNET_NETWORK_ID;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
//#endregion
|
|
143
|
+
//#region src/utils/getAleoExplorerTxUrl/getAleoExplorerTxUrl.ts
|
|
144
|
+
/**
|
|
145
|
+
* Aleo transaction ids are bech32-encoded with the `at1` prefix and a body
|
|
146
|
+
* of lowercase alphanumerics — same character set as account addresses. We
|
|
147
|
+
* validate strictly before letting the id reach the URL, refusing `/`, `?`,
|
|
148
|
+
* `#`, `..`, etc. so a hostile id cannot produce path traversal or an open
|
|
149
|
+
* redirect when the rendered URL is opened.
|
|
150
|
+
*/
|
|
151
|
+
const ALEO_TX_ID_PATTERN = /^at1[a-z0-9]{1,62}$/;
|
|
152
|
+
/**
|
|
153
|
+
* Build the Provable explorer URL for an Aleo transaction id.
|
|
154
|
+
*
|
|
155
|
+
* Examples:
|
|
156
|
+
* getAleoExplorerTxUrl({ txId: 'at1abc...', networkId: 0 })
|
|
157
|
+
* → 'https://explorer.provable.com/transaction/at1abc...'
|
|
158
|
+
* getAleoExplorerTxUrl({ txId: 'at1abc...', networkId: 1 })
|
|
159
|
+
* → 'https://testnet.explorer.provable.com/transaction/at1abc...'
|
|
160
|
+
*
|
|
161
|
+
* @throws InvalidAleoTransactionIdError when `txId` is not a well-formed
|
|
162
|
+
* bech32 Aleo transaction id.
|
|
163
|
+
* @not-instrumented
|
|
164
|
+
*/
|
|
165
|
+
const getAleoExplorerTxUrl = ({ txId, networkId }) => {
|
|
166
|
+
if (!ALEO_TX_ID_PATTERN.test(txId)) throw new InvalidAleoTransactionIdError({ txId });
|
|
167
|
+
return `https://${isAleoMainnet(networkId) ? "" : "testnet."}explorer.provable.com/transaction/${txId}`;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
//#endregion
|
|
171
|
+
//#region src/utils/getNetworkByChainId/getNetworkByChainId.ts
|
|
172
|
+
/**
|
|
173
|
+
* Map from `@provablehq/aleo-types` Network enum to the numeric chain id used
|
|
174
|
+
* everywhere else in the SDK (`0` = mainnet, `1` = testnet).
|
|
175
|
+
*/
|
|
176
|
+
const ALEO_NETWORK_TO_ID_MAP = {
|
|
177
|
+
[Network.MAINNET]: ALEO_MAINNET_NETWORK_ID,
|
|
178
|
+
[Network.TESTNET]: ALEO_TESTNET_NETWORK_ID
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* Resolve the `@provablehq/aleo-types` Network enum value for a numeric
|
|
182
|
+
* chain id, the bridge between the SDK's chain ids and the on-chain
|
|
183
|
+
* network identifier the Aleo libraries expect.
|
|
184
|
+
*
|
|
185
|
+
* @param params.chainId The numeric chain id (`0` = mainnet, `1` = testnet).
|
|
186
|
+
* @returns The matching `Network` enum value, or `undefined` when the id is
|
|
187
|
+
* not a known Aleo network.
|
|
188
|
+
* @not-instrumented
|
|
189
|
+
*/
|
|
190
|
+
const getNetworkByChainId = ({ chainId }) => {
|
|
191
|
+
return Object.entries(ALEO_NETWORK_TO_ID_MAP).find(([, id]) => id === chainId)?.[0];
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
//#endregion
|
|
195
|
+
//#region src/exports/index.ts
|
|
196
|
+
assertPackageVersion(name, version);
|
|
197
|
+
|
|
198
|
+
//#endregion
|
|
199
|
+
export { ALEO_MAINNET_NETWORK_ID, ALEO_NETWORK_TO_ID_MAP, ALEO_TESTNET_NETWORK_ID, AleoFeatureUnsupportedError, InvalidAleoTransactionIdError, MICROCREDITS_PER_CREDIT, NotAleoProviderError, getAleoExplorerTxUrl, getNetworkByChainId, isAleoNetworkProvider, isAleoWalletAccount, isAleoWalletProvider };
|
|
200
|
+
//# sourceMappingURL=index.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","names":["ALEO_NETWORK_TO_ID_MAP: Partial<Record<Network, number>>","packageName","packageVersion"],"sources":["../package.json","../src/errors/AleoFeatureUnsupportedError/AleoFeatureUnsupportedError.ts","../src/errors/InvalidAleoTransactionIdError/InvalidAleoTransactionIdError.ts","../src/errors/NotAleoProviderError/NotAleoProviderError.ts","../src/isAleoNetworkProvider/isAleoNetworkProvider.ts","../src/isAleoWalletAccount/isAleoWalletAccount.ts","../src/isAleoWalletProvider/isAleoWalletProvider.ts","../src/utils/constants.ts","../src/utils/isAleoMainnet/isAleoMainnet.ts","../src/utils/getAleoExplorerTxUrl/getAleoExplorerTxUrl.ts","../src/utils/getNetworkByChainId/getNetworkByChainId.ts","../src/exports/index.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","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 * @not-instrumented\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 * @not-instrumented\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 * @not-instrumented\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","/**\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 { 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 * @not-instrumented\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 * Examples:\n * getAleoExplorerTxUrl({ txId: 'at1abc...', networkId: 0 })\n * → 'https://explorer.provable.com/transaction/at1abc...'\n * getAleoExplorerTxUrl({ txId: 'at1abc...', networkId: 1 })\n * → 'https://testnet.explorer.provable.com/transaction/at1abc...'\n *\n * @throws InvalidAleoTransactionIdError when `txId` is not a well-formed\n * bech32 Aleo transaction id.\n * @not-instrumented\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 { 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 * @param params.chainId The numeric chain id (`0` = mainnet, `1` = testnet).\n * @returns The matching `Network` enum value, or `undefined` when the id is\n * not a known Aleo network.\n * @not-instrumented\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","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":";;;;;;;;;;;;;;;;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;;;;;;;;;;;AChB7B,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;;;;;;;;;;;;;ACV9B,MAAa,yBACX,oBAC2C,gBAAgB,UAAU;;;;;;;;;;;ACFvE,MAAa,uBACX,kBACuC,cAAc,UAAU;;;;;;;;;;;;;ACCjE,MAAa,wBACX,aACmC;AACnC,QAAO,SAAS,UAAU;;;;;;;;;ACb5B,MAAa,0BAA0B;AAEvC,MAAa,0BAA0B;AACvC,MAAa,0BAA0B;;;;;;;;;;;;;;ACMvC,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;;;;;;;;;;;;;;AA0B3B,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;;;;;;;;;ACjClE,MAAaA,yBAA2D;EACrE,QAAQ,UAAU;EAClB,QAAQ,UAAU;CACpB;;;;;;;;;;;AAgBD,MAAa,uBAAuB,EAClC,cACoD;AAIpD,QAFE,OAAO,QAAQ,uBAAuB,CACtC,MAAM,GAAG,QAAQ,OAAO,QAAQ,GACnB;;;;;AC9BjB,qBAAqBC,MAAaC,QAAe"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/isAleoNetworkProvider/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { NetworkProvider } from '@dynamic-labs-sdk/client';
|
|
2
|
+
import type { AleoNetworkProvider } from '../AleoNetworkProvider.types';
|
|
3
|
+
/**
|
|
4
|
+
* Type guard narrowing a generic `NetworkProvider` to `AleoNetworkProvider`.
|
|
5
|
+
* Use this to filter the network-provider registry down to the Aleo
|
|
6
|
+
* network providers.
|
|
7
|
+
*
|
|
8
|
+
* @not-instrumented
|
|
9
|
+
*/
|
|
10
|
+
export declare const isAleoNetworkProvider: (networkProvider: NetworkProvider) => networkProvider is AleoNetworkProvider;
|
|
11
|
+
//# sourceMappingURL=isAleoNetworkProvider.d.ts.map
|
|
@@ -0,0 +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;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,oBACf,eAAe,KAC/B,eAAe,IAAI,mBAAuD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/isAleoWalletAccount/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { WalletAccount } from '@dynamic-labs-sdk/client';
|
|
2
|
+
import type { AleoWalletAccount } from '../AleoWalletAccount.types';
|
|
3
|
+
/**
|
|
4
|
+
* Type guard narrowing a generic `WalletAccount` to `AleoWalletAccount`.
|
|
5
|
+
* Use this to filter mixed-chain wallet account lists down to the Aleo
|
|
6
|
+
* accounts.
|
|
7
|
+
*
|
|
8
|
+
* @not-instrumented
|
|
9
|
+
*/
|
|
10
|
+
export declare const isAleoWalletAccount: (walletAccount: WalletAccount) => walletAccount is AleoWalletAccount;
|
|
11
|
+
//# sourceMappingURL=isAleoWalletAccount.d.ts.map
|
|
@@ -0,0 +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;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,kBACf,aAAa,KAC3B,aAAa,IAAI,iBAAmD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/isAleoWalletProvider/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { WalletProvider } from '@dynamic-labs-sdk/client/core';
|
|
2
|
+
import type { AleoWalletProvider } from '../AleoWalletProvider.types';
|
|
3
|
+
/**
|
|
4
|
+
* Type guard narrowing a generic `WalletProvider` to `AleoWalletProvider`.
|
|
5
|
+
* Returns `true` when the provider's chain is `'ALEO'`. Mirrors the
|
|
6
|
+
* `is{Chain}WalletProvider` pattern used by the sibling chain packages
|
|
7
|
+
* (Tron, Sui, Aptos) — exposes the Aleo-specific methods like
|
|
8
|
+
* `requestTransaction`, `decrypt`, and `requestRecords` to the caller.
|
|
9
|
+
*
|
|
10
|
+
* @not-instrumented
|
|
11
|
+
*/
|
|
12
|
+
export declare const isAleoWalletProvider: (provider: WalletProvider | AleoWalletProvider) => provider is AleoWalletProvider;
|
|
13
|
+
//# sourceMappingURL=isAleoWalletProvider.d.ts.map
|
|
@@ -0,0 +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;;;;;;;;GAQG;AAEH,eAAO,MAAM,oBAAoB,aACrB,cAAc,GAAG,kBAAkB,KAC5C,QAAQ,IAAI,kBAEd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/registerAleoNetworkProviderBuilder/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kCAAkC,EAAE,MAAM,sCAAsC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { DynamicClient } from '@dynamic-labs-sdk/client';
|
|
2
|
+
/**
|
|
3
|
+
* Register the Aleo network-provider builder on a Dynamic client.
|
|
4
|
+
*
|
|
5
|
+
* Wires `createAleoNetworkProvider` into the client's network-provider
|
|
6
|
+
* builder registry under the `'ALEO'` chain key, which is how the SDK's
|
|
7
|
+
* network machinery materializes a per-network provider on demand.
|
|
8
|
+
* Idempotent — a second call is a no-op once the builder is registered.
|
|
9
|
+
*
|
|
10
|
+
* Internal: called by the Aleo extension entry points
|
|
11
|
+
* (`addAleoWalletStandardExtension`, `addAleoWalletAdaptersExtension`,
|
|
12
|
+
* `addAleoExtension`). Not exported from the package's public surface.
|
|
13
|
+
*
|
|
14
|
+
* @not-instrumented
|
|
15
|
+
*/
|
|
16
|
+
export declare const registerAleoNetworkProviderBuilder: (client: DynamicClient) => void;
|
|
17
|
+
//# sourceMappingURL=registerAleoNetworkProviderBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registerAleoNetworkProviderBuilder.d.ts","sourceRoot":"","sources":["../../src/registerAleoNetworkProviderBuilder/registerAleoNetworkProviderBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAK9D;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,kCAAkC,WACrC,aAAa,KACpB,IAYF,CAAC"}
|