Skip to content

Commit

Permalink
FIx 0.8.0 breaking export (#29)
Browse files Browse the repository at this point in the history
* fix: update spec to 0.8.0 rc1

* chore: readme

* feat: constants, refactor string literals, docs, fixes, refactor contract

* fix: address list

* fix: export all top lvl ex. CONTRACT, refactor and Add WebSocketEvents

* chore: package
  • Loading branch information
tabaktoni authored Nov 26, 2024
1 parent 331b08a commit 1e9bb31
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 77 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions src/api/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,31 @@ export type REORG_DATA = {
ending_block_number: BLOCK_NUMBER;
};

export type SubscriptionNewHeadsResponse = {
subscription_id: SUBSCRIPTION_ID;
result: BLOCK_HEADER;
};

export type SubscriptionEventsResponse = {
subscription_id: SUBSCRIPTION_ID;
result: EMITTED_EVENT;
};

export type SubscriptionTransactionsStatusResponse = {
subscription_id: SUBSCRIPTION_ID;
result: NEW_TXN_STATUS;
};

export type SubscriptionPendingTransactionsResponse = {
subscription_id: SUBSCRIPTION_ID;
result: TXN_HASH | TXN;
};

export type SubscriptionReorgResponse = {
subscription_id: SUBSCRIPTION_ID;
result: REORG_DATA;
};

// *****************
// * READ API
// *****************
Expand Down
8 changes: 4 additions & 4 deletions src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export type { Methods } from './methods.js';
export * from './contract.js';
export * as Errors from './errors.js';
export * as SPEC from './components.js';
export * from './methods.js';
export * as CONTRACT from './contract.js';
export * from './errors.js';
export * from './components.js';
export * from './nonspec.js';
export * from './constants.js';
88 changes: 17 additions & 71 deletions src/api/methods.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type {
ADDRESS,
BLOCK_HEADER,
BLOCK_ID,
BLOCK_NUMBER,
BROADCASTED_DECLARE_TXN,
Expand All @@ -9,21 +8,22 @@ import type {
BROADCASTED_TXN,
CHAIN_ID,
CONTRACT_STORAGE_KEYS,
EMITTED_EVENT,
EVENT_FILTER,
EVENT_KEYS,
FELT,
FUNCTION_CALL,
L1_TXN_HASH,
MSG_FROM_L1,
NEW_TXN_STATUS,
REORG_DATA,
RESULT_PAGE_REQUEST,
SIMULATION_FLAG,
SIMULATION_FLAG_FOR_ESTIMATE_FEE,
STORAGE_KEY,
SUBSCRIPTION_ID,
TXN,
SubscriptionEventsResponse,
SubscriptionNewHeadsResponse,
SubscriptionPendingTransactionsResponse,
SubscriptionReorgResponse,
SubscriptionTransactionsStatusResponse,
TXN_HASH,
} from './components.js';
import type * as Errors from './errors.js';
Expand Down Expand Up @@ -432,25 +432,7 @@ type WebSocketMethods = {
};
result: SUBSCRIPTION_ID;
errors: Errors.TOO_MANY_BLOCKS_BACK | Errors.BLOCK_NOT_FOUND | Errors.CALL_ON_PENDING;
events: [
{
method: 'starknet_subscriptionNewHeads';
params: {
subscription_id: SUBSCRIPTION_ID;
result: BLOCK_HEADER;
};
},
{
/**
* Notifies the subscriber of a reorganization of the chain.
*/
method: 'starknet_subscriptionReorg';
params: {
subscription_id: SUBSCRIPTION_ID;
result: REORG_DATA;
};
},
];
events: ['starknet_subscriptionNewHeads', 'starknet_subscriptionReorg'];
};

/**
Expand All @@ -475,25 +457,7 @@ type WebSocketMethods = {
| Errors.TOO_MANY_BLOCKS_BACK
| Errors.BLOCK_NOT_FOUND
| Errors.CALL_ON_PENDING;
events: [
{
method: 'starknet_subscriptionEvents';
params: {
subscription_id: SUBSCRIPTION_ID;
result: EMITTED_EVENT;
};
},
{
/**
* Notifies the subscriber of a reorganization of the chain.
*/
method: 'starknet_subscriptionReorg';
params: {
subscription_id: SUBSCRIPTION_ID;
result: REORG_DATA;
};
},
];
events: ['starknet_subscriptionEvents', 'starknet_subscriptionReorg'];
};

/**
Expand All @@ -510,25 +474,7 @@ type WebSocketMethods = {
};
result: SUBSCRIPTION_ID;
errors: Errors.TOO_MANY_BLOCKS_BACK | Errors.BLOCK_NOT_FOUND;
events: [
{
method: 'starknet_subscriptionTransactionStatus';
params: {
subscription_id: SUBSCRIPTION_ID;
result: NEW_TXN_STATUS;
};
},
{
/**
* Notifies the subscriber of a reorganization of the chain.
*/
method: 'starknet_subscriptionReorg';
params: {
subscription_id: SUBSCRIPTION_ID;
result: REORG_DATA;
};
},
];
events: ['starknet_subscriptionTransactionStatus', 'starknet_subscriptionReorg'];
};

/**
Expand All @@ -548,15 +494,7 @@ type WebSocketMethods = {
};
result: SUBSCRIPTION_ID;
errors: Errors.TOO_MANY_ADDRESSES_IN_FILTER;
events: [
{
method: 'starknet_subscriptionPendingTransactions';
params: {
subscription_id: SUBSCRIPTION_ID;
result: TXN_HASH | TXN;
};
},
];
events: ['starknet_subscriptionPendingTransactions'];
};

/**
Expand All @@ -570,3 +508,11 @@ type WebSocketMethods = {
errors: Errors.INVALID_SUBSCRIPTION_ID;
};
};

export type WebSocketEvents = {
starknet_subscriptionReorg: SubscriptionReorgResponse;
starknet_subscriptionNewHeads: SubscriptionNewHeadsResponse;
starknet_subscriptionEvents: SubscriptionEventsResponse;
starknet_subscriptionTransactionStatus: SubscriptionTransactionsStatusResponse;
starknet_subscriptionPendingTransactions: SubscriptionPendingTransactionsResponse;
};

0 comments on commit 1e9bb31

Please sign in to comment.