starknet 3.18.2 → 4.0.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 +70 -0
- package/README.md +1 -2
- package/__tests__/account.test.ts +11 -56
- package/__tests__/contract.test.ts +11 -49
- package/__tests__/defaultProvider.test.ts +321 -0
- package/__tests__/fixtures.ts +32 -11
- package/__tests__/jest.setup.ts +2 -3
- package/__tests__/rpcProvider.test.ts +17 -0
- package/__tests__/sequencerProvider.test.ts +45 -0
- package/account/default.d.ts +54 -77
- package/account/default.js +271 -596
- package/account/index.js +18 -31
- package/account/interface.d.ts +66 -95
- package/account/interface.js +20 -30
- package/constants.d.ts +17 -19
- package/constants.js +2038 -2059
- package/contract/contractFactory.d.ts +25 -29
- package/contract/contractFactory.js +94 -210
- package/contract/default.d.ts +117 -146
- package/contract/default.js +582 -776
- package/contract/index.js +19 -32
- package/contract/interface.d.ts +72 -92
- package/contract/interface.js +6 -5
- package/dist/account/default.d.ts +5 -9
- package/dist/account/default.js +35 -169
- package/dist/account/interface.d.ts +3 -15
- package/dist/contract/contractFactory.js +4 -4
- package/dist/contract/default.d.ts +3 -3
- package/dist/contract/default.js +3 -2
- package/dist/contract/interface.d.ts +2 -2
- package/dist/provider/default.d.ts +18 -134
- package/dist/provider/default.js +47 -411
- package/dist/provider/index.d.ts +2 -0
- package/dist/provider/index.js +2 -0
- package/dist/provider/interface.d.ts +45 -50
- package/dist/provider/rpc.d.ts +57 -0
- package/dist/provider/rpc.js +364 -0
- package/dist/provider/sequencer.d.ts +66 -0
- package/dist/provider/sequencer.js +444 -0
- package/dist/types/account.d.ts +2 -3
- package/dist/types/api/index.d.ts +16 -0
- package/dist/types/api/index.js +18 -0
- package/dist/types/api/rpc.d.ts +221 -0
- package/dist/types/{api.js → api/rpc.js} +0 -0
- package/dist/types/api/sequencer.d.ts +289 -0
- package/dist/types/api/sequencer.js +2 -0
- package/dist/types/index.d.ts +3 -1
- package/dist/types/index.js +15 -1
- package/dist/types/lib.d.ts +3 -1
- package/dist/types/provider.d.ts +86 -0
- package/dist/types/provider.js +2 -0
- package/dist/utils/fetchPonyfill.d.ts +2 -0
- package/dist/utils/fetchPonyfill.js +6 -0
- package/dist/utils/provider.d.ts +4 -0
- package/dist/utils/provider.js +38 -0
- package/dist/utils/responseParser/index.d.ts +11 -0
- package/dist/utils/responseParser/index.js +9 -0
- package/dist/utils/responseParser/rpc.d.ts +13 -0
- package/dist/utils/responseParser/rpc.js +96 -0
- package/dist/utils/responseParser/sequencer.d.ts +13 -0
- package/dist/utils/responseParser/sequencer.js +124 -0
- package/index.js +42 -75
- package/package.json +2 -3
- package/provider/default.d.ts +21 -175
- package/provider/default.js +139 -704
- package/provider/errors.d.ts +4 -4
- package/provider/errors.js +30 -40
- package/provider/index.d.ts +2 -0
- package/provider/index.js +22 -33
- package/provider/interface.d.ts +104 -131
- package/provider/interface.js +6 -5
- package/provider/rpc.d.ts +57 -0
- package/provider/rpc.js +364 -0
- package/provider/sequencer.d.ts +66 -0
- package/provider/sequencer.js +444 -0
- package/provider/utils.d.ts +7 -9
- package/provider/utils.js +39 -44
- package/signer/default.d.ts +5 -9
- package/signer/default.js +72 -177
- package/signer/index.js +18 -31
- package/signer/interface.d.ts +29 -33
- package/signer/interface.js +6 -5
- package/src/account/default.ts +26 -146
- package/src/account/interface.ts +5 -20
- package/src/contract/contractFactory.ts +3 -6
- package/src/contract/default.ts +6 -4
- package/src/contract/interface.ts +2 -2
- package/src/provider/default.ts +63 -395
- package/src/provider/index.ts +2 -0
- package/src/provider/interface.ts +68 -63
- package/src/provider/rpc.ts +299 -0
- package/src/provider/sequencer.ts +385 -0
- package/src/types/account.ts +2 -3
- package/src/types/api/index.ts +17 -0
- package/src/types/api/rpc.ts +247 -0
- package/src/types/api/sequencer.ts +331 -0
- package/src/types/index.ts +3 -1
- package/src/types/lib.ts +3 -1
- package/src/types/provider.ts +108 -0
- package/src/utils/fetchPonyfill.ts +4 -0
- package/src/utils/provider.ts +28 -0
- package/src/utils/responseParser/index.ts +28 -0
- package/src/utils/responseParser/rpc.ts +93 -0
- package/src/utils/responseParser/sequencer.ts +127 -0
- package/types/account.d.ts +5 -7
- package/types/account.js +2 -2
- package/types/api/index.d.ts +16 -0
- package/types/api/index.js +18 -0
- package/types/api/rpc.d.ts +221 -0
- package/types/api/rpc.js +2 -0
- package/types/api/sequencer.d.ts +289 -0
- package/types/api/sequencer.js +2 -0
- package/types/contract.d.ts +1 -1
- package/types/contract.js +2 -2
- package/types/index.d.ts +3 -1
- package/types/index.js +35 -34
- package/types/lib.d.ts +36 -41
- package/types/lib.js +2 -2
- package/types/provider.d.ts +86 -0
- package/types/provider.js +2 -0
- package/types/signer.d.ts +2 -2
- package/types/signer.js +2 -2
- package/utils/address.js +26 -37
- package/utils/ellipticCurve.d.ts +1 -6
- package/utils/ellipticCurve.js +73 -137
- package/utils/encode.js +49 -85
- package/utils/fetchPonyfill.d.ts +2 -0
- package/utils/fetchPonyfill.js +6 -0
- package/utils/hash.d.ts +4 -31
- package/utils/hash.js +76 -141
- package/utils/json.d.ts +13 -45
- package/utils/json.js +15 -22
- package/utils/number.d.ts +2 -9
- package/utils/number.js +47 -81
- package/utils/provider.d.ts +4 -0
- package/utils/provider.js +38 -0
- package/utils/responseParser/index.d.ts +11 -0
- package/utils/responseParser/index.js +9 -0
- package/utils/responseParser/rpc.d.ts +13 -0
- package/utils/responseParser/rpc.js +96 -0
- package/utils/responseParser/sequencer.d.ts +13 -0
- package/utils/responseParser/sequencer.js +124 -0
- package/utils/shortString.js +13 -21
- package/utils/stark.d.ts +0 -1
- package/utils/stark.js +59 -93
- package/utils/transaction.d.ts +3 -6
- package/utils/transaction.js +50 -81
- package/utils/typedData/index.d.ts +3 -15
- package/utils/typedData/index.js +109 -175
- package/utils/typedData/types.d.ts +9 -9
- package/utils/typedData/types.js +2 -2
- package/utils/typedData/utils.js +6 -6
- package/utils/uint256.d.ts +5 -5
- package/utils/uint256.js +16 -26
- package/www/docs/API/account.md +3 -4
- package/www/docs/API/contract.md +2 -2
- package/www/docs/API/contractFactory.md +2 -2
- package/www/docs/API/provider.md +185 -74
- package/www/guides/account.md +1 -8
- package/www/guides/erc20.md +3 -0
- package/__tests__/provider.test.ts +0 -168
- package/dist/types/api.d.ts +0 -261
- package/src/types/api.ts +0 -303
- package/types/api.d.ts +0 -287
- package/types/api.js +0 -2
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { StarknetChainId } from '../../constants';
|
|
2
|
+
import { Status } from '../lib';
|
|
3
|
+
export declare namespace RPC {
|
|
4
|
+
export type Response = {
|
|
5
|
+
id: number;
|
|
6
|
+
result: any;
|
|
7
|
+
jsonrpc: string;
|
|
8
|
+
error?: {
|
|
9
|
+
code: string;
|
|
10
|
+
message: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export type AddTransactionResponse = {
|
|
14
|
+
transaction_hash: string;
|
|
15
|
+
};
|
|
16
|
+
export type GetClassResponse = {
|
|
17
|
+
program: string;
|
|
18
|
+
entry_point_by_type: any;
|
|
19
|
+
};
|
|
20
|
+
export type DeclareResponse = {
|
|
21
|
+
transaction_hash: string;
|
|
22
|
+
class_hash: string;
|
|
23
|
+
};
|
|
24
|
+
export type EstimateFeeResponse = {
|
|
25
|
+
overall_fee: number;
|
|
26
|
+
gas_consumed: number;
|
|
27
|
+
gas_price: number;
|
|
28
|
+
};
|
|
29
|
+
export type GetBlockResponse = {
|
|
30
|
+
block_hash: string;
|
|
31
|
+
parent_hash: string;
|
|
32
|
+
block_number: number;
|
|
33
|
+
status: Status;
|
|
34
|
+
sequencer: string;
|
|
35
|
+
new_root: string;
|
|
36
|
+
old_root: string;
|
|
37
|
+
accepted_time: number;
|
|
38
|
+
gas_price: string;
|
|
39
|
+
transactions: string[];
|
|
40
|
+
};
|
|
41
|
+
export type GetCodeResponse = {
|
|
42
|
+
bytecode: string[];
|
|
43
|
+
abi: string;
|
|
44
|
+
};
|
|
45
|
+
export type GetStorageAtResponse = string;
|
|
46
|
+
export type GetTransactionReceiptResponse = {
|
|
47
|
+
txn_hash: string;
|
|
48
|
+
actual_fee: string;
|
|
49
|
+
status: Status;
|
|
50
|
+
status_data: string;
|
|
51
|
+
messages_sent: Array<MessageToL1>;
|
|
52
|
+
l1_origin_message: MessageToL2;
|
|
53
|
+
events: Array<StarknetEvent>;
|
|
54
|
+
};
|
|
55
|
+
interface CommonTransactionProperties {
|
|
56
|
+
txn_hash: string;
|
|
57
|
+
max_fee: string;
|
|
58
|
+
version: string;
|
|
59
|
+
nonce: string;
|
|
60
|
+
signature: Array<string>;
|
|
61
|
+
}
|
|
62
|
+
export interface InvokeTransactionResponse extends CommonTransactionProperties {
|
|
63
|
+
contract_address?: string;
|
|
64
|
+
entry_point_selector?: string;
|
|
65
|
+
calldata?: Array<string>;
|
|
66
|
+
}
|
|
67
|
+
export interface DeclareTransactionResponse extends CommonTransactionProperties {
|
|
68
|
+
contract_class?: GetClassResponse;
|
|
69
|
+
sender_address?: string;
|
|
70
|
+
}
|
|
71
|
+
export type GetTransactionResponse = InvokeTransactionResponse & DeclareTransactionResponse;
|
|
72
|
+
export type GetTransactionCountResponse = number;
|
|
73
|
+
export type GetBlockNumberResponse = number;
|
|
74
|
+
export type GetSyncingStatsResponse = {
|
|
75
|
+
starting_block_hash: string;
|
|
76
|
+
starting_block_num: string;
|
|
77
|
+
current_block_hash: string;
|
|
78
|
+
current_block_num: string;
|
|
79
|
+
highest_block_hash: string;
|
|
80
|
+
highest_block_num: string;
|
|
81
|
+
} | boolean;
|
|
82
|
+
export type EventFilter = {
|
|
83
|
+
fromBlock: string;
|
|
84
|
+
toBlock: string;
|
|
85
|
+
address: string;
|
|
86
|
+
keys: string[];
|
|
87
|
+
page_size: number;
|
|
88
|
+
page_number: number;
|
|
89
|
+
};
|
|
90
|
+
export type GetEventsResponse = {
|
|
91
|
+
events: StarknetEmittedEvent[];
|
|
92
|
+
page_number: number;
|
|
93
|
+
is_last_page: number;
|
|
94
|
+
};
|
|
95
|
+
export type DeployContractResponse = {
|
|
96
|
+
transaction_hash: string;
|
|
97
|
+
contract_address: string;
|
|
98
|
+
};
|
|
99
|
+
export type StarknetEvent = {
|
|
100
|
+
from_address: string;
|
|
101
|
+
keys: string[];
|
|
102
|
+
data: string[];
|
|
103
|
+
};
|
|
104
|
+
export type StarknetEmittedEvent = {
|
|
105
|
+
event: StarknetEvent;
|
|
106
|
+
block_hash: string;
|
|
107
|
+
block_number: number;
|
|
108
|
+
transaction_hash: string;
|
|
109
|
+
};
|
|
110
|
+
export type MessageToL1 = {
|
|
111
|
+
to_address: string;
|
|
112
|
+
payload: string[];
|
|
113
|
+
};
|
|
114
|
+
export type MessageToL2 = {
|
|
115
|
+
from_address: string;
|
|
116
|
+
payload: string[];
|
|
117
|
+
};
|
|
118
|
+
export type Methods = {
|
|
119
|
+
starknet_getBlockByHash: {
|
|
120
|
+
QUERY: never;
|
|
121
|
+
REQUEST: any[];
|
|
122
|
+
RESPONSE: GetBlockResponse;
|
|
123
|
+
};
|
|
124
|
+
starknet_getBlockByNumber: {
|
|
125
|
+
QUERY: never;
|
|
126
|
+
REQUEST: any[];
|
|
127
|
+
RESPONSE: GetBlockResponse;
|
|
128
|
+
};
|
|
129
|
+
starknet_getStorageAt: {
|
|
130
|
+
QUERY: never;
|
|
131
|
+
REQUEST: any[];
|
|
132
|
+
RESPONSE: GetStorageAtResponse;
|
|
133
|
+
};
|
|
134
|
+
starknet_getTransactionByHash: {
|
|
135
|
+
QUERY: never;
|
|
136
|
+
REQUEST: any[];
|
|
137
|
+
RESPONSE: GetTransactionResponse;
|
|
138
|
+
};
|
|
139
|
+
starknet_getTransactionByBlockHashAndIndex: {
|
|
140
|
+
QUERY: never;
|
|
141
|
+
REQUEST: any[];
|
|
142
|
+
RESPONSE: GetTransactionResponse;
|
|
143
|
+
};
|
|
144
|
+
starknet_getTransactionByBlockNumberAndIndex: {
|
|
145
|
+
QUERY: never;
|
|
146
|
+
REQUEST: any[];
|
|
147
|
+
RESPONSE: GetTransactionResponse;
|
|
148
|
+
};
|
|
149
|
+
starknet_getTransactionReceipt: {
|
|
150
|
+
QUERY: never;
|
|
151
|
+
REQUEST: any[];
|
|
152
|
+
RESPONSE: GetTransactionReceiptResponse;
|
|
153
|
+
};
|
|
154
|
+
starknet_getBlockTransactionCountByHash: {
|
|
155
|
+
QUERY: never;
|
|
156
|
+
REQUEST: any[];
|
|
157
|
+
RESPONSE: GetTransactionCountResponse;
|
|
158
|
+
};
|
|
159
|
+
starknet_getBlockTransactionCountByNumber: {
|
|
160
|
+
QUERY: never;
|
|
161
|
+
REQUEST: any[];
|
|
162
|
+
RESPONSE: GetTransactionCountResponse;
|
|
163
|
+
};
|
|
164
|
+
starknet_getCode: {
|
|
165
|
+
QUERY: never;
|
|
166
|
+
REQUEST: any[];
|
|
167
|
+
RESPONSE: GetCodeResponse;
|
|
168
|
+
};
|
|
169
|
+
starknet_call: {
|
|
170
|
+
QUERY: never;
|
|
171
|
+
REQUEST: any[];
|
|
172
|
+
RESPONSE: string[];
|
|
173
|
+
};
|
|
174
|
+
starknet_estimateFee: {
|
|
175
|
+
QUERY: never;
|
|
176
|
+
REQUEST: any[];
|
|
177
|
+
RESPONSE: EstimateFeeResponse;
|
|
178
|
+
};
|
|
179
|
+
starknet_blockNumber: {
|
|
180
|
+
QUERY: never;
|
|
181
|
+
REQUEST: any[];
|
|
182
|
+
RESPONSE: GetBlockNumberResponse;
|
|
183
|
+
};
|
|
184
|
+
starknet_chainId: {
|
|
185
|
+
QUERY: never;
|
|
186
|
+
REQUEST: any[];
|
|
187
|
+
RESPONSE: StarknetChainId;
|
|
188
|
+
};
|
|
189
|
+
starknet_syncing: {
|
|
190
|
+
QUERY: never;
|
|
191
|
+
REQUEST: any[];
|
|
192
|
+
RESPONSE: GetSyncingStatsResponse;
|
|
193
|
+
};
|
|
194
|
+
starknet_getEvents: {
|
|
195
|
+
QUERY: never;
|
|
196
|
+
REQUEST: any[];
|
|
197
|
+
RESPONSE: GetEventsResponse;
|
|
198
|
+
};
|
|
199
|
+
starknet_addInvokeTransaction: {
|
|
200
|
+
QUERY: never;
|
|
201
|
+
REQUEST: any[];
|
|
202
|
+
RESPONSE: AddTransactionResponse;
|
|
203
|
+
};
|
|
204
|
+
starknet_addDeployTransaction: {
|
|
205
|
+
QUERY: never;
|
|
206
|
+
REQUEST: any[];
|
|
207
|
+
RESPONSE: DeployContractResponse;
|
|
208
|
+
};
|
|
209
|
+
starknet_addDeclareTransaction: {
|
|
210
|
+
QUERY: never;
|
|
211
|
+
REQUEST: any[];
|
|
212
|
+
RESPONSE: DeclareResponse;
|
|
213
|
+
};
|
|
214
|
+
starknet_getClassAt: {
|
|
215
|
+
QUERY: never;
|
|
216
|
+
REQUEST: any[];
|
|
217
|
+
RESPONSE: any;
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
export {};
|
|
221
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import BN from 'bn.js';
|
|
2
|
+
import { BlockIdentifier } from '../../provider/utils';
|
|
3
|
+
import { BigNumberish } from '../../utils/number';
|
|
4
|
+
import { Abi, BlockNumber, EntryPointType, RawCalldata, Signature, Status, TransactionStatus } from '../lib';
|
|
5
|
+
import { ContractClass } from '../provider';
|
|
6
|
+
export declare type GetTransactionStatusResponse = {
|
|
7
|
+
tx_status: Status;
|
|
8
|
+
block_hash?: string;
|
|
9
|
+
tx_failure_reason?: {
|
|
10
|
+
code: string;
|
|
11
|
+
error_message: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export declare type GetContractAddressesResponse = {
|
|
15
|
+
Starknet: string;
|
|
16
|
+
GpsStatementVerifier: string;
|
|
17
|
+
};
|
|
18
|
+
export declare type InvokeFunctionTrace = {
|
|
19
|
+
caller_address: string;
|
|
20
|
+
contract_address: string;
|
|
21
|
+
code_address: string;
|
|
22
|
+
selector: string;
|
|
23
|
+
calldata: RawCalldata;
|
|
24
|
+
result: Array<any>;
|
|
25
|
+
execution_resources: ExecutionResources;
|
|
26
|
+
internal_call: Array<InvokeFunctionTrace>;
|
|
27
|
+
events: Array<any>;
|
|
28
|
+
messages: Array<any>;
|
|
29
|
+
};
|
|
30
|
+
export declare type ExecutionResources = {
|
|
31
|
+
n_steps: number;
|
|
32
|
+
builtin_instance_counter: {
|
|
33
|
+
pedersen_builtin: number;
|
|
34
|
+
range_check_builtin: number;
|
|
35
|
+
bitwise_builtin: number;
|
|
36
|
+
output_builtin: number;
|
|
37
|
+
ecdsa_builtin: number;
|
|
38
|
+
ec_op_builtin?: number;
|
|
39
|
+
};
|
|
40
|
+
n_memory_holes: number;
|
|
41
|
+
};
|
|
42
|
+
export declare type GetCodeResponse = {
|
|
43
|
+
bytecode: string[];
|
|
44
|
+
abi: Abi;
|
|
45
|
+
};
|
|
46
|
+
export declare type GetTransactionTraceResponse = {
|
|
47
|
+
function_invocation: {
|
|
48
|
+
caller_address: string;
|
|
49
|
+
contract_address: string;
|
|
50
|
+
code_address: string;
|
|
51
|
+
selector: string;
|
|
52
|
+
calldata: RawArgs;
|
|
53
|
+
result: Array<any>;
|
|
54
|
+
execution_resources: ExecutionResources;
|
|
55
|
+
internal_call: Array<any>;
|
|
56
|
+
events: Array<any>;
|
|
57
|
+
messages: Array<any>;
|
|
58
|
+
};
|
|
59
|
+
signature: Signature;
|
|
60
|
+
};
|
|
61
|
+
export declare type RawArgs = {
|
|
62
|
+
[inputName: string]: string | string[] | {
|
|
63
|
+
type: 'struct';
|
|
64
|
+
[k: string]: BigNumberish;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
export declare namespace Sequencer {
|
|
68
|
+
type DeclareTransaction = {
|
|
69
|
+
type: 'DECLARE';
|
|
70
|
+
contract_class: ContractClass;
|
|
71
|
+
nonce: BigNumberish;
|
|
72
|
+
sender_address: BigNumberish;
|
|
73
|
+
signature: Signature;
|
|
74
|
+
};
|
|
75
|
+
type DeployTransaction = {
|
|
76
|
+
type: 'DEPLOY';
|
|
77
|
+
contract_definition: ContractClass;
|
|
78
|
+
contract_address_salt: BigNumberish;
|
|
79
|
+
constructor_calldata: string[];
|
|
80
|
+
nonce?: BigNumberish;
|
|
81
|
+
};
|
|
82
|
+
type InvokeFunctionTransaction = {
|
|
83
|
+
type: 'INVOKE_FUNCTION';
|
|
84
|
+
contract_address: string;
|
|
85
|
+
signature?: Signature;
|
|
86
|
+
entry_point_type?: EntryPointType;
|
|
87
|
+
entry_point_selector: string;
|
|
88
|
+
calldata?: RawCalldata;
|
|
89
|
+
nonce?: BigNumberish;
|
|
90
|
+
max_fee?: BigNumberish;
|
|
91
|
+
version?: BigNumberish;
|
|
92
|
+
};
|
|
93
|
+
type Transaction = DeclareTransaction | DeployTransaction | InvokeFunctionTransaction;
|
|
94
|
+
type AddTransactionResponse = {
|
|
95
|
+
transaction_hash: string;
|
|
96
|
+
code?: TransactionStatus;
|
|
97
|
+
address?: string;
|
|
98
|
+
class_hash?: string;
|
|
99
|
+
};
|
|
100
|
+
interface InvokeFunctionTransactionResponse extends InvokeFunctionTransaction {
|
|
101
|
+
transaction_hash: string;
|
|
102
|
+
}
|
|
103
|
+
type TransactionResponse = DeclareTransaction | DeployTransaction | InvokeFunctionTransactionResponse;
|
|
104
|
+
type SuccessfulTransactionResponse = {
|
|
105
|
+
status: Status;
|
|
106
|
+
transaction: TransactionResponse;
|
|
107
|
+
block_hash: string;
|
|
108
|
+
block_number: BlockNumber;
|
|
109
|
+
transaction_index: number;
|
|
110
|
+
};
|
|
111
|
+
type FailedTransactionResponse = {
|
|
112
|
+
status: 'REJECTED';
|
|
113
|
+
transaction_failure_reason: {
|
|
114
|
+
code: string;
|
|
115
|
+
error_message: string;
|
|
116
|
+
};
|
|
117
|
+
transaction: TransactionResponse;
|
|
118
|
+
};
|
|
119
|
+
type GetTransactionResponse = SuccessfulTransactionResponse | FailedTransactionResponse;
|
|
120
|
+
type TransactionReceiptResponse = SuccessfulTransactionReceiptResponse | FailedTransactionReceiptResponse;
|
|
121
|
+
type SuccessfulTransactionReceiptResponse = {
|
|
122
|
+
status: Status;
|
|
123
|
+
transaction_hash: string;
|
|
124
|
+
transaction_index: number;
|
|
125
|
+
block_hash: string;
|
|
126
|
+
block_number: BlockNumber;
|
|
127
|
+
l2_to_l1_messages: string[];
|
|
128
|
+
events: string[];
|
|
129
|
+
actual_fee: string;
|
|
130
|
+
execution_resources: ExecutionResources;
|
|
131
|
+
};
|
|
132
|
+
type FailedTransactionReceiptResponse = {
|
|
133
|
+
status: 'REJECTED';
|
|
134
|
+
transaction_failure_reason: {
|
|
135
|
+
code: string;
|
|
136
|
+
error_message: string;
|
|
137
|
+
};
|
|
138
|
+
transaction_hash: string;
|
|
139
|
+
l2_to_l1_messages: string[];
|
|
140
|
+
events: string[];
|
|
141
|
+
};
|
|
142
|
+
type GetBlockResponse = {
|
|
143
|
+
block_number: number;
|
|
144
|
+
state_root: string;
|
|
145
|
+
block_hash: string;
|
|
146
|
+
transactions: {
|
|
147
|
+
[txHash: string]: TransactionResponse;
|
|
148
|
+
};
|
|
149
|
+
timestamp: number;
|
|
150
|
+
transaction_receipts: {
|
|
151
|
+
[txHash: string]: {
|
|
152
|
+
block_hash: string;
|
|
153
|
+
transaction_hash: string;
|
|
154
|
+
l2_to_l1_messages: {
|
|
155
|
+
to_address: string;
|
|
156
|
+
payload: string[];
|
|
157
|
+
from_address: string;
|
|
158
|
+
}[];
|
|
159
|
+
block_number: BlockNumber;
|
|
160
|
+
status: Status;
|
|
161
|
+
transaction_index: number;
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
parent_block_hash: string;
|
|
165
|
+
status: Status;
|
|
166
|
+
gas_price: string;
|
|
167
|
+
sequencer_address: string;
|
|
168
|
+
};
|
|
169
|
+
type CallContractTransaction = Omit<InvokeFunctionTransaction, 'type' | 'entry_point_type' | 'nonce'>;
|
|
170
|
+
type CallContractResponse = {
|
|
171
|
+
result: string[];
|
|
172
|
+
};
|
|
173
|
+
type EstimateFeeResponse = {
|
|
174
|
+
overall_fee: number;
|
|
175
|
+
gas_price: number;
|
|
176
|
+
gas_usage: number;
|
|
177
|
+
} | {
|
|
178
|
+
amount: BN;
|
|
179
|
+
unit: string;
|
|
180
|
+
};
|
|
181
|
+
type Endpoints = {
|
|
182
|
+
get_contract_addresses: {
|
|
183
|
+
QUERY: never;
|
|
184
|
+
REQUEST: never;
|
|
185
|
+
RESPONSE: GetContractAddressesResponse;
|
|
186
|
+
};
|
|
187
|
+
add_transaction: {
|
|
188
|
+
QUERY: never;
|
|
189
|
+
REQUEST: Transaction;
|
|
190
|
+
RESPONSE: AddTransactionResponse;
|
|
191
|
+
};
|
|
192
|
+
get_transaction: {
|
|
193
|
+
QUERY: {
|
|
194
|
+
transactionHash: string;
|
|
195
|
+
};
|
|
196
|
+
REQUEST: never;
|
|
197
|
+
RESPONSE: GetTransactionResponse;
|
|
198
|
+
};
|
|
199
|
+
get_transaction_status: {
|
|
200
|
+
QUERY: {
|
|
201
|
+
transactionHash: string;
|
|
202
|
+
};
|
|
203
|
+
REQUEST: never;
|
|
204
|
+
RESPONSE: GetTransactionStatusResponse;
|
|
205
|
+
};
|
|
206
|
+
get_transaction_trace: {
|
|
207
|
+
QUERY: {
|
|
208
|
+
transactionHash: string;
|
|
209
|
+
};
|
|
210
|
+
REQUEST: never;
|
|
211
|
+
RESPONSE: GetTransactionTraceResponse;
|
|
212
|
+
};
|
|
213
|
+
get_transaction_receipt: {
|
|
214
|
+
QUERY: {
|
|
215
|
+
transactionHash: string;
|
|
216
|
+
};
|
|
217
|
+
REQUEST: never;
|
|
218
|
+
RESPONSE: TransactionReceiptResponse;
|
|
219
|
+
};
|
|
220
|
+
get_storage_at: {
|
|
221
|
+
QUERY: {
|
|
222
|
+
contractAddress: string;
|
|
223
|
+
key: BigNumberish;
|
|
224
|
+
blockIdentifier: BlockIdentifier;
|
|
225
|
+
};
|
|
226
|
+
REQUEST: never;
|
|
227
|
+
RESPONSE: string;
|
|
228
|
+
};
|
|
229
|
+
get_code: {
|
|
230
|
+
QUERY: {
|
|
231
|
+
contractAddress: string;
|
|
232
|
+
blockIdentifier: BlockIdentifier;
|
|
233
|
+
};
|
|
234
|
+
REQUEST: never;
|
|
235
|
+
RESPONSE: GetCodeResponse;
|
|
236
|
+
};
|
|
237
|
+
get_block: {
|
|
238
|
+
QUERY: {
|
|
239
|
+
blockIdentifier: BlockIdentifier;
|
|
240
|
+
};
|
|
241
|
+
REQUEST: never;
|
|
242
|
+
RESPONSE: GetBlockResponse;
|
|
243
|
+
};
|
|
244
|
+
call_contract: {
|
|
245
|
+
QUERY: {
|
|
246
|
+
blockIdentifier: BlockIdentifier;
|
|
247
|
+
};
|
|
248
|
+
REQUEST: CallContractTransaction;
|
|
249
|
+
RESPONSE: CallContractResponse;
|
|
250
|
+
};
|
|
251
|
+
estimate_fee: {
|
|
252
|
+
QUERY: {
|
|
253
|
+
blockIdentifier: BlockIdentifier;
|
|
254
|
+
};
|
|
255
|
+
REQUEST: CallContractTransaction;
|
|
256
|
+
RESPONSE: EstimateFeeResponse;
|
|
257
|
+
};
|
|
258
|
+
get_class_by_hash: {
|
|
259
|
+
QUERY: {
|
|
260
|
+
classHash: string;
|
|
261
|
+
};
|
|
262
|
+
REQUEST: never;
|
|
263
|
+
RESPONSE: any;
|
|
264
|
+
};
|
|
265
|
+
get_class_hash_at: {
|
|
266
|
+
QUERY: {
|
|
267
|
+
contractAddress: string;
|
|
268
|
+
blockIdentifier?: BlockIdentifier;
|
|
269
|
+
};
|
|
270
|
+
REQUEST: never;
|
|
271
|
+
RESPONSE: string;
|
|
272
|
+
};
|
|
273
|
+
get_state_update: {
|
|
274
|
+
QUERY: {
|
|
275
|
+
blockHash: string;
|
|
276
|
+
};
|
|
277
|
+
REQUEST: never;
|
|
278
|
+
RESPONSE: any;
|
|
279
|
+
};
|
|
280
|
+
get_full_contract: {
|
|
281
|
+
QUERY: {
|
|
282
|
+
contractAddress: string;
|
|
283
|
+
blockIdentifier?: BlockIdentifier;
|
|
284
|
+
};
|
|
285
|
+
REQUEST: never;
|
|
286
|
+
RESPONSE: any;
|
|
287
|
+
};
|
|
288
|
+
};
|
|
289
|
+
}
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.js
CHANGED
|
@@ -10,12 +10,26 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
11
|
o[k2] = m[k];
|
|
12
12
|
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
13
18
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
19
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
20
|
};
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
16
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.api = void 0;
|
|
17
30
|
__exportStar(require("./lib"), exports);
|
|
18
|
-
|
|
31
|
+
exports.api = __importStar(require("./api"));
|
|
19
32
|
__exportStar(require("./signer"), exports);
|
|
20
33
|
__exportStar(require("./contract"), exports);
|
|
21
34
|
__exportStar(require("./account"), exports);
|
|
35
|
+
__exportStar(require("./provider"), exports);
|
package/dist/types/lib.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export declare type DeployContractPayload = {
|
|
|
10
10
|
};
|
|
11
11
|
export declare type DeclareContractPayload = {
|
|
12
12
|
contract: CompiledContract | string;
|
|
13
|
+
version?: BigNumberish;
|
|
13
14
|
};
|
|
14
15
|
export declare type Invocation = {
|
|
15
16
|
contractAddress: string;
|
|
@@ -50,7 +51,8 @@ export declare type StructAbi = {
|
|
|
50
51
|
export declare type Abi = Array<FunctionAbi | StructAbi>;
|
|
51
52
|
export declare type EntryPointsByType = object;
|
|
52
53
|
export declare type Program = Record<any, any>;
|
|
53
|
-
export declare type
|
|
54
|
+
export declare type BlockTag = 'pending' | 'latest';
|
|
55
|
+
export declare type BlockNumber = BlockTag | null | number;
|
|
54
56
|
export declare type CompiledContract = {
|
|
55
57
|
abi: Abi;
|
|
56
58
|
entry_points_by_type: EntryPointsByType;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import BN from 'bn.js';
|
|
2
|
+
import { Abi, CompressedProgram, EntryPointsByType, RawCalldata, Signature, Status } from './lib';
|
|
3
|
+
export interface GetBlockResponse {
|
|
4
|
+
accepted_time: number;
|
|
5
|
+
block_hash: string;
|
|
6
|
+
block_number: number;
|
|
7
|
+
gas_price: string;
|
|
8
|
+
new_root: string;
|
|
9
|
+
old_root?: string;
|
|
10
|
+
parent_hash: string;
|
|
11
|
+
sequencer: string;
|
|
12
|
+
status: Status;
|
|
13
|
+
transactions: Array<string>;
|
|
14
|
+
starknet_version?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare type GetTransactionResponse = InvokeTransactionResponse & DeclareTransactionResponse;
|
|
17
|
+
export interface CommonTransactionResponse {
|
|
18
|
+
transaction_hash?: string;
|
|
19
|
+
version?: string;
|
|
20
|
+
signature?: Signature;
|
|
21
|
+
max_fee?: string;
|
|
22
|
+
nonce?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface InvokeTransactionResponse extends CommonTransactionResponse {
|
|
25
|
+
contract_address?: string;
|
|
26
|
+
entry_point_selector?: string;
|
|
27
|
+
calldata: RawCalldata;
|
|
28
|
+
}
|
|
29
|
+
export interface ContractEntryPoint {
|
|
30
|
+
offset: string;
|
|
31
|
+
selector: string;
|
|
32
|
+
}
|
|
33
|
+
export interface ContractClass {
|
|
34
|
+
program: CompressedProgram;
|
|
35
|
+
entry_points_by_type: EntryPointsByType;
|
|
36
|
+
abi?: Abi;
|
|
37
|
+
}
|
|
38
|
+
export interface DeclareTransactionResponse extends CommonTransactionResponse {
|
|
39
|
+
contract_class?: any;
|
|
40
|
+
sender_address?: string;
|
|
41
|
+
}
|
|
42
|
+
export declare type GetTransactionReceiptResponse = InvokeTransactionReceiptResponse | DeclareTransactionReceiptResponse;
|
|
43
|
+
export interface CommonTransactionReceiptResponse {
|
|
44
|
+
transaction_hash: string;
|
|
45
|
+
status: Status;
|
|
46
|
+
actual_fee?: string;
|
|
47
|
+
status_data?: string;
|
|
48
|
+
}
|
|
49
|
+
export interface MessageToL1 {
|
|
50
|
+
to_address: string;
|
|
51
|
+
payload: Array<string>;
|
|
52
|
+
}
|
|
53
|
+
export interface Event {
|
|
54
|
+
from_address: string;
|
|
55
|
+
keys: Array<string>;
|
|
56
|
+
data: Array<string>;
|
|
57
|
+
}
|
|
58
|
+
export interface MessageToL2 {
|
|
59
|
+
from_address: string;
|
|
60
|
+
payload: Array<string>;
|
|
61
|
+
}
|
|
62
|
+
export interface InvokeTransactionReceiptResponse extends CommonTransactionReceiptResponse {
|
|
63
|
+
messages_sent: Array<MessageToL1>;
|
|
64
|
+
events: Array<Event>;
|
|
65
|
+
l1_origin_message?: MessageToL2;
|
|
66
|
+
}
|
|
67
|
+
export declare type DeclareTransactionReceiptResponse = CommonTransactionReceiptResponse;
|
|
68
|
+
export interface EstimateFeeResponse {
|
|
69
|
+
overall_fee: BN;
|
|
70
|
+
gas_consumed?: BN;
|
|
71
|
+
gas_price?: BN;
|
|
72
|
+
}
|
|
73
|
+
export interface InvokeFunctionResponse {
|
|
74
|
+
transaction_hash: string;
|
|
75
|
+
}
|
|
76
|
+
export interface DeployContractResponse {
|
|
77
|
+
contract_address: string;
|
|
78
|
+
transaction_hash: string;
|
|
79
|
+
}
|
|
80
|
+
export interface DeclareContractResponse {
|
|
81
|
+
transaction_hash: string;
|
|
82
|
+
class_hash: string;
|
|
83
|
+
}
|
|
84
|
+
export declare type CallContractResponse = {
|
|
85
|
+
result: Array<string>;
|
|
86
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = (typeof window !== 'undefined' && window.fetch) || // use buildin fetch in browser if available
|
|
4
|
+
(typeof global !== 'undefined' && global.fetch) || // use buildin fetch in node, react-native and service worker if available
|
|
5
|
+
// eslint-disable-next-line global-require
|
|
6
|
+
require('isomorphic-fetch'); // ponyfill fetch in node and browsers that don't have it
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { CompiledContract, ContractClass, RawCalldata } from '../types';
|
|
2
|
+
export declare function wait(delay: number): Promise<unknown>;
|
|
3
|
+
export declare function parseCalldata(calldata?: RawCalldata): string[];
|
|
4
|
+
export declare function parseContract(contract: CompiledContract | string): ContractClass;
|