@greymass/eosio
Advanced tools
Comparing version 0.2.3 to 0.2.4
/** | ||
* EOSIO Core v0.2.3 | ||
* EOSIO Core v0.2.4 | ||
* https://github.com/greymass/eosio-core | ||
@@ -676,2 +676,3 @@ * | ||
declare class TimePointBase implements ABISerializableObject { | ||
static abiName: string; | ||
static from<T extends TimePointConstructor>(this: T, value: TimePointType): InstanceType<T>; | ||
@@ -1011,3 +1012,3 @@ static from(value: TimePointType): unknown; | ||
interface ActionFields { | ||
interface ActionBase { | ||
/** The account (a.k.a. contract) to run action on. */ | ||
@@ -1019,2 +1020,4 @@ account: NameType; | ||
authorization: PermissionLevelType[]; | ||
} | ||
interface ActionFields extends ActionBase { | ||
/** The ABI-encoded action data. */ | ||
@@ -1024,6 +1027,3 @@ data: BytesType; | ||
/** Action type that may or may not have its data encoded */ | ||
interface AnyAction { | ||
account: NameType; | ||
name: NameType; | ||
authorization: PermissionLevelType[]; | ||
interface AnyAction extends ActionBase { | ||
data: BytesType | ABISerializable; | ||
@@ -1044,3 +1044,3 @@ } | ||
equals(other: ActionType | AnyAction): boolean; | ||
/** Return action data decoded as given type or using abi. */ | ||
/** Return action data decoded as given type or using ABI. */ | ||
decodeData<T extends ABISerializableConstructor>(type: T): InstanceType<T>; | ||
@@ -1047,0 +1047,0 @@ decodeData<T extends keyof BuiltinTypes>(type: T): BuiltinTypes[T]; |
{ | ||
"name": "@greymass/eosio", | ||
"description": "Library for working with EOSIO blockchains", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"homepage": "https://github.com/greymass/eosio-core", | ||
@@ -30,3 +30,3 @@ "license": "BSD-3-Clause", | ||
"devDependencies": { | ||
"@rollup/plugin-typescript": "^8.0.0", | ||
"@rollup/plugin-typescript": "^8.1.1", | ||
"@types/elliptic": "^6.4.12", | ||
@@ -36,3 +36,3 @@ "@types/mocha": "^8.0.3", | ||
"@typescript-eslint/parser": "^4.9.0", | ||
"eslint": "^7.15.0", | ||
"eslint": "^7.19.0", | ||
"eslint-config-prettier": "^7.0.0", | ||
@@ -44,3 +44,3 @@ "eslint-plugin-prettier": "^3.2.0", | ||
"prettier": "^2.2.1", | ||
"rollup": "^2.34.1", | ||
"rollup": "^2.38.2", | ||
"rollup-plugin-dts": "^2.0.0", | ||
@@ -47,0 +47,0 @@ "ts-node": "^9.1.0", |
@@ -24,3 +24,3 @@ import {abiEncode} from '../serializer/encoder' | ||
export interface ActionFields { | ||
interface ActionBase { | ||
/** The account (a.k.a. contract) to run action on. */ | ||
@@ -32,2 +32,5 @@ account: NameType | ||
authorization: PermissionLevelType[] | ||
} | ||
export interface ActionFields extends ActionBase { | ||
/** The ABI-encoded action data. */ | ||
@@ -38,6 +41,3 @@ data: BytesType | ||
/** Action type that may or may not have its data encoded */ | ||
export interface AnyAction { | ||
account: NameType | ||
name: NameType | ||
authorization: PermissionLevelType[] | ||
export interface AnyAction extends ActionBase { | ||
data: BytesType | ABISerializable | ||
@@ -89,3 +89,3 @@ } | ||
/** Return action data decoded as given type or using abi. */ | ||
/** Return action data decoded as given type or using ABI. */ | ||
decodeData<T extends ABISerializableConstructor>(type: T): InstanceType<T> | ||
@@ -92,0 +92,0 @@ decodeData<T extends keyof BuiltinTypes>(type: T): BuiltinTypes[T] |
@@ -14,12 +14,12 @@ import {ABISerializableObject} from '../serializer/serializable' | ||
static from(value: BytesType, encoding?: BytesEncoding): Bytes { | ||
if (isInstanceOf(value, Bytes)) { | ||
if (isInstanceOf(value, this)) { | ||
return value | ||
} | ||
if (typeof value === 'string') { | ||
return Bytes.fromString(value, encoding) | ||
return this.fromString(value, encoding) | ||
} | ||
if (isInstanceOf(value, Uint8Array)) { | ||
return new Bytes(value) | ||
return new this(value) | ||
} | ||
return new Bytes(new Uint8Array(value)) | ||
return new this(new Uint8Array(value)) | ||
} | ||
@@ -30,6 +30,6 @@ | ||
const array = hexToArray(value) | ||
return new Bytes(array) | ||
return new this(array) | ||
} else if (encoding == 'utf8') { | ||
const encoder = new TextEncoder() | ||
return new Bytes(encoder.encode(value)) | ||
return new this(encoder.encode(value)) | ||
} else { | ||
@@ -42,11 +42,11 @@ throw new Error(`Unknown encoding: ${encoding}`) | ||
const len = decoder.readVaruint32() | ||
return new Bytes(decoder.readArray(len)) | ||
return new this(decoder.readArray(len)) | ||
} | ||
static equal(a: BytesType, b: BytesType): boolean { | ||
return Bytes.from(a).equals(Bytes.from(b)) | ||
return this.from(a).equals(this.from(b)) | ||
} | ||
static random(length: number) { | ||
return new Bytes(secureRandom(length)) | ||
return new this(secureRandom(length)) | ||
} | ||
@@ -53,0 +53,0 @@ |
@@ -13,3 +13,3 @@ import {ripemd160, sha256, sha512} from 'hash.js' | ||
class Checksum implements ABISerializableObject { | ||
static abiName: string | ||
static abiName = '__checksum' | ||
static byteSize: number | ||
@@ -20,2 +20,5 @@ | ||
static from(value: ChecksumType) { | ||
if (isInstanceOf(value, this)) { | ||
return value | ||
} | ||
if (isInstanceOf(value, Checksum)) { | ||
@@ -47,3 +50,7 @@ return new this(value.array) | ||
const self = this.constructor as typeof Checksum | ||
return arrayEquals(this.array, self.from(other).array) | ||
try { | ||
return arrayEquals(this.array, self.from(other).array) | ||
} catch { | ||
return false | ||
} | ||
} | ||
@@ -50,0 +57,0 @@ |
@@ -11,3 +11,3 @@ import {ABISerializableObject} from '../serializer/serializable' | ||
class Float implements ABISerializableObject { | ||
static abiName: string | ||
static abiName = '__float' | ||
static byteWidth: number | ||
@@ -18,3 +18,3 @@ | ||
static from(value: FloatType) { | ||
if (isInstanceOf(value, this as any)) { | ||
if (isInstanceOf(value, this)) { | ||
return value | ||
@@ -25,3 +25,3 @@ } | ||
} else if (isInstanceOf(value, Float)) { | ||
value = (value as any).value as number | ||
value = value.value | ||
} | ||
@@ -28,0 +28,0 @@ return new this(value) |
@@ -11,3 +11,3 @@ import BN from 'bn.js' | ||
class Int implements ABISerializableObject { | ||
static abiName: string | ||
static abiName = '__int' | ||
static isSigned: boolean | ||
@@ -27,3 +27,3 @@ static byteWidth: number | ||
static from(value: any): any { | ||
if (isInstanceOf(value, this as typeof Int)) { | ||
if (isInstanceOf(value, this)) { | ||
return value | ||
@@ -93,3 +93,3 @@ } | ||
class BNInt implements ABISerializableObject { | ||
static abiName: string | ||
static abiName = '__bn_int' | ||
static isSigned: boolean | ||
@@ -101,3 +101,3 @@ static byteWidth: number | ||
static from(value: any): any { | ||
if (isInstanceOf(value, this as typeof BNInt)) { | ||
if (isInstanceOf(value, this)) { | ||
return value | ||
@@ -104,0 +104,0 @@ } |
@@ -22,2 +22,4 @@ import BN from 'bn.js' | ||
class TimePointBase implements ABISerializableObject { | ||
static abiName = '__time_point_base' | ||
static from<T extends TimePointConstructor>(this: T, value: TimePointType): InstanceType<T> | ||
@@ -24,0 +26,0 @@ static from(value: TimePointType): unknown |
@@ -21,3 +21,3 @@ import { | ||
export class Variant implements ABISerializableObject { | ||
static abiName: string | ||
static abiName = '__variant' | ||
static abiVariant: ABITypeDescriptor[] = [] | ||
@@ -24,0 +24,0 @@ |
@@ -92,10 +92,21 @@ import {ABISerializableObject} from './serializer/serializable' | ||
} | ||
if (object == null || typeof object !== 'object') { | ||
return false | ||
} | ||
// not an actual instance but since bundlers can fail to dedupe stuff or | ||
// multiple versions can be included we check for compatibility if possible | ||
const className = someClass['__className'] || someClass['abiName'] | ||
if (!className || !object.constructor) { | ||
if (!className) { | ||
return false | ||
} | ||
const isAlienInstance = | ||
(object.constructor['__className'] || object.constructor['abiName']) === className | ||
let instanceClass = object.constructor | ||
let isAlienInstance = false | ||
while (instanceClass && !isAlienInstance) { | ||
const instanceClassName = instanceClass['__className'] || instanceClass['abiName'] | ||
if (!instanceClassName) { | ||
break | ||
} | ||
isAlienInstance = className == instanceClassName | ||
instanceClass = Object.getPrototypeOf(instanceClass) | ||
} | ||
if (isAlienInstance && !didWarn) { | ||
@@ -102,0 +113,0 @@ // eslint-disable-next-line no-console |
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
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
700157
14085