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

@0xcert/ethereum-generic-provider

Package Overview
Dependencies
Maintainers
2
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@0xcert/ethereum-generic-provider - npm Package Compare versions

Comparing version 2.0.0-alpha1 to 2.0.0-alpha2

.nyc_output/e3c977b9-834a-4113-962d-066ce937c998.json

4

CHANGELOG.json

@@ -5,4 +5,4 @@ {

{
"version": "2.0.0-alpha1",
"tag": "@0xcert/ethereum-generic-provider_v2.0.0-alpha1",
"version": "2.0.0-alpha2",
"tag": "@0xcert/ethereum-generic-provider_v2.0.0-alpha2",
"date": "Wed, 19 Jun 2019 10:31:05 GMT",

@@ -9,0 +9,0 @@ "comments": {}

@@ -5,3 +5,3 @@ # Change Log - @0xcert/ethereum-generic-provider

## 2.0.0-alpha1
## 2.0.0-alpha2
Wed, 19 Jun 2019 10:31:05 GMT

@@ -8,0 +8,0 @@

/// <reference types="node" />
import { MutationBase, MutationEvent } from '@0xcert/scaffold';
import { MutationBase, MutationContext, MutationEvent } from '@0xcert/scaffold';
import { EventEmitter } from 'events';

@@ -19,3 +19,5 @@ export declare enum MutationStatus {

protected _status: MutationStatus;
constructor(provider: any, id: string);
protected _context?: any;
protected _logs: any[];
constructor(provider: any, id: string, context?: MutationContext);
readonly id: string;

@@ -26,2 +28,3 @@ readonly provider: any;

readonly receiverId: string;
readonly logs: any[];
isPending(): boolean;

@@ -46,2 +49,3 @@ isCompleted(): boolean;

protected getLastBlock(): Promise<number>;
protected parseLogs(): Promise<void>;
}

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

const events_1 = require("events");
const types_1 = require("./types");
var MutationStatus;

@@ -22,3 +23,3 @@ (function (MutationStatus) {

class Mutation extends events_1.EventEmitter {
constructor(provider, id) {
constructor(provider, id, context) {
super();

@@ -28,2 +29,3 @@ this._confirmations = 0;

this._status = MutationStatus.INITIALIZED;
this._logs = [];
this._id = id;

@@ -34,2 +36,3 @@ this._provider = provider;

}
this._context = context;
}

@@ -51,2 +54,5 @@ get id() {

}
get logs() {
return this._logs;
}
isPending() {

@@ -124,2 +130,3 @@ return this._status === MutationStatus.PENDING;

if (this._confirmations >= this._provider.requiredConfirmations) {
yield this.parseLogs();
this._status = MutationStatus.COMPLETED;

@@ -166,4 +173,39 @@ return this.emit(scaffold_1.MutationEvent.COMPLETE, this);

}
parseLogs() {
return __awaiter(this, void 0, void 0, function* () {
try {
this._logs = [];
const eventSignatures = this._context.getContext();
if (!eventSignatures) {
return;
}
const transactionReceipt = yield this.getTransactionReceipt();
transactionReceipt.logs.forEach((log) => {
const eventSignature = eventSignatures.find((e) => e.topic == log.topics[0]);
if (!eventSignature) {
return;
}
const obj = {};
obj['event'] = eventSignature.name;
const normal = eventSignature.types.filter((t) => t.kind === types_1.MutationEventTypeKind.NORMAL);
const indexed = eventSignature.types.filter((t) => t.kind === types_1.MutationEventTypeKind.INDEXED);
if (normal.length > 0) {
const normalTypes = normal.map((n) => n.type);
const decoded = this._provider.encoder.decodeParameters(normalTypes, log.data);
normal.forEach((n, idx) => {
obj[n.name] = decoded[idx];
});
}
indexed.forEach((i, idx) => {
obj[i.name] = this._provider.encoder.decodeParameters([i.type], log.topics[idx + 1])[0];
});
this._logs.push(obj);
});
}
catch (e) {
}
});
}
}
exports.Mutation = Mutation;
//# sourceMappingURL=mutation.js.map

@@ -23,1 +23,20 @@ export interface GatewayConfig {

}
export interface MutationEventSignature {
topic: string;
name: string;
types: MutationEventType[];
}
export interface MutationEventType {
kind: MutationEventTypeKind;
name: string;
type: string;
}
export declare enum MutationEventTypeKind {
NORMAL = 0,
INDEXED = 1
}
export declare enum NetworkKind {
LIVE = 0,
ROPSTEN = 1,
RINKEBY = 2
}

@@ -10,2 +10,13 @@ "use strict";

})(SignMethod = exports.SignMethod || (exports.SignMethod = {}));
var MutationEventTypeKind;
(function (MutationEventTypeKind) {
MutationEventTypeKind[MutationEventTypeKind["NORMAL"] = 0] = "NORMAL";
MutationEventTypeKind[MutationEventTypeKind["INDEXED"] = 1] = "INDEXED";
})(MutationEventTypeKind = exports.MutationEventTypeKind || (exports.MutationEventTypeKind = {}));
var NetworkKind;
(function (NetworkKind) {
NetworkKind[NetworkKind["LIVE"] = 0] = "LIVE";
NetworkKind[NetworkKind["ROPSTEN"] = 1] = "ROPSTEN";
NetworkKind[NetworkKind["RINKEBY"] = 2] = "RINKEBY";
})(NetworkKind = exports.NetworkKind || (exports.NetworkKind = {}));
//# sourceMappingURL=types.js.map

@@ -7,1 +7,2 @@ export * from '@0xcert/scaffold/dist/core/mutation';

export * from './core/types';
export * from './core/helpers';

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

__export(require("./core/types"));
__export(require("./core/helpers"));
//# sourceMappingURL=index.js.map

@@ -6,7 +6,9 @@ "use strict";

const spec = new spec_1.Spec();
spec.test('exposes objects', (ctx) => {
spec.only('exposes objects', (ctx) => {
ctx.true(!!view.GenericProvider);
ctx.true(!!view.SignMethod);
ctx.true(!!view.buildGatewayConfig);
ctx.true(!!view.NetworkKind);
});
exports.default = spec;
//# sourceMappingURL=index.test.js.map
{
"name": "@0xcert/ethereum-generic-provider",
"version": "2.0.0-alpha1",
"version": "2.0.0-alpha2",
"description": "Basic implementation of communication provider for the Ethereum blockchain.",

@@ -70,7 +70,7 @@ "main": "./dist/index.js",

"devDependencies": {
"@0xcert/ethereum-sandbox": "2.0.0-alpha1",
"@0xcert/ethereum-sandbox": "2.0.0-alpha2",
"@types/node": "^10.12.24",
"@specron/cli": "^0.5.6",
"@specron/spec": "^0.5.6",
"nyc": "^13.1.0",
"nyc": "^14.1.1",
"promised-timeout": "^0.5.1",

@@ -84,6 +84,6 @@ "solc": "0.5.6",

"dependencies": {
"@0xcert/ethereum-utils": "2.0.0-alpha1",
"@0xcert/scaffold": "2.0.0-alpha1",
"@0xcert/ethereum-utils": "2.0.0-alpha2",
"@0xcert/scaffold": "2.0.0-alpha2",
"events": "^3.0.0"
}
}
import { normalizeAddress } from '@0xcert/ethereum-utils/dist/lib/normalize-address';
import { MutationBase, MutationEvent } from '@0xcert/scaffold';
import { MutationBase, MutationContext, MutationEvent } from '@0xcert/scaffold';
import { EventEmitter } from 'events';
import { MutationEventSignature, MutationEventTypeKind } from './types';

@@ -65,7 +66,18 @@ /**

/**
* Context.
*/
protected _context?: any;
/**
* Mutations logs.
*/
protected _logs: any[] = [];
/**
* Initialize mutation.
* @param provider Provider class with which we comunicate with blockchain.
* @param id Smart contract address on which a mutation will be performed.
* @param context Mutation context.
*/
public constructor(provider: any, id: string) {
public constructor(provider: any, id: string, context?: MutationContext) {
super();

@@ -78,2 +90,3 @@

}
this._context = context;
}

@@ -117,2 +130,9 @@

/**
* Gets mutation logs.
*/
public get logs() {
return this._logs;
}
/**
* Checks if mutation in pending.

@@ -238,2 +258,3 @@ */

if (this._confirmations >= this._provider.requiredConfirmations) {
await this.parseLogs();
this._status = MutationStatus.COMPLETED;

@@ -284,2 +305,39 @@ return this.emit(MutationEvent.COMPLETE, this); // success

/**
* Parses transaction receipt logs.
*/
protected async parseLogs() {
try {
this._logs = [];
const eventSignatures: MutationEventSignature[] = this._context.getContext();
if (!eventSignatures) {
return;
}
const transactionReceipt = await this.getTransactionReceipt();
transactionReceipt.logs.forEach((log) => {
const eventSignature = eventSignatures.find((e) => e.topic == log.topics[0]);
if (!eventSignature) {
return;
}
const obj = {};
obj['event'] = eventSignature.name;
const normal = eventSignature.types.filter((t) => t.kind === MutationEventTypeKind.NORMAL);
const indexed = eventSignature.types.filter((t) => t.kind === MutationEventTypeKind.INDEXED);
if (normal.length > 0) {
const normalTypes = normal.map((n) => n.type);
const decoded = this._provider.encoder.decodeParameters(normalTypes, log.data);
normal.forEach((n, idx) => {
obj[n.name] = decoded[idx];
});
}
indexed.forEach((i, idx) => {
obj[i.name] = this._provider.encoder.decodeParameters([i.type], log.topics[idx + 1])[0];
});
this._logs.push(obj);
});
} catch (e) {
// We don't do anything.
}
}
}

@@ -78,1 +78,36 @@ /**

}
/**
* Mutation event signature definition.
*/
export interface MutationEventSignature {
topic: string;
name: string;
types: MutationEventType[];
}
/**
* Mutation event type definition.
*/
export interface MutationEventType {
kind: MutationEventTypeKind;
name: string;
type: string;
}
/**
* Mutation event type kind definition.
*/
export enum MutationEventTypeKind {
NORMAL = 0,
INDEXED = 1,
}
/**
* Network kind.
*/
export enum NetworkKind {
LIVE,
ROPSTEN,
RINKEBY,
}

@@ -7,1 +7,2 @@ export * from '@0xcert/scaffold/dist/core/mutation';

export * from './core/types';
export * from './core/helpers';

@@ -6,7 +6,9 @@ import { Spec } from '@specron/spec';

spec.test('exposes objects', (ctx) => {
spec.only('exposes objects', (ctx) => {
ctx.true(!!view.GenericProvider);
ctx.true(!!view.SignMethod);
ctx.true(!!view.buildGatewayConfig);
ctx.true(!!view.NetworkKind);
});
export default spec;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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