UNPKG

@accessprotocol/distributor

Version:

Access Protocol Distributor Library

20 lines (19 loc) 1.39 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.newDistributor = newDistributor; const web3_js_1 = require("@solana/web3.js"); const programId_1 = require("../programId"); const spl_token_1 = require("@solana/spl-token"); const spl_token_2 = require("@solana/spl-token"); const MerkleDistributor_1 = require("../accounts/MerkleDistributor"); const spl_token_3 = require("@solana/spl-token"); const raw_instructions_1 = require("../raw_instructions"); /** * Creates a new MerkleDistributor. * After creating this MerkleDistributor, the token_vault should be seeded with max_total_claim tokens. */ function newDistributor(version, root, maxTotalClaim, maxNumNodes, startVestingTs, endVestingTs, mint, creator, programId = programId_1.PROGRAM_ID, systemProgram = web3_js_1.SystemProgram.programId, associatedTokenProgram = spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, tokenProgram = spl_token_2.TOKEN_PROGRAM_ID) { const distributor = MerkleDistributor_1.MerkleDistributor.getAddress(creator, mint, version, programId); const tokenVault = (0, spl_token_3.getAssociatedTokenAddressSync)(mint, distributor, true); return (0, raw_instructions_1.newDistributorRaw)({ version, root, maxTotalClaim, maxNumNodes, startVestingTs, endVestingTs }, { distributor, mint, tokenVault, creator, systemProgram, associatedTokenProgram, tokenProgram }, programId); }