Skip to content

Commit

Permalink
Merge pull request #149 from CirclesUBI/revert-multisend
Browse files Browse the repository at this point in the history
Revert v3.1.1.and v3.1.2: remove multisend
  • Loading branch information
llunaCreixent authored Dec 2, 2022
2 parents 1d5bc40 + b78f346 commit c8a6e34
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 96 deletions.
1 change: 0 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ HUB_ADDRESS=0xCfEB869F69431e42cdB54A4F4f105C19C080A601
PROXY_FACTORY_ADDRESS=0x9b1f7F645351AF3631a656421eD2e40f2802E6c0
SAFE_ADDRESS=0x2612Af3A521c2df9EAF28422Ca335b04AdF3ac66
SAFE_DEFAULT_CALLBACK_HANDLER=0x67B5656d60a809915323Bf2C40A8bEF15A152e3e
MULTISEND_CALLONLY_ADDRESS=0x0290FB167208Af455bB137780163b7B7a9a10C16

# Smart contract addresses of the Base CRC version
PROXY_FACTORY_ADDRESS_CRC=0xD833215cBcc3f914bD1C9ece3EE7BF8B14f841bb
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: '14'

Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
sudo echo "127.0.1.1 relay.circles.local" | sudo tee -a /etc/hosts
- name: Check out circles-core repository code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
path: circles-core

Expand All @@ -28,15 +28,15 @@ jobs:
- name: Read node version from .nvmrc
working-directory: circles-core
id: nvmrc
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc)
run: echo "NODE_VERSION=$(cat .nvmrc)" >> $GITHUB_OUTPUT

- name: Setup node
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: '${{ steps.nvmrc.outputs.NODE_VERSION }}'

- name: Cache Node.js modules
uses: actions/cache@v2
uses: actions/cache@v3
with:
# npm cache files are stored in `~/.npm` on Linux/macOS.
path: ~/.npm
Expand All @@ -46,7 +46,7 @@ jobs:
${{ runner.OS }}-
- name: Get circles-docker repository and copy configs
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
repository: CirclesUBI/circles-docker.git
ref: main
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ const core = new CirclesCore(web3, {
relayServiceEndpoint: 'http://relay.circles.local',
subgraphName: 'circlesubi/circles-subgraph',
fallbackHandlerAddress: '0x67B5656d60a809915323Bf2C40A8bEF15A152e3e',
multiSendCallOnlyAddress: '0x0290FB167208Af455bB137780163b7B7a9a10C16'
});

// Create existing account from private key which owns a Safe
Expand Down
1 change: 0 additions & 1 deletion src/common/constants.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Gnosis Safe operation types
export const CALL_OP = 0;
export const DELEGATE_OP = 1;

// Gnosis Safe owner threshold
export const SAFE_THRESHOLD = 1;
Expand Down
16 changes: 1 addition & 15 deletions src/common/getContracts.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import GnosisSafeContract from '@gnosis.pm/safe-contracts/build/artifacts/contracts/GnosisSafeL2.sol/GnosisSafeL2.json';
import GnosisSafeCRCVersionContract from '@circles/safe-contracts/build/contracts/GnosisSafe.json';
import HubContract from '@circles/circles-contracts/build/contracts/Hub.json';
import MultiSendCallOnlyContract from '@gnosis.pm/safe-contracts/build/artifacts/contracts/libraries/MultiSendCallOnly.sol/MultiSendCallOnly.json';
import ProxyFactoryContract from '@gnosis.pm/safe-contracts/build/artifacts/contracts/proxies/GnosisSafeProxyFactory.sol/GnosisSafeProxyFactory.json';
import TokenContract from '@circles/circles-contracts/build/contracts/Token.json';

