/* * This file is auto-generated using abi-gen. Any changes will be reverted */ // Needed for the promisifed events, some contracts don't have events // tslint:disable:no-unused-variable import { DecodedLogEntryEvent, DecodedLogEntry, DecodedTransactionReceipt } from "@joincivil/typescript-types"; // tslint:enable:no-unused-variable import "rxjs/add/operator/distinctUntilChanged"; import {Contract} from "web3-eth-contract"; import {TransactionConfig, TransactionConfig as SendOptions} from "web3-core"; import { bindNestedAll, isDefined, CivilErrors } from "@joincivil/utils"; import * as Debug from "debug"; import { EthAddress, TxHash } from "@joincivil/typescript-types"; import { streamifyEvent } from "../../../contracts/utils/contracts"; import { EthApi, currentNetwork } from "@joincivil/ethapi"; import { BaseContract } from "../../basecontract"; import { artifacts } from "../artifacts"; // hack(dankins): abi-gen things these are bignumber.js, but they are actually returned as strings // https://github.com/0xProject/0x-monorepo/blob/development/packages/abi-gen/src/utils.ts#L64 type BigNumber = string; const debug = Debug("civil:contracts:NoOpTokenControllerContract"); export class NoOpTokenControllerContract extends BaseContract { // tslint:disable:member-ordering public static async singletonTrusted(ethApi: EthApi): Promise { if (!artifacts.NoOpTokenController.networks) { debug("Trying to get singleton from contract without any singleton data"); return undefined; } const networkId = (await currentNetwork(ethApi)).toString(); const networkData = artifacts.NoOpTokenController.networks[networkId]; if (!networkData) { debug("Failed to find network data for network ID " + networkId + ". Supported networks: " + Object.keys(artifacts.NoOpTokenController.networks)); return undefined; } return NoOpTokenControllerContract.atUntrusted(ethApi, networkData.address); } public static atUntrusted(ethApi: EthApi, address: EthAddress): NoOpTokenControllerContract { const contract = ethApi.getContractClass(artifacts.NoOpTokenController.abi, address); return new NoOpTokenControllerContract(contract, ethApi); } // TODO(ritave): This code won't work with smart-contracts with library links // see [ch429] in Clubhouse public static deployTrusted = { async sendTransactionAsync( ethApi: EthApi, options: SendOptions): Promise { if (!options.gas) { options.gas = await NoOpTokenControllerContract.deployTrusted .estimateGasAsync( ethApi, ); } if (!options.gasPrice) { options.gasPrice = (await ethApi.getGasPrice()).toString(); } const clazz = ethApi.getContractClass(artifacts.NoOpTokenController.abi); return new Promise( (resolve, reject) => { /* There's a bug in Metamask, this callback should be called twice, first when the transaction * gets into mempool, and second when it's mined. But it's called only once, so we have to resolve * the contract on our own */ const tx = clazz.deploy({data: artifacts.NoOpTokenController.bytecode, arguments: []}).send(options); return tx.once("transactionHash", resolve) }) }, async estimateGasAsync( ethApi: EthApi, ): Promise { const clazz = ethApi.getContractClass(artifacts.NoOpTokenController.abi); const contractData = clazz.deploy({ data: artifacts.NoOpTokenController.bytecode, arguments: [] }).encodeABI(); return ethApi.estimateGas({data: contractData}); }, }; // tslint:disable:variable-name public SUCCESS_CODE = { async callAsync( ): Promise { const self = this as NoOpTokenControllerContract; return self.instance.methods.SUCCESS_CODE().call(); } } public SUCCESS_MESSAGE = { async callAsync( ): Promise { const self = this as NoOpTokenControllerContract; return self.instance.methods.SUCCESS_MESSAGE().call(); } } public detectTransferRestriction = { async callAsync( from: string, to: string, value: BigNumber, ): Promise { const self = this as NoOpTokenControllerContract; return self.instance.methods.detectTransferRestriction(from, to, value, ).call(); } } public messageForTransferRestriction = { async callAsync( restrictionCode: number|BigNumber, ): Promise { const self = this as NoOpTokenControllerContract; return self.instance.methods.messageForTransferRestriction(restrictionCode, ).call(); } } // tslint:enable:variable-name private constructor(instance: Contract, ethApi: EthApi) { super(instance, ethApi); // Call methods access this instance while being in a sub-object, we're rebinding what // "this" means for everything in this class, this also requires "noImplicitThis" to be false bindNestedAll(this, ["constructor", "instance", "defaults", "ethApi"]); } // tslint:enable:member-ordering } // tslint:disable:no-namespace export namespace NoOpTokenController { export enum Events { } // tslint:disable:class-name export namespace Args { } // tslint:enable:class-name export namespace Logs { export type All = never; } export namespace LogEvents { export type All = never; } export type Receipt = DecodedTransactionReceipt; export type EventReceipt = DecodedTransactionReceipt; } // tslint:enable:no-namespace