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.19-alphaTez.0 to 0.0.19

61

dist/index.js
"use strict";
require("source-map-support/register");
const Blockchain = {

@@ -31,35 +32,39 @@ getBlockByNumber(blockNumber, provider, callback) {

},
asURI(provider, callback) {
let genesis, latest;
this.getBlockByNumber("0x0", provider, (err, { result }) => {
if (err)
return callback(err);
genesis = result;
this.getBlockByNumber("latest", provider, (err, { result }) => {
asURI(provider) {
return new Promise((resolve, reject) => {
let genesis, latest;
this.getBlockByNumber("0x0", provider, (err, { result }) => {
if (err)
return callback(err);
latest = result;
const url = `blockchain://${genesis.hash.replace("0x", "")}/block/${latest.hash.replace("0x", "")}`;
callback(null, url);
return reject(err);
genesis = result;
this.getBlockByNumber("latest", provider, (err, { result }) => {
if (err)
return reject(err);
latest = result;
const url = `blockchain://${genesis.hash.replace("0x", "")}/block/${latest.hash.replace("0x", "")}`;
resolve(url);
});
});
});
},
matches(uri, provider, callback) {
const parsedUri = this.parse(uri);
const expected_genesis = parsedUri.genesis_hash;
const expected_block = parsedUri.block_hash;
this.getBlockByNumber("0x0", provider, (err, { result }) => {
if (err)
return callback(err);
const block = result;
if (block.hash !== expected_genesis)
return callback(null, false);
this.getBlockByHash(expected_block, provider, (err, { result }) => {
// Treat an error as if the block didn't exist. This is because
// some clients respond differently.
matches(uri, provider) {
return new Promise((resolve, reject) => {
const parsedUri = this.parse(uri);
const expected_genesis = parsedUri.genesis_hash;
const expected_block = parsedUri.block_hash;
this.getBlockByNumber("0x0", provider, (err, { result }) => {
if (err)
return reject(err);
const block = result;
if (err || block == null) {
return callback(null, false);
}
callback(null, true);
if (block.hash !== expected_genesis)
return resolve(false);
this.getBlockByHash(expected_block, provider, (err, { result }) => {
// 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 resolve(false);
}
resolve(true);
});
});

@@ -66,0 +71,0 @@ });

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

import "source-map-support/register";
import { Provider, Callback, JsonRPCResponse } from "web3/providers";

@@ -53,59 +54,63 @@ import { parsedUriObject } from "typings";

asURI(provider: Provider, callback: Callback<any>) {
let genesis: any, latest;
asURI(provider: Provider) {
return new Promise((resolve, reject) => {
let genesis: any, latest;
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 reject(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 reject(err);
latest = result;
const url = `blockchain://${genesis.hash.replace(
"0x",
""
)}/block/${latest.hash.replace("0x", "")}`;
resolve(url);
}
);
}
);
});
},
matches(uri: string, provider: Provider, callback: Callback<any>) {
const parsedUri = this.parse(uri);
matches(uri: string, provider: Provider) {
return new Promise((resolve, reject) => {
const parsedUri = this.parse(uri);
const expected_genesis = parsedUri.genesis_hash;
const expected_block = parsedUri.block_hash;
const expected_genesis = parsedUri.genesis_hash;
const expected_block = parsedUri.block_hash;
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.getBlockByNumber(
"0x0",
provider,
(err: Error, { result }: JsonRPCResponse) => {
if (err) return reject(err);
const block = result;
if (block.hash !== expected_genesis) return resolve(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.
const block = result;
if (err || block == null) {
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.
const block = result;
if (err || block == null) {
return resolve(false);
}
resolve(true);
}
callback(null, true);
}
);
}
);
);
}
);
});
}

@@ -112,0 +117,0 @@ };

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

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

@@ -37,3 +37,6 @@ "scripts": {

},
"gitHead": "9c106f4529dc4e3a2e88e722aea53a40eea5e4de"
"dependencies": {
"source-map-support": "^0.5.19"
},
"gitHead": "cd27f14cf31ad6d3201ebbaa9bfa5eb83dbc590a"
}

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