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/provider/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.Block = exports.txIdentifier = exports.formatHash = void 0;
|
|
4
4
|
var number_1 = require("../utils/number");
|
|
5
5
|
/**
|
|
6
6
|
*
|
|
@@ -29,67 +29,56 @@ function txIdentifier(txHash, txId) {
|
|
|
29
29
|
return "transactionHash=".concat(hashString);
|
|
30
30
|
}
|
|
31
31
|
exports.txIdentifier = txIdentifier;
|
|
32
|
-
var
|
|
33
|
-
function
|
|
34
|
-
|
|
32
|
+
var Block = /** @class */ (function () {
|
|
33
|
+
function Block(_identifier) {
|
|
34
|
+
var _this = this;
|
|
35
|
+
this.hash = null;
|
|
36
|
+
this.number = null;
|
|
37
|
+
this.tag = null;
|
|
38
|
+
this.valueOf = function () { return _this.number; };
|
|
39
|
+
this.toString = function () { return _this.hash; };
|
|
40
|
+
this.setIdentifier = function (__identifier) {
|
|
41
|
+
if (typeof __identifier === 'string' && (0, number_1.isHex)(__identifier)) {
|
|
42
|
+
this.hash = __identifier;
|
|
43
|
+
}
|
|
44
|
+
else if (typeof __identifier === 'number') {
|
|
45
|
+
this.number = __identifier;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
this.tag = __identifier;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
this.setIdentifier(_identifier);
|
|
35
52
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
53
|
+
Object.defineProperty(Block.prototype, "queryIdentifier", {
|
|
54
|
+
get: function () {
|
|
55
|
+
if (this.number !== null) {
|
|
56
|
+
return "blockNumber=".concat(this.number);
|
|
57
|
+
}
|
|
58
|
+
if (this.hash !== null) {
|
|
59
|
+
return "blockHash=".concat(this.hash);
|
|
60
|
+
}
|
|
61
|
+
return "blockNumber=".concat(this.tag);
|
|
62
|
+
},
|
|
63
|
+
enumerable: false,
|
|
64
|
+
configurable: true
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(Block.prototype, "identifier", {
|
|
67
|
+
get: function () {
|
|
68
|
+
if (this.number !== null) {
|
|
69
|
+
return { block_number: this.number };
|
|
70
|
+
}
|
|
71
|
+
if (this.hash !== null) {
|
|
72
|
+
return { block_hash: this.hash };
|
|
73
|
+
}
|
|
74
|
+
return this.tag;
|
|
75
|
+
},
|
|
76
|
+
set: function (_identifier) {
|
|
77
|
+
this.setIdentifier(_identifier);
|
|
78
|
+
},
|
|
79
|
+
enumerable: false,
|
|
80
|
+
configurable: true
|
|
81
|
+
});
|
|
82
|
+
return Block;
|
|
46
83
|
}());
|
|
47
|
-
exports.
|
|
48
|
-
/**
|
|
49
|
-
* Identifies the block to be queried.
|
|
50
|
-
*
|
|
51
|
-
* @param blockIdentifier - block identifier
|
|
52
|
-
* @returns block identifier object
|
|
53
|
-
*/
|
|
54
|
-
function getBlockIdentifier(blockIdentifier) {
|
|
55
|
-
if (blockIdentifier === null || blockIdentifier === 'latest') {
|
|
56
|
-
return { type: 'BLOCK_NUMBER', data: 'latest' }; // default to latest block
|
|
57
|
-
}
|
|
58
|
-
if (blockIdentifier === 'pending') {
|
|
59
|
-
return { type: 'BLOCK_NUMBER', data: 'pending' };
|
|
60
|
-
}
|
|
61
|
-
if (typeof blockIdentifier === 'number' || typeof blockIdentifier === 'bigint') {
|
|
62
|
-
return { type: 'BLOCK_NUMBER', data: blockIdentifier };
|
|
63
|
-
}
|
|
64
|
-
if (typeof blockIdentifier === 'string' && blockIdentifier.startsWith('0x')) {
|
|
65
|
-
return { type: 'BLOCK_HASH', data: blockIdentifier };
|
|
66
|
-
}
|
|
67
|
-
if (typeof blockIdentifier === 'string' && !Number.isNaN(parseInt(blockIdentifier, 10))) {
|
|
68
|
-
return { type: 'BLOCK_NUMBER', data: parseInt(blockIdentifier, 10) };
|
|
69
|
-
}
|
|
70
|
-
if (typeof blockIdentifier === 'string') {
|
|
71
|
-
throw new Error("Invalid block identifier: ".concat(blockIdentifier));
|
|
72
|
-
}
|
|
73
|
-
return { type: 'BLOCK_HASH', data: blockIdentifier };
|
|
74
|
-
}
|
|
75
|
-
exports.getBlockIdentifier = getBlockIdentifier;
|
|
76
|
-
/**
|
|
77
|
-
* Gets the block identifier for API request
|
|
78
|
-
*
|
|
79
|
-
* [Reference](https://github.com/starkware-libs/cairo-lang/blob/fc97bdd8322a7df043c87c371634b26c15ed6cee/src/starkware/starknet/services/api/feeder_gateway/feeder_gateway_client.py#L164-L173)
|
|
80
|
-
*
|
|
81
|
-
* @param blockIdentifier
|
|
82
|
-
* @returns block identifier for API request
|
|
83
|
-
*/
|
|
84
|
-
function getFormattedBlockIdentifier(blockIdentifier) {
|
|
85
|
-
if (blockIdentifier === void 0) { blockIdentifier = null; }
|
|
86
|
-
var blockIdentifierObject = getBlockIdentifier(blockIdentifier);
|
|
87
|
-
if (blockIdentifierObject.type === 'BLOCK_NUMBER' && blockIdentifierObject.data === null) {
|
|
88
|
-
return '';
|
|
89
|
-
}
|
|
90
|
-
if (blockIdentifierObject.type === 'BLOCK_NUMBER') {
|
|
91
|
-
return "blockNumber=".concat(blockIdentifierObject.data);
|
|
92
|
-
}
|
|
93
|
-
return "blockHash=".concat((0, number_1.toHex)((0, number_1.toBN)(blockIdentifierObject.data)));
|
|
94
|
-
}
|
|
95
|
-
exports.getFormattedBlockIdentifier = getFormattedBlockIdentifier;
|
|
84
|
+
exports.Block = Block;
|
package/signer/default.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Abi,
|
|
1
|
+
import { Abi, Call, InvocationsSignerDetails, KeyPair, Signature } from '../types';
|
|
2
2
|
import { TypedData } from '../utils/typedData';
|
|
3
3
|
import { SignerInterface } from './interface';
|
|
4
4
|
export declare class Signer implements SignerInterface {
|
|
5
5
|
protected keyPair: KeyPair;
|
|
6
6
|
constructor(keyPair?: KeyPair);
|
|
7
7
|
getPubKey(): Promise<string>;
|
|
8
|
-
signTransaction(transactions:
|
|
8
|
+
signTransaction(transactions: Call[], transactionsDetail: InvocationsSignerDetails, abis?: Abi[]): Promise<Signature>;
|
|
9
9
|
signMessage(typedData: TypedData, accountAddress: string): Promise<Signature>;
|
|
10
10
|
}
|
package/signer/default.js
CHANGED
|
@@ -60,8 +60,8 @@ var Signer = /** @class */ (function () {
|
|
|
60
60
|
if (abis && abis.length !== transactions.length) {
|
|
61
61
|
throw new Error('ABI must be provided for each transaction or no transaction');
|
|
62
62
|
}
|
|
63
|
-
calldata = (0, transaction_1.
|
|
64
|
-
msgHash = (0, hash_1.
|
|
63
|
+
calldata = (0, transaction_1.fromCallsToExecuteCalldata)(transactions);
|
|
64
|
+
msgHash = (0, hash_1.calculateTransactionHash)(transactionsDetail.walletAddress, transactionsDetail.version, calldata, transactionsDetail.maxFee, transactionsDetail.chainId, transactionsDetail.nonce);
|
|
65
65
|
return [2 /*return*/, (0, ellipticCurve_1.sign)(this.keyPair, msgHash)];
|
|
66
66
|
});
|
|
67
67
|
});
|
package/signer/interface.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Abi,
|
|
1
|
+
import { Abi, Call, InvocationsSignerDetails, Signature } from '../types';
|
|
2
2
|
import { TypedData } from '../utils/typedData';
|
|
3
3
|
export declare abstract class SignerInterface {
|
|
4
4
|
/**
|
|
@@ -29,5 +29,5 @@ export declare abstract class SignerInterface {
|
|
|
29
29
|
*
|
|
30
30
|
* @returns signature
|
|
31
31
|
*/
|
|
32
|
-
abstract signTransaction(transactions:
|
|
32
|
+
abstract signTransaction(transactions: Call[], transactionsDetail: InvocationsSignerDetails, abis?: Abi[]): Promise<Signature>;
|
|
33
33
|
}
|
package/src/account/default.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ZERO } from '../constants';
|
|
2
2
|
import { ProviderInterface, ProviderOptions } from '../provider';
|
|
3
3
|
import { Provider } from '../provider/default';
|
|
4
|
+
import { BlockIdentifier } from '../provider/utils';
|
|
4
5
|
import { Signer, SignerInterface } from '../signer';
|
|
5
6
|
import {
|
|
6
7
|
Abi,
|
|
@@ -12,32 +13,31 @@ import {
|
|
|
12
13
|
Signature,
|
|
13
14
|
} from '../types';
|
|
14
15
|
import { EstimateFee, EstimateFeeDetails } from '../types/account';
|
|
15
|
-
import {
|
|
16
|
-
import { BigNumberish, toBN
|
|
16
|
+
import { transactionVersion } from '../utils/hash';
|
|
17
|
+
import { BigNumberish, toBN } from '../utils/number';
|
|
17
18
|
import { compileCalldata, estimatedFeeToMaxFee } from '../utils/stark';
|
|
18
|
-
import {
|
|
19
|
+
import { fromCallsToExecuteCalldata } from '../utils/transaction';
|
|
19
20
|
import { TypedData, getMessageHash } from '../utils/typedData';
|
|
20
21
|
import { AccountInterface } from './interface';
|
|
21
22
|
|
|
22
23
|
export class Account extends Provider implements AccountInterface {
|
|
23
24
|
public signer: SignerInterface;
|
|
24
25
|
|
|
26
|
+
public address: string;
|
|
27
|
+
|
|
25
28
|
constructor(
|
|
26
29
|
providerOrOptions: ProviderOptions | ProviderInterface,
|
|
27
|
-
|
|
30
|
+
address: string,
|
|
28
31
|
keyPairOrSigner: KeyPair | SignerInterface
|
|
29
32
|
) {
|
|
30
33
|
super(providerOrOptions);
|
|
34
|
+
this.address = address.toLowerCase();
|
|
31
35
|
this.signer =
|
|
32
36
|
'getPubKey' in keyPairOrSigner ? keyPairOrSigner : new Signer(keyPairOrSigner as KeyPair);
|
|
33
37
|
}
|
|
34
38
|
|
|
35
|
-
public async getNonce(): Promise<
|
|
36
|
-
|
|
37
|
-
contractAddress: this.address,
|
|
38
|
-
entrypoint: 'get_nonce',
|
|
39
|
-
});
|
|
40
|
-
return toHex(toBN(result[0]));
|
|
39
|
+
public async getNonce(blockIdentifier?: BlockIdentifier): Promise<BigNumberish> {
|
|
40
|
+
return super.getNonce(this.address, blockIdentifier);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
public async estimateFee(
|
|
@@ -45,13 +45,13 @@ export class Account extends Provider implements AccountInterface {
|
|
|
45
45
|
{ nonce: providedNonce, blockIdentifier }: EstimateFeeDetails = {}
|
|
46
46
|
): Promise<EstimateFee> {
|
|
47
47
|
const transactions = Array.isArray(calls) ? calls : [calls];
|
|
48
|
-
const nonce = providedNonce ?? (await this.getNonce());
|
|
49
|
-
const version = toBN(
|
|
48
|
+
const nonce = toBN(providedNonce ?? (await this.getNonce()));
|
|
49
|
+
const version = toBN(transactionVersion);
|
|
50
50
|
const chainId = await this.getChainId();
|
|
51
51
|
|
|
52
52
|
const signerDetails: InvocationsSignerDetails = {
|
|
53
53
|
walletAddress: this.address,
|
|
54
|
-
nonce
|
|
54
|
+
nonce,
|
|
55
55
|
maxFee: ZERO,
|
|
56
56
|
version,
|
|
57
57
|
chainId,
|
|
@@ -59,11 +59,11 @@ export class Account extends Provider implements AccountInterface {
|
|
|
59
59
|
|
|
60
60
|
const signature = await this.signer.signTransaction(transactions, signerDetails);
|
|
61
61
|
|
|
62
|
-
const calldata =
|
|
62
|
+
const calldata = fromCallsToExecuteCalldata(transactions);
|
|
63
63
|
const response = await super.getEstimateFee(
|
|
64
|
-
{ contractAddress: this.address,
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
{ contractAddress: this.address, calldata, signature },
|
|
65
|
+
{ version, nonce },
|
|
66
|
+
blockIdentifier
|
|
67
67
|
);
|
|
68
68
|
|
|
69
69
|
const suggestedMaxFee = estimatedFeeToMaxFee(response.overall_fee);
|
|
@@ -112,11 +112,12 @@ export class Account extends Provider implements AccountInterface {
|
|
|
112
112
|
|
|
113
113
|
const signature = await this.signer.signTransaction(transactions, signerDetails, abis);
|
|
114
114
|
|
|
115
|
-
const calldata =
|
|
115
|
+
const calldata = fromCallsToExecuteCalldata(transactions);
|
|
116
116
|
|
|
117
117
|
return this.invokeFunction(
|
|
118
|
-
{ contractAddress: this.address,
|
|
118
|
+
{ contractAddress: this.address, calldata, signature },
|
|
119
119
|
{
|
|
120
|
+
nonce,
|
|
120
121
|
maxFee,
|
|
121
122
|
version,
|
|
122
123
|
}
|
|
@@ -158,7 +159,7 @@ export class Account extends Provider implements AccountInterface {
|
|
|
158
159
|
try {
|
|
159
160
|
await this.callContract({
|
|
160
161
|
contractAddress: this.address,
|
|
161
|
-
entrypoint: '
|
|
162
|
+
entrypoint: 'isValidSignature',
|
|
162
163
|
calldata: compileCalldata({
|
|
163
164
|
hash: toBN(hash).toString(),
|
|
164
165
|
signature: signature.map((x) => toBN(x).toString()),
|
package/src/account/interface.ts
CHANGED
|
@@ -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 {
|
|
4
5
|
Abi,
|
|
@@ -92,5 +93,5 @@ export abstract class AccountInterface extends ProviderInterface {
|
|
|
92
93
|
*/
|
|
93
94
|
public abstract verifyMessageHash(hash: BigNumberish, signature: Signature): Promise<boolean>;
|
|
94
95
|
|
|
95
|
-
public abstract getNonce(): Promise<
|
|
96
|
+
public abstract getNonce(blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
|
|
96
97
|
}
|
|
@@ -3,7 +3,6 @@ import assert from 'minimalistic-assert';
|
|
|
3
3
|
import { AccountInterface } from '../account';
|
|
4
4
|
import { ProviderInterface, defaultProvider } from '../provider';
|
|
5
5
|
import { Abi, CompiledContract, RawCalldata } from '../types';
|
|
6
|
-
import { BigNumberish } from '../utils/number';
|
|
7
6
|
import { Contract } from './default';
|
|
8
7
|
|
|
9
8
|
export class ContractFactory {
|
|
@@ -32,7 +31,7 @@ export class ContractFactory {
|
|
|
32
31
|
*/
|
|
33
32
|
public async deploy(
|
|
34
33
|
constructorCalldata?: RawCalldata,
|
|
35
|
-
addressSalt?:
|
|
34
|
+
addressSalt?: string | undefined
|
|
36
35
|
): Promise<Contract> {
|
|
37
36
|
const { contract_address, transaction_hash } = await this.providerOrAccount.deployContract({
|
|
38
37
|
contract: this.compiledContract,
|
package/src/contract/default.ts
CHANGED
|
@@ -9,10 +9,10 @@ import {
|
|
|
9
9
|
AbiEntry,
|
|
10
10
|
Args,
|
|
11
11
|
AsyncContractFunction,
|
|
12
|
+
Call,
|
|
12
13
|
Calldata,
|
|
13
14
|
ContractFunction,
|
|
14
15
|
FunctionAbi,
|
|
15
|
-
Invocation,
|
|
16
16
|
InvokeFunctionResponse,
|
|
17
17
|
Overrides,
|
|
18
18
|
ParsedStruct,
|
|
@@ -125,7 +125,7 @@ export class Contract implements ContractInterface {
|
|
|
125
125
|
address: string,
|
|
126
126
|
providerOrAccount: ProviderInterface | AccountInterface = defaultProvider
|
|
127
127
|
) {
|
|
128
|
-
this.address = address;
|
|
128
|
+
this.address = address.toLowerCase();
|
|
129
129
|
this.providerOrAccount = providerOrAccount;
|
|
130
130
|
this.abi = abi;
|
|
131
131
|
this.structs = abi
|
|
@@ -578,13 +578,22 @@ export class Contract implements ContractInterface {
|
|
|
578
578
|
});
|
|
579
579
|
}
|
|
580
580
|
|
|
581
|
+
if (!options.nonce) {
|
|
582
|
+
throw new Error(`Nonce is required when invoking a function without an account`);
|
|
583
|
+
}
|
|
584
|
+
|
|
581
585
|
// eslint-disable-next-line no-console
|
|
582
586
|
console.warn(`Invoking ${method} without an account. This will not work on a public node.`);
|
|
583
587
|
|
|
584
|
-
return this.providerOrAccount.invokeFunction(
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
+
return this.providerOrAccount.invokeFunction(
|
|
589
|
+
{
|
|
590
|
+
...invocation,
|
|
591
|
+
signature: options.signature || [],
|
|
592
|
+
},
|
|
593
|
+
{
|
|
594
|
+
nonce: options.nonce,
|
|
595
|
+
}
|
|
596
|
+
);
|
|
588
597
|
}
|
|
589
598
|
|
|
590
599
|
public async call(
|
|
@@ -630,13 +639,12 @@ export class Contract implements ContractInterface {
|
|
|
630
639
|
throw Error('Contract must be connected to the account contract to estimate');
|
|
631
640
|
}
|
|
632
641
|
|
|
633
|
-
public populate(method: string, args: Array<any> = []):
|
|
642
|
+
public populate(method: string, args: Array<any> = []): Call {
|
|
634
643
|
const { inputs } = this.abi.find((abi) => abi.name === method) as FunctionAbi;
|
|
635
644
|
return {
|
|
636
645
|
contractAddress: this.address,
|
|
637
646
|
entrypoint: method,
|
|
638
647
|
calldata: this.compileCalldata(args, inputs),
|
|
639
|
-
signature: [],
|
|
640
648
|
};
|
|
641
649
|
}
|
|
642
650
|
}
|
package/src/provider/default.ts
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
GetTransactionReceiptResponse,
|
|
14
14
|
GetTransactionResponse,
|
|
15
15
|
Invocation,
|
|
16
|
-
|
|
16
|
+
InvocationsDetailsWithNonce,
|
|
17
17
|
InvokeFunctionResponse,
|
|
18
18
|
} from '../types';
|
|
19
19
|
import { BigNumberish } from '../utils/number';
|
|
@@ -63,10 +63,17 @@ export class Provider implements ProviderInterface {
|
|
|
63
63
|
|
|
64
64
|
public async getEstimateFee(
|
|
65
65
|
invocation: Invocation,
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
invocationDetails: InvocationsDetailsWithNonce,
|
|
67
|
+
blockIdentifier: BlockIdentifier = 'pending'
|
|
68
68
|
): Promise<EstimateFeeResponse> {
|
|
69
|
-
return this.provider.getEstimateFee(invocation,
|
|
69
|
+
return this.provider.getEstimateFee(invocation, invocationDetails, blockIdentifier);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
public async getNonce(
|
|
73
|
+
contractAddress: string,
|
|
74
|
+
blockIdentifier?: BlockIdentifier
|
|
75
|
+
): Promise<BigNumberish> {
|
|
76
|
+
return this.provider.getNonce(contractAddress, blockIdentifier);
|
|
70
77
|
}
|
|
71
78
|
|
|
72
79
|
public async getStorageAt(
|
|
@@ -94,7 +101,7 @@ export class Provider implements ProviderInterface {
|
|
|
94
101
|
|
|
95
102
|
public async invokeFunction(
|
|
96
103
|
functionInvocation: Invocation,
|
|
97
|
-
details:
|
|
104
|
+
details: InvocationsDetailsWithNonce
|
|
98
105
|
): Promise<InvokeFunctionResponse> {
|
|
99
106
|
return this.provider.invokeFunction(functionInvocation, details);
|
|
100
107
|
}
|
|
@@ -13,7 +13,7 @@ import type {
|
|
|
13
13
|
GetTransactionReceiptResponse,
|
|
14
14
|
GetTransactionResponse,
|
|
15
15
|
Invocation,
|
|
16
|
-
|
|
16
|
+
InvocationsDetailsWithNonce,
|
|
17
17
|
InvokeFunctionResponse,
|
|
18
18
|
} from '../types';
|
|
19
19
|
import type { BigNumberish } from '../utils/number';
|
|
@@ -69,6 +69,17 @@ export abstract class ProviderInterface {
|
|
|
69
69
|
blockIdentifier?: BlockIdentifier
|
|
70
70
|
): Promise<ContractClass>;
|
|
71
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Gets the nonce of a contract with respect to a specific block
|
|
74
|
+
*
|
|
75
|
+
* @param contractAddress - contract address
|
|
76
|
+
* @returns the hex nonce
|
|
77
|
+
*/
|
|
78
|
+
public abstract getNonce(
|
|
79
|
+
contractAddress: string,
|
|
80
|
+
blockIdentifier?: BlockIdentifier
|
|
81
|
+
): Promise<BigNumberish>;
|
|
82
|
+
|
|
72
83
|
/**
|
|
73
84
|
* Gets the contract's storage variable at a specific key.
|
|
74
85
|
*
|
|
@@ -141,7 +152,7 @@ export abstract class ProviderInterface {
|
|
|
141
152
|
*/
|
|
142
153
|
public abstract invokeFunction(
|
|
143
154
|
invocation: Invocation,
|
|
144
|
-
details
|
|
155
|
+
details: InvocationsDetailsWithNonce
|
|
145
156
|
): Promise<InvokeFunctionResponse>;
|
|
146
157
|
|
|
147
158
|
/**
|
|
@@ -160,8 +171,8 @@ export abstract class ProviderInterface {
|
|
|
160
171
|
*/
|
|
161
172
|
public abstract getEstimateFee(
|
|
162
173
|
invocation: Invocation,
|
|
163
|
-
|
|
164
|
-
|
|
174
|
+
details: InvocationsDetailsWithNonce,
|
|
175
|
+
blockIdentifier: BlockIdentifier
|
|
165
176
|
): Promise<EstimateFeeResponse>;
|
|
166
177
|
|
|
167
178
|
/**
|