Skip to content

Commit 66c5f47

Browse files
committed
upgrade schema.graphql
1 parent 4fae48c commit 66c5f47

9 files changed

+433
-76
lines changed

client_block.go

+3
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,15 @@ func (o GetBlockOption) BuildIgnoreChecker() query.IgnoreChecker {
2828
}
2929
if !o.WithTransactions {
3030
checkers = append(checkers, query.IgnoreField(types.Block{}, "Transactions"))
31+
checkers = append(checkers, query.IgnoreField(types.Block{}, "TransactionIds"))
3132
} else if !o.WithTransactionDetail {
3233
checkers = append(checkers, query.IgnoreOtherFields(types.Transaction{}, "Id"))
3334
} else {
3435
// Otherwise it will create circular dependencies
3536
checkers = append(checkers, query.IgnoreField(types.SuccessStatus{}, "Block"))
3637
checkers = append(checkers, query.IgnoreField(types.FailureStatus{}, "Block"))
38+
checkers = append(checkers, query.IgnoreField(types.SuccessStatus{}, "Transaction"))
39+
checkers = append(checkers, query.IgnoreField(types.FailureStatus{}, "Transaction"))
3740
if !o.WithTransactionReceipts {
3841
checkers = append(checkers, query.IgnoreField(types.SuccessStatus{}, "Receipts"))
3942
checkers = append(checkers, query.IgnoreField(types.FailureStatus{}, "Receipts"))

client_block_test.go

+37-18
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@ func Test_GetBlock0(t *testing.T) {
1919
}, GetBlockOption{})
2020
assert.NoError(t, err)
2121
assert.Equal(t, &types.Block{
22-
Id: types.BlockId{Hash: common.HexToHash("0x4e02668366cbdc2ea9197fa3a84e57e723028de5fe4f574ccaa7b6b744ced495")},
23-
Height: 1067005,
22+
Version: "V1",
23+
Id: types.BlockId{Hash: common.HexToHash("0x4e02668366cbdc2ea9197fa3a84e57e723028de5fe4f574ccaa7b6b744ced495")},
24+
Height: 1067005,
2425
}, block)
2526
}
2627

2728
var (
2829
header_1067005 = types.Header{
30+
Version: "V1",
2931
Id: types.BlockId{Hash: common.HexToHash("0x4e02668366cbdc2ea9197fa3a84e57e723028de5fe4f574ccaa7b6b744ced495")},
3032
DaHeight: 5997348,
3133
ConsensusParametersVersion: 1,
@@ -48,6 +50,10 @@ var (
4850
},
4951
},
5052
}
53+
txnIdList_1067005 = []types.TransactionId{
54+
{Hash: common.HexToHash("0x0ec0390a47eb248d579c74861d747259c2a2a3f4c5c4cdccf049f0670b9a4485")},
55+
{Hash: common.HexToHash("0xb0b4aaafa1df52c844ea4b970d40397ef2880087f8bd8d45619e7cac95b1c0d8")},
56+
}
5157
)
5258

