Attempt to fix send/ transfer issue
This commit is contained in:
parent
4faa9d67de
commit
3331f97589
|
@ -36,7 +36,9 @@ contract FallbackManager is SelfAuthorized {
|
|||
{
|
||||
// Only calls without value and with data will be forwarded
|
||||
if (msg.value > 0 || msg.data.length == 0) {
|
||||
emit IncomingTransaction(msg.sender, msg.value);
|
||||
if (gasleft() > 2000) {
|
||||
emit IncomingTransaction(msg.sender, msg.value);
|
||||
}
|
||||
return;
|
||||
}
|
||||
bytes32 slot = FALLBACK_HANDLER_STORAGE_SLOT;
|
||||
|
|
|
@ -11,6 +11,8 @@ interface IProxy {
|
|||
/// @author Richard Meissner - <richard@gnosis.io>
|
||||
contract Proxy {
|
||||
|
||||
event IncomingTransaction(address from, uint256 value);
|
||||
|
||||
// masterCopy always needs to be first declared variable, to ensure that it is at the same location in the contracts to which calls are delegated.
|
||||
// To reduce deployment costs this variable is internal and needs to be retrieved via `getStorageAt`
|
||||
address internal masterCopy;
|
||||
|
@ -29,6 +31,11 @@ contract Proxy {
|
|||
external
|
||||
payable
|
||||
{
|
||||
// Only calls without value and with data will be forwarded
|
||||
if (msg.value > 0 || msg.data.length == 0) {
|
||||
emit IncomingTransaction(msg.sender, msg.value);
|
||||
return;
|
||||
}
|
||||
// solium-disable-next-line security/no-inline-assembly
|
||||
assembly {
|
||||
let masterCopy := and(sload(0), 0xffffffffffffffffffffffffffffffffffffffff)
|
||||
|
|
|
@ -1260,7 +1260,7 @@
|
|||
"requires": {
|
||||
"underscore": "1.9.1",
|
||||
"web3-core-helpers": "1.2.1",
|
||||
"websocket": "github:web3-js/WebSocket-Node#905deb4812572b344f5801f8c9ce8bb02799d82e"
|
||||
"websocket": "github:web3-js/WebSocket-Node#polyfill/globalThis"
|
||||
}
|
||||
},
|
||||
"web3-shh": {
|
||||
|
@ -1296,10 +1296,7 @@
|
|||
"dev": true,
|
||||
"requires": {
|
||||
"debug": "^2.2.0",
|
||||
"es5-ext": "^0.10.50",
|
||||
"nan": "^2.14.0",
|
||||
"typedarray-to-buffer": "^3.1.5",
|
||||
"yaeti": "^0.0.6"
|
||||
"nan": "^2.14.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2236,7 +2233,7 @@
|
|||
"requires": {
|
||||
"underscore": "1.9.1",
|
||||
"web3-core-helpers": "1.2.1",
|
||||
"websocket": "github:web3-js/WebSocket-Node#905deb4812572b344f5801f8c9ce8bb02799d82e"
|
||||
"websocket": "github:web3-js/WebSocket-Node#polyfill/globalThis"
|
||||
}
|
||||
},
|
||||
"web3-shh": {
|
||||
|
@ -2272,10 +2269,7 @@
|
|||
"dev": true,
|
||||
"requires": {
|
||||
"debug": "^2.2.0",
|
||||
"es5-ext": "^0.10.50",
|
||||
"nan": "^2.14.0",
|
||||
"typedarray-to-buffer": "^3.1.5",
|
||||
"yaeti": "^0.0.6"
|
||||
"nan": "^2.14.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4578,16 +4572,6 @@
|
|||
"integrity": "sha512-a+EPoD+uZiNfh+5fxw2nO9QwFa6nJe2Or35fGY6Ipw1R3R4AGz1d1TEZrCegvw2YTmZ0jXirGYlzxxpYSHwpEg==",
|
||||
"dev": true
|
||||
},
|
||||
"d": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz",
|
||||
"integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"es5-ext": "^0.10.50",
|
||||
"type": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"dargs": {
|
||||
"version": "5.1.0",
|
||||
"resolved": "https://registry.npmjs.org/dargs/-/dargs-5.1.0.tgz",
|
||||
|
@ -5190,38 +5174,6 @@
|
|||
"is-symbol": "^1.0.2"
|
||||
}
|
||||
},
|
||||
"es5-ext": {
|
||||
"version": "0.10.52",
|
||||
"resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.52.tgz",
|
||||
"integrity": "sha512-bWCbE9fbpYQY4CU6hJbJ1vSz70EClMlDgJ7BmwI+zEJhxrwjesZRPglGJlsZhu0334U3hI+gaspwksH9IGD6ag==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"es6-iterator": "~2.0.3",
|
||||
"es6-symbol": "~3.1.2",
|
||||
"next-tick": "~1.0.0"
|
||||
}
|
||||
},
|
||||
"es6-iterator": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz",
|
||||
"integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"d": "1",
|
||||
"es5-ext": "^0.10.35",
|
||||
"es6-symbol": "^3.1.1"
|
||||
}
|
||||
},
|
||||
"es6-symbol": {
|
||||
"version": "3.1.3",
|
||||
"resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz",
|
||||
"integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"d": "^1.0.1",
|
||||
"ext": "^1.1.2"
|
||||
}
|
||||
},
|
||||
"escape-html": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
|
||||
|
@ -5487,7 +5439,7 @@
|
|||
"integrity": "sha1-xU2sX8DjdzmcBMGm7LsS5FEyeNY=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"bignumber.js": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934",
|
||||
"bignumber.js": "git+https://github.com/frozeman/bignumber.js-nolookahead.git",
|
||||
"crypto-js": "^3.1.4",
|
||||
"utf8": "^2.1.1",
|
||||
"xhr2": "*",
|
||||
|
@ -5517,7 +5469,7 @@
|
|||
"resolved": "https://registry.npmjs.org/eth-sig-util/-/eth-sig-util-1.4.2.tgz",
|
||||
"integrity": "sha1-jZWCAsftuq6Dlwf7pvCf8ydgYhA=",
|
||||
"requires": {
|
||||
"ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#8431eab7b3384e65e8126a4602520b78031666fb",
|
||||
"ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git",
|
||||
"ethereumjs-util": "^5.1.1"
|
||||
},
|
||||
"dependencies": {
|
||||
|
@ -6131,23 +6083,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"ext": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/ext/-/ext-1.1.2.tgz",
|
||||
"integrity": "sha512-/KLjJdTNyDepCihrk4HQt57nAE1IRCEo5jUt+WgWGCr1oARhibDvmI2DMcSNWood1T9AUWwq+jaV1wvRqaXfnA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"type": "^2.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"type": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/type/-/type-2.0.0.tgz",
|
||||
"integrity": "sha512-KBt58xCHry4Cejnc2ISQAF7QY+ORngsWfxezO68+12hKV6lQY8P/psIkcbjeHWn7MqcgciWJyCCevFMJdIXpow==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"extend": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz",
|
||||
|
@ -9808,12 +9743,6 @@
|
|||
"integrity": "sha512-MFh0d/Wa7vkKO3Y3LlacqAEeHK0mckVqzDieUKTT+KGxi+zIpeVsFxymkIiRpbpDziHc290Xr9A1O4Om7otoRA==",
|
||||
"dev": true
|
||||
},
|
||||
"next-tick": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz",
|
||||
"integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=",
|
||||
"dev": true
|
||||
},
|
||||
"nice-try": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz",
|
||||
|
@ -12358,7 +12287,7 @@
|
|||
"requires": {
|
||||
"mocha": "^4.1.0",
|
||||
"original-require": "1.0.1",
|
||||
"solc": "^0.5.11"
|
||||
"solc": "0.4.24"
|
||||
},
|
||||
"dependencies": {
|
||||
"ansi-regex": {
|
||||
|
@ -12689,12 +12618,6 @@
|
|||
"resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz",
|
||||
"integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q="
|
||||
},
|
||||
"type": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz",
|
||||
"integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==",
|
||||
"dev": true
|
||||
},
|
||||
"type-check": {
|
||||
"version": "0.3.2",
|
||||
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz",
|
||||
|
@ -12719,15 +12642,6 @@
|
|||
"resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
|
||||
"integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c="
|
||||
},
|
||||
"typedarray-to-buffer": {
|
||||
"version": "3.1.5",
|
||||
"resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz",
|
||||
"integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"is-typedarray": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"uglify-js": {
|
||||
"version": "3.4.9",
|
||||
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.9.tgz",
|
||||
|
@ -13073,7 +12987,7 @@
|
|||
"integrity": "sha1-PpcwauAk+yThCj11yIQwJWIhUSA=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"bignumber.js": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934",
|
||||
"bignumber.js": "git+https://github.com/frozeman/bignumber.js-nolookahead.git",
|
||||
"crypto-js": "^3.1.4",
|
||||
"utf8": "^2.1.1",
|
||||
"xhr2": "*",
|
||||
|
@ -13370,7 +13284,6 @@
|
|||
"lodash": "^4.17.11",
|
||||
"oboe": "2.1.4",
|
||||
"url-parse": "1.4.4",
|
||||
"websocket": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2",
|
||||
"xhr2-cookies": "1.1.0"
|
||||
}
|
||||
},
|
||||
|
@ -13660,17 +13573,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"websocket": {
|
||||
"version": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2",
|
||||
"from": "git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"debug": "^2.2.0",
|
||||
"nan": "^2.3.3",
|
||||
"typedarray-to-buffer": "^3.1.2",
|
||||
"yaeti": "^0.0.6"
|
||||
}
|
||||
},
|
||||
"whatwg-fetch": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "http://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz",
|
||||
|
@ -13803,12 +13705,6 @@
|
|||
"resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz",
|
||||
"integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE="
|
||||
},
|
||||
"yaeti": {
|
||||
"version": "0.0.6",
|
||||
"resolved": "https://registry.npmjs.org/yaeti/-/yaeti-0.0.6.tgz",
|
||||
"integrity": "sha1-8m9ITXJoTPQr7ft2lwqhYI+/lXc=",
|
||||
"dev": true
|
||||
},
|
||||
"yallist": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.2.tgz",
|
||||
|
|
|
@ -9,7 +9,7 @@ contract('GnosisSafe setup', function(accounts) {
|
|||
|
||||
const CALL = 0
|
||||
|
||||
it.only('should not be able to call execTransaction before setup', async () => {
|
||||
it('should not be able to call execTransaction before setup', async () => {
|
||||
|
||||
// Create lightwallet
|
||||
gnosisSafe = await utils.deployContract("deploying Gnosis Safe", GnosisSafe)
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
const utils = require('./utils/general')
|
||||
const safeUtils = require('./utils/execution')
|
||||
const abi = require('ethereumjs-abi')
|
||||
|
||||
|
||||
const GnosisSafe = artifacts.require("./GnosisSafe.sol")
|
||||
const ProxyFactory = artifacts.require("./ProxyFactory.sol")
|
||||
|
||||
contract('GnosisSafe allow incoming funds via send/transfer', function(accounts) {
|
||||
|
||||
let lw
|
||||
let gnosisSafe
|
||||
let executor = accounts[8]
|
||||
|
||||
const CALL = 0
|
||||
|
||||
beforeEach(async function () {
|
||||
// Create lightwallet
|
||||
lw = await utils.createLightwallet()
|
||||
// Create Master Copies
|
||||
let proxyFactory = await ProxyFactory.new()
|
||||
let gnosisSafeMasterCopy = await utils.deployContract("deploying Gnosis Safe Mastercopy", GnosisSafe)
|
||||
gnosisSafeMasterCopy.setup([accounts[0], accounts[1], accounts[2]], 2, 0, "0x", 0, 0, 0, 0)
|
||||
// Create Gnosis Safe
|
||||
let gnosisSafeData = await gnosisSafeMasterCopy.contract.setup.getData([lw.accounts[0], lw.accounts[1]], 2, 0, "0x", 0, 0, 0, 0)
|
||||
gnosisSafe = utils.getParamFromTxEvent(
|
||||
await proxyFactory.createProxy(gnosisSafeMasterCopy.address, gnosisSafeData),
|
||||
'ProxyCreation', 'proxy', proxyFactory.address, GnosisSafe, 'create Gnosis Safe Proxy',
|
||||
)
|
||||
})
|
||||
|
||||
it.only('should be able to receive ETH via send', async () => {
|
||||
// Notes: It is not possible to load storage + a call + emit event with 2300 gas
|
||||
// Test Validator
|
||||
let source = `
|
||||
contract Test {
|
||||
function sendEth(address payable safe) public payable returns (bool success) {
|
||||
safe.transfer(msg.value);
|
||||
}
|
||||
}`
|
||||
let testCaller = await safeUtils.deployContract(accounts[0], source);
|
||||
let txHash = await testCaller.sendEth(gnosisSafe.address, {from: accounts[0], value: web3.toWei(1, 'ether')})
|
||||
let receipt = await web3.eth.getTransactionReceipt(txHash)
|
||||
console.log(receipt)
|
||||
assert.equal(receipt.status, '0x1')
|
||||
let balance = await web3.eth.getBalance(gnosisSafe.address)
|
||||
console.log(balance.toNumber())
|
||||
assert.equal(await web3.eth.getBalance(gnosisSafe.address), web3.toWei(1, 'ether'))
|
||||
})
|
||||
})
|
Loading…
Reference in New Issue