-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
call a functions are 1(b), 3(a) and 3(b), and 5(a)
- Loading branch information
1 parent
a46b238
commit 999da52
Showing
4 changed files
with
267 additions
and
78 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
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
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 |
---|---|---|
@@ -1,6 +1,9 @@ | ||
|
||
import React, { useState } from 'react'; | ||
import './issue_form.css'; | ||
import { ethers } from 'ethers'; | ||
import VerifierdMarkets from '../out/VerifiedMarkets.sol/VerifiedMarkets.json'; | ||
|
||
const verifiedMarketsAddress = '0x90Cc254C549fEfD8b7a0C2514d93b487d9d234f3'; | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
const CurrencyOptions = ['USD', 'EUR', 'GBP']; // Add more currency options as needed | ||
|
||
|
@@ -12,9 +15,64 @@ const AssetIssuanceForm: React.FC = () => { | |
const [selectedCurrency, setSelectedCurrency] = useState(''); | ||
const [issuingDocument, setIssuingDocument] = useState<File | null>(null); | ||
|
||
const handleSubmit = (event: React.FormEvent) => { | ||
const handleSubmit = async (event: React.FormEvent) => { | ||
event.preventDefault(); | ||
|
||
// Handle form submission here | ||
|
||
if (!assetAddress || !collateralAddress || !faceValue || !apyOffered || !selectedCurrency || !issuingDocument) { | ||
return; | ||
} | ||
|
||
try { | ||
// Connect to MetaMask | ||
if (window.ethereum) { | ||
console.log('MetaMask detected...'); | ||
|
||
// Request accounts using ethereum.request | ||
await (window.ethereum as any).request({ method: 'eth_requestAccounts' }); | ||
|
||
// Provider and signer from MetaMask | ||
const provider = new ethers.providers.Web3Provider(window.ethereum); | ||
const signer = provider.getSigner(); | ||
|
||
// Create a contract instance | ||
const verifiedMarketsContract = new ethers.Contract(verifiedMarketsAddress, VerifierdMarkets.abi, signer); | ||
|
||
// Convert APY and face value to wei | ||
const _apy = ethers.utils.parseUnits((apyOffered / 100).toString(), 'ether'); | ||
const _faceValue = ethers.utils.parseUnits((faceValue / 100).toString(), 'ether'); | ||
|
||
console.log('Calling submitNewRWA function...'); | ||
|
||
// Call the submitNewRWA function | ||
const transaction = await verifiedMarketsContract.submitNewRWA(assetAddress, collateralAddress, _apy, issuingDocument, { gasLimit: 300000 }); | ||
This comment has been minimized.
Sorry, something went wrong.
kallolborah
Member
|
||
|
||
// '/doc/Verified_Compound_Markets_v1.pdf', // Replace with actual issuingDocs_faceValue, | ||
|
||
console.log('Transaction hash:', transaction.hash); | ||
|
||
// Wait for transaction confirmation | ||
await transaction.wait(); | ||
|
||
// Reset the form after successful submission | ||
setAssetAddress(''); | ||
setCollateralAddress(''); | ||
setFaceValue(''); | ||
setApyOffered(''); | ||
setSelectedCurrency(''); | ||
setIssuingDocument(null); | ||
|
||
console.log('Form submitted successfully'); | ||
} else { | ||
throw new Error('MetaMask not detected'); | ||
} | ||
} catch (error) { | ||
console.error('Error submitting form:', error); | ||
} | ||
|
||
|
||
|
||
}; | ||
|
||
return ( | ||
|
@@ -89,7 +147,7 @@ const AssetIssuanceForm: React.FC = () => { | |
/> | ||
</div> | ||
|
||
<button className ='button button--large button--supply'>Submit</button> | ||
<button className='button button--large button--supply' type='submit'>Submit</button> | ||
</form> | ||
</div> | ||
</div> | ||
|
Oops, something went wrong.
@vinaykumar0103
You should not hardcode contract addresses. In the SDK, the addresses are in /src/ContractAddress and are based on network wallet is connected to.