Skip to content

Commit 2199608

Browse files
committed
revert promptToCreateSolanaAccount
1 parent 2e1c2d1 commit 2199608

File tree

2 files changed

+75
-278
lines changed

2 files changed

+75
-278
lines changed

Diff for: app/scripts/lib/rpc-method-middleware/handlers/wallet-createSession/handler.test.ts

+62-224
Original file line numberDiff line numberDiff line change
@@ -462,37 +462,34 @@ describe('wallet_createSession', () => {
462462

463463
await handler(baseRequest);
464464

465-
expect(requestPermissionsForOrigin).toHaveBeenCalledWith(
466-
{
467-
[Caip25EndowmentPermissionName]: {
468-
caveats: [
469-
{
470-
type: Caip25CaveatType,
471-
value: {
472-
requiredScopes: {
473-
'eip155:1337': {
474-
accounts: ['eip155:1337:0x1', 'eip155:1337:0x3'],
475-
},
465+
expect(requestPermissionsForOrigin).toHaveBeenCalledWith({
466+
[Caip25EndowmentPermissionName]: {
467+
caveats: [
468+
{
469+
type: Caip25CaveatType,
470+
value: {
471+
requiredScopes: {
472+
'eip155:1337': {
473+
accounts: ['eip155:1337:0x1', 'eip155:1337:0x3'],
476474
},
477-
optionalScopes: {
478-
'eip155:100': {
479-
accounts: ['eip155:100:0x1', 'eip155:100:0x3'],
480-
},
481-
[MultichainNetwork.Solana]: {
482-
accounts: [
483-
'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp:EEivRh9T4GTLEJprEaKQyjSQzW13JRb5D7jSpvPQ8296',
484-
],
485-
},
475+
},
476+
optionalScopes: {
477+
'eip155:100': {
478+
accounts: ['eip155:100:0x1', 'eip155:100:0x3'],
479+
},
480+
[MultichainNetwork.Solana]: {
481+
accounts: [
482+
'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp:EEivRh9T4GTLEJprEaKQyjSQzW13JRb5D7jSpvPQ8296',
483+
],
486484
},
487-
isMultichainOrigin: true,
488-
sessionProperties: {},
489485
},
486+
isMultichainOrigin: true,
487+
sessionProperties: {},
490488
},
491-
],
492-
},
489+
},
490+
],
493491
},
494-
{ metadata: { promptToCreateSolanaAccount: false } },
495-
);
492+
});
496493
});
497494

498495
it('throws an error when requesting account permission approval fails', async () => {
@@ -600,32 +597,29 @@ describe('wallet_createSession', () => {
600597
unsupportableScopes: {},
601598
});
602599
await handler(baseRequest);
603-
expect(requestPermissionsForOrigin).toHaveBeenCalledWith(
604-
{
605-
[Caip25EndowmentPermissionName]: {
606-
caveats: [
607-
{
608-
type: Caip25CaveatType,
609-
value: {
610-
requiredScopes: {
611-
'eip155:1337': {
612-
accounts: ['eip155:1337:0x1', 'eip155:1337:0x3'],
613-
},
600+
expect(requestPermissionsForOrigin).toHaveBeenCalledWith({
601+
[Caip25EndowmentPermissionName]: {
602+
caveats: [
603+
{
604+
type: Caip25CaveatType,
605+
value: {
606+
requiredScopes: {
607+
'eip155:1337': {
608+
accounts: ['eip155:1337:0x1', 'eip155:1337:0x3'],
614609
},
615-
optionalScopes: {
616-
'eip155:100': {
617-
accounts: ['eip155:100:0x1', 'eip155:100:0x3'],
618-
},
610+
},
611+
optionalScopes: {
612+
'eip155:100': {
613+
accounts: ['eip155:100:0x1', 'eip155:100:0x3'],
619614
},
620-
isMultichainOrigin: true,
621-
sessionProperties: {},
622615
},
616+
isMultichainOrigin: true,
617+
sessionProperties: {},
623618
},
624-
],
625-
},
619+
},
620+
],
626621
},
627-
{ metadata: { promptToCreateSolanaAccount: false } },
628-
);
622+
});
629623
});
630624

631625
it('preserves known session properties', async () => {
@@ -686,159 +680,6 @@ describe('wallet_createSession', () => {
686680
});
687681
});
688682

689-
describe('promptToCreateSolanaAccount', () => {
690-
const baseRequestWithSolanaScope = {
691-
jsonrpc: '2.0' as const,
692-
id: 0,
693-
method: 'wallet_createSession',
694-
origin: 'http://test.com',
695-
params: {
696-
optionalScopes: {
697-
[MultichainNetwork.Solana]: {
698-
methods: [],
699-
notifications: [],
700-
accounts: [],
701-
},
702-
},
703-
sessionProperties: {
704-
[KnownSessionProperties.SolanaAccountChangedNotifications]: true,
705-
},
706-
},
707-
};
708-
it('prompts to create a solana account if a solana scope is requested and no solana accounts are currently available', async () => {
709-
const {
710-
handler,
711-
requestPermissionsForOrigin,
712-
getNonEvmAccountAddresses,
713-
} = createMockedHandler();
714-
getNonEvmAccountAddresses.mockResolvedValue([]);
715-
MockMultichain.validateAndNormalizeScopes.mockReturnValue({
716-
normalizedRequiredScopes: {
717-
[MultichainNetwork.Solana]: {
718-
methods: [],
719-
notifications: [],
720-
accounts: [],
721-
},
722-
},
723-
normalizedOptionalScopes: {},
724-
});
725-
726-
MockMultichain.bucketScopes
727-
.mockReturnValueOnce({
728-
supportedScopes: {},
729-
supportableScopes: {},
730-
unsupportableScopes: {},
731-
})
732-
.mockReturnValueOnce({
733-
supportedScopes: {
734-
'eip155:1337': {
735-
methods: [],
736-
notifications: [],
737-
accounts: [],
738-
},
739-
},
740-
supportableScopes: {},
741-
unsupportableScopes: {},
742-
});
743-
744-
await handler(baseRequestWithSolanaScope);
745-
746-
expect(requestPermissionsForOrigin).toHaveBeenCalledWith(
747-
{
748-
[Caip25EndowmentPermissionName]: {
749-
caveats: [
750-
{
751-
type: Caip25CaveatType,
752-
value: {
753-
requiredScopes: {},
754-
optionalScopes: {
755-
'eip155:1337': {
756-
accounts: [],
757-
},
758-
},
759-
isMultichainOrigin: true,
760-
sessionProperties: {
761-
[KnownSessionProperties.SolanaAccountChangedNotifications]:
762-
true,
763-
},
764-
},
765-
},
766-
],
767-
},
768-
},
769-
{ metadata: { promptToCreateSolanaAccount: true } },
770-
);
771-
});
772-
773-
it('does not prompt to create a solana account if a solana scope is requested and solana accounts are currently available', async () => {
774-
const {
775-
handler,
776-
requestPermissionsForOrigin,
777-
getNonEvmAccountAddresses,
778-
} = createMockedHandler();
779-
getNonEvmAccountAddresses.mockResolvedValue([
780-
'solana:101:0x1',
781-
'solana:101:0x2',
782-
]);
783-
MockMultichain.validateAndNormalizeScopes.mockReturnValue({
784-
normalizedRequiredScopes: {},
785-
normalizedOptionalScopes: {
786-
[MultichainNetwork.Solana]: {
787-
methods: [],
788-
notifications: [],
789-
accounts: [],
790-
},
791-
},
792-
});
793-
794-
MockMultichain.bucketScopes
795-
.mockReturnValueOnce({
796-
supportedScopes: {},
797-
supportableScopes: {},
798-
unsupportableScopes: {},
799-
})
800-
.mockReturnValueOnce({
801-
supportedScopes: {
802-
[MultichainNetwork.Solana]: {
803-
methods: [],
804-
notifications: [],
805-
accounts: [],
806-
},
807-
},
808-
supportableScopes: {},
809-
unsupportableScopes: {},
810-
});
811-
812-
await handler(baseRequestWithSolanaScope);
813-
814-
expect(requestPermissionsForOrigin).toHaveBeenCalledWith(
815-
{
816-
[Caip25EndowmentPermissionName]: {
817-
caveats: [
818-
{
819-
type: Caip25CaveatType,
820-
value: {
821-
requiredScopes: {},
822-
optionalScopes: {
823-
[MultichainNetwork.Solana]: {
824-
accounts: [],
825-
},
826-
},
827-
isMultichainOrigin: true,
828-
sessionProperties: {
829-
[KnownSessionProperties.SolanaAccountChangedNotifications]:
830-
true,
831-
},
832-
},
833-
},
834-
],
835-
},
836-
},
837-
{ metadata: { promptToCreateSolanaAccount: false } },
838-
);
839-
});
840-
});
841-
842683
describe('address case sensitivity', () => {
843684
it('treats EVM addresses as case insensitive but other addresses as case sensitive', async () => {
844685
const {
@@ -925,35 +766,32 @@ describe('wallet_createSession', () => {
925766
},
926767
});
927768

928-
expect(requestPermissionsForOrigin).toHaveBeenCalledWith(
929-
{
930-
[Caip25EndowmentPermissionName]: {
931-
caveats: [
932-
{
933-
type: Caip25CaveatType,
934-
value: {
935-
requiredScopes: {
936-
'eip155:1': {
937-
accounts: ['eip155:1:0xABC123'], // Requested EVM address included
938-
},
769+
expect(requestPermissionsForOrigin).toHaveBeenCalledWith({
770+
[Caip25EndowmentPermissionName]: {
771+
caveats: [
772+
{
773+
type: Caip25CaveatType,
774+
value: {
775+
requiredScopes: {
776+
'eip155:1': {
777+
accounts: ['eip155:1:0xABC123'], // Requested EVM address included
778+
},
779+
},
780+
optionalScopes: {
781+
[MultichainNetwork.Solana]: {
782+
accounts: [], // Solana address excluded due to case mismatch
939783
},
940-
optionalScopes: {
941-
[MultichainNetwork.Solana]: {
942-
accounts: [], // Solana address excluded due to case mismatch
943-
},
944-
[MultichainNetwork.Bitcoin]: {
945-
accounts: [], // Bitcoin address excluded due to case mismatch
946-
},
784+
[MultichainNetwork.Bitcoin]: {
785+
accounts: [], // Bitcoin address excluded due to case mismatch
947786
},
948-
isMultichainOrigin: true,
949-
sessionProperties: {},
950787
},
788+
isMultichainOrigin: true,
789+
sessionProperties: {},
951790
},
952-
],
953-
},
791+
},
792+
],
954793
},
955-
{ metadata: { promptToCreateSolanaAccount: false } },
956-
);
794+
});
957795
});
958796
});
959797
});

0 commit comments

Comments
 (0)