Skip to content

Commit edb3b14

Browse files
asimm241zone117x
authored andcommitted
feat: add rosetta api schema for type information
1 parent f468945 commit edb3b14

20 files changed

+803
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema",
3+
"$id": "rosetta-network-list-request",
4+
"type": "object",
5+
"title": "RosettaNetworkListRequest",
6+
"description": "This endpoint returns a list of NetworkIdentifiers that the Rosetta server supports.",
7+
"required": [],
8+
"properties": {
9+
"metadata": {
10+
"type": "object",
11+
"description": "A MetadataRequest is utilized in any request where the only argument is optional metadata.",
12+
"required": []
13+
}
14+
}
15+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema",
3+
"$id": "rosetta-network-list-response.schema.json",
4+
"type": "object",
5+
"title": "RosettaNetworkListResponse",
6+
"description": "A NetworkListResponse contains all NetworkIdentifiers that the node can serve information for.",
7+
"required": ["network_identifiers"],
8+
"properties": {
9+
"network_identifiers": {
10+
"type": "array",
11+
"description": "The network_identifier specifies which network a particular object is associated with.",
12+
"items": {
13+
"$ref": "./../../entities/rosetta/rosetta-network-identifier.schema.json"
14+
}
15+
}
16+
}
17+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema",
3+
"$id": "Rosetta-options-request",
4+
"type": "object",
5+
"title": "RosettaOptionsRequest",
6+
"description": "TThis endpoint returns the version information and allowed network-specific types for a NetworkIdentifier. Any NetworkIdentifier returned by /network/list should be accessible here. Because options are retrievable in the context of a NetworkIdentifier, it is possible to define unique options for each network.",
7+
"required": ["network_identifier"],
8+
"properties": {
9+
"network_identifier": {
10+
"$ref": "../../entities/rosetta/rosetta-network-identifier.schema.json"
11+
},
12+
"metadata": {
13+
"type": "object",
14+
"title": "The metadata schema",
15+
"description": "An explanation about the purpose of this instance."
16+
}
17+
}
18+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema",
3+
"$id": "rosetta-network-options",
4+
"type": "object",
5+
"title": "RosettaNetworkOptionsResponse",
6+
"description": "NetworkOptionsResponse contains information about the versioning of the node and the allowed operation statuses, operation types, and errors.",
7+
"required": ["version", "allow"],
8+
"properties": {
9+
"version": {
10+
"type": "object",
11+
"description": "The Version object is utilized to inform the client of the versions of different components of the Rosetta implementation.",
12+
"required": ["rosetta_version", "node_version"],
13+
"properties": {
14+
"rosetta_version": {
15+
"type": "string",
16+
"description": "The rosetta_version is the version of the Rosetta interface the implementation adheres to. This can be useful for clients looking to reliably parse responses."
17+
},
18+
"node_version": {
19+
"type": "string",
20+
"description": "The node_version is the canonical version of the node runtime. This can help clients manage deployments."
21+
},
22+
"middleware_version": {
23+
"type": "string",
24+
"description": "When a middleware server is used to adhere to the Rosetta interface, it should return its version here. This can help clients manage deployments."
25+
},
26+
"metadata": {
27+
"type": "object",
28+
"description": "Any other information that may be useful about versioning of dependent services should be returned here."
29+
}
30+
}
31+
},
32+
"allow": {
33+
"type": "object",
34+
"description": "Allow specifies supported Operation status, Operation types, and all possible error statuses. This Allow object is used by clients to validate the correctness of a Rosetta Server implementation. It is expected that these clients will error if they receive some response that contains any of the above information that is not specified here.",
35+
"required": ["operation_statuses", "operation_types", "errors", "historical_balance_lookup"],
36+
"properties": {
37+
"operation_statuses": {
38+
"type": "array",
39+
"description": "All Operation.Status this implementation supports. Any status that is returned during parsing that is not listed here will cause client validation to error.",
40+
"items": {
41+
"$ref": "./../../entities/rosetta/rosetta-operation-statuses.schema.json"
42+
}
43+
},
44+
"operation_types": {
45+
"type": "array",
46+
"description": "All Operation.Type this implementation supports. Any type that is returned during parsing that is not listed here will cause client validation to error.",
47+
"items": {
48+
"anyOf": [
49+
{
50+
"type": "string"
51+
}
52+
]
53+
}
54+
},
55+
"errors": {
56+
"type": "array",
57+
"description": "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.",
58+
"items": {
59+
"$ref": "./../../entities/rosetta/rosetta-error.schema.json"
60+
}
61+
},
62+
"historical_balance_lookup": {
63+
"type": "boolean",
64+
"description": "Any Rosetta implementation that supports querying the balance of an account at any height in the past should set this to true."
65+
}
66+
}
67+
}
68+
}
69+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema",
3+
"$id": "Rosetta-options-request",
4+
"type": "object",
5+
"title": "RosettaStatusRequest",
6+
"description": "This endpoint returns the current status of the network requested. Any NetworkIdentifier returned by /network/list should be accessible here.",
7+
"required": ["network_identifier"],
8+
"properties": {
9+
"network_identifier": {
10+
"$ref": "../../entities/rosetta/rosetta-network-identifier.schema.json"
11+
},
12+
"metadata": {
13+
"type": "object",
14+
"title": "The metadata schema",
15+
"description": "An explanation about the purpose of this instance."
16+
}
17+
}
18+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema",
3+
"$id": "rosetta-network-status.schema.json",
4+
"type": "object",
5+
"title": "RosettaNetworkStatusResponse",
6+
"description": "NetworkStatusResponse contains basic information about the node's view of a blockchain network. It is assumed that any BlockIdentifier.Index less than or equal to CurrentBlockIdentifier.Index can be queried. 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. If a Rosetta implementation performs some pre-sync before it is possible to query blocks, sync_status should be populated so that clients can still monitor healthiness. Without this field, it may appear that the implementation is stuck syncing and needs to be terminated.",
7+
"required": [
8+
"current_block_identifier",
9+
"current_block_timestamp",
10+
"genesis_block_identifier",
11+
"peers"
12+
],
13+
"properties": {
14+
"current_block_identifier": {
15+
"$ref": "./../../entities/rosetta/rosetta-block-identifier.schema.json"
16+
},
17+
"current_block_timestamp": {
18+
"type": "integer",
19+
"description": "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."
20+
},
21+
"genesis_block_identifier": {
22+
"$ref": "./../../entities/rosetta/rosetta-genesis-block-identifier.schema.json"
23+
},
24+
"oldest_block_identifier": {
25+
"$ref": "./../../entities/rosetta/rosetta-oldest-block-identifier.schema.json"
26+
},
27+
"sync_status": {
28+
"$ref": "./../../entities/rosetta/rosetta-sync-status.schema.json"
29+
},
30+
"peers": {
31+
"type": "array",
32+
"description": "Peers information",
33+
"items": {
34+
"$ref": "./../../entities/rosetta/rosetta-network-peers.schema.json"
35+
}
36+
}
37+
},
38+
"additionalProperties": true
39+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"type": "object",
3+
"title": "RosettaAccount",
4+
"description": "The account_identifier uniquely identifies an account within a network. All fields in the account_identifier are utilized to determine this uniqueness (including the metadata field, if populated).",
5+
"required": ["address"],
6+
"properties": {
7+
"address": {
8+
"type": "string",
9+
"description": "The address may be a cryptographic public key (or some encoding of it) or a provided username."
10+
},
11+
"sub_account": {
12+
"$ref": "./rosetta-sub-account.schema.json"
13+
},
14+
"metadata": {
15+
"type": "object",
16+
"description": "Blockchains that utilize a username model (where the address is not a derivative of a cryptographic public key) should specify the public key(s) owned by the address in metadata.",
17+
"required": [],
18+
"additionalProperties": true
19+
}
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"type": "object",
3+
"title": "RosettaAmount",
4+
"description": "Amount is some Value of a Currency. It is considered invalid to specify a Value without a Currency.",
5+
"required": ["value", "currency"],
6+
"properties": {
7+
"value": {
8+
"type": "string",
9+
"description": "Value of the transaction in atomic units represented as an arbitrary-sized signed integer. For example, 1 BTC would be represented by a value of 100000000."
10+
},
11+
"currency": {
12+
"$ref": "./rosetta-currency.schema.json"
13+
},
14+
"metadata": {
15+
"type": "object",
16+
"description": "An explanation about the purpose of this instance.",
17+
"required": [],
18+
"additionalProperties": true
19+
}
20+
}
21+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"$id": "rosetta-block-identifier.schema.json",
3+
"type": "object",
4+
"title": "RosettaBlockIdentifier",
5+
"description": "The block_identifier uniquely identifies a block in a particular network.",
6+
"required": ["index", "hash"],
7+
"properties": {
8+
"index": {
9+
"type": "integer",
10+
"description": "This is also known as the block height."
11+
},
12+
"hash": {
13+
"type": "string",
14+
"description": "Block hash"
15+
}
16+
}
17+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"type": "object",
3+
"title": "RosettaCoin",
4+
"description": "If a blockchain is UTXO-based, all unspent Coins owned by an account_identifier should be returned alongside the balance. It is highly recommended to populate this field so that users of the Rosetta API implementation don't need to maintain their own indexer to track their UTXOs.",
5+
"required": ["coin_identifier", "amount"],
6+
"properties": {
7+
"coin_identifier": {
8+
"type": "object",
9+
"description": "CoinIdentifier uniquely identifies a Coin.",
10+
"required": ["identifier"],
11+
"properties": {
12+
"identifier": {
13+
"type": "string",
14+
"description": "Identifier should be populated with a globally unique identifier of a Coin. In Bitcoin, this identifier would be transaction_hash:index."
15+
}
16+
}
17+
},
18+
"amount": {
19+
"$ref": "./rosetta-amount.schema.json"
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)