keyring-agent-core 0.1.0 → 0.2.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.
- package/dist/agent/AgentCore.d.ts +37 -1
- package/dist/agent/AgentCore.d.ts.map +1 -1
- package/dist/agent/AgentCore.js +287 -144
- package/dist/agent/AgentCore.js.map +1 -1
- package/dist/agent/QueryRewriter.d.ts +17 -0
- package/dist/agent/QueryRewriter.d.ts.map +1 -1
- package/dist/agent/QueryRewriter.js +48 -4
- package/dist/agent/QueryRewriter.js.map +1 -1
- package/dist/agent/Router.d.ts.map +1 -1
- package/dist/agent/Router.js +73 -35
- package/dist/agent/Router.js.map +1 -1
- package/dist/agent/Subagent.d.ts +17 -0
- package/dist/agent/Subagent.d.ts.map +1 -1
- package/dist/agent/Subagent.js +32 -0
- package/dist/agent/Subagent.js.map +1 -1
- package/dist/agent/chatGraph.d.ts +364 -0
- package/dist/agent/chatGraph.d.ts.map +1 -0
- package/dist/agent/chatGraph.js +184 -0
- package/dist/agent/chatGraph.js.map +1 -0
- package/dist/agent/subagents/AiAgent.d.ts +1 -1
- package/dist/agent/subagents/AiAgent.d.ts.map +1 -1
- package/dist/agent/subagents/AiAgent.js +24 -20
- package/dist/agent/subagents/AiAgent.js.map +1 -1
- package/dist/agent/subagents/NftAgent.d.ts +1 -1
- package/dist/agent/subagents/NftAgent.d.ts.map +1 -1
- package/dist/agent/subagents/NftAgent.js +36 -26
- package/dist/agent/subagents/NftAgent.js.map +1 -1
- package/dist/agent/subagents/PoolSubgraphAgent.d.ts +6 -0
- package/dist/agent/subagents/PoolSubgraphAgent.d.ts.map +1 -0
- package/dist/agent/subagents/PoolSubgraphAgent.js +117 -0
- package/dist/agent/subagents/PoolSubgraphAgent.js.map +1 -0
- package/dist/agent/subagents/TokenAgent.d.ts +1 -1
- package/dist/agent/subagents/TokenAgent.d.ts.map +1 -1
- package/dist/agent/subagents/TokenAgent.js +23 -22
- package/dist/agent/subagents/TokenAgent.js.map +1 -1
- package/dist/agent/subagents/WalletActionAgent.d.ts +6 -0
- package/dist/agent/subagents/WalletActionAgent.d.ts.map +1 -0
- package/dist/agent/subagents/WalletActionAgent.js +55 -0
- package/dist/agent/subagents/WalletActionAgent.js.map +1 -0
- package/dist/agent/subagents/WalletAgent.d.ts +1 -1
- package/dist/agent/subagents/WalletAgent.d.ts.map +1 -1
- package/dist/agent/subagents/WalletAgent.js +18 -17
- package/dist/agent/subagents/WalletAgent.js.map +1 -1
- package/dist/agent/subagents/index.d.ts +23 -3
- package/dist/agent/subagents/index.d.ts.map +1 -1
- package/dist/agent/subagents/index.js +42 -11
- package/dist/agent/subagents/index.js.map +1 -1
- package/dist/constants/abi.d.ts +31 -0
- package/dist/constants/abi.d.ts.map +1 -1
- package/dist/constants/abi.js +24 -1
- package/dist/constants/abi.js.map +1 -1
- package/dist/functions/web3.d.ts +0 -1
- package/dist/functions/web3.d.ts.map +1 -1
- package/dist/functions/web3.js +0 -45
- package/dist/functions/web3.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/llm/GeminiProvider.d.ts.map +1 -1
- package/dist/llm/GeminiProvider.js +115 -34
- package/dist/llm/GeminiProvider.js.map +1 -1
- package/dist/memory/UpstashKnowledgeBase.d.ts +1 -1
- package/dist/memory/UpstashKnowledgeBase.js +1 -1
- package/dist/services/MoralisService.d.ts +3 -25
- package/dist/services/MoralisService.d.ts.map +1 -1
- package/dist/services/MoralisService.js +7 -132
- package/dist/services/MoralisService.js.map +1 -1
- package/dist/services/PantographService.d.ts +61 -1
- package/dist/services/PantographService.d.ts.map +1 -1
- package/dist/services/PantographService.js +264 -12
- package/dist/services/PantographService.js.map +1 -1
- package/dist/services/PoolService.d.ts +1 -4
- package/dist/services/PoolService.d.ts.map +1 -1
- package/dist/services/PoolService.js +18 -40
- package/dist/services/PoolService.js.map +1 -1
- package/dist/services/UniswapSubgraphService.d.ts +144 -0
- package/dist/services/UniswapSubgraphService.d.ts.map +1 -0
- package/dist/services/UniswapSubgraphService.js +606 -0
- package/dist/services/UniswapSubgraphService.js.map +1 -0
- package/dist/services/rpc.d.ts +35 -0
- package/dist/services/rpc.d.ts.map +1 -0
- package/dist/services/rpc.js +110 -0
- package/dist/services/rpc.js.map +1 -0
- package/dist/services/swap/DebridgeAdapter.d.ts +17 -0
- package/dist/services/swap/DebridgeAdapter.d.ts.map +1 -1
- package/dist/services/swap/DebridgeAdapter.js +74 -6
- package/dist/services/swap/DebridgeAdapter.js.map +1 -1
- package/dist/services/swap/SwapServiceFactory.d.ts +1 -0
- package/dist/services/swap/SwapServiceFactory.d.ts.map +1 -1
- package/dist/services/swap/SwapServiceFactory.js +8 -3
- package/dist/services/swap/SwapServiceFactory.js.map +1 -1
- package/dist/tools/builtin/ai/GeminiSearchAiTool.d.ts +36 -0
- package/dist/tools/builtin/ai/GeminiSearchAiTool.d.ts.map +1 -0
- package/dist/tools/builtin/ai/GeminiSearchAiTool.js +91 -0
- package/dist/tools/builtin/ai/GeminiSearchAiTool.js.map +1 -0
- package/dist/tools/builtin/ai/index.d.ts +2 -4
- package/dist/tools/builtin/ai/index.d.ts.map +1 -1
- package/dist/tools/builtin/ai/index.js +3 -5
- package/dist/tools/builtin/ai/index.js.map +1 -1
- package/dist/tools/builtin/index.d.ts +2 -0
- package/dist/tools/builtin/index.d.ts.map +1 -1
- package/dist/tools/builtin/index.js +2 -0
- package/dist/tools/builtin/index.js.map +1 -1
- package/dist/tools/builtin/nft/BaseNftMessageTool.d.ts +35 -0
- package/dist/tools/builtin/nft/BaseNftMessageTool.d.ts.map +1 -0
- package/dist/tools/builtin/nft/BaseNftMessageTool.js +45 -0
- package/dist/tools/builtin/nft/BaseNftMessageTool.js.map +1 -0
- package/dist/tools/builtin/nft/NFTContractInfoTool.d.ts +7 -13
- package/dist/tools/builtin/nft/NFTContractInfoTool.d.ts.map +1 -1
- package/dist/tools/builtin/nft/NFTContractInfoTool.js +8 -43
- package/dist/tools/builtin/nft/NFTContractInfoTool.js.map +1 -1
- package/dist/tools/builtin/nft/NFTMetadataTool.d.ts +7 -113
- package/dist/tools/builtin/nft/NFTMetadataTool.d.ts.map +1 -1
- package/dist/tools/builtin/nft/NFTMetadataTool.js +9 -148
- package/dist/tools/builtin/nft/NFTMetadataTool.js.map +1 -1
- package/dist/tools/builtin/nft/SendNftTool.d.ts +14 -0
- package/dist/tools/builtin/nft/SendNftTool.d.ts.map +1 -0
- package/dist/tools/builtin/nft/SendNftTool.js +20 -0
- package/dist/tools/builtin/nft/SendNftTool.js.map +1 -0
- package/dist/tools/builtin/nft/WalletNFTsTool.d.ts +7 -74
- package/dist/tools/builtin/nft/WalletNFTsTool.d.ts.map +1 -1
- package/dist/tools/builtin/nft/WalletNFTsTool.js +9 -161
- package/dist/tools/builtin/nft/WalletNFTsTool.js.map +1 -1
- package/dist/tools/builtin/pool/EstimatePoolYieldTool.d.ts.map +1 -1
- package/dist/tools/builtin/pool/EstimatePoolYieldTool.js +4 -3
- package/dist/tools/builtin/pool/EstimatePoolYieldTool.js.map +1 -1
- package/dist/tools/builtin/pool/OpenAddLiquidityFormTool.d.ts +1 -0
- package/dist/tools/builtin/pool/OpenAddLiquidityFormTool.d.ts.map +1 -1
- package/dist/tools/builtin/pool/OpenAddLiquidityFormTool.js +8 -5
- package/dist/tools/builtin/pool/OpenAddLiquidityFormTool.js.map +1 -1
- package/dist/tools/builtin/pool/PoolByAddressTool.d.ts.map +1 -1
- package/dist/tools/builtin/pool/PoolByAddressTool.js +4 -3
- package/dist/tools/builtin/pool/PoolByAddressTool.js.map +1 -1
- package/dist/tools/builtin/pool/PoolDetailTool.d.ts.map +1 -1
- package/dist/tools/builtin/pool/PoolDetailTool.js +4 -3
- package/dist/tools/builtin/pool/PoolDetailTool.js.map +1 -1
- package/dist/tools/builtin/pool/PoolSearchTool.d.ts.map +1 -1
- package/dist/tools/builtin/pool/PoolSearchTool.js +4 -3
- package/dist/tools/builtin/pool/PoolSearchTool.js.map +1 -1
- package/dist/tools/builtin/pool/PreviewAddLiquidityTool.d.ts +1 -0
- package/dist/tools/builtin/pool/PreviewAddLiquidityTool.d.ts.map +1 -1
- package/dist/tools/builtin/pool/PreviewAddLiquidityTool.js +5 -3
- package/dist/tools/builtin/pool/PreviewAddLiquidityTool.js.map +1 -1
- package/dist/tools/builtin/pool/TopPoolsTool.d.ts.map +1 -1
- package/dist/tools/builtin/pool/TopPoolsTool.js +4 -3
- package/dist/tools/builtin/pool/TopPoolsTool.js.map +1 -1
- package/dist/tools/builtin/pool-subgraph/SubgraphCoinPoolPairsTool.d.ts +54 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphCoinPoolPairsTool.d.ts.map +1 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphCoinPoolPairsTool.js +98 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphCoinPoolPairsTool.js.map +1 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphPoolByAddressTool.d.ts +63 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphPoolByAddressTool.d.ts.map +1 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphPoolByAddressTool.js +82 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphPoolByAddressTool.js.map +1 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphPoolByPositionIdTool.d.ts +79 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphPoolByPositionIdTool.d.ts.map +1 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphPoolByPositionIdTool.js +97 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphPoolByPositionIdTool.js.map +1 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphPoolSearchTool.d.ts +77 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphPoolSearchTool.d.ts.map +1 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphPoolSearchTool.js +190 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphPoolSearchTool.js.map +1 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphPositionDetailTool.d.ts +107 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphPositionDetailTool.d.ts.map +1 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphPositionDetailTool.js +92 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphPositionDetailTool.js.map +1 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphTrendingPoolsTool.d.ts +56 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphTrendingPoolsTool.d.ts.map +1 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphTrendingPoolsTool.js +94 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphTrendingPoolsTool.js.map +1 -0
- package/dist/tools/builtin/pool-subgraph/index.d.ts +13 -0
- package/dist/tools/builtin/pool-subgraph/index.d.ts.map +1 -0
- package/dist/tools/builtin/pool-subgraph/index.js +18 -0
- package/dist/tools/builtin/pool-subgraph/index.js.map +1 -0
- package/dist/tools/builtin/token/TokenAnalyticsTool.d.ts.map +1 -1
- package/dist/tools/builtin/token/TokenAnalyticsTool.js +4 -3
- package/dist/tools/builtin/token/TokenAnalyticsTool.js.map +1 -1
- package/dist/tools/builtin/token/TokenHoldersTool.d.ts.map +1 -1
- package/dist/tools/builtin/token/TokenHoldersTool.js +4 -3
- package/dist/tools/builtin/token/TokenHoldersTool.js.map +1 -1
- package/dist/tools/builtin/token/TokenInfoTool.d.ts +6 -2
- package/dist/tools/builtin/token/TokenInfoTool.d.ts.map +1 -1
- package/dist/tools/builtin/token/TokenInfoTool.js +66 -8
- package/dist/tools/builtin/token/TokenInfoTool.js.map +1 -1
- package/dist/tools/builtin/token/TokenScoreTool.d.ts.map +1 -1
- package/dist/tools/builtin/token/TokenScoreTool.js +4 -3
- package/dist/tools/builtin/token/TokenScoreTool.js.map +1 -1
- package/dist/tools/builtin/token/TopGainersTool.d.ts +10 -19
- package/dist/tools/builtin/token/TopGainersTool.d.ts.map +1 -1
- package/dist/tools/builtin/token/TopGainersTool.js +44 -54
- package/dist/tools/builtin/token/TopGainersTool.js.map +1 -1
- package/dist/tools/builtin/token/TopLosersTool.d.ts.map +1 -1
- package/dist/tools/builtin/token/TopLosersTool.js +3 -2
- package/dist/tools/builtin/token/TopLosersTool.js.map +1 -1
- package/dist/tools/builtin/token/TrendingTokensTool.d.ts +1 -1
- package/dist/tools/builtin/token/TrendingTokensTool.d.ts.map +1 -1
- package/dist/tools/builtin/token/TrendingTokensTool.js +20 -12
- package/dist/tools/builtin/token/TrendingTokensTool.js.map +1 -1
- package/dist/tools/builtin/token/index.d.ts +0 -2
- package/dist/tools/builtin/token/index.d.ts.map +1 -1
- package/dist/tools/builtin/token/index.js +1 -3
- package/dist/tools/builtin/token/index.js.map +1 -1
- package/dist/tools/builtin/wallet/TransactionByHashTool.d.ts.map +1 -1
- package/dist/tools/builtin/wallet/TransactionByHashTool.js +4 -3
- package/dist/tools/builtin/wallet/TransactionByHashTool.js.map +1 -1
- package/dist/tools/builtin/wallet/WalletApprovalsTool.d.ts.map +1 -1
- package/dist/tools/builtin/wallet/WalletApprovalsTool.js +4 -3
- package/dist/tools/builtin/wallet/WalletApprovalsTool.js.map +1 -1
- package/dist/tools/builtin/wallet/WalletDefiPositionsTool.d.ts.map +1 -1
- package/dist/tools/builtin/wallet/WalletDefiPositionsTool.js +4 -3
- package/dist/tools/builtin/wallet/WalletDefiPositionsTool.js.map +1 -1
- package/dist/tools/builtin/wallet/WalletDefiProtocolPositionsTool.d.ts.map +1 -1
- package/dist/tools/builtin/wallet/WalletDefiProtocolPositionsTool.js +4 -3
- package/dist/tools/builtin/wallet/WalletDefiProtocolPositionsTool.js.map +1 -1
- package/dist/tools/builtin/wallet/WalletDefiSummaryTool.d.ts.map +1 -1
- package/dist/tools/builtin/wallet/WalletDefiSummaryTool.js +4 -3
- package/dist/tools/builtin/wallet/WalletDefiSummaryTool.js.map +1 -1
- package/dist/tools/builtin/wallet/WalletHistoryTool.d.ts.map +1 -1
- package/dist/tools/builtin/wallet/WalletHistoryTool.js +5 -4
- package/dist/tools/builtin/wallet/WalletHistoryTool.js.map +1 -1
- package/dist/tools/builtin/wallet/WalletNetWorthTool.js +1 -1
- package/dist/tools/builtin/wallet/WalletNetWorthTool.js.map +1 -1
- package/dist/tools/builtin/wallet/WalletNftTransfersTool.d.ts.map +1 -1
- package/dist/tools/builtin/wallet/WalletNftTransfersTool.js +5 -4
- package/dist/tools/builtin/wallet/WalletNftTransfersTool.js.map +1 -1
- package/dist/tools/builtin/wallet/WalletPnlSummaryTool.d.ts.map +1 -1
- package/dist/tools/builtin/wallet/WalletPnlSummaryTool.js +4 -3
- package/dist/tools/builtin/wallet/WalletPnlSummaryTool.js.map +1 -1
- package/dist/tools/builtin/wallet/WalletPnlTool.d.ts.map +1 -1
- package/dist/tools/builtin/wallet/WalletPnlTool.js +4 -3
- package/dist/tools/builtin/wallet/WalletPnlTool.js.map +1 -1
- package/dist/tools/builtin/wallet/WalletTokenBalancesTool.d.ts.map +1 -1
- package/dist/tools/builtin/wallet/WalletTokenBalancesTool.js +4 -3
- package/dist/tools/builtin/wallet/WalletTokenBalancesTool.js.map +1 -1
- package/dist/tools/builtin/wallet/WalletTokenTransfersTool.d.ts.map +1 -1
- package/dist/tools/builtin/wallet/WalletTokenTransfersTool.js +5 -4
- package/dist/tools/builtin/wallet/WalletTokenTransfersTool.js.map +1 -1
- package/dist/tools/builtin/wallet/index.d.ts +3 -0
- package/dist/tools/builtin/wallet/index.d.ts.map +1 -1
- package/dist/tools/builtin/wallet/index.js +5 -1
- package/dist/tools/builtin/wallet/index.js.map +1 -1
- package/dist/tools/builtin/wallet-action/ApproveTokenTool.d.ts +25 -0
- package/dist/tools/builtin/wallet-action/ApproveTokenTool.d.ts.map +1 -0
- package/dist/tools/builtin/wallet-action/ApproveTokenTool.js +98 -0
- package/dist/tools/builtin/wallet-action/ApproveTokenTool.js.map +1 -0
- package/dist/tools/builtin/wallet-action/BaseWalletActionTool.d.ts +211 -0
- package/dist/tools/builtin/wallet-action/BaseWalletActionTool.d.ts.map +1 -0
- package/dist/tools/builtin/wallet-action/BaseWalletActionTool.js +499 -0
- package/dist/tools/builtin/wallet-action/BaseWalletActionTool.js.map +1 -0
- package/dist/tools/builtin/wallet-action/BuyTokenTool.d.ts +240 -0
- package/dist/tools/builtin/wallet-action/BuyTokenTool.d.ts.map +1 -0
- package/dist/tools/builtin/wallet-action/BuyTokenTool.js +1257 -0
- package/dist/tools/builtin/wallet-action/BuyTokenTool.js.map +1 -0
- package/dist/tools/builtin/wallet-action/SendNativeTool.d.ts +41 -0
- package/dist/tools/builtin/wallet-action/SendNativeTool.d.ts.map +1 -0
- package/dist/tools/builtin/wallet-action/SendNativeTool.js +127 -0
- package/dist/tools/builtin/wallet-action/SendNativeTool.js.map +1 -0
- package/dist/tools/builtin/wallet-action/SendTokenTool.d.ts +63 -0
- package/dist/tools/builtin/wallet-action/SendTokenTool.d.ts.map +1 -0
- package/dist/tools/builtin/wallet-action/SendTokenTool.js +294 -0
- package/dist/tools/builtin/wallet-action/SendTokenTool.js.map +1 -0
- package/dist/tools/builtin/wallet-action/SwapTokenTool.d.ts +247 -0
- package/dist/tools/builtin/wallet-action/SwapTokenTool.d.ts.map +1 -0
- package/dist/tools/builtin/wallet-action/SwapTokenTool.js +1258 -0
- package/dist/tools/builtin/wallet-action/SwapTokenTool.js.map +1 -0
- package/dist/tools/builtin/wallet-action/UnwrapNativeTool.d.ts +20 -0
- package/dist/tools/builtin/wallet-action/UnwrapNativeTool.d.ts.map +1 -0
- package/dist/tools/builtin/wallet-action/UnwrapNativeTool.js +36 -0
- package/dist/tools/builtin/wallet-action/UnwrapNativeTool.js.map +1 -0
- package/dist/tools/builtin/wallet-action/WrapNativeTool.d.ts +23 -0
- package/dist/tools/builtin/wallet-action/WrapNativeTool.d.ts.map +1 -0
- package/dist/tools/builtin/wallet-action/WrapNativeTool.js +54 -0
- package/dist/tools/builtin/wallet-action/WrapNativeTool.js.map +1 -0
- package/dist/tools/builtin/wallet-action/amountSpec.d.ts +62 -0
- package/dist/tools/builtin/wallet-action/amountSpec.d.ts.map +1 -0
- package/dist/tools/builtin/wallet-action/amountSpec.js +93 -0
- package/dist/tools/builtin/wallet-action/amountSpec.js.map +1 -0
- package/dist/tools/builtin/wallet-action/gasReserve.d.ts +42 -0
- package/dist/tools/builtin/wallet-action/gasReserve.d.ts.map +1 -0
- package/dist/tools/builtin/wallet-action/gasReserve.js +103 -0
- package/dist/tools/builtin/wallet-action/gasReserve.js.map +1 -0
- package/dist/tools/builtin/wallet-action/index.d.ts +9 -0
- package/dist/tools/builtin/wallet-action/index.d.ts.map +1 -0
- package/dist/tools/builtin/wallet-action/index.js +20 -0
- package/dist/tools/builtin/wallet-action/index.js.map +1 -0
- package/dist/tools/chainResolver.d.ts +98 -0
- package/dist/tools/chainResolver.d.ts.map +1 -0
- package/dist/tools/chainResolver.js +302 -0
- package/dist/tools/chainResolver.js.map +1 -0
- package/dist/types/index.d.ts +218 -7
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +7 -3
- package/dist/tools/builtin/ai/MoralisCortexTool.d.ts +0 -33
- package/dist/tools/builtin/ai/MoralisCortexTool.d.ts.map +0 -1
- package/dist/tools/builtin/ai/MoralisCortexTool.js +0 -76
- package/dist/tools/builtin/ai/MoralisCortexTool.js.map +0 -1
- package/dist/tools/builtin/ai/SolanaCortexTool.d.ts +0 -22
- package/dist/tools/builtin/ai/SolanaCortexTool.d.ts.map +0 -1
- package/dist/tools/builtin/ai/SolanaCortexTool.js +0 -80
- package/dist/tools/builtin/ai/SolanaCortexTool.js.map +0 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared JSON-RPC client + default public RPC endpoints.
|
|
3
|
+
*
|
|
4
|
+
* Kept dependency-free (no imports from PoolService / swap) so both
|
|
5
|
+
* `PoolService` and the swap adapters can use it without a circular import.
|
|
6
|
+
*/
|
|
7
|
+
/** Default public RPC endpoint per hex chain id. Single source of truth. */
|
|
8
|
+
export declare const DEFAULT_RPC_BY_CHAIN: Record<string, string>;
|
|
9
|
+
/** Resolve a hex chain id to its default RPC URL, or undefined if unsupported. */
|
|
10
|
+
export declare function getDefaultRpcUrl(chainId: string): string | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Install the shared RPC overrides for the whole core. Replaces any previous
|
|
13
|
+
* set. Keys are normalised to lowercase hex chain ids; blank/non-string values
|
|
14
|
+
* are ignored so a partial map only overrides the chains it actually names.
|
|
15
|
+
* Called once by AgentCore from `AgentConfig.rpcUrls`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function setRpcOverrides(overrides?: Record<string, string>): void;
|
|
18
|
+
/**
|
|
19
|
+
* Resolve a hex chain id to its RPC URL: the caller-supplied override (see
|
|
20
|
+
* {@link setRpcOverrides}) if present, else the built-in public default.
|
|
21
|
+
* Returns undefined only when the chain is both un-overridden and unsupported.
|
|
22
|
+
*/
|
|
23
|
+
export declare function resolveRpcUrl(chainId: string): string | undefined;
|
|
24
|
+
/** Low-level JSON-RPC call with 429 backoff (5 retries, exponential). */
|
|
25
|
+
export declare function rpcCall<T>(rpcUrl: string, method: string, params: unknown[]): Promise<T>;
|
|
26
|
+
/** `eth_call` against an explicit RPC URL. `data` is the encoded calldata. */
|
|
27
|
+
export declare function ethCallAt(rpcUrl: string, to: string, data: string): Promise<string>;
|
|
28
|
+
/**
|
|
29
|
+
* `eth_call` resolving the RPC URL from the hex chain id, honouring any shared
|
|
30
|
+
* overrides (see {@link setRpcOverrides}) before falling back to the default
|
|
31
|
+
* endpoint. Returns `null` when the chain has no known RPC or the call fails —
|
|
32
|
+
* callers that need to distinguish errors should use {@link ethCallAt} directly.
|
|
33
|
+
*/
|
|
34
|
+
export declare function ethCallByChain(chainId: string, to: string, data: string): Promise<string | null>;
|
|
35
|
+
//# sourceMappingURL=rpc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc.d.ts","sourceRoot":"","sources":["../../src/services/rpc.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,4EAA4E;AAC5E,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CASvD,CAAC;AAEF,kFAAkF;AAClF,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEpE;AAWD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAUxE;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGjE;AASD,yEAAyE;AACzE,wBAAsB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAmB9F;AAED,8EAA8E;AAC9E,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAEnF;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAQtG"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Shared JSON-RPC client + default public RPC endpoints.
|
|
4
|
+
*
|
|
5
|
+
* Kept dependency-free (no imports from PoolService / swap) so both
|
|
6
|
+
* `PoolService` and the swap adapters can use it without a circular import.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.DEFAULT_RPC_BY_CHAIN = void 0;
|
|
10
|
+
exports.getDefaultRpcUrl = getDefaultRpcUrl;
|
|
11
|
+
exports.setRpcOverrides = setRpcOverrides;
|
|
12
|
+
exports.resolveRpcUrl = resolveRpcUrl;
|
|
13
|
+
exports.rpcCall = rpcCall;
|
|
14
|
+
exports.ethCallAt = ethCallAt;
|
|
15
|
+
exports.ethCallByChain = ethCallByChain;
|
|
16
|
+
/** Default public RPC endpoint per hex chain id. Single source of truth. */
|
|
17
|
+
exports.DEFAULT_RPC_BY_CHAIN = {
|
|
18
|
+
'0x1': 'https://ethereum-rpc.publicnode.com',
|
|
19
|
+
'0xa': 'https://mainnet.optimism.io',
|
|
20
|
+
'0x38': 'https://bsc-dataseed.binance.org',
|
|
21
|
+
'0x89': 'https://polygon-bor-rpc.publicnode.com"',
|
|
22
|
+
'0x2105': 'https://mainnet.base.org',
|
|
23
|
+
'0xa4b1': 'https://arb1.arbitrum.io/rpc',
|
|
24
|
+
'0xa86a': 'https://avalanche-c-chain-rpc.publicnode.com',
|
|
25
|
+
'0xe708': 'https://rpc.linea.build',
|
|
26
|
+
};
|
|
27
|
+
/** Resolve a hex chain id to its default RPC URL, or undefined if unsupported. */
|
|
28
|
+
function getDefaultRpcUrl(chainId) {
|
|
29
|
+
return exports.DEFAULT_RPC_BY_CHAIN[chainId.toLowerCase()];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Caller-supplied RPC overrides, keyed by lowercase hex chain id. Shared by the
|
|
33
|
+
* whole core (gas-reserve reads, swap allowance checks, PoolService) so a single
|
|
34
|
+
* `AgentConfig.rpcUrls` controls every on-chain read. Empty by default — when a
|
|
35
|
+
* chain is not overridden, {@link resolveRpcUrl} falls back to
|
|
36
|
+
* {@link DEFAULT_RPC_BY_CHAIN}.
|
|
37
|
+
*/
|
|
38
|
+
let RPC_OVERRIDES = {};
|
|
39
|
+
/**
|
|
40
|
+
* Install the shared RPC overrides for the whole core. Replaces any previous
|
|
41
|
+
* set. Keys are normalised to lowercase hex chain ids; blank/non-string values
|
|
42
|
+
* are ignored so a partial map only overrides the chains it actually names.
|
|
43
|
+
* Called once by AgentCore from `AgentConfig.rpcUrls`.
|
|
44
|
+
*/
|
|
45
|
+
function setRpcOverrides(overrides) {
|
|
46
|
+
const next = {};
|
|
47
|
+
if (overrides) {
|
|
48
|
+
for (const [chainId, url] of Object.entries(overrides)) {
|
|
49
|
+
if (typeof url === 'string' && url.trim()) {
|
|
50
|
+
next[chainId.toLowerCase()] = url.trim();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
RPC_OVERRIDES = next;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Resolve a hex chain id to its RPC URL: the caller-supplied override (see
|
|
58
|
+
* {@link setRpcOverrides}) if present, else the built-in public default.
|
|
59
|
+
* Returns undefined only when the chain is both un-overridden and unsupported.
|
|
60
|
+
*/
|
|
61
|
+
function resolveRpcUrl(chainId) {
|
|
62
|
+
const key = chainId.toLowerCase();
|
|
63
|
+
return RPC_OVERRIDES[key] ?? exports.DEFAULT_RPC_BY_CHAIN[key];
|
|
64
|
+
}
|
|
65
|
+
/** Low-level JSON-RPC call with 429 backoff (5 retries, exponential). */
|
|
66
|
+
async function rpcCall(rpcUrl, method, params) {
|
|
67
|
+
const maxRetries = 5;
|
|
68
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
69
|
+
const res = await fetch(rpcUrl, {
|
|
70
|
+
method: 'POST',
|
|
71
|
+
headers: { 'Content-Type': 'application/json' },
|
|
72
|
+
body: JSON.stringify({ jsonrpc: '2.0', id: Date.now(), method, params }),
|
|
73
|
+
});
|
|
74
|
+
if (res.status === 429 && attempt < maxRetries) {
|
|
75
|
+
await new Promise((r) => setTimeout(r, 2 ** attempt * 500));
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
if (!res.ok)
|
|
79
|
+
throw new Error(`RPC ${method} HTTP ${res.status}`);
|
|
80
|
+
const json = (await res.json());
|
|
81
|
+
if (json.error)
|
|
82
|
+
throw new Error(`RPC ${method}: ${json.error.message}`);
|
|
83
|
+
if (json.result === undefined)
|
|
84
|
+
throw new Error(`RPC ${method}: empty result`);
|
|
85
|
+
return json.result;
|
|
86
|
+
}
|
|
87
|
+
throw new Error(`RPC ${method}: exceeded max retries (429)`);
|
|
88
|
+
}
|
|
89
|
+
/** `eth_call` against an explicit RPC URL. `data` is the encoded calldata. */
|
|
90
|
+
function ethCallAt(rpcUrl, to, data) {
|
|
91
|
+
return rpcCall(rpcUrl, 'eth_call', [{ to, data }, 'latest']);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* `eth_call` resolving the RPC URL from the hex chain id, honouring any shared
|
|
95
|
+
* overrides (see {@link setRpcOverrides}) before falling back to the default
|
|
96
|
+
* endpoint. Returns `null` when the chain has no known RPC or the call fails —
|
|
97
|
+
* callers that need to distinguish errors should use {@link ethCallAt} directly.
|
|
98
|
+
*/
|
|
99
|
+
async function ethCallByChain(chainId, to, data) {
|
|
100
|
+
const rpcUrl = resolveRpcUrl(chainId);
|
|
101
|
+
if (!rpcUrl)
|
|
102
|
+
return null;
|
|
103
|
+
try {
|
|
104
|
+
return await ethCallAt(rpcUrl, to, data);
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=rpc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc.js","sourceRoot":"","sources":["../../src/services/rpc.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAeH,4CAEC;AAiBD,0CAUC;AAOD,sCAGC;AAUD,0BAmBC;AAGD,8BAEC;AAQD,wCAQC;AAtGD,4EAA4E;AAC/D,QAAA,oBAAoB,GAA2B;IAC1D,KAAK,EAAE,qCAAqC;IAC5C,KAAK,EAAE,6BAA6B;IACpC,MAAM,EAAE,kCAAkC;IAC1C,MAAM,EAAE,yCAAyC;IACjD,QAAQ,EAAE,0BAA0B;IACpC,QAA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AAM,MAAM,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IACtC,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACzB,IAAI,CAAC;QACH,OAAO,MAAM,SAAS,CAAC,MAAM,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;IAC3C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -12,7 +12,24 @@ export declare class DebridgeAdapter extends BaseSwapService {
|
|
|
12
12
|
getProviderName(): ProviderName;
|
|
13
13
|
hasIntegratedApproval(): boolean;
|
|
14
14
|
getQuote(params: SwapQuoteParams): Promise<SwapQuoteResult>;
|
|
15
|
+
/**
|
|
16
|
+
* deBridge does NOT bundle approval, so the pay token must grant an allowance
|
|
17
|
+
* to the swap router — the `to` of the swap tx (`quoteData.tx.to`) — before the
|
|
18
|
+
* swap can run. Native coin needs no approval. For an ERC-20 we read the
|
|
19
|
+
* on-chain `allowance(userAddress, spender)` and only flag `isNeeded` when the
|
|
20
|
+
* current allowance is below `amount` (no redundant approve when already set).
|
|
21
|
+
*
|
|
22
|
+
* `amount` is the spend in the token's smallest units (wei-equivalent), the
|
|
23
|
+
* same value passed as `srcTokenAmount` to the quote.
|
|
24
|
+
*/
|
|
15
25
|
checkApproval(params: CheckApprovalParams): Promise<CheckApprovalResult>;
|
|
26
|
+
/**
|
|
27
|
+
* Read ERC-20 `allowance(owner, spender)` via the shared RPC client. Returns
|
|
28
|
+
* the allowance as a bigint, or `null` when the chain is unknown / the call
|
|
29
|
+
* fails / the result can't be parsed. Calldata is the `allowance` selector
|
|
30
|
+
* (`0xdd62ed3e`) + two 32-byte-padded addresses.
|
|
31
|
+
*/
|
|
32
|
+
private readAllowance;
|
|
16
33
|
executeSwap(params: ExecuteSwapParams): Promise<ExecuteSwapResult>;
|
|
17
34
|
trackTransaction(params: TrackTransactionParams): Promise<TrackTransactionResult>;
|
|
18
35
|
private get;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DebridgeAdapter.d.ts","sourceRoot":"","sources":["../../../src/services/swap/DebridgeAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"DebridgeAdapter.d.ts","sourceRoot":"","sources":["../../../src/services/swap/DebridgeAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,sBAAsB,EACtB,sBAAsB,EACvB,MAAM,SAAS,CAAC;AAMjB;;;;GAIG;AACH,qBAAa,eAAgB,SAAQ,eAAe;IAClD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;gBAEzB,MAAM,GAAE,iBAAsB;IAM1C,eAAe,IAAI,YAAY;IAI/B,qBAAqB,IAAI,OAAO;IAI1B,QAAQ,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;IAmGjE;;;;;;;;;OASG;IACG,aAAa,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAwD9E;;;;;OAKG;YACW,aAAa;IAoBrB,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAUlE,gBAAgB,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,sBAAsB,CAAC;YAuCzE,GAAG;CAWlB"}
|
|
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DebridgeAdapter = void 0;
|
|
4
4
|
const BaseSwapService_1 = require("./BaseSwapService");
|
|
5
5
|
const affiliate_1 = require("./affiliate");
|
|
6
|
+
const rpc_1 = require("../rpc");
|
|
6
7
|
const DEFAULT_BASE_URL = 'https://dln.debridge.finance/v1.0';
|
|
8
|
+
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
|
|
7
9
|
/**
|
|
8
10
|
* deBridge DLN adapter. Same-chain swap uses /chain/transaction; cross-chain
|
|
9
11
|
* uses /dln/order/create-tx. Approval is NOT integrated — caller must check
|
|
@@ -103,20 +105,86 @@ class DebridgeAdapter extends BaseSwapService_1.BaseSwapService {
|
|
|
103
105
|
};
|
|
104
106
|
}
|
|
105
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* deBridge does NOT bundle approval, so the pay token must grant an allowance
|
|
110
|
+
* to the swap router — the `to` of the swap tx (`quoteData.tx.to`) — before the
|
|
111
|
+
* swap can run. Native coin needs no approval. For an ERC-20 we read the
|
|
112
|
+
* on-chain `allowance(userAddress, spender)` and only flag `isNeeded` when the
|
|
113
|
+
* current allowance is below `amount` (no redundant approve when already set).
|
|
114
|
+
*
|
|
115
|
+
* `amount` is the spend in the token's smallest units (wei-equivalent), the
|
|
116
|
+
* same value passed as `srcTokenAmount` to the quote.
|
|
117
|
+
*/
|
|
106
118
|
async checkApproval(params) {
|
|
107
|
-
const
|
|
108
|
-
|
|
119
|
+
const { chain, userAddress, tokenAddress, amount } = params;
|
|
120
|
+
const spender = params.quoteData?.tx?.to;
|
|
121
|
+
if (!spender) {
|
|
109
122
|
return { isNeeded: false, error: 'No contract address found in quote' };
|
|
110
123
|
}
|
|
111
|
-
//
|
|
112
|
-
|
|
124
|
+
// Native coin (zero-address sentinel) is never an ERC-20 — no approval.
|
|
125
|
+
if (!tokenAddress || tokenAddress.toLowerCase() === ZERO_ADDRESS) {
|
|
126
|
+
return {
|
|
127
|
+
isNeeded: false,
|
|
128
|
+
integrated: false,
|
|
129
|
+
contractAddress: spender,
|
|
130
|
+
message: 'Native coin needs no approval.',
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
// Read the on-chain allowance(owner, spender) for the pay token.
|
|
134
|
+
const allowance = await this.readAllowance(chain, tokenAddress, userAddress, spender);
|
|
135
|
+
// Couldn't read it — err on the safe side and require approval so the swap
|
|
136
|
+
// doesn't revert. The caller approves `amount` to `spender` on `tokenAddress`.
|
|
137
|
+
if (allowance === null) {
|
|
138
|
+
return {
|
|
139
|
+
isNeeded: true,
|
|
140
|
+
integrated: false,
|
|
141
|
+
contractAddress: spender,
|
|
142
|
+
message: 'Could not read allowance; approval required before the swap.',
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
let need;
|
|
146
|
+
try {
|
|
147
|
+
need = BigInt(amount);
|
|
148
|
+
}
|
|
149
|
+
catch {
|
|
150
|
+
need = 0n;
|
|
151
|
+
}
|
|
152
|
+
if (allowance >= need) {
|
|
153
|
+
return {
|
|
154
|
+
isNeeded: false,
|
|
155
|
+
integrated: false,
|
|
156
|
+
contractAddress: spender,
|
|
157
|
+
message: 'Sufficient allowance already granted.',
|
|
158
|
+
};
|
|
159
|
+
}
|
|
113
160
|
return {
|
|
114
161
|
isNeeded: true,
|
|
115
162
|
integrated: false,
|
|
116
|
-
contractAddress,
|
|
117
|
-
message: '
|
|
163
|
+
contractAddress: spender,
|
|
164
|
+
message: 'Approval required: current allowance is below the swap amount.',
|
|
118
165
|
};
|
|
119
166
|
}
|
|
167
|
+
/**
|
|
168
|
+
* Read ERC-20 `allowance(owner, spender)` via the shared RPC client. Returns
|
|
169
|
+
* the allowance as a bigint, or `null` when the chain is unknown / the call
|
|
170
|
+
* fails / the result can't be parsed. Calldata is the `allowance` selector
|
|
171
|
+
* (`0xdd62ed3e`) + two 32-byte-padded addresses.
|
|
172
|
+
*/
|
|
173
|
+
async readAllowance(chain, tokenAddress, owner, spender) {
|
|
174
|
+
if (!chain)
|
|
175
|
+
return null;
|
|
176
|
+
const pad = (addr) => addr.toLowerCase().replace(/^0x/, '').padStart(64, '0');
|
|
177
|
+
const data = `0xdd62ed3e${pad(owner)}${pad(spender)}`;
|
|
178
|
+
const hex = await (0, rpc_1.ethCallByChain)(chain, tokenAddress, data);
|
|
179
|
+
if (typeof hex !== 'string' || !/^0x[0-9a-fA-F]*$/.test(hex) || hex === '0x')
|
|
180
|
+
return null;
|
|
181
|
+
try {
|
|
182
|
+
return BigInt(hex);
|
|
183
|
+
}
|
|
184
|
+
catch {
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
120
188
|
async executeSwap(params) {
|
|
121
189
|
const { quoteData } = params;
|
|
122
190
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DebridgeAdapter.js","sourceRoot":"","sources":["../../../src/services/swap/DebridgeAdapter.ts"],"names":[],"mappings":";;;AAAA,uDAAoD;AACpD,2CAA8C;
|
|
1
|
+
{"version":3,"file":"DebridgeAdapter.js","sourceRoot":"","sources":["../../../src/services/swap/DebridgeAdapter.ts"],"names":[],"mappings":";;;AAAA,uDAAoD;AACpD,2CAA8C;AAC9C,gCAAwC;AAcxC,MAAM,gBAAgB,GAAG,mCAAmC,CAAC;AAE7D,MAAM,YAAY,GAAG,4CAA4C,CAAC;AAElE;;;;GAIG;AACH,MAAa,eAAgB,SAAQ,iCAAe;IACjC,UAAU,CAAS;IACnB,WAAW,CAAS;IAErC,YAAY,SAA4B,EAAE;QACxC,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,IAAI,gBAAgB,CAAC;QACxD,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,IAAI,cAAc,CAAC;IAC1D,CAAC;IAED,eAAe;QACb,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,qBAAqB;QACnB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,MAAuB;QACpC,MAAM,EACJ,UAAU,EACV,eAAe,EACf,cAAc,EACd,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,QAAQ,EACR,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C;YACf,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,MAAM,EAAE,OAAO;gBACf,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;aAC9D,CAAC;QACJ,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,GAAG,CAAI,GAAW,EAAE,KAAsC;QACtE,MAAM,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;aAC7B,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,IAAI,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;aAC5E,IAAI,CAAC,GAAG,CAAC,CAAC;QACb,MAAM,OAAO,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;QAC1C,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,OAAO,EAAE;YAC/B,MAAM,EAAE,KAAK;YACb,OAAO,EAAE,EAAE,MAAM,EAAE,kBAAkB,EAAE;SACxC,CAAC,CAAC;QACH,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAM,CAAC;IACjC,CAAC;CACF;AA7QD,0CA6QC"}
|
|
@@ -13,6 +13,7 @@ export declare class SwapServiceFactory {
|
|
|
13
13
|
private readonly cache;
|
|
14
14
|
constructor(providerConfig?: ExchangeProviderConfig, isProduction?: boolean);
|
|
15
15
|
getService(srcChainId?: number | string | null): Promise<BaseSwapService>;
|
|
16
|
+
getServiceByProvider(provider: ProviderName): Promise<BaseSwapService>;
|
|
16
17
|
getActiveProvider(srcChainId?: number | string | null): Promise<ProviderName>;
|
|
17
18
|
isProviderActive(name: ProviderName, srcChainId?: number | string | null): Promise<boolean>;
|
|
18
19
|
getAvailableProviders(): ProviderName[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SwapServiceFactory.d.ts","sourceRoot":"","sources":["../../../src/services/swap/SwapServiceFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAKzD,OAAO,KAAK,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"SwapServiceFactory.d.ts","sourceRoot":"","sources":["../../../src/services/swap/SwapServiceFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAKzD,OAAO,KAAK,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAQpE;;;;;;GAMG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAyB;IACxD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAU;IACvC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA4C;gBAEtD,cAAc,GAAE,sBAA6C,EAAE,YAAY,UAAO;IAKxF,UAAU,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,eAAe,CAAC;IAUzE,oBAAoB,CAAC,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC,eAAe,CAAC;IAStE,iBAAiB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC;IAO7E,gBAAgB,CAAC,IAAI,EAAE,YAAY,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC;IAIjG,qBAAqB,IAAI,YAAY,EAAE;IAIvC,UAAU,IAAI,IAAI;IAIlB,OAAO,CAAC,aAAa;CAatB;AAED,yBAAyB;AACzB,eAAO,MAAM,kBAAkB,oBAA2B,CAAC"}
|
|
@@ -5,12 +5,9 @@ const DebridgeAdapter_1 = require("./DebridgeAdapter");
|
|
|
5
5
|
const RelayAdapter_1 = require("./RelayAdapter");
|
|
6
6
|
const affiliate_1 = require("./affiliate");
|
|
7
7
|
const config_1 = require("./config");
|
|
8
|
-
const SOLANA_CHAIN_ID = 7565164;
|
|
9
8
|
function normalizeChainId(chainId) {
|
|
10
9
|
if (chainId === null || chainId === undefined)
|
|
11
10
|
return null;
|
|
12
|
-
if (chainId === 'solana' || chainId === 'SOLANA')
|
|
13
|
-
return SOLANA_CHAIN_ID;
|
|
14
11
|
const n = typeof chainId === 'number' ? chainId : Number(chainId);
|
|
15
12
|
return Number.isFinite(n) ? n : null;
|
|
16
13
|
}
|
|
@@ -38,6 +35,14 @@ class SwapServiceFactory {
|
|
|
38
35
|
this.cache.set(provider, service);
|
|
39
36
|
return service;
|
|
40
37
|
}
|
|
38
|
+
async getServiceByProvider(provider) {
|
|
39
|
+
const cached = this.cache.get(provider);
|
|
40
|
+
if (cached)
|
|
41
|
+
return cached;
|
|
42
|
+
const service = this.createService(provider);
|
|
43
|
+
this.cache.set(provider, service);
|
|
44
|
+
return service;
|
|
45
|
+
}
|
|
41
46
|
async getActiveProvider(srcChainId) {
|
|
42
47
|
const src = normalizeChainId(srcChainId);
|
|
43
48
|
if (src === null)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SwapServiceFactory.js","sourceRoot":"","sources":["../../../src/services/swap/SwapServiceFactory.ts"],"names":[],"mappings":";;;AACA,uDAAoD;AACpD,iDAA8C;AAC9C,2CAAiD;AACjD,qCAAkE;AAGlE,
|
|
1
|
+
{"version":3,"file":"SwapServiceFactory.js","sourceRoot":"","sources":["../../../src/services/swap/SwapServiceFactory.ts"],"names":[],"mappings":";;;AACA,uDAAoD;AACpD,iDAA8C;AAC9C,2CAAiD;AACjD,qCAAkE;AAGlE,SAAS,gBAAgB,CAAC,OAA2C;IACnE,IAAI,OAAO,KAAK,IAAI,I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|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { BaseTool } from '../../BaseTool';
|
|
2
|
+
import type { LLMProviderConfig, ToolParameter, UserContext } from '../../../types';
|
|
3
|
+
export type GeminiSearchAiToolConfig = LLMProviderConfig;
|
|
4
|
+
/**
|
|
5
|
+
* Tool: gemini-search-ai
|
|
6
|
+
*
|
|
7
|
+
* Open-ended AI fallback for blockchain / crypto questions that none of the
|
|
8
|
+
* specialised data tools can answer. Backed by Gemini with the built-in
|
|
9
|
+
* `googleSearch` grounding tool, so answers reflect live web data (news,
|
|
10
|
+
* prices, recent on-chain events, protocol updates, etc.).
|
|
11
|
+
*
|
|
12
|
+
* This tool replaces the previous `moralis-cortex-ai` cortex tool. It is chain-agnostic — the caller
|
|
13
|
+
* embeds whatever context (chain id, wallet address, time window, token
|
|
14
|
+
* symbols) directly in `prompt`.
|
|
15
|
+
*
|
|
16
|
+
* Subagents wire this in as their `cortexFallbackTool` so the framework
|
|
17
|
+
* forces a tool call every turn even when no specialised tool matches.
|
|
18
|
+
*/
|
|
19
|
+
export declare class GeminiSearchAiTool extends BaseTool {
|
|
20
|
+
name: string;
|
|
21
|
+
description: string;
|
|
22
|
+
category: string;
|
|
23
|
+
parameters: ToolParameter[];
|
|
24
|
+
private llm;
|
|
25
|
+
constructor(config?: GeminiSearchAiToolConfig);
|
|
26
|
+
protected run(args: Record<string, unknown>, userContext?: UserContext): Promise<{
|
|
27
|
+
error: string;
|
|
28
|
+
source?: undefined;
|
|
29
|
+
answer?: undefined;
|
|
30
|
+
} | {
|
|
31
|
+
source: string;
|
|
32
|
+
answer: string;
|
|
33
|
+
error?: undefined;
|
|
34
|
+
}>;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=GeminiSearchAiTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GeminiSearchAiTool.d.ts","sourceRoot":"","sources":["../../../../src/tools/builtin/ai/GeminiSearchAiTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,KAAK,EAAe,iBAAiB,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEjG,MAAM,MAAM,wBAAwB,GAAG,iBAAiB,CAAC;AAEzD;;;;;;;;;;;;;;GAcG;AACH,qBAAa,kBAAmB,SAAQ,QAAQ;IAC9C,IAAI,SAAsB;IAC1B,WAAW,SAemC;IAC9C,QAAQ,SAAmB;IAC3B,UAAU,EAAE,aAAa,EAAE,CAczB;IAEF,OAAO,CAAC,GAAG,CAAiB;gBAEhB,MAAM,CAAC,EAAE,wBAAwB;cAK7B,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,CAAC,EAAE,WAAW;;;;;;;;;CAiC7E"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GeminiSearchAiTool = void 0;
|
|
4
|
+
const BaseTool_1 = require("../../BaseTool");
|
|
5
|
+
const GeminiProvider_1 = require("../../../llm/GeminiProvider");
|
|
6
|
+
/**
|
|
7
|
+
* Tool: gemini-search-ai
|
|
8
|
+
*
|
|
9
|
+
* Open-ended AI fallback for blockchain / crypto questions that none of the
|
|
10
|
+
* specialised data tools can answer. Backed by Gemini with the built-in
|
|
11
|
+
* `googleSearch` grounding tool, so answers reflect live web data (news,
|
|
12
|
+
* prices, recent on-chain events, protocol updates, etc.).
|
|
13
|
+
*
|
|
14
|
+
* This tool replaces the previous `moralis-cortex-ai` cortex tool. It is chain-agnostic — the caller
|
|
15
|
+
* embeds whatever context (chain id, wallet address, time window, token
|
|
16
|
+
* symbols) directly in `prompt`.
|
|
17
|
+
*
|
|
18
|
+
* Subagents wire this in as their `cortexFallbackTool` so the framework
|
|
19
|
+
* forces a tool call every turn even when no specialised tool matches.
|
|
20
|
+
*/
|
|
21
|
+
class GeminiSearchAiTool extends BaseTool_1.BaseTool {
|
|
22
|
+
name = 'gemini-search-ai';
|
|
23
|
+
description = 'Ask a search-grounded Gemini model for blockchain / crypto insights that no dedicated tool can answer. ' +
|
|
24
|
+
'Use this as a LAST-RESORT fallback when the specialised data tools are insufficient. ' +
|
|
25
|
+
'Backed by live Google Search grounding — good for: market analysis, category/theme queries ' +
|
|
26
|
+
'(meme, AI, gaming, L2, RWA), DeFi protocol explanations, cross-chain comparisons, trend / sentiment, ' +
|
|
27
|
+
'recent news or announcements, gas insights, NFT collection lore, and any open-ended crypto reasoning question. ' +
|
|
28
|
+
'Chain-agnostic — write the chain (Ethereum, BSC, Base, …) and any addresses, time range, or ' +
|
|
29
|
+
'token symbols directly into the prompt. ' +
|
|
30
|
+
'Do NOT use this for: ' +
|
|
31
|
+
'token balances → get-wallet-token-balances; ' +
|
|
32
|
+
'token prices/metadata → get-token-info; ' +
|
|
33
|
+
'NFT holdings → get-wallet-nfts; NFT contract info → get-nft-contract-info; ' +
|
|
34
|
+
'transaction details → get-transaction-by-hash; wallet history → get-wallet-history; ' +
|
|
35
|
+
'token transfers → get-wallet-token-transfers; NFT transfers → get-wallet-nft-transfers; ' +
|
|
36
|
+
'token holders → get-token-holders; wallet PnL → get-wallet-pnl or get-wallet-pnl-summary; ' +
|
|
37
|
+
'pool / liquidity data → pool-agent tools.';
|
|
38
|
+
category = 'blockchain-ai';
|
|
39
|
+
parameters = [
|
|
40
|
+
{
|
|
41
|
+
name: 'prompt',
|
|
42
|
+
type: 'string',
|
|
43
|
+
description: 'A clear, self-contained English question for the AI. ' +
|
|
44
|
+
'Must include every detail needed to answer without the conversation context: ' +
|
|
45
|
+
'chain (Ethereum / BSC / Base / …), wallet or contract addresses, token symbols, ' +
|
|
46
|
+
'time range, what to compare or rank. ' +
|
|
47
|
+
'Instruct the model to use up-to-date web sources when relevant. ' +
|
|
48
|
+
'Example: "List the top 10 meme-category tokens on Ethereum right now, ranked by 24h trading volume, ' +
|
|
49
|
+
'using up-to-date market data."',
|
|
50
|
+
required: true,
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
llm;
|
|
54
|
+
constructor(config) {
|
|
55
|
+
super();
|
|
56
|
+
this.llm = new GeminiProvider_1.GeminiProvider(config ?? {});
|
|
57
|
+
}
|
|
58
|
+
async run(args, userContext) {
|
|
59
|
+
const prompt = typeof args.prompt === 'string' ? args.prompt.trim() : '';
|
|
60
|
+
if (!prompt) {
|
|
61
|
+
return { error: 'Missing required parameter: prompt' };
|
|
62
|
+
}
|
|
63
|
+
// Embed connected-wallet / chain context as an explicit, clearly-labelled
|
|
64
|
+
// system message so the model does not confuse it with the question.
|
|
65
|
+
const contextLines = [];
|
|
66
|
+
if (userContext?.walletAddress) {
|
|
67
|
+
contextLines.push(`- Connected wallet address: ${userContext.walletAddress}`);
|
|
68
|
+
}
|
|
69
|
+
if (userContext?.chain) {
|
|
70
|
+
contextLines.push(`- Current chain: ${userContext.chain}`);
|
|
71
|
+
}
|
|
72
|
+
contextLines.push('Use this context only when relevant to the question. Do not invent on-chain values.');
|
|
73
|
+
const now = Date.now();
|
|
74
|
+
const messages = [
|
|
75
|
+
{ role: 'system', content: `[USER CONTEXT]\n${contextLines.join('\n')}`, timestamp: now },
|
|
76
|
+
{ role: 'user', content: prompt, timestamp: now },
|
|
77
|
+
];
|
|
78
|
+
try {
|
|
79
|
+
const res = await this.llm.chat(messages, undefined, { googleSearch: true, maxRetries: 1 });
|
|
80
|
+
return {
|
|
81
|
+
source: 'gemini-search-ai',
|
|
82
|
+
answer: res.text?.trim() ?? '',
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
return { error: err instanceof Error ? err.message : String(err) };
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.GeminiSearchAiTool = GeminiSearchAiTool;
|
|
91
|
+
//# sourceMappingURL=GeminiSearchAiTool.js.map
|
|
@@ -0,0 +1 @@
|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
|
|
3
|
-
export { SolanaCortexTool } from './SolanaCortexTool';
|
|
4
|
-
export type { SolanaCortexToolConfig } from './SolanaCortexTool';
|
|
1
|
+
export { GeminiSearchAiTool } from './GeminiSearchAiTool';
|
|
2
|
+
export type { GeminiSearchAiToolConfig } from './GeminiSearchAiTool';
|
|
5
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/tools/builtin/ai/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/tools/builtin/ai/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,YAAY,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
var
|
|
5
|
-
Object.defineProperty(exports, "
|
|
6
|
-
var SolanaCortexTool_1 = require("./SolanaCortexTool");
|
|
7
|
-
Object.defineProperty(exports, "SolanaCortexTool", { enumerable: true, get: function () { return SolanaCortexTool_1.SolanaCortexTool; } });
|
|
3
|
+
exports.GeminiSearchAiTool = void 0;
|
|
4
|
+
var GeminiSearchAiTool_1 = require("./GeminiSearchAiTool");
|
|
5
|
+
Object.defineProperty(exports, "GeminiSearchAiTool", { enumerable: true, get: function () { return GeminiSearchAiTool_1.GeminiSearchAiTool; } });
|
|
8
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/tools/builtin/ai/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/tools/builtin/ai/index.ts"],"names":[],"mappings":";;;AAAA,2DAA0D;AAAjD,wHAAA,kBAAkB,OAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/builtin/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,MAAM,CAAC;AACrB,cAAc,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/builtin/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,MAAM,CAAC;AACrB,cAAc,QAAQ,CAAC;AACvB,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC"}
|
|
@@ -19,4 +19,6 @@ __exportStar(require("./wallet"), exports);
|
|
|
19
19
|
__exportStar(require("./nft"), exports);
|
|
20
20
|
__exportStar(require("./ai"), exports);
|
|
21
21
|
__exportStar(require("./pool"), exports);
|
|
22
|
+
__exportStar(require("./pool-subgraph"), exports);
|
|
23
|
+
__exportStar(require("./wallet-action"), exports);
|
|
22
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/builtin/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,2CAAyB;AACzB,wCAAsB;AACtB,uCAAqB;AACrB,yCAAuB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/builtin/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,2CAAyB;AACzB,wCAAsB;AACtB,uCAAqB;AACrB,yCAAuB;AACvB,kDAAgC;AAChC,kDAAgC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { BaseTool } from '../../BaseTool';
|
|
2
|
+
import type { ToolKind, ToolParameter } from '../../../types';
|
|
3
|
+
/** Config for an NFT message tool — the optional website link it points to. */
|
|
4
|
+
export interface NftMessageToolConfig {
|
|
5
|
+
/**
|
|
6
|
+
* Destination URL. When set, the "this website" phrase in the message becomes
|
|
7
|
+
* a Markdown link to it; when omitted/blank, the phrase stays plain text.
|
|
8
|
+
*/
|
|
9
|
+
url?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Shared base for the canned-message NFT notice tools (`send-nft`,
|
|
13
|
+
* `get-wallet-nfts`, `get-nft-metadata`, `get-nft-contract-info`).
|
|
14
|
+
*
|
|
15
|
+
* Each tool emits one fixed sentence that points the user at a website. The
|
|
16
|
+
* phrase "this website" is rendered as a Markdown link to `config.url` when one
|
|
17
|
+
* was supplied at AgentCore construction; otherwise it stays plain text. The
|
|
18
|
+
* tool takes no arguments — it returns the fully-built Markdown message plus
|
|
19
|
+
* `_instructions` telling the agent to reply with it verbatim.
|
|
20
|
+
*/
|
|
21
|
+
export declare abstract class BaseNftMessageTool extends BaseTool {
|
|
22
|
+
kind: ToolKind;
|
|
23
|
+
category: string;
|
|
24
|
+
noSuggestions: boolean;
|
|
25
|
+
parameters: ToolParameter[];
|
|
26
|
+
/** The phrase inside the template that links to the website. */
|
|
27
|
+
protected readonly linkPhrase = "this website";
|
|
28
|
+
/** Message template containing the literal `{link}` placeholder. */
|
|
29
|
+
protected abstract readonly template: string;
|
|
30
|
+
/** Resolved (trimmed) URL, or undefined when none was configured. */
|
|
31
|
+
protected readonly url?: string;
|
|
32
|
+
constructor(config?: NftMessageToolConfig);
|
|
33
|
+
protected run(): Promise<unknown>;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=BaseNftMessageTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseNftMessageTool.d.ts","sourceRoot":"","sources":["../../../../src/tools/builtin/nft/BaseNftMessageTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE9D,+EAA+E;AAC/E,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;GASG;AACH,8BAAsB,kBAAmB,SAAQ,QAAQ;IACvD,IAAI,EAAE,QAAQ,CAAU;IACxB,QAAQ,SAAS;IAGjB,aAAa,UAAQ;IACrB,UAAU,EAAE,aAAa,EAAE,CAAM;IAEjC,gEAAgE;IAChE,SAAS,CAAC,QAAQ,CAAC,UAAU,kBAAkB;IAC/C,oEAAoE;IACpE,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE7C,qEAAqE;IACrE,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;gBAEpB,MAAM,CAAC,EAAE,oBAAoB;cAMzB,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC;CAaxC"}
|