@wharfkit/contract
Advanced tools
Comparing version 0.4.2 to 0.4.3
@@ -80,2 +80,3 @@ import { ABI, APIClient, API, ABIDef, NameType, Name, PermissionLevelType, BytesType, ABISerializableObject, Action, Blob } from '@wharfkit/antelope'; | ||
index?: string; | ||
index_position?: string; | ||
scope?: NameType | number; | ||
@@ -82,0 +83,0 @@ key_type?: keyof API.v1.TableIndexTypes; |
@@ -237,2 +237,3 @@ 'use strict'; | ||
type: this.rowType, | ||
index_position: params.index_position, | ||
key_type: params.key_type, | ||
@@ -246,3 +247,3 @@ lower_bound: wrapIndexValue(params.from), | ||
if (!fieldToIndexMapping[params.index]) { | ||
throw new Error(`Field ${params.index} is not a valid index.`); | ||
throw new Error(`Field ${params.index} is not listed in the ABI under key_names/key_types. Try using 'index_position' instead.`); | ||
} | ||
@@ -260,3 +261,2 @@ tableRowsParams.index_position = fieldToIndexMapping[params.index].index_position; | ||
return tslib.__awaiter(this, void 0, void 0, function* () { | ||
const fieldToIndexMapping = this.getFieldToIndex(); | ||
const tableRowsParams = { | ||
@@ -272,8 +272,13 @@ table: this.name, | ||
upper_bound: wrapIndexValue(value), | ||
index_position: params.index | ||
? fieldToIndexMapping[params.index].index_position | ||
: 'primary', | ||
index_position: params.index_position, | ||
key_type: params.key_type, | ||
json: false, | ||
}; | ||
if (params.index) { | ||
const fieldToIndexMapping = this.getFieldToIndex(); | ||
if (!fieldToIndexMapping[params.index]) { | ||
throw new Error(`Field ${params.index} is not listed in the ABI under key_names/key_types. Try using 'index_position' instead.`); | ||
} | ||
tableRowsParams.index_position = fieldToIndexMapping[params.index].index_position; | ||
} | ||
const { rows } = yield this.client.v1.chain.get_table_rows(tableRowsParams); | ||
@@ -361,2 +366,3 @@ let [row] = rows; | ||
client: this.client, | ||
defaultScope: scope, | ||
name, | ||
@@ -363,0 +369,0 @@ rowType, |
@@ -212,2 +212,3 @@ import { isInstanceOf, UInt128, UInt64, Float64, Checksum256, Checksum160, Name, Serializer, ABI, Blob, PermissionLevel, Action } from '@wharfkit/antelope'; | ||
type: this.rowType, | ||
index_position: params.index_position, | ||
key_type: params.key_type, | ||
@@ -221,3 +222,3 @@ lower_bound: wrapIndexValue(params.from), | ||
if (!fieldToIndexMapping[params.index]) { | ||
throw new Error(`Field ${params.index} is not a valid index.`); | ||
throw new Error(`Field ${params.index} is not listed in the ABI under key_names/key_types. Try using 'index_position' instead.`); | ||
} | ||
@@ -234,3 +235,2 @@ tableRowsParams.index_position = fieldToIndexMapping[params.index].index_position; | ||
async get(value, params = {}) { | ||
const fieldToIndexMapping = this.getFieldToIndex(); | ||
const tableRowsParams = { | ||
@@ -246,8 +246,13 @@ table: this.name, | ||
upper_bound: wrapIndexValue(value), | ||
index_position: params.index | ||
? fieldToIndexMapping[params.index].index_position | ||
: 'primary', | ||
index_position: params.index_position, | ||
key_type: params.key_type, | ||
json: false, | ||
}; | ||
if (params.index) { | ||
const fieldToIndexMapping = this.getFieldToIndex(); | ||
if (!fieldToIndexMapping[params.index]) { | ||
throw new Error(`Field ${params.index} is not listed in the ABI under key_names/key_types. Try using 'index_position' instead.`); | ||
} | ||
tableRowsParams.index_position = fieldToIndexMapping[params.index].index_position; | ||
} | ||
const { rows } = await this.client.v1.chain.get_table_rows(tableRowsParams); | ||
@@ -335,2 +340,3 @@ let [row] = rows; | ||
client: this.client, | ||
defaultScope: scope, | ||
name, | ||
@@ -337,0 +343,0 @@ rowType, |
{ | ||
"name": "@wharfkit/contract", | ||
"description": "ContractKit for Wharf", | ||
"version": "0.4.2", | ||
"version": "0.4.3", | ||
"homepage": "https://github.com/wharfkit/contract", | ||
@@ -18,8 +18,5 @@ "license": "BSD-3-Clause", | ||
}, | ||
"bin": { | ||
"wharf-generate": "./scripts/codegen-cli.js" | ||
}, | ||
"dependencies": { | ||
"@wharfkit/abicache": "^1.1.1", | ||
"@wharfkit/antelope": "^0.7.3", | ||
"@wharfkit/antelope": "^0.8.0", | ||
"@wharfkit/signing-request": "^3.0.0", | ||
@@ -29,3 +26,3 @@ "tslib": "^2.1.0" | ||
"resolutions": { | ||
"@wharfkit/antelope": "^0.7.3" | ||
"@wharfkit/antelope": "^0.8.0" | ||
}, | ||
@@ -47,4 +44,4 @@ "devDependencies": { | ||
"@typescript-eslint/parser": "^5.20.0", | ||
"@wharfkit/mock-data": "^1.0.0", | ||
"@wharfkit/session": "^1.0.0-beta9", | ||
"@wharfkit/mock-data": "^1.0.2", | ||
"@wharfkit/session": "^1.0.0", | ||
"assert": "^2.0.0", | ||
@@ -51,0 +48,0 @@ "chai": "^4.3.4", |
@@ -12,3 +12,2 @@ # Contract Kit | ||
- Cache and optimize ABI call patterns automatically in your application. | ||
- Generate frontend code based on a smart contracts ABI. | ||
@@ -15,0 +14,0 @@ ## Installation |
@@ -84,2 +84,3 @@ import { | ||
client: this.client, | ||
defaultScope: scope, | ||
name, | ||
@@ -86,0 +87,0 @@ rowType, |
@@ -9,2 +9,3 @@ import {ABI, ABIDef, API, APIClient, Name, NameType, Serializer} from '@wharfkit/antelope' | ||
index?: string | ||
index_position?: string | ||
scope?: NameType | number | ||
@@ -124,2 +125,3 @@ key_type?: keyof API.v1.TableIndexTypes | ||
// Filtering | ||
index_position: params.index_position, | ||
key_type: params.key_type, | ||
@@ -135,3 +137,7 @@ lower_bound: wrapIndexValue(params.from), | ||
if (!fieldToIndexMapping[params.index]) { | ||
throw new Error(`Field ${params.index} is not a valid index.`) | ||
// Nearly all contract ABIs are missing data to appropriately map this data. | ||
// See: https://github.com/AntelopeIO/cdt/issues/197 | ||
throw new Error( | ||
`Field ${params.index} is not listed in the ABI under key_names/key_types. Try using 'index_position' instead.` | ||
) | ||
} | ||
@@ -158,5 +164,3 @@ | ||
async get(value?: API.v1.TableIndexType | string, params: QueryParams = {}): Promise<RowType> { | ||
const fieldToIndexMapping = this.getFieldToIndex() | ||
const tableRowsParams = { | ||
const tableRowsParams: any = { | ||
table: this.name, | ||
@@ -172,5 +176,3 @@ code: this.account, | ||
upper_bound: wrapIndexValue(value), | ||
index_position: params.index | ||
? fieldToIndexMapping[params.index].index_position | ||
: 'primary', | ||
index_position: params.index_position, | ||
key_type: params.key_type, | ||
@@ -180,2 +182,16 @@ json: false, | ||
if (params.index) { | ||
const fieldToIndexMapping = this.getFieldToIndex() | ||
if (!fieldToIndexMapping[params.index]) { | ||
// Nearly all contract ABIs are missing data to appropriately map this data. | ||
// See: https://github.com/AntelopeIO/cdt/issues/197 | ||
throw new Error( | ||
`Field ${params.index} is not listed in the ABI under key_names/key_types. Try using 'index_position' instead.` | ||
) | ||
} | ||
tableRowsParams.index_position = fieldToIndexMapping[params.index].index_position | ||
} | ||
const {rows} = await this.client!.v1.chain.get_table_rows(tableRowsParams) | ||
@@ -182,0 +198,0 @@ let [row] = rows |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
2
101426
19
1832
32
+ Added@wharfkit/antelope@0.8.0(transitive)
- Removed@wharfkit/antelope@0.7.3(transitive)
Updated@wharfkit/antelope@^0.8.0