Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promote develop to master #313

Merged
merged 40 commits into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
4565a2e
Connect v1 smart contract interface with auth flow
ccali11 Apr 6, 2023
2a5beb1
Complete responsiveness on analytics and stake cards
DemogorGod Apr 10, 2023
d87b300
Add table layout
DemogorGod Apr 10, 2023
3358c59
Move PoR aggregator feed to automation contract
shanejearley Apr 10, 2023
179297a
Log checkData and performData in upkeep functions
shanejearley Apr 10, 2023
bee265c
Add logic to the tabel in DataTable component
DemogorGod Apr 10, 2023
86f80d2
Fix performData encode/decode test
shanejearley Apr 10, 2023
bd77052
Point automation at PoR in contract diagram
shanejearley Apr 10, 2023
a9de238
Fix automation contract reference in table
shanejearley Apr 10, 2023
c5aa361
Add add responsiveness to tabe in DataTable component
DemogorGod Apr 10, 2023
3451404
Fix merge conflicts with develop
ccali11 Apr 10, 2023
0efd4ab
Add mock aggregator to local deploy
shanejearley Apr 10, 2023
76e09c9
Add auth check in router
ccali11 Apr 10, 2023
0ee9db3
Default connectWallet currency to ETH
ccali11 Apr 10, 2023
2d74d04
Handle undefined user in default-layout componenet
ccali11 Apr 10, 2023
44d86c3
Fix auth bugs and multi-wallet modal
DemogorGod Apr 11, 2023
fb79a26
Merge pull request #312 from consensusnetworks/new-app-design
DemogorGod Apr 11, 2023
c899642
Nest and update @casimir/ethereum README
Apr 11, 2023
d994f19
Add emojis to @casimir/ethereum sections for readability
Apr 11, 2023
eab7daa
Implement the following:
ccali11 Apr 11, 2023
2d67b7b
Remove a few console.logs
ccali11 Apr 11, 2023
fe4061e
Stub getLedgerBalance before fixing transport error
ccali11 Apr 11, 2023
b3581cc
Consolidate getting balance for all providers to use ethersjs
ccali11 Apr 11, 2023
8cdbd44
Fix ledger and trezor emulators
shanejearley Apr 11, 2023
c8828d3
Add detail to @casimir/ethereum overview
Apr 12, 2023
ccfdca8
Update note on internal and external contracts
shanejearley Apr 12, 2023
ace649f
Update operator sections
Apr 12, 2023
8a09bb5
Add functions client
shanejearley Apr 12, 2023
6d12d44
Logout user on new browser session (router.ts)
ccali11 Apr 12, 2023
38d0832
Get and set user account balances
ccali11 Apr 12, 2023
47887ee
Move external contracts to specified directory
shanejearley Apr 12, 2023
253df28
Sync docgen
shanejearley Apr 12, 2023
74f36a4
Resolve conflicts
shanejearley Apr 12, 2023
1867e42
Merge pull request #316 from consensusnetworks/feature/automation
shanejearley Apr 12, 2023
febd732
Fix balance formating on the front-end
DemogorGod Apr 12, 2023
1f1676f
Fix top multi-wallet modalissue with accessing primary wallet
DemogorGod Apr 12, 2023
ee14ec0
Add `/:pathMatch(.*)*` to the possible routes to reroute to dashboard
DemogorGod Apr 12, 2023
6d9375b
Change CASIMIR_MANAGER_ADDRESS var to PUBLIC_CASIMIR_MANAGER
shanejearley Apr 12, 2023
23b3e1a
Resolve conflicts
shanejearley Apr 12, 2023
e9a3de5
Merge pull request #315 from consensusnetworks/feature/get-balances
ccali11 Apr 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ npm run dev
| `--clean` | Whether to clean the local database | true | --clean=false |
| `--emulate` | Whether to use local wallet emulators | false | --emulate=ethereum |
| `--fork` | Which live Ethereum network to fork locally | goerli | --fork=mainnet |
| `--mock` | Whether to mock services | true | --mock=false |
| `--mock` | Whether to mock backend services and external contracts | true | --mock=false |
| `--network` | Which live Ethereum network to use | goerli | --network=mainnet |
| `--simulation` | Whether to run contract simulation fixture | false | --simulation |

**Example commands:**

