@elizaos/plugin-wallet 2.0.0-beta.1 → 2.0.3-beta.6
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/README.md +70 -45
- package/auto-enable.ts +1 -1
- package/dist/actions/failure-codes.d.ts +12 -0
- package/dist/actions/index.d.ts +1 -0
- package/dist/analytics/birdeye/actions/wallet-search-address.d.ts +7 -0
- package/dist/analytics/birdeye/birdeye-task.d.ts +27 -0
- package/dist/analytics/birdeye/birdeye.d.ts +140 -0
- package/dist/analytics/birdeye/constants.d.ts +68 -0
- package/dist/analytics/birdeye/providers/agent-portfolio-provider.d.ts +8 -0
- package/dist/analytics/birdeye/providers/market.d.ts +18 -0
- package/dist/analytics/birdeye/providers/portfolio-factory.d.ts +10 -0
- package/dist/analytics/birdeye/providers/trending.d.ts +19 -0
- package/dist/analytics/birdeye/providers/wallet.d.ts +5 -0
- package/dist/analytics/birdeye/search-category.d.ts +52 -0
- package/dist/analytics/birdeye/service.d.ts +94 -0
- package/dist/analytics/birdeye/types/api/common.d.ts +199 -0
- package/dist/analytics/birdeye/types/api/defi.d.ts +187 -0
- package/dist/analytics/birdeye/types/api/pair.d.ts +182 -0
- package/dist/analytics/birdeye/types/api/search.d.ts +64 -0
- package/dist/analytics/birdeye/types/api/token.d.ts +580 -0
- package/dist/analytics/birdeye/types/api/trader.d.ts +70 -0
- package/dist/analytics/birdeye/types/api/wallet.d.ts +161 -0
- package/dist/analytics/birdeye/types/shared.d.ts +83 -0
- package/dist/analytics/birdeye/utils.d.ts +74 -0
- package/dist/analytics/dexscreener/errors.d.ts +2 -0
- package/dist/analytics/dexscreener/index.d.ts +3 -0
- package/dist/analytics/dexscreener/search-category.d.ts +3 -0
- package/dist/analytics/dexscreener/service.d.ts +34 -0
- package/dist/analytics/dexscreener/types.d.ts +131 -0
- package/dist/analytics/lpinfo/index.d.ts +31 -0
- package/dist/analytics/lpinfo/kamino/index.d.ts +7 -0
- package/dist/analytics/lpinfo/kamino/providers/kaminoLiquidityProvider.d.ts +6 -0
- package/dist/analytics/lpinfo/kamino/providers/kaminoPoolProvider.d.ts +6 -0
- package/dist/analytics/lpinfo/kamino/providers/kaminoProvider.d.ts +6 -0
- package/dist/analytics/lpinfo/kamino/services/kaminoLiquidityService.d.ts +203 -0
- package/dist/analytics/lpinfo/kamino/services/kaminoService.d.ts +171 -0
- package/dist/analytics/lpinfo/steer/index.d.ts +7 -0
- package/dist/analytics/lpinfo/steer/providers/steerLiquidityProvider.d.ts +6 -0
- package/dist/analytics/lpinfo/steer/services/steerLiquidityService.d.ts +208 -0
- package/dist/analytics/lpinfo/steer/steer-display-types.d.ts +97 -0
- package/dist/analytics/news/index.d.ts +32 -0
- package/dist/analytics/news/interfaces/types.d.ts +177 -0
- package/dist/analytics/news/providers/defiNewsProvider.d.ts +106 -0
- package/dist/analytics/news/services/newsDataService.d.ts +72 -0
- package/dist/analytics/news/utils/formatters.d.ts +54 -0
- package/dist/analytics/token-info/action.d.ts +6 -0
- package/dist/analytics/token-info/index.d.ts +3 -0
- package/dist/analytics/token-info/params.d.ts +10 -0
- package/dist/analytics/token-info/providers.d.ts +4 -0
- package/dist/analytics/token-info/service.d.ts +19 -0
- package/dist/analytics/token-info/types.d.ts +45 -0
- package/dist/api/wallet-routes.d.ts +100 -0
- package/dist/audit/audit-log.d.ts +29 -0
- package/dist/browser-shim/build-shim.d.ts +31 -0
- package/dist/browser-shim/index.d.ts +1 -0
- package/dist/chains/evm/actions/helpers.d.ts +31 -0
- package/dist/chains/evm/actions/swap.d.ts +53 -0
- package/dist/chains/evm/actions/transfer.d.ts +10 -0
- package/dist/chains/evm/bridge-router.d.ts +44 -0
- package/dist/chains/evm/build.d.ts +2 -0
- package/dist/chains/evm/chain-handler.d.ts +37 -0
- package/dist/chains/evm/constants.d.ts +16 -0
- package/dist/chains/evm/dex/aerodrome/index.d.ts +6 -0
- package/dist/chains/evm/dex/aerodrome/services/AerodromeLpService.d.ts +27 -0
- package/dist/chains/evm/dex/aerodrome/types.d.ts +435 -0
- package/dist/chains/evm/dex/pancakeswp/index.d.ts +6 -0
- package/dist/chains/evm/dex/pancakeswp/services/PancakeSwapV3LpService.d.ts +28 -0
- package/dist/chains/evm/dex/pancakeswp/types.d.ts +19 -0
- package/dist/chains/evm/dex/uniswap/index.d.ts +6 -0
- package/dist/chains/evm/dex/uniswap/services/UniswapV3LpService.d.ts +28 -0
- package/dist/chains/evm/dex/uniswap/types.d.ts +458 -0
- package/dist/chains/evm/generated/specs/spec-helpers.d.ts +35 -0
- package/dist/chains/evm/generated/specs/specs.d.ts +99 -0
- package/dist/chains/evm/gov-router.d.ts +6 -0
- package/dist/chains/evm/index.browser.d.ts +3 -0
- package/dist/chains/evm/index.d.ts +6 -0
- package/dist/chains/evm/prompts.d.ts +24 -0
- package/dist/chains/evm/providers/get-balance.d.ts +2 -0
- package/dist/chains/evm/providers/wallet.d.ts +35 -0
- package/dist/chains/evm/routes/sign.d.ts +13 -0
- package/dist/chains/evm/rpc-providers.d.ts +26 -0
- package/dist/chains/evm/service.d.ts +26 -0
- package/dist/chains/evm/templates/index.d.ts +1 -0
- package/dist/chains/evm/types/index.d.ts +296 -0
- package/dist/chains/evm/vitest.config.d.ts +2 -0
- package/dist/chains/registry.d.ts +3 -0
- package/dist/chains/solana/actions/confirmation.d.ts +9 -0
- package/dist/chains/solana/bn.d.ts +6 -0
- package/dist/chains/solana/build.d.ts +2 -0
- package/dist/chains/solana/constants.d.ts +2 -0
- package/dist/chains/solana/dex/meteora/e2e/scenarios.d.ts +10 -0
- package/dist/chains/solana/dex/meteora/e2e/test-utils.d.ts +28 -0
- package/dist/chains/solana/dex/meteora/index.d.ts +3 -0
- package/dist/chains/solana/dex/meteora/providers/positionProvider.d.ts +9 -0
- package/dist/chains/solana/dex/meteora/services/MeteoraLpService.d.ts +37 -0
- package/dist/chains/solana/dex/meteora/utils/dlmm.d.ts +6 -0
- package/dist/chains/solana/dex/meteora/utils/loadWallet.d.ts +14 -0
- package/dist/chains/solana/dex/meteora/utils/sendTransaction.d.ts +2 -0
- package/dist/chains/solana/dex/orca/index.d.ts +6 -0
- package/dist/chains/solana/dex/orca/providers/positionProvider.d.ts +10 -0
- package/dist/chains/solana/dex/orca/services/srv_orca.d.ts +10 -0
- package/dist/chains/solana/dex/orca/types.d.ts +61 -0
- package/dist/chains/solana/dex/orca/utils/loadWallet.d.ts +1 -0
- package/dist/chains/solana/dex/orca/utils/sendTransaction.d.ts +2 -0
- package/dist/chains/solana/dex/raydium/index.d.ts +6 -0
- package/dist/chains/solana/dex/raydium/providers/positionProvider.d.ts +10 -0
- package/dist/chains/solana/dex/raydium/services/srv_raydium.d.ts +104 -0
- package/dist/chains/solana/dex/raydium/types.d.ts +42 -0
- package/dist/chains/solana/environment.d.ts +15 -0
- package/dist/chains/solana/generated/specs/spec-helpers.d.ts +35 -0
- package/dist/chains/solana/generated/specs/specs.d.ts +73 -0
- package/dist/chains/solana/index.browser.d.ts +3 -0
- package/dist/chains/solana/index.d.ts +7 -0
- package/dist/chains/solana/keypairUtils.d.ts +7 -0
- package/dist/chains/solana/prompts.d.ts +12 -0
- package/dist/chains/solana/providers/wallet.d.ts +2 -0
- package/dist/chains/solana/routes/index.d.ts +2 -0
- package/dist/chains/solana/routes/sign.d.ts +16 -0
- package/dist/chains/solana/service.d.ts +237 -0
- package/dist/chains/solana/types.d.ts +377 -0
- package/dist/chains/solana/vitest.config.d.ts +2 -0
- package/dist/chains/wallet-action.d.ts +3 -0
- package/dist/contracts.d.ts +58 -0
- package/dist/core-augmentation.d.ts +9 -0
- package/dist/index.d.mts +27 -34727
- package/dist/index.d.ts +27 -0
- package/dist/index.mjs +28246 -21186
- package/dist/index.mjs.map +153 -0
- package/dist/lib/server-wallet-trade.d.ts +22 -0
- package/dist/lib/server-wallet-trade.js +333 -0
- package/dist/lib/server-wallet-trade.js.map +11 -0
- package/dist/lib/wallet-export-guard.d.ts +45 -0
- package/dist/lp/actions/liquidity.d.ts +2 -0
- package/dist/lp/e2e/real-token-tests.d.ts +6 -0
- package/dist/lp/e2e/scenarios.d.ts +9 -0
- package/dist/lp/e2e/test-utils.d.ts +28 -0
- package/dist/lp/lp-manager-entry.d.ts +18 -0
- package/dist/lp/services/ConcentratedLiquidityService.d.ts +32 -0
- package/dist/lp/services/DexInteractionService.d.ts +34 -0
- package/dist/lp/services/LpManagementService.d.ts +116 -0
- package/dist/lp/services/UserLpProfileService.d.ts +18 -0
- package/dist/lp/services/VaultService.d.ts +21 -0
- package/dist/lp/services/YieldOptimizationService.d.ts +59 -0
- package/dist/lp/services/__tests__/MockLpService.d.ts +17 -0
- package/dist/lp/types.d.ts +439 -0
- package/dist/lp/utils/solanaClient.d.ts +26 -0
- package/dist/plugin.d.ts +7 -0
- package/dist/policy/policy.d.ts +14 -0
- package/dist/providers/canonical-provider.d.ts +19 -0
- package/dist/providers/wallet-provider.d.ts +5 -0
- package/dist/register-routes.d.ts +1 -0
- package/dist/routes/plugin.d.ts +14 -0
- package/dist/routes/wallet-market-overview-route.d.ts +7 -0
- package/dist/sdk/abi.d.ts +396 -0
- package/dist/sdk/bridge/abis.d.ts +63 -0
- package/dist/sdk/bridge/client.d.ts +48 -0
- package/dist/sdk/bridge/index.d.ts +14 -0
- package/dist/sdk/bridge/solana.d.ts +131 -0
- package/dist/sdk/bridge/types.d.ts +92 -0
- package/dist/sdk/convenience.d.ts +104 -0
- package/dist/sdk/escrow/MutualStakeEscrow.d.ts +75 -0
- package/dist/sdk/escrow/types.d.ts +58 -0
- package/dist/sdk/escrow/verifiers.d.ts +25 -0
- package/dist/sdk/identity/erc8004.d.ts +304 -0
- package/dist/sdk/identity/reputation.d.ts +317 -0
- package/dist/sdk/identity/uaid.d.ts +192 -0
- package/dist/sdk/identity/validation.d.ts +282 -0
- package/dist/sdk/index.d.ts +133 -0
- package/dist/sdk/index.js +5284 -0
- package/dist/sdk/index.js.map +40 -0
- package/dist/sdk/policy/SpendingPolicy.d.ts +105 -0
- package/dist/sdk/policy/UptoBillingPolicy.d.ts +87 -0
- package/dist/sdk/router/PaymentRouter.d.ts +77 -0
- package/dist/sdk/router/index.d.ts +2 -0
- package/dist/sdk/swap/SwapModule.d.ts +47 -0
- package/dist/sdk/swap/abi.d.ts +50 -0
- package/dist/sdk/swap/index.d.ts +11 -0
- package/dist/sdk/swap/types.d.ts +101 -0
- package/dist/sdk/tokens/decimals.d.ts +64 -0
- package/dist/sdk/tokens/registry.d.ts +81 -0
- package/dist/sdk/tokens/solana.d.ts +107 -0
- package/dist/sdk/tokens/transfers.d.ts +94 -0
- package/dist/sdk/types.d.ts +129 -0
- package/dist/sdk/wallet-core.d.ts +29450 -0
- package/dist/sdk/x402/budget.d.ts +51 -0
- package/dist/sdk/x402/chains/abstract/index.d.ts +134 -0
- package/dist/sdk/x402/client.d.ts +66 -0
- package/dist/sdk/x402/index.d.ts +8 -0
- package/dist/sdk/x402/middleware.d.ts +37 -0
- package/dist/sdk/x402/multi-asset.d.ts +53 -0
- package/dist/sdk/x402/types.d.ts +109 -0
- package/dist/security/wallet-context-safety.d.ts +7 -0
- package/dist/security/wallet-financial-confirmation.d.ts +23 -0
- package/dist/services/wallet-backend-service.d.ts +39 -0
- package/dist/types/wallet-router.d.ts +130 -0
- package/dist/utils/intent-trajectory.d.ts +34 -0
- package/dist/wallet/backend.d.ts +41 -0
- package/dist/wallet/errors.d.ts +17 -0
- package/dist/wallet/index.d.ts +6 -0
- package/dist/wallet/local-eoa-backend.d.ts +37 -0
- package/dist/wallet/pending.d.ts +47 -0
- package/dist/wallet/select-backend.d.ts +11 -0
- package/dist/wallet/steward-backend.d.ts +22 -0
- package/dist/wallet-action.d.ts +1 -0
- package/dist/wallet-action.js +6292 -0
- package/dist/wallet-action.js.map +44 -0
- package/package.json +35 -21
- package/registry-entry.json +134 -0
- package/src/analytics/birdeye/actions/wallet-search-address.ts +85 -5
- package/src/analytics/birdeye/birdeye-task.ts +25 -9
- package/src/analytics/birdeye/birdeye.ts +6 -7
- package/src/analytics/birdeye/constants.ts +0 -1
- package/src/analytics/birdeye/providers/agent-portfolio-provider.ts +0 -1
- package/src/analytics/birdeye/providers/market.ts +51 -45
- package/src/analytics/birdeye/providers/portfolio-factory.ts +79 -38
- package/src/analytics/birdeye/providers/trending.ts +43 -46
- package/src/analytics/birdeye/providers/wallet.ts +0 -1
- package/src/analytics/birdeye/search-category.test.ts +1 -1
- package/src/analytics/birdeye/search-category.ts +77 -12
- package/src/analytics/birdeye/service.test.ts +146 -0
- package/src/analytics/birdeye/service.ts +220 -105
- package/src/analytics/birdeye/types/api/common.ts +0 -1
- package/src/analytics/birdeye/types/api/defi.ts +0 -1
- package/src/analytics/birdeye/types/api/pair.ts +0 -1
- package/src/analytics/birdeye/types/api/search.ts +0 -1
- package/src/analytics/birdeye/types/api/token.ts +0 -1
- package/src/analytics/birdeye/types/api/trader.ts +0 -1
- package/src/analytics/birdeye/types/api/wallet.ts +0 -1
- package/src/analytics/birdeye/types/shared.ts +0 -11
- package/src/analytics/birdeye/utils.test.ts +69 -0
- package/src/analytics/birdeye/utils.ts +11 -8
- package/src/analytics/dexscreener/search-category.ts +0 -1
- package/src/analytics/dexscreener/service.ts +7 -12
- package/src/analytics/dexscreener/types.ts +0 -1
- package/src/analytics/lpinfo/index.ts +5 -2
- package/src/analytics/lpinfo/kamino/README.md +2 -2
- package/src/analytics/lpinfo/kamino/index.ts +9 -2
- package/src/analytics/lpinfo/kamino/providers/kaminoLiquidityProvider.ts +6 -26
- package/src/analytics/lpinfo/kamino/providers/kaminoPoolProvider.ts +11 -12
- package/src/analytics/lpinfo/kamino/providers/kaminoProvider.ts +76 -32
- package/src/analytics/lpinfo/kamino/services/kaminoLiquidityService.ts +78 -38
- package/src/analytics/lpinfo/kamino/services/kaminoService.ts +71 -31
- package/src/analytics/lpinfo/steer/index.ts +7 -2
- package/src/analytics/lpinfo/steer/providers/steerLiquidityProvider.ts +25 -26
- package/src/analytics/lpinfo/steer/services/steerLiquidityService.ts +367 -149
- package/src/analytics/news/index.ts +7 -2
- package/src/analytics/news/interfaces/types.ts +0 -1
- package/src/analytics/news/providers/defiNewsProvider.ts +17 -44
- package/src/analytics/news/services/newsDataService.ts +1 -22
- package/src/analytics/news/utils/formatters.test.ts +60 -0
- package/src/analytics/news/utils/formatters.ts +0 -1
- package/src/analytics/token-info/action.ts +52 -212
- package/src/analytics/token-info/index.ts +1 -1
- package/src/analytics/token-info/params.test.ts +69 -0
- package/src/analytics/token-info/params.ts +13 -11
- package/src/analytics/token-info/providers.ts +46 -17
- package/src/analytics/token-info/service.ts +3 -3
- package/src/analytics/token-info/types.ts +2 -2
- package/src/api/wallet-routes.test.ts +56 -0
- package/src/api/wallet-routes.ts +1728 -0
- package/src/audit/audit-log.ts +57 -2
- package/src/browser-shim/build-shim.ts +1 -1
- package/src/browser-shim/shim.template.js +107 -117
- package/src/chains/{wallet-router.test.ts → __tests__/wallet-router.test.ts} +57 -10
- package/src/chains/evm/actions/helpers.ts +9 -7
- package/src/chains/evm/actions/swap.ts +176 -22
- package/src/chains/evm/actions/transfer.ts +29 -22
- package/src/chains/evm/biome.json +1 -1
- package/src/chains/evm/build.ts +6 -1
- package/src/chains/evm/constants.ts +19 -0
- package/src/chains/evm/contracts/artifacts/OZGovernor.json +25 -1682
- package/src/chains/evm/dex/aerodrome/index.ts +6 -1
- package/src/chains/evm/dex/aerodrome/services/AerodromeLpService.ts +41 -15
- package/src/chains/evm/dex/aerodrome/types.ts +1 -2
- package/src/chains/evm/dex/pancakeswp/index.ts +6 -1
- package/src/chains/evm/dex/pancakeswp/services/PancakeSwapV3LpService.ts +54 -17
- package/src/chains/evm/dex/pancakeswp/types.ts +1 -2
- package/src/chains/evm/dex/uniswap/index.ts +6 -1
- package/src/chains/evm/dex/uniswap/services/UniswapV3LpService.ts +20 -9
- package/src/chains/evm/dex/uniswap/types.ts +1 -2
- package/src/chains/evm/gov-router.ts +3 -1
- package/src/chains/evm/index.browser.ts +1 -1
- package/src/chains/evm/index.ts +5 -1
- package/src/chains/evm/prompts.ts +5 -0
- package/src/chains/evm/providers/get-balance.ts +1 -1
- package/src/chains/evm/providers/wallet.ts +80 -9
- package/src/chains/evm/routes/sign.ts +35 -26
- package/src/chains/evm/rpc-providers.ts +1 -1
- package/src/chains/evm/types/index.ts +22 -2
- package/src/chains/registry.ts +1 -1
- package/src/chains/wallet-action.ts +301 -91
- package/src/index.ts +9 -5
- package/src/lib/wallet-export-guard.test.ts +233 -0
- package/src/lib/wallet-export-guard.ts +1 -1
- package/src/lp/actions/liquidity.ts +53 -26
- package/src/lp/e2e/real-token-tests.ts +0 -1
- package/src/lp/e2e/scenarios.ts +1 -2
- package/src/lp/e2e/test-utils.ts +20 -7
- package/src/lp/lp-manager-entry.ts +2 -5
- package/src/lp/services/ConcentratedLiquidityService.ts +3 -10
- package/src/lp/services/DexInteractionService.ts +1 -2
- package/src/lp/services/LpManagementService.test.ts +0 -1
- package/src/lp/services/LpManagementService.ts +75 -35
- package/src/lp/services/UserLpProfileService.ts +2 -3
- package/src/lp/services/VaultService.ts +10 -4
- package/src/lp/services/YieldOptimizationService.ts +29 -13
- package/src/lp/services/__tests__/MockLpService.ts +1 -2
- package/src/lp/types.ts +9 -13
- package/src/lp/utils/solanaClient.ts +4 -2
- package/src/plugin.routes.test.ts +24 -0
- package/src/plugin.ts +30 -13
- package/src/providers/canonical-provider.ts +1 -1
- package/src/providers/{unified-wallet-provider.ts → wallet-provider.ts} +3 -3
- package/src/routes/__fixtures__/coingecko-markets.recorded.json +97 -0
- package/src/routes/wallet-market-overview-route.ts +1 -1
- package/src/routes/wallet-market-overview.contract.test.ts +139 -0
- package/src/routes/wallet-market-overview.real.test.ts +83 -0
- package/src/sdk/escrow/MutualStakeEscrow.ts +1 -2
- package/src/sdk/identity/erc8004.ts +1 -1
- package/src/sdk/identity/validation.ts +3 -4
- package/src/sdk/index.ts +2 -2
- package/src/sdk/policy/SpendingPolicy.ts +1 -1
- package/src/sdk/router/PaymentRouter.ts +8 -11
- package/src/sdk/swap/SwapModule.ts +1 -1
- package/src/sdk/tokens/registry.ts +1 -1
- package/src/sdk/x402/middleware.ts +2 -8
- package/src/security/__tests__/wallet-context-safety.test.ts +79 -0
- package/src/security/__tests__/wallet-financial-confirmation.test.ts +88 -0
- package/src/security/wallet-context-safety.ts +128 -0
- package/src/security/wallet-financial-confirmation.ts +150 -0
- package/src/services/wallet-backend-service.ts +15 -1
- package/src/utils/intent-trajectory.ts +2 -2
- package/src/wallet/steward-backend.ts +4 -4
- package/dist/LpManagementService-BWrQ5-cO.mjs +0 -353
- package/dist/MockLpService-D_Apn4Fd.mjs +0 -99
- package/dist/aerodrome-CfnESC32.mjs +0 -890
- package/dist/chunk-hT5z_Zn9.mjs +0 -35
- package/dist/lib/server-wallet-trade.d.mts +0 -34
- package/dist/lib/server-wallet-trade.mjs +0 -306
- package/dist/meteora-BPX39hZo.mjs +0 -22640
- package/dist/orca-Bybp1HXO.mjs +0 -249
- package/dist/pancakeswp-CkEXlXti.mjs +0 -604
- package/dist/plugin-ZO_MTyd0.mjs +0 -529
- package/dist/raydium-rfaM9yEf.mjs +0 -539
- package/dist/sdk/index.d.mts +0 -32492
- package/dist/sdk/index.mjs +0 -6415
- package/dist/types-D5252NZk.mjs +0 -487
- package/dist/uniswap-CReXgXVN.mjs +0 -573
- package/dist/wallet-action.d.mts +0 -6
- package/dist/wallet-action.mjs +0 -820
- package/src/analytics/birdeye/tasks/birdeye.ts +0 -232
- package/src/analytics/lpinfo/index.d.ts +0 -7
- package/src/chains/evm/contracts/artifacts/TimelockController.json +0 -1007
- package/src/chains/evm/contracts/artifacts/VoteToken.json +0 -895
- package/src/lp/tasks/LpAutoRebalanceTask.ts +0 -117
- package/src/lp/tasks/__tests__/LpAutoRebalanceTask.test.ts +0 -370
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SolanaBridgeModule — CCTP V2 cross-chain USDC bridge between EVM chains and Solana.
|
|
3
|
+
*
|
|
4
|
+
* Uses Circle's Cross-Chain Transfer Protocol (CCTP) V2 for trustless USDC transfers.
|
|
5
|
+
* EVM side uses viem; Solana side uses @solana/web3.js as an optional peer dependency.
|
|
6
|
+
*
|
|
7
|
+
* Sources:
|
|
8
|
+
* - Circle CCTP Solana docs: https://developers.circle.com/cctp/docs/solana
|
|
9
|
+
* - Solana USDC mint: https://solana.com/ecosystem/usdc
|
|
10
|
+
* - CCTP domain IDs: https://developers.circle.com/cctp/references/contract-addresses
|
|
11
|
+
*/
|
|
12
|
+
import { type Address, type Hash, type Hex, type WalletClient } from "viem";
|
|
13
|
+
import { type EVMBridgeChain } from "./types.js";
|
|
14
|
+
/** Solana CCTP domain ID */
|
|
15
|
+
export declare const SOLANA_CCTP_DOMAIN = 5;
|
|
16
|
+
/** Native USDC mint on Solana Mainnet */
|
|
17
|
+
export declare const SOLANA_USDC_MINT: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
|
18
|
+
/**
|
|
19
|
+
* Solana CCTP V2 TokenMessengerMinterV2 program address.
|
|
20
|
+
* This is the V2 program (not V1 CCTPiPYP...). The V2 program combines
|
|
21
|
+
* TokenMessengerV2 + TokenMinterV2 into a single program.
|
|
22
|
+
* Source: https://developers.circle.com/cctp/references/solana-programs
|
|
23
|
+
* Verified: https://github.com/circlefin/solana-cctp-contracts (programs/v2)
|
|
24
|
+
*/
|
|
25
|
+
export declare const SOLANA_TOKEN_MESSENGER: "CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe";
|
|
26
|
+
/**
|
|
27
|
+
* Solana CCTP V2 MessageTransmitterV2 program address.
|
|
28
|
+
* This is the V2 program (not V1 CCTPmbSD...).
|
|
29
|
+
* Source: https://developers.circle.com/cctp/references/solana-programs
|
|
30
|
+
* Verified: https://github.com/circlefin/solana-cctp-contracts (programs/v2)
|
|
31
|
+
*/
|
|
32
|
+
export declare const SOLANA_MESSAGE_TRANSMITTER: "CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC";
|
|
33
|
+
/** Default Solana Mainnet RPC endpoint */
|
|
34
|
+
export declare const SOLANA_DEFAULT_RPC: "https://api.mainnet-beta.solana.com";
|
|
35
|
+
/**
|
|
36
|
+
* Decode a 32-byte hex buffer back to a Solana base58 public key.
|
|
37
|
+
* Used when interpreting Solana→EVM message recipient fields.
|
|
38
|
+
*/
|
|
39
|
+
export declare function bytes32ToSolanaPubkey(bytes32: Hex): string;
|
|
40
|
+
export interface EVMToSolanaOptions {
|
|
41
|
+
/** Solana recipient address (base58). Defaults to the EVM signer's address re-encoded — usually wrong; always specify. */
|
|
42
|
+
solanaRecipient: string;
|
|
43
|
+
/** EVM source chain. Defaults to 'base'. */
|
|
44
|
+
fromChain?: EVMBridgeChain;
|
|
45
|
+
/** Optional EVM RPC URL override. */
|
|
46
|
+
evmRpcUrl?: string;
|
|
47
|
+
/** Finality threshold: FAST (0) or FINALIZED (1000). Default: FAST. */
|
|
48
|
+
minFinalityThreshold?: number;
|
|
49
|
+
/** Max bridge fee in USDC base units. Default: 0 (no fee). */
|
|
50
|
+
maxFee?: bigint;
|
|
51
|
+
/** Circle IRIS API URL override. */
|
|
52
|
+
attestationApiUrl?: string;
|
|
53
|
+
}
|
|
54
|
+
export interface EVMToSolanaResult {
|
|
55
|
+
/** EVM burn transaction hash */
|
|
56
|
+
burnTxHash: Hash;
|
|
57
|
+
/** Circle message hash (used to poll for attestation) */
|
|
58
|
+
messageHash: Hex;
|
|
59
|
+
/** Raw CCTP message bytes (for manual receiveMessage on Solana) */
|
|
60
|
+
messageBytes: Hex;
|
|
61
|
+
/** Circle attestation signature (for receiveMessage on Solana) */
|
|
62
|
+
attestation: Hex;
|
|
63
|
+
/** The Solana CCTP domain (5) */
|
|
64
|
+
destinationDomain: number;
|
|
65
|
+
/** Amount bridged in USDC base units */
|
|
66
|
+
amount: bigint;
|
|
67
|
+
/** Elapsed time in milliseconds */
|
|
68
|
+
elapsedMs: number;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Bridge USDC from an EVM chain to Solana using CCTP V2.
|
|
72
|
+
*
|
|
73
|
+
* This function handles the EVM burn side and attestation polling.
|
|
74
|
+
* The Solana receive side must be completed by calling `receiveMessageOnSolana()`
|
|
75
|
+
* or by the Solana recipient manually submitting the message and attestation
|
|
76
|
+
* to the Solana MessageTransmitter program.
|
|
77
|
+
*
|
|
78
|
+
* @param walletClient - Viem WalletClient with a signer attached (for EVM)
|
|
79
|
+
* @param amount - Amount to bridge in USDC base units (6 decimals, e.g. 1_000_000n = 1 USDC)
|
|
80
|
+
* @param options - Bridge options including solanaRecipient (required)
|
|
81
|
+
* @returns Burn tx hash, attestation, and message bytes for Solana receive
|
|
82
|
+
*/
|
|
83
|
+
export declare function bridgeEVMToSolana(walletClient: WalletClient, amount: bigint, options: EVMToSolanaOptions): Promise<EVMToSolanaResult>;
|
|
84
|
+
export interface SolanaToEVMOptions {
|
|
85
|
+
/** EVM destination chain */
|
|
86
|
+
toChain: EVMBridgeChain;
|
|
87
|
+
/** Optional EVM destination RPC URL override */
|
|
88
|
+
evmRpcUrl?: string;
|
|
89
|
+
/** EVM recipient address. Defaults to the EVM walletClient's account address. */
|
|
90
|
+
evmRecipient?: Address;
|
|
91
|
+
/** Circle IRIS API URL override */
|
|
92
|
+
attestationApiUrl?: string;
|
|
93
|
+
/** Solana RPC URL override */
|
|
94
|
+
solanaRpcUrl?: string;
|
|
95
|
+
}
|
|
96
|
+
export interface SolanaToEVMBurnParams {
|
|
97
|
+
/** Raw CCTP message bytes from Solana burn transaction */
|
|
98
|
+
messageBytes: Hex;
|
|
99
|
+
/** Circle message hash */
|
|
100
|
+
messageHash: Hex;
|
|
101
|
+
/** Source domain (should be SOLANA_CCTP_DOMAIN = 5) */
|
|
102
|
+
sourceDomain: number;
|
|
103
|
+
}
|
|
104
|
+
export interface SolanaToEVMResult {
|
|
105
|
+
/** EVM mint transaction hash */
|
|
106
|
+
mintTxHash: Hash;
|
|
107
|
+
/** Amount received in USDC base units */
|
|
108
|
+
amount: bigint;
|
|
109
|
+
/** EVM destination chain */
|
|
110
|
+
toChain: EVMBridgeChain;
|
|
111
|
+
/** EVM recipient address */
|
|
112
|
+
recipient: Address;
|
|
113
|
+
/** Elapsed time in milliseconds */
|
|
114
|
+
elapsedMs: number;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Complete the Solana→EVM bridge by polling for Circle's attestation and minting on EVM.
|
|
118
|
+
*
|
|
119
|
+
* The caller is responsible for initiating the Solana burn via the Solana
|
|
120
|
+
* CCTP MessageTransmitter and passing the resulting messageBytes + messageHash here.
|
|
121
|
+
*
|
|
122
|
+
* @param walletClient - Viem WalletClient (for EVM signing)
|
|
123
|
+
* @param burnParams - Message bytes and hash from the Solana burn transaction
|
|
124
|
+
* @param options - Destination chain and optional overrides
|
|
125
|
+
*/
|
|
126
|
+
export declare function receiveFromSolanaOnEVM(walletClient: WalletClient, burnParams: SolanaToEVMBurnParams, options: SolanaToEVMOptions): Promise<SolanaToEVMResult>;
|
|
127
|
+
export type SolanaBridgeErrorCode = "NO_WALLET_CLIENT" | "INVALID_AMOUNT" | "INVALID_RECIPIENT" | "INSUFFICIENT_ALLOWANCE" | "BURN_FAILED" | "ATTESTATION_ERROR" | "ATTESTATION_TIMEOUT" | "MINT_FAILED";
|
|
128
|
+
export declare class SolanaBridgeError extends Error {
|
|
129
|
+
readonly code: SolanaBridgeErrorCode;
|
|
130
|
+
constructor(code: SolanaBridgeErrorCode, message: string);
|
|
131
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module bridge/types
|
|
3
|
+
* Type definitions and constants for the CCTP V2 cross-chain USDC bridge.
|
|
4
|
+
*
|
|
5
|
+
* Supports 10 EVM chains + Solana via Circle's Cross-Chain Transfer Protocol V2.
|
|
6
|
+
* EVM chains: Ethereum, Avalanche, Optimism, Arbitrum, Base, Polygon,
|
|
7
|
+
* Unichain, Linea, Sonic, Worldchain.
|
|
8
|
+
* Non-EVM: Solana (via bridge/solana.ts — uses separate CCTP V2 programs).
|
|
9
|
+
*
|
|
10
|
+
* Contract addresses verified against:
|
|
11
|
+
* - CCTP V2 EVM: https://developers.circle.com/cctp/references/contract-addresses
|
|
12
|
+
* - Solana V2 programs: https://developers.circle.com/cctp/references/solana-programs
|
|
13
|
+
* - USDC addresses: https://developers.circle.com/stablecoins/usdc-contract-addresses
|
|
14
|
+
*/
|
|
15
|
+
import type { Address, Hash, Hex } from "viem";
|
|
16
|
+
/** Supported bridge destination chains */
|
|
17
|
+
export type BridgeChain = "ethereum" | "avalanche" | "optimism" | "arbitrum" | "base" | "polygon" | "unichain" | "linea" | "sonic" | "worldchain" | "solana";
|
|
18
|
+
/** EVM-only bridge chains (excludes non-EVM like Solana) */
|
|
19
|
+
export type EVMBridgeChain = Exclude<BridgeChain, "solana">;
|
|
20
|
+
/**
|
|
21
|
+
* CCTP V2 domain IDs — official Circle domain identifiers.
|
|
22
|
+
* Source: https://developers.circle.com/cctp/references/contract-addresses
|
|
23
|
+
* Solana domain: 5 — https://developers.circle.com/cctp/docs/solana
|
|
24
|
+
*/
|
|
25
|
+
export declare const CCTP_DOMAIN_IDS: Record<BridgeChain, number>;
|
|
26
|
+
/**
|
|
27
|
+
* EVM chain IDs for EVM-compatible bridge chains.
|
|
28
|
+
* Solana is excluded — use solana.ts for Solana-specific operations.
|
|
29
|
+
*/
|
|
30
|
+
export declare const BRIDGE_CHAIN_IDS: Record<EVMBridgeChain, number>;
|
|
31
|
+
/**
|
|
32
|
+
* USDC contract addresses per chain (native Circle USDC, not bridged variants).
|
|
33
|
+
* Solana USDC: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v (stored as string, not Address/Hex)
|
|
34
|
+
*/
|
|
35
|
+
export declare const USDC_CONTRACT: Record<EVMBridgeChain, Address>;
|
|
36
|
+
/** Solana USDC mint address */
|
|
37
|
+
export declare const SOLANA_USDC_MINT: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
|
38
|
+
export declare const TOKEN_MESSENGER_V2: Record<EVMBridgeChain, Address>;
|
|
39
|
+
export declare const MESSAGE_TRANSMITTER_V2: Record<EVMBridgeChain, Address>;
|
|
40
|
+
/**
|
|
41
|
+
* CCTP V2 minFinalityThreshold values.
|
|
42
|
+
* - FAST (0): ~12 seconds. Circle fast attestation.
|
|
43
|
+
* - FINALIZED (1000): Full on-chain finality.
|
|
44
|
+
*/
|
|
45
|
+
export declare const FINALITY_THRESHOLD: {
|
|
46
|
+
readonly FAST: 0;
|
|
47
|
+
readonly FINALIZED: 1000;
|
|
48
|
+
};
|
|
49
|
+
/** Circle IRIS attestation API base URL */
|
|
50
|
+
export declare const CIRCLE_ATTESTATION_API = "https://iris-api.circle.com";
|
|
51
|
+
/** Max attestation polling attempts before timeout */
|
|
52
|
+
export declare const MAX_ATTESTATION_POLLS = 60;
|
|
53
|
+
/** Polling interval for attestation (milliseconds) */
|
|
54
|
+
export declare const ATTESTATION_POLL_INTERVAL_MS = 5000;
|
|
55
|
+
/** Options for a bridge operation */
|
|
56
|
+
export interface BridgeOptions {
|
|
57
|
+
minFinalityThreshold?: number;
|
|
58
|
+
maxFee?: bigint;
|
|
59
|
+
destinationAddress?: Address;
|
|
60
|
+
destinationRpcUrl?: string;
|
|
61
|
+
attestationApiUrl?: string;
|
|
62
|
+
}
|
|
63
|
+
/** Result of a bridge.burn() operation */
|
|
64
|
+
export interface BurnResult {
|
|
65
|
+
burnTxHash: Hash;
|
|
66
|
+
nonce: bigint;
|
|
67
|
+
messageHash: Hex;
|
|
68
|
+
messageBytes: Hex;
|
|
69
|
+
sourceDomain: number;
|
|
70
|
+
destinationDomain: number;
|
|
71
|
+
}
|
|
72
|
+
/** Circle attestation status */
|
|
73
|
+
export type AttestationStatus = "pending_confirmations" | "complete" | "error";
|
|
74
|
+
/** Circle IRIS API response for an attestation */
|
|
75
|
+
export interface AttestationResponse {
|
|
76
|
+
status: AttestationStatus;
|
|
77
|
+
attestation: Hex | null;
|
|
78
|
+
error?: string;
|
|
79
|
+
}
|
|
80
|
+
/** Result of the full EVM↔EVM bridge() operation */
|
|
81
|
+
export interface BridgeResult {
|
|
82
|
+
burnTxHash: Hash;
|
|
83
|
+
mintTxHash: Hash;
|
|
84
|
+
amount: bigint;
|
|
85
|
+
fromChain: EVMBridgeChain;
|
|
86
|
+
toChain: EVMBridgeChain;
|
|
87
|
+
recipient: Address;
|
|
88
|
+
nonce: bigint;
|
|
89
|
+
elapsedMs: number;
|
|
90
|
+
}
|
|
91
|
+
/** Error codes for actionable bridge error messages */
|
|
92
|
+
export type BridgeErrorCode = "UNSUPPORTED_CHAIN" | "INSUFFICIENT_ALLOWANCE" | "INSUFFICIENT_BALANCE" | "BURN_FAILED" | "ATTESTATION_TIMEOUT" | "ATTESTATION_ERROR" | "MINT_FAILED" | "INVALID_AMOUNT" | "NO_WALLET_CLIENT";
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module convenience
|
|
3
|
+
* Environment-variable-driven wallet bootstrap helpers.
|
|
4
|
+
*
|
|
5
|
+
* Provides three dead-simple factory functions that read all configuration
|
|
6
|
+
* from process environment variables so that any agent can set up a fully
|
|
7
|
+
* functional wallet in 3 lines without touching viem directly:
|
|
8
|
+
*
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { walletFromEnv, setPolicyFromEnv, x402FromEnv } from 'agentwallet-sdk';
|
|
11
|
+
*
|
|
12
|
+
* const wallet = walletFromEnv();
|
|
13
|
+
* await setPolicyFromEnv(wallet);
|
|
14
|
+
* const client = x402FromEnv(wallet);
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* ### Environment variables
|
|
18
|
+
*
|
|
19
|
+
* | Variable | Required | Default | Description |
|
|
20
|
+
* |-----------------------|----------|----------------|--------------------------------------------------|
|
|
21
|
+
* | AGENT_PRIVATE_KEY | ✅ yes | — | EOA private key (0x-prefixed hex, 32 bytes) |
|
|
22
|
+
* | AGENT_WALLET_ADDRESS | ✅ yes | — | AgentAccountV2 smart-wallet address |
|
|
23
|
+
* | CHAIN_NAME | no | base | Chain name (base, mainnet, arbitrum, …) |
|
|
24
|
+
* | CHAIN_ID | no | — | Alternative to CHAIN_NAME — numeric chain id |
|
|
25
|
+
* | RPC_URL | no | chain default | Custom JSON-RPC endpoint |
|
|
26
|
+
* | SPEND_LIMIT_PER_TX | no | — | Per-tx USDC limit (decimal, e.g. "1.00") |
|
|
27
|
+
* | SPEND_LIMIT_DAILY | no | — | Daily USDC limit (decimal, e.g. "10.00") |
|
|
28
|
+
* | SPEND_ALLOWLIST | no | — | Comma-separated recipient addresses |
|
|
29
|
+
* | X402_SUPPORTED_NETWORKS | no | (all mainnet) | Comma-separated "chain:chainId" network strings |
|
|
30
|
+
* | X402_GLOBAL_DAILY_LIMIT | no | — | Global daily x402 USDC limit (decimal) |
|
|
31
|
+
* | X402_PER_REQUEST_MAX | no | — | Per-request max USDC spend (decimal) |
|
|
32
|
+
*/
|
|
33
|
+
import { createWallet } from "./wallet-core.js";
|
|
34
|
+
import { createX402Client } from "./x402/middleware.js";
|
|
35
|
+
/**
|
|
36
|
+
* Create a fully configured AgentWallet from environment variables.
|
|
37
|
+
*
|
|
38
|
+
* Reads:
|
|
39
|
+
* - **AGENT_PRIVATE_KEY** — EOA signing key (required; 0x-prefixed 32-byte hex)
|
|
40
|
+
* - **AGENT_WALLET_ADDRESS** — AgentAccountV2 contract address (required)
|
|
41
|
+
* - **CHAIN_NAME** or **CHAIN_ID** — target chain (optional; defaults to Base mainnet)
|
|
42
|
+
* - **RPC_URL** — custom RPC endpoint (optional; uses chain default if omitted)
|
|
43
|
+
*
|
|
44
|
+
* @param options - Optional overrides for chain and rpcUrl.
|
|
45
|
+
* @param options.chain - Chain name that takes precedence over the env var.
|
|
46
|
+
* @param options.rpcUrl - RPC endpoint that takes precedence over the env var.
|
|
47
|
+
* @returns A fully configured wallet object (same shape as `createWallet()`).
|
|
48
|
+
*
|
|
49
|
+
* @throws {Error} If AGENT_PRIVATE_KEY is missing or not a valid hex key.
|
|
50
|
+
* @throws {Error} If AGENT_WALLET_ADDRESS is missing.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* const wallet = walletFromEnv({ chain: 'base-sepolia' });
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function walletFromEnv(options?: {
|
|
58
|
+
chain?: string;
|
|
59
|
+
rpcUrl?: string;
|
|
60
|
+
}): ReturnType<typeof createWallet>;
|
|
61
|
+
/**
|
|
62
|
+
* Apply a spending policy to a wallet from environment variables.
|
|
63
|
+
*
|
|
64
|
+
* Reads:
|
|
65
|
+
* - **SPEND_LIMIT_PER_TX** — maximum USDC per single transaction (e.g. "1.00")
|
|
66
|
+
* - **SPEND_LIMIT_DAILY** — maximum USDC per 24-hour period (e.g. "10.00")
|
|
67
|
+
* - **SPEND_ALLOWLIST** — comma-separated ERC-20 token addresses to restrict
|
|
68
|
+
*
|
|
69
|
+
* If neither limit is set, logs a warning and falls back to queue-for-approval
|
|
70
|
+
* mode (perTxLimit = 0, periodLimit = 0) so all agent transactions must be
|
|
71
|
+
* manually approved. This is the safest default.
|
|
72
|
+
*
|
|
73
|
+
* @param wallet - Wallet returned by `walletFromEnv()` (or `createWallet()`).
|
|
74
|
+
* @returns Promise that resolves to the on-chain tx hash of the policy update.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* await setPolicyFromEnv(wallet);
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export declare function setPolicyFromEnv(wallet: ReturnType<typeof createWallet>): Promise<string>;
|
|
82
|
+
/**
|
|
83
|
+
* Create an x402 payment client from environment variables.
|
|
84
|
+
*
|
|
85
|
+
* Reads:
|
|
86
|
+
* - **X402_SUPPORTED_NETWORKS** — comma-separated "chain:chainId" strings
|
|
87
|
+
* (e.g. "base:8453,arbitrum:42161"); defaults to all supported mainnets
|
|
88
|
+
* - **X402_GLOBAL_DAILY_LIMIT** — total daily USDC budget across all x402
|
|
89
|
+
* services (decimal, e.g. "5.00")
|
|
90
|
+
* - **X402_PER_REQUEST_MAX** — per-request USDC ceiling (decimal)
|
|
91
|
+
*
|
|
92
|
+
* Sensible defaults: supports all 10 mainnet x402 chains, unlimited daily spend
|
|
93
|
+
* (rely on the agent's on-chain spend policy as the hard limit), 1 auto-retry.
|
|
94
|
+
*
|
|
95
|
+
* @param wallet - Wallet returned by `walletFromEnv()` (or `createWallet()`).
|
|
96
|
+
* @returns A configured X402Client instance.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```typescript
|
|
100
|
+
* const client = x402FromEnv(wallet);
|
|
101
|
+
* const data = await client.fetch('https://api.example.com/premium-endpoint');
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
export declare function x402FromEnv(wallet: ReturnType<typeof createWallet>): ReturnType<typeof createX402Client>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { Address, Hex, PublicClient, WalletClient } from "viem";
|
|
2
|
+
import type { CreateEscrowParams, EscrowCreated, EscrowDetails, TxResult } from "./types.js";
|
|
3
|
+
import { TaskStatus } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* MutualStakeEscrow — SDK class for creating and managing mutual-stake escrow vaults
|
|
6
|
+
*
|
|
7
|
+
* Wraps the StakeVault and StakeVaultFactory contracts with a clean TypeScript API.
|
|
8
|
+
* Both buyer and seller deposit collateral, ensuring aligned incentives.
|
|
9
|
+
*/
|
|
10
|
+
export declare class MutualStakeEscrow {
|
|
11
|
+
private publicClient;
|
|
12
|
+
private walletClient;
|
|
13
|
+
private factoryAddress;
|
|
14
|
+
private chainId;
|
|
15
|
+
constructor(params: {
|
|
16
|
+
publicClient: PublicClient;
|
|
17
|
+
walletClient: WalletClient;
|
|
18
|
+
factoryAddress: Address;
|
|
19
|
+
chainId: number;
|
|
20
|
+
});
|
|
21
|
+
/**
|
|
22
|
+
* Create a new escrow vault via the factory
|
|
23
|
+
* @param params - Escrow creation parameters
|
|
24
|
+
* @returns The deployed vault address and transaction hash
|
|
25
|
+
*/
|
|
26
|
+
create(params: CreateEscrowParams): Promise<EscrowCreated>;
|
|
27
|
+
/**
|
|
28
|
+
* Fund an escrow as buyer (deposits payment + buyerStake)
|
|
29
|
+
* @param vaultAddress - Address of the StakeVault
|
|
30
|
+
* @param approveAmount - Total amount to approve (payment + buyerStake)
|
|
31
|
+
*/
|
|
32
|
+
fund(vaultAddress: Address, approveAmount: bigint): Promise<TxResult>;
|
|
33
|
+
/**
|
|
34
|
+
* Accept an escrow as seller (deposits sellerStake)
|
|
35
|
+
* @param vaultAddress - Address of the StakeVault
|
|
36
|
+
*/
|
|
37
|
+
accept(vaultAddress: Address): Promise<TxResult>;
|
|
38
|
+
/**
|
|
39
|
+
* Submit fulfillment proof as seller
|
|
40
|
+
* @param vaultAddress - Address of the StakeVault
|
|
41
|
+
* @param proof - Completion proof bytes
|
|
42
|
+
*/
|
|
43
|
+
fulfill(vaultAddress: Address, proof: Hex): Promise<TxResult>;
|
|
44
|
+
/**
|
|
45
|
+
* Verify completion after challenge window (anyone can call)
|
|
46
|
+
* @param vaultAddress - Address of the StakeVault
|
|
47
|
+
*/
|
|
48
|
+
verify(vaultAddress: Address): Promise<TxResult>;
|
|
49
|
+
/**
|
|
50
|
+
* Challenge a fulfillment as buyer
|
|
51
|
+
* @param vaultAddress - Address of the StakeVault
|
|
52
|
+
* @param evidence - Challenge evidence bytes
|
|
53
|
+
*/
|
|
54
|
+
challenge(vaultAddress: Address, evidence: Hex): Promise<TxResult>;
|
|
55
|
+
/**
|
|
56
|
+
* Cancel escrow before seller accepts (buyer only)
|
|
57
|
+
* @param vaultAddress - Address of the StakeVault
|
|
58
|
+
*/
|
|
59
|
+
cancel(vaultAddress: Address): Promise<TxResult>;
|
|
60
|
+
/**
|
|
61
|
+
* Reclaim funds after deadline expiry
|
|
62
|
+
* @param vaultAddress - Address of the StakeVault
|
|
63
|
+
*/
|
|
64
|
+
reclaimExpired(vaultAddress: Address): Promise<TxResult>;
|
|
65
|
+
/**
|
|
66
|
+
* Get full escrow details from on-chain
|
|
67
|
+
* @param vaultAddress - Address of the StakeVault
|
|
68
|
+
*/
|
|
69
|
+
getDetails(vaultAddress: Address): Promise<EscrowDetails>;
|
|
70
|
+
/**
|
|
71
|
+
* Get the current status of an escrow
|
|
72
|
+
* @param vaultAddress - Address of the StakeVault
|
|
73
|
+
*/
|
|
74
|
+
getStatus(vaultAddress: Address): Promise<TaskStatus>;
|
|
75
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { Address, Hash, Hex } from "viem";
|
|
2
|
+
/** Mirrors the on-chain TaskStatus enum */
|
|
3
|
+
export declare enum TaskStatus {
|
|
4
|
+
Created = 0,
|
|
5
|
+
Funded = 1,
|
|
6
|
+
Fulfilled = 2,
|
|
7
|
+
Challenged = 3,
|
|
8
|
+
Resolved = 4,
|
|
9
|
+
Cancelled = 5
|
|
10
|
+
}
|
|
11
|
+
/** Supported built-in verifier types */
|
|
12
|
+
export type VerifierType = "optimistic" | "hash";
|
|
13
|
+
/** Parameters for creating a new mutual-stake escrow */
|
|
14
|
+
export interface CreateEscrowParams {
|
|
15
|
+
/** Seller/service-provider address */
|
|
16
|
+
seller: Address;
|
|
17
|
+
/** Payment amount in token's smallest unit (e.g., 6 decimals for USDC) */
|
|
18
|
+
paymentAmount: bigint;
|
|
19
|
+
/** Buyer's anti-grief collateral */
|
|
20
|
+
buyerStake: bigint;
|
|
21
|
+
/** Seller's anti-fraud collateral */
|
|
22
|
+
sellerStake: bigint;
|
|
23
|
+
/** Verifier type or custom verifier contract address */
|
|
24
|
+
verifier: VerifierType | Address;
|
|
25
|
+
/** Verifier-specific configuration data (auto-generated for built-in verifiers) */
|
|
26
|
+
verifierData?: Hex;
|
|
27
|
+
/** Challenge window in seconds after fulfillment */
|
|
28
|
+
challengeWindow: number;
|
|
29
|
+
/** Unix timestamp deadline for the task */
|
|
30
|
+
deadline: number;
|
|
31
|
+
/** ERC-20 token address (defaults to USDC on Base) */
|
|
32
|
+
token?: Address;
|
|
33
|
+
}
|
|
34
|
+
/** Result from creating an escrow */
|
|
35
|
+
export interface EscrowCreated {
|
|
36
|
+
/** Address of the deployed StakeVault contract */
|
|
37
|
+
address: Address;
|
|
38
|
+
/** Transaction hash of the factory call */
|
|
39
|
+
txHash: Hash;
|
|
40
|
+
}
|
|
41
|
+
/** Full escrow details from on-chain */
|
|
42
|
+
export interface EscrowDetails {
|
|
43
|
+
buyer: Address;
|
|
44
|
+
seller: Address;
|
|
45
|
+
token: Address;
|
|
46
|
+
paymentAmount: bigint;
|
|
47
|
+
buyerStake: bigint;
|
|
48
|
+
sellerStake: bigint;
|
|
49
|
+
verifier: Address;
|
|
50
|
+
deadline: bigint;
|
|
51
|
+
challengeWindow: bigint;
|
|
52
|
+
status: TaskStatus;
|
|
53
|
+
fulfilledAt: bigint;
|
|
54
|
+
}
|
|
55
|
+
/** Transaction result */
|
|
56
|
+
export interface TxResult {
|
|
57
|
+
txHash: Hash;
|
|
58
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type Address, type Hex } from "viem";
|
|
2
|
+
import type { VerifierType } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Known verifier contract addresses on Base mainnet.
|
|
5
|
+
* These are deployed once and shared by all StakeVault instances.
|
|
6
|
+
*/
|
|
7
|
+
export declare const VERIFIER_ADDRESSES: Record<string, Record<VerifierType, Address>>;
|
|
8
|
+
/**
|
|
9
|
+
* Resolve a verifier type to its deployed contract address for a given chain
|
|
10
|
+
* @param verifier - Built-in verifier type or custom contract address
|
|
11
|
+
* @param chainId - Chain ID to look up
|
|
12
|
+
* @returns The verifier contract address
|
|
13
|
+
*/
|
|
14
|
+
export declare function resolveVerifierAddress(verifier: VerifierType | Address, chainId: number): Address;
|
|
15
|
+
/**
|
|
16
|
+
* Encode verifier configuration data for the HashVerifier
|
|
17
|
+
* @param expectedHash - SHA256 hash of the expected output
|
|
18
|
+
* @returns ABI-encoded bytes for the verifierData field
|
|
19
|
+
*/
|
|
20
|
+
export declare function encodeHashVerifierData(expectedHash: Hex): Hex;
|
|
21
|
+
/**
|
|
22
|
+
* Encode verifier configuration data for the OptimisticVerifier
|
|
23
|
+
* @returns Empty bytes (optimistic verifier has no config)
|
|
24
|
+
*/
|
|
25
|
+
export declare function encodeOptimisticVerifierData(): Hex;
|