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

@greymass/eosio

Package Overview
Dependencies
Maintainers
2
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@greymass/eosio - npm Package Compare versions

Comparing version 0.2.7 to 0.3.0

15

lib/eosio-core.d.ts
/**
* EOSIO Core v0.2.7
* EOSIO Core v0.3.0
* https://github.com/greymass/eosio-core

@@ -735,4 +735,8 @@ *

resolveType(name: string): ABI.ResolvedType;
resolveAll(): {
types: ABI.ResolvedType[];
variants: ABI.ResolvedType[];
structs: ABI.ResolvedType[];
};
private resolve;
resolveStruct(name: string): ABI.Field[] | undefined;
getStruct(name: string): ABI.Struct | undefined;

@@ -792,3 +796,3 @@ getVariant(name: string): ABI.Variant | undefined;

isExtension: boolean;
parent?: ResolvedType;
base?: ResolvedType;
fields?: {

@@ -805,2 +809,7 @@ name: string;

get typeName(): string;
/** All fields including base struct(s), undefined if not a struct type. */
get allFields(): {
name: string;
type: ResolvedType;
}[] | undefined;
}

@@ -807,0 +816,0 @@ }

10

package.json
{
"name": "@greymass/eosio",
"description": "Library for working with EOSIO blockchains",
"version": "0.2.7",
"version": "0.3.0",
"homepage": "https://github.com/greymass/eosio-core",

@@ -23,5 +23,5 @@ "license": "BSD-3-Clause",

"dependencies": {
"bn.js": "^4.4.0",
"brorand": "^1.0.1",
"elliptic": "^6.5.3",
"bn.js": "^4.11.9",
"brorand": "^1.1.0",
"elliptic": "^6.5.4",
"hash.js": "^1.0.0",

@@ -38,3 +38,3 @@ "tslib": "^2.0.3"

"eslint": "^7.19.0",
"eslint-config-prettier": "^7.0.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-prettier": "^3.2.0",

@@ -41,0 +41,0 @@ "mocha": "^8.2.1",

@@ -50,2 +50,12 @@ import {isInstanceOf} from '../utils'

resolveAll() {
const types: {[name: string]: ABI.ResolvedType} = {}
const ctx: {id: number} = {id: 0}
return {
types: this.types.map((t) => this.resolve({name: t.new_type_name, types}, ctx)),
variants: this.variants.map((t) => this.resolve({name: t.name, types}, ctx)),
structs: this.structs.map((t) => this.resolve({name: t.name, types}, ctx)),
}
}
private resolve(

@@ -66,5 +76,8 @@ {name, types}: {name: string; types: {[name: string]: ABI.ResolvedType}},

}
const fields = this.resolveStruct(type.name)
if (fields) {
type.fields = fields.map((field) => {
const struct = this.getStruct(type.name)
if (struct) {
if (struct.base) {
type.base = this.resolve({name: struct.base, types}, ctx)
}
type.fields = struct.fields.map((field) => {
return {

@@ -86,22 +99,2 @@ name: field.name,

resolveStruct(name: string): ABI.Field[] | undefined {
let top = this.getStruct(name)
if (!top) {
return
}
const rv: ABI.Field[] = []
const seen = new Set<string>()
do {
for (let i = top!.fields.length - 1; i >= 0; i--) {
rv.unshift(top!.fields[i])
}
seen.add(top!.name)
if (seen.has(top!.base)) {
return // circular ref
}
top = this.getStruct(top!.base)
} while (top !== undefined)
return rv
}
getStruct(name: string): ABI.Struct | undefined {

@@ -175,3 +168,3 @@ return this.structs.find((struct) => struct.name == name)

parent?: ResolvedType
base?: ResolvedType
fields?: {name: string; type: ResolvedType}[]

@@ -221,3 +214,25 @@ variant?: ResolvedType[]

}
/** All fields including base struct(s), undefined if not a struct type. */
get allFields() {
// eslint-disable-next-line @typescript-eslint/no-this-alias
let current: ResolvedType | undefined = this
const rv: {name: string; type: ResolvedType}[] = []
const seen = new Set<string>()
do {
if (!current.fields) {
return // invalid struct
}
if (seen.has(current.name)) {
return // circular ref
}
for (let i = current.fields.length - 1; i >= 0; i--) {
rv.unshift(current.fields[i])
}
seen.add(current.name)
current = current.base
} while (current !== undefined)
return rv
}
}
}

@@ -181,4 +181,8 @@ /**

} else if (type.fields) {
const fields = type.allFields
if (!fields) {
throw new Error('Invalid struct fields')
}
const rv: any = {}
for (const field of type.fields) {
for (const field of fields) {
ctx.codingPath.push({field: field.name, type: field.type})

@@ -212,3 +216,3 @@ rv[field.name] = decodeBinary(field.type, decoder, ctx)

throw new Error(
type.name === 'any' ? 'Unable to decode any type from binary' : 'Unknown type'
type.name === 'any' ? "Unable to decode 'any' type from binary" : 'Unknown type'
)

@@ -254,4 +258,8 @@ }

}
const fields = type.allFields
if (!fields) {
throw new Error('Invalid struct fields')
}
const struct: any = {}
for (const field of type.fields) {
for (const field of fields) {
ctx.codingPath.push({field: field.name, type: field.type})

@@ -258,0 +266,0 @@ struct[field.name] = decodeObject(value[field.name], field.type, ctx)

@@ -199,3 +199,7 @@ /**

}
for (const field of type.fields) {
const fields = type.allFields
if (!fields) {
throw new Error('Invalid struct fields')
}
for (const field of fields) {
ctx.codingPath.push({field: field.name, type: field.type})

@@ -202,0 +206,0 @@ encodeAny(value[field.name], field.type, ctx)

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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