From 788aa1e3846d6312d00127a2d48784e5bf8545a6 Mon Sep 17 00:00:00 2001 From: ArielElp Date: Tue, 25 Jul 2023 18:04:52 +0300 Subject: [PATCH 1/3] bugs fixes: add tx_hash, errors, and compiled_class_hash --- api/starknet_api_openrpc.json | 77 +++++++++++++++++------------- api/starknet_write_api.json | 89 ++++++++++++++++++++++++++++++----- 2 files changed, 122 insertions(+), 44 deletions(-) diff --git a/api/starknet_api_openrpc.json b/api/starknet_api_openrpc.json index b69a70d..5224c18 100644 --- a/api/starknet_api_openrpc.json +++ b/api/starknet_api_openrpc.json @@ -189,7 +189,23 @@ "name": "result", "schema": { "title": "Transaction", - "$ref": "#/components/schemas/TXN" + "allOf": [ + { + "$ref": "#/components/schemas/TXN" + }, + { + "type": "object", + "properties": { + "transaction_hash": { + "title": "transaction hash", + "$ref": "#/components/schemas/TXN_HASH" + } + }, + "required": [ + "transaction_hash" + ] + } + ] } }, "errors": [ @@ -1644,6 +1660,11 @@ "description": "The address of the account contract sending the declaration transaction", "$ref": "#/components/schemas/ADDRESS" }, + "compiled_class_hash": { + "title": "Compiled class hash", + "description": "The hash of the Cairo assembly resulting from the Sierra compilation", + "$ref": "#/components/schemas/FELT" + }, "max_fee": { "title": "Max fee", "$ref": "#/components/schemas/FELT", @@ -1666,6 +1687,7 @@ "required": [ "type", "sender_address", + "compiled_class_hash", "max_fee", "version", "signature", @@ -1814,6 +1836,13 @@ "title": "Invoke transaction V0", "description": "invokes a specific function in the desired contract (not necessarily an account)", "properties": { + "type": { + "title": "Type", + "type": "string", + "enum": [ + "INVOKE" + ] + }, "max_fee": { "title": "Max fee", "$ref": "#/components/schemas/FELT", @@ -1846,6 +1875,7 @@ } }, "required": [ + "type", "contract_address", "entry_point_selector", "calldata", @@ -1861,6 +1891,13 @@ { "type": "object", "properties": { + "type": { + "title": "Type", + "type": "string", + "enum": [ + "INVOKE" + ] + }, "sender_address": { "title": "sender address", "$ref": "#/components/schemas/ADDRESS" @@ -1893,6 +1930,7 @@ } }, "required": [ + "type", "sender_address", "calldata", "max_fee", @@ -1906,35 +1944,14 @@ "INVOKE_TXN": { "title": "Invoke transaction", "description": "Initiate a transaction from an account", - "allOf": [ + "oneOf": [ { - "type": "object", - "title": "Type", - "properties": { - "type": { - "title": "Type", - "type": "string", - "enum": [ - "INVOKE" - ] - } - }, - "required": [ - "type" - ] + "title": "Invoke transaction V0", + "$ref": "#/components/schemas/INVOKE_TXN_V0" }, { - "title": "Invoke transaction properties", - "oneOf": [ - { - "title": "Invoke transaction V0", - "$ref": "#/components/schemas/INVOKE_TXN_V0" - }, - { - "title": "Invoke transaction V1", - "$ref": "#/components/schemas/INVOKE_TXN_V1" - } - ] + "title": "Invoke transaction V1", + "$ref": "#/components/schemas/INVOKE_TXN_V1" } ] }, @@ -1946,11 +1963,6 @@ "title": "L1 handler transaction", "description": "a call to an l1_handler on an L2 contract induced by a message from L1", "properties": { - "transaction_hash": { - "title": "Transaction hash", - "$ref": "#/components/schemas/TXN_HASH", - "description": "The hash identifying the transaction" - }, "version": { "title": "Version", "description": "Version of the transaction scheme", @@ -1970,7 +1982,6 @@ } }, "required": [ - "transaction_hash", "version", "type", "nonce" diff --git a/api/starknet_write_api.json b/api/starknet_write_api.json index 50c5276..d036807 100644 --- a/api/starknet_write_api.json +++ b/api/starknet_write_api.json @@ -16,7 +16,7 @@ "description": "The information needed to invoke the function (or account, for version 1 transactions)", "required": true, "schema": { - "$ref": "#/components/schemas/INVOKE_TXN" + "$ref": "#/components/schemas/INVOKE_TXN_V1" } } ], @@ -33,7 +33,29 @@ } } }, - "errors": [] + "errors": [ + { + "$ref": "#/components/errors/INSUFFICIENT_ACCOUNT_BALANCE" + }, + { + "$ref": "#/components/errors/INSUFFICIENT_MAX_FEE" + }, + { + "$ref": "#/components/errors/INVALID_TRANSACTION_NONCE" + }, + { + "$ref": "#/components/errors/VALIDATION_FAILURE" + }, + { + "$ref": "#/components/errors/NON_ACCOUNT" + }, + { + "$ref": "#/components/errors/CLASS_HASH_NOT_FOUND" + }, + { + "$ref": "#/components/errors/DUPLICATE_TX" + } + ] }, { "name": "starknet_addDeclareTransaction", @@ -68,10 +90,37 @@ }, "errors": [ { - "$ref": "#/components/errors/INVALID_CONTRACT_CLASS" + "$ref": "#/components/errors/CLASS_ALREADY_DECLARED" }, { - "$ref": "#/components/errors/CLASS_ALREADY_DECLARED" + "$ref": "#/components/errors/COMPILATION_FAILED" + }, + { + "$ref": "#/components/errors/COMPILED_CLASS_HASH_MISMATCH" + }, + { + "$ref": "#/components/errors/INSUFFICIENT_ACCOUNT_BALANCE" + }, + { + "$ref": "#/components/errors/INSUFFICIENT_MAX_FEE" + }, + { + "$ref": "#/components/errors/INVALID_TRANSACTION_NONCE" + }, + { + "$ref": "#/components/errors/VALIDATION_FAILURE" + }, + { + "$ref": "#/components/errors/NON_ACCOUNT" + }, + { + "$ref": "#/components/errors/CLASS_HASH_NOT_FOUND" + }, + { + "$ref": "#/components/errors/DUPLICATE_TX" + }, + { + "$ref": "#/components/errors/CONTRACT_BYTECODE_SIZE_IS_TOO_LARGE" } ] }, @@ -106,8 +155,26 @@ } }, "errors": [ + { + "$ref": "#/components/errors/INSUFFICIENT_ACCOUNT_BALANCE" + }, + { + "$ref": "#/components/errors/INSUFFICIENT_MAX_FEE" + }, + { + "$ref": "#/components/errors/INVALID_TRANSACTION_NONCE" + }, + { + "$ref": "#/components/errors/VALIDATION_FAILURE" + }, + { + "$ref": "#/components/errors/NON_ACCOUNT" + }, { "$ref": "#/components/errors/CLASS_HASH_NOT_FOUND" + }, + { + "$ref": "#/components/errors/DUPLICATE_TX" } ] } @@ -129,8 +196,8 @@ "TXN_HASH": { "$ref": "./api/starknet_api_openrpc.json#/components/schemas/TXN_HASH" }, - "INVOKE_TXN": { - "$ref": "./api/starknet_api_openrpc.json#/components/schemas/INVOKE_TXN" + "INVOKE_TXN_V1": { + "$ref": "./api/starknet_api_openrpc.json#/components/schemas/INVOKE_TXN_V1" }, "DECLARE_TXN": { "$ref": "./api/starknet_api_openrpc.json#/components/schemas/DECLARE_TXN" @@ -143,10 +210,6 @@ } }, "errors": { - "INVALID_CONTRACT_CLASS": { - "code": 50, - "message": "Invalid contract class" - }, "CLASS_HASH_NOT_FOUND": { "code": 28, "message": "Class hash not found" @@ -175,7 +238,7 @@ "code": 56, "message": "Compilation failed" }, - "CONTRACT_BYTECODE_SIZE_TOO_LARGE": { + "CONTRACT_BYTECODE_SIZE_IS_TOO_LARGE": { "code": 57, "message": "Contract bytecode size it too large" }, @@ -186,6 +249,10 @@ "DUPLICATE_TX": { "code": 59, "message": "A transaction with the same hash already exists in the mempool" + }, + "COMPILED_CLASS_HASH_MISMATCH": { + "code": 60, + "message": "the compiled class hash did not match the one supplied in the transaction" } } } From 57f2421bdf4e073db56da4b81f5d09cb13bd05d6 Mon Sep 17 00:00:00 2001 From: ArielElp Date: Tue, 25 Jul 2023 18:10:53 +0300 Subject: [PATCH 2/3] add tx_hash to the result of getTxByBlockIdAndIndex --- api/starknet_api_openrpc.json | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/api/starknet_api_openrpc.json b/api/starknet_api_openrpc.json index 5224c18..6118154 100644 --- a/api/starknet_api_openrpc.json +++ b/api/starknet_api_openrpc.json @@ -243,7 +243,23 @@ "name": "transactionResult", "schema": { "title": "Transaction", - "$ref": "#/components/schemas/TXN" + "allOf": [ + { + "$ref": "#/components/schemas/TXN" + }, + { + "type": "object", + "properties": { + "transaction_hash": { + "title": "transaction hash", + "$ref": "#/components/schemas/TXN_HASH" + } + }, + "required": [ + "transaction_hash" + ] + } + ] } }, "errors": [ From 1459da69ccb583a26b233d3a476d289d11dda0b2 Mon Sep 17 00:00:00 2001 From: ArielElp Date: Tue, 25 Jul 2023 18:37:40 +0300 Subject: [PATCH 3/3] add tx hashes to getPendingTransactions --- api/starknet_api_openrpc.json | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/api/starknet_api_openrpc.json b/api/starknet_api_openrpc.json index 6118154..245bdd1 100644 --- a/api/starknet_api_openrpc.json +++ b/api/starknet_api_openrpc.json @@ -696,7 +696,23 @@ "type": "array", "title": "Pending Transactions", "items": { - "$ref": "#/components/schemas/TXN" + "allOf": [ + { + "$ref": "#/components/schemas/TXN" + }, + { + "type": "object", + "properties": { + "transaction_hash": { + "title": "transaction hash", + "$ref": "#/components/schemas/TXN_HASH" + } + }, + "required": [ + "transaction_hash" + ] + } + ] } } }