-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: some ui issue * fix: some ui issue * feat: validateCapacity * fix: syncIcon * fix: comments * fix: releaseDate * fix: Issue on UI withdrawing from NervosDao * fix: releaseDate * fix --------- Co-authored-by: Chen Yu <[email protected]>
- Loading branch information
1 parent
f598a0f
commit c2ab3ac
Showing
19 changed files
with
139 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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
c2ab3ac
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Packaging for test is done in 7222884975
c2ab3ac
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Packaging for test is done in 7222883739