Skip to content

Commit

Permalink
WIP First version
Browse files Browse the repository at this point in the history
  • Loading branch information
juanenrisley committed Jul 28, 2023
1 parent 0ab3243 commit 77b7387
Show file tree
Hide file tree
Showing 19 changed files with 610 additions and 540 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ HUB_ADDRESS=0xCfEB869F69431e42cdB54A4F4f105C19C080A601
PROXY_FACTORY_ADDRESS=0x9b1f7F645351AF3631a656421eD2e40f2802E6c0
SAFE_ADDRESS=0x2612Af3A521c2df9EAF28422Ca335b04AdF3ac66
SAFE_DEFAULT_CALLBACK_HANDLER=0x67B5656d60a809915323Bf2C40A8bEF15A152e3e
MULTI_SEND_ADDRESS=0xe982E462b094850F12AF94d21D470e21bE9D0E9C
MULTI_SEND_CALL_ONLY_ADDRESS=0x0290FB167208Af455bB137780163b7B7a9a10C16

# Smart contract addresses of the Base CRC version
PROXY_FACTORY_ADDRESS_CRC=0xD833215cBcc3f914bD1C9ece3EE7BF8B14f841bb
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
docs
lib
node_modules
coverage
10 changes: 7 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ require('dotenv').config();
if (!('crypto' in globalThis)) globalThis.crypto = require('crypto');

module.exports = {
testEnvironment: 'node',
testTimeout: 360 * 1000,

collectCoverage: true,
globalTeardown: '<rootDir>/teardown.js',
// Resolve modules with alias
moduleNameMapper: {
'^~(.*)$': '<rootDir>/src$1',
},
modulePathIgnorePatterns: ['<rootDir>/test/helpers'],
testEnvironment: 'node',
testMatch: ['**/safe.test.js'],
testTimeout: 360 * 1000,
verbose: true,
};
195 changes: 187 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"docs:serve": "documentation serve --watch ./src/**",
"docs:lint": "documentation lint ./src/**",
"lint": "eslint --ignore-path .gitignore --ignore-pattern lib .",
"test": "jest --runInBand",
"test": "jest --runInBand --forceExit",
"test:watch": "npm run test -- --watch"
},
"devDependencies": {
Expand All @@ -42,6 +42,7 @@
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.1.0",
"@rollup/plugin-terser": "^0.4.3",
"@truffle/hdwallet-provider": "2.1.13",
"babel-plugin-add-module-exports": "^1.0.4",
"babel-plugin-module-resolver": "^5.0.0",
"documentation": "^14.0.2",
Expand All @@ -65,6 +66,8 @@
"@circles/circles-contracts": "^3.3.2",
"@circles/safe-contracts": "=1.0.14",
"@gnosis.pm/safe-contracts": "^1.3.0",
"@safe-global/protocol-kit": "1.2.0",
"@safe-global/safe-core-sdk-types": "2.2.0",
"eth-lib": "^0.2.8"
}
}
13 changes: 13 additions & 0 deletions src/common/createErrorType.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export default function createErrorType(name, code, init) {
function E(message) {
if (!Error.captureStackTrace) this.stack = new Error().stack;
else Error.captureStackTrace(this, this.constructor);
this.message = message;
this.code = code;
init && init.apply(this, arguments);
}
E.prototype = new Error();
E.prototype.name = name;
E.prototype.constructor = E;
return E;
}
7 changes: 7 additions & 0 deletions src/common/error.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import createSymbolObject from '~/common/createSymbolObject';
import createErrorType from '~/common/createErrorType';

export const ErrorCodes = createSymbolObject([
'FAILED_REQUEST',
'INSUFFICIENT_FUNDS',
'INVALID_OPTIONS',
'INVALID_TRANSFER',
'SAFE_NOT_FOUND',
'SAFE_ALREADY_DEPLOYED',
'TOKEN_NOT_FOUND',
'TOO_COMPLEX_TRANSFER',
'TOO_MANY_ATTEMPTS',
Expand Down Expand Up @@ -57,3 +59,8 @@ export class TransferError extends CoreError {
this.transfer = transferData;
}
}

export const SafeDeployedError = createErrorType(
'SafeDeployedError',
ErrorCodes.SAFE_ALREADY_DEPLOYED,
);
15 changes: 15 additions & 0 deletions src/common/safeContractAbis.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import GnosisSafeContract from '@gnosis.pm/safe-contracts/build/artifacts/contracts/GnosisSafeL2.sol/GnosisSafeL2.json';
import ProxyFactoryContract from '@gnosis.pm/safe-contracts/build/artifacts/contracts/proxies/GnosisSafeProxyFactory.sol/GnosisSafeProxyFactory.json';
import CompatibilityFallbackHandler from '@gnosis.pm/safe-contracts/build/artifacts/contracts/handler/CompatibilityFallbackHandler.sol/CompatibilityFallbackHandler.json';
import MultiSend from '@gnosis.pm/safe-contracts/build/artifacts/contracts/libraries/MultiSend.sol/MultiSend.json';
import MultiSendCallOnly from '@gnosis.pm/safe-contracts/build/artifacts/contracts/libraries/MultiSendCallOnly.sol/MultiSendCallOnly.json';

const abis = {
safeMasterCopyAbi: GnosisSafeContract.abi,
safeProxyFactoryAbi: ProxyFactoryContract.abi,
fallbackHandlerAbi: CompatibilityFallbackHandler.abi,
multiSendAbi: MultiSend.abi,
multiSendCallOnlyAbi: MultiSendCallOnly.abi,
};
// TODO: docs
export default abis;
6 changes: 6 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ export default class CirclesCore {
fallbackHandlerAddress: {
type: web3.utils.checkAddressChecksum,
},
multiSendAddress: {
type: web3.utils.checkAddressChecksum,
},
multiSendCallOnlyAddress: {
type: web3.utils.checkAddressChecksum,
},
graphNodeEndpoint: {
type: 'string',
},
Expand Down
Loading

0 comments on commit 77b7387

Please sign in to comment.