safehands-pharos 1.2.6 → 1.4.0

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 (153) hide show
  1. package/.env.example +64 -26
  2. package/README.md +333 -445
  3. package/dist/cli.d.ts +5 -5
  4. package/dist/cli.d.ts.map +1 -1
  5. package/dist/cli.js +124 -98
  6. package/dist/cli.js.map +1 -1
  7. package/dist/demo.d.ts +1 -1
  8. package/dist/demo.js +171 -171
  9. package/dist/index.d.ts +2 -2
  10. package/dist/index.js +138 -87
  11. package/dist/index.js.map +1 -1
  12. package/dist/init.d.ts +1 -1
  13. package/dist/init.js +65 -65
  14. package/dist/lib/auditLog.d.ts +9 -0
  15. package/dist/lib/auditLog.d.ts.map +1 -0
  16. package/dist/lib/auditLog.js +30 -0
  17. package/dist/lib/auditLog.js.map +1 -0
  18. package/dist/lib/constants.d.ts +291 -291
  19. package/dist/lib/constants.js +292 -292
  20. package/dist/lib/dodoApi.d.ts +78 -70
  21. package/dist/lib/dodoApi.d.ts.map +1 -1
  22. package/dist/lib/dodoApi.js +196 -178
  23. package/dist/lib/dodoApi.js.map +1 -1
  24. package/dist/lib/http.d.ts +14 -14
  25. package/dist/lib/http.js +118 -118
  26. package/dist/lib/pharosClient.d.ts +58 -58
  27. package/dist/lib/pharosClient.d.ts.map +1 -1
  28. package/dist/lib/pharosClient.js +63 -53
  29. package/dist/lib/pharosClient.js.map +1 -1
  30. package/dist/lib/policy/actionPolicyEngine.d.ts +53 -53
  31. package/dist/lib/policy/actionPolicyEngine.js +212 -212
  32. package/dist/lib/policy/actionPolicyEngine.js.map +1 -1
  33. package/dist/lib/riskEngine.d.ts +26 -26
  34. package/dist/lib/riskEngine.js +283 -283
  35. package/dist/lib/signer/index.d.ts +24 -24
  36. package/dist/lib/signer/index.d.ts.map +1 -1
  37. package/dist/lib/signer/index.js +88 -89
  38. package/dist/lib/signer/index.js.map +1 -1
  39. package/dist/lib/spendAccumulator.d.ts +10 -0
  40. package/dist/lib/spendAccumulator.d.ts.map +1 -0
  41. package/dist/lib/spendAccumulator.js +54 -0
  42. package/dist/lib/spendAccumulator.js.map +1 -0
  43. package/dist/lib/testDodoLive.d.ts +1 -1
  44. package/dist/lib/testDodoLive.js +104 -104
  45. package/dist/lib/testLiveSafehands.d.ts +1 -1
  46. package/dist/lib/testLiveSafehands.js +92 -92
  47. package/dist/lib/testRpc.d.ts +1 -1
  48. package/dist/lib/testRpc.js +29 -29
  49. package/dist/lib/testRpcLive.d.ts +1 -1
  50. package/dist/lib/testRpcLive.js +88 -88
  51. package/dist/lib/testTools.d.ts +1 -1
  52. package/dist/lib/testTools.js +397 -397
  53. package/dist/lib/testX402Live.d.ts +1 -1
  54. package/dist/lib/testX402Live.js +159 -159
  55. package/dist/lib/toolResponse.d.ts +25 -25
  56. package/dist/lib/toolResponse.js +53 -53
  57. package/dist/lib/wallet/index.d.ts +37 -18
  58. package/dist/lib/wallet/index.d.ts.map +1 -1
  59. package/dist/lib/wallet/index.js +128 -70
  60. package/dist/lib/wallet/index.js.map +1 -1
  61. package/dist/scripts/checkDeploy.d.ts +1 -1
  62. package/dist/scripts/checkDeploy.js +24 -24
  63. package/dist/scripts/deployRegistry.d.ts +1 -1
  64. package/dist/scripts/deployRegistry.js +100 -100
  65. package/dist/scripts/testRegistry.d.ts +1 -1
  66. package/dist/scripts/testRegistry.js +43 -43
  67. package/dist/tools/approveToken.d.ts +45 -46
  68. package/dist/tools/approveToken.d.ts.map +1 -1
  69. package/dist/tools/approveToken.js +85 -83
  70. package/dist/tools/approveToken.js.map +1 -1
  71. package/dist/tools/assessRisk.d.ts +79 -79
  72. package/dist/tools/assessRisk.d.ts.map +1 -1
  73. package/dist/tools/assessRisk.js +104 -93
  74. package/dist/tools/assessRisk.js.map +1 -1
  75. package/dist/tools/checkAllowance.d.ts +43 -36
  76. package/dist/tools/checkAllowance.d.ts.map +1 -1
  77. package/dist/tools/checkAllowance.js +56 -42
  78. package/dist/tools/checkAllowance.js.map +1 -1
  79. package/dist/tools/checkTokenSecurity.d.ts +46 -46
  80. package/dist/tools/checkTokenSecurity.d.ts.map +1 -1
  81. package/dist/tools/checkTokenSecurity.js +95 -88
  82. package/dist/tools/checkTokenSecurity.js.map +1 -1
  83. package/dist/tools/createAgentWallet.d.ts +26 -26
  84. package/dist/tools/createAgentWallet.d.ts.map +1 -1
  85. package/dist/tools/createAgentWallet.js +58 -59
  86. package/dist/tools/createAgentWallet.js.map +1 -1
  87. package/dist/tools/estimateGas.d.ts +79 -79
  88. package/dist/tools/estimateGas.js +124 -124
  89. package/dist/tools/executeSwap.d.ts +61 -59
  90. package/dist/tools/executeSwap.d.ts.map +1 -1
  91. package/dist/tools/executeSwap.js +141 -129
  92. package/dist/tools/executeSwap.js.map +1 -1
  93. package/dist/tools/explainRisk.d.ts +29 -29
  94. package/dist/tools/explainRisk.js +32 -32
  95. package/dist/tools/getAgentWallet.d.ts +21 -21
  96. package/dist/tools/getAgentWallet.js +27 -27
  97. package/dist/tools/getAgentWalletBalance.d.ts +11 -11
  98. package/dist/tools/getAgentWalletBalance.js +70 -70
  99. package/dist/tools/getExecutionHistory.d.ts +49 -51
  100. package/dist/tools/getExecutionHistory.d.ts.map +1 -1
  101. package/dist/tools/getExecutionHistory.js +154 -93
  102. package/dist/tools/getExecutionHistory.js.map +1 -1
  103. package/dist/tools/getGasPrice.d.ts +43 -43
  104. package/dist/tools/getGasPrice.js +59 -59
  105. package/dist/tools/getPoolInfo.d.ts +75 -75
  106. package/dist/tools/getPoolInfo.js +137 -137
  107. package/dist/tools/getTokenPrice.d.ts +113 -113
  108. package/dist/tools/getTokenPrice.js +117 -117
  109. package/dist/tools/getTransactionStatus.d.ts +43 -57
  110. package/dist/tools/getTransactionStatus.d.ts.map +1 -1
  111. package/dist/tools/getTransactionStatus.js +59 -67
  112. package/dist/tools/getTransactionStatus.js.map +1 -1
  113. package/dist/tools/getWalletBalance.d.ts +68 -68
  114. package/dist/tools/getWalletBalance.js +87 -87
  115. package/dist/tools/publishRiskScore.d.ts +63 -63
  116. package/dist/tools/publishRiskScore.d.ts.map +1 -1
  117. package/dist/tools/publishRiskScore.js +88 -85
  118. package/dist/tools/publishRiskScore.js.map +1 -1
  119. package/dist/tools/queryRiskRegistry.d.ts +38 -48
  120. package/dist/tools/queryRiskRegistry.d.ts.map +1 -1
  121. package/dist/tools/queryRiskRegistry.js +55 -60
  122. package/dist/tools/queryRiskRegistry.js.map +1 -1
  123. package/dist/tools/safehandsPreflightCheck.d.ts +77 -77
  124. package/dist/tools/safehandsPreflightCheck.js +47 -47
  125. package/dist/tools/safehandsRiskReport.d.ts +81 -81
  126. package/dist/tools/safehandsRiskReport.js +28 -28
  127. package/dist/tools/safehandsSafeExecute.d.ts +20 -20
  128. package/dist/tools/safehandsSafeExecute.d.ts.map +1 -1
  129. package/dist/tools/safehandsSafeExecute.js +81 -75
  130. package/dist/tools/safehandsSafeExecute.js.map +1 -1
  131. package/dist/tools/safehandsWalletHealth.d.ts +14 -14
  132. package/dist/tools/safehandsWalletHealth.js +103 -103
  133. package/dist/tools/safehandsX402Preflight.d.ts +26 -26
  134. package/dist/tools/safehandsX402Preflight.js +65 -65
  135. package/dist/tools/sendPayment.d.ts +57 -58
  136. package/dist/tools/sendPayment.d.ts.map +1 -1
  137. package/dist/tools/sendPayment.js +117 -108
  138. package/dist/tools/sendPayment.js.map +1 -1
  139. package/dist/tools/simulateTransaction.d.ts +60 -81
  140. package/dist/tools/simulateTransaction.d.ts.map +1 -1
  141. package/dist/tools/simulateTransaction.js +83 -88
  142. package/dist/tools/simulateTransaction.js.map +1 -1
  143. package/dist/tools/tokenRegistryStatus.d.ts +26 -26
  144. package/dist/tools/tokenRegistryStatus.js +96 -96
  145. package/dist/tools/x402PayAndFetch.d.ts +81 -81
  146. package/dist/tools/x402PayAndFetch.d.ts.map +1 -1
  147. package/dist/tools/x402PayAndFetch.js +152 -149
  148. package/dist/tools/x402PayAndFetch.js.map +1 -1
  149. package/dist/x402Server.d.ts +1 -1
  150. package/dist/x402Server.js +252 -252
  151. package/examples/dashboard/index.html +337 -0
  152. package/package.json +83 -82
  153. package/skill/SKILL.md +133 -133
