Repository: 0xs34n/starknet.js
Pull request #699 (2023-07-27 07:03:39)

Next version
## Motivation and Resolution

...

### RPC version (if applicable)

...

## Usage related changes

<!-- How the changes from this PR affect users. -->

- Change 1.
- ...

## Development related changes

<!-- How these changes affect the developers of this project - e.g. changes in testing or CI/CD. -->

- Change 1.
- ...

## Checklist:

- [ ] Performed a self-review of the code
- [ ] Rebased to the last commit of the target branch (or merged it into my branch)
- [ ] Linked the issues which this PR resolves
- [ ] Documented the changes in code (API docs will be generated automatically)
- [ ] Updated the tests
- [ ] All tests are passing



Patch:
diff --git a/src/account/default.ts b/src/account/default.ts
index 6f81513d..630f0372 100644
--- a/src/account/default.ts
+++ b/src/account/default.ts
@@ -21,6 +21,7 @@ import {
   DeployAccountContractTransaction,
   DeployContractResponse,
   DeployContractUDCResponse,
+  DeployTransactionReceiptResponse,
   Details,
   EstimateFee,
   EstimateFeeAction,
@@ -399,7 +400,7 @@ export class Account extends Provider implements AccountInterface {
   ): Promise<DeployContractUDCResponse> {
     const deployTx = await this.deploy(payload, details);
     const txReceipt = await this.waitForTransaction(deployTx.transaction_hash);
-    return parseUDCEvent(txReceipt);
+    return parseUDCEvent(txReceipt as DeployTransactionReceiptResponse);
   }
 
   public async declareAndDeploy(
diff --git a/src/constants.ts b/src/constants.ts
index df2ac851..f5c07c06 100644
--- a/src/constants.ts
+++ b/src/constants.ts
@@ -1,5 +1,8 @@
 export { IS_BROWSER } from './utils/encode';
 
+export const HEX_STR_TRANSACTION_VERSION_1 = '0x1';
+export const HEX_STR_TRANSACTION_VERSION_2 = '0x2';
+
 export const ZERO = 0n;
 export const MASK_250 = 2n ** 250n - 1n; // 2 ** 250 - 1
 export const MASK_251 = 2n ** 251n;
diff --git a/src/provider/rpc.ts b/src/provider/rpc.ts
index 263756eb..2fe3500a 100644
--- a/src/provider/rpc.ts
+++ b/src/provider/rpc.ts
@@ -1,9 +1,14 @@
-import { StarknetChainId } from '../constants';
+import {
+  HEX_STR_TRANSACTION_VERSION_1,
+  HEX_STR_TRANSACTION_VERSION_2,
+  StarknetChainId,
+} from '../constants';
 import {
   AccountInvocationItem,
   AccountInvocations,
   BigNumberish,
   BlockIdentifier,
+  BlockTag,
   Call,
   CallContractResponse,
   ContractClassResponse,
@@ -19,27 +24,24 @@ import {
   Invocation,
   InvocationsDetailsWithNonce,
   InvokeFunctionResponse,
-  LegacyContractClass,
   RPC,
   RpcProviderOptions,
-  SIMULATION_FLAG,
-  SierraContractClass,
   SimulateTransactionResponse,
-  TransactionStatus,
   TransactionType,
   getEstimateFeeBulkOptions,
   getSimulateTransactionOptions,
   waitForTransactionOptions,
 } from '../types';
+import {
+  SimulationFlag,
+  TransactionExecutionStatus,
+  TransactionFinalityStatus,
+} from '../types/api/rpc';
 import { CallData } from '../utils/calldata';
 import { isSierra } from '../utils/contract';
+import { pascalToSnake } from '../utils/encode';
 import fetch from '../utils/fetchPonyfill';
-import {
-  getSelectorFromName,
-  getVersionsByType,
-  transactionVersion,
-  transactionVersion_2,
-} from '../utils/hash';
+import { getSelectorFromName, getVersionsByType } from '../utils/hash';
 import { stringify } from '../utils/json';
 import { toHex, toStorageKey } from '../utils/num';
 import { wait } from '../utils/provider';
@@ -54,7 +56,7 @@ import { Block } from './utils';
 // Note that pending support is disabled by default and must be enabled by setting poll-pending=true in the configuration options.
 const defaultOptions = {
   headers: { 'Content-Type': 'application/json' },
-  blockIdentifier: 'latest',
+  blockIdentifier: BlockTag.pending,
   retries: 200,
 };
 
@@ -345,7 +347,7 @@ export class RpcProvider implements ProviderInterface {
             entry_points_by_type: contract.entry_points_by_type,
             abi: contract.abi,
           },
-          version: toHex(transactionVersion),
+          version: HEX_STR_TRANSACTION_VERSION_1,
           max_fee: toHex(details.maxFee || 0),
           signature: signatureToHexArray(signature),
           sender_address: senderAddress,
@@ -363,7 +365,7 @@ export class RpcProvider implements ProviderInterface {
           abi: contract.abi,
         },
         compiled_class_hash: compiledClassHash || '',
-        version: toHex(transactionVersion_2),
+        version: HEX_STR_TRANSACTION_VERSION_2,
         max_fee: toHex(details.maxFee || 0),
         signature: signatureToHexArray(signature),
         sender_address: senderAddress,
@@ -434,15 +436,17 @@ export class RpcProvider implements ProviderInterface {
   }
 
   public async waitForTransaction(txHash: string, options?: waitForTransactionOptions) {
-    const errorStates = [TransactionStatus.REJECTED, TransactionStatus.NOT_RECEIVED];
     let { retries } = this;
     let onchain = false;
+    let isErrorState = false;
+    // eslint-disable-next-line no-undef-init
     let txReceipt: any = {};
-
-    const retryInterval = options?.retryInterval ?? 8000;
-    const successStates = options?.successStates ?? [
-      TransactionStatus.ACCEPTED_ON_L1,
-      TransactionStatus.ACCEPTED_ON_L2,
+    const retryInterval = options?.retryInterval ?? 5000;
+    const errorStates: any = options?.errorStates ?? [TransactionExecutionStatus.REVERTED];
+    const successStates: any = options?.successStates ?? [
+      TransactionExecutionStatus.SUCCEEDED,
+      TransactionFinalityStatus.ACCEPTED_ON_L1,
+      TransactionFinalityStatus.ACCEPTED_ON_L2,
     ];
 
     while (!onchain) {
@@ -452,21 +456,28 @@ export class RpcProvider implements ProviderInterface {
         // eslint-disable-next-line no-await-in-loop
         txReceipt = await this.getTransactionReceipt(txHash);
 
-        if (!('status' in txReceipt)) {
-          const error = new Error('transaction status');
+        // TODO: Hotfix until Pathfinder release fixed casing
+        const executionStatus = pascalToSnake(txReceipt.execution_status);
+        const finalityStatus = pascalToSnake(txReceipt.finality_status);
+
+        if (!executionStatus || !finalityStatus) {
+          // Transaction is potentially REJECTED or NOT_RECEIVED but RPC doesn't have dose statuses
+          // so we will retry '{ retries }' times
+          const error = new Error('waiting for transaction status');
           throw error;
         }
 
-        if (txReceipt.status && successStates.includes(txReceipt.status)) {
+        if (successStates.includes(executionStatus) || successStates.includes(finalityStatus)) {
           onchain = true;
-        } else if (txReceipt.status && errorStates.includes(txReceipt.status)) {
-          const message = txReceipt.status;
-          const error = new Error(message) as Error & { response: any };
+        } else if (errorStates.includes(executionStatus) || errorStates.includes(finalityStatus)) {
+          const message = `${executionStatus}: ${finalityStatus}: ${txReceipt.revert_reason}`;
+          const error = new Error(message) as Error & { response: RPC.TransactionReceipt };
           error.response = txReceipt;
+          isErrorState = true;
           throw error;
         }
-      } catch (error: unknown) {
-        if (error instanceof Error && errorStates.includes(error.message as TransactionStatus)) {
+      } catch (error) {
+        if (error instanceof Error && isErrorState) {
           throw error;
         }
 
@@ -531,18 +542,19 @@ export class RpcProvider implements ProviderInterface {
     {
       blockIdentifier = this.blockIdentifier,
       skipValidate = false,
-      skipExecute = false,
+      skipExecute = false, // @deprecated
+      skipFeeCharge = true, // Pathfinder currently does not support `starknet_simulateTransactions` without `SKIP_FEE_CHARGE` simulation flag being set. This will become supported in a future release
     }: getSimulateTransactionOptions
   ): Promise<SimulateTransactionResponse> {
     const block_id = new Block(blockIdentifier).identifier;
 
     const simulationFlags = [];
-    if (skipValidate) simulationFlags.push(SIMULATION_FLAG.SKIP_VALIDATE);
-    if (skipExecute) simulationFlags.push(SIMULATION_FLAG.SKIP_EXECUTE);
+    if (skipValidate) simulationFlags.push(SimulationFlag.SKIP_VALIDATE);
+    if (skipExecute || skipFeeCharge) simulationFlags.push(SimulationFlag.SKIP_FEE_CHARGE);
 
-    return this.fetchEndpoint('starknet_simulateTransaction', {
+    return this.fetchEndpoint('starknet_simulateTransactions', {
       block_id,
-      transactions: invocations.map((it) => this.buildTransaction(it)), // TODO: Pathfinder 0.5.6 bug, should be transaction
+      transactions: invocations.map((it) => this.buildTransaction(it)),
       simulation_flags: simulationFlags,
     }).then(this.responseParser.parseSimulateTransactionResponse);
   }
@@ -558,7 +570,7 @@ export class RpcProvider implements ProviderInterface {
   public buildTransaction(
     invocation: AccountInvocationItem,
     versionType?: 'fee' | 'transaction'
-  ): RPC.BroadcastedTransaction {
+  ): RPC.BaseTransaction {
     const defaultVersions = getVersionsByType(versionType);
     const details = {
       signature: signatureToHexArray(invocation.signature),
@@ -571,32 +583,30 @@ export class RpcProvider implements ProviderInterface {
         type: RPC.TransactionType.INVOKE, // Diff between sequencer and rpc invoke type
         sender_address: invocation.contractAddress,
         calldata: CallData.toHex(invocation.calldata),
-        version: toHex(invocation.version || defaultVersions.v1),
+        version: toHex(invocation.version || defaultVersions.v1) as any, // HEX_STR_TRANSACTION_VERSION_1, // as any HOTFIX TODO: Resolve spec version
         ...details,
       };
     }
-    if (invocation.type === RPC.TransactionType.DECLARE) {
+    if (invocation.type === TransactionType.DECLARE) {
       if (!isSierra(invocation.contract)) {
-        const legacyContract = invocation.contract as LegacyContractClass;
         return {
           type: invocation.type,
-          contract_class: legacyContract,
+          contract_class: invocation.contract,
           sender_address: invocation.senderAddress,
-          version: toHex(invocation.version || defaultVersions.v1),
+          version: toHex(invocation.version || defaultVersions.v1) as any, // HEX_STR_TRANSACTION_VERSION_1, // as any HOTFIX TODO: Resolve spec version
           ...details,
         };
       }
-      const sierraContract = invocation.contract as SierraContractClass;
       return {
         // compiled_class_hash
         type: invocation.type,
         contract_class: {
-          ...sierraContract,
-          sierra_program: decompressProgram(sierraContract.sierra_program),
+          ...invocation.contract,
+          sierra_program: decompressProgram(invocation.contract.sierra_program),
         },
         compiled_class_hash: invocation.compiledClassHash || '',
         sender_address: invocation.senderAddress,
-        version: toHex(invocation.version || defaultVersions.v2),
+        version: toHex(invocation.version || defaultVersions.v2) as any, // HEX_STR_TRANSACTION_VERSION_2, // as any HOTFIX TODO: Resolve spec version
         ...details,
       };
     }
diff --git a/src/provider/sequencer.ts b/src/provider/sequencer.ts
index 2a3a140e..77d94d33 100644
--- a/src/provider/sequencer.ts
+++ b/src/provider/sequencer.ts
@@ -31,7 +31,8 @@ import {
   SequencerProviderOptions,
   SimulateTransactionResponse,
   StateUpdateResponse,
-  TransactionStatus,
+  TransactionExecutionStatus,
+  TransactionFinalityStatus,
   TransactionType,
   getEstimateFeeBulkOptions,
   getSimulateTransactionOptions,
@@ -489,27 +490,46 @@ export class SequencerProvider implements ProviderInterface {
   }
 
   public async waitForTransaction(txHash: BigNumberish, options?: waitForTransactionOptions) {
-    const errorStates = [TransactionStatus.REJECTED, TransactionStatus.NOT_RECEIVED];
-    let onchain = false;
     let res;
-    const retryInterval = options?.retryInterval ?? 8000;
+    let completed = false;
+    let retries = 0;
+    const retryInterval = options?.retryInterval ?? 5000;
+    const errorStates = options?.errorStates ?? [
+      TransactionExecutionStatus.REJECTED,
+      TransactionFinalityStatus.NOT_RECEIVED,
+      TransactionExecutionStatus.REVERTED,
+    ];
     const successStates = options?.successStates ?? [
-      TransactionStatus.ACCEPTED_ON_L1,
-      TransactionStatus.ACCEPTED_ON_L2,
+      TransactionExecutionStatus.SUCCEEDED,
+      TransactionFinalityStatus.ACCEPTED_ON_L1,
+      TransactionFinalityStatus.ACCEPTED_ON_L2,
     ];
 
-    while (!onchain) {
+    while (!completed) {
       // eslint-disable-next-line no-await-in-loop
       await wait(retryInterval);
       // eslint-disable-next-line no-await-in-loop
       res = await this.getTransactionStatus(txHash);
 
-      if (successStates.includes(res.tx_status)) {
-        onchain = true;
-      } else if (errorStates.includes(res.tx_status)) {
-        const message = res.tx_failure_reason
-          ? `${res.tx_status}: ${res.tx_failure_reason.code}\n${res.tx_failure_reason.error_message}`
-          : res.tx_status;
+      if (TransactionFinalityStatus.NOT_RECEIVED === res.finality_status && retries < 3) {
+        retries += 1;
+      } else if (
+        successStates.includes(res.finality_status) ||
+        successStates.includes(res.execution_status)
+      ) {
+        completed = true;
+      } else if (
+        errorStates.includes(res.finality_status) ||
+        errorStates.includes(res.execution_status)
+      ) {
+        let message;
+        if (res.tx_failure_reason) {
+          message = `${res.tx_status}: ${res.tx_failure_reason.code}\n${res.tx_failure_reason.error_message}`;
+        } else if (res.tx_revert_reason) {
+          message = `${res.tx_status}: ${res.tx_revert_reason}`;
+        } else {
+          message = res.tx_status;
+        }
         const error = new Error(message) as Error & { response: GetTransactionStatusResponse };
         error.response = res;
         throw error;
diff --git a/src/types/account.ts b/src/types/account.ts
index b1c50f78..32c587cd 100644
--- a/src/types/account.ts
+++ b/src/types/account.ts
@@ -56,6 +56,6 @@ export type SimulateTransactionDetails = {
 };
 
 export enum SIMULATION_FLAG {
-  SKIP_VALIDATE,
-  SKIP_EXECUTE,
+  SKIP_VALIDATE = 'SKIP_VALIDATE',
+  SKIP_EXECUTE = 'SKIP_EXECUTE',
 }
diff --git a/src/types/api/openrpc.ts b/src/types/api/openrpc.ts
index 7d9a8e54..8cb2cd5d 100644
--- a/src/types/api/openrpc.ts
+++ b/src/types/api/openrpc.ts
@@ -1,23 +1,37 @@
 /**
- * Starknet RPC version 0.3.0
+ * TypeScript Representation of 'starknet-specs' (OpenRpc protocol types)
+ * https://github.com/starkware-libs/starknet-specs/tree/v0.4.0-rc3
  *
- * Starknet Node API 0.50.0 - rpc 0.3.0
- * Starknet Node Write API 0.4.0 - rpc 0.3.0
- * Starknet Trace API 0.4.0 - rpc 0.3.0
- *
- * TypeScript Representation of OpenRpc protocol types
+ * Starknet Node Read API  0.4.0 - rpc tag v0.4.0-rc3
+ * Starknet Node Write API 0.4.0 - rpc tag v0.4.0-rc3
+ * Starknet Node Trace API 0.4.0 - rpc tag v0.4.0-rc3
  */
 
+/**
+ * A field element. represented by at most 63 hex digits
+ * @pattern ^0x(0|[a-fA-F1-9]{1}[a-fA-F0-9]{0,62})$
+ */
 export type FELT = string;
 export type ADDRESS = FELT;
 type NUM_AS_HEX = string;
 type SIGNATURE = Array<FELT>;
-// type ETH_ADDRESS = string;
+/**
+ * an ethereum address represented as 40 hex digits
+ * @pattern ^0x[a-fA-F0-9]{40}$
+ */
+type ETH_ADDRESS = string;
 type BLOCK_NUMBER = number;
 type BLOCK_HASH = FELT;
 type TXN_HASH = FELT;
-type TXN_STATUS = 'ACCEPTED_ON_L2' | 'ACCEPTED_ON_L1' | 'REJECTED';
-export type TXN_TYPE = 'DECLARE' | 'DEPLOY' | 'DEPLOY_ACCOUNT' | 'INVOKE' | 'L1_HANDLER';
+
+export enum TXN_TYPE {
+  DECLARE = 'DECLARE',
+  DEPLOY = 'DEPLOY',
+  DEPLOY_ACCOUNT = 'DEPLOY_ACCOUNT',
+  INVOKE = 'INVOKE',
+  L1_HANDLER = 'L1_HANDLER',
+}
+
 type BLOCK_STATUS = 'PENDING' | 'ACCEPTED_ON_L2' | 'ACCEPTED_ON_L1' | 'REJECTED';
 enum BLOCK_TAG {
   latest = 'latest',
@@ -28,6 +42,24 @@ type MSG_TO_L1 = {
   to_address: FELT;
   payload: Array<FELT>;
 };
+
+type MSG_FROM_L1 = {
+  from_address: ETH_ADDRESS;
+  to_address: ADDRESS;
+  entry_point_selector: FELT;
+  payload: FELT[];
+};
+
+export enum TXN_FINALITY_STATUS {
+  ACCEPTED_ON_L2 = 'ACCEPTED_ON_L2',
+  ACCEPTED_ON_L1 = 'ACCEPTED_ON_L1',
+}
+
+export enum TXN_EXECUTION_STATUS {
+  SUCCEEDED = 'SUCCEEDED',
+  REVERTED = 'REVERTED',
+}
+
 type EVENT = {
   from_address: FELT;
   keys: Array<FELT>;
@@ -37,11 +69,13 @@ type EVENT = {
 type COMMON_RECEIPT_PROPERTIES = {
   transaction_hash: TXN_HASH;
   actual_fee: FELT;
-  status: TXN_STATUS;
+  execution_status: TXN_EXECUTION_STATUS;
+  finality_status: TXN_FINALITY_STATUS;
   block_hash?: BLOCK_HASH;
   block_number?: BLOCK_NUMBER;
   messages_sent: Array<MSG_TO_L1>;
   events: Array<EVENT>;
+  revert_reason?: string;
 };
 
 type PENDING_COMMON_RECEIPT_PROPERTIES = {
@@ -50,6 +84,9 @@ type PENDING_COMMON_RECEIPT_PROPERTIES = {
   type?: TXN_TYPE;
   messages_sent: Array<MSG_TO_L1>;
   events: Array<EVENT>;
+  execution_status: TXN_EXECUTION_STATUS;
+  finality_status: TXN_FINALITY_STATUS;
+  revert_reason?: string;
 };
 
 type INVOKE_TXN_RECEIPT = { type: 'INVOKE' } & COMMON_RECEIPT_PROPERTIES;
@@ -96,37 +133,55 @@ type PENDING_BLOCK_WITH_TX_HASHES = BLOCK_BODY_WITH_TX_HASHES & {
   sequencer_address: FELT;
   parent_hash: BLOCK_HASH;
 };
-// transaction_hash, nonce, type optional because of pathfinder not implemented
-type COMMON_TXN_PROPERTIES = {
-  transaction_hash: TXN_HASH;
-} & BROADCASTED_TXN_COMMON_PROPERTIES;
+
 type FUNCTION_CALL = {
   contract_address: ADDRESS;
   entry_point_selector: FELT;
   calldata: Array<FELT>;
 };
-type INVOKE_TXN = { type: 'INVOKE' } & COMMON_TXN_PROPERTIES & (INVOKE_TXN_V0 | INVOKE_TXN_V1);
+
+type INVOKE_TXN = INVOKE_TXN_V0 | INVOKE_TXN_V1;
+
 type DECLARE_TXN = DECLARE_TXN_V1 | DECLARE_TXN_V2;
-type DECLARE_TXN_V1 = COMMON_TXN_PROPERTIES & {
+
+type DECLARE_TXN_V1 = {
   type: 'DECLARE';
-  class_hash: FELT;
   sender_address: ADDRESS;
-};
-type DECLARE_TXN_V2 = DECLARE_TXN_V1 & { compiled_class_hash: FELT };
-type DEPLOY_TXN = {
-  transaction_hash: TXN_HASH;
-  class_hash: FELT;
-} & DEPLOY_TXN_PROPERTIES;
+  max_fee: FELT;
+  version: '0x1';
+  signature: SIGNATURE;
+  nonce: FELT;
+} & ({ contract_class: DEPRECATED_CONTRACT_CLASS } | { class_hash: FELT });
 
-type DEPLOY_ACCOUNT_TXN = COMMON_TXN_PROPERTIES & DEPLOY_ACCOUNT_TXN_PROPERTIES;
+type DECLARE_TXN_V2 = {
+  type: 'DECLARE';
+  sender_address: ADDRESS;
+  compiled_class_hash: FELT;
+  max_fee: FELT;
+  version: '0x2';
+  signature: SIGNATURE;
+  nonce: FELT;
+} & ({ contract_class: CONTRACT_CLASS } | { class_hash: FELT });
 
-type DEPLOY_ACCOUNT_TXN_PROPERTIES = {
+type DEPLOY_ACCOUNT_TXN = {
   type: 'DEPLOY_ACCOUNT';
+  max_fee: FELT;
+  version: NUM_AS_HEX;
+  signature: SIGNATURE;
+  nonce: FELT;
   contract_address_salt: FELT;
-  constructor_calldata: Array<FELT>;
+  constructor_calldata: FELT[];
   class_hash: FELT;
 };
 
+type DEPLOY_TXN = {
+  type: 'DEPLOY';
+  contract_address_salt: FELT;
+  constructor_calldata: FELT[];
+  class_hash: FELT;
+  version: NUM_AS_HEX;
+};
+
 type DEPLOY_ACCOUNT_TXN_RECEIPT = COMMON_RECEIPT_PROPERTIES & {
   type: 'DEPLOY_ACCOUNT';
   contract_address: FELT;
@@ -134,68 +189,40 @@ type DEPLOY_ACCOUNT_TXN_RECEIPT = COMMON_RECEIPT_PROPERTIES & {
 
 type TXN = INVOKE_TXN | L1_HANDLER_TXN | DECLARE_TXN | DEPLOY_TXN | DEPLOY_ACCOUNT_TXN;
 
+type TXN_WITH_HASH = TXN & { transaction_hash: TXN_HASH };
+
 enum L1_HANDLER {
   'L1_HANDLER',
 }
 
 type L1_HANDLER_TXN = {
-  transaction_hash: TXN_HASH;
   version: NUM_AS_HEX;
   type: L1_HANDLER;
   nonce: NUM_AS_HEX;
 } & FUNCTION_CALL;
 
-type BROADCASTED_DEPLOY_ACCOUNT_TXN = BROADCASTED_TXN_COMMON_PROPERTIES &
-  DEPLOY_ACCOUNT_TXN_PROPERTIES;
-
-type BROADCASTED_TXN =
-  | BROADCASTED_INVOKE_TXN
-  | BROADCASTED_DECLARE_TXN
-  | BROADCASTED_DEPLOY_ACCOUNT_TXN;
-
-type BROADCASTED_INVOKE_TXN = BROADCASTED_TXN_COMMON_PROPERTIES & { type: 'INVOKE' } & (
-    | INVOKE_TXN_V0
-    | INVOKE_TXN_V1
-  );
-
-type BROADCASTED_TXN_COMMON_PROPERTIES = {
+type INVOKE_TXN_V0 = {
+  type: 'INVOKE';
   max_fee: FELT;
-  version: NUM_AS_HEX;
+  version: '0x0';
   signature: SIGNATURE;
-  nonce: FELT;
-};
-
-type BROADCASTED_DECLARE_TXN = BROADCASTED_DECLARE_TXN_V1 | BROADCASTED_DECLARE_TXN_V2;
-
-type BROADCASTED_DECLARE_TXN_V1 = {
-  type: 'DECLARE';
-  contract_class: DEPRECATED_CONTRACT_CLASS;
-  sender_address: ADDRESS;
-} & BROADCASTED_TXN_COMMON_PROPERTIES;
-
-type BROADCASTED_DECLARE_TXN_V2 = {
-  type: 'DECLARE';
-  contract_class: CONTRACT_CLASS;
-  sender_address: ADDRESS;
-  compiled_class_hash: FELT;
-} & BROADCASTED_TXN_COMMON_PROPERTIES;
-
-type DEPLOY_TXN_PROPERTIES = {
-  type: 'DEPLOY';
-  version: NUM_AS_HEX;
-  contract_address_salt: FELT;
-  constructor_calldata: Array<FELT>;
+  contract_address: ADDRESS;
+  entry_point_selector: FELT;
+  calldata: FELT[];
 };
 
-type INVOKE_TXN_V0 = FUNCTION_CALL;
-
 type INVOKE_TXN_V1 = {
+  type: 'INVOKE';
   sender_address: ADDRESS;
-  calldata: Array<FELT>;
+  calldata: FELT[];
+  max_fee: FELT;
+  version: '0x1';
+  signature: SIGNATURE;
+  nonce: FELT;
 };
 
 type BLOCK_BODY_WITH_TXS = {
-  transactions: Array<TXN>;
+  transactions: Array<TXN_WITH_HASH>;
 };
 type BLOCK_WITH_TXS = {
   status: BLOCK_STATUS;
@@ -305,12 +332,18 @@ type PENDING_STATE_UPDATE = {
     }>;
   };
 };
+
+/**
+ * A storage key. Represented as up to 62 hex digits, 3 bits, and 5 leading zeroes.
+ * @pattern ^0x0[0-7]{1}[a-fA-F0-9]{0,62}$
+ */
 type STORAGE_KEY = string;
+
 type EVENT_FILTER = {
-  from_block: BLOCK_ID;
-  to_block: BLOCK_ID;
-  address: ADDRESS;
-  keys: Array<Array<FELT>>;
+  from_block?: BLOCK_ID;
+  to_block?: BLOCK_ID;
+  address?: ADDRESS;
+  keys?: Array<Array<FELT>>;
 };
 type EVENTS_CHUNK = {
   events: Array<EMITTED_EVENT>;
@@ -327,11 +360,11 @@ type EMITTED_EVENT = EVENT & {
 };
 type SYNC_STATUS = {
   starting_block_hash: BLOCK_HASH;
-  starting_block_num: NUM_AS_HEX;
+  starting_block_num: BLOCK_NUMBER;
   current_block_hash: BLOCK_HASH;
-  current_block_num: NUM_AS_HEX;
+  current_block_num: BLOCK_NUMBER;
   highest_block_hash: BLOCK_HASH;
-  highest_block_num: NUM_AS_HEX;
+  highest_block_num: BLOCK_NUMBER;
 };
 type FEE_ESTIMATE = {
   gas_consumed: NUM_AS_HEX;
@@ -350,7 +383,7 @@ enum ENTRY_POINT_TYPE {
 }
 type FUNCTION_INVOCATION = FUNCTION_CALL & {
   caller_address: FELT;
-  code_address: FELT;
+  class_hash: FELT;
   entry_point_type: ENTRY_POINT_TYPE;
   call_type: CALL_TYPE;
   result: FELT;
@@ -362,7 +395,7 @@ type NESTED_CALL = FUNCTION_INVOCATION;
 
 type INVOKE_TXN_TRACE = {
   validate_invocation: FUNCTION_INVOCATION;
-  execute_invocation: FUNCTION_INVOCATION;
+  execute_invocation: FUNCTION_INVOCATION | { revert_reason: string };
   fee_transfer_invocation: FUNCTION_INVOCATION;
 };
 
@@ -387,9 +420,9 @@ type TRANSACTION_TRACE =
   | DEPLOY_ACCOUNT_TXN_TRACE
   | L1_HANDLER_TXN_TRACE;
 
-enum SIMULATION_FLAG {
-  SKIP_VALIDATE,
-  SKIP_EXECUTE,
+export enum SIMULATION_FLAG {
+  SKIP_VALIDATE = 'SKIP_VALIDATE',
+  SKIP_FEE_CHARGE = 'SKIP_FEE_CHARGE',
 }
 
 export namespace OPENRPC {
@@ -399,6 +432,7 @@ export namespace OPENRPC {
   export type StateUpdate = STATE_UPDATE | PENDING_STATE_UPDATE;
   export type Storage = FELT;
   export type Transaction = TXN;
+  export type TransactionWithHash = TXN_WITH_HASH;
   export type TransactionReceipt = TXN_RECEIPT;
   export type ContractClass = CONTRACT_CLASS;
   export type DeprecatedContractClass = DEPRECATED_CONTRACT_CLASS;
@@ -410,7 +444,7 @@ export namespace OPENRPC {
     block_number: BLOCK_NUMBER;
   };
   export type CHAIN_ID = string;
-  export type PendingTransactions = Array<TXN>;
+  export type PendingTransactions = Array<TransactionWithHash>;
   export type SyncingStatus = false | SYNC_STATUS;
   export type Events = EVENTS_CHUNK;
   export type Trace = TRANSACTION_TRACE;
@@ -424,7 +458,6 @@ export namespace OPENRPC {
   export type InvokedTransaction = { transaction_hash: TXN_HASH };
   export type DeclaredTransaction = { transaction_hash: TXN_HASH; class_hash: FELT };
   export type DeployedTransaction = { transaction_hash: TXN_HASH; contract_address: FELT };
-  export type BroadcastedTransaction = BROADCASTED_TXN;
 
   export type SimulationFlags = Array<SIMULATION_FLAG>;
   export type SimulatedTransaction = {
@@ -433,6 +466,8 @@ export namespace OPENRPC {
   };
   export type SimulatedTransactions = SimulatedTransaction[];
 
+  export type BaseTransaction = DECLARE_TXN | INVOKE_TXN | DEPLOY_ACCOUNT_TXN;
+
   // Final Methods
   export type Methods = {
     // Read API
@@ -458,12 +493,12 @@ export namespace OPENRPC {
     };
     starknet_getTransactionByHash: {
       params: { transaction_hash: TXN_HASH };
-      result: Transaction;
+      result: TransactionWithHash;
       errors: Errors.TXN_HASH_NOT_FOUND;
     };
     starknet_getTransactionByBlockIdAndIndex: {
       params: { block_id: BLOCK_ID; index: number };
-      result: Transaction;
+      result: TransactionWithHash;
       errors: Errors.BLOCK_NOT_FOUND | Errors.INVALID_TXN_INDEX;
     };
     starknet_getTransactionReceipt: {
@@ -502,10 +537,19 @@ export namespace OPENRPC {
         | Errors.BLOCK_NOT_FOUND;
     };
     starknet_estimateFee: {
-      params: { request: Array<BROADCASTED_TXN>; block_id: BLOCK_ID };
+      params: { request: Array<BaseTransaction>; block_id: BLOCK_ID };
       result: Array<FEE_ESTIMATE>;
       errors: Errors.CONTRACT_NOT_FOUND | Errors.CONTRACT_ERROR | Errors.BLOCK_NOT_FOUND;
     };
+    /**
+     * estimate the L2 fee of a message sent on L1
+     * estimates the resources required by the l1_handler transaction induced by the message
+     */
+    starknet_estimateMessageFee: {
+      params: { message: MSG_FROM_L1; block_id: BLOCK_ID };
+      result: FEE_ESTIMATE;
+      errors: Errors.CONTRACT_NOT_FOUND | Errors.CONTRACT_ERROR | Errors.BLOCK_NOT_FOUND;
+    };
     starknet_blockNumber: {
       params: {};
       result: BLOCK_NUMBER;
@@ -546,47 +590,80 @@ export namespace OPENRPC {
     // Write API
     starknet_addInvokeTransaction: {
       params: {
-        invoke_transaction: BROADCASTED_INVOKE_TXN;
+        invoke_transaction: INVOKE_TXN_V1;
       };
       result: InvokedTransaction;
+      errors:
+        | Errors.INSUFFICIENT_ACCOUNT_BALANCE
+        | Errors.INSUFFICIENT_MAX_FEE
+        | Errors.INVALID_TRANSACTION_NONCE
+        | Errors.VALIDATION_FAILURE
+        | Errors.NON_ACCOUNT
+        | Errors.DUPLICATE_TX
+        | Errors.UNSUPPORTED_TX_VERSION
+        | Errors.UNEXPECTED_ERROR;
     };
+
     starknet_addDeclareTransaction: {
       params: {
-        declare_transaction: BROADCASTED_DECLARE_TXN;
+        declare_transaction: DECLARE_TXN;
       };
       result: DeclaredTransaction;
-      errors: Errors.INVALID_CONTRACT_CLASS | Errors.CLASS_ALREADY_DECLARED;
+      errors:
+        | Errors.CLASS_ALREADY_DECLARED
+        | Errors.COMPILATION_FAILED
+        | Errors.COMPILED_CLASS_HASH_MISMATCH
+        | Errors.INSUFFICIENT_ACCOUNT_BALANCE
+        | Errors.INSUFFICIENT_MAX_FEE
+        | Errors.INVALID_TRANSACTION_NONCE
+        | Errors.VALIDATION_FAILURE
+        | Errors.NON_ACCOUNT
+        | Errors.DUPLICATE_TX
+        | Errors.CONTRACT_CLASS_SIZE_IS_TOO_LARGE
+        | Errors.UNSUPPORTED_TX_VERSION
+        | Errors.UNSUPPORTED_CONTRACT_CLASS_VERSION
+        | Errors.UNEXPECTED_ERROR;
     };
+
     starknet_addDeployAccountTransaction: {
       params: {
-        deploy_account_transaction: BROADCASTED_DEPLOY_ACCOUNT_TXN;
+        deploy_account_transaction: DEPLOY_ACCOUNT_TXN;
       };
       result: {
         transaction_hash: TXN_HASH;
         contract_address: FELT;
       };
-      errors: Errors.CLASS_HASH_NOT_FOUND;
+      errors:
+        | Errors.INSUFFICIENT_ACCOUNT_BALANCE
+        | Errors.INSUFFICIENT_MAX_FEE
+        | Errors.INVALID_TRANSACTION_NONCE
+        | Errors.VALIDATION_FAILURE
+        | Errors.NON_ACCOUNT
+        | Errors.CLASS_HASH_NOT_FOUND
+        | Errors.DUPLICATE_TX
+        | Errors.UNSUPPORTED_TX_VERSION
+        | Errors.UNEXPECTED_ERROR;
     };
 
     // Trace API
     starknet_traceTransaction: {
       params: { transaction_hash: TXN_HASH };
       result: Trace;
-      errors:
-        | Errors.TXN_HASH_NOT_FOUND
-        | Errors.NO_TRACE_AVAILABLE
-        | Errors.INVALID_BLOCK_HASH
-        | Errors.TXN_HASH_NOT_FOUND;
+      errors: Errors.INVALID_TXN_HASH | Errors.NO_TRACE_AVAILABLE;
     };
     starknet_traceBlockTransactions: {
       params: { block_hash: BLOCK_HASH };
       result: Traces;
       errors: Errors.INVALID_BLOCK_HASH;
     };
-    starknet_simulateTransaction: {
+    /**
+     * simulate a given sequence of transactions on the requested state, and generate the execution traces.
+     * If one of the transactions is reverted, raises CONTRACT_ERROR
+     */
+    starknet_simulateTransactions: {
       params: {
         block_id: BLOCK_ID;
-        transactions: Array<BROADCASTED_TXN>; // Pathfinder 0.5.6 bug, should be transaction
+        transactions: Array<BaseTransaction>;
         simulation_flags: Array<SIMULATION_FLAG>;
       };
       result: SimulatedTransactions;
@@ -601,6 +678,14 @@ export namespace Errors {
     message: 'Failed to write transaction';
   }
 
+  export interface NO_TRACE_AVAILABLE {
+    code: 10;
+    message: 'No trace available for transaction';
+    data: {
+      status: 'RECEIVED' | 'REJECTED';
+    };
+  }
+
   export interface CONTRACT_NOT_FOUND {
     code: 20;
     message: 'Contract not found';
@@ -621,6 +706,16 @@ export namespace Errors {
     message: 'Block not found';
   }
 
+  export interface INVALID_TXN_HASH {
+    code: 25;
+    message: 'Invalid transaction hash';
+  }
+
+  export interface INVALID_BLOCK_HASH {
+    code: 26;
+    message: 'Invalid block hash';
+  }
+
   export interface INVALID_TXN_INDEX {
     code: 27;
     message: 'Invalid transaction index in a block';
@@ -631,6 +726,11 @@ export namespace Errors {
     message: 'Class hash not found';
   }
 
+  export interface TXN_HASH_NOT_FOUND {
+    code: 29;
+    message: 'Transaction hash not found';
+  }
+
   export interface PAGE_SIZE_TOO_BIG {
     code: 31;
     message: 'Requested page size is too big';
@@ -656,31 +756,69 @@ export namespace Errors {
     message: 'Contract error';
   }
 
-  export interface INVALID_CONTRACT_CLASS {
-    code: 50;
-    message: 'Invalid contract class';
-  }
-
   export interface CLASS_ALREADY_DECLARED {
     code: 51;
     message: 'Class already declared';
   }
 
-  export interface NO_TRACE_AVAILABLE {
-    code: 10;
-    message: 'No trace available for transaction';
-    data: {
-      status: 'RECEIVED' | 'REJECTED';
-    };
+  export interface INVALID_TRANSACTION_NONCE {
+    code: 52;
+    message: 'Invalid transaction nonce';
   }
 
-  export interface INVALID_BLOCK_HASH {
-    code: 24;
-    message: 'Invalid block hash';
+  export interface INSUFFICIENT_MAX_FEE {
+    code: 53;
+    message: 'Max fee is smaller than the minimal transaction cost (validation plus fee transfer)';
   }
 
-  export interface TXN_HASH_NOT_FOUND {
-    code: 25;
-    message: 'Transaction hash not found';
+  export interface INSUFFICIENT_ACCOUNT_BALANCE {
+    code: 54;
+    message: "Account balance is smaller than the transaction's max_fee";
+  }
+
+  export interface VALIDATION_FAILURE {
+    code: 55;
+    message: 'Account validation failed';
+  }
+
+  export interface COMPILATION_FAILED {
+    code: 56;
+    message: 'Compilation failed';
+  }
+
+  export interface CONTRACT_CLASS_SIZE_IS_TOO_LARGE {
+    code: 57;
+    message: 'Contract class size it too large';
+  }
+
+  export interface NON_ACCOUNT {
+    code: 58;
+    message: 'Sender address in not an account contract';
+  }
+
+  export interface DUPLICATE_TX {
+    code: 59;
+    message: 'A transaction with the same hash already exists in the mempool';
+  }
+
+  export interface COMPILED_CLASS_HASH_MISMATCH {
+    code: 60;
+    message: 'the compiled class hash did not match the one supplied in the transaction';
+  }
+
+  export interface UNSUPPORTED_TX_VERSION {
+    code: 61;
+    message: 'the transaction version is not supported';
+  }
+
+  export interface UNSUPPORTED_CONTRACT_CLASS_VERSION {
+    code: 62;
+    message: 'the contract class version is not supported';
+  }
+
+  export interface UNEXPECTED_ERROR {
+    code: 63;
+    message: 'An unexpected error occured';
+    data: string;
   }
 }
diff --git a/src/types/api/rpc.ts b/src/types/api/rpc.ts
index 74bb1b8e..a446462d 100644
--- a/src/types/api/rpc.ts
+++ b/src/types/api/rpc.ts
@@ -1,4 +1,13 @@
-import { ADDRESS, CONTRACT_STORAGE_DIFF_ITEM, FELT, OPENRPC } from './openrpc';
+import {
+  ADDRESS,
+  CONTRACT_STORAGE_DIFF_ITEM,
+  FELT,
+  OPENRPC,
+  SIMULATION_FLAG,
+  TXN_EXECUTION_STATUS,
+  TXN_FINALITY_STATUS,
+  TXN_TYPE,
+} from './openrpc';
 
 export type Response = {
   id: number;
@@ -40,19 +49,15 @@ 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',
-}
+export const TransactionType = TXN_TYPE;
+export const SimulationFlag = SIMULATION_FLAG;
+export const TransactionFinalityStatus = TXN_FINALITY_STATUS;
+export const TransactionExecutionStatus = TXN_EXECUTION_STATUS;
+export type BaseTransaction = OPENRPC.BaseTransaction & { version: string };
 
 // Exported Diff on Sequencer (can be removed when diff resolved by new RPC v)
 export type StorageDiffs = Array<CONTRACT_STORAGE_DIFF_ITEM>;
diff --git a/src/types/api/sequencer.ts b/src/types/api/sequencer.ts
index bb446bd9..1b1f9e78 100644
--- a/src/types/api/sequencer.ts
+++ b/src/types/api/sequencer.ts
@@ -11,6 +11,8 @@ import {
   ContractClass,
   EntryPointType,
   RawCalldata,
+  TransactionExecutionStatus,
+  TransactionFinalityStatus,
   TransactionStatus,
   TransactionType,
 } from '../lib';
@@ -18,11 +20,14 @@ import {
 // #region | originally not included in the namespace
 export type GetTransactionStatusResponse = {
   tx_status: TransactionStatus;
+  execution_status: TransactionExecutionStatus;
+  finality_status: TransactionFinalityStatus;
   block_hash?: string;
   tx_failure_reason?: {
     code: string;
     error_message: string;
   };
+  tx_revert_reason?: string;
 };
 
 export type GetContractAddressesResponse = {
@@ -151,11 +156,24 @@ export type TransactionResponse =
   | InvokeFunctionTransactionResponse;
 
 export type SuccessfulTransactionResponse = {
+  execution_status: TransactionExecutionStatus.SUCCEEDED;
+  finality_status: TransactionFinalityStatus;
   status: TransactionStatus;
+  block_hash: string;
+  block_number: BlockNumber;
+  transaction_index: number;
   transaction: TransactionResponse;
+};
+
+export type RevertedTransactionResponse = {
+  execution_status: TransactionExecutionStatus.REVERTED;
+  finality_status: TransactionFinalityStatus;
+  status: TransactionStatus;
   block_hash: string;
   block_number: BlockNumber;
   transaction_index: number;
+  transaction: TransactionResponse;
+  revert_error: string;
 };
 
 export type FailedTransactionResponse = {
@@ -167,33 +185,55 @@ export type FailedTransactionResponse = {
   transaction: TransactionResponse;
 };
 
-export type GetTransactionResponse = SuccessfulTransactionResponse | FailedTransactionResponse;
+export type GetTransactionResponse =
+  | SuccessfulTransactionResponse
+  | RevertedTransactionResponse
+  | FailedTransactionResponse;
 
 export type TransactionReceiptResponse =
   | SuccessfulTransactionReceiptResponse
-  | FailedTransactionReceiptResponse;
+  | RevertedTransactionReceiptResponse
+  | RejectedTransactionReceiptResponse;
 
 export type SuccessfulTransactionReceiptResponse = {
+  execution_status: TransactionExecutionStatus.SUCCEEDED;
+  finality_status: TransactionFinalityStatus;
   status: TransactionStatus;
+  actual_fee: string;
+  block_hash: string;
+  block_number: BlockNumber;
   transaction_hash: string;
   transaction_index: number;
+  l2_to_l1_messages: string[];
+  events: string[];
+  execution_resources?: ExecutionResources; // INVOKE ONLY
+};
+
+export type RevertedTransactionReceiptResponse = {
+  execution_status: TransactionExecutionStatus.REVERTED;
+  finality_status: TransactionFinalityStatus;
+  status: TransactionStatus.REVERTED;
+  actual_fee: string;
   block_hash: string;
   block_number: BlockNumber;
+  transaction_hash: string;
+  transaction_index: number;
   l2_to_l1_messages: string[];
   events: string[];
-  actual_fee: string;
-  execution_resources: ExecutionResources;
+  revert_error: string;
 };
 
-export type FailedTransactionReceiptResponse = {
+export type RejectedTransactionReceiptResponse = {
+  execution_status: TransactionExecutionStatus.REJECTED;
+  finality_status: TransactionFinalityStatus;
   status: TransactionStatus.REJECTED;
+  transaction_hash: string;
+  l2_to_l1_messages: string[];
+  events: string[];
   transaction_failure_reason: {
     code: string;
     error_message: string;
   };
-  transaction_hash: string;
-  l2_to_l1_messages: string[];
-  events: string[];
 };
 
 export type GetBlockResponse = {
diff --git a/src/types/lib/index.ts b/src/types/lib/index.ts
index 930affd4..35a3b5c0 100644
--- a/src/types/lib/index.ts
+++ b/src/types/lib/index.ts
@@ -133,12 +133,30 @@ export enum TransactionType {
   INVOKE = 'INVOKE_FUNCTION',
 }
 
+/**
+ * new statuses are defined by props: finality_status and execution_status
+ * to be #deprecated
+ */
 export enum TransactionStatus {
   NOT_RECEIVED = 'NOT_RECEIVED',
   RECEIVED = 'RECEIVED',
   ACCEPTED_ON_L2 = 'ACCEPTED_ON_L2',
   ACCEPTED_ON_L1 = 'ACCEPTED_ON_L1',
   REJECTED = 'REJECTED',
+  REVERTED = 'REVERTED',
+}
+
+export enum TransactionFinalityStatus {
+  NOT_RECEIVED = 'NOT_RECEIVED',
+  RECEIVED = 'RECEIVED',
+  ACCEPTED_ON_L2 = 'ACCEPTED_ON_L2',
+  ACCEPTED_ON_L1 = 'ACCEPTED_ON_L1',
+}
+
+export enum TransactionExecutionStatus {
+  REJECTED = 'REJECTED',
+  REVERTED = 'REVERTED',
+  SUCCEEDED = 'SUCCEEDED',
 }
 
 export enum BlockStatus {
@@ -200,13 +218,15 @@ export type ParsedStruct = {
 
 export type waitForTransactionOptions = {
   retryInterval?: number;
-  successStates?: Array<TransactionStatus>;
+  successStates?: Array<TransactionFinalityStatus | TransactionExecutionStatus>;
+  errorStates?: Array<TransactionFinalityStatus | TransactionExecutionStatus>;
 };
 
 export type getSimulateTransactionOptions = {
   blockIdentifier?: BlockIdentifier;
   skipValidate?: boolean;
   skipExecute?: boolean;
+  skipFeeCharge?: boolean;
 };
 
 export type getEstimateFeeBulkOptions = {
diff --git a/src/types/provider/response.ts b/src/types/provider/response.ts
index 079cf49e..f8e2b85a 100644
--- a/src/types/provider/response.ts
+++ b/src/types/provider/response.ts
@@ -4,9 +4,11 @@
  */
 
 import * as RPC from '../api/rpc';
+import { BlockHash } from '../api/rpc';
 import * as Sequencer from '../api/sequencer';
 import {
   AllowArray,
+  BlockNumber,
   BlockStatus,
   ByteCode,
   Call,
@@ -16,6 +18,8 @@ import {
   LegacyContractClass,
   RawCalldata,
   Signature,
+  TransactionExecutionStatus,
+  TransactionFinalityStatus,
   TransactionStatus,
   TransactionType,
   UniversalDeployerContractPayload,
@@ -40,13 +44,10 @@ export interface GetCodeResponse {
   // abi: string; // is not consistent between rpc and sequencer (is it?), therefore not included in the provider interface
 }
 
-export type RejectedTransactionResponse = {
-  status: `${TransactionStatus.REJECTED}`;
-  transaction_failure_reason: {
-    code: string;
-    error_message: string;
-  };
-};
+export interface ContractEntryPoint {
+  offset: string;
+  selector: string;
+}
 
 export type GetTransactionResponse =
   | InvokeTransactionResponse
@@ -68,31 +69,11 @@ export interface InvokeTransactionResponse extends CommonTransactionResponse {
   calldata: RawCalldata;
 }
 
-export interface ContractEntryPoint {
-  offset: string;
-  selector: string;
-}
-
 export interface DeclareTransactionResponse extends CommonTransactionResponse {
   contract_class?: any;
   sender_address?: string;
 }
 
-export type RejectedTransactionReceiptResponse = RejectedTransactionResponse &
-  (InvokeTransactionReceiptResponse | DeclareTransactionReceiptResponse);
-
-export type GetTransactionReceiptResponse =
-  | InvokeTransactionReceiptResponse
-  | DeclareTransactionReceiptResponse
-  | RejectedTransactionReceiptResponse;
-
-export interface CommonTransactionReceiptResponse {
-  transaction_hash: string;
-  status?: `${TransactionStatus}`;
-  actual_fee?: string;
-  status_data?: string;
-}
-
 export interface MessageToL1 {
   to_address: string;
   payload: Array<string>;
@@ -109,14 +90,83 @@ export interface MessageToL2 {
   payload: Array<string>;
 }
 
-export interface InvokeTransactionReceiptResponse extends CommonTransactionReceiptResponse {
-  /** @deprecated Use l2_to_l1_messages */
-  messages_sent?: Array<MessageToL1>;
-  events?: Array<Event>;
-  l1_origin_message?: MessageToL2;
+export type RejectedTransactionResponse = {
+  status: `${TransactionStatus.REJECTED}`;
+  transaction_failure_reason: {
+    code: string;
+    error_message: string;
+  };
+};
+
+export type GetTransactionReceiptResponse =
+  | SuccessfulTransactionReceiptResponse
+  | RevertedTransactionReceiptResponse
+  | RejectedTransactionReceiptResponse;
+
+export type SuccessfulTransactionReceiptResponse =
+  | InvokeTransactionReceiptResponse
+  | DeployTransactionReceiptResponse
+  | DeclareTransactionReceiptResponse;
+
+export interface InvokeTransactionReceiptResponse {
+  type?: TransactionType; // RPC only
+  execution_status: TransactionExecutionStatus;
+  finality_status: TransactionFinalityStatus;
+  status?: `${TransactionStatus}`; // SEQ only
+  actual_fee: string;
+  block_hash: BlockHash;
+  block_number: BlockNumber;
+  transaction_hash: string;
+  transaction_index?: number; // SEQ only
+  messages_sent: Array<MessageToL1>; // Casted SEQ l2_to_l1_messages
+  events: any[];
+  execution_resources?: any; // SEQ Only
 }
 
-export type DeclareTransactionReceiptResponse = CommonTransactionReceiptResponse;
+export type DeclareTransactionReceiptResponse = {
+  type?: TransactionType; // RPC only
+  execution_status: TransactionExecutionStatus;
+  finality_status: TransactionFinalityStatus;
+  status?: `${TransactionStatus}`; // SEQ only
+  actual_fee: string;
+  block_hash: BlockHash;
+  block_number: BlockNumber;
+  transaction_hash: string;
+  transaction_index?: number; // SEQ only
+  messages_sent: Array<MessageToL1>; // Casted SEQ l2_to_l1_messages
+  events: any[];
+};
+
+export type DeployTransactionReceiptResponse = InvokeTransactionReceiptResponse;
+
+// TODO: Missing RPC DEPLOY_ACCOUNT_TXN_RECEIPT
+
+// TODO: Missing RPC PENDING_TXN_RECEIPT
+
+// TODO: Missing RPC L1_HANDLER_TXN_RECEIPT
+
+export type RejectedTransactionReceiptResponse = {
+  status: `${TransactionStatus.REJECTED}`;
+  transaction_failure_reason: {
+    code: string;
+    error_message: string;
+  };
+};
+
+export type RevertedTransactionReceiptResponse = {
+  type?: TransactionType | any; // RPC only // any due to RPC Spec issue
+  execution_status: TransactionExecutionStatus.REVERTED | any; // any due to RPC Spec issue
+  finality_status: TransactionFinalityStatus | any;
+  status?: TransactionStatus; // SEQ only
+  actual_fee: string;
+  block_hash?: string; // ?~ optional due to RPC spec issue
+  block_number?: BlockNumber; // ?~ optional due to RCP spec issue
+  transaction_hash: string;
+  transaction_index?: number; // SEQ only
+  messages_sent: Array<MessageToL1>; // SEQ Casted l2_to_l1_messages
+  events: any[];
+  revert_reason?: string; // SEQ Casted revert_error // ?~ optional due to RCP spec issue
+};
 
 export interface EstimateFeeResponse {
   overall_fee: bigint;
diff --git a/src/utils/encode.ts b/src/utils/encode.ts
index 53221f29..e72d13fc 100644
--- a/src/utils/encode.ts
+++ b/src/utils/encode.ts
@@ -72,3 +72,15 @@ export function sanitizeHex(hex: string): string {
 export function utf8ToArray(str: string): Uint8Array {
   return new TextEncoder().encode(str);
 }
+
+/**
+ * String transformation util
+ * pascal case to screaming snake case
+ * @param text string
+ * @returns string
+ */
+export const pascalToSnake = (text: string) =>
+  text
+    .split(/(?=[A-Z])/)
+    .join('_')
+    .toUpperCase();
diff --git a/src/utils/responseParser/sequencer.ts b/src/utils/responseParser/sequencer.ts
index 1f7e9b3b..360cd1a2 100644
--- a/src/utils/responseParser/sequencer.ts
+++ b/src/utils/responseParser/sequencer.ts
@@ -3,6 +3,7 @@
  * Intersection (sequencer response ∩ (∪ rpc responses))
  */
 
+import { LibraryError } from '../../provider/errors';
 import {
   CallContractResponse,
   CompiledContract,
@@ -19,6 +20,8 @@ import {
   Sequencer,
   SimulateTransactionResponse,
   StateUpdateResponse,
+  TransactionFinalityStatus,
+  TransactionStatus,
 } from '../../types';
 import { isSierra } from '../contract';
 import { toBigInt } from '../num';
@@ -41,6 +44,13 @@ export class SequencerAPIResponseParser extends ResponseParser {
   public parseGetTransactionResponse(
     res: Sequencer.GetTransactionResponse
   ): GetTransactionResponse {
+    if (
+      res.status === TransactionStatus.NOT_RECEIVED &&
+      res.finality_status === TransactionFinalityStatus.NOT_RECEIVED
+    ) {
+      throw new LibraryError();
+    }
+
     return {
       ...res,
       calldata: 'calldata' in res.transaction ? (res.transaction.calldata as HexCalldata) : [],
@@ -67,22 +77,9 @@ export class SequencerAPIResponseParser extends ResponseParser {
     res: Sequencer.TransactionReceiptResponse
   ): GetTransactionReceiptResponse {
     return {
-      transaction_hash: res.transaction_hash,
-      status: res.status,
-      messages_sent: res.l2_to_l1_messages as any, // TODO: parse
-      events: res.events as any,
-      ...('block_hash' in res && { block_hash: res.block_hash }),
-      ...('block_number' in res && { block_number: res.block_number }),
-      ...('actual_fee' in res && { actual_fee: res.actual_fee }),
-      ...('transaction_index' in res && { transaction_index: res.transaction_index }),
-      ...('execution_resources' in res && { execution_resources: res.execution_resources }),
-      ...('l1_to_l2_consumed_message' in res && {
-        // eslint-disable-next-line @typescript-eslint/dot-notation
-        l1_to_l2_consumed_message: res['l1_to_l2_consumed_message'],
-      }),
-      ...('transaction_failure_reason' in res && {
-        transaction_failure_reason: res.transaction_failure_reason,
-      }),
+      ...res,
+      messages_sent: res.l2_to_l1_messages as any,
+      ...('revert_error' in res && { revert_reason: res.revert_error }),
     };
   }
 
diff --git a/www/docs/guides/signature.md b/www/docs/guides/signature.md
index 48bdd4c0..91f4e77e 100644
--- a/www/docs/guides/signature.md
+++ b/www/docs/guides/signature.md
@@ -13,7 +13,7 @@ Your message has to be an array of `BigNumberish`. First, calculate the hash of
 > If the message does not respect some safety rules of composition, this method could be a way of attack of your smart contract. If you have any doubt, prefer the [EIP712 like method](#sign-and-verify-following-eip712), which is safe, but is also more complicated.
 
 ```typescript
-import {ec, hash, num, json, Contract } from "starknet";
+import {ec, hash, num, json, Contract, WeierstrassSignatureType } from "starknet";
 
 const privateKey = "0x1234567890987654321";
 const starknetPublicKey = ec.starkCurve.getStarkKey(privateKey);
@@ -22,7 +22,7 @@ const fullPublicKey = encode.addHexPrefix( encode.buf2hex( ec.starkCurve.getPubl
 const message: BigNumberish[] = [1, 128, 18, 14];
 
 const msgHash = hash.computeHashOnElements(message);
-const signature: weierstrass.SignatureType = ec.starkCurve.sign(msgHash,privateKey);
+const signature: WeierstrassSignatureType = ec.starkCurve.sign(msgHash,privateKey);
 ```
 
 Then you can send, by any means, to the recipient of the message:
@@ -167,7 +167,7 @@ const typedDataValidate: TypedData = {
     };
 
 // connect your account, then
-const signature2: weierstrass.SignatureType = await account.signMessage(typedDataValidate) as weierstrass.SignatureType;
+const signature2 = await account.signMessage(typedDataValidate) as WeierstrassSignatureType;
 
 ```
 


Test patch:
diff --git a/__tests__/account.test.ts b/__tests__/account.test.ts
index 74a923cd..12a5ede4 100644
--- a/__tests__/account.test.ts
+++ b/__tests__/account.test.ts
@@ -3,8 +3,8 @@ import {
   Account,
   Contract,
   DeclareDeployUDCResponse,
+  DeployTransactionReceiptResponse,
   Provider,
-  TransactionStatus,
   TransactionType,
   cairo,
   contractClassResponseToLegacyCompiledContract,
@@ -338,9 +338,7 @@ describe('deploy and test Wallet', () => {
       calldata: [erc20.address, '10', '0'],
     });
 
-    await provider.waitForTransaction(transaction_hash, {
-      successStates: [TransactionStatus.ACCEPTED_ON_L2],
-    });
+    await provider.waitForTransaction(transaction_hash);
   });
 
   test('read balance of wallet after transfer', async () => {
@@ -379,9 +377,7 @@ describe('deploy and test Wallet', () => {
       },
     ]);
 
-    await provider.waitForTransaction(transaction_hash, {
-      successStates: [TransactionStatus.ACCEPTED_ON_L2],
-    });
+    await provider.waitForTransaction(transaction_hash);
 
     const response = await dapp.get_number(account.address);
     expect(toBigInt(response.number as string).toString()).toStrictEqual('57');
@@ -552,7 +548,7 @@ describe('deploy and test Wallet', () => {
 
       // check pre-calculated address
       const txReceipt = await provider.waitForTransaction(deployment.transaction_hash);
-      const udcEvent = parseUDCEvent(txReceipt);
+      const udcEvent = parseUDCEvent(txReceipt as DeployTransactionReceiptResponse);
       expect(cleanHex(deployment.contract_address[0])).toBe(cleanHex(udcEvent.contract_address));
     });
 
@@ -573,7 +569,7 @@ describe('deploy and test Wallet', () => {
 
       // check pre-calculated address
       const txReceipt = await provider.waitForTransaction(deployment.transaction_hash);
-      const udcEvent = parseUDCEvent(txReceipt);
+      const udcEvent = parseUDCEvent(txReceipt as DeployTransactionReceiptResponse);
       expect(cleanHex(deployment.contract_address[0])).toBe(cleanHex(udcEvent.contract_address));
     });
 
diff --git a/__tests__/rpcProvider.test.ts b/__tests__/rpcProvider.test.ts
index 3a4f509e..3c302d3b 100644
--- a/__tests__/rpcProvider.test.ts
+++ b/__tests__/rpcProvider.test.ts
@@ -151,8 +151,13 @@ describeIfRpc('RPCProvider', () => {
           chunk_size: 2,
         });
 
+        const result1 = await rpcProvider.getEvents({
+          chunk_size: 2, // all optional paramaters removed
+        });
+
         expect(result).toHaveProperty('continuation_token');
         expect(result).toHaveProperty('events');
+        expect(result1).toHaveProperty('events');
         expect(Array.isArray(result?.events)).toBe(true);
         expect(result?.events?.length).toBe(2);
         expect(result.events[0]).toMatchSchemaRef('StarknetEmittedEvent');
diff --git a/__tests__/schemas/rpc.json b/__tests__/schemas/rpc.json
index f04ac54c..eb942261 100644
--- a/__tests__/schemas/rpc.json
+++ b/__tests__/schemas/rpc.json
@@ -2,34 +2,41 @@
   "$id": "rpcSchemas",
   "definitions": {
     "GetSyncingStatsResponse": {
-      "type": "object",
-      "properties": {
-        "current_block_hash": {
-          "type": "string"
-        },
-        "current_block_num": {
-          "type": "string"
-        },
-        "highest_block_hash": {
-          "type": "string"
+      "oneOf": [
+        {
+          "type": "object",
+          "properties": {
+            "current_block_hash": {
+              "type": "string"
+            },
+            "current_block_num": {
+              "type": "number"
+            },
+            "highest_block_hash": {
+              "type": "string"
+            },
+            "highest_block_num": {
+              "type": "number"
+            },
+            "starting_block_hash": {
+              "type": "string"
+            },
+            "starting_block_num": {
+              "type": "number"
+            }
+          },
+          "required": [
+            "current_block_hash",
+            "current_block_num",
+            "highest_block_hash",
+            "highest_block_num",
+            "starting_block_hash",
+            "starting_block_num"
+          ]
         },
-        "highest_block_num": {
-          "type": "string"
-        },
-        "starting_block_hash": {
-          "type": "string"
-        },
-        "starting_block_num": {
-          "type": "string"
+        {
+          "type": "boolean"
         }
-      },
-      "required": [
-        "current_block_hash",
-        "current_block_num",
-        "highest_block_hash",
-        "highest_block_num",
-        "starting_block_hash",
-        "starting_block_num"
       ]
     },
     "StarknetEmittedEvent": {