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

Update/composables #421

Merged
merged 19 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
Binary file added apps/landing/.parcel-cache/444ef4bdec166956
Binary file not shown.
Binary file added apps/landing/.parcel-cache/data.mdb
Binary file not shown.
Binary file added apps/landing/.parcel-cache/lock.mdb
Binary file not shown.
1 change: 0 additions & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
},
"dependencies": {
"@heroicons/vue": "^1.0.6",
"@solana/web3.js": "^1.63.1",
"@walletconnect/sign-client": "^2.9.2",
"@walletconnect/types": "^2.9.2",
"@walletconnect/universal-provider": "^2.9.2",
Expand Down
24 changes: 0 additions & 24 deletions apps/web/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,30 +1,6 @@
<script lang="ts" setup>
import { RouterView } from 'vue-router'
import DefaultLayout from '@/layouts/default-layout.vue'
import useTxData from '@/mockData/mock_transaction_data'
import { onMounted, watch } from 'vue'
import useUsers from '@/composables/users'

const { mockData } = useTxData()
// Need this to fix initilizing bug between user.ts and ssv.ts
const { user } = useUsers()

const runMockData = () =>{
if(user.value?.accounts.length && user.value?.accounts.length > 0){
const walletAddresses = user.value?.accounts.map(item => {
return item.address
}) as string[]
mockData(walletAddresses)
}
}

watch(user, () =>{
runMockData()
})

onMounted(() => {
runMockData()
})
</script>

<template>
Expand Down
8 changes: 4 additions & 4 deletions apps/web/src/composables/auth.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import useEnvironment from '@/composables/environment'
import { LoginCredentials } from '@casimir/types'
import { SignInWithEthereumCredentials } from '@casimir/types'

const { domain, origin, usersUrl } = useEnvironment()

Expand Down Expand Up @@ -45,17 +45,17 @@ export default function useAuth() {
* Signs user up if they don't exist, otherwise
* logs the user in with an address, message, and signed message
*
* @param {LoginCredentials} loginCredentials - The user's address, provider, currency, message, and signed message
* @param {SignInWithEthereumCredentials} signInWithEthereumCredentials - The user's address, provider, currency, message, and signed message
* @returns {Promise<Response>} - The response from the login request
*/
async function signInWithEthereum(loginCredentials: LoginCredentials): Promise<void> {
async function signInWithEthereum(signInWithEthereumCredentials: SignInWithEthereumCredentials): Promise<void> {
try {
const requestOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(loginCredentials)
body: JSON.stringify(signInWithEthereumCredentials)
}
const response = await fetch(`${usersUrl}/auth/login`, requestOptions)
const { error, message } = await response.json()
Expand Down
28 changes: 28 additions & 0 deletions apps/web/src/composables/coldStorage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import useLedger from '@/composables/ledger'
import useTrezor from '@/composables/trezor'
import { Currency, ProviderString } from '@casimir/types'

export default function useWallet() {
const { getLedgerAddress } = useLedger()
const { getTrezorAddress } = useTrezor()

function getColdStorageAddress(provider: ProviderString, currency: Currency = 'ETH') {
ccali11 marked this conversation as resolved.
Show resolved Hide resolved
if (provider === 'Ledger') {
new Promise((resolve, reject) => {
resolve(getLedgerAddress[currency]())
})
} else if (provider === 'Trezor') {
new Promise((resolve, reject) => {
resolve(getTrezorAddress[currency]())
})
} else {
return new Promise((resolve, reject) => {
resolve('Cold storage provider not yet supported')
})
}
}

return {
getColdStorageAddress
}
}
Loading
Loading