chainai 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 (77) hide show
  1. package/package.json +1 -1
  2. package/dist/commands/broadcast.d.ts +0 -20
  3. package/dist/commands/broadcast.d.ts.map +0 -1
  4. package/dist/commands/broadcast.js +0 -35
  5. package/dist/commands/broadcast.js.map +0 -1
  6. package/dist/commands/gen-wallet.d.ts +0 -9
  7. package/dist/commands/gen-wallet.d.ts.map +0 -1
  8. package/dist/commands/gen-wallet.js +0 -17
  9. package/dist/commands/gen-wallet.js.map +0 -1
  10. package/dist/commands/get-balance.d.ts +0 -24
  11. package/dist/commands/get-balance.d.ts.map +0 -1
  12. package/dist/commands/get-balance.js +0 -82
  13. package/dist/commands/get-balance.js.map +0 -1
  14. package/dist/commands/send.d.ts +0 -27
  15. package/dist/commands/send.d.ts.map +0 -1
  16. package/dist/commands/send.js +0 -108
  17. package/dist/commands/send.js.map +0 -1
  18. package/dist/commands/sign-message.d.ts +0 -17
  19. package/dist/commands/sign-message.d.ts.map +0 -1
  20. package/dist/commands/sign-message.js +0 -36
  21. package/dist/commands/sign-message.js.map +0 -1
  22. package/dist/commands/sign-transaction.d.ts +0 -22
  23. package/dist/commands/sign-transaction.d.ts.map +0 -1
  24. package/dist/commands/sign-transaction.js +0 -31
  25. package/dist/commands/sign-transaction.js.map +0 -1
  26. package/dist/commands/sign-typed-data.d.ts +0 -22
  27. package/dist/commands/sign-typed-data.d.ts.map +0 -1
  28. package/dist/commands/sign-typed-data.js +0 -35
  29. package/dist/commands/sign-typed-data.js.map +0 -1
  30. package/dist/commands/sign.d.ts +0 -25
  31. package/dist/commands/sign.d.ts.map +0 -1
  32. package/dist/commands/sign.js +0 -36
  33. package/dist/commands/sign.js.map +0 -1
  34. package/dist/commands/swap-order-status.d.ts +0 -23
  35. package/dist/commands/swap-order-status.d.ts.map +0 -1
  36. package/dist/commands/swap-order-status.js +0 -35
  37. package/dist/commands/swap-order-status.js.map +0 -1
  38. package/dist/commands/swap.d.ts +0 -32
  39. package/dist/commands/swap.d.ts.map +0 -1
  40. package/dist/commands/swap.js +0 -119
  41. package/dist/commands/swap.js.map +0 -1
  42. package/dist/commands/tx-status.d.ts +0 -25
  43. package/dist/commands/tx-status.d.ts.map +0 -1
  44. package/dist/commands/tx-status.js +0 -54
  45. package/dist/commands/tx-status.js.map +0 -1
  46. package/dist/commands/who-am-i.d.ts +0 -12
  47. package/dist/commands/who-am-i.d.ts.map +0 -1
  48. package/dist/commands/who-am-i.js +0 -14
  49. package/dist/commands/who-am-i.js.map +0 -1
  50. package/dist/configs.d.ts +0 -99
  51. package/dist/configs.d.ts.map +0 -1
  52. package/dist/configs.js +0 -18
  53. package/dist/configs.js.map +0 -1
  54. package/dist/index.d.ts +0 -3
  55. package/dist/index.d.ts.map +0 -1
  56. package/dist/index.js +0 -404
  57. package/dist/index.js.map +0 -1
  58. package/dist/oneInchFusion/configs.d.ts +0 -3
  59. package/dist/oneInchFusion/configs.d.ts.map +0 -1
  60. package/dist/oneInchFusion/configs.js +0 -6
  61. package/dist/oneInchFusion/configs.js.map +0 -1
  62. package/dist/oneInchFusion/oneInchFusion.d.ts +0 -20
  63. package/dist/oneInchFusion/oneInchFusion.d.ts.map +0 -1
  64. package/dist/oneInchFusion/oneInchFusion.js +0 -164
  65. package/dist/oneInchFusion/oneInchFusion.js.map +0 -1
  66. package/dist/oneInchFusion/oneInchProvider.d.ts +0 -11
  67. package/dist/oneInchFusion/oneInchProvider.d.ts.map +0 -1
  68. package/dist/oneInchFusion/oneInchProvider.js +0 -34
  69. package/dist/oneInchFusion/oneInchProvider.js.map +0 -1
  70. package/dist/oneInchFusion/oneInchTypes.d.ts +0 -26
  71. package/dist/oneInchFusion/oneInchTypes.d.ts.map +0 -1
  72. package/dist/oneInchFusion/oneInchTypes.js +0 -3
  73. package/dist/oneInchFusion/oneInchTypes.js.map +0 -1
  74. package/dist/utils.d.ts +0 -68
  75. package/dist/utils.d.ts.map +0 -1
  76. package/dist/utils.js +0 -125
  77. package/dist/utils.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chainai",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "chainai CLI tool",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -1,20 +0,0 @@
