@myria/airdrop-js
Version:
Airdrop in L1 with claim based approach
38 lines (37 loc) • 2.31 kB
TypeScript
/**
* Collection of validation functions
* @module Transaction/Validation
*/
import { ThirdwebContract } from 'thirdweb';
import { Address } from '../type';
/**
* Check whether MerkleTree has already been submitted on-chain or not with the same data to reduce our cost by skipping submitting. Retry safer
*
* @param {ThirdwebContract} airdropContract - The airdrop Thirdweb contract.
* @param {Address} tokenAddress - The token address to claim.
* @param {string} merkleRoot - The generated merkleRoot from whitelist. @see {@link generateMerkleTreeInfoERC20ForWhitelist|Generate merkleRoot}
* @returns {Promise<boolean>} A promise that resolves whether MerkleTree has already been submitted on-chain or not.
*/
export declare const isAlreadySubmittedOnchain: (airdropContract: ThirdwebContract, tokenAddress: Address, merkleRoot: string) => Promise<boolean>;
/**
* Check whether Spender has already been approved allowance on-chain or not to reduce our cost by skipping submitting. Retry safer
*
* @param {Address} owner - The token's owner address.
* @param {Address} spender - The spender's address.
* @param {ThirdwebContract} tokenContract - The airdrop Thirdweb contract.
* @param {number} totalAmount - The total airdrop amount in ether format.
* @param decimals - The number of decimal places to include in the string representation. Default 18
* @returns {Promise<boolean>} A promise that resolves whether Spender has already been approved allowance on-chain or not.
* @throws An error if the totalAmount <= 0.
*/
export declare const isAlreadyApprovedAllowanceOnchain: (owner: Address, spender: Address, tokenContract: ThirdwebContract, totalAmount: number, decimals?: number) => Promise<boolean>;
/**
* Check whether recipient is claimed or not
*
* @param {Address} recipient - The ethereum wallet address to check.
* @param {ThirdwebContract} airdropContract - The airdrop Thirdweb contract.
* @param {Address} token - The token address to claim.
* @param {bigint} claimAmount - The claimAmount or tokenId for ERC721
* @returns {Promise<boolean>} A promise that resolves whether the recipient already claimed or not.
*/
export declare const isRecipientClaimed: (recipient: Address, airdropContract: ThirdwebContract, token: Address, claimAmount?: bigint) => Promise<boolean>;