@@ -1,68 +1,60 @@
1
- // ─── Tool: get_transaction_status ──────────────────────────────────────
2
- // Checks on-chain transaction status by hash via viem.
3
- // ────────────────────────────────────────────────────────────────────────
4
- import { z } from "zod";
5
- import { publicClient, getExplorerUrl } from "../lib/pharosClient.js";
6
- export const getTransactionStatusSchema = z.object({
7
- txHash: z.string().describe("Transaction hash to look up"),
8
- });
9
- export const getTransactionStatusTool = {
10
- name: "get_transaction_status",
11
- description: "Check the on-chain status of a transaction by its hash. Returns status, block number, gas used, and explorer link.",
12
- inputSchema: getTransactionStatusSchema,
13
- };
14
- export async function handleGetTransactionStatus(raw) {
15
- const input = getTransactionStatusSchema.parse(raw);
16
- const hash = input.txHash;
17
- // Try to get the receipt first (only exists if tx is mined)
18
- try {
19
- const receipt = await publicClient.getTransactionReceipt({ hash });
20
- const tx = await publicClient.getTransaction({ hash });
21
- return {
22
- txHash: input.txHash,
23
- status: receipt.status === "success" ? "success" : "failed",
24
- blockNumber: receipt.blockNumber.toString(),
25
- blockHash: receipt.blockHash,
26
- from: receipt.from,
27
- to: receipt.to,
28
- gasUsed: receipt.gasUsed.toString(),
29
- effectiveGasPrice: receipt.effectiveGasPrice.toString(),
30
- value: tx.value.toString(),
31
- explorerUrl: getExplorerUrl(input.txHash),
32
- };
33
- }
34
- catch {
35
- // Receipt not found — check if the tx exists at all (pending)
36
- try {
37
- const tx = await publicClient.getTransaction({ hash });
38
- return {
39
- txHash: input.txHash,
40
- status: "pending",
41
- blockNumber: null,
42
- blockHash: null,
43
- from: tx.from,
44
- to: tx.to,
45
- gasUsed: null,
46
- effectiveGasPrice: null,
47
- value: tx.value.toString(),
48
- explorerUrl: getExplorerUrl(input.txHash),
49
- };
50
- }
51
- catch {
52
- return {
53
- txHash: input.txHash,
54
- status: "not_found",
55
- blockNumber: null,
56
- blockHash: null,
57
- from: null,
58
- to: null,
59
- gasUsed: null,
60
- effectiveGasPrice: null,
61
- value: null,
62
- explorerUrl: getExplorerUrl(input.txHash),
63
- error: "Transaction not found on chain",
64
- };
65
- }
66
- }
67
- }
1
+ // ─── Tool: get_transaction_status ──────────────────────────────────────
2
+ // Checks on-chain transaction status by hash via viem.
3
+ // ────────────────────────────────────────────────────────────────────────
4
+ import { z } from "zod";
5
+ import { publicClient, getExplorerUrl } from "../lib/pharosClient.js";
6
+ import { ok, fail } from "../lib/toolResponse.js";
7
+ export const getTransactionStatusSchema = z.object({
8
+ txHash: z.string().describe("Transaction hash to look up"),
9
+ });
10
+ export const getTransactionStatusTool = {
11
+ name: "get_transaction_status",
12
+ description: "Check the on-chain status of a transaction by its hash. Returns status, block number, gas used, and explorer link.",
13
+ inputSchema: getTransactionStatusSchema,
14
+ };
15
+ export async function handleGetTransactionStatus(raw) {
16
+ const input = getTransactionStatusSchema.parse(raw);
17
+ const hash = input.txHash;
18
+ // Try to get the receipt first (only exists if tx is mined)
19
+ try {
20
+ const receipt = await publicClient.getTransactionReceipt({ hash });
21
+ const tx = await publicClient.getTransaction({ hash });
22
+ const details = {
23
+ txHash: input.txHash,
24
+ blockNumber: receipt.blockNumber.toString(),
25
+ blockHash: receipt.blockHash,
26
+ from: receipt.from,
27
+ to: receipt.to,
28
+ gasUsed: receipt.gasUsed.toString(),
29
+ effectiveGasPrice: receipt.effectiveGasPrice.toString(),
30
+ value: tx.value.toString(),
31
+ explorerUrl: getExplorerUrl(input.txHash),
32
+ };
33
+ if (receipt.status !== "success") {
34
+ return fail("TX_REVERTED", "Transaction was mined but reverted on-chain.", false, "get_transaction_status");
35
+ }
36
+ return ok({ ...details, txStatus: "success" });
37
+ }
38
+ catch {
39
+ // Receipt not found — check if the tx exists at all (pending)
40
+ try {
41
+ const tx = await publicClient.getTransaction({ hash });
42
+ return ok({
43
+ txHash: input.txHash,
44
+ txStatus: "pending",
45
+ blockNumber: null,
46
+ blockHash: null,
47
+ from: tx.from,
48
+ to: tx.to,
49
+ gasUsed: null,
50
+ effectiveGasPrice: null,
51
+ value: tx.value.toString(),
52
+ explorerUrl: getExplorerUrl(input.txHash),
53
+ });
54
+ }
55
+ catch {
56
+ return fail("TX_NOT_FOUND", "Transaction not found on chain.", false, "get_transaction_status");
57
+ }
58
+ }
59
+ }
68
60
  //# sourceMappingURL=getTransactionStatus.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getTransactionStatus.js","sourceRoot":"","sources":["../../src/tools/getTransactionStatus.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,uDAAuD;AACvD,2EAA2E;AAE3E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAEtE,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IACjD,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,6BAA6B,CAAC;CAC3D,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,IAAI,EAAE,wBAAwB;IAC9B,WAAW,EACT,oHAAoH;IACtH,WAAW,EAAE,0BAA0B;CACxC,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAAC,GAA8B;IAC7E,MAAM,KAAK,GAAG,0BAA0B,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACpD,MAAM,IAAI,GAAG,KAAK,CAAC,MAAuB,CAAC;IAE3C,4DAA4D;IAC5D,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,qBAAqB,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;QACnE,MAAM,EAAE,GAAG,MAAM,YAAY,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;QAEvD,OAAO;YACL,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,MAAM,EAAE,OAAO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K,EAAE,wBAAwB,CAAC,CAAC;QAClG,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -1,69 +1,69 @@
