mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
set file object fc.
This commit is contained in:
parent
a460ed9213
commit
fdcad34c91
@ -1,5 +1,6 @@
|
|||||||
|
/* eslint-disable lines-between-class-members */
|
||||||
import { Datatoken } from './Datatoken'
|
import { Datatoken } from './Datatoken'
|
||||||
import { Signer } from 'ethers'
|
import { Bytes, Signer } from 'ethers'
|
||||||
import ERC20Template4 from '@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template4.sol/ERC20Template4.json'
|
import ERC20Template4 from '@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template4.sol/ERC20Template4.json'
|
||||||
import { AbiItem, ReceiptOrEstimate } from '../@types'
|
import { AbiItem, ReceiptOrEstimate } from '../@types'
|
||||||
import { AccessListContract } from './AccessList'
|
import { AccessListContract } from './AccessList'
|
||||||
@ -55,16 +56,18 @@ export class Datatoken4 extends Datatoken {
|
|||||||
* This function allows to set another address for allowListContract, only by datatoken deployer
|
* This function allows to set another address for allowListContract, only by datatoken deployer
|
||||||
* only DatatokenDeployer can succeed
|
* only DatatokenDeployer can succeed
|
||||||
* @param {String} dtAddress Datatoken address
|
* @param {String} dtAddress Datatoken address
|
||||||
* @param {String} address User address
|
* @param {String} address Contract address
|
||||||
|
* @param {String} consumer User address
|
||||||
* @param {Boolean} estimateGas if True, return gas estimate
|
* @param {Boolean} estimateGas if True, return gas estimate
|
||||||
* @return {Promise<ReceiptOrEstimate>} transactionId
|
* @return {Promise<ReceiptOrEstimate>} transactionId
|
||||||
*/
|
*/
|
||||||
public async setAllowListContract<G extends boolean = false>(
|
public async setAllowListContract<G extends boolean = false>(
|
||||||
dtAddress: string,
|
dtAddress: string,
|
||||||
address: string,
|
address: string,
|
||||||
|
consumer: string,
|
||||||
estimateGas?: G
|
estimateGas?: G
|
||||||
): Promise<ReceiptOrEstimate<G>> {
|
): Promise<ReceiptOrEstimate<G>> {
|
||||||
if (!(await this.isDatatokenDeployer(dtAddress, address))) {
|
if (!(await this.isDatatokenDeployer(dtAddress, consumer))) {
|
||||||
throw new Error(`User is not Datatoken Deployer`)
|
throw new Error(`User is not Datatoken Deployer`)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,16 +90,18 @@ export class Datatoken4 extends Datatoken {
|
|||||||
* This function allows to set another address for allowListContract, only by datatoken deployer
|
* This function allows to set another address for allowListContract, only by datatoken deployer
|
||||||
* only DatatokenDeployer can succeed
|
* only DatatokenDeployer can succeed
|
||||||
* @param {String} dtAddress Datatoken address
|
* @param {String} dtAddress Datatoken address
|
||||||
* @param {String} address User address
|
* @param {String} address Contract address
|
||||||
|
* @param {String} consumer User address
|
||||||
* @param {Boolean} estimateGas if True, return gas estimate
|
* @param {Boolean} estimateGas if True, return gas estimate
|
||||||
* @return {Promise<ReceiptOrEstimate>} transactionId
|
* @return {Promise<ReceiptOrEstimate>} transactionId
|
||||||
*/
|
*/
|
||||||
public async setDenyListContract<G extends boolean = false>(
|
public async setDenyListContract<G extends boolean = false>(
|
||||||
dtAddress: string,
|
dtAddress: string,
|
||||||
address: string,
|
address: string,
|
||||||
|
consumer: string,
|
||||||
estimateGas?: G
|
estimateGas?: G
|
||||||
): Promise<ReceiptOrEstimate<G>> {
|
): Promise<ReceiptOrEstimate<G>> {
|
||||||
if (!(await this.isDatatokenDeployer(dtAddress, address))) {
|
if (!(await this.isDatatokenDeployer(dtAddress, consumer))) {
|
||||||
throw new Error(`User is not Datatoken Deployer`)
|
throw new Error(`User is not Datatoken Deployer`)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,6 +117,38 @@ export class Datatoken4 extends Datatoken {
|
|||||||
address
|
address
|
||||||
)
|
)
|
||||||
|
|
||||||
|
return <ReceiptOrEstimate<G>>trxReceipt
|
||||||
|
}
|
||||||
|
/** setFileObject
|
||||||
|
* This function allows to set file object in ecnrypted format, only by datatoken deployer
|
||||||
|
* only DatatokenDeployer can succeed
|
||||||
|
* @param {String} dtAddress Datatoken address
|
||||||
|
* @param {String} address User address
|
||||||
|
* @param {Boolean} estimateGas if True, return gas estimate
|
||||||
|
* @return {Promise<ReceiptOrEstimate>} transactionId
|
||||||
|
*/
|
||||||
|
public async setFileObject<G extends boolean = false>(
|
||||||
|
dtAddress: string,
|
||||||
|
address: string,
|
||||||
|
fileObject: Bytes,
|
||||||
|
estimateGas?: G
|
||||||
|
): Promise<ReceiptOrEstimate<G>> {
|
||||||
|
if (!(await this.isDatatokenDeployer(dtAddress, address))) {
|
||||||
|
throw new Error(`User is not Datatoken Deployer`)
|
||||||
|
}
|
||||||
|
|
||||||
|
const dtContract = this.getContract(dtAddress)
|
||||||
|
const estGas = await dtContract.estimateGas.setFileObject(fileObject)
|
||||||
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
|
const trxReceipt = await sendTx(
|
||||||
|
estGas,
|
||||||
|
this.signer,
|
||||||
|
this.config?.gasFeeMultiplier,
|
||||||
|
dtContract.setFileObject,
|
||||||
|
fileObject
|
||||||
|
)
|
||||||
|
|
||||||
return <ReceiptOrEstimate<G>>trxReceipt
|
return <ReceiptOrEstimate<G>>trxReceipt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user