mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
more cleanup and jsdoc updates
This commit is contained in:
parent
e5bfd3e6bd
commit
967f6642fb
@ -1,6 +1,6 @@
|
||||
export interface MetadataAlgorithm {
|
||||
/**
|
||||
* Language used to implement the software.
|
||||
* Programming language used to implement the software.
|
||||
* @type {string}
|
||||
*/
|
||||
language?: string
|
||||
@ -125,7 +125,7 @@ export interface Metadata {
|
||||
contentLanguage?: string
|
||||
|
||||
/**
|
||||
* Information about asset of typealgorithm
|
||||
* Information about asset of type algorithm. Required for algorithm assets.
|
||||
* @type {MetadataAlgorithm}
|
||||
*/
|
||||
algorithm?: MetadataAlgorithm
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { AbiItem } from 'web3-utils'
|
||||
import { AbiItem } from './Contracts'
|
||||
|
||||
interface FileTypeHeaders {
|
||||
[key: string]: string
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { AbiItem } from 'web3-utils/types'
|
||||
import { AbiItem } from '../@types'
|
||||
import { LogLevel } from '../utils'
|
||||
|
||||
export class Config {
|
||||
@ -26,6 +26,7 @@ export class Config {
|
||||
*/
|
||||
public providerUri?: string
|
||||
|
||||
// TODO: check if this is still necesary
|
||||
/**
|
||||
* Web3 Provider.
|
||||
* @type {any}
|
||||
|
@ -205,6 +205,12 @@ export class ConfigHelper {
|
||||
return configAddresses
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the config object for a specific network supported by the oceanprotocol stack
|
||||
* @param {string | number} network the network's chainId or name
|
||||
* @param {string} infuraProjectId optional infura project id that will replace the configs node URI
|
||||
* @return {Config} Config obhjedct
|
||||
*/
|
||||
public getConfig(network: string | number, infuraProjectId?: string): Config {
|
||||
const filterBy = typeof network === 'string' ? 'network' : 'chainId'
|
||||
let config = configHelperNetworks.find((c) => c[filterBy] === network)
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { ethers, Signer, BigNumber } from 'ethers'
|
||||
import { Interface } from 'ethers/lib/utils'
|
||||
import { ethers, Signer } from 'ethers'
|
||||
import Decimal from 'decimal.js'
|
||||
import ERC20Template from '@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template.sol/ERC20Template.json'
|
||||
import ERC20TemplateEnterprise from '@oceanprotocol/contracts/artifacts/contracts/templates/ERC20TemplateEnterprise.sol/ERC20TemplateEnterprise.json'
|
||||
@ -29,12 +28,12 @@ export class Datatoken extends SmartContract {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiate ERC20 Datatokens
|
||||
* @param {Signer} signer
|
||||
* @param {string | number} network optional network name or chain id
|
||||
* @param {Config} config optional config object
|
||||
* @param {AbiItem[]} abi optional abi
|
||||
* @param {AbiItem[]} abiEnterprise optional enterprise abi
|
||||
* Instantiate Datatoken class
|
||||
* @param {Signer} signer The signer object.
|
||||
* @param {string | number} [network] Network id or name
|
||||
* @param {Config} [config] The configuration object.
|
||||
* @param {AbiItem[]} [abi] ABI array of the smart contract
|
||||
* @param {AbiItem[]} abiEnterprise Enterprise ABI array of the smart contract
|
||||
*/
|
||||
constructor(
|
||||
signer: Signer,
|
||||
@ -49,12 +48,12 @@ export class Datatoken extends SmartContract {
|
||||
}
|
||||
|
||||
/**
|
||||
* Approve
|
||||
* Approves a spender to spend a certain amount of datatokens.
|
||||
* @param {String} dtAddress Datatoken address
|
||||
* @param {String} spender Spender address
|
||||
* @param {string} amount Number of datatokens, as number. Will be converted to wei
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* @return {Promise<ReceiptOrEstimate>} trxReceipt
|
||||
* @return {Promise<ReceiptOrEstimate>}
|
||||
*/
|
||||
public async approve<G extends boolean = false>(
|
||||
dtAddress: string,
|
||||
@ -85,9 +84,9 @@ export class Datatoken extends SmartContract {
|
||||
* Creates a new FixedRateExchange setup.
|
||||
* @param {String} dtAddress Datatoken address
|
||||
* @param {String} address Caller address
|
||||
* @param {FixedRateParams} fixedRateParams
|
||||
* @param {FixedRateParams} fixedRateParams The parameters required to create a fixed-rate exchange contract.
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* @return {Promise<ReceiptOrEstimate>} transactionId
|
||||
* @return {Promise<ReceiptOrEstimate>}
|
||||
*/
|
||||
public async createFixedRate<G extends boolean = false>(
|
||||
dtAddress: string,
|
||||
@ -150,8 +149,8 @@ export class Datatoken extends SmartContract {
|
||||
* Creates a new Dispenser
|
||||
* @param {String} dtAddress Datatoken address
|
||||
* @param {String} address Caller address
|
||||
* @param {String} dispenserAddress ispenser contract address
|
||||
* @param {String} dispenserParams
|
||||
* @param {String} dispenserAddress Dispenser contract address
|
||||
* @param {DispenserParams} dispenserParams The parameters required to create a dispenser contract.
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* @return {Promise<ReceiptOrEstimate>} transactionId
|
||||
*/
|
||||
@ -198,7 +197,7 @@ export class Datatoken extends SmartContract {
|
||||
}
|
||||
|
||||
/**
|
||||
* Mint
|
||||
* Mints datatokens
|
||||
* @param {String} dtAddress Datatoken address
|
||||
* @param {String} address Minter address
|
||||
* @param {String} amount Number of datatokens, as number. Will be converted to wei
|
||||
@ -245,8 +244,8 @@ export class Datatoken extends SmartContract {
|
||||
* Add Minter for an ERC20 Datatoken
|
||||
* only DatatokenDeployer can succeed
|
||||
* @param {String} dtAddress Datatoken address
|
||||
* @param {String} address User address
|
||||
* @param {String} minter User which is going to be a Minter
|
||||
* @param {String} address caller address
|
||||
* @param {String} minter address which is going to be a Minter
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* @return {Promise<ReceiptOrEstimate>} transactionId
|
||||
*/
|
||||
@ -280,10 +279,10 @@ export class Datatoken extends SmartContract {
|
||||
* Revoke Minter permission for an ERC20 Datatoken
|
||||
* only DatatokenDeployer can succeed
|
||||
* @param {String} dtAddress Datatoken address
|
||||
* @param {String} address User address
|
||||
* @param {String} minter User which will be removed from Minter permission
|
||||
* @param {String} address caller address
|
||||
* @param {String} minter address which will have removed the Minter permission
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* @return {Promise<any>}
|
||||
* @return {Promise<ReceiptOrEstimate>}
|
||||
*/
|
||||
public async removeMinter<G extends boolean = false>(
|
||||
dtAddress: string,
|
||||
@ -312,11 +311,11 @@ export class Datatoken extends SmartContract {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add addPaymentManager (can set who's going to collect fee when consuming orders)
|
||||
* Adds a payment manager on a datatoken to a desired address.(can set who's going to collect fee when consuming orders)
|
||||
* only DatatokenDeployer can succeed
|
||||
* @param {String} dtAddress Datatoken address
|
||||
* @param {String} address User address
|
||||
* @param {String} paymentManager User which is going to be a Minter
|
||||
* @param {String} address Caller address
|
||||
* @param {String} paymentManager The address of the payment manager
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* @return {Promise<ReceiptOrEstimate>} transactionId
|
||||
*/
|
||||
@ -385,7 +384,7 @@ export class Datatoken extends SmartContract {
|
||||
* This function allows to set a new PaymentCollector (receives DT when consuming)
|
||||
* If not set the paymentCollector is the NFT Owner
|
||||
* only NFT owner can call
|
||||
* @param dtAddress datatoken address
|
||||
* @param dtAddress Datatoken address
|
||||
* @param address Caller address
|
||||
* @param paymentCollector User to be set as new payment collector
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
@ -422,7 +421,8 @@ export class Datatoken extends SmartContract {
|
||||
return <ReceiptOrEstimate<G>>trxReceipt
|
||||
}
|
||||
|
||||
/** getPaymentCollector - It returns the current paymentCollector
|
||||
/**
|
||||
* getPaymentCollector - It returns the current paymentCollector
|
||||
* @param dtAddress datatoken address
|
||||
* @return {Promise<string>}
|
||||
*/
|
||||
@ -433,10 +433,10 @@ export class Datatoken extends SmartContract {
|
||||
}
|
||||
|
||||
/**
|
||||
* Transfer as number from address to toAddress
|
||||
* Transfer tokens(as number) from address to toAddress
|
||||
* @param {String} dtAddress Datatoken address
|
||||
* @param {String} toAddress Receiver address
|
||||
* @param {String} amount Number of datatokens, as number. To be converted to wei.
|
||||
* @param {String} amount Number of datatokens, as number. Will be converted to wei.
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* @return {Promise<ReceiptOrEstimate>} transactionId
|
||||
*/
|
||||
@ -458,7 +458,7 @@ export class Datatoken extends SmartContract {
|
||||
* Transfer in wei from address to toAddress
|
||||
* @param {String} dtAddress Datatoken address
|
||||
* @param {String} toAddress Receiver address
|
||||
* @param {String} amount Number of datatokens, as number. Expressed as wei
|
||||
* @param {String} amount Number of datatokens (number) expressed as wei
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* @return {Promise<ReceiptOrEstimate>} transactionId
|
||||
*/
|
||||
@ -484,7 +484,8 @@ export class Datatoken extends SmartContract {
|
||||
return <ReceiptOrEstimate<G>>trxReceipt
|
||||
}
|
||||
|
||||
/** Start Order: called by payer or consumer prior ordering a service consume on a marketplace.
|
||||
/**
|
||||
* Start Order: called by payer or consumer prior ordering a service consume on a marketplace.
|
||||
* @param {String} dtAddress Datatoken address
|
||||
* @param {String} consumer Consumer Address
|
||||
* @param {Number} serviceIndex Service index in the metadata
|
||||
@ -531,7 +532,8 @@ export class Datatoken extends SmartContract {
|
||||
return <ReceiptOrEstimate<G>>trxReceipt
|
||||
}
|
||||
|
||||
/** Reuse Order: called by payer or consumer having a valid order, but with expired provider access.
|
||||
/**
|
||||
* Reuse Order: called by payer or consumer having a valid order, but with expired provider access.
|
||||
* Pays the provider fee again, but it will not require a new datatoken payment
|
||||
* Requires previous approval of provider fee.
|
||||
* @param {String} dtAddress Datatoken address
|
||||
@ -562,10 +564,11 @@ export class Datatoken extends SmartContract {
|
||||
return <ReceiptOrEstimate<G>>trxReceipt
|
||||
}
|
||||
|
||||
/** Buys 1 DT from the FRE and then startsOrder, while burning that DT
|
||||
/**
|
||||
* Buys 1 DT from the FRE and then startsOrder, while burning that DT
|
||||
* @param {String} dtAddress Datatoken address
|
||||
* @param {OrderParams} orderParams Consumer Address
|
||||
* @param {FreParams} freParams Amount of tokens that is going to be transfered
|
||||
* @param {OrderParams} orderParams The parameters required to place an order.
|
||||
* @param {FreParams} freParams The parameters required to buy from a fixed-rate exchange.
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* @return {Promise<ReceiptOrEstimate>}
|
||||
*/
|
||||
@ -575,7 +578,7 @@ export class Datatoken extends SmartContract {
|
||||
freParams: FreOrderParams,
|
||||
estimateGas?: G
|
||||
): Promise<ReceiptOrEstimate<G>> {
|
||||
const dtContract = this.getContract(dtAddress, null, this.abiEnterprise)
|
||||
const dtContract = this.getContract(dtAddress, this.abiEnterprise)
|
||||
|
||||
const freContractParams = await this.getFreOrderParams(freParams)
|
||||
|
||||
@ -596,10 +599,11 @@ export class Datatoken extends SmartContract {
|
||||
return <ReceiptOrEstimate<G>>trxReceipt
|
||||
}
|
||||
|
||||
/** Gets DT from dispenser and then startsOrder, while burning that DT
|
||||
/**
|
||||
* Gets 1 DT from dispenser and then startsOrder, while burning that DT
|
||||
* @param {String} dtAddress Datatoken address
|
||||
* @param {OrderParams} orderParams
|
||||
* @param {String} dispenserContract
|
||||
* @param {OrderParams} orderParams - The parameters required to place an order.
|
||||
* @param {String} dispenserContract dispenser address
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* @return {Promise<ReceiptOrEstimate>}
|
||||
*/
|
||||
@ -609,7 +613,7 @@ export class Datatoken extends SmartContract {
|
||||
dispenserContract: string,
|
||||
estimateGas?: G
|
||||
): Promise<ReceiptOrEstimate<G>> {
|
||||
const dtContract = this.getContract(dtAddress, null, this.abiEnterprise)
|
||||
const dtContract = this.getContract(dtAddress, this.abiEnterprise)
|
||||
|
||||
const estGas = await dtContract.estimateGas.buyFromDispenserAndOrder(
|
||||
orderParams,
|
||||
@ -668,8 +672,8 @@ export class Datatoken extends SmartContract {
|
||||
/**
|
||||
* Clean Datatoken level Permissions (minters, paymentManager and reset the paymentCollector) for an ERC20 Datatoken
|
||||
* Only NFT Owner (at 721 level) can call it.
|
||||
* @param dtAddress Datatoken address where we want to clean permissions
|
||||
* @param address User adress
|
||||
* @param {string} dtAddress Datatoken address where we want to clean permissions
|
||||
* @param {string} address User adress
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* @return {Promise<ReceiptOrEstimate>} transactionId
|
||||
*/
|
||||
@ -696,7 +700,8 @@ export class Datatoken extends SmartContract {
|
||||
return <ReceiptOrEstimate<G>>trxReceipt
|
||||
}
|
||||
|
||||
/** Returns ERC20 Datatoken user's permissions for a datatoken
|
||||
/**
|
||||
* Returns ERC20 Datatoken user's permissions for a datatoken
|
||||
* @param {String} dtAddress Datatoken adress
|
||||
* @param {String} address user adress
|
||||
* @return {Promise<DatatokenRoles>}
|
||||
@ -710,7 +715,8 @@ export class Datatoken extends SmartContract {
|
||||
return roles
|
||||
}
|
||||
|
||||
/** Returns the Datatoken cap
|
||||
/**
|
||||
* Returns the Datatoken cap
|
||||
* @param {String} dtAddress Datatoken adress
|
||||
* @return {Promise<string>}
|
||||
*/
|
||||
@ -720,7 +726,8 @@ export class Datatoken extends SmartContract {
|
||||
return await this.unitsToAmount(null, cap, 18)
|
||||
}
|
||||
|
||||
/** It returns the token decimals, how many supported decimal points
|
||||
/**
|
||||
* It returns the token decimals, how many supported decimal points
|
||||
* @param {String} dtAddress Datatoken adress
|
||||
* @return {Promise<number>}
|
||||
*/
|
||||
@ -730,7 +737,8 @@ export class Datatoken extends SmartContract {
|
||||
return decimals
|
||||
}
|
||||
|
||||
/** It returns the token symbol
|
||||
/**
|
||||
* It returns the token symbol
|
||||
* @param {String} dtAddress Datatoken adress
|
||||
* @return {Promise<number>}
|
||||
*/
|
||||
@ -740,7 +748,8 @@ export class Datatoken extends SmartContract {
|
||||
return symbol
|
||||
}
|
||||
|
||||
/** It returns the name of the token
|
||||
/**
|
||||
* It returns the name of the token
|
||||
* @param {String} dtAddress Datatoken adress
|
||||
* @return {Promise<number>}
|
||||
*/
|
||||
@ -750,7 +759,8 @@ export class Datatoken extends SmartContract {
|
||||
return name
|
||||
}
|
||||
|
||||
/** It returns the token decimals, how many supported decimal points
|
||||
/**
|
||||
* It returns the token decimals, how many supported decimal points
|
||||
* @param {String} dtAddress Datatoken adress
|
||||
* @return {Promise<number>}
|
||||
*/
|
||||
@ -760,7 +770,8 @@ export class Datatoken extends SmartContract {
|
||||
return nftAddress
|
||||
}
|
||||
|
||||
/** Returns true if address has deployERC20 role
|
||||
/**
|
||||
* Returns true if address has deployERC20 role
|
||||
* @param {String} dtAddress Datatoken adress
|
||||
* @param {String} dtAddress Datatoken adress
|
||||
* @return {Promise<boolean>}
|
||||
@ -778,15 +789,14 @@ export class Datatoken extends SmartContract {
|
||||
* @return {Promise<String>} balance Number of datatokens. Will be converted from wei
|
||||
*/
|
||||
public async balance(datatokenAddress: string, address: string): Promise<string> {
|
||||
const dtContract = this.getContract(datatokenAddress, address)
|
||||
const dtContract = this.getContract(datatokenAddress)
|
||||
const balance = await dtContract.balanceOf(address)
|
||||
return await this.unitsToAmount(null, balance, 18)
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev setPublishingMarketFee
|
||||
* Only publishMarketFeeAddress can call it
|
||||
* This function allows to set the fee required by the publisherMarket
|
||||
* Allows to set the fee required by the publisherMarket
|
||||
* only publishMarketFeeAddress can call it
|
||||
* @param {string} datatokenAddress Datatoken adress
|
||||
* @param {string} publishMarketFeeAddress new publish Market Fee Address
|
||||
* @param {string} publishMarketFeeToken new publish Market Fee Token
|
||||
@ -802,7 +812,7 @@ export class Datatoken extends SmartContract {
|
||||
address: string,
|
||||
estimateGas?: G
|
||||
): Promise<ReceiptOrEstimate<G>> {
|
||||
const dtContract = this.getContract(datatokenAddress, address)
|
||||
const dtContract = this.getContract(datatokenAddress)
|
||||
const mktFeeAddress = (await dtContract.getPublishingMarketFee())[0]
|
||||
if (mktFeeAddress !== address) {
|
||||
throw new Error(`Caller is not the Publishing Market Fee Address`)
|
||||
@ -828,18 +838,14 @@ export class Datatoken extends SmartContract {
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev getPublishingMarketFee
|
||||
* Get publishingMarket Fee
|
||||
* This function allows to get the current fee set by the publishing market
|
||||
* Returns the current fee set by the publishing market
|
||||
* @param {String} datatokenAddress Datatoken adress
|
||||
* @param {String} address user adress
|
||||
* @return {Promise<PublishingMarketFee>} Current fee set by the publishing market
|
||||
*/
|
||||
public async getPublishingMarketFee(
|
||||
datatokenAddress: string,
|
||||
address: string
|
||||
datatokenAddress: string
|
||||
): Promise<PublishingMarketFee> {
|
||||
const dtContract = this.getContract(datatokenAddress, address)
|
||||
const dtContract = this.getContract(datatokenAddress)
|
||||
|
||||
const publishingMarketFee = await dtContract.getPublishingMarketFee()
|
||||
const returnValues = {
|
||||
|
@ -14,7 +14,7 @@ export class Dispenser extends SmartContractWithAddress {
|
||||
/**
|
||||
* Get information about a datatoken dispenser
|
||||
* @param {String} dtAddress
|
||||
* @return {Promise<FixedPricedExchange>} Exchange details
|
||||
* @return {Promise<DispenserToken>}
|
||||
*/
|
||||
public async status(dtAdress: string): Promise<DispenserToken> {
|
||||
const status2: DispenserToken = await this.contract.status(dtAdress)
|
||||
@ -77,7 +77,7 @@ export class Dispenser extends SmartContractWithAddress {
|
||||
}
|
||||
|
||||
/**
|
||||
* Activates a new dispener.
|
||||
* Activates a dispener.
|
||||
* @param {String} dtAddress refers to datatoken address.
|
||||
* @param {Number} maxTokens max amount of tokens to dispense
|
||||
* @param {Number} maxBalance max balance of user. If user balance is >, then dispense will be rejected
|
||||
@ -135,11 +135,11 @@ export class Dispenser extends SmartContractWithAddress {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a new allowedSwapper.
|
||||
* @param {String} dtAddress refers to datatoken address.
|
||||
* @param {String} newAllowedSwapper refers to the new allowedSwapper
|
||||
* Sets a new allowed swapper.
|
||||
* @param {String} dtAddress Datatoken address.
|
||||
* @param {String} newAllowedSwapper The address of the new allowed swapper.
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* @return {Promise<ReceiptOrEstimate>} TransactionReceipt
|
||||
* @return {Promise<ReceiptOrEstimate>}
|
||||
*/
|
||||
public async setAllowedSwapper<G extends boolean = false>(
|
||||
dtAddress: string,
|
||||
@ -165,13 +165,13 @@ export class Dispenser extends SmartContractWithAddress {
|
||||
|
||||
/**
|
||||
* Dispense datatokens to caller.
|
||||
* The dispenser must be active, hold enough DT (or be able to mint more)
|
||||
* The dispenser must be active, hold enough datatokens (or be able to mint more)
|
||||
* and respect maxTokens/maxBalance requirements
|
||||
* @param {String} dtAddress refers to datatoken address.
|
||||
* @param {String} amount amount of datatokens required.
|
||||
* @param {String} destination who will receive the tokens
|
||||
* @param {String} dtAddress Datatoken address.
|
||||
* @param {String} amount Amount of datatokens required.
|
||||
* @param {String} destination address of tokens receiver
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* @return {Promise<ReceiptOrEstimate>} TransactionReceipt
|
||||
* @return {Promise<ReceiptOrEstimate>}
|
||||
*/
|
||||
public async dispense<G extends boolean = false>(
|
||||
dtAddress: string,
|
||||
@ -200,9 +200,9 @@ export class Dispenser extends SmartContractWithAddress {
|
||||
|
||||
/**
|
||||
* Withdraw all tokens from the dispenser
|
||||
* @param {String} dtAddress refers to datatoken address.
|
||||
* @param {String} dtAddress Datatoken address.
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* @return {Promise<ReceiptOrEstimate>} TransactionReceipt
|
||||
* @return {Promise<ReceiptOrEstimate>}
|
||||
*/
|
||||
public async ownerWithdraw<G extends boolean = false>(
|
||||
dtAddress: string,
|
||||
@ -224,7 +224,7 @@ export class Dispenser extends SmartContractWithAddress {
|
||||
|
||||
/**
|
||||
* Check if tokens can be dispensed
|
||||
* @param {String} dtAddress
|
||||
* @param {String} dtAddress Datatoken address
|
||||
* @param {String} address User address that will receive datatokens
|
||||
* @param {String} amount amount of datatokens required.
|
||||
* @return {Promise<Boolean>}
|
||||
|
@ -136,8 +136,6 @@ export class FixedRateExchange extends SmartContractWithAddress {
|
||||
|
||||
/**
|
||||
* Gets total number of exchanges
|
||||
* @param {String} exchangeId ExchangeId
|
||||
* @param {Number} datatokenAmount Amount of datatokens
|
||||
* @return {Promise<Number>} no of available exchanges
|
||||
*/
|
||||
public async getNumberOfExchanges(): Promise<number> {
|
||||
@ -147,7 +145,7 @@ export class FixedRateExchange extends SmartContractWithAddress {
|
||||
|
||||
/**
|
||||
* Set new rate
|
||||
* @param {String} exchangeId ExchangeId
|
||||
* @param {String} exchangeId Exchange ID
|
||||
* @param {String} newRate New rate
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* @return {Promise<ReceiptOrEstimate>} transaction receipt
|
||||
@ -177,8 +175,8 @@ export class FixedRateExchange extends SmartContractWithAddress {
|
||||
|
||||
/**
|
||||
* Sets a new allowedSwapper
|
||||
* @param {String} exchangeId ExchangeId
|
||||
* @param {String} newAllowedSwapper newAllowedSwapper (set address zero if we want to remove allowed swapper)
|
||||
* @param {String} exchangeId Exchange ID
|
||||
* @param {String} newAllowedSwapper The address of the new allowed swapper (set address zero if we want to remove allowed swapper)
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* @return {Promise<ReceiptOrEstimate>} transaction receipt
|
||||
*/
|
||||
@ -207,7 +205,7 @@ export class FixedRateExchange extends SmartContractWithAddress {
|
||||
/**
|
||||
* Activate an exchange
|
||||
* @param {String} exchangeId ExchangeId
|
||||
* @param {String} address User address
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* @return {Promise<ReceiptOrEstimate>} transaction receipt
|
||||
*/
|
||||
public async activate<G extends boolean = false>(
|
||||
@ -258,8 +256,8 @@ export class FixedRateExchange extends SmartContractWithAddress {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Rate
|
||||
* @param {String} exchangeId ExchangeId
|
||||
* Get Exchange Rate
|
||||
* @param {String} exchangeId Exchange ID
|
||||
* @return {Promise<string>} Rate (converted from wei)
|
||||
*/
|
||||
public async getRate(exchangeId: string): Promise<string> {
|
||||
@ -269,7 +267,7 @@ export class FixedRateExchange extends SmartContractWithAddress {
|
||||
|
||||
/**
|
||||
* Get Datatoken Supply in the exchange
|
||||
* @param {String} exchangeId ExchangeId
|
||||
* @param {String} exchangeId Exchange Id
|
||||
* @return {Promise<string>} dt supply formatted
|
||||
*/
|
||||
public async getDatatokenSupply(exchangeId: string): Promise<string> {
|
||||
@ -279,8 +277,8 @@ export class FixedRateExchange extends SmartContractWithAddress {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get BaseToken Supply in the exchange
|
||||
* @param {String} exchangeId ExchangeId
|
||||
* Returns basetoken supply in the exchange
|
||||
* @param {String} exchangeId Exchange Id
|
||||
* @return {Promise<string>} dt supply formatted
|
||||
*/
|
||||
public async getBasetokenSupply(exchangeId: string): Promise<string> {
|
||||
@ -291,8 +289,8 @@ export class FixedRateExchange extends SmartContractWithAddress {
|
||||
|
||||
/**
|
||||
* Get Allower Swapper (if set this is the only account which can use this exchange, else is set at address(0))
|
||||
* @param {String} exchangeId ExchangeId
|
||||
* @return {Promise<string>} address of allowedSwapper
|
||||
* @param {String} exchangeId Exchange Id
|
||||
* @return {Promise<string>} address of allowed swapper
|
||||
*/
|
||||
public async getAllowedSwapper(exchangeId: string): Promise<string> {
|
||||
return await this.contract.getAllowedSwapper(exchangeId)
|
||||
@ -300,7 +298,7 @@ export class FixedRateExchange extends SmartContractWithAddress {
|
||||
|
||||
/**
|
||||
* calcBaseInGivenDatatokensOut - Calculates how many base tokens are needed to get specified amount of datatokens
|
||||
* @param {String} exchangeId ExchangeId
|
||||
* @param {String} exchangeId Exchange Id
|
||||
* @param {string} datatokenAmount Amount of datatokens user wants to buy
|
||||
* @param {String} consumeMarketFee consumeMarketFee in fraction
|
||||
* @return {Promise<PriceAndFees>} how many base tokens are needed and fees
|
||||
@ -346,8 +344,8 @@ export class FixedRateExchange extends SmartContractWithAddress {
|
||||
}
|
||||
|
||||
/**
|
||||
* getBTOut - returns amount in baseToken that user will receive for datatokenAmount sold
|
||||
* @param {String} exchangeId ExchangeId
|
||||
* Returns amount in baseToken that user will receive for datatokenAmount sold
|
||||
* @param {String} exchangeId Exchange Id
|
||||
* @param {Number} datatokenAmount Amount of datatokens
|
||||
* @param {String} consumeMarketFee consumeMarketFee in fraction
|
||||
* @return {Promise<string>} Amount of baseTokens user will receive
|
||||
@ -369,7 +367,7 @@ export class FixedRateExchange extends SmartContractWithAddress {
|
||||
|
||||
/**
|
||||
* Get exchange details
|
||||
* @param {String} exchangeId ExchangeId
|
||||
* @param {String} exchangeId Exchange Id
|
||||
* @return {Promise<FixedPricedExchange>} Exchange details
|
||||
*/
|
||||
public async getExchange(exchangeId: string): Promise<FixedPriceExchange> {
|
||||
@ -411,8 +409,8 @@ export class FixedRateExchange extends SmartContractWithAddress {
|
||||
|
||||
/**
|
||||
* Get fee details for an exchange
|
||||
* @param {String} exchangeId ExchangeId
|
||||
* @return {Promise<FixedPricedExchange>} Exchange details
|
||||
* @param {String} exchangeId Exchange Id
|
||||
* @return {Promise<FeesInfo>} Exchange details
|
||||
*/
|
||||
public async getFeesInfo(exchangeId: string): Promise<FeesInfo> {
|
||||
const result: FeesInfo = await this.contract.getFeesInfo(exchangeId)
|
||||
@ -438,8 +436,8 @@ export class FixedRateExchange extends SmartContractWithAddress {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all exchanges
|
||||
* @param {String} exchangeId ExchangeId
|
||||
* Returns all exchanges
|
||||
* @param {String} exchangeId Exchang eId
|
||||
* @return {Promise<String[]>} Exchanges list
|
||||
*/
|
||||
public async getExchanges(): Promise<string[]> {
|
||||
@ -449,7 +447,7 @@ export class FixedRateExchange extends SmartContractWithAddress {
|
||||
/**
|
||||
* Check if an exchange is active
|
||||
* @param {String} exchangeId ExchangeId
|
||||
* @return {Promise<Boolean>} Result
|
||||
* @return {Promise<Boolean>}
|
||||
*/
|
||||
public async isActive(exchangeId: string): Promise<boolean> {
|
||||
const active = await this.contract.isActive(exchangeId)
|
||||
@ -458,7 +456,7 @@ export class FixedRateExchange extends SmartContractWithAddress {
|
||||
|
||||
/**
|
||||
* Activate minting option for fixed rate contract
|
||||
* @param {String} exchangeId ExchangeId
|
||||
* @param {String} exchangeId Exchang eId
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* @return {Promise<ReceiptOrEstimate>} transaction receipt
|
||||
*/
|
||||
@ -514,7 +512,7 @@ export class FixedRateExchange extends SmartContractWithAddress {
|
||||
|
||||
/**
|
||||
* Collect BaseTokens in the contract (anyone can call this, funds are sent to Datatoken.paymentCollector)
|
||||
* @param {String} exchangeId ExchangeId
|
||||
* @param {String} exchangeId Exchange Id
|
||||
* @param {String} amount amount to be collected
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* @return {Promise<ReceiptOrEstimate>} transaction receipt
|
||||
@ -550,7 +548,7 @@ export class FixedRateExchange extends SmartContractWithAddress {
|
||||
|
||||
/**
|
||||
* Collect datatokens in the contract (anyone can call this, funds are sent to Datatoken.paymentCollector)
|
||||
* @param {String} exchangeId ExchangeId
|
||||
* @param {String} exchangeId Exchange Id
|
||||
* @param {String} amount amount to be collected
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* @return {Promise<ReceiptOrEstimate>} transaction receipt
|
||||
@ -586,7 +584,7 @@ export class FixedRateExchange extends SmartContractWithAddress {
|
||||
|
||||
/**
|
||||
* Collect market fee and send it to marketFeeCollector (anyone can call it)
|
||||
* @param {String} exchangeId ExchangeId
|
||||
* @param {String} exchangeId Exchange Id
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* @return {Promise<ReceiptOrEstimate>} transaction receipt
|
||||
*/
|
||||
@ -613,7 +611,7 @@ export class FixedRateExchange extends SmartContractWithAddress {
|
||||
|
||||
/**
|
||||
* Collect ocean fee and send it to OPF collector (anyone can call it)
|
||||
* @param {String} exchangeId ExchangeId
|
||||
* @param {String} exchangeId Exchange Id
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* @return {Promise<ReceiptOrEstimate>} transaction receipt
|
||||
*/
|
||||
@ -658,7 +656,7 @@ export class FixedRateExchange extends SmartContractWithAddress {
|
||||
|
||||
/**
|
||||
* Get Exchange Owner given an exchangeId
|
||||
* @param {String} exchangeId ExchangeId
|
||||
* @param {String} exchangeId Exchange Id
|
||||
* @return {String} return exchange owner
|
||||
*/
|
||||
async getExchangeOwner(exchangeId: string): Promise<string> {
|
||||
@ -668,7 +666,7 @@ export class FixedRateExchange extends SmartContractWithAddress {
|
||||
|
||||
/**
|
||||
* Set new market fee, only market fee collector can update it
|
||||
* @param {String} exchangeId ExchangeId
|
||||
* @param {String} exchangeId Exchange Id
|
||||
* @param {String} newMarketFee New market fee
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* @return {Promise<ReceiptOrEstimate>} transaction receipt
|
||||
@ -698,7 +696,7 @@ export class FixedRateExchange extends SmartContractWithAddress {
|
||||
|
||||
/**
|
||||
* Set new market fee collector, only market fee collector can update it
|
||||
* @param {String} exchangeId ExchangeId
|
||||
* @param {String} exchangeId Exchange Id
|
||||
* @param {String} newMarketFeeCollector New market fee collector
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* @return {Promise<ReceiptOrEstimate>} transaction receipt
|
||||
|
@ -95,7 +95,7 @@ export class Nft extends SmartContract {
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @param {String} address NFT Owner adress
|
||||
* @param {String} manager User adress which is going to be assing manager
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* @param {Boolean} [estimateGas] if True, return gas estimate
|
||||
* @return {Promise<ReceiptOrEstimate>} trxReceipt
|
||||
*/
|
||||
public async addManager<G extends boolean = false>(
|
||||
@ -129,7 +129,7 @@ export class Nft extends SmartContract {
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @param {String} address NFT Owner adress
|
||||
* @param {String} manager User adress which is going to be removed as manager
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* @param {Boolean} [estimateGas] if True, return gas estimate
|
||||
* @return {Promise<ReceiptOrEstimate>} trxReceipt
|
||||
*/
|
||||
public async removeManager<G extends boolean = false>(
|
||||
@ -628,7 +628,8 @@ export class Nft extends SmartContract {
|
||||
return <ReceiptOrEstimate<G>>trxReceipt
|
||||
}
|
||||
|
||||
/** set TokenURI on an nft
|
||||
/**
|
||||
* set TokenURI on an nft
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @param {String} data input data for TokenURI
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
@ -655,7 +656,8 @@ export class Nft extends SmartContract {
|
||||
return <ReceiptOrEstimate<G>>trxReceipt
|
||||
}
|
||||
|
||||
/** Get Owner
|
||||
/**
|
||||
* Get NFT Owner
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @return {Promise<string>} string
|
||||
*/
|
||||
@ -665,7 +667,8 @@ export class Nft extends SmartContract {
|
||||
return trxReceipt
|
||||
}
|
||||
|
||||
/** Get users NFT Permissions
|
||||
/**
|
||||
* Gets NFT Permissions for a specified user
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @param {String} address user adress
|
||||
* @return {Promise<NftRoles>}
|
||||
@ -676,7 +679,8 @@ export class Nft extends SmartContract {
|
||||
return roles
|
||||
}
|
||||
|
||||
/** Get users Metadata, return Metadata details
|
||||
/**
|
||||
* Returns Metadata details for an NFT
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @return {Promise<Objecta>}
|
||||
*/
|
||||
@ -685,7 +689,8 @@ export class Nft extends SmartContract {
|
||||
return await nftContract.getMetaData()
|
||||
}
|
||||
|
||||
/** Get users DatatokenDeployer role
|
||||
/**
|
||||
* Checks if user has DatatokenDeployer role
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @param {String} address user adress
|
||||
* @return {Promise<boolean>}
|
||||
@ -699,14 +704,14 @@ export class Nft extends SmartContract {
|
||||
return isDatatokenDeployer
|
||||
}
|
||||
|
||||
/** setData
|
||||
* This function allows to store data with a preset key (keccak256(ERC20Address)) into NFT 725 Store
|
||||
/**
|
||||
* Allows users to store data with a preset key (keccak256(ERC20Address)) into NFT 725 Store
|
||||
* only ERC20Deployer can succeed
|
||||
* @param nftAddress erc721 contract adress
|
||||
* @param address user adress
|
||||
* @param key Key of the data to be stored into 725Y standard
|
||||
* @param value Data to be stored into 725Y standard
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* @param {string} nftAddress Nft datatoken adress
|
||||
* @param {string} address User adress
|
||||
* @param {string} key Key of the data to be stored into 725Y standard
|
||||
* @param {string} value Data to be stored into 725Y standard
|
||||
* @param {boolean} estimateGas if True, return gas estimate
|
||||
* @return {Promise<ReceiptOrEstimate>} transactionId
|
||||
*/
|
||||
public async setData<G extends boolean = false>(
|
||||
@ -739,9 +744,10 @@ export class Nft extends SmartContract {
|
||||
return <ReceiptOrEstimate<G>>trxReceipt
|
||||
}
|
||||
|
||||
/** Gets data at a given `key`
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @param {String} key the key which value to retrieve
|
||||
/**
|
||||
* Gets stored data at a given `key` in an NFT
|
||||
* @param {string} nftAddress - The address of the NFT.
|
||||
* @param {string} key - The key of the data to get.
|
||||
* @return {Promise<string>} The data stored at the key
|
||||
*/
|
||||
public async getData(nftAddress: string, key: string): Promise<string> {
|
||||
@ -751,10 +757,11 @@ export class Nft extends SmartContract {
|
||||
return data ? ethers.utils.toUtf8String(data) : null
|
||||
}
|
||||
|
||||
/** Gets data at a given `key`
|
||||
* @param {String} nftAddress NFT contract address
|
||||
* @param {String} id
|
||||
* @return {Promise<string>} The data stored at the key
|
||||
/**
|
||||
* Gets the token URI of an NFT.
|
||||
* @param {string} nftAddress - The address of the NFT.
|
||||
* @param {number} id - The ID of the token.
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
public async getTokenURI(nftAddress: string, id: number): Promise<string> {
|
||||
const nftContract = this.getContract(nftAddress)
|
||||
|
@ -22,10 +22,10 @@ export class NftFactory extends SmartContractWithAddress {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new NFT
|
||||
* @param {NFTCreateData} nftData
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* @return {Promise<string>} NFT datatoken address
|
||||
* Create new data NFT
|
||||
* @param {NFTCreateData} nftData The data needed to create an NFT.
|
||||
* @param {Boolean} [estimateGas] if True, return gas estimate
|
||||
* @return {Promise<string|BigNumber>} The transaction hash or the gas estimate.
|
||||
*/
|
||||
public async createNFT<G extends boolean = false>(
|
||||
nftData: NftCreateData,
|
||||
@ -79,7 +79,8 @@ export class NftFactory extends SmartContractWithAddress {
|
||||
return events.args[0]
|
||||
}
|
||||
|
||||
/** Get Current NFT Count (NFT created)
|
||||
/**
|
||||
* Get Current NFT Count (NFT created)
|
||||
* @return {Promise<number>} Number of NFT created from this factory
|
||||
*/
|
||||
public async getCurrentNFTCount(): Promise<number> {
|
||||
@ -87,7 +88,8 @@ export class NftFactory extends SmartContractWithAddress {
|
||||
return nftCount
|
||||
}
|
||||
|
||||
/** Get Current Datatoken Count
|
||||
/**
|
||||
* Get Current Datatoken Count
|
||||
* @return {Promise<number>} Number of DTs created from this factory
|
||||
*/
|
||||
public async getCurrentTokenCount(): Promise<number> {
|
||||
@ -95,7 +97,8 @@ export class NftFactory extends SmartContractWithAddress {
|
||||
return tokenCount
|
||||
}
|
||||
|
||||
/** Get Factory Owner
|
||||
/**
|
||||
* Get Factory Owner
|
||||
* @return {Promise<string>} Factory Owner address
|
||||
*/
|
||||
public async getOwner(): Promise<string> {
|
||||
@ -103,7 +106,8 @@ export class NftFactory extends SmartContractWithAddress {
|
||||
return owner
|
||||
}
|
||||
|
||||
/** Get Current NFT Template Count
|
||||
/**
|
||||
* Get Current NFT Template Count
|
||||
* @return {Promise<number>} Number of NFT Template added to this factory
|
||||
*/
|
||||
public async getCurrentNFTTemplateCount(): Promise<number> {
|
||||
@ -111,7 +115,8 @@ export class NftFactory extends SmartContractWithAddress {
|
||||
return count
|
||||
}
|
||||
|
||||
/** Get Current Template Datatoken (ERC20) Count
|
||||
/**
|
||||
* Get Current Template Datatoken (ERC20) Count
|
||||
* @return {Promise<number>} Number of Datatoken Template added to this factory
|
||||
*/
|
||||
public async getCurrentTokenTemplateCount(): Promise<number> {
|
||||
@ -119,8 +124,9 @@ export class NftFactory extends SmartContractWithAddress {
|
||||
return count
|
||||
}
|
||||
|
||||
/** Get NFT Template
|
||||
* @param {Number} index Template index
|
||||
/**
|
||||
* Get NFT Template
|
||||
* @param {number} index Template index
|
||||
* @return {Promise<Template>} Number of Template added to this factory
|
||||
*/
|
||||
public async getNFTTemplate(index: number): Promise<Template> {
|
||||
@ -135,8 +141,9 @@ export class NftFactory extends SmartContractWithAddress {
|
||||
return template
|
||||
}
|
||||
|
||||
/** Get Datatoken (ERC20) Template
|
||||
* @param {Number} index Template index
|
||||
/**
|
||||
* Get Datatoken (ERC20) Template
|
||||
* @param {number} index Template index
|
||||
* @return {Promise<Template>} DT Template info
|
||||
*/
|
||||
public async getTokenTemplate(index: number): Promise<Template> {
|
||||
@ -144,8 +151,9 @@ export class NftFactory extends SmartContractWithAddress {
|
||||
return template
|
||||
}
|
||||
|
||||
/** Check if Datatoken is deployed from the factory
|
||||
* @param {String} datatoken Datatoken address we want to check
|
||||
/**
|
||||
* Check if Datatoken is deployed from the factory
|
||||
* @param {String} datatoken Datatoken address to check
|
||||
* @return {Promise<Boolean>} return true if deployed from this factory
|
||||
*/
|
||||
public async checkDatatoken(datatoken: string): Promise<Boolean> {
|
||||
@ -153,8 +161,9 @@ export class NftFactory extends SmartContractWithAddress {
|
||||
return isDeployed
|
||||
}
|
||||
|
||||
/** Check if NFT is deployed from the factory
|
||||
* @param {String} nftAddress nftAddress address we want to check
|
||||
/**
|
||||
* Check if NFT is deployed from the factory
|
||||
* @param {String} nftAddress nftAddress address to check
|
||||
* @return {Promise<String>} return address(0) if it's not, or the nftAddress if true
|
||||
*/
|
||||
public async checkNFT(nftAddress: string): Promise<String> {
|
||||
@ -164,9 +173,9 @@ export class NftFactory extends SmartContractWithAddress {
|
||||
|
||||
/**
|
||||
* Add a new NFT token template - only factory Owner
|
||||
* @param {String} address
|
||||
* @param {String} address caller address
|
||||
* @param {String} templateAddress template address to add
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* @param {Boolean} [estimateGas] if True, return gas estimate
|
||||
* @return {Promise<ReceiptOrEstimate>}
|
||||
*/
|
||||
public async addNFTTemplate<G extends boolean = false>(
|
||||
@ -271,7 +280,7 @@ export class NftFactory extends SmartContractWithAddress {
|
||||
|
||||
/**
|
||||
* Add a new NFT token template - only factory Owner
|
||||
* @param {String} address
|
||||
* @param {String} address caller address
|
||||
* @param {String} templateAddress template address to add
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* @return {Promise<ReceiptOrEstimate>}
|
||||
@ -304,7 +313,7 @@ export class NftFactory extends SmartContractWithAddress {
|
||||
|
||||
/**
|
||||
* Disable token template - only factory Owner
|
||||
* @param {String} address
|
||||
* @param {String} address caller address
|
||||
* @param {Number} templateIndex index of the template we want to disable
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* @return {Promise<ReceiptOrEstimate>} current token template count
|
||||
@ -343,7 +352,7 @@ export class NftFactory extends SmartContractWithAddress {
|
||||
|
||||
/**
|
||||
* Reactivate a previously disabled token template - only factory Owner
|
||||
* @param {String} address
|
||||
* @param {String} address caller address
|
||||
* @param {Number} templateIndex index of the template we want to reactivate
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* @return {Promise<ReceiptOrEstimate>} current token template count
|
||||
@ -382,15 +391,14 @@ export class NftFactory extends SmartContractWithAddress {
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev startMultipleTokenOrder
|
||||
* Used as a proxy to order multiple services
|
||||
* Users can have inifinite approvals for fees for factory instead of having one approval/ Datatoken contract
|
||||
* Requires previous approval of all :
|
||||
* - consumeFeeTokens
|
||||
* - publishMarketFeeTokens
|
||||
* - ERC20 Datatokens
|
||||
* @param orders an array of struct tokenOrder
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* @param {TokenOrder[]} orders array of of orders
|
||||
* @param {Boolean} [estimateGas] if True, return gas estimate
|
||||
* @return {Promise<ReceiptOrEstimate>} transaction receipt
|
||||
*/
|
||||
public async startMultipleTokenOrder<G extends boolean = false>(
|
||||
@ -416,11 +424,10 @@ export class NftFactory extends SmartContractWithAddress {
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev createNftWithDatatoken
|
||||
* Creates a new NFT, then a Datatoken,all in one call
|
||||
* @param _NftCreateData input data for nft creation
|
||||
* @param _ErcCreateData input data for Datatoken creation
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* Creates a new NFT, then a datatoken,all in one call
|
||||
* @param {NftCreateData} nftCreateData - The data required to create an NFT.
|
||||
* @param {DatatokenCreateParams} dtParams - The parameters required to create a datatoken.
|
||||
* @param {boolean} [estimateGas] - Whether to return only estimate gas or not.
|
||||
* @return {Promise<ReceiptOrEstimate>} transaction receipt
|
||||
*/
|
||||
|
||||
@ -449,15 +456,13 @@ export class NftFactory extends SmartContractWithAddress {
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev createNftWithDatatokenWithFixedRate
|
||||
* Creates a new NFT, then a Datatoken, then a FixedRateExchange, all in one call
|
||||
* Use this carefully, because if Fixed Rate creation fails, you are still going to pay a lot of gas
|
||||
* @param address Caller address
|
||||
* @param nftCreateData input data for NFT Creation
|
||||
* @param dtParams input data for Datatoken Creation
|
||||
* @param freParams input data for FixedRate Creation
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* @return {Promise<TransactionReceipt>} transaction receipt
|
||||
* Creates an NFT with a datatoken with a fixed rate all in one call.
|
||||
* be aware if Fixed Rate creation fails, you are still going to pay a lot of gas
|
||||
* @param {NftCreateData} nftCreateData - The data required to create an NFT.
|
||||
* @param {DatatokenCreateParams} dtParams - The parameters required to create a datatoken.
|
||||
* @param {FreCreationParams} freParams - The parameters required to create a fixed-rate exchange contract.
|
||||
* @param {boolean} [estimateGas] - Whether to return only estimate gas or not.
|
||||
* @returns {Promis<ReceiptOrEstimate<G>>}
|
||||
*/
|
||||
public async createNftWithDatatokenWithFixedRate<G extends boolean = false>(
|
||||
nftCreateData: NftCreateData,
|
||||
@ -489,14 +494,13 @@ export class NftFactory extends SmartContractWithAddress {
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev createNftWithDatatokenWithDispenser
|
||||
* Creates a new NFT, then a Datatoken, then a Dispenser, all in one call
|
||||
* Use this carefully, because if Dispenser creation fails, you are still going to pay a lot of gas
|
||||
* @param nftCreateData input data for NFT Creation
|
||||
* @param dtParams input data for Datatoken Creation
|
||||
* @param dispenserParams input data for Dispenser Creation
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* @return {Promise<TransactionReceipt>} transaction receipt
|
||||
* Creates an NFT with a datatoken with a dispenser in one call.
|
||||
* Be aware if Fixed Rate creation fails, you are still going to pay a lot of gas
|
||||
* @param {NftCreateData} nftCreateData - The data required to create an NFT.
|
||||
* @param {DatatokenCreateParams} dtParams - The parameters required to create a datatoken.
|
||||
* @param {DispenserCreationParams} dispenserParams - The parameters required to create a dispenser contract.
|
||||
* @param {boolean} [estimateGas] - Whether to estimate gas or not.
|
||||
* @returns {Promis<ReceiptOrEstimate<G>>}
|
||||
*/
|
||||
public async createNftWithDatatokenWithDispenser<G extends boolean = false>(
|
||||
nftCreateData: NftCreateData,
|
||||
@ -538,6 +542,11 @@ export class NftFactory extends SmartContractWithAddress {
|
||||
return <ReceiptOrEstimate<G>>trxReceipt
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the parameters required to create an ERC20 token.
|
||||
* @param {DatatokenCreateParams} dtParams - The parameters required to create a datatoken.
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
private async getErcCreationParams(dtParams: DatatokenCreateParams): Promise<any> {
|
||||
let name: string, symbol: string
|
||||
// Generate name & symbol if not present
|
||||
@ -561,6 +570,11 @@ export class NftFactory extends SmartContractWithAddress {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the parameters required to create a fixed-rate exchange contract.
|
||||
* @param {FreCreationParams} freParams - The parameters required to create a fixed-rate exchange contract.
|
||||
* @returns {Promise<any> }
|
||||
*/
|
||||
private async getFreCreationParams(freParams: FreCreationParams): Promise<any> {
|
||||
if (!freParams.allowedConsumer) freParams.allowedConsumer = ZERO_ADDRESS
|
||||
const withMint = freParams.withMint === false ? 0 : 1
|
||||
|
@ -12,9 +12,11 @@ export class Router extends SmartContractWithAddress {
|
||||
}
|
||||
|
||||
/**
|
||||
* buyDatatokenBatch
|
||||
* @param {Operation} operations Operations objects array
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* * Buys a batch of datatokens.
|
||||
* one single call to buy multiple DT for multiple assets.
|
||||
* require tokenIn approvals for router from user. (except for dispenser operations)
|
||||
* @param {Operation[]} operations - The operations to execute.
|
||||
* @param {boolean} [estimateGas=false] - Whether to return only the estimate gas or not.
|
||||
* @return {Promise<ReceiptOrEstimate>} Transaction receipt
|
||||
*/
|
||||
public async buyDatatokenBatch<G extends boolean = false>(
|
||||
@ -35,28 +37,35 @@ export class Router extends SmartContractWithAddress {
|
||||
return <ReceiptOrEstimate<G>>trxReceipt
|
||||
}
|
||||
|
||||
/** Check if a token is on approved tokens list, if true opfFee is lower in pools with that token/DT
|
||||
/**
|
||||
* Checks if a token is on approved tokens list,
|
||||
* if true opfFee is lower in pools with that token/DT
|
||||
* @param {string} address - The address of the token to check.
|
||||
* @return {Promise<boolean>} true if is on the list.
|
||||
*/
|
||||
public async isApprovedToken(address: string): Promise<boolean> {
|
||||
return await this.contract.isApprovedToken(address)
|
||||
}
|
||||
|
||||
/** Check if an address is a Fixed Rate contract.
|
||||
/**
|
||||
* Check if an address is a Fixed Rate contract.
|
||||
* @param {string} address - The address of the fixed rate exchange to check.
|
||||
* @return {Promise<boolean>} true if is a Fixed Rate contract
|
||||
*/
|
||||
public async isFixedPrice(address: string): Promise<boolean> {
|
||||
return await this.contract.isFixedRateContract(address)
|
||||
}
|
||||
|
||||
/** Get Router Owner
|
||||
/**
|
||||
* Get Router Owner
|
||||
* @return {Promise<string>} Router Owner address
|
||||
*/
|
||||
public async getOwner(): Promise<string> {
|
||||
return await this.contract.routerOwner()
|
||||
}
|
||||
|
||||
/** Get NFT Factory address
|
||||
/**
|
||||
* Get NFT Factory address
|
||||
* @return {Promise<string>} NFT Factory address
|
||||
*/
|
||||
public async getNFTFactory(): Promise<string> {
|
||||
@ -67,7 +76,7 @@ export class Router extends SmartContractWithAddress {
|
||||
* Adds a token to the list of tokens with reduced fees
|
||||
* @param {String} address caller address
|
||||
* @param {String} tokenAddress token address to add
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* @param {Boolean} [estimateGas] if True, return gas estimate
|
||||
* @return {Promise<ReceiptOrEstimate>}
|
||||
*/
|
||||
public async addApprovedToken<G extends boolean = false>(
|
||||
@ -95,9 +104,9 @@ export class Router extends SmartContractWithAddress {
|
||||
|
||||
/**
|
||||
* Removes a token if exists from the list of tokens with reduced fees
|
||||
* @param {String} address
|
||||
* @param {String} tokenAddress address to remove
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* @param {String} address caller address
|
||||
* @param {String} tokenAddress token address to remove
|
||||
* @param {Boolean} [estimateGas] if True, return gas estimate
|
||||
* @return {Promise<ReceiptOrEstimate>}
|
||||
*/
|
||||
public async removeApprovedToken<G extends boolean = false>(
|
||||
@ -124,9 +133,9 @@ export class Router extends SmartContractWithAddress {
|
||||
|
||||
/**
|
||||
* Adds an address to the list of fixed rate contracts
|
||||
* @param {String} address
|
||||
* @param {String} address caller address
|
||||
* @param {String} tokenAddress contract address to add
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* @param {Boolean} [estimateGas] if True, return gas estimate
|
||||
* @return {Promise<ReceiptOrEstimate>}
|
||||
*/
|
||||
public async addFixedRateContract<G extends boolean = false>(
|
||||
@ -154,9 +163,9 @@ export class Router extends SmartContractWithAddress {
|
||||
|
||||
/**
|
||||
* Removes an address from the list of fixed rate contracts
|
||||
* @param {String} address
|
||||
* @param {String} address caller address
|
||||
* @param {String} tokenAddress contract address to add
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* @param {Boolean} [estimateGas] if True, return gas estimate
|
||||
* @return {Promise<ReceiptOrEstimate>}
|
||||
*/
|
||||
public async removeFixedRateContract<G extends boolean = false>(
|
||||
@ -184,7 +193,7 @@ export class Router extends SmartContractWithAddress {
|
||||
|
||||
/**
|
||||
* Adds an address to the list of dispensers
|
||||
* @param {String} address
|
||||
* @param {String} address caller address
|
||||
* @param {String} tokenAddress contract address to add
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* @return {Promise<ReceiptOrEstimate>}
|
||||
@ -213,7 +222,7 @@ export class Router extends SmartContractWithAddress {
|
||||
|
||||
/**
|
||||
* Removes an address from the list of dispensers
|
||||
* @param {String} address
|
||||
* @param {String} address caller address
|
||||
* @param {String} tokenAddress address Contract to be removed
|
||||
* @param {Boolean} estimateGas if True, return gas estimate
|
||||
* @return {Promise<ReceiptOrEstimate>}
|
||||
@ -256,7 +265,7 @@ export class Router extends SmartContractWithAddress {
|
||||
|
||||
/**
|
||||
* Updates OP Community Fees
|
||||
* @param {String} address
|
||||
* @param {String} address caller address
|
||||
* @param {number} newSwapOceanFee Amount charged for swapping with ocean approved tokens
|
||||
* @param {number} newSwapNonOceanFee Amount charged for swapping with non ocean approved tokens
|
||||
* @param {number} newConsumeFee Amount charged from consumeFees
|
||||
|
@ -17,10 +17,10 @@ export abstract class SmartContract {
|
||||
|
||||
/**
|
||||
* Instantiate the smart contract.
|
||||
* @param {Signer} signer
|
||||
* @param {string | number} network Network id or name
|
||||
* @param {Config} config Configutation of the smart contract
|
||||
* @param {AbiItem[]} abi ABI of the smart contract
|
||||
* @param {Signer} signer The signer object.
|
||||
* @param {string | number} [network] Network id or name
|
||||
* @param {Config} [config] The configuration object.
|
||||
* @param {AbiItem[]} [abi] ABI array of the smart contract
|
||||
*/
|
||||
constructor(
|
||||
signer: Signer,
|
||||
@ -33,6 +33,13 @@ export abstract class SmartContract {
|
||||
this.abi = abi || this.getDefaultAbi()
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an amount of tokens to units
|
||||
* @param {string} token - The token to convert
|
||||
* @param {string} amount - The amount of tokens to convert
|
||||
* @param {number} [tokenDecimals] - The number of decimals of the token
|
||||
* @returns {Promise<string>} - The converted amount in units
|
||||
*/
|
||||
protected async amountToUnits(
|
||||
token: string,
|
||||
amount: string,
|
||||
@ -41,6 +48,13 @@ export abstract class SmartContract {
|
||||
return amountToUnits(this.signer, token, amount, tokenDecimals)
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an amount of units to tokens
|
||||
* @param {string} token - The token to convert
|
||||
* @param {string} amount - The amount of units to convert
|
||||
* @param {number} [tokenDecimals] - The number of decimals in the token
|
||||
* @returns {Promise<string>} - The converted amount in tokens
|
||||
*/
|
||||
protected async unitsToAmount(
|
||||
token: string,
|
||||
amount: string,
|
||||
@ -49,11 +63,21 @@ export abstract class SmartContract {
|
||||
return unitsToAmount(this.signer, token, amount, tokenDecimals)
|
||||
}
|
||||
|
||||
/**
|
||||
* Retruns the gas price
|
||||
* @returns {Promise<string>} - The fair gas price
|
||||
*/
|
||||
protected async getFairGasPrice(): Promise<string> {
|
||||
return getFairGasPrice(this.signer, this.config?.gasFeeMultiplier)
|
||||
}
|
||||
|
||||
protected getContract(address: string, account?: string, abi?: AbiItem[]): Contract {
|
||||
/**
|
||||
* Returns a contract instance for the given address
|
||||
* @param {string} address - The address of the contract
|
||||
* @param {AbiItem[]} [abi] - The ABI of the contract
|
||||
* @returns {Contract} - The contract instance
|
||||
*/
|
||||
protected getContract(address: string, abi?: AbiItem[]): Contract {
|
||||
const abiToUse = abi || this.abi
|
||||
const contract = new ethers.Contract(
|
||||
address,
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Signer, Contract, ContractFunction } from 'ethers'
|
||||
import { Signer, Contract } from 'ethers'
|
||||
import { AbiItem } from '../@types'
|
||||
import { Config } from '../config'
|
||||
import { SmartContract } from './SmartContract'
|
||||
@ -8,11 +8,11 @@ export abstract class SmartContractWithAddress extends SmartContract {
|
||||
|
||||
/**
|
||||
* Instantiate the smart contract.
|
||||
* @param {string} address Address of the smart contract
|
||||
* @param {Signer} signer
|
||||
* @param {string} address The address of the contract.
|
||||
* @param {Signer} signer The signer object.
|
||||
* @param {string | number} network Network id or name
|
||||
* @param {Config} config Configutation of the smart contract
|
||||
* @param {AbiItem[]} abi ABI of the smart contract
|
||||
* @param {Config} config The configuration object.
|
||||
* @param {AbiItem[]} abi ABI array of the smart contract
|
||||
*/
|
||||
constructor(
|
||||
address: string,
|
||||
|
@ -86,6 +86,7 @@ export async function sendTx(
|
||||
functionToSend: ContractFunction,
|
||||
...args: any[]
|
||||
): Promise<providers.TransactionResponse> {
|
||||
// TODO: update method to use also gasFeeMultiplier
|
||||
const { chainId } = await signer.provider.getNetwork()
|
||||
const feeHistory = await signer.provider.getFeeData()
|
||||
let overrides
|
||||
|
@ -865,8 +865,7 @@ describe('Datatoken', () => {
|
||||
|
||||
it('#setPublishingMarketFee - User should not be able to set the Publishing Market Fee', async () => {
|
||||
const originalPublishingMarketFee = await datatoken.getPublishingMarketFee(
|
||||
datatokenAddress,
|
||||
await user1.getAddress()
|
||||
datatokenAddress
|
||||
)
|
||||
try {
|
||||
await datatoken.setPublishingMarketFee(
|
||||
@ -880,8 +879,7 @@ describe('Datatoken', () => {
|
||||
assert(e.message === 'Caller is not the Publishing Market Fee Address')
|
||||
}
|
||||
const newPublishingMarketFee = await datatoken.getPublishingMarketFee(
|
||||
datatokenAddress,
|
||||
await user3.getAddress()
|
||||
datatokenAddress
|
||||
)
|
||||
|
||||
assert(
|
||||
@ -902,8 +900,7 @@ describe('Datatoken', () => {
|
||||
datatoken = new Datatoken(user2, 8996)
|
||||
|
||||
const originalPublishingMarketFee = await datatoken.getPublishingMarketFee(
|
||||
datatokenAddress,
|
||||
await user2.getAddress()
|
||||
datatokenAddress
|
||||
)
|
||||
try {
|
||||
await datatoken.setPublishingMarketFee(
|
||||
@ -917,8 +914,7 @@ describe('Datatoken', () => {
|
||||
console.log('Error:', e)
|
||||
}
|
||||
const newPublishingMarketFee = await datatoken.getPublishingMarketFee(
|
||||
datatokenAddress,
|
||||
await user2.getAddress()
|
||||
datatokenAddress
|
||||
)
|
||||
|
||||
assert(newPublishingMarketFee !== originalPublishingMarketFee)
|
||||
|
Loading…
x
Reference in New Issue
Block a user