@coinfello/agent-cli 0.1.19 → 0.1.22
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/dist/index.js
CHANGED
|
@@ -331,8 +331,8 @@ function createSubdelegation({
|
|
|
331
331
|
salt: `0x${randomBytes(32).toString("hex")}`
|
|
332
332
|
});
|
|
333
333
|
}
|
|
334
|
-
async function createSmartAccountWithSecureEnclave(
|
|
335
|
-
const chain = resolveChainInput(
|
|
334
|
+
async function createSmartAccountWithSecureEnclave() {
|
|
335
|
+
const chain = resolveChainInput(1);
|
|
336
336
|
const publicClient = createPublicClient(chain);
|
|
337
337
|
const keyPair = await generateKey();
|
|
338
338
|
const keyId = `0x${randomBytes(32).toString("hex")}`;
|
|
@@ -3185,60 +3185,58 @@ program.name("coinfello").description("CoinFello CLI - MetaMask Smart Account in
|
|
|
3185
3185
|
program.command("create_account").description("Create a MetaMask smart account and save its address to local config").option(
|
|
3186
3186
|
"--use-unsafe-private-key",
|
|
3187
3187
|
"Use a raw private key instead of hardware-backed key (Secure Enclave / TPM 2.0)"
|
|
3188
|
-
).option("--delete-existing-private-key", "Delete the existing account and create a new one").action(
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
if (
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
process.exit(1);
|
|
3198
|
-
}
|
|
3199
|
-
console.warn("Deleting existing account and creating a new one...");
|
|
3200
|
-
}
|
|
3201
|
-
const useHardwareKey = !opts.useUnsafePrivateKey && isSecureEnclaveAvailable();
|
|
3202
|
-
if (useHardwareKey) {
|
|
3203
|
-
console.log(`Creating Secure Enclave-backed smart account on ${chain}...`);
|
|
3204
|
-
const { address, keyTag, publicKeyX, publicKeyY, keyId } = await createSmartAccountWithSecureEnclave(chain);
|
|
3205
|
-
config.signer_type = "secureEnclave";
|
|
3206
|
-
config.smart_account_address = address;
|
|
3207
|
-
config.secure_enclave = {
|
|
3208
|
-
key_tag: keyTag,
|
|
3209
|
-
public_key_x: publicKeyX,
|
|
3210
|
-
public_key_y: publicKeyY,
|
|
3211
|
-
key_id: keyId
|
|
3212
|
-
};
|
|
3213
|
-
delete config.private_key;
|
|
3214
|
-
await saveConfig(config);
|
|
3215
|
-
console.log("Secure Enclave smart account created successfully.");
|
|
3216
|
-
console.log(`Address: ${address}`);
|
|
3217
|
-
console.log(`Key tag: ${keyTag}`);
|
|
3218
|
-
console.log(`Config saved to: ${CONFIG_PATH}`);
|
|
3219
|
-
} else {
|
|
3220
|
-
if (!opts.useUnsafePrivateKey) {
|
|
3221
|
-
console.warn(
|
|
3222
|
-
"Warning: No hardware key support detected. Falling back to raw private key."
|
|
3223
|
-
);
|
|
3224
|
-
}
|
|
3225
|
-
console.log(`Creating smart account...`);
|
|
3226
|
-
const privateKey = generatePrivateKey();
|
|
3227
|
-
const { address } = await createSmartAccount(privateKey, 1);
|
|
3228
|
-
config.private_key = privateKey;
|
|
3229
|
-
config.signer_type = "privateKey";
|
|
3230
|
-
config.smart_account_address = address;
|
|
3231
|
-
await saveConfig(config);
|
|
3232
|
-
console.log("Smart account created successfully.");
|
|
3233
|
-
console.log(`Address: ${address}`);
|
|
3234
|
-
console.log(`Config saved to: ${CONFIG_PATH}`);
|
|
3188
|
+
).option("--delete-existing-private-key", "Delete the existing account and create a new one").action(async (opts) => {
|
|
3189
|
+
try {
|
|
3190
|
+
const config = await loadConfig();
|
|
3191
|
+
if (config.smart_account_address) {
|
|
3192
|
+
if (!opts.deleteExistingPrivateKey) {
|
|
3193
|
+
console.error(
|
|
3194
|
+
`Error: An account already exists (${config.smart_account_address}). Use --delete-existing-private-key to overwrite it.`
|
|
3195
|
+
);
|
|
3196
|
+
process.exit(1);
|
|
3235
3197
|
}
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3198
|
+
console.warn("Deleting existing account and creating a new one...");
|
|
3199
|
+
}
|
|
3200
|
+
const useHardwareKey = !opts.useUnsafePrivateKey && isSecureEnclaveAvailable();
|
|
3201
|
+
if (useHardwareKey) {
|
|
3202
|
+
console.log(`Creating Secure Enclave-backed smart account`);
|
|
3203
|
+
const { address, keyTag, publicKeyX, publicKeyY, keyId } = await createSmartAccountWithSecureEnclave();
|
|
3204
|
+
config.signer_type = "secureEnclave";
|
|
3205
|
+
config.smart_account_address = address;
|
|
3206
|
+
config.secure_enclave = {
|
|
3207
|
+
key_tag: keyTag,
|
|
3208
|
+
public_key_x: publicKeyX,
|
|
3209
|
+
public_key_y: publicKeyY,
|
|
3210
|
+
key_id: keyId
|
|
3211
|
+
};
|
|
3212
|
+
delete config.private_key;
|
|
3213
|
+
await saveConfig(config);
|
|
3214
|
+
console.log("Secure Enclave smart account created successfully.");
|
|
3215
|
+
console.log(`Address: ${address}`);
|
|
3216
|
+
console.log(`Key tag: ${keyTag}`);
|
|
3217
|
+
console.log(`Config saved to: ${CONFIG_PATH}`);
|
|
3218
|
+
} else {
|
|
3219
|
+
if (!opts.useUnsafePrivateKey) {
|
|
3220
|
+
console.warn(
|
|
3221
|
+
"Warning: No hardware key support detected. Falling back to raw private key."
|
|
3222
|
+
);
|
|
3223
|
+
}
|
|
3224
|
+
console.log(`Creating smart account...`);
|
|
3225
|
+
const privateKey = generatePrivateKey();
|
|
3226
|
+
const { address } = await createSmartAccount(privateKey, 1);
|
|
3227
|
+
config.private_key = privateKey;
|
|
3228
|
+
config.signer_type = "privateKey";
|
|
3229
|
+
config.smart_account_address = address;
|
|
3230
|
+
await saveConfig(config);
|
|
3231
|
+
console.log("Smart account created successfully.");
|
|
3232
|
+
console.log(`Address: ${address}`);
|
|
3233
|
+
console.log(`Config saved to: ${CONFIG_PATH}`);
|
|
3239
3234
|
}
|
|
3235
|
+
} catch (err) {
|
|
3236
|
+
console.error(`Failed to create account: ${err.message}`);
|
|
3237
|
+
process.exit(1);
|
|
3240
3238
|
}
|
|
3241
|
-
);
|
|
3239
|
+
});
|
|
3242
3240
|
program.command("get_account").description("Display the current smart account address from local config").action(async () => {
|
|
3243
3241
|
try {
|
|
3244
3242
|
const config = await loadConfig();
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coinfello/agent-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.22",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"bin": {
|
|
8
|
-
"
|
|
8
|
+
"coinfello": "./dist/index.js"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"dist"
|