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
|
name?: string
|
||||||
symbol?: string
|
symbol?: string
|
||||||
filesObject?: any // file object for template 4
|
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 {
|
export interface ConsumeMarketFee {
|
||||||
|
@ -182,4 +182,5 @@ export class Config {
|
|||||||
|
|
||||||
// is confidential evm
|
// is confidential evm
|
||||||
confidentialEVM?: boolean
|
confidentialEVM?: boolean
|
||||||
|
accessListFactory?: string
|
||||||
}
|
}
|
||||||
|
@ -154,8 +154,7 @@ 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
|
||||||
confidentialEVM: true
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
...configHelperNetworksBase,
|
...configHelperNetworksBase,
|
||||||
@ -165,8 +164,7 @@ 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
|
||||||
confidentialEVM: true
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
...configHelperNetworksBase,
|
...configHelperNetworksBase,
|
||||||
@ -207,7 +205,8 @@ export class ConfigHelper {
|
|||||||
veDelegationProxy,
|
veDelegationProxy,
|
||||||
DFRewards,
|
DFRewards,
|
||||||
DFStrategyV1,
|
DFStrategyV1,
|
||||||
veFeeEstimate
|
veFeeEstimate,
|
||||||
|
AccessListFactory
|
||||||
} = customAddresses[network]
|
} = customAddresses[network]
|
||||||
configAddresses = {
|
configAddresses = {
|
||||||
nftFactoryAddress: ERC721Factory,
|
nftFactoryAddress: ERC721Factory,
|
||||||
@ -225,6 +224,7 @@ export class ConfigHelper {
|
|||||||
DFRewards,
|
DFRewards,
|
||||||
DFStrategyV1,
|
DFStrategyV1,
|
||||||
veFeeEstimate,
|
veFeeEstimate,
|
||||||
|
accessListFactory: AccessListFactory,
|
||||||
...(process.env.AQUARIUS_URL && { metadataCacheUri: process.env.AQUARIUS_URL }),
|
...(process.env.AQUARIUS_URL && { metadataCacheUri: process.env.AQUARIUS_URL }),
|
||||||
...(process.env.PROVIDER_URL && { providerUri: process.env.PROVIDER_URL })
|
...(process.env.PROVIDER_URL && { providerUri: process.env.PROVIDER_URL })
|
||||||
}
|
}
|
||||||
@ -246,7 +246,8 @@ export class ConfigHelper {
|
|||||||
veDelegationProxy,
|
veDelegationProxy,
|
||||||
DFRewards,
|
DFRewards,
|
||||||
DFStrategyV1,
|
DFStrategyV1,
|
||||||
veFeeEstimate
|
veFeeEstimate,
|
||||||
|
AccessListFactory
|
||||||
} = DefaultContractsAddresses[network]
|
} = DefaultContractsAddresses[network]
|
||||||
configAddresses = {
|
configAddresses = {
|
||||||
nftFactoryAddress: ERC721Factory,
|
nftFactoryAddress: ERC721Factory,
|
||||||
@ -264,6 +265,7 @@ export class ConfigHelper {
|
|||||||
DFRewards,
|
DFRewards,
|
||||||
DFStrategyV1,
|
DFStrategyV1,
|
||||||
veFeeEstimate,
|
veFeeEstimate,
|
||||||
|
accessListFactory: AccessListFactory,
|
||||||
...(process.env.AQUARIUS_URL && { metadataCacheUri: process.env.AQUARIUS_URL }),
|
...(process.env.AQUARIUS_URL && { metadataCacheUri: process.env.AQUARIUS_URL }),
|
||||||
...(process.env.PROVIDER_URL && { providerUri: process.env.PROVIDER_URL })
|
...(process.env.PROVIDER_URL && { providerUri: process.env.PROVIDER_URL })
|
||||||
}
|
}
|
||||||
@ -313,6 +315,9 @@ export class ConfigHelper {
|
|||||||
filterBy === 'chainId'
|
filterBy === 'chainId'
|
||||||
? KNOWN_CONFIDENTIAL_EVMS.includes(Number(network))
|
? KNOWN_CONFIDENTIAL_EVMS.includes(Number(network))
|
||||||
: network.toString().includes('oasis_sap')
|
: network.toString().includes('oasis_sap')
|
||||||
|
if (config.confidentialEVM) {
|
||||||
|
config.accessListFactory = contractAddressesConfig.accessListFactory
|
||||||
|
}
|
||||||
|
|
||||||
config = { ...config, ...contractAddressesConfig }
|
config = { ...config, ...contractAddressesConfig }
|
||||||
|
|
||||||
|
@ -577,7 +577,11 @@ export class NftFactory extends SmartContractWithAddress {
|
|||||||
dtParams.minter,
|
dtParams.minter,
|
||||||
dtParams.paymentCollector,
|
dtParams.paymentCollector,
|
||||||
dtParams.mpFeeAddress,
|
dtParams.mpFeeAddress,
|
||||||
dtParams.feeToken
|
dtParams.feeToken,
|
||||||
|
// template 4 only, ignored for others
|
||||||
|
dtParams.accessListFactory,
|
||||||
|
dtParams.allowAccessList,
|
||||||
|
dtParams.denyAccessList
|
||||||
],
|
],
|
||||||
uints: [
|
uints: [
|
||||||
await this.amountToUnits(null, dtParams.cap, 18),
|
await this.amountToUnits(null, dtParams.cap, 18),
|
||||||
|
@ -19,6 +19,7 @@ import { getEventFromTx } from './ContractUtils'
|
|||||||
import { ProviderInstance } from '../services/Provider'
|
import { ProviderInstance } from '../services/Provider'
|
||||||
// eslint-disable-next-line import/no-named-default
|
// eslint-disable-next-line import/no-named-default
|
||||||
import ERC20Template from '@oceanprotocol/contracts/artifacts/contracts/interfaces/IERC20Template.sol/IERC20Template.json'
|
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'
|
// import * as hre from 'hardhat'
|
||||||
|
|
||||||
@ -126,6 +127,8 @@ export async function calculateActiveTemplateIndex(
|
|||||||
* @param providerFeeToken the provider fee token
|
* @param providerFeeToken the provider fee token
|
||||||
* @param nftContractAddress the nft contract address
|
* @param nftContractAddress the nft contract address
|
||||||
* @param aquariusInstance aquarius, could be node instance url
|
* @param aquariusInstance aquarius, could be node instance url
|
||||||
|
* @param allowAccessList?: string,
|
||||||
|
* @param denyAccessList?: string
|
||||||
* @returns ddo id as string
|
* @returns ddo id as string
|
||||||
*/
|
*/
|
||||||
export async function createAsset(
|
export async function createAsset(
|
||||||
@ -139,7 +142,10 @@ export async function createAsset(
|
|||||||
providerUrl: string,
|
providerUrl: string,
|
||||||
providerFeeToken: string,
|
providerFeeToken: string,
|
||||||
aquariusInstance: Aquarius,
|
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> {
|
): Promise<string> {
|
||||||
const isAddress = typeof templateIDorAddress === 'string'
|
const isAddress = typeof templateIDorAddress === 'string'
|
||||||
const isTemplateIndex = typeof templateIDorAddress === 'number'
|
const isTemplateIndex = typeof templateIDorAddress === 'number'
|
||||||
@ -196,7 +202,14 @@ export async function createAsset(
|
|||||||
|
|
||||||
// include fileObject in the DT constructor
|
// include fileObject in the DT constructor
|
||||||
if (config.confidentialEVM) {
|
if (config.confidentialEVM) {
|
||||||
|
// const accessListAddress = await createAccessListFactory(
|
||||||
|
// config.accessListFactory,
|
||||||
|
// owner
|
||||||
|
// )
|
||||||
datatokenParams.filesObject = assetUrl
|
datatokenParams.filesObject = assetUrl
|
||||||
|
datatokenParams.accessListFactory = accessListFactory || config.accessListFactory
|
||||||
|
datatokenParams.allowAccessList = allowAccessList
|
||||||
|
datatokenParams.denyAccessList = denyAccessList
|
||||||
}
|
}
|
||||||
|
|
||||||
let bundleNFT
|
let bundleNFT
|
||||||
@ -292,3 +305,37 @@ export async function createAsset(
|
|||||||
)
|
)
|
||||||
return ddo.id
|
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