app_store: move to optimism

This commit is contained in:
bitful-pannul 2024-04-10 19:04:59 -04:00
parent 53fbce89ec
commit ea9fa0de7c
7 changed files with 47 additions and 44 deletions

View File

@ -39,8 +39,8 @@ use ft_worker_lib::{
const ICON: &str = include_str!("icon"); const ICON: &str = include_str!("icon");
const CHAIN_ID: u64 = 11155111; // sepolia const CHAIN_ID: u64 = 10; // optimism
const CONTRACT_ADDRESS: &str = "0x18c39eB547A0060C6034f8bEaFB947D1C16eADF1"; // sepolia const CONTRACT_ADDRESS: &str = "0x52185B6a6017E6f079B994452F234f7C2533787B"; // optimism
const EVENTS: [&str; 3] = [ const EVENTS: [&str; 3] = [
"AppRegistered(uint256,string,bytes,string,bytes32)", "AppRegistered(uint256,string,bytes,string,bytes32)",
@ -81,7 +81,7 @@ fn fetch_logs(eth_provider: &eth::Provider, filter: &eth::Filter) -> Vec<eth::Lo
} }
} }
} }
#[cfg(feature = "simulation-mode")] #[cfg(feature = "simulation-mode")] // TODO use local testnet
vec![] vec![]
} }

View File

@ -15,7 +15,7 @@
<meta name="viewport" <meta name="viewport"
content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1.00001, viewport-fit=cover" /> content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1.00001, viewport-fit=cover" />
<link href='https://fonts.googleapis.com/css?family=Montserrat' rel='stylesheet'> <link href='https://fonts.googleapis.com/css?family=Montserrat' rel='stylesheet'>
<script type="module" crossorigin src="/main:app_store:sys/assets/index-przgvy-e.js"></script> <script type="module" crossorigin src="/main:app_store:sys/assets/index-LQNA9SRw.js"></script>
<link rel="stylesheet" crossorigin href="/main:app_store:sys/assets/index-avBSgupm.css"> <link rel="stylesheet" crossorigin href="/main:app_store:sys/assets/index-avBSgupm.css">
</head> </head>

View File

