Skip to content

Commit

Permalink
add maturity date
Browse files Browse the repository at this point in the history
  • Loading branch information
AStox committed Dec 6, 2023
1 parent 14016c9 commit ccd40d6
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
21 changes: 20 additions & 1 deletion tinlake-ui/components/CreateNFT/index.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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()

Expand Down Expand Up @@ -53,6 +59,7 @@ const CreateNFT: React.FC = () => {
tinlake.contractAddresses.ASSET_NFT!,
value,
riskGroup,
Math.floor(new Date(maturityDate).getTime() / 1000),
])
) as any

Expand Down Expand Up @@ -93,6 +100,18 @@ const CreateNFT: React.FC = () => {
disabled={isPending}
/>
</FormField>
{tinlake.contractAddresses['LEGACY_ACTIONS'] && (
<FormField label="Maturity Date">
<DateInput
value={maturityDate}
onChange={(event: any) => {
console.log(event.value)
setMaturityDate(event.value)
}}
disabled={isPending}
/>
</FormField>
)}
</Grid>
</>
)}
Expand Down
5 changes: 3 additions & 2 deletions tinlake-ui/services/tinlake/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -503,9 +503,10 @@ export async function proxyBorrowerMintIssuePrice(
minterAddress: string,
nftRegistryAddress: string,
price: string,
riskGroup: string
riskGroup: string,
maturityDate?: number
): Promise<PendingTransaction> {
return tinlake.proxyBorrowerMintIssuePrice(minterAddress, nftRegistryAddress, price, riskGroup)
return tinlake.proxyBorrowerMintIssuePrice(minterAddress, nftRegistryAddress, price, riskGroup, maturityDate)
}

export async function proxyTransferCurrency(
Expand Down
18 changes: 15 additions & 3 deletions tinlake.js/src/actions/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,27 @@ export function ProxyActions<ActionsBase extends Constructor<TinlakeParams>>(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 })
)
Expand Down Expand Up @@ -303,7 +314,8 @@ export type IProxyActions = {
minterAddress: string,
nftRegistryAddress: string,
price: string,
riskGroup: string
riskGroup: string,
maturityDate?: string
): Promise<PendingTransaction>
proxyTransferIssue(proxyAddr: string, nftRegistryAddr: string, tokenId: string): Promise<PendingTransaction>
proxyLockBorrowWithdraw(proxyAddr: string, loanId: string, amount: string, usr: string): Promise<PendingTransaction>
Expand Down

0 comments on commit ccd40d6

Please sign in to comment.