Skip to content

Commit

Permalink
Call functions
Browse files Browse the repository at this point in the history
call a functions are  1(b), 3(a) and 3(b), and 5(a)
  • Loading branch information
vinaykumar0103 committed Nov 16, 2023
1 parent a46b238 commit 999da52
Show file tree
Hide file tree
Showing 4 changed files with 267 additions and 78 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@

# Comet Extension for Verified Markets

The Verified Markets extension enables real world asset (RWA) owners and managers to borrow liquidity from the Compound protocol. It also enables Compound users to stake collateral for RWAs on Compound and benefit from additional returns that RWAs generate. The [Verified Markets specification is here](https://github.com/verified-network/verified-compound-markets/tree/master/docs/Verified_Compound_Markets_v1.pdf).
The Verified Markets extension enables real world asset (RWA) owners and managers to borrow liquidity from the Compound protocol. It also enables Compound users to stake collateral for RWAs on Compound and benefit from additional returns that RWAs generate. The [Verified Markets specification is here](https://github.com/verified-network/verified-compound-markets/tree/master/docs/Verified_Compound_Markets_v1.pdf).

The operator code is built on [Foundry](https://book.getfoundry.sh/), and the web extension code is built on [React](https://reactjs.org/) using [Vite](https://vitejs.dev/).

## Getting Started

First, [install Foundry](https://book.getfoundry.sh/getting-started/installation) and NodeJS 18+ and [yarn](https://yarnpkg.com/).
First, [install Foundry](https://book.getfoundry.sh/getting-started/installation) and NodeJS 18+ and [yarn](https://yarnpkg.com/).

You can build this Compound Extension's operator by running:

Expand Down Expand Up @@ -47,9 +46,9 @@ This should spawn a web server at an address such as http://localhost:5183. Visi

A few notes:

* Any changes to web source code should auto-reload.
* If you want to change the smart contract code, you'll need to kill and restart `yarn forge:playground`.
* The standalone development experience is not the primary usage of the extension. See [Webb3](https://github.com/compound-finance/webb3) for details on running as an embedded extension.
- Any changes to web source code should auto-reload.
- If you want to change the smart contract code, you'll need to kill and restart `yarn forge:playground`.
- The standalone development experience is not the primary usage of the extension. See [Webb3](https://github.com/compound-finance/webb3) for details on running as an embedded extension.

To run this in embedded mode (see Embedding below), you should run the following command in Webb3:

Expand Down Expand Up @@ -81,6 +80,8 @@ export RPC_URL="https://goerli.infura.io/v3/<your infura key>"
export ETHEREUM_PK="<your private key with 0x preceding it>"
```

forge verify-contract

Next, you can deploy it to goerli:

```sh
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,22 @@
"@ethersproject/experimental": "^5.5.0",
"@ethersproject/providers": "^5.7.0",
"@ethersproject/units": "^5.4.0",
"@verified-network/verified-sdk": "^1.3.3",
"@web3-react/core": "8.0.35-beta.0",
"@web3-react/metamask": "8.0.28-beta.0",
"@web3-react/network": "8.0.27-beta.0",
"@web3-react/types": "8.0.20-beta.0",
"@web3-react/url": "8.0.25-beta.0",
"axios": "^1.6.1",
"comet": "https://github.com/compound-finance/comet.git#c54ccc62e06186bdf237048ac7c9f3ce34d813b4",
"compound-config": "https://github.com/compound-finance/compound-config.git#0815f079ebe6c7421361b3334f7b8eaab50722b0",
"compound-styles": "https://github.com/compound-finance/compound-styles.git#fc29b8a832c698920f2fcf7a06d978c4580a48e1",
"dotenv": "^16.3.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.15.0",
"rollup-plugin-polyfill-node": "^0.10.2"
"rollup-plugin-polyfill-node": "^0.10.2",
"web3modal": "^1.9.12"
},
"devDependencies": {
"@testing-library/jest-dom": "^5.16.2",
Expand Down
64 changes: 61 additions & 3 deletions web/issue_form.tsx
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';

Check failure on line 4 in web/issue_form.tsx

View workflow job for this annotation

GitHub Actions / Build

Cannot find module '../out/VerifiedMarkets.sol/VerifiedMarkets.json' or its corresponding type declarations.

const verifiedMarketsAddress = '0x90Cc254C549fEfD8b7a0C2514d93b487d9d234f3';

This comment has been minimized.

Copy link
@kallolborah

kallolborah Nov 19, 2023

Member

@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.


const CurrencyOptions = ['USD', 'EUR', 'GBP']; // Add more currency options as needed

Expand All @@ -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.

Copy link
@kallolborah

kallolborah Nov 19, 2023

Member

@vinaykumar0103

When RWA asset details are submitted, the bond issue request is first made. This is the first call of the sequence here.


// '/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 (
Expand Down Expand Up @@ -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>
Expand Down

0 comments on commit 999da52

Please sign in to comment.