-
Notifications
You must be signed in to change notification settings - Fork 92
fix: some ui issue #2952
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
Merged
Merged
fix: some ui issue #2952
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
13f0aba
fix: some ui issue
devchenyan 5847658
fix: some ui issue
devchenyan 2a548f6
Merge branch 'develop' into fix-UI-issues
devchenyan 3e81350
feat: validateCapacity
devchenyan 88bd62b
fix: syncIcon
devchenyan dddada4
Merge branch 'develop' into fix-UI-issues
Keith-CY fd086e2
fix: comments
devchenyan 824b544
fix: releaseDate
devchenyan c19d0f6
Merge branch 'develop' into fix-UI-issues
Keith-CY 3a1db57
Merge branch 'develop' into fix-UI-issues
Keith-CY 71c2917
fix: Issue on UI withdrawing from NervosDao
devchenyan 05e6592
Merge branch 'develop' into fix-UI-issues
devchenyan 2a884ea
fix: releaseDate
devchenyan bf0d234
fix
devchenyan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,6 @@ | |
| margin-left: 4px; | ||
|
|
||
| path { | ||
| fill: #ffffff; | ||
| fill: var(--main-text-color); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,5 +20,6 @@ | |
| color: #999; | ||
| font-size: 12px; | ||
| margin-left: 4px; | ||
| white-space: nowrap; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
packages/neuron-ui/src/tests/validators/capacity/fixtures.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import { ErrorCode } from 'utils/enums' | ||
|
|
||
| export default { | ||
| 'Should throw an error when address is not a string': { | ||
| params: { | ||
| address: 'ckb1qrgqep8saj8agswr30pls73hra28ry8jlnlc3ejzh3dl2ju7xxpjxqgqqy28n5m69va267nv0wvsudngtxz8t9jwss3xkhpk', | ||
| amount: '62', | ||
| unit: 'ckb', | ||
| }, | ||
| exception: ErrorCode.CapacityTooSmall, | ||
| }, | ||
| 'Should throw an error when address is required but not provided': { | ||
| params: { | ||
| address: 'ckb1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsq2n0egquval9ljqm2ga6t9509kwcex5ejq3hy6dk', | ||
| amount: '62', | ||
| unit: 'ckb', | ||
| }, | ||
| exception: null, | ||
| }, | ||
| } |
25 changes: 25 additions & 0 deletions
25
packages/neuron-ui/src/tests/validators/capacity/index.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { describe, test, expect } from '@jest/globals' | ||
| import { isErrorWithI18n } from 'exceptions' | ||
| import { validateCapacity } from 'utils/validators' | ||
| import fixtures from './fixtures' | ||
|
|
||
| const fixtureTable: Fixture.Validator<typeof validateCapacity>[] = Object.entries(fixtures).map( | ||
| ([title, { params, exception }]) => [title, [params], exception] | ||
| ) | ||
|
|
||
| describe(`Test capacity validator`, () => { | ||
| test.each(fixtureTable)(`%s`, (_title, [params], exception) => { | ||
| if (exception) { | ||
| expect.assertions(2) | ||
| try { | ||
| validateCapacity(params) | ||
| } catch (err) { | ||
| expect(isErrorWithI18n(err)).toBeTruthy() | ||
| expect((err as { code: number }).code).toBe(exception) | ||
| } | ||
| } else { | ||
| expect.assertions(1) | ||
| expect(validateCapacity(params)).toBeTruthy() | ||
| } | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { CKBToShannonFormatter } from 'utils/formatters' | ||
| import { CapacityTooSmallException } from 'exceptions' | ||
| import { bytes as byteUtils } from '@ckb-lumos/codec' | ||
| import { ckbCore } from 'services/chain' | ||
|
|
||
| export const validateCapacity = (item: State.Output) => { | ||
| const { amount, unit, address } = item | ||
| const capacity = CKBToShannonFormatter(amount, unit) | ||
| const script = ckbCore.utils.addressToScript(address as string) | ||
| const size = 1 + byteUtils.concat(script.args, script.codeHash).byteLength | ||
| const outputSize = 8 + byteUtils.bytify('0x').byteLength + size | ||
|
|
||
| if (BigInt(capacity) < BigInt(outputSize) * BigInt(10 ** 8)) { | ||
| throw new CapacityTooSmallException(outputSize.toString()) | ||
| } | ||
|
|
||
| return true | ||
| } | ||
| export default validateCapacity |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.