Skip to content

Commit 1cbefd1

Browse files
authored
extending TxPaginationMeta (#63)
* extended tx pagination meta queries added Signed-off-by: Piotr Pawlowski <ppiotru@gmail.com> * semicolon removed Signed-off-by: Piotr Pawlowski <ppiotru@gmail.com> * proto donwgraded Signed-off-by: Piotr Pawlowski <ppiotru@gmail.com> * example changed, args ordering updated, Pending txs updated Signed-off-by: Piotr Pawlowski <ppiotru@gmail.com> * params description added Signed-off-by: Piotr Pawlowski <ppiotru@gmail.com> * setField fixed Signed-off-by: Piotr Pawlowski <ppiotru@gmail.com> * version fixed Signed-off-by: Piotr Pawlowski <ppiotru@gmail.com> * version fixed Signed-off-by: Piotr Pawlowski <ppiotru@gmail.com> * yarn.lock fixed Signed-off-by: Piotr Pawlowski <ppiotru@gmail.com> * fix Signed-off-by: Piotr Pawlowski <ppiotru@gmail.com>
1 parent 00bb4a9 commit 1cbefd1

File tree

7 files changed

+356
-10
lines changed

7 files changed

+356
-10
lines changed

example/chain.ts

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
import grpc from 'grpc'
44
import {
5+
QueryService_v1Client as QueryService,
56
CommandService_v1Client as CommandService
67
} from '../lib/proto/endpoint_grpc_pb'
78

89
import { TxBuilder, BatchBuilder } from '../lib/chain'
10+
import queries from '../lib/queries'
911

1012
const IROHA_ADDRESS = 'localhost:50051'
1113

@@ -17,9 +19,14 @@ const commandService = new CommandService(
1719
grpc.credentials.createInsecure()
1820
)
1921

22+
const queryService = new QueryService(
23+
IROHA_ADDRESS,
24+
grpc.credentials.createInsecure()
25+
)
26+
2027
const firstTx = new TxBuilder()
2128
.createAccount({
22-
accountName: 'user1',
29+
accountName: 'usera',
2330
domainId: 'test',
2431
publicKey: '0000000000000000000000000000000000000000000000000000000000000000'
2532
})
@@ -28,7 +35,7 @@ const firstTx = new TxBuilder()
2835

2936
const secondTx = new TxBuilder()
3037
.createAccount({
31-
accountName: 'user2',
38+
accountName: 'userb',
3239
domainId: 'test',
3340
publicKey: '0000000000000000000000000000000000000000000000000000000000000000'
3441
})
@@ -45,3 +52,26 @@ new BatchBuilder([
4552
.send(commandService)
4653
.then(res => console.log(res))
4754
.catch(err => console.error(err))
55+
56+
Promise.all([
57+
queries.getAccountTransactions({
58+
privateKey: adminPriv,
59+
creatorAccountId: 'admin@test',
60+
queryService,
61+
timeoutLimit: 5000
62+
}, {
63+
accountId: 'admin@test',
64+
pageSize: 10,
65+
firstTxHash: undefined,
66+
ordering: {
67+
field: undefined,
68+
direction: undefined
69+
},
70+
firstTxTime: undefined,
71+
lastTxTime: undefined,
72+
firstTxHeight: 1,
73+
lastTxHeight: 3
74+
})
75+
])
76+
.then(a => console.log(a))
77+
.catch(e => console.error(e))

example/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ Promise.all([
100100
accountId: 'admin@test',
101101
pageSize: 5,
102102
firstTxHash: undefined,
103+
firstTxTime: undefined,
104+
lastTxTime: undefined,
105+
firstTxHeight: undefined,
106+
lastTxHeight: undefined,
103107
ordering: {
104108
field: undefined,
105109
direction: undefined

example/tls.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ queries.getAccountTransactions({
6161
accountId: 'admin@test',
6262
firstTxHash: null,
6363
pageSize: 100,
64+
firstTxTime: null,
65+
lastTxTime: null,
66+
firstTxHeight: null,
67+
lastTxHeight: null,
6468
ordering: {
6569
field: 0,
6670
direction: 1

src/proto/queries_pb.d.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import * as jspb from "google-protobuf";
55
import * as primitive_pb from "./primitive_pb";
6+
import * as google_protobuf_timestamp_pb from "google-protobuf/google/protobuf/timestamp_pb";
67

78
export class Ordering extends jspb.Message {
89
clearSequenceList(): void;
@@ -64,7 +65,31 @@ export class TxPaginationMeta extends jspb.Message {
6465
getOrdering(): Ordering | undefined;
6566
setOrdering(value?: Ordering): void;
6667

68+
hasFirstTxTime(): boolean;
69+
clearFirstTxTime(): void;
70+
getFirstTxTime(): google_protobuf_timestamp_pb.Timestamp | undefined;
71+
setFirstTxTime(value?: google_protobuf_timestamp_pb.Timestamp): void;
72+
73+
hasLastTxTime(): boolean;
74+
clearLastTxTime(): void;
75+
getLastTxTime(): google_protobuf_timestamp_pb.Timestamp | undefined;
76+
setLastTxTime(value?: google_protobuf_timestamp_pb.Timestamp): void;
77+
78+
hasFirstTxHeight(): boolean;
79+
clearFirstTxHeight(): void;
80+
getFirstTxHeight(): number;
81+
setFirstTxHeight(value: number): void;
82+
83+
hasLastTxHeight(): boolean;
84+
clearLastTxHeight(): void;
85+
getLastTxHeight(): number;
86+
setLastTxHeight(value: number): void;
87+
6788
getOptFirstTxHashCase(): TxPaginationMeta.OptFirstTxHashCase;
89+
getOptFirstTxTimeCase(): TxPaginationMeta.OptFirstTxTimeCase;
90+
getOptLastTxTimeCase(): TxPaginationMeta.OptLastTxTimeCase;
91+
getOptFirstTxHeightCase(): TxPaginationMeta.OptFirstTxHeightCase;
92+
getOptLastTxHeightCase(): TxPaginationMeta.OptLastTxHeightCase;
6893
serializeBinary(): Uint8Array;
6994
toObject(includeInstance?: boolean): TxPaginationMeta.AsObject;
7095
static toObject(includeInstance: boolean, msg: TxPaginationMeta): TxPaginationMeta.AsObject;
@@ -80,12 +105,36 @@ export namespace TxPaginationMeta {
80105
pageSize: number,
81106
firstTxHash: string,
82107
ordering?: Ordering.AsObject,
108+
firstTxTime?: google_protobuf_timestamp_pb.Timestamp.AsObject,
109+
lastTxTime?: google_protobuf_timestamp_pb.Timestamp.AsObject,
110+
firstTxHeight: number,
111+
lastTxHeight: number,
83112
}
84113

85114
export enum OptFirstTxHashCase {
86115
OPT_FIRST_TX_HASH_NOT_SET = 0,
87116
FIRST_TX_HASH = 2,
88117
}
118+
119+
export enum OptFirstTxTimeCase {
120+
OPT_FIRST_TX_TIME_NOT_SET = 0,
121+
FIRST_TX_TIME = 4,
122+
}
123+
124+
export enum OptLastTxTimeCase {
125+
OPT_LAST_TX_TIME_NOT_SET = 0,
126+
LAST_TX_TIME = 5,
127+
}
128+
129+
export enum OptFirstTxHeightCase {
130+
OPT_FIRST_TX_HEIGHT_NOT_SET = 0,
131+
FIRST_TX_HEIGHT = 6,
132+
}
133+
134+
export enum OptLastTxHeightCase {
135+
OPT_LAST_TX_HEIGHT_NOT_SET = 0,
136+
LAST_TX_HEIGHT = 7,
137+
}
89138
}
90139

91140
export class AssetPaginationMeta extends jspb.Message {

0 commit comments

Comments
 (0)