Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: 5afe/contract-proxy-kit
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 4246a9de8d8df1cbe2dc1d8a120fd2b2ec1943f9
Choose a base ref
..
head repository: 5afe/contract-proxy-kit
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: d6d2fdd01d165b2cc90bd0873fd0ff2b5f4d2f7d
Choose a head ref
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -9,11 +9,15 @@ Enable batched transactions and contract account interactions using a unique det

npm install contract-proxy-kit

## API Documentation
## Resources

[Method list](https://github.com/gnosis/contract-proxy-kit/tree/master/docs/cpk.md)
[Video introduction to Building with Safe Apps SDK & Contract Proxy Kit](https://www.youtube.com/watch?v=YGw8WfBw5OI)

[Architecture diagram](https://github.com/gnosis/contract-proxy-kit/tree/master/docs/CPKdiagram.png)
[CPK basic tutorial](https://docs.gnosis.io/safe/docs/cpktutorial1/)

[CPK API Documentation](https://github.com/gnosis/contract-proxy-kit/tree/master/docs/cpk.md)

[CPK architecture diagram](https://github.com/gnosis/contract-proxy-kit/tree/master/docs/CPKdiagram.png)

## Usage

31 changes: 0 additions & 31 deletions contracts/Migrations.sol

This file was deleted.

File renamed without changes
2 changes: 1 addition & 1 deletion docs/cpk.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# CPK methods
# CPK API Documentation

## create
```
14 changes: 6 additions & 8 deletions migrations-ts/1-deploy-contracts.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
module.exports = function(deployer: Truffle.Deployer, network: string) {
const deploy = (
name: string
): Truffle.Deployer => deployer.deploy(artifacts.require(name as any));
module.exports = function (deployer: Truffle.Deployer, network: string) {
const deploy = (name: any): Truffle.Deployer => deployer.deploy(artifacts.require(name))

['Migrations', 'CPKFactory'].forEach(deploy);
deploy('CPKFactory')

if (network === 'test' || network === 'local') {
[
;[
'GnosisSafe',
'GnosisSafeProxyFactory',
'MultiSend',
@@ -15,7 +13,7 @@ module.exports = function(deployer: Truffle.Deployer, network: string) {
'DailyLimitModule',
'ERC20Mintable',
'ConditionalTokens'
].forEach(deploy);
].forEach(deploy)
}

deployer.deploy(
@@ -27,4 +25,4 @@ module.exports = function(deployer: Truffle.Deployer, network: string) {
);
} as Truffle.Migration;

export {};
export {}
19 changes: 0 additions & 19 deletions migrations/1-deploy-contracts.js

This file was deleted.

32 changes: 16 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "contract-proxy-kit",
"version": "2.2.0-alpha.1",
"version": "2.2.0-alpha.3",
"description": "Enable batched transactions and contract account interactions using a unique deterministic Gnosis Safe.",
"main": "lib/cjs/index.js",
"module": "lib/esm/index.js",
@@ -43,34 +43,34 @@
],
"homepage": "https://github.com/gnosis/contract-proxy-kit#readme",
"dependencies": {
"@gnosis.pm/safe-apps-sdk": "^0.4.1",
"@truffle/contract": "^4.2.23",
"@gnosis.pm/safe-apps-sdk": "^0.4.2",
"@truffle/contract": "^4.2.26",
"@types/uuid": "^8.3.0",
"bignumber.js": "^9.0.0",
"bignumber.js": "^9.0.1",
"node-fetch": "^2.6.1",
"uuid": "^8.3.0"
"uuid": "^8.3.1"
},
"devDependencies": {
"@gnosis.pm/conditional-tokens-contracts": "^0.5.4",
"@gnosis.pm/safe-contracts": "gnosis/safe-contracts#development",
"@truffle/hdwallet-provider": "^1.1.0",
"@gnosis.pm/safe-contracts": "1.2.0",
"@truffle/hdwallet-provider": "^1.1.1",
"@typechain/truffle-v5": "^2.0.2",
"@types/chai": "^4.2.12",
"@types/chai": "^4.2.14",
"@types/chai-as-promised": "^7.1.3",
"@types/mocha": "^8.0.3",
"@types/node-fetch": "^2.5.7",
"@typescript-eslint/eslint-plugin": "^4.2.0",
"@typescript-eslint/parser": "^4.2.0",
"@typescript-eslint/eslint-plugin": "^4.5.0",
"@typescript-eslint/parser": "^4.5.0",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"coveralls": "^3.1.0",
"dotenv": "^8.2.0",
"eslint": "^7.10.0",
"eslint-config-prettier": "^6.12.0",
"eslint": "^7.11.0",
"eslint-config-prettier": "^6.13.0",
"eslint-plugin-prettier": "^3.1.4",
"ethers-4": "npm:ethers@^4.0.45",
"ethers-5": "npm:ethers@^5.0.14",
"ganache-cli": "^6.10.2",
"ethers-5": "npm:ethers@^5.0.18",
"ganache-cli": "^6.12.0",
"geth-dev-assistant": "^0.1.7",
"jsdom": "^16.4.0",
"jsdom-global": "^3.0.2",
@@ -79,10 +79,10 @@
"prettier-eslint-cli": "^5.0.0",
"run-with-testrpc": "^0.3.1",
"should": "^13.2.3",
"truffle": "^5.1.46",
"truffle": "^5.1.49",
"truffle-typings": "^1.0.8",
"ts-node": "^9.0.0",
"typechain": "^2.0.0",
"typechain": "^3.0.0",
"typescript": "^4.0.3",
"wait-port": "^0.2.9",
"web3-1-3": "npm:web3@^1.3.0",
9 changes: 3 additions & 6 deletions src/CPK.ts
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ import multiSendAbi from './abis/MultiSendAbi.json'
import { Address } from './utils/basicTypes'
import { predeterminedSaltNonce, sentinelModules } from './utils/constants'
import { joinHexData, getHexDataLength } from './utils/hexData'
import { OperationType, SendOptions, standardizeSafeAppsTransaction } from './utils/transactions'
import { OperationType, standardizeSafeAppsTransaction } from './utils/transactions'
import {
Transaction,
TransactionResult,
@@ -18,6 +18,7 @@ import {
StandardTransaction,
normalizeGasLimit
} from './utils/transactions'
import { checkConnectedToSafe } from './utils/checkConnectedToSafe'

export interface CPKConfig {
ethLibAdapter: EthLibAdapter
@@ -92,11 +93,7 @@ class CPK {

const ownerAccount = await this.getOwnerAccount()

const provider = this.#ethLibAdapter.getProvider()
const wc = provider && (provider.wc || (provider.connection && provider.connection.wc))
if (wc && wc.peerMeta && wc.peerMeta.name && wc.peerMeta.name.startsWith('Gnosis Safe')) {
this.#isConnectedToSafe = true
}
this.#isConnectedToSafe = await checkConnectedToSafe(this.#ethLibAdapter.getProvider())

this.#multiSend = this.#ethLibAdapter.getContract(multiSendAbi, network.multiSendAddress)

15 changes: 11 additions & 4 deletions src/config/networks.ts
Original file line number Diff line number Diff line change
@@ -15,27 +15,34 @@ export const defaultNetworks: NetworksConfig = {
masterCopyAddress: '0x34CfAC646f301356fAa8B21e94227e3583Fe3F5F',
proxyFactoryAddress: '0x0fB4340432e56c014fa96286de17222822a9281b',
multiSendAddress: '0x8D29bE29923b68abfDD21e541b9374737B49cdAD',
fallbackHandlerAddress: '0x40A930851BD2e590Bd5A5C981b436de25742E980'
fallbackHandlerAddress: '0xd5D82B6aDDc9027B22dCA772Aa68D5d74cdBdF44'
},
// rinkeby
4: {
masterCopyAddress: '0x34CfAC646f301356fAa8B21e94227e3583Fe3F5F',
proxyFactoryAddress: '0x336c19296d3989e9e0c2561ef21c964068657c38',
multiSendAddress: '0x8D29bE29923b68abfDD21e541b9374737B49cdAD',
fallbackHandlerAddress: '0x40A930851BD2e590Bd5A5C981b436de25742E980'
fallbackHandlerAddress: '0xd5D82B6aDDc9027B22dCA772Aa68D5d74cdBdF44'
},
// goerli
5: {
masterCopyAddress: '0x34CfAC646f301356fAa8B21e94227e3583Fe3F5F',
proxyFactoryAddress: '0xfC7577774887aAE7bAcdf0Fc8ce041DA0b3200f7',
multiSendAddress: '0x8D29bE29923b68abfDD21e541b9374737B49cdAD',
fallbackHandlerAddress: '0x40A930851BD2e590Bd5A5C981b436de25742E980'
fallbackHandlerAddress: '0xd5D82B6aDDc9027B22dCA772Aa68D5d74cdBdF44'
},
// kovan
42: {
masterCopyAddress: '0x34CfAC646f301356fAa8B21e94227e3583Fe3F5F',
proxyFactoryAddress: '0xfC7577774887aAE7bAcdf0Fc8ce041DA0b3200f7',
multiSendAddress: '0x8D29bE29923b68abfDD21e541b9374737B49cdAD',
fallbackHandlerAddress: '0x40A930851BD2e590Bd5A5C981b436de25742E980'
fallbackHandlerAddress: '0xd5D82B6aDDc9027B22dCA772Aa68D5d74cdBdF44'
},
// xdai
100: {
masterCopyAddress: '0x6851D6fDFAfD08c0295C392436245E5bc78B0185',
proxyFactoryAddress: '0xfC7577774887aAE7bAcdf0Fc8ce041DA0b3200f7',
multiSendAddress: '0x8D29bE29923b68abfDD21e541b9374737B49cdAD',
fallbackHandlerAddress: '0xd5D82B6aDDc9027B22dCA772Aa68D5d74cdBdF44'
}
}
9 changes: 7 additions & 2 deletions src/ethLibAdapters/EthersAdapter/EthersV4ContractAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { Contract } from '../EthLibAdapter'
import EthersAdapter, { EthersTransactionResult } from './'
import { CallOptions, SendOptions, normalizeGasLimit } from '../../utils/transactions'
import EthersAdapter from './'
import {
CallOptions,
SendOptions,
normalizeGasLimit,
EthersTransactionResult
} from '../../utils/transactions'
import { Address } from '../../utils/basicTypes'

class EthersContractAdapter implements Contract {
9 changes: 7 additions & 2 deletions src/ethLibAdapters/EthersAdapter/EthersV5ContractAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { Contract } from '../EthLibAdapter'
import EthersAdapter, { EthersTransactionResult } from './'
import { CallOptions, SendOptions, normalizeGasLimit } from '../../utils/transactions'
import EthersAdapter from './'
import {
CallOptions,
SendOptions,
normalizeGasLimit,
EthersTransactionResult
} from '../../utils/transactions'
import { Address } from '../../utils/basicTypes'

class EthersContractAdapter implements Contract {
12 changes: 4 additions & 8 deletions src/ethLibAdapters/EthersAdapter/index.ts
Original file line number Diff line number Diff line change
@@ -2,13 +2,11 @@ import EthLibAdapter, { Contract } from '../EthLibAdapter'
import EthersV4ContractAdapter from './EthersV4ContractAdapter'
import EthersV5ContractAdapter from './EthersV5ContractAdapter'
import {
TransactionResult,
CallOptions,
SendOptions,
EthCallTx,
formatCallTx,
EthSendTx,
normalizeGasLimit
normalizeGasLimit,
EthersTransactionResult
} from '../../utils/transactions'
import { zeroAddress } from '../../utils/constants'
import { Address, Abi } from '../../utils/basicTypes'
@@ -18,10 +16,6 @@ export interface EthersAdapterConfig {
signer: any
}

export interface EthersTransactionResult extends TransactionResult {
transactionResponse: Record<string, any>
}

class EthersAdapter extends EthLibAdapter {
ethers: any
signer: any
@@ -148,6 +142,8 @@ class EthersAdapter extends EthLibAdapter {
}

toSafeRelayTxResult(txHash: string, tx: Record<string, any>): Promise<EthersTransactionResult> {
tx['hash'] = tx['txHash']
delete tx['txHash']
return new Promise((resolve, reject) =>
resolve({
transactionResponse: new Promise((resolve, reject) => resolve(tx)),
9 changes: 7 additions & 2 deletions src/ethLibAdapters/Web3Adapter/Web3ContractAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { Contract } from '../EthLibAdapter'
import { Web3TransactionResult, toTxResult } from './'
import { SendOptions, CallOptions, normalizeGasLimit } from '../../utils/transactions'
import { toTxResult } from './'
import {
SendOptions,
CallOptions,
normalizeGasLimit,
Web3TransactionResult
} from '../../utils/transactions'
import { Address } from '../../utils/basicTypes'

class Web3ContractAdapter implements Contract {
11 changes: 4 additions & 7 deletions src/ethLibAdapters/Web3Adapter/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import EthLibAdapter, { Contract } from '../EthLibAdapter'
import Web3ContractAdapter from './Web3ContractAdapter'
import {
TransactionResult,
SendOptions,
EthCallTx,
formatCallTx,
EthSendTx,
normalizeGasLimit
normalizeGasLimit,
Web3TransactionResult
} from '../../utils/transactions'
import { Address, Abi } from '../../utils/basicTypes'

@@ -25,11 +25,6 @@ export interface Web3AdapterConfig {
web3: any
}

export interface Web3TransactionResult extends TransactionResult {
sendOptions?: SendOptions
promiEvent: Promise<any>
}

class Web3Adapter extends EthLibAdapter {
web3: any

@@ -151,6 +146,8 @@ class Web3Adapter extends EthLibAdapter {
}

toSafeRelayTxResult(txHash: string, tx: Record<string, any>): Promise<Web3TransactionResult> {
tx['transactionHash'] = tx['txHash']
delete tx['txHash']
return new Promise((resolve, reject) =>
resolve({
promiEvent: new Promise((resolve, reject) => resolve(tx)),
9 changes: 2 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import CPK, { CPKConfig } from './CPK'
import EthLibAdapter from './ethLibAdapters/EthLibAdapter'
import EthersAdapter, {
EthersAdapterConfig,
EthersTransactionResult
} from './ethLibAdapters/EthersAdapter'
import Web3Adapter, { Web3AdapterConfig, Web3TransactionResult } from './ethLibAdapters/Web3Adapter'
import EthersAdapter, { EthersAdapterConfig } from './ethLibAdapters/EthersAdapter'
import Web3Adapter, { Web3AdapterConfig } from './ethLibAdapters/Web3Adapter'
import TransactionManager, {
TransactionManagerConfig,
TransactionManagerNames
@@ -36,9 +33,7 @@ export type {
CPKConfig,
// EthLibAdapters
EthersAdapterConfig,
EthersTransactionResult,
Web3AdapterConfig,
Web3TransactionResult,
// TransactionManagers
TransactionManager,
TransactionManagerConfig,
Loading