Skip to content
This repository has been archived by the owner on May 19, 2023. It is now read-only.

A sample app for the multisig project to help developers build dapps with the SDK transaction service.

Notifications You must be signed in to change notification settings

rsksmart/multisig-sample-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

logo

multisig-sample-app

Sample application for the RIF Savings and Vault project

npm Alerts Code Quality

Developer Resources:

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.

Setup:

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()

Creating and connecting

  • createSafe({ addresses, threshold }) - create a safe with addresses and threshold for executing transactions. Code Example
  • create(etheres, safeAddress, signer) - connect to a deployed safe. Code Example

Query the safe

  • safe.getBalance().then(console.log) - Returns a promise of the balance of the safe. Code Example
  • safe.getAddress() - Returns the safe address. Code Example
  • safe.getOwners() - Returns a promise with an array of addresses who are the owners of the safe. Code Example
  • safe.getThreshold() - Returns a promise with the number of signatures required to execute a transaction. Code Example

Policy Updates

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 example
  • getAddOwner(address, threshold) - Add an owner and update the threshold if needed. Code example
  • getRemoveOwnerTx(address, threshold) - Remove an owher and update the threshold if needed. Code Example
  • getSwapOwnerTx(address) - Swap one owner for another. Code Example

Transactions

  • createTransaction({ to, value, nonce, data }) - Create a transaction. Code Example
  • approveTransactionHash(txHash) - approve a transaction on-chain using its hash. See example on how to get the hash of a transaction. Code Example
  • executeTransaction(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 Example
  • rejectTx(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

Available Scripts

yarn

Install project dependencies

Available Scripts

In the project directory, you can run:

yarn start

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.

yarn test

Runs the tests, displays coverage, and runs the linter. See below for more specific commands

yarn test:watch

Launches the test runner in the interactive watch mode.

yarn test:coverage

Runs the test coverage and saves the report in thecoverage folder.

yarn lint

Runs the linter and returns status.

yarn build

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.

CI scripts

yarn test:ci

Runs the test coverage and saves the report in thereports folder. Uses maxWorkers=2 - CircleCI recommendation

yarn test:ci

Runs the linter and saves the report in thereports folder.

Knowledge base

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.