UNPKG

@augustdigital/sdk

Version:

JS SDK powering the August Digital ecosystem.

51 lines 2.25 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.AugustSDK = void 0; const pools_1 = require("@augustdigital/pools"); const vaults_1 = require("@augustdigital/vaults"); const utils_1 = require("@augustdigital/utils"); class AugustSDK extends utils_1.AugustBase { constructor(baseConfig) { super(baseConfig); this.authorized = true; if (Object.keys(this.providers).length === 0) throw new Error('Must pass at least 1 provider.'); this.pools = new pools_1.default(baseConfig); this.vaults = new vaults_1.default(baseConfig); } switchNetwork(chainId) { this.pools.switchNetwork(chainId); this.vaults.switchNetwork(chainId); } updateWallet(address) { this.monitoring['x-user-id'] = address; this.pools.updateWallet(address); this.vaults.updateWallet(address); } clearWallet() { this.monitoring['x-user-id'] = undefined; this.pools.clearWallet(); this.vaults.clearWallet(); } getPrice(symbol) { return __awaiter(this, void 0, void 0, function* () { var _a; if (!this.authorized) throw new Error('Not authorized.'); if (!symbol) throw new Error(`Symbol input parameter is not defined.`); return yield (0, utils_1.fetchTokenPrice)(symbol, null, (_a = this.keys) === null || _a === void 0 ? void 0 : _a.coingecko); }); } } exports.AugustSDK = AugustSDK; //# sourceMappingURL=main.js.map