Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@resolverworks/ezccip

Package Overview
Dependencies
Maintainers
3
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@resolverworks/ezccip

Turnkey CCIP-Read Handler

Source
npmnpm
Version
0.0.7
Version published
Weekly downloads
20
100%
Maintainers
3
Weekly downloads
 
Created
Source

ezccip.js

Turnkey CCIP-Read Handler for ENS

npm i @resolverworks/ezccip

  • see types / uses ethers
  • implements TheOffchainResolver.sol protocol
  • used by TheOffchainGateway.js
  • works with enson.js
  • supports Multicall-over-CCIP-Read
    • resolve(multicall(...))
    • multicall(resolve(...))
    • multicall(resolve(multicall(...)), ...)
  • use serve() to quickly launch a server
import {EZCCIP} from '@resolverworks/ezccip';

let ezccip = new EZCCIP();

// implement a wildcard ENSIP-10 resolver
ezccip.enableENSIP10(async (name, context) => {
    return {
        async text(key) {
            switch (key) {
                case 'name': return 'Raffy';
                case 'avatar': return 'https://raffy.antistupid.com/ens.jpg';
            }
        },
    };
});

// implement an arbitrary function
ezccip.register('add(uint256, uint256) returns (uint256)', ([a, b]) => [a + b]);

// imagine: your HTTP server has a request for CCIP-Read from GET or POST
let {sender, data: calldata} = JSON.parse(req.body);
let {data, history} = await ezccip.handleRead(sender, calldata, {
    signingKey, // your private key
    resolver, // any TOR deployment
    // all other values are considered "context" passed to each handler
    thing: 1,
});
reply.json({data});

Demo

  • npm run start
    • The demo.js server will print:

      0xd00d726b2aD6C81E894DC6B87BE6Ce9c5572D2cd http://localhost:8016
        ""0x828ec5bDe537B8673AF98D77bCB275ae1CA26D1f ← Mainnet
      "s"0x9Ec7f2ce83fcDF589487303fA9984942EF80Cb39 ← Sepolia
      "g"0x9b87849Aa21889343b6fB1E146f9F734ecFA9982 ← Goerli

    • Those keys correspond to the TOR deployment on each chain.
    • The above configuration implies following CONTEXT:
      • Mainnet: 0xd00d726b2aD6C81E894DC6B87BE6Ce9c5572D2cd http://localhost:8016/
      • Sepolia: 0xd00d726b2aD6C81E894DC6B87BE6Ce9c5572D2cd http://localhost:8016/s/key
  • set CONTEXT

Examples

  • DNS: ezccip.raffy.xyz
    • Context: 0xd00d726b2aD6C81E894DC6B87BE6Ce9c5572D2cd https://raffy.xyz/ezccip/
  • ENS: ezccip.eth
    • Context: 0xd00d726b2aD6C81E894DC6B87BE6Ce9c5572D2cd https://raffy.xyz/ezccip/s

Keywords

ENS

FAQs

Package last updated on 12 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts