Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use espresso arbitrum sdk #1

Merged
merged 15 commits into from
Aug 13, 2024
Merged
7 changes: 7 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
if ! has nix_direnv_version || ! nix_direnv_version 3.0.5; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.5/direnvrc" "sha256-RuwIS+QKFj/T9M2TFXScjBsLR6V3A17YVoEW/Q6AZ1w="
fi

use nix
watch_file flake.nix
watch_file flake.lock
42 changes: 42 additions & 0 deletions .github/workflows/espresso-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Deploy frontend to github pages
on:
push:
branches:
- "integration" # our default branch for nitro forks
- "release-*"
pull_request:
schedule:
- cron: "0 0 * * 1"
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ (github.ref == 'refs/heads/integration' && github.run_number) || github.ref }}
cancel-in-progress: true

jobs:
pages:
runs-on: ubuntu-24.04
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: 20

- name: Build
run: |
yarn
yarn build
env:
# Go to https://cloud.walletconnect.com/sign-up and create a project to obtain an ID
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID: ${{ secrets.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID }}
NEXT_PUBLIC_SEPOLIA_RPC_URL: https://ethereum-sepolia-rpc.publicnode.com

- name: Deploy
uses: peaceiris/actions-gh-pages@v4
if: ${{ github.ref == 'refs/heads/integration' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./packages/arb-token-bridge-ui/build
cname: arbitrum-bridge.cappuccino.testnet.espresso.network
25 changes: 25 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
description = "A Nix-flake-based Node.js development environment";

inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.*.tar.gz";

outputs = { self, nixpkgs }:
let
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
pkgs = import nixpkgs { inherit system; overlays = [ self.overlays.default ]; };
});
in
{
overlays.default = final: prev: rec {
nodejs = prev.nodejs;
yarn = (prev.yarn.override { inherit nodejs; });
};

devShells = forEachSupportedSystem ({ pkgs }: {
default = pkgs.mkShell {
packages = with pkgs; [ node2nix nodejs nodePackages.pnpm yarn ];
};
});
};
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"resolutions": {
"**/@walletconnect/ethereum-provider": "2.13.1",
"**/@ethersproject/providers/ws": "7.5.10",
"**/@synthetixio/synpress/ws": "8.17.1"
"**/@synthetixio/synpress/ws": "8.17.1",
"**/@arbitrum/sdk": "https://github.com/EspressoSystems/arbitrum-sdk/releases/download/v5.0.0-pre/espressosystems-arbitrum-sdk-v4.0.1.tgz"
},
"keywords": [],
"author": "",
Expand Down
5 changes: 5 additions & 0 deletions packages/arb-token-bridge-ui/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
**/

module.exports = {
basePath: '/arbitrum-token-bridge',
output: 'export',
images: {
unoptimized: true
},
distDir: 'build',
productionBrowserSourceMaps: true,
reactStrictMode: true,
Expand Down
86 changes: 43 additions & 43 deletions packages/arb-token-bridge-ui/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,49 +77,49 @@ function addOrbitChainsToArbitrumSDK() {
)
}

export function getServerSideProps({
query
}: GetServerSidePropsContext): GetServerSidePropsResult<Record<string, never>> {
const sourceChainId = decodeChainQueryParam(query.sourceChain)
const destinationChainId = decodeChainQueryParam(query.destinationChain)

// If both sourceChain and destinationChain are not present, let the client sync with Metamask
if (!sourceChainId && !destinationChainId) {
return {
props: {}
}
}

// it's necessary to call this before sanitization to make sure all chains are registered
addOrbitChainsToArbitrumSDK()

// sanitize the query params
const sanitized = sanitizeQueryParams({ sourceChainId, destinationChainId })

// if the sanitized query params are different from the initial values, redirect to the url with sanitized query params
if (
sourceChainId !== sanitized.sourceChainId ||
destinationChainId !== sanitized.destinationChainId
) {
console.log(`[getServerSideProps] sanitizing query params`)
console.log(
`[getServerSideProps] sourceChain=${sourceChainId}&destinationChain=${destinationChainId} (before)`
)
console.log(
`[getServerSideProps] sourceChain=${sanitized.sourceChainId}&destinationChain=${sanitized.destinationChainId} (after)`
)
return {
redirect: {
permanent: false,
destination: getDestinationWithSanitizedQueryParams(sanitized, query)
}
}
}

return {
props: {}
}
}
// export function getServerSideProps({
// query
// }: GetServerSidePropsContext): GetServerSidePropsResult<Record<string, never>> {
// const sourceChainId = decodeChainQueryParam(query.sourceChain)
// const destinationChainId = decodeChainQueryParam(query.destinationChain)

