starknet 6.8.0 → 6.9.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 +17 -1
- package/dist/index.d.ts +367 -109
- package/dist/index.global.js +1140 -801
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +339 -218
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +337 -215
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -5
package/dist/index.global.js
CHANGED
|
@@ -12324,9 +12324,9 @@ var starknet = (() => {
|
|
|
12324
12324
|
var form = new FormData();
|
|
12325
12325
|
body.trim().split("&").forEach(function(bytes3) {
|
|
12326
12326
|
if (bytes3) {
|
|
12327
|
-
var
|
|
12328
|
-
var name =
|
|
12329
|
-
var value =
|
|
12327
|
+
var split3 = bytes3.split("=");
|
|
12328
|
+
var name = split3.shift().replace(/\+/g, " ");
|
|
12329
|
+
var value = split3.join("=").replace(/\+/g, " ");
|
|
12330
12330
|
form.append(decodeURIComponent(name), decodeURIComponent(value));
|
|
12331
12331
|
}
|
|
12332
12332
|
});
|
|
@@ -12702,7 +12702,6 @@ var starknet = (() => {
|
|
|
12702
12702
|
ReceiptTx: () => ReceiptTx,
|
|
12703
12703
|
RpcChannel: () => RpcChannel2,
|
|
12704
12704
|
RpcProvider: () => RpcProvider2,
|
|
12705
|
-
SIMULATION_FLAG: () => SIMULATION_FLAG,
|
|
12706
12705
|
Signer: () => Signer,
|
|
12707
12706
|
SignerInterface: () => SignerInterface,
|
|
12708
12707
|
TransactionExecutionStatus: () => TransactionExecutionStatus,
|
|
@@ -13299,19 +13298,16 @@ var starknet = (() => {
|
|
|
13299
13298
|
var RANGE_U128 = range(ZERO, 2n ** 128n - 1n);
|
|
13300
13299
|
var BaseUrl = /* @__PURE__ */ ((BaseUrl2) => {
|
|
13301
13300
|
BaseUrl2["SN_MAIN"] = "https://alpha-mainnet.starknet.io";
|
|
13302
|
-
BaseUrl2["SN_GOERLI"] = "https://alpha4.starknet.io";
|
|
13303
13301
|
BaseUrl2["SN_SEPOLIA"] = "https://alpha-sepolia.starknet.io";
|
|
13304
13302
|
return BaseUrl2;
|
|
13305
13303
|
})(BaseUrl || {});
|
|
13306
13304
|
var NetworkName = /* @__PURE__ */ ((NetworkName2) => {
|
|
13307
13305
|
NetworkName2["SN_MAIN"] = "SN_MAIN";
|
|
13308
|
-
NetworkName2["SN_GOERLI"] = "SN_GOERLI";
|
|
13309
13306
|
NetworkName2["SN_SEPOLIA"] = "SN_SEPOLIA";
|
|
13310
13307
|
return NetworkName2;
|
|
13311
13308
|
})(NetworkName || {});
|
|
13312
13309
|
var StarknetChainId = /* @__PURE__ */ ((StarknetChainId6) => {
|
|
13313
13310
|
StarknetChainId6["SN_MAIN"] = "0x534e5f4d41494e";
|
|
13314
|
-
StarknetChainId6["SN_GOERLI"] = "0x534e5f474f45524c49";
|
|
13315
13311
|
StarknetChainId6["SN_SEPOLIA"] = "0x534e5f5345504f4c4941";
|
|
13316
13312
|
return StarknetChainId6;
|
|
13317
13313
|
})(StarknetChainId || {});
|
|
@@ -13335,10 +13331,6 @@ var starknet = (() => {
|
|
|
13335
13331
|
};
|
|
13336
13332
|
var RPC_DEFAULT_VERSION = "v0_7";
|
|
13337
13333
|
var RPC_NODES = {
|
|
13338
|
-
SN_GOERLI: [
|
|
13339
|
-
`https://starknet-testnet.public.blastapi.io/rpc/${RPC_DEFAULT_VERSION}`,
|
|
13340
|
-
`https://free-rpc.nethermind.io/goerli-juno/${RPC_DEFAULT_VERSION}`
|
|
13341
|
-
],
|
|
13342
13334
|
SN_MAIN: [
|
|
13343
13335
|
`https://starknet-mainnet.public.blastapi.io/rpc/${RPC_DEFAULT_VERSION}`,
|
|
13344
13336
|
`https://free-rpc.nethermind.io/mainnet-juno/${RPC_DEFAULT_VERSION}`
|
|
@@ -13349,181 +13341,6 @@ var starknet = (() => {
|
|
|
13349
13341
|
]
|
|
13350
13342
|
};
|
|
13351
13343
|
|
|
13352
|
-
// src/provider/errors.ts
|
|
13353
|
-
function fixStack(target, fn = target.constructor) {
|
|
13354
|
-
const { captureStackTrace } = Error;
|
|
13355
|
-
captureStackTrace && captureStackTrace(target, fn);
|
|
13356
|
-
}
|
|
13357
|
-
function fixProto(target, prototype) {
|
|
13358
|
-
const { setPrototypeOf } = Object;
|
|
13359
|
-
setPrototypeOf ? setPrototypeOf(target, prototype) : target.__proto__ = prototype;
|
|
13360
|
-
}
|
|
13361
|
-
var CustomError = class extends Error {
|
|
13362
|
-
name;
|
|
13363
|
-
constructor(message) {
|
|
13364
|
-
super(message);
|
|
13365
|
-
Object.defineProperty(this, "name", {
|
|
13366
|
-
value: new.target.name,
|
|
13367
|
-
enumerable: false,
|
|
13368
|
-
configurable: true
|
|
13369
|
-
});
|
|
13370
|
-
fixProto(this, new.target.prototype);
|
|
13371
|
-
fixStack(this);
|
|
13372
|
-
}
|
|
13373
|
-
};
|
|
13374
|
-
var LibraryError = class extends CustomError {
|
|
13375
|
-
};
|
|
13376
|
-
var GatewayError = class extends LibraryError {
|
|
13377
|
-
constructor(message, errorCode) {
|
|
13378
|
-
super(message);
|
|
13379
|
-
this.errorCode = errorCode;
|
|
13380
|
-
}
|
|
13381
|
-
};
|
|
13382
|
-
var HttpError = class extends LibraryError {
|
|
13383
|
-
constructor(message, errorCode) {
|
|
13384
|
-
super(message);
|
|
13385
|
-
this.errorCode = errorCode;
|
|
13386
|
-
}
|
|
13387
|
-
};
|
|
13388
|
-
|
|
13389
|
-
// src/channel/rpc_0_6.ts
|
|
13390
|
-
var rpc_0_6_exports = {};
|
|
13391
|
-
__export(rpc_0_6_exports, {
|
|
13392
|
-
RpcChannel: () => RpcChannel
|
|
13393
|
-
});
|
|
13394
|
-
|
|
13395
|
-
// src/types/index.ts
|
|
13396
|
-
var types_exports = {};
|
|
13397
|
-
__export(types_exports, {
|
|
13398
|
-
BlockStatus: () => BlockStatus,
|
|
13399
|
-
BlockTag: () => BlockTag,
|
|
13400
|
-
EntryPointType: () => EntryPointType,
|
|
13401
|
-
Literal: () => Literal,
|
|
13402
|
-
RPC: () => api_exports2,
|
|
13403
|
-
SIMULATION_FLAG: () => SIMULATION_FLAG,
|
|
13404
|
-
TransactionExecutionStatus: () => TransactionExecutionStatus,
|
|
13405
|
-
TransactionFinalityStatus: () => TransactionFinalityStatus,
|
|
13406
|
-
TransactionStatus: () => TransactionStatus,
|
|
13407
|
-
TransactionType: () => TransactionType,
|
|
13408
|
-
TypedDataRevision: () => TypedDataRevision,
|
|
13409
|
-
Uint: () => Uint,
|
|
13410
|
-
ValidateType: () => ValidateType
|
|
13411
|
-
});
|
|
13412
|
-
|
|
13413
|
-
// src/types/account.ts
|
|
13414
|
-
var SIMULATION_FLAG = /* @__PURE__ */ ((SIMULATION_FLAG2) => {
|
|
13415
|
-
SIMULATION_FLAG2["SKIP_VALIDATE"] = "SKIP_VALIDATE";
|
|
13416
|
-
SIMULATION_FLAG2["SKIP_EXECUTE"] = "SKIP_EXECUTE";
|
|
13417
|
-
return SIMULATION_FLAG2;
|
|
13418
|
-
})(SIMULATION_FLAG || {});
|
|
13419
|
-
|
|
13420
|
-
// src/types/calldata.ts
|
|
13421
|
-
var ValidateType = /* @__PURE__ */ ((ValidateType2) => {
|
|
13422
|
-
ValidateType2["DEPLOY"] = "DEPLOY";
|
|
13423
|
-
ValidateType2["CALL"] = "CALL";
|
|
13424
|
-
ValidateType2["INVOKE"] = "INVOKE";
|
|
13425
|
-
return ValidateType2;
|
|
13426
|
-
})(ValidateType || {});
|
|
13427
|
-
var Uint = /* @__PURE__ */ ((Uint2) => {
|
|
13428
|
-
Uint2["u8"] = "core::integer::u8";
|
|
13429
|
-
Uint2["u16"] = "core::integer::u16";
|
|
13430
|
-
Uint2["u32"] = "core::integer::u32";
|
|
13431
|
-
Uint2["u64"] = "core::integer::u64";
|
|
13432
|
-
Uint2["u128"] = "core::integer::u128";
|
|
13433
|
-
Uint2["u256"] = "core::integer::u256";
|
|
13434
|
-
Uint2["u512"] = "core::integer::u512";
|
|
13435
|
-
return Uint2;
|
|
13436
|
-
})(Uint || {});
|
|
13437
|
-
var Literal = /* @__PURE__ */ ((Literal2) => {
|
|
13438
|
-
Literal2["ClassHash"] = "core::starknet::class_hash::ClassHash";
|
|
13439
|
-
Literal2["ContractAddress"] = "core::starknet::contract_address::ContractAddress";
|
|
13440
|
-
Literal2["Secp256k1Point"] = "core::starknet::secp256k1::Secp256k1Point";
|
|
13441
|
-
return Literal2;
|
|
13442
|
-
})(Literal || {});
|
|
13443
|
-
|
|
13444
|
-
// src/types/lib/contract/index.ts
|
|
13445
|
-
var EntryPointType = /* @__PURE__ */ ((EntryPointType2) => {
|
|
13446
|
-
EntryPointType2["EXTERNAL"] = "EXTERNAL";
|
|
13447
|
-
EntryPointType2["L1_HANDLER"] = "L1_HANDLER";
|
|
13448
|
-
EntryPointType2["CONSTRUCTOR"] = "CONSTRUCTOR";
|
|
13449
|
-
return EntryPointType2;
|
|
13450
|
-
})(EntryPointType || {});
|
|
13451
|
-
|
|
13452
|
-
// src/types/lib/index.ts
|
|
13453
|
-
var TransactionType = /* @__PURE__ */ ((TransactionType2) => {
|
|
13454
|
-
TransactionType2["DECLARE"] = "DECLARE";
|
|
13455
|
-
TransactionType2["DEPLOY"] = "DEPLOY";
|
|
13456
|
-
TransactionType2["DEPLOY_ACCOUNT"] = "DEPLOY_ACCOUNT";
|
|
13457
|
-
TransactionType2["INVOKE"] = "INVOKE_FUNCTION";
|
|
13458
|
-
return TransactionType2;
|
|
13459
|
-
})(TransactionType || {});
|
|
13460
|
-
var TransactionStatus = /* @__PURE__ */ ((TransactionStatus2) => {
|
|
13461
|
-
TransactionStatus2["NOT_RECEIVED"] = "NOT_RECEIVED";
|
|
13462
|
-
TransactionStatus2["RECEIVED"] = "RECEIVED";
|
|
13463
|
-
TransactionStatus2["ACCEPTED_ON_L2"] = "ACCEPTED_ON_L2";
|
|
13464
|
-
TransactionStatus2["ACCEPTED_ON_L1"] = "ACCEPTED_ON_L1";
|
|
13465
|
-
TransactionStatus2["REJECTED"] = "REJECTED";
|
|
13466
|
-
TransactionStatus2["REVERTED"] = "REVERTED";
|
|
13467
|
-
return TransactionStatus2;
|
|
13468
|
-
})(TransactionStatus || {});
|
|
13469
|
-
var TransactionFinalityStatus = /* @__PURE__ */ ((TransactionFinalityStatus2) => {
|
|
13470
|
-
TransactionFinalityStatus2["NOT_RECEIVED"] = "NOT_RECEIVED";
|
|
13471
|
-
TransactionFinalityStatus2["RECEIVED"] = "RECEIVED";
|
|
13472
|
-
TransactionFinalityStatus2["ACCEPTED_ON_L2"] = "ACCEPTED_ON_L2";
|
|
13473
|
-
TransactionFinalityStatus2["ACCEPTED_ON_L1"] = "ACCEPTED_ON_L1";
|
|
13474
|
-
return TransactionFinalityStatus2;
|
|
13475
|
-
})(TransactionFinalityStatus || {});
|
|
13476
|
-
var TransactionExecutionStatus = /* @__PURE__ */ ((TransactionExecutionStatus2) => {
|
|
13477
|
-
TransactionExecutionStatus2["REJECTED"] = "REJECTED";
|
|
13478
|
-
TransactionExecutionStatus2["REVERTED"] = "REVERTED";
|
|
13479
|
-
TransactionExecutionStatus2["SUCCEEDED"] = "SUCCEEDED";
|
|
13480
|
-
return TransactionExecutionStatus2;
|
|
13481
|
-
})(TransactionExecutionStatus || {});
|
|
13482
|
-
var BlockStatus = /* @__PURE__ */ ((BlockStatus2) => {
|
|
13483
|
-
BlockStatus2["PENDING"] = "PENDING";
|
|
13484
|
-
BlockStatus2["ACCEPTED_ON_L1"] = "ACCEPTED_ON_L1";
|
|
13485
|
-
BlockStatus2["ACCEPTED_ON_L2"] = "ACCEPTED_ON_L2";
|
|
13486
|
-
BlockStatus2["REJECTED"] = "REJECTED";
|
|
13487
|
-
return BlockStatus2;
|
|
13488
|
-
})(BlockStatus || {});
|
|
13489
|
-
var BlockTag = /* @__PURE__ */ ((BlockTag2) => {
|
|
13490
|
-
BlockTag2["pending"] = "pending";
|
|
13491
|
-
BlockTag2["latest"] = "latest";
|
|
13492
|
-
return BlockTag2;
|
|
13493
|
-
})(BlockTag || {});
|
|
13494
|
-
|
|
13495
|
-
// src/utils/assert.ts
|
|
13496
|
-
function assert(condition, message) {
|
|
13497
|
-
if (!condition) {
|
|
13498
|
-
throw new Error(message || "Assertion failure");
|
|
13499
|
-
}
|
|
13500
|
-
}
|
|
13501
|
-
|
|
13502
|
-
// src/utils/num.ts
|
|
13503
|
-
var num_exports = {};
|
|
13504
|
-
__export(num_exports, {
|
|
13505
|
-
addPercent: () => addPercent,
|
|
13506
|
-
assertInRange: () => assertInRange,
|
|
13507
|
-
bigNumberishArrayToDecimalStringArray: () => bigNumberishArrayToDecimalStringArray,
|
|
13508
|
-
bigNumberishArrayToHexadecimalStringArray: () => bigNumberishArrayToHexadecimalStringArray,
|
|
13509
|
-
cleanHex: () => cleanHex,
|
|
13510
|
-
getDecimalString: () => getDecimalString,
|
|
13511
|
-
getHexString: () => getHexString,
|
|
13512
|
-
getHexStringArray: () => getHexStringArray,
|
|
13513
|
-
hexToBytes: () => hexToBytes2,
|
|
13514
|
-
hexToDecimalString: () => hexToDecimalString,
|
|
13515
|
-
isBigInt: () => isBigInt,
|
|
13516
|
-
isBoolean: () => isBoolean,
|
|
13517
|
-
isHex: () => isHex,
|
|
13518
|
-
isNumber: () => isNumber,
|
|
13519
|
-
isStringWholeNumber: () => isStringWholeNumber,
|
|
13520
|
-
toBigInt: () => toBigInt,
|
|
13521
|
-
toCairoBool: () => toCairoBool,
|
|
13522
|
-
toHex: () => toHex,
|
|
13523
|
-
toHexString: () => toHexString,
|
|
13524
|
-
toStorageKey: () => toStorageKey
|
|
13525
|
-
});
|
|
13526
|
-
|
|
13527
13344
|
// node_modules/@noble/curves/esm/abstract/utils.js
|
|
13528
13345
|
var utils_exports = {};
|
|
13529
13346
|
__export(utils_exports, {
|
|
@@ -13707,7 +13524,7 @@ var starknet = (() => {
|
|
|
13707
13524
|
k = h(u8fr([1]), seed);
|
|
13708
13525
|
v = h();
|
|
13709
13526
|
};
|
|
13710
|
-
const
|
|
13527
|
+
const gen3 = () => {
|
|
13711
13528
|
if (i++ >= 1e3)
|
|
13712
13529
|
throw new Error("drbg: tried 1000 values");
|
|
13713
13530
|
let len = 0;
|
|
@@ -13724,7 +13541,7 @@ var starknet = (() => {
|
|
|
13724
13541
|
reset();
|
|
13725
13542
|
reseed(seed);
|
|
13726
13543
|
let res = void 0;
|
|
13727
|
-
while (!(res = pred(
|
|
13544
|
+
while (!(res = pred(gen3())))
|
|
13728
13545
|
reseed();
|
|
13729
13546
|
reset();
|
|
13730
13547
|
return res;
|
|
@@ -13761,7 +13578,484 @@ var starknet = (() => {
|
|
|
13761
13578
|
return object;
|
|
13762
13579
|
}
|
|
13763
13580
|
|
|
13581
|
+
// node_modules/@noble/hashes/esm/_assert.js
|
|
13582
|
+
function number(n) {
|
|
13583
|
+
if (!Number.isSafeInteger(n) || n < 0)
|
|
13584
|
+
throw new Error(`positive integer expected, not ${n}`);
|
|
13585
|
+
}
|
|
13586
|
+
function isBytes3(a) {
|
|
13587
|
+
return a instanceof Uint8Array || a != null && typeof a === "object" && a.constructor.name === "Uint8Array";
|
|
13588
|
+
}
|
|
13589
|
+
function bytes(b, ...lengths) {
|
|
13590
|
+
if (!isBytes3(b))
|
|
13591
|
+
throw new Error("Uint8Array expected");
|
|
13592
|
+
if (lengths.length > 0 && !lengths.includes(b.length))
|
|
13593
|
+
throw new Error(`Uint8Array expected of length ${lengths}, not of length=${b.length}`);
|
|
13594
|
+
}
|
|
13595
|
+
function hash(h) {
|
|
13596
|
+
if (typeof h !== "function" || typeof h.create !== "function")
|
|
13597
|
+
throw new Error("Hash should be wrapped by utils.wrapConstructor");
|
|
13598
|
+
number(h.outputLen);
|
|
13599
|
+
number(h.blockLen);
|
|
13600
|
+
}
|
|
13601
|
+
function exists(instance, checkFinished = true) {
|
|
13602
|
+
if (instance.destroyed)
|
|
13603
|
+
throw new Error("Hash instance has been destroyed");
|
|
13604
|
+
if (checkFinished && instance.finished)
|
|
13605
|
+
throw new Error("Hash#digest() has already been called");
|
|
13606
|
+
}
|
|
13607
|
+
function output(out, instance) {
|
|
13608
|
+
bytes(out);
|
|
13609
|
+
const min = instance.outputLen;
|
|
13610
|
+
if (out.length < min) {
|
|
13611
|
+
throw new Error(`digestInto() expects output buffer of length at least ${min}`);
|
|
13612
|
+
}
|
|
13613
|
+
}
|
|
13614
|
+
|
|
13615
|
+
// node_modules/@noble/hashes/esm/_u64.js
|
|
13616
|
+
var U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
13617
|
+
var _32n = /* @__PURE__ */ BigInt(32);
|
|
13618
|
+
function fromBig(n, le = false) {
|
|
13619
|
+
if (le)
|
|
13620
|
+
return { h: Number(n & U32_MASK64), l: Number(n >> _32n & U32_MASK64) };
|
|
13621
|
+
return { h: Number(n >> _32n & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
|
|
13622
|
+
}
|
|
13623
|
+
function split(lst, le = false) {
|
|
13624
|
+
let Ah = new Uint32Array(lst.length);
|
|
13625
|
+
let Al = new Uint32Array(lst.length);
|
|
13626
|
+
for (let i = 0; i < lst.length; i++) {
|
|
13627
|
+
const { h, l } = fromBig(lst[i], le);
|
|
13628
|
+
[Ah[i], Al[i]] = [h, l];
|
|
13629
|
+
}
|
|
13630
|
+
return [Ah, Al];
|
|
13631
|
+
}
|
|
13632
|
+
var rotlSH = (h, l, s) => h << s | l >>> 32 - s;
|
|
13633
|
+
var rotlSL = (h, l, s) => l << s | h >>> 32 - s;
|
|
13634
|
+
var rotlBH = (h, l, s) => l << s - 32 | h >>> 64 - s;
|
|
13635
|
+
var rotlBL = (h, l, s) => h << s - 32 | l >>> 64 - s;
|
|
13636
|
+
|
|
13637
|
+
// node_modules/@noble/hashes/esm/crypto.js
|
|
13638
|
+
var crypto = typeof globalThis === "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
|
|
13639
|
+
|
|
13640
|
+
// node_modules/@noble/hashes/esm/utils.js
|
|
13641
|
+
var u32 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
|
|
13642
|
+
var createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
13643
|
+
var rotr = (word, shift) => word << 32 - shift | word >>> shift;
|
|
13644
|
+
var isLE = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
13645
|
+
var byteSwap = (word) => word << 24 & 4278190080 | word << 8 & 16711680 | word >>> 8 & 65280 | word >>> 24 & 255;
|
|
13646
|
+
function byteSwap32(arr) {
|
|
13647
|
+
for (let i = 0; i < arr.length; i++) {
|
|
13648
|
+
arr[i] = byteSwap(arr[i]);
|
|
13649
|
+
}
|
|
13650
|
+
}
|
|
13651
|
+
function utf8ToBytes2(str) {
|
|
13652
|
+
if (typeof str !== "string")
|
|
13653
|
+
throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
|
|
13654
|
+
return new Uint8Array(new TextEncoder().encode(str));
|
|
13655
|
+
}
|
|
13656
|
+
function toBytes(data) {
|
|
13657
|
+
if (typeof data === "string")
|
|
13658
|
+
data = utf8ToBytes2(data);
|
|
13659
|
+
bytes(data);
|
|
13660
|
+
return data;
|
|
13661
|
+
}
|
|
13662
|
+
function concatBytes2(...arrays) {
|
|
13663
|
+
let sum = 0;
|
|
13664
|
+
for (let i = 0; i < arrays.length; i++) {
|
|
13665
|
+
const a = arrays[i];
|
|
13666
|
+
bytes(a);
|
|
13667
|
+
sum += a.length;
|
|
13668
|
+
}
|
|
13669
|
+
const res = new Uint8Array(sum);
|
|
13670
|
+
for (let i = 0, pad = 0; i < arrays.length; i++) {
|
|
13671
|
+
const a = arrays[i];
|
|
13672
|
+
res.set(a, pad);
|
|
13673
|
+
pad += a.length;
|
|
13674
|
+
}
|
|
13675
|
+
return res;
|
|
13676
|
+
}
|
|
13677
|
+
var Hash = class {
|
|
13678
|
+
// Safe version that clones internal state
|
|
13679
|
+
clone() {
|
|
13680
|
+
return this._cloneInto();
|
|
13681
|
+
}
|
|
13682
|
+
};
|
|
13683
|
+
var toStr = {}.toString;
|
|
13684
|
+
function wrapConstructor(hashCons) {
|
|
13685
|
+
const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
|
|
13686
|
+
const tmp = hashCons();
|
|
13687
|
+
hashC.outputLen = tmp.outputLen;
|
|
13688
|
+
hashC.blockLen = tmp.blockLen;
|
|
13689
|
+
hashC.create = () => hashCons();
|
|
13690
|
+
return hashC;
|
|
13691
|
+
}
|
|
13692
|
+
function wrapXOFConstructorWithOpts(hashCons) {
|
|
13693
|
+
const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();
|
|
13694
|
+
const tmp = hashCons({});
|
|
13695
|
+
hashC.outputLen = tmp.outputLen;
|
|
13696
|
+
hashC.blockLen = tmp.blockLen;
|
|
13697
|
+
hashC.create = (opts) => hashCons(opts);
|
|
13698
|
+
return hashC;
|
|
13699
|
+
}
|
|
13700
|
+
function randomBytes(bytesLength = 32) {
|
|
13701
|
+
if (crypto && typeof crypto.getRandomValues === "function") {
|
|
13702
|
+
return crypto.getRandomValues(new Uint8Array(bytesLength));
|
|
13703
|
+
}
|
|
13704
|
+
throw new Error("crypto.getRandomValues must be defined");
|
|
13705
|
+
}
|
|
13706
|
+
|
|
13707
|
+
// node_modules/@noble/hashes/esm/sha3.js
|
|
13708
|
+
var SHA3_PI = [];
|
|
13709
|
+
var SHA3_ROTL = [];
|
|
13710
|
+
var _SHA3_IOTA = [];
|
|
13711
|
+
var _0n2 = /* @__PURE__ */ BigInt(0);
|
|
13712
|
+
var _1n2 = /* @__PURE__ */ BigInt(1);
|
|
13713
|
+
var _2n2 = /* @__PURE__ */ BigInt(2);
|
|
13714
|
+
var _7n = /* @__PURE__ */ BigInt(7);
|
|
13715
|
+
var _256n = /* @__PURE__ */ BigInt(256);
|
|
13716
|
+
var _0x71n = /* @__PURE__ */ BigInt(113);
|
|
13717
|
+
for (let round = 0, R = _1n2, x = 1, y = 0; round < 24; round++) {
|
|
13718
|
+
[x, y] = [y, (2 * x + 3 * y) % 5];
|
|
13719
|
+
SHA3_PI.push(2 * (5 * y + x));
|
|
13720
|
+
SHA3_ROTL.push((round + 1) * (round + 2) / 2 % 64);
|
|
13721
|
+
let t = _0n2;
|
|
13722
|
+
for (let j = 0; j < 7; j++) {
|
|
13723
|
+
R = (R << _1n2 ^ (R >> _7n) * _0x71n) % _256n;
|
|
13724
|
+
if (R & _2n2)
|
|
13725
|
+
t ^= _1n2 << (_1n2 << /* @__PURE__ */ BigInt(j)) - _1n2;
|
|
13726
|
+
}
|
|
13727
|
+
_SHA3_IOTA.push(t);
|
|
13728
|
+
}
|
|
13729
|
+
var [SHA3_IOTA_H, SHA3_IOTA_L] = /* @__PURE__ */ split(_SHA3_IOTA, true);
|
|
13730
|
+
var rotlH = (h, l, s) => s > 32 ? rotlBH(h, l, s) : rotlSH(h, l, s);
|
|
13731
|
+
var rotlL = (h, l, s) => s > 32 ? rotlBL(h, l, s) : rotlSL(h, l, s);
|
|
13732
|
+
function keccakP(s, rounds = 24) {
|
|
13733
|
+
const B = new Uint32Array(5 * 2);
|
|
13734
|
+
for (let round = 24 - rounds; round < 24; round++) {
|
|
13735
|
+
for (let x = 0; x < 10; x++)
|
|
13736
|
+
B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40];
|
|
13737
|
+
for (let x = 0; x < 10; x += 2) {
|
|
13738
|
+
const idx1 = (x + 8) % 10;
|
|
13739
|
+
const idx0 = (x + 2) % 10;
|
|
13740
|
+
const B0 = B[idx0];
|
|
13741
|
+
const B1 = B[idx0 + 1];
|
|
13742
|
+
const Th = rotlH(B0, B1, 1) ^ B[idx1];
|
|
13743
|
+
const Tl = rotlL(B0, B1, 1) ^ B[idx1 + 1];
|
|
13744
|
+
for (let y = 0; y < 50; y += 10) {
|
|
13745
|
+
s[x + y] ^= Th;
|
|
13746
|
+
s[x + y + 1] ^= Tl;
|
|
13747
|
+
}
|
|
13748
|
+
}
|
|
13749
|
+
let curH = s[2];
|
|
13750
|
+
let curL = s[3];
|
|
13751
|
+
for (let t = 0; t < 24; t++) {
|
|
13752
|
+
const shift = SHA3_ROTL[t];
|
|
13753
|
+
const Th = rotlH(curH, curL, shift);
|
|
13754
|
+
const Tl = rotlL(curH, curL, shift);
|
|
13755
|
+
const PI = SHA3_PI[t];
|
|
13756
|
+
curH = s[PI];
|
|
13757
|
+
curL = s[PI + 1];
|
|
13758
|
+
s[PI] = Th;
|
|
13759
|
+
s[PI + 1] = Tl;
|
|
13760
|
+
}
|
|
13761
|
+
for (let y = 0; y < 50; y += 10) {
|
|
13762
|
+
for (let x = 0; x < 10; x++)
|
|
13763
|
+
B[x] = s[y + x];
|
|
13764
|
+
for (let x = 0; x < 10; x++)
|
|
13765
|
+
s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10];
|
|
13766
|
+
}
|
|
13767
|
+
s[0] ^= SHA3_IOTA_H[round];
|
|
13768
|
+
s[1] ^= SHA3_IOTA_L[round];
|
|
13769
|
+
}
|
|
13770
|
+
B.fill(0);
|
|
13771
|
+
}
|
|
13772
|
+
var Keccak = class _Keccak extends Hash {
|
|
13773
|
+
// NOTE: we accept arguments in bytes instead of bits here.
|
|
13774
|
+
constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) {
|
|
13775
|
+
super();
|
|
13776
|
+
this.blockLen = blockLen;
|
|
13777
|
+
this.suffix = suffix;
|
|
13778
|
+
this.outputLen = outputLen;
|
|
13779
|
+
this.enableXOF = enableXOF;
|
|
13780
|
+
this.rounds = rounds;
|
|
13781
|
+
this.pos = 0;
|
|
13782
|
+
this.posOut = 0;
|
|
13783
|
+
this.finished = false;
|
|
13784
|
+
this.destroyed = false;
|
|
13785
|
+
number(outputLen);
|
|
13786
|
+
if (0 >= this.blockLen || this.blockLen >= 200)
|
|
13787
|
+
throw new Error("Sha3 supports only keccak-f1600 function");
|
|
13788
|
+
this.state = new Uint8Array(200);
|
|
13789
|
+
this.state32 = u32(this.state);
|
|
13790
|
+
}
|
|
13791
|
+
keccak() {
|
|
13792
|
+
if (!isLE)
|
|
13793
|
+
byteSwap32(this.state32);
|
|
13794
|
+
keccakP(this.state32, this.rounds);
|
|
13795
|
+
if (!isLE)
|
|
13796
|
+
byteSwap32(this.state32);
|
|
13797
|
+
this.posOut = 0;
|
|
13798
|
+
this.pos = 0;
|
|
13799
|
+
}
|
|
13800
|
+
update(data) {
|
|
13801
|
+
exists(this);
|
|
13802
|
+
const { blockLen, state } = this;
|
|
13803
|
+
data = toBytes(data);
|
|
13804
|
+
const len = data.length;
|
|
13805
|
+
for (let pos = 0; pos < len; ) {
|
|
13806
|
+
const take = Math.min(blockLen - this.pos, len - pos);
|
|
13807
|
+
for (let i = 0; i < take; i++)
|
|
13808
|
+
state[this.pos++] ^= data[pos++];
|
|
13809
|
+
if (this.pos === blockLen)
|
|
13810
|
+
this.keccak();
|
|
13811
|
+
}
|
|
13812
|
+
return this;
|
|
13813
|
+
}
|
|
13814
|
+
finish() {
|
|
13815
|
+
if (this.finished)
|
|
13816
|
+
return;
|
|
13817
|
+
this.finished = true;
|
|
13818
|
+
const { state, suffix, pos, blockLen } = this;
|
|
13819
|
+
state[pos] ^= suffix;
|
|
13820
|
+
if ((suffix & 128) !== 0 && pos === blockLen - 1)
|
|
13821
|
+
this.keccak();
|
|
13822
|
+
state[blockLen - 1] ^= 128;
|
|
13823
|
+
this.keccak();
|
|
13824
|
+
}
|
|
13825
|
+
writeInto(out) {
|
|
13826
|
+
exists(this, false);
|
|
13827
|
+
bytes(out);
|
|
13828
|
+
this.finish();
|
|
13829
|
+
const bufferOut = this.state;
|
|
13830
|
+
const { blockLen } = this;
|
|
13831
|
+
for (let pos = 0, len = out.length; pos < len; ) {
|
|
13832
|
+
if (this.posOut >= blockLen)
|
|
13833
|
+
this.keccak();
|
|
13834
|
+
const take = Math.min(blockLen - this.posOut, len - pos);
|
|
13835
|
+
out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos);
|
|
13836
|
+
this.posOut += take;
|
|
13837
|
+
pos += take;
|
|
13838
|
+
}
|
|
13839
|
+
return out;
|
|
13840
|
+
}
|
|
13841
|
+
xofInto(out) {
|
|
13842
|
+
if (!this.enableXOF)
|
|
13843
|
+
throw new Error("XOF is not possible for this instance");
|
|
13844
|
+
return this.writeInto(out);
|
|
13845
|
+
}
|
|
13846
|
+
xof(bytes3) {
|
|
13847
|
+
number(bytes3);
|
|
13848
|
+
return this.xofInto(new Uint8Array(bytes3));
|
|
13849
|
+
}
|
|
13850
|
+
digestInto(out) {
|
|
13851
|
+
output(out, this);
|
|
13852
|
+
if (this.finished)
|
|
13853
|
+
throw new Error("digest() was already called");
|
|
13854
|
+
this.writeInto(out);
|
|
13855
|
+
this.destroy();
|
|
13856
|
+
return out;
|
|
13857
|
+
}
|
|
13858
|
+
digest() {
|
|
13859
|
+
return this.digestInto(new Uint8Array(this.outputLen));
|
|
13860
|
+
}
|
|
13861
|
+
destroy() {
|
|
13862
|
+
this.destroyed = true;
|
|
13863
|
+
this.state.fill(0);
|
|
13864
|
+
}
|
|
13865
|
+
_cloneInto(to) {
|
|
13866
|
+
const { blockLen, suffix, outputLen, rounds, enableXOF } = this;
|
|
13867
|
+
to || (to = new _Keccak(blockLen, suffix, outputLen, enableXOF, rounds));
|
|
13868
|
+
to.state32.set(this.state32);
|
|
13869
|
+
to.pos = this.pos;
|
|
13870
|
+
to.posOut = this.posOut;
|
|
13871
|
+
to.finished = this.finished;
|
|
13872
|
+
to.rounds = rounds;
|
|
13873
|
+
to.suffix = suffix;
|
|
13874
|
+
to.outputLen = outputLen;
|
|
13875
|
+
to.enableXOF = enableXOF;
|
|
13876
|
+
to.destroyed = this.destroyed;
|
|
13877
|
+
return to;
|
|
13878
|
+
}
|
|
13879
|
+
};
|
|
13880
|
+
var gen = (suffix, blockLen, outputLen) => wrapConstructor(() => new Keccak(blockLen, suffix, outputLen));
|
|
13881
|
+
var sha3_224 = /* @__PURE__ */ gen(6, 144, 224 / 8);
|
|
13882
|
+
var sha3_256 = /* @__PURE__ */ gen(6, 136, 256 / 8);
|
|
13883
|
+
var sha3_384 = /* @__PURE__ */ gen(6, 104, 384 / 8);
|
|
13884
|
+
var sha3_512 = /* @__PURE__ */ gen(6, 72, 512 / 8);
|
|
13885
|
+
var keccak_224 = /* @__PURE__ */ gen(1, 144, 224 / 8);
|
|
13886
|
+
var keccak_256 = /* @__PURE__ */ gen(1, 136, 256 / 8);
|
|
13887
|
+
var keccak_384 = /* @__PURE__ */ gen(1, 104, 384 / 8);
|
|
13888
|
+
var keccak_512 = /* @__PURE__ */ gen(1, 72, 512 / 8);
|
|
13889
|
+
var genShake = (suffix, blockLen, outputLen) => wrapXOFConstructorWithOpts((opts = {}) => new Keccak(blockLen, suffix, opts.dkLen === void 0 ? outputLen : opts.dkLen, true));
|
|
13890
|
+
var shake128 = /* @__PURE__ */ genShake(31, 168, 128 / 8);
|
|
13891
|
+
var shake256 = /* @__PURE__ */ genShake(31, 136, 256 / 8);
|
|
13892
|
+
|
|
13893
|
+
// src/channel/rpc_0_6.ts
|
|
13894
|
+
var rpc_0_6_exports = {};
|
|
13895
|
+
__export(rpc_0_6_exports, {
|
|
13896
|
+
RpcChannel: () => RpcChannel
|
|
13897
|
+
});
|
|
13898
|
+
|
|
13899
|
+
// src/provider/errors.ts
|
|
13900
|
+
function fixStack(target, fn = target.constructor) {
|
|
13901
|
+
const { captureStackTrace } = Error;
|
|
13902
|
+
captureStackTrace && captureStackTrace(target, fn);
|
|
13903
|
+
}
|
|
13904
|
+
function fixProto(target, prototype) {
|
|
13905
|
+
const { setPrototypeOf } = Object;
|
|
13906
|
+
setPrototypeOf ? setPrototypeOf(target, prototype) : target.__proto__ = prototype;
|
|
13907
|
+
}
|
|
13908
|
+
var CustomError = class extends Error {
|
|
13909
|
+
name;
|
|
13910
|
+
constructor(message) {
|
|
13911
|
+
super(message);
|
|
13912
|
+
Object.defineProperty(this, "name", {
|
|
13913
|
+
value: new.target.name,
|
|
13914
|
+
enumerable: false,
|
|
13915
|
+
configurable: true
|
|
13916
|
+
});
|
|
13917
|
+
fixProto(this, new.target.prototype);
|
|
13918
|
+
fixStack(this);
|
|
13919
|
+
}
|
|
13920
|
+
};
|
|
13921
|
+
var LibraryError = class extends CustomError {
|
|
13922
|
+
};
|
|
13923
|
+
var GatewayError = class extends LibraryError {
|
|
13924
|
+
constructor(message, errorCode) {
|
|
13925
|
+
super(message);
|
|
13926
|
+
this.errorCode = errorCode;
|
|
13927
|
+
}
|
|
13928
|
+
};
|
|
13929
|
+
var HttpError = class extends LibraryError {
|
|
13930
|
+
constructor(message, errorCode) {
|
|
13931
|
+
super(message);
|
|
13932
|
+
this.errorCode = errorCode;
|
|
13933
|
+
}
|
|
13934
|
+
};
|
|
13935
|
+
|
|
13936
|
+
// src/types/index.ts
|
|
13937
|
+
var types_exports = {};
|
|
13938
|
+
__export(types_exports, {
|
|
13939
|
+
BlockStatus: () => BlockStatus,
|
|
13940
|
+
BlockTag: () => BlockTag,
|
|
13941
|
+
EntryPointType: () => EntryPointType,
|
|
13942
|
+
Literal: () => Literal,
|
|
13943
|
+
RPC: () => api_exports2,
|
|
13944
|
+
TransactionExecutionStatus: () => TransactionExecutionStatus,
|
|
13945
|
+
TransactionFinalityStatus: () => TransactionFinalityStatus,
|
|
13946
|
+
TransactionStatus: () => TransactionStatus,
|
|
13947
|
+
TransactionType: () => TransactionType,
|
|
13948
|
+
TypedDataRevision: () => TypedDataRevision,
|
|
13949
|
+
Uint: () => Uint,
|
|
13950
|
+
ValidateType: () => ValidateType
|
|
13951
|
+
});
|
|
13952
|
+
|
|
13953
|
+
// src/types/calldata.ts
|
|
13954
|
+
var ValidateType = /* @__PURE__ */ ((ValidateType2) => {
|
|
13955
|
+
ValidateType2["DEPLOY"] = "DEPLOY";
|
|
13956
|
+
ValidateType2["CALL"] = "CALL";
|
|
13957
|
+
ValidateType2["INVOKE"] = "INVOKE";
|
|
13958
|
+
return ValidateType2;
|
|
13959
|
+
})(ValidateType || {});
|
|
13960
|
+
var Uint = /* @__PURE__ */ ((Uint2) => {
|
|
13961
|
+
Uint2["u8"] = "core::integer::u8";
|
|
13962
|
+
Uint2["u16"] = "core::integer::u16";
|
|
13963
|
+
Uint2["u32"] = "core::integer::u32";
|
|
13964
|
+
Uint2["u64"] = "core::integer::u64";
|
|
13965
|
+
Uint2["u128"] = "core::integer::u128";
|
|
13966
|
+
Uint2["u256"] = "core::integer::u256";
|
|
13967
|
+
Uint2["u512"] = "core::integer::u512";
|
|
13968
|
+
return Uint2;
|
|
13969
|
+
})(Uint || {});
|
|
13970
|
+
var Literal = /* @__PURE__ */ ((Literal2) => {
|
|
13971
|
+
Literal2["ClassHash"] = "core::starknet::class_hash::ClassHash";
|
|
13972
|
+
Literal2["ContractAddress"] = "core::starknet::contract_address::ContractAddress";
|
|
13973
|
+
Literal2["Secp256k1Point"] = "core::starknet::secp256k1::Secp256k1Point";
|
|
13974
|
+
return Literal2;
|
|
13975
|
+
})(Literal || {});
|
|
13976
|
+
|
|
13977
|
+
// src/types/lib/contract/index.ts
|
|
13978
|
+
var EntryPointType = /* @__PURE__ */ ((EntryPointType2) => {
|
|
13979
|
+
EntryPointType2["EXTERNAL"] = "EXTERNAL";
|
|
13980
|
+
EntryPointType2["L1_HANDLER"] = "L1_HANDLER";
|
|
13981
|
+
EntryPointType2["CONSTRUCTOR"] = "CONSTRUCTOR";
|
|
13982
|
+
return EntryPointType2;
|
|
13983
|
+
})(EntryPointType || {});
|
|
13984
|
+
|
|
13985
|
+
// src/types/lib/index.ts
|
|
13986
|
+
var TransactionType = /* @__PURE__ */ ((TransactionType2) => {
|
|
13987
|
+
TransactionType2["DECLARE"] = "DECLARE";
|
|
13988
|
+
TransactionType2["DEPLOY"] = "DEPLOY";
|
|
13989
|
+
TransactionType2["DEPLOY_ACCOUNT"] = "DEPLOY_ACCOUNT";
|
|
13990
|
+
TransactionType2["INVOKE"] = "INVOKE_FUNCTION";
|
|
13991
|
+
return TransactionType2;
|
|
13992
|
+
})(TransactionType || {});
|
|
13993
|
+
var TransactionStatus = /* @__PURE__ */ ((TransactionStatus2) => {
|
|
13994
|
+
TransactionStatus2["NOT_RECEIVED"] = "NOT_RECEIVED";
|
|
13995
|
+
TransactionStatus2["RECEIVED"] = "RECEIVED";
|
|
13996
|
+
TransactionStatus2["ACCEPTED_ON_L2"] = "ACCEPTED_ON_L2";
|
|
13997
|
+
TransactionStatus2["ACCEPTED_ON_L1"] = "ACCEPTED_ON_L1";
|
|
13998
|
+
TransactionStatus2["REJECTED"] = "REJECTED";
|
|
13999
|
+
TransactionStatus2["REVERTED"] = "REVERTED";
|
|
14000
|
+
return TransactionStatus2;
|
|
14001
|
+
})(TransactionStatus || {});
|
|
14002
|
+
var TransactionFinalityStatus = /* @__PURE__ */ ((TransactionFinalityStatus2) => {
|
|
14003
|
+
TransactionFinalityStatus2["NOT_RECEIVED"] = "NOT_RECEIVED";
|
|
14004
|
+
TransactionFinalityStatus2["RECEIVED"] = "RECEIVED";
|
|
14005
|
+
TransactionFinalityStatus2["ACCEPTED_ON_L2"] = "ACCEPTED_ON_L2";
|
|
14006
|
+
TransactionFinalityStatus2["ACCEPTED_ON_L1"] = "ACCEPTED_ON_L1";
|
|
14007
|
+
return TransactionFinalityStatus2;
|
|
14008
|
+
})(TransactionFinalityStatus || {});
|
|
14009
|
+
var TransactionExecutionStatus = /* @__PURE__ */ ((TransactionExecutionStatus2) => {
|
|
14010
|
+
TransactionExecutionStatus2["REJECTED"] = "REJECTED";
|
|
14011
|
+
TransactionExecutionStatus2["REVERTED"] = "REVERTED";
|
|
14012
|
+
TransactionExecutionStatus2["SUCCEEDED"] = "SUCCEEDED";
|
|
14013
|
+
return TransactionExecutionStatus2;
|
|
14014
|
+
})(TransactionExecutionStatus || {});
|
|
14015
|
+
var BlockStatus = /* @__PURE__ */ ((BlockStatus2) => {
|
|
14016
|
+
BlockStatus2["PENDING"] = "PENDING";
|
|
14017
|
+
BlockStatus2["ACCEPTED_ON_L1"] = "ACCEPTED_ON_L1";
|
|
14018
|
+
BlockStatus2["ACCEPTED_ON_L2"] = "ACCEPTED_ON_L2";
|
|
14019
|
+
BlockStatus2["REJECTED"] = "REJECTED";
|
|
14020
|
+
return BlockStatus2;
|
|
14021
|
+
})(BlockStatus || {});
|
|
14022
|
+
var BlockTag = /* @__PURE__ */ ((BlockTag2) => {
|
|
14023
|
+
BlockTag2["pending"] = "pending";
|
|
14024
|
+
BlockTag2["latest"] = "latest";
|
|
14025
|
+
return BlockTag2;
|
|
14026
|
+
})(BlockTag || {});
|
|
14027
|
+
|
|
14028
|
+
// src/utils/assert.ts
|
|
14029
|
+
function assert(condition, message) {
|
|
14030
|
+
if (!condition) {
|
|
14031
|
+
throw new Error(message || "Assertion failure");
|
|
14032
|
+
}
|
|
14033
|
+
}
|
|
14034
|
+
|
|
13764
14035
|
// src/utils/num.ts
|
|
14036
|
+
var num_exports = {};
|
|
14037
|
+
__export(num_exports, {
|
|
14038
|
+
addPercent: () => addPercent,
|
|
14039
|
+
assertInRange: () => assertInRange,
|
|
14040
|
+
bigNumberishArrayToDecimalStringArray: () => bigNumberishArrayToDecimalStringArray,
|
|
14041
|
+
bigNumberishArrayToHexadecimalStringArray: () => bigNumberishArrayToHexadecimalStringArray,
|
|
14042
|
+
cleanHex: () => cleanHex,
|
|
14043
|
+
getDecimalString: () => getDecimalString,
|
|
14044
|
+
getHexString: () => getHexString,
|
|
14045
|
+
getHexStringArray: () => getHexStringArray,
|
|
14046
|
+
hexToBytes: () => hexToBytes2,
|
|
14047
|
+
hexToDecimalString: () => hexToDecimalString,
|
|
14048
|
+
isBigInt: () => isBigInt,
|
|
14049
|
+
isBoolean: () => isBoolean,
|
|
14050
|
+
isHex: () => isHex,
|
|
14051
|
+
isNumber: () => isNumber,
|
|
14052
|
+
isStringWholeNumber: () => isStringWholeNumber,
|
|
14053
|
+
toBigInt: () => toBigInt,
|
|
14054
|
+
toCairoBool: () => toCairoBool,
|
|
14055
|
+
toHex: () => toHex,
|
|
14056
|
+
toHexString: () => toHexString,
|
|
14057
|
+
toStorageKey: () => toStorageKey
|
|
14058
|
+
});
|
|
13765
14059
|
function isHex(hex) {
|
|
13766
14060
|
return /^0x[0-9a-f]*$/i.test(hex);
|
|
13767
14061
|
}
|
|
@@ -13882,92 +14176,92 @@ var starknet = (() => {
|
|
|
13882
14176
|
verify: () => verify
|
|
13883
14177
|
});
|
|
13884
14178
|
|
|
13885
|
-
// node_modules/@noble/hashes/esm/_assert.js
|
|
13886
|
-
function
|
|
14179
|
+
// node_modules/@scure/starknet/node_modules/@noble/hashes/esm/_assert.js
|
|
14180
|
+
function number2(n) {
|
|
13887
14181
|
if (!Number.isSafeInteger(n) || n < 0)
|
|
13888
14182
|
throw new Error(`Wrong positive integer: ${n}`);
|
|
13889
14183
|
}
|
|
13890
|
-
function
|
|
14184
|
+
function isBytes4(a) {
|
|
13891
14185
|
return a instanceof Uint8Array || a != null && typeof a === "object" && a.constructor.name === "Uint8Array";
|
|
13892
14186
|
}
|
|
13893
|
-
function
|
|
13894
|
-
if (!
|
|
14187
|
+
function bytes2(b, ...lengths) {
|
|
14188
|
+
if (!isBytes4(b))
|
|
13895
14189
|
throw new Error("Expected Uint8Array");
|
|
13896
14190
|
if (lengths.length > 0 && !lengths.includes(b.length))
|
|
13897
14191
|
throw new Error(`Expected Uint8Array of length ${lengths}, not of length=${b.length}`);
|
|
13898
14192
|
}
|
|
13899
|
-
function
|
|
14193
|
+
function hash2(hash3) {
|
|
13900
14194
|
if (typeof hash3 !== "function" || typeof hash3.create !== "function")
|
|
13901
14195
|
throw new Error("Hash should be wrapped by utils.wrapConstructor");
|
|
13902
|
-
|
|
13903
|
-
|
|
14196
|
+
number2(hash3.outputLen);
|
|
14197
|
+
number2(hash3.blockLen);
|
|
13904
14198
|
}
|
|
13905
|
-
function
|
|
14199
|
+
function exists2(instance, checkFinished = true) {
|
|
13906
14200
|
if (instance.destroyed)
|
|
13907
14201
|
throw new Error("Hash instance has been destroyed");
|
|
13908
14202
|
if (checkFinished && instance.finished)
|
|
13909
14203
|
throw new Error("Hash#digest() has already been called");
|
|
13910
14204
|
}
|
|
13911
|
-
function
|
|
13912
|
-
|
|
14205
|
+
function output2(out, instance) {
|
|
14206
|
+
bytes2(out);
|
|
13913
14207
|
const min = instance.outputLen;
|
|
13914
14208
|
if (out.length < min) {
|
|
13915
14209
|
throw new Error(`digestInto() expects output buffer of length at least ${min}`);
|
|
13916
14210
|
}
|
|
13917
14211
|
}
|
|
13918
14212
|
|
|
13919
|
-
// node_modules/@noble/hashes/esm/_u64.js
|
|
13920
|
-
var
|
|
13921
|
-
var
|
|
13922
|
-
function
|
|
14213
|
+
// node_modules/@scure/starknet/node_modules/@noble/hashes/esm/_u64.js
|
|
14214
|
+
var U32_MASK642 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
14215
|
+
var _32n2 = /* @__PURE__ */ BigInt(32);
|
|
14216
|
+
function fromBig2(n, le = false) {
|
|
13923
14217
|
if (le)
|
|
13924
|
-
return { h: Number(n &
|
|
13925
|
-
return { h: Number(n >>
|
|
14218
|
+
return { h: Number(n & U32_MASK642), l: Number(n >> _32n2 & U32_MASK642) };
|
|
14219
|
+
return { h: Number(n >> _32n2 & U32_MASK642) | 0, l: Number(n & U32_MASK642) | 0 };
|
|
13926
14220
|
}
|
|
13927
|
-
function
|
|
14221
|
+
function split2(lst, le = false) {
|
|
13928
14222
|
let Ah = new Uint32Array(lst.length);
|
|
13929
14223
|
let Al = new Uint32Array(lst.length);
|
|
13930
14224
|
for (let i = 0; i < lst.length; i++) {
|
|
13931
|
-
const { h, l } =
|
|
14225
|
+
const { h, l } = fromBig2(lst[i], le);
|
|
13932
14226
|
[Ah[i], Al[i]] = [h, l];
|
|
13933
14227
|
}
|
|
13934
14228
|
return [Ah, Al];
|
|
13935
14229
|
}
|
|
13936
|
-
var
|
|
13937
|
-
var
|
|
13938
|
-
var
|
|
13939
|
-
var
|
|
14230
|
+
var rotlSH2 = (h, l, s) => h << s | l >>> 32 - s;
|
|
14231
|
+
var rotlSL2 = (h, l, s) => l << s | h >>> 32 - s;
|
|
14232
|
+
var rotlBH2 = (h, l, s) => l << s - 32 | h >>> 64 - s;
|
|
14233
|
+
var rotlBL2 = (h, l, s) => h << s - 32 | l >>> 64 - s;
|
|
13940
14234
|
|
|
13941
|
-
// node_modules/@noble/hashes/esm/crypto.js
|
|
13942
|
-
var
|
|
14235
|
+
// node_modules/@scure/starknet/node_modules/@noble/hashes/esm/crypto.js
|
|
14236
|
+
var crypto2 = typeof globalThis === "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
|
|
13943
14237
|
|
|
13944
|
-
// node_modules/@noble/hashes/esm/utils.js
|
|
13945
|
-
var
|
|
13946
|
-
function
|
|
14238
|
+
// node_modules/@scure/starknet/node_modules/@noble/hashes/esm/utils.js
|
|
14239
|
+
var u322 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
|
|
14240
|
+
function isBytes5(a) {
|
|
13947
14241
|
return a instanceof Uint8Array || a != null && typeof a === "object" && a.constructor.name === "Uint8Array";
|
|
13948
14242
|
}
|
|
13949
|
-
var
|
|
13950
|
-
var
|
|
13951
|
-
var
|
|
13952
|
-
if (!
|
|
14243
|
+
var createView2 = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
14244
|
+
var rotr2 = (word, shift) => word << 32 - shift | word >>> shift;
|
|
14245
|
+
var isLE2 = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
14246
|
+
if (!isLE2)
|
|
13953
14247
|
throw new Error("Non little-endian hardware is not supported");
|
|
13954
|
-
function
|
|
14248
|
+
function utf8ToBytes3(str) {
|
|
13955
14249
|
if (typeof str !== "string")
|
|
13956
14250
|
throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
|
|
13957
14251
|
return new Uint8Array(new TextEncoder().encode(str));
|
|
13958
14252
|
}
|
|
13959
|
-
function
|
|
14253
|
+
function toBytes2(data) {
|
|
13960
14254
|
if (typeof data === "string")
|
|
13961
|
-
data =
|
|
13962
|
-
if (!
|
|
14255
|
+
data = utf8ToBytes3(data);
|
|
14256
|
+
if (!isBytes5(data))
|
|
13963
14257
|
throw new Error(`expected Uint8Array, got ${typeof data}`);
|
|
13964
14258
|
return data;
|
|
13965
14259
|
}
|
|
13966
|
-
function
|
|
14260
|
+
function concatBytes3(...arrays) {
|
|
13967
14261
|
let sum = 0;
|
|
13968
14262
|
for (let i = 0; i < arrays.length; i++) {
|
|
13969
14263
|
const a = arrays[i];
|
|
13970
|
-
if (!
|
|
14264
|
+
if (!isBytes5(a))
|
|
13971
14265
|
throw new Error("Uint8Array expected");
|
|
13972
14266
|
sum += a.length;
|
|
13973
14267
|
}
|
|
@@ -13979,60 +14273,60 @@ var starknet = (() => {
|
|
|
13979
14273
|
}
|
|
13980
14274
|
return res;
|
|
13981
14275
|
}
|
|
13982
|
-
var
|
|
14276
|
+
var Hash2 = class {
|
|
13983
14277
|
// Safe version that clones internal state
|
|
13984
14278
|
clone() {
|
|
13985
14279
|
return this._cloneInto();
|
|
13986
14280
|
}
|
|
13987
14281
|
};
|
|
13988
|
-
var
|
|
13989
|
-
function
|
|
13990
|
-
const hashC = (msg) => hashCons().update(
|
|
14282
|
+
var toStr2 = {}.toString;
|
|
14283
|
+
function wrapConstructor2(hashCons) {
|
|
14284
|
+
const hashC = (msg) => hashCons().update(toBytes2(msg)).digest();
|
|
13991
14285
|
const tmp = hashCons();
|
|
13992
14286
|
hashC.outputLen = tmp.outputLen;
|
|
13993
14287
|
hashC.blockLen = tmp.blockLen;
|
|
13994
14288
|
hashC.create = () => hashCons();
|
|
13995
14289
|
return hashC;
|
|
13996
14290
|
}
|
|
13997
|
-
function
|
|
13998
|
-
const hashC = (msg, opts) => hashCons(opts).update(
|
|
14291
|
+
function wrapXOFConstructorWithOpts2(hashCons) {
|
|
14292
|
+
const hashC = (msg, opts) => hashCons(opts).update(toBytes2(msg)).digest();
|
|
13999
14293
|
const tmp = hashCons({});
|
|
14000
14294
|
hashC.outputLen = tmp.outputLen;
|
|
14001
14295
|
hashC.blockLen = tmp.blockLen;
|
|
14002
14296
|
hashC.create = (opts) => hashCons(opts);
|
|
14003
14297
|
return hashC;
|
|
14004
14298
|
}
|
|
14005
|
-
function
|
|
14006
|
-
if (
|
|
14007
|
-
return
|
|
14299
|
+
function randomBytes2(bytesLength = 32) {
|
|
14300
|
+
if (crypto2 && typeof crypto2.getRandomValues === "function") {
|
|
14301
|
+
return crypto2.getRandomValues(new Uint8Array(bytesLength));
|
|
14008
14302
|
}
|
|
14009
14303
|
throw new Error("crypto.getRandomValues must be defined");
|
|
14010
14304
|
}
|
|
14011
14305
|
|
|
14012
|
-
// node_modules/@noble/hashes/esm/sha3.js
|
|
14013
|
-
var [
|
|
14014
|
-
var
|
|
14015
|
-
var
|
|
14016
|
-
var
|
|
14017
|
-
var
|
|
14018
|
-
var
|
|
14019
|
-
var
|
|
14020
|
-
for (let round = 0, R =
|
|
14306
|
+
// node_modules/@scure/starknet/node_modules/@noble/hashes/esm/sha3.js
|
|
14307
|
+
var [SHA3_PI2, SHA3_ROTL2, _SHA3_IOTA2] = [[], [], []];
|
|
14308
|
+
var _0n3 = /* @__PURE__ */ BigInt(0);
|
|
14309
|
+
var _1n3 = /* @__PURE__ */ BigInt(1);
|
|
14310
|
+
var _2n3 = /* @__PURE__ */ BigInt(2);
|
|
14311
|
+
var _7n2 = /* @__PURE__ */ BigInt(7);
|
|
14312
|
+
var _256n2 = /* @__PURE__ */ BigInt(256);
|
|
14313
|
+
var _0x71n2 = /* @__PURE__ */ BigInt(113);
|
|
14314
|
+
for (let round = 0, R = _1n3, x = 1, y = 0; round < 24; round++) {
|
|
14021
14315
|
[x, y] = [y, (2 * x + 3 * y) % 5];
|
|
14022
|
-
|
|
14023
|
-
|
|
14024
|
-
let t =
|
|
14316
|
+
SHA3_PI2.push(2 * (5 * y + x));
|
|
14317
|
+
SHA3_ROTL2.push((round + 1) * (round + 2) / 2 % 64);
|
|
14318
|
+
let t = _0n3;
|
|
14025
14319
|
for (let j = 0; j < 7; j++) {
|
|
14026
|
-
R = (R <<
|
|
14027
|
-
if (R &
|
|
14028
|
-
t ^=
|
|
14320
|
+
R = (R << _1n3 ^ (R >> _7n2) * _0x71n2) % _256n2;
|
|
14321
|
+
if (R & _2n3)
|
|
14322
|
+
t ^= _1n3 << (_1n3 << /* @__PURE__ */ BigInt(j)) - _1n3;
|
|
14029
14323
|
}
|
|
14030
|
-
|
|
14324
|
+
_SHA3_IOTA2.push(t);
|
|
14031
14325
|
}
|
|
14032
|
-
var [
|
|
14033
|
-
var
|
|
14034
|
-
var
|
|
14035
|
-
function
|
|
14326
|
+
var [SHA3_IOTA_H2, SHA3_IOTA_L2] = /* @__PURE__ */ split2(_SHA3_IOTA2, true);
|
|
14327
|
+
var rotlH2 = (h, l, s) => s > 32 ? rotlBH2(h, l, s) : rotlSH2(h, l, s);
|
|
14328
|
+
var rotlL2 = (h, l, s) => s > 32 ? rotlBL2(h, l, s) : rotlSL2(h, l, s);
|
|
14329
|
+
function keccakP2(s, rounds = 24) {
|
|
14036
14330
|
const B = new Uint32Array(5 * 2);
|
|
14037
14331
|
for (let round = 24 - rounds; round < 24; round++) {
|
|
14038
14332
|
for (let x = 0; x < 10; x++)
|
|
@@ -14042,8 +14336,8 @@ var starknet = (() => {
|
|
|
14042
14336
|
const idx0 = (x + 2) % 10;
|
|
14043
14337
|
const B0 = B[idx0];
|
|
14044
14338
|
const B1 = B[idx0 + 1];
|
|
14045
|
-
const Th =
|
|
14046
|
-
const Tl =
|
|
14339
|
+
const Th = rotlH2(B0, B1, 1) ^ B[idx1];
|
|
14340
|
+
const Tl = rotlL2(B0, B1, 1) ^ B[idx1 + 1];
|
|
14047
14341
|
for (let y = 0; y < 50; y += 10) {
|
|
14048
14342
|
s[x + y] ^= Th;
|
|
14049
14343
|
s[x + y + 1] ^= Tl;
|
|
@@ -14052,10 +14346,10 @@ var starknet = (() => {
|
|
|
14052
14346
|
let curH = s[2];
|
|
14053
14347
|
let curL = s[3];
|
|
14054
14348
|
for (let t = 0; t < 24; t++) {
|
|
14055
|
-
const shift =
|
|
14056
|
-
const Th =
|
|
14057
|
-
const Tl =
|
|
14058
|
-
const PI =
|
|
14349
|
+
const shift = SHA3_ROTL2[t];
|
|
14350
|
+
const Th = rotlH2(curH, curL, shift);
|
|
14351
|
+
const Tl = rotlL2(curH, curL, shift);
|
|
14352
|
+
const PI = SHA3_PI2[t];
|
|
14059
14353
|
curH = s[PI];
|
|
14060
14354
|
curL = s[PI + 1];
|
|
14061
14355
|
s[PI] = Th;
|
|
@@ -14067,12 +14361,12 @@ var starknet = (() => {
|
|
|
14067
14361
|
for (let x = 0; x < 10; x++)
|
|
14068
14362
|
s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10];
|
|
14069
14363
|
}
|
|
14070
|
-
s[0] ^=
|
|
14071
|
-
s[1] ^=
|
|
14364
|
+
s[0] ^= SHA3_IOTA_H2[round];
|
|
14365
|
+
s[1] ^= SHA3_IOTA_L2[round];
|
|
14072
14366
|
}
|
|
14073
14367
|
B.fill(0);
|
|
14074
14368
|
}
|
|
14075
|
-
var
|
|
14369
|
+
var Keccak2 = class _Keccak extends Hash2 {
|
|
14076
14370
|
// NOTE: we accept arguments in bytes instead of bits here.
|
|
14077
14371
|
constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) {
|
|
14078
14372
|
super();
|
|
@@ -14085,21 +14379,21 @@ var starknet = (() => {
|
|
|
14085
14379
|
this.posOut = 0;
|
|
14086
14380
|
this.finished = false;
|
|
14087
14381
|
this.destroyed = false;
|
|
14088
|
-
|
|
14382
|
+
number2(outputLen);
|
|
14089
14383
|
if (0 >= this.blockLen || this.blockLen >= 200)
|
|
14090
14384
|
throw new Error("Sha3 supports only keccak-f1600 function");
|
|
14091
14385
|
this.state = new Uint8Array(200);
|
|
14092
|
-
this.state32 =
|
|
14386
|
+
this.state32 = u322(this.state);
|
|
14093
14387
|
}
|
|
14094
14388
|
keccak() {
|
|
14095
|
-
|
|
14389
|
+
keccakP2(this.state32, this.rounds);
|
|
14096
14390
|
this.posOut = 0;
|
|
14097
14391
|
this.pos = 0;
|
|
14098
14392
|
}
|
|
14099
14393
|
update(data) {
|
|
14100
|
-
|
|
14394
|
+
exists2(this);
|
|
14101
14395
|
const { blockLen, state } = this;
|
|
14102
|
-
data =
|
|
14396
|
+
data = toBytes2(data);
|
|
14103
14397
|
const len = data.length;
|
|
14104
14398
|
for (let pos = 0; pos < len; ) {
|
|
14105
14399
|
const take = Math.min(blockLen - this.pos, len - pos);
|
|
@@ -14122,8 +14416,8 @@ var starknet = (() => {
|
|
|
14122
14416
|
this.keccak();
|
|
14123
14417
|
}
|
|
14124
14418
|
writeInto(out) {
|
|
14125
|
-
|
|
14126
|
-
|
|
14419
|
+
exists2(this, false);
|
|
14420
|
+
bytes2(out);
|
|
14127
14421
|
this.finish();
|
|
14128
14422
|
const bufferOut = this.state;
|
|
14129
14423
|
const { blockLen } = this;
|
|
@@ -14143,11 +14437,11 @@ var starknet = (() => {
|
|
|
14143
14437
|
return this.writeInto(out);
|
|
14144
14438
|
}
|
|
14145
14439
|
xof(bytes3) {
|
|
14146
|
-
|
|
14440
|
+
number2(bytes3);
|
|
14147
14441
|
return this.xofInto(new Uint8Array(bytes3));
|
|
14148
14442
|
}
|
|
14149
14443
|
digestInto(out) {
|
|
14150
|
-
|
|
14444
|
+
output2(out, this);
|
|
14151
14445
|
if (this.finished)
|
|
14152
14446
|
throw new Error("digest() was already called");
|
|
14153
14447
|
this.writeInto(out);
|
|
@@ -14176,33 +14470,33 @@ var starknet = (() => {
|
|
|
14176
14470
|
return to;
|
|
14177
14471
|
}
|
|
14178
14472
|
};
|
|
14179
|
-
var
|
|
14180
|
-
var
|
|
14181
|
-
var
|
|
14182
|
-
var
|
|
14183
|
-
var
|
|
14184
|
-
var
|
|
14185
|
-
var
|
|
14186
|
-
var
|
|
14187
|
-
var
|
|
14188
|
-
var
|
|
14189
|
-
var
|
|
14190
|
-
var
|
|
14473
|
+
var gen2 = (suffix, blockLen, outputLen) => wrapConstructor2(() => new Keccak2(blockLen, suffix, outputLen));
|
|
14474
|
+
var sha3_2242 = /* @__PURE__ */ gen2(6, 144, 224 / 8);
|
|
14475
|
+
var sha3_2562 = /* @__PURE__ */ gen2(6, 136, 256 / 8);
|
|
14476
|
+
var sha3_3842 = /* @__PURE__ */ gen2(6, 104, 384 / 8);
|
|
14477
|
+
var sha3_5122 = /* @__PURE__ */ gen2(6, 72, 512 / 8);
|
|
14478
|
+
var keccak_2242 = /* @__PURE__ */ gen2(1, 144, 224 / 8);
|
|
14479
|
+
var keccak_2562 = /* @__PURE__ */ gen2(1, 136, 256 / 8);
|
|
14480
|
+
var keccak_3842 = /* @__PURE__ */ gen2(1, 104, 384 / 8);
|
|
14481
|
+
var keccak_5122 = /* @__PURE__ */ gen2(1, 72, 512 / 8);
|
|
14482
|
+
var genShake2 = (suffix, blockLen, outputLen) => wrapXOFConstructorWithOpts2((opts = {}) => new Keccak2(blockLen, suffix, opts.dkLen === void 0 ? outputLen : opts.dkLen, true));
|
|
14483
|
+
var shake1282 = /* @__PURE__ */ genShake2(31, 168, 128 / 8);
|
|
14484
|
+
var shake2562 = /* @__PURE__ */ genShake2(31, 136, 256 / 8);
|
|
14191
14485
|
|
|
14192
|
-
// node_modules/@noble/hashes/esm/_sha2.js
|
|
14486
|
+
// node_modules/@scure/starknet/node_modules/@noble/hashes/esm/_sha2.js
|
|
14193
14487
|
function setBigUint64(view, byteOffset, value, isLE3) {
|
|
14194
14488
|
if (typeof view.setBigUint64 === "function")
|
|
14195
14489
|
return view.setBigUint64(byteOffset, value, isLE3);
|
|
14196
|
-
const
|
|
14490
|
+
const _32n3 = BigInt(32);
|
|
14197
14491
|
const _u32_max = BigInt(4294967295);
|
|
14198
|
-
const wh = Number(value >>
|
|
14492
|
+
const wh = Number(value >> _32n3 & _u32_max);
|
|
14199
14493
|
const wl = Number(value & _u32_max);
|
|
14200
14494
|
const h = isLE3 ? 4 : 0;
|
|
14201
14495
|
const l = isLE3 ? 0 : 4;
|
|
14202
14496
|
view.setUint32(byteOffset + h, wh, isLE3);
|
|
14203
14497
|
view.setUint32(byteOffset + l, wl, isLE3);
|
|
14204
14498
|
}
|
|
14205
|
-
var SHA2 = class extends
|
|
14499
|
+
var SHA2 = class extends Hash2 {
|
|
14206
14500
|
constructor(blockLen, outputLen, padOffset, isLE3) {
|
|
14207
14501
|
super();
|
|
14208
14502
|
this.blockLen = blockLen;
|
|
@@ -14214,17 +14508,17 @@ var starknet = (() => {
|
|
|
14214
14508
|
this.pos = 0;
|
|
14215
14509
|
this.destroyed = false;
|
|
14216
14510
|
this.buffer = new Uint8Array(blockLen);
|
|
14217
|
-
this.view =
|
|
14511
|
+
this.view = createView2(this.buffer);
|
|
14218
14512
|
}
|
|
14219
14513
|
update(data) {
|
|
14220
|
-
|
|
14514
|
+
exists2(this);
|
|
14221
14515
|
const { view, buffer, blockLen } = this;
|
|
14222
|
-
data =
|
|
14516
|
+
data = toBytes2(data);
|
|
14223
14517
|
const len = data.length;
|
|
14224
14518
|
for (let pos = 0; pos < len; ) {
|
|
14225
14519
|
const take = Math.min(blockLen - this.pos, len - pos);
|
|
14226
14520
|
if (take === blockLen) {
|
|
14227
|
-
const dataView =
|
|
14521
|
+
const dataView = createView2(data);
|
|
14228
14522
|
for (; blockLen <= len - pos; pos += blockLen)
|
|
14229
14523
|
this.process(dataView, pos);
|
|
14230
14524
|
continue;
|
|
@@ -14242,8 +14536,8 @@ var starknet = (() => {
|
|
|
14242
14536
|
return this;
|
|
14243
14537
|
}
|
|
14244
14538
|
digestInto(out) {
|
|
14245
|
-
|
|
14246
|
-
|
|
14539
|
+
exists2(this);
|
|
14540
|
+
output2(out, this);
|
|
14247
14541
|
this.finished = true;
|
|
14248
14542
|
const { buffer, view, blockLen, isLE: isLE3 } = this;
|
|
14249
14543
|
let { pos } = this;
|
|
@@ -14257,7 +14551,7 @@ var starknet = (() => {
|
|
|
14257
14551
|
buffer[i] = 0;
|
|
14258
14552
|
setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE3);
|
|
14259
14553
|
this.process(view, 0);
|
|
14260
|
-
const oview =
|
|
14554
|
+
const oview = createView2(out);
|
|
14261
14555
|
const len = this.outputLen;
|
|
14262
14556
|
if (len % 4)
|
|
14263
14557
|
throw new Error("_sha2: outputLen should be aligned to 32bit");
|
|
@@ -14289,7 +14583,7 @@ var starknet = (() => {
|
|
|
14289
14583
|
}
|
|
14290
14584
|
};
|
|
14291
14585
|
|
|
14292
|
-
// node_modules/@noble/hashes/esm/sha256.js
|
|
14586
|
+
// node_modules/@scure/starknet/node_modules/@noble/hashes/esm/sha256.js
|
|
14293
14587
|
var Chi = (a, b, c) => a & b ^ ~a & c;
|
|
14294
14588
|
var Maj = (a, b, c) => a & b ^ a & c ^ b & c;
|
|
14295
14589
|
var SHA256_K = /* @__PURE__ */ new Uint32Array([
|
|
@@ -14402,15 +14696,15 @@ var starknet = (() => {
|
|
|
14402
14696
|
for (let i = 16; i < 64; i++) {
|
|
14403
14697
|
const W15 = SHA256_W[i - 15];
|
|
14404
14698
|
const W2 = SHA256_W[i - 2];
|
|
14405
|
-
const s0 =
|
|
14406
|
-
const s1 =
|
|
14699
|
+
const s0 = rotr2(W15, 7) ^ rotr2(W15, 18) ^ W15 >>> 3;
|
|
14700
|
+
const s1 = rotr2(W2, 17) ^ rotr2(W2, 19) ^ W2 >>> 10;
|
|
14407
14701
|
SHA256_W[i] = s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0;
|
|
14408
14702
|
}
|
|
14409
14703
|
let { A, B, C, D, E, F, G, H } = this;
|
|
14410
14704
|
for (let i = 0; i < 64; i++) {
|
|
14411
|
-
const sigma1 =
|
|
14705
|
+
const sigma1 = rotr2(E, 6) ^ rotr2(E, 11) ^ rotr2(E, 25);
|
|
14412
14706
|
const T1 = H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i] | 0;
|
|
14413
|
-
const sigma0 =
|
|
14707
|
+
const sigma0 = rotr2(A, 2) ^ rotr2(A, 13) ^ rotr2(A, 22);
|
|
14414
14708
|
const T2 = sigma0 + Maj(A, B, C) | 0;
|
|
14415
14709
|
H = G;
|
|
14416
14710
|
G = F;
|
|
@@ -14439,7 +14733,7 @@ var starknet = (() => {
|
|
|
14439
14733
|
this.buffer.fill(0);
|
|
14440
14734
|
}
|
|
14441
14735
|
};
|
|
14442
|
-
var sha256 = /* @__PURE__ */
|
|
14736
|
+
var sha256 = /* @__PURE__ */ wrapConstructor2(() => new SHA256());
|
|
14443
14737
|
|
|
14444
14738
|
// node_modules/@scure/starknet/node_modules/@noble/curves/esm/abstract/utils.js
|
|
14445
14739
|
var utils_exports2 = {};
|
|
@@ -14451,29 +14745,29 @@ var starknet = (() => {
|
|
|
14451
14745
|
bytesToHex: () => bytesToHex2,
|
|
14452
14746
|
bytesToNumberBE: () => bytesToNumberBE2,
|
|
14453
14747
|
bytesToNumberLE: () => bytesToNumberLE2,
|
|
14454
|
-
concatBytes: () =>
|
|
14748
|
+
concatBytes: () => concatBytes4,
|
|
14455
14749
|
createHmacDrbg: () => createHmacDrbg2,
|
|
14456
14750
|
ensureBytes: () => ensureBytes2,
|
|
14457
14751
|
equalBytes: () => equalBytes2,
|
|
14458
14752
|
hexToBytes: () => hexToBytes3,
|
|
14459
14753
|
hexToNumber: () => hexToNumber2,
|
|
14460
|
-
isBytes: () =>
|
|
14754
|
+
isBytes: () => isBytes6,
|
|
14461
14755
|
numberToBytesBE: () => numberToBytesBE2,
|
|
14462
14756
|
numberToBytesLE: () => numberToBytesLE2,
|
|
14463
14757
|
numberToHexUnpadded: () => numberToHexUnpadded2,
|
|
14464
14758
|
numberToVarBytesBE: () => numberToVarBytesBE2,
|
|
14465
|
-
utf8ToBytes: () =>
|
|
14759
|
+
utf8ToBytes: () => utf8ToBytes4,
|
|
14466
14760
|
validateObject: () => validateObject2
|
|
14467
14761
|
});
|
|
14468
|
-
var
|
|
14469
|
-
var
|
|
14470
|
-
var
|
|
14471
|
-
function
|
|
14762
|
+
var _0n4 = BigInt(0);
|
|
14763
|
+
var _1n4 = BigInt(1);
|
|
14764
|
+
var _2n4 = BigInt(2);
|
|
14765
|
+
function isBytes6(a) {
|
|
14472
14766
|
return a instanceof Uint8Array || a != null && typeof a === "object" && a.constructor.name === "Uint8Array";
|
|
14473
14767
|
}
|
|
14474
14768
|
var hexes2 = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
|
|
14475
14769
|
function bytesToHex2(bytes3) {
|
|
14476
|
-
if (!
|
|
14770
|
+
if (!isBytes6(bytes3))
|
|
14477
14771
|
throw new Error("Uint8Array expected");
|
|
14478
14772
|
let hex = "";
|
|
14479
14773
|
for (let i = 0; i < bytes3.length; i++) {
|
|
@@ -14523,7 +14817,7 @@ var starknet = (() => {
|
|
|
14523
14817
|
return hexToNumber2(bytesToHex2(bytes3));
|
|
14524
14818
|
}
|
|
14525
14819
|
function bytesToNumberLE2(bytes3) {
|
|
14526
|
-
if (!
|
|
14820
|
+
if (!isBytes6(bytes3))
|
|
14527
14821
|
throw new Error("Uint8Array expected");
|
|
14528
14822
|
return hexToNumber2(bytesToHex2(Uint8Array.from(bytes3).reverse()));
|
|
14529
14823
|
}
|
|
@@ -14544,7 +14838,7 @@ var starknet = (() => {
|
|
|
14544
14838
|
} catch (e) {
|
|
14545
14839
|
throw new Error(`${title} must be valid hex string, got "${hex}". Cause: ${e}`);
|
|
14546
14840
|
}
|
|
14547
|
-
} else if (
|
|
14841
|
+
} else if (isBytes6(hex)) {
|
|
14548
14842
|
res = Uint8Array.from(hex);
|
|
14549
14843
|
} else {
|
|
14550
14844
|
throw new Error(`${title} must be hex string or Uint8Array`);
|
|
@@ -14554,11 +14848,11 @@ var starknet = (() => {
|
|
|
14554
14848
|
throw new Error(`${title} expected ${expectedLength} bytes, got ${len}`);
|
|
14555
14849
|
return res;
|
|
14556
14850
|
}
|
|
14557
|
-
function
|
|
14851
|
+
function concatBytes4(...arrays) {
|
|
14558
14852
|
let sum = 0;
|
|
14559
14853
|
for (let i = 0; i < arrays.length; i++) {
|
|
14560
14854
|
const a = arrays[i];
|
|
14561
|
-
if (!
|
|
14855
|
+
if (!isBytes6(a))
|
|
14562
14856
|
throw new Error("Uint8Array expected");
|
|
14563
14857
|
sum += a.length;
|
|
14564
14858
|
}
|
|
@@ -14579,24 +14873,24 @@ var starknet = (() => {
|
|
|
14579
14873
|
diff |= a[i] ^ b[i];
|
|
14580
14874
|
return diff === 0;
|
|
14581
14875
|
}
|
|
14582
|
-
function
|
|
14876
|
+
function utf8ToBytes4(str) {
|
|
14583
14877
|
if (typeof str !== "string")
|
|
14584
14878
|
throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
|
|
14585
14879
|
return new Uint8Array(new TextEncoder().encode(str));
|
|
14586
14880
|
}
|
|
14587
14881
|
function bitLen2(n) {
|
|
14588
14882
|
let len;
|
|
14589
|
-
for (len = 0; n >
|
|
14883
|
+
for (len = 0; n > _0n4; n >>= _1n4, len += 1)
|
|
14590
14884
|
;
|
|
14591
14885
|
return len;
|
|
14592
14886
|
}
|
|
14593
14887
|
function bitGet2(n, pos) {
|
|
14594
|
-
return n >> BigInt(pos) &
|
|
14888
|
+
return n >> BigInt(pos) & _1n4;
|
|
14595
14889
|
}
|
|
14596
14890
|
var bitSet2 = (n, pos, value) => {
|
|
14597
|
-
return n | (value ?
|
|
14891
|
+
return n | (value ? _1n4 : _0n4) << BigInt(pos);
|
|
14598
14892
|
};
|
|
14599
|
-
var bitMask2 = (n) => (
|
|
14893
|
+
var bitMask2 = (n) => (_2n4 << BigInt(n - 1)) - _1n4;
|
|
14600
14894
|
var u8n2 = (data) => new Uint8Array(data);
|
|
14601
14895
|
var u8fr2 = (arr) => Uint8Array.from(arr);
|
|
14602
14896
|
function createHmacDrbg2(hashLen, qByteLen, hmacFn) {
|
|
@@ -14623,7 +14917,7 @@ var starknet = (() => {
|
|
|
14623
14917
|
k = h(u8fr2([1]), seed);
|
|
14624
14918
|
v = h();
|
|
14625
14919
|
};
|
|
14626
|
-
const
|
|
14920
|
+
const gen3 = () => {
|
|
14627
14921
|
if (i++ >= 1e3)
|
|
14628
14922
|
throw new Error("drbg: tried 1000 values");
|
|
14629
14923
|
let len = 0;
|
|
@@ -14634,13 +14928,13 @@ var starknet = (() => {
|
|
|
14634
14928
|
out.push(sl);
|
|
14635
14929
|
len += v.length;
|
|
14636
14930
|
}
|
|
14637
|
-
return
|
|
14931
|
+
return concatBytes4(...out);
|
|
14638
14932
|
};
|
|
14639
14933
|
const genUntil = (seed, pred) => {
|
|
14640
14934
|
reset();
|
|
14641
14935
|
reseed(seed);
|
|
14642
14936
|
let res = void 0;
|
|
14643
|
-
while (!(res = pred(
|
|
14937
|
+
while (!(res = pred(gen3())))
|
|
14644
14938
|
reseed();
|
|
14645
14939
|
reset();
|
|
14646
14940
|
return res;
|
|
@@ -14652,7 +14946,7 @@ var starknet = (() => {
|
|
|
14652
14946
|
function: (val) => typeof val === "function",
|
|
14653
14947
|
boolean: (val) => typeof val === "boolean",
|
|
14654
14948
|
string: (val) => typeof val === "string",
|
|
14655
|
-
stringOrUint8Array: (val) => typeof val === "string" ||
|
|
14949
|
+
stringOrUint8Array: (val) => typeof val === "string" || isBytes6(val),
|
|
14656
14950
|
isSafeInteger: (val) => Number.isSafeInteger(val),
|
|
14657
14951
|
array: (val) => Array.isArray(val),
|
|
14658
14952
|
field: (val, object) => object.Fp.isValid(val),
|
|
@@ -14678,9 +14972,9 @@ var starknet = (() => {
|
|
|
14678
14972
|
}
|
|
14679
14973
|
|
|
14680
14974
|
// node_modules/@scure/starknet/node_modules/@noble/curves/esm/abstract/modular.js
|
|
14681
|
-
var
|
|
14682
|
-
var
|
|
14683
|
-
var
|
|
14975
|
+
var _0n5 = BigInt(0);
|
|
14976
|
+
var _1n5 = BigInt(1);
|
|
14977
|
+
var _2n5 = BigInt(2);
|
|
14684
14978
|
var _3n = BigInt(3);
|
|
14685
14979
|
var _4n = BigInt(4);
|
|
14686
14980
|
var _5n = BigInt(5);
|
|
@@ -14689,30 +14983,30 @@ var starknet = (() => {
|
|
|
14689
14983
|
var _16n = BigInt(16);
|
|
14690
14984
|
function mod(a, b) {
|
|
14691
14985
|
const result = a % b;
|
|
14692
|
-
return result >=
|
|
14986
|
+
return result >= _0n5 ? result : b + result;
|
|
14693
14987
|
}
|
|
14694
14988
|
function pow(num, power, modulo) {
|
|
14695
|
-
if (modulo <=
|
|
14989
|
+
if (modulo <= _0n5 || power < _0n5)
|
|
14696
14990
|
throw new Error("Expected power/modulo > 0");
|
|
14697
|
-
if (modulo ===
|
|
14698
|
-
return
|
|
14699
|
-
let res =
|
|
14700
|
-
while (power >
|
|
14701
|
-
if (power &
|
|
14991
|
+
if (modulo === _1n5)
|
|
14992
|
+
return _0n5;
|
|
14993
|
+
let res = _1n5;
|
|
14994
|
+
while (power > _0n5) {
|
|
14995
|
+
if (power & _1n5)
|
|
14702
14996
|
res = res * num % modulo;
|
|
14703
14997
|
num = num * num % modulo;
|
|
14704
|
-
power >>=
|
|
14998
|
+
power >>= _1n5;
|
|
14705
14999
|
}
|
|
14706
15000
|
return res;
|
|
14707
15001
|
}
|
|
14708
15002
|
function invert(number4, modulo) {
|
|
14709
|
-
if (number4 ===
|
|
15003
|
+
if (number4 === _0n5 || modulo <= _0n5) {
|
|
14710
15004
|
throw new Error(`invert: expected positive integers, got n=${number4} mod=${modulo}`);
|
|
14711
15005
|
}
|
|
14712
15006
|
let a = mod(number4, modulo);
|
|
14713
15007
|
let b = modulo;
|
|
14714
|
-
let x =
|
|
14715
|
-
while (a !==
|
|
15008
|
+
let x = _0n5, y = _1n5, u = _1n5, v = _0n5;
|
|
15009
|
+
while (a !== _0n5) {
|
|
14716
15010
|
const q = b / a;
|
|
14717
15011
|
const r = b % a;
|
|
14718
15012
|
const m = x - u * q;
|
|
@@ -14720,19 +15014,19 @@ var starknet = (() => {
|
|
|
14720
15014
|
b = a, a = r, x = u, y = v, u = m, v = n;
|
|
14721
15015
|
}
|
|
14722
15016
|
const gcd2 = b;
|
|
14723
|
-
if (gcd2 !==
|
|
15017
|
+
if (gcd2 !== _1n5)
|
|
14724
15018
|
throw new Error("invert: does not exist");
|
|
14725
15019
|
return mod(x, modulo);
|
|
14726
15020
|
}
|
|
14727
15021
|
function tonelliShanks(P) {
|
|
14728
|
-
const legendreC = (P -
|
|
15022
|
+
const legendreC = (P - _1n5) / _2n5;
|
|
14729
15023
|
let Q, S, Z;
|
|
14730
|
-
for (Q = P -
|
|
15024
|
+
for (Q = P - _1n5, S = 0; Q % _2n5 === _0n5; Q /= _2n5, S++)
|
|
14731
15025
|
;
|
|
14732
|
-
for (Z =
|
|
15026
|
+
for (Z = _2n5; Z < P && pow(Z, legendreC, P) !== P - _1n5; Z++)
|
|
14733
15027
|
;
|
|
14734
15028
|
if (S === 1) {
|
|
14735
|
-
const p1div4 = (P +
|
|
15029
|
+
const p1div4 = (P + _1n5) / _4n;
|
|
14736
15030
|
return function tonelliFast(Fp2, n) {
|
|
14737
15031
|
const root = Fp2.pow(n, p1div4);
|
|
14738
15032
|
if (!Fp2.eql(Fp2.sqr(root), n))
|
|
@@ -14740,7 +15034,7 @@ var starknet = (() => {
|
|
|
14740
15034
|
return root;
|
|
14741
15035
|
};
|
|
14742
15036
|
}
|
|
14743
|
-
const Q1div2 = (Q +
|
|
15037
|
+
const Q1div2 = (Q + _1n5) / _2n5;
|
|
14744
15038
|
return function tonelliSlow(Fp2, n) {
|
|
14745
15039
|
if (Fp2.pow(n, legendreC) === Fp2.neg(Fp2.ONE))
|
|
14746
15040
|
throw new Error("Cannot find square root");
|
|
@@ -14757,7 +15051,7 @@ var starknet = (() => {
|
|
|
14757
15051
|
break;
|
|
14758
15052
|
t2 = Fp2.sqr(t2);
|
|
14759
15053
|
}
|
|
14760
|
-
const ge = Fp2.pow(g2,
|
|
15054
|
+
const ge = Fp2.pow(g2, _1n5 << BigInt(r - m - 1));
|
|
14761
15055
|
g2 = Fp2.sqr(ge);
|
|
14762
15056
|
x = Fp2.mul(x, ge);
|
|
14763
15057
|
b = Fp2.mul(b, g2);
|
|
@@ -14768,7 +15062,7 @@ var starknet = (() => {
|
|
|
14768
15062
|
}
|
|
14769
15063
|
function FpSqrt(P) {
|
|
14770
15064
|
if (P % _4n === _3n) {
|
|
14771
|
-
const p1div4 = (P +
|
|
15065
|
+
const p1div4 = (P + _1n5) / _4n;
|
|
14772
15066
|
return function sqrt3mod4(Fp2, n) {
|
|
14773
15067
|
const root = Fp2.pow(n, p1div4);
|
|
14774
15068
|
if (!Fp2.eql(Fp2.sqr(root), n))
|
|
@@ -14779,10 +15073,10 @@ var starknet = (() => {
|
|
|
14779
15073
|
if (P % _8n === _5n) {
|
|
14780
15074
|
const c1 = (P - _5n) / _8n;
|
|
14781
15075
|
return function sqrt5mod8(Fp2, n) {
|
|
14782
|
-
const n2 = Fp2.mul(n,
|
|
15076
|
+
const n2 = Fp2.mul(n, _2n5);
|
|
14783
15077
|
const v = Fp2.pow(n2, c1);
|
|
14784
15078
|
const nv = Fp2.mul(n, v);
|
|
14785
|
-
const i = Fp2.mul(Fp2.mul(nv,
|
|
15079
|
+
const i = Fp2.mul(Fp2.mul(nv, _2n5), v);
|
|
14786
15080
|
const root = Fp2.mul(nv, Fp2.sub(i, Fp2.ONE));
|
|
14787
15081
|
if (!Fp2.eql(Fp2.sqr(root), n))
|
|
14788
15082
|
throw new Error("Cannot find square root");
|
|
@@ -14826,19 +15120,19 @@ var starknet = (() => {
|
|
|
14826
15120
|
return validateObject2(field, opts);
|
|
14827
15121
|
}
|
|
14828
15122
|
function FpPow(f, num, power) {
|
|
14829
|
-
if (power <
|
|
15123
|
+
if (power < _0n5)
|
|
14830
15124
|
throw new Error("Expected power > 0");
|
|
14831
|
-
if (power ===
|
|
15125
|
+
if (power === _0n5)
|
|
14832
15126
|
return f.ONE;
|
|
14833
|
-
if (power ===
|
|
15127
|
+
if (power === _1n5)
|
|
14834
15128
|
return num;
|
|
14835
15129
|
let p = f.ONE;
|
|
14836
15130
|
let d = num;
|
|
14837
|
-
while (power >
|
|
14838
|
-
if (power &
|
|
15131
|
+
while (power > _0n5) {
|
|
15132
|
+
if (power & _1n5)
|
|
14839
15133
|
p = f.mul(p, d);
|
|
14840
15134
|
d = f.sqr(d);
|
|
14841
|
-
power >>=
|
|
15135
|
+
power >>= _1n5;
|
|
14842
15136
|
}
|
|
14843
15137
|
return p;
|
|
14844
15138
|
}
|
|
@@ -14865,7 +15159,7 @@ var starknet = (() => {
|
|
|
14865
15159
|
return { nBitLength: _nBitLength, nByteLength };
|
|
14866
15160
|
}
|
|
14867
15161
|
function Field(ORDER, bitLen3, isLE3 = false, redef = {}) {
|
|
14868
|
-
if (ORDER <=
|
|
15162
|
+
if (ORDER <= _0n5)
|
|
14869
15163
|
throw new Error(`Expected Field ORDER > 0, got ${ORDER}`);
|
|
14870
15164
|
const { nBitLength: BITS, nByteLength: BYTES } = nLength(ORDER, bitLen3);
|
|
14871
15165
|
if (BYTES > 2048)
|
|
@@ -14876,16 +15170,16 @@ var starknet = (() => {
|
|
|
14876
15170
|
BITS,
|
|
14877
15171
|
BYTES,
|
|
14878
15172
|
MASK: bitMask2(BITS),
|
|
14879
|
-
ZERO:
|
|
14880
|
-
ONE:
|
|
15173
|
+
ZERO: _0n5,
|
|
15174
|
+
ONE: _1n5,
|
|
14881
15175
|
create: (num) => mod(num, ORDER),
|
|
14882
15176
|
isValid: (num) => {
|
|
14883
15177
|
if (typeof num !== "bigint")
|
|
14884
15178
|
throw new Error(`Invalid field element: expected bigint, got ${typeof num}`);
|
|
14885
|
-
return
|
|
15179
|
+
return _0n5 <= num && num < ORDER;
|
|
14886
15180
|
},
|
|
14887
|
-
is0: (num) => num ===
|
|
14888
|
-
isOdd: (num) => (num &
|
|
15181
|
+
is0: (num) => num === _0n5,
|
|
15182
|
+
isOdd: (num) => (num & _1n5) === _1n5,
|
|
14889
15183
|
neg: (num) => mod(-num, ORDER),
|
|
14890
15184
|
eql: (lhs, rhs) => lhs === rhs,
|
|
14891
15185
|
sqr: (num) => mod(num * num, ORDER),
|
|
@@ -14931,7 +15225,7 @@ var starknet = (() => {
|
|
|
14931
15225
|
if (len < 16 || len < minLen || len > 1024)
|
|
14932
15226
|
throw new Error(`expected ${minLen}-1024 bytes of input, got ${len}`);
|
|
14933
15227
|
const num = isLE3 ? bytesToNumberBE2(key) : bytesToNumberLE2(key);
|
|
14934
|
-
const reduced = mod(num, fieldOrder -
|
|
15228
|
+
const reduced = mod(num, fieldOrder - _1n5) + _1n5;
|
|
14935
15229
|
return isLE3 ? numberToBytesLE2(reduced, fieldLen) : numberToBytesBE2(reduced, fieldLen);
|
|
14936
15230
|
}
|
|
14937
15231
|
|
|
@@ -15019,8 +15313,8 @@ var starknet = (() => {
|
|
|
15019
15313
|
}
|
|
15020
15314
|
|
|
15021
15315
|
// node_modules/@scure/starknet/node_modules/@noble/curves/esm/abstract/curve.js
|
|
15022
|
-
var
|
|
15023
|
-
var
|
|
15316
|
+
var _0n6 = BigInt(0);
|
|
15317
|
+
var _1n6 = BigInt(1);
|
|
15024
15318
|
function wNAF(c, bits) {
|
|
15025
15319
|
const constTimeNegate = (condition, item) => {
|
|
15026
15320
|
const neg = item.negate();
|
|
@@ -15037,11 +15331,11 @@ var starknet = (() => {
|
|
|
15037
15331
|
unsafeLadder(elm, n) {
|
|
15038
15332
|
let p = c.ZERO;
|
|
15039
15333
|
let d = elm;
|
|
15040
|
-
while (n >
|
|
15041
|
-
if (n &
|
|
15334
|
+
while (n > _0n6) {
|
|
15335
|
+
if (n & _1n6)
|
|
15042
15336
|
p = p.add(d);
|
|
15043
15337
|
d = d.double();
|
|
15044
|
-
n >>=
|
|
15338
|
+
n >>= _1n6;
|
|
15045
15339
|
}
|
|
15046
15340
|
return p;
|
|
15047
15341
|
},
|
|
@@ -15091,7 +15385,7 @@ var starknet = (() => {
|
|
|
15091
15385
|
n >>= shiftBy;
|
|
15092
15386
|
if (wbits > windowSize) {
|
|
15093
15387
|
wbits -= maxNumber;
|
|
15094
|
-
n +=
|
|
15388
|
+
n += _1n6;
|
|
15095
15389
|
}
|
|
15096
15390
|
const offset1 = offset;
|
|
15097
15391
|
const offset2 = offset + Math.abs(wbits) - 1;
|
|
@@ -15187,7 +15481,7 @@ var starknet = (() => {
|
|
|
15187
15481
|
toSig(hex) {
|
|
15188
15482
|
const { Err: E } = DER;
|
|
15189
15483
|
const data = typeof hex === "string" ? h2b(hex) : hex;
|
|
15190
|
-
if (!
|
|
15484
|
+
if (!isBytes6(data))
|
|
15191
15485
|
throw new Error("ui8a expected");
|
|
15192
15486
|
let l = data.length;
|
|
15193
15487
|
if (l < 2 || data[0] != 48)
|
|
@@ -15215,9 +15509,9 @@ var starknet = (() => {
|
|
|
15215
15509
|
return `30${h(rhl + shl + 4)}02${rl}${r}02${sl}${s}`;
|
|
15216
15510
|
}
|
|
15217
15511
|
};
|
|
15218
|
-
var
|
|
15219
|
-
var
|
|
15220
|
-
var
|
|
15512
|
+
var _0n7 = BigInt(0);
|
|
15513
|
+
var _1n7 = BigInt(1);
|
|
15514
|
+
var _2n6 = BigInt(2);
|
|
15221
15515
|
var _3n2 = BigInt(3);
|
|
15222
15516
|
var _4n2 = BigInt(4);
|
|
15223
15517
|
function weierstrassPoints(opts) {
|
|
@@ -15225,7 +15519,7 @@ var starknet = (() => {
|
|
|
15225
15519
|
const { Fp: Fp2 } = CURVE2;
|
|
15226
15520
|
const toBytes3 = CURVE2.toBytes || ((_c, point, _isCompressed) => {
|
|
15227
15521
|
const a = point.toAffine();
|
|
15228
|
-
return
|
|
15522
|
+
return concatBytes4(Uint8Array.from([4]), Fp2.toBytes(a.x), Fp2.toBytes(a.y));
|
|
15229
15523
|
});
|
|
15230
15524
|
const fromBytes = CURVE2.fromBytes || ((bytes3) => {
|
|
15231
15525
|
const tail = bytes3.subarray(1);
|
|
@@ -15242,7 +15536,7 @@ var starknet = (() => {
|
|
|
15242
15536
|
if (!Fp2.eql(Fp2.sqr(CURVE2.Gy), weierstrassEquation(CURVE2.Gx)))
|
|
15243
15537
|
throw new Error("bad generator point: equation left != right");
|
|
15244
15538
|
function isWithinCurveOrder(num) {
|
|
15245
|
-
return typeof num === "bigint" &&
|
|
15539
|
+
return typeof num === "bigint" && _0n7 < num && num < CURVE2.n;
|
|
15246
15540
|
}
|
|
15247
15541
|
function assertGE(num) {
|
|
15248
15542
|
if (!isWithinCurveOrder(num))
|
|
@@ -15251,7 +15545,7 @@ var starknet = (() => {
|
|
|
15251
15545
|
function normPrivateKeyToScalar(key) {
|
|
15252
15546
|
const { allowedPrivateKeyLengths: lengths, nByteLength, wrapPrivateKey, n } = CURVE2;
|
|
15253
15547
|
if (lengths && typeof key !== "bigint") {
|
|
15254
|
-
if (
|
|
15548
|
+
if (isBytes6(key))
|
|
15255
15549
|
key = bytesToHex2(key);
|
|
15256
15550
|
if (typeof key !== "string" || !lengths.includes(key.length))
|
|
15257
15551
|
throw new Error("Invalid key");
|
|
@@ -15486,10 +15780,10 @@ var starknet = (() => {
|
|
|
15486
15780
|
*/
|
|
15487
15781
|
multiplyUnsafe(n) {
|
|
15488
15782
|
const I = Point2.ZERO;
|
|
15489
|
-
if (n ===
|
|
15783
|
+
if (n === _0n7)
|
|
15490
15784
|
return I;
|
|
15491
15785
|
assertGE(n);
|
|
15492
|
-
if (n ===
|
|
15786
|
+
if (n === _1n7)
|
|
15493
15787
|
return this;
|
|
15494
15788
|
const { endo } = CURVE2;
|
|
15495
15789
|
if (!endo)
|
|
@@ -15498,14 +15792,14 @@ var starknet = (() => {
|
|
|
15498
15792
|
let k1p = I;
|
|
15499
15793
|
let k2p = I;
|
|
15500
15794
|
let d = this;
|
|
15501
|
-
while (k1 >
|
|
15502
|
-
if (k1 &
|
|
15795
|
+
while (k1 > _0n7 || k2 > _0n7) {
|
|
15796
|
+
if (k1 & _1n7)
|
|
15503
15797
|
k1p = k1p.add(d);
|
|
15504
|
-
if (k2 &
|
|
15798
|
+
if (k2 & _1n7)
|
|
15505
15799
|
k2p = k2p.add(d);
|
|
15506
15800
|
d = d.double();
|
|
15507
|
-
k1 >>=
|
|
15508
|
-
k2 >>=
|
|
15801
|
+
k1 >>= _1n7;
|
|
15802
|
+
k2 >>= _1n7;
|
|
15509
15803
|
}
|
|
15510
15804
|
if (k1neg)
|
|
15511
15805
|
k1p = k1p.negate();
|
|
@@ -15552,7 +15846,7 @@ var starknet = (() => {
|
|
|
15552
15846
|
*/
|
|
15553
15847
|
multiplyAndAddUnsafe(Q, a, b) {
|
|
15554
15848
|
const G = Point2.BASE;
|
|
15555
|
-
const mul = (P, a2) => a2 ===
|
|
15849
|
+
const mul = (P, a2) => a2 === _0n7 || a2 === _1n7 || !P.equals(G) ? P.multiplyUnsafe(a2) : P.multiply(a2);
|
|
15556
15850
|
const sum = mul(this, a).add(mul(Q, b));
|
|
15557
15851
|
return sum.is0() ? void 0 : sum;
|
|
15558
15852
|
}
|
|
@@ -15575,7 +15869,7 @@ var starknet = (() => {
|
|
|
15575
15869
|
}
|
|
15576
15870
|
isTorsionFree() {
|
|
15577
15871
|
const { h: cofactor, isTorsionFree } = CURVE2;
|
|
15578
|
-
if (cofactor ===
|
|
15872
|
+
if (cofactor === _1n7)
|
|
15579
15873
|
return true;
|
|
15580
15874
|
if (isTorsionFree)
|
|
15581
15875
|
return isTorsionFree(Point2, this);
|
|
@@ -15583,7 +15877,7 @@ var starknet = (() => {
|
|
|
15583
15877
|
}
|
|
15584
15878
|
clearCofactor() {
|
|
15585
15879
|
const { h: cofactor, clearCofactor } = CURVE2;
|
|
15586
|
-
if (cofactor ===
|
|
15880
|
+
if (cofactor === _1n7)
|
|
15587
15881
|
return this;
|
|
15588
15882
|
if (clearCofactor)
|
|
15589
15883
|
return clearCofactor(Point2, this);
|
|
@@ -15628,7 +15922,7 @@ var starknet = (() => {
|
|
|
15628
15922
|
const compressedLen = Fp2.BYTES + 1;
|
|
15629
15923
|
const uncompressedLen = 2 * Fp2.BYTES + 1;
|
|
15630
15924
|
function isValidFieldElement(num) {
|
|
15631
|
-
return
|
|
15925
|
+
return _0n7 < num && num < Fp2.ORDER;
|
|
15632
15926
|
}
|
|
15633
15927
|
function modN(a) {
|
|
15634
15928
|
return mod(a, CURVE_ORDER2);
|
|
@@ -15641,7 +15935,7 @@ var starknet = (() => {
|
|
|
15641
15935
|
toBytes(_c, point, isCompressed) {
|
|
15642
15936
|
const a = point.toAffine();
|
|
15643
15937
|
const x = Fp2.toBytes(a.x);
|
|
15644
|
-
const cat =
|
|
15938
|
+
const cat = concatBytes4;
|
|
15645
15939
|
if (isCompressed) {
|
|
15646
15940
|
return cat(Uint8Array.from([point.hasEvenY() ? 2 : 3]), x);
|
|
15647
15941
|
} else {
|
|
@@ -15658,7 +15952,7 @@ var starknet = (() => {
|
|
|
15658
15952
|
throw new Error("Point is not on curve");
|
|
15659
15953
|
const y2 = weierstrassEquation(x);
|
|
15660
15954
|
let y = Fp2.sqrt(y2);
|
|
15661
|
-
const isYOdd = (y &
|
|
15955
|
+
const isYOdd = (y & _1n7) === _1n7;
|
|
15662
15956
|
const isHeadOdd = (head & 1) === 1;
|
|
15663
15957
|
if (isHeadOdd !== isYOdd)
|
|
15664
15958
|
y = Fp2.neg(y);
|
|
@@ -15674,7 +15968,7 @@ var starknet = (() => {
|
|
|
15674
15968
|
});
|
|
15675
15969
|
const numToNByteStr = (num) => bytesToHex2(numberToBytesBE2(num, CURVE2.nByteLength));
|
|
15676
15970
|
function isBiggerThanHalfOrder(number4) {
|
|
15677
|
-
const HALF = CURVE_ORDER2 >>
|
|
15971
|
+
const HALF = CURVE_ORDER2 >> _1n7;
|
|
15678
15972
|
return number4 > HALF;
|
|
15679
15973
|
}
|
|
15680
15974
|
function normalizeS(s) {
|
|
@@ -15786,7 +16080,7 @@ var starknet = (() => {
|
|
|
15786
16080
|
return Point2.fromPrivateKey(privateKey).toRawBytes(isCompressed);
|
|
15787
16081
|
}
|
|
15788
16082
|
function isProbPub(item) {
|
|
15789
|
-
const arr =
|
|
16083
|
+
const arr = isBytes6(item);
|
|
15790
16084
|
const str = typeof item === "string";
|
|
15791
16085
|
const len = (arr || str) && item.length;
|
|
15792
16086
|
if (arr)
|
|
@@ -15817,7 +16111,7 @@ var starknet = (() => {
|
|
|
15817
16111
|
function int2octets(num) {
|
|
15818
16112
|
if (typeof num !== "bigint")
|
|
15819
16113
|
throw new Error("bigint expected");
|
|
15820
|
-
if (!(
|
|
16114
|
+
if (!(_0n7 <= num && num < ORDER_MASK))
|
|
15821
16115
|
throw new Error(`bigint expected < 2^${CURVE2.nBitLength}`);
|
|
15822
16116
|
return numberToBytesBE2(num, CURVE2.nByteLength);
|
|
15823
16117
|
}
|
|
@@ -15838,7 +16132,7 @@ var starknet = (() => {
|
|
|
15838
16132
|
const e = ent === true ? randomBytes3(Fp2.BYTES) : ent;
|
|
15839
16133
|
seedArgs.push(ensureBytes2("extraEntropy", e));
|
|
15840
16134
|
}
|
|
15841
|
-
const seed =
|
|
16135
|
+
const seed = concatBytes4(...seedArgs);
|
|
15842
16136
|
const m = h1int;
|
|
15843
16137
|
function k2sig(kBytes) {
|
|
15844
16138
|
const k = bits2int2(kBytes);
|
|
@@ -15847,12 +16141,12 @@ var starknet = (() => {
|
|
|
15847
16141
|
const ik = invN(k);
|
|
15848
16142
|
const q = Point2.BASE.multiply(k).toAffine();
|
|
15849
16143
|
const r = modN(q.x);
|
|
15850
|
-
if (r ===
|
|
16144
|
+
if (r === _0n7)
|
|
15851
16145
|
return;
|
|
15852
16146
|
const s = modN(ik * modN(m + r * d));
|
|
15853
|
-
if (s ===
|
|
16147
|
+
if (s === _0n7)
|
|
15854
16148
|
return;
|
|
15855
|
-
let recovery = (q.x === r ? 0 : 2) | Number(q.y &
|
|
16149
|
+
let recovery = (q.x === r ? 0 : 2) | Number(q.y & _1n7);
|
|
15856
16150
|
let normS = s;
|
|
15857
16151
|
if (lowS && isBiggerThanHalfOrder(s)) {
|
|
15858
16152
|
normS = normalizeS(s);
|
|
@@ -15881,7 +16175,7 @@ var starknet = (() => {
|
|
|
15881
16175
|
let _sig = void 0;
|
|
15882
16176
|
let P;
|
|
15883
16177
|
try {
|
|
15884
|
-
if (typeof sg === "string" ||
|
|
16178
|
+
if (typeof sg === "string" || isBytes6(sg)) {
|
|
15885
16179
|
try {
|
|
15886
16180
|
_sig = Signature3.fromDER(sg);
|
|
15887
16181
|
} catch (derError) {
|
|
@@ -15928,14 +16222,14 @@ var starknet = (() => {
|
|
|
15928
16222
|
};
|
|
15929
16223
|
}
|
|
15930
16224
|
|
|
15931
|
-
// node_modules/@noble/hashes/esm/hmac.js
|
|
15932
|
-
var HMAC = class extends
|
|
16225
|
+
// node_modules/@scure/starknet/node_modules/@noble/hashes/esm/hmac.js
|
|
16226
|
+
var HMAC = class extends Hash2 {
|
|
15933
16227
|
constructor(hash3, _key) {
|
|
15934
16228
|
super();
|
|
15935
16229
|
this.finished = false;
|
|
15936
16230
|
this.destroyed = false;
|
|
15937
|
-
|
|
15938
|
-
const key =
|
|
16231
|
+
hash2(hash3);
|
|
16232
|
+
const key = toBytes2(_key);
|
|
15939
16233
|
this.iHash = hash3.create();
|
|
15940
16234
|
if (typeof this.iHash.update !== "function")
|
|
15941
16235
|
throw new Error("Expected instance of class which extends utils.Hash");
|
|
@@ -15954,13 +16248,13 @@ var starknet = (() => {
|
|
|
15954
16248
|
pad.fill(0);
|
|
15955
16249
|
}
|
|
15956
16250
|
update(buf) {
|
|
15957
|
-
|
|
16251
|
+
exists2(this);
|
|
15958
16252
|
this.iHash.update(buf);
|
|
15959
16253
|
return this;
|
|
15960
16254
|
}
|
|
15961
16255
|
digestInto(out) {
|
|
15962
|
-
|
|
15963
|
-
|
|
16256
|
+
exists2(this);
|
|
16257
|
+
bytes2(out, this.outputLen);
|
|
15964
16258
|
this.finished = true;
|
|
15965
16259
|
this.iHash.digestInto(out);
|
|
15966
16260
|
this.oHash.update(out);
|
|
@@ -15997,8 +16291,8 @@ var starknet = (() => {
|
|
|
15997
16291
|
function getHash(hash3) {
|
|
15998
16292
|
return {
|
|
15999
16293
|
hash: hash3,
|
|
16000
|
-
hmac: (key, ...msgs) => hmac(hash3, key,
|
|
16001
|
-
randomBytes
|
|
16294
|
+
hmac: (key, ...msgs) => hmac(hash3, key, concatBytes3(...msgs)),
|
|
16295
|
+
randomBytes: randomBytes2
|
|
16002
16296
|
};
|
|
16003
16297
|
}
|
|
16004
16298
|
|
|
@@ -16101,7 +16395,7 @@ var starknet = (() => {
|
|
|
16101
16395
|
const sha256mask = 2n ** 256n;
|
|
16102
16396
|
const limit = sha256mask - mod(sha256mask, CURVE_ORDER);
|
|
16103
16397
|
for (let i = 0; ; i++) {
|
|
16104
|
-
const key = sha256Num(
|
|
16398
|
+
const key = sha256Num(concatBytes4(_seed, numberToVarBytesBE2(BigInt(i))));
|
|
16105
16399
|
if (key < limit)
|
|
16106
16400
|
return mod(key, CURVE_ORDER).toString(16);
|
|
16107
16401
|
if (i === 1e5)
|
|
@@ -16183,11 +16477,11 @@ var starknet = (() => {
|
|
|
16183
16477
|
}
|
|
16184
16478
|
var computeHashOnElements = (data, fn = pedersen) => [0, ...data, data.length].reduce((x, y) => fn(x, y));
|
|
16185
16479
|
var MASK_2502 = bitMask2(250);
|
|
16186
|
-
var keccak = (data) => bytesToNumberBE2(
|
|
16480
|
+
var keccak = (data) => bytesToNumberBE2(keccak_2562(data)) & MASK_2502;
|
|
16187
16481
|
var sha256Num = (data) => bytesToNumberBE2(sha256(data));
|
|
16188
16482
|
var Fp251 = Field(BigInt("3618502788666131213697322783095070105623107215331596699973092056135872020481"));
|
|
16189
16483
|
function poseidonRoundConstant(Fp2, name, idx) {
|
|
16190
|
-
const val = Fp2.fromBytes(sha256(
|
|
16484
|
+
const val = Fp2.fromBytes(sha256(utf8ToBytes3(`${name}${idx}`)));
|
|
16191
16485
|
return Fp2.create(val);
|
|
16192
16486
|
}
|
|
16193
16487
|
function _poseidonMDS(Fp2, name, m, attempt = 0) {
|
|
@@ -16885,46 +17179,49 @@ var starknet = (() => {
|
|
|
16885
17179
|
}
|
|
16886
17180
|
};
|
|
16887
17181
|
function formatter(data, type, sameType) {
|
|
16888
|
-
return Object.entries(data).reduce(
|
|
16889
|
-
|
|
16890
|
-
|
|
16891
|
-
|
|
16892
|
-
|
|
16893
|
-
}
|
|
16894
|
-
if (elType === "string") {
|
|
16895
|
-
if (Array.isArray(data[key])) {
|
|
16896
|
-
const arrayStr = formatter(
|
|
16897
|
-
data[key],
|
|
16898
|
-
data[key].map((_) => elType)
|
|
16899
|
-
);
|
|
16900
|
-
acc[key] = Object.values(arrayStr).join("");
|
|
17182
|
+
return Object.entries(data).reduce(
|
|
17183
|
+
(acc, [key, value]) => {
|
|
17184
|
+
const elType = sameType ?? type[key];
|
|
17185
|
+
if (!(key in type) && !sameType) {
|
|
17186
|
+
acc[key] = value;
|
|
16901
17187
|
return acc;
|
|
16902
17188
|
}
|
|
16903
|
-
|
|
16904
|
-
|
|
16905
|
-
|
|
16906
|
-
|
|
16907
|
-
|
|
16908
|
-
|
|
16909
|
-
|
|
16910
|
-
|
|
16911
|
-
|
|
16912
|
-
|
|
16913
|
-
|
|
16914
|
-
|
|
16915
|
-
|
|
16916
|
-
|
|
16917
|
-
|
|
16918
|
-
|
|
16919
|
-
|
|
16920
|
-
|
|
16921
|
-
|
|
16922
|
-
|
|
17189
|
+
if (elType === "string") {
|
|
17190
|
+
if (Array.isArray(data[key])) {
|
|
17191
|
+
const arrayStr = formatter(
|
|
17192
|
+
data[key],
|
|
17193
|
+
data[key].map((_) => elType)
|
|
17194
|
+
);
|
|
17195
|
+
acc[key] = Object.values(arrayStr).join("");
|
|
17196
|
+
return acc;
|
|
17197
|
+
}
|
|
17198
|
+
guard.isBN(data, type, key);
|
|
17199
|
+
acc[key] = decodeShortString(value);
|
|
17200
|
+
return acc;
|
|
17201
|
+
}
|
|
17202
|
+
if (elType === "number") {
|
|
17203
|
+
guard.isBN(data, type, key);
|
|
17204
|
+
acc[key] = Number(value);
|
|
17205
|
+
return acc;
|
|
17206
|
+
}
|
|
17207
|
+
if (typeof elType === "function") {
|
|
17208
|
+
acc[key] = elType(value);
|
|
17209
|
+
return acc;
|
|
17210
|
+
}
|
|
17211
|
+
if (Array.isArray(elType)) {
|
|
17212
|
+
const arrayObj = formatter(data[key], elType, elType[0]);
|
|
17213
|
+
acc[key] = Object.values(arrayObj);
|
|
17214
|
+
return acc;
|
|
17215
|
+
}
|
|
17216
|
+
if (typeof elType === "object") {
|
|
17217
|
+
acc[key] = formatter(data[key], elType);
|
|
17218
|
+
return acc;
|
|
17219
|
+
}
|
|
17220
|
+
guard.unknown(data, type, key);
|
|
16923
17221
|
return acc;
|
|
16924
|
-
}
|
|
16925
|
-
|
|
16926
|
-
|
|
16927
|
-
}, {});
|
|
17222
|
+
},
|
|
17223
|
+
{}
|
|
17224
|
+
);
|
|
16928
17225
|
}
|
|
16929
17226
|
|
|
16930
17227
|
// src/utils/calldata/parser/parser-0-1.1.0.ts
|
|
@@ -16979,7 +17276,9 @@ var starknet = (() => {
|
|
|
16979
17276
|
* @returns FunctionAbi | undefined
|
|
16980
17277
|
*/
|
|
16981
17278
|
getMethod(name) {
|
|
16982
|
-
const intf = this.abi.find(
|
|
17279
|
+
const intf = this.abi.find(
|
|
17280
|
+
(it) => it.type === "interface"
|
|
17281
|
+
);
|
|
16983
17282
|
return intf.items.find((it) => it.name === name);
|
|
16984
17283
|
}
|
|
16985
17284
|
/**
|
|
@@ -17949,7 +18248,7 @@ var starknet = (() => {
|
|
|
17949
18248
|
* Compile contract callData with abi
|
|
17950
18249
|
* Parse the calldata by using input fields from the abi for that method
|
|
17951
18250
|
* @param method string - method name
|
|
17952
|
-
* @param
|
|
18251
|
+
* @param argsCalldata RawArgs - arguments passed to the method. Can be an array of arguments (in the order of abi definition), or an object constructed in conformity with abi (in this case, the parameter can be in a wrong order).
|
|
17953
18252
|
* @return Calldata - parsed arguments in format that contract is expecting
|
|
17954
18253
|
* @example
|
|
17955
18254
|
* ```typescript
|
|
@@ -18194,9 +18493,9 @@ var starknet = (() => {
|
|
|
18194
18493
|
});
|
|
18195
18494
|
|
|
18196
18495
|
// node_modules/@noble/curves/esm/abstract/modular.js
|
|
18197
|
-
var
|
|
18198
|
-
var
|
|
18199
|
-
var
|
|
18496
|
+
var _0n8 = BigInt(0);
|
|
18497
|
+
var _1n8 = BigInt(1);
|
|
18498
|
+
var _2n7 = BigInt(2);
|
|
18200
18499
|
var _3n3 = BigInt(3);
|
|
18201
18500
|
var _4n3 = BigInt(4);
|
|
18202
18501
|
var _5n2 = BigInt(5);
|
|
@@ -18205,38 +18504,38 @@ var starknet = (() => {
|
|
|
18205
18504
|
var _16n2 = BigInt(16);
|
|
18206
18505
|
function mod2(a, b) {
|
|
18207
18506
|
const result = a % b;
|
|
18208
|
-
return result >=
|
|
18507
|
+
return result >= _0n8 ? result : b + result;
|
|
18209
18508
|
}
|
|
18210
18509
|
function pow2(num, power, modulo) {
|
|
18211
|
-
if (modulo <=
|
|
18510
|
+
if (modulo <= _0n8 || power < _0n8)
|
|
18212
18511
|
throw new Error("Expected power/modulo > 0");
|
|
18213
|
-
if (modulo ===
|
|
18214
|
-
return
|
|
18215
|
-
let res =
|
|
18216
|
-
while (power >
|
|
18217
|
-
if (power &
|
|
18512
|
+
if (modulo === _1n8)
|
|
18513
|
+
return _0n8;
|
|
18514
|
+
let res = _1n8;
|
|
18515
|
+
while (power > _0n8) {
|
|
18516
|
+
if (power & _1n8)
|
|
18218
18517
|
res = res * num % modulo;
|
|
18219
18518
|
num = num * num % modulo;
|
|
18220
|
-
power >>=
|
|
18519
|
+
power >>= _1n8;
|
|
18221
18520
|
}
|
|
18222
18521
|
return res;
|
|
18223
18522
|
}
|
|
18224
18523
|
function pow22(x, power, modulo) {
|
|
18225
18524
|
let res = x;
|
|
18226
|
-
while (power-- >
|
|
18525
|
+
while (power-- > _0n8) {
|
|
18227
18526
|
res *= res;
|
|
18228
18527
|
res %= modulo;
|
|
18229
18528
|
}
|
|
18230
18529
|
return res;
|
|
18231
18530
|
}
|
|
18232
18531
|
function invert2(number4, modulo) {
|
|
18233
|
-
if (number4 ===
|
|
18532
|
+
if (number4 === _0n8 || modulo <= _0n8) {
|
|
18234
18533
|
throw new Error(`invert: expected positive integers, got n=${number4} mod=${modulo}`);
|
|
18235
18534
|
}
|
|
18236
18535
|
let a = mod2(number4, modulo);
|
|
18237
18536
|
let b = modulo;
|
|
18238
|
-
let x =
|
|
18239
|
-
while (a !==
|
|
18537
|
+
let x = _0n8, y = _1n8, u = _1n8, v = _0n8;
|
|
18538
|
+
while (a !== _0n8) {
|
|
18240
18539
|
const q = b / a;
|
|
18241
18540
|
const r = b % a;
|
|
18242
18541
|
const m = x - u * q;
|
|
@@ -18244,19 +18543,19 @@ var starknet = (() => {
|
|
|
18244
18543
|
b = a, a = r, x = u, y = v, u = m, v = n;
|
|
18245
18544
|
}
|
|
18246
18545
|
const gcd2 = b;
|
|
18247
|
-
if (gcd2 !==
|
|
18546
|
+
if (gcd2 !== _1n8)
|
|
18248
18547
|
throw new Error("invert: does not exist");
|
|
18249
18548
|
return mod2(x, modulo);
|
|
18250
18549
|
}
|
|
18251
18550
|
function tonelliShanks2(P) {
|
|
18252
|
-
const legendreC = (P -
|
|
18551
|
+
const legendreC = (P - _1n8) / _2n7;
|
|
18253
18552
|
let Q, S, Z;
|
|
18254
|
-
for (Q = P -
|
|
18553
|
+
for (Q = P - _1n8, S = 0; Q % _2n7 === _0n8; Q /= _2n7, S++)
|
|
18255
18554
|
;
|
|
18256
|
-
for (Z =
|
|
18555
|
+
for (Z = _2n7; Z < P && pow2(Z, legendreC, P) !== P - _1n8; Z++)
|
|
18257
18556
|
;
|
|
18258
18557
|
if (S === 1) {
|
|
18259
|
-
const p1div4 = (P +
|
|
18558
|
+
const p1div4 = (P + _1n8) / _4n3;
|
|
18260
18559
|
return function tonelliFast(Fp2, n) {
|
|
18261
18560
|
const root = Fp2.pow(n, p1div4);
|
|
18262
18561
|
if (!Fp2.eql(Fp2.sqr(root), n))
|
|
@@ -18264,7 +18563,7 @@ var starknet = (() => {
|
|
|
18264
18563
|
return root;
|
|
18265
18564
|
};
|
|
18266
18565
|
}
|
|
18267
|
-
const Q1div2 = (Q +
|
|
18566
|
+
const Q1div2 = (Q + _1n8) / _2n7;
|
|
18268
18567
|
return function tonelliSlow(Fp2, n) {
|
|
18269
18568
|
if (Fp2.pow(n, legendreC) === Fp2.neg(Fp2.ONE))
|
|
18270
18569
|
throw new Error("Cannot find square root");
|
|
@@ -18281,7 +18580,7 @@ var starknet = (() => {
|
|
|
18281
18580
|
break;
|
|
18282
18581
|
t2 = Fp2.sqr(t2);
|
|
18283
18582
|
}
|
|
18284
|
-
const ge = Fp2.pow(g2,
|
|
18583
|
+
const ge = Fp2.pow(g2, _1n8 << BigInt(r - m - 1));
|
|
18285
18584
|
g2 = Fp2.sqr(ge);
|
|
18286
18585
|
x = Fp2.mul(x, ge);
|
|
18287
18586
|
b = Fp2.mul(b, g2);
|
|
@@ -18292,7 +18591,7 @@ var starknet = (() => {
|
|
|
18292
18591
|
}
|
|
18293
18592
|
function FpSqrt2(P) {
|
|
18294
18593
|
if (P % _4n3 === _3n3) {
|
|
18295
|
-
const p1div4 = (P +
|
|
18594
|
+
const p1div4 = (P + _1n8) / _4n3;
|
|
18296
18595
|
return function sqrt3mod4(Fp2, n) {
|
|
18297
18596
|
const root = Fp2.pow(n, p1div4);
|
|
18298
18597
|
if (!Fp2.eql(Fp2.sqr(root), n))
|
|
@@ -18303,10 +18602,10 @@ var starknet = (() => {
|
|
|
18303
18602
|
if (P % _8n2 === _5n2) {
|
|
18304
18603
|
const c1 = (P - _5n2) / _8n2;
|
|
18305
18604
|
return function sqrt5mod8(Fp2, n) {
|
|
18306
|
-
const n2 = Fp2.mul(n,
|
|
18605
|
+
const n2 = Fp2.mul(n, _2n7);
|
|
18307
18606
|
const v = Fp2.pow(n2, c1);
|
|
18308
18607
|
const nv = Fp2.mul(n, v);
|
|
18309
|
-
const i = Fp2.mul(Fp2.mul(nv,
|
|
18608
|
+
const i = Fp2.mul(Fp2.mul(nv, _2n7), v);
|
|
18310
18609
|
const root = Fp2.mul(nv, Fp2.sub(i, Fp2.ONE));
|
|
18311
18610
|
if (!Fp2.eql(Fp2.sqr(root), n))
|
|
18312
18611
|
throw new Error("Cannot find square root");
|
|
@@ -18350,19 +18649,19 @@ var starknet = (() => {
|
|
|
18350
18649
|
return validateObject(field, opts);
|
|
18351
18650
|
}
|
|
18352
18651
|
function FpPow2(f, num, power) {
|
|
18353
|
-
if (power <
|
|
18652
|
+
if (power < _0n8)
|
|
18354
18653
|
throw new Error("Expected power > 0");
|
|
18355
|
-
if (power ===
|
|
18654
|
+
if (power === _0n8)
|
|
18356
18655
|
return f.ONE;
|
|
18357
|
-
if (power ===
|
|
18656
|
+
if (power === _1n8)
|
|
18358
18657
|
return num;
|
|
18359
18658
|
let p = f.ONE;
|
|
18360
18659
|
let d = num;
|
|
18361
|
-
while (power >
|
|
18362
|
-
if (power &
|
|
18660
|
+
while (power > _0n8) {
|
|
18661
|
+
if (power & _1n8)
|
|
18363
18662
|
p = f.mul(p, d);
|
|
18364
18663
|
d = f.sqr(d);
|
|
18365
|
-
power >>=
|
|
18664
|
+
power >>= _1n8;
|
|
18366
18665
|
}
|
|
18367
18666
|
return p;
|
|
18368
18667
|
}
|
|
@@ -18389,7 +18688,7 @@ var starknet = (() => {
|
|
|
18389
18688
|
return { nBitLength: _nBitLength, nByteLength };
|
|
18390
18689
|
}
|
|
18391
18690
|
function Field2(ORDER, bitLen3, isLE3 = false, redef = {}) {
|
|
18392
|
-
if (ORDER <=
|
|
18691
|
+
if (ORDER <= _0n8)
|
|
18393
18692
|
throw new Error(`Expected Field ORDER > 0, got ${ORDER}`);
|
|
18394
18693
|
const { nBitLength: BITS, nByteLength: BYTES } = nLength2(ORDER, bitLen3);
|
|
18395
18694
|
if (BYTES > 2048)
|
|
@@ -18400,16 +18699,16 @@ var starknet = (() => {
|
|
|
18400
18699
|
BITS,
|
|
18401
18700
|
BYTES,
|
|
18402
18701
|
MASK: bitMask(BITS),
|
|
18403
|
-
ZERO:
|
|
18404
|
-
ONE:
|
|
18702
|
+
ZERO: _0n8,
|
|
18703
|
+
ONE: _1n8,
|
|
18405
18704
|
create: (num) => mod2(num, ORDER),
|
|
18406
18705
|
isValid: (num) => {
|
|
18407
18706
|
if (typeof num !== "bigint")
|
|
18408
18707
|
throw new Error(`Invalid field element: expected bigint, got ${typeof num}`);
|
|
18409
|
-
return
|
|
18708
|
+
return _0n8 <= num && num < ORDER;
|
|
18410
18709
|
},
|
|
18411
|
-
is0: (num) => num ===
|
|
18412
|
-
isOdd: (num) => (num &
|
|
18710
|
+
is0: (num) => num === _0n8,
|
|
18711
|
+
isOdd: (num) => (num & _1n8) === _1n8,
|
|
18413
18712
|
neg: (num) => mod2(-num, ORDER),
|
|
18414
18713
|
eql: (lhs, rhs) => lhs === rhs,
|
|
18415
18714
|
sqr: (num) => mod2(num * num, ORDER),
|
|
@@ -18455,7 +18754,7 @@ var starknet = (() => {
|
|
|
18455
18754
|
if (len < 16 || len < minLen || len > 1024)
|
|
18456
18755
|
throw new Error(`expected ${minLen}-1024 bytes of input, got ${len}`);
|
|
18457
18756
|
const num = isLE3 ? bytesToNumberBE(key) : bytesToNumberLE(key);
|
|
18458
|
-
const reduced = mod2(num, fieldOrder -
|
|
18757
|
+
const reduced = mod2(num, fieldOrder - _1n8) + _1n8;
|
|
18459
18758
|
return isLE3 ? numberToBytesLE(reduced, fieldLen) : numberToBytesBE(reduced, fieldLen);
|
|
18460
18759
|
}
|
|
18461
18760
|
|
|
@@ -18586,8 +18885,8 @@ var starknet = (() => {
|
|
|
18586
18885
|
});
|
|
18587
18886
|
|
|
18588
18887
|
// node_modules/@noble/curves/esm/abstract/curve.js
|
|
18589
|
-
var
|
|
18590
|
-
var
|
|
18888
|
+
var _0n9 = BigInt(0);
|
|
18889
|
+
var _1n9 = BigInt(1);
|
|
18591
18890
|
function wNAF2(c, bits) {
|
|
18592
18891
|
const constTimeNegate = (condition, item) => {
|
|
18593
18892
|
const neg = item.negate();
|
|
@@ -18604,11 +18903,11 @@ var starknet = (() => {
|
|
|
18604
18903
|
unsafeLadder(elm, n) {
|
|
18605
18904
|
let p = c.ZERO;
|
|
18606
18905
|
let d = elm;
|
|
18607
|
-
while (n >
|
|
18608
|
-
if (n &
|
|
18906
|
+
while (n > _0n9) {
|
|
18907
|
+
if (n & _1n9)
|
|
18609
18908
|
p = p.add(d);
|
|
18610
18909
|
d = d.double();
|
|
18611
|
-
n >>=
|
|
18910
|
+
n >>= _1n9;
|
|
18612
18911
|
}
|
|
18613
18912
|
return p;
|
|
18614
18913
|
},
|
|
@@ -18658,7 +18957,7 @@ var starknet = (() => {
|
|
|
18658
18957
|
n >>= shiftBy;
|
|
18659
18958
|
if (wbits > windowSize) {
|
|
18660
18959
|
wbits -= maxNumber;
|
|
18661
|
-
n +=
|
|
18960
|
+
n += _1n9;
|
|
18662
18961
|
}
|
|
18663
18962
|
const offset1 = offset;
|
|
18664
18963
|
const offset2 = offset + Math.abs(wbits) - 1;
|
|
@@ -18781,9 +19080,9 @@ var starknet = (() => {
|
|
|
18781
19080
|
return `30${h(rhl + shl + 4)}02${rl}${r}02${sl}${s}`;
|
|
18782
19081
|
}
|
|
18783
19082
|
};
|
|
18784
|
-
var
|
|
18785
|
-
var
|
|
18786
|
-
var
|
|
19083
|
+
var _0n10 = BigInt(0);
|
|
19084
|
+
var _1n10 = BigInt(1);
|
|
19085
|
+
var _2n8 = BigInt(2);
|
|
18787
19086
|
var _3n4 = BigInt(3);
|
|
18788
19087
|
var _4n4 = BigInt(4);
|
|
18789
19088
|
function weierstrassPoints2(opts) {
|
|
@@ -18808,7 +19107,7 @@ var starknet = (() => {
|
|
|
18808
19107
|
if (!Fp2.eql(Fp2.sqr(CURVE2.Gy), weierstrassEquation(CURVE2.Gx)))
|
|
18809
19108
|
throw new Error("bad generator point: equation left != right");
|
|
18810
19109
|
function isWithinCurveOrder(num) {
|
|
18811
|
-
return typeof num === "bigint" &&
|
|
19110
|
+
return typeof num === "bigint" && _0n10 < num && num < CURVE2.n;
|
|
18812
19111
|
}
|
|
18813
19112
|
function assertGE(num) {
|
|
18814
19113
|
if (!isWithinCurveOrder(num))
|
|
@@ -19052,10 +19351,10 @@ var starknet = (() => {
|
|
|
19052
19351
|
*/
|
|
19053
19352
|
multiplyUnsafe(n) {
|
|
19054
19353
|
const I = Point2.ZERO;
|
|
19055
|
-
if (n ===
|
|
19354
|
+
if (n === _0n10)
|
|
19056
19355
|
return I;
|
|
19057
19356
|
assertGE(n);
|
|
19058
|
-
if (n ===
|
|
19357
|
+
if (n === _1n10)
|
|
19059
19358
|
return this;
|
|
19060
19359
|
const { endo } = CURVE2;
|
|
19061
19360
|
if (!endo)
|
|
@@ -19064,14 +19363,14 @@ var starknet = (() => {
|
|
|
19064
19363
|
let k1p = I;
|
|
19065
19364
|
let k2p = I;
|
|
19066
19365
|
let d = this;
|
|
19067
|
-
while (k1 >
|
|
19068
|
-
if (k1 &
|
|
19366
|
+
while (k1 > _0n10 || k2 > _0n10) {
|
|
19367
|
+
if (k1 & _1n10)
|
|
19069
19368
|
k1p = k1p.add(d);
|
|
19070
|
-
if (k2 &
|
|
19369
|
+
if (k2 & _1n10)
|
|
19071
19370
|
k2p = k2p.add(d);
|
|
19072
19371
|
d = d.double();
|
|
19073
|
-
k1 >>=
|
|
19074
|
-
k2 >>=
|
|
19372
|
+
k1 >>= _1n10;
|
|
19373
|
+
k2 >>= _1n10;
|
|
19075
19374
|
}
|
|
19076
19375
|
if (k1neg)
|
|
19077
19376
|
k1p = k1p.negate();
|
|
@@ -19118,7 +19417,7 @@ var starknet = (() => {
|
|
|
19118
19417
|
*/
|
|
19119
19418
|
multiplyAndAddUnsafe(Q, a, b) {
|
|
19120
19419
|
const G = Point2.BASE;
|
|
19121
|
-
const mul = (P, a2) => a2 ===
|
|
19420
|
+
const mul = (P, a2) => a2 === _0n10 || a2 === _1n10 || !P.equals(G) ? P.multiplyUnsafe(a2) : P.multiply(a2);
|
|
19122
19421
|
const sum = mul(this, a).add(mul(Q, b));
|
|
19123
19422
|
return sum.is0() ? void 0 : sum;
|
|
19124
19423
|
}
|
|
@@ -19141,7 +19440,7 @@ var starknet = (() => {
|
|
|
19141
19440
|
}
|
|
19142
19441
|
isTorsionFree() {
|
|
19143
19442
|
const { h: cofactor, isTorsionFree } = CURVE2;
|
|
19144
|
-
if (cofactor ===
|
|
19443
|
+
if (cofactor === _1n10)
|
|
19145
19444
|
return true;
|
|
19146
19445
|
if (isTorsionFree)
|
|
19147
19446
|
return isTorsionFree(Point2, this);
|
|
@@ -19149,7 +19448,7 @@ var starknet = (() => {
|
|
|
19149
19448
|
}
|
|
19150
19449
|
clearCofactor() {
|
|
19151
19450
|
const { h: cofactor, clearCofactor } = CURVE2;
|
|
19152
|
-
if (cofactor ===
|
|
19451
|
+
if (cofactor === _1n10)
|
|
19153
19452
|
return this;
|
|
19154
19453
|
if (clearCofactor)
|
|
19155
19454
|
return clearCofactor(Point2, this);
|
|
@@ -19194,7 +19493,7 @@ var starknet = (() => {
|
|
|
19194
19493
|
const compressedLen = Fp2.BYTES + 1;
|
|
19195
19494
|
const uncompressedLen = 2 * Fp2.BYTES + 1;
|
|
19196
19495
|
function isValidFieldElement(num) {
|
|
19197
|
-
return
|
|
19496
|
+
return _0n10 < num && num < Fp2.ORDER;
|
|
19198
19497
|
}
|
|
19199
19498
|
function modN(a) {
|
|
19200
19499
|
return mod2(a, CURVE_ORDER2);
|
|
@@ -19230,7 +19529,7 @@ var starknet = (() => {
|
|
|
19230
19529
|
const suffix = sqrtError instanceof Error ? ": " + sqrtError.message : "";
|
|
19231
19530
|
throw new Error("Point is not on curve" + suffix);
|
|
19232
19531
|
}
|
|
19233
|
-
const isYOdd = (y &
|
|
19532
|
+
const isYOdd = (y & _1n10) === _1n10;
|
|
19234
19533
|
const isHeadOdd = (head & 1) === 1;
|
|
19235
19534
|
if (isHeadOdd !== isYOdd)
|
|
19236
19535
|
y = Fp2.neg(y);
|
|
@@ -19246,7 +19545,7 @@ var starknet = (() => {
|
|
|
19246
19545
|
});
|
|
19247
19546
|
const numToNByteStr = (num) => bytesToHex(numberToBytesBE(num, CURVE2.nByteLength));
|
|
19248
19547
|
function isBiggerThanHalfOrder(number4) {
|
|
19249
|
-
const HALF = CURVE_ORDER2 >>
|
|
19548
|
+
const HALF = CURVE_ORDER2 >> _1n10;
|
|
19250
19549
|
return number4 > HALF;
|
|
19251
19550
|
}
|
|
19252
19551
|
function normalizeS(s) {
|
|
@@ -19389,7 +19688,7 @@ var starknet = (() => {
|
|
|
19389
19688
|
function int2octets(num) {
|
|
19390
19689
|
if (typeof num !== "bigint")
|
|
19391
19690
|
throw new Error("bigint expected");
|
|
19392
|
-
if (!(
|
|
19691
|
+
if (!(_0n10 <= num && num < ORDER_MASK))
|
|
19393
19692
|
throw new Error(`bigint expected < 2^${CURVE2.nBitLength}`);
|
|
19394
19693
|
return numberToBytesBE(num, CURVE2.nByteLength);
|
|
19395
19694
|
}
|
|
@@ -19419,12 +19718,12 @@ var starknet = (() => {
|
|
|
19419
19718
|
const ik = invN(k);
|
|
19420
19719
|
const q = Point2.BASE.multiply(k).toAffine();
|
|
19421
19720
|
const r = modN(q.x);
|
|
19422
|
-
if (r ===
|
|
19721
|
+
if (r === _0n10)
|
|
19423
19722
|
return;
|
|
19424
19723
|
const s = modN(ik * modN(m + r * d));
|
|
19425
|
-
if (s ===
|
|
19724
|
+
if (s === _0n10)
|
|
19426
19725
|
return;
|
|
19427
|
-
let recovery = (q.x === r ? 0 : 2) | Number(q.y &
|
|
19726
|
+
let recovery = (q.x === r ? 0 : 2) | Number(q.y & _1n10);
|
|
19428
19727
|
let normS = s;
|
|
19429
19728
|
if (lowS && isBiggerThanHalfOrder(s)) {
|
|
19430
19729
|
normS = normalizeS(s);
|
|
@@ -19501,18 +19800,18 @@ var starknet = (() => {
|
|
|
19501
19800
|
}
|
|
19502
19801
|
function SWUFpSqrtRatio(Fp2, Z) {
|
|
19503
19802
|
const q = Fp2.ORDER;
|
|
19504
|
-
let l =
|
|
19505
|
-
for (let o = q -
|
|
19506
|
-
l +=
|
|
19803
|
+
let l = _0n10;
|
|
19804
|
+
for (let o = q - _1n10; o % _2n8 === _0n10; o /= _2n8)
|
|
19805
|
+
l += _1n10;
|
|
19507
19806
|
const c1 = l;
|
|
19508
|
-
const _2n_pow_c1_1 =
|
|
19509
|
-
const _2n_pow_c1 = _2n_pow_c1_1 *
|
|
19510
|
-
const c2 = (q -
|
|
19511
|
-
const c3 = (c2 -
|
|
19512
|
-
const c4 = _2n_pow_c1 -
|
|
19807
|
+
const _2n_pow_c1_1 = _2n8 << c1 - _1n10 - _1n10;
|
|
19808
|
+
const _2n_pow_c1 = _2n_pow_c1_1 * _2n8;
|
|
19809
|
+
const c2 = (q - _1n10) / _2n_pow_c1;
|
|
19810
|
+
const c3 = (c2 - _1n10) / _2n8;
|
|
19811
|
+
const c4 = _2n_pow_c1 - _1n10;
|
|
19513
19812
|
const c5 = _2n_pow_c1_1;
|
|
19514
19813
|
const c6 = Fp2.pow(Z, c2);
|
|
19515
|
-
const c7 = Fp2.pow(Z, (c2 +
|
|
19814
|
+
const c7 = Fp2.pow(Z, (c2 + _1n10) / _2n8);
|
|
19516
19815
|
let sqrtRatio = (u, v) => {
|
|
19517
19816
|
let tv1 = c6;
|
|
19518
19817
|
let tv2 = Fp2.pow(v, c4);
|
|
@@ -19530,9 +19829,9 @@ var starknet = (() => {
|
|
|
19530
19829
|
tv5 = Fp2.mul(tv4, tv1);
|
|
19531
19830
|
tv3 = Fp2.cmov(tv2, tv3, isQR);
|
|
19532
19831
|
tv4 = Fp2.cmov(tv5, tv4, isQR);
|
|
19533
|
-
for (let i = c1; i >
|
|
19534
|
-
let tv52 = i -
|
|
19535
|
-
tv52 =
|
|
19832
|
+
for (let i = c1; i > _1n10; i--) {
|
|
19833
|
+
let tv52 = i - _2n8;
|
|
19834
|
+
tv52 = _2n8 << tv52 - _1n10;
|
|
19536
19835
|
let tvv5 = Fp2.pow(tv4, tv52);
|
|
19537
19836
|
const e1 = Fp2.eql(tvv5, Fp2.ONE);
|
|
19538
19837
|
tv2 = Fp2.mul(tv3, tv1);
|
|
@@ -24888,102 +25187,13 @@ var starknet = (() => {
|
|
|
24888
25187
|
validateAndParseEthAddress: () => validateAndParseEthAddress
|
|
24889
25188
|
});
|
|
24890
25189
|
|
|
24891
|
-
// node_modules/@noble/
|
|
24892
|
-
function number2(n) {
|
|
24893
|
-
if (!Number.isSafeInteger(n) || n < 0)
|
|
24894
|
-
throw new Error(`positive integer expected, not ${n}`);
|
|
24895
|
-
}
|
|
24896
|
-
function isBytes6(a) {
|
|
24897
|
-
return a instanceof Uint8Array || a != null && typeof a === "object" && a.constructor.name === "Uint8Array";
|
|
24898
|
-
}
|
|
24899
|
-
function bytes2(b, ...lengths) {
|
|
24900
|
-
if (!isBytes6(b))
|
|
24901
|
-
throw new Error("Uint8Array expected");
|
|
24902
|
-
if (lengths.length > 0 && !lengths.includes(b.length))
|
|
24903
|
-
throw new Error(`Uint8Array expected of length ${lengths}, not of length=${b.length}`);
|
|
24904
|
-
}
|
|
24905
|
-
function hash2(h) {
|
|
24906
|
-
if (typeof h !== "function" || typeof h.create !== "function")
|
|
24907
|
-
throw new Error("Hash should be wrapped by utils.wrapConstructor");
|
|
24908
|
-
number2(h.outputLen);
|
|
24909
|
-
number2(h.blockLen);
|
|
24910
|
-
}
|
|
24911
|
-
function exists2(instance, checkFinished = true) {
|
|
24912
|
-
if (instance.destroyed)
|
|
24913
|
-
throw new Error("Hash instance has been destroyed");
|
|
24914
|
-
if (checkFinished && instance.finished)
|
|
24915
|
-
throw new Error("Hash#digest() has already been called");
|
|
24916
|
-
}
|
|
24917
|
-
function output2(out, instance) {
|
|
24918
|
-
bytes2(out);
|
|
24919
|
-
const min = instance.outputLen;
|
|
24920
|
-
if (out.length < min) {
|
|
24921
|
-
throw new Error(`digestInto() expects output buffer of length at least ${min}`);
|
|
24922
|
-
}
|
|
24923
|
-
}
|
|
24924
|
-
|
|
24925
|
-
// node_modules/@noble/curves/node_modules/@noble/hashes/esm/crypto.js
|
|
24926
|
-
var crypto2 = typeof globalThis === "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
|
|
24927
|
-
|
|
24928
|
-
// node_modules/@noble/curves/node_modules/@noble/hashes/esm/utils.js
|
|
24929
|
-
var createView2 = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
24930
|
-
var rotr2 = (word, shift) => word << 32 - shift | word >>> shift;
|
|
24931
|
-
var isLE2 = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
24932
|
-
function utf8ToBytes4(str) {
|
|
24933
|
-
if (typeof str !== "string")
|
|
24934
|
-
throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
|
|
24935
|
-
return new Uint8Array(new TextEncoder().encode(str));
|
|
24936
|
-
}
|
|
24937
|
-
function toBytes2(data) {
|
|
24938
|
-
if (typeof data === "string")
|
|
24939
|
-
data = utf8ToBytes4(data);
|
|
24940
|
-
bytes2(data);
|
|
24941
|
-
return data;
|
|
24942
|
-
}
|
|
24943
|
-
function concatBytes4(...arrays) {
|
|
24944
|
-
let sum = 0;
|
|
24945
|
-
for (let i = 0; i < arrays.length; i++) {
|
|
24946
|
-
const a = arrays[i];
|
|
24947
|
-
bytes2(a);
|
|
24948
|
-
sum += a.length;
|
|
24949
|
-
}
|
|
24950
|
-
const res = new Uint8Array(sum);
|
|
24951
|
-
for (let i = 0, pad = 0; i < arrays.length; i++) {
|
|
24952
|
-
const a = arrays[i];
|
|
24953
|
-
res.set(a, pad);
|
|
24954
|
-
pad += a.length;
|
|
24955
|
-
}
|
|
24956
|
-
return res;
|
|
24957
|
-
}
|
|
24958
|
-
var Hash2 = class {
|
|
24959
|
-
// Safe version that clones internal state
|
|
24960
|
-
clone() {
|
|
24961
|
-
return this._cloneInto();
|
|
24962
|
-
}
|
|
24963
|
-
};
|
|
24964
|
-
var toStr2 = {}.toString;
|
|
24965
|
-
function wrapConstructor2(hashCons) {
|
|
24966
|
-
const hashC = (msg) => hashCons().update(toBytes2(msg)).digest();
|
|
24967
|
-
const tmp = hashCons();
|
|
24968
|
-
hashC.outputLen = tmp.outputLen;
|
|
24969
|
-
hashC.blockLen = tmp.blockLen;
|
|
24970
|
-
hashC.create = () => hashCons();
|
|
24971
|
-
return hashC;
|
|
24972
|
-
}
|
|
24973
|
-
function randomBytes2(bytesLength = 32) {
|
|
24974
|
-
if (crypto2 && typeof crypto2.getRandomValues === "function") {
|
|
24975
|
-
return crypto2.getRandomValues(new Uint8Array(bytesLength));
|
|
24976
|
-
}
|
|
24977
|
-
throw new Error("crypto.getRandomValues must be defined");
|
|
24978
|
-
}
|
|
24979
|
-
|
|
24980
|
-
// node_modules/@noble/curves/node_modules/@noble/hashes/esm/_md.js
|
|
25190
|
+
// node_modules/@noble/hashes/esm/_md.js
|
|
24981
25191
|
function setBigUint642(view, byteOffset, value, isLE3) {
|
|
24982
25192
|
if (typeof view.setBigUint64 === "function")
|
|
24983
25193
|
return view.setBigUint64(byteOffset, value, isLE3);
|
|
24984
|
-
const
|
|
25194
|
+
const _32n3 = BigInt(32);
|
|
24985
25195
|
const _u32_max = BigInt(4294967295);
|
|
24986
|
-
const wh = Number(value >>
|
|
25196
|
+
const wh = Number(value >> _32n3 & _u32_max);
|
|
24987
25197
|
const wl = Number(value & _u32_max);
|
|
24988
25198
|
const h = isLE3 ? 4 : 0;
|
|
24989
25199
|
const l = isLE3 ? 0 : 4;
|
|
@@ -24992,7 +25202,7 @@ var starknet = (() => {
|
|
|
24992
25202
|
}
|
|
24993
25203
|
var Chi2 = (a, b, c) => a & b ^ ~a & c;
|
|
24994
25204
|
var Maj2 = (a, b, c) => a & b ^ a & c ^ b & c;
|
|
24995
|
-
var HashMD = class extends
|
|
25205
|
+
var HashMD = class extends Hash {
|
|
24996
25206
|
constructor(blockLen, outputLen, padOffset, isLE3) {
|
|
24997
25207
|
super();
|
|
24998
25208
|
this.blockLen = blockLen;
|
|
@@ -25004,17 +25214,17 @@ var starknet = (() => {
|
|
|
25004
25214
|
this.pos = 0;
|
|
25005
25215
|
this.destroyed = false;
|
|
25006
25216
|
this.buffer = new Uint8Array(blockLen);
|
|
25007
|
-
this.view =
|
|
25217
|
+
this.view = createView(this.buffer);
|
|
25008
25218
|
}
|
|
25009
25219
|
update(data) {
|
|
25010
|
-
|
|
25220
|
+
exists(this);
|
|
25011
25221
|
const { view, buffer, blockLen } = this;
|
|
25012
|
-
data =
|
|
25222
|
+
data = toBytes(data);
|
|
25013
25223
|
const len = data.length;
|
|
25014
25224
|
for (let pos = 0; pos < len; ) {
|
|
25015
25225
|
const take = Math.min(blockLen - this.pos, len - pos);
|
|
25016
25226
|
if (take === blockLen) {
|
|
25017
|
-
const dataView =
|
|
25227
|
+
const dataView = createView(data);
|
|
25018
25228
|
for (; blockLen <= len - pos; pos += blockLen)
|
|
25019
25229
|
this.process(dataView, pos);
|
|
25020
25230
|
continue;
|
|
@@ -25032,8 +25242,8 @@ var starknet = (() => {
|
|
|
25032
25242
|
return this;
|
|
25033
25243
|
}
|
|
25034
25244
|
digestInto(out) {
|
|
25035
|
-
|
|
25036
|
-
|
|
25245
|
+
exists(this);
|
|
25246
|
+
output(out, this);
|
|
25037
25247
|
this.finished = true;
|
|
25038
25248
|
const { buffer, view, blockLen, isLE: isLE3 } = this;
|
|
25039
25249
|
let { pos } = this;
|
|
@@ -25047,7 +25257,7 @@ var starknet = (() => {
|
|
|
25047
25257
|
buffer[i] = 0;
|
|
25048
25258
|
setBigUint642(view, blockLen - 8, BigInt(this.length * 8), isLE3);
|
|
25049
25259
|
this.process(view, 0);
|
|
25050
|
-
const oview =
|
|
25260
|
+
const oview = createView(out);
|
|
25051
25261
|
const len = this.outputLen;
|
|
25052
25262
|
if (len % 4)
|
|
25053
25263
|
throw new Error("_sha2: outputLen should be aligned to 32bit");
|
|
@@ -25079,7 +25289,7 @@ var starknet = (() => {
|
|
|
25079
25289
|
}
|
|
25080
25290
|
};
|
|
25081
25291
|
|
|
25082
|
-
// node_modules/@noble/
|
|
25292
|
+
// node_modules/@noble/hashes/esm/sha256.js
|
|
25083
25293
|
var SHA256_K2 = /* @__PURE__ */ new Uint32Array([
|
|
25084
25294
|
1116352408,
|
|
25085
25295
|
1899447441,
|
|
@@ -25190,15 +25400,15 @@ var starknet = (() => {
|
|
|
25190
25400
|
for (let i = 16; i < 64; i++) {
|
|
25191
25401
|
const W15 = SHA256_W2[i - 15];
|
|
25192
25402
|
const W2 = SHA256_W2[i - 2];
|
|
25193
|
-
const s0 =
|
|
25194
|
-
const s1 =
|
|
25403
|
+
const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ W15 >>> 3;
|
|
25404
|
+
const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ W2 >>> 10;
|
|
25195
25405
|
SHA256_W2[i] = s1 + SHA256_W2[i - 7] + s0 + SHA256_W2[i - 16] | 0;
|
|
25196
25406
|
}
|
|
25197
25407
|
let { A, B, C, D, E, F, G, H } = this;
|
|
25198
25408
|
for (let i = 0; i < 64; i++) {
|
|
25199
|
-
const sigma1 =
|
|
25409
|
+
const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
|
|
25200
25410
|
const T1 = H + sigma1 + Chi2(E, F, G) + SHA256_K2[i] + SHA256_W2[i] | 0;
|
|
25201
|
-
const sigma0 =
|
|
25411
|
+
const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);
|
|
25202
25412
|
const T2 = sigma0 + Maj2(A, B, C) | 0;
|
|
25203
25413
|
H = G;
|
|
25204
25414
|
G = F;
|
|
@@ -25227,16 +25437,16 @@ var starknet = (() => {
|
|
|
25227
25437
|
this.buffer.fill(0);
|
|
25228
25438
|
}
|
|
25229
25439
|
};
|
|
25230
|
-
var sha2562 = /* @__PURE__ */
|
|
25440
|
+
var sha2562 = /* @__PURE__ */ wrapConstructor(() => new SHA2562());
|
|
25231
25441
|
|
|
25232
|
-
// node_modules/@noble/
|
|
25233
|
-
var HMAC2 = class extends
|
|
25442
|
+
// node_modules/@noble/hashes/esm/hmac.js
|
|
25443
|
+
var HMAC2 = class extends Hash {
|
|
25234
25444
|
constructor(hash3, _key) {
|
|
25235
25445
|
super();
|
|
25236
25446
|
this.finished = false;
|
|
25237
25447
|
this.destroyed = false;
|
|
25238
|
-
|
|
25239
|
-
const key =
|
|
25448
|
+
hash(hash3);
|
|
25449
|
+
const key = toBytes(_key);
|
|
25240
25450
|
this.iHash = hash3.create();
|
|
25241
25451
|
if (typeof this.iHash.update !== "function")
|
|
25242
25452
|
throw new Error("Expected instance of class which extends utils.Hash");
|
|
@@ -25255,13 +25465,13 @@ var starknet = (() => {
|
|
|
25255
25465
|
pad.fill(0);
|
|
25256
25466
|
}
|
|
25257
25467
|
update(buf) {
|
|
25258
|
-
|
|
25468
|
+
exists(this);
|
|
25259
25469
|
this.iHash.update(buf);
|
|
25260
25470
|
return this;
|
|
25261
25471
|
}
|
|
25262
25472
|
digestInto(out) {
|
|
25263
|
-
|
|
25264
|
-
|
|
25473
|
+
exists(this);
|
|
25474
|
+
bytes(out, this.outputLen);
|
|
25265
25475
|
this.finished = true;
|
|
25266
25476
|
this.iHash.digestInto(out);
|
|
25267
25477
|
this.oHash.update(out);
|
|
@@ -25298,8 +25508,8 @@ var starknet = (() => {
|
|
|
25298
25508
|
function getHash2(hash3) {
|
|
25299
25509
|
return {
|
|
25300
25510
|
hash: hash3,
|
|
25301
|
-
hmac: (key, ...msgs) => hmac2(hash3, key,
|
|
25302
|
-
randomBytes
|
|
25511
|
+
hmac: (key, ...msgs) => hmac2(hash3, key, concatBytes2(...msgs)),
|
|
25512
|
+
randomBytes
|
|
25303
25513
|
};
|
|
25304
25514
|
}
|
|
25305
25515
|
function createCurve(curveDef, defHash) {
|
|
@@ -25310,9 +25520,9 @@ var starknet = (() => {
|
|
|
25310
25520
|
// node_modules/@noble/curves/esm/secp256k1.js
|
|
25311
25521
|
var secp256k1P = BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f");
|
|
25312
25522
|
var secp256k1N = BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141");
|
|
25313
|
-
var
|
|
25314
|
-
var
|
|
25315
|
-
var divNearest = (a, b) => (a + b /
|
|
25523
|
+
var _1n11 = BigInt(1);
|
|
25524
|
+
var _2n9 = BigInt(2);
|
|
25525
|
+
var divNearest = (a, b) => (a + b / _2n9) / b;
|
|
25316
25526
|
function sqrtMod(y) {
|
|
25317
25527
|
const P = secp256k1P;
|
|
25318
25528
|
const _3n5 = BigInt(3), _6n = BigInt(6), _11n = BigInt(11), _22n = BigInt(22);
|
|
@@ -25321,7 +25531,7 @@ var starknet = (() => {
|
|
|
25321
25531
|
const b3 = b2 * b2 * y % P;
|
|
25322
25532
|
const b6 = pow22(b3, _3n5, P) * b3 % P;
|
|
25323
25533
|
const b9 = pow22(b6, _3n5, P) * b3 % P;
|
|
25324
|
-
const b11 = pow22(b9,
|
|
25534
|
+
const b11 = pow22(b9, _2n9, P) * b2 % P;
|
|
25325
25535
|
const b22 = pow22(b11, _11n, P) * b11 % P;
|
|
25326
25536
|
const b44 = pow22(b22, _22n, P) * b22 % P;
|
|
25327
25537
|
const b88 = pow22(b44, _44n, P) * b44 % P;
|
|
@@ -25330,7 +25540,7 @@ var starknet = (() => {
|
|
|
25330
25540
|
const b223 = pow22(b220, _3n5, P) * b3 % P;
|
|
25331
25541
|
const t1 = pow22(b223, _23n, P) * b22 % P;
|
|
25332
25542
|
const t2 = pow22(t1, _6n, P) * b2 % P;
|
|
25333
|
-
const root = pow22(t2,
|
|
25543
|
+
const root = pow22(t2, _2n9, P);
|
|
25334
25544
|
if (!Fp.eql(Fp.sqr(root), y))
|
|
25335
25545
|
throw new Error("Cannot find square root");
|
|
25336
25546
|
return root;
|
|
@@ -25363,7 +25573,7 @@ var starknet = (() => {
|
|
|
25363
25573
|
splitScalar: (k) => {
|
|
25364
25574
|
const n = secp256k1N;
|
|
25365
25575
|
const a1 = BigInt("0x3086d221a7d46bcde86c90e49284eb15");
|
|
25366
|
-
const b1 = -
|
|
25576
|
+
const b1 = -_1n11 * BigInt("0xe4437ed6010e88286f547fa90abfe4c3");
|
|
25367
25577
|
const a2 = BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8");
|
|
25368
25578
|
const b2 = a1;
|
|
25369
25579
|
const POW_2_128 = BigInt("0x100000000000000000000000000000000");
|
|
@@ -25384,7 +25594,7 @@ var starknet = (() => {
|
|
|
25384
25594
|
}
|
|
25385
25595
|
}
|
|
25386
25596
|
}, sha2562);
|
|
25387
|
-
var
|
|
25597
|
+
var _0n11 = BigInt(0);
|
|
25388
25598
|
var Point = secp256k1.ProjectivePoint;
|
|
25389
25599
|
|
|
25390
25600
|
// src/utils/eth.ts
|
|
@@ -25394,7 +25604,7 @@ var starknet = (() => {
|
|
|
25394
25604
|
function validateAndParseEthAddress(address) {
|
|
25395
25605
|
assertInRange(address, ZERO, 2n ** 160n - 1n, "Ethereum Address ");
|
|
25396
25606
|
const result = addHexPrefix(removeHexPrefix(toHex(address)).padStart(40, "0"));
|
|
25397
|
-
assert(result.match(/^(0x)?[0-9a-f]{40}$/), "Invalid Ethereum Address Format");
|
|
25607
|
+
assert(Boolean(result.match(/^(0x)?[0-9a-f]{40}$/)), "Invalid Ethereum Address Format");
|
|
25398
25608
|
return result;
|
|
25399
25609
|
}
|
|
25400
25610
|
|
|
@@ -25961,11 +26171,12 @@ var starknet = (() => {
|
|
|
25961
26171
|
* - skipValidate (default false)<br/>
|
|
25962
26172
|
* - skipFeeCharge (default true)<br/>
|
|
25963
26173
|
*/
|
|
25964
|
-
simulateTransaction(invocations, {
|
|
25965
|
-
|
|
25966
|
-
|
|
25967
|
-
|
|
25968
|
-
|
|
26174
|
+
simulateTransaction(invocations, simulateTransactionOptions = {}) {
|
|
26175
|
+
const {
|
|
26176
|
+
blockIdentifier = this.blockIdentifier,
|
|
26177
|
+
skipValidate = true,
|
|
26178
|
+
skipFeeCharge = true
|
|
26179
|
+
} = simulateTransactionOptions;
|
|
25969
26180
|
const block_id = new Block(blockIdentifier).identifier;
|
|
25970
26181
|
const simulationFlags = [];
|
|
25971
26182
|
if (skipValidate)
|
|
@@ -26350,10 +26561,20 @@ var starknet = (() => {
|
|
|
26350
26561
|
blockIdentifier;
|
|
26351
26562
|
chainId;
|
|
26352
26563
|
specVersion;
|
|
26564
|
+
transactionRetryIntervalFallback;
|
|
26353
26565
|
waitMode;
|
|
26354
26566
|
// behave like web2 rpc and return when tx is processed
|
|
26355
26567
|
constructor(optionsOrProvider) {
|
|
26356
|
-
const {
|
|
26568
|
+
const {
|
|
26569
|
+
nodeUrl,
|
|
26570
|
+
retries,
|
|
26571
|
+
headers,
|
|
26572
|
+
blockIdentifier,
|
|
26573
|
+
chainId,
|
|
26574
|
+
specVersion,
|
|
26575
|
+
waitMode,
|
|
26576
|
+
transactionRetryIntervalFallback
|
|
26577
|
+
} = optionsOrProvider || {};
|
|
26357
26578
|
if (Object.values(NetworkName).includes(nodeUrl)) {
|
|
26358
26579
|
this.nodeUrl = getDefaultNodeUrl(nodeUrl, optionsOrProvider?.default);
|
|
26359
26580
|
} else if (nodeUrl) {
|
|
@@ -26368,6 +26589,10 @@ var starknet = (() => {
|
|
|
26368
26589
|
this.specVersion = specVersion;
|
|
26369
26590
|
this.waitMode = waitMode || false;
|
|
26370
26591
|
this.requestId = 0;
|
|
26592
|
+
this.transactionRetryIntervalFallback = transactionRetryIntervalFallback;
|
|
26593
|
+
}
|
|
26594
|
+
get transactionRetryIntervalDefault() {
|
|
26595
|
+
return this.transactionRetryIntervalFallback ?? 5e3;
|
|
26371
26596
|
}
|
|
26372
26597
|
setChainId(chainId) {
|
|
26373
26598
|
this.chainId = chainId;
|
|
@@ -26498,11 +26723,12 @@ var starknet = (() => {
|
|
|
26498
26723
|
* - skipValidate (default false)<br/>
|
|
26499
26724
|
* - skipFeeCharge (default true)<br/>
|
|
26500
26725
|
*/
|
|
26501
|
-
simulateTransaction(invocations, {
|
|
26502
|
-
|
|
26503
|
-
|
|
26504
|
-
|
|
26505
|
-
|
|
26726
|
+
simulateTransaction(invocations, simulateTransactionOptions = {}) {
|
|
26727
|
+
const {
|
|
26728
|
+
blockIdentifier = this.blockIdentifier,
|
|
26729
|
+
skipValidate = true,
|
|
26730
|
+
skipFeeCharge = true
|
|
26731
|
+
} = simulateTransactionOptions;
|
|
26506
26732
|
const block_id = new Block(blockIdentifier).identifier;
|
|
26507
26733
|
const simulationFlags = [];
|
|
26508
26734
|
if (skipValidate)
|
|
@@ -26520,7 +26746,7 @@ var starknet = (() => {
|
|
|
26520
26746
|
let { retries } = this;
|
|
26521
26747
|
let onchain = false;
|
|
26522
26748
|
let isErrorState = false;
|
|
26523
|
-
const retryInterval = options?.retryInterval ??
|
|
26749
|
+
const retryInterval = options?.retryInterval ?? this.transactionRetryIntervalDefault;
|
|
26524
26750
|
const errorStates = options?.errorStates ?? [
|
|
26525
26751
|
esm_exports.ETransactionStatus.REJECTED
|
|
26526
26752
|
// TODO: commented out to preserve the long-standing behavior of "reverted" not being treated as an error by default
|
|
@@ -27041,9 +27267,63 @@ var starknet = (() => {
|
|
|
27041
27267
|
async getBlockWithTxs(blockIdentifier) {
|
|
27042
27268
|
return this.channel.getBlockWithTxs(blockIdentifier);
|
|
27043
27269
|
}
|
|
27270
|
+
/**
|
|
27271
|
+
* Pause the execution of the script until a specified block is created.
|
|
27272
|
+
* @param {BlockIdentifier} blockIdentifier bloc number (BigNumberisk) or 'pending' or 'latest'.
|
|
27273
|
+
* Use of 'latest" or of a block already created will generate no pause.
|
|
27274
|
+
* @param {number} [retryInterval] number of milliseconds between 2 requests to the node
|
|
27275
|
+
* @example
|
|
27276
|
+
* ```typescript
|
|
27277
|
+
* await myProvider.waitForBlock();
|
|
27278
|
+
* // wait the creation of the pending block
|
|
27279
|
+
* ```
|
|
27280
|
+
*/
|
|
27281
|
+
async waitForBlock(blockIdentifier = "pending", retryInterval = 5e3) {
|
|
27282
|
+
if (blockIdentifier === "latest" /* latest */)
|
|
27283
|
+
return;
|
|
27284
|
+
const currentBlock = await this.getBlockNumber();
|
|
27285
|
+
const targetBlock = blockIdentifier === "pending" /* pending */ ? currentBlock + 1 : Number(toHex(blockIdentifier));
|
|
27286
|
+
if (targetBlock <= currentBlock)
|
|
27287
|
+
return;
|
|
27288
|
+
const { retries } = this.channel;
|
|
27289
|
+
let retriesCount = retries;
|
|
27290
|
+
let isTargetBlock = false;
|
|
27291
|
+
while (!isTargetBlock) {
|
|
27292
|
+
const currBlock = await this.getBlockNumber();
|
|
27293
|
+
if (currBlock === targetBlock) {
|
|
27294
|
+
isTargetBlock = true;
|
|
27295
|
+
} else {
|
|
27296
|
+
await wait(retryInterval);
|
|
27297
|
+
}
|
|
27298
|
+
retriesCount -= 1;
|
|
27299
|
+
if (retriesCount <= 0) {
|
|
27300
|
+
throw new Error(`waitForBlock() timed-out after ${retries} tries.`);
|
|
27301
|
+
}
|
|
27302
|
+
}
|
|
27303
|
+
}
|
|
27044
27304
|
async getL1GasPrice(blockIdentifier) {
|
|
27045
27305
|
return this.channel.getBlockWithTxHashes(blockIdentifier).then(this.responseParser.parseL1GasPriceResponse);
|
|
27046
27306
|
}
|
|
27307
|
+
async getL1MessageHash(l2TxHash) {
|
|
27308
|
+
const transaction = await this.channel.getTransactionByHash(l2TxHash);
|
|
27309
|
+
assert(transaction.type === "L1_HANDLER", "This L2 transaction is not a L1 message.");
|
|
27310
|
+
const { calldata, contract_address, entry_point_selector, nonce } = transaction;
|
|
27311
|
+
const params = [
|
|
27312
|
+
calldata[0],
|
|
27313
|
+
contract_address,
|
|
27314
|
+
nonce,
|
|
27315
|
+
entry_point_selector,
|
|
27316
|
+
calldata.length - 1,
|
|
27317
|
+
...calldata.slice(1)
|
|
27318
|
+
];
|
|
27319
|
+
const myEncode = addHexPrefix(
|
|
27320
|
+
params.reduce(
|
|
27321
|
+
(res, par) => res + removeHexPrefix(toHex(par)).padStart(64, "0"),
|
|
27322
|
+
""
|
|
27323
|
+
)
|
|
27324
|
+
);
|
|
27325
|
+
return addHexPrefix(bytesToHex(keccak_256(hexToBytes2(myEncode))));
|
|
27326
|
+
}
|
|
27047
27327
|
async getBlockWithReceipts(blockIdentifier) {
|
|
27048
27328
|
if (this.channel instanceof rpc_0_6_exports.RpcChannel)
|
|
27049
27329
|
throw new LibraryError("Unsupported method for RPC version");
|
|
@@ -27095,7 +27375,7 @@ var starknet = (() => {
|
|
|
27095
27375
|
}
|
|
27096
27376
|
/**
|
|
27097
27377
|
* @param invocations AccountInvocations
|
|
27098
|
-
* @param
|
|
27378
|
+
* @param options blockIdentifier and flags to skip validation and fee charge<br/>
|
|
27099
27379
|
* - blockIdentifier<br/>
|
|
27100
27380
|
* - skipValidate (default false)<br/>
|
|
27101
27381
|
* - skipFeeCharge (default true)<br/>
|
|
@@ -27557,7 +27837,6 @@ var starknet = (() => {
|
|
|
27557
27837
|
}
|
|
27558
27838
|
var StarknetIdContract = /* @__PURE__ */ ((StarknetIdContract2) => {
|
|
27559
27839
|
StarknetIdContract2["MAINNET"] = "0x6ac597f8116f886fa1c97a23fa4e08299975ecaf6b598873ca6792b9bbfb678";
|
|
27560
|
-
StarknetIdContract2["TESTNET"] = "0x3bab268e932d2cecd1946f100ae67ce3dff9fd234119ea2f6da57d16d29fce";
|
|
27561
27840
|
StarknetIdContract2["TESTNET_SEPOLIA"] = "0x0707f09bc576bd7cfee59694846291047e965f4184fe13dac62c56759b3b6fa7";
|
|
27562
27841
|
return StarknetIdContract2;
|
|
27563
27842
|
})(StarknetIdContract || {});
|
|
@@ -27565,8 +27844,6 @@ var starknet = (() => {
|
|
|
27565
27844
|
switch (chainId) {
|
|
27566
27845
|
case "0x534e5f4d41494e" /* SN_MAIN */:
|
|
27567
27846
|
return "0x6ac597f8116f886fa1c97a23fa4e08299975ecaf6b598873ca6792b9bbfb678" /* MAINNET */;
|
|
27568
|
-
case "0x534e5f474f45524c49" /* SN_GOERLI */:
|
|
27569
|
-
return "0x3bab268e932d2cecd1946f100ae67ce3dff9fd234119ea2f6da57d16d29fce" /* TESTNET */;
|
|
27570
27847
|
case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
|
|
27571
27848
|
return "0x0707f09bc576bd7cfee59694846291047e965f4184fe13dac62c56759b3b6fa7" /* TESTNET_SEPOLIA */;
|
|
27572
27849
|
default:
|
|
@@ -27575,7 +27852,6 @@ var starknet = (() => {
|
|
|
27575
27852
|
}
|
|
27576
27853
|
var StarknetIdIdentityContract = /* @__PURE__ */ ((StarknetIdIdentityContract2) => {
|
|
27577
27854
|
StarknetIdIdentityContract2["MAINNET"] = "0x05dbdedc203e92749e2e746e2d40a768d966bd243df04a6b712e222bc040a9af";
|
|
27578
|
-
StarknetIdIdentityContract2["TESTNET"] = "0x783a9097b26eae0586373b2ce0ed3529ddc44069d1e0fbc4f66d42b69d6850d";
|
|
27579
27855
|
StarknetIdIdentityContract2["TESTNET_SEPOLIA"] = "0x070DF8B4F5cb2879f8592849fA8f3134da39d25326B8558cc9C8FE8D47EA3A90";
|
|
27580
27856
|
return StarknetIdIdentityContract2;
|
|
27581
27857
|
})(StarknetIdIdentityContract || {});
|
|
@@ -27583,8 +27859,6 @@ var starknet = (() => {
|
|
|
27583
27859
|
switch (chainId) {
|
|
27584
27860
|
case "0x534e5f4d41494e" /* SN_MAIN */:
|
|
27585
27861
|
return "0x05dbdedc203e92749e2e746e2d40a768d966bd243df04a6b712e222bc040a9af" /* MAINNET */;
|
|
27586
|
-
case "0x534e5f474f45524c49" /* SN_GOERLI */:
|
|
27587
|
-
return "0x783a9097b26eae0586373b2ce0ed3529ddc44069d1e0fbc4f66d42b69d6850d" /* TESTNET */;
|
|
27588
27862
|
case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
|
|
27589
27863
|
return "0x070DF8B4F5cb2879f8592849fA8f3134da39d25326B8558cc9C8FE8D47EA3A90" /* TESTNET_SEPOLIA */;
|
|
27590
27864
|
default:
|
|
@@ -27596,8 +27870,6 @@ var starknet = (() => {
|
|
|
27596
27870
|
switch (chainId) {
|
|
27597
27871
|
case "0x534e5f4d41494e" /* SN_MAIN */:
|
|
27598
27872
|
return StarknetIdMulticallContract;
|
|
27599
|
-
case "0x534e5f474f45524c49" /* SN_GOERLI */:
|
|
27600
|
-
return StarknetIdMulticallContract;
|
|
27601
27873
|
case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
|
|
27602
27874
|
return StarknetIdMulticallContract;
|
|
27603
27875
|
default:
|
|
@@ -27606,7 +27878,6 @@ var starknet = (() => {
|
|
|
27606
27878
|
}
|
|
27607
27879
|
var StarknetIdVerifierContract = /* @__PURE__ */ ((StarknetIdVerifierContract2) => {
|
|
27608
27880
|
StarknetIdVerifierContract2["MAINNET"] = "0x07d14dfd8ee95b41fce179170d88ba1f0d5a512e13aeb232f19cfeec0a88f8bf";
|
|
27609
|
-
StarknetIdVerifierContract2["TESTNET"] = "0x057c942544063c3aea6ea6c37009cc9d1beacd750cb6801549a129c7265f0f11";
|
|
27610
27881
|
StarknetIdVerifierContract2["TESTNET_SEPOLIA"] = "0x0182EcE8173C216A395f4828e1523541b7e3600bf190CB252E1a1A0cE219d184";
|
|
27611
27882
|
return StarknetIdVerifierContract2;
|
|
27612
27883
|
})(StarknetIdVerifierContract || {});
|
|
@@ -27614,8 +27885,6 @@ var starknet = (() => {
|
|
|
27614
27885
|
switch (chainId) {
|
|
27615
27886
|
case "0x534e5f4d41494e" /* SN_MAIN */:
|
|
27616
27887
|
return "0x07d14dfd8ee95b41fce179170d88ba1f0d5a512e13aeb232f19cfeec0a88f8bf" /* MAINNET */;
|
|
27617
|
-
case "0x534e5f474f45524c49" /* SN_GOERLI */:
|
|
27618
|
-
return "0x057c942544063c3aea6ea6c37009cc9d1beacd750cb6801549a129c7265f0f11" /* TESTNET */;
|
|
27619
27888
|
case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
|
|
27620
27889
|
return "0x0182EcE8173C216A395f4828e1523541b7e3600bf190CB252E1a1A0cE219d184" /* TESTNET_SEPOLIA */;
|
|
27621
27890
|
default:
|
|
@@ -27624,7 +27893,6 @@ var starknet = (() => {
|
|
|
27624
27893
|
}
|
|
27625
27894
|
var StarknetIdPfpContract = /* @__PURE__ */ ((StarknetIdPfpContract2) => {
|
|
27626
27895
|
StarknetIdPfpContract2["MAINNET"] = "0x070aaa20ec4a46da57c932d9fd89ca5e6bb9ca3188d3df361a32306aff7d59c7";
|
|
27627
|
-
StarknetIdPfpContract2["TESTNET"] = "0x03cac3228b434259734ee0e4ff445f642206ea11adace7e4f45edd2596748698";
|
|
27628
27896
|
StarknetIdPfpContract2["TESTNET_SEPOLIA"] = "0x058061bb6bdc501eE215172c9f87d557C1E0f466dC498cA81b18f998Bf1362b2";
|
|
27629
27897
|
return StarknetIdPfpContract2;
|
|
27630
27898
|
})(StarknetIdPfpContract || {});
|
|
@@ -27632,8 +27900,6 @@ var starknet = (() => {
|
|
|
27632
27900
|
switch (chainId) {
|
|
27633
27901
|
case "0x534e5f4d41494e" /* SN_MAIN */:
|
|
27634
27902
|
return "0x070aaa20ec4a46da57c932d9fd89ca5e6bb9ca3188d3df361a32306aff7d59c7" /* MAINNET */;
|
|
27635
|
-
case "0x534e5f474f45524c49" /* SN_GOERLI */:
|
|
27636
|
-
return "0x03cac3228b434259734ee0e4ff445f642206ea11adace7e4f45edd2596748698" /* TESTNET */;
|
|
27637
27903
|
case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
|
|
27638
27904
|
return "0x058061bb6bdc501eE215172c9f87d557C1E0f466dC498cA81b18f998Bf1362b2" /* TESTNET_SEPOLIA */;
|
|
27639
27905
|
default:
|
|
@@ -27644,7 +27910,6 @@ var starknet = (() => {
|
|
|
27644
27910
|
}
|
|
27645
27911
|
var StarknetIdPopContract = /* @__PURE__ */ ((StarknetIdPopContract2) => {
|
|
27646
27912
|
StarknetIdPopContract2["MAINNET"] = "0x0293eb2ba9862f762bd3036586d5755a782bd22e6f5028320f1d0405fd47bff4";
|
|
27647
|
-
StarknetIdPopContract2["TESTNET"] = "0x03528caf090179e337931ee669a5b0214041e1bae30d460ff07d2cea2c7a9106";
|
|
27648
27913
|
StarknetIdPopContract2["TESTNET_SEPOLIA"] = "0x0023FE3b845ed5665a9eb3792bbB17347B490EE4090f855C1298d03BB5F49B49";
|
|
27649
27914
|
return StarknetIdPopContract2;
|
|
27650
27915
|
})(StarknetIdPopContract || {});
|
|
@@ -27652,8 +27917,6 @@ var starknet = (() => {
|
|
|
27652
27917
|
switch (chainId) {
|
|
27653
27918
|
case "0x534e5f4d41494e" /* SN_MAIN */:
|
|
27654
27919
|
return "0x0293eb2ba9862f762bd3036586d5755a782bd22e6f5028320f1d0405fd47bff4" /* MAINNET */;
|
|
27655
|
-
case "0x534e5f474f45524c49" /* SN_GOERLI */:
|
|
27656
|
-
return "0x03528caf090179e337931ee669a5b0214041e1bae30d460ff07d2cea2c7a9106" /* TESTNET */;
|
|
27657
27920
|
case "0x534e5f5345504f4c4941" /* SN_SEPOLIA */:
|
|
27658
27921
|
return "0x0023FE3b845ed5665a9eb3792bbB17347B490EE4090f855C1298d03BB5F49B49" /* TESTNET_SEPOLIA */;
|
|
27659
27922
|
default:
|
|
@@ -27718,13 +27981,7 @@ var starknet = (() => {
|
|
|
27718
27981
|
const chainId = await provider.getChainId();
|
|
27719
27982
|
const contract = StarknetIdContract2 ?? getStarknetIdContract(chainId);
|
|
27720
27983
|
try {
|
|
27721
|
-
const hexDomain = await
|
|
27722
|
-
contractAddress: contract,
|
|
27723
|
-
entrypoint: "address_to_domain",
|
|
27724
|
-
calldata: CallData.compile({
|
|
27725
|
-
address
|
|
27726
|
-
})
|
|
27727
|
-
});
|
|
27984
|
+
const hexDomain = await this.executeStarkName(provider, address, contract);
|
|
27728
27985
|
const decimalDomain = hexDomain.map((element) => BigInt(element)).slice(1);
|
|
27729
27986
|
const stringDomain = useDecoded(decimalDomain);
|
|
27730
27987
|
if (!stringDomain) {
|
|
@@ -27738,6 +27995,26 @@ var starknet = (() => {
|
|
|
27738
27995
|
throw Error("Could not get stark name");
|
|
27739
27996
|
}
|
|
27740
27997
|
}
|
|
27998
|
+
static async executeStarkName(provider, address, contract) {
|
|
27999
|
+
try {
|
|
28000
|
+
return await provider.callContract({
|
|
28001
|
+
contractAddress: contract,
|
|
28002
|
+
entrypoint: "address_to_domain",
|
|
28003
|
+
calldata: CallData.compile({
|
|
28004
|
+
address,
|
|
28005
|
+
hint: []
|
|
28006
|
+
})
|
|
28007
|
+
});
|
|
28008
|
+
} catch (initialError) {
|
|
28009
|
+
return await provider.callContract({
|
|
28010
|
+
contractAddress: contract,
|
|
28011
|
+
entrypoint: "address_to_domain",
|
|
28012
|
+
calldata: CallData.compile({
|
|
28013
|
+
address
|
|
28014
|
+
})
|
|
28015
|
+
});
|
|
28016
|
+
}
|
|
28017
|
+
}
|
|
27741
28018
|
static async getAddressFromStarkName(provider, name, StarknetIdContract2) {
|
|
27742
28019
|
const chainId = await provider.getChainId();
|
|
27743
28020
|
const contract = StarknetIdContract2 ?? getStarknetIdContract(chainId);
|
|
@@ -27762,100 +28039,111 @@ var starknet = (() => {
|
|
|
27762
28039
|
const popContract = StarknetIdPopContract2 ?? getStarknetIdPopContract(chainId);
|
|
27763
28040
|
const multicallAddress = StarknetIdMulticallContract2 ?? getStarknetIdMulticallContract(chainId);
|
|
27764
28041
|
try {
|
|
27765
|
-
const
|
|
27766
|
-
|
|
27767
|
-
|
|
27768
|
-
|
|
27769
|
-
|
|
27770
|
-
|
|
27771
|
-
|
|
27772
|
-
to: dynamicFelt(contract),
|
|
27773
|
-
selector: dynamicFelt(getSelectorFromName("address_to_domain")),
|
|
27774
|
-
calldata: [dynamicCallData(address)]
|
|
27775
|
-
},
|
|
27776
|
-
{
|
|
27777
|
-
execution: execution({}),
|
|
27778
|
-
to: dynamicFelt(contract),
|
|
27779
|
-
selector: dynamicFelt(getSelectorFromName("domain_to_id")),
|
|
27780
|
-
calldata: [dynamicCallData(void 0, void 0, [0, 0])]
|
|
27781
|
-
},
|
|
27782
|
-
{
|
|
27783
|
-
execution: execution({}),
|
|
27784
|
-
to: dynamicFelt(identityContract),
|
|
27785
|
-
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
27786
|
-
calldata: [
|
|
27787
|
-
dynamicCallData(void 0, [1, 0]),
|
|
27788
|
-
dynamicCallData(encodeShortString("twitter")),
|
|
27789
|
-
dynamicCallData(verifierContract),
|
|
27790
|
-
dynamicCallData("0")
|
|
27791
|
-
]
|
|
27792
|
-
},
|
|
27793
|
-
{
|
|
27794
|
-
execution: execution({}),
|
|
27795
|
-
to: dynamicFelt(identityContract),
|
|
27796
|
-
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
27797
|
-
calldata: [
|
|
27798
|
-
dynamicCallData(void 0, [1, 0]),
|
|
27799
|
-
dynamicCallData(encodeShortString("github")),
|
|
27800
|
-
dynamicCallData(verifierContract),
|
|
27801
|
-
dynamicCallData("0")
|
|
27802
|
-
]
|
|
27803
|
-
},
|
|
27804
|
-
{
|
|
27805
|
-
execution: execution({}),
|
|
27806
|
-
to: dynamicFelt(identityContract),
|
|
27807
|
-
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
27808
|
-
calldata: [
|
|
27809
|
-
dynamicCallData(void 0, [1, 0]),
|
|
27810
|
-
dynamicCallData(encodeShortString("discord")),
|
|
27811
|
-
dynamicCallData(verifierContract),
|
|
27812
|
-
dynamicCallData("0")
|
|
27813
|
-
]
|
|
27814
|
-
},
|
|
27815
|
-
{
|
|
27816
|
-
execution: execution({}),
|
|
27817
|
-
to: dynamicFelt(identityContract),
|
|
27818
|
-
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
27819
|
-
calldata: [
|
|
27820
|
-
dynamicCallData(void 0, [1, 0]),
|
|
27821
|
-
dynamicCallData(encodeShortString("proof_of_personhood")),
|
|
27822
|
-
dynamicCallData(popContract),
|
|
27823
|
-
dynamicCallData("0")
|
|
27824
|
-
]
|
|
27825
|
-
},
|
|
27826
|
-
// PFP
|
|
27827
|
-
{
|
|
27828
|
-
execution: execution({}),
|
|
27829
|
-
to: dynamicFelt(identityContract),
|
|
27830
|
-
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
27831
|
-
calldata: [
|
|
27832
|
-
dynamicCallData(void 0, [1, 0]),
|
|
27833
|
-
dynamicCallData(encodeShortString("nft_pp_contract")),
|
|
27834
|
-
dynamicCallData(pfpContract),
|
|
27835
|
-
dynamicCallData("0")
|
|
27836
|
-
]
|
|
27837
|
-
},
|
|
27838
|
-
{
|
|
27839
|
-
execution: execution({}),
|
|
27840
|
-
to: dynamicFelt(identityContract),
|
|
27841
|
-
selector: dynamicFelt(getSelectorFromName("get_extended_verifier_data")),
|
|
27842
|
-
calldata: [
|
|
27843
|
-
dynamicCallData(void 0, [1, 0]),
|
|
27844
|
-
dynamicCallData(encodeShortString("nft_pp_id")),
|
|
27845
|
-
dynamicCallData("2"),
|
|
27846
|
-
dynamicCallData(pfpContract),
|
|
27847
|
-
dynamicCallData("0")
|
|
27848
|
-
]
|
|
27849
|
-
},
|
|
27850
|
-
{
|
|
27851
|
-
execution: execution(void 0, void 0, [6, 0, 0]),
|
|
27852
|
-
to: dynamicFelt(void 0, [6, 0]),
|
|
27853
|
-
selector: dynamicFelt(getSelectorFromName("tokenURI")),
|
|
27854
|
-
calldata: [dynamicCallData(void 0, [7, 1]), dynamicCallData(void 0, [7, 2])]
|
|
27855
|
-
}
|
|
27856
|
-
]
|
|
27857
|
-
})
|
|
28042
|
+
const initialCalldata = [];
|
|
28043
|
+
const fallbackCalldata = [];
|
|
28044
|
+
initialCalldata.push({
|
|
28045
|
+
execution: execution({}),
|
|
28046
|
+
to: dynamicCallData(contract),
|
|
28047
|
+
selector: dynamicCallData(getSelectorFromName("address_to_domain")),
|
|
28048
|
+
calldata: [dynamicCallData(address), dynamicCallData("0")]
|
|
27858
28049
|
});
|
|
28050
|
+
fallbackCalldata.push({
|
|
28051
|
+
execution: execution({}),
|
|
28052
|
+
to: dynamicCallData(contract),
|
|
28053
|
+
selector: dynamicFelt(getSelectorFromName("address_to_domain")),
|
|
28054
|
+
calldata: [dynamicCallData(address)]
|
|
28055
|
+
});
|
|
28056
|
+
const calls = [
|
|
28057
|
+
{
|
|
28058
|
+
execution: execution({}),
|
|
28059
|
+
to: dynamicFelt(contract),
|
|
28060
|
+
selector: dynamicFelt(getSelectorFromName("domain_to_id")),
|
|
28061
|
+
calldata: [dynamicCallData(void 0, void 0, [0, 0])]
|
|
28062
|
+
},
|
|
28063
|
+
{
|
|
28064
|
+
execution: execution({}),
|
|
28065
|
+
to: dynamicFelt(identityContract),
|
|
28066
|
+
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
28067
|
+
calldata: [
|
|
28068
|
+
dynamicCallData(void 0, [1, 0]),
|
|
28069
|
+
dynamicCallData(encodeShortString("twitter")),
|
|
28070
|
+
dynamicCallData(verifierContract),
|
|
28071
|
+
dynamicCallData("0")
|
|
28072
|
+
]
|
|
28073
|
+
},
|
|
28074
|
+
{
|
|
28075
|
+
execution: execution({}),
|
|
28076
|
+
to: dynamicFelt(identityContract),
|
|
28077
|
+
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
28078
|
+
calldata: [
|
|
28079
|
+
dynamicCallData(void 0, [1, 0]),
|
|
28080
|
+
dynamicCallData(encodeShortString("github")),
|
|
28081
|
+
dynamicCallData(verifierContract),
|
|
28082
|
+
dynamicCallData("0")
|
|
28083
|
+
]
|
|
28084
|
+
},
|
|
28085
|
+
{
|
|
28086
|
+
execution: execution({}),
|
|
28087
|
+
to: dynamicFelt(identityContract),
|
|
28088
|
+
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
28089
|
+
calldata: [
|
|
28090
|
+
dynamicCallData(void 0, [1, 0]),
|
|
28091
|
+
dynamicCallData(encodeShortString("discord")),
|
|
28092
|
+
dynamicCallData(verifierContract),
|
|
28093
|
+
dynamicCallData("0")
|
|
28094
|
+
]
|
|
28095
|
+
},
|
|
28096
|
+
{
|
|
28097
|
+
execution: execution({}),
|
|
28098
|
+
to: dynamicFelt(identityContract),
|
|
28099
|
+
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
28100
|
+
calldata: [
|
|
28101
|
+
dynamicCallData(void 0, [1, 0]),
|
|
28102
|
+
dynamicCallData(encodeShortString("proof_of_personhood")),
|
|
28103
|
+
dynamicCallData(popContract),
|
|
28104
|
+
dynamicCallData("0")
|
|
28105
|
+
]
|
|
28106
|
+
},
|
|
28107
|
+
// PFP
|
|
28108
|
+
{
|
|
28109
|
+
execution: execution({}),
|
|
28110
|
+
to: dynamicFelt(identityContract),
|
|
28111
|
+
selector: dynamicFelt(getSelectorFromName("get_verifier_data")),
|
|
28112
|
+
calldata: [
|
|
28113
|
+
dynamicCallData(void 0, [1, 0]),
|
|
28114
|
+
dynamicCallData(encodeShortString("nft_pp_contract")),
|
|
28115
|
+
dynamicCallData(pfpContract),
|
|
28116
|
+
dynamicCallData("0")
|
|
28117
|
+
]
|
|
28118
|
+
},
|
|
28119
|
+
{
|
|
28120
|
+
execution: execution({}),
|
|
28121
|
+
to: dynamicFelt(identityContract),
|
|
28122
|
+
selector: dynamicFelt(getSelectorFromName("get_extended_verifier_data")),
|
|
28123
|
+
calldata: [
|
|
28124
|
+
dynamicCallData(void 0, [1, 0]),
|
|
28125
|
+
dynamicCallData(encodeShortString("nft_pp_id")),
|
|
28126
|
+
dynamicCallData("2"),
|
|
28127
|
+
dynamicCallData(pfpContract),
|
|
28128
|
+
dynamicCallData("0")
|
|
28129
|
+
]
|
|
28130
|
+
},
|
|
28131
|
+
{
|
|
28132
|
+
execution: execution(void 0, void 0, [6, 0, 0]),
|
|
28133
|
+
to: dynamicFelt(void 0, [6, 0]),
|
|
28134
|
+
selector: dynamicFelt(getSelectorFromName("tokenURI")),
|
|
28135
|
+
calldata: [dynamicCallData(void 0, [7, 1]), dynamicCallData(void 0, [7, 2])]
|
|
28136
|
+
}
|
|
28137
|
+
];
|
|
28138
|
+
initialCalldata.push(...calls);
|
|
28139
|
+
fallbackCalldata.push(...calls);
|
|
28140
|
+
const data = await this.executeStarkProfile(
|
|
28141
|
+
provider,
|
|
28142
|
+
multicallAddress,
|
|
28143
|
+
"aggregate",
|
|
28144
|
+
initialCalldata,
|
|
28145
|
+
fallbackCalldata
|
|
28146
|
+
);
|
|
27859
28147
|
if (Array.isArray(data)) {
|
|
27860
28148
|
const size = parseInt(data[0], 16);
|
|
27861
28149
|
const finalArray = [];
|
|
@@ -27895,6 +28183,25 @@ var starknet = (() => {
|
|
|
27895
28183
|
throw Error("Could not get user stark profile data from address");
|
|
27896
28184
|
}
|
|
27897
28185
|
}
|
|
28186
|
+
static async executeStarkProfile(provider, contract, functionName, initialCalldata, fallbackCalldata) {
|
|
28187
|
+
try {
|
|
28188
|
+
return await provider.callContract({
|
|
28189
|
+
contractAddress: contract,
|
|
28190
|
+
entrypoint: functionName,
|
|
28191
|
+
calldata: CallData.compile({
|
|
28192
|
+
calls: initialCalldata
|
|
28193
|
+
})
|
|
28194
|
+
});
|
|
28195
|
+
} catch (initialError) {
|
|
28196
|
+
return await provider.callContract({
|
|
28197
|
+
contractAddress: contract,
|
|
28198
|
+
entrypoint: functionName,
|
|
28199
|
+
calldata: CallData.compile({
|
|
28200
|
+
calls: fallbackCalldata
|
|
28201
|
+
})
|
|
28202
|
+
});
|
|
28203
|
+
}
|
|
28204
|
+
}
|
|
27898
28205
|
};
|
|
27899
28206
|
|
|
27900
28207
|
// src/provider/extensions/default.ts
|
|
@@ -28574,7 +28881,7 @@ var starknet = (() => {
|
|
|
28574
28881
|
}
|
|
28575
28882
|
}
|
|
28576
28883
|
/**
|
|
28577
|
-
* Retrieves the Cairo version from the network and sets `cairoVersion` if not already set in the constructor
|
|
28884
|
+
* Retrieves the Cairo version from the network and sets `cairoVersion` if not already set in the constructor.
|
|
28578
28885
|
* @param classHash if provided detects Cairo version from classHash, otherwise from the account address
|
|
28579
28886
|
*/
|
|
28580
28887
|
async getCairoVersion(classHash) {
|
|
@@ -28909,32 +29216,64 @@ var starknet = (() => {
|
|
|
28909
29216
|
async hashMessage(typedData) {
|
|
28910
29217
|
return getMessageHash(typedData, this.address);
|
|
28911
29218
|
}
|
|
28912
|
-
async verifyMessageHash(hash3, signature) {
|
|
28913
|
-
|
|
28914
|
-
|
|
28915
|
-
|
|
28916
|
-
|
|
28917
|
-
|
|
28918
|
-
|
|
28919
|
-
|
|
28920
|
-
|
|
28921
|
-
|
|
28922
|
-
|
|
28923
|
-
|
|
28924
|
-
|
|
28925
|
-
|
|
28926
|
-
|
|
28927
|
-
|
|
28928
|
-
|
|
28929
|
-
|
|
28930
|
-
|
|
29219
|
+
async verifyMessageHash(hash3, signature, signatureVerificationFunctionName, signatureVerificationResponse) {
|
|
29220
|
+
const knownSigVerificationFName = signatureVerificationFunctionName ? [signatureVerificationFunctionName] : ["isValidSignature", "is_valid_signature"];
|
|
29221
|
+
const knownSignatureResponse = signatureVerificationResponse || {
|
|
29222
|
+
okResponse: [
|
|
29223
|
+
// any non-nok response is true
|
|
29224
|
+
],
|
|
29225
|
+
nokResponse: [
|
|
29226
|
+
"0x0",
|
|
29227
|
+
// Devnet
|
|
29228
|
+
"0x00"
|
|
29229
|
+
// OpenZeppelin 0.7.0 to 0.9.0 invalid signature
|
|
29230
|
+
],
|
|
29231
|
+
error: [
|
|
29232
|
+
"argent/invalid-signature",
|
|
29233
|
+
// ArgentX 0.3.0 to 0.3.1
|
|
29234
|
+
"is invalid, with respect to the public key",
|
|
29235
|
+
// OpenZeppelin until 0.6.1, Braavos 0.0.11
|
|
29236
|
+
"INVALID_SIG"
|
|
29237
|
+
// Braavos 1.0.0
|
|
29238
|
+
]
|
|
29239
|
+
};
|
|
29240
|
+
let error2;
|
|
29241
|
+
for (const SigVerificationFName of knownSigVerificationFName) {
|
|
29242
|
+
try {
|
|
29243
|
+
const resp = await this.callContract({
|
|
29244
|
+
contractAddress: this.address,
|
|
29245
|
+
entrypoint: SigVerificationFName,
|
|
29246
|
+
calldata: CallData.compile({
|
|
29247
|
+
hash: toBigInt(hash3).toString(),
|
|
29248
|
+
signature: formatSignature(signature)
|
|
29249
|
+
})
|
|
29250
|
+
});
|
|
29251
|
+
if (knownSignatureResponse.nokResponse.includes(resp[0].toString())) {
|
|
29252
|
+
return false;
|
|
29253
|
+
}
|
|
29254
|
+
if (knownSignatureResponse.okResponse.length === 0 || knownSignatureResponse.okResponse.includes(resp[0].toString())) {
|
|
29255
|
+
return true;
|
|
29256
|
+
}
|
|
29257
|
+
throw Error("signatureVerificationResponse Error: response is not part of known responses");
|
|
29258
|
+
} catch (err2) {
|
|
29259
|
+
if (knownSignatureResponse.error.some(
|
|
29260
|
+
(errMessage) => err2.message.includes(errMessage)
|
|
29261
|
+
)) {
|
|
29262
|
+
return false;
|
|
29263
|
+
}
|
|
29264
|
+
error2 = err2;
|
|
28931
29265
|
}
|
|
28932
|
-
throw Error(`Signature verification request is rejected by the network: ${err2}`);
|
|
28933
29266
|
}
|
|
29267
|
+
throw Error(`Signature verification Error: ${error2}`);
|
|
28934
29268
|
}
|
|
28935
|
-
async verifyMessage(typedData, signature) {
|
|
29269
|
+
async verifyMessage(typedData, signature, signatureVerificationFunctionName, signatureVerificationResponse) {
|
|
28936
29270
|
const hash3 = await this.hashMessage(typedData);
|
|
28937
|
-
return this.verifyMessageHash(
|
|
29271
|
+
return this.verifyMessageHash(
|
|
29272
|
+
hash3,
|
|
29273
|
+
signature,
|
|
29274
|
+
signatureVerificationFunctionName,
|
|
29275
|
+
signatureVerificationResponse
|
|
29276
|
+
);
|
|
28938
29277
|
}
|
|
28939
29278
|
/*
|
|
28940
29279
|
* Support methods
|
|
@@ -29983,6 +30322,9 @@ tough-cookie/lib/cookie.js:
|
|
|
29983
30322
|
@noble/hashes/esm/utils.js:
|
|
29984
30323
|
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
29985
30324
|
|
|
30325
|
+
@noble/hashes/esm/utils.js:
|
|
30326
|
+
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
30327
|
+
|
|
29986
30328
|
@noble/curves/esm/abstract/utils.js:
|
|
29987
30329
|
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
29988
30330
|
|
|
@@ -30016,9 +30358,6 @@ tough-cookie/lib/cookie.js:
|
|
|
30016
30358
|
pako/dist/pako.esm.mjs:
|
|
30017
30359
|
(*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) *)
|
|
30018
30360
|
|
|
30019
|
-
@noble/hashes/esm/utils.js:
|
|
30020
|
-
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
30021
|
-
|
|
30022
30361
|
@noble/curves/esm/_shortw_utils.js:
|
|
30023
30362
|
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
30024
30363
|
|