@greymass/eosio
Advanced tools
Comparing version 0.2.1 to 0.2.2
/** | ||
* EOSIO Core v0.2.1 | ||
* EOSIO Core v0.2.2 | ||
* https://github.com/greymass/eosio-core | ||
@@ -38,319 +38,11 @@ * | ||
declare type Fetch = typeof window.fetch; | ||
interface APIProvider { | ||
/** | ||
* Call an API endpoint and return the response. | ||
* Provider is responsible for JSON encoding the params and decoding the response. | ||
* @argument path The endpoint path, e.g. `/v1/chain/get_info` | ||
* @argument params The request body if any. | ||
*/ | ||
call(path: string, params?: unknown): Promise<unknown>; | ||
} | ||
interface FetchProviderOptions { | ||
/** | ||
* Fetch instance, must be provided in non-browser environments. | ||
* You can use the node-fetch package in Node.js. | ||
*/ | ||
fetch?: Fetch; | ||
} | ||
/** Default provider that uses the Fetch API to call a single node. */ | ||
declare class FetchProvider implements APIProvider { | ||
readonly url: string; | ||
readonly fetch: Fetch; | ||
constructor(url: string, options?: FetchProviderOptions); | ||
call(path: string, params?: unknown): Promise<any>; | ||
} | ||
declare type FloatType = Float | number | string; | ||
declare class Float implements ABISerializableObject { | ||
static abiName: string; | ||
static byteWidth: number; | ||
static from<T extends typeof Float>(this: T, value: FloatType): InstanceType<T>; | ||
static from(value: FloatType): unknown; | ||
static fromABI<T extends typeof Float>(this: T, decoder: ABIDecoder): InstanceType<T>; | ||
static fromABI(decoder: ABIDecoder): unknown; | ||
static random<T extends typeof Float>(this: T): InstanceType<T>; | ||
static random(): unknown; | ||
value: number; | ||
constructor(value: number); | ||
equals(other: FloatType): boolean; | ||
toABI(encoder: ABIEncoder): void; | ||
toString(): string; | ||
toJSON(): string; | ||
} | ||
declare type Float32Type = Float32 | FloatType; | ||
declare class Float32 extends Float { | ||
static abiName: string; | ||
static byteWidth: number; | ||
toString(): string; | ||
} | ||
declare type Float64Type = Float64 | FloatType; | ||
declare class Float64 extends Float { | ||
static abiName: string; | ||
static byteWidth: number; | ||
} | ||
declare type Float128Type = Float128 | BytesType; | ||
declare class Float128 implements ABISerializableObject { | ||
static abiName: string; | ||
static byteWidth: number; | ||
static from(value: Float128Type): Float128; | ||
static fromABI(decoder: ABIDecoder): Float128; | ||
static random(): Float128; | ||
data: Bytes; | ||
constructor(data: Bytes); | ||
equals(other: Float128Type): boolean; | ||
toABI(encoder: ABIEncoder): void; | ||
toString(): string; | ||
toJSON(): string; | ||
} | ||
declare type AssetType = Asset | string; | ||
declare class Asset implements ABISerializableObject { | ||
static abiName: string; | ||
units: Int64; | ||
symbol: Asset.Symbol; | ||
static from(value: AssetType): Asset; | ||
static from(value: number, symbol: Asset.SymbolType): Asset; | ||
static fromString(value: string): Asset; | ||
static fromFloat(value: number, symbol: Asset.SymbolType): Asset; | ||
static fromUnits(value: Int64Type, symbol: Asset.SymbolType): Asset; | ||
static fromABI(decoder: ABIDecoder): Asset; | ||
constructor(units: Int64, symbol: Asset.Symbol); | ||
equals(other: AssetType): boolean; | ||
get value(): number; | ||
set value(newValue: number); | ||
toABI(encoder: ABIEncoder): void; | ||
toString(): string; | ||
toJSON(): string; | ||
} | ||
declare namespace Asset { | ||
type SymbolType = Symbol | UInt64 | string; | ||
class Symbol implements ABISerializableObject { | ||
static abiName: string; | ||
static symbolNamePattern: RegExp; | ||
static maxPrecision: number; | ||
static from(value: SymbolType): Symbol; | ||
static fromParts(name: string, precision: number): Symbol; | ||
static fromABI(decoder: ABIDecoder): Symbol; | ||
value: UInt64; | ||
constructor(value: UInt64); | ||
equals(other: SymbolType): boolean; | ||
get name(): string; | ||
get precision(): number; | ||
get code(): SymbolCode; | ||
toABI(encoder: ABIEncoder): void; | ||
/** | ||
* Convert units to floating point number according to symbol precision. | ||
* @throws If the given units can't be represented in 53 bits. | ||
**/ | ||
convertUnits(units: Int64): number; | ||
/** | ||
* Convert floating point to units according to symbol precision. | ||
* Note that the value will be rounded to closest precision. | ||
**/ | ||
convertFloat(float: number): Int64; | ||
toString(): string; | ||
toJSON(): string; | ||
} | ||
type SymbolCodeType = SymbolCode | UInt64 | string | number; | ||
class SymbolCode implements ABISerializableObject { | ||
static abiName: string; | ||
static from(value: SymbolCodeType): SymbolCode; | ||
static fromABI(decoder: ABIDecoder): SymbolCode; | ||
value: UInt64; | ||
constructor(value: UInt64); | ||
equals(other: SymbolCodeType): boolean; | ||
toABI(encoder: ABIEncoder): void; | ||
toString(): string; | ||
toJSON(): string; | ||
} | ||
} | ||
declare type ExtendedAssetType = ExtendedAsset | { | ||
quantity: AssetType; | ||
contract: NameType; | ||
}; | ||
declare class ExtendedAsset implements ABISerializableObject { | ||
static abiName: string; | ||
static from(value: ExtendedAssetType): ExtendedAsset; | ||
static fromABI(decoder: ABIDecoder): ExtendedAsset; | ||
quantity: Asset; | ||
contract: Name; | ||
constructor(quantity: Asset, contract: Name); | ||
equals(other: ExtendedAssetType): boolean; | ||
toABI(encoder: ABIEncoder): void; | ||
toJSON(): { | ||
quantity: Asset; | ||
contract: Name; | ||
}; | ||
} | ||
declare type ChecksumType = Checksum | BytesType; | ||
declare class Checksum implements ABISerializableObject { | ||
static abiName: string; | ||
static byteSize: number; | ||
static from<T extends typeof Checksum>(this: T, value: ChecksumType): InstanceType<T>; | ||
static from(value: ChecksumType): unknown; | ||
static fromABI<T extends typeof Checksum>(this: T, decoder: ABIDecoder): InstanceType<T>; | ||
static fromABI(decoder: ABIDecoder): unknown; | ||
readonly array: Uint8Array; | ||
constructor(array: Uint8Array); | ||
equals(other: Checksum160Type | Checksum256Type | Checksum512Type): boolean; | ||
get hexString(): string; | ||
toABI(encoder: ABIEncoder): void; | ||
toString(): string; | ||
toJSON(): string; | ||
} | ||
declare type Checksum256Type = Checksum256 | BytesType; | ||
declare class Checksum256 extends Checksum { | ||
static abiName: string; | ||
static byteSize: number; | ||
static from(value: Checksum256Type): Checksum256; | ||
static hash(data: BytesType): Checksum256; | ||
} | ||
declare type Checksum512Type = Checksum512 | BytesType; | ||
declare class Checksum512 extends Checksum { | ||
static abiName: string; | ||
static byteSize: number; | ||
static from(value: Checksum512Type): Checksum512; | ||
static hash(data: BytesType): Checksum512; | ||
} | ||
declare type Checksum160Type = Checksum160 | BytesType; | ||
declare class Checksum160 extends Checksum { | ||
static abiName: string; | ||
static byteSize: number; | ||
static from(value: Checksum160Type): Checksum160; | ||
static hash(data: BytesType): Checksum160; | ||
} | ||
/** Supported EOSIO curve types. */ | ||
declare enum CurveType { | ||
K1 = "K1", | ||
R1 = "R1", | ||
WA = "WA" | ||
} | ||
declare namespace CurveType { | ||
function indexFor(value: CurveType): 0 | 1 | 2; | ||
function from(value: number | string): CurveType; | ||
} | ||
declare type PublicKeyType = PublicKey | string | { | ||
type: string; | ||
compressed: Uint8Array; | ||
}; | ||
declare class PublicKey implements ABISerializableObject { | ||
static abiName: string; | ||
/** Type, e.g. `K1` */ | ||
type: CurveType; | ||
/** Compressed public key point. */ | ||
data: Bytes; | ||
/** Create PublicKey object from representing types. */ | ||
static from(value: PublicKeyType): PublicKey; | ||
/** @internal */ | ||
static fromABI(decoder: ABIDecoder): PublicKey; | ||
/** @internal */ | ||
constructor(type: CurveType, data: Bytes); | ||
equals(other: PublicKeyType): boolean; | ||
/** | ||
* Return EOSIO legacy (`EOS<base58data>`) formatted key. | ||
* @throws If the key type isn't `K1` | ||
*/ | ||
toLegacyString(prefix?: string): string; | ||
/** Return key in modern EOSIO format (`PUB_<type>_<base58data>`) */ | ||
toString(): string; | ||
/** @internal */ | ||
toABI(encoder: ABIEncoder): void; | ||
/** @internal */ | ||
toJSON(): string; | ||
} | ||
declare type SignatureType = Signature | string | { | ||
type: string; | ||
r: Uint8Array; | ||
s: Uint8Array; | ||
recid: number; | ||
}; | ||
declare class Signature implements ABISerializableObject { | ||
static abiName: string; | ||
/** Type, e.g. `K1` */ | ||
type: CurveType; | ||
/** Signature data. */ | ||
data: Bytes; | ||
/** Create Signature object from representing types. */ | ||
static from(value: SignatureType): Signature; | ||
/** @internal */ | ||
static fromABI(decoder: ABIDecoder): Signature; | ||
/** @internal */ | ||
constructor(type: CurveType, data: Bytes); | ||
equals(other: SignatureType): boolean; | ||
/** Recover public key from given message digest. */ | ||
recoverDigest(digest: Checksum256Type): PublicKey; | ||
/** Recover public key from given message. */ | ||
recoverMessage(message: BytesType): PublicKey; | ||
/** Verify this signature with given message digest and public key. */ | ||
verifyDigest(digest: Checksum256Type, publicKey: PublicKey): boolean; | ||
/** Verify this signature with given message and public key. */ | ||
verifyMessage(message: BytesType, publicKey: PublicKey): boolean; | ||
/** Base58check encoded string representation of this signature (`SIG_<type>_<data>`). */ | ||
toString(): string; | ||
/** @internal */ | ||
toABI(encoder: ABIEncoder): void; | ||
/** @internal */ | ||
toJSON(): string; | ||
} | ||
declare type TimePointType = TimePoint | TimePointSec | string | Date | AnyInt; | ||
interface TimePointConstructor { | ||
from(value: TimePointType): TimePointBase; | ||
fromInteger(value: AnyInt): TimePointBase; | ||
fromDate(value: Date): TimePointBase; | ||
fromString(value: string): TimePointBase; | ||
fromMilliseconds(value: number): TimePointBase; | ||
new (...args: any[]): TimePointBase; | ||
} | ||
declare class TimePointBase implements ABISerializableObject { | ||
static from<T extends TimePointConstructor>(this: T, value: TimePointType): InstanceType<T>; | ||
static from(value: TimePointType): unknown; | ||
static fromString<T extends TimePointConstructor>(this: T, string: string): InstanceType<T>; | ||
static fromString(string: string): unknown; | ||
static fromDate<T extends TimePointConstructor>(this: T, date: Date): InstanceType<T>; | ||
static fromDate(date: Date): unknown; | ||
toABI(encoder: ABIEncoder): void; | ||
equals(other: TimePointType): boolean; | ||
toMilliseconds(): number; | ||
toDate(): Date; | ||
toJSON(): string; | ||
value: any; | ||
constructor(value: any); | ||
} | ||
/** Timestamp with microsecond accuracy. */ | ||
declare class TimePoint extends TimePointBase { | ||
static abiName: string; | ||
static fromMilliseconds(ms: number): TimePoint; | ||
static fromInteger(value: Int64Type): TimePoint; | ||
static fromABI(decoder: ABIDecoder): TimePoint; | ||
value: Int64; | ||
toString(): string; | ||
toMilliseconds(): number; | ||
} | ||
/** Timestamp with second accuracy. */ | ||
declare class TimePointSec extends TimePointBase { | ||
static abiName: string; | ||
static fromMilliseconds(ms: number): TimePointSec; | ||
static fromInteger(value: UInt32Type): TimePointSec; | ||
static fromABI(decoder: ABIDecoder): TimePointSec; | ||
value: UInt32; | ||
toString(): string; | ||
toMilliseconds(): number; | ||
} | ||
declare class BlockTimestamp extends TimePointBase { | ||
static abiName: string; | ||
static fromMilliseconds(ms: number): TimePointSec; | ||
static fromInteger(value: UInt32Type): TimePointSec; | ||
static fromABI(decoder: ABIDecoder): BlockTimestamp; | ||
value: UInt32; | ||
toString(): string; | ||
toMilliseconds(): number; | ||
} | ||
interface BuiltinTypes { | ||
string: string; | ||
'string?'?: string; | ||
'string[]': string[]; | ||
'string[]?'?: string[]; | ||
bool: boolean; | ||
'bool?'?: boolean; | ||
'bool[]': boolean[]; | ||
'bool[]?'?: boolean[]; | ||
asset: Asset; | ||
@@ -364,6 +56,2 @@ 'asset?'?: Asset; | ||
'extended_asset[]?'?: ExtendedAsset[]; | ||
bool: boolean; | ||
'bool?'?: boolean; | ||
'bool[]': boolean[]; | ||
'bool[]?'?: boolean[]; | ||
bytes: Bytes; | ||
@@ -397,6 +85,2 @@ 'bytes?'?: Bytes; | ||
'signature[]?'?: Signature[]; | ||
string: string; | ||
'string?'?: string; | ||
'string[]': string[]; | ||
'string[]?'?: string[]; | ||
symbol: Asset.Symbol; | ||
@@ -485,2 +169,52 @@ 'symbol?'?: Asset.Symbol; | ||
/** | ||
* EOSIO ABI Decoder | ||
*/ | ||
interface DecodeArgsBase { | ||
abi?: ABIDef; | ||
data?: BytesType | ABIDecoder; | ||
json?: string; | ||
object?: any; | ||
customTypes?: ABISerializableConstructor[]; | ||
/** Optional encoder metadata. */ | ||
metadata?: Record<string, any>; | ||
} | ||
interface TypedDecodeArgs<T extends ABISerializableType> extends DecodeArgsBase { | ||
type: T; | ||
} | ||
interface BuiltinDecodeArgs<T extends keyof BuiltinTypes> extends DecodeArgsBase { | ||
type: T; | ||
} | ||
interface UntypedDecodeArgs extends DecodeArgsBase { | ||
type: ABISerializableType; | ||
} | ||
declare function abiDecode<T extends keyof BuiltinTypes>(args: BuiltinDecodeArgs<T>): BuiltinTypes[T]; | ||
declare function abiDecode<T extends ABISerializableConstructor>(args: TypedDecodeArgs<T>): InstanceType<T>; | ||
declare function abiDecode(args: UntypedDecodeArgs): ABISerializable; | ||
declare class ABIDecoder { | ||
private array; | ||
static __className: string; | ||
private pos; | ||
private data; | ||
private textDecoder; | ||
/** User declared metadata, can be used to pass info to instances when decoding. */ | ||
metadata: Record<string, any>; | ||
constructor(array: Uint8Array); | ||
canRead(bytes?: number): boolean; | ||
private ensure; | ||
/** Read one byte. */ | ||
readByte(): number; | ||
/** Read integer as JavaScript number, up to 32 bits. */ | ||
readNum(byteWidth: number, isSigned: boolean): number; | ||
/** Read integer as a bn.js number. */ | ||
readBn(bytes: number, signed: boolean): BN; | ||
/** Read floating point as JavaScript number, 32 or 64 bits. */ | ||
readFloat(byteWidth: number): number; | ||
readVaruint32(): number; | ||
readVarint32(): number; | ||
readArray(length: number): Uint8Array; | ||
readString(): string; | ||
} | ||
/** | ||
* EOSIO ABI Encoder | ||
@@ -559,2 +293,62 @@ */ | ||
/** A self-describing object that can be ABI encoded and decoded. */ | ||
declare type ABISerializable = ABISerializableObject | string | boolean | ABISerializable[] | { | ||
[key: string]: ABISerializable; | ||
}; | ||
/** Type describing an ABI type, either a string (e.g. `uint32[]`) or a ABI type class. */ | ||
declare type ABISerializableType = string | ABISerializableConstructor | ABITypeDescriptor; | ||
/** Interface that should be implemented by ABI serializable objects. */ | ||
interface ABISerializableObject { | ||
/** Called when encoding to binary abi format. */ | ||
toABI?(encoder: ABIEncoder): void; | ||
/** Called when encoding to json abi format. */ | ||
toJSON(): any; | ||
/** Return true if the object equals the other object passed. */ | ||
equals(other: any): boolean; | ||
} | ||
interface ABITypeDescriptor { | ||
type: ABISerializableConstructor | string; | ||
optional?: boolean; | ||
array?: boolean; | ||
extension?: boolean; | ||
} | ||
interface ABIField extends ABITypeDescriptor { | ||
name: string; | ||
default?: any; | ||
} | ||
interface ABISerializableConstructor { | ||
/** Name of the type, e.g. `asset`. */ | ||
abiName: string; | ||
/** For structs, the fields that this type contains. */ | ||
abiFields?: ABIField[]; | ||
/** For structs, the base class this type extends. */ | ||
abiBase?: ABISerializableConstructor; | ||
/** For variants, the different types this type can represent. */ | ||
abiVariant?: ABITypeDescriptor[]; | ||
/** Alias to another type. */ | ||
abiAlias?: ABITypeDescriptor; | ||
/** | ||
* Create new instance from JavaScript object. | ||
* Should also accept an instance of itself and return that unchanged. | ||
*/ | ||
from(value: any): ABISerializable; | ||
/** | ||
* Create instance from binary ABI data. | ||
* @param decoder Decoder instance to read from. | ||
*/ | ||
fromABI?(decoder: ABIDecoder): ABISerializable; | ||
/** | ||
* Static ABI encoding can be used to encode non-class types. | ||
* Will be used in favor of instance.toABI if both exists. | ||
* @param value The value to encode. | ||
* @param encoder The encoder to write the value to. | ||
*/ | ||
toABI?(value: any, encoder: ABIEncoder): void; | ||
/** | ||
* Create a new instance, don't use this other than from a custom `from` factory method. | ||
* @internal | ||
*/ | ||
new (...args: any[]): ABISerializableObject; | ||
} | ||
declare type BytesType = Bytes | Uint8Array | ArrayLike<number> | string; | ||
@@ -573,5 +367,2 @@ declare type BytesEncoding = 'hex' | 'utf8'; | ||
constructor(array?: Uint8Array); | ||
get ripemd160Digest(): Checksum160; | ||
get sha256Digest(): Checksum256; | ||
get sha512Digest(): Checksum512; | ||
get hexString(): string; | ||
@@ -588,51 +379,50 @@ get utf8String(): string; | ||
/** | ||
* EOSIO ABI Decoder | ||
*/ | ||
interface DecodeArgsBase { | ||
abi?: ABIDef; | ||
data?: BytesType | ABIDecoder; | ||
json?: string; | ||
object?: any; | ||
customTypes?: ABISerializableConstructor[]; | ||
/** Optional encoder metadata. */ | ||
metadata?: Record<string, any>; | ||
declare type ChecksumType = Checksum | BytesType; | ||
declare class Checksum implements ABISerializableObject { | ||
static abiName: string; | ||
static byteSize: number; | ||
static from<T extends typeof Checksum>(this: T, value: ChecksumType): InstanceType<T>; | ||
static from(value: ChecksumType): unknown; | ||
static fromABI<T extends typeof Checksum>(this: T, decoder: ABIDecoder): InstanceType<T>; | ||
static fromABI(decoder: ABIDecoder): unknown; | ||
readonly array: Uint8Array; | ||
constructor(array: Uint8Array); | ||
equals(other: Checksum160Type | Checksum256Type | Checksum512Type): boolean; | ||
get hexString(): string; | ||
toABI(encoder: ABIEncoder): void; | ||
toString(): string; | ||
toJSON(): string; | ||
} | ||
interface TypedDecodeArgs<T extends ABISerializableType> extends DecodeArgsBase { | ||
type: T; | ||
declare type Checksum256Type = Checksum256 | BytesType; | ||
declare class Checksum256 extends Checksum { | ||
static abiName: string; | ||
static byteSize: number; | ||
static from(value: Checksum256Type): Checksum256; | ||
static hash(data: BytesType): Checksum256; | ||
} | ||
interface BuiltinDecodeArgs<T extends keyof BuiltinTypes> extends DecodeArgsBase { | ||
type: T; | ||
declare type Checksum512Type = Checksum512 | BytesType; | ||
declare class Checksum512 extends Checksum { | ||
static abiName: string; | ||
static byteSize: number; | ||
static from(value: Checksum512Type): Checksum512; | ||
static hash(data: BytesType): Checksum512; | ||
} | ||
interface UntypedDecodeArgs extends DecodeArgsBase { | ||
type: ABISerializableType; | ||
declare type Checksum160Type = Checksum160 | BytesType; | ||
declare class Checksum160 extends Checksum { | ||
static abiName: string; | ||
static byteSize: number; | ||
static from(value: Checksum160Type): Checksum160; | ||
static hash(data: BytesType): Checksum160; | ||
} | ||
declare function abiDecode<T extends keyof BuiltinTypes>(args: BuiltinDecodeArgs<T>): BuiltinTypes[T]; | ||
declare function abiDecode<T extends ABISerializableConstructor>(args: TypedDecodeArgs<T>): InstanceType<T>; | ||
declare function abiDecode(args: UntypedDecodeArgs): ABISerializable; | ||
declare class ABIDecoder { | ||
private array; | ||
static __className: string; | ||
private pos; | ||
private data; | ||
private textDecoder; | ||
/** User declared metadata, can be used to pass info to instances when decoding. */ | ||
metadata: Record<string, any>; | ||
constructor(array: Uint8Array); | ||
canRead(bytes?: number): boolean; | ||
private ensure; | ||
/** Read one byte. */ | ||
readByte(): number; | ||
/** Read integer as JavaScript number, up to 32 bits. */ | ||
readNum(byteWidth: number, isSigned: boolean): number; | ||
/** Read integer as a bn.js number. */ | ||
readBn(bytes: number, signed: boolean): BN; | ||
/** Read floating point as JavaScript number, 32 or 64 bits. */ | ||
readFloat(byteWidth: number): number; | ||
readVaruint32(): number; | ||
readVarint32(): number; | ||
readArray(length: number): Uint8Array; | ||
readString(): string; | ||
/** Supported EOSIO curve types. */ | ||
declare enum CurveType { | ||
K1 = "K1", | ||
R1 = "R1", | ||
WA = "WA" | ||
} | ||
declare namespace CurveType { | ||
function indexFor(value: CurveType): 0 | 2 | 1; | ||
function from(value: number | string): CurveType; | ||
} | ||
@@ -760,2 +550,103 @@ declare type IntType = Int | BNInt | number | string | BN; | ||
interface StructConstructor extends ABISerializableConstructor { | ||
new <T extends Struct>(...args: any[]): T; | ||
structFields: ABIField[]; | ||
} | ||
declare class Struct implements ABISerializableObject { | ||
static abiName: string; | ||
static abiFields: ABIField[]; | ||
static abiBase: ABISerializableConstructor; | ||
static from<T extends StructConstructor>(this: T, value: any): InstanceType<T>; | ||
static from(value: any): unknown; | ||
static get structFields(): ABIField[]; | ||
/** @internal */ | ||
constructor(object: any); | ||
/** | ||
* Return true if this struct equals the other. | ||
* | ||
* Note: This compares the ABI encoded bytes of both structs, subclasses | ||
* should implement their own fast equality check when possible. | ||
*/ | ||
equals(other: any): boolean; | ||
/** @internal */ | ||
toJSON(): any; | ||
} | ||
declare namespace Struct { | ||
function type(name: string): <T extends StructConstructor>(struct: T) => T; | ||
function field(type: ABISerializableConstructor | string, options?: Partial<ABIField>): <T extends Struct>(target: T, name: string) => void; | ||
} | ||
declare function TypeAlias(name: string): (typeAlias: any) => any; | ||
interface VariantConstructor extends ABISerializableConstructor { | ||
new <T extends Variant>(...args: any[]): T; | ||
} | ||
declare type AnyVariant = Variant | ABISerializable | [string, any]; | ||
declare class Variant implements ABISerializableObject { | ||
static abiName: string; | ||
static abiVariant: ABITypeDescriptor[]; | ||
static from<T extends VariantConstructor>(this: T, object: AnyVariant): InstanceType<T>; | ||
static from(object: AnyVariant): unknown; | ||
value: ABISerializable; | ||
variantIdx: number; | ||
/** @internal */ | ||
constructor(variant: [string, ABISerializable]); | ||
/** | ||
* Return true if this variant equals the other. | ||
* | ||
* Note: This compares the ABI encoded bytes of both variants, subclasses | ||
* should implement their own fast equality check when possible. | ||
*/ | ||
equals(other: AnyVariant): boolean; | ||
get variantName(): string; | ||
/** @internal */ | ||
toJSON(): ABISerializable[]; | ||
} | ||
declare namespace Variant { | ||
function type(name: string, types: ABISerializableType[]): <T extends VariantConstructor>(variant: T) => T; | ||
} | ||
declare type FloatType = Float | number | string; | ||
declare class Float implements ABISerializableObject { | ||
static abiName: string; | ||
static byteWidth: number; | ||
static from<T extends typeof Float>(this: T, value: FloatType): InstanceType<T>; | ||
static from(value: FloatType): unknown; | ||
static fromABI<T extends typeof Float>(this: T, decoder: ABIDecoder): InstanceType<T>; | ||
static fromABI(decoder: ABIDecoder): unknown; | ||
static random<T extends typeof Float>(this: T): InstanceType<T>; | ||
static random(): unknown; | ||
value: number; | ||
constructor(value: number); | ||
equals(other: FloatType): boolean; | ||
toABI(encoder: ABIEncoder): void; | ||
toString(): string; | ||
toJSON(): string; | ||
} | ||
declare type Float32Type = Float32 | FloatType; | ||
declare class Float32 extends Float { | ||
static abiName: string; | ||
static byteWidth: number; | ||
toString(): string; | ||
} | ||
declare type Float64Type = Float64 | FloatType; | ||
declare class Float64 extends Float { | ||
static abiName: string; | ||
static byteWidth: number; | ||
} | ||
declare type Float128Type = Float128 | BytesType; | ||
declare class Float128 implements ABISerializableObject { | ||
static abiName: string; | ||
static byteWidth: number; | ||
static from(value: Float128Type): Float128; | ||
static fromABI(decoder: ABIDecoder): Float128; | ||
static random(): Float128; | ||
data: Bytes; | ||
constructor(data: Bytes); | ||
equals(other: Float128Type): boolean; | ||
toABI(encoder: ABIEncoder): void; | ||
toString(): string; | ||
toJSON(): string; | ||
} | ||
/** Type representing a name. */ | ||
@@ -783,2 +674,56 @@ declare type NameType = Name | UInt64 | string; | ||
declare type TimePointType = TimePoint | TimePointSec | string | Date | AnyInt; | ||
interface TimePointConstructor { | ||
from(value: TimePointType): TimePointBase; | ||
fromInteger(value: AnyInt): TimePointBase; | ||
fromDate(value: Date): TimePointBase; | ||
fromString(value: string): TimePointBase; | ||
fromMilliseconds(value: number): TimePointBase; | ||
new (...args: any[]): TimePointBase; | ||
} | ||
declare class TimePointBase implements ABISerializableObject { | ||
static from<T extends TimePointConstructor>(this: T, value: TimePointType): InstanceType<T>; | ||
static from(value: TimePointType): unknown; | ||
static fromString<T extends TimePointConstructor>(this: T, string: string): InstanceType<T>; | ||
static fromString(string: string): unknown; | ||
static fromDate<T extends TimePointConstructor>(this: T, date: Date): InstanceType<T>; | ||
static fromDate(date: Date): unknown; | ||
toABI(encoder: ABIEncoder): void; | ||
equals(other: TimePointType): boolean; | ||
toMilliseconds(): number; | ||
toDate(): Date; | ||
toJSON(): string; | ||
value: any; | ||
constructor(value: any); | ||
} | ||
/** Timestamp with microsecond accuracy. */ | ||
declare class TimePoint extends TimePointBase { | ||
static abiName: string; | ||
static fromMilliseconds(ms: number): TimePoint; | ||
static fromInteger(value: Int64Type): TimePoint; | ||
static fromABI(decoder: ABIDecoder): TimePoint; | ||
value: Int64; | ||
toString(): string; | ||
toMilliseconds(): number; | ||
} | ||
/** Timestamp with second accuracy. */ | ||
declare class TimePointSec extends TimePointBase { | ||
static abiName: string; | ||
static fromMilliseconds(ms: number): TimePointSec; | ||
static fromInteger(value: UInt32Type): TimePointSec; | ||
static fromABI(decoder: ABIDecoder): TimePointSec; | ||
value: UInt32; | ||
toString(): string; | ||
toMilliseconds(): number; | ||
} | ||
declare class BlockTimestamp extends TimePointBase { | ||
static abiName: string; | ||
static fromMilliseconds(ms: number): TimePointSec; | ||
static fromInteger(value: UInt32Type): TimePointSec; | ||
static fromABI(decoder: ABIDecoder): BlockTimestamp; | ||
value: UInt32; | ||
toString(): string; | ||
toMilliseconds(): number; | ||
} | ||
declare type ABIDef = string | Partial<ABI.Def> | ABI; | ||
@@ -869,89 +814,191 @@ declare class ABI { | ||
/** A self-describing object that can be ABI encoded and decoded. */ | ||
declare type ABISerializable = ABISerializableObject | string | boolean | ABISerializable[] | { | ||
[key: string]: ABISerializable; | ||
declare type AssetType = Asset | string; | ||
declare class Asset implements ABISerializableObject { | ||
static abiName: string; | ||
units: Int64; | ||
symbol: Asset.Symbol; | ||
static from(value: AssetType): Asset; | ||
static from(value: number, symbol: Asset.SymbolType): Asset; | ||
static fromString(value: string): Asset; | ||
static fromFloat(value: number, symbol: Asset.SymbolType): Asset; | ||
static fromUnits(value: Int64Type, symbol: Asset.SymbolType): Asset; | ||
static fromABI(decoder: ABIDecoder): Asset; | ||
constructor(units: Int64, symbol: Asset.Symbol); | ||
equals(other: AssetType): boolean; | ||
get value(): number; | ||
set value(newValue: number); | ||
toABI(encoder: ABIEncoder): void; | ||
toString(): string; | ||
toJSON(): string; | ||
} | ||
declare namespace Asset { | ||
type SymbolType = Symbol | UInt64 | string; | ||
class Symbol implements ABISerializableObject { | ||
static abiName: string; | ||
static symbolNamePattern: RegExp; | ||
static maxPrecision: number; | ||
static from(value: SymbolType): Symbol; | ||
static fromParts(name: string, precision: number): Symbol; | ||
static fromABI(decoder: ABIDecoder): Symbol; | ||
value: UInt64; | ||
constructor(value: UInt64); | ||
equals(other: SymbolType): boolean; | ||
get name(): string; | ||
get precision(): number; | ||
get code(): SymbolCode; | ||
toABI(encoder: ABIEncoder): void; | ||
/** | ||
* Convert units to floating point number according to symbol precision. | ||
* @throws If the given units can't be represented in 53 bits. | ||
**/ | ||
convertUnits(units: Int64): number; | ||
/** | ||
* Convert floating point to units according to symbol precision. | ||
* Note that the value will be rounded to closest precision. | ||
**/ | ||
convertFloat(float: number): Int64; | ||
toString(): string; | ||
toJSON(): string; | ||
} | ||
type SymbolCodeType = SymbolCode | UInt64 | string | number; | ||
class SymbolCode implements ABISerializableObject { | ||
static abiName: string; | ||
static from(value: SymbolCodeType): SymbolCode; | ||
static fromABI(decoder: ABIDecoder): SymbolCode; | ||
value: UInt64; | ||
constructor(value: UInt64); | ||
equals(other: SymbolCodeType): boolean; | ||
toABI(encoder: ABIEncoder): void; | ||
toString(): string; | ||
toJSON(): string; | ||
} | ||
} | ||
declare type ExtendedAssetType = ExtendedAsset | { | ||
quantity: AssetType; | ||
contract: NameType; | ||
}; | ||
/** Type describing an ABI type, either a string (e.g. `uint32[]`) or a ABI type class. */ | ||
declare type ABISerializableType = string | ABISerializableConstructor | ABITypeDescriptor; | ||
/** Interface that should be implemented by ABI serializable objects. */ | ||
interface ABISerializableObject { | ||
/** Called when encoding to binary abi format. */ | ||
toABI?(encoder: ABIEncoder): void; | ||
/** Called when encoding to json abi format. */ | ||
toJSON(): any; | ||
/** Return true if the object equals the other object passed. */ | ||
equals(other: any): boolean; | ||
declare class ExtendedAsset implements ABISerializableObject { | ||
static abiName: string; | ||
static from(value: ExtendedAssetType): ExtendedAsset; | ||
static fromABI(decoder: ABIDecoder): ExtendedAsset; | ||
quantity: Asset; | ||
contract: Name; | ||
constructor(quantity: Asset, contract: Name); | ||
equals(other: ExtendedAssetType): boolean; | ||
toABI(encoder: ABIEncoder): void; | ||
toJSON(): { | ||
quantity: Asset; | ||
contract: Name; | ||
}; | ||
} | ||
interface ABITypeDescriptor { | ||
type: ABISerializableConstructor | string; | ||
optional?: boolean; | ||
array?: boolean; | ||
extension?: boolean; | ||
declare type PublicKeyType = PublicKey | string | { | ||
type: string; | ||
compressed: Uint8Array; | ||
}; | ||
declare class PublicKey implements ABISerializableObject { | ||
static abiName: string; | ||
/** Type, e.g. `K1` */ | ||
type: CurveType; | ||
/** Compressed public key point. */ | ||
data: Bytes; | ||
/** Create PublicKey object from representing types. */ | ||
static from(value: PublicKeyType): PublicKey; | ||
/** @internal */ | ||
static fromABI(decoder: ABIDecoder): PublicKey; | ||
/** @internal */ | ||
constructor(type: CurveType, data: Bytes); | ||
equals(other: PublicKeyType): boolean; | ||
/** | ||
* Return EOSIO legacy (`EOS<base58data>`) formatted key. | ||
* @throws If the key type isn't `K1` | ||
*/ | ||
toLegacyString(prefix?: string): string; | ||
/** Return key in modern EOSIO format (`PUB_<type>_<base58data>`) */ | ||
toString(): string; | ||
/** @internal */ | ||
toABI(encoder: ABIEncoder): void; | ||
/** @internal */ | ||
toJSON(): string; | ||
} | ||
interface ABIField extends ABITypeDescriptor { | ||
name: string; | ||
default?: any; | ||
declare type SignatureType = Signature | string | { | ||
type: string; | ||
r: Uint8Array; | ||
s: Uint8Array; | ||
recid: number; | ||
}; | ||
declare class Signature implements ABISerializableObject { | ||
static abiName: string; | ||
/** Type, e.g. `K1` */ | ||
type: CurveType; | ||
/** Signature data. */ | ||
data: Bytes; | ||
/** Create Signature object from representing types. */ | ||
static from(value: SignatureType): Signature; | ||
/** @internal */ | ||
static fromABI(decoder: ABIDecoder): Signature; | ||
/** @internal */ | ||
constructor(type: CurveType, data: Bytes); | ||
equals(other: SignatureType): boolean; | ||
/** Recover public key from given message digest. */ | ||
recoverDigest(digest: Checksum256Type): PublicKey; | ||
/** Recover public key from given message. */ | ||
recoverMessage(message: BytesType): PublicKey; | ||
/** Verify this signature with given message digest and public key. */ | ||
verifyDigest(digest: Checksum256Type, publicKey: PublicKey): boolean; | ||
/** Verify this signature with given message and public key. */ | ||
verifyMessage(message: BytesType, publicKey: PublicKey): boolean; | ||
/** Base58check encoded string representation of this signature (`SIG_<type>_<data>`). */ | ||
toString(): string; | ||
/** @internal */ | ||
toABI(encoder: ABIEncoder): void; | ||
/** @internal */ | ||
toJSON(): string; | ||
} | ||
interface ABISerializableConstructor { | ||
/** Name of the type, e.g. `asset`. */ | ||
abiName: string; | ||
/** For structs, the fields that this type contains. */ | ||
abiFields?: ABIField[]; | ||
/** For structs, the base class this type extends. */ | ||
abiBase?: ABISerializableConstructor; | ||
/** For variants, the different types this type can represent. */ | ||
abiVariant?: ABITypeDescriptor[]; | ||
/** Alias to another type. */ | ||
abiAlias?: ABITypeDescriptor; | ||
declare type PrivateKeyType = PrivateKey | string; | ||
declare class PrivateKey { | ||
type: CurveType; | ||
data: Bytes; | ||
/** Create PrivateKey object from representing types. */ | ||
static from(value: PrivateKeyType): PrivateKey; | ||
/** | ||
* Create new instance from JavaScript object. | ||
* Should also accept an instance of itself and return that unchanged. | ||
* Generate new PrivateKey. | ||
* @throws If a secure random source isn't available. | ||
*/ | ||
from(value: any): ABISerializable; | ||
static generate(type: CurveType | string): PrivateKey; | ||
/** @internal */ | ||
constructor(type: CurveType, data: Bytes); | ||
/** | ||
* Create instance from binary ABI data. | ||
* @param decoder Decoder instance to read from. | ||
* Sign message digest using this key. | ||
* @throws If the key type isn't R1 or K1. | ||
*/ | ||
fromABI?(decoder: ABIDecoder): ABISerializable; | ||
signDigest(digest: Checksum256Type): Signature; | ||
/** | ||
* Static ABI encoding can be used to encode non-class types. | ||
* Will be used in favor of instance.toABI if both exists. | ||
* @param value The value to encode. | ||
* @param encoder The encoder to write the value to. | ||
* Sign message using this key. | ||
* @throws If the key type isn't R1 or K1. | ||
*/ | ||
toABI?(value: any, encoder: ABIEncoder): void; | ||
signMessage(message: BytesType): Signature; | ||
/** | ||
* Create a new instance, don't use this other than from a custom `from` factory method. | ||
* @internal | ||
* Derive the shared secret between this private key and given public key. | ||
* @throws If the key type isn't R1 or K1. | ||
*/ | ||
new (...args: any[]): ABISerializableObject; | ||
} | ||
interface StructConstructor extends ABISerializableConstructor { | ||
new <T extends Struct>(...args: any[]): T; | ||
structFields: ABIField[]; | ||
} | ||
declare class Struct implements ABISerializableObject { | ||
static abiName: string; | ||
static abiFields: ABIField[]; | ||
static abiBase: ABISerializableConstructor; | ||
static from<T extends StructConstructor>(this: T, value: any): InstanceType<T>; | ||
static from(value: any): unknown; | ||
static get structFields(): ABIField[]; | ||
/** @internal */ | ||
constructor(object: any); | ||
sharedSecret(publicKey: PublicKey): Checksum512; | ||
/** | ||
* Return true if this struct equals the other. | ||
* | ||
* Note: This compares the ABI encoded bytes of both structs, subclasses | ||
* should implement their own fast equality check when possible. | ||
* Get the corresponding public key. | ||
* @throws If the key type isn't R1 or K1. | ||
*/ | ||
equals(other: any): boolean; | ||
/** @internal */ | ||
toJSON(): any; | ||
toPublic(): PublicKey; | ||
/** | ||
* Return WIF representation of this private key | ||
* @throws If the key type isn't K1. | ||
*/ | ||
toWif(): string; | ||
/** | ||
* Return the key in EOSIO PVT_<type>_<base58check> format. | ||
*/ | ||
toString(): string; | ||
toJSON(): string; | ||
} | ||
declare namespace Struct { | ||
function type(name: string): <T extends StructConstructor>(struct: T) => T; | ||
function field(type: ABISerializableConstructor | string, options?: Partial<ABIField>): <T extends Struct>(target: T, name: string) => void; | ||
} | ||
@@ -970,2 +1017,3 @@ declare type PermissionLevelType = PermissionLevel | { | ||
equals(other: PermissionLevelType | string): boolean; | ||
toString(): string; | ||
} | ||
@@ -1111,2 +1159,40 @@ | ||
declare class Weight extends UInt16 { | ||
} | ||
declare class KeyWeight extends Struct { | ||
key: PublicKey; | ||
weight: Weight; | ||
} | ||
declare class PermissionLevelWeight extends Struct { | ||
permission: PermissionLevel; | ||
weight: Weight; | ||
} | ||
declare class WaitWeight extends Struct { | ||
wait_sec: UInt32; | ||
weight: Weight; | ||
} | ||
declare class Authority extends Struct { | ||
threshold: UInt32; | ||
keys: KeyWeight[]; | ||
accounts: PermissionLevelWeight[]; | ||
waits: WaitWeight[]; | ||
/** Total weight of all waits. */ | ||
get waitThreshold(): number; | ||
/** Weight a key needs to sign for this authority. */ | ||
get keyTreshhold(): number; | ||
/** Return the weight for given public key, or zero if it is not included in this authority. */ | ||
keyWeight(publicKey: PublicKeyType): number; | ||
/** | ||
* Check if given public key has permission in this authority, | ||
* @attention Does not take indirect permissions for the key via account weights into account. | ||
* @param publicKey The key to check. | ||
* @param includePartial Whether to consider auths where the key is included but can't be reached alone (e.g. multisig). | ||
*/ | ||
hasPermission(publicKey: PublicKeyType, includePartial?: boolean): boolean; | ||
/** | ||
* Sorts the authority weights in place, should be called before including the authority in a `updateauth` action or it might be rejected. | ||
*/ | ||
sort(): void; | ||
} | ||
declare namespace Serializer { | ||
@@ -1118,19 +1204,49 @@ const encode: typeof abiEncode; | ||
declare class AccountAuth extends Struct { | ||
weight: UInt32; | ||
permission: PermissionLevel; | ||
declare namespace Base58 { | ||
/** Decode a Base58 encoded string. */ | ||
function decode(s: string, size?: number): Bytes; | ||
/** Decode a Base58Check encoded string. */ | ||
function decodeCheck(encoded: string, size?: number): Bytes; | ||
/** Decode a Base58Check encoded string that uses ripemd160 instead of double sha256 for the digest. */ | ||
function decodeRipemd160Check(encoded: string, size?: number, suffix?: string): Bytes; | ||
/** Encode bytes to a Base58 string. */ | ||
function encode(data: BytesType): string; | ||
function encodeCheck(data: BytesType): string; | ||
function encodeRipemd160Check(data: BytesType, suffix?: string): string; | ||
} | ||
declare class KeyAuth extends Struct { | ||
weight: UInt32; | ||
key: PublicKey; | ||
/** Check if object in instance of class. */ | ||
declare function isInstanceOf<T extends { | ||
new (...args: any[]): InstanceType<T>; | ||
}>(object: any, someClass: T): object is InstanceType<T>; | ||
declare type Fetch = typeof window.fetch; | ||
interface APIProvider { | ||
/** | ||
* Call an API endpoint and return the response. | ||
* Provider is responsible for JSON encoding the params and decoding the response. | ||
* @argument path The endpoint path, e.g. `/v1/chain/get_info` | ||
* @argument params The request body if any. | ||
*/ | ||
call(path: string, params?: unknown): Promise<unknown>; | ||
} | ||
declare class RequiredAuth extends Struct { | ||
threshold: UInt32; | ||
keys: KeyAuth[]; | ||
accounts: AccountAuth[]; | ||
interface FetchProviderOptions { | ||
/** | ||
* Fetch instance, must be provided in non-browser environments. | ||
* You can use the node-fetch package in Node.js. | ||
*/ | ||
fetch?: Fetch; | ||
} | ||
/** Default provider that uses the Fetch API to call a single node. */ | ||
declare class FetchProvider implements APIProvider { | ||
readonly url: string; | ||
readonly fetch: Fetch; | ||
constructor(url: string, options?: FetchProviderOptions); | ||
call(path: string, params?: unknown): Promise<any>; | ||
} | ||
declare class AccountPermission extends Struct { | ||
perm_name: Name; | ||
parent: Name; | ||
required_auth: RequiredAuth; | ||
required_auth: Authority; | ||
} | ||
@@ -1387,8 +1503,2 @@ declare class AccountResourceLimit extends Struct { | ||
type types_AccountAuth = AccountAuth; | ||
declare const types_AccountAuth: typeof AccountAuth; | ||
type types_KeyAuth = KeyAuth; | ||
declare const types_KeyAuth: typeof KeyAuth; | ||
type types_RequiredAuth = RequiredAuth; | ||
declare const types_RequiredAuth: typeof RequiredAuth; | ||
type types_AccountPermission = AccountPermission; | ||
@@ -1444,5 +1554,2 @@ declare const types_AccountPermission: typeof AccountPermission; | ||
export { | ||
types_AccountAuth as AccountAuth, | ||
types_KeyAuth as KeyAuth, | ||
types_RequiredAuth as RequiredAuth, | ||
types_AccountPermission as AccountPermission, | ||
@@ -1555,95 +1662,2 @@ types_AccountResourceLimit as AccountResourceLimit, | ||
declare type PrivateKeyType = PrivateKey | string; | ||
declare class PrivateKey { | ||
type: CurveType; | ||
data: Bytes; | ||
/** Create PrivateKey object from representing types. */ | ||
static from(value: PrivateKeyType): PrivateKey; | ||
/** | ||
* Generate new PrivateKey. | ||
* @throws If a secure random source isn't available. | ||
*/ | ||
static generate(type: CurveType | string): PrivateKey; | ||
/** @internal */ | ||
constructor(type: CurveType, data: Bytes); | ||
/** | ||
* Sign message digest using this key. | ||
* @throws If the key type isn't R1 or K1. | ||
*/ | ||
signDigest(digest: Checksum256Type): Signature; | ||
/** | ||
* Sign message using this key. | ||
* @throws If the key type isn't R1 or K1. | ||
*/ | ||
signMessage(message: BytesType): Signature; | ||
/** | ||
* Derive the shared secret between this private key and given public key. | ||
* @throws If the key type isn't R1 or K1. | ||
*/ | ||
sharedSecret(publicKey: PublicKey): Checksum512; | ||
/** | ||
* Get the corresponding public key. | ||
* @throws If the key type isn't R1 or K1. | ||
*/ | ||
toPublic(): PublicKey; | ||
/** | ||
* Return WIF representation of this private key | ||
* @throws If the key type isn't K1. | ||
*/ | ||
toWif(): string; | ||
/** | ||
* Return the key in EOSIO PVT_<type>_<base58check> format. | ||
*/ | ||
toString(): string; | ||
toJSON(): string; | ||
} | ||
declare function TypeAlias(name: string): (typeAlias: any) => any; | ||
interface VariantConstructor extends ABISerializableConstructor { | ||
new <T extends Variant>(...args: any[]): T; | ||
} | ||
declare type AnyVariant = Variant | ABISerializable | [string, any]; | ||
declare class Variant implements ABISerializableObject { | ||
static abiName: string; | ||
static abiVariant: ABITypeDescriptor[]; | ||
static from<T extends VariantConstructor>(this: T, object: AnyVariant): InstanceType<T>; | ||
static from(object: AnyVariant): unknown; | ||
value: ABISerializable; | ||
variantIdx: number; | ||
/** @internal */ | ||
constructor(variant: [string, ABISerializable]); | ||
/** | ||
* Return true if this variant equals the other. | ||
* | ||
* Note: This compares the ABI encoded bytes of both variants, subclasses | ||
* should implement their own fast equality check when possible. | ||
*/ | ||
equals(other: AnyVariant): boolean; | ||
get variantName(): string; | ||
/** @internal */ | ||
toJSON(): ABISerializable[]; | ||
} | ||
declare namespace Variant { | ||
function type(name: string, types: ABISerializableType[]): <T extends VariantConstructor>(variant: T) => T; | ||
} | ||
declare namespace Base58 { | ||
/** Decode a Base58 encoded string. */ | ||
function decode(s: string, size?: number): Bytes; | ||
/** Decode a Base58Check encoded string. */ | ||
function decodeCheck(encoded: string, size?: number): Bytes; | ||
/** Decode a Base58Check encoded string that uses ripemd160 instead of double sha256 for the digest. */ | ||
function decodeRipemd160Check(encoded: string, size?: number, suffix?: string): Bytes; | ||
/** Encode bytes to a Base58 string. */ | ||
function encode(data: BytesType): string; | ||
function encodeCheck(data: BytesType): string; | ||
function encodeRipemd160Check(data: BytesType, suffix?: string): string; | ||
} | ||
/** Check if object in instance of class. */ | ||
declare function isInstanceOf<T extends { | ||
new (...args: any[]): InstanceType<T>; | ||
}>(object: any, someClass: T): object is InstanceType<T>; | ||
export { ABI, ABIDecoder, ABIDef, ABIEncoder, ABISerializable, ABISerializableConstructor, ABISerializableObject, ABISerializableType, types$1 as API, APIClient, APIClientOptions, APIError, APIErrorData, APIErrorDetail, APIProvider, Action, ActionFields, ActionType, AnyAction, AnyInt, AnyTransaction, AnyVariant, Asset, AssetType, Base58, BlockTimestamp, Bytes, BytesEncoding, BytesType, Checksum160, Checksum160Type, Checksum256, Checksum256Type, Checksum512, Checksum512Type, CurveType, ExtendedAsset, ExtendedAssetType, FetchProvider, FetchProviderOptions, Float128, Float128Type, Float32, Float32Type, Float64, Float64Type, Int128, Int128Type, Int16, Int16Type, Int32, Int32Type, Int64, Int64Type, Int8, Int8Type, Name, NameType, PackedTransaction, PermissionLevel, PermissionLevelType, PrivateKey, PrivateKeyType, PublicKey, PublicKeyType, Serializer, Signature, SignatureType, SignedTransaction, SignedTransactionFields, SignedTransactionType, Struct, StructConstructor, TimePoint, TimePointSec, TimePointType, Transaction, TransactionExtension, TransactionFields, TransactionHeader, TransactionHeaderFields, TransactionHeaderType, TransactionReceipt, TransactionType, TypeAlias, UInt128, UInt128Type, UInt16, UInt16Type, UInt32, UInt32Type, UInt64, UInt64Type, UInt8, UInt8Type, VarInt, VarIntType, VarUInt, VarUIntType, Variant, VariantConstructor, isInstanceOf }; | ||
export { ABI, ABIDecoder, ABIDef, ABIEncoder, ABISerializable, ABISerializableConstructor, ABISerializableObject, ABISerializableType, types$1 as API, APIClient, APIClientOptions, APIError, APIErrorData, APIErrorDetail, APIProvider, Action, ActionFields, ActionType, AnyAction, AnyInt, AnyTransaction, AnyVariant, Asset, AssetType, Authority, Base58, BlockTimestamp, Bytes, BytesEncoding, BytesType, Checksum160, Checksum160Type, Checksum256, Checksum256Type, Checksum512, Checksum512Type, CurveType, ExtendedAsset, ExtendedAssetType, FetchProvider, FetchProviderOptions, Float128, Float128Type, Float32, Float32Type, Float64, Float64Type, Int128, Int128Type, Int16, Int16Type, Int32, Int32Type, Int64, Int64Type, Int8, Int8Type, KeyWeight, Name, NameType, PackedTransaction, PermissionLevel, PermissionLevelType, PermissionLevelWeight, PrivateKey, PrivateKeyType, PublicKey, PublicKeyType, Serializer, Signature, SignatureType, SignedTransaction, SignedTransactionFields, SignedTransactionType, Struct, StructConstructor, TimePoint, TimePointSec, TimePointType, Transaction, TransactionExtension, TransactionFields, TransactionHeader, TransactionHeaderFields, TransactionHeaderType, TransactionReceipt, TransactionType, TypeAlias, UInt128, UInt128Type, UInt16, UInt16Type, UInt32, UInt32Type, UInt64, UInt64Type, UInt8, UInt8Type, VarInt, VarIntType, VarUInt, VarUIntType, Variant, VariantConstructor, WaitWeight, Weight, isInstanceOf }; |
{ | ||
"name": "@greymass/eosio", | ||
"description": "Library for working with EOSIO blockchains", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"homepage": "https://github.com/greymass/eosio-core", | ||
@@ -6,0 +6,0 @@ "license": "BSD-3-Clause", |
import {APIClient} from '../client' | ||
import {Int128, Int64, UInt32, UInt64} from '../../chain/integer' | ||
import {Name, NameType} from '../../chain/name' | ||
import {PackedTransaction, SignedTransaction, SignedTransactionType} from '../../chain/transaction' | ||
import { | ||
Bytes, | ||
Checksum160, | ||
Checksum256, | ||
Float128, | ||
Float64, | ||
Int128, | ||
Int64, | ||
Name, | ||
NameType, | ||
PackedTransaction, | ||
SignedTransaction, | ||
SignedTransactionType, | ||
UInt32, | ||
UInt64, | ||
} from '../../chain' | ||
import { | ||
AccountObject, | ||
@@ -20,6 +34,4 @@ GetAbiResponse, | ||
} from './types' | ||
import {ABISerializableConstructor, ABISerializableType, Serializer} from '../../serializer' | ||
import {Checksum160, Checksum256} from '../../chain/checksum' | ||
import {Float128, Float64} from '../../chain/float' | ||
import {Bytes} from '../../chain/bytes' | ||
import {isInstanceOf} from '../../utils' | ||
@@ -26,0 +38,0 @@ |
@@ -1,35 +0,30 @@ | ||
import {ABI} from '../../chain/abi' | ||
import {Asset} from '../../chain/asset' | ||
import {Bytes} from '../../chain/bytes' | ||
import {Checksum160, Checksum256} from '../../chain/checksum' | ||
import {Int128, Int32, Int64, UInt16, UInt32, UInt32Type, UInt64} from '../../chain/integer' | ||
import {Name, NameType} from '../../chain/name' | ||
import {PermissionLevel} from '../../chain/permission-level' | ||
import {PublicKey} from '../../chain/public-key' | ||
import {Struct} from '../../chain/struct' | ||
import {TimePoint, TimePointSec} from '../../chain/time' | ||
import {Signature} from '../../chain/signature' | ||
import {TransactionHeader, TransactionReceipt} from '../../chain/transaction' | ||
import { | ||
ABI, | ||
Asset, | ||
Authority, | ||
Bytes, | ||
Checksum160, | ||
Checksum256, | ||
Float128, | ||
Float64, | ||
Int128, | ||
Int32, | ||
Int64, | ||
Name, | ||
NameType, | ||
PublicKey, | ||
Signature, | ||
Struct, | ||
TimePoint, | ||
TimePointSec, | ||
TransactionHeader, | ||
TransactionReceipt, | ||
UInt16, | ||
UInt32, | ||
UInt32Type, | ||
UInt64, | ||
} from '../../chain' | ||
import {ABISerializableType} from '../../serializer' | ||
import {Float128, Float64} from '../../chain/float' | ||
@Struct.type('account_auth') | ||
export class AccountAuth extends Struct { | ||
@Struct.field('uint32') weight!: UInt32 | ||
@Struct.field(PermissionLevel) permission!: PermissionLevel | ||
} | ||
@Struct.type('key_auth') | ||
export class KeyAuth extends Struct { | ||
@Struct.field('uint32') weight!: UInt32 | ||
@Struct.field('public_key') key!: PublicKey | ||
} | ||
@Struct.type('required_auth') | ||
export class RequiredAuth extends Struct { | ||
@Struct.field('uint32') threshold!: UInt32 | ||
@Struct.field(KeyAuth, {array: true, default: []}) keys!: KeyAuth[] | ||
@Struct.field(AccountAuth, {array: true, default: []}) accounts!: AccountAuth[] | ||
} | ||
@Struct.type('account_permission') | ||
@@ -39,3 +34,3 @@ export class AccountPermission extends Struct { | ||
@Struct.field('name') parent!: Name | ||
@Struct.field(RequiredAuth) required_auth!: RequiredAuth | ||
@Struct.field(Authority) required_auth!: Authority | ||
} | ||
@@ -42,0 +37,0 @@ |
import {ripemd160, sha256} from 'hash.js' | ||
import {arrayEquals} from './utils' | ||
import {Bytes, BytesType} from './chain/bytes' | ||
import {Bytes, BytesType} from './chain' | ||
@@ -5,0 +5,0 @@ export namespace Base58 { |
import {isInstanceOf} from '../utils' | ||
import {Name, NameType} from './name' | ||
import {Name, NameType} from '../' | ||
export type ABIDef = string | Partial<ABI.Def> | ABI | ||
@@ -5,0 +6,0 @@ |
@@ -1,6 +0,2 @@ | ||
import {Struct} from './struct' | ||
import {Name, NameType} from './name' | ||
import {Bytes, BytesType} from './bytes' | ||
import {abiEncode} from '../serializer/encoder' | ||
import {ABI, ABIDef} from './abi' | ||
import {abiDecode} from '../serializer/decoder' | ||
@@ -12,6 +8,18 @@ import { | ||
} from '../serializer/serializable' | ||
import {PermissionLevel, PermissionLevelType} from './permission-level' | ||
import {arrayEquatableEquals} from '../utils' | ||
import {BuiltinTypes} from '../serializer/builtins' | ||
import { | ||
ABI, | ||
ABIDef, | ||
Bytes, | ||
BytesType, | ||
Name, | ||
NameType, | ||
PermissionLevel, | ||
PermissionLevelType, | ||
Struct, | ||
} from '../' | ||
export interface ActionFields { | ||
@@ -18,0 +26,0 @@ /** The account (a.k.a. contract) to run action on. */ |
import BN from 'bn.js' | ||
import {ABISerializableObject} from '../serializer/serializable' | ||
import {Int64, Int64Type, UInt64} from './integer' | ||
import {ABIEncoder} from '../serializer/encoder' | ||
import {ABIDecoder} from '../serializer/decoder' | ||
import {Name, NameType} from './name' | ||
import {isInstanceOf} from '../utils' | ||
import {Int64, Int64Type, Name, NameType, UInt64} from '../' | ||
export type AssetType = Asset | string | ||
@@ -11,0 +11,0 @@ |
@@ -5,3 +5,2 @@ import {ABISerializableObject} from '../serializer/serializable' | ||
import {arrayEquals, arrayToHex, hexToArray, isInstanceOf, secureRandom} from '../utils' | ||
import {Checksum160, Checksum256, Checksum512} from './checksum' | ||
@@ -73,14 +72,2 @@ export type BytesType = Bytes | Uint8Array | ArrayLike<number> | string | ||
get ripemd160Digest(): Checksum160 { | ||
return Checksum160.hash(this) | ||
} | ||
get sha256Digest(): Checksum256 { | ||
return Checksum256.hash(this) | ||
} | ||
get sha512Digest(): Checksum512 { | ||
return Checksum512.hash(this) | ||
} | ||
get hexString(): string { | ||
@@ -87,0 +74,0 @@ return arrayToHex(this.array) |
@@ -6,6 +6,6 @@ import {ripemd160, sha256, sha512} from 'hash.js' | ||
import {ABISerializableObject} from '../serializer/serializable' | ||
import {Bytes, BytesType} from './bytes' | ||
import {arrayEquals, arrayToHex, isInstanceOf} from '../utils' | ||
import {Bytes, BytesType} from '../' | ||
type ChecksumType = Checksum | BytesType | ||
@@ -12,0 +12,0 @@ |
@@ -5,4 +5,5 @@ import {ABISerializableObject} from '../serializer/serializable' | ||
import {isInstanceOf, secureRandom} from '../utils' | ||
import {Bytes, BytesType} from './bytes' | ||
import {Bytes, BytesType} from '../' | ||
type FloatType = Float | number | string | ||
@@ -9,0 +10,0 @@ |
@@ -1,2 +0,1 @@ | ||
import {UInt64} from './integer' | ||
import {ABISerializableObject} from '../serializer/serializable' | ||
@@ -7,2 +6,4 @@ import {ABIEncoder} from '../serializer/encoder' | ||
import {UInt64} from '../' | ||
/** Type representing a name. */ | ||
@@ -9,0 +10,0 @@ export type NameType = Name | UInt64 | string |
@@ -1,3 +0,2 @@ | ||
import {Name, NameType} from './name' | ||
import {Struct} from './struct' | ||
import {Name, NameType, Struct} from '../' | ||
@@ -31,2 +30,6 @@ export type PermissionLevelType = PermissionLevel | {actor: NameType; permission: NameType} | ||
} | ||
toString() { | ||
return `${this.actor}@${this.permission}` | ||
} | ||
} |
import {Base58} from '../base58' | ||
import {isInstanceOf} from '../utils' | ||
import {Bytes, BytesType} from './bytes' | ||
import {Checksum256, Checksum256Type} from './checksum' | ||
import {PublicKey} from './public-key' | ||
import {Signature} from './signature' | ||
import {getPublic} from '../crypto/get-public' | ||
@@ -12,5 +8,14 @@ import {sharedSecret} from '../crypto/shared-secret' | ||
import {generate} from '../crypto/generate' | ||
import {CurveType} from './curve-type' | ||
import {isInstanceOf} from '../utils' | ||
import { | ||
Bytes, | ||
BytesType, | ||
Checksum256, | ||
Checksum256Type, | ||
Checksum512, | ||
CurveType, | ||
PublicKey, | ||
Signature, | ||
} from '../' | ||
export type PrivateKeyType = PrivateKey | string | ||
@@ -51,3 +56,3 @@ | ||
if (data.array[0] !== 0x80) { | ||
throw new Error('Invalid private key wif') | ||
throw new Error('Invalid private key WIF') | ||
} | ||
@@ -86,3 +91,3 @@ return new PrivateKey(type, data.droppingFirst()) | ||
signMessage(message: BytesType) { | ||
return this.signDigest(Bytes.from(message).sha256Digest) | ||
return this.signDigest(Checksum256.hash(message)) | ||
} | ||
@@ -96,3 +101,3 @@ | ||
const shared = sharedSecret(this.data.array, publicKey.data.array, this.type) | ||
return new Bytes(shared).sha512Digest | ||
return Checksum512.hash(shared) | ||
} | ||
@@ -99,0 +104,0 @@ |
@@ -6,7 +6,6 @@ import {ABIDecoder} from '../serializer/decoder' | ||
import {Base58} from '../base58' | ||
import {Bytes} from './bytes' | ||
import {CurveType} from './curve-type' | ||
import {isInstanceOf} from '../utils' | ||
import {Bytes, CurveType} from '../' | ||
export type PublicKeyType = PublicKey | string | {type: string; compressed: Uint8Array} | ||
@@ -13,0 +12,0 @@ |
@@ -6,11 +6,9 @@ import {ABIDecoder} from '../serializer/decoder' | ||
import {Base58} from '../base58' | ||
import {Bytes, BytesType} from './bytes' | ||
import {Checksum256, Checksum256Type} from './checksum' | ||
import {PublicKey} from './public-key' | ||
import {isInstanceOf} from '../utils' | ||
import {recover} from '../crypto/recover' | ||
import {verify} from '../crypto/verify' | ||
import {CurveType} from './curve-type' | ||
import {isInstanceOf} from '../utils' | ||
import {Bytes, BytesType, Checksum256, Checksum256Type, CurveType, PublicKey} from '../' | ||
export type SignatureType = | ||
@@ -96,3 +94,3 @@ | Signature | ||
recoverMessage(message: BytesType) { | ||
return this.recoverDigest(Bytes.from(message).sha256Digest) | ||
return this.recoverDigest(Checksum256.hash(message)) | ||
} | ||
@@ -108,3 +106,3 @@ | ||
verifyMessage(message: BytesType, publicKey: PublicKey) { | ||
return this.verifyDigest(Bytes.from(message).sha256Digest, publicKey) | ||
return this.verifyDigest(Checksum256.hash(message), publicKey) | ||
} | ||
@@ -111,0 +109,0 @@ |
@@ -8,3 +8,3 @@ import BN from 'bn.js' | ||
import {AnyInt, Int64, Int64Type, UInt32, UInt32Type} from './integer' | ||
import {AnyInt, Int64, Int64Type, UInt32, UInt32Type} from '../' | ||
@@ -11,0 +11,0 @@ export type TimePointType = TimePoint | TimePointSec | string | Date | AnyInt |
@@ -1,5 +0,19 @@ | ||
import {Action, ActionType, AnyAction} from './action' | ||
import {Bytes, BytesType} from './bytes' | ||
import {Checksum256, Checksum256Type} from './checksum' | ||
import {abiEncode} from '../serializer/encoder' | ||
import {Signature, SignatureType} from './signature' | ||
import {abiDecode} from '../serializer/decoder' | ||
import { | ||
ABIDef, | ||
Action, | ||
ActionType, | ||
AnyAction, | ||
Bytes, | ||
BytesType, | ||
Checksum256, | ||
Checksum256Type, | ||
Name, | ||
NameType, | ||
Struct, | ||
TimePointSec, | ||
TimePointType, | ||
UInt16, | ||
@@ -13,12 +27,4 @@ UInt16Type, | ||
VarUIntType, | ||
} from './integer' | ||
import {Struct} from './struct' | ||
import {TimePointSec, TimePointType} from './time' | ||
} from '../' | ||
import {abiEncode} from '../serializer/encoder' | ||
import {Signature, SignatureType} from './signature' | ||
import {abiDecode} from '../serializer/decoder' | ||
import {ABIDef} from './abi' | ||
import {Name, NameType} from './name' | ||
@Struct.type('transaction_extension') | ||
@@ -130,3 +136,3 @@ export class TransactionExtension extends Struct { | ||
get id(): Checksum256 { | ||
return abiEncode({object: this}).sha256Digest | ||
return Checksum256.hash(abiEncode({object: this})) | ||
} | ||
@@ -138,3 +144,3 @@ | ||
data = data.appending(new Uint8Array(32)) | ||
return data.sha256Digest | ||
return Checksum256.hash(data) | ||
} | ||
@@ -141,0 +147,0 @@ } |
@@ -1,25 +0,3 @@ | ||
// api | ||
export * from './api/client' | ||
export * from './api/provider' | ||
export * as API from './api/types' | ||
// chain types | ||
export * from './chain/abi' | ||
export * from './chain/action' | ||
export * from './chain/asset' | ||
export * from './chain/bytes' | ||
export * from './chain/checksum' | ||
export * from './chain/curve-type' | ||
export * from './chain/float' | ||
export * from './chain/integer' | ||
export * from './chain/name' | ||
export * from './chain/permission-level' | ||
export * from './chain/private-key' | ||
export * from './chain/public-key' | ||
export * from './chain/signature' | ||
export * from './chain/struct' | ||
export * from './chain/time' | ||
export * from './chain/transaction' | ||
export * from './chain/type-alias' | ||
export * from './chain/variant' | ||
export * from './chain' | ||
@@ -30,1 +8,6 @@ // utils | ||
export {isInstanceOf} from './utils' | ||
// api | ||
export * from './api/client' | ||
export * from './api/provider' | ||
export * as API from './api/types' |
import {ABIDecoder} from './decoder' | ||
import {ABIEncoder} from './encoder' | ||
import {ABIField, ABISerializableConstructor} from './serializable' | ||
import {Bytes} from '../chain/bytes' | ||
import {Name} from '../chain/name' | ||
import {Float128, Float32, Float64} from '../chain/float' | ||
import { | ||
Asset, | ||
BlockTimestamp, | ||
Bytes, | ||
Checksum160, | ||
Checksum256, | ||
Checksum512, | ||
ExtendedAsset, | ||
Float128, | ||
Float32, | ||
Float64, | ||
Int128, | ||
@@ -13,2 +21,8 @@ Int16, | ||
Int8, | ||
Name, | ||
PublicKey, | ||
Signature, | ||
Struct, | ||
TimePoint, | ||
TimePointSec, | ||
UInt128, | ||
@@ -21,9 +35,3 @@ UInt16, | ||
VarUInt, | ||
} from '../chain/integer' | ||
import {Asset, ExtendedAsset} from '../chain/asset' | ||
import {Checksum160, Checksum256, Checksum512} from '../chain/checksum' | ||
import {Signature} from '../chain/signature' | ||
import {PublicKey} from '../chain/public-key' | ||
import {Struct} from '../chain/struct' | ||
import {BlockTimestamp, TimePoint, TimePointSec} from '../chain/time' | ||
} from '../chain' | ||
@@ -53,2 +61,10 @@ const StringType = { | ||
export interface BuiltinTypes { | ||
string: string | ||
'string?'?: string | ||
'string[]': string[] | ||
'string[]?'?: string[] | ||
bool: boolean | ||
'bool?'?: boolean | ||
'bool[]': boolean[] | ||
'bool[]?'?: boolean[] | ||
asset: Asset | ||
@@ -62,6 +78,2 @@ 'asset?'?: Asset | ||
'extended_asset[]?'?: ExtendedAsset[] | ||
bool: boolean | ||
'bool?'?: boolean | ||
'bool[]': boolean[] | ||
'bool[]?'?: boolean[] | ||
bytes: Bytes | ||
@@ -95,6 +107,2 @@ 'bytes?'?: Bytes | ||
'signature[]?'?: Signature[] | ||
string: string | ||
'string?'?: string | ||
'string[]': string[] | ||
'string[]?'?: string[] | ||
symbol: Asset.Symbol | ||
@@ -182,37 +190,39 @@ 'symbol?'?: Asset.Symbol | ||
const builtins = [ | ||
// types represented by JavaScript builtins | ||
BoolType as ABISerializableConstructor, | ||
StringType as ABISerializableConstructor, | ||
// types represented by Classes | ||
Asset, | ||
Asset.Symbol, | ||
Asset.SymbolCode, | ||
ExtendedAsset, | ||
Bytes, | ||
Checksum160, | ||
Checksum256, | ||
Checksum512, | ||
Int8, | ||
Int16, | ||
Int32, | ||
Int64, | ||
Int128, | ||
Float32, | ||
Float64, | ||
Float128, | ||
Name, | ||
PublicKey, | ||
Signature, | ||
TimePoint, | ||
TimePointSec, | ||
BlockTimestamp, | ||
UInt8, | ||
UInt16, | ||
UInt32, | ||
UInt64, | ||
UInt128, | ||
VarInt, | ||
VarUInt, | ||
] | ||
function getBuiltins(): ABISerializableConstructor[] { | ||
return [ | ||
// types represented by JavaScript builtins | ||
BoolType as ABISerializableConstructor, | ||
StringType as ABISerializableConstructor, | ||
// types represented by Classes | ||
Asset, | ||
Asset.Symbol, | ||
Asset.SymbolCode, | ||
BlockTimestamp, | ||
Bytes, | ||
Checksum160, | ||
Checksum256, | ||
Checksum512, | ||
ExtendedAsset, | ||
Float128, | ||
Float32, | ||
Float64, | ||
Int128, | ||
Int16, | ||
Int32, | ||
Int64, | ||
Int8, | ||
Name, | ||
PublicKey, | ||
Signature, | ||
TimePoint, | ||
TimePointSec, | ||
UInt128, | ||
UInt16, | ||
UInt32, | ||
UInt64, | ||
UInt8, | ||
VarInt, | ||
VarUInt, | ||
] | ||
} | ||
@@ -223,2 +233,3 @@ export type TypeLookup = {[name: string]: ABISerializableConstructor} | ||
const rv: TypeLookup = {} | ||
const builtins = getBuiltins() | ||
for (const type of builtins) { | ||
@@ -228,3 +239,5 @@ rv[type.abiName] = type | ||
for (const type of additional) { | ||
// TODO: check conformance? | ||
if (!type.abiName) { | ||
throw new Error('Invalid type') | ||
} | ||
rv[type.abiName] = type | ||
@@ -231,0 +244,0 @@ } |
@@ -7,4 +7,3 @@ /** | ||
import {ABI, ABIDef} from '../chain/abi' | ||
import {Bytes, BytesType} from '../chain/bytes' | ||
import {ABI, ABIDef, Bytes, BytesType, Variant} from '../chain' | ||
@@ -19,4 +18,5 @@ import { | ||
} from './serializable' | ||
import {buildTypeLookup, BuiltinTypes, getTypeName, TypeLookup} from './builtins' | ||
import {Variant} from '../chain/variant' | ||
import {isInstanceOf} from '../utils' | ||
@@ -23,0 +23,0 @@ |
@@ -7,4 +7,4 @@ /** | ||
import {ABI, ABIDef} from '../chain/abi' | ||
import {Bytes} from '../chain/bytes' | ||
import {ABI, ABIDef, Bytes, Variant} from '../chain' | ||
import {isInstanceOf} from '../utils' | ||
@@ -21,4 +21,2 @@ import { | ||
import {buildTypeLookup, getType, getTypeName} from './builtins' | ||
import {Variant} from '../chain/variant' | ||
import {isInstanceOf} from '../utils' | ||
@@ -25,0 +23,0 @@ class EncodingError extends Error { |
@@ -1,2 +0,2 @@ | ||
import {ABI} from '../chain/abi' | ||
import {ABI} from '../chain' | ||
import {ABIDecoder} from './decoder' | ||
@@ -3,0 +3,0 @@ import {ABIEncoder} from './encoder' |
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
731267
47
14478