@provablehq/aleo-wallet-adaptor-puzzle 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/LICENSE +674 -0
- package/README.md +31 -0
- package/dist/index.d.mts +146 -0
- package/dist/index.d.ts +146 -0
- package/dist/index.js +321 -0
- package/dist/index.mjs +320 -0
- package/package.json +45 -0
- package/src/PuzzleWalletAdapter.ts +382 -0
- package/src/icon.ts +2 -0
- package/src/index.ts +2 -0
- package/src/types.ts +44 -0
package/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# @provablehq/aleo-wallet-adaptor-puzzle
|
|
2
|
+
|
|
3
|
+
Adapter that exposes the Puzzle wallet through the Aleo wallet adaptor interfaces.
|
|
4
|
+
|
|
5
|
+
## When to use it
|
|
6
|
+
|
|
7
|
+
- Offer Puzzle wallet users a seamless connect experience in your Aleo dApp.
|
|
8
|
+
- Combine Puzzle with other wallets (Leo, Prove Alpha, Fox, Soter) in a single provider instance.
|
|
9
|
+
- Prototype wallet flows that rely on Puzzle’s capabilities without forking adaptor logic.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pnpm add @provablehq/aleo-wallet-adaptor-puzzle
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
import { PuzzleWalletAdapter } from '@provablehq/aleo-wallet-adaptor-puzzle';
|
|
21
|
+
|
|
22
|
+
const wallets = [new PuzzleWalletAdapter()];
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Related packages
|
|
26
|
+
|
|
27
|
+
- `@provablehq/aleo-wallet-adaptor-core` – required base implementation.
|
|
28
|
+
- `@provablehq/aleo-wallet-adaptor-react` – provider that wires Puzzle into React apps.
|
|
29
|
+
- `@provablehq/aleo-wallet-adaptor-react-ui` – wallet picker UI that automatically lists Puzzle when available.
|
|
30
|
+
|
|
31
|
+
Live demo: https://aleo-dev-toolkit-react-app.vercel.app/
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { Network, Account, TransactionOptions, TransactionStatusResponse } from '@provablehq/aleo-types';
|
|
2
|
+
import { WalletName, WalletDecryptPermission, WalletReadyState, AleoDeployment } from '@provablehq/aleo-wallet-standard';
|
|
3
|
+
import { BaseAleoWalletAdapter } from '@provablehq/aleo-wallet-adaptor-core';
|
|
4
|
+
import { Network as Network$1 } from '@puzzlehq/sdk-core';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Puzzle window interface
|
|
8
|
+
*/
|
|
9
|
+
interface PuzzleWindow extends Window {
|
|
10
|
+
puzzle?: {
|
|
11
|
+
connected: boolean;
|
|
12
|
+
connect(): Promise<unknown>;
|
|
13
|
+
disconnect(): Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Puzzle wallet adapter configuration
|
|
18
|
+
*/
|
|
19
|
+
interface PuzzleWalletAdapterConfig {
|
|
20
|
+
/**
|
|
21
|
+
* Application name
|
|
22
|
+
*/
|
|
23
|
+
appName?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Application icon URL
|
|
26
|
+
*/
|
|
27
|
+
appIconUrl?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Application description
|
|
30
|
+
*/
|
|
31
|
+
appDescription?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Program ID permissions by network
|
|
34
|
+
*/
|
|
35
|
+
programIdPermissions?: Record<string, string[]>;
|
|
36
|
+
}
|
|
37
|
+
declare const PUZZLE_NETWORK_MAP: Record<Network, Network$1>;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Puzzle wallet adapter
|
|
41
|
+
*/
|
|
42
|
+
declare class PuzzleWalletAdapter extends BaseAleoWalletAdapter {
|
|
43
|
+
/**
|
|
44
|
+
* The wallet name
|
|
45
|
+
*/
|
|
46
|
+
name: WalletName<"Puzzle Wallet">;
|
|
47
|
+
/**
|
|
48
|
+
* The wallet URL
|
|
49
|
+
*/
|
|
50
|
+
url: string;
|
|
51
|
+
/**
|
|
52
|
+
* The wallet icon (base64-encoded SVG)
|
|
53
|
+
*/
|
|
54
|
+
icon: string;
|
|
55
|
+
/**
|
|
56
|
+
* The window object
|
|
57
|
+
*/
|
|
58
|
+
private _window;
|
|
59
|
+
/**
|
|
60
|
+
* App name
|
|
61
|
+
*/
|
|
62
|
+
private _appName;
|
|
63
|
+
/**
|
|
64
|
+
* App icon URL
|
|
65
|
+
*/
|
|
66
|
+
private _appIconUrl?;
|
|
67
|
+
/**
|
|
68
|
+
* App description
|
|
69
|
+
*/
|
|
70
|
+
private _appDescription?;
|
|
71
|
+
/**
|
|
72
|
+
* Current network
|
|
73
|
+
*/
|
|
74
|
+
network: Network;
|
|
75
|
+
/**
|
|
76
|
+
* The wallet's decrypt permission
|
|
77
|
+
*/
|
|
78
|
+
decryptPermission: WalletDecryptPermission;
|
|
79
|
+
_readyState: WalletReadyState;
|
|
80
|
+
/**
|
|
81
|
+
* Public key
|
|
82
|
+
*/
|
|
83
|
+
private _publicKey;
|
|
84
|
+
/**
|
|
85
|
+
* Create a new Puzzle wallet adapter
|
|
86
|
+
* @param config Adapter configuration
|
|
87
|
+
*/
|
|
88
|
+
constructor(config?: PuzzleWalletAdapterConfig);
|
|
89
|
+
/**
|
|
90
|
+
* Check if Puzzle wallet is available
|
|
91
|
+
*/
|
|
92
|
+
private _checkAvailability;
|
|
93
|
+
/**
|
|
94
|
+
* Connect to Puzzle wallet
|
|
95
|
+
* @param network The network to connect to
|
|
96
|
+
* @returns The connected account
|
|
97
|
+
*/
|
|
98
|
+
connect(network: Network, decryptPermission: WalletDecryptPermission, programs?: string[]): Promise<Account>;
|
|
99
|
+
/**
|
|
100
|
+
* Disconnect from Puzzle wallet
|
|
101
|
+
*/
|
|
102
|
+
disconnect(): Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* Sign a message with Puzzle wallet
|
|
105
|
+
* @param message The message to sign
|
|
106
|
+
* @returns The signed message
|
|
107
|
+
*/
|
|
108
|
+
signMessage(message: Uint8Array): Promise<Uint8Array>;
|
|
109
|
+
decrypt(cipherText: string): Promise<string>;
|
|
110
|
+
/**
|
|
111
|
+
* Execute a transaction with Puzzle wallet
|
|
112
|
+
* @param options Transaction options
|
|
113
|
+
* @returns The executed temporary transaction ID
|
|
114
|
+
*/
|
|
115
|
+
executeTransaction(options: TransactionOptions): Promise<{
|
|
116
|
+
transactionId: string;
|
|
117
|
+
}>;
|
|
118
|
+
/**
|
|
119
|
+
* Get transaction status
|
|
120
|
+
* @param transactionId The transaction ID
|
|
121
|
+
* @returns The transaction status
|
|
122
|
+
*/
|
|
123
|
+
transactionStatus(transactionId: string): Promise<TransactionStatusResponse>;
|
|
124
|
+
/**
|
|
125
|
+
* Request records from Leo wallet
|
|
126
|
+
* @param program The program to request records from
|
|
127
|
+
* @param includePlaintext Whether to include plaintext on each record
|
|
128
|
+
* @returns The records
|
|
129
|
+
*/
|
|
130
|
+
requestRecords(program: string): Promise<unknown[]>;
|
|
131
|
+
/**
|
|
132
|
+
* Switch the network
|
|
133
|
+
* @param network The network to switch to
|
|
134
|
+
*/
|
|
135
|
+
switchNetwork(_network: Network): Promise<void>;
|
|
136
|
+
/**
|
|
137
|
+
* Execute a deployment
|
|
138
|
+
* @param deployment The deployment to execute
|
|
139
|
+
* @returns The executed transaction ID
|
|
140
|
+
*/
|
|
141
|
+
executeDeployment(_deployment: AleoDeployment): Promise<{
|
|
142
|
+
transactionId: string;
|
|
143
|
+
}>;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export { PUZZLE_NETWORK_MAP, PuzzleWalletAdapter, type PuzzleWalletAdapterConfig, type PuzzleWindow };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { Network, Account, TransactionOptions, TransactionStatusResponse } from '@provablehq/aleo-types';
|
|
2
|
+
import { WalletName, WalletDecryptPermission, WalletReadyState, AleoDeployment } from '@provablehq/aleo-wallet-standard';
|
|
3
|
+
import { BaseAleoWalletAdapter } from '@provablehq/aleo-wallet-adaptor-core';
|
|
4
|
+
import { Network as Network$1 } from '@puzzlehq/sdk-core';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Puzzle window interface
|
|
8
|
+
*/
|
|
9
|
+
interface PuzzleWindow extends Window {
|
|
10
|
+
puzzle?: {
|
|
11
|
+
connected: boolean;
|
|
12
|
+
connect(): Promise<unknown>;
|
|
13
|
+
disconnect(): Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Puzzle wallet adapter configuration
|
|
18
|
+
*/
|
|
19
|
+
interface PuzzleWalletAdapterConfig {
|
|
20
|
+
/**
|
|
21
|
+
* Application name
|
|
22
|
+
*/
|
|
23
|
+
appName?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Application icon URL
|
|
26
|
+
*/
|
|
27
|
+
appIconUrl?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Application description
|
|
30
|
+
*/
|
|
31
|
+
appDescription?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Program ID permissions by network
|
|
34
|
+
*/
|
|
35
|
+
programIdPermissions?: Record<string, string[]>;
|
|
36
|
+
}
|
|
37
|
+
declare const PUZZLE_NETWORK_MAP: Record<Network, Network$1>;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Puzzle wallet adapter
|
|
41
|
+
*/
|
|
42
|
+
declare class PuzzleWalletAdapter extends BaseAleoWalletAdapter {
|
|
43
|
+
/**
|
|
44
|
+
* The wallet name
|
|
45
|
+
*/
|
|
46
|
+
name: WalletName<"Puzzle Wallet">;
|
|
47
|
+
/**
|
|
48
|
+
* The wallet URL
|
|
49
|
+
*/
|
|
50
|
+
url: string;
|
|
51
|
+
/**
|
|
52
|
+
* The wallet icon (base64-encoded SVG)
|
|
53
|
+
*/
|
|
54
|
+
icon: string;
|
|
55
|
+
/**
|
|
56
|
+
* The window object
|
|
57
|
+
*/
|
|
58
|
+
private _window;
|
|
59
|
+
/**
|
|
60
|
+
* App name
|
|
61
|
+
*/
|
|
62
|
+
private _appName;
|
|
63
|
+
/**
|
|
64
|
+
* App icon URL
|
|
65
|
+
*/
|
|
66
|
+
private _appIconUrl?;
|
|
67
|
+
/**
|
|
68
|
+
* App description
|
|
69
|
+
*/
|
|
70
|
+
private _appDescription?;
|
|
71
|
+
/**
|
|
72
|
+
* Current network
|
|
73
|
+
*/
|
|
74
|
+
network: Network;
|
|
75
|
+
/**
|
|
76
|
+
* The wallet's decrypt permission
|
|
77
|
+
*/
|
|
78
|
+
decryptPermission: WalletDecryptPermission;
|
|
79
|
+
_readyState: WalletReadyState;
|
|
80
|
+
/**
|
|
81
|
+
* Public key
|
|
82
|
+
*/
|
|
83
|
+
private _publicKey;
|
|
84
|
+
/**
|
|
85
|
+
* Create a new Puzzle wallet adapter
|
|
86
|
+
* @param config Adapter configuration
|
|
87
|
+
*/
|
|
88
|
+
constructor(config?: PuzzleWalletAdapterConfig);
|
|
89
|
+
/**
|
|
90
|
+
* Check if Puzzle wallet is available
|
|
91
|
+
*/
|
|
92
|
+
private _checkAvailability;
|
|
93
|
+
/**
|
|
94
|
+
* Connect to Puzzle wallet
|
|
95
|
+
* @param network The network to connect to
|
|
96
|
+
* @returns The connected account
|
|
97
|
+
*/
|
|
98
|
+
connect(network: Network, decryptPermission: WalletDecryptPermission, programs?: string[]): Promise<Account>;
|
|
99
|
+
/**
|
|
100
|
+
* Disconnect from Puzzle wallet
|
|
101
|
+
*/
|
|
102
|
+
disconnect(): Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* Sign a message with Puzzle wallet
|
|
105
|
+
* @param message The message to sign
|
|
106
|
+
* @returns The signed message
|
|
107
|
+
*/
|
|
108
|
+
signMessage(message: Uint8Array): Promise<Uint8Array>;
|
|
109
|
+
decrypt(cipherText: string): Promise<string>;
|
|
110
|
+
/**
|
|
111
|
+
* Execute a transaction with Puzzle wallet
|
|
112
|
+
* @param options Transaction options
|
|
113
|
+
* @returns The executed temporary transaction ID
|
|
114
|
+
*/
|
|
115
|
+
executeTransaction(options: TransactionOptions): Promise<{
|
|
116
|
+
transactionId: string;
|
|
117
|
+
}>;
|
|
118
|
+
/**
|
|
119
|
+
* Get transaction status
|
|
120
|
+
* @param transactionId The transaction ID
|
|
121
|
+
* @returns The transaction status
|
|
122
|
+
*/
|
|
123
|
+
transactionStatus(transactionId: string): Promise<TransactionStatusResponse>;
|
|
124
|
+
/**
|
|
125
|
+
* Request records from Leo wallet
|
|
126
|
+
* @param program The program to request records from
|
|
127
|
+
* @param includePlaintext Whether to include plaintext on each record
|
|
128
|
+
* @returns The records
|
|
129
|
+
*/
|
|
130
|
+
requestRecords(program: string): Promise<unknown[]>;
|
|
131
|
+
/**
|
|
132
|
+
* Switch the network
|
|
133
|
+
* @param network The network to switch to
|
|
134
|
+
*/
|
|
135
|
+
switchNetwork(_network: Network): Promise<void>;
|
|
136
|
+
/**
|
|
137
|
+
* Execute a deployment
|
|
138
|
+
* @param deployment The deployment to execute
|
|
139
|
+
* @returns The executed transaction ID
|
|
140
|
+
*/
|
|
141
|
+
executeDeployment(_deployment: AleoDeployment): Promise<{
|
|
142
|
+
transactionId: string;
|
|
143
|
+
}>;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export { PUZZLE_NETWORK_MAP, PuzzleWalletAdapter, type PuzzleWalletAdapterConfig, type PuzzleWindow };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
PUZZLE_NETWORK_MAP: () => PUZZLE_NETWORK_MAP,
|
|
24
|
+
PuzzleWalletAdapter: () => PuzzleWalletAdapter
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(src_exports);
|
|
27
|
+
|
|
28
|
+
// src/PuzzleWalletAdapter.ts
|
|
29
|
+
var import_aleo_types2 = require("@provablehq/aleo-types");
|
|
30
|
+
var import_aleo_wallet_standard = require("@provablehq/aleo-wallet-standard");
|
|
31
|
+
var import_aleo_wallet_adaptor_core = require("@provablehq/aleo-wallet-adaptor-core");
|
|
32
|
+
var import_sdk_core2 = require("@puzzlehq/sdk-core");
|
|
33
|
+
|
|
34
|
+
// src/types.ts
|
|
35
|
+
var import_aleo_types = require("@provablehq/aleo-types");
|
|
36
|
+
var import_sdk_core = require("@puzzlehq/sdk-core");
|
|
37
|
+
var PUZZLE_NETWORK_MAP = {
|
|
38
|
+
[import_aleo_types.Network.MAINNET]: import_sdk_core.Network.AleoMainnet,
|
|
39
|
+
[import_aleo_types.Network.TESTNET3]: import_sdk_core.Network.AleoTestnet,
|
|
40
|
+
[import_aleo_types.Network.CANARY]: import_sdk_core.Network.AleoTestnet
|
|
41
|
+
};
|
|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wU92jjEh3wWp8TBIgLIlViATHIYsHi9L0fxcduHwOIO0r1iRG+42lqyAHaepVJ82ofoDJQ/ut1+r9hPSkkT8enuULbN0wUIlr8ZC3UBt41SFp23Dcq1/n1YESJHzNHG4qEubZjEDYnXOQVdg1Dz1iiJEFzMQlioQGrdC0nf7wvvYLUkscP1jSJETuchmKi15R/h0sYzSoEfQo/4JYUofk0tcWSiYmTh9WKVHsyp+BuLLkZkVUZI2Jgoj+bp0viC+WLrtEiQ4MhtYMMwjF3uAQWJpItxKfxMI14ZLkgK0xO7IpM4nbRxpYsTfVo1CNUUfLpHm2NC4kRW1XMbmwmEA3n2UqDSi4Rzkgk0cBtdpMjSnAXhCZ2ac87Y7c4QCRUpr09zEYxil2KVNiS4p2rtpnXBIvW9cABPbdWAjRE9fy7hSj+irayw0MUL9nszLXnXzNuWApa2NJyeNZSzKKSQpUfzbeiaiRbGEjEjZd42c0ocGim7QClqR4zhAJ7aeMcqYSN7xq9Wh9Sz7NHCFFYjBS6+vkf6YhfQ3h4NRY7Etic4WpBY+TTO15eCFzvdwm94USa7vh4pfKn7+3Uj38Zg63eaxI+UMv+YvJcvqgN97RQuDqUQpj1rtsKTBk0AoQEURwnTLy2BpCjuFft1+wSPPvYgajVi6Kke9G4iSoFMRTP/z/oTupY0+sG78+/X26f6dY8ofmg4IbPn+cWdA0nBTHTFB3HOc8xd5bnLLGeF/8ocz3kcVp2kiEbqsyz0f6H/C/1f6P9C/xf6v9D/hf4v9H+h/wv9v77rAg==";
|
|
45
|
+
|
|
46
|
+
// src/PuzzleWalletAdapter.ts
|
|
47
|
+
var PuzzleWalletAdapter = class extends import_aleo_wallet_adaptor_core.BaseAleoWalletAdapter {
|
|
48
|
+
/**
|
|
49
|
+
* Create a new Puzzle wallet adapter
|
|
50
|
+
* @param config Adapter configuration
|
|
51
|
+
*/
|
|
52
|
+
constructor(config) {
|
|
53
|
+
super();
|
|
54
|
+
/**
|
|
55
|
+
* The wallet name
|
|
56
|
+
*/
|
|
57
|
+
this.name = "Puzzle Wallet";
|
|
58
|
+
/**
|
|
59
|
+
* The wallet URL
|
|
60
|
+
*/
|
|
61
|
+
this.url = "https://puzzle.online/wallet";
|
|
62
|
+
/**
|
|
63
|
+
* The wallet icon (base64-encoded SVG)
|
|
64
|
+
*/
|
|
65
|
+
this.icon = PuzzleIcon;
|
|
66
|
+
/**
|
|
67
|
+
* Current network
|
|
68
|
+
*/
|
|
69
|
+
this.network = import_aleo_types2.Network.TESTNET3;
|
|
70
|
+
/**
|
|
71
|
+
* The wallet's decrypt permission
|
|
72
|
+
*/
|
|
73
|
+
this.decryptPermission = import_aleo_wallet_standard.WalletDecryptPermission.NoDecrypt;
|
|
74
|
+
this._readyState = typeof window === "undefined" || typeof document === "undefined" ? import_aleo_wallet_standard.WalletReadyState.UNSUPPORTED : import_aleo_wallet_standard.WalletReadyState.NOT_DETECTED;
|
|
75
|
+
/**
|
|
76
|
+
* Public key
|
|
77
|
+
*/
|
|
78
|
+
this._publicKey = "";
|
|
79
|
+
this._appName = config?.appName || "Aleo App";
|
|
80
|
+
this._appIconUrl = config?.appIconUrl;
|
|
81
|
+
this._appDescription = config?.appDescription;
|
|
82
|
+
this._checkAvailability();
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Check if Puzzle wallet is available
|
|
86
|
+
*/
|
|
87
|
+
_checkAvailability() {
|
|
88
|
+
if (typeof window === "undefined") {
|
|
89
|
+
this.readyState = import_aleo_wallet_standard.WalletReadyState.UNSUPPORTED;
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
this._window = window;
|
|
93
|
+
if (this._window.puzzle) {
|
|
94
|
+
this.readyState = import_aleo_wallet_standard.WalletReadyState.INSTALLED;
|
|
95
|
+
} else {
|
|
96
|
+
const isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
|
|
97
|
+
if (isMobile) {
|
|
98
|
+
this.readyState = import_aleo_wallet_standard.WalletReadyState.LOADABLE;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Connect to Puzzle wallet
|
|
104
|
+
* @param network The network to connect to
|
|
105
|
+
* @returns The connected account
|
|
106
|
+
*/
|
|
107
|
+
async connect(network, decryptPermission, programs) {
|
|
108
|
+
try {
|
|
109
|
+
if (this.readyState !== import_aleo_wallet_standard.WalletReadyState.INSTALLED) {
|
|
110
|
+
throw new import_aleo_wallet_adaptor_core.WalletConnectionError("Puzzle Wallet is not available");
|
|
111
|
+
}
|
|
112
|
+
const response = await (0, import_sdk_core2.connect)({
|
|
113
|
+
dAppInfo: {
|
|
114
|
+
name: this._appName,
|
|
115
|
+
description: this._appDescription,
|
|
116
|
+
iconUrl: this._appIconUrl
|
|
117
|
+
},
|
|
118
|
+
permissions: {
|
|
119
|
+
programIds: {
|
|
120
|
+
[PUZZLE_NETWORK_MAP[network]]: programs
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
if (!response || typeof response !== "object" || !("connection" in response)) {
|
|
125
|
+
throw new import_aleo_wallet_adaptor_core.WalletConnectionError("Invalid response from wallet");
|
|
126
|
+
}
|
|
127
|
+
this.network = network;
|
|
128
|
+
this.decryptPermission = decryptPermission;
|
|
129
|
+
const address = response.connection?.address;
|
|
130
|
+
if (!address) {
|
|
131
|
+
throw new import_aleo_wallet_adaptor_core.WalletConnectionError("No address returned from wallet");
|
|
132
|
+
}
|
|
133
|
+
this._publicKey = address;
|
|
134
|
+
const account = {
|
|
135
|
+
address: this._publicKey
|
|
136
|
+
};
|
|
137
|
+
this.account = account;
|
|
138
|
+
this.emit("connect", account);
|
|
139
|
+
return account;
|
|
140
|
+
} catch (err) {
|
|
141
|
+
this.emit("error", err instanceof Error ? err : new Error(String(err)));
|
|
142
|
+
throw new import_aleo_wallet_adaptor_core.WalletConnectionError(err instanceof Error ? err.message : "Connection failed");
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Disconnect from Puzzle wallet
|
|
147
|
+
*/
|
|
148
|
+
async disconnect() {
|
|
149
|
+
try {
|
|
150
|
+
await (0, import_sdk_core2.disconnect)();
|
|
151
|
+
this._publicKey = "";
|
|
152
|
+
this.account = void 0;
|
|
153
|
+
this.emit("disconnect");
|
|
154
|
+
} catch (err) {
|
|
155
|
+
this.emit("error", err instanceof Error ? err : new Error(String(err)));
|
|
156
|
+
throw new import_aleo_wallet_adaptor_core.WalletDisconnectionError(
|
|
157
|
+
err instanceof Error ? err.message : "Disconnection failed"
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Sign a message with Puzzle wallet
|
|
163
|
+
* @param message The message to sign
|
|
164
|
+
* @returns The signed message
|
|
165
|
+
*/
|
|
166
|
+
async signMessage(message) {
|
|
167
|
+
if (!this._publicKey || !this.account) {
|
|
168
|
+
throw new import_aleo_wallet_adaptor_core.WalletNotConnectedError();
|
|
169
|
+
}
|
|
170
|
+
try {
|
|
171
|
+
const signature = await (0, import_sdk_core2.requestSignature)({
|
|
172
|
+
message: message.toString(),
|
|
173
|
+
address: this._publicKey
|
|
174
|
+
});
|
|
175
|
+
return new TextEncoder().encode(signature.signature);
|
|
176
|
+
} catch (error) {
|
|
177
|
+
throw new import_aleo_wallet_adaptor_core.WalletSignMessageError(
|
|
178
|
+
error instanceof Error ? error.message : "Failed to sign message"
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
async decrypt(cipherText) {
|
|
183
|
+
if (!this._publicKey || !this.account) {
|
|
184
|
+
throw new import_aleo_wallet_adaptor_core.WalletNotConnectedError();
|
|
185
|
+
}
|
|
186
|
+
switch (this.decryptPermission) {
|
|
187
|
+
case import_aleo_wallet_standard.WalletDecryptPermission.NoDecrypt:
|
|
188
|
+
throw new import_aleo_wallet_adaptor_core.WalletDecryptionNotAllowedError();
|
|
189
|
+
case import_aleo_wallet_standard.WalletDecryptPermission.UponRequest:
|
|
190
|
+
case import_aleo_wallet_adaptor_core.DecryptPermission.AutoDecrypt:
|
|
191
|
+
case import_aleo_wallet_adaptor_core.DecryptPermission.OnChainHistory: {
|
|
192
|
+
try {
|
|
193
|
+
const text = await (0, import_sdk_core2.decrypt)({ ciphertexts: [cipherText] });
|
|
194
|
+
return text.plaintexts[0];
|
|
195
|
+
} catch (error) {
|
|
196
|
+
throw new import_aleo_wallet_adaptor_core.WalletDecryptionError(
|
|
197
|
+
error instanceof Error ? error.message : "Failed to decrypt"
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
default:
|
|
202
|
+
throw new import_aleo_wallet_adaptor_core.WalletDecryptionError();
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Execute a transaction with Puzzle wallet
|
|
207
|
+
* @param options Transaction options
|
|
208
|
+
* @returns The executed temporary transaction ID
|
|
209
|
+
*/
|
|
210
|
+
async executeTransaction(options) {
|
|
211
|
+
if (!this._publicKey || !this.account) {
|
|
212
|
+
throw new import_aleo_wallet_adaptor_core.WalletNotConnectedError();
|
|
213
|
+
}
|
|
214
|
+
if (options.privateFee) {
|
|
215
|
+
throw new import_aleo_wallet_adaptor_core.WalletTransactionError("Private fee is not supported by Puzzle wallet");
|
|
216
|
+
}
|
|
217
|
+
try {
|
|
218
|
+
const fee = options.fee ? options.fee / 1e6 : 1e-3;
|
|
219
|
+
const requestData = {
|
|
220
|
+
type: import_sdk_core2.EventType.Execute,
|
|
221
|
+
programId: options.program,
|
|
222
|
+
functionId: options.function,
|
|
223
|
+
fee,
|
|
224
|
+
inputs: options.inputs,
|
|
225
|
+
address: this._publicKey,
|
|
226
|
+
network: PUZZLE_NETWORK_MAP[this.network]
|
|
227
|
+
};
|
|
228
|
+
const result = await (0, import_sdk_core2.requestCreateEvent)(requestData);
|
|
229
|
+
if (result.error) {
|
|
230
|
+
throw new import_aleo_wallet_adaptor_core.WalletTransactionError(result.error);
|
|
231
|
+
}
|
|
232
|
+
if (!result.eventId) {
|
|
233
|
+
throw new import_aleo_wallet_adaptor_core.WalletTransactionError("Could not create transaction");
|
|
234
|
+
}
|
|
235
|
+
return {
|
|
236
|
+
transactionId: result.eventId
|
|
237
|
+
};
|
|
238
|
+
} catch (error) {
|
|
239
|
+
console.error("Puzzle Wallet executeTransaction error", error);
|
|
240
|
+
if (error instanceof import_aleo_wallet_adaptor_core.WalletError) {
|
|
241
|
+
throw error;
|
|
242
|
+
}
|
|
243
|
+
throw new import_aleo_wallet_adaptor_core.WalletTransactionError(
|
|
244
|
+
error instanceof Error ? error.message : "Failed to execute transaction"
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Get transaction status
|
|
250
|
+
* @param transactionId The transaction ID
|
|
251
|
+
* @returns The transaction status
|
|
252
|
+
*/
|
|
253
|
+
async transactionStatus(transactionId) {
|
|
254
|
+
if (!this._publicKey || !this.account) {
|
|
255
|
+
throw new import_aleo_wallet_adaptor_core.WalletNotConnectedError();
|
|
256
|
+
}
|
|
257
|
+
try {
|
|
258
|
+
const result = await (0, import_sdk_core2.getEvent)({
|
|
259
|
+
id: transactionId,
|
|
260
|
+
address: this._publicKey,
|
|
261
|
+
network: PUZZLE_NETWORK_MAP[this.network]
|
|
262
|
+
});
|
|
263
|
+
return {
|
|
264
|
+
status: result.event?.status || import_aleo_types2.TransactionStatus.PENDING,
|
|
265
|
+
transactionId: result.event?.transactionId,
|
|
266
|
+
error: result.event?.error
|
|
267
|
+
};
|
|
268
|
+
} catch (error) {
|
|
269
|
+
throw new import_aleo_wallet_adaptor_core.WalletTransactionError(
|
|
270
|
+
error instanceof Error ? error.message : "Failed to get transaction status"
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Request records from Leo wallet
|
|
276
|
+
* @param program The program to request records from
|
|
277
|
+
* @param includePlaintext Whether to include plaintext on each record
|
|
278
|
+
* @returns The records
|
|
279
|
+
*/
|
|
280
|
+
async requestRecords(program) {
|
|
281
|
+
if (!this._publicKey || !this.account) {
|
|
282
|
+
throw new import_aleo_wallet_adaptor_core.WalletNotConnectedError();
|
|
283
|
+
}
|
|
284
|
+
try {
|
|
285
|
+
const result = await (0, import_sdk_core2.getRecords)({
|
|
286
|
+
filter: {
|
|
287
|
+
programIds: [program],
|
|
288
|
+
status: "All"
|
|
289
|
+
},
|
|
290
|
+
address: this._publicKey,
|
|
291
|
+
network: PUZZLE_NETWORK_MAP[this.network]
|
|
292
|
+
});
|
|
293
|
+
return result?.records || [];
|
|
294
|
+
} catch (error) {
|
|
295
|
+
throw new import_aleo_wallet_adaptor_core.WalletError(error instanceof Error ? error.message : "Failed to request records");
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Switch the network
|
|
300
|
+
* @param network The network to switch to
|
|
301
|
+
*/
|
|
302
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
303
|
+
async switchNetwork(_network) {
|
|
304
|
+
console.error("Puzzle Wallet does not support switching networks");
|
|
305
|
+
throw new import_aleo_wallet_adaptor_core.MethodNotImplementedError("switchNetwork");
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Execute a deployment
|
|
309
|
+
* @param deployment The deployment to execute
|
|
310
|
+
* @returns The executed transaction ID
|
|
311
|
+
*/
|
|
312
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
313
|
+
async executeDeployment(_deployment) {
|
|
314
|
+
throw new import_aleo_wallet_adaptor_core.MethodNotImplementedError("executeDeployment");
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
318
|
+
0 && (module.exports = {
|
|
319
|
+
PUZZLE_NETWORK_MAP,
|
|
320
|
+
PuzzleWalletAdapter
|
|
321
|
+
});
|