starknet 3.1.0 → 3.4.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 +19 -0
- package/__mocks__/ArgentAccount.json +68548 -51944
- package/__mocks__/TestDapp.json +12962 -0
- package/__tests__/account.test.ts +63 -50
- package/__tests__/accountContract.test.ts +51 -71
- package/__tests__/contract.test.ts +32 -20
- package/__tests__/fixtures.ts +13 -0
- package/__tests__/provider.test.ts +3 -15
- package/__tests__/utils/__snapshots__/utils.browser.test.ts.snap +2 -2
- package/__tests__/utils/__snapshots__/utils.test.ts.snap +2 -2
- package/__tests__/utils/ellipticalCurve.test.ts +20 -13
- package/__tests__/utils/utils.test.ts +3 -3
- package/account/default.d.ts +10 -4
- package/account/default.js +165 -84
- package/account/interface.d.ts +2 -2
- package/dist/account/default.d.ts +8 -3
- package/dist/account/default.js +129 -55
- package/dist/account/interface.d.ts +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/provider/default.d.ts +6 -4
- package/dist/provider/default.js +42 -17
- package/dist/provider/interface.d.ts +5 -1
- package/dist/signer/default.d.ts +1 -1
- package/dist/signer/default.js +6 -18
- package/dist/signer/interface.d.ts +3 -2
- package/dist/types/api.d.ts +5 -0
- package/dist/types/lib.d.ts +3 -3
- package/dist/utils/ellipticCurve.js +1 -1
- package/dist/utils/hash.d.ts +12 -2
- package/dist/utils/hash.js +37 -9
- package/dist/utils/stark.d.ts +0 -8
- package/dist/utils/stark.js +1 -14
- package/dist/utils/transaction.d.ts +19 -0
- package/dist/utils/transaction.js +75 -0
- package/dist/utils/typedData/index.d.ts +1 -1
- package/dist/utils/typedData/index.js +2 -3
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +1 -1
- package/provider/default.d.ts +6 -4
- package/provider/default.js +55 -19
- package/provider/interface.d.ts +5 -1
- package/signer/default.d.ts +1 -1
- package/signer/default.js +10 -44
- package/signer/interface.d.ts +3 -2
- package/src/account/default.ts +129 -42
- package/src/account/interface.ts +2 -2
- package/src/index.ts +1 -0
- package/src/provider/default.ts +32 -22
- package/src/provider/interface.ts +6 -1
- package/src/signer/default.ts +10 -26
- package/src/signer/interface.ts +3 -2
- package/src/types/api.ts +5 -0
- package/src/types/lib.ts +3 -4
- package/src/utils/ellipticCurve.ts +1 -1
- package/src/utils/hash.ts +39 -12
- package/src/utils/stark.ts +1 -14
- package/src/utils/transaction.ts +50 -0
- package/src/utils/typedData/index.ts +2 -3
- package/types/api.d.ts +5 -0
- package/types/lib.d.ts +3 -3
- package/utils/ellipticCurve.js +1 -1
- package/utils/hash.d.ts +15 -6
- package/utils/hash.js +42 -10
- package/utils/stark.d.ts +0 -8
- package/utils/stark.js +0 -14
- package/utils/transaction.d.ts +19 -0
- package/utils/transaction.js +99 -0
- package/utils/typedData/index.d.ts +1 -1
- package/utils/typedData/index.js +2 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ec, getKeyPair, getStarkKey, sign, verify } from '../../src/utils/ellipticCurve';
|
|
2
2
|
import { removeHexPrefix } from '../../src/utils/encode';
|
|
3
|
-
import {
|
|
3
|
+
import { computeHashOnElements, hashMulticall, pedersen } from '../../src/utils/hash';
|
|
4
4
|
import { toBN, toHex } from '../../src/utils/number';
|
|
5
5
|
|
|
6
6
|
test('getKeyPair()', () => {
|
|
@@ -17,35 +17,42 @@ test('pedersen()', () => {
|
|
|
17
17
|
expect(own).toMatchSnapshot();
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
test('
|
|
20
|
+
test('computeHashOnElements()', () => {
|
|
21
21
|
const array = ['1', '2', '3', '4'];
|
|
22
|
-
expect(
|
|
22
|
+
expect(computeHashOnElements(array)).toBe(
|
|
23
23
|
'0x66bd4335902683054d08a0572747ea78ebd9e531536fb43125424ca9f902084'
|
|
24
24
|
);
|
|
25
25
|
expect(array).toStrictEqual(['1', '2', '3', '4']);
|
|
26
26
|
|
|
27
|
-
expect(
|
|
27
|
+
expect(computeHashOnElements(['1', '2'])).toBe(
|
|
28
28
|
'0x501a3a8e6cd4f5241c639c74052aaa34557aafa84dd4ba983d6443c590ab7df'
|
|
29
29
|
);
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
test('hashMessage()', () => {
|
|
33
33
|
const privateKey = '0x019800ea6a9a73f94aee6a3d2edf018fc770443e90c7ba121e8303ec6b349279';
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
const account = '2007067565103695475819120104515800035851923905855118399071773059478896040938';
|
|
35
|
+
const transactions = [
|
|
36
|
+
{
|
|
37
|
+
contractAddress:
|
|
38
|
+
'3290661298119599979891444342541795905081168856323302956721669397616389152866',
|
|
39
|
+
entrypoint: 'set_number',
|
|
40
|
+
calldata: ['47'],
|
|
41
|
+
},
|
|
42
|
+
];
|
|
43
|
+
const nonce = '3';
|
|
44
|
+
const maxFee = '0';
|
|
45
|
+
const hashMsg = hashMulticall(account, transactions, nonce, maxFee);
|
|
46
|
+
expect(hashMsg).toBe(
|
|
47
|
+
toHex(toBN('1608351043472325350463069815257733118091727529101532499046754244230898025592'))
|
|
40
48
|
);
|
|
41
|
-
expect(hashMsg).toBe('0x7f15c38ea577a26f4f553282fcfe4f1feeb8ecfaad8f221ae41abf8224cbddd');
|
|
42
49
|
const keyPair = getKeyPair(privateKey);
|
|
43
50
|
const [r, s] = sign(keyPair, removeHexPrefix(hashMsg));
|
|
44
51
|
expect(r.toString()).toStrictEqual(
|
|
45
|
-
toBN('
|
|
52
|
+
toBN('1079537730825246752292590270213864261175133133352510235773017189606850691611').toString()
|
|
46
53
|
);
|
|
47
54
|
expect(s.toString()).toStrictEqual(
|
|
48
|
-
toBN('
|
|
55
|
+
toBN('2904560423220491364719171767721067837294296476624248675613584621502231297000').toString()
|
|
49
56
|
);
|
|
50
57
|
});
|
|
51
58
|
|
|
@@ -44,17 +44,17 @@ describe('makeAddress()', () => {
|
|
|
44
44
|
});
|
|
45
45
|
describe('getSelectorFromName()', () => {
|
|
46
46
|
test('hash works for value="test"', () => {
|
|
47
|
-
expect(
|
|
47
|
+
expect(hash.getSelectorFromName('test')).toBe(
|
|
48
48
|
'0x22ff5f21f0b81b113e63f7db6da94fedef11b2119b4088b89664fb9a3cb658'
|
|
49
49
|
);
|
|
50
50
|
});
|
|
51
51
|
test('hash works for value="initialize"', () => {
|
|
52
|
-
expect(
|
|
52
|
+
expect(hash.getSelectorFromName('initialize')).toBe(
|
|
53
53
|
'0x79dc0da7c54b95f10aa182ad0a46400db63156920adb65eca2654c0945a463'
|
|
54
54
|
);
|
|
55
55
|
});
|
|
56
56
|
test('hash works for value="mint"', () => {
|
|
57
|
-
expect(
|
|
57
|
+
expect(hash.getSelectorFromName('mint')).toBe(
|
|
58
58
|
'0x2f0b3c5710379609eb5495f1ecd348cb28167711b73609fe565a72734550354'
|
|
59
59
|
);
|
|
60
60
|
});
|
package/account/default.d.ts
CHANGED
|
@@ -2,10 +2,11 @@ import { Provider } from '../provider';
|
|
|
2
2
|
import {
|
|
3
3
|
Abi,
|
|
4
4
|
AddTransactionResponse,
|
|
5
|
-
|
|
5
|
+
Call,
|
|
6
6
|
InvocationsDetails,
|
|
7
7
|
KeyPair,
|
|
8
8
|
Signature,
|
|
9
|
+
Transaction,
|
|
9
10
|
} from '../types';
|
|
10
11
|
import { BigNumberish } from '../utils/number';
|
|
11
12
|
import { TypedData } from '../utils/typedData';
|
|
@@ -24,10 +25,15 @@ export declare class Account extends Provider implements AccountInterface {
|
|
|
24
25
|
* @returns a confirmation of invoking a function on the starknet contract
|
|
25
26
|
*/
|
|
26
27
|
execute(
|
|
27
|
-
|
|
28
|
-
abis?: Abi[],
|
|
28
|
+
calls: Call | Call[],
|
|
29
|
+
abis?: Abi[] | undefined,
|
|
29
30
|
transactionsDetail?: InvocationsDetails
|
|
30
31
|
): Promise<AddTransactionResponse>;
|
|
32
|
+
/**
|
|
33
|
+
* Temporary method to allow dapps on starknet.js v2 to work with Argent X v3
|
|
34
|
+
* @deprecated to remove ASAP
|
|
35
|
+
*/
|
|
36
|
+
LEGACY_addTransaction(transaction: Transaction): Promise<AddTransactionResponse>;
|
|
31
37
|
/**
|
|
32
38
|
* Sign an JSON object with the starknet private key and return the signature
|
|
33
39
|
*
|
|
@@ -47,7 +53,7 @@ export declare class Account extends Provider implements AccountInterface {
|
|
|
47
53
|
/**
|
|
48
54
|
* Verify a signature of a JSON object
|
|
49
55
|
*
|
|
50
|
-
* @param
|
|
56
|
+
* @param hash - JSON object to be verified
|
|
51
57
|
* @param signature - signature of the JSON object
|
|
52
58
|
* @returns true if the signature is valid, false otherwise
|
|
53
59
|
* @throws {Error} if the JSON object is not a valid JSON or the signature is not a valid signature
|
package/account/default.js
CHANGED
|
@@ -24,20 +24,6 @@ var __extends =
|
|
|
24
24
|
d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
|
|
25
25
|
};
|
|
26
26
|
})();
|
|
27
|
-
var __assign =
|
|
28
|
-
(this && this.__assign) ||
|
|
29
|
-
function () {
|
|
30
|
-
__assign =
|
|
31
|
-
Object.assign ||
|
|
32
|
-
function (t) {
|
|
33
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
34
|
-
s = arguments[i];
|
|
35
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
36
|
-
}
|
|
37
|
-
return t;
|
|
38
|
-
};
|
|
39
|
-
return __assign.apply(this, arguments);
|
|
40
|
-
};
|
|
41
27
|
var __awaiter =
|
|
42
28
|
(this && this.__awaiter) ||
|
|
43
29
|
function (thisArg, _arguments, P, generator) {
|
|
@@ -169,19 +155,6 @@ var __generator =
|
|
|
169
155
|
return { value: op[0] ? op[1] : void 0, done: true };
|
|
170
156
|
}
|
|
171
157
|
};
|
|
172
|
-
var __rest =
|
|
173
|
-
(this && this.__rest) ||
|
|
174
|
-
function (s, e) {
|
|
175
|
-
var t = {};
|
|
176
|
-
for (var p in s)
|
|
177
|
-
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
178
|
-
if (s != null && typeof Object.getOwnPropertySymbols === 'function')
|
|
179
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
180
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
181
|
-
t[p[i]] = s[p[i]];
|
|
182
|
-
}
|
|
183
|
-
return t;
|
|
184
|
-
};
|
|
185
158
|
var __read =
|
|
186
159
|
(this && this.__read) ||
|
|
187
160
|
function (o, n) {
|
|
@@ -216,12 +189,21 @@ var __spreadArray =
|
|
|
216
189
|
}
|
|
217
190
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
218
191
|
};
|
|
192
|
+
var __importDefault =
|
|
193
|
+
(this && this.__importDefault) ||
|
|
194
|
+
function (mod) {
|
|
195
|
+
return mod && mod.__esModule ? mod : { default: mod };
|
|
196
|
+
};
|
|
219
197
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
220
198
|
exports.Account = void 0;
|
|
199
|
+
var minimalistic_assert_1 = __importDefault(require('minimalistic-assert'));
|
|
221
200
|
var provider_1 = require('../provider');
|
|
222
201
|
var signer_1 = require('../signer');
|
|
202
|
+
var ellipticCurve_1 = require('../utils/ellipticCurve');
|
|
203
|
+
var hash_1 = require('../utils/hash');
|
|
223
204
|
var number_1 = require('../utils/number');
|
|
224
205
|
var stark_1 = require('../utils/stark');
|
|
206
|
+
var transaction_1 = require('../utils/transaction');
|
|
225
207
|
var typedData_1 = require('../utils/typedData');
|
|
226
208
|
var Account = /** @class */ (function (_super) {
|
|
227
209
|
__extends(Account, _super);
|
|
@@ -259,84 +241,183 @@ var Account = /** @class */ (function (_super) {
|
|
|
259
241
|
* @param transaction - transaction to be invoked
|
|
260
242
|
* @returns a confirmation of invoking a function on the starknet contract
|
|
261
243
|
*/
|
|
262
|
-
Account.prototype.execute = function (
|
|
244
|
+
Account.prototype.execute = function (calls, abis, transactionsDetail) {
|
|
245
|
+
var _a, _b;
|
|
263
246
|
if (abis === void 0) {
|
|
264
|
-
abis =
|
|
247
|
+
abis = undefined;
|
|
265
248
|
}
|
|
266
249
|
if (transactionsDetail === void 0) {
|
|
267
250
|
transactionsDetail = {};
|
|
268
251
|
}
|
|
269
252
|
return __awaiter(this, void 0, void 0, function () {
|
|
270
|
-
var
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
entrypoint,
|
|
275
|
-
invocation,
|
|
276
|
-
nonce,
|
|
277
|
-
nonceBn,
|
|
278
|
-
_c,
|
|
279
|
-
_d,
|
|
280
|
-
calldataDecimal,
|
|
281
|
-
signature,
|
|
282
|
-
entrypointSelector;
|
|
283
|
-
return __generator(this, function (_e) {
|
|
284
|
-
switch (_e.label) {
|
|
253
|
+
var transactions, signerDetails, _c, _d, signature, calldata;
|
|
254
|
+
var _e;
|
|
255
|
+
return __generator(this, function (_f) {
|
|
256
|
+
switch (_f.label) {
|
|
285
257
|
case 0:
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
(contractAddress = _a.contractAddress),
|
|
291
|
-
(_b = _a.calldata),
|
|
292
|
-
(calldata = _b === void 0 ? [] : _b),
|
|
293
|
-
(entrypoint = _a.entrypoint),
|
|
294
|
-
(invocation = __rest(_a, ['contractAddress', 'calldata', 'entrypoint']));
|
|
295
|
-
nonce = transactionsDetail.nonce;
|
|
258
|
+
transactions = Array.isArray(calls) ? calls : [calls];
|
|
259
|
+
_e = {
|
|
260
|
+
walletAddress: this.address,
|
|
261
|
+
};
|
|
296
262
|
_c = number_1.toBN;
|
|
297
|
-
if (!(nonce !== null &&
|
|
298
|
-
|
|
263
|
+
if (!((_a = transactionsDetail.nonce) !== null && _a !== void 0))
|
|
264
|
+
return [3 /*break*/, 1];
|
|
265
|
+
_d = _a;
|
|
299
266
|
return [3 /*break*/, 3];
|
|
300
267
|
case 1:
|
|
301
268
|
return [4 /*yield*/, this.getNonce()];
|
|
302
269
|
case 2:
|
|
303
|
-
_d =
|
|
304
|
-
|
|
270
|
+
_d = _f.sent();
|
|
271
|
+
_f.label = 3;
|
|
305
272
|
case 3:
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
contractAddress: contractAddress,
|
|
314
|
-
calldata: calldataDecimal,
|
|
315
|
-
entrypoint: entrypoint,
|
|
316
|
-
}),
|
|
317
|
-
],
|
|
318
|
-
{ walletAddress: this.address, nonce: nonceBn },
|
|
319
|
-
abis
|
|
320
|
-
),
|
|
321
|
-
];
|
|
273
|
+
signerDetails =
|
|
274
|
+
((_e.nonce = _c.apply(void 0, [_d])),
|
|
275
|
+
(_e.maxFee = (0, number_1.toBN)(
|
|
276
|
+
(_b = transactionsDetail.maxFee) !== null && _b !== void 0 ? _b : '0'
|
|
277
|
+
)),
|
|
278
|
+
_e);
|
|
279
|
+
return [4 /*yield*/, this.signer.signTransaction(transactions, signerDetails, abis)];
|
|
322
280
|
case 4:
|
|
323
|
-
signature =
|
|
324
|
-
|
|
281
|
+
signature = _f.sent();
|
|
282
|
+
calldata = __spreadArray(
|
|
283
|
+
__spreadArray(
|
|
284
|
+
[],
|
|
285
|
+
__read((0, transaction_1.fromCallsToExecuteCalldata)(transactions)),
|
|
286
|
+
false
|
|
287
|
+
),
|
|
288
|
+
[signerDetails.nonce.toString()],
|
|
289
|
+
false
|
|
290
|
+
);
|
|
325
291
|
return [
|
|
326
292
|
2 /*return*/,
|
|
327
|
-
|
|
293
|
+
this.fetchEndpoint('add_transaction', undefined, {
|
|
294
|
+
type: 'INVOKE_FUNCTION',
|
|
295
|
+
contract_address: this.address,
|
|
296
|
+
entry_point_selector: (0, hash_1.getSelectorFromName)('__execute__'),
|
|
297
|
+
calldata: calldata,
|
|
298
|
+
signature: (0, number_1.bigNumberishArrayToDecimalStringArray)(signature),
|
|
299
|
+
}),
|
|
300
|
+
];
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
});
|
|
304
|
+
};
|
|
305
|
+
/**
|
|
306
|
+
* Temporary method to allow dapps on starknet.js v2 to work with Argent X v3
|
|
307
|
+
* @deprecated to remove ASAP
|
|
308
|
+
*/
|
|
309
|
+
Account.prototype.LEGACY_addTransaction = function (transaction) {
|
|
310
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
311
|
+
function hashMulticall(account, transactions, nonce, maxFee) {
|
|
312
|
+
var hashArray = transactions
|
|
313
|
+
.map(function (_a) {
|
|
314
|
+
var contract_address = _a.contract_address,
|
|
315
|
+
entry_point_selector = _a.entry_point_selector,
|
|
316
|
+
calldata = _a.calldata;
|
|
317
|
+
return [
|
|
318
|
+
contract_address,
|
|
319
|
+
entry_point_selector,
|
|
320
|
+
(0, hash_1.computeHashOnElements)(calldata || []),
|
|
321
|
+
];
|
|
322
|
+
})
|
|
323
|
+
.map(number_1.bigNumberishArrayToDecimalStringArray)
|
|
324
|
+
.map(hash_1.computeHashOnElements);
|
|
325
|
+
return (0,
|
|
326
|
+
hash_1.computeHashOnElements)([hash_1.transactionPrefix, account, (0, hash_1.computeHashOnElements)(hashArray), nonce, maxFee, hash_1.transactionVersion]);
|
|
327
|
+
}
|
|
328
|
+
var nonceBn,
|
|
329
|
+
result,
|
|
330
|
+
msgHash,
|
|
331
|
+
signature,
|
|
332
|
+
transformCallsToMulticallArrays,
|
|
333
|
+
fromCallsToExecuteCalldata2,
|
|
334
|
+
calldata;
|
|
335
|
+
return __generator(this, function (_a) {
|
|
336
|
+
switch (_a.label) {
|
|
337
|
+
case 0:
|
|
338
|
+
if (transaction.type === 'DEPLOY') throw new Error('No DEPLOYS');
|
|
339
|
+
(0,
|
|
340
|
+
minimalistic_assert_1.default)(!transaction.signature, "Adding signatures to a signer transaction currently isn't supported");
|
|
341
|
+
if (!transaction.nonce) return [3 /*break*/, 1];
|
|
342
|
+
nonceBn = (0, number_1.toBN)(transaction.nonce);
|
|
343
|
+
return [3 /*break*/, 3];
|
|
344
|
+
case 1:
|
|
345
|
+
return [
|
|
346
|
+
4 /*yield*/,
|
|
347
|
+
this.callContract({
|
|
328
348
|
contractAddress: this.address,
|
|
329
|
-
entrypoint: '
|
|
330
|
-
|
|
349
|
+
entrypoint: 'get_nonce',
|
|
350
|
+
}),
|
|
351
|
+
];
|
|
352
|
+
case 2:
|
|
353
|
+
result = _a.sent().result;
|
|
354
|
+
nonceBn = (0, number_1.toBN)(result[0]);
|
|
355
|
+
_a.label = 3;
|
|
356
|
+
case 3:
|
|
357
|
+
msgHash = hashMulticall(this.address, [transaction], nonceBn.toString(), '0');
|
|
358
|
+
if (!('keyPair' in this.signer)) {
|
|
359
|
+
throw new Error('No keyPair');
|
|
360
|
+
}
|
|
361
|
+
signature = (0, ellipticCurve_1.sign)(this.signer.keyPair, msgHash);
|
|
362
|
+
transformCallsToMulticallArrays = function (calls) {
|
|
363
|
+
var callArray = [];
|
|
364
|
+
var calldata = [];
|
|
365
|
+
calls.forEach(function (call) {
|
|
366
|
+
var data = call.calldata || [];
|
|
367
|
+
callArray.push({
|
|
368
|
+
to: (0, number_1.toBN)(call.contract_address).toString(10),
|
|
369
|
+
selector: (0, number_1.toBN)(call.entry_point_selector).toString(10),
|
|
370
|
+
data_offset: calldata.length.toString(),
|
|
371
|
+
data_len: data.length.toString(),
|
|
372
|
+
});
|
|
373
|
+
calldata.push.apply(calldata, __spreadArray([], __read(data), false));
|
|
374
|
+
});
|
|
375
|
+
return {
|
|
376
|
+
callArray: callArray,
|
|
377
|
+
calldata: (0, number_1.bigNumberishArrayToDecimalStringArray)(calldata),
|
|
378
|
+
};
|
|
379
|
+
};
|
|
380
|
+
fromCallsToExecuteCalldata2 = function (calls) {
|
|
381
|
+
var _a = transformCallsToMulticallArrays(calls),
|
|
382
|
+
callArray = _a.callArray,
|
|
383
|
+
calldata = _a.calldata;
|
|
384
|
+
return __spreadArray(
|
|
385
|
+
__spreadArray(
|
|
331
386
|
__spreadArray(
|
|
332
|
-
[
|
|
333
|
-
__read(
|
|
387
|
+
[callArray.length.toString()],
|
|
388
|
+
__read(
|
|
389
|
+
callArray
|
|
390
|
+
.map(function (_a) {
|
|
391
|
+
var to = _a.to,
|
|
392
|
+
selector = _a.selector,
|
|
393
|
+
data_offset = _a.data_offset,
|
|
394
|
+
data_len = _a.data_len;
|
|
395
|
+
return [to, selector, data_offset, data_len];
|
|
396
|
+
})
|
|
397
|
+
.flat()
|
|
398
|
+
),
|
|
334
399
|
false
|
|
335
400
|
),
|
|
336
|
-
[
|
|
401
|
+
[calldata.length.toString()],
|
|
337
402
|
false
|
|
338
403
|
),
|
|
339
|
-
|
|
404
|
+
__read(calldata),
|
|
405
|
+
false
|
|
406
|
+
);
|
|
407
|
+
};
|
|
408
|
+
calldata = __spreadArray(
|
|
409
|
+
__spreadArray([], __read(fromCallsToExecuteCalldata2([transaction])), false),
|
|
410
|
+
[nonceBn.toString()],
|
|
411
|
+
false
|
|
412
|
+
);
|
|
413
|
+
return [
|
|
414
|
+
2 /*return*/,
|
|
415
|
+
this.fetchEndpoint('add_transaction', undefined, {
|
|
416
|
+
type: 'INVOKE_FUNCTION',
|
|
417
|
+
contract_address: this.address,
|
|
418
|
+
entry_point_selector: (0, hash_1.getSelectorFromName)('__execute__'),
|
|
419
|
+
calldata: calldata,
|
|
420
|
+
signature: (0, number_1.bigNumberishArrayToDecimalStringArray)(signature),
|
|
340
421
|
}),
|
|
341
422
|
];
|
|
342
423
|
}
|
|
@@ -374,7 +455,7 @@ var Account = /** @class */ (function (_super) {
|
|
|
374
455
|
/**
|
|
375
456
|
* Verify a signature of a JSON object
|
|
376
457
|
*
|
|
377
|
-
* @param
|
|
458
|
+
* @param hash - JSON object to be verified
|
|
378
459
|
* @param signature - signature of the JSON object
|
|
379
460
|
* @returns true if the signature is valid, false otherwise
|
|
380
461
|
* @throws {Error} if the JSON object is not a valid JSON or the signature is not a valid signature
|
package/account/interface.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { ProviderInterface } from '../provider';
|
|
|
2
2
|
import {
|
|
3
3
|
Abi,
|
|
4
4
|
AddTransactionResponse,
|
|
5
|
+
Call,
|
|
5
6
|
DeployContractPayload,
|
|
6
|
-
ExecuteInvocation,
|
|
7
7
|
InvocationsDetails,
|
|
8
8
|
Signature,
|
|
9
9
|
} from '../types';
|
|
@@ -38,7 +38,7 @@ export declare abstract class AccountInterface extends ProviderInterface {
|
|
|
38
38
|
* @returns response from addTransaction
|
|
39
39
|
*/
|
|
40
40
|
abstract execute(
|
|
41
|
-
transactions:
|
|
41
|
+
transactions: Call | Call[],
|
|
42
42
|
abis?: Abi[],
|
|
43
43
|
transactionsDetail?: InvocationsDetails
|
|
44
44
|
): Promise<AddTransactionResponse>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Provider } from '../provider';
|
|
2
|
-
import { Abi, AddTransactionResponse,
|
|
2
|
+
import { Abi, AddTransactionResponse, Call, InvocationsDetails, KeyPair, Signature, Transaction } from '../types';
|
|
3
3
|
import { BigNumberish } from '../utils/number';
|
|
4
4
|
import { TypedData } from '../utils/typedData';
|
|
5
5
|
import { AccountInterface } from './interface';
|
|
@@ -16,7 +16,12 @@ export declare class Account extends Provider implements AccountInterface {
|
|
|
16
16
|
* @param transaction - transaction to be invoked
|
|
17
17
|
* @returns a confirmation of invoking a function on the starknet contract
|
|
18
18
|
*/
|
|
19
|
-
execute(
|
|
19
|
+
execute(calls: Call | Call[], abis?: Abi[] | undefined, transactionsDetail?: InvocationsDetails): Promise<AddTransactionResponse>;
|
|
20
|
+
/**
|
|
21
|
+
* Temporary method to allow dapps on starknet.js v2 to work with Argent X v3
|
|
22
|
+
* @deprecated to remove ASAP
|
|
23
|
+
*/
|
|
24
|
+
LEGACY_addTransaction(transaction: Transaction): Promise<AddTransactionResponse>;
|
|
20
25
|
/**
|
|
21
26
|
* Sign an JSON object with the starknet private key and return the signature
|
|
22
27
|
*
|
|
@@ -36,7 +41,7 @@ export declare class Account extends Provider implements AccountInterface {
|
|
|
36
41
|
/**
|
|
37
42
|
* Verify a signature of a JSON object
|
|
38
43
|
*
|
|
39
|
-
* @param
|
|
44
|
+
* @param hash - JSON object to be verified
|
|
40
45
|
* @param signature - signature of the JSON object
|
|
41
46
|
* @returns true if the signature is valid, false otherwise
|
|
42
47
|
* @throws {Error} if the JSON object is not a valid JSON or the signature is not a valid signature
|