Skip to content

Commit

Permalink
Fix address validation in row component
Browse files Browse the repository at this point in the history
  • Loading branch information
FrederikBolding committed Mar 8, 2024
1 parent 43d8903 commit 2d0c134
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion packages/snaps-sdk/src/ui/components/address.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ describe('address', () => {

it('validates the args', () => {
expect(() => address({ value: 'foo' })).toThrow(
'Invalid address component: At path: value -- Expected a string matching `/0x[a-fA-F0-9]{40}/` but received "foo"',
'Invalid address component: At path: value -- Expected a string matching `/0x[a-fA-F0-9]{40}$/` but received "foo"',
);

expect(() =>
address({ value: '0x4bbeEB066eD09B7AEd07bF39EEe0460DFa2615200' }),
).toThrow(
'Invalid address component: At path: value -- Expected a string matching `/0x[a-fA-F0-9]{40}$/` but received "0x4bbeEB066eD09B7AEd07bF39EEe0460DFa2615200"',
);

// @ts-expect-error - Invalid args.
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-sdk/src/ui/components/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const AddressStruct = assign(
LiteralStruct,
object({
type: literal(NodeType.Address),
value: pattern(string(), /0x[a-fA-F0-9]{40}/u),
value: pattern(string(), /0x[a-fA-F0-9]{40}$/u),
}),
);

Expand Down

0 comments on commit 2d0c134

Please sign in to comment.