Skip to content
Merged
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
6 changes: 3 additions & 3 deletions miniapps/forge/src/App.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -258,16 +258,16 @@ export const TokenPicker: Story = {

await userEvent.click(canvas.getByRole('button', { name: /连接钱包/i }))

// Wait for token selector button
// Wait for token selector button (BSC/BNB is now first due to chain ordering)
await waitFor(
() => {
expect(canvas.getByText('ETH')).toBeInTheDocument()
expect(canvas.getByText('BNB')).toBeInTheDocument()
},
{ timeout: 5000 }
)

// Click token selector to open picker
const tokenButton = canvas.getAllByRole('button').find((btn) => btn.textContent?.includes('ETH'))
const tokenButton = canvas.getAllByRole('button').find((btn) => btn.textContent?.includes('BNB'))
if (tokenButton) {
await userEvent.click(tokenButton)
}
Expand Down
9 changes: 5 additions & 4 deletions miniapps/forge/src/hooks/useRechargeConfig.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,17 @@ describe('useRechargeConfig', () => {
const options = result.current.forgeOptions
expect(options).toHaveLength(2) // ETH and BSC enabled, TRON disabled

// Chain order: BSC -> TRON -> ETH
expect(options[0]).toMatchObject({
externalChain: 'ETH',
externalAsset: 'ETH',
externalChain: 'BSC',
externalAsset: 'BNB',
internalChain: 'bfmeta',
internalAsset: 'BFM',
})

expect(options[1]).toMatchObject({
externalChain: 'BSC',
externalAsset: 'BNB',
externalChain: 'ETH',
externalAsset: 'ETH',
internalChain: 'bfmeta',
internalAsset: 'BFM',
})
Expand Down
6 changes: 6 additions & 0 deletions miniapps/forge/src/hooks/useRechargeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ export interface ForgeOption {
logo?: string
}

/** Chain display order: BSC -> TRON -> ETH */
const CHAIN_ORDER: Record<string, number> = { BSC: 1, TRON: 2, ETH: 3 }

/**
* Parse recharge config to forge options
*/
Expand All @@ -52,6 +55,9 @@ function parseForgeOptions(config: RechargeConfig): ForgeOption[] {
}
}

// Sort by chain order: BSC -> TRON -> ETH
options.sort((a, b) => (CHAIN_ORDER[a.externalChain] ?? 99) - (CHAIN_ORDER[b.externalChain] ?? 99))

return options
}

Expand Down