Skip to content

Commit

Permalink
refactor: using params directly in send nano contract tx
Browse files Browse the repository at this point in the history
  • Loading branch information
andreabadesso committed Feb 25, 2025
1 parent ecf6825 commit 2788c52
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
14 changes: 13 additions & 1 deletion packages/hathor-rpc-handler/src/rpcMethods/getUtxos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,23 @@ export async function getUtxos(

validateNetwork(wallet, params.network);

// Extract only the snake_case properties that the wallet.getUtxos expects
const options = {
'token': params.token,
'authorities': params.authorities,
'max_utxos': params.max_utxos,
'filter_address': params.filter_address,
'amount_smaller_than': params.amount_smaller_than,
'amount_bigger_than': params.amount_bigger_than,
'max_amount': params.max_amount,
'only_available_utxos': params.only_available_utxos,
};

// We have the same issues here that we do have in the headless wallet:
// TODO: Memory usage enhancements are required here as wallet.getUtxos can cause issues on
// wallets with a huge amount of utxos.
// TODO: This needs to be paginated.
const utxoDetails: UtxoDetails[] = await wallet.getUtxos(params);
const utxoDetails: UtxoDetails[] = await wallet.getUtxos(options);

const confirmed = await promptHandler({
type: TriggerTypes.GetUtxosConfirmationPrompt,
Expand Down
16 changes: 9 additions & 7 deletions packages/hathor-rpc-handler/src/rpcMethods/sendNanoContractTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export async function sendNanoContractTx(
data: {
blueprintId: params.blueprintId,
ncId: params.ncId,
actions: params.actions as NanoContractAction[],
actions: params.actions,
method: params.method,
args: params.args,
pushTx: params.pushTx,
Expand Down Expand Up @@ -112,15 +112,17 @@ export async function sendNanoContractTx(
};
triggerHandler(sendNanoContractLoadingTrigger, requestMetadata);

const txData = {
ncId: params.ncId,
blueprintId: confirmedBluePrintId,
actions: confirmedActions,
args: confirmedArgs,
};

const response = await sendMethod(
params.method,
caller,
{
ncId: params.ncId,
blueprintId: confirmedBluePrintId,
actions: confirmedActions,
args: confirmedArgs,
},
txData,
{
pinCode: pinCodeResponse.data.pinCode,
}
Expand Down

0 comments on commit 2788c52

Please sign in to comment.