starknet 10.3.0 → 10.3.2
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 +12 -0
- package/dist/index.d.ts +195 -199
- package/dist/index.global.js +61 -31
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +61 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +61 -31
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -1690,8 +1690,11 @@ var CairoUint512 = class _CairoUint512 {
|
|
|
1690
1690
|
var isLen = (name) => /_len$/.test(name);
|
|
1691
1691
|
var isTypeFelt = (type) => type === "felt" || type === "core::felt252";
|
|
1692
1692
|
var isTypeArray = (type) => /\*/.test(type) || type.startsWith("core::array::Array::") || type.startsWith("core::array::Span::");
|
|
1693
|
-
var isTypeTuple = (type) =>
|
|
1694
|
-
var isTypeNamedTuple = (type) =>
|
|
1693
|
+
var isTypeTuple = (type) => type.startsWith("(") && type.endsWith(")");
|
|
1694
|
+
var isTypeNamedTuple = (type) => {
|
|
1695
|
+
const start = type.indexOf("(");
|
|
1696
|
+
return start !== -1 && type.indexOf(")", start + 1) !== -1 && type.includes(":");
|
|
1697
|
+
};
|
|
1695
1698
|
var isTypeStruct = (type, structs) => type in structs;
|
|
1696
1699
|
var isTypeEnum = (type, enums) => type in enums;
|
|
1697
1700
|
var isTypeOption = (type) => type.startsWith("core::option::Option::");
|
|
@@ -1707,7 +1710,7 @@ var isTypeU96 = (type) => type === "core::internal::bounded_int::BoundedInt::<0,
|
|
|
1707
1710
|
var isTypeSecp256k1Point = (type) => type === Literal.Secp256k1Point;
|
|
1708
1711
|
var isCairo1Type = (type) => type.includes("::");
|
|
1709
1712
|
var getArrayType = (type) => {
|
|
1710
|
-
return isCairo1Type(type) ? type.substring(type.indexOf("<") + 1, type.lastIndexOf(">")) : type.
|
|
1713
|
+
return isCairo1Type(type) ? type.substring(type.indexOf("<") + 1, type.lastIndexOf(">")) : type.replaceAll("*", "");
|
|
1711
1714
|
};
|
|
1712
1715
|
function isCairo1Abi(abi) {
|
|
1713
1716
|
const { cairo } = getAbiContractVersion(abi);
|
|
@@ -3510,6 +3513,18 @@ var CairoFixedArray = class _CairoFixedArray {
|
|
|
3510
3513
|
* Cairo fixed array type.
|
|
3511
3514
|
*/
|
|
3512
3515
|
arrayType;
|
|
3516
|
+
static parseFixedArrayType(type) {
|
|
3517
|
+
if (!type.startsWith("[") || !type.endsWith("]")) {
|
|
3518
|
+
return void 0;
|
|
3519
|
+
}
|
|
3520
|
+
const separator = type.lastIndexOf("; ");
|
|
3521
|
+
const itemType = type.slice(1, separator);
|
|
3522
|
+
const size = type.slice(separator + 2, -1);
|
|
3523
|
+
if (separator <= 1 || size.length === 0 || ![...size].every((char) => char >= "0" && char <= "9")) {
|
|
3524
|
+
return void 0;
|
|
3525
|
+
}
|
|
3526
|
+
return { itemType, size };
|
|
3527
|
+
}
|
|
3513
3528
|
/**
|
|
3514
3529
|
* Create an instance representing a Cairo fixed Array.
|
|
3515
3530
|
* @param {any[]} content JS array representing a Cairo fixed array.
|
|
@@ -3553,10 +3568,10 @@ var CairoFixedArray = class _CairoFixedArray {
|
|
|
3553
3568
|
* ```
|
|
3554
3569
|
*/
|
|
3555
3570
|
static getFixedArraySize(type) {
|
|
3556
|
-
const
|
|
3557
|
-
if (
|
|
3571
|
+
const fixedArrayType = _CairoFixedArray.parseFixedArrayType(type);
|
|
3572
|
+
if (!fixedArrayType)
|
|
3558
3573
|
throw new Error(`ABI type ${type} do not includes a valid number after ';' character.`);
|
|
3559
|
-
return Number(
|
|
3574
|
+
return Number(fixedArrayType.size);
|
|
3560
3575
|
}
|
|
3561
3576
|
/**
|
|
3562
3577
|
* Retrieves the Cairo fixed array size from the CairoFixedArray instance.
|
|
@@ -3582,10 +3597,9 @@ var CairoFixedArray = class _CairoFixedArray {
|
|
|
3582
3597
|
* ```
|
|
3583
3598
|
*/
|
|
3584
3599
|
static getFixedArrayType = (type) => {
|
|
3585
|
-
const
|
|
3586
|
-
if (
|
|
3587
|
-
|
|
3588
|
-
return matchArray[0];
|
|
3600
|
+
const fixedArrayType = _CairoFixedArray.parseFixedArrayType(type);
|
|
3601
|
+
if (!fixedArrayType) throw new Error(`ABI type ${type} do not includes a valid type of data.`);
|
|
3602
|
+
return fixedArrayType.itemType;
|
|
3589
3603
|
};
|
|
3590
3604
|
/**
|
|
3591
3605
|
* Retrieve the Cairo content type of the Cairo fixed array.
|
|
@@ -3643,7 +3657,7 @@ var CairoFixedArray = class _CairoFixedArray {
|
|
|
3643
3657
|
* // result = true
|
|
3644
3658
|
*/
|
|
3645
3659
|
static isTypeFixedArray(type) {
|
|
3646
|
-
return
|
|
3660
|
+
return _CairoFixedArray.parseFixedArrayType(type) !== void 0;
|
|
3647
3661
|
}
|
|
3648
3662
|
};
|
|
3649
3663
|
|
|
@@ -4311,7 +4325,7 @@ function responseParser({
|
|
|
4311
4325
|
parsedDataArr.push(
|
|
4312
4326
|
parseResponseValue(
|
|
4313
4327
|
responseIterator,
|
|
4314
|
-
{ name, type: output.type.
|
|
4328
|
+
{ name, type: output.type.replaceAll("*", "") },
|
|
4315
4329
|
parser,
|
|
4316
4330
|
structs,
|
|
4317
4331
|
enums
|
|
@@ -6307,18 +6321,20 @@ var RpcChannel = class {
|
|
|
6307
6321
|
}
|
|
6308
6322
|
async fetchEndpoint(method, params) {
|
|
6309
6323
|
try {
|
|
6324
|
+
let error;
|
|
6325
|
+
let result;
|
|
6310
6326
|
if (this.batchClient) {
|
|
6311
|
-
|
|
6312
|
-
|
|
6313
|
-
|
|
6314
|
-
|
|
6315
|
-
);
|
|
6316
|
-
this.errorHandler(method, params, error2);
|
|
6317
|
-
return result2;
|
|
6327
|
+
({ error, result } = await this.batchClient.fetch(method, params, this.requestId += 1));
|
|
6328
|
+
} else {
|
|
6329
|
+
const rawResult = await this.fetch(method, params, this.requestId += 1);
|
|
6330
|
+
({ error, result } = await rawResult.json());
|
|
6318
6331
|
}
|
|
6319
|
-
const rawResult = await this.fetch(method, params, this.requestId += 1);
|
|
6320
|
-
const { error, result } = await rawResult.json();
|
|
6321
6332
|
this.errorHandler(method, params, error);
|
|
6333
|
+
if (result === void 0) {
|
|
6334
|
+
throw new LibraryError(
|
|
6335
|
+
`RPC: '${method}' returned an empty response (no result and no error). The node reply is malformed or not a valid JSON-RPC response.`
|
|
6336
|
+
);
|
|
6337
|
+
}
|
|
6322
6338
|
return result;
|
|
6323
6339
|
} catch (error) {
|
|
6324
6340
|
this.errorHandler(method, params, error?.response?.data, error);
|
|
@@ -6862,18 +6878,20 @@ var RpcChannel2 = class {
|
|
|
6862
6878
|
}
|
|
6863
6879
|
async fetchEndpoint(method, params) {
|
|
6864
6880
|
try {
|
|
6881
|
+
let error;
|
|
6882
|
+
let result;
|
|
6865
6883
|
if (this.batchClient) {
|
|
6866
|
-
|
|
6867
|
-
|
|
6868
|
-
|
|
6869
|
-
|
|
6870
|
-
);
|
|
6871
|
-
this.errorHandler(method, params, error2);
|
|
6872
|
-
return result2;
|
|
6884
|
+
({ error, result } = await this.batchClient.fetch(method, params, this.requestId += 1));
|
|
6885
|
+
} else {
|
|
6886
|
+
const rawResult = await this.fetch(method, params, this.requestId += 1);
|
|
6887
|
+
({ error, result } = await rawResult.json());
|
|
6873
6888
|
}
|
|
6874
|
-
const rawResult = await this.fetch(method, params, this.requestId += 1);
|
|
6875
|
-
const { error, result } = await rawResult.json();
|
|
6876
6889
|
this.errorHandler(method, params, error);
|
|
6890
|
+
if (result === void 0) {
|
|
6891
|
+
throw new LibraryError(
|
|
6892
|
+
`RPC: '${method}' returned an empty response (no result and no error). The node reply is malformed or not a valid JSON-RPC response.`
|
|
6893
|
+
);
|
|
6894
|
+
}
|
|
6877
6895
|
return result;
|
|
6878
6896
|
} catch (error) {
|
|
6879
6897
|
this.errorHandler(method, params, error?.response?.data, error);
|
|
@@ -9189,7 +9207,19 @@ function dynamicCallData(hardcoded, reference = void 0, arrayReference = void 0)
|
|
|
9189
9207
|
});
|
|
9190
9208
|
}
|
|
9191
9209
|
function isStarkDomain(domain) {
|
|
9192
|
-
|
|
9210
|
+
const starkSuffix = ".stark";
|
|
9211
|
+
if (!domain.endsWith(starkSuffix)) {
|
|
9212
|
+
return false;
|
|
9213
|
+
}
|
|
9214
|
+
const name = domain.slice(0, -starkSuffix.length);
|
|
9215
|
+
if (name.length === 0) {
|
|
9216
|
+
return false;
|
|
9217
|
+
}
|
|
9218
|
+
return name.split(".").every((label) => {
|
|
9219
|
+
return label.length > 0 && label.length <= 48 && [...label].every((char) => {
|
|
9220
|
+
return char >= "a" && char <= "z" || char >= "0" && char <= "9" || char === "-";
|
|
9221
|
+
});
|
|
9222
|
+
});
|
|
9193
9223
|
}
|
|
9194
9224
|
|
|
9195
9225
|
// src/plugins/starknet-id/index.ts
|