starknet 4.3.0 → 4.3.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.
Files changed (63) hide show
  1. package/CHANGELOG.md +16 -1
  2. package/__tests__/defaultProvider.test.ts +11 -24
  3. package/__tests__/rpcProvider.test.ts +3 -3
  4. package/__tests__/sequencerProvider.test.ts +9 -1
  5. package/dist/provider/default.d.ts +2 -2
  6. package/dist/provider/default.js +3 -3
  7. package/dist/provider/interface.d.ts +6 -3
  8. package/dist/provider/rpc.d.ts +9 -4
  9. package/dist/provider/rpc.js +67 -25
  10. package/dist/provider/sequencer.d.ts +2 -2
  11. package/dist/provider/sequencer.js +4 -4
  12. package/dist/provider/utils.d.ts +12 -0
  13. package/dist/provider/utils.js +17 -1
  14. package/dist/types/api/openrpc.d.ts +151 -0
  15. package/dist/types/api/openrpc.js +9 -0
  16. package/dist/types/api/rpc.d.ts +22 -43
  17. package/dist/types/provider.d.ts +5 -5
  18. package/dist/utils/ellipticCurve.d.ts +13 -0
  19. package/dist/utils/ellipticCurve.js +20 -16
  20. package/dist/utils/responseParser/rpc.d.ts +13 -3
  21. package/dist/utils/responseParser/rpc.js +2 -10
  22. package/dist/utils/responseParser/sequencer.d.ts +4 -1
  23. package/dist/utils/responseParser/sequencer.js +1 -7
  24. package/package.json +1 -1
  25. package/provider/default.d.ts +2 -2
  26. package/provider/default.js +3 -3
  27. package/provider/interface.d.ts +6 -3
  28. package/provider/rpc.d.ts +9 -4
  29. package/provider/rpc.js +67 -25
  30. package/provider/sequencer.d.ts +2 -2
  31. package/provider/sequencer.js +4 -4
  32. package/provider/utils.d.ts +12 -0
  33. package/provider/utils.js +17 -1
  34. package/src/provider/default.ts +2 -3
  35. package/src/provider/interface.ts +5 -3
  36. package/src/provider/rpc.ts +56 -34
  37. package/src/provider/sequencer.ts +3 -6
  38. package/src/provider/utils.ts +22 -1
  39. package/src/types/api/openrpc.ts +168 -0
  40. package/src/types/api/rpc.ts +22 -45
  41. package/src/types/provider.ts +5 -5
  42. package/src/utils/ellipticCurve.ts +20 -16
  43. package/src/utils/responseParser/rpc.ts +16 -13
  44. package/src/utils/responseParser/sequencer.ts +5 -8
  45. package/types/api/openrpc.d.ts +151 -0
  46. package/types/api/openrpc.js +9 -0
  47. package/types/api/rpc.d.ts +22 -43
  48. package/types/provider.d.ts +5 -5
  49. package/utils/ellipticCurve.d.ts +13 -0
  50. package/utils/ellipticCurve.js +20 -16
  51. package/utils/responseParser/rpc.d.ts +13 -3
  52. package/utils/responseParser/rpc.js +2 -10
  53. package/utils/responseParser/sequencer.d.ts +4 -1
  54. package/utils/responseParser/sequencer.js +1 -7
  55. package/www/docs/API/account.md +20 -18
  56. package/www/docs/API/contract.md +10 -10
  57. package/www/docs/API/contractFactory.md +14 -11
  58. package/www/docs/API/provider.md +29 -63
  59. package/www/docs/API/signer.md +8 -10
  60. package/www/docs/API/utils.md +151 -74
  61. package/www/guides/account.md +5 -5
  62. package/www/guides/erc20.md +20 -4
  63. package/www/guides/intro.md +3 -1
