Skip to content

Commit

Permalink
Update stage environments (#461)
Browse files Browse the repository at this point in the history
This is a pull request that upon merging will update stage environments
with recent `main` changes.
  • Loading branch information
jagodarybacka authored Oct 20, 2023
2 parents d6b8789 + 4c76dee commit 938eb9a
Show file tree
Hide file tree
Showing 14 changed files with 286 additions and 61 deletions.
1 change: 1 addition & 0 deletions .env.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ ALLOW_TENDERLY_RESET="false"
SEASON_LENGTH_IN_WEEKS=8
CONTRACT_DEPLOYMENT_BLOCK_NUMBER=553443
SKIP_REACT_STRICT_MODE="false"
IS_COMING_SOON="true"
41 changes: 41 additions & 0 deletions .github/workflows/update-environments.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Update staging and production environments

on:
push:
branches:
- main
- stage-live

jobs:
sync-main-to-stage-live:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Open/update a PR from `main` to `stage-live`
id: pull
uses: tretuna/[email protected]
with:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
FROM_BRANCH: "main"
TO_BRANCH: "stage-live"
PULL_REQUEST_TITLE: "Update stage environments"
PULL_REQUEST_BODY: "This is a pull request that upon merging will update stage environments with recent `main` changes."
REVIEWERS: '["andreachapman"]'
sync-stage-live-to-release:
if: github.ref == 'refs/heads/stage-live'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Open/update a PR from `main` to `stage-live`
id: pull
uses: tretuna/[email protected]
with:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
FROM_BRANCH: "stage-live"
TO_BRANCH: "release"
PULL_REQUEST_TITLE: "Update release branch"
PULL_REQUEST_BODY: "This is a pull request that upon merging will update production environment with recent `stage-live` changes."
TEAM_REVIEWERS: '["tahowallet/extension-devs"]'
46 changes: 3 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,47 +12,7 @@
```
3. Open [http://localhost:9000](http://localhost:9000) to view it in the browser.

## Working with locally forked Arbitrum Sepolia chain
## Docs

### In the dapp:

- Override `USE_LOCALHOST_FORK="true"` in `.env` file.
- Run the dapp

### In the [extension](https://github.com/tahowallet/extension):

- Install extension due to readme
- Change `.env` variables
```bash
# Forking Arbitrum Sepolia
USE_MAINNET_FORK=true
MAINNET_FORK_CHAIN_ID="421614"
CHAIN_API_URL="https://sepolia-rollup.arbitrum.io/rpc"
```
- Restart extension's process
- Install extension as usual in the browser
- In the wallet let's import the account from the private key of the `testertesting.eth`
- Based on the Taho token's contract address (see `deployment-info.json` in the dapp or contracts repository) add the Taho asset to the wallet
### In the [contracts](https://github.com/tahowallet/contracts):
Instruction based on [the system tests readme](https://github.com/tahowallet/contracts/blob/main/system-tests/README.md)
- Install contracts
- `nvm use`
- `yarn install`
- Provide [`.envrc`](https://github.com/tahowallet/contracts/blob/main/system-tests/.envrc.SAMPLE) variables, make sure you have [Direnv](https://direnv.net/) installed
```bash
export FORKING_URL="https://sepolia-rollup.arbitrum.io/rpc"
export TAHO_DEPLOYER_PRIVATE_KEY="..." # mnemonic or first private key from `testertesting.eth`
export FORKING_BLOCK="..." # historical block; optional - setting this var enables cache and speeds up repatable read operations
```
- Open first terminal and run `yarn run test:fork`
---
After all the steps above you should have:
- the Taho token deployed on the Arbitrum Sepolia forked chain
- the dapp should be able to interact with the token
- the extension should be able to display the token's balance
- [Local environment setup](docs/local-env-setup.md)
- [Testing environment](docs/testing-env.md)
44 changes: 44 additions & 0 deletions docs/local-env-setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Working with locally forked Arbitrum Sepolia chain

### In the dapp:

- Override `USE_LOCALHOST_FORK="true"` in `.env` file.
- Run the dapp

### In the [extension](https://github.com/tahowallet/extension):

- Install extension due to readme
- Change `.env` variables
```bash
# Forking Arbitrum Sepolia
USE_MAINNET_FORK=true
MAINNET_FORK_CHAIN_ID="421614"
CHAIN_API_URL="https://sepolia-rollup.arbitrum.io/rpc"
```
- Restart extension's process
- Install extension as usual in the browser
- In the wallet let's import the account from the private key of the `testertesting.eth`
- Based on the Taho token's contract address (see `deployment-info.json` in the dapp or contracts repository) add the Taho asset to the wallet

### In the [contracts](https://github.com/tahowallet/contracts):

Instruction based on [the system tests readme](https://github.com/tahowallet/contracts/blob/main/system-tests/README.md)

- Install contracts
- `nvm use`
- `yarn install`
- Provide [`.envrc`](https://github.com/tahowallet/contracts/blob/main/system-tests/.envrc.SAMPLE) variables, make sure you have [Direnv](https://direnv.net/) installed
```bash
export FORKING_URL="https://sepolia-rollup.arbitrum.io/rpc"
export TAHO_DEPLOYER_PRIVATE_KEY="..." # mnemonic or first private key from `testertesting.eth`
export FORKING_BLOCK="..." # historical block; optional - setting this var enables cache and speeds up repatable read operations
```
- Open first terminal and run `yarn run test:fork`

---

After all the steps above you should have:

- the Taho token deployed on the Arbitrum Sepolia forked chain
- the dapp should be able to interact with the token
- the extension should be able to display the token's balance
82 changes: 82 additions & 0 deletions docs/testing-env.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Development to Production Flow

### Branches

- `main`
- branch `main` is the base branch for current developement
- every feature branch should be merged into `main` via pull request
- `stage-live`
- base for running the staging environment that is running on the live chain
- stage-live website is building based on the current status of the branch `stage-live`
- changes from `main` should be merged into the `stage-live` in batches using PR
- person QAing stage environment should be the one to accept and merge the PR - merging the PR means the staging environment will rebuild and manual tests can be started
- `stage-fork`
- state of the branch `stage-fork` should be always the same as `stage-live`
- base for building the staging environment that is running on the chain fork
- stage-fork website is building based on the current status of the branch `stage-fork`
- changes on `stage-live` should be auto-merged to the `stage-fork` by the Github Action
- accepting the PR to `stage-live` means stage-fork website will rebuild as well as stage-live website
- `release`
- changes from `stage-live` branch should be opening the PR to `release` branch
- batch of changes from the PR should be tested manually on staging environments and then PR to release should be accepted and merged by QA
- production environment is building based on the current status of the branch `release`

### Environments

- [app](https://app.taho.xyz/) or [release](https://release--taho-development.netlify.app/) - production env based on branch `release`
- [stage fork](https://stage-fork--taho-development.netlify.app/) - staging env based on branch `stage-fork`
- running on Tenderly fork of Arbitrum
- can reset the fork by clicking a few times in the logo
- to be used together with special build of the Taho wallet
- [stage live](https://stage-live--taho-development.netlify.app/) - staging env based on branch `stage-live`
- running on live chain
- to be used with production version of the Taho wallet
- [main](https://main--taho-development.netlify.app/) - development build based on `main`
- no need to do QA here
- running on chain fork
- can be used to preview most recent development

### Hotfix flow

If production needs a quick fix then:

- create a feature branch from `main`
- fix it as usual, merge back to `main`
- cherry-pick the fix to separate branch
- create a separate PR to `stage-live`
- merge it so fix will be added to the current batch of chages from staging env
- QA on staging
- merge PR `stage-live -> release`


```mermaid
---
title: "Dapp Lifecycle"
---
flowchart
609277{"main\nbranch"} -->|"Auto PR"| 140433{"stage-live \nbranch\n"}
style 609277 fill:#8fe465
style 140433 fill:#64e3db
609277 -->|"Hotfix PR"| 140433
linkStyle 1 stroke:#dc2a2a
609277 <-->|"PR"| 788810{"feature\nbranch"}
linkStyle 2 stroke:#f103d0
style 788810 fill:#64e3db
788810 -->|"Auto deploy"| 588961(("PR-preview"))
style 588961 fill:#e3c464
140433 -->|"Auto deploy"| 836305(("stage-fork\n"))
style 836305 fill:#e3c464
809682{"stage-fork\nbranch"} -->|"Auto deploy"| 490721(("stage-live\n"))
style 809682 fill:#64e3db
style 490721 fill:#e36464
804724{"release\nbranch"} -->|"Auto deploy"| 389165(("app.taho.xyz"))
style 804724 fill:#8fe465
style 389165 fill:#e36464
140433 -->|"Auto PR\n"| 804724
140433 -->|"Auto merge"| 809682
%% Mermaid Flow Diagram Link
%% Keep this link to make future edits to your diagram
%% https://www.mermaidflow.app/flowchart#N4IgZgNg9g7iBcoB2UAmBTAzgg2qGAlqgC4AWCAjAAwBsANCKegQOanGUAsAnA0QiBpVuAJgDsYkAwAOUTAWIEoSBKAAeCUQDoKADk4ia3Gof3cAzLxABPBGICsVLUZG7dl+-ZH2KAXwaoAIbEgaogEIEARugQAgC2gQRIADp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OEcOYVkbIhAakbG-TETIhSNh1g8CWD8zzQMBqxQDxIVSORsjcBHih5arcAGDFxbRdgEAfCZBxAACyGygQ3QUekKYw9aAgAAKgAEIchgBtITBYHBC1phCKDEAzLdDoEsCYHAQkEKCrBaguzrwdzazgzZDHDn4TACEMBuwmhbACFDDS5qCP7EBKJZAxAADyZm8AP6DALA0AkQGwEKMUJB2aoAqApwGwVWSQ6ABhZCwk-ADABytBBalhNEA24hkI8UAgguj2yuWhUAOhEA7UjhDBUOziVCSYLh0A6Q7hVAUR0RHIOh2QHQbBvSRSAAwq4REQyIYoPAwJEPFBgOkKkeEZEdEVEbEbkckiQaQAQPEWKpgBlF2v+M8GCvgZgEwClkSEAA
```
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"crypto-browserify": "^3.12.0",
"emittery": "^1.0.1",
"ethers": "^5",
"@ethersproject/networks": "^5.7.1",
"gifler": "^0.1.0",
"https-browserify": "^1.0.0",
"konva": "^9.2.0",
Expand Down Expand Up @@ -71,6 +72,7 @@
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"babel-loader": "^9.1.3",
"copy-webpack-plugin": "^11.0.0",
"dotenv-defaults": "^5.0.2",
"dotenv-webpack": "^8.0.1",
"eslint": "^8.44.0",
Expand Down
2 changes: 1 addition & 1 deletion src/shared/components/Modals/OnboardingModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default function OnboardingModal({
<style jsx>{`
.label {
font: var(--text-h1);
margin-bottom: 24px;
margin-bottom: ${buttonLabel ? "24px" : "0"};
}
`}</style>
</>
Expand Down
39 changes: 36 additions & 3 deletions src/shared/hooks/wallets.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useConnectWallet } from "@web3-onboard/react"
import { useCallback, useEffect, useMemo, useState } from "react"
import { ethers } from "ethers"
import { ethers, logger } from "ethers"
import {
useDappDispatch,
connectWalletGlobally,
Expand All @@ -17,14 +17,43 @@ import {
BALANCE_UPDATE_INTERVAL,
LOCAL_STORAGE_WALLET,
} from "shared/constants"
import { Logger, defineReadOnly } from "ethers/lib/utils"
import { Network } from "@ethersproject/networks"
import { useAssistant } from "./assistant"
import { useInterval, useLocalStorageChange } from "./helpers"

class StaticJsonBatchRpcProvider extends ethers.providers.JsonRpcBatchProvider {
override async detectNetwork(): Promise<Network> {
let { network } = this
if (network == null) {
network = await super.detectNetwork()

if (!network) {
logger.throwError(
"no network detected",
Logger.errors.UNKNOWN_ERROR,
{}
)
}

// If still not set, set it
// eslint-disable-next-line no-underscore-dangle
if (this._network == null) {
// A static network does not support "any"
defineReadOnly(this, "_network", network)

this.emit("network", network, null)
}
}
return network
}
}

// To make it possible to start fetching blockchain data before the user
// connects the wallet let's get the provider from the RPC URL
export function useArbitrumProvider(): ethers.providers.JsonRpcBatchProvider {
const arbitrumProvider = useMemo(
() => new ethers.providers.JsonRpcBatchProvider(ARBITRUM_SEPOLIA.rpcUrl),
() => new StaticJsonBatchRpcProvider(ARBITRUM_SEPOLIA.rpcUrl),
[]
)

Expand Down Expand Up @@ -130,7 +159,11 @@ export function useConnect() {
return wallet && disconnect(wallet)
}, [wallet, disconnect, updateWalletOnboarding])

return { isConnected: !!wallet, connect, disconnect: disconnectBound }
return {
isConnected: process.env.IS_COMING_SOON !== "true" && !!wallet,
connect,
disconnect: disconnectBound,
}
}

// Hook is invoked after user switched accounts
Expand Down
7 changes: 4 additions & 3 deletions src/testing/utils/quickUnstaking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { gameParametersAbi, tahoDeployerAbi } from "shared/contracts/abi"

const TAHO_MULTISIG = "0x6e80164ea60673d64d5d6228beb684a1274bb017"

const localhostProvider = process.env.USE_LOCALHOST_FORK
? new ethers.providers.JsonRpcProvider(process.env.LOCALHOST_RPC_URL)
: null
const localhostProvider =
process.env.USE_LOCALHOST_FORK === "true"
? new ethers.providers.JsonRpcProvider(process.env.LOCALHOST_RPC_URL)
: null

const impersonate = (address: string) =>
localhostProvider?.send("hardhat_impersonateAccount", [address])
Expand Down
25 changes: 18 additions & 7 deletions src/ui/Nav/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ const NAV_ITEMS = [
title: "The Island",
exact: true,
extraInfo: "BETA",
},
{
path: ROUTES.FEEDBACK,
exact: true,
title: "Feedback",
target: "blank",
icon: feedbackIcon,
} as {
path: string
title: string
exact: boolean
extraInfo?: string
target?: string
icon?: string
},
// {
// path: ROUTES.REFERRALS,
Expand All @@ -37,6 +37,16 @@ const NAV_ITEMS = [
// },
]

if (process.env.IS_COMING_SOON !== "true") {
NAV_ITEMS.push({
path: ROUTES.FEEDBACK,
title: "Feedback",
exact: true,
target: "blank",
icon: feedbackIcon,
})
}

function EnvironmentInfo() {
if (process.env.USE_LOCALHOST_FORK === "true") {
return <span>🏝️ Using localhost</span>
Expand Down Expand Up @@ -103,6 +113,7 @@ export default function Nav(): JSX.Element {
iconSize="large"
iconSrc={walletIcon}
onClick={() => connect()}
isDisabled={process.env.IS_COMING_SOON === "true"}
>
Connect wallet
</Button>
Expand Down
12 changes: 12 additions & 0 deletions src/ui/Onboarding/Teaser.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from "react"
import OnboardingModal from "shared/components/Modals/OnboardingModal"

export default function Teaser() {
return (
<OnboardingModal>
Portal opens
<br />
soon
</OnboardingModal>
)
}
Loading

0 comments on commit 938eb9a

Please sign in to comment.