@ledgerhq/coin-hedera
Version:
Ledger Hedera Coin integration
20 lines • 1.14 kB
JavaScript
import { Transaction as HederaSDKTransaction } from "@hashgraph/sdk";
import { patchOperationWithHash } from "@ledgerhq/coin-framework/operation";
import { base64ToUrlSafeBase64, patchOperationWithExtra } from "./utils";
import { broadcastTransaction } from "../api/network";
export const broadcast = async ({ signedOperation }) => {
const { signature, operation } = signedOperation;
// NOTE: expecting a serialized transaction to be signedOperation.signature (in hex)
const hederaTransaction = HederaSDKTransaction.fromBytes(Buffer.from(signature, "base64"));
const response = await broadcastTransaction(hederaTransaction);
const base64Hash = Buffer.from(response.transactionHash).toString("base64");
const base64HashUrlSafe = base64ToUrlSafeBase64(base64Hash);
const extra = {
transactionId: response.transactionId.toString(),
};
let patchedOperation = operation;
patchedOperation = patchOperationWithHash(patchedOperation, base64HashUrlSafe);
patchedOperation = patchOperationWithExtra(patchedOperation, extra);
return patchedOperation;
};
//# sourceMappingURL=broadcast.js.map