Skip to content

Commit

Permalink
New types
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-ogrady committed Jun 26, 2020
1 parent deafbd6 commit 880e03e
Show file tree
Hide file tree
Showing 27 changed files with 447 additions and 17 deletions.
3 changes: 3 additions & 0 deletions types/allow.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,7 @@ type Allow struct {
// All Errors that this implementation could return. Any error that is returned during parsing
// that is not listed here will cause client validation to error.
Errors []*Error `json:"errors"`
// Any Rosetta implementation that supports querying the balance of an account at any height in
// the past should set this to true.
HistoricalBalanceLookup bool `json:"historical_balance_lookup"`
}
26 changes: 26 additions & 0 deletions types/construction_combine_request.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2020 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

// ConstructionCombineRequest ConstructionCombineRequest is the input to the `/construction/combine`
// endpoint. It contains the unsigned transaction blob returned by `/construction/payloads` and all
// required signatures to create a network transaction.
type ConstructionCombineRequest struct {
NetworkIdentifier *NetworkIdentifier `json:"network_identifier"`
UnsignedTransaction string `json:"unsigned_transaction"`
Signatures []*Signature `json:"signatures"`
}
23 changes: 23 additions & 0 deletions types/construction_combine_response.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2020 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

// ConstructionCombineResponse ConstructionCombineResponse is returned by `/construction/combine`.
// The network payload will be sent directly to the `construction/submit` endpoint.
type ConstructionCombineResponse struct {
SignedTransaction string `json:"signed_transaction"`
}
27 changes: 27 additions & 0 deletions types/construction_derive_request.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2020 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

