starknet 5.6.0 → 5.6.1
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 +7 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.global.js +17 -7
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +17 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2313,6 +2313,7 @@ __export(cairo_exports, {
|
|
|
2313
2313
|
isTypeStruct: () => isTypeStruct,
|
|
2314
2314
|
isTypeTuple: () => isTypeTuple,
|
|
2315
2315
|
isTypeUint: () => isTypeUint,
|
|
2316
|
+
isTypeUint256: () => isTypeUint256,
|
|
2316
2317
|
tuple: () => tuple,
|
|
2317
2318
|
uint256: () => uint256
|
|
2318
2319
|
});
|
|
@@ -2508,6 +2509,7 @@ var isTypeTuple = (type) => /^\(.*\)$/i.test(type);
|
|
|
2508
2509
|
var isTypeNamedTuple = (type) => /\(.*\)/i.test(type) && type.includes(":");
|
|
2509
2510
|
var isTypeStruct = (type, structs) => type in structs;
|
|
2510
2511
|
var isTypeUint = (type) => Object.values(Uint).includes(type);
|
|
2512
|
+
var isTypeUint256 = (type) => type === "core::integer::u256";
|
|
2511
2513
|
var isTypeBool = (type) => type === "core::bool";
|
|
2512
2514
|
var isTypeContractAddress = (type) => type === "core::starknet::contract_address::ContractAddress";
|
|
2513
2515
|
var isCairo1Type = (type) => type.includes("core::");
|
|
@@ -3797,10 +3799,11 @@ var SequencerProvider = class {
|
|
|
3797
3799
|
const url = buildUrl(this.baseUrl, "", endpoint);
|
|
3798
3800
|
const method = (options == null ? void 0 : options.method) ?? "GET";
|
|
3799
3801
|
const headers = this.getHeaders(method);
|
|
3802
|
+
const body = stringify2(options == null ? void 0 : options.body);
|
|
3800
3803
|
try {
|
|
3801
3804
|
const response = await fetchPonyfill_default(url, {
|
|
3802
3805
|
method,
|
|
3803
|
-
body
|
|
3806
|
+
body,
|
|
3804
3807
|
headers
|
|
3805
3808
|
});
|
|
3806
3809
|
const textResponse = await response.text();
|
|
@@ -4366,6 +4369,10 @@ function parseCalldataValue(element, type, structs) {
|
|
|
4366
4369
|
if (Array.isArray(element)) {
|
|
4367
4370
|
throw Error(`Array inside array (nD) are not supported by cairo. Element: ${element} ${type}`);
|
|
4368
4371
|
}
|
|
4372
|
+
if (isTypeUint256(type)) {
|
|
4373
|
+
const el_uint256 = uint256(element);
|
|
4374
|
+
return [felt(el_uint256.low), felt(el_uint256.high)];
|
|
4375
|
+
}
|
|
4369
4376
|
if (structs[type] && structs[type].members.length) {
|
|
4370
4377
|
const { members } = structs[type];
|
|
4371
4378
|
const subElement = element;
|
|
@@ -4409,10 +4416,10 @@ function parseCalldataField(argsIterator, input, structs) {
|
|
|
4409
4416
|
}
|
|
4410
4417
|
return acc;
|
|
4411
4418
|
}, result);
|
|
4412
|
-
case (isTypeStruct(type, structs) || isTypeTuple(type)):
|
|
4419
|
+
case (isTypeStruct(type, structs) || isTypeTuple(type) || isTypeUint256(type)):
|
|
4413
4420
|
return parseCalldataValue(value, type, structs);
|
|
4414
4421
|
case isTypeBool(type):
|
|
4415
|
-
return value
|
|
4422
|
+
return `${+value}`;
|
|
4416
4423
|
default:
|
|
4417
4424
|
return felt(value);
|
|
4418
4425
|
}
|
|
@@ -4448,6 +4455,10 @@ function responseParser(responseIterator, output, structs, parsedResult) {
|
|
|
4448
4455
|
case isTypeBool(type):
|
|
4449
4456
|
temp = responseIterator.next().value;
|
|
4450
4457
|
return Boolean(BigInt(temp));
|
|
4458
|
+
case isTypeUint256(type):
|
|
4459
|
+
const low = responseIterator.next().value;
|
|
4460
|
+
const high = responseIterator.next().value;
|
|
4461
|
+
return uint256ToBN({ low, high });
|
|
4451
4462
|
case isTypeArray(type):
|
|
4452
4463
|
const parsedDataArr = [];
|
|
4453
4464
|
if (isCairo1Type(type)) {
|
|
@@ -4845,11 +4856,10 @@ var Contract = class {
|
|
|
4845
4856
|
return this;
|
|
4846
4857
|
}
|
|
4847
4858
|
async call(method, args = [], options = { parseRequest: true, parseResponse: true, formatResponse: void 0 }) {
|
|
4848
|
-
var _a;
|
|
4849
4859
|
assert(this.address !== null, "contract is not connected to an address");
|
|
4850
4860
|
const blockIdentifier = (options == null ? void 0 : options.blockIdentifier) || void 0;
|
|
4851
|
-
let calldata = args[0];
|
|
4852
|
-
if (options.parseRequest && !(
|
|
4861
|
+
let calldata = "compiled" in args ? args : args[0];
|
|
4862
|
+
if (options.parseRequest && !(calldata == null ? void 0 : calldata.compiled)) {
|
|
4853
4863
|
const { inputs } = this.abi.find((abi) => abi.name === method);
|
|
4854
4864
|
this.callData.validate("CALL", method, args);
|
|
4855
4865
|
calldata = this.callData.compile(args, inputs);
|
|
@@ -4875,7 +4885,7 @@ var Contract = class {
|
|
|
4875
4885
|
parseRequest: true
|
|
4876
4886
|
}) {
|
|
4877
4887
|
assert(this.address !== null, "contract is not connected to an address");
|
|
4878
|
-
let calldata =
|
|
4888
|
+
let calldata = "compiled" in args ? args : args[0];
|
|
4879
4889
|
if (options.parseRequest && !(calldata == null ? void 0 : calldata.compiled)) {
|
|
4880
4890
|
const { inputs } = this.abi.find((abi) => abi.name === method);
|
|
4881
4891
|
this.callData.validate("INVOKE", method, args);
|