@kadi.build/deploy-ability 0.0.7 → 0.0.9

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.
Files changed (38) hide show
  1. package/.env-example +72 -0
  2. package/README.md +240 -0
  3. package/dist/targets/akash/deployer.d.ts +64 -3
  4. package/dist/targets/akash/deployer.d.ts.map +1 -1
  5. package/dist/targets/akash/deployer.js +170 -4
  6. package/dist/targets/akash/deployer.js.map +1 -1
  7. package/dist/targets/akash/index.d.ts +86 -2
  8. package/dist/targets/akash/index.d.ts.map +1 -1
  9. package/dist/targets/akash/index.js +49 -2
  10. package/dist/targets/akash/index.js.map +1 -1
  11. package/dist/targets/akash/secrets-provider.d.ts +189 -0
  12. package/dist/targets/akash/secrets-provider.d.ts.map +1 -0
  13. package/dist/targets/akash/secrets-provider.js +249 -0
  14. package/dist/targets/akash/secrets-provider.js.map +1 -0
  15. package/dist/targets/akash/types.d.ts +96 -0
  16. package/dist/targets/akash/types.d.ts.map +1 -1
  17. package/dist/targets/akash/wallet-manager.d.ts +21 -3
  18. package/dist/targets/akash/wallet-manager.d.ts.map +1 -1
  19. package/dist/targets/akash/wallet-manager.js +137 -8
  20. package/dist/targets/akash/wallet-manager.js.map +1 -1
  21. package/dist/types/index.d.ts +1 -1
  22. package/dist/types/index.d.ts.map +1 -1
  23. package/dist/types/index.js.map +1 -1
  24. package/dist/types/options.d.ts +74 -0
  25. package/dist/types/options.d.ts.map +1 -1
  26. package/dist/utils/registry/manager.d.ts +10 -9
  27. package/dist/utils/registry/manager.d.ts.map +1 -1
  28. package/dist/utils/registry/manager.js +28 -18
  29. package/dist/utils/registry/manager.js.map +1 -1
  30. package/dist/utils/registry/setup.d.ts +2 -2
  31. package/dist/utils/registry/setup.d.ts.map +1 -1
  32. package/dist/utils/registry/setup.js +7 -5
  33. package/dist/utils/registry/setup.js.map +1 -1
  34. package/dist/utils/registry/transformer.d.ts +1 -1
  35. package/dist/utils/registry/transformer.js +1 -1
  36. package/dist/utils/registry/types.d.ts +36 -12
  37. package/dist/utils/registry/types.d.ts.map +1 -1
  38. package/package.json +3 -2