// // If both sourceChain and destinationChain are not present, let the client sync with Metamask
// if (!sourceChainId && !destinationChainId) {
// return {
// props: {}
// }
// }

// // it's necessary to call this before sanitization to make sure all chains are registered
// addOrbitChainsToArbitrumSDK()

// // sanitize the query params
// const sanitized = sanitizeQueryParams({ sourceChainId, destinationChainId })

// // if the sanitized query params are different from the initial values, redirect to the url with sanitized query params
// if (
// sourceChainId !== sanitized.sourceChainId ||
// destinationChainId !== sanitized.destinationChainId
// ) {
// console.log(`[getServerSideProps] sanitizing query params`)
// console.log(
// `[getServerSideProps] sourceChain=${sourceChainId}&destinationChain=${destinationChainId} (before)`
// )
// console.log(
// `[getServerSideProps] sourceChain=${sanitized.sourceChainId}&destinationChain=${sanitized.destinationChainId} (after)`
// )
// return {
// redirect: {
// permanent: false,
// destination: getDestinationWithSanitizedQueryParams(sanitized, query)
// }
// }
// }

// return {
// props: {}
// }
// }

export default function Index() {
useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/arb-token-bridge-ui/src/util/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ export const defaultL2Network: ArbitrumNetwork = {
outbox: '0x50143333b44Ea46255BEb67255C9Afd35551072F',
rollup: process.env.NEXT_PUBLIC_IS_E2E_TEST
? '0xE8A8F50F2a237D06D0087D14E690f6Ff0556259D'
: '0x46966d871d29e1772c2809459469f849d8AAb1A3',
: '0x9E7027f19AE93681f5A2cb2d87841a7e1E3Cdbe7',
sequencerInbox: '0x18d19C5d3E685f5be5b9C86E097f0E439285D216'
},
isCustom: true,
Expand Down
5 changes: 2 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,9 @@
tslib "^2.3.0"
zen-observable-ts "^1.2.5"

"@arbitrum/sdk@^4.0.1":
"@arbitrum/sdk@^4.0.1", "@arbitrum/sdk@https://github.com/EspressoSystems/arbitrum-sdk/releases/download/v5.0.0-pre/espressosystems-arbitrum-sdk-v4.0.1.tgz":
version "4.0.1"
resolved "https://registry.yarnpkg.com/@arbitrum/sdk/-/sdk-4.0.1.tgz#b51c7bb8ecef0143a35b7f3ab8538031bb1830d2"
integrity sha512-uW0Pe/oICbmlHpIpYOaHHWsNQRG+3UbCa3s0SJsp2O1Kt9b0M0CX/fEdFOFLyAi3OxHonNEfzhfvQrALy9C3Yw==
resolved "https://github.com/EspressoSystems/arbitrum-sdk/releases/download/v5.0.0-pre/espressosystems-arbitrum-sdk-v4.0.1.tgz#42eb09129d1deab205e235be0c7dd7a19ce29418"
dependencies:
"@ethersproject/address" "^5.0.8"
"@ethersproject/bignumber" "^5.1.1"
Expand Down