Skip to content

Commit

Permalink
feat: fetch contracts from rollup for automation (#1981)
Browse files Browse the repository at this point in the history
  • Loading branch information
douglance authored Oct 22, 2024
1 parent e3af561 commit d4c70d5
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 54 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
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

0 comments on commit d4c70d5

Please sign in to comment.