Merge pull request #2469 from 0xProject/feature/broker/deployments
Broker-related updates to contract-artifacts, contract-wrappers, contract-addresses
This commit is contained in:
@@ -9,6 +9,18 @@
|
||||
{
|
||||
"note": "Update `ERC20BridgeSampler` address on mainnet and kovan.",
|
||||
"pr": 2476
|
||||
},
|
||||
{
|
||||
"note": "Removed OrderValidator and DutchAuction addresses",
|
||||
"pr": 2469
|
||||
},
|
||||
{
|
||||
"note": "Added Broker and GodsUnchainedValidator addresses",
|
||||
"pr": 2469
|
||||
},
|
||||
{
|
||||
"note": "Updated Forwarder addresses",
|
||||
"pr": 2469
|
||||
}
|
||||
],
|
||||
"timestamp": 1581204851
|
||||
|
@@ -4,13 +4,11 @@
|
||||
"exchange": "0x61935cbdd02287b511119ddb11aeb42f1593b7ef",
|
||||
"erc20Proxy": "0x95e6f48254609a6ee006f7d493c8e5fb97094cef",
|
||||
"erc721Proxy": "0xefc70a1b18c432bdc64b596838b4d138f6bc6cad",
|
||||
"forwarder": "0x4ef40d1bf0983899892946830abf99eca2dbc5ce",
|
||||
"orderValidator": "0x0000000000000000000000000000000000000000",
|
||||
"forwarder": "0x4aa817c6f383c8e8ae77301d18ce48efb16fd2be",
|
||||
"zrxToken": "0xe41d2489571d322189246dafa5ebde1f4699f498",
|
||||
"etherToken": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
|
||||
"assetProxyOwner": "0xdffe798c7172dd6deb32baee68af322e8f495ce0",
|
||||
"zeroExGovernor": "0x7d3455421bbc5ed534a83c88fd80387dc8271392",
|
||||
"dutchAuction": "0x0000000000000000000000000000000000000000",
|
||||
"coordinatorRegistry": "0x45797531b873fd5e519477a070a955764c1a5b07",
|
||||
"coordinator": "0x38a795580d0f687e399913a00ddef6a17612c722",
|
||||
"multiAssetProxy": "0xef701d5389ae74503d633396c4d654eabedc9d78",
|
||||
@@ -26,7 +24,9 @@
|
||||
"kyberBridge": "0xf342f3a80fdc9b48713d58fe97e17f5cc764ee62",
|
||||
"eth2DaiBridge": "0xe3379a1956f4a79f39eb2e87bb441419e167538e",
|
||||
"chaiBridge": "0x77c31eba23043b9a72d13470f3a3a311344d7438",
|
||||
"dydxBridge": "0x55dc8f21d20d4c6ed3c82916a438a413ca68e335"
|
||||
"dydxBridge": "0x55dc8f21d20d4c6ed3c82916a438a413ca68e335",
|
||||
"godsUnchainedValidator": "0x09A379Ef7218BCFD8913fAa8B281ebc5A2E0bC04",
|
||||
"broker": "0xd4690a51044db77D91d7Aa8f7a3a5ad5dA331Af0"
|
||||
},
|
||||
"3": {
|
||||
"erc20Proxy": "0xb1408f4c245a23c31b98d2c626777d4c0d766caa",
|
||||
@@ -37,9 +37,7 @@
|
||||
"exchange": "0xfb2dd2a1366de37f7241c83d47da58fd503e2c64",
|
||||
"assetProxyOwner": "0x0000000000000000000000000000000000000000",
|
||||
"zeroExGovernor": "0x53993733d41a88ae86f77a18a024e5548ee26579",
|
||||
"forwarder": "0x14e931e2439e211a13576bbec643c9130cbdd0c8",
|
||||
"orderValidator": "0x0000000000000000000000000000000000000000",
|
||||
"dutchAuction": "0x0000000000000000000000000000000000000000",
|
||||
"forwarder": "0xe2bfd35306495d11e3c9db0d8de390cda24563cf",
|
||||
"coordinatorRegistry": "0x403cc23e88c17c4652fb904784d1af640a6722d9",
|
||||
"coordinator": "0x6ff734d96104965c9c1b0108f83abc46e6e501df",
|
||||
"multiAssetProxy": "0xab8fbd189c569ccdee3a4d929bb7f557be4028f6",
|
||||
@@ -55,7 +53,9 @@
|
||||
"erc20BridgeSampler": "0x0000000000000000000000000000000000000000",
|
||||
"kyberBridge": "0x0000000000000000000000000000000000000000",
|
||||
"chaiBridge": "0x0000000000000000000000000000000000000000",
|
||||
"dydxBridge": "0x0000000000000000000000000000000000000000"
|
||||
"dydxBridge": "0x0000000000000000000000000000000000000000",
|
||||
"godsUnchainedValidator": "0xd4690a51044db77D91d7Aa8f7a3a5ad5dA331Af0",
|
||||
"broker": "0x4Aa817C6f383C8e8aE77301d18Ce48efb16Fd2BE"
|
||||
},
|
||||
"4": {
|
||||
"exchangeV2": "0xbff9493f92a3df4b0429b6d00743b3cfb4c85831",
|
||||
@@ -66,9 +66,7 @@
|
||||
"etherToken": "0xc778417e063141139fce010982780140aa0cd5ab",
|
||||
"assetProxyOwner": "0x0000000000000000000000000000000000000000",
|
||||
"zeroExGovernor": "0x3f46b98061a3e1e1f41dff296ec19402c298f8a9",
|
||||
"forwarder": "0xd67f2f346f6e85db70632d9f18f50e04192ab54d",
|
||||
"orderValidator": "0x0000000000000000000000000000000000000000",
|
||||
"dutchAuction": "0x0000000000000000000000000000000000000000",
|
||||
"forwarder": "0x263ccc190ccb1cb3342ab07e50f03edb2f05aa36",
|
||||
"coordinatorRegistry": "0x1084b6a398e47907bae43fec3ff4b677db6e4fee",
|
||||
"coordinator": "0x70c5385ee5ee4629ef72abd169e888c8b4a12238",
|
||||
"multiAssetProxy": "0xb34cde0ad3a83d04abebc0b66e75196f22216621",
|
||||
@@ -84,7 +82,9 @@
|
||||
"erc20BridgeSampler": "0x0000000000000000000000000000000000000000",
|
||||
"kyberBridge": "0x0000000000000000000000000000000000000000",
|
||||
"chaiBridge": "0x0000000000000000000000000000000000000000",
|
||||
"dydxBridge": "0x0000000000000000000000000000000000000000"
|
||||
"dydxBridge": "0x0000000000000000000000000000000000000000",
|
||||
"godsUnchainedValidator": "0x0000000000000000000000000000000000000000",
|
||||
"broker": "0x0000000000000000000000000000000000000000"
|
||||
},
|
||||
"42": {
|
||||
"erc20Proxy": "0xf1ec01d6236d3cd881a0bf0130ea25fe4234003e",
|
||||
@@ -95,9 +95,7 @@
|
||||
"exchange": "0x4eacd0af335451709e1e7b570b8ea68edec8bc97",
|
||||
"assetProxyOwner": "0x0000000000000000000000000000000000000000",
|
||||
"zeroExGovernor": "0x6ff734d96104965c9c1b0108f83abc46e6e501df",
|
||||
"forwarder": "0x2759a4c639fa4882d6d64973630ef81faf901d27",
|
||||
"orderValidator": "0x0000000000000000000000000000000000000000",
|
||||
"dutchAuction": "0x0000000000000000000000000000000000000000",
|
||||
"forwarder": "0x263ccc190ccb1cb3342ab07e50f03edb2f05aa36",
|
||||
"coordinatorRegistry": "0x09fb99968c016a3ff537bf58fb3d9fe55a7975d5",
|
||||
"coordinator": "0xd29e59e51e8ab5f94121efaeebd935ca4214e257",
|
||||
"multiAssetProxy": "0xf6313a772c222f51c28f2304c0703b8cf5428fd8",
|
||||
@@ -113,7 +111,9 @@
|
||||
"erc20BridgeSampler": "0x76a3d21fc9c16afd29eb12a5bdcedd5ddbf24357",
|
||||
"kyberBridge": "0xde7b2747624a647600fdb349184d0448ab954929",
|
||||
"chaiBridge": "0x0000000000000000000000000000000000000000",
|
||||
"dydxBridge": "0x0000000000000000000000000000000000000000"
|
||||
"dydxBridge": "0x0000000000000000000000000000000000000000",
|
||||
"godsUnchainedValidator": "0x0000000000000000000000000000000000000000",
|
||||
"broker": "0x0000000000000000000000000000000000000000"
|
||||
},
|
||||
"1337": {
|
||||
"erc20Proxy": "0x1dc4c1cefef38a777b15aa20260a54e584b16c48",
|
||||
@@ -126,8 +126,6 @@
|
||||
"erc20BridgeProxy": "0x038f9b392fb9a9676dbaddf78ea5fdbf6c7d9710",
|
||||
"zeroExGovernor": "0x0000000000000000000000000000000000000000",
|
||||
"forwarder": "0xe704967449b57b2382b7fa482718748c13c63190",
|
||||
"orderValidator": "0x0000000000000000000000000000000000000000",
|
||||
"dutchAuction": "0x0000000000000000000000000000000000000000",
|
||||
"coordinatorRegistry": "0xaa86dda78e9434aca114b6676fc742a18d15a1cc",
|
||||
"coordinator": "0x4d3d5c850dd5bd9d6f4adda3dd039a3c8054ca29",
|
||||
"multiAssetProxy": "0xcfc18cec799fbd1793b5c43e773c98d4d61cc2db",
|
||||
@@ -142,6 +140,8 @@
|
||||
"erc20BridgeSampler": "0x0000000000000000000000000000000000000000",
|
||||
"kyberBridge": "0x0000000000000000000000000000000000000000",
|
||||
"chaiBridge": "0x0000000000000000000000000000000000000000",
|
||||
"dydxBridge": "0x0000000000000000000000000000000000000000"
|
||||
"dydxBridge": "0x0000000000000000000000000000000000000000",
|
||||
"godsUnchainedValidator": "0x0000000000000000000000000000000000000000",
|
||||
"broker": "0x0000000000000000000000000000000000000000"
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,17 @@
|
||||
[
|
||||
{
|
||||
"version": "3.6.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Add Broker and GodsUnchainedValidator artifacts",
|
||||
"pr": 2469
|
||||
},
|
||||
{
|
||||
"note": "Updated Forwarder artifact",
|
||||
"pr": 2469
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "3.5.0",
|
||||
"changes": [
|
||||
|
206
packages/contract-artifacts/artifacts/Broker.json
generated
Normal file
206
packages/contract-artifacts/artifacts/Broker.json
generated
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
70
packages/contract-artifacts/artifacts/GodsUnchainedValidator.json
generated
Normal file
70
packages/contract-artifacts/artifacts/GodsUnchainedValidator.json
generated
Normal file
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"schemaVersion": "2.0.0",
|
||||
"contractName": "GodsUnchainedValidator",
|
||||
"compilerOutput": {
|
||||
"abi": [
|
||||
{
|
||||
"inputs": [{ "internalType": "address", "name": "_godsUnchained", "type": "address" }],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "constructor"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{ "internalType": "uint256", "name": "tokenId", "type": "uint256" },
|
||||
{ "internalType": "bytes", "name": "propertyData", "type": "bytes" }
|
||||
],
|
||||
"name": "checkBrokerAsset",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
}
|
||||
],
|
||||
"devdoc": {
|
||||
"methods": {
|
||||
"checkBrokerAsset(uint256,bytes)": {
|
||||
"details": "Checks that the given card (encoded as assetData) has the proto and quality encoded in `propertyData`. Reverts if the card doesn't match the specified proto and quality.",
|
||||
"params": {
|
||||
"propertyData": "Encoded proto and quality that the card is expected to have.",
|
||||
"tokenId": "The ERC721 tokenId of the card to check."
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"evm": {
|
||||
"bytecode": {
|
||||
"object": "0x608060405234801561001057600080fd5b5060405161042b38038061042b83398101604081905261002f91610054565b600080546001600160a01b0319166001600160a01b0392909216919091179055610082565b600060208284031215610065578081fd5b81516001600160a01b038116811461007b578182fd5b9392505050565b61039a806100916000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80639256050a14610030575b600080fd5b61004361003e3660046101fd565b610045565b005b60008061005483850185610197565b600080546040517fb93a89f700000000000000000000000000000000000000000000000000000000815293955091935091829173ffffffffffffffffffffffffffffffffffffffff169063b93a89f7906100b2908a9060040161032c565b604080518083038186803b1580156100c957600080fd5b505afa1580156100dd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061010191908101906101cf565b915091508361ffff168261ffff161461014f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610146906102cf565b60405180910390fd5b8260ff168160ff161461018e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161014690610272565b50505050505050565b600080604083850312156101a9578182fd5b82356101b481610335565b915060208301356101c481610348565b809150509250929050565b600080604083850312156101e1578182fd5b82516101ec81610335565b60208401519092506101c481610348565b600080600060408486031215610211578081fd5b83359250602084013567ffffffffffffffff8082111561022f578283fd5b81860187601f820112610240578384fd5b8035925081831115610250578384fd5b876020848301011115610261578384fd5b949760209095019650909450505050565b60208082526027908201527f476f6473556e636861696e656456616c696461746f722f5155414c4954595f4d60408201527f49534d4154434800000000000000000000000000000000000000000000000000606082015260800190565b60208082526025908201527f476f6473556e636861696e656456616c696461746f722f50524f544f5f4d495360408201527f4d41544348000000000000000000000000000000000000000000000000000000606082015260800190565b90815260200190565b61ffff8116811461034557600080fd5b50565b60ff8116811461034557600080fdfea365627a7a723158203028b97b542e7c9694b2dfadb335cd83bec3bff6276b5f2cdb1d7c1abed796e46c6578706572696d656e74616cf564736f6c63430005100040"
|
||||
},
|
||||
"deployedBytecode": {
|
||||
"object": "0x608060405234801561001057600080fd5b506004361061002b5760003560e01c80639256050a14610030575b600080fd5b61004361003e3660046101fd565b610045565b005b60008061005483850185610197565b600080546040517fb93a89f700000000000000000000000000000000000000000000000000000000815293955091935091829173ffffffffffffffffffffffffffffffffffffffff169063b93a89f7906100b2908a9060040161032c565b604080518083038186803b1580156100c957600080fd5b505afa1580156100dd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061010191908101906101cf565b915091508361ffff168261ffff161461014f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610146906102cf565b60405180910390fd5b8260ff168160ff161461018e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161014690610272565b50505050505050565b600080604083850312156101a9578182fd5b82356101b481610335565b915060208301356101c481610348565b809150509250929050565b600080604083850312156101e1578182fd5b82516101ec81610335565b60208401519092506101c481610348565b600080600060408486031215610211578081fd5b83359250602084013567ffffffffffffffff8082111561022f578283fd5b81860187601f820112610240578384fd5b8035925081831115610250578384fd5b876020848301011115610261578384fd5b949760209095019650909450505050565b60208082526027908201527f476f6473556e636861696e656456616c696461746f722f5155414c4954595f4d60408201527f49534d4154434800000000000000000000000000000000000000000000000000606082015260800190565b60208082526025908201527f476f6473556e636861696e656456616c696461746f722f50524f544f5f4d495360408201527f4d41544348000000000000000000000000000000000000000000000000000000606082015260800190565b90815260200190565b61ffff8116811461034557600080fd5b50565b60ff8116811461034557600080fdfea365627a7a723158203028b97b542e7c9694b2dfadb335cd83bec3bff6276b5f2cdb1d7c1abed796e46c6578706572696d656e74616cf564736f6c63430005100040"
|
||||
}
|
||||
}
|
||||
},
|
||||
"compiler": {
|
||||
"name": "solc",
|
||||
"version": "soljson-v0.5.16+commit.9c3226ce.js",
|
||||
"settings": {
|
||||
"optimizer": {
|
||||
"enabled": true,
|
||||
"runs": 1000000,
|
||||
"details": { "yul": true, "deduplicate": true, "cse": true, "constantOptimizer": true }
|
||||
},
|
||||
"outputSelection": {
|
||||
"*": {
|
||||
"*": [
|
||||
"abi",
|
||||
"devdoc",
|
||||
"evm.bytecode.object",
|
||||
"evm.bytecode.sourceMap",
|
||||
"evm.deployedBytecode.object",
|
||||
"evm.deployedBytecode.sourceMap"
|
||||
]
|
||||
}
|
||||
},
|
||||
"evmVersion": "istanbul"
|
||||
}
|
||||
},
|
||||
"chains": {}
|
||||
}
|
@@ -1,4 +1,5 @@
|
||||
import * as AssetProxyOwner from '../artifacts/AssetProxyOwner.json';
|
||||
import * as Broker from '../artifacts/Broker.json';
|
||||
import * as Coordinator from '../artifacts/Coordinator.json';
|
||||
import * as CoordinatorRegistry from '../artifacts/CoordinatorRegistry.json';
|
||||
import * as DevUtils from '../artifacts/DevUtils.json';
|
||||
@@ -12,6 +13,7 @@ import * as ERC721Proxy from '../artifacts/ERC721Proxy.json';
|
||||
import * as ERC721Token from '../artifacts/ERC721Token.json';
|
||||
import * as Exchange from '../artifacts/Exchange.json';
|
||||
import * as Forwarder from '../artifacts/Forwarder.json';
|
||||
import * as GodsUnchainedValidator from '../artifacts/GodsUnchainedValidator.json';
|
||||
import * as IAssetProxy from '../artifacts/IAssetProxy.json';
|
||||
import * as IValidator from '../artifacts/IValidator.json';
|
||||
import * as IWallet from '../artifacts/IWallet.json';
|
||||
@@ -27,6 +29,7 @@ import * as IERC20BridgeSampler from '../artifacts/IERC20BridgeSampler.json';
|
||||
|
||||
export {
|
||||
AssetProxyOwner,
|
||||
Broker,
|
||||
DevUtils,
|
||||
DummyERC20Token,
|
||||
DummyERC721Token,
|
||||
@@ -39,6 +42,7 @@ export {
|
||||
ERC721Token,
|
||||
Exchange,
|
||||
Forwarder,
|
||||
GodsUnchainedValidator,
|
||||
IAssetProxy,
|
||||
IValidator,
|
||||
IWallet,
|
||||
|
@@ -8,6 +8,7 @@
|
||||
"include": ["./src/**/*", "./test/**/*"],
|
||||
"files": [
|
||||
"./artifacts/AssetProxyOwner.json",
|
||||
"./artifacts/Broker.json",
|
||||
"./artifacts/DevUtils.json",
|
||||
"./artifacts/DutchAuction.json",
|
||||
"./artifacts/DummyERC20Token.json",
|
||||
@@ -19,6 +20,7 @@
|
||||
"./artifacts/ERC721Token.json",
|
||||
"./artifacts/Exchange.json",
|
||||
"./artifacts/Forwarder.json",
|
||||
"./artifacts/GodsUnchainedValidator.json",
|
||||
"./artifacts/IAssetProxy.json",
|
||||
"./artifacts/IValidator.json",
|
||||
"./artifacts/IWallet.json",
|
||||
|
@@ -1,4 +1,17 @@
|
||||
[
|
||||
{
|
||||
"version": "13.6.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Add Broker and GodsUnchainedValidator wrappers",
|
||||
"pr": 2469
|
||||
},
|
||||
{
|
||||
"note": "Updated Forwarder wrapper",
|
||||
"pr": 2469
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "13.5.0",
|
||||
"changes": [
|
||||
|
@@ -31,7 +31,7 @@
|
||||
"wrappers:generate": "abi-gen --abis ${npm_package_config_abis} --output src/generated-wrappers --backend ethers"
|
||||
},
|
||||
"config": {
|
||||
"abis": "../contract-artifacts/artifacts/@(DevUtils|ERC20Token|ERC721Token|Exchange|Forwarder|IAssetData|LibTransactionDecoder|WETH9|Coordinator|Staking|StakingProxy|IERC20BridgeSampler).json"
|
||||
"abis": "../contract-artifacts/artifacts/@(DevUtils|ERC20Token|ERC721Token|Exchange|Forwarder|IAssetData|LibTransactionDecoder|WETH9|Coordinator|Staking|StakingProxy|IERC20BridgeSampler|GodsUnchainedValidator|Broker).json"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
826
packages/contract-wrappers/src/generated-wrappers/broker.ts
generated
Normal file
826
packages/contract-wrappers/src/generated-wrappers/broker.ts
generated
Normal file
@@ -0,0 +1,826 @@
|
||||
// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma enum-naming
|
||||
// tslint:disable:whitespace no-unbound-method no-trailing-whitespace
|
||||
// tslint:disable:no-unused-variable
|
||||
import {
|
||||
AwaitTransactionSuccessOpts,
|
||||
ContractFunctionObj,
|
||||
ContractTxFunctionObj,
|
||||
SendTransactionOpts,
|
||||
BaseContract,
|
||||
PromiseWithTransactionHash,
|
||||
methodAbiToFunctionSignature,
|
||||
} from '@0x/base-contract';
|
||||
import { schemas } from '@0x/json-schemas';
|
||||
import {
|
||||
BlockParam,
|
||||
BlockParamLiteral,
|
||||
BlockRange,
|
||||
CallData,
|
||||
ContractAbi,
|
||||
ContractArtifact,
|
||||
DecodedLogArgs,
|
||||
MethodAbi,
|
||||
TransactionReceiptWithDecodedLogs,
|
||||
TxData,
|
||||
TxDataPayable,
|
||||
SupportedProvider,
|
||||
} from 'ethereum-types';
|
||||
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
||||
import { EventCallback, IndexedFilterValues, SimpleContractArtifact } from '@0x/types';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { assert } from '@0x/assert';
|
||||
import * as ethers from 'ethers';
|
||||
// tslint:enable:no-unused-variable
|
||||
|
||||
/* istanbul ignore next */
|
||||
// tslint:disable:no-parameter-reassignment
|
||||
// tslint:disable-next-line:class-name
|
||||
export class BrokerContract extends BaseContract {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
public static deployedBytecode: string | undefined;
|
||||
public static contractName = 'Broker';
|
||||
private readonly _methodABIIndex: { [name: string]: number } = {};
|
||||
public static async deployFrom0xArtifactAsync(
|
||||
artifact: ContractArtifact | SimpleContractArtifact,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
logDecodeDependencies: { [contractName: string]: ContractArtifact | SimpleContractArtifact },
|
||||
exchange: string,
|
||||
weth: string,
|
||||
): Promise<BrokerContract> {
|
||||
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
|
||||
schemas.addressSchema,
|
||||
schemas.numberSchema,
|
||||
schemas.jsNumber,
|
||||
]);
|
||||
if (artifact.compilerOutput === undefined) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const bytecode = artifact.compilerOutput.evm.bytecode.object;
|
||||
const abi = artifact.compilerOutput.abi;
|
||||
const logDecodeDependenciesAbiOnly: { [contractName: string]: ContractAbi } = {};
|
||||
if (Object.keys(logDecodeDependencies) !== undefined) {
|
||||
for (const key of Object.keys(logDecodeDependencies)) {
|
||||
logDecodeDependenciesAbiOnly[key] = logDecodeDependencies[key].compilerOutput.abi;
|
||||
}
|
||||
}
|
||||
return BrokerContract.deployAsync(
|
||||
bytecode,
|
||||
abi,
|
||||
provider,
|
||||
txDefaults,
|
||||
logDecodeDependenciesAbiOnly,
|
||||
exchange,
|
||||
weth,
|
||||
);
|
||||
}
|
||||
public static async deployAsync(
|
||||
bytecode: string,
|
||||
abi: ContractAbi,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
logDecodeDependencies: { [contractName: string]: ContractAbi },
|
||||
exchange: string,
|
||||
weth: string,
|
||||
): Promise<BrokerContract> {
|
||||
assert.isHexString('bytecode', bytecode);
|
||||
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
|
||||
schemas.addressSchema,
|
||||
schemas.numberSchema,
|
||||
schemas.jsNumber,
|
||||
]);
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
|
||||
[exchange, weth] = BaseContract._formatABIDataItemList(
|
||||
constructorAbi.inputs,
|
||||
[exchange, weth],
|
||||
BaseContract._bigNumberToString,
|
||||
);
|
||||
const iface = new ethers.utils.Interface(abi);
|
||||
const deployInfo = iface.deployFunction;
|
||||
const txData = deployInfo.encode(bytecode, [exchange, weth]);
|
||||
const web3Wrapper = new Web3Wrapper(provider);
|
||||
const txDataWithDefaults = await BaseContract._applyDefaultsToContractTxDataAsync(
|
||||
{
|
||||
data: txData,
|
||||
...txDefaults,
|
||||
},
|
||||
web3Wrapper.estimateGasAsync.bind(web3Wrapper),
|
||||
);
|
||||
const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||
logUtils.log(`transactionHash: ${txHash}`);
|
||||
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
|
||||
logUtils.log(`Broker successfully deployed at ${txReceipt.contractAddress}`);
|
||||
const contractInstance = new BrokerContract(
|
||||
txReceipt.contractAddress as string,
|
||||
provider,
|
||||
txDefaults,
|
||||
logDecodeDependencies,
|
||||
);
|
||||
contractInstance.constructorArgs = [exchange, weth];
|
||||
return contractInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns The contract ABI
|
||||
*/
|
||||
public static ABI(): ContractAbi {
|
||||
const abi = [
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
name: 'exchange',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
name: 'weth',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
outputs: [],
|
||||
payable: false,
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'constructor',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
outputs: [],
|
||||
payable: true,
|
||||
stateMutability: 'payable',
|
||||
type: 'fallback',
|
||||
},
|
||||
{
|
||||
constant: false,
|
||||
inputs: [
|
||||
{
|
||||
name: 'brokeredTokenIds',
|
||||
type: 'uint256[]',
|
||||
},
|
||||
{
|
||||
name: 'orders',
|
||||
type: 'tuple[]',
|
||||
components: [
|
||||
{
|
||||
name: 'makerAddress',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
name: 'takerAddress',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
name: 'feeRecipientAddress',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
name: 'senderAddress',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
name: 'makerAssetAmount',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
name: 'takerAssetAmount',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
name: 'makerFee',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
name: 'takerFee',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
name: 'expirationTimeSeconds',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
name: 'salt',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
name: 'makerAssetData',
|
||||
type: 'bytes',
|
||||
},
|
||||
{
|
||||
name: 'takerAssetData',
|
||||
type: 'bytes',
|
||||
},
|
||||
{
|
||||
name: 'makerFeeAssetData',
|
||||
type: 'bytes',
|
||||
},
|
||||
{
|
||||
name: 'takerFeeAssetData',
|
||||
type: 'bytes',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'takerAssetFillAmounts',
|
||||
type: 'uint256[]',
|
||||
},
|
||||
{
|
||||
name: 'signatures',
|
||||
type: 'bytes[]',
|
||||
},
|
||||
{
|
||||
name: 'batchFillFunctionSelector',
|
||||
type: 'bytes4',
|
||||
},
|
||||
{
|
||||
name: 'ethFeeAmounts',
|
||||
type: 'uint256[]',
|
||||
},
|
||||
{
|
||||
name: 'feeRecipients',
|
||||
type: 'address[]',
|
||||
},
|
||||
],
|
||||
name: 'batchBrokerTrade',
|
||||
outputs: [
|
||||
{
|
||||
name: 'fillResults',
|
||||
type: 'tuple[]',
|
||||
components: [
|
||||
{
|
||||
name: 'makerAssetFilledAmount',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
name: 'takerAssetFilledAmount',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
name: 'makerFeePaid',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
name: 'takerFeePaid',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
name: 'protocolFeePaid',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
payable: true,
|
||||
stateMutability: 'payable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
constant: false,
|
||||
inputs: [
|
||||
{
|
||||
name: 'brokeredTokenIds',
|
||||
type: 'uint256[]',
|
||||
},
|
||||
{
|
||||
name: 'order',
|
||||
type: 'tuple',
|
||||
components: [
|
||||
{
|
||||
name: 'makerAddress',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
name: 'takerAddress',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
name: 'feeRecipientAddress',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
name: 'senderAddress',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
name: 'makerAssetAmount',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
name: 'takerAssetAmount',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
name: 'makerFee',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
name: 'takerFee',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
name: 'expirationTimeSeconds',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
name: 'salt',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
name: 'makerAssetData',
|
||||
type: 'bytes',
|
||||
},
|
||||
{
|
||||
name: 'takerAssetData',
|
||||
type: 'bytes',
|
||||
},
|
||||
{
|
||||
name: 'makerFeeAssetData',
|
||||
type: 'bytes',
|
||||
},
|
||||
{
|
||||
name: 'takerFeeAssetData',
|
||||
type: 'bytes',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'takerAssetFillAmount',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
name: 'signature',
|
||||
type: 'bytes',
|
||||
},
|
||||
{
|
||||
name: 'fillFunctionSelector',
|
||||
type: 'bytes4',
|
||||
},
|
||||
{
|
||||
name: 'ethFeeAmounts',
|
||||
type: 'uint256[]',
|
||||
},
|
||||
{
|
||||
name: 'feeRecipients',
|
||||
type: 'address[]',
|
||||
},
|
||||
],
|
||||
name: 'brokerTrade',
|
||||
outputs: [
|
||||
{
|
||||
name: 'fillResults',
|
||||
type: 'tuple',
|
||||
components: [
|
||||
{
|
||||
name: 'makerAssetFilledAmount',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
name: 'takerAssetFilledAmount',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
name: 'makerFeePaid',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
name: 'takerFeePaid',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
name: 'protocolFeePaid',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
payable: true,
|
||||
stateMutability: 'payable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
constant: false,
|
||||
inputs: [
|
||||
{
|
||||
name: 'from',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
name: 'to',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
name: 'index_2',
|
||||
type: 'uint256[]',
|
||||
},
|
||||
{
|
||||
name: 'amounts',
|
||||
type: 'uint256[]',
|
||||
},
|
||||
{
|
||||
name: 'data',
|
||||
type: 'bytes',
|
||||
},
|
||||
],
|
||||
name: 'safeBatchTransferFrom',
|
||||
outputs: [],
|
||||
payable: false,
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
] as ContractAbi;
|
||||
return abi;
|
||||
}
|
||||
|
||||
public getFunctionSignature(methodName: string): string {
|
||||
const index = this._methodABIIndex[methodName];
|
||||
const methodAbi = BrokerContract.ABI()[index] as MethodAbi; // tslint:disable-line:no-unnecessary-type-assertion
|
||||
const functionSignature = methodAbiToFunctionSignature(methodAbi);
|
||||
return functionSignature;
|
||||
}
|
||||
public getABIDecodedTransactionData<T>(methodName: string, callData: string): T {
|
||||
const functionSignature = this.getFunctionSignature(methodName);
|
||||
const self = (this as any) as BrokerContract;
|
||||
const abiEncoder = self._lookupAbiEncoder(functionSignature);
|
||||
const abiDecodedCallData = abiEncoder.strictDecode<T>(callData);
|
||||
return abiDecodedCallData;
|
||||
}
|
||||
public getABIDecodedReturnData<T>(methodName: string, callData: string): T {
|
||||
const functionSignature = this.getFunctionSignature(methodName);
|
||||
const self = (this as any) as BrokerContract;
|
||||
const abiEncoder = self._lookupAbiEncoder(functionSignature);
|
||||
const abiDecodedCallData = abiEncoder.strictDecodeReturnValue<T>(callData);
|
||||
return abiDecodedCallData;
|
||||
}
|
||||
public getSelector(methodName: string): string {
|
||||
const functionSignature = this.getFunctionSignature(methodName);
|
||||
const self = (this as any) as BrokerContract;
|
||||
const abiEncoder = self._lookupAbiEncoder(functionSignature);
|
||||
return abiEncoder.getSelector();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills multiple property-based orders by the given amounts using the given assets.
|
||||
* Pays protocol fees using either the ETH supplied by the taker to the transaction or
|
||||
* WETH acquired from the maker during settlement. The final WETH balance is sent to the taker.
|
||||
* @param brokeredTokenIds Token IDs specified by the taker to be used to fill
|
||||
* the orders.
|
||||
* @param orders The property-based orders to fill. The format of a property-
|
||||
* based order is the same as that of a normal order, except the
|
||||
* takerAssetData. Instaed of specifying a specific ERC721 asset,
|
||||
* the takerAssetData should be ERC1155 assetData where the
|
||||
* underlying tokenAddress is this contract's address and the desired
|
||||
* properties are encoded in the extra data field. Also note that
|
||||
* takerFees must be denominated in WETH (or zero).
|
||||
* @param takerAssetFillAmounts The amounts to fill the orders by.
|
||||
* @param signatures The makers' signatures for the given orders.
|
||||
* @param batchFillFunctionSelector The selector for either `batchFillOrders`,
|
||||
* `batchFillOrKillOrders`, or `batchFillOrdersNoThrow`.
|
||||
* @param ethFeeAmounts Amounts of ETH, denominated in Wei, that are paid to
|
||||
* corresponding feeRecipients.
|
||||
* @param feeRecipients Addresses that will receive ETH when orders are filled.
|
||||
* @returns fillResults Amounts filled and fees paid by the makers and taker.
|
||||
*/
|
||||
public batchBrokerTrade(
|
||||
brokeredTokenIds: BigNumber[],
|
||||
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;
|
||||
makerFeeAssetData: string;
|
||||
takerFeeAssetData: string;
|
||||
}>,
|
||||
takerAssetFillAmounts: BigNumber[],
|
||||
signatures: string[],
|
||||
batchFillFunctionSelector: string,
|
||||
ethFeeAmounts: BigNumber[],
|
||||
feeRecipients: string[],
|
||||
): ContractTxFunctionObj<
|
||||
Array<{
|
||||
makerAssetFilledAmount: BigNumber;
|
||||
takerAssetFilledAmount: BigNumber;
|
||||
makerFeePaid: BigNumber;
|
||||
takerFeePaid: BigNumber;
|
||||
protocolFeePaid: BigNumber;
|
||||
}>
|
||||
> {
|
||||
const self = (this as any) as BrokerContract;
|
||||
assert.isArray('brokeredTokenIds', brokeredTokenIds);
|
||||
assert.isArray('orders', orders);
|
||||
assert.isArray('takerAssetFillAmounts', takerAssetFillAmounts);
|
||||
assert.isArray('signatures', signatures);
|
||||
assert.isString('batchFillFunctionSelector', batchFillFunctionSelector);
|
||||
assert.isArray('ethFeeAmounts', ethFeeAmounts);
|
||||
assert.isArray('feeRecipients', feeRecipients);
|
||||
const functionSignature =
|
||||
'batchBrokerTrade(uint256[],(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes)[],uint256[],bytes[],bytes4,uint256[],address[])';
|
||||
|
||||
return {
|
||||
async sendTransactionAsync(
|
||||
txData?: Partial<TxData> | undefined,
|
||||
opts: SendTransactionOpts = { shouldValidate: true },
|
||||
): Promise<string> {
|
||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
|
||||
{ ...txData, data: this.getABIEncodedTransactionData() },
|
||||
this.estimateGasAsync.bind(this),
|
||||
);
|
||||
if (opts.shouldValidate !== false) {
|
||||
await this.callAsync(txDataWithDefaults);
|
||||
}
|
||||
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||
},
|
||||
awaitTransactionSuccessAsync(
|
||||
txData?: Partial<TxData>,
|
||||
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
|
||||
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
||||
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
|
||||
},
|
||||
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
|
||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
||||
...txData,
|
||||
data: this.getABIEncodedTransactionData(),
|
||||
});
|
||||
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||
},
|
||||
async callAsync(
|
||||
callData: Partial<CallData> = {},
|
||||
defaultBlock?: BlockParam,
|
||||
): Promise<
|
||||
Array<{
|
||||
makerAssetFilledAmount: BigNumber;
|
||||
takerAssetFilledAmount: BigNumber;
|
||||
makerFeePaid: BigNumber;
|
||||
takerFeePaid: BigNumber;
|
||||
protocolFeePaid: BigNumber;
|
||||
}>
|
||||
> {
|
||||
BaseContract._assertCallParams(callData, defaultBlock);
|
||||
const rawCallResult = await self._performCallAsync(
|
||||
{ ...callData, data: this.getABIEncodedTransactionData() },
|
||||
defaultBlock,
|
||||
);
|
||||
const abiEncoder = self._lookupAbiEncoder(functionSignature);
|
||||
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
|
||||
return abiEncoder.strictDecodeReturnValue<
|
||||
Array<{
|
||||
makerAssetFilledAmount: BigNumber;
|
||||
takerAssetFilledAmount: BigNumber;
|
||||
makerFeePaid: BigNumber;
|
||||
takerFeePaid: BigNumber;
|
||||
protocolFeePaid: BigNumber;
|
||||
}>
|
||||
>(rawCallResult);
|
||||
},
|
||||
getABIEncodedTransactionData(): string {
|
||||
return self._strictEncodeArguments(functionSignature, [
|
||||
brokeredTokenIds,
|
||||
orders,
|
||||
takerAssetFillAmounts,
|
||||
signatures,
|
||||
batchFillFunctionSelector,
|
||||
ethFeeAmounts,
|
||||
feeRecipients,
|
||||
]);
|
||||
},
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Fills a single property-based order by the given amount using the given assets.
|
||||
* Pays protocol fees using either the ETH supplied by the taker to the transaction or
|
||||
* WETH acquired from the maker during settlement. The final WETH balance is sent to the taker.
|
||||
* @param brokeredTokenIds Token IDs specified by the taker to be used to fill
|
||||
* the orders.
|
||||
* @param order The property-based order to fill. The format of a property-
|
||||
* based order is the same as that of a normal order, except the
|
||||
* takerAssetData. Instaed of specifying a specific ERC721 asset,
|
||||
* the takerAssetData should be ERC1155 assetData where the
|
||||
* underlying tokenAddress is this contract's address and the desired
|
||||
* properties are encoded in the extra data field. Also note that
|
||||
* takerFees must be denominated in WETH (or zero).
|
||||
* @param takerAssetFillAmount The amount to fill the order by.
|
||||
* @param signature The maker's signature of the given order.
|
||||
* @param fillFunctionSelector The selector for either `fillOrder` or
|
||||
* `fillOrKillOrder`.
|
||||
* @param ethFeeAmounts Amounts of ETH, denominated in Wei, that are paid to
|
||||
* corresponding feeRecipients.
|
||||
* @param feeRecipients Addresses that will receive ETH when orders are filled.
|
||||
* @returns fillResults Amounts filled and fees paid by the maker and taker.
|
||||
*/
|
||||
public brokerTrade(
|
||||
brokeredTokenIds: BigNumber[],
|
||||
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;
|
||||
makerFeeAssetData: string;
|
||||
takerFeeAssetData: string;
|
||||
},
|
||||
takerAssetFillAmount: BigNumber,
|
||||
signature: string,
|
||||
fillFunctionSelector: string,
|
||||
ethFeeAmounts: BigNumber[],
|
||||
feeRecipients: string[],
|
||||
): ContractTxFunctionObj<{
|
||||
makerAssetFilledAmount: BigNumber;
|
||||
takerAssetFilledAmount: BigNumber;
|
||||
makerFeePaid: BigNumber;
|
||||
takerFeePaid: BigNumber;
|
||||
protocolFeePaid: BigNumber;
|
||||
}> {
|
||||
const self = (this as any) as BrokerContract;
|
||||
assert.isArray('brokeredTokenIds', brokeredTokenIds);
|
||||
|
||||
assert.isBigNumber('takerAssetFillAmount', takerAssetFillAmount);
|
||||
assert.isString('signature', signature);
|
||||
assert.isString('fillFunctionSelector', fillFunctionSelector);
|
||||
assert.isArray('ethFeeAmounts', ethFeeAmounts);
|
||||
assert.isArray('feeRecipients', feeRecipients);
|
||||
const functionSignature =
|
||||
'brokerTrade(uint256[],(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes,bytes,bytes),uint256,bytes,bytes4,uint256[],address[])';
|
||||
|
||||
return {
|
||||
async sendTransactionAsync(
|
||||
txData?: Partial<TxData> | undefined,
|
||||
opts: SendTransactionOpts = { shouldValidate: true },
|
||||
): Promise<string> {
|
||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
|
||||
{ ...txData, data: this.getABIEncodedTransactionData() },
|
||||
this.estimateGasAsync.bind(this),
|
||||
);
|
||||
if (opts.shouldValidate !== false) {
|
||||
await this.callAsync(txDataWithDefaults);
|
||||
}
|
||||
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||
},
|
||||
awaitTransactionSuccessAsync(
|
||||
txData?: Partial<TxData>,
|
||||
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
|
||||
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
||||
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
|
||||
},
|
||||
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
|
||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
||||
...txData,
|
||||
data: this.getABIEncodedTransactionData(),
|
||||
});
|
||||
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||
},
|
||||
async callAsync(
|
||||
callData: Partial<CallData> = {},
|
||||
defaultBlock?: BlockParam,
|
||||
): Promise<{
|
||||
makerAssetFilledAmount: BigNumber;
|
||||
takerAssetFilledAmount: BigNumber;
|
||||
makerFeePaid: BigNumber;
|
||||
takerFeePaid: BigNumber;
|
||||
protocolFeePaid: BigNumber;
|
||||
}> {
|
||||
BaseContract._assertCallParams(callData, defaultBlock);
|
||||
const rawCallResult = await self._performCallAsync(
|
||||
{ ...callData, data: this.getABIEncodedTransactionData() },
|
||||
defaultBlock,
|
||||
);
|
||||
const abiEncoder = self._lookupAbiEncoder(functionSignature);
|
||||
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
|
||||
return abiEncoder.strictDecodeReturnValue<{
|
||||
makerAssetFilledAmount: BigNumber;
|
||||
takerAssetFilledAmount: BigNumber;
|
||||
makerFeePaid: BigNumber;
|
||||
takerFeePaid: BigNumber;
|
||||
protocolFeePaid: BigNumber;
|
||||
}>(rawCallResult);
|
||||
},
|
||||
getABIEncodedTransactionData(): string {
|
||||
return self._strictEncodeArguments(functionSignature, [
|
||||
brokeredTokenIds,
|
||||
order,
|
||||
takerAssetFillAmount,
|
||||
signature,
|
||||
fillFunctionSelector,
|
||||
ethFeeAmounts,
|
||||
feeRecipients,
|
||||
]);
|
||||
},
|
||||
};
|
||||
}
|
||||
/**
|
||||
* The Broker implements the ERC1155 transfer function to be compatible with the ERC1155 asset proxy
|
||||
* @param from Since the Broker serves as the taker of the order, this should
|
||||
* equal `address(this)`
|
||||
* @param to This should be the maker of the order.
|
||||
* @param amounts Should be an array of just one `uint256`, specifying the
|
||||
* amount of the brokered assets to transfer.
|
||||
* @param data Encodes the validator contract address and any auxiliary data it
|
||||
* needs for property validation.
|
||||
*/
|
||||
public safeBatchTransferFrom(
|
||||
from: string,
|
||||
to: string,
|
||||
index_2: BigNumber[],
|
||||
amounts: BigNumber[],
|
||||
data: string,
|
||||
): ContractTxFunctionObj<void> {
|
||||
const self = (this as any) as BrokerContract;
|
||||
assert.isString('from', from);
|
||||
assert.isString('to', to);
|
||||
assert.isArray('index_2', index_2);
|
||||
assert.isArray('amounts', amounts);
|
||||
assert.isString('data', data);
|
||||
const functionSignature = 'safeBatchTransferFrom(address,address,uint256[],uint256[],bytes)';
|
||||
|
||||
return {
|
||||
async sendTransactionAsync(
|
||||
txData?: Partial<TxData> | undefined,
|
||||
opts: SendTransactionOpts = { shouldValidate: true },
|
||||
): Promise<string> {
|
||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
|
||||
{ ...txData, data: this.getABIEncodedTransactionData() },
|
||||
this.estimateGasAsync.bind(this),
|
||||
);
|
||||
if (opts.shouldValidate !== false) {
|
||||
await this.callAsync(txDataWithDefaults);
|
||||
}
|
||||
return self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||
},
|
||||
awaitTransactionSuccessAsync(
|
||||
txData?: Partial<TxData>,
|
||||
opts: AwaitTransactionSuccessOpts = { shouldValidate: true },
|
||||
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
||||
return self._promiseWithTransactionHash(this.sendTransactionAsync(txData, opts), opts);
|
||||
},
|
||||
async estimateGasAsync(txData?: Partial<TxData> | undefined): Promise<number> {
|
||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
||||
...txData,
|
||||
data: this.getABIEncodedTransactionData(),
|
||||
});
|
||||
return self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||
},
|
||||
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<void> {
|
||||
BaseContract._assertCallParams(callData, defaultBlock);
|
||||
const rawCallResult = await self._performCallAsync(
|
||||
{ ...callData, data: this.getABIEncodedTransactionData() },
|
||||
defaultBlock,
|
||||
);
|
||||
const abiEncoder = self._lookupAbiEncoder(functionSignature);
|
||||
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
|
||||
return abiEncoder.strictDecodeReturnValue<void>(rawCallResult);
|
||||
},
|
||||
getABIEncodedTransactionData(): string {
|
||||
return self._strictEncodeArguments(functionSignature, [
|
||||
from.toLowerCase(),
|
||||
to.toLowerCase(),
|
||||
index_2,
|
||||
amounts,
|
||||
data,
|
||||
]);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
constructor(
|
||||
address: string,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults?: Partial<TxData>,
|
||||
logDecodeDependencies?: { [contractName: string]: ContractAbi },
|
||||
deployedBytecode: string | undefined = BrokerContract.deployedBytecode,
|
||||
) {
|
||||
super(
|
||||
'Broker',
|
||||
BrokerContract.ABI(),
|
||||
address,
|
||||
supportedProvider,
|
||||
txDefaults,
|
||||
logDecodeDependencies,
|
||||
deployedBytecode,
|
||||
);
|
||||
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']);
|
||||
BrokerContract.ABI().forEach((item, index) => {
|
||||
if (item.type === 'function') {
|
||||
const methodAbi = item as MethodAbi;
|
||||
this._methodABIIndex[methodAbi.name] = index;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// tslint:disable:max-file-line-count
|
||||
// tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align
|
||||
// tslint:enable:trailing-comma whitespace no-trailing-whitespace
|
248
packages/contract-wrappers/src/generated-wrappers/gods_unchained_validator.ts
generated
Normal file
248
packages/contract-wrappers/src/generated-wrappers/gods_unchained_validator.ts
generated
Normal file
@@ -0,0 +1,248 @@
|
||||
// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma enum-naming
|
||||
// tslint:disable:whitespace no-unbound-method no-trailing-whitespace
|
||||
// tslint:disable:no-unused-variable
|
||||
import {
|
||||
AwaitTransactionSuccessOpts,
|
||||
ContractFunctionObj,
|
||||
ContractTxFunctionObj,
|
||||
SendTransactionOpts,
|
||||
BaseContract,
|
||||
PromiseWithTransactionHash,
|
||||
methodAbiToFunctionSignature,
|
||||
} from '@0x/base-contract';
|
||||
import { schemas } from '@0x/json-schemas';
|
||||
import {
|
||||
BlockParam,
|
||||
BlockParamLiteral,
|
||||
BlockRange,
|
||||
CallData,
|
||||
ContractAbi,
|
||||
ContractArtifact,
|
||||
DecodedLogArgs,
|
||||
MethodAbi,
|
||||
TransactionReceiptWithDecodedLogs,
|
||||
TxData,
|
||||
TxDataPayable,
|
||||
SupportedProvider,
|
||||
} from 'ethereum-types';
|
||||
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
||||
import { EventCallback, IndexedFilterValues, SimpleContractArtifact } from '@0x/types';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { assert } from '@0x/assert';
|
||||
import * as ethers from 'ethers';
|
||||
// tslint:enable:no-unused-variable
|
||||
|
||||
/* istanbul ignore next */
|
||||
// tslint:disable:no-parameter-reassignment
|
||||
// tslint:disable-next-line:class-name
|
||||
export class GodsUnchainedValidatorContract extends BaseContract {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
public static deployedBytecode: string | undefined;
|
||||
public static contractName = 'GodsUnchainedValidator';
|
||||
private readonly _methodABIIndex: { [name: string]: number } = {};
|
||||
public static async deployFrom0xArtifactAsync(
|
||||
artifact: ContractArtifact | SimpleContractArtifact,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
logDecodeDependencies: { [contractName: string]: ContractArtifact | SimpleContractArtifact },
|
||||
_godsUnchained: string,
|
||||
): Promise<GodsUnchainedValidatorContract> {
|
||||
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
|
||||
schemas.addressSchema,
|
||||
schemas.numberSchema,
|
||||
schemas.jsNumber,
|
||||
]);
|
||||
if (artifact.compilerOutput === undefined) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const bytecode = artifact.compilerOutput.evm.bytecode.object;
|
||||
const abi = artifact.compilerOutput.abi;
|
||||
const logDecodeDependenciesAbiOnly: { [contractName: string]: ContractAbi } = {};
|
||||
if (Object.keys(logDecodeDependencies) !== undefined) {
|
||||
for (const key of Object.keys(logDecodeDependencies)) {
|
||||
logDecodeDependenciesAbiOnly[key] = logDecodeDependencies[key].compilerOutput.abi;
|
||||
}
|
||||
}
|
||||
return GodsUnchainedValidatorContract.deployAsync(
|
||||
bytecode,
|
||||
abi,
|
||||
provider,
|
||||
txDefaults,
|
||||
logDecodeDependenciesAbiOnly,
|
||||
_godsUnchained,
|
||||
);
|
||||
}
|
||||
public static async deployAsync(
|
||||
bytecode: string,
|
||||
abi: ContractAbi,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
logDecodeDependencies: { [contractName: string]: ContractAbi },
|
||||
_godsUnchained: string,
|
||||
): Promise<GodsUnchainedValidatorContract> {
|
||||
assert.isHexString('bytecode', bytecode);
|
||||
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
|
||||
schemas.addressSchema,
|
||||
schemas.numberSchema,
|
||||
schemas.jsNumber,
|
||||
]);
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
|
||||
[_godsUnchained] = BaseContract._formatABIDataItemList(
|
||||
constructorAbi.inputs,
|
||||
[_godsUnchained],
|
||||
BaseContract._bigNumberToString,
|
||||
);
|
||||
const iface = new ethers.utils.Interface(abi);
|
||||
const deployInfo = iface.deployFunction;
|
||||
const txData = deployInfo.encode(bytecode, [_godsUnchained]);
|
||||
const web3Wrapper = new Web3Wrapper(provider);
|
||||
const txDataWithDefaults = await BaseContract._applyDefaultsToContractTxDataAsync(
|
||||
{
|
||||
data: txData,
|
||||
...txDefaults,
|
||||
},
|
||||
web3Wrapper.estimateGasAsync.bind(web3Wrapper),
|
||||
);
|
||||
const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||
logUtils.log(`transactionHash: ${txHash}`);
|
||||
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
|
||||
logUtils.log(`GodsUnchainedValidator successfully deployed at ${txReceipt.contractAddress}`);
|
||||
const contractInstance = new GodsUnchainedValidatorContract(
|
||||
txReceipt.contractAddress as string,
|
||||
provider,
|
||||
txDefaults,
|
||||
logDecodeDependencies,
|
||||
);
|
||||
contractInstance.constructorArgs = [_godsUnchained];
|
||||
return contractInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns The contract ABI
|
||||
*/
|
||||
public static ABI(): ContractAbi {
|
||||
const abi = [
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
name: '_godsUnchained',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
outputs: [],
|
||||
payable: false,
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'constructor',
|
||||
},
|
||||
{
|
||||
constant: true,
|
||||
inputs: [
|
||||
{
|
||||
name: 'tokenId',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
name: 'propertyData',
|
||||
type: 'bytes',
|
||||
},
|
||||
],
|
||||
name: 'checkBrokerAsset',
|
||||
outputs: [],
|
||||
payable: false,
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
] as ContractAbi;
|
||||
return abi;
|
||||
}
|
||||
|
||||
public getFunctionSignature(methodName: string): string {
|
||||
const index = this._methodABIIndex[methodName];
|
||||
const methodAbi = GodsUnchainedValidatorContract.ABI()[index] as MethodAbi; // tslint:disable-line:no-unnecessary-type-assertion
|
||||
const functionSignature = methodAbiToFunctionSignature(methodAbi);
|
||||
return functionSignature;
|
||||
}
|
||||
public getABIDecodedTransactionData<T>(methodName: string, callData: string): T {
|
||||
const functionSignature = this.getFunctionSignature(methodName);
|
||||
const self = (this as any) as GodsUnchainedValidatorContract;
|
||||
const abiEncoder = self._lookupAbiEncoder(functionSignature);
|
||||
const abiDecodedCallData = abiEncoder.strictDecode<T>(callData);
|
||||
return abiDecodedCallData;
|
||||
}
|
||||
public getABIDecodedReturnData<T>(methodName: string, callData: string): T {
|
||||
const functionSignature = this.getFunctionSignature(methodName);
|
||||
const self = (this as any) as GodsUnchainedValidatorContract;
|
||||
const abiEncoder = self._lookupAbiEncoder(functionSignature);
|
||||
const abiDecodedCallData = abiEncoder.strictDecodeReturnValue<T>(callData);
|
||||
return abiDecodedCallData;
|
||||
}
|
||||
public getSelector(methodName: string): string {
|
||||
const functionSignature = this.getFunctionSignature(methodName);
|
||||
const self = (this as any) as GodsUnchainedValidatorContract;
|
||||
const abiEncoder = self._lookupAbiEncoder(functionSignature);
|
||||
return abiEncoder.getSelector();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the given card (encoded as assetData) has the proto and quality encoded in `propertyData`.
|
||||
* Reverts if the card doesn't match the specified proto and quality.
|
||||
* @param tokenId The ERC721 tokenId of the card to check.
|
||||
* @param propertyData Encoded proto and quality that the card is expected to
|
||||
* have.
|
||||
*/
|
||||
public checkBrokerAsset(tokenId: BigNumber, propertyData: string): ContractFunctionObj<void> {
|
||||
const self = (this as any) as GodsUnchainedValidatorContract;
|
||||
assert.isBigNumber('tokenId', tokenId);
|
||||
assert.isString('propertyData', propertyData);
|
||||
const functionSignature = 'checkBrokerAsset(uint256,bytes)';
|
||||
|
||||
return {
|
||||
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<void> {
|
||||
BaseContract._assertCallParams(callData, defaultBlock);
|
||||
const rawCallResult = await self._performCallAsync(
|
||||
{ ...callData, data: this.getABIEncodedTransactionData() },
|
||||
defaultBlock,
|
||||
);
|
||||
const abiEncoder = self._lookupAbiEncoder(functionSignature);
|
||||
BaseContract._throwIfUnexpectedEmptyCallResult(rawCallResult, abiEncoder);
|
||||
return abiEncoder.strictDecodeReturnValue<void>(rawCallResult);
|
||||
},
|
||||
getABIEncodedTransactionData(): string {
|
||||
return self._strictEncodeArguments(functionSignature, [tokenId, propertyData]);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
constructor(
|
||||
address: string,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults?: Partial<TxData>,
|
||||
logDecodeDependencies?: { [contractName: string]: ContractAbi },
|
||||
deployedBytecode: string | undefined = GodsUnchainedValidatorContract.deployedBytecode,
|
||||
) {
|
||||
super(
|
||||
'GodsUnchainedValidator',
|
||||
GodsUnchainedValidatorContract.ABI(),
|
||||
address,
|
||||
supportedProvider,
|
||||
txDefaults,
|
||||
logDecodeDependencies,
|
||||
deployedBytecode,
|
||||
);
|
||||
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']);
|
||||
GodsUnchainedValidatorContract.ABI().forEach((item, index) => {
|
||||
if (item.type === 'function') {
|
||||
const methodAbi = item as MethodAbi;
|
||||
this._methodABIIndex[methodAbi.name] = index;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// tslint:disable:max-file-line-count
|
||||
// tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align
|
||||
// tslint:enable:trailing-comma whitespace no-trailing-whitespace
|
@@ -287,8 +287,6 @@ export async function runMigrationsAsync(
|
||||
erc20BridgeProxy: erc20BridgeProxy.address,
|
||||
zeroExGovernor: constants.NULL_ADDRESS,
|
||||
forwarder: forwarder.address,
|
||||
orderValidator: constants.NULL_ADDRESS,
|
||||
dutchAuction: constants.NULL_ADDRESS,
|
||||
coordinatorRegistry: coordinatorRegistry.address,
|
||||
coordinator: coordinator.address,
|
||||
multiAssetProxy: multiAssetProxy.address,
|
||||
|
@@ -46,12 +46,6 @@ class ContractAddresses(NamedTuple):
|
||||
forwarder: str
|
||||
"""Address of the Forwarder contract."""
|
||||
|
||||
order_validator: str
|
||||
"""Address of the OrderValidator contract."""
|
||||
|
||||
dutch_auction: str
|
||||
"""Address of the DutchAuction contract."""
|
||||
|
||||
coordinator_registry: str
|
||||
"""Address of the CoordinatorRegistry contract."""
|
||||
|
||||
@@ -146,8 +140,6 @@ def chain_to_addresses(chain_id: ChainId) -> ContractAddresses:
|
||||
asset_proxy_owner=addresses["assetProxyOwner"],
|
||||
zero_ex_governor=addresses["zeroExGovernor"],
|
||||
forwarder=addresses["forwarder"],
|
||||
order_validator=addresses["orderValidator"],
|
||||
dutch_auction=addresses["dutchAuction"],
|
||||
coordinator_registry=addresses["coordinatorRegistry"],
|
||||
coordinator=addresses["coordinator"],
|
||||
multi_asset_proxy=addresses["multiAssetProxy"],
|
||||
|
Reference in New Issue
Block a user