Skip to content

Commit

Permalink
chore: Update NODE_ENV environment variable in GitHub Actions workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
mashharuki committed Jun 8, 2024
1 parent f83bace commit b6b48e2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ jobs:
NEXT_PUBLIC_RPC_URL: ${{ secrets.NEXT_PUBLIC_RPC_URL }}
DEFENDER_API_KEY: ${{ secrets.DEFENDER_API_KEY }}
DEFENDER_SECRET_KEY: ${{ secrets.DEFENDER_SECRET_KEY }}
NODE_ENV: ${{ secrets.NODE_ENV }}

- name: Export Pages Artifact
run: yarn frontend export
Expand Down
14 changes: 12 additions & 2 deletions pkgs/frontend/src/context/IntmaxProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import HelloWorldJson from "@/contracts/HelloWorld.sol/HelloWorld.json";
import SampleForwarderJson from "@/contracts/SampleForwarder.sol/SampleForwarder.json";
import {
BLOCK_EXPLORER_URL,
CHAIN_ID,
DAPP_METADATA,
DEFAULT_WALLET_URL,
Expand Down Expand Up @@ -154,7 +155,7 @@ export const IntmaxProvider = ({
params: [{ from: address, to: to, value: parseEther(value) }],
});

console.log("tx info:", `https://sepolia.etherscan.io/tx/${result}`);
console.log("tx info:", `${BLOCK_EXPLORER_URL}/tx/${result}`);

// ブロックを取得する
const currentBlockNubmer = await ethereum.request({
Expand Down Expand Up @@ -270,8 +271,17 @@ export const IntmaxProvider = ({

console.log("sig:", sig);

// ローカルかGitHubPagesかでパスが変わるのでここで制御
let apiUrl: string;

if (process.env.NODE_ENV === "production") {
apiUrl = "api/requestRelayer";
} else {
apiUrl = "IntmaxRepo/api/requestRelayer";
}

// call requestRelayer API
const gaslessResult = await fetch("IntmaxRepo/api/requestRelayer", {
const gaslessResult = await fetch(apiUrl, {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand Down
11 changes: 10 additions & 1 deletion pkgs/frontend/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Loading from "@/components/Loading";
import Toaster from "@/components/Toaster";
import { IntmaxContext } from "@/context/IntmaxProvider";
import styles from "@/styles/Home.module.css";
import { BLOCK_EXPLORER_URL } from "@/utils/constants";
import { displayAddress } from "@/utils/functions";
import { useContext } from "react";
import "react-toastify/dist/ReactToastify.css";
Expand Down Expand Up @@ -55,7 +56,15 @@ export default function Home() {
{intmaxContext.address ? (
<>
<h3>Your Address</h3>
<h3>{displayAddress(intmaxContext.address)}</h3>
<h3>
<a
className="underline"
href={`${BLOCK_EXPLORER_URL}/address/${intmaxContext.address}`}
target="_blank"
>
{displayAddress(intmaxContext.address)}
</a>
</h3>
<h3>Your Balance</h3>
<h3>{intmaxContext.balance} ETH</h3>
<button onClick={sendTx} className={styles.authButton}>
Expand Down
1 change: 1 addition & 0 deletions pkgs/frontend/src/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export const CHAIN_ID = 534351;
export const RPC_URL = process.env.NEXT_PUBLIC_RPC_URL!;
export const BLOCK_EXPLORER_URL = "https://sepolia.scrollscan.dev";
export const DEFAULT_WALLET_URL =
process.env.NEXT_PUBLIC_WALLET_URL ||
"https://intmaxwallet-sdk-wallet.vercel.app/";
Expand Down

0 comments on commit b6b48e2

Please sign in to comment.