@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
package/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# @dynamic-labs-sdk/aleo
|
|
2
|
+
|
|
3
|
+
This package contains the Aleo integration for the Dynamic SDK. It enables support for Aleo external wallets via the [Aleo Wallet Standard](https://github.com/ProvableHQ/aleo-wallet-standard) and adapter-based wallets (e.g. Shield).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
pnpm add @dynamic-labs-sdk/aleo
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { addAleoExtension } from '@dynamic-labs-sdk/aleo';
|
|
15
|
+
import { createDynamicClient } from '@dynamic-labs-sdk/client';
|
|
16
|
+
|
|
17
|
+
const dynamicClient = createDynamicClient({
|
|
18
|
+
environmentId: '123',
|
|
19
|
+
});
|
|
20
|
+
addAleoExtension(dynamicClient);
|
|
21
|
+
```
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { BaseNetworkProvider } from '@dynamic-labs-sdk/client/core';
|
|
2
|
+
export type AleoNetworkProvider = BaseNetworkProvider<'ALEO'>;
|
|
3
|
+
declare global {
|
|
4
|
+
interface NetworkProviderMap {
|
|
5
|
+
ALEO: AleoNetworkProvider;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=AleoNetworkProvider.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AleoNetworkProvider.types.d.ts","sourceRoot":"","sources":["../src/AleoNetworkProvider.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAEzE,MAAM,MAAM,mBAAmB,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC;AAE9D,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,kBAAkB;QAC1B,IAAI,EAAE,mBAAmB,CAAC;KAC3B;CACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { BaseWalletAccount } from '@dynamic-labs-sdk/client/core';
|
|
2
|
+
export type AleoWalletAccount = BaseWalletAccount<'ALEO'>;
|
|
3
|
+
declare global {
|
|
4
|
+
interface WalletAccountMap {
|
|
5
|
+
ALEO: AleoWalletAccount;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=AleoWalletAccount.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AleoWalletAccount.types.d.ts","sourceRoot":"","sources":["../src/AleoWalletAccount.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAEvE,MAAM,MAAM,iBAAiB,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;AAE1D,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,gBAAgB;QACxB,IAAI,EAAE,iBAAiB,CAAC;KACzB;CACF"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Aleo wallet provider specific types
|
|
3
|
+
*/
|
|
4
|
+
import type { WalletProvider } from '@dynamic-labs-sdk/client/core';
|
|
5
|
+
import type { AleoWalletAccount } from './AleoWalletAccount.types';
|
|
6
|
+
/**
|
|
7
|
+
* A transition is a single function execution within an Aleo transaction —
|
|
8
|
+
* one program invocation with its inputs.
|
|
9
|
+
*/
|
|
10
|
+
export type AleoTransition = {
|
|
11
|
+
functionName: string;
|
|
12
|
+
inputs: unknown[];
|
|
13
|
+
program: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* An Aleo transaction is a bundle of transitions submitted together with a
|
|
17
|
+
* single fee. `feePrivate` selects between the private and public fee paths.
|
|
18
|
+
*/
|
|
19
|
+
export type AleoTransaction = {
|
|
20
|
+
address: string;
|
|
21
|
+
chainId: string;
|
|
22
|
+
fee: number;
|
|
23
|
+
feePrivate: boolean;
|
|
24
|
+
transitions: AleoTransition[];
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Options passed to `decrypt` when the wallet should decrypt a ciphertext
|
|
28
|
+
* that originated from a transition output (`tpk` + program/function/index
|
|
29
|
+
* are needed to derive the decryption key for that record position).
|
|
30
|
+
*/
|
|
31
|
+
export type AleoDecryptOptions = {
|
|
32
|
+
functionName?: string;
|
|
33
|
+
index?: number;
|
|
34
|
+
programId?: string;
|
|
35
|
+
tpk?: string;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Options for `requestRecords`. `plaintext` controls whether the wallet
|
|
39
|
+
* should return the raw plaintext records (when supported) or the encrypted
|
|
40
|
+
* record ciphertexts.
|
|
41
|
+
*/
|
|
42
|
+
export type AleoRequestRecordsOptions = {
|
|
43
|
+
plaintext?: boolean;
|
|
44
|
+
};
|
|
45
|
+
export type AleoWalletProvider = WalletProvider & {
|
|
46
|
+
chain: 'ALEO';
|
|
47
|
+
/**
|
|
48
|
+
* Decrypts an Aleo record ciphertext belonging to the connected wallet.
|
|
49
|
+
* Optional — not every wallet exposes the decrypt feature.
|
|
50
|
+
*/
|
|
51
|
+
decrypt?: (args: {
|
|
52
|
+
ciphertext: string;
|
|
53
|
+
options?: AleoDecryptOptions;
|
|
54
|
+
walletAccount: AleoWalletAccount;
|
|
55
|
+
}) => Promise<{
|
|
56
|
+
plaintext: string;
|
|
57
|
+
}>;
|
|
58
|
+
/**
|
|
59
|
+
* Requests the wallet to return records owned by the connected account for
|
|
60
|
+
* a given program. Optional — not every wallet exposes the records feature.
|
|
61
|
+
*/
|
|
62
|
+
requestRecords?: (args: {
|
|
63
|
+
options?: AleoRequestRecordsOptions;
|
|
64
|
+
program: string;
|
|
65
|
+
walletAccount: AleoWalletAccount;
|
|
66
|
+
}) => Promise<{
|
|
67
|
+
records: unknown[];
|
|
68
|
+
}>;
|
|
69
|
+
/**
|
|
70
|
+
* Submits an Aleo transaction (one or more transitions + fee) to the wallet
|
|
71
|
+
* for signing and broadcast. Returns the on-chain transaction id.
|
|
72
|
+
*/
|
|
73
|
+
requestTransaction: (args: {
|
|
74
|
+
transaction: AleoTransaction;
|
|
75
|
+
walletAccount: AleoWalletAccount;
|
|
76
|
+
}) => Promise<{
|
|
77
|
+
transactionId: string;
|
|
78
|
+
}>;
|
|
79
|
+
};
|
|
80
|
+
//# sourceMappingURL=AleoWalletProvider.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AleoWalletProvider.types.d.ts","sourceRoot":"","sources":["../src/AleoWalletProvider.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAEpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAEnE;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,OAAO,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,cAAc,EAAE,CAAC;CAC/B,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,cAAc,GAAG;IAChD,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE;QACf,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,kBAAkB,CAAC;QAC7B,aAAa,EAAE,iBAAiB,CAAC;KAClC,KAAK,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACrC;;;OAGG;IACH,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE;QACtB,OAAO,CAAC,EAAE,yBAAyB,CAAC;QACpC,OAAO,EAAE,MAAM,CAAC;QAChB,aAAa,EAAE,iBAAiB,CAAC;KAClC,KAAK,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,EAAE,CAAA;KAAE,CAAC,CAAC;IACtC;;;OAGG;IACH,kBAAkB,EAAE,CAAC,IAAI,EAAE;QACzB,WAAW,EAAE,eAAe,CAAC;QAC7B,aAAa,EAAE,iBAAiB,CAAC;KAClC,KAAK,OAAO,CAAC;QAAE,aAAa,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC1C,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseError } from '@dynamic-labs-sdk/client';
|
|
2
|
+
/**
|
|
3
|
+
* Thrown when an Aleo wallet does not advertise a feature the caller asked
|
|
4
|
+
* for — e.g. a wallet that lacks `aleo:decrypt` when `decrypt(...)` is
|
|
5
|
+
* invoked. Carries the feature name and the wallet display name so the
|
|
6
|
+
* UI / logs can surface which wallet was missing what.
|
|
7
|
+
*/
|
|
8
|
+
export declare class AleoFeatureUnsupportedError extends BaseError {
|
|
9
|
+
readonly featureName: string;
|
|
10
|
+
readonly walletName: string;
|
|
11
|
+
constructor(params: {
|
|
12
|
+
featureName: string;
|
|
13
|
+
walletName: string;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=AleoFeatureUnsupportedError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AleoFeatureUnsupportedError.d.ts","sourceRoot":"","sources":["../../../src/errors/AleoFeatureUnsupportedError/AleoFeatureUnsupportedError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAErD;;;;;GAKG;AACH,qBAAa,2BAA4B,SAAQ,SAAS;IACxD,SAAgB,WAAW,EAAE,MAAM,CAAC;IAEpC,SAAgB,UAAU,EAAE,MAAM,CAAC;gBAEvB,MAAM,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE;CAYhE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/errors/AleoFeatureUnsupportedError/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseError } from '@dynamic-labs-sdk/client';
|
|
2
|
+
/**
|
|
3
|
+
* Thrown when an input meant to be an Aleo transaction id (`at1...`) does
|
|
4
|
+
* not match the bech32 pattern. Carries the offending value on `txId` for
|
|
5
|
+
* inclusion in error logs / UI surfaces.
|
|
6
|
+
*/
|
|
7
|
+
export declare class InvalidAleoTransactionIdError extends BaseError {
|
|
8
|
+
readonly txId: string;
|
|
9
|
+
constructor(params: {
|
|
10
|
+
txId: string;
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=InvalidAleoTransactionIdError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InvalidAleoTransactionIdError.d.ts","sourceRoot":"","sources":["../../../src/errors/InvalidAleoTransactionIdError/InvalidAleoTransactionIdError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAErD;;;;GAIG;AACH,qBAAa,6BAA8B,SAAQ,SAAS;IAC1D,SAAgB,IAAI,EAAE,MAAM,CAAC;gBAEjB,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE;CAWrC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/errors/InvalidAleoTransactionIdError/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseError } from '@dynamic-labs-sdk/client';
|
|
2
|
+
/**
|
|
3
|
+
* Thrown by Aleo-specific top-level helpers (`signMessage`,
|
|
4
|
+
* `requestTransaction`, `decrypt`, `requestRecords`) when the wallet
|
|
5
|
+
* provider resolved from a wallet account is not an Aleo provider — i.e.
|
|
6
|
+
* the caller passed a wallet account from a different chain. Carries the
|
|
7
|
+
* offending provider's key on `providerKey`.
|
|
8
|
+
*/
|
|
9
|
+
export declare class NotAleoProviderError extends BaseError {
|
|
10
|
+
readonly providerKey: string;
|
|
11
|
+
constructor(params: {
|
|
12
|
+
providerKey: string;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=NotAleoProviderError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NotAleoProviderError.d.ts","sourceRoot":"","sources":["../../../src/errors/NotAleoProviderError/NotAleoProviderError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAErD;;;;;;GAMG;AACH,qBAAa,oBAAqB,SAAQ,SAAS;IACjD,SAAgB,WAAW,EAAE,MAAM,CAAC;gBAExB,MAAM,EAAE;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE;CAW5C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/errors/NotAleoProviderError/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { AleoFeatureUnsupportedError } from '../errors/AleoFeatureUnsupportedError';
|
|
2
|
+
export { InvalidAleoTransactionIdError } from '../errors/InvalidAleoTransactionIdError';
|
|
3
|
+
export { NotAleoProviderError } from '../errors/NotAleoProviderError';
|
|
4
|
+
export { isAleoNetworkProvider } from '../isAleoNetworkProvider';
|
|
5
|
+
export { isAleoWalletAccount } from '../isAleoWalletAccount';
|
|
6
|
+
export { isAleoWalletProvider } from '../isAleoWalletProvider';
|
|
7
|
+
export type { AleoNetworkProvider } from '../AleoNetworkProvider.types';
|
|
8
|
+
export type { AleoWalletAccount } from '../AleoWalletAccount.types';
|
|
9
|
+
export type { AleoDecryptOptions, AleoRequestRecordsOptions, AleoTransaction, AleoTransition, AleoWalletProvider, } from '../AleoWalletProvider.types';
|
|
10
|
+
export { getAleoExplorerTxUrl } from '../utils/getAleoExplorerTxUrl';
|
|
11
|
+
export { ALEO_NETWORK_TO_ID_MAP, getNetworkByChainId, } from '../utils/getNetworkByChainId';
|
|
12
|
+
export { ALEO_MAINNET_NETWORK_ID, ALEO_TESTNET_NETWORK_ID, MICROCREDITS_PER_CREDIT, } from '../utils/constants';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/exports/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,2BAA2B,EAAE,MAAM,uCAAuC,CAAC;AACpF,OAAO,EAAE,6BAA6B,EAAE,MAAM,yCAAyC,CAAC;AACxF,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,YAAY,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACxE,YAAY,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,YAAY,EACV,kBAAkB,EAClB,yBAAyB,EACzB,eAAe,EACf,cAAc,EACd,kBAAkB,GACnB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EACL,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,uBAAuB,EACvB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,oBAAoB,CAAC"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
let _dynamic_labs_sdk_assert_package_version = require("@dynamic-labs-sdk/assert-package-version");
|
|
2
|
+
let _dynamic_labs_sdk_client = require("@dynamic-labs-sdk/client");
|
|
3
|
+
let _provablehq_aleo_types = require("@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 _dynamic_labs_sdk_client.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 _dynamic_labs_sdk_client.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 _dynamic_labs_sdk_client.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
|
+
[_provablehq_aleo_types.Network.MAINNET]: ALEO_MAINNET_NETWORK_ID,
|
|
178
|
+
[_provablehq_aleo_types.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
|
+
(0, _dynamic_labs_sdk_assert_package_version.assertPackageVersion)(name, version);
|
|
197
|
+
|
|
198
|
+
//#endregion
|
|
199
|
+
exports.ALEO_MAINNET_NETWORK_ID = ALEO_MAINNET_NETWORK_ID;
|
|
200
|
+
exports.ALEO_NETWORK_TO_ID_MAP = ALEO_NETWORK_TO_ID_MAP;
|
|
201
|
+
exports.ALEO_TESTNET_NETWORK_ID = ALEO_TESTNET_NETWORK_ID;
|
|
202
|
+
exports.AleoFeatureUnsupportedError = AleoFeatureUnsupportedError;
|
|
203
|
+
exports.InvalidAleoTransactionIdError = InvalidAleoTransactionIdError;
|
|
204
|
+
exports.MICROCREDITS_PER_CREDIT = MICROCREDITS_PER_CREDIT;
|
|
205
|
+
exports.NotAleoProviderError = NotAleoProviderError;
|
|
206
|
+
exports.getAleoExplorerTxUrl = getAleoExplorerTxUrl;
|
|
207
|
+
exports.getNetworkByChainId = getNetworkByChainId;
|
|
208
|
+
exports.isAleoNetworkProvider = isAleoNetworkProvider;
|
|
209
|
+
exports.isAleoWalletAccount = isAleoWalletAccount;
|
|
210
|
+
exports.isAleoWalletProvider = isAleoWalletProvider;
|
|
211
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["BaseError","BaseError","BaseError","ALEO_NETWORK_TO_ID_MAP: Partial<Record<Network, number>>","Network","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,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;;;;;;;;;;;AChB7B,IAAa,gCAAb,cAAmDC,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;;;;;;;;;;;;;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,MAAaC,yBAA2D;EACrEC,+BAAQ,UAAU;EAClBA,+BAAQ,UAAU;CACpB;;;;;;;;;;;AAgBD,MAAa,uBAAuB,EAClC,cACoD;AAIpD,QAFE,OAAO,QAAQ,uBAAuB,CACtC,MAAM,GAAG,QAAQ,OAAO,QAAQ,GACnB;;;;;mEC9BIC,MAAaC,QAAe"}
|