File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed
packages/examples/packages/send-flow Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change 77 "url" : " https://github.com/MetaMask/snaps.git"
88 },
99 "source" : {
10- "shasum" : " 5qERUafayyDWQ12V/+htfEs2wzmQwhSn0EcQolI7quo =" ,
10+ "shasum" : " INn+njbWhdgWBpvU4y5opvJpDWSyT14xl7DQEvwY0JM =" ,
1111 "location" : {
1212 "npm" : {
1313 "filePath" : " dist/bundle.js" ,
Original file line number Diff line number Diff line change @@ -3,10 +3,11 @@ import type {
33 OnHomePageHandler ,
44 OnUserInputHandler ,
55 OnRpcRequestHandler ,
6+ CaipAccountId ,
67} from '@metamask/snaps-sdk' ;
78import { UserInputEventType } from '@metamask/snaps-sdk' ;
89import { is } from '@metamask/superstruct' ;
9- import { HexChecksumAddressStruct } from '@metamask/utils' ;
10+ import { HexChecksumAddressStruct , parseCaipAccountId } from '@metamask/utils' ;
1011
1112import { SendFlow } from './components' ;
1213import { accountsArray , accounts } from './data' ;
@@ -102,6 +103,14 @@ export const onUserInput: OnUserInputHandler = async ({
102103 case 'amount' :
103104 case 'to' : {
104105 // For testing purposes, we display the avatar if the address is a valid hex checksum address.
106+ let parsedAddress ;
107+ try {
108+ parsedAddress = parseCaipAccountId (
109+ event . value as CaipAccountId ,
110+ ) . address ;
111+ } catch {
112+ /** noop */
113+ }
105114 await snap . request ( {
106115 method : 'snap_updateInterface' ,
107116 params : {
@@ -114,7 +123,7 @@ export const onUserInput: OnUserInputHandler = async ({
114123 total = { total }
115124 fees = { fees }
116125 errors = { formErrors }
117- displayAvatar = { is ( event . value , HexChecksumAddressStruct ) }
126+ displayAvatar = { is ( parsedAddress , HexChecksumAddressStruct ) }
118127 />
119128 ) ,
120129 } ,
You can’t perform that action at this time.
0 commit comments