-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Daniel Lima
committed
Nov 27, 2023
1 parent
9b10825
commit 58639da
Showing
2 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { ethers, network as hardhatNetwork } from 'hardhat' | ||
import config, { Network } from '../addresses' | ||
import { colors, print, confirmOrDie } from '../utils/misc' | ||
import { RentalOffer } from '../utils/types' | ||
import { AddressZero, EMPTY_BYTES, ONE_DAY } from '../utils/constants' | ||
import { randomBytes } from 'crypto' | ||
import { toWei } from '../utils/bignumber' | ||
import { USER_ROLE } from '../utils/roles' | ||
|
||
async function main() { | ||
const NETWORK = hardhatNetwork.name as Network | ||
const CONTRACT_NAME = 'OriumMarketplace' | ||
const CONTRACT_ADDRESS = config[NETWORK][CONTRACT_NAME].address | ||
|
||
await confirmOrDie( | ||
`Are you sure you want to create a rental offer ${config[NETWORK].RolesRegistry.address} for ${CONTRACT_NAME} on ${NETWORK} network?`, | ||
) | ||
|
||
const contract = await ethers.getContractAt(CONTRACT_NAME, CONTRACT_ADDRESS) | ||
|
||
const blockTimestamp = (await ethers.provider.getBlock('latest')).timestamp | ||
|
||
const rentalOffer: RentalOffer = { | ||
nonce: `0x${randomBytes(32).toString('hex')}`, | ||
lender: '0xe3A75c99cD21674188bea652Fe378cA5cf7e7906', | ||
borrower: AddressZero, | ||
tokenAddress: '0x86935F11C86623deC8a25696E1C19a8659CbF95d', | ||
tokenId: 13477, //13477, | ||
feeTokenAddress: '0x385Eeac5cB85A38A9a07A70c73e0a3271CfB54A7', | ||
feeAmountPerSecond: toWei('0.999999999907421'), | ||
deadline: blockTimestamp + ONE_DAY, | ||
roles: [USER_ROLE], | ||
rolesData: [EMPTY_BYTES], | ||
} | ||
const tx = await contract.createRentalOffer(rentalOffer) | ||
|
||
print(colors.highlight, `Transaction hash: ${tx.hash}`) | ||
print(colors.success, `Created rental offer in ${CONTRACT_NAME} on ${NETWORK} network!`) | ||
} | ||
|
||
main() | ||
.then(() => { | ||
console.log('Done!') | ||
}) | ||
.catch(error => { | ||
console.error(error) | ||
process.exitCode = 1 | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { ethers, network as hardhatNetwork } from 'hardhat' | ||
import config, { Network } from '../addresses' | ||
import { colors, print, confirmOrDie } from '../utils/misc' | ||
|
||
async function main() { | ||
const NETWORK = hardhatNetwork.name as Network | ||
const CONTRACT_NAME = 'OriumMarketplace' | ||
const CONTRACT_ADDRESS = config[NETWORK][CONTRACT_NAME].address | ||
|
||
await confirmOrDie( | ||
`Are you sure you want to cancel a rental offer ${config[NETWORK].RolesRegistry.address} for ${CONTRACT_NAME} on ${NETWORK} network?`, | ||
) | ||
|
||
const contract = await ethers.getContractAt(CONTRACT_NAME, CONTRACT_ADDRESS) | ||
|
||
const nonce = '71870379709915352622008287115212578751761046896364388794105918647859783855919' | ||
const tx = await contract.cancelRentalOffer(nonce) | ||
|
||
print(colors.highlight, `Transaction hash: ${tx.hash}`) | ||
print(colors.success, `Cancelled rental offer in ${CONTRACT_NAME} on ${NETWORK} network!`) | ||
} | ||
|
||
main() | ||
.then(() => { | ||
console.log('Done!') | ||
}) | ||
.catch(error => { | ||
console.error(error) | ||
process.exitCode = 1 | ||
}) |