-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: payable calls for solidity >= 0.5 (#59)
* fix payable calls for solidity >= 0.5 * test: add escrow integration
- Loading branch information
1 parent
c4e5f67
commit 7fc2bf5
Showing
3 changed files
with
194 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
{ | ||
"_format": "hh-sol-artifact-1", | ||
"contractName": "Escrow", | ||
"sourceName": "contracts/utils/escrow/Escrow.sol", | ||
"abi": [ | ||
{ | ||
"anonymous": false, | ||
"inputs": [ | ||
{ | ||
"indexed": true, | ||
"internalType": "address", | ||
"name": "payee", | ||
"type": "address" | ||
}, | ||
{ | ||
"indexed": false, | ||
"internalType": "uint256", | ||
"name": "weiAmount", | ||
"type": "uint256" | ||
} | ||
], | ||
"name": "Deposited", | ||
"type": "event" | ||
}, | ||
{ | ||
"anonymous": false, | ||
"inputs": [ | ||
{ | ||
"indexed": true, | ||
"internalType": "address", | ||
"name": "previousOwner", | ||
"type": "address" | ||
}, | ||
{ | ||
"indexed": true, | ||
"internalType": "address", | ||
"name": "newOwner", | ||
"type": "address" | ||
} | ||
], | ||
"name": "OwnershipTransferred", | ||
"type": "event" | ||
}, | ||
{ | ||
"anonymous": false, | ||
"inputs": [ | ||
{ | ||
"indexed": true, | ||
"internalType": "address", | ||
"name": "payee", | ||
"type": "address" | ||
}, | ||
{ | ||
"indexed": false, | ||
"internalType": "uint256", | ||
"name": "weiAmount", | ||
"type": "uint256" | ||
} | ||
], | ||
"name": "Withdrawn", | ||
"type": "event" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"internalType": "address", | ||
"name": "payee", | ||
"type": "address" | ||
} | ||
], | ||
"name": "deposit", | ||
"outputs": [], | ||
"stateMutability": "payable", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"internalType": "address", | ||
"name": "payee", | ||
"type": "address" | ||
} | ||
], | ||
"name": "depositsOf", | ||
"outputs": [ | ||
{ | ||
"internalType": "uint256", | ||
"name": "", | ||
"type": "uint256" | ||
} | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "owner", | ||
"outputs": [ | ||
{ | ||
"internalType": "address", | ||
"name": "", | ||
"type": "address" | ||
} | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "renounceOwnership", | ||
"outputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"internalType": "address", | ||
"name": "newOwner", | ||
"type": "address" | ||
} | ||
], | ||
"name": "transferOwnership", | ||
"outputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"internalType": "address payable", | ||
"name": "payee", | ||
"type": "address" | ||
} | ||
], | ||
"name": "withdraw", | ||
"outputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
} | ||
], | ||
"bytecode": "0x608060405234801561001057600080fd5b50600061001b61006a565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a35061006e565b3390565b61065f8061007d6000396000f3fe6080604052600436106100555760003560e01c806351cff8d91461005a578063715018a61461007c5780638da5cb5b14610091578063e3a9db1a146100bc578063f2fde38b146100e9578063f340fa0114610109575b600080fd5b34801561006657600080fd5b5061007a61007536600461049b565b61011c565b005b34801561008857600080fd5b5061007a6101d1565b34801561009d57600080fd5b506100a661025a565b6040516100b391906104c1565b60405180910390f35b3480156100c857600080fd5b506100dc6100d736600461049b565b610269565b6040516100b391906105e4565b3480156100f557600080fd5b5061007a61010436600461049b565b610284565b61007a61011736600461049b565b610344565b6101246103f6565b6001600160a01b031661013561025a565b6001600160a01b0316146101645760405162461bcd60e51b815260040161015b906105af565b60405180910390fd5b6001600160a01b038116600081815260016020526040812080549190559061018c90826103fa565b816001600160a01b03167f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5826040516101c591906105e4565b60405180910390a25050565b6101d96103f6565b6001600160a01b03166101ea61025a565b6001600160a01b0316146102105760405162461bcd60e51b815260040161015b906105af565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b031690565b6001600160a01b031660009081526001602052604090205490565b61028c6103f6565b6001600160a01b031661029d61025a565b6001600160a01b0316146102c35760405162461bcd60e51b815260040161015b906105af565b6001600160a01b0381166102e95760405162461bcd60e51b815260040161015b906104d5565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b61034c6103f6565b6001600160a01b031661035d61025a565b6001600160a01b0316146103835760405162461bcd60e51b815260040161015b906105af565b6001600160a01b03811660009081526001602052604090205434906103a99082906105ed565b6001600160a01b038316600081815260016020526040908190209290925590517f2da466a7b24304f47e87fa2e1e5a81b9831ce54fec19055ce277ca2f39ba42c4906101c59084906105e4565b3390565b8047101561041a5760405162461bcd60e51b815260040161015b90610578565b6000826001600160a01b031682604051610433906104be565b60006040518083038185875af1925050503d8060008114610470576040519150601f19603f3d011682016040523d82523d6000602084013e610475565b606091505b50509050806104965760405162461bcd60e51b815260040161015b9061051b565b505050565b6000602082840312156104ac578081fd5b81356104b781610611565b9392505050565b90565b6001600160a01b0391909116815260200190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252603a908201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260408201527f6563697069656e74206d61792068617665207265766572746564000000000000606082015260800190565b6020808252601d908201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b90815260200190565b6000821982111561060c57634e487b7160e01b81526011600452602481fd5b500190565b6001600160a01b038116811461062657600080fd5b5056fea26469706673582212207138a4dfbe69899966f7c45a3a442d204a13a4e673824d47f349c508e254536c64736f6c63430008000033", | ||
"deployedBytecode": "0x6080604052600436106100555760003560e01c806351cff8d91461005a578063715018a61461007c5780638da5cb5b14610091578063e3a9db1a146100bc578063f2fde38b146100e9578063f340fa0114610109575b600080fd5b34801561006657600080fd5b5061007a61007536600461049b565b61011c565b005b34801561008857600080fd5b5061007a6101d1565b34801561009d57600080fd5b506100a661025a565b6040516100b391906104c1565b60405180910390f35b3480156100c857600080fd5b506100dc6100d736600461049b565b610269565b6040516100b391906105e4565b3480156100f557600080fd5b5061007a61010436600461049b565b610284565b61007a61011736600461049b565b610344565b6101246103f6565b6001600160a01b031661013561025a565b6001600160a01b0316146101645760405162461bcd60e51b815260040161015b906105af565b60405180910390fd5b6001600160a01b038116600081815260016020526040812080549190559061018c90826103fa565b816001600160a01b03167f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5826040516101c591906105e4565b60405180910390a25050565b6101d96103f6565b6001600160a01b03166101ea61025a565b6001600160a01b0316146102105760405162461bcd60e51b815260040161015b906105af565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b031690565b6001600160a01b031660009081526001602052604090205490565b61028c6103f6565b6001600160a01b031661029d61025a565b6001600160a01b0316146102c35760405162461bcd60e51b815260040161015b906105af565b6001600160a01b0381166102e95760405162461bcd60e51b815260040161015b906104d5565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b61034c6103f6565b6001600160a01b031661035d61025a565b6001600160a01b0316146103835760405162461bcd60e51b815260040161015b906105af565b6001600160a01b03811660009081526001602052604090205434906103a99082906105ed565b6001600160a01b038316600081815260016020526040908190209290925590517f2da466a7b24304f47e87fa2e1e5a81b9831ce54fec19055ce277ca2f39ba42c4906101c59084906105e4565b3390565b8047101561041a5760405162461bcd60e51b815260040161015b90610578565b6000826001600160a01b031682604051610433906104be565b60006040518083038185875af1925050503d8060008114610470576040519150601f19603f3d011682016040523d82523d6000602084013e610475565b606091505b50509050806104965760405162461bcd60e51b815260040161015b9061051b565b505050565b6000602082840312156104ac578081fd5b81356104b781610611565b9392505050565b90565b6001600160a01b0391909116815260200190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252603a908201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260408201527f6563697069656e74206d61792068617665207265766572746564000000000000606082015260800190565b6020808252601d908201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b90815260200190565b6000821982111561060c57634e487b7160e01b81526011600452602481fd5b500190565b6001600160a01b038116811461062657600080fd5b5056fea26469706673582212207138a4dfbe69899966f7c45a3a442d204a13a4e673824d47f349c508e254536c64736f6c63430008000033", | ||
"linkReferences": {}, | ||
"deployedLinkReferences": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import 'isomorphic-fetch' | ||
import * as expect from 'expect' | ||
import { ContractFactory, RequestManager, BigNumber } from '../src' | ||
import { testAllProviders } from './helpers/testAllProviders' | ||
import { abi, bytecode } from './fixtures/Escrow.json' | ||
|
||
describe('integration.escrow', function () { | ||
testAllProviders(doTest) | ||
}) | ||
|
||
function doTest(requestManager: RequestManager) { | ||
it('should unlock the account', async () => { | ||
const accounts = await requestManager.eth_accounts() | ||
const account = accounts[0] | ||
const accountUnlocked = await requestManager.personal_unlockAccount(account, '', 300) | ||
console.log(`> Unlocking account status=${accountUnlocked}`) | ||
expect(accountUnlocked).toEqual(true) | ||
}) | ||
|
||
let EscrowContract = null | ||
|
||
it('deploys a new contract', async function () { | ||
this.timeout(100000) | ||
const accounts = await requestManager.eth_accounts() | ||
const account = accounts[0] | ||
|
||
console.log(`> Account: ${account}`) | ||
const factory = new ContractFactory(requestManager, abi) | ||
EscrowContract = await factory.deploy({ data: bytecode, from: account, to: null }) | ||
|
||
console.log(`> Tx: ${EscrowContract.transactionHash}`) | ||
}) | ||
|
||
it('deposit', async function () { | ||
this.timeout(1000000) | ||
const account = (await requestManager.eth_accounts())[0] | ||
const depositResult = await EscrowContract.deposit(account, { from: account, value: 123 }) | ||
const tx = await requestManager.getConfirmedTransaction(depositResult) | ||
expect(tx.status).toEqual('confirmed') | ||
expect(typeof tx.receipt).toEqual('object') | ||
expect(tx.receipt.status).toEqual(1) | ||
const deposits = await EscrowContract.depositsOf(account, { from: account }); | ||
expect(deposits).toBeInstanceOf(BigNumber) | ||
expect((deposits as BigNumber).eq(123)).toEqual(true) | ||
}) | ||
} |