Skip to content

Commit

Permalink
1084 sepolia guard (#1241)
Browse files Browse the repository at this point in the history
* fix(app): only show on chain button on sepolia

* fix(app): mock chains

* fix(app): renaimg env var NEXT_PUBLIC_GITCOIN_VC_SCHEMA_ADDRESS => NEXT_PUBLIC_GITCOIN_VC_SCHEMA_UUID

---------

Co-authored-by: Gerald Iakobinyi-Pich <nutrina@Geralds-Mac-mini-2.local>
  • Loading branch information
Tim Schultz and Gerald Iakobinyi-Pich committed May 9, 2023
1 parent 6dada48 commit da3df10
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/.env-example.env
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ NEXT_PUBLIC_ALLO_SCORER_API_KEY=SCORER_API_KEY
NEXT_PUBLIC_SCORER_ENDPOINT=http://localhost:8002/ceramic-cache

NEXT_PUBLIC_GITCOIN_ATTESTER_CONTRACT_ADDRESS=0xc000000000000000000000000000000000000004
NEXT_PUBLIC_GITCOIN_VC_SCHEMA_ADDRESS=0xc000000000000000000000000000000000000004
NEXT_PUBLIC_GITCOIN_VC_SCHEMA_UUID=0xc000000000000000000000000000000000000004
NEXT_PUBLIC_FF_CHAIN_SYNC=on

NEXT_PUBLIC_ENABLE_TESTNET=on
11 changes: 9 additions & 2 deletions app/__test-fixtures__/onboardHookValues.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Account, WalletState } from "@web3-onboard/core/dist/types";
import { Account, ConnectedChain, WalletState } from "@web3-onboard/core/dist/types";
import { sepoliaChainId } from "../utils/onboard";

export const mockAddress = "0xmyAddress";
export const mockAccount: Account = {
Expand All @@ -11,5 +12,11 @@ export const mockWallet: WalletState = {
icon: "",
provider: { on: jest.fn(), removeListener: jest.fn(), request: jest.fn() },
accounts: [mockAccount],
chains: [],
chains: [
[
{
id: sepoliaChainId,
},
] as unknown as ConnectedChain,
],
};
2 changes: 1 addition & 1 deletion app/components/SyncToChainButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const SyncToChainButton = () => {
const { v, r, s } = data.signature;

const transaction = await gitcoinAttesterContract.addPassportWithSignature(
process.env.NEXT_PUBLIC_GITCOIN_VC_SCHEMA_ADDRESS as string,
process.env.NEXT_PUBLIC_GITCOIN_VC_SCHEMA_UUID as string,
data.passport,
v,
r,
Expand Down
3 changes: 2 additions & 1 deletion app/pages/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { ExpiredStampModal } from "../components/ExpiredStampModal";
import ProcessingPopup from "../components/ProcessingPopup";
import SyncToChainButton from "../components/SyncToChainButton";
import { getFilterName } from "../config/filters";
import { sepoliaChainId } from "../utils/onboard";

const isLiveAlloScoreEnabled = process.env.NEXT_PUBLIC_FF_LIVE_ALLO_SCORE === "on";
const isOnChainSyncEnabled = process.env.NEXT_PUBLIC_FF_CHAIN_SYNC === "on";
Expand Down Expand Up @@ -257,7 +258,7 @@ export default function Dashboard() {
</div>
)}

{isOnChainSyncEnabled && (
{isOnChainSyncEnabled && wallet?.chains[0].id === sepoliaChainId && (
<div className="mx-4">
<SyncToChainButton />
</div>
Expand Down
4 changes: 3 additions & 1 deletion app/utils/onboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ const walletConnect = walletConnectModule();
// Include ledger capabilities
const ledger = ledgerModule();

export const sepoliaChainId = "0xaa36a7";

const chains = [
{
id: "0x1",
Expand All @@ -26,7 +28,7 @@ const chains = [

if (process.env.NEXT_PUBLIC_ENABLE_TESTNET === "on") {
chains.push({
id: "0xaa36a7",
id: sepoliaChainId,
token: "ETH",
label: "Sepolia",
rpcUrl: process.env.NEXT_PUBLIC_PASSPORT_SEPOLIA_RPC_URL as string,
Expand Down

3 comments on commit da3df10

@kaluram605
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello very very nice project

@Iziedking
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks Good

@Sunnyrays13
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks interesting.. looking forward to seeing more

Please sign in to comment.