UNPKG

@citizenwallet/sdk

Version:

An sdk to easily work with citizen wallet.

96 lines 3.33 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.CommunityConfig = void 0; const dotenv_1 = __importDefault(require("dotenv")); dotenv_1.default.config(); class CommunityConfig { constructor(config) { this.config = config; } get primaryToken() { return this.config.tokens[`${this.config.community.primary_token.chain_id}:${this.config.community.primary_token.address}`]; } get primaryNetwork() { return this.config.chains[`${this.primaryToken.chain_id}`]; } get primaryRPCUrl() { const accountConfig = this.primaryAccountConfig; return `${this.primaryNetwork.node.url}/v1/rpc/${accountConfig.paymaster_address}`; } get primaryAccountConfig() { return this.config.accounts[`${this.primaryNetwork.id}:${this.config.community.primary_account_factory.address}`]; } get primarySessionConfig() { if (!this.config.sessions || !this.config.community.primary_session_manager) { throw new Error("No sessions found"); } return this.config.sessions[`${this.primaryNetwork.id}:${this.config.community.primary_session_manager.address}`]; } get primaryCardConfig() { if (!this.config.cards || !this.config.community.primary_card_manager) { throw new Error("No cards found"); } return this.config.cards[`${this.primaryNetwork.id}:${this.config.community.primary_card_manager.address}`]; } get primaryClassicCardConfig() { if (!this.config.cards || !this.config.community.primary_card_manager) { throw new Error("No cards found"); } return this.config.cards[`${this.primaryNetwork.id}:${this.config.community.primary_card_manager.address}`]; } get primarySafeCardConfig() { if (!this.config.cards || !this.config.community.primary_card_manager) { throw new Error("No cards found"); } return this.config.cards[`${this.primaryNetwork.id}:${this.config.community.primary_card_manager.address}`]; } communityUrl(baseDomain) { const { custom_domain, alias } = this.config.community; if (custom_domain && !custom_domain.endsWith(baseDomain)) { return `https://${custom_domain}`; } return `https://${alias}.${baseDomain}`; } get explorer() { return this.config.scan; } get community() { return this.config.community; } get tokens() { return this.config.tokens; } get scan() { return this.config.scan; } get accounts() { return this.config.accounts; } get sessions() { return this.config.sessions; } get cards() { return this.config.cards; } get chains() { return this.config.chains; } get ipfs() { return this.config.ipfs; } get plugins() { return this.config.plugins; } get configLocation() { return this.config.config_location; } get version() { return this.config.version; } } exports.CommunityConfig = CommunityConfig; //# sourceMappingURL=index.js.map