Skip to content

Commit

Permalink
Merge c04bb22 into bd9eeda
Browse files Browse the repository at this point in the history
  • Loading branch information
germartinez committed Jul 12, 2023
2 parents bd9eeda + c04bb22 commit 23cd67c
Show file tree
Hide file tree
Showing 90 changed files with 1,032 additions and 567 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test_contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
matrix:
node-version: [16.x]
provider: [ethers, web3]
contract-version: [v1.0.0, v1.1.1, v1.2.0, v1.3.0]
contract-version: [v1.0.0, v1.1.1, v1.2.0, v1.3.0, v1.4.1]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
Expand Down
4 changes: 2 additions & 2 deletions guides/integrating-the-safe-core-sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ const safeFactory = await SafeFactory.create({ ethAdapter })
const safeSdk = await Safe.create({ ethAdapter, safeAddress })
```

There are two versions of the Safe contracts: [GnosisSafe.sol](https://github.com/safe-global/safe-contracts/blob/v1.3.0/contracts/GnosisSafe.sol) that does not trigger events in order to save gas and [GnosisSafeL2.sol](https://github.com/safe-global/safe-contracts/blob/v1.3.0/contracts/GnosisSafeL2.sol) that does, which is more appropriate for L2 networks.
There are two versions of the Safe contracts: [Safe.sol](https://github.com/safe-global/safe-contracts/blob/v1.4.1/contracts/Safe.sol) that does not trigger events in order to save gas and [SafeL2.sol](https://github.com/safe-global/safe-contracts/blob/v1.4.1/contracts/SafeL2.sol) that does, which is more appropriate for L2 networks.

By default `GnosisSafe.sol` will be only used on Ethereum Mainnet. For the rest of the networks where the Safe contracts are already deployed, the `GnosisSafeL2.sol` contract will be used unless you add the property `isL1SafeMasterCopy` to force the use of the `GnosisSafe.sol` contract.
By default `Safe.sol` will be only used on Ethereum Mainnet. For the rest of the networks where the Safe contracts are already deployed, the `SafeL2.sol` contract will be used unless you add the property `isL1SafeMasterCopy` to force the use of the `Safe.sol` contract.

```js
const safeFactory = await SafeFactory.create({ ethAdapter, isL1SafeMasterCopy: true })
Expand Down
23 changes: 12 additions & 11 deletions packages/account-abstraction-kit/src/AccountAbstraction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,37 @@ import {
OperationType
} from '@safe-global/account-abstraction-kit-poc/types'
import Safe, {
predictSafeAddress,
encodeMultiSendData,
EthersAdapter,
getMultiSendCallOnlyContract,
getProxyFactoryContract,
getSafeContract,
PredictedSafeProps,
PREDETERMINED_SALT_NONCE,
PredictedSafeProps,
SAFE_LAST_VERSION,
SafeAccountConfig,
SafeDeploymentConfig,
encodeCreateProxyWithNonce,
SafeAccountConfig,
encodeSetupCallData
encodeMultiSendData,
encodeSetupCallData,
getMultiSendCallOnlyContract,
getProxyFactoryContract,
getSafeContract,
predictSafeAddress
} from '@safe-global/protocol-kit'
import { RelayPack } from '@safe-global/relay-kit'
import {
GnosisSafeProxyFactoryContract,
MetaTransactionData,
MetaTransactionOptions,
RelayTransaction,
SafeProxyFactoryContract,
SafeVersion
} from '@safe-global/safe-core-sdk-types'
import { ethers } from 'ethers'

const safeVersion: SafeVersion = '1.3.0'
const safeVersion: SafeVersion = SAFE_LAST_VERSION