Expand Down
25 changes: 21 additions & 4 deletions apps/web/src/components/charts/LineChartJS.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ onMounted(() => {
label : 'Net Value',
borderColor : '#C1D3F8',
fill: false,
tension: 0.4,
}]
},
options : {
responsive: true,
responsive: false,
maintainAspectRatio: false,
plugins: {
legend: {
display: props.legend,
Expand Down Expand Up @@ -75,14 +75,31 @@ onMounted(() => {
}
}
})

const line_chart_container_el = document.getElementById('line_chart_container_' + props.id)
let WIDTH = 0
let HEIGHT = 0

// watches for size changes...
const outputsize = () => {
if(line_chart_container_el){
WIDTH = line_chart_container_el.offsetWidth
HEIGHT = line_chart_container_el.offsetHeight
}
chart.value.resize(WIDTH -20 , HEIGHT)
}
if(line_chart_container_el){
new ResizeObserver(outputsize).observe(line_chart_container_el)
}
})
</script>

<template>
<div>
<div
class="h-full w-full px-10"
>
<canvas
:id="props.id"
class="w-full h-full"
/>
</div>
</template>
23 changes: 6 additions & 17 deletions apps/web/src/composables/ethers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import { ethers } from 'ethers'
import { BrowserProviders, EthersProvider, MessageInit, TransactionInit } from '@/interfaces/index'
import { Currency, ProviderString } from '@casimir/types'
import useAuth from '@/composables/auth'
import useEnvironment from '@/composables/environment'

const { getMessage, login } = useAuth()
const { ethereumURL } = useEnvironment()

const defaultProviders = {
MetaMask: undefined,
Expand All @@ -25,23 +27,10 @@ export default function useEthers() {
}
}

// TODO: Identify the difference beteween the two functions below (requestEthersBalance and getEthersBalance)
async function requestEthersBalance(provider: EthersProvider, address: string) {
if (provider?.request) {
return await provider.request({
method: 'eth_getBalance',
params: [address, 'latest'],
})
}
}