@@ -0,0 +1,168 @@
1
+ /**
2
+ * Starknet RPC version 0.1.0
3
+ * starknet_api_openrpc version 0.31.0
4
+ *
5
+ * TypeScript Representation of OpenRpc protocol types | results
6
+ * errors are not implemented here only results
7
+ */
8
+
9
+ /**
10
+ * "type": "string",
11
+ * "title": "Field element",
12
+ * "$comment": "A field element, represented as a string of hex digits",
13
+ * "description": "A field element. Represented as up to 63 hex digits and leading 4 bits zeroed.",
14
+ * "pattern": "^0x0[a-fA-F0-9]{1,63}$"
15
+ */
16
+ type FELT = string;
17
+ type BLOCK_NUMBER = number;
18
+ type BLOCK_HASH = FELT;
19
+ type TXN_HASH = FELT;
20
+ type TXN_STATUS = 'PENDING' | 'ACCEPTED_ON_L2' | 'ACCEPTED_ON_L1' | 'REJECTED';
21
+ type TXN_TYPE = 'DECLARE' | 'DEPLOY' | 'INVOKE' | 'L1_HANDLER';
22
+ type MSG_TO_L1 = {
23
+ to_address: FELT;
24
+ payload: Array<FELT>;
25
+ };
26
+ type EVENT = {
27
+ from_address: FELT;
28
+ keys: Array<FELT>;
29
+ data: Array<FELT>;
30
+ };
31
+ type COMMON_RECEIPT_PROPERTIES = {
32
+ transaction_hash: TXN_HASH;
33
+ actual_fee: FELT;
34
+ status: TXN_STATUS;
35
+ block_hash: BLOCK_HASH;
36
+ block_number: BLOCK_NUMBER;
37
+ type?: TXN_TYPE;
38
+ };
39
+ type INVOKE_TXN_RECEIPT_PROPERTIES = {
40
+ messages_sent: MSG_TO_L1;
41
+ events: EVENT;
42
+ };
43
+ type PENDING_COMMON_RECEIPT_PROPERTIES = {
44
+ transaction_hash: TXN_HASH;
45
+ actual_fee: FELT;
46
+ type?: TXN_TYPE;
47
+ };
48
+ type INVOKE_TXN_RECEIPT = COMMON_RECEIPT_PROPERTIES & INVOKE_TXN_RECEIPT_PROPERTIES;
49
+ type L1_HANDLER_TXN_RECEIPT = COMMON_RECEIPT_PROPERTIES;
50
+ type DECLARE_TXN_RECEIPT = COMMON_RECEIPT_PROPERTIES;
51
+ type DEPLOY_TXN_RECEIPT = COMMON_RECEIPT_PROPERTIES;
52
+ type PENDING_INVOKE_TXN_RECEIPT = PENDING_COMMON_RECEIPT_PROPERTIES & INVOKE_TXN_RECEIPT_PROPERTIES;
53
+ type PENDING_TXN_RECEIPT = PENDING_INVOKE_TXN_RECEIPT | PENDING_COMMON_RECEIPT_PROPERTIES;
54
+ type TXN_RECEIPT =
55
+ | INVOKE_TXN_RECEIPT
56
+ | L1_HANDLER_TXN_RECEIPT
57
+ | DECLARE_TXN_RECEIPT
58
+ | DEPLOY_TXN_RECEIPT
59
+ | PENDING_TXN_RECEIPT;
60
+
61
+ export namespace RPC_1 {
62
+ export type GetTransactionReceiptResponse = TXN_RECEIPT;
63
+
64
+ export type Methods = {
65
+ starknet_getTransactionReceipt: {
66
+ QUERY: never;
67
+ REQUEST: any[];
68
+ RESPONSE: GetTransactionReceiptResponse;
69
+ };
70
+ };
71
+ }
72
+
73
+ // starknet_getBlockWithTxHashes
74
+ type BLOCK_HEADER = {
75
+ block_hash: BLOCK_HASH;
76
+ parent_hash: BLOCK_HASH;
77
+ block_number: BLOCK_NUMBER;
78
+ new_root: FELT;
79
+ timestamp: number;
80
+ sequencer_address: FELT;
81
+ };
82
+ type BLOCK_BODY_WITH_TX_HASHES = {
83
+ transactions: Array<TXN_HASH>;
84
+ };
85
+ type BLOCK_WITH_TX_HASHES = {
86
+ status: TXN_STATUS;
87
+ } & BLOCK_HEADER &
88
+ BLOCK_BODY_WITH_TX_HASHES;
89
+ type PENDING_BLOCK_WITH_TX_HASHES = BLOCK_BODY_WITH_TX_HASHES & {
90
+ timestamp: number;
91
+ sequencer_address: FELT;
92
+ parent_hash: BLOCK_HASH;
93
+ };
94
+
95
+ // starknet_getBlockWithTx
96
+ type BLOCK_STATUS = 'PENDING' | 'ACCEPTED_ON_L2' | 'ACCEPTED_ON_L1' | 'REJECTED';
97
+ /**
98
+ * "title": "An integer number in hex format (0x...)",
99
+ * "pattern": "^0x[a-fA-F0-9]+$"
100
+ */
101
+ type NUM_AS_HEX = string;
102
+ type SIGNATURE = Array<FELT>;
103
+ type COMMON_TXN_PROPERTIES = {
104
+ transaction_hash: TXN_HASH;
105
+ max_fee: FELT;
106
+ version: NUM_AS_HEX;
107
+ signature: SIGNATURE;
108
+ nonce: FELT;
109
+ type: TXN_TYPE;
110
+ };
111
+ type ADDRESS = FELT;
112
+ type FUNCTION_CALL = {
113
+ contract_address: ADDRESS;
114
+ entry_point_selector: FELT;
115
+ calldata: Array<FELT>;
116
+ };
117
+ type INVOKE_TXN = COMMON_TXN_PROPERTIES & FUNCTION_CALL;
118
+ type DECLARE_TXN = COMMON_TXN_PROPERTIES & {
119
+ class_hash: FELT;
120
+ sender_address: ADDRESS;
121
+ };
122
+ type DEPLOY_TXN = {
123
+ transaction_hash: TXN_HASH;
124
+ class_hash: FELT;
125
+ version: NUM_AS_HEX;
126
+ type: TXN_TYPE;
127
+ contract_address: FELT;
128
+ contract_address_salt: FELT;
129
+ constructor_calldata: Array<FELT>;
130
+ };
131
+ type TXN = INVOKE_TXN | DECLARE_TXN | DEPLOY_TXN;
132
+ type BLOCK_BODY_WITH_TXS = {
133
+ transactions: Array<TXN>;
134
+ };
135
+ type BLOCK_WITH_TXS = {
136
+ status: BLOCK_STATUS;
137
+ } & BLOCK_HEADER &
138
+ BLOCK_BODY_WITH_TXS;
139
+
140
+ type PENDING_BLOCK_WITH_TXS = BLOCK_BODY_WITH_TXS & {
141
+ timestamp: number;
142
+ sequencer_address: FELT;
143
+ parent_hash: BLOCK_HASH;
144
+ };
145
+
146
+ type CONTRACT_CLASS = {
147
+ program: string; // A base64 representation of the compressed program code
148
+ entry_points_by_type: {
149
+ CONSTRUCTOR: CONTRACT_ENTRY_POINT_LIST;
150
+ EXTERNAL: CONTRACT_ENTRY_POINT_LIST;
151
+ L1_HANDLER: CONTRACT_ENTRY_POINT_LIST;
152
+ };
153
+ };
154
+
155
+ type CONTRACT_ENTRY_POINT_LIST = Array<CONTRACT_ENTRY_POINT>;
156
+ type CONTRACT_ENTRY_POINT = {
157
+ offset: NUM_AS_HEX;
158
+ selector: FELT;
159
+ };
160
+
161
+ export namespace OPENRPC {
162
+ export type GetBlockWithTxHashesResponse = BLOCK_WITH_TX_HASHES | PENDING_BLOCK_WITH_TX_HASHES;
163
+ export type GetBlockWithTxs = BLOCK_WITH_TXS | PENDING_BLOCK_WITH_TXS;
164
+ export type GetStorageAtResponse = FELT;
165
+ export type GetTransactionByHashResponse = TXN;
166
+ export type GetTransactionByBlockIdAndIndex = TXN;
167
+ export type GetClassResponse = CONTRACT_CLASS;
168
+ }
@@ -1,5 +1,7 @@
1
1
  import { StarknetChainId } from '../../constants';
