Skip to content

Commit 408fe8b

Browse files
committed
Add updated props for address component
1 parent 02c70c7 commit 408fe8b

File tree

5 files changed

+30
-2
lines changed

5 files changed

+30
-2
lines changed

packages/examples/packages/browserify-plugin/snap.manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"url": "https://github.com/MetaMask/snaps.git"
88
},
99
"source": {
10-
"shasum": "HEAbfXBUqw5fNP+sJVyvUpXucZy6CwiCFXJi36CEfUw=",
10+
"shasum": "3/BuUTwY9FEKC+WoGDR8gUxkYp02eE8qhlgb5yLRs+o=",
1111
"location": {
1212
"npm": {
1313
"filePath": "dist/bundle.js",

packages/examples/packages/browserify/snap.manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"url": "https://github.com/MetaMask/snaps.git"
88
},
99
"source": {
10-
"shasum": "mCoDlMSdhDJAXd9zT74ST7jHysifHdQ8r0++b8uPbOs=",
10+
"shasum": "564aSuXVGtNUkWdP5vpW+yD6g7kCYhW/tIKP/NEjPzg=",
1111
"location": {
1212
"npm": {
1313
"filePath": "dist/bundle.js",

packages/snaps-sdk/src/jsx/components/Address.test.tsx

+22
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,26 @@ describe('Address', () => {
1414
},
1515
});
1616
});
17+
18+
it('renders an address with customized props', () => {
19+
const result = (
20+
<Address
21+
address="0x1234567890123456789012345678901234567890"
22+
truncate={true}
23+
displayName={true}
24+
avatar={false}
25+
/>
26+
);
27+
28+
expect(result).toStrictEqual({
29+
type: 'Address',
30+
key: null,
31+
props: {
32+
address: '0x1234567890123456789012345678901234567890',
33+
truncate: true,
34+
displayName: true,
35+
avatar: false,
36+
},
37+
});
38+
});
1739
});

packages/snaps-sdk/src/jsx/components/Address.ts

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ import { createSnapComponent } from '../component';
1010
*/
1111
export type AddressProps = {
1212
address: `0x${string}` | CaipAccountId;
13+
truncate?: boolean;
14+
displayName?: boolean;
15+
avatar?: boolean;
1316
};
1417

1518
const TYPE = 'Address';

packages/snaps-sdk/src/jsx/validation.ts

+3
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,9 @@ export const FormattingStruct: Describe<StandardFormattingElement> = typedUnion(
472472
*/
473473
export const AddressStruct: Describe<AddressElement> = element('Address', {
474474
address: nullUnion([HexChecksumAddressStruct, CaipAccountIdStruct]),
475+
truncate: optional(boolean()),
476+
displayName: optional(boolean()),
477+
avatar: optional(boolean()),
475478
});
476479

477480
/**

0 commit comments

Comments
 (0)