@wharfkit/contract
Advanced tools
Comparing version 1.1.5 to 1.2.0
@@ -103,2 +103,3 @@ import { ABI, APIClient, API, ABIDef, NameType, Name, PermissionLevelType, BytesType, ABISerializableObject, Action, Blob } from '@wharfkit/antelope'; | ||
fieldToIndex?: FieldToIndex; | ||
debug?: boolean; | ||
defaultRowLimit?: number; | ||
@@ -124,2 +125,3 @@ defaultScope?: NameType; | ||
readonly tableABI: ABI.Table; | ||
readonly debug: boolean; | ||
private fieldToIndex?; | ||
@@ -192,2 +194,5 @@ defaultScope?: NameType; | ||
} | ||
interface ContractOptions { | ||
debug?: boolean; | ||
} | ||
interface ActionOptions { | ||
@@ -212,2 +217,3 @@ authorization?: PermissionLevelType[]; | ||
readonly client: APIClient; | ||
readonly debug: boolean; | ||
/** | ||
@@ -218,3 +224,3 @@ * Constructs a new `Contract` instance. | ||
*/ | ||
constructor(args: ContractArgs); | ||
constructor(args: ContractArgs, options?: ContractOptions); | ||
get tableNames(): string[]; | ||
@@ -251,2 +257,3 @@ hasTable(name: NameType): boolean; | ||
abis?: ABIDefinition[]; | ||
debug?: boolean; | ||
} | ||
@@ -256,2 +263,3 @@ declare class ContractKit { | ||
readonly client: APIClient; | ||
readonly debug: boolean; | ||
constructor(args: ContractKitArgs, options?: ContractKitOptions); | ||
@@ -276,2 +284,2 @@ /** | ||
export { ABIDefinition, ActionConstructor, ActionDataType, ActionOptions, ActionsArgs, Contract, ContractArgs, ContractKit, ContractKitArgs, ContractKitOptions, GetTableRowsOptions, PartialBy, QueryParams, Table, TableRowCursor, TableScopeCursor, abiToBlob, blobStringToAbi, capitalize, ContractKit as default, indexPositionInWords, pascalCase, singularize, wrapIndexValue }; | ||
export { ABIDefinition, ActionConstructor, ActionDataType, ActionOptions, ActionsArgs, Contract, ContractArgs, ContractKit, ContractKitArgs, ContractKitOptions, ContractOptions, GetTableRowsOptions, PartialBy, QueryParams, Table, TableRowCursor, TableScopeCursor, abiToBlob, blobStringToAbi, capitalize, ContractKit as default, indexPositionInWords, pascalCase, singularize, wrapIndexValue }; |
@@ -53,3 +53,3 @@ 'use strict'; | ||
function wrapIndexValue(value) { | ||
if (!value) { | ||
if (value === undefined || value === null) { | ||
return; | ||
@@ -213,2 +213,3 @@ } | ||
constructor(args) { | ||
this.debug = false; | ||
this.defaultRowLimit = 1000; | ||
@@ -227,2 +228,5 @@ this.abi = antelope.ABI.from(args.abi); | ||
this.defaultScope = args.defaultScope; | ||
if (args.debug) { | ||
this.debug = true; | ||
} | ||
} | ||
@@ -240,2 +244,3 @@ static from(tableParams) { | ||
type: this.rowType, | ||
json: this.debug, | ||
index_position: params.index_position, | ||
@@ -276,3 +281,3 @@ key_type: params.key_type, | ||
key_type: params.key_type, | ||
json: false, | ||
json: this.debug, | ||
reverse: params.reverse, | ||
@@ -292,2 +297,5 @@ }; | ||
let [row] = rows; | ||
if (this.debug) { | ||
return row; | ||
} | ||
if (!this.rowType) { | ||
@@ -346,3 +354,4 @@ row = antelope.Serializer.decode({ | ||
class Contract { | ||
constructor(args) { | ||
constructor(args, options = {}) { | ||
this.debug = false; | ||
if (!args.abi) { | ||
@@ -360,2 +369,5 @@ throw new Error('Contract requires an ABI'); | ||
this.client = args.client; | ||
if (options.debug) { | ||
this.debug = options.debug; | ||
} | ||
} | ||
@@ -376,2 +388,3 @@ get tableNames() { | ||
client: this.client, | ||
debug: this.debug, | ||
defaultScope: scope, | ||
@@ -449,2 +462,3 @@ name, | ||
constructor(args, options = defaultContractKitOptions) { | ||
this.debug = false; | ||
if (args.client) { | ||
@@ -465,2 +479,5 @@ this.client = args.client; | ||
} | ||
if (options.debug) { | ||
this.debug = options.debug; | ||
} | ||
} | ||
@@ -475,2 +492,4 @@ load(contract) { | ||
client: this.client, | ||
}, { | ||
debug: this.debug, | ||
}); | ||
@@ -477,0 +496,0 @@ }); |
@@ -48,3 +48,3 @@ import { isInstanceOf, UInt128, UInt64, Float64, Checksum256, Checksum160, Name, Serializer, ABI, Blob, PermissionLevel, Action, Transaction } from '@wharfkit/antelope'; | ||
function wrapIndexValue(value) { | ||
if (!value) { | ||
if (value === undefined || value === null) { | ||
return; | ||
@@ -188,2 +188,3 @@ } | ||
constructor(args) { | ||
this.debug = false; | ||
this.defaultRowLimit = 1000; | ||
@@ -202,2 +203,5 @@ this.abi = ABI.from(args.abi); | ||
this.defaultScope = args.defaultScope; | ||
if (args.debug) { | ||
this.debug = true; | ||
} | ||
} | ||
@@ -215,2 +219,3 @@ static from(tableParams) { | ||
type: this.rowType, | ||
json: this.debug, | ||
index_position: params.index_position, | ||
@@ -250,3 +255,3 @@ key_type: params.key_type, | ||
key_type: params.key_type, | ||
json: false, | ||
json: this.debug, | ||
reverse: params.reverse, | ||
@@ -266,2 +271,5 @@ }; | ||
let [row] = rows; | ||
if (this.debug) { | ||
return row; | ||
} | ||
if (!this.rowType) { | ||
@@ -320,3 +328,4 @@ row = Serializer.decode({ | ||
class Contract { | ||
constructor(args) { | ||
constructor(args, options = {}) { | ||
this.debug = false; | ||
if (!args.abi) { | ||
@@ -334,2 +343,5 @@ throw new Error('Contract requires an ABI'); | ||
this.client = args.client; | ||
if (options.debug) { | ||
this.debug = options.debug; | ||
} | ||
} | ||
@@ -350,2 +362,3 @@ get tableNames() { | ||
client: this.client, | ||
debug: this.debug, | ||
defaultScope: scope, | ||
@@ -421,2 +434,3 @@ name, | ||
constructor(args, options = defaultContractKitOptions) { | ||
this.debug = false; | ||
if (args.client) { | ||
@@ -437,2 +451,5 @@ this.client = args.client; | ||
} | ||
if (options.debug) { | ||
this.debug = options.debug; | ||
} | ||
} | ||
@@ -446,2 +463,4 @@ async load(contract) { | ||
client: this.client, | ||
}, { | ||
debug: this.debug, | ||
}); | ||
@@ -448,0 +467,0 @@ } |
{ | ||
"name": "@wharfkit/contract", | ||
"description": "ContractKit for Wharf", | ||
"version": "1.1.5", | ||
"version": "1.2.0", | ||
"homepage": "https://github.com/wharfkit/contract", | ||
@@ -6,0 +6,0 @@ "license": "BSD-3-Clause", |
@@ -25,2 +25,6 @@ import { | ||
export interface ContractOptions { | ||
debug?: boolean | ||
} | ||
export interface ActionOptions { | ||
@@ -49,2 +53,3 @@ authorization?: PermissionLevelType[] | ||
readonly client: APIClient | ||
readonly debug: boolean = false | ||
@@ -56,3 +61,3 @@ /** | ||
*/ | ||
constructor(args: ContractArgs) { | ||
constructor(args: ContractArgs, options: ContractOptions = {}) { | ||
if (!args.abi) { | ||
@@ -70,2 +75,5 @@ throw new Error('Contract requires an ABI') | ||
this.client = args.client | ||
if (options.debug) { | ||
this.debug = options.debug | ||
} | ||
} | ||
@@ -89,2 +97,3 @@ | ||
client: this.client, | ||
debug: this.debug, | ||
defaultScope: scope, | ||
@@ -91,0 +100,0 @@ name, |
@@ -33,2 +33,3 @@ import {ABI, ABIDef, API, APIClient, Name, NameType, Serializer} from '@wharfkit/antelope' | ||
fieldToIndex?: FieldToIndex | ||
debug?: boolean | ||
defaultRowLimit?: number | ||
@@ -56,2 +57,3 @@ defaultScope?: NameType | ||
readonly tableABI: ABI.Table | ||
readonly debug: boolean = false | ||
@@ -87,2 +89,5 @@ private fieldToIndex?: any | ||
this.defaultScope = args.defaultScope | ||
if (args.debug) { | ||
this.debug = true | ||
} | ||
} | ||
@@ -124,2 +129,3 @@ | ||
type: this.rowType, | ||
json: this.debug, | ||
// Filtering | ||
@@ -181,3 +187,3 @@ index_position: params.index_position, | ||
key_type: params.key_type, | ||
json: false, | ||
json: this.debug, | ||
reverse: params.reverse, | ||
@@ -207,2 +213,7 @@ } | ||
// Debug mode will return a JSON result, so just return it | ||
if (this.debug) { | ||
return row | ||
} | ||
if (!this.rowType) { | ||
@@ -209,0 +220,0 @@ row = Serializer.decode({ |
@@ -18,2 +18,3 @@ import type {ABICacheInterface} from '@wharfkit/abicache' | ||
abis?: ABIDefinition[] | ||
debug?: boolean | ||
} | ||
@@ -26,2 +27,3 @@ | ||
readonly client: APIClient | ||
readonly debug: boolean = false | ||
@@ -48,2 +50,6 @@ constructor(args: ContractKitArgs, options: ContractKitOptions = defaultContractKitOptions) { | ||
} | ||
if (options.debug) { | ||
this.debug = options.debug | ||
} | ||
} | ||
@@ -60,8 +66,13 @@ | ||
const abiDef = await this.abiCache.getAbi(account) | ||
return new Contract({ | ||
abi: ABI.from(abiDef), | ||
account, | ||
client: this.client, | ||
}) | ||
return new Contract( | ||
{ | ||
abi: ABI.from(abiDef), | ||
account, | ||
client: this.client, | ||
}, | ||
{ | ||
debug: this.debug, | ||
} | ||
) | ||
} | ||
} |
@@ -62,3 +62,3 @@ import { | ||
export function wrapIndexValue(value): API.v1.TableIndexType | undefined { | ||
if (!value) { | ||
if (value === undefined || value === null) { | ||
return | ||
@@ -65,0 +65,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
110566
2003