Make wrappers small again (#2243)
* introduce --debug option to abi-gen and remove debug functions from @0x/abi-gen-wrappers * make evmExecAsync protected; ignore deployedBytecode in doc comment * trim deployedBytecode so it's undefined unless a contract has pure functions * remove validateAndSendTransactionAsync * Create `AwaitTransactionSuccessOpts` and `SendTransactionOpts` types * Remove duplicate types `IndexedFilterValues`, `DecodedLogEvent`, `EventCallback` from `@0x/base-contract`
This commit is contained in:
parent
23198174f3
commit
0e90b0e7d0
@ -22,7 +22,7 @@
|
|||||||
"compile": "sol-compiler",
|
"compile": "sol-compiler",
|
||||||
"watch": "sol-compiler -w",
|
"watch": "sol-compiler -w",
|
||||||
"clean": "shx rm -rf lib generated-artifacts generated-wrappers",
|
"clean": "shx rm -rf lib generated-artifacts generated-wrappers",
|
||||||
"generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers",
|
"generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers",
|
||||||
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||||
"fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
"fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||||
"coverage:report:text": "istanbul report text",
|
"coverage:report:text": "istanbul report text",
|
||||||
|
@ -1,11 +1,4 @@
|
|||||||
import {
|
import { chaiSetup, expectTransactionFailedAsync, provider, txDefaults, web3Wrapper } from '@0x/contracts-test-utils';
|
||||||
chaiSetup,
|
|
||||||
constants,
|
|
||||||
expectTransactionFailedAsync,
|
|
||||||
provider,
|
|
||||||
txDefaults,
|
|
||||||
web3Wrapper,
|
|
||||||
} from '@0x/contracts-test-utils';
|
|
||||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||||
import { RevertReason } from '@0x/types';
|
import { RevertReason } from '@0x/types';
|
||||||
import { BigNumber } from '@0x/utils';
|
import { BigNumber } from '@0x/utils';
|
||||||
@ -60,21 +53,13 @@ describe('Authorizable', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should allow owner to add an authorized address', async () => {
|
it('should allow owner to add an authorized address', async () => {
|
||||||
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner });
|
||||||
address,
|
|
||||||
{ from: owner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
const isAuthorized = await authorizable.authorized.callAsync(address);
|
const isAuthorized = await authorizable.authorized.callAsync(address);
|
||||||
expect(isAuthorized).to.be.true();
|
expect(isAuthorized).to.be.true();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should revert if owner attempts to authorize a duplicate address', async () => {
|
it('should revert if owner attempts to authorize a duplicate address', async () => {
|
||||||
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner });
|
||||||
address,
|
|
||||||
{ from: owner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
return expectTransactionFailedAsync(
|
return expectTransactionFailedAsync(
|
||||||
authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }),
|
authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }),
|
||||||
RevertReason.TargetAlreadyAuthorized,
|
RevertReason.TargetAlreadyAuthorized,
|
||||||
@ -84,11 +69,7 @@ describe('Authorizable', () => {
|
|||||||
|
|
||||||
describe('removeAuthorizedAddress', () => {
|
describe('removeAuthorizedAddress', () => {
|
||||||
it('should revert if not called by owner', async () => {
|
it('should revert if not called by owner', async () => {
|
||||||
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner });
|
||||||
address,
|
|
||||||
{ from: owner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
await expectTransactionFailedAsync(
|
await expectTransactionFailedAsync(
|
||||||
authorizable.removeAuthorizedAddress.sendTransactionAsync(address, { from: notOwner }),
|
authorizable.removeAuthorizedAddress.sendTransactionAsync(address, { from: notOwner }),
|
||||||
RevertReason.OnlyContractOwner,
|
RevertReason.OnlyContractOwner,
|
||||||
@ -96,16 +77,8 @@ describe('Authorizable', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should allow owner to remove an authorized address', async () => {
|
it('should allow owner to remove an authorized address', async () => {
|
||||||
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner });
|
||||||
address,
|
await authorizable.removeAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner });
|
||||||
{ from: owner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
await authorizable.removeAuthorizedAddress.awaitTransactionSuccessAsync(
|
|
||||||
address,
|
|
||||||
{ from: owner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
const isAuthorized = await authorizable.authorized.callAsync(address);
|
const isAuthorized = await authorizable.authorized.callAsync(address);
|
||||||
expect(isAuthorized).to.be.false();
|
expect(isAuthorized).to.be.false();
|
||||||
});
|
});
|
||||||
@ -122,11 +95,7 @@ describe('Authorizable', () => {
|
|||||||
|
|
||||||
describe('removeAuthorizedAddressAtIndex', () => {
|
describe('removeAuthorizedAddressAtIndex', () => {
|
||||||
it('should revert if not called by owner', async () => {
|
it('should revert if not called by owner', async () => {
|
||||||
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner });
|
||||||
address,
|
|
||||||
{ from: owner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
const index = new BigNumber(0);
|
const index = new BigNumber(0);
|
||||||
await expectTransactionFailedAsync(
|
await expectTransactionFailedAsync(
|
||||||
authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(address, index, {
|
authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(address, index, {
|
||||||
@ -137,11 +106,7 @@ describe('Authorizable', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should revert if index is >= authorities.length', async () => {
|
it('should revert if index is >= authorities.length', async () => {
|
||||||
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner });
|
||||||
address,
|
|
||||||
{ from: owner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
const index = new BigNumber(1);
|
const index = new BigNumber(1);
|
||||||
return expectTransactionFailedAsync(
|
return expectTransactionFailedAsync(
|
||||||
authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(address, index, {
|
authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(address, index, {
|
||||||
@ -164,16 +129,8 @@ describe('Authorizable', () => {
|
|||||||
it('should revert if address at index does not match target', async () => {
|
it('should revert if address at index does not match target', async () => {
|
||||||
const address1 = address;
|
const address1 = address;
|
||||||
const address2 = notOwner;
|
const address2 = notOwner;
|
||||||
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address1, { from: owner });
|
||||||
address1,
|
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address2, { from: owner });
|
||||||
{ from: owner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
|
||||||
address2,
|
|
||||||
{ from: owner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
const address1Index = new BigNumber(0);
|
const address1Index = new BigNumber(0);
|
||||||
return expectTransactionFailedAsync(
|
return expectTransactionFailedAsync(
|
||||||
authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(address2, address1Index, {
|
authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(address2, address1Index, {
|
||||||
@ -184,18 +141,11 @@ describe('Authorizable', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should allow owner to remove an authorized address', async () => {
|
it('should allow owner to remove an authorized address', async () => {
|
||||||
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner });
|
||||||
address,
|
|
||||||
{ from: owner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
const index = new BigNumber(0);
|
const index = new BigNumber(0);
|
||||||
await authorizable.removeAuthorizedAddressAtIndex.awaitTransactionSuccessAsync(
|
await authorizable.removeAuthorizedAddressAtIndex.awaitTransactionSuccessAsync(address, index, {
|
||||||
address,
|
from: owner,
|
||||||
index,
|
});
|
||||||
{ from: owner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
const isAuthorized = await authorizable.authorized.callAsync(address);
|
const isAuthorized = await authorizable.authorized.callAsync(address);
|
||||||
expect(isAuthorized).to.be.false();
|
expect(isAuthorized).to.be.false();
|
||||||
});
|
});
|
||||||
@ -205,19 +155,11 @@ describe('Authorizable', () => {
|
|||||||
it('should return all authorized addresses', async () => {
|
it('should return all authorized addresses', async () => {
|
||||||
const initial = await authorizable.getAuthorizedAddresses.callAsync();
|
const initial = await authorizable.getAuthorizedAddresses.callAsync();
|
||||||
expect(initial).to.have.length(0);
|
expect(initial).to.have.length(0);
|
||||||
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner });
|
||||||
address,
|
|
||||||
{ from: owner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
const afterAdd = await authorizable.getAuthorizedAddresses.callAsync();
|
const afterAdd = await authorizable.getAuthorizedAddresses.callAsync();
|
||||||
expect(afterAdd).to.have.length(1);
|
expect(afterAdd).to.have.length(1);
|
||||||
expect(afterAdd).to.include(address);
|
expect(afterAdd).to.include(address);
|
||||||
await authorizable.removeAuthorizedAddress.awaitTransactionSuccessAsync(
|
await authorizable.removeAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner });
|
||||||
address,
|
|
||||||
{ from: owner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
const afterRemove = await authorizable.getAuthorizedAddresses.callAsync();
|
const afterRemove = await authorizable.getAuthorizedAddresses.callAsync();
|
||||||
expect(afterRemove).to.have.length(0);
|
expect(afterRemove).to.have.length(0);
|
||||||
});
|
});
|
||||||
|
@ -72,16 +72,8 @@ describe('ERC1155Proxy', () => {
|
|||||||
const usedAddresses = ([owner, notAuthorized, authorized, spender, receiver] = _.slice(accounts, 0, 5));
|
const usedAddresses = ([owner, notAuthorized, authorized, spender, receiver] = _.slice(accounts, 0, 5));
|
||||||
erc1155ProxyWrapper = new ERC1155ProxyWrapper(provider, usedAddresses, owner);
|
erc1155ProxyWrapper = new ERC1155ProxyWrapper(provider, usedAddresses, owner);
|
||||||
erc1155Proxy = await erc1155ProxyWrapper.deployProxyAsync();
|
erc1155Proxy = await erc1155ProxyWrapper.deployProxyAsync();
|
||||||
await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(authorized, { from: owner });
|
||||||
authorized,
|
await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(erc1155Proxy.address, { from: owner });
|
||||||
{ from: owner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
|
||||||
erc1155Proxy.address,
|
|
||||||
{ from: owner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
// deploy & configure ERC1155 tokens and receiver
|
// deploy & configure ERC1155 tokens and receiver
|
||||||
[erc1155Wrapper] = await erc1155ProxyWrapper.deployDummyContractsAsync();
|
[erc1155Wrapper] = await erc1155ProxyWrapper.deployDummyContractsAsync();
|
||||||
erc1155Contract = erc1155Wrapper.getContract();
|
erc1155Contract = erc1155Wrapper.getContract();
|
||||||
@ -696,25 +688,18 @@ describe('ERC1155Proxy', () => {
|
|||||||
const tokenUri = '';
|
const tokenUri = '';
|
||||||
for (const tokenToCreate of tokensToCreate) {
|
for (const tokenToCreate of tokensToCreate) {
|
||||||
// create token
|
// create token
|
||||||
await erc1155Wrapper.getContract().createWithType.awaitTransactionSuccessAsync(
|
await erc1155Wrapper
|
||||||
tokenToCreate,
|
.getContract()
|
||||||
tokenUri,
|
.createWithType.awaitTransactionSuccessAsync(tokenToCreate, tokenUri, {
|
||||||
{
|
|
||||||
from: owner,
|
from: owner,
|
||||||
},
|
});
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
|
|
||||||
// mint balance for spender
|
// mint balance for spender
|
||||||
await erc1155Wrapper.getContract().mintFungible.awaitTransactionSuccessAsync(
|
await erc1155Wrapper
|
||||||
tokenToCreate,
|
.getContract()
|
||||||
[spender],
|
.mintFungible.awaitTransactionSuccessAsync(tokenToCreate, [spender], [spenderInitialBalance], {
|
||||||
[spenderInitialBalance],
|
|
||||||
{
|
|
||||||
from: owner,
|
from: owner,
|
||||||
},
|
});
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
///// Step 2/5 /////
|
///// Step 2/5 /////
|
||||||
// Check balances before transfer
|
// Check balances before transfer
|
||||||
@ -805,25 +790,18 @@ describe('ERC1155Proxy', () => {
|
|||||||
const tokenUri = '';
|
const tokenUri = '';
|
||||||
for (const tokenToCreate of tokensToCreate) {
|
for (const tokenToCreate of tokensToCreate) {
|
||||||
// create token
|
// create token
|
||||||
await erc1155Wrapper.getContract().createWithType.awaitTransactionSuccessAsync(
|
await erc1155Wrapper
|
||||||
tokenToCreate,
|
.getContract()
|
||||||
tokenUri,
|
.createWithType.awaitTransactionSuccessAsync(tokenToCreate, tokenUri, {
|
||||||
{
|
|
||||||
from: owner,
|
from: owner,
|
||||||
},
|
});
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
|
|
||||||
// mint balance for spender
|
// mint balance for spender
|
||||||
await erc1155Wrapper.getContract().mintFungible.awaitTransactionSuccessAsync(
|
await erc1155Wrapper
|
||||||
tokenToCreate,
|
.getContract()
|
||||||
[spender],
|
.mintFungible.awaitTransactionSuccessAsync(tokenToCreate, [spender], [spenderInitialBalance], {
|
||||||
[spenderInitialBalance],
|
|
||||||
{
|
|
||||||
from: owner,
|
from: owner,
|
||||||
},
|
});
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
///// Step 2/5 /////
|
///// Step 2/5 /////
|
||||||
// Check balances before transfer
|
// Check balances before transfer
|
||||||
@ -937,25 +915,18 @@ describe('ERC1155Proxy', () => {
|
|||||||
const tokenUri = '';
|
const tokenUri = '';
|
||||||
for (const tokenToCreate of tokensToCreate) {
|
for (const tokenToCreate of tokensToCreate) {
|
||||||
// create token
|
// create token
|
||||||
await erc1155Wrapper.getContract().createWithType.awaitTransactionSuccessAsync(
|
await erc1155Wrapper
|
||||||
tokenToCreate,
|
.getContract()
|
||||||
tokenUri,
|
.createWithType.awaitTransactionSuccessAsync(tokenToCreate, tokenUri, {
|
||||||
{
|
|
||||||
from: owner,
|
from: owner,
|
||||||
},
|
});
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
|
|
||||||
// mint balance for spender
|
// mint balance for spender
|
||||||
await erc1155Wrapper.getContract().mintFungible.awaitTransactionSuccessAsync(
|
await erc1155Wrapper
|
||||||
tokenToCreate,
|
.getContract()
|
||||||
[spender],
|
.mintFungible.awaitTransactionSuccessAsync(tokenToCreate, [spender], [spenderInitialBalance], {
|
||||||
[spenderInitialBalance],
|
|
||||||
{
|
|
||||||
from: owner,
|
from: owner,
|
||||||
},
|
});
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
///// Step 2/5 /////
|
///// Step 2/5 /////
|
||||||
// Check balances before transfer
|
// Check balances before transfer
|
||||||
@ -1667,13 +1638,9 @@ describe('ERC1155Proxy', () => {
|
|||||||
it('should propagate revert reason from erc1155 contract failure', async () => {
|
it('should propagate revert reason from erc1155 contract failure', async () => {
|
||||||
// disable transfers
|
// disable transfers
|
||||||
const shouldRejectTransfer = true;
|
const shouldRejectTransfer = true;
|
||||||
await erc1155Receiver.setRejectTransferFlag.awaitTransactionSuccessAsync(
|
await erc1155Receiver.setRejectTransferFlag.awaitTransactionSuccessAsync(shouldRejectTransfer, {
|
||||||
shouldRejectTransfer,
|
from: owner,
|
||||||
{
|
});
|
||||||
from: owner,
|
|
||||||
},
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
// setup test parameters
|
// setup test parameters
|
||||||
const tokenHolders = [spender, receiverContract];
|
const tokenHolders = [spender, receiverContract];
|
||||||
const tokensToTransfer = fungibleTokens.slice(0, 1);
|
const tokensToTransfer = fungibleTokens.slice(0, 1);
|
||||||
|
@ -105,64 +105,24 @@ describe('Asset Transfer Proxies', () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Configure ERC20Proxy
|
// Configure ERC20Proxy
|
||||||
await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(authorized, { from: owner });
|
||||||
authorized,
|
await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxy.address, { from: owner });
|
||||||
{ from: owner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
|
||||||
multiAssetProxy.address,
|
|
||||||
{ from: owner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Configure ERC721Proxy
|
// Configure ERC721Proxy
|
||||||
await erc721Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
await erc721Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(authorized, { from: owner });
|
||||||
authorized,
|
await erc721Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxy.address, { from: owner });
|
||||||
{ from: owner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
await erc721Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
|
||||||
multiAssetProxy.address,
|
|
||||||
{ from: owner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Configure ERC115Proxy
|
// Configure ERC115Proxy
|
||||||
erc1155ProxyWrapper = new ERC1155ProxyWrapper(provider, usedAddresses, owner);
|
erc1155ProxyWrapper = new ERC1155ProxyWrapper(provider, usedAddresses, owner);
|
||||||
erc1155Proxy = await erc1155ProxyWrapper.deployProxyAsync();
|
erc1155Proxy = await erc1155ProxyWrapper.deployProxyAsync();
|
||||||
await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(authorized, { from: owner });
|
||||||
authorized,
|
await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxy.address, { from: owner });
|
||||||
{ from: owner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
|
||||||
multiAssetProxy.address,
|
|
||||||
{ from: owner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Configure MultiAssetProxy
|
// Configure MultiAssetProxy
|
||||||
await multiAssetProxy.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
await multiAssetProxy.addAuthorizedAddress.awaitTransactionSuccessAsync(authorized, { from: owner });
|
||||||
authorized,
|
await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, { from: owner });
|
||||||
{ from: owner },
|
await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(erc721Proxy.address, { from: owner });
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(erc1155Proxy.address, { from: owner });
|
||||||
);
|
|
||||||
await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(
|
|
||||||
erc20Proxy.address,
|
|
||||||
{ from: owner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(
|
|
||||||
erc721Proxy.address,
|
|
||||||
{ from: owner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(
|
|
||||||
erc1155Proxy.address,
|
|
||||||
{ from: owner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Deploy and configure ERC20 tokens
|
// Deploy and configure ERC20 tokens
|
||||||
const numDummyErc20ToDeploy = 2;
|
const numDummyErc20ToDeploy = 2;
|
||||||
@ -192,19 +152,13 @@ describe('Asset Transfer Proxies', () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
await erc20Wrapper.setBalancesAndAllowancesAsync();
|
await erc20Wrapper.setBalancesAndAllowancesAsync();
|
||||||
await noReturnErc20Token.setBalance.awaitTransactionSuccessAsync(
|
await noReturnErc20Token.setBalance.awaitTransactionSuccessAsync(fromAddress, constants.INITIAL_ERC20_BALANCE, {
|
||||||
fromAddress,
|
from: owner,
|
||||||
constants.INITIAL_ERC20_BALANCE,
|
});
|
||||||
{
|
|
||||||
from: owner,
|
|
||||||
},
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
await noReturnErc20Token.approve.awaitTransactionSuccessAsync(
|
await noReturnErc20Token.approve.awaitTransactionSuccessAsync(
|
||||||
erc20Proxy.address,
|
erc20Proxy.address,
|
||||||
constants.INITIAL_ERC20_ALLOWANCE,
|
constants.INITIAL_ERC20_ALLOWANCE,
|
||||||
{ from: fromAddress },
|
{ from: fromAddress },
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
);
|
||||||
await multipleReturnErc20Token.setBalance.awaitTransactionSuccessAsync(
|
await multipleReturnErc20Token.setBalance.awaitTransactionSuccessAsync(
|
||||||
fromAddress,
|
fromAddress,
|
||||||
@ -212,13 +166,11 @@ describe('Asset Transfer Proxies', () => {
|
|||||||
{
|
{
|
||||||
from: owner,
|
from: owner,
|
||||||
},
|
},
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
);
|
||||||
await multipleReturnErc20Token.approve.awaitTransactionSuccessAsync(
|
await multipleReturnErc20Token.approve.awaitTransactionSuccessAsync(
|
||||||
erc20Proxy.address,
|
erc20Proxy.address,
|
||||||
constants.INITIAL_ERC20_ALLOWANCE,
|
constants.INITIAL_ERC20_ALLOWANCE,
|
||||||
{ from: fromAddress },
|
{ from: fromAddress },
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Deploy and configure ERC721 tokens and receiver
|
// Deploy and configure ERC721 tokens and receiver
|
||||||
@ -407,12 +359,9 @@ describe('Asset Transfer Proxies', () => {
|
|||||||
toAddress,
|
toAddress,
|
||||||
amount,
|
amount,
|
||||||
);
|
);
|
||||||
await erc20TokenA.approve.awaitTransactionSuccessAsync(
|
await erc20TokenA.approve.awaitTransactionSuccessAsync(erc20Proxy.address, allowance, {
|
||||||
erc20Proxy.address,
|
from: fromAddress,
|
||||||
allowance,
|
});
|
||||||
{ from: fromAddress },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
const erc20Balances = await erc20Wrapper.getBalancesAsync();
|
const erc20Balances = await erc20Wrapper.getBalancesAsync();
|
||||||
// Perform a transfer; expect this to fail.
|
// Perform a transfer; expect this to fail.
|
||||||
await expectTransactionFailedAsync(
|
await expectTransactionFailedAsync(
|
||||||
@ -439,12 +388,9 @@ describe('Asset Transfer Proxies', () => {
|
|||||||
toAddress,
|
toAddress,
|
||||||
amount,
|
amount,
|
||||||
);
|
);
|
||||||
await noReturnErc20Token.approve.awaitTransactionSuccessAsync(
|
await noReturnErc20Token.approve.awaitTransactionSuccessAsync(erc20Proxy.address, allowance, {
|
||||||
erc20Proxy.address,
|
from: fromAddress,
|
||||||
allowance,
|
});
|
||||||
{ from: fromAddress },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
const initialFromBalance = await noReturnErc20Token.balanceOf.callAsync(fromAddress);
|
const initialFromBalance = await noReturnErc20Token.balanceOf.callAsync(fromAddress);
|
||||||
const initialToBalance = await noReturnErc20Token.balanceOf.callAsync(toAddress);
|
const initialToBalance = await noReturnErc20Token.balanceOf.callAsync(toAddress);
|
||||||
// Perform a transfer; expect this to fail.
|
// Perform a transfer; expect this to fail.
|
||||||
@ -680,19 +626,13 @@ describe('Asset Transfer Proxies', () => {
|
|||||||
const ownerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId);
|
const ownerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId);
|
||||||
expect(ownerFromAsset).to.be.equal(fromAddress);
|
expect(ownerFromAsset).to.be.equal(fromAddress);
|
||||||
// Remove blanket transfer approval for fromAddress.
|
// Remove blanket transfer approval for fromAddress.
|
||||||
await erc721TokenA.setApprovalForAll.awaitTransactionSuccessAsync(
|
await erc721TokenA.setApprovalForAll.awaitTransactionSuccessAsync(erc721Proxy.address, false, {
|
||||||
erc721Proxy.address,
|
from: fromAddress,
|
||||||
false,
|
});
|
||||||
{ from: fromAddress },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
// Remove token transfer approval for fromAddress.
|
// Remove token transfer approval for fromAddress.
|
||||||
await erc721TokenA.approve.awaitTransactionSuccessAsync(
|
await erc721TokenA.approve.awaitTransactionSuccessAsync(constants.NULL_ADDRESS, erc721AFromTokenId, {
|
||||||
constants.NULL_ADDRESS,
|
from: fromAddress,
|
||||||
erc721AFromTokenId,
|
});
|
||||||
{ from: fromAddress },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
// Perform a transfer; expect this to fail.
|
// Perform a transfer; expect this to fail.
|
||||||
const amount = new BigNumber(1);
|
const amount = new BigNumber(1);
|
||||||
const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData(
|
const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData(
|
||||||
|
@ -70,13 +70,11 @@ export class ERC20Wrapper {
|
|||||||
tokenOwnerAddress,
|
tokenOwnerAddress,
|
||||||
constants.INITIAL_ERC20_BALANCE,
|
constants.INITIAL_ERC20_BALANCE,
|
||||||
{ from: this._contractOwnerAddress },
|
{ from: this._contractOwnerAddress },
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
);
|
||||||
await dummyTokenContract.approve.awaitTransactionSuccessAsync(
|
await dummyTokenContract.approve.awaitTransactionSuccessAsync(
|
||||||
(this._proxyContract as ERC20ProxyContract).address,
|
(this._proxyContract as ERC20ProxyContract).address,
|
||||||
constants.INITIAL_ERC20_ALLOWANCE,
|
constants.INITIAL_ERC20_ALLOWANCE,
|
||||||
{ from: tokenOwnerAddress },
|
{ from: tokenOwnerAddress },
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -88,12 +86,9 @@ export class ERC20Wrapper {
|
|||||||
}
|
}
|
||||||
public async setBalanceAsync(userAddress: string, assetData: string, amount: BigNumber): Promise<void> {
|
public async setBalanceAsync(userAddress: string, assetData: string, amount: BigNumber): Promise<void> {
|
||||||
const tokenContract = this._getTokenContractFromAssetData(assetData);
|
const tokenContract = this._getTokenContractFromAssetData(assetData);
|
||||||
await tokenContract.setBalance.awaitTransactionSuccessAsync(
|
await tokenContract.setBalance.awaitTransactionSuccessAsync(userAddress, amount, {
|
||||||
userAddress,
|
from: this._contractOwnerAddress,
|
||||||
amount,
|
});
|
||||||
{ from: this._contractOwnerAddress },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
public async getProxyAllowanceAsync(userAddress: string, assetData: string): Promise<BigNumber> {
|
public async getProxyAllowanceAsync(userAddress: string, assetData: string): Promise<BigNumber> {
|
||||||
const tokenContract = this._getTokenContractFromAssetData(assetData);
|
const tokenContract = this._getTokenContractFromAssetData(assetData);
|
||||||
@ -104,12 +99,7 @@ export class ERC20Wrapper {
|
|||||||
public async setAllowanceAsync(userAddress: string, assetData: string, amount: BigNumber): Promise<void> {
|
public async setAllowanceAsync(userAddress: string, assetData: string, amount: BigNumber): Promise<void> {
|
||||||
const tokenContract = this._getTokenContractFromAssetData(assetData);
|
const tokenContract = this._getTokenContractFromAssetData(assetData);
|
||||||
const proxyAddress = (this._proxyContract as ERC20ProxyContract).address;
|
const proxyAddress = (this._proxyContract as ERC20ProxyContract).address;
|
||||||
await tokenContract.approve.awaitTransactionSuccessAsync(
|
await tokenContract.approve.awaitTransactionSuccessAsync(proxyAddress, amount, { from: userAddress });
|
||||||
proxyAddress,
|
|
||||||
amount,
|
|
||||||
{ from: userAddress },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
public async getBalancesAsync(): Promise<ERC20BalancesByOwner> {
|
public async getBalancesAsync(): Promise<ERC20BalancesByOwner> {
|
||||||
this._validateDummyTokenContractsExistOrThrow();
|
this._validateDummyTokenContractsExistOrThrow();
|
||||||
|
@ -93,22 +93,14 @@ export class ERC721Wrapper {
|
|||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
|
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
|
||||||
const proxyAddress = (this._proxyContract as ERC721ProxyContract).address;
|
const proxyAddress = (this._proxyContract as ERC721ProxyContract).address;
|
||||||
await tokenContract.setApprovalForAll.awaitTransactionSuccessAsync(
|
await tokenContract.setApprovalForAll.awaitTransactionSuccessAsync(proxyAddress, isApproved, {
|
||||||
proxyAddress,
|
from: ownerAddress,
|
||||||
isApproved,
|
});
|
||||||
{ from: ownerAddress },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
public async approveAsync(to: string, tokenAddress: string, tokenId: BigNumber): Promise<void> {
|
public async approveAsync(to: string, tokenAddress: string, tokenId: BigNumber): Promise<void> {
|
||||||
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
|
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
|
||||||
const tokenOwner = await this.ownerOfAsync(tokenAddress, tokenId);
|
const tokenOwner = await this.ownerOfAsync(tokenAddress, tokenId);
|
||||||
await tokenContract.approve.awaitTransactionSuccessAsync(
|
await tokenContract.approve.awaitTransactionSuccessAsync(to, tokenId, { from: tokenOwner });
|
||||||
to,
|
|
||||||
tokenId,
|
|
||||||
{ from: tokenOwner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
public async transferFromAsync(
|
public async transferFromAsync(
|
||||||
tokenAddress: string,
|
tokenAddress: string,
|
||||||
@ -117,31 +109,19 @@ export class ERC721Wrapper {
|
|||||||
userAddress: string,
|
userAddress: string,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
|
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
|
||||||
await tokenContract.transferFrom.awaitTransactionSuccessAsync(
|
await tokenContract.transferFrom.awaitTransactionSuccessAsync(currentOwner, userAddress, tokenId, {
|
||||||
currentOwner,
|
from: currentOwner,
|
||||||
userAddress,
|
});
|
||||||
tokenId,
|
|
||||||
{ from: currentOwner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
public async mintAsync(tokenAddress: string, tokenId: BigNumber, userAddress: string): Promise<void> {
|
public async mintAsync(tokenAddress: string, tokenId: BigNumber, userAddress: string): Promise<void> {
|
||||||
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
|
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
|
||||||
await tokenContract.mint.awaitTransactionSuccessAsync(
|
await tokenContract.mint.awaitTransactionSuccessAsync(userAddress, tokenId, {
|
||||||
userAddress,
|
from: this._contractOwnerAddress,
|
||||||
tokenId,
|
});
|
||||||
{ from: this._contractOwnerAddress },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
public async burnAsync(tokenAddress: string, tokenId: BigNumber, owner: string): Promise<void> {
|
public async burnAsync(tokenAddress: string, tokenId: BigNumber, owner: string): Promise<void> {
|
||||||
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
|
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
|
||||||
await tokenContract.burn.awaitTransactionSuccessAsync(
|
await tokenContract.burn.awaitTransactionSuccessAsync(owner, tokenId, { from: this._contractOwnerAddress });
|
||||||
owner,
|
|
||||||
tokenId,
|
|
||||||
{ from: this._contractOwnerAddress },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
public async ownerOfAsync(tokenAddress: string, tokenId: BigNumber): Promise<string> {
|
public async ownerOfAsync(tokenAddress: string, tokenId: BigNumber): Promise<string> {
|
||||||
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
|
const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
"compile": "sol-compiler",
|
"compile": "sol-compiler",
|
||||||
"watch": "sol-compiler -w",
|
"watch": "sol-compiler -w",
|
||||||
"clean": "shx rm -rf lib generated-artifacts generated-wrappers",
|
"clean": "shx rm -rf lib generated-artifacts generated-wrappers",
|
||||||
"generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers",
|
"generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers",
|
||||||
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||||
"fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
"fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||||
"coverage:report:text": "istanbul report text",
|
"coverage:report:text": "istanbul report text",
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
"compile": "sol-compiler",
|
"compile": "sol-compiler",
|
||||||
"watch": "sol-compiler -w",
|
"watch": "sol-compiler -w",
|
||||||
"clean": "shx rm -rf lib generated-artifacts generated-wrappers",
|
"clean": "shx rm -rf lib generated-artifacts generated-wrappers",
|
||||||
"generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers",
|
"generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers",
|
||||||
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||||
"fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
"fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||||
"coverage:report:text": "istanbul report text",
|
"coverage:report:text": "istanbul report text",
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
"compile": "sol-compiler",
|
"compile": "sol-compiler",
|
||||||
"watch": "sol-compiler -w",
|
"watch": "sol-compiler -w",
|
||||||
"clean": "shx rm -rf lib generated-artifacts generated-wrappers",
|
"clean": "shx rm -rf lib generated-artifacts generated-wrappers",
|
||||||
"generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers",
|
"generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers",
|
||||||
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||||
"fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
"fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||||
"coverage:report:text": "istanbul report text",
|
"coverage:report:text": "istanbul report text",
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { constants, LogDecoder } from '@0x/contracts-test-utils';
|
import { LogDecoder } from '@0x/contracts-test-utils';
|
||||||
import { BigNumber } from '@0x/utils';
|
import { BigNumber } from '@0x/utils';
|
||||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||||
import * as chai from 'chai';
|
import * as chai from 'chai';
|
||||||
@ -100,7 +100,6 @@ export class Erc1155Wrapper {
|
|||||||
beneficiaries,
|
beneficiaries,
|
||||||
tokenAmountsAsArray,
|
tokenAmountsAsArray,
|
||||||
{ from: this._contractOwner },
|
{ from: this._contractOwner },
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
public async mintNonFungibleTokensAsync(beneficiaries: string[]): Promise<[BigNumber, BigNumber[]]> {
|
public async mintNonFungibleTokensAsync(beneficiaries: string[]): Promise<[BigNumber, BigNumber[]]> {
|
||||||
@ -114,12 +113,9 @@ export class Erc1155Wrapper {
|
|||||||
// tslint:disable-next-line no-unnecessary-type-assertion
|
// tslint:disable-next-line no-unnecessary-type-assertion
|
||||||
const createFungibleTokenLog = tx.logs[0] as LogWithDecodedArgs<ERC1155TransferSingleEventArgs>;
|
const createFungibleTokenLog = tx.logs[0] as LogWithDecodedArgs<ERC1155TransferSingleEventArgs>;
|
||||||
const token = createFungibleTokenLog.args.id;
|
const token = createFungibleTokenLog.args.id;
|
||||||
await this._erc1155Contract.mintNonFungible.awaitTransactionSuccessAsync(
|
await this._erc1155Contract.mintNonFungible.awaitTransactionSuccessAsync(token, beneficiaries, {
|
||||||
token,
|
from: this._contractOwner,
|
||||||
beneficiaries,
|
});
|
||||||
{ from: this._contractOwner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
const encodedNftIds: BigNumber[] = [];
|
const encodedNftIds: BigNumber[] = [];
|
||||||
const nftIdBegin = 1;
|
const nftIdBegin = 1;
|
||||||
const nftIdEnd = beneficiaries.length + 1;
|
const nftIdEnd = beneficiaries.length + 1;
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
"compile": "sol-compiler",
|
"compile": "sol-compiler",
|
||||||
"watch": "sol-compiler -w",
|
"watch": "sol-compiler -w",
|
||||||
"clean": "shx rm -rf lib generated-artifacts generated-wrappers",
|
"clean": "shx rm -rf lib generated-artifacts generated-wrappers",
|
||||||
"generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers",
|
"generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers",
|
||||||
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||||
"fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
"fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||||
"coverage:report:text": "istanbul report text",
|
"coverage:report:text": "istanbul report text",
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
"compile": "sol-compiler",
|
"compile": "sol-compiler",
|
||||||
"watch": "sol-compiler -w",
|
"watch": "sol-compiler -w",
|
||||||
"clean": "shx rm -rf lib generated-artifacts generated-wrappers",
|
"clean": "shx rm -rf lib generated-artifacts generated-wrappers",
|
||||||
"generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers",
|
"generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers",
|
||||||
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||||
"fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
"fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||||
"coverage:report:text": "istanbul report text",
|
"coverage:report:text": "istanbul report text",
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
"compile": "sol-compiler",
|
"compile": "sol-compiler",
|
||||||
"watch": "sol-compiler -w",
|
"watch": "sol-compiler -w",
|
||||||
"clean": "shx rm -rf lib generated-artifacts generated-wrappers",
|
"clean": "shx rm -rf lib generated-artifacts generated-wrappers",
|
||||||
"generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers",
|
"generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers",
|
||||||
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||||
"coverage:report:text": "istanbul report text",
|
"coverage:report:text": "istanbul report text",
|
||||||
"coverage:report:html": "istanbul report html && open coverage/index.html",
|
"coverage:report:html": "istanbul report html && open coverage/index.html",
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
"compile": "sol-compiler",
|
"compile": "sol-compiler",
|
||||||
"watch": "sol-compiler -w",
|
"watch": "sol-compiler -w",
|
||||||
"clean": "shx rm -rf lib generated-artifacts generated-wrappers",
|
"clean": "shx rm -rf lib generated-artifacts generated-wrappers",
|
||||||
"generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers",
|
"generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers",
|
||||||
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||||
"fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
"fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||||
"coverage:report:text": "istanbul report text",
|
"coverage:report:text": "istanbul report text",
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
"compile": "sol-compiler",
|
"compile": "sol-compiler",
|
||||||
"watch": "sol-compiler -w",
|
"watch": "sol-compiler -w",
|
||||||
"clean": "shx rm -rf lib generated-artifacts generated-wrappers",
|
"clean": "shx rm -rf lib generated-artifacts generated-wrappers",
|
||||||
"generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers",
|
"generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers",
|
||||||
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||||
"fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
"fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||||
"coverage:report:text": "istanbul report text",
|
"coverage:report:text": "istanbul report text",
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { PromiseWithTransactionHash } from '@0x/base-contract';
|
import { PromiseWithTransactionHash } from '@0x/base-contract';
|
||||||
|
import { AwaitTransactionSuccessOpts } from '@0x/types';
|
||||||
import { BlockParam, CallData, TransactionReceiptWithDecodedLogs, TxData } from 'ethereum-types';
|
import { BlockParam, CallData, TransactionReceiptWithDecodedLogs, TxData } from 'ethereum-types';
|
||||||
|
|
||||||
// Generated Wrapper Interfaces
|
// Generated Wrapper Interfaces
|
||||||
@ -7,8 +8,7 @@ export interface AssetProxyDispatcher {
|
|||||||
awaitTransactionSuccessAsync: (
|
awaitTransactionSuccessAsync: (
|
||||||
assetProxy: string,
|
assetProxy: string,
|
||||||
txData?: Partial<TxData>,
|
txData?: Partial<TxData>,
|
||||||
pollingIntervalMs?: number,
|
txOpts?: AwaitTransactionSuccessOpts,
|
||||||
timeoutMs?: number,
|
|
||||||
) => PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>;
|
) => PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>;
|
||||||
};
|
};
|
||||||
getAssetProxy: {
|
getAssetProxy: {
|
||||||
@ -21,16 +21,14 @@ export interface Authorizable extends Ownable {
|
|||||||
awaitTransactionSuccessAsync: (
|
awaitTransactionSuccessAsync: (
|
||||||
target: string,
|
target: string,
|
||||||
txData?: Partial<TxData>,
|
txData?: Partial<TxData>,
|
||||||
pollingIntervalMs?: number,
|
txOpts?: AwaitTransactionSuccessOpts,
|
||||||
timeoutMs?: number,
|
|
||||||
) => PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>;
|
) => PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>;
|
||||||
};
|
};
|
||||||
removeAuthorizedAddress: {
|
removeAuthorizedAddress: {
|
||||||
awaitTransactionSuccessAsync: (
|
awaitTransactionSuccessAsync: (
|
||||||
target: string,
|
target: string,
|
||||||
txData?: Partial<TxData>,
|
txData?: Partial<TxData>,
|
||||||
pollingIntervalMs?: number,
|
txOpts?: AwaitTransactionSuccessOpts,
|
||||||
timeoutMs?: number,
|
|
||||||
) => PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>;
|
) => PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>;
|
||||||
};
|
};
|
||||||
authorized: {
|
authorized: {
|
||||||
@ -46,8 +44,7 @@ export interface Ownable {
|
|||||||
awaitTransactionSuccessAsync: (
|
awaitTransactionSuccessAsync: (
|
||||||
newOwner: string,
|
newOwner: string,
|
||||||
txData?: Partial<TxData>,
|
txData?: Partial<TxData>,
|
||||||
pollingIntervalMs?: number,
|
txOpts?: AwaitTransactionSuccessOpts,
|
||||||
timeoutMs?: number,
|
|
||||||
) => PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>;
|
) => PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>;
|
||||||
};
|
};
|
||||||
owner: {
|
owner: {
|
||||||
|
@ -141,56 +141,30 @@ describe('matchOrders', () => {
|
|||||||
await exchangeWrapper.registerAssetProxyAsync(erc1155Proxy.address, owner);
|
await exchangeWrapper.registerAssetProxyAsync(erc1155Proxy.address, owner);
|
||||||
await exchangeWrapper.registerAssetProxyAsync(multiAssetProxyContract.address, owner);
|
await exchangeWrapper.registerAssetProxyAsync(multiAssetProxyContract.address, owner);
|
||||||
// Authorize proxies.
|
// Authorize proxies.
|
||||||
await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address, { from: owner });
|
||||||
exchange.address,
|
await erc721Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address, { from: owner });
|
||||||
{ from: owner },
|
await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address, { from: owner });
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
await multiAssetProxyContract.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address, {
|
||||||
);
|
from: owner,
|
||||||
await erc721Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
});
|
||||||
exchange.address,
|
await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxyContract.address, {
|
||||||
{ from: owner },
|
from: owner,
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
});
|
||||||
);
|
await erc721Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxyContract.address, {
|
||||||
await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
from: owner,
|
||||||
exchange.address,
|
});
|
||||||
{ from: owner },
|
await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxyContract.address, {
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
from: owner,
|
||||||
);
|
});
|
||||||
await multiAssetProxyContract.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
await multiAssetProxyContract.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, {
|
||||||
exchange.address,
|
from: owner,
|
||||||
{ from: owner },
|
});
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
await multiAssetProxyContract.registerAssetProxy.awaitTransactionSuccessAsync(erc721Proxy.address, {
|
||||||
);
|
from: owner,
|
||||||
await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
});
|
||||||
multiAssetProxyContract.address,
|
await multiAssetProxyContract.registerAssetProxy.awaitTransactionSuccessAsync(erc1155Proxy.address, {
|
||||||
{ from: owner },
|
from: owner,
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
});
|
||||||
);
|
|
||||||
await erc721Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
|
||||||
multiAssetProxyContract.address,
|
|
||||||
{ from: owner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
|
||||||
multiAssetProxyContract.address,
|
|
||||||
{ from: owner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
await multiAssetProxyContract.registerAssetProxy.awaitTransactionSuccessAsync(
|
|
||||||
erc20Proxy.address,
|
|
||||||
{ from: owner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
await multiAssetProxyContract.registerAssetProxy.awaitTransactionSuccessAsync(
|
|
||||||
erc721Proxy.address,
|
|
||||||
{ from: owner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
await multiAssetProxyContract.registerAssetProxy.awaitTransactionSuccessAsync(
|
|
||||||
erc1155Proxy.address,
|
|
||||||
{ from: owner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Set default addresses
|
// Set default addresses
|
||||||
defaultERC20MakerAssetAddress = erc20Tokens[0].address;
|
defaultERC20MakerAssetAddress = erc20Tokens[0].address;
|
||||||
|
@ -123,65 +123,37 @@ export async function fillOrderCombinatorialUtilsFactoryAsync(
|
|||||||
await exchangeWrapper.registerAssetProxyAsync(erc1155Proxy.address, ownerAddress);
|
await exchangeWrapper.registerAssetProxyAsync(erc1155Proxy.address, ownerAddress);
|
||||||
await exchangeWrapper.registerAssetProxyAsync(multiAssetProxy.address, ownerAddress);
|
await exchangeWrapper.registerAssetProxyAsync(multiAssetProxy.address, ownerAddress);
|
||||||
|
|
||||||
await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchangeContract.address, {
|
||||||
exchangeContract.address,
|
from: ownerAddress,
|
||||||
{ from: ownerAddress },
|
});
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
|
|
||||||
await erc721Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
await erc721Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchangeContract.address, {
|
||||||
exchangeContract.address,
|
from: ownerAddress,
|
||||||
{ from: ownerAddress },
|
});
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
|
|
||||||
await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchangeContract.address, {
|
||||||
exchangeContract.address,
|
from: ownerAddress,
|
||||||
{ from: ownerAddress },
|
});
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
|
|
||||||
await multiAssetProxy.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
await multiAssetProxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchangeContract.address, {
|
||||||
exchangeContract.address,
|
from: ownerAddress,
|
||||||
{ from: ownerAddress },
|
});
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
|
|
||||||
await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxy.address, { from: ownerAddress });
|
||||||
multiAssetProxy.address,
|
|
||||||
{ from: ownerAddress },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
|
|
||||||
await erc721Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
await erc721Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxy.address, {
|
||||||
multiAssetProxy.address,
|
from: ownerAddress,
|
||||||
{ from: ownerAddress },
|
});
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
|
|
||||||
await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
await erc1155Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(multiAssetProxy.address, {
|
||||||
multiAssetProxy.address,
|
from: ownerAddress,
|
||||||
{ from: ownerAddress },
|
});
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
|
|
||||||
await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(
|
await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, { from: ownerAddress });
|
||||||
erc20Proxy.address,
|
|
||||||
{ from: ownerAddress },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
|
|
||||||
await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(
|
await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(erc721Proxy.address, { from: ownerAddress });
|
||||||
erc721Proxy.address,
|
|
||||||
{ from: ownerAddress },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
|
|
||||||
await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(
|
await multiAssetProxy.registerAssetProxy.awaitTransactionSuccessAsync(erc1155Proxy.address, { from: ownerAddress });
|
||||||
erc1155Proxy.address,
|
|
||||||
{ from: ownerAddress },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
|
|
||||||
const orderFactory = new OrderFactoryFromScenario(
|
const orderFactory = new OrderFactoryFromScenario(
|
||||||
userAddresses,
|
userAddresses,
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
"compile": "sol-compiler",
|
"compile": "sol-compiler",
|
||||||
"watch": "sol-compiler -w",
|
"watch": "sol-compiler -w",
|
||||||
"clean": "shx rm -rf lib generated-artifacts generated-wrappers",
|
"clean": "shx rm -rf lib generated-artifacts generated-wrappers",
|
||||||
"generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers",
|
"generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers",
|
||||||
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||||
"fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
"fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||||
"coverage:report:text": "istanbul report text",
|
"coverage:report:text": "istanbul report text",
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
"compile": "sol-compiler",
|
"compile": "sol-compiler",
|
||||||
"watch": "sol-compiler -w",
|
"watch": "sol-compiler -w",
|
||||||
"clean": "shx rm -rf lib generated-artifacts generated-wrappers",
|
"clean": "shx rm -rf lib generated-artifacts generated-wrappers",
|
||||||
"generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers",
|
"generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers",
|
||||||
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||||
"fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
"fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||||
"coverage:report:text": "istanbul report text",
|
"coverage:report:text": "istanbul report text",
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
"compile": "sol-compiler",
|
"compile": "sol-compiler",
|
||||||
"watch": "sol-compiler -w",
|
"watch": "sol-compiler -w",
|
||||||
"clean": "shx rm -rf lib generated-artifacts generated-wrappers",
|
"clean": "shx rm -rf lib generated-artifacts generated-wrappers",
|
||||||
"generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers",
|
"generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers",
|
||||||
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||||
"fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
"fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||||
"coverage:report:text": "istanbul report text",
|
"coverage:report:text": "istanbul report text",
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
"compile": "sol-compiler",
|
"compile": "sol-compiler",
|
||||||
"watch": "sol-compiler -w",
|
"watch": "sol-compiler -w",
|
||||||
"clean": "shx rm -rf lib generated-artifacts generated-wrappers",
|
"clean": "shx rm -rf lib generated-artifacts generated-wrappers",
|
||||||
"generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers",
|
"generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output generated-wrappers --backend ethers",
|
||||||
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||||
"fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
"fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||||
"coverage:report:text": "istanbul report text",
|
"coverage:report:text": "istanbul report text",
|
||||||
|
@ -63,11 +63,7 @@ describe('Authorizable', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should revert if owner attempts to authorize a duplicate address', async () => {
|
it('should revert if owner attempts to authorize a duplicate address', async () => {
|
||||||
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner });
|
||||||
address,
|
|
||||||
{ from: owner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
const expectedError = new AuthorizableRevertErrors.TargetAlreadyAuthorizedError(address);
|
const expectedError = new AuthorizableRevertErrors.TargetAlreadyAuthorizedError(address);
|
||||||
const tx = authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner });
|
const tx = authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner });
|
||||||
return expect(tx).to.revertWith(expectedError);
|
return expect(tx).to.revertWith(expectedError);
|
||||||
@ -76,27 +72,15 @@ describe('Authorizable', () => {
|
|||||||
|
|
||||||
describe('removeAuthorizedAddress', () => {
|
describe('removeAuthorizedAddress', () => {
|
||||||
it('should revert if not called by owner', async () => {
|
it('should revert if not called by owner', async () => {
|
||||||
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner });
|
||||||
address,
|
|
||||||
{ from: owner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
const expectedError = new OwnableRevertErrors.OnlyOwnerError(notOwner, owner);
|
const expectedError = new OwnableRevertErrors.OnlyOwnerError(notOwner, owner);
|
||||||
const tx = authorizable.removeAuthorizedAddress.sendTransactionAsync(address, { from: notOwner });
|
const tx = authorizable.removeAuthorizedAddress.sendTransactionAsync(address, { from: notOwner });
|
||||||
return expect(tx).to.revertWith(expectedError);
|
return expect(tx).to.revertWith(expectedError);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should allow owner to remove an authorized address', async () => {
|
it('should allow owner to remove an authorized address', async () => {
|
||||||
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner });
|
||||||
address,
|
await authorizable.removeAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner });
|
||||||
{ from: owner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
await authorizable.removeAuthorizedAddress.awaitTransactionSuccessAsync(
|
|
||||||
address,
|
|
||||||
{ from: owner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
const isAuthorized = await authorizable.authorized.callAsync(address);
|
const isAuthorized = await authorizable.authorized.callAsync(address);
|
||||||
expect(isAuthorized).to.be.false();
|
expect(isAuthorized).to.be.false();
|
||||||
});
|
});
|
||||||
@ -110,11 +94,7 @@ describe('Authorizable', () => {
|
|||||||
|
|
||||||
describe('removeAuthorizedAddressAtIndex', () => {
|
describe('removeAuthorizedAddressAtIndex', () => {
|
||||||
it('should revert if not called by owner', async () => {
|
it('should revert if not called by owner', async () => {
|
||||||
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner });
|
||||||
address,
|
|
||||||
{ from: owner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
const index = new BigNumber(0);
|
const index = new BigNumber(0);
|
||||||
const expectedError = new OwnableRevertErrors.OnlyOwnerError(notOwner, owner);
|
const expectedError = new OwnableRevertErrors.OnlyOwnerError(notOwner, owner);
|
||||||
const tx = authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(address, index, {
|
const tx = authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(address, index, {
|
||||||
@ -124,11 +104,7 @@ describe('Authorizable', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should revert if index is >= authorities.length', async () => {
|
it('should revert if index is >= authorities.length', async () => {
|
||||||
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner });
|
||||||
address,
|
|
||||||
{ from: owner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
const index = new BigNumber(1);
|
const index = new BigNumber(1);
|
||||||
const expectedError = new AuthorizableRevertErrors.IndexOutOfBoundsError(index, index);
|
const expectedError = new AuthorizableRevertErrors.IndexOutOfBoundsError(index, index);
|
||||||
const tx = authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(address, index, {
|
const tx = authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(address, index, {
|
||||||
@ -149,16 +125,8 @@ describe('Authorizable', () => {
|
|||||||
it('should revert if address at index does not match target', async () => {
|
it('should revert if address at index does not match target', async () => {
|
||||||
const address1 = address;
|
const address1 = address;
|
||||||
const address2 = notOwner;
|
const address2 = notOwner;
|
||||||
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address1, { from: owner });
|
||||||
address1,
|
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address2, { from: owner });
|
||||||
{ from: owner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
|
||||||
address2,
|
|
||||||
{ from: owner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
const address1Index = new BigNumber(0);
|
const address1Index = new BigNumber(0);
|
||||||
const expectedError = new AuthorizableRevertErrors.AuthorizedAddressMismatchError(address1, address2);
|
const expectedError = new AuthorizableRevertErrors.AuthorizedAddressMismatchError(address1, address2);
|
||||||
const tx = authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(address2, address1Index, {
|
const tx = authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(address2, address1Index, {
|
||||||
@ -168,18 +136,11 @@ describe('Authorizable', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should allow owner to remove an authorized address', async () => {
|
it('should allow owner to remove an authorized address', async () => {
|
||||||
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner });
|
||||||
address,
|
|
||||||
{ from: owner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
const index = new BigNumber(0);
|
const index = new BigNumber(0);
|
||||||
await authorizable.removeAuthorizedAddressAtIndex.awaitTransactionSuccessAsync(
|
await authorizable.removeAuthorizedAddressAtIndex.awaitTransactionSuccessAsync(address, index, {
|
||||||
address,
|
from: owner,
|
||||||
index,
|
});
|
||||||
{ from: owner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
const isAuthorized = await authorizable.authorized.callAsync(address);
|
const isAuthorized = await authorizable.authorized.callAsync(address);
|
||||||
expect(isAuthorized).to.be.false();
|
expect(isAuthorized).to.be.false();
|
||||||
});
|
});
|
||||||
@ -189,19 +150,11 @@ describe('Authorizable', () => {
|
|||||||
it('should return all authorized addresses', async () => {
|
it('should return all authorized addresses', async () => {
|
||||||
const initial = await authorizable.getAuthorizedAddresses.callAsync();
|
const initial = await authorizable.getAuthorizedAddresses.callAsync();
|
||||||
expect(initial).to.have.length(0);
|
expect(initial).to.have.length(0);
|
||||||
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner });
|
||||||
address,
|
|
||||||
{ from: owner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
const afterAdd = await authorizable.getAuthorizedAddresses.callAsync();
|
const afterAdd = await authorizable.getAuthorizedAddresses.callAsync();
|
||||||
expect(afterAdd).to.have.length(1);
|
expect(afterAdd).to.have.length(1);
|
||||||
expect(afterAdd).to.include(address);
|
expect(afterAdd).to.include(address);
|
||||||
await authorizable.removeAuthorizedAddress.awaitTransactionSuccessAsync(
|
await authorizable.removeAuthorizedAddress.awaitTransactionSuccessAsync(address, { from: owner });
|
||||||
address,
|
|
||||||
{ from: owner },
|
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
|
||||||
);
|
|
||||||
const afterRemove = await authorizable.getAuthorizedAddresses.callAsync();
|
const afterRemove = await authorizable.getAuthorizedAddresses.callAsync();
|
||||||
expect(afterRemove).to.have.length(0);
|
expect(afterRemove).to.have.length(0);
|
||||||
});
|
});
|
||||||
|
@ -83,6 +83,8 @@ export {
|
|||||||
SimpleEvmOutput,
|
SimpleEvmOutput,
|
||||||
SimpleEvmBytecodeOutput,
|
SimpleEvmBytecodeOutput,
|
||||||
EIP712DomainWithDefaultSchema,
|
EIP712DomainWithDefaultSchema,
|
||||||
|
AwaitTransactionSuccessOpts,
|
||||||
|
SendTransactionOpts,
|
||||||
EventCallback,
|
EventCallback,
|
||||||
IndexedFilterValues,
|
IndexedFilterValues,
|
||||||
DecodedLogEvent,
|
DecodedLogEvent,
|
||||||
|
@ -1,4 +1,25 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"version": "5.4.0-beta.1",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Remove debug functions `getABIDecodedTransactionData` and `getABIDecodedReturnData`",
|
||||||
|
"pr": 2243
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"note": "Remove `getABIEncodedTransactionData` for constant functions (pure and view)",
|
||||||
|
"pr": 2243
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"note": "Introduce TxOpts object for `sendTransactionAsync` and `awaitTransactionSuccessAsync`. Replaces `timeoutMs` and `pollingIntervalMs` arguments for `awaitTransactionSuccessAsync`",
|
||||||
|
"pr": 2243
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"note": "Remove `validateAndSendTransactionAsync`. Replaced with `shouldValidate` key in TxOpts. Defaults to true",
|
||||||
|
"pr": 2243
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"version": "5.4.0-beta.0",
|
"version": "5.4.0-beta.0",
|
||||||
"changes": [
|
"changes": [
|
||||||
|
@ -34,21 +34,20 @@
|
|||||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/abi-gen-wrappers/README.md",
|
"homepage": "https://github.com/0xProject/0x-monorepo/packages/abi-gen-wrappers/README.md",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@0x/abi-gen": "^4.3.0-beta.0",
|
"@0x/abi-gen": "^4.3.0-beta.0",
|
||||||
"@0x/assert": "^2.2.0-beta.0",
|
"@0x/contract-artifacts": "^2.3.0-beta.0",
|
||||||
"@0x/json-schemas": "^4.1.0-beta.0",
|
|
||||||
"@0x/tslint-config": "^3.0.1",
|
"@0x/tslint-config": "^3.0.1",
|
||||||
|
"shx": "^0.2.2"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@0x/assert": "^2.2.0-beta.0",
|
||||||
|
"@0x/base-contract": "^5.5.0-beta.0",
|
||||||
|
"@0x/contract-addresses": "^3.3.0-beta.0",
|
||||||
|
"@0x/json-schemas": "^4.1.0-beta.0",
|
||||||
"@0x/types": "^2.5.0-beta.0",
|
"@0x/types": "^2.5.0-beta.0",
|
||||||
"@0x/utils": "^4.6.0-beta.0",
|
"@0x/utils": "^4.6.0-beta.0",
|
||||||
"@0x/web3-wrapper": "^6.1.0-beta.0",
|
"@0x/web3-wrapper": "^6.1.0-beta.0",
|
||||||
"ethereum-types": "^2.2.0-beta.0",
|
"ethereum-types": "^2.2.0-beta.0",
|
||||||
"ethers": "~4.0.4",
|
"ethers": "~4.0.4"
|
||||||
"lodash": "^4.17.11",
|
|
||||||
"shx": "^0.2.2"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"@0x/base-contract": "^5.5.0-beta.0",
|
|
||||||
"@0x/contract-addresses": "^3.3.0-beta.0",
|
|
||||||
"@0x/contract-artifacts": "^2.3.0-beta.0"
|
|
||||||
},
|
},
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
|
File diff suppressed because one or more lines are too long
@ -18,7 +18,13 @@ import {
|
|||||||
SupportedProvider,
|
SupportedProvider,
|
||||||
} from 'ethereum-types';
|
} from 'ethereum-types';
|
||||||
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
||||||
import { SimpleContractArtifact, EventCallback, IndexedFilterValues } from '@0x/types';
|
import {
|
||||||
|
AwaitTransactionSuccessOpts,
|
||||||
|
EventCallback,
|
||||||
|
IndexedFilterValues,
|
||||||
|
SendTransactionOpts,
|
||||||
|
SimpleContractArtifact,
|
||||||
|
} from '@0x/types';
|
||||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||||
import { assert } from '@0x/assert';
|
import { assert } from '@0x/assert';
|
||||||
import * as ethers from 'ethers';
|
import * as ethers from 'ethers';
|
||||||
@ -28,6 +34,9 @@ import * as ethers from 'ethers';
|
|||||||
// tslint:disable:no-parameter-reassignment
|
// tslint:disable:no-parameter-reassignment
|
||||||
// tslint:disable-next-line:class-name
|
// tslint:disable-next-line:class-name
|
||||||
export class CoordinatorContract extends BaseContract {
|
export class CoordinatorContract extends BaseContract {
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
public static deployedBytecode: string | undefined;
|
public static deployedBytecode: string | undefined;
|
||||||
/**
|
/**
|
||||||
* Recovers the address of a signer given a hash and signature.
|
* Recovers the address of a signer given a hash and signature.
|
||||||
@ -62,7 +71,7 @@ export class CoordinatorContract extends BaseContract {
|
|||||||
|
|
||||||
let rawCallResult;
|
let rawCallResult;
|
||||||
try {
|
try {
|
||||||
rawCallResult = await self.evmExecAsync(encodedDataBytes);
|
rawCallResult = await self._evmExecAsync(encodedDataBytes);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
BaseContract._throwIfThrownErrorIsRevertError(err);
|
BaseContract._throwIfThrownErrorIsRevertError(err);
|
||||||
throw err;
|
throw err;
|
||||||
@ -75,48 +84,6 @@ export class CoordinatorContract extends BaseContract {
|
|||||||
// tslint:enable boolean-naming
|
// tslint:enable boolean-naming
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
|
||||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
|
||||||
* to create a 0x transaction (see protocol spec for more details).
|
|
||||||
* @param hash Any 32 byte hash.
|
|
||||||
* @param signature Proof that the hash has been signed by signer.
|
|
||||||
* @returns The ABI encoded transaction data as a string
|
|
||||||
*/
|
|
||||||
getABIEncodedTransactionData(hash: string, signature: string): string {
|
|
||||||
assert.isString('hash', hash);
|
|
||||||
assert.isString('signature', signature);
|
|
||||||
const self = (this as any) as CoordinatorContract;
|
|
||||||
const abiEncodedTransactionData = self._strictEncodeArguments('getSignerAddress(bytes32,bytes)', [
|
|
||||||
hash,
|
|
||||||
signature,
|
|
||||||
]);
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): string {
|
|
||||||
const self = (this as any) as CoordinatorContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('getSignerAddress(bytes32,bytes)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<string>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): string {
|
|
||||||
const self = (this as any) as CoordinatorContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('getSignerAddress(bytes32,bytes)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<string>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Calculates the EIP712 hash of a 0x transaction using the domain separator of the Exchange contract.
|
* Calculates the EIP712 hash of a 0x transaction using the domain separator of the Exchange contract.
|
||||||
@ -171,49 +138,6 @@ export class CoordinatorContract extends BaseContract {
|
|||||||
// tslint:enable boolean-naming
|
// tslint:enable boolean-naming
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
|
||||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
|
||||||
* to create a 0x transaction (see protocol spec for more details).
|
|
||||||
* @param transaction 0x transaction containing salt, signerAddress, and data.
|
|
||||||
* @returns The ABI encoded transaction data as a string
|
|
||||||
*/
|
|
||||||
getABIEncodedTransactionData(transaction: { salt: BigNumber; signerAddress: string; data: string }): string {
|
|
||||||
const self = (this as any) as CoordinatorContract;
|
|
||||||
const abiEncodedTransactionData = self._strictEncodeArguments(
|
|
||||||
'getTransactionHash((uint256,address,bytes))',
|
|
||||||
[transaction],
|
|
||||||
);
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): { salt: BigNumber; signerAddress: string; data: string } {
|
|
||||||
const self = (this as any) as CoordinatorContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('getTransactionHash((uint256,address,bytes))');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<{
|
|
||||||
salt: BigNumber;
|
|
||||||
signerAddress: string;
|
|
||||||
data: string;
|
|
||||||
}>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): string {
|
|
||||||
const self = (this as any) as CoordinatorContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('getTransactionHash((uint256,address,bytes))');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<string>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Calculated the EIP712 hash of the Coordinator approval mesasage using the domain separator of this contract.
|
* Calculated the EIP712 hash of the Coordinator approval mesasage using the domain separator of this contract.
|
||||||
@ -275,63 +199,6 @@ export class CoordinatorContract extends BaseContract {
|
|||||||
// tslint:enable boolean-naming
|
// tslint:enable boolean-naming
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
|
||||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
|
||||||
* to create a 0x transaction (see protocol spec for more details).
|
|
||||||
* @param approval Coordinator approval message containing the transaction
|
|
||||||
* hash, transaction signature, and expiration of the approval.
|
|
||||||
* @returns The ABI encoded transaction data as a string
|
|
||||||
*/
|
|
||||||
getABIEncodedTransactionData(approval: {
|
|
||||||
txOrigin: string;
|
|
||||||
transactionHash: string;
|
|
||||||
transactionSignature: string;
|
|
||||||
approvalExpirationTimeSeconds: BigNumber;
|
|
||||||
}): string {
|
|
||||||
const self = (this as any) as CoordinatorContract;
|
|
||||||
const abiEncodedTransactionData = self._strictEncodeArguments(
|
|
||||||
'getCoordinatorApprovalHash((address,bytes32,bytes,uint256))',
|
|
||||||
[approval],
|
|
||||||
);
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(
|
|
||||||
callData: string,
|
|
||||||
): {
|
|
||||||
txOrigin: string;
|
|
||||||
transactionHash: string;
|
|
||||||
transactionSignature: string;
|
|
||||||
approvalExpirationTimeSeconds: BigNumber;
|
|
||||||
} {
|
|
||||||
const self = (this as any) as CoordinatorContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('getCoordinatorApprovalHash((address,bytes32,bytes,uint256))');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<{
|
|
||||||
txOrigin: string;
|
|
||||||
transactionHash: string;
|
|
||||||
transactionSignature: string;
|
|
||||||
approvalExpirationTimeSeconds: BigNumber;
|
|
||||||
}>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): string {
|
|
||||||
const self = (this as any) as CoordinatorContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('getCoordinatorApprovalHash((address,bytes32,bytes,uint256))');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<string>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Executes a 0x transaction that has been signed by the feeRecipients that correspond to each order in the transaction's Exchange calldata.
|
* Executes a 0x transaction that has been signed by the feeRecipients that correspond to each order in the transaction's Exchange calldata.
|
||||||
@ -359,6 +226,7 @@ export class CoordinatorContract extends BaseContract {
|
|||||||
approvalExpirationTimeSeconds: BigNumber[],
|
approvalExpirationTimeSeconds: BigNumber[],
|
||||||
approvalSignatures: string[],
|
approvalSignatures: string[],
|
||||||
txData?: Partial<TxData> | undefined,
|
txData?: Partial<TxData> | undefined,
|
||||||
|
opts: SendTransactionOpts = { shouldValidate: true },
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
assert.isString('txOrigin', txOrigin);
|
assert.isString('txOrigin', txOrigin);
|
||||||
assert.isString('transactionSignature', transactionSignature);
|
assert.isString('transactionSignature', transactionSignature);
|
||||||
@ -387,6 +255,17 @@ export class CoordinatorContract extends BaseContract {
|
|||||||
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
|
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opts.shouldValidate !== false) {
|
||||||
|
await self.executeTransaction.callAsync(
|
||||||
|
transaction,
|
||||||
|
txOrigin,
|
||||||
|
transactionSignature,
|
||||||
|
approvalExpirationTimeSeconds,
|
||||||
|
approvalSignatures,
|
||||||
|
txDataWithDefaults,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
return txHash;
|
return txHash;
|
||||||
},
|
},
|
||||||
@ -413,8 +292,7 @@ export class CoordinatorContract extends BaseContract {
|
|||||||
approvalExpirationTimeSeconds: BigNumber[],
|
approvalExpirationTimeSeconds: BigNumber[],
|
||||||
approvalSignatures: string[],
|
approvalSignatures: string[],
|
||||||
txData?: Partial<TxData>,
|
txData?: Partial<TxData>,
|
||||||
pollingIntervalMs?: number,
|
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
|
||||||
timeoutMs?: number,
|
|
||||||
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
||||||
assert.isString('txOrigin', txOrigin);
|
assert.isString('txOrigin', txOrigin);
|
||||||
assert.isString('transactionSignature', transactionSignature);
|
assert.isString('transactionSignature', transactionSignature);
|
||||||
@ -428,6 +306,7 @@ export class CoordinatorContract extends BaseContract {
|
|||||||
approvalExpirationTimeSeconds,
|
approvalExpirationTimeSeconds,
|
||||||
approvalSignatures,
|
approvalSignatures,
|
||||||
txData,
|
txData,
|
||||||
|
opts,
|
||||||
);
|
);
|
||||||
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
||||||
txHashPromise,
|
txHashPromise,
|
||||||
@ -435,8 +314,8 @@ export class CoordinatorContract extends BaseContract {
|
|||||||
// When the transaction hash resolves, wait for it to be mined.
|
// When the transaction hash resolves, wait for it to be mined.
|
||||||
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
await txHashPromise,
|
await txHashPromise,
|
||||||
pollingIntervalMs,
|
opts.pollingIntervalMs,
|
||||||
timeoutMs,
|
opts.timeoutMs,
|
||||||
);
|
);
|
||||||
})(),
|
})(),
|
||||||
);
|
);
|
||||||
@ -493,32 +372,6 @@ export class CoordinatorContract extends BaseContract {
|
|||||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
return gas;
|
return gas;
|
||||||
},
|
},
|
||||||
async validateAndSendTransactionAsync(
|
|
||||||
transaction: { salt: BigNumber; signerAddress: string; data: string },
|
|
||||||
txOrigin: string,
|
|
||||||
transactionSignature: string,
|
|
||||||
approvalExpirationTimeSeconds: BigNumber[],
|
|
||||||
approvalSignatures: string[],
|
|
||||||
txData?: Partial<TxData> | undefined,
|
|
||||||
): Promise<string> {
|
|
||||||
await (this as any).executeTransaction.callAsync(
|
|
||||||
transaction,
|
|
||||||
txOrigin,
|
|
||||||
transactionSignature,
|
|
||||||
approvalExpirationTimeSeconds,
|
|
||||||
approvalSignatures,
|
|
||||||
txData,
|
|
||||||
);
|
|
||||||
const txHash = await (this as any).executeTransaction.sendTransactionAsync(
|
|
||||||
transaction,
|
|
||||||
txOrigin,
|
|
||||||
transactionSignature,
|
|
||||||
approvalExpirationTimeSeconds,
|
|
||||||
approvalSignatures,
|
|
||||||
txData,
|
|
||||||
);
|
|
||||||
return txHash;
|
|
||||||
},
|
|
||||||
/**
|
/**
|
||||||
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
|
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
|
||||||
* Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas
|
* Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas
|
||||||
@ -631,38 +484,6 @@ export class CoordinatorContract extends BaseContract {
|
|||||||
);
|
);
|
||||||
return abiEncodedTransactionData;
|
return abiEncodedTransactionData;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(
|
|
||||||
callData: string,
|
|
||||||
): [{ salt: BigNumber; signerAddress: string; data: string }, string, string, BigNumber[], string[]] {
|
|
||||||
const self = (this as any) as CoordinatorContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder(
|
|
||||||
'executeTransaction((uint256,address,bytes),address,bytes,uint256[],bytes[])',
|
|
||||||
);
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<
|
|
||||||
[{ salt: BigNumber; signerAddress: string; data: string }, string, string, BigNumber[], string[]]
|
|
||||||
>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): void {
|
|
||||||
const self = (this as any) as CoordinatorContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder(
|
|
||||||
'executeTransaction((uint256,address,bytes),address,bytes,uint256[],bytes[])',
|
|
||||||
);
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<void>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
public EIP712_EXCHANGE_DOMAIN_HASH = {
|
public EIP712_EXCHANGE_DOMAIN_HASH = {
|
||||||
/**
|
/**
|
||||||
@ -706,41 +527,6 @@ export class CoordinatorContract extends BaseContract {
|
|||||||
// tslint:enable boolean-naming
|
// tslint:enable boolean-naming
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
|
||||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
|
||||||
* to create a 0x transaction (see protocol spec for more details).
|
|
||||||
* @returns The ABI encoded transaction data as a string
|
|
||||||
*/
|
|
||||||
getABIEncodedTransactionData(): string {
|
|
||||||
const self = (this as any) as CoordinatorContract;
|
|
||||||
const abiEncodedTransactionData = self._strictEncodeArguments('EIP712_EXCHANGE_DOMAIN_HASH()', []);
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): void {
|
|
||||||
const self = (this as any) as CoordinatorContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('EIP712_EXCHANGE_DOMAIN_HASH()');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<void>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): string {
|
|
||||||
const self = (this as any) as CoordinatorContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('EIP712_EXCHANGE_DOMAIN_HASH()');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<string>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Validates that the 0x transaction has been approved by all of the feeRecipients
|
* Validates that the 0x transaction has been approved by all of the feeRecipients
|
||||||
@ -820,77 +606,6 @@ export class CoordinatorContract extends BaseContract {
|
|||||||
// tslint:enable boolean-naming
|
// tslint:enable boolean-naming
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
|
||||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
|
||||||
* to create a 0x transaction (see protocol spec for more details).
|
|
||||||
* @param transaction 0x transaction containing salt, signerAddress, and data.
|
|
||||||
* @param txOrigin Required signer of Ethereum transaction calling this
|
|
||||||
* function.
|
|
||||||
* @param transactionSignature Proof that the transaction has been signed by
|
|
||||||
* the signer.
|
|
||||||
* @param approvalExpirationTimeSeconds Array of expiration times in seconds
|
|
||||||
* for which each corresponding approval signature expires.
|
|
||||||
* @param approvalSignatures Array of signatures that correspond to the
|
|
||||||
* feeRecipients of each order in the transaction's Exchange calldata.
|
|
||||||
* @returns The ABI encoded transaction data as a string
|
|
||||||
*/
|
|
||||||
getABIEncodedTransactionData(
|
|
||||||
transaction: { salt: BigNumber; signerAddress: string; data: string },
|
|
||||||
txOrigin: string,
|
|
||||||
transactionSignature: string,
|
|
||||||
approvalExpirationTimeSeconds: BigNumber[],
|
|
||||||
approvalSignatures: string[],
|
|
||||||
): string {
|
|
||||||
assert.isString('txOrigin', txOrigin);
|
|
||||||
assert.isString('transactionSignature', transactionSignature);
|
|
||||||
assert.isArray('approvalExpirationTimeSeconds', approvalExpirationTimeSeconds);
|
|
||||||
assert.isArray('approvalSignatures', approvalSignatures);
|
|
||||||
const self = (this as any) as CoordinatorContract;
|
|
||||||
const abiEncodedTransactionData = self._strictEncodeArguments(
|
|
||||||
'assertValidCoordinatorApprovals((uint256,address,bytes),address,bytes,uint256[],bytes[])',
|
|
||||||
[
|
|
||||||
transaction,
|
|
||||||
txOrigin.toLowerCase(),
|
|
||||||
transactionSignature,
|
|
||||||
approvalExpirationTimeSeconds,
|
|
||||||
approvalSignatures,
|
|
||||||
],
|
|
||||||
);
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(
|
|
||||||
callData: string,
|
|
||||||
): [{ salt: BigNumber; signerAddress: string; data: string }, string, string, BigNumber[], string[]] {
|
|
||||||
const self = (this as any) as CoordinatorContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder(
|
|
||||||
'assertValidCoordinatorApprovals((uint256,address,bytes),address,bytes,uint256[],bytes[])',
|
|
||||||
);
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<
|
|
||||||
[{ salt: BigNumber; signerAddress: string; data: string }, string, string, BigNumber[], string[]]
|
|
||||||
>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): void {
|
|
||||||
const self = (this as any) as CoordinatorContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder(
|
|
||||||
'assertValidCoordinatorApprovals((uint256,address,bytes),address,bytes,uint256[],bytes[])',
|
|
||||||
);
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<void>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Decodes the orders from Exchange calldata representing any fill method.
|
* Decodes the orders from Exchange calldata representing any fill method.
|
||||||
@ -938,7 +653,7 @@ export class CoordinatorContract extends BaseContract {
|
|||||||
|
|
||||||
let rawCallResult;
|
let rawCallResult;
|
||||||
try {
|
try {
|
||||||
rawCallResult = await self.evmExecAsync(encodedDataBytes);
|
rawCallResult = await self._evmExecAsync(encodedDataBytes);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
BaseContract._throwIfThrownErrorIsRevertError(err);
|
BaseContract._throwIfThrownErrorIsRevertError(err);
|
||||||
throw err;
|
throw err;
|
||||||
@ -966,73 +681,6 @@ export class CoordinatorContract extends BaseContract {
|
|||||||
// tslint:enable boolean-naming
|
// tslint:enable boolean-naming
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
|
||||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
|
||||||
* to create a 0x transaction (see protocol spec for more details).
|
|
||||||
* @param data Exchange calldata representing a fill method.
|
|
||||||
* @returns The ABI encoded transaction data as a string
|
|
||||||
*/
|
|
||||||
getABIEncodedTransactionData(data: string): string {
|
|
||||||
assert.isString('data', data);
|
|
||||||
const self = (this as any) as CoordinatorContract;
|
|
||||||
const abiEncodedTransactionData = self._strictEncodeArguments('decodeOrdersFromFillData(bytes)', [data]);
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): string {
|
|
||||||
const self = (this as any) as CoordinatorContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('decodeOrdersFromFillData(bytes)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<string>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(
|
|
||||||
returnData: string,
|
|
||||||
): Array<{
|
|
||||||
makerAddress: string;
|
|
||||||
takerAddress: string;
|
|
||||||
feeRecipientAddress: string;
|
|
||||||
senderAddress: string;
|
|
||||||
makerAssetAmount: BigNumber;
|
|
||||||
takerAssetAmount: BigNumber;
|
|
||||||
makerFee: BigNumber;
|
|
||||||
takerFee: BigNumber;
|
|
||||||
expirationTimeSeconds: BigNumber;
|
|
||||||
salt: BigNumber;
|
|
||||||
makerAssetData: string;
|
|
||||||
takerAssetData: string;
|
|
||||||
}> {
|
|
||||||
const self = (this as any) as CoordinatorContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('decodeOrdersFromFillData(bytes)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<
|
|
||||||
Array<{
|
|
||||||
makerAddress: string;
|
|
||||||
takerAddress: string;
|
|
||||||
feeRecipientAddress: string;
|
|
||||||
senderAddress: string;
|
|
||||||
makerAssetAmount: BigNumber;
|
|
||||||
takerAssetAmount: BigNumber;
|
|
||||||
makerFee: BigNumber;
|
|
||||||
takerFee: BigNumber;
|
|
||||||
expirationTimeSeconds: BigNumber;
|
|
||||||
salt: BigNumber;
|
|
||||||
makerAssetData: string;
|
|
||||||
takerAssetData: string;
|
|
||||||
}>
|
|
||||||
>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
public EIP712_COORDINATOR_DOMAIN_HASH = {
|
public EIP712_COORDINATOR_DOMAIN_HASH = {
|
||||||
/**
|
/**
|
||||||
@ -1076,41 +724,6 @@ export class CoordinatorContract extends BaseContract {
|
|||||||
// tslint:enable boolean-naming
|
// tslint:enable boolean-naming
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
|
||||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
|
||||||
* to create a 0x transaction (see protocol spec for more details).
|
|
||||||
* @returns The ABI encoded transaction data as a string
|
|
||||||
*/
|
|
||||||
getABIEncodedTransactionData(): string {
|
|
||||||
const self = (this as any) as CoordinatorContract;
|
|
||||||
const abiEncodedTransactionData = self._strictEncodeArguments('EIP712_COORDINATOR_DOMAIN_HASH()', []);
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): void {
|
|
||||||
const self = (this as any) as CoordinatorContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('EIP712_COORDINATOR_DOMAIN_HASH()');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<void>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): string {
|
|
||||||
const self = (this as any) as CoordinatorContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('EIP712_COORDINATOR_DOMAIN_HASH()');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<string>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
public static async deployFrom0xArtifactAsync(
|
public static async deployFrom0xArtifactAsync(
|
||||||
artifact: ContractArtifact | SimpleContractArtifact,
|
artifact: ContractArtifact | SimpleContractArtifact,
|
||||||
|
@ -19,7 +19,13 @@ import {
|
|||||||
SupportedProvider,
|
SupportedProvider,
|
||||||
} from 'ethereum-types';
|
} from 'ethereum-types';
|
||||||
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
||||||
import { SimpleContractArtifact, EventCallback, IndexedFilterValues } from '@0x/types';
|
import {
|
||||||
|
AwaitTransactionSuccessOpts,
|
||||||
|
EventCallback,
|
||||||
|
IndexedFilterValues,
|
||||||
|
SendTransactionOpts,
|
||||||
|
SimpleContractArtifact,
|
||||||
|
} from '@0x/types';
|
||||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||||
import { assert } from '@0x/assert';
|
import { assert } from '@0x/assert';
|
||||||
import * as ethers from 'ethers';
|
import * as ethers from 'ethers';
|
||||||
@ -40,6 +46,9 @@ export interface CoordinatorRegistryCoordinatorEndpointSetEventArgs extends Deco
|
|||||||
// tslint:disable:no-parameter-reassignment
|
// tslint:disable:no-parameter-reassignment
|
||||||
// tslint:disable-next-line:class-name
|
// tslint:disable-next-line:class-name
|
||||||
export class CoordinatorRegistryContract extends BaseContract {
|
export class CoordinatorRegistryContract extends BaseContract {
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
public static deployedBytecode: string | undefined;
|
public static deployedBytecode: string | undefined;
|
||||||
/**
|
/**
|
||||||
* Called by a Coordinator operator to set the endpoint of their Coordinator.
|
* Called by a Coordinator operator to set the endpoint of their Coordinator.
|
||||||
@ -52,7 +61,11 @@ export class CoordinatorRegistryContract extends BaseContract {
|
|||||||
* @param txData Additional data for transaction
|
* @param txData Additional data for transaction
|
||||||
* @returns The hash of the transaction
|
* @returns The hash of the transaction
|
||||||
*/
|
*/
|
||||||
async sendTransactionAsync(coordinatorEndpoint: string, txData?: Partial<TxData> | undefined): Promise<string> {
|
async sendTransactionAsync(
|
||||||
|
coordinatorEndpoint: string,
|
||||||
|
txData?: Partial<TxData> | undefined,
|
||||||
|
opts: SendTransactionOpts = { shouldValidate: true },
|
||||||
|
): Promise<string> {
|
||||||
assert.isString('coordinatorEndpoint', coordinatorEndpoint);
|
assert.isString('coordinatorEndpoint', coordinatorEndpoint);
|
||||||
const self = (this as any) as CoordinatorRegistryContract;
|
const self = (this as any) as CoordinatorRegistryContract;
|
||||||
const encodedData = self._strictEncodeArguments('setCoordinatorEndpoint(string)', [coordinatorEndpoint]);
|
const encodedData = self._strictEncodeArguments('setCoordinatorEndpoint(string)', [coordinatorEndpoint]);
|
||||||
@ -68,6 +81,10 @@ export class CoordinatorRegistryContract extends BaseContract {
|
|||||||
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
|
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opts.shouldValidate !== false) {
|
||||||
|
await self.setCoordinatorEndpoint.callAsync(coordinatorEndpoint, txDataWithDefaults);
|
||||||
|
}
|
||||||
|
|
||||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
return txHash;
|
return txHash;
|
||||||
},
|
},
|
||||||
@ -82,20 +99,19 @@ export class CoordinatorRegistryContract extends BaseContract {
|
|||||||
awaitTransactionSuccessAsync(
|
awaitTransactionSuccessAsync(
|
||||||
coordinatorEndpoint: string,
|
coordinatorEndpoint: string,
|
||||||
txData?: Partial<TxData>,
|
txData?: Partial<TxData>,
|
||||||
pollingIntervalMs?: number,
|
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
|
||||||
timeoutMs?: number,
|
|
||||||
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
||||||
assert.isString('coordinatorEndpoint', coordinatorEndpoint);
|
assert.isString('coordinatorEndpoint', coordinatorEndpoint);
|
||||||
const self = (this as any) as CoordinatorRegistryContract;
|
const self = (this as any) as CoordinatorRegistryContract;
|
||||||
const txHashPromise = self.setCoordinatorEndpoint.sendTransactionAsync(coordinatorEndpoint, txData);
|
const txHashPromise = self.setCoordinatorEndpoint.sendTransactionAsync(coordinatorEndpoint, txData, opts);
|
||||||
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
||||||
txHashPromise,
|
txHashPromise,
|
||||||
(async (): Promise<TransactionReceiptWithDecodedLogs> => {
|
(async (): Promise<TransactionReceiptWithDecodedLogs> => {
|
||||||
// When the transaction hash resolves, wait for it to be mined.
|
// When the transaction hash resolves, wait for it to be mined.
|
||||||
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
await txHashPromise,
|
await txHashPromise,
|
||||||
pollingIntervalMs,
|
opts.pollingIntervalMs,
|
||||||
timeoutMs,
|
opts.timeoutMs,
|
||||||
);
|
);
|
||||||
})(),
|
})(),
|
||||||
);
|
);
|
||||||
@ -125,14 +141,6 @@ export class CoordinatorRegistryContract extends BaseContract {
|
|||||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
return gas;
|
return gas;
|
||||||
},
|
},
|
||||||
async validateAndSendTransactionAsync(
|
|
||||||
coordinatorEndpoint: string,
|
|
||||||
txData?: Partial<TxData> | undefined,
|
|
||||||
): Promise<string> {
|
|
||||||
await (this as any).setCoordinatorEndpoint.callAsync(coordinatorEndpoint, txData);
|
|
||||||
const txHash = await (this as any).setCoordinatorEndpoint.sendTransactionAsync(coordinatorEndpoint, txData);
|
|
||||||
return txHash;
|
|
||||||
},
|
|
||||||
/**
|
/**
|
||||||
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
|
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
|
||||||
* Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas
|
* Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas
|
||||||
@ -195,30 +203,6 @@ export class CoordinatorRegistryContract extends BaseContract {
|
|||||||
]);
|
]);
|
||||||
return abiEncodedTransactionData;
|
return abiEncodedTransactionData;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): [string] {
|
|
||||||
const self = (this as any) as CoordinatorRegistryContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('setCoordinatorEndpoint(string)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<[string]>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): void {
|
|
||||||
const self = (this as any) as CoordinatorRegistryContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('setCoordinatorEndpoint(string)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<void>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Gets the endpoint for a Coordinator.
|
* Gets the endpoint for a Coordinator.
|
||||||
@ -273,45 +257,6 @@ export class CoordinatorRegistryContract extends BaseContract {
|
|||||||
// tslint:enable boolean-naming
|
// tslint:enable boolean-naming
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
|
||||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
|
||||||
* to create a 0x transaction (see protocol spec for more details).
|
|
||||||
* @param coordinatorOperator operator of the Coordinator endpoint.
|
|
||||||
* @returns The ABI encoded transaction data as a string
|
|
||||||
*/
|
|
||||||
getABIEncodedTransactionData(coordinatorOperator: string): string {
|
|
||||||
assert.isString('coordinatorOperator', coordinatorOperator);
|
|
||||||
const self = (this as any) as CoordinatorRegistryContract;
|
|
||||||
const abiEncodedTransactionData = self._strictEncodeArguments('getCoordinatorEndpoint(address)', [
|
|
||||||
coordinatorOperator.toLowerCase(),
|
|
||||||
]);
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): string {
|
|
||||||
const self = (this as any) as CoordinatorRegistryContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('getCoordinatorEndpoint(address)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<string>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): string {
|
|
||||||
const self = (this as any) as CoordinatorRegistryContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('getCoordinatorEndpoint(address)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<string>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
private readonly _subscriptionManager: SubscriptionManager<CoordinatorRegistryEventArgs, CoordinatorRegistryEvents>;
|
private readonly _subscriptionManager: SubscriptionManager<CoordinatorRegistryEventArgs, CoordinatorRegistryEvents>;
|
||||||
public static async deployFrom0xArtifactAsync(
|
public static async deployFrom0xArtifactAsync(
|
||||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -18,7 +18,13 @@ import {
|
|||||||
SupportedProvider,
|
SupportedProvider,
|
||||||
} from 'ethereum-types';
|
} from 'ethereum-types';
|
||||||
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
||||||
import { SimpleContractArtifact, EventCallback, IndexedFilterValues } from '@0x/types';
|
import {
|
||||||
|
AwaitTransactionSuccessOpts,
|
||||||
|
EventCallback,
|
||||||
|
IndexedFilterValues,
|
||||||
|
SendTransactionOpts,
|
||||||
|
SimpleContractArtifact,
|
||||||
|
} from '@0x/types';
|
||||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||||
import { assert } from '@0x/assert';
|
import { assert } from '@0x/assert';
|
||||||
import * as ethers from 'ethers';
|
import * as ethers from 'ethers';
|
||||||
@ -28,6 +34,9 @@ import * as ethers from 'ethers';
|
|||||||
// tslint:disable:no-parameter-reassignment
|
// tslint:disable:no-parameter-reassignment
|
||||||
// tslint:disable-next-line:class-name
|
// tslint:disable-next-line:class-name
|
||||||
export class DutchAuctionContract extends BaseContract {
|
export class DutchAuctionContract extends BaseContract {
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
public static deployedBytecode: string | undefined;
|
public static deployedBytecode: string | undefined;
|
||||||
/**
|
/**
|
||||||
* Calculates the Auction Details for the given order
|
* Calculates the Auction Details for the given order
|
||||||
@ -56,6 +65,7 @@ export class DutchAuctionContract extends BaseContract {
|
|||||||
takerAssetData: string;
|
takerAssetData: string;
|
||||||
},
|
},
|
||||||
txData?: Partial<TxData> | undefined,
|
txData?: Partial<TxData> | undefined,
|
||||||
|
opts: SendTransactionOpts = { shouldValidate: true },
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const self = (this as any) as DutchAuctionContract;
|
const self = (this as any) as DutchAuctionContract;
|
||||||
const encodedData = self._strictEncodeArguments(
|
const encodedData = self._strictEncodeArguments(
|
||||||
@ -74,6 +84,10 @@ export class DutchAuctionContract extends BaseContract {
|
|||||||
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
|
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opts.shouldValidate !== false) {
|
||||||
|
await self.getAuctionDetails.callAsync(order, txDataWithDefaults);
|
||||||
|
}
|
||||||
|
|
||||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
return txHash;
|
return txHash;
|
||||||
},
|
},
|
||||||
@ -101,19 +115,18 @@ export class DutchAuctionContract extends BaseContract {
|
|||||||
takerAssetData: string;
|
takerAssetData: string;
|
||||||
},
|
},
|
||||||
txData?: Partial<TxData>,
|
txData?: Partial<TxData>,
|
||||||
pollingIntervalMs?: number,
|
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
|
||||||
timeoutMs?: number,
|
|
||||||
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
||||||
const self = (this as any) as DutchAuctionContract;
|
const self = (this as any) as DutchAuctionContract;
|
||||||
const txHashPromise = self.getAuctionDetails.sendTransactionAsync(order, txData);
|
const txHashPromise = self.getAuctionDetails.sendTransactionAsync(order, txData, opts);
|
||||||
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
||||||
txHashPromise,
|
txHashPromise,
|
||||||
(async (): Promise<TransactionReceiptWithDecodedLogs> => {
|
(async (): Promise<TransactionReceiptWithDecodedLogs> => {
|
||||||
// When the transaction hash resolves, wait for it to be mined.
|
// When the transaction hash resolves, wait for it to be mined.
|
||||||
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
await txHashPromise,
|
await txHashPromise,
|
||||||
pollingIntervalMs,
|
opts.pollingIntervalMs,
|
||||||
timeoutMs,
|
opts.timeoutMs,
|
||||||
);
|
);
|
||||||
})(),
|
})(),
|
||||||
);
|
);
|
||||||
@ -161,27 +174,6 @@ export class DutchAuctionContract extends BaseContract {
|
|||||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
return gas;
|
return gas;
|
||||||
},
|
},
|
||||||
async validateAndSendTransactionAsync(
|
|
||||||
order: {
|
|
||||||
makerAddress: string;
|
|
||||||
takerAddress: string;
|
|
||||||
feeRecipientAddress: string;
|
|
||||||
senderAddress: string;
|
|
||||||
makerAssetAmount: BigNumber;
|
|
||||||
takerAssetAmount: BigNumber;
|
|
||||||
makerFee: BigNumber;
|
|
||||||
takerFee: BigNumber;
|
|
||||||
expirationTimeSeconds: BigNumber;
|
|
||||||
salt: BigNumber;
|
|
||||||
makerAssetData: string;
|
|
||||||
takerAssetData: string;
|
|
||||||
},
|
|
||||||
txData?: Partial<TxData> | undefined,
|
|
||||||
): Promise<string> {
|
|
||||||
await (this as any).getAuctionDetails.callAsync(order, txData);
|
|
||||||
const txHash = await (this as any).getAuctionDetails.sendTransactionAsync(order, txData);
|
|
||||||
return txHash;
|
|
||||||
},
|
|
||||||
/**
|
/**
|
||||||
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
|
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
|
||||||
* Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas
|
* Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas
|
||||||
@ -289,78 +281,6 @@ export class DutchAuctionContract extends BaseContract {
|
|||||||
);
|
);
|
||||||
return abiEncodedTransactionData;
|
return abiEncodedTransactionData;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(
|
|
||||||
callData: string,
|
|
||||||
): {
|
|
||||||
makerAddress: string;
|
|
||||||
takerAddress: string;
|
|
||||||
feeRecipientAddress: string;
|
|
||||||
senderAddress: string;
|
|
||||||
makerAssetAmount: BigNumber;
|
|
||||||
takerAssetAmount: BigNumber;
|
|
||||||
makerFee: BigNumber;
|
|
||||||
takerFee: BigNumber;
|
|
||||||
expirationTimeSeconds: BigNumber;
|
|
||||||
salt: BigNumber;
|
|
||||||
makerAssetData: string;
|
|
||||||
takerAssetData: string;
|
|
||||||
} {
|
|
||||||
const self = (this as any) as DutchAuctionContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder(
|
|
||||||
'getAuctionDetails((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))',
|
|
||||||
);
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<{
|
|
||||||
makerAddress: string;
|
|
||||||
takerAddress: string;
|
|
||||||
feeRecipientAddress: string;
|
|
||||||
senderAddress: string;
|
|
||||||
makerAssetAmount: BigNumber;
|
|
||||||
takerAssetAmount: BigNumber;
|
|
||||||
makerFee: BigNumber;
|
|
||||||
takerFee: BigNumber;
|
|
||||||
expirationTimeSeconds: BigNumber;
|
|
||||||
salt: BigNumber;
|
|
||||||
makerAssetData: string;
|
|
||||||
takerAssetData: string;
|
|
||||||
}>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(
|
|
||||||
returnData: string,
|
|
||||||
): {
|
|
||||||
beginTimeSeconds: BigNumber;
|
|
||||||
endTimeSeconds: BigNumber;
|
|
||||||
beginAmount: BigNumber;
|
|
||||||
endAmount: BigNumber;
|
|
||||||
currentAmount: BigNumber;
|
|
||||||
currentTimeSeconds: BigNumber;
|
|
||||||
} {
|
|
||||||
const self = (this as any) as DutchAuctionContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder(
|
|
||||||
'getAuctionDetails((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))',
|
|
||||||
);
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<{
|
|
||||||
beginTimeSeconds: BigNumber;
|
|
||||||
endTimeSeconds: BigNumber;
|
|
||||||
beginAmount: BigNumber;
|
|
||||||
endAmount: BigNumber;
|
|
||||||
currentAmount: BigNumber;
|
|
||||||
currentTimeSeconds: BigNumber;
|
|
||||||
}>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Matches the buy and sell orders at an amount given the following: the current block time, the auction
|
* Matches the buy and sell orders at an amount given the following: the current block time, the auction
|
||||||
@ -424,6 +344,7 @@ export class DutchAuctionContract extends BaseContract {
|
|||||||
buySignature: string,
|
buySignature: string,
|
||||||
sellSignature: string,
|
sellSignature: string,
|
||||||
txData?: Partial<TxData> | undefined,
|
txData?: Partial<TxData> | undefined,
|
||||||
|
opts: SendTransactionOpts = { shouldValidate: true },
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
assert.isString('buySignature', buySignature);
|
assert.isString('buySignature', buySignature);
|
||||||
assert.isString('sellSignature', sellSignature);
|
assert.isString('sellSignature', sellSignature);
|
||||||
@ -444,6 +365,10 @@ export class DutchAuctionContract extends BaseContract {
|
|||||||
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
|
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opts.shouldValidate !== false) {
|
||||||
|
await self.matchOrders.callAsync(buyOrder, sellOrder, buySignature, sellSignature, txDataWithDefaults);
|
||||||
|
}
|
||||||
|
|
||||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
return txHash;
|
return txHash;
|
||||||
},
|
},
|
||||||
@ -492,8 +417,7 @@ export class DutchAuctionContract extends BaseContract {
|
|||||||
buySignature: string,
|
buySignature: string,
|
||||||
sellSignature: string,
|
sellSignature: string,
|
||||||
txData?: Partial<TxData>,
|
txData?: Partial<TxData>,
|
||||||
pollingIntervalMs?: number,
|
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
|
||||||
timeoutMs?: number,
|
|
||||||
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
||||||
assert.isString('buySignature', buySignature);
|
assert.isString('buySignature', buySignature);
|
||||||
assert.isString('sellSignature', sellSignature);
|
assert.isString('sellSignature', sellSignature);
|
||||||
@ -504,6 +428,7 @@ export class DutchAuctionContract extends BaseContract {
|
|||||||
buySignature,
|
buySignature,
|
||||||
sellSignature,
|
sellSignature,
|
||||||
txData,
|
txData,
|
||||||
|
opts,
|
||||||
);
|
);
|
||||||
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
||||||
txHashPromise,
|
txHashPromise,
|
||||||
@ -511,8 +436,8 @@ export class DutchAuctionContract extends BaseContract {
|
|||||||
// When the transaction hash resolves, wait for it to be mined.
|
// When the transaction hash resolves, wait for it to be mined.
|
||||||
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
await txHashPromise,
|
await txHashPromise,
|
||||||
pollingIntervalMs,
|
opts.pollingIntervalMs,
|
||||||
timeoutMs,
|
opts.timeoutMs,
|
||||||
);
|
);
|
||||||
})(),
|
})(),
|
||||||
);
|
);
|
||||||
@ -583,49 +508,6 @@ export class DutchAuctionContract extends BaseContract {
|
|||||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
return gas;
|
return gas;
|
||||||
},
|
},
|
||||||
async validateAndSendTransactionAsync(
|
|
||||||
buyOrder: {
|
|
||||||
makerAddress: string;
|
|
||||||
takerAddress: string;
|
|
||||||
feeRecipientAddress: string;
|
|
||||||
senderAddress: string;
|
|
||||||
makerAssetAmount: BigNumber;
|
|
||||||
takerAssetAmount: BigNumber;
|
|
||||||
makerFee: BigNumber;
|
|
||||||
takerFee: BigNumber;
|
|
||||||
expirationTimeSeconds: BigNumber;
|
|
||||||
salt: BigNumber;
|
|
||||||
makerAssetData: string;
|
|
||||||
takerAssetData: string;
|
|
||||||
},
|
|
||||||
sellOrder: {
|
|
||||||
makerAddress: string;
|
|
||||||
takerAddress: string;
|
|
||||||
feeRecipientAddress: string;
|
|
||||||
senderAddress: string;
|
|
||||||
makerAssetAmount: BigNumber;
|
|
||||||
takerAssetAmount: BigNumber;
|
|
||||||
makerFee: BigNumber;
|
|
||||||
takerFee: BigNumber;
|
|
||||||
expirationTimeSeconds: BigNumber;
|
|
||||||
salt: BigNumber;
|
|
||||||
makerAssetData: string;
|
|
||||||
takerAssetData: string;
|
|
||||||
},
|
|
||||||
buySignature: string,
|
|
||||||
sellSignature: string,
|
|
||||||
txData?: Partial<TxData> | undefined,
|
|
||||||
): Promise<string> {
|
|
||||||
await (this as any).matchOrders.callAsync(buyOrder, sellOrder, buySignature, sellSignature, txData);
|
|
||||||
const txHash = await (this as any).matchOrders.sendTransactionAsync(
|
|
||||||
buyOrder,
|
|
||||||
sellOrder,
|
|
||||||
buySignature,
|
|
||||||
sellSignature,
|
|
||||||
txData,
|
|
||||||
);
|
|
||||||
return txHash;
|
|
||||||
},
|
|
||||||
/**
|
/**
|
||||||
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
|
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
|
||||||
* Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas
|
* Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas
|
||||||
@ -795,92 +677,6 @@ export class DutchAuctionContract extends BaseContract {
|
|||||||
);
|
);
|
||||||
return abiEncodedTransactionData;
|
return abiEncodedTransactionData;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(
|
|
||||||
callData: string,
|
|
||||||
): {
|
|
||||||
makerAddress: string;
|
|
||||||
takerAddress: string;
|
|
||||||
feeRecipientAddress: string;
|
|
||||||
senderAddress: string;
|
|
||||||
makerAssetAmount: BigNumber;
|
|
||||||
takerAssetAmount: BigNumber;
|
|
||||||
makerFee: BigNumber;
|
|
||||||
takerFee: BigNumber;
|
|
||||||
expirationTimeSeconds: BigNumber;
|
|
||||||
salt: BigNumber;
|
|
||||||
makerAssetData: string;
|
|
||||||
takerAssetData: string;
|
|
||||||
} {
|
|
||||||
const self = (this as any) as DutchAuctionContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder(
|
|
||||||
'matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)',
|
|
||||||
);
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<{
|
|
||||||
makerAddress: string;
|
|
||||||
takerAddress: string;
|
|
||||||
feeRecipientAddress: string;
|
|
||||||
senderAddress: string;
|
|
||||||
makerAssetAmount: BigNumber;
|
|
||||||
takerAssetAmount: BigNumber;
|
|
||||||
makerFee: BigNumber;
|
|
||||||
takerFee: BigNumber;
|
|
||||||
expirationTimeSeconds: BigNumber;
|
|
||||||
salt: BigNumber;
|
|
||||||
makerAssetData: string;
|
|
||||||
takerAssetData: string;
|
|
||||||
}>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(
|
|
||||||
returnData: string,
|
|
||||||
): {
|
|
||||||
left: {
|
|
||||||
makerAssetFilledAmount: BigNumber;
|
|
||||||
takerAssetFilledAmount: BigNumber;
|
|
||||||
makerFeePaid: BigNumber;
|
|
||||||
takerFeePaid: BigNumber;
|
|
||||||
};
|
|
||||||
right: {
|
|
||||||
makerAssetFilledAmount: BigNumber;
|
|
||||||
takerAssetFilledAmount: BigNumber;
|
|
||||||
makerFeePaid: BigNumber;
|
|
||||||
takerFeePaid: BigNumber;
|
|
||||||
};
|
|
||||||
leftMakerAssetSpreadAmount: BigNumber;
|
|
||||||
} {
|
|
||||||
const self = (this as any) as DutchAuctionContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder(
|
|
||||||
'matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)',
|
|
||||||
);
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<{
|
|
||||||
left: {
|
|
||||||
makerAssetFilledAmount: BigNumber;
|
|
||||||
takerAssetFilledAmount: BigNumber;
|
|
||||||
makerFeePaid: BigNumber;
|
|
||||||
takerFeePaid: BigNumber;
|
|
||||||
};
|
|
||||||
right: {
|
|
||||||
makerAssetFilledAmount: BigNumber;
|
|
||||||
takerAssetFilledAmount: BigNumber;
|
|
||||||
makerFeePaid: BigNumber;
|
|
||||||
takerFeePaid: BigNumber;
|
|
||||||
};
|
|
||||||
leftMakerAssetSpreadAmount: BigNumber;
|
|
||||||
}>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
public static async deployFrom0xArtifactAsync(
|
public static async deployFrom0xArtifactAsync(
|
||||||
artifact: ContractArtifact | SimpleContractArtifact,
|
artifact: ContractArtifact | SimpleContractArtifact,
|
||||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -19,7 +19,13 @@ import {
|
|||||||
SupportedProvider,
|
SupportedProvider,
|
||||||
} from 'ethereum-types';
|
} from 'ethereum-types';
|
||||||
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
||||||
import { SimpleContractArtifact, EventCallback, IndexedFilterValues } from '@0x/types';
|
import {
|
||||||
|
AwaitTransactionSuccessOpts,
|
||||||
|
EventCallback,
|
||||||
|
IndexedFilterValues,
|
||||||
|
SendTransactionOpts,
|
||||||
|
SimpleContractArtifact,
|
||||||
|
} from '@0x/types';
|
||||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||||
import { assert } from '@0x/assert';
|
import { assert } from '@0x/assert';
|
||||||
import * as ethers from 'ethers';
|
import * as ethers from 'ethers';
|
||||||
@ -48,8 +54,10 @@ export interface ERC20TokenApprovalEventArgs extends DecodedLogArgs {
|
|||||||
// tslint:disable:no-parameter-reassignment
|
// tslint:disable:no-parameter-reassignment
|
||||||
// tslint:disable-next-line:class-name
|
// tslint:disable-next-line:class-name
|
||||||
export class ERC20TokenContract extends BaseContract {
|
export class ERC20TokenContract extends BaseContract {
|
||||||
public static deployedBytecode =
|
/**
|
||||||
'0x608060405234801561001057600080fd5b50600436106100725760003560e01c806370a082311161005057806370a0823114610121578063a9059cbb14610154578063dd62ed3e1461018d57610072565b8063095ea7b31461007757806318160ddd146100c457806323b872dd146100de575b600080fd5b6100b06004803603604081101561008d57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001356101c8565b604080519115158252519081900360200190f35b6100cc61023b565b60408051918252519081900360200190f35b6100b0600480360360608110156100f457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060400135610241565b6100cc6004803603602081101561013757600080fd5b503573ffffffffffffffffffffffffffffffffffffffff1661049d565b6100b06004803603604081101561016a57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001356104c5565b6100cc600480360360408110156101a357600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516610652565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60025490565b73ffffffffffffffffffffffffffffffffffffffff83166000908152602081905260408120548211156102d557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f45524332305f494e53554646494349454e545f42414c414e4345000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8416600090815260016020908152604080832033845290915290205482111561037457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f45524332305f494e53554646494349454e545f414c4c4f57414e434500000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8316600090815260208190526040902054828101101561040a57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f55494e543235365f4f564552464c4f5700000000000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff80841660008181526020818152604080832080548801905593881680835284832080548890039055600182528483203384528252918490208054879003905583518681529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35060019392505050565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205490565b3360009081526020819052604081205482111561054357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f45524332305f494e53554646494349454e545f42414c414e4345000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604090205482810110156105d957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f55494e543235365f4f564552464c4f5700000000000000000000000000000000604482015290519081900360640190fd5b336000818152602081815260408083208054879003905573ffffffffffffffffffffffffffffffffffffffff871680845292819020805487019055805186815290519293927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a350600192915050565b73ffffffffffffffffffffffffffffffffffffffff91821660009081526001602090815260408083209390941682529190915220549056fea265627a7a723158205713efa92f66e67a8d01b80af8500df66bd6e9862dcf791e587181109d8ab0c464736f6c634300050b0032';
|
* @ignore
|
||||||
|
*/
|
||||||
|
public static deployedBytecode: string | undefined;
|
||||||
/**
|
/**
|
||||||
* `msg.sender` approves `_spender` to spend `_value` tokens
|
* `msg.sender` approves `_spender` to spend `_value` tokens
|
||||||
*/
|
*/
|
||||||
@ -66,6 +74,7 @@ export class ERC20TokenContract extends BaseContract {
|
|||||||
_spender: string,
|
_spender: string,
|
||||||
_value: BigNumber,
|
_value: BigNumber,
|
||||||
txData?: Partial<TxData> | undefined,
|
txData?: Partial<TxData> | undefined,
|
||||||
|
opts: SendTransactionOpts = { shouldValidate: true },
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
assert.isString('_spender', _spender);
|
assert.isString('_spender', _spender);
|
||||||
assert.isBigNumber('_value', _value);
|
assert.isBigNumber('_value', _value);
|
||||||
@ -86,6 +95,10 @@ export class ERC20TokenContract extends BaseContract {
|
|||||||
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
|
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opts.shouldValidate !== false) {
|
||||||
|
await self.approve.callAsync(_spender, _value, txDataWithDefaults);
|
||||||
|
}
|
||||||
|
|
||||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
return txHash;
|
return txHash;
|
||||||
},
|
},
|
||||||
@ -102,21 +115,20 @@ export class ERC20TokenContract extends BaseContract {
|
|||||||
_spender: string,
|
_spender: string,
|
||||||
_value: BigNumber,
|
_value: BigNumber,
|
||||||
txData?: Partial<TxData>,
|
txData?: Partial<TxData>,
|
||||||
pollingIntervalMs?: number,
|
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
|
||||||
timeoutMs?: number,
|
|
||||||
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
||||||
assert.isString('_spender', _spender);
|
assert.isString('_spender', _spender);
|
||||||
assert.isBigNumber('_value', _value);
|
assert.isBigNumber('_value', _value);
|
||||||
const self = (this as any) as ERC20TokenContract;
|
const self = (this as any) as ERC20TokenContract;
|
||||||
const txHashPromise = self.approve.sendTransactionAsync(_spender.toLowerCase(), _value, txData);
|
const txHashPromise = self.approve.sendTransactionAsync(_spender.toLowerCase(), _value, txData, opts);
|
||||||
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
||||||
txHashPromise,
|
txHashPromise,
|
||||||
(async (): Promise<TransactionReceiptWithDecodedLogs> => {
|
(async (): Promise<TransactionReceiptWithDecodedLogs> => {
|
||||||
// When the transaction hash resolves, wait for it to be mined.
|
// When the transaction hash resolves, wait for it to be mined.
|
||||||
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
await txHashPromise,
|
await txHashPromise,
|
||||||
pollingIntervalMs,
|
opts.pollingIntervalMs,
|
||||||
timeoutMs,
|
opts.timeoutMs,
|
||||||
);
|
);
|
||||||
})(),
|
})(),
|
||||||
);
|
);
|
||||||
@ -155,15 +167,6 @@ export class ERC20TokenContract extends BaseContract {
|
|||||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
return gas;
|
return gas;
|
||||||
},
|
},
|
||||||
async validateAndSendTransactionAsync(
|
|
||||||
_spender: string,
|
|
||||||
_value: BigNumber,
|
|
||||||
txData?: Partial<TxData> | undefined,
|
|
||||||
): Promise<string> {
|
|
||||||
await (this as any).approve.callAsync(_spender, _value, txData);
|
|
||||||
const txHash = await (this as any).approve.sendTransactionAsync(_spender, _value, txData);
|
|
||||||
return txHash;
|
|
||||||
},
|
|
||||||
/**
|
/**
|
||||||
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
|
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
|
||||||
* Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas
|
* Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas
|
||||||
@ -236,30 +239,6 @@ export class ERC20TokenContract extends BaseContract {
|
|||||||
]);
|
]);
|
||||||
return abiEncodedTransactionData;
|
return abiEncodedTransactionData;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): string {
|
|
||||||
const self = (this as any) as ERC20TokenContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('approve(address,uint256)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<string>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): boolean {
|
|
||||||
const self = (this as any) as ERC20TokenContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('approve(address,uint256)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<boolean>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Query total supply of token
|
* Query total supply of token
|
||||||
@ -307,41 +286,6 @@ export class ERC20TokenContract extends BaseContract {
|
|||||||
// tslint:enable boolean-naming
|
// tslint:enable boolean-naming
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
|
||||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
|
||||||
* to create a 0x transaction (see protocol spec for more details).
|
|
||||||
* @returns The ABI encoded transaction data as a string
|
|
||||||
*/
|
|
||||||
getABIEncodedTransactionData(): string {
|
|
||||||
const self = (this as any) as ERC20TokenContract;
|
|
||||||
const abiEncodedTransactionData = self._strictEncodeArguments('totalSupply()', []);
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): void {
|
|
||||||
const self = (this as any) as ERC20TokenContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('totalSupply()');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<void>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): BigNumber {
|
|
||||||
const self = (this as any) as ERC20TokenContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('totalSupply()');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<BigNumber>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* send `value` token to `to` from `from` on the condition it is approved by `from`
|
* send `value` token to `to` from `from` on the condition it is approved by `from`
|
||||||
@ -361,6 +305,7 @@ export class ERC20TokenContract extends BaseContract {
|
|||||||
_to: string,
|
_to: string,
|
||||||
_value: BigNumber,
|
_value: BigNumber,
|
||||||
txData?: Partial<TxData> | undefined,
|
txData?: Partial<TxData> | undefined,
|
||||||
|
opts: SendTransactionOpts = { shouldValidate: true },
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
assert.isString('_from', _from);
|
assert.isString('_from', _from);
|
||||||
assert.isString('_to', _to);
|
assert.isString('_to', _to);
|
||||||
@ -383,6 +328,10 @@ export class ERC20TokenContract extends BaseContract {
|
|||||||
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
|
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opts.shouldValidate !== false) {
|
||||||
|
await self.transferFrom.callAsync(_from, _to, _value, txDataWithDefaults);
|
||||||
|
}
|
||||||
|
|
||||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
return txHash;
|
return txHash;
|
||||||
},
|
},
|
||||||
@ -401,8 +350,7 @@ export class ERC20TokenContract extends BaseContract {
|
|||||||
_to: string,
|
_to: string,
|
||||||
_value: BigNumber,
|
_value: BigNumber,
|
||||||
txData?: Partial<TxData>,
|
txData?: Partial<TxData>,
|
||||||
pollingIntervalMs?: number,
|
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
|
||||||
timeoutMs?: number,
|
|
||||||
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
||||||
assert.isString('_from', _from);
|
assert.isString('_from', _from);
|
||||||
assert.isString('_to', _to);
|
assert.isString('_to', _to);
|
||||||
@ -413,6 +361,7 @@ export class ERC20TokenContract extends BaseContract {
|
|||||||
_to.toLowerCase(),
|
_to.toLowerCase(),
|
||||||
_value,
|
_value,
|
||||||
txData,
|
txData,
|
||||||
|
opts,
|
||||||
);
|
);
|
||||||
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
||||||
txHashPromise,
|
txHashPromise,
|
||||||
@ -420,8 +369,8 @@ export class ERC20TokenContract extends BaseContract {
|
|||||||
// When the transaction hash resolves, wait for it to be mined.
|
// When the transaction hash resolves, wait for it to be mined.
|
||||||
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
await txHashPromise,
|
await txHashPromise,
|
||||||
pollingIntervalMs,
|
opts.pollingIntervalMs,
|
||||||
timeoutMs,
|
opts.timeoutMs,
|
||||||
);
|
);
|
||||||
})(),
|
})(),
|
||||||
);
|
);
|
||||||
@ -464,16 +413,6 @@ export class ERC20TokenContract extends BaseContract {
|
|||||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
return gas;
|
return gas;
|
||||||
},
|
},
|
||||||
async validateAndSendTransactionAsync(
|
|
||||||
_from: string,
|
|
||||||
_to: string,
|
|
||||||
_value: BigNumber,
|
|
||||||
txData?: Partial<TxData> | undefined,
|
|
||||||
): Promise<string> {
|
|
||||||
await (this as any).transferFrom.callAsync(_from, _to, _value, txData);
|
|
||||||
const txHash = await (this as any).transferFrom.sendTransactionAsync(_from, _to, _value, txData);
|
|
||||||
return txHash;
|
|
||||||
},
|
|
||||||
/**
|
/**
|
||||||
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
|
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
|
||||||
* Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas
|
* Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas
|
||||||
@ -553,30 +492,6 @@ export class ERC20TokenContract extends BaseContract {
|
|||||||
]);
|
]);
|
||||||
return abiEncodedTransactionData;
|
return abiEncodedTransactionData;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): string {
|
|
||||||
const self = (this as any) as ERC20TokenContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('transferFrom(address,address,uint256)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<string>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): boolean {
|
|
||||||
const self = (this as any) as ERC20TokenContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('transferFrom(address,address,uint256)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<boolean>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Query the balance of owner
|
* Query the balance of owner
|
||||||
@ -630,43 +545,6 @@ export class ERC20TokenContract extends BaseContract {
|
|||||||
// tslint:enable boolean-naming
|
// tslint:enable boolean-naming
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
|
||||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
|
||||||
* to create a 0x transaction (see protocol spec for more details).
|
|
||||||
* @param _owner The address from which the balance will be retrieved
|
|
||||||
* @returns The ABI encoded transaction data as a string
|
|
||||||
*/
|
|
||||||
getABIEncodedTransactionData(_owner: string): string {
|
|
||||||
assert.isString('_owner', _owner);
|
|
||||||
const self = (this as any) as ERC20TokenContract;
|
|
||||||
const abiEncodedTransactionData = self._strictEncodeArguments('balanceOf(address)', [_owner.toLowerCase()]);
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): string {
|
|
||||||
const self = (this as any) as ERC20TokenContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('balanceOf(address)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<string>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): BigNumber {
|
|
||||||
const self = (this as any) as ERC20TokenContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('balanceOf(address)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<BigNumber>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* send `value` token to `to` from `msg.sender`
|
* send `value` token to `to` from `msg.sender`
|
||||||
@ -684,6 +562,7 @@ export class ERC20TokenContract extends BaseContract {
|
|||||||
_to: string,
|
_to: string,
|
||||||
_value: BigNumber,
|
_value: BigNumber,
|
||||||
txData?: Partial<TxData> | undefined,
|
txData?: Partial<TxData> | undefined,
|
||||||
|
opts: SendTransactionOpts = { shouldValidate: true },
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
assert.isString('_to', _to);
|
assert.isString('_to', _to);
|
||||||
assert.isBigNumber('_value', _value);
|
assert.isBigNumber('_value', _value);
|
||||||
@ -701,6 +580,10 @@ export class ERC20TokenContract extends BaseContract {
|
|||||||
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
|
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opts.shouldValidate !== false) {
|
||||||
|
await self.transfer.callAsync(_to, _value, txDataWithDefaults);
|
||||||
|
}
|
||||||
|
|
||||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
return txHash;
|
return txHash;
|
||||||
},
|
},
|
||||||
@ -717,21 +600,20 @@ export class ERC20TokenContract extends BaseContract {
|
|||||||
_to: string,
|
_to: string,
|
||||||
_value: BigNumber,
|
_value: BigNumber,
|
||||||
txData?: Partial<TxData>,
|
txData?: Partial<TxData>,
|
||||||
pollingIntervalMs?: number,
|
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
|
||||||
timeoutMs?: number,
|
|
||||||
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
||||||
assert.isString('_to', _to);
|
assert.isString('_to', _to);
|
||||||
assert.isBigNumber('_value', _value);
|
assert.isBigNumber('_value', _value);
|
||||||
const self = (this as any) as ERC20TokenContract;
|
const self = (this as any) as ERC20TokenContract;
|
||||||
const txHashPromise = self.transfer.sendTransactionAsync(_to.toLowerCase(), _value, txData);
|
const txHashPromise = self.transfer.sendTransactionAsync(_to.toLowerCase(), _value, txData, opts);
|
||||||
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
||||||
txHashPromise,
|
txHashPromise,
|
||||||
(async (): Promise<TransactionReceiptWithDecodedLogs> => {
|
(async (): Promise<TransactionReceiptWithDecodedLogs> => {
|
||||||
// When the transaction hash resolves, wait for it to be mined.
|
// When the transaction hash resolves, wait for it to be mined.
|
||||||
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
await txHashPromise,
|
await txHashPromise,
|
||||||
pollingIntervalMs,
|
opts.pollingIntervalMs,
|
||||||
timeoutMs,
|
opts.timeoutMs,
|
||||||
);
|
);
|
||||||
})(),
|
})(),
|
||||||
);
|
);
|
||||||
@ -763,15 +645,6 @@ export class ERC20TokenContract extends BaseContract {
|
|||||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
return gas;
|
return gas;
|
||||||
},
|
},
|
||||||
async validateAndSendTransactionAsync(
|
|
||||||
_to: string,
|
|
||||||
_value: BigNumber,
|
|
||||||
txData?: Partial<TxData> | undefined,
|
|
||||||
): Promise<string> {
|
|
||||||
await (this as any).transfer.callAsync(_to, _value, txData);
|
|
||||||
const txHash = await (this as any).transfer.sendTransactionAsync(_to, _value, txData);
|
|
||||||
return txHash;
|
|
||||||
},
|
|
||||||
/**
|
/**
|
||||||
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
|
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
|
||||||
* Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas
|
* Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas
|
||||||
@ -841,30 +714,6 @@ export class ERC20TokenContract extends BaseContract {
|
|||||||
]);
|
]);
|
||||||
return abiEncodedTransactionData;
|
return abiEncodedTransactionData;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): string {
|
|
||||||
const self = (this as any) as ERC20TokenContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('transfer(address,uint256)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<string>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): boolean {
|
|
||||||
const self = (this as any) as ERC20TokenContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('transfer(address,uint256)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<boolean>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
public allowance = {
|
public allowance = {
|
||||||
/**
|
/**
|
||||||
@ -921,48 +770,6 @@ export class ERC20TokenContract extends BaseContract {
|
|||||||
// tslint:enable boolean-naming
|
// tslint:enable boolean-naming
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
|
||||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
|
||||||
* to create a 0x transaction (see protocol spec for more details).
|
|
||||||
* @param _owner The address of the account owning tokens
|
|
||||||
* @param _spender The address of the account able to transfer the tokens
|
|
||||||
* @returns The ABI encoded transaction data as a string
|
|
||||||
*/
|
|
||||||
getABIEncodedTransactionData(_owner: string, _spender: string): string {
|
|
||||||
assert.isString('_owner', _owner);
|
|
||||||
assert.isString('_spender', _spender);
|
|
||||||
const self = (this as any) as ERC20TokenContract;
|
|
||||||
const abiEncodedTransactionData = self._strictEncodeArguments('allowance(address,address)', [
|
|
||||||
_owner.toLowerCase(),
|
|
||||||
_spender.toLowerCase(),
|
|
||||||
]);
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): string {
|
|
||||||
const self = (this as any) as ERC20TokenContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('allowance(address,address)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<string>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): BigNumber {
|
|
||||||
const self = (this as any) as ERC20TokenContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('allowance(address,address)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<BigNumber>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
private readonly _subscriptionManager: SubscriptionManager<ERC20TokenEventArgs, ERC20TokenEvents>;
|
private readonly _subscriptionManager: SubscriptionManager<ERC20TokenEventArgs, ERC20TokenEvents>;
|
||||||
public static async deployFrom0xArtifactAsync(
|
public static async deployFrom0xArtifactAsync(
|
||||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -18,7 +18,13 @@ import {
|
|||||||
SupportedProvider,
|
SupportedProvider,
|
||||||
} from 'ethereum-types';
|
} from 'ethereum-types';
|
||||||
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
||||||
import { SimpleContractArtifact, EventCallback, IndexedFilterValues } from '@0x/types';
|
import {
|
||||||
|
AwaitTransactionSuccessOpts,
|
||||||
|
EventCallback,
|
||||||
|
IndexedFilterValues,
|
||||||
|
SendTransactionOpts,
|
||||||
|
SimpleContractArtifact,
|
||||||
|
} from '@0x/types';
|
||||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||||
import { assert } from '@0x/assert';
|
import { assert } from '@0x/assert';
|
||||||
import * as ethers from 'ethers';
|
import * as ethers from 'ethers';
|
||||||
@ -28,8 +34,10 @@ import * as ethers from 'ethers';
|
|||||||
// tslint:disable:no-parameter-reassignment
|
// tslint:disable:no-parameter-reassignment
|
||||||
// tslint:disable-next-line:class-name
|
// tslint:disable-next-line:class-name
|
||||||
export class EthBalanceCheckerContract extends BaseContract {
|
export class EthBalanceCheckerContract extends BaseContract {
|
||||||
public static deployedBytecode =
|
/**
|
||||||
'0x608060405234801561001057600080fd5b506004361061002b5760003560e01c8063a0901e5114610030575b600080fd5b6100d36004803603602081101561004657600080fd5b81019060208101813564010000000081111561006157600080fd5b82018360208201111561007357600080fd5b8035906020019184602083028401116401000000008311171561009557600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550610123945050505050565b60408051602080825283518183015283519192839290830191858101910280838360005b8381101561010f5781810151838201526020016100f7565b505050509050019250505060405180910390f35b6060808251604051908082528060200260200182016040528015610151578160200160208202803883390190505b50905060005b835181146101a95783818151811061016b57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff163182828151811061019657fe5b6020908102919091010152600101610157565b509291505056fea265627a7a7231582094309783f0b63086d85d9cb4f6e5be253699056ac1580a863367c5076ecb5c1864736f6c634300050b0032';
|
* @ignore
|
||||||
|
*/
|
||||||
|
public static deployedBytecode: string | undefined;
|
||||||
/**
|
/**
|
||||||
* Batch fetches ETH balances
|
* Batch fetches ETH balances
|
||||||
*/
|
*/
|
||||||
@ -82,43 +90,6 @@ export class EthBalanceCheckerContract extends BaseContract {
|
|||||||
// tslint:enable boolean-naming
|
// tslint:enable boolean-naming
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
|
||||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
|
||||||
* to create a 0x transaction (see protocol spec for more details).
|
|
||||||
* @param addresses Array of addresses.
|
|
||||||
* @returns The ABI encoded transaction data as a string
|
|
||||||
*/
|
|
||||||
getABIEncodedTransactionData(addresses: string[]): string {
|
|
||||||
assert.isArray('addresses', addresses);
|
|
||||||
const self = (this as any) as EthBalanceCheckerContract;
|
|
||||||
const abiEncodedTransactionData = self._strictEncodeArguments('getEthBalances(address[])', [addresses]);
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): string[] {
|
|
||||||
const self = (this as any) as EthBalanceCheckerContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('getEthBalances(address[])');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<string[]>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): BigNumber[] {
|
|
||||||
const self = (this as any) as EthBalanceCheckerContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('getEthBalances(address[])');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<BigNumber[]>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
public static async deployFrom0xArtifactAsync(
|
public static async deployFrom0xArtifactAsync(
|
||||||
artifact: ContractArtifact | SimpleContractArtifact,
|
artifact: ContractArtifact | SimpleContractArtifact,
|
||||||
|
3345
packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts
generated
3345
packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts
generated
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -18,7 +18,13 @@ import {
|
|||||||
SupportedProvider,
|
SupportedProvider,
|
||||||
} from 'ethereum-types';
|
} from 'ethereum-types';
|
||||||
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
||||||
import { SimpleContractArtifact, EventCallback, IndexedFilterValues } from '@0x/types';
|
import {
|
||||||
|
AwaitTransactionSuccessOpts,
|
||||||
|
EventCallback,
|
||||||
|
IndexedFilterValues,
|
||||||
|
SendTransactionOpts,
|
||||||
|
SimpleContractArtifact,
|
||||||
|
} from '@0x/types';
|
||||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||||
import { assert } from '@0x/assert';
|
import { assert } from '@0x/assert';
|
||||||
import * as ethers from 'ethers';
|
import * as ethers from 'ethers';
|
||||||
@ -28,6 +34,9 @@ import * as ethers from 'ethers';
|
|||||||
// tslint:disable:no-parameter-reassignment
|
// tslint:disable:no-parameter-reassignment
|
||||||
// tslint:disable-next-line:class-name
|
// tslint:disable-next-line:class-name
|
||||||
export class IAssetProxyContract extends BaseContract {
|
export class IAssetProxyContract extends BaseContract {
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
public static deployedBytecode: string | undefined;
|
public static deployedBytecode: string | undefined;
|
||||||
/**
|
/**
|
||||||
* Transfers assets. Either succeeds or throws.
|
* Transfers assets. Either succeeds or throws.
|
||||||
@ -49,6 +58,7 @@ export class IAssetProxyContract extends BaseContract {
|
|||||||
to: string,
|
to: string,
|
||||||
amount: BigNumber,
|
amount: BigNumber,
|
||||||
txData?: Partial<TxData> | undefined,
|
txData?: Partial<TxData> | undefined,
|
||||||
|
opts: SendTransactionOpts = { shouldValidate: true },
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
assert.isString('assetData', assetData);
|
assert.isString('assetData', assetData);
|
||||||
assert.isString('from', from);
|
assert.isString('from', from);
|
||||||
@ -73,6 +83,10 @@ export class IAssetProxyContract extends BaseContract {
|
|||||||
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
|
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opts.shouldValidate !== false) {
|
||||||
|
await self.transferFrom.callAsync(assetData, from, to, amount, txDataWithDefaults);
|
||||||
|
}
|
||||||
|
|
||||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
return txHash;
|
return txHash;
|
||||||
},
|
},
|
||||||
@ -93,8 +107,7 @@ export class IAssetProxyContract extends BaseContract {
|
|||||||
to: string,
|
to: string,
|
||||||
amount: BigNumber,
|
amount: BigNumber,
|
||||||
txData?: Partial<TxData>,
|
txData?: Partial<TxData>,
|
||||||
pollingIntervalMs?: number,
|
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
|
||||||
timeoutMs?: number,
|
|
||||||
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
||||||
assert.isString('assetData', assetData);
|
assert.isString('assetData', assetData);
|
||||||
assert.isString('from', from);
|
assert.isString('from', from);
|
||||||
@ -107,6 +120,7 @@ export class IAssetProxyContract extends BaseContract {
|
|||||||
to.toLowerCase(),
|
to.toLowerCase(),
|
||||||
amount,
|
amount,
|
||||||
txData,
|
txData,
|
||||||
|
opts,
|
||||||
);
|
);
|
||||||
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
||||||
txHashPromise,
|
txHashPromise,
|
||||||
@ -114,8 +128,8 @@ export class IAssetProxyContract extends BaseContract {
|
|||||||
// When the transaction hash resolves, wait for it to be mined.
|
// When the transaction hash resolves, wait for it to be mined.
|
||||||
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
await txHashPromise,
|
await txHashPromise,
|
||||||
pollingIntervalMs,
|
opts.pollingIntervalMs,
|
||||||
timeoutMs,
|
opts.timeoutMs,
|
||||||
);
|
);
|
||||||
})(),
|
})(),
|
||||||
);
|
);
|
||||||
@ -162,17 +176,6 @@ export class IAssetProxyContract extends BaseContract {
|
|||||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
return gas;
|
return gas;
|
||||||
},
|
},
|
||||||
async validateAndSendTransactionAsync(
|
|
||||||
assetData: string,
|
|
||||||
from: string,
|
|
||||||
to: string,
|
|
||||||
amount: BigNumber,
|
|
||||||
txData?: Partial<TxData> | undefined,
|
|
||||||
): Promise<string> {
|
|
||||||
await (this as any).transferFrom.callAsync(assetData, from, to, amount, txData);
|
|
||||||
const txHash = await (this as any).transferFrom.sendTransactionAsync(assetData, from, to, amount, txData);
|
|
||||||
return txHash;
|
|
||||||
},
|
|
||||||
/**
|
/**
|
||||||
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
|
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
|
||||||
* Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas
|
* Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas
|
||||||
@ -256,30 +259,6 @@ export class IAssetProxyContract extends BaseContract {
|
|||||||
);
|
);
|
||||||
return abiEncodedTransactionData;
|
return abiEncodedTransactionData;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): [string, string, string, BigNumber] {
|
|
||||||
const self = (this as any) as IAssetProxyContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('transferFrom(bytes,address,address,uint256)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<[string, string, string, BigNumber]>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): void {
|
|
||||||
const self = (this as any) as IAssetProxyContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('transferFrom(bytes,address,address,uint256)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<void>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Gets the proxy id associated with the proxy address.
|
* Gets the proxy id associated with the proxy address.
|
||||||
@ -306,7 +285,7 @@ export class IAssetProxyContract extends BaseContract {
|
|||||||
|
|
||||||
let rawCallResult;
|
let rawCallResult;
|
||||||
try {
|
try {
|
||||||
rawCallResult = await self.evmExecAsync(encodedDataBytes);
|
rawCallResult = await self._evmExecAsync(encodedDataBytes);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
BaseContract._throwIfThrownErrorIsRevertError(err);
|
BaseContract._throwIfThrownErrorIsRevertError(err);
|
||||||
throw err;
|
throw err;
|
||||||
@ -319,41 +298,6 @@ export class IAssetProxyContract extends BaseContract {
|
|||||||
// tslint:enable boolean-naming
|
// tslint:enable boolean-naming
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
|
||||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
|
||||||
* to create a 0x transaction (see protocol spec for more details).
|
|
||||||
* @returns The ABI encoded transaction data as a string
|
|
||||||
*/
|
|
||||||
getABIEncodedTransactionData(): string {
|
|
||||||
const self = (this as any) as IAssetProxyContract;
|
|
||||||
const abiEncodedTransactionData = self._strictEncodeArguments('getProxyId()', []);
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): void {
|
|
||||||
const self = (this as any) as IAssetProxyContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('getProxyId()');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<void>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): string {
|
|
||||||
const self = (this as any) as IAssetProxyContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('getProxyId()');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<string>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
public static async deployFrom0xArtifactAsync(
|
public static async deployFrom0xArtifactAsync(
|
||||||
artifact: ContractArtifact | SimpleContractArtifact,
|
artifact: ContractArtifact | SimpleContractArtifact,
|
||||||
|
@ -18,7 +18,13 @@ import {
|
|||||||
SupportedProvider,
|
SupportedProvider,
|
||||||
} from 'ethereum-types';
|
} from 'ethereum-types';
|
||||||
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
||||||
import { SimpleContractArtifact, EventCallback, IndexedFilterValues } from '@0x/types';
|
import {
|
||||||
|
AwaitTransactionSuccessOpts,
|
||||||
|
EventCallback,
|
||||||
|
IndexedFilterValues,
|
||||||
|
SendTransactionOpts,
|
||||||
|
SimpleContractArtifact,
|
||||||
|
} from '@0x/types';
|
||||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||||
import { assert } from '@0x/assert';
|
import { assert } from '@0x/assert';
|
||||||
import * as ethers from 'ethers';
|
import * as ethers from 'ethers';
|
||||||
@ -28,6 +34,9 @@ import * as ethers from 'ethers';
|
|||||||
// tslint:disable:no-parameter-reassignment
|
// tslint:disable:no-parameter-reassignment
|
||||||
// tslint:disable-next-line:class-name
|
// tslint:disable-next-line:class-name
|
||||||
export class IValidatorContract extends BaseContract {
|
export class IValidatorContract extends BaseContract {
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
public static deployedBytecode: string | undefined;
|
public static deployedBytecode: string | undefined;
|
||||||
/**
|
/**
|
||||||
* Verifies that a signature is valid.
|
* Verifies that a signature is valid.
|
||||||
@ -91,51 +100,6 @@ export class IValidatorContract extends BaseContract {
|
|||||||
// tslint:enable boolean-naming
|
// tslint:enable boolean-naming
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
|
||||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
|
||||||
* to create a 0x transaction (see protocol spec for more details).
|
|
||||||
* @param hash Message hash that is signed.
|
|
||||||
* @param signerAddress Address that should have signed the given hash.
|
|
||||||
* @param signature Proof of signing.
|
|
||||||
* @returns The ABI encoded transaction data as a string
|
|
||||||
*/
|
|
||||||
getABIEncodedTransactionData(hash: string, signerAddress: string, signature: string): string {
|
|
||||||
assert.isString('hash', hash);
|
|
||||||
assert.isString('signerAddress', signerAddress);
|
|
||||||
assert.isString('signature', signature);
|
|
||||||
const self = (this as any) as IValidatorContract;
|
|
||||||
const abiEncodedTransactionData = self._strictEncodeArguments('isValidSignature(bytes32,address,bytes)', [
|
|
||||||
hash,
|
|
||||||
signerAddress.toLowerCase(),
|
|
||||||
signature,
|
|
||||||
]);
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): string {
|
|
||||||
const self = (this as any) as IValidatorContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('isValidSignature(bytes32,address,bytes)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<string>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): string {
|
|
||||||
const self = (this as any) as IValidatorContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('isValidSignature(bytes32,address,bytes)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<string>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
public static async deployFrom0xArtifactAsync(
|
public static async deployFrom0xArtifactAsync(
|
||||||
artifact: ContractArtifact | SimpleContractArtifact,
|
artifact: ContractArtifact | SimpleContractArtifact,
|
||||||
|
@ -18,7 +18,13 @@ import {
|
|||||||
SupportedProvider,
|
SupportedProvider,
|
||||||
} from 'ethereum-types';
|
} from 'ethereum-types';
|
||||||
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
||||||
import { SimpleContractArtifact, EventCallback, IndexedFilterValues } from '@0x/types';
|
import {
|
||||||
|
AwaitTransactionSuccessOpts,
|
||||||
|
EventCallback,
|
||||||
|
IndexedFilterValues,
|
||||||
|
SendTransactionOpts,
|
||||||
|
SimpleContractArtifact,
|
||||||
|
} from '@0x/types';
|
||||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||||
import { assert } from '@0x/assert';
|
import { assert } from '@0x/assert';
|
||||||
import * as ethers from 'ethers';
|
import * as ethers from 'ethers';
|
||||||
@ -28,6 +34,9 @@ import * as ethers from 'ethers';
|
|||||||
// tslint:disable:no-parameter-reassignment
|
// tslint:disable:no-parameter-reassignment
|
||||||
// tslint:disable-next-line:class-name
|
// tslint:disable-next-line:class-name
|
||||||
export class IWalletContract extends BaseContract {
|
export class IWalletContract extends BaseContract {
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
public static deployedBytecode: string | undefined;
|
public static deployedBytecode: string | undefined;
|
||||||
/**
|
/**
|
||||||
* Validates a hash with the `Wallet` signature type.
|
* Validates a hash with the `Wallet` signature type.
|
||||||
@ -84,48 +93,6 @@ export class IWalletContract extends BaseContract {
|
|||||||
// tslint:enable boolean-naming
|
// tslint:enable boolean-naming
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
|
||||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
|
||||||
* to create a 0x transaction (see protocol spec for more details).
|
|
||||||
* @param hash Message hash that is signed.
|
|
||||||
* @param signature Proof of signing.
|
|
||||||
* @returns The ABI encoded transaction data as a string
|
|
||||||
*/
|
|
||||||
getABIEncodedTransactionData(hash: string, signature: string): string {
|
|
||||||
assert.isString('hash', hash);
|
|
||||||
assert.isString('signature', signature);
|
|
||||||
const self = (this as any) as IWalletContract;
|
|
||||||
const abiEncodedTransactionData = self._strictEncodeArguments('isValidSignature(bytes32,bytes)', [
|
|
||||||
hash,
|
|
||||||
signature,
|
|
||||||
]);
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): string {
|
|
||||||
const self = (this as any) as IWalletContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('isValidSignature(bytes32,bytes)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<string>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): string {
|
|
||||||
const self = (this as any) as IWalletContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('isValidSignature(bytes32,bytes)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<string>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
public static async deployFrom0xArtifactAsync(
|
public static async deployFrom0xArtifactAsync(
|
||||||
artifact: ContractArtifact | SimpleContractArtifact,
|
artifact: ContractArtifact | SimpleContractArtifact,
|
||||||
|
File diff suppressed because one or more lines are too long
@ -18,7 +18,13 @@ import {
|
|||||||
SupportedProvider,
|
SupportedProvider,
|
||||||
} from 'ethereum-types';
|
} from 'ethereum-types';
|
||||||
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
||||||
import { SimpleContractArtifact, EventCallback, IndexedFilterValues } from '@0x/types';
|
import {
|
||||||
|
AwaitTransactionSuccessOpts,
|
||||||
|
EventCallback,
|
||||||
|
IndexedFilterValues,
|
||||||
|
SendTransactionOpts,
|
||||||
|
SimpleContractArtifact,
|
||||||
|
} from '@0x/types';
|
||||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||||
import { assert } from '@0x/assert';
|
import { assert } from '@0x/assert';
|
||||||
import * as ethers from 'ethers';
|
import * as ethers from 'ethers';
|
||||||
@ -28,6 +34,9 @@ import * as ethers from 'ethers';
|
|||||||
// tslint:disable:no-parameter-reassignment
|
// tslint:disable:no-parameter-reassignment
|
||||||
// tslint:disable-next-line:class-name
|
// tslint:disable-next-line:class-name
|
||||||
export class OrderValidatorContract extends BaseContract {
|
export class OrderValidatorContract extends BaseContract {
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
public static deployedBytecode: string | undefined;
|
public static deployedBytecode: string | undefined;
|
||||||
public getOrderAndTraderInfo = {
|
public getOrderAndTraderInfo = {
|
||||||
/**
|
/**
|
||||||
@ -123,129 +132,6 @@ export class OrderValidatorContract extends BaseContract {
|
|||||||
// tslint:enable boolean-naming
|
// tslint:enable boolean-naming
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
|
||||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
|
||||||
* to create a 0x transaction (see protocol spec for more details).
|
|
||||||
* @returns The ABI encoded transaction data as a string
|
|
||||||
*/
|
|
||||||
getABIEncodedTransactionData(
|
|
||||||
order: {
|
|
||||||
makerAddress: string;
|
|
||||||
takerAddress: string;
|
|
||||||
feeRecipientAddress: string;
|
|
||||||
senderAddress: string;
|
|
||||||
makerAssetAmount: BigNumber;
|
|
||||||
takerAssetAmount: BigNumber;
|
|
||||||
makerFee: BigNumber;
|
|
||||||
takerFee: BigNumber;
|
|
||||||
expirationTimeSeconds: BigNumber;
|
|
||||||
salt: BigNumber;
|
|
||||||
makerAssetData: string;
|
|
||||||
takerAssetData: string;
|
|
||||||
},
|
|
||||||
takerAddress: string,
|
|
||||||
): string {
|
|
||||||
assert.isString('takerAddress', takerAddress);
|
|
||||||
const self = (this as any) as OrderValidatorContract;
|
|
||||||
const abiEncodedTransactionData = self._strictEncodeArguments(
|
|
||||||
'getOrderAndTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)',
|
|
||||||
[order, takerAddress.toLowerCase()],
|
|
||||||
);
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(
|
|
||||||
callData: string,
|
|
||||||
): [
|
|
||||||
{
|
|
||||||
makerAddress: string;
|
|
||||||
takerAddress: string;
|
|
||||||
feeRecipientAddress: string;
|
|
||||||
senderAddress: string;
|
|
||||||
makerAssetAmount: BigNumber;
|
|
||||||
takerAssetAmount: BigNumber;
|
|
||||||
makerFee: BigNumber;
|
|
||||||
takerFee: BigNumber;
|
|
||||||
expirationTimeSeconds: BigNumber;
|
|
||||||
salt: BigNumber;
|
|
||||||
makerAssetData: string;
|
|
||||||
takerAssetData: string;
|
|
||||||
},
|
|
||||||
string
|
|
||||||
] {
|
|
||||||
const self = (this as any) as OrderValidatorContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder(
|
|
||||||
'getOrderAndTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)',
|
|
||||||
);
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<
|
|
||||||
[
|
|
||||||
{
|
|
||||||
makerAddress: string;
|
|
||||||
takerAddress: string;
|
|
||||||
feeRecipientAddress: string;
|
|
||||||
senderAddress: string;
|
|
||||||
makerAssetAmount: BigNumber;
|
|
||||||
takerAssetAmount: BigNumber;
|
|
||||||
makerFee: BigNumber;
|
|
||||||
takerFee: BigNumber;
|
|
||||||
expirationTimeSeconds: BigNumber;
|
|
||||||
salt: BigNumber;
|
|
||||||
makerAssetData: string;
|
|
||||||
takerAssetData: string;
|
|
||||||
},
|
|
||||||
string
|
|
||||||
]
|
|
||||||
>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(
|
|
||||||
returnData: string,
|
|
||||||
): [
|
|
||||||
{ orderStatus: number; orderHash: string; orderTakerAssetFilledAmount: BigNumber },
|
|
||||||
{
|
|
||||||
makerBalance: BigNumber;
|
|
||||||
makerAllowance: BigNumber;
|
|
||||||
takerBalance: BigNumber;
|
|
||||||
takerAllowance: BigNumber;
|
|
||||||
makerZrxBalance: BigNumber;
|
|
||||||
makerZrxAllowance: BigNumber;
|
|
||||||
takerZrxBalance: BigNumber;
|
|
||||||
takerZrxAllowance: BigNumber;
|
|
||||||
}
|
|
||||||
] {
|
|
||||||
const self = (this as any) as OrderValidatorContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder(
|
|
||||||
'getOrderAndTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)',
|
|
||||||
);
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<
|
|
||||||
[
|
|
||||||
{ orderStatus: number; orderHash: string; orderTakerAssetFilledAmount: BigNumber },
|
|
||||||
{
|
|
||||||
makerBalance: BigNumber;
|
|
||||||
makerAllowance: BigNumber;
|
|
||||||
takerBalance: BigNumber;
|
|
||||||
takerAllowance: BigNumber;
|
|
||||||
makerZrxBalance: BigNumber;
|
|
||||||
makerZrxAllowance: BigNumber;
|
|
||||||
takerZrxBalance: BigNumber;
|
|
||||||
takerZrxAllowance: BigNumber;
|
|
||||||
}
|
|
||||||
]
|
|
||||||
>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
public getBalanceAndAllowance = {
|
public getBalanceAndAllowance = {
|
||||||
/**
|
/**
|
||||||
@ -299,46 +185,6 @@ export class OrderValidatorContract extends BaseContract {
|
|||||||
// tslint:enable boolean-naming
|
// tslint:enable boolean-naming
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
|
||||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
|
||||||
* to create a 0x transaction (see protocol spec for more details).
|
|
||||||
* @returns The ABI encoded transaction data as a string
|
|
||||||
*/
|
|
||||||
getABIEncodedTransactionData(target: string, assetData: string): string {
|
|
||||||
assert.isString('target', target);
|
|
||||||
assert.isString('assetData', assetData);
|
|
||||||
const self = (this as any) as OrderValidatorContract;
|
|
||||||
const abiEncodedTransactionData = self._strictEncodeArguments('getBalanceAndAllowance(address,bytes)', [
|
|
||||||
target.toLowerCase(),
|
|
||||||
assetData,
|
|
||||||
]);
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): [string, string] {
|
|
||||||
const self = (this as any) as OrderValidatorContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('getBalanceAndAllowance(address,bytes)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<[string, string]>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): [BigNumber, BigNumber] {
|
|
||||||
const self = (this as any) as OrderValidatorContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('getBalanceAndAllowance(address,bytes)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<[BigNumber, BigNumber]>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
public getOrdersAndTradersInfo = {
|
public getOrdersAndTradersInfo = {
|
||||||
/**
|
/**
|
||||||
@ -435,130 +281,6 @@ export class OrderValidatorContract extends BaseContract {
|
|||||||
// tslint:enable boolean-naming
|
// tslint:enable boolean-naming
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
|
||||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
|
||||||
* to create a 0x transaction (see protocol spec for more details).
|
|
||||||
* @returns The ABI encoded transaction data as a string
|
|
||||||
*/
|
|
||||||
getABIEncodedTransactionData(
|
|
||||||
orders: Array<{
|
|
||||||
makerAddress: string;
|
|
||||||
takerAddress: string;
|
|
||||||
feeRecipientAddress: string;
|
|
||||||
senderAddress: string;
|
|
||||||
makerAssetAmount: BigNumber;
|
|
||||||
takerAssetAmount: BigNumber;
|
|
||||||
makerFee: BigNumber;
|
|
||||||
takerFee: BigNumber;
|
|
||||||
expirationTimeSeconds: BigNumber;
|
|
||||||
salt: BigNumber;
|
|
||||||
makerAssetData: string;
|
|
||||||
takerAssetData: string;
|
|
||||||
}>,
|
|
||||||
takerAddresses: string[],
|
|
||||||
): string {
|
|
||||||
assert.isArray('orders', orders);
|
|
||||||
assert.isArray('takerAddresses', takerAddresses);
|
|
||||||
const self = (this as any) as OrderValidatorContract;
|
|
||||||
const abiEncodedTransactionData = self._strictEncodeArguments(
|
|
||||||
'getOrdersAndTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])',
|
|
||||||
[orders, takerAddresses],
|
|
||||||
);
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(
|
|
||||||
callData: string,
|
|
||||||
): [
|
|
||||||
Array<{
|
|
||||||
makerAddress: string;
|
|
||||||
takerAddress: string;
|
|
||||||
feeRecipientAddress: string;
|
|
||||||
senderAddress: string;
|
|
||||||
makerAssetAmount: BigNumber;
|
|
||||||
takerAssetAmount: BigNumber;
|
|
||||||
makerFee: BigNumber;
|
|
||||||
takerFee: BigNumber;
|
|
||||||
expirationTimeSeconds: BigNumber;
|
|
||||||
salt: BigNumber;
|
|
||||||
makerAssetData: string;
|
|
||||||
takerAssetData: string;
|
|
||||||
}>,
|
|
||||||
string[]
|
|
||||||
] {
|
|
||||||
const self = (this as any) as OrderValidatorContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder(
|
|
||||||
'getOrdersAndTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])',
|
|
||||||
);
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<
|
|
||||||
[
|
|
||||||
Array<{
|
|
||||||
makerAddress: string;
|
|
||||||
takerAddress: string;
|
|
||||||
feeRecipientAddress: string;
|
|
||||||
senderAddress: string;
|
|
||||||
makerAssetAmount: BigNumber;
|
|
||||||
takerAssetAmount: BigNumber;
|
|
||||||
makerFee: BigNumber;
|
|
||||||
takerFee: BigNumber;
|
|
||||||
expirationTimeSeconds: BigNumber;
|
|
||||||
salt: BigNumber;
|
|
||||||
makerAssetData: string;
|
|
||||||
takerAssetData: string;
|
|
||||||
}>,
|
|
||||||
string[]
|
|
||||||
]
|
|
||||||
>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(
|
|
||||||
returnData: string,
|
|
||||||
): [
|
|
||||||
Array<{ orderStatus: number; orderHash: string; orderTakerAssetFilledAmount: BigNumber }>,
|
|
||||||
Array<{
|
|
||||||
makerBalance: BigNumber;
|
|
||||||
makerAllowance: BigNumber;
|
|
||||||
takerBalance: BigNumber;
|
|
||||||
takerAllowance: BigNumber;
|
|
||||||
makerZrxBalance: BigNumber;
|
|
||||||
makerZrxAllowance: BigNumber;
|
|
||||||
takerZrxBalance: BigNumber;
|
|
||||||
takerZrxAllowance: BigNumber;
|
|
||||||
}>
|
|
||||||
] {
|
|
||||||
const self = (this as any) as OrderValidatorContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder(
|
|
||||||
'getOrdersAndTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])',
|
|
||||||
);
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<
|
|
||||||
[
|
|
||||||
Array<{ orderStatus: number; orderHash: string; orderTakerAssetFilledAmount: BigNumber }>,
|
|
||||||
Array<{
|
|
||||||
makerBalance: BigNumber;
|
|
||||||
makerAllowance: BigNumber;
|
|
||||||
takerBalance: BigNumber;
|
|
||||||
takerAllowance: BigNumber;
|
|
||||||
makerZrxBalance: BigNumber;
|
|
||||||
makerZrxAllowance: BigNumber;
|
|
||||||
takerZrxBalance: BigNumber;
|
|
||||||
takerZrxAllowance: BigNumber;
|
|
||||||
}>
|
|
||||||
]
|
|
||||||
>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
public getTradersInfo = {
|
public getTradersInfo = {
|
||||||
/**
|
/**
|
||||||
@ -649,118 +371,6 @@ export class OrderValidatorContract extends BaseContract {
|
|||||||
// tslint:enable boolean-naming
|
// tslint:enable boolean-naming
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
|
||||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
|
||||||
* to create a 0x transaction (see protocol spec for more details).
|
|
||||||
* @returns The ABI encoded transaction data as a string
|
|
||||||
*/
|
|
||||||
getABIEncodedTransactionData(
|
|
||||||
orders: Array<{
|
|
||||||
makerAddress: string;
|
|
||||||
takerAddress: string;
|
|
||||||
feeRecipientAddress: string;
|
|
||||||
senderAddress: string;
|
|
||||||
makerAssetAmount: BigNumber;
|
|
||||||
takerAssetAmount: BigNumber;
|
|
||||||
makerFee: BigNumber;
|
|
||||||
takerFee: BigNumber;
|
|
||||||
expirationTimeSeconds: BigNumber;
|
|
||||||
salt: BigNumber;
|
|
||||||
makerAssetData: string;
|
|
||||||
takerAssetData: string;
|
|
||||||
}>,
|
|
||||||
takerAddresses: string[],
|
|
||||||
): string {
|
|
||||||
assert.isArray('orders', orders);
|
|
||||||
assert.isArray('takerAddresses', takerAddresses);
|
|
||||||
const self = (this as any) as OrderValidatorContract;
|
|
||||||
const abiEncodedTransactionData = self._strictEncodeArguments(
|
|
||||||
'getTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])',
|
|
||||||
[orders, takerAddresses],
|
|
||||||
);
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(
|
|
||||||
callData: string,
|
|
||||||
): Array<{
|
|
||||||
makerAddress: string;
|
|
||||||
takerAddress: string;
|
|
||||||
feeRecipientAddress: string;
|
|
||||||
senderAddress: string;
|
|
||||||
makerAssetAmount: BigNumber;
|
|
||||||
takerAssetAmount: BigNumber;
|
|
||||||
makerFee: BigNumber;
|
|
||||||
takerFee: BigNumber;
|
|
||||||
expirationTimeSeconds: BigNumber;
|
|
||||||
salt: BigNumber;
|
|
||||||
makerAssetData: string;
|
|
||||||
takerAssetData: string;
|
|
||||||
}> {
|
|
||||||
const self = (this as any) as OrderValidatorContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder(
|
|
||||||
'getTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])',
|
|
||||||
);
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<
|
|
||||||
Array<{
|
|
||||||
makerAddress: string;
|
|
||||||
takerAddress: string;
|
|
||||||
feeRecipientAddress: string;
|
|
||||||
senderAddress: string;
|
|
||||||
makerAssetAmount: BigNumber;
|
|
||||||
takerAssetAmount: BigNumber;
|
|
||||||
makerFee: BigNumber;
|
|
||||||
takerFee: BigNumber;
|
|
||||||
expirationTimeSeconds: BigNumber;
|
|
||||||
salt: BigNumber;
|
|
||||||
makerAssetData: string;
|
|
||||||
takerAssetData: string;
|
|
||||||
}>
|
|
||||||
>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(
|
|
||||||
returnData: string,
|
|
||||||
): Array<{
|
|
||||||
makerBalance: BigNumber;
|
|
||||||
makerAllowance: BigNumber;
|
|
||||||
takerBalance: BigNumber;
|
|
||||||
takerAllowance: BigNumber;
|
|
||||||
makerZrxBalance: BigNumber;
|
|
||||||
makerZrxAllowance: BigNumber;
|
|
||||||
takerZrxBalance: BigNumber;
|
|
||||||
takerZrxAllowance: BigNumber;
|
|
||||||
}> {
|
|
||||||
const self = (this as any) as OrderValidatorContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder(
|
|
||||||
'getTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])',
|
|
||||||
);
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<
|
|
||||||
Array<{
|
|
||||||
makerBalance: BigNumber;
|
|
||||||
makerAllowance: BigNumber;
|
|
||||||
takerBalance: BigNumber;
|
|
||||||
takerAllowance: BigNumber;
|
|
||||||
makerZrxBalance: BigNumber;
|
|
||||||
makerZrxAllowance: BigNumber;
|
|
||||||
takerZrxBalance: BigNumber;
|
|
||||||
takerZrxAllowance: BigNumber;
|
|
||||||
}>
|
|
||||||
>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
public getERC721TokenOwner = {
|
public getERC721TokenOwner = {
|
||||||
/**
|
/**
|
||||||
@ -814,46 +424,6 @@ export class OrderValidatorContract extends BaseContract {
|
|||||||
// tslint:enable boolean-naming
|
// tslint:enable boolean-naming
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
|
||||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
|
||||||
* to create a 0x transaction (see protocol spec for more details).
|
|
||||||
* @returns The ABI encoded transaction data as a string
|
|
||||||
*/
|
|
||||||
getABIEncodedTransactionData(token: string, tokenId: BigNumber): string {
|
|
||||||
assert.isString('token', token);
|
|
||||||
assert.isBigNumber('tokenId', tokenId);
|
|
||||||
const self = (this as any) as OrderValidatorContract;
|
|
||||||
const abiEncodedTransactionData = self._strictEncodeArguments('getERC721TokenOwner(address,uint256)', [
|
|
||||||
token.toLowerCase(),
|
|
||||||
tokenId,
|
|
||||||
]);
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): string {
|
|
||||||
const self = (this as any) as OrderValidatorContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('getERC721TokenOwner(address,uint256)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<string>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): string {
|
|
||||||
const self = (this as any) as OrderValidatorContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('getERC721TokenOwner(address,uint256)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<string>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
public getBalancesAndAllowances = {
|
public getBalancesAndAllowances = {
|
||||||
/**
|
/**
|
||||||
@ -907,46 +477,6 @@ export class OrderValidatorContract extends BaseContract {
|
|||||||
// tslint:enable boolean-naming
|
// tslint:enable boolean-naming
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
|
||||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
|
||||||
* to create a 0x transaction (see protocol spec for more details).
|
|
||||||
* @returns The ABI encoded transaction data as a string
|
|
||||||
*/
|
|
||||||
getABIEncodedTransactionData(target: string, assetData: string[]): string {
|
|
||||||
assert.isString('target', target);
|
|
||||||
assert.isArray('assetData', assetData);
|
|
||||||
const self = (this as any) as OrderValidatorContract;
|
|
||||||
const abiEncodedTransactionData = self._strictEncodeArguments('getBalancesAndAllowances(address,bytes[])', [
|
|
||||||
target.toLowerCase(),
|
|
||||||
assetData,
|
|
||||||
]);
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): [string, string[]] {
|
|
||||||
const self = (this as any) as OrderValidatorContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('getBalancesAndAllowances(address,bytes[])');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<[string, string[]]>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): [BigNumber[], BigNumber[]] {
|
|
||||||
const self = (this as any) as OrderValidatorContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('getBalancesAndAllowances(address,bytes[])');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<[BigNumber[], BigNumber[]]>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
public getTraderInfo = {
|
public getTraderInfo = {
|
||||||
/**
|
/**
|
||||||
@ -1032,113 +562,6 @@ export class OrderValidatorContract extends BaseContract {
|
|||||||
// tslint:enable boolean-naming
|
// tslint:enable boolean-naming
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
|
||||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
|
||||||
* to create a 0x transaction (see protocol spec for more details).
|
|
||||||
* @returns The ABI encoded transaction data as a string
|
|
||||||
*/
|
|
||||||
getABIEncodedTransactionData(
|
|
||||||
order: {
|
|
||||||
makerAddress: string;
|
|
||||||
takerAddress: string;
|
|
||||||
feeRecipientAddress: string;
|
|
||||||
senderAddress: string;
|
|
||||||
makerAssetAmount: BigNumber;
|
|
||||||
takerAssetAmount: BigNumber;
|
|
||||||
makerFee: BigNumber;
|
|
||||||
takerFee: BigNumber;
|
|
||||||
expirationTimeSeconds: BigNumber;
|
|
||||||
salt: BigNumber;
|
|
||||||
makerAssetData: string;
|
|
||||||
takerAssetData: string;
|
|
||||||
},
|
|
||||||
takerAddress: string,
|
|
||||||
): string {
|
|
||||||
assert.isString('takerAddress', takerAddress);
|
|
||||||
const self = (this as any) as OrderValidatorContract;
|
|
||||||
const abiEncodedTransactionData = self._strictEncodeArguments(
|
|
||||||
'getTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)',
|
|
||||||
[order, takerAddress.toLowerCase()],
|
|
||||||
);
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(
|
|
||||||
callData: string,
|
|
||||||
): {
|
|
||||||
makerAddress: string;
|
|
||||||
takerAddress: string;
|
|
||||||
feeRecipientAddress: string;
|
|
||||||
senderAddress: string;
|
|
||||||
makerAssetAmount: BigNumber;
|
|
||||||
takerAssetAmount: BigNumber;
|
|
||||||
makerFee: BigNumber;
|
|
||||||
takerFee: BigNumber;
|
|
||||||
expirationTimeSeconds: BigNumber;
|
|
||||||
salt: BigNumber;
|
|
||||||
makerAssetData: string;
|
|
||||||
takerAssetData: string;
|
|
||||||
} {
|
|
||||||
const self = (this as any) as OrderValidatorContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder(
|
|
||||||
'getTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)',
|
|
||||||
);
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<{
|
|
||||||
makerAddress: string;
|
|
||||||
takerAddress: string;
|
|
||||||
feeRecipientAddress: string;
|
|
||||||
senderAddress: string;
|
|
||||||
makerAssetAmount: BigNumber;
|
|
||||||
takerAssetAmount: BigNumber;
|
|
||||||
makerFee: BigNumber;
|
|
||||||
takerFee: BigNumber;
|
|
||||||
expirationTimeSeconds: BigNumber;
|
|
||||||
salt: BigNumber;
|
|
||||||
makerAssetData: string;
|
|
||||||
takerAssetData: string;
|
|
||||||
}>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(
|
|
||||||
returnData: string,
|
|
||||||
): {
|
|
||||||
makerBalance: BigNumber;
|
|
||||||
makerAllowance: BigNumber;
|
|
||||||
takerBalance: BigNumber;
|
|
||||||
takerAllowance: BigNumber;
|
|
||||||
makerZrxBalance: BigNumber;
|
|
||||||
makerZrxAllowance: BigNumber;
|
|
||||||
takerZrxBalance: BigNumber;
|
|
||||||
takerZrxAllowance: BigNumber;
|
|
||||||
} {
|
|
||||||
const self = (this as any) as OrderValidatorContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder(
|
|
||||||
'getTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)',
|
|
||||||
);
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<{
|
|
||||||
makerBalance: BigNumber;
|
|
||||||
makerAllowance: BigNumber;
|
|
||||||
takerBalance: BigNumber;
|
|
||||||
takerAllowance: BigNumber;
|
|
||||||
makerZrxBalance: BigNumber;
|
|
||||||
makerZrxAllowance: BigNumber;
|
|
||||||
takerZrxBalance: BigNumber;
|
|
||||||
takerZrxAllowance: BigNumber;
|
|
||||||
}>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
public static async deployFrom0xArtifactAsync(
|
public static async deployFrom0xArtifactAsync(
|
||||||
artifact: ContractArtifact | SimpleContractArtifact,
|
artifact: ContractArtifact | SimpleContractArtifact,
|
||||||
|
@ -18,7 +18,13 @@ import {
|
|||||||
SupportedProvider,
|
SupportedProvider,
|
||||||
} from 'ethereum-types';
|
} from 'ethereum-types';
|
||||||
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
||||||
import { SimpleContractArtifact, EventCallback, IndexedFilterValues } from '@0x/types';
|
import {
|
||||||
|
AwaitTransactionSuccessOpts,
|
||||||
|
EventCallback,
|
||||||
|
IndexedFilterValues,
|
||||||
|
SendTransactionOpts,
|
||||||
|
SimpleContractArtifact,
|
||||||
|
} from '@0x/types';
|
||||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||||
import { assert } from '@0x/assert';
|
import { assert } from '@0x/assert';
|
||||||
import * as ethers from 'ethers';
|
import * as ethers from 'ethers';
|
||||||
@ -28,6 +34,9 @@ import * as ethers from 'ethers';
|
|||||||
// tslint:disable:no-parameter-reassignment
|
// tslint:disable:no-parameter-reassignment
|
||||||
// tslint:disable-next-line:class-name
|
// tslint:disable-next-line:class-name
|
||||||
export class StaticCallProxyContract extends BaseContract {
|
export class StaticCallProxyContract extends BaseContract {
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
public static deployedBytecode =
|
public static deployedBytecode =
|
||||||
'0x608060405234801561001057600080fd5b50600436106100365760003560e01c8063a85e59e41461003b578063ae25532e146100d3575b600080fd5b6100d16004803603608081101561005157600080fd5b81019060208101813564010000000081111561006c57600080fd5b82018360208201111561007e57600080fd5b803590602001918460018302840111640100000000831117156100a057600080fd5b919350915073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060400135610110565b005b6100db6103a5565b604080517fffffffff000000000000000000000000000000000000000000000000000000009092168252519081900360200190f35b6000606060006101656004898990508a8a8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092949392505063ffffffff6103c5169050565b806020019051606081101561017957600080fd5b8151602083018051604051929492938301929190846401000000008211156101a057600080fd5b9083019060208201858111156101b557600080fd5b82516401000000008111828201881017156101cf57600080fd5b82525081516020918201929091019080838360005b838110156101fc5781810151838201526020016101e4565b50505050905090810190601f1680156102295780820380516001836020036101000a031916815260200191505b5060405260200180519060200190929190505050925092509250600060608473ffffffffffffffffffffffffffffffffffffffff16846040518082805190602001908083835b602083106102ac57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161026f565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d806000811461030c576040519150601f19603f3d011682016040523d82523d6000602084013e610311565b606091505b50915091508161032357805160208201fd5b8051602082012083811461039857604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f554e45585045435445445f5354415449435f43414c4c5f524553554c54000000604482015290519081900360640190fd5b5050505050505050505050565b600060405180806104b06021913960210190506040518091039020905090565b6060818311156103e3576103e36103de60008585610408565b6104a7565b83518211156103fc576103fc6103de6001848751610408565b50819003910190815290565b6060632800659560e01b8484846040516024018084600781111561042857fe5b60ff1681526020018381526020018281526020019350505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505090509392505050565b805160208201fdfe53746174696343616c6c28616464726573732c62797465732c6279746573333229a265627a7a72315820c55cf13cfcaaf322238d786911313ce7d45854692241ae9b56709bdbfed4f54c64736f6c634300050b0032';
|
'0x608060405234801561001057600080fd5b50600436106100365760003560e01c8063a85e59e41461003b578063ae25532e146100d3575b600080fd5b6100d16004803603608081101561005157600080fd5b81019060208101813564010000000081111561006c57600080fd5b82018360208201111561007e57600080fd5b803590602001918460018302840111640100000000831117156100a057600080fd5b919350915073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060400135610110565b005b6100db6103a5565b604080517fffffffff000000000000000000000000000000000000000000000000000000009092168252519081900360200190f35b6000606060006101656004898990508a8a8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092949392505063ffffffff6103c5169050565b806020019051606081101561017957600080fd5b8151602083018051604051929492938301929190846401000000008211156101a057600080fd5b9083019060208201858111156101b557600080fd5b82516401000000008111828201881017156101cf57600080fd5b82525081516020918201929091019080838360005b838110156101fc5781810151838201526020016101e4565b50505050905090810190601f1680156102295780820380516001836020036101000a031916815260200191505b5060405260200180519060200190929190505050925092509250600060608473ffffffffffffffffffffffffffffffffffffffff16846040518082805190602001908083835b602083106102ac57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161026f565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d806000811461030c576040519150601f19603f3d011682016040523d82523d6000602084013e610311565b606091505b50915091508161032357805160208201fd5b8051602082012083811461039857604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f554e45585045435445445f5354415449435f43414c4c5f524553554c54000000604482015290519081900360640190fd5b5050505050505050505050565b600060405180806104b06021913960210190506040518091039020905090565b6060818311156103e3576103e36103de60008585610408565b6104a7565b83518211156103fc576103fc6103de6001848751610408565b50819003910190815290565b6060632800659560e01b8484846040516024018084600781111561042857fe5b60ff1681526020018381526020018281526020019350505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505090509392505050565b805160208201fdfe53746174696343616c6c28616464726573732c62797465732c6279746573333229a265627a7a72315820c55cf13cfcaaf322238d786911313ce7d45854692241ae9b56709bdbfed4f54c64736f6c634300050b0032';
|
||||||
/**
|
/**
|
||||||
@ -96,53 +105,6 @@ export class StaticCallProxyContract extends BaseContract {
|
|||||||
// tslint:enable boolean-naming
|
// tslint:enable boolean-naming
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
|
||||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
|
||||||
* to create a 0x transaction (see protocol spec for more details).
|
|
||||||
* @param assetData Byte array encoded with staticCallTarget, staticCallData,
|
|
||||||
* and expectedCallResultHash
|
|
||||||
* @param from This value is ignored.
|
|
||||||
* @param to This value is ignored.
|
|
||||||
* @param amount This value is ignored.
|
|
||||||
* @returns The ABI encoded transaction data as a string
|
|
||||||
*/
|
|
||||||
getABIEncodedTransactionData(assetData: string, from: string, to: string, amount: BigNumber): string {
|
|
||||||
assert.isString('assetData', assetData);
|
|
||||||
assert.isString('from', from);
|
|
||||||
assert.isString('to', to);
|
|
||||||
assert.isBigNumber('amount', amount);
|
|
||||||
const self = (this as any) as StaticCallProxyContract;
|
|
||||||
const abiEncodedTransactionData = self._strictEncodeArguments(
|
|
||||||
'transferFrom(bytes,address,address,uint256)',
|
|
||||||
[assetData, from.toLowerCase(), to.toLowerCase(), amount],
|
|
||||||
);
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): [string, string, string, BigNumber] {
|
|
||||||
const self = (this as any) as StaticCallProxyContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('transferFrom(bytes,address,address,uint256)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<[string, string, string, BigNumber]>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): void {
|
|
||||||
const self = (this as any) as StaticCallProxyContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('transferFrom(bytes,address,address,uint256)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<void>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Gets the proxy id associated with the proxy address.
|
* Gets the proxy id associated with the proxy address.
|
||||||
@ -169,7 +131,7 @@ export class StaticCallProxyContract extends BaseContract {
|
|||||||
|
|
||||||
let rawCallResult;
|
let rawCallResult;
|
||||||
try {
|
try {
|
||||||
rawCallResult = await self.evmExecAsync(encodedDataBytes);
|
rawCallResult = await self._evmExecAsync(encodedDataBytes);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
BaseContract._throwIfThrownErrorIsRevertError(err);
|
BaseContract._throwIfThrownErrorIsRevertError(err);
|
||||||
throw err;
|
throw err;
|
||||||
@ -182,41 +144,6 @@ export class StaticCallProxyContract extends BaseContract {
|
|||||||
// tslint:enable boolean-naming
|
// tslint:enable boolean-naming
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
|
||||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
|
||||||
* to create a 0x transaction (see protocol spec for more details).
|
|
||||||
* @returns The ABI encoded transaction data as a string
|
|
||||||
*/
|
|
||||||
getABIEncodedTransactionData(): string {
|
|
||||||
const self = (this as any) as StaticCallProxyContract;
|
|
||||||
const abiEncodedTransactionData = self._strictEncodeArguments('getProxyId()', []);
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): void {
|
|
||||||
const self = (this as any) as StaticCallProxyContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('getProxyId()');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<void>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): string {
|
|
||||||
const self = (this as any) as StaticCallProxyContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('getProxyId()');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<string>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
public static async deployFrom0xArtifactAsync(
|
public static async deployFrom0xArtifactAsync(
|
||||||
artifact: ContractArtifact | SimpleContractArtifact,
|
artifact: ContractArtifact | SimpleContractArtifact,
|
||||||
|
@ -19,7 +19,13 @@ import {
|
|||||||
SupportedProvider,
|
SupportedProvider,
|
||||||
} from 'ethereum-types';
|
} from 'ethereum-types';
|
||||||
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
||||||
import { SimpleContractArtifact, EventCallback, IndexedFilterValues } from '@0x/types';
|
import {
|
||||||
|
AwaitTransactionSuccessOpts,
|
||||||
|
EventCallback,
|
||||||
|
IndexedFilterValues,
|
||||||
|
SendTransactionOpts,
|
||||||
|
SimpleContractArtifact,
|
||||||
|
} from '@0x/types';
|
||||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||||
import { assert } from '@0x/assert';
|
import { assert } from '@0x/assert';
|
||||||
import * as ethers from 'ethers';
|
import * as ethers from 'ethers';
|
||||||
@ -64,8 +70,10 @@ export interface WETH9WithdrawalEventArgs extends DecodedLogArgs {
|
|||||||
// tslint:disable:no-parameter-reassignment
|
// tslint:disable:no-parameter-reassignment
|
||||||
// tslint:disable-next-line:class-name
|
// tslint:disable-next-line:class-name
|
||||||
export class WETH9Contract extends BaseContract {
|
export class WETH9Contract extends BaseContract {
|
||||||
public static deployedBytecode =
|
/**
|
||||||
'0x6080604052600436106100925760003560e01c63ffffffff16806306fdde031461009c578063095ea7b31461012657806318160ddd1461016b57806323b872dd146101925780632e1a7d4d146101c9578063313ce567146101e157806370a082311461020c57806395d89b411461023a578063a9059cbb1461024f578063d0e30db014610092578063dd62ed3e14610280575b61009a6102b4565b005b3480156100a857600080fd5b506100b1610303565b6040805160208082528351818301528351919283929083019185019080838360005b838110156100eb5781810151838201526020016100d3565b50505050905090810190601f1680156101185780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561013257600080fd5b5061015773ffffffffffffffffffffffffffffffffffffffff600435166024356103af565b604080519115158252519081900360200190f35b34801561017757600080fd5b50610180610422565b60408051918252519081900360200190f35b34801561019e57600080fd5b5061015773ffffffffffffffffffffffffffffffffffffffff60043581169060243516604435610427565b3480156101d557600080fd5b5061009a6004356105c7565b3480156101ed57600080fd5b506101f661065c565b6040805160ff9092168252519081900360200190f35b34801561021857600080fd5b5061018073ffffffffffffffffffffffffffffffffffffffff60043516610665565b34801561024657600080fd5b506100b1610677565b34801561025b57600080fd5b5061015773ffffffffffffffffffffffffffffffffffffffff600435166024356106ef565b34801561028c57600080fd5b5061018073ffffffffffffffffffffffffffffffffffffffff60043581169060243516610703565b33600081815260036020908152604091829020805434908101909155825190815291517fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c9281900390910190a2565b6000805460408051602060026001851615610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190941693909304601f810184900484028201840190925281815292918301828280156103a75780601f1061037c576101008083540402835291602001916103a7565b820191906000526020600020905b81548152906001019060200180831161038a57829003601f168201915b505050505081565b33600081815260046020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b303190565b73ffffffffffffffffffffffffffffffffffffffff831660009081526003602052604081205482111561045957600080fd5b73ffffffffffffffffffffffffffffffffffffffff841633148015906104cf575073ffffffffffffffffffffffffffffffffffffffff841660009081526004602090815260408083203384529091529020547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14155b156105495773ffffffffffffffffffffffffffffffffffffffff8416600090815260046020908152604080832033845290915290205482111561051157600080fd5b73ffffffffffffffffffffffffffffffffffffffff841660009081526004602090815260408083203384529091529020805483900390555b73ffffffffffffffffffffffffffffffffffffffff808516600081815260036020908152604080832080548890039055938716808352918490208054870190558351868152935191937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929081900390910190a35060019392505050565b336000908152600360205260409020548111156105e357600080fd5b33600081815260036020526040808220805485900390555183156108fc0291849190818181858888f19350505050158015610622573d6000803e3d6000fd5b5060408051828152905133917f7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65919081900360200190a250565b60025460ff1681565b60036020526000908152604090205481565b60018054604080516020600284861615610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190941693909304601f810184900484028201840190925281815292918301828280156103a75780601f1061037c576101008083540402835291602001916103a7565b60006106fc338484610427565b9392505050565b6004602090815260009283526040808420909152908252902054815600a165627a7a723058201ebe888a6b56dd871f599adbe0f19ec3c29c28aec0685788dfac9b37a99fc9d20029';
|
* @ignore
|
||||||
|
*/
|
||||||
|
public static deployedBytecode: string | undefined;
|
||||||
public name = {
|
public name = {
|
||||||
/**
|
/**
|
||||||
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
|
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
|
||||||
@ -108,41 +116,6 @@ export class WETH9Contract extends BaseContract {
|
|||||||
// tslint:enable boolean-naming
|
// tslint:enable boolean-naming
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
|
||||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
|
||||||
* to create a 0x transaction (see protocol spec for more details).
|
|
||||||
* @returns The ABI encoded transaction data as a string
|
|
||||||
*/
|
|
||||||
getABIEncodedTransactionData(): string {
|
|
||||||
const self = (this as any) as WETH9Contract;
|
|
||||||
const abiEncodedTransactionData = self._strictEncodeArguments('name()', []);
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): void {
|
|
||||||
const self = (this as any) as WETH9Contract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('name()');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<void>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): string {
|
|
||||||
const self = (this as any) as WETH9Contract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('name()');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<string>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
public approve = {
|
public approve = {
|
||||||
/**
|
/**
|
||||||
@ -151,7 +124,12 @@ export class WETH9Contract extends BaseContract {
|
|||||||
* @param txData Additional data for transaction
|
* @param txData Additional data for transaction
|
||||||
* @returns The hash of the transaction
|
* @returns The hash of the transaction
|
||||||
*/
|
*/
|
||||||
async sendTransactionAsync(guy: string, wad: BigNumber, txData?: Partial<TxData> | undefined): Promise<string> {
|
async sendTransactionAsync(
|
||||||
|
guy: string,
|
||||||
|
wad: BigNumber,
|
||||||
|
txData?: Partial<TxData> | undefined,
|
||||||
|
opts: SendTransactionOpts = { shouldValidate: true },
|
||||||
|
): Promise<string> {
|
||||||
assert.isString('guy', guy);
|
assert.isString('guy', guy);
|
||||||
assert.isBigNumber('wad', wad);
|
assert.isBigNumber('wad', wad);
|
||||||
const self = (this as any) as WETH9Contract;
|
const self = (this as any) as WETH9Contract;
|
||||||
@ -168,6 +146,10 @@ export class WETH9Contract extends BaseContract {
|
|||||||
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
|
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opts.shouldValidate !== false) {
|
||||||
|
await self.approve.callAsync(guy, wad, txDataWithDefaults);
|
||||||
|
}
|
||||||
|
|
||||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
return txHash;
|
return txHash;
|
||||||
},
|
},
|
||||||
@ -182,21 +164,20 @@ export class WETH9Contract extends BaseContract {
|
|||||||
guy: string,
|
guy: string,
|
||||||
wad: BigNumber,
|
wad: BigNumber,
|
||||||
txData?: Partial<TxData>,
|
txData?: Partial<TxData>,
|
||||||
pollingIntervalMs?: number,
|
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
|
||||||
timeoutMs?: number,
|
|
||||||
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
||||||
assert.isString('guy', guy);
|
assert.isString('guy', guy);
|
||||||
assert.isBigNumber('wad', wad);
|
assert.isBigNumber('wad', wad);
|
||||||
const self = (this as any) as WETH9Contract;
|
const self = (this as any) as WETH9Contract;
|
||||||
const txHashPromise = self.approve.sendTransactionAsync(guy.toLowerCase(), wad, txData);
|
const txHashPromise = self.approve.sendTransactionAsync(guy.toLowerCase(), wad, txData, opts);
|
||||||
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
||||||
txHashPromise,
|
txHashPromise,
|
||||||
(async (): Promise<TransactionReceiptWithDecodedLogs> => {
|
(async (): Promise<TransactionReceiptWithDecodedLogs> => {
|
||||||
// When the transaction hash resolves, wait for it to be mined.
|
// When the transaction hash resolves, wait for it to be mined.
|
||||||
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
await txHashPromise,
|
await txHashPromise,
|
||||||
pollingIntervalMs,
|
opts.pollingIntervalMs,
|
||||||
timeoutMs,
|
opts.timeoutMs,
|
||||||
);
|
);
|
||||||
})(),
|
})(),
|
||||||
);
|
);
|
||||||
@ -226,15 +207,6 @@ export class WETH9Contract extends BaseContract {
|
|||||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
return gas;
|
return gas;
|
||||||
},
|
},
|
||||||
async validateAndSendTransactionAsync(
|
|
||||||
guy: string,
|
|
||||||
wad: BigNumber,
|
|
||||||
txData?: Partial<TxData> | undefined,
|
|
||||||
): Promise<string> {
|
|
||||||
await (this as any).approve.callAsync(guy, wad, txData);
|
|
||||||
const txHash = await (this as any).approve.sendTransactionAsync(guy, wad, txData);
|
|
||||||
return txHash;
|
|
||||||
},
|
|
||||||
/**
|
/**
|
||||||
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
|
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
|
||||||
* Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas
|
* Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas
|
||||||
@ -299,30 +271,6 @@ export class WETH9Contract extends BaseContract {
|
|||||||
]);
|
]);
|
||||||
return abiEncodedTransactionData;
|
return abiEncodedTransactionData;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): string {
|
|
||||||
const self = (this as any) as WETH9Contract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('approve(address,uint256)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<string>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): boolean {
|
|
||||||
const self = (this as any) as WETH9Contract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('approve(address,uint256)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<boolean>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
public totalSupply = {
|
public totalSupply = {
|
||||||
/**
|
/**
|
||||||
@ -366,41 +314,6 @@ export class WETH9Contract extends BaseContract {
|
|||||||
// tslint:enable boolean-naming
|
// tslint:enable boolean-naming
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
|
||||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
|
||||||
* to create a 0x transaction (see protocol spec for more details).
|
|
||||||
* @returns The ABI encoded transaction data as a string
|
|
||||||
*/
|
|
||||||
getABIEncodedTransactionData(): string {
|
|
||||||
const self = (this as any) as WETH9Contract;
|
|
||||||
const abiEncodedTransactionData = self._strictEncodeArguments('totalSupply()', []);
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): void {
|
|
||||||
const self = (this as any) as WETH9Contract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('totalSupply()');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<void>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): BigNumber {
|
|
||||||
const self = (this as any) as WETH9Contract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('totalSupply()');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<BigNumber>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
public transferFrom = {
|
public transferFrom = {
|
||||||
/**
|
/**
|
||||||
@ -414,6 +327,7 @@ export class WETH9Contract extends BaseContract {
|
|||||||
dst: string,
|
dst: string,
|
||||||
wad: BigNumber,
|
wad: BigNumber,
|
||||||
txData?: Partial<TxData> | undefined,
|
txData?: Partial<TxData> | undefined,
|
||||||
|
opts: SendTransactionOpts = { shouldValidate: true },
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
assert.isString('src', src);
|
assert.isString('src', src);
|
||||||
assert.isString('dst', dst);
|
assert.isString('dst', dst);
|
||||||
@ -436,6 +350,10 @@ export class WETH9Contract extends BaseContract {
|
|||||||
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
|
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opts.shouldValidate !== false) {
|
||||||
|
await self.transferFrom.callAsync(src, dst, wad, txDataWithDefaults);
|
||||||
|
}
|
||||||
|
|
||||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
return txHash;
|
return txHash;
|
||||||
},
|
},
|
||||||
@ -451,8 +369,7 @@ export class WETH9Contract extends BaseContract {
|
|||||||
dst: string,
|
dst: string,
|
||||||
wad: BigNumber,
|
wad: BigNumber,
|
||||||
txData?: Partial<TxData>,
|
txData?: Partial<TxData>,
|
||||||
pollingIntervalMs?: number,
|
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
|
||||||
timeoutMs?: number,
|
|
||||||
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
||||||
assert.isString('src', src);
|
assert.isString('src', src);
|
||||||
assert.isString('dst', dst);
|
assert.isString('dst', dst);
|
||||||
@ -463,6 +380,7 @@ export class WETH9Contract extends BaseContract {
|
|||||||
dst.toLowerCase(),
|
dst.toLowerCase(),
|
||||||
wad,
|
wad,
|
||||||
txData,
|
txData,
|
||||||
|
opts,
|
||||||
);
|
);
|
||||||
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
||||||
txHashPromise,
|
txHashPromise,
|
||||||
@ -470,8 +388,8 @@ export class WETH9Contract extends BaseContract {
|
|||||||
// When the transaction hash resolves, wait for it to be mined.
|
// When the transaction hash resolves, wait for it to be mined.
|
||||||
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
await txHashPromise,
|
await txHashPromise,
|
||||||
pollingIntervalMs,
|
opts.pollingIntervalMs,
|
||||||
timeoutMs,
|
opts.timeoutMs,
|
||||||
);
|
);
|
||||||
})(),
|
})(),
|
||||||
);
|
);
|
||||||
@ -511,16 +429,6 @@ export class WETH9Contract extends BaseContract {
|
|||||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
return gas;
|
return gas;
|
||||||
},
|
},
|
||||||
async validateAndSendTransactionAsync(
|
|
||||||
src: string,
|
|
||||||
dst: string,
|
|
||||||
wad: BigNumber,
|
|
||||||
txData?: Partial<TxData> | undefined,
|
|
||||||
): Promise<string> {
|
|
||||||
await (this as any).transferFrom.callAsync(src, dst, wad, txData);
|
|
||||||
const txHash = await (this as any).transferFrom.sendTransactionAsync(src, dst, wad, txData);
|
|
||||||
return txHash;
|
|
||||||
},
|
|
||||||
/**
|
/**
|
||||||
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
|
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
|
||||||
* Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas
|
* Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas
|
||||||
@ -593,30 +501,6 @@ export class WETH9Contract extends BaseContract {
|
|||||||
]);
|
]);
|
||||||
return abiEncodedTransactionData;
|
return abiEncodedTransactionData;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): string {
|
|
||||||
const self = (this as any) as WETH9Contract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('transferFrom(address,address,uint256)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<string>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): boolean {
|
|
||||||
const self = (this as any) as WETH9Contract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('transferFrom(address,address,uint256)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<boolean>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
public withdraw = {
|
public withdraw = {
|
||||||
/**
|
/**
|
||||||
@ -625,7 +509,11 @@ export class WETH9Contract extends BaseContract {
|
|||||||
* @param txData Additional data for transaction
|
* @param txData Additional data for transaction
|
||||||
* @returns The hash of the transaction
|
* @returns The hash of the transaction
|
||||||
*/
|
*/
|
||||||
async sendTransactionAsync(wad: BigNumber, txData?: Partial<TxData> | undefined): Promise<string> {
|
async sendTransactionAsync(
|
||||||
|
wad: BigNumber,
|
||||||
|
txData?: Partial<TxData> | undefined,
|
||||||
|
opts: SendTransactionOpts = { shouldValidate: true },
|
||||||
|
): Promise<string> {
|
||||||
assert.isBigNumber('wad', wad);
|
assert.isBigNumber('wad', wad);
|
||||||
const self = (this as any) as WETH9Contract;
|
const self = (this as any) as WETH9Contract;
|
||||||
const encodedData = self._strictEncodeArguments('withdraw(uint256)', [wad]);
|
const encodedData = self._strictEncodeArguments('withdraw(uint256)', [wad]);
|
||||||
@ -641,6 +529,10 @@ export class WETH9Contract extends BaseContract {
|
|||||||
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
|
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opts.shouldValidate !== false) {
|
||||||
|
await self.withdraw.callAsync(wad, txDataWithDefaults);
|
||||||
|
}
|
||||||
|
|
||||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
return txHash;
|
return txHash;
|
||||||
},
|
},
|
||||||
@ -654,20 +546,19 @@ export class WETH9Contract extends BaseContract {
|
|||||||
awaitTransactionSuccessAsync(
|
awaitTransactionSuccessAsync(
|
||||||
wad: BigNumber,
|
wad: BigNumber,
|
||||||
txData?: Partial<TxData>,
|
txData?: Partial<TxData>,
|
||||||
pollingIntervalMs?: number,
|
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
|
||||||
timeoutMs?: number,
|
|
||||||
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
||||||
assert.isBigNumber('wad', wad);
|
assert.isBigNumber('wad', wad);
|
||||||
const self = (this as any) as WETH9Contract;
|
const self = (this as any) as WETH9Contract;
|
||||||
const txHashPromise = self.withdraw.sendTransactionAsync(wad, txData);
|
const txHashPromise = self.withdraw.sendTransactionAsync(wad, txData, opts);
|
||||||
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
||||||
txHashPromise,
|
txHashPromise,
|
||||||
(async (): Promise<TransactionReceiptWithDecodedLogs> => {
|
(async (): Promise<TransactionReceiptWithDecodedLogs> => {
|
||||||
// When the transaction hash resolves, wait for it to be mined.
|
// When the transaction hash resolves, wait for it to be mined.
|
||||||
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
await txHashPromise,
|
await txHashPromise,
|
||||||
pollingIntervalMs,
|
opts.pollingIntervalMs,
|
||||||
timeoutMs,
|
opts.timeoutMs,
|
||||||
);
|
);
|
||||||
})(),
|
})(),
|
||||||
);
|
);
|
||||||
@ -696,11 +587,6 @@ export class WETH9Contract extends BaseContract {
|
|||||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
return gas;
|
return gas;
|
||||||
},
|
},
|
||||||
async validateAndSendTransactionAsync(wad: BigNumber, txData?: Partial<TxData> | undefined): Promise<string> {
|
|
||||||
await (this as any).withdraw.callAsync(wad, txData);
|
|
||||||
const txHash = await (this as any).withdraw.sendTransactionAsync(wad, txData);
|
|
||||||
return txHash;
|
|
||||||
},
|
|
||||||
/**
|
/**
|
||||||
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
|
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
|
||||||
* Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas
|
* Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas
|
||||||
@ -755,30 +641,6 @@ export class WETH9Contract extends BaseContract {
|
|||||||
const abiEncodedTransactionData = self._strictEncodeArguments('withdraw(uint256)', [wad]);
|
const abiEncodedTransactionData = self._strictEncodeArguments('withdraw(uint256)', [wad]);
|
||||||
return abiEncodedTransactionData;
|
return abiEncodedTransactionData;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): [BigNumber] {
|
|
||||||
const self = (this as any) as WETH9Contract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('withdraw(uint256)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<[BigNumber]>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): void {
|
|
||||||
const self = (this as any) as WETH9Contract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('withdraw(uint256)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<void>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
public decimals = {
|
public decimals = {
|
||||||
/**
|
/**
|
||||||
@ -822,41 +684,6 @@ export class WETH9Contract extends BaseContract {
|
|||||||
// tslint:enable boolean-naming
|
// tslint:enable boolean-naming
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
|
||||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
|
||||||
* to create a 0x transaction (see protocol spec for more details).
|
|
||||||
* @returns The ABI encoded transaction data as a string
|
|
||||||
*/
|
|
||||||
getABIEncodedTransactionData(): string {
|
|
||||||
const self = (this as any) as WETH9Contract;
|
|
||||||
const abiEncodedTransactionData = self._strictEncodeArguments('decimals()', []);
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): void {
|
|
||||||
const self = (this as any) as WETH9Contract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('decimals()');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<void>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): number {
|
|
||||||
const self = (this as any) as WETH9Contract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('decimals()');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<number>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
public balanceOf = {
|
public balanceOf = {
|
||||||
/**
|
/**
|
||||||
@ -905,44 +732,6 @@ export class WETH9Contract extends BaseContract {
|
|||||||
// tslint:enable boolean-naming
|
// tslint:enable boolean-naming
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
|
||||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
|
||||||
* to create a 0x transaction (see protocol spec for more details).
|
|
||||||
* @returns The ABI encoded transaction data as a string
|
|
||||||
*/
|
|
||||||
getABIEncodedTransactionData(index_0: string): string {
|
|
||||||
assert.isString('index_0', index_0);
|
|
||||||
const self = (this as any) as WETH9Contract;
|
|
||||||
const abiEncodedTransactionData = self._strictEncodeArguments('balanceOf(address)', [
|
|
||||||
index_0.toLowerCase(),
|
|
||||||
]);
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): string {
|
|
||||||
const self = (this as any) as WETH9Contract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('balanceOf(address)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<string>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): BigNumber {
|
|
||||||
const self = (this as any) as WETH9Contract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('balanceOf(address)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<BigNumber>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
public symbol = {
|
public symbol = {
|
||||||
/**
|
/**
|
||||||
@ -986,41 +775,6 @@ export class WETH9Contract extends BaseContract {
|
|||||||
// tslint:enable boolean-naming
|
// tslint:enable boolean-naming
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
|
||||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
|
||||||
* to create a 0x transaction (see protocol spec for more details).
|
|
||||||
* @returns The ABI encoded transaction data as a string
|
|
||||||
*/
|
|
||||||
getABIEncodedTransactionData(): string {
|
|
||||||
const self = (this as any) as WETH9Contract;
|
|
||||||
const abiEncodedTransactionData = self._strictEncodeArguments('symbol()', []);
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): void {
|
|
||||||
const self = (this as any) as WETH9Contract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('symbol()');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<void>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): string {
|
|
||||||
const self = (this as any) as WETH9Contract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('symbol()');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<string>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
public transfer = {
|
public transfer = {
|
||||||
/**
|
/**
|
||||||
@ -1029,7 +783,12 @@ export class WETH9Contract extends BaseContract {
|
|||||||
* @param txData Additional data for transaction
|
* @param txData Additional data for transaction
|
||||||
* @returns The hash of the transaction
|
* @returns The hash of the transaction
|
||||||
*/
|
*/
|
||||||
async sendTransactionAsync(dst: string, wad: BigNumber, txData?: Partial<TxData> | undefined): Promise<string> {
|
async sendTransactionAsync(
|
||||||
|
dst: string,
|
||||||
|
wad: BigNumber,
|
||||||
|
txData?: Partial<TxData> | undefined,
|
||||||
|
opts: SendTransactionOpts = { shouldValidate: true },
|
||||||
|
): Promise<string> {
|
||||||
assert.isString('dst', dst);
|
assert.isString('dst', dst);
|
||||||
assert.isBigNumber('wad', wad);
|
assert.isBigNumber('wad', wad);
|
||||||
const self = (this as any) as WETH9Contract;
|
const self = (this as any) as WETH9Contract;
|
||||||
@ -1046,6 +805,10 @@ export class WETH9Contract extends BaseContract {
|
|||||||
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
|
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opts.shouldValidate !== false) {
|
||||||
|
await self.transfer.callAsync(dst, wad, txDataWithDefaults);
|
||||||
|
}
|
||||||
|
|
||||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
return txHash;
|
return txHash;
|
||||||
},
|
},
|
||||||
@ -1060,21 +823,20 @@ export class WETH9Contract extends BaseContract {
|
|||||||
dst: string,
|
dst: string,
|
||||||
wad: BigNumber,
|
wad: BigNumber,
|
||||||
txData?: Partial<TxData>,
|
txData?: Partial<TxData>,
|
||||||
pollingIntervalMs?: number,
|
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
|
||||||
timeoutMs?: number,
|
|
||||||
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
||||||
assert.isString('dst', dst);
|
assert.isString('dst', dst);
|
||||||
assert.isBigNumber('wad', wad);
|
assert.isBigNumber('wad', wad);
|
||||||
const self = (this as any) as WETH9Contract;
|
const self = (this as any) as WETH9Contract;
|
||||||
const txHashPromise = self.transfer.sendTransactionAsync(dst.toLowerCase(), wad, txData);
|
const txHashPromise = self.transfer.sendTransactionAsync(dst.toLowerCase(), wad, txData, opts);
|
||||||
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
||||||
txHashPromise,
|
txHashPromise,
|
||||||
(async (): Promise<TransactionReceiptWithDecodedLogs> => {
|
(async (): Promise<TransactionReceiptWithDecodedLogs> => {
|
||||||
// When the transaction hash resolves, wait for it to be mined.
|
// When the transaction hash resolves, wait for it to be mined.
|
||||||
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
await txHashPromise,
|
await txHashPromise,
|
||||||
pollingIntervalMs,
|
opts.pollingIntervalMs,
|
||||||
timeoutMs,
|
opts.timeoutMs,
|
||||||
);
|
);
|
||||||
})(),
|
})(),
|
||||||
);
|
);
|
||||||
@ -1104,15 +866,6 @@ export class WETH9Contract extends BaseContract {
|
|||||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
return gas;
|
return gas;
|
||||||
},
|
},
|
||||||
async validateAndSendTransactionAsync(
|
|
||||||
dst: string,
|
|
||||||
wad: BigNumber,
|
|
||||||
txData?: Partial<TxData> | undefined,
|
|
||||||
): Promise<string> {
|
|
||||||
await (this as any).transfer.callAsync(dst, wad, txData);
|
|
||||||
const txHash = await (this as any).transfer.sendTransactionAsync(dst, wad, txData);
|
|
||||||
return txHash;
|
|
||||||
},
|
|
||||||
/**
|
/**
|
||||||
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
|
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
|
||||||
* Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas
|
* Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas
|
||||||
@ -1177,30 +930,6 @@ export class WETH9Contract extends BaseContract {
|
|||||||
]);
|
]);
|
||||||
return abiEncodedTransactionData;
|
return abiEncodedTransactionData;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): string {
|
|
||||||
const self = (this as any) as WETH9Contract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('transfer(address,uint256)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<string>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): boolean {
|
|
||||||
const self = (this as any) as WETH9Contract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('transfer(address,uint256)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<boolean>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
public deposit = {
|
public deposit = {
|
||||||
/**
|
/**
|
||||||
@ -1209,7 +938,10 @@ export class WETH9Contract extends BaseContract {
|
|||||||
* @param txData Additional data for transaction
|
* @param txData Additional data for transaction
|
||||||
* @returns The hash of the transaction
|
* @returns The hash of the transaction
|
||||||
*/
|
*/
|
||||||
async sendTransactionAsync(txData?: Partial<TxData> | undefined): Promise<string> {
|
async sendTransactionAsync(
|
||||||
|
txData?: Partial<TxData> | undefined,
|
||||||
|
opts: SendTransactionOpts = { shouldValidate: true },
|
||||||
|
): Promise<string> {
|
||||||
const self = (this as any) as WETH9Contract;
|
const self = (this as any) as WETH9Contract;
|
||||||
const encodedData = self._strictEncodeArguments('deposit()', []);
|
const encodedData = self._strictEncodeArguments('deposit()', []);
|
||||||
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||||
@ -1224,6 +956,10 @@ export class WETH9Contract extends BaseContract {
|
|||||||
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
|
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opts.shouldValidate !== false) {
|
||||||
|
await self.deposit.callAsync(txDataWithDefaults);
|
||||||
|
}
|
||||||
|
|
||||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
return txHash;
|
return txHash;
|
||||||
},
|
},
|
||||||
@ -1236,19 +972,18 @@ export class WETH9Contract extends BaseContract {
|
|||||||
*/
|
*/
|
||||||
awaitTransactionSuccessAsync(
|
awaitTransactionSuccessAsync(
|
||||||
txData?: Partial<TxData>,
|
txData?: Partial<TxData>,
|
||||||
pollingIntervalMs?: number,
|
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
|
||||||
timeoutMs?: number,
|
|
||||||
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
||||||
const self = (this as any) as WETH9Contract;
|
const self = (this as any) as WETH9Contract;
|
||||||
const txHashPromise = self.deposit.sendTransactionAsync(txData);
|
const txHashPromise = self.deposit.sendTransactionAsync(txData, opts);
|
||||||
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
||||||
txHashPromise,
|
txHashPromise,
|
||||||
(async (): Promise<TransactionReceiptWithDecodedLogs> => {
|
(async (): Promise<TransactionReceiptWithDecodedLogs> => {
|
||||||
// When the transaction hash resolves, wait for it to be mined.
|
// When the transaction hash resolves, wait for it to be mined.
|
||||||
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
await txHashPromise,
|
await txHashPromise,
|
||||||
pollingIntervalMs,
|
opts.pollingIntervalMs,
|
||||||
timeoutMs,
|
opts.timeoutMs,
|
||||||
);
|
);
|
||||||
})(),
|
})(),
|
||||||
);
|
);
|
||||||
@ -1276,11 +1011,6 @@ export class WETH9Contract extends BaseContract {
|
|||||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
return gas;
|
return gas;
|
||||||
},
|
},
|
||||||
async validateAndSendTransactionAsync(txData?: Partial<TxData> | undefined): Promise<string> {
|
|
||||||
await (this as any).deposit.callAsync(txData);
|
|
||||||
const txHash = await (this as any).deposit.sendTransactionAsync(txData);
|
|
||||||
return txHash;
|
|
||||||
},
|
|
||||||
/**
|
/**
|
||||||
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
|
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
|
||||||
* Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas
|
* Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas
|
||||||
@ -1333,30 +1063,6 @@ export class WETH9Contract extends BaseContract {
|
|||||||
const abiEncodedTransactionData = self._strictEncodeArguments('deposit()', []);
|
const abiEncodedTransactionData = self._strictEncodeArguments('deposit()', []);
|
||||||
return abiEncodedTransactionData;
|
return abiEncodedTransactionData;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): void {
|
|
||||||
const self = (this as any) as WETH9Contract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('deposit()');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<void>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): void {
|
|
||||||
const self = (this as any) as WETH9Contract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('deposit()');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<void>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
public allowance = {
|
public allowance = {
|
||||||
/**
|
/**
|
||||||
@ -1410,46 +1116,6 @@ export class WETH9Contract extends BaseContract {
|
|||||||
// tslint:enable boolean-naming
|
// tslint:enable boolean-naming
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
|
||||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
|
||||||
* to create a 0x transaction (see protocol spec for more details).
|
|
||||||
* @returns The ABI encoded transaction data as a string
|
|
||||||
*/
|
|
||||||
getABIEncodedTransactionData(index_0: string, index_1: string): string {
|
|
||||||
assert.isString('index_0', index_0);
|
|
||||||
assert.isString('index_1', index_1);
|
|
||||||
const self = (this as any) as WETH9Contract;
|
|
||||||
const abiEncodedTransactionData = self._strictEncodeArguments('allowance(address,address)', [
|
|
||||||
index_0.toLowerCase(),
|
|
||||||
index_1.toLowerCase(),
|
|
||||||
]);
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): string {
|
|
||||||
const self = (this as any) as WETH9Contract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('allowance(address,address)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<string>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): BigNumber {
|
|
||||||
const self = (this as any) as WETH9Contract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('allowance(address,address)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<BigNumber>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
private readonly _subscriptionManager: SubscriptionManager<WETH9EventArgs, WETH9Events>;
|
private readonly _subscriptionManager: SubscriptionManager<WETH9EventArgs, WETH9Events>;
|
||||||
public static async deployFrom0xArtifactAsync(
|
public static async deployFrom0xArtifactAsync(
|
||||||
|
@ -19,7 +19,13 @@ import {
|
|||||||
SupportedProvider,
|
SupportedProvider,
|
||||||
} from 'ethereum-types';
|
} from 'ethereum-types';
|
||||||
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
||||||
import { SimpleContractArtifact, EventCallback, IndexedFilterValues } from '@0x/types';
|
import {
|
||||||
|
AwaitTransactionSuccessOpts,
|
||||||
|
EventCallback,
|
||||||
|
IndexedFilterValues,
|
||||||
|
SendTransactionOpts,
|
||||||
|
SimpleContractArtifact,
|
||||||
|
} from '@0x/types';
|
||||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||||
import { assert } from '@0x/assert';
|
import { assert } from '@0x/assert';
|
||||||
import * as ethers from 'ethers';
|
import * as ethers from 'ethers';
|
||||||
@ -48,8 +54,10 @@ export interface ZRXTokenApprovalEventArgs extends DecodedLogArgs {
|
|||||||
// tslint:disable:no-parameter-reassignment
|
// tslint:disable:no-parameter-reassignment
|
||||||
// tslint:disable-next-line:class-name
|
// tslint:disable-next-line:class-name
|
||||||
export class ZRXTokenContract extends BaseContract {
|
export class ZRXTokenContract extends BaseContract {
|
||||||
public static deployedBytecode =
|
/**
|
||||||
'0x606060405236156100965763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde038114610098578063095ea7b31461014657806318160ddd1461018657806323b872dd146101a8578063313ce567146101ee57806370a082311461021457806395d89b411461024f578063a9059cbb146102fd578063dd62ed3e1461033d575bfe5b34156100a057fe5b6100a861037e565b60408051602080825283518183015283519192839290830191850190808383821561010c575b80518252602083111561010c577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016100ce565b505050905090810190601f1680156101385780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561014e57fe5b61017273ffffffffffffffffffffffffffffffffffffffff600435166024356103b5565b604080519115158252519081900360200190f35b341561018e57fe5b61019661042d565b60408051918252519081900360200190f35b34156101b057fe5b61017273ffffffffffffffffffffffffffffffffffffffff60043581169060243516604435610433565b604080519115158252519081900360200190f35b34156101f657fe5b6101fe6105d4565b6040805160ff9092168252519081900360200190f35b341561021c57fe5b61019673ffffffffffffffffffffffffffffffffffffffff600435166105d9565b60408051918252519081900360200190f35b341561025757fe5b6100a8610605565b60408051602080825283518183015283519192839290830191850190808383821561010c575b80518252602083111561010c577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016100ce565b505050905090810190601f1680156101385780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561030557fe5b61017273ffffffffffffffffffffffffffffffffffffffff6004351660243561063c565b604080519115158252519081900360200190f35b341561034557fe5b61019673ffffffffffffffffffffffffffffffffffffffff60043581169060243516610727565b60408051918252519081900360200190f35b60408051808201909152601181527f30782050726f746f636f6c20546f6b656e000000000000000000000000000000602082015281565b73ffffffffffffffffffffffffffffffffffffffff338116600081815260016020908152604080832094871680845294825280832086905580518681529051929493927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060015b92915050565b60035481565b73ffffffffffffffffffffffffffffffffffffffff808416600081815260016020908152604080832033909516835293815283822054928252819052918220548390108015906104835750828110155b80156104b6575073ffffffffffffffffffffffffffffffffffffffff841660009081526020819052604090205483810110155b156105c65773ffffffffffffffffffffffffffffffffffffffff808516600090815260208190526040808220805487019055918716815220805484900390557fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8110156105585773ffffffffffffffffffffffffffffffffffffffff808616600090815260016020908152604080832033909416835292905220805484900390555b8373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3600191506105cb565b600091505b5b509392505050565b601281565b73ffffffffffffffffffffffffffffffffffffffff81166000908152602081905260409020545b919050565b60408051808201909152600381527f5a52580000000000000000000000000000000000000000000000000000000000602082015281565b73ffffffffffffffffffffffffffffffffffffffff3316600090815260208190526040812054829010801590610699575073ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604090205482810110155b156107185773ffffffffffffffffffffffffffffffffffffffff33811660008181526020818152604080832080548890039055938716808352918490208054870190558351868152935191937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929081900390910190a3506001610427565b506000610427565b5b92915050565b73ffffffffffffffffffffffffffffffffffffffff8083166000908152600160209081526040808320938516835292905220545b929150505600a165627a7a72305820d984298155c708a8164f1cbf83c7275bcc6851dd082c0404013c1f4463b238fa0029';
|
* @ignore
|
||||||
|
*/
|
||||||
|
public static deployedBytecode: string | undefined;
|
||||||
public name = {
|
public name = {
|
||||||
/**
|
/**
|
||||||
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
|
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
|
||||||
@ -92,41 +100,6 @@ export class ZRXTokenContract extends BaseContract {
|
|||||||
// tslint:enable boolean-naming
|
// tslint:enable boolean-naming
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
|
||||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
|
||||||
* to create a 0x transaction (see protocol spec for more details).
|
|
||||||
* @returns The ABI encoded transaction data as a string
|
|
||||||
*/
|
|
||||||
getABIEncodedTransactionData(): string {
|
|
||||||
const self = (this as any) as ZRXTokenContract;
|
|
||||||
const abiEncodedTransactionData = self._strictEncodeArguments('name()', []);
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): void {
|
|
||||||
const self = (this as any) as ZRXTokenContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('name()');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<void>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): string {
|
|
||||||
const self = (this as any) as ZRXTokenContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('name()');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<string>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
public approve = {
|
public approve = {
|
||||||
/**
|
/**
|
||||||
@ -139,6 +112,7 @@ export class ZRXTokenContract extends BaseContract {
|
|||||||
_spender: string,
|
_spender: string,
|
||||||
_value: BigNumber,
|
_value: BigNumber,
|
||||||
txData?: Partial<TxData> | undefined,
|
txData?: Partial<TxData> | undefined,
|
||||||
|
opts: SendTransactionOpts = { shouldValidate: true },
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
assert.isString('_spender', _spender);
|
assert.isString('_spender', _spender);
|
||||||
assert.isBigNumber('_value', _value);
|
assert.isBigNumber('_value', _value);
|
||||||
@ -159,6 +133,10 @@ export class ZRXTokenContract extends BaseContract {
|
|||||||
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
|
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opts.shouldValidate !== false) {
|
||||||
|
await self.approve.callAsync(_spender, _value, txDataWithDefaults);
|
||||||
|
}
|
||||||
|
|
||||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
return txHash;
|
return txHash;
|
||||||
},
|
},
|
||||||
@ -173,21 +151,20 @@ export class ZRXTokenContract extends BaseContract {
|
|||||||
_spender: string,
|
_spender: string,
|
||||||
_value: BigNumber,
|
_value: BigNumber,
|
||||||
txData?: Partial<TxData>,
|
txData?: Partial<TxData>,
|
||||||
pollingIntervalMs?: number,
|
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
|
||||||
timeoutMs?: number,
|
|
||||||
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
||||||
assert.isString('_spender', _spender);
|
assert.isString('_spender', _spender);
|
||||||
assert.isBigNumber('_value', _value);
|
assert.isBigNumber('_value', _value);
|
||||||
const self = (this as any) as ZRXTokenContract;
|
const self = (this as any) as ZRXTokenContract;
|
||||||
const txHashPromise = self.approve.sendTransactionAsync(_spender.toLowerCase(), _value, txData);
|
const txHashPromise = self.approve.sendTransactionAsync(_spender.toLowerCase(), _value, txData, opts);
|
||||||
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
||||||
txHashPromise,
|
txHashPromise,
|
||||||
(async (): Promise<TransactionReceiptWithDecodedLogs> => {
|
(async (): Promise<TransactionReceiptWithDecodedLogs> => {
|
||||||
// When the transaction hash resolves, wait for it to be mined.
|
// When the transaction hash resolves, wait for it to be mined.
|
||||||
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
await txHashPromise,
|
await txHashPromise,
|
||||||
pollingIntervalMs,
|
opts.pollingIntervalMs,
|
||||||
timeoutMs,
|
opts.timeoutMs,
|
||||||
);
|
);
|
||||||
})(),
|
})(),
|
||||||
);
|
);
|
||||||
@ -224,15 +201,6 @@ export class ZRXTokenContract extends BaseContract {
|
|||||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
return gas;
|
return gas;
|
||||||
},
|
},
|
||||||
async validateAndSendTransactionAsync(
|
|
||||||
_spender: string,
|
|
||||||
_value: BigNumber,
|
|
||||||
txData?: Partial<TxData> | undefined,
|
|
||||||
): Promise<string> {
|
|
||||||
await (this as any).approve.callAsync(_spender, _value, txData);
|
|
||||||
const txHash = await (this as any).approve.sendTransactionAsync(_spender, _value, txData);
|
|
||||||
return txHash;
|
|
||||||
},
|
|
||||||
/**
|
/**
|
||||||
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
|
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
|
||||||
* Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas
|
* Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas
|
||||||
@ -300,30 +268,6 @@ export class ZRXTokenContract extends BaseContract {
|
|||||||
]);
|
]);
|
||||||
return abiEncodedTransactionData;
|
return abiEncodedTransactionData;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): string {
|
|
||||||
const self = (this as any) as ZRXTokenContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('approve(address,uint256)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<string>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): boolean {
|
|
||||||
const self = (this as any) as ZRXTokenContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('approve(address,uint256)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<boolean>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
public totalSupply = {
|
public totalSupply = {
|
||||||
/**
|
/**
|
||||||
@ -367,41 +311,6 @@ export class ZRXTokenContract extends BaseContract {
|
|||||||
// tslint:enable boolean-naming
|
// tslint:enable boolean-naming
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
|
||||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
|
||||||
* to create a 0x transaction (see protocol spec for more details).
|
|
||||||
* @returns The ABI encoded transaction data as a string
|
|
||||||
*/
|
|
||||||
getABIEncodedTransactionData(): string {
|
|
||||||
const self = (this as any) as ZRXTokenContract;
|
|
||||||
const abiEncodedTransactionData = self._strictEncodeArguments('totalSupply()', []);
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): void {
|
|
||||||
const self = (this as any) as ZRXTokenContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('totalSupply()');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<void>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): BigNumber {
|
|
||||||
const self = (this as any) as ZRXTokenContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('totalSupply()');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<BigNumber>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* ERC20 transferFrom, modified such that an allowance of MAX_UINT represents an unlimited allowance.
|
* ERC20 transferFrom, modified such that an allowance of MAX_UINT represents an unlimited allowance.
|
||||||
@ -421,6 +330,7 @@ export class ZRXTokenContract extends BaseContract {
|
|||||||
_to: string,
|
_to: string,
|
||||||
_value: BigNumber,
|
_value: BigNumber,
|
||||||
txData?: Partial<TxData> | undefined,
|
txData?: Partial<TxData> | undefined,
|
||||||
|
opts: SendTransactionOpts = { shouldValidate: true },
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
assert.isString('_from', _from);
|
assert.isString('_from', _from);
|
||||||
assert.isString('_to', _to);
|
assert.isString('_to', _to);
|
||||||
@ -443,6 +353,10 @@ export class ZRXTokenContract extends BaseContract {
|
|||||||
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
|
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opts.shouldValidate !== false) {
|
||||||
|
await self.transferFrom.callAsync(_from, _to, _value, txDataWithDefaults);
|
||||||
|
}
|
||||||
|
|
||||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
return txHash;
|
return txHash;
|
||||||
},
|
},
|
||||||
@ -461,8 +375,7 @@ export class ZRXTokenContract extends BaseContract {
|
|||||||
_to: string,
|
_to: string,
|
||||||
_value: BigNumber,
|
_value: BigNumber,
|
||||||
txData?: Partial<TxData>,
|
txData?: Partial<TxData>,
|
||||||
pollingIntervalMs?: number,
|
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
|
||||||
timeoutMs?: number,
|
|
||||||
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
||||||
assert.isString('_from', _from);
|
assert.isString('_from', _from);
|
||||||
assert.isString('_to', _to);
|
assert.isString('_to', _to);
|
||||||
@ -473,6 +386,7 @@ export class ZRXTokenContract extends BaseContract {
|
|||||||
_to.toLowerCase(),
|
_to.toLowerCase(),
|
||||||
_value,
|
_value,
|
||||||
txData,
|
txData,
|
||||||
|
opts,
|
||||||
);
|
);
|
||||||
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
||||||
txHashPromise,
|
txHashPromise,
|
||||||
@ -480,8 +394,8 @@ export class ZRXTokenContract extends BaseContract {
|
|||||||
// When the transaction hash resolves, wait for it to be mined.
|
// When the transaction hash resolves, wait for it to be mined.
|
||||||
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
await txHashPromise,
|
await txHashPromise,
|
||||||
pollingIntervalMs,
|
opts.pollingIntervalMs,
|
||||||
timeoutMs,
|
opts.timeoutMs,
|
||||||
);
|
);
|
||||||
})(),
|
})(),
|
||||||
);
|
);
|
||||||
@ -524,16 +438,6 @@ export class ZRXTokenContract extends BaseContract {
|
|||||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
return gas;
|
return gas;
|
||||||
},
|
},
|
||||||
async validateAndSendTransactionAsync(
|
|
||||||
_from: string,
|
|
||||||
_to: string,
|
|
||||||
_value: BigNumber,
|
|
||||||
txData?: Partial<TxData> | undefined,
|
|
||||||
): Promise<string> {
|
|
||||||
await (this as any).transferFrom.callAsync(_from, _to, _value, txData);
|
|
||||||
const txHash = await (this as any).transferFrom.sendTransactionAsync(_from, _to, _value, txData);
|
|
||||||
return txHash;
|
|
||||||
},
|
|
||||||
/**
|
/**
|
||||||
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
|
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
|
||||||
* Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas
|
* Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas
|
||||||
@ -613,30 +517,6 @@ export class ZRXTokenContract extends BaseContract {
|
|||||||
]);
|
]);
|
||||||
return abiEncodedTransactionData;
|
return abiEncodedTransactionData;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): string {
|
|
||||||
const self = (this as any) as ZRXTokenContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('transferFrom(address,address,uint256)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<string>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): boolean {
|
|
||||||
const self = (this as any) as ZRXTokenContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('transferFrom(address,address,uint256)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<boolean>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
public decimals = {
|
public decimals = {
|
||||||
/**
|
/**
|
||||||
@ -680,41 +560,6 @@ export class ZRXTokenContract extends BaseContract {
|
|||||||
// tslint:enable boolean-naming
|
// tslint:enable boolean-naming
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
|
||||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
|
||||||
* to create a 0x transaction (see protocol spec for more details).
|
|
||||||
* @returns The ABI encoded transaction data as a string
|
|
||||||
*/
|
|
||||||
getABIEncodedTransactionData(): string {
|
|
||||||
const self = (this as any) as ZRXTokenContract;
|
|
||||||
const abiEncodedTransactionData = self._strictEncodeArguments('decimals()', []);
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): void {
|
|
||||||
const self = (this as any) as ZRXTokenContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('decimals()');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<void>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): number {
|
|
||||||
const self = (this as any) as ZRXTokenContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('decimals()');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<number>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
public balanceOf = {
|
public balanceOf = {
|
||||||
/**
|
/**
|
||||||
@ -763,42 +608,6 @@ export class ZRXTokenContract extends BaseContract {
|
|||||||
// tslint:enable boolean-naming
|
// tslint:enable boolean-naming
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
|
||||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
|
||||||
* to create a 0x transaction (see protocol spec for more details).
|
|
||||||
* @returns The ABI encoded transaction data as a string
|
|
||||||
*/
|
|
||||||
getABIEncodedTransactionData(_owner: string): string {
|
|
||||||
assert.isString('_owner', _owner);
|
|
||||||
const self = (this as any) as ZRXTokenContract;
|
|
||||||
const abiEncodedTransactionData = self._strictEncodeArguments('balanceOf(address)', [_owner.toLowerCase()]);
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): string {
|
|
||||||
const self = (this as any) as ZRXTokenContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('balanceOf(address)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<string>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): BigNumber {
|
|
||||||
const self = (this as any) as ZRXTokenContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('balanceOf(address)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<BigNumber>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
public symbol = {
|
public symbol = {
|
||||||
/**
|
/**
|
||||||
@ -842,41 +651,6 @@ export class ZRXTokenContract extends BaseContract {
|
|||||||
// tslint:enable boolean-naming
|
// tslint:enable boolean-naming
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
|
||||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
|
||||||
* to create a 0x transaction (see protocol spec for more details).
|
|
||||||
* @returns The ABI encoded transaction data as a string
|
|
||||||
*/
|
|
||||||
getABIEncodedTransactionData(): string {
|
|
||||||
const self = (this as any) as ZRXTokenContract;
|
|
||||||
const abiEncodedTransactionData = self._strictEncodeArguments('symbol()', []);
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): void {
|
|
||||||
const self = (this as any) as ZRXTokenContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('symbol()');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<void>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): string {
|
|
||||||
const self = (this as any) as ZRXTokenContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('symbol()');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<string>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
public transfer = {
|
public transfer = {
|
||||||
/**
|
/**
|
||||||
@ -889,6 +663,7 @@ export class ZRXTokenContract extends BaseContract {
|
|||||||
_to: string,
|
_to: string,
|
||||||
_value: BigNumber,
|
_value: BigNumber,
|
||||||
txData?: Partial<TxData> | undefined,
|
txData?: Partial<TxData> | undefined,
|
||||||
|
opts: SendTransactionOpts = { shouldValidate: true },
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
assert.isString('_to', _to);
|
assert.isString('_to', _to);
|
||||||
assert.isBigNumber('_value', _value);
|
assert.isBigNumber('_value', _value);
|
||||||
@ -906,6 +681,10 @@ export class ZRXTokenContract extends BaseContract {
|
|||||||
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
|
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opts.shouldValidate !== false) {
|
||||||
|
await self.transfer.callAsync(_to, _value, txDataWithDefaults);
|
||||||
|
}
|
||||||
|
|
||||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
return txHash;
|
return txHash;
|
||||||
},
|
},
|
||||||
@ -920,21 +699,20 @@ export class ZRXTokenContract extends BaseContract {
|
|||||||
_to: string,
|
_to: string,
|
||||||
_value: BigNumber,
|
_value: BigNumber,
|
||||||
txData?: Partial<TxData>,
|
txData?: Partial<TxData>,
|
||||||
pollingIntervalMs?: number,
|
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
|
||||||
timeoutMs?: number,
|
|
||||||
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
||||||
assert.isString('_to', _to);
|
assert.isString('_to', _to);
|
||||||
assert.isBigNumber('_value', _value);
|
assert.isBigNumber('_value', _value);
|
||||||
const self = (this as any) as ZRXTokenContract;
|
const self = (this as any) as ZRXTokenContract;
|
||||||
const txHashPromise = self.transfer.sendTransactionAsync(_to.toLowerCase(), _value, txData);
|
const txHashPromise = self.transfer.sendTransactionAsync(_to.toLowerCase(), _value, txData, opts);
|
||||||
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
||||||
txHashPromise,
|
txHashPromise,
|
||||||
(async (): Promise<TransactionReceiptWithDecodedLogs> => {
|
(async (): Promise<TransactionReceiptWithDecodedLogs> => {
|
||||||
// When the transaction hash resolves, wait for it to be mined.
|
// When the transaction hash resolves, wait for it to be mined.
|
||||||
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
await txHashPromise,
|
await txHashPromise,
|
||||||
pollingIntervalMs,
|
opts.pollingIntervalMs,
|
||||||
timeoutMs,
|
opts.timeoutMs,
|
||||||
);
|
);
|
||||||
})(),
|
})(),
|
||||||
);
|
);
|
||||||
@ -964,15 +742,6 @@ export class ZRXTokenContract extends BaseContract {
|
|||||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
return gas;
|
return gas;
|
||||||
},
|
},
|
||||||
async validateAndSendTransactionAsync(
|
|
||||||
_to: string,
|
|
||||||
_value: BigNumber,
|
|
||||||
txData?: Partial<TxData> | undefined,
|
|
||||||
): Promise<string> {
|
|
||||||
await (this as any).transfer.callAsync(_to, _value, txData);
|
|
||||||
const txHash = await (this as any).transfer.sendTransactionAsync(_to, _value, txData);
|
|
||||||
return txHash;
|
|
||||||
},
|
|
||||||
/**
|
/**
|
||||||
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
|
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
|
||||||
* Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas
|
* Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas
|
||||||
@ -1037,30 +806,6 @@ export class ZRXTokenContract extends BaseContract {
|
|||||||
]);
|
]);
|
||||||
return abiEncodedTransactionData;
|
return abiEncodedTransactionData;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): string {
|
|
||||||
const self = (this as any) as ZRXTokenContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('transfer(address,uint256)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<string>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): boolean {
|
|
||||||
const self = (this as any) as ZRXTokenContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('transfer(address,uint256)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<boolean>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
public allowance = {
|
public allowance = {
|
||||||
/**
|
/**
|
||||||
@ -1114,46 +859,6 @@ export class ZRXTokenContract extends BaseContract {
|
|||||||
// tslint:enable boolean-naming
|
// tslint:enable boolean-naming
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
|
||||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
|
||||||
* to create a 0x transaction (see protocol spec for more details).
|
|
||||||
* @returns The ABI encoded transaction data as a string
|
|
||||||
*/
|
|
||||||
getABIEncodedTransactionData(_owner: string, _spender: string): string {
|
|
||||||
assert.isString('_owner', _owner);
|
|
||||||
assert.isString('_spender', _spender);
|
|
||||||
const self = (this as any) as ZRXTokenContract;
|
|
||||||
const abiEncodedTransactionData = self._strictEncodeArguments('allowance(address,address)', [
|
|
||||||
_owner.toLowerCase(),
|
|
||||||
_spender.toLowerCase(),
|
|
||||||
]);
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded transaction data into its input arguments
|
|
||||||
* @param callData The ABI-encoded transaction data
|
|
||||||
* @returns An array representing the input arguments in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedTransactionData(callData: string): string {
|
|
||||||
const self = (this as any) as ZRXTokenContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('allowance(address,address)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedCallData = abiEncoder.strictDecode<string>(callData);
|
|
||||||
return abiDecodedCallData;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Decode the ABI-encoded return data from a transaction
|
|
||||||
* @param returnData the data returned after transaction execution
|
|
||||||
* @returns An array representing the output results in order. Keynames of nested structs are preserved.
|
|
||||||
*/
|
|
||||||
getABIDecodedReturnData(returnData: string): BigNumber {
|
|
||||||
const self = (this as any) as ZRXTokenContract;
|
|
||||||
const abiEncoder = self._lookupAbiEncoder('allowance(address,address)');
|
|
||||||
// tslint:disable boolean-naming
|
|
||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<BigNumber>(returnData);
|
|
||||||
return abiDecodedReturnData;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
private readonly _subscriptionManager: SubscriptionManager<ZRXTokenEventArgs, ZRXTokenEvents>;
|
private readonly _subscriptionManager: SubscriptionManager<ZRXTokenEventArgs, ZRXTokenEvents>;
|
||||||
public static async deployFrom0xArtifactAsync(
|
public static async deployFrom0xArtifactAsync(
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
"watch:sol": "sol-compiler -w",
|
"watch:sol": "sol-compiler -w",
|
||||||
"prettier_contract_wrappers": "prettier --write ./test-cli/output/typescript/* --config ../../.prettierrc",
|
"prettier_contract_wrappers": "prettier --write ./test-cli/output/typescript/* --config ../../.prettierrc",
|
||||||
"generate_contract_wrappers": "run-p gen_typescript gen_python",
|
"generate_contract_wrappers": "run-p gen_typescript gen_python",
|
||||||
"gen_typescript": "abi-gen --abis ${npm_package_config_abis} --output ./test-cli/output/typescript --backend ethers",
|
"gen_typescript": "abi-gen --abis ${npm_package_config_abis} --debug --output ./test-cli/output/typescript --backend ethers",
|
||||||
"gen_python": "pip install black && abi-gen --abis ${npm_package_config_abis} --output ./test-cli/output/python --language Python",
|
"gen_python": "pip install black && abi-gen --abis ${npm_package_config_abis} --output ./test-cli/output/python --language Python",
|
||||||
"diff_contract_wrappers": "git diff --exit-code ./test-cli/output",
|
"diff_contract_wrappers": "git diff --exit-code ./test-cli/output",
|
||||||
"coverage:report:text": "istanbul report text",
|
"coverage:report:text": "istanbul report text",
|
||||||
@ -79,9 +79,11 @@
|
|||||||
"yargs": "^10.0.3"
|
"yargs": "^10.0.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@0x/assert": "^2.2.0-beta.0",
|
||||||
"@0x/base-contract": "^5.5.0-beta.0",
|
"@0x/base-contract": "^5.5.0-beta.0",
|
||||||
"@0x/contracts-gen": "^1.1.0-beta.0",
|
"@0x/contracts-gen": "^1.1.0-beta.0",
|
||||||
"@0x/dev-utils": "^2.4.0-beta.0",
|
"@0x/dev-utils": "^2.4.0-beta.0",
|
||||||
|
"@0x/json-schemas": "^4.1.0-beta.0",
|
||||||
"@0x/sol-compiler": "^3.2.0-beta.0",
|
"@0x/sol-compiler": "^3.2.0-beta.0",
|
||||||
"@0x/subproviders": "^5.1.0-beta.0",
|
"@0x/subproviders": "^5.1.0-beta.0",
|
||||||
"@0x/tslint-config": "^3.0.1",
|
"@0x/tslint-config": "^3.0.1",
|
||||||
@ -96,6 +98,7 @@
|
|||||||
"chai-as-promised": "^7.1.0",
|
"chai-as-promised": "^7.1.0",
|
||||||
"chai-bignumber": "^3.0.0",
|
"chai-bignumber": "^3.0.0",
|
||||||
"dirty-chai": "^2.0.1",
|
"dirty-chai": "^2.0.1",
|
||||||
|
"ethers": "~4.0.4",
|
||||||
"make-promises-safe": "^1.1.0",
|
"make-promises-safe": "^1.1.0",
|
||||||
"mocha": "^6.2.0",
|
"mocha": "^6.2.0",
|
||||||
"npm-run-all": "^4.1.2",
|
"npm-run-all": "^4.1.2",
|
||||||
|
@ -44,6 +44,10 @@ const args = yargs
|
|||||||
normalize: true,
|
normalize: true,
|
||||||
demandOption: true,
|
demandOption: true,
|
||||||
})
|
})
|
||||||
|
.option('debug', {
|
||||||
|
describe: 'Includes debug functions in the wrappers such as `getABIDecodedTransactionData`',
|
||||||
|
type: 'boolean',
|
||||||
|
})
|
||||||
.option('partials', {
|
.option('partials', {
|
||||||
describe: 'Glob pattern for the partial template files',
|
describe: 'Glob pattern for the partial template files',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
@ -73,12 +77,11 @@ const args = yargs
|
|||||||
default: 'TypeScript',
|
default: 'TypeScript',
|
||||||
})
|
})
|
||||||
.example(
|
.example(
|
||||||
"$0 --abis 'src/artifacts/**/*.json' --out 'src/contracts/generated/' --partials 'src/templates/partials/**/*.handlebars' --template 'src/templates/contract.handlebars'",
|
"$0 --abis 'src/artifacts/**/*.json' --out 'src/contracts/generated/' --debug --partials 'src/templates/partials/**/*.handlebars' --template 'src/templates/contract.handlebars'",
|
||||||
'Full usage example',
|
'Full usage example',
|
||||||
).argv;
|
).argv;
|
||||||
|
|
||||||
const templateFilename = args.template || `${__dirname}/../../templates/${args.language}/contract.handlebars`;
|
const templateFilename = args.template || `${__dirname}/../../templates/${args.language}/contract.handlebars`;
|
||||||
|
|
||||||
const mainTemplate = utils.getNamedContent(templateFilename);
|
const mainTemplate = utils.getNamedContent(templateFilename);
|
||||||
const template = Handlebars.compile<ContextData>(mainTemplate.content);
|
const template = Handlebars.compile<ContextData>(mainTemplate.content);
|
||||||
const abiFileNames = globSync(args.abis);
|
const abiFileNames = globSync(args.abis);
|
||||||
@ -417,14 +420,17 @@ for (const abiFileName of abiFileNames) {
|
|||||||
return eventData;
|
return eventData;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const shouldIncludeBytecode = methodsData.find(methodData => methodData.stateMutability === 'pure') !== undefined;
|
||||||
|
|
||||||
const contextData = {
|
const contextData = {
|
||||||
contractName: namedContent.name,
|
contractName: namedContent.name,
|
||||||
ctor,
|
ctor,
|
||||||
deployedBytecode,
|
deployedBytecode: shouldIncludeBytecode ? deployedBytecode : undefined,
|
||||||
ABI: ABI as ContractAbi,
|
ABI: ABI as ContractAbi,
|
||||||
ABIString: JSON.stringify(ABI),
|
ABIString: JSON.stringify(ABI),
|
||||||
methods: methodsData,
|
methods: methodsData,
|
||||||
events: eventsData,
|
events: eventsData,
|
||||||
|
debug: args.debug,
|
||||||
};
|
};
|
||||||
const renderedCode = template(contextData);
|
const renderedCode = template(contextData);
|
||||||
utils.writeOutputFile(outFilePath, renderedCode);
|
utils.writeOutputFile(outFilePath, renderedCode);
|
||||||
|
@ -20,7 +20,7 @@ import {
|
|||||||
SupportedProvider,
|
SupportedProvider,
|
||||||
} from 'ethereum-types';
|
} from 'ethereum-types';
|
||||||
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
||||||
import { SimpleContractArtifact, EventCallback, IndexedFilterValues } from '@0x/types';
|
import { AwaitTransactionSuccessOpts, EventCallback, IndexedFilterValues, SendTransactionOpts, SimpleContractArtifact } from '@0x/types';
|
||||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||||
import { assert } from '@0x/assert';
|
import { assert } from '@0x/assert';
|
||||||
import * as ethers from 'ethers';
|
import * as ethers from 'ethers';
|
||||||
@ -48,6 +48,9 @@ export enum {{contractName}}Events {
|
|||||||
// tslint:disable:no-parameter-reassignment
|
// tslint:disable:no-parameter-reassignment
|
||||||
// tslint:disable-next-line:class-name
|
// tslint:disable-next-line:class-name
|
||||||
export class {{contractName}}Contract extends BaseContract {
|
export class {{contractName}}Contract extends BaseContract {
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
{{#ifEquals this.deployedBytecode undefined~}}
|
{{#ifEquals this.deployedBytecode undefined~}}
|
||||||
public static deployedBytecode: string | undefined;
|
public static deployedBytecode: string | undefined;
|
||||||
{{else~}}
|
{{else~}}
|
||||||
@ -69,7 +72,7 @@ export class {{contractName}}Contract extends BaseContract {
|
|||||||
{{else}}
|
{{else}}
|
||||||
{{> method_call contractName=../contractName}}
|
{{> method_call contractName=../contractName}}
|
||||||
{{/ifEquals}}
|
{{/ifEquals}}
|
||||||
{{> method_abi_helper contractName=../contractName}}
|
{{> method_abi_helper contractName=../contractName debug=../debug}}
|
||||||
};
|
};
|
||||||
{{/each}}
|
{{/each}}
|
||||||
{{#if events}}private readonly _subscriptionManager: SubscriptionManager<{{contractName}}EventArgs, {{contractName}}Events>;
|
{{#if events}}private readonly _subscriptionManager: SubscriptionManager<{{contractName}}EventArgs, {{contractName}}Events>;
|
||||||
|
@ -1,3 +1,27 @@
|
|||||||
|
{{!-- if ((NOT constant) AND (NOT debug)), to avoid repetition bbecause we use all 3 functions if (debug) --}}
|
||||||
|
{{^if constant~}}
|
||||||
|
{{^if debug~}}
|
||||||
|
/**
|
||||||
|
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
||||||
|
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
||||||
|
* to create a 0x transaction (see protocol spec for more details).
|
||||||
|
{{> params_docstring inputs=inputs docstrings=devdoc.params}}
|
||||||
|
* @returns The ABI encoded transaction data as a string
|
||||||
|
*/
|
||||||
|
getABIEncodedTransactionData(
|
||||||
|
{{> typed_params inputs=inputs}}
|
||||||
|
): string {
|
||||||
|
{{#each inputs}}
|
||||||
|
{{#assertionType name type}}{{/assertionType}}
|
||||||
|
{{/each}}
|
||||||
|
const self = this as any as {{contractName}}Contract;
|
||||||
|
const abiEncodedTransactionData = self._strictEncodeArguments('{{this.functionSignature}}', [{{> normalized_params inputs=inputs}}]);
|
||||||
|
return abiEncodedTransactionData;
|
||||||
|
},
|
||||||
|
{{/if~}}
|
||||||
|
{{/if~}}
|
||||||
|
|
||||||
|
{{#if debug~}}
|
||||||
/**
|
/**
|
||||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
||||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
||||||
@ -43,3 +67,4 @@ getABIDecodedReturnData(
|
|||||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<{{> return_type outputs=outputs}}>(returnData);
|
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<{{> return_type outputs=outputs}}>(returnData);
|
||||||
return abiDecodedReturnData;
|
return abiDecodedReturnData;
|
||||||
},
|
},
|
||||||
|
{{/if}}
|
||||||
|
@ -29,7 +29,7 @@ async callAsync(
|
|||||||
|
|
||||||
let rawCallResult;
|
let rawCallResult;
|
||||||
try {
|
try {
|
||||||
rawCallResult = await self.evmExecAsync(encodedDataBytes);
|
rawCallResult = await self._evmExecAsync(encodedDataBytes);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
BaseContract._throwIfThrownErrorIsRevertError(err);
|
BaseContract._throwIfThrownErrorIsRevertError(err);
|
||||||
throw err;
|
throw err;
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
async sendTransactionAsync(
|
async sendTransactionAsync(
|
||||||
{{> typed_params inputs=inputs}}
|
{{> typed_params inputs=inputs}}
|
||||||
txData?: Partial<TxData> | undefined,
|
txData?: Partial<TxData> | undefined,
|
||||||
|
opts: SendTransactionOpts = { shouldValidate: true },
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
{{#each inputs}}
|
{{#each inputs}}
|
||||||
{{#assertionType name type}}{{/assertionType}}
|
{{#assertionType name type}}{{/assertionType}}
|
||||||
@ -26,6 +27,15 @@ txData?: Partial<TxData> | undefined,
|
|||||||
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
|
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opts.shouldValidate !== false) {
|
||||||
|
await self.{{languageSpecificName}}.callAsync(
|
||||||
|
{{#each inputs~}}
|
||||||
|
{{name}},
|
||||||
|
{{/each~}}
|
||||||
|
txDataWithDefaults,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||||
return txHash;
|
return txHash;
|
||||||
},
|
},
|
||||||
@ -40,17 +50,16 @@ txData?: Partial<TxData> | undefined,
|
|||||||
awaitTransactionSuccessAsync(
|
awaitTransactionSuccessAsync(
|
||||||
{{> typed_params inputs=inputs}}
|
{{> typed_params inputs=inputs}}
|
||||||
txData?: Partial<TxData>,
|
txData?: Partial<TxData>,
|
||||||
pollingIntervalMs?: number,
|
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
|
||||||
timeoutMs?: number,
|
|
||||||
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
||||||
{{#each inputs}}
|
{{#each inputs}}
|
||||||
{{#assertionType name type}}{{/assertionType}}
|
{{#assertionType name type}}{{/assertionType}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
const self = this as any as {{contractName}}Contract;
|
const self = this as any as {{contractName}}Contract;
|
||||||
{{#if inputs}}
|
{{#if inputs}}
|
||||||
const txHashPromise = self.{{languageSpecificName}}.sendTransactionAsync({{> normalized_params input=inputs}}, txData);
|
const txHashPromise = self.{{languageSpecificName}}.sendTransactionAsync({{> normalized_params input=inputs}}, txData, opts);
|
||||||
{{else}}
|
{{else}}
|
||||||
const txHashPromise = self.{{languageSpecificName}}.sendTransactionAsync(txData);
|
const txHashPromise = self.{{languageSpecificName}}.sendTransactionAsync(txData, opts);
|
||||||
{{/if}}
|
{{/if}}
|
||||||
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
||||||
txHashPromise,
|
txHashPromise,
|
||||||
@ -58,8 +67,8 @@ awaitTransactionSuccessAsync(
|
|||||||
// When the transaction hash resolves, wait for it to be mined.
|
// When the transaction hash resolves, wait for it to be mined.
|
||||||
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
await txHashPromise,
|
await txHashPromise,
|
||||||
pollingIntervalMs,
|
opts.pollingIntervalMs,
|
||||||
timeoutMs,
|
opts.timeoutMs,
|
||||||
);
|
);
|
||||||
})(),
|
})(),
|
||||||
);
|
);
|
||||||
@ -94,21 +103,3 @@ async estimateGasAsync(
|
|||||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||||
return gas;
|
return gas;
|
||||||
},
|
},
|
||||||
async validateAndSendTransactionAsync(
|
|
||||||
{{> typed_params inputs=inputs}}
|
|
||||||
txData?: Partial<TxData> | undefined,
|
|
||||||
): Promise<string> {
|
|
||||||
await (this as any).{{languageSpecificName}}.callAsync(
|
|
||||||
{{#each inputs~}}
|
|
||||||
{{name}},
|
|
||||||
{{/each~}}
|
|
||||||
txData,
|
|
||||||
);
|
|
||||||
const txHash = await (this as any).{{languageSpecificName}}.sendTransactionAsync(
|
|
||||||
{{#each inputs~}}
|
|
||||||
{{name}},
|
|
||||||
{{/each~}}
|
|
||||||
txData,
|
|
||||||
);
|
|
||||||
return txHash;
|
|
||||||
},
|
|
||||||
|
File diff suppressed because one or more lines are too long
@ -18,7 +18,13 @@ import {
|
|||||||
SupportedProvider,
|
SupportedProvider,
|
||||||
} from 'ethereum-types';
|
} from 'ethereum-types';
|
||||||
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
||||||
import { SimpleContractArtifact, EventCallback, IndexedFilterValues } from '@0x/types';
|
import {
|
||||||
|
AwaitTransactionSuccessOpts,
|
||||||
|
EventCallback,
|
||||||
|
IndexedFilterValues,
|
||||||
|
SendTransactionOpts,
|
||||||
|
SimpleContractArtifact,
|
||||||
|
} from '@0x/types';
|
||||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||||
import { assert } from '@0x/assert';
|
import { assert } from '@0x/assert';
|
||||||
import * as ethers from 'ethers';
|
import * as ethers from 'ethers';
|
||||||
@ -28,8 +34,10 @@ import * as ethers from 'ethers';
|
|||||||
// tslint:disable:no-parameter-reassignment
|
// tslint:disable:no-parameter-reassignment
|
||||||
// tslint:disable-next-line:class-name
|
// tslint:disable-next-line:class-name
|
||||||
export class LibDummyContract extends BaseContract {
|
export class LibDummyContract extends BaseContract {
|
||||||
public static deployedBytecode =
|
/**
|
||||||
'0x73000000000000000000000000000000000000000030146080604052600080fdfea265627a7a72305820b14322cd05aa1dcae66812e472d3ab85cced78118ea7f9a5098d073b2accc45964736f6c634300050a0032';
|
* @ignore
|
||||||
|
*/
|
||||||
|
public static deployedBytecode: string | undefined;
|
||||||
public static async deployFrom0xArtifactAsync(
|
public static async deployFrom0xArtifactAsync(
|
||||||
artifact: ContractArtifact | SimpleContractArtifact,
|
artifact: ContractArtifact | SimpleContractArtifact,
|
||||||
supportedProvider: SupportedProvider,
|
supportedProvider: SupportedProvider,
|
||||||
|
@ -18,7 +18,13 @@ import {
|
|||||||
SupportedProvider,
|
SupportedProvider,
|
||||||
} from 'ethereum-types';
|
} from 'ethereum-types';
|
||||||
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
||||||
import { SimpleContractArtifact, EventCallback, IndexedFilterValues } from '@0x/types';
|
import {
|
||||||
|
AwaitTransactionSuccessOpts,
|
||||||
|
EventCallback,
|
||||||
|
IndexedFilterValues,
|
||||||
|
SendTransactionOpts,
|
||||||
|
SimpleContractArtifact,
|
||||||
|
} from '@0x/types';
|
||||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||||
import { assert } from '@0x/assert';
|
import { assert } from '@0x/assert';
|
||||||
import * as ethers from 'ethers';
|
import * as ethers from 'ethers';
|
||||||
@ -28,6 +34,9 @@ import * as ethers from 'ethers';
|
|||||||
// tslint:disable:no-parameter-reassignment
|
// tslint:disable:no-parameter-reassignment
|
||||||
// tslint:disable-next-line:class-name
|
// tslint:disable-next-line:class-name
|
||||||
export class TestLibDummyContract extends BaseContract {
|
export class TestLibDummyContract extends BaseContract {
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
public static deployedBytecode =
|
public static deployedBytecode =
|
||||||
'0x6080604052348015600f57600080fd5b506004361060325760003560e01c806322935e921460375780632b82fdf0146063575b600080fd5b605160048036036020811015604b57600080fd5b5035607d565b60408051918252519081900360200190f35b605160048036036020811015607757600080fd5b5035608c565b60006086826095565b92915050565b6000608682609c565b6104d20190565b6001019056fea265627a7a72305820ddb720d14b34694daaefebcbd729af6ae04fa2232481812dd8fde63d6a4c32c164736f6c634300050a0032';
|
'0x6080604052348015600f57600080fd5b506004361060325760003560e01c806322935e921460375780632b82fdf0146063575b600080fd5b605160048036036020811015604b57600080fd5b5035607d565b60408051918252519081900360200190f35b605160048036036020811015607757600080fd5b5035608c565b60006086826095565b92915050565b6000608682609c565b6104d20190565b6001019056fea265627a7a72305820ddb720d14b34694daaefebcbd729af6ae04fa2232481812dd8fde63d6a4c32c164736f6c634300050a0032';
|
||||||
public publicAddConstant = {
|
public publicAddConstant = {
|
||||||
@ -52,7 +61,7 @@ export class TestLibDummyContract extends BaseContract {
|
|||||||
|
|
||||||
let rawCallResult;
|
let rawCallResult;
|
||||||
try {
|
try {
|
||||||
rawCallResult = await self.evmExecAsync(encodedDataBytes);
|
rawCallResult = await self._evmExecAsync(encodedDataBytes);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
BaseContract._throwIfThrownErrorIsRevertError(err);
|
BaseContract._throwIfThrownErrorIsRevertError(err);
|
||||||
throw err;
|
throw err;
|
||||||
@ -124,7 +133,7 @@ export class TestLibDummyContract extends BaseContract {
|
|||||||
|
|
||||||
let rawCallResult;
|
let rawCallResult;
|
||||||
try {
|
try {
|
||||||
rawCallResult = await self.evmExecAsync(encodedDataBytes);
|
rawCallResult = await self._evmExecAsync(encodedDataBytes);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
BaseContract._throwIfThrownErrorIsRevertError(err);
|
BaseContract._throwIfThrownErrorIsRevertError(err);
|
||||||
throw err;
|
throw err;
|
||||||
|
@ -138,14 +138,6 @@ describe('AbiGenDummy Contract', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('validate and send transaction', () => {
|
|
||||||
it('should call validateAndSendTransactionAsync', async () => {
|
|
||||||
const txHash = await abiGenDummy.nonPureMethod.validateAndSendTransactionAsync();
|
|
||||||
const hexRegex = /^0x[a-fA-F0-9]+$/;
|
|
||||||
expect(txHash.match(hexRegex)).to.deep.equal([txHash]);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('event subscription', () => {
|
describe('event subscription', () => {
|
||||||
const indexFilterValues = {};
|
const indexFilterValues = {};
|
||||||
const emptyCallback = () => {}; // tslint:disable-line:no-empty
|
const emptyCallback = () => {}; // tslint:disable-line:no-empty
|
||||||
@ -284,6 +276,13 @@ describe('AbiGenDummy Contract', () => {
|
|||||||
expect(decodedOutput, 'decoded output').to.be.deep.equal(output);
|
expect(decodedOutput, 'decoded output').to.be.deep.equal(output);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
describe('awaitTransactionSuccessAsync', async () => {
|
||||||
|
it('should successfully call the non pure function', async () => {
|
||||||
|
expect(
|
||||||
|
abiGenDummy.nonPureMethod.awaitTransactionSuccessAsync({}, { pollingIntervalMs: 10, timeoutMs: 100 }),
|
||||||
|
).to.be.fulfilled('');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Lib dummy contract', () => {
|
describe('Lib dummy contract', () => {
|
||||||
|
@ -267,7 +267,7 @@ export class AssetBuyer {
|
|||||||
// if no ethAmount is provided, default to the worst ethAmount from buyQuote
|
// if no ethAmount is provided, default to the worst ethAmount from buyQuote
|
||||||
const value = ethAmount || worstCaseQuoteInfo.totalEthAmount;
|
const value = ethAmount || worstCaseQuoteInfo.totalEthAmount;
|
||||||
|
|
||||||
const txHash = await this._contractWrappers.forwarder.marketBuyOrdersWithEth.validateAndSendTransactionAsync(
|
const txHash = await this._contractWrappers.forwarder.marketBuyOrdersWithEth.sendTransactionAsync(
|
||||||
orders,
|
orders,
|
||||||
assetBuyAmount,
|
assetBuyAmount,
|
||||||
orders.map(o => o.signature),
|
orders.map(o => o.signature),
|
||||||
|
@ -144,7 +144,7 @@ export class ExchangeSwapQuoteConsumer implements SwapQuoteConsumerBase<Exchange
|
|||||||
let txHash: string;
|
let txHash: string;
|
||||||
if (quote.type === MarketOperation.Buy) {
|
if (quote.type === MarketOperation.Buy) {
|
||||||
const { makerAssetFillAmount } = quote;
|
const { makerAssetFillAmount } = quote;
|
||||||
txHash = await this._contractWrappers.exchange.marketBuyOrdersNoThrow.validateAndSendTransactionAsync(
|
txHash = await this._contractWrappers.exchange.marketBuyOrdersNoThrow.sendTransactionAsync(
|
||||||
orders,
|
orders,
|
||||||
makerAssetFillAmount,
|
makerAssetFillAmount,
|
||||||
orders.map(o => o.signature),
|
orders.map(o => o.signature),
|
||||||
@ -156,7 +156,7 @@ export class ExchangeSwapQuoteConsumer implements SwapQuoteConsumerBase<Exchange
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
const { takerAssetFillAmount } = quote;
|
const { takerAssetFillAmount } = quote;
|
||||||
txHash = await this._contractWrappers.exchange.marketSellOrdersNoThrow.validateAndSendTransactionAsync(
|
txHash = await this._contractWrappers.exchange.marketSellOrdersNoThrow.sendTransactionAsync(
|
||||||
orders,
|
orders,
|
||||||
takerAssetFillAmount,
|
takerAssetFillAmount,
|
||||||
orders.map(o => o.signature),
|
orders.map(o => o.signature),
|
||||||
|
@ -197,7 +197,7 @@ export class ForwarderSwapQuoteConsumer implements SwapQuoteConsumerBase<Forward
|
|||||||
let txHash: string;
|
let txHash: string;
|
||||||
if (quoteWithAffiliateFee.type === MarketOperation.Buy) {
|
if (quoteWithAffiliateFee.type === MarketOperation.Buy) {
|
||||||
const { makerAssetFillAmount } = quoteWithAffiliateFee;
|
const { makerAssetFillAmount } = quoteWithAffiliateFee;
|
||||||
txHash = await this._contractWrappers.forwarder.marketBuyOrdersWithEth.validateAndSendTransactionAsync(
|
txHash = await this._contractWrappers.forwarder.marketBuyOrdersWithEth.sendTransactionAsync(
|
||||||
orders,
|
orders,
|
||||||
makerAssetFillAmount,
|
makerAssetFillAmount,
|
||||||
orders.map(o => o.signature),
|
orders.map(o => o.signature),
|
||||||
@ -211,7 +211,7 @@ export class ForwarderSwapQuoteConsumer implements SwapQuoteConsumerBase<Forward
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
txHash = await this._contractWrappers.forwarder.marketSellOrdersWithEth.validateAndSendTransactionAsync(
|
txHash = await this._contractWrappers.forwarder.marketSellOrdersWithEth.sendTransactionAsync(
|
||||||
orders,
|
orders,
|
||||||
orders.map(o => o.signature),
|
orders.map(o => o.signature),
|
||||||
formattedFeePercentage,
|
formattedFeePercentage,
|
||||||
|
@ -1,4 +1,17 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"version": "5.5.0-beta.1",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Make `evmExecAsync` protected and rename to `_evmExecAsync`",
|
||||||
|
"pr": 2243
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"note": "Remove duplicate types `IndexedFilterValues`, `DecodedLogEvent`, `EventCallback`",
|
||||||
|
"pr": 2243
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"version": "5.5.0-beta.0",
|
"version": "5.5.0-beta.0",
|
||||||
"changes": [
|
"changes": [
|
||||||
|
@ -184,7 +184,7 @@ export class BaseContract {
|
|||||||
}
|
}
|
||||||
return rawEncoded;
|
return rawEncoded;
|
||||||
}
|
}
|
||||||
public async evmExecAsync(input: Buffer): Promise<string> {
|
protected async _evmExecAsync(input: Buffer): Promise<string> {
|
||||||
const addressBuf = Buffer.from(this.address.substr(2), 'hex');
|
const addressBuf = Buffer.from(this.address.substr(2), 'hex');
|
||||||
// should only run once, the first time it is called
|
// should only run once, the first time it is called
|
||||||
if (this._evmIfExists === undefined) {
|
if (this._evmIfExists === undefined) {
|
||||||
|
@ -13,7 +13,9 @@ import {
|
|||||||
import { Block, BlockAndLogStreamer, Log } from 'ethereumjs-blockstream';
|
import { Block, BlockAndLogStreamer, Log } from 'ethereumjs-blockstream';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import { EventCallback, IndexedFilterValues, SubscriptionErrors } from './types';
|
import { EventCallback, IndexedFilterValues } from '@0x/types';
|
||||||
|
|
||||||
|
import { SubscriptionErrors } from './types';
|
||||||
import { filterUtils } from './utils/filter_utils';
|
import { filterUtils } from './utils/filter_utils';
|
||||||
|
|
||||||
const DEFAULT_BLOCK_POLLING_INTERVAL = 1000;
|
const DEFAULT_BLOCK_POLLING_INTERVAL = 1000;
|
||||||
@ -80,7 +82,7 @@ export class SubscriptionManager<ContractEventArgs, ContractEvents extends strin
|
|||||||
}
|
}
|
||||||
const filterToken = filterUtils.generateUUID();
|
const filterToken = filterUtils.generateUUID();
|
||||||
this._filters[filterToken] = filter;
|
this._filters[filterToken] = filter;
|
||||||
this._filterCallbacks[filterToken] = callback as EventCallback<ContractEventArgs>;
|
this._filterCallbacks[filterToken] = callback as EventCallback<ContractEventArgs>; // tslint:disable-line:no-unnecessary-type-assertion
|
||||||
return filterToken;
|
return filterToken;
|
||||||
}
|
}
|
||||||
public async getLogsAsync<ArgsType extends ContractEventArgs>(
|
public async getLogsAsync<ArgsType extends ContractEventArgs>(
|
||||||
|
@ -1,15 +1,6 @@
|
|||||||
import { ContractEventArg, DecodedLogArgs, LogEntryEvent, LogWithDecodedArgs } from 'ethereum-types';
|
import { LogEntryEvent } from 'ethereum-types';
|
||||||
|
|
||||||
export type LogEvent = LogEntryEvent;
|
export type LogEvent = LogEntryEvent;
|
||||||
export interface DecodedLogEvent<ArgsType extends DecodedLogArgs> {
|
|
||||||
isRemoved: boolean;
|
|
||||||
log: LogWithDecodedArgs<ArgsType>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type EventCallback<ArgsType extends DecodedLogArgs> = (
|
|
||||||
err: null | Error,
|
|
||||||
log?: DecodedLogEvent<ArgsType>,
|
|
||||||
) => void;
|
|
||||||
|
|
||||||
export interface ContractEvent<ContractEventArgs> {
|
export interface ContractEvent<ContractEventArgs> {
|
||||||
logIndex: number;
|
logIndex: number;
|
||||||
@ -27,7 +18,3 @@ export enum SubscriptionErrors {
|
|||||||
SubscriptionNotFound = 'SUBSCRIPTION_NOT_FOUND',
|
SubscriptionNotFound = 'SUBSCRIPTION_NOT_FOUND',
|
||||||
SubscriptionAlreadyPresent = 'SUBSCRIPTION_ALREADY_PRESENT',
|
SubscriptionAlreadyPresent = 'SUBSCRIPTION_ALREADY_PRESENT',
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IndexedFilterValues {
|
|
||||||
[index: string]: ContractEventArg;
|
|
||||||
}
|
|
||||||
|
@ -154,6 +154,8 @@ export {
|
|||||||
SignedZeroExTransaction,
|
SignedZeroExTransaction,
|
||||||
SimpleEvmOutput,
|
SimpleEvmOutput,
|
||||||
SimpleEvmBytecodeOutput,
|
SimpleEvmBytecodeOutput,
|
||||||
|
AwaitTransactionSuccessOpts,
|
||||||
|
SendTransactionOpts,
|
||||||
EIP712DomainWithDefaultSchema,
|
EIP712DomainWithDefaultSchema,
|
||||||
EventCallback,
|
EventCallback,
|
||||||
DecodedLogEvent,
|
DecodedLogEvent,
|
||||||
|
@ -40,6 +40,7 @@ export interface ContractWrappersConfig {
|
|||||||
blockPollingIntervalMs?: number;
|
blockPollingIntervalMs?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(xianny): remove after refactoring coordinator wrapper
|
||||||
/**
|
/**
|
||||||
* gasPrice: Gas price in Wei to use for a transaction
|
* gasPrice: Gas price in Wei to use for a transaction
|
||||||
* gasLimit: The amount of gas to send with a transaction (in Gwei)
|
* gasLimit: The amount of gas to send with a transaction (in Gwei)
|
||||||
@ -51,6 +52,7 @@ export interface TransactionOpts {
|
|||||||
nonce?: number;
|
nonce?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(xianny): remove after refactoring coordinator wrapper
|
||||||
/**
|
/**
|
||||||
* shouldValidate: Flag indicating whether the library should make attempts to validate a transaction before
|
* shouldValidate: Flag indicating whether the library should make attempts to validate a transaction before
|
||||||
* broadcasting it. For example, order has a valid signature, maker has sufficient funds, etc. Default=true.
|
* broadcasting it. For example, order has a valid signature, maker has sufficient funds, etc. Default=true.
|
||||||
|
@ -1,4 +1,13 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"version": "2.5.0-beta.1",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Add `SendTransactionOpts` and `AwaitTransactionSuccessOpts` types for contract wrappers",
|
||||||
|
"pr": 2243
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"version": "2.5.0-beta.0",
|
"version": "2.5.0-beta.0",
|
||||||
"changes": [
|
"changes": [
|
||||||
|
@ -670,6 +670,18 @@ export interface Type {
|
|||||||
tupleElements?: Type[];
|
tupleElements?: Type[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * shouldValidate: Flag indicating whether the library should make attempts to validate a transaction before
|
||||||
|
* broadcasting it. For example, order has a valid signature, maker has sufficient funds, etc. Default=true.
|
||||||
|
* * pollingIntervalMs: Used with `awaitTransactionSuccessAsync` to determine polling interval in milliseconds
|
||||||
|
* * timeoutMs: Used with `awaitTransactionSuccessAsync` to determine timeout in milliseconds
|
||||||
|
*/
|
||||||
|
export interface SendTransactionOpts {
|
||||||
|
shouldValidate?: boolean;
|
||||||
|
pollingIntervalMs?: number;
|
||||||
|
timeoutMs?: number;
|
||||||
|
}
|
||||||
|
|
||||||
export interface ElementType {
|
export interface ElementType {
|
||||||
name: string;
|
name: string;
|
||||||
typeDocType: TypeDocTypes;
|
typeDocType: TypeDocTypes;
|
||||||
@ -742,27 +754,6 @@ export interface Stats {
|
|||||||
orderCount: number;
|
orderCount: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SimpleContractArtifact {
|
|
||||||
schemaVersion: string;
|
|
||||||
contractName: string;
|
|
||||||
compilerOutput: SimpleStandardContractOutput;
|
|
||||||
networks: ContractNetworks;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SimpleStandardContractOutput {
|
|
||||||
abi: ContractAbi;
|
|
||||||
evm: SimpleEvmOutput;
|
|
||||||
devdoc?: DevdocOutput;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SimpleEvmOutput {
|
|
||||||
bytecode: SimpleEvmBytecodeOutput;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SimpleEvmBytecodeOutput {
|
|
||||||
object: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface DutchAuctionDetails {
|
export interface DutchAuctionDetails {
|
||||||
beginTimeSeconds: BigNumber;
|
beginTimeSeconds: BigNumber;
|
||||||
endTimeSeconds: BigNumber;
|
endTimeSeconds: BigNumber;
|
||||||
@ -862,3 +853,48 @@ export type EventCallback<ArgsType extends DecodedLogArgs> = (
|
|||||||
export interface IndexedFilterValues {
|
export interface IndexedFilterValues {
|
||||||
[index: string]: ContractEventArg;
|
[index: string]: ContractEventArg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Begin types for @0x/abi-gen-wrappers
|
||||||
|
* Allow these types to be imported when needed instead of having to import
|
||||||
|
* the whole package, which is large
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used with `sendTransactionAsync`
|
||||||
|
* * shouldValidate: Flag indicating whether the library should make attempts to validate a transaction before
|
||||||
|
* broadcasting it. For example, order has a valid signature, maker has sufficient funds, etc. Default=true.
|
||||||
|
*/
|
||||||
|
export interface SendTransactionOpts {
|
||||||
|
shouldValidate?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used with `awaitTransactionSuccessAsync`
|
||||||
|
* * pollingIntervalMs: Determine polling intervals in milliseconds
|
||||||
|
* * timeoutMs: Determines timeout in milliseconds
|
||||||
|
*/
|
||||||
|
export interface AwaitTransactionSuccessOpts extends SendTransactionOpts {
|
||||||
|
pollingIntervalMs?: number;
|
||||||
|
timeoutMs?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SimpleContractArtifact {
|
||||||
|
schemaVersion: string;
|
||||||
|
contractName: string;
|
||||||
|
compilerOutput: SimpleStandardContractOutput;
|
||||||
|
networks: ContractNetworks;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SimpleStandardContractOutput {
|
||||||
|
abi: ContractAbi;
|
||||||
|
evm: SimpleEvmOutput;
|
||||||
|
devdoc?: DevdocOutput;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SimpleEvmOutput {
|
||||||
|
bytecode: SimpleEvmBytecodeOutput;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SimpleEvmBytecodeOutput {
|
||||||
|
object: string;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user