starknet 4.4.2 → 4.5.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 +11 -0
- package/account/default.js +13 -7
- package/dist/account/default.js +13 -7
- package/dist/provider/default.d.ts +1 -0
- package/dist/provider/default.js +7 -0
- package/dist/provider/interface.d.ts +6 -0
- package/dist/provider/rpc.js +2 -0
- package/dist/provider/sequencer.d.ts +1 -0
- package/dist/provider/sequencer.js +7 -0
- package/package.json +4 -1
- package/provider/default.d.ts +1 -0
- package/provider/default.js +7 -0
- package/provider/interface.d.ts +6 -0
- package/provider/rpc.js +2 -0
- package/provider/sequencer.d.ts +1 -0
- package/provider/sequencer.js +7 -0
- package/src/account/default.ts +4 -2
- package/src/provider/default.ts +4 -0
- package/src/provider/interface.ts +7 -0
- package/src/provider/rpc.ts +2 -0
- package/src/provider/sequencer.ts +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
# [4.5.0](https://github.com/0xs34n/starknet.js/compare/v4.4.2...v4.5.0) (2022-09-09)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
- prevent undefined rpc chainId in account ([9f69229](https://github.com/0xs34n/starknet.js/commit/9f69229fcb5205bb3fd1fcc7eb7c627faa300561))
|
|
6
|
+
- repair chain fix ([d7758a6](https://github.com/0xs34n/starknet.js/commit/d7758a6d180cd1af89f8aefb37bce077b92c5fd5))
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- optional abi field for deploy and declare rpc transactions ([ce62648](https://github.com/0xs34n/starknet.js/commit/ce626481cb6bc3dea77963482820ae6f50c82566))
|
|
11
|
+
|
|
1
12
|
## [4.4.2](https://github.com/0xs34n/starknet.js/compare/v4.4.1...v4.4.2) (2022-09-07)
|
|
2
13
|
|
|
3
14
|
### Bug Fixes
|
package/account/default.js
CHANGED
|
@@ -99,7 +99,7 @@ var Account = /** @class */ (function (_super) {
|
|
|
99
99
|
Account.prototype.estimateFee = function (calls, _a) {
|
|
100
100
|
var _b = _a === void 0 ? {} : _a, providedNonce = _b.nonce, blockIdentifier = _b.blockIdentifier;
|
|
101
101
|
return __awaiter(this, void 0, void 0, function () {
|
|
102
|
-
var transactions, nonce, _c, version, signerDetails, signature, calldata, response, suggestedMaxFee;
|
|
102
|
+
var transactions, nonce, _c, version, chainId, signerDetails, signature, calldata, response, suggestedMaxFee;
|
|
103
103
|
return __generator(this, function (_d) {
|
|
104
104
|
switch (_d.label) {
|
|
105
105
|
case 0:
|
|
@@ -114,19 +114,22 @@ var Account = /** @class */ (function (_super) {
|
|
|
114
114
|
case 3:
|
|
115
115
|
nonce = _c;
|
|
116
116
|
version = (0, number_1.toBN)(hash_1.feeTransactionVersion);
|
|
117
|
+
return [4 /*yield*/, this.getChainId()];
|
|
118
|
+
case 4:
|
|
119
|
+
chainId = _d.sent();
|
|
117
120
|
signerDetails = {
|
|
118
121
|
walletAddress: this.address,
|
|
119
122
|
nonce: (0, number_1.toBN)(nonce),
|
|
120
123
|
maxFee: constants_1.ZERO,
|
|
121
124
|
version: version,
|
|
122
|
-
chainId:
|
|
125
|
+
chainId: chainId,
|
|
123
126
|
};
|
|
124
127
|
return [4 /*yield*/, this.signer.signTransaction(transactions, signerDetails)];
|
|
125
|
-
case
|
|
128
|
+
case 5:
|
|
126
129
|
signature = _d.sent();
|
|
127
130
|
calldata = (0, transaction_1.fromCallsToExecuteCalldataWithNonce)(transactions, nonce);
|
|
128
131
|
return [4 /*yield*/, _super.prototype.getEstimateFee.call(this, { contractAddress: this.address, entrypoint: '__execute__', calldata: calldata, signature: signature }, blockIdentifier, { version: version })];
|
|
129
|
-
case
|
|
132
|
+
case 6:
|
|
130
133
|
response = _d.sent();
|
|
131
134
|
suggestedMaxFee = (0, stark_1.estimatedFeeToMaxFee)(response.overall_fee);
|
|
132
135
|
return [2 /*return*/, __assign(__assign({}, response), { suggestedMaxFee: suggestedMaxFee })];
|
|
@@ -149,7 +152,7 @@ var Account = /** @class */ (function (_super) {
|
|
|
149
152
|
if (abis === void 0) { abis = undefined; }
|
|
150
153
|
if (transactionsDetail === void 0) { transactionsDetail = {}; }
|
|
151
154
|
return __awaiter(this, void 0, void 0, function () {
|
|
152
|
-
var transactions, nonce, _b, _c, maxFee, suggestedMaxFee, version, signerDetails, signature, calldata;
|
|
155
|
+
var transactions, nonce, _b, _c, maxFee, suggestedMaxFee, version, chainId, signerDetails, signature, calldata;
|
|
153
156
|
return __generator(this, function (_d) {
|
|
154
157
|
switch (_d.label) {
|
|
155
158
|
case 0:
|
|
@@ -175,15 +178,18 @@ var Account = /** @class */ (function (_super) {
|
|
|
175
178
|
_d.label = 6;
|
|
176
179
|
case 6:
|
|
177
180
|
version = (0, number_1.toBN)(hash_1.transactionVersion);
|
|
181
|
+
return [4 /*yield*/, this.getChainId()];
|
|
182
|
+
case 7:
|
|
183
|
+
chainId = _d.sent();
|
|
178
184
|
signerDetails = {
|
|
179
185
|
walletAddress: this.address,
|
|
180
186
|
nonce: nonce,
|
|
181
187
|
maxFee: maxFee,
|
|
182
188
|
version: version,
|
|
183
|
-
chainId:
|
|
189
|
+
chainId: chainId,
|
|
184
190
|
};
|
|
185
191
|
return [4 /*yield*/, this.signer.signTransaction(transactions, signerDetails, abis)];
|
|
186
|
-
case
|
|
192
|
+
case 8:
|
|
187
193
|
signature = _d.sent();
|
|
188
194
|
calldata = (0, transaction_1.fromCallsToExecuteCalldataWithNonce)(transactions, nonce);
|
|
189
195
|
return [2 /*return*/, this.invokeFunction({ contractAddress: this.address, entrypoint: '__execute__', calldata: calldata, signature: signature }, {
|
package/dist/account/default.js
CHANGED
|
@@ -99,7 +99,7 @@ var Account = /** @class */ (function (_super) {
|
|
|
99
99
|
Account.prototype.estimateFee = function (calls, _a) {
|
|
100
100
|
var _b = _a === void 0 ? {} : _a, providedNonce = _b.nonce, blockIdentifier = _b.blockIdentifier;
|
|
101
101
|
return __awaiter(this, void 0, void 0, function () {
|
|
102
|
-
var transactions, nonce, _c, version, signerDetails, signature, calldata, response, suggestedMaxFee;
|
|
102
|
+
var transactions, nonce, _c, version, chainId, signerDetails, signature, calldata, response, suggestedMaxFee;
|
|
103
103
|
return __generator(this, function (_d) {
|
|
104
104
|
switch (_d.label) {
|
|
105
105
|
case 0:
|
|
@@ -114,19 +114,22 @@ var Account = /** @class */ (function (_super) {
|
|
|
114
114
|
case 3:
|
|
115
115
|
nonce = _c;
|
|
116
116
|
version = (0, number_1.toBN)(hash_1.feeTransactionVersion);
|
|
117
|
+
return [4 /*yield*/, this.getChainId()];
|
|
118
|
+
case 4:
|
|
119
|
+
chainId = _d.sent();
|
|
117
120
|
signerDetails = {
|
|
118
121
|
walletAddress: this.address,
|
|
119
122
|
nonce: (0, number_1.toBN)(nonce),
|
|
120
123
|
maxFee: constants_1.ZERO,
|
|
121
124
|
version: version,
|
|
122
|
-
chainId:
|
|
125
|
+
chainId: chainId,
|
|
123
126
|
};
|
|
124
127
|
return [4 /*yield*/, this.signer.signTransaction(transactions, signerDetails)];
|
|
125
|
-
case
|
|
128
|
+
case 5:
|
|
126
129
|
signature = _d.sent();
|
|
127
130
|
calldata = (0, transaction_1.fromCallsToExecuteCalldataWithNonce)(transactions, nonce);
|
|
128
131
|
return [4 /*yield*/, _super.prototype.getEstimateFee.call(this, { contractAddress: this.address, entrypoint: '__execute__', calldata: calldata, signature: signature }, blockIdentifier, { version: version })];
|
|
129
|
-
case
|
|
132
|
+
case 6:
|
|
130
133
|
response = _d.sent();
|
|
131
134
|
suggestedMaxFee = (0, stark_1.estimatedFeeToMaxFee)(response.overall_fee);
|
|
132
135
|
return [2 /*return*/, __assign(__assign({}, response), { suggestedMaxFee: suggestedMaxFee })];
|
|
@@ -149,7 +152,7 @@ var Account = /** @class */ (function (_super) {
|
|
|
149
152
|
if (abis === void 0) { abis = undefined; }
|
|
150
153
|
if (transactionsDetail === void 0) { transactionsDetail = {}; }
|
|
151
154
|
return __awaiter(this, void 0, void 0, function () {
|
|
152
|
-
var transactions, nonce, _b, _c, maxFee, suggestedMaxFee, version, signerDetails, signature, calldata;
|
|
155
|
+
var transactions, nonce, _b, _c, maxFee, suggestedMaxFee, version, chainId, signerDetails, signature, calldata;
|
|
153
156
|
return __generator(this, function (_d) {
|
|
154
157
|
switch (_d.label) {
|
|
155
158
|
case 0:
|
|
@@ -175,15 +178,18 @@ var Account = /** @class */ (function (_super) {
|
|
|
175
178
|
_d.label = 6;
|
|
176
179
|
case 6:
|
|
177
180
|
version = (0, number_1.toBN)(hash_1.transactionVersion);
|
|
181
|
+
return [4 /*yield*/, this.getChainId()];
|
|
182
|
+
case 7:
|
|
183
|
+
chainId = _d.sent();
|
|
178
184
|
signerDetails = {
|
|
179
185
|
walletAddress: this.address,
|
|
180
186
|
nonce: nonce,
|
|
181
187
|
maxFee: maxFee,
|
|
182
188
|
version: version,
|
|
183
|
-
chainId:
|
|
189
|
+
chainId: chainId,
|
|
184
190
|
};
|
|
185
191
|
return [4 /*yield*/, this.signer.signTransaction(transactions, signerDetails, abis)];
|
|
186
|
-
case
|
|
192
|
+
case 8:
|
|
187
193
|
signature = _d.sent();
|
|
188
194
|
calldata = (0, transaction_1.fromCallsToExecuteCalldataWithNonce)(transactions, nonce);
|
|
189
195
|
return [2 /*return*/, this.invokeFunction({ contractAddress: this.address, entrypoint: '__execute__', calldata: calldata, signature: signature }, {
|
|
@@ -13,6 +13,7 @@ export declare class Provider implements ProviderInterface {
|
|
|
13
13
|
private provider;
|
|
14
14
|
constructor(providerOrOptions?: ProviderOptions | ProviderInterface);
|
|
15
15
|
get chainId(): StarknetChainId;
|
|
16
|
+
getChainId(): Promise<StarknetChainId>;
|
|
16
17
|
getBlock(blockIdentifier?: BlockIdentifier): Promise<GetBlockResponse>;
|
|
17
18
|
getClassAt(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<ContractClass>;
|
|
18
19
|
getEstimateFee(invocation: Invocation, blockIdentifier?: BlockIdentifier, invocationDetails?: InvocationsDetails): Promise<EstimateFeeResponse>;
|
package/dist/provider/default.js
CHANGED
|
@@ -61,6 +61,13 @@ var Provider = /** @class */ (function () {
|
|
|
61
61
|
enumerable: false,
|
|
62
62
|
configurable: true
|
|
63
63
|
});
|
|
64
|
+
Provider.prototype.getChainId = function () {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
66
|
+
return __generator(this, function (_a) {
|
|
67
|
+
return [2 /*return*/, this.provider.getChainId()];
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
};
|
|
64
71
|
Provider.prototype.getBlock = function (blockIdentifier) {
|
|
65
72
|
if (blockIdentifier === void 0) { blockIdentifier = 'pending'; }
|
|
66
73
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -4,6 +4,12 @@ import type { BigNumberish } from '../utils/number';
|
|
|
4
4
|
import { BlockIdentifier } from './utils';
|
|
5
5
|
export declare abstract class ProviderInterface {
|
|
6
6
|
abstract chainId: StarknetChainId;
|
|
7
|
+
/**
|
|
8
|
+
* Gets the Starknet chain Id
|
|
9
|
+
*
|
|
10
|
+
* @returns the chain Id
|
|
11
|
+
*/
|
|
12
|
+
abstract getChainId(): Promise<StarknetChainId>;
|
|
7
13
|
/**
|
|
8
14
|
* Calls a function on the StarkNet contract.
|
|
9
15
|
*
|
package/dist/provider/rpc.js
CHANGED
|
@@ -235,6 +235,7 @@ var RpcProvider = /** @class */ (function () {
|
|
|
235
235
|
{
|
|
236
236
|
program: contractDefinition.program,
|
|
237
237
|
entry_points_by_type: contractDefinition.entry_points_by_type,
|
|
238
|
+
abi: contractDefinition.abi, // rpc 2.0
|
|
238
239
|
},
|
|
239
240
|
(0, number_1.toHex)((0, number_1.toBN)(version || 0)),
|
|
240
241
|
]).then(this.responseParser.parseDeclareContractResponse)];
|
|
@@ -253,6 +254,7 @@ var RpcProvider = /** @class */ (function () {
|
|
|
253
254
|
{
|
|
254
255
|
program: contractDefinition.program,
|
|
255
256
|
entry_points_by_type: contractDefinition.entry_points_by_type,
|
|
257
|
+
abi: contractDefinition.abi, // rpc 2.0
|
|
256
258
|
},
|
|
257
259
|
]).then(this.responseParser.parseDeployContractResponse)];
|
|
258
260
|
});
|
|
@@ -27,6 +27,7 @@ export declare class SequencerProvider implements ProviderInterface {
|
|
|
27
27
|
private getQueryString;
|
|
28
28
|
private getHeaders;
|
|
29
29
|
protected fetchEndpoint<T extends keyof Sequencer.Endpoints>(endpoint: T, ...[query, request]: Sequencer.Endpoints[T]['QUERY'] extends never ? Sequencer.Endpoints[T]['REQUEST'] extends never ? [] : [undefined, Sequencer.Endpoints[T]['REQUEST']] : Sequencer.Endpoints[T]['REQUEST'] extends never ? [Sequencer.Endpoints[T]['QUERY']] : [Sequencer.Endpoints[T]['QUERY'], Sequencer.Endpoints[T]['REQUEST']]): Promise<Sequencer.Endpoints[T]['RESPONSE']>;
|
|
30
|
+
getChainId(): Promise<StarknetChainId>;
|
|
30
31
|
callContract({ contractAddress, entrypoint: entryPointSelector, calldata }: Call, blockIdentifier?: BlockIdentifier): Promise<CallContractResponse>;
|
|
31
32
|
getBlock(blockIdentifier?: BlockIdentifier): Promise<GetBlockResponse>;
|
|
32
33
|
getStorageAt(contractAddress: string, key: BigNumberish, blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
|
|
@@ -227,6 +227,13 @@ var SequencerProvider = /** @class */ (function () {
|
|
|
227
227
|
});
|
|
228
228
|
});
|
|
229
229
|
};
|
|
230
|
+
SequencerProvider.prototype.getChainId = function () {
|
|
231
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
232
|
+
return __generator(this, function (_a) {
|
|
233
|
+
return [2 /*return*/, Promise.resolve(this.chainId)];
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
};
|
|
230
237
|
SequencerProvider.prototype.callContract = function (_a, blockIdentifier) {
|
|
231
238
|
var contractAddress = _a.contractAddress, entryPointSelector = _a.entrypoint, _b = _a.calldata, calldata = _b === void 0 ? [] : _b;
|
|
232
239
|
if (blockIdentifier === void 0) { blockIdentifier = 'pending'; }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "starknet",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0",
|
|
4
4
|
"description": "JavaScript library for StarkNet",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -85,6 +85,9 @@
|
|
|
85
85
|
],
|
|
86
86
|
"setupFilesAfterEnv": [
|
|
87
87
|
"./__tests__/jest.setup.ts"
|
|
88
|
+
],
|
|
89
|
+
"sandboxInjectedGlobals": [
|
|
90
|
+
"Math"
|
|
88
91
|
]
|
|
89
92
|
},
|
|
90
93
|
"importSort": {
|
package/provider/default.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export declare class Provider implements ProviderInterface {
|
|
|
13
13
|
private provider;
|
|
14
14
|
constructor(providerOrOptions?: ProviderOptions | ProviderInterface);
|
|
15
15
|
get chainId(): StarknetChainId;
|
|
16
|
+
getChainId(): Promise<StarknetChainId>;
|
|
16
17
|
getBlock(blockIdentifier?: BlockIdentifier): Promise<GetBlockResponse>;
|
|
17
18
|
getClassAt(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<ContractClass>;
|
|
18
19
|
getEstimateFee(invocation: Invocation, blockIdentifier?: BlockIdentifier, invocationDetails?: InvocationsDetails): Promise<EstimateFeeResponse>;
|
package/provider/default.js
CHANGED
|
@@ -61,6 +61,13 @@ var Provider = /** @class */ (function () {
|
|
|
61
61
|
enumerable: false,
|
|
62
62
|
configurable: true
|
|
63
63
|
});
|
|
64
|
+
Provider.prototype.getChainId = function () {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
66
|
+
return __generator(this, function (_a) {
|
|
67
|
+
return [2 /*return*/, this.provider.getChainId()];
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
};
|
|
64
71
|
Provider.prototype.getBlock = function (blockIdentifier) {
|
|
65
72
|
if (blockIdentifier === void 0) { blockIdentifier = 'pending'; }
|
|
66
73
|
return __awaiter(this, void 0, void 0, function () {
|
package/provider/interface.d.ts
CHANGED
|
@@ -4,6 +4,12 @@ import type { BigNumberish } from '../utils/number';
|
|
|
4
4
|
import { BlockIdentifier } from './utils';
|
|
5
5
|
export declare abstract class ProviderInterface {
|
|
6
6
|
abstract chainId: StarknetChainId;
|
|
7
|
+
/**
|
|
8
|
+
* Gets the Starknet chain Id
|
|
9
|
+
*
|
|
10
|
+
* @returns the chain Id
|
|
11
|
+
*/
|
|
12
|
+
abstract getChainId(): Promise<StarknetChainId>;
|
|
7
13
|
/**
|
|
8
14
|
* Calls a function on the StarkNet contract.
|
|
9
15
|
*
|
package/provider/rpc.js
CHANGED
|
@@ -235,6 +235,7 @@ var RpcProvider = /** @class */ (function () {
|
|
|
235
235
|
{
|
|
236
236
|
program: contractDefinition.program,
|
|
237
237
|
entry_points_by_type: contractDefinition.entry_points_by_type,
|
|
238
|
+
abi: contractDefinition.abi, // rpc 2.0
|
|
238
239
|
},
|
|
239
240
|
(0, number_1.toHex)((0, number_1.toBN)(version || 0)),
|
|
240
241
|
]).then(this.responseParser.parseDeclareContractResponse)];
|
|
@@ -253,6 +254,7 @@ var RpcProvider = /** @class */ (function () {
|
|
|
253
254
|
{
|
|
254
255
|
program: contractDefinition.program,
|
|
255
256
|
entry_points_by_type: contractDefinition.entry_points_by_type,
|
|
257
|
+
abi: contractDefinition.abi, // rpc 2.0
|
|
256
258
|
},
|
|
257
259
|
]).then(this.responseParser.parseDeployContractResponse)];
|
|
258
260
|
});
|
package/provider/sequencer.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ export declare class SequencerProvider implements ProviderInterface {
|
|
|
27
27
|
private getQueryString;
|
|
28
28
|
private getHeaders;
|
|
29
29
|
protected fetchEndpoint<T extends keyof Sequencer.Endpoints>(endpoint: T, ...[query, request]: Sequencer.Endpoints[T]['QUERY'] extends never ? Sequencer.Endpoints[T]['REQUEST'] extends never ? [] : [undefined, Sequencer.Endpoints[T]['REQUEST']] : Sequencer.Endpoints[T]['REQUEST'] extends never ? [Sequencer.Endpoints[T]['QUERY']] : [Sequencer.Endpoints[T]['QUERY'], Sequencer.Endpoints[T]['REQUEST']]): Promise<Sequencer.Endpoints[T]['RESPONSE']>;
|
|
30
|
+
getChainId(): Promise<StarknetChainId>;
|
|
30
31
|
callContract({ contractAddress, entrypoint: entryPointSelector, calldata }: Call, blockIdentifier?: BlockIdentifier): Promise<CallContractResponse>;
|
|
31
32
|
getBlock(blockIdentifier?: BlockIdentifier): Promise<GetBlockResponse>;
|
|
32
33
|
getStorageAt(contractAddress: string, key: BigNumberish, blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
|
package/provider/sequencer.js
CHANGED
|
@@ -227,6 +227,13 @@ var SequencerProvider = /** @class */ (function () {
|
|
|
227
227
|
});
|
|
228
228
|
});
|
|
229
229
|
};
|
|
230
|
+
SequencerProvider.prototype.getChainId = function () {
|
|
231
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
232
|
+
return __generator(this, function (_a) {
|
|
233
|
+
return [2 /*return*/, Promise.resolve(this.chainId)];
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
};
|
|
230
237
|
SequencerProvider.prototype.callContract = function (_a, blockIdentifier) {
|
|
231
238
|
var contractAddress = _a.contractAddress, entryPointSelector = _a.entrypoint, _b = _a.calldata, calldata = _b === void 0 ? [] : _b;
|
|
232
239
|
if (blockIdentifier === void 0) { blockIdentifier = 'pending'; }
|
package/src/account/default.ts
CHANGED
|
@@ -47,13 +47,14 @@ export class Account extends Provider implements AccountInterface {
|
|
|
47
47
|
const transactions = Array.isArray(calls) ? calls : [calls];
|
|
48
48
|
const nonce = providedNonce ?? (await this.getNonce());
|
|
49
49
|
const version = toBN(feeTransactionVersion);
|
|
50
|
+
const chainId = await this.getChainId();
|
|
50
51
|
|
|
51
52
|
const signerDetails: InvocationsSignerDetails = {
|
|
52
53
|
walletAddress: this.address,
|
|
53
54
|
nonce: toBN(nonce),
|
|
54
55
|
maxFee: ZERO,
|
|
55
56
|
version,
|
|
56
|
-
chainId
|
|
57
|
+
chainId,
|
|
57
58
|
};
|
|
58
59
|
|
|
59
60
|
const signature = await this.signer.signTransaction(transactions, signerDetails);
|
|
@@ -99,13 +100,14 @@ export class Account extends Provider implements AccountInterface {
|
|
|
99
100
|
}
|
|
100
101
|
|
|
101
102
|
const version = toBN(transactionVersion);
|
|
103
|
+
const chainId = await this.getChainId();
|
|
102
104
|
|
|
103
105
|
const signerDetails: InvocationsSignerDetails = {
|
|
104
106
|
walletAddress: this.address,
|
|
105
107
|
nonce,
|
|
106
108
|
maxFee,
|
|
107
109
|
version,
|
|
108
|
-
chainId
|
|
110
|
+
chainId,
|
|
109
111
|
};
|
|
110
112
|
|
|
111
113
|
const signature = await this.signer.signTransaction(transactions, signerDetails, abis);
|
package/src/provider/default.ts
CHANGED
|
@@ -46,6 +46,10 @@ export class Provider implements ProviderInterface {
|
|
|
46
46
|
return this.provider.chainId;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
public async getChainId(): Promise<StarknetChainId> {
|
|
50
|
+
return this.provider.getChainId();
|
|
51
|
+
}
|
|
52
|
+
|
|
49
53
|
public async getBlock(blockIdentifier: BlockIdentifier = 'pending'): Promise<GetBlockResponse> {
|
|
50
54
|
return this.provider.getBlock(blockIdentifier);
|
|
51
55
|
}
|
|
@@ -22,6 +22,13 @@ import { BlockIdentifier } from './utils';
|
|
|
22
22
|
export abstract class ProviderInterface {
|
|
23
23
|
public abstract chainId: StarknetChainId;
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Gets the Starknet chain Id
|
|
27
|
+
*
|
|
28
|
+
* @returns the chain Id
|
|
29
|
+
*/
|
|
30
|
+
public abstract getChainId(): Promise<StarknetChainId>;
|
|
31
|
+
|
|
25
32
|
/**
|
|
26
33
|
* Calls a function on the StarkNet contract.
|
|
27
34
|
*
|
package/src/provider/rpc.ts
CHANGED
|
@@ -188,6 +188,7 @@ export class RpcProvider implements ProviderInterface {
|
|
|
188
188
|
{
|
|
189
189
|
program: contractDefinition.program,
|
|
190
190
|
entry_points_by_type: contractDefinition.entry_points_by_type,
|
|
191
|
+
abi: contractDefinition.abi, // rpc 2.0
|
|
191
192
|
},
|
|
192
193
|
toHex(toBN(version || 0)),
|
|
193
194
|
]).then(this.responseParser.parseDeclareContractResponse);
|
|
@@ -206,6 +207,7 @@ export class RpcProvider implements ProviderInterface {
|
|
|
206
207
|
{
|
|
207
208
|
program: contractDefinition.program,
|
|
208
209
|
entry_points_by_type: contractDefinition.entry_points_by_type,
|
|
210
|
+
abi: contractDefinition.abi, // rpc 2.0
|
|
209
211
|
},
|
|
210
212
|
]).then(this.responseParser.parseDeployContractResponse);
|
|
211
213
|
}
|
|
@@ -207,6 +207,10 @@ export class SequencerProvider implements ProviderInterface {
|
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
+
public async getChainId(): Promise<StarknetChainId> {
|
|
211
|
+
return Promise.resolve(this.chainId);
|
|
212
|
+
}
|
|
213
|
+
|
|
210
214
|
public async callContract(
|
|
211
215
|
{ contractAddress, entrypoint: entryPointSelector, calldata = [] }: Call,
|
|
212
216
|
blockIdentifier: BlockIdentifier = 'pending'
|