diff --git a/client/client.go b/client/client.go index 02c24773..9ce83b26 100644 --- a/client/client.go +++ b/client/client.go @@ -41,7 +41,7 @@ var ( ErrRetriable = errors.New("retriable http status code received") ) -// APIClient manages communication with the Rosetta API v1.4.10 +// APIClient manages communication with the Rosetta API v1.4.12 // In most cases there should be only one, shared, APIClient. type APIClient struct { cfg *Configuration diff --git a/codegen.sh b/codegen.sh index 4b4e5b2c..6cf47b50 100755 --- a/codegen.sh +++ b/codegen.sh @@ -53,7 +53,7 @@ done rm -rf tmp; # Download spec file from releases -ROSETTA_SPEC_VERSION=1.4.10 +ROSETTA_SPEC_VERSION=1.4.12 curl -L https://github.com/coinbase/rosetta-specifications/releases/download/v${ROSETTA_SPEC_VERSION}/api.json -o api.json; # Generate client + types code @@ -121,8 +121,9 @@ sed "${SED_IFLAG[@]}" 's/*CoinAction/CoinAction/g' client/* server/*; sed "${SED_IFLAG[@]}" 's/*ExemptionType/ExemptionType/g' client/* server/*; sed "${SED_IFLAG[@]}" 's/*BlockEventType/BlockEventType/g' client/* server/*; sed "${SED_IFLAG[@]}" 's/*Direction/Direction/g' client/* server/*; +sed "${SED_IFLAG[@]}" 's/*Case/Case/g' client/* server/*; -# Fix CurveTypes, SignatureTypes, CoinActions, ExemptionTypes, Direction +# Fix CurveTypes, SignatureTypes, CoinActions, ExemptionTypes, Direction, Case sed "${SED_IFLAG[@]}" 's/SECP256K1/Secp256k1/g' client/* server/*; sed "${SED_IFLAG[@]}" 's/SECP256R1/Secp256r1/g' client/* server/*; sed "${SED_IFLAG[@]}" 's/EDWARDS25519/Edwards25519/g' client/* server/*; @@ -132,6 +133,7 @@ sed "${SED_IFLAG[@]}" 's/ECDSA/Ecdsa/g' client/* server/*; sed "${SED_IFLAG[@]}" 's/ED25519/Ed25519/g' client/* server/*; sed "${SED_IFLAG[@]}" 's/SCHNORR_1/Schnorr1/g' client/* server/*; sed "${SED_IFLAG[@]}" 's/SCHNORR_POSEIDON/SchnorrPoseidon/g' client/* server/*; +sed "${SED_IFLAG[@]}" 's/PALLAS/Pallas/g' client/* server/*; sed "${SED_IFLAG[@]}" 's/CREATED/CoinCreated/g' client/* server/*; sed "${SED_IFLAG[@]}" 's/SPENT/CoinSpent/g' client/* server/*; sed "${SED_IFLAG[@]}" 's/GREATER_OR_EQUAL/BalanceGreaterOrEqual/g' client/* server/*; @@ -139,6 +141,10 @@ sed "${SED_IFLAG[@]}" 's/LESS_OR_EQUAL/BalanceLessOrEqual/g' client/* server/*; sed "${SED_IFLAG[@]}" 's/DYNAMIC/BalanceDynamic/g' client/* server/*; sed "${SED_IFLAG[@]}" 's/FORWARD/Forward/g' client/* server/*; sed "${SED_IFLAG[@]}" 's/BACKWARD/Backward/g' client/* server/*; +sed "${SED_IFLAG[@]}" 's/UPPER_CASE/UpperCase/g' client/* server/*; +sed "${SED_IFLAG[@]}" 's/LOWER_CASE/LowerCase/g' client/* server/*; +sed "${SED_IFLAG[@]}" 's/CASE_SENSITIVE/CaseSensitive/g' client/* server/*; +sed "${SED_IFLAG[@]}" 's/NULL/Null/g' client/* server/*; # Convert HexBytes to Bytes sed "${SED_IFLAG[@]}" '/Hex-encoded public key bytes in the format specified by the CurveType/d' client/* server/*; diff --git a/types/allow.go b/types/allow.go index a22374cf..ee6804a9 100644 --- a/types/allow.go +++ b/types/allow.go @@ -51,5 +51,7 @@ type Allow struct { // Any Rosetta implementation that can update an AccountIdentifier's unspent coins based on the // contents of the mempool should populate this field as true. If false, requests to // `/account/coins` that set `include_mempool` as true will be automatically rejected. - MempoolCoins bool `json:"mempool_coins"` + MempoolCoins bool `json:"mempool_coins"` + BlockHashCase Case `json:"block_hash_case,omitempty"` + TransactionHashCase Case `json:"transaction_hash_case,omitempty"` } diff --git a/types/block_identifier.go b/types/block_identifier.go index 1e0e8c38..32688aaa 100644 --- a/types/block_identifier.go +++ b/types/block_identifier.go @@ -19,6 +19,8 @@ package types // BlockIdentifier The block_identifier uniquely identifies a block in a particular network. type BlockIdentifier struct { // This is also known as the block height. - Index int64 `json:"index"` - Hash string `json:"hash"` + Index int64 `json:"index"` + // This should be normalized according to the case specified in the block_hash_case network + // options. + Hash string `json:"hash"` } diff --git a/types/case.go b/types/case.go new file mode 100644 index 00000000..9717780a --- /dev/null +++ b/types/case.go @@ -0,0 +1,28 @@ +// Copyright 2022 Coinbase, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated by: OpenAPI Generator (https://openapi-generator.tech) + +package types + +// Case Case specifies the expected case for strings and hashes. +type Case string + +// List of Case +const ( + UpperCase Case = "upper_case" + LowerCase Case = "lower_case" + CaseSensitive Case = "case_sensitive" + Null Case = "null" +) diff --git a/types/curve_type.go b/types/curve_type.go index 45bba872..4100c9c0 100644 --- a/types/curve_type.go +++ b/types/curve_type.go @@ -22,6 +22,7 @@ package types // (255-bits) || x-sign-bit (1-bit)` - `32 bytes` (https://ed25519.cr.yp.to/ed25519-20110926.pdf) * // tweedle: 1st pk : Fq.t (32 bytes) || 2nd pk : Fq.t (32 bytes) // (https://github.com/CodaProtocol/coda/blob/develop/rfcs/0038-rosetta-construction-api.md#marshal-keys) +// * pallas: `x (255 bits) || y-parity-bit (1-bit) - 32 bytes` (https://github.com/zcash/pasta) type CurveType string // List of CurveType @@ -30,4 +31,5 @@ const ( Secp256r1 CurveType = "secp256r1" Edwards25519 CurveType = "edwards25519" Tweedle CurveType = "tweedle" + Pallas CurveType = "pallas" ) diff --git a/types/sync_status.go b/types/sync_status.go index 55ccad97..0015fe86 100644 --- a/types/sync_status.go +++ b/types/sync_status.go @@ -32,7 +32,7 @@ type SyncStatus struct { TargetIndex *int64 `json:"target_index,omitempty"` // Stage is the phase of the sync process. Stage *string `json:"stage,omitempty"` - // sycned is a boolean that indicates if an implementation has synced up to the most recent + // synced is a boolean that indicates if an implementation has synced up to the most recent // block. If this field is not populated, the caller should rely on a traditional tip timestamp // comparison to determine if an implementation is synced. This field is particularly useful for // quiescent blockchains (blocks only produced when there are pending transactions). In these diff --git a/types/transaction_identifier.go b/types/transaction_identifier.go index 24202c4d..2cd6e233 100644 --- a/types/transaction_identifier.go +++ b/types/transaction_identifier.go @@ -20,6 +20,7 @@ package types // particular network and block or in the mempool. type TransactionIdentifier struct { // Any transactions that are attributable only to a block (ex: a block event) should use the - // hash of the block as the identifier. + // hash of the block as the identifier. This should be normalized according to the case + // specified in the transaction_hash_case in network options. Hash string `json:"hash"` } diff --git a/types/types.go b/types/types.go index 9742eaa1..c49f04b3 100644 --- a/types/types.go +++ b/types/types.go @@ -18,5 +18,5 @@ const ( // RosettaAPIVersion is the version of the Rosetta API // specification used to generate code for this release // of the SDK. - RosettaAPIVersion = "1.4.10" + RosettaAPIVersion = "1.4.12" )