Companion library for ser, the smart execution router.
Features:
- query execution routes from ser
- rank execution routes for choosing the most frictionless alternative
- encode calls through a given execution route
Avatar – The smart contract account that is being controlled
Initiator – The EOA that provides the signature for the transaction
Route – A list of waypoint along which the execution of the meta transaction flows, from the initiator to the avatar
Waypoint – Each waypoint represents a blockchain address. The waypoint properties identify the type of the account or contract at that address as well as how it is connected to the previous waypoint.
import { queryRoutes, rankRoutes, encodeExecution } from 'ser-kit'
// 1. retrieve all execution routes from `eoaSignerAddress` as initiator, controlling `safeAddress` as avatar
const routes = await queryRoutes(eoaSignerAddress, safeAddress)
// 2. choose the most frictionless route
const rankedRoutes = rankRoutes(routes)
const bestRoute = rankedRoutes[0]
// 3. determine actions for getting the transaction executed through that route
const actions = planExecution(metaTx, bestRoute)
// 4. execute these actions using the provided EIP-1193 provider
const state = [] // mutable execution state
const result = execute(actions, state, provider)
The execute
function sequentially executes the actions using the given provider.
It updates the given state array in place, so that the outcome of the action at index i
is written at state[i]
.
If execution fails half-way through the plan, the partial state can be passed as input when retrying so execution is picked at from that point on.
This project uses Bun, a fast all-in-one JavaScript runtime. To install bun follow the instructions at https://bun.sh/docs/installation.
Install through foundryup
: https://book.getfoundry.sh/getting-started/installation#using-foundryup
To install project dependencies:
bun install
To run tests:
bun test