// ConstructionDeriveRequest ConstructionDeriveRequest is passed to the `/construction/derive`
// endpoint. Network is provided in the request because some blockchains have different address
// formats for different networks. Metadata is provided in the request because some blockchains
// allow for multiple address types (i.e. different address for validators vs normal accounts).
type ConstructionDeriveRequest struct {
NetworkIdentifier *NetworkIdentifier `json:"network_identifier"`
PublicKey *PublicKey `json:"public_key"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
25 changes: 25 additions & 0 deletions types/construction_derive_response.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2020 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

// ConstructionDeriveResponse ConstructionDeriveResponse is returned by the `/construction/derive`
// endpoint.
type ConstructionDeriveResponse struct {
// Address in network-specific format.
Address string `json:"address"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@

package types

// MempoolRequest A MempoolRequest is utilized to retrieve all transaction identifiers in the
// mempool for a particular network_identifier.
type MempoolRequest struct {
// ConstructionHashRequest ConstructionHashRequest is the input to the `/construction/hash`
// endpoint.
type ConstructionHashRequest struct {
NetworkIdentifier *NetworkIdentifier `json:"network_identifier"`
SignedTransaction string `json:"signed_transaction"`
}
23 changes: 23 additions & 0 deletions types/construction_hash_response.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2020 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

// ConstructionHashResponse ConstructionHashResponse is the output of the `/construction/hash`
// endpoint.
type ConstructionHashResponse struct {
TransactionHash string `json:"transaction_hash"`
}
3 changes: 1 addition & 2 deletions types/construction_metadata_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
package types

// ConstructionMetadataResponse The ConstructionMetadataResponse returns network-specific metadata
// used for transaction construction. It is likely that the client will not inspect this metadata
// before passing it to a client SDK that uses it for construction.
// used for transaction construction.
type ConstructionMetadataResponse struct {
Metadata map[string]interface{} `json:"metadata"`
}
28 changes: 28 additions & 0 deletions types/construction_parse_request.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright 2020 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

// ConstructionParseRequest ConstructionParseRequest is the input to the `/construction/parse`
// endpoint. It allows the caller to parse either an unsigned or signed transaction.
type ConstructionParseRequest struct {
NetworkIdentifier *NetworkIdentifier `json:"network_identifier"`
// Signed is a boolean indicating whether the transaction is signed.
Signed bool `json:"signed"`
// This must be either the unsigned transaction blob returned by `/construction/payloads` or the
// signed transaction blob returned by `/construction/combine`.
Transaction string `json:"transaction"`
}
27 changes: 27 additions & 0 deletions types/construction_parse_response.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2020 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

// ConstructionParseResponse ConstructionParseResponse contains an array of operations that occur in
// a transaction blob. This should match the array of operations provided to
// `/construction/preprocess` and `/construction/payloads`.
type ConstructionParseResponse struct {
Operations []*Operation `json:"operations"`
// All signers of a particular transaction. If the transaction is unsigned, it should be empty.
Signers []string `json:"signers"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
26 changes: 26 additions & 0 deletions types/construction_payloads_request.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2020 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

// ConstructionPayloadsRequest ConstructionPayloadsRequest is the request to
// `/construction/payloads`. It contains the network, a slice of operations, and arbitrary metadata
// that was returned by the call to `/construction/metadata`.
type ConstructionPayloadsRequest struct {
NetworkIdentifier *NetworkIdentifier `json:"network_identifier"`
Operations []*Operation `json:"operations"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
26 changes: 26 additions & 0 deletions types/construction_payloads_response.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2020 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

// ConstructionPayloadsResponse ConstructionTransactionResponse is returned by
// `/construction/payloads`. It contains an unsigned transaction blob (that is usually needed to
// construct the a network transaction from a collection of signatures) and an array of payloads
// that must be signed by the caller.
type ConstructionPayloadsResponse struct {
UnsignedTransaction string `json:"unsigned_transaction"`
Payloads []*SigningPayload `json:"payloads"`
}
26 changes: 26 additions & 0 deletions types/construction_preprocess_request.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2020 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

// ConstructionPreprocessRequest ConstructionPreprocessRequest is passed to the
// `/construction/preprocess` endpoint so that a Rosetta implementation can determine which metadata
// it needs to request for construction.
type ConstructionPreprocessRequest struct {
NetworkIdentifier *NetworkIdentifier `json:"network_identifier"`
Operations []*Operation `json:"operations"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
25 changes: 25 additions & 0 deletions types/construction_preprocess_response.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2020 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

// ConstructionPreprocessResponse ConstructionPreprocessResponse contains the request that will be
// sent directly to `/construction/metadata`. If it is not necessary to make a request to
// `/construction/metadata`, options should be null.
type ConstructionPreprocessResponse struct {
// The options that will be sent directly to `/construction/metadata` by the caller.
Options map[string]interface{} `json:"options,omitempty"`
}
6 changes: 3 additions & 3 deletions types/currency.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ package types
type Currency struct {
// Canonical symbol associated with a currency.
Symbol string `json:"symbol"`
// Number of decimal places in the standard unit representation of the amount. For example, BTC
// Number of decimal places in the standard unit representation of the amount. For example, BTC
// has 8 decimals. Note that it is not possible to represent the value of some currency in
// atomic units that is not base 10.
Decimals int32 `json:"decimals"`
// Any additional information related to the currency itself. For example, it would be useful
// to populate this object with the contract address of an ERC-20 token.
// Any additional information related to the currency itself. For example, it would be useful to
// populate this object with the contract address of an ERC-20 token.
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
28 changes: 28 additions & 0 deletions types/curve_type.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright 2020 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

// CurveType CurveType is the type of cryptographic curve associated with a PublicKey. * secp256k1:
// SEC compressed - `33 bytes` (https://secg.org/sec1-v2.pdf#subsubsection.2.3.3) * edwards25519: `y
// (255-bits) || x-sign-bit (1-bit)` - `32 bytes` (https://ed25519.cr.yp.to/ed25519-20110926.pdf)
type CurveType string

// List of CurveType
const (
Secp256k1 CurveType = "secp256k1"
Edwards25519 CurveType = "edwards25519"
)
4 changes: 4 additions & 0 deletions types/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@ type Error struct {
Message string `json:"message"`
// An error is retriable if the same request may succeed if submitted again.
Retriable bool `json:"retriable"`
// Often times it is useful to return context specific to the request that caused the error
// (i.e. a sample of the stack trace or impacted account) in addition to the standard error
// message.
Details map[string]interface{} `json:"details,omitempty"`
}
5 changes: 4 additions & 1 deletion types/network_status_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@
package types

// NetworkStatusResponse NetworkStatusResponse contains basic information about the node's view of a
// blockchain network.
// blockchain network. If a Rosetta implementation prunes historical state, it should populate the
// optional `oldest_block_identifier` field with the oldest block available to query. If this is not
// populated, it is assumed that the `genesis_block_identifier` is the oldest queryable block.
type NetworkStatusResponse struct {
CurrentBlockIdentifier *BlockIdentifier `json:"current_block_identifier"`
// The timestamp of the block in milliseconds since the Unix Epoch. The timestamp is stored in
// milliseconds because some blockchains produce blocks more often than once a second.
CurrentBlockTimestamp int64 `json:"current_block_timestamp"`
GenesisBlockIdentifier *BlockIdentifier `json:"genesis_block_identifier"`
OldestBlockIdentifier *BlockIdentifier `json:"oldest_block_identifier,omitempty"`
Peers []*Peer `json:"peers"`
}
Loading

0 comments on commit 880e03e

Please sign in to comment.