@graphprotocol/graph-cli 0.23.0 → 0.23.1
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/README.md +83 -0
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/.travis.yml +4 -0
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/chain/ethereum.ts +10 -16
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/chain/near.ts +402 -0
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/common/collections.ts +125 -4
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/common/eager_offset.ts +2 -1
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/common/json.ts +14 -0
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/common/numbers.ts +58 -16
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/common/value.ts +2 -5
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/global/global.ts +108 -0
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/helper-functions.ts +5 -5
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/index.ts +6 -15
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/package.json +5 -2
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/test/bigInt.ts +138 -108
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/test/bytes.ts +31 -20
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/test/test.js +120 -88
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/tsconfig.json +2 -2
- package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/types/tsconfig.base.json +3 -0
- package/examples/basic-event-handlers/package.json +1 -1
- package/examples/basic-event-handlers/yarn.lock +4 -4
- package/examples/example-subgraph/package.json +1 -1
- package/examples/example-subgraph/yarn.lock +4 -4
- package/jest.config.js +2 -2
- package/package.json +2 -6
- package/src/commands/init.js +30 -3
- package/src/commands/test.js +1 -1
- package/src/scaffold.js +18 -2
- package/tests/cli/globalSetup.js +6 -0
- package/tests/cli/globalTeardown.js +6 -0
- package/tests/cli/init.test.js +1 -1
- package/tests/cli/util.js +17 -8
- package/tests/cli/init/from-contract/abis/Contract.json +0 -69
- package/tests/cli/init/from-contract/package.json +0 -16
- package/tests/cli/init/from-contract/schema.graphql +0 -6
- package/tests/cli/init/from-contract/src/mapping.ts +0 -49
- package/tests/cli/init/from-contract/subgraph.yaml +0 -26
package/README.md
CHANGED
|
@@ -53,6 +53,89 @@ The Graph CLI can be used with a local or self-hosted [Graph Node](https://githu
|
|
|
53
53
|
|
|
54
54
|
If you are ready to dive into the details of building a subgraph from scratch, there is a [detailed walkthrough](https://thegraph.com/docs/define-a-subgraph) for that as well, along with API documentation for the [AssemblyScript API](https://thegraph.com/docs/assemblyscript-api).
|
|
55
55
|
|
|
56
|
+
## Release process
|
|
57
|
+
|
|
58
|
+
The steps to create a new version of the `graph-cli` are:
|
|
59
|
+
|
|
60
|
+
1. Decide which version number you'll be rolling out. You can check the differences between the current `master` branch and the latest release.
|
|
61
|
+
2. Create a PR with the commit generated by `npm version <VERSION> [<PREID>]`.
|
|
62
|
+
3. Once that's approved and merged to `master`, you can publish it to `npm` and push the git tags as well.
|
|
63
|
+
4. Last but not least, create a Github Release refering to the pushed git tag, linking to the PRs involved.
|
|
64
|
+
|
|
65
|
+
Helpful links:
|
|
66
|
+
|
|
67
|
+
- [Semver official docs](https://semver.org/)
|
|
68
|
+
- [`npm version` docs](https://docs.npmjs.com/cli/v7/commands/npm-version)
|
|
69
|
+
- [`npm publish` docs](https://docs.npmjs.com/cli/v7/commands/npm-publish)
|
|
70
|
+
- [`npm unpublish` docs](https://docs.npmjs.com/cli/v7/commands/npm-unpublish)
|
|
71
|
+
- [`npm deprecate` docs](https://docs.npmjs.com/cli/v7/commands/npm-deprecate)
|
|
72
|
+
|
|
73
|
+
### Stable release example
|
|
74
|
+
|
|
75
|
+
Current version: `0.34.9`.
|
|
76
|
+
Desired release: `0.35.0`.
|
|
77
|
+
|
|
78
|
+
To create the PR:
|
|
79
|
+
```
|
|
80
|
+
git checkout -b <BRANCH>
|
|
81
|
+
|
|
82
|
+
npm version minor
|
|
83
|
+
|
|
84
|
+
git push --set-upstream <REMOTE> <BRANCH>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Once that's approved and merged, you can update your local `master` and:
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
npm publish
|
|
91
|
+
|
|
92
|
+
npm push --tags
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Alpha release example
|
|
96
|
+
|
|
97
|
+
Current version: `0.29.2`.
|
|
98
|
+
Desired release: `0.30.0-alpha.0`.
|
|
99
|
+
|
|
100
|
+
To create the PR:
|
|
101
|
+
```
|
|
102
|
+
git checkout -b <BRANCH>
|
|
103
|
+
|
|
104
|
+
npm version preminor --preid alpha
|
|
105
|
+
|
|
106
|
+
git push --set-upstream <REMOTE> <BRANCH>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Once that's approved and merged, you can update your local `master` and:
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
npm publish --tag alpha
|
|
113
|
+
|
|
114
|
+
npm push --tags
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Alpha pre-release example
|
|
118
|
+
|
|
119
|
+
Current version: `0.30.0-alpha.0`.
|
|
120
|
+
Desired release: `0.30.0-alpha.1`.
|
|
121
|
+
|
|
122
|
+
To create the PR:
|
|
123
|
+
```
|
|
124
|
+
git checkout -b <BRANCH>
|
|
125
|
+
|
|
126
|
+
npm version prerelease --preid alpha
|
|
127
|
+
|
|
128
|
+
git push --set-upstream <REMOTE> <BRANCH>
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Once that's approved and merged, you can update your local `master` and:
|
|
132
|
+
|
|
133
|
+
```
|
|
134
|
+
npm publish --tag alpha
|
|
135
|
+
|
|
136
|
+
npm push --tags
|
|
137
|
+
```
|
|
138
|
+
|
|
56
139
|
## License
|
|
57
140
|
|
|
58
141
|
Copyright © 2018-2019 Graph Protocol, Inc. and contributors.
|
package/examples/basic-event-handlers/node_modules/@graphprotocol/graph-ts/chain/ethereum.ts
CHANGED
|
@@ -35,10 +35,7 @@ export namespace ethereum {
|
|
|
35
35
|
* A dynamically typed value used when accessing Ethereum data.
|
|
36
36
|
*/
|
|
37
37
|
export class Value {
|
|
38
|
-
constructor(
|
|
39
|
-
public kind: ValueKind,
|
|
40
|
-
public data: ValuePayload,
|
|
41
|
-
) {}
|
|
38
|
+
constructor(public kind: ValueKind, public data: ValuePayload) {}
|
|
42
39
|
|
|
43
40
|
@operator('<')
|
|
44
41
|
lt(other: Value): boolean {
|
|
@@ -113,7 +110,7 @@ export namespace ethereum {
|
|
|
113
110
|
let valueArray = this.toArray()
|
|
114
111
|
let out = new Array<T>(valueArray.length)
|
|
115
112
|
for (let i: i32 = 0; i < valueArray.length; i++) {
|
|
116
|
-
out[i] = <T>valueArray[i].toTuple()
|
|
113
|
+
out[i] = changetype<T>(valueArray[i].toTuple())
|
|
117
114
|
}
|
|
118
115
|
return out
|
|
119
116
|
}
|
|
@@ -341,7 +338,7 @@ export namespace ethereum {
|
|
|
341
338
|
public timestamp: BigInt,
|
|
342
339
|
public difficulty: BigInt,
|
|
343
340
|
public totalDifficulty: BigInt,
|
|
344
|
-
public size: BigInt | null
|
|
341
|
+
public size: BigInt | null,
|
|
345
342
|
) {}
|
|
346
343
|
}
|
|
347
344
|
|
|
@@ -349,7 +346,7 @@ export namespace ethereum {
|
|
|
349
346
|
* An Ethereum transaction.
|
|
350
347
|
*/
|
|
351
348
|
export class Transaction {
|
|
352
|
-
constructor
|
|
349
|
+
constructor(
|
|
353
350
|
public hash: Bytes,
|
|
354
351
|
public index: BigInt,
|
|
355
352
|
public from: Address,
|
|
@@ -357,7 +354,7 @@ export namespace ethereum {
|
|
|
357
354
|
public value: BigInt,
|
|
358
355
|
public gasLimit: BigInt,
|
|
359
356
|
public gasPrice: BigInt,
|
|
360
|
-
public input: Bytes
|
|
357
|
+
public input: Bytes,
|
|
361
358
|
) {}
|
|
362
359
|
}
|
|
363
360
|
|
|
@@ -365,13 +362,13 @@ export namespace ethereum {
|
|
|
365
362
|
* Common representation for Ethereum smart contract calls.
|
|
366
363
|
*/
|
|
367
364
|
export class Call {
|
|
368
|
-
constructor
|
|
365
|
+
constructor(
|
|
369
366
|
public to: Address,
|
|
370
367
|
public from: Address,
|
|
371
368
|
public block: Block,
|
|
372
369
|
public transaction: Transaction,
|
|
373
370
|
public inputValues: Array<EventParam>,
|
|
374
|
-
public outputValues: Array<EventParam
|
|
371
|
+
public outputValues: Array<EventParam>,
|
|
375
372
|
) {}
|
|
376
373
|
}
|
|
377
374
|
|
|
@@ -379,14 +376,14 @@ export namespace ethereum {
|
|
|
379
376
|
* Common representation for Ethereum smart contract events.
|
|
380
377
|
*/
|
|
381
378
|
export class Event {
|
|
382
|
-
constructor
|
|
379
|
+
constructor(
|
|
383
380
|
public address: Address,
|
|
384
381
|
public logIndex: BigInt,
|
|
385
382
|
public transactionLogIndex: BigInt,
|
|
386
383
|
public logType: string | null,
|
|
387
384
|
public block: Block,
|
|
388
385
|
public transaction: Transaction,
|
|
389
|
-
public parameters: Array<EventParam
|
|
386
|
+
public parameters: Array<EventParam>,
|
|
390
387
|
) {}
|
|
391
388
|
}
|
|
392
389
|
|
|
@@ -394,10 +391,7 @@ export namespace ethereum {
|
|
|
394
391
|
* A dynamically-typed Ethereum event parameter.
|
|
395
392
|
*/
|
|
396
393
|
export class EventParam {
|
|
397
|
-
constructor
|
|
398
|
-
public name: string,
|
|
399
|
-
public value: Value
|
|
400
|
-
) {}
|
|
394
|
+
constructor(public name: string, public value: Value) {}
|
|
401
395
|
}
|
|
402
396
|
|
|
403
397
|
export class SmartContractCall {
|
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
import '../common/eager_offset'
|
|
2
|
+
import { Bytes } from '../common/collections'
|
|
3
|
+
import { BigInt } from '../common/numbers'
|
|
4
|
+
|
|
5
|
+
// Most types from this namespace are direct mappings or adaptations from:
|
|
6
|
+
// https://github.com/streamingfast/proto-near/blob/develop/sf/near/codec/v1/codec.proto
|
|
7
|
+
export namespace near {
|
|
8
|
+
export type CryptoHash = Bytes
|
|
9
|
+
|
|
10
|
+
export type Account = string
|
|
11
|
+
|
|
12
|
+
export type BlockHeight = u64
|
|
13
|
+
|
|
14
|
+
export type Balance = BigInt
|
|
15
|
+
|
|
16
|
+
export type Gas = u64
|
|
17
|
+
|
|
18
|
+
export type ShardId = u64
|
|
19
|
+
|
|
20
|
+
export type NumBlocks = u64
|
|
21
|
+
|
|
22
|
+
export type ProtocolVersion = u32
|
|
23
|
+
|
|
24
|
+
export type Payload = u64
|
|
25
|
+
|
|
26
|
+
export enum CurveKind {
|
|
27
|
+
ED25519 = 0,
|
|
28
|
+
SECP256K1 = 1,
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export class Signature {
|
|
32
|
+
constructor(public kind: CurveKind, public bytes: Bytes) {}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export class PublicKey {
|
|
36
|
+
constructor(public kind: CurveKind, public bytes: Bytes) {}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export enum AccessKeyPermissionKind {
|
|
40
|
+
FUNCTION_CALL = 0,
|
|
41
|
+
FULL_ACCESS = 1,
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export class FunctionCallPermission {
|
|
45
|
+
constructor(
|
|
46
|
+
public allowance: BigInt,
|
|
47
|
+
public receiverId: string,
|
|
48
|
+
public methodNames: Array<string>,
|
|
49
|
+
) {}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export class FullAccessPermission {}
|
|
53
|
+
|
|
54
|
+
export class AccessKeyPermissionValue {
|
|
55
|
+
constructor(public kind: AccessKeyPermissionKind, public data: Payload) {}
|
|
56
|
+
|
|
57
|
+
toFunctionCall(): FunctionCallPermission {
|
|
58
|
+
assert(
|
|
59
|
+
this.kind == AccessKeyPermissionKind.FUNCTION_CALL,
|
|
60
|
+
"AccessKeyPermissionValue is not a 'FunctionCall'.",
|
|
61
|
+
)
|
|
62
|
+
return changetype<FunctionCallPermission>(this.data as u32)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
toFullAccess(): FullAccessPermission {
|
|
66
|
+
assert(
|
|
67
|
+
this.kind == AccessKeyPermissionKind.FULL_ACCESS,
|
|
68
|
+
"AccessKeyPermissionValue is not a 'FullAccess'.",
|
|
69
|
+
)
|
|
70
|
+
return changetype<FullAccessPermission>(this.data as u32)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
static fromFunctionCall(input: FunctionCallPermission): AccessKeyPermissionValue {
|
|
74
|
+
return new AccessKeyPermissionValue(
|
|
75
|
+
AccessKeyPermissionKind.FUNCTION_CALL,
|
|
76
|
+
changetype<u32>(input),
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
static fromFullAccess(input: FullAccessPermission): AccessKeyPermissionValue {
|
|
81
|
+
return new AccessKeyPermissionValue(
|
|
82
|
+
AccessKeyPermissionKind.FULL_ACCESS,
|
|
83
|
+
changetype<u32>(input),
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export class AccessKey {
|
|
89
|
+
constructor(public nonce: u64, public permission: AccessKeyPermissionValue) {}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export class DataReceiver {
|
|
93
|
+
constructor(public dataId: CryptoHash, public receiverId: string) {}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export enum ActionKind {
|
|
97
|
+
CREATE_ACCOUNT = 0,
|
|
98
|
+
DEPLOY_CONTRACT = 1,
|
|
99
|
+
FUNCTION_CALL = 2,
|
|
100
|
+
TRANSFER = 3,
|
|
101
|
+
STAKE = 4,
|
|
102
|
+
ADD_KEY = 5,
|
|
103
|
+
DELETE_KEY = 6,
|
|
104
|
+
DELETE_ACCOUNT = 7,
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export class CreateAccountAction {}
|
|
108
|
+
|
|
109
|
+
export class DeployContractAction {
|
|
110
|
+
constructor(public codeHash: Bytes) {}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export class FunctionCallAction {
|
|
114
|
+
constructor(
|
|
115
|
+
public methodName: string,
|
|
116
|
+
public args: Bytes,
|
|
117
|
+
public gas: u64,
|
|
118
|
+
public deposit: BigInt,
|
|
119
|
+
) {}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export class TransferAction {
|
|
123
|
+
constructor(public deposit: BigInt) {}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export class StakeAction {
|
|
127
|
+
constructor(public stake: Balance, public publicKey: PublicKey) {}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export class AddKeyAction {
|
|
131
|
+
constructor(public publicKey: PublicKey, public accessKey: AccessKey) {}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export class DeleteKeyAction {
|
|
135
|
+
constructor(public publicKey: PublicKey) {}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export class DeleteAccountAction {
|
|
139
|
+
constructor(public beneficiaryId: Account) {}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export class ActionValue {
|
|
143
|
+
constructor(public kind: ActionKind, public data: Payload) {}
|
|
144
|
+
|
|
145
|
+
toCreateAccount(): CreateAccountAction {
|
|
146
|
+
assert(
|
|
147
|
+
this.kind == ActionKind.CREATE_ACCOUNT,
|
|
148
|
+
"ActionValue is not a 'CreateAccount'.",
|
|
149
|
+
)
|
|
150
|
+
return changetype<CreateAccountAction>(this.data as u32)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
toDeployContract(): DeployContractAction {
|
|
154
|
+
assert(
|
|
155
|
+
this.kind == ActionKind.DEPLOY_CONTRACT,
|
|
156
|
+
"ActionValue is not a 'DeployContract'.",
|
|
157
|
+
)
|
|
158
|
+
return changetype<DeployContractAction>(this.data as u32)
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
toFunctionCall(): FunctionCallAction {
|
|
162
|
+
assert(
|
|
163
|
+
this.kind == ActionKind.FUNCTION_CALL,
|
|
164
|
+
"ActionValue is not a 'FunctionCall'.",
|
|
165
|
+
)
|
|
166
|
+
return changetype<FunctionCallAction>(this.data as u32)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
toTransfer(): TransferAction {
|
|
170
|
+
assert(this.kind == ActionKind.TRANSFER, "ActionValue is not a 'Transfer'.")
|
|
171
|
+
return changetype<TransferAction>(this.data as u32)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
toStake(): StakeAction {
|
|
175
|
+
assert(this.kind == ActionKind.STAKE, "ActionValue is not a 'Stake'.")
|
|
176
|
+
return changetype<StakeAction>(this.data as u32)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
toAddKey(): AddKeyAction {
|
|
180
|
+
assert(this.kind == ActionKind.ADD_KEY, "ActionValue is not a 'AddKey'.")
|
|
181
|
+
return changetype<AddKeyAction>(this.data as u32)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
toDeleteKey(): DeleteKeyAction {
|
|
185
|
+
assert(this.kind == ActionKind.DELETE_KEY, "ActionValue is not a 'DeleteKey'.")
|
|
186
|
+
return changetype<DeleteKeyAction>(this.data as u32)
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
toDeleteAccount(): DeleteAccountAction {
|
|
190
|
+
assert(
|
|
191
|
+
this.kind == ActionKind.DELETE_ACCOUNT,
|
|
192
|
+
"ActionValue is not a 'DeleteAccount'.",
|
|
193
|
+
)
|
|
194
|
+
return changetype<DeleteAccountAction>(this.data as u32)
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
static fromCreateAccount(input: CreateAccountAction): ActionValue {
|
|
198
|
+
return new ActionValue(ActionKind.CREATE_ACCOUNT, changetype<u32>(input))
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
static fromDeployContract(input: DeployContractAction): ActionValue {
|
|
202
|
+
return new ActionValue(ActionKind.DEPLOY_CONTRACT, changetype<u32>(input))
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
static fromFunctionCall(input: FunctionCallAction): ActionValue {
|
|
206
|
+
return new ActionValue(ActionKind.FUNCTION_CALL, changetype<u32>(input))
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
static fromTransfer(input: TransferAction): ActionValue {
|
|
210
|
+
return new ActionValue(ActionKind.TRANSFER, changetype<u32>(input))
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
static fromStake(input: StakeAction): ActionValue {
|
|
214
|
+
return new ActionValue(ActionKind.STAKE, changetype<u32>(input))
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
static fromAddKey(input: AddKeyAction): ActionValue {
|
|
218
|
+
return new ActionValue(ActionKind.ADD_KEY, changetype<u32>(input))
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
static fromDeleteKey(input: DeleteKeyAction): ActionValue {
|
|
222
|
+
return new ActionValue(ActionKind.DELETE_KEY, changetype<u32>(input))
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
static fromDeleteAccount(input: DeleteAccountAction): ActionValue {
|
|
226
|
+
return new ActionValue(ActionKind.DELETE_ACCOUNT, changetype<u32>(input))
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// We don't map ReceiptData
|
|
231
|
+
export class ActionReceipt {
|
|
232
|
+
constructor(
|
|
233
|
+
// Receipt fields
|
|
234
|
+
public predecessorId: string,
|
|
235
|
+
public receiverId: string,
|
|
236
|
+
public id: CryptoHash,
|
|
237
|
+
|
|
238
|
+
// ReceiptAction fields
|
|
239
|
+
public signerId: string,
|
|
240
|
+
public signerPublicKey: PublicKey,
|
|
241
|
+
public gasPrice: BigInt,
|
|
242
|
+
public outputDataReceivers: Array<DataReceiver>,
|
|
243
|
+
public inputDataIds: Array<CryptoHash>,
|
|
244
|
+
public actions: Array<ActionValue>,
|
|
245
|
+
) {}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export enum SuccessStatusKind {
|
|
249
|
+
VALUE = 0,
|
|
250
|
+
RECEIPT_ID = 1,
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// Doesn't have Value suffix because it has
|
|
254
|
+
// VALUE variant/kind, that would be confusing.
|
|
255
|
+
export class SuccessStatus {
|
|
256
|
+
constructor(public kind: SuccessStatusKind, public data: Payload) {}
|
|
257
|
+
|
|
258
|
+
toValue(): Bytes {
|
|
259
|
+
assert(this.kind == SuccessStatusKind.VALUE, "SuccessStatus is not a 'Value'.")
|
|
260
|
+
return changetype<Bytes>(this.data as u32)
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
toReceiptId(): CryptoHash {
|
|
264
|
+
assert(
|
|
265
|
+
this.kind == SuccessStatusKind.RECEIPT_ID,
|
|
266
|
+
"SuccessStatus is not a 'ReceiptId'.",
|
|
267
|
+
)
|
|
268
|
+
return changetype<CryptoHash>(this.data as u32)
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
static fromValue(input: Bytes): SuccessStatus {
|
|
272
|
+
return new SuccessStatus(SuccessStatusKind.VALUE, changetype<u32>(input))
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
static fromReceiptId(input: CryptoHash): SuccessStatus {
|
|
276
|
+
return new SuccessStatus(SuccessStatusKind.RECEIPT_ID, changetype<u32>(input))
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
export enum Direction {
|
|
281
|
+
LEFT = 0,
|
|
282
|
+
RIGHT = 1,
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export class MerklePathItem {
|
|
286
|
+
constructor(public hash: CryptoHash, public direction: Direction) {}
|
|
287
|
+
|
|
288
|
+
@operator('<')
|
|
289
|
+
lt(other: MerklePathItem): boolean {
|
|
290
|
+
abort("Less than operator isn't supported in MerklePathItem")
|
|
291
|
+
return false
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
@operator('>')
|
|
295
|
+
gt(other: MerklePathItem): boolean {
|
|
296
|
+
abort("Greater than operator isn't supported in MerklePathItem")
|
|
297
|
+
return false
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
toString(): string {
|
|
301
|
+
return `{hash: ${this.hash.toString()}}, direction: ${this.direction.toString()}`
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
export class MerklePath extends Array<MerklePathItem> {}
|
|
306
|
+
|
|
307
|
+
export class ExecutionOutcome {
|
|
308
|
+
constructor(
|
|
309
|
+
public gasBurnt: u64,
|
|
310
|
+
public proof: MerklePath,
|
|
311
|
+
public blockHash: CryptoHash,
|
|
312
|
+
public id: CryptoHash,
|
|
313
|
+
public logs: Array<string>,
|
|
314
|
+
public receiptIds: Array<CryptoHash>,
|
|
315
|
+
public tokensBurnt: BigInt,
|
|
316
|
+
public executorId: string,
|
|
317
|
+
public status: SuccessStatus,
|
|
318
|
+
) {}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
export class SlashedValidator {
|
|
322
|
+
constructor(public account: Account, public isDoubleSign: bool) {}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
export class BlockHeader {
|
|
326
|
+
constructor(
|
|
327
|
+
public height: BlockHeight,
|
|
328
|
+
public prevHeight: BlockHeight, // Always zero when version < V3
|
|
329
|
+
public blockOrdinal: NumBlocks, // Always zero when version < V3
|
|
330
|
+
public epochId: CryptoHash,
|
|
331
|
+
public nextEpochId: CryptoHash,
|
|
332
|
+
public chunksIncluded: u64,
|
|
333
|
+
public hash: CryptoHash,
|
|
334
|
+
public prevHash: CryptoHash,
|
|
335
|
+
public timestampNanosec: u64,
|
|
336
|
+
public prevStateRoot: CryptoHash,
|
|
337
|
+
public chunkReceiptsRoot: CryptoHash,
|
|
338
|
+
public chunkHeadersRoot: CryptoHash,
|
|
339
|
+
public chunkTxRoot: CryptoHash,
|
|
340
|
+
public outcomeRoot: CryptoHash,
|
|
341
|
+
public challengesRoot: CryptoHash,
|
|
342
|
+
public randomValue: CryptoHash,
|
|
343
|
+
public validatorProposals: Array<ValidatorStake>,
|
|
344
|
+
public chunkMask: Array<bool>,
|
|
345
|
+
public gasPrice: Balance,
|
|
346
|
+
public totalSupply: Balance,
|
|
347
|
+
public challengesResult: Array<SlashedValidator>,
|
|
348
|
+
public lastFinalBlock: CryptoHash,
|
|
349
|
+
public lastDsFinalBlock: CryptoHash,
|
|
350
|
+
public nextBpHash: CryptoHash,
|
|
351
|
+
public blockMerkleRoot: CryptoHash,
|
|
352
|
+
public epochSyncDataHash: CryptoHash, // Always empty when version < V3
|
|
353
|
+
public approvals: Array<Signature>, // Array<Option<Signature>>
|
|
354
|
+
public signature: Signature,
|
|
355
|
+
public latestProtocolVersion: ProtocolVersion,
|
|
356
|
+
) {}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
export class ValidatorStake {
|
|
360
|
+
constructor(
|
|
361
|
+
public account: Account,
|
|
362
|
+
public publicKey: PublicKey,
|
|
363
|
+
public stake: Balance,
|
|
364
|
+
) {}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
export class ChunkHeader {
|
|
368
|
+
constructor(
|
|
369
|
+
public encodedLength: u64,
|
|
370
|
+
public gasUsed: Gas,
|
|
371
|
+
public gasLimit: Gas,
|
|
372
|
+
public shardId: ShardId,
|
|
373
|
+
public heightCreated: BlockHeight,
|
|
374
|
+
public heightIncluded: BlockHeight,
|
|
375
|
+
public chunkHash: CryptoHash,
|
|
376
|
+
public signature: Signature,
|
|
377
|
+
public prevBlockHash: CryptoHash,
|
|
378
|
+
public prevStateRoot: CryptoHash,
|
|
379
|
+
public encodedMerkleRoot: CryptoHash,
|
|
380
|
+
public balanceBurnt: Balance,
|
|
381
|
+
public outgoingReceiptsRoot: CryptoHash,
|
|
382
|
+
public txRoot: CryptoHash,
|
|
383
|
+
public validatorProposals: Array<ValidatorStake>,
|
|
384
|
+
) {}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
export class Block {
|
|
388
|
+
constructor(
|
|
389
|
+
public author: Account,
|
|
390
|
+
public header: BlockHeader,
|
|
391
|
+
public chunks: Array<ChunkHeader>,
|
|
392
|
+
) {}
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
export class ReceiptWithOutcome {
|
|
396
|
+
constructor(
|
|
397
|
+
public outcome: ExecutionOutcome,
|
|
398
|
+
public receipt: ActionReceipt,
|
|
399
|
+
public block: Block,
|
|
400
|
+
) {}
|
|
401
|
+
}
|
|
402
|
+
}
|