-
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
1 parent
65a7152
commit fbd4141
Showing
13 changed files
with
4,862 additions
and
219 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 |
---|---|---|
@@ -1,9 +1,5 @@ | ||
REACT_APP_SETJS_CONTROLLER=0xa4c8d221d8BB851f83aadd0223a8900A6921A349 | ||
REACT_APP_SETJS_SET_TOKEN_CREATOR_ADDRESS=0xeF72D3278dC3Eba6Dc2614965308d1435FFd748a | ||
REACT_APP_SETJS_BASIC_ISSUANCE_MODULE=0xd8EF3cACe8b4907117a45B0b125c68560532F94D | ||
REACT_APP_SETJS_DEBT_ISSUANCE_MODULE=0x39F024d621367C044BacE2bf0Fb15Fb3612eCB92 | ||
REACT_APP_SETJS_STREAMING_FEE_MODULE=0x08f866c74205617B6F3903EF481798EcED10cDEC | ||
REACT_APP_SETJS_TRADE_MODULE=0x90F765F63E7DC5aE97d6c576BF693FB6AF41C129 | ||
REACT_APP_SETJS_NAV_ISSUANCE_MODULE=0xaB9a964c6b95fA529CA7F27DAc1E7175821f2334 | ||
REACT_APP_SETJS_PROTOCOL_VIEWER=0x74391125304f1e4ce11bDb8aaAAABcF3A3Ae2f41 | ||
REACT_APP_SETJS_MASTER_ORACLE_ADDRESS=0xA60f9e1641747762aDE7FD5F881b90B691E92B0a | ||
REACT_APP_SETJS_CONTROLLER= | ||
REACT_APP_SETJS_SET_TOKEN_CREATOR_ADDRESS= | ||
REACT_APP_SETJS_BASIC_ISSUANCE_MODULE= | ||
REACT_APP_SETJS_DEBT_ISSUANCE_MODULE= | ||
REACT_APP_SETJS_STREAMING_FEE_MODULE= |
Large diffs are not rendered by default.
Oops, something went wrong.
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,26 +1,117 @@ | ||
import React from 'react'; | ||
import logo from './logo.svg'; | ||
import './App.css'; | ||
|
||
function App() { | ||
return ( | ||
<div className="App"> | ||
<header className="App-header"> | ||
<img src={logo} className="App-logo" alt="logo" /> | ||
<p> | ||
Edit <code>src/App.tsx</code> and save to reload. | ||
</p> | ||
<a | ||
className="App-link" | ||
href="https://reactjs.org" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
Learn React | ||
</a> | ||
</header> | ||
</div> | ||
); | ||
// src/App.js | ||
|
||
import React, {Component} from 'react'; | ||
import Set from "set.js"; | ||
import { | ||
basicIssuanceModuleAddress, | ||
controllerAddress, | ||
debtIssuanceModuleAddress, | ||
governanceModuleAddress, | ||
masterOracleAddress, | ||
navIssuanceModuleAddress, | ||
protocolViewerAddress, | ||
setTokenCreatorAddress, | ||
streamingFeeModuleAddress, | ||
tradeModuleAddress | ||
} from "./constants/ethContractAddresses"; | ||
import {infuraMainnetUrl} from "./constants/web3Providers"; | ||
import {defiPulseAddress, layerTwoAddress, metaverseAddress} from "./constants/tokens"; | ||
import {DisplaySet, Position} from "./classes/DisplaySet"; | ||
import SetList from "./components/SetList"; | ||
import tokenList from "./constants/ethereum.tokenlist.json" | ||
|
||
const Web3 = require('web3'); | ||
|
||
class App extends Component { | ||
|
||
web3: any; | ||
mainConfig: any; | ||
setToken: any; | ||
myAddress = '0xA817fDf9b769D2E74D12e8e28294eFa2c331B799'; | ||
tokenSets = [defiPulseAddress, metaverseAddress, layerTwoAddress]; | ||
displayedSets: DisplaySet[] = []; | ||
showSets = false; | ||
|
||
state = { | ||
setList: this.displayedSets | ||
} | ||
|
||
render() { | ||
return ( | ||
<SetList setList={this.state.setList}/> | ||
); | ||
} | ||
|
||
async componentDidMount() { | ||
await this.instantiateSetToken(); | ||
await this.mapSetDetailsToDisplaySets(); | ||
await this.setChildState(); | ||
} | ||
|
||
private async instantiateSetToken() { | ||
this.web3 = new Web3(infuraMainnetUrl); | ||
this.mainConfig = { | ||
web3Provider: this.web3.currentProvider, | ||
basicIssuanceModuleAddress: basicIssuanceModuleAddress, | ||
controllerAddress: controllerAddress, | ||
masterOracleAddress: masterOracleAddress, | ||
navIssuanceModuleAddress: navIssuanceModuleAddress, | ||
protocolViewerAddress: protocolViewerAddress, | ||
setTokenCreatorAddress: setTokenCreatorAddress, | ||
streamingFeeModuleAddress: streamingFeeModuleAddress, | ||
tradeModuleAddress: tradeModuleAddress, | ||
debtIssuanceModuleAddress: debtIssuanceModuleAddress, | ||
debtIssuanceModuleV2Address: debtIssuanceModuleAddress, | ||
governanceModuleAddress: governanceModuleAddress | ||
} | ||
this.setToken = new Set(this.mainConfig).setToken; | ||
} | ||
|
||
private async mapSetDetailsToDisplaySets() { | ||
for (const set of this.tokenSets) { | ||
|
||
await this.fetchSetDetails(set, this.myAddress).then(async res => { | ||
const positionAddresses: string[] = []; | ||
res.positions.forEach((pos: string[]) => { | ||
positionAddresses.push(pos[0]); | ||
}) | ||
const positionsObj = await this.fetchTokenPositionList(positionAddresses); | ||
this.displayedSets.push(new DisplaySet(res.name, res.symbol, set, positionsObj)); | ||
}); | ||
} | ||
console.log("finished mapping -> ", this.displayedSets); | ||
} | ||
|
||
private async setChildState() { | ||
this.setState({setList: this.displayedSets}); | ||
} | ||
|
||
private async fetchSetDetails(setAddress: string, callerAddress: string): Promise<any> { | ||
if (this.setToken) { | ||
const modules = await this.setToken.getModulesAsync(setAddress, callerAddress); | ||
return await this.setToken.fetchSetDetailsAsync(setAddress, modules, callerAddress); | ||
} | ||
} | ||
|
||
private async fetchTokenPositionList(positions: string[]) { | ||
|
||
const fullPositionList: any[] = []; | ||
|
||
// For each address, fetch the name and logo from a hashmap created from json file of coingecko tokens | ||
for (const address of positions) { | ||
const array = tokenList.tokens; | ||
const result = new Map<String, String>(array.map(obj => [obj.address.toLowerCase(), obj.name + '^' + obj.logoURI])); | ||
let mapEntryPosition = result.get(address.toLowerCase()); | ||
|
||
if (mapEntryPosition) { | ||
// To avoid complex multi-value map, both name and logo stored in value. extracted below: | ||
const name = mapEntryPosition.split('^')[0]; | ||
const logoURI = mapEntryPosition.split('^')[1]; | ||
fullPositionList.push(new Position(name, address.toLowerCase(), logoURI)); | ||
} | ||
} | ||
return fullPositionList; | ||
} | ||
} | ||
|
||
export default App; |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Set JS Contract Addresses - Mainnet | ||
export const controllerAddress = '0xa4c8d221d8BB851f83aadd0223a8900A6921A349'; | ||
export const setTokenCreatorAddress = '0xeF72D3278dC3Eba6Dc2614965308d1435FFd748a'; | ||
export const basicIssuanceModuleAddress = '0xd8EF3cACe8b4907117a45B0b125c68560532F94D'; | ||
export const debtIssuanceModuleAddress = '0x39F024d621367C044BacE2bf0Fb15Fb3612eCB92'; | ||
export const streamingFeeModuleAddress = '0x08f866c74205617B6F3903EF481798EcED10cDEC' | ||
export const tradeModuleAddress = '0x90F765F63E7DC5aE97d6c576BF693FB6AF41C129'; | ||
export const navIssuanceModuleAddress = '0xaB9a964c6b95fA529CA7F27DAc1E7175821f2334'; | ||
export const protocolViewerAddress = '0x74391125304f1e4ce11bDb8aaAAABcF3A3Ae2f41'; | ||
export const masterOracleAddress = '0xA60f9e1641747762aDE7FD5F881b90B691E92B0a'; | ||
export const governanceModuleAddress = 'x5C87b042494cDcebA44C541fbB3BC8bFF179d500'; | ||
|
||
// Set JS Contract Addresses - Kovan | ||
export const basicIssuanceModuleAddressTest = '0x8a070235a4B9b477655Bf4Eb65a1dB81051B3cC1'; | ||
export const controllerAddressTest = '0x9048278cA7e874F9338e4898C436Ab07AA454701'; | ||
export const masterOracleAddressTest = '0xDFEA02F2824Ee177733d6f108005E95C85D1D4bE'; | ||
export const navIssuanceModuleAddressTest = '0x5dB52450a8C0eb5e0B777D4e08d7A93dA5a9c848'; | ||
export const protocolViewerAddressTest = '0xbbC86C6099B148383941e8E592847fDC61a03283'; | ||
export const setTokenCreatorAddressTest = '0xB24F7367ee8efcB5EAbe4491B42fA222EC68d411'; | ||
export const streamingFeeModuleAddressTest = '0xE038E59DEEC8657d105B6a3Fb5040b3a6189Dd51'; | ||
export const tradeModuleAddressTest = '0xC93c8CDE0eDf4963ea1eea156099B285A945210a'; | ||
export const debtIssuanceModuleAddressTest = '0xe34031E7F4D8Ba4eFab190ce5f4D8451eD1B6A82'; | ||
export const debtIssuanceModuleV2AddressTest = '0xe34031E7F4D8Ba4eFab190ce5f4D8451eD1B6A82'; | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
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,3 @@ | ||
export const defiPulseAddress = '0x1494CA1F11D487c2bBe4543E90080AeBa4BA3C2b'; | ||
export const metaverseAddress = '0x72e364f2abdc788b7e918bc238b21f109cd634d7'; | ||
export const layerTwoAddress = '0x693391144D1e079e20cC64f795e9450C94966171'; |
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,3 @@ | ||
export const infuraMainnetUrl = 'https://mainnet.infura.io/v3/a195ae3eaf104a6c944903d74f668de9'; | ||
|
||
export const infuraKovanUrl = 'https://kovan.infura.io/v3/a195ae3eaf104a6c944903d74f668de9'; |
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
Oops, something went wrong.