Skip to content

Commit

Permalink
add coinconfig + update translations
Browse files Browse the repository at this point in the history
  • Loading branch information
hedi-edelbloute committed Oct 1, 2024
1 parent 076e1e0 commit 25a97cc
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 11 deletions.
8 changes: 4 additions & 4 deletions apps/ledger-live-desktop/static/i18n/en/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -6085,12 +6085,12 @@
"title": "Ensure that you have {{depositAmount}} ADA available for the deposit"
},
"CardanoFeeTooHigh": {
"title": "Network fees seems higher than usual",
"description": "Please try again or contact Ledger Support"
"title": "Abnormally high network fees.",
"description": "Network fees unusually high please double check your transaction."
},
"CardanoInvalidProtoParams": {
"title": "Cardano Invalid Protocol Prams",
"description": "Something went wrong, Please contact Ledger Support"
"title": "Cardano Invalid Protocol Parameters",
"description": "ADA transactions are temporarily unavailable. Please resync your account and try again or contact Support if you need assistance."
},
"StacksMemoTooLong": {
"title": "Memo length is too long"
Expand Down
12 changes: 12 additions & 0 deletions libs/coin-modules/coin-cardano/src/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import buildConConfig, { type CurrencyConfig } from "@ledgerhq/coin-framework/config";

export type CardanoConfig = {
maxFeesWarning: number;
maxFeesError: number;
};

export type CardanoCoinConfig = CurrencyConfig & CardanoConfig;

const coinConfig = buildConConfig<CardanoCoinConfig>();

export default coinConfig;
3 changes: 0 additions & 3 deletions libs/coin-modules/coin-cardano/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,3 @@ export const CARDANO_MAX_SUPPLY = 45e9;

export const CARDANO_API_ENDPOINT = getEnv("CARDANO_API_ENDPOINT");
export const CARDANO_TESTNET_API_ENDPOINT = getEnv("CARDANO_TESTNET_API_ENDPOINT");

export const MAX_FEES_WARN = 5e6;
export const MAX_FEES_THROW = 10e6;
6 changes: 5 additions & 1 deletion libs/coin-modules/coin-cardano/src/getTransactionStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ import type {
Transaction,
TransactionStatus,
} from "./types";
import { CARDANO_MAX_SUPPLY, MAX_FEES_THROW, MAX_FEES_WARN } from "./constants";
import { CARDANO_MAX_SUPPLY } from "./constants";
import coinConfig from "./config";

export const getTransactionStatus: AccountBridge<
Transaction,
Expand Down Expand Up @@ -64,6 +65,9 @@ export const getTransactionStatus: AccountBridge<
throw new Error("Invalid transaction mode");
}

const MAX_FEES_WARN = coinConfig.getCoinConfig().maxFeesWarning;
const MAX_FEES_THROW = coinConfig.getCoinConfig().maxFeesError;

if (txStatus.estimatedFees.gt(MAX_FEES_THROW)) {
throw new CardanoFeeTooHigh();
} else if (txStatus.estimatedFees.gt(MAX_FEES_WARN)) {
Expand Down
9 changes: 6 additions & 3 deletions libs/ledger-live-common/src/families/cardano/config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { ConfigInfo } from "@ledgerhq/live-config/LiveConfig";
import { CardanoCoinConfig } from "@ledgerhq/coin-cardano/config";
import { CurrencyLiveConfigDefinition } from "../../config";

export const cardanoConfig: Record<string, ConfigInfo> = {
export const cardanoConfig: CurrencyLiveConfigDefinition = {
config_currency_cardano: {
type: "object",
default: {
status: {
type: "active",
},
},
maxFeesWarning: 5e6,
maxFeesError: 10e6,
} as CardanoCoinConfig,
},
};

0 comments on commit 25a97cc

Please sign in to comment.