Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@solana/rpc-transport-http

Package Overview
Dependencies
Maintainers
15
Versions
936
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solana/rpc-transport-http - npm Package Compare versions

Comparing version 2.0.0-experimental.9a26b88 to 2.0.0-experimental.9ce1f51

25

dist/index.browser.js

@@ -0,1 +1,3 @@

import { SolanaError, SOLANA_ERROR__RPC_TRANSPORT_HTTP_ERROR, SOLANA_ERROR__RPC_TRANSPORT_HEADER_FORBIDDEN } from '@solana/errors';
// ../build-scripts/env-shim.ts

@@ -6,17 +8,2 @@ var __DEV__ = /* @__PURE__ */ (() => process["env"].NODE_ENV === "development")();

var e = globalThis.fetch;
// src/http-transport-errors.ts
var SolanaHttpError = class extends Error {
statusCode;
constructor(details) {
super(`HTTP error (${details.statusCode}): ${details.message}`);
Error.captureStackTrace(this, this.constructor);
this.statusCode = details.statusCode;
}
get name() {
return "SolanaHttpError";
}
};
// src/http-transport-headers.ts
var DISALLOWED_HEADERS = {

@@ -58,5 +45,5 @@ accept: true,

if (badHeaders.length > 0) {
throw new Error(
`${badHeaders.length > 1 ? "These headers are" : "This header is"} forbidden: \`${badHeaders.join("`, `")}\`. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.`
);
throw new SolanaError(SOLANA_ERROR__RPC_TRANSPORT_HEADER_FORBIDDEN, {
headers: badHeaders
});
}

@@ -113,3 +100,3 @@ }

if (!response.ok) {
throw new SolanaHttpError({
throw new SolanaError(SOLANA_ERROR__RPC_TRANSPORT_HTTP_ERROR, {
message: response.statusText,

@@ -116,0 +103,0 @@ statusCode: response.status

@@ -0,1 +1,3 @@

import { SolanaError, SOLANA_ERROR__RPC_TRANSPORT_HTTP_ERROR, SOLANA_ERROR__RPC_TRANSPORT_HEADER_FORBIDDEN } from '@solana/errors';
// ../build-scripts/env-shim.ts

@@ -6,17 +8,2 @@ var __DEV__ = /* @__PURE__ */ (() => process["env"].NODE_ENV === "development")();

var e = globalThis.fetch;
// src/http-transport-errors.ts
var SolanaHttpError = class extends Error {
statusCode;
constructor(details) {
super(`HTTP error (${details.statusCode}): ${details.message}`);
Error.captureStackTrace(this, this.constructor);
this.statusCode = details.statusCode;
}
get name() {
return "SolanaHttpError";
}
};
// src/http-transport-headers.ts
var DISALLOWED_HEADERS = {

@@ -58,5 +45,5 @@ accept: true,

if (badHeaders.length > 0) {
throw new Error(
`${badHeaders.length > 1 ? "These headers are" : "This header is"} forbidden: \`${badHeaders.join("`, `")}\`. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.`
);
throw new SolanaError(SOLANA_ERROR__RPC_TRANSPORT_HEADER_FORBIDDEN, {
headers: badHeaders
});
}

@@ -113,3 +100,3 @@ }

if (!response.ok) {
throw new SolanaHttpError({
throw new SolanaError(SOLANA_ERROR__RPC_TRANSPORT_HTTP_ERROR, {
message: response.statusText,

@@ -116,0 +103,0 @@ statusCode: response.status

@@ -0,1 +1,2 @@

import { SolanaError, SOLANA_ERROR__RPC_TRANSPORT_HTTP_ERROR, SOLANA_ERROR__RPC_TRANSPORT_HEADER_FORBIDDEN } from '@solana/errors';
import { fetch } from 'undici';

@@ -5,17 +6,2 @@

var __DEV__ = /* @__PURE__ */ (() => process["env"].NODE_ENV === "development")();
// src/http-transport-errors.ts
var SolanaHttpError = class extends Error {
statusCode;
constructor(details) {
super(`HTTP error (${details.statusCode}): ${details.message}`);
Error.captureStackTrace(this, this.constructor);
this.statusCode = details.statusCode;
}
get name() {
return "SolanaHttpError";
}
};
// src/http-transport-headers.ts
var DISALLOWED_HEADERS = {

@@ -57,5 +43,5 @@ accept: true,

if (badHeaders.length > 0) {
throw new Error(
`${badHeaders.length > 1 ? "These headers are" : "This header is"} forbidden: \`${badHeaders.join("`, `")}\`. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.`
);
throw new SolanaError(SOLANA_ERROR__RPC_TRANSPORT_HEADER_FORBIDDEN, {
headers: badHeaders
});
}

@@ -105,3 +91,3 @@ }

if (!response.ok) {
throw new SolanaHttpError({
throw new SolanaError(SOLANA_ERROR__RPC_TRANSPORT_HTTP_ERROR, {
message: response.statusText,

@@ -108,0 +94,0 @@ statusCode: response.status

{
"name": "@solana/rpc-transport-http",
"version": "2.0.0-experimental.9a26b88",
"version": "2.0.0-experimental.9ce1f51",
"description": "An RPC transport that uses HTTP requests",

@@ -50,3 +50,4 @@ "exports": {

"undici": "^6.6.2",
"@solana/rpc-spec": "2.0.0-experimental.9a26b88"
"@solana/errors": "2.0.0-experimental.9ce1f51",
"@solana/rpc-spec": "2.0.0-experimental.9ce1f51"
},

@@ -53,0 +54,0 @@ "bundlewatch": {

@@ -219,3 +219,27 @@ [![npm][npm-image]][npm-url]

```ts
// TODO: Your turn; send us a pull request with an example.
import { RpcTransport } from '@solana/rpc-spec';
import { createHttpTransport } from '@solana/rpc-transport-http';
// Create a transport for each RPC server
const transports = [
createHttpTransport({ url: 'https://mainnet-beta.my-server-1.com' }),
createHttpTransport({ url: 'https://mainnet-beta.my-server-2.com' }),
createHttpTransport({ url: 'https://mainnet-beta.my-server-2.com' }),
];
// A failover transport that will try each transport in order until one succeeds before failing
async function failoverTransport<TResponse>(...args: Parameters<RpcTransport>): Promise<TResponse> {
let requestError;
for (const transport of transports) {
try {
return await transport(...args);
} catch (err) {
requestError = err;
console.error(err);
}
}
throw requestError;
}
```

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc