@ape.swap/bonds-sdk 1.0.515 → 1.0.516

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.
@@ -56,6 +56,7 @@ import { NETWORK_ICONS } from '../../../config/constants/chains';
56
56
  import { formatUSDNumber, getPremiumColor, premium, youGet, youGetUSD, youSpend, youSpendUSD } from './helper';
57
57
  import '../../../scss/BondModal.scss';
58
58
  import { useWriteContract } from "wagmi";
59
+ import { PUBLIC_RPC_URLS } from "../../../config/constants/networks";
59
60
  var BondModal = function (_a) {
60
61
  var account = _a.account, accountChainId = _a.accountChainId, isActive = _a.isActive, isOpen = _a.isOpen, onClose = _a.onClose, bondAddress = _a.bondAddress;
61
62
  if (!isOpen)
@@ -187,14 +188,13 @@ var BondModal = function (_a) {
187
188
  }
188
189
  }, [isActive, account, bondData]);
189
190
  var getTokenBalance = function (chainId, tokenAddress, walletAddress) { return __awaiter(void 0, void 0, void 0, function () {
190
- var provider, contract, balance, balanceInEther, error_3;
191
+ var urls, provider, contract, balance, balanceInEther, error_3;
191
192
  return __generator(this, function (_a) {
192
193
  switch (_a.label) {
193
194
  case 0:
194
195
  _a.trys.push([0, 2, , 3]);
195
- provider = new ethers.providers.JsonRpcProvider("https://bsc-dataseed.binance.org/");
196
- // const provider = getProvider(56, true)
197
- // const provider = RPC_PROVIDERS[chainId];
196
+ urls = PUBLIC_RPC_URLS;
197
+ provider = new ethers.providers.JsonRpcProvider(urls[chainId][0]);
198
198
  if (!provider) {
199
199
  throw new Error("No provider found for chainId: ".concat(chainId));
200
200
  }
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.515",
6
+ "version": "1.0.516",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist/index.es.js",
9
9
  "types": "dist/index.d.ts",
@@ -1,14 +0,0 @@
1
- import { StaticJsonRpcProvider } from '@ethersproject/providers';
2
- import { ChainId } from './chains';
3
- declare class AppJsonRpcProvider extends StaticJsonRpcProvider {
4
- private _blockCache;
5
- get blockCache(): Map<string, Promise<any>>;
6
- constructor(chainId: ChainId, useApeRPC?: boolean);
7
- send(method: string, params: Array<any>): Promise<any>;
8
- }
9
- /**
10
- * These are the only JsonRpcProviders used directly by the interface.
11
- */
12
- export declare const RPC_PROVIDERS: Record<ChainId, StaticJsonRpcProvider>;
13
- export declare const getProvider: (chainId: ChainId, useApeRPC?: boolean) => AppJsonRpcProvider;
14
- export {};
@@ -1,103 +0,0 @@
1
- var __extends = (this && this.__extends) || (function () {
2
- var extendStatics = function (d, b) {
3
- extendStatics = Object.setPrototypeOf ||
4
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
- return extendStatics(d, b);
7
- };
8
- return function (d, b) {
9
- if (typeof b !== "function" && b !== null)
10
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
- extendStatics(d, b);
12
- function __() { this.constructor = d; }
13
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
- };
15
- })();
16
- var _a;
17
- import { PUBLIC_RPC_URLS } from './networks';
18
- import { StaticJsonRpcProvider } from '@ethersproject/providers';
19
- import { AVERAGE_L1_BLOCK_TIME, CHAIN_NAMES, ChainId } from './chains';
20
- import { isPlain } from '@reduxjs/toolkit';
21
- import { deepCopy } from 'ethers/lib/utils';
22
- var AppJsonRpcProvider = /** @class */ (function (_super) {
23
- __extends(AppJsonRpcProvider, _super);
24
- function AppJsonRpcProvider(chainId, useApeRPC) {
25
- if (useApeRPC === void 0) { useApeRPC = false; }
26
- var _this = this;
27
- var urls = PUBLIC_RPC_URLS;
28
- _this = _super.call(this, urls[chainId][0], /* networkish= */ { chainId: chainId, name: CHAIN_NAMES[chainId] }) || this;
29
- _this._blockCache = new Map();
30
- // NB: Third-party providers (eg MetaMask) will have their own polling intervals,
31
- // which should be left as-is to allow operations (eg transaction confirmation) to resolve faster.
32
- // Network providers (eg AppJsonRpcProvider) need to update less frequently to be considered responsive.
33
- _this.pollingInterval = AVERAGE_L1_BLOCK_TIME;
34
- return _this;
35
- }
36
- Object.defineProperty(AppJsonRpcProvider.prototype, "blockCache", {
37
- get: function () {
38
- var _this = this;
39
- // If the blockCache has not yet been initialized this block, do so by
40
- // setting a listener to clear it on the next block.
41
- if (!this._blockCache.size) {
42
- this.once('block', function () { return _this._blockCache.clear(); });
43
- }
44
- return this._blockCache;
45
- },
46
- enumerable: false,
47
- configurable: true
48
- });
49
- AppJsonRpcProvider.prototype.send = function (method, params) {
50
- // Only cache eth_call's.
51
- if (method !== 'eth_call')
52
- return _super.prototype.send.call(this, method, params);
53
- // Only cache if params are serializable.
54
- if (!isPlain(params))
55
- return _super.prototype.send.call(this, method, params);
56
- var key = "call:".concat(JSON.stringify(params));
57
- var cached = this.blockCache.get(key);
58
- if (cached) {
59
- this.emit('debug', {
60
- action: 'request',
61
- request: deepCopy({ method: method, params: params, id: 'cache' }),
62
- provider: this,
63
- });
64
- return cached;
65
- }
66
- var result = _super.prototype.send.call(this, method, params);
67
- this.blockCache.set(key, result);
68
- return result;
69
- };
70
- return AppJsonRpcProvider;
71
- }(StaticJsonRpcProvider));
72
- /**
73
- * These are the only JsonRpcProviders used directly by the interface.
74
- */
75
- export var RPC_PROVIDERS = (_a = {},
76
- _a[ChainId.MAINNET] = new AppJsonRpcProvider(ChainId.MAINNET),
77
- _a[ChainId.POLYGON] = new AppJsonRpcProvider(ChainId.POLYGON),
78
- _a[ChainId.ARBITRUM_ONE] = new AppJsonRpcProvider(ChainId.ARBITRUM_ONE),
79
- _a[ChainId.POLYGON_MUMBAI] = new AppJsonRpcProvider(ChainId.POLYGON_MUMBAI),
80
- _a[ChainId.BSC] = new AppJsonRpcProvider(ChainId.BSC),
81
- _a[ChainId.BSC_TESTNET] = new AppJsonRpcProvider(ChainId.BSC_TESTNET),
82
- _a[ChainId.TLOS] = new AppJsonRpcProvider(ChainId.TLOS),
83
- _a[ChainId.GNOSIS] = new AppJsonRpcProvider(ChainId.GNOSIS),
84
- _a[ChainId.AVALANCHE] = new AppJsonRpcProvider(ChainId.AVALANCHE),
85
- _a[ChainId.OPTIMISM] = new AppJsonRpcProvider(ChainId.OPTIMISM),
86
- _a[ChainId.FANTOM] = new AppJsonRpcProvider(ChainId.FANTOM),
87
- _a[ChainId.CRONOS] = new AppJsonRpcProvider(ChainId.CRONOS),
88
- _a[ChainId.POLYGON_ZK] = new AppJsonRpcProvider(ChainId.POLYGON_ZK),
89
- _a[ChainId.OKX] = new AppJsonRpcProvider(ChainId.OKX),
90
- _a[ChainId.CELO] = new AppJsonRpcProvider(ChainId.CELO),
91
- _a[ChainId.INJECTED_EVM_TESTNET] = new AppJsonRpcProvider(ChainId.INJECTED_EVM_TESTNET),
92
- _a[ChainId.INEVM] = new AppJsonRpcProvider(ChainId.INEVM),
93
- _a[ChainId.SEPOLIA] = new AppJsonRpcProvider(ChainId.SEPOLIA),
94
- _a[ChainId.LINEA] = new AppJsonRpcProvider(ChainId.LINEA),
95
- _a[ChainId.LIGHTLINK] = new AppJsonRpcProvider(ChainId.LIGHTLINK),
96
- _a[ChainId.IOTA] = new AppJsonRpcProvider(ChainId.IOTA),
97
- _a[ChainId.IOTA_TESTNET] = new AppJsonRpcProvider(ChainId.IOTA_TESTNET),
98
- _a[ChainId.BASE] = new AppJsonRpcProvider(ChainId.BASE),
99
- _a);
100
- export var getProvider = function (chainId, useApeRPC) {
101
- if (useApeRPC === void 0) { useApeRPC = false; }
102
- return new AppJsonRpcProvider(chainId, useApeRPC);
103
- };