mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
added changes for access lists
This commit is contained in:
parent
51ddf52d58
commit
b5a2a64271
@ -11,6 +11,9 @@ export interface DatatokenCreateParams {
|
||||
name?: string
|
||||
symbol?: string
|
||||
filesObject?: any // file object for template 4
|
||||
accessListFactory?: string // access list factory address
|
||||
allowAccessList?: string // Allow List Contract (if any)
|
||||
denyAccessList?: string // Deny List Contract (if any)
|
||||
}
|
||||
|
||||
export interface ConsumeMarketFee {
|
||||
|
@ -182,4 +182,5 @@ export class Config {
|
||||
|
||||
// is confidential evm
|
||||
confidentialEVM?: boolean
|
||||
accessListFactory?: string
|
||||
}
|
||||
|
@ -154,8 +154,7 @@ export const configHelperNetworks: Config[] = [
|
||||
nodeUri: 'https://sapphire.oasis.io',
|
||||
subgraphUri: 'https://v4.subgraph.sapphire-mainnet.oceanprotocol.com/',
|
||||
explorerUri: 'https://explorer.oasis.io/mainnet/sapphire/',
|
||||
gasFeeMultiplier: 1,
|
||||
confidentialEVM: true
|
||||
gasFeeMultiplier: 1
|
||||
},
|
||||
{
|
||||
...configHelperNetworksBase,
|
||||
@ -165,8 +164,7 @@ export const configHelperNetworks: Config[] = [
|
||||
subgraphUri:
|
||||
'https://v4.subgraph.sapphire-testnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph',
|
||||
explorerUri: 'https://explorer.oasis.io/testnet/sapphire/',
|
||||
gasFeeMultiplier: 1,
|
||||
confidentialEVM: true
|
||||
gasFeeMultiplier: 1
|
||||
},
|
||||
{
|
||||
...configHelperNetworksBase,
|
||||
@ -207,7 +205,8 @@ export class ConfigHelper {
|
||||
veDelegationProxy,
|
||||
DFRewards,
|
||||
DFStrategyV1,
|
||||
veFeeEstimate
|
||||
veFeeEstimate,
|
||||
AccessListFactory
|
||||
} = customAddresses[network]
|
||||
configAddresses = {
|
||||
nftFactoryAddress: ERC721Factory,
|
||||
@ -225,6 +224,7 @@ export class ConfigHelper {
|
||||
DFRewards,
|
||||
DFStrategyV1,
|
||||
veFeeEstimate,
|
||||
accessListFactory: AccessListFactory,
|
||||
...(process.env.AQUARIUS_URL && { metadataCacheUri: process.env.AQUARIUS_URL }),
|
||||
...(process.env.PROVIDER_URL && { providerUri: process.env.PROVIDER_URL })
|
||||
}
|
||||
@ -246,7 +246,8 @@ export class ConfigHelper {
|
||||
veDelegationProxy,
|
||||
DFRewards,
|
||||
DFStrategyV1,
|
||||
veFeeEstimate
|
||||
veFeeEstimate,
|
||||
AccessListFactory
|
||||
} = DefaultContractsAddresses[network]
|
||||
configAddresses = {
|
||||
nftFactoryAddress: ERC721Factory,
|
||||
@ -264,6 +265,7 @@ export class ConfigHelper {
|
||||
DFRewards,
|
||||
DFStrategyV1,
|
||||
veFeeEstimate,
|
||||
accessListFactory: AccessListFactory,
|
||||
...(process.env.AQUARIUS_URL && { metadataCacheUri: process.env.AQUARIUS_URL }),
|
||||
...(process.env.PROVIDER_URL && { providerUri: process.env.PROVIDER_URL })
|
||||
}
|
||||
@ -313,6 +315,9 @@ export class ConfigHelper {
|
||||
filterBy === 'chainId'
|
||||
? KNOWN_CONFIDENTIAL_EVMS.includes(Number(network))
|
||||
: network.toString().includes('oasis_sap')
|
||||
if (config.confidentialEVM) {
|
||||
config.accessListFactory = contractAddressesConfig.accessListFactory
|
||||
}
|
||||
|
||||
config = { ...config, ...contractAddressesConfig }
|
||||
|
||||
|
@ -577,7 +577,11 @@ export class NftFactory extends SmartContractWithAddress {
|
||||
dtParams.minter,
|
||||
dtParams.paymentCollector,
|
||||
dtParams.mpFeeAddress,
|
||||
dtParams.feeToken
|
||||
dtParams.feeToken,
|
||||
// template 4 only, ignored for others
|
||||
dtParams.accessListFactory,
|
||||
dtParams.allowAccessList,
|
||||
dtParams.denyAccessList
|
||||
],
|
||||
uints: [
|
||||
await this.amountToUnits(null, dtParams.cap, 18),
|
||||
|
@ -19,6 +19,7 @@ import { getEventFromTx } from './ContractUtils'
|
||||
import { ProviderInstance } from '../services/Provider'
|
||||
// eslint-disable-next-line import/no-named-default
|
||||
import ERC20Template from '@oceanprotocol/contracts/artifacts/contracts/interfaces/IERC20Template.sol/IERC20Template.json'
|
||||
import AccessListFactory from '@oceanprotocol/contracts/artifacts/contracts/accesslists/AccessListFactory.sol/AccessListFactory.json'
|
||||
|
||||
// import * as hre from 'hardhat'
|
||||
|
||||
@ -126,6 +127,8 @@ export async function calculateActiveTemplateIndex(
|
||||
* @param providerFeeToken the provider fee token
|
||||
* @param nftContractAddress the nft contract address
|
||||
* @param aquariusInstance aquarius, could be node instance url
|
||||
* @param allowAccessList?: string,
|
||||
* @param denyAccessList?: string
|
||||
* @returns ddo id as string
|
||||
*/
|
||||
export async function createAsset(
|
||||
@ -139,7 +142,10 @@ export async function createAsset(
|
||||
providerUrl: string,
|
||||
providerFeeToken: string,
|
||||
aquariusInstance: Aquarius,
|
||||
nftContractAddress?: string // addresses.ERC721Factory,
|
||||
nftContractAddress?: string, // addresses.ERC721Factory,
|
||||
accessListFactory?: string, // access list factory address
|
||||
allowAccessList?: string, // allow list address
|
||||
denyAccessList?: string // deny list address
|
||||
): Promise<string> {
|
||||
const isAddress = typeof templateIDorAddress === 'string'
|
||||
const isTemplateIndex = typeof templateIDorAddress === 'number'
|
||||
@ -196,7 +202,14 @@ export async function createAsset(
|
||||
|
||||
// include fileObject in the DT constructor
|
||||
if (config.confidentialEVM) {
|
||||
// const accessListAddress = await createAccessListFactory(
|
||||
// config.accessListFactory,
|
||||
// owner
|
||||
// )
|
||||
datatokenParams.filesObject = assetUrl
|
||||
datatokenParams.accessListFactory = accessListFactory || config.accessListFactory
|
||||
datatokenParams.allowAccessList = allowAccessList
|
||||
datatokenParams.denyAccessList = denyAccessList
|
||||
}
|
||||
|
||||
let bundleNFT
|
||||
@ -292,3 +305,37 @@ export async function createAsset(
|
||||
)
|
||||
return ddo.id
|
||||
}
|
||||
|
||||
/**
|
||||
* deploy new access list factory if needed
|
||||
* @param accessListFactory accessListFactory address
|
||||
* @param owner owner account
|
||||
* @param addressesList list of addresses to deploy
|
||||
* @returns accessListFactory address
|
||||
*/
|
||||
export async function createAccessListFactory(
|
||||
accessListFactory: string,
|
||||
owner: Signer,
|
||||
addressesList?: string[]
|
||||
): Promise<any> {
|
||||
const factory = new ethers.Contract(accessListFactory, AccessListFactory.abi, owner)
|
||||
const ownerAccount = await owner.getAddress()
|
||||
try {
|
||||
const accessListTx = await factory.deployAccessListContract(
|
||||
'AllowList',
|
||||
'ALLOW',
|
||||
true,
|
||||
ownerAccount,
|
||||
addressesList || [ownerAccount],
|
||||
['https://oceanprotocol.com/nft/']
|
||||
)
|
||||
if (accessListTx && accessListTx.wait) {
|
||||
const trxReceipt = await accessListTx.wait()
|
||||
const events = getEventFromTx(trxReceipt, 'NewAccessList')
|
||||
return events.args[0]
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('ERROR createAccessListFactory(): ', error)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user