@ -20,6 +20,7 @@ const connectors: [MetaMask, Web3ReactHooks][] = [
declare global { declare global {
interface ImportMeta { interface ImportMeta {
env: { env: {
VITE_OPTIMISM_RPC_URL: string;
VITE_SEPOLIA_RPC_URL: string; VITE_SEPOLIA_RPC_URL: string;
BASE_URL: string; BASE_URL: string;
VITE_NODE_URL?: string; VITE_NODE_URL?: string;
@ -38,7 +39,7 @@ const {
useProvider, useProvider,
} = metaMaskHooks; } = metaMaskHooks;
const RPC_URL = import.meta.env.VITE_SEPOLIA_RPC_URL; const RPC_URL = import.meta.env.VITE_OPTIMISM_RPC_URL;
const BASE_URL = import.meta.env.BASE_URL; const BASE_URL = import.meta.env.BASE_URL;
if (window.our) window.our.process = BASE_URL?.replace("/", ""); if (window.our) window.our.process = BASE_URL?.replace("/", "");
@ -56,15 +57,15 @@ function App() {
const [packageAbi, setPackageAbi] = useState<PackageStore>( const [packageAbi, setPackageAbi] = useState<PackageStore>(
PackageStore__factory.connect( PackageStore__factory.connect(
PACKAGE_STORE_ADDRESSES[ChainId.SEPOLIA], PACKAGE_STORE_ADDRESSES[ChainId.OPTIMISM],
new ethers.providers.JsonRpcProvider(RPC_URL)) // TODO: get the RPC URL from the wallet new ethers.providers.JsonRpcProvider(RPC_URL)) // TODO: get the RPC URL from the wallet
); );
useEffect(() => { useEffect(() => {
provider?.getNetwork().then(network => { provider?.getNetwork().then(network => {
if (network.chainId === ChainId.SEPOLIA) { if (network.chainId === ChainId.OPTIMISM) {
setPackageAbi(PackageStore__factory.connect( setPackageAbi(PackageStore__factory.connect(
PACKAGE_STORE_ADDRESSES[ChainId.SEPOLIA], PACKAGE_STORE_ADDRESSES[ChainId.OPTIMISM],
provider!.getSigner()) provider!.getSigner())
) )
} }

View File

@ -8,9 +8,11 @@ export enum ChainId {
export const SEPOLIA_OPT_HEX = '0xaa36a7'; export const SEPOLIA_OPT_HEX = '0xaa36a7';
export const OPTIMISM_OPT_HEX = '0xa'; export const OPTIMISM_OPT_HEX = '0xa';
export const SEPOLIA_OPT_INT = '11155111'; export const SEPOLIA_OPT_INT = '11155111';
export const OPTIMISM_OPT_INT = '10';
// Sepolia (for now) // Optimism (for now)
export const PACKAGE_STORE_ADDRESSES = { export const PACKAGE_STORE_ADDRESSES = {
[ChainId.SEPOLIA]: '0x18c39eB547A0060C6034f8bEaFB947D1C16eADF1', [ChainId.OPTIMISM]: '0x52185B6a6017E6f079B994452F234f7C2533787B',
// [ChainId.OPTIMISM]: '0x8f6e1c9C5a0fE0A7f9Cf0e9b3aF1A9c4f5c6A9e0', // [ChainId.SEPOLIA]: '0x18c39eB547A0060C6034f8bEaFB947D1C16eADF1',
}; };

View File

@ -6,7 +6,7 @@ import { useWeb3React } from "@web3-react/core";
import SearchHeader from "../components/SearchHeader"; import SearchHeader from "../components/SearchHeader";
import { PageProps } from "../types/Page"; import { PageProps } from "../types/Page";
import { setChain } from "../utils/chain"; import { setChain } from "../utils/chain";
import { SEPOLIA_OPT_HEX } from "../constants/chain"; import { OPTIMISM_OPT_HEX } from "../constants/chain";
import { hooks, metaMask } from "../utils/metamask"; import { hooks, metaMask } from "../utils/metamask";
import Loader from "../components/Loader"; import Loader from "../components/Loader";
import { toDNSWireFormat } from "../utils/dnsWire"; import { toDNSWireFormat } from "../utils/dnsWire";
@ -58,7 +58,7 @@ export default function PublishPage({
await metaMask.activate().catch(() => { }); await metaMask.activate().catch(() => { });
try { try {
setChain(SEPOLIA_OPT_HEX); setChain(OPTIMISM_OPT_HEX);
} catch (error) { } catch (error) {
console.error(error); console.error(error);
} }
@ -100,7 +100,7 @@ export default function PublishPage({
setLoading("Please confirm the transaction in your wallet"); setLoading("Please confirm the transaction in your wallet");
const publisherIdDnsWireFormat = toDNSWireFormat(publisherId); const publisherIdDnsWireFormat = toDNSWireFormat(publisherId);
await setChain(SEPOLIA_OPT_HEX); await setChain(OPTIMISM_OPT_HEX);
// TODO: have a checkbox to show if it's an update of an existing package // TODO: have a checkbox to show if it's an update of an existing package

View File

@ -40,21 +40,21 @@ export const CHAIN_DETAILS: { [key: string]: Chain } = {
export const getNetworkName = (networkId: string) => { export const getNetworkName = (networkId: string) => {
switch (networkId) { switch (networkId) {
case '1': case '1':
case '0x1': case '0x1':
return 'Ethereum'; // Ethereum Mainnet return 'Ethereum'; // Ethereum Mainnet
case '10': case '10':
case 'a': case 'a':
case '0xa': case '0xa':
return 'Optimism'; // Optimism return 'Optimism'; // Optimism
case '42161': case '42161':
return 'Arbitrum'; // Arbitrum One return 'Arbitrum'; // Arbitrum One
case '11155111': case '11155111':
case 'aa36a7': case 'aa36a7':
case '0xaa36a7': case '0xaa36a7':
return 'Sepolia'; // Sepolia Testnet return 'Sepolia'; // Sepolia Testnet
default: default:
return 'Unknown'; return 'Unknown';
} }
}; };