@@ -0,0 +1,249 @@
1
+ /**
2
+ * Secrets Provider for Akash Autonomous Deployments
3
+ *
4
+ * Integrates with KADI's secret-ability to securely retrieve
5
+ * wallet mnemonics and certificates from local vaults.
6
+ *
7
+ * Uses a "global" vault stored in ~/.kadi/akash-secrets.toml
8
+ * for machine-level secrets (not project-specific).
9
+ */
10
+ import * as os from 'node:os';
11
+ import * as path from 'node:path';
12
+ // =============================================================================
13
+ // Constants - Key Names and Vault Configuration
14
+ // =============================================================================
15
+ /**
16
+ * Default vault name for Akash secrets.
17
+ * This vault uses 'age' encryption with OS keychain for master key.
18
+ */
19
+ export const AKASH_VAULT_NAME = 'global';
20
+ /**
21
+ * Global config path for machine-level secrets.
22
+ * Stored in ~/.kadi/secrets/config.toml (not project-specific).
23
+ */
24
+ export const GLOBAL_CONFIG_PATH = path.join(os.homedir(), '.kadi', 'secrets', 'config.toml');
25
+ /**
26
+ * Key names for Akash secrets in the vault.
27
+ * These are the standardized key names used across the KADI ecosystem.
28
+ */
29
+ export const AKASH_SECRET_KEYS = {
30
+ /**
31
+ * BIP39 mnemonic phrase for the Akash wallet (12 or 24 words).
32
+ * Example: "abandon abandon abandon ... about"
33
+ */
34
+ WALLET_MNEMONIC: 'AKASH_WALLET',
35
+ /**
36
+ * Cached TLS certificate for Akash provider communication.
37
+ * Stored as JSON: { cert: string, pubkey: string, privkey: string }
38
+ */
39
+ TLS_CERTIFICATE: 'akash-tls-certificate',
40
+ /**
41
+ * Optional: Wallet password if the mnemonic is BIP39 password-protected.
42
+ * Most wallets don't use this, but we support it.
43
+ */
44
+ WALLET_PASSWORD: 'akash-wallet-password',
45
+ };
46
+ // =============================================================================
47
+ // SecretsProvider Implementation
48
+ // =============================================================================
49
+ /**
50
+ * Create a SecretsProvider that integrates with secret-ability.
51
+ *
52
+ * This provider retrieves secrets from a local 'age' vault encrypted
53
+ * with ChaCha20-Poly1305, with the master key stored in the OS keychain.
54
+ *
55
+ * @param client - The secret-ability client (from KADI agent)
56
+ * @param config - Optional configuration overrides
57
+ * @returns A SecretsProvider for autonomous deployments
58
+ *
59
+ * @example
60
+ * ```typescript
61
+ * // In KADI agent context:
62
+ * const secrets = createSecretsProvider(this.secrets);
63
+ *
64
+ * // Use in autonomous deployment:
65
+ * await deployToAkash({
66
+ * autonomous: {
67
+ * secrets,
68
+ * bidStrategy: 'cheapest',
69
+ * },
70
+ * profile: myProfile,
71
+ * });
72
+ * ```
73
+ */
74
+ export function createSecretsProvider(client, config = {}) {
75
+ const configPath = config.configPath ?? GLOBAL_CONFIG_PATH;
76
+ const vaultName = config.vaultName ?? AKASH_VAULT_NAME;
77
+ return {
78
+ async getMnemonic() {
79
+ try {
80
+ const result = await client.invoke('get', {
81
+ configPath,
82
+ vault: vaultName,
83
+ key: AKASH_SECRET_KEYS.WALLET_MNEMONIC,
84
+ });
85
+ return result.value;
86
+ }
87
+ catch (error) {
88
+ const message = error instanceof Error ? error.message : String(error);
89
+ throw new Error(`Failed to retrieve Akash wallet mnemonic from vault '${vaultName}': ${message}. ` +
90
+ `Make sure you have stored the mnemonic using: ` +
91
+ `secrets.invoke('set', { configPath: '${configPath}', vault: '${vaultName}', ` +
92
+ `key: '${AKASH_SECRET_KEYS.WALLET_MNEMONIC}', value: '<your-mnemonic>' })`);
93
+ }
94
+ },
95
+ async getCertificate() {
96
+ try {
97
+ // Check if certificate exists
98
+ const { exists } = await client.invoke('exists', {
99
+ configPath,
100
+ vault: vaultName,
101
+ key: AKASH_SECRET_KEYS.TLS_CERTIFICATE,
102
+ });
103
+ if (!exists) {
104
+ return null;
105
+ }
106
+ const result = await client.invoke('get', {
107
+ configPath,
108
+ vault: vaultName,
109
+ key: AKASH_SECRET_KEYS.TLS_CERTIFICATE,
110
+ });
111
+ const stored = JSON.parse(result.value);
112
+ return {
113
+ cert: stored.cert,
114
+ privateKey: stored.privateKey,
115
+ publicKey: stored.publicKey,
116
+ chain: stored.chain,
117
+ };
118
+ }
119
+ catch {
120
+ // Certificate retrieval is optional - return null on error
121
+ return null;
122
+ }
123
+ },
124
+ async storeCertificate(cert) {
125
+ const stored = {
126
+ cert: cert.cert,
127
+ privateKey: cert.privateKey,
128
+ publicKey: cert.publicKey,
129
+ chain: cert.chain,
130
+ createdAt: new Date().toISOString(),
131
+ };
132
+ await client.invoke('set', {
133
+ configPath,
134
+ vault: vaultName,
135
+ key: AKASH_SECRET_KEYS.TLS_CERTIFICATE,
136
+ value: JSON.stringify(stored),
137
+ });
138
+ },
139
+ };
140
+ }
141
+ // =============================================================================
142
+ // Vault Setup Utilities
143
+ // =============================================================================
144
+ /**
145
+ * Initialize the Akash secrets vault.
146
+ * Call this once to set up the vault before storing secrets.
147
+ *
148
+ * @param client - The secret-ability client
149
+ * @param config - Optional configuration overrides
150
+ *
151
+ * @example
152
+ * ```typescript
153
+ * // Set up the vault:
154
+ * await initializeAkashVault(this.secrets);
155
+ *
156
+ * // Then store the mnemonic:
157
+ * await this.secrets.invoke('set', {
158
+ * configPath: GLOBAL_CONFIG_PATH,
159
+ * vault: 'akash',
160
+ * key: 'akash-wallet-mnemonic',
161
+ * value: 'your 24 word mnemonic phrase here',
162
+ * });
163
+ * ```
164
+ */
165
+ export async function initializeAkashVault(client, config = {}) {
166
+ const configPath = config.configPath ?? GLOBAL_CONFIG_PATH;
167
+ const vaultName = config.vaultName ?? AKASH_VAULT_NAME;
168
+ try {
169
+ await client.invoke('config.createVault', {
170
+ configPath,
171
+ name: vaultName,
172
+ type: 'age',
173
+ });
174
+ }
175
+ catch (error) {
176
+ // Vault might already exist - that's okay
177
+ const message = error instanceof Error ? error.message : String(error);
178
+ if (!message.includes('already exists')) {
179
+ throw error;
180
+ }
181
+ }
182
+ }
183
+ /**
184
+ * Check if the Akash vault has all required secrets configured.
185
+ *
186
+ * @param client - The secret-ability client
187
+ * @param config - Optional configuration overrides
188
+ * @returns Object indicating which secrets are present
189
+ */
190
+ export async function checkAkashVaultStatus(client, config = {}) {
191
+ const configPath = config.configPath ?? GLOBAL_CONFIG_PATH;
192
+ const vaultName = config.vaultName ?? AKASH_VAULT_NAME;
193
+ try {
194
+ const { keys } = await client.invoke('list', {
195
+ configPath,
196
+ vault: vaultName,
197
+ });
198
+ return {
199
+ vaultExists: true,
200
+ hasMnemonic: keys.includes(AKASH_SECRET_KEYS.WALLET_MNEMONIC),
201
+ hasCertificate: keys.includes(AKASH_SECRET_KEYS.TLS_CERTIFICATE),
202
+ keys,
203
+ };
204
+ }
205
+ catch {
206
+ return {
207
+ vaultExists: false,
208
+ hasMnemonic: false,
209
+ hasCertificate: false,
210
+ keys: [],
211
+ };
212
+ }
213
+ }
214
+ // =============================================================================
215
+ // Simple Mnemonic Provider (No Secret-Ability Required)
216
+ // =============================================================================
217
+ /**
218
+ * Create a simple SecretsProvider from a raw mnemonic.
219
+ * Use this for testing or when secret-ability is not available.
220
+ *
221
+ * ⚠️ WARNING: This stores the mnemonic in memory. For production use,
222
+ * prefer createSecretsProvider() with secret-ability integration.
223
+ *
224
+ * @param mnemonic - The BIP39 mnemonic phrase
225
+ * @returns A SecretsProvider for autonomous deployments
226
+ *
227
+ * @example
228
+ * ```typescript
229
+ * // For testing only:
230
+ * const secrets = createSimpleMnemonicProvider(
231
+ * 'abandon abandon abandon ... about'
232
+ * );
233
+ * ```
234
+ */
235
+ export function createSimpleMnemonicProvider(mnemonic) {
236
+ let cachedCertificate = null;
237
+ return {
238
+ async getMnemonic() {
239
+ return mnemonic;
240
+ },
241
+ async getCertificate() {
242
+ return cachedCertificate;
243
+ },
244
+ async storeCertificate(cert) {
245
+ cachedCertificate = cert;
246
+ },
247
+ };
248
+ }
249
+ //# sourceMappingURL=secrets-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secrets-provider.js","sourceRoot":"","sources":["../../../src/targets/akash/secrets-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,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C;QACH,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE;YAC3C,UAAU;YACV,KAAK,EAAE,SAAS;SACjB,CAAC,CAAC;QAEH,OAAO;YACL,WAAW,EAAE,IAAI;YACjB,WAAW,EAAE,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,eAAe,CAAC;YAC7D,cAAc,EAAE,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,eAAe,CAAC;YAChE,IAAI;SACL,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO;YACL,WAAW,EAAE,KAAK;YAClB,WAAW,EAAE,KAAK;YAClB,cAAc,EAAE,KAAK;YACrB,IAAI,EAAE,EAAE;SACT,CAAC;IACJ,CAAC;AACH,CAAC;AAED,gFAAgF;AAChF,wDAAwD;AACxD,gFAAgF;AAEhF;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,4BAA4B,CAAC,QAAgB;IAC3D,IAAI,iBAAiB,GAAuC,IAAI,CAAC;IAEjE,OAAO;QACL,KAAK,CAAC,WAAW;YACf,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,KAAK,CAAC,cAAc;YAClB,OAAO,iBAAiB,CAAC;QAC3B,CAAC;QAED,KAAK,CAAC,gBAAgB,CAAC,IAAiC;YACtD,iBAAiB,GAAG,IAAI,CAAC;QAC3B,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -105,4 +105,100 @@ export interface LeaseDetails {
105
105
  };
