Skip to content

Commit

Permalink
Merge branch 'master' of github.com:OffchainLabs/arbitrum-token-bridg…
Browse files Browse the repository at this point in the history
…e into fs-609/portal-in-bridge
  • Loading branch information
dewanshparashar committed Oct 8, 2024
2 parents b89c14f + 957fdf0 commit 5c5c221
Show file tree
Hide file tree
Showing 23 changed files with 5,346 additions and 2,049 deletions.
68 changes: 38 additions & 30 deletions .github/ISSUE_TEMPLATE/add-orbit-chain-request.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Add Orbit Chain Request
description: File a request to have your Orbit chain added to the bridge
title: "[feat]: "
title: "[feat]: Add Orbit chain "
labels: ["feat", "triage"]
body:
- type: markdown
Expand Down Expand Up @@ -59,11 +59,18 @@ body:
label: Explorer URL
validations:
required: true
- type: input

- type: dropdown
id: parent-chain-id
attributes:
label: Parent chain ID
placeholder: ex. 42161
label: Parent Chain ID
description: Select the parent chain for your Orbit chain.
options:
- "1"
- "42161"
- "421614"
- "11155111"
- "17000"
validations:
required: true

Expand All @@ -78,7 +85,7 @@ body:
- type: input
id: native-token-address
attributes:
label: Native token address
label: Native token address on Parent Chain
placeholder: ex. 0x0000000000000000000000000000000000000000
validations:
required: false
Expand All @@ -88,7 +95,7 @@ body:
label: Native token name
placeholder: ex. Ether
validations:
required: false
required: false
- type: input
id: native-token-symbol
attributes:
Expand Down Expand Up @@ -168,45 +175,46 @@ body:
value: |
You can find this information under the `"l2Contracts" : {...}` key.
- type: input
id: parent-customGateway
id: parent-custom-gateway
attributes:
label: customGateway
label: Parent Custom Gateway
validations:
required: true
- type: input
id: parent-ERC20Gateway
id: parent-erc20-gateway
attributes:
label: ERC20Gateway
label: Parent ERC20 Gateway
description: This is also called the standard gateway. [Read more](https://docs.arbitrum.io/build-decentralized-apps/token-bridging/token-bridge-erc20#default-standard-bridging).
validations:
required: true
- type: input
id: parent-gatewayRouter
id: parent-gateway-router
attributes:
label: gatewayRouter
label: Parent Gateway Router
validations:
required: true
- type: input
id: parent-multicall
attributes:
label: multicall
label: Parent MultiCall
validations:
required: true
- type: input
id: parent-proxyAdmin
id: parent-proxy-admin
attributes:
label: proxyAdmin
label: Parent Proxy Admin
validations:
required: true
- type: input
id: parent-weth
attributes:
label: weth
label: Parent WETH
validations:
required: true
- type: input
id: parent-wethGateway
id: parent-weth-gateway
attributes:
label: wethGateway
label: Parent WETH Gateway
validations:
required: true

Expand All @@ -219,44 +227,44 @@ body:
value: |
You can find this information under the `"l3Contracts" : {...}` key.
- type: input
id: child-customGateway
id: child-custom-gateway
attributes:
label: customGateway
label: Child Custom Gateway
validations:
required: true
- type: input
id: child-ERC20Gateway
id: child-erc20-gateway
attributes:
label: ERC20Gateway
label: Child ERC20 Gateway
validations:
required: true
- type: input
id: child-gatewayRouter
id: child-gateway-router
attributes:
label: gatewayRouter
label: Child Gateway Router
validations:
required: true
- type: input
id: child-multicall
attributes:
label: multicall
label: Child Multicall
validations:
required: true
- type: input
id: child-proxyAdmin
id: child-proxy-admin
attributes:
label: proxyAdmin
label: Child Proxy Admin
validations:
required: true
- type: input
id: child-weth
attributes:
label: weth
label: Child WETH
validations:
required: true
- type: input
id: child-wethGateway
id: child-weth-gateway
attributes:
label: wethGateway
label: Child WETH Gateway
validations:
required: true
41 changes: 41 additions & 0 deletions .github/workflows/add-orbit-chain.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Add Orbit Chain

on:
workflow_dispatch:
inputs:
issue_number:
description: 'Issue Number'
required: true
type: string

permissions:
issues: read
contents: write
pull-requests: write

jobs:
add_orbit_chain:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'yarn'

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

- name: Build scripts
run: yarn workspace scripts build

- name: Run addOrbitChain script
run: yarn workspace scripts add-orbit-chain ../../packages/arb-token-bridge-ui/src/util/orbitChainsData.json
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE_NUMBER: ${{ github.event.issue.number || inputs.issue_number }}
33 changes: 33 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,36 @@ jobs:
- name: Regular E2E Failed
if: needs.e2e-tests.result != 'success' && needs.e2e-tests.result != 'skipped'
run: exit 1

test-scripts:
name: "Test Scripts"
runs-on: ubuntu-latest
needs: [check-files]
if: needs.check-files.outputs.run_tests == 'true'
steps:
- name: Checkout
uses: actions/checkout@v4

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

- name: Run scripts tests
run: yarn workspace scripts test

validate-orbit-chains-data:
name: "Validate Orbit Chains Data"
runs-on: ubuntu-latest
needs: [check-files]
if: needs.check-files.outputs.run_tests == 'true'
steps:
- name: Checkout
uses: actions/checkout@v4

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

- name: Build
run: yarn workspace scripts build

- name: Validate orbitChainsData.json
run: yarn workspace scripts validate-orbit-chains-data ../arb-token-bridge-ui/src/util/orbitChainsData.json
49 changes: 30 additions & 19 deletions packages/arb-token-bridge-ui/src/hooks/useTransactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ type Action =
| { type: 'SET_RESOLVED_TIMESTAMP'; txID: string; timestamp?: string }
| { type: 'ADD_TRANSACTIONS'; transactions: Transaction[] }
| {
type: 'UPDATE_L1TOL2MSG_DATA'
type: 'UPDATE_PARENT_TO_CHILD_MSG_DATA'
txID: string
l1ToL2MsgData: ParentToChildMessageData
parentToChildMsgData: ParentToChildMessageData
}
| { type: 'SET_TRANSACTIONS'; transactions: Transaction[] }

Expand Down Expand Up @@ -177,10 +177,10 @@ function updateBlockNumber(
return newState
}

function updateTxnL1ToL2Msg(
function updateTxnParentToChildMsg(
state: Transaction[],
txID: string,
l1ToL2MsgData: ParentToChildMessageData
parentToChildMsgData: ParentToChildMessageData
) {
const newState = [...state]
const index = newState.findIndex(txn => txn.txID === txID)
Expand All @@ -193,17 +193,18 @@ function updateTxnL1ToL2Msg(

if (!(transaction.type === 'deposit' || transaction.type === 'deposit-l1')) {
throw new Error(
"Attempting to add a l1tol2msg to a tx that isn't a deposit:" + txID
"Attempting to add a parentToChildMsg to a tx that isn't a deposit:" +
txID
)
}

const previousL1ToL2MsgData = transaction.parentToChildMsgData
if (!previousL1ToL2MsgData) {
const previousParentToChildMsgData = transaction.parentToChildMsgData
if (!previousParentToChildMsgData) {
newState[index] = {
...transaction,
parentToChildMsgData: {
status: l1ToL2MsgData.status,
retryableCreationTxID: l1ToL2MsgData.retryableCreationTxID,
status: parentToChildMsgData.status,
retryableCreationTxID: parentToChildMsgData.retryableCreationTxID,
fetchingUpdate: false
}
}
Expand All @@ -212,7 +213,10 @@ function updateTxnL1ToL2Msg(

newState[index] = {
...transaction,
parentToChildMsgData: { ...previousL1ToL2MsgData, ...l1ToL2MsgData }
parentToChildMsgData: {
...previousParentToChildMsgData,
...parentToChildMsgData
}
}
return newState
}
Expand Down Expand Up @@ -283,8 +287,12 @@ function reducer(state: Transaction[], action: Action) {
case 'SET_RESOLVED_TIMESTAMP': {
return updateResolvedTimestamp(state, action.txID, action.timestamp)
}
case 'UPDATE_L1TOL2MSG_DATA': {
return updateTxnL1ToL2Msg(state, action.txID, action.l1ToL2MsgData)
case 'UPDATE_PARENT_TO_CHILD_MSG_DATA': {
return updateTxnParentToChildMsg(
state,
action.txID,
action.parentToChildMsgData
)
}
case 'SET_TRANSACTIONS': {
return action.transactions
Expand Down Expand Up @@ -339,14 +347,14 @@ const useTransactions = (): [Transaction[], TransactionActions] => {
})
}

const updateTxnL1ToL2MsgData = async (
const updateTxnParentToChildMsgData = async (
txID: string,
l1ToL2MsgData: ParentToChildMessageData
parentToChildMsgData: ParentToChildMessageData
) => {
dispatch({
type: 'UPDATE_L1TOL2MSG_DATA',
type: 'UPDATE_PARENT_TO_CHILD_MSG_DATA',
txID: txID,
l1ToL2MsgData
parentToChildMsgData
})
}

Expand Down Expand Up @@ -384,7 +392,7 @@ const useTransactions = (): [Transaction[], TransactionActions] => {
const updateTransaction = (
txReceipt: TransactionReceipt,
tx?: ethers.ContractTransaction,
l1ToL2MsgData?: ParentToChildMessageData
parentToChildMsgData?: ParentToChildMessageData
) => {
if (!txReceipt.transactionHash) {
return console.warn(
Expand All @@ -410,8 +418,11 @@ const useTransactions = (): [Transaction[], TransactionActions] => {
if (tx) {
setResolvedTimestamp(txReceipt.transactionHash, new Date().toISOString())
}
if (l1ToL2MsgData) {
updateTxnL1ToL2MsgData(txReceipt.transactionHash, l1ToL2MsgData)
if (parentToChildMsgData) {
updateTxnParentToChildMsgData(
txReceipt.transactionHash,
parentToChildMsgData
)
}
}

Expand Down
Loading

0 comments on commit 5c5c221

Please sign in to comment.