lib/contract/basic_node_signer.js

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.basicNodeSigner = void 0;
var _stellarBase = require("@stellar/stellar-base");
/**
 * For use with {@link Client} and {@link AssembledTransaction}.
 * Implements `signTransaction` and `signAuthEntry` with signatures expected by
 * those classes. This is useful for testing and maybe some simple Node
 * applications. Feel free to use this as a starting point for your own
 * Wallet/TransactionSigner implementation.
 */
const basicNodeSigner = (keypair, networkPassphrase) => ({
  // eslint-disable-next-line require-await
  signTransaction: async tx => {
    const t = _stellarBase.TransactionBuilder.fromXDR(tx, networkPassphrase);
    t.sign(keypair);
    return t.toXDR();
  },
  // eslint-disable-next-line require-await
  signAuthEntry: async entryXdr => keypair.sign((0, _stellarBase.hash)(Buffer.from(entryXdr, "base64"))).toString("base64")
});
exports.basicNodeSigner = basicNodeSigner;