Skip to content

Commit

Permalink
update txn
Browse files Browse the repository at this point in the history
  • Loading branch information
Wozacosta committed Jan 13, 2025
1 parent fb813b6 commit 40aac8f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
7 changes: 4 additions & 3 deletions libs/coin-modules/coin-module-boilerplate/src/bridge/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import getAddressWrapper from "@ledgerhq/coin-framework/bridge/getAddressWrapper";
import {
defaultUpdateTransaction,
makeAccountBridgeReceive,
makeScanAccounts,
makeSync,
Expand All @@ -19,6 +18,7 @@ import { getTransactionStatus } from "./getTransactionStatus";
import { prepareTransaction } from "./prepareTransaction";
import { buildSignOperation } from "./signOperation";
import { getAccountShape } from "./sync";
import { updateTransaction } from "./updateTransaction";

export function createBridges(
signerContext: SignerContext<BoilerplateSigner>,
Expand All @@ -42,8 +42,9 @@ export function createBridges(
const accountBridge: AccountBridge<Transaction> = {
broadcast,
createTransaction,
// TODO: maybe give example of updateTransaction and when it's required
updateTransaction: defaultUpdateTransaction<Transaction>,
updateTransaction,
// NOTE: use updateTransaction: defaultUpdateTransaction<Transaction>,
// if you don't need to update the transaction patch object
prepareTransaction,
getTransactionStatus,
estimateMaxSpendable,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { updateTransaction as defaultUpdateTransaction } from "@ledgerhq/coin-framework/bridge/jsHelpers";
import { AccountBridge } from "@ledgerhq/types-live";
import type { Transaction } from "../types";

// NOTE: this method is optional, use defaultUpdateTransaction
// acts as a middleware to update the transaction patch object

// NOTE: here is an example transaction updater function
// in this case, it resets fee to null depending on the patch content
export const updateTransaction: AccountBridge<Transaction>["updateTransaction"] = (tx, patch) => {
if (patch.recipient === "boilerplate1" || true) {
patch = { ...patch, fee: null };
}

return defaultUpdateTransaction(tx, patch);
};

0 comments on commit 40aac8f

Please sign in to comment.