@@ -16833,6 +16833,12 @@ function ethDefaultProvider(network) {
16833
16833
}
16834
16834
catch (error) { }
16835
16835
}
16836
+ if (providers.PocketGatewayProvider) {
16837
+ try {
16838
+ providerList.push(new providers.PocketGatewayProvider(network, options.pocket_gateway));
16839
+ }
16840
+ catch (error) { }
16841
+ }
16836
16842
if (providers.CloudflareProvider) {
16837
16843
try {
16838
16844
providerList.push(new providers.CloudflareProvider(network));
@@ -21428,62 +21434,6 @@ class NodesmithProvider extends UrlJsonRpcProvider {
21428
21434
21429
21435
"use strict";
21430
21436
const logger$D = new Logger(version$m);
21431
- const defaultApplicationId = "5f7f8547b90218002e9ce9dd";
21432
- class PocketProvider extends UrlJsonRpcProvider {
21433
- static getApiKey(apiKey) {
21434
- const apiKeyObj = {
21435
- applicationId: defaultApplicationId,
21436
- applicationSecretKey: null
21437
- };
21438
- if (apiKey == null) {
21439
- return apiKeyObj;
21440
- }
21441
- // Parse applicationId and applicationSecretKey
21442
- if (typeof (apiKey) === "string") {
21443
- apiKeyObj.applicationId = apiKey;
21444
- }
21445
- else if (apiKey.applicationSecretKey != null) {
21446
- logger$D.assertArgument((typeof (apiKey.applicationId) === "string"), "applicationSecretKey requires an applicationId", "applicationId", apiKey.applicationId);
21447
- logger$D.assertArgument((typeof (apiKey.applicationSecretKey) === "string"), "invalid applicationSecretKey", "applicationSecretKey", "[REDACTED]");
21448
- apiKeyObj.applicationId = apiKey.applicationId;
21449
- apiKeyObj.applicationSecretKey = apiKey.applicationSecretKey;
21450
- }
21451
- else if (apiKey.applicationId) {
21452
- apiKeyObj.applicationId = apiKey.applicationId;
21453
- }
21454
- return apiKeyObj;
21455
- }
21456
- static getUrl(network, apiKey) {
21457
- let host = null;
21458
- switch (network ? network.name : "unknown") {
21459
- case "homestead":
21460
- host = "eth-mainnet.gateway.pokt.network";
21461
- break;
21462
- default:
21463
- logger$D.throwError("unsupported network", Logger.errors.INVALID_ARGUMENT, {
21464
- argument: "network",
21465
- value: network
21466
- });
21467
- }
21468
- const connection = {
21469
- url: (`https:/\/${host}/v1/${apiKey.applicationId}`),
21470
- };
21471
- // Initialize empty headers
21472
- connection.headers = {};
21473
- // Apply application secret key
21474
- if (apiKey.applicationSecretKey != null) {
21475
- connection.user = "";
21476
- connection.password = apiKey.applicationSecretKey;
21477
- }
21478
- return connection;
21479
- }
21480
- isCommunityResource() {
21481
- return (this.applicationId === defaultApplicationId);
21482
- }
21483
- }
21484
-
21485
- "use strict";
21486
- const logger$E = new Logger(version$m);
21487
21437
let _nextId = 1;
21488
21438
function buildWeb3LegacyFetcher(provider, sendFunc) {
21489
21439
return function (method, params) {
@@ -21531,9 +21481,9 @@ function buildEip1193Fetcher(provider) {
21531
21481
}
21532
21482
class Web3Provider extends JsonRpcProvider {
21533
21483
constructor(provider, network) {
21534
- logger$E .checkNew(new.target, Web3Provider);
21484
+ logger$D .checkNew(new.target, Web3Provider);
21535
21485
if (provider == null) {
21536
- logger$E .throwArgumentError("missing provider", "provider", provider);
21486
+ logger$D .throwArgumentError("missing provider", "provider", provider);
21537
21487
}
21538
21488
let path = null;
21539
21489
let jsonRpcFetchFunc = null;
@@ -21561,7 +21511,7 @@ class Web3Provider extends JsonRpcProvider {
21561
21511
jsonRpcFetchFunc = buildWeb3LegacyFetcher(provider, provider.send.bind(provider));
21562
21512
}
21563
21513
else {
21564
- logger$E .throwArgumentError("unsupported provider", "provider", provider);
21514
+ logger$D .throwArgumentError("unsupported provider", "provider", provider);
21565
21515
}
21566
21516
if (!path) {
21567
21517
path = "unknown:";
@@ -21576,6 +21526,182 @@ class Web3Provider extends JsonRpcProvider {
21576
21526
}
21577
21527
}
21578
21528
21529
+ "use strict";
21530
+ const logger$E = new Logger(version$m);
21531
+ const defaultApplicationId = "defaultApp";
21532
+ const defaultLoadBalancer = "defaultLB";
21533
+ var EndpointType;
21534
+ (function (EndpointType) {
21535
+ EndpointType["LoadBalancer"] = "LoadBalancer";
21536
+ EndpointType["Application"] = "Application";
21537
+ })(EndpointType || (EndpointType = {}));
21538
+ class PocketGatewayProvider extends UrlJsonRpcProvider {
21539
+ static getApiKey(apiKey) {
21540
+ let apiKeyObj = PocketApiKeyObject.build(apiKey);
21541
+ return apiKeyObj;
21542
+ }
21543
+ static getUrl(network, apiKey) {
21544
+ let host = null;
21545
+ switch (network ? network.name : "unknown") {
21546
+ case "homestead":
21547
+ host = "eth-mainnet.gateway.pokt.network";
21548
+ break;
21549
+ case "mainnet":
21550
+ host = "eth-mainnet.gateway.pokt.network";
21551
+ break;
21552
+ case "ropsten":
21553
+ host = "eth-ropsten.gateway.pokt.network";
21554
+ break;
21555
+ case "goerli":
21556
+ host = "eth-ropsten.gateway.pokt.network";
21557
+ break;
21558
+ case "rinkeby":
21559
+ host = "eth-rinkeby.gateway.pokt.network";
21560
+ break;
21561
+ default:
21562
+ logger$E.throwError("unsupported network", Logger.errors.INVALID_ARGUMENT, {
21563
+ argument: "network",
21564
+ value: network
21565
+ });
21566
+ }
21567
+ const connection = {
21568
+ url: PocketApiKeyObject.getUrl(apiKey, host),
21569
+ };
21570
+ // Initialize empty headers
21571
+ connection.headers = {};
21572
+ // Apply application secret key
21573
+ if (apiKey.applicationSecretKey != null) {
21574
+ connection.user = "";
21575
+ connection.password = apiKey.applicationSecretKey;
21576
+ }
21577
+ return connection;
21578
+ }
21579
+ isCommunityResource() {
21580
+ if (typeof (this.apiKey) === "string") {
21581
+ return (this.apiKey === defaultApplicationId || this.apiKey === defaultLoadBalancer);
21582
+ }
21583
+ else if (typeof (this.apiKey) === "object") {
21584
+ return (this.apiKey.applicationId === defaultApplicationId || this.apiKey.applicationId === defaultLoadBalancer);
21585
+ }
21586
+ return true;
21587
+ }
21588
+ }
21589
+ class PocketApiKeyObject {
21590
+ constructor() {
21591
+ this.applicationId = defaultLoadBalancer;
21592
+ this.endpointType = EndpointType.LoadBalancer;
21593
+ this.applicationSecretKey = null;
21594
+ this.applicationOrigin = null;
21595
+ this.applicationUserAgent = null;
21596
+ }
21597
+ static build(apiKey) {
21598
+ if (apiKey == null)
21599
+ return new PocketApiKeyObject();
21600
+ var apiKeyObj = new PocketApiKeyObject();
21601
+ // Parse Origin
21602
+ if (typeof (apiKey.applicationOrigin) === "string") {
21603
+ apiKeyObj.applicationOrigin = apiKey.applicationOrigin;
21604
+ }
21605
+ // Parse User Agent
21606
+ if (typeof (apiKey.applicationUserAgent) === "string") {
21607
+ apiKeyObj.applicationUserAgent = apiKey.applicationUserAgent;
21608
+ }
21609
+ if (typeof (apiKey.endpointType) === "string") {
21610
+ switch (apiKey.endpointType.toLowerCase()) {
21611
+ case "application":
21612
+ apiKeyObj.endpointType = EndpointType.Application;
21613
+ apiKeyObj.applicationId = defaultApplicationId;
21614
+ break;
21615
+ default:
21616
+ apiKeyObj.endpointType = EndpointType.LoadBalancer;
21617
+ apiKeyObj.applicationId = defaultLoadBalancer;
21618
+ break;
21619
+ }
21620
+ }
21621
+ switch (true) {
21622
+ case typeof (apiKey) === "string":
21623
+ apiKeyObj.applicationId = apiKey;
21624
+ break;
21625
+ case apiKey.applicationSecretKey != null:
21626
+ logger$E.assertArgument((typeof (apiKey.applicationId) === "string"), "applicationSecretKey requires an applicationId", "applicationId", apiKey.applicationId);
21627
+ logger$E.assertArgument((typeof (apiKey.applicationSecretKey) === "string"), "invalid applicationSecretKey", "applicationSecretKey", "[*********]");
21628
+ apiKeyObj.applicationId = apiKey.applicationId;
21629
+ apiKeyObj.applicationSecretKey = apiKey.applicationSecretKey;
21630
+ break;
21631
+ case apiKey !== null && typeof (apiKey.applicationId) === "string":
21632
+ apiKeyObj.applicationId = apiKey.applicationId;
21633
+ break;
21634
+ }
21635
+ return apiKeyObj;
21636
+ }
21637
+ static getDefaultAppForHost(host) {
21638
+ let defaultAppId = null;
21639
+ switch (host) {
21640
+ case "eth-mainnet.gateway.pokt.network":
21641
+ defaultAppId = "6004b7060aea5b606775f4d9";
21642
+ break;
21643
+ case "eth-ropsten.gateway.pokt.network":
21644
+ defaultAppId = "6004b9aa0aea5b606775f4de";
21645
+ break;
21646
+ case "eth-goerli.gateway.pokt.network":
21647
+ defaultAppId = "6004b9e30aea5b606775f4df";
21648
+ break;
21649
+ case "eth-rinkeby.gateway.pokt.network":
21650
+ defaultAppId = "6004ba310aea5b606775f4e0";
21651
+ break;
21652
+ default:
21653
+ logger$E.throwError("unsupported host for default app", Logger.errors.INVALID_ARGUMENT, {
21654
+ argument: "host",
21655
+ value: host
21656
+ });
21657
+ }
21658
+ return defaultAppId;
21659
+ }
21660
+ static getDefaultLoadBalancerForHost(host) {
21661
+ let defaultLbId = null;
21662
+ switch (host) {
21663
+ case "eth-mainnet.gateway.pokt.network":
21664
+ defaultLbId = "6004bcd10040261633ade990";
21665
+ break;
21666
+ case "eth-ropsten.gateway.pokt.network":
21667
+ defaultLbId = "6004bd4d0040261633ade991";
21668
+ break;
21669
+ case "eth-goerli.gateway.pokt.network":
21670
+ defaultLbId = "6004bd860040261633ade992";
21671
+ break;
21672
+ case "eth-rinkeby.gateway.pokt.network":
21673
+ defaultLbId = "6004bda20040261633ade994";
21674
+ break;
21675
+ default:
21676
+ logger$E.throwError("unsupported host for default app", Logger.errors.INVALID_ARGUMENT, {
21677
+ argument: "host",
21678
+ value: host
21679
+ });
21680
+ }
21681
+ return defaultLbId;
21682
+ }
21683
+ static getUrl(apiKey, host) {
21684
+ var appId = null;
21685
+ if (apiKey.applicationId === defaultLoadBalancer) {
21686
+ appId = PocketApiKeyObject.getDefaultLoadBalancerForHost(host);
21687
+ }
21688
+ else {
21689
+ appId = apiKey.applicationId;
21690
+ }
21691
+ var url = ("https:/" + "/" + host + "/v1/lb/" + appId);
21692
+ if (typeof (apiKey.endpointType) === "string" && apiKey.endpointType.toLowerCase() === "application") {
21693
+ if (appId === defaultApplicationId) {
21694
+ appId = PocketApiKeyObject.getDefaultAppForHost(host);
21695
+ }
21696
+ else {
21697
+ appId = apiKey.applicationId;
21698
+ }
21699
+ url = ("https:/" + "/" + host + "/v1/" + appId);
21700
+ }
21701
+ return url;
21702
+ }
21703
+ }
21704
+
21579
21705
"use strict";
21580
21706
const logger$F = new Logger(version$m);
21581
21707
////////////////////////
@@ -21615,8 +21741,8 @@ function getDefaultProvider(network, options) {
21615
21741
InfuraProvider,
21616
21742
JsonRpcProvider,
21617
21743
NodesmithProvider,
21618
- PocketProvider,
21619
21744
Web3Provider,
21745
+ PocketGatewayProvider,
21620
21746
IpcProvider,
21621
21747
}, options);
21622
21748
}
@@ -21636,10 +21762,10 @@ var index$3 = /*#__PURE__*/Object.freeze({
21636
21762
InfuraWebSocketProvider: InfuraWebSocketProvider,
21637
21763
JsonRpcProvider: JsonRpcProvider,
21638
21764
NodesmithProvider: NodesmithProvider,
21639
- PocketProvider: PocketProvider,
21640
21765
StaticJsonRpcProvider: StaticJsonRpcProvider,
21641
21766
Web3Provider: Web3Provider,
21642
21767
WebSocketProvider: WebSocketProvider,
21768
+ PocketGatewayProvider: PocketGatewayProvider,
21643
21769
IpcProvider: IpcProvider,
21644
21770
JsonRpcSigner: JsonRpcSigner,
21645
21771
getDefaultProvider: getDefaultProvider,
0 commit comments