@heliofi/solana-adapter-v1
Version:
API to interact with Helio Finances program on Solana.
35 lines • 1.62 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getWithdrawTx = void 0;
const web3_js_1 = require("@solana/web3.js");
const spl_token_1 = require("@solana/spl-token");
const config_1 = require("./config");
const getWithdrawTx = async (program, req, fee = 0, otherSigner) => {
const [pda] = await web3_js_1.PublicKey.findProgramAddress([req.payment.toBytes()], program.programId);
const mint = req.mintAddress;
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);
console.log('Lib other signer: ', otherSigner);
const transaction = await program.methods
.withdraw()
.accounts({
signer: otherSigner,
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.getWithdrawTx = getWithdrawTx;
//# sourceMappingURL=getWithdrawTx.js.map