@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
64 lines • 2.37 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createTransaction = createTransaction;
const bignumber_js_1 = __importDefault(require("bignumber.js"));
function createTransaction(account) {
const currency = account.type === "TokenAccount" ? account.token.parentCurrency : account.currency;
switch (currency.family) {
case "xrp":
case "ripple":
return {
family: currency.family,
amount: (0, bignumber_js_1.default)(0),
recipient: "",
fees: null,
tag: undefined,
};
case "stellar":
return {
family: currency.family,
amount: new bignumber_js_1.default(0),
fees: null,
recipient: "",
memoValue: null,
memoType: null,
useAllAmount: false,
mode: "send",
assetReference: "",
assetOwner: "",
networkInfo: null,
};
case "tezos":
// note: default transaction for tezos, mode will be set by UI (send, stake, unstake)
return {
family: currency.family,
amount: new bignumber_js_1.default(0),
fees: null,
recipient: "",
useAllAmount: false,
mode: "send",
networkInfo: null,
};
case "evm": {
return {
mode: "send",
type: 2,
family: currency.family,
amount: new bignumber_js_1.default(0),
recipient: "",
useAllAmount: false,
feesStrategy: "medium",
chainId: currency.ethereumLikeInfo?.chainId ?? 0,
gasLimit: new bignumber_js_1.default(21000),
maxFeePerGas: new bignumber_js_1.default(0),
maxPriorityFeePerGas: new bignumber_js_1.default(0),
};
}
default:
throw new Error(`Unsupported currency family: ${currency.family}`);
}
}
//# sourceMappingURL=createTransaction.js.map