106
106
  readonly createdAt: string;
107
107
  }
108
+ /**
109
+ * Interface for retrieving deployment secrets
110
+ *
111
+ * Agents implement this interface to provide wallet credentials and certificate storage
112
+ * for fully automated deployments without user interaction.
113
+ *
114
+ * **SECURITY:** Implementations should retrieve secrets from secure storage
115
+ * (e.g., encrypted vault, KMS, secure environment variables).
116
+ *
117
+ * @example
118
+ * ```typescript
119
+ * const secretsProvider: SecretsProvider = {
120
+ * getMnemonic: async () => {
121
+ * // Retrieve from secure storage
122
+ * return await vault.getSecret('akash-wallet-mnemonic');
123
+ * },
124
+ * getCertificate: async () => {
125
+ * // Return cached cert or null to generate new
126
+ * return await storage.get('akash-certificate');
127
+ * },
128
+ * storeCertificate: async (cert) => {
129
+ * // Cache for future deployments
130
+ * await storage.set('akash-certificate', cert);
131
+ * }
132
+ * };
133
+ * ```
134
+ */
135
+ export interface SecretsProvider {
136
+ /**
137
+ * Retrieve the mnemonic phrase for the deployment wallet
138
+ *
139
+ * Called once at the start of deployment to create the signing wallet.
140
+ * The mnemonic should be a valid BIP39 phrase (12 or 24 words).
141
+ *
142
+ * @returns The mnemonic phrase
143
+ * @throws If mnemonic cannot be retrieved
144
+ */
145
+ getMnemonic(): Promise<string>;
146
+ /**
147
+ * Retrieve an existing TLS certificate (optional)
148
+ *
149
+ * If a valid certificate is returned, it will be used for provider communication.
150
+ * If null is returned, a new certificate will be generated and broadcast.
151
+ *
152
+ * Providing a cached certificate saves one blockchain transaction (~0.01 AKT).
153
+ *
154
+ * @returns Existing certificate or null to generate new
155
+ */
156
+ getCertificate?(): Promise<AkashProviderTlsCertificate | null>;
157
+ /**
158
+ * Store a newly generated certificate (optional)
159
+ *
160
+ * Called when a new certificate is generated and broadcast to the blockchain.
161
+ * Implementations should persist this for future deployments to avoid
162
+ * regenerating certificates.
163
+ *
164
+ * @param certificate - The newly generated certificate to store
165
+ */
166
+ storeCertificate?(certificate: AkashProviderTlsCertificate): Promise<void>;
167
+ }
168
+ /**
169
+ * Bid selection strategy for autonomous deployments
170
+ */
171
+ export type BidStrategy = 'cheapest' | 'most-reliable' | 'balanced';
172
+ /**
173
+ * Uptime period for reliability filtering
174
+ */
175
+ export type UptimePeriod = '1d' | '7d' | '30d';
176
+ /**
177
+ * Filter criteria for bid selection
178
+ */
179
+ export interface BidFilterCriteria {
180
+ /** Maximum price per block in uAKT */
181
+ readonly maxPricePerBlock?: number;
182
+ /**
183
+ * Minimum uptime requirement
184
+ *
185
+ * @example
186
+ * ```typescript
187
+ * // Require 95% uptime over last 7 days
188
+ * minUptime: { value: 0.95, period: '7d' }
189
+ * ```
190
+ */
191
+ readonly minUptime?: {
192
+ /** Uptime percentage (0-1), e.g., 0.95 = 95% */
193
+ readonly value: number;
194
+ /** Period to check: '1d', '7d', or '30d' */
195
+ readonly period: UptimePeriod;
196
+ };
197
+ /** Require audited providers only */
198
+ readonly requireAudited?: boolean;
199
+ /** Preferred regions (ISO country codes) */
200
+ readonly preferredRegions?: readonly string[];
201
+ /** Require provider to be online */
202
+ readonly requireOnline?: boolean;
203
+ }
108
204
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/targets/akash/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAExD,8FAA8F;AAC9F,MAAM,MAAM,WAAW,GAAG,kBAAkB,GAAG,mBAAmB,CAAC;AAEnE,sDAAsD;AACtD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;IACnC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,gGAAgG;AAChG,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAC;IACpC,QAAQ,CAAC,UAAU,CAAC,EAAE,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AAI,GAAG,IAAI,GAAG,KAAK,CAAC;AAE/C;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,sCAAsC;IACtC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC;;;;;;;;OAQG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE;QACnB,gDAAgD;QAChD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QACvB,4CAA4C;QAC5C,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;KAC/B,CAAC;IACF,qCAAqC;IACrC,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAClC,4CAA4C;IAC5C,QAAQ,CAAC,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9C,oCAAoC;IACpC,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;CAClC"}
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * Akash Network Wallet Connection Module
3
3
  *
