safehands-pharos 1.4.0 → 1.5.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 (124) hide show
  1. package/README.md +174 -63
  2. package/dist/cli.d.ts +5 -5
  3. package/dist/cli.d.ts.map +1 -1
  4. package/dist/cli.js +126 -124
  5. package/dist/cli.js.map +1 -1
  6. package/dist/demo.d.ts +1 -1
  7. package/dist/demo.js +171 -171
  8. package/dist/index.d.ts +2 -2
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +73 -65
  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/constants.d.ts +303 -291
  15. package/dist/lib/constants.d.ts.map +1 -1
  16. package/dist/lib/constants.js +302 -292
  17. package/dist/lib/constants.js.map +1 -1
  18. package/dist/lib/dodoApi.d.ts +78 -78
  19. package/dist/lib/dodoApi.js +196 -196
  20. package/dist/lib/envLoader.d.ts +2 -0
  21. package/dist/lib/envLoader.d.ts.map +1 -0
  22. package/dist/lib/envLoader.js +44 -0
  23. package/dist/lib/envLoader.js.map +1 -0
  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.js +63 -63
  28. package/dist/lib/policy/actionPolicyEngine.d.ts +53 -53
  29. package/dist/lib/policy/actionPolicyEngine.js +212 -212
  30. package/dist/lib/riskEngine.d.ts +26 -26
  31. package/dist/lib/riskEngine.d.ts.map +1 -1
  32. package/dist/lib/riskEngine.js +288 -283
  33. package/dist/lib/riskEngine.js.map +1 -1
  34. package/dist/lib/signer/index.d.ts +24 -24
  35. package/dist/lib/signer/index.js +88 -88
  36. package/dist/lib/testDodoLive.d.ts +1 -1
  37. package/dist/lib/testDodoLive.js +104 -104
  38. package/dist/lib/testLiveSafehands.d.ts +1 -1
  39. package/dist/lib/testLiveSafehands.js +92 -92
  40. package/dist/lib/testRpcLive.d.ts +1 -1
  41. package/dist/lib/testRpcLive.js +88 -88
  42. package/dist/lib/testTools.js +397 -398
  43. package/dist/lib/testX402Live.d.ts +1 -1
  44. package/dist/lib/testX402Live.js +159 -159
  45. package/dist/lib/toolResponse.d.ts +25 -25
  46. package/dist/lib/toolResponse.js +53 -53
  47. package/dist/lib/wallet/index.d.ts +37 -37
  48. package/dist/lib/wallet/index.js +128 -128
  49. package/dist/scripts/checkDeploy.d.ts +1 -1
  50. package/dist/scripts/checkDeploy.js +24 -24
  51. package/dist/scripts/deployRegistry.d.ts +1 -1
  52. package/dist/scripts/deployRegistry.js +100 -100
  53. package/dist/scripts/testRegistry.d.ts +1 -1
  54. package/dist/scripts/testRegistry.js +43 -43
  55. package/dist/tools/approveToken.d.ts +45 -45
  56. package/dist/tools/approveToken.js +85 -85
  57. package/dist/tools/assessRisk.d.ts +79 -79
  58. package/dist/tools/assessRisk.js +104 -104
  59. package/dist/tools/checkAllowance.d.ts +43 -43
  60. package/dist/tools/checkAllowance.js +56 -56
  61. package/dist/tools/checkTokenSecurity.d.ts +46 -46
  62. package/dist/tools/checkTokenSecurity.js +95 -95
  63. package/dist/tools/createAgentWallet.d.ts +28 -26
  64. package/dist/tools/createAgentWallet.d.ts.map +1 -1
  65. package/dist/tools/createAgentWallet.js +82 -58
  66. package/dist/tools/createAgentWallet.js.map +1 -1
  67. package/dist/tools/estimateGas.d.ts +79 -79
  68. package/dist/tools/estimateGas.js +124 -124
  69. package/dist/tools/executeSwap.d.ts +61 -61
  70. package/dist/tools/executeSwap.js +141 -141
  71. package/dist/tools/explainRisk.d.ts +29 -29
  72. package/dist/tools/explainRisk.js +32 -32
  73. package/dist/tools/getAgentWallet.d.ts +21 -21
  74. package/dist/tools/getAgentWallet.js +27 -27
  75. package/dist/tools/getAgentWalletBalance.d.ts +11 -11
  76. package/dist/tools/getAgentWalletBalance.js +70 -70
  77. package/dist/tools/getExecutionHistory.d.ts +49 -49
  78. package/dist/tools/getExecutionHistory.js +154 -154
  79. package/dist/tools/getGasPrice.d.ts +43 -43
  80. package/dist/tools/getGasPrice.js +59 -59
  81. package/dist/tools/getPoolInfo.d.ts +75 -75
  82. package/dist/tools/getPoolInfo.js +137 -137
  83. package/dist/tools/getTokenPrice.d.ts +113 -113
  84. package/dist/tools/getTokenPrice.js +117 -117
  85. package/dist/tools/getTransactionStatus.d.ts +43 -43
  86. package/dist/tools/getTransactionStatus.js +59 -59
  87. package/dist/tools/getWalletBalance.d.ts +68 -68
  88. package/dist/tools/getWalletBalance.js +87 -87
  89. package/dist/tools/publishRiskScore.d.ts +63 -63
  90. package/dist/tools/publishRiskScore.js +88 -88
  91. package/dist/tools/queryRiskRegistry.d.ts +38 -38
  92. package/dist/tools/queryRiskRegistry.js +55 -55
  93. package/dist/tools/safehandsPreflightCheck.d.ts +77 -77
  94. package/dist/tools/safehandsPreflightCheck.js +47 -47
  95. package/dist/tools/safehandsRiskReport.d.ts +81 -81
  96. package/dist/tools/safehandsRiskReport.js +28 -28
  97. package/dist/tools/safehandsSafeExecute.d.ts +20 -20
  98. package/dist/tools/safehandsSafeExecute.js +81 -81
  99. package/dist/tools/safehandsWalletHealth.d.ts +14 -14
  100. package/dist/tools/safehandsWalletHealth.js +103 -103
  101. package/dist/tools/safehandsX402Preflight.d.ts +26 -26
  102. package/dist/tools/safehandsX402Preflight.js +65 -65
  103. package/dist/tools/sendPayment.d.ts +57 -57
  104. package/dist/tools/sendPayment.js +117 -117
  105. package/dist/tools/simulateTransaction.d.ts +60 -60
  106. package/dist/tools/simulateTransaction.js +83 -83
  107. package/dist/tools/tokenRegistryStatus.d.ts +26 -26
  108. package/dist/tools/tokenRegistryStatus.js +96 -96
  109. package/dist/tools/x402PayAndFetch.d.ts +81 -81
  110. package/dist/tools/x402PayAndFetch.js +152 -152
  111. package/dist/x402Server.d.ts +1 -1
  112. package/dist/x402Server.js +300 -252
  113. package/dist/x402Server.js.map +1 -1
  114. package/package.json +6 -16
  115. package/examples/dashboard/index.html +0 -337
  116. package/examples/pharos-skill-engine/SKILL.safehands.md +0 -85
  117. package/examples/pharos-skill-engine/assets/safehands/example-actions.json +0 -49
  118. package/examples/pharos-skill-engine/assets/safehands/policy-defaults.json +0 -11
  119. package/examples/pharos-skill-engine/references/safehands.md +0 -345
  120. package/examples/scenario-hack.ts +0 -38
  121. package/skill/SKILL.md +0 -133
  122. package/skill/assets/safehands/example-actions.json +0 -49
  123. package/skill/assets/safehands/policy-defaults.json +0 -11
  124. package/skill/references/safehands.md +0 -345
@@ -1,60 +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
- 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
- }
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
+ }
60
60
  //# sourceMappingURL=getTransactionStatus.js.map
@@ -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