mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
add estimateGas parameter to NFTFactory
This commit is contained in:
parent
e52c8a10e0
commit
5145d9706c
@ -222,10 +222,11 @@ export class NftFactory extends SmartContractWithAddress {
|
|||||||
* @param {Number} templateIndex index of the template we want to disable
|
* @param {Number} templateIndex index of the template we want to disable
|
||||||
* @return {Promise<TransactionReceipt>} current token template count
|
* @return {Promise<TransactionReceipt>} current token template count
|
||||||
*/
|
*/
|
||||||
public async disableNFTTemplate(
|
public async disableNFTTemplate<G extends boolean = false>(
|
||||||
address: string,
|
address: string,
|
||||||
templateIndex: number
|
templateIndex: number,
|
||||||
): Promise<TransactionReceipt> {
|
estimateGas?: G
|
||||||
|
): Promise<G extends false ? TransactionReceipt : number> {
|
||||||
if ((await this.getOwner()) !== address) {
|
if ((await this.getOwner()) !== address) {
|
||||||
throw new Error(`Caller is not Factory Owner`)
|
throw new Error(`Caller is not Factory Owner`)
|
||||||
}
|
}
|
||||||
@ -241,6 +242,7 @@ export class NftFactory extends SmartContractWithAddress {
|
|||||||
this.contract.methods.disable721TokenTemplate,
|
this.contract.methods.disable721TokenTemplate,
|
||||||
templateIndex
|
templateIndex
|
||||||
)
|
)
|
||||||
|
if (estimateGas) return estGas
|
||||||
|
|
||||||
// Invoke createToken function of the contract
|
// Invoke createToken function of the contract
|
||||||
const trxReceipt = await this.contract.methods
|
const trxReceipt = await this.contract.methods
|
||||||
@ -260,10 +262,11 @@ export class NftFactory extends SmartContractWithAddress {
|
|||||||
* @param {Number} templateIndex index of the template we want to reactivate
|
* @param {Number} templateIndex index of the template we want to reactivate
|
||||||
* @return {Promise<TransactionReceipt>} current token template count
|
* @return {Promise<TransactionReceipt>} current token template count
|
||||||
*/
|
*/
|
||||||
public async reactivateNFTTemplate(
|
public async reactivateNFTTemplate<G extends boolean = false>(
|
||||||
address: string,
|
address: string,
|
||||||
templateIndex: number
|
templateIndex: number,
|
||||||
): Promise<TransactionReceipt> {
|
estimateGas?: G
|
||||||
|
): Promise<G extends false ? TransactionReceipt : number> {
|
||||||
if ((await this.getOwner()) !== address) {
|
if ((await this.getOwner()) !== address) {
|
||||||
throw new Error(`Caller is not Factory Owner`)
|
throw new Error(`Caller is not Factory Owner`)
|
||||||
}
|
}
|
||||||
@ -280,6 +283,7 @@ export class NftFactory extends SmartContractWithAddress {
|
|||||||
this.contract.methods.reactivate721TokenTemplate,
|
this.contract.methods.reactivate721TokenTemplate,
|
||||||
templateIndex
|
templateIndex
|
||||||
)
|
)
|
||||||
|
if (estimateGas) return estGas
|
||||||
|
|
||||||
// Invoke createToken function of the contract
|
// Invoke createToken function of the contract
|
||||||
const trxReceipt = await this.contract.methods
|
const trxReceipt = await this.contract.methods
|
||||||
@ -299,10 +303,11 @@ export class NftFactory extends SmartContractWithAddress {
|
|||||||
* @param {String} templateAddress template address to add
|
* @param {String} templateAddress template address to add
|
||||||
* @return {Promise<TransactionReceipt>}
|
* @return {Promise<TransactionReceipt>}
|
||||||
*/
|
*/
|
||||||
public async addTokenTemplate(
|
public async addTokenTemplate<G extends boolean = false>(
|
||||||
address: string,
|
address: string,
|
||||||
templateAddress: string
|
templateAddress: string,
|
||||||
): Promise<TransactionReceipt> {
|
estimateGas?: G
|
||||||
|
): Promise<G extends false ? TransactionReceipt : number> {
|
||||||
if ((await this.getOwner()) !== address) {
|
if ((await this.getOwner()) !== address) {
|
||||||
throw new Error(`Caller is not Factory Owner`)
|
throw new Error(`Caller is not Factory Owner`)
|
||||||
}
|
}
|
||||||
@ -315,6 +320,7 @@ export class NftFactory extends SmartContractWithAddress {
|
|||||||
this.contract.methods.addTokenTemplate,
|
this.contract.methods.addTokenTemplate,
|
||||||
templateAddress
|
templateAddress
|
||||||
)
|
)
|
||||||
|
if (estimateGas) return estGas
|
||||||
|
|
||||||
// Invoke createToken function of the contract
|
// Invoke createToken function of the contract
|
||||||
const trxReceipt = await this.contract.methods
|
const trxReceipt = await this.contract.methods
|
||||||
@ -334,10 +340,11 @@ export class NftFactory extends SmartContractWithAddress {
|
|||||||
* @param {Number} templateIndex index of the template we want to disable
|
* @param {Number} templateIndex index of the template we want to disable
|
||||||
* @return {Promise<TransactionReceipt>} current token template count
|
* @return {Promise<TransactionReceipt>} current token template count
|
||||||
*/
|
*/
|
||||||
public async disableTokenTemplate(
|
public async disableTokenTemplate<G extends boolean = false>(
|
||||||
address: string,
|
address: string,
|
||||||
templateIndex: number
|
templateIndex: number,
|
||||||
): Promise<TransactionReceipt> {
|
estimateGas?: G
|
||||||
|
): Promise<G extends false ? TransactionReceipt : number> {
|
||||||
if ((await this.getOwner()) !== address) {
|
if ((await this.getOwner()) !== address) {
|
||||||
throw new Error(`Caller is not Factory Owner`)
|
throw new Error(`Caller is not Factory Owner`)
|
||||||
}
|
}
|
||||||
@ -356,6 +363,7 @@ export class NftFactory extends SmartContractWithAddress {
|
|||||||
this.contract.methods.disableTokenTemplate,
|
this.contract.methods.disableTokenTemplate,
|
||||||
templateIndex
|
templateIndex
|
||||||
)
|
)
|
||||||
|
if (estimateGas) return estGas
|
||||||
|
|
||||||
// Invoke createToken function of the contract
|
// Invoke createToken function of the contract
|
||||||
const trxReceipt = await this.contract.methods
|
const trxReceipt = await this.contract.methods
|
||||||
@ -375,10 +383,11 @@ export class NftFactory extends SmartContractWithAddress {
|
|||||||
* @param {Number} templateIndex index of the template we want to reactivate
|
* @param {Number} templateIndex index of the template we want to reactivate
|
||||||
* @return {Promise<TransactionReceipt>} current token template count
|
* @return {Promise<TransactionReceipt>} current token template count
|
||||||
*/
|
*/
|
||||||
public async reactivateTokenTemplate(
|
public async reactivateTokenTemplate<G extends boolean = false>(
|
||||||
address: string,
|
address: string,
|
||||||
templateIndex: number
|
templateIndex: number,
|
||||||
): Promise<TransactionReceipt> {
|
estimateGas?: G
|
||||||
|
): Promise<G extends false ? TransactionReceipt : number> {
|
||||||
if ((await this.getOwner()) !== address) {
|
if ((await this.getOwner()) !== address) {
|
||||||
throw new Error(`Caller is not Factory Owner`)
|
throw new Error(`Caller is not Factory Owner`)
|
||||||
}
|
}
|
||||||
@ -398,6 +407,7 @@ export class NftFactory extends SmartContractWithAddress {
|
|||||||
this.contract.methods.reactivateTokenTemplate,
|
this.contract.methods.reactivateTokenTemplate,
|
||||||
templateIndex
|
templateIndex
|
||||||
)
|
)
|
||||||
|
if (estimateGas) return estGas
|
||||||
|
|
||||||
// Invoke createToken function of the contract
|
// Invoke createToken function of the contract
|
||||||
const trxReceipt = await this.contract.methods
|
const trxReceipt = await this.contract.methods
|
||||||
@ -423,10 +433,11 @@ export class NftFactory extends SmartContractWithAddress {
|
|||||||
* @param orders an array of struct tokenOrder
|
* @param orders an array of struct tokenOrder
|
||||||
* @return {Promise<TransactionReceipt>} transaction receipt
|
* @return {Promise<TransactionReceipt>} transaction receipt
|
||||||
*/
|
*/
|
||||||
public async startMultipleTokenOrder(
|
public async startMultipleTokenOrder<G extends boolean = false>(
|
||||||
address: string,
|
address: string,
|
||||||
orders: TokenOrder[]
|
orders: TokenOrder[],
|
||||||
): Promise<TransactionReceipt> {
|
estimateGas?: G
|
||||||
|
): Promise<G extends false ? TransactionReceipt : number> {
|
||||||
if (orders.length > 50) {
|
if (orders.length > 50) {
|
||||||
throw new Error(`Too many orders`)
|
throw new Error(`Too many orders`)
|
||||||
}
|
}
|
||||||
@ -436,6 +447,7 @@ export class NftFactory extends SmartContractWithAddress {
|
|||||||
this.contract.methods.startMultipleTokenOrder,
|
this.contract.methods.startMultipleTokenOrder,
|
||||||
orders
|
orders
|
||||||
)
|
)
|
||||||
|
if (estimateGas) return estGas
|
||||||
|
|
||||||
// Invoke createToken function of the contract
|
// Invoke createToken function of the contract
|
||||||
const trxReceipt = await this.contract.methods.startMultipleTokenOrder(orders).send({
|
const trxReceipt = await this.contract.methods.startMultipleTokenOrder(orders).send({
|
||||||
@ -456,11 +468,12 @@ export class NftFactory extends SmartContractWithAddress {
|
|||||||
* @return {Promise<TransactionReceipt>} transaction receipt
|
* @return {Promise<TransactionReceipt>} transaction receipt
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public async createNftWithDatatoken(
|
public async createNftWithDatatoken<G extends boolean = false>(
|
||||||
address: string,
|
address: string,
|
||||||
nftCreateData: NftCreateData,
|
nftCreateData: NftCreateData,
|
||||||
ercParams: DatatokenCreateParams
|
ercParams: DatatokenCreateParams,
|
||||||
): Promise<TransactionReceipt> {
|
estimateGas?: G
|
||||||
|
): Promise<G extends false ? TransactionReceipt : number> {
|
||||||
const ercCreateData = this.getErcCreationParams(ercParams)
|
const ercCreateData = this.getErcCreationParams(ercParams)
|
||||||
|
|
||||||
const estGas = await calculateEstimatedGas(
|
const estGas = await calculateEstimatedGas(
|
||||||
@ -469,6 +482,7 @@ export class NftFactory extends SmartContractWithAddress {
|
|||||||
nftCreateData,
|
nftCreateData,
|
||||||
ercCreateData
|
ercCreateData
|
||||||
)
|
)
|
||||||
|
if (estimateGas) return estGas
|
||||||
|
|
||||||
// Invoke createToken function of the contract
|
// Invoke createToken function of the contract
|
||||||
const trxReceipt = await this.contract.methods
|
const trxReceipt = await this.contract.methods
|
||||||
@ -492,12 +506,13 @@ export class NftFactory extends SmartContractWithAddress {
|
|||||||
* @param poolParams input data for Pool Creation
|
* @param poolParams input data for Pool Creation
|
||||||
* @return {Promise<TransactionReceipt>} transaction receipt
|
* @return {Promise<TransactionReceipt>} transaction receipt
|
||||||
*/
|
*/
|
||||||
public async createNftWithDatatokenWithPool(
|
public async createNftWithDatatokenWithPool<G extends boolean = false>(
|
||||||
address: string,
|
address: string,
|
||||||
nftCreateData: NftCreateData,
|
nftCreateData: NftCreateData,
|
||||||
ercParams: DatatokenCreateParams,
|
ercParams: DatatokenCreateParams,
|
||||||
poolParams: PoolCreationParams
|
poolParams: PoolCreationParams,
|
||||||
): Promise<TransactionReceipt> {
|
estimateGas?: G
|
||||||
|
): Promise<G extends false ? TransactionReceipt : number> {
|
||||||
const ercCreateData = this.getErcCreationParams(ercParams)
|
const ercCreateData = this.getErcCreationParams(ercParams)
|
||||||
const poolData = await this.getPoolCreationParams(poolParams)
|
const poolData = await this.getPoolCreationParams(poolParams)
|
||||||
|
|
||||||
@ -508,6 +523,7 @@ export class NftFactory extends SmartContractWithAddress {
|
|||||||
ercCreateData,
|
ercCreateData,
|
||||||
poolData
|
poolData
|
||||||
)
|
)
|
||||||
|
if (estimateGas) return estGas
|
||||||
|
|
||||||
// Invoke createToken function of the contract
|
// Invoke createToken function of the contract
|
||||||
const trxReceipt = await this.contract.methods
|
const trxReceipt = await this.contract.methods
|
||||||
@ -531,12 +547,13 @@ export class NftFactory extends SmartContractWithAddress {
|
|||||||
* @param freParams input data for FixedRate Creation
|
* @param freParams input data for FixedRate Creation
|
||||||
* @return {Promise<TransactionReceipt>} transaction receipt
|
* @return {Promise<TransactionReceipt>} transaction receipt
|
||||||
*/
|
*/
|
||||||
public async createNftWithDatatokenWithFixedRate(
|
public async createNftWithDatatokenWithFixedRate<G extends boolean = false>(
|
||||||
address: string,
|
address: string,
|
||||||
nftCreateData: NftCreateData,
|
nftCreateData: NftCreateData,
|
||||||
ercParams: DatatokenCreateParams,
|
ercParams: DatatokenCreateParams,
|
||||||
freParams: FreCreationParams
|
freParams: FreCreationParams,
|
||||||
): Promise<TransactionReceipt> {
|
estimateGas?: G
|
||||||
|
): Promise<G extends false ? TransactionReceipt : number> {
|
||||||
const ercCreateData = this.getErcCreationParams(ercParams)
|
const ercCreateData = this.getErcCreationParams(ercParams)
|
||||||
const fixedData = this.getFreCreationParams(freParams)
|
const fixedData = this.getFreCreationParams(freParams)
|
||||||
|
|
||||||
@ -547,6 +564,7 @@ export class NftFactory extends SmartContractWithAddress {
|
|||||||
ercCreateData,
|
ercCreateData,
|
||||||
fixedData
|
fixedData
|
||||||
)
|
)
|
||||||
|
if (estimateGas) return estGas
|
||||||
|
|
||||||
// Invoke createToken function of the contract
|
// Invoke createToken function of the contract
|
||||||
const trxReceipt = await this.contract.methods
|
const trxReceipt = await this.contract.methods
|
||||||
@ -570,12 +588,13 @@ export class NftFactory extends SmartContractWithAddress {
|
|||||||
* @param dispenserParams input data for Dispenser Creation
|
* @param dispenserParams input data for Dispenser Creation
|
||||||
* @return {Promise<TransactionReceipt>} transaction receipt
|
* @return {Promise<TransactionReceipt>} transaction receipt
|
||||||
*/
|
*/
|
||||||
public async createNftWithDatatokenWithDispenser(
|
public async createNftWithDatatokenWithDispenser<G extends boolean = false>(
|
||||||
address: string,
|
address: string,
|
||||||
nftCreateData: NftCreateData,
|
nftCreateData: NftCreateData,
|
||||||
ercParams: DatatokenCreateParams,
|
ercParams: DatatokenCreateParams,
|
||||||
dispenserParams: DispenserCreationParams
|
dispenserParams: DispenserCreationParams,
|
||||||
): Promise<TransactionReceipt> {
|
estimateGas?: G
|
||||||
|
): Promise<G extends false ? TransactionReceipt : number> {
|
||||||
const ercCreateData = this.getErcCreationParams(ercParams)
|
const ercCreateData = this.getErcCreationParams(ercParams)
|
||||||
|
|
||||||
dispenserParams.maxBalance = Web3.utils.toWei(dispenserParams.maxBalance)
|
dispenserParams.maxBalance = Web3.utils.toWei(dispenserParams.maxBalance)
|
||||||
@ -588,6 +607,7 @@ export class NftFactory extends SmartContractWithAddress {
|
|||||||
ercCreateData,
|
ercCreateData,
|
||||||
dispenserParams
|
dispenserParams
|
||||||
)
|
)
|
||||||
|
if (estimateGas) return estGas
|
||||||
|
|
||||||
// Invoke createToken function of the contract
|
// Invoke createToken function of the contract
|
||||||
const trxReceipt = await this.contract.methods
|
const trxReceipt = await this.contract.methods
|
||||||
|
Loading…
x
Reference in New Issue
Block a user