mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
Add confidential EVM flag when creating a datatoken 4 in NFT class (#1859)
* Add confidential EVM flag when creating a datatoken 4. * Add comments. * fix lint. * fix lint. * Add chain id check to bundled functions. * Updating CodeExamples.md * Updating ComputeExamples.md * Used config object. * Added check for sapphire confidential EVM. Fix tests. * Added sapphire wrap signer for all contracts. * Make network mandatory field. * Undo making network mandatory. * refactor condition. * refactor condition. * Add condition when creating NFT. * Refactor with sdk. * fix lint. * tweak. * tweak. * Created protected function to get vthe signer according to the sdk from config. * Fix lint. Add check for sdk within the config. * Fix lint. * Updating CodeExamples.md * Updating ComputeExamples.md --------- Co-authored-by: GitHub Actions Bot <>
This commit is contained in:
parent
cc91e1d376
commit
a0a8df328f
@ -289,7 +289,11 @@ you need to mint oceans to mentioned accounts only if you are using barge to tes
|
|||||||
|
|
||||||
### 6.1 Publish a dataset (create NFT + Datatoken) with a fixed rate exchange
|
### 6.1 Publish a dataset (create NFT + Datatoken) with a fixed rate exchange
|
||||||
```Typescript
|
```Typescript
|
||||||
const factory = new NftFactory(addresses.ERC721Factory, publisherAccount)
|
const factory = new NftFactory(
|
||||||
|
addresses.ERC721Factory,
|
||||||
|
publisherAccount,
|
||||||
|
await publisherAccount.getChainId()
|
||||||
|
)
|
||||||
|
|
||||||
const nftParams: NftCreateData = {
|
const nftParams: NftCreateData = {
|
||||||
name: FRE_NFT_NAME,
|
name: FRE_NFT_NAME,
|
||||||
@ -409,7 +413,11 @@ Now let's console log the DID to check everything is working
|
|||||||
|
|
||||||
### 6.3 Marketplace displays fixed rate asset for sale
|
### 6.3 Marketplace displays fixed rate asset for sale
|
||||||
```Typescript
|
```Typescript
|
||||||
const fixedRate = new FixedRateExchange(freAddress, publisherAccount)
|
const fixedRate = new FixedRateExchange(
|
||||||
|
freAddress,
|
||||||
|
publisherAccount,
|
||||||
|
await publisherAccount.getChainId()
|
||||||
|
)
|
||||||
const oceanAmount = await (
|
const oceanAmount = await (
|
||||||
await fixedRate.calcBaseInGivenDatatokensOut(freId, '1')
|
await fixedRate.calcBaseInGivenDatatokensOut(freId, '1')
|
||||||
).baseTokenAmount
|
).baseTokenAmount
|
||||||
@ -424,7 +432,7 @@ Now that the market has fetched those values it can display the asset on the fro
|
|||||||
|
|
||||||
### 7.1 Consumer buys a fixed rate asset data asset, and downloads it
|
### 7.1 Consumer buys a fixed rate asset data asset, and downloads it
|
||||||
```Typescript
|
```Typescript
|
||||||
datatoken = new Datatoken(publisherAccount)
|
datatoken = new Datatoken(publisherAccount, await publisherAccount.getChainId())
|
||||||
const DATATOKEN_AMOUNT = '10000'
|
const DATATOKEN_AMOUNT = '10000'
|
||||||
|
|
||||||
await datatoken.mint(
|
await datatoken.mint(
|
||||||
@ -473,7 +481,11 @@ Before we call the contract we have to call `approve` so that the contract can m
|
|||||||
DATATOKEN_AMOUNT
|
DATATOKEN_AMOUNT
|
||||||
)
|
)
|
||||||
|
|
||||||
const fixedRate = new FixedRateExchange(freAddress, consumerAccount)
|
const fixedRate = new FixedRateExchange(
|
||||||
|
freAddress,
|
||||||
|
consumerAccount,
|
||||||
|
await consumerAccount.getChainId()
|
||||||
|
)
|
||||||
```
|
```
|
||||||
Now we can make the contract call
|
Now we can make the contract call
|
||||||
```Typescript
|
```Typescript
|
||||||
@ -517,7 +529,7 @@ Next, we need to initialize the provider
|
|||||||
validUntil: initializeData.providerFee.validUntil
|
validUntil: initializeData.providerFee.validUntil
|
||||||
}
|
}
|
||||||
|
|
||||||
datatoken = new Datatoken(consumerAccount)
|
datatoken = new Datatoken(consumerAccount, await consumerAccount.getChainId())
|
||||||
|
|
||||||
```
|
```
|
||||||
Lets now make the payment
|
Lets now make the payment
|
||||||
@ -574,7 +586,11 @@ Lets check that the download URL was successfully received
|
|||||||
|
|
||||||
### 8.1 Publish a dataset (create NFT + Datatoken) with a dispenser
|
### 8.1 Publish a dataset (create NFT + Datatoken) with a dispenser
|
||||||
```Typescript
|
```Typescript
|
||||||
const factory = new NftFactory(addresses.ERC721Factory, publisherAccount)
|
const factory = new NftFactory(
|
||||||
|
addresses.ERC721Factory,
|
||||||
|
publisherAccount,
|
||||||
|
await publisherAccount.getChainId()
|
||||||
|
)
|
||||||
|
|
||||||
const nftParams: NftCreateData = {
|
const nftParams: NftCreateData = {
|
||||||
name: DISP_NFT_NAME,
|
name: DISP_NFT_NAME,
|
||||||
@ -679,8 +695,12 @@ Now we need to encrypt file(s) using provider
|
|||||||
|
|
||||||
### 9.1 Consumer gets a dispenser data asset, and downloads it
|
### 9.1 Consumer gets a dispenser data asset, and downloads it
|
||||||
```Typescript
|
```Typescript
|
||||||
datatoken = new Datatoken(publisherAccount)
|
datatoken = new Datatoken(publisherAccount, await publisherAccount.getChainId())
|
||||||
const dispenser = new Dispenser(addresses.Dispenser, consumerAccount)
|
const dispenser = new Dispenser(
|
||||||
|
addresses.Dispenser,
|
||||||
|
consumerAccount,
|
||||||
|
await consumerAccount.getChainId()
|
||||||
|
)
|
||||||
|
|
||||||
let consumerDTBalance = await balance(
|
let consumerDTBalance = await balance(
|
||||||
consumerAccount,
|
consumerAccount,
|
||||||
@ -709,7 +729,7 @@ Now we need to encrypt file(s) using provider
|
|||||||
const resolvedDDO = await aquarius.waitForAqua(fixedDDO.id)
|
const resolvedDDO = await aquarius.waitForAqua(fixedDDO.id)
|
||||||
assert(resolvedDDO, 'Cannot fetch DDO from Aquarius')
|
assert(resolvedDDO, 'Cannot fetch DDO from Aquarius')
|
||||||
|
|
||||||
datatoken = new Datatoken(consumerAccount)
|
datatoken = new Datatoken(consumerAccount, await consumerAccount.getChainId())
|
||||||
|
|
||||||
```
|
```
|
||||||
At this point we need to encrypt file(s) using provider
|
At this point we need to encrypt file(s) using provider
|
||||||
@ -791,7 +811,7 @@ Here are the steps:
|
|||||||
### 10.1 Add key-value pair to data NFT
|
### 10.1 Add key-value pair to data NFT
|
||||||
Let's start by using the `setData` method to update the nft key value store with some data
|
Let's start by using the `setData` method to update the nft key value store with some data
|
||||||
```Typescript
|
```Typescript
|
||||||
const nft = new Nft(publisherAccount)
|
const nft = new Nft(publisherAccount, await publisherAccount.getChainId())
|
||||||
const data = 'SomeData'
|
const data = 'SomeData'
|
||||||
try {
|
try {
|
||||||
await nft.setData(
|
await nft.setData(
|
||||||
|
@ -293,7 +293,11 @@ async function createAsset(
|
|||||||
) {
|
) {
|
||||||
const nft = new Nft(owner, (await owner.provider.getNetwork()).chainId)
|
const nft = new Nft(owner, (await owner.provider.getNetwork()).chainId)
|
||||||
|
|
||||||
const nftFactory = new NftFactory(addresses.ERC721Factory, owner)
|
const nftFactory = new NftFactory(
|
||||||
|
addresses.ERC721Factory,
|
||||||
|
owner,
|
||||||
|
await owner.getChainId()
|
||||||
|
)
|
||||||
|
|
||||||
const chain = (await owner.provider.getNetwork()).chainId
|
const chain = (await owner.provider.getNetwork()).chainId
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import { AbiItem } from '../@types'
|
import { AbiItem } from '../@types'
|
||||||
import { LogLevel } from '../utils'
|
import { LogLevel } from '../utils'
|
||||||
|
|
||||||
|
type SDK = 'evm' | 'oasis'
|
||||||
|
|
||||||
export class Config {
|
export class Config {
|
||||||
/**
|
/**
|
||||||
* Ethereum node URL.
|
* Ethereum node URL.
|
||||||
@ -187,6 +189,6 @@ export class Config {
|
|||||||
veFeeEstimate?: string
|
veFeeEstimate?: string
|
||||||
|
|
||||||
// is confidential evm
|
// is confidential evm
|
||||||
confidentialEVM?: boolean
|
sdk?: SDK
|
||||||
accessListFactory?: string
|
accessListFactory?: string
|
||||||
}
|
}
|
||||||
|
@ -35,11 +35,12 @@ export const configHelperNetworks: Config[] = [
|
|||||||
// comment th following configs if running on macOS
|
// comment th following configs if running on macOS
|
||||||
metadataCacheUri: 'http://172.15.0.5:5000',
|
metadataCacheUri: 'http://172.15.0.5:5000',
|
||||||
providerUri: 'http://172.15.0.4:8030',
|
providerUri: 'http://172.15.0.4:8030',
|
||||||
subgraphUri: 'https://172.15.0.15:8000'
|
subgraphUri: 'https://172.15.0.15:8000',
|
||||||
// uncomment the following configs if running on macOS
|
// uncomment the following configs if running on macOS
|
||||||
// metadataCacheUri: 'http://127.0.0.1:5000',
|
// metadataCacheUri: 'http://127.0.0.1:5000',
|
||||||
// providerUri: 'http://127.0.0.1:8030/',
|
// providerUri: 'http://127.0.0.1:8030/',
|
||||||
// subgraphUri: 'http://127.0.0.1:9000/'
|
// subgraphUri: 'http://127.0.0.1:9000/'
|
||||||
|
sdk: 'evm'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
...configHelperNetworksBase,
|
...configHelperNetworksBase,
|
||||||
@ -48,7 +49,8 @@ export const configHelperNetworks: Config[] = [
|
|||||||
nodeUri: 'https://sepolia.infura.io/v3',
|
nodeUri: 'https://sepolia.infura.io/v3',
|
||||||
subgraphUri: 'https://v4.subgraph.sepolia.oceanprotocol.com',
|
subgraphUri: 'https://v4.subgraph.sepolia.oceanprotocol.com',
|
||||||
explorerUri: 'https://sepolia.etherscan.io',
|
explorerUri: 'https://sepolia.etherscan.io',
|
||||||
gasFeeMultiplier: 1.1
|
gasFeeMultiplier: 1.1,
|
||||||
|
sdk: 'evm'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
...configHelperNetworksBase,
|
...configHelperNetworksBase,
|
||||||
@ -61,7 +63,8 @@ export const configHelperNetworks: Config[] = [
|
|||||||
transactionBlockTimeout: 150,
|
transactionBlockTimeout: 150,
|
||||||
transactionConfirmationBlocks: 5,
|
transactionConfirmationBlocks: 5,
|
||||||
transactionPollingTimeout: 1750,
|
transactionPollingTimeout: 1750,
|
||||||
gasFeeMultiplier: 1.05
|
gasFeeMultiplier: 1.05,
|
||||||
|
sdk: 'evm'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
...configHelperNetworksBase,
|
...configHelperNetworksBase,
|
||||||
@ -71,7 +74,8 @@ export const configHelperNetworks: Config[] = [
|
|||||||
subgraphUri: 'https://v4.subgraph.polygon.oceanprotocol.com',
|
subgraphUri: 'https://v4.subgraph.polygon.oceanprotocol.com',
|
||||||
explorerUri: 'https://polygonscan.com',
|
explorerUri: 'https://polygonscan.com',
|
||||||
oceanTokenSymbol: 'mOCEAN',
|
oceanTokenSymbol: 'mOCEAN',
|
||||||
gasFeeMultiplier: 1.6
|
gasFeeMultiplier: 1.6,
|
||||||
|
sdk: 'evm'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
...configHelperNetworksBase,
|
...configHelperNetworksBase,
|
||||||
@ -80,7 +84,8 @@ export const configHelperNetworks: Config[] = [
|
|||||||
nodeUri: 'https://rpc.gaiaxtestnet.oceanprotocol.com',
|
nodeUri: 'https://rpc.gaiaxtestnet.oceanprotocol.com',
|
||||||
providerUri: 'https://v4.provider.gaiaxtestnet.oceanprotocol.com',
|
providerUri: 'https://v4.provider.gaiaxtestnet.oceanprotocol.com',
|
||||||
subgraphUri: 'https://v4.subgraph.gaiaxtestnet.oceanprotocol.com',
|
subgraphUri: 'https://v4.subgraph.gaiaxtestnet.oceanprotocol.com',
|
||||||
explorerUri: 'https://blockscout.gaiaxtestnet.oceanprotocol.com'
|
explorerUri: 'https://blockscout.gaiaxtestnet.oceanprotocol.com',
|
||||||
|
sdk: 'evm'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
...configHelperNetworksBase,
|
...configHelperNetworksBase,
|
||||||
@ -89,7 +94,8 @@ export const configHelperNetworks: Config[] = [
|
|||||||
nodeUri: 'https://polygon-mumbai.infura.io/v3',
|
nodeUri: 'https://polygon-mumbai.infura.io/v3',
|
||||||
subgraphUri: 'https://v4.subgraph.mumbai.oceanprotocol.com',
|
subgraphUri: 'https://v4.subgraph.mumbai.oceanprotocol.com',
|
||||||
explorerUri: 'https://mumbai.polygonscan.com',
|
explorerUri: 'https://mumbai.polygonscan.com',
|
||||||
gasFeeMultiplier: 1.1
|
gasFeeMultiplier: 1.1,
|
||||||
|
sdk: 'evm'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
...configHelperNetworksBase,
|
...configHelperNetworksBase,
|
||||||
@ -98,7 +104,8 @@ export const configHelperNetworks: Config[] = [
|
|||||||
nodeUri: 'https://bsc-dataseed.binance.org',
|
nodeUri: 'https://bsc-dataseed.binance.org',
|
||||||
subgraphUri: 'https://v4.subgraph.bsc.oceanprotocol.com',
|
subgraphUri: 'https://v4.subgraph.bsc.oceanprotocol.com',
|
||||||
explorerUri: 'https://bscscan.com/',
|
explorerUri: 'https://bscscan.com/',
|
||||||
gasFeeMultiplier: 1.05
|
gasFeeMultiplier: 1.05,
|
||||||
|
sdk: 'evm'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
...configHelperNetworksBase,
|
...configHelperNetworksBase,
|
||||||
@ -107,7 +114,8 @@ export const configHelperNetworks: Config[] = [
|
|||||||
nodeUri: 'https://rpc.energyweb.org',
|
nodeUri: 'https://rpc.energyweb.org',
|
||||||
subgraphUri: 'https://v4.subgraph.energyweb.oceanprotocol.com',
|
subgraphUri: 'https://v4.subgraph.energyweb.oceanprotocol.com',
|
||||||
explorerUri: 'https://explorer.energyweb.org',
|
explorerUri: 'https://explorer.energyweb.org',
|
||||||
gasFeeMultiplier: 1.05
|
gasFeeMultiplier: 1.05,
|
||||||
|
sdk: 'evm'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
...configHelperNetworksBase,
|
...configHelperNetworksBase,
|
||||||
@ -116,7 +124,8 @@ export const configHelperNetworks: Config[] = [
|
|||||||
nodeUri: 'https://moonriver.api.onfinality.io/public',
|
nodeUri: 'https://moonriver.api.onfinality.io/public',
|
||||||
subgraphUri: 'https://v4.subgraph.moonriver.oceanprotocol.com',
|
subgraphUri: 'https://v4.subgraph.moonriver.oceanprotocol.com',
|
||||||
explorerUri: 'https://moonriver.moonscan.io/',
|
explorerUri: 'https://moonriver.moonscan.io/',
|
||||||
gasFeeMultiplier: 1.05
|
gasFeeMultiplier: 1.05,
|
||||||
|
sdk: 'evm'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
...configHelperNetworksBase,
|
...configHelperNetworksBase,
|
||||||
@ -127,7 +136,8 @@ export const configHelperNetworks: Config[] = [
|
|||||||
providerUri: 'https://provider.v4.genx.delta-dao.com',
|
providerUri: 'https://provider.v4.genx.delta-dao.com',
|
||||||
subgraphUri: 'https://subgraph.v4.genx.minimal-gaia-x.eu',
|
subgraphUri: 'https://subgraph.v4.genx.minimal-gaia-x.eu',
|
||||||
explorerUri: 'https://explorer.genx.minimal-gaia-x.eu/',
|
explorerUri: 'https://explorer.genx.minimal-gaia-x.eu/',
|
||||||
gasFeeMultiplier: 1
|
gasFeeMultiplier: 1,
|
||||||
|
sdk: 'evm'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
...configHelperNetworksBase,
|
...configHelperNetworksBase,
|
||||||
@ -136,7 +146,8 @@ export const configHelperNetworks: Config[] = [
|
|||||||
nodeUri: 'https://mainnet.optimism.io',
|
nodeUri: 'https://mainnet.optimism.io',
|
||||||
subgraphUri: 'https://v4.subgraph.optimism.oceanprotocol.com',
|
subgraphUri: 'https://v4.subgraph.optimism.oceanprotocol.com',
|
||||||
explorerUri: 'https://optimistic.etherscan.io/',
|
explorerUri: 'https://optimistic.etherscan.io/',
|
||||||
gasFeeMultiplier: 1.1
|
gasFeeMultiplier: 1.1,
|
||||||
|
sdk: 'evm'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
...configHelperNetworksBase,
|
...configHelperNetworksBase,
|
||||||
@ -145,7 +156,8 @@ export const configHelperNetworks: Config[] = [
|
|||||||
nodeUri: 'https://sepolia.optimism.io',
|
nodeUri: 'https://sepolia.optimism.io',
|
||||||
subgraphUri: 'https://v4.subgraph.optimism-sepolia.oceanprotocol.com',
|
subgraphUri: 'https://v4.subgraph.optimism-sepolia.oceanprotocol.com',
|
||||||
explorerUri: 'https://sepolia-optimism.etherscan.io/',
|
explorerUri: 'https://sepolia-optimism.etherscan.io/',
|
||||||
gasFeeMultiplier: 1.1
|
gasFeeMultiplier: 1.1,
|
||||||
|
sdk: 'evm'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
...configHelperNetworksBase,
|
...configHelperNetworksBase,
|
||||||
@ -154,7 +166,8 @@ export const configHelperNetworks: Config[] = [
|
|||||||
nodeUri: 'https://sapphire.oasis.io',
|
nodeUri: 'https://sapphire.oasis.io',
|
||||||
subgraphUri: 'https://v4.subgraph.sapphire-mainnet.oceanprotocol.com/',
|
subgraphUri: 'https://v4.subgraph.sapphire-mainnet.oceanprotocol.com/',
|
||||||
explorerUri: 'https://explorer.oasis.io/mainnet/sapphire/',
|
explorerUri: 'https://explorer.oasis.io/mainnet/sapphire/',
|
||||||
gasFeeMultiplier: 1
|
gasFeeMultiplier: 1,
|
||||||
|
sdk: 'oasis'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
...configHelperNetworksBase,
|
...configHelperNetworksBase,
|
||||||
@ -164,7 +177,8 @@ export const configHelperNetworks: Config[] = [
|
|||||||
subgraphUri:
|
subgraphUri:
|
||||||
'https://v4.subgraph.sapphire-testnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph',
|
'https://v4.subgraph.sapphire-testnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph',
|
||||||
explorerUri: 'https://explorer.oasis.io/testnet/sapphire/',
|
explorerUri: 'https://explorer.oasis.io/testnet/sapphire/',
|
||||||
gasFeeMultiplier: 1
|
gasFeeMultiplier: 1,
|
||||||
|
sdk: 'oasis'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
...configHelperNetworksBase,
|
...configHelperNetworksBase,
|
||||||
@ -174,7 +188,8 @@ export const configHelperNetworks: Config[] = [
|
|||||||
metadataCacheUri: 'https://aquarius.dev.pontus-x.eu',
|
metadataCacheUri: 'https://aquarius.dev.pontus-x.eu',
|
||||||
providerUri: 'https://provider.dev.pontus-x.eu',
|
providerUri: 'https://provider.dev.pontus-x.eu',
|
||||||
subgraphUri: 'https://subgraph.dev.pontus-x.eu',
|
subgraphUri: 'https://subgraph.dev.pontus-x.eu',
|
||||||
explorerUri: 'https://explorer.dev.pontus-x.eu/testnet/pontusx'
|
explorerUri: 'https://explorer.dev.pontus-x.eu/testnet/pontusx',
|
||||||
|
sdk: 'evm'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -315,14 +330,17 @@ export class ConfigHelper {
|
|||||||
addresses
|
addresses
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
config.confidentialEVM =
|
|
||||||
filterBy === 'chainId'
|
if (!('sdk' in config) || config.sdk === null) {
|
||||||
? KNOWN_CONFIDENTIAL_EVMS.includes(Number(network))
|
if (KNOWN_CONFIDENTIAL_EVMS.includes(config.chainId)) {
|
||||||
: network.toString().includes('oasis_sap')
|
config.sdk = 'oasis'
|
||||||
if (config.confidentialEVM) {
|
} else {
|
||||||
config.accessListFactory = contractAddressesConfig.accessListFactory
|
config.sdk = 'evm'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
config.accessListFactory = contractAddressesConfig.accessListFactory
|
||||||
|
|
||||||
config = { ...config, ...contractAddressesConfig }
|
config = { ...config, ...contractAddressesConfig }
|
||||||
|
|
||||||
const nodeUri = infuraProjectId
|
const nodeUri = infuraProjectId
|
||||||
|
@ -96,10 +96,9 @@ export class AccessListContract extends SmartContractWithAddress {
|
|||||||
): Promise<ReceiptOrEstimate<G>> {
|
): Promise<ReceiptOrEstimate<G>> {
|
||||||
const estGas = await this.contract.estimateGas.mint(user, tokenUri)
|
const estGas = await this.contract.estimateGas.mint(user, tokenUri)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.mint,
|
this.contract.mint,
|
||||||
user,
|
user,
|
||||||
@ -122,10 +121,9 @@ export class AccessListContract extends SmartContractWithAddress {
|
|||||||
): Promise<ReceiptOrEstimate<G>> {
|
): Promise<ReceiptOrEstimate<G>> {
|
||||||
const estGas = await this.contract.estimateGas.batchMint(users, tokenUris)
|
const estGas = await this.contract.estimateGas.batchMint(users, tokenUris)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.batchMint,
|
this.contract.batchMint,
|
||||||
users,
|
users,
|
||||||
@ -146,10 +144,9 @@ export class AccessListContract extends SmartContractWithAddress {
|
|||||||
): Promise<ReceiptOrEstimate<G>> {
|
): Promise<ReceiptOrEstimate<G>> {
|
||||||
const estGas = await this.contract.estimateGas.burn(tokenId)
|
const estGas = await this.contract.estimateGas.burn(tokenId)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.burn,
|
this.contract.burn,
|
||||||
tokenId
|
tokenId
|
||||||
@ -169,10 +166,9 @@ export class AccessListContract extends SmartContractWithAddress {
|
|||||||
): Promise<ReceiptOrEstimate<G>> {
|
): Promise<ReceiptOrEstimate<G>> {
|
||||||
const estGas = await this.contract.estimateGas.transferOwnership(newOwner)
|
const estGas = await this.contract.estimateGas.transferOwnership(newOwner)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.transferOwnership,
|
this.contract.transferOwnership,
|
||||||
newOwner
|
newOwner
|
||||||
@ -190,10 +186,9 @@ export class AccessListContract extends SmartContractWithAddress {
|
|||||||
): Promise<ReceiptOrEstimate<G>> {
|
): Promise<ReceiptOrEstimate<G>> {
|
||||||
const estGas = await this.contract.estimateGas.renounceOwnership()
|
const estGas = await this.contract.estimateGas.renounceOwnership()
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.renounceOwnership
|
this.contract.renounceOwnership
|
||||||
)
|
)
|
||||||
|
@ -70,7 +70,7 @@ export class AccesslistFactory extends SmartContractWithAddress {
|
|||||||
try {
|
try {
|
||||||
const tx = await sendTx(
|
const tx = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.deployAccessListContract,
|
this.contract.deployAccessListContract,
|
||||||
nameAccessList,
|
nameAccessList,
|
||||||
@ -144,10 +144,9 @@ export class AccesslistFactory extends SmartContractWithAddress {
|
|||||||
|
|
||||||
const estGas = await this.contract.estimateGas.changeTemplateAddress(templateAddress)
|
const estGas = await this.contract.estimateGas.changeTemplateAddress(templateAddress)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.functions.changeTemplateAddress,
|
this.contract.functions.changeTemplateAddress,
|
||||||
templateAddress
|
templateAddress
|
||||||
|
@ -44,7 +44,7 @@ export class Datatoken extends SmartContract {
|
|||||||
) {
|
) {
|
||||||
super(signer, network, config, abi)
|
super(signer, network, config, abi)
|
||||||
this.abiEnterprise = abiEnterprise || (ERC20TemplateEnterprise.abi as AbiItem[])
|
this.abiEnterprise = abiEnterprise || (ERC20TemplateEnterprise.abi as AbiItem[])
|
||||||
this.nft = new Nft(this.signer)
|
this.nft = new Nft(this.signer, network)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -62,7 +62,6 @@ export class Datatoken extends SmartContract {
|
|||||||
estimateGas?: G
|
estimateGas?: G
|
||||||
): Promise<ReceiptOrEstimate<G>> {
|
): Promise<ReceiptOrEstimate<G>> {
|
||||||
const dtContract = this.getContract(dtAddress)
|
const dtContract = this.getContract(dtAddress)
|
||||||
|
|
||||||
const estGas = await dtContract.estimateGas.approve(
|
const estGas = await dtContract.estimateGas.approve(
|
||||||
spender,
|
spender,
|
||||||
amountToUnits(null, null, amount, 18)
|
amountToUnits(null, null, amount, 18)
|
||||||
@ -71,7 +70,7 @@ export class Datatoken extends SmartContract {
|
|||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
dtContract.approve,
|
dtContract.approve,
|
||||||
spender,
|
spender,
|
||||||
@ -124,7 +123,7 @@ export class Datatoken extends SmartContract {
|
|||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
dtContract.createFixedRate,
|
dtContract.createFixedRate,
|
||||||
fixedRateParams.fixedRateAddress,
|
fixedRateParams.fixedRateAddress,
|
||||||
@ -166,7 +165,6 @@ export class Datatoken extends SmartContract {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const dtContract = this.getContract(dtAddress)
|
const dtContract = this.getContract(dtAddress)
|
||||||
|
|
||||||
if (!dispenserParams.allowedSwapper) dispenserParams.allowedSwapper = ZERO_ADDRESS
|
if (!dispenserParams.allowedSwapper) dispenserParams.allowedSwapper = ZERO_ADDRESS
|
||||||
|
|
||||||
dispenserParams.withMint = dispenserParams.withMint !== false
|
dispenserParams.withMint = dispenserParams.withMint !== false
|
||||||
@ -184,7 +182,7 @@ export class Datatoken extends SmartContract {
|
|||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
dtContract.createDispenser,
|
dtContract.createDispenser,
|
||||||
dispenserAddress,
|
dispenserAddress,
|
||||||
@ -213,7 +211,6 @@ export class Datatoken extends SmartContract {
|
|||||||
estimateGas?: G
|
estimateGas?: G
|
||||||
): Promise<ReceiptOrEstimate<G>> {
|
): Promise<ReceiptOrEstimate<G>> {
|
||||||
const dtContract = this.getContract(dtAddress)
|
const dtContract = this.getContract(dtAddress)
|
||||||
|
|
||||||
if ((await this.getPermissions(dtAddress, address)).minter !== true) {
|
if ((await this.getPermissions(dtAddress, address)).minter !== true) {
|
||||||
throw new Error(`Caller is not Minter`)
|
throw new Error(`Caller is not Minter`)
|
||||||
}
|
}
|
||||||
@ -228,7 +225,7 @@ export class Datatoken extends SmartContract {
|
|||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
dtContract.mint,
|
dtContract.mint,
|
||||||
toAddress || address,
|
toAddress || address,
|
||||||
@ -256,7 +253,6 @@ export class Datatoken extends SmartContract {
|
|||||||
estimateGas?: G
|
estimateGas?: G
|
||||||
): Promise<ReceiptOrEstimate<G>> {
|
): Promise<ReceiptOrEstimate<G>> {
|
||||||
const dtContract = this.getContract(dtAddress)
|
const dtContract = this.getContract(dtAddress)
|
||||||
|
|
||||||
if ((await this.isDatatokenDeployer(dtAddress, address)) !== true) {
|
if ((await this.isDatatokenDeployer(dtAddress, address)) !== true) {
|
||||||
throw new Error(`Caller is not DatatokenDeployer`)
|
throw new Error(`Caller is not DatatokenDeployer`)
|
||||||
}
|
}
|
||||||
@ -266,7 +262,7 @@ export class Datatoken extends SmartContract {
|
|||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
dtContract.addMinter,
|
dtContract.addMinter,
|
||||||
minter
|
minter
|
||||||
@ -291,7 +287,6 @@ export class Datatoken extends SmartContract {
|
|||||||
estimateGas?: G
|
estimateGas?: G
|
||||||
): Promise<ReceiptOrEstimate<G>> {
|
): Promise<ReceiptOrEstimate<G>> {
|
||||||
const dtContract = this.getContract(dtAddress)
|
const dtContract = this.getContract(dtAddress)
|
||||||
|
|
||||||
if ((await this.isDatatokenDeployer(dtAddress, address)) !== true) {
|
if ((await this.isDatatokenDeployer(dtAddress, address)) !== true) {
|
||||||
throw new Error(`Caller is not DatatokenDeployer`)
|
throw new Error(`Caller is not DatatokenDeployer`)
|
||||||
}
|
}
|
||||||
@ -301,7 +296,7 @@ export class Datatoken extends SmartContract {
|
|||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
dtContract.removeMinter,
|
dtContract.removeMinter,
|
||||||
minter
|
minter
|
||||||
@ -326,7 +321,6 @@ export class Datatoken extends SmartContract {
|
|||||||
estimateGas?: G
|
estimateGas?: G
|
||||||
): Promise<ReceiptOrEstimate<G>> {
|
): Promise<ReceiptOrEstimate<G>> {
|
||||||
const dtContract = this.getContract(dtAddress)
|
const dtContract = this.getContract(dtAddress)
|
||||||
|
|
||||||
if ((await this.isDatatokenDeployer(dtAddress, address)) !== true) {
|
if ((await this.isDatatokenDeployer(dtAddress, address)) !== true) {
|
||||||
throw new Error(`Caller is not DatatokenDeployer`)
|
throw new Error(`Caller is not DatatokenDeployer`)
|
||||||
}
|
}
|
||||||
@ -336,7 +330,7 @@ export class Datatoken extends SmartContract {
|
|||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
dtContract.addPaymentManager,
|
dtContract.addPaymentManager,
|
||||||
paymentManager
|
paymentManager
|
||||||
@ -361,7 +355,6 @@ export class Datatoken extends SmartContract {
|
|||||||
estimateGas?: G
|
estimateGas?: G
|
||||||
): Promise<ReceiptOrEstimate<G>> {
|
): Promise<ReceiptOrEstimate<G>> {
|
||||||
const dtContract = this.getContract(dtAddress)
|
const dtContract = this.getContract(dtAddress)
|
||||||
|
|
||||||
if ((await this.isDatatokenDeployer(dtAddress, address)) !== true) {
|
if ((await this.isDatatokenDeployer(dtAddress, address)) !== true) {
|
||||||
throw new Error(`Caller is not DatatokenDeployer`)
|
throw new Error(`Caller is not DatatokenDeployer`)
|
||||||
}
|
}
|
||||||
@ -371,7 +364,7 @@ export class Datatoken extends SmartContract {
|
|||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
dtContract.removePaymentManager,
|
dtContract.removePaymentManager,
|
||||||
paymentManager
|
paymentManager
|
||||||
@ -413,7 +406,7 @@ export class Datatoken extends SmartContract {
|
|||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
dtContract.setPaymentCollector,
|
dtContract.setPaymentCollector,
|
||||||
paymentCollector
|
paymentCollector
|
||||||
@ -469,13 +462,12 @@ export class Datatoken extends SmartContract {
|
|||||||
estimateGas?: G
|
estimateGas?: G
|
||||||
): Promise<ReceiptOrEstimate<G>> {
|
): Promise<ReceiptOrEstimate<G>> {
|
||||||
const dtContract = this.getContract(dtAddress)
|
const dtContract = this.getContract(dtAddress)
|
||||||
|
|
||||||
const estGas = await dtContract.estimateGas.transfer(toAddress, amount)
|
const estGas = await dtContract.estimateGas.transfer(toAddress, amount)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
dtContract.transfer,
|
dtContract.transfer,
|
||||||
toAddress,
|
toAddress,
|
||||||
@ -518,10 +510,9 @@ export class Datatoken extends SmartContract {
|
|||||||
consumeMarketFee
|
consumeMarketFee
|
||||||
)
|
)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
dtContract.startOrder,
|
dtContract.startOrder,
|
||||||
consumer,
|
consumer,
|
||||||
@ -552,10 +543,9 @@ export class Datatoken extends SmartContract {
|
|||||||
|
|
||||||
const estGas = await dtContract.estimateGas.reuseOrder(orderTxId, providerFees)
|
const estGas = await dtContract.estimateGas.reuseOrder(orderTxId, providerFees)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
dtContract.reuseOrder,
|
dtContract.reuseOrder,
|
||||||
orderTxId,
|
orderTxId,
|
||||||
@ -587,10 +577,9 @@ export class Datatoken extends SmartContract {
|
|||||||
freContractParams
|
freContractParams
|
||||||
)
|
)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
dtContract.buyFromFreAndOrder,
|
dtContract.buyFromFreAndOrder,
|
||||||
orderParams,
|
orderParams,
|
||||||
@ -620,10 +609,9 @@ export class Datatoken extends SmartContract {
|
|||||||
dispenserContract
|
dispenserContract
|
||||||
)
|
)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
dtContract.buyFromDispenserAndOrder,
|
dtContract.buyFromDispenserAndOrder,
|
||||||
orderParams,
|
orderParams,
|
||||||
@ -652,7 +640,6 @@ export class Datatoken extends SmartContract {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const dtContract = this.getContract(dtAddress)
|
const dtContract = this.getContract(dtAddress)
|
||||||
|
|
||||||
const valueHex = ethers.utils.hexlify(ethers.utils.toUtf8Bytes(value))
|
const valueHex = ethers.utils.hexlify(ethers.utils.toUtf8Bytes(value))
|
||||||
|
|
||||||
const estGas = await dtContract.estimateGas.setData(valueHex)
|
const estGas = await dtContract.estimateGas.setData(valueHex)
|
||||||
@ -660,7 +647,7 @@ export class Datatoken extends SmartContract {
|
|||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
dtContract.setData,
|
dtContract.setData,
|
||||||
valueHex
|
valueHex
|
||||||
@ -686,13 +673,12 @@ export class Datatoken extends SmartContract {
|
|||||||
throw new Error('Caller is NOT Nft Owner')
|
throw new Error('Caller is NOT Nft Owner')
|
||||||
}
|
}
|
||||||
const dtContract = this.getContract(dtAddress)
|
const dtContract = this.getContract(dtAddress)
|
||||||
|
|
||||||
const estGas = await dtContract.estimateGas.cleanPermissions()
|
const estGas = await dtContract.estimateGas.cleanPermissions()
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
dtContract.cleanPermissions
|
dtContract.cleanPermissions
|
||||||
)
|
)
|
||||||
@ -856,10 +842,9 @@ export class Datatoken extends SmartContract {
|
|||||||
publishMarketFeeAmount
|
publishMarketFeeAmount
|
||||||
)
|
)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
dtContract.setPublishingMarketFee,
|
dtContract.setPublishingMarketFee,
|
||||||
publishMarketFeeAddress,
|
publishMarketFeeAddress,
|
||||||
|
@ -6,7 +6,6 @@ import { AbiItem, ReceiptOrEstimate } from '../@types'
|
|||||||
import { AccessListContract } from './AccessList'
|
import { AccessListContract } from './AccessList'
|
||||||
import { Config } from '../config'
|
import { Config } from '../config'
|
||||||
import { sendTx } from '../utils'
|
import { sendTx } from '../utils'
|
||||||
import * as sapphire from '@oasisprotocol/sapphire-paratime'
|
|
||||||
|
|
||||||
export class Datatoken4 extends Datatoken {
|
export class Datatoken4 extends Datatoken {
|
||||||
public accessList: AccessListContract
|
public accessList: AccessListContract
|
||||||
@ -73,7 +72,6 @@ export class Datatoken4 extends Datatoken {
|
|||||||
dtAddress: string,
|
dtAddress: string,
|
||||||
address: string,
|
address: string,
|
||||||
consumer: string,
|
consumer: string,
|
||||||
confidentialEVM: boolean = true,
|
|
||||||
estimateGas?: G
|
estimateGas?: G
|
||||||
): Promise<ReceiptOrEstimate<G>> {
|
): Promise<ReceiptOrEstimate<G>> {
|
||||||
if (!(await this.isDatatokenDeployer(dtAddress, consumer))) {
|
if (!(await this.isDatatokenDeployer(dtAddress, consumer))) {
|
||||||
@ -86,7 +84,7 @@ export class Datatoken4 extends Datatoken {
|
|||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
confidentialEVM === true ? sapphire.wrap(this.signer) : this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
dtContract.functions.setAllowListContract,
|
dtContract.functions.setAllowListContract,
|
||||||
address
|
address
|
||||||
@ -108,7 +106,6 @@ export class Datatoken4 extends Datatoken {
|
|||||||
dtAddress: string,
|
dtAddress: string,
|
||||||
address: string,
|
address: string,
|
||||||
consumer: string,
|
consumer: string,
|
||||||
confidentialEVM: boolean = true,
|
|
||||||
estimateGas?: G
|
estimateGas?: G
|
||||||
): Promise<ReceiptOrEstimate<G>> {
|
): Promise<ReceiptOrEstimate<G>> {
|
||||||
if (!(await this.isDatatokenDeployer(dtAddress, consumer))) {
|
if (!(await this.isDatatokenDeployer(dtAddress, consumer))) {
|
||||||
@ -121,7 +118,7 @@ export class Datatoken4 extends Datatoken {
|
|||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
confidentialEVM === true ? sapphire.wrap(this.signer) : this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
dtContract.functions.setDenyListContract,
|
dtContract.functions.setDenyListContract,
|
||||||
address
|
address
|
||||||
@ -140,7 +137,6 @@ export class Datatoken4 extends Datatoken {
|
|||||||
public async setFileObject<G extends boolean = false>(
|
public async setFileObject<G extends boolean = false>(
|
||||||
dtAddress: string,
|
dtAddress: string,
|
||||||
address: string,
|
address: string,
|
||||||
confidentialEVM: boolean = true,
|
|
||||||
estimateGas?: G
|
estimateGas?: G
|
||||||
): Promise<ReceiptOrEstimate<G>> {
|
): Promise<ReceiptOrEstimate<G>> {
|
||||||
if (!(await this.isDatatokenDeployer(dtAddress, address))) {
|
if (!(await this.isDatatokenDeployer(dtAddress, address))) {
|
||||||
@ -153,7 +149,7 @@ export class Datatoken4 extends Datatoken {
|
|||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
confidentialEVM === true ? sapphire.wrap(this.signer) : this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
dtContract.functions.setFilesObject,
|
dtContract.functions.setFilesObject,
|
||||||
this.fileObject
|
this.fileObject
|
||||||
|
@ -58,11 +58,10 @@ export class Dispenser extends SmartContractWithAddress {
|
|||||||
allowedSwapper
|
allowedSwapper
|
||||||
)
|
)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
// Call createFixedRate contract method
|
// Call createFixedRate contract method
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.create,
|
this.contract.create,
|
||||||
dtAddress,
|
dtAddress,
|
||||||
@ -95,10 +94,9 @@ export class Dispenser extends SmartContractWithAddress {
|
|||||||
this.amountToUnits(null, maxBalance, 18)
|
this.amountToUnits(null, maxBalance, 18)
|
||||||
)
|
)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.activate,
|
this.contract.activate,
|
||||||
dtAddress,
|
dtAddress,
|
||||||
@ -121,10 +119,9 @@ export class Dispenser extends SmartContractWithAddress {
|
|||||||
): Promise<ReceiptOrEstimate<G>> {
|
): Promise<ReceiptOrEstimate<G>> {
|
||||||
const estGas = await this.contract.estimateGas.deactivate(dtAddress)
|
const estGas = await this.contract.estimateGas.deactivate(dtAddress)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.deactivate,
|
this.contract.deactivate,
|
||||||
dtAddress
|
dtAddress
|
||||||
@ -150,10 +147,9 @@ export class Dispenser extends SmartContractWithAddress {
|
|||||||
newAllowedSwapper
|
newAllowedSwapper
|
||||||
)
|
)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.setAllowedSwapper,
|
this.contract.setAllowedSwapper,
|
||||||
dtAddress,
|
dtAddress,
|
||||||
@ -184,10 +180,9 @@ export class Dispenser extends SmartContractWithAddress {
|
|||||||
destination
|
destination
|
||||||
)
|
)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.dispense,
|
this.contract.dispense,
|
||||||
dtAddress,
|
dtAddress,
|
||||||
@ -209,10 +204,9 @@ export class Dispenser extends SmartContractWithAddress {
|
|||||||
): Promise<ReceiptOrEstimate<G>> {
|
): Promise<ReceiptOrEstimate<G>> {
|
||||||
const estGas = await this.contract.estimateGas.ownerWithdraw(dtAddress)
|
const estGas = await this.contract.estimateGas.ownerWithdraw(dtAddress)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.ownerWithdraw,
|
this.contract.ownerWithdraw,
|
||||||
dtAddress
|
dtAddress
|
||||||
|
@ -64,10 +64,9 @@ export class FixedRateExchange extends SmartContractWithAddress {
|
|||||||
consumeMarketFeeFormatted
|
consumeMarketFeeFormatted
|
||||||
)
|
)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.buyDT,
|
this.contract.buyDT,
|
||||||
exchangeId,
|
exchangeId,
|
||||||
@ -118,10 +117,9 @@ export class FixedRateExchange extends SmartContractWithAddress {
|
|||||||
consumeMarketFeeFormatted
|
consumeMarketFeeFormatted
|
||||||
)
|
)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.sellDT,
|
this.contract.sellDT,
|
||||||
exchangeId,
|
exchangeId,
|
||||||
@ -159,10 +157,9 @@ export class FixedRateExchange extends SmartContractWithAddress {
|
|||||||
await this.amountToUnits(null, newRate, 18)
|
await this.amountToUnits(null, newRate, 18)
|
||||||
)
|
)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.setRate,
|
this.contract.setRate,
|
||||||
exchangeId,
|
exchangeId,
|
||||||
@ -189,10 +186,9 @@ export class FixedRateExchange extends SmartContractWithAddress {
|
|||||||
newAllowedSwapper
|
newAllowedSwapper
|
||||||
)
|
)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.setAllowedSwapper,
|
this.contract.setAllowedSwapper,
|
||||||
exchangeId,
|
exchangeId,
|
||||||
@ -216,10 +212,9 @@ export class FixedRateExchange extends SmartContractWithAddress {
|
|||||||
if (exchange.active === true) return null
|
if (exchange.active === true) return null
|
||||||
const estGas = await this.contract.estimateGas.toggleExchangeState(exchangeId)
|
const estGas = await this.contract.estimateGas.toggleExchangeState(exchangeId)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.toggleExchangeState,
|
this.contract.toggleExchangeState,
|
||||||
exchangeId
|
exchangeId
|
||||||
@ -243,10 +238,9 @@ export class FixedRateExchange extends SmartContractWithAddress {
|
|||||||
|
|
||||||
const estGas = await this.contract.estimateGas.toggleExchangeState(exchangeId)
|
const estGas = await this.contract.estimateGas.toggleExchangeState(exchangeId)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.toggleExchangeState,
|
this.contract.toggleExchangeState,
|
||||||
exchangeId
|
exchangeId
|
||||||
@ -469,10 +463,9 @@ export class FixedRateExchange extends SmartContractWithAddress {
|
|||||||
|
|
||||||
const estGas = await this.contract.estimateGas.toggleMintState(exchangeId, true)
|
const estGas = await this.contract.estimateGas.toggleMintState(exchangeId, true)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.toggleMintState,
|
this.contract.toggleMintState,
|
||||||
exchangeId,
|
exchangeId,
|
||||||
@ -497,10 +490,9 @@ export class FixedRateExchange extends SmartContractWithAddress {
|
|||||||
|
|
||||||
const estGas = await this.contract.estimateGas.toggleMintState(exchangeId, false)
|
const estGas = await this.contract.estimateGas.toggleMintState(exchangeId, false)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.toggleMintState,
|
this.contract.toggleMintState,
|
||||||
exchangeId,
|
exchangeId,
|
||||||
@ -533,10 +525,9 @@ export class FixedRateExchange extends SmartContractWithAddress {
|
|||||||
|
|
||||||
const estGas = await this.contract.estimateGas.collectBT(exchangeId, amountWei)
|
const estGas = await this.contract.estimateGas.collectBT(exchangeId, amountWei)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.collectBT,
|
this.contract.collectBT,
|
||||||
exchangeId,
|
exchangeId,
|
||||||
@ -569,10 +560,9 @@ export class FixedRateExchange extends SmartContractWithAddress {
|
|||||||
|
|
||||||
const estGas = await this.contract.estimateGas.collectDT(exchangeId, amountWei)
|
const estGas = await this.contract.estimateGas.collectDT(exchangeId, amountWei)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.collectDT,
|
this.contract.collectDT,
|
||||||
exchangeId,
|
exchangeId,
|
||||||
@ -596,10 +586,9 @@ export class FixedRateExchange extends SmartContractWithAddress {
|
|||||||
|
|
||||||
const estGas = await this.contract.estimateGas.collectMarketFee(exchangeId)
|
const estGas = await this.contract.estimateGas.collectMarketFee(exchangeId)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.collectMarketFee,
|
this.contract.collectMarketFee,
|
||||||
exchangeId
|
exchangeId
|
||||||
@ -623,10 +612,9 @@ export class FixedRateExchange extends SmartContractWithAddress {
|
|||||||
|
|
||||||
const estGas = await this.contract.estimateGas.collectOceanFee(exchangeId)
|
const estGas = await this.contract.estimateGas.collectOceanFee(exchangeId)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.collectOceanFee,
|
this.contract.collectOceanFee,
|
||||||
exchangeId
|
exchangeId
|
||||||
@ -680,10 +668,9 @@ export class FixedRateExchange extends SmartContractWithAddress {
|
|||||||
await this.amountToUnits(null, newMarketFee, 18)
|
await this.amountToUnits(null, newMarketFee, 18)
|
||||||
)
|
)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.updateMarketFee,
|
this.contract.updateMarketFee,
|
||||||
exchangeId,
|
exchangeId,
|
||||||
@ -710,10 +697,9 @@ export class FixedRateExchange extends SmartContractWithAddress {
|
|||||||
newMarketFeeCollector
|
newMarketFeeCollector
|
||||||
)
|
)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.updateMarketFeeCollector,
|
this.contract.updateMarketFeeCollector,
|
||||||
exchangeId,
|
exchangeId,
|
||||||
|
@ -104,7 +104,7 @@ export class Nft extends SmartContract {
|
|||||||
|
|
||||||
const tx = await sendTx(
|
const tx = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
nftContract.createERC20,
|
nftContract.createERC20,
|
||||||
templateIndex,
|
templateIndex,
|
||||||
@ -146,7 +146,7 @@ export class Nft extends SmartContract {
|
|||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
nftContract.addManager,
|
nftContract.addManager,
|
||||||
manager
|
manager
|
||||||
@ -180,7 +180,7 @@ export class Nft extends SmartContract {
|
|||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
nftContract.removeManager,
|
nftContract.removeManager,
|
||||||
manager
|
manager
|
||||||
@ -215,7 +215,7 @@ export class Nft extends SmartContract {
|
|||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
nftContract.addToCreateERC20List,
|
nftContract.addToCreateERC20List,
|
||||||
datatokenDeployer
|
datatokenDeployer
|
||||||
@ -254,7 +254,7 @@ export class Nft extends SmartContract {
|
|||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
nftContract.removeFromCreateERC20List,
|
nftContract.removeFromCreateERC20List,
|
||||||
datatokenDeployer
|
datatokenDeployer
|
||||||
@ -288,7 +288,7 @@ export class Nft extends SmartContract {
|
|||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
nftContract.addToMetadataList,
|
nftContract.addToMetadataList,
|
||||||
metadataUpdater
|
metadataUpdater
|
||||||
@ -311,7 +311,6 @@ export class Nft extends SmartContract {
|
|||||||
estimateGas?: G
|
estimateGas?: G
|
||||||
): Promise<ReceiptOrEstimate<G>> {
|
): Promise<ReceiptOrEstimate<G>> {
|
||||||
const nftContract = this.getContract(nftAddress)
|
const nftContract = this.getContract(nftAddress)
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(await this.getNftPermissions(nftAddress, address)).manager !== true ||
|
(await this.getNftPermissions(nftAddress, address)).manager !== true ||
|
||||||
(address !== metadataUpdater &&
|
(address !== metadataUpdater &&
|
||||||
@ -325,7 +324,7 @@ export class Nft extends SmartContract {
|
|||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
nftContract.removeFromMetadataList,
|
nftContract.removeFromMetadataList,
|
||||||
metadataUpdater
|
metadataUpdater
|
||||||
@ -358,7 +357,7 @@ export class Nft extends SmartContract {
|
|||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
nftContract.addTo725StoreList,
|
nftContract.addTo725StoreList,
|
||||||
storeUpdater
|
storeUpdater
|
||||||
@ -382,7 +381,6 @@ export class Nft extends SmartContract {
|
|||||||
estimateGas?: G
|
estimateGas?: G
|
||||||
): Promise<ReceiptOrEstimate<G>> {
|
): Promise<ReceiptOrEstimate<G>> {
|
||||||
const nftContract = this.getContract(nftAddress)
|
const nftContract = this.getContract(nftAddress)
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(await this.getNftPermissions(nftAddress, address)).manager !== true ||
|
(await this.getNftPermissions(nftAddress, address)).manager !== true ||
|
||||||
(address !== storeUpdater &&
|
(address !== storeUpdater &&
|
||||||
@ -396,7 +394,7 @@ export class Nft extends SmartContract {
|
|||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
nftContract.removeFrom725StoreList,
|
nftContract.removeFrom725StoreList,
|
||||||
storeUpdater
|
storeUpdater
|
||||||
@ -421,7 +419,6 @@ export class Nft extends SmartContract {
|
|||||||
estimateGas?: G
|
estimateGas?: G
|
||||||
): Promise<ReceiptOrEstimate<G>> {
|
): Promise<ReceiptOrEstimate<G>> {
|
||||||
const nftContract = this.getContract(nftAddress)
|
const nftContract = this.getContract(nftAddress)
|
||||||
|
|
||||||
if ((await this.getNftOwner(nftAddress)) !== address) {
|
if ((await this.getNftOwner(nftAddress)) !== address) {
|
||||||
throw new Error(`Caller is not NFT Owner`)
|
throw new Error(`Caller is not NFT Owner`)
|
||||||
}
|
}
|
||||||
@ -431,7 +428,7 @@ export class Nft extends SmartContract {
|
|||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
nftContract.cleanPermissions
|
nftContract.cleanPermissions
|
||||||
)
|
)
|
||||||
@ -457,7 +454,6 @@ export class Nft extends SmartContract {
|
|||||||
estimateGas?: G
|
estimateGas?: G
|
||||||
): Promise<ReceiptOrEstimate<G>> {
|
): Promise<ReceiptOrEstimate<G>> {
|
||||||
const nftContract = this.getContract(nftAddress)
|
const nftContract = this.getContract(nftAddress)
|
||||||
|
|
||||||
if ((await this.getNftOwner(nftAddress)) !== nftOwner) {
|
if ((await this.getNftOwner(nftAddress)) !== nftOwner) {
|
||||||
throw new Error(`Caller is not NFT Owner`)
|
throw new Error(`Caller is not NFT Owner`)
|
||||||
}
|
}
|
||||||
@ -473,7 +469,7 @@ export class Nft extends SmartContract {
|
|||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
nftContract.transferFrom,
|
nftContract.transferFrom,
|
||||||
nftOwner,
|
nftOwner,
|
||||||
@ -502,7 +498,6 @@ export class Nft extends SmartContract {
|
|||||||
estimateGas?: G
|
estimateGas?: G
|
||||||
): Promise<ReceiptOrEstimate<G>> {
|
): Promise<ReceiptOrEstimate<G>> {
|
||||||
const nftContract = this.getContract(nftAddress)
|
const nftContract = this.getContract(nftAddress)
|
||||||
|
|
||||||
if ((await this.getNftOwner(nftAddress)) !== nftOwner) {
|
if ((await this.getNftOwner(nftAddress)) !== nftOwner) {
|
||||||
throw new Error(`Caller is not NFT Owner`)
|
throw new Error(`Caller is not NFT Owner`)
|
||||||
}
|
}
|
||||||
@ -518,7 +513,7 @@ export class Nft extends SmartContract {
|
|||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
nftContract.safeTransferFrom,
|
nftContract.safeTransferFrom,
|
||||||
nftOwner,
|
nftOwner,
|
||||||
@ -641,7 +636,6 @@ export class Nft extends SmartContract {
|
|||||||
estimateGas?: G
|
estimateGas?: G
|
||||||
): Promise<ReceiptOrEstimate<G>> {
|
): Promise<ReceiptOrEstimate<G>> {
|
||||||
const nftContract = this.getContract(nftAddress)
|
const nftContract = this.getContract(nftAddress)
|
||||||
|
|
||||||
if (!(await this.getNftPermissions(nftAddress, address)).updateMetadata) {
|
if (!(await this.getNftPermissions(nftAddress, address)).updateMetadata) {
|
||||||
throw new Error(`Caller is not Metadata updater`)
|
throw new Error(`Caller is not Metadata updater`)
|
||||||
}
|
}
|
||||||
@ -651,7 +645,7 @@ export class Nft extends SmartContract {
|
|||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
nftContract.setMetaDataState,
|
nftContract.setMetaDataState,
|
||||||
metadataState
|
metadataState
|
||||||
@ -672,13 +666,12 @@ export class Nft extends SmartContract {
|
|||||||
estimateGas?: G
|
estimateGas?: G
|
||||||
): Promise<ReceiptOrEstimate<G>> {
|
): Promise<ReceiptOrEstimate<G>> {
|
||||||
const nftContract = this.getContract(nftAddress)
|
const nftContract = this.getContract(nftAddress)
|
||||||
|
|
||||||
const estGas = await nftContract.estimateGas.setTokenURI('1', data)
|
const estGas = await nftContract.estimateGas.setTokenURI('1', data)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
nftContract.setTokenURI,
|
nftContract.setTokenURI,
|
||||||
'1',
|
'1',
|
||||||
@ -757,7 +750,6 @@ export class Nft extends SmartContract {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const nftContract = this.getContract(nftAddress)
|
const nftContract = this.getContract(nftAddress)
|
||||||
|
|
||||||
const keyHash = ethers.utils.keccak256(key)
|
const keyHash = ethers.utils.keccak256(key)
|
||||||
const valueHex = ethers.utils.hexlify(ethers.utils.toUtf8Bytes(value))
|
const valueHex = ethers.utils.hexlify(ethers.utils.toUtf8Bytes(value))
|
||||||
|
|
||||||
@ -765,7 +757,7 @@ export class Nft extends SmartContract {
|
|||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
nftContract.setNewData,
|
nftContract.setNewData,
|
||||||
keyHash,
|
keyHash,
|
||||||
|
@ -55,6 +55,7 @@ export class NftFactory extends SmartContractWithAddress {
|
|||||||
if ((await this.getNFTTemplate(nftData.templateIndex)).isActive === false) {
|
if ((await this.getNFTTemplate(nftData.templateIndex)).isActive === false) {
|
||||||
throw new Error(`Template is not active`)
|
throw new Error(`Template is not active`)
|
||||||
}
|
}
|
||||||
|
|
||||||
const estGas = await this.contract.estimateGas.deployERC721Contract(
|
const estGas = await this.contract.estimateGas.deployERC721Contract(
|
||||||
nftData.name,
|
nftData.name,
|
||||||
nftData.symbol,
|
nftData.symbol,
|
||||||
@ -70,7 +71,7 @@ export class NftFactory extends SmartContractWithAddress {
|
|||||||
try {
|
try {
|
||||||
const tx = await sendTx(
|
const tx = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.deployERC721Contract,
|
this.contract.deployERC721Contract,
|
||||||
nftData.name,
|
nftData.name,
|
||||||
@ -212,7 +213,7 @@ export class NftFactory extends SmartContractWithAddress {
|
|||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.add721TokenTemplate,
|
this.contract.add721TokenTemplate,
|
||||||
templateAddress
|
templateAddress
|
||||||
@ -242,12 +243,13 @@ export class NftFactory extends SmartContractWithAddress {
|
|||||||
if (templateIndex === 0) {
|
if (templateIndex === 0) {
|
||||||
throw new Error(`Template index cannot be ZERO`)
|
throw new Error(`Template index cannot be ZERO`)
|
||||||
}
|
}
|
||||||
|
|
||||||
const estGas = await this.contract.estimateGas.disable721TokenTemplate(templateIndex)
|
const estGas = await this.contract.estimateGas.disable721TokenTemplate(templateIndex)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.disable721TokenTemplate,
|
this.contract.disable721TokenTemplate,
|
||||||
templateIndex
|
templateIndex
|
||||||
@ -286,7 +288,7 @@ export class NftFactory extends SmartContractWithAddress {
|
|||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.reactivate721TokenTemplate,
|
this.contract.reactivate721TokenTemplate,
|
||||||
templateIndex
|
templateIndex
|
||||||
@ -319,7 +321,7 @@ export class NftFactory extends SmartContractWithAddress {
|
|||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.addTokenTemplate,
|
this.contract.addTokenTemplate,
|
||||||
templateAddress
|
templateAddress
|
||||||
@ -353,12 +355,13 @@ export class NftFactory extends SmartContractWithAddress {
|
|||||||
if ((await this.getTokenTemplate(templateIndex)).isActive === false) {
|
if ((await this.getTokenTemplate(templateIndex)).isActive === false) {
|
||||||
throw new Error(`Template is already disabled`)
|
throw new Error(`Template is already disabled`)
|
||||||
}
|
}
|
||||||
|
|
||||||
const estGas = await this.contract.estimateGas.disableTokenTemplate(templateIndex)
|
const estGas = await this.contract.estimateGas.disableTokenTemplate(templateIndex)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.disableTokenTemplate,
|
this.contract.disableTokenTemplate,
|
||||||
templateIndex
|
templateIndex
|
||||||
@ -398,7 +401,7 @@ export class NftFactory extends SmartContractWithAddress {
|
|||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.reactivateTokenTemplate,
|
this.contract.reactivateTokenTemplate,
|
||||||
templateIndex
|
templateIndex
|
||||||
@ -431,7 +434,7 @@ export class NftFactory extends SmartContractWithAddress {
|
|||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.startMultipleTokenOrder,
|
this.contract.startMultipleTokenOrder,
|
||||||
orders
|
orders
|
||||||
@ -454,6 +457,7 @@ export class NftFactory extends SmartContractWithAddress {
|
|||||||
estimateGas?: G
|
estimateGas?: G
|
||||||
): Promise<ReceiptOrEstimate<G>> {
|
): Promise<ReceiptOrEstimate<G>> {
|
||||||
const ercCreateData = await this.getErcCreationParams(dtParams)
|
const ercCreateData = await this.getErcCreationParams(dtParams)
|
||||||
|
|
||||||
const estGas = await this.contract.estimateGas.createNftWithErc20(
|
const estGas = await this.contract.estimateGas.createNftWithErc20(
|
||||||
nftCreateData,
|
nftCreateData,
|
||||||
ercCreateData
|
ercCreateData
|
||||||
@ -462,7 +466,7 @@ export class NftFactory extends SmartContractWithAddress {
|
|||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.createNftWithErc20,
|
this.contract.createNftWithErc20,
|
||||||
nftCreateData,
|
nftCreateData,
|
||||||
@ -499,7 +503,7 @@ export class NftFactory extends SmartContractWithAddress {
|
|||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.createNftWithErc20WithFixedRate,
|
this.contract.createNftWithErc20WithFixedRate,
|
||||||
nftCreateData,
|
nftCreateData,
|
||||||
@ -548,7 +552,7 @@ export class NftFactory extends SmartContractWithAddress {
|
|||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.createNftWithErc20WithDispenser,
|
this.contract.createNftWithErc20WithDispenser,
|
||||||
nftCreateData,
|
nftCreateData,
|
||||||
|
@ -28,7 +28,7 @@ export class Router extends SmartContractWithAddress {
|
|||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.buyDTBatch,
|
this.contract.buyDTBatch,
|
||||||
operations
|
operations
|
||||||
@ -93,7 +93,7 @@ export class Router extends SmartContractWithAddress {
|
|||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.addApprovedToken,
|
this.contract.addApprovedToken,
|
||||||
tokenAddress
|
tokenAddress
|
||||||
@ -123,7 +123,7 @@ export class Router extends SmartContractWithAddress {
|
|||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.removeApprovedToken,
|
this.contract.removeApprovedToken,
|
||||||
tokenAddress
|
tokenAddress
|
||||||
@ -152,7 +152,7 @@ export class Router extends SmartContractWithAddress {
|
|||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.addFixedRateContract,
|
this.contract.addFixedRateContract,
|
||||||
tokenAddress
|
tokenAddress
|
||||||
@ -182,7 +182,7 @@ export class Router extends SmartContractWithAddress {
|
|||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.removeFixedRateContract,
|
this.contract.removeFixedRateContract,
|
||||||
tokenAddress
|
tokenAddress
|
||||||
@ -212,7 +212,7 @@ export class Router extends SmartContractWithAddress {
|
|||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.addDispenserContract,
|
this.contract.addDispenserContract,
|
||||||
tokenAddress
|
tokenAddress
|
||||||
@ -241,7 +241,7 @@ export class Router extends SmartContractWithAddress {
|
|||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.removeDispenserContract,
|
this.contract.removeDispenserContract,
|
||||||
tokenAddress
|
tokenAddress
|
||||||
@ -295,7 +295,7 @@ export class Router extends SmartContractWithAddress {
|
|||||||
|
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.updateOPCFee,
|
this.contract.updateOPCFee,
|
||||||
newSwapOceanFee,
|
newSwapOceanFee,
|
||||||
|
@ -7,6 +7,7 @@ import {
|
|||||||
setContractDefaults,
|
setContractDefaults,
|
||||||
unitsToAmount
|
unitsToAmount
|
||||||
} from '../utils'
|
} from '../utils'
|
||||||
|
import * as sapphire from '@oasisprotocol/sapphire-paratime'
|
||||||
|
|
||||||
export abstract class SmartContract {
|
export abstract class SmartContract {
|
||||||
public signer: Signer
|
public signer: Signer
|
||||||
@ -29,10 +30,16 @@ export abstract class SmartContract {
|
|||||||
abi?: AbiItem[]
|
abi?: AbiItem[]
|
||||||
) {
|
) {
|
||||||
this.signer = signer
|
this.signer = signer
|
||||||
this.config = config || new ConfigHelper().getConfig(network || 'unknown')
|
this.config = config || new ConfigHelper().getConfig(network)
|
||||||
this.abi = abi || this.getDefaultAbi()
|
this.abi = abi || this.getDefaultAbi()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected getSignerAccordingSdk() {
|
||||||
|
return this.config && 'sdk' in this.config && this.config.sdk === 'oasis'
|
||||||
|
? sapphire.wrap(this.signer)
|
||||||
|
: this.signer
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts an amount of tokens to units
|
* Converts an amount of tokens to units
|
||||||
* @param {string} token - The token to convert
|
* @param {string} token - The token to convert
|
||||||
|
@ -40,11 +40,10 @@ export class DfRewards extends SmartContractWithAddress {
|
|||||||
): Promise<ReceiptOrEstimate<G>> {
|
): Promise<ReceiptOrEstimate<G>> {
|
||||||
const estGas = await this.contract.estimateGas.claimFor(userAddress, tokenAddress)
|
const estGas = await this.contract.estimateGas.claimFor(userAddress, tokenAddress)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
// Invoke function of the contract
|
// Invoke function of the contract
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.claimFor,
|
this.contract.claimFor,
|
||||||
userAddress,
|
userAddress,
|
||||||
@ -76,11 +75,10 @@ export class DfRewards extends SmartContractWithAddress {
|
|||||||
tokenAddress
|
tokenAddress
|
||||||
)
|
)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
// Invoke function of the contract
|
// Invoke function of the contract
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.allocate,
|
this.contract.allocate,
|
||||||
userAddresses,
|
userAddresses,
|
||||||
|
@ -43,11 +43,10 @@ export class DfStrategyV1 extends SmartContractWithAddress {
|
|||||||
tokenAddresses
|
tokenAddresses
|
||||||
)
|
)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
// Invoke function of the contract
|
// Invoke function of the contract
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas,
|
estGas,
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.claimMultiple,
|
this.contract.claimMultiple,
|
||||||
userAddress,
|
userAddress,
|
||||||
|
@ -4,7 +4,10 @@ export * from './Dispenser'
|
|||||||
export * from './FixedRateExchange'
|
export * from './FixedRateExchange'
|
||||||
export * from './Router'
|
export * from './Router'
|
||||||
export * from './Datatoken'
|
export * from './Datatoken'
|
||||||
|
export * from './Datatoken4'
|
||||||
export * from './NFT'
|
export * from './NFT'
|
||||||
|
export * from './AccessList'
|
||||||
|
export * from './AccessListFactory'
|
||||||
export * from './NFTFactory'
|
export * from './NFTFactory'
|
||||||
export * from './ve/VeOcean'
|
export * from './ve/VeOcean'
|
||||||
export * from './ve/VeFeeDistributor'
|
export * from './ve/VeFeeDistributor'
|
||||||
|
@ -30,7 +30,7 @@ export class VeAllocate extends SmartContractWithAddress {
|
|||||||
// Invoke function of the contract
|
// Invoke function of the contract
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas.add(20000),
|
estGas.add(20000),
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.setAllocation,
|
this.contract.setAllocation,
|
||||||
amount,
|
amount,
|
||||||
@ -60,11 +60,10 @@ export class VeAllocate extends SmartContractWithAddress {
|
|||||||
chainId
|
chainId
|
||||||
)
|
)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
// Invoke function of the contract
|
// Invoke function of the contract
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas.add(20000),
|
estGas.add(20000),
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.setBatchAllocation,
|
this.contract.setBatchAllocation,
|
||||||
amount,
|
amount,
|
||||||
|
@ -29,7 +29,7 @@ export class VeFeeDistributor extends SmartContractWithAddress {
|
|||||||
// Invoke function of the contract
|
// Invoke function of the contract
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas.add(20000),
|
estGas.add(20000),
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.claim
|
this.contract.claim
|
||||||
)
|
)
|
||||||
@ -51,11 +51,10 @@ export class VeFeeDistributor extends SmartContractWithAddress {
|
|||||||
): Promise<ReceiptOrEstimate<G>> {
|
): Promise<ReceiptOrEstimate<G>> {
|
||||||
const estGas = await this.contract.estimateGas.claim_many(addresses)
|
const estGas = await this.contract.estimateGas.claim_many(addresses)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
// Invoke function of the contract
|
// Invoke function of the contract
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas.add(20000),
|
estGas.add(20000),
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.claim_many,
|
this.contract.claim_many,
|
||||||
addresses
|
addresses
|
||||||
|
@ -28,11 +28,10 @@ export class VeOcean extends SmartContractWithAddress {
|
|||||||
unlockTime
|
unlockTime
|
||||||
)
|
)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
// Invoke function of the contract
|
// Invoke function of the contract
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas.add(20000),
|
estGas.add(20000),
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.create_lock,
|
this.contract.create_lock,
|
||||||
amountFormatted,
|
amountFormatted,
|
||||||
@ -57,11 +56,10 @@ export class VeOcean extends SmartContractWithAddress {
|
|||||||
const amountFormatted = await this.amountToUnits(await this.getToken(), amount)
|
const amountFormatted = await this.amountToUnits(await this.getToken(), amount)
|
||||||
const estGas = await this.contract.estimateGas.deposit_for(toAddress, amountFormatted)
|
const estGas = await this.contract.estimateGas.deposit_for(toAddress, amountFormatted)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
// Invoke function of the contract
|
// Invoke function of the contract
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas.add(20000),
|
estGas.add(20000),
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.deposit_for,
|
this.contract.deposit_for,
|
||||||
toAddress,
|
toAddress,
|
||||||
@ -83,11 +81,10 @@ export class VeOcean extends SmartContractWithAddress {
|
|||||||
const amountFormatted = await this.amountToUnits(await this.getToken(), amount)
|
const amountFormatted = await this.amountToUnits(await this.getToken(), amount)
|
||||||
const estGas = await this.contract.estimateGas.increase_amount(amountFormatted)
|
const estGas = await this.contract.estimateGas.increase_amount(amountFormatted)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
// Invoke function of the contract
|
// Invoke function of the contract
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas.add(20000),
|
estGas.add(20000),
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.increase_amount,
|
this.contract.increase_amount,
|
||||||
amountFormatted
|
amountFormatted
|
||||||
@ -107,11 +104,10 @@ export class VeOcean extends SmartContractWithAddress {
|
|||||||
): Promise<ReceiptOrEstimate<G>> {
|
): Promise<ReceiptOrEstimate<G>> {
|
||||||
const estGas = await this.contract.estimateGas.increase_unlock_time(unlockTime)
|
const estGas = await this.contract.estimateGas.increase_unlock_time(unlockTime)
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
// Invoke function of the contract
|
// Invoke function of the contract
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas.add(20000),
|
estGas.add(20000),
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.increase_unlock_time,
|
this.contract.increase_unlock_time,
|
||||||
unlockTime
|
unlockTime
|
||||||
@ -129,11 +125,10 @@ export class VeOcean extends SmartContractWithAddress {
|
|||||||
): Promise<ReceiptOrEstimate<G>> {
|
): Promise<ReceiptOrEstimate<G>> {
|
||||||
const estGas = await this.contract.estimateGas.withdraw()
|
const estGas = await this.contract.estimateGas.withdraw()
|
||||||
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
if (estimateGas) return <ReceiptOrEstimate<G>>estGas
|
||||||
|
|
||||||
// Invoke function of the contract
|
// Invoke function of the contract
|
||||||
const trxReceipt = await sendTx(
|
const trxReceipt = await sendTx(
|
||||||
estGas.add(20000),
|
estGas.add(20000),
|
||||||
this.signer,
|
this.getSignerAccordingSdk(),
|
||||||
this.config?.gasFeeMultiplier,
|
this.config?.gasFeeMultiplier,
|
||||||
this.contract.withdraw
|
this.contract.withdraw
|
||||||
)
|
)
|
||||||
|
@ -26,9 +26,9 @@ import ERC20Template4 from '@oceanprotocol/contracts/artifacts/contracts/templat
|
|||||||
|
|
||||||
export const DEVELOPMENT_CHAIN_ID = 8996
|
export const DEVELOPMENT_CHAIN_ID = 8996
|
||||||
// template address OR templateId
|
// template address OR templateId
|
||||||
export function isConfidentialEVM(network: string | number): boolean {
|
export function useOasisSDK(network: string | number): boolean {
|
||||||
const config = new ConfigHelper().getConfig(network)
|
const config = new ConfigHelper().getConfig(network)
|
||||||
return config && config.confidentialEVM
|
return config && config.sdk === 'oasis'
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -196,7 +196,7 @@ export async function createAsset(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// include fileObject in the DT constructor
|
// include fileObject in the DT constructor
|
||||||
if (config.confidentialEVM) {
|
if (config.sdk === 'oasis') {
|
||||||
datatokenParams.filesObject = assetUrl
|
datatokenParams.filesObject = assetUrl
|
||||||
datatokenParams.accessListFactory = accessListFactory || config.accessListFactory
|
datatokenParams.accessListFactory = accessListFactory || config.accessListFactory
|
||||||
datatokenParams.allowAccessList = allowAccessList
|
datatokenParams.allowAccessList = allowAccessList
|
||||||
@ -256,7 +256,7 @@ export async function createAsset(
|
|||||||
assetUrl.datatokenAddress = datatokenAddressAsset
|
assetUrl.datatokenAddress = datatokenAddressAsset
|
||||||
assetUrl.nftAddress = nftAddress
|
assetUrl.nftAddress = nftAddress
|
||||||
|
|
||||||
if (config.confidentialEVM) {
|
if (config.sdk === 'oasis') {
|
||||||
// we need to update files object on the SC otherwise it will fail validation on provider
|
// we need to update files object on the SC otherwise it will fail validation on provider
|
||||||
// because DDO datatokenAddress and nftAddress will not match the values on files object
|
// because DDO datatokenAddress and nftAddress will not match the values on files object
|
||||||
const contract = new ethers.Contract(datatokenAddressAsset, ERC20Template4.abi, owner)
|
const contract = new ethers.Contract(datatokenAddressAsset, ERC20Template4.abi, owner)
|
||||||
@ -274,7 +274,7 @@ export async function createAsset(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if confidential EVM no need to make encrypt call here
|
// if confidential EVM no need to make encrypt call here
|
||||||
if (config.confidentialEVM) {
|
if (config.sdk === 'oasis') {
|
||||||
ddo.services[0].files = '' // on confidental EVM it needs to be empty string not null, for schema validation
|
ddo.services[0].files = '' // on confidental EVM it needs to be empty string not null, for schema validation
|
||||||
} else {
|
} else {
|
||||||
ddo.services[0].files = await ProviderInstance.encrypt(assetUrl, chainID, providerUrl)
|
ddo.services[0].files = await ProviderInstance.encrypt(assetUrl, chainID, providerUrl)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { ethers, Signer, providers, Contract, ContractFunction, BigNumber } from 'ethers'
|
import { ethers, Signer, providers, Contract, ContractFunction, BigNumber } from 'ethers'
|
||||||
|
|
||||||
import { Config } from '../config'
|
import { Config, KNOWN_CONFIDENTIAL_EVMS } from '../config'
|
||||||
import { LoggerInstance, minAbi } from '.'
|
import { LoggerInstance, minAbi } from '.'
|
||||||
|
|
||||||
const MIN_GAS_FEE_POLYGON = 30000000000 // minimum recommended 30 gwei polygon main and mumbai fees
|
const MIN_GAS_FEE_POLYGON = 30000000000 // minimum recommended 30 gwei polygon main and mumbai fees
|
||||||
@ -9,8 +9,6 @@ const MIN_GAS_FEE_SAPPHIRE = 10000000000 // recommended for mainnet and testnet
|
|||||||
const POLYGON_NETWORK_ID = 137
|
const POLYGON_NETWORK_ID = 137
|
||||||
const MUMBAI_NETWORK_ID = 80001
|
const MUMBAI_NETWORK_ID = 80001
|
||||||
const SEPOLIA_NETWORK_ID = 11155111
|
const SEPOLIA_NETWORK_ID = 11155111
|
||||||
const SAPPHIRE_TESTNET_NETWORK_ID = 23295
|
|
||||||
const SAPPHIRE_MAINNET_NETWORK_ID = 23294
|
|
||||||
|
|
||||||
export function setContractDefaults(contract: Contract, config: Config): Contract {
|
export function setContractDefaults(contract: Contract, config: Config): Contract {
|
||||||
// TO DO - since ethers does not provide this
|
// TO DO - since ethers does not provide this
|
||||||
@ -142,8 +140,7 @@ export async function sendTx(
|
|||||||
: chainId === SEPOLIA_NETWORK_ID &&
|
: chainId === SEPOLIA_NETWORK_ID &&
|
||||||
Number(aggressiveFeePriorityFeePerGas) < MIN_GAS_FEE_SEPOLIA
|
Number(aggressiveFeePriorityFeePerGas) < MIN_GAS_FEE_SEPOLIA
|
||||||
? MIN_GAS_FEE_SEPOLIA
|
? MIN_GAS_FEE_SEPOLIA
|
||||||
: (chainId === SAPPHIRE_MAINNET_NETWORK_ID ||
|
: KNOWN_CONFIDENTIAL_EVMS.includes(chainId) &&
|
||||||
chainId === SAPPHIRE_TESTNET_NETWORK_ID) &&
|
|
||||||
Number(aggressiveFeePriorityFeePerGas) < MIN_GAS_FEE_SAPPHIRE
|
Number(aggressiveFeePriorityFeePerGas) < MIN_GAS_FEE_SAPPHIRE
|
||||||
? MIN_GAS_FEE_SAPPHIRE
|
? MIN_GAS_FEE_SAPPHIRE
|
||||||
: Number(aggressiveFeePriorityFeePerGas),
|
: Number(aggressiveFeePriorityFeePerGas),
|
||||||
@ -155,8 +152,7 @@ export async function sendTx(
|
|||||||
: chainId === SEPOLIA_NETWORK_ID &&
|
: chainId === SEPOLIA_NETWORK_ID &&
|
||||||
Number(aggressiveFeePerGas) < MIN_GAS_FEE_SEPOLIA
|
Number(aggressiveFeePerGas) < MIN_GAS_FEE_SEPOLIA
|
||||||
? MIN_GAS_FEE_SEPOLIA
|
? MIN_GAS_FEE_SEPOLIA
|
||||||
: (chainId === SAPPHIRE_MAINNET_NETWORK_ID ||
|
: KNOWN_CONFIDENTIAL_EVMS.includes(chainId) &&
|
||||||
chainId === SAPPHIRE_TESTNET_NETWORK_ID) &&
|
|
||||||
Number(aggressiveFeePerGas) < MIN_GAS_FEE_SAPPHIRE
|
Number(aggressiveFeePerGas) < MIN_GAS_FEE_SAPPHIRE
|
||||||
? MIN_GAS_FEE_SAPPHIRE
|
? MIN_GAS_FEE_SAPPHIRE
|
||||||
: Number(aggressiveFeePerGas)
|
: Number(aggressiveFeePerGas)
|
||||||
|
@ -289,7 +289,11 @@ describe('Marketplace flow tests', async () => {
|
|||||||
|
|
||||||
it('6.1 Publish a dataset (create NFT + Datatoken) with a fixed rate exchange', async () => {
|
it('6.1 Publish a dataset (create NFT + Datatoken) with a fixed rate exchange', async () => {
|
||||||
/// ```Typescript
|
/// ```Typescript
|
||||||
const factory = new NftFactory(addresses.ERC721Factory, publisherAccount)
|
const factory = new NftFactory(
|
||||||
|
addresses.ERC721Factory,
|
||||||
|
publisherAccount,
|
||||||
|
await publisherAccount.getChainId()
|
||||||
|
)
|
||||||
|
|
||||||
const nftParams: NftCreateData = {
|
const nftParams: NftCreateData = {
|
||||||
name: FRE_NFT_NAME,
|
name: FRE_NFT_NAME,
|
||||||
@ -409,7 +413,11 @@ describe('Marketplace flow tests', async () => {
|
|||||||
|
|
||||||
it('6.3 Marketplace displays fixed rate asset for sale', async () => {
|
it('6.3 Marketplace displays fixed rate asset for sale', async () => {
|
||||||
/// ```Typescript
|
/// ```Typescript
|
||||||
const fixedRate = new FixedRateExchange(freAddress, publisherAccount)
|
const fixedRate = new FixedRateExchange(
|
||||||
|
freAddress,
|
||||||
|
publisherAccount,
|
||||||
|
await publisherAccount.getChainId()
|
||||||
|
)
|
||||||
const oceanAmount = await (
|
const oceanAmount = await (
|
||||||
await fixedRate.calcBaseInGivenDatatokensOut(freId, '1')
|
await fixedRate.calcBaseInGivenDatatokensOut(freId, '1')
|
||||||
).baseTokenAmount
|
).baseTokenAmount
|
||||||
@ -424,7 +432,7 @@ describe('Marketplace flow tests', async () => {
|
|||||||
|
|
||||||
it('7.1 Consumer buys a fixed rate asset data asset, and downloads it', async () => {
|
it('7.1 Consumer buys a fixed rate asset data asset, and downloads it', async () => {
|
||||||
/// ```Typescript
|
/// ```Typescript
|
||||||
datatoken = new Datatoken(publisherAccount)
|
datatoken = new Datatoken(publisherAccount, await publisherAccount.getChainId())
|
||||||
const DATATOKEN_AMOUNT = '10000'
|
const DATATOKEN_AMOUNT = '10000'
|
||||||
|
|
||||||
await datatoken.mint(
|
await datatoken.mint(
|
||||||
@ -473,7 +481,11 @@ describe('Marketplace flow tests', async () => {
|
|||||||
DATATOKEN_AMOUNT
|
DATATOKEN_AMOUNT
|
||||||
)
|
)
|
||||||
|
|
||||||
const fixedRate = new FixedRateExchange(freAddress, consumerAccount)
|
const fixedRate = new FixedRateExchange(
|
||||||
|
freAddress,
|
||||||
|
consumerAccount,
|
||||||
|
await consumerAccount.getChainId()
|
||||||
|
)
|
||||||
/// ```
|
/// ```
|
||||||
/// Now we can make the contract call
|
/// Now we can make the contract call
|
||||||
/// ```Typescript
|
/// ```Typescript
|
||||||
@ -517,7 +529,7 @@ describe('Marketplace flow tests', async () => {
|
|||||||
validUntil: initializeData.providerFee.validUntil
|
validUntil: initializeData.providerFee.validUntil
|
||||||
}
|
}
|
||||||
|
|
||||||
datatoken = new Datatoken(consumerAccount)
|
datatoken = new Datatoken(consumerAccount, await consumerAccount.getChainId())
|
||||||
|
|
||||||
/// ```
|
/// ```
|
||||||
/// Lets now make the payment
|
/// Lets now make the payment
|
||||||
@ -574,7 +586,11 @@ describe('Marketplace flow tests', async () => {
|
|||||||
|
|
||||||
it('8.1 Publish a dataset (create NFT + Datatoken) with a dispenser', async () => {
|
it('8.1 Publish a dataset (create NFT + Datatoken) with a dispenser', async () => {
|
||||||
/// ```Typescript
|
/// ```Typescript
|
||||||
const factory = new NftFactory(addresses.ERC721Factory, publisherAccount)
|
const factory = new NftFactory(
|
||||||
|
addresses.ERC721Factory,
|
||||||
|
publisherAccount,
|
||||||
|
await publisherAccount.getChainId()
|
||||||
|
)
|
||||||
|
|
||||||
const nftParams: NftCreateData = {
|
const nftParams: NftCreateData = {
|
||||||
name: DISP_NFT_NAME,
|
name: DISP_NFT_NAME,
|
||||||
@ -679,8 +695,12 @@ describe('Marketplace flow tests', async () => {
|
|||||||
|
|
||||||
it('9.1 Consumer gets a dispenser data asset, and downloads it', async () => {
|
it('9.1 Consumer gets a dispenser data asset, and downloads it', async () => {
|
||||||
/// ```Typescript
|
/// ```Typescript
|
||||||
datatoken = new Datatoken(publisherAccount)
|
datatoken = new Datatoken(publisherAccount, await publisherAccount.getChainId())
|
||||||
const dispenser = new Dispenser(addresses.Dispenser, consumerAccount)
|
const dispenser = new Dispenser(
|
||||||
|
addresses.Dispenser,
|
||||||
|
consumerAccount,
|
||||||
|
await consumerAccount.getChainId()
|
||||||
|
)
|
||||||
|
|
||||||
let consumerDTBalance = await balance(
|
let consumerDTBalance = await balance(
|
||||||
consumerAccount,
|
consumerAccount,
|
||||||
@ -709,7 +729,7 @@ describe('Marketplace flow tests', async () => {
|
|||||||
const resolvedDDO = await aquarius.waitForAqua(fixedDDO.id)
|
const resolvedDDO = await aquarius.waitForAqua(fixedDDO.id)
|
||||||
assert(resolvedDDO, 'Cannot fetch DDO from Aquarius')
|
assert(resolvedDDO, 'Cannot fetch DDO from Aquarius')
|
||||||
|
|
||||||
datatoken = new Datatoken(consumerAccount)
|
datatoken = new Datatoken(consumerAccount, await consumerAccount.getChainId())
|
||||||
|
|
||||||
/// ```
|
/// ```
|
||||||
/// At this point we need to encrypt file(s) using provider
|
/// At this point we need to encrypt file(s) using provider
|
||||||
@ -791,7 +811,7 @@ describe('Marketplace flow tests', async () => {
|
|||||||
it('10.1 Add key-value pair to data NFT', async () => {
|
it('10.1 Add key-value pair to data NFT', async () => {
|
||||||
/// Let's start by using the `setData` method to update the nft key value store with some data
|
/// Let's start by using the `setData` method to update the nft key value store with some data
|
||||||
/// ```Typescript
|
/// ```Typescript
|
||||||
const nft = new Nft(publisherAccount)
|
const nft = new Nft(publisherAccount, await publisherAccount.getChainId())
|
||||||
const data = 'SomeData'
|
const data = 'SomeData'
|
||||||
try {
|
try {
|
||||||
await nft.setData(
|
await nft.setData(
|
||||||
|
@ -293,7 +293,11 @@ async function createAsset(
|
|||||||
) {
|
) {
|
||||||
const nft = new Nft(owner, (await owner.provider.getNetwork()).chainId)
|
const nft = new Nft(owner, (await owner.provider.getNetwork()).chainId)
|
||||||
|
|
||||||
const nftFactory = new NftFactory(addresses.ERC721Factory, owner)
|
const nftFactory = new NftFactory(
|
||||||
|
addresses.ERC721Factory,
|
||||||
|
owner,
|
||||||
|
await owner.getChainId()
|
||||||
|
)
|
||||||
|
|
||||||
const chain = (await owner.provider.getNetwork()).chainId
|
const chain = (await owner.provider.getNetwork()).chainId
|
||||||
|
|
||||||
|
@ -94,8 +94,12 @@ describe('Publish tests', async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('initialize test classes', async () => {
|
it('initialize test classes', async () => {
|
||||||
nft = new Nft(publisherAccount)
|
nft = new Nft(publisherAccount, await publisherAccount.getChainId())
|
||||||
factory = new NftFactory(addresses.ERC721Factory, publisherAccount)
|
factory = new NftFactory(
|
||||||
|
addresses.ERC721Factory,
|
||||||
|
publisherAccount,
|
||||||
|
await publisherAccount.getChainId()
|
||||||
|
)
|
||||||
|
|
||||||
await approve(
|
await approve(
|
||||||
publisherAccount,
|
publisherAccount,
|
||||||
|
@ -56,6 +56,7 @@ describe('Sapphire tests', async () => {
|
|||||||
]
|
]
|
||||||
|
|
||||||
const config: Config = {
|
const config: Config = {
|
||||||
|
sdk: 'oasis',
|
||||||
chainId: 23295,
|
chainId: 23295,
|
||||||
network: 'oasis_sapphire_testnet',
|
network: 'oasis_sapphire_testnet',
|
||||||
nodeUri: 'https://testnet.sapphire.oasis.dev',
|
nodeUri: 'https://testnet.sapphire.oasis.dev',
|
||||||
|
@ -55,7 +55,8 @@ export async function createAsset(
|
|||||||
|
|
||||||
const bundleNFT = await nftFactory.createNftWithDatatoken(
|
const bundleNFT = await nftFactory.createNftWithDatatoken(
|
||||||
nftParamsAsset,
|
nftParamsAsset,
|
||||||
datatokenParams
|
datatokenParams,
|
||||||
|
false
|
||||||
)
|
)
|
||||||
|
|
||||||
const trxReceipt = await bundleNFT.wait()
|
const trxReceipt = await bundleNFT.wait()
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { assert } from 'chai'
|
import { assert } from 'chai'
|
||||||
import { KNOWN_CONFIDENTIAL_EVMS } from '../../src/config'
|
import { KNOWN_CONFIDENTIAL_EVMS } from '../../src/config'
|
||||||
import { provider, getAddresses } from '../config'
|
import { provider, getAddresses } from '../config'
|
||||||
import { calculateActiveTemplateIndex, isConfidentialEVM } from '../../src/utils'
|
import { calculateActiveTemplateIndex, useOasisSDK } from '../../src/utils'
|
||||||
import { Signer } from 'ethers/lib/ethers'
|
import { Signer } from 'ethers/lib/ethers'
|
||||||
|
|
||||||
let nftOwner: Signer
|
let nftOwner: Signer
|
||||||
@ -14,16 +14,13 @@ describe('Asset utils (createAsset)', () => {
|
|||||||
|
|
||||||
it('should check if confidential EVM', async () => {
|
it('should check if confidential EVM', async () => {
|
||||||
for (const chain of KNOWN_CONFIDENTIAL_EVMS) {
|
for (const chain of KNOWN_CONFIDENTIAL_EVMS) {
|
||||||
assert(
|
assert(useOasisSDK(chain) === true, `Chain Id: "${chain}" is not a confidental EVM`)
|
||||||
isConfidentialEVM(chain) === true,
|
|
||||||
`Chain Id: "${chain}" is not a confidental EVM`
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// optimism sepolia
|
// optimism sepolia
|
||||||
// 11155420
|
// 11155420
|
||||||
assert(
|
assert(
|
||||||
isConfidentialEVM(11155420) === false,
|
useOasisSDK(11155420) === false,
|
||||||
`Chain Id: "11155420" is wrongly considered a confidental EVM`
|
`Chain Id: "11155420" is wrongly considered a confidental EVM`
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
@ -58,12 +58,20 @@ describe('Dispenser flow', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should initialize Dispenser class', async () => {
|
it('should initialize Dispenser class', async () => {
|
||||||
DispenserClass = new Dispenser(addresses.Dispenser, factoryOwner)
|
DispenserClass = new Dispenser(
|
||||||
|
addresses.Dispenser,
|
||||||
|
factoryOwner,
|
||||||
|
await factoryOwner.getChainId()
|
||||||
|
)
|
||||||
assert(DispenserClass !== null)
|
assert(DispenserClass !== null)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#createNftwithErc - should create an NFT and a Datatoken ', async () => {
|
it('#createNftwithErc - should create an NFT and a Datatoken ', async () => {
|
||||||
nftFactory = new NftFactory(addresses.ERC721Factory, factoryOwner)
|
nftFactory = new NftFactory(
|
||||||
|
addresses.ERC721Factory,
|
||||||
|
factoryOwner,
|
||||||
|
await factoryOwner.getChainId()
|
||||||
|
)
|
||||||
|
|
||||||
const tx = await nftFactory.createNftWithDatatoken(nftData, dtParams)
|
const tx = await nftFactory.createNftWithDatatoken(nftData, dtParams)
|
||||||
const trxReceipt = await tx.wait()
|
const trxReceipt = await tx.wait()
|
||||||
@ -76,7 +84,7 @@ describe('Dispenser flow', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('Make user2 minter', async () => {
|
it('Make user2 minter', async () => {
|
||||||
datatoken = new Datatoken(factoryOwner)
|
datatoken = new Datatoken(factoryOwner, await factoryOwner.getChainId())
|
||||||
await datatoken.addMinter(
|
await datatoken.addMinter(
|
||||||
dtAddress,
|
dtAddress,
|
||||||
await factoryOwner.getAddress(),
|
await factoryOwner.getAddress(),
|
||||||
@ -144,7 +152,11 @@ describe('Dispenser flow', () => {
|
|||||||
'1'
|
'1'
|
||||||
)
|
)
|
||||||
assert(check === true, 'isDispensable should return true')
|
assert(check === true, 'isDispensable should return true')
|
||||||
const DispenserClassForUser2 = new Dispenser(addresses.Dispenser, user2)
|
const DispenserClassForUser2 = new Dispenser(
|
||||||
|
addresses.Dispenser,
|
||||||
|
user2,
|
||||||
|
await user2.getChainId()
|
||||||
|
)
|
||||||
const tx = await DispenserClassForUser2.dispense(
|
const tx = await DispenserClassForUser2.dispense(
|
||||||
dtAddress,
|
dtAddress,
|
||||||
'1',
|
'1',
|
||||||
|
@ -69,7 +69,11 @@ describe('Fixed Rate unit test', () => {
|
|||||||
// CREATE AN Exchange
|
// CREATE AN Exchange
|
||||||
// we prepare transaction parameters objects
|
// we prepare transaction parameters objects
|
||||||
|
|
||||||
const nftFactory = new NftFactory(addresses.ERC721Factory, exchangeOwner)
|
const nftFactory = new NftFactory(
|
||||||
|
addresses.ERC721Factory,
|
||||||
|
exchangeOwner,
|
||||||
|
await exchangeOwner.getChainId()
|
||||||
|
)
|
||||||
|
|
||||||
const freParams: FreCreationParams = {
|
const freParams: FreCreationParams = {
|
||||||
fixedRateAddress: addresses.FixedPrice,
|
fixedRateAddress: addresses.FixedPrice,
|
||||||
@ -99,7 +103,11 @@ describe('Fixed Rate unit test', () => {
|
|||||||
// user1 has no dt1
|
// user1 has no dt1
|
||||||
expect(await balance(user1, dtAddress, await user1.getAddress())).to.equal('0.0')
|
expect(await balance(user1, dtAddress, await user1.getAddress())).to.equal('0.0')
|
||||||
|
|
||||||
fixedRate = new FixedRateExchange(addresses.FixedPrice, exchangeOwner)
|
fixedRate = new FixedRateExchange(
|
||||||
|
addresses.FixedPrice,
|
||||||
|
exchangeOwner,
|
||||||
|
await exchangeOwner.getChainId()
|
||||||
|
)
|
||||||
assert(fixedRate != null)
|
assert(fixedRate != null)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -197,7 +205,7 @@ describe('Fixed Rate unit test', () => {
|
|||||||
|
|
||||||
it('#buyDatatokens - user1 should buy some dt', async () => {
|
it('#buyDatatokens - user1 should buy some dt', async () => {
|
||||||
// total supply is ZERO right now so dt owner mints 1000 DT and approves the fixed rate contract
|
// total supply is ZERO right now so dt owner mints 1000 DT and approves the fixed rate contract
|
||||||
const datatoken = new Datatoken(exchangeOwner)
|
const datatoken = new Datatoken(exchangeOwner, await exchangeOwner.getChainId())
|
||||||
await datatoken.mint(
|
await datatoken.mint(
|
||||||
dtAddress,
|
dtAddress,
|
||||||
await exchangeOwner.getAddress(),
|
await exchangeOwner.getAddress(),
|
||||||
@ -238,7 +246,11 @@ describe('Fixed Rate unit test', () => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
// user1 buys 10 DT
|
// user1 buys 10 DT
|
||||||
fixedRate = new FixedRateExchange(addresses.FixedPrice, user1)
|
fixedRate = new FixedRateExchange(
|
||||||
|
addresses.FixedPrice,
|
||||||
|
user1,
|
||||||
|
await user1.getChainId()
|
||||||
|
)
|
||||||
const amount = '10'
|
const amount = '10'
|
||||||
const maxAmount = '11'
|
const maxAmount = '11'
|
||||||
const tx = await fixedRate.buyDatatokens(exchangeId, amount, maxAmount)
|
const tx = await fixedRate.buyDatatokens(exchangeId, amount, maxAmount)
|
||||||
@ -352,7 +364,11 @@ describe('Fixed Rate unit test', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('#setAllowedSwapper- should set an allowed swapper, if exchangeOwner', async () => {
|
it('#setAllowedSwapper- should set an allowed swapper, if exchangeOwner', async () => {
|
||||||
fixedRate = new FixedRateExchange(addresses.FixedPrice, exchangeOwner)
|
fixedRate = new FixedRateExchange(
|
||||||
|
addresses.FixedPrice,
|
||||||
|
exchangeOwner,
|
||||||
|
await exchangeOwner.getChainId()
|
||||||
|
)
|
||||||
await fixedRate.setAllowedSwapper(exchangeId, await user1.getAddress())
|
await fixedRate.setAllowedSwapper(exchangeId, await user1.getAddress())
|
||||||
expect(await fixedRate.getAllowedSwapper(exchangeId)).to.equal(
|
expect(await fixedRate.getAllowedSwapper(exchangeId)).to.equal(
|
||||||
await user1.getAddress()
|
await user1.getAddress()
|
||||||
@ -365,7 +381,11 @@ describe('Fixed Rate unit test', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('#collectBasetokens- should collect BT in the contract, if exchangeOwner', async () => {
|
it('#collectBasetokens- should collect BT in the contract, if exchangeOwner', async () => {
|
||||||
fixedRate = new FixedRateExchange(addresses.FixedPrice, user1)
|
fixedRate = new FixedRateExchange(
|
||||||
|
addresses.FixedPrice,
|
||||||
|
user1,
|
||||||
|
await user1.getChainId()
|
||||||
|
)
|
||||||
// there are no bt in the contract
|
// there are no bt in the contract
|
||||||
expect((await fixedRate.getExchange(exchangeId)).btBalance).to.equal('0.0')
|
expect((await fixedRate.getExchange(exchangeId)).btBalance).to.equal('0.0')
|
||||||
// user1 buys 1 DT
|
// user1 buys 1 DT
|
||||||
@ -380,7 +400,11 @@ describe('Fixed Rate unit test', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('#collectDatatokens- should collect DT in the contract, if exchangeOwner', async () => {
|
it('#collectDatatokens- should collect DT in the contract, if exchangeOwner', async () => {
|
||||||
fixedRate = new FixedRateExchange(addresses.FixedPrice, exchangeOwner)
|
fixedRate = new FixedRateExchange(
|
||||||
|
addresses.FixedPrice,
|
||||||
|
exchangeOwner,
|
||||||
|
await exchangeOwner.getChainId()
|
||||||
|
)
|
||||||
const result = await fixedRate.getExchange(exchangeId)
|
const result = await fixedRate.getExchange(exchangeId)
|
||||||
// 9 dts left
|
// 9 dts left
|
||||||
expect(result.dtBalance).to.equal('9.0')
|
expect(result.dtBalance).to.equal('9.0')
|
||||||
@ -395,7 +419,11 @@ describe('Fixed Rate unit test', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('#collectMarketFee- should collect marketFee and send it to marketFeeCollector, anyone can call it', async () => {
|
it('#collectMarketFee- should collect marketFee and send it to marketFeeCollector, anyone can call it', async () => {
|
||||||
fixedRate = new FixedRateExchange(addresses.FixedPrice, user2)
|
fixedRate = new FixedRateExchange(
|
||||||
|
addresses.FixedPrice,
|
||||||
|
user2,
|
||||||
|
await user2.getChainId()
|
||||||
|
)
|
||||||
let result = await fixedRate.getFeesInfo(exchangeId)
|
let result = await fixedRate.getFeesInfo(exchangeId)
|
||||||
// we made 2 swaps for 10 DT at rate 1, the fee is 0.1% for market and always in baseToken so it's 0.01 DAI
|
// we made 2 swaps for 10 DT at rate 1, the fee is 0.1% for market and always in baseToken so it's 0.01 DAI
|
||||||
// plus another swap for 1 DT
|
// plus another swap for 1 DT
|
||||||
@ -435,7 +463,11 @@ describe('Fixed Rate unit test', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('#updateMarketFee- should update Market fee if market fee collector', async () => {
|
it('#updateMarketFee- should update Market fee if market fee collector', async () => {
|
||||||
fixedRate = new FixedRateExchange(addresses.FixedPrice, user2)
|
fixedRate = new FixedRateExchange(
|
||||||
|
addresses.FixedPrice,
|
||||||
|
user2,
|
||||||
|
await user2.getChainId()
|
||||||
|
)
|
||||||
expect((await fixedRate.getFeesInfo(exchangeId)).marketFee).to.equal('0.001')
|
expect((await fixedRate.getFeesInfo(exchangeId)).marketFee).to.equal('0.001')
|
||||||
// user2 is marketFeeCollector
|
// user2 is marketFeeCollector
|
||||||
await fixedRate.updateMarketFee(exchangeId, '0.01')
|
await fixedRate.updateMarketFee(exchangeId, '0.01')
|
||||||
@ -444,7 +476,11 @@ describe('Fixed Rate unit test', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('#updateMarketFeeCollector - should update Market fee collector if market fee collector', async () => {
|
it('#updateMarketFeeCollector - should update Market fee collector if market fee collector', async () => {
|
||||||
fixedRate = new FixedRateExchange(addresses.FixedPrice, user2)
|
fixedRate = new FixedRateExchange(
|
||||||
|
addresses.FixedPrice,
|
||||||
|
user2,
|
||||||
|
await user2.getChainId()
|
||||||
|
)
|
||||||
expect((await fixedRate.getFeesInfo(exchangeId)).marketFeeCollector).to.equal(
|
expect((await fixedRate.getFeesInfo(exchangeId)).marketFeeCollector).to.equal(
|
||||||
await user2.getAddress()
|
await user2.getAddress()
|
||||||
)
|
)
|
||||||
@ -463,7 +499,11 @@ describe('Fixed Rate unit test', () => {
|
|||||||
// since FRE is created without mint rights, owner has to send dt to that exchange
|
// since FRE is created without mint rights, owner has to send dt to that exchange
|
||||||
// we prepare transaction parameters objects
|
// we prepare transaction parameters objects
|
||||||
|
|
||||||
const nftFactory = new NftFactory(addresses.ERC721Factory, exchangeOwner)
|
const nftFactory = new NftFactory(
|
||||||
|
addresses.ERC721Factory,
|
||||||
|
exchangeOwner,
|
||||||
|
await exchangeOwner.getChainId()
|
||||||
|
)
|
||||||
|
|
||||||
const freParams: FreCreationParams = {
|
const freParams: FreCreationParams = {
|
||||||
fixedRateAddress: addresses.FixedPrice,
|
fixedRateAddress: addresses.FixedPrice,
|
||||||
@ -493,7 +533,11 @@ describe('Fixed Rate unit test', () => {
|
|||||||
// user1 has no dt1
|
// user1 has no dt1
|
||||||
expect(await balance(user1, dtAddress, await user1.getAddress())).to.equal('0.0')
|
expect(await balance(user1, dtAddress, await user1.getAddress())).to.equal('0.0')
|
||||||
|
|
||||||
fixedRate = new FixedRateExchange(addresses.FixedPrice, exchangeOwner)
|
fixedRate = new FixedRateExchange(
|
||||||
|
addresses.FixedPrice,
|
||||||
|
exchangeOwner,
|
||||||
|
await exchangeOwner.getChainId()
|
||||||
|
)
|
||||||
assert(fixedRate != null)
|
assert(fixedRate != null)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -587,7 +631,7 @@ describe('Fixed Rate unit test', () => {
|
|||||||
|
|
||||||
it('#buyDatatokens - user1 should buy some dt', async () => {
|
it('#buyDatatokens - user1 should buy some dt', async () => {
|
||||||
// total supply is ZERO right now so dt owner mints 1000 DT and approves the fixed rate contract
|
// total supply is ZERO right now so dt owner mints 1000 DT and approves the fixed rate contract
|
||||||
const datatoken = new Datatoken(exchangeOwner)
|
const datatoken = new Datatoken(exchangeOwner, await exchangeOwner.getChainId())
|
||||||
await datatoken.mint(
|
await datatoken.mint(
|
||||||
dtAddress,
|
dtAddress,
|
||||||
await exchangeOwner.getAddress(),
|
await exchangeOwner.getAddress(),
|
||||||
@ -620,7 +664,11 @@ describe('Fixed Rate unit test', () => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
// user1 buys 10 DT
|
// user1 buys 10 DT
|
||||||
fixedRate = new FixedRateExchange(addresses.FixedPrice, user1)
|
fixedRate = new FixedRateExchange(
|
||||||
|
addresses.FixedPrice,
|
||||||
|
user1,
|
||||||
|
await user1.getChainId()
|
||||||
|
)
|
||||||
const amount = '10'
|
const amount = '10'
|
||||||
const maxAmount = '11'
|
const maxAmount = '11'
|
||||||
const tx = await fixedRate.buyDatatokens(exchangeId, amount, maxAmount)
|
const tx = await fixedRate.buyDatatokens(exchangeId, amount, maxAmount)
|
||||||
@ -736,7 +784,11 @@ describe('Fixed Rate unit test', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('#setAllowedSwapper- should set an allowed swapper, if exchangeOwner', async () => {
|
it('#setAllowedSwapper- should set an allowed swapper, if exchangeOwner', async () => {
|
||||||
fixedRate = new FixedRateExchange(addresses.FixedPrice, exchangeOwner)
|
fixedRate = new FixedRateExchange(
|
||||||
|
addresses.FixedPrice,
|
||||||
|
exchangeOwner,
|
||||||
|
await exchangeOwner.getChainId()
|
||||||
|
)
|
||||||
|
|
||||||
await fixedRate.setAllowedSwapper(exchangeId, await user1.getAddress())
|
await fixedRate.setAllowedSwapper(exchangeId, await user1.getAddress())
|
||||||
expect(await fixedRate.getAllowedSwapper(exchangeId)).to.equal(
|
expect(await fixedRate.getAllowedSwapper(exchangeId)).to.equal(
|
||||||
@ -750,14 +802,22 @@ describe('Fixed Rate unit test', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('#collectBasetokens- should collect BT in the contract, if exchangeOwner', async () => {
|
it('#collectBasetokens- should collect BT in the contract, if exchangeOwner', async () => {
|
||||||
fixedRate = new FixedRateExchange(addresses.FixedPrice, user1)
|
fixedRate = new FixedRateExchange(
|
||||||
|
addresses.FixedPrice,
|
||||||
|
user1,
|
||||||
|
await user1.getChainId()
|
||||||
|
)
|
||||||
|
|
||||||
// there are no bt in the contract
|
// there are no bt in the contract
|
||||||
expect((await fixedRate.getExchange(exchangeId)).btBalance).to.equal('0.0')
|
expect((await fixedRate.getExchange(exchangeId)).btBalance).to.equal('0.0')
|
||||||
// user1 buys 1 DT
|
// user1 buys 1 DT
|
||||||
await fixedRate.buyDatatokens(exchangeId, '1', '2')
|
await fixedRate.buyDatatokens(exchangeId, '1', '2')
|
||||||
// 1 DAI in the contract
|
// 1 DAI in the contract
|
||||||
fixedRate = new FixedRateExchange(addresses.FixedPrice, exchangeOwner)
|
fixedRate = new FixedRateExchange(
|
||||||
|
addresses.FixedPrice,
|
||||||
|
exchangeOwner,
|
||||||
|
await exchangeOwner.getChainId()
|
||||||
|
)
|
||||||
|
|
||||||
const exchangeDetails = await fixedRate.getExchange(exchangeId)
|
const exchangeDetails = await fixedRate.getExchange(exchangeId)
|
||||||
expect(exchangeDetails.btBalance).to.equal('1.0')
|
expect(exchangeDetails.btBalance).to.equal('1.0')
|
||||||
@ -781,7 +841,11 @@ describe('Fixed Rate unit test', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('#updateMarketFee- should update Market fee if market fee collector', async () => {
|
it('#updateMarketFee- should update Market fee if market fee collector', async () => {
|
||||||
fixedRate = new FixedRateExchange(addresses.FixedPrice, user2)
|
fixedRate = new FixedRateExchange(
|
||||||
|
addresses.FixedPrice,
|
||||||
|
user2,
|
||||||
|
await user2.getChainId()
|
||||||
|
)
|
||||||
|
|
||||||
expect((await fixedRate.getFeesInfo(exchangeId)).marketFee).to.equal('0.001')
|
expect((await fixedRate.getFeesInfo(exchangeId)).marketFee).to.equal('0.001')
|
||||||
// user2 is marketFeeCollector
|
// user2 is marketFeeCollector
|
||||||
@ -808,7 +872,11 @@ describe('Fixed Rate unit test', () => {
|
|||||||
// CREATE AN Exchange
|
// CREATE AN Exchange
|
||||||
// we prepare transaction parameters objects
|
// we prepare transaction parameters objects
|
||||||
|
|
||||||
const nftFactory = new NftFactory(addresses.ERC721Factory, exchangeOwner)
|
const nftFactory = new NftFactory(
|
||||||
|
addresses.ERC721Factory,
|
||||||
|
exchangeOwner,
|
||||||
|
await exchangeOwner.getChainId()
|
||||||
|
)
|
||||||
|
|
||||||
const freParams: FreCreationParams = {
|
const freParams: FreCreationParams = {
|
||||||
fixedRateAddress: addresses.FixedPrice,
|
fixedRateAddress: addresses.FixedPrice,
|
||||||
@ -836,7 +904,7 @@ describe('Fixed Rate unit test', () => {
|
|||||||
|
|
||||||
const datatokenAddress = tokenCreatedEvent.args.newTokenAddress
|
const datatokenAddress = tokenCreatedEvent.args.newTokenAddress
|
||||||
|
|
||||||
const datatoken = new Datatoken(exchangeOwner)
|
const datatoken = new Datatoken(exchangeOwner, await exchangeOwner.getChainId())
|
||||||
|
|
||||||
const publishingMarketFee = await datatoken.getPublishingMarketFee(datatokenAddress)
|
const publishingMarketFee = await datatoken.getPublishingMarketFee(datatokenAddress)
|
||||||
|
|
||||||
@ -850,7 +918,11 @@ describe('Fixed Rate unit test', () => {
|
|||||||
// CREATE AN Exchange
|
// CREATE AN Exchange
|
||||||
// we prepare transaction parameters objects
|
// we prepare transaction parameters objects
|
||||||
|
|
||||||
const nftFactory = new NftFactory(addresses.ERC721Factory, exchangeOwner)
|
const nftFactory = new NftFactory(
|
||||||
|
addresses.ERC721Factory,
|
||||||
|
exchangeOwner,
|
||||||
|
await exchangeOwner.getChainId()
|
||||||
|
)
|
||||||
|
|
||||||
const freParams: FreCreationParams = {
|
const freParams: FreCreationParams = {
|
||||||
fixedRateAddress: addresses.FixedPrice,
|
fixedRateAddress: addresses.FixedPrice,
|
||||||
@ -878,7 +950,7 @@ describe('Fixed Rate unit test', () => {
|
|||||||
|
|
||||||
const datatokenAddress = tokenCreatedEvent.args.newTokenAddress
|
const datatokenAddress = tokenCreatedEvent.args.newTokenAddress
|
||||||
|
|
||||||
const datatoken = new Datatoken(exchangeOwner)
|
const datatoken = new Datatoken(exchangeOwner, await exchangeOwner.getChainId())
|
||||||
|
|
||||||
const publishingMarketFee = await datatoken.getPublishingMarketFee(datatokenAddress)
|
const publishingMarketFee = await datatoken.getPublishingMarketFee(datatokenAddress)
|
||||||
assert(
|
assert(
|
||||||
|
@ -66,7 +66,11 @@ describe('Nft Factory test', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should initiate NFTFactory instance', async () => {
|
it('should initiate NFTFactory instance', async () => {
|
||||||
nftFactory = new NftFactory(addresses.ERC721Factory, nftOwner)
|
nftFactory = new NftFactory(
|
||||||
|
addresses.ERC721Factory,
|
||||||
|
nftOwner,
|
||||||
|
await nftOwner.getChainId()
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#getOwner - should return actual owner', async () => {
|
it('#getOwner - should return actual owner', async () => {
|
||||||
@ -91,14 +95,14 @@ describe('Nft Factory test', () => {
|
|||||||
nftAddress = await nftFactory.createNFT(nftData)
|
nftAddress = await nftFactory.createNFT(nftData)
|
||||||
|
|
||||||
// we check the created nft
|
// we check the created nft
|
||||||
const nftDatatoken = new Nft(nftOwner)
|
const nftDatatoken = new Nft(nftOwner, await nftOwner.getChainId())
|
||||||
const tokenURI = await nftDatatoken.getTokenURI(nftAddress, 1)
|
const tokenURI = await nftDatatoken.getTokenURI(nftAddress, 1)
|
||||||
assert(tokenURI === nftData.tokenURI)
|
assert(tokenURI === nftData.tokenURI)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#createNftwithErc - should create an NFT and a Datatoken', async () => {
|
it('#createNftwithErc - should create an NFT and a Datatoken', async () => {
|
||||||
// we prepare transaction parameters objects
|
// we prepare transaction parameters objects
|
||||||
const tx = await nftFactory.createNftWithDatatoken(nftData, dtParams)
|
const tx = await nftFactory.createNftWithDatatoken(nftData, dtParams, false)
|
||||||
const trxReceipt = await tx.wait()
|
const trxReceipt = await tx.wait()
|
||||||
const nftCreatedEvent = getEventFromTx(trxReceipt, 'NFTCreated')
|
const nftCreatedEvent = getEventFromTx(trxReceipt, 'NFTCreated')
|
||||||
const tokenCreatedEvent = getEventFromTx(trxReceipt, 'TokenCreated')
|
const tokenCreatedEvent = getEventFromTx(trxReceipt, 'TokenCreated')
|
||||||
@ -114,7 +118,7 @@ describe('Nft Factory test', () => {
|
|||||||
const currentNFTCount = await nftFactory.getCurrentNFTCount()
|
const currentNFTCount = await nftFactory.getCurrentNFTCount()
|
||||||
const currentTokenCount = await nftFactory.getCurrentTokenCount()
|
const currentTokenCount = await nftFactory.getCurrentTokenCount()
|
||||||
|
|
||||||
await nftFactory.createNftWithDatatoken(nftData, dtParams)
|
await nftFactory.createNftWithDatatoken(nftData, dtParams, false)
|
||||||
|
|
||||||
expect((await nftFactory.getCurrentNFTCount()) === currentNFTCount + 1)
|
expect((await nftFactory.getCurrentNFTCount()) === currentNFTCount + 1)
|
||||||
expect((await nftFactory.getCurrentTokenCount()) === currentTokenCount + 1)
|
expect((await nftFactory.getCurrentTokenCount()) === currentTokenCount + 1)
|
||||||
@ -187,14 +191,18 @@ describe('Nft Factory test', () => {
|
|||||||
const consumeFeeAddress = user2 // marketplace fee Collector
|
const consumeFeeAddress = user2 // marketplace fee Collector
|
||||||
const consumeFeeAmount = '0' // fee to be collected on top, requires approval
|
const consumeFeeAmount = '0' // fee to be collected on top, requires approval
|
||||||
const consumeFeeToken = addresses.MockDAI // token address for the feeAmount, in this case DAI
|
const consumeFeeToken = addresses.MockDAI // token address for the feeAmount, in this case DAI
|
||||||
nftFactory = new NftFactory(addresses.ERC721Factory, consumer)
|
nftFactory = new NftFactory(
|
||||||
|
addresses.ERC721Factory,
|
||||||
|
consumer,
|
||||||
|
await consumer.getChainId()
|
||||||
|
)
|
||||||
// we reuse a DT created in a previous test
|
// we reuse a DT created in a previous test
|
||||||
expect(
|
expect(
|
||||||
parseInt(await balance(nftOwner, dtAddress, await user1.getAddress()))
|
parseInt(await balance(nftOwner, dtAddress, await user1.getAddress()))
|
||||||
).to.equal(0)
|
).to.equal(0)
|
||||||
|
|
||||||
// dt owner mint DATA_TOKEN_AMOUNT to user1
|
// dt owner mint DATA_TOKEN_AMOUNT to user1
|
||||||
const datatoken = new Datatoken(nftOwner)
|
const datatoken = new Datatoken(nftOwner, await nftOwner.getChainId())
|
||||||
datatoken.mint(
|
datatoken.mint(
|
||||||
dtAddress,
|
dtAddress,
|
||||||
await nftOwner.getAddress(),
|
await nftOwner.getAddress(),
|
||||||
@ -311,7 +319,11 @@ describe('Nft Factory test', () => {
|
|||||||
|
|
||||||
it('#addNFTTemplate - should add a new NFT token template', async () => {
|
it('#addNFTTemplate - should add a new NFT token template', async () => {
|
||||||
const currentNFTTemplateCount = await nftFactory.getCurrentNFTTemplateCount()
|
const currentNFTTemplateCount = await nftFactory.getCurrentNFTTemplateCount()
|
||||||
nftFactory = new NftFactory(addresses.ERC721Factory, factoryOwner)
|
nftFactory = new NftFactory(
|
||||||
|
addresses.ERC721Factory,
|
||||||
|
factoryOwner,
|
||||||
|
await factoryOwner.getChainId()
|
||||||
|
)
|
||||||
await nftFactory.addNFTTemplate(
|
await nftFactory.addNFTTemplate(
|
||||||
await factoryOwner.getAddress(),
|
await factoryOwner.getAddress(),
|
||||||
addresses.ERC721Template['1']
|
addresses.ERC721Template['1']
|
||||||
@ -324,7 +336,11 @@ describe('Nft Factory test', () => {
|
|||||||
|
|
||||||
it('#disableNFTTemplate - should disable an NFT token template', async () => {
|
it('#disableNFTTemplate - should disable an NFT token template', async () => {
|
||||||
const currentNFTTemplateCount = await nftFactory.getCurrentNFTTemplateCount()
|
const currentNFTTemplateCount = await nftFactory.getCurrentNFTTemplateCount()
|
||||||
nftFactory = new NftFactory(addresses.ERC721Factory, factoryOwner)
|
nftFactory = new NftFactory(
|
||||||
|
addresses.ERC721Factory,
|
||||||
|
factoryOwner,
|
||||||
|
await factoryOwner.getChainId()
|
||||||
|
)
|
||||||
let nftTemplate = await nftFactory.getNFTTemplate(currentNFTTemplateCount)
|
let nftTemplate = await nftFactory.getNFTTemplate(currentNFTTemplateCount)
|
||||||
assert(nftTemplate.isActive === true)
|
assert(nftTemplate.isActive === true)
|
||||||
|
|
||||||
@ -339,7 +355,11 @@ describe('Nft Factory test', () => {
|
|||||||
|
|
||||||
it('#reactivateNFTTemplate - should reactivate an NFT previously disabled token template', async () => {
|
it('#reactivateNFTTemplate - should reactivate an NFT previously disabled token template', async () => {
|
||||||
const currentNFTTemplateCount = await nftFactory.getCurrentNFTTemplateCount()
|
const currentNFTTemplateCount = await nftFactory.getCurrentNFTTemplateCount()
|
||||||
nftFactory = new NftFactory(addresses.ERC721Factory, factoryOwner)
|
nftFactory = new NftFactory(
|
||||||
|
addresses.ERC721Factory,
|
||||||
|
factoryOwner,
|
||||||
|
await factoryOwner.getChainId()
|
||||||
|
)
|
||||||
let nftTemplate = await nftFactory.getNFTTemplate(currentNFTTemplateCount)
|
let nftTemplate = await nftFactory.getNFTTemplate(currentNFTTemplateCount)
|
||||||
assert(nftTemplate.isActive === false)
|
assert(nftTemplate.isActive === false)
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ describe('Router unit test', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should initiate Router instance', async () => {
|
it('should initiate Router instance', async () => {
|
||||||
router = new Router(addresses.Router, user1)
|
router = new Router(addresses.Router, user1, await user1.getChainId())
|
||||||
})
|
})
|
||||||
|
|
||||||
it('#getOwner - should return actual owner', async () => {
|
it('#getOwner - should return actual owner', async () => {
|
||||||
@ -107,7 +107,7 @@ describe('Router unit test', () => {
|
|||||||
|
|
||||||
it('#buyDatatokenBatch - should buy multiple DT in one call', async () => {
|
it('#buyDatatokenBatch - should buy multiple DT in one call', async () => {
|
||||||
// APPROVE DAI
|
// APPROVE DAI
|
||||||
const daiContract = new Datatoken(factoryOwner)
|
const daiContract = new Datatoken(factoryOwner, await factoryOwner.getChainId())
|
||||||
await daiContract.transfer(addresses.MockDAI, await user1.getAddress(), DAI_AMOUNT)
|
await daiContract.transfer(addresses.MockDAI, await user1.getAddress(), DAI_AMOUNT)
|
||||||
|
|
||||||
await approve(
|
await approve(
|
||||||
@ -133,7 +133,11 @@ describe('Router unit test', () => {
|
|||||||
withMint: true
|
withMint: true
|
||||||
}
|
}
|
||||||
|
|
||||||
const nftFactory = new NftFactory(addresses.ERC721Factory, factoryOwner)
|
const nftFactory = new NftFactory(
|
||||||
|
addresses.ERC721Factory,
|
||||||
|
factoryOwner,
|
||||||
|
await factoryOwner.getChainId()
|
||||||
|
)
|
||||||
const tx = await nftFactory.createNftWithDatatokenWithFixedRate(
|
const tx = await nftFactory.createNftWithDatatokenWithFixedRate(
|
||||||
NFT_DATA,
|
NFT_DATA,
|
||||||
ERC_PARAMS,
|
ERC_PARAMS,
|
||||||
@ -152,7 +156,7 @@ describe('Router unit test', () => {
|
|||||||
|
|
||||||
const freId1 = NewFixedRateEvent.args.exchangeId
|
const freId1 = NewFixedRateEvent.args.exchangeId
|
||||||
|
|
||||||
const datatoken = new Datatoken(factoryOwner)
|
const datatoken = new Datatoken(factoryOwner, await factoryOwner.getChainId())
|
||||||
await datatoken.mint(
|
await datatoken.mint(
|
||||||
datatokenAddress,
|
datatokenAddress,
|
||||||
await factoryOwner.getAddress(),
|
await factoryOwner.getAddress(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user