Skip to content

Commit

Permalink
chore: handle fast withdrawals in orbit form (#2086)
Browse files Browse the repository at this point in the history
  • Loading branch information
brtkx authored Nov 21, 2024
1 parent 8c6671b commit cf19cbd
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 5 deletions.
18 changes: 18 additions & 0 deletions .github/ISSUE_TEMPLATE/add-orbit-chain-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,24 @@ body:
validations:
required: true

- type: dropdown
id: fast-withdrawal
attributes:
label: Fast Withdrawals active
description: Only select Yes if your chain has Fast Withdrawals enabled. We will show information in our UI that your chain has Fast Withdrawals implemented and that withdrawals will take less time than usual.
options:
- "No"
- "Yes"
default: 0
- type: input
id: fast-withdrawal-time
attributes:
label: Fast Withdrawals time in minutes
description: Only fill this if your chain has Fast Withdrawals enabled.
placeholder: ex. 1440
validations:
required: false

- type: input
id: launch-date
attributes:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/add-orbit-chain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ jobs:

- name: Commit changes
run: |
git add packages/arb-token-bridge-ui/src/**/*
git add packages/arb-token-bridge-ui/public/**/*
git add "packages/arb-token-bridge-ui/src/**/*"
git add "packages/arb-token-bridge-ui/public/**/*" ":!public/images/__auto-generated/**"
git status
git commit -m "feat: add ${{ steps.issue.outputs.result }}"
git push origin ${{ steps.branch.outputs.name }}
Expand Down
5 changes: 5 additions & 0 deletions packages/scripts/src/addOrbitChain/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ export const bridgeUiConfigSchema = z.object({
logoUrl: z.string().optional(),
})
.optional(),
fastWithdrawalTime: z.number().int().positive().optional(),
});

export const chainSchema = z
Expand Down Expand Up @@ -287,6 +288,8 @@ export const incomingChainDataSchema = z.object({
childWeth: addressSchema,
parentMultiCall: addressSchema,
childMultiCall: addressSchema,
fastWithdrawalActive: z.boolean(),
fastWithdrawalMinutes: z.string().regex(/^\d+$/).optional(),
});

// Schema for the final OrbitChain structure
Expand Down Expand Up @@ -360,6 +363,8 @@ export const chainDataLabelToKey: Record<string, string> = {
"Parent MultiCall": "parentMultiCall",
"Child MultiCall": "childMultiCall",
"Parent WETH": "parentWeth",
"Fast Withdrawals active": "fastWithdrawalActive",
"Fast Withdrawals time in minutes": "fastWithdrawalMinutes",
};

export interface Issue {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ export const mockIncomingChainData: IncomingChainData = {
childWeth: "0x0000000000000000000000000000000000000019",
parentMultiCall: "0x0000000000000000000000000000000000000010",
childMultiCall: "0x0000000000000000000000000000000000000017",
fastWithdrawalMinutes: "15",
fastWithdrawalActive: true,
};

export const mockOrbitChain: OrbitChain = {
Expand Down Expand Up @@ -222,6 +224,7 @@ export const mockOrbitChain: OrbitChain = {
symbol: "XAI",
logoUrl: "/images/XaiLogo.svg",
},
fastWithdrawalTime: 900000,
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ exports[`Transforms > transformIncomingDataToOrbitChain > should transform incom
{
"bridgeUiConfig": {
"color": "#FF0000",
"fastWithdrawalTime": 900000,
"nativeTokenData": {
"logoUrl": "/images/mockChain_NativeTokenLogo.png",
"name": "Test Token",
Expand Down Expand Up @@ -147,7 +148,8 @@ exports[`Transforms > updateOrbitChainsFile > should add a new testnet chain whi
\\"name\\": \\"Xai\\",
\\"symbol\\": \\"XAI\\",
\\"logoUrl\\": \\"/images/XaiLogo.svg\\"
}
},
\\"fastWithdrawalTime\\": 900000
}
}
]
Expand Down Expand Up @@ -202,7 +204,8 @@ exports[`Transforms > updateOrbitChainsFile > should handle updating an existing
\\"name\\": \\"Xai\\",
\\"symbol\\": \\"XAI\\",
\\"logoUrl\\": \\"/images/XaiLogo.svg\\"
}
},
\\"fastWithdrawalTime\\": 900000
}
},
{
Expand Down Expand Up @@ -283,7 +286,8 @@ exports[`Transforms > updateOrbitChainsFile > should update the orbit chains fil
\\"name\\": \\"Xai\\",
\\"symbol\\": \\"XAI\\",
\\"logoUrl\\": \\"/images/XaiLogo.svg\\"
}
},
\\"fastWithdrawalTime\\": 900000
}
}
],
Expand Down
1 change: 1 addition & 0 deletions packages/scripts/src/addOrbitChain/tests/schemas.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ describe("Validation Functions", () => {
decimals: 18,
logoUrl: "https://example.com/token-logo.png",
},
fastWithdrawalTime: 900000,
};
expect(() =>
bridgeUiConfigSchema.parse(validBridgeUiConfig)
Expand Down
7 changes: 7 additions & 0 deletions packages/scripts/src/addOrbitChain/transforms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ export const extractRawChainData = (
if (key === "chainLogo" || key === "nativeTokenLogo") {
const imageUrl = extractImageUrlFromMarkdown(trimmedValue);
rawData[key] = imageUrl || trimmedValue;
} else if (key === "fastWithdrawalActive") {
rawData[key] = trimmedValue === "Yes";
} else {
rawData[key] = trimmedValue;
}
Expand Down Expand Up @@ -392,6 +394,11 @@ export const transformIncomingDataToOrbitChain = async (
logoUrl: nativeTokenLogoPath,
},
}),
...(chainData.fastWithdrawalActive && {
fastWithdrawalTime: chainData.fastWithdrawalMinutes
? Number(chainData.fastWithdrawalMinutes) * 60 * 1000
: undefined,
}),
},
};
};
Expand Down

0 comments on commit cf19cbd

Please sign in to comment.