Skip to content

Commit

Permalink
fix bearby minimal fee
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjah committed Aug 1, 2024
1 parent 02042c8 commit 1b07303
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
17 changes: 7 additions & 10 deletions src/bearbyWallet/BearbyAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,18 +139,19 @@ export class BearbyAccount implements Provider {
}
}

private async minimalFee(): Promise<bigint> {
const { minimalFee } = await this.networkInfos();
return minimalFee;
}

public async callSC(params: CallSCParams): Promise<Operation> {
// await this.connect();

const args = params.parameter ?? new Uint8Array();
const unsafeParameters =
args instanceof Uint8Array ? args : Uint8Array.from(args.serialize());

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

try {
const operationId = await web3.contract.call({
Expand Down Expand Up @@ -179,11 +180,7 @@ export class BearbyAccount implements Provider {
const unsafeParameters =
args instanceof Uint8Array ? args : Uint8Array.from(args.serialize());

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

try {
// const res = await web3.contract.readSmartContract({
Expand Down
4 changes: 2 additions & 2 deletions src/bearbyWallet/utils/network.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { web3 } from '@hicaru/bearby.js';
import { Network } from '@massalabs/massa-web3';
import { Mas, Network } from '@massalabs/massa-web3';

export const networkInfos = async (): Promise<Network> => {
const { net } = await web3.wallet.network;
Expand All @@ -12,6 +12,6 @@ export const networkInfos = async (): Promise<Network> => {
return {
name: net,
chainId: res.result.chain_id,
minimalFee: res.result.minimal_fee,
minimalFee: Mas.fromString(res.result.minimal_fee),
};
};

0 comments on commit 1b07303

Please sign in to comment.