Skip to content

Commit

Permalink
Merge pull request #154 from gnosis/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
germartinez authored Feb 1, 2022
2 parents 6b6588e + 6df1d2f commit db232e0
Show file tree
Hide file tree
Showing 113 changed files with 3,090 additions and 4,975 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
node-version: [16.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
Expand Down
25 changes: 20 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,29 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
node-version: [16.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: |
yarn install
yarn build
yarn test

- name: Yarn cache
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}

- name: Yarn install
run: |
mkdir .yarncache
yarn install --cache-folder ./.yarncache --frozen-lockfile
rm -rf .yarncache
yarn cache clean
- name: Build
run: yarn build

- name: Test
run: yarn test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Safe Core SDK Test (Safe v1.2.0)
name: Safe Core SDK Test - Ethers - Safe v1.2.0
on: [push, pull_request]
env:
INFURA_KEY: ${{ secrets.INFURA_KEY }}
Expand All @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
node-version: [16.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Safe Core SDK Test (Safe v1.3.0)
name: Safe Core SDK Test - Ethers - Safe v1.3.0
on: [push, pull_request]
env:
INFURA_KEY: ${{ secrets.INFURA_KEY }}
Expand All @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
node-version: [16.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/test_web3_V1_2_0.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Safe Core SDK Test - Web3 - Safe v1.2.0
on: [push, pull_request]
env:
INFURA_KEY: ${{ secrets.INFURA_KEY }}
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: |
yarn install
yarn build
cd packages/safe-core-sdk
yarn test:hardhat:web3:v1.2.0
21 changes: 21 additions & 0 deletions .github/workflows/test_web3_V1_3_0.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Safe Core SDK Test - Web3 - Safe v1.3.0
on: [push, pull_request]
env:
INFURA_KEY: ${{ secrets.INFURA_KEY }}
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: |
yarn install
yarn build
cd packages/safe-core-sdk
yarn test:hardhat:web3:v1.3.0
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 Gnosis Ltd
Copyright (c) 2021-2022 Gnosis Ltd

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:

Expand Down
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ Software developer tools that facilitate the interaction with the Gnosis Safe [c

| Package | Release | Description |
| ------- | :-----: | ----------- |
| [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) |
[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) |
[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 |
[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) |
<!--
| [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) |
|
-->
| [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) |
[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 |
[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) |
[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) |
[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 |
[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) |
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
"scripts": {
"clean": "lerna clean",
"unbuild": "lerna run unbuild",
"build": "lerna run build --stream",
"test": "FORCE_COLOR=1 lerna run test --stream",
"test:ci": "FORCE_COLOR=1 lerna run test:ci --stream"
"build": "lerna run build --stream --npm-client=yarn",
"test": "FORCE_COLOR=1 lerna run test --stream --npm-client=yarn",
"test:ci": "FORCE_COLOR=1 lerna run test:ci --stream --npm-client=yarn",
"format": "lerna run format --npm-client=yarn",
"postinstall": "cd packages/safe-ethers-lib; hardhat compile"
},
"workspaces": {
"packages": [
Expand Down
14 changes: 8 additions & 6 deletions packages/guides/integrating-the-safe-core-sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ The [Safe Core SDK](https://github.com/gnosis/safe-core-sdk/tree/main/packages/s

* **Using ethers.js**

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

```js
import { EthersAdapter } from '@gnosis.pm/safe-core-sdk'
import EthersAdapter from '@gnosis.pm/safe-ethers-lib'
import { ethers } from 'ethers'

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

* **Using web3.js**

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

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

const ethAdapter = new Web3Adapter({
Expand Down Expand Up @@ -131,7 +131,7 @@ const safeAccountConfig: SafeAccountConfig = {
threshold: 2,
// ... (optional params)
}
const safeSdk = await safeFactory.deploySafe(safeAccountConfig)
const safeSdk = await safeFactory.deploySafe({ safeAccountConfig })
```

Calling the method `deploySafe` will deploy the desired Safe and return a Safe Core SDK initialized instance ready to be used.
Expand Down Expand Up @@ -213,6 +213,7 @@ Once we have the Safe transaction object we can share it with the other owners o
- `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.
- `safeTxHash`: The Safe transaction hash, calculated by calling the method `getTransactionHash` from the Safe Core SDK.
- `senderAddress`: The Safe owner proposing the transaction.
- `origin`: Optional string that allows to provide more information about the app proposing the transaction.

```js
await safeSdk.signTransaction(safeTransaction)
Expand All @@ -221,7 +222,8 @@ await safeService.proposeTransaction({
safeAddress,
safeTransaction,
safeTxHash,
senderAddress
senderAddress,
origin
})
```

Expand Down
9 changes: 9 additions & 0 deletions packages/safe-core-sdk-types/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
MIT License

Copyright (c) 2021-2022 Gnosis Ltd

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:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

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.
23 changes: 19 additions & 4 deletions packages/safe-core-sdk-types/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gnosis.pm/safe-core-sdk-types",
"version": "0.1.1",
"version": "1.0.0",
"description": "Safe Core SDK types",
"main": "dist/src/index.js",
"typings": "dist/src/index.d.ts",
Expand All @@ -12,7 +12,9 @@
],
"scripts": {
"unbuild": "rimraf dist *.tsbuildinfo",
"build": "tsc"
"build": "rimraf dist && tsc",
"format": "prettier --write \"{src,tests}/**/*.ts\"",
"lint": "tslint -p tsconfig.json"
},
"repository": {
"type": "git",
Expand All @@ -24,10 +26,23 @@
"url": "https://github.com/gnosis/safe-core-sdk/issues"
},
"files": [
"dist/**/*"
"dist"
],
"homepage": "https://github.com/gnosis/safe-core-sdk#readme",
"devDependencies": {
"typescript": "^4.2.4"
"@types/node": "^17.0.13",
"@typescript-eslint/eslint-plugin": "^5.10.1",
"@typescript-eslint/parser": "^5.10.1",
"eslint": "^8.7.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"prettier": "^2.5.1",
"typescript": "^4.5.5"
},
"dependencies": {
"@ethersproject/bignumber": "^5.5.0",
"@ethersproject/contracts": "^5.5.0",
"@gnosis.pm/safe-deployments": "^1.8.0",
"web3-core": "^1.7.0"
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { BigNumber } from '@ethersproject/bignumber'
import { SafeTransaction, SafeTransactionData } from '@gnosis.pm/safe-core-sdk-types'
import { TransactionOptions, TransactionResult } from '../../utils/transactions/types'
import {
SafeTransaction,
SafeTransactionData,
SafeVersion,
TransactionOptions,
TransactionResult
} from '../types'

interface GnosisSafeContract {
getVersion(): Promise<string>
export interface GnosisSafeContract {
getVersion(): Promise<SafeVersion>
getAddress(): string
getNonce(): Promise<number>
getThreshold(): Promise<number>
Expand All @@ -18,8 +23,6 @@ interface GnosisSafeContract {
safeTransaction: SafeTransaction,
options?: TransactionOptions
): Promise<TransactionResult>
encode(methodName: any, params: any): string
encode(methodName: string, params: any): string
estimateGas(methodName: string, params: any[], options: TransactionOptions): Promise<number>
}

export default GnosisSafeContract
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TransactionOptions } from '../../utils/transactions/types'
import { TransactionOptions } from '../types'

export interface CreateProxyProps {
safeMasterCopyAddress: string
Expand All @@ -7,10 +7,9 @@ export interface CreateProxyProps {
options?: TransactionOptions
}

interface GnosisSafeProxyFactory {
export interface GnosisSafeProxyFactoryContract {
getAddress(): string
createProxy(options: CreateProxyProps): Promise<string>
encode(methodName: string, params: any[]): string
estimateGas(methodName: string, params: any[], options: TransactionOptions): Promise<number>
}

export default GnosisSafeProxyFactory
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
interface MultiSendContract {
export interface MultiSendContract {
getAddress(): string
encode(methodName: any, params: any): string
}

export default MultiSendContract
61 changes: 61 additions & 0 deletions packages/safe-core-sdk-types/src/ethereumLibs/EthAdapter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { BigNumber } from '@ethersproject/bignumber'
import { SingletonDeployment } from '@gnosis.pm/safe-deployments'
import { AbiItem } from 'web3-utils'
import { GnosisSafeContract } from '../contracts/GnosisSafeContract'
import { GnosisSafeProxyFactoryContract } from '../contracts/GnosisSafeProxyFactoryContract'
import { MultiSendContract } from '../contracts/MultiSendContract'
import { SafeVersion } from '../types'

export interface EthAdapterTransaction {
to: string
from: string
data: string
value?: string
gasPrice?: number
gasLimit?: number
}

export interface GetContractProps {
safeVersion: SafeVersion
chainId: number
singletonDeployment?: SingletonDeployment
customContractAddress?: string
customContractAbi?: AbiItem | AbiItem[]
}

export interface EthAdapter {
isAddress(address: string): boolean
getBalance(address: string): Promise<BigNumber>
getChainId(): Promise<number>
getSafeContract({
safeVersion,
chainId,
singletonDeployment,
customContractAddress,
customContractAbi
}: GetContractProps): GnosisSafeContract
getMultiSendContract({
safeVersion,
chainId,
singletonDeployment,
customContractAddress,
customContractAbi
}: GetContractProps): MultiSendContract
getSafeProxyFactoryContract({
safeVersion,
chainId,
singletonDeployment,
customContractAddress,
customContractAbi
}: GetContractProps): GnosisSafeProxyFactoryContract
getContractCode(address: string): Promise<string>
isContractDeployed(address: string): Promise<boolean>
getTransaction(transactionHash: string): Promise<any>
getSignerAddress(): Promise<string>
signMessage(message: string, signerAddress: string): Promise<string>
estimateGas(
transaction: EthAdapterTransaction,
callback?: (error: Error, gas: number) => void
): Promise<number>
call(transaction: EthAdapterTransaction): Promise<string>
}
6 changes: 5 additions & 1 deletion packages/safe-core-sdk-types/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
export * from './types';
export * from './contracts/GnosisSafeContract'
export * from './contracts/GnosisSafeProxyFactoryContract'
export * from './contracts/MultiSendContract'
export * from './ethereumLibs/EthAdapter'
export * from './types'
Loading

0 comments on commit db232e0

Please sign in to comment.