starknet 4.9.0 → 4.11.0
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 +43 -0
- package/README.md +1 -3
- package/__tests__/account.test.ts +5 -1
- package/__tests__/defaultProvider.test.ts +97 -210
- package/__tests__/fixtures.ts +2 -2
- package/__tests__/rpcProvider.test.ts +7 -4
- package/__tests__/udc.test.ts +41 -0
- package/account/default.d.ts +3 -1
- package/account/default.js +53 -3
- package/account/interface.d.ts +24 -7
- package/constants.d.ts +7 -1
- package/constants.js +7 -1
- package/contract/default.d.ts +11 -27
- package/contract/default.js +104 -120
- package/contract/interface.d.ts +5 -2
- package/dist/account/default.d.ts +3 -1
- package/dist/account/default.js +53 -3
- package/dist/account/interface.d.ts +24 -7
- package/dist/constants.d.ts +7 -1
- package/dist/constants.js +7 -1
- package/dist/contract/default.d.ts +11 -27
- package/dist/contract/default.js +104 -120
- package/dist/contract/interface.d.ts +5 -2
- package/dist/provider/default.d.ts +4 -2
- package/dist/provider/default.js +13 -2
- package/dist/provider/interface.d.ts +18 -3
- package/dist/provider/rpc.d.ts +15 -10
- package/dist/provider/rpc.js +71 -31
- package/dist/provider/sequencer.d.ts +6 -2
- package/dist/provider/sequencer.js +33 -5
- package/dist/signer/default.d.ts +2 -2
- package/dist/signer/default.js +15 -15
- package/dist/signer/interface.d.ts +2 -0
- package/dist/types/api/index.d.ts +0 -6
- package/dist/types/api/openrpc.d.ts +147 -98
- package/dist/types/api/openrpc.js +22 -4
- package/dist/types/index.d.ts +1 -1
- package/dist/types/lib.d.ts +22 -2
- package/dist/types/lib.js +6 -0
- package/dist/utils/number.d.ts +1 -0
- package/dist/utils/number.js +3 -1
- package/package.json +1 -1
- package/provider/default.d.ts +4 -2
- package/provider/default.js +13 -2
- package/provider/interface.d.ts +18 -3
- package/provider/rpc.d.ts +15 -10
- package/provider/rpc.js +71 -31
- package/provider/sequencer.d.ts +6 -2
- package/provider/sequencer.js +33 -5
- package/signer/default.d.ts +2 -2
- package/signer/default.js +15 -15
- package/signer/interface.d.ts +2 -0
- package/src/account/default.ts +51 -7
- package/src/account/interface.ts +34 -7
- package/src/constants.ts +7 -0
- package/src/contract/default.ts +123 -140
- package/src/contract/interface.ts +5 -2
- package/src/provider/default.ts +21 -3
- package/src/provider/interface.ts +26 -2
- package/src/provider/rpc.ts +73 -45
- package/src/provider/sequencer.ts +24 -4
- package/src/signer/default.ts +18 -18
- package/src/signer/interface.ts +2 -0
- package/src/types/api/index.ts +0 -4
- package/src/types/api/openrpc.ts +193 -105
- package/src/types/api/rpc.ts +0 -1
- package/src/types/index.ts +1 -1
- package/src/types/lib.ts +23 -2
- package/src/utils/number.ts +2 -0
- package/types/api/index.d.ts +0 -6
- package/types/api/openrpc.d.ts +147 -98
- package/types/api/openrpc.js +22 -4
- package/types/index.d.ts +1 -1
- package/types/lib.d.ts +22 -2
- package/types/lib.js +6 -0
- package/utils/number.d.ts +1 -0
- package/utils/number.js +3 -1
- package/www/docs/API/account.md +122 -22
- package/www/docs/API/contract.md +39 -3
- package/www/docs/API/provider.md +4 -0
- package/www/docs/API/signer.md +56 -2
package/www/docs/API/account.md
CHANGED
|
@@ -24,20 +24,56 @@ The address of the account contract.
|
|
|
24
24
|
|
|
25
25
|
## Methods
|
|
26
26
|
|
|
27
|
-
account.**getNonce()** => _Promise < BigNumberish >_
|
|
27
|
+
account.**getNonce(blockIdentifier)** => _Promise < BigNumberish >_
|
|
28
28
|
|
|
29
|
-
Gets the
|
|
29
|
+
Gets the nonce of the account with respect to a specific block.
|
|
30
|
+
|
|
31
|
+
_blockIdentifier_ - optional blockIdentifier. Defaults to 'pending'.
|
|
32
|
+
|
|
33
|
+
Returns the nonce of the account.
|
|
34
|
+
|
|
35
|
+
<hr />
|
|
36
|
+
|
|
37
|
+
account.**estimateInvokeFee**(calls [ , estimateFeeDetails ]) => _Promise < EstimateFeeResponse >_
|
|
38
|
+
|
|
39
|
+
Estimate Fee for executing an INVOKE transaction on starknet.
|
|
40
|
+
|
|
41
|
+
The _calls_ object structure:
|
|
42
|
+
|
|
43
|
+
- calls.**contractAddress** - Address of the contract
|
|
44
|
+
- calls.**entrypoint** - Entrypoint of the call (method name)
|
|
45
|
+
- calls.**calldata** - Payload for the invoking method
|
|
46
|
+
|
|
47
|
+
The _estimateFeeDetails_ object may include any of:
|
|
48
|
+
|
|
49
|
+
- estimateFeeDetails.**blockIdentifier** - Block Identifier for the transaction
|
|
50
|
+
- estimateFeeDetails.**nonce** - Nonce for the transaction
|
|
51
|
+
|
|
52
|
+
###### _EstimateFeeResponse_
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
{
|
|
56
|
+
overall_fee: BN;
|
|
57
|
+
gas_consumed?: BN;
|
|
58
|
+
gas_price?: BN;
|
|
59
|
+
}
|
|
60
|
+
```
|
|
30
61
|
|
|
31
62
|
<hr />
|
|
32
63
|
|
|
33
|
-
account.**
|
|
64
|
+
account.**estimateDeclareFee**(contractPayload [ , estimateFeeDetails ]) => _Promise < EstimateFeeResponse >_
|
|
65
|
+
|
|
66
|
+
Estimate Fee for executing a DECLARE transaction on starknet.
|
|
34
67
|
|
|
35
|
-
|
|
68
|
+
The _contractPayload_ object structure:
|
|
36
69
|
|
|
37
|
-
|
|
70
|
+
- contractPayload.**contract** - The compiled contract
|
|
71
|
+
- contractPayload.**classHash** - This can be obtained by using starknet-cli. Once the classHash is included in CompiledContract, this can be removed
|
|
38
72
|
|
|
39
|
-
|
|
40
|
-
|
|
73
|
+
The _estimateFeeDetails_ object may include any of:
|
|
74
|
+
|
|
75
|
+
- estimateFeeDetails.**blockIdentifier** - Block Identifier for the transaction
|
|
76
|
+
- estimateFeeDetails.**nonce** - Nonce for the transaction
|
|
41
77
|
|
|
42
78
|
###### _EstimateFeeResponse_
|
|
43
79
|
|
|
@@ -51,14 +87,19 @@ The _options_ object may include any of:
|
|
|
51
87
|
|
|
52
88
|
<hr />
|
|
53
89
|
|
|
54
|
-
account.**
|
|
90
|
+
account.**estimateAccountDeployFee**(contractPayload [ , estimateFeeDetails ]) => _Promise < EstimateFeeResponse >_
|
|
91
|
+
|
|
92
|
+
Estimate Fee for executing a DEPLOY_ACCOUNT transaction on starknet
|
|
55
93
|
|
|
56
|
-
|
|
94
|
+
The _contractPayload_ object structure:
|
|
57
95
|
|
|
58
|
-
The
|
|
96
|
+
- contractPayload.**contract** - The compiled contract to be declared
|
|
97
|
+
- contractPayload.**classHash** - This can be obtained by using starknet-cli. Once the classHash is included in CompiledContract, this can be removed
|
|
59
98
|
|
|
60
|
-
|
|
61
|
-
|
|
99
|
+
The _estimateFeeDetails_ object may include any of:
|
|
100
|
+
|
|
101
|
+
- estimateFeeDetails.**blockIdentifier** - Block Identifier for the transaction
|
|
102
|
+
- estimateFeeDetails.**nonce** - Nonce for the transaction
|
|
62
103
|
|
|
63
104
|
###### _EstimateFeeResponse_
|
|
64
105
|
|
|
@@ -72,17 +113,26 @@ The _options_ object may include any of:
|
|
|
72
113
|
|
|
73
114
|
<hr />
|
|
74
115
|
|
|
75
|
-
account.**execute**(
|
|
116
|
+
account.**execute**(transactions [ , abi , transactionsDetail ]) => _Promise < InvokeFunctionResponse >_
|
|
76
117
|
|
|
77
118
|
Executes one or multiple calls using the account contract.
|
|
78
119
|
|
|
120
|
+
The _transactions_ object structure:
|
|
121
|
+
|
|
122
|
+
- contractPayload.**contractAddress** - the address of the contract
|
|
123
|
+
- contractPayload.**entrypoint** - the entrypoint of the contract
|
|
124
|
+
- contractPayload.**calldata** - (defaults to []) the calldata
|
|
125
|
+
- contractPayload.**signature** - (defaults to []) the signature
|
|
126
|
+
|
|
127
|
+
_abi_ - (optional) the abi of the contract for better displaying
|
|
128
|
+
|
|
79
129
|
The _transactionsDetail_ object may include any of:
|
|
80
130
|
|
|
81
131
|
- transactionsDetail.**maxFee** - Max Fee that that will be used to execute the call(s)
|
|
82
132
|
- transactionsDetail.**nonce** - Nonce for the transaction
|
|
83
133
|
- transactionsDetail.**version** - Version for the transaction (default is 1)
|
|
84
134
|
|
|
85
|
-
######
|
|
135
|
+
###### _InvokeFunctionResponse_
|
|
86
136
|
|
|
87
137
|
```typescript
|
|
88
138
|
{
|
|
@@ -92,12 +142,14 @@ The _transactionsDetail_ object may include any of:
|
|
|
92
142
|
|
|
93
143
|
<hr />
|
|
94
144
|
|
|
95
|
-
account.**declare**(
|
|
145
|
+
account.**declare**(contractPayload [ , transactionsDetail ]) => _Promise < DeclareContractResponse >_
|
|
96
146
|
|
|
97
|
-
|
|
147
|
+
Declares a given compiled contract (json) to starknet.
|
|
98
148
|
|
|
99
|
-
|
|
100
|
-
|
|
149
|
+
The _contractPayload_ object consists of:
|
|
150
|
+
|
|
151
|
+
- contractPayload.**contract** - The compiled contract
|
|
152
|
+
- contractPayload.**classHash** - Hash of the compiled contract
|
|
101
153
|
|
|
102
154
|
The _transactionsDetail_ object may include any of:
|
|
103
155
|
|
|
@@ -105,8 +157,6 @@ The _transactionsDetail_ object may include any of:
|
|
|
105
157
|
- transactionsDetail.**nonce** - Nonce for the transaction
|
|
106
158
|
- transactionsDetail.**version** - Version for the transaction (default is 1)
|
|
107
159
|
|
|
108
|
-
Declares a contract on Starknet.
|
|
109
|
-
|
|
110
160
|
> _Note:_ Once the classHash is included in CompiledContract, this parameter can be removed. Currently it can be pre-computed from starknet-cli.
|
|
111
161
|
|
|
112
162
|
Example:
|
|
@@ -128,11 +178,43 @@ const declareTx = await account.declare({
|
|
|
128
178
|
};
|
|
129
179
|
```
|
|
130
180
|
|
|
181
|
+
<hr />
|
|
182
|
+
|
|
183
|
+
account.**deployAccount**(contractPayload [ , transactionsDetail ]) => _Promise < DeployContractResponse >_
|
|
184
|
+
|
|
185
|
+
Declares a given compiled contract (json) to starknet.
|
|
186
|
+
|
|
187
|
+
The _contractPayload_ object consists of:
|
|
188
|
+
|
|
189
|
+
- contractPayload.**classHash** - Hash of the compiled contract
|
|
190
|
+
- contractPayload.**constructorCalldata** - optional
|
|
191
|
+
- contractPayload.**addressSalt** - optional
|
|
192
|
+
- contractPayload.**contractAddress** - optional
|
|
193
|
+
|
|
194
|
+
The _transactionsDetail_ object may include any of:
|
|
195
|
+
|
|
196
|
+
- transactionsDetail.**maxFee** - Max Fee that that will be used to execute the call(s)
|
|
197
|
+
- transactionsDetail.**nonce** - Nonce for the transaction
|
|
198
|
+
- transactionsDetail.**version** - Version for the transaction (default is 1)
|
|
199
|
+
|
|
200
|
+
> _Note:_ Once the classHash is included in CompiledContract, this parameter can be removed. Currently it can be pre-computed from starknet-cli.
|
|
201
|
+
|
|
202
|
+
###### _DeployContractResponse_
|
|
203
|
+
|
|
204
|
+
```typescript
|
|
205
|
+
{
|
|
206
|
+
contract_address: string;
|
|
207
|
+
transaction_hash: string;
|
|
208
|
+
};
|
|
209
|
+
```
|
|
210
|
+
|
|
131
211
|
<hr/>
|
|
132
212
|
|
|
133
213
|
account.**signMessage**(typedData) => _Promise < Signature >_
|
|
134
214
|
|
|
135
|
-
|
|
215
|
+
Sign an JSON object for off-chain usage with the starknet private key and return the signature. This adds a message prefix so it cant be interchanged with transactions.
|
|
216
|
+
|
|
217
|
+
_typedData_ - JSON object to be signed
|
|
136
218
|
|
|
137
219
|
###### _Signature_
|
|
138
220
|
|
|
@@ -144,7 +226,11 @@ string[];
|
|
|
144
226
|
|
|
145
227
|
account.**hashMessage**(typedData) => _Promise < string >_
|
|
146
228
|
|
|
147
|
-
|
|
229
|
+
Hash a JSON object with pederson hash and return the hash. This adds a message prefix so it cant be interchanged with transactions.
|
|
230
|
+
|
|
231
|
+
_typedData_ - JSON object to be signed
|
|
232
|
+
|
|
233
|
+
Returns the hash of the JSON object.
|
|
148
234
|
|
|
149
235
|
<hr />
|
|
150
236
|
|
|
@@ -162,4 +248,18 @@ account.**verifyMessage**(typedData, signature) => _Promise < boolean >_
|
|
|
162
248
|
|
|
163
249
|
Verify a signature of a JSON object.
|
|
164
250
|
|
|
251
|
+
_typedData_ - JSON object to be verified
|
|
252
|
+
_signature_ - signature of the JSON object
|
|
253
|
+
|
|
254
|
+
Returns true if the signature is valid, false otherwise
|
|
255
|
+
|
|
165
256
|
<hr />
|
|
257
|
+
|
|
258
|
+
account.**getSuggestedMaxFee**(estimateFeeAction, details) => _Promise < BigNumberish >_
|
|
259
|
+
|
|
260
|
+
Gets Suggested Max Fee based on the transaction type.
|
|
261
|
+
|
|
262
|
+
The _details_ object may include any of:
|
|
263
|
+
|
|
264
|
+
- details.**blockIdentifier**
|
|
265
|
+
- details.**nonce**
|
package/www/docs/API/contract.md
CHANGED
|
@@ -18,6 +18,10 @@ Contracts allow you to transform Cairo values, like `Uint256` to `BigNumber`. It
|
|
|
18
18
|
|
|
19
19
|
## Properties
|
|
20
20
|
|
|
21
|
+
contract.**abi** => _Abi_
|
|
22
|
+
|
|
23
|
+
The ABI the contract was constructed with.
|
|
24
|
+
|
|
21
25
|
contract.**address** => _string_
|
|
22
26
|
|
|
23
27
|
The address the contract was constructed/connected with.
|
|
@@ -30,16 +34,48 @@ contract.**deployTransactionHash** => _string | null_
|
|
|
30
34
|
|
|
31
35
|
If the Contract object is the result of a ContractFactory deployment, this is the transaction which was used to deploy the contract.
|
|
32
36
|
|
|
33
|
-
|
|
37
|
+
## Methods
|
|
34
38
|
|
|
35
|
-
|
|
39
|
+
contract.**attach**(address) => void
|
|
36
40
|
|
|
37
|
-
|
|
41
|
+
Saves the address of the contract deployed on network that will be used for interaction.
|
|
42
|
+
|
|
43
|
+
_address_ - address of the contract.
|
|
44
|
+
|
|
45
|
+
<br></br>
|
|
46
|
+
|
|
47
|
+
contract.**connect**(providerOrAccount) => void
|
|
48
|
+
|
|
49
|
+
Attaches to new Provider or Account
|
|
50
|
+
|
|
51
|
+
<br></br>
|
|
38
52
|
|
|
39
53
|
contract.**deployed**() => _Promise < Contract >_
|
|
40
54
|
|
|
41
55
|
If the Contract object is the result of a ContractFactory deployment, this method will wait for the transaction to be resolved.
|
|
42
56
|
|
|
57
|
+
<br></br>
|
|
58
|
+
|
|
59
|
+
contract.**call**(method, args, options) => _Promise < Result >_
|
|
60
|
+
|
|
61
|
+
Calls a method on a contract.
|
|
62
|
+
|
|
63
|
+
<br></br>
|
|
64
|
+
|
|
65
|
+
contract.**invoke**(method, args, options) => _Promise < InvokeFunctionResponse >_
|
|
66
|
+
|
|
67
|
+
Invokes a method on a contract.
|
|
68
|
+
|
|
69
|
+
<br></br>
|
|
70
|
+
|
|
71
|
+
contract.**estimate**(method, args, options) => _Promise < any >_
|
|
72
|
+
|
|
73
|
+
Estimates a method on a contract.
|
|
74
|
+
|
|
75
|
+
<br></br>
|
|
76
|
+
|
|
77
|
+
contract.**populate**(method, args, options) => _Invocation_
|
|
78
|
+
|
|
43
79
|
## Meta-Class
|
|
44
80
|
|
|
45
81
|
A Meta-Class is a Class which has any of its properties determined at run-time. The Contract object uses a Contract's ABI to determine what methods are available, so the following sections describe the generic ways to interact with the properties added at run-time during the Contract constructor.
|
package/www/docs/API/provider.md
CHANGED
|
@@ -259,10 +259,12 @@ The options for the provider depend on the network. The structure of the options
|
|
|
259
259
|
- options.**baseUrl** - Base URL of the network
|
|
260
260
|
- options.**feederGatewayUrl** - Feeder Gateway Endpoint of the network
|
|
261
261
|
- options.**gatewayUrl** - Gateway Endpoint
|
|
262
|
+
- options.**headers** - [Optional] custom fetch headers
|
|
262
263
|
|
|
263
264
|
or
|
|
264
265
|
|
|
265
266
|
- options.**network** - Either 'mainnet-alpha' or 'goerli-alpha'
|
|
267
|
+
- options.**headers** - [Optional] custom fetch headers
|
|
266
268
|
|
|
267
269
|
Example:
|
|
268
270
|
|
|
@@ -396,6 +398,8 @@ Gets the transaction trace from a tx hash.
|
|
|
396
398
|
`new starknet.RpcProvider(options)`
|
|
397
399
|
|
|
398
400
|
- options.**nodeUrl** - Starknet RPC node url
|
|
401
|
+
- options.**headers** - [Optional] custom fetch headers
|
|
402
|
+
- options.**retries** - [Optional] wait for transaction max retries
|
|
399
403
|
|
|
400
404
|
Example:
|
|
401
405
|
|
package/www/docs/API/signer.md
CHANGED
|
@@ -20,7 +20,15 @@ Returns the public key of the signer.
|
|
|
20
20
|
|
|
21
21
|
signer.**signTransaction**(transactions, transactionsDetail [ , abi ]) => _Promise < Signature >_
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
Signs a transaction with the starknet private key and returns the signature.
|
|
24
|
+
|
|
25
|
+
The _transactions_ object for write methods may include any of:
|
|
26
|
+
|
|
27
|
+
- transactions.**contractAddress** - the address of the contract
|
|
28
|
+
- transactions.**entrypoint** - the entrypoint of the contract
|
|
29
|
+
- transactions.**calldata** - (defaults to []) the calldata
|
|
30
|
+
|
|
31
|
+
_abi_ - (optional) the abi of the contract for better displaying
|
|
24
32
|
|
|
25
33
|
###### _Signature_
|
|
26
34
|
|
|
@@ -32,7 +40,53 @@ string[]
|
|
|
32
40
|
|
|
33
41
|
signer.**signMessage**(typedData, accountAddress) => _Promise < Signature >_
|
|
34
42
|
|
|
35
|
-
|
|
43
|
+
Sign an JSON object for off-chain usage with the starknet private key and return the signature. This adds a message prefix so it cant be interchanged with transactions.
|
|
44
|
+
|
|
45
|
+
_typedData_ - JSON object to be signed
|
|
46
|
+
_accountAddress_ - calldata to be passed in deploy constructor
|
|
47
|
+
|
|
48
|
+
###### _Signature_
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
string[]
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
<hr />
|
|
55
|
+
|
|
56
|
+
signer.**signDeployAccountTransaction**(transaction) => _Promise < Signature >_
|
|
57
|
+
|
|
58
|
+
Signs a DEPLOY_ACCOUNT transaction with the starknet private key and returns the signature.
|
|
59
|
+
|
|
60
|
+
The _transactions_ object for write methods may include any of:
|
|
61
|
+
|
|
62
|
+
- transactions.**contractAddress** - the address of the contract
|
|
63
|
+
- transactions.**constructorCalldata** - calldata to be passed in deploy constructor
|
|
64
|
+
- transactions.**addressSalt** - contract address salt
|
|
65
|
+
- transactions.**chainId** - the chainId to declare contract on
|
|
66
|
+
- transactions.**maxFee** - maxFee for the declare transaction
|
|
67
|
+
- transactions.**version** - transaction version
|
|
68
|
+
- transactions.**nonce** - Nonce of the declare transaction
|
|
69
|
+
|
|
70
|
+
###### _Signature_
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
string[]
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
<hr />
|
|
77
|
+
|
|
78
|
+
signer.**signDeclareTransaction**(transaction, transactionsDetail [ , abi ]) => _Promise < Signature >_
|
|
79
|
+
|
|
80
|
+
Signs a DECLARE transaction with the starknet private key and returns the signature.
|
|
81
|
+
|
|
82
|
+
The _transaction_ object for write methods may include any of:
|
|
83
|
+
|
|
84
|
+
- transactions.**classHash** - computed class hash. Will be replaced by ContractClass in future once class hash is present in CompiledContract
|
|
85
|
+
- transactions.**senderAddress** - the address of the sender
|
|
86
|
+
- transactions.**chainId** - the chainId to declare contract on
|
|
87
|
+
- transactions.**maxFee** - maxFee for the declare transaction
|
|
88
|
+
- transactions.**version** - transaction version
|
|
89
|
+
- transactions.**nonce** - Nonce of the declare transaction
|
|
36
90
|
|
|
37
91
|
###### _Signature_
|
|
38
92
|
|