Coder Social home page Coder Social logo

ser-kit's Introduction

ser-kit

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

Concepts

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.

Usage

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.

Contributing

Prerequisites

bun

This project uses Bun, a fast all-in-one JavaScript runtime. To install bun follow the instructions at https://bun.sh/docs/installation.

anvil

Install through foundryup: https://book.getfoundry.sh/getting-started/installation#using-foundryup

To install project dependencies:

bun install

To run tests:

bun test

ser-kit's People

Contributors

jfschwarz avatar

Watchers

samepant avatar Auryn Macmillan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.