starknet 4.6.0 → 4.8.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 +44 -0
- package/CONTRIBUTING.md +2 -2
- package/__mocks__/l1l2_compiled.json +10107 -0
- package/__tests__/account.test.ts +2 -5
- package/__tests__/contract.test.ts +0 -1
- package/__tests__/defaultProvider.test.ts +5 -3
- package/__tests__/fixtures.ts +2 -0
- package/__tests__/sequencerProvider.test.ts +50 -9
- package/__tests__/utils/ellipticalCurve.test.ts +7 -8
- package/__tests__/utils/merkle.test.ts +15 -0
- package/account/default.d.ts +3 -2
- package/account/default.js +22 -29
- package/account/interface.d.ts +2 -1
- package/contract/contractFactory.d.ts +1 -2
- package/contract/default.d.ts +2 -2
- package/contract/default.js +7 -3
- package/dist/account/default.d.ts +3 -2
- package/dist/account/default.js +22 -29
- package/dist/account/interface.d.ts +2 -1
- package/dist/contract/contractFactory.d.ts +1 -2
- package/dist/contract/default.d.ts +2 -2
- package/dist/contract/default.js +7 -3
- package/dist/provider/default.d.ts +4 -3
- package/dist/provider/default.js +9 -3
- package/dist/provider/interface.d.ts +10 -3
- package/dist/provider/rpc.d.ts +12 -10
- package/dist/provider/rpc.js +80 -72
- package/dist/provider/sequencer.d.ts +6 -4
- package/dist/provider/sequencer.js +36 -7
- package/dist/signer/default.d.ts +2 -2
- package/dist/signer/default.js +2 -2
- package/dist/signer/interface.d.ts +2 -2
- package/dist/types/api/openrpc.d.ts +17 -27
- package/dist/types/api/rpc.d.ts +4 -128
- package/dist/types/api/sequencer.d.ts +36 -20
- package/dist/types/lib.d.ts +10 -4
- package/dist/types/provider.d.ts +7 -2
- package/dist/utils/hash.d.ts +8 -2
- package/dist/utils/hash.js +20 -5
- package/dist/utils/merkle.js +2 -1
- package/dist/utils/number.d.ts +5 -0
- package/dist/utils/number.js +29 -1
- package/dist/utils/responseParser/rpc.d.ts +2 -5
- package/dist/utils/responseParser/rpc.js +2 -38
- package/dist/utils/responseParser/sequencer.js +7 -19
- package/package.json +1 -1
- package/provider/default.d.ts +4 -3
- package/provider/default.js +9 -3
- package/provider/interface.d.ts +10 -3
- package/provider/rpc.d.ts +12 -10
- package/provider/rpc.js +80 -72
- package/provider/sequencer.d.ts +6 -4
- package/provider/sequencer.js +36 -7
- package/signer/default.d.ts +2 -2
- package/signer/default.js +2 -2
- package/signer/interface.d.ts +2 -2
- package/src/account/default.ts +21 -20
- package/src/account/interface.ts +2 -1
- package/src/contract/contractFactory.ts +1 -2
- package/src/contract/default.ts +16 -8
- package/src/provider/default.ts +12 -5
- package/src/provider/interface.ts +15 -4
- package/src/provider/rpc.ts +89 -73
- package/src/provider/sequencer.ts +47 -11
- package/src/signer/default.ts +8 -8
- package/src/signer/interface.ts +2 -2
- package/src/types/api/openrpc.ts +20 -25
- package/src/types/api/rpc.ts +4 -128
- package/src/types/api/sequencer.ts +39 -20
- package/src/types/lib.ts +7 -5
- package/src/types/provider.ts +7 -2
- package/src/utils/hash.ts +32 -8
- package/src/utils/merkle.ts +2 -1
- package/src/utils/number.ts +27 -0
- package/src/utils/responseParser/rpc.ts +7 -25
- package/src/utils/responseParser/sequencer.ts +12 -7
- package/types/api/openrpc.d.ts +17 -27
- package/types/api/rpc.d.ts +4 -128
- package/types/api/sequencer.d.ts +36 -20
- package/types/lib.d.ts +10 -4
- package/types/provider.d.ts +7 -2
- package/utils/hash.d.ts +8 -2
- package/utils/hash.js +20 -5
- package/utils/merkle.js +2 -1
- package/utils/number.d.ts +5 -0
- package/utils/number.js +29 -1
- package/utils/responseParser/rpc.d.ts +2 -5
- package/utils/responseParser/rpc.js +2 -38
- package/utils/responseParser/sequencer.js +7 -19
- package/www/docs/API/account.md +3 -3
- package/www/docs/API/contract.md +2 -2
- package/www/docs/API/provider.md +20 -6
- package/www/docs/API/utils.md +2 -2
- package/www/guides/account.md +1 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Map RPC Response to common interface response
|
|
3
3
|
* Intersection (sequencer response ∩ (∪ rpc responses))
|
|
4
4
|
*/
|
|
5
|
-
import { CallContractResponse,
|
|
5
|
+
import { CallContractResponse, EstimateFeeResponse, GetBlockResponse, GetTransactionReceiptResponse, GetTransactionResponse } from '../../types';
|
|
6
6
|
import { RPC } from '../../types/api';
|
|
7
7
|
import { ResponseParser } from '.';
|
|
8
8
|
declare type RpcGetBlockResponse = RPC.GetBlockWithTxHashesResponse & {
|
|
@@ -14,14 +14,11 @@ declare type GetTransactionByHashResponse = RPC.GetTransactionByHashResponse & {
|
|
|
14
14
|
declare type TransactionReceipt = RPC.TransactionReceipt & {
|
|
15
15
|
[key: string]: any;
|
|
16
16
|
};
|
|
17
|
-
export declare class RPCResponseParser
|
|
17
|
+
export declare class RPCResponseParser implements Omit<ResponseParser, 'parseDeclareContractResponse' | 'parseDeployContractResponse' | 'parseInvokeFunctionResponse'> {
|
|
18
18
|
parseGetBlockResponse(res: RpcGetBlockResponse): GetBlockResponse;
|
|
19
19
|
parseGetTransactionResponse(res: GetTransactionByHashResponse): GetTransactionResponse;
|
|
20
20
|
parseGetTransactionReceiptResponse(res: TransactionReceipt): GetTransactionReceiptResponse;
|
|
21
21
|
parseFeeEstimateResponse(res: RPC.EstimateFeeResponse): EstimateFeeResponse;
|
|
22
22
|
parseCallContractResponse(res: Array<string>): CallContractResponse;
|
|
23
|
-
parseInvokeFunctionResponse(res: RPC.InvokedTransaction): InvokeFunctionResponse;
|
|
24
|
-
parseDeployContractResponse(res: RPC.DeployedTransaction): DeployContractResponse;
|
|
25
|
-
parseDeclareContractResponse(res: RPC.DeclaredTransaction): DeclareContractResponse;
|
|
26
23
|
}
|
|
27
24
|
export {};
|
|
@@ -1,27 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
3
|
exports.RPCResponseParser = void 0;
|
|
19
4
|
var number_1 = require("../number");
|
|
20
|
-
var
|
|
21
|
-
var RPCResponseParser = /** @class */ (function (_super) {
|
|
22
|
-
__extends(RPCResponseParser, _super);
|
|
5
|
+
var RPCResponseParser = /** @class */ (function () {
|
|
23
6
|
function RPCResponseParser() {
|
|
24
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
25
7
|
}
|
|
26
8
|
RPCResponseParser.prototype.parseGetBlockResponse = function (res) {
|
|
27
9
|
return {
|
|
@@ -38,7 +20,6 @@ var RPCResponseParser = /** @class */ (function (_super) {
|
|
|
38
20
|
return {
|
|
39
21
|
calldata: res.calldata || [],
|
|
40
22
|
contract_address: res.contract_address,
|
|
41
|
-
entry_point_selector: res.entry_point_selector,
|
|
42
23
|
max_fee: res.max_fee,
|
|
43
24
|
nonce: res.nonce,
|
|
44
25
|
signature: res.signature || [],
|
|
@@ -69,23 +50,6 @@ var RPCResponseParser = /** @class */ (function (_super) {
|
|
|
69
50
|
result: res,
|
|
70
51
|
};
|
|
71
52
|
};
|
|
72
|
-
RPCResponseParser.prototype.parseInvokeFunctionResponse = function (res) {
|
|
73
|
-
return {
|
|
74
|
-
transaction_hash: res.transaction_hash,
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
RPCResponseParser.prototype.parseDeployContractResponse = function (res) {
|
|
78
|
-
return {
|
|
79
|
-
transaction_hash: res.transaction_hash,
|
|
80
|
-
contract_address: res.contract_address,
|
|
81
|
-
};
|
|
82
|
-
};
|
|
83
|
-
RPCResponseParser.prototype.parseDeclareContractResponse = function (res) {
|
|
84
|
-
return {
|
|
85
|
-
transaction_hash: res.transaction_hash,
|
|
86
|
-
class_hash: res.class_hash,
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
53
|
return RPCResponseParser;
|
|
90
|
-
}(
|
|
54
|
+
}());
|
|
91
55
|
exports.RPCResponseParser = RPCResponseParser;
|
|
@@ -35,17 +35,9 @@ var SequencerAPIResponseParser = /** @class */ (function (_super) {
|
|
|
35
35
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
36
36
|
}
|
|
37
37
|
SequencerAPIResponseParser.prototype.parseGetBlockResponse = function (res) {
|
|
38
|
-
return {
|
|
39
|
-
timestamp: res.timestamp,
|
|
40
|
-
block_hash: res.block_hash,
|
|
41
|
-
block_number: res.block_number,
|
|
42
|
-
new_root: res.state_root,
|
|
43
|
-
parent_hash: res.parent_block_hash,
|
|
44
|
-
status: res.status,
|
|
45
|
-
transactions: Object.values(res.transactions)
|
|
38
|
+
return __assign(__assign({}, res), { new_root: res.state_root, parent_hash: res.parent_block_hash, transactions: Object.values(res.transactions)
|
|
46
39
|
.map(function (value) { return 'transaction_hash' in value && value.transaction_hash; })
|
|
47
|
-
.filter(Boolean)
|
|
48
|
-
};
|
|
40
|
+
.filter(Boolean) });
|
|
49
41
|
};
|
|
50
42
|
SequencerAPIResponseParser.prototype.parseGetTransactionResponse = function (res) {
|
|
51
43
|
return {
|
|
@@ -66,15 +58,11 @@ var SequencerAPIResponseParser = /** @class */ (function (_super) {
|
|
|
66
58
|
};
|
|
67
59
|
};
|
|
68
60
|
SequencerAPIResponseParser.prototype.parseGetTransactionReceiptResponse = function (res) {
|
|
69
|
-
return {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
messages_sent: res.l2_to_l1_messages,
|
|
75
|
-
events: res.events,
|
|
76
|
-
l1_origin_message: undefined,
|
|
77
|
-
};
|
|
61
|
+
return __assign(__assign(__assign(__assign(__assign(__assign(__assign({ transaction_hash: res.transaction_hash, status: res.status, messages_sent: res.l2_to_l1_messages, events: res.events }, ('block_hash' in res && { block_hash: res.block_hash })), ('block_number' in res && { block_number: res.block_number })), ('actual_fee' in res && { actual_fee: res.actual_fee })), ('transaction_index' in res && { transaction_index: res.transaction_index })), ('execution_resources' in res && { execution_resources: res.execution_resources })), ('l1_to_l2_consumed_message' in res && {
|
|
62
|
+
l1_to_l2_consumed_message: res['l1_to_l2_consumed_message'],
|
|
63
|
+
})), ('transaction_failure_reason' in res && {
|
|
64
|
+
transaction_failure_reason: res.transaction_failure_reason,
|
|
65
|
+
}));
|
|
78
66
|
};
|
|
79
67
|
SequencerAPIResponseParser.prototype.parseFeeEstimateResponse = function (res) {
|
|
80
68
|
if ('overall_fee' in res) {
|
package/www/docs/API/account.md
CHANGED
|
@@ -24,9 +24,9 @@ The address of the account contract.
|
|
|
24
24
|
|
|
25
25
|
## Methods
|
|
26
26
|
|
|
27
|
-
account.**getNonce()** => _Promise <
|
|
27
|
+
account.**getNonce()** => _Promise < BigNumberish >_
|
|
28
28
|
|
|
29
|
-
Gets the new Nonce for the next transaction.
|
|
29
|
+
Gets the new Nonce of the connected account for the next transaction.
|
|
30
30
|
|
|
31
31
|
<hr />
|
|
32
32
|
|
|
@@ -59,7 +59,7 @@ The _transactionsDetail_ object may include any of:
|
|
|
59
59
|
|
|
60
60
|
- transactionsDetail.**maxFee** - Max Fee that that will be used to execute the call(s)
|
|
61
61
|
- transactionsDetail.**nonce** - Nonce for the transaction
|
|
62
|
-
- transactionsDetail.**version** - Version for the transaction (default is
|
|
62
|
+
- transactionsDetail.**version** - Version for the transaction (default is 1)
|
|
63
63
|
|
|
64
64
|
###### _AddTransactionResponse_
|
|
65
65
|
|
package/www/docs/API/contract.md
CHANGED
|
@@ -78,8 +78,8 @@ contract.estimateGas.**METHOD_NAME**( ...args ) => _Promise < EstimateFeeRespons
|
|
|
78
78
|
|
|
79
79
|
Returns the estimate units of gas that would be required to execute the METHOD_NAME with args and overrides.
|
|
80
80
|
|
|
81
|
-
contract.populateTransaction.**METHOD_NAME**( ...args [ , overrides ] ) ⇒
|
|
81
|
+
contract.populateTransaction.**METHOD_NAME**( ...args [ , overrides ] ) ⇒ _Call_
|
|
82
82
|
|
|
83
|
-
Returns an
|
|
83
|
+
Returns an _Call_ object which represents the transaction that would need to be signed and submitted to the network to execute METHOD_NAME with args and overrides.
|
|
84
84
|
|
|
85
85
|
The overrides are identical to the overrides above for write methods.
|
package/www/docs/API/provider.md
CHANGED
|
@@ -271,21 +271,29 @@ Gets the transaction trace from a tx hash.
|
|
|
271
271
|
|
|
272
272
|
```typescript
|
|
273
273
|
{
|
|
274
|
-
|
|
274
|
+
validate_invocation?: FunctionInvocation;
|
|
275
|
+
function_invocation?: FunctionInvocation;
|
|
276
|
+
fee_transfer_invocation?: FunctionInvocation;
|
|
277
|
+
signature: Signature;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
{
|
|
281
|
+
FunctionInvocation: {
|
|
275
282
|
caller_address: string;
|
|
276
283
|
contract_address: string;
|
|
277
|
-
code_address: string;
|
|
278
|
-
selector: string;
|
|
279
284
|
calldata: {
|
|
280
285
|
[inputName: string]: string | string[] | { type: 'struct'; [k: string]: BigNumberish };
|
|
281
286
|
};
|
|
287
|
+
call_type?: string;
|
|
288
|
+
class_hash?: string;
|
|
289
|
+
selector?: string;
|
|
290
|
+
entry_point_type?: EntryPointType;
|
|
282
291
|
result: Array<any>;
|
|
283
|
-
execution_resources:
|
|
284
|
-
|
|
292
|
+
execution_resources: ExecutionResources;
|
|
293
|
+
internal_calls: Array<FunctionInvocation>;
|
|
285
294
|
events: Array<any>;
|
|
286
295
|
messages: Array<any>;
|
|
287
296
|
};
|
|
288
|
-
signature: Signature;
|
|
289
297
|
}
|
|
290
298
|
```
|
|
291
299
|
|
|
@@ -319,6 +327,12 @@ Gets the latest block number.
|
|
|
319
327
|
|
|
320
328
|
<hr/>
|
|
321
329
|
|
|
330
|
+
provider.**getNonce**(contractAddress, blockIdentifier) => _Promise < BigNumberish >_
|
|
331
|
+
|
|
332
|
+
Gets the nonce of the provided contractAddress
|
|
333
|
+
|
|
334
|
+
<hr/>
|
|
335
|
+
|
|
322
336
|
provider.**getSyncingStats**() => _Promise < GetSyncingStatsResponse >_
|
|
323
337
|
|
|
324
338
|
Gets syncing status of the node.
|
package/www/docs/API/utils.md
CHANGED
|
@@ -268,9 +268,9 @@ Function that calculates the deployment transaction hash in the StarkNet network
|
|
|
268
268
|
|
|
269
269
|
Internally calls `calculateTransactionHashCommon` with `TransactionHashPrefix.DEPLOY`.
|
|
270
270
|
|
|
271
|
-
###
|
|
271
|
+
### calculateTransactionHash
|
|
272
272
|
|
|
273
|
-
`
|
|
273
|
+
`calculateTransactionHash(contractAddress: BigNumberish, version: BigNumberish, entryPointSelector: BigNumberish, calldata: BigNumberish[], maxFee: BigNumberish, chainId: StarknetChainId, nonce: BigNumberish): string`
|
|
274
274
|
|
|
275
275
|
Function that internally calls `calculateTransactionHashCommon`, with `TransactionHashPrefix.INVOKE`.
|
|
276
276
|
|
package/www/guides/account.md
CHANGED
|
@@ -45,7 +45,7 @@ const compiledAccount = json.parse(
|
|
|
45
45
|
|
|
46
46
|
> **Note**
|
|
47
47
|
>
|
|
48
|
-
> below example uses [Argent's](https://github.com/argentlabs/argent-contracts-starknet/blob/develop/contracts/ArgentAccount.cairo) account contract
|
|
48
|
+
> below example uses [Argent's](https://github.com/argentlabs/argent-contracts-starknet/blob/develop/contracts/account/ArgentAccount.cairo) account contract
|
|
49
49
|
|
|
50
50
|
```javascript
|
|
51
51
|
const accountResponse = await defaultProvider.deployContract({
|