From 4127d20d0807bd9f8ea54b23d7236e384fd03658 Mon Sep 17 00:00:00 2001 From: amanusk Date: Thu, 23 May 2024 08:07:30 +0300 Subject: [PATCH] Add optional spec version param to all requests * Add error for api version not supported * Add error for account already deployed --- wallet-api/wallet_rpc.json | 144 +++++++++++++++++++++++++++++++++++-- 1 file changed, 137 insertions(+), 7 deletions(-) diff --git a/wallet-api/wallet_rpc.json b/wallet-api/wallet_rpc.json index 9d09136..04d8ae1 100644 --- a/wallet-api/wallet_rpc.json +++ b/wallet-api/wallet_rpc.json @@ -28,7 +28,15 @@ { "name": "wallet_getPermissions", "summary": "Get the existing permissions for the Dapp from the wallet", - "params": [], + "params": [ + { + "name": "wallet_api_version", + "required": false, + "schema": { + "$ref": "#/components/schemas/WALLET_API_VERSION" + } + } + ], "result": { "name": "result", "schema": { @@ -50,7 +58,14 @@ "required": [] } }, - "errors": [] + "errors": [ + { + "$ref": "#/components/errors/WALLET_API_VERSION_NOT_SUPPORTED" + }, + { + "$ref": "#/components/errors/UNKNOWN_ERROR" + } + ] }, { "name": "wallet_requestAccounts", @@ -63,6 +78,13 @@ "schema": { "type": "boolean" } + }, + { + "name": "wallet_api_version", + "required": false, + "schema": { + "$ref": "#/components/schemas/WALLET_API_VERSION" + } } ], "result": { @@ -77,12 +99,27 @@ "required": [] } }, - "errors": [] + "errors": [ + { + "$ref": "#/components/errors/WALLET_API_VERSION_NOT_SUPPORTED" + }, + { + "$ref": "#/components/errors/UNKNOWN_ERROR" + } + ] }, { "name": "wallet_requestChainId", "summary": "Request the current Chain Id", - "params": [], + "params": [ + { + "name": "wallet_api_version", + "required": false, + "schema": { + "$ref": "#/components/schemas/WALLET_API_VERSION" + } + } + ], "result": { "name": "result", "description": "The active chainId", @@ -90,12 +127,27 @@ "$ref": "#/components/schemas/CHAIN_ID" } }, - "errors": [] + "errors": [ + { + "$ref": "#/components/errors/WALLET_API_VERSION_NOT_SUPPORTED" + }, + { + "$ref": "#/components/errors/UNKNOWN_ERROR" + } + ] }, { "name": "wallet_deploymentData", "summary": "Request from the current wallet the data required to deploy the account at the current address", - "params": [], + "params": [ + { + "name": "wallet_api_version", + "required": false, + "schema": { + "$ref": "#/components/schemas/WALLET_API_VERSION" + } + } + ], "result": { "name": "result", "schema": { @@ -104,7 +156,10 @@ }, "errors": [ { - "$ref": "#/components/errors/USER_REFUSED_OP" + "$ref": "#/components/errors/ACCOUNT_ALREADY_DEPLOYED" + }, + { + "$ref": "#/components/errors/WALLET_API_VERSION_NOT_SUPPORTED" }, { "$ref": "#/components/errors/UNKNOWN_ERROR" @@ -121,6 +176,13 @@ "schema": { "$ref": "#/components/schemas/CHAIN_ID" } + }, + { + "name": "wallet_api_version", + "required": false, + "schema": { + "$ref": "#/components/schemas/WALLET_API_VERSION" + } } ], "result": { @@ -138,6 +200,9 @@ { "$ref": "#/components/errors/USER_REFUSED_OP" }, + { + "$ref": "#/components/errors/WALLET_API_VERSION_NOT_SUPPORTED" + }, { "$ref": "#/components/errors/UNKNOWN_ERROR" } @@ -154,6 +219,13 @@ "schema": { "$ref": "#/components/schemas/ASSET" } + }, + { + "name": "wallet_api_version", + "required": false, + "schema": { + "$ref": "#/components/schemas/WALLET_API_VERSION" + } } ], "result": { @@ -174,6 +246,9 @@ { "$ref": "#/components/errors/USER_REFUSED_OP" }, + { + "$ref": "#/components/errors/WALLET_API_VERSION_NOT_SUPPORTED" + }, { "$ref": "#/components/errors/UNKNOWN_ERROR" } @@ -190,6 +265,13 @@ "schema": { "$ref": "#/components/schemas/STARKNET_CHAIN" } + }, + { + "name": "wallet_api_version", + "required": false, + "schema": { + "$ref": "#/components/schemas/WALLET_API_VERSION" + } } ], "result": { @@ -207,6 +289,9 @@ { "$ref": "#/components/errors/USER_REFUSED_OP" }, + { + "$ref": "#/components/errors/WALLET_API_VERSION_NOT_SUPPORTED" + }, { "$ref": "#/components/errors/UNKNOWN_ERROR" } @@ -226,6 +311,13 @@ "$ref": "#/components/schemas/INVOKE_CALL" } } + }, + { + "name": "wallet_api_version", + "required": false, + "schema": { + "$ref": "#/components/schemas/WALLET_API_VERSION" + } } ], "result": { @@ -249,6 +341,9 @@ { "$ref": "#/components/errors/USER_REFUSED_OP" }, + { + "$ref": "#/components/errors/WALLET_API_VERSION_NOT_SUPPORTED" + }, { "$ref": "#/components/errors/UNKNOWN_ERROR" } @@ -265,6 +360,13 @@ "schema": { "$ref": "#/components/schemas/DECLARE_TXN" } + }, + { + "name": "wallet_api_version", + "required": false, + "schema": { + "$ref": "#/components/schemas/WALLET_API_VERSION" + } } ], "result": { @@ -292,6 +394,9 @@ { "$ref": "#/components/errors/USER_REFUSED_OP" }, + { + "$ref": "#/components/errors/WALLET_API_VERSION_NOT_SUPPORTED" + }, { "$ref": "#/components/errors/UNKNOWN_ERROR" } @@ -308,6 +413,13 @@ "schema": { "$ref": "#/components/schemas/TYPED_DATA" } + }, + { + "name": "wallet_api_version", + "required": false, + "schema": { + "$ref": "#/components/schemas/WALLET_API_VERSION" + } } ], "result": { @@ -325,6 +437,9 @@ { "$ref": "#/components/errors/USER_REFUSED_OP" }, + { + "$ref": "#/components/errors/WALLET_API_VERSION_NOT_SUPPORTED" + }, { "$ref": "#/components/errors/UNKNOWN_ERROR" } @@ -357,6 +472,12 @@ "type": "string", "pattern": "^[0-9]+\\.[0-9]+$" }, + "WALLET_API_VERSION": { + "title": "Wallet API version", + "description": "The version of wallet API the request expecting. If not specified, the latest is assumed", + "type": "string", + "pattern": "^[0-9]+\\.[0-9]+$" + }, "PERMISSION": { "title": "Wallet permission", "type": "string", @@ -694,6 +815,15 @@ "code": 114, "message": "An error occurred (INVALID_REQUEST_PAYLOAD)" }, + "ACCOUNT_ALREADY_DEPLOYED": { + "code": 115, + "message": "An error occurred (ACCOUNT_ALREADY_DEPLOYED)" + }, + "WALLET_API_VERSION_NOT_SUPPORTED": { + "code": 162, + "message": "An error occurred (WALLET_API_VERSION_NOT_SUPPORTED)", + "data": "string" + }, "UNKNOWN_ERROR": { "code": 163, "message": "An error occurred (UNKNOWN_ERROR)",