From 9354404c62e2e9881f285c941f6dbcec741e18ff Mon Sep 17 00:00:00 2001 From: SynthLuvr <131367121+SynthLuvr@users.noreply.github.com> Date: Tue, 1 Jul 2025 12:30:16 +0200 Subject: [PATCH] Added persistent wallet configuration --- .prettierrc | 2 + package.json | 23 +- pnpm-lock.yaml | 420 +++++++++++++++++++----------------- src/addresses/to-address.ts | 12 +- src/commands/cli.ts | 4 +- src/commands/config.ts | 48 +++++ src/commands/index.ts | 3 +- src/commands/payload.ts | 10 +- src/commands/wallet.ts | 4 +- src/config.ts | 21 ++ src/node-machine-id.d.ts | 8 + src/seed.ts | 23 +- 12 files changed, 334 insertions(+), 244 deletions(-) create mode 100644 .prettierrc create mode 100644 src/commands/config.ts create mode 100644 src/config.ts create mode 100644 src/node-machine-id.d.ts diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..907f6ba --- /dev/null +++ b/.prettierrc @@ -0,0 +1,2 @@ +plugins: + - "@ianvs/prettier-plugin-sort-imports" diff --git a/package.json b/package.json index 4b325fa..36d801a 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "version": "0.0.0", "description": "CLI for interacting with Mynth wallets", "license": "MIT", - "packageManager": "pnpm@10.12.1", + "packageManager": "pnpm@10.12.4", "repository": { "type": "git", "url": "git+https://github.com/MynthAI/wallet.git" @@ -27,7 +27,7 @@ "dependencies": { "@inquirer/prompts": "^7.5.3", "@lucid-evolution/lucid": "^0.4.29", - "@mysten/sui": "^1.33.0", + "@mysten/sui": "^1.34.0", "@webbuf/blake3": "^1.0.127", "@webbuf/webbuf": "^1.0.127", "arktype": "^2.1.20", @@ -38,23 +38,24 @@ "conf": "^14.0.0", "inquirer": "^12.6.3", "js-sha3": "^0.9.3", + "node-machine-id": "^1.1.12", "ts-handling": "^0.2.5", "web3-utils": "^4.3.3" }, "devDependencies": { "@eslint/eslintrc": "^3.3.1", - "@eslint/js": "^9.29.0", + "@eslint/js": "^9.30.0", "@ianvs/prettier-plugin-sort-imports": "^4.4.2", - "@types/node": "^24.0.1", - "@typescript-eslint/eslint-plugin": "^8.34.0", - "@typescript-eslint/parser": "^8.34.0", - "concurrently": "^9.1.2", + "@types/node": "^24.0.8", + "@typescript-eslint/eslint-plugin": "^8.35.1", + "@typescript-eslint/parser": "^8.35.1", + "concurrently": "^9.2.0", + "eslint": "^9.30.0", "eslint-config-prettier": "^10.1.5", "eslint-import-resolver-node": "^0.3.9", - "eslint-import-resolver-typescript": "^4.4.3", - "eslint-plugin-import": "^2.31.0", - "eslint": "^9.29.0", - "prettier": "^3.5.3", + "eslint-import-resolver-typescript": "^4.4.4", + "eslint-plugin-import": "^2.32.0", + "prettier": "^3.6.2", "tsx": "^4.20.3" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9483e0f..27caab2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,13 +12,13 @@ importers: dependencies: "@inquirer/prompts": specifier: ^7.5.3 - version: 7.5.3(@types/node@24.0.1) + version: 7.5.3(@types/node@24.0.8) "@lucid-evolution/lucid": specifier: ^0.4.29 version: 0.4.29(@harmoniclabs/bytestring@1.0.0)(@harmoniclabs/cbor@1.6.6)(@harmoniclabs/crypto@0.3.0)(@harmoniclabs/pair@1.0.0)(fast-check@3.23.2)(rxjs@7.8.2) "@mysten/sui": - specifier: ^1.33.0 - version: 1.33.0(typescript@5.8.3) + specifier: ^1.34.0 + version: 1.34.0(typescript@5.8.3) "@webbuf/blake3": specifier: ^1.0.127 version: 1.0.127(@webbuf/fixedbuf@1.0.127(@webbuf/webbuf@1.0.127))(@webbuf/webbuf@1.0.127) @@ -45,10 +45,13 @@ importers: version: 14.0.0 inquirer: specifier: ^12.6.3 - version: 12.6.3(@types/node@24.0.1) + version: 12.6.3(@types/node@24.0.8) js-sha3: specifier: ^0.9.3 version: 0.9.3 + node-machine-id: + specifier: ^1.1.12 + version: 1.1.12 ts-handling: specifier: ^0.2.5 version: 0.2.5 @@ -60,41 +63,41 @@ importers: specifier: ^3.3.1 version: 3.3.1 "@eslint/js": - specifier: ^9.29.0 - version: 9.29.0 + specifier: ^9.30.0 + version: 9.30.0 "@ianvs/prettier-plugin-sort-imports": specifier: ^4.4.2 - version: 4.4.2(prettier@3.5.3) + version: 4.4.2(prettier@3.6.2) "@types/node": - specifier: ^24.0.1 - version: 24.0.1 + specifier: ^24.0.8 + version: 24.0.8 "@typescript-eslint/eslint-plugin": - specifier: ^8.34.0 - version: 8.34.0(@typescript-eslint/parser@8.34.0(eslint@9.29.0)(typescript@5.8.3))(eslint@9.29.0)(typescript@5.8.3) + specifier: ^8.35.1 + version: 8.35.1(@typescript-eslint/parser@8.35.1(eslint@9.30.0)(typescript@5.8.3))(eslint@9.30.0)(typescript@5.8.3) "@typescript-eslint/parser": - specifier: ^8.34.0 - version: 8.34.0(eslint@9.29.0)(typescript@5.8.3) + specifier: ^8.35.1 + version: 8.35.1(eslint@9.30.0)(typescript@5.8.3) concurrently: - specifier: ^9.1.2 - version: 9.1.2 + specifier: ^9.2.0 + version: 9.2.0 eslint: - specifier: ^9.29.0 - version: 9.29.0 + specifier: ^9.30.0 + version: 9.30.0 eslint-config-prettier: specifier: ^10.1.5 - version: 10.1.5(eslint@9.29.0) + version: 10.1.5(eslint@9.30.0) eslint-import-resolver-node: specifier: ^0.3.9 version: 0.3.9 eslint-import-resolver-typescript: - specifier: ^4.4.3 - version: 4.4.3(eslint-plugin-import@2.31.0)(eslint@9.29.0) + specifier: ^4.4.4 + version: 4.4.4(eslint-plugin-import@2.32.0)(eslint@9.30.0) eslint-plugin-import: - specifier: ^2.31.0 - version: 2.31.0(@typescript-eslint/parser@8.34.0(eslint@9.29.0)(typescript@5.8.3))(eslint-import-resolver-typescript@4.4.3)(eslint@9.29.0) + specifier: ^2.32.0 + version: 2.32.0(@typescript-eslint/parser@8.35.1(eslint@9.30.0)(typescript@5.8.3))(eslint-import-resolver-typescript@4.4.4)(eslint@9.30.0) prettier: - specifier: ^3.5.3 - version: 3.5.3 + specifier: ^3.6.2 + version: 3.6.2 tsx: specifier: ^4.20.3 version: 4.20.3 @@ -635,17 +638,17 @@ packages: } engines: { node: ^12.0.0 || ^14.0.0 || >=16.0.0 } - "@eslint/config-array@0.20.1": + "@eslint/config-array@0.21.0": resolution: { - integrity: sha512-OL0RJzC/CBzli0DrrR31qzj6d6i6Mm3HByuhflhl4LOBiWxN+3i6/t/ZQQNii4tjksXi8r2CRW1wMpWA2ULUEw==, + integrity: sha512-ENIdc4iLu0d93HeYirvKmrzshzofPw6VkZRKQGe9Nv46ZnWUzcF1xV01dcvEg/1wXUR61OmmlSfyeyO7EvjLxQ==, } engines: { node: ^18.18.0 || ^20.9.0 || >=21.1.0 } - "@eslint/config-helpers@0.2.3": + "@eslint/config-helpers@0.3.0": resolution: { - integrity: sha512-u180qk2Um1le4yf0ruXH3PYFeEZeYC3p/4wCTKrr2U1CmGdzGi3KtY0nuPDH48UJxlKCC5RDzbcbh4X0XlqgHg==, + integrity: sha512-ViuymvFmcJi04qdZeDc2whTHryouGcDlaxPqarTD0ZE10ISpxGUVZGZDx4w01upyIynL3iu6IXH2bS1NhclQMw==, } engines: { node: ^18.18.0 || ^20.9.0 || >=21.1.0 } @@ -670,10 +673,10 @@ packages: } engines: { node: ^18.18.0 || ^20.9.0 || >=21.1.0 } - "@eslint/js@9.29.0": + "@eslint/js@9.30.0": resolution: { - integrity: sha512-3PIF4cBw/y+1u2EazflInpV+lYsSG0aByVIQzAgb1m1MhHFSbqTyNqtBKHgWf/9Ykud+DhILS9EGkmekVhbKoQ==, + integrity: sha512-Wzw3wQwPvc9sHM+NjakWTcPx11mbZyiYHuwWa/QfZ7cIRX7WK54PSk7bdyXDaoaopUcMatv1zaQvOAAO8hCdww==, } engines: { node: ^18.18.0 || ^20.9.0 || >=21.1.0 } @@ -1139,10 +1142,10 @@ packages: integrity: sha512-QQ6u0U7a4+/o6rZ9tALTeGYMdf6V5z/HkRI/mhD5/fSr80DJoGzOWpFszcN/fhJpKb36vBaSQUMpS7yNQ10xBQ==, } - "@mysten/sui@1.33.0": + "@mysten/sui@1.34.0": resolution: { - integrity: sha512-V6hNQrFe0IT85iZquBJ2BccywQtLXCmq5jojRsdy1iFTZCve2h+Aj0kE7z9+b8X0QD7weg/6KC9JMUa1j05neQ==, + integrity: sha512-Btf2Tq5VPXqABOXqtw9hV13DskepggP7MpeGb7OnRNF2grh1nHyWj9J0Y2UmkhZUEdTWpnVRnl/ufIZ6VmU1kg==, } engines: { node: ">=18" } @@ -1296,98 +1299,98 @@ packages: integrity: sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==, } - "@types/node@24.0.1": + "@types/node@24.0.8": resolution: { - integrity: sha512-MX4Zioh39chHlDJbKmEgydJDS3tspMP/lnQC67G3SWsTnb9NeYVWOjkxpOSy4oMfPs4StcWHwBrvUb4ybfnuaw==, + integrity: sha512-WytNrFSgWO/esSH9NbpWUfTMGQwCGIKfCmNlmFDNiI5gGhgMmEA+V1AEvKLeBNvvtBnailJtkrEa2OIISwrVAA==, } - "@typescript-eslint/eslint-plugin@8.34.0": + "@typescript-eslint/eslint-plugin@8.35.1": resolution: { - integrity: sha512-QXwAlHlbcAwNlEEMKQS2RCgJsgXrTJdjXT08xEgbPFa2yYQgVjBymxP5DrfrE7X7iodSzd9qBUHUycdyVJTW1w==, + integrity: sha512-9XNTlo7P7RJxbVeICaIIIEipqxLKguyh+3UbXuT2XQuFp6d8VOeDEGuz5IiX0dgZo8CiI6aOFLg4e8cF71SFVg==, } engines: { node: ^18.18.0 || ^20.9.0 || >=21.1.0 } peerDependencies: - "@typescript-eslint/parser": ^8.34.0 + "@typescript-eslint/parser": ^8.35.1 eslint: ^8.57.0 || ^9.0.0 typescript: ">=4.8.4 <5.9.0" - "@typescript-eslint/parser@8.34.0": + "@typescript-eslint/parser@8.35.1": resolution: { - integrity: sha512-vxXJV1hVFx3IXz/oy2sICsJukaBrtDEQSBiV48/YIV5KWjX1dO+bcIr/kCPrW6weKXvsaGKFNlwH0v2eYdRRbA==, + integrity: sha512-3MyiDfrfLeK06bi/g9DqJxP5pV74LNv4rFTyvGDmT3x2p1yp1lOd+qYZfiRPIOf/oON+WRZR5wxxuF85qOar+w==, } engines: { node: ^18.18.0 || ^20.9.0 || >=21.1.0 } peerDependencies: eslint: ^8.57.0 || ^9.0.0 typescript: ">=4.8.4 <5.9.0" - "@typescript-eslint/project-service@8.34.0": + "@typescript-eslint/project-service@8.35.1": resolution: { - integrity: sha512-iEgDALRf970/B2YExmtPMPF54NenZUf4xpL3wsCRx/lgjz6ul/l13R81ozP/ZNuXfnLCS+oPmG7JIxfdNYKELw==, + integrity: sha512-VYxn/5LOpVxADAuP3NrnxxHYfzVtQzLKeldIhDhzC8UHaiQvYlXvKuVho1qLduFbJjjy5U5bkGwa3rUGUb1Q6Q==, } engines: { node: ^18.18.0 || ^20.9.0 || >=21.1.0 } peerDependencies: typescript: ">=4.8.4 <5.9.0" - "@typescript-eslint/scope-manager@8.34.0": + "@typescript-eslint/scope-manager@8.35.1": resolution: { - integrity: sha512-9Ac0X8WiLykl0aj1oYQNcLZjHgBojT6cW68yAgZ19letYu+Hxd0rE0veI1XznSSst1X5lwnxhPbVdwjDRIomRw==, + integrity: sha512-s/Bpd4i7ht2934nG+UoSPlYXd08KYz3bmjLEb7Ye1UVob0d1ENiT3lY8bsCmik4RqfSbPw9xJJHbugpPpP5JUg==, } engines: { node: ^18.18.0 || ^20.9.0 || >=21.1.0 } - "@typescript-eslint/tsconfig-utils@8.34.0": + "@typescript-eslint/tsconfig-utils@8.35.1": resolution: { - integrity: sha512-+W9VYHKFIzA5cBeooqQxqNriAP0QeQ7xTiDuIOr71hzgffm3EL2hxwWBIIj4GuofIbKxGNarpKqIq6Q6YrShOA==, + integrity: sha512-K5/U9VmT9dTHoNowWZpz+/TObS3xqC5h0xAIjXPw+MNcKV9qg6eSatEnmeAwkjHijhACH0/N7bkhKvbt1+DXWQ==, } engines: { node: ^18.18.0 || ^20.9.0 || >=21.1.0 } peerDependencies: typescript: ">=4.8.4 <5.9.0" - "@typescript-eslint/type-utils@8.34.0": + "@typescript-eslint/type-utils@8.35.1": resolution: { - integrity: sha512-n7zSmOcUVhcRYC75W2pnPpbO1iwhJY3NLoHEtbJwJSNlVAZuwqu05zY3f3s2SDWWDSo9FdN5szqc73DCtDObAg==, + integrity: sha512-HOrUBlfVRz5W2LIKpXzZoy6VTZzMu2n8q9C2V/cFngIC5U1nStJgv0tMV4sZPzdf4wQm9/ToWUFPMN9Vq9VJQQ==, } engines: { node: ^18.18.0 || ^20.9.0 || >=21.1.0 } peerDependencies: eslint: ^8.57.0 || ^9.0.0 typescript: ">=4.8.4 <5.9.0" - "@typescript-eslint/types@8.34.0": + "@typescript-eslint/types@8.35.1": resolution: { - integrity: sha512-9V24k/paICYPniajHfJ4cuAWETnt7Ssy+R0Rbcqo5sSFr3QEZ/8TSoUi9XeXVBGXCaLtwTOKSLGcInCAvyZeMA==, + integrity: sha512-q/O04vVnKHfrrhNAscndAn1tuQhIkwqnaW+eu5waD5IPts2eX1dgJxgqcPx5BX109/qAz7IG6VrEPTOYKCNfRQ==, } engines: { node: ^18.18.0 || ^20.9.0 || >=21.1.0 } - "@typescript-eslint/typescript-estree@8.34.0": + "@typescript-eslint/typescript-estree@8.35.1": resolution: { - integrity: sha512-rOi4KZxI7E0+BMqG7emPSK1bB4RICCpF7QD3KCLXn9ZvWoESsOMlHyZPAHyG04ujVplPaHbmEvs34m+wjgtVtg==, + integrity: sha512-Vvpuvj4tBxIka7cPs6Y1uvM7gJgdF5Uu9F+mBJBPY4MhvjrjWGK4H0lVgLJd/8PWZ23FTqsaJaLEkBCFUk8Y9g==, } engines: { node: ^18.18.0 || ^20.9.0 || >=21.1.0 } peerDependencies: typescript: ">=4.8.4 <5.9.0" - "@typescript-eslint/utils@8.34.0": + "@typescript-eslint/utils@8.35.1": resolution: { - integrity: sha512-8L4tWatGchV9A1cKbjaavS6mwYwp39jql8xUmIIKJdm+qiaeHy5KMKlBrf30akXAWBzn2SqKsNOtSENWUwg7XQ==, + integrity: sha512-lhnwatFmOFcazAsUm3ZnZFpXSxiwoa1Lj50HphnDe1Et01NF4+hrdXONSUHIcbVu2eFb1bAf+5yjXkGVkXBKAQ==, } engines: { node: ^18.18.0 || ^20.9.0 || >=21.1.0 } peerDependencies: eslint: ^8.57.0 || ^9.0.0 typescript: ">=4.8.4 <5.9.0" - "@typescript-eslint/visitor-keys@8.34.0": + "@typescript-eslint/visitor-keys@8.35.1": resolution: { - integrity: sha512-qHV7pW7E85A0x6qyrFn+O+q1k1p3tQCsqIZ1KZ5ESLXY57aTvUd3/a4rdPTeXisvhXn2VQG0VSKUqs8KHF2zcA==, + integrity: sha512-VRwixir4zBWCSTP/ljEo091lbpypz57PoeAQ9imjG+vbeof9LplljsL1mos4ccG6H9IjfrVGM359RozUnuFhpw==, } engines: { node: ^18.18.0 || ^20.9.0 || >=21.1.0 } @@ -1902,10 +1905,10 @@ packages: integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==, } - concurrently@9.1.2: + concurrently@9.2.0: resolution: { - integrity: sha512-H9MWcoPsYddwbOGM6difjVwVZHl63nwMEwDJG/L7VGtuaJhb12h2caPG2tVPWs7emuYix252iGfqOyrz1GczTQ==, + integrity: sha512-IsB/fiXTupmagMW4MNp2lx2cdSN2FfZq78vF90LBB+zZHArbIQZjQtzXCiXnvTxCZSvXanTqFLWBjw2UkLx1SQ==, } engines: { node: ">=18" } hasBin: true @@ -2165,10 +2168,10 @@ packages: integrity: sha512-WFj2isz22JahUv+B788TlO3N6zL3nNJGU8CcZbPZvVEkBPaJdCV4vy5wyghty5ROFbCRnm132v8BScu5/1BQ8g==, } - eslint-import-resolver-typescript@4.4.3: + eslint-import-resolver-typescript@4.4.4: resolution: { - integrity: sha512-elVDn1eWKFrWlzxlWl9xMt8LltjKl161Ix50JFC50tHXI5/TRP32SNEqlJ/bo/HV+g7Rou/tlPQU2AcRtIhrOg==, + integrity: sha512-1iM2zeBvrYmUNTj2vSC/90JTHDth+dfOfiNKkxApWRsTJYNrc8rOdxxIf5vazX+BiAXTeOT0UvWpGI/7qIWQOw==, } engines: { node: ^16.17.0 || >=18.6.0 } peerDependencies: @@ -2181,10 +2184,10 @@ packages: eslint-plugin-import-x: optional: true - eslint-module-utils@2.12.0: + eslint-module-utils@2.12.1: resolution: { - integrity: sha512-wALZ0HFoytlyh/1+4wuZ9FJCD/leWHQzzrxJ8+rebyReSLk7LApMyd3WJaLVoN+D5+WIdJyDK1c6JnE65V4Zyg==, + integrity: sha512-L8jSWTze7K2mTg0vos/RuLRS5soomksDPoJLXIslC7c8Wmut3bx7CPpJijDcBZtxQ5lrbUdM+s0OlNbz0DCDNw==, } engines: { node: ">=4" } peerDependencies: @@ -2205,10 +2208,10 @@ packages: eslint-import-resolver-webpack: optional: true - eslint-plugin-import@2.31.0: + eslint-plugin-import@2.32.0: resolution: { - integrity: sha512-ixmkI62Rbc2/w8Vfxyh1jQRTdRTF52VxwRVHl/ykPAmqG+Nb7/kNn+byLP0LxPgI7zWA16Jt82SybJInmMia3A==, + integrity: sha512-whOE1HFo/qJDyX4SnXzP4N6zOWn79WhnCUY/iDR0mPfQZO8wcYE4JClzI2oZrhBnnMUCBCHZhO6VQyoBU95mZA==, } engines: { node: ">=4" } peerDependencies: @@ -2239,10 +2242,10 @@ packages: } engines: { node: ^18.18.0 || ^20.9.0 || >=21.1.0 } - eslint@9.29.0: + eslint@9.30.0: resolution: { - integrity: sha512-GsGizj2Y1rCWDu6XoEekL3RLilp0voSePurjZIkxL3wlm5o5EC9VpgaP7lrCvjnkuLvzFBQWB3vWB3K5KQTveQ==, + integrity: sha512-iN/SiPxmQu6EVkf+m1qpBxzUhE12YqFLOSySuOyVLJLEF9nzTf+h/1AJYc1JWzCnktggeNrjvQGLngDzXirU6g==, } engines: { node: ^18.18.0 || ^20.9.0 || >=21.1.0 } hasBin: true @@ -3141,6 +3144,12 @@ packages: } hasBin: true + node-machine-id@1.1.12: + resolution: + { + integrity: sha512-QNABxbrPa3qEIfrE6GOJ7BYIuignnJw7iQ2YPbc3Nla1HzRJjXzZOiikfF8m7eAMfichLt3M4VgLOetqgDmgGQ==, + } + npm@9.9.4: resolution: { @@ -3385,10 +3394,10 @@ packages: } engines: { node: ">= 0.8.0" } - prettier@3.5.3: + prettier@3.6.2: resolution: { - integrity: sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw==, + integrity: sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==, } engines: { node: ">=14" } hasBin: true @@ -3658,6 +3667,13 @@ packages: } engines: { node: ">=12.0.0" } + stable-hash-x@0.2.0: + resolution: + { + integrity: sha512-o3yWv49B/o4QZk5ZcsALc6t0+eCelPc44zZsLtCQnZPDwFpDYSWcDnrv2TtMmMbQ7uKo3J0HTURCqckw23czNQ==, + } + engines: { node: ">=12.0.0" } + stop-iteration-iterator@1.1.0: resolution: { @@ -4416,14 +4432,14 @@ snapshots: "@esbuild/win32-x64@0.25.5": optional: true - "@eslint-community/eslint-utils@4.7.0(eslint@9.29.0)": + "@eslint-community/eslint-utils@4.7.0(eslint@9.30.0)": dependencies: - eslint: 9.29.0 + eslint: 9.30.0 eslint-visitor-keys: 3.4.3 "@eslint-community/regexpp@4.12.1": {} - "@eslint/config-array@0.20.1": + "@eslint/config-array@0.21.0": dependencies: "@eslint/object-schema": 2.1.6 debug: 4.4.1 @@ -4431,7 +4447,7 @@ snapshots: transitivePeerDependencies: - supports-color - "@eslint/config-helpers@0.2.3": {} + "@eslint/config-helpers@0.3.0": {} "@eslint/core@0.14.0": dependencies: @@ -4455,7 +4471,7 @@ snapshots: transitivePeerDependencies: - supports-color - "@eslint/js@9.29.0": {} + "@eslint/js@9.30.0": {} "@eslint/object-schema@2.1.6": {} @@ -4545,38 +4561,38 @@ snapshots: "@humanwhocodes/retry@0.4.3": {} - "@ianvs/prettier-plugin-sort-imports@4.4.2(prettier@3.5.3)": + "@ianvs/prettier-plugin-sort-imports@4.4.2(prettier@3.6.2)": dependencies: "@babel/generator": 7.27.5 "@babel/parser": 7.27.5 "@babel/traverse": 7.27.4 "@babel/types": 7.27.6 - prettier: 3.5.3 + prettier: 3.6.2 semver: 7.7.2 transitivePeerDependencies: - supports-color - "@inquirer/checkbox@4.1.8(@types/node@24.0.1)": + "@inquirer/checkbox@4.1.8(@types/node@24.0.8)": dependencies: - "@inquirer/core": 10.1.13(@types/node@24.0.1) + "@inquirer/core": 10.1.13(@types/node@24.0.8) "@inquirer/figures": 1.0.12 - "@inquirer/type": 3.0.7(@types/node@24.0.1) + "@inquirer/type": 3.0.7(@types/node@24.0.8) ansi-escapes: 4.3.2 yoctocolors-cjs: 2.1.2 optionalDependencies: - "@types/node": 24.0.1 + "@types/node": 24.0.8 - "@inquirer/confirm@5.1.12(@types/node@24.0.1)": + "@inquirer/confirm@5.1.12(@types/node@24.0.8)": dependencies: - "@inquirer/core": 10.1.13(@types/node@24.0.1) - "@inquirer/type": 3.0.7(@types/node@24.0.1) + "@inquirer/core": 10.1.13(@types/node@24.0.8) + "@inquirer/type": 3.0.7(@types/node@24.0.8) optionalDependencies: - "@types/node": 24.0.1 + "@types/node": 24.0.8 - "@inquirer/core@10.1.13(@types/node@24.0.1)": + "@inquirer/core@10.1.13(@types/node@24.0.8)": dependencies: "@inquirer/figures": 1.0.12 - "@inquirer/type": 3.0.7(@types/node@24.0.1) + "@inquirer/type": 3.0.7(@types/node@24.0.8) ansi-escapes: 4.3.2 cli-width: 4.1.0 mute-stream: 2.0.0 @@ -4584,93 +4600,93 @@ snapshots: wrap-ansi: 6.2.0 yoctocolors-cjs: 2.1.2 optionalDependencies: - "@types/node": 24.0.1 + "@types/node": 24.0.8 - "@inquirer/editor@4.2.13(@types/node@24.0.1)": + "@inquirer/editor@4.2.13(@types/node@24.0.8)": dependencies: - "@inquirer/core": 10.1.13(@types/node@24.0.1) - "@inquirer/type": 3.0.7(@types/node@24.0.1) + "@inquirer/core": 10.1.13(@types/node@24.0.8) + "@inquirer/type": 3.0.7(@types/node@24.0.8) external-editor: 3.1.0 optionalDependencies: - "@types/node": 24.0.1 + "@types/node": 24.0.8 - "@inquirer/expand@4.0.15(@types/node@24.0.1)": + "@inquirer/expand@4.0.15(@types/node@24.0.8)": dependencies: - "@inquirer/core": 10.1.13(@types/node@24.0.1) - "@inquirer/type": 3.0.7(@types/node@24.0.1) + "@inquirer/core": 10.1.13(@types/node@24.0.8) + "@inquirer/type": 3.0.7(@types/node@24.0.8) yoctocolors-cjs: 2.1.2 optionalDependencies: - "@types/node": 24.0.1 + "@types/node": 24.0.8 "@inquirer/figures@1.0.12": {} - "@inquirer/input@4.1.12(@types/node@24.0.1)": + "@inquirer/input@4.1.12(@types/node@24.0.8)": dependencies: - "@inquirer/core": 10.1.13(@types/node@24.0.1) - "@inquirer/type": 3.0.7(@types/node@24.0.1) + "@inquirer/core": 10.1.13(@types/node@24.0.8) + "@inquirer/type": 3.0.7(@types/node@24.0.8) optionalDependencies: - "@types/node": 24.0.1 + "@types/node": 24.0.8 - "@inquirer/number@3.0.15(@types/node@24.0.1)": + "@inquirer/number@3.0.15(@types/node@24.0.8)": dependencies: - "@inquirer/core": 10.1.13(@types/node@24.0.1) - "@inquirer/type": 3.0.7(@types/node@24.0.1) + "@inquirer/core": 10.1.13(@types/node@24.0.8) + "@inquirer/type": 3.0.7(@types/node@24.0.8) optionalDependencies: - "@types/node": 24.0.1 + "@types/node": 24.0.8 - "@inquirer/password@4.0.15(@types/node@24.0.1)": + "@inquirer/password@4.0.15(@types/node@24.0.8)": dependencies: - "@inquirer/core": 10.1.13(@types/node@24.0.1) - "@inquirer/type": 3.0.7(@types/node@24.0.1) + "@inquirer/core": 10.1.13(@types/node@24.0.8) + "@inquirer/type": 3.0.7(@types/node@24.0.8) ansi-escapes: 4.3.2 optionalDependencies: - "@types/node": 24.0.1 - - "@inquirer/prompts@7.5.3(@types/node@24.0.1)": - dependencies: - "@inquirer/checkbox": 4.1.8(@types/node@24.0.1) - "@inquirer/confirm": 5.1.12(@types/node@24.0.1) - "@inquirer/editor": 4.2.13(@types/node@24.0.1) - "@inquirer/expand": 4.0.15(@types/node@24.0.1) - "@inquirer/input": 4.1.12(@types/node@24.0.1) - "@inquirer/number": 3.0.15(@types/node@24.0.1) - "@inquirer/password": 4.0.15(@types/node@24.0.1) - "@inquirer/rawlist": 4.1.3(@types/node@24.0.1) - "@inquirer/search": 3.0.15(@types/node@24.0.1) - "@inquirer/select": 4.2.3(@types/node@24.0.1) + "@types/node": 24.0.8 + + "@inquirer/prompts@7.5.3(@types/node@24.0.8)": + dependencies: + "@inquirer/checkbox": 4.1.8(@types/node@24.0.8) + "@inquirer/confirm": 5.1.12(@types/node@24.0.8) + "@inquirer/editor": 4.2.13(@types/node@24.0.8) + "@inquirer/expand": 4.0.15(@types/node@24.0.8) + "@inquirer/input": 4.1.12(@types/node@24.0.8) + "@inquirer/number": 3.0.15(@types/node@24.0.8) + "@inquirer/password": 4.0.15(@types/node@24.0.8) + "@inquirer/rawlist": 4.1.3(@types/node@24.0.8) + "@inquirer/search": 3.0.15(@types/node@24.0.8) + "@inquirer/select": 4.2.3(@types/node@24.0.8) optionalDependencies: - "@types/node": 24.0.1 + "@types/node": 24.0.8 - "@inquirer/rawlist@4.1.3(@types/node@24.0.1)": + "@inquirer/rawlist@4.1.3(@types/node@24.0.8)": dependencies: - "@inquirer/core": 10.1.13(@types/node@24.0.1) - "@inquirer/type": 3.0.7(@types/node@24.0.1) + "@inquirer/core": 10.1.13(@types/node@24.0.8) + "@inquirer/type": 3.0.7(@types/node@24.0.8) yoctocolors-cjs: 2.1.2 optionalDependencies: - "@types/node": 24.0.1 + "@types/node": 24.0.8 - "@inquirer/search@3.0.15(@types/node@24.0.1)": + "@inquirer/search@3.0.15(@types/node@24.0.8)": dependencies: - "@inquirer/core": 10.1.13(@types/node@24.0.1) + "@inquirer/core": 10.1.13(@types/node@24.0.8) "@inquirer/figures": 1.0.12 - "@inquirer/type": 3.0.7(@types/node@24.0.1) + "@inquirer/type": 3.0.7(@types/node@24.0.8) yoctocolors-cjs: 2.1.2 optionalDependencies: - "@types/node": 24.0.1 + "@types/node": 24.0.8 - "@inquirer/select@4.2.3(@types/node@24.0.1)": + "@inquirer/select@4.2.3(@types/node@24.0.8)": dependencies: - "@inquirer/core": 10.1.13(@types/node@24.0.1) + "@inquirer/core": 10.1.13(@types/node@24.0.8) "@inquirer/figures": 1.0.12 - "@inquirer/type": 3.0.7(@types/node@24.0.1) + "@inquirer/type": 3.0.7(@types/node@24.0.8) ansi-escapes: 4.3.2 yoctocolors-cjs: 2.1.2 optionalDependencies: - "@types/node": 24.0.1 + "@types/node": 24.0.8 - "@inquirer/type@3.0.7(@types/node@24.0.1)": + "@inquirer/type@3.0.7(@types/node@24.0.8)": optionalDependencies: - "@types/node": 24.0.1 + "@types/node": 24.0.8 "@jridgewell/gen-mapping@0.3.8": dependencies: @@ -4854,7 +4870,7 @@ snapshots: "@mysten/utils": 0.1.0 "@scure/base": 1.2.6 - "@mysten/sui@1.33.0(typescript@5.8.3)": + "@mysten/sui@1.34.0(typescript@5.8.3)": dependencies: "@graphql-typed-document-node/core": 3.2.0(graphql@16.11.0) "@mysten/bcs": 1.6.3 @@ -4947,7 +4963,7 @@ snapshots: "@types/dns-packet@5.6.5": dependencies: - "@types/node": 24.0.1 + "@types/node": 24.0.8 "@types/estree@1.0.8": {} @@ -4957,19 +4973,19 @@ snapshots: "@types/json5@0.0.29": {} - "@types/node@24.0.1": + "@types/node@24.0.8": dependencies: undici-types: 7.8.0 - "@typescript-eslint/eslint-plugin@8.34.0(@typescript-eslint/parser@8.34.0(eslint@9.29.0)(typescript@5.8.3))(eslint@9.29.0)(typescript@5.8.3)": + "@typescript-eslint/eslint-plugin@8.35.1(@typescript-eslint/parser@8.35.1(eslint@9.30.0)(typescript@5.8.3))(eslint@9.30.0)(typescript@5.8.3)": dependencies: "@eslint-community/regexpp": 4.12.1 - "@typescript-eslint/parser": 8.34.0(eslint@9.29.0)(typescript@5.8.3) - "@typescript-eslint/scope-manager": 8.34.0 - "@typescript-eslint/type-utils": 8.34.0(eslint@9.29.0)(typescript@5.8.3) - "@typescript-eslint/utils": 8.34.0(eslint@9.29.0)(typescript@5.8.3) - "@typescript-eslint/visitor-keys": 8.34.0 - eslint: 9.29.0 + "@typescript-eslint/parser": 8.35.1(eslint@9.30.0)(typescript@5.8.3) + "@typescript-eslint/scope-manager": 8.35.1 + "@typescript-eslint/type-utils": 8.35.1(eslint@9.30.0)(typescript@5.8.3) + "@typescript-eslint/utils": 8.35.1(eslint@9.30.0)(typescript@5.8.3) + "@typescript-eslint/visitor-keys": 8.35.1 + eslint: 9.30.0 graphemer: 1.4.0 ignore: 7.0.5 natural-compare: 1.4.0 @@ -4978,55 +4994,55 @@ snapshots: transitivePeerDependencies: - supports-color - "@typescript-eslint/parser@8.34.0(eslint@9.29.0)(typescript@5.8.3)": + "@typescript-eslint/parser@8.35.1(eslint@9.30.0)(typescript@5.8.3)": dependencies: - "@typescript-eslint/scope-manager": 8.34.0 - "@typescript-eslint/types": 8.34.0 - "@typescript-eslint/typescript-estree": 8.34.0(typescript@5.8.3) - "@typescript-eslint/visitor-keys": 8.34.0 + "@typescript-eslint/scope-manager": 8.35.1 + "@typescript-eslint/types": 8.35.1 + "@typescript-eslint/typescript-estree": 8.35.1(typescript@5.8.3) + "@typescript-eslint/visitor-keys": 8.35.1 debug: 4.4.1 - eslint: 9.29.0 + eslint: 9.30.0 typescript: 5.8.3 transitivePeerDependencies: - supports-color - "@typescript-eslint/project-service@8.34.0(typescript@5.8.3)": + "@typescript-eslint/project-service@8.35.1(typescript@5.8.3)": dependencies: - "@typescript-eslint/tsconfig-utils": 8.34.0(typescript@5.8.3) - "@typescript-eslint/types": 8.34.0 + "@typescript-eslint/tsconfig-utils": 8.35.1(typescript@5.8.3) + "@typescript-eslint/types": 8.35.1 debug: 4.4.1 typescript: 5.8.3 transitivePeerDependencies: - supports-color - "@typescript-eslint/scope-manager@8.34.0": + "@typescript-eslint/scope-manager@8.35.1": dependencies: - "@typescript-eslint/types": 8.34.0 - "@typescript-eslint/visitor-keys": 8.34.0 + "@typescript-eslint/types": 8.35.1 + "@typescript-eslint/visitor-keys": 8.35.1 - "@typescript-eslint/tsconfig-utils@8.34.0(typescript@5.8.3)": + "@typescript-eslint/tsconfig-utils@8.35.1(typescript@5.8.3)": dependencies: typescript: 5.8.3 - "@typescript-eslint/type-utils@8.34.0(eslint@9.29.0)(typescript@5.8.3)": + "@typescript-eslint/type-utils@8.35.1(eslint@9.30.0)(typescript@5.8.3)": dependencies: - "@typescript-eslint/typescript-estree": 8.34.0(typescript@5.8.3) - "@typescript-eslint/utils": 8.34.0(eslint@9.29.0)(typescript@5.8.3) + "@typescript-eslint/typescript-estree": 8.35.1(typescript@5.8.3) + "@typescript-eslint/utils": 8.35.1(eslint@9.30.0)(typescript@5.8.3) debug: 4.4.1 - eslint: 9.29.0 + eslint: 9.30.0 ts-api-utils: 2.1.0(typescript@5.8.3) typescript: 5.8.3 transitivePeerDependencies: - supports-color - "@typescript-eslint/types@8.34.0": {} + "@typescript-eslint/types@8.35.1": {} - "@typescript-eslint/typescript-estree@8.34.0(typescript@5.8.3)": + "@typescript-eslint/typescript-estree@8.35.1(typescript@5.8.3)": dependencies: - "@typescript-eslint/project-service": 8.34.0(typescript@5.8.3) - "@typescript-eslint/tsconfig-utils": 8.34.0(typescript@5.8.3) - "@typescript-eslint/types": 8.34.0 - "@typescript-eslint/visitor-keys": 8.34.0 + "@typescript-eslint/project-service": 8.35.1(typescript@5.8.3) + "@typescript-eslint/tsconfig-utils": 8.35.1(typescript@5.8.3) + "@typescript-eslint/types": 8.35.1 + "@typescript-eslint/visitor-keys": 8.35.1 debug: 4.4.1 fast-glob: 3.3.3 is-glob: 4.0.3 @@ -5037,20 +5053,20 @@ snapshots: transitivePeerDependencies: - supports-color - "@typescript-eslint/utils@8.34.0(eslint@9.29.0)(typescript@5.8.3)": + "@typescript-eslint/utils@8.35.1(eslint@9.30.0)(typescript@5.8.3)": dependencies: - "@eslint-community/eslint-utils": 4.7.0(eslint@9.29.0) - "@typescript-eslint/scope-manager": 8.34.0 - "@typescript-eslint/types": 8.34.0 - "@typescript-eslint/typescript-estree": 8.34.0(typescript@5.8.3) - eslint: 9.29.0 + "@eslint-community/eslint-utils": 4.7.0(eslint@9.30.0) + "@typescript-eslint/scope-manager": 8.35.1 + "@typescript-eslint/types": 8.35.1 + "@typescript-eslint/typescript-estree": 8.35.1(typescript@5.8.3) + eslint: 9.30.0 typescript: 5.8.3 transitivePeerDependencies: - supports-color - "@typescript-eslint/visitor-keys@8.34.0": + "@typescript-eslint/visitor-keys@8.35.1": dependencies: - "@typescript-eslint/types": 8.34.0 + "@typescript-eslint/types": 8.35.1 eslint-visitor-keys: 4.2.1 "@unrs/resolver-binding-android-arm-eabi@1.9.0": @@ -5343,7 +5359,7 @@ snapshots: concat-map@0.0.1: {} - concurrently@9.1.2: + concurrently@9.2.0: dependencies: chalk: 4.1.2 lodash: 4.17.21 @@ -5582,9 +5598,9 @@ snapshots: escape-string-regexp@4.0.0: {} - eslint-config-prettier@10.1.5(eslint@9.29.0): + eslint-config-prettier@10.1.5(eslint@9.30.0): dependencies: - eslint: 9.29.0 + eslint: 9.30.0 eslint-import-context@0.1.8(unrs-resolver@1.9.0): dependencies: @@ -5601,33 +5617,33 @@ snapshots: transitivePeerDependencies: - supports-color - eslint-import-resolver-typescript@4.4.3(eslint-plugin-import@2.31.0)(eslint@9.29.0): + eslint-import-resolver-typescript@4.4.4(eslint-plugin-import@2.32.0)(eslint@9.30.0): dependencies: debug: 4.4.1 - eslint: 9.29.0 + eslint: 9.30.0 eslint-import-context: 0.1.8(unrs-resolver@1.9.0) get-tsconfig: 4.10.1 is-bun-module: 2.0.0 - stable-hash-x: 0.1.1 + stable-hash-x: 0.2.0 tinyglobby: 0.2.14 unrs-resolver: 1.9.0 optionalDependencies: - eslint-plugin-import: 2.31.0(@typescript-eslint/parser@8.34.0(eslint@9.29.0)(typescript@5.8.3))(eslint-import-resolver-typescript@4.4.3)(eslint@9.29.0) + eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.35.1(eslint@9.30.0)(typescript@5.8.3))(eslint-import-resolver-typescript@4.4.4)(eslint@9.30.0) transitivePeerDependencies: - supports-color - eslint-module-utils@2.12.0(@typescript-eslint/parser@8.34.0(eslint@9.29.0)(typescript@5.8.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@4.4.3)(eslint@9.29.0): + eslint-module-utils@2.12.1(@typescript-eslint/parser@8.35.1(eslint@9.30.0)(typescript@5.8.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@4.4.4)(eslint@9.30.0): dependencies: debug: 3.2.7 optionalDependencies: - "@typescript-eslint/parser": 8.34.0(eslint@9.29.0)(typescript@5.8.3) - eslint: 9.29.0 + "@typescript-eslint/parser": 8.35.1(eslint@9.30.0)(typescript@5.8.3) + eslint: 9.30.0 eslint-import-resolver-node: 0.3.9 - eslint-import-resolver-typescript: 4.4.3(eslint-plugin-import@2.31.0)(eslint@9.29.0) + eslint-import-resolver-typescript: 4.4.4(eslint-plugin-import@2.32.0)(eslint@9.30.0) transitivePeerDependencies: - supports-color - eslint-plugin-import@2.31.0(@typescript-eslint/parser@8.34.0(eslint@9.29.0)(typescript@5.8.3))(eslint-import-resolver-typescript@4.4.3)(eslint@9.29.0): + eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.35.1(eslint@9.30.0)(typescript@5.8.3))(eslint-import-resolver-typescript@4.4.4)(eslint@9.30.0): dependencies: "@rtsao/scc": 1.1.0 array-includes: 3.1.9 @@ -5636,9 +5652,9 @@ snapshots: array.prototype.flatmap: 1.3.3 debug: 3.2.7 doctrine: 2.1.0 - eslint: 9.29.0 + eslint: 9.30.0 eslint-import-resolver-node: 0.3.9 - eslint-module-utils: 2.12.0(@typescript-eslint/parser@8.34.0(eslint@9.29.0)(typescript@5.8.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@4.4.3)(eslint@9.29.0) + eslint-module-utils: 2.12.1(@typescript-eslint/parser@8.35.1(eslint@9.30.0)(typescript@5.8.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@4.4.4)(eslint@9.30.0) hasown: 2.0.2 is-core-module: 2.16.1 is-glob: 4.0.3 @@ -5650,7 +5666,7 @@ snapshots: string.prototype.trimend: 1.0.9 tsconfig-paths: 3.15.0 optionalDependencies: - "@typescript-eslint/parser": 8.34.0(eslint@9.29.0)(typescript@5.8.3) + "@typescript-eslint/parser": 8.35.1(eslint@9.30.0)(typescript@5.8.3) transitivePeerDependencies: - eslint-import-resolver-typescript - eslint-import-resolver-webpack @@ -5665,15 +5681,15 @@ snapshots: eslint-visitor-keys@4.2.1: {} - eslint@9.29.0: + eslint@9.30.0: dependencies: - "@eslint-community/eslint-utils": 4.7.0(eslint@9.29.0) + "@eslint-community/eslint-utils": 4.7.0(eslint@9.30.0) "@eslint-community/regexpp": 4.12.1 - "@eslint/config-array": 0.20.1 - "@eslint/config-helpers": 0.2.3 + "@eslint/config-array": 0.21.0 + "@eslint/config-helpers": 0.3.0 "@eslint/core": 0.14.0 "@eslint/eslintrc": 3.3.1 - "@eslint/js": 9.29.0 + "@eslint/js": 9.30.0 "@eslint/plugin-kit": 0.3.2 "@humanfs/node": 0.16.6 "@humanwhocodes/module-importer": 1.0.1 @@ -5926,17 +5942,17 @@ snapshots: inherits@2.0.4: {} - inquirer@12.6.3(@types/node@24.0.1): + inquirer@12.6.3(@types/node@24.0.8): dependencies: - "@inquirer/core": 10.1.13(@types/node@24.0.1) - "@inquirer/prompts": 7.5.3(@types/node@24.0.1) - "@inquirer/type": 3.0.7(@types/node@24.0.1) + "@inquirer/core": 10.1.13(@types/node@24.0.8) + "@inquirer/prompts": 7.5.3(@types/node@24.0.8) + "@inquirer/type": 3.0.7(@types/node@24.0.8) ansi-escapes: 4.3.2 mute-stream: 2.0.0 run-async: 3.0.0 rxjs: 7.8.2 optionalDependencies: - "@types/node": 24.0.1 + "@types/node": 24.0.8 internal-slot@1.1.0: dependencies: @@ -6178,6 +6194,8 @@ snapshots: detect-libc: 2.0.4 optional: true + node-machine-id@1.1.12: {} + npm@9.9.4: {} object-inspect@1.13.4: {} @@ -6275,7 +6293,7 @@ snapshots: prelude-ls@1.2.1: {} - prettier@3.5.3: {} + prettier@3.6.2: {} progress-events@1.0.1: {} @@ -6442,6 +6460,8 @@ snapshots: stable-hash-x@0.1.1: {} + stable-hash-x@0.2.0: {} + stop-iteration-iterator@1.1.0: dependencies: es-errors: 1.3.0 diff --git a/src/addresses/to-address.ts b/src/addresses/to-address.ts index 70d5849..c4ad6da 100644 --- a/src/addresses/to-address.ts +++ b/src/addresses/to-address.ts @@ -1,16 +1,16 @@ -import { toCardanoAddress } from "./cardano.js"; -import { toEthereumAddress } from "./ethereum.js"; -import { toSolanaAddress } from "./solana.js"; -import { toSuiAddress } from "./sui.js"; -import { toTronAddress } from "./tron.js"; -import { PrivateKey } from "../private-key.js"; import { type } from "arktype"; import { Err, Ok, Result } from "ts-handling"; import { deriveCompressedEd25519PublicKey, deriveSecp256k1PublicKey, } from "../ecc/index.js"; +import { PrivateKey } from "../private-key.js"; +import { toCardanoAddress } from "./cardano.js"; +import { toEthereumAddress } from "./ethereum.js"; import { toPublicKey } from "./public-key.js"; +import { toSolanaAddress } from "./solana.js"; +import { toSuiAddress } from "./sui.js"; +import { toTronAddress } from "./tron.js"; type Network = "mainnet" | "testnet"; diff --git a/src/commands/cli.ts b/src/commands/cli.ts index 06b9b99..823b826 100644 --- a/src/commands/cli.ts +++ b/src/commands/cli.ts @@ -1,7 +1,7 @@ -import { Command } from "commander"; import { readFileSync } from "fs"; -import { fileURLToPath } from "url"; import { dirname, join } from "path"; +import { fileURLToPath } from "url"; +import { Command } from "commander"; const { name, description } = JSON.parse( readFileSync( diff --git a/src/commands/config.ts b/src/commands/config.ts new file mode 100644 index 0000000..11d1b23 --- /dev/null +++ b/src/commands/config.ts @@ -0,0 +1,48 @@ +import { type } from "arktype"; +import config from "../config.js"; +import { exit, program } from "./cli.js"; + +const ProviderId = type(/^[a-z0-9_-]{3,20}$/); +const Fee = type("string.numeric.parse | number").pipe( + type("0 <= number < 99"), +); + +const cli = program + .command("config") + .description("Shows and updates wallet configuration"); + +cli + .command("show") + .description("Shows current wallet configuration") + .action(() => { + const providerId = config.get("providerId"); + const fee = config.get("fee") || 0; + + if (providerId) console.log("Provider ID:", providerId); + + console.log(`Fee: ${fee}%`); + }); + +const set = cli.command("set").description("Updates wallet configuration"); + +set + .command("provider-id") + .description("Sets the provider ID to use for intent generation") + .argument("id", "The provider ID to use for intent generation") + .action(($providerId: string) => { + const providerId = ProviderId($providerId); + if (providerId instanceof type.errors) exit(providerId.summary); + config.set("providerId", providerId); + console.log("Set providerId to", providerId); + }); + +set + .command("fee") + .description("Sets the fee to use for intent generation") + .argument("fee", "The fee to use for intent generation") + .action(($fee: string) => { + const fee = Fee($fee); + if (fee instanceof type.errors) exit(fee.summary); + config.set("fee", fee); + console.log(`Set fee to ${fee}%`); + }); diff --git a/src/commands/index.ts b/src/commands/index.ts index e600f3b..04864d8 100644 --- a/src/commands/index.ts +++ b/src/commands/index.ts @@ -1,5 +1,6 @@ import { program } from "./cli.js"; -import "./wallet.js"; +import "./config.js"; import "./payload.js"; +import "./wallet.js"; export default program; diff --git a/src/commands/payload.ts b/src/commands/payload.ts index 5e4a325..5406a67 100644 --- a/src/commands/payload.ts +++ b/src/commands/payload.ts @@ -1,15 +1,15 @@ -import { program, exit } from "./cli.js"; -import { getSavedSeed } from "../seed.js"; import { - signData, getAddressDetails, + signData, verifyData, walletFromSeed, } from "@lucid-evolution/lucid"; -import { type } from "arktype"; -import { entropyToMnemonic } from "bip39"; import { blake3Hash } from "@webbuf/blake3"; import { WebBuf } from "@webbuf/webbuf"; +import { type } from "arktype"; +import { entropyToMnemonic } from "bip39"; +import { getSavedSeed } from "../seed.js"; +import { exit, program } from "./cli.js"; const Payload = type("string > 0").pipe((payload) => { if (/^[a-fA-F0-9]{64}$/.test(payload)) return payload.toLowerCase(); diff --git a/src/commands/wallet.ts b/src/commands/wallet.ts index e407155..7658ae4 100644 --- a/src/commands/wallet.ts +++ b/src/commands/wallet.ts @@ -1,8 +1,8 @@ -import { getSavedSeed, saveNewSeed, saveRandomSeed } from "../seed.js"; import { confirm } from "@inquirer/prompts"; import { entropyToMnemonic } from "bip39"; import { toAddresses } from "../addresses/index.js"; -import { program, exit } from "./cli.js"; +import { getSavedSeed, saveNewSeed, saveRandomSeed } from "../seed.js"; +import { exit, program } from "./cli.js"; program .command("new") diff --git a/src/config.ts b/src/config.ts new file mode 100644 index 0000000..b9847b4 --- /dev/null +++ b/src/config.ts @@ -0,0 +1,21 @@ +import { blake3Hash } from "@webbuf/blake3"; +import { WebBuf } from "@webbuf/webbuf"; +import Conf from "conf"; +import * as id from "node-machine-id"; + +type Settings = { + fee?: number; + providerId?: string; + seed?: string; +}; + +const getEncryptionKey = () => + blake3Hash(WebBuf.fromHex(id.default.machineIdSync())).toHex(); + +const config = new Conf({ + clearInvalidConfig: true, + encryptionKey: getEncryptionKey(), + projectName: "encrypt", +}); + +export default config; diff --git a/src/node-machine-id.d.ts b/src/node-machine-id.d.ts new file mode 100644 index 0000000..b98a9cf --- /dev/null +++ b/src/node-machine-id.d.ts @@ -0,0 +1,8 @@ +declare module "node-machine-id" { + export function machineIdSync(): string; + interface NodeMachineId { + machineIdSync: typeof machineIdSync; + } + const id: NodeMachineId; + export default id; +} diff --git a/src/seed.ts b/src/seed.ts index c3c0ad2..cb3db42 100644 --- a/src/seed.ts +++ b/src/seed.ts @@ -1,23 +1,12 @@ -import Conf from "conf"; -import { password } from "@inquirer/prompts"; -import { Err, mayFail, Ok } from "ts-handling"; -import { mnemonicToEntropy } from "bip39"; import { randomBytes } from "crypto"; -import { type } from "arktype"; -import { PrivateKey } from "./private-key.js"; +import { password } from "@inquirer/prompts"; import { blake3Hash } from "@webbuf/blake3"; import { WebBuf } from "@webbuf/webbuf"; - -type Settings = { seed: string }; - -// Save seed locally and obscure. This is not designed for security. -// DO NOT SAVE ANY SENSITIVE SEED PHRASE USING THIS APP. Use only seed phrases -// dedicated to testing. -const config = new Conf({ - projectName: "encrypt", - encryptionKey: - "65cee028e58eac7b391a04790670c863aff3f467fa1f325b37df2be8536ddec0", -}); +import { type } from "arktype"; +import { mnemonicToEntropy } from "bip39"; +import { Err, mayFail, Ok } from "ts-handling"; +import config from "./config.js"; +import { PrivateKey } from "./private-key.js"; const getSavedSeed = () => config.get("seed");