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

feat: adds rollup data fetching from Orbit template #1981

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 1 addition & 31 deletions .github/ISSUE_TEMPLATE/add-orbit-chain-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,6 @@ 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:
Expand All @@ -135,34 +128,11 @@ body:
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
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
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 @@ -27,11 +27,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
29 changes: 18 additions & 11 deletions packages/scripts/src/addOrbitChain/transforms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

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 * as fs from "fs";
import sharp from "sharp";
Expand Down Expand Up @@ -118,7 +120,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 @@ -131,7 +133,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 @@ -153,7 +155,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 @@ -181,7 +183,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 @@ -334,23 +336,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
Loading
Loading