feat: per-request network override + 12 clause-builder intent tools#128
Draft
davidecarpini wants to merge 10 commits into
Draft
feat: per-request network override + 12 clause-builder intent tools#128davidecarpini wants to merge 10 commits into
davidecarpini wants to merge 10 commits into
Conversation
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…dd category filter - Extract VeBetterDAO addresses and IPFS gateway URL into src/constants - Split ABIs into src/services/abis (ERC20, ERC721 Enumerable, X-Allocation-Voting, X2EarnApps) - Move fetchJson and mapWithConcurrency into src/utils - Replace viem encode/decode and raw fetch with VeChain SDK Contract + executeMultipleClausesCall - Add categories filter to getVeBetterDaoApps (IPFS-backed, case-insensitive, OR semantics) - Add .cursor/rules/code-organization.mdc documenting src/ folder conventions Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…rDaoApps Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Introduces a central registry covering VeBetterDAO, Stargate and standard ERC20/721 contracts, plus four MCP tools to discover, inspect and interact with them: listKnownContracts, getContractAbi, callContract (multicall reads) and buildContractTransaction (multi-clause tx for wallet signing). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…cts-registry Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…apps-tool Co-authored-by: Cursor <cursoragent@cursor.com> # Conflicts: # src/constants/index.ts # src/services/vebetterdao-contracts.ts # src/tools/get-gm-nft-status.ts # src/tools/index.ts
The file was reintroduced by the merge with origin/main, but it is dead code: all consumers were migrated to `contracts-registry` in cffb561. Restoring the post-refactor state. Co-authored-by: Cursor <cursoragent@cursor.com>
Drop the @vechain/stargate-contracts-artifacts dependency in favor of four hand-vendored JSON files under src/services/contracts-registry/ stargate/. The upstream package buries the V4 contracts under deprecated/ and ships a broken ESM dist on Node 22, so vendoring just the abi[] is the cleanest path until they publish a flat artifacts layout. Shrinks the prod bundle from 2.19 MB to 414 KB (the package included bytecode + metadata we don't need) and removes the stargate entry from tsup `noExternal`. Co-authored-by: Cursor <cursoragent@cursor.com>
Make the server per-request network aware via AsyncLocalStorage so a single process can serve mainnet, testnet and solo at the same time, and add the 12 build*Clauses intent tools that own the previously backend-side clause encoding for token transfers, swaps, Stargate staking/delegation/rewards, and VeBetterDAO governance. - thor/config.ts: per-network ThorClient cache; getThorClient/Network/Url resolve from explicit override > request context > env default - thor/request-context.ts: AsyncLocalStorage with runWithRequestNetwork - server.ts: every registered tool gets `network` injected into its input shape and runs inside runWithRequestNetwork so env-default callers are unaffected and clients that pass `network` get a live override - contracts-registry: add vechainSwapRouter, wvet, vtho addresses and UNISWAP_V2_ROUTER_ABI; new "swap" category - new services/stargate-levels: STARGATE_LEVELS + resolveStargateLevel - new clause-builder service: types, units, encoders, onchain-reads, token-resolution shared by every build*Clauses tool - new tools: getStargateLevels, resolveVnsName, resolveToken, getCuratedStargateValidators, plus the 12 build*Clauses tools (all destructiveHint=true so the agent loop routes them to the SSE exec_clauses event) - tests/clause-parity: 27 unit tests asserting byte-equal parity with the legacy veworld-b3mo-backend clauseBuilder/* output - bump version to 2.0.0-alpha.0 (breaking: tool input shapes now expose `network`, intent tools are new public surface)
There was a problem hiding this comment.
8 Open source vulnerabilities detected - critical severity
Aikido detected 8 vulnerabilities across 4 packages, it includes 1 critical and 7 high vulnerabilities.
Details
Remediation Aikido suggests bumping the vulnerable packages to a safe version.
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Make the MCP server per-request network aware and add 12 new
build*Clausesintent tools so external agent loops (e.g.veworld-b3mo-backend) can stop carrying ABIs and clause encoding locally and delegate everything to this server.This is a breaking change (bumped to
2.0.0-alpha.0):networkfieldgetStargateLevels,resolveVnsName,resolveToken,getCuratedStargateValidators, plus 12build*ClausestoolsPer-request network awareness (Fase 1)
services/thor/request-context.ts—runWithRequestNetwork+getRequestNetworkbacked byAsyncLocalStorageservices/thor/config.ts— replaces the singletonThorClientwith aMap<ThorNetworkType, ThorClient>cache;getThorClient/getThorNetworkType/getThorNodeUrlnow resolve in order: explicit override → request context → env defaultserver.ts— every registered tool getsnetworkinjected into its input shape and runs insiderunWithRequestNetwork(network), so existing tools keep working with the env default while clients that passnetworkget a per-request override (no leak across concurrent requests, see parity tests)Registry primitives (Fase 2)
contracts-registry/addresses.ts— addvechainSwapRouter,wvet,vthofor mainnet/testnetcontracts-registry/abis.ts— addUNISWAP_V2_ROUTER_ABIcontracts-registry/index.ts— newswapcategory, three new entries (vechainSwapRouter,wvet,vtho)services/stargate-levels/—STARGATE_LEVELS+findStargateLevelById/ByTier/ByVet+resolveStargateLevelgetStargateLevels,resolveVnsName,resolveTokenCurated read tool (Fase 3)
getCuratedStargateValidators— wrapsgetValidators, applies the offline% filter and sorts bynftYieldsIfDelegatedNextCycle[tier]Clause builders (Fase 4)
New
services/clause-builder/shared module (types, units, encoders, on-chain reads, token resolution) + 12 new MCP tools, all withannotations.destructiveHint: trueandreadOnlyHint: falseso downstream agents can route them onto anexec_clausesevent:buildSendTokenClauses,buildSwapClausesbuildStargateStakeAndDelegateClauses,buildStargateDelegateClauses,buildStargateUndelegateClauses,buildStargateClaimRewardsClausesbuildB3trConvertToVot3Clauses,buildB3trConvertToB3trClauses,buildB3trCastAllocationVotesClauses,buildB3trClaimVoterRewardsClauses,buildB3trCastProposalVoteClauses,buildB3trDelegateVot3ClausesEach tool returns the canonical
{ ok, network, data: { clauses, summary, gasHint }, error? }shape. The server NEVER signs or broadcasts.Parity tests
tests/clause-parity/clause-parity.unit.test.ts— 27 unit tests asserting byte-equal parity with the legacyveworld-b3mo-backend/src/services/clauseBuilder/*output (transfer/approve selectors, exact stake amounts, allowance-conditional approve, tier-vs-amount validation, X-tier rejection, etc.).Test plan
npx tsupbuilds cleannpx jest tests/clause-parity/— 27/27 greentools/listreturns the new tools and thenetworkfield appears in every input schemabuildSendTokenClauseswithnetwork: "testnet"and verify the recipient/value/data match a known fixturenetworkoverrides do not leak the Thor client (mainnet/testnet caches stay independent)veworld-b3mo-backendagent loop works against this branch end-to-end