Skip to content

SAFE-anwang/web3.js-plugin-safe4

Repository files navigation

Web3.js Safe4 Plugin

ES Version Node Version

This is a web3.js 4.x plugin for interacting with Safe4 contracts.

Prerequisites

Installation

yarn add @safe-anwang/web3.js-plugin-safe4

Using this plugin

Installing Version 4.x of web3

When adding the web3 package to your project, make sure to use version 4.x. You can append @4.0.2-dev.af57eae.0 tag to install the latest version of 4 that this plugin was tested with:

  • npm i -S web3@4.0.2-dev.af57eae.0
  • yarn add web3@4.0.2-dev.af57eae.0

NOTE
If 4.x was already released, you are good to just use web3 without appending anything to it.

To verify you have the correct web3 version installed, after adding the package to your project (the above commands), look at the versions listed in your project's package.json under the dependencies section, it should contain version 4.x similar to:

"dependencies": {
	"web3": "4.0.2-dev.af57eae.0"
}

Registering the Plugin with a web3.js Instance

After importing Safe4Plugin from @safe-anwang/web3.js-plugin-safe4 and Web3 from web3, register an instance of Safe4Plugin with an instance of Web3 like so:

import { Safe4Plugin } from "@safe-anwang/web3.js-plugin-safe4";
import { Web3 } from "web3";

const web3 = new Web3("YOUR_PROVIDER_URL");
const safe4Plugin = new Safe4Plugin();

web3.registerPlugin(safe4Plugin);

More information about registering web3.js plugins can be found here.

Plugin Methods

System Property Value

getValue

async getValue(name: string)

The getValue method, it's parameter is property name.

import { Web3 } from "web3";
import { Safe4Plugin } from "../../src";

const web3 = new Web3("YOUR_PROVIDER_URL");
const safe4Plugin = new Safe4Plugin();

web3.registerPlugin(safe4Plugin);

web3.safe4.sysproperty.getValue("block_space").then(console.log); // get value of property: block_space = 30

Found an issue or have a question or suggestion

  • ✍️ If you found an issue or have a question or suggestion submit an issue

Run the tests

  1. Clone the repo
  2. Run yarn to install dependencies
    • If you receive the following warning, please remove the file package-lock.json and make sure to run yarn to install dependencies instead of npm i:
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
  1. Run the tests:

Choose one of the following commands to run the mocked tests that do not make a network request using the Jest framework

yarn test
yarn test:unit
yarn test:all

Useful links

Package.json Scripts

Script Description
clean Uses rimraf to remove lib/ and dist/
prebuild Calls yarn clean
build Uses tsc to build all packages
lint Uses eslint to lint all packages
lint:fix Uses eslint to check and fix any warnings
format Uses prettier to format the code
test Uses jest to run unit tests in each package
test:unit Uses jest to run tests under /test/unit in each package

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published