Skip to content

Commit 6014bbd

Browse files
authored
Merge pull request #1 from gnosis/boostrap
Init project, add Allowance Module deployments
2 parents 1e38795 + 8483366 commit 6014bbd

File tree

14 files changed

+1789
-0
lines changed

14 files changed

+1789
-0
lines changed

.eslintrc.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser',
3+
extends: ['plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended'],
4+
parserOptions: {
5+
ecmaVersion: 2020,
6+
sourceType: 'module',
7+
},
8+
rules: {
9+
'@typescript-eslint/camelcase': 'off',
10+
'@typescript-eslint/no-var-requires': 'off',
11+
'@typescript-eslint/no-unused-vars': ['error', { ignoreRestSiblings: true }],
12+
},
13+
};

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
build/
2+
node_modules/
3+
.DS_Store
4+
.zos.session
5+
.openzeppelin/.session
6+
deployments/
7+
env/
8+
.env
9+
dist/
10+
bin/
11+
solc
12+
coverage/
13+
coverage.json
14+
yarn-error.log

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v16

.prettierrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"printWidth": 120,
3+
"trailingComma": "all",
4+
"singleQuote": true
5+
}

LICENSE

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
MIT License
2+
3+
Copyright (c) 2018 Gnosis Ltd
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Gnosis Safe Modules Deployments
2+
3+
[![npm version](https://badge.fury.io/js/%40gnosis.pm%2Fsafe-modules-deployments.svg)](https://badge.fury.io/js/%40gnosis.pm%2Fsafe-modules-deployments)
4+
5+
This contract contains a collection of deployments of audited contracts from the [Safe modules repository](https://github.com/gnosis/safe-modules).
6+
7+
For each deployment the address on the different networks and the abi files are available. To get an overview of the available versions check the available [json assets](./src/assets/).
8+
9+
To add additional deployments please follow the [deployment steps in the module folder in the Safe modules repository](https://github.com/gnosis/safe-modules).
10+
11+
## Install
12+
13+
- npm - `npm i @gnosis.pm/safe-modules-deployments`
14+
- yarn - `yarn add @gnosis.pm/safe-modules-deployments`
15+
16+
## Usage
17+
18+
It is possible to directly use the json files in the [assets folder](./src/assets/) that contain the addresses and abi definitions.
19+
20+
An alternative is to use the JavaScript library methods to query the correct deployment. The library supports different methods to get the deployment of a specific contract.
21+
22+
Each of the method takes an optional `DeploymentFilter` as a parameter.
23+
24+
```ts
25+
interface DeploymentFilter {
26+
version?: string;
27+
released?: boolean; // Defaults to true if no filter is specified
28+
network?: string; // Chain id of the network
29+
}
30+
```
31+
32+
The method will return a `SingletonDeployment` object or `undefined` if no deployment was found for the specified filter.
33+
34+
```ts
35+
interface SingletonDeployment {
36+
version: string;
37+
abi: any[];
38+
networkAddresses: Record<string, string>; // Address of the contract by network
39+
contractName: string;
40+
released: boolean; // A released version was audited and has a running bug bounty
41+
}
42+
```
43+
44+
- Allowance Module
45+
46+
```ts
47+
const allowanceModule = getAllowanceModuleDeployment();
48+
49+
// Returns latest contract version, even if not finally released yet
50+
const allowanceModuleNightly = getAllowanceModuleDeployment({ released: undefined });
51+
52+
// Returns released contract version for specific network
53+
const allowanceModuleGörli = getAllowanceModuleDeployment({ network: '5' });
54+
55+
// Returns released contract version for specific version
56+
const allowanceModule010 = getAllowanceModuleDeployment({ version: '0.1.0' });
57+
```
58+
59+
## Notes
60+
61+
A list of network information can be found at [chainid.network](https://chainid.network/)
62+
63+
## License
64+
65+
This library is released under MIT.

package.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"name": "@gnosis.pm/safe-modules-deployments",
3+
"version": "1.0.0",
4+
"description": "Collection of Safe Modules singleton deployments",
5+
"homepage": "https://github.com/gnosis/safe-modules-deployments/",
6+
"license": "MIT",
7+
"main": "dist/index.js",
8+
"typings": "dist/index.d.ts",
9+
"files": [
10+
"dist",
11+
"src",
12+
"test",
13+
"build"
14+
],
15+
"scripts": {
16+
"build": "yarn rimraf dist && tsc",
17+
"lint": "eslint --max-warnings 0 .",
18+
"prepack": "yarn build"
19+
},
20+
"repository": {
21+
"type": "git",
22+
"url": "git+https://github.com/gnosis/safe-modules-deployments.git"
23+
},
24+
"keywords": [
25+
"Ethereum",
26+
"Wallet",
27+
"Safe"
28+
],
29+
"author": "mikhail@gnosis.io",
30+
"bugs": {
31+
"url": "https://github.com/gnosis/safe-modules-deployments/issues"
32+
},
33+
"devDependencies": {
34+
"@types/node": "^14.14.21",
35+
"@typescript-eslint/eslint-plugin": "^5.10.1",
36+
"@typescript-eslint/parser": "^5.10.1",
37+
"eslint": "8.7.0",
38+
"eslint-config-prettier": "^8.3.0",
39+
"eslint-plugin-prettier": "^4.0.0",
40+
"prettier": "^2.1.2",
41+
"rimraf": "^3.0.2",
42+
"typescript": "^4.2.4"
43+
}
44+
}

src/allowance-module.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import AllowanceModule010 from './assets/allowance-module/v0.1.0/allowance-module.json';
2+
import { DeploymentFilter, SingletonDeployment } from './types';
3+
import { applyFilterDefaults, findDeployment } from './utils';
4+
5+
// The array should be sorted from the latest version to the oldest.
6+
const ALLOWANCE_MODULE_DEPLOYMENTS: SingletonDeployment[] = [AllowanceModule010];
7+
8+
export const getAllowanceModuleDeployment = (filter?: DeploymentFilter): SingletonDeployment | undefined => {
9+
return findDeployment(applyFilterDefaults(filter), ALLOWANCE_MODULE_DEPLOYMENTS);
10+
};

0 commit comments

Comments
 (0)