Skip to content

Commit

Permalink
Polygon support (#422)
Browse files Browse the repository at this point in the history
* Add configs for polygon

* Point to polygon contracts

* Add now config

* Do not hard code 1 gwei

* hardcode polygon

* Update README

* Parse ipfs avatar

* Fix  overlay bug on mobile

* Wait calling participant list until logged in

* Fix z-index on mobile dropdown and onboard popup

* Fix POAP checkin

* Fix deploy command

* Add default snapshot image

* Fix error of not showing votes with multiple choices

* Updata onboardjs and change walletconnect setting (#420)

* Bump version to 1.2.0
  • Loading branch information
makoto authored Aug 14, 2021
1 parent 8e1f989 commit a7771a8
Show file tree
Hide file tree
Showing 21 changed files with 1,777 additions and 479 deletions.
28 changes: 28 additions & 0 deletions .deploy/now.polygon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"version": 2,
"scope": "wearekickback",
"builds": [
{ "src": "build/**", "use": "@now/static" },
{ "src": "api/**", "use": "@now/node" }
],
"routes": [
{ "src": "/", "dest": "build/index.html" },
{ "src": "/gettingstarted", "dest": "build/index.html" },
{ "src": "/faq", "dest": "build/index.html" },
{ "src": "/team", "dest": "build/index.html" },
{ "src": "/terms", "dest": "build/index.html" },
{ "src": "/privacy", "dest": "build/index.html" },
{ "src": "/pricing", "dest": "build/index.html" },
{ "src": "/create/?", "dest": "build/index.html" },
{ "src": "/deploy/?", "dest": "build/index.html" },
{ "src": "/events/?", "dest": "build/index.html" },
{ "src": "/event/.+", "dest": "api/event.js" },
{ "src": "/user/.+", "dest": "build/index.html" },
{
"src": "/service-worker.js",
"dest": "build/service-worker.js",
"headers": { "cache-control": "no-cache" }
},
{ "src": "/(.+)", "dest": "build/$1" }
]
}
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v10.18.1
v14.17.0
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,15 @@ vercel login
vercel switch wearekickback
vercel -f --local-config .deploy/now.xdai.json --public --prod
```

## Deploying to Polygon env manually



```
vercel login
vercel switch wearekickback
// 1. Make sure .vercel/project.json points to Polygon project
yarn build:release:polygon
vercel -f --local-config .deploy/now.polygon.json --public --prod
```
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "app",
"version": "1.1.0",
"version": "1.2.0",
"private": true,
"dependencies": {
"@emotion/core": "^10.0.27",
"@emotion/styled": "^10.0.27",
"@ensdomains/ens-contracts": "^0.0.3",
"@wearekickback/contracts": "npm:@wearekickback/contracts-integration@1.4.5",
"@wearekickback/contracts": "1.4.6",
"@wearekickback/shared": "^1.14.1",
"apollo-cache-inmemory": "^1.2.8",
"apollo-client": "^2.4.0",
Expand All @@ -15,7 +15,7 @@
"apollo-link-state": "^0.4.1",
"apollo-upload-client": "^10.0.0",
"apollo-utilities": "^1.0.21",
"bnc-onboard": "^1.25.0",
"bnc-onboard": "^1.34.1",
"decimal.js": "^10.0.1",
"es6-promisify": "^6.0.0",
"ethereum-event-logs": "^1.0.2",
Expand Down Expand Up @@ -70,14 +70,16 @@
"build:release:alpha": "yarn setup --alpha && yarn build",
"build:release:live": "yarn setup --live && yarn build",
"build:release:xdai": "yarn setup --xdai && yarn build",
"build:release:polygon": "yarn setup --polygon && yarn build",
"deploy:ropsten": "yarn build:release:ropsten && yarn now -f --local-config .deploy/now.ropsten.json --public && yarn now alias --local-config .deploy/now.ropsten.json && yarn now rm kickback-app-ropsten --safe --yes",
"deploy:rinkeby": "yarn build:release:rinkeby && yarn now -f --local-config .deploy/now.rinkeby.json --public && yarn now alias --local-config .deploy/now.rinkeby.json && yarn now rm kickback-app-rinkeby --safe --yes",
"deploy:kovan": "yarn build:release:kovan && yarn now -f --local-config .deploy/now.kovan.json --public && yarn now alias --local-config .deploy/now.kovan.json && yarn now rm kickback-app-kovan --safe --yes",
"deploy:alpha": "yarn build:release:alpha && yarn now -f --local-config .deploy/now.alpha.json --public && yarn now alias --local-config .deploy/now.alpha.json && yarn now rm kickback-app-alpha --safe --yes",
"deploy:live": "yarn build:release:live && yarn now -f --local-config .deploy/now.live.json --public && yarn now alias --local-config .deploy/now.live.json && yarn now rm kickback-app-live --safe --yes",
"deploy:xdai": "yarn build:release:xdai && yarn now -f --local-config .deploy/now.xdai.json --public && yarn now alias --local-config .deploy/now.xdai.json && yarn now rm kickback-app-xdai --safe --yes",
"deploy:polygon": "yarn build:release:polygon && vercel -f --local-config .deploy/now.xdai.json --public --prod",
"deploy:dev": "yarn deploy:rinkeby",
"deploy:branch": "/bin/sh -c 'if [ \"$TRAVIS_BRANCH\" = \"master\" ]; then yarn deploy:xdai; elif [ \"$TRAVIS_BRANCH\" = \"dev\" ]; then yarn deploy:dev; fi'",
"deploy:branch": "/bin/sh -c 'if [ \"$TRAVIS_BRANCH\" = \"master\" ]; then yarn deploy:polygon; elif [ \"$TRAVIS_BRANCH\" = \"dev\" ]; then yarn deploy:dev; fi'",
"deploy:pr": "yarn build:release:rinkeby && scripts/deployTravisBuildToSurge.sh",
"deploy": "/bin/sh -c 'if [ \"$TRAVIS_PULL_REQUEST\" = \"false\" ]; then yarn deploy:branch; else yarn deploy:pr; fi'",
"precommit": "lint-staged",
Expand Down
150 changes: 82 additions & 68 deletions scripts/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,74 +30,88 @@ appConfig.API_URL = 'http://localhost:3001'
if (undefined === appConfig.NUM_CONFIRMATIONS) {
appConfig.NUM_CONFIRMATIONS = 1
}

if (argv.ropsten) {
appConfig.ENV = 'ropsten'
appConfig.API_URL = 'https://kickback-ropsten.herokuapp.com'
appConfig.GIT_COMMIT = getGitCommit()
appConfig.ROLLBAR_TOKEN = '37e0bca9006a4a348e244ae2d233d660'
appConfig.BLOCKNATIVE_DAPPID = '18cb2fa0-5941-43a2-b71d-07221c15a50f'
appConfig.INFURA_KEY = 'cd1ba006128543a0a11d23e54efaab93'
appConfig.FORTMATIC_KEY = 'pk_test_D3CAA2AEFE6A022E'
appConfig.PORTIS_KEY = '0ae69aa0-2a4e-41b2-a312-4aa2de69626e'
appConfig.SQUARELINK_KEY = '7918e26f77908d911fac'
} else if (argv.rinkeby) {
appConfig.ENV = 'rinkeby'
appConfig.API_URL = 'https://kickback-rinkeby.herokuapp.com'
appConfig.GIT_COMMIT = getGitCommit()
appConfig.ROLLBAR_TOKEN = 'e676d64e462b48d098a12db8a173598a'
appConfig.BLOCKNATIVE_DAPPID = '27b3eac2-e46c-428a-9a0c-56cce2725d42'
appConfig.INFURA_KEY = 'cd1ba006128543a0a11d23e54efaab93'
appConfig.FORTMATIC_KEY = 'pk_test_D3CAA2AEFE6A022E'
appConfig.PORTIS_KEY = '0ae69aa0-2a4e-41b2-a312-4aa2de69626e'
appConfig.SQUARELINK_KEY = '7918e26f77908d911fac'
} else if (argv.kovan) {
appConfig.ENV = 'kovan'
appConfig.API_URL = 'https://kickback-kovan.herokuapp.com'
appConfig.GIT_COMMIT = getGitCommit()
appConfig.ROLLBAR_TOKEN = ''
appConfig.BLOCKNATIVE_DAPPID = ''
appConfig.INFURA_KEY = 'cd1ba006128543a0a11d23e54efaab93'
appConfig.FORTMATIC_KEY = 'pk_test_D3CAA2AEFE6A022E'
appConfig.PORTIS_KEY = '0ae69aa0-2a4e-41b2-a312-4aa2de69626e'
appConfig.SQUARELINK_KEY = '7918e26f77908d911fac'
} else if (argv.alpha) {
appConfig.ENV = 'alpha'
appConfig.API_URL = 'https://kickback-alpha.herokuapp.com'
appConfig.GIT_COMMIT = getGitCommit()
appConfig.ROLLBAR_TOKEN = ''
appConfig.BLOCKNATIVE_DAPPID = ''
appConfig.INFURA_KEY = 'cd1ba006128543a0a11d23e54efaab93'
appConfig.FORTMATIC_KEY = 'pk_test_D3CAA2AEFE6A022E'
appConfig.PORTIS_KEY = '0ae69aa0-2a4e-41b2-a312-4aa2de69626e'
appConfig.SQUARELINK_KEY = '7918e26f77908d911fac'
} else if (argv.xdai) {
appConfig.ENV = 'xdai'
appConfig.API_URL = 'https://kickback-xdai.herokuapp.com'
appConfig.GIT_COMMIT = getGitCommit()
appConfig.ROLLBAR_TOKEN = ''
appConfig.BLOCKNATIVE_DAPPID = ''
appConfig.INFURA_KEY = 'cd1ba006128543a0a11d23e54efaab93'
appConfig.FORTMATIC_KEY = 'pk_test_D3CAA2AEFE6A022E'
appConfig.PORTIS_KEY = '0ae69aa0-2a4e-41b2-a312-4aa2de69626e'
appConfig.SQUARELINK_KEY = '7918e26f77908d911fac'
appConfig.PLATFORM_FEE_ADDRESS = '0xeC34bf8f41BC951071A501502e1E60Af0cC9f9d6'
} else if (argv.live) {
appConfig.ENV = 'live'
appConfig.API_URL = 'https://kickback-live.herokuapp.com'
appConfig.GIT_COMMIT = getGitCommit()
appConfig.MIXPANEL_ID = '11a2f7a59470cdb46cb611c5d22876f2'
appConfig.LOGROCKET_TOKEN = '5gnafo/kickback-live'
appConfig.ROLLBAR_TOKEN = 'bfb8dfff7ff44f6fa6a13d4571447c28'
appConfig.BLOCKNATIVE_DAPPID = '612ef703-3041-442c-b246-cf68604b8ce9'
appConfig.INFURA_KEY = 'cd1ba006128543a0a11d23e54efaab93'
appConfig.FORTMATIC_KEY = 'pk_live_34FA001C997028B0'
appConfig.PORTIS_KEY = '0ae69aa0-2a4e-41b2-a312-4aa2de69626e'
appConfig.SQUARELINK_KEY = '7918e26f77908d911fac'
} else {
// local
appConfig.PLATFORM_FEE_ADDRESS = '0x4ef57faD87Ce46e3f63C8F6B7A1ACB987e9140Fe' // Some random address
}
// Hardcode polygon
// if (argv.ropsten) {
// appConfig.ENV = 'ropsten'
// appConfig.API_URL = 'https://kickback-ropsten.herokuapp.com'
// appConfig.GIT_COMMIT = getGitCommit()
// appConfig.ROLLBAR_TOKEN = '37e0bca9006a4a348e244ae2d233d660'
// appConfig.BLOCKNATIVE_DAPPID = '18cb2fa0-5941-43a2-b71d-07221c15a50f'
// appConfig.INFURA_KEY = 'cd1ba006128543a0a11d23e54efaab93'
// appConfig.FORTMATIC_KEY = 'pk_test_D3CAA2AEFE6A022E'
// appConfig.PORTIS_KEY = '0ae69aa0-2a4e-41b2-a312-4aa2de69626e'
// appConfig.SQUARELINK_KEY = '7918e26f77908d911fac'
// } else if (argv.rinkeby) {
// appConfig.ENV = 'rinkeby'
// appConfig.API_URL = 'https://kickback-rinkeby.herokuapp.com'
// appConfig.GIT_COMMIT = getGitCommit()
// appConfig.ROLLBAR_TOKEN = 'e676d64e462b48d098a12db8a173598a'
// appConfig.BLOCKNATIVE_DAPPID = '27b3eac2-e46c-428a-9a0c-56cce2725d42'
// appConfig.INFURA_KEY = 'cd1ba006128543a0a11d23e54efaab93'
// appConfig.FORTMATIC_KEY = 'pk_test_D3CAA2AEFE6A022E'
// appConfig.PORTIS_KEY = '0ae69aa0-2a4e-41b2-a312-4aa2de69626e'
// appConfig.SQUARELINK_KEY = '7918e26f77908d911fac'
// } else if (argv.kovan) {
// appConfig.ENV = 'kovan'
// appConfig.API_URL = 'https://kickback-kovan.herokuapp.com'
// appConfig.GIT_COMMIT = getGitCommit()
// appConfig.ROLLBAR_TOKEN = ''
// appConfig.BLOCKNATIVE_DAPPID = ''
// appConfig.INFURA_KEY = 'cd1ba006128543a0a11d23e54efaab93'
// appConfig.FORTMATIC_KEY = 'pk_test_D3CAA2AEFE6A022E'
// appConfig.PORTIS_KEY = '0ae69aa0-2a4e-41b2-a312-4aa2de69626e'
// appConfig.SQUARELINK_KEY = '7918e26f77908d911fac'
// } else if (argv.alpha) {
// appConfig.ENV = 'alpha'
// appConfig.API_URL = 'https://kickback-alpha.herokuapp.com'
// appConfig.GIT_COMMIT = getGitCommit()
// appConfig.ROLLBAR_TOKEN = ''
// appConfig.BLOCKNATIVE_DAPPID = ''
// appConfig.INFURA_KEY = 'cd1ba006128543a0a11d23e54efaab93'
// appConfig.FORTMATIC_KEY = 'pk_test_D3CAA2AEFE6A022E'
// appConfig.PORTIS_KEY = '0ae69aa0-2a4e-41b2-a312-4aa2de69626e'
// appConfig.SQUARELINK_KEY = '7918e26f77908d911fac'
// } else if (argv.xdai) {
// appConfig.ENV = 'xdai'
// appConfig.API_URL = 'https://kickback-xdai.herokuapp.com'
// appConfig.GIT_COMMIT = getGitCommit()
// appConfig.ROLLBAR_TOKEN = ''
// appConfig.BLOCKNATIVE_DAPPID = ''
// appConfig.INFURA_KEY = 'cd1ba006128543a0a11d23e54efaab93'
// appConfig.FORTMATIC_KEY = 'pk_test_D3CAA2AEFE6A022E'
// appConfig.PORTIS_KEY = '0ae69aa0-2a4e-41b2-a312-4aa2de69626e'
// appConfig.SQUARELINK_KEY = '7918e26f77908d911fac'
// appConfig.PLATFORM_FEE_ADDRESS = '0xeC34bf8f41BC951071A501502e1E60Af0cC9f9d6'
// appConfig.NETWORK_NAME = 'xdai'
// } else if (argv.polygon) {
appConfig.ENV = 'polygon'
appConfig.API_URL = 'https://kickback-polygon.herokuapp.com'
appConfig.GIT_COMMIT = getGitCommit()
appConfig.ROLLBAR_TOKEN = ''
appConfig.BLOCKNATIVE_DAPPID = ''
appConfig.INFURA_KEY = '3f0f6038f2614a7994fb48b7031e22ad'
appConfig.FORTMATIC_KEY = 'pk_test_D3CAA2AEFE6A022E'
appConfig.PORTIS_KEY = '0ae69aa0-2a4e-41b2-a312-4aa2de69626e'
appConfig.SQUARELINK_KEY = '7918e26f77908d911fac'
appConfig.PLATFORM_FEE_ADDRESS = ''
appConfig.NETWORK_NAME = 'polygon-mainnet'
// } else if (argv.live) {
// appConfig.ENV = 'live'
// appConfig.API_URL = 'https://kickback-live.herokuapp.com'
// appConfig.GIT_COMMIT = getGitCommit()
// appConfig.MIXPANEL_ID = '11a2f7a59470cdb46cb611c5d22876f2'
// appConfig.LOGROCKET_TOKEN = '5gnafo/kickback-live'
// appConfig.ROLLBAR_TOKEN = 'bfb8dfff7ff44f6fa6a13d4571447c28'
// appConfig.BLOCKNATIVE_DAPPID = '612ef703-3041-442c-b246-cf68604b8ce9'
// appConfig.INFURA_KEY = 'cd1ba006128543a0a11d23e54efaab93'
// appConfig.FORTMATIC_KEY = 'pk_live_34FA001C997028B0'
// appConfig.PORTIS_KEY = '0ae69aa0-2a4e-41b2-a312-4aa2de69626e'
// appConfig.SQUARELINK_KEY = '7918e26f77908d911fac'
// appConfig.NETWORK_NAME = 'mainnet'
// } else {
// // local
// appConfig.PLATFORM_FEE_ADDRESS = '0x4ef57faD87Ce46e3f63C8F6B7A1ACB987e9140Fe' // Some random address
// }
console.log('***appConfig', { appConfig })
const str = JSON.stringify(appConfig, null, 2)
console.log(str)
Expand Down
17 changes: 11 additions & 6 deletions src/GlobalState.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {
BLOCKNATIVE_DAPPID,
INFURA_KEY,
FORTMATIC_KEY,
PORTIS_KEY
PORTIS_KEY,
NETWORK_NAME
// SQUARELINK_KEY
} from './config'
import { identify as logRocketIdentify } from './api/logRocket'
Expand Down Expand Up @@ -44,9 +45,7 @@ const TOKEN_SECRET = 'kickback'
const TOKEN_ALGORITHM = 'HS256'

const walletChecks = [{ checkName: 'connect' }, { checkName: 'network' }]

const wallets = [
{ walletName: 'authereum', preferred: true },
{ walletName: 'coinbase', preferred: true },
{
walletName: 'fortmatic',
Expand All @@ -69,10 +68,13 @@ const wallets = [
preferred: true
},
{ walletName: 'trust', preferred: true },
{ walletName: 'unilogin', preferred: true },
{
walletName: 'walletConnect',
infuraKey: INFURA_KEY,
rpc: {
'1': `https://mainnet.infura.io/v3/${INFURA_KEY}`,
'137': `https://polygon-mainnet.infura.io/v3/${INFURA_KEY}`,
'100': 'https://dai.poa.network'
},
preferred: true
}
// Disabled as it throws an error message
Expand Down Expand Up @@ -114,18 +116,21 @@ class Provider extends Component {
}

