/// <summary> /// Query for blockchain smart contract table state information /// </summary> /// <typeparam name="TRowType">Type used for each row</typeparam> /// <param name="request.Json">Request rows using json or raw format</param> /// <param name="request.Code">accountName of the contract to search for table rows</param> /// <param name="request.Scope">scope text segmenting the table set</param> /// <param name="request.Table">table name</param> /// <param name="request.TableKey">unused so far?</param> /// <param name="request.LowerBound">lower bound for the selected index value</param> /// <param name="request.UpperBound">upper bound for the selected index value</param> /// <param name="request.KeyType">Type of the index choosen, ex: i64</param> /// <param name="request.IndexPosition">1 - primary(first), 2 - secondary index(in order defined by multi_index), 3 - third index, etc</param> /// <returns>Rows and if is there More rows to be fetched</returns> public async Task <GetTableRowsResponse <TRowType> > GetTableRows <TRowType>(GetTableRowsRequest request) { if (request.json) { return(await Api.GetTableRows <TRowType>(request)); } else { var apiResult = await Api.GetTableRows(request); var result = new GetTableRowsResponse <TRowType>() { more = apiResult.more }; var unpackedRows = new List <TRowType>(); var abi = await AbiSerializer.GetAbi(request.code); var table = abi.tables.First(t => t.name == request.table); foreach (var rowData in apiResult.rows) { unpackedRows.Add(AbiSerializer.DeserializeStructData <TRowType>(table.type, (string)rowData, abi)); } result.rows = unpackedRows; return(result); } }
/// <summary> /// Query for blockchain smart contract table state information /// </summary> /// <param name="request.Json">Request rows using json or raw format</param> /// <param name="request.Code">accountName of the contract to search for table rows</param> /// <param name="request.Scope">scope text segmenting the table set</param> /// <param name="request.Table">table name</param> /// <param name="request.TableKey">unused so far?</param> /// <param name="request.LowerBound">lower bound for the selected index value</param> /// <param name="request.UpperBound">upper bound for the selected index value</param> /// <param name="request.KeyType">Type of the index choosen, ex: i64</param> /// <param name="request.IndexPosition">1 - primary(first), 2 - secondary index(in order defined by multi_index), 3 - third index, etc</param> /// <returns>Rows and if is there More rows to be fetched</returns> public async Task <GetTableRowsResponse> GetTableRows(GetTableRowsRequest request) { var result = await Api.GetTableRows(request); if (!request.json) { var unpackedRows = new List <object>(); var abi = await AbiSerializer.GetAbi(request.code); var table = abi.tables.First(t => t.name == request.table); foreach (var rowData in result.rows) { unpackedRows.Add(AbiSerializer.DeserializeStructData(table.type, (string)rowData, abi)); } result.rows = unpackedRows; } return(result); }
public Task <GetTableRowsResponse> GetTableRows(GetTableRowsRequest request) { return(Api.GetTableRows(request)); }