Skip to content

Commit

Permalink
Add updated props for address component
Browse files Browse the repository at this point in the history
  • Loading branch information
david0xd committed Oct 11, 2024
1 parent 02c70c7 commit 408fe8b
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "HEAbfXBUqw5fNP+sJVyvUpXucZy6CwiCFXJi36CEfUw=",
"shasum": "3/BuUTwY9FEKC+WoGDR8gUxkYp02eE8qhlgb5yLRs+o=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/browserify/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "mCoDlMSdhDJAXd9zT74ST7jHysifHdQ8r0++b8uPbOs=",
"shasum": "564aSuXVGtNUkWdP5vpW+yD6g7kCYhW/tIKP/NEjPzg=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
22 changes: 22 additions & 0 deletions packages/snaps-sdk/src/jsx/components/Address.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,26 @@ describe('Address', () => {
},
});
});

it('renders an address with customized props', () => {
const result = (
<Address
address="0x1234567890123456789012345678901234567890"
truncate={true}
displayName={true}
avatar={false}
/>
);

expect(result).toStrictEqual({
type: 'Address',
key: null,
props: {
address: '0x1234567890123456789012345678901234567890',
truncate: true,
displayName: true,
avatar: false,
},
});
});
});
3 changes: 3 additions & 0 deletions packages/snaps-sdk/src/jsx/components/Address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import { createSnapComponent } from '../component';
*/
export type AddressProps = {
address: `0x${string}` | CaipAccountId;
truncate?: boolean;
displayName?: boolean;
avatar?: boolean;
};

const TYPE = 'Address';
Expand Down
3 changes: 3 additions & 0 deletions packages/snaps-sdk/src/jsx/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,9 @@ export const FormattingStruct: Describe<StandardFormattingElement> = typedUnion(
*/
export const AddressStruct: Describe<AddressElement> = element('Address', {
address: nullUnion([HexChecksumAddressStruct, CaipAccountIdStruct]),
truncate: optional(boolean()),
displayName: optional(boolean()),
avatar: optional(boolean()),
});

/**
Expand Down

0 comments on commit 408fe8b

Please sign in to comment.