class AccountAbstraction {
#ethAdapter: EthersAdapter
#signer: ethers.Signer
#safeSdk?: Safe
#safeProxyFactoryContract?: GnosisSafeProxyFactoryContract
#safeProxyFactoryContract?: SafeProxyFactoryContract
#relayPack?: RelayPack

constructor(signer: ethers.Signer) {
Expand Down
16 changes: 8 additions & 8 deletions packages/protocol-kit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ const safeFactory = await SafeFactory.create({ ethAdapter })
- The `isL1SafeMasterCopy` flag
There are two versions of the Safe contracts: [GnosisSafe.sol](https://github.com/safe-global/safe-contracts/blob/v1.3.0/contracts/GnosisSafe.sol) that does not trigger events in order to save gas and [GnosisSafeL2.sol](https://github.com/safe-global/safe-contracts/blob/v1.3.0/contracts/GnosisSafeL2.sol) that does, which is more appropriate for L2 networks.
There are two versions of the Safe contracts: [Safe.sol](https://github.com/safe-global/safe-contracts/blob/v1.4.1/contracts/Safe.sol) that does not trigger events in order to save gas and [SafeL2.sol](https://github.com/safe-global/safe-contracts/blob/v1.4.1/contracts/SafeL2.sol) that does, which is more appropriate for L2 networks.
By default `GnosisSafe.sol` will be only used on Ethereum Mainnet. For the rest of the networks where the Safe contracts are already deployed, the `GnosisSafeL2.sol` contract will be used unless you add the `isL1SafeMasterCopy` flag to force the use of the `GnosisSafe.sol` contract.
By default `Safe.sol` will be only used on Ethereum Mainnet. For the rest of the networks where the Safe contracts are already deployed, the `SafeL2.sol` contract will be used unless you add the `isL1SafeMasterCopy` flag to force the use of the `Safe.sol` contract.
```js
const safeFactory = await SafeFactory.create({ ethAdapter, isL1SafeMasterCopy: true })
Expand Down Expand Up @@ -205,7 +205,7 @@ const safeFactory = await SafeFactory.create({ ethAdapter })
- The `safeVersion` property
The `SafeFactory` constructor also accepts the `safeVersion` property to specify the Safe contract version that will be deployed. This string can take the values `1.0.0`, `1.1.1`, `1.2.0` or `1.3.0`. If not specified, the most recent contract version will be used by default.
The `SafeFactory` constructor also accepts the `safeVersion` property to specify the Safe contract version that will be deployed. This string can take the values `1.0.0`, `1.1.1`, `1.2.0`, `1.3.0` or `1.4.1`. If not specified, the most recent contract version will be used by default.
```js
const safeVersion = 'X.Y.Z'
Expand All @@ -214,7 +214,7 @@ const safeFactory = await SafeFactory.create({ ethAdapter })
### deploySafe
Deploys a new Safe and returns an instance of the Protocol Kit connected to the deployed Safe. The address of the Master Copy, Safe contract version and the contract (`GnosisSafe.sol` or `GnosisSafeL2.sol`) of the deployed Safe will depend on the initialization of the `safeFactory` instance.
Deploys a new Safe and returns an instance of the Protocol Kit connected to the deployed Safe. The address of the Master Copy, Safe contract version and the contract (`Safe.sol` or `SafeL2.sol`) of the deployed Safe will depend on the initialization of the `safeFactory` instance.
```js
const safeAccountConfig: SafeAccountConfig = {
Expand Down Expand Up @@ -317,9 +317,9 @@ const safeSdk = await Safe.create({ ethAdapter, predictedSafe })
- The `isL1SafeMasterCopy` flag
There are two versions of the Safe contracts: [GnosisSafe.sol](https://github.com/safe-global/safe-contracts/blob/v1.3.0/contracts/GnosisSafe.sol) that does not trigger events in order to save gas and [GnosisSafeL2.sol](https://github.com/safe-global/safe-contracts/blob/v1.3.0/contracts/GnosisSafeL2.sol) that does, which is more appropriate for L2 networks.
There are two versions of the Safe contracts: [Safe.sol](https://github.com/safe-global/safe-contracts/blob/v1.4.1/contracts/Safe.sol) that does not trigger events in order to save gas and [SafeL2.sol](https://github.com/safe-global/safe-contracts/blob/v1.4.1/contracts/SafeL2.sol) that does, which is more appropriate for L2 networks.
By default `GnosisSafe.sol` will be only used on Ethereum Mainnet. For the rest of the networks where the Safe contracts are already deployed, the `GnosisSafeL2.sol` contract will be used unless you add the `isL1SafeMasterCopy` flag to force the use of the `GnosisSafe.sol` contract.
By default `Safe.sol` will be only used on Ethereum Mainnet. For the rest of the networks where the Safe contracts are already deployed, the `SafeL2.sol` contract will be used unless you add the `isL1SafeMasterCopy` flag to force the use of the `Safe.sol` contract.
```js
const safeSdk = await Safe.create({ ethAdapter, safeAddress, isL1SafeMasterCopy: true })
Expand Down Expand Up @@ -380,9 +380,9 @@ const safeSdk = await safeSdk.connect({ ethAdapter, predictedSafe })
- The `isL1SafeMasterCopy` flag
There are two versions of the Safe contracts: [GnosisSafe.sol](https://github.com/safe-global/safe-contracts/blob/v1.3.0/contracts/GnosisSafe.sol) that does not trigger events in order to save gas and [GnosisSafeL2.sol](https://github.com/safe-global/safe-contracts/blob/v1.3.0/contracts/GnosisSafeL2.sol) that does, which is more appropriate for L2 networks.
There are two versions of the Safe contracts: [Safe.sol](https://github.com/safe-global/safe-contracts/blob/v1.4.1/contracts/Safe.sol) that does not trigger events in order to save gas and [SafeL2.sol](https://github.com/safe-global/safe-contracts/blob/v1.4.1/contracts/SafeL2.sol) that does, which is more appropriate for L2 networks.
By default `GnosisSafe.sol` will be only used on Ethereum Mainnet. For the rest of the networks where the Safe contracts are already deployed, the `GnosisSafeL2.sol` contract will be used unless you add the `isL1SafeMasterCopy` flag to force the use of the `GnosisSafe.sol` contract.
By default `Safe.sol` will be only used on Ethereum Mainnet. For the rest of the networks where the Safe contracts are already deployed, the `SafeL2.sol` contract will be used unless you add the `isL1SafeMasterCopy` flag to force the use of the `Safe.sol` contract.
```js
const safeSdk = await Safe.connect({ ethAdapter, safeAddress, isL1SafeMasterCopy: true })
Expand Down
4 changes: 2 additions & 2 deletions packages/protocol-kit/contracts/Deps_V1_0_0.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ pragma solidity >=0.5.0 <0.9.0;
import { ProxyFactory } from "./safe_V1_0_0/proxies/ProxyFactory.sol";
import { GnosisSafe } from "./safe_V1_0_0/GnosisSafe.sol";

contract ProxyFactory_SV1_0_0 is ProxyFactory {}
contract GnosisSafe_SV1_0_0 is GnosisSafe {}
contract SafeProxyFactory_SV1_0_0 is ProxyFactory {}
contract Safe_SV1_0_0 is GnosisSafe {}
4 changes: 2 additions & 2 deletions packages/protocol-kit/contracts/Deps_V1_1_1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { GnosisSafe } from "./safe_V1_1_1/GnosisSafe.sol";
import { MultiSend } from "./safe_V1_1_1/libraries/MultiSend.sol";
import { CreateCall } from "./safe_V1_1_1/libraries/CreateCall.sol";

contract ProxyFactory_SV1_1_1 is ProxyFactory {}
contract GnosisSafe_SV1_1_1 is GnosisSafe {}
contract SafeProxyFactory_SV1_1_1 is ProxyFactory {}
contract Safe_SV1_1_1 is GnosisSafe {}
contract MultiSend_SV1_1_1 is GnosisSafe {}
contract CreateCall_SV1_1_1 is GnosisSafe {}
6 changes: 4 additions & 2 deletions packages/protocol-kit/contracts/Deps_V1_2_0.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ pragma solidity >=0.5.0 <0.9.0;
import { GnosisSafeProxyFactory } from "@gnosis.pm/safe-contracts-v1.2.0/contracts/proxies/GnosisSafeProxyFactory.sol";
import { GnosisSafe } from "@gnosis.pm/safe-contracts-v1.2.0/contracts/GnosisSafe.sol";
import { MultiSend } from "@gnosis.pm/safe-contracts-v1.2.0/contracts/libraries/MultiSend.sol";

// Testing contracts
import { DailyLimitModule } from "@gnosis.pm/safe-contracts-v1.2.0/contracts/modules/DailyLimitModule.sol";
import { SocialRecoveryModule } from "@gnosis.pm/safe-contracts-v1.2.0/contracts/modules/SocialRecoveryModule.sol";
import { ERC20Mintable } from "openzeppelin-solidity/contracts/token/ERC20/ERC20Mintable.sol";

contract ProxyFactory_SV1_2_0 is GnosisSafeProxyFactory {}
contract GnosisSafe_SV1_2_0 is GnosisSafe {}
contract SafeProxyFactory_SV1_2_0 is GnosisSafeProxyFactory {}
contract Safe_SV1_2_0 is GnosisSafe {}
contract MultiSend_SV1_2_0 is MultiSend {}
8 changes: 5 additions & 3 deletions packages/protocol-kit/contracts/Deps_V1_3_0.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ import { MultiSend } from "@gnosis.pm/safe-contracts-v1.3.0/contracts/libraries/
import { MultiSendCallOnly } from "@gnosis.pm/safe-contracts-v1.3.0/contracts/libraries/MultiSendCallOnly.sol";
import { SignMessageLib } from "@gnosis.pm/safe-contracts-v1.3.0/contracts/examples/libraries/SignMessage.sol";
import { CreateCall } from "@gnosis.pm/safe-contracts-v1.3.0/contracts/libraries/CreateCall.sol";
import { DebugTransactionGuard } from "@gnosis.pm/safe-contracts-v1.3.0/contracts/examples/guards/DebugTransactionGuard.sol";
import { DefaultCallbackHandler } from "@gnosis.pm/safe-contracts-v1.3.0/contracts/handler/DefaultCallbackHandler.sol";

contract ProxyFactory_SV1_3_0 is GnosisSafeProxyFactory {}
contract GnosisSafe_SV1_3_0 is GnosisSafe {}
// Testing contracts
import { DebugTransactionGuard } from "@gnosis.pm/safe-contracts-v1.3.0/contracts/examples/guards/DebugTransactionGuard.sol";

contract SafeProxyFactory_SV1_3_0 is GnosisSafeProxyFactory {}
contract Safe_SV1_3_0 is GnosisSafe {}
contract CompatibilityFallbackHandler_SV1_3_0 is CompatibilityFallbackHandler {}
contract MultiSend_SV1_3_0 is MultiSend {}
contract MultiSendCallOnly_SV1_3_0 is MultiSendCallOnly {}
Expand Down
20 changes: 20 additions & 0 deletions packages/protocol-kit/contracts/Deps_V1_4_1.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.7.0 <0.9.0;

import { SafeProxyFactory } from "@safe-global/safe-contracts-v1.4.1/contracts/proxies/SafeProxyFactory.sol";
import { Safe } from "@safe-global/safe-contracts-v1.4.1/contracts/Safe.sol";
import { CompatibilityFallbackHandler } from "@safe-global/safe-contracts-v1.4.1/contracts/handler/CompatibilityFallbackHandler.sol";
import { MultiSend } from "@safe-global/safe-contracts-v1.4.1/contracts/libraries/MultiSend.sol";
import { MultiSendCallOnly } from "@safe-global/safe-contracts-v1.4.1/contracts/libraries/MultiSendCallOnly.sol";
import { SignMessageLib } from "@safe-global/safe-contracts-v1.4.1/contracts/libraries/SignMessageLib.sol";
import { CreateCall } from "@safe-global/safe-contracts-v1.4.1/contracts/libraries/CreateCall.sol";
import { TokenCallbackHandler } from "@safe-global/safe-contracts-v1.4.1/contracts/handler/TokenCallbackHandler.sol";

contract SafeProxyFactory_SV1_4_1 is SafeProxyFactory {}
contract Safe_SV1_4_1 is Safe {}
contract CompatibilityFallbackHandler_SV1_4_1 is CompatibilityFallbackHandler {}
contract MultiSend_SV1_4_1 is MultiSend {}
contract MultiSendCallOnly_SV1_4_1 is MultiSendCallOnly {}
contract SignMessageLib_SV1_4_1 is SignMessageLib {}
contract CreateCall_SV1_4_1 is CreateCall {}
contract TokenCallbackHandler_SV1_4_1 is TokenCallbackHandler {}
50 changes: 33 additions & 17 deletions packages/protocol-kit/hardhat/deploy/deploy-contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,56 +4,65 @@ import { HardhatRuntimeEnvironment } from 'hardhat/types'

export const safeVersionDeployed = process.env.SAFE_VERSION as SafeVersion

const gnosisSafeContracts = {
'1.3.0': { name: 'GnosisSafe_SV1_3_0' },
'1.2.0': { name: 'GnosisSafe_SV1_2_0' },
'1.1.1': { name: 'GnosisSafe_SV1_1_1' },
'1.0.0': { name: 'GnosisSafe_SV1_0_0' }
type SafeVersions = { [key: string]: { name: string} }

const safeContracts: SafeVersions = {
'1.4.1': { name: 'Safe_SV1_4_1' },
'1.3.0': { name: 'Safe_SV1_3_0' },
'1.2.0': { name: 'Safe_SV1_2_0' },
'1.1.1': { name: 'Safe_SV1_1_1' },
'1.0.0': { name: 'Safe_SV1_0_0' }
}

const proxyFactoryContracts = {
'1.3.0': { name: 'ProxyFactory_SV1_3_0' },
'1.2.0': { name: 'ProxyFactory_SV1_2_0' },
'1.1.1': { name: 'ProxyFactory_SV1_1_1' },
'1.0.0': { name: 'ProxyFactory_SV1_0_0' }
const proxyFactoryContracts: SafeVersions = {
'1.4.1': { name: 'SafeProxyFactory_SV1_4_1' },
'1.3.0': { name: 'SafeProxyFactory_SV1_3_0' },
'1.2.0': { name: 'SafeProxyFactory_SV1_2_0' },
'1.1.1': { name: 'SafeProxyFactory_SV1_1_1' },
'1.0.0': { name: 'SafeProxyFactory_SV1_0_0' }
}

const multiSendContracts = {
const multiSendContracts: SafeVersions = {
'1.4.1': { name: 'MultiSend_SV1_4_1' },
'1.3.0': { name: 'MultiSend_SV1_3_0' },
'1.2.0': { name: 'MultiSend_SV1_2_0' },
'1.1.1': { name: 'MultiSend_SV1_2_0' },
'1.0.0': { name: 'MultiSend_SV1_2_0' }
}

const multiSendCallOnlyContracts = {
const multiSendCallOnlyContracts: SafeVersions = {
'1.4.1': { name: 'MultiSendCallOnly_SV1_4_1' },
'1.3.0': { name: 'MultiSendCallOnly_SV1_3_0' },
'1.2.0': { name: 'MultiSendCallOnly_SV1_3_0' },
'1.1.1': { name: 'MultiSendCallOnly_SV1_3_0' },
'1.0.0': { name: 'MultiSendCallOnly_SV1_3_0' }
}

const compatibilityFallbackHandlerContracts = {
const compatibilityFallbackHandlerContracts: SafeVersions = {
'1.4.1': { name: 'CompatibilityFallbackHandler_SV1_4_1' },
'1.3.0': { name: 'CompatibilityFallbackHandler_SV1_3_0' },
'1.2.0': { name: 'CompatibilityFallbackHandler_SV1_3_0' },
'1.1.1': { name: 'CompatibilityFallbackHandler_SV1_3_0' },
'1.0.0': { name: 'CompatibilityFallbackHandler_SV1_3_0' }
}

const signMessageLibContracts = {
const signMessageLibContracts: SafeVersions = {
'1.4.1': { name: 'SignMessageLib_SV1_4_1' },
'1.3.0': { name: 'SignMessageLib_SV1_3_0' },
'1.2.0': { name: 'SignMessageLib_SV1_3_0' },
'1.1.1': { name: 'SignMessageLib_SV1_3_0' },
'1.0.0': { name: 'SignMessageLib_SV1_3_0' }
}

const createCallContracts = {
const createCallContracts: SafeVersions = {
'1.4.1': { name: 'CreateCall_SV1_4_1' },
'1.3.0': { name: 'CreateCall_SV1_3_0' },
'1.2.0': { name: 'CreateCall_SV1_3_0' },
'1.1.1': { name: 'CreateCall_SV1_3_0' },
'1.0.0': { name: 'CreateCall_SV1_3_0' }
}

export const gnosisSafeDeployed = gnosisSafeContracts[safeVersionDeployed]
export const safeDeployed = safeContracts[safeVersionDeployed]
export const proxyFactoryDeployed = proxyFactoryContracts[safeVersionDeployed]
export const multiSendDeployed = multiSendContracts[safeVersionDeployed]
export const multiSendCallOnlyDeployed = multiSendCallOnlyContracts[safeVersionDeployed]
Expand All @@ -67,7 +76,7 @@ const deploy: DeployFunction = async (hre: HardhatRuntimeEnvironment): Promise<v
const { deployer } = await getNamedAccounts()
const { deploy } = deployments

await deploy(gnosisSafeDeployed.name, {
await deploy(safeDeployed.name, {
from: deployer,
args: [],
log: true,
Expand Down Expand Up @@ -148,6 +157,13 @@ const deploy: DeployFunction = async (hre: HardhatRuntimeEnvironment): Promise<v
log: true,
deterministicDeployment: true
})

await deploy('TokenCallbackHandler_SV1_4_1', {
from: deployer,
args: [],
log: true,
deterministicDeployment: true
})
}

export default deploy
Loading

0 comments on commit 23cd67c

Please sign in to comment.