Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove static fees mock #50

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 3 additions & 26 deletions packages/mainsail/source/fee.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Contracts, IoC, Services } from "@ardenthq/sdk";
import { BigNumber, get } from "@ardenthq/sdk-helpers";
import { BigNumber } from "@ardenthq/sdk-helpers";

import { Request } from "./request.js";

Expand All @@ -18,12 +18,10 @@ export class FeeService extends Services.AbstractFeeService {

public override async all(): Promise<Services.TransactionFees> {
const node = await this.#request.get("node/fees");
// @TODO: Uncomment when endpoint will be available in mainsail.
// const type = await this.#request.get("transactions/fees");
const type = await this.#request.get("transactions/fees");

const staticFees: object = type.data;
const dynamicFees: object = node.data;
// @TODO: Remove and use /transactions/fees when available in mainsail.
const staticFees: object = this.#transformDynamicFeesToStatic(dynamicFees);

return {
delegateRegistration: this.#transform("delegateRegistration", 1, staticFees, dynamicFees),
Expand All @@ -50,27 +48,6 @@ export class FeeService extends Services.AbstractFeeService {
return BigNumber.ZERO;
}

// @TODO: Replace with static fee api once available in mainsail.
#transformDynamicFeesToStatic(dynamicFees: object): Object {
return {
"1": {
transfer: "10000000",
secondSignature: "500000000",
delegateRegistration: "2500000000",
vote: "100000000",
multiSignature: "500000000",
ipfs: "500000000",
multiPayment: "10000000",
delegateResignation: "2500000000",
},
"2": {
entityRegistration: "5000000000",
entityResignation: "500000000",
entityUpdate: "500000000",
},
};
}

#transform(type: string, typeGroup: number, staticFees: object, dynamicFees: object): Services.TransactionFee {
const dynamicFee = (dynamicFees[typeGroup] ?? staticFees[typeGroup])[type] ?? "0";
let minimumFee = this.bigNumberService.make(dynamicFee?.min ?? "0");
Expand Down
Loading