let { onboard } = this.state
console.log({ networkId, NETWORK_NAME })

if (!onboard) {
// dappid is mandatory so will have throw away id for local usage.
let testid = 'c212885d-e81d-416f-ac37-06d9ad2cf5af'
onboard = Onboard({
dappId: BLOCKNATIVE_DAPPID || testid,
networkId: parseInt(networkId),
networkName: NETWORK_NAME,
walletCheck: walletChecks,
walletSelect: {
heading: 'Select a wallet to connect to Kickback',
description:
'To use Kickback you need an Ethereum wallet. Please select one from below:',
wallets: wallets
wallets
}
})
this.setState({ onboard })
Expand Down
8 changes: 4 additions & 4 deletions src/api/resolvers/singleEventResolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ const getOption = async args => {
const option = {
from: account
}
// TODO: Do this only for xDai.
if (true) {
option.gasPrice = 1000000000 // 1gwei
}
// TODO: Do this only for xDai/Polygon.
// if (true) {
// option.gasPrice = 1000000000 // 1gwei
// }
return {
...option,
...args
Expand Down
4 changes: 4 additions & 0 deletions src/api/rootResolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ const resolvers = {
__typename: event.event
}))
},
async poapEventName(_, { eventId }) {
let response = await fetch(`https://api.poap.xyz/events/id/${eventId}`)
return response.json()
},
async poapBadges(_, { userAddress }) {
let response = await fetch(
`https://api.poap.xyz/actions/scan/${userAddress}`
Expand Down
10 changes: 10 additions & 0 deletions src/api/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,13 @@ export function lazyAsync(getter) {
return promise
}
}

export const parseAvatar = url => {
const ipfs = url.match(/^ipfs:\/\/(.*)/)
if (ipfs) {
const cid = ipfs[1]
return `https://ipfs.io/ipfs/${cid}`
} else {
return url
}
}
1 change: 1 addition & 0 deletions src/components/Header/HamburgerMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const HamburgerMenuContainer = styled('div')`
color: white;
padding: 10px 0;
}
z-index: 2;
`

function HamburgerMenu({ isMenuOpen }) {
Expand Down
2 changes: 2 additions & 0 deletions src/components/Links/EtherScanLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ const EtherScanLink = ({ address, tx, children }) => (
'1' === expectedNetworkId ? '' : `${expectedNetworkName.toLowerCase()}.`
if (expectedNetworkId === '100') {
host = `https://blockscout.com/poa/xdai`
} else if (expectedNetworkId === '137') {
host = `https://polygonscan.com`
} else {
host = `https://${prefix}etherscan.io`
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Modal/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const ModalContainer = styled('div')`
display: flex;
justify-content: center;
align-items: center;
z-index: 2;
z-index: 3;
`

const ModalContent = styled('div')`
Expand Down
Loading

0 comments on commit a7771a8

Please sign in to comment.