@provablehq/aleo-wallet-adaptor-core 0.1.1-alpha.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/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # @provablehq/aleo-wallet-adaptor-core
2
+
3
+ Foundation utilities and base classes for implementing Aleo-compatible wallet adapters.
4
+
5
+ ## When to use it
6
+
7
+ - Author a first-party or partner wallet adapter that plugs into the Aleo wallet ecosystem.
8
+ - Share common adapter behaviour (events, feature checks, network switching) across multiple wallet implementations.
9
+ - Build higher-level tooling (React hooks, UI kits) on a consistent adapter contract.
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ pnpm add @provablehq/aleo-wallet-adaptor-core
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ```ts
20
+ import { BaseAleoWalletAdapter } from '@provablehq/aleo-wallet-adaptor-core';
21
+
22
+ class MyWalletAdapter extends BaseAleoWalletAdapter {
23
+ // extend the base adapter with wallet-specific logic
24
+ }
25
+ ```
26
+
27
+ ## Related packages
28
+
29
+ - `@provablehq/aleo-wallet-adaptor-react` – React provider and hooks built on this core.
30
+ - `@provablehq/aleo-wallet-adaptor-react-ui` – Pre-built React components for any adapter that extends the core.
31
+ - `@provablehq/aleo-wallet-standard` – Shared feature definitions and event interfaces consumed by the base adapter.
32
+
33
+ Live demo: https://aleo-dev-toolkit-react-app.vercel.app/
@@ -0,0 +1,187 @@
1
+ import { Account, Network, TransactionOptions, TransactionStatusResponse, AccountOptions } from '@provablehq/aleo-types';
2
+ import { EventEmitter, WalletEvents, WalletAdapter, WalletName, WalletReadyState, WalletDecryptPermission, StandardWallet, AleoChain, AleoDeployment } from '@provablehq/aleo-wallet-standard';
3
+ export { WalletDecryptPermission as DecryptPermission } from '@provablehq/aleo-wallet-standard';
4
+
5
+ /**
6
+ * Base class for Aleo wallet adapters
7
+ */
8
+ declare abstract class BaseAleoWalletAdapter extends EventEmitter<WalletEvents> implements WalletAdapter {
9
+ /**
10
+ * The wallet name
11
+ */
12
+ abstract name: WalletName<string>;
13
+ /**
14
+ * The wallet URL
15
+ */
16
+ abstract url?: string;
17
+ /**
18
+ * The wallet icon
19
+ */
20
+ abstract icon?: string;
21
+ /**
22
+ * The wallet's ready state
23
+ */
24
+ abstract _readyState: WalletReadyState;
25
+ get readyState(): WalletReadyState;
26
+ protected set readyState(state: WalletReadyState);
27
+ /**
28
+ * The connected account, if any
29
+ */
30
+ account?: Account;
31
+ /**
32
+ * The wallet's network
33
+ */
34
+ abstract network: Network;
35
+ /**
36
+ * The wallet's decrypt permission
37
+ */
38
+ abstract decryptPermission: WalletDecryptPermission;
39
+ /**
40
+ * The wallet's standard interface, if available
41
+ */
42
+ protected _wallet?: StandardWallet;
43
+ /**
44
+ * The supported chains
45
+ */
46
+ get chains(): AleoChain[];
47
+ /**
48
+ * The wallet's connected state
49
+ */
50
+ get connected(): boolean;
51
+ /**
52
+ * Connect to the wallet
53
+ * @param network The network to connect to
54
+ * @param decryptPermission The decrypt permission
55
+ * @param programs The programs to connect to
56
+ * @returns The connected account
57
+ */
58
+ connect(network: Network, decryptPermission: WalletDecryptPermission, programs?: string[]): Promise<Account>;
59
+ /**
60
+ * Disconnect from the wallet
61
+ */
62
+ disconnect(): Promise<void>;
63
+ /**
64
+ * Sign a message
65
+ * @param options Transaction options
66
+ * @returns The signed transaction
67
+ */
68
+ signMessage(message: Uint8Array): Promise<Uint8Array>;
69
+ /**
70
+ * Execute a transaction
71
+ * @param options Transaction options
72
+ * @returns The executed temporary transaction ID
73
+ */
74
+ executeTransaction(options: TransactionOptions): Promise<{
75
+ transactionId: string;
76
+ }>;
77
+ /**
78
+ * Get transaction status
79
+ * @param transactionId The transaction ID
80
+ * @returns The transaction status
81
+ */
82
+ transactionStatus(transactionId: string): Promise<TransactionStatusResponse>;
83
+ switchNetwork(network: Network): Promise<void>;
84
+ decrypt(cipherText: string, tpk?: string, programId?: string, functionName?: string, index?: number): Promise<string>;
85
+ requestRecords(program: string, includePlaintext: boolean): Promise<unknown[]>;
86
+ executeDeployment(deployment: AleoDeployment): Promise<{
87
+ transactionId: string;
88
+ }>;
89
+ }
90
+
91
+ /**
92
+ * Get the short address representation (for display)
93
+ * @param address The full address
94
+ * @param prefixLength The number of characters to keep at the beginning
95
+ * @param suffixLength The number of characters to keep at the end
96
+ * @returns The short address representation
97
+ */
98
+ declare function getShortAddress(address: string, prefixLength?: number, suffixLength?: number): string;
99
+ /**
100
+ * Create a new account with the given options
101
+ * @param options Account options
102
+ * @returns The created account
103
+ */
104
+ declare function createAccount(options?: AccountOptions): Account;
105
+
106
+ /**
107
+ * Base wallet error
108
+ */
109
+ declare class WalletError extends Error {
110
+ name: string;
111
+ }
112
+ /**
113
+ * Error thrown when a wallet is not connected
114
+ */
115
+ declare class WalletNotConnectedError extends WalletError {
116
+ name: string;
117
+ constructor();
118
+ }
119
+ /**
120
+ * Error thrown when the wallet connection is rejected
121
+ */
122
+ declare class WalletConnectionError extends WalletError {
123
+ name: string;
124
+ constructor(message?: string);
125
+ }
126
+ /**
127
+ * Error thrown when a required wallet feature is not available
128
+ */
129
+ declare class WalletFeatureNotAvailableError extends WalletError {
130
+ name: string;
131
+ constructor(feature: string);
132
+ }
133
+ /**
134
+ * Error thrown when a wallet transaction fails
135
+ */
136
+ declare class WalletTransactionError extends WalletError {
137
+ name: string;
138
+ constructor(message?: string);
139
+ }
140
+ /**
141
+ * Error thrown when a user rejects a transaction
142
+ */
143
+ declare class WalletTransactionRejectedError extends WalletTransactionError {
144
+ name: string;
145
+ constructor();
146
+ }
147
+ /**
148
+ * Error thrown when a transaction times out
149
+ */
150
+ declare class WalletTransactionTimeoutError extends WalletTransactionError {
151
+ name: string;
152
+ constructor();
153
+ }
154
+ declare class WalletNotSelectedError extends WalletError {
155
+ name: string;
156
+ constructor();
157
+ }
158
+ declare class WalletDisconnectionError extends WalletError {
159
+ name: string;
160
+ constructor(message?: string);
161
+ }
162
+ declare class WalletSignMessageError extends WalletError {
163
+ name: string;
164
+ constructor(message?: string);
165
+ }
166
+ declare class WalletSwitchNetworkError extends WalletError {
167
+ name: string;
168
+ constructor(message?: string);
169
+ }
170
+ declare class WalletNotReadyError extends WalletError {
171
+ name: string;
172
+ constructor();
173
+ }
174
+ declare class WalletDecryptionNotAllowedError extends WalletError {
175
+ name: string;
176
+ constructor();
177
+ }
178
+ declare class WalletDecryptionError extends WalletError {
179
+ name: string;
180
+ constructor(message?: string);
181
+ }
182
+ declare class MethodNotImplementedError extends WalletError {
183
+ name: string;
184
+ constructor(method: string);
185
+ }
186
+
187
+ export { BaseAleoWalletAdapter, MethodNotImplementedError, WalletConnectionError, WalletDecryptionError, WalletDecryptionNotAllowedError, WalletDisconnectionError, WalletError, WalletFeatureNotAvailableError, WalletNotConnectedError, WalletNotReadyError, WalletNotSelectedError, WalletSignMessageError, WalletSwitchNetworkError, WalletTransactionError, WalletTransactionRejectedError, WalletTransactionTimeoutError, createAccount, getShortAddress };
@@ -0,0 +1,187 @@
1
+ import { Account, Network, TransactionOptions, TransactionStatusResponse, AccountOptions } from '@provablehq/aleo-types';
2
+ import { EventEmitter, WalletEvents, WalletAdapter, WalletName, WalletReadyState, WalletDecryptPermission, StandardWallet, AleoChain, AleoDeployment } from '@provablehq/aleo-wallet-standard';
3
+ export { WalletDecryptPermission as DecryptPermission } from '@provablehq/aleo-wallet-standard';
4
+
5
+ /**
6
+ * Base class for Aleo wallet adapters
7
+ */
8
+ declare abstract class BaseAleoWalletAdapter extends EventEmitter<WalletEvents> implements WalletAdapter {
9
+ /**
10
+ * The wallet name
11
+ */
12
+ abstract name: WalletName<string>;
13
+ /**
14
+ * The wallet URL
15
+ */
16
+ abstract url?: string;
17
+ /**
18
+ * The wallet icon
19
+ */
20
+ abstract icon?: string;
21
+ /**
22
+ * The wallet's ready state
23
+ */
24
+ abstract _readyState: WalletReadyState;
25
+ get readyState(): WalletReadyState;
26
+ protected set readyState(state: WalletReadyState);
27
+ /**
28
+ * The connected account, if any
29
+ */
30
+ account?: Account;
31
+ /**
32
+ * The wallet's network
33
+ */
34
+ abstract network: Network;
35
+ /**
36
+ * The wallet's decrypt permission
37
+ */
38
+ abstract decryptPermission: WalletDecryptPermission;
39
+ /**
40
+ * The wallet's standard interface, if available
41
+ */
42
+ protected _wallet?: StandardWallet;
43
+ /**
44
+ * The supported chains
45
+ */
46
+ get chains(): AleoChain[];
47
+ /**
48
+ * The wallet's connected state
49
+ */
50
+ get connected(): boolean;
51
+ /**
52
+ * Connect to the wallet
53
+ * @param network The network to connect to
54
+ * @param decryptPermission The decrypt permission
55
+ * @param programs The programs to connect to
56
+ * @returns The connected account
57
+ */
58
+ connect(network: Network, decryptPermission: WalletDecryptPermission, programs?: string[]): Promise<Account>;
59
+ /**
60
+ * Disconnect from the wallet
61
+ */
62
+ disconnect(): Promise<void>;
63
+ /**
64
+ * Sign a message
65
+ * @param options Transaction options
66
+ * @returns The signed transaction
67
+ */
68
+ signMessage(message: Uint8Array): Promise<Uint8Array>;
69
+ /**
70
+ * Execute a transaction
71
+ * @param options Transaction options
72
+ * @returns The executed temporary transaction ID
73
+ */
74
+ executeTransaction(options: TransactionOptions): Promise<{
75
+ transactionId: string;
76
+ }>;
77
+ /**
78
+ * Get transaction status
79
+ * @param transactionId The transaction ID
80
+ * @returns The transaction status
81
+ */
82
+ transactionStatus(transactionId: string): Promise<TransactionStatusResponse>;
83
+ switchNetwork(network: Network): Promise<void>;
84
+ decrypt(cipherText: string, tpk?: string, programId?: string, functionName?: string, index?: number): Promise<string>;
85
+ requestRecords(program: string, includePlaintext: boolean): Promise<unknown[]>;
86
+ executeDeployment(deployment: AleoDeployment): Promise<{
87
+ transactionId: string;
88
+ }>;
89
+ }
90
+
91
+ /**
92
+ * Get the short address representation (for display)
93
+ * @param address The full address
94
+ * @param prefixLength The number of characters to keep at the beginning
95
+ * @param suffixLength The number of characters to keep at the end
96
+ * @returns The short address representation
97
+ */
98
+ declare function getShortAddress(address: string, prefixLength?: number, suffixLength?: number): string;
99
+ /**
100
+ * Create a new account with the given options
101
+ * @param options Account options
102
+ * @returns The created account
103
+ */
104
+ declare function createAccount(options?: AccountOptions): Account;
105
+
106
+ /**
107
+ * Base wallet error
108
+ */
109
+ declare class WalletError extends Error {
110
+ name: string;
111
+ }
112
+ /**
113
+ * Error thrown when a wallet is not connected
114
+ */
115
+ declare class WalletNotConnectedError extends WalletError {
116
+ name: string;
117
+ constructor();
118
+ }
119
+ /**
120
+ * Error thrown when the wallet connection is rejected
121
+ */
122
+ declare class WalletConnectionError extends WalletError {
123
+ name: string;
124
+ constructor(message?: string);
125
+ }
126
+ /**
127
+ * Error thrown when a required wallet feature is not available
128
+ */
129
+ declare class WalletFeatureNotAvailableError extends WalletError {
130
+ name: string;
131
+ constructor(feature: string);
132
+ }
133
+ /**
134
+ * Error thrown when a wallet transaction fails
135
+ */
136
+ declare class WalletTransactionError extends WalletError {
137
+ name: string;
138
+ constructor(message?: string);
139
+ }
140
+ /**
141
+ * Error thrown when a user rejects a transaction
142
+ */
143
+ declare class WalletTransactionRejectedError extends WalletTransactionError {
144
+ name: string;
145
+ constructor();
146
+ }
147
+ /**
148
+ * Error thrown when a transaction times out
149
+ */
150
+ declare class WalletTransactionTimeoutError extends WalletTransactionError {
151
+ name: string;
152
+ constructor();
153
+ }
154
+ declare class WalletNotSelectedError extends WalletError {
155
+ name: string;
156
+ constructor();
157
+ }
158
+ declare class WalletDisconnectionError extends WalletError {
159
+ name: string;
160
+ constructor(message?: string);
161
+ }
162
+ declare class WalletSignMessageError extends WalletError {
163
+ name: string;
164
+ constructor(message?: string);
165
+ }
166
+ declare class WalletSwitchNetworkError extends WalletError {
167
+ name: string;
168
+ constructor(message?: string);
169
+ }
170
+ declare class WalletNotReadyError extends WalletError {
171
+ name: string;
172
+ constructor();
173
+ }
174
+ declare class WalletDecryptionNotAllowedError extends WalletError {
175
+ name: string;
176
+ constructor();
177
+ }
178
+ declare class WalletDecryptionError extends WalletError {
179
+ name: string;
180
+ constructor(message?: string);
181
+ }
182
+ declare class MethodNotImplementedError extends WalletError {
183
+ name: string;
184
+ constructor(method: string);
185
+ }
186
+
187
+ export { BaseAleoWalletAdapter, MethodNotImplementedError, WalletConnectionError, WalletDecryptionError, WalletDecryptionNotAllowedError, WalletDisconnectionError, WalletError, WalletFeatureNotAvailableError, WalletNotConnectedError, WalletNotReadyError, WalletNotSelectedError, WalletSignMessageError, WalletSwitchNetworkError, WalletTransactionError, WalletTransactionRejectedError, WalletTransactionTimeoutError, createAccount, getShortAddress };