mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
add estimategas optional parameter to functions
This commit is contained in:
parent
6a193ac88d
commit
2ec7bd7f70
@ -16,7 +16,8 @@
|
|||||||
"rules": {
|
"rules": {
|
||||||
"no-empty": ["error", { "allowEmptyCatch": true }],
|
"no-empty": ["error", { "allowEmptyCatch": true }],
|
||||||
"prefer-destructuring": ["warn", { "object": true, "array": false }],
|
"prefer-destructuring": ["warn", { "object": true, "array": false }],
|
||||||
"no-dupe-class-members": ["warn"],
|
"no-dupe-class-members": "off",
|
||||||
|
"no-redeclare": "off",
|
||||||
"no-useless-constructor": ["warn"],
|
"no-useless-constructor": ["warn"],
|
||||||
"no-unused-vars": ["warn"],
|
"no-unused-vars": ["warn"],
|
||||||
"constructor-super": ["warn"]
|
"constructor-super": ["warn"]
|
||||||
|
@ -33,7 +33,11 @@ export class NftFactory extends SmartContractWithAddress {
|
|||||||
* @param {NFTCreateData} nftData
|
* @param {NFTCreateData} nftData
|
||||||
* @return {Promise<string>} NFT datatoken address
|
* @return {Promise<string>} NFT datatoken address
|
||||||
*/
|
*/
|
||||||
public async createNFT(address: string, nftData: NftCreateData): Promise<string> {
|
public async createNFT<G extends boolean = false>(
|
||||||
|
address: string,
|
||||||
|
nftData: NftCreateData,
|
||||||
|
estimateGas?: G
|
||||||
|
): Promise<G extends false ? string : number> {
|
||||||
if (!nftData.templateIndex) nftData.templateIndex = 1
|
if (!nftData.templateIndex) nftData.templateIndex = 1
|
||||||
|
|
||||||
if (!nftData.name || !nftData.symbol) {
|
if (!nftData.name || !nftData.symbol) {
|
||||||
@ -63,6 +67,7 @@ export class NftFactory extends SmartContractWithAddress {
|
|||||||
nftData.transferable,
|
nftData.transferable,
|
||||||
nftData.owner
|
nftData.owner
|
||||||
)
|
)
|
||||||
|
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
|
||||||
@ -180,10 +185,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 addNFTTemplate(
|
public async addNFTTemplate<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`)
|
||||||
}
|
}
|
||||||
@ -196,6 +202,7 @@ export class NftFactory extends SmartContractWithAddress {
|
|||||||
this.contract.methods.add721TokenTemplate,
|
this.contract.methods.add721TokenTemplate,
|
||||||
templateAddress
|
templateAddress
|
||||||
)
|
)
|
||||||
|
if (estimateGas) return estGas
|
||||||
|
|
||||||
// Invoke add721TokenTemplate function of the contract
|
// Invoke add721TokenTemplate 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