starknet 6.9.0 → 6.10.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 +12 -0
- package/LICENSE +1 -1
- package/README.md +5 -9
- package/dist/account/default.cjs +655 -0
- package/dist/account/default.d.ts +67 -0
- package/dist/account/default.mjs +652 -0
- package/dist/account/index.cjs +27 -0
- package/dist/account/index.d.ts +2 -0
- package/dist/account/index.mjs +2 -0
- package/dist/account/interface.cjs +9 -0
- package/dist/account/interface.d.ts +301 -0
- package/dist/account/interface.mjs +3 -0
- package/dist/channel/index.cjs +27 -0
- package/dist/channel/index.d.ts +3 -0
- package/dist/channel/index.mjs +3 -0
- package/dist/channel/rpc_0_6.cjs +607 -0
- package/dist/channel/rpc_0_6.d.ts +78 -0
- package/dist/channel/rpc_0_6.mjs +543 -0
- package/dist/channel/rpc_0_7.cjs +619 -0
- package/dist/channel/rpc_0_7.d.ts +81 -0
- package/dist/channel/rpc_0_7.mjs +561 -0
- package/dist/constants.cjs +76 -0
- package/dist/constants.d.ts +70 -0
- package/dist/constants.mjs +60 -0
- package/dist/contract/contractFactory.cjs +93 -0
- package/dist/contract/contractFactory.d.ts +46 -0
- package/dist/contract/contractFactory.mjs +83 -0
- package/dist/contract/default.cjs +269 -0
- package/dist/contract/default.d.ts +58 -0
- package/dist/contract/default.mjs +254 -0
- package/dist/contract/index.cjs +38 -0
- package/dist/contract/index.d.ts +3 -0
- package/dist/contract/index.mjs +3 -0
- package/dist/contract/interface.cjs +13 -0
- package/dist/contract/interface.d.ts +128 -0
- package/dist/contract/interface.mjs +6 -0
- package/dist/index.cjs +267 -0
- package/dist/index.d.ts +45 -5991
- package/dist/index.global.js +728 -609
- package/dist/index.global.js.map +1 -1
- package/dist/index.mjs +39 -7320
- package/dist/provider/errors.cjs +50 -0
- package/dist/provider/errors.d.ts +16 -0
- package/dist/provider/errors.mjs +35 -0
- package/dist/provider/extensions/default.cjs +11 -0
- package/dist/provider/extensions/default.d.ts +6 -0
- package/dist/provider/extensions/default.mjs +5 -0
- package/dist/provider/extensions/starknetId.cjs +174 -0
- package/dist/provider/extensions/starknetId.d.ts +10 -0
- package/dist/provider/extensions/starknetId.mjs +230 -0
- package/dist/provider/index.cjs +56 -0
- package/dist/provider/index.d.ts +6 -0
- package/dist/provider/index.mjs +6 -0
- package/dist/provider/interface.cjs +8 -0
- package/dist/provider/interface.d.ts +261 -0
- package/dist/provider/interface.mjs +2 -0
- package/dist/provider/rpc.cjs +301 -0
- package/dist/provider/rpc.d.ts +115 -0
- package/dist/provider/rpc.mjs +302 -0
- package/dist/service/types.cjs +1 -0
- package/dist/service/types.d.ts +5 -0
- package/dist/service/types.mjs +0 -0
- package/dist/signer/default.cjs +105 -0
- package/dist/signer/default.d.ts +12 -0
- package/dist/signer/default.mjs +102 -0
- package/dist/signer/ethSigner.cjs +123 -0
- package/dist/signer/ethSigner.d.ts +25 -0
- package/dist/signer/ethSigner.mjs +140 -0
- package/dist/signer/index.cjs +38 -0
- package/dist/signer/index.d.ts +3 -0
- package/dist/signer/index.mjs +3 -0
- package/dist/signer/interface.cjs +8 -0
- package/dist/signer/interface.d.ts +115 -0
- package/dist/signer/interface.mjs +2 -0
- package/dist/types/account.cjs +1 -0
- package/dist/types/account.d.ts +79 -0
- package/dist/types/account.mjs +0 -0
- package/dist/types/api/index.cjs +30 -0
- package/dist/types/api/index.d.ts +4 -0
- package/dist/types/api/index.mjs +4 -0
- package/dist/types/api/jsonrpc/index.cjs +1 -0
- package/dist/types/api/jsonrpc/index.d.ts +21 -0
- package/dist/types/api/jsonrpc/index.mjs +0 -0
- package/dist/types/api/rpcspec_0_6/components.cjs +1 -0
- package/dist/types/api/rpcspec_0_6/components.d.ts +541 -0
- package/dist/types/api/rpcspec_0_6/components.mjs +0 -0
- package/dist/types/api/rpcspec_0_6/contract.cjs +1 -0
- package/dist/types/api/rpcspec_0_6/contract.d.ts +85 -0
- package/dist/types/api/rpcspec_0_6/contract.mjs +0 -0
- package/dist/types/api/rpcspec_0_6/errors.cjs +1 -0
- package/dist/types/api/rpcspec_0_6/errors.d.ts +128 -0
- package/dist/types/api/rpcspec_0_6/errors.mjs +0 -0
- package/dist/types/api/rpcspec_0_6/index.cjs +45 -0
- package/dist/types/api/rpcspec_0_6/index.d.ts +8 -0
- package/dist/types/api/rpcspec_0_6/index.mjs +5 -0
- package/dist/types/api/rpcspec_0_6/methods.cjs +1 -0
- package/dist/types/api/rpcspec_0_6/methods.d.ts +207 -0
- package/dist/types/api/rpcspec_0_6/methods.mjs +0 -0
- package/dist/types/api/rpcspec_0_6/nonspec.cjs +65 -0
- package/dist/types/api/rpcspec_0_6/nonspec.d.ts +147 -0
- package/dist/types/api/rpcspec_0_6/nonspec.mjs +59 -0
- package/dist/types/cairoEnum.cjs +1 -0
- package/dist/types/cairoEnum.d.ts +2 -0
- package/dist/types/cairoEnum.mjs +0 -0
- package/dist/types/calldata.cjs +27 -0
- package/dist/types/calldata.d.ts +23 -0
- package/dist/types/calldata.mjs +21 -0
- package/dist/types/contract.cjs +1 -0
- package/dist/types/contract.d.ts +27 -0
- package/dist/types/contract.mjs +0 -0
- package/dist/types/helpers/valuesType.cjs +1 -0
- package/dist/types/helpers/valuesType.d.ts +1 -0
- package/dist/types/helpers/valuesType.mjs +0 -0
- package/dist/types/index.cjs +121 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/index.mjs +10 -0
- package/dist/types/lib/contract/abi.cjs +1 -0
- package/dist/types/lib/contract/abi.d.ts +71 -0
- package/dist/types/lib/contract/abi.mjs +0 -0
- package/dist/types/lib/contract/index.cjs +50 -0
- package/dist/types/lib/contract/index.d.ts +26 -0
- package/dist/types/lib/contract/index.mjs +8 -0
- package/dist/types/lib/contract/legacy.cjs +1 -0
- package/dist/types/lib/contract/legacy.d.ts +33 -0
- package/dist/types/lib/contract/legacy.mjs +0 -0
- package/dist/types/lib/contract/sierra.cjs +1 -0
- package/dist/types/lib/contract/sierra.d.ts +52 -0
- package/dist/types/lib/contract/sierra.mjs +0 -0
- package/dist/types/lib/index.cjs +61 -0
- package/dist/types/lib/index.d.ts +259 -0
- package/dist/types/lib/index.mjs +36 -0
- package/dist/types/provider/configuration.cjs +1 -0
- package/dist/types/provider/configuration.d.ts +20 -0
- package/dist/types/provider/configuration.mjs +0 -0
- package/dist/types/provider/index.cjs +27 -0
- package/dist/types/provider/index.d.ts +2 -0
- package/dist/types/provider/index.mjs +2 -0
- package/dist/types/provider/response.cjs +30 -0
- package/dist/types/provider/response.d.ts +98 -0
- package/dist/types/provider/response.mjs +1 -0
- package/dist/types/provider/spec.cjs +1 -0
- package/dist/types/provider/spec.d.ts +49 -0
- package/dist/types/provider/spec.mjs +0 -0
- package/dist/types/signer.cjs +1 -0
- package/dist/types/signer.d.ts +49 -0
- package/dist/types/signer.mjs +0 -0
- package/dist/types/transactionReceipt.cjs +1 -0
- package/dist/types/transactionReceipt.d.ts +23 -0
- package/dist/types/transactionReceipt.mjs +0 -0
- package/dist/types/typedData.cjs +12 -0
- package/dist/types/typedData.d.ts +1 -0
- package/dist/types/typedData.mjs +3 -0
- package/dist/utils/address.cjs +44 -0
- package/dist/utils/address.d.ts +55 -0
- package/dist/utils/address.mjs +35 -0
- package/dist/utils/assert.cjs +11 -0
- package/dist/utils/assert.d.ts +12 -0
- package/dist/utils/assert.mjs +5 -0
- package/dist/utils/cairoDataTypes/felt.cjs +31 -0
- package/dist/utils/cairoDataTypes/felt.d.ts +6 -0
- package/dist/utils/cairoDataTypes/felt.mjs +27 -0
- package/dist/utils/cairoDataTypes/uint256.cjs +113 -0
- package/dist/utils/cairoDataTypes/uint256.d.ts +72 -0
- package/dist/utils/cairoDataTypes/uint256.mjs +103 -0
- package/dist/utils/cairoDataTypes/uint512.cjs +125 -0
- package/dist/utils/cairoDataTypes/uint512.d.ts +76 -0
- package/dist/utils/cairoDataTypes/uint512.mjs +123 -0
- package/dist/utils/calldata/byteArray.cjs +27 -0
- package/dist/utils/calldata/byteArray.d.ts +32 -0
- package/dist/utils/calldata/byteArray.mjs +20 -0
- package/dist/utils/calldata/cairo.cjs +114 -0
- package/dist/utils/calldata/cairo.d.ts +196 -0
- package/dist/utils/calldata/cairo.mjs +68 -0
- package/dist/utils/calldata/enum/CairoCustomEnum.cjs +55 -0
- package/dist/utils/calldata/enum/CairoCustomEnum.d.ts +38 -0
- package/dist/utils/calldata/enum/CairoCustomEnum.mjs +50 -0
- package/dist/utils/calldata/enum/CairoOption.cjs +55 -0
- package/dist/utils/calldata/enum/CairoOption.d.ts +37 -0
- package/dist/utils/calldata/enum/CairoOption.mjs +50 -0
- package/dist/utils/calldata/enum/CairoResult.cjs +54 -0
- package/dist/utils/calldata/enum/CairoResult.d.ts +36 -0
- package/dist/utils/calldata/enum/CairoResult.mjs +47 -0
- package/dist/utils/calldata/enum/index.cjs +38 -0
- package/dist/utils/calldata/enum/index.d.ts +3 -0
- package/dist/utils/calldata/enum/index.mjs +3 -0
- package/dist/utils/calldata/formatter.cjs +55 -0
- package/dist/utils/calldata/formatter.d.ts +9 -0
- package/dist/utils/calldata/formatter.mjs +58 -0
- package/dist/utils/calldata/index.cjs +272 -0
- package/dist/utils/calldata/index.d.ts +90 -0
- package/dist/utils/calldata/index.mjs +276 -0
- package/dist/utils/calldata/parser/index.cjs +29 -0
- package/dist/utils/calldata/parser/index.d.ts +5 -0
- package/dist/utils/calldata/parser/index.mjs +21 -0
- package/dist/utils/calldata/parser/interface.cjs +8 -0
- package/dist/utils/calldata/parser/interface.d.ts +20 -0
- package/dist/utils/calldata/parser/interface.mjs +2 -0
- package/dist/utils/calldata/parser/parser-0-1.1.0.cjs +38 -0
- package/dist/utils/calldata/parser/parser-0-1.1.0.d.ts +24 -0
- package/dist/utils/calldata/parser/parser-0-1.1.0.mjs +31 -0
- package/dist/utils/calldata/parser/parser-2.0.0.cjs +42 -0
- package/dist/utils/calldata/parser/parser-2.0.0.d.ts +23 -0
- package/dist/utils/calldata/parser/parser-2.0.0.mjs +37 -0
- package/dist/utils/calldata/propertyOrder.cjs +159 -0
- package/dist/utils/calldata/propertyOrder.d.ts +2 -0
- package/dist/utils/calldata/propertyOrder.mjs +189 -0
- package/dist/utils/calldata/requestParser.cjs +204 -0
- package/dist/utils/calldata/requestParser.d.ts +11 -0
- package/dist/utils/calldata/requestParser.mjs +231 -0
- package/dist/utils/calldata/responseParser.cjs +200 -0
- package/dist/utils/calldata/responseParser.d.ts +11 -0
- package/dist/utils/calldata/responseParser.mjs +201 -0
- package/dist/utils/calldata/tuple.cjs +106 -0
- package/dist/utils/calldata/tuple.d.ts +6 -0
- package/dist/utils/calldata/tuple.mjs +88 -0
- package/dist/utils/calldata/validate.cjs +241 -0
- package/dist/utils/calldata/validate.d.ts +6 -0
- package/dist/utils/calldata/validate.mjs +315 -0
- package/dist/utils/contract.cjs +40 -0
- package/dist/utils/contract.d.ts +37 -0
- package/dist/utils/contract.mjs +31 -0
- package/dist/utils/ec.cjs +12 -0
- package/dist/utils/ec.d.ts +2 -0
- package/dist/utils/ec.mjs +2 -0
- package/dist/utils/encode.cjs +78 -0
- package/dist/utils/encode.d.ts +207 -0
- package/dist/utils/encode.mjs +56 -0
- package/dist/utils/eth.cjs +22 -0
- package/dist/utils/eth.d.ts +22 -0
- package/dist/utils/eth.mjs +14 -0
- package/dist/utils/events/index.cjs +144 -0
- package/dist/utils/events/index.d.ts +84 -0
- package/dist/utils/events/index.mjs +136 -0
- package/dist/utils/fetchPonyfill.cjs +14 -0
- package/dist/utils/fetchPonyfill.d.ts +2 -0
- package/dist/utils/fetchPonyfill.mjs +5 -0
- package/dist/utils/hash/classHash.cjs +151 -0
- package/dist/utils/hash/classHash.d.ts +120 -0
- package/dist/utils/hash/classHash.mjs +168 -0
- package/dist/utils/hash/index.cjs +49 -0
- package/dist/utils/hash/index.d.ts +7 -0
- package/dist/utils/hash/index.mjs +4 -0
- package/dist/utils/hash/selector.cjs +37 -0
- package/dist/utils/hash/selector.d.ts +57 -0
- package/dist/utils/hash/selector.mjs +28 -0
- package/dist/utils/hash/transactionHash/index.cjs +38 -0
- package/dist/utils/hash/transactionHash/index.d.ts +81 -0
- package/dist/utils/hash/transactionHash/index.mjs +102 -0
- package/dist/utils/hash/transactionHash/v2.cjs +31 -0
- package/dist/utils/hash/transactionHash/v2.d.ts +34 -0
- package/dist/utils/hash/transactionHash/v2.mjs +57 -0
- package/dist/utils/hash/transactionHash/v3.cjs +45 -0
- package/dist/utils/hash/transactionHash/v3.d.ts +24 -0
- package/dist/utils/hash/transactionHash/v3.mjs +80 -0
- package/dist/utils/json.cjs +21 -0
- package/dist/utils/json.d.ts +50 -0
- package/dist/utils/json.mjs +10 -0
- package/dist/utils/merkle.cjs +118 -0
- package/dist/utils/merkle.d.ts +87 -0
- package/dist/utils/merkle.mjs +114 -0
- package/dist/utils/num.cjs +109 -0
- package/dist/utils/num.d.ts +283 -0
- package/dist/utils/num.mjs +86 -0
- package/dist/utils/provider.cjs +182 -0
- package/dist/utils/provider.d.ts +217 -0
- package/dist/utils/provider.mjs +158 -0
- package/dist/utils/responseParser/index.cjs +27 -0
- package/dist/utils/responseParser/index.d.ts +2 -0
- package/dist/utils/responseParser/index.mjs +2 -0
- package/dist/utils/responseParser/interface.cjs +8 -0
- package/dist/utils/responseParser/interface.d.ts +13 -0
- package/dist/utils/responseParser/interface.mjs +2 -0
- package/dist/utils/responseParser/rpc.cjs +83 -0
- package/dist/utils/responseParser/rpc.d.ts +19 -0
- package/dist/utils/responseParser/rpc.mjs +77 -0
- package/dist/utils/shortString.cjs +56 -0
- package/dist/utils/shortString.d.ts +116 -0
- package/dist/utils/shortString.mjs +39 -0
- package/dist/utils/stark.cjs +137 -0
- package/dist/utils/stark.d.ts +224 -0
- package/dist/utils/stark.mjs +109 -0
- package/dist/utils/starknetId.cjs +196 -0
- package/dist/utils/starknetId.d.ts +182 -0
- package/dist/utils/starknetId.mjs +185 -0
- package/dist/utils/transaction.cjs +115 -0
- package/dist/utils/transaction.d.ts +185 -0
- package/dist/utils/transaction.mjs +98 -0
- package/dist/utils/transactionReceipt.cjs +54 -0
- package/dist/utils/transactionReceipt.d.ts +33 -0
- package/dist/utils/transactionReceipt.mjs +49 -0
- package/dist/utils/typedData.cjs +285 -0
- package/dist/utils/typedData.d.ts +54 -0
- package/dist/utils/typedData.mjs +286 -0
- package/dist/utils/uint256.cjs +30 -0
- package/dist/utils/uint256.d.ts +45 -0
- package/dist/utils/uint256.mjs +11 -0
- package/dist/utils/url.cjs +35 -0
- package/dist/utils/url.d.ts +29 -0
- package/dist/utils/url.mjs +27 -0
- package/dist/wallet/account.cjs +115 -0
- package/dist/wallet/account.d.ts +31 -0
- package/dist/wallet/account.mjs +112 -0
- package/dist/wallet/connect.cjs +90 -0
- package/dist/wallet/connect.d.ts +82 -0
- package/dist/wallet/connect.mjs +64 -0
- package/dist/wallet/index.cjs +16 -0
- package/dist/wallet/index.d.ts +1 -0
- package/dist/wallet/index.mjs +1 -0
- package/dist/wallet/types.cjs +1 -0
- package/dist/wallet/types.d.ts +4 -0
- package/dist/wallet/types.mjs +0 -0
- package/package.json +13 -13
- package/dist/index.js +0 -7426
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { RPC06, RPC07 } from '../channel';
|
|
2
|
+
import { StarknetChainId } from '../constants';
|
|
3
|
+
import type { AccountInvocations, BigNumberish, Block, BlockIdentifier, Call, CallContractResponse, ContractClassResponse, ContractVersion, DeclareContractResponse, DeclareContractTransaction, DeployAccountContractPayload, DeployAccountContractTransaction, DeployContractResponse, EstimateFeeResponse, EstimateFeeResponseBulk, GetBlockResponse, GetTransactionResponse, Invocation, InvocationsDetailsWithNonce, InvokeFunctionResponse, Nonce, PendingBlock, SimulateTransactionResponse, StateUpdateResponse, Storage, getContractVersionOptions, getEstimateFeeBulkOptions, getSimulateTransactionOptions, waitForTransactionOptions } from '../types';
|
|
4
|
+
import type { GetTransactionReceiptResponse } from '../utils/transactionReceipt';
|
|
5
|
+
export declare abstract class ProviderInterface {
|
|
6
|
+
abstract channel: RPC07.RpcChannel | RPC06.RpcChannel;
|
|
7
|
+
/**
|
|
8
|
+
* Gets the Starknet chain Id
|
|
9
|
+
*
|
|
10
|
+
* @returns the chain Id
|
|
11
|
+
*/
|
|
12
|
+
abstract getChainId(): Promise<StarknetChainId>;
|
|
13
|
+
/**
|
|
14
|
+
* Calls a function on the Starknet contract.
|
|
15
|
+
*
|
|
16
|
+
* @param call transaction to be called
|
|
17
|
+
* @param blockIdentifier block identifier
|
|
18
|
+
* @returns the result of the function on the smart contract.
|
|
19
|
+
*/
|
|
20
|
+
abstract callContract(call: Call, blockIdentifier?: BlockIdentifier): Promise<CallContractResponse>;
|
|
21
|
+
/**
|
|
22
|
+
* Gets the block information
|
|
23
|
+
*
|
|
24
|
+
* @param blockIdentifier block identifier
|
|
25
|
+
* @returns the block object
|
|
26
|
+
*/
|
|
27
|
+
abstract getBlock(blockIdentifier?: 'pending'): Promise<PendingBlock>;
|
|
28
|
+
abstract getBlock(blockIdentifier: 'latest'): Promise<Block>;
|
|
29
|
+
abstract getBlock(blockIdentifier: BlockIdentifier): Promise<GetBlockResponse>;
|
|
30
|
+
/**
|
|
31
|
+
* Gets the contract class of the deployed contract.
|
|
32
|
+
*
|
|
33
|
+
* @param contractAddress - contract address
|
|
34
|
+
* @param blockIdentifier - block identifier
|
|
35
|
+
* @returns Contract class of compiled contract
|
|
36
|
+
*/
|
|
37
|
+
abstract getClassAt(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<ContractClassResponse>;
|
|
38
|
+
/**
|
|
39
|
+
* Gets the price of l1 gas in the block
|
|
40
|
+
*
|
|
41
|
+
* @param blockIdentifier block identifier
|
|
42
|
+
* @returns gas price of the block
|
|
43
|
+
*/
|
|
44
|
+
abstract getL1GasPrice(blockIdentifier: BlockIdentifier): Promise<string>;
|
|
45
|
+
/**
|
|
46
|
+
* Get L1 message hash from L2 transaction hash
|
|
47
|
+
* @param {BigNumberish} l2TxHash L2 transaction hash
|
|
48
|
+
* @returns {string} Hex string of L1 message hash
|
|
49
|
+
* @example
|
|
50
|
+
* In Sepolia Testnet :
|
|
51
|
+
* ```typescript
|
|
52
|
+
* const result = provider.getL1MessageHash('0x28dfc05eb4f261b37ddad451ff22f1d08d4e3c24dc646af0ec69fa20e096819');
|
|
53
|
+
* // result = '0x55b3f8b6e607fffd9b4d843dfe8f9b5c05822cd94fcad8797deb01d77805532a'
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
abstract getL1MessageHash(l2TxHash: BigNumberish): Promise<string>;
|
|
57
|
+
/**
|
|
58
|
+
* Returns the contract class hash in the given block for the contract deployed at the given address
|
|
59
|
+
*
|
|
60
|
+
* @param contractAddress - contract address
|
|
61
|
+
* @param blockIdentifier - block identifier
|
|
62
|
+
* @returns Class hash
|
|
63
|
+
*/
|
|
64
|
+
abstract getClassHashAt(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<string>;
|
|
65
|
+
/**
|
|
66
|
+
* Returns the contract class deployed under the given class hash.
|
|
67
|
+
*
|
|
68
|
+
* @param classHash - class hash
|
|
69
|
+
* @returns Contract class of compiled contract
|
|
70
|
+
*/
|
|
71
|
+
abstract getClassByHash(classHash: string): Promise<ContractClassResponse>;
|
|
72
|
+
/**
|
|
73
|
+
* Returns the nonce associated with the given address in the given block
|
|
74
|
+
*
|
|
75
|
+
* @param contractAddress - contract address
|
|
76
|
+
* @returns the hex nonce
|
|
77
|
+
*/
|
|
78
|
+
abstract getNonceForAddress(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<Nonce>;
|
|
79
|
+
/**
|
|
80
|
+
* Get the value of the storage (contract's variable) at the given address and key
|
|
81
|
+
*
|
|
82
|
+
* @param contractAddress
|
|
83
|
+
* @param key - from getStorageVarAddress('<STORAGE_VARIABLE_NAME>') (WIP)
|
|
84
|
+
* @param blockIdentifier - block identifier
|
|
85
|
+
* @returns the value of the storage variable
|
|
86
|
+
*/
|
|
87
|
+
abstract getStorageAt(contractAddress: string, key: BigNumberish, blockIdentifier?: BlockIdentifier): Promise<Storage>;
|
|
88
|
+
/**
|
|
89
|
+
* Gets the transaction information from a tx id.
|
|
90
|
+
*
|
|
91
|
+
* @param transactionHash
|
|
92
|
+
* @returns the transaction object \{ transaction_id, status, transaction, block_number?, block_number?, transaction_index?, transaction_failure_reason? \}
|
|
93
|
+
*/
|
|
94
|
+
abstract getTransaction(transactionHash: BigNumberish): Promise<GetTransactionResponse>;
|
|
95
|
+
/**
|
|
96
|
+
* Gets the transaction receipt from a tx hash.
|
|
97
|
+
*
|
|
98
|
+
* @param transactionHash
|
|
99
|
+
* @returns the transaction receipt object
|
|
100
|
+
*/
|
|
101
|
+
abstract getTransactionReceipt(transactionHash: BigNumberish): Promise<GetTransactionReceiptResponse>;
|
|
102
|
+
/**
|
|
103
|
+
* Deploys a given compiled Account contract (json) to starknet
|
|
104
|
+
*
|
|
105
|
+
* @param payload payload to be deployed containing:
|
|
106
|
+
* - compiled contract code
|
|
107
|
+
* - constructor calldata
|
|
108
|
+
* - address salt
|
|
109
|
+
* @returns a confirmation of sending a transaction on the starknet contract
|
|
110
|
+
*/
|
|
111
|
+
abstract deployAccountContract(payload: DeployAccountContractPayload, details: InvocationsDetailsWithNonce): Promise<DeployContractResponse>;
|
|
112
|
+
/**
|
|
113
|
+
* Invokes a function on starknet
|
|
114
|
+
* @deprecated This method won't be supported as soon as fees are mandatory. Should not be used outside of Account class
|
|
115
|
+
*
|
|
116
|
+
* @param invocation the invocation object containing:
|
|
117
|
+
* - contractAddress - the address of the contract
|
|
118
|
+
* - entrypoint - the entrypoint of the contract
|
|
119
|
+
* - calldata - (defaults to []) the calldata
|
|
120
|
+
* - signature - (defaults to []) the signature
|
|
121
|
+
* @param details - optional details containing:
|
|
122
|
+
* - nonce - optional nonce
|
|
123
|
+
* - version - optional version
|
|
124
|
+
* - maxFee - optional maxFee
|
|
125
|
+
* @returns response from addTransaction
|
|
126
|
+
*/
|
|
127
|
+
abstract invokeFunction(invocation: Invocation, details: InvocationsDetailsWithNonce): Promise<InvokeFunctionResponse>;
|
|
128
|
+
/**
|
|
129
|
+
* Declares a given compiled contract (json) to starknet
|
|
130
|
+
* @param transaction transaction payload to be deployed containing:
|
|
131
|
+
* - compiled contract code
|
|
132
|
+
* - sender address
|
|
133
|
+
* - signature
|
|
134
|
+
* @param details Invocation Details containing:
|
|
135
|
+
* - nonce
|
|
136
|
+
* - optional version
|
|
137
|
+
* - optional maxFee
|
|
138
|
+
* @returns a confirmation of sending a transaction on the starknet contract
|
|
139
|
+
*/
|
|
140
|
+
abstract declareContract(transaction: DeclareContractTransaction, details: InvocationsDetailsWithNonce): Promise<DeclareContractResponse>;
|
|
141
|
+
/**
|
|
142
|
+
* Estimates the fee for a given INVOKE transaction
|
|
143
|
+
* @deprecated Please use getInvokeEstimateFee or getDeclareEstimateFee instead. Should not be used outside of Account class
|
|
144
|
+
*
|
|
145
|
+
* @param invocation the invocation object containing:
|
|
146
|
+
* - contractAddress - the address of the contract
|
|
147
|
+
* - entrypoint - the entrypoint of the contract
|
|
148
|
+
* - calldata - (defaults to []) the calldata
|
|
149
|
+
* - signature - (defaults to []) the signature
|
|
150
|
+
* @param details - optional details containing:
|
|
151
|
+
* - nonce - optional nonce
|
|
152
|
+
* - version - optional version
|
|
153
|
+
* @param blockIdentifier - (optional) block identifier
|
|
154
|
+
* @param skipValidate - (optional) skip cairo __validate__ method
|
|
155
|
+
* @returns the estimated fee
|
|
156
|
+
*/
|
|
157
|
+
abstract getEstimateFee(invocation: Invocation, details: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier, skipValidate?: boolean): Promise<EstimateFeeResponse>;
|
|
158
|
+
/**
|
|
159
|
+
* Estimates the fee for a given INVOKE transaction
|
|
160
|
+
*
|
|
161
|
+
* @param invocation the invocation object containing:
|
|
162
|
+
* - contractAddress - the address of the contract
|
|
163
|
+
* - entrypoint - the entrypoint of the contract
|
|
164
|
+
* - calldata - (defaults to []) the calldata
|
|
165
|
+
* - signature - (defaults to []) the signature
|
|
166
|
+
* @param details - optional details containing:
|
|
167
|
+
* - nonce - optional nonce
|
|
168
|
+
* - version - optional version
|
|
169
|
+
* @param blockIdentifier - (optional) block identifier
|
|
170
|
+
* @param skipValidate - (optional) skip cairo __validate__ method
|
|
171
|
+
* @returns the estimated fee
|
|
172
|
+
*/
|
|
173
|
+
abstract getInvokeEstimateFee(invocation: Invocation, details: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier, skipValidate?: boolean): Promise<EstimateFeeResponse>;
|
|
174
|
+
/**
|
|
175
|
+
* Estimates the fee for a given DECLARE transaction
|
|
176
|
+
*
|
|
177
|
+
* @param transaction transaction payload to be declared containing:
|
|
178
|
+
* - compiled contract code
|
|
179
|
+
* - sender address
|
|
180
|
+
* - signature - (defaults to []) the signature
|
|
181
|
+
* @param details - optional details containing:
|
|
182
|
+
* - nonce
|
|
183
|
+
* - version - optional version
|
|
184
|
+
* - optional maxFee
|
|
185
|
+
* @param blockIdentifier - (optional) block identifier
|
|
186
|
+
* @param skipValidate - (optional) skip cairo __validate__ method
|
|
187
|
+
* @returns the estimated fee
|
|
188
|
+
*/
|
|
189
|
+
abstract getDeclareEstimateFee(transaction: DeclareContractTransaction, details: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier, skipValidate?: boolean): Promise<EstimateFeeResponse>;
|
|
190
|
+
/**
|
|
191
|
+
* Estimates the fee for a given DEPLOY_ACCOUNT transaction
|
|
192
|
+
*
|
|
193
|
+
* @param transaction transaction payload to be deployed containing:
|
|
194
|
+
* - classHash
|
|
195
|
+
* - constructorCalldata
|
|
196
|
+
* - addressSalt
|
|
197
|
+
* - signature - (defaults to []) the signature
|
|
198
|
+
* @param details - optional details containing:
|
|
199
|
+
* - nonce
|
|
200
|
+
* - version - optional version
|
|
201
|
+
* - optional maxFee
|
|
202
|
+
* @param blockIdentifier - (optional) block identifier
|
|
203
|
+
* @param skipValidate - (optional) skip cairo __validate__ method
|
|
204
|
+
* @returns the estimated fee
|
|
205
|
+
*/
|
|
206
|
+
abstract getDeployAccountEstimateFee(transaction: DeployAccountContractTransaction, details: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier, skipValidate?: boolean): Promise<EstimateFeeResponse>;
|
|
207
|
+
/**
|
|
208
|
+
* Estimates the fee for a list of INVOKE transaction
|
|
209
|
+
*
|
|
210
|
+
* @param invocations AccountInvocations - Complete invocations array with account details
|
|
211
|
+
* @param options getEstimateFeeBulkOptions
|
|
212
|
+
* - (optional) blockIdentifier - BlockIdentifier
|
|
213
|
+
* @returns the estimated fee
|
|
214
|
+
*/
|
|
215
|
+
abstract getEstimateFeeBulk(invocations: AccountInvocations, options?: getEstimateFeeBulkOptions): Promise<EstimateFeeResponseBulk>;
|
|
216
|
+
/**
|
|
217
|
+
* Wait for the transaction to be accepted
|
|
218
|
+
* @param txHash - transaction hash
|
|
219
|
+
* @param options waitForTransactionOptions
|
|
220
|
+
* - (optional) retryInterval: number | undefined;
|
|
221
|
+
* - (optional) successStates: TransactionStatus[] | undefined;
|
|
222
|
+
* @return GetTransactionReceiptResponse
|
|
223
|
+
*/
|
|
224
|
+
abstract waitForTransaction(txHash: BigNumberish, options?: waitForTransactionOptions): Promise<GetTransactionReceiptResponse>;
|
|
225
|
+
/**
|
|
226
|
+
* Simulates the transaction and returns the transaction trace and estimated fee.
|
|
227
|
+
*
|
|
228
|
+
* @param invocations AccountInvocations - Complete invocations array with account details
|
|
229
|
+
* @param options - getSimulateTransactionOptions
|
|
230
|
+
* - (optional) blockIdentifier - block identifier
|
|
231
|
+
* - (optional) skipValidate - skip cairo __validate__ method
|
|
232
|
+
* - (optional) skipExecute - skip cairo __execute__ method
|
|
233
|
+
* @returns an array of transaction trace and estimated fee
|
|
234
|
+
*/
|
|
235
|
+
abstract getSimulateTransaction(invocations: AccountInvocations, options?: getSimulateTransactionOptions): Promise<SimulateTransactionResponse>;
|
|
236
|
+
/**
|
|
237
|
+
* Gets the state changes in a specific block (result of executing the requested block)
|
|
238
|
+
*
|
|
239
|
+
* @param blockIdentifier - block identifier
|
|
240
|
+
* @returns StateUpdateResponse
|
|
241
|
+
*/
|
|
242
|
+
abstract getStateUpdate(blockIdentifier?: BlockIdentifier): Promise<StateUpdateResponse>;
|
|
243
|
+
/**
|
|
244
|
+
* Gets the contract version from the provided address
|
|
245
|
+
* @param contractAddress string
|
|
246
|
+
* @param classHash undefined
|
|
247
|
+
* @param options - getContractVersionOptions
|
|
248
|
+
* - (optional) compiler - (default true) extract compiler version using type tactic from abi
|
|
249
|
+
* - (optional) blockIdentifier - block identifier
|
|
250
|
+
*/
|
|
251
|
+
abstract getContractVersion(contractAddress: string, classHash?: undefined, options?: getContractVersionOptions): Promise<ContractVersion>;
|
|
252
|
+
/**
|
|
253
|
+
* Gets the contract version from the provided address
|
|
254
|
+
* @param contractAddress undefined
|
|
255
|
+
* @param classHash
|
|
256
|
+
* @param options - getContractVersionOptions
|
|
257
|
+
* - (optional) compiler - (default true) extract compiler version using type tactic from abi
|
|
258
|
+
* - (optional) blockIdentifier - block identifier
|
|
259
|
+
*/
|
|
260
|
+
abstract getContractVersion(contractAddress: undefined, classHash: string, options?: getContractVersionOptions): Promise<ContractVersion>;
|
|
261
|
+
}
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.RpcProvider = void 0;
|
|
7
|
+
var _utils = require("@noble/curves/abstract/utils");
|
|
8
|
+
var _sha = require("@noble/hashes/sha3");
|
|
9
|
+
var _channel = require("../channel/index.cjs");
|
|
10
|
+
var _types = require("../types/index.cjs");
|
|
11
|
+
var _assert = _interopRequireDefault(require("../utils/assert.cjs"));
|
|
12
|
+
var _cairo = require("../utils/calldata/cairo.cjs");
|
|
13
|
+
var _contract = require("../utils/contract.cjs");
|
|
14
|
+
var _encode = require("../utils/encode.cjs");
|
|
15
|
+
var _num = require("../utils/num.cjs");
|
|
16
|
+
var _provider = require("../utils/provider.cjs");
|
|
17
|
+
var _rpc = require("../utils/responseParser/rpc.cjs");
|
|
18
|
+
var _transactionReceipt = require("../utils/transactionReceipt.cjs");
|
|
19
|
+
var _errors = require("./errors.cjs");
|
|
20
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
21
|
+
class RpcProvider {
|
|
22
|
+
responseParser;
|
|
23
|
+
channel;
|
|
24
|
+
constructor(optionsOrProvider) {
|
|
25
|
+
if (optionsOrProvider && "channel" in optionsOrProvider) {
|
|
26
|
+
this.channel = optionsOrProvider.channel;
|
|
27
|
+
this.responseParser = "responseParser" in optionsOrProvider ? optionsOrProvider.responseParser : new _rpc.RPCResponseParser();
|
|
28
|
+
} else {
|
|
29
|
+
this.channel = new _channel.RpcChannel({
|
|
30
|
+
...optionsOrProvider,
|
|
31
|
+
waitMode: false
|
|
32
|
+
});
|
|
33
|
+
this.responseParser = new _rpc.RPCResponseParser(optionsOrProvider?.feeMarginPercentage);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
fetch(method, params, id = 0) {
|
|
37
|
+
return this.channel.fetch(method, params, id);
|
|
38
|
+
}
|
|
39
|
+
async getChainId() {
|
|
40
|
+
return this.channel.getChainId();
|
|
41
|
+
}
|
|
42
|
+
async getSpecVersion() {
|
|
43
|
+
return this.channel.getSpecVersion();
|
|
44
|
+
}
|
|
45
|
+
async getNonceForAddress(contractAddress, blockIdentifier) {
|
|
46
|
+
return this.channel.getNonceForAddress(contractAddress, blockIdentifier);
|
|
47
|
+
}
|
|
48
|
+
async getBlock(blockIdentifier) {
|
|
49
|
+
return this.channel.getBlockWithTxHashes(blockIdentifier).then(this.responseParser.parseGetBlockResponse);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Get the most recent accepted block hash and number
|
|
53
|
+
*/
|
|
54
|
+
async getBlockLatestAccepted() {
|
|
55
|
+
return this.channel.getBlockLatestAccepted();
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Get the most recent accepted block number
|
|
59
|
+
* redundant use getBlockLatestAccepted();
|
|
60
|
+
* @returns Number of the latest block
|
|
61
|
+
*/
|
|
62
|
+
async getBlockNumber() {
|
|
63
|
+
return this.channel.getBlockNumber();
|
|
64
|
+
}
|
|
65
|
+
async getBlockWithTxHashes(blockIdentifier) {
|
|
66
|
+
return this.channel.getBlockWithTxHashes(blockIdentifier);
|
|
67
|
+
}
|
|
68
|
+
async getBlockWithTxs(blockIdentifier) {
|
|
69
|
+
return this.channel.getBlockWithTxs(blockIdentifier);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Pause the execution of the script until a specified block is created.
|
|
73
|
+
* @param {BlockIdentifier} blockIdentifier bloc number (BigNumberisk) or 'pending' or 'latest'.
|
|
74
|
+
* Use of 'latest" or of a block already created will generate no pause.
|
|
75
|
+
* @param {number} [retryInterval] number of milliseconds between 2 requests to the node
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* await myProvider.waitForBlock();
|
|
79
|
+
* // wait the creation of the pending block
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
async waitForBlock(blockIdentifier = "pending", retryInterval = 5e3) {
|
|
83
|
+
if (blockIdentifier === _types.BlockTag.LATEST) return;
|
|
84
|
+
const currentBlock = await this.getBlockNumber();
|
|
85
|
+
const targetBlock = blockIdentifier === _types.BlockTag.PENDING ? currentBlock + 1 : Number((0, _num.toHex)(blockIdentifier));
|
|
86
|
+
if (targetBlock <= currentBlock) return;
|
|
87
|
+
const {
|
|
88
|
+
retries
|
|
89
|
+
} = this.channel;
|
|
90
|
+
let retriesCount = retries;
|
|
91
|
+
let isTargetBlock = false;
|
|
92
|
+
while (!isTargetBlock) {
|
|
93
|
+
const currBlock = await this.getBlockNumber();
|
|
94
|
+
if (currBlock === targetBlock) {
|
|
95
|
+
isTargetBlock = true;
|
|
96
|
+
} else {
|
|
97
|
+
await (0, _provider.wait)(retryInterval);
|
|
98
|
+
}
|
|
99
|
+
retriesCount -= 1;
|
|
100
|
+
if (retriesCount <= 0) {
|
|
101
|
+
throw new Error(`waitForBlock() timed-out after ${retries} tries.`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
async getL1GasPrice(blockIdentifier) {
|
|
106
|
+
return this.channel.getBlockWithTxHashes(blockIdentifier).then(this.responseParser.parseL1GasPriceResponse);
|
|
107
|
+
}
|
|
108
|
+
async getL1MessageHash(l2TxHash) {
|
|
109
|
+
const transaction = await this.channel.getTransactionByHash(l2TxHash);
|
|
110
|
+
(0, _assert.default)(transaction.type === "L1_HANDLER", "This L2 transaction is not a L1 message.");
|
|
111
|
+
const {
|
|
112
|
+
calldata,
|
|
113
|
+
contract_address,
|
|
114
|
+
entry_point_selector,
|
|
115
|
+
nonce
|
|
116
|
+
} = transaction;
|
|
117
|
+
const params = [calldata[0], contract_address, nonce, entry_point_selector, calldata.length - 1, ...calldata.slice(1)];
|
|
118
|
+
const myEncode = (0, _encode.addHexPrefix)(params.reduce((res, par) => res + (0, _encode.removeHexPrefix)((0, _num.toHex)(par)).padStart(64, "0"), ""));
|
|
119
|
+
return (0, _encode.addHexPrefix)((0, _utils.bytesToHex)((0, _sha.keccak_256)((0, _num.hexToBytes)(myEncode))));
|
|
120
|
+
}
|
|
121
|
+
async getBlockWithReceipts(blockIdentifier) {
|
|
122
|
+
if (this.channel instanceof _channel.RPC06.RpcChannel) throw new _errors.LibraryError("Unsupported method for RPC version");
|
|
123
|
+
return this.channel.getBlockWithReceipts(blockIdentifier);
|
|
124
|
+
}
|
|
125
|
+
getStateUpdate = this.getBlockStateUpdate;
|
|
126
|
+
async getBlockStateUpdate(blockIdentifier) {
|
|
127
|
+
return this.channel.getBlockStateUpdate(blockIdentifier);
|
|
128
|
+
}
|
|
129
|
+
async getBlockTransactionsTraces(blockIdentifier) {
|
|
130
|
+
return this.channel.getBlockTransactionsTraces(blockIdentifier);
|
|
131
|
+
}
|
|
132
|
+
async getBlockTransactionCount(blockIdentifier) {
|
|
133
|
+
return this.channel.getBlockTransactionCount(blockIdentifier);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Return transactions from pending block
|
|
137
|
+
* @deprecated Instead use getBlock(BlockTag.PENDING); (will be removed in next minor version)
|
|
138
|
+
* Utility method, same result can be achieved using getBlockWithTxHashes(BlockTag.pending);
|
|
139
|
+
*/
|
|
140
|
+
async getPendingTransactions() {
|
|
141
|
+
const {
|
|
142
|
+
transactions
|
|
143
|
+
} = await this.getBlockWithTxHashes(_types.BlockTag.PENDING).then(this.responseParser.parseGetBlockResponse);
|
|
144
|
+
return Promise.all(transactions.map(it => this.getTransactionByHash(it)));
|
|
145
|
+
}
|
|
146
|
+
async getTransaction(txHash) {
|
|
147
|
+
return this.channel.getTransactionByHash(txHash);
|
|
148
|
+
}
|
|
149
|
+
async getTransactionByHash(txHash) {
|
|
150
|
+
return this.channel.getTransactionByHash(txHash);
|
|
151
|
+
}
|
|
152
|
+
async getTransactionByBlockIdAndIndex(blockIdentifier, index) {
|
|
153
|
+
return this.channel.getTransactionByBlockIdAndIndex(blockIdentifier, index);
|
|
154
|
+
}
|
|
155
|
+
async getTransactionReceipt(txHash) {
|
|
156
|
+
const txReceiptWoHelper = await this.channel.getTransactionReceipt(txHash);
|
|
157
|
+
const txReceiptWoHelperModified = this.responseParser.parseTransactionReceipt(txReceiptWoHelper);
|
|
158
|
+
return new _transactionReceipt.ReceiptTx(txReceiptWoHelperModified);
|
|
159
|
+
}
|
|
160
|
+
async getTransactionTrace(txHash) {
|
|
161
|
+
return this.channel.getTransactionTrace(txHash);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Get the status of a transaction
|
|
165
|
+
*/
|
|
166
|
+
async getTransactionStatus(transactionHash) {
|
|
167
|
+
return this.channel.getTransactionStatus(transactionHash);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* @param invocations AccountInvocations
|
|
171
|
+
* @param options blockIdentifier and flags to skip validation and fee charge<br/>
|
|
172
|
+
* - blockIdentifier<br/>
|
|
173
|
+
* - skipValidate (default false)<br/>
|
|
174
|
+
* - skipFeeCharge (default true)<br/>
|
|
175
|
+
*/
|
|
176
|
+
async getSimulateTransaction(invocations, options) {
|
|
177
|
+
return this.channel.simulateTransaction(invocations, options).then(r => this.responseParser.parseSimulateTransactionResponse(r));
|
|
178
|
+
}
|
|
179
|
+
async waitForTransaction(txHash, options) {
|
|
180
|
+
const receiptWoHelper = await this.channel.waitForTransaction(txHash, options);
|
|
181
|
+
return new _transactionReceipt.ReceiptTx(receiptWoHelper);
|
|
182
|
+
}
|
|
183
|
+
async getStorageAt(contractAddress, key, blockIdentifier) {
|
|
184
|
+
return this.channel.getStorageAt(contractAddress, key, blockIdentifier);
|
|
185
|
+
}
|
|
186
|
+
async getClassHashAt(contractAddress, blockIdentifier) {
|
|
187
|
+
return this.channel.getClassHashAt(contractAddress, blockIdentifier);
|
|
188
|
+
}
|
|
189
|
+
async getClassByHash(classHash) {
|
|
190
|
+
return this.getClass(classHash);
|
|
191
|
+
}
|
|
192
|
+
async getClass(classHash, blockIdentifier) {
|
|
193
|
+
return this.channel.getClass(classHash, blockIdentifier).then(this.responseParser.parseContractClassResponse);
|
|
194
|
+
}
|
|
195
|
+
async getClassAt(contractAddress, blockIdentifier) {
|
|
196
|
+
return this.channel.getClassAt(contractAddress, blockIdentifier).then(this.responseParser.parseContractClassResponse);
|
|
197
|
+
}
|
|
198
|
+
async getContractVersion(contractAddress, classHash, {
|
|
199
|
+
blockIdentifier = this.channel.blockIdentifier,
|
|
200
|
+
compiler = true
|
|
201
|
+
} = {}) {
|
|
202
|
+
let contractClass;
|
|
203
|
+
if (contractAddress) {
|
|
204
|
+
contractClass = await this.getClassAt(contractAddress, blockIdentifier);
|
|
205
|
+
} else if (classHash) {
|
|
206
|
+
contractClass = await this.getClass(classHash, blockIdentifier);
|
|
207
|
+
} else {
|
|
208
|
+
throw Error("getContractVersion require contractAddress or classHash");
|
|
209
|
+
}
|
|
210
|
+
if ((0, _contract.isSierra)(contractClass)) {
|
|
211
|
+
if (compiler) {
|
|
212
|
+
const abiTest = (0, _cairo.getAbiContractVersion)(contractClass.abi);
|
|
213
|
+
return {
|
|
214
|
+
cairo: "1",
|
|
215
|
+
compiler: abiTest.compiler
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
return {
|
|
219
|
+
cairo: "1",
|
|
220
|
+
compiler: void 0
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
return {
|
|
224
|
+
cairo: "0",
|
|
225
|
+
compiler: "0"
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* @deprecated use get*type*EstimateFee (will be refactored based on type after sequencer deprecation)
|
|
230
|
+
*/
|
|
231
|
+
async getEstimateFee(invocation, invocationDetails, blockIdentifier, skipValidate) {
|
|
232
|
+
return this.getInvokeEstimateFee(invocation, invocationDetails, blockIdentifier, skipValidate);
|
|
233
|
+
}
|
|
234
|
+
async getInvokeEstimateFee(invocation, invocationDetails, blockIdentifier, skipValidate) {
|
|
235
|
+
return this.channel.getEstimateFee([{
|
|
236
|
+
type: _types.TransactionType.INVOKE,
|
|
237
|
+
...invocation,
|
|
238
|
+
...invocationDetails
|
|
239
|
+
}], {
|
|
240
|
+
blockIdentifier,
|
|
241
|
+
skipValidate
|
|
242
|
+
}).then(r => this.responseParser.parseFeeEstimateResponse(r));
|
|
243
|
+
}
|
|
244
|
+
async getDeclareEstimateFee(invocation, details, blockIdentifier, skipValidate) {
|
|
245
|
+
return this.channel.getEstimateFee([{
|
|
246
|
+
type: _types.TransactionType.DECLARE,
|
|
247
|
+
...invocation,
|
|
248
|
+
...details
|
|
249
|
+
}], {
|
|
250
|
+
blockIdentifier,
|
|
251
|
+
skipValidate
|
|
252
|
+
}).then(r => this.responseParser.parseFeeEstimateResponse(r));
|
|
253
|
+
}
|
|
254
|
+
async getDeployAccountEstimateFee(invocation, details, blockIdentifier, skipValidate) {
|
|
255
|
+
return this.channel.getEstimateFee([{
|
|
256
|
+
type: _types.TransactionType.DEPLOY_ACCOUNT,
|
|
257
|
+
...invocation,
|
|
258
|
+
...details
|
|
259
|
+
}], {
|
|
260
|
+
blockIdentifier,
|
|
261
|
+
skipValidate
|
|
262
|
+
}).then(r => this.responseParser.parseFeeEstimateResponse(r));
|
|
263
|
+
}
|
|
264
|
+
async getEstimateFeeBulk(invocations, options) {
|
|
265
|
+
return this.channel.getEstimateFee(invocations, options).then(r => this.responseParser.parseFeeEstimateBulkResponse(r));
|
|
266
|
+
}
|
|
267
|
+
async invokeFunction(functionInvocation, details) {
|
|
268
|
+
return this.channel.invoke(functionInvocation, details);
|
|
269
|
+
}
|
|
270
|
+
async declareContract(transaction, details) {
|
|
271
|
+
return this.channel.declare(transaction, details);
|
|
272
|
+
}
|
|
273
|
+
async deployAccountContract(transaction, details) {
|
|
274
|
+
return this.channel.deployAccount(transaction, details);
|
|
275
|
+
}
|
|
276
|
+
async callContract(call, blockIdentifier) {
|
|
277
|
+
return this.channel.callContract(call, blockIdentifier);
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* NEW: Estimate the fee for a message from L1
|
|
281
|
+
* @param message Message From L1
|
|
282
|
+
*/
|
|
283
|
+
async estimateMessageFee(message, blockIdentifier) {
|
|
284
|
+
return this.channel.estimateMessageFee(message, blockIdentifier);
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Returns an object about the sync status, or false if the node is not synching
|
|
288
|
+
* @returns Object with the stats data
|
|
289
|
+
*/
|
|
290
|
+
async getSyncingStats() {
|
|
291
|
+
return this.channel.getSyncingStats();
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Returns all events matching the given filter
|
|
295
|
+
* @returns events and the pagination of the events
|
|
296
|
+
*/
|
|
297
|
+
async getEvents(eventFilter) {
|
|
298
|
+
return this.channel.getEvents(eventFilter);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
exports.RpcProvider = RpcProvider;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { RPC06, RPC07 } from '../channel';
|
|
2
|
+
import { AccountInvocations, BigNumberish, Block, BlockIdentifier, Call, ContractVersion, DeclareContractTransaction, DeployAccountContractTransaction, GetBlockResponse, Invocation, InvocationsDetailsWithNonce, PendingBlock, PendingStateUpdate, RPC, RpcProviderOptions, StateUpdate, StateUpdateResponse, getContractVersionOptions, getEstimateFeeBulkOptions, getSimulateTransactionOptions, waitForTransactionOptions } from '../types';
|
|
3
|
+
import { RPCResponseParser } from '../utils/responseParser/rpc';
|
|
4
|
+
import { GetTransactionReceiptResponse } from '../utils/transactionReceipt';
|
|
5
|
+
import { ProviderInterface } from './interface';
|
|
6
|
+
export declare class RpcProvider implements ProviderInterface {
|
|
7
|
+
responseParser: RPCResponseParser;
|
|
8
|
+
channel: RPC07.RpcChannel | RPC06.RpcChannel;
|
|
9
|
+
constructor(optionsOrProvider?: RpcProviderOptions | ProviderInterface | RpcProvider);
|
|
10
|
+
fetch(method: string, params?: object, id?: string | number): any;
|
|
11
|
+
getChainId(): Promise<"0x534e5f4d41494e" | "0x534e5f5345504f4c4941">;
|
|
12
|
+
getSpecVersion(): Promise<string>;
|
|
13
|
+
getNonceForAddress(contractAddress: BigNumberish, blockIdentifier?: BlockIdentifier): Promise<string>;
|
|
14
|
+
getBlock(): Promise<PendingBlock>;
|
|
15
|
+
getBlock(blockIdentifier: 'pending'): Promise<PendingBlock>;
|
|
16
|
+
getBlock(blockIdentifier: 'latest'): Promise<Block>;
|
|
17
|
+
getBlock(blockIdentifier?: BlockIdentifier): Promise<GetBlockResponse>;
|
|
18
|
+
/**
|
|
19
|
+
* Get the most recent accepted block hash and number
|
|
20
|
+
*/
|
|
21
|
+
getBlockLatestAccepted(): Promise<RPC.RPCSPEC06.BlockHashAndNumber>;
|
|
22
|
+
/**
|
|
23
|
+
* Get the most recent accepted block number
|
|
24
|
+
* redundant use getBlockLatestAccepted();
|
|
25
|
+
* @returns Number of the latest block
|
|
26
|
+
*/
|
|
27
|
+
getBlockNumber(): Promise<number>;
|
|
28
|
+
getBlockWithTxHashes(blockIdentifier?: BlockIdentifier): Promise<RPC.RPCSPEC06.BlockWithTxHashes>;
|
|
29
|
+
getBlockWithTxs(blockIdentifier?: BlockIdentifier): Promise<RPC.RPCSPEC06.BlockWithTxs>;
|
|
30
|
+
/**
|
|
31
|
+
* Pause the execution of the script until a specified block is created.
|
|
32
|
+
* @param {BlockIdentifier} blockIdentifier bloc number (BigNumberisk) or 'pending' or 'latest'.
|
|
33
|
+
* Use of 'latest" or of a block already created will generate no pause.
|
|
34
|
+
* @param {number} [retryInterval] number of milliseconds between 2 requests to the node
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* await myProvider.waitForBlock();
|
|
38
|
+
* // wait the creation of the pending block
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
waitForBlock(blockIdentifier?: BlockIdentifier, retryInterval?: number): Promise<void>;
|
|
42
|
+
getL1GasPrice(blockIdentifier?: BlockIdentifier): Promise<string>;
|
|
43
|
+
getL1MessageHash(l2TxHash: BigNumberish): Promise<string>;
|
|
44
|
+
getBlockWithReceipts(blockIdentifier?: BlockIdentifier): Promise<RPC.BlockWithTxReceipts>;
|
|
45
|
+
getStateUpdate: {
|
|
46
|
+
(): Promise<PendingStateUpdate>;
|
|
47
|
+
(blockIdentifier: 'pending'): Promise<PendingStateUpdate>;
|
|
48
|
+
(blockIdentifier: 'latest'): Promise<StateUpdate>;
|
|
49
|
+
(blockIdentifier?: BlockIdentifier): Promise<StateUpdateResponse>;
|
|
50
|
+
};
|
|
51
|
+
getBlockStateUpdate(): Promise<PendingStateUpdate>;
|
|
52
|
+
getBlockStateUpdate(blockIdentifier: 'pending'): Promise<PendingStateUpdate>;
|
|
53
|
+
getBlockStateUpdate(blockIdentifier: 'latest'): Promise<StateUpdate>;
|
|
54
|
+
getBlockStateUpdate(blockIdentifier?: BlockIdentifier): Promise<StateUpdateResponse>;
|
|
55
|
+
getBlockTransactionsTraces(blockIdentifier?: BlockIdentifier): Promise<RPC.RPCSPEC06.BlockTransactionsTraces>;
|
|
56
|
+
getBlockTransactionCount(blockIdentifier?: BlockIdentifier): Promise<number>;
|
|
57
|
+
/**
|
|
58
|
+
* Return transactions from pending block
|
|
59
|
+
* @deprecated Instead use getBlock(BlockTag.PENDING); (will be removed in next minor version)
|
|
60
|
+
* Utility method, same result can be achieved using getBlockWithTxHashes(BlockTag.pending);
|
|
61
|
+
*/
|
|
62
|
+
getPendingTransactions(): Promise<RPC.RPCSPEC06.TransactionWithHash[]>;
|
|
63
|
+
getTransaction(txHash: BigNumberish): Promise<RPC.RPCSPEC06.TransactionWithHash>;
|
|
64
|
+
getTransactionByHash(txHash: BigNumberish): Promise<RPC.RPCSPEC06.TransactionWithHash>;
|
|
65
|
+
getTransactionByBlockIdAndIndex(blockIdentifier: BlockIdentifier, index: number): Promise<RPC.RPCSPEC06.TransactionWithHash>;
|
|
66
|
+
getTransactionReceipt(txHash: BigNumberish): Promise<GetTransactionReceiptResponse>;
|
|
67
|
+
getTransactionTrace(txHash: BigNumberish): Promise<RPC.RPCSPEC06.SPEC.TRANSACTION_TRACE>;
|
|
68
|
+
/**
|
|
69
|
+
* Get the status of a transaction
|
|
70
|
+
*/
|
|
71
|
+
getTransactionStatus(transactionHash: BigNumberish): Promise<RPC.RPCSPEC06.TransactionStatus>;
|
|
72
|
+
/**
|
|
73
|
+
* @param invocations AccountInvocations
|
|
74
|
+
* @param options blockIdentifier and flags to skip validation and fee charge<br/>
|
|
75
|
+
* - blockIdentifier<br/>
|
|
76
|
+
* - skipValidate (default false)<br/>
|
|
77
|
+
* - skipFeeCharge (default true)<br/>
|
|
78
|
+
*/
|
|
79
|
+
getSimulateTransaction(invocations: AccountInvocations, options?: getSimulateTransactionOptions): Promise<import("../types").SimulateTransactionResponse>;
|
|
80
|
+
waitForTransaction(txHash: BigNumberish, options?: waitForTransactionOptions): Promise<GetTransactionReceiptResponse>;
|
|
81
|
+
getStorageAt(contractAddress: BigNumberish, key: BigNumberish, blockIdentifier?: BlockIdentifier): Promise<string>;
|
|
82
|
+
getClassHashAt(contractAddress: BigNumberish, blockIdentifier?: BlockIdentifier): Promise<string>;
|
|
83
|
+
getClassByHash(classHash: BigNumberish): Promise<import("../types").LegacyContractClass | Omit<import("../types").CompiledSierra, "sierra_program_debug_info">>;
|
|
84
|
+
getClass(classHash: BigNumberish, blockIdentifier?: BlockIdentifier): Promise<import("../types").LegacyContractClass | Omit<import("../types").CompiledSierra, "sierra_program_debug_info">>;
|
|
85
|
+
getClassAt(contractAddress: BigNumberish, blockIdentifier?: BlockIdentifier): Promise<import("../types").LegacyContractClass | Omit<import("../types").CompiledSierra, "sierra_program_debug_info">>;
|
|
86
|
+
getContractVersion(contractAddress: BigNumberish, classHash?: undefined, options?: getContractVersionOptions): Promise<ContractVersion>;
|
|
87
|
+
getContractVersion(contractAddress: undefined, classHash: BigNumberish, options?: getContractVersionOptions): Promise<ContractVersion>;
|
|
88
|
+
/**
|
|
89
|
+
* @deprecated use get*type*EstimateFee (will be refactored based on type after sequencer deprecation)
|
|
90
|
+
*/
|
|
91
|
+
getEstimateFee(invocation: Invocation, invocationDetails: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier, skipValidate?: boolean): Promise<import("../types").EstimateFeeResponse>;
|
|
92
|
+
getInvokeEstimateFee(invocation: Invocation, invocationDetails: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier, skipValidate?: boolean): Promise<import("../types").EstimateFeeResponse>;
|
|
93
|
+
getDeclareEstimateFee(invocation: DeclareContractTransaction, details: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier, skipValidate?: boolean): Promise<import("../types").EstimateFeeResponse>;
|
|
94
|
+
getDeployAccountEstimateFee(invocation: DeployAccountContractTransaction, details: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier, skipValidate?: boolean): Promise<import("../types").EstimateFeeResponse>;
|
|
95
|
+
getEstimateFeeBulk(invocations: AccountInvocations, options: getEstimateFeeBulkOptions): Promise<import("../types").EstimateFeeResponseBulk>;
|
|
96
|
+
invokeFunction(functionInvocation: Invocation, details: InvocationsDetailsWithNonce): Promise<RPC.InvokedTransaction>;
|
|
97
|
+
declareContract(transaction: DeclareContractTransaction, details: InvocationsDetailsWithNonce): Promise<RPC.DeclaredTransaction>;
|
|
98
|
+
deployAccountContract(transaction: DeployAccountContractTransaction, details: InvocationsDetailsWithNonce): Promise<RPC.DeployedAccountTransaction>;
|
|
99
|
+
callContract(call: Call, blockIdentifier?: BlockIdentifier): Promise<string[]>;
|
|
100
|
+
/**
|
|
101
|
+
* NEW: Estimate the fee for a message from L1
|
|
102
|
+
* @param message Message From L1
|
|
103
|
+
*/
|
|
104
|
+
estimateMessageFee(message: RPC.L1Message, blockIdentifier?: BlockIdentifier): Promise<RPC.RPCSPEC06.SPEC.FEE_ESTIMATE>;
|
|
105
|
+
/**
|
|
106
|
+
* Returns an object about the sync status, or false if the node is not synching
|
|
107
|
+
* @returns Object with the stats data
|
|
108
|
+
*/
|
|
109
|
+
getSyncingStats(): Promise<RPC.RPCSPEC06.Syncing>;
|
|
110
|
+
/**
|
|
111
|
+
* Returns all events matching the given filter
|
|
112
|
+
* @returns events and the pagination of the events
|
|
113
|
+
*/
|
|
114
|
+
getEvents(eventFilter: RPC.EventFilter): Promise<RPC.RPCSPEC06.SPEC.EVENTS_CHUNK>;
|
|
115
|
+
}
|