1
- import { z } from "zod";
2
- export declare const getWalletBalanceSchema: z.ZodObject<{
3
- walletAddress: z.ZodString;
4
- }, "strip", z.ZodTypeAny, {
5
- walletAddress: string;
6
- }, {
7
- walletAddress: string;
8
- }>;
9
- export type GetWalletBalanceInput = z.input<typeof getWalletBalanceSchema>;
10
- export declare const getWalletBalanceTool: {
11
- name: string;
12
- description: string;
13
- inputSchema: z.ZodObject<{
14
- walletAddress: z.ZodString;
15
- }, "strip", z.ZodTypeAny, {
16
- walletAddress: string;
17
- }, {
18
- walletAddress: string;
19
- }>;
20
- };
21
- export declare function handleGetWalletBalance(raw: GetWalletBalanceInput): Promise<import("../lib/toolResponse.js").ToolFailure | import("../lib/toolResponse.js").ToolSuccess<{
22
- walletAddress: `0x${string}`;
23
- balances: {
24
- PHRS: {
25
- balance: {
26
- value: string;
27
- unit: string;
28
- };
29
- valueUsd: {
30
- value: string;
31
- unit: string;
32
- };
33
- };
34
- USDC: {
35
- balance: {
36
- value: string;
37
- unit: string;
38
- };
39
- valueUsd: {
40
- value: string;
41
- unit: string;
42
- };
43
- };
44
- USDT: {
45
- balance: {
46
- value: string;
47
- unit: string;
48
- };
49
- valueUsd: {
50
- value: string;
51
- unit: string;
52
- };
53
- };
54
- };
55
- totalUsd: {
56
- value: string;
57
- unit: string;
58
- };
59
- phrsPrice: {
60
- value: string;
61
- unit: string;
62
- } | null;
63
- priceSourceStatus: string;
64
- chainId: number;
65
- environment: string;
66
- isMainnet: boolean;
67
- source: string;
68
- }>>;
1
+ import { z } from "zod";
2
+ export declare const getWalletBalanceSchema: z.ZodObject<{
3
+ walletAddress: z.ZodString;
4
+ }, "strip", z.ZodTypeAny, {
5
+ walletAddress: string;
6
+ }, {
7
+ walletAddress: string;
8
+ }>;
9
+ export type GetWalletBalanceInput = z.input<typeof getWalletBalanceSchema>;
10
+ export declare const getWalletBalanceTool: {
11
+ name: string;
12
+ description: string;
13
+ inputSchema: z.ZodObject<{
14
+ walletAddress: z.ZodString;
15
+ }, "strip", z.ZodTypeAny, {
16
+ walletAddress: string;
17
+ }, {
18
+ walletAddress: string;
19
+ }>;
20
+ };
21
+ export declare function handleGetWalletBalance(raw: GetWalletBalanceInput): Promise<import("../lib/toolResponse.js").ToolFailure | import("../lib/toolResponse.js").ToolSuccess<{
22
+ walletAddress: `0x${string}`;
23
+ balances: {
24
+ PHRS: {
25
+ balance: {
26
+ value: string;
27
+ unit: string;
28
+ };
29
+ valueUsd: {
30
+ value: string;
31
+ unit: string;
32
+ };
33
+ };
34
+ USDC: {
35
+ balance: {
36
+ value: string;
37
+ unit: string;
38
+ };
39
+ valueUsd: {
40
+ value: string;
41
+ unit: string;
42
+ };
43
+ };
44
+ USDT: {
45
+ balance: {
46
+ value: string;
47
+ unit: string;
48
+ };
49
+ valueUsd: {
50
+ value: string;
51
+ unit: string;
52
+ };
53
+ };
54
+ };
55
+ totalUsd: {
56
+ value: string;
57
+ unit: string;
58
+ };
59
+ phrsPrice: {
60
+ value: string;
61
+ unit: string;
62
+ } | null;
63
+ priceSourceStatus: string;
64
+ chainId: number;
65
+ environment: string;
66
+ isMainnet: boolean;
67
+ source: string;
68
+ }>>;
69
69
  //# sourceMappingURL=getWalletBalance.d.ts.map
