Skip to content

Commit

Permalink
fix: rpc send transfer recipient default network
Browse files Browse the repository at this point in the history
  • Loading branch information
alter-eggo committed Apr 22, 2024
1 parent a6f774c commit d285924
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/background/messaging/rpc-methods/send-transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
type RpcSendTransferParams,
type RpcSendTransferParamsLegacy,
convertRpcSendTransferLegacyParamsToNew,
defaultRpcSendTransferNetwork,
getRpcSendTransferParamErrors,
validateRpcSendTransferLegacyParams,
validateRpcSendTransferParams,
Expand Down Expand Up @@ -63,7 +64,7 @@ export async function rpcSendTransfer(
const requestParams: RequestParams = [
...recipients,
...amounts,
['network', params.network ?? 'mainnet'],
['network', params.network ?? defaultRpcSendTransferNetwork],
['requestId', message.id],
];

Expand Down
6 changes: 5 additions & 1 deletion src/shared/rpc/methods/send-transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import {
validateRpcParams,
} from './validation.utils';

export const defaultRpcSendTransferNetwork = 'mainnet';

export const rpcSendTransferParamsSchemaLegacy = yup.object().shape({
account: accountSchema,
address: yup.string().required(),
Expand All @@ -38,7 +40,9 @@ export const rpcSendTransferParamsSchema = yup.object().shape({
FormErrorMessages.IncorrectNetworkAddress,
(value, context) => {
const contextOptions = context.options as any;
const network = contextOptions.from[1].value.network as BitcoinNetworkModes;
const network =
(contextOptions.from[1].value.network as BitcoinNetworkModes) ||
defaultRpcSendTransferNetwork;
return btcAddressNetworkValidator(network).isValidSync(value);
}
),
Expand Down

0 comments on commit d285924

Please sign in to comment.