Skip to content

Commit

Permalink
Add Support for Related Transactions (#74)
Browse files Browse the repository at this point in the history
* add modeling for related transactions

* bump version

* fix quotes

* nit
  • Loading branch information
varunpcb authored Jan 6, 2021
1 parent b76365b commit c820407
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 2 deletions.
35 changes: 34 additions & 1 deletion api.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"openapi":"3.0.2",
"info": {
"version":"1.4.9",
"version":"1.4.10",
"title":"Rosetta",
"description":"Build Once. Integrate Your Blockchain Everywhere.",
"license": {
Expand Down Expand Up @@ -1056,6 +1056,12 @@
"$ref":"#/components/schemas/Operation"
}
},
"related_transactions": {
"type":"array",
"items": {
"$ref":"#/components/schemas/RelatedTransaction"
}
},
"metadata": {
"description":"Transactions that are related to other transactions (like a cross-shard transaction) should include the tranaction_identifier of these transactions in the metadata.",
"type":"object",
Expand Down Expand Up @@ -1557,6 +1563,33 @@
}
}
},
"RelatedTransaction": {
"description":"The related_transaction allows implementations to link together multiple transactions. An unpopulated network identifier indicates that the related transaction is on the same network.",
"type":"object",
"required": [
"transaction_identifier",
"direction"
],
"properties": {
"network_identifier": {
"$ref":"#/components/schemas/NetworkIdentifier"
},
"transaction_identifier": {
"$ref":"#/components/schemas/TransactionIdentifier"
},
"direction": {
"$ref":"#/components/schemas/Direction"
}
}
},
"Direction": {
"description":"Used by RelatedTransaction to indicate the direction of the relation (i.e. cross-shard/cross-network sends may reference `backward` to an earlier transaction and async execution may reference `forward`). Can be used to indicate if a transaction relation is from child to parent or the reverse.",
"type":"string",
"enum": [
"forward",
"backward"
]
},
"AccountBalanceRequest": {
"description":"An AccountBalanceRequest is utilized to make a balance request on the /account/balance endpoint. If the block_identifier is populated, a historical balance query should be performed.",
"type":"object",
Expand Down
6 changes: 5 additions & 1 deletion api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

openapi: 3.0.2
info:
version: 1.4.9
version: 1.4.10
title: Rosetta
description: |
Build Once. Integrate Your Blockchain Everywhere.
Expand Down Expand Up @@ -801,6 +801,10 @@ components:
$ref: 'models/Operator.yaml'
BlockTransaction:
$ref: 'models/BlockTransaction.yaml'
RelatedTransaction:
$ref: 'models/RelatedTransaction.yaml'
Direction:
$ref: 'models/Direction.yaml'

# Request/Responses
AccountBalanceRequest:
Expand Down
21 changes: 21 additions & 0 deletions models/Direction.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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.
description: |
Used by RelatedTransaction to indicate the direction of the relation (i.e. cross-shard/cross-network sends may
reference `backward` to an earlier transaction and async execution may reference `forward`). Can be used to indicate if
a transaction relation is from child to parent or the reverse.
type: string
enum:
- forward
- backward
28 changes: 28 additions & 0 deletions models/RelatedTransaction.yaml
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.

description: |
The related_transaction allows implementations to link together multiple transactions.
An unpopulated network identifier indicates that the related transaction is on the same network.
type: object
required:
- transaction_identifier
- direction
properties:
network_identifier:
$ref: 'NetworkIdentifier.yaml'
transaction_identifier:
$ref: 'TransactionIdentifier.yaml'
direction:
$ref: 'Direction.yaml'
4 changes: 4 additions & 0 deletions models/Transaction.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ properties:
type: array
items:
$ref: 'Operation.yaml'
related_transactions:
type: array
items:
$ref: 'RelatedTransaction.yaml'
metadata:
description: |
Transactions that are related to other transactions (like a cross-shard transaction) should include
Expand Down

0 comments on commit c820407

Please sign in to comment.