Skip to content

Commit

Permalink
fix: issue #20 (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
tabaktoni authored Nov 28, 2024
1 parent f4e2ebf commit d702721
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
6 changes: 4 additions & 2 deletions src/wallet-api/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,11 @@ export interface AccountDeploymentData {
version: 0 | 1; // Cairo version (an integer)
}

export type API_VERSION = string;

/**
* The version of wallet API the request expecting. If not specified, the latest is assumed
*/
export interface ApiVersion {
api_version?: string;
export interface ApiVersionRequest {
api_version?: API_VERSION;
}
25 changes: 13 additions & 12 deletions src/wallet-api/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ import { Permission } from './constants.js';
import type { TypedData } from './typedData.js';
import * as Errors from './errors.js';
import type {
API_VERSION,
AccountDeploymentData,
AddDeclareTransactionParameters,
AddDeclareTransactionResult,
AddInvokeTransactionParameters,
AddInvokeTransactionResult,
AddStarknetChainParameters,
Address,
ApiVersion,
ApiVersionRequest,
RequestAccountsParameters,
Signature,
SpecVersion,
Expand All @@ -27,7 +28,7 @@ export interface RpcTypeToMessageMap {
* @returns An array of permissions.
*/
wallet_getPermissions: {
params?: ApiVersion;
params?: ApiVersionRequest;
result: Permission[] | [];
errors: Errors.API_VERSION_NOT_SUPPORTED | Errors.UNKNOWN_ERROR;
};
Expand All @@ -38,7 +39,7 @@ export interface RpcTypeToMessageMap {
* @returns An array of account addresses as strings.
*/
wallet_requestAccounts: {
params?: RequestAccountsParameters & ApiVersion;
params?: RequestAccountsParameters & ApiVersionRequest;
result: Address[];
errors: Errors.API_VERSION_NOT_SUPPORTED | Errors.UNKNOWN_ERROR;
};
Expand All @@ -49,7 +50,7 @@ export interface RpcTypeToMessageMap {
* @returns A boolean indicating if the operation was successful.
*/
wallet_watchAsset: {
params: WatchAssetParameters & ApiVersion;
params: WatchAssetParameters & ApiVersionRequest;
result: boolean;
errors:
| Errors.NOT_ERC20
Expand All @@ -65,7 +66,7 @@ export interface RpcTypeToMessageMap {
* @returns A boolean indicating if the operation was successful.
*/
wallet_addStarknetChain: {
params: AddStarknetChainParameters & ApiVersion;
params: AddStarknetChainParameters & ApiVersionRequest;
result: boolean;
errors:
| Errors.INVALID_REQUEST_PAYLOAD
Expand All @@ -80,7 +81,7 @@ export interface RpcTypeToMessageMap {
* @returns A boolean indicating if the operation was successful.
*/
wallet_switchStarknetChain: {
params: SwitchStarknetChainParameters & ApiVersion;
params: SwitchStarknetChainParameters & ApiVersionRequest;
result: boolean;
errors:
| Errors.UNLISTED_NETWORK
Expand All @@ -94,7 +95,7 @@ export interface RpcTypeToMessageMap {
* @returns The current Starknet chain ID.
*/
wallet_requestChainId: {
params?: ApiVersion;
params?: ApiVersionRequest;
result: ChainId;
errors: Errors.API_VERSION_NOT_SUPPORTED | Errors.UNKNOWN_ERROR;
};
Expand All @@ -104,7 +105,7 @@ export interface RpcTypeToMessageMap {
* @returns The deployment data result.
*/
wallet_deploymentData: {
params?: ApiVersion;
params?: ApiVersionRequest;
result: AccountDeploymentData;
errors:
| Errors.ACCOUNT_ALREADY_DEPLOYED
Expand All @@ -118,7 +119,7 @@ export interface RpcTypeToMessageMap {
* @returns The result of adding the invoke transaction.
*/
wallet_addInvokeTransaction: {
params: AddInvokeTransactionParameters & ApiVersion;
params: AddInvokeTransactionParameters & ApiVersionRequest;
result: AddInvokeTransactionResult;
errors:
| Errors.INVALID_REQUEST_PAYLOAD
Expand All @@ -133,7 +134,7 @@ export interface RpcTypeToMessageMap {
* @returns The result of adding the declare transaction.
*/
wallet_addDeclareTransaction: {
params: AddDeclareTransactionParameters & ApiVersion;
params: AddDeclareTransactionParameters & ApiVersionRequest;
result: AddDeclareTransactionResult;
errors:
| Errors.INVALID_REQUEST_PAYLOAD
Expand All @@ -148,7 +149,7 @@ export interface RpcTypeToMessageMap {
* @returns An array of signatures as strings.
*/
wallet_signTypedData: {
params: TypedData & ApiVersion;
params: TypedData & ApiVersionRequest;
result: Signature;
errors:
| Errors.INVALID_REQUEST_PAYLOAD
Expand All @@ -168,7 +169,7 @@ export interface RpcTypeToMessageMap {
* Notice this might be different from Starknet JSON-RPC spec
* @returns An array of supported wallet api versions.
*/
wallet_supportedWalletApi: { params?: never; result: ApiVersion[] };
wallet_supportedWalletApi: { params?: never; result: API_VERSION[] };
}

export type RpcMessage = {
Expand Down

0 comments on commit d702721

Please sign in to comment.