Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ON-815: add set royalties function to nft rental marketplace #49

Merged
merged 2 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
ON-815
: update scripts
  • Loading branch information
Daniel Lima committed May 10, 2024
commit 4827b2a44b6a616055607360a2ee10d469600a55
1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions scripts/nft-rental-marketplace/07-approve-nft.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { print, colors } from '../../utils/misc'
import { callContractFunction } from '../../utils/write-contract'
import addresses, { Network } from '../../addresses'
import { network } from 'hardhat'

const NETWORK = network.name as Network
const CONTRACT_NAME = 'MockERC721'
const CONTRACT_FUNCTION = 'setApprovalForAll'
const FUNCTION_PARAMS = [addresses[NETWORK].NftRentalMarketplace.address, true]
const CUSTOM_CONTRACT_ADDRESS = '0xcB13945Ca8104f813992e4315F8fFeFE64ac49cA'

async function main() {
await callContractFunction(CONTRACT_NAME, CONTRACT_FUNCTION, FUNCTION_PARAMS, { CUSTOM_CONTRACT_ADDRESS })
}

main()
.then(() => {
print(colors.bigSuccess, 'All done!')
})
.catch(error => {
console.error(error)
process.exitCode = 1
})
18 changes: 13 additions & 5 deletions utils/write-contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,19 @@ const NETWORK = network.name as Network
* @param CONTRACT_NAME The name of the contract
* @param FUNCTION_NAME The function to call
* @param FUNCTION_ARGUMENTS The arguments to pass to the function
* @param CUSTOM_FEE_DATA The custom fee data (optional)
* @param OPTIONS The custom fee data, signer or contract file name
*/
export async function callContractFunction(
CONTRACT_NAME: keyof (typeof config)[Network],
CONTRACT_NAME: keyof (typeof config)[Network] | string,
FUNCTION_NAME: string,
FUNCTION_ARGUMENTS: any,
CUSTOM_FEE_DATA?: { maxFeePerGas: bigint; maxPriorityFeePerGas: bigint },
CUSTOM_SIGNER?: Signer,
OPTIONS: {
CUSTOM_FEE_DATA?: { maxFeePerGas: bigint; maxPriorityFeePerGas: bigint }
CUSTOM_SIGNER?: Signer
CUSTOM_CONTRACT_ADDRESS?: string
},
) {
const { CUSTOM_FEE_DATA, CUSTOM_SIGNER, CUSTOM_CONTRACT_ADDRESS } = OPTIONS
const signer = CUSTOM_SIGNER || (await ethers.getSigners())[0]
console.log('CONTRACT_NAME', CONTRACT_NAME)
await confirmOrDie(
Expand All @@ -32,7 +36,11 @@ export async function callContractFunction(
}
print(colors.warn, `Arguments:`)
console.log(FUNCTION_ARGUMENTS)
const contract = await ethers.getContractAt(CONTRACT_NAME, config[NETWORK][CONTRACT_NAME].address, signer)
const contract = await ethers.getContractAt(
CONTRACT_NAME,
CUSTOM_CONTRACT_ADDRESS ?? config[NETWORK][CONTRACT_NAME as keyof (typeof config)[Network]].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
Loading