starknet 3.14.0 → 3.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## [3.14.1](https://github.com/0xs34n/starknet.js/compare/v3.14.0...v3.14.1) (2022-06-15)
2
+
3
+ ### Bug Fixes
4
+
5
+ - update api typings ([44796af](https://github.com/0xs34n/starknet.js/commit/44796af4849b6bab3d99065bb1e1948e4ea0b55e))
6
+
1
7
  # [3.14.0](https://github.com/0xs34n/starknet.js/compare/v3.13.1...v3.14.0) (2022-06-15)
2
8
 
3
9
  ### Bug Fixes
@@ -85,20 +85,43 @@ describe('defaultProvider', () => {
85
85
  )
86
86
  ).resolves.not.toThrow();
87
87
  });
88
- test('getTransaction()', async () => {
89
- return expect(
90
- defaultProvider.getTransaction(
91
- '0x37013e1cb9c133e6fe51b4b371b76b317a480f56d80576730754c1662582348'
92
- )
93
- ).resolves.not.toThrow();
88
+
89
+ test('getTransaction() - successful transaction', async () => {
90
+ const transaction = await defaultProvider.getTransaction(
91
+ '0x37013e1cb9c133e6fe51b4b371b76b317a480f56d80576730754c1662582348'
92
+ );
93
+
94
+ expect(transaction).not.toHaveProperty('transaction_failure_reason');
95
+
96
+ expect(transaction.transaction).toHaveProperty('transaction_hash');
97
+
98
+ return expect(transaction.status).not.toEqual('REJECTED');
94
99
  });
95
100
 
96
- test('getTransactionReceipt', async () => {
97
- return expect(
98
- defaultProvider.getTransactionReceipt(
99
- '0x37013e1cb9c133e6fe51b4b371b76b317a480f56d80576730754c1662582348'
100
- )
101
- ).resolves.not.toThrow();
101
+ test('getTransaction() - failed transaction', async () => {
102
+ const transaction = await defaultProvider.getTransaction(
103
+ '0x698e60db2bae3ef8d5fafda10ff83b6ba634351aa1f4fcf8455ec0cffa738d9'
104
+ );
105
+
106
+ expect(transaction).toHaveProperty('transaction_failure_reason');
107
+
108
+ return expect(transaction.status).toEqual('REJECTED');
109
+ });
110
+
111
+ test('getTransactionReceipt() - successful transaction', async () => {
112
+ const transactionReceipt = await defaultProvider.getTransactionReceipt(
113
+ '0x18c49389193b40e178dfc9f2f595a7c79a7a55639e9951d956329f2ce6cfd4f'
114
+ );
115
+
116
+ return expect(transactionReceipt).toHaveProperty('actual_fee');
117
+ });
118
+
119
+ test('getTransactionReceipt() - failed transaction', async () => {
120
+ const transactionReceipt = await defaultProvider.getTransactionReceipt(
121
+ '0x698e60db2bae3ef8d5fafda10ff83b6ba634351aa1f4fcf8455ec0cffa738d9'
122
+ );
123
+
124
+ return expect(transactionReceipt).not.toHaveProperty('actual_fee');
102
125
  });
103
126
 
104
127
  test('callContract()', () => {
@@ -129,7 +129,7 @@ export declare type ExecutionResources = {
129
129
  bitwise_builtin: number;
130
130
  output_builtin: number;
131
131
  ecdsa_builtin: number;
132
- ec_op_builtin: number;
132
+ ec_op_builtin?: number;
133
133
  };
134
134
  n_memory_holes: number;
135
135
  };
@@ -160,8 +160,9 @@ export declare type GetBlockResponse = {
160
160
  transaction_index: number;
161
161
  };
162
162
  };
163
- previous_block_hash: string;
163
+ parent_block_hash: string;
164
164
  status: Status;
165
+ gas_price: string;
165
166
  };
166
167
  export declare type GetCodeResponse = {
167
168
  bytecode: string[];
@@ -169,9 +170,8 @@ export declare type GetCodeResponse = {
169
170
  };
170
171
  export declare type GetTransactionStatusResponse = {
171
172
  tx_status: Status;
172
- block_hash: string;
173
+ block_hash?: string;
173
174
  tx_failure_reason?: {
174
- tx_id: number;
175
175
  code: string;
176
176
  error_message: string;
177
177
  };
@@ -184,28 +184,36 @@ export declare type GetTransactionTraceResponse = {
184
184
  selector: string;
185
185
  calldata: RawArgs;
186
186
  result: Array<any>;
187
- execution_resources: any;
187
+ execution_resources: ExecutionResources;
188
188
  internal_call: Array<any>;
189
189
  events: Array<any>;
190
190
  messages: Array<any>;
191
191
  };
192
192
  signature: Signature;
193
193
  };
194
- export declare type GetTransactionResponse = {
194
+ export declare type SuccessfulTransactionResponse = {
195
195
  status: Status;
196
196
  transaction: Transaction;
197
197
  block_hash: string;
198
198
  block_number: BlockNumber;
199
199
  transaction_index: number;
200
- transaction_hash: string;
201
200
  };
201
+ export declare type FailedTransactionResponse = {
202
+ status: 'REJECTED';
203
+ transaction_failure_reason: {
204
+ code: string;
205
+ error_message: string;
206
+ };
207
+ transaction: Transaction;
208
+ };
209
+ export declare type GetTransactionResponse = SuccessfulTransactionResponse | FailedTransactionResponse;
202
210
  export declare type AddTransactionResponse = {
203
211
  code: TransactionStatus;
204
212
  transaction_hash: string;
205
213
  address?: string;
206
214
  class_hash?: string;
207
215
  };
208
- export declare type TransactionReceiptResponse = {
216
+ export declare type SuccessfulTransactionReceiptResponse = {
209
217
  status: Status;
210
218
  transaction_hash: string;
211
219
  transaction_index: number;
@@ -213,7 +221,20 @@ export declare type TransactionReceiptResponse = {
213
221
  block_number: BlockNumber;
214
222
  l2_to_l1_messages: string[];
215
223
  events: string[];
224
+ actual_fee: string;
225
+ execution_resources: ExecutionResources;
226
+ };
227
+ export declare type FailedTransactionReceiptResponse = {
228
+ status: 'REJECTED';
229
+ transaction_failure_reason: {
230
+ code: string;
231
+ error_message: string;
232
+ };
233
+ transaction_hash: string;
234
+ l2_to_l1_messages: string[];
235
+ events: string[];
216
236
  };
237
+ export declare type TransactionReceiptResponse = SuccessfulTransactionReceiptResponse | FailedTransactionReceiptResponse;
217
238
  export declare type EstimateFeeResponse = {
218
239
  amount: BN;
219
240
  unit: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starknet",
3
- "version": "3.14.0",
3
+ "version": "3.14.1",
4
4
  "description": "JavaScript library for StarkNet",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/types/api.ts CHANGED
@@ -146,7 +146,7 @@ export type ExecutionResources = {
146
146
  bitwise_builtin: number;
147
147
  output_builtin: number;
148
148
  ecdsa_builtin: number;
149
- ec_op_builtin: number;
149
+ ec_op_builtin?: number;
150
150
  };
151
151
  n_memory_holes: number;
152
152
  };
@@ -184,8 +184,9 @@ export type GetBlockResponse = {
184
184
  transaction_index: number;
185
185
  };
186
186
  };
187
- previous_block_hash: string;
187
+ parent_block_hash: string;
188
188
  status: Status;
189
+ gas_price: string;
189
190
  };
190
191
 
191
192
  export type GetCodeResponse = {
@@ -195,9 +196,8 @@ export type GetCodeResponse = {
195
196
 
196
197
  export type GetTransactionStatusResponse = {
197
198
  tx_status: Status;
198
- block_hash: string;
199
+ block_hash?: string;
199
200
  tx_failure_reason?: {
200
- tx_id: number;
201
201
  code: string;
202
202
  error_message: string;
203
203
  };
@@ -211,7 +211,7 @@ export type GetTransactionTraceResponse = {
211
211
  selector: string;
212
212
  calldata: RawArgs;
213
213
  result: Array<any>;
214
- execution_resources: any;
214
+ execution_resources: ExecutionResources;
215
215
  internal_call: Array<any>;
216
216
  events: Array<any>;
217
217
  messages: Array<any>;
@@ -219,15 +219,25 @@ export type GetTransactionTraceResponse = {
219
219
  signature: Signature;
220
220
  };
221
221
 
222
- export type GetTransactionResponse = {
222
+ export type SuccessfulTransactionResponse = {
223
223
  status: Status;
224
224
  transaction: Transaction;
225
225
  block_hash: string;
226
226
  block_number: BlockNumber;
227
227
  transaction_index: number;
228
- transaction_hash: string;
229
228
  };
230
229
 
230
+ export type FailedTransactionResponse = {
231
+ status: 'REJECTED';
232
+ transaction_failure_reason: {
233
+ code: string;
234
+ error_message: string;
235
+ };
236
+ transaction: Transaction;
237
+ };
238
+
239
+ export type GetTransactionResponse = SuccessfulTransactionResponse | FailedTransactionResponse;
240
+
231
241
  export type AddTransactionResponse = {
232
242
  code: TransactionStatus;
233
243
  transaction_hash: string;
@@ -235,7 +245,7 @@ export type AddTransactionResponse = {
235
245
  class_hash?: string;
236
246
  };
237
247
 
238
- export type TransactionReceiptResponse = {
248
+ export type SuccessfulTransactionReceiptResponse = {
239
249
  status: Status;
240
250
  transaction_hash: string;
241
251
  transaction_index: number;
@@ -243,8 +253,25 @@ export type TransactionReceiptResponse = {
243
253
  block_number: BlockNumber;
244
254
  l2_to_l1_messages: string[];
245
255
  events: string[];
256
+ actual_fee: string;
257
+ execution_resources: ExecutionResources;
246
258
  };
247
259
 
260
+ export type FailedTransactionReceiptResponse = {
261
+ status: 'REJECTED';
262
+ transaction_failure_reason: {
263
+ code: string;
264
+ error_message: string;
265
+ };
266
+ transaction_hash: string;
267
+ l2_to_l1_messages: string[];
268
+ events: string[];
269
+ };
270
+
271
+ export type TransactionReceiptResponse =
272
+ | SuccessfulTransactionReceiptResponse
273
+ | FailedTransactionReceiptResponse;
274
+
248
275
  export type EstimateFeeResponse = {
249
276
  amount: BN;
250
277
  unit: string;
package/types/api.d.ts CHANGED
@@ -139,7 +139,7 @@ export declare type ExecutionResources = {
139
139
  bitwise_builtin: number;
140
140
  output_builtin: number;
141
141
  ecdsa_builtin: number;
142
- ec_op_builtin: number;
142
+ ec_op_builtin?: number;
143
143
  };
144
144
  n_memory_holes: number;
145
145
  };
@@ -176,8 +176,9 @@ export declare type GetBlockResponse = {
176
176
  transaction_index: number;
177
177
  };
178
178
  };
179
- previous_block_hash: string;
179
+ parent_block_hash: string;
180
180
  status: Status;
181
+ gas_price: string;
181
182
  };
182
183
  export declare type GetCodeResponse = {
183
184
  bytecode: string[];
@@ -185,9 +186,8 @@ export declare type GetCodeResponse = {
185
186
  };
186
187
  export declare type GetTransactionStatusResponse = {
187
188
  tx_status: Status;
188
- block_hash: string;
189
+ block_hash?: string;
189
190
  tx_failure_reason?: {
190
- tx_id: number;
191
191
  code: string;
192
192
  error_message: string;
193
193
  };
@@ -200,28 +200,38 @@ export declare type GetTransactionTraceResponse = {
200
200
  selector: string;
201
201
  calldata: RawArgs;
202
202
  result: Array<any>;
203
- execution_resources: any;
203
+ execution_resources: ExecutionResources;
204
204
  internal_call: Array<any>;
205
205
  events: Array<any>;
206
206
  messages: Array<any>;
207
207
  };
208
208
  signature: Signature;
209
209
  };
210
- export declare type GetTransactionResponse = {
210
+ export declare type SuccessfulTransactionResponse = {
211
211
  status: Status;
212
212
  transaction: Transaction;
213
213
  block_hash: string;
214
214
  block_number: BlockNumber;
215
215
  transaction_index: number;
216
- transaction_hash: string;
217
216
  };
217
+ export declare type FailedTransactionResponse = {
218
+ status: 'REJECTED';
219
+ transaction_failure_reason: {
220
+ code: string;
221
+ error_message: string;
222
+ };
223
+ transaction: Transaction;
224
+ };
225
+ export declare type GetTransactionResponse =
226
+ | SuccessfulTransactionResponse
227
+ | FailedTransactionResponse;
218
228
  export declare type AddTransactionResponse = {
219
229
  code: TransactionStatus;
220
230
  transaction_hash: string;
221
231
  address?: string;
222
232
  class_hash?: string;
223
233
  };
224
- export declare type TransactionReceiptResponse = {
234
+ export declare type SuccessfulTransactionReceiptResponse = {
225
235
  status: Status;
226
236
  transaction_hash: string;
227
237
  transaction_index: number;
@@ -229,7 +239,22 @@ export declare type TransactionReceiptResponse = {
229
239
  block_number: BlockNumber;
230
240
  l2_to_l1_messages: string[];
231
241
  events: string[];
242
+ actual_fee: string;
243
+ execution_resources: ExecutionResources;
244
+ };
245
+ export declare type FailedTransactionReceiptResponse = {
246
+ status: 'REJECTED';
247
+ transaction_failure_reason: {
248
+ code: string;
249
+ error_message: string;
250
+ };
251
+ transaction_hash: string;
252
+ l2_to_l1_messages: string[];
253
+ events: string[];
232
254
  };
255
+ export declare type TransactionReceiptResponse =
256
+ | SuccessfulTransactionReceiptResponse
257
+ | FailedTransactionReceiptResponse;
233
258
  export declare type EstimateFeeResponse = {
234
259
  amount: BN;
235
260
  unit: string;