Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,46 @@ describe('MultichainRouter', () => {
}),
).rejects.toThrow('No available account found for request.');
});

it(`throws if address resolution returns a lower case address that isn't available`, async () => {
const rootMessenger = getRootMultichainRouterMessenger();
const messenger = getRestrictedMultichainRouterMessenger(rootMessenger);
const withSnapKeyring = getMockWithSnapKeyring({
// Simulate the Snap returning an unconnected address
resolveAccountAddress: jest.fn().mockResolvedValue({
address: `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp:${MOCK_SOLANA_ACCOUNTS[0].address.toLowerCase()}`,
}),
});

/* eslint-disable-next-line no-new */
new MultichainRouter({
messenger,
withSnapKeyring,
});

rootMessenger.registerActionHandler(
'AccountsController:listMultichainAccounts',
() => MOCK_SOLANA_ACCOUNTS,
);

rootMessenger.registerActionHandler(
'PermissionController:getPermissions',
() => MOCK_SOLANA_SNAP_PERMISSIONS,
);

await expect(
messenger.call('MultichainRouter:handleRequest', {
connectedAddresses: SOLANA_CONNECTED_ACCOUNTS,
scope: SOLANA_CAIP2,
request: {
method: 'signAndSendTransaction',
params: {
message: 'foo',
},
},
}),
).rejects.toThrow('No available account found for request.');
});
});

describe('getSupportedMethods', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export class MultichainRouter {
const selectedAccount = accounts.find(
(account) =>
parsedConnectedAddresses.includes(account.address) &&
(!address || account.address.toLowerCase() === address.toLowerCase()),
(!address || account.address === address),
);

if (!selectedAccount) {
Expand Down Expand Up @@ -268,6 +268,9 @@ export class MultichainRouter {
* Handle an incoming JSON-RPC request tied to a specific scope by routing
* to either a procotol Snap or an account Snap.
*
* Note: Addresses are considered case sensitive by the MultichainRouter as
* not all non-EVM chains are case insensitive.
*
* @param options - An options bag.
* @param options.connectedAddresses - Addresses currently connected to the origin.
* @param options.origin - The origin of the RPC request.
Expand Down
Loading