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.1.0-ens-events.0 to 0.1.0-tezos.0

86

index.ts

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

import { Provider, Callback, JsonRPCResponse } from "web3/providers"
import { parsedUriObject } from "typings"
import { Provider, Callback, JsonRPCResponse } from "web3/providers";
import { parsedUriObject } from "typings";
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.1.0-ens-events.0",
"version": "0.1.0-tezos.0",
"main": "dist/index.js",

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

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

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

},
"gitHead": "0327ff65cb9f9cc5641fdad91e6ed0eea2df9f69"
"gitHead": "c2fd8c5e2664a9f8c51fc043a1f7b4b3ab0be2fa"
}

@@ -21,5 +21,5 @@ {

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

@@ -26,0 +26,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