4
- * Provides a clean, step-by-step API for connecting to Keplr wallet via WalletConnect.
4
+ * Provides a clean, step-by-step API for connecting to Keplr wallet via WalletConnect
5
+ * or creating agent-controlled wallets from mnemonics for fully automated deployments.
5
6
  * This is a LIBRARY - no QR code display, no prompts, just pure wallet operations.
6
7
  *
7
8
  * @module targets/akash/wallet
@@ -188,22 +189,39 @@ export declare function connectWallet(projectId: string, network: AkashNetwork,
188
189
  /**
189
190
  * Create wallet context from mnemonic (for agent-controlled wallets)
190
191
  *
192
+ * Creates a fully functional wallet context from a BIP39 mnemonic phrase,
193
+ * enabling fully automated deployments without any user interaction.
194
+ *
191
195
  * **SECURITY WARNING:** Only use this for automation YOU control (CI/CD, your own agents).
192
196
  * For third-party services, use connectWallet() with WalletConnect instead to avoid
193
197
  * exposing your mnemonic.
194
198
  *
195
199
  * @param mnemonic - BIP39 mnemonic phrase (12 or 24 words)
196
200
  * @param network - Akash network to connect to
201
+ * @param options - Optional configuration
197
202
  * @returns Result with wallet context or error
198
203
  *
199
204
  * @example
200
205
  * ```typescript
201
- * const mnemonic = process.env.DEPLOYMENT_WALLET_MNEMONIC!;
206
+ * // Agent-controlled deployment
207
+ * const mnemonic = await mySecretsPlugin.getWalletMnemonic();
202
208
  * const wallet = await createWalletFromMnemonic(mnemonic, 'mainnet');
203
209
  * if (wallet.success) {
204
210
  * await deployToAkash({ wallet: wallet.data, ... });
205
211
  * }
206
212
  * ```
213
+ *
214
+ * @example
215
+ * ```typescript
216
+ * // CI/CD pipeline
217
+ * const mnemonic = process.env.DEPLOYMENT_WALLET_MNEMONIC!;
218
+ * const wallet = await createWalletFromMnemonic(mnemonic, 'mainnet');
219
+ * ```
207
220
  */
208
- export declare function createWalletFromMnemonic(_mnemonic: string, network: AkashNetwork): Promise<Result<WalletContext, WalletError>>;
221
+ export declare function createWalletFromMnemonic(mnemonic: string, network: AkashNetwork, options?: {
222
+ /** HD derivation path (defaults to Cosmos standard: m/44'/118'/0'/0/0) */
223
+ hdPath?: string;
224
+ /** Account index for HD derivation (defaults to 0) */
225
+ accountIndex?: number;
226
+ }): Promise<Result<WalletContext, WalletError>>;
209
227
  //# sourceMappingURL=wallet-manager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wallet-manager.d.ts","sourceRoot":"","sources":["../../../src/targets/akash/wallet-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;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,EAAqC,MAAM,uBAAuB,CAAC;AACvF,OAAO,EAAoB,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEvE,mCAAmC;AACnC,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,M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BG;AACH,wBAAsB,aAAa,CACjC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,YAAY,EACrB,OAAO,CAAC,EAAE;IACR,sDAAsD;IACtD,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,yCAAyC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mBAAmB;IACnB,QAAQ,CAAC,EAAE;QACT,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,MAAM,EAAE,CAAC;KACjB,CAAC;CACH,GACA,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC,CA6B7C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAsB,wBAAwB,CAC5C,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,YAAY,EACrB,OAAO,CAAC,EAAE;IACR,0EAA0E;IAC1E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sDAAsD;IACtD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GACA,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC,CA0J7C"}
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * Akash Network Wallet Connection Module
3
3
  *
4
- * Provides a clean, step-by-step API for connecting to Keplr wallet via WalletConnect.
4
+ * Provides a clean, step-by-step API for connecting to Keplr wallet via WalletConnect
5
+ * or creating agent-controlled wallets from mnemonics for fully automated deployments.
5
6
  * This is a LIBRARY - no QR code display, no prompts, just pure wallet operations.
6
7
  *
7
8
  * @module targets/akash/wallet
@@ -9,6 +10,7 @@
9
10
  import { SignClient } from '@walletconnect/sign-client';
10
11
  import { KeplrWalletConnectV2 } from '@keplr-wallet/wc-client';
11
12
  import { fromHex } from '@cosmjs/encoding';
13
+ import { DirectSecp256k1HdWallet } from '@cosmjs/proto-signing';
12
14
  import { StargateClient } from '@cosmjs/stargate';
13
15
  import { WalletError, WalletErrorCodes, getErrorMessage } from '../../errors/index.js';
14
16
  import { getNetworkConfig } from './environment.js';
@@ -529,28 +531,155 @@ export async function connectWallet(projectId, network, options) {
529
531
  /**
530
532
  * Create wallet context from mnemonic (for agent-controlled wallets)
531
533
  *
534
+ * Creates a fully functional wallet context from a BIP39 mnemonic phrase,
535
+ * enabling fully automated deployments without any user interaction.
536
+ *
532
537
  * **SECURITY WARNING:** Only use this for automation YOU control (CI/CD, your own agents).
533
538
  * For third-party services, use connectWallet() with WalletConnect instead to avoid
534
539
  * exposing your mnemonic.
535
540
  *
536
541
  * @param mnemonic - BIP39 mnemonic phrase (12 or 24 words)
537
542
  * @param network - Akash network to connect to
543
+ * @param options - Optional configuration
538
544
  * @returns Result with wallet context or error
539
545
  *
540
546
  * @example
541
547
  * ```typescript
542
- * const mnemonic = process.env.DEPLOYMENT_WALLET_MNEMONIC!;
548
+ * // Agent-controlled deployment
549
+ * const mnemonic = await mySecretsPlugin.getWalletMnemonic();
543
550
  * const wallet = await createWalletFromMnemonic(mnemonic, 'mainnet');
544
551
  * if (wallet.success) {
545
552
  * await deployToAkash({ wallet: wallet.data, ... });
546
553
  * }
547
554
  * ```
555
+ *
556
+ * @example
557
+ * ```typescript
558
+ * // CI/CD pipeline
559
+ * const mnemonic = process.env.DEPLOYMENT_WALLET_MNEMONIC!;
560
+ * const wallet = await createWalletFromMnemonic(mnemonic, 'mainnet');
561
+ * ```
548
562
  */
549
- export async function createWalletFromMnemonic(_mnemonic, network) {
550
- // TODO: Implement using DirectSecp256k1HdWallet from @cosmjs/proto-signing
551
- return {
552
- success: false,
553
- error: new WalletError('createWalletFromMnemonic() not yet implemented', WalletErrorCodes.NOT_IMPLEMENTED, { network }),
554
- };
563
+ export async function createWalletFromMnemonic(mnemonic, network, options) {
564
+ try {
565
+ // Step 1: Validate mnemonic format
566
+ if (!mnemonic || typeof mnemonic !== 'string') {
567
+ return {
568
+ success: false,
569
+ error: new WalletError('Mnemonic is required', WalletErrorCodes.WALLET_ERROR, { provided: typeof mnemonic }),
570
+ };
571
+ }
572
+ // Basic mnemonic validation (12 or 24 words)
573
+ const words = mnemonic.trim().split(/\s+/);
574
+ if (words.length !== 12 && words.length !== 24) {
575
+ return {
576
+ success: false,
577
+ error: new WalletError(`Invalid mnemonic: expected 12 or 24 words, got ${words.length}`, WalletErrorCodes.WALLET_ERROR, { wordCount: words.length }),
578
+ };
579
+ }
580
+ // Step 2: Get network configuration
581
+ const networkConfig = getNetworkConfig(network);
582
+ // Step 3: Create DirectSecp256k1HdWallet with Akash bech32 prefix
583
+ // The wallet handles both Amino and Direct signing
584
+ let wallet;
585
+ try {
586
+ wallet = await DirectSecp256k1HdWallet.fromMnemonic(mnemonic.trim(), {
587
+ prefix: 'akash',
588
+ // Use custom HD path if provided, otherwise use Cosmos default
589
+ hdPaths: options?.hdPath
590
+ ? [{ toString: () => options.hdPath }]
591
+ : undefined,
592
+ });
593
+ }
594
+ catch (error) {
595
+ const errMsg = getErrorMessage(error);
596
+ return {
597
+ success: false,
598
+ error: new WalletError(`Invalid mnemonic phrase: ${errMsg}`, WalletErrorCodes.WALLET_ERROR, { error: errMsg }),
599
+ };
600
+ }
601
+ // Step 4: Get accounts from wallet
602
+ const accounts = await wallet.getAccounts();
603
+ if (accounts.length === 0) {
604
+ return {
605
+ success: false,
606
+ error: new WalletError('No accounts derived from mnemonic', WalletErrorCodes.NO_SIGNER_ACCOUNTS, { network }),
607
+ };
608
+ }
609
+ const accountIndex = options?.accountIndex ?? 0;
610
+ const account = accounts[accountIndex];
611
+ if (!account) {
612
+ return {
613
+ success: false,
614
+ error: new WalletError(`Account index ${accountIndex} not found (only ${accounts.length} accounts available)`, WalletErrorCodes.ACCOUNT_NOT_FOUND, { accountIndex, availableAccounts: accounts.length }),
615
+ };
616
+ }
617
+ const address = account.address;
618
+ // Step 5: Create a signer that implements both OfflineAminoSigner & OfflineDirectSigner
619
+ // DirectSecp256k1HdWallet implements OfflineDirectSigner but we need both for Akash
620
+ // We create a combined signer interface
621
+ const signer = {
622
+ getAccounts: async () => wallet.getAccounts(),
623
+ signDirect: async (signerAddress, signDoc) => wallet.signDirect(signerAddress, signDoc),
624
+ // For Amino signing, we use the direct signer's accounts
625
+ // and delegate to signDirect (Akash SDK handles conversion)
626
+ signAmino: async (_signerAddress, _signDoc) => {
627
+ // DirectSecp256k1HdWallet doesn't implement signAmino directly
628
+ // but Akash chain-sdk uses signDirect when available
629
+ // For compatibility, we throw a clear error if Amino is specifically required
630
+ throw new Error('Amino signing not supported by mnemonic wallet. ' +
631
+ 'Use WalletConnect for legacy Amino-only operations.');
632
+ },
633
+ };
634
+ // Step 6: Query blockchain for account data (balance, sequence, etc.)
635
+ // This is non-fatal - wallet can work without it (account created on first tx)
636
+ let accountData;
637
+ try {
638
+ const stargateClient = await StargateClient.connect(networkConfig.rpc);
639
+ try {
640
+ const chainAccount = await stargateClient.getAccount(address);
641
+ if (chainAccount) {
642
+ accountData = {
643
+ address: chainAccount.address,
644
+ pubkey: chainAccount.pubkey
645
+ ? fromHex(Buffer.from(chainAccount.pubkey.value).toString('hex'))
646
+ : null,
647
+ accountNumber: chainAccount.accountNumber,
648
+ sequence: chainAccount.sequence,
649
+ };
650
+ }
651
+ // Account might not exist on chain yet (new/unfunded account)
652
+ // This is OK - account will be created with first transaction
653
+ }
654
+ finally {
655
+ stargateClient.disconnect();
656
+ }
657
+ }
658
+ catch {
659
+ // Network query failed - wallet still works, just no account data
660
+ // This is fine for new accounts or when network is unreachable
661
+ accountData = undefined;
662
+ }
663
+ // Step 7: Create wallet context
664
+ const walletContext = {
665
+ address,
666
+ signer,
667
+ offlineSigner: signer,
668
+ chainId: networkConfig.chainId,
669
+ account: accountData,
670
+ // signClient and session are undefined - only used for WalletConnect
671
+ };
672
+ return {
673
+ success: true,
674
+ data: walletContext,
675
+ };
676
+ }
677
+ catch (error) {
678
+ const errMsg = getErrorMessage(error);
679
+ return {
680
+ success: false,
681
+ error: new WalletError(`Failed to create wallet from mnemonic: ${errMsg}`, WalletErrorCodes.CONTEXT_CREATION_FAILED, { error: errMsg, network }),
682
+ };
683
+ }
555
684
  }
556
685
  //# sourceMappingURL=wallet-manager.js.map