@solana/spl-token
Version:
SPL Token Program JS API
42 lines • 2.66 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.approveChecked = approveChecked;
const web3_js_1 = require("@solana/web3.js");
const constants_js_1 = require("../constants.js");
const approveChecked_js_1 = require("../instructions/approveChecked.js");
const internal_js_1 = require("./internal.js");
/**
* Approve a delegate to transfer up to a maximum number of tokens from an account, asserting the token mint and
* decimals
*
* @param connection Connection to use
* @param payer Payer of the transaction fees
* @param mint Address of the mint
* @param account Address of the account
* @param delegate Account authorized to perform a transfer tokens from the source account
* @param owner Owner of the source account
* @param amount Maximum number of tokens the delegate may transfer
* @param decimals Number of decimals in approve amount
* @param multiSigners Signing accounts if `owner` is a multisig
* @param confirmOptions Options for confirming the transaction
* @param programId SPL Token program account
*
* @return Signature of the confirmed transaction
*/
function approveChecked(connection_1, payer_1, mint_1, account_1, delegate_1, owner_1, amount_1, decimals_1) {
return __awaiter(this, arguments, void 0, function* (connection, payer, mint, account, delegate, owner, amount, decimals, multiSigners = [], confirmOptions, programId = constants_js_1.TOKEN_PROGRAM_ID) {
const [ownerPublicKey, signers] = (0, internal_js_1.getSigners)(owner, multiSigners);
const transaction = new web3_js_1.Transaction().add((0, approveChecked_js_1.createApproveCheckedInstruction)(account, mint, delegate, ownerPublicKey, amount, decimals, multiSigners, programId));
return yield (0, web3_js_1.sendAndConfirmTransaction)(connection, transaction, [payer, ...signers], confirmOptions);
});
}
//# sourceMappingURL=approveChecked.js.map