Skip to content

Commit

Permalink
factorize MS minimalFee
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjah committed Aug 1, 2024
1 parent 2cf1ba8 commit 02042c8
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions src/massaStation/MassaStationAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,18 @@ export class MassaStationAccount implements Provider {
};
}

private async minimalFee(): Promise<bigint> {
const client = await getClient();
return client.getMinimalFee();
}

private async rollOperation(
type: operationType.BuyRolls | operationType.SellRolls,
amount: bigint,
opts?: OperationOptions,
): Promise<Operation> {
let fee = opts?.fee;
if (!fee) {
const client = await getClient();
fee = await client.getMinimalFee();
}
let fee = opts?.fee ?? (await this.minimalFee());

const body = {
fee: fee.toString(),
amount: amount.toString(),
Expand Down Expand Up @@ -142,11 +144,8 @@ export class MassaStationAccount implements Provider {
amount: bigint,
opts?: OperationOptions,
): Promise<Operation> {
let fee = opts?.fee;
if (!fee) {
const client = await getClient();
fee = await client.getMinimalFee();
}
let fee = opts?.fee ?? (await this.minimalFee());

const body = {
fee: fee.toString(),
amount: amount.toString(),
Expand Down Expand Up @@ -174,11 +173,7 @@ export class MassaStationAccount implements Provider {
args = argsToBase64(params.parameter);
}

let fee = params?.fee;
if (!fee) {
const client = await getClient();
fee = await client.getMinimalFee();
}
let fee = params?.fee ?? (await this.minimalFee());

const body: ExecuteFunctionBody = {
nickname: this.accountName,
Expand Down Expand Up @@ -220,10 +215,7 @@ export class MassaStationAccount implements Provider {

const client = await getClient();

let fee = params?.fee;
if (!fee) {
fee = await client.getMinimalFee();
}
let fee = params?.fee ?? (await this.minimalFee());

const args = params.parameter ?? new Uint8Array();
const readOnlyParams = {
Expand Down

0 comments on commit 02042c8

Please sign in to comment.