UNPKG

@blockassetlabs/blaze

Version:

Blockasset Blaze

138 lines 6.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.claimPrizeInstruction = exports.resolveBlazeInstruction = exports.redeemEntrantsInstruction = exports.closeBlazeInstruction = exports.updateBlazeInstruction = exports.initBlazeInstruction = exports.initIdentifierInstruction = void 0; const anchor_1 = require("@project-serum/anchor"); const spl_token_1 = require("@solana/spl-token"); const web3_js_1 = require("@solana/web3.js"); const constants_1 = require("./constants"); const initIdentifierInstruction = (connection, wallet, params) => { const provider = new anchor_1.AnchorProvider(connection, wallet, {}); const blazeProgram = new anchor_1.Program(constants_1.BLAZE_IDL, constants_1.BLAZE_ADDRESS, provider); return blazeProgram.methods .initIdentifier() .accounts({ identifier: params.identifierId, payer: wallet.publicKey, systemProgram: web3_js_1.SystemProgram.programId }) .transaction(); }; exports.initIdentifierInstruction = initIdentifierInstruction; const initBlazeInstruction = (connection, wallet, params) => { const provider = new anchor_1.AnchorProvider(connection, wallet, {}); const blazeProgram = new anchor_1.Program(constants_1.BLAZE_IDL, constants_1.BLAZE_ADDRESS, provider); return blazeProgram.methods .initBlaze({ prizeMint: params.prizeMint, tokenMint: params.tokenMint || null, tokenAccount: params.tokenAccount || null, treasury: params.treasury || null, entrantFee: params.entrantFee, maxEntrants: params.maxEntrants, start: params.start, end: params.end, maxEntrantsPerWalletRate: params.maxEntrantsPerWalletRate || null, category: params.category || null, burnRate: params.burnRate || null }) .accounts({ blaze: params.blazeId, identifier: params.identifierId, project: params.projectId, projectWallet: params.projectWallet, blazePrizeMintTokenAccount: params.blazePrizeMintTokenAccount, authority: wallet.publicKey, authorityPrizeMintTokenAccount: params.userPrizeMintTokenAccount, entrants: params.entrants, systemProgram: web3_js_1.SystemProgram.programId, tokenProgram: spl_token_1.TOKEN_PROGRAM_ID }) .transaction(); }; exports.initBlazeInstruction = initBlazeInstruction; const updateBlazeInstruction = (connection, wallet, params) => { const provider = new anchor_1.AnchorProvider(connection, wallet, {}); const blazeProgram = new anchor_1.Program(constants_1.BLAZE_IDL, constants_1.BLAZE_ADDRESS, provider); return blazeProgram.methods .updateBlaze({ tokenMint: params.tokenMint || null, tokenAccount: params.tokenAccount || null, treasury: params.treasury || null, entrantFee: params.entrantFee, start: params.start, end: params.end, maxEntrantsPerWalletRate: params.maxEntrantsPerWalletRate || null, category: params.category || null, burnRate: params.burnRate || null }) .accounts({ blaze: params.blazeId, project: params.projectId, authority: wallet.publicKey }) .transaction(); }; exports.updateBlazeInstruction = updateBlazeInstruction; const closeBlazeInstruction = (connection, wallet, params) => { const provider = new anchor_1.AnchorProvider(connection, wallet, {}); const blazeProgram = new anchor_1.Program(constants_1.BLAZE_IDL, constants_1.BLAZE_ADDRESS, provider); return blazeProgram.methods .closeBlaze() .accounts({ blaze: params.blazeId, project: params.projectId, blazePrizeMintTokenAccount: params.blazePrizeMintTokenAccount, authorityPrizeMintTokenAccount: params.userPrizeMintTokenAccount, entrants: params.entrants, authority: wallet.publicKey, tokenProgram: spl_token_1.TOKEN_PROGRAM_ID }) .transaction(); }; exports.closeBlazeInstruction = closeBlazeInstruction; const redeemEntrantsInstruction = (connection, wallet, params) => { const provider = new anchor_1.AnchorProvider(connection, wallet, {}); const blazeProgram = new anchor_1.Program(constants_1.BLAZE_IDL, constants_1.BLAZE_ADDRESS, provider); return blazeProgram.methods .redeemEntrants(params.quantity) .accounts({ blaze: params.blazeId, entrants: params.entrants, signer: wallet.publicKey, systemProgram: web3_js_1.SystemProgram.programId, tokenProgram: spl_token_1.TOKEN_PROGRAM_ID }) .remainingAccounts(params.remainingAccountsForRedeem) .transaction(); }; exports.redeemEntrantsInstruction = redeemEntrantsInstruction; const resolveBlazeInstruction = (connection, wallet, params) => { const provider = new anchor_1.AnchorProvider(connection, wallet, {}); const blazeProgram = new anchor_1.Program(constants_1.BLAZE_IDL, constants_1.BLAZE_ADDRESS, provider); return blazeProgram.methods .resolveBlaze() .accounts({ blaze: params.blazeId, entrants: params.entrants, recentBlockhashes: web3_js_1.SYSVAR_RECENT_BLOCKHASHES_PUBKEY, tokenProgram: spl_token_1.TOKEN_PROGRAM_ID }) .transaction(); }; exports.resolveBlazeInstruction = resolveBlazeInstruction; const claimPrizeInstruction = (connection, wallet, params) => { const provider = new anchor_1.AnchorProvider(connection, wallet, {}); const blazeProgram = new anchor_1.Program(constants_1.BLAZE_IDL, constants_1.BLAZE_ADDRESS, provider); return blazeProgram.methods .claimPrize() .accounts({ blaze: params.blazeId, blazePrizeMintTokenAccount: params.blazePrizeMintTokenAccount, winnerPrizeMintTokenAccount: params.winnerPrizeMintTokenAccount, winner: wallet.publicKey, tokenProgram: spl_token_1.TOKEN_PROGRAM_ID }) .transaction(); }; exports.claimPrizeInstruction = claimPrizeInstruction; //# sourceMappingURL=instruction.js.map