Skip to content

Commit

Permalink
Merge pull request #1482 from dusk-network/gql-txraw
Browse files Browse the repository at this point in the history
Add `raw` field to the transaction
  • Loading branch information
herr-seppia authored Dec 21, 2022
2 parents 62e98c9 + 7066bf1 commit ad774bf
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

### Added
- Add `raw` field to GQL transaction object [#1481]
- Add `blocksrange` filter to GQL transaction lookup [#1468]

### Changed
### Removed
- Remove hardcoded genesis checks [#1464]
- Remove provisioners list updates at every block [#1479]

## [0.6.0] - 2022-09-07

Expand Down Expand Up @@ -87,6 +89,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

<!-- Issues -->

[#1481]: https://github.com/dusk-network/dusk-blockchain/issues/1481
[#1479]: https://github.com/dusk-network/dusk-blockchain/issues/1479
[#1464]: https://github.com/dusk-network/dusk-blockchain/issues/1464
[#1468]: https://github.com/dusk-network/dusk-blockchain/issues/1468
[#1457]: https://github.com/dusk-network/dusk-blockchain/issues/1457
Expand Down
1 change: 1 addition & 0 deletions pkg/gql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ NB: The examples from below represent only query structures. To send a query as
gasprice
gasspent
json
raw
size
txerror
txid
Expand Down
2 changes: 2 additions & 0 deletions pkg/gql/query/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type (
JSON string
TxError string
ContractInfo *contractInfo `json:"contractinfo"`
Raw []byte
}
)

Expand All @@ -80,6 +81,7 @@ func newQueryTx(tx core.ContractCall, blockHash []byte, timestamp int64, blockhe
qd.GasPrice = decoded.Fee.GasPrice

qd.GasSpent = tx.GasSpent()
qd.Raw = tx.StandardTx().Data

qd.BlockHash = blockHash
qd.BlockTimestamp = timestamp
Expand Down
29 changes: 29 additions & 0 deletions pkg/gql/query/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package query

import (
b64 "encoding/base64"
"encoding/hex"
"time"

Expand Down Expand Up @@ -122,6 +123,9 @@ var Transaction = graphql.NewObject(
"contractinfo": &graphql.Field{
Type: ContractInfo,
},
"raw": &graphql.Field{
Type: Base64,
},
},
},
)
Expand Down Expand Up @@ -171,6 +175,31 @@ var Hex = graphql.NewScalar(graphql.ScalarConfig{
},
})

// Base64 is the graphql object representing a base64 scalar.
var Base64 = graphql.NewScalar(graphql.ScalarConfig{
Name: "Base64",
Description: "Base64 scalar type represents a byte array",
// Serialize serializes `CustomID` to string.
Serialize: func(value interface{}) interface{} {
switch value := value.(type) {
case []byte:
return b64.StdEncoding.EncodeToString(value)
default:
return nil
}
},
// ParseValue parses GraphQL variables from `string` to `[]byte`.
ParseValue: func(value interface{}) interface{} {
// not implemented
return nil
},
// ParseLiteral parses GraphQL AST value to `CustomID`.
ParseLiteral: func(valueAST ast.Value) interface{} {
// not implemented
return nil
},
})

// UnixTimestamp the one and only.
var UnixTimestamp = graphql.NewScalar(graphql.ScalarConfig{
Name: "UnixTimestamp",
Expand Down

0 comments on commit ad774bf

Please sign in to comment.