@heliofi/solana-adapter-v1
Version:
API to interact with Helio Finances program on Solana.
37 lines • 1.74 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCancelPaymentTx = void 0;
const web3_js_1 = require("@solana/web3.js");
const spl_token_1 = require("@solana/spl-token");
const config_1 = require("./config");
const getCancelPaymentTx = async (program, req, fee = 0) => {
const [pda] = await web3_js_1.PublicKey.findProgramAddress([req.payment.toBytes()], program.programId);
const mint = req.mintAddress;
const senderTokenAccount = await (0, spl_token_1.getAssociatedTokenAddress)(mint, req.sender);
const recipientTokenAccount = await (0, spl_token_1.getAssociatedTokenAddress)(mint, req.recipient);
const paymentTokenAccount = await (0, spl_token_1.getAssociatedTokenAddress)(mint, req.payment);
const helioFeeTokenAccount = await (0, spl_token_1.getAssociatedTokenAddress)(mint, config_1.helioFeeWalletKey);
const daoFeeTokenAccount = await (0, spl_token_1.getAssociatedTokenAddress)(mint, config_1.daoFeeWalletKey);
const transaction = await program.methods
.cancelPayment()
.accounts({
signer: req.sender,
sender: req.sender,
senderTokenAccount,
recipient: req.recipient,
recipientTokenAccount,
paymentAccount: req.payment,
paymentTokenAccount,
pdaSigner: pda,
helioFeeAccount: config_1.helioFeeWalletKey,
helioFeeTokenAccount,
daoFeeAccount: config_1.daoFeeWalletKey,
daoFeeTokenAccount,
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
systemProgram: web3_js_1.SystemProgram.programId,
})
.transaction();
return transaction;
};
exports.getCancelPaymentTx = getCancelPaymentTx;
//# sourceMappingURL=getCancelPaymentTx.js.map