diff --git a/package-lock.json b/package-lock.json index 6207e5878..62d8ec7d3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1821,6 +1821,7 @@ "integrity": "sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==", "dev": true, "optional": true, + "peer": true, "engines": { "node": ">=0.1.90" } @@ -5912,6 +5913,7 @@ "resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.6.3.tgz", "integrity": "sha512-w5Jac5SykAeZJKntOxJCrm63Eg5/4dhMWIcuTbo9rpE+brgaSZo0RuNJZeOyMgsUdhDeojvgyQLmjI+K50ZGyg==", "dev": true, + "peer": true, "dependencies": { "string-width": "^4.2.0" }, @@ -5926,13 +5928,15 @@ "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true + "dev": true, + "peer": true }, "node_modules/cli-table3/node_modules/is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", "dev": true, + "peer": true, "engines": { "node": ">=8" } @@ -5942,6 +5946,7 @@ "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", "dev": true, + "peer": true, "dependencies": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", @@ -11683,9 +11688,9 @@ } }, "node_modules/lossless-json": { - "version": "2.0.9", - "resolved": "https://registry.npmjs.org/lossless-json/-/lossless-json-2.0.9.tgz", - "integrity": "sha512-PUfJ5foxULG1x/dXpSckmt0woBDqyq/WFoI885vEqjGwuP41K2EBYh2IT3zYx9dWqcTLIfXiCE5AjhF1jk9Sbg==" + "version": "2.0.11", + "resolved": "https://registry.npmjs.org/lossless-json/-/lossless-json-2.0.11.tgz", + "integrity": "sha512-BP0vn+NGYvzDielvBZaFain/wgeJ1hTvURCqtKvhr1SCPePdaaTanmmcplrHfEJSJOUql7hk4FHwToNJjWRY3g==" }, "node_modules/lru-cache": { "version": "5.1.1", diff --git a/src/types/api/rpc.ts b/src/types/api/rpc.ts index ba8aa97e7..74bb1b8e0 100644 --- a/src/types/api/rpc.ts +++ b/src/types/api/rpc.ts @@ -1,66 +1,64 @@ import { ADDRESS, CONTRACT_STORAGE_DIFF_ITEM, FELT, OPENRPC } from './openrpc'; -export namespace RPC { - export type Response = { - id: number; - jsonrpc: string; - result?: any; - error?: { - code: string; - message: string; - }; +export type Response = { + id: number; + jsonrpc: string; + result?: any; + error?: { + code: string; + message: string; }; +}; - export type ChainId = OPENRPC.CHAIN_ID; - export type CallResponse = OPENRPC.CallResponse; - export type ContractAddress = ADDRESS; - export type Felt = FELT; - export type Nonce = OPENRPC.Nonce; - export type ContractClass = OPENRPC.ContractClass | OPENRPC.DeprecatedContractClass; - export type StateUpdate = OPENRPC.StateUpdate; - export type Transaction = OPENRPC.Transaction; - export type PendingTransactions = OPENRPC.PendingTransactions; - export type TransactionHash = OPENRPC.TransactionHash; - export type Trace = OPENRPC.Trace; - export type Traces = OPENRPC.Traces; - export type BlockHash = OPENRPC.BlockHash; - export type BlockHashAndNumber = OPENRPC.BlockHashAndNumber; - export type EstimateFeeResponse = OPENRPC.EstimatedFee; - export type GetBlockWithTxHashesResponse = OPENRPC.BlockWithTxHashes; - export type GetBlockWithTxs = OPENRPC.BlockWithTxs; - export type GetStorageAtResponse = OPENRPC.Storage; - export type TransactionReceipt = OPENRPC.TransactionReceipt; - export type GetTransactionByHashResponse = OPENRPC.Transaction; - export type GetTransactionByBlockIdAndIndex = OPENRPC.Transaction; - export type GetTransactionCountResponse = number; - export type GetBlockNumberResponse = OPENRPC.BlockNumber; - export type GetSyncingStatsResponse = OPENRPC.SyncingStatus; - export type EventFilter = OPENRPC.EventFilter; - export type GetEventsResponse = OPENRPC.Events; - export type InvokedTransaction = OPENRPC.InvokedTransaction; - export type DeclaredTransaction = OPENRPC.DeclaredTransaction; - export type DeployedTransaction = OPENRPC.DeployedTransaction; - export type SimulationFlags = OPENRPC.SimulationFlags; - export type BroadcastedTransaction = OPENRPC.BroadcastedTransaction; - export type EstimatedFee = OPENRPC.EstimatedFee; - export type Methods = OPENRPC.Methods; - export type Storage = OPENRPC.Storage; - export type SimulateTransactionResponse = OPENRPC.SimulatedTransactions; +export type ChainId = OPENRPC.CHAIN_ID; +export type CallResponse = OPENRPC.CallResponse; +export type ContractAddress = ADDRESS; +export type Felt = FELT; +export type Nonce = OPENRPC.Nonce; +export type ContractClass = OPENRPC.ContractClass | OPENRPC.DeprecatedContractClass; +export type StateUpdate = OPENRPC.StateUpdate; +export type Transaction = OPENRPC.Transaction; +export type PendingTransactions = OPENRPC.PendingTransactions; +export type TransactionHash = OPENRPC.TransactionHash; +export type Trace = OPENRPC.Trace; +export type Traces = OPENRPC.Traces; +export type BlockHash = OPENRPC.BlockHash; +export type BlockHashAndNumber = OPENRPC.BlockHashAndNumber; +export type EstimateFeeResponse = OPENRPC.EstimatedFee; +export type GetBlockWithTxHashesResponse = OPENRPC.BlockWithTxHashes; +export type GetBlockWithTxs = OPENRPC.BlockWithTxs; +export type GetStorageAtResponse = OPENRPC.Storage; +export type TransactionReceipt = OPENRPC.TransactionReceipt; +export type GetTransactionByHashResponse = OPENRPC.Transaction; +export type GetTransactionByBlockIdAndIndex = OPENRPC.Transaction; +export type GetTransactionCountResponse = number; +export type GetBlockNumberResponse = OPENRPC.BlockNumber; +export type GetSyncingStatsResponse = OPENRPC.SyncingStatus; +export type EventFilter = OPENRPC.EventFilter; +export type GetEventsResponse = OPENRPC.Events; +export type InvokedTransaction = OPENRPC.InvokedTransaction; +export type DeclaredTransaction = OPENRPC.DeclaredTransaction; +export type DeployedTransaction = OPENRPC.DeployedTransaction; +export type SimulationFlags = OPENRPC.SimulationFlags; +export type BroadcastedTransaction = OPENRPC.BroadcastedTransaction; +export type EstimatedFee = OPENRPC.EstimatedFee; +export type Methods = OPENRPC.Methods; +export type Storage = OPENRPC.Storage; +export type SimulateTransactionResponse = OPENRPC.SimulatedTransactions; - export enum TransactionType { - DECLARE = 'DECLARE', - DEPLOY = 'DEPLOY', - DEPLOY_ACCOUNT = 'DEPLOY_ACCOUNT', - INVOKE = 'INVOKE', - L1_HANDLER = 'L1_HANDLER', - } - - // Exported Diff on Sequencer (can be removed when diff resolved by new RPC v) - export type StorageDiffs = Array; - export type DeprecatedDeclaredClasses = Array; - export type Nonces = Array<{ - contract_address: ADDRESS; - nonce: FELT; - }>; - export type ReplacedClasses = Array<{ contract_address: ADDRESS; class_hash: FELT }>; +export enum TransactionType { + DECLARE = 'DECLARE', + DEPLOY = 'DEPLOY', + DEPLOY_ACCOUNT = 'DEPLOY_ACCOUNT', + INVOKE = 'INVOKE', + L1_HANDLER = 'L1_HANDLER', } + +// Exported Diff on Sequencer (can be removed when diff resolved by new RPC v) +export type StorageDiffs = Array; +export type DeprecatedDeclaredClasses = Array; +export type Nonces = Array<{ + contract_address: ADDRESS; + nonce: FELT; +}>; +export type ReplacedClasses = Array<{ contract_address: ADDRESS; class_hash: FELT }>; diff --git a/src/types/api/sequencer.ts b/src/types/api/sequencer.ts index a19ebe585..bb446bd96 100644 --- a/src/types/api/sequencer.ts +++ b/src/types/api/sequencer.ts @@ -15,6 +15,7 @@ import { TransactionType, } from '../lib'; +// #region | originally not included in the namespace export type GetTransactionStatusResponse = { tx_status: TransactionStatus; block_hash?: string; @@ -70,408 +71,407 @@ export type DeployedContractItem = { }; export type SequencerIdentifier = { blockHash: string } | { blockNumber: BlockNumber }; +// #endregion + +export type TransactionTraceResponse = { + validate_invocation?: FunctionInvocation; + function_invocation?: FunctionInvocation; + fee_transfer_invocation?: FunctionInvocation; + constructor_invocation?: FunctionInvocation; + signature: string[]; +}; -export namespace Sequencer { - export type TransactionTraceResponse = { - validate_invocation?: FunctionInvocation; - function_invocation?: FunctionInvocation; - fee_transfer_invocation?: FunctionInvocation; - constructor_invocation?: FunctionInvocation; - signature: string[]; - }; +export type DeclareTransaction = { + type: TransactionType.DECLARE; + sender_address: string; + contract_class: ContractClass; + signature?: string[]; + nonce: BigNumberish; + max_fee?: BigNumberish; + version?: BigNumberish; + compiled_class_hash?: string; // v2 declare +}; - export type DeclareTransaction = { - type: TransactionType.DECLARE; - sender_address: string; - contract_class: ContractClass; - signature?: string[]; - nonce: BigNumberish; - max_fee?: BigNumberish; - version?: BigNumberish; - compiled_class_hash?: string; // v2 declare - }; +export type DeployTransaction = { + type: TransactionType.DEPLOY; + contract_definition: ContractClass; + contract_address_salt: BigNumberish; + constructor_calldata: string[]; + nonce?: BigNumberish; +}; - export type DeployTransaction = { - type: TransactionType.DEPLOY; - contract_definition: ContractClass; - contract_address_salt: BigNumberish; - constructor_calldata: string[]; - nonce?: BigNumberish; - }; +export type DeployAccountTransaction = { + type: TransactionType.DEPLOY_ACCOUNT; + class_hash: string; + contract_address_salt: BigNumberish; + constructor_calldata: string[]; + signature?: string[]; + max_fee?: BigNumberish; + version?: BigNumberish; + nonce?: BigNumberish; +}; - export type DeployAccountTransaction = { - type: TransactionType.DEPLOY_ACCOUNT; - class_hash: string; - contract_address_salt: BigNumberish; - constructor_calldata: string[]; - signature?: string[]; - max_fee?: BigNumberish; - version?: BigNumberish; - nonce?: BigNumberish; - }; +export type InvokeFunctionTransaction = { + type: TransactionType.INVOKE; + sender_address: string; + signature?: string[]; + entry_point_type?: EntryPointType.EXTERNAL; // TODO: check this + calldata?: RawCalldata; + nonce: BigNumberish; + max_fee?: BigNumberish; + version?: BigNumberish; +}; - export type InvokeFunctionTransaction = { - type: TransactionType.INVOKE; - sender_address: string; - signature?: string[]; - entry_point_type?: EntryPointType.EXTERNAL; // TODO: check this - calldata?: RawCalldata; - nonce: BigNumberish; - max_fee?: BigNumberish; - version?: BigNumberish; - }; +export type Transaction = + | DeclareTransaction + | DeployTransaction + | InvokeFunctionTransaction + | DeployAccountTransaction; - export type Transaction = - | DeclareTransaction - | DeployTransaction - | InvokeFunctionTransaction - | DeployAccountTransaction; - - export type AddTransactionResponse = { - transaction_hash: string; - code?: 'TRANSACTION_RECEIVED'; - address?: string; - class_hash?: string; - }; +export type AddTransactionResponse = { + transaction_hash: string; + code?: 'TRANSACTION_RECEIVED'; + address?: string; + class_hash?: string; +}; - export type GetCodeResponse = { - bytecode: ByteCode; - abi: Abi; - }; +export type GetCodeResponse = { + bytecode: ByteCode; + abi: Abi; +}; - export interface InvokeFunctionTransactionResponse extends InvokeFunctionTransaction { - transaction_hash: string; - entry_point_selector: string; - } - - export type TransactionResponse = - | DeclareTransaction - | DeployTransaction - | InvokeFunctionTransactionResponse; - - export type SuccessfulTransactionResponse = { - status: TransactionStatus; - transaction: TransactionResponse; - block_hash: string; - block_number: BlockNumber; - transaction_index: number; - }; +export interface InvokeFunctionTransactionResponse extends InvokeFunctionTransaction { + transaction_hash: string; + entry_point_selector: string; +} - export type FailedTransactionResponse = { - status: TransactionStatus.REJECTED; - transaction_failure_reason: { - code: string; - error_message: string; - }; - transaction: TransactionResponse; - }; +export type TransactionResponse = + | DeclareTransaction + | DeployTransaction + | InvokeFunctionTransactionResponse; + +export type SuccessfulTransactionResponse = { + status: TransactionStatus; + transaction: TransactionResponse; + block_hash: string; + block_number: BlockNumber; + transaction_index: number; +}; - export type GetTransactionResponse = SuccessfulTransactionResponse | FailedTransactionResponse; - - export type TransactionReceiptResponse = - | SuccessfulTransactionReceiptResponse - | FailedTransactionReceiptResponse; - - export type SuccessfulTransactionReceiptResponse = { - status: TransactionStatus; - transaction_hash: string; - transaction_index: number; - block_hash: string; - block_number: BlockNumber; - l2_to_l1_messages: string[]; - events: string[]; - actual_fee: string; - execution_resources: ExecutionResources; +export type FailedTransactionResponse = { + status: TransactionStatus.REJECTED; + transaction_failure_reason: { + code: string; + error_message: string; }; + transaction: TransactionResponse; +}; - export type FailedTransactionReceiptResponse = { - status: TransactionStatus.REJECTED; - transaction_failure_reason: { - code: string; - error_message: string; - }; - transaction_hash: string; - l2_to_l1_messages: string[]; - events: string[]; - }; +export type GetTransactionResponse = SuccessfulTransactionResponse | FailedTransactionResponse; + +export type TransactionReceiptResponse = + | SuccessfulTransactionReceiptResponse + | FailedTransactionReceiptResponse; + +export type SuccessfulTransactionReceiptResponse = { + status: TransactionStatus; + transaction_hash: string; + transaction_index: number; + block_hash: string; + block_number: BlockNumber; + l2_to_l1_messages: string[]; + events: string[]; + actual_fee: string; + execution_resources: ExecutionResources; +}; - export type GetBlockResponse = { - block_number: number; - state_root: string; - block_hash: string; - transactions: { - [txHash: string]: TransactionResponse; - }; - timestamp: number; - transaction_receipts: { - [txHash: string]: { - block_hash: string; - transaction_hash: string; - l2_to_l1_messages: { - to_address: string; - payload: string[]; - from_address: string; - }[]; - block_number: BlockNumber; - status: TransactionStatus; - transaction_index: number; - }; - }; - parent_block_hash: string; - status: BlockStatus; - gas_price: string; - sequencer_address: string; - starknet_version: string; +export type FailedTransactionReceiptResponse = { + status: TransactionStatus.REJECTED; + transaction_failure_reason: { + code: string; + error_message: string; }; + transaction_hash: string; + l2_to_l1_messages: string[]; + events: string[]; +}; - export type CallContractTransaction = { - calldata?: RawCalldata; - max_fee?: BigNumberish; - version?: BigNumberish; - entry_point_selector: string; - } & ( - | { - sender_address: string; - signature: string[]; - } - | { - contract_address: string; - signature?: never; - } - ); - - export type CallContractResponse = { - result: string[]; +export type GetBlockResponse = { + block_number: number; + state_root: string; + block_hash: string; + transactions: { + [txHash: string]: TransactionResponse; + }; + timestamp: number; + transaction_receipts: { + [txHash: string]: { + block_hash: string; + transaction_hash: string; + l2_to_l1_messages: { + to_address: string; + payload: string[]; + from_address: string; + }[]; + block_number: BlockNumber; + status: TransactionStatus; + transaction_index: number; + }; }; + parent_block_hash: string; + status: BlockStatus; + gas_price: string; + sequencer_address: string; + starknet_version: string; +}; - export type InvokeEstimateFee = Omit; - export type DeclareEstimateFee = Omit; - export type DeployAccountEstimateFee = Omit; - export type DeployEstimateFee = DeployTransaction; +export type CallContractTransaction = { + calldata?: RawCalldata; + max_fee?: BigNumberish; + version?: BigNumberish; + entry_point_selector: string; +} & ( + | { + sender_address: string; + signature: string[]; + } + | { + contract_address: string; + signature?: never; + } +); + +export type CallContractResponse = { + result: string[]; +}; - export type SimulateTransactionResponse = { - trace: TransactionTraceResponse; // diff with OPENRPC "transaction_trace" - fee_estimation: Sequencer.EstimateFeeResponse; - }; +export type InvokeEstimateFee = Omit; +export type DeclareEstimateFee = Omit; +export type DeployAccountEstimateFee = Omit; +export type DeployEstimateFee = DeployTransaction; - export type AccountTransactionItem = - | InvokeEstimateFee - | DeclareEstimateFee - | DeployEstimateFee - | DeployAccountEstimateFee; - - /** - * Transaction filled with account data - */ - export type AccountTransaction = AllowArray; - - // Support 0.9.1 changes in a backward-compatible way - export type EstimateFeeResponse = - | { - overall_fee: number; - gas_price: number; - gas_usage: number; - uint: string; - } - | { - amount: bigint; - unit: string; - }; - - export type EstimateFeeResponseBulk = AllowArray; - - export type BlockTransactionTracesResponse = { - traces: Array; - }; +export type SimulateTransactionResponse = { + trace: TransactionTraceResponse; // diff with OPENRPC "transaction_trace" + fee_estimation: EstimateFeeResponse; +}; - export type Storage = string; - - export type StateUpdateResponse = { - block_hash: string; - new_root: string; - old_root: string; - state_diff: { - storage_diffs: StorageDiffs; - nonces: Nonces; - deployed_contracts: Array; - old_declared_contracts: OldDeclaredContracts; - declared_classes: DeclaredClasses; - replaced_classes: ReplacedClasses; // no definition is it array of string +export type AccountTransactionItem = + | InvokeEstimateFee + | DeclareEstimateFee + | DeployEstimateFee + | DeployAccountEstimateFee; + +/** + * Transaction filled with account data + */ +export type AccountTransaction = AllowArray; + +// Support 0.9.1 changes in a backward-compatible way +export type EstimateFeeResponse = + | { + overall_fee: number; + gas_price: number; + gas_usage: number; + uint: string; + } + | { + amount: bigint; + unit: string; }; + +export type EstimateFeeResponseBulk = AllowArray; + +export type BlockTransactionTracesResponse = { + traces: Array; +}; + +export type Storage = string; + +export type StateUpdateResponse = { + block_hash: string; + new_root: string; + old_root: string; + state_diff: { + storage_diffs: StorageDiffs; + nonces: Nonces; + deployed_contracts: Array; + old_declared_contracts: OldDeclaredContracts; + declared_classes: DeclaredClasses; + replaced_classes: ReplacedClasses; // no definition is it array of string }; +}; - export type StorageDiffs = { [address: string]: Array }; +export type StorageDiffs = { [address: string]: Array }; - export type StateDiffItem = { key: string; value: string }; +export type StateDiffItem = { key: string; value: string }; - export type Nonces = { [address: string]: Nonce }; +export type Nonces = { [address: string]: Nonce }; - export type Nonce = string; +export type Nonce = string; - export type DeployedContracts = DeployedContractItem[]; +export type DeployedContracts = DeployedContractItem[]; - export type OldDeclaredContracts = string[]; +export type OldDeclaredContracts = string[]; - export type DeclaredClasses = DeclaredClass[]; +export type DeclaredClasses = DeclaredClass[]; - export type DeclaredClass = { class_hash: string; compiled_class_hash: string }; +export type DeclaredClass = { class_hash: string; compiled_class_hash: string }; - export type ReplacedClasses = string[]; // no definition is it array of string ? +export type ReplacedClasses = string[]; // no definition is it array of string ? - export type Endpoints = { - get_contract_addresses: { - QUERY: never; - REQUEST: never; - RESPONSE: GetContractAddressesResponse; - }; - add_transaction: { - QUERY: never; - REQUEST: Transaction; - RESPONSE: AddTransactionResponse; - }; - get_transaction: { - QUERY: { - transactionHash: string; - }; - REQUEST: never; - RESPONSE: GetTransactionResponse; - }; - get_transaction_status: { - QUERY: { - transactionHash: string; - }; - REQUEST: never; - RESPONSE: GetTransactionStatusResponse; +export type Endpoints = { + get_contract_addresses: { + QUERY: never; + REQUEST: never; + RESPONSE: GetContractAddressesResponse; + }; + add_transaction: { + QUERY: never; + REQUEST: Transaction; + RESPONSE: AddTransactionResponse; + }; + get_transaction: { + QUERY: { + transactionHash: string; }; - get_transaction_trace: { - QUERY: { - transactionHash: string; - }; - REQUEST: never; - RESPONSE: TransactionTraceResponse; + REQUEST: never; + RESPONSE: GetTransactionResponse; + }; + get_transaction_status: { + QUERY: { + transactionHash: string; }; - get_transaction_receipt: { - QUERY: { - transactionHash: string; - }; - REQUEST: never; - RESPONSE: TransactionReceiptResponse; + REQUEST: never; + RESPONSE: GetTransactionStatusResponse; + }; + get_transaction_trace: { + QUERY: { + transactionHash: string; }; - get_nonce: { - QUERY: { - contractAddress: string; - blockIdentifier: BlockIdentifier; - }; - REQUEST: never; - RESPONSE: Nonce; + REQUEST: never; + RESPONSE: TransactionTraceResponse; + }; + get_transaction_receipt: { + QUERY: { + transactionHash: string; }; - get_storage_at: { - QUERY: { - contractAddress: string; - key: BigNumberish; - blockIdentifier: BlockIdentifier; - }; - REQUEST: never; - RESPONSE: Storage; + REQUEST: never; + RESPONSE: TransactionReceiptResponse; + }; + get_nonce: { + QUERY: { + contractAddress: string; + blockIdentifier: BlockIdentifier; }; - get_code: { - QUERY: { - contractAddress: string; - blockIdentifier: BlockIdentifier; - }; - REQUEST: never; - RESPONSE: GetCodeResponse; + REQUEST: never; + RESPONSE: Nonce; + }; + get_storage_at: { + QUERY: { + contractAddress: string; + key: BigNumberish; + blockIdentifier: BlockIdentifier; }; - get_block: { - QUERY: { - blockIdentifier: BlockIdentifier; - }; - REQUEST: never; - RESPONSE: GetBlockResponse; + REQUEST: never; + RESPONSE: Storage; + }; + get_code: { + QUERY: { + contractAddress: string; + blockIdentifier: BlockIdentifier; }; - call_contract: { - QUERY: { - blockIdentifier: BlockIdentifier; - }; - REQUEST: CallContractTransaction; - RESPONSE: CallContractResponse; + REQUEST: never; + RESPONSE: GetCodeResponse; + }; + get_block: { + QUERY: { + blockIdentifier: BlockIdentifier; }; - estimate_fee: { - QUERY: { - blockIdentifier: BlockIdentifier; - skipValidate: boolean; - }; - REQUEST: AccountTransactionItem; - RESPONSE: EstimateFeeResponse; + REQUEST: never; + RESPONSE: GetBlockResponse; + }; + call_contract: { + QUERY: { + blockIdentifier: BlockIdentifier; }; - get_class_by_hash: { - QUERY: { - classHash: string; - blockIdentifier?: BlockIdentifier; - }; - REQUEST: never; - RESPONSE: CompiledContract; + REQUEST: CallContractTransaction; + RESPONSE: CallContractResponse; + }; + estimate_fee: { + QUERY: { + blockIdentifier: BlockIdentifier; + skipValidate: boolean; }; - get_class_hash_at: { - QUERY: { - contractAddress: string; - blockIdentifier?: BlockIdentifier; - }; - REQUEST: never; - RESPONSE: string; + REQUEST: AccountTransactionItem; + RESPONSE: EstimateFeeResponse; + }; + get_class_by_hash: { + QUERY: { + classHash: string; + blockIdentifier?: BlockIdentifier; }; - get_state_update: { - QUERY: { - blockHash?: string; - blockNumber?: BlockNumber; - }; - REQUEST: never; - RESPONSE: StateUpdateResponse; + REQUEST: never; + RESPONSE: CompiledContract; + }; + get_class_hash_at: { + QUERY: { + contractAddress: string; + blockIdentifier?: BlockIdentifier; }; - get_full_contract: { - QUERY: { - contractAddress: string; - blockIdentifier?: BlockIdentifier; - }; - REQUEST: never; - RESPONSE: CompiledContract; + REQUEST: never; + RESPONSE: string; + }; + get_state_update: { + QUERY: { + blockHash?: string; + blockNumber?: BlockNumber; }; - estimate_message_fee: { - QUERY: any; - REQUEST: any; - RESPONSE: EstimateFeeResponse; + REQUEST: never; + RESPONSE: StateUpdateResponse; + }; + get_full_contract: { + QUERY: { + contractAddress: string; + blockIdentifier?: BlockIdentifier; }; - simulate_transaction: { - QUERY: { - blockIdentifier: BlockIdentifier; - skipValidate: boolean; - }; - REQUEST: AccountTransaction; - RESPONSE: SimulateTransactionResponse; + REQUEST: never; + RESPONSE: CompiledContract; + }; + estimate_message_fee: { + QUERY: any; + REQUEST: any; + RESPONSE: EstimateFeeResponse; + }; + simulate_transaction: { + QUERY: { + blockIdentifier: BlockIdentifier; + skipValidate: boolean; }; - estimate_fee_bulk: { - QUERY: { - blockIdentifier: BlockIdentifier; - skipValidate: boolean; - }; - REQUEST: AccountTransaction; - RESPONSE: EstimateFeeResponseBulk; + REQUEST: AccountTransaction; + RESPONSE: SimulateTransactionResponse; + }; + estimate_fee_bulk: { + QUERY: { + blockIdentifier: BlockIdentifier; + skipValidate: boolean; }; - get_block_traces: { - QUERY: { - blockHash?: string; - blockNumber?: BlockNumber; - }; - REQUEST: never; - RESPONSE: BlockTransactionTracesResponse; + REQUEST: AccountTransaction; + RESPONSE: EstimateFeeResponseBulk; + }; + get_block_traces: { + QUERY: { + blockHash?: string; + blockNumber?: BlockNumber; }; - get_compiled_class_by_class_hash: { - QUERY: { - classHash: string; - blockIdentifier?: BlockIdentifier; - }; - REQUEST: any; - RESPONSE: CairoAssembly; + REQUEST: never; + RESPONSE: BlockTransactionTracesResponse; + }; + get_compiled_class_by_class_hash: { + QUERY: { + classHash: string; + blockIdentifier?: BlockIdentifier; }; + REQUEST: any; + RESPONSE: CairoAssembly; }; -} +}; diff --git a/src/types/index.ts b/src/types/index.ts index ae41cbca2..a43534d9f 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -1,9 +1,19 @@ export * from './account'; +export * from './calldata'; export * from './contract'; export * from './lib'; export * from './provider'; export * from './signer'; export * from './typedData'; -export * from './api/sequencer'; -export * from './api/rpc'; -export * from './calldata'; + +export * as RPC from './api/rpc'; +export { + CallL1Handler, + DeployedContractItem, + ExecutionResources, + FunctionInvocation, + GetContractAddressesResponse, + GetTransactionStatusResponse, + SequencerIdentifier, +} from './api/sequencer'; +export * as Sequencer from './api/sequencer'; diff --git a/src/types/provider/response.ts b/src/types/provider/response.ts index 8bc5c516e..079cf49ed 100644 --- a/src/types/provider/response.ts +++ b/src/types/provider/response.ts @@ -3,8 +3,8 @@ * Intersection (sequencer response ∩ (∪ rpc responses)) */ -import { RPC } from '../api/rpc'; -import { Sequencer } from '../api/sequencer'; +import * as RPC from '../api/rpc'; +import * as Sequencer from '../api/sequencer'; import { AllowArray, BlockStatus, diff --git a/src/utils/json.ts b/src/utils/json.ts index dbe313d31..3d7a8a20e 100644 --- a/src/utils/json.ts +++ b/src/utils/json.ts @@ -9,12 +9,18 @@ const parseIntAsNumberOrBigInt = (x: string) => { }; // NOTE: the String() wrapping is used so the behaviour conforms to JSON.parse() // which can accept simple data types but is not represented in the default typing -export const parse = (x: string): any => json.parse(String(x), null, parseIntAsNumberOrBigInt); +export const parse = (x: string): any => json.parse(String(x), undefined, parseIntAsNumberOrBigInt); export const parseAlwaysAsBig = (x: string): any => - json.parse(String(x), null, json.parseNumberAndBigInt); + json.parse(String(x), undefined, json.parseNumberAndBigInt); // NOTE: the not-null assertion is used so the return type conforms to JSON.stringify() // which can also return undefined but is not represented in the default typing -export const stringify = (...p: Parameters): string => json.stringify(...p)!; +export const stringify = ( + value: json.JavaScriptValue, + replacer?: any, + space?: string | number | undefined, + numberStringifiers?: json.NumberStringifier[] | undefined +): string => json.stringify(value, replacer, space, numberStringifiers)!; + /** @deprecated equivalent to 'stringify', alias will be removed */ export const stringifyAlwaysAsBig = stringify; diff --git a/tsconfig.json b/tsconfig.json index 787a6e405..7051f253c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,8 +14,6 @@ "target": "ES2020" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, "lib": [ "ES2020", - "es7", - "es6", "dom" ] /* Specify a set of bundled library declaration files that describe the target runtime environment. */, // "jsx": "preserve", /* Specify what JSX code is generated. */ @@ -78,7 +76,7 @@ "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */, /* Type Checking */ - "strict": true /* Enable all strict type-checking options. */, + "strict": true /* Enable all strict type-checking options. */ // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */ // "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */ // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ @@ -100,7 +98,7 @@ /* Completeness */ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ - "skipLibCheck": true /* Skip type checking all .d.ts files. */ + // "skipLibCheck": true /* Skip type checking all .d.ts files. */ }, "include": ["src/**/*"], "exclude": ["node_modules"]