starknet 5.2.0 → 5.3.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 +13 -0
- package/README.md +2 -5
- package/dist/index.d.ts +1139 -984
- package/dist/index.global.js +245 -808
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +248 -167
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +247 -168
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -3
package/dist/index.global.js
CHANGED
|
@@ -540,647 +540,6 @@ var starknet = (() => {
|
|
|
540
540
|
}
|
|
541
541
|
});
|
|
542
542
|
|
|
543
|
-
// node_modules/@noble/hashes/_assert.js
|
|
544
|
-
var require_assert = __commonJS({
|
|
545
|
-
"node_modules/@noble/hashes/_assert.js"(exports) {
|
|
546
|
-
"use strict";
|
|
547
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
548
|
-
exports.output = exports.exists = exports.hash = exports.bytes = exports.bool = exports.number = void 0;
|
|
549
|
-
function number3(n) {
|
|
550
|
-
if (!Number.isSafeInteger(n) || n < 0)
|
|
551
|
-
throw new Error(`Wrong positive integer: ${n}`);
|
|
552
|
-
}
|
|
553
|
-
exports.number = number3;
|
|
554
|
-
function bool2(b) {
|
|
555
|
-
if (typeof b !== "boolean")
|
|
556
|
-
throw new Error(`Expected boolean, not ${b}`);
|
|
557
|
-
}
|
|
558
|
-
exports.bool = bool2;
|
|
559
|
-
function bytes2(b, ...lengths) {
|
|
560
|
-
if (!(b instanceof Uint8Array))
|
|
561
|
-
throw new TypeError("Expected Uint8Array");
|
|
562
|
-
if (lengths.length > 0 && !lengths.includes(b.length))
|
|
563
|
-
throw new TypeError(`Expected Uint8Array of length ${lengths}, not of length=${b.length}`);
|
|
564
|
-
}
|
|
565
|
-
exports.bytes = bytes2;
|
|
566
|
-
function hash2(hash3) {
|
|
567
|
-
if (typeof hash3 !== "function" || typeof hash3.create !== "function")
|
|
568
|
-
throw new Error("Hash should be wrapped by utils.wrapConstructor");
|
|
569
|
-
number3(hash3.outputLen);
|
|
570
|
-
number3(hash3.blockLen);
|
|
571
|
-
}
|
|
572
|
-
exports.hash = hash2;
|
|
573
|
-
function exists2(instance, checkFinished = true) {
|
|
574
|
-
if (instance.destroyed)
|
|
575
|
-
throw new Error("Hash instance has been destroyed");
|
|
576
|
-
if (checkFinished && instance.finished)
|
|
577
|
-
throw new Error("Hash#digest() has already been called");
|
|
578
|
-
}
|
|
579
|
-
exports.exists = exists2;
|
|
580
|
-
function output2(out, instance) {
|
|
581
|
-
bytes2(out);
|
|
582
|
-
const min = instance.outputLen;
|
|
583
|
-
if (out.length < min) {
|
|
584
|
-
throw new Error(`digestInto() expects output buffer of length at least ${min}`);
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
exports.output = output2;
|
|
588
|
-
var assert3 = {
|
|
589
|
-
number: number3,
|
|
590
|
-
bool: bool2,
|
|
591
|
-
bytes: bytes2,
|
|
592
|
-
hash: hash2,
|
|
593
|
-
exists: exists2,
|
|
594
|
-
output: output2
|
|
595
|
-
};
|
|
596
|
-
exports.default = assert3;
|
|
597
|
-
}
|
|
598
|
-
});
|
|
599
|
-
|
|
600
|
-
// node_modules/@noble/hashes/_u64.js
|
|
601
|
-
var require_u64 = __commonJS({
|
|
602
|
-
"node_modules/@noble/hashes/_u64.js"(exports) {
|
|
603
|
-
"use strict";
|
|
604
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
605
|
-
exports.add = exports.toBig = exports.split = exports.fromBig = void 0;
|
|
606
|
-
var U32_MASK642 = BigInt(2 ** 32 - 1);
|
|
607
|
-
var _32n2 = BigInt(32);
|
|
608
|
-
function fromBig2(n, le = false) {
|
|
609
|
-
if (le)
|
|
610
|
-
return { h: Number(n & U32_MASK642), l: Number(n >> _32n2 & U32_MASK642) };
|
|
611
|
-
return { h: Number(n >> _32n2 & U32_MASK642) | 0, l: Number(n & U32_MASK642) | 0 };
|
|
612
|
-
}
|
|
613
|
-
exports.fromBig = fromBig2;
|
|
614
|
-
function split2(lst, le = false) {
|
|
615
|
-
let Ah = new Uint32Array(lst.length);
|
|
616
|
-
let Al = new Uint32Array(lst.length);
|
|
617
|
-
for (let i = 0; i < lst.length; i++) {
|
|
618
|
-
const { h, l } = fromBig2(lst[i], le);
|
|
619
|
-
[Ah[i], Al[i]] = [h, l];
|
|
620
|
-
}
|
|
621
|
-
return [Ah, Al];
|
|
622
|
-
}
|
|
623
|
-
exports.split = split2;
|
|
624
|
-
var toBig2 = (h, l) => BigInt(h >>> 0) << _32n2 | BigInt(l >>> 0);
|
|
625
|
-
exports.toBig = toBig2;
|
|
626
|
-
var shrSH2 = (h, l, s) => h >>> s;
|
|
627
|
-
var shrSL2 = (h, l, s) => h << 32 - s | l >>> s;
|
|
628
|
-
var rotrSH2 = (h, l, s) => h >>> s | l << 32 - s;
|
|
629
|
-
var rotrSL2 = (h, l, s) => h << 32 - s | l >>> s;
|
|
630
|
-
var rotrBH2 = (h, l, s) => h << 64 - s | l >>> s - 32;
|
|
631
|
-
var rotrBL2 = (h, l, s) => h >>> s - 32 | l << 64 - s;
|
|
632
|
-
var rotr32H2 = (h, l) => l;
|
|
633
|
-
var rotr32L2 = (h, l) => h;
|
|
634
|
-
var rotlSH2 = (h, l, s) => h << s | l >>> 32 - s;
|
|
635
|
-
var rotlSL2 = (h, l, s) => l << s | h >>> 32 - s;
|
|
636
|
-
var rotlBH2 = (h, l, s) => l << s - 32 | h >>> 64 - s;
|
|
637
|
-
var rotlBL2 = (h, l, s) => h << s - 32 | l >>> 64 - s;
|
|
638
|
-
function add2(Ah, Al, Bh, Bl) {
|
|
639
|
-
const l = (Al >>> 0) + (Bl >>> 0);
|
|
640
|
-
return { h: Ah + Bh + (l / 2 ** 32 | 0) | 0, l: l | 0 };
|
|
641
|
-
}
|
|
642
|
-
exports.add = add2;
|
|
643
|
-
var add3L2 = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
|
|
644
|
-
var add3H2 = (low, Ah, Bh, Ch) => Ah + Bh + Ch + (low / 2 ** 32 | 0) | 0;
|
|
645
|
-
var add4L2 = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);
|
|
646
|
-
var add4H2 = (low, Ah, Bh, Ch, Dh) => Ah + Bh + Ch + Dh + (low / 2 ** 32 | 0) | 0;
|
|
647
|
-
var add5L2 = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
|
|
648
|
-
var add5H2 = (low, Ah, Bh, Ch, Dh, Eh) => Ah + Bh + Ch + Dh + Eh + (low / 2 ** 32 | 0) | 0;
|
|
649
|
-
var u642 = {
|
|
650
|
-
fromBig: fromBig2,
|
|
651
|
-
split: split2,
|
|
652
|
-
toBig: exports.toBig,
|
|
653
|
-
shrSH: shrSH2,
|
|
654
|
-
shrSL: shrSL2,
|
|
655
|
-
rotrSH: rotrSH2,
|
|
656
|
-
rotrSL: rotrSL2,
|
|
657
|
-
rotrBH: rotrBH2,
|
|
658
|
-
rotrBL: rotrBL2,
|
|
659
|
-
rotr32H: rotr32H2,
|
|
660
|
-
rotr32L: rotr32L2,
|
|
661
|
-
rotlSH: rotlSH2,
|
|
662
|
-
rotlSL: rotlSL2,
|
|
663
|
-
rotlBH: rotlBH2,
|
|
664
|
-
rotlBL: rotlBL2,
|
|
665
|
-
add: add2,
|
|
666
|
-
add3L: add3L2,
|
|
667
|
-
add3H: add3H2,
|
|
668
|
-
add4L: add4L2,
|
|
669
|
-
add4H: add4H2,
|
|
670
|
-
add5H: add5H2,
|
|
671
|
-
add5L: add5L2
|
|
672
|
-
};
|
|
673
|
-
exports.default = u642;
|
|
674
|
-
}
|
|
675
|
-
});
|
|
676
|
-
|
|
677
|
-
// node_modules/@noble/hashes/cryptoBrowser.js
|
|
678
|
-
var require_cryptoBrowser = __commonJS({
|
|
679
|
-
"node_modules/@noble/hashes/cryptoBrowser.js"(exports) {
|
|
680
|
-
"use strict";
|
|
681
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
682
|
-
exports.crypto = void 0;
|
|
683
|
-
exports.crypto = {
|
|
684
|
-
node: void 0,
|
|
685
|
-
web: typeof self === "object" && "crypto" in self ? self.crypto : void 0
|
|
686
|
-
};
|
|
687
|
-
}
|
|
688
|
-
});
|
|
689
|
-
|
|
690
|
-
// node_modules/@noble/hashes/utils.js
|
|
691
|
-
var require_utils = __commonJS({
|
|
692
|
-
"node_modules/@noble/hashes/utils.js"(exports) {
|
|
693
|
-
"use strict";
|
|
694
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
695
|
-
exports.randomBytes = exports.wrapConstructorWithOpts = exports.wrapConstructor = exports.checkOpts = exports.Hash = exports.concatBytes = exports.toBytes = exports.utf8ToBytes = exports.asyncLoop = exports.nextTick = exports.hexToBytes = exports.bytesToHex = exports.isLE = exports.rotr = exports.createView = exports.u32 = exports.u8 = void 0;
|
|
696
|
-
var crypto_1 = require_cryptoBrowser();
|
|
697
|
-
var u8 = (arr) => new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
698
|
-
exports.u8 = u8;
|
|
699
|
-
var u322 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
|
|
700
|
-
exports.u32 = u322;
|
|
701
|
-
var createView2 = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
702
|
-
exports.createView = createView2;
|
|
703
|
-
var rotr2 = (word, shift) => word << 32 - shift | word >>> shift;
|
|
704
|
-
exports.rotr = rotr2;
|
|
705
|
-
exports.isLE = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
706
|
-
if (!exports.isLE)
|
|
707
|
-
throw new Error("Non little-endian hardware is not supported");
|
|
708
|
-
var hexes3 = Array.from({ length: 256 }, (v, i) => i.toString(16).padStart(2, "0"));
|
|
709
|
-
function bytesToHex2(uint8a) {
|
|
710
|
-
if (!(uint8a instanceof Uint8Array))
|
|
711
|
-
throw new Error("Uint8Array expected");
|
|
712
|
-
let hex = "";
|
|
713
|
-
for (let i = 0; i < uint8a.length; i++) {
|
|
714
|
-
hex += hexes3[uint8a[i]];
|
|
715
|
-
}
|
|
716
|
-
return hex;
|
|
717
|
-
}
|
|
718
|
-
exports.bytesToHex = bytesToHex2;
|
|
719
|
-
function hexToBytes3(hex) {
|
|
720
|
-
if (typeof hex !== "string") {
|
|
721
|
-
throw new TypeError("hexToBytes: expected string, got " + typeof hex);
|
|
722
|
-
}
|
|
723
|
-
if (hex.length % 2)
|
|
724
|
-
throw new Error("hexToBytes: received invalid unpadded hex");
|
|
725
|
-
const array = new Uint8Array(hex.length / 2);
|
|
726
|
-
for (let i = 0; i < array.length; i++) {
|
|
727
|
-
const j = i * 2;
|
|
728
|
-
const hexByte = hex.slice(j, j + 2);
|
|
729
|
-
const byte = Number.parseInt(hexByte, 16);
|
|
730
|
-
if (Number.isNaN(byte) || byte < 0)
|
|
731
|
-
throw new Error("Invalid byte sequence");
|
|
732
|
-
array[i] = byte;
|
|
733
|
-
}
|
|
734
|
-
return array;
|
|
735
|
-
}
|
|
736
|
-
exports.hexToBytes = hexToBytes3;
|
|
737
|
-
var nextTick = async () => {
|
|
738
|
-
};
|
|
739
|
-
exports.nextTick = nextTick;
|
|
740
|
-
async function asyncLoop(iters, tick, cb) {
|
|
741
|
-
let ts = Date.now();
|
|
742
|
-
for (let i = 0; i < iters; i++) {
|
|
743
|
-
cb(i);
|
|
744
|
-
const diff = Date.now() - ts;
|
|
745
|
-
if (diff >= 0 && diff < tick)
|
|
746
|
-
continue;
|
|
747
|
-
await (0, exports.nextTick)();
|
|
748
|
-
ts += diff;
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
exports.asyncLoop = asyncLoop;
|
|
752
|
-
function utf8ToBytes3(str) {
|
|
753
|
-
if (typeof str !== "string") {
|
|
754
|
-
throw new TypeError(`utf8ToBytes expected string, got ${typeof str}`);
|
|
755
|
-
}
|
|
756
|
-
return new TextEncoder().encode(str);
|
|
757
|
-
}
|
|
758
|
-
exports.utf8ToBytes = utf8ToBytes3;
|
|
759
|
-
function toBytes2(data) {
|
|
760
|
-
if (typeof data === "string")
|
|
761
|
-
data = utf8ToBytes3(data);
|
|
762
|
-
if (!(data instanceof Uint8Array))
|
|
763
|
-
throw new TypeError(`Expected input type is Uint8Array (got ${typeof data})`);
|
|
764
|
-
return data;
|
|
765
|
-
}
|
|
766
|
-
exports.toBytes = toBytes2;
|
|
767
|
-
function concatBytes3(...arrays) {
|
|
768
|
-
if (!arrays.every((a) => a instanceof Uint8Array))
|
|
769
|
-
throw new Error("Uint8Array list expected");
|
|
770
|
-
if (arrays.length === 1)
|
|
771
|
-
return arrays[0];
|
|
772
|
-
const length = arrays.reduce((a, arr) => a + arr.length, 0);
|
|
773
|
-
const result = new Uint8Array(length);
|
|
774
|
-
for (let i = 0, pad = 0; i < arrays.length; i++) {
|
|
775
|
-
const arr = arrays[i];
|
|
776
|
-
result.set(arr, pad);
|
|
777
|
-
pad += arr.length;
|
|
778
|
-
}
|
|
779
|
-
return result;
|
|
780
|
-
}
|
|
781
|
-
exports.concatBytes = concatBytes3;
|
|
782
|
-
var Hash2 = class {
|
|
783
|
-
clone() {
|
|
784
|
-
return this._cloneInto();
|
|
785
|
-
}
|
|
786
|
-
};
|
|
787
|
-
exports.Hash = Hash2;
|
|
788
|
-
var isPlainObject = (obj) => Object.prototype.toString.call(obj) === "[object Object]" && obj.constructor === Object;
|
|
789
|
-
function checkOpts(defaults, opts) {
|
|
790
|
-
if (opts !== void 0 && (typeof opts !== "object" || !isPlainObject(opts)))
|
|
791
|
-
throw new TypeError("Options should be object or undefined");
|
|
792
|
-
const merged = Object.assign(defaults, opts);
|
|
793
|
-
return merged;
|
|
794
|
-
}
|
|
795
|
-
exports.checkOpts = checkOpts;
|
|
796
|
-
function wrapConstructor2(hashConstructor) {
|
|
797
|
-
const hashC = (message) => hashConstructor().update(toBytes2(message)).digest();
|
|
798
|
-
const tmp = hashConstructor();
|
|
799
|
-
hashC.outputLen = tmp.outputLen;
|
|
800
|
-
hashC.blockLen = tmp.blockLen;
|
|
801
|
-
hashC.create = () => hashConstructor();
|
|
802
|
-
return hashC;
|
|
803
|
-
}
|
|
804
|
-
exports.wrapConstructor = wrapConstructor2;
|
|
805
|
-
function wrapConstructorWithOpts2(hashCons) {
|
|
806
|
-
const hashC = (msg, opts) => hashCons(opts).update(toBytes2(msg)).digest();
|
|
807
|
-
const tmp = hashCons({});
|
|
808
|
-
hashC.outputLen = tmp.outputLen;
|
|
809
|
-
hashC.blockLen = tmp.blockLen;
|
|
810
|
-
hashC.create = (opts) => hashCons(opts);
|
|
811
|
-
return hashC;
|
|
812
|
-
}
|
|
813
|
-
exports.wrapConstructorWithOpts = wrapConstructorWithOpts2;
|
|
814
|
-
function randomBytes2(bytesLength = 32) {
|
|
815
|
-
if (crypto_1.crypto.web) {
|
|
816
|
-
return crypto_1.crypto.web.getRandomValues(new Uint8Array(bytesLength));
|
|
817
|
-
} else if (crypto_1.crypto.node) {
|
|
818
|
-
return new Uint8Array(crypto_1.crypto.node.randomBytes(bytesLength).buffer);
|
|
819
|
-
} else {
|
|
820
|
-
throw new Error("The environment doesn't have randomBytes function");
|
|
821
|
-
}
|
|
822
|
-
}
|
|
823
|
-
exports.randomBytes = randomBytes2;
|
|
824
|
-
}
|
|
825
|
-
});
|
|
826
|
-
|
|
827
|
-
// node_modules/@noble/hashes/sha3.js
|
|
828
|
-
var require_sha3 = __commonJS({
|
|
829
|
-
"node_modules/@noble/hashes/sha3.js"(exports) {
|
|
830
|
-
"use strict";
|
|
831
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
832
|
-
exports.shake256 = exports.shake128 = exports.keccak_512 = exports.keccak_384 = exports.keccak_256 = exports.keccak_224 = exports.sha3_512 = exports.sha3_384 = exports.sha3_256 = exports.sha3_224 = exports.Keccak = exports.keccakP = void 0;
|
|
833
|
-
var _assert_js_1 = require_assert();
|
|
834
|
-
var _u64_js_1 = require_u64();
|
|
835
|
-
var utils_js_1 = require_utils();
|
|
836
|
-
var [SHA3_PI2, SHA3_ROTL2, _SHA3_IOTA2] = [[], [], []];
|
|
837
|
-
var _0n6 = BigInt(0);
|
|
838
|
-
var _1n6 = BigInt(1);
|
|
839
|
-
var _2n4 = BigInt(2);
|
|
840
|
-
var _7n2 = BigInt(7);
|
|
841
|
-
var _256n2 = BigInt(256);
|
|
842
|
-
var _0x71n2 = BigInt(113);
|
|
843
|
-
for (let round = 0, R = _1n6, x = 1, y = 0; round < 24; round++) {
|
|
844
|
-
[x, y] = [y, (2 * x + 3 * y) % 5];
|
|
845
|
-
SHA3_PI2.push(2 * (5 * y + x));
|
|
846
|
-
SHA3_ROTL2.push((round + 1) * (round + 2) / 2 % 64);
|
|
847
|
-
let t = _0n6;
|
|
848
|
-
for (let j = 0; j < 7; j++) {
|
|
849
|
-
R = (R << _1n6 ^ (R >> _7n2) * _0x71n2) % _256n2;
|
|
850
|
-
if (R & _2n4)
|
|
851
|
-
t ^= _1n6 << (_1n6 << BigInt(j)) - _1n6;
|
|
852
|
-
}
|
|
853
|
-
_SHA3_IOTA2.push(t);
|
|
854
|
-
}
|
|
855
|
-
var [SHA3_IOTA_H2, SHA3_IOTA_L2] = _u64_js_1.default.split(_SHA3_IOTA2, true);
|
|
856
|
-
var rotlH2 = (h, l, s) => s > 32 ? _u64_js_1.default.rotlBH(h, l, s) : _u64_js_1.default.rotlSH(h, l, s);
|
|
857
|
-
var rotlL2 = (h, l, s) => s > 32 ? _u64_js_1.default.rotlBL(h, l, s) : _u64_js_1.default.rotlSL(h, l, s);
|
|
858
|
-
function keccakP2(s, rounds = 24) {
|
|
859
|
-
const B = new Uint32Array(5 * 2);
|
|
860
|
-
for (let round = 24 - rounds; round < 24; round++) {
|
|
861
|
-
for (let x = 0; x < 10; x++)
|
|
862
|
-
B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40];
|
|
863
|
-
for (let x = 0; x < 10; x += 2) {
|
|
864
|
-
const idx1 = (x + 8) % 10;
|
|
865
|
-
const idx0 = (x + 2) % 10;
|
|
866
|
-
const B0 = B[idx0];
|
|
867
|
-
const B1 = B[idx0 + 1];
|
|
868
|
-
const Th = rotlH2(B0, B1, 1) ^ B[idx1];
|
|
869
|
-
const Tl = rotlL2(B0, B1, 1) ^ B[idx1 + 1];
|
|
870
|
-
for (let y = 0; y < 50; y += 10) {
|
|
871
|
-
s[x + y] ^= Th;
|
|
872
|
-
s[x + y + 1] ^= Tl;
|
|
873
|
-
}
|
|
874
|
-
}
|
|
875
|
-
let curH = s[2];
|
|
876
|
-
let curL = s[3];
|
|
877
|
-
for (let t = 0; t < 24; t++) {
|
|
878
|
-
const shift = SHA3_ROTL2[t];
|
|
879
|
-
const Th = rotlH2(curH, curL, shift);
|
|
880
|
-
const Tl = rotlL2(curH, curL, shift);
|
|
881
|
-
const PI = SHA3_PI2[t];
|
|
882
|
-
curH = s[PI];
|
|
883
|
-
curL = s[PI + 1];
|
|
884
|
-
s[PI] = Th;
|
|
885
|
-
s[PI + 1] = Tl;
|
|
886
|
-
}
|
|
887
|
-
for (let y = 0; y < 50; y += 10) {
|
|
888
|
-
for (let x = 0; x < 10; x++)
|
|
889
|
-
B[x] = s[y + x];
|
|
890
|
-
for (let x = 0; x < 10; x++)
|
|
891
|
-
s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10];
|
|
892
|
-
}
|
|
893
|
-
s[0] ^= SHA3_IOTA_H2[round];
|
|
894
|
-
s[1] ^= SHA3_IOTA_L2[round];
|
|
895
|
-
}
|
|
896
|
-
B.fill(0);
|
|
897
|
-
}
|
|
898
|
-
exports.keccakP = keccakP2;
|
|
899
|
-
var Keccak2 = class extends utils_js_1.Hash {
|
|
900
|
-
constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) {
|
|
901
|
-
super();
|
|
902
|
-
this.blockLen = blockLen;
|
|
903
|
-
this.suffix = suffix;
|
|
904
|
-
this.outputLen = outputLen;
|
|
905
|
-
this.enableXOF = enableXOF;
|
|
906
|
-
this.rounds = rounds;
|
|
907
|
-
this.pos = 0;
|
|
908
|
-
this.posOut = 0;
|
|
909
|
-
this.finished = false;
|
|
910
|
-
this.destroyed = false;
|
|
911
|
-
_assert_js_1.default.number(outputLen);
|
|
912
|
-
if (0 >= this.blockLen || this.blockLen >= 200)
|
|
913
|
-
throw new Error("Sha3 supports only keccak-f1600 function");
|
|
914
|
-
this.state = new Uint8Array(200);
|
|
915
|
-
this.state32 = (0, utils_js_1.u32)(this.state);
|
|
916
|
-
}
|
|
917
|
-
keccak() {
|
|
918
|
-
keccakP2(this.state32, this.rounds);
|
|
919
|
-
this.posOut = 0;
|
|
920
|
-
this.pos = 0;
|
|
921
|
-
}
|
|
922
|
-
update(data) {
|
|
923
|
-
_assert_js_1.default.exists(this);
|
|
924
|
-
const { blockLen, state } = this;
|
|
925
|
-
data = (0, utils_js_1.toBytes)(data);
|
|
926
|
-
const len = data.length;
|
|
927
|
-
for (let pos = 0; pos < len; ) {
|
|
928
|
-
const take = Math.min(blockLen - this.pos, len - pos);
|
|
929
|
-
for (let i = 0; i < take; i++)
|
|
930
|
-
state[this.pos++] ^= data[pos++];
|
|
931
|
-
if (this.pos === blockLen)
|
|
932
|
-
this.keccak();
|
|
933
|
-
}
|
|
934
|
-
return this;
|
|
935
|
-
}
|
|
936
|
-
finish() {
|
|
937
|
-
if (this.finished)
|
|
938
|
-
return;
|
|
939
|
-
this.finished = true;
|
|
940
|
-
const { state, suffix, pos, blockLen } = this;
|
|
941
|
-
state[pos] ^= suffix;
|
|
942
|
-
if ((suffix & 128) !== 0 && pos === blockLen - 1)
|
|
943
|
-
this.keccak();
|
|
944
|
-
state[blockLen - 1] ^= 128;
|
|
945
|
-
this.keccak();
|
|
946
|
-
}
|
|
947
|
-
writeInto(out) {
|
|
948
|
-
_assert_js_1.default.exists(this, false);
|
|
949
|
-
_assert_js_1.default.bytes(out);
|
|
950
|
-
this.finish();
|
|
951
|
-
const bufferOut = this.state;
|
|
952
|
-
const { blockLen } = this;
|
|
953
|
-
for (let pos = 0, len = out.length; pos < len; ) {
|
|
954
|
-
if (this.posOut >= blockLen)
|
|
955
|
-
this.keccak();
|
|
956
|
-
const take = Math.min(blockLen - this.posOut, len - pos);
|
|
957
|
-
out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos);
|
|
958
|
-
this.posOut += take;
|
|
959
|
-
pos += take;
|
|
960
|
-
}
|
|
961
|
-
return out;
|
|
962
|
-
}
|
|
963
|
-
xofInto(out) {
|
|
964
|
-
if (!this.enableXOF)
|
|
965
|
-
throw new Error("XOF is not possible for this instance");
|
|
966
|
-
return this.writeInto(out);
|
|
967
|
-
}
|
|
968
|
-
xof(bytes2) {
|
|
969
|
-
_assert_js_1.default.number(bytes2);
|
|
970
|
-
return this.xofInto(new Uint8Array(bytes2));
|
|
971
|
-
}
|
|
972
|
-
digestInto(out) {
|
|
973
|
-
_assert_js_1.default.output(out, this);
|
|
974
|
-
if (this.finished)
|
|
975
|
-
throw new Error("digest() was already called");
|
|
976
|
-
this.writeInto(out);
|
|
977
|
-
this.destroy();
|
|
978
|
-
return out;
|
|
979
|
-
}
|
|
980
|
-
digest() {
|
|
981
|
-
return this.digestInto(new Uint8Array(this.outputLen));
|
|
982
|
-
}
|
|
983
|
-
destroy() {
|
|
984
|
-
this.destroyed = true;
|
|
985
|
-
this.state.fill(0);
|
|
986
|
-
}
|
|
987
|
-
_cloneInto(to) {
|
|
988
|
-
const { blockLen, suffix, outputLen, rounds, enableXOF } = this;
|
|
989
|
-
to || (to = new Keccak2(blockLen, suffix, outputLen, enableXOF, rounds));
|
|
990
|
-
to.state32.set(this.state32);
|
|
991
|
-
to.pos = this.pos;
|
|
992
|
-
to.posOut = this.posOut;
|
|
993
|
-
to.finished = this.finished;
|
|
994
|
-
to.rounds = rounds;
|
|
995
|
-
to.suffix = suffix;
|
|
996
|
-
to.outputLen = outputLen;
|
|
997
|
-
to.enableXOF = enableXOF;
|
|
998
|
-
to.destroyed = this.destroyed;
|
|
999
|
-
return to;
|
|
1000
|
-
}
|
|
1001
|
-
};
|
|
1002
|
-
exports.Keccak = Keccak2;
|
|
1003
|
-
var gen2 = (suffix, blockLen, outputLen) => (0, utils_js_1.wrapConstructor)(() => new Keccak2(blockLen, suffix, outputLen));
|
|
1004
|
-
exports.sha3_224 = gen2(6, 144, 224 / 8);
|
|
1005
|
-
exports.sha3_256 = gen2(6, 136, 256 / 8);
|
|
1006
|
-
exports.sha3_384 = gen2(6, 104, 384 / 8);
|
|
1007
|
-
exports.sha3_512 = gen2(6, 72, 512 / 8);
|
|
1008
|
-
exports.keccak_224 = gen2(1, 144, 224 / 8);
|
|
1009
|
-
exports.keccak_256 = gen2(1, 136, 256 / 8);
|
|
1010
|
-
exports.keccak_384 = gen2(1, 104, 384 / 8);
|
|
1011
|
-
exports.keccak_512 = gen2(1, 72, 512 / 8);
|
|
1012
|
-
var genShake2 = (suffix, blockLen, outputLen) => (0, utils_js_1.wrapConstructorWithOpts)((opts = {}) => new Keccak2(blockLen, suffix, opts.dkLen === void 0 ? outputLen : opts.dkLen, true));
|
|
1013
|
-
exports.shake128 = genShake2(31, 168, 128 / 8);
|
|
1014
|
-
exports.shake256 = genShake2(31, 136, 256 / 8);
|
|
1015
|
-
}
|
|
1016
|
-
});
|
|
1017
|
-
|
|
1018
|
-
// node_modules/ethereum-cryptography/utils.js
|
|
1019
|
-
var require_utils2 = __commonJS({
|
|
1020
|
-
"node_modules/ethereum-cryptography/utils.js"(exports, module) {
|
|
1021
|
-
"use strict";
|
|
1022
|
-
var __importDefault = exports && exports.__importDefault || function(mod2) {
|
|
1023
|
-
return mod2 && mod2.__esModule ? mod2 : { "default": mod2 };
|
|
1024
|
-
};
|
|
1025
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1026
|
-
exports.crypto = exports.wrapHash = exports.equalsBytes = exports.hexToBytes = exports.bytesToUtf8 = exports.utf8ToBytes = exports.createView = exports.concatBytes = exports.toHex = exports.bytesToHex = exports.assertBytes = exports.assertBool = void 0;
|
|
1027
|
-
var _assert_1 = __importDefault(require_assert());
|
|
1028
|
-
var utils_1 = require_utils();
|
|
1029
|
-
var assertBool = _assert_1.default.bool;
|
|
1030
|
-
exports.assertBool = assertBool;
|
|
1031
|
-
var assertBytes = _assert_1.default.bytes;
|
|
1032
|
-
exports.assertBytes = assertBytes;
|
|
1033
|
-
var utils_2 = require_utils();
|
|
1034
|
-
Object.defineProperty(exports, "bytesToHex", { enumerable: true, get: function() {
|
|
1035
|
-
return utils_2.bytesToHex;
|
|
1036
|
-
} });
|
|
1037
|
-
Object.defineProperty(exports, "toHex", { enumerable: true, get: function() {
|
|
1038
|
-
return utils_2.bytesToHex;
|
|
1039
|
-
} });
|
|
1040
|
-
Object.defineProperty(exports, "concatBytes", { enumerable: true, get: function() {
|
|
1041
|
-
return utils_2.concatBytes;
|
|
1042
|
-
} });
|
|
1043
|
-
Object.defineProperty(exports, "createView", { enumerable: true, get: function() {
|
|
1044
|
-
return utils_2.createView;
|
|
1045
|
-
} });
|
|
1046
|
-
Object.defineProperty(exports, "utf8ToBytes", { enumerable: true, get: function() {
|
|
1047
|
-
return utils_2.utf8ToBytes;
|
|
1048
|
-
} });
|
|
1049
|
-
function bytesToUtf8(data) {
|
|
1050
|
-
if (!(data instanceof Uint8Array)) {
|
|
1051
|
-
throw new TypeError(`bytesToUtf8 expected Uint8Array, got ${typeof data}`);
|
|
1052
|
-
}
|
|
1053
|
-
return new TextDecoder().decode(data);
|
|
1054
|
-
}
|
|
1055
|
-
exports.bytesToUtf8 = bytesToUtf8;
|
|
1056
|
-
function hexToBytes3(data) {
|
|
1057
|
-
const sliced = data.startsWith("0x") ? data.substring(2) : data;
|
|
1058
|
-
return (0, utils_1.hexToBytes)(sliced);
|
|
1059
|
-
}
|
|
1060
|
-
exports.hexToBytes = hexToBytes3;
|
|
1061
|
-
function equalsBytes(a, b) {
|
|
1062
|
-
if (a.length !== b.length) {
|
|
1063
|
-
return false;
|
|
1064
|
-
}
|
|
1065
|
-
for (let i = 0; i < a.length; i++) {
|
|
1066
|
-
if (a[i] !== b[i]) {
|
|
1067
|
-
return false;
|
|
1068
|
-
}
|
|
1069
|
-
}
|
|
1070
|
-
return true;
|
|
1071
|
-
}
|
|
1072
|
-
exports.equalsBytes = equalsBytes;
|
|
1073
|
-
function wrapHash(hash2) {
|
|
1074
|
-
return (msg) => {
|
|
1075
|
-
_assert_1.default.bytes(msg);
|
|
1076
|
-
return hash2(msg);
|
|
1077
|
-
};
|
|
1078
|
-
}
|
|
1079
|
-
exports.wrapHash = wrapHash;
|
|
1080
|
-
exports.crypto = (() => {
|
|
1081
|
-
const webCrypto = typeof self === "object" && "crypto" in self ? self.crypto : void 0;
|
|
1082
|
-
const nodeRequire = typeof module !== "undefined" && typeof module.require === "function" && module.require.bind(module);
|
|
1083
|
-
return {
|
|
1084
|
-
node: nodeRequire && !webCrypto ? nodeRequire("crypto") : void 0,
|
|
1085
|
-
web: webCrypto
|
|
1086
|
-
};
|
|
1087
|
-
})();
|
|
1088
|
-
}
|
|
1089
|
-
});
|
|
1090
|
-
|
|
1091
|
-
// node_modules/ethereum-cryptography/keccak.js
|
|
1092
|
-
var require_keccak = __commonJS({
|
|
1093
|
-
"node_modules/ethereum-cryptography/keccak.js"(exports) {
|
|
1094
|
-
"use strict";
|
|
1095
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1096
|
-
exports.keccak512 = exports.keccak384 = exports.keccak256 = exports.keccak224 = void 0;
|
|
1097
|
-
var sha3_1 = require_sha3();
|
|
1098
|
-
var utils_1 = require_utils2();
|
|
1099
|
-
exports.keccak224 = (0, utils_1.wrapHash)(sha3_1.keccak_224);
|
|
1100
|
-
exports.keccak256 = (() => {
|
|
1101
|
-
const k = (0, utils_1.wrapHash)(sha3_1.keccak_256);
|
|
1102
|
-
k.create = sha3_1.keccak_256.create;
|
|
1103
|
-
return k;
|
|
1104
|
-
})();
|
|
1105
|
-
exports.keccak384 = (0, utils_1.wrapHash)(sha3_1.keccak_384);
|
|
1106
|
-
exports.keccak512 = (0, utils_1.wrapHash)(sha3_1.keccak_512);
|
|
1107
|
-
}
|
|
1108
|
-
});
|
|
1109
|
-
|
|
1110
|
-
// node_modules/json-keys-sort/index.js
|
|
1111
|
-
var require_json_keys_sort = __commonJS({
|
|
1112
|
-
"node_modules/json-keys-sort/index.js"(exports) {
|
|
1113
|
-
var typeOf = function(data) {
|
|
1114
|
-
const objectConstructor = {}.constructor;
|
|
1115
|
-
const arrayConstructor = [].constructor;
|
|
1116
|
-
const stringConstructor = "test".constructor;
|
|
1117
|
-
if (data && data !== null && data.constructor === objectConstructor) {
|
|
1118
|
-
return "OBJECT";
|
|
1119
|
-
} else if (data && data !== null && data.constructor === arrayConstructor) {
|
|
1120
|
-
return "ARRAY";
|
|
1121
|
-
} else if (data && data !== null && data.constructor === stringConstructor) {
|
|
1122
|
-
return "STRING";
|
|
1123
|
-
} else {
|
|
1124
|
-
return "";
|
|
1125
|
-
}
|
|
1126
|
-
};
|
|
1127
|
-
function jsonSort(data, sort2) {
|
|
1128
|
-
if (typeOf(data) === "ARRAY") {
|
|
1129
|
-
let newData = [];
|
|
1130
|
-
for (let w = 0; w < data.length; w++) {
|
|
1131
|
-
let d = data[w];
|
|
1132
|
-
if (typeOf(d) === "OBJECT" || typeOf(d) === "ARRAY")
|
|
1133
|
-
newData.push(jsonSort(d, sort2));
|
|
1134
|
-
else {
|
|
1135
|
-
newData.push(d);
|
|
1136
|
-
}
|
|
1137
|
-
}
|
|
1138
|
-
return newData;
|
|
1139
|
-
} else if (typeOf(data) === "OBJECT") {
|
|
1140
|
-
let newKeys = [], keys, newData = {};
|
|
1141
|
-
if (sort2 === void 0)
|
|
1142
|
-
sort2 = true;
|
|
1143
|
-
keys = Object.keys(data).sort();
|
|
1144
|
-
if (!sort2) {
|
|
1145
|
-
for (let i = keys.length - 1; i >= 0; i--)
|
|
1146
|
-
newKeys.push(keys[i]);
|
|
1147
|
-
keys = newKeys;
|
|
1148
|
-
}
|
|
1149
|
-
for (let j = 0; j < keys.length; j++) {
|
|
1150
|
-
let key = keys[j];
|
|
1151
|
-
if (typeOf(data[key]) === "OBJECT")
|
|
1152
|
-
newData[key] = jsonSort(data[key], sort2);
|
|
1153
|
-
else if (typeOf(data[key]) === "ARRAY") {
|
|
1154
|
-
newData[key] = [];
|
|
1155
|
-
for (let k = 0; k < data[key].length; k++) {
|
|
1156
|
-
let d = data[key][k];
|
|
1157
|
-
if (typeOf(d) === "OBJECT" || typeOf(d) === "ARRAY")
|
|
1158
|
-
newData[key].push(jsonSort(data[key][k], sort2));
|
|
1159
|
-
else
|
|
1160
|
-
newData[key].push(data[key][k]);
|
|
1161
|
-
}
|
|
1162
|
-
} else
|
|
1163
|
-
newData[key] = data[key];
|
|
1164
|
-
}
|
|
1165
|
-
return newData;
|
|
1166
|
-
} else
|
|
1167
|
-
throw new Error("must be an object/array");
|
|
1168
|
-
}
|
|
1169
|
-
async function jsonSortAsync(data, sort2) {
|
|
1170
|
-
return new Promise((resolve, reject) => {
|
|
1171
|
-
try {
|
|
1172
|
-
const response = jsonSort(data, sort2);
|
|
1173
|
-
resolve(response);
|
|
1174
|
-
} catch (e) {
|
|
1175
|
-
reject(e);
|
|
1176
|
-
}
|
|
1177
|
-
});
|
|
1178
|
-
}
|
|
1179
|
-
exports.sort = jsonSort;
|
|
1180
|
-
exports.sortAsync = jsonSortAsync;
|
|
1181
|
-
}
|
|
1182
|
-
});
|
|
1183
|
-
|
|
1184
543
|
// node_modules/bignumber.js/bignumber.js
|
|
1185
544
|
var require_bignumber = __commonJS({
|
|
1186
545
|
"node_modules/bignumber.js/bignumber.js"(exports, module) {
|
|
@@ -3128,9 +2487,11 @@ var starknet = (() => {
|
|
|
3128
2487
|
__export(src_exports, {
|
|
3129
2488
|
Account: () => Account,
|
|
3130
2489
|
AccountInterface: () => AccountInterface,
|
|
2490
|
+
CallData: () => CallData,
|
|
3131
2491
|
Contract: () => Contract,
|
|
3132
2492
|
ContractFactory: () => ContractFactory,
|
|
3133
2493
|
ContractInterface: () => ContractInterface,
|
|
2494
|
+
EntryPointType: () => EntryPointType,
|
|
3134
2495
|
GatewayError: () => GatewayError,
|
|
3135
2496
|
HttpError: () => HttpError,
|
|
3136
2497
|
LibraryError: () => LibraryError,
|
|
@@ -3165,7 +2526,15 @@ var starknet = (() => {
|
|
|
3165
2526
|
validateChecksumAddress: () => validateChecksumAddress
|
|
3166
2527
|
});
|
|
3167
2528
|
|
|
3168
|
-
// src/types/lib.ts
|
|
2529
|
+
// src/types/lib/contract/index.ts
|
|
2530
|
+
var EntryPointType = /* @__PURE__ */ ((EntryPointType2) => {
|
|
2531
|
+
EntryPointType2["EXTERNAL"] = "EXTERNAL";
|
|
2532
|
+
EntryPointType2["L1_HANDLER"] = "L1_HANDLER";
|
|
2533
|
+
EntryPointType2["CONSTRUCTOR"] = "CONSTRUCTOR";
|
|
2534
|
+
return EntryPointType2;
|
|
2535
|
+
})(EntryPointType || {});
|
|
2536
|
+
|
|
2537
|
+
// src/types/lib/index.ts
|
|
3169
2538
|
var TransactionStatus = /* @__PURE__ */ ((TransactionStatus2) => {
|
|
3170
2539
|
TransactionStatus2["NOT_RECEIVED"] = "NOT_RECEIVED";
|
|
3171
2540
|
TransactionStatus2["RECEIVED"] = "RECEIVED";
|
|
@@ -3213,19 +2582,18 @@ var starknet = (() => {
|
|
|
3213
2582
|
computeContractClassHash: () => computeContractClassHash,
|
|
3214
2583
|
computeHashOnElements: () => computeHashOnElements2,
|
|
3215
2584
|
computeLegacyContractClassHash: () => computeLegacyContractClassHash,
|
|
3216
|
-
|
|
2585
|
+
computeSierraContractClassHash: () => computeSierraContractClassHash,
|
|
3217
2586
|
default: () => computeHintedClassHash,
|
|
3218
2587
|
feeTransactionVersion: () => feeTransactionVersion,
|
|
2588
|
+
formatSpaces: () => formatSpaces,
|
|
3219
2589
|
getSelector: () => getSelector,
|
|
3220
2590
|
getSelectorFromName: () => getSelectorFromName,
|
|
3221
2591
|
keccakBn: () => keccakBn,
|
|
3222
2592
|
poseidon: () => poseidon_exports,
|
|
3223
2593
|
starknetKeccak: () => starknetKeccak,
|
|
3224
|
-
transactionVersion: () => transactionVersion
|
|
2594
|
+
transactionVersion: () => transactionVersion,
|
|
2595
|
+
transactionVersion_2: () => transactionVersion_2
|
|
3225
2596
|
});
|
|
3226
|
-
var import_keccak = __toESM(require_keccak());
|
|
3227
|
-
var import_utils10 = __toESM(require_utils2());
|
|
3228
|
-
var import_json_keys_sort = __toESM(require_json_keys_sort());
|
|
3229
2597
|
|
|
3230
2598
|
// node_modules/micro-starknet/lib/esm/index.js
|
|
3231
2599
|
var esm_exports = {};
|
|
@@ -7831,6 +7199,7 @@ var starknet = (() => {
|
|
|
7831
7199
|
getDecimalString: () => getDecimalString,
|
|
7832
7200
|
getHexString: () => getHexString,
|
|
7833
7201
|
getHexStringArray: () => getHexStringArray,
|
|
7202
|
+
hexToBytes: () => hexToBytes2,
|
|
7834
7203
|
hexToDecimalString: () => hexToDecimalString,
|
|
7835
7204
|
isBigInt: () => isBigInt,
|
|
7836
7205
|
isHex: () => isHex,
|
|
@@ -7905,6 +7274,15 @@ var starknet = (() => {
|
|
|
7905
7274
|
return value.map((el) => getHexString(el));
|
|
7906
7275
|
}
|
|
7907
7276
|
var toCairoBool = (value) => (+value).toString();
|
|
7277
|
+
function hexToBytes2(value) {
|
|
7278
|
+
if (!isHex(value))
|
|
7279
|
+
throw new Error(`${value} need to be a hex-string`);
|
|
7280
|
+
let adaptedValue = removeHexPrefix(value);
|
|
7281
|
+
if (adaptedValue.length % 2 !== 0) {
|
|
7282
|
+
adaptedValue = `0${adaptedValue}`;
|
|
7283
|
+
}
|
|
7284
|
+
return hexToBytes(adaptedValue);
|
|
7285
|
+
}
|
|
7908
7286
|
|
|
7909
7287
|
// src/utils/shortString.ts
|
|
7910
7288
|
var shortString_exports = {};
|
|
@@ -8044,14 +7422,15 @@ var starknet = (() => {
|
|
|
8044
7422
|
|
|
8045
7423
|
// src/utils/hash.ts
|
|
8046
7424
|
var transactionVersion = 1n;
|
|
7425
|
+
var transactionVersion_2 = 2n;
|
|
8047
7426
|
var feeTransactionVersion = 2n ** 128n + transactionVersion;
|
|
8048
7427
|
function keccakBn(value) {
|
|
8049
7428
|
const hexWithoutPrefix = removeHexPrefix(toHex(BigInt(value)));
|
|
8050
7429
|
const evenHex = hexWithoutPrefix.length % 2 === 0 ? hexWithoutPrefix : `0${hexWithoutPrefix}`;
|
|
8051
|
-
return addHexPrefix(
|
|
7430
|
+
return addHexPrefix(keccak(hexToBytes2(addHexPrefix(evenHex))).toString(16));
|
|
8052
7431
|
}
|
|
8053
7432
|
function keccakHex(value) {
|
|
8054
|
-
return addHexPrefix(
|
|
7433
|
+
return addHexPrefix(keccak(utf8ToArray(value)).toString(16));
|
|
8055
7434
|
}
|
|
8056
7435
|
function starknetKeccak(value) {
|
|
8057
7436
|
const hash2 = BigInt(keccakHex(value));
|
|
@@ -8097,7 +7476,7 @@ var starknet = (() => {
|
|
|
8097
7476
|
chainId
|
|
8098
7477
|
);
|
|
8099
7478
|
}
|
|
8100
|
-
function calculateDeclareTransactionHash(classHash, senderAddress, version, maxFee, chainId, nonce) {
|
|
7479
|
+
function calculateDeclareTransactionHash(classHash, senderAddress, version, maxFee, chainId, nonce, compiledClassHash) {
|
|
8101
7480
|
return calculateTransactionHashCommon(
|
|
8102
7481
|
"0x6465636c617265" /* DECLARE */,
|
|
8103
7482
|
version,
|
|
@@ -8106,7 +7485,7 @@ var starknet = (() => {
|
|
|
8106
7485
|
[classHash],
|
|
8107
7486
|
maxFee,
|
|
8108
7487
|
chainId,
|
|
8109
|
-
[nonce]
|
|
7488
|
+
[nonce, ...compiledClassHash ? [compiledClassHash] : []]
|
|
8110
7489
|
);
|
|
8111
7490
|
}
|
|
8112
7491
|
function calculateDeployAccountTransactionHash(contractAddress, classHash, constructorCalldata, salt, version, maxFee, chainId, nonce) {
|
|
@@ -8215,36 +7594,12 @@ var starknet = (() => {
|
|
|
8215
7594
|
});
|
|
8216
7595
|
return poseidonHashMany(base);
|
|
8217
7596
|
}
|
|
8218
|
-
function parseHints(hints) {
|
|
8219
|
-
return hints.reduce((cum, [hint_id, hint_codes]) => {
|
|
8220
|
-
cum[hint_id] = hint_codes.map((it) => ({
|
|
8221
|
-
code: it,
|
|
8222
|
-
accessible_scopes: [],
|
|
8223
|
-
flow_tracking_data: { ap_tracking: { group: 0, offset: 0 }, reference_ids: {} }
|
|
8224
|
-
}));
|
|
8225
|
-
return cum;
|
|
8226
|
-
}, {});
|
|
8227
|
-
}
|
|
8228
|
-
function hintedProgram(casm) {
|
|
8229
|
-
const sortedHintedProgram = (0, import_json_keys_sort.sort)({
|
|
8230
|
-
program: {
|
|
8231
|
-
prime: casm.prime,
|
|
8232
|
-
data: casm.bytecode,
|
|
8233
|
-
builtins: [],
|
|
8234
|
-
hints: parseHints(casm.hints),
|
|
8235
|
-
compiler_version: casm.compiler_version
|
|
8236
|
-
}
|
|
8237
|
-
});
|
|
8238
|
-
const serialized = formatSpaces(stringify(sortedHintedProgram));
|
|
8239
|
-
return BigInt(addHexPrefix(esm_exports.keccak(utf8ToArray(serialized)).toString(16)));
|
|
8240
|
-
}
|
|
8241
7597
|
function computeCompiledClassHash(casm) {
|
|
8242
7598
|
const COMPILED_CLASS_VERSION = "COMPILED_CLASS_V1";
|
|
8243
7599
|
const compiledClassVersion = BigInt(encodeShortString(COMPILED_CLASS_VERSION));
|
|
8244
7600
|
const externalEntryPointsHash = hashEntryPoint(casm.entry_points_by_type.EXTERNAL);
|
|
8245
7601
|
const l1Handlers = hashEntryPoint(casm.entry_points_by_type.L1_HANDLER);
|
|
8246
7602
|
const constructor = hashEntryPoint(casm.entry_points_by_type.CONSTRUCTOR);
|
|
8247
|
-
const hintedCompiledClassHash = hintedProgram(casm);
|
|
8248
7603
|
const bytecode = poseidonHashMany(casm.bytecode.map((it) => BigInt(it)));
|
|
8249
7604
|
return toHex(
|
|
8250
7605
|
poseidonHashMany([
|
|
@@ -8252,29 +7607,28 @@ var starknet = (() => {
|
|
|
8252
7607
|
externalEntryPointsHash,
|
|
8253
7608
|
l1Handlers,
|
|
8254
7609
|
constructor,
|
|
8255
|
-
hintedCompiledClassHash,
|
|
8256
7610
|
bytecode
|
|
8257
7611
|
])
|
|
8258
7612
|
);
|
|
8259
7613
|
}
|
|
8260
|
-
function
|
|
7614
|
+
function hashEntryPointSierra(data) {
|
|
8261
7615
|
const base = data.flatMap((it) => {
|
|
8262
7616
|
return [BigInt(it.selector), BigInt(it.function_idx)];
|
|
8263
7617
|
});
|
|
8264
7618
|
return poseidonHashMany(base);
|
|
8265
7619
|
}
|
|
8266
|
-
function hashAbi(
|
|
8267
|
-
const indentString = stringify(
|
|
7620
|
+
function hashAbi(sierra) {
|
|
7621
|
+
const indentString = formatSpaces(stringify(sierra.abi, null));
|
|
8268
7622
|
return BigInt(addHexPrefix(esm_exports.keccak(utf8ToArray(indentString)).toString(16)));
|
|
8269
7623
|
}
|
|
8270
|
-
function
|
|
7624
|
+
function computeSierraContractClassHash(sierra) {
|
|
8271
7625
|
const CONTRACT_CLASS_VERSION = "CONTRACT_CLASS_V0.1.0";
|
|
8272
7626
|
const compiledClassVersion = BigInt(encodeShortString(CONTRACT_CLASS_VERSION));
|
|
8273
|
-
const externalEntryPointsHash =
|
|
8274
|
-
const l1Handlers =
|
|
8275
|
-
const constructor =
|
|
8276
|
-
const abiHash = hashAbi(
|
|
8277
|
-
const
|
|
7627
|
+
const externalEntryPointsHash = hashEntryPointSierra(sierra.entry_points_by_type.EXTERNAL);
|
|
7628
|
+
const l1Handlers = hashEntryPointSierra(sierra.entry_points_by_type.L1_HANDLER);
|
|
7629
|
+
const constructor = hashEntryPointSierra(sierra.entry_points_by_type.CONSTRUCTOR);
|
|
7630
|
+
const abiHash = hashAbi(sierra);
|
|
7631
|
+
const sierraProgram = poseidonHashMany(sierra.sierra_program.map((it) => BigInt(it)));
|
|
8278
7632
|
return toHex(
|
|
8279
7633
|
poseidonHashMany([
|
|
8280
7634
|
compiledClassVersion,
|
|
@@ -8282,18 +7636,41 @@ var starknet = (() => {
|
|
|
8282
7636
|
l1Handlers,
|
|
8283
7637
|
constructor,
|
|
8284
7638
|
abiHash,
|
|
8285
|
-
|
|
7639
|
+
sierraProgram
|
|
8286
7640
|
])
|
|
8287
7641
|
);
|
|
8288
7642
|
}
|
|
8289
7643
|
function computeContractClassHash(contract) {
|
|
8290
7644
|
const compiledContract = typeof contract === "string" ? parse(contract) : contract;
|
|
8291
7645
|
if ("sierra_program" in compiledContract) {
|
|
8292
|
-
return
|
|
7646
|
+
return computeSierraContractClassHash(compiledContract);
|
|
8293
7647
|
}
|
|
8294
7648
|
return computeLegacyContractClassHash(compiledContract);
|
|
8295
7649
|
}
|
|
8296
7650
|
|
|
7651
|
+
// src/utils/contract.ts
|
|
7652
|
+
var import_json_bigint2 = __toESM(require_json_bigint());
|
|
7653
|
+
function isSierra(contract) {
|
|
7654
|
+
const compiledContract = typeof contract === "string" ? (0, import_json_bigint2.parse)(contract) : contract;
|
|
7655
|
+
return "sierra_program" in compiledContract;
|
|
7656
|
+
}
|
|
7657
|
+
function extractContractHashes(payload) {
|
|
7658
|
+
const response = { ...payload };
|
|
7659
|
+
if (isSierra(payload.contract)) {
|
|
7660
|
+
if (!payload.compiledClassHash && payload.casm) {
|
|
7661
|
+
response.compiledClassHash = computeCompiledClassHash(payload.casm);
|
|
7662
|
+
}
|
|
7663
|
+
if (!response.compiledClassHash)
|
|
7664
|
+
throw new Error(
|
|
7665
|
+
"Extract compiledClassHash failed, provide (CairoAssembly).casm file or compiledClassHash"
|
|
7666
|
+
);
|
|
7667
|
+
}
|
|
7668
|
+
response.classHash = payload.classHash ?? computeContractClassHash(payload.contract);
|
|
7669
|
+
if (!response.classHash)
|
|
7670
|
+
throw new Error("Extract classHash failed, provide (CompiledContract).json file or classHash");
|
|
7671
|
+
return response;
|
|
7672
|
+
}
|
|
7673
|
+
|
|
8297
7674
|
// src/utils/stark.ts
|
|
8298
7675
|
var stark_exports = {};
|
|
8299
7676
|
__export(stark_exports, {
|
|
@@ -12451,12 +11828,23 @@ var starknet = (() => {
|
|
|
12451
11828
|
return toHex(data);
|
|
12452
11829
|
});
|
|
12453
11830
|
}
|
|
11831
|
+
function createSierraContractClass(contract) {
|
|
11832
|
+
const result = { ...contract };
|
|
11833
|
+
delete result.sierra_program_debug_info;
|
|
11834
|
+
result.abi = formatSpaces(stringify(contract.abi));
|
|
11835
|
+
result.sierra_program = formatSpaces(stringify(contract.sierra_program));
|
|
11836
|
+
result.sierra_program = compressProgram(result.sierra_program);
|
|
11837
|
+
return result;
|
|
11838
|
+
}
|
|
12454
11839
|
function parseContract(contract) {
|
|
12455
11840
|
const parsedContract = typeof contract === "string" ? parse(contract) : contract;
|
|
12456
|
-
|
|
12457
|
-
|
|
12458
|
-
|
|
12459
|
-
|
|
11841
|
+
if (!isSierra(contract)) {
|
|
11842
|
+
return {
|
|
11843
|
+
...parsedContract,
|
|
11844
|
+
..."program" in parsedContract && { program: compressProgram(parsedContract.program) }
|
|
11845
|
+
};
|
|
11846
|
+
}
|
|
11847
|
+
return createSierraContractClass(parsedContract);
|
|
12460
11848
|
}
|
|
12461
11849
|
|
|
12462
11850
|
// src/utils/responseParser/rpc.ts
|
|
@@ -12476,6 +11864,7 @@ var starknet = (() => {
|
|
|
12476
11864
|
return {
|
|
12477
11865
|
calldata: res.calldata || [],
|
|
12478
11866
|
contract_address: res.contract_address,
|
|
11867
|
+
sender_address: res.contract_address,
|
|
12479
11868
|
max_fee: res.max_fee,
|
|
12480
11869
|
nonce: res.nonce,
|
|
12481
11870
|
signature: res.signature || [],
|
|
@@ -12897,22 +12286,25 @@ var starknet = (() => {
|
|
|
12897
12286
|
}
|
|
12898
12287
|
async getDeclareEstimateFee({ senderAddress, contractDefinition, signature }, details, blockIdentifier = this.blockIdentifier) {
|
|
12899
12288
|
const block_id = new Block(blockIdentifier).identifier;
|
|
12900
|
-
|
|
12901
|
-
|
|
12902
|
-
|
|
12903
|
-
|
|
12904
|
-
|
|
12905
|
-
|
|
12906
|
-
|
|
12289
|
+
if ("program" in contractDefinition) {
|
|
12290
|
+
return this.fetchEndpoint("starknet_estimateFee", {
|
|
12291
|
+
request: {
|
|
12292
|
+
type: RPC.TransactionType.DECLARE,
|
|
12293
|
+
contract_class: {
|
|
12294
|
+
program: contractDefinition.program,
|
|
12295
|
+
entry_points_by_type: contractDefinition.entry_points_by_type,
|
|
12296
|
+
abi: contractDefinition.abi
|
|
12297
|
+
},
|
|
12298
|
+
sender_address: senderAddress,
|
|
12299
|
+
signature: signatureToHexArray(signature),
|
|
12300
|
+
version: toHex((details == null ? void 0 : details.version) || 0),
|
|
12301
|
+
nonce: toHex(details.nonce),
|
|
12302
|
+
max_fee: toHex((details == null ? void 0 : details.maxFee) || 0)
|
|
12907
12303
|
},
|
|
12908
|
-
|
|
12909
|
-
|
|
12910
|
-
|
|
12911
|
-
|
|
12912
|
-
max_fee: toHex((details == null ? void 0 : details.maxFee) || 0)
|
|
12913
|
-
},
|
|
12914
|
-
block_id
|
|
12915
|
-
}).then(this.responseParser.parseFeeEstimateResponse);
|
|
12304
|
+
block_id
|
|
12305
|
+
}).then(this.responseParser.parseFeeEstimateResponse);
|
|
12306
|
+
}
|
|
12307
|
+
throw new Error("RPC do not support Sierra Contracts yet");
|
|
12916
12308
|
}
|
|
12917
12309
|
async getDeployAccountEstimateFee({ classHash, constructorCalldata, addressSalt, signature }, details, blockIdentifier = this.blockIdentifier) {
|
|
12918
12310
|
const block_id = new Block(blockIdentifier).identifier;
|
|
@@ -12934,21 +12326,24 @@ var starknet = (() => {
|
|
|
12934
12326
|
throw new Error("RPC does not implement getInvokeEstimateFeeBulk function");
|
|
12935
12327
|
}
|
|
12936
12328
|
async declareContract({ contractDefinition, signature, senderAddress }, details) {
|
|
12937
|
-
|
|
12938
|
-
|
|
12939
|
-
|
|
12940
|
-
|
|
12941
|
-
|
|
12942
|
-
|
|
12943
|
-
|
|
12944
|
-
|
|
12945
|
-
|
|
12946
|
-
|
|
12947
|
-
|
|
12948
|
-
|
|
12949
|
-
|
|
12950
|
-
|
|
12951
|
-
|
|
12329
|
+
if ("program" in contractDefinition) {
|
|
12330
|
+
return this.fetchEndpoint("starknet_addDeclareTransaction", {
|
|
12331
|
+
declare_transaction: {
|
|
12332
|
+
contract_class: {
|
|
12333
|
+
program: contractDefinition.program,
|
|
12334
|
+
entry_points_by_type: contractDefinition.entry_points_by_type,
|
|
12335
|
+
abi: contractDefinition.abi
|
|
12336
|
+
},
|
|
12337
|
+
type: RPC.TransactionType.DECLARE,
|
|
12338
|
+
version: "0x1",
|
|
12339
|
+
max_fee: toHex(details.maxFee || 0),
|
|
12340
|
+
signature: signatureToHexArray(signature),
|
|
12341
|
+
sender_address: senderAddress,
|
|
12342
|
+
nonce: toHex(details.nonce)
|
|
12343
|
+
}
|
|
12344
|
+
});
|
|
12345
|
+
}
|
|
12346
|
+
throw new Error("RPC do not support Sierra Contracts yet");
|
|
12952
12347
|
}
|
|
12953
12348
|
async deployAccountContract({ classHash, constructorCalldata, addressSalt, signature }, details) {
|
|
12954
12349
|
return this.fetchEndpoint("starknet_addDeployAccountTransaction", {
|
|
@@ -12971,7 +12366,7 @@ var starknet = (() => {
|
|
|
12971
12366
|
calldata: parseCalldata(functionInvocation.calldata),
|
|
12972
12367
|
type: RPC.TransactionType.INVOKE,
|
|
12973
12368
|
max_fee: toHex(details.maxFee || 0),
|
|
12974
|
-
version:
|
|
12369
|
+
version: "0x1",
|
|
12975
12370
|
signature: signatureToHexArray(functionInvocation.signature),
|
|
12976
12371
|
nonce: toHex(details.nonce)
|
|
12977
12372
|
}
|
|
@@ -13080,7 +12475,6 @@ var starknet = (() => {
|
|
|
13080
12475
|
return {
|
|
13081
12476
|
...res,
|
|
13082
12477
|
calldata: "calldata" in res.transaction ? res.transaction.calldata : [],
|
|
13083
|
-
contract_address: "contract_address" in res.transaction ? res.transaction.contract_address : void 0,
|
|
13084
12478
|
contract_class: "contract_class" in res.transaction ? res.transaction.contract_class : void 0,
|
|
13085
12479
|
entry_point_selector: "entry_point_selector" in res.transaction ? res.transaction.entry_point_selector : void 0,
|
|
13086
12480
|
max_fee: "max_fee" in res.transaction ? res.transaction.max_fee : void 0,
|
|
@@ -13198,24 +12592,18 @@ var starknet = (() => {
|
|
|
13198
12592
|
};
|
|
13199
12593
|
}
|
|
13200
12594
|
parseGetStateUpdateResponse(res) {
|
|
13201
|
-
const nonces =
|
|
13202
|
-
|
|
13203
|
-
|
|
13204
|
-
|
|
13205
|
-
|
|
13206
|
-
|
|
13207
|
-
|
|
13208
|
-
return {
|
|
13209
|
-
address,
|
|
13210
|
-
storage_entries
|
|
13211
|
-
};
|
|
13212
|
-
});
|
|
12595
|
+
const nonces = Object.entries(res.state_diff.nonces).map(([contract_address, nonce]) => ({
|
|
12596
|
+
contract_address,
|
|
12597
|
+
nonce
|
|
12598
|
+
}));
|
|
12599
|
+
const storage_diffs = Object.entries(res.state_diff.storage_diffs).map(
|
|
12600
|
+
([address, storage_entries]) => ({ address, storage_entries })
|
|
12601
|
+
);
|
|
13213
12602
|
return {
|
|
13214
12603
|
...res,
|
|
13215
12604
|
state_diff: {
|
|
12605
|
+
...res.state_diff,
|
|
13216
12606
|
storage_diffs,
|
|
13217
|
-
declared_contract_hashes: res.state_diff.declared_contract_hashes,
|
|
13218
|
-
deployed_contracts: res.state_diff.deployed_contracts,
|
|
13219
12607
|
nonces
|
|
13220
12608
|
}
|
|
13221
12609
|
};
|
|
@@ -13389,7 +12777,6 @@ var starknet = (() => {
|
|
|
13389
12777
|
"call_contract",
|
|
13390
12778
|
{ blockIdentifier },
|
|
13391
12779
|
{
|
|
13392
|
-
signature: [],
|
|
13393
12780
|
contract_address: contractAddress,
|
|
13394
12781
|
entry_point_selector: getSelectorFromName(entryPointSelector),
|
|
13395
12782
|
calldata
|
|
@@ -13434,18 +12821,23 @@ var starknet = (() => {
|
|
|
13434
12821
|
async getClassHashAt(contractAddress, blockIdentifier = this.blockIdentifier) {
|
|
13435
12822
|
return this.fetchEndpoint("get_class_hash_at", { blockIdentifier, contractAddress });
|
|
13436
12823
|
}
|
|
13437
|
-
async getClassByHash(classHash) {
|
|
13438
|
-
return this.fetchEndpoint("get_class_by_hash", { classHash }).then(
|
|
12824
|
+
async getClassByHash(classHash, blockIdentifier = this.blockIdentifier) {
|
|
12825
|
+
return this.fetchEndpoint("get_class_by_hash", { classHash, blockIdentifier }).then(
|
|
12826
|
+
parseContract
|
|
12827
|
+
);
|
|
12828
|
+
}
|
|
12829
|
+
async getCompiledClassByClassHash(classHash, blockIdentifier = this.blockIdentifier) {
|
|
12830
|
+
return this.fetchEndpoint("get_compiled_class_by_class_hash", { classHash, blockIdentifier });
|
|
13439
12831
|
}
|
|
13440
12832
|
async invokeFunction(functionInvocation, details) {
|
|
13441
12833
|
return this.fetchEndpoint("add_transaction", void 0, {
|
|
13442
12834
|
type: "INVOKE_FUNCTION" /* INVOKE */,
|
|
13443
|
-
|
|
12835
|
+
sender_address: functionInvocation.contractAddress,
|
|
13444
12836
|
calldata: bigNumberishArrayToDecimalStringArray(functionInvocation.calldata ?? []),
|
|
13445
12837
|
signature: signatureToDecimalArray(functionInvocation.signature),
|
|
13446
12838
|
nonce: toHex(details.nonce),
|
|
13447
12839
|
max_fee: toHex(details.maxFee || 0),
|
|
13448
|
-
version:
|
|
12840
|
+
version: "0x1"
|
|
13449
12841
|
}).then(this.responseParser.parseInvokeFunctionResponse);
|
|
13450
12842
|
}
|
|
13451
12843
|
async deployAccountContract({ classHash, constructorCalldata, addressSalt, signature }, details) {
|
|
@@ -13460,27 +12852,39 @@ var starknet = (() => {
|
|
|
13460
12852
|
signature: signatureToDecimalArray(signature)
|
|
13461
12853
|
}).then(this.responseParser.parseDeployContractResponse);
|
|
13462
12854
|
}
|
|
13463
|
-
async declareContract({ senderAddress, contractDefinition, signature }, details) {
|
|
12855
|
+
async declareContract({ senderAddress, contractDefinition, signature, compiledClassHash }, details) {
|
|
12856
|
+
if (!isSierra(contractDefinition)) {
|
|
12857
|
+
return this.fetchEndpoint("add_transaction", void 0, {
|
|
12858
|
+
type: "DECLARE" /* DECLARE */,
|
|
12859
|
+
contract_class: contractDefinition,
|
|
12860
|
+
nonce: toHex(details.nonce),
|
|
12861
|
+
signature: signatureToDecimalArray(signature),
|
|
12862
|
+
sender_address: senderAddress,
|
|
12863
|
+
max_fee: toHex(details.maxFee || 0),
|
|
12864
|
+
version: "0x1"
|
|
12865
|
+
}).then(this.responseParser.parseDeclareContractResponse);
|
|
12866
|
+
}
|
|
13464
12867
|
return this.fetchEndpoint("add_transaction", void 0, {
|
|
13465
12868
|
type: "DECLARE" /* DECLARE */,
|
|
12869
|
+
sender_address: senderAddress,
|
|
12870
|
+
compiled_class_hash: compiledClassHash,
|
|
13466
12871
|
contract_class: contractDefinition,
|
|
13467
12872
|
nonce: toHex(details.nonce),
|
|
13468
12873
|
signature: signatureToDecimalArray(signature),
|
|
13469
|
-
sender_address: senderAddress,
|
|
13470
12874
|
max_fee: toHex(details.maxFee || 0),
|
|
13471
|
-
version:
|
|
12875
|
+
version: "0x2"
|
|
13472
12876
|
}).then(this.responseParser.parseDeclareContractResponse);
|
|
13473
12877
|
}
|
|
13474
|
-
async getEstimateFee(invocation, invocationDetails, blockIdentifier = this.blockIdentifier) {
|
|
13475
|
-
return this.getInvokeEstimateFee(invocation, invocationDetails, blockIdentifier);
|
|
12878
|
+
async getEstimateFee(invocation, invocationDetails, blockIdentifier = this.blockIdentifier, skipValidate = false) {
|
|
12879
|
+
return this.getInvokeEstimateFee(invocation, invocationDetails, blockIdentifier, skipValidate);
|
|
13476
12880
|
}
|
|
13477
|
-
async getInvokeEstimateFee(invocation, invocationDetails, blockIdentifier = this.blockIdentifier) {
|
|
12881
|
+
async getInvokeEstimateFee(invocation, invocationDetails, blockIdentifier = this.blockIdentifier, skipValidate = false) {
|
|
13478
12882
|
return this.fetchEndpoint(
|
|
13479
12883
|
"estimate_fee",
|
|
13480
|
-
{ blockIdentifier },
|
|
12884
|
+
{ blockIdentifier, skipValidate },
|
|
13481
12885
|
{
|
|
13482
12886
|
type: "INVOKE_FUNCTION" /* INVOKE */,
|
|
13483
|
-
|
|
12887
|
+
sender_address: invocation.contractAddress,
|
|
13484
12888
|
calldata: invocation.calldata ?? [],
|
|
13485
12889
|
signature: signatureToDecimalArray(invocation.signature),
|
|
13486
12890
|
version: toHex((invocationDetails == null ? void 0 : invocationDetails.version) || 1),
|
|
@@ -13488,24 +12892,39 @@ var starknet = (() => {
|
|
|
13488
12892
|
}
|
|
13489
12893
|
).then(this.responseParser.parseFeeEstimateResponse);
|
|
13490
12894
|
}
|
|
13491
|
-
async getDeclareEstimateFee({ senderAddress, contractDefinition, signature }, details, blockIdentifier = this.blockIdentifier) {
|
|
12895
|
+
async getDeclareEstimateFee({ senderAddress, contractDefinition, signature, compiledClassHash }, details, blockIdentifier = this.blockIdentifier, skipValidate = false) {
|
|
12896
|
+
if (!isSierra(contractDefinition)) {
|
|
12897
|
+
return this.fetchEndpoint(
|
|
12898
|
+
"estimate_fee",
|
|
12899
|
+
{ blockIdentifier, skipValidate },
|
|
12900
|
+
{
|
|
12901
|
+
type: "DECLARE" /* DECLARE */,
|
|
12902
|
+
sender_address: senderAddress,
|
|
12903
|
+
contract_class: contractDefinition,
|
|
12904
|
+
signature: signatureToDecimalArray(signature),
|
|
12905
|
+
version: toHex((details == null ? void 0 : details.version) || toBigInt(feeTransactionVersion)),
|
|
12906
|
+
nonce: toHex(details.nonce)
|
|
12907
|
+
}
|
|
12908
|
+
).then(this.responseParser.parseFeeEstimateResponse);
|
|
12909
|
+
}
|
|
13492
12910
|
return this.fetchEndpoint(
|
|
13493
12911
|
"estimate_fee",
|
|
13494
|
-
{ blockIdentifier },
|
|
12912
|
+
{ blockIdentifier, skipValidate },
|
|
13495
12913
|
{
|
|
13496
12914
|
type: "DECLARE" /* DECLARE */,
|
|
13497
12915
|
sender_address: senderAddress,
|
|
12916
|
+
compiled_class_hash: compiledClassHash,
|
|
13498
12917
|
contract_class: contractDefinition,
|
|
12918
|
+
nonce: toHex(details.nonce),
|
|
13499
12919
|
signature: signatureToDecimalArray(signature),
|
|
13500
|
-
version:
|
|
13501
|
-
nonce: toHex(details.nonce)
|
|
12920
|
+
version: "0x2"
|
|
13502
12921
|
}
|
|
13503
12922
|
).then(this.responseParser.parseFeeEstimateResponse);
|
|
13504
12923
|
}
|
|
13505
|
-
async getDeployAccountEstimateFee({ classHash, addressSalt, constructorCalldata, signature }, details, blockIdentifier = this.blockIdentifier) {
|
|
12924
|
+
async getDeployAccountEstimateFee({ classHash, addressSalt, constructorCalldata, signature }, details, blockIdentifier = this.blockIdentifier, skipValidate = false) {
|
|
13506
12925
|
return this.fetchEndpoint(
|
|
13507
12926
|
"estimate_fee",
|
|
13508
|
-
{ blockIdentifier },
|
|
12927
|
+
{ blockIdentifier, skipValidate },
|
|
13509
12928
|
{
|
|
13510
12929
|
type: "DEPLOY_ACCOUNT" /* DEPLOY_ACCOUNT */,
|
|
13511
12930
|
class_hash: toHex(classHash),
|
|
@@ -13523,7 +12942,7 @@ var starknet = (() => {
|
|
|
13523
12942
|
if (invocation.type === "INVOKE_FUNCTION") {
|
|
13524
12943
|
res = {
|
|
13525
12944
|
type: invocation.type,
|
|
13526
|
-
|
|
12945
|
+
sender_address: invocation.contractAddress,
|
|
13527
12946
|
calldata: invocation.calldata ?? []
|
|
13528
12947
|
};
|
|
13529
12948
|
} else if (invocation.type === "DECLARE") {
|
|
@@ -13602,13 +13021,13 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
13602
13021
|
};
|
|
13603
13022
|
return this.fetchEndpoint("estimate_message_fee", { blockIdentifier }, validCallL1Handler);
|
|
13604
13023
|
}
|
|
13605
|
-
async getSimulateTransaction(invocation, invocationDetails, blockIdentifier = this.blockIdentifier) {
|
|
13024
|
+
async getSimulateTransaction(invocation, invocationDetails, blockIdentifier = this.blockIdentifier, skipValidate = false) {
|
|
13606
13025
|
return this.fetchEndpoint(
|
|
13607
13026
|
"simulate_transaction",
|
|
13608
|
-
{ blockIdentifier },
|
|
13027
|
+
{ blockIdentifier, skipValidate },
|
|
13609
13028
|
{
|
|
13610
13029
|
type: "INVOKE_FUNCTION",
|
|
13611
|
-
|
|
13030
|
+
sender_address: invocation.contractAddress,
|
|
13612
13031
|
calldata: invocation.calldata ?? [],
|
|
13613
13032
|
signature: signatureToDecimalArray(invocation.signature),
|
|
13614
13033
|
version: toHex((invocationDetails == null ? void 0 : invocationDetails.version) || 1),
|
|
@@ -13668,11 +13087,12 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
13668
13087
|
async getEstimateFee(invocationWithTxType, invocationDetails, blockIdentifier) {
|
|
13669
13088
|
return this.provider.getEstimateFee(invocationWithTxType, invocationDetails, blockIdentifier);
|
|
13670
13089
|
}
|
|
13671
|
-
async getInvokeEstimateFee(invocationWithTxType, invocationDetails, blockIdentifier) {
|
|
13090
|
+
async getInvokeEstimateFee(invocationWithTxType, invocationDetails, blockIdentifier, skipValidate) {
|
|
13672
13091
|
return this.provider.getInvokeEstimateFee(
|
|
13673
13092
|
invocationWithTxType,
|
|
13674
13093
|
invocationDetails,
|
|
13675
|
-
blockIdentifier
|
|
13094
|
+
blockIdentifier,
|
|
13095
|
+
skipValidate
|
|
13676
13096
|
);
|
|
13677
13097
|
}
|
|
13678
13098
|
async getEstimateFeeBulk(invocations, blockIdentifier) {
|
|
@@ -13702,11 +13122,16 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
13702
13122
|
async declareContract(transaction, details) {
|
|
13703
13123
|
return this.provider.declareContract(transaction, details);
|
|
13704
13124
|
}
|
|
13705
|
-
async getDeclareEstimateFee(transaction, details, blockIdentifier) {
|
|
13706
|
-
return this.provider.getDeclareEstimateFee(transaction, details, blockIdentifier);
|
|
13125
|
+
async getDeclareEstimateFee(transaction, details, blockIdentifier, skipValidate) {
|
|
13126
|
+
return this.provider.getDeclareEstimateFee(transaction, details, blockIdentifier, skipValidate);
|
|
13707
13127
|
}
|
|
13708
|
-
getDeployAccountEstimateFee(transaction, details, blockIdentifier) {
|
|
13709
|
-
return this.provider.getDeployAccountEstimateFee(
|
|
13128
|
+
getDeployAccountEstimateFee(transaction, details, blockIdentifier, skipValidate) {
|
|
13129
|
+
return this.provider.getDeployAccountEstimateFee(
|
|
13130
|
+
transaction,
|
|
13131
|
+
details,
|
|
13132
|
+
blockIdentifier,
|
|
13133
|
+
skipValidate
|
|
13134
|
+
);
|
|
13710
13135
|
}
|
|
13711
13136
|
async getCode(contractAddress, blockIdentifier) {
|
|
13712
13137
|
return this.provider.getCode(contractAddress, blockIdentifier);
|
|
@@ -13714,8 +13139,13 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
13714
13139
|
async waitForTransaction(txHash, options) {
|
|
13715
13140
|
return this.provider.waitForTransaction(txHash, options);
|
|
13716
13141
|
}
|
|
13717
|
-
async getSimulateTransaction(invocation, invocationDetails, blockIdentifier) {
|
|
13718
|
-
return this.provider.getSimulateTransaction(
|
|
13142
|
+
async getSimulateTransaction(invocation, invocationDetails, blockIdentifier, skipValidate) {
|
|
13143
|
+
return this.provider.getSimulateTransaction(
|
|
13144
|
+
invocation,
|
|
13145
|
+
invocationDetails,
|
|
13146
|
+
blockIdentifier,
|
|
13147
|
+
skipValidate
|
|
13148
|
+
);
|
|
13719
13149
|
}
|
|
13720
13150
|
async getStateUpdate(blockIdentifier) {
|
|
13721
13151
|
return this.provider.getStateUpdate(blockIdentifier);
|
|
@@ -14693,14 +14123,23 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
14693
14123
|
);
|
|
14694
14124
|
return esm_exports.sign(msgHash, this.pk);
|
|
14695
14125
|
}
|
|
14696
|
-
async signDeclareTransaction({
|
|
14126
|
+
async signDeclareTransaction({
|
|
14127
|
+
classHash,
|
|
14128
|
+
senderAddress,
|
|
14129
|
+
chainId,
|
|
14130
|
+
maxFee,
|
|
14131
|
+
version,
|
|
14132
|
+
nonce,
|
|
14133
|
+
compiledClassHash
|
|
14134
|
+
}) {
|
|
14697
14135
|
const msgHash = calculateDeclareTransactionHash(
|
|
14698
14136
|
classHash,
|
|
14699
14137
|
senderAddress,
|
|
14700
14138
|
version,
|
|
14701
14139
|
maxFee,
|
|
14702
14140
|
chainId,
|
|
14703
|
-
nonce
|
|
14141
|
+
nonce,
|
|
14142
|
+
compiledClassHash
|
|
14704
14143
|
);
|
|
14705
14144
|
return esm_exports.sign(msgHash, this.pk);
|
|
14706
14145
|
}
|
|
@@ -14742,7 +14181,7 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
14742
14181
|
async estimateFee(calls, estimateFeeDetails) {
|
|
14743
14182
|
return this.estimateInvokeFee(calls, estimateFeeDetails);
|
|
14744
14183
|
}
|
|
14745
|
-
async estimateInvokeFee(calls, { nonce: providedNonce, blockIdentifier } = {}) {
|
|
14184
|
+
async estimateInvokeFee(calls, { nonce: providedNonce, blockIdentifier, skipValidate } = {}) {
|
|
14746
14185
|
const transactions = Array.isArray(calls) ? calls : [calls];
|
|
14747
14186
|
const nonce = toBigInt(providedNonce ?? await this.getNonce());
|
|
14748
14187
|
const version = toBigInt(feeTransactionVersion);
|
|
@@ -14758,7 +14197,8 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
14758
14197
|
const response = await super.getInvokeEstimateFee(
|
|
14759
14198
|
{ ...invocation },
|
|
14760
14199
|
{ version, nonce },
|
|
14761
|
-
blockIdentifier
|
|
14200
|
+
blockIdentifier,
|
|
14201
|
+
skipValidate
|
|
14762
14202
|
);
|
|
14763
14203
|
const suggestedMaxFee = estimatedFeeToMaxFee(response.overall_fee);
|
|
14764
14204
|
return {
|
|
@@ -14766,18 +14206,19 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
14766
14206
|
suggestedMaxFee
|
|
14767
14207
|
};
|
|
14768
14208
|
}
|
|
14769
|
-
async estimateDeclareFee({ contract, classHash: providedClassHash }, { blockIdentifier, nonce: providedNonce } = {}) {
|
|
14209
|
+
async estimateDeclareFee({ contract, classHash: providedClassHash, casm, compiledClassHash }, { blockIdentifier, nonce: providedNonce, skipValidate } = {}) {
|
|
14770
14210
|
const nonce = toBigInt(providedNonce ?? await this.getNonce());
|
|
14771
|
-
const version = toBigInt(feeTransactionVersion);
|
|
14211
|
+
const version = !isSierra(contract) ? toBigInt(feeTransactionVersion) : transactionVersion_2;
|
|
14772
14212
|
const chainId = await this.getChainId();
|
|
14773
|
-
const
|
|
14774
|
-
{ classHash: providedClassHash, contract },
|
|
14213
|
+
const declareContractTransaction = await this.buildDeclarePayload(
|
|
14214
|
+
{ classHash: providedClassHash, contract, casm, compiledClassHash },
|
|
14775
14215
|
{ nonce, chainId, version, walletAddress: this.address, maxFee: ZERO }
|
|
14776
14216
|
);
|
|
14777
14217
|
const response = await super.getDeclareEstimateFee(
|
|
14778
|
-
|
|
14218
|
+
declareContractTransaction,
|
|
14779
14219
|
{ version, nonce },
|
|
14780
|
-
blockIdentifier
|
|
14220
|
+
blockIdentifier,
|
|
14221
|
+
skipValidate
|
|
14781
14222
|
);
|
|
14782
14223
|
const suggestedMaxFee = estimatedFeeToMaxFee(response.overall_fee);
|
|
14783
14224
|
return {
|
|
@@ -14790,7 +14231,7 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
14790
14231
|
addressSalt = 0,
|
|
14791
14232
|
constructorCalldata = [],
|
|
14792
14233
|
contractAddress: providedContractAddress
|
|
14793
|
-
}, { blockIdentifier } = {}) {
|
|
14234
|
+
}, { blockIdentifier, skipValidate } = {}) {
|
|
14794
14235
|
const version = toBigInt(feeTransactionVersion);
|
|
14795
14236
|
const nonce = ZERO;
|
|
14796
14237
|
const chainId = await this.getChainId();
|
|
@@ -14801,7 +14242,8 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
14801
14242
|
const response = await super.getDeployAccountEstimateFee(
|
|
14802
14243
|
{ ...payload },
|
|
14803
14244
|
{ version, nonce },
|
|
14804
|
-
blockIdentifier
|
|
14245
|
+
blockIdentifier,
|
|
14246
|
+
skipValidate
|
|
14805
14247
|
);
|
|
14806
14248
|
const suggestedMaxFee = estimatedFeeToMaxFee(response.overall_fee);
|
|
14807
14249
|
return {
|
|
@@ -14917,32 +14359,24 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
14917
14359
|
}
|
|
14918
14360
|
);
|
|
14919
14361
|
}
|
|
14920
|
-
async declare(
|
|
14921
|
-
const
|
|
14922
|
-
const
|
|
14923
|
-
|
|
14924
|
-
|
|
14362
|
+
async declare(payload, transactionsDetail = {}) {
|
|
14363
|
+
const declareContractPayload = extractContractHashes(payload);
|
|
14364
|
+
const details = {};
|
|
14365
|
+
details.nonce = toBigInt(transactionsDetail.nonce ?? await this.getNonce());
|
|
14366
|
+
details.maxFee = transactionsDetail.maxFee ?? await this.getSuggestedMaxFee(
|
|
14367
|
+
{
|
|
14368
|
+
type: "DECLARE" /* DECLARE */,
|
|
14369
|
+
payload: declareContractPayload
|
|
14370
|
+
},
|
|
14925
14371
|
transactionsDetail
|
|
14926
14372
|
);
|
|
14927
|
-
|
|
14928
|
-
|
|
14929
|
-
const
|
|
14930
|
-
|
|
14931
|
-
|
|
14932
|
-
chainId,
|
|
14933
|
-
maxFee,
|
|
14934
|
-
version,
|
|
14935
|
-
nonce
|
|
14373
|
+
details.version = !isSierra(payload.contract) ? transactionVersion : transactionVersion_2;
|
|
14374
|
+
details.chainId = await this.getChainId();
|
|
14375
|
+
const declareContractTransaction = await this.buildDeclarePayload(declareContractPayload, {
|
|
14376
|
+
...details,
|
|
14377
|
+
walletAddress: this.address
|
|
14936
14378
|
});
|
|
14937
|
-
|
|
14938
|
-
return this.declareContract(
|
|
14939
|
-
{ contractDefinition, senderAddress: this.address, signature },
|
|
14940
|
-
{
|
|
14941
|
-
nonce,
|
|
14942
|
-
maxFee,
|
|
14943
|
-
version
|
|
14944
|
-
}
|
|
14945
|
-
);
|
|
14379
|
+
return this.declareContract(declareContractTransaction, details);
|
|
14946
14380
|
}
|
|
14947
14381
|
async deploy(payload, details) {
|
|
14948
14382
|
const params = [].concat(payload).map((it) => {
|
|
@@ -15083,11 +14517,12 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
15083
14517
|
}
|
|
15084
14518
|
return feeEstimate.suggestedMaxFee.toString();
|
|
15085
14519
|
}
|
|
15086
|
-
async buildDeclarePayload(
|
|
14520
|
+
async buildDeclarePayload(payload, { nonce, chainId, version, walletAddress, maxFee }) {
|
|
14521
|
+
const { classHash, contract, compiledClassHash } = extractContractHashes(payload);
|
|
15087
14522
|
const contractDefinition = parseContract(contract);
|
|
15088
|
-
const classHash = providedClassHash ?? computeContractClassHash(contract);
|
|
15089
14523
|
const signature = await this.signer.signDeclareTransaction({
|
|
15090
14524
|
classHash,
|
|
14525
|
+
compiledClassHash,
|
|
15091
14526
|
senderAddress: walletAddress,
|
|
15092
14527
|
chainId,
|
|
15093
14528
|
maxFee,
|
|
@@ -15097,7 +14532,8 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
15097
14532
|
return {
|
|
15098
14533
|
senderAddress: walletAddress,
|
|
15099
14534
|
signature,
|
|
15100
|
-
contractDefinition
|
|
14535
|
+
contractDefinition,
|
|
14536
|
+
compiledClassHash
|
|
15101
14537
|
};
|
|
15102
14538
|
}
|
|
15103
14539
|
async buildAccountDeployPayload({
|
|
@@ -15147,7 +14583,7 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
15147
14583
|
});
|
|
15148
14584
|
return calls;
|
|
15149
14585
|
}
|
|
15150
|
-
async simulateTransaction(calls, { nonce: providedNonce, blockIdentifier } = {}) {
|
|
14586
|
+
async simulateTransaction(calls, { nonce: providedNonce, blockIdentifier, skipValidate } = {}) {
|
|
15151
14587
|
const transactions = Array.isArray(calls) ? calls : [calls];
|
|
15152
14588
|
const nonce = toBigInt(providedNonce ?? await this.getNonce());
|
|
15153
14589
|
const version = toBigInt(feeTransactionVersion);
|
|
@@ -15163,7 +14599,8 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
15163
14599
|
const response = await super.getSimulateTransaction(
|
|
15164
14600
|
invocation,
|
|
15165
14601
|
{ version, nonce },
|
|
15166
|
-
blockIdentifier
|
|
14602
|
+
blockIdentifier,
|
|
14603
|
+
skipValidate
|
|
15167
14604
|
);
|
|
15168
14605
|
const suggestedMaxFee = estimatedFeeToMaxFee(response.fee_estimation.overall_fee);
|
|
15169
14606
|
return {
|