Skip to content

Commit

Permalink
Merge pull request #92 from gnosis/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
cag authored Sep 1, 2020
2 parents bd3e916 + f504058 commit 9f19bd0
Show file tree
Hide file tree
Showing 44 changed files with 5,647 additions and 3,328 deletions.
42 changes: 8 additions & 34 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,12 @@
module.exports = {
env: {
browser: true,
es6: true,
node: true,
},
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
'prettier/@typescript-eslint', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
'plugin:prettier/recommended', // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
parserOptions: {
ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features
sourceType: 'module', // Allows for the use of imports
},
parser: '@typescript-eslint/parser',
plugins: [
'@typescript-eslint',
],
root: true,
rules: {
'quotes': ['error', 'single'],
'indent': ['error', 2],
'max-len': ['error', {
'code': 100,
'tabWidth': 2,
'ignoreComments': false,
'ignoreRegExpLiterals': true,
'ignoreStrings': true,
'ignoreTemplateLiterals': true,
'ignoreUrls': true
}],
'semi': ['error', 'always'],
'no-unused-vars': ['error', {
'varsIgnorePattern': 'should|expect'
}]
}
};
}
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@ types/truffle-contracts

# Truffle
build/
migrations/*.js
migrations/*.js.map
migrations/*.d.ts

# Typechain for migrations
migrations/
4 changes: 0 additions & 4 deletions .npmignore

This file was deleted.

9 changes: 9 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"bracketSpacing": true,
"arrowParens": "always",
"printWidth": 100,
"trailingComma": "none",
"tabWidth": 2,
"semi": false,
"singleQuote": true
}
83 changes: 47 additions & 36 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,55 +1,66 @@
dist: xenial
os: linux
language: node_js

node_js:
- lts/dubnium

node_js: lts/dubnium
cache: yarn
services:
- docker

before_install:
- git clone https://github.com/gnosis/safe-relay-service.git
- cd safe-relay-service
- git checkout cpk-test
- docker-compose -f docker-compose.yml -f docker-compose.dev.yml build

install:
- yarn global add [email protected]
- yarn install

jobs:
include:
- name: Ganache
before_script:
- CONTAINER_ID=$(docker run -d -p 8545:8545 trufflesuite/ganache-cli)
- yarn wait-port -t 10000 localhost:8545
- CONTAINER_ID=$(docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d)
- ganache-cli -d --defaultBalanceEther 10000 -h 0.0.0.0 --noVMErrorsOnRPCResponse > /dev/null &
- sleep 60
script:
- yarn test
after_script:
- docker logs $CONTAINER_ID
- docker stop $CONTAINER_ID
- docker rm $CONTAINER_ID

- name: Ganache with --noVMErrorsOnRPCResponse
before_script:
- CONTAINER_ID=$(docker run -d -p 8545:8545 trufflesuite/ganache-cli --noVMErrorsOnRPCResponse)
- yarn wait-port -t 10000 localhost:8545
script:
- yarn test
after_script:
- docker logs $CONTAINER_ID
- docker stop $CONTAINER_ID
- docker rm $CONTAINER_ID
#- name: Ganache with --noVMErrorsOnRPCResponse
# before_script:
# - CONTAINER_ID=$(docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d)
# - sleep 60
# script:
# - yarn test-rpc
# after_script:
# - docker logs $CONTAINER_ID
# - docker stop $CONTAINER_ID
# - docker rm $CONTAINER_ID

- name: Geth
before_script:
- yarn geth-dev-assistant --accounts 2 --gasLimit 6721975
script:
- yarn test
after_script:
- docker stop geth-client
#- name: Geth
# before_script:
# - yarn geth-dev-assistant --accounts 2 --gasLimit 6721975
# script:
# - yarn test
# after_script:
# - docker stop geth-client

- name: OpenEthereum
before_script:
- PASSFILE=$(mktemp)
- echo '' > $PASSFILE
- chmod 644 $PASSFILE
- CONTAINER_ID=$(docker run -d -p 8545:8545 -p 8546:8546 -v $PASSFILE:$PASSFILE openethereum/openethereum --config dev --jsonrpc-interface=all --ws-interface=all --unlock 0x00a329c0648769a73afac7f9381e08fb43dbea72 --password $PASSFILE)
- yarn wait-port -t 10000 localhost:8545
script:
- yarn test
after_script:
- docker logs $CONTAINER_ID
- docker stop $CONTAINER_ID
- docker rm $CONTAINER_ID
#- name: OpenEthereum
# before_script:
# - PASSFILE=$(mktemp)
# - echo '' > $PASSFILE
# - chmod 644 $PASSFILE
# - CONTAINER_ID=$(docker run -d -p 8545:8545 -p 8546:8546 -v $PASSFILE:$PASSFILE openethereum/openethereum --config dev --jsonrpc-interface=all --ws-interface=all --unlock 0x00a329c0648769a73afac7f9381e08fb43dbea72 --password $PASSFILE)
# - yarn wait-port -t 10000 localhost:8545
# script:
# - yarn test
# after_script:
# - docker logs $CONTAINER_ID
# - docker stop $CONTAINER_ID
# - docker rm $CONTAINER_ID

after_success: yarn coverage
24 changes: 20 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ The proxy owner will be the account associated with the signer.

#### Networks configuration

Regardless of which type of underlying API is being used, the *CPK* instance will check the ID of the network given by the provider in order to prepare for contract interactions. By default, Ethereum mainnet (ID 1) and the Rinkeby (ID 4), Goerli (ID 5), and Kovan (ID 42) test networks will have preconfigured addresses for the required contracts:
Regardless of which type of underlying API is being used, the *CPK* instance will check the ID of the network given by the provider in order to prepare for contract interactions. By default, Ethereum Mainnet (ID 1) and the Rinkeby (ID 4), Goerli (ID 5), and Kovan (ID 42) test networks will have preconfigured addresses for the required contracts:

* `masterCopyAddress`: Gnosis Safe master copy
* `proxyFactoryAddress`: CPK factory
Expand All @@ -93,6 +93,22 @@ const cpk = await CPK.create({

Please refer to the `migrations/` folder of this package for information on how to deploy the required contracts on a network, and note that these addresses must be available for the connected network in order for *CPK* creation to be successful.

#### Transaction relayer configuration

By default, the CPK will not use any transaction relayer. However, the [Safe Relay Service](https://github.com/gnosis/safe-relay-service) can be used to submit all the transactions when the optional property `transactionManager` is passed to the CPK constructor with an instance of the class `SafeRelayTransactionManager`.

```js
const safeRelayTransactionManager = new SafeRelayTransactionManager({ url: 'https://safe-relay.gnosis.io/'})
const cpk = await CPK.create({
// ...otherOptions,
transactionManager: safeRelayTransactionManager,
});
```

The URL of the [Safe Relay Service](https://github.com/gnosis/safe-relay-service) is different depending on the network:
- Mainnet: https://safe-relay.gnosis.io/
- Rinkeby: https://safe-relay.rinkeby.gnosis.io/

### CPK#getOwnerAccount

This may be used to figure out which account the proxy considers the owner account. It returns a Promise which resolves to the owner account:
Expand All @@ -112,7 +128,7 @@ Once created, the `address` property on a *CPK* instance will provide the proxy'

This address is calculated even if the proxy has not been deployed yet, and it is deterministically generated from the proxy owner address. This means that for any given owner, the same proxy owner address will always be generated.

#### Support for WalletConnected Gnosis Safe
#### Support for connection to a Gnosis Safe

If the provider underlying the *CPK* instance is connected to a Gnosis Safe via WalletConnect, the address will match the owner account:

Expand Down Expand Up @@ -256,9 +272,9 @@ const txObject = await cpk.execTransactions(
);
```

#### Support for WalletConnected Gnosis Safe
#### Support for connection to a Gnosis Safe

When WalletConnected to Gnosis Safe, `execTransactions` will use the Safe's native support for sending batch transactions (via `gs_multi_send`). In this case, the gas price option is not available, and `execTransactions` will only return a transaction hash.
When connected to a Gnosis Safe, `execTransactions` will use the Safe's native support for sending batch transactions (via `gs_multi_send`). In this case, the gas price option is not available, and `execTransactions` will only return a transaction hash.

```js
const { hash } = await cpk.execTransactions([
Expand Down
File renamed without changes.
18 changes: 18 additions & 0 deletions migrations/1-deploy-contracts.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 38 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"name": "contract-proxy-kit",
"version": "1.1.1",
"version": "2.0.0-alpha.3",
"description": "Enable batched transactions and contract account interactions using a unique deterministic Gnosis Safe.",
"main": "src/index.ts",
"main": "lib/cjs/index.js",
"module": "lib/esm/index.js",
"scripts": {
"generate-types": "typechain --target=truffle-v5 './build/contracts/*.json'",
"postinstall": "truffle compile && yarn generate-types",
"migrate": "tsc -p ./tsconfig.migrate.json --outDir ./migrations && truffle migrate --network local",
"test-ts": "nyc mocha -t 5000 -r ts-node/register ./test/contract-proxy-kit.ts --exit",
"test": "yarn migrate && yarn test-ts",
"test-rpc": "run-with-testrpc --noVMErrorsOnRPCResponse 'yarn migrate && yarn test-ts'",
"test-ts": "TS_NODE_PROJECT='./tsconfig.cjs.json' nyc mocha -t 20000 -r ts-node/register -r jsdom-global/register ./test/contract-proxy-kit.ts --exit",
"test": "yarn generate-types && yarn migrate && yarn test-ts",
"test-rpc": "run-with-testrpc --noVMErrorsOnRPCResponse 'yarn test'",
"coverage": "nyc report --reporter=text-lcov | coveralls",
"lint:check": "eslint . --ext .js,.jsx,.ts,.tsx",
"lint:fix": "yarn lint:check --fix",
"typecheck": "tsc"
"format": "prettier-eslint --write $PWD/'src/**/*.{js,ts,json}' $PWD/'test/**/*.{js,ts,json}'",
"build": "tsc && tsc -p tsconfig.cjs.json",
"prepack": "yarn build"
},
"repository": {
"type": "git",
Expand All @@ -36,34 +36,52 @@
"bugs": {
"url": "https://github.com/gnosis/contract-proxy-kit/issues"
},
"files": [
"contracts",
"lib",
"src"
],
"homepage": "https://github.com/gnosis/contract-proxy-kit#readme",
"dependencies": {
"@gnosis.pm/safe-apps-sdk": "0.3.0",
"@truffle/contract": "^4.2.15",
"bignumber.js": "^9.0.0",
"node-fetch": "^2.6.0"
},
"devDependencies": {
"@gnosis.pm/conditional-tokens-contracts": "^0.5.4",
"@gnosis.pm/safe-contracts": "^1.1.1",
"@truffle/contract": "^4.2.8",
"@truffle/hdwallet-provider": "^1.0.35",
"@truffle/hdwallet-provider": "^1.0.40",
"@typechain/truffle-v5": "^2.0.2",
"@types/chai": "^4.2.11",
"@types/chai-as-promised": "^7.1.2",
"@types/mocha": "^7.0.2",
"@typescript-eslint/eslint-plugin": "^3.1.0",
"@typescript-eslint/parser": "^3.1.0",
"@types/chai": "^4.2.12",
"@types/chai-as-promised": "^7.1.3",
"@types/mocha": "^8.0.1",
"@types/node-fetch": "^2.5.7",
"@typescript-eslint/eslint-plugin": "^3.7.1",
"@typescript-eslint/parser": "^3.7.1",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"coveralls": "^3.1.0",
"dotenv": "^8.2.0",
"eslint": "^7.2.0",
"eslint": "^7.6.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-prettier": "^3.1.4",
"ethers-4": "npm:ethers@^4.0.45",
"ethers-5": "npm:ethers@^5.0.2",
"ganache-cli": "^6.9.1",
"geth-dev-assistant": "^0.1.4",
"geth-dev-assistant": "^0.1.5",
"jsdom": "^16.3.0",
"jsdom-global": "^3.0.2",
"nyc": "^15.1.0",
"prettier": "^2.0.5",
"prettier-eslint-cli": "^5.0.0",
"run-with-testrpc": "^0.3.1",
"should": "^13.2.3",
"truffle": "^5.1.29",
"truffle": "^5.1.37",
"truffle-typings": "^1.0.8",
"ts-node": "^8.10.2",
"typechain": "^2.0.0",
"typescript": "^3.9.5",
"typescript": "^3.9.7",
"wait-port": "^0.2.9",
"web3-1-2": "npm:web3@^1.2.6",
"web3-2-alpha": "npm:web3@^2.0.0-alpha.1"
Expand Down
Loading

0 comments on commit 9f19bd0

Please sign in to comment.