Skip to content

Commit

Permalink
Update scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Lima committed Apr 30, 2024
1 parent 7f3ab81 commit ed40718
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 27 deletions.
10 changes: 5 additions & 5 deletions addresses/cronos/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
"KMSDeployer": {
"address": "0x04c8c6c56dab836f8bd62cb6884371507e706806"
},
"OriumMarketplace": {
"address": "0xD9DDC66Ba9dE5B6f3b437133F5bf4D8e1c2Bc558",
"operator": "0x04c8c6c56dab836f8bd62cb6884371507e706806",
"implementation": "0x55DaC2D38817686fb5e6Dbd4393f2dAFB2e298F5",
"proxyAdmin": "0x5E053177c73636d4378cfB4D095cFb374eBb3Da6"
"NftRentalMarketplace": {
"address": "",
"operator": "",
"implementation": "",
"proxyAdmin": ""
},
"ImmutableOwnerCreate2Factory": {
"address": "0x066f91a9Aa4C33D4ea4c12aBee6f4cb4e919F71d"
Expand Down
10 changes: 5 additions & 5 deletions addresses/cronosTestnet/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
"KMSDeployer": {
"address": "0x04c8c6c56dab836f8bd62cb6884371507e706806"
},
"OriumMarketplace": {
"address": "0x0BA6c992049b3219e733424E24bE7829d7736f6b",
"operator": "0x04c8c6c56dab836f8bd62cb6884371507e706806",
"implementation": "0xAb8E668acD4FEF935D5DfD869410bf8704688a53",
"proxyAdmin": "0xC3154ccAC181eb9d71ccd53f29F425BDdD52d983"
"NftRentalMarketplace": {
"address": "",
"operator": "",
"implementation": "",
"proxyAdmin": ""
},
"ImmutableOwnerCreate2Factory": {
"address": "0x066f91a9Aa4C33D4ea4c12aBee6f4cb4e919F71d"
Expand Down
6 changes: 0 additions & 6 deletions addresses/moonbeam/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@
"KMSDeployer": {
"address": "0x04c8c6c56dab836f8bd62cb6884371507e706806"
},
"OriumMarketplace": {
"address": "",
"operator": "",
"implementation": "",
"proxyAdmin": ""
},
"ImmutableOwnerCreate2Factory": {
"address": ""
},
Expand Down
10 changes: 5 additions & 5 deletions addresses/polygon/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
"KMSDeployer": {
"address": "0x04c8c6c56dab836f8bd62cb6884371507e706806"
},
"OriumMarketplace": {
"address": "0x277fe6c16BF507E4816CB41dB2170aec955a24A6",
"operator": "0x359E1208DE02Af11461A37D72165Ef2dcD2Adfc8",
"implementation": "0x830cBc0e100e72e8682391A668Ce6c9Db703848F",
"proxyAdmin": "0x48c769f6a8de57d824f0e7330d7A27dee53a43cD"
"NftRentalMarketplace": {
"address": "",
"operator": "",
"implementation": "",
"proxyAdmin": ""
},
"ImmutableOwnerCreate2Factory": {
"address": "0x066f91a9Aa4C33D4ea4c12aBee6f4cb4e919F71d"
Expand Down
39 changes: 39 additions & 0 deletions scripts/nft-rental-marketplace/02-create-rental-offer.ts
Original file line number Diff line number Diff line change
@@ -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

Check warning on line 15 in scripts/nft-rental-marketplace/02-create-rental-offer.ts

View workflow job for this annotation

GitHub Actions / build_test_deploy

Forbidden non-null assertion
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
})
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
22 changes: 22 additions & 0 deletions scripts/orium-marketplace-royalties/10-set-roles-registry.ts
Original file line number Diff line number Diff line change
@@ -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
})
12 changes: 8 additions & 4 deletions utils/write-contract.ts
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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?`,
Expand All @@ -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...`)
Expand Down

0 comments on commit ed40718

Please sign in to comment.