diff --git a/tinlake-ui/components/CreateNFT/index.tsx b/tinlake-ui/components/CreateNFT/index.tsx index 526a56e4..7c60b4da 100644 --- a/tinlake-ui/components/CreateNFT/index.tsx +++ b/tinlake-ui/components/CreateNFT/index.tsx @@ -1,5 +1,5 @@ import { baseToDisplay, displayToBase } from '@centrifuge/tinlake-js' -import { Box, Button, FormField } from 'grommet' +import { Box, Button, DateInput, FormField } from 'grommet' import { useRouter } from 'next/router' import * as React from 'react' import { useDispatch } from 'react-redux' @@ -10,13 +10,19 @@ import { Grid } from '../Layout' import NumberInput from '../NumberInput' import { useTinlake } from '../TinlakeProvider' +// const convertDateToTimestampInSeconds = (date: Date): number => { +// return Math.floor(date.getTime() / 1000).toString() +// } + const CreateNFT: React.FC = () => { + const DAYS = 24 * 60 * 60 * 1000 const tinlake = useTinlake() const dispatch = useDispatch() const router = useRouter() const [value, setValue] = React.useState('') const [riskGroup, setRiskGroup] = React.useState('1') + const [maturityDate, setMaturityDate] = React.useState(new Date(Date.now() + 30 * DAYS).toISOString()) const [txStatus, , setTxId, tx] = useTransactionState() @@ -53,6 +59,7 @@ const CreateNFT: React.FC = () => { tinlake.contractAddresses.ASSET_NFT!, value, riskGroup, + Math.floor(new Date(maturityDate).getTime() / 1000), ]) ) as any @@ -93,6 +100,18 @@ const CreateNFT: React.FC = () => { disabled={isPending} /> + {tinlake.contractAddresses['LEGACY_ACTIONS'] && ( + + { + console.log(event.value) + setMaturityDate(event.value) + }} + disabled={isPending} + /> + + )} )} diff --git a/tinlake-ui/services/tinlake/actions.ts b/tinlake-ui/services/tinlake/actions.ts index ab2382e7..c36e5286 100644 --- a/tinlake-ui/services/tinlake/actions.ts +++ b/tinlake-ui/services/tinlake/actions.ts @@ -503,9 +503,10 @@ export async function proxyBorrowerMintIssuePrice( minterAddress: string, nftRegistryAddress: string, price: string, - riskGroup: string + riskGroup: string, + maturityDate?: number ): Promise { - return tinlake.proxyBorrowerMintIssuePrice(minterAddress, nftRegistryAddress, price, riskGroup) + return tinlake.proxyBorrowerMintIssuePrice(minterAddress, nftRegistryAddress, price, riskGroup, maturityDate) } export async function proxyTransferCurrency( diff --git a/tinlake.js/src/actions/proxy.ts b/tinlake.js/src/actions/proxy.ts index 821f218f..1a23e023 100644 --- a/tinlake.js/src/actions/proxy.ts +++ b/tinlake.js/src/actions/proxy.ts @@ -83,16 +83,27 @@ export function ProxyActions>(Bas minterAddress: string, nftRegistryAddress: string, price: string, - riskGroup: string + riskGroup: string, + maturityDate?: number ) => { const proxy = this.contract('BORROWER_PROXY') - const encoded = this.contract('ACTIONS').interface.encodeFunctionData('mintIssuePriceLock', [ + let encoded = this.contract('ACTIONS').interface.encodeFunctionData('mintIssuePriceLock', [ minterAddress, nftRegistryAddress, price, riskGroup, ]) + if (maturityDate) { + encoded = this.contract('ACTIONS').interface.encodeFunctionData('mintIssuePriceLock', [ + minterAddress, + nftRegistryAddress, + price, + riskGroup, + maturityDate, + ]) + } + return this.pending( proxy.userExecute(this.contract('ACTIONS').address, encoded, { ...this.overrides, gasLimit: 1500000 }) ) @@ -303,7 +314,8 @@ export type IProxyActions = { minterAddress: string, nftRegistryAddress: string, price: string, - riskGroup: string + riskGroup: string, + maturityDate?: string ): Promise proxyTransferIssue(proxyAddr: string, nftRegistryAddr: string, tokenId: string): Promise proxyLockBorrowWithdraw(proxyAddr: string, loanId: string, amount: string, usr: string): Promise