starknet 4.5.0 → 4.7.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 +40 -0
- package/README.md +3 -1
- package/__tests__/account.test.ts +2 -5
- package/__tests__/contract.test.ts +0 -1
- package/__tests__/defaultProvider.test.ts +16 -10
- package/__tests__/rpcProvider.test.ts +107 -12
- package/__tests__/sequencerProvider.test.ts +10 -8
- package/__tests__/utils/ellipticalCurve.test.ts +7 -8
- package/__tests__/utils/utils.test.ts +17 -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 +24 -12
- package/dist/provider/rpc.js +167 -105
- package/dist/provider/sequencer.d.ts +4 -3
- package/dist/provider/sequencer.js +16 -7
- package/dist/provider/utils.d.ts +11 -35
- package/dist/provider/utils.js +52 -63
- 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 +395 -45
- package/dist/types/api/openrpc.js +21 -3
- package/dist/types/api/rpc.d.ts +34 -191
- package/dist/types/api/sequencer.d.ts +15 -4
- package/dist/types/lib.d.ts +10 -4
- package/dist/types/provider.d.ts +3 -2
- package/dist/utils/hash.d.ts +2 -2
- package/dist/utils/hash.js +5 -5
- package/dist/utils/responseParser/rpc.d.ts +6 -6
- package/dist/utils/responseParser/rpc.js +3 -39
- 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 +24 -12
- package/provider/rpc.js +167 -105
- package/provider/sequencer.d.ts +4 -3
- package/provider/sequencer.js +16 -7
- package/provider/utils.d.ts +11 -35
- package/provider/utils.js +52 -63
- 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 +152 -102
- package/src/provider/sequencer.ts +19 -10
- package/src/provider/utils.ts +43 -56
- package/src/signer/default.ts +8 -8
- package/src/signer/interface.ts +2 -2
- package/src/types/api/openrpc.ts +378 -53
- package/src/types/api/rpc.ts +33 -211
- package/src/types/api/sequencer.ts +17 -4
- package/src/types/lib.ts +7 -5
- package/src/types/provider.ts +3 -2
- package/src/utils/hash.ts +7 -6
- package/src/utils/responseParser/rpc.ts +13 -27
- package/types/api/openrpc.d.ts +395 -45
- package/types/api/openrpc.js +21 -3
- package/types/api/rpc.d.ts +34 -191
- package/types/api/sequencer.d.ts +15 -4
- package/types/lib.d.ts +10 -4
- package/types/provider.d.ts +3 -2
- package/utils/hash.d.ts +2 -2
- package/utils/hash.js +5 -5
- package/utils/responseParser/rpc.d.ts +6 -6
- package/utils/responseParser/rpc.js +3 -39
- package/www/docs/API/account.md +3 -3
- package/www/docs/API/contract.md +2 -2
- package/www/docs/API/provider.md +6 -0
- package/www/docs/API/utils.md +2 -2
package/dist/account/default.js
CHANGED
|
@@ -75,62 +75,54 @@ var Account = /** @class */ (function (_super) {
|
|
|
75
75
|
__extends(Account, _super);
|
|
76
76
|
function Account(providerOrOptions, address, keyPairOrSigner) {
|
|
77
77
|
var _this = _super.call(this, providerOrOptions) || this;
|
|
78
|
-
_this.address = address;
|
|
78
|
+
_this.address = address.toLowerCase();
|
|
79
79
|
_this.signer =
|
|
80
80
|
'getPubKey' in keyPairOrSigner ? keyPairOrSigner : new signer_1.Signer(keyPairOrSigner);
|
|
81
81
|
return _this;
|
|
82
82
|
}
|
|
83
|
-
Account.prototype.getNonce = function () {
|
|
83
|
+
Account.prototype.getNonce = function (blockIdentifier) {
|
|
84
84
|
return __awaiter(this, void 0, void 0, function () {
|
|
85
|
-
var result;
|
|
86
85
|
return __generator(this, function (_a) {
|
|
87
|
-
|
|
88
|
-
case 0: return [4 /*yield*/, this.callContract({
|
|
89
|
-
contractAddress: this.address,
|
|
90
|
-
entrypoint: 'get_nonce',
|
|
91
|
-
})];
|
|
92
|
-
case 1:
|
|
93
|
-
result = (_a.sent()).result;
|
|
94
|
-
return [2 /*return*/, (0, number_1.toHex)((0, number_1.toBN)(result[0]))];
|
|
95
|
-
}
|
|
86
|
+
return [2 /*return*/, _super.prototype.getNonce.call(this, this.address, blockIdentifier)];
|
|
96
87
|
});
|
|
97
88
|
});
|
|
98
89
|
};
|
|
99
90
|
Account.prototype.estimateFee = function (calls, _a) {
|
|
100
91
|
var _b = _a === void 0 ? {} : _a, providedNonce = _b.nonce, blockIdentifier = _b.blockIdentifier;
|
|
101
92
|
return __awaiter(this, void 0, void 0, function () {
|
|
102
|
-
var transactions, nonce, _c, version, chainId, signerDetails, signature, calldata, response, suggestedMaxFee;
|
|
103
|
-
return __generator(this, function (
|
|
104
|
-
switch (
|
|
93
|
+
var transactions, nonce, _c, _d, version, chainId, signerDetails, signature, calldata, response, suggestedMaxFee;
|
|
94
|
+
return __generator(this, function (_e) {
|
|
95
|
+
switch (_e.label) {
|
|
105
96
|
case 0:
|
|
106
97
|
transactions = Array.isArray(calls) ? calls : [calls];
|
|
98
|
+
_c = number_1.toBN;
|
|
107
99
|
if (!(providedNonce !== null && providedNonce !== void 0)) return [3 /*break*/, 1];
|
|
108
|
-
|
|
100
|
+
_d = providedNonce;
|
|
109
101
|
return [3 /*break*/, 3];
|
|
110
102
|
case 1: return [4 /*yield*/, this.getNonce()];
|
|
111
103
|
case 2:
|
|
112
|
-
|
|
113
|
-
|
|
104
|
+
_d = (_e.sent());
|
|
105
|
+
_e.label = 3;
|
|
114
106
|
case 3:
|
|
115
|
-
nonce = _c;
|
|
116
|
-
version = (0, number_1.toBN)(hash_1.
|
|
107
|
+
nonce = _c.apply(void 0, [_d]);
|
|
108
|
+
version = (0, number_1.toBN)(hash_1.transactionVersion);
|
|
117
109
|
return [4 /*yield*/, this.getChainId()];
|
|
118
110
|
case 4:
|
|
119
|
-
chainId =
|
|
111
|
+
chainId = _e.sent();
|
|
120
112
|
signerDetails = {
|
|
121
113
|
walletAddress: this.address,
|
|
122
|
-
nonce:
|
|
114
|
+
nonce: nonce,
|
|
123
115
|
maxFee: constants_1.ZERO,
|
|
124
116
|
version: version,
|
|
125
117
|
chainId: chainId,
|
|
126
118
|
};
|
|
127
119
|
return [4 /*yield*/, this.signer.signTransaction(transactions, signerDetails)];
|
|
128
120
|
case 5:
|
|
129
|
-
signature =
|
|
130
|
-
calldata = (0, transaction_1.
|
|
131
|
-
return [4 /*yield*/, _super.prototype.getEstimateFee.call(this, { contractAddress: this.address,
|
|
121
|
+
signature = _e.sent();
|
|
122
|
+
calldata = (0, transaction_1.fromCallsToExecuteCalldata)(transactions);
|
|
123
|
+
return [4 /*yield*/, _super.prototype.getEstimateFee.call(this, { contractAddress: this.address, calldata: calldata, signature: signature }, { version: version, nonce: nonce }, blockIdentifier)];
|
|
132
124
|
case 6:
|
|
133
|
-
response =
|
|
125
|
+
response = _e.sent();
|
|
134
126
|
suggestedMaxFee = (0, stark_1.estimatedFeeToMaxFee)(response.overall_fee);
|
|
135
127
|
return [2 /*return*/, __assign(__assign({}, response), { suggestedMaxFee: suggestedMaxFee })];
|
|
136
128
|
}
|
|
@@ -191,8 +183,9 @@ var Account = /** @class */ (function (_super) {
|
|
|
191
183
|
return [4 /*yield*/, this.signer.signTransaction(transactions, signerDetails, abis)];
|
|
192
184
|
case 8:
|
|
193
185
|
signature = _d.sent();
|
|
194
|
-
calldata = (0, transaction_1.
|
|
195
|
-
return [2 /*return*/, this.invokeFunction({ contractAddress: this.address,
|
|
186
|
+
calldata = (0, transaction_1.fromCallsToExecuteCalldata)(transactions);
|
|
187
|
+
return [2 /*return*/, this.invokeFunction({ contractAddress: this.address, calldata: calldata, signature: signature }, {
|
|
188
|
+
nonce: nonce,
|
|
196
189
|
maxFee: maxFee,
|
|
197
190
|
version: version,
|
|
198
191
|
})];
|
|
@@ -246,7 +239,7 @@ var Account = /** @class */ (function (_super) {
|
|
|
246
239
|
_b.trys.push([0, 2, , 3]);
|
|
247
240
|
return [4 /*yield*/, this.callContract({
|
|
248
241
|
contractAddress: this.address,
|
|
249
|
-
entrypoint: '
|
|
242
|
+
entrypoint: 'isValidSignature',
|
|
250
243
|
calldata: (0, stark_1.compileCalldata)({
|
|
251
244
|
hash: (0, number_1.toBN)(hash).toString(),
|
|
252
245
|
signature: signature.map(function (x) { return (0, number_1.toBN)(x).toString(); }),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ProviderInterface } from '../provider';
|
|
2
|
+
import { BlockIdentifier } from '../provider/utils';
|
|
2
3
|
import { SignerInterface } from '../signer';
|
|
3
4
|
import { Abi, Call, EstimateFeeDetails, EstimateFeeResponse, InvocationsDetails, InvokeFunctionResponse, Signature } from '../types';
|
|
4
5
|
import { BigNumberish } from '../utils/number';
|
|
@@ -68,5 +69,5 @@ export declare abstract class AccountInterface extends ProviderInterface {
|
|
|
68
69
|
* @throws {Error} if the signature is not a valid signature
|
|
69
70
|
*/
|
|
70
71
|
abstract verifyMessageHash(hash: BigNumberish, signature: Signature): Promise<boolean>;
|
|
71
|
-
abstract getNonce(): Promise<
|
|
72
|
+
abstract getNonce(blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
|
|
72
73
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { AccountInterface } from '../account';
|
|
2
2
|
import { ProviderInterface } from '../provider';
|
|
3
3
|
import { Abi, CompiledContract, RawCalldata } from '../types';
|
|
4
|
-
import { BigNumberish } from '../utils/number';
|
|
5
4
|
import { Contract } from './default';
|
|
6
5
|
export declare class ContractFactory {
|
|
7
6
|
abi: Abi;
|
|
@@ -15,7 +14,7 @@ export declare class ContractFactory {
|
|
|
15
14
|
* @param addressSalt (optional) - Address Salt for deployment
|
|
16
15
|
* @returns deployed Contract
|
|
17
16
|
*/
|
|
18
|
-
deploy(constructorCalldata?: RawCalldata, addressSalt?:
|
|
17
|
+
deploy(constructorCalldata?: RawCalldata, addressSalt?: string | undefined): Promise<Contract>;
|
|
19
18
|
/**
|
|
20
19
|
* Attaches to new Provider or Account
|
|
21
20
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AccountInterface } from '../account';
|
|
2
2
|
import { ProviderInterface } from '../provider';
|
|
3
3
|
import { BlockIdentifier } from '../provider/utils';
|
|
4
|
-
import { Abi, AbiEntry, Args, AsyncContractFunction, Calldata, ContractFunction,
|
|
4
|
+
import { Abi, AbiEntry, Args, AsyncContractFunction, Call, Calldata, ContractFunction, InvokeFunctionResponse, Overrides, ParsedStruct, Result, StructAbi } from '../types';
|
|
5
5
|
import { BigNumberish } from '../utils/number';
|
|
6
6
|
import { ContractInterface } from './interface';
|
|
7
7
|
export declare class Contract implements ContractInterface {
|
|
@@ -120,5 +120,5 @@ export declare class Contract implements ContractInterface {
|
|
|
120
120
|
blockIdentifier?: BlockIdentifier;
|
|
121
121
|
}): Promise<Result>;
|
|
122
122
|
estimate(method: string, args?: Array<any>): Promise<import("../types").EstimateFeeResponse>;
|
|
123
|
-
populate(method: string, args?: Array<any>):
|
|
123
|
+
populate(method: string, args?: Array<any>): Call;
|
|
124
124
|
}
|
package/dist/contract/default.js
CHANGED
|
@@ -181,7 +181,7 @@ var Contract = /** @class */ (function () {
|
|
|
181
181
|
function Contract(abi, address, providerOrAccount) {
|
|
182
182
|
if (providerOrAccount === void 0) { providerOrAccount = provider_1.defaultProvider; }
|
|
183
183
|
var _this = this;
|
|
184
|
-
this.address = address;
|
|
184
|
+
this.address = address.toLowerCase();
|
|
185
185
|
this.providerOrAccount = providerOrAccount;
|
|
186
186
|
this.abi = abi;
|
|
187
187
|
this.structs = abi
|
|
@@ -592,9 +592,14 @@ var Contract = /** @class */ (function () {
|
|
|
592
592
|
nonce: options.nonce,
|
|
593
593
|
});
|
|
594
594
|
}
|
|
595
|
+
if (!options.nonce) {
|
|
596
|
+
throw new Error("Nonce is required when invoking a function without an account");
|
|
597
|
+
}
|
|
595
598
|
// eslint-disable-next-line no-console
|
|
596
599
|
console.warn("Invoking ".concat(method, " without an account. This will not work on a public node."));
|
|
597
|
-
return this.providerOrAccount.invokeFunction(__assign(__assign({}, invocation), { signature: options.signature || [] })
|
|
600
|
+
return this.providerOrAccount.invokeFunction(__assign(__assign({}, invocation), { signature: options.signature || [] }), {
|
|
601
|
+
nonce: options.nonce,
|
|
602
|
+
});
|
|
598
603
|
};
|
|
599
604
|
Contract.prototype.call = function (method, args, _a) {
|
|
600
605
|
if (args === void 0) { args = []; }
|
|
@@ -644,7 +649,6 @@ var Contract = /** @class */ (function () {
|
|
|
644
649
|
contractAddress: this.address,
|
|
645
650
|
entrypoint: method,
|
|
646
651
|
calldata: this.compileCalldata(args, inputs),
|
|
647
|
-
signature: [],
|
|
648
652
|
};
|
|
649
653
|
};
|
|
650
654
|
return Contract;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StarknetChainId } from '../constants';
|
|
2
|
-
import { Call, CallContractResponse, ContractClass, DeclareContractPayload, DeclareContractResponse, DeployContractPayload, DeployContractResponse, EstimateFeeResponse, GetBlockResponse, GetCodeResponse, GetTransactionReceiptResponse, GetTransactionResponse, Invocation,
|
|
2
|
+
import { Call, CallContractResponse, ContractClass, DeclareContractPayload, DeclareContractResponse, DeployContractPayload, DeployContractResponse, EstimateFeeResponse, GetBlockResponse, GetCodeResponse, GetTransactionReceiptResponse, GetTransactionResponse, Invocation, InvocationsDetailsWithNonce, InvokeFunctionResponse } from '../types';
|
|
3
3
|
import { BigNumberish } from '../utils/number';
|
|
4
4
|
import { ProviderInterface } from './interface';
|
|
5
5
|
import { RpcProviderOptions } from './rpc';
|
|
@@ -16,12 +16,13 @@ export declare class Provider implements ProviderInterface {
|
|
|
16
16
|
getChainId(): Promise<StarknetChainId>;
|
|
17
17
|
getBlock(blockIdentifier?: BlockIdentifier): Promise<GetBlockResponse>;
|
|
18
18
|
getClassAt(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<ContractClass>;
|
|
19
|
-
getEstimateFee(invocation: Invocation,
|
|
19
|
+
getEstimateFee(invocation: Invocation, invocationDetails: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
|
|
20
|
+
getNonce(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
|
|
20
21
|
getStorageAt(contractAddress: string, key: BigNumberish, blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
|
|
21
22
|
getTransaction(txHash: BigNumberish): Promise<GetTransactionResponse>;
|
|
22
23
|
getTransactionReceipt(txHash: BigNumberish): Promise<GetTransactionReceiptResponse>;
|
|
23
24
|
callContract(request: Call, blockIdentifier?: BlockIdentifier): Promise<CallContractResponse>;
|
|
24
|
-
invokeFunction(functionInvocation: Invocation, details:
|
|
25
|
+
invokeFunction(functionInvocation: Invocation, details: InvocationsDetailsWithNonce): Promise<InvokeFunctionResponse>;
|
|
25
26
|
deployContract(payload: DeployContractPayload): Promise<DeployContractResponse>;
|
|
26
27
|
declareContract(payload: DeclareContractPayload): Promise<DeclareContractResponse>;
|
|
27
28
|
getCode(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<GetCodeResponse>;
|
package/dist/provider/default.js
CHANGED
|
@@ -84,12 +84,18 @@ var Provider = /** @class */ (function () {
|
|
|
84
84
|
});
|
|
85
85
|
});
|
|
86
86
|
};
|
|
87
|
-
Provider.prototype.getEstimateFee = function (invocation,
|
|
87
|
+
Provider.prototype.getEstimateFee = function (invocation, invocationDetails, blockIdentifier) {
|
|
88
88
|
if (blockIdentifier === void 0) { blockIdentifier = 'pending'; }
|
|
89
|
-
if (invocationDetails === void 0) { invocationDetails = {}; }
|
|
90
89
|
return __awaiter(this, void 0, void 0, function () {
|
|
91
90
|
return __generator(this, function (_a) {
|
|
92
|
-
return [2 /*return*/, this.provider.getEstimateFee(invocation,
|
|
91
|
+
return [2 /*return*/, this.provider.getEstimateFee(invocation, invocationDetails, blockIdentifier)];
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
Provider.prototype.getNonce = function (contractAddress, blockIdentifier) {
|
|
96
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
97
|
+
return __generator(this, function (_a) {
|
|
98
|
+
return [2 /*return*/, this.provider.getNonce(contractAddress, blockIdentifier)];
|
|
93
99
|
});
|
|
94
100
|
});
|
|
95
101
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StarknetChainId } from '../constants';
|
|
2
|
-
import type { Call, CallContractResponse, ContractClass, DeclareContractPayload, DeclareContractResponse, DeployContractPayload, DeployContractResponse, EstimateFeeResponse, GetBlockResponse, GetCodeResponse, GetTransactionReceiptResponse, GetTransactionResponse, Invocation,
|
|
2
|
+
import type { Call, CallContractResponse, ContractClass, DeclareContractPayload, DeclareContractResponse, DeployContractPayload, DeployContractResponse, EstimateFeeResponse, GetBlockResponse, GetCodeResponse, GetTransactionReceiptResponse, GetTransactionResponse, Invocation, InvocationsDetailsWithNonce, InvokeFunctionResponse } from '../types';
|
|
3
3
|
import type { BigNumberish } from '../utils/number';
|
|
4
4
|
import { BlockIdentifier } from './utils';
|
|
5
5
|
export declare abstract class ProviderInterface {
|
|
@@ -37,6 +37,13 @@ export declare abstract class ProviderInterface {
|
|
|
37
37
|
* @returns Contract class of compiled contract
|
|
38
38
|
*/
|
|
39
39
|
abstract getClassAt(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<ContractClass>;
|
|
40
|
+
/**
|
|
41
|
+
* Gets the nonce of a contract with respect to a specific block
|
|
42
|
+
*
|
|
43
|
+
* @param contractAddress - contract address
|
|
44
|
+
* @returns the hex nonce
|
|
45
|
+
*/
|
|
46
|
+
abstract getNonce(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
|
|
40
47
|
/**
|
|
41
48
|
* Gets the contract's storage variable at a specific key.
|
|
42
49
|
*
|
|
@@ -94,7 +101,7 @@ export declare abstract class ProviderInterface {
|
|
|
94
101
|
* - maxFee - optional maxFee
|
|
95
102
|
* @returns response from addTransaction
|
|
96
103
|
*/
|
|
97
|
-
abstract invokeFunction(invocation: Invocation, details
|
|
104
|
+
abstract invokeFunction(invocation: Invocation, details: InvocationsDetailsWithNonce): Promise<InvokeFunctionResponse>;
|
|
98
105
|
/**
|
|
99
106
|
* Estimates the fee for a given transaction
|
|
100
107
|
*
|
|
@@ -109,7 +116,7 @@ export declare abstract class ProviderInterface {
|
|
|
109
116
|
* - version - optional version
|
|
110
117
|
* @returns the estimated fee
|
|
111
118
|
*/
|
|
112
|
-
abstract getEstimateFee(invocation: Invocation,
|
|
119
|
+
abstract getEstimateFee(invocation: Invocation, details: InvocationsDetailsWithNonce, blockIdentifier: BlockIdentifier): Promise<EstimateFeeResponse>;
|
|
113
120
|
/**
|
|
114
121
|
* Wait for the transaction to be accepted
|
|
115
122
|
* @param txHash - transaction hash
|
package/dist/provider/rpc.d.ts
CHANGED
|
@@ -1,36 +1,48 @@
|
|
|
1
1
|
import { StarknetChainId } from '../constants';
|
|
2
|
-
import { Call, CallContractResponse, DeclareContractPayload, DeclareContractResponse, DeployContractPayload, DeployContractResponse, EstimateFeeResponse, GetBlockResponse, GetCodeResponse, GetTransactionReceiptResponse, GetTransactionResponse, Invocation,
|
|
2
|
+
import { Call, CallContractResponse, DeclareContractPayload, DeclareContractResponse, DeployContractPayload, DeployContractResponse, EstimateFeeResponse, GetBlockResponse, GetCodeResponse, GetTransactionReceiptResponse, GetTransactionResponse, Invocation, InvocationsDetailsWithNonce, InvokeFunctionResponse } from '../types';
|
|
3
3
|
import { RPC } from '../types/api';
|
|
4
4
|
import { BigNumberish } from '../utils/number';
|
|
5
5
|
import { ProviderInterface } from './interface';
|
|
6
6
|
import { BlockIdentifier } from './utils';
|
|
7
7
|
export declare type RpcProviderOptions = {
|
|
8
8
|
nodeUrl: string;
|
|
9
|
+
retries?: number;
|
|
9
10
|
};
|
|
10
11
|
export declare class RpcProvider implements ProviderInterface {
|
|
11
12
|
nodeUrl: string;
|
|
12
13
|
chainId: StarknetChainId;
|
|
13
14
|
private responseParser;
|
|
15
|
+
private retries;
|
|
14
16
|
constructor(optionsOrProvider: RpcProviderOptions);
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
fetch(method: any, params: any): Promise<any>;
|
|
18
|
+
protected errorHandler(error: any): void;
|
|
19
|
+
protected fetchEndpoint<T extends keyof RPC.Methods>(method: T, params?: RPC.Methods[T]['params']): Promise<RPC.Methods[T]['result']>;
|
|
20
|
+
getChainId(): Promise<any>;
|
|
17
21
|
getBlock(blockIdentifier?: BlockIdentifier): Promise<GetBlockResponse>;
|
|
22
|
+
getBlockHashAndNumber(): Promise<RPC.BlockHashAndNumber>;
|
|
18
23
|
getBlockWithTxHashes(blockIdentifier?: BlockIdentifier): Promise<RPC.GetBlockWithTxHashesResponse>;
|
|
19
24
|
getBlockWithTxs(blockIdentifier?: BlockIdentifier): Promise<RPC.GetBlockWithTxs>;
|
|
20
|
-
|
|
25
|
+
getClassHashAt(blockIdentifier: BlockIdentifier, contractAddress: RPC.ContractAddress): Promise<RPC.Felt>;
|
|
26
|
+
getNonce(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<RPC.Nonce>;
|
|
27
|
+
getPendingTransactions(): Promise<RPC.PendingTransactions>;
|
|
28
|
+
getProtocolVersion(): Promise<Error>;
|
|
29
|
+
getStateUpdate(blockIdentifier: BlockIdentifier): Promise<RPC.StateUpdate>;
|
|
21
30
|
getStorageAt(contractAddress: string, key: BigNumberish, blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
|
|
22
|
-
getTransaction(txHash:
|
|
23
|
-
getTransactionByHash(txHash:
|
|
31
|
+
getTransaction(txHash: string): Promise<GetTransactionResponse>;
|
|
32
|
+
getTransactionByHash(txHash: string): Promise<RPC.GetTransactionByHashResponse>;
|
|
24
33
|
getTransactionByBlockIdAndIndex(blockIdentifier: BlockIdentifier, index: number): Promise<RPC.GetTransactionByBlockIdAndIndex>;
|
|
25
|
-
getTransactionReceipt(txHash:
|
|
26
|
-
|
|
27
|
-
|
|
34
|
+
getTransactionReceipt(txHash: string): Promise<GetTransactionReceiptResponse>;
|
|
35
|
+
getClass(classHash: RPC.Felt): Promise<RPC.ContractClass>;
|
|
36
|
+
getClassAt(contractAddress: string, blockIdentifier: BlockIdentifier): Promise<RPC.ContractClass>;
|
|
37
|
+
getCode(_contractAddress: string, _blockIdentifier?: BlockIdentifier): Promise<GetCodeResponse>;
|
|
38
|
+
getEstimateFee(invocation: Invocation, invocationDetails: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
|
|
28
39
|
declareContract({ contract, version, }: DeclareContractPayload): Promise<DeclareContractResponse>;
|
|
29
40
|
deployContract({ contract, constructorCalldata, addressSalt, }: DeployContractPayload): Promise<DeployContractResponse>;
|
|
30
|
-
invokeFunction(functionInvocation: Invocation, details:
|
|
41
|
+
invokeFunction(functionInvocation: Invocation, details: InvocationsDetailsWithNonce): Promise<InvokeFunctionResponse>;
|
|
31
42
|
callContract(call: Call, blockIdentifier?: BlockIdentifier): Promise<CallContractResponse>;
|
|
32
|
-
|
|
33
|
-
|
|
43
|
+
traceTransaction(transactionHash: RPC.TransactionHash): Promise<RPC.Trace>;
|
|
44
|
+
traceBlockTransactions(blockHash: RPC.BlockHash): Promise<RPC.Traces>;
|
|
45
|
+
waitForTransaction(txHash: string, retryInterval?: number): Promise<void>;
|
|
34
46
|
/**
|
|
35
47
|
* Gets the transaction count from a block.
|
|
36
48
|
*
|