From ed40718276a6f44bd72053d59017271928bc6c9d Mon Sep 17 00:00:00 2001 From: Daniel Lima Date: Tue, 30 Apr 2024 16:19:38 -0300 Subject: [PATCH] Update scripts --- addresses/cronos/index.json | 10 ++--- addresses/cronosTestnet/index.json | 10 ++--- addresses/moonbeam/index.json | 6 --- addresses/polygon/index.json | 10 ++--- .../02-create-rental-offer.ts | 39 +++++++++++++++++++ .../08-set-trusted-tokens.ts | 2 +- ...s => 09-set-default-nft-roles-registry.ts} | 3 +- .../10-set-roles-registry.ts | 22 +++++++++++ utils/write-contract.ts | 12 ++++-- 9 files changed, 87 insertions(+), 27 deletions(-) create mode 100644 scripts/nft-rental-marketplace/02-create-rental-offer.ts rename scripts/orium-marketplace-royalties/{09-set-default-nft-roles-registry copy.ts => 09-set-default-nft-roles-registry.ts} (85%) create mode 100644 scripts/orium-marketplace-royalties/10-set-roles-registry.ts diff --git a/addresses/cronos/index.json b/addresses/cronos/index.json index d4eecb4..8af8984 100644 --- a/addresses/cronos/index.json +++ b/addresses/cronos/index.json @@ -11,11 +11,11 @@ "KMSDeployer": { "address": "0x04c8c6c56dab836f8bd62cb6884371507e706806" }, - "OriumMarketplace": { - "address": "0xD9DDC66Ba9dE5B6f3b437133F5bf4D8e1c2Bc558", - "operator": "0x04c8c6c56dab836f8bd62cb6884371507e706806", - "implementation": "0x55DaC2D38817686fb5e6Dbd4393f2dAFB2e298F5", - "proxyAdmin": "0x5E053177c73636d4378cfB4D095cFb374eBb3Da6" + "NftRentalMarketplace": { + "address": "", + "operator": "", + "implementation": "", + "proxyAdmin": "" }, "ImmutableOwnerCreate2Factory": { "address": "0x066f91a9Aa4C33D4ea4c12aBee6f4cb4e919F71d" diff --git a/addresses/cronosTestnet/index.json b/addresses/cronosTestnet/index.json index 9586010..1b4aa31 100644 --- a/addresses/cronosTestnet/index.json +++ b/addresses/cronosTestnet/index.json @@ -11,11 +11,11 @@ "KMSDeployer": { "address": "0x04c8c6c56dab836f8bd62cb6884371507e706806" }, - "OriumMarketplace": { - "address": "0x0BA6c992049b3219e733424E24bE7829d7736f6b", - "operator": "0x04c8c6c56dab836f8bd62cb6884371507e706806", - "implementation": "0xAb8E668acD4FEF935D5DfD869410bf8704688a53", - "proxyAdmin": "0xC3154ccAC181eb9d71ccd53f29F425BDdD52d983" + "NftRentalMarketplace": { + "address": "", + "operator": "", + "implementation": "", + "proxyAdmin": "" }, "ImmutableOwnerCreate2Factory": { "address": "0x066f91a9Aa4C33D4ea4c12aBee6f4cb4e919F71d" diff --git a/addresses/moonbeam/index.json b/addresses/moonbeam/index.json index 258417a..ff71741 100644 --- a/addresses/moonbeam/index.json +++ b/addresses/moonbeam/index.json @@ -11,12 +11,6 @@ "KMSDeployer": { "address": "0x04c8c6c56dab836f8bd62cb6884371507e706806" }, - "OriumMarketplace": { - "address": "", - "operator": "", - "implementation": "", - "proxyAdmin": "" - }, "ImmutableOwnerCreate2Factory": { "address": "" }, diff --git a/addresses/polygon/index.json b/addresses/polygon/index.json index 49d4be8..b588485 100644 --- a/addresses/polygon/index.json +++ b/addresses/polygon/index.json @@ -11,11 +11,11 @@ "KMSDeployer": { "address": "0x04c8c6c56dab836f8bd62cb6884371507e706806" }, - "OriumMarketplace": { - "address": "0x277fe6c16BF507E4816CB41dB2170aec955a24A6", - "operator": "0x359E1208DE02Af11461A37D72165Ef2dcD2Adfc8", - "implementation": "0x830cBc0e100e72e8682391A668Ce6c9Db703848F", - "proxyAdmin": "0x48c769f6a8de57d824f0e7330d7A27dee53a43cD" + "NftRentalMarketplace": { + "address": "", + "operator": "", + "implementation": "", + "proxyAdmin": "" }, "ImmutableOwnerCreate2Factory": { "address": "0x066f91a9Aa4C33D4ea4c12aBee6f4cb4e919F71d" diff --git a/scripts/nft-rental-marketplace/02-create-rental-offer.ts b/scripts/nft-rental-marketplace/02-create-rental-offer.ts new file mode 100644 index 0000000..736a742 --- /dev/null +++ b/scripts/nft-rental-marketplace/02-create-rental-offer.ts @@ -0,0 +1,39 @@ +import { ZeroAddress } from 'ethers' +import { print, colors } from '../../utils/misc' +import { callContractFunction } from '../../utils/write-contract' +import { randomBytes } from 'crypto' +import { etherPerDayToWeiPerSecond } from '../../utils/bignumber' +import { EMPTY_BYTES, ONE_DAY } from '../../utils/constants' +import { USER_ROLE } from '../../utils/roles' +import { ethers } from 'hardhat' +import { RentalOffer } from '../../utils/types' + +const CONTRACT_NAME = 'NftRentalMarketplace' +const CONTRACT_FUNCTION = 'createRentalOffer' + +async function main() { + const blockTimestamp = (await ethers.provider.getBlock('latest'))!.timestamp + const RENTAL_OFFER: RentalOffer = { + nonce: `0x${randomBytes(32).toString('hex')}`, + lender: '0xe3A75c99cD21674188bea652Fe378cA5cf7e7906', + borrower: ZeroAddress, + tokenId: 1994, + tokenAddress: '0xcb13945ca8104f813992e4315f8ffefe64ac49ca', // GLMR jungle address + feeTokenAddress: '0xd10078fdbc835726c79533a4a19db40cfad69d7f', // GLMB address + feeAmountPerSecond: etherPerDayToWeiPerSecond('0.01'), + deadline: blockTimestamp + ONE_DAY, + minDuration: 0, + roles: [USER_ROLE], + rolesData: [EMPTY_BYTES], + } + await callContractFunction(CONTRACT_NAME, CONTRACT_FUNCTION, [RENTAL_OFFER]) +} + +main() + .then(() => { + print(colors.bigSuccess, 'All done!') + }) + .catch(error => { + console.error(error) + process.exitCode = 1 + }) diff --git a/scripts/orium-marketplace-royalties/08-set-trusted-tokens.ts b/scripts/orium-marketplace-royalties/08-set-trusted-tokens.ts index 6a7fa0f..1909f46 100644 --- a/scripts/orium-marketplace-royalties/08-set-trusted-tokens.ts +++ b/scripts/orium-marketplace-royalties/08-set-trusted-tokens.ts @@ -1,7 +1,7 @@ import { print, colors } from '../../utils/misc' import { callContractFunction } from '../../utils/write-contract' -const TOKEN_ADDRESSES = ['0x8fbe243d898e7c88a6724bb9eb13d746614d23d6'] // GLMRApes address moonbeam +const TOKEN_ADDRESSES = ['0xcb13945ca8104f813992e4315f8ffefe64ac49ca'] // GLMR Jungle address moonbeam const FEE_TOKEN_ADDRESSES = ['0xd10078fdbc835726c79533a4a19db40cfad69d7f'] // GLMB address moonbeam const IS_TRUSTED = [true] const CONTRACT_NAME = 'OriumMarketplaceRoyalties' diff --git a/scripts/orium-marketplace-royalties/09-set-default-nft-roles-registry copy.ts b/scripts/orium-marketplace-royalties/09-set-default-nft-roles-registry.ts similarity index 85% rename from scripts/orium-marketplace-royalties/09-set-default-nft-roles-registry copy.ts rename to scripts/orium-marketplace-royalties/09-set-default-nft-roles-registry.ts index 2731d3d..db77380 100644 --- a/scripts/orium-marketplace-royalties/09-set-default-nft-roles-registry copy.ts +++ b/scripts/orium-marketplace-royalties/09-set-default-nft-roles-registry.ts @@ -1,12 +1,13 @@ import { ZeroAddress } from 'ethers' import { print, colors } from '../../utils/misc' import { callContractFunction } from '../../utils/write-contract' +import { kmsDeployer } from '../../utils/deployer' const CONTRACT_NAME = 'OriumMarketplaceRoyalties' const CONTRACT_FUNCTION = 'setDefaultNftRolesRegistry' const CONTRACT_ARGUMENTS = [ZeroAddress] async function main() { - await callContractFunction(CONTRACT_NAME, CONTRACT_FUNCTION, CONTRACT_ARGUMENTS) + await callContractFunction(CONTRACT_NAME, CONTRACT_FUNCTION, CONTRACT_ARGUMENTS, kmsDeployer as any) } main() diff --git a/scripts/orium-marketplace-royalties/10-set-roles-registry.ts b/scripts/orium-marketplace-royalties/10-set-roles-registry.ts new file mode 100644 index 0000000..b1f2f7b --- /dev/null +++ b/scripts/orium-marketplace-royalties/10-set-roles-registry.ts @@ -0,0 +1,22 @@ +import { kmsDeployer } from '../../utils/deployer' +import { print, colors } from '../../utils/misc' +import { callContractFunction } from '../../utils/write-contract' + +const CONTRACT_NAME = 'OriumMarketplaceRoyalties' +const CONTRACT_FUNCTION = 'setRolesRegistry' +const TOKEN_ADDRESS = '0xcb13945ca8104f813992e4315f8ffefe64ac49ca' +const ROLES_REGISTRY = '0xc3154ccac181eb9d71ccd53f29f425bddd52d983' +const CONTRACT_ARGUMENTS = [TOKEN_ADDRESS, ROLES_REGISTRY] + +async function main() { + await callContractFunction(CONTRACT_NAME, CONTRACT_FUNCTION, CONTRACT_ARGUMENTS, kmsDeployer as any) +} + +main() + .then(() => { + print(colors.bigSuccess, 'All done!') + }) + .catch(error => { + console.error(error) + process.exitCode = 1 + }) diff --git a/utils/write-contract.ts b/utils/write-contract.ts index 2d86a81..e449208 100644 --- a/utils/write-contract.ts +++ b/utils/write-contract.ts @@ -1,7 +1,8 @@ -import { ethers, network } from 'hardhat' +import { network, ethers } from 'hardhat' import config, { Network } from '../addresses' import { print, colors, confirmOrDie } from '../utils/misc' -import { kmsDeployer, kmsProvider } from './deployer' +import { kmsProvider } from './deployer' +import { Signer } from 'ethers' const NETWORK = network.name as Network @@ -18,7 +19,9 @@ export async function callContractFunction( FUNCTION_NAME: string, FUNCTION_ARGUMENTS: any, CUSTOM_FEE_DATA?: { maxFeePerGas: bigint; maxPriorityFeePerGas: bigint }, + CUSTOM_SIGNER?: Signer, ) { + const signer = CUSTOM_SIGNER || (await ethers.getSigners())[0] console.log('CONTRACT_NAME', CONTRACT_NAME) await confirmOrDie( `Are you sure you want to call ${FUNCTION_NAME} in ${CONTRACT_NAME} contract on ${NETWORK} network?`, @@ -27,8 +30,9 @@ export async function callContractFunction( const FEE_DATA: any = CUSTOM_FEE_DATA kmsProvider.getFeeData = async () => FEE_DATA } - print(colors.warn, `Arguments: ${FUNCTION_ARGUMENTS}`) - const contract = await ethers.getContractAt(CONTRACT_NAME, config[NETWORK][CONTRACT_NAME].address, kmsDeployer) + print(colors.warn, `Arguments:`) + console.log(FUNCTION_ARGUMENTS) + const contract = await ethers.getContractAt(CONTRACT_NAME, config[NETWORK][CONTRACT_NAME].address, signer) print(colors.highlight, `Sending Transaction...`) const response = await contract[FUNCTION_NAME](...FUNCTION_ARGUMENTS) print(colors.highlight, `Waiting for transaction to be mined...`)