@provablehq/aleo-wallet-adaptor-leo 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,31 @@
1
+ # @provablehq/aleo-wallet-adaptor-leo
2
+
3
+ Adapter that maps Leo wallet functionality onto the Aleo wallet adaptor contract.
4
+
5
+ ## When to use it
6
+
7
+ - Allow users of the Leo wallet to connect, sign, decrypt, and execute transactions in your Aleo app.
8
+ - Pair Leo with other adapters in a single wallet list without branching your app logic.
9
+ - Prototype Leo-specific functionality while keeping the rest of your integration untouched.
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ pnpm add @provablehq/aleo-wallet-adaptor-leo
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ```tsx
20
+ import { LeoWalletAdapter } from '@provablehq/aleo-wallet-adaptor-leo';
21
+
22
+ const wallets = [new LeoWalletAdapter()];
23
+ ```
24
+
25
+ ## Related packages
26
+
27
+ - `@provablehq/aleo-wallet-adaptor-core` – shared adapter base implementation.
28
+ - `@provablehq/aleo-wallet-adaptor-react` – provider that surface Leo in React apps.
29
+ - Other wallet adapters (`-prove-alpha`, `-puzzle`, `-fox`, etc.) that can coexist with Leo.
30
+
31
+ Live demo: https://aleo-dev-toolkit-react-app.vercel.app/
@@ -0,0 +1,219 @@
1
+ import { Network, Account, TransactionOptions, TransactionStatusResponse } from '@provablehq/aleo-types';
2
+ import { EventEmitter, WalletDecryptPermission, WalletName, WalletReadyState, AleoDeployment as AleoDeployment$1 } from '@provablehq/aleo-wallet-standard';
3
+ import { BaseAleoWalletAdapter } from '@provablehq/aleo-wallet-adaptor-core';
4
+
5
+ /**
6
+ * Leo wallet adapter configuration
7
+ */
8
+ interface LeoWalletAdapterConfig {
9
+ /**
10
+ * Application name
11
+ */
12
+ appName?: string;
13
+ /**
14
+ * Application icon URL
15
+ */
16
+ appIconUrl?: string;
17
+ /**
18
+ * Application description
19
+ */
20
+ appDescription?: string;
21
+ /**
22
+ * Program ID permissions by network
23
+ */
24
+ programIdPermissions?: Record<string, string[]>;
25
+ /**
26
+ * Whether the wallet is mobile
27
+ */
28
+ isMobile?: boolean;
29
+ /**
30
+ * The mobile webview URL
31
+ */
32
+ mobileWebviewUrl?: string;
33
+ }
34
+ interface LeoWalletEvents {
35
+ connect(...args: unknown[]): unknown;
36
+ disconnect(...args: unknown[]): unknown;
37
+ accountChange(...args: unknown[]): unknown;
38
+ }
39
+ type LeoNetwork = 'mainnet' | 'testnetbeta';
40
+ declare const LEO_NETWORK_MAP: Record<Network, LeoNetwork>;
41
+ interface LeoWallet extends EventEmitter<LeoWalletEvents> {
42
+ publicKey?: string;
43
+ isAvailable(): Promise<boolean>;
44
+ signMessage(message: Uint8Array): Promise<{
45
+ signature: Uint8Array;
46
+ }>;
47
+ decrypt(cipherText: string, tpk?: string, programId?: string, functionName?: string, index?: number): Promise<{
48
+ text: string;
49
+ }>;
50
+ requestRecords(program: string): Promise<{
51
+ records: unknown[];
52
+ }>;
53
+ requestTransaction(transaction: AleoTransaction): Promise<{
54
+ transactionId?: string;
55
+ }>;
56
+ requestExecution(transaction: AleoTransaction): Promise<{
57
+ transactionId?: string;
58
+ }>;
59
+ requestBulkTransactions(transactions: AleoTransaction[]): Promise<{
60
+ transactionIds?: string[];
61
+ }>;
62
+ requestDeploy(deployment: AleoDeployment): Promise<{
63
+ transactionId?: string;
64
+ }>;
65
+ transactionStatus(transactionId: string): Promise<{
66
+ status: string;
67
+ }>;
68
+ transitionViewKeys(transactionId: string): Promise<{
69
+ viewKeys?: string[];
70
+ }>;
71
+ getExecution(transactionId: string): Promise<{
72
+ execution: string;
73
+ }>;
74
+ requestRecordPlaintexts(program: string): Promise<{
75
+ records: unknown[];
76
+ }>;
77
+ requestTransactionHistory(program: string): Promise<{
78
+ transactions: unknown[];
79
+ }>;
80
+ connect(decryptPermission: WalletDecryptPermission, network: LeoNetwork, programs?: string[]): Promise<void>;
81
+ disconnect(): Promise<void>;
82
+ }
83
+ interface LeoWindow extends Window {
84
+ leoWallet?: LeoWallet;
85
+ leo?: LeoWallet;
86
+ }
87
+ interface AleoTransaction {
88
+ address: string;
89
+ chainId: string;
90
+ transitions: AleoTransition[];
91
+ fee: number;
92
+ feePrivate: boolean;
93
+ }
94
+ interface AleoTransition {
95
+ program: string;
96
+ functionName: string;
97
+ inputs: unknown[];
98
+ }
99
+ declare class Transition implements AleoTransition {
100
+ program: string;
101
+ functionName: string;
102
+ inputs: unknown[];
103
+ constructor(program: string, functionName: string, inputs: unknown[]);
104
+ }
105
+ interface AleoDeployment {
106
+ address: string;
107
+ chainId: string;
108
+ program: string;
109
+ fee: number;
110
+ feePrivate: boolean;
111
+ }
112
+ declare class Deployment implements AleoDeployment {
113
+ address: string;
114
+ chainId: string;
115
+ program: string;
116
+ fee: number;
117
+ feePrivate: boolean;
118
+ constructor(address: string, chainId: string, program: string, fee: number, feePrivate?: boolean);
119
+ }
120
+
121
+ /**
122
+ * Leo wallet adapter
123
+ */
124
+ declare class LeoWalletAdapter extends BaseAleoWalletAdapter {
125
+ /**
126
+ * The wallet name
127
+ */
128
+ readonly name: WalletName<"Leo Wallet">;
129
+ /**
130
+ * The wallet URL
131
+ */
132
+ url: string;
133
+ /**
134
+ * The wallet icon (base64-encoded SVG)
135
+ */
136
+ readonly icon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFwAAABcCAMAAADUMSJqAAAASFBMVEVjTP////9kTf9GIP/5+P9dRP+ajf9WO//Jwv9fR/9KJv+Ccf9ZP//08/+Xiv9aQf+upf/c2P+Qgf96aP9TNv/Nx/+Fdf+6sv91nL8+AAABCUlEQVRoge2YyQ6EIBBEccVWBHf//09H42FESNRJk+ik3s06vANCQ0oIAAAAf0ps48u8XHKXiYVZsyE5pbxgj8s63RPpTAhZROkZ9QV7nKSRRb7JT0kTyCGHHPInyceAcppyBz0zyQVlDlJzyT1k+XvkZKQ0FEROqmqKoqkU8ctV327fba+45ar7Jp3ilVO/j3pilat2H7WKU06VnVXEKDeNnTWGUX6cioV8izzosgT9ocetuKzKWw5R0OMfdnAtKyPDjVwR9LI48ny5lu6zgm0rztp9EE1cJ9THyDW4fLBNRcghhxxyDvmh+vOxybVdB16p/pzS0sewesz90vJGtfpD3QoAAOCNfADu9hzTpMe3fQAAAABJRU5ErkJggg==";
137
+ /**
138
+ * The window object
139
+ */
140
+ private _window;
141
+ /**
142
+ * Current network
143
+ */
144
+ network: Network;
145
+ /**
146
+ * The wallet's decrypt permission
147
+ */
148
+ decryptPermission: WalletDecryptPermission;
149
+ /**
150
+ * Public key
151
+ */
152
+ private _publicKey;
153
+ _readyState: WalletReadyState;
154
+ /**
155
+ * Leo wallet instance
156
+ */
157
+ private _leoWallet;
158
+ /**
159
+ * Create a new Leo wallet adapter
160
+ * @param config Adapter configuration
161
+ */
162
+ constructor(config?: LeoWalletAdapterConfig);
163
+ /**
164
+ * Check if Leo wallet is available
165
+ */
166
+ private _checkAvailability;
167
+ /**
168
+ * Connect to Leo wallet
169
+ * @returns The connected account
170
+ */
171
+ connect(network: Network, decryptPermission: WalletDecryptPermission, programs?: string[]): Promise<Account>;
172
+ /**
173
+ * Disconnect from Leo wallet
174
+ */
175
+ disconnect(): Promise<void>;
176
+ /**
177
+ * Sign a transaction with Leo wallet
178
+ * @param options Transaction options
179
+ * @returns The signed transaction
180
+ */
181
+ signMessage(message: Uint8Array): Promise<Uint8Array>;
182
+ decrypt(cipherText: string, tpk?: string, programId?: string, functionName?: string, index?: number): Promise<string>;
183
+ /**
184
+ * Execute a transaction with Leo wallet
185
+ * @param options Transaction options
186
+ * @returns The executed temporary transaction ID
187
+ */
188
+ executeTransaction(options: TransactionOptions): Promise<{
189
+ transactionId: string;
190
+ }>;
191
+ /**
192
+ * Get transaction status
193
+ * @param transactionId The transaction ID
194
+ * @returns The transaction status
195
+ */
196
+ transactionStatus(transactionId: string): Promise<TransactionStatusResponse>;
197
+ /**
198
+ * Request records from Leo wallet
199
+ * @param program The program to request records from
200
+ * @param includePlaintext Whether to include plaintext on each record
201
+ * @returns The records
202
+ */
203
+ requestRecords(program: string, includePlaintext: boolean): Promise<unknown[]>;
204
+ /**
205
+ * Switch the network
206
+ * @param network The network to switch to
207
+ */
208
+ switchNetwork(_network: Network): Promise<void>;
209
+ /**
210
+ * Execute a deployment
211
+ * @param deployment The deployment to execute
212
+ * @returns The executed transaction ID
213
+ */
214
+ executeDeployment(deployment: AleoDeployment$1): Promise<{
215
+ transactionId: string;
216
+ }>;
217
+ }
218
+
219
+ export { type AleoDeployment, type AleoTransaction, type AleoTransition, Deployment, LEO_NETWORK_MAP, type LeoNetwork, type LeoWallet, LeoWalletAdapter, type LeoWalletAdapterConfig, type LeoWalletEvents, type LeoWindow, Transition };
@@ -0,0 +1,219 @@
1
+ import { Network, Account, TransactionOptions, TransactionStatusResponse } from '@provablehq/aleo-types';
2
+ import { EventEmitter, WalletDecryptPermission, WalletName, WalletReadyState, AleoDeployment as AleoDeployment$1 } from '@provablehq/aleo-wallet-standard';
3
+ import { BaseAleoWalletAdapter } from '@provablehq/aleo-wallet-adaptor-core';
4
+
5
+ /**
6
+ * Leo wallet adapter configuration
7
+ */
8
+ interface LeoWalletAdapterConfig {
9
+ /**
10
+ * Application name
11
+ */
12
+ appName?: string;
13
+ /**
14
+ * Application icon URL
15
+ */
16
+ appIconUrl?: string;
17
+ /**
18
+ * Application description
19
+ */
20
+ appDescription?: string;
21
+ /**
22
+ * Program ID permissions by network
23
+ */
24
+ programIdPermissions?: Record<string, string[]>;
25
+ /**
26
+ * Whether the wallet is mobile
27
+ */
28
+ isMobile?: boolean;
29
+ /**
30
+ * The mobile webview URL
31
+ */
32
+ mobileWebviewUrl?: string;
33
+ }
34
+ interface LeoWalletEvents {
35
+ connect(...args: unknown[]): unknown;
36
+ disconnect(...args: unknown[]): unknown;
37
+ accountChange(...args: unknown[]): unknown;
38
+ }
39
+ type LeoNetwork = 'mainnet' | 'testnetbeta';
40
+ declare const LEO_NETWORK_MAP: Record<Network, LeoNetwork>;
41
+ interface LeoWallet extends EventEmitter<LeoWalletEvents> {
42
+ publicKey?: string;
43
+ isAvailable(): Promise<boolean>;
44
+ signMessage(message: Uint8Array): Promise<{
45
+ signature: Uint8Array;
46
+ }>;
47
+ decrypt(cipherText: string, tpk?: string, programId?: string, functionName?: string, index?: number): Promise<{
48
+ text: string;
49
+ }>;
50
+ requestRecords(program: string): Promise<{
51
+ records: unknown[];
52
+ }>;
53
+ requestTransaction(transaction: AleoTransaction): Promise<{
54
+ transactionId?: string;
55
+ }>;
56
+ requestExecution(transaction: AleoTransaction): Promise<{
57
+ transactionId?: string;
58
+ }>;
59
+ requestBulkTransactions(transactions: AleoTransaction[]): Promise<{
60
+ transactionIds?: string[];
61
+ }>;
62
+ requestDeploy(deployment: AleoDeployment): Promise<{
63
+ transactionId?: string;
64
+ }>;
65
+ transactionStatus(transactionId: string): Promise<{
66
+ status: string;
67
+ }>;
68
+ transitionViewKeys(transactionId: string): Promise<{
69
+ viewKeys?: string[];
70
+ }>;
71
+ getExecution(transactionId: string): Promise<{
72
+ execution: string;
73
+ }>;
74
+ requestRecordPlaintexts(program: string): Promise<{
75
+ records: unknown[];
76
+ }>;
77
+ requestTransactionHistory(program: string): Promise<{
78
+ transactions: unknown[];
79
+ }>;
80
+ connect(decryptPermission: WalletDecryptPermission, network: LeoNetwork, programs?: string[]): Promise<void>;
81
+ disconnect(): Promise<void>;
82
+ }
83
+ interface LeoWindow extends Window {
84
+ leoWallet?: LeoWallet;
85
+ leo?: LeoWallet;
86
+ }
87
+ interface AleoTransaction {
88
+ address: string;
89
+ chainId: string;
90
+ transitions: AleoTransition[];
91
+ fee: number;
92
+ feePrivate: boolean;
93
+ }
94
+ interface AleoTransition {
95
+ program: string;
96
+ functionName: string;
97
+ inputs: unknown[];
98
+ }
99
+ declare class Transition implements AleoTransition {
100
+ program: string;
101
+ functionName: string;
102
+ inputs: unknown[];
103
+ constructor(program: string, functionName: string, inputs: unknown[]);
104
+ }
105
+ interface AleoDeployment {
106
+ address: string;
107
+ chainId: string;
108
+ program: string;
109
+ fee: number;
110
+ feePrivate: boolean;
111
+ }
112
+ declare class Deployment implements AleoDeployment {
113
+ address: string;
114
+ chainId: string;
115
+ program: string;
116
+ fee: number;
117
+ feePrivate: boolean;
118
+ constructor(address: string, chainId: string, program: string, fee: number, feePrivate?: boolean);
119
+ }
120
+
121
+ /**
122
+ * Leo wallet adapter
123
+ */
124
+ declare class LeoWalletAdapter extends BaseAleoWalletAdapter {
125
+ /**
126
+ * The wallet name
127
+ */
128
+ readonly name: WalletName<"Leo Wallet">;
129
+ /**
130
+ * The wallet URL
131
+ */
132
+ url: string;
133
+ /**
134
+ * The wallet icon (base64-encoded SVG)
135
+ */
136
+ readonly icon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFwAAABcCAMAAADUMSJqAAAASFBMVEVjTP////9kTf9GIP/5+P9dRP+ajf9WO//Jwv9fR/9KJv+Ccf9ZP//08/+Xiv9aQf+upf/c2P+Qgf96aP9TNv/Nx/+Fdf+6sv91nL8+AAABCUlEQVRoge2YyQ6EIBBEccVWBHf//09H42FESNRJk+ik3s06vANCQ0oIAAAAf0ps48u8XHKXiYVZsyE5pbxgj8s63RPpTAhZROkZ9QV7nKSRRb7JT0kTyCGHHPInyceAcppyBz0zyQVlDlJzyT1k+XvkZKQ0FEROqmqKoqkU8ctV327fba+45ar7Jp3ilVO/j3pilat2H7WKU06VnVXEKDeNnTWGUX6cioV8izzosgT9ocetuKzKWw5R0OMfdnAtKyPDjVwR9LI48ny5lu6zgm0rztp9EE1cJ9THyDW4fLBNRcghhxxyDvmh+vOxybVdB16p/pzS0sewesz90vJGtfpD3QoAAOCNfADu9hzTpMe3fQAAAABJRU5ErkJggg==";
137
+ /**
138
+ * The window object
139
+ */
140
+ private _window;
141
+ /**
142
+ * Current network
143
+ */
144
+ network: Network;
145
+ /**
146
+ * The wallet's decrypt permission
147
+ */
148
+ decryptPermission: WalletDecryptPermission;
149
+ /**
150
+ * Public key
151
+ */
152
+ private _publicKey;
153
+ _readyState: WalletReadyState;
154
+ /**
155
+ * Leo wallet instance
156
+ */
157
+ private _leoWallet;
158
+ /**
159
+ * Create a new Leo wallet adapter
160
+ * @param config Adapter configuration
161
+ */
162
+ constructor(config?: LeoWalletAdapterConfig);
163
+ /**
164
+ * Check if Leo wallet is available
165
+ */
166
+ private _checkAvailability;
167
+ /**
168
+ * Connect to Leo wallet
169
+ * @returns The connected account
170
+ */
171
+ connect(network: Network, decryptPermission: WalletDecryptPermission, programs?: string[]): Promise<Account>;
172
+ /**
173
+ * Disconnect from Leo wallet
174
+ */
175
+ disconnect(): Promise<void>;
176
+ /**
177
+ * Sign a transaction with Leo wallet
178
+ * @param options Transaction options
179
+ * @returns The signed transaction
180
+ */
181
+ signMessage(message: Uint8Array): Promise<Uint8Array>;
182
+ decrypt(cipherText: string, tpk?: string, programId?: string, functionName?: string, index?: number): Promise<string>;
183
+ /**
184
+ * Execute a transaction with Leo wallet
185
+ * @param options Transaction options
186
+ * @returns The executed temporary transaction ID
187
+ */
188
+ executeTransaction(options: TransactionOptions): Promise<{
189
+ transactionId: string;
190
+ }>;
191
+ /**
192
+ * Get transaction status
193
+ * @param transactionId The transaction ID
194
+ * @returns The transaction status
195
+ */
196
+ transactionStatus(transactionId: string): Promise<TransactionStatusResponse>;
197
+ /**
198
+ * Request records from Leo wallet
199
+ * @param program The program to request records from
200
+ * @param includePlaintext Whether to include plaintext on each record
201
+ * @returns The records
202
+ */
203
+ requestRecords(program: string, includePlaintext: boolean): Promise<unknown[]>;
204
+ /**
205
+ * Switch the network
206
+ * @param network The network to switch to
207
+ */
208
+ switchNetwork(_network: Network): Promise<void>;
209
+ /**
210
+ * Execute a deployment
211
+ * @param deployment The deployment to execute
212
+ * @returns The executed transaction ID
213
+ */
214
+ executeDeployment(deployment: AleoDeployment$1): Promise<{
215
+ transactionId: string;
216
+ }>;
217
+ }
218
+
219
+ export { type AleoDeployment, type AleoTransaction, type AleoTransition, Deployment, LEO_NETWORK_MAP, type LeoNetwork, type LeoWallet, LeoWalletAdapter, type LeoWalletAdapterConfig, type LeoWalletEvents, type LeoWindow, Transition };