Sample application for the RIF Savings and Vault project
This repo contains many of the functions available from the RSK Safe Factory SDK. Below is a list of the methods and where they are implemented.
The SDK uses etheres to connect with the web3Provider. Many of the examples below assume that you have a provider and/or a signer available. In this repo we are using rLogin to get the web3Provider.
import { ethers } from 'ethers'
// ...
const provider = new ethers.providers.Web3Provider(web3Provider)
const signer = provider.getSigner()
createSafe({ addresses, threshold })
- create a safe with addresses and threshold for executing transactions. Code Examplecreate(etheres, safeAddress, signer)
- connect to a deployed safe. Code Example
safe.getBalance().then(console.log)
- Returns a promise of the balance of the safe. Code Examplesafe.getAddress()
- Returns the safe address. Code Examplesafe.getOwners()
- Returns a promise with an array of addresses who are the owners of the safe. Code Examplesafe.getThreshold()
- Returns a promise with the number of signatures required to execute a transaction. Code Example
All of the following return a transaction that needs to be signed and then executed (see under transactions).
getChangeThresholdTx(number)
- Change the number of signers required to execute a transaction. Code examplegetAddOwner(address, threshold)
- Add an owner and update the threshold if needed. Code examplegetRemoveOwnerTx(address, threshold)
- Remove an owher and update the threshold if needed. Code ExamplegetSwapOwnerTx(address)
- Swap one owner for another. Code Example
createTransaction({ to, value, nonce, data })
- Create a transaction. Code ExampleapproveTransactionHash(txHash)
- approve a transaction on-chain using its hash. See example on how to get the hash of a transaction. Code ExampleexecuteTransaction(safe, transaction)
- execute a transaction that has the proper number of approvers. Uses the SDK which fixes the gas limit if you are on the RSK network. Code ExamplerejectTx(safe, transaction)
Create a rejection transaction, which is a zero value transaction to the safe with the same nonce as the given transaction. Code Example
Install project dependencies
In the project directory, you can run:
Runs the app in the development mode. Open http://localhost:3000 to view it in the browser.
The page will reload if you make edits. You will also see any lint errors in the console.
Runs the tests, displays coverage, and runs the linter. See below for more specific commands
Launches the test runner in the interactive watch mode.
Runs the test coverage and saves the report in thecoverage
folder.
Runs the linter and returns status.
Builds the app for production to the build
folder.
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.
Your app is ready to be deployed!
See the section about deployment for more information.
Runs the test coverage and saves the report in thereports
folder. Uses maxWorkers=2
- CircleCI recommendation
Runs the linter and saves the report in thereports
folder.
This project was bootstrapped with the Typescript tempalte of Create React App and added Eslint, CircleCI, and Enzyme testing utility.
Current React.js version: v17.0.1
, but Enzyme is set up for v16
- this will be upgraded when Enzyme releases a new version.