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

@truffle/blockchain-utils

Package Overview
Dependencies
Maintainers
6
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@truffle/blockchain-utils - npm Package Compare versions

Comparing version 0.0.15-alphaTez.0 to 0.0.15-micah.0

86

index.ts

@@ -1,6 +0,10 @@

import { Provider, Callback, JsonRPCResponse } from "web3/providers"
import { parsedUriObject } from "typings"
import { parsedUriObject } from "typings";
import { Callback, JsonRpcResponse, Provider } from "@truffle/provider";
const Blockchain = {
getBlockByNumber(blockNumber: string, provider: Provider, callback: Callback<JsonRPCResponse>) {
getBlockByNumber(
blockNumber: string,
provider: Provider,
callback: Callback<JsonRpcResponse>
) {
const params = [blockNumber, true];

@@ -18,3 +22,7 @@ provider.send(

getBlockByHash(blockHash: string, provider: Provider, callback: Callback<JsonRPCResponse>) {
getBlockByHash(
blockHash: string,
provider: Provider,
callback: Callback<JsonRpcResponse>
) {
const params = [blockHash, true];

@@ -49,16 +57,24 @@ provider.send(

this.getBlockByNumber("0x0", provider, (err: Error, { result } : JsonRPCResponse) => {
if (err) return callback(err);
genesis = result;
this.getBlockByNumber(
"0x0",
provider,
(err: Error, { result }: JsonRpcResponse) => {
if (err) return callback(err);
genesis = result;
this.getBlockByNumber("latest", provider, (err: Error, { result } : JsonRPCResponse) => {
if (err) return callback(err);
latest = result;
const url = `blockchain://${genesis.hash.replace(
"0x",
""
)}/block/${latest.hash.replace("0x", "")}`;
callback(null, url);
});
});
this.getBlockByNumber(
"latest",
provider,
(err: Error, { result }: JsonRpcResponse) => {
if (err) return callback(err);
latest = result;
const url = `blockchain://${genesis.hash.replace(
"0x",
""
)}/block/${latest.hash.replace("0x", "")}`;
callback(null, url);
}
);
}
);
},

@@ -72,18 +88,26 @@

this.getBlockByNumber("0x0", provider, (err: Error, { result } : JsonRPCResponse) => {
if (err) return callback(err);
const block = result;
if (block.hash !== expected_genesis) return callback(null, false);
this.getBlockByHash(expected_block, provider, (err: Error, { result } : JsonRPCResponse) => {
// Treat an error as if the block didn't exist. This is because
// some clients respond differently.
this.getBlockByNumber(
"0x0",
provider,
(err: Error, { result }: JsonRpcResponse) => {
if (err) return callback(err);
const block = result;
if (err || block == null) {
return callback(null, false);
}
if (block.hash !== expected_genesis) return callback(null, false);
callback(null, true);
});
});
this.getBlockByHash(
expected_block,
provider,
(err: Error, { result }: JsonRpcResponse) => {
// Treat an error as if the block didn't exist. This is because
// some clients respond differently.
const block = result;
if (err || block == null) {
return callback(null, false);
}
callback(null, true);
}
);
}
);
}

@@ -90,0 +114,0 @@ };

@@ -11,3 +11,3 @@ {

},
"version": "0.0.15-alphaTez.0",
"version": "0.0.15-micah.0",
"main": "dist/index.js",

@@ -22,3 +22,3 @@ "scripts": {

"@types/assert": "^1.4.2",
"@types/web3": "^1.0.19",
"@types/node": "^12.12.5",
"mocha": "5.2.0",

@@ -36,3 +36,6 @@ "ts-node": "^8.3.0",

},
"gitHead": "417061491cba7e36296fd012181ea66958636124"
"dependencies": {
"@truffle/provider": "^0.2.2-micah.0"
},
"gitHead": "03adee6cc853ee4babd40381fa06a9e03ea1c126"
}

@@ -13,5 +13,5 @@ {

"paths": {
"web3": [
"../../node_modules/@types/web3/index",
"node_modules/web3/index"
"net": [
"../../node_modules/@types/node",
"node_modules/@types/node"
]

@@ -23,3 +23,2 @@ },

"../../**/node_modules/@types/mocha",
"../../**/node_modules/@types/web3",
"../../**/node_modules/@types/assert"

@@ -26,0 +25,0 @@ ]

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