Expand Down Expand Up @@ -73,12 +72,7 @@ export function getTokenContract(web3, address) {
* @return {Object} - contract instances
*/
export default function getContracts(web3, options) {
const {
safeMasterAddress,
proxyFactoryAddress,
hubAddress,
multiSendCallOnlyAddress,
} = options;
const { safeMasterAddress, proxyFactoryAddress, hubAddress } = options;

// Gnosis master Safe copy
const safeMaster = getSafeContract(web3, safeMasterAddress);
Expand All @@ -93,16 +87,8 @@ export default function getContracts(web3, options) {
// Circles Hub
const hub = getContract(web3, HubContract.abi, hubAddress);

// Multisend Call Only contract
const multiSendCallOnly = getContract(
web3,
MultiSendCallOnlyContract.abi,
multiSendCallOnlyAddress,
);

return {
hub,
multiSendCallOnly,
proxyFactory,
safeMaster,
};
Expand Down
19 changes: 0 additions & 19 deletions src/common/multiSend.js

This file was deleted.

4 changes: 0 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export default class CirclesCore {
* @param {string} options.fallbackHandlerAddress - address of the fallback handler of the Safe contract
* @param {string} options.graphNodeEndpoint - URL of the graph node
* @param {string} options.hubAddress - address of deployed Circles Hub contract
* @param {string} options.multiSendCallOnlyAddress - address of deployed Gnosis MultiSendCallOnly contract
* @param {string} options.proxyFactoryAddress - address of deployed Gnosis ProxyFactory contract
* @param {string} options.relayServiceEndpoint - URL of the Relayer server
* @param {string} options.safeMasterAddress - address of deployed Gnosis Safe master copy contract
Expand All @@ -49,9 +48,6 @@ export default class CirclesCore {
hubAddress: {
type: web3.utils.checkAddressChecksum,
},
multiSendCallOnlyAddress: {
type: web3.utils.checkAddressChecksum,
},
proxyFactoryAddress: {
type: web3.utils.checkAddressChecksum,
},
Expand Down
51 changes: 17 additions & 34 deletions src/safe.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
DELEGATE_OP,
SAFE_LAST_VERSION,
SAFE_THRESHOLD,
SENTINEL_ADDRESS,
Expand All @@ -11,7 +10,6 @@ import {
getSafeContract,
getSafeCRCVersionContract,
} from '~/common/getContracts';
import encodeMultiSendCall from '~/common/multiSend';

/**
* Helper method to receive a list of all Gnosis Safe owners.
Expand Down Expand Up @@ -129,7 +127,7 @@ export default function createSafeModule(
globalOptions,
) {
const { fallbackHandlerAddress } = globalOptions;
const { safeMaster, multiSendCallOnly } = contracts;
const { safeMaster } = contracts;
return {
/**
* Predict Safe address.
Expand Down Expand Up @@ -518,7 +516,8 @@ export default function createSafeModule(
});

const safeVersion = await getVersion(web3, options.safeAddress);
let txHash;
let txHashChangeMasterCopy;
let txHashFallbackHandler;

if (safeVersion != SAFE_LAST_VERSION) {
// References:
Expand All @@ -536,44 +535,28 @@ export default function createSafeModule(
const updateSafeTxData = safeInstance.methods
.changeMasterCopy(safeMaster.options.address)
.encodeABI();
// Then we setup the fallbackHandler
const fallbackHandlerTxData = safeInstance.methods
.setFallbackHandler(fallbackHandlerAddress)
.encodeABI();

const txs = [
{
to: options.safeAddress,
value: '0',
data: updateSafeTxData,
},
{
to: options.safeAddress,
value: '0',
data: fallbackHandlerTxData,
},
];

const multiSendCallTxData = encodeMultiSendCall(
web3,
txs,
multiSendCallOnly,
);

txHash = await utils.executeTokenSafeTx(account, {
txHashChangeMasterCopy = await utils.executeTokenSafeTx(account, {
safeAddress: options.safeAddress,
to: multiSendCallOnly.options.address,
txData: multiSendCallTxData,
to: options.safeAddress,
txData: updateSafeTxData,
isCRCVersion: true,
operation: DELEGATE_OP,
});
if (!txHash) {
if (!txHashChangeMasterCopy) {
throw new CoreError(
`Safe with version ${safeVersion} failed to change the Master Copy`,
);
}
// Then we setup the fallbackHandler
const fallbackHandlerTxData = safeInstance.methods
.setFallbackHandler(fallbackHandlerAddress)
.encodeABI();
txHashFallbackHandler = await utils.executeTokenSafeTx(account, {
safeAddress: options.safeAddress,
to: options.safeAddress,
txData: fallbackHandlerTxData,
});
}
return txHash;
return { txHashChangeMasterCopy, txHashFallbackHandler };
},
};
}
7 changes: 2 additions & 5 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -744,13 +744,10 @@ export default function createUtilsModule(web3, contracts, globalOptions) {
type: 'boolean',
default: false,
},
operation: {
type: 'number',
default: CALL_OP,
},
});

const { txData, safeAddress, to, isCRCVersion, operation } = options;
const { txData, safeAddress, to, isCRCVersion } = options;
const operation = CALL_OP;
const refundReceiver = ZERO_ADDRESS;
const value = 0;

Expand Down
2 changes: 0 additions & 2 deletions test/common.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ describe('Common', () => {
beforeEach(() => {
contracts = getContracts(web3, {
hubAddress: ZERO_ADDRESS,
multiSendCallOnlyAddress: ZERO_ADDRESS,
proxyFactoryAddress: ZERO_ADDRESS,
safeMasterAddress: ZERO_ADDRESS,
});
Expand All @@ -184,7 +183,6 @@ describe('Common', () => {
it('should give us access to contracts', () => {
expect(contracts.safeMaster.methods).toBeDefined();
expect(contracts.hub.methods).toBeDefined();
expect(contracts.multiSendCallOnly.methods).toBeDefined();
expect(contracts.proxyFactory.methods).toBeDefined();
});

Expand Down
1 change: 0 additions & 1 deletion test/helpers/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export default function createCore() {
fallbackHandlerAddress: process.env.SAFE_DEFAULT_CALLBACK_HANDLER,
graphNodeEndpoint: process.env.GRAPH_NODE_ENDPOINT,
hubAddress: process.env.HUB_ADDRESS,
multiSendCallOnlyAddress: process.env.MULTISEND_CALLONLY_ADDRESS,
proxyFactoryAddress: process.env.PROXY_FACTORY_ADDRESS,
relayServiceEndpoint: process.env.RELAY_SERVICE_ENDPOINT,
safeMasterAddress: process.env.SAFE_ADDRESS,
Expand Down
11 changes: 6 additions & 5 deletions test/safe.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ describe('Safe', () => {
const hubAddress = core.options.hubAddress;
contracts = await getContracts(web3, {
hubAddress: hubAddress,
multiSendCallOnlyAddress: ZERO_ADDRESS,
proxyFactoryAddress: ZERO_ADDRESS,
safeMasterAddress: ZERO_ADDRESS,
});
Expand Down Expand Up @@ -292,11 +291,13 @@ describe('Safe', () => {
});

it('I should get the last version when update the Safe version of a deployed Safe', async () => {
const txHash = await core.safe.updateToLastVersion(ownerCRCVersion, {
safeAddress: CRCVersionSafeAddress,
});
const { txHashChangeMasterCopy, txHashFallbackHandler } =
await core.safe.updateToLastVersion(ownerCRCVersion, {
safeAddress: CRCVersionSafeAddress,
});

expect(web3.utils.isHexStrict(txHash)).toBe(true);
expect(web3.utils.isHexStrict(txHashChangeMasterCopy)).toBe(true);
expect(web3.utils.isHexStrict(txHashFallbackHandler)).toBe(true);

const version = await core.safe.getVersion(ownerCRCVersion, {
safeAddress: CRCVersionSafeAddress,
Expand Down
1 change: 0 additions & 1 deletion test/token.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ describe('Token', () => {
hubAddress = core.options.hubAddress;
contracts = await getContracts(web3, {
hubAddress: hubAddress,
multiSendCallOnlyAddress: ZERO_ADDRESS,
proxyFactoryAddress: ZERO_ADDRESS,
safeMasterAddress: ZERO_ADDRESS,
});
Expand Down

0 comments on commit c8a6e34

Please sign in to comment.