Skip to content

Commit

Permalink
Merge pull request #510 from persistenceOne/redirect-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
blackpanther1881 authored Jan 16, 2024
2 parents bd3cee9 + 73a1c1a commit 6c76f23
Show file tree
Hide file tree
Showing 3 changed files with 167 additions and 98 deletions.
182 changes: 109 additions & 73 deletions .github/workflows/staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,93 +5,129 @@ name: Staging

on:
push:
branches: [ main ]
branches: [main]
jobs:
testnet:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [ 16.x ]
node-version: [16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: git config --global url."https://github.com/".insteadOf ssh://git@github.com/
- run: npm ci
- run: npm run build --if-present
env:
CI: false
REACT_APP_API_KEY: 'https://rest.testnet2.persistence.one'
REACT_APP_TENDERMINT_RPC_ENDPOINT: 'https://rpc.testnet2.persistence.one'
REACT_APP_WEBSITE_URL: 'https://test-core-1.wallet.persistence.one'
REACT_APP_EXPLORER_API: 'https://testnet.mintscan.io/persistence-testnet'
REACT_APP_MAIL_CHIMP_URL: 'https://one.us17.list-manage.com/subscribe/post?u=fd70c7f5c39a43acbedb49253&id=7f8e2dbc48'
REACT_APP_CHAIN_ID: 'test-core-2'
REACT_APP_CHAIN_NAME: 'Persistence Testnet'
REACT_APP_IBC_CONFIG: 'ibcStaging.json'
REACT_APP_GA_TRACKING_ID: 'UA-219210130-1'
REACT_APP_SENTRY_API: ''
- name: Upload to IPFS
uses: aquiladev/ipfs-action@v0.3.1
with:
path: ./build
service: pinata
pinataKey: ${{ secrets.PINATA_API_KEY }}
pinataSecret: ${{ secrets.PINATA_API_SECRET }}
pinName: pWallet ${{ github.event.release.name }} - Testnet Staging
- name: Publish
uses: cloudflare/wrangler-action@1.3.0
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
environment: 'testnet-staging'

- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: git config --global url."https://github.com/".insteadOf ssh://git@github.com/
- run: npm ci
- run: npm run build:ipfs --if-present
env:
CI: false
REACT_APP_API_KEY: "https://rest.testnet2.persistence.one"
REACT_APP_TENDERMINT_RPC_ENDPOINT: "https://rpc.testnet2.persistence.one"
REACT_APP_WEBSITE_URL: "https://test-core-1.wallet.persistence.one"
REACT_APP_EXPLORER_API: "https://testnet.mintscan.io/persistence-testnet"
REACT_APP_MAIL_CHIMP_URL: "https://one.us17.list-manage.com/subscribe/post?u=fd70c7f5c39a43acbedb49253&id=7f8e2dbc48"
REACT_APP_CHAIN_ID: "test-core-2"
REACT_APP_CHAIN_NAME: "Persistence Testnet"
REACT_APP_IBC_CONFIG: "ibcStaging.json"
REACT_APP_GA_TRACKING_ID: "UA-219210130-1"
REACT_APP_SENTRY_API: ""
REACT_APP_IPFS: true
- name: Upload to IPFS
id: ipfs-build
uses: aquiladev/ipfs-action@v0.3.1
with:
path: ./build
service: pinata
pinataKey: ${{ secrets.PINATA_API_KEY }}
pinataSecret: ${{ secrets.PINATA_API_SECRET }}
pinName: pWallet ${{ github.event.release.name }} - Testnet Staging
- name: Delete IPFS Build
if: steps.ipfs-build.outcome == 'success'
run: rm -rf ./build
- run: npm run build --if-present
env:
CI: false
REACT_APP_API_KEY: "https://rest.testnet2.persistence.one"
REACT_APP_TENDERMINT_RPC_ENDPOINT: "https://rpc.testnet2.persistence.one"
REACT_APP_WEBSITE_URL: "https://test-core-1.wallet.persistence.one"
REACT_APP_EXPLORER_API: "https://testnet.mintscan.io/persistence-testnet"
REACT_APP_MAIL_CHIMP_URL: "https://one.us17.list-manage.com/subscribe/post?u=fd70c7f5c39a43acbedb49253&id=7f8e2dbc48"
REACT_APP_CHAIN_ID: "test-core-2"
REACT_APP_CHAIN_NAME: "Persistence Testnet"
REACT_APP_IBC_CONFIG: "ibcStaging.json"
REACT_APP_GA_TRACKING_ID: "UA-219210130-1"
REACT_APP_SENTRY_API: ""
REACT_APP_IPFS: false
- name: Publish
uses: cloudflare/wrangler-action@1.3.0
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
environment: "testnet-staging"

mainnet:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 16.x ]
node-version: [16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: git config --global url."https://github.com/".insteadOf ssh://git@github.com/
- run: npm ci
- run: npm run build --if-present
env:
CI: false
REACT_APP_API_KEY: 'https://rest.core.persistence.one'
REACT_APP_TENDERMINT_RPC_ENDPOINT: 'https://rpc.core.persistence.one'
REACT_APP_WEBSITE_URL: 'https://staging.wallet.persistence.one'
REACT_APP_EXPLORER_API: 'https://www.mintscan.io/persistence'
REACT_APP_MAIL_CHIMP_URL: 'https://one.us17.list-manage.com/subscribe/post?u=fd70c7f5c39a43acbedb49253&id=7f8e2dbc48'
REACT_APP_CHAIN_ID: 'core-1'
REACT_APP_CHAIN_NAME: 'Persistence'
REACT_APP_IBC_CONFIG: 'ibcMainnet.json'
REACT_APP_GA_TRACKING_ID: 'UA-219210130-1'
REACT_APP_SENTRY_API: 'https://a31c61f5ce774e0791ffdc3b830b406c@o1083089.ingest.sentry.io/6092403'
- name: Upload to IPFS
uses: aquiladev/ipfs-action@v0.3.1
with:
path: ./build
service: pinata
pinataKey: ${{ secrets.PINATA_API_KEY }}
pinataSecret: ${{ secrets.PINATA_API_SECRET }}
pinName: pWallet ${{ github.event.release.name }} - Mainnet Staging
- name: Publish
uses: cloudflare/wrangler-action@1.3.0
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
environment: 'mainnet-staging'
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: git config --global url."https://github.com/".insteadOf ssh://git@github.com/
- run: npm ci
- run: npm run build:ipfs --if-present
env:
CI: false
REACT_APP_API_KEY: "https://rest.core.persistence.one"
REACT_APP_TENDERMINT_RPC_ENDPOINT: "https://rpc.core.persistence.one"
REACT_APP_WEBSITE_URL: "https://staging.wallet.persistence.one"
REACT_APP_EXPLORER_API: "https://www.mintscan.io/persistence"
REACT_APP_MAIL_CHIMP_URL: "https://one.us17.list-manage.com/subscribe/post?u=fd70c7f5c39a43acbedb49253&id=7f8e2dbc48"
REACT_APP_CHAIN_ID: "core-1"
REACT_APP_CHAIN_NAME: "Persistence"
REACT_APP_IBC_CONFIG: "ibcMainnet.json"
REACT_APP_GA_TRACKING_ID: "UA-219210130-1"
REACT_APP_SENTRY_API: "https://a31c61f5ce774e0791ffdc3b830b406c@o1083089.ingest.sentry.io/6092403"
REACT_APP_IPFS: true
- name: Upload to IPFS
id: ipfs-build
uses: aquiladev/ipfs-action@v0.3.1
with:
path: ./build
service: pinata
pinataKey: ${{ secrets.PINATA_API_KEY }}
pinataSecret: ${{ secrets.PINATA_API_SECRET }}
pinName: pWallet ${{ github.event.release.name }} - Mainnet Staging
- name: Delete IPFS Build
if: steps.ipfs-build.outcome == 'success'
run: rm -rf ./build
- run: npm run build --if-present
env:
CI: false
REACT_APP_API_KEY: "https://rest.testnet2.persistence.one"
REACT_APP_TENDERMINT_RPC_ENDPOINT: "https://rpc.testnet2.persistence.one"
REACT_APP_WEBSITE_URL: "https://test-core-1.wallet.persistence.one"
REACT_APP_EXPLORER_API: "https://testnet.mintscan.io/persistence-testnet"
REACT_APP_MAIL_CHIMP_URL: "https://one.us17.list-manage.com/subscribe/post?u=fd70c7f5c39a43acbedb49253&id=7f8e2dbc48"
REACT_APP_CHAIN_ID: "test-core-2"
REACT_APP_CHAIN_NAME: "Persistence Testnet"
REACT_APP_IBC_CONFIG: "ibcStaging.json"
REACT_APP_GA_TRACKING_ID: "UA-219210130-1"
REACT_APP_SENTRY_API: ""
REACT_APP_IPFS: false
- name: Publish
uses: cloudflare/wrangler-action@1.3.0
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
environment: "mainnet-staging"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "pwallet",
"version": "3.1.1",
"private": true,
"homepage": ".",
"dependencies": {
"@cosmjs/crypto": "^0.31.1",
"@cosmjs/encoding": "^0.31.1",
Expand Down Expand Up @@ -64,6 +63,7 @@
},
"scripts": {
"start": "react-app-rewired start",
"build:ipfs": "PUBLIC_URL=. react-app-rewired build",
"build": "react-app-rewired build",
"test": "react-app-rewired test",
"eject": "react-app-rewired eject"
Expand Down
81 changes: 57 additions & 24 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useEffect, useState } from "react";
import { useEffect, useState } from "react";
import {
HashRouter,
Redirect,
Route,
Switch,
useHistory,
Expand Down Expand Up @@ -81,13 +80,7 @@ const Main = () => {
address = loginInfo && loginInfo.address;
const page = location.pathname;

useEffect(() => {
if (window.location.pathname === "/dashboard/wallet") {
window.location.replace("/#/dashboard/wallet");
} else if (window.location.pathname === "/dashboard/staking") {
window.location.replace("/#/dashboard/staking");
}
}, []);
const isIpfs = process.env.REACT_APP_IPFS === "true";

useEffect(() => {
const fetchApi = async () => {
Expand Down Expand Up @@ -174,21 +167,48 @@ const Main = () => {
) : (
""
)}
<HashRouter>
{isIpfs ? (
<HashRouter>
<Switch>
<Route
key="/"
exact
component={
JSON.parse(window.localStorage.getItem(LOGIN_INFO)) === null ||
address === undefined ||
address === null ||
address === ""
? withRouter(Homepage)
: withRouter(DashboardWallet)
}
path="/"
/>
{routes.map((route) => {
if (route.private) {
return (
<PrivateRoute
key={route.path}
exact
component={withRouter(route.component)}
path={route.path}
/>
);
}

return (
<Route
key={route.path}
exact
component={withRouter(route.component)}
path={route.path}
/>
);
})}
<Route component={RouteNotFound} />
</Switch>
</HashRouter>
) : (
<Switch>
<Route
key="/"
exact
component={
JSON.parse(window.localStorage.getItem(LOGIN_INFO)) === null ||
address === undefined ||
address === null ||
address === ""
? withRouter(Homepage)
: withRouter(DashboardWallet)
}
path="/"
/>
{routes.map((route) => {
if (route.private) {
return (
Expand All @@ -210,9 +230,22 @@ const Main = () => {
/>
);
})}
<Route
key="/"
exact
component={
JSON.parse(window.localStorage.getItem(LOGIN_INFO)) === null ||
address === undefined ||
address === null ||
address === ""
? withRouter(Homepage)
: withRouter(DashboardWallet)
}
path="/"
/>
<Route component={RouteNotFound} />
</Switch>
</HashRouter>
)}
<ModalTerms />
</>
);
Expand Down

0 comments on commit 6c76f23

Please sign in to comment.