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

@rpch/sdk

Package Overview
Dependencies
Maintainers
2
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rpch/sdk - npm Package Compare versions

Comparing version 1.10.0 to 1.10.1

1

build/index.d.ts

@@ -94,2 +94,3 @@ import * as DPapi from './dp-api';

send: (req: JRPC.Request, ops?: RequestOps) => Promise<Response.Response>;
private doSend;
private sendSegment;

@@ -96,0 +97,0 @@ private resendRequest;

@@ -34,3 +34,2 @@ "use strict";

const Payload = __importStar(require("./payload"));
const ProviderAPI = __importStar(require("./provider-api"));
const Request = __importStar(require("./request"));

@@ -115,4 +114,7 @@ const RequestCache = __importStar(require("./request-cache"));

this.send = async (req, ops) => {
this.populateChainIds(ops?.provider);
return this.doSend(req, ops);
};
this.doSend = async (req, ops) => {
const reqOps = this.requestOps(ops);
this.populateChainIds(ops?.provider);
// TODO fixme

@@ -431,12 +433,33 @@ // eslint-disable-next-line no-async-promise-executor

this.fetchChainId = async (provider) => {
const res = await ProviderAPI.fetchChainId(provider).catch((err) => log.warn('error fetching chainId for %s: %s[%o]', provider, JSON.stringify(err), err));
const req = JRPC.chainId(provider);
// fetch request through RPCh
const res = await this.doSend(req, { provider }).catch((err) => log.warn('error fetching chainId for %s: %s[%o]', provider, JSON.stringify(err), err));
if (!res) {
return;
}
if (JRPC.isError(res)) {
log.warn('unable to resolve chainId for %s: %s', provider, JSON.stringify(res.error));
// check HTTP response status and determine error
if (res.status !== 200) {
try {
log.warn('unable to resolve chainId for %s: %s', provider, await res.text());
}
catch (err) {
log.error('unable to determine error message for failed chainId call to %s: %s[%o]', provider, JSON.stringify(err), err);
}
return;
}
const id = parseInt(res.result, 16);
this.chainIds.set(provider, id);
// check JRPC payload and determine error
try {
const jrpc = await res.json();
if (JRPC.isError(jrpc)) {
log.warn('jrpc error response for chainId request to %s: %s', provider, JSON.stringify(jrpc.error));
}
else {
const id = parseInt(jrpc.result, 16);
log.info('determined chain id %d for %s', id, provider);
this.chainIds.set(provider, id);
}
}
catch (err) {
log.error('unable to resolve json response for chainId call to %s, %s[%o]', provider, JSON.stringify(err), err);
}
};

@@ -443,0 +466,0 @@ this.determineProvider = ({ provider }, { method }) => {

7

build/jrpc.d.ts

@@ -22,8 +22,3 @@ export type Request = {

};
export declare function chainId(id: string): {
jsonrpc: string;
method: string;
id: string;
params: never[];
};
export declare function chainId(id: string): Request;
export declare function isError(r: Response): r is Error;

@@ -7,3 +7,2 @@ import * as JRPC from './jrpc';

};
export declare function fetchChainId(provider: string): Promise<JRPC.Response>;
export declare function fetchRPC(provider: string, req: JRPC.Request, reqHeaders?: Record<string, string>): Promise<Res.Result<JRPC.Response, RPCFailure>>;

@@ -26,17 +26,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.fetchRPC = exports.fetchChainId = void 0;
const JRPC = __importStar(require("./jrpc"));
exports.fetchRPC = void 0;
const Res = __importStar(require("./result"));
function fetchChainId(provider) {
const url = new URL(provider);
const headers = { 'Content-Type': 'application/json' };
const body = JSON.stringify(JRPC.chainId(provider));
return fetch(url, { headers, method: 'POST', body }).then(async (res) => {
if (res.status !== 200) {
throw new Error(`Unexpected response: ${res.status}, ${await res.text()}`);
}
return res.json();
});
}
exports.fetchChainId = fetchChainId;
function fetchRPC(provider, req, reqHeaders) {

@@ -43,0 +30,0 @@ return new Promise((resolve, reject) => {

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

declare const _default: "1.10.0";
declare const _default: "1.10.1";
export default _default;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = '1.10.0';
exports.default = '1.10.1';
# @rpch/sdk
## 1.10.1
### Patch Changes
- 8225d5c: route chain id request through RPCh instead of directly calling it
## 1.10.0

@@ -4,0 +10,0 @@

{
"name": "@rpch/sdk",
"version": "1.10.0",
"version": "1.10.1",
"license": "LGPL-3.0",

@@ -5,0 +5,0 @@ "main": "./build/index.js",

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