ZeroEx: TransformERC20, TokenSpender (#2545)
* `@0x/contracts-utils`: Convert more 0.6 contracts * `@0x/contracts-erc20`: Add solidity 0.6 contracts. * `@0x/utils`: Add new `ZeroExRevertErrors` revert types * `@0x/contracts-zero-ex`: Introduce the `TransformERC20` feature. * `@0x/subproviders`: Update ganache-core. `@0x/web3-wrapper`: Update ganache-core. * `@0x/contracts-zero-ex`: Make `TokenSpender`'s puppet contract a distinct contract type and rename `getTokenSpenderPuppet()` to `getAllowanceTarget()` * `@0x/zero-ex`: Rebase and use "slot" instead of "offset" language in storage buckets. * `@0x/web3-wrapper`: Add `getAccountNonceAsync()` to `Web3Wrapper` * `@0x/contracts-zero-ex`: Revamp TransformERC20. * `@0x/contracts-zero-ex`: Remove `payable` from `IERC20Transformer.transform()` and disable hex capitalization linter rule because of prettier conflicts. * `@0x/contracts-zero-ex`: Use `immutable` owner in `Puppet` instead of `Ownable`. * `@x/utils`: Address review feedback. * `@0x/contracts-zero-ex`: Address review feedback. * `@0x/contracts-utils`: Address review feedback. * `@0x/contracts-zero-ex`: Return deployment nonce in `transform()`. * `@0x/contracts-zero-ex`: Finish returning deployment nonce in `transform()`. * `@0x/contracts-zero-ex`: Fix doc-gen bug. * `@0x/contracts-zero-ex`: Address review comments. * `@0x/utils`: Add `NegativeTransformERC20OutputERror` * `@0x/contracts-zero-ex`: Revert if the taker's output amount decreases. Co-authored-by: Lawrence Forman <me@merklejerk.com>
This commit is contained in:
@@ -1,4 +1,17 @@
|
||||
[
|
||||
{
|
||||
"version": "7.1.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Add `getAccountNonce()` to `Web3Wrapper`",
|
||||
"pr": 2545
|
||||
},
|
||||
{
|
||||
"note": "Update ganache-core",
|
||||
"pr": 2545
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1582623685,
|
||||
"version": "7.0.7",
|
||||
|
@@ -47,7 +47,7 @@
|
||||
"chai-as-promised": "^7.1.0",
|
||||
"chai-bignumber": "^3.0.0",
|
||||
"dirty-chai": "^2.0.1",
|
||||
"ganache-core": "^2.9.0-istanbul.0",
|
||||
"ganache-core": "^2.10.2",
|
||||
"make-promises-safe": "^1.1.0",
|
||||
"mocha": "^6.2.0",
|
||||
"npm-run-all": "^4.1.2",
|
||||
|
@@ -360,6 +360,27 @@ export class Web3Wrapper {
|
||||
const blockNumber = utils.convertHexToNumberOrNull(blockNumberHex);
|
||||
return blockNumber as number;
|
||||
}
|
||||
/**
|
||||
* Fetches the nonce for an account (transaction count for EOAs).
|
||||
* @param address Address of account.
|
||||
* @param defaultBlock Block height at which to make the call. Defaults to `latest`
|
||||
* @returns Account nonce.
|
||||
*/
|
||||
public async getAccountNonceAsync(address: string, defaultBlock?: BlockParam): Promise<number> {
|
||||
assert.isETHAddressHex('address', address);
|
||||
if (defaultBlock !== undefined) {
|
||||
Web3Wrapper._assertBlockParam(defaultBlock);
|
||||
}
|
||||
const marshalledDefaultBlock = marshaller.marshalBlockParam(defaultBlock);
|
||||
const encodedAddress = marshaller.marshalAddress(address);
|
||||
const nonceHex = await this.sendRawPayloadAsync<string>({
|
||||
method: 'eth_getTransactionCount',
|
||||
params: [encodedAddress, marshalledDefaultBlock],
|
||||
});
|
||||
assert.isHexString('nonce', nonceHex);
|
||||
// tslint:disable-next-line:custom-no-magic-numbers
|
||||
return parseInt(nonceHex.substr(2), 16);
|
||||
}
|
||||
/**
|
||||
* Fetch a specific Ethereum block without transaction data
|
||||
* @param blockParam The block you wish to fetch (blockHash, blockNumber or blockLiteral)
|
||||
|
@@ -35,8 +35,7 @@ describe('Web3Wrapper tests', () => {
|
||||
describe('#getNodeVersionAsync', () => {
|
||||
it('gets the node version', async () => {
|
||||
const nodeVersion = await web3Wrapper.getNodeVersionAsync();
|
||||
const NODE_VERSION = 'EthereumJS TestRPC/v2.9.0-istanbul.0/ethereum-js';
|
||||
expect(nodeVersion).to.be.equal(NODE_VERSION);
|
||||
expect(nodeVersion).to.be.match(/EthereumJS TestRPC\/.+\/ethereum-js$/);
|
||||
});
|
||||
});
|
||||
describe('#getNetworkIdAsync', () => {
|
||||
|
Reference in New Issue
Block a user