Skip to content

Commit dce6f52

Browse files
refactor: remove unnecessary address validation
1 parent 761f7fa commit dce6f52

File tree

1 file changed

+1
-35
lines changed

1 file changed

+1
-35
lines changed

packages/snap/src/handlers/KeyringRequestHandler.ts

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -172,32 +172,23 @@ export class KeyringRequestHandler {
172172
switch (method as AccountCapability) {
173173
case AccountCapability.SignPsbt: {
174174
assert(params, SignPsbtRequest);
175-
const { account: accountParam, psbt, feeRate, options } = params;
176-
await this.#validateAccountAddress(account, accountParam.address);
175+
const { psbt, feeRate, options } = params;
177176
return this.#signPsbt(account, psbt, origin, options, feeRate);
178177
}
179178
case AccountCapability.FillPsbt: {
180179
assert(params, FillPsbtRequest);
181-
const { account: accountParam } = params;
182-
await this.#validateAccountAddress(account, accountParam.address);
183180
return this.#fillPsbt(account, params.psbt, params.feeRate);
184181
}
185182
case AccountCapability.ComputeFee: {
186183
assert(params, ComputeFeeRequest);
187-
const { account: accountParam } = params;
188-
await this.#validateAccountAddress(account, accountParam.address);
189184
return this.#computeFee(account, params.psbt, params.feeRate);
190185
}
191186
case AccountCapability.BroadcastPsbt: {
192187
assert(params, BroadcastPsbtRequest);
193-
const { account: accountParam } = params;
194-
await this.#validateAccountAddress(account, accountParam.address);
195188
return this.#broadcastPsbt(account, params.psbt, origin);
196189
}
197190
case AccountCapability.SendTransfer: {
198191
assert(params, SendTransferRequest);
199-
const { account: accountParam } = params;
200-
await this.#validateAccountAddress(account, accountParam.address);
201192
return this.#sendTransfer(
202193
account,
203194
params.recipients,
@@ -207,8 +198,6 @@ export class KeyringRequestHandler {
207198
}
208199
case AccountCapability.GetUtxo: {
209200
assert(params, GetUtxoRequest);
210-
const { account: accountParam } = params;
211-
await this.#validateAccountAddress(account, accountParam.address);
212201
return this.#getUtxo(account, params.outpoint);
213202
}
214203
case AccountCapability.ListUtxos: {
@@ -219,8 +208,6 @@ export class KeyringRequestHandler {
219208
}
220209
case AccountCapability.SignMessage: {
221210
assert(params, SignMessageRequest);
222-
const { account: accountParam } = params;
223-
await this.#validateAccountAddress(account, accountParam.address);
224211
return this.#signMessage(account, params.message, origin);
225212
}
226213
default: {
@@ -360,27 +347,6 @@ export class KeyringRequestHandler {
360347
};
361348
}
362349

363-
/**
364-
* Validates that the account address in params matches the account's address.
365-
* This ensures the caller is specifying the correct account.
366-
*
367-
* @param accountId - The account ID from the KeyringRequest
368-
* @param accountAddress - The account address from the request params
369-
*/
370-
async #validateAccountAddress(
371-
accountId: string,
372-
accountAddress: string,
373-
): Promise<void> {
374-
const account = await this.#accountsUseCases.get(accountId);
375-
if (account.publicAddress.toString() !== accountAddress) {
376-
throw new NotFoundError('Account address mismatch', {
377-
accountId,
378-
expected: account.publicAddress.toString(),
379-
received: accountAddress,
380-
});
381-
}
382-
}
383-
384350
/**
385351
* Resolves the address of an account from a signing request.
386352
*

0 commit comments

Comments
 (0)