diff --git a/packages/snaps-controllers/src/interface/utils.test.tsx b/packages/snaps-controllers/src/interface/utils.test.tsx index 44a27b6004..e45f228619 100644 --- a/packages/snaps-controllers/src/interface/utils.test.tsx +++ b/packages/snaps-controllers/src/interface/utils.test.tsx @@ -553,16 +553,15 @@ describe('constructState', () => { ); const result = constructState({}, element); expect(result).toStrictEqual({ - foo: '0x1234567890123456789012345678901234567890', + foo: '1b9d6bcd-bbfd-4b2d-9b5d-ab8dfbbd4bed', }); }); @@ -571,16 +570,15 @@ describe('constructState', () => { ); const result = constructState({}, element); expect(result).toStrictEqual({ - foo: '0x1234567890123456789012345678901234567890', + foo: '1b9d6bcd-bbfd-4b2d-9b5d-ab8dfbbd4bed', }); }); @@ -590,9 +588,8 @@ describe('constructState', () => {
@@ -600,7 +597,7 @@ describe('constructState', () => { const result = constructState({}, element); expect(result).toStrictEqual({ - form: { foo: '0x1234567890123456789012345678901234567890' }, + form: { foo: '1b9d6bcd-bbfd-4b2d-9b5d-ab8dfbbd4bed' }, }); }); @@ -610,9 +607,8 @@ describe('constructState', () => {
@@ -620,7 +616,7 @@ describe('constructState', () => { const result = constructState({}, element); expect(result).toStrictEqual({ - form: { foo: '0x1234567890123456789012345678901234567890' }, + form: { foo: '1b9d6bcd-bbfd-4b2d-9b5d-ab8dfbbd4bed' }, }); }); diff --git a/packages/snaps-controllers/src/interface/utils.ts b/packages/snaps-controllers/src/interface/utils.ts index d92c1c374f..feb3fe1377 100644 --- a/packages/snaps-controllers/src/interface/utils.ts +++ b/packages/snaps-controllers/src/interface/utils.ts @@ -121,7 +121,7 @@ function getComponentStateValue( return element.props.checked; case 'AccountSelector': - return element.props.selectedAddress; + return element.props.selectedAccount; default: return element.props.value; diff --git a/packages/snaps-sdk/src/jsx/components/form/AccountSelector.test.tsx b/packages/snaps-sdk/src/jsx/components/form/AccountSelector.test.tsx index d4de0ad47f..2371bd8117 100644 --- a/packages/snaps-sdk/src/jsx/components/form/AccountSelector.test.tsx +++ b/packages/snaps-sdk/src/jsx/components/form/AccountSelector.test.tsx @@ -6,7 +6,7 @@ describe('AccountSelector', () => { ); @@ -15,7 +15,7 @@ describe('AccountSelector', () => { props: { name: 'account', chainIds: ['bip122:p2wpkh'], - selectedAddress: 'bc1qc8dwyqua9elc3mzcxk93c70kjz8tcc92x0a8a6', + selectedAccount: '1b9d6bcd-bbfd-4b2d-9b5d-ab8dfbbd4bed', }, key: null, }); diff --git a/packages/snaps-sdk/src/jsx/components/form/AccountSelector.ts b/packages/snaps-sdk/src/jsx/components/form/AccountSelector.ts index ec3e8e8b37..2f36bcbea6 100644 --- a/packages/snaps-sdk/src/jsx/components/form/AccountSelector.ts +++ b/packages/snaps-sdk/src/jsx/components/form/AccountSelector.ts @@ -1,4 +1,4 @@ -import type { CaipAccountAddress, CaipChainId } from '@metamask/utils'; +import type { CaipChainId } from '@metamask/utils'; import { createSnapComponent } from '../../component'; @@ -8,13 +8,13 @@ import { createSnapComponent } from '../../component'; * @property name - The name of the account selector. This is used to identify the * state in the form data. * @property chainIds - The chain IDs of the account selector. This should be a valid CAIP-2 chain ID array. - * @property selectedAddress - The default selected address of the account selector. This should be a - * valid CAIP-10 account address. + * @property selectedAccount - The default selected account of the account selector. This should be a + * valid account ID. */ export type AccountSelectorProps = { name: string; chainIds: CaipChainId[]; - selectedAddress: CaipAccountAddress; + selectedAccount: string; }; const TYPE = 'AccountSelector'; @@ -28,13 +28,13 @@ const TYPE = 'AccountSelector'; * @param props.name - The name of the account selector field. This is used to identify the * state in the form data. * @param props.chainIds - The chain IDs of the account selector. This should be a valid CAIP-2 chain ID array. - * @param props.selectedAddress - The selected address of the account selector. This should be a - * valid CAIP-10 account address. + * @param props.selectedAccount - The default selected account of the account selector. This should be a + * valid account ID. * @returns An account selector element. * @example - * + * * @example - * + * */ export const AccountSelector = createSnapComponent< AccountSelectorProps, diff --git a/packages/snaps-sdk/src/jsx/validation.test.tsx b/packages/snaps-sdk/src/jsx/validation.test.tsx index b397708166..b15d188412 100644 --- a/packages/snaps-sdk/src/jsx/validation.test.tsx +++ b/packages/snaps-sdk/src/jsx/validation.test.tsx @@ -301,7 +301,7 @@ describe('FieldStruct', () => { , ])('validates a field element', (value) => { @@ -970,12 +970,12 @@ describe('AccountSelectorStruct', () => { , , ])('validates an account picker element', (value) => { expect(is(value, AccountSelectorStruct)).toBe(true); @@ -999,16 +999,11 @@ describe('AccountSelectorStruct', () => { // @ts-expect-error - Invalid props. , // @ts-expect-error - Invalid props. - , + , , - , foo, diff --git a/packages/snaps-sdk/src/jsx/validation.ts b/packages/snaps-sdk/src/jsx/validation.ts index 60bb3e1f8c..99b3feb481 100644 --- a/packages/snaps-sdk/src/jsx/validation.ts +++ b/packages/snaps-sdk/src/jsx/validation.ts @@ -20,7 +20,6 @@ import { refine, } from '@metamask/superstruct'; import { - CaipAccountAddressStruct, CaipAccountIdStruct, CaipChainIdStruct, hasProperty, @@ -347,7 +346,7 @@ export const AccountSelectorStruct: Describe = element( Infer >, ), - selectedAddress: CaipAccountAddressStruct, + selectedAccount: string(), }, );