diff --git a/libs/ledger-live-common/src/families/stellar/js-buildTransaction.ts b/libs/ledger-live-common/src/families/stellar/js-buildTransaction.ts index 04d9ed443189..c6586f88b032 100644 --- a/libs/ledger-live-common/src/families/stellar/js-buildTransaction.ts +++ b/libs/ledger-live-common/src/families/stellar/js-buildTransaction.ts @@ -1,5 +1,5 @@ import invariant from "invariant"; -import StellarSdk from "stellar-sdk"; +import { Memo, Operation as StellarSdkOperation, xdr } from "stellar-sdk"; import { AmountRequired, FeeNotLoaded, NetworkDown } from "@ledgerhq/errors"; import type { Account } from "@ledgerhq/types-live"; import type { Transaction } from "./types"; @@ -17,10 +17,7 @@ import { StellarAssetRequired, StellarMuxedAccountNotExist } from "../../errors" * @param {Account} a * @param {Transaction} t */ -export const buildTransaction = async ( - account: Account, - transaction: Transaction, -): Promise => { +export const buildTransaction = async (account: Account, transaction: Transaction) => { const { recipient, networkInfo, fees, memoType, memoValue, mode, assetCode, assetIssuer } = transaction; @@ -37,7 +34,7 @@ export const buildTransaction = async ( invariant(networkInfo && networkInfo.family === "stellar", "stellar family"); const transactionBuilder = buildTransactionBuilder(source, fees); - let operation = null; + let operation: xdr.Operation | null = null; if (mode === "changeTrust") { if (!assetCode || !assetIssuer) { @@ -76,24 +73,24 @@ export const buildTransaction = async ( transactionBuilder.addOperation(operation); - let memo = null; + let memo: Memo | null = null; if (memoType && memoValue) { switch (memoType) { case "MEMO_TEXT": - memo = StellarSdk.Memo.text(memoValue); + memo = Memo.text(memoValue); break; case "MEMO_ID": - memo = StellarSdk.Memo.id(memoValue); + memo = Memo.id(memoValue); break; case "MEMO_HASH": - memo = StellarSdk.Memo.hash(memoValue); + memo = Memo.hash(memoValue); break; case "MEMO_RETURN": - memo = StellarSdk.Memo.return(memoValue); + memo = Memo.return(memoValue); break; } } @@ -105,4 +102,5 @@ export const buildTransaction = async ( const built = transactionBuilder.setTimeout(0).build(); return built; }; + export default buildTransaction;