2
+ import { BlockIdentifier } from '../../provider/utils';
2
3
  import { Status } from '../lib';
4
+ import { OPENRPC } from './openrpc';
3
5
 
4
6
  export namespace RPC {
5
7
  export type Response = {
@@ -32,25 +34,9 @@ export namespace RPC {
32
34
  gas_price: number;
33
35
  };
34
36
 
35
- export type GetBlockResponse = {
36
- block_hash: string;
37
- parent_hash: string;
38
- block_number: number;
39
- status: Status;
40
- sequencer: string;
41
- new_root: string;
42
- old_root: string;
43
- accepted_time: number;
44
- gas_price: string;
45
- transactions: string[];
46
- };
47
-
48
- export type GetCodeResponse = {
49
- bytecode: string[];
50
- abi: string;
51
- };
52
-
53
- export type GetStorageAtResponse = string;
37
+ export type GetBlockWithTxHashesResponse = OPENRPC.GetBlockWithTxHashesResponse;
38
+ export type GetBlockWithTxs = OPENRPC.GetBlockWithTxs;
39
+ export type GetStorageAtResponse = OPENRPC.GetStorageAtResponse;
54
40
 
55
41
  export type GetTransactionReceiptResponse = {
56
42
  txn_hash: string;
@@ -81,7 +67,8 @@ export namespace RPC {
81
67
  sender_address?: string;
82
68
  }
83
69
 
84
- export type GetTransactionResponse = InvokeTransactionResponse & DeclareTransactionResponse;
70
+ export type GetTransactionByHashResponse = OPENRPC.GetTransactionByHashResponse;
71
+ export type GetTransactionByBlockIdAndIndex = OPENRPC.GetTransactionByBlockIdAndIndex;
85
72
 
86
73
  export type GetTransactionCountResponse = number;
87
74
 
@@ -99,8 +86,8 @@ export namespace RPC {
99
86
  | boolean;
100
87
 
101
88
  export type EventFilter = {
102
- fromBlock: string;
103
- toBlock: string;
89
+ fromBlock: BlockIdentifier;
90
+ toBlock: BlockIdentifier;
104
91
  address: string;
105
92
  keys: string[];
106
93
  page_size: number;
@@ -143,56 +130,46 @@ export namespace RPC {
143
130
  };
144
131
 
145
132
  export type Methods = {
146
- starknet_getBlockByHash: {
133
+ starknet_getBlockWithTxHashes: {
147
134
  QUERY: never;
148
135
  REQUEST: any[];
149
- RESPONSE: GetBlockResponse;
136
+ RESPONSE: GetBlockWithTxHashesResponse;
150
137
  };
151
- starknet_getBlockByNumber: {
138
+ starknet_getBlockWithTxs: {
152
139
  QUERY: never;
153
140
  REQUEST: any[];
154
- RESPONSE: GetBlockResponse;
141
+ RESPONSE: GetBlockWithTxs;
155
142
  };
156
- starknet_getStorageAt: {
143
+ starknet_getNonce: {
157
144
  QUERY: never;
158
145
  REQUEST: any[];
159
- RESPONSE: GetStorageAtResponse;
146
+ RESPONSE: string;
160
147
  };
161
- starknet_getTransactionByHash: {
148
+ starknet_getStorageAt: {
162
149
  QUERY: never;
163
150
  REQUEST: any[];
164
- RESPONSE: GetTransactionResponse;
151
+ RESPONSE: GetStorageAtResponse;
165
152
  };
166
- starknet_getTransactionByBlockHashAndIndex: {
153
+ starknet_getTransactionByHash: {
167
154
  QUERY: never;
168
155
  REQUEST: any[];
169
- RESPONSE: GetTransactionResponse;
156
+ RESPONSE: GetTransactionByHashResponse;
170
157
  };
171
- starknet_getTransactionByBlockNumberAndIndex: {
158
+ starknet_getTransactionByBlockIdAndIndex: {
172
159
  QUERY: never;
173
160
  REQUEST: any[];
174
- RESPONSE: GetTransactionResponse;
161
+ RESPONSE: GetTransactionByBlockIdAndIndex;
175
162
  };
176
163
  starknet_getTransactionReceipt: {
177
164
  QUERY: never;
178
165
  REQUEST: any[];
179
166
  RESPONSE: GetTransactionReceiptResponse;
180
167
  };
181
- starknet_getBlockTransactionCountByHash: {
182
- QUERY: never;
183
- REQUEST: any[];
184
- RESPONSE: GetTransactionCountResponse;
185
- };
186
- starknet_getBlockTransactionCountByNumber: {
168
+ starknet_getBlockTransactionCount: {
187
169
  QUERY: never;
188
170
  REQUEST: any[];
189
171
  RESPONSE: GetTransactionCountResponse;
190
172
  };
191
- starknet_getCode: {
192
- QUERY: never;
193
- REQUEST: any[];
194
- RESPONSE: GetCodeResponse;
195
- };
196
173
  starknet_call: {
197
174
  QUERY: never;
198
175
  REQUEST: any[];
@@ -1,19 +1,19 @@
1
+ /**
2
+ * Common interface response
3
+ * Intersection (sequencer response ∩ (∪ rpc responses))
4
+ */
1
5
  import BN from 'bn.js';
2
6
 
3
7
  import { Abi, CompressedProgram, EntryPointsByType, RawCalldata, Signature, Status } from './lib';
4
8
 
5
9
  export interface GetBlockResponse {
6
- accepted_time: number;
10
+ timestamp: number;
7
11
  block_hash: string;
8
12
  block_number: number;
9
- gas_price: string;
10
13
  new_root: string;
11
- old_root?: string;
12
14
  parent_hash: string;
13
- sequencer: string;
14
15
  status: Status;
15
16
  transactions: Array<string>;
16
- starknet_version?: string;
17
17
  }
18
18
 
19
19
  export interface GetCodeResponse {
@@ -21,11 +21,13 @@ export const ec = new EC(
21
21
  })
22
22
  );
23
23
 
24
- /*
25
- The function _truncateToN in lib/elliptic/ec/index.js does a shift-right of 4 bits
26
- in some cases. This function does the opposite operation so that
27
- _truncateToN(fixMessage(msg)) == msg.
28
- */
24
+ /**
25
+ * The function _truncateToN in lib/elliptic/ec/index.js does a shift-right of 4 bits
26
+ * in some cases. This function does the opposite operation so that
27
+ * _truncateToN(fixMessage(msg)) == msg.
28
+ *
29
+ * @param msg
30
+ */
29
31
  function fixMessage(msg: string) {
30
32
  const pureHex = msg.replace(/^0x0*/, '');
31
33
 
@@ -64,11 +66,12 @@ export function getKeyPairFromPublicKey(publicKey: BigNumberish): KeyPair {
64
66
  return ec.keyFromPublic(removeHexPrefix(toHex(publicKeyBn)), 'hex');
65
67
  }
66
68
 
67
- /*
68
- Signs a message using the provided key.
69
- key should be an KeyPair with a valid private key.
70
- Returns an Signature.
71
- */
69
+ /**
70
+ * Signs a message using the provided key.
71
+ *
72
+ * @param keyPair should be an KeyPair with a valid private key.
73
+ * @returns an Signature.
74
+ */
72
75
  export function sign(keyPair: KeyPair, msgHash: string): Signature {
73
76
  const msgHashBN = toBN(addHexPrefix(msgHash));
74
77
  // Verify message hash has valid length.
@@ -89,12 +92,13 @@ function chunkArray(arr: any[], n: number): any[][] {
89
92
  .map((_, i) => arr.slice(i * n, i * n + n));
90
93
  }
91
94
 
92
- /*
93
- Verifies a message using the provided key.
94
- key should be an KeyPair with a valid public key.
95
- msgSignature should be an Signature.
96
- Returns a boolean true if the verification succeeds.
97
- */
95
+ /**
96
+ * Verifies a message using the provided key.
97
+ *
98
+ * @param keyPair should be an KeyPair with a valid public key.
99
+ * @param sig should be an Signature.
100
+ * @returns true if the verification succeeds.
101
+ */
98
102
  export function verify(keyPair: KeyPair | KeyPair[], msgHash: string, sig: Signature): boolean {
99
103
  const keyPairArray = Array.isArray(keyPair) ? keyPair : [keyPair];
100
104
  const msgHashBN = toBN(addHexPrefix(msgHash));
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Map RPC Response to common interface response
3
+ * Intersection (sequencer response ∩ (∪ rpc responses))
4
+ */
1
5
  import {
2
6
  CallContractResponse,
3
7
  DeclareContractResponse,
@@ -12,33 +16,36 @@ import { RPC } from '../../types/api';
12
16
  import { toBN } from '../number';
13
17
  import { ResponseParser } from '.';
14
18
 
19
+ type RpcGetBlockResponse = RPC.GetBlockWithTxHashesResponse & {
20
+ [key: string]: any;
21
+ };
22
+
23
+ type GetTransactionByHashResponse = RPC.GetTransactionByHashResponse & {
24
+ [key: string]: any;
25
+ };
26
+
15
27
  export class RPCResponseParser extends ResponseParser {
16
- public parseGetBlockResponse(res: RPC.GetBlockResponse): GetBlockResponse {
28
+ public parseGetBlockResponse(res: RpcGetBlockResponse): GetBlockResponse {
17
29
  return {
18
- accepted_time: res.accepted_time,
30
+ timestamp: res.timestamp,
19
31
  block_hash: res.block_hash,
20
32
  block_number: res.block_number,
21
- gas_price: res.gas_price,
22
33
  new_root: res.new_root,
23
- old_root: res.old_root,
24
34
  parent_hash: res.parent_hash,
25
- sequencer: res.sequencer,
26
35
  status: res.status,
27
36
  transactions: res.transactions,
28
37
  };
29
38
  }
30
39
 
31
- public parseGetTransactionResponse(res: RPC.GetTransactionResponse): GetTransactionResponse {
40
+ public parseGetTransactionResponse(res: GetTransactionByHashResponse): GetTransactionResponse {
32
41
  return {
33
42
  calldata: res.calldata || [],
34
43
  contract_address: res.contract_address,
35
- contract_class: res.contract_class,
36
44
  entry_point_selector: res.entry_point_selector,
37
45
  max_fee: res.max_fee,
38
46
  nonce: res.nonce,
39
- sender_address: res.sender_address,
40
47
  signature: res.signature || [],
41
- transaction_hash: res.txn_hash,
48
+ transaction_hash: res.transaction_hash,
42
49
  version: res.version,
43
50
  };
44
51
  }
@@ -57,10 +64,6 @@ export class RPCResponseParser extends ResponseParser {
57
64
  };
58
65
  }
59
66
 
60
- public parseGetCodeResponse(res: RPC.GetCodeResponse): RPC.GetCodeResponse {
61
- return res;
62
- }
63
-
64
67
  public parseFeeEstimateResponse(res: RPC.EstimateFeeResponse): EstimateFeeResponse {
65
68
  return {
66
69
  overall_fee: toBN(res.overall_fee),
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Map Sequencer Response to common interface response
3
+ * Intersection (sequencer response ∩ (∪ rpc responses))
4
+ */
1
5
  import {
2
6
  CallContractResponse,
3
7
  DeclareContractResponse,
@@ -15,14 +19,11 @@ import { ResponseParser } from '.';
15
19
  export class SequencerAPIResponseParser extends ResponseParser {
16
20
  public parseGetBlockResponse(res: Sequencer.GetBlockResponse): GetBlockResponse {
17
21
  return {
18
- accepted_time: res.timestamp,
22
+ timestamp: res.timestamp,
19
23
  block_hash: res.block_hash,
20
24
  block_number: res.block_number,
21
- gas_price: res.gas_price,
22
25
  new_root: res.state_root,
23
- old_root: undefined,
24
26
  parent_hash: res.parent_block_hash,
25
- sequencer: res.sequencer_address,
26
27
  status: res.status,
27
28
  transactions: Object.values(res.transactions)
28
29
  .map((value) => 'transaction_hash' in value && value.transaction_hash)
@@ -70,10 +71,6 @@ export class SequencerAPIResponseParser extends ResponseParser {
70
71
  };
71
72
  }
72
73
 
73
- public parseGetCodeResponse(res: Sequencer.GetCodeResponse): Sequencer.GetCodeResponse {
74
- return res;
75
- }
76
-
77
74
  public parseFeeEstimateResponse(res: Sequencer.EstimateFeeResponse): EstimateFeeResponse {
78
75
  if ('overall_fee' in res) {
79
76
  let gasInfo = {};
@@ -0,0 +1,151 @@
1
+ /**
2
+ * Starknet RPC version 0.1.0
3
+ * starknet_api_openrpc version 0.31.0
4
+ *
5
+ * TypeScript Representation of OpenRpc protocol types | results
6
+ * errors are not implemented here only results
7
+ */
8
+ /**
9
+ * "type": "string",
10
+ * "title": "Field element",
11
+ * "$comment": "A field element, represented as a string of hex digits",
12
+ * "description": "A field element. Represented as up to 63 hex digits and leading 4 bits zeroed.",
13
+ * "pattern": "^0x0[a-fA-F0-9]{1,63}$"
14
+ */
15
+ declare type FELT = string;
16
+ declare type BLOCK_NUMBER = number;
17
+ declare type BLOCK_HASH = FELT;
18
+ declare type TXN_HASH = FELT;
19
+ declare type TXN_STATUS = 'PENDING' | 'ACCEPTED_ON_L2' | 'ACCEPTED_ON_L1' | 'REJECTED';
20
+ declare type TXN_TYPE = 'DECLARE' | 'DEPLOY' | 'INVOKE' | 'L1_HANDLER';
21
+ declare type MSG_TO_L1 = {
22
+ to_address: FELT;
23
+ payload: Array<FELT>;
24
+ };
25
+ declare type EVENT = {
26
+ from_address: FELT;
27
+ keys: Array<FELT>;
28
+ data: Array<FELT>;
29
+ };
30
+ declare type COMMON_RECEIPT_PROPERTIES = {
31
+ transaction_hash: TXN_HASH;
32
+ actual_fee: FELT;
33
+ status: TXN_STATUS;
34
+ block_hash: BLOCK_HASH;
35
+ block_number: BLOCK_NUMBER;
36
+ type?: TXN_TYPE;
37
+ };
38
+ declare type INVOKE_TXN_RECEIPT_PROPERTIES = {
39
+ messages_sent: MSG_TO_L1;
40
+ events: EVENT;
41
+ };
42
+ declare type PENDING_COMMON_RECEIPT_PROPERTIES = {
43
+ transaction_hash: TXN_HASH;
44
+ actual_fee: FELT;
45
+ type?: TXN_TYPE;
46
+ };
47
+ declare type INVOKE_TXN_RECEIPT = COMMON_RECEIPT_PROPERTIES & INVOKE_TXN_RECEIPT_PROPERTIES;
48
+ declare type L1_HANDLER_TXN_RECEIPT = COMMON_RECEIPT_PROPERTIES;
49
+ declare type DECLARE_TXN_RECEIPT = COMMON_RECEIPT_PROPERTIES;
50
+ declare type DEPLOY_TXN_RECEIPT = COMMON_RECEIPT_PROPERTIES;
51
+ declare type PENDING_INVOKE_TXN_RECEIPT = PENDING_COMMON_RECEIPT_PROPERTIES & INVOKE_TXN_RECEIPT_PROPERTIES;
52
+ declare type PENDING_TXN_RECEIPT = PENDING_INVOKE_TXN_RECEIPT | PENDING_COMMON_RECEIPT_PROPERTIES;
53
+ declare type TXN_RECEIPT = INVOKE_TXN_RECEIPT | L1_HANDLER_TXN_RECEIPT | DECLARE_TXN_RECEIPT | DEPLOY_TXN_RECEIPT | PENDING_TXN_RECEIPT;
54
+ export declare namespace RPC_1 {
55
+ type GetTransactionReceiptResponse = TXN_RECEIPT;
56
+ type Methods = {
57
+ starknet_getTransactionReceipt: {
58
+ QUERY: never;
59
+ REQUEST: any[];
60
+ RESPONSE: GetTransactionReceiptResponse;
61
+ };
62
+ };
63
+ }
64
+ declare type BLOCK_HEADER = {
65
+ block_hash: BLOCK_HASH;
66
+ parent_hash: BLOCK_HASH;
67
+ block_number: BLOCK_NUMBER;
68
+ new_root: FELT;
69
+ timestamp: number;
70
+ sequencer_address: FELT;
71
+ };
72
+ declare type BLOCK_BODY_WITH_TX_HASHES = {
73
+ transactions: Array<TXN_HASH>;
74
+ };
75
+ declare type BLOCK_WITH_TX_HASHES = {
76
+ status: TXN_STATUS;
77
+ } & BLOCK_HEADER & BLOCK_BODY_WITH_TX_HASHES;
78
+ declare type PENDING_BLOCK_WITH_TX_HASHES = BLOCK_BODY_WITH_TX_HASHES & {
79
+ timestamp: number;
80
+ sequencer_address: FELT;
81
+ parent_hash: BLOCK_HASH;
82
+ };
83
+ declare type BLOCK_STATUS = 'PENDING' | 'ACCEPTED_ON_L2' | 'ACCEPTED_ON_L1' | 'REJECTED';
84
+ /**
85
+ * "title": "An integer number in hex format (0x...)",
86
+ * "pattern": "^0x[a-fA-F0-9]+$"
87
+ */
88
+ declare type NUM_AS_HEX = string;
89
+ declare type SIGNATURE = Array<FELT>;
90
+ declare type COMMON_TXN_PROPERTIES = {
91
+ transaction_hash: TXN_HASH;
92
+ max_fee: FELT;
93
+ version: NUM_AS_HEX;
94
+ signature: SIGNATURE;
95
+ nonce: FELT;
96
+ type: TXN_TYPE;
97
+ };
98
+ declare type ADDRESS = FELT;
99
+ declare type FUNCTION_CALL = {
100
+ contract_address: ADDRESS;
101
+ entry_point_selector: FELT;
102
+ calldata: Array<FELT>;
103
+ };
104
+ declare type INVOKE_TXN = COMMON_TXN_PROPERTIES & FUNCTION_CALL;
105
+ declare type DECLARE_TXN = COMMON_TXN_PROPERTIES & {
106
+ class_hash: FELT;
107
+ sender_address: ADDRESS;
108
+ };
109
+ declare type DEPLOY_TXN = {
110
+ transaction_hash: TXN_HASH;
111
+ class_hash: FELT;
112
+ version: NUM_AS_HEX;
113
+ type: TXN_TYPE;
114
+ contract_address: FELT;
115
+ contract_address_salt: FELT;
116
+ constructor_calldata: Array<FELT>;
117
+ };
118
+ declare type TXN = INVOKE_TXN | DECLARE_TXN | DEPLOY_TXN;
119
+ declare type BLOCK_BODY_WITH_TXS = {
120
+ transactions: Array<TXN>;
121
+ };
122
+ declare type BLOCK_WITH_TXS = {
123
+ status: BLOCK_STATUS;
124
+ } & BLOCK_HEADER & BLOCK_BODY_WITH_TXS;
125
+ declare type PENDING_BLOCK_WITH_TXS = BLOCK_BODY_WITH_TXS & {
126
+ timestamp: number;
127
+ sequencer_address: FELT;
128
+ parent_hash: BLOCK_HASH;
129
+ };
130
+ declare type CONTRACT_CLASS = {
131
+ program: string;
132
+ entry_points_by_type: {
133
+ CONSTRUCTOR: CONTRACT_ENTRY_POINT_LIST;
134
+ EXTERNAL: CONTRACT_ENTRY_POINT_LIST;
135
+ L1_HANDLER: CONTRACT_ENTRY_POINT_LIST;
136
+ };
137
+ };
138
+ declare type CONTRACT_ENTRY_POINT_LIST = Array<CONTRACT_ENTRY_POINT>;
139
+ declare type CONTRACT_ENTRY_POINT = {
140
+ offset: NUM_AS_HEX;
141
+ selector: FELT;
142
+ };
143
+ export declare namespace OPENRPC {
144
+ type GetBlockWithTxHashesResponse = BLOCK_WITH_TX_HASHES | PENDING_BLOCK_WITH_TX_HASHES;
145
+ type GetBlockWithTxs = BLOCK_WITH_TXS | PENDING_BLOCK_WITH_TXS;
146
+ type GetStorageAtResponse = FELT;
147
+ type GetTransactionByHashResponse = TXN;
148
+ type GetTransactionByBlockIdAndIndex = TXN;
149
+ type GetClassResponse = CONTRACT_CLASS;
150
+ }
151
+ export {};
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ /**
3
+ * Starknet RPC version 0.1.0
4
+ * starknet_api_openrpc version 0.31.0
5
+ *
6
+ * TypeScript Representation of OpenRpc protocol types | results
7
+ * errors are not implemented here only results
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });