From 9451c70c265f9434d09403ff3ecbb53867335f8d Mon Sep 17 00:00:00 2001 From: Saurabh Chauhan <36479565+starc007@users.noreply.github.com> Date: Fri, 21 Oct 2022 16:36:47 +0530 Subject: [PATCH] Delete dist directory --- dist/bundle.es5.js | 414 --------------------------- dist/bundle.umd.js | 422 ---------------------------- dist/lib/Auth/_metamask.js | 202 ------------- dist/lib/Auth/_metamask.js.map | 1 - dist/lib/Auth/_walletConnect.js | 210 -------------- dist/lib/Auth/_walletConnect.js.map | 1 - dist/lib/Error/ErrorHandler.js | 28 -- dist/lib/Error/ErrorHandler.js.map | 1 - dist/lib/index.js | 15 - dist/lib/index.js.map | 1 - dist/types/Auth/_metamask.d.ts | 23 -- dist/types/Auth/_walletConnect.d.ts | 25 -- dist/types/Error/ErrorHandler.d.ts | 1 - dist/types/index.d.ts | 7 - 14 files changed, 1351 deletions(-) delete mode 100644 dist/bundle.es5.js delete mode 100644 dist/bundle.umd.js delete mode 100644 dist/lib/Auth/_metamask.js delete mode 100644 dist/lib/Auth/_metamask.js.map delete mode 100644 dist/lib/Auth/_walletConnect.js delete mode 100644 dist/lib/Auth/_walletConnect.js.map delete mode 100644 dist/lib/Error/ErrorHandler.js delete mode 100644 dist/lib/Error/ErrorHandler.js.map delete mode 100644 dist/lib/index.js delete mode 100644 dist/lib/index.js.map delete mode 100644 dist/types/Auth/_metamask.d.ts delete mode 100644 dist/types/Auth/_walletConnect.d.ts delete mode 100644 dist/types/Error/ErrorHandler.d.ts delete mode 100644 dist/types/index.d.ts diff --git a/dist/bundle.es5.js b/dist/bundle.es5.js deleted file mode 100644 index 9427cd6..0000000 --- a/dist/bundle.es5.js +++ /dev/null @@ -1,414 +0,0 @@ -import { ethers as ethers$1 } from 'ethers'; -import WalletConnectProvider from '@walletconnect/web3-provider'; - -/****************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */ - -function __awaiter(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()); - }); -} - -function __generator(thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -} - -var ErrorHandler = function (error) { - var msg = ""; - if (error.code === 4001) { - msg = "Request rejected. Please accept to continue."; - } - else if (error.code === 4100) { - msg = "Account is inaccessible. Please unlock your account."; - } - else if (error.code === 4902) { - msg = "Network is not supported. Please add the network manually."; - } - else if (error.code === -32002) { - msg = - "Network switch request is already pending, please approve the request on your wallet."; - } - else if (error.code === "SERVER_ERROR") { - msg = "Please switch network in your wallet manually."; - } - else { - msg = "error: " + error.message || "Something is wrong. Try reloading!"; - } - return msg; -}; - -var Metamask = /** @class */ (function () { - function Metamask() { - this._provider = null; - this._initMM(); - } - Metamask.prototype._initMM = function () { - var _a = window, ethereum = _a.ethereum, web3 = _a.web3; - if (ethereum != undefined) { - this._provider = new ethers$1.providers.Web3Provider(ethereum); - } - else if (web3 != undefined) { - this._provider = new ethers$1.providers.Web3Provider(web3.currentProvider); - } - else { - console.log("Metamask install karle BSDK"); - this._provider = null; - } - }; - Metamask.prototype._connectMM = function () { - return __awaiter(this, void 0, void 0, function () { - var accounts, network, err_1; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - _a.trys.push([0, 3, , 4]); - if (!this._provider) - this._initMM(); - return [4 /*yield*/, this._provider.send("eth_requestAccounts", [])]; - case 1: - accounts = _a.sent(); - return [4 /*yield*/, this._provider.getNetwork()]; - case 2: - network = _a.sent(); - return [2 /*return*/, { - message: "Wallet connected", - success: true, - address: accounts[0], - chainId: network.chainId, - }]; - case 3: - err_1 = _a.sent(); - return [2 /*return*/, { - message: ErrorHandler(err_1), - success: false, - address: null, - chainId: null, - }]; - case 4: return [2 /*return*/]; - } - }); - }); - }; - Metamask.prototype.onNetworkChange = function (callback) { - var ethereum = window.ethereum; - if (!ethereum) - return; - ethereum.on("chainChanged", function (chainId) { - callback(chainId); - }); - }; - Metamask.prototype.onAccountChange = function (callback) { - var ethereum = window.ethereum; - if (!ethereum) - return; - ethereum.on("accountsChanged", function (accounts) { - callback(accounts); - }); - }; - Metamask.prototype._signMessage = function (message) { - return __awaiter(this, void 0, void 0, function () { - var signer, err_2; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - _a.trys.push([0, 2, , 3]); - signer = this._provider.getSigner(); - return [4 /*yield*/, signer.signMessage(message)]; - case 1: - _a.sent(); - return [2 /*return*/, { - message: "Message signed", - success: true, - }]; - case 2: - err_2 = _a.sent(); - return [2 /*return*/, { - message: ErrorHandler(err_2), - success: false, - }]; - case 3: return [2 /*return*/]; - } - }); - }); - }; - Metamask.prototype.removeListeners = function () { - var ethereum = window.ethereum; - if (ethereum && "removeAllListeners" in ethereum) { - ethereum.removeAllListeners(); - } - }; - Metamask.prototype.getProviderMM = function () { - return this._provider; - }; - Metamask.prototype._switchNetwork = function (chainId) { - return __awaiter(this, void 0, void 0, function () { - var error_1; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - if (isNaN(chainId)) - return [2 /*return*/, { success: false, message: "Invalid chainId" }]; - _a.label = 1; - case 1: - _a.trys.push([1, 3, , 4]); - return [4 /*yield*/, this._provider.send("wallet_switchEthereumChain", [ - { - chainId: "0x".concat(chainId.toString(16)), - }, - ])]; - case 2: - _a.sent(); - return [2 /*return*/, { - message: "Network switched", - success: true, - }]; - case 3: - error_1 = _a.sent(); - if (error_1.code === 4902) { - return [2 /*return*/, { - message: ErrorHandler(error_1), - success: false, - }]; - } - else if (error_1.code === -32002) { - return [2 /*return*/, { - success: false, - message: ErrorHandler(error_1), - }]; - } - else if (error_1.code === "SERVER_ERROR") { - return [2 /*return*/, { - success: false, - message: ErrorHandler(error_1), - }]; - } - else { - return [2 /*return*/, { - success: false, - message: ErrorHandler(error_1), - }]; - } - case 4: return [2 /*return*/]; - } - }); - }); - }; - return Metamask; -}()); - -var WalletConnect = /** @class */ (function () { - function WalletConnect(_a) { - var rpc = _a.rpc; - this.rpc = rpc; - this._provider = null; - this._web3Provider = null; - this._initWC(); - } - WalletConnect.prototype._initWC = function () { - this._provider = new WalletConnectProvider({ - rpc: this.rpc, - qrcodeModalOptions: { - mobileLinks: ["rainbow", "metamask", "trust"], - }, - }); - this._web3Provider = new ethers$1.providers.Web3Provider(this._provider); - }; - WalletConnect.prototype._connectWC = function () { - return __awaiter(this, void 0, void 0, function () { - var signer, address, chainId, err_1; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - _a.trys.push([0, 4, , 5]); - // Enable session (triggers QR Code modal) - if (!this._provider) - this._initWC(); - return [4 /*yield*/, this._provider.enable()]; - case 1: - _a.sent(); - signer = this._web3Provider.getSigner(); - return [4 /*yield*/, signer.getAddress()]; - case 2: - address = _a.sent(); - return [4 /*yield*/, this._web3Provider.getNetwork()]; - case 3: - chainId = _a.sent(); - return [2 /*return*/, { - message: "Wallet connected", - success: true, - address: address, - chainId: chainId.chainId, - }]; - case 4: - err_1 = _a.sent(); - return [2 /*return*/, { - message: ErrorHandler(err_1), - success: false, - address: null, - chainId: null, - }]; - case 5: return [2 /*return*/]; - } - }); - }); - }; - WalletConnect.prototype._disconnectWC = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this._provider.disconnect()]; - case 1: - _a.sent(); - this._provider = null; - return [2 /*return*/]; - } - }); - }); - }; - WalletConnect.prototype.onNetworkChange = function (callback) { - this._provider.on("chainChanged", function (chainId) { - callback(chainId); - }); - }; - WalletConnect.prototype.onAccountChange = function (callback) { - this._provider.on("accountsChanged", function (accounts) { - callback(accounts); - }); - }; - WalletConnect.prototype._signMessage = function (message) { - return __awaiter(this, void 0, void 0, function () { - var signer, err_2; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - _a.trys.push([0, 2, , 3]); - signer = this._web3Provider.getSigner(); - return [4 /*yield*/, signer.signMessage(message)]; - case 1: - _a.sent(); - return [2 /*return*/, { - success: true, - message: "Message signed", - }]; - case 2: - err_2 = _a.sent(); - return [2 /*return*/, { - success: false, - message: ErrorHandler(err_2), - }]; - case 3: return [2 /*return*/]; - } - }); - }); - }; - WalletConnect.prototype.getProviderWC = function () { - return this._web3Provider; - }; - WalletConnect.prototype._switchNetwork = function (chainId) { - return __awaiter(this, void 0, void 0, function () { - var id, error_1; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - if (isNaN(chainId)) - return [2 /*return*/, { success: false, message: "Invalid chainId" }]; - _a.label = 1; - case 1: - _a.trys.push([1, 3, , 4]); - id = "0x".concat(chainId.toString(16)); - return [4 /*yield*/, this._web3Provider.send("wallet_switchEthereumChain", [ - { - chainId: id, - }, - ])]; - case 2: - _a.sent(); - this._initWC(); - return [2 /*return*/, { - message: "Network switched", - success: true, - }]; - case 3: - error_1 = _a.sent(); - if (error_1.code === 4902) { - return [2 /*return*/, { - message: ErrorHandler(error_1), - success: false, - }]; - } - else if (error_1.code === -32002) { - return [2 /*return*/, { - success: false, - message: ErrorHandler(error_1), - }]; - } - else if (error_1.code === "SERVER_ERROR") { - return [2 /*return*/, { - success: false, - message: ErrorHandler(error_1), - }]; - } - else { - return [2 /*return*/, { - success: false, - message: ErrorHandler(error_1), - }]; - } - case 4: return [2 /*return*/]; - } - }); - }); - }; - return WalletConnect; -}()); - -function useContract(contractAddress, abi, provider) { - var contract = new ethers$1.Contract(contractAddress, abi, provider); - return contract; -} -var useMetamask = Metamask; -var useWalletConnect = WalletConnect; -var ethers = ethers$1; - -export { ethers, useContract, useMetamask, useWalletConnect }; diff --git a/dist/bundle.umd.js b/dist/bundle.umd.js deleted file mode 100644 index 1937104..0000000 --- a/dist/bundle.umd.js +++ /dev/null @@ -1,422 +0,0 @@ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('ethers'), require('@walletconnect/web3-provider')) : - typeof define === 'function' && define.amd ? define(['exports', 'ethers', '@walletconnect/web3-provider'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Auth = {}, global.ethers, global.WalletConnectProvider)); -})(this, (function (exports, ethers$1, WalletConnectProvider) { 'use strict'; - - /****************************************************************************** - Copyright (c) Microsoft Corporation. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - PERFORMANCE OF THIS SOFTWARE. - ***************************************************************************** */ - - function __awaiter(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()); - }); - } - - function __generator(thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } - } - - var ErrorHandler = function (error) { - var msg = ""; - if (error.code === 4001) { - msg = "Request rejected. Please accept to continue."; - } - else if (error.code === 4100) { - msg = "Account is inaccessible. Please unlock your account."; - } - else if (error.code === 4902) { - msg = "Network is not supported. Please add the network manually."; - } - else if (error.code === -32002) { - msg = - "Network switch request is already pending, please approve the request on your wallet."; - } - else if (error.code === "SERVER_ERROR") { - msg = "Please switch network in your wallet manually."; - } - else { - msg = "error: " + error.message || "Something is wrong. Try reloading!"; - } - return msg; - }; - - var Metamask = /** @class */ (function () { - function Metamask() { - this._provider = null; - this._initMM(); - } - Metamask.prototype._initMM = function () { - var _a = window, ethereum = _a.ethereum, web3 = _a.web3; - if (ethereum != undefined) { - this._provider = new ethers$1.ethers.providers.Web3Provider(ethereum); - } - else if (web3 != undefined) { - this._provider = new ethers$1.ethers.providers.Web3Provider(web3.currentProvider); - } - else { - console.log("Metamask install karle BSDK"); - this._provider = null; - } - }; - Metamask.prototype._connectMM = function () { - return __awaiter(this, void 0, void 0, function () { - var accounts, network, err_1; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - _a.trys.push([0, 3, , 4]); - if (!this._provider) - this._initMM(); - return [4 /*yield*/, this._provider.send("eth_requestAccounts", [])]; - case 1: - accounts = _a.sent(); - return [4 /*yield*/, this._provider.getNetwork()]; - case 2: - network = _a.sent(); - return [2 /*return*/, { - message: "Wallet connected", - success: true, - address: accounts[0], - chainId: network.chainId, - }]; - case 3: - err_1 = _a.sent(); - return [2 /*return*/, { - message: ErrorHandler(err_1), - success: false, - address: null, - chainId: null, - }]; - case 4: return [2 /*return*/]; - } - }); - }); - }; - Metamask.prototype.onNetworkChange = function (callback) { - var ethereum = window.ethereum; - if (!ethereum) - return; - ethereum.on("chainChanged", function (chainId) { - callback(chainId); - }); - }; - Metamask.prototype.onAccountChange = function (callback) { - var ethereum = window.ethereum; - if (!ethereum) - return; - ethereum.on("accountsChanged", function (accounts) { - callback(accounts); - }); - }; - Metamask.prototype._signMessage = function (message) { - return __awaiter(this, void 0, void 0, function () { - var signer, err_2; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - _a.trys.push([0, 2, , 3]); - signer = this._provider.getSigner(); - return [4 /*yield*/, signer.signMessage(message)]; - case 1: - _a.sent(); - return [2 /*return*/, { - message: "Message signed", - success: true, - }]; - case 2: - err_2 = _a.sent(); - return [2 /*return*/, { - message: ErrorHandler(err_2), - success: false, - }]; - case 3: return [2 /*return*/]; - } - }); - }); - }; - Metamask.prototype.removeListeners = function () { - var ethereum = window.ethereum; - if (ethereum && "removeAllListeners" in ethereum) { - ethereum.removeAllListeners(); - } - }; - Metamask.prototype.getProviderMM = function () { - return this._provider; - }; - Metamask.prototype._switchNetwork = function (chainId) { - return __awaiter(this, void 0, void 0, function () { - var error_1; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - if (isNaN(chainId)) - return [2 /*return*/, { success: false, message: "Invalid chainId" }]; - _a.label = 1; - case 1: - _a.trys.push([1, 3, , 4]); - return [4 /*yield*/, this._provider.send("wallet_switchEthereumChain", [ - { - chainId: "0x".concat(chainId.toString(16)), - }, - ])]; - case 2: - _a.sent(); - return [2 /*return*/, { - message: "Network switched", - success: true, - }]; - case 3: - error_1 = _a.sent(); - if (error_1.code === 4902) { - return [2 /*return*/, { - message: ErrorHandler(error_1), - success: false, - }]; - } - else if (error_1.code === -32002) { - return [2 /*return*/, { - success: false, - message: ErrorHandler(error_1), - }]; - } - else if (error_1.code === "SERVER_ERROR") { - return [2 /*return*/, { - success: false, - message: ErrorHandler(error_1), - }]; - } - else { - return [2 /*return*/, { - success: false, - message: ErrorHandler(error_1), - }]; - } - case 4: return [2 /*return*/]; - } - }); - }); - }; - return Metamask; - }()); - - var WalletConnect = /** @class */ (function () { - function WalletConnect(_a) { - var rpc = _a.rpc; - this.rpc = rpc; - this._provider = null; - this._web3Provider = null; - this._initWC(); - } - WalletConnect.prototype._initWC = function () { - this._provider = new WalletConnectProvider({ - rpc: this.rpc, - qrcodeModalOptions: { - mobileLinks: ["rainbow", "metamask", "trust"], - }, - }); - this._web3Provider = new ethers$1.ethers.providers.Web3Provider(this._provider); - }; - WalletConnect.prototype._connectWC = function () { - return __awaiter(this, void 0, void 0, function () { - var signer, address, chainId, err_1; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - _a.trys.push([0, 4, , 5]); - // Enable session (triggers QR Code modal) - if (!this._provider) - this._initWC(); - return [4 /*yield*/, this._provider.enable()]; - case 1: - _a.sent(); - signer = this._web3Provider.getSigner(); - return [4 /*yield*/, signer.getAddress()]; - case 2: - address = _a.sent(); - return [4 /*yield*/, this._web3Provider.getNetwork()]; - case 3: - chainId = _a.sent(); - return [2 /*return*/, { - message: "Wallet connected", - success: true, - address: address, - chainId: chainId.chainId, - }]; - case 4: - err_1 = _a.sent(); - return [2 /*return*/, { - message: ErrorHandler(err_1), - success: false, - address: null, - chainId: null, - }]; - case 5: return [2 /*return*/]; - } - }); - }); - }; - WalletConnect.prototype._disconnectWC = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this._provider.disconnect()]; - case 1: - _a.sent(); - this._provider = null; - return [2 /*return*/]; - } - }); - }); - }; - WalletConnect.prototype.onNetworkChange = function (callback) { - this._provider.on("chainChanged", function (chainId) { - callback(chainId); - }); - }; - WalletConnect.prototype.onAccountChange = function (callback) { - this._provider.on("accountsChanged", function (accounts) { - callback(accounts); - }); - }; - WalletConnect.prototype._signMessage = function (message) { - return __awaiter(this, void 0, void 0, function () { - var signer, err_2; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - _a.trys.push([0, 2, , 3]); - signer = this._web3Provider.getSigner(); - return [4 /*yield*/, signer.signMessage(message)]; - case 1: - _a.sent(); - return [2 /*return*/, { - success: true, - message: "Message signed", - }]; - case 2: - err_2 = _a.sent(); - return [2 /*return*/, { - success: false, - message: ErrorHandler(err_2), - }]; - case 3: return [2 /*return*/]; - } - }); - }); - }; - WalletConnect.prototype.getProviderWC = function () { - return this._web3Provider; - }; - WalletConnect.prototype._switchNetwork = function (chainId) { - return __awaiter(this, void 0, void 0, function () { - var id, error_1; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - if (isNaN(chainId)) - return [2 /*return*/, { success: false, message: "Invalid chainId" }]; - _a.label = 1; - case 1: - _a.trys.push([1, 3, , 4]); - id = "0x".concat(chainId.toString(16)); - return [4 /*yield*/, this._web3Provider.send("wallet_switchEthereumChain", [ - { - chainId: id, - }, - ])]; - case 2: - _a.sent(); - this._initWC(); - return [2 /*return*/, { - message: "Network switched", - success: true, - }]; - case 3: - error_1 = _a.sent(); - if (error_1.code === 4902) { - return [2 /*return*/, { - message: ErrorHandler(error_1), - success: false, - }]; - } - else if (error_1.code === -32002) { - return [2 /*return*/, { - success: false, - message: ErrorHandler(error_1), - }]; - } - else if (error_1.code === "SERVER_ERROR") { - return [2 /*return*/, { - success: false, - message: ErrorHandler(error_1), - }]; - } - else { - return [2 /*return*/, { - success: false, - message: ErrorHandler(error_1), - }]; - } - case 4: return [2 /*return*/]; - } - }); - }); - }; - return WalletConnect; - }()); - - function useContract(contractAddress, abi, provider) { - var contract = new ethers$1.ethers.Contract(contractAddress, abi, provider); - return contract; - } - var useMetamask = Metamask; - var useWalletConnect = WalletConnect; - var ethers = ethers$1.ethers; - - exports.ethers = ethers; - exports.useContract = useContract; - exports.useMetamask = useMetamask; - exports.useWalletConnect = useWalletConnect; - -})); diff --git a/dist/lib/Auth/_metamask.js b/dist/lib/Auth/_metamask.js deleted file mode 100644 index e5edab5..0000000 --- a/dist/lib/Auth/_metamask.js +++ /dev/null @@ -1,202 +0,0 @@ -"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()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Metamask = void 0; -var ethers_1 = require("ethers"); -var ErrorHandler_1 = require("../Error/ErrorHandler"); -var Metamask = /** @class */ (function () { - function Metamask() { - this._provider = null; - this._initMM(); - } - Metamask.prototype._initMM = function () { - var _a = window, ethereum = _a.ethereum, web3 = _a.web3; - if (ethereum != undefined) { - this._provider = new ethers_1.ethers.providers.Web3Provider(ethereum); - } - else if (web3 != undefined) { - this._provider = new ethers_1.ethers.providers.Web3Provider(web3.currentProvider); - } - else { - console.log("Metamask install karle BSDK"); - this._provider = null; - } - }; - Metamask.prototype._connectMM = function () { - return __awaiter(this, void 0, void 0, function () { - var accounts, network, err_1; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - _a.trys.push([0, 3, , 4]); - if (!this._provider) - this._initMM(); - return [4 /*yield*/, this._provider.send("eth_requestAccounts", [])]; - case 1: - accounts = _a.sent(); - return [4 /*yield*/, this._provider.getNetwork()]; - case 2: - network = _a.sent(); - return [2 /*return*/, { - message: "Wallet connected", - success: true, - address: accounts[0], - chainId: network.chainId, - }]; - case 3: - err_1 = _a.sent(); - return [2 /*return*/, { - message: (0, ErrorHandler_1.ErrorHandler)(err_1), - success: false, - address: null, - chainId: null, - }]; - case 4: return [2 /*return*/]; - } - }); - }); - }; - Metamask.prototype.onNetworkChange = function (callback) { - var ethereum = window.ethereum; - if (!ethereum) - return; - ethereum.on("chainChanged", function (chainId) { - callback(chainId); - }); - }; - Metamask.prototype.onAccountChange = function (callback) { - var ethereum = window.ethereum; - if (!ethereum) - return; - ethereum.on("accountsChanged", function (accounts) { - callback(accounts); - }); - }; - Metamask.prototype._signMessage = function (message) { - return __awaiter(this, void 0, void 0, function () { - var signer, err_2; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - _a.trys.push([0, 2, , 3]); - signer = this._provider.getSigner(); - return [4 /*yield*/, signer.signMessage(message)]; - case 1: - _a.sent(); - return [2 /*return*/, { - message: "Message signed", - success: true, - }]; - case 2: - err_2 = _a.sent(); - return [2 /*return*/, { - message: (0, ErrorHandler_1.ErrorHandler)(err_2), - success: false, - }]; - case 3: return [2 /*return*/]; - } - }); - }); - }; - Metamask.prototype.removeListeners = function () { - var ethereum = window.ethereum; - if (ethereum && "removeAllListeners" in ethereum) { - ethereum.removeAllListeners(); - } - }; - Metamask.prototype.getProviderMM = function () { - return this._provider; - }; - Metamask.prototype._switchNetwork = function (chainId) { - return __awaiter(this, void 0, void 0, function () { - var error_1; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - if (isNaN(chainId)) - return [2 /*return*/, { success: false, message: "Invalid chainId" }]; - _a.label = 1; - case 1: - _a.trys.push([1, 3, , 4]); - return [4 /*yield*/, this._provider.send("wallet_switchEthereumChain", [ - { - chainId: "0x".concat(chainId.toString(16)), - }, - ])]; - case 2: - _a.sent(); - return [2 /*return*/, { - message: "Network switched", - success: true, - }]; - case 3: - error_1 = _a.sent(); - if (error_1.code === 4902) { - return [2 /*return*/, { - message: (0, ErrorHandler_1.ErrorHandler)(error_1), - success: false, - }]; - } - else if (error_1.code === -32002) { - return [2 /*return*/, { - success: false, - message: (0, ErrorHandler_1.ErrorHandler)(error_1), - }]; - } - else if (error_1.code === "SERVER_ERROR") { - return [2 /*return*/, { - success: false, - message: (0, ErrorHandler_1.ErrorHandler)(error_1), - }]; - } - else { - return [2 /*return*/, { - success: false, - message: (0, ErrorHandler_1.ErrorHandler)(error_1), - }]; - } - return [3 /*break*/, 4]; - case 4: return [2 /*return*/]; - } - }); - }); - }; - return Metamask; -}()); -exports.Metamask = Metamask; -//# sourceMappingURL=_metamask.js.map \ No newline at end of file diff --git a/dist/lib/Auth/_metamask.js.map b/dist/lib/Auth/_metamask.js.map deleted file mode 100644 index b385751..0000000 --- a/dist/lib/Auth/_metamask.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"_metamask.js","sourceRoot":"","sources":["../../../src/Auth/_metamask.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAAgC;AAChC,sDAAqD;AAErD;IAEE;QACE,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,OAAO,EAAE,CAAC;IACjB,CAAC;IAEO,0BAAO,GAAf;QACQ,IAAA,KAAqB,MAAa,EAAhC,QAAQ,cAAA,EAAE,IAAI,UAAkB,CAAC;QACzC,IAAI,QAAQ,IAAI,SAAS,EAAE;YACzB,IAAI,CAAC,SAAS,GAAG,IAAI,eAAM,CAAC,SAAS,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;SAC9D;aAAM,IAAI,IAAI,IAAI,SAAS,EAAE;YAC5B,IAAI,CAAC,SAAS,GAAG,IAAI,eAAM,CAAC,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;SAC1E;aAAM;YACL,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;YAC3C,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;SACvB;IACH,CAAC;IAEK,6BAAU,GAAhB;;;;;;;wBAEI,IAAI,CAAC,IAAI,CAAC,SAAS;4BAAE,IAAI,CAAC,OAAO,EAAE,CAAC;wBACnB,qBAAM,IAAI,C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,2BAAY,EAAC,OAAK,CAAC;iCAC7B,EAAC;yBACH;6BAAM;4BACL,sBAAO;oCACL,OAAO,EAAE,KAAK;oCACd,OAAO,EAAE,IAAA,2BAAY,EAAC,OAAK,CAAC;iCAC7B,EAAC;yBACH;;;;;;KAEJ;IACH,eAAC;AAAD,CAAC,AAvHD,IAuHC;AAvHY,4BAAQ"} \ No newline at end of file diff --git a/dist/lib/Auth/_walletConnect.js b/dist/lib/Auth/_walletConnect.js deleted file mode 100644 index 516d24c..0000000 --- a/dist/lib/Auth/_walletConnect.js +++ /dev/null @@ -1,210 +0,0 @@ -"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()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.WalletConnect = void 0; -var web3_provider_1 = require("@walletconnect/web3-provider"); -var ethers_1 = require("ethers"); -var ErrorHandler_1 = require("../Error/ErrorHandler"); -var WalletConnect = /** @class */ (function () { - function WalletConnect(_a) { - var rpc = _a.rpc; - this.rpc = rpc; - this._provider = null; - this._web3Provider = null; - this._initWC(); - } - WalletConnect.prototype._initWC = function () { - this._provider = new web3_provider_1.default({ - rpc: this.rpc, - qrcodeModalOptions: { - mobileLinks: ["rainbow", "metamask", "trust"], - }, - }); - this._web3Provider = new ethers_1.ethers.providers.Web3Provider(this._provider); - }; - WalletConnect.prototype._connectWC = function () { - return __awaiter(this, void 0, void 0, function () { - var signer, address, chainId, err_1; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - _a.trys.push([0, 4, , 5]); - // Enable session (triggers QR Code modal) - if (!this._provider) - this._initWC(); - return [4 /*yield*/, this._provider.enable()]; - case 1: - _a.sent(); - signer = this._web3Provider.getSigner(); - return [4 /*yield*/, signer.getAddress()]; - case 2: - address = _a.sent(); - return [4 /*yield*/, this._web3Provider.getNetwork()]; - case 3: - chainId = _a.sent(); - return [2 /*return*/, { - message: "Wallet connected", - success: true, - address: address, - chainId: chainId.chainId, - }]; - case 4: - err_1 = _a.sent(); - return [2 /*return*/, { - message: (0, ErrorHandler_1.ErrorHandler)(err_1), - success: false, - address: null, - chainId: null, - }]; - case 5: return [2 /*return*/]; - } - }); - }); - }; - WalletConnect.prototype._disconnectWC = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this._provider.disconnect()]; - case 1: - _a.sent(); - this._provider = null; - return [2 /*return*/]; - } - }); - }); - }; - WalletConnect.prototype.onNetworkChange = function (callback) { - this._provider.on("chainChanged", function (chainId) { - callback(chainId); - }); - }; - WalletConnect.prototype.onAccountChange = function (callback) { - this._provider.on("accountsChanged", function (accounts) { - callback(accounts); - }); - }; - WalletConnect.prototype._signMessage = function (message) { - return __awaiter(this, void 0, void 0, function () { - var signer, err_2; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - _a.trys.push([0, 2, , 3]); - signer = this._web3Provider.getSigner(); - return [4 /*yield*/, signer.signMessage(message)]; - case 1: - _a.sent(); - return [2 /*return*/, { - success: true, - message: "Message signed", - }]; - case 2: - err_2 = _a.sent(); - return [2 /*return*/, { - success: false, - message: (0, ErrorHandler_1.ErrorHandler)(err_2), - }]; - case 3: return [2 /*return*/]; - } - }); - }); - }; - WalletConnect.prototype.getProviderWC = function () { - return this._web3Provider; - }; - WalletConnect.prototype._switchNetwork = function (chainId) { - return __awaiter(this, void 0, void 0, function () { - var id, error_1; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - if (isNaN(chainId)) - return [2 /*return*/, { success: false, message: "Invalid chainId" }]; - _a.label = 1; - case 1: - _a.trys.push([1, 3, , 4]); - id = "0x".concat(chainId.toString(16)); - return [4 /*yield*/, this._web3Provider.send("wallet_switchEthereumChain", [ - { - chainId: id, - }, - ])]; - case 2: - _a.sent(); - this._initWC(); - return [2 /*return*/, { - message: "Network switched", - success: true, - }]; - case 3: - error_1 = _a.sent(); - if (error_1.code === 4902) { - return [2 /*return*/, { - message: (0, ErrorHandler_1.ErrorHandler)(error_1), - success: false, - }]; - } - else if (error_1.code === -32002) { - return [2 /*return*/, { - success: false, - message: (0, ErrorHandler_1.ErrorHandler)(error_1), - }]; - } - else if (error_1.code === "SERVER_ERROR") { - return [2 /*return*/, { - success: false, - message: (0, ErrorHandler_1.ErrorHandler)(error_1), - }]; - } - else { - return [2 /*return*/, { - success: false, - message: (0, ErrorHandler_1.ErrorHandler)(error_1), - }]; - } - return [3 /*break*/, 4]; - case 4: return [2 /*return*/]; - } - }); - }); - }; - return WalletConnect; -}()); -exports.WalletConnect = WalletConnect; -//# sourceMappingURL=_walletConnect.js.map \ No newline at end of file diff --git a/dist/lib/Auth/_walletConnect.js.map b/dist/lib/Auth/_walletConnect.js.map deleted file mode 100644 index 5b3651c..0000000 --- a/dist/lib/Auth/_walletConnect.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"_walletConnect.js","sourceRoot":"","sources":["../../../src/Auth/_walletConnect.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8DAAiE;AACjE,iCAAgC;AAChC,sDAAqD;AAErD;IAIE,uBAAY,EAAY;YAAV,GAAG,SAAA;QACf,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC1B,IAAI,CAAC,OAAO,EAAE,CAAC;IACjB,CAAC;IAEO,+BAAO,GAAf;QACE,IAAI,CAAC,SAAS,GAAG,IAAI,uBAAqB,CAAC;YACzC,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,kBAAkB,EAAE;gBAClB,WAAW,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,OAAO,CAAC;aAC9C;SACF,CAAC,CAAC;QACH,IAAI,CAAC,aAAa,GAAG,IAAI,eAAM,CAAC,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACzE,CAAC;IAEK,kCAAU,GAAhB;;;;;;;wBAEI,0CAA0C;wBAC1C,IAAI,CAAC,IAAI,CAAC,SAAS;4BAAE,IAA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AAO,EAAE,KAAK;oCACd,OAAO,EAAE,IAAA,2BAAY,EAAC,OAAK,CAAC;iCAC7B,EAAC;yBACH;6BAAM;4BACL,sBAAO;oCACL,OAAO,EAAE,KAAK;oCACd,OAAO,EAAE,IAAA,2BAAY,EAAC,OAAK,CAAC;iCAC7B,EAAC;yBACH;;;;;;KAEJ;IACH,oBAAC;AAAD,CAAC,AAxHD,IAwHC;AAxHY,sCAAa"} \ No newline at end of file diff --git a/dist/lib/Error/ErrorHandler.js b/dist/lib/Error/ErrorHandler.js deleted file mode 100644 index ad99027..0000000 --- a/dist/lib/Error/ErrorHandler.js +++ /dev/null @@ -1,28 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.ErrorHandler = void 0; -var ErrorHandler = function (error) { - var msg = ""; - if (error.code === 4001) { - msg = "Request rejected. Please accept to continue."; - } - else if (error.code === 4100) { - msg = "Account is inaccessible. Please unlock your account."; - } - else if (error.code === 4902) { - msg = "Network is not supported. Please add the network manually."; - } - else if (error.code === -32002) { - msg = - "Network switch request is already pending, please approve the request on your wallet."; - } - else if (error.code === "SERVER_ERROR") { - msg = "Please switch network in your wallet manually."; - } - else { - msg = "error: " + error.message || "Something is wrong. Try reloading!"; - } - return msg; -}; -exports.ErrorHandler = ErrorHandler; -//# sourceMappingURL=ErrorHandler.js.map \ No newline at end of file diff --git a/dist/lib/Error/ErrorHandler.js.map b/dist/lib/Error/ErrorHandler.js.map deleted file mode 100644 index 65f8234..0000000 --- a/dist/lib/Error/ErrorHandler.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"ErrorHandler.js","sourceRoot":"","sources":["../../../src/Error/ErrorHandler.ts"],"names":[],"mappings":";;;AAAO,IAAM,YAAY,GAAG,UAAC,KAAU;IACrC,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,EAAE;QACvB,GAAG,GAAG,8CAA8C,CAAC;KACtD;SAAM,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,EAAE;QAC9B,GAAG,GAAG,sDAAsD,CAAC;KAC9D;SAAM,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,EAAE;QAC9B,GAAG,GAAG,4DAA4D,CAAC;KACpE;SAAM,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,EAAE;QAChC,GAAG;YACD,uFAAuF,CAAC;KAC3F;SAAM,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc,EAAE;QACxC,GAAG,GAAG,gDAAgD,CAAC;KACxD;SAAM;QACL,GAAG,GAAG,SAAS,GAAG,KAAK,CAAC,OAAO,IAAI,oCAAoC,CAAC;KACzE;IACD,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAjBW,QAAA,YAAY,gBAiBvB"} \ No newline at end of file diff --git a/dist/lib/index.js b/dist/lib/index.js deleted file mode 100644 index e2e288f..0000000 --- a/dist/lib/index.js +++ /dev/null @@ -1,15 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.ethers = exports.useWalletConnect = exports.useMetamask = exports.useContract = void 0; -var ethers_1 = require("ethers"); -var _metamask_1 = require("./Auth/_metamask"); -var _walletConnect_1 = require("./Auth/_walletConnect"); -function useContract(contractAddress, abi, provider) { - var contract = new ethers_1.ethers.Contract(contractAddress, abi, provider); - return contract; -} -exports.useContract = useContract; -exports.useMetamask = _metamask_1.Metamask; -exports.useWalletConnect = _walletConnect_1.WalletConnect; -exports.ethers = ethers_1.ethers; -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/lib/index.js.map b/dist/lib/index.js.map deleted file mode 100644 index 6a9f38c..0000000 --- a/dist/lib/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,iCAA2C;AAC3C,8CAA4C;AAC5C,wDAAsD;AACtD,SAAgB,WAAW,CAAC,eAAuB,EAAE,GAAQ,EAAE,QAAa;IAC1E,IAAM,QAAQ,GAAG,IAAI,eAAO,CAAC,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;IACtE,OAAO,QAAQ,CAAC;AAClB,CAAC;AAHD,kCAGC;AAEY,QAAA,WAAW,GAAG,oBAAQ,CAAC;AACvB,QAAA,gBAAgB,GAAG,8BAAa,CAAC;AACjC,QAAA,MAAM,GAAG,eAAO,CAAC"} \ No newline at end of file diff --git a/dist/types/Auth/_metamask.d.ts b/dist/types/Auth/_metamask.d.ts deleted file mode 100644 index c676029..0000000 --- a/dist/types/Auth/_metamask.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -export declare class Metamask { - _provider: any; - constructor(); - private _initMM; - _connectMM(): Promise<{ - message: string; - success: boolean; - address: any; - chainId: any; - }>; - onNetworkChange(callback: (chainId: string) => any): void; - onAccountChange(callback: (accounts: string[]) => any): void; - _signMessage(message: string): Promise<{ - message: string; - success: boolean; - }>; - removeListeners(): void; - getProviderMM(): any; - _switchNetwork(chainId: number): Promise<{ - success: boolean; - message: string; - }>; -} diff --git a/dist/types/Auth/_walletConnect.d.ts b/dist/types/Auth/_walletConnect.d.ts deleted file mode 100644 index fa68c37..0000000 --- a/dist/types/Auth/_walletConnect.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -export declare class WalletConnect { - rpc: any; - _provider: any; - _web3Provider: any; - constructor({ rpc }: any); - private _initWC; - _connectWC(): Promise<{ - message: string; - success: boolean; - address: any; - chainId: any; - }>; - _disconnectWC(): Promise; - onNetworkChange(callback: (chainId: string) => any): void; - onAccountChange(callback: (accounts: string[]) => any): void; - _signMessage(message: string): Promise<{ - success: boolean; - message: string; - }>; - getProviderWC(): any; - _switchNetwork(chainId: number): Promise<{ - success: boolean; - message: string; - }>; -} diff --git a/dist/types/Error/ErrorHandler.d.ts b/dist/types/Error/ErrorHandler.d.ts deleted file mode 100644 index 6016052..0000000 --- a/dist/types/Error/ErrorHandler.d.ts +++ /dev/null @@ -1 +0,0 @@ -export declare const ErrorHandler: (error: any) => string; diff --git a/dist/types/index.d.ts b/dist/types/index.d.ts deleted file mode 100644 index a188204..0000000 --- a/dist/types/index.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { ethers as _ethers } from "ethers"; -import { Metamask } from "./Auth/_metamask"; -import { WalletConnect } from "./Auth/_walletConnect"; -export declare function useContract(contractAddress: string, abi: any, provider: any): _ethers.Contract; -export declare const useMetamask: typeof Metamask; -export declare const useWalletConnect: typeof WalletConnect; -export declare const ethers: typeof _ethers;