@greymass/eosio
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -0,1 +1,38 @@ | ||
/** | ||
* EOSIO Core by Greymass | ||
* Library for working with EOSIO blockchains in JavaScript environments | ||
* https://github.com/greymass/eosio-core | ||
* | ||
* @license | ||
* Copyright (c) 2020 FFF00 Agents AB & Greymass Inc. All Rights Reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without modification, | ||
* are permitted provided that the following conditions are met: | ||
* | ||
* 1. Redistribution of source code must retain the above copyright notice, this | ||
* list of conditions and the following disclaimer. | ||
* | ||
* 2. Redistribution in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* | ||
* 3. Neither the name of the copyright holder nor the names of its contributors | ||
* may be used to endorse or promote products derived from this software without | ||
* specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | ||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE | ||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
* OF THE POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
* YOU ACKNOWLEDGE THAT THIS SOFTWARE IS NOT DESIGNED, LICENSED OR INTENDED FOR USE | ||
* IN THE DESIGN, CONSTRUCTION, OPERATION OR MAINTENANCE OF ANY MILITARY FACILITY. | ||
* | ||
*/ | ||
import BN from 'bn.js'; | ||
@@ -482,3 +519,3 @@ | ||
declare type EncodeArgs = EncodeArgsSerializable | EncodeArgsUntyped; | ||
declare function encode(args: EncodeArgs): Bytes; | ||
declare function abiEncode(args: EncodeArgs): Bytes; | ||
declare class ABIEncoder { | ||
@@ -558,5 +595,5 @@ private pageSize; | ||
} | ||
declare function decode<T extends keyof BuiltinTypes>(args: BuiltinDecodeArgs<T>): BuiltinTypes[T]; | ||
declare function decode<T extends ABISerializableConstructor>(args: TypedDecodeArgs<T>): InstanceType<T>; | ||
declare function decode(args: UntypedDecodeArgs): ABISerializable; | ||
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 { | ||
@@ -1059,4 +1096,4 @@ private array; | ||
declare namespace Serializer { | ||
const encode: typeof encode; | ||
const decode: typeof decode; | ||
const encode: typeof abiEncode; | ||
const decode: typeof abiDecode; | ||
function synthesize(type: ABISerializableConstructor): ABI; | ||
@@ -1063,0 +1100,0 @@ } |
{ | ||
"name": "@greymass/eosio", | ||
"description": "Library for working with EOSIO blockchains", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"license": "BSD-3-Clause", | ||
@@ -6,0 +6,0 @@ "main": "lib/eosio-core.js", |
import {APIProvider, FetchProvider, FetchProviderOptions} from './provider' | ||
import {ABISerializableConstructor, ABISerializableType} from '../serializer/serializable' | ||
import {decode} from '../serializer/decoder' | ||
import {abiDecode} from '../serializer/decoder' | ||
import {ChainAPI} from './v1/chain' | ||
@@ -93,3 +93,3 @@ import {BuiltinTypes} from '../serializer/builtins' | ||
if (args.responseType) { | ||
return decode({type: args.responseType, object: response}) | ||
return abiDecode({type: args.responseType, object: response}) | ||
} | ||
@@ -96,0 +96,0 @@ return response |
import {Struct} from './struct' | ||
import {Name, NameType} from './name' | ||
import {Bytes, BytesType} from './bytes' | ||
import {encode} from '../serializer/encoder' | ||
import {abiEncode} from '../serializer/encoder' | ||
import {ABI, ABIDef} from './abi' | ||
import {decode} from '../serializer/decoder' | ||
import {abiDecode} from '../serializer/decoder' | ||
import { | ||
@@ -61,3 +61,3 @@ ABISerializable, | ||
...object, | ||
data: encode({object: data, type, abi}), | ||
data: abiEncode({object: data, type, abi}), | ||
} | ||
@@ -85,3 +85,3 @@ } | ||
if (typeof typeOrAbi === 'string' || (typeOrAbi as ABISerializableConstructor).abiName) { | ||
return decode({ | ||
return abiDecode({ | ||
data: this.data, | ||
@@ -96,5 +96,5 @@ type: typeOrAbi as string, | ||
} | ||
return decode({data: this.data, type, abi}) | ||
return abiDecode({data: this.data, type, abi}) | ||
} | ||
} | ||
} |
@@ -6,4 +6,4 @@ import { | ||
} from '../serializer/serializable' | ||
import {decode, Resolved} from '../serializer/decoder' | ||
import {encode} from '../serializer/encoder' | ||
import {abiDecode, Resolved} from '../serializer/decoder' | ||
import {abiEncode} from '../serializer/encoder' | ||
@@ -36,3 +36,3 @@ export interface StructConstructor extends ABISerializableConstructor { | ||
} | ||
return decode({object, type: this}) | ||
return abiDecode({object, type: this}) | ||
} | ||
@@ -77,3 +77,3 @@ | ||
} | ||
return encode({object: this}).equals(encode({object: self.from(other)})) | ||
return abiEncode({object: this}).equals(abiEncode({object: self.from(other)})) | ||
} | ||
@@ -80,0 +80,0 @@ |
@@ -17,5 +17,5 @@ import {Action, ActionType, AnyAction} from './action' | ||
import {encode} from '../serializer/encoder' | ||
import {abiEncode} from '../serializer/encoder' | ||
import {Signature, SignatureType} from './signature' | ||
import {decode} from '../serializer/decoder' | ||
import {abiDecode} from '../serializer/decoder' | ||
import {ABIDef} from './abi' | ||
@@ -133,3 +133,3 @@ import {Name, NameType} from './name' | ||
get id(): Checksum256 { | ||
return encode({object: this}).sha256Digest | ||
return abiEncode({object: this}).sha256Digest | ||
} | ||
@@ -139,3 +139,3 @@ | ||
let data = Bytes.from(Checksum256.from(chainId).array) | ||
data = data.appending(encode({object: this})) | ||
data = data.appending(abiEncode({object: this})) | ||
data = data.appending(new Uint8Array(32)) | ||
@@ -181,4 +181,7 @@ return data.sha256Digest | ||
signatures: signed.signatures, | ||
packed_context_free_data: encode({object: signed.context_free_data, type: 'bytes[]'}), | ||
packed_trx: encode({object: tx}), | ||
packed_context_free_data: abiEncode({ | ||
object: signed.context_free_data, | ||
type: 'bytes[]', | ||
}), | ||
packed_trx: abiEncode({object: tx}), | ||
}) | ||
@@ -191,3 +194,3 @@ } | ||
} | ||
return decode({data: this.packed_trx, type: Transaction}) as Transaction | ||
return abiDecode({data: this.packed_trx, type: Transaction}) as Transaction | ||
} | ||
@@ -194,0 +197,0 @@ |
@@ -10,4 +10,4 @@ import { | ||
} from '../serializer/serializable' | ||
import {decode, Resolved} from '../serializer/decoder' | ||
import {encode} from '../serializer/encoder' | ||
import {abiDecode, Resolved} from '../serializer/decoder' | ||
import {abiEncode} from '../serializer/encoder' | ||
@@ -31,3 +31,3 @@ export interface VariantConstructor extends ABISerializableConstructor { | ||
} | ||
return decode({object, type: this}) | ||
return abiDecode({object, type: this}) | ||
} | ||
@@ -61,3 +61,3 @@ | ||
} | ||
return encode({object: this}).equals(encode({object: otherVariant})) | ||
return abiEncode({object: this}).equals(abiEncode({object: otherVariant})) | ||
} | ||
@@ -64,0 +64,0 @@ |
@@ -63,8 +63,8 @@ /** | ||
export function decode<T extends keyof BuiltinTypes>(args: BuiltinDecodeArgs<T>): BuiltinTypes[T] | ||
export function decode<T extends ABISerializableConstructor>( | ||
export function abiDecode<T extends keyof BuiltinTypes>(args: BuiltinDecodeArgs<T>): BuiltinTypes[T] | ||
export function abiDecode<T extends ABISerializableConstructor>( | ||
args: TypedDecodeArgs<T> | ||
): InstanceType<T> | ||
export function decode(args: UntypedDecodeArgs): ABISerializable | ||
export function decode(args: UntypedDecodeArgs | BuiltinDecodeArgs<any> | TypedDecodeArgs<any>) { | ||
export function abiDecode(args: UntypedDecodeArgs): ABISerializable | ||
export function abiDecode(args: UntypedDecodeArgs | BuiltinDecodeArgs<any> | TypedDecodeArgs<any>) { | ||
const descriptor = toTypeDescriptor(args.type) | ||
@@ -71,0 +71,0 @@ const typeName = abiTypeString(descriptor) |
@@ -89,3 +89,3 @@ /** | ||
export function encode(args: EncodeArgs): Bytes { | ||
export function abiEncode(args: EncodeArgs): Bytes { | ||
let type: ABISerializableConstructor | undefined | ||
@@ -92,0 +92,0 @@ let typeName: string | undefined |
@@ -1,3 +0,3 @@ | ||
import {encode as abiEncode} from './encoder' | ||
import {decode as abiDecode} from './decoder' | ||
import {abiEncode} from './encoder' | ||
import {abiDecode} from './decoder' | ||
import {ABISerializableConstructor, synthesizeABI} from './serializable' | ||
@@ -4,0 +4,0 @@ |
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 not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
843929
13164
0