Skip to content

Commit db232e0

Browse files
authored
Merge pull request #154 from gnosis/development
Development
2 parents 6b6588e + 6df1d2f commit db232e0

File tree

113 files changed

+3090
-4975
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+3090
-4975
lines changed

.github/workflows/e2e-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616
strategy:
1717
matrix:
18-
node-version: [14.x]
18+
node-version: [16.x]
1919
steps:
2020
- uses: actions/checkout@v2
2121
- name: Use Node.js ${{ matrix.node-version }}

.github/workflows/test.yml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,29 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
node-version: [14.x]
10+
node-version: [16.x]
1111
steps:
1212
- uses: actions/checkout@v2
1313
- name: Use Node.js ${{ matrix.node-version }}
1414
uses: actions/setup-node@v1
1515
with:
1616
node-version: ${{ matrix.node-version }}
17-
- run: |
18-
yarn install
19-
yarn build
20-
yarn test
17+
18+
- name: Yarn cache
19+
uses: actions/cache@v2
20+
with:
21+
path: '**/node_modules'
22+
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
23+
24+
- name: Yarn install
25+
run: |
26+
mkdir .yarncache
27+
yarn install --cache-folder ./.yarncache --frozen-lockfile
28+
rm -rf .yarncache
29+
yarn cache clean
30+
31+
- name: Build
32+
run: yarn build
33+
34+
- name: Test
35+
run: yarn test

.github/workflows/test_V1_2_0.yml renamed to .github/workflows/test_ethers_V1_2_0.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Safe Core SDK Test (Safe v1.2.0)
1+
name: Safe Core SDK Test - Ethers - Safe v1.2.0
22
on: [push, pull_request]
33
env:
44
INFURA_KEY: ${{ secrets.INFURA_KEY }}
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
node-version: [14.x]
10+
node-version: [16.x]
1111
steps:
1212
- uses: actions/checkout@v2
1313
- name: Use Node.js ${{ matrix.node-version }}

.github/workflows/test_V1_3_0.yml renamed to .github/workflows/test_ethers_V1_3_0.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Safe Core SDK Test (Safe v1.3.0)
1+
name: Safe Core SDK Test - Ethers - Safe v1.3.0
22
on: [push, pull_request]
33
env:
44
INFURA_KEY: ${{ secrets.INFURA_KEY }}
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
node-version: [14.x]
10+
node-version: [16.x]
1111
steps:
1212
- uses: actions/checkout@v2
1313
- name: Use Node.js ${{ matrix.node-version }}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Safe Core SDK Test - Web3 - Safe v1.2.0
2+
on: [push, pull_request]
3+
env:
4+
INFURA_KEY: ${{ secrets.INFURA_KEY }}
5+
jobs:
6+
test:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
node-version: [16.x]
11+
steps:
12+
- uses: actions/checkout@v2
13+
- name: Use Node.js ${{ matrix.node-version }}
14+
uses: actions/setup-node@v1
15+
with:
16+
node-version: ${{ matrix.node-version }}
17+
- run: |
18+
yarn install
19+
yarn build
20+
cd packages/safe-core-sdk
21+
yarn test:hardhat:web3:v1.2.0
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Safe Core SDK Test - Web3 - Safe v1.3.0
2+
on: [push, pull_request]
3+
env:
4+
INFURA_KEY: ${{ secrets.INFURA_KEY }}
5+
jobs:
6+
test:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
node-version: [16.x]
11+
steps:
12+
- uses: actions/checkout@v2
13+
- name: Use Node.js ${{ matrix.node-version }}
14+
uses: actions/setup-node@v1
15+
with:
16+
node-version: ${{ matrix.node-version }}
17+
- run: |
18+
yarn install
19+
yarn build
20+
cd packages/safe-core-sdk
21+
yarn test:hardhat:web3:v1.3.0

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2021 Gnosis Ltd
3+
Copyright (c) 2021-2022 Gnosis Ltd
44

55
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:
66

