datai-sdk 1.0.6 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API/v1/activePositions/ActivePositionsResult.ts +221 -3
- package/API/v1/activePositions/NftItem.ts +63 -0
- package/API/v1/activePositions/PerpPosition.ts +129 -0
- package/API/v1/activePositions/TokenBalance.ts +32 -1
- package/API/v1/activePositions/activePositions.ts +8 -1
- package/API/v1/index.ts +6 -0
- package/API/v1/proto/activePositions/activePositions/ActivePositionsResultPb.ts +159 -0
- package/API/v1/proto/activePositions/activePositions/NftItemPb.ts +71 -0
- package/API/v1/proto/activePositions/activePositions/PerpPositionPb.ts +142 -0
- package/API/v1/proto/activePositions/activePositions/PerpSide.ts +10 -0
- package/API/v1/proto/activePositions/activePositions/TokenBalancePb.ts +71 -0
- package/API/v1/proto/activePositions/google/protobuf/Timestamp.ts +48 -0
- package/API/v1/proto/watcher/WatcherInputPb.ts +121 -0
- package/API/v1/watcher/WatcherInput.ts +100 -2
- package/API/v1/watcher/watcher.ts +154 -4
- package/package.json +5 -2
- package/@graphprotocol/graph-ts/README.md +0 -13
- package/@graphprotocol/graph-ts/chain/arweave.ts +0 -82
- package/@graphprotocol/graph-ts/chain/cosmos.ts +0 -426
- package/@graphprotocol/graph-ts/chain/ethereum.ts +0 -727
- package/@graphprotocol/graph-ts/chain/near.ts +0 -420
- package/@graphprotocol/graph-ts/chain/starknet.ts +0 -39
- package/@graphprotocol/graph-ts/common/collections.ts +0 -495
- package/@graphprotocol/graph-ts/common/conversion.ts +0 -3
- package/@graphprotocol/graph-ts/common/datasource.ts +0 -41
- package/@graphprotocol/graph-ts/common/eager_offset.ts +0 -42
- package/@graphprotocol/graph-ts/common/json.ts +0 -28
- package/@graphprotocol/graph-ts/common/numbers.ts +0 -407
- package/@graphprotocol/graph-ts/common/value.ts +0 -585
- package/@graphprotocol/graph-ts/global/global.ts +0 -4
- package/@graphprotocol/graph-ts/helper-functions.ts +0 -79
- package/@graphprotocol/graph-ts/index.ts +0 -156
- package/@graphprotocol/graph-ts/package.json +0 -3
- package/@graphprotocol/graph-ts/tsconfig.json +0 -4
- package/@graphprotocol/graph-ts/types/tsconfig.base.json +0 -3
|
@@ -1,20 +1,170 @@
|
|
|
1
1
|
import { Protobuf } from 'as-proto/assembly'
|
|
2
2
|
import { WatcherResultPb } from '../proto/watcher/WatcherResultPb'
|
|
3
|
+
import { WatcherInputPb } from '../proto/watcher/WatcherInputPb'
|
|
3
4
|
import { Any } from '../proto/google/protobuf/Any'
|
|
4
5
|
import { Host } from '@extism/as-pdk'
|
|
5
6
|
import { WatcherInput } from './WatcherInput'
|
|
6
|
-
import {
|
|
7
|
-
import { EntityPb } from '../store/EntityPb'
|
|
7
|
+
import { Bytes } from '@graphprotocol/graph-ts'
|
|
8
8
|
|
|
9
|
+
// Cached input to avoid re-decoding on multiple calls
|
|
10
|
+
let _cachedInput: WatcherInput | null = null
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Watcher namespace providing input/output functions for watcher implementations.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import { watcher, activePositions, ActivePositionsResult } from 'datai-sdk'
|
|
18
|
+
*
|
|
19
|
+
* export function GetActivePositions(): void {
|
|
20
|
+
* const input = watcher.input()
|
|
21
|
+
* const position = activePositions.inputPosition<MyPosition>()
|
|
22
|
+
*
|
|
23
|
+
* // Check for external data
|
|
24
|
+
* if (watcher.hasExternalData('my_key')) {
|
|
25
|
+
* const data = watcher.getExternalData('my_key')!
|
|
26
|
+
* // Use the data...
|
|
27
|
+
* }
|
|
28
|
+
*
|
|
29
|
+
* const output = new ActivePositionsResult()
|
|
30
|
+
* // ... build output
|
|
31
|
+
* activePositions.output(output)
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
9
35
|
export namespace watcher {
|
|
36
|
+
/** Default update schedule */
|
|
10
37
|
export const SCHEDULE_DEFAULT = 'DEFAULT'
|
|
38
|
+
|
|
39
|
+
/** Low priority update schedule (less frequent updates) */
|
|
11
40
|
export const SCHEDULE_LOW_PRIORITY = 'LOW_PRIORITY'
|
|
12
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Get the watcher input (position + external data).
|
|
44
|
+
* Result is cached for the duration of the watcher call.
|
|
45
|
+
*
|
|
46
|
+
* NOTE: This function expects WatcherInputPb format.
|
|
47
|
+
* Watchers built with this SDK version MUST be configured in the host
|
|
48
|
+
* to receive the extended format.
|
|
49
|
+
*
|
|
50
|
+
* @returns WatcherInput containing position and optional external data
|
|
51
|
+
*/
|
|
13
52
|
export function input(): WatcherInput {
|
|
14
|
-
|
|
15
|
-
|
|
53
|
+
if (_cachedInput !== null) {
|
|
54
|
+
return _cachedInput!
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const rawInput = Host.input()
|
|
58
|
+
|
|
59
|
+
// Decode as WatcherInputPb (new format with external data support)
|
|
60
|
+
const inputPb = Protobuf.decode<WatcherInputPb>(rawInput, WatcherInputPb.decode)
|
|
61
|
+
|
|
62
|
+
// Convert external data map from Uint8Array to Bytes
|
|
63
|
+
const externalData = new Map<string, Bytes>()
|
|
64
|
+
const keys = inputPb.externalData.keys()
|
|
65
|
+
for (let i = 0; i < keys.length; i++) {
|
|
66
|
+
const key = keys[i]
|
|
67
|
+
const value = inputPb.externalData.get(key)
|
|
68
|
+
externalData.set(key, changetype<Bytes>(value))
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Create WatcherInput with position and external data
|
|
72
|
+
_cachedInput = new WatcherInput(inputPb.position!, externalData)
|
|
73
|
+
return _cachedInput!
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Helper: Get external data by key.
|
|
78
|
+
* Convenience method that calls input().getExternalData(key).
|
|
79
|
+
*
|
|
80
|
+
* @param key - The external data key to retrieve
|
|
81
|
+
* @returns The data as Bytes if present, null otherwise
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* const amount = watcher.getExternalData('merkl_amount:0xUser:0xToken')
|
|
86
|
+
* if (amount !== null) {
|
|
87
|
+
* // Process amount...
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
export function getExternalData(key: string): Bytes | null {
|
|
92
|
+
return input().getExternalData(key)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Helper: Check if external data exists for a key.
|
|
97
|
+
* Convenience method that calls input().hasExternalData(key).
|
|
98
|
+
*
|
|
99
|
+
* @param key - The external data key to check
|
|
100
|
+
* @returns true if data exists for the key, false otherwise
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```typescript
|
|
104
|
+
* if (watcher.hasExternalData('merkl_proof:0xUser:0xToken')) {
|
|
105
|
+
* const proof = watcher.getExternalData('merkl_proof:0xUser:0xToken')!
|
|
106
|
+
* // Use proof...
|
|
107
|
+
* }
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
export function hasExternalData(key: string): bool {
|
|
111
|
+
return input().hasExternalData(key)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Helper: Get all external data keys.
|
|
116
|
+
* Convenience method that calls input().getExternalDataKeys().
|
|
117
|
+
*
|
|
118
|
+
* @returns Array of all external data keys
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```typescript
|
|
122
|
+
* const keys = watcher.getExternalDataKeys()
|
|
123
|
+
* for (let i = 0; i < keys.length; i++) {
|
|
124
|
+
* const data = watcher.getExternalData(keys[i])
|
|
125
|
+
* // Process data...
|
|
126
|
+
* }
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
export function getExternalDataKeys(): string[] {
|
|
130
|
+
return input().getExternalDataKeys()
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Helper: Check if any external data was provided.
|
|
135
|
+
* Convenience method that calls input().hasAnyExternalData().
|
|
136
|
+
*
|
|
137
|
+
* @returns true if at least one external data entry exists
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```typescript
|
|
141
|
+
* if (watcher.hasAnyExternalData()) {
|
|
142
|
+
* // External data is available, process it
|
|
143
|
+
* const keys = watcher.getExternalDataKeys()
|
|
144
|
+
* // ...
|
|
145
|
+
* }
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
export function hasAnyExternalData(): bool {
|
|
149
|
+
return input().hasAnyExternalData()
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Reset cached input.
|
|
154
|
+
* Called automatically by the host between watcher invocations.
|
|
155
|
+
* Watchers should not need to call this directly.
|
|
156
|
+
*/
|
|
157
|
+
export function resetInput(): void {
|
|
158
|
+
_cachedInput = null
|
|
16
159
|
}
|
|
17
160
|
|
|
161
|
+
/**
|
|
162
|
+
* Output the watcher result to the host.
|
|
163
|
+
*
|
|
164
|
+
* @param resultTypeUrl - The protobuf type URL for the result
|
|
165
|
+
* @param resultBytes - The serialized result bytes
|
|
166
|
+
* @param updateTrigger - The update trigger/schedule for next update
|
|
167
|
+
*/
|
|
18
168
|
export function output(
|
|
19
169
|
resultTypeUrl: string,
|
|
20
170
|
resultBytes: Uint8Array,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "datai-sdk",
|
|
3
3
|
"main": "index.ts",
|
|
4
|
-
"version": "1.0
|
|
4
|
+
"version": "1.1.0",
|
|
5
5
|
"description": "Datai SDK which has useful libraries to help building projections",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"postinstall": "node postinstall-script.js"
|
|
@@ -9,5 +9,8 @@
|
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@extism/as-pdk": "^1.0.0",
|
|
11
11
|
"as-proto": "^1.3.0"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"as-proto-gen": "^1.3.0"
|
|
12
15
|
}
|
|
13
|
-
}
|
|
16
|
+
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
# The Graph TypeScript Library (graph-ts) adapted to Extism PDK
|
|
2
|
-
|
|
3
|
-
## License
|
|
4
|
-
|
|
5
|
-
Copyright © 2018 Graph Protocol, Inc. and contributors.
|
|
6
|
-
|
|
7
|
-
The Graph TypeScript library is dual-licensed under the [MIT license](LICENSE-MIT) and the
|
|
8
|
-
[Apache License, Version 2.0](LICENSE-APACHE).
|
|
9
|
-
|
|
10
|
-
Unless required by applicable law or agreed to in writing, software distributed under the License is
|
|
11
|
-
distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
12
|
-
implied. See the License for the specific language governing permissions and limitations under the
|
|
13
|
-
License.
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import '../common/eager_offset';
|
|
2
|
-
import { Bytes } from '../common/collections';
|
|
3
|
-
|
|
4
|
-
// Most types from this namespace are direct mappings or adaptations from:
|
|
5
|
-
// https://github.com/ChainSafe/firehose-arweave/blob/master/proto/sf/arweave/type/v1/type.proto
|
|
6
|
-
export namespace arweave {
|
|
7
|
-
/**
|
|
8
|
-
* A key-value pair for arbitrary metadata
|
|
9
|
-
*/
|
|
10
|
-
export class Tag {
|
|
11
|
-
constructor(
|
|
12
|
-
public name: Bytes,
|
|
13
|
-
public value: Bytes,
|
|
14
|
-
) {}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export class ProofOfAccess {
|
|
18
|
-
constructor(
|
|
19
|
-
public option: string,
|
|
20
|
-
public txPath: Bytes,
|
|
21
|
-
public dataPath: Bytes,
|
|
22
|
-
public chunk: Bytes,
|
|
23
|
-
) {}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* An Arweave block.
|
|
28
|
-
*/
|
|
29
|
-
export class Block {
|
|
30
|
-
constructor(
|
|
31
|
-
public timestamp: u64,
|
|
32
|
-
public lastRetarget: u64,
|
|
33
|
-
public height: u64,
|
|
34
|
-
public indepHash: Bytes,
|
|
35
|
-
public nonce: Bytes,
|
|
36
|
-
public previousBlock: Bytes,
|
|
37
|
-
public diff: Bytes,
|
|
38
|
-
public hash: Bytes,
|
|
39
|
-
public txRoot: Bytes,
|
|
40
|
-
public txs: Bytes[],
|
|
41
|
-
public walletList: Bytes,
|
|
42
|
-
public rewardAddr: Bytes,
|
|
43
|
-
public tags: Tag[],
|
|
44
|
-
public rewardPool: Bytes,
|
|
45
|
-
public weaveSize: Bytes,
|
|
46
|
-
public blockSize: Bytes,
|
|
47
|
-
public cumulativeDiff: Bytes,
|
|
48
|
-
public hashListMerkle: Bytes,
|
|
49
|
-
public poa: ProofOfAccess,
|
|
50
|
-
) {}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* An Arweave transaction
|
|
55
|
-
*/
|
|
56
|
-
export class Transaction {
|
|
57
|
-
constructor(
|
|
58
|
-
public format: u32,
|
|
59
|
-
public id: Bytes,
|
|
60
|
-
public lastTx: Bytes,
|
|
61
|
-
public owner: Bytes,
|
|
62
|
-
public tags: Tag[],
|
|
63
|
-
public target: Bytes,
|
|
64
|
-
public quantity: Bytes,
|
|
65
|
-
public data: Bytes,
|
|
66
|
-
public dataSize: Bytes,
|
|
67
|
-
public dataRoot: Bytes,
|
|
68
|
-
public signature: Bytes,
|
|
69
|
-
public reward: Bytes,
|
|
70
|
-
) {}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* An Arweave transaction with block ptr
|
|
75
|
-
*/
|
|
76
|
-
export class TransactionWithBlockPtr {
|
|
77
|
-
constructor(
|
|
78
|
-
public tx: Transaction,
|
|
79
|
-
public block: Block,
|
|
80
|
-
) {}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
@@ -1,426 +0,0 @@
|
|
|
1
|
-
import '../common/eager_offset';
|
|
2
|
-
import { Bytes } from '../common/collections';
|
|
3
|
-
|
|
4
|
-
export namespace cosmos {
|
|
5
|
-
export class Block {
|
|
6
|
-
constructor(
|
|
7
|
-
public header: Header,
|
|
8
|
-
public evidence: EvidenceList,
|
|
9
|
-
public lastCommit: Commit,
|
|
10
|
-
public resultBeginBlock: ResponseBeginBlock,
|
|
11
|
-
public resultEndBlock: ResponseEndBlock,
|
|
12
|
-
public transactions: Array<TxResult>,
|
|
13
|
-
public validatorUpdates: Array<Validator>,
|
|
14
|
-
) {}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export class HeaderOnlyBlock {
|
|
18
|
-
constructor(public header: Header) {}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export class EventData {
|
|
22
|
-
constructor(
|
|
23
|
-
public event: Event,
|
|
24
|
-
public block: HeaderOnlyBlock,
|
|
25
|
-
public tx: TransactionContext,
|
|
26
|
-
) {}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export class TransactionData {
|
|
30
|
-
constructor(
|
|
31
|
-
public tx: TxResult,
|
|
32
|
-
public block: HeaderOnlyBlock,
|
|
33
|
-
) {}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export class MessageData {
|
|
37
|
-
constructor(
|
|
38
|
-
public message: Any,
|
|
39
|
-
public block: HeaderOnlyBlock,
|
|
40
|
-
public tx: TransactionContext,
|
|
41
|
-
) {}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export class TransactionContext {
|
|
45
|
-
constructor(
|
|
46
|
-
public hash: Bytes,
|
|
47
|
-
public index: u32,
|
|
48
|
-
public code: u32,
|
|
49
|
-
public gasWanted: i64,
|
|
50
|
-
public gasUsed: i64,
|
|
51
|
-
) {}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export class Header {
|
|
55
|
-
constructor(
|
|
56
|
-
public version: Consensus,
|
|
57
|
-
public chainId: string,
|
|
58
|
-
public height: u64,
|
|
59
|
-
public time: Timestamp,
|
|
60
|
-
public lastBlockId: BlockID,
|
|
61
|
-
public lastCommitHash: Bytes,
|
|
62
|
-
public dataHash: Bytes,
|
|
63
|
-
public validatorsHash: Bytes,
|
|
64
|
-
public nextValidatorsHash: Bytes,
|
|
65
|
-
public consensusHash: Bytes,
|
|
66
|
-
public appHash: Bytes,
|
|
67
|
-
public lastResultsHash: Bytes,
|
|
68
|
-
public evidenceHash: Bytes,
|
|
69
|
-
public proposerAddress: Bytes,
|
|
70
|
-
public hash: Bytes,
|
|
71
|
-
) {}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export class Consensus {
|
|
75
|
-
constructor(
|
|
76
|
-
public block: u64,
|
|
77
|
-
public app: u64,
|
|
78
|
-
) {}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export class Timestamp {
|
|
82
|
-
constructor(
|
|
83
|
-
public seconds: i64,
|
|
84
|
-
public nanos: i32,
|
|
85
|
-
) {}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export class BlockID {
|
|
89
|
-
constructor(
|
|
90
|
-
public hash: Bytes,
|
|
91
|
-
public partSetHeader: PartSetHeader,
|
|
92
|
-
) {}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export class PartSetHeader {
|
|
96
|
-
constructor(
|
|
97
|
-
public total: u32,
|
|
98
|
-
public hash: Bytes,
|
|
99
|
-
) {}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export class EvidenceList {
|
|
103
|
-
constructor(public evidence: Array<Evidence>) {}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export class Evidence {
|
|
107
|
-
constructor(
|
|
108
|
-
public duplicateVoteEvidence: DuplicateVoteEvidence,
|
|
109
|
-
public lightClientAttackEvidence: LightClientAttackEvidence,
|
|
110
|
-
) {}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export class DuplicateVoteEvidence {
|
|
114
|
-
constructor(
|
|
115
|
-
public voteA: EventVote,
|
|
116
|
-
public voteB: EventVote,
|
|
117
|
-
public totalVotingPower: i64,
|
|
118
|
-
public validatorPower: i64,
|
|
119
|
-
public timestamp: Timestamp,
|
|
120
|
-
) {}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export class EventVote {
|
|
124
|
-
constructor(
|
|
125
|
-
public eventVoteType: SignedMsgType,
|
|
126
|
-
public height: u64,
|
|
127
|
-
public round: i32,
|
|
128
|
-
public blockId: BlockID,
|
|
129
|
-
public timestamp: Timestamp,
|
|
130
|
-
public validatorAddress: Bytes,
|
|
131
|
-
public validatorIndex: i32,
|
|
132
|
-
public signature: Bytes,
|
|
133
|
-
) {}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export enum SignedMsgType {
|
|
137
|
-
SIGNED_MSG_TYPE_UNKNOWN = 0,
|
|
138
|
-
SIGNED_MSG_TYPE_PREVOTE = 1,
|
|
139
|
-
SIGNED_MSG_TYPE_PRECOMMIT = 2,
|
|
140
|
-
SIGNED_MSG_TYPE_PROPOSAL = 32,
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
export class LightClientAttackEvidence {
|
|
144
|
-
constructor(
|
|
145
|
-
public conflictingBlock: LightBlock,
|
|
146
|
-
public commonHeight: i64,
|
|
147
|
-
public byzantineValidators: Array<Validator>,
|
|
148
|
-
public totalVotingPower: i64,
|
|
149
|
-
public timestamp: Timestamp,
|
|
150
|
-
) {}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export class LightBlock {
|
|
154
|
-
constructor(
|
|
155
|
-
public signedHeader: SignedHeader,
|
|
156
|
-
public validatorSet: ValidatorSet,
|
|
157
|
-
) {}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
export class SignedHeader {
|
|
161
|
-
constructor(
|
|
162
|
-
public header: Header,
|
|
163
|
-
public commit: Commit,
|
|
164
|
-
) {}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
export class Commit {
|
|
168
|
-
constructor(
|
|
169
|
-
public height: i64,
|
|
170
|
-
public round: i32,
|
|
171
|
-
public blockId: BlockID,
|
|
172
|
-
public signatures: Array<CommitSig>,
|
|
173
|
-
) {}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
export class CommitSig {
|
|
177
|
-
constructor(
|
|
178
|
-
public blockIdFlag: BlockIDFlag,
|
|
179
|
-
public validatorAddress: Bytes,
|
|
180
|
-
public timestamp: Timestamp,
|
|
181
|
-
public signature: Bytes,
|
|
182
|
-
) {}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
export enum BlockIDFlag {
|
|
186
|
-
BLOCK_ID_FLAG_UNKNOWN = 0,
|
|
187
|
-
BLOCK_ID_FLAG_ABSENT = 1,
|
|
188
|
-
BLOCK_ID_FLAG_COMMIT = 2,
|
|
189
|
-
BLOCK_ID_FLAG_NIL = 3,
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
export class ValidatorSet {
|
|
193
|
-
constructor(
|
|
194
|
-
public validators: Array<Validator>,
|
|
195
|
-
public proposer: Validator,
|
|
196
|
-
public totalVotingPower: i64,
|
|
197
|
-
) {}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
export class Validator {
|
|
201
|
-
constructor(
|
|
202
|
-
public address: Bytes,
|
|
203
|
-
public pubKey: PublicKey,
|
|
204
|
-
public votingPower: i64,
|
|
205
|
-
public proposerPriority: i64,
|
|
206
|
-
) {}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
export class PublicKey {
|
|
210
|
-
constructor(
|
|
211
|
-
public ed25519: Bytes,
|
|
212
|
-
public secp256k1: Bytes,
|
|
213
|
-
) {}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
export class ResponseBeginBlock {
|
|
217
|
-
constructor(public events: Array<Event>) {}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
export class Event {
|
|
221
|
-
constructor(
|
|
222
|
-
public eventType: string,
|
|
223
|
-
public attributes: Array<EventAttribute>,
|
|
224
|
-
) {}
|
|
225
|
-
|
|
226
|
-
getAttribute(key: string): EventAttribute | null {
|
|
227
|
-
for (let i = 0; i < this.attributes.length; i++) {
|
|
228
|
-
if (this.attributes[i].key == key) {
|
|
229
|
-
return this.attributes[i];
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
return null;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
getAttributeValue(key: string): string {
|
|
236
|
-
const attribute = this.getAttribute(key);
|
|
237
|
-
return attribute ? attribute.value : '';
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
export class EventAttribute {
|
|
242
|
-
constructor(
|
|
243
|
-
public key: string,
|
|
244
|
-
public value: string,
|
|
245
|
-
public index: bool,
|
|
246
|
-
) {}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
export class ResponseEndBlock {
|
|
250
|
-
constructor(
|
|
251
|
-
public validatorUpdates: Array<ValidatorUpdate>,
|
|
252
|
-
public consensusParamUpdates: ConsensusParams,
|
|
253
|
-
public events: Array<Event>,
|
|
254
|
-
) {}
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
export class ValidatorUpdate {
|
|
258
|
-
constructor(
|
|
259
|
-
public address: Bytes,
|
|
260
|
-
public pubKey: PublicKey,
|
|
261
|
-
public power: i64,
|
|
262
|
-
) {}
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
export class ConsensusParams {
|
|
266
|
-
constructor(
|
|
267
|
-
public block: BlockParams,
|
|
268
|
-
public evidence: EvidenceParams,
|
|
269
|
-
public validator: ValidatorParams,
|
|
270
|
-
public version: VersionParams,
|
|
271
|
-
) {}
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
export class BlockParams {
|
|
275
|
-
constructor(
|
|
276
|
-
public maxBytes: i64,
|
|
277
|
-
public maxGas: i64,
|
|
278
|
-
) {}
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
export class EvidenceParams {
|
|
282
|
-
constructor(
|
|
283
|
-
public maxAgeNumBlocks: i64,
|
|
284
|
-
public maxAgeDuration: Duration,
|
|
285
|
-
public maxBytes: i64,
|
|
286
|
-
) {}
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
export class Duration {
|
|
290
|
-
constructor(
|
|
291
|
-
public seconds: i64,
|
|
292
|
-
public nanos: i32,
|
|
293
|
-
) {}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
export class ValidatorParams {
|
|
297
|
-
constructor(public pubKeyTypes: Array<string>) {}
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
export class VersionParams {
|
|
301
|
-
constructor(public appVersion: u64) {}
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
export class TxResult {
|
|
305
|
-
constructor(
|
|
306
|
-
public height: u64,
|
|
307
|
-
public index: u32,
|
|
308
|
-
public tx: Tx,
|
|
309
|
-
public result: ResponseDeliverTx,
|
|
310
|
-
public hash: Bytes,
|
|
311
|
-
) {}
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
export class Tx {
|
|
315
|
-
constructor(
|
|
316
|
-
public body: TxBody,
|
|
317
|
-
public authInfo: AuthInfo,
|
|
318
|
-
public signatures: Array<Bytes>,
|
|
319
|
-
) {}
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
export class TxBody {
|
|
323
|
-
constructor(
|
|
324
|
-
public messages: Array<Any>,
|
|
325
|
-
public memo: string,
|
|
326
|
-
public timeoutHeight: u64,
|
|
327
|
-
public extensionOptions: Array<Any>,
|
|
328
|
-
public nonCriticalExtensionOptions: Array<Any>,
|
|
329
|
-
) {}
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
export class Any {
|
|
333
|
-
constructor(
|
|
334
|
-
public typeUrl: string,
|
|
335
|
-
public value: Bytes,
|
|
336
|
-
) {}
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
export class AuthInfo {
|
|
340
|
-
constructor(
|
|
341
|
-
public signerInfos: Array<SignerInfo>,
|
|
342
|
-
public fee: Fee,
|
|
343
|
-
public tip: Tip,
|
|
344
|
-
) {}
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
export class SignerInfo {
|
|
348
|
-
constructor(
|
|
349
|
-
public publicKey: Any,
|
|
350
|
-
public modeInfo: ModeInfo,
|
|
351
|
-
public sequence: u64,
|
|
352
|
-
) {}
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
export class ModeInfo {
|
|
356
|
-
constructor(
|
|
357
|
-
public single: ModeInfoSingle,
|
|
358
|
-
public multi: ModeInfoMulti,
|
|
359
|
-
) {}
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
export class ModeInfoSingle {
|
|
363
|
-
constructor(public mode: SignMode) {}
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
export enum SignMode {
|
|
367
|
-
SIGN_MODE_UNSPECIFIED = 0,
|
|
368
|
-
SIGN_MODE_DIRECT = 1,
|
|
369
|
-
SIGN_MODE_TEXTUAL = 2,
|
|
370
|
-
SIGN_MODE_LEGACY_AMINO_JSON = 127,
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
export class ModeInfoMulti {
|
|
374
|
-
constructor(
|
|
375
|
-
public bitarray: CompactBitArray,
|
|
376
|
-
public modeInfos: Array<ModeInfo>,
|
|
377
|
-
) {}
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
export class CompactBitArray {
|
|
381
|
-
constructor(
|
|
382
|
-
public extraBitsStored: u32,
|
|
383
|
-
public elems: Bytes,
|
|
384
|
-
) {}
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
export class Fee {
|
|
388
|
-
constructor(
|
|
389
|
-
public amount: Array<Coin>,
|
|
390
|
-
public gasLimit: u64,
|
|
391
|
-
public payer: string,
|
|
392
|
-
public granter: string,
|
|
393
|
-
) {}
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
export class Coin {
|
|
397
|
-
constructor(
|
|
398
|
-
public denom: string,
|
|
399
|
-
public amount: string,
|
|
400
|
-
) {}
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
export class Tip {
|
|
404
|
-
constructor(
|
|
405
|
-
public amount: Array<Coin>,
|
|
406
|
-
public tipper: string,
|
|
407
|
-
) {}
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
export class ResponseDeliverTx {
|
|
411
|
-
constructor(
|
|
412
|
-
public code: u32,
|
|
413
|
-
public data: Bytes,
|
|
414
|
-
public log: string,
|
|
415
|
-
public info: string,
|
|
416
|
-
public gasWanted: i64,
|
|
417
|
-
public gasUsed: i64,
|
|
418
|
-
public events: Array<Event>,
|
|
419
|
-
public codespace: string,
|
|
420
|
-
) {}
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
export class ValidatorSetUpdates {
|
|
424
|
-
constructor(public validatorUpdates: Array<Validator>) {}
|
|
425
|
-
}
|
|
426
|
-
}
|