bitski-provider
Advanced tools
Comparing version 0.2.3 to 0.3.0
@@ -6,5 +6,6 @@ /// <reference path="../types/web3-provider-engine.d.ts" /> | ||
import InflightCacheSubprovider from 'web3-provider-engine/subproviders/inflight-cache'; | ||
import NonceTrackerSubprovider from 'web3-provider-engine/subproviders/nonce-tracker'; | ||
import SanitizingSubprovider from 'web3-provider-engine/subproviders/sanitizer'; | ||
import SubscriptionSubprovider from 'web3-provider-engine/subproviders/subscriptions'; | ||
import { NonceTrackerSubprovider } from './subproviders/nonce-tracker'; | ||
import { TransactionValidatorSubprovider } from './subproviders/transaction-validator'; | ||
export class BitskiEngine extends Web3ProviderEngine { | ||
@@ -15,2 +16,3 @@ constructor(options) { | ||
this.addProvider(new NonceTrackerSubprovider()); | ||
this.addProvider(new TransactionValidatorSubprovider()); | ||
this.addProvider(new SanitizingSubprovider()); | ||
@@ -25,2 +27,12 @@ this.addProvider(new CacheSubprovider()); | ||
} | ||
// Some versions of web3 prefer to use send(payload, callback) instead of sendAsync() with a callback. | ||
send(payload) { | ||
// Typescript doesn't like overrides with overloads, so use arguments array. | ||
if (typeof arguments[1] === 'function') { | ||
this.sendAsync(payload, arguments[1]); | ||
} | ||
else { | ||
throw new Error('synchronous requests are not supported'); | ||
} | ||
} | ||
} |
/// <reference path="../types/web3-provider-engine.d.ts" /> | ||
import { JSONRPCRequestPayload } from 'ethereum-protocol'; | ||
import Web3ProviderEngine from 'web3-provider-engine'; | ||
export declare class BitskiEngine extends Web3ProviderEngine { | ||
constructor(options: any); | ||
send(payload: JSONRPCRequestPayload): void; | ||
} |
@@ -24,3 +24,3 @@ /// <reference path="../types/web3-provider-engine.d.ts" /> | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports", "web3-provider-engine", "web3-provider-engine/subproviders/cache", "web3-provider-engine/subproviders/default-fixture", "web3-provider-engine/subproviders/inflight-cache", "web3-provider-engine/subproviders/nonce-tracker", "web3-provider-engine/subproviders/sanitizer", "web3-provider-engine/subproviders/subscriptions"], factory); | ||
define(["require", "exports", "web3-provider-engine", "web3-provider-engine/subproviders/cache", "web3-provider-engine/subproviders/default-fixture", "web3-provider-engine/subproviders/inflight-cache", "web3-provider-engine/subproviders/sanitizer", "web3-provider-engine/subproviders/subscriptions", "./subproviders/nonce-tracker", "./subproviders/transaction-validator"], factory); | ||
} | ||
@@ -34,5 +34,6 @@ })(function (require, exports) { | ||
var inflight_cache_1 = __importDefault(require("web3-provider-engine/subproviders/inflight-cache")); | ||
var nonce_tracker_1 = __importDefault(require("web3-provider-engine/subproviders/nonce-tracker")); | ||
var sanitizer_1 = __importDefault(require("web3-provider-engine/subproviders/sanitizer")); | ||
var subscriptions_1 = __importDefault(require("web3-provider-engine/subproviders/subscriptions")); | ||
var nonce_tracker_1 = require("./subproviders/nonce-tracker"); | ||
var transaction_validator_1 = require("./subproviders/transaction-validator"); | ||
var BitskiEngine = /** @class */ (function (_super) { | ||
@@ -43,3 +44,4 @@ __extends(BitskiEngine, _super); | ||
_this.addProvider(new default_fixture_1.default()); | ||
_this.addProvider(new nonce_tracker_1.default()); | ||
_this.addProvider(new nonce_tracker_1.NonceTrackerSubprovider()); | ||
_this.addProvider(new transaction_validator_1.TransactionValidatorSubprovider()); | ||
_this.addProvider(new sanitizer_1.default()); | ||
@@ -55,2 +57,12 @@ _this.addProvider(new cache_1.default()); | ||
} | ||
// Some versions of web3 prefer to use send(payload, callback) instead of sendAsync() with a callback. | ||
BitskiEngine.prototype.send = function (payload) { | ||
// Typescript doesn't like overrides with overloads, so use arguments array. | ||
if (typeof arguments[1] === 'function') { | ||
this.sendAsync(payload, arguments[1]); | ||
} | ||
else { | ||
throw new Error('synchronous requests are not supported'); | ||
} | ||
}; | ||
return BitskiEngine; | ||
@@ -57,0 +69,0 @@ }(web3_provider_engine_1.default)); |
@@ -12,3 +12,3 @@ { | ||
}, | ||
"version": "0.2.3", | ||
"version": "0.3.0", | ||
"scripts": { | ||
@@ -50,3 +50,3 @@ "build": "tsc -p tsconfig.main.json && tsc -p tsconfig.module.json", | ||
}, | ||
"gitHead": "4b32762af466baf24636b421cf4b2b935e669d2d" | ||
"gitHead": "f59a0f95948928ca357652c020113162288533fc" | ||
} |
/// <reference path="../types/web3-provider-engine.d.ts" /> | ||
import { JSONRPCRequestPayload } from 'ethereum-protocol'; | ||
import Web3ProviderEngine from 'web3-provider-engine'; | ||
@@ -7,6 +8,8 @@ import CacheSubprovider from 'web3-provider-engine/subproviders/cache'; | ||
import InflightCacheSubprovider from 'web3-provider-engine/subproviders/inflight-cache'; | ||
import NonceTrackerSubprovider from 'web3-provider-engine/subproviders/nonce-tracker'; | ||
import SanitizingSubprovider from 'web3-provider-engine/subproviders/sanitizer'; | ||
import SubscriptionSubprovider from 'web3-provider-engine/subproviders/subscriptions'; | ||
import { NonceTrackerSubprovider } from './subproviders/nonce-tracker'; | ||
import { TransactionValidatorSubprovider } from './subproviders/transaction-validator'; | ||
export class BitskiEngine extends Web3ProviderEngine { | ||
@@ -18,2 +21,3 @@ | ||
this.addProvider(new NonceTrackerSubprovider()); | ||
this.addProvider(new TransactionValidatorSubprovider()); | ||
this.addProvider(new SanitizingSubprovider()); | ||
@@ -31,2 +35,12 @@ this.addProvider(new CacheSubprovider()); | ||
// Some versions of web3 prefer to use send(payload, callback) instead of sendAsync() with a callback. | ||
public send(payload: JSONRPCRequestPayload) { | ||
// Typescript doesn't like overrides with overloads, so use arguments array. | ||
if (typeof arguments[1] === 'function') { | ||
this.sendAsync(payload, arguments[1]); | ||
} else { | ||
throw new Error('synchronous requests are not supported'); | ||
} | ||
} | ||
} |
@@ -6,1 +6,10 @@ import { BitskiEngine } from "../src"; | ||
}); | ||
test('it forwards sends when callback is present', () => { | ||
const engine = new BitskiEngine({}); | ||
engine.start(); | ||
const spy = jest.spyOn(engine, 'sendAsync'); | ||
// @ts-ignore | ||
engine.send({}, jest.fn()); | ||
expect(spy).toBeCalled(); | ||
}); |
@@ -42,4 +42,18 @@ // Type definitions for web3-provider-engine 14.0 | ||
declare module "web3-provider-engine/subproviders/subprovider" { | ||
import { JSONRPCRequestPayload, JSONRPCResponsePayload } from "ethereum-protocol"; | ||
import Web3ProviderEngine from "web3-provider-engine"; | ||
class Subprovider { | ||
engine?: Web3ProviderEngine; | ||
setEngine(engine: Web3ProviderEngine); | ||
handleRequest(payload: JSONRPCRequestPayload, next: () => void, end: () => void); | ||
emitPayload(payload: JSONRPCRequestPayload, callback: (error: null | Error, response: JSONRPCResponsePayload) => void); | ||
} | ||
export = Subprovider; | ||
} | ||
// declare module "web3-provider-engine/subproviders/nonce-tracker"; | ||
// declare module "web3-provider-engine/subproviders/hooked-wallet"; | ||
// declare module "web3-provider-engine/subproviders/filters"; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
75338
50
1621