@kadi.build/deploy-ability 0.0.1
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 +523 -0
- package/dist/constants.d.ts +82 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +82 -0
- package/dist/constants.js.map +1 -0
- package/dist/errors/certificate-error.d.ts +95 -0
- package/dist/errors/certificate-error.d.ts.map +1 -0
- package/dist/errors/certificate-error.js +111 -0
- package/dist/errors/certificate-error.js.map +1 -0
- package/dist/errors/deployment-error.d.ts +122 -0
- package/dist/errors/deployment-error.d.ts.map +1 -0
- package/dist/errors/deployment-error.js +185 -0
- package/dist/errors/deployment-error.js.map +1 -0
- package/dist/errors/index.d.ts +13 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +18 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/errors/profile-error.d.ts +106 -0
- package/dist/errors/profile-error.d.ts.map +1 -0
- package/dist/errors/profile-error.js +127 -0
- package/dist/errors/profile-error.js.map +1 -0
- package/dist/errors/provider-error.d.ts +104 -0
- package/dist/errors/provider-error.d.ts.map +1 -0
- package/dist/errors/provider-error.js +120 -0
- package/dist/errors/provider-error.js.map +1 -0
- package/dist/errors/wallet-error.d.ts +131 -0
- package/dist/errors/wallet-error.d.ts.map +1 -0
- package/dist/errors/wallet-error.js +154 -0
- package/dist/errors/wallet-error.js.map +1 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -0
- package/dist/targets/akash/bid-selectors.d.ts +251 -0
- package/dist/targets/akash/bid-selectors.d.ts.map +1 -0
- package/dist/targets/akash/bid-selectors.js +322 -0
- package/dist/targets/akash/bid-selectors.js.map +1 -0
- package/dist/targets/akash/bid-types.d.ts +297 -0
- package/dist/targets/akash/bid-types.d.ts.map +1 -0
- package/dist/targets/akash/bid-types.js +89 -0
- package/dist/targets/akash/bid-types.js.map +1 -0
- package/dist/targets/akash/blockchain-client.d.ts +577 -0
- package/dist/targets/akash/blockchain-client.d.ts.map +1 -0
- package/dist/targets/akash/blockchain-client.js +803 -0
- package/dist/targets/akash/blockchain-client.js.map +1 -0
- package/dist/targets/akash/certificate-manager.d.ts +228 -0
- package/dist/targets/akash/certificate-manager.d.ts.map +1 -0
- package/dist/targets/akash/certificate-manager.js +395 -0
- package/dist/targets/akash/certificate-manager.js.map +1 -0
- package/dist/targets/akash/constants.d.ts +231 -0
- package/dist/targets/akash/constants.d.ts.map +1 -0
- package/dist/targets/akash/constants.js +225 -0
- package/dist/targets/akash/constants.js.map +1 -0
- package/dist/targets/akash/deployer.d.ts +136 -0
- package/dist/targets/akash/deployer.d.ts.map +1 -0
- package/dist/targets/akash/deployer.js +599 -0
- package/dist/targets/akash/deployer.js.map +1 -0
- package/dist/targets/akash/environment.d.ts +241 -0
- package/dist/targets/akash/environment.d.ts.map +1 -0
- package/dist/targets/akash/environment.js +245 -0
- package/dist/targets/akash/environment.js.map +1 -0
- package/dist/targets/akash/index.d.ts +1113 -0
- package/dist/targets/akash/index.d.ts.map +1 -0
- package/dist/targets/akash/index.js +909 -0
- package/dist/targets/akash/index.js.map +1 -0
- package/dist/targets/akash/lease-monitor.d.ts +51 -0
- package/dist/targets/akash/lease-monitor.d.ts.map +1 -0
- package/dist/targets/akash/lease-monitor.js +110 -0
- package/dist/targets/akash/lease-monitor.js.map +1 -0
- package/dist/targets/akash/logs.d.ts +71 -0
- package/dist/targets/akash/logs.d.ts.map +1 -0
- package/dist/targets/akash/logs.js +311 -0
- package/dist/targets/akash/logs.js.map +1 -0
- package/dist/targets/akash/logs.types.d.ts +102 -0
- package/dist/targets/akash/logs.types.d.ts.map +1 -0
- package/dist/targets/akash/logs.types.js +9 -0
- package/dist/targets/akash/logs.types.js.map +1 -0
- package/dist/targets/akash/pricing.d.ts +247 -0
- package/dist/targets/akash/pricing.d.ts.map +1 -0
- package/dist/targets/akash/pricing.js +246 -0
- package/dist/targets/akash/pricing.js.map +1 -0
- package/dist/targets/akash/provider-client.d.ts +114 -0
- package/dist/targets/akash/provider-client.d.ts.map +1 -0
- package/dist/targets/akash/provider-client.js +318 -0
- package/dist/targets/akash/provider-client.js.map +1 -0
- package/dist/targets/akash/provider-metadata.d.ts +228 -0
- package/dist/targets/akash/provider-metadata.d.ts.map +1 -0
- package/dist/targets/akash/provider-metadata.js +14 -0
- package/dist/targets/akash/provider-metadata.js.map +1 -0
- package/dist/targets/akash/provider-service.d.ts +133 -0
- package/dist/targets/akash/provider-service.d.ts.map +1 -0
- package/dist/targets/akash/provider-service.js +391 -0
- package/dist/targets/akash/provider-service.js.map +1 -0
- package/dist/targets/akash/query-client.d.ts +125 -0
- package/dist/targets/akash/query-client.d.ts.map +1 -0
- package/dist/targets/akash/query-client.js +332 -0
- package/dist/targets/akash/query-client.js.map +1 -0
- package/dist/targets/akash/sdl-generator.d.ts +31 -0
- package/dist/targets/akash/sdl-generator.d.ts.map +1 -0
- package/dist/targets/akash/sdl-generator.js +279 -0
- package/dist/targets/akash/sdl-generator.js.map +1 -0
- package/dist/targets/akash/types.d.ts +285 -0
- package/dist/targets/akash/types.d.ts.map +1 -0
- package/dist/targets/akash/types.js +54 -0
- package/dist/targets/akash/types.js.map +1 -0
- package/dist/targets/akash/wallet-manager.d.ts +526 -0
- package/dist/targets/akash/wallet-manager.d.ts.map +1 -0
- package/dist/targets/akash/wallet-manager.js +953 -0
- package/dist/targets/akash/wallet-manager.js.map +1 -0
- package/dist/targets/local/compose-generator.d.ts +244 -0
- package/dist/targets/local/compose-generator.d.ts.map +1 -0
- package/dist/targets/local/compose-generator.js +324 -0
- package/dist/targets/local/compose-generator.js.map +1 -0
- package/dist/targets/local/deployer.d.ts +82 -0
- package/dist/targets/local/deployer.d.ts.map +1 -0
- package/dist/targets/local/deployer.js +367 -0
- package/dist/targets/local/deployer.js.map +1 -0
- package/dist/targets/local/engine-manager.d.ts +155 -0
- package/dist/targets/local/engine-manager.d.ts.map +1 -0
- package/dist/targets/local/engine-manager.js +250 -0
- package/dist/targets/local/engine-manager.js.map +1 -0
- package/dist/targets/local/index.d.ts +40 -0
- package/dist/targets/local/index.d.ts.map +1 -0
- package/dist/targets/local/index.js +43 -0
- package/dist/targets/local/index.js.map +1 -0
- package/dist/targets/local/network-manager.d.ts +160 -0
- package/dist/targets/local/network-manager.d.ts.map +1 -0
- package/dist/targets/local/network-manager.js +337 -0
- package/dist/targets/local/network-manager.js.map +1 -0
- package/dist/targets/local/types.d.ts +327 -0
- package/dist/targets/local/types.d.ts.map +1 -0
- package/dist/targets/local/types.js +9 -0
- package/dist/targets/local/types.js.map +1 -0
- package/dist/types/common.d.ts +585 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/common.js +13 -0
- package/dist/types/common.js.map +1 -0
- package/dist/types/index.d.ts +15 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +12 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/options.d.ts +329 -0
- package/dist/types/options.d.ts.map +1 -0
- package/dist/types/options.js +10 -0
- package/dist/types/options.js.map +1 -0
- package/dist/types/profiles.d.ts +329 -0
- package/dist/types/profiles.d.ts.map +1 -0
- package/dist/types/profiles.js +27 -0
- package/dist/types/profiles.js.map +1 -0
- package/dist/types/results.d.ts +443 -0
- package/dist/types/results.d.ts.map +1 -0
- package/dist/types/results.js +64 -0
- package/dist/types/results.js.map +1 -0
- package/dist/types/validators.d.ts +118 -0
- package/dist/types/validators.d.ts.map +1 -0
- package/dist/types/validators.js +198 -0
- package/dist/types/validators.js.map +1 -0
- package/dist/utils/command-runner.d.ts +128 -0
- package/dist/utils/command-runner.d.ts.map +1 -0
- package/dist/utils/command-runner.js +210 -0
- package/dist/utils/command-runner.js.map +1 -0
- package/dist/utils/index.d.ts +10 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +10 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.d.ts +68 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +93 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/profile-loader.d.ts +76 -0
- package/dist/utils/profile-loader.d.ts.map +1 -0
- package/dist/utils/profile-loader.js +194 -0
- package/dist/utils/profile-loader.js.map +1 -0
- package/dist/utils/registry/index.d.ts +27 -0
- package/dist/utils/registry/index.d.ts.map +1 -0
- package/dist/utils/registry/index.js +29 -0
- package/dist/utils/registry/index.js.map +1 -0
- package/dist/utils/registry/manager.d.ts +319 -0
- package/dist/utils/registry/manager.d.ts.map +1 -0
- package/dist/utils/registry/manager.js +671 -0
- package/dist/utils/registry/manager.js.map +1 -0
- package/dist/utils/registry/setup.d.ts +135 -0
- package/dist/utils/registry/setup.d.ts.map +1 -0
- package/dist/utils/registry/setup.js +207 -0
- package/dist/utils/registry/setup.js.map +1 -0
- package/dist/utils/registry/transformer.d.ts +92 -0
- package/dist/utils/registry/transformer.d.ts.map +1 -0
- package/dist/utils/registry/transformer.js +131 -0
- package/dist/utils/registry/transformer.js.map +1 -0
- package/dist/utils/registry/types.d.ts +241 -0
- package/dist/utils/registry/types.d.ts.map +1 -0
- package/dist/utils/registry/types.js +10 -0
- package/dist/utils/registry/types.js.map +1 -0
- package/docs/EXAMPLES.md +293 -0
- package/docs/PLACEMENT.md +433 -0
- package/docs/STORAGE.md +318 -0
- package/docs/building-provider-reliability-tracker.md +2581 -0
- package/package.json +109 -0
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Akash Network Wallet Connection Module
|
|
3
|
+
*
|
|
4
|
+
* Provides a clean, step-by-step API for connecting to Keplr wallet via WalletConnect.
|
|
5
|
+
* This is a LIBRARY - no QR code display, no prompts, just pure wallet operations.
|
|
6
|
+
*
|
|
7
|
+
* Key Improvements from kadi-deploy:
|
|
8
|
+
* - ✅ ZERO CLI dependencies (no QRCode, chalk, enquirer)
|
|
9
|
+
* - ✅ ZERO `any` types (was 5 any types)
|
|
10
|
+
* - ✅ Split into 4 clear steps for composability
|
|
11
|
+
* - ✅ Result types for all operations
|
|
12
|
+
* - ✅ Natural, intuitive API design
|
|
13
|
+
*
|
|
14
|
+
* Architecture:
|
|
15
|
+
* ```
|
|
16
|
+
* Step 1: initWalletConnect() → Create SignClient
|
|
17
|
+
* ↓
|
|
18
|
+
* Step 2: generateConnectionUri() → Get URI for QR code
|
|
19
|
+
* ↓
|
|
20
|
+
* Step 3: waitForApproval() → Poll for user approval
|
|
21
|
+
* ↓
|
|
22
|
+
* Step 4: createWalletContext() → Get ready-to-use wallet
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* Design Philosophy:
|
|
26
|
+
* Each step is independent and composable. Callers can:
|
|
27
|
+
* - Display QR codes however they want (terminal, web, mobile)
|
|
28
|
+
* - Add their own timeout logic
|
|
29
|
+
* - Implement custom retry mechanisms
|
|
30
|
+
* - Show progress however they prefer
|
|
31
|
+
*
|
|
32
|
+
* @module targets/akash/wallet
|
|
33
|
+
*/
|
|
34
|
+
import { SignClient } from '@walletconnect/sign-client';
|
|
35
|
+
import type { SessionTypes } from '@walletconnect/types';
|
|
36
|
+
import type { Result } from '../../types/index.js';
|
|
37
|
+
import type { WalletContext } from './types.js';
|
|
38
|
+
import { WalletError } from '../../errors/index.js';
|
|
39
|
+
import { type AkashNetwork } from './environment.js';
|
|
40
|
+
/**
|
|
41
|
+
* WalletConnect client wrapper
|
|
42
|
+
*
|
|
43
|
+
* Contains the SignClient and metadata for managing connections.
|
|
44
|
+
*/
|
|
45
|
+
export interface WalletConnectClient {
|
|
46
|
+
/** SignClient instance for WalletConnect operations */
|
|
47
|
+
readonly client: InstanceType<typeof SignClient>;
|
|
48
|
+
/** Project metadata for display in wallets */
|
|
49
|
+
readonly metadata: {
|
|
50
|
+
readonly name: string;
|
|
51
|
+
readonly description: string;
|
|
52
|
+
readonly url: string;
|
|
53
|
+
readonly icons: readonly string[];
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Connection URI result
|
|
58
|
+
*
|
|
59
|
+
* Contains the URI to display as QR code and approval promise.
|
|
60
|
+
*/
|
|
61
|
+
export interface ConnectionUriResult {
|
|
62
|
+
/** URI to display as QR code or clickable link */
|
|
63
|
+
readonly uri: string;
|
|
64
|
+
/** Approval promise that resolves when user approves */
|
|
65
|
+
readonly approval: () => Promise<SessionTypes.Struct>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Connection approval result
|
|
69
|
+
*
|
|
70
|
+
* Contains the approved session and account information.
|
|
71
|
+
*/
|
|
72
|
+
export interface ApprovalResult {
|
|
73
|
+
/** Approved WalletConnect session */
|
|
74
|
+
readonly session: SessionTypes.Struct;
|
|
75
|
+
/** Connected wallet address */
|
|
76
|
+
readonly address: string;
|
|
77
|
+
/** Chain ID that was connected */
|
|
78
|
+
readonly chainId: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Step 1: Initialize WalletConnect client
|
|
82
|
+
*
|
|
83
|
+
* Creates a WalletConnect SignClient with proper configuration.
|
|
84
|
+
* This is a one-time setup that can be reused for multiple connections.
|
|
85
|
+
*
|
|
86
|
+
* @param projectId - WalletConnect Cloud project ID
|
|
87
|
+
* @param metadata - Optional app metadata (defaults to KADI Deploy)
|
|
88
|
+
* @returns Result with WalletConnect client or error
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* // Initialize with your project ID
|
|
93
|
+
* const clientResult = await initWalletConnect('your-project-id-here');
|
|
94
|
+
*
|
|
95
|
+
* if (!clientResult.success) {
|
|
96
|
+
* console.error('Failed to initialize:', clientResult.error);
|
|
97
|
+
* return;
|
|
98
|
+
* }
|
|
99
|
+
*
|
|
100
|
+
* const wcClient = clientResult.data;
|
|
101
|
+
* console.log('WalletConnect ready!');
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
export declare function initWalletConnect(projectId: string, metadata?: {
|
|
105
|
+
name: string;
|
|
106
|
+
description: string;
|
|
107
|
+
url: string;
|
|
108
|
+
icons: string[];
|
|
109
|
+
}): Promise<Result<WalletConnectClient, WalletError>>;
|
|
110
|
+
/**
|
|
111
|
+
* Step 2: Generate connection URI for QR code display
|
|
112
|
+
*
|
|
113
|
+
* Creates a new pairing and generates the WalletConnect URI.
|
|
114
|
+
* The caller is responsible for displaying this URI as a QR code.
|
|
115
|
+
*
|
|
116
|
+
* @param wcClient - Initialized WalletConnect client from step 1
|
|
117
|
+
* @param network - Akash network to connect to
|
|
118
|
+
* @returns Result with URI and pairing info or error
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```typescript
|
|
122
|
+
* // Generate URI for QR code
|
|
123
|
+
* const uriResult = await generateConnectionUri(wcClient, 'mainnet');
|
|
124
|
+
*
|
|
125
|
+
* if (!uriResult.success) {
|
|
126
|
+
* console.error('Failed to generate URI:', uriResult.error);
|
|
127
|
+
* return;
|
|
128
|
+
* }
|
|
129
|
+
*
|
|
130
|
+
* const { uri, pairingTopic, approval } = uriResult.data;
|
|
131
|
+
*
|
|
132
|
+
* // Caller displays QR code however they want:
|
|
133
|
+
* // - Terminal: QRCode.generate(uri)
|
|
134
|
+
* // - Web: <QRCode value={uri} />
|
|
135
|
+
* // - Or just show as text: console.log(uri)
|
|
136
|
+
* console.log('Scan this QR code:', uri);
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
export declare function generateConnectionUri(wcClient: WalletConnectClient, network: AkashNetwork): Promise<Result<ConnectionUriResult, WalletError>>;
|
|
140
|
+
/**
|
|
141
|
+
* Step 3: Wait for user to approve connection
|
|
142
|
+
*
|
|
143
|
+
* Polls for wallet approval with configurable timeout.
|
|
144
|
+
* Returns immediately when user approves or rejects.
|
|
145
|
+
*
|
|
146
|
+
* @param approval - Approval promise from step 2
|
|
147
|
+
* @param timeoutMs - Maximum wait time in milliseconds (default: 5 minutes)
|
|
148
|
+
* @returns Result with approved session or error
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```typescript
|
|
152
|
+
* // Wait for user to scan QR and approve
|
|
153
|
+
* console.log('Waiting for approval...');
|
|
154
|
+
*
|
|
155
|
+
* const approvalResult = await waitForApproval(
|
|
156
|
+
* approval,
|
|
157
|
+
* 60000 // 60 second timeout
|
|
158
|
+
* );
|
|
159
|
+
*
|
|
160
|
+
* if (!approvalResult.success) {
|
|
161
|
+
* if (approvalResult.error.code === 'APPROVAL_TIMEOUT') {
|
|
162
|
+
* console.log('User did not approve in time');
|
|
163
|
+
* } else if (approvalResult.error.code === 'APPROVAL_REJECTED') {
|
|
164
|
+
* console.log('User rejected connection');
|
|
165
|
+
* }
|
|
166
|
+
* return;
|
|
167
|
+
* }
|
|
168
|
+
*
|
|
169
|
+
* const { session, address } = approvalResult.data;
|
|
170
|
+
* console.log(`Connected to ${address}!`);
|
|
171
|
+
* ```
|
|
172
|
+
*/
|
|
173
|
+
export declare function waitForApproval(approval: () => Promise<SessionTypes.Struct>, timeoutMs?: number): Promise<Result<ApprovalResult, WalletError>>;
|
|
174
|
+
/**
|
|
175
|
+
* Step 4: Create complete wallet context for Akash operations
|
|
176
|
+
*
|
|
177
|
+
* Finalizes the connection by creating signers and querying account data.
|
|
178
|
+
* Returns a ready-to-use WalletContext for all Akash operations.
|
|
179
|
+
*
|
|
180
|
+
* @param wcClient - WalletConnect client from step 1
|
|
181
|
+
* @param approvalResult - Approval result from step 3
|
|
182
|
+
* @param network - Akash network being used
|
|
183
|
+
* @returns Result with complete wallet context or error
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```typescript
|
|
187
|
+
* // Create final wallet context
|
|
188
|
+
* const walletResult = await createWalletContext(
|
|
189
|
+
* wcClient,
|
|
190
|
+
* approvalResult.data,
|
|
191
|
+
* 'mainnet'
|
|
192
|
+
* );
|
|
193
|
+
*
|
|
194
|
+
* if (!walletResult.success) {
|
|
195
|
+
* console.error('Failed to create wallet:', walletResult.error);
|
|
196
|
+
* return;
|
|
197
|
+
* }
|
|
198
|
+
*
|
|
199
|
+
* const wallet = walletResult.data;
|
|
200
|
+
* console.log('Wallet ready!');
|
|
201
|
+
* console.log('Address:', wallet.address);
|
|
202
|
+
* console.log('Chain:', wallet.chainId);
|
|
203
|
+
*
|
|
204
|
+
* // Now ready for Akash operations
|
|
205
|
+
* const deployment = await deployToAkash({ wallet, ... });
|
|
206
|
+
* ```
|
|
207
|
+
*/
|
|
208
|
+
export declare function createWalletContext(wcClient: WalletConnectClient, approvalResult: ApprovalResult, network: AkashNetwork): Promise<Result<WalletContext, WalletError>>;
|
|
209
|
+
/**
|
|
210
|
+
* Create wallet context from any offline signer
|
|
211
|
+
*
|
|
212
|
+
* Use this for **automated deployments** where you have direct access to a signer
|
|
213
|
+
* (e.g., agent wallet, CI/CD, hardware wallet, KMS) instead of interactive wallet
|
|
214
|
+
* connection via browser or WalletConnect.
|
|
215
|
+
*
|
|
216
|
+
* **Security Model:**
|
|
217
|
+
* This function accepts a **signer interface**, NOT a private key or mnemonic!
|
|
218
|
+
* The signer can sign transactions without exposing the underlying key.
|
|
219
|
+
*
|
|
220
|
+
* **Common Use Cases:**
|
|
221
|
+
* - Self-deploying agents (signer from encrypted storage)
|
|
222
|
+
* - CI/CD pipelines (signer from secrets manager)
|
|
223
|
+
* - Hardware wallets (Ledger - key never leaves device)
|
|
224
|
+
* - Cloud KMS (AWS/GCP - key stays in cloud)
|
|
225
|
+
* - Multi-signature wallets (threshold signing)
|
|
226
|
+
*
|
|
227
|
+
* @param signer - Any offline signer (must implement OfflineAminoSigner & OfflineDirectSigner)
|
|
228
|
+
* @param network - Akash network to connect to
|
|
229
|
+
* @returns Result with wallet context ready for deployments
|
|
230
|
+
*
|
|
231
|
+
* @example Agent with encrypted wallet
|
|
232
|
+
* ```typescript
|
|
233
|
+
* import { DirectSecp256k1Wallet } from '@cosmjs/proto-signing';
|
|
234
|
+
* import { createWalletContextFromSigner } from 'deploy-ability/akash';
|
|
235
|
+
*
|
|
236
|
+
* // Agent loads signer from secure storage (mnemonic never exposed to caller)
|
|
237
|
+
* const agentSigner = await myAgent.wallet.getSigner();
|
|
238
|
+
*
|
|
239
|
+
* // Create wallet context
|
|
240
|
+
* const walletCtx = await createWalletContextFromSigner(agentSigner, 'mainnet');
|
|
241
|
+
*
|
|
242
|
+
* if (walletCtx.success) {
|
|
243
|
+
* // Ready to deploy - signer will handle signing internally
|
|
244
|
+
* await deployToAkash({
|
|
245
|
+
* wallet: walletCtx.data,
|
|
246
|
+
* certificate: cert,
|
|
247
|
+
* projectRoot: './',
|
|
248
|
+
* profile: 'prod'
|
|
249
|
+
* });
|
|
250
|
+
* }
|
|
251
|
+
* ```
|
|
252
|
+
*
|
|
253
|
+
* @example CI/CD with secrets manager
|
|
254
|
+
* ```typescript
|
|
255
|
+
* // Load signer from AWS Secrets Manager / GitHub Secrets
|
|
256
|
+
* const mnemonic = await loadFromSecretsManager('deploy-wallet-key');
|
|
257
|
+
* const signer = await DirectSecp256k1Wallet.fromMnemonic(mnemonic, {
|
|
258
|
+
* prefix: 'akash'
|
|
259
|
+
* });
|
|
260
|
+
*
|
|
261
|
+
* const walletCtx = await createWalletContextFromSigner(signer, 'testnet');
|
|
262
|
+
* // Now deploy without any user interaction
|
|
263
|
+
* ```
|
|
264
|
+
*
|
|
265
|
+
* @example Hardware wallet (Ledger)
|
|
266
|
+
* ```typescript
|
|
267
|
+
* import Ledger from '@cosmjs/ledger-amino';
|
|
268
|
+
*
|
|
269
|
+
* // Connect to Ledger - key never leaves device
|
|
270
|
+
* const transport = await TransportWebUSB.create();
|
|
271
|
+
* const ledgerSigner = new Ledger(transport, {
|
|
272
|
+
* hdPaths: [makeCosmoshubPath(0)],
|
|
273
|
+
* prefix: 'akash'
|
|
274
|
+
* });
|
|
275
|
+
*
|
|
276
|
+
* const walletCtx = await createWalletContextFromSigner(ledgerSigner, 'mainnet');
|
|
277
|
+
* // Ledger will prompt for approval when signing
|
|
278
|
+
* ```
|
|
279
|
+
*
|
|
280
|
+
* @example Cloud KMS
|
|
281
|
+
* ```typescript
|
|
282
|
+
* // Custom signer using AWS KMS / GCP KMS
|
|
283
|
+
* class KmsSigner implements OfflineSigner {
|
|
284
|
+
* constructor(private keyId: string) {}
|
|
285
|
+
*
|
|
286
|
+
* async signDirect(address: string, signDoc: SignDoc) {
|
|
287
|
+
* // Sign using KMS - key never leaves cloud
|
|
288
|
+
* return await kms.sign(this.keyId, signDoc);
|
|
289
|
+
* }
|
|
290
|
+
* }
|
|
291
|
+
*
|
|
292
|
+
* const kmsSigner = new KmsSigner('arn:aws:kms:...');
|
|
293
|
+
* const walletCtx = await createWalletContextFromSigner(kmsSigner, 'mainnet');
|
|
294
|
+
* ```
|
|
295
|
+
*/
|
|
296
|
+
export declare function createWalletContextFromSigner(signer: WalletContext['signer'], network: AkashNetwork): Promise<Result<WalletContext, WalletError>>;
|
|
297
|
+
/**
|
|
298
|
+
* Disconnect an active WalletConnect session
|
|
299
|
+
*
|
|
300
|
+
* Cleanly disconnects from the wallet, clearing the session and cleaning up
|
|
301
|
+
* all internal resources (relay transport, heartbeat, event listeners).
|
|
302
|
+
*
|
|
303
|
+
* This ensures the Node.js event loop can exit by releasing all timers and
|
|
304
|
+
* connections. Without this cleanup, the WalletConnect client keeps the
|
|
305
|
+
* process alive indefinitely.
|
|
306
|
+
*
|
|
307
|
+
* Always call this when done with wallet operations to prevent hanging.
|
|
308
|
+
*
|
|
309
|
+
* Note: This only applies to WalletConnect sessions. Wallets created
|
|
310
|
+
* with `createWalletContextFromSigner()` don't need disconnection.
|
|
311
|
+
*
|
|
312
|
+
* @param wallet - Wallet context to disconnect
|
|
313
|
+
* @returns Result indicating success or error
|
|
314
|
+
*
|
|
315
|
+
* @example
|
|
316
|
+
* ```typescript
|
|
317
|
+
* // Disconnect when done
|
|
318
|
+
* const result = await disconnectWallet(wallet);
|
|
319
|
+
*
|
|
320
|
+
* if (result.success) {
|
|
321
|
+
* console.log('Wallet disconnected');
|
|
322
|
+
* } else {
|
|
323
|
+
* console.warn('Disconnect failed:', result.error);
|
|
324
|
+
* }
|
|
325
|
+
* ```
|
|
326
|
+
*/
|
|
327
|
+
export declare function disconnectWallet(wallet: WalletContext): Promise<Result<void, WalletError>>;
|
|
328
|
+
/**
|
|
329
|
+
* Complete wallet connection flow (convenience function)
|
|
330
|
+
*
|
|
331
|
+
* Combines all 4 steps into a single function for simple use cases.
|
|
332
|
+
* For more control, use the individual step functions.
|
|
333
|
+
*
|
|
334
|
+
* @param projectId - WalletConnect project ID
|
|
335
|
+
* @param network - Akash network to connect to
|
|
336
|
+
* @param options - Optional configuration
|
|
337
|
+
* @returns Result with wallet context or error
|
|
338
|
+
*
|
|
339
|
+
* @example
|
|
340
|
+
* ```typescript
|
|
341
|
+
* // Simple one-call connection
|
|
342
|
+
* const walletResult = await connectWallet(
|
|
343
|
+
* 'your-project-id',
|
|
344
|
+
* 'mainnet',
|
|
345
|
+
* {
|
|
346
|
+
* onUriGenerated: (uri) => {
|
|
347
|
+
* // Display QR code
|
|
348
|
+
* QRCode.generate(uri);
|
|
349
|
+
* console.log('Scan QR code with Keplr');
|
|
350
|
+
* },
|
|
351
|
+
* timeoutMs: 60000
|
|
352
|
+
* }
|
|
353
|
+
* );
|
|
354
|
+
*
|
|
355
|
+
* if (!walletResult.success) {
|
|
356
|
+
* console.error('Connection failed:', walletResult.error);
|
|
357
|
+
* return;
|
|
358
|
+
* }
|
|
359
|
+
*
|
|
360
|
+
* const wallet = walletResult.data;
|
|
361
|
+
* console.log('Connected to:', wallet.address);
|
|
362
|
+
* ```
|
|
363
|
+
*/
|
|
364
|
+
export declare function connectWallet(projectId: string, network: AkashNetwork, options?: {
|
|
365
|
+
/** Callback when URI is generated (for QR display) */
|
|
366
|
+
onUriGenerated?: (uri: string) => void;
|
|
367
|
+
/** Connection timeout in milliseconds */
|
|
368
|
+
timeoutMs?: number;
|
|
369
|
+
/** App metadata */
|
|
370
|
+
metadata?: {
|
|
371
|
+
name: string;
|
|
372
|
+
description: string;
|
|
373
|
+
url: string;
|
|
374
|
+
icons: string[];
|
|
375
|
+
};
|
|
376
|
+
}): Promise<Result<WalletContext, WalletError>>;
|
|
377
|
+
/**
|
|
378
|
+
* Create wallet context from mnemonic (for agent-controlled wallets)
|
|
379
|
+
*
|
|
380
|
+
* ⚠️ **CRITICAL SECURITY WARNING** ⚠️
|
|
381
|
+
*
|
|
382
|
+
* This function is ONLY for scenarios where YOU control the mnemonic:
|
|
383
|
+
* - ✅ Your own automation (CI/CD, personal scripts)
|
|
384
|
+
* - ✅ Your own agent (running on infrastructure you control)
|
|
385
|
+
* - ✅ Custodial services YOU operate (creating wallets for your users)
|
|
386
|
+
*
|
|
387
|
+
* **NEVER use this if:**
|
|
388
|
+
* - ❌ Someone else's agent asks for your mnemonic
|
|
389
|
+
* - ❌ Third-party service requests your mnemonic
|
|
390
|
+
* - ❌ You don't fully control where the mnemonic is stored/used
|
|
391
|
+
*
|
|
392
|
+
* **For third-party agents/services:**
|
|
393
|
+
* Use `connectWallet()` with WalletConnect instead! This lets you approve
|
|
394
|
+
* transactions on YOUR device without exposing your mnemonic.
|
|
395
|
+
*
|
|
396
|
+
* **Security Model:**
|
|
397
|
+
* ```
|
|
398
|
+
* ┌─────────────────────────────────────────────────────────────┐
|
|
399
|
+
* │ WHO CONTROLS THE AGENT? │
|
|
400
|
+
* ├─────────────────────────────────────────────────────────────┤
|
|
401
|
+
* │ │
|
|
402
|
+
* │ YOU control it: │
|
|
403
|
+
* │ ✅ createWalletFromMnemonic() - You trust your own code │
|
|
404
|
+
* │ │
|
|
405
|
+
* │ SOMEONE ELSE controls it: │
|
|
406
|
+
* │ ✅ connectWallet() - WalletConnect for approval │
|
|
407
|
+
* │ ❌ createWalletFromMnemonic() - NEVER share mnemonic! │
|
|
408
|
+
* │ │
|
|
409
|
+
* └─────────────────────────────────────────────────────────────┘
|
|
410
|
+
* ```
|
|
411
|
+
*
|
|
412
|
+
* **Common Use Cases:**
|
|
413
|
+
*
|
|
414
|
+
* @example 1. Your own CI/CD pipeline
|
|
415
|
+
* ```typescript
|
|
416
|
+
* // Mnemonic stored in GitHub Secrets / GitLab CI Variables
|
|
417
|
+
* const mnemonic = process.env.DEPLOYMENT_WALLET_MNEMONIC!;
|
|
418
|
+
* const wallet = await createWalletFromMnemonic(mnemonic, 'mainnet');
|
|
419
|
+
*
|
|
420
|
+
* if (wallet.success) {
|
|
421
|
+
* // Automated deployment from CI/CD
|
|
422
|
+
* await deployToAkash({
|
|
423
|
+
* wallet: wallet.data,
|
|
424
|
+
* projectRoot: './',
|
|
425
|
+
* profile: 'production'
|
|
426
|
+
* });
|
|
427
|
+
* }
|
|
428
|
+
* ```
|
|
429
|
+
*
|
|
430
|
+
* @example 2. Your own agent with encrypted storage
|
|
431
|
+
* ```typescript
|
|
432
|
+
* // Agent loads its OWN mnemonic (not user's!)
|
|
433
|
+
* class DeploymentAgent {
|
|
434
|
+
* async deploy(projectConfig: Config) {
|
|
435
|
+
* // Agent uses its own wallet to pay for deployments
|
|
436
|
+
* const mnemonic = await this.secrets.getEncryptedMnemonic();
|
|
437
|
+
* const wallet = await createWalletFromMnemonic(mnemonic, 'mainnet');
|
|
438
|
+
*
|
|
439
|
+
* if (wallet.success) {
|
|
440
|
+
* // Agent deploys using its own funds
|
|
441
|
+
* return deployToAkash({
|
|
442
|
+
* wallet: wallet.data,
|
|
443
|
+
* ...projectConfig
|
|
444
|
+
* });
|
|
445
|
+
* }
|
|
446
|
+
* }
|
|
447
|
+
* }
|
|
448
|
+
* ```
|
|
449
|
+
*
|
|
450
|
+
* @example 3. Custodial wallet service (you operate the service)
|
|
451
|
+
* ```typescript
|
|
452
|
+
* // Service creates and manages wallets FOR users
|
|
453
|
+
* class CustodialWalletService {
|
|
454
|
+
* async createUserWallet(userId: string) {
|
|
455
|
+
* // Generate new wallet for user
|
|
456
|
+
* const { DirectSecp256k1HdWallet } = await import('@cosmjs/proto-signing');
|
|
457
|
+
* const newWallet = await DirectSecp256k1HdWallet.generate(24);
|
|
458
|
+
* const mnemonic = newWallet.mnemonic;
|
|
459
|
+
*
|
|
460
|
+
* // Store encrypted mnemonic in your secure database
|
|
461
|
+
* await this.db.storeEncryptedMnemonic(userId, mnemonic);
|
|
462
|
+
*
|
|
463
|
+
* return { userId, address: (await newWallet.getAccounts())[0].address };
|
|
464
|
+
* }
|
|
465
|
+
*
|
|
466
|
+
* async deployForUser(userId: string, projectConfig: Config) {
|
|
467
|
+
* // Load user's mnemonic from secure storage
|
|
468
|
+
* const mnemonic = await this.db.getDecryptedMnemonic(userId);
|
|
469
|
+
* const wallet = await createWalletFromMnemonic(mnemonic, 'mainnet');
|
|
470
|
+
*
|
|
471
|
+
* if (wallet.success) {
|
|
472
|
+
* // Deploy on user's behalf
|
|
473
|
+
* return deployToAkash({
|
|
474
|
+
* wallet: wallet.data,
|
|
475
|
+
* ...projectConfig
|
|
476
|
+
* });
|
|
477
|
+
* }
|
|
478
|
+
* }
|
|
479
|
+
* }
|
|
480
|
+
* ```
|
|
481
|
+
*
|
|
482
|
+
* @example 4. WRONG - Never do this!
|
|
483
|
+
* ```typescript
|
|
484
|
+
* // ❌ DANGEROUS - Third-party agent asking for your mnemonic!
|
|
485
|
+
* const thirdPartyAgent = new SomeoneElsesAgent();
|
|
486
|
+
*
|
|
487
|
+
* // ❌ DO NOT DO THIS!
|
|
488
|
+
* await thirdPartyAgent.deploy({
|
|
489
|
+
* mnemonic: myMnemonic, // ❌ Now they can steal all your funds!
|
|
490
|
+
* project: './my-app'
|
|
491
|
+
* });
|
|
492
|
+
*
|
|
493
|
+
* // ✅ DO THIS INSTEAD - Use WalletConnect!
|
|
494
|
+
* const wallet = await connectWallet(projectId, 'mainnet', {
|
|
495
|
+
* onUriGenerated: (uri) => {
|
|
496
|
+
* console.log('Scan QR code to approve');
|
|
497
|
+
* // You approve on YOUR device, agent never gets mnemonic
|
|
498
|
+
* }
|
|
499
|
+
* });
|
|
500
|
+
* await thirdPartyAgent.deploy({ wallet: wallet.data, ... });
|
|
501
|
+
* ```
|
|
502
|
+
*
|
|
503
|
+
* **Implementation Notes for Future:**
|
|
504
|
+
*
|
|
505
|
+
* This function should:
|
|
506
|
+
* 1. Import DirectSecp256k1HdWallet from @cosmjs/proto-signing
|
|
507
|
+
* 2. Create signer with proper network prefix:
|
|
508
|
+
* - mainnet/testnet → 'akash'
|
|
509
|
+
* - sandbox → 'akash'
|
|
510
|
+
* 3. Call createWalletContextFromSigner() with the signer
|
|
511
|
+
* 4. Return Result<WalletContext, WalletError>
|
|
512
|
+
*
|
|
513
|
+
* Dependencies needed:
|
|
514
|
+
* - @cosmjs/proto-signing (DirectSecp256k1HdWallet)
|
|
515
|
+
*
|
|
516
|
+
* Error handling:
|
|
517
|
+
* - Invalid mnemonic format
|
|
518
|
+
* - Network configuration issues
|
|
519
|
+
* - Account fetch failures
|
|
520
|
+
*
|
|
521
|
+
* @param mnemonic - BIP39 mnemonic phrase (12 or 24 words)
|
|
522
|
+
* @param network - Akash network to connect to
|
|
523
|
+
* @returns Result with wallet context or error
|
|
524
|
+
*/
|
|
525
|
+
export declare function createWalletFromMnemonic(_mnemonic: string, network: AkashNetwork): Promise<Result<WalletContext, WalletError>>;
|
|
526
|
+
//# sourceMappingURL=wallet-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet-manager.d.ts","sourceRoot":"","sources":["../../../src/targets/akash/wallet-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAIxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAe,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAoB,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAA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