@@ -1,88 +1,88 @@
1
- // ─── Tool: get_wallet_balance ──────────────────────────────────────────
2
- // Returns PHRS, USDC, USDT balances for a wallet using viem reads.
3
- // ────────────────────────────────────────────────────────────────────────
4
- import { z } from "zod";
5
- import { publicClient } from "../lib/pharosClient.js";
6
- import { getDodoRoute } from "../lib/dodoApi.js";
7
- import { USDC_ADDRESS, USDT_ADDRESS, ERC20_ABI, CHAIN_ID, PHAROS_ENVIRONMENT } from "../lib/constants.js";
8
- import { formatEther, formatUnits, isAddress } from "viem";
9
- import { classifyExternalError, fail, ok } from "../lib/toolResponse.js";
10
- export const getWalletBalanceSchema = z.object({
11
- walletAddress: z.string().describe("Wallet address to check balances for"),
12
- });
13
- export const getWalletBalanceTool = {
14
- name: "get_wallet_balance",
15
- description: "Return PHRS (native), USDC, and USDT balances for a wallet on Pharos Atlantic Testnet, with total USD estimate.",
16
- inputSchema: getWalletBalanceSchema,
17
- };
18
- const QUOTE_WALLET = "0x0000000000000000000000000000000000000001";
19
- export async function handleGetWalletBalance(raw) {
20
- const input = getWalletBalanceSchema.parse(raw);
21
- if (!isAddress(input.walletAddress)) {
22
- return fail("INVALID_WALLET_ADDRESS", `Invalid wallet address: ${input.walletAddress}`, false, "get_wallet_balance");
23
- }
24
- const addr = input.walletAddress;
25
- try {
26
- const [phrsBalanceWei, usdcBalanceRaw, usdtBalanceRaw] = await Promise.all([
27
- publicClient.getBalance({ address: addr }),
28
- publicClient.readContract({
29
- address: USDC_ADDRESS,
30
- abi: ERC20_ABI,
31
- functionName: "balanceOf",
32
- args: [addr],
33
- }),
34
- publicClient.readContract({
35
- address: USDT_ADDRESS,
36
- abi: ERC20_ABI,
37
- functionName: "balanceOf",
38
- args: [addr],
39
- }),
40
- ]);
41
- const phrsBalance = formatEther(phrsBalanceWei);
42
- const usdcBalance = formatUnits(usdcBalanceRaw, 6);
43
- const usdtBalance = formatUnits(usdtBalanceRaw, 6);
44
- let phrsUsd = 0;
45
- let priceSourceStatus = "unavailable";
46
- try {
47
- const quote = await getDodoRoute({
48
- fromToken: "PHRS",
49
- toToken: "USDC",
50
- amountHuman: "1",
51
- walletAddress: QUOTE_WALLET,
52
- });
53
- if (quote.routeAvailable) {
54
- phrsUsd = parseFloat(quote.amountOut);
55
- priceSourceStatus = "ok";
56
- }
57
- else {
58
- priceSourceStatus = "no_route_available";
59
- }
60
- }
61
- catch {
62
- priceSourceStatus = "unavailable";
63
- }
64
- const phrsValueUsd = parseFloat(phrsBalance) * phrsUsd;
65
- const usdcValueUsd = parseFloat(usdcBalance);
66
- const usdtValueUsd = parseFloat(usdtBalance);
67
- const totalUsd = (phrsValueUsd + usdcValueUsd + usdtValueUsd).toFixed(4);
68
- return ok({
69
- walletAddress: input.walletAddress,
70
- balances: {
71
- PHRS: { balance: { value: phrsBalance, unit: "PHRS" }, valueUsd: { value: phrsValueUsd.toFixed(4), unit: "USD" } },
72
- USDC: { balance: { value: usdcBalance, unit: "USDC" }, valueUsd: { value: usdcValueUsd.toFixed(4), unit: "USD" } },
73
- USDT: { balance: { value: usdtBalance, unit: "USDT" }, valueUsd: { value: usdtValueUsd.toFixed(4), unit: "USD" } },
74
- },
75
- totalUsd: { value: totalUsd, unit: "USD" },
76
- phrsPrice: phrsUsd > 0 ? { value: phrsUsd.toFixed(4), unit: "USD" } : null,
77
- priceSourceStatus,
78
- chainId: CHAIN_ID,
79
- environment: PHAROS_ENVIRONMENT,
80
- isMainnet: false,
81
- source: "pharos_rpc",
82
- });
83
- }
84
- catch (err) {
85
- return classifyExternalError("pharos_rpc", err);
86
- }
87
- }
1
+ // ─── Tool: get_wallet_balance ──────────────────────────────────────────
2
+ // Returns PHRS, USDC, USDT balances for a wallet using viem reads.
3
+ // ────────────────────────────────────────────────────────────────────────
4
+ import { z } from "zod";
5
+ import { publicClient } from "../lib/pharosClient.js";
6
+ import { getDodoRoute } from "../lib/dodoApi.js";
7
+ import { USDC_ADDRESS, USDT_ADDRESS, ERC20_ABI, CHAIN_ID, PHAROS_ENVIRONMENT } from "../lib/constants.js";
8
+ import { formatEther, formatUnits, isAddress } from "viem";
9
+ import { classifyExternalError, fail, ok } from "../lib/toolResponse.js";
10
+ export const getWalletBalanceSchema = z.object({
11
+ walletAddress: z.string().describe("Wallet address to check balances for"),
12
+ });
13
+ export const getWalletBalanceTool = {
14
+ name: "get_wallet_balance",
15
+ description: "Return PHRS (native), USDC, and USDT balances for a wallet on Pharos Atlantic Testnet, with total USD estimate.",
16
+ inputSchema: getWalletBalanceSchema,
17
+ };
18
+ const QUOTE_WALLET = "0x0000000000000000000000000000000000000001";
19
+ export async function handleGetWalletBalance(raw) {
20
+ const input = getWalletBalanceSchema.parse(raw);
21
+ if (!isAddress(input.walletAddress)) {
22
+ return fail("INVALID_WALLET_ADDRESS", `Invalid wallet address: ${input.walletAddress}`, false, "get_wallet_balance");
23
+ }
24
+ const addr = input.walletAddress;
25
+ try {
26
+ const [phrsBalanceWei, usdcBalanceRaw, usdtBalanceRaw] = await Promise.all([
27
+ publicClient.getBalance({ address: addr }),
28
+ publicClient.readContract({
29
+ address: USDC_ADDRESS,
30
+ abi: ERC20_ABI,
31
+ functionName: "balanceOf",
32
+ args: [addr],
33
+ }),
34
+ publicClient.readContract({
35
+ address: USDT_ADDRESS,
36
+ abi: ERC20_ABI,
37
+ functionName: "balanceOf",
38
+ args: [addr],
39
+ }),
40
+ ]);
41
+ const phrsBalance = formatEther(phrsBalanceWei);
42
+ const usdcBalance = formatUnits(usdcBalanceRaw, 6);
43
+ const usdtBalance = formatUnits(usdtBalanceRaw, 6);
44
+ let phrsUsd = 0;
45
+ let priceSourceStatus = "unavailable";
46
+ try {
47
+ const quote = await getDodoRoute({
48
+ fromToken: "PHRS",
49
+ toToken: "USDC",
50
+ amountHuman: "1",
51
+ walletAddress: QUOTE_WALLET,
52
+ });
53
+ if (quote.routeAvailable) {
54
+ phrsUsd = parseFloat(quote.amountOut);
55
+ priceSourceStatus = "ok";
56
+ }
57
+ else {
58
+ priceSourceStatus = "no_route_available";
59
+ }
60
+ }
61
+ catch {
62
+ priceSourceStatus = "unavailable";
63
+ }
64
+ const phrsValueUsd = parseFloat(phrsBalance) * phrsUsd;
65
+ const usdcValueUsd = parseFloat(usdcBalance);
66
+ const usdtValueUsd = parseFloat(usdtBalance);
67
+ const totalUsd = (phrsValueUsd + usdcValueUsd + usdtValueUsd).toFixed(4);
68
+ return ok({
69
+ walletAddress: input.walletAddress,
70
+ balances: {
71
+ PHRS: { balance: { value: phrsBalance, unit: "PHRS" }, valueUsd: { value: phrsValueUsd.toFixed(4), unit: "USD" } },
72
+ USDC: { balance: { value: usdcBalance, unit: "USDC" }, valueUsd: { value: usdcValueUsd.toFixed(4), unit: "USD" } },
73
+ USDT: { balance: { value: usdtBalance, unit: "USDT" }, valueUsd: { value: usdtValueUsd.toFixed(4), unit: "USD" } },
74
+ },
75
+ totalUsd: { value: totalUsd, unit: "USD" },
76
+ phrsPrice: phrsUsd > 0 ? { value: phrsUsd.toFixed(4), unit: "USD" } : null,
77
+ priceSourceStatus,
78
+ chainId: CHAIN_ID,
79
+ environment: PHAROS_ENVIRONMENT,
80
+ isMainnet: false,
81
+ source: "pharos_rpc",
82
+ });
83
+ }
84
+ catch (err) {
85
+ return classifyExternalError("pharos_rpc", err);
86
+ }
87
+ }
88
88
  //# sourceMappingURL=getWalletBalance.js.map
