Skip to content

Commit

Permalink
updated unlock environment selection by package.json parameters, adde…
Browse files Browse the repository at this point in the history
…d instructions in README
  • Loading branch information
edsonayllon committed Dec 13, 2019
1 parent 595316b commit c1f1908
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 12 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,18 @@ yarn start

**Test creating a event locally**

Event creation is has a paywall by Unlock. Unlock currently only supports Rinkeby and Mainnet. Using Kovan with your wallet will cause an error.

Rinkeby or Mainnet for Unlock is chosen with `package.json` scripts. Using `yarn build:release:` will select either Rinkeby or Mainnet depending on the script you use. These scripts are found in `package.json`.

Using `yarn build` will select Mainnet for Unlock. Using `yarn start` will select Rinkeby for unlock. These can be overwritten by entering a network with your start script. `REACT_APP_ENV=live yarn start` will have Unlock use Mainnet, and `REACT_APP_ENV=rinkeby yarn build` will have Unlock use Rinkeby.

If `env.json` sets `ENV` to `local`, no paywall will be shown.

After the app starts with an envirnoment chosen for unlock:

- Go to http://localhost:3000/create
- Display form by paying for a membership tier (must be Rinkeby or Mainnet)
- Fill in event detail (leave password as blank)
- Fill in event detail and press "Submit"

Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@
"seedParty": "node scripts/seedParty.js",
"start": "react-scripts start",
"build": "react-scripts build",
"build:release:kovan": "yarn setup --kovan && yarn build",
"build:release:ropsten": "yarn setup --ropsten && yarn build",
"build:release:rinkeby": "yarn setup --rinkeby && yarn build",
"build:release:alpha": "yarn setup --alpha && yarn build",
"build:release:live": "yarn setup --live && yarn build",
"build:release:kovan": "REACT_APP_ENV=kovan yarn setup --kovan && yarn build",
"build:release:ropsten": "REACT_APP_ENV=ropsten yarn setup --ropsten && yarn build",
"build:release:rinkeby": "REACT_APP_ENV=rinkeby yarn setup --rinkeby && yarn build",
"build:release:alpha": "REACT_APP_ENV=alpha yarn setup --alpha && yarn build",
"build:release:live": "REACT_APP_ENV=live yarn setup --live && 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",
Expand Down
25 changes: 19 additions & 6 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,15 @@
https://github.com/unlock-protocol/react-example/blob/master/public/index.html
-->
<script> (function (d, s) {
// if production, set network to Mainnet, else set to Rinkeby for paywall
const environment = "%NODE_ENV%";
const networkId = environment === "production" ? 1 : 4;
// set network based on start scripts environment variables
const nodeEnv = "%NODE_ENV%";
const ethEnv = "%REACT_APP_ENV%";
const networkId = (ethEnv.includes("REACT_APP_ENV") && nodeEnv === "production") ? 1
: (ethEnv.includes("REACT_APP_ENV") && nodeEnv !== "production") ? 4
: ethEnv === "rinkeby" ? 4
// : ethEnv === "kovan" ? 42 // include kovan when supported by unlock paywall
: ethEnv === "live" ? 1
: 4;

// if Rinkeby set, use Rinkeby paywall, else use Mainnet
let testnetUrl = networkId === 4 ? 'staging-' : '';
Expand All @@ -78,13 +84,20 @@
</script>

<script>
// if production, set network to Mainnet, else set to Rinkeby for paywall
const environment = "%NODE_ENV%";
const networkId = environment === "production" ? 1 : 4;
// set network based on start scripts environment variables
const nodeEnv = "%NODE_ENV%";
const ethEnv = "%REACT_APP_ENV%";
const networkId = (ethEnv.includes("REACT_APP_ENV") && nodeEnv === "production") ? 1
: (ethEnv.includes("REACT_APP_ENV") && nodeEnv !== "production") ? 4
: ethEnv === "rinkeby" ? 4
// : ethEnv === "kovan" ? 42 // include kovan when supported by unlock paywall
: ethEnv === "live" ? 1
: 4;

/*
Kovan is included, but currently only Rinkeby and Mainnet is supported with paywall
tokens entered first to last are displayed right to left in paywall modal
Kovan lock is included for when kovan is supported by Unlock paywall
NOTE: Replace Mainnet keys with keys Kickback owns
*/
const locks = {
Expand Down
1 change: 0 additions & 1 deletion src/routes/CreateEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export default function Create() {
}

useEffect(() => {
console.log(ENV)
if (ENV !== 'local') {
window.addEventListener('unlockProtocol', unlockHandler)
} else {
Expand Down

0 comments on commit c1f1908

Please sign in to comment.