async function getEthersBalance(providerString: ProviderString, address: string, ) {
const provider = availableProviders.value[providerString as keyof BrowserProviders]
if (provider) {
const balance = await requestEthersBalance(provider as EthersProvider, address)
console.log('balance :>> ', balance)
return ethers.utils.formatEther(balance)
}
async function getEthersBalance(address: string, ) {
const provider = new ethers.providers.JsonRpcProvider(ethereumURL)
const balance = await provider.getBalance(address)
return ethers.utils.formatEther(balance)
}

function getEthersBrowserSigner(providerString: ProviderString): ethers.Signer | undefined {
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/composables/ledger.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { BitcoinLedgerSigner, EthersLedgerSigner } from '@casimir/wallets'
import { EthersProvider } from '@/interfaces/index'
import { ethers } from 'ethers'
import { MessageInit, TransactionInit } from '@/interfaces/index'
import { Currency, ProviderString } from '@casimir/types'
Expand Down
30 changes: 30 additions & 0 deletions apps/web/src/composables/router.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { createWebHistory, createRouter } from 'vue-router'
import useWallet from '@/composables/wallet'
import useUsers from '@/composables/users'

/* eslint-disable @typescript-eslint/ban-ts-comment */
import Dashboard from '@/pages/dashboard/Dashboard.vue'
Expand All @@ -16,6 +18,11 @@ const routes = [
name: Auth,
component: Auth,
},
{
path: '/:pathMatch(.*)*',
name: Dashboard,
component: Dashboard,
},
{
path: '/test',
name: Test,
Expand All @@ -32,4 +39,27 @@ const router = createRouter({
// TO DO: Add a routing beforeEach that
// dynamically fixes rerouting to auth page

router.beforeEach(async (to, from, next) => {
if (import.meta.env.DEV) {
const appLaunched = sessionStorage.getItem('appLaunch')
if (!appLaunched) {
const { logout } = useWallet()
await logout()
sessionStorage.setItem('appLaunch', 'true')
}
}

const { checkUserSessionExists } = useUsers()
const loggedIn = await checkUserSessionExists()
if (to.fullPath === '/auth' && !loggedIn) {
next()
} else if (to.fullPath === '/auth' && loggedIn) {
next('/')
} else if (!loggedIn) {
next('/auth')
} else {
next()
}
})

export default router
4 changes: 2 additions & 2 deletions apps/web/src/composables/ssv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ export default function useSSV() {

if (!casimirManager) {
casimirManager = (() => {
const address = import.meta.env.PUBLIC_SSV_MANAGER
const address = import.meta.env.PUBLIC_CASIMIR_MANAGER
if (!address) console.log(
`
The PUBLIC_SSV_MANAGER environment variable is empty.\n
The PUBLIC_CASIMIR_MANAGER environment variable is empty.\n
If you are on mainnet or testnet, the contract does not exist yet.\n
If you are on the local network, check your terminal logs for a contract address or errors.
`
Expand Down
34 changes: 33 additions & 1 deletion apps/web/src/composables/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import useUsers from '@/composables/users'
import { Account, ProviderString, Currency } from '@casimir/types'
import { MessageInit, TransactionInit } from '@/interfaces/index'
import * as Session from 'supertokens-web-js/recipe/session'
import router from './router'

// Test ethereum send to address : 0xD4e5faa8aD7d499Aa03BDDE2a3116E66bc8F8203
// Test ethereum send to address : 0xd557a5745d4560B24D36A68b52351ffF9c86A212
Expand Down Expand Up @@ -75,7 +76,7 @@ export default function useWallet() {
* @param currency
* @returns
*/
async function connectWallet(provider: ProviderString, currency?: Currency) {
async function connectWallet(provider: ProviderString, currency: Currency = 'ETH') {
try { // Sign Up or Login
if (!user?.value?.address) {
const connectedAddress = await getConnectedAddressFromProvider(provider, currency) as string
Expand All @@ -89,6 +90,8 @@ export default function useWallet() {
setSelectedCurrency(connectedCurrency)
primaryAddress.value = user?.value?.address as string
}
loadingUserWallets.value = false
router.push('/')
} else { // Add account
console.log('already logged in')
const connectedAddress = await getConnectedAddressFromProvider(provider, currency) as string
Expand Down Expand Up @@ -117,9 +120,11 @@ export default function useWallet() {
setSelectedAddress(connectedAddress)
setSelectedCurrency(connectedCurrency)
primaryAddress.value = user?.value?.address as string
router.push('/')
}
}
}
await setUserAccountBalances()
console.log('user.value after connecting wallet :>> ', user.value)
return user.value
} catch (error) {
Expand Down Expand Up @@ -176,6 +181,31 @@ export default function useWallet() {
}
}

async function getAccountBalance(account: Account) {
// TODO: Find where api endpoint is configured for ethers.
try {
const balance = await getEthersBalance(account.address)
return balance
} catch (err) {
console.error('There was an error in getAccountBalance :>> ', err)
}
}

async function setUserAccountBalances() {
if (user?.value?.accounts) {
const accounts = user.value.accounts
const accountsWithBalances = await Promise.all(accounts.map(async (account: Account) => {
const balance = await getAccountBalance(account)
return {
...account,
balance
}
}))
user.value.accounts = accountsWithBalances
setUser(user.value)
}
}

// TODO: What is this used for?
// Do we need balance of active address only?
// Or do we need balance of all addresses in accounts associated with user?
Expand Down Expand Up @@ -219,6 +249,7 @@ export default function useWallet() {
primaryAddress.value = ''
console.log('user.value on logout :>> ', user.value)
loadingUserWallets.value = false
router.push('/auth')
}

async function removeConnectedAccount() {
Expand Down Expand Up @@ -361,6 +392,7 @@ export default function useWallet() {
getUserBalance,
removeConnectedAccount,
sendTransaction,
setUserAccountBalances,
setPrimaryWalletAccount,
signMessage,
switchNetwork
Expand Down
38 changes: 29 additions & 9 deletions apps/web/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,8 @@ background: #555;
.switch {
position: relative;
display: inline-block;
width: 45px;
height: 20px;
width: 36px;
height: 16px;
}

.switch input {
Expand All @@ -432,10 +432,9 @@ background: #555;
.slider:before {
position: absolute;
content: "";
height: 12px;
width: 12px;
height: 10px;
width: 10px;
left: 4px;
bottom: 4px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
Expand All @@ -450,20 +449,41 @@ background: #555;
}

input:checked + .slider:before {
-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);
transform: translateX(26px);
-webkit-transform: translateX(18px);
-ms-transform: translateX(18px);
transform: translateX(18px);
}

.slider.round {
border-radius: 34px;
border-radius: 100px;
}

.slider.round:before {
border-radius: 50%;
}
}
@layer utilities {
.animate_up {
animation: up 0.25s ease-in-out;
}

@keyframes up {
from {transform: translateY(+100%); opacity: 0;}
to { transform: translateY(0); opacity: 1;}
}

.slide_escape-enter-active, .slide_escape-leave-active {
opacity: 1;
transition: all .25s;
}
.slide_escape-enter, .slide_escape-leave-to {
animation: down 0.25s ease-in-out;
transition: all .25s;
}
@keyframes down {
from {transform: translateY(0%); opacity: 1;}
to { transform: translateY(+100%); opacity: 0;}
}
.two_thirds_one_third_grid_to_full{
display: grid;
grid-template-columns: 2fr 1fr;
Expand Down
Loading