@@ -1,64 +1,64 @@
1
- import { z } from "zod";
2
- export declare const publishRiskScoreSchema: z.ZodObject<{
3
- action: z.ZodEnum<["swap", "transfer"]>;
4
- tokenIn: z.ZodOptional<z.ZodString>;
5
- tokenOut: z.ZodOptional<z.ZodString>;
6
- amount: z.ZodString;
7
- toAddress: z.ZodOptional<z.ZodString>;
8
- agentId: z.ZodOptional<z.ZodString>;
9
- }, "strip", z.ZodTypeAny, {
10
- amount: string;
11
- action: "transfer" | "swap";
12
- tokenIn?: string | undefined;
13
- tokenOut?: string | undefined;
14
- agentId?: string | undefined;
15
- toAddress?: string | undefined;
16
- }, {
17
- amount: string;
18
- action: "transfer" | "swap";
19
- tokenIn?: string | undefined;
20
- tokenOut?: string | undefined;
21
- agentId?: string | undefined;
22
- toAddress?: string | undefined;
23
- }>;
24
- export type PublishRiskScoreInput = z.input<typeof publishRiskScoreSchema>;
25
- export declare const publishRiskScoreTool: {
26
- name: string;
27
- description: string;
28
- inputSchema: z.ZodObject<{
29
- action: z.ZodEnum<["swap", "transfer"]>;
30
- tokenIn: z.ZodOptional<z.ZodString>;
31
- tokenOut: z.ZodOptional<z.ZodString>;
32
- amount: z.ZodString;
33
- toAddress: z.ZodOptional<z.ZodString>;
34
- agentId: z.ZodOptional<z.ZodString>;
35
- }, "strip", z.ZodTypeAny, {
36
- amount: string;
37
- action: "transfer" | "swap";
38
- tokenIn?: string | undefined;
39
- tokenOut?: string | undefined;
40
- agentId?: string | undefined;
41
- toAddress?: string | undefined;
42
- }, {
43
- amount: string;
44
- action: "transfer" | "swap";
45
- tokenIn?: string | undefined;
46
- tokenOut?: string | undefined;
47
- agentId?: string | undefined;
48
- toAddress?: string | undefined;
49
- }>;
50
- };
51
- export declare function handlePublishRiskScore(raw: PublishRiskScoreInput): Promise<import("../lib/toolResponse.js").ToolFailure | import("../lib/toolResponse.js").ToolSuccess<{
52
- assessment: import("../lib/riskEngine.js").RiskAssessment;
53
- policy: import("../lib/policy/actionPolicyEngine.js").ActionPolicyResult;
54
- signerMode: import("../lib/signer/index.js").SignerMode;
55
- onChain: {
56
- txHash: `0x${string}`;
57
- explorerUrl: string;
58
- contractAddress: `0x${string}`;
59
- gasUsed: string;
60
- blockNumber: string;
61
- };
62
- source: string;
63
- }>>;
1
+ import { z } from "zod";
2
+ export declare const publishRiskScoreSchema: z.ZodObject<{
3
+ action: z.ZodEnum<["swap", "transfer"]>;
4
+ tokenIn: z.ZodOptional<z.ZodString>;
5
+ tokenOut: z.ZodOptional<z.ZodString>;
6
+ amount: z.ZodString;
7
+ toAddress: z.ZodOptional<z.ZodString>;
8
+ agentId: z.ZodOptional<z.ZodString>;
9
+ }, "strip", z.ZodTypeAny, {
10
+ amount: string;
11
+ action: "transfer" | "swap";
12
+ tokenIn?: string | undefined;
13
+ tokenOut?: string | undefined;
14
+ agentId?: string | undefined;
15
+ toAddress?: string | undefined;
16
+ }, {
17
+ amount: string;
18
+ action: "transfer" | "swap";
19
+ tokenIn?: string | undefined;
20
+ tokenOut?: string | undefined;
21
+ agentId?: string | undefined;
22
+ toAddress?: string | undefined;
23
+ }>;
24
+ export type PublishRiskScoreInput = z.input<typeof publishRiskScoreSchema>;
25
+ export declare const publishRiskScoreTool: {
26
+ name: string;
27
+ description: string;
28
+ inputSchema: z.ZodObject<{
29
+ action: z.ZodEnum<["swap", "transfer"]>;
30
+ tokenIn: z.ZodOptional<z.ZodString>;
31
+ tokenOut: z.ZodOptional<z.ZodString>;
32
+ amount: z.ZodString;
33
+ toAddress: z.ZodOptional<z.ZodString>;
34
+ agentId: z.ZodOptional<z.ZodString>;
35
+ }, "strip", z.ZodTypeAny, {
36
+ amount: string;
37
+ action: "transfer" | "swap";
38
+ tokenIn?: string | undefined;
39
+ tokenOut?: string | undefined;
40
+ agentId?: string | undefined;
41
+ toAddress?: string | undefined;
42
+ }, {
43
+ amount: string;
44
+ action: "transfer" | "swap";
45
+ tokenIn?: string | undefined;
46
+ tokenOut?: string | undefined;
47
+ agentId?: string | undefined;
48
+ toAddress?: string | undefined;
49
+ }>;
50
+ };
51
+ export declare function handlePublishRiskScore(raw: PublishRiskScoreInput): Promise<import("../lib/toolResponse.js").ToolFailure | import("../lib/toolResponse.js").ToolSuccess<{
52
+ assessment: import("../lib/riskEngine.js").RiskAssessment;
53
+ policy: import("../lib/policy/actionPolicyEngine.js").ActionPolicyResult;
54
+ signerMode: import("../lib/signer/index.js").SignerMode;
55
+ onChain: {
56
+ txHash: `0x${string}`;
57
+ explorerUrl: string;
58
+ contractAddress: `0x${string}`;
59
+ gasUsed: string;
60
+ blockNumber: string;
61
+ };
62
+ source: string;
63
+ }>>;
64
64
  //# sourceMappingURL=publishRiskScore.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"publishRiskScore.d.ts","sourceRoot":"","sources":["../../src/tools/publishRiskScore.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;EAOjC,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAE3E,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;CAMhC,CAAC;AAEF,wBAAsB,sBAAsB,CAAC,GAAG,EAAE,qBAAqB;;;;;;;;;;;;IAiEtE"}
1
+ {"version":3,"file":"publishRiskScore.d.ts","sourceRoot":"","sources":["../../src/tools/publishRiskScore.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;EAOjC,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAE3E,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;CAMhC,CAAC;AAEF,wBAAsB,sBAAsB,CAAC,GAAG,EAAE,qBAAqB;;;;;;;;;;;;IAgFtE"}