@0xsequence/network
Advanced tools
Comparing version 0.0.0-20241216114019 to 0.0.0-20241218203257
@@ -10,14 +10,9 @@ 'use strict'; | ||
function _extends() { | ||
_extends = Object.assign ? Object.assign.bind() : function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
return _extends = Object.assign ? Object.assign.bind() : function (n) { | ||
for (var e = 1; e < arguments.length; e++) { | ||
var t = arguments[e]; | ||
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
return n; | ||
}, _extends.apply(null, arguments); | ||
} | ||
@@ -724,2 +719,15 @@ | ||
function _classPrivateFieldLooseBase(e, t) { | ||
if (!{}.hasOwnProperty.call(e, t)) throw new TypeError("attempted to use private field on non-instance"); | ||
return e; | ||
} | ||
var id = 0; | ||
function _classPrivateFieldLooseKey(e) { | ||
return "__private_" + id++ + "_" + e; | ||
} | ||
var _chainId = /*#__PURE__*/_classPrivateFieldLooseKey("chainId"); | ||
var _nextId = /*#__PURE__*/_classPrivateFieldLooseKey("nextId"); | ||
var _sender = /*#__PURE__*/_classPrivateFieldLooseKey("sender"); | ||
// JsonRpcProvider with a middleware stack. By default it will use a simple caching middleware. | ||
@@ -732,5 +740,14 @@ class JsonRpcProvider extends ethers.ethers.JsonRpcProvider { | ||
this.url = url; | ||
this.chainId = void 0; | ||
this.nextId = 1; | ||
this.sender = void 0; | ||
Object.defineProperty(this, _chainId, { | ||
writable: true, | ||
value: void 0 | ||
}); | ||
Object.defineProperty(this, _nextId, { | ||
writable: true, | ||
value: 1 | ||
}); | ||
Object.defineProperty(this, _sender, { | ||
writable: true, | ||
value: void 0 | ||
}); | ||
this.fetch = async function (request) { | ||
@@ -747,3 +764,3 @@ if (_this.url === undefined) { | ||
params, | ||
id: _this.nextId++, | ||
id: _classPrivateFieldLooseBase(_this, _nextId)[_nextId]++, | ||
jsonrpc: '2.0' | ||
@@ -789,3 +806,3 @@ }; | ||
const blockCache = options == null ? void 0 : options.blockCache; | ||
this.chainId = chainId; | ||
_classPrivateFieldLooseBase(this, _chainId)[_chainId] = chainId; | ||
@@ -804,6 +821,6 @@ // NOTE: it will either use the middleware stack passed to the constructor | ||
})], new JsonRpcHandler(this.fetch, chainId)); | ||
this.sender = router; | ||
_classPrivateFieldLooseBase(this, _sender)[_sender] = router; | ||
} | ||
async request(request) { | ||
return this.sender.request(request); | ||
return _classPrivateFieldLooseBase(this, _sender)[_sender].request(request); | ||
} | ||
@@ -818,3 +835,3 @@ async send(method, params, chainId) { | ||
async getNetwork() { | ||
const chainId = this.chainId; | ||
const chainId = _classPrivateFieldLooseBase(this, _chainId)[_chainId]; | ||
if (chainId) { | ||
@@ -831,3 +848,3 @@ const network = constants_dist_0xsequenceNetworkConstants.networks[chainId]; | ||
const chainIdHex = await this.send('eth_chainId', []); | ||
this.chainId = Number(chainIdHex); | ||
_classPrivateFieldLooseBase(this, _chainId)[_chainId] = Number(chainIdHex); | ||
return this.getNetwork(); | ||
@@ -834,0 +851,0 @@ } |
@@ -10,14 +10,9 @@ 'use strict'; | ||
function _extends() { | ||
_extends = Object.assign ? Object.assign.bind() : function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
return _extends = Object.assign ? Object.assign.bind() : function (n) { | ||
for (var e = 1; e < arguments.length; e++) { | ||
var t = arguments[e]; | ||
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
return n; | ||
}, _extends.apply(null, arguments); | ||
} | ||
@@ -724,2 +719,15 @@ | ||
function _classPrivateFieldLooseBase(e, t) { | ||
if (!{}.hasOwnProperty.call(e, t)) throw new TypeError("attempted to use private field on non-instance"); | ||
return e; | ||
} | ||
var id = 0; | ||
function _classPrivateFieldLooseKey(e) { | ||
return "__private_" + id++ + "_" + e; | ||
} | ||
var _chainId = /*#__PURE__*/_classPrivateFieldLooseKey("chainId"); | ||
var _nextId = /*#__PURE__*/_classPrivateFieldLooseKey("nextId"); | ||
var _sender = /*#__PURE__*/_classPrivateFieldLooseKey("sender"); | ||
// JsonRpcProvider with a middleware stack. By default it will use a simple caching middleware. | ||
@@ -732,5 +740,14 @@ class JsonRpcProvider extends ethers.ethers.JsonRpcProvider { | ||
this.url = url; | ||
this.chainId = void 0; | ||
this.nextId = 1; | ||
this.sender = void 0; | ||
Object.defineProperty(this, _chainId, { | ||
writable: true, | ||
value: void 0 | ||
}); | ||
Object.defineProperty(this, _nextId, { | ||
writable: true, | ||
value: 1 | ||
}); | ||
Object.defineProperty(this, _sender, { | ||
writable: true, | ||
value: void 0 | ||
}); | ||
this.fetch = async function (request) { | ||
@@ -747,3 +764,3 @@ if (_this.url === undefined) { | ||
params, | ||
id: _this.nextId++, | ||
id: _classPrivateFieldLooseBase(_this, _nextId)[_nextId]++, | ||
jsonrpc: '2.0' | ||
@@ -789,3 +806,3 @@ }; | ||
const blockCache = options == null ? void 0 : options.blockCache; | ||
this.chainId = chainId; | ||
_classPrivateFieldLooseBase(this, _chainId)[_chainId] = chainId; | ||
@@ -804,6 +821,6 @@ // NOTE: it will either use the middleware stack passed to the constructor | ||
})], new JsonRpcHandler(this.fetch, chainId)); | ||
this.sender = router; | ||
_classPrivateFieldLooseBase(this, _sender)[_sender] = router; | ||
} | ||
async request(request) { | ||
return this.sender.request(request); | ||
return _classPrivateFieldLooseBase(this, _sender)[_sender].request(request); | ||
} | ||
@@ -818,3 +835,3 @@ async send(method, params, chainId) { | ||
async getNetwork() { | ||
const chainId = this.chainId; | ||
const chainId = _classPrivateFieldLooseBase(this, _chainId)[_chainId]; | ||
if (chainId) { | ||
@@ -831,3 +848,3 @@ const network = constants_dist_0xsequenceNetworkConstants.networks[chainId]; | ||
const chainIdHex = await this.send('eth_chainId', []); | ||
this.chainId = Number(chainIdHex); | ||
_classPrivateFieldLooseBase(this, _chainId)[_chainId] = Number(chainIdHex); | ||
return this.getNetwork(); | ||
@@ -834,0 +851,0 @@ } |
@@ -7,14 +7,9 @@ import { networks, ChainId } from '../constants/dist/0xsequence-network-constants.esm.js'; | ||
function _extends() { | ||
_extends = Object.assign ? Object.assign.bind() : function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
return _extends = Object.assign ? Object.assign.bind() : function (n) { | ||
for (var e = 1; e < arguments.length; e++) { | ||
var t = arguments[e]; | ||
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
return n; | ||
}, _extends.apply(null, arguments); | ||
} | ||
@@ -721,2 +716,15 @@ | ||
function _classPrivateFieldLooseBase(e, t) { | ||
if (!{}.hasOwnProperty.call(e, t)) throw new TypeError("attempted to use private field on non-instance"); | ||
return e; | ||
} | ||
var id = 0; | ||
function _classPrivateFieldLooseKey(e) { | ||
return "__private_" + id++ + "_" + e; | ||
} | ||
var _chainId = /*#__PURE__*/_classPrivateFieldLooseKey("chainId"); | ||
var _nextId = /*#__PURE__*/_classPrivateFieldLooseKey("nextId"); | ||
var _sender = /*#__PURE__*/_classPrivateFieldLooseKey("sender"); | ||
// JsonRpcProvider with a middleware stack. By default it will use a simple caching middleware. | ||
@@ -729,5 +737,14 @@ class JsonRpcProvider extends ethers.JsonRpcProvider { | ||
this.url = url; | ||
this.chainId = void 0; | ||
this.nextId = 1; | ||
this.sender = void 0; | ||
Object.defineProperty(this, _chainId, { | ||
writable: true, | ||
value: void 0 | ||
}); | ||
Object.defineProperty(this, _nextId, { | ||
writable: true, | ||
value: 1 | ||
}); | ||
Object.defineProperty(this, _sender, { | ||
writable: true, | ||
value: void 0 | ||
}); | ||
this.fetch = async function (request) { | ||
@@ -744,3 +761,3 @@ if (_this.url === undefined) { | ||
params, | ||
id: _this.nextId++, | ||
id: _classPrivateFieldLooseBase(_this, _nextId)[_nextId]++, | ||
jsonrpc: '2.0' | ||
@@ -786,3 +803,3 @@ }; | ||
const blockCache = options == null ? void 0 : options.blockCache; | ||
this.chainId = chainId; | ||
_classPrivateFieldLooseBase(this, _chainId)[_chainId] = chainId; | ||
@@ -801,6 +818,6 @@ // NOTE: it will either use the middleware stack passed to the constructor | ||
})], new JsonRpcHandler(this.fetch, chainId)); | ||
this.sender = router; | ||
_classPrivateFieldLooseBase(this, _sender)[_sender] = router; | ||
} | ||
async request(request) { | ||
return this.sender.request(request); | ||
return _classPrivateFieldLooseBase(this, _sender)[_sender].request(request); | ||
} | ||
@@ -815,3 +832,3 @@ async send(method, params, chainId) { | ||
async getNetwork() { | ||
const chainId = this.chainId; | ||
const chainId = _classPrivateFieldLooseBase(this, _chainId)[_chainId]; | ||
if (chainId) { | ||
@@ -828,3 +845,3 @@ const network = networks[chainId]; | ||
const chainIdHex = await this.send('eth_chainId', []); | ||
this.chainId = Number(chainIdHex); | ||
_classPrivateFieldLooseBase(this, _chainId)[_chainId] = Number(chainIdHex); | ||
return this.getNetwork(); | ||
@@ -831,0 +848,0 @@ } |
@@ -9,6 +9,4 @@ import { ethers } from 'ethers'; | ||
export declare class JsonRpcProvider extends ethers.JsonRpcProvider implements EIP1193Provider, JsonRpcSender { | ||
#private; | ||
url: string | ethers.FetchRequest | undefined; | ||
private chainId?; | ||
private nextId; | ||
private sender; | ||
constructor(url: string | ethers.FetchRequest | undefined, options?: JsonRpcProviderOptions, jsonRpcApiProviderOptions?: ethers.JsonRpcApiProviderOptions); | ||
@@ -15,0 +13,0 @@ request(request: { |
{ | ||
"name": "@0xsequence/network", | ||
"version": "0.0.0-20241216114019", | ||
"version": "0.0.0-20241218203257", | ||
"description": "network sub-package for Sequence", | ||
@@ -15,6 +15,6 @@ "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/network", | ||
"dependencies": { | ||
"@0xsequence/core": "0.0.0-20241216114019", | ||
"@0xsequence/utils": "0.0.0-20241216114019", | ||
"@0xsequence/indexer": "0.0.0-20241216114019", | ||
"@0xsequence/relayer": "0.0.0-20241216114019" | ||
"@0xsequence/core": "0.0.0-20241218203257", | ||
"@0xsequence/indexer": "0.0.0-20241218203257", | ||
"@0xsequence/utils": "0.0.0-20241218203257", | ||
"@0xsequence/relayer": "0.0.0-20241218203257" | ||
}, | ||
@@ -21,0 +21,0 @@ "devDependencies": { |
@@ -29,5 +29,5 @@ import { ethers } from 'ethers' | ||
export class JsonRpcProvider extends ethers.JsonRpcProvider implements EIP1193Provider, JsonRpcSender { | ||
private chainId?: number | ||
private nextId: number = 1 | ||
private sender: EIP1193Provider | ||
#chainId?: number | ||
#nextId: number = 1 | ||
#sender: EIP1193Provider | ||
@@ -45,3 +45,3 @@ constructor( | ||
this.chainId = chainId | ||
this.#chainId = chainId | ||
@@ -62,7 +62,7 @@ // NOTE: it will either use the middleware stack passed to the constructor | ||
this.sender = router | ||
this.#sender = router | ||
} | ||
async request(request: { method: string; params?: any[]; chainId?: number }): Promise<any> { | ||
return this.sender.request(request) | ||
return this.#sender.request(request) | ||
} | ||
@@ -75,3 +75,3 @@ | ||
async getNetwork(): Promise<ethers.Network> { | ||
const chainId = this.chainId | ||
const chainId = this.#chainId | ||
if (chainId) { | ||
@@ -88,3 +88,3 @@ const network = networks[chainId as ChainId] | ||
const chainIdHex = await this.send('eth_chainId', []) | ||
this.chainId = Number(chainIdHex) | ||
this.#chainId = Number(chainIdHex) | ||
return this.getNetwork() | ||
@@ -104,3 +104,3 @@ } | ||
params, | ||
id: this.nextId++, | ||
id: this.#nextId++, | ||
jsonrpc: '2.0' | ||
@@ -107,0 +107,0 @@ } |
273741
7763
+ Added@0xsequence/abi@0.0.0-20241218203257(transitive)
+ Added@0xsequence/core@0.0.0-20241218203257(transitive)
+ Added@0xsequence/indexer@0.0.0-20241218203257(transitive)
+ Added@0xsequence/relayer@0.0.0-20241218203257(transitive)
+ Added@0xsequence/utils@0.0.0-20241218203257(transitive)
- Removed@0xsequence/abi@0.0.0-20241216114019(transitive)
- Removed@0xsequence/core@0.0.0-20241216114019(transitive)
- Removed@0xsequence/indexer@0.0.0-20241216114019(transitive)
- Removed@0xsequence/relayer@0.0.0-20241216114019(transitive)
- Removed@0xsequence/utils@0.0.0-20241216114019(transitive)