README.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ Software developer tools that facilitate the interaction with the Gnosis Safe [c
66

77
| Package | Release | Description |
88
| ------- | :-----: | ----------- |
9-
| [safe-core-sdk](https://github.com/gnosis/safe-core-sdk/tree/master/packages/safe-core-sdk) | [![NPM Version](https://badge.fury.io/js/%40gnosis.pm%2Fsafe-core-sdk.svg)](https://badge.fury.io/js/%40gnosis.pm%2Fsafe-core-sdk) | TypeScript library that facilitates the interaction with the [Gnosis Safe contracts](https://github.com/gnosis/safe-contracts) |
10-
[safe-core-sdk-types](https://github.com/gnosis/safe-core-sdk/tree/master/packages/safe-core-sdk-types) | [![NPM Version](https://badge.fury.io/js/%40gnosis.pm%2Fsafe-core-sdk-types.svg)](https://badge.fury.io/js/%40gnosis.pm%2Fsafe-core-sdk-types) | Common types extracted from the [Safe Core SDK](https://github.com/gnosis/safe-core-sdk/tree/master/packages/safe-core-sdk) |
11-
[safe-service-client](https://github.com/gnosis/safe-core-sdk/tree/master/packages/safe-service-client) | [![NPM Version](https://badge.fury.io/js/%40gnosis.pm%2Fsafe-service-client.svg)](https://badge.fury.io/js/%40gnosis.pm%2Fsafe-service-client) | [Safe Transaction Service API](https://github.com/gnosis/safe-transaction-service) client library |
12-
[safe-ethers-adapters](https://github.com/gnosis/safe-core-sdk/tree/master/packages/safe-ethers-adapters) | [![NPM Version](https://badge.fury.io/js/%40gnosis.pm%2Fsafe-ethers-adapters.svg)](https://badge.fury.io/js/%40gnosis.pm%2Fsafe-ethers-adapters) | [Ethers](https://docs.ethers.io/v5/single-page/) adapter that facilitates the interaction with the [Gnosis Safe Services](https://github.com/gnosis/safe-transaction-service) |
13-
<!--
14-
| [safe-core-sdk-app](https://github.com/gnosis/safe-core-sdk/tree/master/packages/safe-core-sdk-app) | - | Example Dapp that uses the [Safe Core SDK](https://github.com/gnosis/safe-core-sdk/tree/master/packages/safe-core-sdk) |
15-
|
16-
-->
9+
| [safe-core-sdk](https://github.com/gnosis/safe-core-sdk/tree/main/packages/safe-core-sdk) | [![NPM Version](https://badge.fury.io/js/%40gnosis.pm%2Fsafe-core-sdk.svg)](https://badge.fury.io/js/%40gnosis.pm%2Fsafe-core-sdk) | TypeScript library that facilitates the interaction with the [Gnosis Safe contracts](https://github.com/gnosis/safe-contracts) |
10+
[safe-core-sdk-types](https://github.com/gnosis/safe-core-sdk/tree/main/packages/safe-core-sdk-types) | [![NPM Version](https://badge.fury.io/js/%40gnosis.pm%2Fsafe-core-sdk-types.svg)](https://badge.fury.io/js/%40gnosis.pm%2Fsafe-core-sdk-types) | Common types extracted from the [Safe Core SDK](https://github.com/gnosis/safe-core-sdk/tree/main/packages) packages |
11+
[safe-ethers-lib](https://github.com/gnosis/safe-core-sdk/tree/main/packages/safe-ethers-lib) | [![NPM Version](https://badge.fury.io/js/%40gnosis.pm%2Fsafe-ethers-lib.svg)](https://badge.fury.io/js/%40gnosis.pm%2Fsafe-ethers-lib) | Ethers.js utilities and Safe contracts types (typechain ethers-v5) used to initialize the [Safe Core SDK](https://github.com/gnosis/safe-core-sdk/tree/main/packages/safe-core-sdk) |
12+
[safe-web3-lib](https://github.com/gnosis/safe-core-sdk/tree/main/packages/safe-web3-lib) | [![NPM Version](https://badge.fury.io/js/%40gnosis.pm%2Fsafe-web3-lib.svg)](https://badge.fury.io/js/%40gnosis.pm%2Fsafe-web3-lib) | Web3.js utilities and Safe contracts types (typechain web3-v1) used to initialize the [Safe Core SDK](https://github.com/gnosis/safe-core-sdk/tree/main/packages/safe-core-sdk) |
13+
[safe-service-client](https://github.com/gnosis/safe-core-sdk/tree/main/packages/safe-service-client) | [![NPM Version](https://badge.fury.io/js/%40gnosis.pm%2Fsafe-service-client.svg)](https://badge.fury.io/js/%40gnosis.pm%2Fsafe-service-client) | [Safe Transaction Service API](https://github.com/gnosis/safe-transaction-service) client library |
14+
[safe-ethers-adapters](https://github.com/gnosis/safe-core-sdk/tree/main/packages/safe-ethers-adapters) | [![NPM Version](https://badge.fury.io/js/%40gnosis.pm%2Fsafe-ethers-adapters.svg)](https://badge.fury.io/js/%40gnosis.pm%2Fsafe-ethers-adapters) | [Ethers](https://docs.ethers.io/v5/single-page/) adapter that facilitates the interaction with the [Gnosis Safe Services](https://github.com/gnosis/safe-transaction-service) |

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
"scripts": {
55
"clean": "lerna clean",
66
"unbuild": "lerna run unbuild",
7-
"build": "lerna run build --stream",
8-
"test": "FORCE_COLOR=1 lerna run test --stream",
9-
"test:ci": "FORCE_COLOR=1 lerna run test:ci --stream"
7+
"build": "lerna run build --stream --npm-client=yarn",
8+
"test": "FORCE_COLOR=1 lerna run test --stream --npm-client=yarn",
9+
"test:ci": "FORCE_COLOR=1 lerna run test:ci --stream --npm-client=yarn",
10+
"format": "lerna run format --npm-client=yarn",
11+
"postinstall": "cd packages/safe-ethers-lib; hardhat compile"
1012
},
1113
"workspaces": {
1214
"packages": [

packages/guides/integrating-the-safe-core-sdk.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ The [Safe Core SDK](https://github.com/gnosis/safe-core-sdk/tree/main/packages/s
4141

4242
* **Using ethers.js**
4343

44-
We can use the class `EthersAdapter` from `@gnosis.pm/safe-core-sdk` as the wrapper for `ethers.js`.
44+
We can use the class `EthersAdapter` from `@gnosis.pm/safe-ethers-lib` as the wrapper for `ethers.js`.
4545

4646
```js
47-
import { EthersAdapter } from '@gnosis.pm/safe-core-sdk'
47+
import EthersAdapter from '@gnosis.pm/safe-ethers-lib'
4848
import { ethers } from 'ethers'
4949

5050
const web3Provider = // ...
@@ -59,10 +59,10 @@ The [Safe Core SDK](https://github.com/gnosis/safe-core-sdk/tree/main/packages/s
5959

6060
* **Using web3.js**
6161

62-
We can use the class `Web3Adapter` from `@gnosis.pm/safe-core-sdk` as the wrapper for `web3.js`.
62+
We can use the class `Web3Adapter` from `@gnosis.pm/safe-web3-lib` as the wrapper for `web3.js`.
6363

6464
```js
65-
import { Web3Adapter } from '@gnosis.pm/safe-core-sdk'
65+
import Web3Adapter from '@gnosis.pm/safe-web3-lib'
6666
import Web3 from 'web3'
6767

6868
const ethAdapter = new Web3Adapter({
@@ -131,7 +131,7 @@ const safeAccountConfig: SafeAccountConfig = {
131131
threshold: 2,
132132
// ... (optional params)
133133
}
134-
const safeSdk = await safeFactory.deploySafe(safeAccountConfig)
134+
const safeSdk = await safeFactory.deploySafe({ safeAccountConfig })
135135
```
136136

137137
Calling the method `deploySafe` will deploy the desired Safe and return a Safe Core SDK initialized instance ready to be used.
@@ -213,6 +213,7 @@ Once we have the Safe transaction object we can share it with the other owners o
213213
- `safeTransaction`: The Safe transaction object returned from the method `createTransaction`. Make sure that this object includes the signature of the owner which is proposing it.
214214
- `safeTxHash`: The Safe transaction hash, calculated by calling the method `getTransactionHash` from the Safe Core SDK.
215215
- `senderAddress`: The Safe owner proposing the transaction.
216+
- `origin`: Optional string that allows to provide more information about the app proposing the transaction.
216217

217218
```js
218219
await safeSdk.signTransaction(safeTransaction)
@@ -221,7 +222,8 @@ await safeService.proposeTransaction({
221222
safeAddress,
222223
safeTransaction,
223224
safeTxHash,
224-
senderAddress
225+
senderAddress,
226+
origin
225227
})
226228
```
227229

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) 2021-2022 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.

packages/safe-core-sdk-types/package.json

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@gnosis.pm/safe-core-sdk-types",
3-
"version": "0.1.1",
3+
"version": "1.0.0",
44
"description": "Safe Core SDK types",
55
"main": "dist/src/index.js",
66
"typings": "dist/src/index.d.ts",
@@ -12,7 +12,9 @@
1212
],
1313
"scripts": {
1414
"unbuild": "rimraf dist *.tsbuildinfo",
15-
"build": "tsc"
15+
"build": "rimraf dist && tsc",
16+
"format": "prettier --write \"{src,tests}/**/*.ts\"",
17+
"lint": "tslint -p tsconfig.json"
1618
},
1719
"repository": {
1820
"type": "git",
@@ -24,10 +26,23 @@
2426
"url": "https://github.com/gnosis/safe-core-sdk/issues"
2527
},
2628
"files": [
27-
"dist/**/*"
29+
"dist"
2830
],
2931
"homepage": "https://github.com/gnosis/safe-core-sdk#readme",
3032
"devDependencies": {
31-
"typescript": "^4.2.4"
33+
"@types/node": "^17.0.13",
34+
"@typescript-eslint/eslint-plugin": "^5.10.1",
35+
"@typescript-eslint/parser": "^5.10.1",
36+
"eslint": "^8.7.0",
37+
"eslint-config-prettier": "^8.3.0",
38+
"eslint-plugin-prettier": "^4.0.0",
39+
"prettier": "^2.5.1",
40+
"typescript": "^4.5.5"
41+
},
42+
"dependencies": {
43+
"@ethersproject/bignumber": "^5.5.0",
44+
"@ethersproject/contracts": "^5.5.0",
45+
"@gnosis.pm/safe-deployments": "^1.8.0",
46+
"web3-core": "^1.7.0"
3247
}
3348
}

packages/safe-core-sdk/src/contracts/GnosisSafe/GnosisSafeContract.ts renamed to packages/safe-core-sdk-types/src/contracts/GnosisSafeContract.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import { BigNumber } from '@ethersproject/bignumber'
2-
import { SafeTransaction, SafeTransactionData } from '@gnosis.pm/safe-core-sdk-types'
3-
import { TransactionOptions, TransactionResult } from '../../utils/transactions/types'
2+
import {
3+
SafeTransaction,
4+
SafeTransactionData,
5+
SafeVersion,
6+
TransactionOptions,
7+
TransactionResult
8+
} from '../types'
49

5-
interface GnosisSafeContract {
6-
getVersion(): Promise<string>
10+
export interface GnosisSafeContract {
11+
getVersion(): Promise<SafeVersion>
712
getAddress(): string
813
getNonce(): Promise<number>
914
getThreshold(): Promise<number>
@@ -18,8 +23,6 @@ interface GnosisSafeContract {
1823
safeTransaction: SafeTransaction,
1924
options?: TransactionOptions
2025
): Promise<TransactionResult>
21-
encode(methodName: any, params: any): string
26+
encode(methodName: string, params: any): string
2227
estimateGas(methodName: string, params: any[], options: TransactionOptions): Promise<number>
2328
}
24-
25-
export default GnosisSafeContract
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { TransactionOptions } from '../../utils/transactions/types'
1+
import { TransactionOptions } from '../types'
22

33
export interface CreateProxyProps {
44
safeMasterCopyAddress: string
@@ -7,10 +7,9 @@ export interface CreateProxyProps {
77
options?: TransactionOptions
88
}
99

10-
interface GnosisSafeProxyFactory {
10+
export interface GnosisSafeProxyFactoryContract {
1111
getAddress(): string
1212
createProxy(options: CreateProxyProps): Promise<string>
1313
encode(methodName: string, params: any[]): string
14+
estimateGas(methodName: string, params: any[], options: TransactionOptions): Promise<number>
1415
}
15-
16-
export default GnosisSafeProxyFactory
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
interface MultiSendContract {
1+
export interface MultiSendContract {
22
getAddress(): string
33
encode(methodName: any, params: any): string
44
}
5-
6-
export default MultiSendContract
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import { BigNumber } from '@ethersproject/bignumber'
2+
import { SingletonDeployment } from '@gnosis.pm/safe-deployments'
3+
import { AbiItem } from 'web3-utils'
4+
import { GnosisSafeContract } from '../contracts/GnosisSafeContract'
5+
import { GnosisSafeProxyFactoryContract } from '../contracts/GnosisSafeProxyFactoryContract'
6+
import { MultiSendContract } from '../contracts/MultiSendContract'
7+
import { SafeVersion } from '../types'
8+
9+
export interface EthAdapterTransaction {
10+
to: string
11+
from: string
12+
data: string
13+
value?: string
14+
gasPrice?: number
15+
gasLimit?: number
16+
}
17+
18+
export interface GetContractProps {
19+
safeVersion: SafeVersion
20+
chainId: number
21+
singletonDeployment?: SingletonDeployment
22+
customContractAddress?: string
23+
customContractAbi?: AbiItem | AbiItem[]
24+
}
25+
26+
export interface EthAdapter {
27+
isAddress(address: string): boolean
28+
getBalance(address: string): Promise<BigNumber>
29+
getChainId(): Promise<number>
30+
getSafeContract({
31+
safeVersion,
32+
chainId,
33+
singletonDeployment,
34+
customContractAddress,
35+
customContractAbi
36+
}: GetContractProps): GnosisSafeContract
37+
getMultiSendContract({
38+
safeVersion,
39+
chainId,
40+
singletonDeployment,
41+
customContractAddress,
42+
customContractAbi
43+
}: GetContractProps): MultiSendContract
44+
getSafeProxyFactoryContract({
45+
safeVersion,
46+
chainId,
47+
singletonDeployment,
48+
customContractAddress,
49+
customContractAbi
50+
}: GetContractProps): GnosisSafeProxyFactoryContract
51+
getContractCode(address: string): Promise<string>
52+
isContractDeployed(address: string): Promise<boolean>
53+
getTransaction(transactionHash: string): Promise<any>
54+
getSignerAddress(): Promise<string>
55+
signMessage(message: string, signerAddress: string): Promise<string>
56+
estimateGas(
57+
transaction: EthAdapterTransaction,
58+
callback?: (error: Error, gas: number) => void
59+
): Promise<number>
60+
call(transaction: EthAdapterTransaction): Promise<string>
61+
}
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
export * from './types';
1+
export * from './contracts/GnosisSafeContract'
2+
export * from './contracts/GnosisSafeProxyFactoryContract'
3+
export * from './contracts/MultiSendContract'
4+
export * from './ethereumLibs/EthAdapter'
5+
export * from './types'

0 commit comments

Comments
 (0)