@elizaos/plugin-wallet 2.0.0-beta.1
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/LICENSE +21 -0
- package/README.md +64 -0
- package/auto-enable.ts +76 -0
- package/dist/LpManagementService-BWrQ5-cO.mjs +353 -0
- package/dist/MockLpService-D_Apn4Fd.mjs +99 -0
- package/dist/aerodrome-CfnESC32.mjs +890 -0
- package/dist/chunk-hT5z_Zn9.mjs +35 -0
- package/dist/index.d.mts +34727 -0
- package/dist/index.mjs +21590 -0
- package/dist/lib/server-wallet-trade.d.mts +34 -0
- package/dist/lib/server-wallet-trade.mjs +306 -0
- package/dist/meteora-BPX39hZo.mjs +22640 -0
- package/dist/orca-Bybp1HXO.mjs +249 -0
- package/dist/pancakeswp-CkEXlXti.mjs +604 -0
- package/dist/plugin-ZO_MTyd0.mjs +529 -0
- package/dist/raydium-rfaM9yEf.mjs +539 -0
- package/dist/sdk/index.d.mts +32492 -0
- package/dist/sdk/index.mjs +6415 -0
- package/dist/types-D5252NZk.mjs +487 -0
- package/dist/uniswap-CReXgXVN.mjs +573 -0
- package/dist/wallet-action.d.mts +6 -0
- package/dist/wallet-action.mjs +820 -0
- package/package.json +152 -0
- package/src/actions/failure-codes.ts +79 -0
- package/src/actions/index.ts +1 -0
- package/src/analytics/birdeye/actions/wallet-search-address.ts +9 -0
- package/src/analytics/birdeye/birdeye-task.ts +175 -0
- package/src/analytics/birdeye/birdeye.ts +813 -0
- package/src/analytics/birdeye/constants.ts +74 -0
- package/src/analytics/birdeye/providers/agent-portfolio-provider.ts +18 -0
- package/src/analytics/birdeye/providers/market.ts +227 -0
- package/src/analytics/birdeye/providers/portfolio-factory.test.ts +138 -0
- package/src/analytics/birdeye/providers/portfolio-factory.ts +252 -0
- package/src/analytics/birdeye/providers/trending.ts +365 -0
- package/src/analytics/birdeye/providers/wallet.ts +14 -0
- package/src/analytics/birdeye/search-category.test.ts +207 -0
- package/src/analytics/birdeye/search-category.ts +506 -0
- package/src/analytics/birdeye/service.ts +992 -0
- package/src/analytics/birdeye/tasks/birdeye.ts +232 -0
- package/src/analytics/birdeye/types/api/common.ts +305 -0
- package/src/analytics/birdeye/types/api/defi.ts +220 -0
- package/src/analytics/birdeye/types/api/pair.ts +200 -0
- package/src/analytics/birdeye/types/api/search.ts +86 -0
- package/src/analytics/birdeye/types/api/token.ts +635 -0
- package/src/analytics/birdeye/types/api/trader.ts +76 -0
- package/src/analytics/birdeye/types/api/wallet.ts +181 -0
- package/src/analytics/birdeye/types/shared.ts +106 -0
- package/src/analytics/birdeye/utils.ts +700 -0
- package/src/analytics/dexscreener/errors.ts +28 -0
- package/src/analytics/dexscreener/index.ts +3 -0
- package/src/analytics/dexscreener/search-category.test.ts +49 -0
- package/src/analytics/dexscreener/search-category.ts +42 -0
- package/src/analytics/dexscreener/service.ts +595 -0
- package/src/analytics/dexscreener/types.ts +128 -0
- package/src/analytics/lpinfo/index.d.ts +7 -0
- package/src/analytics/lpinfo/index.ts +52 -0
- package/src/analytics/lpinfo/kamino/README.md +102 -0
- package/src/analytics/lpinfo/kamino/index.ts +24 -0
- package/src/analytics/lpinfo/kamino/providers/kaminoLiquidityProvider.ts +422 -0
- package/src/analytics/lpinfo/kamino/providers/kaminoPoolProvider.ts +365 -0
- package/src/analytics/lpinfo/kamino/providers/kaminoProvider.ts +496 -0
- package/src/analytics/lpinfo/kamino/services/kaminoLiquidityService.ts +1123 -0
- package/src/analytics/lpinfo/kamino/services/kaminoService.ts +758 -0
- package/src/analytics/lpinfo/steer/README.md +169 -0
- package/src/analytics/lpinfo/steer/index.ts +23 -0
- package/src/analytics/lpinfo/steer/providers/steerLiquidityProvider.ts +544 -0
- package/src/analytics/lpinfo/steer/services/steerLiquidityService.ts +1690 -0
- package/src/analytics/lpinfo/steer/steer-display-types.ts +99 -0
- package/src/analytics/news/index.ts +52 -0
- package/src/analytics/news/interfaces/types.ts +222 -0
- package/src/analytics/news/providers/defiNewsProvider.ts +734 -0
- package/src/analytics/news/services/newsDataService.ts +332 -0
- package/src/analytics/news/utils/formatters.ts +151 -0
- package/src/analytics/token-info/action.ts +240 -0
- package/src/analytics/token-info/index.ts +3 -0
- package/src/analytics/token-info/params.ts +215 -0
- package/src/analytics/token-info/providers.ts +681 -0
- package/src/analytics/token-info/service.ts +168 -0
- package/src/analytics/token-info/types.ts +74 -0
- package/src/audit/audit-log.ts +45 -0
- package/src/browser-shim/build-shim.ts +123 -0
- package/src/browser-shim/index.ts +5 -0
- package/src/browser-shim/shim.template.js +563 -0
- package/src/chains/evm/.github/workflows/npm-deploy.yml +112 -0
- package/src/chains/evm/LICENSE +21 -0
- package/src/chains/evm/README.md +106 -0
- package/src/chains/evm/actions/helpers.ts +147 -0
- package/src/chains/evm/actions/swap.ts +839 -0
- package/src/chains/evm/actions/transfer.ts +254 -0
- package/src/chains/evm/biome.json +61 -0
- package/src/chains/evm/bridge-router.ts +660 -0
- package/src/chains/evm/build.ts +89 -0
- package/src/chains/evm/chain-handler.ts +416 -0
- package/src/chains/evm/constants.ts +23 -0
- package/src/chains/evm/contracts/artifacts/OZGovernor.json +1707 -0
- package/src/chains/evm/contracts/artifacts/TimelockController.json +1007 -0
- package/src/chains/evm/contracts/artifacts/VoteToken.json +895 -0
- package/src/chains/evm/dex/aerodrome/index.ts +34 -0
- package/src/chains/evm/dex/aerodrome/services/AerodromeLpService.ts +558 -0
- package/src/chains/evm/dex/aerodrome/types.ts +318 -0
- package/src/chains/evm/dex/pancakeswp/index.ts +35 -0
- package/src/chains/evm/dex/pancakeswp/services/PancakeSwapV3LpService.ts +743 -0
- package/src/chains/evm/dex/pancakeswp/types.ts +65 -0
- package/src/chains/evm/dex/uniswap/index.ts +35 -0
- package/src/chains/evm/dex/uniswap/services/UniswapV3LpService.ts +759 -0
- package/src/chains/evm/dex/uniswap/types.ts +390 -0
- package/src/chains/evm/generated/specs/spec-helpers.ts +73 -0
- package/src/chains/evm/generated/specs/specs.ts +151 -0
- package/src/chains/evm/gov-router.ts +250 -0
- package/src/chains/evm/index.browser.ts +16 -0
- package/src/chains/evm/index.ts +31 -0
- package/src/chains/evm/prompts.ts +193 -0
- package/src/chains/evm/providers/get-balance.ts +123 -0
- package/src/chains/evm/providers/wallet.ts +715 -0
- package/src/chains/evm/routes/sign.ts +333 -0
- package/src/chains/evm/rpc-providers.ts +410 -0
- package/src/chains/evm/service.ts +140 -0
- package/src/chains/evm/templates/index.ts +10 -0
- package/src/chains/evm/types/index.ts +432 -0
- package/src/chains/evm/vitest.config.ts +18 -0
- package/src/chains/registry.ts +668 -0
- package/src/chains/solana/README.md +367 -0
- package/src/chains/wallet-action.ts +533 -0
- package/src/chains/wallet-router.test.ts +296 -0
- package/src/contracts.ts +65 -0
- package/src/core-augmentation.ts +10 -0
- package/src/index.ts +71 -0
- package/src/lib/server-wallet-trade.ts +192 -0
- package/src/lib/wallet-export-guard.ts +330 -0
- package/src/lp/actions/liquidity.ts +827 -0
- package/src/lp/e2e/real-token-tests.ts +428 -0
- package/src/lp/e2e/scenarios.ts +470 -0
- package/src/lp/e2e/test-utils.ts +145 -0
- package/src/lp/lp-manager-entry.ts +303 -0
- package/src/lp/services/ConcentratedLiquidityService.ts +120 -0
- package/src/lp/services/DexInteractionService.ts +226 -0
- package/src/lp/services/LpManagementService.test.ts +148 -0
- package/src/lp/services/LpManagementService.ts +632 -0
- package/src/lp/services/UserLpProfileService.ts +163 -0
- package/src/lp/services/VaultService.ts +153 -0
- package/src/lp/services/YieldOptimizationService.ts +344 -0
- package/src/lp/services/__tests__/MockLpService.ts +146 -0
- package/src/lp/tasks/LpAutoRebalanceTask.ts +117 -0
- package/src/lp/tasks/__tests__/LpAutoRebalanceTask.test.ts +370 -0
- package/src/lp/types.ts +582 -0
- package/src/lp/utils/solanaClient.ts +143 -0
- package/src/plugin.ts +125 -0
- package/src/policy/policy.ts +19 -0
- package/src/providers/canonical-provider.ts +27 -0
- package/src/providers/unified-wallet-provider.ts +79 -0
- package/src/register-routes.ts +11 -0
- package/src/routes/plugin.ts +47 -0
- package/src/routes/wallet-market-overview-route.ts +869 -0
- package/src/sdk/abi.ts +258 -0
- package/src/sdk/bridge/abis.ts +126 -0
- package/src/sdk/bridge/client.ts +518 -0
- package/src/sdk/bridge/index.ts +56 -0
- package/src/sdk/bridge/solana.ts +604 -0
- package/src/sdk/bridge/types.ts +202 -0
- package/src/sdk/convenience.ts +347 -0
- package/src/sdk/escrow/MutualStakeEscrow.ts +480 -0
- package/src/sdk/escrow/types.ts +64 -0
- package/src/sdk/escrow/verifiers.ts +73 -0
- package/src/sdk/identity/erc8004.ts +692 -0
- package/src/sdk/identity/reputation.ts +449 -0
- package/src/sdk/identity/uaid.ts +497 -0
- package/src/sdk/identity/validation.ts +372 -0
- package/src/sdk/index.ts +763 -0
- package/src/sdk/policy/SpendingPolicy.ts +260 -0
- package/src/sdk/policy/UptoBillingPolicy.ts +320 -0
- package/src/sdk/router/PaymentRouter.ts +215 -0
- package/src/sdk/router/index.ts +8 -0
- package/src/sdk/swap/SwapModule.ts +310 -0
- package/src/sdk/swap/abi.ts +117 -0
- package/src/sdk/swap/index.ts +34 -0
- package/src/sdk/swap/types.ts +135 -0
- package/src/sdk/tokens/decimals.ts +140 -0
- package/src/sdk/tokens/registry.ts +911 -0
- package/src/sdk/tokens/solana.ts +419 -0
- package/src/sdk/tokens/transfers.ts +327 -0
- package/src/sdk/types.ts +158 -0
- package/src/sdk/wallet-core.ts +115 -0
- package/src/sdk/x402/budget.ts +168 -0
- package/src/sdk/x402/chains/abstract/index.ts +280 -0
- package/src/sdk/x402/client.ts +320 -0
- package/src/sdk/x402/index.ts +46 -0
- package/src/sdk/x402/middleware.ts +92 -0
- package/src/sdk/x402/multi-asset.ts +144 -0
- package/src/sdk/x402/types.ts +156 -0
- package/src/services/wallet-backend-service.ts +328 -0
- package/src/types/wallet-router.ts +227 -0
- package/src/utils/intent-trajectory.ts +106 -0
- package/src/wallet/backend.ts +62 -0
- package/src/wallet/errors.ts +49 -0
- package/src/wallet/index.ts +27 -0
- package/src/wallet/local-eoa-backend.ts +201 -0
- package/src/wallet/pending.ts +60 -0
- package/src/wallet/select-backend.ts +47 -0
- package/src/wallet/steward-backend.ts +161 -0
- package/src/wallet-action.ts +1 -0
package/src/plugin.ts
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { resolveCloudRoute, toRuntimeSettings } from "@elizaos/cloud-routing";
|
|
2
|
+
import {
|
|
3
|
+
type IAgentRuntime,
|
|
4
|
+
type Plugin,
|
|
5
|
+
parseBooleanFromText,
|
|
6
|
+
type ServiceClass,
|
|
7
|
+
} from "@elizaos/core";
|
|
8
|
+
import { walletSearchAddressAction } from "./analytics/birdeye/actions/wallet-search-address.js";
|
|
9
|
+
import { agentPortfolioProvider } from "./analytics/birdeye/providers/agent-portfolio-provider.js";
|
|
10
|
+
import { marketProvider } from "./analytics/birdeye/providers/market.js";
|
|
11
|
+
import { trendingProvider } from "./analytics/birdeye/providers/trending.js";
|
|
12
|
+
import { registerBirdeyeSearchCategories } from "./analytics/birdeye/search-category.js";
|
|
13
|
+
import {
|
|
14
|
+
BIRDEYE_ROUTE_SPEC,
|
|
15
|
+
BirdeyeService,
|
|
16
|
+
} from "./analytics/birdeye/service.js";
|
|
17
|
+
import { registerDexScreenerSearchCategory } from "./analytics/dexscreener/search-category.js";
|
|
18
|
+
import { DexScreenerService } from "./analytics/dexscreener/service.js";
|
|
19
|
+
import { tokenInfoAction } from "./analytics/token-info/action.js";
|
|
20
|
+
import { TokenInfoService } from "./analytics/token-info/service.js";
|
|
21
|
+
import evmPlugin from "./chains/evm/index.js";
|
|
22
|
+
import solanaPlugin from "./chains/solana/index.js";
|
|
23
|
+
import { unifiedWalletProvider } from "./providers/unified-wallet-provider.js";
|
|
24
|
+
import { WalletBackendService } from "./services/wallet-backend-service.js";
|
|
25
|
+
|
|
26
|
+
const coreWalletPlugin: Plugin = {
|
|
27
|
+
name: "wallet-backend",
|
|
28
|
+
description:
|
|
29
|
+
"Wallet backend service + unified wallet provider (Steward / local).",
|
|
30
|
+
services: [WalletBackendService],
|
|
31
|
+
providers: [unifiedWalletProvider],
|
|
32
|
+
actions: [],
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
function concatServices(
|
|
36
|
+
...chunks: (readonly ServiceClass[] | undefined)[]
|
|
37
|
+
): ServiceClass[] {
|
|
38
|
+
const out: ServiceClass[] = [];
|
|
39
|
+
for (const c of chunks) {
|
|
40
|
+
if (c) out.push(...c);
|
|
41
|
+
}
|
|
42
|
+
return out;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function concatPlugins<T>(...chunks: (readonly T[] | undefined)[]): T[] {
|
|
46
|
+
const out: T[] = [];
|
|
47
|
+
for (const c of chunks) {
|
|
48
|
+
if (c) out.push(...c);
|
|
49
|
+
}
|
|
50
|
+
return out;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async function initBirdeyeAnalytics(runtime: IAgentRuntime): Promise<void> {
|
|
54
|
+
const birdeyeRoute = resolveCloudRoute(
|
|
55
|
+
toRuntimeSettings(runtime),
|
|
56
|
+
BIRDEYE_ROUTE_SPEC,
|
|
57
|
+
);
|
|
58
|
+
registerBirdeyeSearchCategories(runtime, {
|
|
59
|
+
enabled: birdeyeRoute.source !== "disabled",
|
|
60
|
+
disabledReason:
|
|
61
|
+
birdeyeRoute.source === "disabled"
|
|
62
|
+
? "BIRDEYE_API_KEY or Eliza Cloud route is not configured."
|
|
63
|
+
: undefined,
|
|
64
|
+
});
|
|
65
|
+
if (birdeyeRoute.source === "disabled") {
|
|
66
|
+
runtime.logger.log(
|
|
67
|
+
"birdeye: no BIRDEYE_API_KEY and Eliza Cloud not connected, skipping plugin-birdeye init",
|
|
68
|
+
);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const walletAddr = runtime.getSetting("BIRDEYE_WALLET_ADDR");
|
|
73
|
+
if (walletAddr) {
|
|
74
|
+
runtime.registerProvider(agentPortfolioProvider);
|
|
75
|
+
}
|
|
76
|
+
runtime.registerProvider(marketProvider);
|
|
77
|
+
|
|
78
|
+
const beNoTrending = parseBooleanFromText(
|
|
79
|
+
String(runtime.getSetting("BIRDEYE_NO_TRENDING") ?? ""),
|
|
80
|
+
);
|
|
81
|
+
if (!beNoTrending) {
|
|
82
|
+
runtime.registerProvider(trendingProvider);
|
|
83
|
+
} else {
|
|
84
|
+
runtime.logger.log(
|
|
85
|
+
"BIRDEYE_NO_TRENDING is set, skipping trending provider",
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const analyticsServices: ServiceClass[] = [
|
|
91
|
+
BirdeyeService,
|
|
92
|
+
DexScreenerService,
|
|
93
|
+
TokenInfoService,
|
|
94
|
+
] as ServiceClass[];
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Single plugin surface: EVM + Solana wallet backend.
|
|
98
|
+
* Consumers should depend only on `@elizaos/plugin-wallet`.
|
|
99
|
+
*/
|
|
100
|
+
export const walletPlugin: Plugin = {
|
|
101
|
+
name: "wallet",
|
|
102
|
+
description:
|
|
103
|
+
"Unified non-custodial wallet for elizaOS — EVM + Solana, Steward/local backends, x402, CCTP, and venue routing.",
|
|
104
|
+
services: concatServices(
|
|
105
|
+
coreWalletPlugin.services,
|
|
106
|
+
evmPlugin.services as ServiceClass[] | undefined,
|
|
107
|
+
solanaPlugin.services as ServiceClass[] | undefined,
|
|
108
|
+
analyticsServices,
|
|
109
|
+
),
|
|
110
|
+
providers: concatPlugins(coreWalletPlugin.providers, evmPlugin.providers),
|
|
111
|
+
actions: concatPlugins(coreWalletPlugin.actions, evmPlugin.actions, [
|
|
112
|
+
tokenInfoAction,
|
|
113
|
+
walletSearchAddressAction,
|
|
114
|
+
]),
|
|
115
|
+
routes: concatPlugins(solanaPlugin.routes),
|
|
116
|
+
init: async (config, runtime) => {
|
|
117
|
+
await coreWalletPlugin.init?.(config, runtime);
|
|
118
|
+
await evmPlugin.init?.(config, runtime);
|
|
119
|
+
await solanaPlugin.init?.(config, runtime);
|
|
120
|
+
registerDexScreenerSearchCategory(runtime);
|
|
121
|
+
await initBirdeyeAnalytics(runtime);
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export default walletPlugin;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ApprovalSummary, SignScope } from "../wallet/pending.js";
|
|
2
|
+
|
|
3
|
+
export interface PolicyEvaluation {
|
|
4
|
+
readonly kind: "ok" | "requires_approval" | "blocked";
|
|
5
|
+
readonly reason?: string;
|
|
6
|
+
readonly rule?: string;
|
|
7
|
+
readonly cooldownUntil?: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Business rules for size limits, allowlists, and cooldowns. Actions never
|
|
12
|
+
* inline policy checks — they delegate here after zod parse + plugin checks.
|
|
13
|
+
*/
|
|
14
|
+
export interface PolicyModule {
|
|
15
|
+
evaluate(
|
|
16
|
+
scope: SignScope,
|
|
17
|
+
summary: ApprovalSummary,
|
|
18
|
+
): Promise<PolicyEvaluation>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
IAgentRuntime,
|
|
3
|
+
Memory,
|
|
4
|
+
ProviderResult,
|
|
5
|
+
State,
|
|
6
|
+
} from "@elizaos/core";
|
|
7
|
+
|
|
8
|
+
export type HealthStatus = { ok: true } | { ok: false; reason: string };
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Typed venue / data-source adapter. Canonical actions dispatch into concrete
|
|
12
|
+
* provider classes registered on the runtime provider registry (Phase 2 wiring).
|
|
13
|
+
*
|
|
14
|
+
* See docs/architecture/wallet-and-trading.md §B.3.
|
|
15
|
+
*/
|
|
16
|
+
export interface CanonicalProvider {
|
|
17
|
+
readonly name: string;
|
|
18
|
+
readonly contextBudgetTokens: number;
|
|
19
|
+
|
|
20
|
+
getContext(
|
|
21
|
+
runtime: IAgentRuntime,
|
|
22
|
+
message: Memory,
|
|
23
|
+
state: State,
|
|
24
|
+
): Promise<ProviderResult>;
|
|
25
|
+
|
|
26
|
+
healthcheck(runtime: IAgentRuntime): Promise<HealthStatus>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { IAgentRuntime, Memory, Provider, State } from "@elizaos/core";
|
|
2
|
+
import type { WalletBackendService } from "../services/wallet-backend-service.js";
|
|
3
|
+
import {
|
|
4
|
+
StewardUnavailableError,
|
|
5
|
+
WalletBackendNotConfiguredError,
|
|
6
|
+
} from "../wallet/errors.js";
|
|
7
|
+
|
|
8
|
+
const MAX_WALLET_TEXT_CHARS = 1000;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Injects live addresses into planner context. Always-on (200-token budget in spec).
|
|
12
|
+
*/
|
|
13
|
+
export const unifiedWalletProvider: Provider = {
|
|
14
|
+
name: "wallet",
|
|
15
|
+
description:
|
|
16
|
+
"Unified non-custodial wallet — EVM + Solana addresses (@elizaos/plugin-wallet).",
|
|
17
|
+
descriptionCompressed:
|
|
18
|
+
"unifi non-custodial wallet EVM + Solana address (elizaos/plugin-wallet)",
|
|
19
|
+
contexts: ["finance", "crypto", "wallet"],
|
|
20
|
+
contextGate: { anyOf: ["finance", "crypto", "wallet"] },
|
|
21
|
+
cacheStable: false,
|
|
22
|
+
cacheScope: "turn",
|
|
23
|
+
roleGate: { minRole: "OWNER" },
|
|
24
|
+
position: -5,
|
|
25
|
+
dynamic: true,
|
|
26
|
+
get: async (runtime: IAgentRuntime, _message: Memory, _state: State) => {
|
|
27
|
+
void _message;
|
|
28
|
+
void _state;
|
|
29
|
+
const svc = runtime.getService(
|
|
30
|
+
"wallet-backend",
|
|
31
|
+
) as WalletBackendService | null;
|
|
32
|
+
if (!svc) {
|
|
33
|
+
return {
|
|
34
|
+
text: "## Wallet\nWallet backend service is not running.",
|
|
35
|
+
values: { walletReady: false },
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
const w = svc.getWalletBackend();
|
|
40
|
+
const { evm, solana } = w.getAddresses();
|
|
41
|
+
const evmLine = evm ? `- EVM: ${evm}` : "- EVM: (not configured)";
|
|
42
|
+
const solLine = solana
|
|
43
|
+
? `- Solana: ${solana.toBase58()}`
|
|
44
|
+
: "- Solana: (not configured)";
|
|
45
|
+
const text = `## Wallet\n${evmLine}\n${solLine}`.slice(
|
|
46
|
+
0,
|
|
47
|
+
MAX_WALLET_TEXT_CHARS,
|
|
48
|
+
);
|
|
49
|
+
return {
|
|
50
|
+
text,
|
|
51
|
+
values: {
|
|
52
|
+
walletReady: evm !== null || solana !== null,
|
|
53
|
+
evmAddress: evm ?? null,
|
|
54
|
+
solanaAddress: solana?.toBase58() ?? null,
|
|
55
|
+
backendKind: w.kind,
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
} catch (e) {
|
|
59
|
+
if (
|
|
60
|
+
e instanceof WalletBackendNotConfiguredError ||
|
|
61
|
+
e instanceof StewardUnavailableError
|
|
62
|
+
) {
|
|
63
|
+
return {
|
|
64
|
+
text: `## Wallet\n${e.message}`,
|
|
65
|
+
values: { walletReady: false, walletError: e.name },
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
text: `## Wallet\nWallet backend error: ${
|
|
70
|
+
e instanceof Error ? e.message : String(e)
|
|
71
|
+
}`,
|
|
72
|
+
values: {
|
|
73
|
+
walletReady: false,
|
|
74
|
+
walletError: e instanceof Error ? e.name : "WalletBackendError",
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Side-effect import: registers the @elizaos/plugin-wallet route plugin
|
|
3
|
+
* with the runtime app-route plugin registry. Imported by the API server
|
|
4
|
+
* at startup so wallet HTTP routes are dispatched via Plugin.routes.
|
|
5
|
+
*/
|
|
6
|
+
import { registerAppRoutePluginLoader } from "@elizaos/core";
|
|
7
|
+
|
|
8
|
+
registerAppRoutePluginLoader("@elizaos/plugin-wallet:routes", async () => {
|
|
9
|
+
const { walletRoutePlugin } = await import("./routes/plugin");
|
|
10
|
+
return walletRoutePlugin;
|
|
11
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wallet route plugin — registers wallet HTTP route handlers with the
|
|
3
|
+
* elizaOS runtime plugin route system.
|
|
4
|
+
*
|
|
5
|
+
* All routes use `rawPath: true` to preserve the legacy `/api/wallet/*`
|
|
6
|
+
* paths without a plugin-name prefix. This module is node-only — the main
|
|
7
|
+
* runtime plugin (services, actions, providers) lives in `../plugin.ts`
|
|
8
|
+
* and is browser-safe; this `plugin.ts` is loaded only on the server via
|
|
9
|
+
* `../register-routes.ts`.
|
|
10
|
+
*
|
|
11
|
+
* Migrated from packages/app-core/src/api/wallet-market-overview-route.ts.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import type http from "node:http";
|
|
15
|
+
import type { Plugin, Route } from "@elizaos/core";
|
|
16
|
+
import { handleWalletMarketOverviewRoute } from "./wallet-market-overview-route";
|
|
17
|
+
|
|
18
|
+
async function marketOverviewHandler(
|
|
19
|
+
req: unknown,
|
|
20
|
+
res: unknown,
|
|
21
|
+
_runtime: unknown,
|
|
22
|
+
): Promise<void> {
|
|
23
|
+
const httpReq = req as http.IncomingMessage;
|
|
24
|
+
const httpRes = res as http.ServerResponse;
|
|
25
|
+
await handleWalletMarketOverviewRoute(httpReq, httpRes);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const walletHttpRoutes: Route[] = [
|
|
29
|
+
// GET /api/wallet/market-overview — public cached market overview for
|
|
30
|
+
// wallet empty states and cloud feeds. The handler also responds to
|
|
31
|
+
// OPTIONS preflight with 204 and rejects other methods with 405.
|
|
32
|
+
{
|
|
33
|
+
type: "GET",
|
|
34
|
+
path: "/api/wallet/market-overview",
|
|
35
|
+
rawPath: true,
|
|
36
|
+
public: true,
|
|
37
|
+
name: "wallet-market-overview",
|
|
38
|
+
handler: marketOverviewHandler,
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
export const walletRoutePlugin: Plugin = {
|
|
43
|
+
name: "@elizaos/plugin-wallet:routes",
|
|
44
|
+
description:
|
|
45
|
+
"Wallet HTTP route handlers (market overview, etc.) — extracted from packages/app-core/src/api.",
|
|
46
|
+
routes: walletHttpRoutes,
|
|
47
|
+
};
|