@provablehq/veil-aleo-wallet-adapter 0.4.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Provable Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,69 @@
1
+ # @provablehq/veil-aleo-wallet-adapter
2
+
3
+ Adapts a Provable/Aleo wallet-standard adapter (Shield, Leo, Puzzle, Fox, …) into
4
+ the abstract `@provablehq/veil-core` account and transport interfaces.
5
+
6
+ Reach for this when a connected wallet — not the app — should hold the keys and
7
+ records and prove transactions. The adapter keeps signing, decryption, record
8
+ lookup, and proving inside the wallet, so the app carries no key material. It
9
+ turns any standard-conforming adapter into the `account` and `transport` a Veil
10
+ client is built from.
11
+
12
+ ## Installation
13
+
14
+ ```sh
15
+ pnpm add @provablehq/veil-aleo-wallet-adapter @provablehq/veil-core
16
+ ```
17
+
18
+ The concrete wallet adapter packages are optional peers — install only the ones
19
+ for the wallets a developer supports:
20
+
21
+ ```sh
22
+ pnpm add @provablehq/aleo-wallet-adaptor-core # base adapter class
23
+ pnpm add @provablehq/aleo-wallet-adaptor-leo # e.g. Leo
24
+ ```
25
+
26
+ `@provablehq/aleo-wallet-adaptor-core` is an optional peer, so nothing in this
27
+ package statically imports it — `fromWalletAdapter` works on any object matching
28
+ the adapter shape.
29
+
30
+ ## Usage
31
+
32
+ Connect a wallet adapter, then hand it to `fromWalletAdapter` to get a Veil
33
+ `account` and `transport`. The transport handles wallet operations
34
+ (`executeTransaction`, `decrypt`, `requestRecords`, …); pair it with `http()`
35
+ through `fallback()` so read methods (`getBlock`, `getBalance`) still resolve.
36
+
37
+ ```ts
38
+ import { LeoWalletAdapter } from '@provablehq/aleo-wallet-adaptor-leo'
39
+ import { fromWalletAdapter } from '@provablehq/veil-aleo-wallet-adapter'
40
+ import { createWalletClient, http, fallback } from '@provablehq/veil-core'
41
+
42
+ const wallet = new LeoWalletAdapter()
43
+ await wallet.connect(network, decryptPermission)
44
+
45
+ const { account, transport } = fromWalletAdapter(wallet)
46
+
47
+ const client = createWalletClient({
48
+ account,
49
+ transport: fallback([transport, http('https://api.provable.com/v2')]),
50
+ })
51
+ ```
52
+
53
+ `fromWalletAdapter` is the primary entry point. It composes the two lower-level
54
+ helpers, `rpcAccountFromAdapter` and `transportFromAdapter`, which are exported
55
+ if a caller needs the account or transport on its own. The adapter must already
56
+ be connected — the account throws otherwise.
57
+
58
+ The package also exports the `AleoWalletAdapter` interface (the post-connect
59
+ method subset Veil invokes), the `AnyWalletAdapter` union (that interface or the
60
+ upstream `BaseAleoWalletAdapter`), and the privacy-feature types
61
+ (`InputRequest`, `RecordFilters`, `ConnectOptions`, `RecordAccessGrant`,
62
+ `AlgorithmGrant`, …) so a call site can import them alongside `fromWalletAdapter`.
63
+
64
+ ## Where this fits
65
+
66
+ Most React apps use `@provablehq/veil-aleo-react-hooks` and its `VeilProvider`, which wraps this
67
+ package and manages connection state for the caller. `@provablehq/veil-aleo-wallet-adapter` is
68
+ the framework-agnostic layer underneath — reach for it directly in scripts,
69
+ non-React apps, or when building a custom provider.
@@ -0,0 +1,148 @@
1
+ import { Network, TransactionStatusResponse, RecordStatusFilter, TxHistoryResult, RpcAccount, Transport } from '@provablehq/veil-core';
2
+ export { AlgorithmGrant, ConnectOptions, InputRequest, Network, RecordAccessGrant, RecordFilters, RecordView, TransactionInput, TransactionStatusResponse, TxHistoryResult } from '@provablehq/veil-core';
3
+ import { TransactionOptions } from '@provablehq/aleo-types';
4
+ export { TransactionOptions } from '@provablehq/aleo-types';
5
+ import { AleoDeployment } from '@provablehq/aleo-wallet-standard';
6
+ import { BaseAleoWalletAdapter } from '@provablehq/aleo-wallet-adaptor-core';
7
+ export { BaseAleoWalletAdapter } from '@provablehq/aleo-wallet-adaptor-core';
8
+
9
+ /**
10
+ * @provablehq/veil-aleo-wallet-adapter
11
+ *
12
+ * Wraps @provablehq/aleo-wallet-adaptor-core into veil's
13
+ * Account and Transport interfaces.
14
+ *
15
+ * Usage with any wallet adapter (Leo, Puzzle, Fox, Shield):
16
+ *
17
+ * import { LeoWalletAdapter } from '@provablehq/aleo-wallet-adaptor-leo'
18
+ * import { fromWalletAdapter } from '@provablehq/veil-aleo-wallet-adapter'
19
+ * import { createWalletClient, http, fallback } from '@provablehq/veil-core'
20
+ *
21
+ * const leoWallet = new LeoWalletAdapter()
22
+ * await leoWallet.connect(Network.MAINNET, DecryptPermission.UponRequest)
23
+ *
24
+ * const { account, transport } = fromWalletAdapter(leoWallet)
25
+ *
26
+ * const walletClient = createWalletClient({
27
+ * account,
28
+ * transport: fallback([transport, http('https://api.provable.com/v2')]),
29
+ * })
30
+ */
31
+
32
+ /**
33
+ * The post-connect subset of the Provable wallet standard's `WalletAdapter`
34
+ * interface — covers the methods veil invokes after a wallet is already
35
+ * connected. `connect` and `disconnect` are deliberately omitted; consumers
36
+ * call those on the adapter directly before passing it to `fromWalletAdapter`.
37
+ *
38
+ * All standard-conforming adapters (Leo, Puzzle, Fox, Shield) satisfy this
39
+ * shape because their classes implement every method declared here.
40
+ * Implementations that don't support a given feature should throw at runtime
41
+ * (the standard's `WalletFeatureNotAvailableError` contract).
42
+ */
43
+ interface AleoWalletAdapter {
44
+ /** The connected account. */
45
+ account?: {
46
+ address: string;
47
+ viewKey?: string;
48
+ privateKey?: string;
49
+ };
50
+ /** Whether the wallet is currently connected. */
51
+ connected: boolean;
52
+ /** The wallet's currently selected network. May be null before connect. */
53
+ network: Network | null;
54
+ /** Sign an arbitrary message — returns raw signature bytes. */
55
+ signMessage(message: Uint8Array): Promise<Uint8Array>;
56
+ /** Execute a program function — returns temporary transaction id. */
57
+ executeTransaction(options: TransactionOptions): Promise<{
58
+ transactionId: string;
59
+ }>;
60
+ /** Deploy a program — returns temporary transaction id. */
61
+ executeDeployment(deployment: AleoDeployment): Promise<{
62
+ transactionId: string;
63
+ }>;
64
+ /** Get the status of a submitted transaction. */
65
+ transactionStatus(transactionId: string): Promise<TransactionStatusResponse>;
66
+ /**
67
+ * Decrypt a record ciphertext using the wallet's view key.
68
+ *
69
+ * Throws `WalletAddressWithheldError` when the connection was made with
70
+ * `readAddress: false` — decryption would reveal the address.
71
+ */
72
+ decrypt(cipherText: string, tpk?: string, programId?: string, functionName?: string, index?: number): Promise<string>;
73
+ /**
74
+ * Request records for a program.
75
+ *
76
+ * Throws `WalletAddressWithheldError` when the connection was made with
77
+ * `readAddress: false`.
78
+ */
79
+ requestRecords(program: string, includePlaintext: boolean, statusFilter?: RecordStatusFilter): Promise<unknown[]>;
80
+ /**
81
+ * Get transition view keys for a transaction.
82
+ *
83
+ * Throws `WalletAddressWithheldError` when the connection was made with
84
+ * `readAddress: false`.
85
+ */
86
+ transitionViewKeys(transactionId: string): Promise<string[]>;
87
+ /** Switch the connected network. May throw if the wallet doesn't support it. */
88
+ switchNetwork(network: Network): Promise<void>;
89
+ /**
90
+ * Get transaction history for a program. May throw if the wallet doesn't support it.
91
+ *
92
+ * Throws `WalletAddressWithheldError` when the connection was made with
93
+ * `readAddress: false`.
94
+ */
95
+ requestTransactionHistory(program: string): Promise<TxHistoryResult>;
96
+ /**
97
+ * List the derived-input algorithms this wallet supports. Empty if none.
98
+ *
99
+ * Optional: wallets that predate the privacy feature omit it, in which case
100
+ * the transport reports no supported algorithms.
101
+ */
102
+ algorithmsSupported?(): Promise<string[]>;
103
+ }
104
+ /**
105
+ * Union of Veil's minimal interface and the real BaseAleoWalletAdapter.
106
+ * All public functions accept either shape — duck-typing handles
107
+ * the differences since both expose the same method signatures.
108
+ */
109
+ type AnyWalletAdapter = AleoWalletAdapter | BaseAleoWalletAdapter;
110
+ /**
111
+ * Creates an veil RpcAccount from a connected wallet adapter.
112
+ *
113
+ * The adapter must be connected (adapter.account must exist).
114
+ * Sign operations are delegated to the wallet.
115
+ */
116
+ declare function rpcAccountFromAdapter(adapter: AnyWalletAdapter): RpcAccount;
117
+ /**
118
+ * Creates an veil custom transport that routes wallet-specific
119
+ * operations through the adapter.
120
+ *
121
+ * This transport handles:
122
+ * - executeTransaction → adapter.executeTransaction()
123
+ * - deployProgram → adapter.executeDeployment()
124
+ * - signMessage → adapter.signMessage()
125
+ * - decrypt → adapter.decrypt()
126
+ * - requestRecords → adapter.requestRecords()
127
+ * - transactionStatus → adapter.transactionStatus()
128
+ * - transitionViewKeys → adapter.transitionViewKeys()
129
+ *
130
+ * Read operations (getBlock, getBalance, etc.) are NOT handled — pair
131
+ * with http() via fallback() for full coverage:
132
+ *
133
+ * fallback([transportFromAdapter(adapter), http(url)])
134
+ */
135
+ declare function transportFromAdapter(adapter: AnyWalletAdapter): Transport<'custom'>;
136
+ /**
137
+ * Creates both an veil account and transport from a connected
138
+ * wallet adapter. This is the primary entry point.
139
+ *
140
+ * const { account, transport } = fromWalletAdapter(leoWallet)
141
+ * const client = createWalletClient({ account, transport })
142
+ */
143
+ declare function fromWalletAdapter(adapter: AnyWalletAdapter): {
144
+ account: RpcAccount;
145
+ transport: Transport<'custom'>;
146
+ };
147
+
148
+ export { type AleoWalletAdapter, type AnyWalletAdapter, fromWalletAdapter, rpcAccountFromAdapter, transportFromAdapter };
package/dist/index.js ADDED
@@ -0,0 +1,103 @@
1
+ // src/index.ts
2
+ import { custom } from "@provablehq/veil-core";
3
+ function rpcAccountFromAdapter(adapter) {
4
+ if (!adapter.account) {
5
+ throw new Error(
6
+ "Wallet adapter is not connected. Call adapter.connect() before creating an account."
7
+ );
8
+ }
9
+ const address = adapter.account.address;
10
+ return {
11
+ type: "rpc",
12
+ address,
13
+ sign: (message) => adapter.signMessage(message),
14
+ signMessage: (message) => adapter.signMessage(message)
15
+ };
16
+ }
17
+ function transportFromAdapter(adapter) {
18
+ return custom({
19
+ key: "walletAdapter",
20
+ name: "Wallet Adapter Transport",
21
+ request: async ({ method, params }) => {
22
+ const p = params;
23
+ switch (method) {
24
+ case "executeTransaction": {
25
+ const options = {
26
+ program: p?.programName,
27
+ function: p?.functionName,
28
+ // Inputs may be Aleo-encoded strings or InputRequest objects the wallet
29
+ // fulfils (address/record/derived); pass them through untouched.
30
+ inputs: p?.inputs,
31
+ privateFee: p?.privateFee ?? false
32
+ };
33
+ if (p?.imports != null) {
34
+ options.imports = p.imports;
35
+ }
36
+ const result = await adapter.executeTransaction(options);
37
+ return result.transactionId;
38
+ }
39
+ case "deployProgram": {
40
+ const deployment = {
41
+ program: p?.program,
42
+ address: adapter.account?.address ?? "",
43
+ priorityFee: 0,
44
+ privateFee: p?.privateFee ?? false
45
+ };
46
+ const result = await adapter.executeDeployment(deployment);
47
+ return result.transactionId;
48
+ }
49
+ case "signMessage": {
50
+ return adapter.signMessage(p?.message);
51
+ }
52
+ case "decrypt":
53
+ return adapter.decrypt(
54
+ p?.cipherText,
55
+ p?.tpk,
56
+ p?.programId,
57
+ p?.functionName,
58
+ p?.index
59
+ );
60
+ case "requestRecords":
61
+ return adapter.requestRecords(
62
+ p?.program,
63
+ p?.includePlaintext ?? true,
64
+ p?.statusFilter
65
+ );
66
+ case "transactionStatus": {
67
+ return adapter.transactionStatus(p?.transactionId);
68
+ }
69
+ case "getTransitionViewKeys": {
70
+ return adapter.transitionViewKeys(p?.id);
71
+ }
72
+ case "algorithmsSupported": {
73
+ return adapter.algorithmsSupported ? adapter.algorithmsSupported() : [];
74
+ }
75
+ case "switchNetwork": {
76
+ return adapter.switchNetwork(p?.network);
77
+ }
78
+ case "requestTransactionHistory": {
79
+ return adapter.requestTransactionHistory(p?.program);
80
+ }
81
+ case "getChainId": {
82
+ return adapter.network;
83
+ }
84
+ default:
85
+ throw new Error(
86
+ `Wallet adapter transport does not handle method "${method}". Use fallback([transportFromAdapter(adapter), http(url)]) for read methods.`
87
+ );
88
+ }
89
+ }
90
+ });
91
+ }
92
+ function fromWalletAdapter(adapter) {
93
+ return {
94
+ account: rpcAccountFromAdapter(adapter),
95
+ transport: transportFromAdapter(adapter)
96
+ };
97
+ }
98
+ export {
99
+ fromWalletAdapter,
100
+ rpcAccountFromAdapter,
101
+ transportFromAdapter
102
+ };
103
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @provablehq/veil-aleo-wallet-adapter\n *\n * Wraps @provablehq/aleo-wallet-adaptor-core into veil's\n * Account and Transport interfaces.\n *\n * Usage with any wallet adapter (Leo, Puzzle, Fox, Shield):\n *\n * import { LeoWalletAdapter } from '@provablehq/aleo-wallet-adaptor-leo'\n * import { fromWalletAdapter } from '@provablehq/veil-aleo-wallet-adapter'\n * import { createWalletClient, http, fallback } from '@provablehq/veil-core'\n *\n * const leoWallet = new LeoWalletAdapter()\n * await leoWallet.connect(Network.MAINNET, DecryptPermission.UponRequest)\n *\n * const { account, transport } = fromWalletAdapter(leoWallet)\n *\n * const walletClient = createWalletClient({\n * account,\n * transport: fallback([transport, http('https://api.provable.com/v2')]),\n * })\n */\n\nimport { custom } from '@provablehq/veil-core'\nimport type { Network, RpcAccount, Transport, TransactionStatusResponse, TxHistoryResult } from '@provablehq/veil-core'\n\n// Import the real types from the Provable ecosystem\nimport type { TransactionOptions, TransactionInput } from '@provablehq/aleo-types'\nimport type { AleoDeployment } from '@provablehq/aleo-wallet-standard'\nimport type { RecordStatusFilter } from '@provablehq/veil-core'\nimport type { BaseAleoWalletAdapter } from '@provablehq/aleo-wallet-adaptor-core'\n\n// Re-export useful types so consumers don't need extra imports\nexport type { TransactionOptions } from '@provablehq/aleo-types'\nexport type { Network, TransactionStatusResponse, TxHistoryResult } from '@provablehq/veil-core'\nexport type { BaseAleoWalletAdapter } from '@provablehq/aleo-wallet-adaptor-core'\n\n// Re-export the privacy-feature types (Veil mirrors) so consumers can import them\n// from the wallet-adapter boundary alongside fromWalletAdapter.\n//\n// The upstream error classes (WalletAddressWithheldError, etc.) are deliberately\n// NOT re-exported here: @provablehq/aleo-wallet-adaptor-core is an OPTIONAL peer\n// dependency, and a value re-export would compile to a static runtime import,\n// breaking consumers who use fromWalletAdapter without installing -core. Consumers\n// that need to catch those classes import them from\n// @provablehq/aleo-wallet-adaptor-core directly.\nexport type {\n TransactionInput,\n InputRequest,\n RecordFilters,\n RecordView,\n ConnectOptions,\n RecordAccessGrant,\n AlgorithmGrant,\n} from '@provablehq/veil-core'\n\n// --------------------------------------------------------------------------\n// Wallet adapter interface — matches BaseAleoWalletAdapter from\n// @provablehq/aleo-wallet-adaptor-core\n// --------------------------------------------------------------------------\n\n/**\n * The post-connect subset of the Provable wallet standard's `WalletAdapter`\n * interface — covers the methods veil invokes after a wallet is already\n * connected. `connect` and `disconnect` are deliberately omitted; consumers\n * call those on the adapter directly before passing it to `fromWalletAdapter`.\n *\n * All standard-conforming adapters (Leo, Puzzle, Fox, Shield) satisfy this\n * shape because their classes implement every method declared here.\n * Implementations that don't support a given feature should throw at runtime\n * (the standard's `WalletFeatureNotAvailableError` contract).\n */\nexport interface AleoWalletAdapter {\n /** The connected account. */\n account?: { address: string; viewKey?: string; privateKey?: string }\n\n /** Whether the wallet is currently connected. */\n connected: boolean\n\n /** The wallet's currently selected network. May be null before connect. */\n network: Network | null\n\n /** Sign an arbitrary message — returns raw signature bytes. */\n signMessage(message: Uint8Array): Promise<Uint8Array>\n\n /** Execute a program function — returns temporary transaction id. */\n executeTransaction(options: TransactionOptions): Promise<{ transactionId: string }>\n\n /** Deploy a program — returns temporary transaction id. */\n executeDeployment(deployment: AleoDeployment): Promise<{ transactionId: string }>\n\n /** Get the status of a submitted transaction. */\n transactionStatus(transactionId: string): Promise<TransactionStatusResponse>\n\n /**\n * Decrypt a record ciphertext using the wallet's view key.\n *\n * Throws `WalletAddressWithheldError` when the connection was made with\n * `readAddress: false` — decryption would reveal the address.\n */\n decrypt(\n cipherText: string,\n tpk?: string,\n programId?: string,\n functionName?: string,\n index?: number,\n ): Promise<string>\n\n /**\n * Request records for a program.\n *\n * Throws `WalletAddressWithheldError` when the connection was made with\n * `readAddress: false`.\n */\n requestRecords(\n program: string,\n includePlaintext: boolean,\n statusFilter?: RecordStatusFilter,\n ): Promise<unknown[]>\n\n /**\n * Get transition view keys for a transaction.\n *\n * Throws `WalletAddressWithheldError` when the connection was made with\n * `readAddress: false`.\n */\n transitionViewKeys(transactionId: string): Promise<string[]>\n\n /** Switch the connected network. May throw if the wallet doesn't support it. */\n switchNetwork(network: Network): Promise<void>\n\n /**\n * Get transaction history for a program. May throw if the wallet doesn't support it.\n *\n * Throws `WalletAddressWithheldError` when the connection was made with\n * `readAddress: false`.\n */\n requestTransactionHistory(program: string): Promise<TxHistoryResult>\n\n /**\n * List the derived-input algorithms this wallet supports. Empty if none.\n *\n * Optional: wallets that predate the privacy feature omit it, in which case\n * the transport reports no supported algorithms.\n */\n algorithmsSupported?(): Promise<string[]>\n}\n\n/**\n * Union of Veil's minimal interface and the real BaseAleoWalletAdapter.\n * All public functions accept either shape — duck-typing handles\n * the differences since both expose the same method signatures.\n */\nexport type AnyWalletAdapter = AleoWalletAdapter | BaseAleoWalletAdapter\n\n// --------------------------------------------------------------------------\n// Account adapter\n// --------------------------------------------------------------------------\n\n/**\n * Creates an veil RpcAccount from a connected wallet adapter.\n *\n * The adapter must be connected (adapter.account must exist).\n * Sign operations are delegated to the wallet.\n */\nexport function rpcAccountFromAdapter(adapter: AnyWalletAdapter): RpcAccount {\n if (!adapter.account) {\n throw new Error(\n 'Wallet adapter is not connected. Call adapter.connect() before creating an account.',\n )\n }\n\n const address = adapter.account.address\n\n return {\n type: 'rpc',\n address,\n sign: (message: Uint8Array) => adapter.signMessage(message),\n signMessage: (message: Uint8Array) => adapter.signMessage(message),\n }\n}\n\n// --------------------------------------------------------------------------\n// Transport adapter\n// --------------------------------------------------------------------------\n\n/**\n * Creates an veil custom transport that routes wallet-specific\n * operations through the adapter.\n *\n * This transport handles:\n * - executeTransaction → adapter.executeTransaction()\n * - deployProgram → adapter.executeDeployment()\n * - signMessage → adapter.signMessage()\n * - decrypt → adapter.decrypt()\n * - requestRecords → adapter.requestRecords()\n * - transactionStatus → adapter.transactionStatus()\n * - transitionViewKeys → adapter.transitionViewKeys()\n *\n * Read operations (getBlock, getBalance, etc.) are NOT handled — pair\n * with http() via fallback() for full coverage:\n *\n * fallback([transportFromAdapter(adapter), http(url)])\n */\nexport function transportFromAdapter(adapter: AnyWalletAdapter): Transport<'custom'> {\n return custom({\n key: 'walletAdapter',\n name: 'Wallet Adapter Transport',\n request: async ({ method, params }) => {\n const p = params as Record<string, unknown> | undefined\n\n switch (method) {\n case 'executeTransaction': {\n const options: TransactionOptions = {\n program: p?.programName as string,\n function: p?.functionName as string,\n // Inputs may be Aleo-encoded strings or InputRequest objects the wallet\n // fulfils (address/record/derived); pass them through untouched.\n inputs: p?.inputs as TransactionInput[],\n privateFee: (p?.privateFee as boolean) ?? false,\n }\n if (p?.imports != null) {\n options.imports = p.imports as string[]\n }\n const result = await adapter.executeTransaction(options)\n return result.transactionId\n }\n\n case 'deployProgram': {\n // The wallet-standard `AleoDeployment` shape requires `priorityFee`,\n // but Veil's user-facing API treats fees as auto-estimated; pass 0 so\n // the wallet uses its own default.\n const deployment: AleoDeployment = {\n program: p?.program as string,\n address: adapter.account?.address ?? '',\n priorityFee: 0,\n privateFee: (p?.privateFee as boolean) ?? false,\n }\n const result = await adapter.executeDeployment(deployment)\n return result.transactionId\n }\n\n case 'signMessage': {\n return adapter.signMessage(p?.message as Uint8Array)\n }\n\n case 'decrypt':\n return adapter.decrypt(\n p?.cipherText as string,\n p?.tpk as string | undefined,\n p?.programId as string | undefined,\n p?.functionName as string | undefined,\n p?.index as number | undefined,\n )\n\n case 'requestRecords':\n return adapter.requestRecords(\n p?.program as string,\n (p?.includePlaintext as boolean) ?? true,\n p?.statusFilter as RecordStatusFilter | undefined,\n )\n\n case 'transactionStatus': {\n return adapter.transactionStatus(p?.transactionId as string)\n }\n\n case 'getTransitionViewKeys': {\n return adapter.transitionViewKeys(p?.id as string)\n }\n\n case 'algorithmsSupported': {\n return adapter.algorithmsSupported ? adapter.algorithmsSupported() : []\n }\n\n case 'switchNetwork': {\n // Cast: BaseAleoWalletAdapter expects @provablehq/aleo-types' Network\n // enum, AleoWalletAdapter expects @provablehq/veil-core's string-union Network.\n // Runtime values are identical strings.\n return (adapter.switchNetwork as (n: unknown) => Promise<void>)(p?.network)\n }\n\n case 'requestTransactionHistory': {\n return adapter.requestTransactionHistory(p?.program as string)\n }\n\n case 'getChainId': {\n return adapter.network\n }\n\n default:\n throw new Error(\n `Wallet adapter transport does not handle method \"${method}\". ` +\n 'Use fallback([transportFromAdapter(adapter), http(url)]) for read methods.',\n )\n }\n },\n })\n}\n\n// --------------------------------------------------------------------------\n// Convenience\n// --------------------------------------------------------------------------\n\n/**\n * Creates both an veil account and transport from a connected\n * wallet adapter. This is the primary entry point.\n *\n * const { account, transport } = fromWalletAdapter(leoWallet)\n * const client = createWalletClient({ account, transport })\n */\nexport function fromWalletAdapter(adapter: AnyWalletAdapter): {\n account: RpcAccount\n transport: Transport<'custom'>\n} {\n return {\n account: rpcAccountFromAdapter(adapter),\n transport: transportFromAdapter(adapter),\n }\n}\n"],"mappings":";AAuBA,SAAS,cAAc;AA8IhB,SAAS,sBAAsB,SAAuC;AAC3E,MAAI,CAAC,QAAQ,SAAS;AACpB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,UAAU,QAAQ,QAAQ;AAEhC,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,IACA,MAAM,CAAC,YAAwB,QAAQ,YAAY,OAAO;AAAA,IAC1D,aAAa,CAAC,YAAwB,QAAQ,YAAY,OAAO;AAAA,EACnE;AACF;AAwBO,SAAS,qBAAqB,SAAgD;AACnF,SAAO,OAAO;AAAA,IACZ,KAAK;AAAA,IACL,MAAM;AAAA,IACN,SAAS,OAAO,EAAE,QAAQ,OAAO,MAAM;AACrC,YAAM,IAAI;AAEV,cAAQ,QAAQ;AAAA,QACd,KAAK,sBAAsB;AACzB,gBAAM,UAA8B;AAAA,YAClC,SAAS,GAAG;AAAA,YACZ,UAAU,GAAG;AAAA;AAAA;AAAA,YAGb,QAAQ,GAAG;AAAA,YACX,YAAa,GAAG,cAA0B;AAAA,UAC5C;AACA,cAAI,GAAG,WAAW,MAAM;AACtB,oBAAQ,UAAU,EAAE;AAAA,UACtB;AACA,gBAAM,SAAS,MAAM,QAAQ,mBAAmB,OAAO;AACvD,iBAAO,OAAO;AAAA,QAChB;AAAA,QAEA,KAAK,iBAAiB;AAIpB,gBAAM,aAA6B;AAAA,YACjC,SAAS,GAAG;AAAA,YACZ,SAAS,QAAQ,SAAS,WAAW;AAAA,YACrC,aAAa;AAAA,YACb,YAAa,GAAG,cAA0B;AAAA,UAC5C;AACA,gBAAM,SAAS,MAAM,QAAQ,kBAAkB,UAAU;AACzD,iBAAO,OAAO;AAAA,QAChB;AAAA,QAEA,KAAK,eAAe;AAClB,iBAAO,QAAQ,YAAY,GAAG,OAAqB;AAAA,QACrD;AAAA,QAEA,KAAK;AACH,iBAAO,QAAQ;AAAA,YACb,GAAG;AAAA,YACH,GAAG;AAAA,YACH,GAAG;AAAA,YACH,GAAG;AAAA,YACH,GAAG;AAAA,UACL;AAAA,QAEF,KAAK;AACH,iBAAO,QAAQ;AAAA,YACb,GAAG;AAAA,YACF,GAAG,oBAAgC;AAAA,YACpC,GAAG;AAAA,UACL;AAAA,QAEF,KAAK,qBAAqB;AACxB,iBAAO,QAAQ,kBAAkB,GAAG,aAAuB;AAAA,QAC7D;AAAA,QAEA,KAAK,yBAAyB;AAC5B,iBAAO,QAAQ,mBAAmB,GAAG,EAAY;AAAA,QACnD;AAAA,QAEA,KAAK,uBAAuB;AAC1B,iBAAO,QAAQ,sBAAsB,QAAQ,oBAAoB,IAAI,CAAC;AAAA,QACxE;AAAA,QAEA,KAAK,iBAAiB;AAIpB,iBAAQ,QAAQ,cAAgD,GAAG,OAAO;AAAA,QAC5E;AAAA,QAEA,KAAK,6BAA6B;AAChC,iBAAO,QAAQ,0BAA0B,GAAG,OAAiB;AAAA,QAC/D;AAAA,QAEA,KAAK,cAAc;AACjB,iBAAO,QAAQ;AAAA,QACjB;AAAA,QAEA;AACE,gBAAM,IAAI;AAAA,YACR,oDAAoD,MAAM;AAAA,UAE5D;AAAA,MACJ;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAaO,SAAS,kBAAkB,SAGhC;AACA,SAAO;AAAA,IACL,SAAS,sBAAsB,OAAO;AAAA,IACtC,WAAW,qBAAqB,OAAO;AAAA,EACzC;AACF;","names":[]}
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@provablehq/veil-aleo-wallet-adapter",
3
+ "version": "0.4.0",
4
+ "description": "Aleo wallet adapter bindings for the Veil Aleo SDK.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/ProvableHQ/veil.git",
9
+ "directory": "packages/wallet-adapter"
10
+ },
11
+ "homepage": "https://github.com/ProvableHQ/veil#readme",
12
+ "type": "module",
13
+ "main": "dist/index.js",
14
+ "types": "dist/index.d.ts",
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "import": "./dist/index.js"
19
+ }
20
+ },
21
+ "sideEffects": false,
22
+ "files": [
23
+ "dist"
24
+ ],
25
+ "engines": {
26
+ "node": ">=18"
27
+ },
28
+ "publishConfig": {
29
+ "access": "public"
30
+ },
31
+ "peerDependencies": {
32
+ "@provablehq/aleo-wallet-adaptor-core": "*",
33
+ "@provablehq/veil-core": "0.4.0"
34
+ },
35
+ "peerDependenciesMeta": {
36
+ "@provablehq/aleo-wallet-adaptor-core": {
37
+ "optional": true
38
+ }
39
+ },
40
+ "devDependencies": {
41
+ "@provablehq/aleo-types": "1.0.0",
42
+ "@provablehq/aleo-wallet-adaptor-core": "1.0.0",
43
+ "@provablehq/aleo-wallet-standard": "1.0.0"
44
+ },
45
+ "scripts": {
46
+ "build": "tsup",
47
+ "typecheck": "tsc --noEmit"
48
+ }
49
+ }