starknet 4.8.0 → 4.10.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 +46 -0
- package/README.md +1 -3
- package/__mocks__/ERC20.json +32561 -29055
- package/__tests__/account.test.ts +32 -24
- package/__tests__/contract.test.ts +25 -14
- package/__tests__/defaultProvider.test.ts +91 -240
- package/__tests__/fixtures.ts +10 -2
- package/__tests__/rpcProvider.test.ts +8 -16
- package/__tests__/sequencerProvider.test.ts +17 -10
- package/__tests__/udc.test.ts +41 -0
- package/__tests__/utils/merkle.test.ts +98 -3
- package/__tests__/utils/typedData.test.ts +3 -3
- package/account/default.d.ts +12 -44
- package/account/default.js +305 -61
- package/account/interface.d.ts +96 -8
- package/constants.d.ts +8 -1
- package/constants.js +8 -1
- package/contract/default.d.ts +11 -27
- package/contract/default.js +105 -121
- package/contract/interface.d.ts +5 -2
- package/dist/account/default.d.ts +12 -44
- package/dist/account/default.js +305 -61
- package/dist/account/interface.d.ts +96 -8
- package/dist/constants.d.ts +8 -1
- package/dist/constants.js +8 -1
- package/dist/contract/default.d.ts +11 -27
- package/dist/contract/default.js +105 -121
- package/dist/contract/interface.d.ts +5 -2
- package/dist/provider/default.d.ts +8 -3
- package/dist/provider/default.js +31 -4
- package/dist/provider/interface.d.ts +67 -5
- package/dist/provider/rpc.d.ts +10 -3
- package/dist/provider/rpc.js +98 -10
- package/dist/provider/sequencer.d.ts +11 -4
- package/dist/provider/sequencer.js +89 -18
- package/dist/signer/default.d.ts +5 -2
- package/dist/signer/default.js +25 -3
- package/dist/signer/interface.d.ts +29 -2
- package/dist/types/api/index.d.ts +0 -6
- package/dist/types/api/openrpc.d.ts +24 -2
- package/dist/types/api/sequencer.d.ts +22 -7
- package/dist/types/index.d.ts +1 -1
- package/dist/types/lib.d.ts +36 -2
- package/dist/types/provider.d.ts +15 -10
- package/dist/types/signer.d.ts +14 -1
- package/dist/utils/hash.d.ts +2 -0
- package/dist/utils/hash.js +13 -2
- package/dist/utils/merkle.js +2 -4
- package/dist/utils/number.d.ts +1 -0
- package/dist/utils/number.js +3 -1
- package/dist/utils/responseParser/rpc.d.ts +2 -6
- package/dist/utils/responseParser/rpc.js +0 -11
- package/dist/utils/responseParser/sequencer.js +4 -14
- package/package.json +1 -1
- package/provider/default.d.ts +8 -3
- package/provider/default.js +31 -4
- package/provider/interface.d.ts +67 -5
- package/provider/rpc.d.ts +10 -3
- package/provider/rpc.js +98 -10
- package/provider/sequencer.d.ts +11 -4
- package/provider/sequencer.js +89 -18
- package/signer/default.d.ts +5 -2
- package/signer/default.js +25 -3
- package/signer/interface.d.ts +29 -2
- package/src/account/default.ts +243 -55
- package/src/account/interface.ts +132 -7
- package/src/constants.ts +8 -0
- package/src/contract/default.ts +124 -141
- package/src/contract/interface.ts +5 -2
- package/src/provider/default.ts +43 -5
- package/src/provider/interface.ts +92 -7
- package/src/provider/rpc.ts +93 -15
- package/src/provider/sequencer.ts +87 -14
- package/src/signer/default.ts +56 -4
- package/src/signer/interface.ts +33 -2
- package/src/types/api/index.ts +0 -4
- package/src/types/api/openrpc.ts +28 -2
- package/src/types/api/sequencer.ts +32 -9
- package/src/types/index.ts +1 -1
- package/src/types/lib.ts +43 -2
- package/src/types/provider.ts +27 -11
- package/src/types/signer.ts +18 -1
- package/src/utils/hash.ts +46 -1
- package/src/utils/merkle.ts +2 -4
- package/src/utils/number.ts +2 -0
- package/src/utils/responseParser/rpc.ts +4 -20
- package/src/utils/responseParser/sequencer.ts +2 -0
- package/types/api/index.d.ts +0 -6
- package/types/api/openrpc.d.ts +24 -2
- package/types/api/sequencer.d.ts +22 -7
- package/types/index.d.ts +1 -1
- package/types/lib.d.ts +36 -2
- package/types/provider.d.ts +15 -10
- package/types/signer.d.ts +14 -1
- package/utils/hash.d.ts +2 -0
- package/utils/hash.js +13 -2
- package/utils/merkle.js +2 -4
- package/utils/number.d.ts +1 -0
- package/utils/number.js +3 -1
- package/utils/responseParser/rpc.d.ts +2 -6
- package/utils/responseParser/rpc.js +0 -11
- package/utils/responseParser/sequencer.js +4 -14
- package/www/docs/API/account.md +170 -11
- package/www/docs/API/contract.md +39 -3
- package/www/docs/API/provider.md +310 -17
- package/www/docs/API/signer.md +56 -2
- package/www/guides/erc20.md +13 -7
package/contract/default.d.ts
CHANGED
|
@@ -33,25 +33,22 @@ export declare class Contract implements ContractInterface {
|
|
|
33
33
|
* @param providerOrAccount (optional) - Provider or Account to attach to
|
|
34
34
|
*/
|
|
35
35
|
constructor(abi: Abi, address: string, providerOrAccount?: ProviderInterface | AccountInterface);
|
|
36
|
-
/**
|
|
37
|
-
* Saves the address of the contract deployed on network that will be used for interaction
|
|
38
|
-
*
|
|
39
|
-
* @param address - address of the contract
|
|
40
|
-
*/
|
|
41
36
|
attach(address: string): void;
|
|
42
|
-
/**
|
|
43
|
-
* Attaches to new Provider or Account
|
|
44
|
-
*
|
|
45
|
-
* @param providerOrAccount - new Provider or Account to attach to
|
|
46
|
-
*/
|
|
47
37
|
connect(providerOrAccount: ProviderInterface | AccountInterface): void;
|
|
38
|
+
deployed(): Promise<Contract>;
|
|
39
|
+
call(method: string, args?: Array<any>, { blockIdentifier, }?: {
|
|
40
|
+
blockIdentifier?: BlockIdentifier;
|
|
41
|
+
}): Promise<Result>;
|
|
42
|
+
invoke(method: string, args?: Array<any>, options?: Overrides): Promise<InvokeFunctionResponse>;
|
|
43
|
+
estimate(method: string, args?: Array<any>): Promise<import("../types").EstimateFeeResponse>;
|
|
44
|
+
populate(method: string, args?: Array<any>): Call;
|
|
48
45
|
/**
|
|
49
|
-
*
|
|
46
|
+
* Deep parse of the object that has been passed to the method
|
|
50
47
|
*
|
|
51
|
-
* @
|
|
52
|
-
* @
|
|
48
|
+
* @param struct - struct that needs to be calculated
|
|
49
|
+
* @return {number} - number of members for the given struct
|
|
53
50
|
*/
|
|
54
|
-
|
|
51
|
+
private calculateStructMembers;
|
|
55
52
|
/**
|
|
56
53
|
* Validates if all arguments that are passed to the method are corresponding to the ones in the abi
|
|
57
54
|
*
|
|
@@ -60,13 +57,6 @@ export declare class Contract implements ContractInterface {
|
|
|
60
57
|
* @param args - arguments that are passed to the method
|
|
61
58
|
*/
|
|
62
59
|
protected validateMethodAndArgs(type: 'INVOKE' | 'CALL', method: string, args?: Array<any>): void;
|
|
63
|
-
/**
|
|
64
|
-
* Deep parse of the object that has been passed to the method
|
|
65
|
-
*
|
|
66
|
-
* @param struct - struct that needs to be calculated
|
|
67
|
-
* @return {number} - number of members for the given struct
|
|
68
|
-
*/
|
|
69
|
-
private calculateStructMembers;
|
|
70
60
|
/**
|
|
71
61
|
* Deep parse of the object that has been passed to the method
|
|
72
62
|
*
|
|
@@ -115,10 +105,4 @@ export declare class Contract implements ContractInterface {
|
|
|
115
105
|
* @return - parsed response corresponding to the abi
|
|
116
106
|
*/
|
|
117
107
|
protected parseResponse(method: string, response: string[]): Result;
|
|
118
|
-
invoke(method: string, args?: Array<any>, options?: Overrides): Promise<InvokeFunctionResponse>;
|
|
119
|
-
call(method: string, args?: Array<any>, { blockIdentifier, }?: {
|
|
120
|
-
blockIdentifier?: BlockIdentifier;
|
|
121
|
-
}): Promise<Result>;
|
|
122
|
-
estimate(method: string, args?: Array<any>): Promise<import("../types").EstimateFeeResponse>;
|
|
123
|
-
populate(method: string, args?: Array<any>): Call;
|
|
124
108
|
}
|
package/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.toLowerCase();
|
|
184
|
+
this.address = address && address.toLowerCase();
|
|
185
185
|
this.providerOrAccount = providerOrAccount;
|
|
186
186
|
this.abi = abi;
|
|
187
187
|
this.structs = abi
|
|
@@ -252,28 +252,12 @@ var Contract = /** @class */ (function () {
|
|
|
252
252
|
}
|
|
253
253
|
});
|
|
254
254
|
}
|
|
255
|
-
/**
|
|
256
|
-
* Saves the address of the contract deployed on network that will be used for interaction
|
|
257
|
-
*
|
|
258
|
-
* @param address - address of the contract
|
|
259
|
-
*/
|
|
260
255
|
Contract.prototype.attach = function (address) {
|
|
261
256
|
this.address = address;
|
|
262
257
|
};
|
|
263
|
-
/**
|
|
264
|
-
* Attaches to new Provider or Account
|
|
265
|
-
*
|
|
266
|
-
* @param providerOrAccount - new Provider or Account to attach to
|
|
267
|
-
*/
|
|
268
258
|
Contract.prototype.connect = function (providerOrAccount) {
|
|
269
259
|
this.providerOrAccount = providerOrAccount;
|
|
270
260
|
};
|
|
271
|
-
/**
|
|
272
|
-
* Resolves when contract is deployed on the network or when no deployment transaction is found
|
|
273
|
-
*
|
|
274
|
-
* @returns Promise that resolves when contract is deployed on the network or when no deployment transaction is found
|
|
275
|
-
* @throws When deployment fails
|
|
276
|
-
*/
|
|
277
261
|
Contract.prototype.deployed = function () {
|
|
278
262
|
return __awaiter(this, void 0, void 0, function () {
|
|
279
263
|
return __generator(this, function (_a) {
|
|
@@ -290,6 +274,110 @@ var Contract = /** @class */ (function () {
|
|
|
290
274
|
});
|
|
291
275
|
});
|
|
292
276
|
};
|
|
277
|
+
Contract.prototype.call = function (method, args, _a) {
|
|
278
|
+
if (args === void 0) { args = []; }
|
|
279
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.blockIdentifier, blockIdentifier = _c === void 0 ? 'pending' : _c;
|
|
280
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
281
|
+
var inputs, calldata;
|
|
282
|
+
var _this = this;
|
|
283
|
+
return __generator(this, function (_d) {
|
|
284
|
+
// ensure contract is connected
|
|
285
|
+
(0, minimalistic_assert_1.default)(this.address !== null, 'contract is not connected to an address');
|
|
286
|
+
// validate method and args
|
|
287
|
+
this.validateMethodAndArgs('CALL', method, args);
|
|
288
|
+
inputs = this.abi.find(function (abi) { return abi.name === method; }).inputs;
|
|
289
|
+
calldata = this.compileCalldata(args, inputs);
|
|
290
|
+
return [2 /*return*/, this.providerOrAccount
|
|
291
|
+
.callContract({
|
|
292
|
+
contractAddress: this.address,
|
|
293
|
+
calldata: calldata,
|
|
294
|
+
entrypoint: method,
|
|
295
|
+
}, blockIdentifier)
|
|
296
|
+
.then(function (x) { return _this.parseResponse(method, x.result); })];
|
|
297
|
+
});
|
|
298
|
+
});
|
|
299
|
+
};
|
|
300
|
+
Contract.prototype.invoke = function (method, args, options) {
|
|
301
|
+
if (args === void 0) { args = []; }
|
|
302
|
+
if (options === void 0) { options = {}; }
|
|
303
|
+
// ensure contract is connected
|
|
304
|
+
(0, minimalistic_assert_1.default)(this.address !== null, 'contract is not connected to an address');
|
|
305
|
+
// validate method and args
|
|
306
|
+
this.validateMethodAndArgs('INVOKE', method, args);
|
|
307
|
+
var inputs = this.abi.find(function (abi) { return abi.name === method; }).inputs;
|
|
308
|
+
var inputsLength = inputs.reduce(function (acc, input) {
|
|
309
|
+
if (!/_len$/.test(input.name)) {
|
|
310
|
+
return acc + 1;
|
|
311
|
+
}
|
|
312
|
+
return acc;
|
|
313
|
+
}, 0);
|
|
314
|
+
if (args.length !== inputsLength) {
|
|
315
|
+
throw Error("Invalid number of arguments, expected ".concat(inputsLength, " arguments, but got ").concat(args.length));
|
|
316
|
+
}
|
|
317
|
+
// compile calldata
|
|
318
|
+
var calldata = this.compileCalldata(args, inputs);
|
|
319
|
+
var invocation = {
|
|
320
|
+
contractAddress: this.address,
|
|
321
|
+
calldata: calldata,
|
|
322
|
+
entrypoint: method,
|
|
323
|
+
};
|
|
324
|
+
if ('execute' in this.providerOrAccount) {
|
|
325
|
+
return this.providerOrAccount.execute(invocation, undefined, {
|
|
326
|
+
maxFee: options.maxFee,
|
|
327
|
+
nonce: options.nonce,
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
if (!options.nonce) {
|
|
331
|
+
throw new Error("Nonce is required when invoking a function without an account");
|
|
332
|
+
}
|
|
333
|
+
// eslint-disable-next-line no-console
|
|
334
|
+
console.warn("Invoking ".concat(method, " without an account. This will not work on a public node."));
|
|
335
|
+
return this.providerOrAccount.invokeFunction(__assign(__assign({}, invocation), { signature: options.signature || [] }), {
|
|
336
|
+
nonce: options.nonce,
|
|
337
|
+
});
|
|
338
|
+
};
|
|
339
|
+
Contract.prototype.estimate = function (method, args) {
|
|
340
|
+
if (args === void 0) { args = []; }
|
|
341
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
342
|
+
var invocation;
|
|
343
|
+
var _a;
|
|
344
|
+
return __generator(this, function (_b) {
|
|
345
|
+
// ensure contract is connected
|
|
346
|
+
(0, minimalistic_assert_1.default)(this.address !== null, 'contract is not connected to an address');
|
|
347
|
+
// validate method and args
|
|
348
|
+
this.validateMethodAndArgs('INVOKE', method, args);
|
|
349
|
+
invocation = (_a = this.populateTransaction)[method].apply(_a, __spreadArray([], __read(args), false));
|
|
350
|
+
if ('estimateInvokeFee' in this.providerOrAccount) {
|
|
351
|
+
return [2 /*return*/, this.providerOrAccount.estimateInvokeFee(invocation)];
|
|
352
|
+
}
|
|
353
|
+
throw Error('Contract must be connected to the account contract to estimate');
|
|
354
|
+
});
|
|
355
|
+
});
|
|
356
|
+
};
|
|
357
|
+
Contract.prototype.populate = function (method, args) {
|
|
358
|
+
if (args === void 0) { args = []; }
|
|
359
|
+
var inputs = this.abi.find(function (abi) { return abi.name === method; }).inputs;
|
|
360
|
+
return {
|
|
361
|
+
contractAddress: this.address,
|
|
362
|
+
entrypoint: method,
|
|
363
|
+
calldata: this.compileCalldata(args, inputs),
|
|
364
|
+
};
|
|
365
|
+
};
|
|
366
|
+
/**
|
|
367
|
+
* Deep parse of the object that has been passed to the method
|
|
368
|
+
*
|
|
369
|
+
* @param struct - struct that needs to be calculated
|
|
370
|
+
* @return {number} - number of members for the given struct
|
|
371
|
+
*/
|
|
372
|
+
Contract.prototype.calculateStructMembers = function (struct) {
|
|
373
|
+
var _this = this;
|
|
374
|
+
return this.structs[struct].members.reduce(function (acc, member) {
|
|
375
|
+
if (member.type === 'felt') {
|
|
376
|
+
return acc + 1;
|
|
377
|
+
}
|
|
378
|
+
return acc + _this.calculateStructMembers(member.type);
|
|
379
|
+
}, 0);
|
|
380
|
+
};
|
|
293
381
|
/**
|
|
294
382
|
* Validates if all arguments that are passed to the method are corresponding to the ones in the abi
|
|
295
383
|
*
|
|
@@ -371,21 +459,6 @@ var Contract = /** @class */ (function () {
|
|
|
371
459
|
}
|
|
372
460
|
});
|
|
373
461
|
};
|
|
374
|
-
/**
|
|
375
|
-
* Deep parse of the object that has been passed to the method
|
|
376
|
-
*
|
|
377
|
-
* @param struct - struct that needs to be calculated
|
|
378
|
-
* @return {number} - number of members for the given struct
|
|
379
|
-
*/
|
|
380
|
-
Contract.prototype.calculateStructMembers = function (struct) {
|
|
381
|
-
var _this = this;
|
|
382
|
-
return this.structs[struct].members.reduce(function (acc, member) {
|
|
383
|
-
if (member.type === 'felt') {
|
|
384
|
-
return acc + 1;
|
|
385
|
-
}
|
|
386
|
-
return acc + _this.calculateStructMembers(member.type);
|
|
387
|
-
}, 0);
|
|
388
|
-
};
|
|
389
462
|
/**
|
|
390
463
|
* Deep parse of the object that has been passed to the method
|
|
391
464
|
*
|
|
@@ -562,95 +635,6 @@ var Contract = /** @class */ (function () {
|
|
|
562
635
|
return acc;
|
|
563
636
|
}, []);
|
|
564
637
|
};
|
|
565
|
-
Contract.prototype.invoke = function (method, args, options) {
|
|
566
|
-
if (args === void 0) { args = []; }
|
|
567
|
-
if (options === void 0) { options = {}; }
|
|
568
|
-
// ensure contract is connected
|
|
569
|
-
(0, minimalistic_assert_1.default)(this.address !== null, 'contract isnt connected to an address');
|
|
570
|
-
// validate method and args
|
|
571
|
-
this.validateMethodAndArgs('INVOKE', method, args);
|
|
572
|
-
var inputs = this.abi.find(function (abi) { return abi.name === method; }).inputs;
|
|
573
|
-
var inputsLength = inputs.reduce(function (acc, input) {
|
|
574
|
-
if (!/_len$/.test(input.name)) {
|
|
575
|
-
return acc + 1;
|
|
576
|
-
}
|
|
577
|
-
return acc;
|
|
578
|
-
}, 0);
|
|
579
|
-
if (args.length !== inputsLength) {
|
|
580
|
-
throw Error("Invalid number of arguments, expected ".concat(inputsLength, " arguments, but got ").concat(args.length));
|
|
581
|
-
}
|
|
582
|
-
// compile calldata
|
|
583
|
-
var calldata = this.compileCalldata(args, inputs);
|
|
584
|
-
var invocation = {
|
|
585
|
-
contractAddress: this.address,
|
|
586
|
-
calldata: calldata,
|
|
587
|
-
entrypoint: method,
|
|
588
|
-
};
|
|
589
|
-
if ('execute' in this.providerOrAccount) {
|
|
590
|
-
return this.providerOrAccount.execute(invocation, undefined, {
|
|
591
|
-
maxFee: options.maxFee,
|
|
592
|
-
nonce: options.nonce,
|
|
593
|
-
});
|
|
594
|
-
}
|
|
595
|
-
if (!options.nonce) {
|
|
596
|
-
throw new Error("Nonce is required when invoking a function without an account");
|
|
597
|
-
}
|
|
598
|
-
// eslint-disable-next-line no-console
|
|
599
|
-
console.warn("Invoking ".concat(method, " without an account. This will not work on a public node."));
|
|
600
|
-
return this.providerOrAccount.invokeFunction(__assign(__assign({}, invocation), { signature: options.signature || [] }), {
|
|
601
|
-
nonce: options.nonce,
|
|
602
|
-
});
|
|
603
|
-
};
|
|
604
|
-
Contract.prototype.call = function (method, args, _a) {
|
|
605
|
-
if (args === void 0) { args = []; }
|
|
606
|
-
var _b = _a === void 0 ? {} : _a, _c = _b.blockIdentifier, blockIdentifier = _c === void 0 ? 'pending' : _c;
|
|
607
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
608
|
-
var inputs, calldata;
|
|
609
|
-
var _this = this;
|
|
610
|
-
return __generator(this, function (_d) {
|
|
611
|
-
// ensure contract is connected
|
|
612
|
-
(0, minimalistic_assert_1.default)(this.address !== null, 'contract isnt connected to an address');
|
|
613
|
-
// validate method and args
|
|
614
|
-
this.validateMethodAndArgs('CALL', method, args);
|
|
615
|
-
inputs = this.abi.find(function (abi) { return abi.name === method; }).inputs;
|
|
616
|
-
calldata = this.compileCalldata(args, inputs);
|
|
617
|
-
return [2 /*return*/, this.providerOrAccount
|
|
618
|
-
.callContract({
|
|
619
|
-
contractAddress: this.address,
|
|
620
|
-
calldata: calldata,
|
|
621
|
-
entrypoint: method,
|
|
622
|
-
}, blockIdentifier)
|
|
623
|
-
.then(function (x) { return _this.parseResponse(method, x.result); })];
|
|
624
|
-
});
|
|
625
|
-
});
|
|
626
|
-
};
|
|
627
|
-
Contract.prototype.estimate = function (method, args) {
|
|
628
|
-
if (args === void 0) { args = []; }
|
|
629
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
630
|
-
var invocation;
|
|
631
|
-
var _a;
|
|
632
|
-
return __generator(this, function (_b) {
|
|
633
|
-
// ensure contract is connected
|
|
634
|
-
(0, minimalistic_assert_1.default)(this.address !== null, 'contract isnt connected to an address');
|
|
635
|
-
// validate method and args
|
|
636
|
-
this.validateMethodAndArgs('INVOKE', method, args);
|
|
637
|
-
invocation = (_a = this.populateTransaction)[method].apply(_a, __spreadArray([], __read(args), false));
|
|
638
|
-
if ('estimateFee' in this.providerOrAccount) {
|
|
639
|
-
return [2 /*return*/, this.providerOrAccount.estimateFee(invocation)];
|
|
640
|
-
}
|
|
641
|
-
throw Error('Contract must be connected to the account contract to estimate');
|
|
642
|
-
});
|
|
643
|
-
});
|
|
644
|
-
};
|
|
645
|
-
Contract.prototype.populate = function (method, args) {
|
|
646
|
-
if (args === void 0) { args = []; }
|
|
647
|
-
var inputs = this.abi.find(function (abi) { return abi.name === method; }).inputs;
|
|
648
|
-
return {
|
|
649
|
-
contractAddress: this.address,
|
|
650
|
-
entrypoint: method,
|
|
651
|
-
calldata: this.compileCalldata(args, inputs),
|
|
652
|
-
};
|
|
653
|
-
};
|
|
654
638
|
return Contract;
|
|
655
639
|
}());
|
|
656
640
|
exports.Contract = Contract;
|
package/contract/interface.d.ts
CHANGED
|
@@ -44,6 +44,7 @@ export declare abstract class ContractInterface {
|
|
|
44
44
|
*
|
|
45
45
|
* @param method name of the method
|
|
46
46
|
* @param args Array of the arguments for the call
|
|
47
|
+
* @param options optional blockIdentifier
|
|
47
48
|
* @returns Result of the call as an array with key value pars
|
|
48
49
|
*/
|
|
49
50
|
abstract call(method: string, args?: Array<any>, options?: {
|
|
@@ -54,14 +55,16 @@ export declare abstract class ContractInterface {
|
|
|
54
55
|
*
|
|
55
56
|
* @param method name of the method
|
|
56
57
|
* @param args Array of the arguments for the invoke
|
|
58
|
+
* @param options
|
|
57
59
|
* @returns Add Transaction Response
|
|
58
60
|
*/
|
|
59
61
|
abstract invoke(method: string, args?: Array<any>, options?: Overrides): Promise<InvokeFunctionResponse>;
|
|
60
62
|
/**
|
|
61
|
-
*
|
|
63
|
+
* Estimates a method on a contract
|
|
62
64
|
*
|
|
63
65
|
* @param method name of the method
|
|
64
66
|
* @param args Array of the arguments for the call
|
|
67
|
+
* @param options optional blockIdentifier
|
|
65
68
|
*/
|
|
66
69
|
abstract estimate(method: string, args?: Array<any>, options?: {
|
|
67
70
|
blockIdentifier?: BlockIdentifier;
|
|
@@ -71,7 +74,7 @@ export declare abstract class ContractInterface {
|
|
|
71
74
|
*
|
|
72
75
|
* @param method name of the method
|
|
73
76
|
* @param args Array of the arguments for the call
|
|
74
|
-
* @returns Invocation
|
|
77
|
+
* @returns Invocation object
|
|
75
78
|
*/
|
|
76
79
|
abstract populate(method: string, args?: Array<any>): Invocation;
|
|
77
80
|
}
|
|
@@ -2,8 +2,9 @@ import { ProviderInterface, ProviderOptions } from '../provider';
|
|
|
2
2
|
import { Provider } from '../provider/default';
|
|
3
3
|
import { BlockIdentifier } from '../provider/utils';
|
|
4
4
|
import { SignerInterface } from '../signer';
|
|
5
|
-
import { Abi, Call, InvocationsDetails, InvokeFunctionResponse, KeyPair, Signature } from '../types';
|
|
5
|
+
import { Abi, Call, DeclareContractResponse, DeployContractResponse, EstimateFeeAction, InvocationsDetails, InvokeFunctionResponse, KeyPair, Signature } from '../types';
|
|
6
6
|
import { EstimateFee, EstimateFeeDetails } from '../types/account';
|
|
7
|
+
import { AllowArray, DeclareContractPayload, DeployAccountContractPayload, UniversalDeployerContractPayload } from '../types/lib';
|
|
7
8
|
import { BigNumberish } from '../utils/number';
|
|
8
9
|
import { TypedData } from '../utils/typedData';
|
|
9
10
|
import { AccountInterface } from './interface';
|
|
@@ -12,51 +13,18 @@ export declare class Account extends Provider implements AccountInterface {
|
|
|
12
13
|
address: string;
|
|
13
14
|
constructor(providerOrOptions: ProviderOptions | ProviderInterface, address: string, keyPairOrSigner: KeyPair | SignerInterface);
|
|
14
15
|
getNonce(blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
|
|
15
|
-
estimateFee(calls: Call
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
* @returns a confirmation of invoking a function on the starknet contract
|
|
25
|
-
*/
|
|
26
|
-
execute(calls: Call | Call[], abis?: Abi[] | undefined, transactionsDetail?: InvocationsDetails): Promise<InvokeFunctionResponse>;
|
|
27
|
-
/**
|
|
28
|
-
* Sign an JSON object with the starknet private key and return the signature
|
|
29
|
-
*
|
|
30
|
-
* @param json - JSON object to be signed
|
|
31
|
-
* @returns the signature of the JSON object
|
|
32
|
-
* @throws {Error} if the JSON object is not a valid JSON
|
|
33
|
-
*/
|
|
16
|
+
estimateFee(calls: AllowArray<Call>, estimateFeeDetails?: EstimateFeeDetails | undefined): Promise<EstimateFee>;
|
|
17
|
+
estimateInvokeFee(calls: AllowArray<Call>, { nonce: providedNonce, blockIdentifier }?: EstimateFeeDetails): Promise<EstimateFee>;
|
|
18
|
+
estimateDeclareFee({ classHash, contract }: DeclareContractPayload, { blockIdentifier, nonce: providedNonce }?: EstimateFeeDetails): Promise<EstimateFee>;
|
|
19
|
+
estimateAccountDeployFee({ classHash, addressSalt, constructorCalldata, contractAddress: providedContractAddress, }: DeployAccountContractPayload, { blockIdentifier, nonce: providedNonce }?: EstimateFeeDetails): Promise<EstimateFee>;
|
|
20
|
+
execute(calls: AllowArray<Call>, abis?: Abi[] | undefined, transactionsDetail?: InvocationsDetails): Promise<InvokeFunctionResponse>;
|
|
21
|
+
declare({ classHash, contract }: DeclareContractPayload, transactionsDetail?: InvocationsDetails): Promise<DeclareContractResponse>;
|
|
22
|
+
deploy({ classHash, salt, unique, constructorCalldata, isDevnet, }: UniversalDeployerContractPayload, additionalCalls?: AllowArray<Call>, // support multicall
|
|
23
|
+
transactionsDetail?: InvocationsDetails): Promise<InvokeFunctionResponse>;
|
|
24
|
+
deployAccount({ classHash, constructorCalldata, addressSalt, contractAddress: providedContractAddress, }: DeployAccountContractPayload, transactionsDetail?: InvocationsDetails): Promise<DeployContractResponse>;
|
|
34
25
|
signMessage(typedData: TypedData): Promise<Signature>;
|
|
35
|
-
/**
|
|
36
|
-
* Hash a JSON object with pederson hash and return the hash
|
|
37
|
-
*
|
|
38
|
-
* @param json - JSON object to be hashed
|
|
39
|
-
* @returns the hash of the JSON object
|
|
40
|
-
* @throws {Error} if the JSON object is not a valid JSON
|
|
41
|
-
*/
|
|
42
26
|
hashMessage(typedData: TypedData): Promise<string>;
|
|
43
|
-
/**
|
|
44
|
-
* Verify a signature of a given hash
|
|
45
|
-
* @warning This method is not recommended, use verifyMessage instead
|
|
46
|
-
*
|
|
47
|
-
* @param hash - JSON object to be verified
|
|
48
|
-
* @param signature - signature of the JSON object
|
|
49
|
-
* @returns true if the signature is valid, false otherwise
|
|
50
|
-
* @throws {Error} if the JSON object is not a valid JSON or the signature is not a valid signature
|
|
51
|
-
*/
|
|
52
27
|
verifyMessageHash(hash: BigNumberish, signature: Signature): Promise<boolean>;
|
|
53
|
-
/**
|
|
54
|
-
* Verify a signature of a JSON object
|
|
55
|
-
*
|
|
56
|
-
* @param hash - hash to be verified
|
|
57
|
-
* @param signature - signature of the hash
|
|
58
|
-
* @returns true if the signature is valid, false otherwise
|
|
59
|
-
* @throws {Error} if the signature is not a valid signature
|
|
60
|
-
*/
|
|
61
28
|
verifyMessage(typedData: TypedData, signature: Signature): Promise<boolean>;
|
|
29
|
+
getSuggestedMaxFee(estimateFeeAction: EstimateFeeAction, details: EstimateFeeDetails): Promise<string>;
|
|
62
30
|
}
|