Skip to content

Commit

Permalink
Merge branch 'master' into dl/image-handler
Browse files Browse the repository at this point in the history
  • Loading branch information
douglance committed Oct 22, 2024
2 parents b8a12a7 + 0654a93 commit 37797e4
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 104 deletions.
34 changes: 2 additions & 32 deletions .github/ISSUE_TEMPLATE/add-orbit-chain-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,50 +121,20 @@ body:
attributes:
value: |
Please fill out this section with your chain configuration details and contract addresses. As a reminder, you can get all contract addresses by running [getAllContracts](https://github.com/OffchainLabs/arbitrum-orbit-sdk/blob/feat-add-verification-scripts/examples/verify-rollup/README.md#get-all-contracts).
- type: input
id: confirmPeriodBlocks
attributes:
label: confirmPeriodBlocks
placeholder: ex. 45818
validations:
required: true
- type: markdown
attributes:
value: |
## Rollup contract addresses
## Rollup contract address
- type: markdown
attributes:
value: |
You can find this information under the `"coreContracts" : {...}` key.
- type: input
id: bridge
attributes:
label: bridge
validations:
required: true
- type: input
id: inbox
attributes:
label: inbox
validations:
required: true
- type: input
id: outbox
attributes:
label: outbox
validations:
required: true
- type: input
id: rollup
attributes:
label: rollup
validations:
required: true
- type: input
id: sequencerInbox
attributes:
label: sequencerInbox
description: Please provide the address of the rollup contract. Other core contract addresses will be fetched automatically.
validations:
required: true

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ jobs:

- name: Install node_modules
uses: OffchainLabs/actions/node-modules/install@main

- name: Build
run: yarn workspace scripts build

Expand Down
Binary file not shown.
50 changes: 0 additions & 50 deletions packages/arb-token-bridge-ui/src/util/orbitChainsData.json
Original file line number Diff line number Diff line change
Expand Up @@ -781,56 +781,6 @@
}
}
},
{
"chainId": 1183,
"confirmPeriodBlocks": 150,
"ethBridge": {
"bridge": "0xCAeCF7c5c2769e250Ef69592dD470D40BC61D1f7",
"inbox": "0x44199D537Aa690bE3B4446602e0c66F2B992D51e",
"outbox": "0xAD6A8df458dBD6b440F50313C5d53E3C5b4734e9",
"rollup": "0x357717a0F9Ac8714A5995109Fba3BAd3b5f0954F",
"sequencerInbox": "0x146bCf344F949ad4c9Fcf339eb4415981aE21dF9"
},
"nativeToken": "0x566f8345F7bF45358FaB2802C19c60D691dE04e4",
"explorerUrl": "https://testnet.theatlas.tech",
"rpcUrl": "https://theatlas.tech",
"isCustom": true,
"isTestnet": true,
"name": "Atlas Testnet",
"slug": "atlas-testnet",
"parentChainId": 421614,
"retryableLifetimeSeconds": 604800,
"tokenBridge": {
"parentCustomGateway": "0xE5A8943e36f93491f97A521447772fCF529533B5",
"parentErc20Gateway": "0xBc89C0A2CCA8A0e1583AA6d4e22B36E26661C78E",
"parentGatewayRouter": "0xc93fDF8327e04776fd184188bB4EC8521E5E96D7",
"parentMultiCall": "0xce1CAd780c529e66e3aa6D952a1ED9A6447791c1",
"parentProxyAdmin": "0x0000000000000000000000000000000000000000",
"parentWeth": "0x0000000000000000000000000000000000000000",
"parentWethGateway": "0x0000000000000000000000000000000000000000",
"childCustomGateway": "0x2c2Be954C9B79d9cA2CF145d9d6363F3c3784615",
"childErc20Gateway": "0xDfCD9f6154BEA2E98e8aE493f3Fec2E22De52D6a",
"childGatewayRouter": "0xBc63Ec54dA9Ee3B2b3D4cA5DE3622a3F85e0F219",
"childMultiCall": "0x54AFaf5Fd025A99708e73e52c317454bD52B1e77",
"childProxyAdmin": "0xE1C9a27C47bb9691bA5b4E35eb7617B39F6098B9",
"childWeth": "0x0000000000000000000000000000000000000000",
"childWethGateway": "0x0000000000000000000000000000000000000000"
},
"bridgeUiConfig": {
"color": "#889B6F",
"network": {
"name": "Atlas Testnet",
"logo": "/images/AtlasLogo.png",
"description": "Aarc is the first modular layer for unified borderless dapps."
},
"nativeTokenData": {
"name": "Aarc",
"symbol": "AARC",
"decimals": 18,
"logoUrl": "/images/AtlasLogo.png"
}
}
},
{
"chainId": 2730,
"confirmPeriodBlocks": 64,
Expand Down
1 change: 1 addition & 0 deletions packages/scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"dependencies": {
"@actions/core": "^1.10.1",
"@actions/github": "^6.0.0",
"@arbitrum/sdk": "^4.0.1",
"@octokit/rest": "^21.0.2",
"axios": "^1.7.7",
"commander": "^12.1.0",
Expand Down
3 changes: 3 additions & 0 deletions packages/scripts/src/addOrbitChain/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
updateAndValidateOrbitChainsList,
commitChangesAndCreatePR,
setOutputs,
runPrettier,
} from "./transforms";

/**
Expand Down Expand Up @@ -36,6 +37,8 @@ export async function addOrbitChain(targetJsonPath: string): Promise<void> {
targetJsonPath
);

await runPrettier(targetJsonPath);

await commitChangesAndCreatePR(
branchName,
targetJsonPath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export const mockIncomingChainData: IncomingChainData = {
description: "This is a test chain.",
chainLogo: "https://example.com/testchain.png",
color: "#FF0000",
rpcUrl: "https://testrpc.com",
rpcUrl: "https://sepolia-rollup.arbitrum.io/rpc",
explorerUrl: "https://testexplorer.com",
parentChainId: "421614",
confirmPeriodBlocks: "150",
Expand All @@ -191,7 +191,7 @@ export const mockIncomingChainData: IncomingChainData = {
bridge: "0x0000000000000000000000000000000000000001",
inbox: "0x0000000000000000000000000000000000000002",
outbox: "0x0000000000000000000000000000000000000003",
rollup: "0x0000000000000000000000000000000000000004",
rollup: "0xeedE9367Df91913ab149e828BDd6bE336df2c892",
sequencerInbox: "0x0000000000000000000000000000000000000005",
parentGatewayRouter: "0x0000000000000000000000000000000000000009",
childGatewayRouter: "0x0000000000000000000000000000000000000016",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ exports[`Transforms > transformIncomingDataToOrbitChain > should transform incom
"chainId": 1234567890,
"confirmPeriodBlocks": 150,
"ethBridge": {
"bridge": "0x0000000000000000000000000000000000000001",
"inbox": "0x0000000000000000000000000000000000000002",
"outbox": "0x0000000000000000000000000000000000000003",
"rollup": "0x0000000000000000000000000000000000000004",
"sequencerInbox": "0x0000000000000000000000000000000000000005",
"bridge": "0x6c7FAC4edC72E86B3388B48979eF37Ecca5027e6",
"inbox": "0x6396825803B720bc6A43c63caa1DcD7B31EB4dd0",
"outbox": "0xc7491a559b416540427f9f112C5c98b1412c5d51",
"rollup": "0xeedE9367Df91913ab149e828BDd6bE336df2c892",
"sequencerInbox": "0x529a2061A1973be80D315770bA9469F3Da40D938",
},
"explorerUrl": "https://testexplorer.com",
"isArbitrum": true,
Expand All @@ -70,7 +70,7 @@ exports[`Transforms > transformIncomingDataToOrbitChain > should transform incom
"nativeToken": "0x0000000000000000000000000000000000000006",
"parentChainId": 421614,
"retryableLifetimeSeconds": 604800,
"rpcUrl": "https://testrpc.com",
"rpcUrl": "https://sepolia-rollup.arbitrum.io/rpc",
"slug": "test-chain",
"tokenBridge": {
"childCustomGateway": "0x0000000000000000000000000000000000000014",
Expand Down
4 changes: 2 additions & 2 deletions packages/scripts/src/addOrbitChain/tests/transforms.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ describe("Transforms", () => {
});

describe("transformIncomingDataToOrbitChain", () => {
it("should transform incoming chain data to OrbitChain format", () => {
it("should transform incoming chain data to OrbitChain format", async () => {
const chainLogoPath = "/images/mockChain_Logo.png";
const nativeTokenLogoPath = "/images/mockChain_NativeTokenLogo.png";

const result = transformIncomingDataToOrbitChain(
const result = await transformIncomingDataToOrbitChain(
mockIncomingChainData as IncomingChainData,
chainLogoPath,
nativeTokenLogoPath
Expand Down
46 changes: 35 additions & 11 deletions packages/scripts/src/addOrbitChain/transforms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */

import * as core from "@actions/core";
import { warning } from "@actions/core";
import { getArbitrumNetworkInformationFromRollup } from "@arbitrum/sdk";
import { JsonRpcProvider } from "@ethersproject/providers";
import axios from "axios";
import { fileTypeFromBuffer } from "file-type";
import * as fs from "fs";
import path from "path";
import sharp from "sharp";
import prettier from "prettier";

import { lookup } from "mime-types";
import {
Expand Down Expand Up @@ -124,7 +128,7 @@ export const createAndValidateOrbitChain = async (
) => {
core.startGroup("Orbit Chain Creation and Validation");
console.log("Creating OrbitChain object...");
const orbitChain = transformIncomingDataToOrbitChain(
const orbitChain = await transformIncomingDataToOrbitChain(
validatedIncomingData,
chainLogoPath,
nativeTokenLogoPath
Expand All @@ -137,7 +141,7 @@ export const createAndValidateOrbitChain = async (
};

export const updateAndValidateOrbitChainsList = async (
orbitChain: ReturnType<typeof transformIncomingDataToOrbitChain>,
orbitChain: OrbitChain,
targetJsonPath: string
) => {
core.startGroup("Orbit ChainsList Update and Validation");
Expand All @@ -159,7 +163,7 @@ export const commitChangesAndCreatePR = async (
branchName: string,
targetJsonPath: string,
updatedOrbitChainsList: ReturnType<typeof updateOrbitChainsFile>,
orbitChain: ReturnType<typeof transformIncomingDataToOrbitChain>
orbitChain: OrbitChain
) => {
core.startGroup("Commit Changes and Create Pull Request");
console.log("Preparing to commit changes...");
Expand Down Expand Up @@ -187,7 +191,7 @@ export const commitChangesAndCreatePR = async (

export const setOutputs = (
branchName: string,
orbitChain: ReturnType<typeof transformIncomingDataToOrbitChain>,
orbitChain: OrbitChain,
targetJsonPath: string
) => {
core.startGroup("Set Outputs");
Expand Down Expand Up @@ -354,23 +358,28 @@ export const fetchAndSaveImage = async (
return `/${imageSavePath}`;
};

export const transformIncomingDataToOrbitChain = (
export const transformIncomingDataToOrbitChain = async (
chainData: IncomingChainData,
chainLogoPath: string,
nativeTokenLogoPath?: string
): OrbitChain => {
): Promise<OrbitChain> => {
const parentChainId = parseInt(chainData.parentChainId, 10);
const isTestnet = TESTNET_PARENT_CHAIN_IDS.includes(parentChainId);
const provider = new JsonRpcProvider(chainData.rpcUrl);
const rollupData = await getArbitrumNetworkInformationFromRollup(
chainData.rollup,
provider
);

return {
chainId: parseInt(chainData.chainId, 10),
confirmPeriodBlocks: parseInt(chainData.confirmPeriodBlocks, 10),
confirmPeriodBlocks: rollupData.confirmPeriodBlocks,
ethBridge: {
bridge: chainData.bridge,
inbox: chainData.inbox,
outbox: chainData.outbox,
bridge: rollupData.ethBridge.bridge,
inbox: rollupData.ethBridge.inbox,
outbox: rollupData.ethBridge.outbox,
rollup: chainData.rollup,
sequencerInbox: chainData.sequencerInbox,
sequencerInbox: rollupData.ethBridge.sequencerInbox,
},
nativeToken: chainData.nativeTokenAddress,
explorerUrl: chainData.explorerUrl,
Expand Down Expand Up @@ -450,3 +459,18 @@ export const updateOrbitChainsFile = (

return orbitChains;
};

export async function runPrettier(targetJsonPath: string): Promise<void> {
try {
const fileContent = fs.readFileSync(targetJsonPath, "utf8");
const prettierConfig = await prettier.resolveConfig(targetJsonPath);
const formattedContent = await prettier.format(fileContent, {
...prettierConfig,
filepath: targetJsonPath,
});
fs.writeFileSync(targetJsonPath, formattedContent);
console.log(`Prettier formatting applied to ${targetJsonPath}`);
} catch (error) {
warning(`Failed to run Prettier: ${error}`);
}
}

0 comments on commit 37797e4

Please sign in to comment.