Skip to content

Commit

Permalink
bug fixes: cookie parsing. use prod auth wallet address for faucet.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonkernel committed Sep 11, 2022
1 parent 1d4b3bc commit 1dc23f2
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 7 deletions.
5 changes: 3 additions & 2 deletions packages/common/src/contexts/ServicesContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,11 @@ const handleMessage = (dispatch, messageEvent) => {
}

const group = (acc, e, i) => {
i % 2 === 0 ? acc[Math.floor(i / 2)] = [e] : acc[Math.floor(i / 2)].push(e)
const chunkIndex = Math.floor(i / 2)
i % 2 === 0 ? acc[chunkIndex] = [e] : acc[chunkIndex].push(e)
return acc
}
const cookies = (cookie) => Object.fromEntries(cookie.split('=').reduce(group))
const cookies = (cookie) => Object.fromEntries(cookie.split('=').reduce(group, []))

const hasCookie = () => document.cookie.includes(COOKIE_USER)
const fromCookie = () => JSON.parse(decodeURIComponent(cookies(document.cookie)[COOKIE_USER]))
Expand Down
2 changes: 2 additions & 0 deletions packages/wallet/.env.development
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
REACT_APP_DEPLOY_TARGET="STAGING"
REACT_APP_AUTH_WALLET_ADDRESS_DEV="0x77eCAb07c313315133F1971A9d4Fc199C499f363"
REACT_APP_AUTH_WALLET_ADDRESS_STAGING="0x77eCAb07c313315133F1971A9d4Fc199C499f363"
REACT_APP_AUTH_ENDPOINT_DEV="http://localhost:3001/auth/rpc"
REACT_APP_AUTH_ENDPOINT_STAGING="https://staging.services.kernel.community/auth/rpc"
REACT_APP_AUTH_URL_DEV="http://localhost:3003/auth"
Expand Down
2 changes: 2 additions & 0 deletions packages/wallet/.env.production
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
REACT_APP_AUTH_WALLET_ADDRESS_PROD="0xB59fB3D5E187E4B68F4370c14755c13275b21b0c"
REACT_APP_AUTH_WALLET_ADDRESS_STAGING="0x77eCAb07c313315133F1971A9d4Fc199C499f363"
REACT_APP_AUTH_ENDPOINT_PROD="https://services.kernel.community/auth/rpc"
REACT_APP_AUTH_ENDPOINT_STAGING="https://staging.services.kernel.community/auth/rpc"
REACT_APP_AUTH_URL_STAGING="https://staging.wallet.kernel.community/auth"
Expand Down
1 change: 0 additions & 1 deletion packages/wallet/src/App.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"minRole": 1000,
"logoUrl": "/icon-192x192.png",
"homeUrl": "/portal",
"servicesWallet": "0x77eCAb07c313315133F1971A9d4Fc199C499f363",
"navbar": {
"links": []
}
Expand Down
5 changes: 4 additions & 1 deletion packages/wallet/src/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const WALLET_STORE_VERSION = '1'

const env = process.env.REACT_APP_DEPLOY_TARGET || 'PROD'
const PROVIDER_ENDPOINT = process.env[`REACT_APP_PROVIDER_ENDPOINT_${env}`]
const AUTH_WALLET_ADDRESS = process.env[`REACT_APP_AUTH_WALLET_ADDRESS_${env}`]

const BLOCK_EXPLORER = {
1: 'https://etherscan.io',
Expand Down Expand Up @@ -61,4 +62,6 @@ const humanizeHash = (hash, n = 4) => hash ? `${hash.substr(0, n)}...${hash.subs

const blockExplorer = (chainId, hash) => `${BLOCK_EXPLORER[chainId]}/tx/${hash}`

export { loadWallet, defaultProvider, provider, voidSigner, humanizeEther, humanizeGwei, humanizeHash, blockExplorer }
export {
AUTH_WALLET_ADDRESS, loadWallet, defaultProvider, provider, voidSigner, humanizeEther, humanizeGwei, humanizeHash, blockExplorer
}
6 changes: 3 additions & 3 deletions packages/wallet/src/views/Claim.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useServices, linesVector } from '@kernel/common'

import AppConfig from 'App.config'

import { loadWallet, provider, voidSigner, humanizeEther } from 'common'
import { AUTH_WALLET_ADDRESS, loadWallet, provider, voidSigner, humanizeEther } from 'common'
import Page from 'components/Page'

const RINKEBY_CHAIN_ID = 4
Expand Down Expand Up @@ -87,7 +87,7 @@ const Claim = () => {
const rinkebyBalance = await rinkebySigner.getBalance()
dispatch({ type: 'rinkebyBalance', payload: rinkebyBalance })

const rinkebyFaucet = voidSigner(AppConfig.servicesWallet, rinkebyProvider)
const rinkebyFaucet = voidSigner(AUTH_WALLET_ADDRESS, rinkebyProvider)
const rinkebyFaucetBalance = await rinkebyFaucet.getBalance()
dispatch({ type: 'rinkebyFaucet', payload: rinkebyFaucetBalance })

Expand All @@ -99,7 +99,7 @@ const Claim = () => {
const goerliBalance = await goerliSigner.getBalance()
dispatch({ type: 'goerliBalance', payload: goerliBalance })

const goerliFaucet = voidSigner(AppConfig.servicesWallet, goerliProvider)
const goerliFaucet = voidSigner(AUTH_WALLET_ADDRESS, goerliProvider)
const goerliFaucetBalance = await goerliFaucet.getBalance()
dispatch({ type: 'goerliFaucet', payload: goerliFaucetBalance })
})()
Expand Down

0 comments on commit 1dc23f2

Please sign in to comment.