@safe-anwang/web3.js-plugin-safe4
v0.1.5
Published
A Web3.js 4.x Plugin for Interacting With Safe4 Smart Contracts
Downloads
2
Readme
Web3.js Safe4 Plugin
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 [email protected]
yarn add [email protected]
NOTE
If 4.x was already released, you are good to just useweb3
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
- :writing_hand: If you found an issue or have a question or suggestion submit an issue
Run the tests
- Clone the repo
- Run
yarn
to install dependencies- If you receive the following warning, please remove the file
package-lock.json
and make sure to runyarn
to install dependencies instead ofnpm i
:
- If you receive the following warning, please remove the file
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.
- 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
- web3.js Documentation
- [Safe4 Documentation]
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 |