@myria/airdrop-js
Version:
Airdrop in L1 with claim based approach
151 lines • 7.73 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Config = void 0;
/**
* Centralize your configuration in Config class
* @class
*/
class Config {
/**
* private constructor follow singleton design pattern
*
* @param {ConfigOptions} options - optional config object to initialize once if you want
*/
constructor(options) {
this.tokenAddress = options === null || options === void 0 ? void 0 : options.tokenAddress;
this.airdropAddress = options === null || options === void 0 ? void 0 : options.airdropAddress;
this.selectedChain = options === null || options === void 0 ? void 0 : options.selectedChain;
this.extraGasOptions = options === null || options === void 0 ? void 0 : options.extraGasOptions;
this.thirdwebClientId = options === null || options === void 0 ? void 0 : options.thirdwebClientId;
this.thirdwebClientSecret = options === null || options === void 0 ? void 0 : options.thirdwebClientSecret;
this.debug = options === null || options === void 0 ? void 0 : options.debug;
}
/**
* Single entry point to let consumer initial or access the shared access with singleton pattern
*
* @param {ConfigOptions} configOptions - optional config object to initialize once if you want
* @returns {Config} - Return the exiting or create a new one
*/
static getInstance(configOptions) {
if (!Config.instance) {
Config.instance = new Config(configOptions);
}
return Config.instance;
}
// Setters
/**
* Set the tokenAddress
* @param {string} tokenAddress - The token smart contract address
* @returns {Config} - Return the current instance
*/
setTokenAddress(tokenAddress) {
this.tokenAddress = tokenAddress;
return this;
}
/**
* Set the airdropAddress
* @param {string} airdropAddress - The airdrop smart contract address
* @returns {Config} - Return the current instance
*/
setAirdropAddress(airdropAddress) {
this.airdropAddress = airdropAddress;
return this;
}
/**
* Set the selectedChain
* @param {SupportingChain} selectedChain - The selected chain
* @returns {Config} - Return the current instance
*/
setSelectedChain(selectedChain) {
this.selectedChain = selectedChain;
return this;
}
/**
* Set the thirdwebClientId
* @param {string} thirdwebClientId - The thirdweb client id
* @returns {Config} - Return the current instance
*/
setThirdwebClientId(thirdwebClientId) {
this.thirdwebClientId = thirdwebClientId;
return this;
}
/**
* Set the thirdwebClientSecret
* @param {string} thirdwebClientSecret - The thirdweb client secret key
* @returns {Config} - Return the current instance
*/
setThirdwebClientSecret(thirdwebClientSecret) {
this.thirdwebClientSecret = thirdwebClientSecret;
return this;
}
/**
* Set the debug
* @param {boolean} debug - Whether turn on the log to debug or not
* @returns {Config} - Return the current instance
*/
setDebug(debug) {
this.debug = debug;
return this;
}
/**
* Set the extraGasOptions
* @param {ExtraGasOptions} extraGasOptions - Configure the ExtraGasOptions when submitting a transaction
* @returns {Config} - Return the current instance
*/
setExtraGasOptions(extraGasOptions) {
this.extraGasOptions = extraGasOptions;
return this;
}
// Getters
/**
* Get the tokenAddress
* @returns {string} - Return the current tokenAddress
*/
getTokenAddress() {
return this.tokenAddress;
}
/**
* Get the airdropAddress
* @returns {string} - Return the current airdropAddress
*/
getAirdropAddress() {
return this.airdropAddress;
}
/**
* Get the extraGasOptions
* @returns {ExtraGasOptions} - Return the current extraGasOptions
*/
getExtraGasOptions() {
return this.extraGasOptions;
}
/**
* Get the selectedChain
* @returns {SupportingChain} - Return the current selectedChain
*/
getSelectedChain() {
return this.selectedChain;
}
/**
* Get the thirdwebClientId
* @returns {string} - Return the current thirdwebClientId
*/
getThirdwebClientId() {
return this.thirdwebClientId;
}
/**
* Get the thirdwebClientSecret
* @returns {string} - Return the current thirdwebClientSecret
*/
getThirdwebClientSecret() {
return this.thirdwebClientSecret;
}
/**
* Get the debug
* @returns {boolean} - Return the current debug mode
*/
getDebug() {
return this.debug;
}
}
exports.Config = Config;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQ29uZmlnLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NvbmZpZy9Db25maWcudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBS0E7OztHQUdHO0FBQ0gsTUFBYSxNQUFNO0lBVWY7Ozs7T0FJRztJQUNILFlBQW9CLE9BQXVCO1FBQ3ZDLElBQUksQ0FBQyxZQUFZLEdBQUcsT0FBTyxhQUFQLE9BQU8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