-
Notifications
You must be signed in to change notification settings - Fork 87
Add subscriptions for pre-confirmed transactions #323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1f7f496
d8df3f8
76087b8
55fd05f
6a18e07
c56e41d
9387e37
3f63b99
b73e5cf
686d07c
cc63388
cba2cfb
7dea195
d276485
433486c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| { | ||
| "openrpc": "1.3.2", | ||
| "info": { | ||
| "version": "0.9.0-rc.2", | ||
| "version": "0.9.0-rc.3", | ||
| "title": "StarkNet WebSocket RPC API", | ||
| "license": {} | ||
| }, | ||
|
|
@@ -58,7 +58,7 @@ | |
| { | ||
| "name": "starknet_subscribeEvents", | ||
| "summary": "Events subscription", | ||
| "description": "Creates a WebSocket stream which will fire events for new Starknet events with applied filters", | ||
| "description": "Creates a WebSocket stream which will fire events for new Starknet events with applied filters. Events are emitted for all events from the specified block_id, up to the latest block", | ||
| "params": [ | ||
| { | ||
| "name": "from_address", | ||
|
|
@@ -84,6 +84,15 @@ | |
| "schema": { | ||
| "$ref": "#/components/schemas/SUBSCRIPTION_BLOCK_ID" | ||
| } | ||
| }, | ||
| { | ||
| "name": "finality_status", | ||
| "summary": "The finality status of the most recent events to include, default is ACCEPTED_ON_L2", | ||
| "required": false, | ||
| "schema": { | ||
| "type": "string", | ||
| "enum": ["PRE_CONFIRMED", "ACCEPTED_ON_L2"] | ||
| } | ||
| } | ||
| ], | ||
| "result": { | ||
|
|
@@ -107,7 +116,7 @@ | |
| { | ||
| "name": "starknet_subscriptionEvents", | ||
| "summary": "New events notification", | ||
| "description": "Notification to the client of a new event", | ||
| "description": "Notification to the client of a new event. The event also includes the finality status of the transaction emitting the event", | ||
| "params": [ | ||
| { | ||
| "name": "subscription_id", | ||
|
|
@@ -118,7 +127,14 @@ | |
| { | ||
| "name": "result", | ||
| "schema": { | ||
| "$ref": "./api/starknet_api_openrpc.json#/components/schemas/EMITTED_EVENT" | ||
| "allOf": [ | ||
| { | ||
| "$ref": "./api/starknet_api_openrpc.json#/components/schemas/EMITTED_EVENT" | ||
| }, | ||
| { | ||
| "$ref": "#/components/schemas/TXN_FINALITY_STATUS" | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| ], | ||
|
|
@@ -167,21 +183,97 @@ | |
| "errors": [] | ||
| }, | ||
| { | ||
| "name": "starknet_subscribePendingTransactions", | ||
| "summary": "New Pending Transactions subscription", | ||
| "description": "Creates a WebSocket stream which will fire events when a new pending transaction is added. While there is no mempool, this notifies of transactions in the pending block", | ||
| "name": "starknet_subscribeNewTransactionReceipts", | ||
| "summary": "New transactions receipts subscription", | ||
| "description": "Creates a WebSocket stream which will fire events when new transaction receipts are created. The endpoint receives a vector of finality statuses. An event is fired for each finality status update. It is possible for receipts for pre-confirmed transactions to be received multiple times, or not at all.", | ||
| "params": [ | ||
| { | ||
| "name": "finality_status", | ||
| "summary": "A vector of finality statuses to receive updates for, default is [ACCEPTED_ON_L2]", | ||
| "required": false, | ||
| "schema": { | ||
| "type": "array", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I'm missing why this field is an array instead of a string like starknet_subscribeEvents
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The idea was to allow to get only a subset of transaction, based on the finality you are looking fore. Only accepted_on_l2 if you don't want duplicates, and add pre_confirmed if more recent transactions are needed, and duplicates are acceptable
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BTW, do we really want to support the It'd be great if this
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kkovaacs, I agree. Supporting Re having the same semantics, we can have them as close as we can, but there are no receipts for |
||
| "items": { | ||
| "allOf": [ | ||
| { | ||
| "$ref": "./api/starknet_api_openrpc.json#/components/schemas/TXN_FINALITY_STATUS" | ||
| }, | ||
| { | ||
| "not": { | ||
| "type": "string", | ||
| "enum": ["ACCEPTED_ON_L1"] | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| "name": "sender_address", | ||
| "summary": "Filter transaction receipts to only include transactions sent by the specified addresses", | ||
| "required": false, | ||
| "schema": { | ||
| "type": "array", | ||
| "items": { | ||
| "$ref": "#/components/schemas/ADDRESS" | ||
| } | ||
| } | ||
| } | ||
| ], | ||
| "result": { | ||
| "name": "subscription_id", | ||
| "schema": { | ||
| "$ref": "#/components/schemas/SUBSCRIPTION_ID" | ||
| } | ||
| }, | ||
| "errors": [ | ||
| { | ||
| "$ref": "#/components/errors/TOO_MANY_ADDRESSES_IN_FILTER" | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "name": "starknet_subscriptionNewTransactionReceipts", | ||
| "summary": "New transaction receipt notification", | ||
| "description": "Notification to the client of a new transaction receipt, with its current finality status", | ||
| "params": [ | ||
| { | ||
| "name": "subscription_id", | ||
| "schema": { | ||
| "$ref": "#/components/schemas/SUBSCRIPTION_ID" | ||
| } | ||
| }, | ||
| { | ||
| "name": "result", | ||
| "description": "A transaction receipt", | ||
| "schema": { | ||
| "$ref": "./api/starknet_api_openrpc.json#/components/schemas/TXN_RECEIPT_WITH_BLOCK_INFO" | ||
| } | ||
| } | ||
| ], | ||
| "errors": [] | ||
| }, | ||
| { | ||
| "name": "starknet_subscribeNewTransactions", | ||
| "summary": "New transactions subscription", | ||
| "description": "Creates a WebSocket stream which will fire events when new transaction are created. The endpoint receives a vector of finality statuses. An event is fired for each finality status update. It is possible for events for pre-confirmed and candidate transactions to be received multiple times, or not at all.", | ||
| "params": [ | ||
| { | ||
| "name": "transaction_details", | ||
| "summary": "Get all transaction details, and not only the hash. If not provided, only hash is returned. Default is false", | ||
| "name": "finality_status", | ||
| "summary": "A vector of finality statuses to receive updates for, default is [ACCEPTED_ON_L2]", | ||
| "required": false, | ||
| "schema": { | ||
| "type": "boolean" | ||
| "type": "array", | ||
| "items": { | ||
| "items": { | ||
| "$ref": "#/components/schemas/TXN_STATUS_WITHOUT_L1" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| "name": "sender_address", | ||
| "summary": "Filter transactions to only receive notification from address list", | ||
| "summary": "Filter to only include transactions sent by the specified addresses", | ||
| "required": false, | ||
| "schema": { | ||
| "type": "array", | ||
|
|
@@ -204,9 +296,9 @@ | |
| ] | ||
| }, | ||
| { | ||
| "name": "starknet_subscriptionPendingTransactions", | ||
| "summary": "New pending transaction notification", | ||
| "description": "Notification to the client of a new pending transaction", | ||
| "name": "starknet_subscriptionNewTransaction", | ||
| "summary": "New transaction notification", | ||
| "description": "Notification to the client of a new transaction, with its current finality status", | ||
| "params": [ | ||
| { | ||
| "name": "subscription_id", | ||
|
|
@@ -216,14 +308,23 @@ | |
| }, | ||
| { | ||
| "name": "result", | ||
| "description": "Either a tranasaction hash or full transaction details, based on subscription", | ||
| "description": "A transaction and its current finality status", | ||
| "schema": { | ||
| "oneOf": [ | ||
| "allOf": [ | ||
| { | ||
| "$ref": "./api/starknet_api_openrpc.json#/components/schemas/TXN_HASH" | ||
| "$ref": "./api/starknet_api_openrpc.json#/components/schemas/TXN_WITH_HASH" | ||
| }, | ||
| { | ||
| "$ref": "./api/starknet_api_openrpc.json#/components/schemas/TXN_WITH_HASH" | ||
| "type": "object", | ||
| "properties": { | ||
| "finality_status": { | ||
| "description": "Finality status of the transaction", | ||
| "$ref": "#/components/schemas/TXN_STATUS_WITHOUT_L1" | ||
| } | ||
| }, | ||
| "required": [ | ||
| "finality_status" | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
|
|
@@ -308,42 +409,38 @@ | |
| }, | ||
| "SUBSCRIPTION_BLOCK_ID": { | ||
| "title": "Subscription Block id", | ||
| "description": "Block hash, number or tag, same as BLOCK_ID, but without 'pending'", | ||
| "oneOf": [ | ||
| { | ||
| "title": "Block hash", | ||
| "type": "object", | ||
| "properties": { | ||
| "block_hash": { | ||
| "title": "Block hash", | ||
| "$ref": "./api/starknet_api_openrpc.json#/components/schemas/BLOCK_HASH" | ||
| } | ||
| "description": "Block hash, number or tag, same as BLOCK_ID, but without 'pre_confirmed' or 'l1_accepted'", | ||
| "schema": { | ||
| "title": "Block id", | ||
| "allOf": [ | ||
| { | ||
| "$ref": "./api/starknet_api_openrpc.json#/components/schemas/BLOCK_ID" | ||
| }, | ||
| "required": ["block_hash"] | ||
| }, | ||
| { | ||
| "title": "Block number", | ||
| "type": "object", | ||
| "properties": { | ||
| "block_number": { | ||
| "title": "Block number", | ||
| "$ref": "./api/starknet_api_openrpc.json#/components/schemas/BLOCK_NUMBER" | ||
| { | ||
| "not": { | ||
| "type": "string", | ||
| "enum": ["l1_accepted", "pre_confirmed"] | ||
| } | ||
| }, | ||
| "required": ["block_number"] | ||
| } | ||
| ] | ||
| } | ||
| }, | ||
| "TXN_STATUS_WITHOUT_L1": { | ||
| "title": "Transaction status without ACCEPTED_ON_L1", | ||
| "description": "Transaction status for new transactions subscription", | ||
| "allOf": [ | ||
| { | ||
| "$ref": "./api/starknet_api_openrpc.json#/components/schemas/TXN_STATUS" | ||
| }, | ||
| { | ||
| "title": "Block tag", | ||
| "$ref": "#/components/schemas/SUBSCRIPTION_BLOCK_TAG" | ||
| "not": { | ||
| "type": "string", | ||
| "enum": ["ACCEPTED_ON_L1"] | ||
| } | ||
| } | ||
| ] | ||
| }, | ||
| "SUBSCRIPTION_BLOCK_TAG": { | ||
| "title": "Subscription Block tag", | ||
| "type": "string", | ||
| "description": "Same as BLOCK_TAG, but without 'pending'", | ||
| "enum": ["latest"] | ||
| }, | ||
|
|
||
| "REORG_DATA": { | ||
| "name": "Reorg Data", | ||
| "description": "Data about reorganized blocks, starting and ending block number and hash", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using
starknet_subscribeEventswithblock_id: Latestandfinality_status: PRE_CONFIRMED, we're supposed to return all events in the latest block before starting to return events in the pre-confirmed block, correct? ie. there's no way to tell the node to start from the pre-confirmed block(not saying it's a bad or good thing, I'm just making sure I'm reading this right)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, as is the case in 0.8 with events of Pending transactions