@ape.swap/bonds-sdk 1.0.47 → 1.0.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,10 @@
1
1
  /** @jsxImportSource theme-ui */
2
2
  import React from 'react';
3
+ declare global {
4
+ interface Window {
5
+ ethereum?: any;
6
+ }
7
+ }
3
8
  interface BondsProps {
4
9
  connectionString?: string;
5
10
  }
@@ -128,7 +128,7 @@ var Bonds = function (_a) {
128
128
  return 1;
129
129
  }
130
130
  else {
131
- return a.discount - b.discount;
131
+ return b.discount - a.discount;
132
132
  }
133
133
  });
134
134
  return (_jsxs(ThemeUIProvider, __assign({ theme: defaultTheme }, { children: [isActive && account && (_jsx("p", { children: account })), isActive && account && (_jsx("button", __assign({ onClick: handleApprove }, { children: "Approve USDT" }))), _jsxs(Flex, __assign({ className: "container table-container", sx: styles.tableContainer }, { children: [_jsxs(Flex, __assign({ className: "container header-container", sx: styles.headerContainer }, { children: [_jsx(Flex, __assign({ className: "column column-header" }, { children: "Tokens" })), _jsx(Flex, __assign({ className: "column column-header" }, { children: "Discount" })), _jsx(Flex, __assign({ className: "column column-header" }, { children: "ARR" })), _jsx(Flex, __assign({ className: "column column-header" }, { children: "Terms" })), _jsx(Flex, __assign({ className: "column column-header" }, { children: "Tokens Remaining" })), _jsx(Flex, { className: "column column-header" })] })), sortedBonds.map(function (bond) {
package/dist/index.d.ts CHANGED
@@ -1,4 +1,2 @@
1
1
  import Bonds from './components/bonds/Bonds';
2
- import Wallet from './components/wallet/Wallet';
3
- import App from './App';
4
- export { Bonds, Wallet, App };
2
+ export { Bonds };
package/dist/index.js CHANGED
@@ -1,5 +1,3 @@
1
1
  // src/index.ts
2
2
  import Bonds from './components/bonds/Bonds';
3
- import Wallet from './components/wallet/Wallet';
4
- import App from './App';
5
- export { Bonds, Wallet, App };
3
+ export { Bonds };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Ape Bond SDK",
4
4
  "author": "Ape Bond",
5
5
  "license": "MIT",
6
- "version": "1.0.47",
6
+ "version": "1.0.49",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist/index.es.js",
9
9
  "types": "dist/index.d.ts",
package/dist/App.d.ts DELETED
@@ -1,2 +0,0 @@
1
- declare function App(): import("react/jsx-runtime").JSX.Element;
2
- export default App;
package/dist/App.js DELETED
@@ -1,8 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
- import Bonds from './components/bonds/Bonds';
3
- function App() {
4
- // const { chainId, account, isActive } = useWeb3React();
5
- // const [connectionType, setConnectionType] = useState<ConnectionType | null>(null);
6
- return (_jsx(_Fragment, { children: _jsx(Bonds, {}) }));
7
- }
8
- export default App;
@@ -1,9 +0,0 @@
1
- import { ConnectionType } from './connections';
2
- type ConnectOptionsParams = {
3
- activeConnectionType: ConnectionType | null;
4
- isConnectionActive: boolean;
5
- onActivate: (connectionType: ConnectionType) => void;
6
- onDeactivate: (connectionType: null) => void;
7
- };
8
- export declare const ConnectionOptions: ({ activeConnectionType, isConnectionActive, onActivate, onDeactivate, }: ConnectOptionsParams) => import("react/jsx-runtime").JSX.Element;
9
- export {};
@@ -1,26 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
13
- import { ConnectionType, getHasMetaMaskExtensionInstalled } from './connections';
14
- import { METAMASK_URL } from './constants';
15
- import { Option } from './Option';
16
- export var ConnectionOptions = function (_a) {
17
- var activeConnectionType = _a.activeConnectionType, isConnectionActive = _a.isConnectionActive, onActivate = _a.onActivate, onDeactivate = _a.onDeactivate;
18
- function getOptions(isActive) {
19
- var hasMetaMaskExtension = getHasMetaMaskExtensionInstalled();
20
- var isNoOptionActive = !isActive || (isActive && activeConnectionType === null);
21
- var metaMaskOption = hasMetaMaskExtension ? (_jsx(Option, { isEnabled: isNoOptionActive || activeConnectionType === ConnectionType.INJECTED, isConnected: activeConnectionType === ConnectionType.INJECTED, connectionType: ConnectionType.INJECTED, onActivate: onActivate, onDeactivate: onDeactivate })) : (_jsx("a", __assign({ href: METAMASK_URL }, { children: _jsx("button", { children: "Install Metamask" }) })));
22
- var walletConnectOption = (_jsx(Option, { isEnabled: isNoOptionActive || activeConnectionType === ConnectionType.WALLET_CONNECT, isConnected: activeConnectionType === ConnectionType.WALLET_CONNECT, connectionType: ConnectionType.WALLET_CONNECT, onActivate: onActivate, onDeactivate: onDeactivate }));
23
- return (_jsxs(_Fragment, { children: [metaMaskOption, walletConnectOption] }));
24
- }
25
- return _jsx("div", __assign({ className: "connectors" }, { children: getOptions(isConnectionActive) }));
26
- };
@@ -1,8 +0,0 @@
1
- import { ConnectionType } from './connections';
2
- export declare const Option: ({ isEnabled, isConnected, connectionType, onActivate, onDeactivate, }: {
3
- isEnabled: boolean;
4
- isConnected: boolean;
5
- connectionType: ConnectionType;
6
- onActivate: (connectionType: ConnectionType) => void;
7
- onDeactivate: (connectionType: null) => void;
8
- }) => import("react/jsx-runtime").JSX.Element;
@@ -1,81 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
- return new (P || (P = Promise))(function (resolve, reject) {
15
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
- step((generator = generator.apply(thisArg, _arguments || [])).next());
19
- });
20
- };
21
- var __generator = (this && this.__generator) || function (thisArg, body) {
22
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
- function verb(n) { return function (v) { return step([n, v]); }; }
25
- function step(op) {
26
- if (f) throw new TypeError("Generator is already executing.");
27
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
- 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;
29
- if (y = 0, t) op = [op[0] & 2, t.value];
30
- switch (op[0]) {
31
- case 0: case 1: t = op; break;
32
- case 4: _.label++; return { value: op[1], done: false };
33
- case 5: _.label++; y = op[1]; op = [0]; continue;
34
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
- default:
36
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
- if (t[2]) _.ops.pop();
41
- _.trys.pop(); continue;
42
- }
43
- op = body.call(thisArg, _);
44
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
- }
47
- };
48
- import { jsx as _jsx } from "react/jsx-runtime";
49
- import { getConnection, tryActivateConnector, tryDeactivateConnector } from './connections';
50
- export var Option = function (_a) {
51
- var isEnabled = _a.isEnabled, isConnected = _a.isConnected, connectionType = _a.connectionType, onActivate = _a.onActivate, onDeactivate = _a.onDeactivate;
52
- var onClick = function () { return __awaiter(void 0, void 0, void 0, function () {
53
- var deactivation, activation;
54
- return __generator(this, function (_a) {
55
- switch (_a.label) {
56
- case 0:
57
- if (!isConnected) return [3 /*break*/, 2];
58
- return [4 /*yield*/, tryDeactivateConnector(getConnection(connectionType).connector)
59
- // undefined means the deactivation failed
60
- ];
61
- case 1:
62
- deactivation = _a.sent();
63
- // undefined means the deactivation failed
64
- if (deactivation === undefined) {
65
- return [2 /*return*/];
66
- }
67
- onDeactivate(deactivation);
68
- return [2 /*return*/];
69
- case 2: return [4 /*yield*/, tryActivateConnector(getConnection(connectionType).connector)];
70
- case 3:
71
- activation = _a.sent();
72
- if (!activation) {
73
- return [2 /*return*/];
74
- }
75
- onActivate(activation);
76
- return [2 /*return*/];
77
- }
78
- });
79
- }); };
80
- return (_jsx("div", { children: _jsx("button", __assign({ onClick: onClick, disabled: !isEnabled }, { children: "".concat(isConnected ? 'Disconnect' : 'Connect', " ").concat(connectionType) })) }));
81
- };
@@ -1,3 +0,0 @@
1
- import React from 'react';
2
- declare const Wallet: React.FC;
3
- export default Wallet;
@@ -1,10 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useState } from 'react';
3
- import { useWeb3React } from '@web3-react/core';
4
- import { ConnectionOptions } from './ConnectionOptions';
5
- var isActive = useWeb3React().isActive;
6
- var _a = useState(null), connectionType = _a[0], setConnectionType = _a[1];
7
- var Wallet = function () {
8
- return (_jsx(ConnectionOptions, { activeConnectionType: connectionType, isConnectionActive: isActive, onActivate: setConnectionType, onDeactivate: setConnectionType }));
9
- };
10
- export default Wallet;
@@ -1,13 +0,0 @@
1
- export declare enum Chain {
2
- POLYGON = 0,
3
- MAINNET = 1
4
- }
5
- interface ExampleConfig {
6
- chain: Chain;
7
- rpc: {
8
- polygon: string;
9
- mainnet: string;
10
- };
11
- }
12
- export declare const CurrentConfig: ExampleConfig;
13
- export {};
@@ -1,14 +0,0 @@
1
- // Sets if the example should run locally or on chain
2
- export var Chain;
3
- (function (Chain) {
4
- Chain[Chain["POLYGON"] = 0] = "POLYGON";
5
- Chain[Chain["MAINNET"] = 1] = "MAINNET";
6
- })(Chain || (Chain = {}));
7
- // Example Configuration
8
- export var CurrentConfig = {
9
- chain: Chain.MAINNET,
10
- rpc: {
11
- polygon: '',
12
- mainnet: '',
13
- },
14
- };
@@ -1,21 +0,0 @@
1
- import { Web3ReactHooks } from '@web3-react/core';
2
- import { Connector } from '@web3-react/types';
3
- export interface Connection {
4
- connector: Connector;
5
- hooks: Web3ReactHooks;
6
- type: ConnectionType;
7
- }
8
- export declare enum ConnectionType {
9
- INJECTED = "INJECTED",
10
- NETWORK = "NETWORK",
11
- WALLET_CONNECT = "WALLET_CONNECT"
12
- }
13
- export declare function getHasMetaMaskExtensionInstalled(): boolean;
14
- export declare function onConnectionError(error: Error): void;
15
- export declare const PRIORITIZED_CONNECTORS: {
16
- [key in ConnectionType]: Connection;
17
- };
18
- export declare function getConnection(c: Connector | ConnectionType): Connection;
19
- export declare const switchNetwork: (chainId: number, connectionType: ConnectionType | null) => Promise<void>;
20
- export declare const tryActivateConnector: (connector: Connector) => Promise<ConnectionType | undefined>;
21
- export declare const tryDeactivateConnector: (connector: Connector) => Promise<null | undefined>;
@@ -1,133 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
- function verb(n) { return function (v) { return step([n, v]); }; }
14
- function step(op) {
15
- if (f) throw new TypeError("Generator is already executing.");
16
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
- 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;
18
- if (y = 0, t) op = [op[0] & 2, t.value];
19
- switch (op[0]) {
20
- case 0: case 1: t = op; break;
21
- case 4: _.label++; return { value: op[1], done: false };
22
- case 5: _.label++; y = op[1]; op = [0]; continue;
23
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
- default:
25
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
- if (t[2]) _.ops.pop();
30
- _.trys.pop(); continue;
31
- }
32
- op = body.call(thisArg, _);
33
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
- }
36
- };
37
- var _a;
38
- import { Connector } from '@web3-react/types';
39
- import { CHAIN_INFO } from './constants';
40
- import { buildInjectedConnector } from './injected';
41
- import { buildNetworkConnector } from './network';
42
- import { buildWalletConnectConnector } from './wallet-connect';
43
- export var ConnectionType;
44
- (function (ConnectionType) {
45
- ConnectionType["INJECTED"] = "INJECTED";
46
- ConnectionType["NETWORK"] = "NETWORK";
47
- ConnectionType["WALLET_CONNECT"] = "WALLET_CONNECT";
48
- })(ConnectionType || (ConnectionType = {}));
49
- // function getIsBraveWallet(): boolean {
50
- // return window.ethereum?.isBraveWallet ?? false
51
- // }
52
- export function getHasMetaMaskExtensionInstalled() {
53
- var _a, _b;
54
- return ((_b = (_a = window.ethereum) === null || _a === void 0 ? void 0 : _a.isMetaMask) !== null && _b !== void 0 ? _b : false);
55
- // && !getIsBraveWallet()
56
- }
57
- export function onConnectionError(error) {
58
- console.debug("web3-react error: ".concat(error));
59
- }
60
- export var PRIORITIZED_CONNECTORS = (_a = {},
61
- _a[ConnectionType.INJECTED] = buildInjectedConnector(),
62
- _a[ConnectionType.WALLET_CONNECT] = buildWalletConnectConnector(),
63
- _a[ConnectionType.NETWORK] = buildNetworkConnector(),
64
- _a);
65
- export function getConnection(c) {
66
- if (c instanceof Connector) {
67
- var connection = Object.values(PRIORITIZED_CONNECTORS).find(function (connection) { return connection.connector === c; });
68
- if (!connection) {
69
- throw Error('Unsupported Connector');
70
- }
71
- return connection;
72
- }
73
- else {
74
- switch (c) {
75
- case ConnectionType.INJECTED:
76
- return PRIORITIZED_CONNECTORS[ConnectionType.INJECTED];
77
- case ConnectionType.WALLET_CONNECT:
78
- return PRIORITIZED_CONNECTORS[ConnectionType.WALLET_CONNECT];
79
- case ConnectionType.NETWORK:
80
- return PRIORITIZED_CONNECTORS[ConnectionType.NETWORK];
81
- }
82
- }
83
- }
84
- export var switchNetwork = function (chainId, connectionType) { return __awaiter(void 0, void 0, void 0, function () {
85
- var connector, chainInfo, addChainParameter;
86
- return __generator(this, function (_a) {
87
- switch (_a.label) {
88
- case 0:
89
- if (!connectionType) {
90
- return [2 /*return*/];
91
- }
92
- connector = getConnection(connectionType).connector;
93
- if (!(connectionType === ConnectionType.WALLET_CONNECT || connectionType === ConnectionType.NETWORK)) return [3 /*break*/, 2];
94
- return [4 /*yield*/, connector.activate(chainId)];
95
- case 1:
96
- _a.sent();
97
- return [2 /*return*/];
98
- case 2:
99
- chainInfo = CHAIN_INFO[chainId];
100
- addChainParameter = {
101
- chainId: chainId,
102
- chainName: chainInfo.label,
103
- rpcUrls: [chainInfo.rpcUrl],
104
- nativeCurrency: chainInfo.nativeCurrency,
105
- blockExplorerUrls: [chainInfo.explorer],
106
- };
107
- return [4 /*yield*/, connector.activate(addChainParameter)];
108
- case 3:
109
- _a.sent();
110
- return [2 /*return*/];
111
- }
112
- });
113
- }); };
114
- export var tryActivateConnector = function (connector) { return __awaiter(void 0, void 0, void 0, function () {
115
- var connectionType;
116
- return __generator(this, function (_a) {
117
- switch (_a.label) {
118
- case 0: return [4 /*yield*/, connector.activate()];
119
- case 1:
120
- _a.sent();
121
- connectionType = getConnection(connector).type;
122
- return [2 /*return*/, connectionType];
123
- }
124
- });
125
- }); };
126
- export var tryDeactivateConnector = function (connector) { return __awaiter(void 0, void 0, void 0, function () {
127
- var _a;
128
- return __generator(this, function (_b) {
129
- (_a = connector.deactivate) === null || _a === void 0 ? void 0 : _a.call(connector);
130
- connector.resetState();
131
- return [2 /*return*/, null];
132
- });
133
- }); };
@@ -1,21 +0,0 @@
1
- export declare const INPUT_CHAIN_ID: number;
2
- export declare const INPUT_CHAIN_URL: string;
3
- export declare const CHAIN_TO_URL_MAP: {
4
- 137: string;
5
- 1: string;
6
- };
7
- type ChainInfo = {
8
- explorer: string;
9
- label: string;
10
- nativeCurrency: {
11
- name: string;
12
- symbol: string;
13
- decimals: 18;
14
- };
15
- rpcUrl: string;
16
- };
17
- export declare const CHAIN_INFO: {
18
- [key: string]: ChainInfo;
19
- };
20
- export declare const METAMASK_URL = "https://metamask.io/";
21
- export {};
@@ -1,27 +0,0 @@
1
- var _a, _b;
2
- import { Chain, CurrentConfig } from './config';
3
- // Chains
4
- var MAINNET_CHAIN_ID = 1;
5
- var POLYGON_CHAIN_ID = 137;
6
- export var INPUT_CHAIN_ID = CurrentConfig.chain === Chain.POLYGON ? POLYGON_CHAIN_ID : MAINNET_CHAIN_ID;
7
- export var INPUT_CHAIN_URL = CurrentConfig.chain === Chain.POLYGON ? CurrentConfig.rpc.polygon : CurrentConfig.rpc.mainnet;
8
- export var CHAIN_TO_URL_MAP = (_a = {},
9
- _a[POLYGON_CHAIN_ID] = CurrentConfig.rpc.polygon,
10
- _a[MAINNET_CHAIN_ID] = CurrentConfig.rpc.mainnet,
11
- _a);
12
- export var CHAIN_INFO = (_b = {},
13
- _b[MAINNET_CHAIN_ID] = {
14
- explorer: 'https://etherscan.io/',
15
- label: 'Ethereum',
16
- nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
17
- rpcUrl: CurrentConfig.rpc.mainnet,
18
- },
19
- _b[POLYGON_CHAIN_ID] = {
20
- explorer: 'https://polygonscan.com/',
21
- label: 'Polygon',
22
- nativeCurrency: { name: 'Polygon Matic', symbol: 'MATIC', decimals: 18 },
23
- rpcUrl: CurrentConfig.rpc.polygon,
24
- },
25
- _b);
26
- // URLs
27
- export var METAMASK_URL = 'https://metamask.io/';
@@ -1,2 +0,0 @@
1
- import { Connection } from './connections';
2
- export declare function buildInjectedConnector(): Connection;
@@ -1,12 +0,0 @@
1
- import { initializeConnector } from '@web3-react/core';
2
- import { MetaMask } from '@web3-react/metamask';
3
- import { ConnectionType, onConnectionError } from './connections';
4
- export function buildInjectedConnector() {
5
- var _a = initializeConnector(function (actions) { return new MetaMask({ actions: actions, onError: onConnectionError }); }), web3MetamaskWallet = _a[0], web3MetamaskWalletHooks = _a[1];
6
- var injectedConnection = {
7
- connector: web3MetamaskWallet,
8
- hooks: web3MetamaskWalletHooks,
9
- type: ConnectionType.INJECTED,
10
- };
11
- return injectedConnection;
12
- }
@@ -1,2 +0,0 @@
1
- import { Connection } from './connections';
2
- export declare function buildNetworkConnector(): Connection;
@@ -1,19 +0,0 @@
1
- import { initializeConnector } from '@web3-react/core';
2
- import { Network } from '@web3-react/network';
3
- import { ConnectionType } from './connections';
4
- import { CHAIN_TO_URL_MAP, INPUT_CHAIN_ID } from './constants';
5
- export function buildNetworkConnector() {
6
- var _a = initializeConnector(function (actions) {
7
- return new Network({
8
- actions: actions,
9
- urlMap: CHAIN_TO_URL_MAP,
10
- defaultChainId: INPUT_CHAIN_ID,
11
- });
12
- }), web3Network = _a[0], web3NetworkHooks = _a[1];
13
- var networkConnection = {
14
- connector: web3Network,
15
- hooks: web3NetworkHooks,
16
- type: ConnectionType.NETWORK,
17
- };
18
- return networkConnection;
19
- }
@@ -1,4 +0,0 @@
1
- import { ReactNode } from 'react';
2
- export declare const Web3ContextProvider: ({ children }: {
3
- children: ReactNode;
4
- }) => import("react/jsx-runtime").JSX.Element;
@@ -1,95 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
- return new (P || (P = Promise))(function (resolve, reject) {
15
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
- step((generator = generator.apply(thisArg, _arguments || [])).next());
19
- });
20
- };
21
- var __generator = (this && this.__generator) || function (thisArg, body) {
22
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
- function verb(n) { return function (v) { return step([n, v]); }; }
25
- function step(op) {
26
- if (f) throw new TypeError("Generator is already executing.");
27
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
- 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;
29
- if (y = 0, t) op = [op[0] & 2, t.value];
30
- switch (op[0]) {
31
- case 0: case 1: t = op; break;
32
- case 4: _.label++; return { value: op[1], done: false };
33
- case 5: _.label++; y = op[1]; op = [0]; continue;
34
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
- default:
36
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
- if (t[2]) _.ops.pop();
41
- _.trys.pop(); continue;
42
- }
43
- op = body.call(thisArg, _);
44
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
- }
47
- };
48
- import { jsx as _jsx } from "react/jsx-runtime";
49
- // src/wallet/provider.tsx
50
- import { Web3ReactProvider } from '@web3-react/core';
51
- import { useEffect } from 'react';
52
- import { ConnectionType, getConnection, PRIORITIZED_CONNECTORS } from './connections';
53
- function connect(connector) {
54
- return __awaiter(this, void 0, void 0, function () {
55
- var error_1;
56
- return __generator(this, function (_a) {
57
- switch (_a.label) {
58
- case 0:
59
- _a.trys.push([0, 5, , 6]);
60
- if (!connector.connectEagerly) return [3 /*break*/, 2];
61
- return [4 /*yield*/, connector.connectEagerly()];
62
- case 1:
63
- _a.sent();
64
- return [3 /*break*/, 4];
65
- case 2: return [4 /*yield*/, connector.activate()];
66
- case 3:
67
- _a.sent();
68
- _a.label = 4;
69
- case 4: return [3 /*break*/, 6];
70
- case 5:
71
- error_1 = _a.sent();
72
- console.debug("web3-react eager connection error: ".concat(error_1));
73
- return [3 /*break*/, 6];
74
- case 6: return [2 /*return*/];
75
- }
76
- });
77
- });
78
- }
79
- var connectEagerly = function () { return __awaiter(void 0, void 0, void 0, function () {
80
- return __generator(this, function (_a) {
81
- switch (_a.label) {
82
- case 0: return [4 /*yield*/, connect(getConnection(ConnectionType.NETWORK).connector)];
83
- case 1:
84
- _a.sent();
85
- return [2 /*return*/];
86
- }
87
- });
88
- }); };
89
- export var Web3ContextProvider = function (_a) {
90
- var children = _a.children;
91
- useEffect(function () {
92
- connectEagerly();
93
- }, []);
94
- return (_jsx(Web3ReactProvider, __assign({ connectors: Object.values(PRIORITIZED_CONNECTORS).map(function (connector) { return [connector.connector, connector.hooks]; }) }, { children: children })));
95
- };
@@ -1,2 +0,0 @@
1
- import { Connection } from './connections';
2
- export declare function buildWalletConnectConnector(): Connection;
@@ -1,22 +0,0 @@
1
- import { initializeConnector } from '@web3-react/core';
2
- import { WalletConnect } from '@web3-react/walletconnect';
3
- import { ConnectionType, onConnectionError } from './connections';
4
- import { CHAIN_TO_URL_MAP } from './constants';
5
- export function buildWalletConnectConnector() {
6
- var _a = initializeConnector(function (actions) {
7
- return new WalletConnect({
8
- actions: actions,
9
- options: {
10
- rpc: CHAIN_TO_URL_MAP,
11
- qrcode: true,
12
- },
13
- onError: onConnectionError,
14
- });
15
- }), web3WalletConnect = _a[0], web3WalletConnectHooks = _a[1];
16
- var walletConnectConnection = {
17
- connector: web3WalletConnect,
18
- hooks: web3WalletConnectHooks,
19
- type: ConnectionType.WALLET_CONNECT,
20
- };
21
- return walletConnectConnection;
22
- }