From 880e03ee2fa222bece019e54457eddb34acebde8 Mon Sep 17 00:00:00 2001 From: Patrick O'Grady Date: Fri, 26 Jun 2020 16:32:53 -0700 Subject: [PATCH] New types --- types/allow.go | 3 ++ types/construction_combine_request.go | 26 +++++++++++++++++ types/construction_combine_response.go | 23 +++++++++++++++ types/construction_derive_request.go | 27 +++++++++++++++++ types/construction_derive_response.go | 25 ++++++++++++++++ ...equest.go => construction_hash_request.go} | 7 +++-- types/construction_hash_response.go | 23 +++++++++++++++ types/construction_metadata_response.go | 3 +- types/construction_parse_request.go | 28 ++++++++++++++++++ types/construction_parse_response.go | 27 +++++++++++++++++ types/construction_payloads_request.go | 26 +++++++++++++++++ types/construction_payloads_response.go | 26 +++++++++++++++++ types/construction_preprocess_request.go | 26 +++++++++++++++++ types/construction_preprocess_response.go | 25 ++++++++++++++++ types/currency.go | 6 ++-- types/curve_type.go | 28 ++++++++++++++++++ types/error.go | 4 +++ types/network_status_response.go | 5 +++- types/operation.go | 2 +- types/operation_identifier.go | 7 +++-- types/operation_status.go | 2 +- types/public_key.go | 25 ++++++++++++++++ types/signature.go | 28 ++++++++++++++++++ types/signature_type.go | 29 +++++++++++++++++++ types/signing_payload.go | 27 +++++++++++++++++ types/sub_account_identifier.go | 4 +-- types/transaction.go | 2 +- 27 files changed, 447 insertions(+), 17 deletions(-) create mode 100644 types/construction_combine_request.go create mode 100644 types/construction_combine_response.go create mode 100644 types/construction_derive_request.go create mode 100644 types/construction_derive_response.go rename types/{mempool_request.go => construction_hash_request.go} (78%) create mode 100644 types/construction_hash_response.go create mode 100644 types/construction_parse_request.go create mode 100644 types/construction_parse_response.go create mode 100644 types/construction_payloads_request.go create mode 100644 types/construction_payloads_response.go create mode 100644 types/construction_preprocess_request.go create mode 100644 types/construction_preprocess_response.go create mode 100644 types/curve_type.go create mode 100644 types/public_key.go create mode 100644 types/signature.go create mode 100644 types/signature_type.go create mode 100644 types/signing_payload.go diff --git a/types/allow.go b/types/allow.go index c5e1dba9..66d672a7 100644 --- a/types/allow.go +++ b/types/allow.go @@ -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"` } diff --git a/types/construction_combine_request.go b/types/construction_combine_request.go new file mode 100644 index 00000000..0d9b198f --- /dev/null +++ b/types/construction_combine_request.go @@ -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"` +} diff --git a/types/construction_combine_response.go b/types/construction_combine_response.go new file mode 100644 index 00000000..40593260 --- /dev/null +++ b/types/construction_combine_response.go @@ -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"` +} diff --git a/types/construction_derive_request.go b/types/construction_derive_request.go new file mode 100644 index 00000000..df6dcea3 --- /dev/null +++ b/types/construction_derive_request.go @@ -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"` +} diff --git a/types/construction_derive_response.go b/types/construction_derive_response.go new file mode 100644 index 00000000..174a92d9 --- /dev/null +++ b/types/construction_derive_response.go @@ -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"` +} diff --git a/types/mempool_request.go b/types/construction_hash_request.go similarity index 78% rename from types/mempool_request.go rename to types/construction_hash_request.go index b54625e7..93f033a5 100644 --- a/types/mempool_request.go +++ b/types/construction_hash_request.go @@ -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"` } diff --git a/types/construction_hash_response.go b/types/construction_hash_response.go new file mode 100644 index 00000000..6eee417a --- /dev/null +++ b/types/construction_hash_response.go @@ -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"` +} diff --git a/types/construction_metadata_response.go b/types/construction_metadata_response.go index 219f95d6..e294009e 100644 --- a/types/construction_metadata_response.go +++ b/types/construction_metadata_response.go @@ -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"` } diff --git a/types/construction_parse_request.go b/types/construction_parse_request.go new file mode 100644 index 00000000..0f8b249b --- /dev/null +++ b/types/construction_parse_request.go @@ -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"` +} diff --git a/types/construction_parse_response.go b/types/construction_parse_response.go new file mode 100644 index 00000000..551f0892 --- /dev/null +++ b/types/construction_parse_response.go @@ -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"` +} diff --git a/types/construction_payloads_request.go b/types/construction_payloads_request.go new file mode 100644 index 00000000..e47118ab --- /dev/null +++ b/types/construction_payloads_request.go @@ -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"` +} diff --git a/types/construction_payloads_response.go b/types/construction_payloads_response.go new file mode 100644 index 00000000..0352dfd0 --- /dev/null +++ b/types/construction_payloads_response.go @@ -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"` +} diff --git a/types/construction_preprocess_request.go b/types/construction_preprocess_request.go new file mode 100644 index 00000000..f765c8af --- /dev/null +++ b/types/construction_preprocess_request.go @@ -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"` +} diff --git a/types/construction_preprocess_response.go b/types/construction_preprocess_response.go new file mode 100644 index 00000000..66c94f68 --- /dev/null +++ b/types/construction_preprocess_response.go @@ -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"` +} diff --git a/types/currency.go b/types/currency.go index 26aafef1..6dd71651 100644 --- a/types/currency.go +++ b/types/currency.go @@ -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"` } diff --git a/types/curve_type.go b/types/curve_type.go new file mode 100644 index 00000000..22dd4e0b --- /dev/null +++ b/types/curve_type.go @@ -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" +) diff --git a/types/error.go b/types/error.go index 7fdda38b..4bf5c3e1 100644 --- a/types/error.go +++ b/types/error.go @@ -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"` } diff --git a/types/network_status_response.go b/types/network_status_response.go index b52dfbf6..4d3009b2 100644 --- a/types/network_status_response.go +++ b/types/network_status_response.go @@ -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"` } diff --git a/types/operation.go b/types/operation.go index 8c7dff31..f6a065bf 100644 --- a/types/operation.go +++ b/types/operation.go @@ -27,7 +27,7 @@ type Operation struct { // linking operations in a call tree. RelatedOperations []*OperationIdentifier `json:"related_operations,omitempty"` // The network-specific type of the operation. Ensure that any type that can be returned here is - // also specified in the NetowrkStatus. This can be very useful to downstream consumers that + // also specified in the NetworkStatus. This can be very useful to downstream consumers that // parse all block data. Type string `json:"type"` // The network-specific status of the operation. Status is not defined on the transaction object diff --git a/types/operation_identifier.go b/types/operation_identifier.go index 6f27f6a3..4501228d 100644 --- a/types/operation_identifier.go +++ b/types/operation_identifier.go @@ -20,11 +20,12 @@ package types // transaction. type OperationIdentifier struct { // The operation index is used to ensure each operation has a unique identifier within a - // transaction. To clarify, there may not be any notion of an operation index in the blockchain - // being described. + // transaction. This index is only relative to the transaction and NOT GLOBAL. The operations in + // each transaction should start from index 0. To clarify, there may not be any notion of an + // operation index in the blockchain being described. Index int64 `json:"index"` // Some blockchains specify an operation index that is essential for client use. For example, - // Bitcoin uses a network_index to identify which UTXO was used in a transaction. network_index + // Bitcoin uses a network_index to identify which UTXO was used in a transaction. network_index // should not be populated if there is no notion of an operation index in a blockchain // (typically most account-based blockchains). NetworkIndex *int64 `json:"network_index,omitempty"` diff --git a/types/operation_status.go b/types/operation_status.go index 5d5c960d..46e6a363 100644 --- a/types/operation_status.go +++ b/types/operation_status.go @@ -24,7 +24,7 @@ type OperationStatus struct { // An Operation is considered successful if the Operation.Amount should affect the // Operation.Account. Some blockchains (like Bitcoin) only include successful operations in // blocks but other blockchains (like Ethereum) include unsuccessful operations that incur a - // fee. To reconcile the computed balance from the stream of Operations, it is critical to + // fee. To reconcile the computed balance from the stream of Operations, it is critical to // understand which Operation.Status indicate an Operation is successful and should affect an // Account. Successful bool `json:"successful"` diff --git a/types/public_key.go b/types/public_key.go new file mode 100644 index 00000000..6224f47e --- /dev/null +++ b/types/public_key.go @@ -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 + +// PublicKey PublicKey contains a public key byte array for a particular CurveType encoded in hex. +// Note that there is no PrivateKey struct as this is NEVER the concern of an implementation. +type PublicKey struct { + // Hex-encoded public key bytes in the format specified by the CurveType. + HexBytes string `json:"hex_bytes"` + CurveType CurveType `json:"curve_type"` +} diff --git a/types/signature.go b/types/signature.go new file mode 100644 index 00000000..4fa43506 --- /dev/null +++ b/types/signature.go @@ -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 + +// Signature Signature contains the payload that was signed, the public keys of the keypairs used to +// produce the signature, the signature (encoded in hex), and the SignatureType. PublicKey is often +// times not known during construction of the signing payloads but may be needed to combine +// signatures properly. +type Signature struct { + SigningPayload *SigningPayload `json:"signing_payload"` + PublicKey *PublicKey `json:"public_key"` + SignatureType SignatureType `json:"signature_type"` + HexBytes string `json:"hex_bytes"` +} diff --git a/types/signature_type.go b/types/signature_type.go new file mode 100644 index 00000000..81bec148 --- /dev/null +++ b/types/signature_type.go @@ -0,0 +1,29 @@ +// 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 + +// SignatureType SignatureType is the type of a cryptographic signature. * ecdsa: `r (32-bytes) || s +// (32-bytes)` - `64 bytes` * ecdsa_recovery: `r (32-bytes) || s (32-bytes) || v (1-byte)` - `65 +// bytes` * ed25519: `R (32-byte) || s (32-bytes)` - `64 bytes` +type SignatureType string + +// List of SignatureType +const ( + Ecdsa SignatureType = "ecdsa" + EcdsaRecovery SignatureType = "ecdsa_recovery" + Ed25519 SignatureType = "ed25519" +) diff --git a/types/signing_payload.go b/types/signing_payload.go new file mode 100644 index 00000000..c237d40e --- /dev/null +++ b/types/signing_payload.go @@ -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 + +// SigningPayload SigningPayload is signed by the client with the keypair associated with an address +// using the specified SignatureType. SignatureType can be optionally populated if there is a +// restriction on the signature scheme that can be used to sign the payload. +type SigningPayload struct { + // The network-specific address of the account that should sign the payload. + Address string `json:"address"` + HexBytes string `json:"hex_bytes"` + SignatureType SignatureType `json:"signature_type,omitempty"` +} diff --git a/types/sub_account_identifier.go b/types/sub_account_identifier.go index b110a46f..730f0644 100644 --- a/types/sub_account_identifier.go +++ b/types/sub_account_identifier.go @@ -24,7 +24,7 @@ type SubAccountIdentifier struct { // that uniquely specifies a SubAccount. Address string `json:"address"` // If the SubAccount address is not sufficient to uniquely specify a SubAccount, any other - // identifying information can be stored here. It is important to note that two SubAccounts - // with identical addresses but differing metadata will not be considered equal by clients. + // identifying information can be stored here. It is important to note that two SubAccounts with + // identical addresses but differing metadata will not be considered equal by clients. Metadata map[string]interface{} `json:"metadata,omitempty"` } diff --git a/types/transaction.go b/types/transaction.go index ab918322..63a2fcfb 100644 --- a/types/transaction.go +++ b/types/transaction.go @@ -21,7 +21,7 @@ package types type Transaction struct { TransactionIdentifier *TransactionIdentifier `json:"transaction_identifier"` Operations []*Operation `json:"operations"` - // Transactions that are related to other transactions (like a cross-shard transactioin) should + // Transactions that are related to other transactions (like a cross-shard transaction) should // include the tranaction_identifier of these transactions in the metadata. Metadata map[string]interface{} `json:"metadata,omitempty"` }