@coinfello/agent-cli 0.1.15 → 0.1.16
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
CHANGED
|
@@ -13,22 +13,22 @@ You can run the CLI via `node dist/index.js` after building.
|
|
|
13
13
|
|
|
14
14
|
### 1. create_account
|
|
15
15
|
|
|
16
|
-
Creates a MetaMask Hybrid smart account
|
|
16
|
+
Creates a MetaMask Hybrid smart account. By default, the signing key is generated in the **macOS Secure Enclave** (hardware-backed, non-exportable). If Secure Enclave is unavailable, the CLI warns and falls back to a software key. The chain is determined dynamically by the server when a delegation is requested via `send_prompt`.
|
|
17
17
|
|
|
18
18
|
Pass `--use-unsafe-private-key` to explicitly use a plaintext software key (development/testing only).
|
|
19
19
|
|
|
20
20
|
```bash
|
|
21
21
|
# Default: Secure Enclave
|
|
22
|
-
node dist/index.js create_account
|
|
22
|
+
node dist/index.js create_account
|
|
23
23
|
|
|
24
24
|
# Development/testing: plaintext private key
|
|
25
|
-
node dist/index.js create_account
|
|
25
|
+
node dist/index.js create_account --use-unsafe-private-key
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
Expected output (Secure Enclave):
|
|
29
29
|
|
|
30
30
|
```
|
|
31
|
-
Creating Secure Enclave-backed smart account
|
|
31
|
+
Creating Secure Enclave-backed smart account...
|
|
32
32
|
Secure Enclave smart account created successfully.
|
|
33
33
|
Address: 0x...
|
|
34
34
|
Key tag: ...
|
|
@@ -38,7 +38,7 @@ Config saved to: /home/<user>/.clawdbot/skills/coinfello/config.json
|
|
|
38
38
|
Expected output (unsafe private key):
|
|
39
39
|
|
|
40
40
|
```
|
|
41
|
-
Creating smart account
|
|
41
|
+
Creating smart account...
|
|
42
42
|
Smart account created successfully.
|
|
43
43
|
Address: 0x...
|
|
44
44
|
Config saved to: /home/<user>/.clawdbot/skills/coinfello/config.json
|
package/dist/index.js
CHANGED
|
@@ -3044,18 +3044,14 @@ async function sendConversation({
|
|
|
3044
3044
|
}
|
|
3045
3045
|
return response.json();
|
|
3046
3046
|
}
|
|
3047
|
+
const SIWE_CHAIN_ID = 1;
|
|
3047
3048
|
async function signInWithAgent(baseUrl, config) {
|
|
3048
3049
|
if (!config.smart_account_address) {
|
|
3049
3050
|
throw new Error("No smart account address found in config. Run 'create_account' first.");
|
|
3050
3051
|
}
|
|
3051
|
-
if (!config.chain) {
|
|
3052
|
-
throw new Error("No chain found in config. Run 'create_account' first.");
|
|
3053
|
-
}
|
|
3054
3052
|
if (config.signer_type !== "secureEnclave" && !config.private_key) {
|
|
3055
3053
|
throw new Error("No private key found in config. Run 'create_account' first.");
|
|
3056
3054
|
}
|
|
3057
|
-
const chain = resolveChain(config.chain);
|
|
3058
|
-
const chainId = chain.id;
|
|
3059
3055
|
const walletAddress = config.smart_account_address;
|
|
3060
3056
|
let smartAccount;
|
|
3061
3057
|
if (config.signer_type === "secureEnclave") {
|
|
@@ -3067,10 +3063,10 @@ async function signInWithAgent(baseUrl, config) {
|
|
|
3067
3063
|
config.secure_enclave.public_key_x,
|
|
3068
3064
|
config.secure_enclave.public_key_y,
|
|
3069
3065
|
config.secure_enclave.key_id,
|
|
3070
|
-
|
|
3066
|
+
SIWE_CHAIN_ID
|
|
3071
3067
|
);
|
|
3072
3068
|
} else {
|
|
3073
|
-
const result2 = await createSmartAccount(config.private_key,
|
|
3069
|
+
const result2 = await createSmartAccount(config.private_key, SIWE_CHAIN_ID);
|
|
3074
3070
|
smartAccount = result2.smartAccount;
|
|
3075
3071
|
}
|
|
3076
3072
|
const url = new URL(baseUrl);
|
|
@@ -3079,7 +3075,7 @@ async function signInWithAgent(baseUrl, config) {
|
|
|
3079
3075
|
const nonceResponse = await fetchWithCookies(`${baseUrl}/siwe/nonce`, {
|
|
3080
3076
|
method: "POST",
|
|
3081
3077
|
headers: { "Content-Type": "application/json" },
|
|
3082
|
-
body: JSON.stringify({ walletAddress, chainId })
|
|
3078
|
+
body: JSON.stringify({ walletAddress, chainId: SIWE_CHAIN_ID })
|
|
3083
3079
|
});
|
|
3084
3080
|
if (!nonceResponse.ok) {
|
|
3085
3081
|
const text = await nonceResponse.text();
|
|
@@ -3105,7 +3101,7 @@ async function signInWithAgent(baseUrl, config) {
|
|
|
3105
3101
|
const verifyResponse = await fetchWithCookies(`${baseUrl}/siwe/verify`, {
|
|
3106
3102
|
method: "POST",
|
|
3107
3103
|
headers: { "Content-Type": "application/json" },
|
|
3108
|
-
body: JSON.stringify({ message, signature, walletAddress, chainId })
|
|
3104
|
+
body: JSON.stringify({ message, signature, walletAddress, chainId: SIWE_CHAIN_ID })
|
|
3109
3105
|
});
|
|
3110
3106
|
if (!verifyResponse.ok) {
|
|
3111
3107
|
const text = await verifyResponse.text();
|
|
@@ -3186,7 +3182,7 @@ function parseScope(raw) {
|
|
|
3186
3182
|
}
|
|
3187
3183
|
const program = new Command();
|
|
3188
3184
|
program.name("openclaw").description("CoinFello CLI - MetaMask Smart Account interactions").version("1.0.0");
|
|
3189
|
-
program.command("create_account").description("Create a MetaMask smart account and save its address to local config").
|
|
3185
|
+
program.command("create_account").description("Create a MetaMask smart account and save its address to local config").option(
|
|
3190
3186
|
"--use-unsafe-private-key",
|
|
3191
3187
|
"Use a raw private key instead of hardware-backed key (Secure Enclave / TPM 2.0)"
|
|
3192
3188
|
).option("--delete-existing-private-key", "Delete the existing account and create a new one").action(
|
|
@@ -3208,7 +3204,6 @@ program.command("create_account").description("Create a MetaMask smart account a
|
|
|
3208
3204
|
const { address, keyTag, publicKeyX, publicKeyY, keyId } = await createSmartAccountWithSecureEnclave(chain);
|
|
3209
3205
|
config.signer_type = "secureEnclave";
|
|
3210
3206
|
config.smart_account_address = address;
|
|
3211
|
-
config.chain = chain;
|
|
3212
3207
|
config.secure_enclave = {
|
|
3213
3208
|
key_tag: keyTag,
|
|
3214
3209
|
public_key_x: publicKeyX,
|
|
@@ -3227,13 +3222,12 @@ program.command("create_account").description("Create a MetaMask smart account a
|
|
|
3227
3222
|
"Warning: No hardware key support detected. Falling back to raw private key."
|
|
3228
3223
|
);
|
|
3229
3224
|
}
|
|
3230
|
-
console.log(`Creating smart account
|
|
3225
|
+
console.log(`Creating smart account...`);
|
|
3231
3226
|
const privateKey = generatePrivateKey();
|
|
3232
|
-
const { address } = await createSmartAccount(privateKey,
|
|
3227
|
+
const { address } = await createSmartAccount(privateKey, 1);
|
|
3233
3228
|
config.private_key = privateKey;
|
|
3234
3229
|
config.signer_type = "privateKey";
|
|
3235
3230
|
config.smart_account_address = address;
|
|
3236
|
-
config.chain = chain;
|
|
3237
3231
|
await saveConfig(config);
|
|
3238
3232
|
console.log("Smart account created successfully.");
|
|
3239
3233
|
console.log(`Address: ${address}`);
|
|
@@ -3295,10 +3289,6 @@ program.command("send_prompt").description("Send a prompt to CoinFello, creating
|
|
|
3295
3289
|
console.error("Error: No smart account found. Run 'create_account' first.");
|
|
3296
3290
|
process.exit(1);
|
|
3297
3291
|
}
|
|
3298
|
-
if (!config.chain) {
|
|
3299
|
-
console.error("Error: No chain found in config. Run 'create_account' first.");
|
|
3300
|
-
process.exit(1);
|
|
3301
|
-
}
|
|
3302
3292
|
if (config.signer_type !== "secureEnclave" && !config.private_key) {
|
|
3303
3293
|
console.error("Error: No private key found in config. Run 'create_account' first.");
|
|
3304
3294
|
process.exit(1);
|
|
@@ -3361,7 +3351,7 @@ program.command("send_prompt").description("Send a prompt to CoinFello, creating
|
|
|
3361
3351
|
});
|
|
3362
3352
|
console.log("Signed subdelegation");
|
|
3363
3353
|
let sig = signature;
|
|
3364
|
-
const chain = resolveChainInput(
|
|
3354
|
+
const chain = resolveChainInput(args.chainId);
|
|
3365
3355
|
const publicClient = createPublicClient(chain);
|
|
3366
3356
|
console.log("Getting code...");
|
|
3367
3357
|
const code = await publicClient.getCode({ address: smartAccount.address });
|
|
Binary file
|