5359
func Test_GetBlock1(t *testing.T) {
@@ -57,6 +63,7 @@ func Test_GetBlock1(t *testing.T) {
5763
}, GetBlockOption{WithHeader: true, WithConsensus: true})
5864
assert.NoError(t, err)
5965
assert.Equal(t, &types.Block{
66+
Version: "V1",
6067
Id: types.BlockId{Hash: common.HexToHash("0x4e02668366cbdc2ea9197fa3a84e57e723028de5fe4f574ccaa7b6b744ced495")},
6168
Height: 1067005,
6269
Header: header_1067005,
@@ -71,8 +78,10 @@ func Test_GetBlock2(t *testing.T) {
7178
}, GetBlockOption{WithTransactions: true})
7279
assert.NoError(t, err)
7380
assert.Equal(t, &types.Block{
74-
Id: types.BlockId{Hash: common.HexToHash("0x4e02668366cbdc2ea9197fa3a84e57e723028de5fe4f574ccaa7b6b744ced495")},
75-
Height: 1067005,
81+
Version: "V1",
82+
Id: types.BlockId{Hash: common.HexToHash("0x4e02668366cbdc2ea9197fa3a84e57e723028de5fe4f574ccaa7b6b744ced495")},
83+
Height: 1067005,
84+
TransactionIds: txnIdList_1067005,
7685
Transactions: []types.Transaction{{
7786
Id: types.TransactionId{Hash: common.HexToHash("0x0ec0390a47eb248d579c74861d747259c2a2a3f4c5c4cdccf049f0670b9a4485")},
7887
}, {
@@ -87,9 +96,11 @@ func Test_GetBlock3(t *testing.T) {
8796
Id: &types.BlockId{Hash: common.HexToHash("0x4e02668366cbdc2ea9197fa3a84e57e723028de5fe4f574ccaa7b6b744ced495")},
8897
}, GetBlockOption{WithTransactions: true, WithTransactionDetail: true, WithTransactionReceipts: true})
8998
exp := &types.Block{
90-
Id: types.BlockId{Hash: common.HexToHash("0x4e02668366cbdc2ea9197fa3a84e57e723028de5fe4f574ccaa7b6b744ced495")},
91-
Height: 1067005,
92-
Transactions: []types.Transaction{txn_1067005_0, txn_1067005_1},
99+
Version: "V1",
100+
Id: types.BlockId{Hash: common.HexToHash("0x4e02668366cbdc2ea9197fa3a84e57e723028de5fe4f574ccaa7b6b744ced495")},
101+
Height: 1067005,
102+
TransactionIds: txnIdList_1067005,
103+
Transactions: []types.Transaction{txn_1067005_0, txn_1067005_1},
93104
}
94105
assert.NoError(t, err)
95106
assert.Equal(t, exp, block)
@@ -102,19 +113,22 @@ func Test_GetBlock4(t *testing.T) {
102113
}, GetBlockOption{})
103114
assert.NoError(t, err)
104115
assert.Equal(t, &types.Block{
105-
Id: types.BlockId{Hash: common.HexToHash("0x4e02668366cbdc2ea9197fa3a84e57e723028de5fe4f574ccaa7b6b744ced495")},
106-
Height: 1067005,
116+
Version: "V1",
117+
Id: types.BlockId{Hash: common.HexToHash("0x4e02668366cbdc2ea9197fa3a84e57e723028de5fe4f574ccaa7b6b744ced495")},
118+
Height: 1067005,
107119
}, block)
108120
}
109121

110122
func Test_GetBlock_marshalJSON(t *testing.T) {
111123
block := types.Block{
112-
Id: types.BlockId{Hash: common.HexToHash("0x5d7f48fc777144b21ea760525936db069329dee2ccce509550c1478c1c0b5b2c")},
113-
Height: 9758550,
124+
Version: "V1",
125+
Id: types.BlockId{Hash: common.HexToHash("0x5d7f48fc777144b21ea760525936db069329dee2ccce509550c1478c1c0b5b2c")},
126+
Height: 9758550,
114127
Header: types.Header{
115-
Id: types.BlockId{Hash: common.HexToHash("0x5d7f48fc777144b21ea760525936db069329dee2ccce509550c1478c1c0b5b2c")},
116-
Height: 9758550,
117-
Time: types.Tai64Timestamp{Time: time.Date(2024, time.April, 5, 1, 2, 3, 0, time.UTC)},
128+
Version: "V1",
129+
Id: types.BlockId{Hash: common.HexToHash("0x5d7f48fc777144b21ea760525936db069329dee2ccce509550c1478c1c0b5b2c")},
130+
Height: 9758550,
131+
Time: types.Tai64Timestamp{Time: time.Date(2024, time.April, 5, 1, 2, 3, 0, time.UTC)},
118132
},
119133
Consensus: types.Consensus{
120134
TypeName_: "PoAConsensus",
@@ -126,9 +140,11 @@ func Test_GetBlock_marshalJSON(t *testing.T) {
126140
text, err := json.MarshalIndent(block, "", " ")
127141
assert.NoError(t, err)
128142
assert.Equal(t, `{
143+
"version": "V1",
129144
"id": "0x5d7f48fc777144b21ea760525936db069329dee2ccce509550c1478c1c0b5b2c",
130145
"height": "9758550",
131146
"header": {
147+
"version": "V1",
132148
"id": "0x5d7f48fc777144b21ea760525936db069329dee2ccce509550c1478c1c0b5b2c",
133149
"daHeight": "0",
134150
"consensusParametersVersion": "0",
@@ -147,6 +163,7 @@ func Test_GetBlock_marshalJSON(t *testing.T) {
147163
"__typename": "PoAConsensus",
148164
"signature": "0x123456"
149165
},
166+
"transactionIds": null,
150167
"transactions": null
151168
}`, string(text))
152169

@@ -164,10 +181,12 @@ func Test_GetBlocks(t *testing.T) {
164181
}}, GetBlockOption{})
165182
assert.NoError(t, err)
166183
assert.Equal(t, []*types.Block{{
167-
Id: types.BlockId{Hash: common.HexToHash("0x4e02668366cbdc2ea9197fa3a84e57e723028de5fe4f574ccaa7b6b744ced495")},
168-
Height: 1067005,
184+
Version: "V1",
185+
Id: types.BlockId{Hash: common.HexToHash("0x4e02668366cbdc2ea9197fa3a84e57e723028de5fe4f574ccaa7b6b744ced495")},
186+
Height: 1067005,
169187
}, {
170-
Id: types.BlockId{Hash: common.HexToHash("0xae197dbe746cc36784aaff0cf38e1678dbc6ee6b85b15d6bb2c3e932c2ad156d")},
171-
Height: 1067006,
188+
Version: "V1",
189+
Id: types.BlockId{Hash: common.HexToHash("0xae197dbe746cc36784aaff0cf38e1678dbc6ee6b85b15d6bb2c3e932c2ad156d")},
190+
Height: 1067006,
172191
}}, blocks)
173192
}

client_test.go

+80-8
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,14 @@ func Test_ExecuteQuery(t *testing.T) {
6464

6565
func Test_GenObjectQuery(t *testing.T) {
6666
assert.Equal(t,
67-
"id height header { id daHeight consensusParametersVersion stateTransitionBytecodeVersion transactionsCount messageReceiptCount transactionsRoot messageOutboxRoot eventInboxRoot height prevRoot time applicationHash } consensus { __typename ... on Genesis { chainConfigHash coinsRoot contractsRoot messagesRoot transactionsRoot } ... on PoAConsensus { signature } } ",
67+
"version id height header { version id daHeight consensusParametersVersion stateTransitionBytecodeVersion transactionsCount messageReceiptCount transactionsRoot messageOutboxRoot eventInboxRoot height prevRoot time applicationHash } consensus { __typename ... on Genesis { chainConfigHash coinsRoot contractsRoot messagesRoot transactionsRoot } ... on PoAConsensus { signature } } transactionIds ",
6868
query.Simple.GenObjectQuery(types.Block{}, query.IgnoreObjects(types.Transaction{})),
6969
)
70-
assert.Equal(t, `id
70+
assert.Equal(t, `version
71+
id
7172
height
7273
header {
74+
version
7375
id
7476
daHeight
7577
consensusParametersVersion
@@ -97,12 +99,13 @@ consensus {
9799
signature
98100
}
99101
}
102+
transactionIds
100103
`,
101104
query.Beauty.GenObjectQuery(types.Block{}, query.IgnoreObjects(types.Transaction{})),
102105
)
103106

104107
assert.Equal(t,
105-
"id height header { id daHeight consensusParametersVersion stateTransitionBytecodeVersion transactionsCount messageReceiptCount transactionsRoot messageOutboxRoot eventInboxRoot height prevRoot time applicationHash } consensus { __typename ... on Genesis { chainConfigHash coinsRoot contractsRoot messagesRoot transactionsRoot } ... on PoAConsensus { signature } } transactions { id inputAssetIds inputContracts inputContract { utxoId balanceRoot stateRoot txPointer contractId } policies { tip witnessLimit maturity maxFee } scriptGasLimit maturity mintAmount mintAssetId mintGasPrice txPointer isScript isCreate isMint isUpgrade isUpload inputs { __typename ... on InputCoin { utxoId owner amount assetId txPointer witnessIndex predicateGasUsed predicate predicateData } ... on InputContract { utxoId balanceRoot stateRoot txPointer contractId } ... on InputMessage { sender recipient amount nonce witnessIndex predicateGasUsed data predicate predicateData } } outputs { __typename ... on CoinOutput { to amount assetId } ... on ContractOutput { inputIndex balanceRoot stateRoot } ... on ChangeOutput { to amount assetId } ... on VariableOutput { to amount assetId } ... on ContractCreated { contract stateRoot } } outputContract { inputIndex balanceRoot stateRoot } witnesses receiptsRoot status { __typename ... on SubmittedStatus { time } ... on SqueezedOutStatus { reason } } script scriptData bytecodeWitnessIndex salt storageSlots bytecodeRoot subsectionIndex subsectionsNumber proofSet upgradePurpose { __typename ... on ConsensusParametersPurpose { witnessIndex checksum } ... on StateTransitionPurpose { root } } rawPayload } ",
108+
"version id height header { version id daHeight consensusParametersVersion stateTransitionBytecodeVersion transactionsCount messageReceiptCount transactionsRoot messageOutboxRoot eventInboxRoot height prevRoot time applicationHash } consensus { __typename ... on Genesis { chainConfigHash coinsRoot contractsRoot messagesRoot transactionsRoot } ... on PoAConsensus { signature } } transactionIds transactions { id inputAssetIds inputContracts inputContract { utxoId balanceRoot stateRoot txPointer contractId } policies { tip witnessLimit maturity maxFee } scriptGasLimit maturity mintAmount mintAssetId mintGasPrice txPointer isScript isCreate isMint isUpgrade isUpload isBlob inputs { __typename ... on InputCoin { utxoId owner amount assetId txPointer witnessIndex predicateGasUsed predicate predicateData } ... on InputContract { utxoId balanceRoot stateRoot txPointer contractId } ... on InputMessage { sender recipient amount nonce witnessIndex predicateGasUsed data predicate predicateData } } outputs { __typename ... on CoinOutput { to amount assetId } ... on ContractOutput { inputIndex balanceRoot stateRoot } ... on ChangeOutput { to amount assetId } ... on VariableOutput { to amount assetId } ... on ContractCreated { contract stateRoot } } outputContract { inputIndex balanceRoot stateRoot } witnesses receiptsRoot status { __typename ... on SubmittedStatus { time } ... on SqueezedOutStatus { reason } } script scriptData bytecodeWitnessIndex blobId salt storageSlots bytecodeRoot subsectionIndex subsectionsNumber proofSet upgradePurpose { __typename ... on ConsensusParametersPurpose { witnessIndex checksum } ... on StateTransitionPurpose { root } } rawPayload } ",
106109
query.Simple.GenObjectQuery(types.Block{}, query.IgnoreObjects(types.SuccessStatus{}, types.FailureStatus{})),
107110
)
108111
}
@@ -143,10 +146,13 @@ func Test_Union_marshalJSON(t *testing.T) {
143146
TransactionId: types.TransactionId{
144147
Hash: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000123"),
145148
},
149+
BlockHeight: 5,
146150
Block: types.Block{
147-
Id: types.BlockId{Hash: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000001")},
148-
Height: 5,
151+
Version: "V1",
152+
Id: types.BlockId{Hash: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000001")},
153+
Height: 5,
149154
Header: types.Header{
155+
Version: "V1",
150156
Id: types.BlockId{Hash: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000001")},
151157
DaHeight: 2,
152158
TransactionsCount: 3,
@@ -155,17 +161,23 @@ func Test_Union_marshalJSON(t *testing.T) {
155161
Time: types.Tai64Timestamp{Time: time.Date(2024, time.April, 15, 2, 44, 2, 0, time.UTC)},
156162
},
157163
},
164+
Transaction: types.Transaction{
165+
Id: types.TransactionId{Hash: common.HexToHash("0x9999")},
166+
},
158167
},
159168
}
160169
text, err := json.MarshalIndent(status, "", " ")
161170
assert.NoError(t, err)
162171
assert.Equal(t, `{
163172
"__typename": "SuccessStatus",
164173
"transactionId": "0x0000000000000000000000000000000000000000000000000000000000000123",
174+
"blockHeight": "5",
165175
"block": {
176+
"version": "V1",
166177
"id": "0x0000000000000000000000000000000000000000000000000000000000000001",
167178
"height": "5",
168179
"header": {
180+
"version": "V1",
169181
"id": "0x0000000000000000000000000000000000000000000000000000000000000001",
170182
"daHeight": "2",
171183
"consensusParametersVersion": "0",
@@ -181,8 +193,46 @@ func Test_Union_marshalJSON(t *testing.T) {
181193
"applicationHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
182194
},
183195
"consensus": null,
196+
"transactionIds": null,
184197
"transactions": null
185198
},
199+
"transaction": {
200+
"id": "0x0000000000000000000000000000000000000000000000000000000000009999",
201+
"inputAssetIds": null,
202+
"inputContracts": null,
203+
"inputContract": null,
204+
"policies": null,
205+
"scriptGasLimit": null,
206+
"maturity": null,
207+
"mintAmount": null,
208+
"mintAssetId": null,
209+
"mintGasPrice": null,
210+
"txPointer": null,
211+
"isScript": false,
212+
"isCreate": false,
213+
"isMint": false,
214+
"isUpgrade": false,
215+
"isUpload": false,
216+
"isBlob": false,
217+
"inputs": null,
218+
"outputs": null,
219+
"outputContract": null,
220+
"witnesses": null,
221+
"receiptsRoot": null,
222+
"status": null,
223+
"script": null,
224+
"scriptData": null,
225+
"bytecodeWitnessIndex": null,
226+
"blobId": null,
227+
"salt": null,
228+
"storageSlots": null,
229+
"bytecodeRoot": null,
230+
"subsectionIndex": null,
231+
"subsectionsNumber": null,
232+
"proofSet": null,
233+
"upgradePurpose": null,
234+
"rawPayload": "0x"
235+
},
186236
"time": "4611685956291791114",
187237
"programState": null,
188238
"receipts": null,
@@ -237,6 +287,7 @@ func Test_marshalStructpb(t *testing.T) {
237287
"isMint": structpb.NewBoolValue(false),
238288
"isUpgrade": structpb.NewBoolValue(false),
239289
"isUpload": structpb.NewBoolValue(false),
290+
"isBlob": structpb.NewBoolValue(false),
240291
"inputs": structpb.NewListValue(&structpb.ListValue{Values: []*structpb.Value{
241292
structpb.NewStructValue(&structpb.Struct{Fields: map[string]*structpb.Value{
242293
"__typename": structpb.NewStringValue("InputContract"),
@@ -279,11 +330,14 @@ func Test_marshalStructpb(t *testing.T) {
279330
"receiptsRoot": structpb.NewStringValue("0x74ab41b67d3e1ccb4bda92dfac21bfb448f80d0500b3cd56480aaee2fa37cbf0"),
280331
"status": structpb.NewStructValue(&structpb.Struct{Fields: map[string]*structpb.Value{
281332
"__typename": structpb.NewStringValue("SuccessStatus"),
333+
"blockHeight": structpb.NewStringValue("1067005"),
282334
"transactionId": structpb.NewStringValue("0x0ec0390a47eb248d579c74861d747259c2a2a3f4c5c4cdccf049f0670b9a4485"),
283335
"block": structpb.NewStructValue(&structpb.Struct{Fields: map[string]*structpb.Value{
284-
"id": structpb.NewStringValue("0x0000000000000000000000000000000000000000000000000000000000000000"),
285-
"height": structpb.NewStringValue("0"),
336+
"version": structpb.NewStringValue(""),
337+
"id": structpb.NewStringValue("0x0000000000000000000000000000000000000000000000000000000000000000"),
338+
"height": structpb.NewStringValue("0"),
286339
"header": structpb.NewStructValue(&structpb.Struct{Fields: map[string]*structpb.Value{
340+
"version": structpb.NewStringValue(""),
287341
"id": structpb.NewStringValue("0x0000000000000000000000000000000000000000000000000000000000000000"),
288342
"daHeight": structpb.NewStringValue("0"),
289343
"consensusParametersVersion": structpb.NewStringValue("0"),
@@ -298,7 +352,25 @@ func Test_marshalStructpb(t *testing.T) {
298352
"time": structpb.NewStringValue("4611685956291791114"),
299353
"applicationHash": structpb.NewStringValue("0x0000000000000000000000000000000000000000000000000000000000000000"),
300354
}}),
301-
"transactions": structpb.NewListValue(&structpb.ListValue{Values: []*structpb.Value{}}),
355+
"transactionIds": structpb.NewListValue(&structpb.ListValue{Values: []*structpb.Value{}}),
356+
"transactions": structpb.NewListValue(&structpb.ListValue{Values: []*structpb.Value{}}),
357+
}}),
358+
"transaction": structpb.NewStructValue(&structpb.Struct{Fields: map[string]*structpb.Value{
359+
"id": structpb.NewStringValue("0x0000000000000000000000000000000000000000000000000000000000000000"),
360+
"inputAssetIds": structpb.NewListValue(&structpb.ListValue{Values: []*structpb.Value{}}),
361+
"inputContracts": structpb.NewListValue(&structpb.ListValue{Values: []*structpb.Value{}}),
362+
"inputs": structpb.NewListValue(&structpb.ListValue{Values: []*structpb.Value{}}),
363+
"outputs": structpb.NewListValue(&structpb.ListValue{Values: []*structpb.Value{}}),
364+
"proofSet": structpb.NewListValue(&structpb.ListValue{Values: []*structpb.Value{}}),
365+
"storageSlots": structpb.NewListValue(&structpb.ListValue{Values: []*structpb.Value{}}),
366+
"witnesses": structpb.NewListValue(&structpb.ListValue{Values: []*structpb.Value{}}),
367+
"isScript": structpb.NewBoolValue(false),
368+
"isCreate": structpb.NewBoolValue(false),
369+
"isMint": structpb.NewBoolValue(false),
370+
"isUpgrade": structpb.NewBoolValue(false),
371+
"isUpload": structpb.NewBoolValue(false),
372+
"isBlob": structpb.NewBoolValue(false),
373+
"rawPayload": structpb.NewStringValue("0x"),
302374
}}),
303375
"receipts": structpb.NewListValue(&structpb.ListValue{Values: []*structpb.Value{
304376
structpb.NewStructValue(&structpb.Struct{Fields: map[string]*structpb.Value{

client_transaction.go

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ type GetTransactionOption struct {
1717
func (o GetTransactionOption) BuildIgnoreChecker() query.IgnoreChecker {
1818
ignoreCheckers := []query.IgnoreChecker{
1919
query.IgnoreField(types.Block{}, "Transactions"),
20+
query.IgnoreField(types.SuccessStatus{}, "Transaction"),
21+
query.IgnoreField(types.FailureStatus{}, "Transaction"),
2022
}
2123
if !o.WithContractBytecode {
2224
ignoreCheckers = append(ignoreCheckers, query.IgnoreField(types.Contract{}, "Bytecode"))

0 commit comments

Comments
 (0)