starknet 3.12.3 → 3.13.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/.github/workflows/pr.yml +3 -0
- package/.github/workflows/release.yml +4 -0
- package/CHANGELOG.md +26 -0
- package/__mocks__/Account.json +25468 -0
- package/__tests__/account.test.ts +102 -65
- package/__tests__/contract.test.ts +23 -65
- package/__tests__/fixtures.ts +21 -1
- package/__tests__/provider.test.ts +20 -1
- package/account/index.js +10 -6
- package/contract/default.js +20 -21
- package/contract/index.js +10 -6
- package/dist/account/index.js +5 -1
- package/dist/contract/default.js +18 -18
- package/dist/contract/index.js +5 -1
- package/dist/index.js +5 -1
- package/dist/provider/default.d.ts +1 -1
- package/dist/provider/default.js +8 -6
- package/dist/provider/index.js +5 -1
- package/dist/provider/interface.d.ts +1 -1
- package/dist/provider/utils.js +5 -5
- package/dist/signer/index.js +5 -1
- package/dist/types/api.d.ts +1 -1
- package/dist/types/index.js +5 -1
- package/dist/utils/ellipticCurve.js +1 -1
- package/dist/utils/encode.js +1 -1
- package/dist/utils/hash.js +1 -1
- package/dist/utils/number.js +8 -4
- package/dist/utils/shortString.js +2 -2
- package/dist/utils/typedData/index.js +8 -4
- package/index.js +10 -6
- package/package.json +30 -28
- package/provider/default.d.ts +1 -1
- package/provider/default.js +9 -10
- package/provider/index.js +10 -6
- package/provider/interface.d.ts +1 -1
- package/provider/utils.js +5 -5
- package/signer/index.js +10 -6
- package/src/provider/default.ts +4 -2
- package/src/provider/interface.ts +1 -1
- package/src/types/api.ts +1 -1
- package/types/api.d.ts +1 -1
- package/types/index.js +10 -6
- package/utils/ellipticCurve.js +1 -1
- package/utils/encode.js +1 -1
- package/utils/hash.js +1 -1
- package/utils/number.js +13 -9
- package/utils/shortString.js +2 -2
- package/utils/typedData/index.js +15 -13
- package/www/guides/account.md +21 -7
- package/www/guides/erc20.md +15 -27
- package/__tests__/accountContract.test.ts +0 -110
package/dist/account/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/contract/default.js
CHANGED
|
@@ -179,8 +179,8 @@ var Contract = /** @class */ (function () {
|
|
|
179
179
|
* @param providerOrAccount (optional) - Provider or Account to attach to
|
|
180
180
|
*/
|
|
181
181
|
function Contract(abi, address, providerOrAccount) {
|
|
182
|
-
var _this = this;
|
|
183
182
|
if (providerOrAccount === void 0) { providerOrAccount = provider_1.defaultProvider; }
|
|
183
|
+
var _this = this;
|
|
184
184
|
this.address = address;
|
|
185
185
|
this.providerOrAccount = providerOrAccount;
|
|
186
186
|
this.abi = abi;
|
|
@@ -309,7 +309,7 @@ var Contract = /** @class */ (function () {
|
|
|
309
309
|
return type === 'INVOKE' ? !isView : isView;
|
|
310
310
|
})
|
|
311
311
|
.map(function (abi) { return abi.name; });
|
|
312
|
-
(0, minimalistic_assert_1.default)(invokeableFunctionNames.includes(method), (type === 'INVOKE' ? 'invokeable' : 'viewable'
|
|
312
|
+
(0, minimalistic_assert_1.default)(invokeableFunctionNames.includes(method), "".concat(type === 'INVOKE' ? 'invokeable' : 'viewable', " method not found in abi"));
|
|
313
313
|
// ensure args match abi type
|
|
314
314
|
var methodAbi = this.abi.find(function (abi) { return abi.name === method && abi.type === 'function'; });
|
|
315
315
|
var argPosition = 0;
|
|
@@ -320,35 +320,35 @@ var Contract = /** @class */ (function () {
|
|
|
320
320
|
if (input.type === 'felt') {
|
|
321
321
|
(0, minimalistic_assert_1.default)(typeof args[argPosition] === 'string' ||
|
|
322
322
|
typeof args[argPosition] === 'number' ||
|
|
323
|
-
args[argPosition] instanceof bn_js_1.default, "arg "
|
|
323
|
+
args[argPosition] instanceof bn_js_1.default, "arg ".concat(input.name, " should be a felt (string, number, BigNumber)"));
|
|
324
324
|
argPosition += 1;
|
|
325
325
|
}
|
|
326
326
|
else if (input.type in _this.structs && typeof args[argPosition] === 'object') {
|
|
327
327
|
if (Array.isArray(args[argPosition])) {
|
|
328
328
|
var structMembersLength = _this.calculateStructMembers(input.type);
|
|
329
|
-
(0, minimalistic_assert_1.default)(args[argPosition].length === structMembersLength, "arg should be of length "
|
|
329
|
+
(0, minimalistic_assert_1.default)(args[argPosition].length === structMembersLength, "arg should be of length ".concat(structMembersLength));
|
|
330
330
|
}
|
|
331
331
|
else {
|
|
332
332
|
_this.structs[input.type].members.forEach(function (_a) {
|
|
333
333
|
var name = _a.name;
|
|
334
|
-
(0, minimalistic_assert_1.default)(Object.keys(args[argPosition]).includes(name), "arg should have a property "
|
|
334
|
+
(0, minimalistic_assert_1.default)(Object.keys(args[argPosition]).includes(name), "arg should have a property ".concat(name));
|
|
335
335
|
});
|
|
336
336
|
}
|
|
337
337
|
argPosition += 1;
|
|
338
338
|
}
|
|
339
339
|
else {
|
|
340
|
-
(0, minimalistic_assert_1.default)(Array.isArray(args[argPosition]), "arg "
|
|
340
|
+
(0, minimalistic_assert_1.default)(Array.isArray(args[argPosition]), "arg ".concat(input.name, " should be an Array"));
|
|
341
341
|
if (input.type === 'felt*') {
|
|
342
342
|
args[argPosition].forEach(function (felt) {
|
|
343
|
-
(0, minimalistic_assert_1.default)(typeof felt === 'string' || typeof felt === 'number' || felt instanceof bn_js_1.default, "arg "
|
|
343
|
+
(0, minimalistic_assert_1.default)(typeof felt === 'string' || typeof felt === 'number' || felt instanceof bn_js_1.default, "arg ".concat(input.name, " should be an array of string, number or BigNumber"));
|
|
344
344
|
});
|
|
345
345
|
argPosition += 1;
|
|
346
346
|
}
|
|
347
347
|
else if (/\(felt/.test(input.type)) {
|
|
348
348
|
var tupleLength = input.type.split(',').length;
|
|
349
|
-
(0, minimalistic_assert_1.default)(args[argPosition].length === tupleLength, "arg "
|
|
349
|
+
(0, minimalistic_assert_1.default)(args[argPosition].length === tupleLength, "arg ".concat(input.name, " should have ").concat(tupleLength, " elements in tuple"));
|
|
350
350
|
args[argPosition].forEach(function (felt) {
|
|
351
|
-
(0, minimalistic_assert_1.default)(typeof felt === 'string' || typeof felt === 'number' || felt instanceof bn_js_1.default, "arg "
|
|
351
|
+
(0, minimalistic_assert_1.default)(typeof felt === 'string' || typeof felt === 'number' || felt instanceof bn_js_1.default, "arg ".concat(input.name, " should be an array of string, number or BigNumber"));
|
|
352
352
|
});
|
|
353
353
|
argPosition += 1;
|
|
354
354
|
}
|
|
@@ -359,10 +359,10 @@ var Contract = /** @class */ (function () {
|
|
|
359
359
|
var name = _a.name;
|
|
360
360
|
if (Array.isArray(struct)) {
|
|
361
361
|
var structMembersLength = _this.calculateStructMembers(arrayType_1);
|
|
362
|
-
(0, minimalistic_assert_1.default)(struct.length === structMembersLength, "arg should be of length "
|
|
362
|
+
(0, minimalistic_assert_1.default)(struct.length === structMembersLength, "arg should be of length ".concat(structMembersLength));
|
|
363
363
|
}
|
|
364
364
|
else {
|
|
365
|
-
(0, minimalistic_assert_1.default)(Object.keys(struct).includes(name), "arg "
|
|
365
|
+
(0, minimalistic_assert_1.default)(Object.keys(struct).includes(name), "arg ".concat(input.name, " should be an array of ").concat(arrayType_1));
|
|
366
366
|
}
|
|
367
367
|
});
|
|
368
368
|
});
|
|
@@ -469,14 +469,14 @@ var Contract = /** @class */ (function () {
|
|
|
469
469
|
return acc;
|
|
470
470
|
}, parsedCalldata);
|
|
471
471
|
}
|
|
472
|
-
throw Error("Expected "
|
|
472
|
+
throw Error("Expected ".concat(name, " to be array"));
|
|
473
473
|
case type in this.structs:
|
|
474
474
|
return this.parseCalldataValue(value, type);
|
|
475
475
|
case /\(felt/.test(type):
|
|
476
476
|
if (Array.isArray(value)) {
|
|
477
477
|
return value.map(function (el) { return (0, number_1.toFelt)(el); });
|
|
478
478
|
}
|
|
479
|
-
throw Error("Expected "
|
|
479
|
+
throw Error("Expected ".concat(name, " to be array"));
|
|
480
480
|
default:
|
|
481
481
|
return (0, number_1.toFelt)(value);
|
|
482
482
|
}
|
|
@@ -524,8 +524,8 @@ var Contract = /** @class */ (function () {
|
|
|
524
524
|
return acc;
|
|
525
525
|
}, []);
|
|
526
526
|
case /\*/.test(type):
|
|
527
|
-
if (parsedResult && parsedResult[name
|
|
528
|
-
var arrLen = parsedResult[name
|
|
527
|
+
if (parsedResult && parsedResult["".concat(name, "_len")]) {
|
|
528
|
+
var arrLen = parsedResult["".concat(name, "_len")];
|
|
529
529
|
while (parsedDataArr.length < arrLen) {
|
|
530
530
|
parsedDataArr.push(this.parseResponseStruct(responseIterator, output.type.replace('*', '')));
|
|
531
531
|
}
|
|
@@ -550,8 +550,8 @@ var Contract = /** @class */ (function () {
|
|
|
550
550
|
var responseIterator = response.flat()[Symbol.iterator]();
|
|
551
551
|
var resultObject = outputs.flat().reduce(function (acc, output) {
|
|
552
552
|
acc[output.name] = _this.parseResponseField(responseIterator, output, acc);
|
|
553
|
-
if (acc[output.name] && acc[output.name
|
|
554
|
-
delete acc[output.name
|
|
553
|
+
if (acc[output.name] && acc["".concat(output.name, "_len")]) {
|
|
554
|
+
delete acc["".concat(output.name, "_len")];
|
|
555
555
|
}
|
|
556
556
|
return acc;
|
|
557
557
|
}, {});
|
|
@@ -577,7 +577,7 @@ var Contract = /** @class */ (function () {
|
|
|
577
577
|
return acc;
|
|
578
578
|
}, 0);
|
|
579
579
|
if (args.length !== inputsLength) {
|
|
580
|
-
throw Error("Invalid number of arguments, expected "
|
|
580
|
+
throw Error("Invalid number of arguments, expected ".concat(inputsLength, " arguments, but got ").concat(args.length));
|
|
581
581
|
}
|
|
582
582
|
// compile calldata
|
|
583
583
|
var calldata = this.compileCalldata(args, inputs);
|
package/dist/contract/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -74,7 +74,7 @@ export declare class Provider implements ProviderInterface {
|
|
|
74
74
|
* @param blockNumber
|
|
75
75
|
* @returns the value of the storage variable
|
|
76
76
|
*/
|
|
77
|
-
getStorageAt(contractAddress: string, key:
|
|
77
|
+
getStorageAt(contractAddress: string, key: BigNumberish, blockIdentifier?: BlockIdentifier): Promise<object>;
|
|
78
78
|
/**
|
|
79
79
|
* Gets the status of a transaction.
|
|
80
80
|
*
|
package/dist/provider/default.js
CHANGED
|
@@ -77,7 +77,9 @@ var stark_1 = require("../utils/stark");
|
|
|
77
77
|
var interface_1 = require("./interface");
|
|
78
78
|
var utils_1 = require("./utils");
|
|
79
79
|
function wait(delay) {
|
|
80
|
-
return new Promise(function (res) {
|
|
80
|
+
return new Promise(function (res) {
|
|
81
|
+
setTimeout(res, delay);
|
|
82
|
+
});
|
|
81
83
|
}
|
|
82
84
|
function isEmptyQueryObject(obj) {
|
|
83
85
|
return (obj === undefined ||
|
|
@@ -127,7 +129,7 @@ var Provider = /** @class */ (function () {
|
|
|
127
129
|
}
|
|
128
130
|
catch (_a) {
|
|
129
131
|
// eslint-disable-next-line no-console
|
|
130
|
-
console.error("Could not parse baseUrl: "
|
|
132
|
+
console.error("Could not parse baseUrl: ".concat(baseUrl));
|
|
131
133
|
}
|
|
132
134
|
return constants_1.StarknetChainId.TESTNET;
|
|
133
135
|
};
|
|
@@ -147,12 +149,12 @@ var Provider = /** @class */ (function () {
|
|
|
147
149
|
.map(function (_a) {
|
|
148
150
|
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
149
151
|
if (key === 'blockIdentifier') {
|
|
150
|
-
return ""
|
|
152
|
+
return "".concat((0, utils_1.getFormattedBlockIdentifier)(value));
|
|
151
153
|
}
|
|
152
|
-
return key
|
|
154
|
+
return "".concat(key, "=").concat(value);
|
|
153
155
|
})
|
|
154
156
|
.join('&');
|
|
155
|
-
return "?"
|
|
157
|
+
return "?".concat(queryString);
|
|
156
158
|
};
|
|
157
159
|
Provider.prototype.getHeaders = function (method) {
|
|
158
160
|
if (method === 'POST') {
|
|
@@ -432,7 +434,7 @@ var Provider = /** @class */ (function () {
|
|
|
432
434
|
}
|
|
433
435
|
else if (errorStates.includes(res.tx_status)) {
|
|
434
436
|
message = res.tx_failure_reason
|
|
435
|
-
? res.tx_status
|
|
437
|
+
? "".concat(res.tx_status, ": ").concat(res.tx_failure_reason.code, "\n").concat(res.tx_failure_reason.error_message)
|
|
436
438
|
: res.tx_status;
|
|
437
439
|
error = new Error(message);
|
|
438
440
|
error.response = res;
|
package/dist/provider/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -55,7 +55,7 @@ export declare abstract class ProviderInterface {
|
|
|
55
55
|
* @param blockIdentifier - block identifier
|
|
56
56
|
* @returns the value of the storage variable
|
|
57
57
|
*/
|
|
58
|
-
abstract getStorageAt(contractAddress: string, key:
|
|
58
|
+
abstract getStorageAt(contractAddress: string, key: BigNumberish, blockIdentifier?: BlockIdentifier): Promise<object>;
|
|
59
59
|
/**
|
|
60
60
|
* Gets the status of a transaction.
|
|
61
61
|
*
|
package/dist/provider/utils.js
CHANGED
|
@@ -23,10 +23,10 @@ exports.formatHash = formatHash;
|
|
|
23
23
|
*/
|
|
24
24
|
function txIdentifier(txHash, txId) {
|
|
25
25
|
if (!txHash) {
|
|
26
|
-
return "transactionId="
|
|
26
|
+
return "transactionId=".concat(JSON.stringify(txId));
|
|
27
27
|
}
|
|
28
28
|
var hashString = formatHash(txHash);
|
|
29
|
-
return "transactionHash="
|
|
29
|
+
return "transactionHash=".concat(hashString);
|
|
30
30
|
}
|
|
31
31
|
exports.txIdentifier = txIdentifier;
|
|
32
32
|
/**
|
|
@@ -52,7 +52,7 @@ function getBlockIdentifier(blockIdentifier) {
|
|
|
52
52
|
return { type: 'BLOCK_NUMBER', data: parseInt(blockIdentifier, 10) };
|
|
53
53
|
}
|
|
54
54
|
if (typeof blockIdentifier === 'string') {
|
|
55
|
-
throw new Error("Invalid block identifier: "
|
|
55
|
+
throw new Error("Invalid block identifier: ".concat(blockIdentifier));
|
|
56
56
|
}
|
|
57
57
|
return { type: 'BLOCK_HASH', data: blockIdentifier };
|
|
58
58
|
}
|
|
@@ -72,8 +72,8 @@ function getFormattedBlockIdentifier(blockIdentifier) {
|
|
|
72
72
|
return '';
|
|
73
73
|
}
|
|
74
74
|
if (blockIdentifierObject.type === 'BLOCK_NUMBER') {
|
|
75
|
-
return "blockNumber="
|
|
75
|
+
return "blockNumber=".concat(blockIdentifierObject.data);
|
|
76
76
|
}
|
|
77
|
-
return "blockHash="
|
|
77
|
+
return "blockHash=".concat((0, number_1.toHex)((0, number_1.toBN)(blockIdentifierObject.data)));
|
|
78
78
|
}
|
|
79
79
|
exports.getFormattedBlockIdentifier = getFormattedBlockIdentifier;
|
package/dist/signer/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/types/api.d.ts
CHANGED
package/dist/types/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -51,7 +51,7 @@ function fixMessage(msg) {
|
|
|
51
51
|
}
|
|
52
52
|
(0, minimalistic_assert_1.default)(pureHex.length === 63);
|
|
53
53
|
// In this case delta will be 4 so we perform a shift-left of 4 bits by adding a ZERO_BN.
|
|
54
|
-
return pureHex
|
|
54
|
+
return "".concat(pureHex, "0");
|
|
55
55
|
}
|
|
56
56
|
exports.genKeyPair = exports.ec.genKeyPair.bind(exports.ec);
|
|
57
57
|
function getKeyPair(pk) {
|
package/dist/utils/encode.js
CHANGED
|
@@ -50,7 +50,7 @@ function removeHexPrefix(hex) {
|
|
|
50
50
|
}
|
|
51
51
|
exports.removeHexPrefix = removeHexPrefix;
|
|
52
52
|
function addHexPrefix(hex) {
|
|
53
|
-
return "0x"
|
|
53
|
+
return "0x".concat(removeHexPrefix(hex));
|
|
54
54
|
}
|
|
55
55
|
exports.addHexPrefix = addHexPrefix;
|
|
56
56
|
function padString(str, length, left, padding) {
|
package/dist/utils/hash.js
CHANGED
|
@@ -70,7 +70,7 @@ function pedersen(input) {
|
|
|
70
70
|
var point = constantPoints[0];
|
|
71
71
|
for (var i = 0; i < input.length; i += 1) {
|
|
72
72
|
var x = (0, number_1.toBN)(input[i]);
|
|
73
|
-
(0, minimalistic_assert_1.default)(x.gte(constants_1.ZERO) && x.lt((0, number_1.toBN)((0, encode_1.addHexPrefix)(constants_1.FIELD_PRIME))), "Invalid input: "
|
|
73
|
+
(0, minimalistic_assert_1.default)(x.gte(constants_1.ZERO) && x.lt((0, number_1.toBN)((0, encode_1.addHexPrefix)(constants_1.FIELD_PRIME))), "Invalid input: ".concat(input[i]));
|
|
74
74
|
for (var j = 0; j < 252; j += 1) {
|
|
75
75
|
var pt = constantPoints[2 + i * 252 + j];
|
|
76
76
|
(0, minimalistic_assert_1.default)(!point.getX().eq(pt.getX()));
|
package/dist/utils/number.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -41,7 +45,7 @@ function toHex(number) {
|
|
|
41
45
|
}
|
|
42
46
|
exports.toHex = toHex;
|
|
43
47
|
function hexToDecimalString(hex) {
|
|
44
|
-
return toBN("0x"
|
|
48
|
+
return toBN("0x".concat(hex.replace(/^0x/, ''))).toString();
|
|
45
49
|
}
|
|
46
50
|
exports.hexToDecimalString = hexToDecimalString;
|
|
47
51
|
function toFelt(num) {
|
|
@@ -59,9 +63,9 @@ exports.toFelt = toFelt;
|
|
|
59
63
|
*/
|
|
60
64
|
function assertInRange(input, lowerBound, upperBound, inputName) {
|
|
61
65
|
if (inputName === void 0) { inputName = ''; }
|
|
62
|
-
var messageSuffix = inputName === '' ? 'invalid length' : "invalid "
|
|
66
|
+
var messageSuffix = inputName === '' ? 'invalid length' : "invalid ".concat(inputName, " length");
|
|
63
67
|
var inputBn = toBN(input);
|
|
64
|
-
(0, minimalistic_assert_1.default)(inputBn.gte(toBN(lowerBound)) && inputBn.lt(toBN(upperBound)), "Message not signable, "
|
|
68
|
+
(0, minimalistic_assert_1.default)(inputBn.gte(toBN(lowerBound)) && inputBn.lt(toBN(upperBound)), "Message not signable, ".concat(messageSuffix, "."));
|
|
65
69
|
}
|
|
66
70
|
exports.assertInRange = assertInRange;
|
|
67
71
|
function bigNumberishArrayToDecimalStringArray(rawCalldata) {
|
|
@@ -14,9 +14,9 @@ function isShortString(str) {
|
|
|
14
14
|
exports.isShortString = isShortString;
|
|
15
15
|
function encodeShortString(str) {
|
|
16
16
|
if (!isASCII(str))
|
|
17
|
-
throw new Error(str
|
|
17
|
+
throw new Error("".concat(str, " is not an ASCII string"));
|
|
18
18
|
if (!isShortString(str))
|
|
19
|
-
throw new Error(str
|
|
19
|
+
throw new Error("".concat(str, " is too long"));
|
|
20
20
|
return (0, encode_1.addHexPrefix)(str.replace(/./g, function (char) { return char.charCodeAt(0).toString(16); }));
|
|
21
21
|
}
|
|
22
22
|
exports.encodeShortString = encodeShortString;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -49,7 +53,7 @@ function getHex(value) {
|
|
|
49
53
|
if (typeof value === 'string') {
|
|
50
54
|
return (0, number_1.toHex)((0, number_1.toBN)((0, shortString_1.encodeShortString)(value)));
|
|
51
55
|
}
|
|
52
|
-
throw new Error("Invalid BigNumberish: "
|
|
56
|
+
throw new Error("Invalid BigNumberish: ".concat(value));
|
|
53
57
|
}
|
|
54
58
|
}
|
|
55
59
|
/**
|
|
@@ -90,7 +94,7 @@ var encodeType = function (typedData, type) {
|
|
|
90
94
|
var types = __spreadArray([primary], __read(dependencies.sort()), false);
|
|
91
95
|
return types
|
|
92
96
|
.map(function (dependency) {
|
|
93
|
-
return dependency
|
|
97
|
+
return "".concat(dependency, "(").concat(typedData.types[dependency].map(function (t) { return "".concat(t.name, ":").concat(t.type); }), ")");
|
|
94
98
|
})
|
|
95
99
|
.join('');
|
|
96
100
|
};
|
|
@@ -137,7 +141,7 @@ var encodeData = function (typedData, type, data) {
|
|
|
137
141
|
var _a = __read(typedData.types[type].reduce(function (_a, field) {
|
|
138
142
|
var _b = __read(_a, 2), ts = _b[0], vs = _b[1];
|
|
139
143
|
if (data[field.name] === undefined || data[field.name] === null) {
|
|
140
|
-
throw new Error("Cannot encode data: missing data for '"
|
|
144
|
+
throw new Error("Cannot encode data: missing data for '".concat(field.name, "'"));
|
|
141
145
|
}
|
|
142
146
|
var value = data[field.name];
|
|
143
147
|
var _c = __read(encodeValue(typedData, field.type, value), 2), t = _c[0], encodedValue = _c[1];
|
package/index.js
CHANGED
|
@@ -4,12 +4,16 @@ var __createBinding =
|
|
|
4
4
|
(Object.create
|
|
5
5
|
? function (o, m, k, k2) {
|
|
6
6
|
if (k2 === undefined) k2 = k;
|
|
7
|
-
Object.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () {
|
|
12
|
+
return m[k];
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
Object.defineProperty(o, k2, desc);
|
|
13
17
|
}
|
|
14
18
|
: function (o, m, k, k2) {
|
|
15
19
|
if (k2 === undefined) k2 = k;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "starknet",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.13.0",
|
|
4
4
|
"description": "JavaScript library for StarkNet",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -27,45 +27,47 @@
|
|
|
27
27
|
"author": "Sean Han",
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@babel/
|
|
31
|
-
"@babel/preset-
|
|
32
|
-
"@
|
|
33
|
-
"@commitlint/
|
|
34
|
-
"@
|
|
35
|
-
"@semantic-release/
|
|
36
|
-
"@semantic-release/
|
|
37
|
-
"@semantic-release/
|
|
38
|
-
"@semantic-release/
|
|
39
|
-
"@
|
|
40
|
-
"@types/
|
|
30
|
+
"@babel/plugin-transform-modules-commonjs": "^7.18.2",
|
|
31
|
+
"@babel/preset-env": "^7.18.2",
|
|
32
|
+
"@babel/preset-typescript": "^7.17.12",
|
|
33
|
+
"@commitlint/cli": "^17.0.2",
|
|
34
|
+
"@commitlint/config-conventional": "^17.0.2",
|
|
35
|
+
"@semantic-release/changelog": "^6.0.1",
|
|
36
|
+
"@semantic-release/commit-analyzer": "^9.0.2",
|
|
37
|
+
"@semantic-release/git": "^10.0.1",
|
|
38
|
+
"@semantic-release/npm": "^9.0.1",
|
|
39
|
+
"@semantic-release/release-notes-generator": "^10.0.3",
|
|
40
|
+
"@types/elliptic": "^6.4.14",
|
|
41
|
+
"@types/jest": "^28.1.1",
|
|
41
42
|
"@types/json-bigint": "^1.0.1",
|
|
42
43
|
"@types/minimalistic-assert": "^1.0.1",
|
|
43
|
-
"@types/pako": "^
|
|
44
|
+
"@types/pako": "^2.0.0",
|
|
44
45
|
"@types/url-join": "^4.0.1",
|
|
45
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
46
|
-
"@typescript-eslint/parser": "^5.
|
|
47
|
-
"eslint": "^
|
|
48
|
-
"eslint-config-airbnb-base": "^
|
|
49
|
-
"eslint-config-airbnb-typescript": "^
|
|
50
|
-
"eslint-config-prettier": "^8.
|
|
51
|
-
"eslint-plugin-import": "^2.
|
|
46
|
+
"@typescript-eslint/eslint-plugin": "^5.28.0",
|
|
47
|
+
"@typescript-eslint/parser": "^5.28.0",
|
|
48
|
+
"eslint": "^8.17.0",
|
|
49
|
+
"eslint-config-airbnb-base": "^15.0.0",
|
|
50
|
+
"eslint-config-airbnb-typescript": "^17.0.0",
|
|
51
|
+
"eslint-config-prettier": "^8.5.0",
|
|
52
|
+
"eslint-plugin-import": "^2.26.0",
|
|
52
53
|
"eslint-plugin-prettier": "^4.0.0",
|
|
53
|
-
"husky": "^
|
|
54
|
+
"husky": "^8.0.1",
|
|
54
55
|
"import-sort-style-module": "^6.0.0",
|
|
55
|
-
"jest": "^
|
|
56
|
-
"
|
|
57
|
-
"
|
|
56
|
+
"jest": "^28.1.1",
|
|
57
|
+
"jest-environment-jsdom": "^28.1.1",
|
|
58
|
+
"lint-staged": "^13.0.1",
|
|
59
|
+
"prettier": "^2.7.0",
|
|
58
60
|
"prettier-plugin-import-sort": "^0.0.7",
|
|
59
|
-
"typedoc": "^0.22.
|
|
60
|
-
"typescript": "^4.
|
|
61
|
+
"typedoc": "^0.22.17",
|
|
62
|
+
"typescript": "^4.7.3",
|
|
61
63
|
"whatwg-fetch": "^3.6.2"
|
|
62
64
|
},
|
|
63
65
|
"dependencies": {
|
|
64
66
|
"@ethersproject/bytes": "^5.6.1",
|
|
65
|
-
"bn.js": "^5.2.
|
|
67
|
+
"bn.js": "^5.2.1",
|
|
66
68
|
"cross-fetch": "^3.1.5",
|
|
67
69
|
"elliptic": "^6.5.4",
|
|
68
|
-
"ethereum-cryptography": "^0.
|
|
70
|
+
"ethereum-cryptography": "^1.0.3",
|
|
69
71
|
"fetch-intercept": "^2.4.0",
|
|
70
72
|
"hash.js": "^1.1.7",
|
|
71
73
|
"json-bigint": "^1.0.0",
|
package/provider/default.d.ts
CHANGED
package/provider/default.js
CHANGED
|
@@ -184,7 +184,7 @@ var interface_1 = require('./interface');
|
|
|
184
184
|
var utils_1 = require('./utils');
|
|
185
185
|
function wait(delay) {
|
|
186
186
|
return new Promise(function (res) {
|
|
187
|
-
|
|
187
|
+
setTimeout(res, delay);
|
|
188
188
|
});
|
|
189
189
|
}
|
|
190
190
|
function isEmptyQueryObject(obj) {
|
|
@@ -242,7 +242,7 @@ var Provider = /** @class */ (function () {
|
|
|
242
242
|
}
|
|
243
243
|
} catch (_a) {
|
|
244
244
|
// eslint-disable-next-line no-console
|
|
245
|
-
console.error('Could not parse baseUrl: '
|
|
245
|
+
console.error('Could not parse baseUrl: '.concat(baseUrl));
|
|
246
246
|
}
|
|
247
247
|
return constants_1.StarknetChainId.TESTNET;
|
|
248
248
|
};
|
|
@@ -264,12 +264,12 @@ var Provider = /** @class */ (function () {
|
|
|
264
264
|
key = _b[0],
|
|
265
265
|
value = _b[1];
|
|
266
266
|
if (key === 'blockIdentifier') {
|
|
267
|
-
return ''
|
|
267
|
+
return ''.concat((0, utils_1.getFormattedBlockIdentifier)(value));
|
|
268
268
|
}
|
|
269
|
-
return key
|
|
269
|
+
return ''.concat(key, '=').concat(value);
|
|
270
270
|
})
|
|
271
271
|
.join('&');
|
|
272
|
-
return '?'
|
|
272
|
+
return '?'.concat(queryString);
|
|
273
273
|
};
|
|
274
274
|
Provider.prototype.getHeaders = function (method) {
|
|
275
275
|
if (method === 'POST') {
|
|
@@ -609,11 +609,10 @@ var Provider = /** @class */ (function () {
|
|
|
609
609
|
onchain = true;
|
|
610
610
|
} else if (errorStates.includes(res.tx_status)) {
|
|
611
611
|
message = res.tx_failure_reason
|
|
612
|
-
?
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
res.tx_failure_reason.error_message
|
|
612
|
+
? ''
|
|
613
|
+
.concat(res.tx_status, ': ')
|
|
614
|
+
.concat(res.tx_failure_reason.code, '\n')
|
|
615
|
+
.concat(res.tx_failure_reason.error_message)
|
|
617
616
|
: res.tx_status;
|
|
618
617
|
error = new Error(message);
|
|
619
618
|
error.response = res;
|
package/provider/index.js
CHANGED
|
@@ -4,12 +4,16 @@ var __createBinding =
|
|
|
4
4
|
(Object.create
|
|
5
5
|
? function (o, m, k, k2) {
|
|
6
6
|
if (k2 === undefined) k2 = k;
|
|
7
|
-
Object.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () {
|
|
12
|
+
return m[k];
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
Object.defineProperty(o, k2, desc);
|
|
13
17
|
}
|
|
14
18
|
: function (o, m, k, k2) {
|
|
15
19
|
if (k2 === undefined) k2 = k;
|