1
- import type { Hex } from 'viem';
2
- export interface BroadcastInput {
3
- serializedTransaction: Hex;
4
- network?: string;
5
- }
6
- export interface BroadcastResult {
7
- transactionHash: string;
8
- network: string;
9
- explorerUrl: string;
10
- }
11
- /**
12
- * Broadcasts a serialized signed transaction to the network.
13
- *
14
- * Takes a hex-encoded RLP-serialized signed transaction (e.g. from `sign-transaction` or `send`)
15
- * and submits it via `eth_sendRawTransaction`.
16
- *
17
- * Returns the transaction hash on success.
18
- */
19
- export declare function broadcast(input: BroadcastInput): Promise<BroadcastResult>;
20
- //# sourceMappingURL=broadcast.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"broadcast.d.ts","sourceRoot":"","sources":["../../src/commands/broadcast.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAOhC,MAAM,WAAW,cAAc;IAC7B,qBAAqB,EAAE,GAAG,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,eAAe;IAC9B,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,wBAAsB,SAAS,CAC7B,KAAK,EAAE,cAAc,GACpB,OAAO,CAAC,eAAe,CAAC,CA2B1B"}
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.broadcast = broadcast;
4
- const viem_1 = require("viem");
5
- const utils_1 = require("../utils");
6
- /**
7
- * Broadcasts a serialized signed transaction to the network.
8
- *
9
- * Takes a hex-encoded RLP-serialized signed transaction (e.g. from `sign-transaction` or `send`)
10
- * and submits it via `eth_sendRawTransaction`.
11
- *
12
- * Returns the transaction hash on success.
13
- */
14
- async function broadcast(input) {
15
- const { serializedTransaction, network = 'mainnet' } = input;
16
- if (!serializedTransaction || !(0, viem_1.isHex)(serializedTransaction)) {
17
- throw new Error('Serialized transaction must be a valid 0x-prefixed hex string');
18
- }
19
- const chain = (0, utils_1.resolveNetwork)(network);
20
- const networkConfig = (0, utils_1.getNetworkConfig)(chain);
21
- const client = (0, utils_1.createNetworkClient)(chain, networkConfig);
22
- const transactionHash = await client.sendRawTransaction({
23
- serializedTransaction,
24
- });
25
- const explorerBase = chain.blockExplorers?.default?.url;
26
- const explorerUrl = explorerBase
27
- ? `${explorerBase}/tx/${transactionHash}`
28
- : `https://etherscan.io/tx/${transactionHash}`;
29
- return {
30
- transactionHash,
31
- network: chain.name,
32
- explorerUrl,
33
- };
34
- }
35
- //# sourceMappingURL=broadcast.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"broadcast.js","sourceRoot":"","sources":["../../src/commands/broadcast.ts"],"names":[],"mappings":";;AA2BA,8BA6BC;AAxDD,+BAA6B;AAE7B,oCAIkB;AAalB;;;;;;;GAOG;AACI,KAAK,UAAU,SAAS,CAC7B,KAAqB;IAErB,MAAM,EAAE,qBAAqB,EAAE,OAAO,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IAE7D,IAAI,CAAC,qBAAqB,IAAI,CAAC,IAAA,YAAK,EAAC,qBAAqB,CAAC,EAAE,CAAC;QAC5D,MAAM,IAAI,KAAK,CACb,+DAA+D,CAChE,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,GAAG,IAAA,sBAAc,EAAC,OAAO,CAAC,CAAC;IACtC,MAAM,aAAa,GAAG,IAAA,wBAAgB,EAAC,KAAK,CAAC,CAAC;IAC9C,MAAM,MAAM,GAAG,IAAA,2BAAmB,EAAC,KAAK,EAAE,aAAa,CAAC,CAAC;IAEzD,MAAM,eAAe,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC;QACtD,qBAAqB;KACtB,CAAC,CAAC;IAEH,MAAM,YAAY,GAAG,KAAK,CAAC,cAAc,EAAE,OAAO,EAAE,GAAG,CAAC;IACxD,MAAM,WAAW,GAAG,YAAY;QAC9B,CAAC,CAAC,GAAG,YAAY,OAAO,eAAe,EAAE;QACzC,CAAC,CAAC,2BAA2B,eAAe,EAAE,CAAC;IAEjD,OAAO;QACL,eAAe;QACf,OAAO,EAAE,KAAK,CAAC,IAAI;QACnB,WAAW;KACZ,CAAC;AACJ,CAAC"}
@@ -1,9 +0,0 @@
1
- export interface GenWalletResult {
2
- address: string;
3
- privateKey: string;
4
- }
5
- /**
6
- * Generates a new random wallet (private key + address).
7
- */
8
- export declare function genWallet(): GenWalletResult;
9
- //# sourceMappingURL=gen-wallet.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"gen-wallet.d.ts","sourceRoot":"","sources":["../../src/commands/gen-wallet.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,wBAAgB,SAAS,IAAI,eAAe,CAO3C"}
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.genWallet = genWallet;
4
- const accounts_1 = require("viem/accounts");
5
- const accounts_2 = require("viem/accounts");
6
- /**
7
- * Generates a new random wallet (private key + address).
8
- */
9
- function genWallet() {
10
- const privateKey = (0, accounts_2.generatePrivateKey)();
11
- const account = (0, accounts_1.privateKeyToAccount)(privateKey);
12
- return {
13
- address: account.address,
14
- privateKey,
15
- };
16
- }
17
- //# sourceMappingURL=gen-wallet.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"gen-wallet.js","sourceRoot":"","sources":["../../src/commands/gen-wallet.ts"],"names":[],"mappings":";;AAWA,8BAOC;AAlBD,4CAAoD;AACpD,4CAAmD;AAOnD;;GAEG;AACH,SAAgB,SAAS;IACvB,MAAM,UAAU,GAAG,IAAA,6BAAkB,GAAE,CAAC;IACxC,MAAM,OAAO,GAAG,IAAA,8BAAmB,EAAC,UAAU,CAAC,CAAC;IAChD,OAAO;QACL,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,UAAU;KACX,CAAC;AACJ,CAAC"}
@@ -1,24 +0,0 @@
1
- import type { Hex } from 'viem';
2
- export interface GetBalanceInput {
3
- address: Hex;
4
- network?: string;
5
- token?: string;
6
- all?: boolean;
7
- }
8
- export interface GetBalanceResult {
9
- address: string;
10
- network: string;
11
- token: string;
12
- balance: string;
13
- rawBalance: string;
14
- decimals: number;
15
- contract: string | null;
16
- }
17
- /**
18
- * Fetches the balance of a native token or ERC-20 token for a given address.
19
- *
20
- * - For native tokens (ETH, BNB, etc.), uses the node RPC via viem.
21
- * - For ERC-20 tokens, uses the MEW balances API.
22
- */
23
- export declare function getBalance(input: GetBalanceInput): Promise<GetBalanceResult | GetBalanceResult[]>;
24
- //# sourceMappingURL=get-balance.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-balance.d.ts","sourceRoot":"","sources":["../../src/commands/get-balance.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAS,MAAM,MAAM,CAAC;AASvC,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,GAAG,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED;;;;;GAKG;AACH,wBAAsB,UAAU,CAC9B,KAAK,EAAE,eAAe,GACrB,OAAO,CAAC,gBAAgB,GAAG,gBAAgB,EAAE,CAAC,CAmEhD"}
@@ -1,82 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getBalance = getBalance;
4
- const viem_1 = require("viem");
5
- const utils_1 = require("../utils");
6
- /**
7
- * Fetches the balance of a native token or ERC-20 token for a given address.
8
- *
9
- * - For native tokens (ETH, BNB, etc.), uses the node RPC via viem.
10
- * - For ERC-20 tokens, uses the MEW balances API.
11
- */
12
- async function getBalance(input) {
13
- const { address, network = 'mainnet', token = utils_1.NATIVE_TOKEN_ADDRESS, all = false, } = input;
14
- if (!address || !address.startsWith('0x')) {
15
- throw new Error('Address must be a valid 0x-prefixed hex string');
16
- }
17
- const chain = (0, utils_1.resolveNetwork)(network);
18
- const networkConfig = (0, utils_1.getNetworkConfig)(chain);
19
- if (all) {
20
- return getAllBalances(address, chain, networkConfig);
21
- }
22
- if (!(0, viem_1.isAddress)(token)) {
23
- throw new Error(`Token must be a valid 0x-prefixed address. Use ${utils_1.NATIVE_TOKEN_ADDRESS} for native token.`);
24
- }
25
- const isNative = token.toLowerCase() === utils_1.NATIVE_TOKEN_ADDRESS;
26
- if (isNative) {
27
- const client = (0, utils_1.createNetworkClient)(chain, networkConfig);
28
- const balanceWei = await client.getBalance({ address });
29
- const formatted = (0, viem_1.formatUnits)(balanceWei, chain.nativeCurrency.decimals);
30
- return {
31
- address,
32
- network: chain.name,
33
- token: chain.nativeCurrency.symbol,
34
- balance: formatted,
35
- rawBalance: balanceWei.toString(),
36
- decimals: chain.nativeCurrency.decimals,
37
- contract: utils_1.NATIVE_TOKEN_ADDRESS,
38
- };
39
- }
40
- // ERC-20 token: look up from balances API
41
- const balances = await (0, utils_1.getTokenBalances)(chain.id, address);
42
- const tokenLower = token.toLowerCase();
43
- const found = balances.find((t) => t.contract.toLowerCase() === tokenLower);
44
- if (!found) {
45
- throw new Error(`Token "${token}" not found for address ${address} on ${chain.name}. The address may not hold this token.`);
46
- }
47
- const rawBalance = BigInt(found.balance);
48
- const formatted = (0, viem_1.formatUnits)(rawBalance, found.decimals);
49
- return {
50
- address,
51
- network: chain.name,
52
- token: found.symbol,
53
- balance: formatted,
54
- rawBalance: rawBalance.toString(),
55
- decimals: found.decimals,
56
- contract: found.contract,
57
- };
58
- }
59
- /**
60
- * Fetches all token balances (native + ERC-20) for a given address.
61
- */
62
- async function getAllBalances(address, chain, networkConfig) {
63
- const [tokenBalances] = await Promise.all([
64
- (0, utils_1.getTokenBalances)(chain.id, address),
65
- ]);
66
- const results = [];
67
- // All balances including Native
68
- for (const t of tokenBalances) {
69
- const raw = BigInt(t.balance);
70
- results.push({
71
- address,
72
- network: chain.name,
73
- token: t.symbol,
74
- balance: (0, viem_1.formatUnits)(raw, t.decimals),
75
- rawBalance: raw.toString(),
76
- decimals: t.decimals,
77
- contract: t.contract,
78
- });
79
- }
80
- return results;
81
- }
82
- //# sourceMappingURL=get-balance.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-balance.js","sourceRoot":"","sources":["../../src/commands/get-balance.ts"],"names":[],"mappings":";;AAiCA,gCAqEC;AAtGD,+BAA8C;AAE9C,oCAMkB;AAmBlB;;;;;GAKG;AACI,KAAK,UAAU,UAAU,CAC9B,KAAsB;IAEtB,MAAM,EACJ,OAAO,EACP,OAAO,GAAG,SAAS,EACnB,KAAK,GAAG,4BAAoB,EAC5B,GAAG,GAAG,KAAK,GACZ,GAAG,KAAK,CAAC;IAEV,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IACpE,CAAC;IAED,MAAM,KAAK,GAAG,IAAA,sBAAc,EAAC,OAAO,CAAC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C,CAAC,QAAQ;YACpB,QAAQ,EAAE,CAAC,CAAC,QAAQ;SACrB,CAAC,CAAC;IACL,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -1,27 +0,0 @@
1
- import type { Hex } from 'viem';
2
- export interface SendInput {
3
- privateKey: Hex;
4
- to: Hex;
5
- token: string;
6
- amount: string;
7
- network?: string;
8
- }
9
- export interface SendResult {
10
- from: string;
11
- to: string;
12
- token: string;
13
- amount: string;
14
- network: string;
15
- serializedTransaction: string;
16
- }
17
- /**
18
- * Builds and signs a transaction to send native tokens or ERC-20 tokens.
19
- *
20
- * - For native tokens (ETH, BNB), creates a simple value transfer.
21
- * - For ERC-20 tokens, encodes a `transfer(address, uint256)` call.
22
- *
23
- * Fetches nonce, gas estimate, and fee data from the network RPC.
24
- * Returns the serialized signed transaction ready to broadcast.
25
- */
26
- export declare function send(input: SendInput): Promise<SendResult>;
27
- //# sourceMappingURL=send.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"send.d.ts","sourceRoot":"","sources":["../../src/commands/send.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AA6BhC,MAAM,WAAW,SAAS;IACxB,UAAU,EAAE,GAAG,CAAC;IAChB,EAAE,EAAE,GAAG,CAAC;IACR,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,qBAAqB,EAAE,MAAM,CAAC;CAC/B;AAED;;;;;;;;GAQG;AACH,wBAAsB,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CA4FhE"}
@@ -1,108 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.send = send;
4
- const viem_1 = require("viem");
5
- const utils_1 = require("../utils");
6
- const ERC20_ABI = [
7
- {
8
- name: 'transfer',
9
- type: 'function',
10
- inputs: [
11
- { name: 'to', type: 'address' },
12
- { name: 'amount', type: 'uint256' },
13
- ],
14
- outputs: [{ name: '', type: 'bool' }],
15
- stateMutability: 'nonpayable',
16
- },
17
- {
18
- name: 'decimals',
19
- type: 'function',
20
- inputs: [],
21
- outputs: [{ name: '', type: 'uint8' }],
22
- stateMutability: 'view',
23
- },
24
- ];
25
- /**
26
- * Builds and signs a transaction to send native tokens or ERC-20 tokens.
27
- *
28
- * - For native tokens (ETH, BNB), creates a simple value transfer.
29
- * - For ERC-20 tokens, encodes a `transfer(address, uint256)` call.
30
- *
31
- * Fetches nonce, gas estimate, and fee data from the network RPC.
32
- * Returns the serialized signed transaction ready to broadcast.
33
- */
34
- async function send(input) {
35
- const { privateKey, to, token, amount, network = 'mainnet' } = input;
36
- const account = (0, utils_1.validateAndCreateAccount)(privateKey);
37
- if (!(0, viem_1.isAddress)(to)) {
38
- throw new Error('Recipient "to" must be a valid 0x-prefixed address');
39
- }
40
- if (!(0, viem_1.isAddress)(token)) {
41
- throw new Error(`Token must be a valid 0x-prefixed address. Use ${utils_1.NATIVE_TOKEN_ADDRESS} for native token.`);
42
- }
43
- if (!amount || isNaN(Number(amount)) || Number(amount) <= 0) {
44
- throw new Error('Amount must be a positive number');
45
- }
46
- const chain = (0, utils_1.resolveNetwork)(network);
47
- const networkConfig = (0, utils_1.getNetworkConfig)(chain);
48
- const client = (0, utils_1.createNetworkClient)(chain, networkConfig);
49
- const isNative = token.toLowerCase() === utils_1.NATIVE_TOKEN_ADDRESS;
50
- const nonce = await client.getTransactionCount({ address: account.address });
51
- const feeData = await client.estimateFeesPerGas();
52
- let txRequest;
53
- if (isNative) {
54
- const value = (0, viem_1.parseUnits)(amount, chain.nativeCurrency.decimals);
55
- const gas = await client.estimateGas({
56
- account: account.address,
57
- to: to,
58
- value,
59
- });
60
- txRequest = {
61
- to,
62
- value,
63
- gas,
64
- nonce,
65
- chainId: chain.id,
66
- maxFeePerGas: feeData.maxFeePerGas,
67
- maxPriorityFeePerGas: feeData.maxPriorityFeePerGas,
68
- };
69
- }
70
- else {
71
- // ERC-20: read decimals then encode transfer
72
- const decimals = await client.readContract({
73
- address: token,
74
- abi: ERC20_ABI,
75
- functionName: 'decimals',
76
- });
77
- const rawAmount = (0, viem_1.parseUnits)(amount, decimals);
78
- const data = (0, viem_1.encodeFunctionData)({
79
- abi: ERC20_ABI,
80
- functionName: 'transfer',
81
- args: [to, rawAmount],
82
- });
83
- const gas = await client.estimateGas({
84
- account: account.address,
85
- to: token,
86
- data,
87
- });
88
- txRequest = {
89
- to: token,
90
- data,
91
- gas,
92
- nonce,
93
- chainId: chain.id,
94
- maxFeePerGas: feeData.maxFeePerGas,
95
- maxPriorityFeePerGas: feeData.maxPriorityFeePerGas,
96
- };
97
- }
98
- const serializedTransaction = await account.signTransaction(txRequest);
99
- return {
100
- from: account.address,
101
- to,
102
- token,
103
- amount,
104
- network: chain.name,
105
- serializedTransaction,
106
- };
107
- }
108
- //# sourceMappingURL=send.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"send.js","sourceRoot":"","sources":["../../src/commands/send.ts"],"names":[],"mappings":";;AAwDA,oBA4FC;AApJD,+BAAiE;AAEjE,oCAMkB;AAElB,MAAM,SAAS,GAAG;IAChB;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,UAAU;QAChB,MAAM,EAAE;YACN,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE;YAC/B,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE;SACpC;QACD,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QACrC,eAAe,EAA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,OAAO,EAAE,KAAK,CAAC,EAAE;YACjB,YAAY,EAAE,OAAO,CAAC,YAAY;YAClC,oBAAoB,EAAE,OAAO,CAAC,oBAAoB;SACnD,CAAC;IACJ,CAAC;IAED,MAAM,qBAAqB,GAAG,MAAM,OAAO,CAAC,eAAe,CAAC,SAAgB,CAAC,CAAC;IAE9E,OAAO;QACL,IAAI,EAAE,OAAO,CAAC,OAAO;QACrB,EAAE;QACF,KAAK;QACL,MAAM;QACN,OAAO,EAAE,KAAK,CAAC,IAAI;QACnB,qBAAqB;KACtB,CAAC;AACJ,CAAC"}
@@ -1,17 +0,0 @@
1
- import type { Hex } from 'viem';
2
- export interface SignMessageInput {
3
- privateKey: Hex;
4
- message: string;
5
- raw?: boolean;
6
- }
7
- export interface SignMessageResult {
8
- address: string;
9
- message: string;
10
- signature: string;
11
- }
12
- /**
13
- * Signs a message using the provided private key via viem.
14
- * Returns the signer address, original message, and resulting signature.
15
- */
16
- export declare function signMessage(input: SignMessageInput): Promise<SignMessageResult>;
17
- //# sourceMappingURL=sign-message.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sign-message.d.ts","sourceRoot":"","sources":["../../src/commands/sign-message.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAGhC,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,GAAG,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAsB,WAAW,CAC/B,KAAK,EAAE,gBAAgB,GACtB,OAAO,CAAC,iBAAiB,CAAC,CAgC5B"}
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.signMessage = signMessage;
4
- const viem_1 = require("viem");
5
- const utils_1 = require("../utils");
6
- /**
7
- * Signs a message using the provided private key via viem.
8
- * Returns the signer address, original message, and resulting signature.
9
- */
10
- async function signMessage(input) {
11
- const { privateKey, message } = input;
12
- if (!message || message.length === 0) {
13
- throw new Error('Message must be a non-empty string');
14
- }
15
- const account = (0, utils_1.validateAndCreateAccount)(privateKey);
16
- if (input.raw) {
17
- if (!(0, viem_1.isHex)(message, { strict: true })) {
18
- throw new Error('Message must be a valid hex string (0x-prefixed) when using raw mode');
19
- }
20
- const signature = await account.signMessage({
21
- message: { raw: message },
22
- });
23
- return {
24
- address: account.address,
25
- message,
26
- signature,
27
- };
28
- }
29
- const signature = await account.signMessage({ message });
30
- return {
31
- address: account.address,
32
- message,
33
- signature,
34
- };
35
- }
36
- //# sourceMappingURL=sign-message.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sign-message.js","sourceRoot":"","sources":["../../src/commands/sign-message.ts"],"names":[],"mappings":";;AAoBA,kCAkCC;AAtDD,+BAA6B;AAE7B,oCAAoD;AAcpD;;;GAGG;AACI,KAAK,UAAU,WAAW,CAC/B,KAAuB;IAEvB,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IAEtC,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;IACxD,CAAC;IAED,MAAM,OAAO,GAAG,IAAA,gCAAwB,EAAC,UAAU,CAAC,CAAC;IAErD,IAAI,KAAK,CAAC,GAAG,EAAE,CAAC;QACd,IAAI,CAAC,IAAA,YAAK,EAAC,OAAO,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;YACtC,MAAM,IAAI,KAAK,CACb,sEAAsE,CACvE,CAAC;QACJ,CAAC;QACD,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,WAAW,CAAC;YAC1C,OAAO,EAAE,EAAE,GAAG,EAAE,OAAc,EAAE;SACjC,CAAC,CAAC;QACH,OAAO;YACL,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,OAAO;YACP,SAAS;SACV,CAAC;IACJ,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IAEzD,OAAO;QACL,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,OAAO;QACP,SAAS;KACV,CAAC;AACJ,CAAC"}
@@ -1,22 +0,0 @@
1
- import type { Hex, TransactionSerializableEIP1559, TransactionSerializableEIP2930, TransactionSerializableLegacy } from 'viem';
2
- export type TransactionInput = TransactionSerializableLegacy | TransactionSerializableEIP2930 | TransactionSerializableEIP1559;
3
- export interface SignTransactionInput {
4
- privateKey: Hex;
5
- transaction: TransactionInput;
6
- }
7
- export interface SignTransactionResult {
8
- address: string;
9
- serializedTransaction: string;
10
- }
11
- /**
12
- * Signs a transaction using the provided private key via viem.
13
- * Returns the signer address and the serialized signed transaction
14
- * (RLP-encoded, ready to broadcast).
15
- *
16
- * ⚠️ SECURITY NOTE ⚠️
17
- * This produces a fully signed transaction that can be broadcast to a network.
18
- * Agents should verify transaction parameters (to, value, data, chainId)
19
- * before signing.
20
- */
21
- export declare function signTransaction(input: SignTransactionInput): Promise<SignTransactionResult>;
22
- //# sourceMappingURL=sign-transaction.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sign-transaction.d.ts","sourceRoot":"","sources":["../../src/commands/sign-transaction.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,GAAG,EACH,8BAA8B,EAC9B,8BAA8B,EAC9B,6BAA6B,EAC9B,MAAM,MAAM,CAAC;AAGd,MAAM,MAAM,gBAAgB,GACxB,6BAA6B,GAC7B,8BAA8B,GAC9B,8BAA8B,CAAC;AAEnC,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,GAAG,CAAC;IAChB,WAAW,EAAE,gBAAgB,CAAC;CAC/B;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,qBAAqB,EAAE,MAAM,CAAC;CAC/B;AAED;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CACnC,KAAK,EAAE,oBAAoB,GAC1B,OAAO,CAAC,qBAAqB,CAAC,CAoBhC"}
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.signTransaction = signTransaction;
4
- const viem_1 = require("viem");
5
- const utils_1 = require("../utils");
6
- /**
7
- * Signs a transaction using the provided private key via viem.
8
- * Returns the signer address and the serialized signed transaction
9
- * (RLP-encoded, ready to broadcast).
10
- *
11
- * ⚠️ SECURITY NOTE ⚠️
12
- * This produces a fully signed transaction that can be broadcast to a network.
13
- * Agents should verify transaction parameters (to, value, data, chainId)
14
- * before signing.
15
- */
16
- async function signTransaction(input) {
17
- const { privateKey, transaction } = input;
18
- if (!transaction || typeof transaction !== 'object') {
19
- throw new Error('Transaction must be a valid transaction object');
20
- }
21
- if (transaction.to && !(0, viem_1.isHex)(transaction.to, { strict: true })) {
22
- throw new Error('Transaction "to" field must be a valid 0x-prefixed hex address');
23
- }
24
- const account = (0, utils_1.validateAndCreateAccount)(privateKey);
25
- const serializedTransaction = await account.signTransaction(transaction);
26
- return {
27
- address: account.address,
28
- serializedTransaction,
29
- };
30
- }
31
- //# sourceMappingURL=sign-transaction.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sign-transaction.js","sourceRoot":"","sources":["../../src/commands/sign-transaction.ts"],"names":[],"mappings":";;AAkCA,0CAsBC;AAxDD,+BAA6B;AAO7B,oCAAoD;AAiBpD;;;;;;;;;GASG;AACI,KAAK,UAAU,eAAe,CACnC,KAA2B;IAE3B,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC;IAE1C,IAAI,CAAC,WAAW,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE,CAAC;QACpD,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IACpE,CAAC;IAED,IAAI,WAAW,CAAC,EAAE,IAAI,CAAC,IAAA,YAAK,EAAC,WAAW,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;QAC/D,MAAM,IAAI,KAAK,CACb,gEAAgE,CACjE,CAAC;IACJ,CAAC;IAED,MAAM,OAAO,GAAG,IAAA,gCAAwB,EAAC,UAAU,CAAC,CAAC;IACrD,MAAM,qBAAqB,GAAG,MAAM,OAAO,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;IAEzE,OAAO;QACL,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,qBAAqB;KACtB,CAAC;AACJ,CAAC"}
@@ -1,22 +0,0 @@
1
- import type { Hex, TypedDataDomain } from 'viem';
2
- export interface TypedDataField {
3
- name: string;
4
- type: string;
5
- }
6
- export interface SignTypedDataInput {
7
- privateKey: Hex;
8
- domain: TypedDataDomain;
9
- types: Record<string, TypedDataField[]>;
10
- primaryType: string;
11
- message: Record<string, unknown>;
12
- }
13
- export interface SignTypedDataResult {
14
- address: string;
15
- signature: string;
16
- }
17
- /**
18
- * Signs EIP-712 typed data using the provided private key via viem.
19
- * Returns the signer address and resulting signature.
20
- */
21
- export declare function signTypedData(input: SignTypedDataInput): Promise<SignTypedDataResult>;
22
- //# sourceMappingURL=sign-typed-data.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sign-typed-data.d.ts","sourceRoot":"","sources":["../../src/commands/sign-typed-data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAGjD,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,GAAG,CAAC;IAChB,MAAM,EAAE,eAAe,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC;IACxC,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAsB,aAAa,CACjC,KAAK,EAAE,kBAAkB,GACxB,OAAO,CAAC,mBAAmB,CAAC,CA+B9B"}
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.signTypedData = signTypedData;
4
- const utils_1 = require("../utils");
5
- /**
6
- * Signs EIP-712 typed data using the provided private key via viem.
7
- * Returns the signer address and resulting signature.
8
- */
9
- async function signTypedData(input) {
10
- const { privateKey, domain, types, primaryType, message } = input;
11
- if (!domain || typeof domain !== 'object') {
12
- throw new Error('Domain must be a valid EIP-712 domain object');
13
- }
14
- if (!types || typeof types !== 'object' || Object.keys(types).length === 0) {
15
- throw new Error('Types must be a non-empty object defining EIP-712 types');
16
- }
17
- if (!primaryType || typeof primaryType !== 'string') {
18
- throw new Error('Primary type must be a non-empty string');
19
- }
20
- if (!message || typeof message !== 'object') {
21
- throw new Error('Message must be a valid object');
22
- }
23
- const account = (0, utils_1.validateAndCreateAccount)(privateKey);
24
- const signature = await account.signTypedData({
25
- domain,
26
- types,
27
- primaryType,
28
- message,
29
- });
30
- return {
31
- address: account.address,
32
- signature,
33
- };
34
- }
35
- //# sourceMappingURL=sign-typed-data.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sign-typed-data.js","sourceRoot":"","sources":["../../src/commands/sign-typed-data.ts"],"names":[],"mappings":";;AAyBA,sCAiCC;AAzDD,oCAAoD;AAoBpD;;;GAGG;AACI,KAAK,UAAU,aAAa,CACjC,KAAyB;IAEzB,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IAElE,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAClE,CAAC;IAED,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3E,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,CAAC;IAED,IAAI,CAAC,WAAW,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE,CAAC;QACpD,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC7D,CAAC;IAED,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACpD,CAAC;IAED,MAAM,OAAO,GAAG,IAAA,gCAAwB,EAAC,UAAU,CAAC,CAAC;IACrD,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,aAAa,CAAC;QAC5C,MAAM;QACN,KAAK;QACL,WAAW;QACX,OAAO;KACR,CAAC,CAAC;IAEH,OAAO;QACL,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,SAAS;KACV,CAAC;AACJ,CAAC"}
@@ -1,25 +0,0 @@
1
- import type { Hex } from 'viem';
2
- export interface SignInput {
3
- privateKey: Hex;
4
- hash: Hex;
5
- }
6
- export interface SignResult {
7
- address: string;
8
- hash: string;
9
- signature: string;
10
- }
11
- /**
12
- * Signs raw data using account.sign (secp256k1 signature over a digest).
13
- *
14
- * ⚠️ CRITICAL SECURITY WARNING ⚠️
15
- * This function signs arbitrary hashes WITHOUT any prefix or envelope.
16
- * The resulting signature can authorize transactions, token transfers,
17
- * contract interactions, or any on-chain action — potentially without
18
- * the user's knowledge or explicit consent.
19
- *
20
- * Only use this when absolutely necessary. Prefer `signMessage` (EIP-191)
21
- * whenever possible, as it applies a human-readable prefix that prevents
22
- * signed data from being replayed as a transaction.
23
- */
24
- export declare function sign(input: SignInput): Promise<SignResult>;
25
- //# sourceMappingURL=sign.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sign.d.ts","sourceRoot":"","sources":["../../src/commands/sign.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAGhC,MAAM,WAAW,SAAS;IACxB,UAAU,EAAE,GAAG,CAAC;IAChB,IAAI,EAAE,GAAG,CAAC;CACX;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAoBhE"}
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sign = sign;
4
- const viem_1 = require("viem");
5
- const utils_1 = require("../utils");
6
- /**
7
- * Signs raw data using account.sign (secp256k1 signature over a digest).
8
- *
9
- * ⚠️ CRITICAL SECURITY WARNING ⚠️
10
- * This function signs arbitrary hashes WITHOUT any prefix or envelope.
11
- * The resulting signature can authorize transactions, token transfers,
12
- * contract interactions, or any on-chain action — potentially without
13
- * the user's knowledge or explicit consent.
14
- *
15
- * Only use this when absolutely necessary. Prefer `signMessage` (EIP-191)
16
- * whenever possible, as it applies a human-readable prefix that prevents
17
- * signed data from being replayed as a transaction.
18
- */
19
- async function sign(input) {
20
- const { privateKey, hash } = input;
21
- if (!hash || !(0, viem_1.isHex)(hash, { strict: true })) {
22
- throw new Error('Hash must be a valid 0x-prefixed hex string');
23
- }
24
- // 32 bytes = 64 hex characters + '0x' prefix = 66 characters
25
- if (hash.length !== 66) {
26
- throw new Error('Hash must be exactly 32 bytes (64 hex characters)');
27
- }
28
- const account = (0, utils_1.validateAndCreateAccount)(privateKey);
29
- const signature = await account.sign({ hash });
30
- return {
31
- address: account.address,
32
- hash,
33
- signature,
34
- };
35
- }
36
- //# sourceMappingURL=sign.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sign.js","sourceRoot":"","sources":["../../src/commands/sign.ts"],"names":[],"mappings":";;AA4BA,oBAoBC;AAhDD,+BAA6B;AAE7B,oCAAoD;AAapD;;;;;;;;;;;;GAYG;AACI,KAAK,UAAU,IAAI,CAAC,KAAgB;IACzC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;IAEnC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAA,YAAK,EAAC,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;IACjE,CAAC;IAED,6DAA6D;IAC7D,IAAI,IAAI,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACvE,CAAC;IAED,MAAM,OAAO,GAAG,IAAA,gCAAwB,EAAC,UAAU,CAAC,CAAC;IACrD,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;IAE/C,OAAO;QACL,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,IAAI;QACJ,SAAS;KACV,CAAC;AACJ,CAAC"}