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.mjs
CHANGED
|
@@ -2245,6 +2245,7 @@ __export(cairo_exports, {
|
|
|
2245
2245
|
isTypeStruct: () => isTypeStruct,
|
|
2246
2246
|
isTypeTuple: () => isTypeTuple,
|
|
2247
2247
|
isTypeUint: () => isTypeUint,
|
|
2248
|
+
isTypeUint256: () => isTypeUint256,
|
|
2248
2249
|
tuple: () => tuple,
|
|
2249
2250
|
uint256: () => uint256
|
|
2250
2251
|
});
|
|
@@ -2440,6 +2441,7 @@ var isTypeTuple = (type) => /^\(.*\)$/i.test(type);
|
|
|
2440
2441
|
var isTypeNamedTuple = (type) => /\(.*\)/i.test(type) && type.includes(":");
|
|
2441
2442
|
var isTypeStruct = (type, structs) => type in structs;
|
|
2442
2443
|
var isTypeUint = (type) => Object.values(Uint).includes(type);
|
|
2444
|
+
var isTypeUint256 = (type) => type === "core::integer::u256";
|
|
2443
2445
|
var isTypeBool = (type) => type === "core::bool";
|
|
2444
2446
|
var isTypeContractAddress = (type) => type === "core::starknet::contract_address::ContractAddress";
|
|
2445
2447
|
var isCairo1Type = (type) => type.includes("core::");
|
|
@@ -3729,10 +3731,11 @@ var SequencerProvider = class {
|
|
|
3729
3731
|
const url = buildUrl(this.baseUrl, "", endpoint);
|
|
3730
3732
|
const method = (options == null ? void 0 : options.method) ?? "GET";
|
|
3731
3733
|
const headers = this.getHeaders(method);
|
|
3734
|
+
const body = stringify2(options == null ? void 0 : options.body);
|
|
3732
3735
|
try {
|
|
3733
3736
|
const response = await fetchPonyfill_default(url, {
|
|
3734
3737
|
method,
|
|
3735
|
-
body
|
|
3738
|
+
body,
|
|
3736
3739
|
headers
|
|
3737
3740
|
});
|
|
3738
3741
|
const textResponse = await response.text();
|
|
@@ -4298,6 +4301,10 @@ function parseCalldataValue(element, type, structs) {
|
|
|
4298
4301
|
if (Array.isArray(element)) {
|
|
4299
4302
|
throw Error(`Array inside array (nD) are not supported by cairo. Element: ${element} ${type}`);
|
|
4300
4303
|
}
|
|
4304
|
+
if (isTypeUint256(type)) {
|
|
4305
|
+
const el_uint256 = uint256(element);
|
|
4306
|
+
return [felt(el_uint256.low), felt(el_uint256.high)];
|
|
4307
|
+
}
|
|
4301
4308
|
if (structs[type] && structs[type].members.length) {
|
|
4302
4309
|
const { members } = structs[type];
|
|
4303
4310
|
const subElement = element;
|
|
@@ -4341,10 +4348,10 @@ function parseCalldataField(argsIterator, input, structs) {
|
|
|
4341
4348
|
}
|
|
4342
4349
|
return acc;
|
|
4343
4350
|
}, result);
|
|
4344
|
-
case (isTypeStruct(type, structs) || isTypeTuple(type)):
|
|
4351
|
+
case (isTypeStruct(type, structs) || isTypeTuple(type) || isTypeUint256(type)):
|
|
4345
4352
|
return parseCalldataValue(value, type, structs);
|
|
4346
4353
|
case isTypeBool(type):
|
|
4347
|
-
return value
|
|
4354
|
+
return `${+value}`;
|
|
4348
4355
|
default:
|
|
4349
4356
|
return felt(value);
|
|
4350
4357
|
}
|
|
@@ -4380,6 +4387,10 @@ function responseParser(responseIterator, output, structs, parsedResult) {
|
|
|
4380
4387
|
case isTypeBool(type):
|
|
4381
4388
|
temp = responseIterator.next().value;
|
|
4382
4389
|
return Boolean(BigInt(temp));
|
|
4390
|
+
case isTypeUint256(type):
|
|
4391
|
+
const low = responseIterator.next().value;
|
|
4392
|
+
const high = responseIterator.next().value;
|
|
4393
|
+
return uint256ToBN({ low, high });
|
|
4383
4394
|
case isTypeArray(type):
|
|
4384
4395
|
const parsedDataArr = [];
|
|
4385
4396
|
if (isCairo1Type(type)) {
|
|
@@ -4777,11 +4788,10 @@ var Contract = class {
|
|
|
4777
4788
|
return this;
|
|
4778
4789
|
}
|
|
4779
4790
|
async call(method, args = [], options = { parseRequest: true, parseResponse: true, formatResponse: void 0 }) {
|
|
4780
|
-
var _a;
|
|
4781
4791
|
assert(this.address !== null, "contract is not connected to an address");
|
|
4782
4792
|
const blockIdentifier = (options == null ? void 0 : options.blockIdentifier) || void 0;
|
|
4783
|
-
let calldata = args[0];
|
|
4784
|
-
if (options.parseRequest && !(
|
|
4793
|
+
let calldata = "compiled" in args ? args : args[0];
|
|
4794
|
+
if (options.parseRequest && !(calldata == null ? void 0 : calldata.compiled)) {
|
|
4785
4795
|
const { inputs } = this.abi.find((abi) => abi.name === method);
|
|
4786
4796
|
this.callData.validate("CALL", method, args);
|
|
4787
4797
|
calldata = this.callData.compile(args, inputs);
|
|
@@ -4807,7 +4817,7 @@ var Contract = class {
|
|
|
4807
4817
|
parseRequest: true
|
|
4808
4818
|
}) {
|
|
4809
4819
|
assert(this.address !== null, "contract is not connected to an address");
|
|
4810
|
-
let calldata =
|
|
4820
|
+
let calldata = "compiled" in args ? args : args[0];
|
|
4811
4821
|
if (options.parseRequest && !(calldata == null ? void 0 : calldata.compiled)) {
|
|
4812
4822
|
const { inputs } = this.abi.find((abi) => abi.name === method);
|
|
4813
4823
|
this.callData.validate("INVOKE", method, args);
|