Skip to content

Commit

Permalink
Merge pull request #278 from safe-global/development
Browse files Browse the repository at this point in the history
Merge `development` into `main`
  • Loading branch information
germartinez authored Nov 22, 2022
2 parents e77db75 + 6ce99ba commit b6d4580
Show file tree
Hide file tree
Showing 71 changed files with 4,286 additions and 1,559 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module.exports = {
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
extends: [
'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.
],
parserOptions: {
Expand Down
24 changes: 18 additions & 6 deletions guides/integrating-the-safe-core-sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,23 @@ If the Safe contracts are not deployed to your current network, the property `co
```js
import { ContractNetworksConfig } from '@gnosis.pm/safe-core-sdk'

const id = await ethAdapter.getChainId()
const chainId = await ethAdapter.getChainId()
const contractNetworks: ContractNetworksConfig = {
[id]: {
multiSendAddress: '<MULTI_SEND_ADDRESS>',
multiSendCallOnlyAddress: '<MULTI_SEND_CALL_ONLY_ADDRESS>',
[chainId]: {
safeMasterCopyAddress: '<MASTER_COPY_ADDRESS>',
safeProxyFactoryAddress: '<PROXY_FACTORY_ADDRESS>',
multiSendAddress: '<MULTI_SEND_ADDRESS>',
multiSendCallOnlyAddress: '<MULTI_SEND_CALL_ONLY_ADDRESS>',
fallbackHandlerAddress: '<FALLBACK_HANDLER_ADDRESS>',
signMessageLibAddress: '<SIGN_MESSAGE_LIB_ADDRESS>',
createCallAddress: '<CREATE_CALL_ADDRESS>',
safeMasterCopyAbi: '<MASTER_COPY_ABI>', // Optional. Only needed with web3.js
safeProxyFactoryAbi: '<PROXY_FACTORY_ABI>', // Optional. Only needed with web3.js
multiSendAbi: '<MULTI_SEND_ABI>', // Optional. Only needed with web3.js
multiSendCallOnlyAbi: '<MULTI_SEND_CALL_ONLY_ABI>', // Optional. Only needed with web3.js
safeMasterCopyAbi: '<MASTER_COPY_ABI>', // Optional. Only needed with web3.js
safeProxyFactoryAbi: '<PROXY_FACTORY_ABI>' // Optional. Only needed with web3.js
fallbackHandlerAbi: '<FALLBACK_HANDLER_ABI>', // Optional. Only needed with web3.js
signMessageLibAbi: '<SIGN_MESSAGE_LIB_ABI>', // Optional. Only needed with web3.js
createCallAbi: '<CREATE_CALL_ABI>' // Optional. Only needed with web3.js
}
}

Expand Down Expand Up @@ -321,6 +327,12 @@ const executeTxResponse = await safeSdk.executeTransaction(safeTransaction)
const receipt = executeTxResponse.transactionResponse && (await executeTxResponse.transactionResponse.wait())
```

Optionally, the `isValidTransaction` method, that returns a boolean value, could be called right before the `executeTransaction` method to check if the transaction will be executed successfully or not.

```js
const isValidTx = await safeSdk.isValidTransaction(safeTransaction)
```

## <a name="interface-checks">9. Interface checks</a>

During the process of collecting the signatures/executing transactions, some useful checks can be made in the interface to display or hide a button to confirm or execute the transaction depending on the current number of confirmations, the address of accounts that confirmed the transaction and the Safe threshold:
Expand Down
8 changes: 6 additions & 2 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"packages": ["packages/*"],
"npmClient": "yarn",
"version": "independent",
"useWorkspaces": true
"useWorkspaces": true,
"command": {
"run": {
"npmClient": "yarn"
}
}
}
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
"scripts": {
"clean": "lerna clean",
"unbuild": "lerna run unbuild",
"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",
"build": "lerna run build --stream",
"test": "FORCE_COLOR=1 lerna run test --stream",
"test:ci": "FORCE_COLOR=1 lerna run test:ci --stream",
"play": "ts-node ./playground",
"format": "lerna run format --npm-client=yarn",
"format": "lerna run format",
"postinstall": "cd packages/safe-ethers-lib; hardhat compile"
},
"workspaces": {
Expand All @@ -19,7 +19,7 @@
"author": "Safe (https://safe.global)",
"license": "MIT",
"devDependencies": {
"lerna": "^4.0.0",
"lerna": "^6.0.3",
"rimraf": "^3.0.2"
}
}
18 changes: 9 additions & 9 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": "1.6.1",
"version": "1.7.0",
"description": "Safe Core SDK types",
"main": "dist/src/index.js",
"typings": "dist/src/index.d.ts",
Expand Down Expand Up @@ -30,20 +30,20 @@
],
"homepage": "https://github.com/safe-global/safe-core-sdk#readme",
"devDependencies": {
"@types/node": "^18.7.18",
"@typescript-eslint/eslint-plugin": "^5.38.0",
"@typescript-eslint/parser": "^5.38.0",
"eslint": "^8.23.1",
"@types/node": "^18.11.9",
"@typescript-eslint/eslint-plugin": "^5.44.0",
"@typescript-eslint/parser": "^5.44.0",
"eslint": "^8.28.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"prettier": "^2.7.1",
"typescript": "^4.8.3"
"typescript": "^4.9.3"
},
"dependencies": {
"@ethersproject/bignumber": "^5.7.0",
"@ethersproject/contracts": "^5.7.0",
"@gnosis.pm/safe-deployments": "1.16.0",
"web3-core": "^1.8.0",
"web3-utils": "^1.8.0"
"@gnosis.pm/safe-deployments": "1.17.0",
"web3-core": "^1.8.1",
"web3-utils": "^1.8.1"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface CompatibilityFallbackHandlerContract {
getAddress(): string
encode(methodName: any, params: any): string
}
18 changes: 18 additions & 0 deletions packages/safe-core-sdk-types/src/contracts/CreateCallContract.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { TransactionOptions, TransactionResult } from '../types'

export interface CreateCallContract {
getAddress(): string
performCreate2(
value: string,
deploymentData: string,
salt: string,
options?: TransactionOptions
): Promise<TransactionResult>
performCreate(
value: string,
deploymentData: string,
options?: TransactionOptions
): Promise<TransactionResult>
encode(methodName: any, params: any): string
estimateGas(methodName: string, params: any[], options: TransactionOptions): Promise<number>
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ export interface GnosisSafeContract {
approveHash(hash: string, options?: TransactionOptions): Promise<TransactionResult>
getModules(): Promise<string[]>
isModuleEnabled(moduleAddress: string): Promise<boolean>
isValidTransaction(
safeTransaction: SafeTransaction,
options?: TransactionOptions
): Promise<boolean>
execTransaction(
safeTransaction: SafeTransaction,
options?: TransactionOptions
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { TransactionOptions, TransactionResult } from '../types'

export interface SignMessageLibContract {
getAddress(): string
signMessage(data: string, options?: TransactionOptions): Promise<TransactionResult>
getMessageHash(message: string): Promise<string>
encode(methodName: any, params: any): string
estimateGas(methodName: string, params: any[], options: TransactionOptions): Promise<number>
}
26 changes: 25 additions & 1 deletion packages/safe-core-sdk-types/src/ethereumLibs/EthAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { BigNumber } from '@ethersproject/bignumber'
import { SingletonDeployment } from '@gnosis.pm/safe-deployments'
import { AbiItem } from 'web3-utils'
import { CompatibilityFallbackHandlerContract } from '../contracts/CompatibilityFallbackHandlerContract'
import { CreateCallContract } from '../contracts/CreateCallContract'
import { GnosisSafeContract } from '../contracts/GnosisSafeContract'
import { GnosisSafeProxyFactoryContract } from '../contracts/GnosisSafeProxyFactoryContract'
import { MultiSendCallOnlyContract } from '../contracts/MultiSendCallOnlyContract'
import { MultiSendContract } from '../contracts/MultiSendContract'
import { SignMessageLibContract } from '../contracts/SignMessageLibContract'
import { Eip3770Address, SafeTransactionEIP712Args, SafeVersion } from '../types'

export interface EthAdapterTransaction {
Expand Down Expand Up @@ -54,18 +57,39 @@ export interface EthAdapter {
customContractAddress,
customContractAbi
}: GetContractProps): MultiSendCallOnlyContract
getCompatibilityFallbackHandlerContract({
safeVersion,
chainId,
singletonDeployment,
customContractAddress,
customContractAbi
}: GetContractProps): CompatibilityFallbackHandlerContract
getSafeProxyFactoryContract({
safeVersion,
chainId,
singletonDeployment,
customContractAddress,
customContractAbi
}: GetContractProps): GnosisSafeProxyFactoryContract
getSignMessageLibContract({
safeVersion,
chainId,
singletonDeployment,
customContractAddress,
customContractAbi
}: GetContractProps): SignMessageLibContract
getCreateCallContract({
safeVersion,
chainId,
singletonDeployment,
customContractAddress,
customContractAbi
}: GetContractProps): CreateCallContract
getContractCode(address: string, defaultBlock?: string | number): Promise<string>
isContractDeployed(address: string, defaultBlock?: string | number): Promise<boolean>
getStorageAt(address: string, position: string): Promise<string>
getTransaction(transactionHash: string): Promise<any>
getSignerAddress(): Promise<string>
getSignerAddress(): Promise<string | undefined>
signMessage(message: string): Promise<string>
signTypedData(
safeTransactionEIP712Args: SafeTransactionEIP712Args,
Expand Down
3 changes: 3 additions & 0 deletions packages/safe-core-sdk-types/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
export * from './contracts/CompatibilityFallbackHandlerContract'
export * from './contracts/CreateCallContract'
export * from './contracts/GnosisSafeContract'
export * from './contracts/GnosisSafeProxyFactoryContract'
export * from './contracts/MultiSendCallOnlyContract'
export * from './contracts/MultiSendContract'
export * from './contracts/SignMessageLibContract'
export * from './ethereumLibs/EthAdapter'
export * from './types'
28 changes: 14 additions & 14 deletions packages/safe-core-sdk-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gnosis.pm/safe-core-sdk-utils",
"version": "1.4.1",
"version": "1.5.0",
"description": "Safe Core SDK Utilities",
"main": "dist/src/index.js",
"typings": "dist/src/index.d.ts",
Expand Down Expand Up @@ -32,28 +32,28 @@
],
"homepage": "https://github.com/safe-global/safe-core-sdk#readme",
"devDependencies": {
"@gnosis.pm/safe-deployments": "1.16.0",
"@types/chai": "^4.3.3",
"@gnosis.pm/safe-deployments": "1.17.0",
"@types/chai": "^4.3.4",
"@types/chai-as-promised": "^7.1.5",
"@types/mocha": "^9.1.1",
"@types/node": "^18.7.18",
"@types/semver": "^7.3.12",
"@typescript-eslint/eslint-plugin": "^5.38.0",
"@typescript-eslint/parser": "^5.38.0",
"chai": "^4.3.6",
"@types/mocha": "^10.0.0",
"@types/node": "^18.11.9",
"@types/semver": "^7.3.13",
"@typescript-eslint/eslint-plugin": "^5.44.0",
"@typescript-eslint/parser": "^5.44.0",
"chai": "^4.3.7",
"chai-as-promised": "^7.1.1",
"eslint": "^8.23.1",
"eslint": "^8.28.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"mocha": "^10.0.0",
"mocha": "^10.1.0",
"nyc": "^15.1.0",
"prettier": "^2.7.1",
"ts-node": "^10.9.1",
"typescript": "^4.8.3"
"typescript": "^4.9.3"
},
"dependencies": {
"@gnosis.pm/safe-core-sdk-types": "^1.6.1",
"semver": "^7.3.7",
"web3-utils": "^1.8.0"
"semver": "^7.3.8",
"web3-utils": "^1.8.1"
}
}
25 changes: 24 additions & 1 deletion packages/safe-core-sdk-utils/src/eip-3770/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,32 @@ export const networks: NetworkShortName[] = [
{ chainId: 11, shortName: 'meta' },
{ chainId: 12, shortName: 'kal' },
{ chainId: 25, shortName: 'cro' },
{ chainId: 28, shortName: 'boba-rinkeby' },
{ chainId: 28, shortName: 'bobarinkeby' },
{ chainId: 40, shortName: 'telosevm' },
{ chainId: 41, shortName: 'telosevmtestnet' },
{ chainId: 42, shortName: 'kov' },
{ chainId: 56, shortName: 'bnb' },
{ chainId: 61, shortName: 'etc' },
{ chainId: 63, shortName: 'metc' },
{ chainId: 69, shortName: 'okov' },
{ chainId: 82, shortName: 'meter' },
{ chainId: 83, shortName: 'meter-test' },
{ chainId: 97, shortName: 'bnbt' },
{ chainId: 100, shortName: 'gno' },
{ chainId: 106, shortName: 'vlx' },
{ chainId: 111, shortName: 'etl' },
{ chainId: 122, shortName: 'fuse' },
{ chainId: 123, shortName: 'spark' },
{ chainId: 137, shortName: 'matic' },
{ chainId: 246, shortName: 'ewt' },
{ chainId: 250, shortName: 'ftm' },
{ chainId: 288, shortName: 'boba' },
{ chainId: 300, shortName: 'ogn' },
{ chainId: 321, shortName: 'kcs' },
{ chainId: 322, shortName: 'kcst' },
{ chainId: 336, shortName: 'sdn' },
{ chainId: 338, shortName: 'tcro' },
{ chainId: 420, shortName: 'ogor' },
{ chainId: 588, shortName: 'metis-stardust' },
{ chainId: 592, shortName: 'astr' },
{ chainId: 595, shortName: 'maca' },
Expand All @@ -41,11 +50,21 @@ export const networks: NetworkShortName[] = [
{ chainId: 1284, shortName: 'mbeam' },
{ chainId: 1285, shortName: 'mriver' },
{ chainId: 1287, shortName: 'mbase' },
{ chainId: 1294, shortName: 'bobabeam' },
{ chainId: 1807, shortName: 'rana' },
{ chainId: 1984, shortName: 'euntest' },
{ chainId: 2001, shortName: 'milkada' },
{ chainId: 2002, shortName: 'milkalgo' },
{ chainId: 2008, shortName: 'cloudwalk_testnet' },
{ chainId: 2019, shortName: 'pmint_test' },
{ chainId: 4002, shortName: 'tftm' },
{ chainId: 2020, shortName: 'pmint' },
{ chainId: 2221, shortName: 'tkava' },
{ chainId: 2222, shortName: 'kava' },
{ chainId: 4918, shortName: 'txvm' },
{ chainId: 4919, shortName: 'xvm' },
{ chainId: 7341, shortName: 'shyft' },
{ chainId: 7700, shortName: 'canto' },
{ chainId: 8217, shortName: 'cypress' },
{ chainId: 9000, shortName: 'evmos-testnet' },
{ chainId: 9001, shortName: 'evmos' },
Expand All @@ -54,16 +73,20 @@ export const networks: NetworkShortName[] = [
{ chainId: 11437, shortName: 'shyftt' },
{ chainId: 12357, shortName: 'rei-testnet' },
{ chainId: 42161, shortName: 'arb1' },
{ chainId: 42170, shortName: 'arb-nova' },
{ chainId: 42220, shortName: 'celo' },
{ chainId: 43113, shortName: 'fuji' },
{ chainId: 43114, shortName: 'avax' },
{ chainId: 47805, shortName: 'rei' },
{ chainId: 71401, shortName: 'gw-testnet-v1' },
{ chainId: 73799, shortName: 'vt' },
{ chainId: 80001, shortName: 'maticmum' },
{ chainId: 200101, shortName: 'milktada' },
{ chainId: 200202, shortName: 'milktalgo' },
{ chainId: 333999, shortName: 'olympus' },
{ chainId: 421611, shortName: 'arb-rinkeby' },
{ chainId: 421613, shortName: 'arb-goerli' },
{ chainId: 11155111, shortName: 'sep' },
{ chainId: 1313161554, shortName: 'aurora' },
{ chainId: 1313161555, shortName: 'aurora-testnet' },
{ chainId: 1666600000, shortName: 'hmy-s0' },
Expand Down
Loading

0 comments on commit b6d4580

Please sign in to comment.