@ledgerhq/coin-hedera
Version:
Ledger Hedera Coin integration
148 lines • 7.73 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.STAKING_REWARD_HASH_SUFFIX = exports.OP_TYPES_EXCLUDING_FEES = exports.MAP_STAKING_MODE_TO_METHOD = exports.MAP_STAKING_MODE_TO_OPERATION_TYPE = exports.MAP_STAKING_MODE_TO_MEMO = exports.SUPPORTED_ERC20_TOKENS = exports.BASE_USD_FEE_BY_OPERATION_TYPE = exports.HEDERA_DELEGATION_STATUS = exports.FINALITY_MS = exports.HARDCODED_BLOCK_HEIGHT = exports.TRANSACTION_VALID_DURATION_SECONDS = exports.HEDERA_MAINNET_CHAIN_ID = exports.DEFAULT_GAS_PRICE_TINYBARS = exports.DEFAULT_GAS_LIMIT = exports.ESTIMATED_FEE_SAFETY_RATE = exports.ESTIMATED_GAS_SAFETY_RATE = exports.ERC20_TRANSFER_EVENT_TOPIC = exports.SYNTHETIC_BLOCK_WINDOW_SECONDS = exports.DEFAULT_TINYBAR_FEE = exports.TINYBAR_SCALE = exports.HEDERA_OPERATION_TYPES = exports.HEDERA_TRANSACTION_NAMES = exports.HEDERA_TRANSACTION_MODES = void 0;
const bignumber_js_1 = __importDefault(require("bignumber.js"));
/**
* Internal types to distinguish custom Hedera transaction behaviors.
* These can be used in transaction.mode and used to route specific preparation logic.
*/
var HEDERA_TRANSACTION_MODES;
(function (HEDERA_TRANSACTION_MODES) {
HEDERA_TRANSACTION_MODES["Send"] = "send";
HEDERA_TRANSACTION_MODES["TokenAssociate"] = "token-associate";
HEDERA_TRANSACTION_MODES["Delegate"] = "delegate";
HEDERA_TRANSACTION_MODES["Undelegate"] = "undelegate";
HEDERA_TRANSACTION_MODES["Redelegate"] = "redelegate";
HEDERA_TRANSACTION_MODES["ClaimRewards"] = "claim-rewards";
})(HEDERA_TRANSACTION_MODES || (exports.HEDERA_TRANSACTION_MODES = HEDERA_TRANSACTION_MODES = {}));
/**
* Enum representing Hedera transaction names used in the Hedera Mirror Node API.
*/
var HEDERA_TRANSACTION_NAMES;
(function (HEDERA_TRANSACTION_NAMES) {
HEDERA_TRANSACTION_NAMES["ContractCall"] = "CONTRACTCALL";
HEDERA_TRANSACTION_NAMES["UpdateAccount"] = "CRYPTOUPDATEACCOUNT";
})(HEDERA_TRANSACTION_NAMES || (exports.HEDERA_TRANSACTION_NAMES = HEDERA_TRANSACTION_NAMES = {}));
/**
* Enum representing the supported Hedera operation types for fee estimation
*/
var HEDERA_OPERATION_TYPES;
(function (HEDERA_OPERATION_TYPES) {
HEDERA_OPERATION_TYPES["CryptoUpdate"] = "CryptoUpdate";
HEDERA_OPERATION_TYPES["CryptoTransfer"] = "CryptoTransfer";
HEDERA_OPERATION_TYPES["TokenTransfer"] = "TokenTransfer";
HEDERA_OPERATION_TYPES["TokenAssociate"] = "TokenAssociate";
HEDERA_OPERATION_TYPES["ContractCall"] = "ContractCall";
})(HEDERA_OPERATION_TYPES || (exports.HEDERA_OPERATION_TYPES = HEDERA_OPERATION_TYPES = {}));
exports.TINYBAR_SCALE = 8;
// old value moved from https://github.com/LedgerHQ/ledger-live/blob/8447b68b7c6f1e7ccd4aa9db4da0e6c8de36a88e/libs/coin-modules/coin-hedera/src/bridge/utils.ts#L77
exports.DEFAULT_TINYBAR_FEE = 150200;
exports.SYNTHETIC_BLOCK_WINDOW_SECONDS = 10;
exports.ERC20_TRANSFER_EVENT_TOPIC = "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef";
exports.ESTIMATED_GAS_SAFETY_RATE = 1.2;
exports.ESTIMATED_FEE_SAFETY_RATE = 2;
exports.DEFAULT_GAS_LIMIT = new bignumber_js_1.default(100_000);
exports.DEFAULT_GAS_PRICE_TINYBARS = new bignumber_js_1.default(100);
exports.HEDERA_MAINNET_CHAIN_ID = 295;
exports.TRANSACTION_VALID_DURATION_SECONDS = 180;
exports.HARDCODED_BLOCK_HEIGHT = 10;
/**
* On Hedera, transactions are not appended to a global chain of immutable blocks. Instead, each consensus node
* publishes its own transactions stream, and mirrornode publishes transactions data as it receives it from each
* consensus node. This leads to a changing transaction history on the window [now - delay of worst node, now].
* This delay has been empirically observed to be maximum 10 seconds (see BACK-10242).
*/
exports.FINALITY_MS = 10_000;
/**
* Enum representing the delegation status of a Hedera account
*/
var HEDERA_DELEGATION_STATUS;
(function (HEDERA_DELEGATION_STATUS) {
HEDERA_DELEGATION_STATUS["Inactive"] = "inactive";
HEDERA_DELEGATION_STATUS["Overstaked"] = "overstaked";
HEDERA_DELEGATION_STATUS["Active"] = "active";
})(HEDERA_DELEGATION_STATUS || (exports.HEDERA_DELEGATION_STATUS = HEDERA_DELEGATION_STATUS = {}));
/**
* https://docs.hedera.com/hedera/networks/mainnet/fees
*
* These are Hedera's estimated fee costs in USD, scaled to tinybars (1 HBAR = 10^8 tinybars),
* so they can be converted into actual HBAR amounts based on current USD/crypto rates.
*
* Used in fee estimation logic (estimateFees function) to determine whether an account
* has sufficient balance to cover the cost of a transaction (e.g. token association).
*/
exports.BASE_USD_FEE_BY_OPERATION_TYPE = {
[HEDERA_OPERATION_TYPES.CryptoUpdate]: 0.00022 * 10 ** exports.TINYBAR_SCALE,
[HEDERA_OPERATION_TYPES.CryptoTransfer]: 0.0001 * 10 ** exports.TINYBAR_SCALE,
[HEDERA_OPERATION_TYPES.TokenTransfer]: 0.001 * 10 ** exports.TINYBAR_SCALE,
[HEDERA_OPERATION_TYPES.TokenAssociate]: 0.05 * 10 ** exports.TINYBAR_SCALE,
[HEDERA_OPERATION_TYPES.ContractCall]: 0, // Contract call fees are based on gas used and are handled separately
};
/**
* Array of supported ERC20 token IDs for Hedera.
*
* This is a temporary solution to allow bypassing deprecated methods.
* It is essential to update this list in the future to ensure support
* for other erc20 tokens.
*
* task that should remove this: https://ledgerhq.atlassian.net/browse/LIVE-24948
*/
exports.SUPPORTED_ERC20_TOKENS = [
{
id: "hedera/erc20/weth_0xca367694cdac8f152e33683bb36cc9d6a73f1ef2",
contractAddress: "0xca367694cdac8f152e33683bb36cc9d6a73f1ef2",
tokenId: "0.0.9470869",
},
{
id: "hedera/erc20/bonzo_atoken_usdc_0xb7687538c7f4cad022d5e97cc778d0b46457c5db",
contractAddress: "0xb7687538c7f4cad022d5e97cc778d0b46457c5db",
tokenId: "0.0.7308496",
},
{
id: "hedera/erc20/audd_0x39ceba2b467fa987546000eb5d1373acf1f3a2e1",
contractAddress: "0x39ceba2b467fa987546000eb5d1373acf1f3a2e1",
tokenId: "0.0.8317070",
},
{
id: "hedera/erc20/wrapped_btc_0xd7d4d91d64a6061fa00a94e2b3a2d2a5fb677849",
contractAddress: "0xd7d4d91d64a6061fa00a94e2b3a2d2a5fb677849",
tokenId: "0.0.10047837",
},
];
exports.MAP_STAKING_MODE_TO_MEMO = {
[HEDERA_TRANSACTION_MODES.ClaimRewards]: "Collect Staking Rewards",
[HEDERA_TRANSACTION_MODES.Delegate]: "Stake",
[HEDERA_TRANSACTION_MODES.Undelegate]: "Unstake",
[HEDERA_TRANSACTION_MODES.Redelegate]: "Restake",
};
exports.MAP_STAKING_MODE_TO_OPERATION_TYPE = {
[HEDERA_TRANSACTION_MODES.Delegate]: "DELEGATE",
[HEDERA_TRANSACTION_MODES.Undelegate]: "UNDELEGATE",
[HEDERA_TRANSACTION_MODES.Redelegate]: "REDELEGATE",
};
exports.MAP_STAKING_MODE_TO_METHOD = {
[HEDERA_TRANSACTION_MODES.Delegate]: "Delegate",
[HEDERA_TRANSACTION_MODES.Undelegate]: "Undelegate",
[HEDERA_TRANSACTION_MODES.Redelegate]: "Redelegate",
[HEDERA_TRANSACTION_MODES.ClaimRewards]: "Claim Rewards",
};
/**
* Operation types where fees should be excluded from value of native HBAR operations.
*/
exports.OP_TYPES_EXCLUDING_FEES = [
"OUT",
"DELEGATE",
"UNDELEGATE",
"REDELEGATE",
"UPDATE_ACCOUNT",
"CONTRACT_CALL",
];
/**
* Suffix used for staking reward Ledger operations to distinguish them from operations that trigger the rewards claim.
* Since staking rewards on Hedera are not represented as separate transactions, we need to create synthetic operations for them.
*/
exports.STAKING_REWARD_HASH_SUFFIX = "-staking-reward";
//# sourceMappingURL=constants.js.map