Skip to content

Commit a3fde7b

Browse files
Add unit test and note in docs
1 parent 00449a0 commit a3fde7b

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

packages/snaps-controllers/src/multichain/MultichainRouter.test.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,46 @@ describe('MultichainRouter', () => {
268268
}),
269269
).rejects.toThrow('No available account found for request.');
270270
});
271+
272+
it('throws if address resolution returns a lower case address that isnt available', async () => {
273+
const rootMessenger = getRootMultichainRouterMessenger();
274+
const messenger = getRestrictedMultichainRouterMessenger(rootMessenger);
275+
const withSnapKeyring = getMockWithSnapKeyring({
276+
// Simulate the Snap returning an unconnected address
277+
resolveAccountAddress: jest.fn().mockResolvedValue({
278+
address: `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp:${MOCK_SOLANA_ACCOUNTS[0].address.toLowerCase()}`,
279+
}),
280+
});
281+
282+
/* eslint-disable-next-line no-new */
283+
new MultichainRouter({
284+
messenger,
285+
withSnapKeyring,
286+
});
287+
288+
rootMessenger.registerActionHandler(
289+
'AccountsController:listMultichainAccounts',
290+
() => MOCK_SOLANA_ACCOUNTS,
291+
);
292+
293+
rootMessenger.registerActionHandler(
294+
'PermissionController:getPermissions',
295+
() => MOCK_SOLANA_SNAP_PERMISSIONS,
296+
);
297+
298+
await expect(
299+
messenger.call('MultichainRouter:handleRequest', {
300+
connectedAddresses: SOLANA_CONNECTED_ACCOUNTS,
301+
scope: SOLANA_CAIP2,
302+
request: {
303+
method: 'signAndSendTransaction',
304+
params: {
305+
message: 'foo',
306+
},
307+
},
308+
}),
309+
).rejects.toThrow('No available account found for request.');
310+
});
271311
});
272312

273313
describe('getSupportedMethods', () => {

packages/snaps-controllers/src/multichain/MultichainRouter.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,9 @@ export class MultichainRouter {
268268
* Handle an incoming JSON-RPC request tied to a specific scope by routing
269269
* to either a procotol Snap or an account Snap.
270270
*
271+
* Note: Addresses are considered case sensitive by the MultichainRouter as
272+
* not all non-EVM chains are case insensitive.
273+
*
271274
* @param options - An options bag.
272275
* @param options.connectedAddresses - Addresses currently connected to the origin.
273276
* @param options.origin - The origin of the RPC request.

0 commit comments

Comments
 (0)