@fastxyz/cli 1.0.1 → 1.0.3
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/LICENSE +21 -0
- package/README.md +366 -6
- package/dist/_esm-PAFIJ3CY.js +0 -0
- package/dist/{app-IJ6QEQ2I.js → app-ZXKQBKVM.js} +1 -1
- package/dist/ccip-25L4RSNC.js +0 -0
- package/dist/chunk-5U55A5N6.js +0 -0
- package/dist/chunk-77HVPD4G.js +0 -0
- package/dist/chunk-DITXH2ZY.js +2476 -0
- package/dist/chunk-MWATGKBS.js +0 -0
- package/dist/chunk-T7HRTMD7.js +0 -0
- package/dist/{chunk-MIRQRJSD.js → chunk-UZZ2O26Y.js} +90 -51
- package/dist/chunk-VOHYNW3B.js +0 -0
- package/dist/database-NXA7GQKE.js +0 -0
- package/dist/main.js +616 -2466
- package/dist/{network-5PLYLKX3.js → network-GHRVPGMD.js} +2 -2
- package/dist/secp256k1-CWQX754O.js +0 -0
- package/package.json +20 -12
- package/dist/chunk-FLS2KI2D.js +0 -146
package/dist/main.js
CHANGED
|
@@ -165,13 +165,36 @@ import {
|
|
|
165
165
|
} from "./chunk-VOHYNW3B.js";
|
|
166
166
|
import "./chunk-MWATGKBS.js";
|
|
167
167
|
import {
|
|
168
|
-
|
|
169
|
-
|
|
168
|
+
AccountInfoResponseFromRest,
|
|
169
|
+
AddressFromRest,
|
|
170
|
+
EscrowJobRecordFromRest,
|
|
171
|
+
EscrowJobWithCertsFromRest,
|
|
172
|
+
GetAccountInfoInput,
|
|
173
|
+
GetEscrowJobInput,
|
|
174
|
+
GetEscrowJobsInput,
|
|
175
|
+
GetPendingMultisigInput,
|
|
176
|
+
GetTokenInfoInput,
|
|
177
|
+
GetTransactionCertificatesInput,
|
|
178
|
+
LatestTransactionVersion,
|
|
179
|
+
NetworkConfigService,
|
|
180
|
+
PrivateKeyFromInput,
|
|
181
|
+
ProxySubmitTransactionResultFromRest,
|
|
182
|
+
SignatureFromInput,
|
|
183
|
+
SignatureOrMultiSigFromBcs,
|
|
184
|
+
TokenIdFromRest,
|
|
185
|
+
TokenInfoResponseFromRest,
|
|
186
|
+
TransactionCertificateFromRest,
|
|
187
|
+
TransactionCertificateFromRpc,
|
|
188
|
+
TransactionEnvelopeFromRest,
|
|
189
|
+
VersionedTransactionFromBcs,
|
|
190
|
+
bcs_layout_exports,
|
|
191
|
+
getTransactionVersionConfig
|
|
192
|
+
} from "./chunk-DITXH2ZY.js";
|
|
170
193
|
import {
|
|
171
194
|
AppConfigLive,
|
|
172
195
|
getAppName,
|
|
173
196
|
getVersion
|
|
174
|
-
} from "./chunk-
|
|
197
|
+
} from "./chunk-UZZ2O26Y.js";
|
|
175
198
|
import {
|
|
176
199
|
AccountExistsError,
|
|
177
200
|
AccountNotFoundError,
|
|
@@ -213,7 +236,7 @@ import { Option as Option7 } from "effect";
|
|
|
213
236
|
// src/app.ts
|
|
214
237
|
import { Effect as Effect14, Layer as Layer6 } from "effect";
|
|
215
238
|
|
|
216
|
-
// ../../packages/fast-sdk/dist/chunk-
|
|
239
|
+
// ../../packages/fast-sdk/dist/chunk-2WOJNW4N.js
|
|
217
240
|
import { Data } from "effect";
|
|
218
241
|
|
|
219
242
|
// ../../node_modules/.pnpm/@noble+hashes@2.0.1/node_modules/@noble/hashes/_u64.js
|
|
@@ -602,1936 +625,13 @@ var Keccak = class _Keccak {
|
|
|
602
625
|
var genKeccak = (suffix, blockLen, outputLen, info = {}) => createHasher(() => new Keccak(blockLen, suffix, outputLen), info);
|
|
603
626
|
var keccak_2562 = /* @__PURE__ */ genKeccak(1, 136, 32);
|
|
604
627
|
|
|
605
|
-
// ../../packages/fast-sdk/dist/chunk-
|
|
628
|
+
// ../../packages/fast-sdk/dist/chunk-2WOJNW4N.js
|
|
606
629
|
import { Effect, Encoding } from "effect";
|
|
607
630
|
import { Cause, Effect as Effect2, Exit, Option } from "effect";
|
|
608
631
|
import { Data as Data2 } from "effect";
|
|
609
632
|
import { Data as Data3 } from "effect";
|
|
610
633
|
import { Data as Data4 } from "effect";
|
|
611
|
-
|
|
612
|
-
// ../../packages/fast-schema/dist/index.mjs
|
|
613
|
-
import { Schema as Schema5 } from "effect";
|
|
614
|
-
import { bech32m } from "bech32";
|
|
615
|
-
import { ParseResult, Schema } from "effect";
|
|
616
|
-
import { Schema as Schema2 } from "effect";
|
|
617
|
-
import { Schema as Schema3, String as Str } from "effect";
|
|
618
|
-
import { Either, ParseResult as ParseResult2, Schema as Schema4 } from "effect";
|
|
619
|
-
import { Schema as Schema6 } from "effect";
|
|
620
|
-
import { Schema as Schema7 } from "effect";
|
|
621
|
-
import { Schema as Schema8 } from "effect";
|
|
622
|
-
import { Schema as Schema9 } from "effect";
|
|
623
|
-
|
|
624
|
-
// ../../node_modules/.pnpm/@mysten+bcs@2.0.3/node_modules/@mysten/bcs/dist/uleb.mjs
|
|
625
|
-
function ulebEncode(num) {
|
|
626
|
-
let bigNum = BigInt(num);
|
|
627
|
-
const arr = [];
|
|
628
|
-
let len = 0;
|
|
629
|
-
if (bigNum === 0n) return [0];
|
|
630
|
-
while (bigNum > 0) {
|
|
631
|
-
arr[len] = Number(bigNum & 127n);
|
|
632
|
-
bigNum >>= 7n;
|
|
633
|
-
if (bigNum > 0n) arr[len] |= 128;
|
|
634
|
-
len += 1;
|
|
635
|
-
}
|
|
636
|
-
return arr;
|
|
637
|
-
}
|
|
638
|
-
function ulebDecode(arr) {
|
|
639
|
-
let total = 0n;
|
|
640
|
-
let shift = 0n;
|
|
641
|
-
let len = 0;
|
|
642
|
-
while (true) {
|
|
643
|
-
if (len >= arr.length) throw new Error("ULEB decode error: buffer overflow");
|
|
644
|
-
const byte = arr[len];
|
|
645
|
-
len += 1;
|
|
646
|
-
total += BigInt(byte & 127) << shift;
|
|
647
|
-
if ((byte & 128) === 0) break;
|
|
648
|
-
shift += 7n;
|
|
649
|
-
}
|
|
650
|
-
if (total > BigInt(Number.MAX_SAFE_INTEGER)) throw new Error("ULEB decode error: value exceeds MAX_SAFE_INTEGER");
|
|
651
|
-
return {
|
|
652
|
-
value: Number(total),
|
|
653
|
-
length: len
|
|
654
|
-
};
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
// ../../node_modules/.pnpm/@mysten+bcs@2.0.3/node_modules/@mysten/bcs/dist/reader.mjs
|
|
658
|
-
var BcsReader = class {
|
|
659
|
-
/**
|
|
660
|
-
* @param {Uint8Array} data Data to use as a buffer.
|
|
661
|
-
*/
|
|
662
|
-
constructor(data) {
|
|
663
|
-
this.bytePosition = 0;
|
|
664
|
-
this.dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
665
|
-
}
|
|
666
|
-
/**
|
|
667
|
-
* Shift current cursor position by `bytes`.
|
|
668
|
-
*
|
|
669
|
-
* @param {Number} bytes Number of bytes to
|
|
670
|
-
* @returns {this} Self for possible chaining.
|
|
671
|
-
*/
|
|
672
|
-
shift(bytes) {
|
|
673
|
-
this.bytePosition += bytes;
|
|
674
|
-
return this;
|
|
675
|
-
}
|
|
676
|
-
/**
|
|
677
|
-
* Read U8 value from the buffer and shift cursor by 1.
|
|
678
|
-
* @returns
|
|
679
|
-
*/
|
|
680
|
-
read8() {
|
|
681
|
-
const value = this.dataView.getUint8(this.bytePosition);
|
|
682
|
-
this.shift(1);
|
|
683
|
-
return value;
|
|
684
|
-
}
|
|
685
|
-
/**
|
|
686
|
-
* Read U16 value from the buffer and shift cursor by 2.
|
|
687
|
-
* @returns
|
|
688
|
-
*/
|
|
689
|
-
read16() {
|
|
690
|
-
const value = this.dataView.getUint16(this.bytePosition, true);
|
|
691
|
-
this.shift(2);
|
|
692
|
-
return value;
|
|
693
|
-
}
|
|
694
|
-
/**
|
|
695
|
-
* Read U32 value from the buffer and shift cursor by 4.
|
|
696
|
-
* @returns
|
|
697
|
-
*/
|
|
698
|
-
read32() {
|
|
699
|
-
const value = this.dataView.getUint32(this.bytePosition, true);
|
|
700
|
-
this.shift(4);
|
|
701
|
-
return value;
|
|
702
|
-
}
|
|
703
|
-
/**
|
|
704
|
-
* Read U64 value from the buffer and shift cursor by 8.
|
|
705
|
-
* @returns
|
|
706
|
-
*/
|
|
707
|
-
read64() {
|
|
708
|
-
const value1 = this.read32();
|
|
709
|
-
const result2 = this.read32().toString(16) + value1.toString(16).padStart(8, "0");
|
|
710
|
-
return BigInt("0x" + result2).toString(10);
|
|
711
|
-
}
|
|
712
|
-
/**
|
|
713
|
-
* Read U128 value from the buffer and shift cursor by 16.
|
|
714
|
-
*/
|
|
715
|
-
read128() {
|
|
716
|
-
const value1 = BigInt(this.read64());
|
|
717
|
-
const result2 = BigInt(this.read64()).toString(16) + value1.toString(16).padStart(16, "0");
|
|
718
|
-
return BigInt("0x" + result2).toString(10);
|
|
719
|
-
}
|
|
720
|
-
/**
|
|
721
|
-
* Read U128 value from the buffer and shift cursor by 32.
|
|
722
|
-
* @returns
|
|
723
|
-
*/
|
|
724
|
-
read256() {
|
|
725
|
-
const value1 = BigInt(this.read128());
|
|
726
|
-
const result2 = BigInt(this.read128()).toString(16) + value1.toString(16).padStart(32, "0");
|
|
727
|
-
return BigInt("0x" + result2).toString(10);
|
|
728
|
-
}
|
|
729
|
-
/**
|
|
730
|
-
* Read `num` number of bytes from the buffer and shift cursor by `num`.
|
|
731
|
-
* @param num Number of bytes to read.
|
|
732
|
-
*/
|
|
733
|
-
readBytes(num) {
|
|
734
|
-
const start = this.bytePosition + this.dataView.byteOffset;
|
|
735
|
-
const value = new Uint8Array(this.dataView.buffer, start, num);
|
|
736
|
-
this.shift(num);
|
|
737
|
-
return value;
|
|
738
|
-
}
|
|
739
|
-
/**
|
|
740
|
-
* Read ULEB value - an integer of varying size. Used for enum indexes and
|
|
741
|
-
* vector lengths.
|
|
742
|
-
* @returns {Number} The ULEB value.
|
|
743
|
-
*/
|
|
744
|
-
readULEB() {
|
|
745
|
-
const start = this.bytePosition + this.dataView.byteOffset;
|
|
746
|
-
const { value, length } = ulebDecode(new Uint8Array(this.dataView.buffer, start));
|
|
747
|
-
this.shift(length);
|
|
748
|
-
return value;
|
|
749
|
-
}
|
|
750
|
-
/**
|
|
751
|
-
* Read a BCS vector: read a length and then apply function `cb` X times
|
|
752
|
-
* where X is the length of the vector, defined as ULEB in BCS bytes.
|
|
753
|
-
* @param cb Callback to process elements of vector.
|
|
754
|
-
* @returns {Array<Any>} Array of the resulting values, returned by callback.
|
|
755
|
-
*/
|
|
756
|
-
readVec(cb) {
|
|
757
|
-
const length = this.readULEB();
|
|
758
|
-
const result2 = [];
|
|
759
|
-
for (let i = 0; i < length; i++) result2.push(cb(this, i, length));
|
|
760
|
-
return result2;
|
|
761
|
-
}
|
|
762
|
-
};
|
|
763
|
-
|
|
764
|
-
// ../../node_modules/.pnpm/@scure+base@2.0.0/node_modules/@scure/base/index.js
|
|
765
|
-
function isBytes2(a) {
|
|
766
|
-
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
767
|
-
}
|
|
768
|
-
function isArrayOf(isString, arr) {
|
|
769
|
-
if (!Array.isArray(arr))
|
|
770
|
-
return false;
|
|
771
|
-
if (arr.length === 0)
|
|
772
|
-
return true;
|
|
773
|
-
if (isString) {
|
|
774
|
-
return arr.every((item) => typeof item === "string");
|
|
775
|
-
} else {
|
|
776
|
-
return arr.every((item) => Number.isSafeInteger(item));
|
|
777
|
-
}
|
|
778
|
-
}
|
|
779
|
-
function astr(label, input) {
|
|
780
|
-
if (typeof input !== "string")
|
|
781
|
-
throw new Error(`${label}: string expected`);
|
|
782
|
-
return true;
|
|
783
|
-
}
|
|
784
|
-
function anumber2(n) {
|
|
785
|
-
if (!Number.isSafeInteger(n))
|
|
786
|
-
throw new Error(`invalid integer: ${n}`);
|
|
787
|
-
}
|
|
788
|
-
function aArr(input) {
|
|
789
|
-
if (!Array.isArray(input))
|
|
790
|
-
throw new Error("array expected");
|
|
791
|
-
}
|
|
792
|
-
function astrArr(label, input) {
|
|
793
|
-
if (!isArrayOf(true, input))
|
|
794
|
-
throw new Error(`${label}: array of strings expected`);
|
|
795
|
-
}
|
|
796
|
-
function anumArr(label, input) {
|
|
797
|
-
if (!isArrayOf(false, input))
|
|
798
|
-
throw new Error(`${label}: array of numbers expected`);
|
|
799
|
-
}
|
|
800
|
-
// @__NO_SIDE_EFFECTS__
|
|
801
|
-
function chain(...args) {
|
|
802
|
-
const id = (a) => a;
|
|
803
|
-
const wrap3 = (a, b) => (c) => a(b(c));
|
|
804
|
-
const encode5 = args.map((x) => x.encode).reduceRight(wrap3, id);
|
|
805
|
-
const decode2 = args.map((x) => x.decode).reduce(wrap3, id);
|
|
806
|
-
return { encode: encode5, decode: decode2 };
|
|
807
|
-
}
|
|
808
|
-
// @__NO_SIDE_EFFECTS__
|
|
809
|
-
function alphabet(letters) {
|
|
810
|
-
const lettersA = typeof letters === "string" ? letters.split("") : letters;
|
|
811
|
-
const len = lettersA.length;
|
|
812
|
-
astrArr("alphabet", lettersA);
|
|
813
|
-
const indexes = new Map(lettersA.map((l, i) => [l, i]));
|
|
814
|
-
return {
|
|
815
|
-
encode: (digits) => {
|
|
816
|
-
aArr(digits);
|
|
817
|
-
return digits.map((i) => {
|
|
818
|
-
if (!Number.isSafeInteger(i) || i < 0 || i >= len)
|
|
819
|
-
throw new Error(`alphabet.encode: digit index outside alphabet "${i}". Allowed: ${letters}`);
|
|
820
|
-
return lettersA[i];
|
|
821
|
-
});
|
|
822
|
-
},
|
|
823
|
-
decode: (input) => {
|
|
824
|
-
aArr(input);
|
|
825
|
-
return input.map((letter) => {
|
|
826
|
-
astr("alphabet.decode", letter);
|
|
827
|
-
const i = indexes.get(letter);
|
|
828
|
-
if (i === void 0)
|
|
829
|
-
throw new Error(`Unknown letter: "${letter}". Allowed: ${letters}`);
|
|
830
|
-
return i;
|
|
831
|
-
});
|
|
832
|
-
}
|
|
833
|
-
};
|
|
834
|
-
}
|
|
835
|
-
// @__NO_SIDE_EFFECTS__
|
|
836
|
-
function join(separator = "") {
|
|
837
|
-
astr("join", separator);
|
|
838
|
-
return {
|
|
839
|
-
encode: (from14) => {
|
|
840
|
-
astrArr("join.decode", from14);
|
|
841
|
-
return from14.join(separator);
|
|
842
|
-
},
|
|
843
|
-
decode: (to) => {
|
|
844
|
-
astr("join.decode", to);
|
|
845
|
-
return to.split(separator);
|
|
846
|
-
}
|
|
847
|
-
};
|
|
848
|
-
}
|
|
849
|
-
function convertRadix(data, from14, to) {
|
|
850
|
-
if (from14 < 2)
|
|
851
|
-
throw new Error(`convertRadix: invalid from=${from14}, base cannot be less than 2`);
|
|
852
|
-
if (to < 2)
|
|
853
|
-
throw new Error(`convertRadix: invalid to=${to}, base cannot be less than 2`);
|
|
854
|
-
aArr(data);
|
|
855
|
-
if (!data.length)
|
|
856
|
-
return [];
|
|
857
|
-
let pos = 0;
|
|
858
|
-
const res = [];
|
|
859
|
-
const digits = Array.from(data, (d) => {
|
|
860
|
-
anumber2(d);
|
|
861
|
-
if (d < 0 || d >= from14)
|
|
862
|
-
throw new Error(`invalid integer: ${d}`);
|
|
863
|
-
return d;
|
|
864
|
-
});
|
|
865
|
-
const dlen = digits.length;
|
|
866
|
-
while (true) {
|
|
867
|
-
let carry = 0;
|
|
868
|
-
let done = true;
|
|
869
|
-
for (let i = pos; i < dlen; i++) {
|
|
870
|
-
const digit = digits[i];
|
|
871
|
-
const fromCarry = from14 * carry;
|
|
872
|
-
const digitBase = fromCarry + digit;
|
|
873
|
-
if (!Number.isSafeInteger(digitBase) || fromCarry / from14 !== carry || digitBase - digit !== fromCarry) {
|
|
874
|
-
throw new Error("convertRadix: carry overflow");
|
|
875
|
-
}
|
|
876
|
-
const div = digitBase / to;
|
|
877
|
-
carry = digitBase % to;
|
|
878
|
-
const rounded = Math.floor(div);
|
|
879
|
-
digits[i] = rounded;
|
|
880
|
-
if (!Number.isSafeInteger(rounded) || rounded * to + carry !== digitBase)
|
|
881
|
-
throw new Error("convertRadix: carry overflow");
|
|
882
|
-
if (!done)
|
|
883
|
-
continue;
|
|
884
|
-
else if (!rounded)
|
|
885
|
-
pos = i;
|
|
886
|
-
else
|
|
887
|
-
done = false;
|
|
888
|
-
}
|
|
889
|
-
res.push(carry);
|
|
890
|
-
if (done)
|
|
891
|
-
break;
|
|
892
|
-
}
|
|
893
|
-
for (let i = 0; i < data.length - 1 && data[i] === 0; i++)
|
|
894
|
-
res.push(0);
|
|
895
|
-
return res.reverse();
|
|
896
|
-
}
|
|
897
|
-
// @__NO_SIDE_EFFECTS__
|
|
898
|
-
function radix(num) {
|
|
899
|
-
anumber2(num);
|
|
900
|
-
const _256 = 2 ** 8;
|
|
901
|
-
return {
|
|
902
|
-
encode: (bytes) => {
|
|
903
|
-
if (!isBytes2(bytes))
|
|
904
|
-
throw new Error("radix.encode input should be Uint8Array");
|
|
905
|
-
return convertRadix(Array.from(bytes), _256, num);
|
|
906
|
-
},
|
|
907
|
-
decode: (digits) => {
|
|
908
|
-
anumArr("radix.decode", digits);
|
|
909
|
-
return Uint8Array.from(convertRadix(digits, num, _256));
|
|
910
|
-
}
|
|
911
|
-
};
|
|
912
|
-
}
|
|
913
|
-
var genBase58 = /* @__NO_SIDE_EFFECTS__ */ (abc) => /* @__PURE__ */ chain(/* @__PURE__ */ radix(58), /* @__PURE__ */ alphabet(abc), /* @__PURE__ */ join(""));
|
|
914
|
-
var base58 = /* @__PURE__ */ genBase58("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
|
|
915
|
-
|
|
916
|
-
// ../../node_modules/.pnpm/@mysten+utils@0.3.1/node_modules/@mysten/utils/dist/b58.mjs
|
|
917
|
-
var toBase58 = (buffer2) => base58.encode(buffer2);
|
|
918
|
-
var fromBase58 = (str) => base58.decode(str);
|
|
919
|
-
|
|
920
|
-
// ../../node_modules/.pnpm/@mysten+utils@0.3.1/node_modules/@mysten/utils/dist/b64.mjs
|
|
921
|
-
function fromBase64(base64String) {
|
|
922
|
-
return Uint8Array.from(atob(base64String), (char) => char.charCodeAt(0));
|
|
923
|
-
}
|
|
924
|
-
var CHUNK_SIZE = 8192;
|
|
925
|
-
function toBase64(bytes) {
|
|
926
|
-
if (bytes.length < CHUNK_SIZE) return btoa(String.fromCharCode(...bytes));
|
|
927
|
-
let output = "";
|
|
928
|
-
for (var i = 0; i < bytes.length; i += CHUNK_SIZE) {
|
|
929
|
-
const chunk = bytes.slice(i, i + CHUNK_SIZE);
|
|
930
|
-
output += String.fromCharCode(...chunk);
|
|
931
|
-
}
|
|
932
|
-
return btoa(output);
|
|
933
|
-
}
|
|
934
|
-
|
|
935
|
-
// ../../node_modules/.pnpm/@mysten+utils@0.3.1/node_modules/@mysten/utils/dist/hex.mjs
|
|
936
|
-
function fromHex2(hexStr) {
|
|
937
|
-
const normalized = hexStr.startsWith("0x") ? hexStr.slice(2) : hexStr;
|
|
938
|
-
const padded = normalized.length % 2 === 0 ? normalized : `0${normalized}`;
|
|
939
|
-
const intArr = padded.match(/[0-9a-fA-F]{2}/g)?.map((byte) => parseInt(byte, 16)) ?? [];
|
|
940
|
-
if (intArr.length !== padded.length / 2) throw new Error(`Invalid hex string ${hexStr}`);
|
|
941
|
-
return Uint8Array.from(intArr);
|
|
942
|
-
}
|
|
943
|
-
function toHex2(bytes) {
|
|
944
|
-
return bytes.reduce((str, byte) => str + byte.toString(16).padStart(2, "0"), "");
|
|
945
|
-
}
|
|
946
|
-
|
|
947
|
-
// ../../node_modules/.pnpm/@mysten+bcs@2.0.3/node_modules/@mysten/bcs/dist/utils.mjs
|
|
948
|
-
function encodeStr(data, encoding) {
|
|
949
|
-
switch (encoding) {
|
|
950
|
-
case "base58":
|
|
951
|
-
return toBase58(data);
|
|
952
|
-
case "base64":
|
|
953
|
-
return toBase64(data);
|
|
954
|
-
case "hex":
|
|
955
|
-
return toHex2(data);
|
|
956
|
-
default:
|
|
957
|
-
throw new Error("Unsupported encoding, supported values are: base64, hex");
|
|
958
|
-
}
|
|
959
|
-
}
|
|
960
|
-
|
|
961
|
-
// ../../node_modules/.pnpm/@mysten+bcs@2.0.3/node_modules/@mysten/bcs/dist/writer.mjs
|
|
962
|
-
var BcsWriter = class {
|
|
963
|
-
constructor({ initialSize = 1024, maxSize = Infinity, allocateSize = 1024 } = {}) {
|
|
964
|
-
this.bytePosition = 0;
|
|
965
|
-
this.size = initialSize;
|
|
966
|
-
this.maxSize = maxSize;
|
|
967
|
-
this.allocateSize = allocateSize;
|
|
968
|
-
this.dataView = new DataView(new ArrayBuffer(initialSize));
|
|
969
|
-
}
|
|
970
|
-
ensureSizeOrGrow(bytes) {
|
|
971
|
-
const requiredSize = this.bytePosition + bytes;
|
|
972
|
-
if (requiredSize > this.size) {
|
|
973
|
-
const nextSize = Math.min(this.maxSize, Math.max(this.size + requiredSize, this.size + this.allocateSize));
|
|
974
|
-
if (requiredSize > nextSize) throw new Error(`Attempting to serialize to BCS, but buffer does not have enough size. Allocated size: ${this.size}, Max size: ${this.maxSize}, Required size: ${requiredSize}`);
|
|
975
|
-
this.size = nextSize;
|
|
976
|
-
const nextBuffer = new ArrayBuffer(this.size);
|
|
977
|
-
new Uint8Array(nextBuffer).set(new Uint8Array(this.dataView.buffer));
|
|
978
|
-
this.dataView = new DataView(nextBuffer);
|
|
979
|
-
}
|
|
980
|
-
}
|
|
981
|
-
/**
|
|
982
|
-
* Shift current cursor position by `bytes`.
|
|
983
|
-
*
|
|
984
|
-
* @param {Number} bytes Number of bytes to
|
|
985
|
-
* @returns {this} Self for possible chaining.
|
|
986
|
-
*/
|
|
987
|
-
shift(bytes) {
|
|
988
|
-
this.bytePosition += bytes;
|
|
989
|
-
return this;
|
|
990
|
-
}
|
|
991
|
-
/**
|
|
992
|
-
* Write a U8 value into a buffer and shift cursor position by 1.
|
|
993
|
-
* @param {Number} value Value to write.
|
|
994
|
-
* @returns {this}
|
|
995
|
-
*/
|
|
996
|
-
write8(value) {
|
|
997
|
-
this.ensureSizeOrGrow(1);
|
|
998
|
-
this.dataView.setUint8(this.bytePosition, Number(value));
|
|
999
|
-
return this.shift(1);
|
|
1000
|
-
}
|
|
1001
|
-
/**
|
|
1002
|
-
* Write a U8 value into a buffer and shift cursor position by 1.
|
|
1003
|
-
* @param {Number} value Value to write.
|
|
1004
|
-
* @returns {this}
|
|
1005
|
-
*/
|
|
1006
|
-
writeBytes(bytes) {
|
|
1007
|
-
this.ensureSizeOrGrow(bytes.length);
|
|
1008
|
-
for (let i = 0; i < bytes.length; i++) this.dataView.setUint8(this.bytePosition + i, bytes[i]);
|
|
1009
|
-
return this.shift(bytes.length);
|
|
1010
|
-
}
|
|
1011
|
-
/**
|
|
1012
|
-
* Write a U16 value into a buffer and shift cursor position by 2.
|
|
1013
|
-
* @param {Number} value Value to write.
|
|
1014
|
-
* @returns {this}
|
|
1015
|
-
*/
|
|
1016
|
-
write16(value) {
|
|
1017
|
-
this.ensureSizeOrGrow(2);
|
|
1018
|
-
this.dataView.setUint16(this.bytePosition, Number(value), true);
|
|
1019
|
-
return this.shift(2);
|
|
1020
|
-
}
|
|
1021
|
-
/**
|
|
1022
|
-
* Write a U32 value into a buffer and shift cursor position by 4.
|
|
1023
|
-
* @param {Number} value Value to write.
|
|
1024
|
-
* @returns {this}
|
|
1025
|
-
*/
|
|
1026
|
-
write32(value) {
|
|
1027
|
-
this.ensureSizeOrGrow(4);
|
|
1028
|
-
this.dataView.setUint32(this.bytePosition, Number(value), true);
|
|
1029
|
-
return this.shift(4);
|
|
1030
|
-
}
|
|
1031
|
-
/**
|
|
1032
|
-
* Write a U64 value into a buffer and shift cursor position by 8.
|
|
1033
|
-
* @param {bigint} value Value to write.
|
|
1034
|
-
* @returns {this}
|
|
1035
|
-
*/
|
|
1036
|
-
write64(value) {
|
|
1037
|
-
toLittleEndian(BigInt(value), 8).forEach((el) => this.write8(el));
|
|
1038
|
-
return this;
|
|
1039
|
-
}
|
|
1040
|
-
/**
|
|
1041
|
-
* Write a U128 value into a buffer and shift cursor position by 16.
|
|
1042
|
-
*
|
|
1043
|
-
* @param {bigint} value Value to write.
|
|
1044
|
-
* @returns {this}
|
|
1045
|
-
*/
|
|
1046
|
-
write128(value) {
|
|
1047
|
-
toLittleEndian(BigInt(value), 16).forEach((el) => this.write8(el));
|
|
1048
|
-
return this;
|
|
1049
|
-
}
|
|
1050
|
-
/**
|
|
1051
|
-
* Write a U256 value into a buffer and shift cursor position by 16.
|
|
1052
|
-
*
|
|
1053
|
-
* @param {bigint} value Value to write.
|
|
1054
|
-
* @returns {this}
|
|
1055
|
-
*/
|
|
1056
|
-
write256(value) {
|
|
1057
|
-
toLittleEndian(BigInt(value), 32).forEach((el) => this.write8(el));
|
|
1058
|
-
return this;
|
|
1059
|
-
}
|
|
1060
|
-
/**
|
|
1061
|
-
* Write a ULEB value into a buffer and shift cursor position by number of bytes
|
|
1062
|
-
* written.
|
|
1063
|
-
* @param {Number} value Value to write.
|
|
1064
|
-
* @returns {this}
|
|
1065
|
-
*/
|
|
1066
|
-
writeULEB(value) {
|
|
1067
|
-
ulebEncode(value).forEach((el) => this.write8(el));
|
|
1068
|
-
return this;
|
|
1069
|
-
}
|
|
1070
|
-
/**
|
|
1071
|
-
* Write a vector into a buffer by first writing the vector length and then calling
|
|
1072
|
-
* a callback on each passed value.
|
|
1073
|
-
*
|
|
1074
|
-
* @param {Array<Any>} vector Array of elements to write.
|
|
1075
|
-
* @param {WriteVecCb} cb Callback to call on each element of the vector.
|
|
1076
|
-
* @returns {this}
|
|
1077
|
-
*/
|
|
1078
|
-
writeVec(vector2, cb) {
|
|
1079
|
-
this.writeULEB(vector2.length);
|
|
1080
|
-
Array.from(vector2).forEach((el, i) => cb(this, el, i, vector2.length));
|
|
1081
|
-
return this;
|
|
1082
|
-
}
|
|
1083
|
-
/**
|
|
1084
|
-
* Adds support for iterations over the object.
|
|
1085
|
-
* @returns {Uint8Array}
|
|
1086
|
-
*/
|
|
1087
|
-
*[Symbol.iterator]() {
|
|
1088
|
-
for (let i = 0; i < this.bytePosition; i++) yield this.dataView.getUint8(i);
|
|
1089
|
-
return this.toBytes();
|
|
1090
|
-
}
|
|
1091
|
-
/**
|
|
1092
|
-
* Get underlying buffer taking only value bytes (in case initial buffer size was bigger).
|
|
1093
|
-
* @returns {Uint8Array} Resulting bcs.
|
|
1094
|
-
*/
|
|
1095
|
-
toBytes() {
|
|
1096
|
-
return new Uint8Array(this.dataView.buffer.slice(0, this.bytePosition));
|
|
1097
|
-
}
|
|
1098
|
-
/**
|
|
1099
|
-
* Represent data as 'hex' or 'base64'
|
|
1100
|
-
* @param encoding Encoding to use: 'base64' or 'hex'
|
|
1101
|
-
*/
|
|
1102
|
-
toString(encoding) {
|
|
1103
|
-
return encodeStr(this.toBytes(), encoding);
|
|
1104
|
-
}
|
|
1105
|
-
};
|
|
1106
|
-
function toLittleEndian(bigint, size5) {
|
|
1107
|
-
const result2 = new Uint8Array(size5);
|
|
1108
|
-
let i = 0;
|
|
1109
|
-
while (bigint > 0) {
|
|
1110
|
-
result2[i] = Number(bigint % BigInt(256));
|
|
1111
|
-
bigint = bigint / BigInt(256);
|
|
1112
|
-
i += 1;
|
|
1113
|
-
}
|
|
1114
|
-
return result2;
|
|
1115
|
-
}
|
|
1116
|
-
|
|
1117
|
-
// ../../node_modules/.pnpm/@mysten+bcs@2.0.3/node_modules/@mysten/bcs/dist/bcs-type.mjs
|
|
1118
|
-
var BcsType = class BcsType2 {
|
|
1119
|
-
#write;
|
|
1120
|
-
#serialize;
|
|
1121
|
-
constructor(options) {
|
|
1122
|
-
this.name = options.name;
|
|
1123
|
-
this.read = options.read;
|
|
1124
|
-
this.serializedSize = options.serializedSize ?? (() => null);
|
|
1125
|
-
this.#write = options.write;
|
|
1126
|
-
this.#serialize = options.serialize ?? ((value, options$1) => {
|
|
1127
|
-
const writer = new BcsWriter({
|
|
1128
|
-
initialSize: this.serializedSize(value) ?? void 0,
|
|
1129
|
-
...options$1
|
|
1130
|
-
});
|
|
1131
|
-
this.#write(value, writer);
|
|
1132
|
-
return writer.toBytes();
|
|
1133
|
-
});
|
|
1134
|
-
this.validate = options.validate ?? (() => {
|
|
1135
|
-
});
|
|
1136
|
-
}
|
|
1137
|
-
write(value, writer) {
|
|
1138
|
-
this.validate(value);
|
|
1139
|
-
this.#write(value, writer);
|
|
1140
|
-
}
|
|
1141
|
-
serialize(value, options) {
|
|
1142
|
-
this.validate(value);
|
|
1143
|
-
return new SerializedBcs(this, this.#serialize(value, options));
|
|
1144
|
-
}
|
|
1145
|
-
parse(bytes) {
|
|
1146
|
-
const reader = new BcsReader(bytes);
|
|
1147
|
-
return this.read(reader);
|
|
1148
|
-
}
|
|
1149
|
-
fromHex(hex) {
|
|
1150
|
-
return this.parse(fromHex2(hex));
|
|
1151
|
-
}
|
|
1152
|
-
fromBase58(b64) {
|
|
1153
|
-
return this.parse(fromBase58(b64));
|
|
1154
|
-
}
|
|
1155
|
-
fromBase64(b64) {
|
|
1156
|
-
return this.parse(fromBase64(b64));
|
|
1157
|
-
}
|
|
1158
|
-
transform({ name, input, output, validate: validate6 }) {
|
|
1159
|
-
return new BcsType2({
|
|
1160
|
-
name: name ?? this.name,
|
|
1161
|
-
read: (reader) => output ? output(this.read(reader)) : this.read(reader),
|
|
1162
|
-
write: (value, writer) => this.#write(input ? input(value) : value, writer),
|
|
1163
|
-
serializedSize: (value) => this.serializedSize(input ? input(value) : value),
|
|
1164
|
-
serialize: (value, options) => this.#serialize(input ? input(value) : value, options),
|
|
1165
|
-
validate: (value) => {
|
|
1166
|
-
validate6?.(value);
|
|
1167
|
-
this.validate(input ? input(value) : value);
|
|
1168
|
-
}
|
|
1169
|
-
});
|
|
1170
|
-
}
|
|
1171
|
-
};
|
|
1172
|
-
var SERIALIZED_BCS_BRAND = /* @__PURE__ */ Symbol.for("@mysten/serialized-bcs");
|
|
1173
|
-
var SerializedBcs = class {
|
|
1174
|
-
#schema;
|
|
1175
|
-
#bytes;
|
|
1176
|
-
get [SERIALIZED_BCS_BRAND]() {
|
|
1177
|
-
return true;
|
|
1178
|
-
}
|
|
1179
|
-
constructor(schema, bytes) {
|
|
1180
|
-
this.#schema = schema;
|
|
1181
|
-
this.#bytes = bytes;
|
|
1182
|
-
}
|
|
1183
|
-
toBytes() {
|
|
1184
|
-
return this.#bytes;
|
|
1185
|
-
}
|
|
1186
|
-
toHex() {
|
|
1187
|
-
return toHex2(this.#bytes);
|
|
1188
|
-
}
|
|
1189
|
-
toBase64() {
|
|
1190
|
-
return toBase64(this.#bytes);
|
|
1191
|
-
}
|
|
1192
|
-
toBase58() {
|
|
1193
|
-
return toBase58(this.#bytes);
|
|
1194
|
-
}
|
|
1195
|
-
parse() {
|
|
1196
|
-
return this.#schema.parse(this.#bytes);
|
|
1197
|
-
}
|
|
1198
|
-
};
|
|
1199
|
-
function fixedSizeBcsType({ size: size5, ...options }) {
|
|
1200
|
-
return new BcsType({
|
|
1201
|
-
...options,
|
|
1202
|
-
serializedSize: () => size5
|
|
1203
|
-
});
|
|
1204
|
-
}
|
|
1205
|
-
function uIntBcsType({ readMethod, writeMethod, ...options }) {
|
|
1206
|
-
return fixedSizeBcsType({
|
|
1207
|
-
...options,
|
|
1208
|
-
read: (reader) => reader[readMethod](),
|
|
1209
|
-
write: (value, writer) => writer[writeMethod](value),
|
|
1210
|
-
validate: (value) => {
|
|
1211
|
-
if (value < 0 || value > options.maxValue) throw new TypeError(`Invalid ${options.name} value: ${value}. Expected value in range 0-${options.maxValue}`);
|
|
1212
|
-
options.validate?.(value);
|
|
1213
|
-
}
|
|
1214
|
-
});
|
|
1215
|
-
}
|
|
1216
|
-
function bigUIntBcsType({ readMethod, writeMethod, ...options }) {
|
|
1217
|
-
return fixedSizeBcsType({
|
|
1218
|
-
...options,
|
|
1219
|
-
read: (reader) => reader[readMethod](),
|
|
1220
|
-
write: (value, writer) => writer[writeMethod](BigInt(value)),
|
|
1221
|
-
validate: (val) => {
|
|
1222
|
-
const value = BigInt(val);
|
|
1223
|
-
if (value < 0 || value > options.maxValue) throw new TypeError(`Invalid ${options.name} value: ${value}. Expected value in range 0-${options.maxValue}`);
|
|
1224
|
-
options.validate?.(value);
|
|
1225
|
-
}
|
|
1226
|
-
});
|
|
1227
|
-
}
|
|
1228
|
-
function dynamicSizeBcsType({ serialize, ...options }) {
|
|
1229
|
-
const type = new BcsType({
|
|
1230
|
-
...options,
|
|
1231
|
-
serialize,
|
|
1232
|
-
write: (value, writer) => {
|
|
1233
|
-
for (const byte of type.serialize(value).toBytes()) writer.write8(byte);
|
|
1234
|
-
}
|
|
1235
|
-
});
|
|
1236
|
-
return type;
|
|
1237
|
-
}
|
|
1238
|
-
function stringLikeBcsType({ toBytes: toBytes3, fromBytes: fromBytes4, ...options }) {
|
|
1239
|
-
return new BcsType({
|
|
1240
|
-
...options,
|
|
1241
|
-
read: (reader) => {
|
|
1242
|
-
const length = reader.readULEB();
|
|
1243
|
-
return fromBytes4(reader.readBytes(length));
|
|
1244
|
-
},
|
|
1245
|
-
write: (hex, writer) => {
|
|
1246
|
-
const bytes = toBytes3(hex);
|
|
1247
|
-
writer.writeULEB(bytes.length);
|
|
1248
|
-
for (let i = 0; i < bytes.length; i++) writer.write8(bytes[i]);
|
|
1249
|
-
},
|
|
1250
|
-
serialize: (value) => {
|
|
1251
|
-
const bytes = toBytes3(value);
|
|
1252
|
-
const size5 = ulebEncode(bytes.length);
|
|
1253
|
-
const result2 = new Uint8Array(size5.length + bytes.length);
|
|
1254
|
-
result2.set(size5, 0);
|
|
1255
|
-
result2.set(bytes, size5.length);
|
|
1256
|
-
return result2;
|
|
1257
|
-
},
|
|
1258
|
-
validate: (value) => {
|
|
1259
|
-
if (typeof value !== "string") throw new TypeError(`Invalid ${options.name} value: ${value}. Expected string`);
|
|
1260
|
-
options.validate?.(value);
|
|
1261
|
-
}
|
|
1262
|
-
});
|
|
1263
|
-
}
|
|
1264
|
-
function lazyBcsType(cb) {
|
|
1265
|
-
let lazyType = null;
|
|
1266
|
-
function getType() {
|
|
1267
|
-
if (!lazyType) lazyType = cb();
|
|
1268
|
-
return lazyType;
|
|
1269
|
-
}
|
|
1270
|
-
return new BcsType({
|
|
1271
|
-
name: "lazy",
|
|
1272
|
-
read: (data) => getType().read(data),
|
|
1273
|
-
serializedSize: (value) => getType().serializedSize(value),
|
|
1274
|
-
write: (value, writer) => getType().write(value, writer),
|
|
1275
|
-
serialize: (value, options) => getType().serialize(value, options).toBytes()
|
|
1276
|
-
});
|
|
1277
|
-
}
|
|
1278
|
-
var BcsStruct = class extends BcsType {
|
|
1279
|
-
constructor({ name, fields, ...options }) {
|
|
1280
|
-
const canonicalOrder = Object.entries(fields);
|
|
1281
|
-
super({
|
|
1282
|
-
name,
|
|
1283
|
-
serializedSize: (values) => {
|
|
1284
|
-
let total = 0;
|
|
1285
|
-
for (const [field, type] of canonicalOrder) {
|
|
1286
|
-
const size5 = type.serializedSize(values[field]);
|
|
1287
|
-
if (size5 == null) return null;
|
|
1288
|
-
total += size5;
|
|
1289
|
-
}
|
|
1290
|
-
return total;
|
|
1291
|
-
},
|
|
1292
|
-
read: (reader) => {
|
|
1293
|
-
const result2 = {};
|
|
1294
|
-
for (const [field, type] of canonicalOrder) result2[field] = type.read(reader);
|
|
1295
|
-
return result2;
|
|
1296
|
-
},
|
|
1297
|
-
write: (value, writer) => {
|
|
1298
|
-
for (const [field, type] of canonicalOrder) type.write(value[field], writer);
|
|
1299
|
-
},
|
|
1300
|
-
...options,
|
|
1301
|
-
validate: (value) => {
|
|
1302
|
-
options?.validate?.(value);
|
|
1303
|
-
if (typeof value !== "object" || value == null) throw new TypeError(`Expected object, found ${typeof value}`);
|
|
1304
|
-
}
|
|
1305
|
-
});
|
|
1306
|
-
}
|
|
1307
|
-
};
|
|
1308
|
-
var BcsEnum = class extends BcsType {
|
|
1309
|
-
constructor({ fields, ...options }) {
|
|
1310
|
-
const canonicalOrder = Object.entries(fields);
|
|
1311
|
-
super({
|
|
1312
|
-
read: (reader) => {
|
|
1313
|
-
const index2 = reader.readULEB();
|
|
1314
|
-
const enumEntry = canonicalOrder[index2];
|
|
1315
|
-
if (!enumEntry) throw new TypeError(`Unknown value ${index2} for enum ${options.name}`);
|
|
1316
|
-
const [kind, type] = enumEntry;
|
|
1317
|
-
return {
|
|
1318
|
-
[kind]: type?.read(reader) ?? true,
|
|
1319
|
-
$kind: kind
|
|
1320
|
-
};
|
|
1321
|
-
},
|
|
1322
|
-
write: (value, writer) => {
|
|
1323
|
-
const [name, val] = Object.entries(value).filter(([name$1]) => Object.hasOwn(fields, name$1))[0];
|
|
1324
|
-
for (let i = 0; i < canonicalOrder.length; i++) {
|
|
1325
|
-
const [optionName2, optionType] = canonicalOrder[i];
|
|
1326
|
-
if (optionName2 === name) {
|
|
1327
|
-
writer.writeULEB(i);
|
|
1328
|
-
optionType?.write(val, writer);
|
|
1329
|
-
return;
|
|
1330
|
-
}
|
|
1331
|
-
}
|
|
1332
|
-
},
|
|
1333
|
-
...options,
|
|
1334
|
-
validate: (value) => {
|
|
1335
|
-
options?.validate?.(value);
|
|
1336
|
-
if (typeof value !== "object" || value == null) throw new TypeError(`Expected object, found ${typeof value}`);
|
|
1337
|
-
const keys = Object.keys(value).filter((k) => value[k] !== void 0 && Object.hasOwn(fields, k));
|
|
1338
|
-
if (keys.length !== 1) throw new TypeError(`Expected object with one key, but found ${keys.length} for type ${options.name}}`);
|
|
1339
|
-
const [variant] = keys;
|
|
1340
|
-
if (!Object.hasOwn(fields, variant)) throw new TypeError(`Invalid enum variant ${variant}`);
|
|
1341
|
-
}
|
|
1342
|
-
});
|
|
1343
|
-
}
|
|
1344
|
-
};
|
|
1345
|
-
var BcsTuple = class extends BcsType {
|
|
1346
|
-
constructor({ fields, name, ...options }) {
|
|
1347
|
-
super({
|
|
1348
|
-
name: name ?? `(${fields.map((t) => t.name).join(", ")})`,
|
|
1349
|
-
serializedSize: (values) => {
|
|
1350
|
-
let total = 0;
|
|
1351
|
-
for (let i = 0; i < fields.length; i++) {
|
|
1352
|
-
const size5 = fields[i].serializedSize(values[i]);
|
|
1353
|
-
if (size5 == null) return null;
|
|
1354
|
-
total += size5;
|
|
1355
|
-
}
|
|
1356
|
-
return total;
|
|
1357
|
-
},
|
|
1358
|
-
read: (reader) => {
|
|
1359
|
-
const result2 = [];
|
|
1360
|
-
for (const field of fields) result2.push(field.read(reader));
|
|
1361
|
-
return result2;
|
|
1362
|
-
},
|
|
1363
|
-
write: (value, writer) => {
|
|
1364
|
-
for (let i = 0; i < fields.length; i++) fields[i].write(value[i], writer);
|
|
1365
|
-
},
|
|
1366
|
-
...options,
|
|
1367
|
-
validate: (value) => {
|
|
1368
|
-
options?.validate?.(value);
|
|
1369
|
-
if (!Array.isArray(value)) throw new TypeError(`Expected array, found ${typeof value}`);
|
|
1370
|
-
if (value.length !== fields.length) throw new TypeError(`Expected array of length ${fields.length}, found ${value.length}`);
|
|
1371
|
-
}
|
|
1372
|
-
});
|
|
1373
|
-
}
|
|
1374
|
-
};
|
|
1375
|
-
|
|
1376
|
-
// ../../node_modules/.pnpm/@mysten+bcs@2.0.3/node_modules/@mysten/bcs/dist/bcs.mjs
|
|
1377
|
-
function fixedArray(size5, type, options) {
|
|
1378
|
-
return new BcsType({
|
|
1379
|
-
read: (reader) => {
|
|
1380
|
-
const result2 = new Array(size5);
|
|
1381
|
-
for (let i = 0; i < size5; i++) result2[i] = type.read(reader);
|
|
1382
|
-
return result2;
|
|
1383
|
-
},
|
|
1384
|
-
write: (value, writer) => {
|
|
1385
|
-
for (const item of value) type.write(item, writer);
|
|
1386
|
-
},
|
|
1387
|
-
...options,
|
|
1388
|
-
name: options?.name ?? `${type.name}[${size5}]`,
|
|
1389
|
-
validate: (value) => {
|
|
1390
|
-
options?.validate?.(value);
|
|
1391
|
-
if (!value || typeof value !== "object" || !("length" in value)) throw new TypeError(`Expected array, found ${typeof value}`);
|
|
1392
|
-
if (value.length !== size5) throw new TypeError(`Expected array of length ${size5}, found ${value.length}`);
|
|
1393
|
-
}
|
|
1394
|
-
});
|
|
1395
|
-
}
|
|
1396
|
-
function option(type) {
|
|
1397
|
-
return bcs.enum(`Option<${type.name}>`, {
|
|
1398
|
-
None: null,
|
|
1399
|
-
Some: type
|
|
1400
|
-
}).transform({
|
|
1401
|
-
input: (value) => {
|
|
1402
|
-
if (value == null) return { None: true };
|
|
1403
|
-
return { Some: value };
|
|
1404
|
-
},
|
|
1405
|
-
output: (value) => {
|
|
1406
|
-
if (value.$kind === "Some") return value.Some;
|
|
1407
|
-
return null;
|
|
1408
|
-
}
|
|
1409
|
-
});
|
|
1410
|
-
}
|
|
1411
|
-
function vector(type, options) {
|
|
1412
|
-
return new BcsType({
|
|
1413
|
-
read: (reader) => {
|
|
1414
|
-
const length = reader.readULEB();
|
|
1415
|
-
const result2 = new Array(length);
|
|
1416
|
-
for (let i = 0; i < length; i++) result2[i] = type.read(reader);
|
|
1417
|
-
return result2;
|
|
1418
|
-
},
|
|
1419
|
-
write: (value, writer) => {
|
|
1420
|
-
writer.writeULEB(value.length);
|
|
1421
|
-
for (const item of value) type.write(item, writer);
|
|
1422
|
-
},
|
|
1423
|
-
...options,
|
|
1424
|
-
name: options?.name ?? `vector<${type.name}>`,
|
|
1425
|
-
validate: (value) => {
|
|
1426
|
-
options?.validate?.(value);
|
|
1427
|
-
if (!value || typeof value !== "object" || !("length" in value)) throw new TypeError(`Expected array, found ${typeof value}`);
|
|
1428
|
-
}
|
|
1429
|
-
});
|
|
1430
|
-
}
|
|
1431
|
-
function compareBcsBytes(a, b) {
|
|
1432
|
-
for (let i = 0; i < Math.min(a.length, b.length); i++) if (a[i] !== b[i]) return a[i] - b[i];
|
|
1433
|
-
return a.length - b.length;
|
|
1434
|
-
}
|
|
1435
|
-
function map(keyType, valueType) {
|
|
1436
|
-
return new BcsType({
|
|
1437
|
-
name: `Map<${keyType.name}, ${valueType.name}>`,
|
|
1438
|
-
read: (reader) => {
|
|
1439
|
-
const length = reader.readULEB();
|
|
1440
|
-
const result2 = /* @__PURE__ */ new Map();
|
|
1441
|
-
for (let i = 0; i < length; i++) result2.set(keyType.read(reader), valueType.read(reader));
|
|
1442
|
-
return result2;
|
|
1443
|
-
},
|
|
1444
|
-
write: (value, writer) => {
|
|
1445
|
-
const entries = [...value.entries()].map(([key, val]) => [keyType.serialize(key).toBytes(), val]);
|
|
1446
|
-
entries.sort(([a], [b]) => compareBcsBytes(a, b));
|
|
1447
|
-
writer.writeULEB(entries.length);
|
|
1448
|
-
for (const [keyBytes, val] of entries) {
|
|
1449
|
-
writer.writeBytes(keyBytes);
|
|
1450
|
-
valueType.write(val, writer);
|
|
1451
|
-
}
|
|
1452
|
-
}
|
|
1453
|
-
});
|
|
1454
|
-
}
|
|
1455
|
-
var bcs = {
|
|
1456
|
-
u8(options) {
|
|
1457
|
-
return uIntBcsType({
|
|
1458
|
-
readMethod: "read8",
|
|
1459
|
-
writeMethod: "write8",
|
|
1460
|
-
size: 1,
|
|
1461
|
-
maxValue: 2 ** 8 - 1,
|
|
1462
|
-
...options,
|
|
1463
|
-
name: options?.name ?? "u8"
|
|
1464
|
-
});
|
|
1465
|
-
},
|
|
1466
|
-
u16(options) {
|
|
1467
|
-
return uIntBcsType({
|
|
1468
|
-
readMethod: "read16",
|
|
1469
|
-
writeMethod: "write16",
|
|
1470
|
-
size: 2,
|
|
1471
|
-
maxValue: 2 ** 16 - 1,
|
|
1472
|
-
...options,
|
|
1473
|
-
name: options?.name ?? "u16"
|
|
1474
|
-
});
|
|
1475
|
-
},
|
|
1476
|
-
u32(options) {
|
|
1477
|
-
return uIntBcsType({
|
|
1478
|
-
readMethod: "read32",
|
|
1479
|
-
writeMethod: "write32",
|
|
1480
|
-
size: 4,
|
|
1481
|
-
maxValue: 2 ** 32 - 1,
|
|
1482
|
-
...options,
|
|
1483
|
-
name: options?.name ?? "u32"
|
|
1484
|
-
});
|
|
1485
|
-
},
|
|
1486
|
-
u64(options) {
|
|
1487
|
-
return bigUIntBcsType({
|
|
1488
|
-
readMethod: "read64",
|
|
1489
|
-
writeMethod: "write64",
|
|
1490
|
-
size: 8,
|
|
1491
|
-
maxValue: 2n ** 64n - 1n,
|
|
1492
|
-
...options,
|
|
1493
|
-
name: options?.name ?? "u64"
|
|
1494
|
-
});
|
|
1495
|
-
},
|
|
1496
|
-
u128(options) {
|
|
1497
|
-
return bigUIntBcsType({
|
|
1498
|
-
readMethod: "read128",
|
|
1499
|
-
writeMethod: "write128",
|
|
1500
|
-
size: 16,
|
|
1501
|
-
maxValue: 2n ** 128n - 1n,
|
|
1502
|
-
...options,
|
|
1503
|
-
name: options?.name ?? "u128"
|
|
1504
|
-
});
|
|
1505
|
-
},
|
|
1506
|
-
u256(options) {
|
|
1507
|
-
return bigUIntBcsType({
|
|
1508
|
-
readMethod: "read256",
|
|
1509
|
-
writeMethod: "write256",
|
|
1510
|
-
size: 32,
|
|
1511
|
-
maxValue: 2n ** 256n - 1n,
|
|
1512
|
-
...options,
|
|
1513
|
-
name: options?.name ?? "u256"
|
|
1514
|
-
});
|
|
1515
|
-
},
|
|
1516
|
-
bool(options) {
|
|
1517
|
-
return fixedSizeBcsType({
|
|
1518
|
-
size: 1,
|
|
1519
|
-
read: (reader) => reader.read8() === 1,
|
|
1520
|
-
write: (value, writer) => writer.write8(value ? 1 : 0),
|
|
1521
|
-
...options,
|
|
1522
|
-
name: options?.name ?? "bool",
|
|
1523
|
-
validate: (value) => {
|
|
1524
|
-
options?.validate?.(value);
|
|
1525
|
-
if (typeof value !== "boolean") throw new TypeError(`Expected boolean, found ${typeof value}`);
|
|
1526
|
-
}
|
|
1527
|
-
});
|
|
1528
|
-
},
|
|
1529
|
-
uleb128(options) {
|
|
1530
|
-
return dynamicSizeBcsType({
|
|
1531
|
-
read: (reader) => reader.readULEB(),
|
|
1532
|
-
serialize: (value) => {
|
|
1533
|
-
return Uint8Array.from(ulebEncode(value));
|
|
1534
|
-
},
|
|
1535
|
-
...options,
|
|
1536
|
-
name: options?.name ?? "uleb128"
|
|
1537
|
-
});
|
|
1538
|
-
},
|
|
1539
|
-
bytes(size5, options) {
|
|
1540
|
-
return fixedSizeBcsType({
|
|
1541
|
-
size: size5,
|
|
1542
|
-
read: (reader) => reader.readBytes(size5),
|
|
1543
|
-
write: (value, writer) => {
|
|
1544
|
-
writer.writeBytes(new Uint8Array(value));
|
|
1545
|
-
},
|
|
1546
|
-
...options,
|
|
1547
|
-
name: options?.name ?? `bytes[${size5}]`,
|
|
1548
|
-
validate: (value) => {
|
|
1549
|
-
options?.validate?.(value);
|
|
1550
|
-
if (!value || typeof value !== "object" || !("length" in value)) throw new TypeError(`Expected array, found ${typeof value}`);
|
|
1551
|
-
if (value.length !== size5) throw new TypeError(`Expected array of length ${size5}, found ${value.length}`);
|
|
1552
|
-
}
|
|
1553
|
-
});
|
|
1554
|
-
},
|
|
1555
|
-
byteVector(options) {
|
|
1556
|
-
return new BcsType({
|
|
1557
|
-
read: (reader) => {
|
|
1558
|
-
const length = reader.readULEB();
|
|
1559
|
-
return reader.readBytes(length);
|
|
1560
|
-
},
|
|
1561
|
-
write: (value, writer) => {
|
|
1562
|
-
const array = new Uint8Array(value);
|
|
1563
|
-
writer.writeULEB(array.length);
|
|
1564
|
-
writer.writeBytes(array);
|
|
1565
|
-
},
|
|
1566
|
-
...options,
|
|
1567
|
-
name: options?.name ?? "vector<u8>",
|
|
1568
|
-
serializedSize: (value) => {
|
|
1569
|
-
const length = "length" in value ? value.length : null;
|
|
1570
|
-
return length == null ? null : ulebEncode(length).length + length;
|
|
1571
|
-
},
|
|
1572
|
-
validate: (value) => {
|
|
1573
|
-
options?.validate?.(value);
|
|
1574
|
-
if (!value || typeof value !== "object" || !("length" in value)) throw new TypeError(`Expected array, found ${typeof value}`);
|
|
1575
|
-
}
|
|
1576
|
-
});
|
|
1577
|
-
},
|
|
1578
|
-
string(options) {
|
|
1579
|
-
return stringLikeBcsType({
|
|
1580
|
-
toBytes: (value) => new TextEncoder().encode(value),
|
|
1581
|
-
fromBytes: (bytes) => new TextDecoder().decode(bytes),
|
|
1582
|
-
...options,
|
|
1583
|
-
name: options?.name ?? "string"
|
|
1584
|
-
});
|
|
1585
|
-
},
|
|
1586
|
-
fixedArray,
|
|
1587
|
-
option,
|
|
1588
|
-
vector,
|
|
1589
|
-
tuple(fields, options) {
|
|
1590
|
-
return new BcsTuple({
|
|
1591
|
-
fields,
|
|
1592
|
-
...options
|
|
1593
|
-
});
|
|
1594
|
-
},
|
|
1595
|
-
struct(name, fields, options) {
|
|
1596
|
-
return new BcsStruct({
|
|
1597
|
-
name,
|
|
1598
|
-
fields,
|
|
1599
|
-
...options
|
|
1600
|
-
});
|
|
1601
|
-
},
|
|
1602
|
-
enum(name, fields, options) {
|
|
1603
|
-
return new BcsEnum({
|
|
1604
|
-
name,
|
|
1605
|
-
fields,
|
|
1606
|
-
...options
|
|
1607
|
-
});
|
|
1608
|
-
},
|
|
1609
|
-
map,
|
|
1610
|
-
lazy(cb) {
|
|
1611
|
-
return lazyBcsType(cb);
|
|
1612
|
-
}
|
|
1613
|
-
};
|
|
1614
|
-
|
|
1615
|
-
// ../../packages/fast-schema/dist/index.mjs
|
|
1616
|
-
import { Schema as Schema10 } from "effect";
|
|
1617
|
-
import { Schema as Schema13 } from "effect";
|
|
1618
|
-
import { Schema as Schema12 } from "effect";
|
|
1619
|
-
import { Schema as Schema11 } from "effect";
|
|
1620
|
-
import { Schema as Schema14 } from "effect";
|
|
1621
|
-
import { Schema as Schema15 } from "effect";
|
|
1622
|
-
import { Schema as Schema16 } from "effect";
|
|
1623
|
-
import { Schema as Schema17 } from "effect";
|
|
1624
|
-
var __defProp = Object.defineProperty;
|
|
1625
|
-
var __export2 = (target, all) => {
|
|
1626
|
-
for (var name in all)
|
|
1627
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
1628
|
-
};
|
|
1629
|
-
var Uint8ArrayFromNumberArray = Schema.transform(Schema.Array(Schema.Number), Schema.Uint8ArrayFromSelf, {
|
|
1630
|
-
strict: true,
|
|
1631
|
-
decode: (arr) => new Uint8Array(arr),
|
|
1632
|
-
encode: (buf) => Array.from(buf)
|
|
1633
|
-
});
|
|
1634
|
-
var Uint8ArrayFromBase64 = Schema.Uint8ArrayFromBase64;
|
|
1635
|
-
var Uint8ArrayFromHex = Schema.Uint8ArrayFromHex;
|
|
1636
|
-
var Strip0xHex = Schema.transform(Schema.String, Schema.String, {
|
|
1637
|
-
strict: true,
|
|
1638
|
-
decode: (s) => s.startsWith("0x") || s.startsWith("0X") ? s.slice(2) : s,
|
|
1639
|
-
encode: (s) => s
|
|
1640
|
-
});
|
|
1641
|
-
var Uint8ArrayFromHexOptional0x = Schema.compose(Strip0xHex, Uint8ArrayFromHex);
|
|
1642
|
-
var Uint8ArrayFromBech32m = (hrp) => Schema.transformOrFail(Schema.String, Schema.Uint8ArrayFromSelf, {
|
|
1643
|
-
strict: true,
|
|
1644
|
-
decode: (encoded, _options, ast) => {
|
|
1645
|
-
let result2;
|
|
1646
|
-
try {
|
|
1647
|
-
result2 = bech32m.decode(encoded);
|
|
1648
|
-
} catch (e) {
|
|
1649
|
-
const error = e instanceof Error ? e.message : String(e);
|
|
1650
|
-
const message2 = `Failed to decode bech32m: ${error}`;
|
|
1651
|
-
const failure = new ParseResult.Type(ast, encoded, message2);
|
|
1652
|
-
return ParseResult.fail(failure);
|
|
1653
|
-
}
|
|
1654
|
-
const prefix = result2.prefix;
|
|
1655
|
-
const words = result2.words;
|
|
1656
|
-
if (prefix !== hrp) {
|
|
1657
|
-
const message2 = `Expected bech32m prefix "${hrp}", got "${prefix}"`;
|
|
1658
|
-
const failure = new ParseResult.Type(ast, encoded, message2);
|
|
1659
|
-
return ParseResult.fail(failure);
|
|
1660
|
-
}
|
|
1661
|
-
const array = new Uint8Array(bech32m.fromWords(words));
|
|
1662
|
-
return ParseResult.succeed(array);
|
|
1663
|
-
},
|
|
1664
|
-
encode: (data, _options, ast) => {
|
|
1665
|
-
let words;
|
|
1666
|
-
try {
|
|
1667
|
-
words = bech32m.toWords(data);
|
|
1668
|
-
} catch (e) {
|
|
1669
|
-
const error = e instanceof Error ? e.message : String(e);
|
|
1670
|
-
const message2 = `Failed to encode bech32m: ${error}`;
|
|
1671
|
-
const inner = new ParseResult.Type(ast, data, message2);
|
|
1672
|
-
const failure = new ParseResult.Transformation(ast, data, "Transformation", inner);
|
|
1673
|
-
return ParseResult.fail(failure);
|
|
1674
|
-
}
|
|
1675
|
-
return ParseResult.succeed(bech32m.encode(hrp, words));
|
|
1676
|
-
}
|
|
1677
|
-
});
|
|
1678
|
-
var FixedUint8Array = (n) => Schema.Uint8ArrayFromSelf.pipe(
|
|
1679
|
-
Schema.filter((a) => a.length === n, {
|
|
1680
|
-
message: () => `Expected exactly ${n} bytes`
|
|
1681
|
-
}),
|
|
1682
|
-
Schema.brand(`Uint8Array${n}`)
|
|
1683
|
-
);
|
|
1684
|
-
var FixedUint8ArrayFromNumberArray = (n) => Schema.compose(Uint8ArrayFromNumberArray, FixedUint8Array(n));
|
|
1685
|
-
var FixedUint8ArrayFromHex = (n) => Schema.compose(Uint8ArrayFromHex, FixedUint8Array(n));
|
|
1686
|
-
var FixedUint8ArrayFromHexOptional0x = (n) => Schema.compose(Uint8ArrayFromHexOptional0x, FixedUint8Array(n));
|
|
1687
|
-
var DecimalBigInt = Schema2.BigInt;
|
|
1688
|
-
var HexBigInt = Schema2.transform(Schema2.String, Schema2.BigIntFromSelf, {
|
|
1689
|
-
strict: true,
|
|
1690
|
-
decode: (s) => {
|
|
1691
|
-
const sign2 = s[0] === "-" ? -1n : 1n;
|
|
1692
|
-
const digits = s[0] === "-" ? s.slice(1) : s;
|
|
1693
|
-
return sign2 * BigInt(`0x${digits}`);
|
|
1694
|
-
},
|
|
1695
|
-
encode: (n) => n.toString(16)
|
|
1696
|
-
});
|
|
1697
|
-
var DecimalNumber = Schema2.NumberFromString;
|
|
1698
|
-
var HexNumber = Schema2.transform(Schema2.String, Schema2.Number, {
|
|
1699
|
-
strict: true,
|
|
1700
|
-
decode: (s) => Number(`0x${s}`),
|
|
1701
|
-
encode: (n) => n.toString(16)
|
|
1702
|
-
});
|
|
1703
|
-
var BigIntFromNumberOrSelf = Schema2.transform(Schema2.Union(Schema2.Number, Schema2.BigIntFromSelf), Schema2.BigIntFromSelf, {
|
|
1704
|
-
strict: true,
|
|
1705
|
-
decode: (n) => typeof n === "bigint" ? n : BigInt(n),
|
|
1706
|
-
encode: (n) => n
|
|
1707
|
-
});
|
|
1708
|
-
var UintNumber = (bits) => Schema2.Number.pipe(Schema2.int(), Schema2.between(0, 2 ** bits - 1), Schema2.brand(`Uint${bits}`));
|
|
1709
|
-
var IntNumber = (bits) => Schema2.Number.pipe(Schema2.int(), Schema2.between(-(2 ** (bits - 1)), 2 ** (bits - 1) - 1), Schema2.brand(`Int${bits}`));
|
|
1710
|
-
var UintBigInt = (bits) => Schema2.BigIntFromSelf.pipe(Schema2.betweenBigInt(0n, 2n ** BigInt(bits) - 1n), Schema2.brand(`Uint${bits}`));
|
|
1711
|
-
var IntBigInt = (bits) => Schema2.BigIntFromSelf.pipe(Schema2.betweenBigInt(-(2n ** BigInt(bits - 1)), 2n ** BigInt(bits - 1) - 1n), Schema2.brand(`Int${bits}`));
|
|
1712
|
-
var HexUintBigInt = (bits) => Schema2.compose(HexBigInt, UintBigInt(bits));
|
|
1713
|
-
var HexIntBigInt = (bits) => Schema2.compose(HexBigInt, IntBigInt(bits));
|
|
1714
|
-
var DecimalUintBigInt = (bits) => Schema2.compose(DecimalBigInt, UintBigInt(bits));
|
|
1715
|
-
var DecimalIntBigInt = (bits) => Schema2.compose(DecimalBigInt, IntBigInt(bits));
|
|
1716
|
-
var UintBigIntFromNumberOrSelf = (bits) => Schema2.compose(BigIntFromNumberOrSelf, UintBigInt(bits));
|
|
1717
|
-
var IntBigIntFromNumberOrSelf = (bits) => Schema2.compose(BigIntFromNumberOrSelf, IntBigInt(bits));
|
|
1718
|
-
var Uint8Array32 = FixedUint8Array(32);
|
|
1719
|
-
var Uint8Array64 = FixedUint8Array(64);
|
|
1720
|
-
var Uint8Array32FromNumberArray = FixedUint8ArrayFromNumberArray(32);
|
|
1721
|
-
var Uint8Array32FromHex = FixedUint8ArrayFromHex(32);
|
|
1722
|
-
var Uint8Array32FromHex0x = FixedUint8ArrayFromHexOptional0x(32);
|
|
1723
|
-
var Uint8Array64FromNumberArray = FixedUint8ArrayFromNumberArray(64);
|
|
1724
|
-
var Uint8Array64FromHex0x = FixedUint8ArrayFromHexOptional0x(64);
|
|
1725
|
-
var Uint8Array64FromHex = FixedUint8ArrayFromHex(64);
|
|
1726
|
-
var Uint8 = UintNumber(8);
|
|
1727
|
-
var Uint16 = UintNumber(16);
|
|
1728
|
-
var Uint32 = UintNumber(32);
|
|
1729
|
-
var Int32 = IntNumber(32);
|
|
1730
|
-
var Uint64 = UintBigInt(64);
|
|
1731
|
-
var Int64 = IntBigInt(64);
|
|
1732
|
-
var Uint128 = UintBigInt(128);
|
|
1733
|
-
var Uint256 = UintBigInt(256);
|
|
1734
|
-
var Int320 = IntBigInt(320);
|
|
1735
|
-
var HexUint64 = HexUintBigInt(64);
|
|
1736
|
-
var HexUint256 = HexUintBigInt(256);
|
|
1737
|
-
var HexInt320 = HexIntBigInt(320);
|
|
1738
|
-
var DecimalUint64 = DecimalUintBigInt(64);
|
|
1739
|
-
var DecimalUint256 = DecimalUintBigInt(256);
|
|
1740
|
-
var DecimalInt320 = DecimalIntBigInt(320);
|
|
1741
|
-
var Uint64FromNumberOrSelf = UintBigIntFromNumberOrSelf(64);
|
|
1742
|
-
var Uint256FromNumberOrSelf = UintBigIntFromNumberOrSelf(256);
|
|
1743
|
-
var Int320FromNumberOrSelf = IntBigIntFromNumberOrSelf(320);
|
|
1744
|
-
var CamelCaseStruct = (fields) => {
|
|
1745
|
-
const structFields = {};
|
|
1746
|
-
for (const key of Object.keys(fields)) {
|
|
1747
|
-
const schema = fields[key];
|
|
1748
|
-
const camelKey = Str.snakeToCamel(key);
|
|
1749
|
-
if (camelKey !== key) {
|
|
1750
|
-
structFields[camelKey] = Schema3.propertySignature(schema).pipe(Schema3.fromKey(key));
|
|
1751
|
-
} else {
|
|
1752
|
-
structFields[camelKey] = schema;
|
|
1753
|
-
}
|
|
1754
|
-
}
|
|
1755
|
-
return Schema3.Struct(structFields);
|
|
1756
|
-
};
|
|
1757
|
-
var KeyedVariantSchema = Schema4.Union(Schema4.Record({ key: Schema4.String, value: Schema4.Unknown }), Schema4.String);
|
|
1758
|
-
var TypedVariantSchema = Schema4.Struct({
|
|
1759
|
-
type: Schema4.String,
|
|
1760
|
-
value: Schema4.optional(Schema4.Unknown)
|
|
1761
|
-
});
|
|
1762
|
-
var TypedVariant = (variants, options) => {
|
|
1763
|
-
const bcsMode = options?.unitEncoding === "bcs";
|
|
1764
|
-
const fail = (ast, actual, message2) => ParseResult2.fail(new ParseResult2.Type(ast, actual, message2));
|
|
1765
|
-
return Schema4.transformOrFail(KeyedVariantSchema, TypedVariantSchema, {
|
|
1766
|
-
strict: false,
|
|
1767
|
-
decode: (kv, _options, ast) => {
|
|
1768
|
-
if (typeof kv === "string") {
|
|
1769
|
-
if (!(kv in variants)) return fail(ast, kv, `Unknown variant "${kv}"`);
|
|
1770
|
-
if (variants[kv] !== null) return fail(ast, kv, `Variant "${kv}" expects data`);
|
|
1771
|
-
return ParseResult2.succeed({ type: kv });
|
|
1772
|
-
}
|
|
1773
|
-
const keys = Object.keys(kv);
|
|
1774
|
-
if (keys.length !== 1) {
|
|
1775
|
-
return fail(ast, kv, `Expected exactly one key, got ${keys.length}`);
|
|
1776
|
-
}
|
|
1777
|
-
const type = keys[0];
|
|
1778
|
-
if (!(type in variants)) return fail(ast, kv, `Unknown variant "${type}"`);
|
|
1779
|
-
const schema = variants[type];
|
|
1780
|
-
if (schema === null || schema === void 0) {
|
|
1781
|
-
return ParseResult2.succeed({ type });
|
|
1782
|
-
}
|
|
1783
|
-
const decoded = ParseResult2.decodeUnknownEither(schema)(kv[type]);
|
|
1784
|
-
if (Either.isLeft(decoded)) return ParseResult2.fail(decoded.left);
|
|
1785
|
-
return ParseResult2.succeed({ type, value: decoded.right });
|
|
1786
|
-
},
|
|
1787
|
-
encode: (tv, _options, ast) => {
|
|
1788
|
-
const { type, value } = tv;
|
|
1789
|
-
if (!(type in variants)) return fail(ast, tv, `Unknown variant "${type}"`);
|
|
1790
|
-
const schema = variants[type];
|
|
1791
|
-
if (schema === null || schema === void 0) {
|
|
1792
|
-
return ParseResult2.succeed(bcsMode ? { [type]: [] } : type);
|
|
1793
|
-
}
|
|
1794
|
-
const encoded = ParseResult2.encodeUnknownEither(schema)(value);
|
|
1795
|
-
if (Either.isLeft(encoded)) return ParseResult2.fail(encoded.left);
|
|
1796
|
-
return ParseResult2.succeed({ [type]: encoded.right });
|
|
1797
|
-
}
|
|
1798
|
-
});
|
|
1799
|
-
};
|
|
1800
|
-
var AmountFromBcs = Uint256FromNumberOrSelf.pipe(Schema5.brand("Amount"));
|
|
1801
|
-
var BalanceFromBcs = Int320FromNumberOrSelf.pipe(Schema5.brand("Balance"));
|
|
1802
|
-
var NonceFromBcs = Uint64FromNumberOrSelf.pipe(Schema5.brand("Nonce"));
|
|
1803
|
-
var QuorumFromBcs = Uint64FromNumberOrSelf.pipe(Schema5.brand("Quorum"));
|
|
1804
|
-
var NetworkIdFromBcs = Schema5.Literal("fast:localnet", "fast:devnet", "fast:testnet", "fast:mainnet");
|
|
1805
|
-
var AddressFromBcs = Uint8Array32FromNumberArray.pipe(Schema5.brand("Address"));
|
|
1806
|
-
var SignatureFromBcs = Uint8Array64FromNumberArray.pipe(Schema5.brand("Signature"));
|
|
1807
|
-
var TokenIdFromBcs = Uint8Array32FromNumberArray.pipe(Schema5.brand("TokenId"));
|
|
1808
|
-
var StateKeyFromBcs = Uint8Array32FromNumberArray.pipe(Schema5.brand("StateKey"));
|
|
1809
|
-
var StateFromBcs = Uint8Array32FromNumberArray.pipe(Schema5.brand("State"));
|
|
1810
|
-
var ClaimDataFromBcs = Uint8ArrayFromNumberArray.pipe(Schema5.brand("ClaimData"));
|
|
1811
|
-
var UserDataFromBcs = Schema5.NullOr(Uint8Array32FromNumberArray.pipe(Schema5.brand("UserData")));
|
|
1812
|
-
var AmountFromInput = Schema6.Union(Uint256FromNumberOrSelf, HexUint256, DecimalUint256).pipe(Schema6.brand("Amount"));
|
|
1813
|
-
var BalanceFromInput = Schema6.Union(Int320FromNumberOrSelf, HexInt320, DecimalInt320).pipe(Schema6.brand("Balance"));
|
|
1814
|
-
var NonceFromInput = Uint64FromNumberOrSelf.pipe(Schema6.brand("Nonce"));
|
|
1815
|
-
var QuorumFromInput = Uint64FromNumberOrSelf.pipe(Schema6.brand("Quorum"));
|
|
1816
|
-
var NetworkIdFromInput = Schema6.Literal("fast:localnet", "fast:devnet", "fast:testnet", "fast:mainnet");
|
|
1817
|
-
var AddressFromInput = Schema6.Union(
|
|
1818
|
-
Uint8Array32,
|
|
1819
|
-
Uint8Array32FromNumberArray,
|
|
1820
|
-
Uint8Array32FromHex0x,
|
|
1821
|
-
Schema6.compose(Uint8ArrayFromBech32m("fast"), Uint8Array32)
|
|
1822
|
-
).pipe(Schema6.brand("Address"));
|
|
1823
|
-
var SignatureFromInput = Schema6.Union(Uint8Array64, Uint8Array64FromNumberArray, Uint8Array64FromHex0x).pipe(Schema6.brand("Signature"));
|
|
1824
|
-
var TokenIdFromInput = Schema6.Union(Uint8Array32, Uint8Array32FromNumberArray, Uint8Array32FromHex0x).pipe(Schema6.brand("TokenId"));
|
|
1825
|
-
var StateKeyFromInput = Schema6.Union(Uint8Array32, Uint8Array32FromNumberArray, Uint8Array32FromHex0x).pipe(Schema6.brand("StateKey"));
|
|
1826
|
-
var StateFromInput = Schema6.Union(Uint8Array32, Uint8Array32FromNumberArray, Uint8Array32FromHex0x).pipe(Schema6.brand("State"));
|
|
1827
|
-
var ClaimDataFromInput = Schema6.Union(Schema6.Uint8ArrayFromSelf, Uint8ArrayFromNumberArray, Uint8ArrayFromHexOptional0x).pipe(
|
|
1828
|
-
Schema6.brand("ClaimData")
|
|
1829
|
-
);
|
|
1830
|
-
var UserDataFromInput = Schema6.NullOr(
|
|
1831
|
-
Schema6.Union(Uint8Array32, Uint8Array32FromNumberArray, Uint8Array32FromHex0x).pipe(Schema6.brand("UserData"))
|
|
1832
|
-
);
|
|
1833
|
-
var Amount = Uint256.pipe(Schema7.brand("Amount"));
|
|
1834
|
-
var Balance = Int320.pipe(Schema7.brand("Balance"));
|
|
1835
|
-
var Nonce = Uint64.pipe(Schema7.brand("Nonce"));
|
|
1836
|
-
var Quorum = Uint64.pipe(Schema7.brand("Quorum"));
|
|
1837
|
-
var NetworkId = Schema7.Literal("fast:localnet", "fast:devnet", "fast:testnet", "fast:mainnet");
|
|
1838
|
-
var TransactionVersion = Schema7.Literal("Release20260319");
|
|
1839
|
-
var Address = Uint8Array32.pipe(Schema7.brand("Address"));
|
|
1840
|
-
var Signature = Uint8Array64.pipe(Schema7.brand("Signature"));
|
|
1841
|
-
var TokenId = Uint8Array32.pipe(Schema7.brand("TokenId"));
|
|
1842
|
-
var StateKey = Uint8Array32.pipe(Schema7.brand("StateKey"));
|
|
1843
|
-
var State = Uint8Array32.pipe(Schema7.brand("State"));
|
|
1844
|
-
var ClaimData = Schema7.Uint8ArrayFromSelf.pipe(Schema7.brand("ClaimData"));
|
|
1845
|
-
var UserData = Schema7.NullOr(Uint8Array32.pipe(Schema7.brand("UserData")));
|
|
1846
|
-
var AmountFromRest = DecimalUint256.pipe(Schema8.brand("Amount"));
|
|
1847
|
-
var BalanceFromRest = DecimalInt320.pipe(Schema8.brand("Balance"));
|
|
1848
|
-
var NonceFromRest = Uint64FromNumberOrSelf.pipe(Schema8.brand("Nonce"));
|
|
1849
|
-
var QuorumFromRest = Uint64FromNumberOrSelf.pipe(Schema8.brand("Quorum"));
|
|
1850
|
-
var NetworkIdFromRest = Schema8.Literal("fast:localnet", "fast:devnet", "fast:testnet", "fast:mainnet");
|
|
1851
|
-
var AddressFromRest = Uint8ArrayFromBech32m("fast").pipe(Schema8.brand("Address"));
|
|
1852
|
-
var SignatureFromRest = Uint8Array64FromHex.pipe(Schema8.brand("Signature"));
|
|
1853
|
-
var TokenIdFromRest = Uint8Array32FromHex.pipe(Schema8.brand("TokenId"));
|
|
1854
|
-
var StateKeyFromRest = Uint8Array32FromHex.pipe(Schema8.brand("StateKey"));
|
|
1855
|
-
var StateFromRest = Uint8Array32FromHex.pipe(Schema8.brand("State"));
|
|
1856
|
-
var ClaimDataFromRest = Schema8.Uint8ArrayFromHex.pipe(Schema8.brand("ClaimData"));
|
|
1857
|
-
var UserDataFromRest = Schema8.NullOr(Uint8Array32FromHex.pipe(Schema8.brand("UserData")));
|
|
1858
|
-
var AmountFromRpc = HexUint256.pipe(Schema9.brand("Amount"));
|
|
1859
|
-
var BalanceFromRpc = HexInt320.pipe(Schema9.brand("Balance"));
|
|
1860
|
-
var NonceFromRpc = Uint64FromNumberOrSelf.pipe(Schema9.brand("Nonce"));
|
|
1861
|
-
var QuorumFromRpc = Uint64FromNumberOrSelf.pipe(Schema9.brand("Quorum"));
|
|
1862
|
-
var NetworkIdFromRpc = Schema9.Literal("fast:localnet", "fast:devnet", "fast:testnet", "fast:mainnet");
|
|
1863
|
-
var AddressFromRpc = Uint8Array32FromNumberArray.pipe(Schema9.brand("Address"));
|
|
1864
|
-
var SignatureFromRpc = Uint8Array64FromNumberArray.pipe(Schema9.brand("Signature"));
|
|
1865
|
-
var TokenIdFromRpc = Uint8Array32FromNumberArray.pipe(Schema9.brand("TokenId"));
|
|
1866
|
-
var StateKeyFromRpc = Uint8Array32FromNumberArray.pipe(Schema9.brand("StateKey"));
|
|
1867
|
-
var StateFromRpc = Uint8Array32FromNumberArray.pipe(Schema9.brand("State"));
|
|
1868
|
-
var ClaimDataFromRpc = Uint8ArrayFromNumberArray.pipe(Schema9.brand("ClaimData"));
|
|
1869
|
-
var UserDataFromRpc = Schema9.NullOr(Uint8Array32FromNumberArray.pipe(Schema9.brand("UserData")));
|
|
1870
|
-
var bcs_layout_exports = {};
|
|
1871
|
-
__export2(bcs_layout_exports, {
|
|
1872
|
-
AddressChange: () => AddressChange,
|
|
1873
|
-
Amount: () => Amount2,
|
|
1874
|
-
Burn: () => Burn,
|
|
1875
|
-
ClaimData: () => ClaimData2,
|
|
1876
|
-
ClaimType: () => ClaimType,
|
|
1877
|
-
CommitteeChange: () => CommitteeChange,
|
|
1878
|
-
CommitteeConfig: () => CommitteeConfig,
|
|
1879
|
-
ExternalClaim: () => ExternalClaim,
|
|
1880
|
-
ExternalClaimBody: () => ExternalClaimBody,
|
|
1881
|
-
Mint: () => Mint,
|
|
1882
|
-
Nonce: () => Nonce2,
|
|
1883
|
-
Operation: () => Operation,
|
|
1884
|
-
PublicKeyBytes: () => PublicKeyBytes,
|
|
1885
|
-
Quorum: () => Quorum2,
|
|
1886
|
-
Signature: () => Signature2,
|
|
1887
|
-
State: () => State2,
|
|
1888
|
-
StateInitialization: () => StateInitialization,
|
|
1889
|
-
StateKey: () => StateKey2,
|
|
1890
|
-
StateReset: () => StateReset,
|
|
1891
|
-
StateUpdate: () => StateUpdate,
|
|
1892
|
-
TimestampNanos: () => TimestampNanos,
|
|
1893
|
-
TokenCreation: () => TokenCreation,
|
|
1894
|
-
TokenDecimals: () => TokenDecimals,
|
|
1895
|
-
TokenId: () => TokenId2,
|
|
1896
|
-
TokenManagement: () => TokenManagement,
|
|
1897
|
-
TokenName: () => TokenName,
|
|
1898
|
-
TokenTransfer: () => TokenTransfer,
|
|
1899
|
-
Transaction20260319: () => Transaction20260319,
|
|
1900
|
-
UserData: () => UserData2,
|
|
1901
|
-
ValidatorConfig: () => ValidatorConfig,
|
|
1902
|
-
VerifierSig: () => VerifierSig,
|
|
1903
|
-
VersionedTransaction: () => VersionedTransaction
|
|
1904
|
-
});
|
|
1905
|
-
var PublicKeyBytes = bcs.fixedArray(32, bcs.u8());
|
|
1906
|
-
var StateKey2 = bcs.fixedArray(32, bcs.u8());
|
|
1907
|
-
var Nonce2 = bcs.u64();
|
|
1908
|
-
var TimestampNanos = bcs.u128();
|
|
1909
|
-
var TokenId2 = bcs.fixedArray(32, bcs.u8());
|
|
1910
|
-
var TokenName = bcs.string();
|
|
1911
|
-
var TokenDecimals = bcs.u8();
|
|
1912
|
-
var Amount2 = bcs.u256();
|
|
1913
|
-
var UserData2 = bcs.option(bcs.fixedArray(32, bcs.u8()));
|
|
1914
|
-
var State2 = bcs.fixedArray(32, bcs.u8());
|
|
1915
|
-
var Quorum2 = bcs.u64();
|
|
1916
|
-
var ClaimData2 = bcs.vector(bcs.u8());
|
|
1917
|
-
var Signature2 = bcs.fixedArray(64, bcs.u8());
|
|
1918
|
-
var AddressChange = bcs.enum("AddressChange", {
|
|
1919
|
-
Add: bcs.tuple([]),
|
|
1920
|
-
Remove: bcs.tuple([])
|
|
1921
|
-
});
|
|
1922
|
-
var TokenTransfer = bcs.struct("TokenTransfer", {
|
|
1923
|
-
token_id: TokenId2,
|
|
1924
|
-
recipient: PublicKeyBytes,
|
|
1925
|
-
amount: Amount2,
|
|
1926
|
-
user_data: UserData2
|
|
1927
|
-
});
|
|
1928
|
-
var TokenCreation = bcs.struct("TokenCreation", {
|
|
1929
|
-
token_name: TokenName,
|
|
1930
|
-
decimals: TokenDecimals,
|
|
1931
|
-
initial_amount: Amount2,
|
|
1932
|
-
mints: bcs.vector(PublicKeyBytes),
|
|
1933
|
-
user_data: UserData2
|
|
1934
|
-
});
|
|
1935
|
-
var TokenManagement = bcs.struct("TokenManagement", {
|
|
1936
|
-
token_id: TokenId2,
|
|
1937
|
-
update_id: Nonce2,
|
|
1938
|
-
new_admin: bcs.option(PublicKeyBytes),
|
|
1939
|
-
mints: bcs.vector(bcs.tuple([AddressChange, PublicKeyBytes])),
|
|
1940
|
-
user_data: UserData2
|
|
1941
|
-
});
|
|
1942
|
-
var Mint = bcs.struct("Mint", {
|
|
1943
|
-
token_id: TokenId2,
|
|
1944
|
-
recipient: PublicKeyBytes,
|
|
1945
|
-
amount: Amount2
|
|
1946
|
-
});
|
|
1947
|
-
var Burn = bcs.struct("Burn", {
|
|
1948
|
-
token_id: TokenId2,
|
|
1949
|
-
amount: Amount2
|
|
1950
|
-
});
|
|
1951
|
-
var StateInitialization = bcs.struct("StateInitialization", {
|
|
1952
|
-
key: StateKey2,
|
|
1953
|
-
initial_state: State2
|
|
1954
|
-
});
|
|
1955
|
-
var StateUpdate = bcs.struct("StateUpdate", {
|
|
1956
|
-
key: StateKey2,
|
|
1957
|
-
previous_state: State2,
|
|
1958
|
-
next_state: State2,
|
|
1959
|
-
compute_claim_tx_hash: bcs.fixedArray(32, bcs.u8()),
|
|
1960
|
-
compute_claim_tx_timestamp: TimestampNanos
|
|
1961
|
-
});
|
|
1962
|
-
var StateReset = bcs.struct("StateReset", {
|
|
1963
|
-
key: StateKey2,
|
|
1964
|
-
reset_state: State2
|
|
1965
|
-
});
|
|
1966
|
-
var ExternalClaimBody = bcs.struct("ExternalClaimBody", {
|
|
1967
|
-
verifier_committee: bcs.vector(PublicKeyBytes),
|
|
1968
|
-
verifier_quorum: Quorum2,
|
|
1969
|
-
claim_data: ClaimData2
|
|
1970
|
-
});
|
|
1971
|
-
var VerifierSig = bcs.struct("VerifierSig", {
|
|
1972
|
-
verifier_addr: PublicKeyBytes,
|
|
1973
|
-
sig: Signature2
|
|
1974
|
-
});
|
|
1975
|
-
var ExternalClaim = bcs.struct("ExternalClaim", {
|
|
1976
|
-
claim: ExternalClaimBody,
|
|
1977
|
-
signatures: bcs.vector(VerifierSig)
|
|
1978
|
-
});
|
|
1979
|
-
var ValidatorConfig = bcs.struct("ValidatorConfig", {
|
|
1980
|
-
address: PublicKeyBytes,
|
|
1981
|
-
host: bcs.string(),
|
|
1982
|
-
rpc_port: bcs.u32()
|
|
1983
|
-
});
|
|
1984
|
-
var CommitteeConfig = bcs.struct("CommitteeConfig", {
|
|
1985
|
-
validators: bcs.vector(ValidatorConfig)
|
|
1986
|
-
});
|
|
1987
|
-
var CommitteeChange = bcs.struct("CommitteeChange", {
|
|
1988
|
-
new_committee: CommitteeConfig,
|
|
1989
|
-
epoch: bcs.u32()
|
|
1990
|
-
});
|
|
1991
|
-
var Operation = bcs.enum("Operation", {
|
|
1992
|
-
TokenTransfer,
|
|
1993
|
-
TokenCreation,
|
|
1994
|
-
TokenManagement,
|
|
1995
|
-
Mint,
|
|
1996
|
-
Burn,
|
|
1997
|
-
StateInitialization,
|
|
1998
|
-
StateUpdate,
|
|
1999
|
-
ExternalClaim,
|
|
2000
|
-
StateReset,
|
|
2001
|
-
JoinCommittee: ValidatorConfig,
|
|
2002
|
-
LeaveCommittee: bcs.tuple([]),
|
|
2003
|
-
ChangeCommittee: CommitteeChange
|
|
2004
|
-
});
|
|
2005
|
-
var ClaimType = bcs.enum("ClaimType", {
|
|
2006
|
-
TokenTransfer,
|
|
2007
|
-
TokenCreation,
|
|
2008
|
-
TokenManagement,
|
|
2009
|
-
Mint,
|
|
2010
|
-
Burn,
|
|
2011
|
-
StateInitialization,
|
|
2012
|
-
StateUpdate,
|
|
2013
|
-
ExternalClaim,
|
|
2014
|
-
StateReset,
|
|
2015
|
-
JoinCommittee: ValidatorConfig,
|
|
2016
|
-
LeaveCommittee: bcs.tuple([]),
|
|
2017
|
-
ChangeCommittee: CommitteeChange,
|
|
2018
|
-
Batch: bcs.vector(Operation)
|
|
2019
|
-
});
|
|
2020
|
-
var Transaction20260319 = bcs.struct("Transaction", {
|
|
2021
|
-
network_id: bcs.string(),
|
|
2022
|
-
sender: PublicKeyBytes,
|
|
2023
|
-
nonce: Nonce2,
|
|
2024
|
-
timestamp_nanos: TimestampNanos,
|
|
2025
|
-
claim: ClaimType,
|
|
2026
|
-
archival: bcs.bool(),
|
|
2027
|
-
fee_token: bcs.option(TokenId2)
|
|
2028
|
-
});
|
|
2029
|
-
var VersionedTransaction = bcs.enum("VersionedTransaction", {
|
|
2030
|
-
Release20260319: Transaction20260319
|
|
2031
|
-
});
|
|
2032
|
-
var FastSetErrorData = TypedVariant({
|
|
2033
|
-
UnexpectedNonce: CamelCaseStruct({
|
|
2034
|
-
expected_nonce: BigIntFromNumberOrSelf
|
|
2035
|
-
}),
|
|
2036
|
-
InsufficientFunding: CamelCaseStruct({
|
|
2037
|
-
current_balance: BigIntFromNumberOrSelf
|
|
2038
|
-
}),
|
|
2039
|
-
PreviousTransactionMustBeConfirmedFirst: CamelCaseStruct({
|
|
2040
|
-
pending_confirmation: Schema10.Unknown
|
|
2041
|
-
}),
|
|
2042
|
-
InvalidSignature: Schema10.Struct({
|
|
2043
|
-
error: Schema10.String
|
|
2044
|
-
}),
|
|
2045
|
-
MissingEarlierConfirmations: CamelCaseStruct({
|
|
2046
|
-
current_nonce: BigIntFromNumberOrSelf
|
|
2047
|
-
}),
|
|
2048
|
-
CertificateTooYoung: CamelCaseStruct({
|
|
2049
|
-
resend_after_nanos: BigIntFromNumberOrSelf
|
|
2050
|
-
}),
|
|
2051
|
-
NonSubmittableOperation: Schema10.Struct({
|
|
2052
|
-
reason: Schema10.String
|
|
2053
|
-
})
|
|
2054
|
-
});
|
|
2055
|
-
var JsonRpcError = TypedVariant({
|
|
2056
|
-
FastSet: FastSetErrorData,
|
|
2057
|
-
Generic: Schema10.String
|
|
2058
|
-
});
|
|
2059
|
-
var ProxyErrorData = TypedVariant({
|
|
2060
|
-
GeneralError: Schema10.String,
|
|
2061
|
-
FaucetDisabled: null,
|
|
2062
|
-
RpcError: JsonRpcError,
|
|
2063
|
-
FaucetThrottled: Schema10.Unknown,
|
|
2064
|
-
FaucetTxnFailed: Schema10.Unknown,
|
|
2065
|
-
FaucetThresholdExceeded: Schema10.Unknown,
|
|
2066
|
-
VerifierSigsInvalid: Schema10.Unknown,
|
|
2067
|
-
DatabaseError: Schema10.String,
|
|
2068
|
-
TooManyCertificatesRequested: null,
|
|
2069
|
-
UnexpectedNonce: CamelCaseStruct({
|
|
2070
|
-
tx_nonce: BigIntFromNumberOrSelf,
|
|
2071
|
-
expected_nonce: BigIntFromNumberOrSelf
|
|
2072
|
-
}),
|
|
2073
|
-
InvalidRequest: Schema10.String
|
|
2074
|
-
});
|
|
2075
|
-
var makeAddressChange = (options) => TypedVariant({ Add: null, Remove: null }, options);
|
|
2076
|
-
var AddressChange2 = makeAddressChange();
|
|
2077
|
-
var makeTokenTransfer = (p4) => CamelCaseStruct({ token_id: p4.TokenId, recipient: p4.Address, amount: p4.Amount, user_data: p4.UserData });
|
|
2078
|
-
var makeTokenCreation = (p4) => CamelCaseStruct({
|
|
2079
|
-
token_name: Schema11.String,
|
|
2080
|
-
decimals: Schema11.Number,
|
|
2081
|
-
initial_amount: p4.Amount,
|
|
2082
|
-
mints: Schema11.Array(p4.Address),
|
|
2083
|
-
user_data: p4.UserData
|
|
2084
|
-
});
|
|
2085
|
-
var makeTokenManagement = (p4, options) => CamelCaseStruct({
|
|
2086
|
-
token_id: p4.TokenId,
|
|
2087
|
-
update_id: p4.Nonce,
|
|
2088
|
-
new_admin: Schema11.NullOr(p4.Address),
|
|
2089
|
-
mints: Schema11.Array(Schema11.Tuple(makeAddressChange(options), p4.Address)),
|
|
2090
|
-
user_data: p4.UserData
|
|
2091
|
-
});
|
|
2092
|
-
var makeMint = (p4) => CamelCaseStruct({ token_id: p4.TokenId, recipient: p4.Address, amount: p4.Amount });
|
|
2093
|
-
var makeBurn = (p4) => CamelCaseStruct({ token_id: p4.TokenId, amount: p4.Amount });
|
|
2094
|
-
var makeStateInitialization = (p4) => CamelCaseStruct({ key: p4.StateKey, initial_state: p4.State });
|
|
2095
|
-
var makeStateUpdate = (p4) => CamelCaseStruct({
|
|
2096
|
-
key: p4.StateKey,
|
|
2097
|
-
previous_state: p4.State,
|
|
2098
|
-
next_state: p4.State,
|
|
2099
|
-
compute_claim_tx_hash: p4.StateKey,
|
|
2100
|
-
compute_claim_tx_timestamp: p4.BigInt
|
|
2101
|
-
});
|
|
2102
|
-
var makeStateReset = (p4) => CamelCaseStruct({ key: p4.StateKey, reset_state: p4.State });
|
|
2103
|
-
var makeExternalClaimBody = (p4) => CamelCaseStruct({ verifier_committee: Schema11.Array(p4.Address), verifier_quorum: p4.Quorum, claim_data: p4.ClaimData });
|
|
2104
|
-
var makeVerifierSig = (p4) => CamelCaseStruct({ verifier_addr: p4.Address, sig: p4.Signature });
|
|
2105
|
-
var makeExternalClaim = (p4) => Schema11.Struct({ claim: makeExternalClaimBody(p4), signatures: Schema11.Array(makeVerifierSig(p4)) });
|
|
2106
|
-
var makeValidatorConfig = (p4) => CamelCaseStruct({ address: p4.Address, host: Schema11.String, rpc_port: Schema11.Number });
|
|
2107
|
-
var makeCommitteeConfig = (p4) => Schema11.Struct({ validators: Schema11.Array(makeValidatorConfig(p4)) });
|
|
2108
|
-
var makeCommitteeChange = (p4) => CamelCaseStruct({ new_committee: makeCommitteeConfig(p4), epoch: Schema11.Number });
|
|
2109
|
-
var makeOperation = (p4, options) => TypedVariant(
|
|
2110
|
-
{
|
|
2111
|
-
TokenTransfer: makeTokenTransfer(p4),
|
|
2112
|
-
TokenCreation: makeTokenCreation(p4),
|
|
2113
|
-
TokenManagement: makeTokenManagement(p4, options),
|
|
2114
|
-
Mint: makeMint(p4),
|
|
2115
|
-
Burn: makeBurn(p4),
|
|
2116
|
-
StateInitialization: makeStateInitialization(p4),
|
|
2117
|
-
StateUpdate: makeStateUpdate(p4),
|
|
2118
|
-
StateReset: makeStateReset(p4),
|
|
2119
|
-
ExternalClaim: makeExternalClaim(p4),
|
|
2120
|
-
JoinCommittee: makeValidatorConfig(p4),
|
|
2121
|
-
LeaveCommittee: null,
|
|
2122
|
-
ChangeCommittee: makeCommitteeChange(p4)
|
|
2123
|
-
},
|
|
2124
|
-
options
|
|
2125
|
-
);
|
|
2126
|
-
var makeClaimType = (p4, options) => TypedVariant(
|
|
2127
|
-
{
|
|
2128
|
-
TokenTransfer: makeTokenTransfer(p4),
|
|
2129
|
-
TokenCreation: makeTokenCreation(p4),
|
|
2130
|
-
TokenManagement: makeTokenManagement(p4, options),
|
|
2131
|
-
Mint: makeMint(p4),
|
|
2132
|
-
Burn: makeBurn(p4),
|
|
2133
|
-
StateInitialization: makeStateInitialization(p4),
|
|
2134
|
-
StateUpdate: makeStateUpdate(p4),
|
|
2135
|
-
StateReset: makeStateReset(p4),
|
|
2136
|
-
ExternalClaim: makeExternalClaim(p4),
|
|
2137
|
-
JoinCommittee: makeValidatorConfig(p4),
|
|
2138
|
-
LeaveCommittee: null,
|
|
2139
|
-
ChangeCommittee: makeCommitteeChange(p4),
|
|
2140
|
-
Batch: Schema11.Array(makeOperation(p4, options))
|
|
2141
|
-
},
|
|
2142
|
-
options
|
|
2143
|
-
);
|
|
2144
|
-
var makeTransaction = (p4, options) => CamelCaseStruct({
|
|
2145
|
-
network_id: p4.NetworkId,
|
|
2146
|
-
sender: p4.Address,
|
|
2147
|
-
nonce: p4.Nonce,
|
|
2148
|
-
timestamp_nanos: p4.BigInt,
|
|
2149
|
-
claim: makeClaimType(p4, options),
|
|
2150
|
-
archival: Schema12.Boolean,
|
|
2151
|
-
fee_token: Schema12.NullOr(p4.TokenId)
|
|
2152
|
-
});
|
|
2153
|
-
var makeVersionedTransaction = (p4, options) => TypedVariant({ Release20260319: makeTransaction(p4, options) });
|
|
2154
|
-
var makeMultiSigConfig = (p4) => CamelCaseStruct({ authorized_signers: Schema13.Array(p4.Address), quorum: p4.Quorum, nonce: p4.Nonce });
|
|
2155
|
-
var makeMultiSig = (p4) => Schema13.Struct({
|
|
2156
|
-
config: makeMultiSigConfig(p4),
|
|
2157
|
-
signatures: Schema13.Array(Schema13.Tuple(p4.Address, p4.Signature))
|
|
2158
|
-
});
|
|
2159
|
-
var makeSignatureOrMultiSig = (p4) => TypedVariant({
|
|
2160
|
-
Signature: p4.Signature,
|
|
2161
|
-
MultiSig: makeMultiSig(p4)
|
|
2162
|
-
});
|
|
2163
|
-
var makeTransactionEnvelope = (p4) => Schema13.Struct({
|
|
2164
|
-
transaction: makeVersionedTransaction(p4),
|
|
2165
|
-
signature: makeSignatureOrMultiSig(p4)
|
|
2166
|
-
});
|
|
2167
|
-
var makeValidatedTransaction = (p4) => Schema13.Struct({
|
|
2168
|
-
value: makeTransactionEnvelope(p4),
|
|
2169
|
-
validator: p4.Address,
|
|
2170
|
-
signature: p4.Signature
|
|
2171
|
-
});
|
|
2172
|
-
var makeTransactionCertificate = (p4) => Schema13.Struct({
|
|
2173
|
-
envelope: makeTransactionEnvelope(p4),
|
|
2174
|
-
signatures: Schema13.Array(Schema13.Tuple(p4.Address, p4.Signature))
|
|
2175
|
-
});
|
|
2176
|
-
var makeNonceRange = (p4) => Schema14.Struct({ start: p4.Nonce, limit: Schema14.Number });
|
|
2177
|
-
var makePageRequest = (p4) => Schema14.Struct({ limit: Schema14.Number, token: Schema14.optional(p4.BigInt) });
|
|
2178
|
-
var makeTokenMetadata = (p4) => CamelCaseStruct({
|
|
2179
|
-
update_id: p4.Nonce,
|
|
2180
|
-
admin: p4.Address,
|
|
2181
|
-
token_name: Schema14.String,
|
|
2182
|
-
decimals: Schema14.Number,
|
|
2183
|
-
total_supply: p4.Amount,
|
|
2184
|
-
mints: Schema14.Array(p4.Address)
|
|
2185
|
-
});
|
|
2186
|
-
var makeAccountInfoResponse = (p4) => CamelCaseStruct({
|
|
2187
|
-
sender: p4.Address,
|
|
2188
|
-
balance: p4.Balance,
|
|
2189
|
-
next_nonce: p4.Nonce,
|
|
2190
|
-
pending_confirmation: Schema14.NullOr(makeValidatedTransaction(p4)),
|
|
2191
|
-
requested_state: Schema14.Array(Schema14.Tuple(p4.StateKey, p4.State)),
|
|
2192
|
-
requested_certificates: Schema14.NullOr(Schema14.Array(makeTransactionCertificate(p4))),
|
|
2193
|
-
requested_validated_transaction: Schema14.NullOr(makeValidatedTransaction(p4)),
|
|
2194
|
-
token_balance: Schema14.Array(Schema14.Tuple(p4.TokenId, p4.Balance))
|
|
2195
|
-
});
|
|
2196
|
-
var makeTokenInfoResponse = (p4) => CamelCaseStruct({
|
|
2197
|
-
requested_token_metadata: Schema14.Array(Schema14.Tuple(p4.TokenId, Schema14.NullOr(makeTokenMetadata(p4))))
|
|
2198
|
-
});
|
|
2199
|
-
var makeSubmitTransactionResponse = (p4) => CamelCaseStruct({ validator: p4.Address, signature: p4.Signature, next_nonce: p4.Nonce, transaction_hash: p4.ClaimData });
|
|
2200
|
-
var makeConfirmTransactionResponse = (p4) => CamelCaseStruct({ token_ids: Schema14.Array(p4.TokenId) });
|
|
2201
|
-
var makeProxySubmitTransactionResult = (p4) => TypedVariant({
|
|
2202
|
-
Success: makeTransactionCertificate(p4),
|
|
2203
|
-
IncompleteVerifierSigs: null,
|
|
2204
|
-
IncompleteMultiSig: null
|
|
2205
|
-
});
|
|
2206
|
-
var makeSubmitTransactionParams = (p4) => makeTransactionEnvelope(p4);
|
|
2207
|
-
var makeFaucetDripParams = (p4) => CamelCaseStruct({
|
|
2208
|
-
recipient: p4.Address,
|
|
2209
|
-
amount: p4.Amount,
|
|
2210
|
-
token_id: Schema15.NullOr(p4.TokenId)
|
|
2211
|
-
});
|
|
2212
|
-
var makeGetAccountInfoParams = (p4) => CamelCaseStruct({
|
|
2213
|
-
address: p4.Address,
|
|
2214
|
-
token_balances_filter: Schema15.NullOr(Schema15.Array(p4.TokenId)),
|
|
2215
|
-
state_key_filter: Schema15.NullOr(Schema15.Array(p4.StateKey)),
|
|
2216
|
-
certificate_by_nonce: Schema15.NullOr(Schema15.Struct({ start: p4.Nonce, limit: Schema15.Number }))
|
|
2217
|
-
});
|
|
2218
|
-
var makeGetPendingMultisigParams = (p4) => Schema15.Struct({ address: p4.Address });
|
|
2219
|
-
var makeGetTokenInfoParams = (p4) => CamelCaseStruct({ token_ids: Schema15.Array(p4.TokenId) });
|
|
2220
|
-
var makeGetTransactionCertificatesParams = (p4) => CamelCaseStruct({
|
|
2221
|
-
address: p4.Address,
|
|
2222
|
-
from_nonce: p4.Nonce,
|
|
2223
|
-
limit: Schema15.Number
|
|
2224
|
-
});
|
|
2225
|
-
var FaucetDripInput = Schema15.Struct({
|
|
2226
|
-
recipient: AddressFromInput,
|
|
2227
|
-
amount: AmountFromInput,
|
|
2228
|
-
tokenId: Schema15.NullOr(TokenIdFromInput)
|
|
2229
|
-
});
|
|
2230
|
-
var GetAccountInfoInput = Schema15.Struct({
|
|
2231
|
-
address: AddressFromInput,
|
|
2232
|
-
tokenBalancesFilter: Schema15.optionalWith(Schema15.NullOr(Schema15.Array(TokenIdFromInput)), { default: () => null }),
|
|
2233
|
-
stateKeyFilter: Schema15.optionalWith(Schema15.NullOr(Schema15.Array(StateKeyFromInput)), { default: () => null }),
|
|
2234
|
-
certificateByNonce: Schema15.optionalWith(
|
|
2235
|
-
Schema15.NullOr(
|
|
2236
|
-
Schema15.Struct({
|
|
2237
|
-
start: NonceFromInput,
|
|
2238
|
-
limit: Schema15.Number
|
|
2239
|
-
})
|
|
2240
|
-
),
|
|
2241
|
-
{ default: () => null }
|
|
2242
|
-
)
|
|
2243
|
-
});
|
|
2244
|
-
var GetPendingMultisigInput = Schema15.Struct({
|
|
2245
|
-
address: AddressFromInput
|
|
2246
|
-
});
|
|
2247
|
-
var GetTokenInfoInput = Schema15.Struct({
|
|
2248
|
-
tokenIds: Schema15.Array(TokenIdFromInput)
|
|
2249
|
-
});
|
|
2250
|
-
var GetTransactionCertificatesInput = Schema15.Struct({
|
|
2251
|
-
address: AddressFromInput,
|
|
2252
|
-
fromNonce: NonceFromInput,
|
|
2253
|
-
limit: Schema15.Number
|
|
2254
|
-
});
|
|
2255
|
-
var PrivateKeyFromInput = Schema16.Union(Uint8Array32, Uint8Array32FromHex0x, Uint8Array32FromNumberArray).pipe(Schema16.brand("PrivateKey"));
|
|
2256
|
-
var TokenTransferInput = Schema17.Struct({
|
|
2257
|
-
tokenId: TokenIdFromInput,
|
|
2258
|
-
recipient: AddressFromInput,
|
|
2259
|
-
amount: AmountFromInput,
|
|
2260
|
-
userData: UserDataFromInput
|
|
2261
|
-
});
|
|
2262
|
-
var TokenCreationInput = Schema17.Struct({
|
|
2263
|
-
tokenName: Schema17.String,
|
|
2264
|
-
decimals: Schema17.Number,
|
|
2265
|
-
initialAmount: AmountFromInput,
|
|
2266
|
-
mints: Schema17.Array(AddressFromInput),
|
|
2267
|
-
userData: UserDataFromInput
|
|
2268
|
-
});
|
|
2269
|
-
var TokenManagementInput = Schema17.Struct({
|
|
2270
|
-
tokenId: TokenIdFromInput,
|
|
2271
|
-
updateId: NonceFromInput,
|
|
2272
|
-
newAdmin: Schema17.NullOr(AddressFromInput),
|
|
2273
|
-
mints: Schema17.Array(
|
|
2274
|
-
Schema17.Tuple(Schema17.Union(Schema17.Struct({ type: Schema17.Literal("Add") }), Schema17.Struct({ type: Schema17.Literal("Remove") })), AddressFromInput)
|
|
2275
|
-
),
|
|
2276
|
-
userData: UserDataFromInput
|
|
2277
|
-
});
|
|
2278
|
-
var MintInput = Schema17.Struct({
|
|
2279
|
-
tokenId: TokenIdFromInput,
|
|
2280
|
-
recipient: AddressFromInput,
|
|
2281
|
-
amount: AmountFromInput
|
|
2282
|
-
});
|
|
2283
|
-
var BurnInput = Schema17.Struct({
|
|
2284
|
-
tokenId: TokenIdFromInput,
|
|
2285
|
-
amount: AmountFromInput
|
|
2286
|
-
});
|
|
2287
|
-
var StateInitializationInput = Schema17.Struct({
|
|
2288
|
-
key: StateKeyFromInput,
|
|
2289
|
-
initialState: StateFromInput
|
|
2290
|
-
});
|
|
2291
|
-
var StateUpdateInput = Schema17.Struct({
|
|
2292
|
-
key: StateKeyFromInput,
|
|
2293
|
-
previousState: StateFromInput,
|
|
2294
|
-
nextState: StateFromInput,
|
|
2295
|
-
computeClaimTxHash: StateKeyFromInput,
|
|
2296
|
-
computeClaimTxTimestamp: BigIntFromNumberOrSelf
|
|
2297
|
-
});
|
|
2298
|
-
var StateResetInput = Schema17.Struct({
|
|
2299
|
-
key: StateKeyFromInput,
|
|
2300
|
-
resetState: StateFromInput
|
|
2301
|
-
});
|
|
2302
|
-
var ExternalClaimInput = Schema17.Struct({
|
|
2303
|
-
claim: Schema17.Struct({
|
|
2304
|
-
verifierCommittee: Schema17.Array(AddressFromInput),
|
|
2305
|
-
verifierQuorum: QuorumFromInput,
|
|
2306
|
-
claimData: ClaimDataFromInput
|
|
2307
|
-
}),
|
|
2308
|
-
signatures: Schema17.Array(
|
|
2309
|
-
Schema17.Struct({
|
|
2310
|
-
verifierAddr: AddressFromInput,
|
|
2311
|
-
sig: SignatureFromInput
|
|
2312
|
-
})
|
|
2313
|
-
)
|
|
2314
|
-
});
|
|
2315
|
-
var ValidatorConfigInput = Schema17.Struct({
|
|
2316
|
-
address: AddressFromInput,
|
|
2317
|
-
host: Schema17.String,
|
|
2318
|
-
rpcPort: Schema17.Number
|
|
2319
|
-
});
|
|
2320
|
-
var CommitteeChangeInput = Schema17.Struct({
|
|
2321
|
-
newCommittee: Schema17.Struct({
|
|
2322
|
-
validators: Schema17.Array(ValidatorConfigInput)
|
|
2323
|
-
}),
|
|
2324
|
-
epoch: Schema17.Number
|
|
2325
|
-
});
|
|
2326
|
-
var OperationInput = Schema17.Union(
|
|
2327
|
-
Schema17.Struct({
|
|
2328
|
-
type: Schema17.Literal("TokenTransfer"),
|
|
2329
|
-
value: TokenTransferInput
|
|
2330
|
-
}),
|
|
2331
|
-
Schema17.Struct({
|
|
2332
|
-
type: Schema17.Literal("TokenCreation"),
|
|
2333
|
-
value: TokenCreationInput
|
|
2334
|
-
}),
|
|
2335
|
-
Schema17.Struct({
|
|
2336
|
-
type: Schema17.Literal("TokenManagement"),
|
|
2337
|
-
value: TokenManagementInput
|
|
2338
|
-
}),
|
|
2339
|
-
Schema17.Struct({ type: Schema17.Literal("Mint"), value: MintInput }),
|
|
2340
|
-
Schema17.Struct({ type: Schema17.Literal("Burn"), value: BurnInput }),
|
|
2341
|
-
Schema17.Struct({
|
|
2342
|
-
type: Schema17.Literal("StateInitialization"),
|
|
2343
|
-
value: StateInitializationInput
|
|
2344
|
-
}),
|
|
2345
|
-
Schema17.Struct({
|
|
2346
|
-
type: Schema17.Literal("StateUpdate"),
|
|
2347
|
-
value: StateUpdateInput
|
|
2348
|
-
}),
|
|
2349
|
-
Schema17.Struct({ type: Schema17.Literal("StateReset"), value: StateResetInput }),
|
|
2350
|
-
Schema17.Struct({
|
|
2351
|
-
type: Schema17.Literal("ExternalClaim"),
|
|
2352
|
-
value: ExternalClaimInput
|
|
2353
|
-
}),
|
|
2354
|
-
Schema17.Struct({
|
|
2355
|
-
type: Schema17.Literal("JoinCommittee"),
|
|
2356
|
-
value: ValidatorConfigInput
|
|
2357
|
-
}),
|
|
2358
|
-
Schema17.Struct({ type: Schema17.Literal("LeaveCommittee") }),
|
|
2359
|
-
Schema17.Struct({
|
|
2360
|
-
type: Schema17.Literal("ChangeCommittee"),
|
|
2361
|
-
value: CommitteeChangeInput
|
|
2362
|
-
})
|
|
2363
|
-
);
|
|
2364
|
-
var ClaimTypeInput = Schema17.Union(
|
|
2365
|
-
...OperationInput.members,
|
|
2366
|
-
Schema17.Struct({
|
|
2367
|
-
type: Schema17.Literal("Batch"),
|
|
2368
|
-
value: Schema17.Array(OperationInput)
|
|
2369
|
-
})
|
|
2370
|
-
);
|
|
2371
|
-
var TransactionInput = Schema17.Struct({
|
|
2372
|
-
networkId: NetworkIdFromInput,
|
|
2373
|
-
sender: AddressFromInput,
|
|
2374
|
-
nonce: NonceFromInput,
|
|
2375
|
-
timestampNanos: BigIntFromNumberOrSelf,
|
|
2376
|
-
claim: ClaimTypeInput,
|
|
2377
|
-
archival: Schema17.Boolean,
|
|
2378
|
-
feeToken: Schema17.NullOr(TokenIdFromInput)
|
|
2379
|
-
});
|
|
2380
|
-
var RpcPalette = {
|
|
2381
|
-
Amount: AmountFromRpc,
|
|
2382
|
-
Balance: BalanceFromRpc,
|
|
2383
|
-
Nonce: NonceFromRpc,
|
|
2384
|
-
Quorum: QuorumFromRpc,
|
|
2385
|
-
NetworkId: NetworkIdFromRpc,
|
|
2386
|
-
Address: AddressFromRpc,
|
|
2387
|
-
Signature: SignatureFromRpc,
|
|
2388
|
-
TokenId: TokenIdFromRpc,
|
|
2389
|
-
StateKey: StateKeyFromRpc,
|
|
2390
|
-
State: StateFromRpc,
|
|
2391
|
-
ClaimData: ClaimDataFromRpc,
|
|
2392
|
-
UserData: UserDataFromRpc,
|
|
2393
|
-
BigInt: BigIntFromNumberOrSelf
|
|
2394
|
-
};
|
|
2395
|
-
var RestPalette = {
|
|
2396
|
-
Amount: AmountFromRest,
|
|
2397
|
-
Balance: BalanceFromRest,
|
|
2398
|
-
Nonce: NonceFromRest,
|
|
2399
|
-
Quorum: QuorumFromRest,
|
|
2400
|
-
NetworkId: NetworkIdFromRest,
|
|
2401
|
-
Address: AddressFromRest,
|
|
2402
|
-
Signature: SignatureFromRest,
|
|
2403
|
-
TokenId: TokenIdFromRest,
|
|
2404
|
-
StateKey: StateKeyFromRest,
|
|
2405
|
-
State: StateFromRest,
|
|
2406
|
-
ClaimData: ClaimDataFromRest,
|
|
2407
|
-
UserData: UserDataFromRest,
|
|
2408
|
-
BigInt: BigIntFromNumberOrSelf
|
|
2409
|
-
};
|
|
2410
|
-
var BcsPalette = {
|
|
2411
|
-
Amount: AmountFromBcs,
|
|
2412
|
-
Balance: BalanceFromBcs,
|
|
2413
|
-
Nonce: NonceFromBcs,
|
|
2414
|
-
Quorum: QuorumFromBcs,
|
|
2415
|
-
NetworkId: NetworkIdFromBcs,
|
|
2416
|
-
Address: AddressFromBcs,
|
|
2417
|
-
Signature: SignatureFromBcs,
|
|
2418
|
-
TokenId: TokenIdFromBcs,
|
|
2419
|
-
StateKey: StateKeyFromBcs,
|
|
2420
|
-
State: StateFromBcs,
|
|
2421
|
-
ClaimData: ClaimDataFromBcs,
|
|
2422
|
-
UserData: UserDataFromBcs,
|
|
2423
|
-
BigInt: BigIntFromNumberOrSelf
|
|
2424
|
-
};
|
|
2425
|
-
var p = BcsPalette;
|
|
2426
|
-
var TokenTransferFromBcs = makeTokenTransfer(p);
|
|
2427
|
-
var TokenCreationFromBcs = makeTokenCreation(p);
|
|
2428
|
-
var TokenManagementFromBcs = makeTokenManagement(p);
|
|
2429
|
-
var MintFromBcs = makeMint(p);
|
|
2430
|
-
var BurnFromBcs = makeBurn(p);
|
|
2431
|
-
var StateInitializationFromBcs = makeStateInitialization(p);
|
|
2432
|
-
var StateUpdateFromBcs = makeStateUpdate(p);
|
|
2433
|
-
var StateResetFromBcs = makeStateReset(p);
|
|
2434
|
-
var ExternalClaimBodyFromBcs = makeExternalClaimBody(p);
|
|
2435
|
-
var VerifierSigFromBcs = makeVerifierSig(p);
|
|
2436
|
-
var ExternalClaimFromBcs = makeExternalClaim(p);
|
|
2437
|
-
var ValidatorConfigFromBcs = makeValidatorConfig(p);
|
|
2438
|
-
var CommitteeConfigFromBcs = makeCommitteeConfig(p);
|
|
2439
|
-
var CommitteeChangeFromBcs = makeCommitteeChange(p);
|
|
2440
|
-
var bcsOpts = { unitEncoding: "bcs" };
|
|
2441
|
-
var OperationFromBcs = makeOperation(p, bcsOpts);
|
|
2442
|
-
var ClaimTypeFromBcs = makeClaimType(p, bcsOpts);
|
|
2443
|
-
var TransactionFromBcs = makeTransaction(p, bcsOpts);
|
|
2444
|
-
var VersionedTransactionFromBcs = makeVersionedTransaction(p, bcsOpts);
|
|
2445
|
-
var MultiSigConfigFromBcs = makeMultiSigConfig(p);
|
|
2446
|
-
var MultiSigFromBcs = makeMultiSig(p);
|
|
2447
|
-
var SignatureOrMultiSigFromBcs = makeSignatureOrMultiSig(p);
|
|
2448
|
-
var TransactionEnvelopeFromBcs = makeTransactionEnvelope(p);
|
|
2449
|
-
var ValidatedTransactionFromBcs = makeValidatedTransaction(p);
|
|
2450
|
-
var TransactionCertificateFromBcs = makeTransactionCertificate(p);
|
|
2451
|
-
var NonceRangeFromBcs = makeNonceRange(p);
|
|
2452
|
-
var PageRequestFromBcs = makePageRequest(p);
|
|
2453
|
-
var TokenMetadataFromBcs = makeTokenMetadata(p);
|
|
2454
|
-
var AccountInfoResponseFromBcs = makeAccountInfoResponse(p);
|
|
2455
|
-
var TokenInfoResponseFromBcs = makeTokenInfoResponse(p);
|
|
2456
|
-
var SubmitTransactionResponseFromBcs = makeSubmitTransactionResponse(p);
|
|
2457
|
-
var ConfirmTransactionResponseFromBcs = makeConfirmTransactionResponse(p);
|
|
2458
|
-
var ProxySubmitTransactionResultFromBcs = makeProxySubmitTransactionResult(p);
|
|
2459
|
-
var p2 = RestPalette;
|
|
2460
|
-
var TokenTransferFromRest = makeTokenTransfer(p2);
|
|
2461
|
-
var TokenCreationFromRest = makeTokenCreation(p2);
|
|
2462
|
-
var TokenManagementFromRest = makeTokenManagement(p2);
|
|
2463
|
-
var MintFromRest = makeMint(p2);
|
|
2464
|
-
var BurnFromRest = makeBurn(p2);
|
|
2465
|
-
var StateInitializationFromRest = makeStateInitialization(p2);
|
|
2466
|
-
var StateUpdateFromRest = makeStateUpdate(p2);
|
|
2467
|
-
var StateResetFromRest = makeStateReset(p2);
|
|
2468
|
-
var ExternalClaimBodyFromRest = makeExternalClaimBody(p2);
|
|
2469
|
-
var VerifierSigFromRest = makeVerifierSig(p2);
|
|
2470
|
-
var ExternalClaimFromRest = makeExternalClaim(p2);
|
|
2471
|
-
var ValidatorConfigFromRest = makeValidatorConfig(p2);
|
|
2472
|
-
var CommitteeConfigFromRest = makeCommitteeConfig(p2);
|
|
2473
|
-
var CommitteeChangeFromRest = makeCommitteeChange(p2);
|
|
2474
|
-
var OperationFromRest = makeOperation(p2);
|
|
2475
|
-
var ClaimTypeFromRest = makeClaimType(p2);
|
|
2476
|
-
var TransactionFromRest = makeTransaction(p2);
|
|
2477
|
-
var VersionedTransactionFromRest = makeVersionedTransaction(p2);
|
|
2478
|
-
var MultiSigConfigFromRest = makeMultiSigConfig(p2);
|
|
2479
|
-
var MultiSigFromRest = makeMultiSig(p2);
|
|
2480
|
-
var SignatureOrMultiSigFromRest = makeSignatureOrMultiSig(p2);
|
|
2481
|
-
var TransactionEnvelopeFromRest = makeTransactionEnvelope(p2);
|
|
2482
|
-
var ValidatedTransactionFromRest = makeValidatedTransaction(p2);
|
|
2483
|
-
var TransactionCertificateFromRest = makeTransactionCertificate(p2);
|
|
2484
|
-
var NonceRangeFromRest = makeNonceRange(p2);
|
|
2485
|
-
var PageRequestFromRest = makePageRequest(p2);
|
|
2486
|
-
var TokenMetadataFromRest = makeTokenMetadata(p2);
|
|
2487
|
-
var AccountInfoResponseFromRest = makeAccountInfoResponse(p2);
|
|
2488
|
-
var TokenInfoResponseFromRest = makeTokenInfoResponse(p2);
|
|
2489
|
-
var SubmitTransactionResponseFromRest = makeSubmitTransactionResponse(p2);
|
|
2490
|
-
var ConfirmTransactionResponseFromRest = makeConfirmTransactionResponse(p2);
|
|
2491
|
-
var ProxySubmitTransactionResultFromRest = makeProxySubmitTransactionResult(p2);
|
|
2492
|
-
var p3 = RpcPalette;
|
|
2493
|
-
var TokenTransferFromRpc = makeTokenTransfer(p3);
|
|
2494
|
-
var TokenCreationFromRpc = makeTokenCreation(p3);
|
|
2495
|
-
var TokenManagementFromRpc = makeTokenManagement(p3);
|
|
2496
|
-
var MintFromRpc = makeMint(p3);
|
|
2497
|
-
var BurnFromRpc = makeBurn(p3);
|
|
2498
|
-
var StateInitializationFromRpc = makeStateInitialization(p3);
|
|
2499
|
-
var StateUpdateFromRpc = makeStateUpdate(p3);
|
|
2500
|
-
var StateResetFromRpc = makeStateReset(p3);
|
|
2501
|
-
var ExternalClaimBodyFromRpc = makeExternalClaimBody(p3);
|
|
2502
|
-
var VerifierSigFromRpc = makeVerifierSig(p3);
|
|
2503
|
-
var ExternalClaimFromRpc = makeExternalClaim(p3);
|
|
2504
|
-
var ValidatorConfigFromRpc = makeValidatorConfig(p3);
|
|
2505
|
-
var CommitteeConfigFromRpc = makeCommitteeConfig(p3);
|
|
2506
|
-
var CommitteeChangeFromRpc = makeCommitteeChange(p3);
|
|
2507
|
-
var OperationFromRpc = makeOperation(p3);
|
|
2508
|
-
var ClaimTypeFromRpc = makeClaimType(p3);
|
|
2509
|
-
var TransactionFromRpc = makeTransaction(p3);
|
|
2510
|
-
var VersionedTransactionFromRpc = makeVersionedTransaction(p3);
|
|
2511
|
-
var MultiSigConfigFromRpc = makeMultiSigConfig(p3);
|
|
2512
|
-
var MultiSigFromRpc = makeMultiSig(p3);
|
|
2513
|
-
var SignatureOrMultiSigFromRpc = makeSignatureOrMultiSig(p3);
|
|
2514
|
-
var TransactionEnvelopeFromRpc = makeTransactionEnvelope(p3);
|
|
2515
|
-
var ValidatedTransactionFromRpc = makeValidatedTransaction(p3);
|
|
2516
|
-
var TransactionCertificateFromRpc = makeTransactionCertificate(p3);
|
|
2517
|
-
var NonceRangeFromRpc = makeNonceRange(p3);
|
|
2518
|
-
var PageRequestFromRpc = makePageRequest(p3);
|
|
2519
|
-
var TokenMetadataFromRpc = makeTokenMetadata(p3);
|
|
2520
|
-
var AccountInfoResponseFromRpc = makeAccountInfoResponse(p3);
|
|
2521
|
-
var TokenInfoResponseFromRpc = makeTokenInfoResponse(p3);
|
|
2522
|
-
var SubmitTransactionResponseFromRpc = makeSubmitTransactionResponse(p3);
|
|
2523
|
-
var ConfirmTransactionResponseFromRpc = makeConfirmTransactionResponse(p3);
|
|
2524
|
-
var ProxySubmitTransactionResultFromRpc = makeProxySubmitTransactionResult(p3);
|
|
2525
|
-
var SubmitTransactionParamsFromRpc = makeSubmitTransactionParams(p3);
|
|
2526
|
-
var FaucetDripParamsFromRpc = makeFaucetDripParams(p3);
|
|
2527
|
-
var GetAccountInfoParamsFromRpc = makeGetAccountInfoParams(p3);
|
|
2528
|
-
var GetPendingMultisigParamsFromRpc = makeGetPendingMultisigParams(p3);
|
|
2529
|
-
var GetTokenInfoParamsFromRpc = makeGetTokenInfoParams(p3);
|
|
2530
|
-
var GetTransactionCertificatesParamsFromRpc = makeGetTransactionCertificatesParams(p3);
|
|
2531
|
-
|
|
2532
|
-
// ../../packages/fast-sdk/dist/chunk-J4LYMR5I.mjs
|
|
2533
|
-
import { Schema as Schema18 } from "effect";
|
|
2534
|
-
import { Effect as Effect3, Schema as Schema22 } from "effect";
|
|
634
|
+
import { Effect as Effect3, Schema } from "effect";
|
|
2535
635
|
|
|
2536
636
|
// ../../node_modules/.pnpm/json-with-bigint@3.5.8/node_modules/json-with-bigint/json-with-bigint.js
|
|
2537
637
|
var intRegex = /^-?\d+$/;
|
|
@@ -2636,8 +736,8 @@ var JSONParse = (text, reviver) => {
|
|
|
2636
736
|
);
|
|
2637
737
|
};
|
|
2638
738
|
|
|
2639
|
-
// ../../packages/fast-sdk/dist/chunk-
|
|
2640
|
-
import { Effect as Effect4, Schema as
|
|
739
|
+
// ../../packages/fast-sdk/dist/chunk-2WOJNW4N.js
|
|
740
|
+
import { Effect as Effect4, Encoding as Encoding2, Schema as Schema2 } from "effect";
|
|
2641
741
|
|
|
2642
742
|
// ../../node_modules/.pnpm/@noble+ed25519@3.0.1/node_modules/@noble/ed25519/index.js
|
|
2643
743
|
var ed25519_CURVE = {
|
|
@@ -2663,9 +763,9 @@ var err = (message2 = "") => {
|
|
|
2663
763
|
};
|
|
2664
764
|
var isBig = (n) => typeof n === "bigint";
|
|
2665
765
|
var isStr = (s) => typeof s === "string";
|
|
2666
|
-
var
|
|
766
|
+
var isBytes2 = (a) => a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
2667
767
|
var abytes2 = (value, length, title = "") => {
|
|
2668
|
-
const bytes =
|
|
768
|
+
const bytes = isBytes2(value);
|
|
2669
769
|
const len = value?.length;
|
|
2670
770
|
const needsLen = length !== void 0;
|
|
2671
771
|
if (!bytes || needsLen && len !== length) {
|
|
@@ -2745,7 +845,7 @@ var invert = (num, md) => {
|
|
|
2745
845
|
}
|
|
2746
846
|
return b === 1n ? M(x, md) : err("no inverse");
|
|
2747
847
|
};
|
|
2748
|
-
var apoint = (
|
|
848
|
+
var apoint = (p) => p instanceof Point ? p : err("Point expected");
|
|
2749
849
|
var B256 = 2n ** 256n;
|
|
2750
850
|
var Point = class _Point {
|
|
2751
851
|
static BASE;
|
|
@@ -2765,8 +865,8 @@ var Point = class _Point {
|
|
|
2765
865
|
static CURVE() {
|
|
2766
866
|
return ed25519_CURVE;
|
|
2767
867
|
}
|
|
2768
|
-
static fromAffine(
|
|
2769
|
-
return new _Point(
|
|
868
|
+
static fromAffine(p) {
|
|
869
|
+
return new _Point(p.x, p.y, 1n, modP(p.x * p.y));
|
|
2770
870
|
}
|
|
2771
871
|
/** RFC8032 5.1.3: Uint8Array to Point. */
|
|
2772
872
|
static fromBytes(hex, zip215 = false) {
|
|
@@ -2804,10 +904,10 @@ var Point = class _Point {
|
|
|
2804
904
|
assertValidity() {
|
|
2805
905
|
const a = _a;
|
|
2806
906
|
const d = _d;
|
|
2807
|
-
const
|
|
2808
|
-
if (
|
|
907
|
+
const p = this;
|
|
908
|
+
if (p.is0())
|
|
2809
909
|
return err("bad point: ZERO");
|
|
2810
|
-
const { X, Y, Z, T } =
|
|
910
|
+
const { X, Y, Z, T } = p;
|
|
2811
911
|
const X2 = modP(X * X);
|
|
2812
912
|
const Y2 = modP(Y * Y);
|
|
2813
913
|
const Z2 = modP(Z * Z);
|
|
@@ -2897,15 +997,15 @@ var Point = class _Point {
|
|
|
2897
997
|
return this;
|
|
2898
998
|
if (this.equals(G))
|
|
2899
999
|
return wNAF(n).p;
|
|
2900
|
-
let
|
|
1000
|
+
let p = I;
|
|
2901
1001
|
let f = G;
|
|
2902
1002
|
for (let d = this; n > 0n; d = d.double(), n >>= 1n) {
|
|
2903
1003
|
if (n & 1n)
|
|
2904
|
-
|
|
1004
|
+
p = p.add(d);
|
|
2905
1005
|
else if (safe)
|
|
2906
1006
|
f = f.add(d);
|
|
2907
1007
|
}
|
|
2908
|
-
return
|
|
1008
|
+
return p;
|
|
2909
1009
|
}
|
|
2910
1010
|
multiplyUnsafe(scalar) {
|
|
2911
1011
|
return this.multiply(scalar, false);
|
|
@@ -2938,10 +1038,10 @@ var Point = class _Point {
|
|
|
2938
1038
|
return this.clearCofactor().is0();
|
|
2939
1039
|
}
|
|
2940
1040
|
isTorsionFree() {
|
|
2941
|
-
let
|
|
1041
|
+
let p = this.multiply(N / 2n, false).double();
|
|
2942
1042
|
if (N % 2n)
|
|
2943
|
-
|
|
2944
|
-
return
|
|
1043
|
+
p = p.add(this);
|
|
1044
|
+
return p.is0();
|
|
2945
1045
|
}
|
|
2946
1046
|
};
|
|
2947
1047
|
var G = new Point(Gx, Gy, 1n, M(Gx * Gy));
|
|
@@ -3006,7 +1106,7 @@ var hash2extK = (hashed) => {
|
|
|
3006
1106
|
return { head, prefix, scalar, point, pointBytes };
|
|
3007
1107
|
};
|
|
3008
1108
|
var getExtendedPublicKeyAsync = (secretKey) => sha512a(abytes2(secretKey, L)).then(hash2extK);
|
|
3009
|
-
var getPublicKeyAsync = (secretKey) => getExtendedPublicKeyAsync(secretKey).then((
|
|
1109
|
+
var getPublicKeyAsync = (secretKey) => getExtendedPublicKeyAsync(secretKey).then((p) => p.pointBytes);
|
|
3010
1110
|
var hashFinishA = (res) => sha512a(res.hashable).then(res.finish);
|
|
3011
1111
|
var _sign = (e, rBytes, msg) => {
|
|
3012
1112
|
const { pointBytes: P2, scalar: s } = e;
|
|
@@ -3039,27 +1139,27 @@ var pwindows = Math.ceil(scalarBits / W) + 1;
|
|
|
3039
1139
|
var pwindowSize = 2 ** (W - 1);
|
|
3040
1140
|
var precompute = () => {
|
|
3041
1141
|
const points = [];
|
|
3042
|
-
let
|
|
3043
|
-
let b =
|
|
1142
|
+
let p = G;
|
|
1143
|
+
let b = p;
|
|
3044
1144
|
for (let w = 0; w < pwindows; w++) {
|
|
3045
|
-
b =
|
|
1145
|
+
b = p;
|
|
3046
1146
|
points.push(b);
|
|
3047
1147
|
for (let i = 1; i < pwindowSize; i++) {
|
|
3048
|
-
b = b.add(
|
|
1148
|
+
b = b.add(p);
|
|
3049
1149
|
points.push(b);
|
|
3050
1150
|
}
|
|
3051
|
-
|
|
1151
|
+
p = b.double();
|
|
3052
1152
|
}
|
|
3053
1153
|
return points;
|
|
3054
1154
|
};
|
|
3055
1155
|
var Gpows = void 0;
|
|
3056
|
-
var ctneg = (cnd,
|
|
3057
|
-
const n =
|
|
3058
|
-
return cnd ? n :
|
|
1156
|
+
var ctneg = (cnd, p) => {
|
|
1157
|
+
const n = p.negate();
|
|
1158
|
+
return cnd ? n : p;
|
|
3059
1159
|
};
|
|
3060
1160
|
var wNAF = (n) => {
|
|
3061
1161
|
const comp = Gpows || (Gpows = precompute());
|
|
3062
|
-
let
|
|
1162
|
+
let p = I;
|
|
3063
1163
|
let f = G;
|
|
3064
1164
|
const pow_2_w = 2 ** W;
|
|
3065
1165
|
const maxNum = pow_2_w;
|
|
@@ -3080,17 +1180,17 @@ var wNAF = (n) => {
|
|
|
3080
1180
|
if (wbits === 0) {
|
|
3081
1181
|
f = f.add(ctneg(isEven, comp[offF]));
|
|
3082
1182
|
} else {
|
|
3083
|
-
|
|
1183
|
+
p = p.add(ctneg(isNeg, comp[offP]));
|
|
3084
1184
|
}
|
|
3085
1185
|
}
|
|
3086
1186
|
if (n !== 0n)
|
|
3087
1187
|
err("invalid wnaf");
|
|
3088
|
-
return { p
|
|
1188
|
+
return { p, f };
|
|
3089
1189
|
};
|
|
3090
1190
|
|
|
3091
|
-
// ../../packages/fast-sdk/dist/chunk-
|
|
1191
|
+
// ../../packages/fast-sdk/dist/chunk-2WOJNW4N.js
|
|
3092
1192
|
import { Effect as Effect5 } from "effect";
|
|
3093
|
-
import { Effect as Effect6, Schema as
|
|
1193
|
+
import { Effect as Effect6, Schema as Schema3 } from "effect";
|
|
3094
1194
|
var BcsEncodeError = class extends Data.TaggedError("BcsEncodeError") {
|
|
3095
1195
|
};
|
|
3096
1196
|
var SigningError = class extends Data.TaggedError("SigningError") {
|
|
@@ -3152,30 +1252,12 @@ var ValidatorGenericError = class extends Data2.TaggedError(
|
|
|
3152
1252
|
};
|
|
3153
1253
|
var RpcTimeoutError = class extends Data3.TaggedError("RpcTimeoutError") {
|
|
3154
1254
|
};
|
|
3155
|
-
var
|
|
3156
|
-
"JsonRpcProtocolError"
|
|
3157
|
-
) {
|
|
1255
|
+
var RestTimeoutError = class extends Data3.TaggedError("RestTimeoutError") {
|
|
3158
1256
|
};
|
|
3159
|
-
var
|
|
1257
|
+
var RestError = class extends Data3.TaggedError("RestError") {
|
|
3160
1258
|
};
|
|
3161
1259
|
var GeneralError = class extends Data4.TaggedError("GeneralError") {
|
|
3162
1260
|
};
|
|
3163
|
-
var FaucetDisabledError = class extends Data4.TaggedError(
|
|
3164
|
-
"FaucetDisabledError"
|
|
3165
|
-
) {
|
|
3166
|
-
};
|
|
3167
|
-
var FaucetThrottledError = class extends Data4.TaggedError(
|
|
3168
|
-
"FaucetThrottledError"
|
|
3169
|
-
) {
|
|
3170
|
-
};
|
|
3171
|
-
var FaucetTxnFailedError = class extends Data4.TaggedError(
|
|
3172
|
-
"FaucetTxnFailedError"
|
|
3173
|
-
) {
|
|
3174
|
-
};
|
|
3175
|
-
var FaucetThresholdExceededError = class extends Data4.TaggedError(
|
|
3176
|
-
"FaucetThresholdExceededError"
|
|
3177
|
-
) {
|
|
3178
|
-
};
|
|
3179
1261
|
var VerifierSigsInvalidError = class extends Data4.TaggedError(
|
|
3180
1262
|
"VerifierSigsInvalidError"
|
|
3181
1263
|
) {
|
|
@@ -3194,174 +1276,214 @@ var InvalidRequestError = class extends Data4.TaggedError(
|
|
|
3194
1276
|
"InvalidRequestError"
|
|
3195
1277
|
) {
|
|
3196
1278
|
};
|
|
3197
|
-
var
|
|
3198
|
-
if (rpcErr.type === "Generic") {
|
|
3199
|
-
return new ValidatorGenericError({ message: rpcErr.value });
|
|
3200
|
-
}
|
|
3201
|
-
const err2 = rpcErr.value;
|
|
3202
|
-
switch (err2.type) {
|
|
3203
|
-
case "UnexpectedNonce":
|
|
3204
|
-
return new UnexpectedNonceError({
|
|
3205
|
-
message: message2,
|
|
3206
|
-
expectedNonce: err2.value.expectedNonce
|
|
3207
|
-
});
|
|
3208
|
-
case "InsufficientFunding":
|
|
3209
|
-
return new InsufficientFundingError({
|
|
3210
|
-
message: message2,
|
|
3211
|
-
currentBalance: err2.value.currentBalance
|
|
3212
|
-
});
|
|
3213
|
-
case "PreviousTransactionMustBeConfirmedFirst":
|
|
3214
|
-
return new PreviousTransactionPendingError({
|
|
3215
|
-
message: message2,
|
|
3216
|
-
pendingConfirmation: err2.value.pendingConfirmation
|
|
3217
|
-
});
|
|
3218
|
-
case "InvalidSignature":
|
|
3219
|
-
return new InvalidSignatureError({ message: message2, error: err2.value.error });
|
|
3220
|
-
case "MissingEarlierConfirmations":
|
|
3221
|
-
return new MissingEarlierConfirmationsError({
|
|
3222
|
-
message: message2,
|
|
3223
|
-
currentNonce: err2.value.currentNonce
|
|
3224
|
-
});
|
|
3225
|
-
case "CertificateTooYoung":
|
|
3226
|
-
return new CertificateTooYoungError({
|
|
3227
|
-
message: message2,
|
|
3228
|
-
resendAfterNanos: err2.value.resendAfterNanos
|
|
3229
|
-
});
|
|
3230
|
-
case "NonSubmittableOperation":
|
|
3231
|
-
return new NonSubmittableOperationError({
|
|
3232
|
-
message: message2,
|
|
3233
|
-
reason: err2.value.reason
|
|
3234
|
-
});
|
|
3235
|
-
default:
|
|
3236
|
-
return new GeneralError({ message: message2 });
|
|
3237
|
-
}
|
|
1279
|
+
var NotFoundError = class extends Data4.TaggedError("NotFoundError") {
|
|
3238
1280
|
};
|
|
3239
|
-
var
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
case "
|
|
1281
|
+
var IpRateLimitedError = class extends Data4.TaggedError(
|
|
1282
|
+
"IpRateLimitedError"
|
|
1283
|
+
) {
|
|
1284
|
+
};
|
|
1285
|
+
var UpstreamError = class extends Data4.TaggedError("UpstreamError") {
|
|
1286
|
+
};
|
|
1287
|
+
var ServiceUnavailableError = class extends Data4.TaggedError(
|
|
1288
|
+
"ServiceUnavailableError"
|
|
1289
|
+
) {
|
|
1290
|
+
};
|
|
1291
|
+
var parseRestError = (status, err2) => {
|
|
1292
|
+
const { code, message: message2, details } = err2;
|
|
1293
|
+
const d = details;
|
|
1294
|
+
switch (code) {
|
|
1295
|
+
case "INVALID_REQUEST":
|
|
1296
|
+
return new InvalidRequestError({ message: message2 });
|
|
1297
|
+
case "NOT_FOUND":
|
|
1298
|
+
return new NotFoundError({ message: message2 });
|
|
1299
|
+
case "TOO_MANY_CERTIFICATES_REQUESTED":
|
|
1300
|
+
return new TooManyCertificatesRequestedError({ message: message2 });
|
|
1301
|
+
case "UNEXPECTED_NONCE":
|
|
3254
1302
|
return new ProxyUnexpectedNonceError({
|
|
3255
1303
|
message: message2,
|
|
3256
|
-
txNonce:
|
|
3257
|
-
expectedNonce:
|
|
1304
|
+
txNonce: BigInt(d?.tx_nonce ?? 0),
|
|
1305
|
+
expectedNonce: BigInt(d?.expected_nonce ?? 0)
|
|
3258
1306
|
});
|
|
3259
|
-
case "
|
|
3260
|
-
return new GeneralError({ message: parsed2.value });
|
|
3261
|
-
case "FaucetDisabled":
|
|
3262
|
-
return new FaucetDisabledError({ message: message2 });
|
|
3263
|
-
case "FaucetThrottled":
|
|
3264
|
-
return new FaucetThrottledError({ message: message2 });
|
|
3265
|
-
case "FaucetTxnFailed":
|
|
3266
|
-
return new FaucetTxnFailedError({ message: message2 });
|
|
3267
|
-
case "FaucetThresholdExceeded":
|
|
3268
|
-
return new FaucetThresholdExceededError({ message: message2 });
|
|
3269
|
-
case "VerifierSigsInvalid":
|
|
1307
|
+
case "VERIFIER_SIGNATURES_INVALID":
|
|
3270
1308
|
return new VerifierSigsInvalidError({ message: message2 });
|
|
3271
|
-
case "
|
|
3272
|
-
return new
|
|
3273
|
-
case "
|
|
3274
|
-
return new
|
|
3275
|
-
case "
|
|
3276
|
-
return new
|
|
1309
|
+
case "INTERNAL_ERROR":
|
|
1310
|
+
return new GeneralError({ message: message2 });
|
|
1311
|
+
case "UPSTREAM_ERROR":
|
|
1312
|
+
return new UpstreamError({ message: message2 });
|
|
1313
|
+
case "IP_RATE_LIMITED":
|
|
1314
|
+
return new IpRateLimitedError({
|
|
1315
|
+
message: message2,
|
|
1316
|
+
retryAfterSecs: d?.retry_after_secs ?? 0
|
|
1317
|
+
});
|
|
1318
|
+
case "SERVICE_UNAVAILABLE":
|
|
1319
|
+
return new ServiceUnavailableError({ message: message2 });
|
|
1320
|
+
case "DATABASE_ERROR":
|
|
1321
|
+
return new DatabaseError2({ message: message2 });
|
|
3277
1322
|
default:
|
|
3278
|
-
return new
|
|
1323
|
+
return new RestError({ status, code, message: message2, details });
|
|
3279
1324
|
}
|
|
3280
1325
|
};
|
|
3281
|
-
var
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
id: Schema22.Number,
|
|
3285
|
-
result: Schema22.optional(Schema22.Unknown),
|
|
3286
|
-
error: Schema22.optional(
|
|
3287
|
-
Schema22.Struct({
|
|
3288
|
-
code: Schema22.Number,
|
|
3289
|
-
message: Schema22.String,
|
|
3290
|
-
data: Schema22.optional(Schema22.Unknown)
|
|
3291
|
-
})
|
|
3292
|
-
)
|
|
1326
|
+
var RestSuccessEnvelope = Schema.Struct({
|
|
1327
|
+
data: Schema.Unknown,
|
|
1328
|
+
meta: Schema.Struct({ timestamp: Schema.String })
|
|
3293
1329
|
});
|
|
3294
|
-
var
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
()
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
1330
|
+
var RestErrorEnvelope = Schema.Struct({
|
|
1331
|
+
error: Schema.Struct({
|
|
1332
|
+
code: Schema.String,
|
|
1333
|
+
message: Schema.String,
|
|
1334
|
+
details: Schema.optional(Schema.Unknown)
|
|
1335
|
+
}),
|
|
1336
|
+
meta: Schema.Struct({ timestamp: Schema.String })
|
|
1337
|
+
});
|
|
1338
|
+
var restCallEffect = (baseUrl, opts) => {
|
|
1339
|
+
const timeoutMs = opts.timeoutMs ?? 15e3;
|
|
1340
|
+
return Effect3.gen(function* () {
|
|
1341
|
+
const url = new URL(`${baseUrl.replace(/\/$/, "")}${opts.path}`);
|
|
1342
|
+
if (opts.query) {
|
|
1343
|
+
for (const [k, v] of Object.entries(opts.query)) {
|
|
1344
|
+
if (v !== void 0) url.searchParams.set(k, v);
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
const fetchOpts = { method: opts.method };
|
|
1348
|
+
if (opts.body !== void 0) {
|
|
1349
|
+
fetchOpts.headers = { "Content-Type": "application/json" };
|
|
1350
|
+
fetchOpts.body = JSONStringify(opts.body);
|
|
1351
|
+
}
|
|
1352
|
+
const res = yield* Effect3.tryPromise(() => fetch(url.toString(), fetchOpts));
|
|
1353
|
+
const text = yield* Effect3.tryPromise(() => res.text());
|
|
1354
|
+
let json;
|
|
1355
|
+
try {
|
|
1356
|
+
json = JSONParse(text);
|
|
1357
|
+
} catch {
|
|
1358
|
+
return yield* parseRestError(res.status, {
|
|
1359
|
+
code: `HTTP_${res.status}`,
|
|
1360
|
+
message: text.slice(0, 200)
|
|
1361
|
+
});
|
|
1362
|
+
}
|
|
1363
|
+
if (!res.ok) {
|
|
1364
|
+
const errEnv = yield* Schema.decodeUnknown(RestErrorEnvelope)(json);
|
|
1365
|
+
return yield* parseRestError(res.status, errEnv.error);
|
|
1366
|
+
}
|
|
1367
|
+
const okEnv = yield* Schema.decodeUnknown(RestSuccessEnvelope)(json);
|
|
1368
|
+
return okEnv.data;
|
|
1369
|
+
}).pipe(
|
|
1370
|
+
Effect3.timeout(`${timeoutMs} millis`),
|
|
1371
|
+
Effect3.catchTag(
|
|
1372
|
+
"TimeoutException",
|
|
1373
|
+
() => new RestTimeoutError({ path: opts.path, timeoutMs })
|
|
1374
|
+
)
|
|
3303
1375
|
);
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
}).pipe(
|
|
3311
|
-
Effect3.timeout(`${timeoutMs} millis`),
|
|
3312
|
-
Effect3.catchTag(
|
|
3313
|
-
"TimeoutException",
|
|
3314
|
-
() => new RpcTimeoutError({ method, timeoutMs })
|
|
3315
|
-
)
|
|
3316
|
-
);
|
|
3317
|
-
var submitTransaction = (rpcUrl, params) => Effect4.gen(function* () {
|
|
3318
|
-
const wire = yield* Schema32.encode(SubmitTransactionParamsFromRpc)(params);
|
|
3319
|
-
const result2 = yield* rpcCallEffect(
|
|
3320
|
-
rpcUrl,
|
|
3321
|
-
"proxy_submitTransaction",
|
|
3322
|
-
wire
|
|
1376
|
+
};
|
|
1377
|
+
var addressToStr = (addr) => Schema2.encodeSync(AddressFromRest)(addr);
|
|
1378
|
+
var tokenIdToHex = (id) => Schema2.encodeSync(TokenIdFromRest)(id);
|
|
1379
|
+
var submitTransaction = (url, params) => Effect4.gen(function* () {
|
|
1380
|
+
const bcsEncoded = yield* Schema2.encode(VersionedTransactionFromBcs)(
|
|
1381
|
+
params.transaction
|
|
3323
1382
|
);
|
|
3324
|
-
|
|
1383
|
+
const txBytes = yield* encode(
|
|
1384
|
+
bcs_layout_exports.VersionedTransaction,
|
|
1385
|
+
bcsEncoded
|
|
1386
|
+
);
|
|
1387
|
+
const txHex = Encoding2.encodeHex(txBytes);
|
|
1388
|
+
const sigBcsEncoded = yield* Schema2.encode(SignatureOrMultiSigFromBcs)(
|
|
1389
|
+
params.signature
|
|
1390
|
+
);
|
|
1391
|
+
const sigBytes = yield* encode(
|
|
1392
|
+
bcs_layout_exports.SignatureOrMultiSig,
|
|
1393
|
+
sigBcsEncoded
|
|
1394
|
+
);
|
|
1395
|
+
const sigHex = Encoding2.encodeHex(sigBytes);
|
|
1396
|
+
const result2 = yield* restCallEffect(url, {
|
|
1397
|
+
method: "POST",
|
|
1398
|
+
path: "/v1/submit-transaction",
|
|
1399
|
+
body: {
|
|
1400
|
+
transaction: txHex,
|
|
1401
|
+
signature: sigHex,
|
|
1402
|
+
witness_certificates: []
|
|
1403
|
+
}
|
|
1404
|
+
});
|
|
1405
|
+
return yield* Schema2.decodeUnknown(ProxySubmitTransactionResultFromRest)(
|
|
3325
1406
|
result2
|
|
3326
1407
|
);
|
|
3327
1408
|
});
|
|
3328
|
-
var
|
|
3329
|
-
const
|
|
3330
|
-
yield*
|
|
1409
|
+
var getAccountInfo = (url, params) => Effect4.gen(function* () {
|
|
1410
|
+
const addr = addressToStr(params.address);
|
|
1411
|
+
const result2 = yield* restCallEffect(url, {
|
|
1412
|
+
method: "GET",
|
|
1413
|
+
path: `/v1/accounts/${addr}`,
|
|
1414
|
+
query: {
|
|
1415
|
+
token_balances_filter: params.tokenBalancesFilter ? params.tokenBalancesFilter.map(tokenIdToHex).join(",") : void 0,
|
|
1416
|
+
state_key_filter: params.stateKeyFilter ? params.stateKeyFilter.map((k) => Encoding2.encodeHex(k)).join(",") : void 0
|
|
1417
|
+
}
|
|
1418
|
+
});
|
|
1419
|
+
return yield* Schema2.decodeUnknown(AccountInfoResponseFromRest)(result2);
|
|
3331
1420
|
});
|
|
3332
|
-
var
|
|
3333
|
-
const
|
|
3334
|
-
const result2 = yield*
|
|
3335
|
-
|
|
1421
|
+
var getPendingMultisigTransactions = (url, params) => Effect4.gen(function* () {
|
|
1422
|
+
const addr = addressToStr(params.address);
|
|
1423
|
+
const result2 = yield* restCallEffect(url, {
|
|
1424
|
+
method: "GET",
|
|
1425
|
+
path: `/v1/accounts/${addr}/pending-multisig-transactions`
|
|
1426
|
+
});
|
|
1427
|
+
return yield* Schema2.decodeUnknown(
|
|
1428
|
+
Schema2.Array(TransactionEnvelopeFromRest)
|
|
1429
|
+
)(result2);
|
|
3336
1430
|
});
|
|
3337
|
-
var
|
|
3338
|
-
const
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
1431
|
+
var getTokenInfo = (url, params) => Effect4.gen(function* () {
|
|
1432
|
+
const result2 = yield* restCallEffect(url, {
|
|
1433
|
+
method: "GET",
|
|
1434
|
+
path: "/v1/tokens",
|
|
1435
|
+
query: {
|
|
1436
|
+
token_ids: params.tokenIds.map(tokenIdToHex).join(",")
|
|
1437
|
+
}
|
|
1438
|
+
});
|
|
1439
|
+
return yield* Schema2.decodeUnknown(TokenInfoResponseFromRest)(result2);
|
|
1440
|
+
});
|
|
1441
|
+
var getTransactionCertificates = (url, params) => Effect4.gen(function* () {
|
|
1442
|
+
const addr = addressToStr(params.address);
|
|
1443
|
+
const result2 = yield* restCallEffect(url, {
|
|
1444
|
+
method: "GET",
|
|
1445
|
+
path: `/v1/accounts/${addr}/certificates`,
|
|
1446
|
+
query: {
|
|
1447
|
+
from_nonce: params.fromNonce.toString(),
|
|
1448
|
+
limit: params.limit.toString()
|
|
1449
|
+
}
|
|
1450
|
+
});
|
|
1451
|
+
return yield* Schema2.decodeUnknown(
|
|
1452
|
+
Schema2.Array(TransactionCertificateFromRest)
|
|
3346
1453
|
)(result2);
|
|
3347
1454
|
});
|
|
3348
|
-
var
|
|
3349
|
-
const
|
|
3350
|
-
const result2 = yield*
|
|
3351
|
-
|
|
1455
|
+
var getEscrowJob = (url, params) => Effect4.gen(function* () {
|
|
1456
|
+
const jobIdHex = tokenIdToHex(params.jobId);
|
|
1457
|
+
const result2 = yield* restCallEffect(url, {
|
|
1458
|
+
method: "GET",
|
|
1459
|
+
path: `/v1/escrow-jobs/${jobIdHex}`,
|
|
1460
|
+
query: { certs: params.certs ? "true" : void 0 }
|
|
1461
|
+
});
|
|
1462
|
+
if (params.certs) {
|
|
1463
|
+
return yield* Schema2.decodeUnknown(EscrowJobWithCertsFromRest)(result2);
|
|
1464
|
+
}
|
|
1465
|
+
return yield* Schema2.decodeUnknown(EscrowJobRecordFromRest)(result2);
|
|
3352
1466
|
});
|
|
3353
|
-
var
|
|
3354
|
-
const
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
1467
|
+
var getEscrowJobs = (url, params) => Effect4.gen(function* () {
|
|
1468
|
+
const result2 = yield* restCallEffect(url, {
|
|
1469
|
+
method: "GET",
|
|
1470
|
+
path: "/v1/escrow-jobs",
|
|
1471
|
+
query: {
|
|
1472
|
+
client: params.client ? addressToStr(params.client) : void 0,
|
|
1473
|
+
provider: params.provider ? addressToStr(params.provider) : void 0,
|
|
1474
|
+
evaluator: params.evaluator ? addressToStr(params.evaluator) : void 0,
|
|
1475
|
+
status: params.status,
|
|
1476
|
+
certs: params.certs ? "true" : void 0
|
|
1477
|
+
}
|
|
1478
|
+
});
|
|
1479
|
+
if (params.certs) {
|
|
1480
|
+
return yield* Schema2.decodeUnknown(
|
|
1481
|
+
Schema2.Array(EscrowJobWithCertsFromRest)
|
|
1482
|
+
)(result2);
|
|
1483
|
+
}
|
|
1484
|
+
return yield* Schema2.decodeUnknown(Schema2.Array(EscrowJobRecordFromRest))(
|
|
1485
|
+
result2
|
|
3361
1486
|
);
|
|
3362
|
-
return yield* Schema32.decodeUnknown(
|
|
3363
|
-
Schema32.Array(TransactionCertificateFromRpc)
|
|
3364
|
-
)(result2);
|
|
3365
1487
|
});
|
|
3366
1488
|
var signMessage = (privateKey, message2) => Effect5.tryPromise({
|
|
3367
1489
|
try: () => signAsync(message2, privateKey),
|
|
@@ -3376,7 +1498,7 @@ var getPublicKey = (privateKey) => Effect5.tryPromise({
|
|
|
3376
1498
|
catch: (cause) => new PublicKeyError({ cause })
|
|
3377
1499
|
});
|
|
3378
1500
|
var buildSignedEnvelope = (privateKey, transaction) => Effect6.gen(function* () {
|
|
3379
|
-
const bcsEncoded = yield*
|
|
1501
|
+
const bcsEncoded = yield* Schema3.encode(VersionedTransactionFromBcs)(
|
|
3380
1502
|
transaction
|
|
3381
1503
|
);
|
|
3382
1504
|
const rawSig = yield* signTypedData(
|
|
@@ -3384,82 +1506,98 @@ var buildSignedEnvelope = (privateKey, transaction) => Effect6.gen(function* ()
|
|
|
3384
1506
|
bcs_layout_exports.VersionedTransaction,
|
|
3385
1507
|
bcsEncoded
|
|
3386
1508
|
);
|
|
3387
|
-
const signature = yield*
|
|
1509
|
+
const signature = yield* Schema3.decodeUnknown(SignatureFromInput)(rawSig);
|
|
3388
1510
|
return {
|
|
3389
1511
|
transaction,
|
|
3390
1512
|
signature: { type: "Signature", value: signature }
|
|
3391
1513
|
};
|
|
3392
1514
|
});
|
|
3393
1515
|
|
|
3394
|
-
// ../../packages/fast-sdk/dist/index.
|
|
3395
|
-
import { bech32m
|
|
3396
|
-
import { Encoding as
|
|
3397
|
-
import { Schema as
|
|
3398
|
-
import { Redacted, Schema as
|
|
3399
|
-
import { Schema as
|
|
3400
|
-
var
|
|
3401
|
-
var
|
|
1516
|
+
// ../../packages/fast-sdk/dist/index.js
|
|
1517
|
+
import { bech32m } from "bech32";
|
|
1518
|
+
import { Encoding as Encoding3 } from "effect";
|
|
1519
|
+
import { Schema as Schema4 } from "effect";
|
|
1520
|
+
import { Redacted, Schema as Schema22 } from "effect";
|
|
1521
|
+
import { Schema as Schema32 } from "effect";
|
|
1522
|
+
var toHex2 = (bytes) => `0x${Encoding3.encodeHex(bytes)}`;
|
|
1523
|
+
var fromHex2 = (hex) => {
|
|
3402
1524
|
const stripped = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
3403
|
-
const result2 =
|
|
1525
|
+
const result2 = Encoding3.decodeHex(stripped);
|
|
3404
1526
|
if (result2._tag === "Left") throw new Error(`Invalid hex string: ${hex}`);
|
|
3405
1527
|
return result2.right;
|
|
3406
1528
|
};
|
|
3407
|
-
var toFastAddress = (bytes) =>
|
|
1529
|
+
var toFastAddress = (bytes) => bech32m.encode("fast", bech32m.toWords(bytes));
|
|
3408
1530
|
var fromFastAddress = (address) => {
|
|
3409
|
-
const { prefix, words } =
|
|
1531
|
+
const { prefix, words } = bech32m.decode(address);
|
|
3410
1532
|
if (prefix !== "fast")
|
|
3411
1533
|
throw new Error(`Expected "fast" prefix, got "${prefix}"`);
|
|
3412
|
-
return new Uint8Array(
|
|
1534
|
+
return new Uint8Array(bech32m.fromWords(words));
|
|
3413
1535
|
};
|
|
3414
1536
|
var hashHex2 = (schema, message2) => run(hashHex(schema, message2));
|
|
3415
1537
|
var FastProvider = class {
|
|
3416
|
-
|
|
1538
|
+
_network;
|
|
3417
1539
|
constructor(opts) {
|
|
3418
|
-
this.
|
|
1540
|
+
this._network = {
|
|
1541
|
+
url: opts.url,
|
|
1542
|
+
networkId: opts.networkId,
|
|
1543
|
+
explorerUrl: opts.explorerUrl
|
|
1544
|
+
};
|
|
3419
1545
|
}
|
|
3420
|
-
/** The
|
|
3421
|
-
get
|
|
3422
|
-
return this.
|
|
1546
|
+
/** The {@link FastNetwork} this provider targets. */
|
|
1547
|
+
get network() {
|
|
1548
|
+
return this._network;
|
|
1549
|
+
}
|
|
1550
|
+
/** The proxy base URL this provider was constructed with. */
|
|
1551
|
+
get url() {
|
|
1552
|
+
return this._network.url;
|
|
3423
1553
|
}
|
|
3424
1554
|
/**
|
|
3425
1555
|
* Submit a signed transaction envelope to the network.
|
|
3426
1556
|
* The envelope should be produced by {@link TransactionBuilder.sign}.
|
|
3427
1557
|
*/
|
|
3428
1558
|
async submitTransaction(params) {
|
|
3429
|
-
return run(submitTransaction(this.
|
|
3430
|
-
}
|
|
3431
|
-
/** Request a faucet drip for the given recipient. */
|
|
3432
|
-
async faucetDrip(params) {
|
|
3433
|
-
const internal = Schema19.decodeUnknownSync(FaucetDripInput)(params);
|
|
3434
|
-
return run(faucetDrip(this._rpcUrl, internal));
|
|
1559
|
+
return run(submitTransaction(this._network.url, params));
|
|
3435
1560
|
}
|
|
3436
1561
|
/**
|
|
3437
1562
|
* Fetch account information including balance, nonce, token balances, and state.
|
|
3438
1563
|
* Use filters to request specific token balances or state keys.
|
|
3439
1564
|
*/
|
|
3440
1565
|
async getAccountInfo(params) {
|
|
3441
|
-
const internal =
|
|
3442
|
-
return run(getAccountInfo(this.
|
|
1566
|
+
const internal = Schema4.decodeUnknownSync(GetAccountInfoInput)(params);
|
|
1567
|
+
return run(getAccountInfo(this._network.url, internal));
|
|
3443
1568
|
}
|
|
3444
1569
|
/** Fetch pending multisig transactions for the given address. */
|
|
3445
1570
|
async getPendingMultisigTransactions(params) {
|
|
3446
|
-
const internal =
|
|
3447
|
-
return run(getPendingMultisigTransactions(this.
|
|
1571
|
+
const internal = Schema4.decodeUnknownSync(GetPendingMultisigInput)(params);
|
|
1572
|
+
return run(getPendingMultisigTransactions(this._network.url, internal));
|
|
3448
1573
|
}
|
|
3449
1574
|
/** Fetch metadata for one or more tokens by their IDs. */
|
|
3450
1575
|
async getTokenInfo(params) {
|
|
3451
|
-
const internal =
|
|
3452
|
-
return run(getTokenInfo(this.
|
|
1576
|
+
const internal = Schema4.decodeUnknownSync(GetTokenInfoInput)(params);
|
|
1577
|
+
return run(getTokenInfo(this._network.url, internal));
|
|
3453
1578
|
}
|
|
3454
1579
|
/**
|
|
3455
1580
|
* Fetch finalized transaction certificates for an address.
|
|
3456
1581
|
* Results are paginated by nonce range.
|
|
3457
1582
|
*/
|
|
3458
1583
|
async getTransactionCertificates(params) {
|
|
3459
|
-
const internal =
|
|
1584
|
+
const internal = Schema4.decodeUnknownSync(GetTransactionCertificatesInput)(
|
|
3460
1585
|
params
|
|
3461
1586
|
);
|
|
3462
|
-
return run(getTransactionCertificates(this.
|
|
1587
|
+
return run(getTransactionCertificates(this._network.url, internal));
|
|
1588
|
+
}
|
|
1589
|
+
/** Fetch a single escrow job by ID, optionally including certificates. */
|
|
1590
|
+
async getEscrowJob(params) {
|
|
1591
|
+
const internal = Schema4.decodeUnknownSync(GetEscrowJobInput)(params);
|
|
1592
|
+
return run(getEscrowJob(this._network.url, internal));
|
|
1593
|
+
}
|
|
1594
|
+
/**
|
|
1595
|
+
* List escrow jobs filtered by role (client, provider, or evaluator).
|
|
1596
|
+
* Optionally filter by status and include certificates.
|
|
1597
|
+
*/
|
|
1598
|
+
async getEscrowJobs(params) {
|
|
1599
|
+
const internal = Schema4.decodeUnknownSync(GetEscrowJobsInput)(params);
|
|
1600
|
+
return run(getEscrowJobs(this._network.url, internal));
|
|
3463
1601
|
}
|
|
3464
1602
|
};
|
|
3465
1603
|
var Signer = class {
|
|
@@ -3471,7 +1609,7 @@ var Signer = class {
|
|
|
3471
1609
|
* @throws ParseError if the key is not exactly 32 bytes.
|
|
3472
1610
|
*/
|
|
3473
1611
|
constructor(privateKey) {
|
|
3474
|
-
const key =
|
|
1612
|
+
const key = Schema22.decodeUnknownSync(PrivateKeyFromInput)(privateKey);
|
|
3475
1613
|
this.privateKey = Redacted.make(key);
|
|
3476
1614
|
}
|
|
3477
1615
|
/** Return the raw private key bytes. Handle with care. */
|
|
@@ -3560,6 +1698,11 @@ var TransactionBuilder = class {
|
|
|
3560
1698
|
this.operations.push({ type: "LeaveCommittee" });
|
|
3561
1699
|
return this;
|
|
3562
1700
|
}
|
|
1701
|
+
/** Add an escrow operation (CreateConfig, CreateJob, Submit, Reject, Complete). */
|
|
1702
|
+
addEscrow(params) {
|
|
1703
|
+
this.operations.push({ type: "Escrow", value: params });
|
|
1704
|
+
return this;
|
|
1705
|
+
}
|
|
3563
1706
|
/** Update the nonce for the next {@link sign} call. */
|
|
3564
1707
|
setNonce(nonce) {
|
|
3565
1708
|
this.options = { ...this.options, nonce };
|
|
@@ -3585,22 +1728,24 @@ var TransactionBuilder = class {
|
|
|
3585
1728
|
* @returns A signed {@link TransactionEnvelope} ready for submission.
|
|
3586
1729
|
*/
|
|
3587
1730
|
async sign() {
|
|
1731
|
+
if (this.operations.length === 0) {
|
|
1732
|
+
throw new Error("TransactionBuilder.sign() requires at least one operation");
|
|
1733
|
+
}
|
|
3588
1734
|
const { signer, networkId, nonce, version, archival, feeToken } = this.options;
|
|
3589
1735
|
const sender = await signer.getPublicKey();
|
|
3590
1736
|
const privateKey = await signer.getPrivateKey();
|
|
3591
1737
|
const ops = this.operations;
|
|
3592
|
-
const
|
|
3593
|
-
const
|
|
1738
|
+
const type = version ?? LatestTransactionVersion;
|
|
1739
|
+
const config = getTransactionVersionConfig(type);
|
|
1740
|
+
const internal = Schema32.decodeUnknownSync(config.inputSchema)({
|
|
3594
1741
|
networkId,
|
|
3595
1742
|
sender,
|
|
3596
1743
|
nonce,
|
|
3597
1744
|
timestampNanos: BigInt(Date.now()) * 1000000n,
|
|
3598
|
-
|
|
1745
|
+
...config.wrapOperations(ops),
|
|
3599
1746
|
archival: archival ?? false,
|
|
3600
1747
|
feeToken: feeToken ?? null
|
|
3601
|
-
};
|
|
3602
|
-
const internal = Schema33.decodeUnknownSync(TransactionInput)(txInput);
|
|
3603
|
-
const type = version ?? "Release20260319";
|
|
1748
|
+
});
|
|
3604
1749
|
const versioned = { type, value: internal };
|
|
3605
1750
|
return run(buildSignedEnvelope(privateKey, versioned));
|
|
3606
1751
|
}
|
|
@@ -3895,11 +2040,11 @@ async function recoverAuthorizationAddress(parameters) {
|
|
|
3895
2040
|
|
|
3896
2041
|
// ../../node_modules/.pnpm/viem@2.47.6_typescript@6.0.2/node_modules/viem/_esm/errors/estimateGas.js
|
|
3897
2042
|
var EstimateGasExecutionError = class extends BaseError {
|
|
3898
|
-
constructor(cause, { account, docsPath: docsPath3, chain
|
|
2043
|
+
constructor(cause, { account, docsPath: docsPath3, chain, data, gas, gasPrice, maxFeePerGas, maxPriorityFeePerGas, nonce, to, value }) {
|
|
3899
2044
|
const prettyArgs = prettyPrint({
|
|
3900
2045
|
from: account?.address,
|
|
3901
2046
|
to,
|
|
3902
|
-
value: typeof value !== "undefined" && `${formatEther(value)} ${
|
|
2047
|
+
value: typeof value !== "undefined" && `${formatEther(value)} ${chain?.nativeCurrency?.symbol || "ETH"}`,
|
|
3903
2048
|
data,
|
|
3904
2049
|
gas,
|
|
3905
2050
|
gasPrice: typeof gasPrice !== "undefined" && `${formatGwei(gasPrice)} gwei`,
|
|
@@ -4106,9 +2251,9 @@ async function estimateMaxPriorityFeePerGas(client, args) {
|
|
|
4106
2251
|
return internal_estimateMaxPriorityFeePerGas(client, args);
|
|
4107
2252
|
}
|
|
4108
2253
|
async function internal_estimateMaxPriorityFeePerGas(client, args) {
|
|
4109
|
-
const { block: block_, chain
|
|
2254
|
+
const { block: block_, chain = client.chain, request } = args || {};
|
|
4110
2255
|
try {
|
|
4111
|
-
const maxPriorityFeePerGas =
|
|
2256
|
+
const maxPriorityFeePerGas = chain?.fees?.maxPriorityFeePerGas ?? chain?.fees?.defaultPriorityFee;
|
|
4112
2257
|
if (typeof maxPriorityFeePerGas === "function") {
|
|
4113
2258
|
const block = block_ || await getAction(client, getBlock, "getBlock")({});
|
|
4114
2259
|
const maxPriorityFeePerGas_ = await maxPriorityFeePerGas({
|
|
@@ -4145,15 +2290,15 @@ async function estimateFeesPerGas(client, args) {
|
|
|
4145
2290
|
return internal_estimateFeesPerGas(client, args);
|
|
4146
2291
|
}
|
|
4147
2292
|
async function internal_estimateFeesPerGas(client, args) {
|
|
4148
|
-
const { block: block_, chain
|
|
2293
|
+
const { block: block_, chain = client.chain, request, type = "eip1559" } = args || {};
|
|
4149
2294
|
const baseFeeMultiplier = await (async () => {
|
|
4150
|
-
if (typeof
|
|
4151
|
-
return
|
|
2295
|
+
if (typeof chain?.fees?.baseFeeMultiplier === "function")
|
|
2296
|
+
return chain.fees.baseFeeMultiplier({
|
|
4152
2297
|
block: block_,
|
|
4153
2298
|
client,
|
|
4154
2299
|
request
|
|
4155
2300
|
});
|
|
4156
|
-
return
|
|
2301
|
+
return chain?.fees?.baseFeeMultiplier ?? 1.2;
|
|
4157
2302
|
})();
|
|
4158
2303
|
if (baseFeeMultiplier < 1)
|
|
4159
2304
|
throw new BaseFeeScalarError();
|
|
@@ -4161,8 +2306,8 @@ async function internal_estimateFeesPerGas(client, args) {
|
|
|
4161
2306
|
const denominator = 10 ** decimals;
|
|
4162
2307
|
const multiply = (base2) => base2 * BigInt(Math.ceil(baseFeeMultiplier * denominator)) / BigInt(denominator);
|
|
4163
2308
|
const block = block_ ? block_ : await getAction(client, getBlock, "getBlock")({});
|
|
4164
|
-
if (typeof
|
|
4165
|
-
const fees = await
|
|
2309
|
+
if (typeof chain?.fees?.estimateFeesPerGas === "function") {
|
|
2310
|
+
const fees = await chain.fees.estimateFeesPerGas({
|
|
4166
2311
|
block: block_,
|
|
4167
2312
|
client,
|
|
4168
2313
|
multiply,
|
|
@@ -4177,7 +2322,7 @@ async function internal_estimateFeesPerGas(client, args) {
|
|
|
4177
2322
|
throw new Eip1559FeesNotSupportedError();
|
|
4178
2323
|
const maxPriorityFeePerGas = typeof request?.maxPriorityFeePerGas === "bigint" ? request.maxPriorityFeePerGas : await internal_estimateMaxPriorityFeePerGas(client, {
|
|
4179
2324
|
block,
|
|
4180
|
-
chain
|
|
2325
|
+
chain,
|
|
4181
2326
|
request
|
|
4182
2327
|
});
|
|
4183
2328
|
const baseFeePerGas = multiply(block.baseFeePerGas);
|
|
@@ -4409,7 +2554,7 @@ async function getChainId(client) {
|
|
|
4409
2554
|
|
|
4410
2555
|
// ../../node_modules/.pnpm/viem@2.47.6_typescript@6.0.2/node_modules/viem/_esm/actions/public/fillTransaction.js
|
|
4411
2556
|
async function fillTransaction(client, parameters) {
|
|
4412
|
-
const { account = client.account, accessList, authorizationList, chain
|
|
2557
|
+
const { account = client.account, accessList, authorizationList, chain = client.chain, blobVersionedHashes, blobs, data, gas, gasPrice, maxFeePerBlobGas, maxFeePerGas, maxPriorityFeePerGas, nonce: nonce_, nonceManager, to, type, value, ...rest } = parameters;
|
|
4413
2558
|
const nonce = await (async () => {
|
|
4414
2559
|
if (!account)
|
|
4415
2560
|
return nonce_;
|
|
@@ -4418,7 +2563,7 @@ async function fillTransaction(client, parameters) {
|
|
|
4418
2563
|
if (typeof nonce_ !== "undefined")
|
|
4419
2564
|
return nonce_;
|
|
4420
2565
|
const account_ = parseAccount(account);
|
|
4421
|
-
const chainId =
|
|
2566
|
+
const chainId = chain ? chain.id : await getAction(client, getChainId, "getChainId")({});
|
|
4422
2567
|
return await nonceManager.consume({
|
|
4423
2568
|
address: account_.address,
|
|
4424
2569
|
chainId,
|
|
@@ -4426,7 +2571,7 @@ async function fillTransaction(client, parameters) {
|
|
|
4426
2571
|
});
|
|
4427
2572
|
})();
|
|
4428
2573
|
assertRequest(parameters);
|
|
4429
|
-
const chainFormat =
|
|
2574
|
+
const chainFormat = chain?.formatters?.transactionRequest?.format;
|
|
4430
2575
|
const format = chainFormat || formatTransactionRequest;
|
|
4431
2576
|
const request = format({
|
|
4432
2577
|
// Pick out extra data that might exist on the chain's transaction request type.
|
|
@@ -4452,7 +2597,7 @@ async function fillTransaction(client, parameters) {
|
|
|
4452
2597
|
method: "eth_fillTransaction",
|
|
4453
2598
|
params: [request]
|
|
4454
2599
|
});
|
|
4455
|
-
const format2 =
|
|
2600
|
+
const format2 = chain?.formatters?.transaction?.format || formatTransaction;
|
|
4456
2601
|
const transaction = format2(response.tx);
|
|
4457
2602
|
delete transaction.blockHash;
|
|
4458
2603
|
delete transaction.blockNumber;
|
|
@@ -4475,15 +2620,15 @@ async function fillTransaction(client, parameters) {
|
|
|
4475
2620
|
if (transaction.nonce)
|
|
4476
2621
|
transaction.nonce = parameters.nonce ?? transaction.nonce;
|
|
4477
2622
|
const feeMultiplier = await (async () => {
|
|
4478
|
-
if (typeof
|
|
2623
|
+
if (typeof chain?.fees?.baseFeeMultiplier === "function") {
|
|
4479
2624
|
const block = await getAction(client, getBlock, "getBlock")({});
|
|
4480
|
-
return
|
|
2625
|
+
return chain.fees.baseFeeMultiplier({
|
|
4481
2626
|
block,
|
|
4482
2627
|
client,
|
|
4483
2628
|
request: parameters
|
|
4484
2629
|
});
|
|
4485
2630
|
}
|
|
4486
|
-
return
|
|
2631
|
+
return chain?.fees?.baseFeeMultiplier ?? 1.2;
|
|
4487
2632
|
})();
|
|
4488
2633
|
if (feeMultiplier < 1)
|
|
4489
2634
|
throw new BaseFeeScalarError();
|
|
@@ -4524,17 +2669,17 @@ async function prepareTransactionRequest(client, args) {
|
|
|
4524
2669
|
let request = args;
|
|
4525
2670
|
request.account ??= client.account;
|
|
4526
2671
|
request.parameters ??= defaultParameters;
|
|
4527
|
-
const { account: account_, chain
|
|
2672
|
+
const { account: account_, chain = client.chain, nonceManager, parameters } = request;
|
|
4528
2673
|
const prepareTransactionRequest2 = (() => {
|
|
4529
|
-
if (typeof
|
|
2674
|
+
if (typeof chain?.prepareTransactionRequest === "function")
|
|
4530
2675
|
return {
|
|
4531
|
-
fn:
|
|
2676
|
+
fn: chain.prepareTransactionRequest,
|
|
4532
2677
|
runAt: ["beforeFillTransaction"]
|
|
4533
2678
|
};
|
|
4534
|
-
if (Array.isArray(
|
|
2679
|
+
if (Array.isArray(chain?.prepareTransactionRequest))
|
|
4535
2680
|
return {
|
|
4536
|
-
fn:
|
|
4537
|
-
runAt:
|
|
2681
|
+
fn: chain.prepareTransactionRequest[0],
|
|
2682
|
+
runAt: chain.prepareTransactionRequest[1].runAt
|
|
4538
2683
|
};
|
|
4539
2684
|
return void 0;
|
|
4540
2685
|
})();
|
|
@@ -4544,8 +2689,8 @@ async function prepareTransactionRequest(client, args) {
|
|
|
4544
2689
|
return chainId;
|
|
4545
2690
|
if (typeof request.chainId !== "undefined")
|
|
4546
2691
|
return request.chainId;
|
|
4547
|
-
if (
|
|
4548
|
-
return
|
|
2692
|
+
if (chain)
|
|
2693
|
+
return chain.id;
|
|
4549
2694
|
const chainId_ = await getAction(client, getChainId, "getChainId")({});
|
|
4550
2695
|
chainId = chainId_;
|
|
4551
2696
|
return chainId;
|
|
@@ -4561,7 +2706,7 @@ async function prepareTransactionRequest(client, args) {
|
|
|
4561
2706
|
});
|
|
4562
2707
|
}
|
|
4563
2708
|
if (prepareTransactionRequest2?.fn && prepareTransactionRequest2.runAt?.includes("beforeFillTransaction")) {
|
|
4564
|
-
request = await prepareTransactionRequest2.fn({ ...request, chain
|
|
2709
|
+
request = await prepareTransactionRequest2.fn({ ...request, chain }, {
|
|
4565
2710
|
phase: "beforeFillTransaction"
|
|
4566
2711
|
});
|
|
4567
2712
|
nonce ??= request.nonce;
|
|
@@ -4620,7 +2765,7 @@ async function prepareTransactionRequest(client, args) {
|
|
|
4620
2765
|
};
|
|
4621
2766
|
const { blobs, gas, kzg, type } = request;
|
|
4622
2767
|
if (prepareTransactionRequest2?.fn && prepareTransactionRequest2.runAt?.includes("beforeFillParameters")) {
|
|
4623
|
-
request = await prepareTransactionRequest2.fn({ ...request, chain
|
|
2768
|
+
request = await prepareTransactionRequest2.fn({ ...request, chain }, {
|
|
4624
2769
|
phase: "beforeFillParameters"
|
|
4625
2770
|
});
|
|
4626
2771
|
}
|
|
@@ -4677,7 +2822,7 @@ async function prepareTransactionRequest(client, args) {
|
|
|
4677
2822
|
const block2 = await getBlock2();
|
|
4678
2823
|
const { maxFeePerGas, maxPriorityFeePerGas } = await internal_estimateFeesPerGas(client, {
|
|
4679
2824
|
block: block2,
|
|
4680
|
-
chain
|
|
2825
|
+
chain,
|
|
4681
2826
|
request
|
|
4682
2827
|
});
|
|
4683
2828
|
if (typeof request.maxPriorityFeePerGas === "undefined" && request.maxFeePerGas && request.maxFeePerGas < maxPriorityFeePerGas)
|
|
@@ -4694,7 +2839,7 @@ async function prepareTransactionRequest(client, args) {
|
|
|
4694
2839
|
const block2 = await getBlock2();
|
|
4695
2840
|
const { gasPrice: gasPrice_ } = await internal_estimateFeesPerGas(client, {
|
|
4696
2841
|
block: block2,
|
|
4697
|
-
chain
|
|
2842
|
+
chain,
|
|
4698
2843
|
request,
|
|
4699
2844
|
type: "legacy"
|
|
4700
2845
|
});
|
|
@@ -4709,7 +2854,7 @@ async function prepareTransactionRequest(client, args) {
|
|
|
4709
2854
|
prepare: account?.type === "local" ? [] : ["blobVersionedHashes"]
|
|
4710
2855
|
});
|
|
4711
2856
|
if (prepareTransactionRequest2?.fn && prepareTransactionRequest2.runAt?.includes("afterFillParameters"))
|
|
4712
|
-
request = await prepareTransactionRequest2.fn({ ...request, chain
|
|
2857
|
+
request = await prepareTransactionRequest2.fn({ ...request, chain }, {
|
|
4713
2858
|
phase: "afterFillParameters"
|
|
4714
2859
|
});
|
|
4715
2860
|
assertRequest(request);
|
|
@@ -5175,9 +3320,9 @@ function observe(observerId, callbacks, fn) {
|
|
|
5175
3320
|
return;
|
|
5176
3321
|
const cleanup2 = cleanupCache.get(observerId);
|
|
5177
3322
|
if (listeners2.length === 1 && cleanup2) {
|
|
5178
|
-
const
|
|
5179
|
-
if (
|
|
5180
|
-
|
|
3323
|
+
const p = cleanup2();
|
|
3324
|
+
if (p instanceof Promise)
|
|
3325
|
+
p.catch(() => {
|
|
5181
3326
|
});
|
|
5182
3327
|
}
|
|
5183
3328
|
unsubscribe();
|
|
@@ -5511,11 +3656,11 @@ var AccountTypeNotSupportedError = class extends BaseError {
|
|
|
5511
3656
|
};
|
|
5512
3657
|
|
|
5513
3658
|
// ../../node_modules/.pnpm/viem@2.47.6_typescript@6.0.2/node_modules/viem/_esm/utils/chain/assertCurrentChain.js
|
|
5514
|
-
function assertCurrentChain({ chain
|
|
5515
|
-
if (!
|
|
3659
|
+
function assertCurrentChain({ chain, currentChainId }) {
|
|
3660
|
+
if (!chain)
|
|
5516
3661
|
throw new ChainNotFoundError();
|
|
5517
|
-
if (currentChainId !==
|
|
5518
|
-
throw new ChainMismatchError({ chain
|
|
3662
|
+
if (currentChainId !== chain.id)
|
|
3663
|
+
throw new ChainMismatchError({ chain, currentChainId });
|
|
5519
3664
|
}
|
|
5520
3665
|
|
|
5521
3666
|
// ../../node_modules/.pnpm/viem@2.47.6_typescript@6.0.2/node_modules/viem/_esm/actions/wallet/sendRawTransaction.js
|
|
@@ -5529,7 +3674,7 @@ async function sendRawTransaction(client, { serializedTransaction }) {
|
|
|
5529
3674
|
// ../../node_modules/.pnpm/viem@2.47.6_typescript@6.0.2/node_modules/viem/_esm/actions/wallet/sendTransaction.js
|
|
5530
3675
|
var supportsWalletNamespace = new LruMap(128);
|
|
5531
3676
|
async function sendTransaction(client, parameters) {
|
|
5532
|
-
const { account: account_ = client.account, assertChainId = true, chain
|
|
3677
|
+
const { account: account_ = client.account, assertChainId = true, chain = client.chain, accessList, authorizationList, blobs, data, dataSuffix = typeof client.dataSuffix === "string" ? client.dataSuffix : client.dataSuffix?.value, gas, gasPrice, maxFeePerBlobGas, maxFeePerGas, maxPriorityFeePerGas, nonce, type, value, ...rest } = parameters;
|
|
5533
3678
|
if (typeof account_ === "undefined")
|
|
5534
3679
|
throw new AccountNotFoundError2({
|
|
5535
3680
|
docsPath: "/docs/actions/wallet/sendTransaction"
|
|
@@ -5552,12 +3697,12 @@ async function sendTransaction(client, parameters) {
|
|
|
5552
3697
|
})();
|
|
5553
3698
|
if (account?.type === "json-rpc" || account === null) {
|
|
5554
3699
|
let chainId;
|
|
5555
|
-
if (
|
|
3700
|
+
if (chain !== null) {
|
|
5556
3701
|
chainId = await getAction(client, getChainId, "getChainId")({});
|
|
5557
3702
|
if (assertChainId)
|
|
5558
3703
|
assertCurrentChain({
|
|
5559
3704
|
currentChainId: chainId,
|
|
5560
|
-
chain
|
|
3705
|
+
chain
|
|
5561
3706
|
});
|
|
5562
3707
|
}
|
|
5563
3708
|
const chainFormat = client.chain?.formatters?.transactionRequest?.format;
|
|
@@ -5617,7 +3762,7 @@ async function sendTransaction(client, parameters) {
|
|
|
5617
3762
|
accessList,
|
|
5618
3763
|
authorizationList,
|
|
5619
3764
|
blobs,
|
|
5620
|
-
chain
|
|
3765
|
+
chain,
|
|
5621
3766
|
data: dataSuffix ? concat([data ?? "0x", dataSuffix]) : data,
|
|
5622
3767
|
gas,
|
|
5623
3768
|
gasPrice,
|
|
@@ -5632,7 +3777,7 @@ async function sendTransaction(client, parameters) {
|
|
|
5632
3777
|
...rest,
|
|
5633
3778
|
to
|
|
5634
3779
|
});
|
|
5635
|
-
const serializer =
|
|
3780
|
+
const serializer = chain?.serializers?.transaction;
|
|
5636
3781
|
const serializedTransaction = await account.signTransaction(request, {
|
|
5637
3782
|
serializer
|
|
5638
3783
|
});
|
|
@@ -5773,7 +3918,7 @@ var fallbackTransactionErrorMagicIdentifier = numberToHex(0, {
|
|
|
5773
3918
|
size: 32
|
|
5774
3919
|
});
|
|
5775
3920
|
async function sendCalls(client, parameters) {
|
|
5776
|
-
const { account: account_ = client.account, chain
|
|
3921
|
+
const { account: account_ = client.account, chain = client.chain, experimental_fallback, experimental_fallbackDelay = 32, forceAtomic = false, id, version = "2.0.0" } = parameters;
|
|
5777
3922
|
const account = account_ ? parseAccount(account_) : null;
|
|
5778
3923
|
let capabilities = parameters.capabilities;
|
|
5779
3924
|
if (client.dataSuffix && !parameters.capabilities?.dataSuffix) {
|
|
@@ -5812,7 +3957,7 @@ async function sendCalls(client, parameters) {
|
|
|
5812
3957
|
atomicRequired: forceAtomic,
|
|
5813
3958
|
calls,
|
|
5814
3959
|
capabilities,
|
|
5815
|
-
chainId: numberToHex(
|
|
3960
|
+
chainId: numberToHex(chain.id),
|
|
5816
3961
|
from: account?.address,
|
|
5817
3962
|
id,
|
|
5818
3963
|
version
|
|
@@ -5846,7 +3991,7 @@ async function sendCalls(client, parameters) {
|
|
|
5846
3991
|
for (const call2 of calls) {
|
|
5847
3992
|
const promise = sendTransaction(client, {
|
|
5848
3993
|
account,
|
|
5849
|
-
chain
|
|
3994
|
+
chain,
|
|
5850
3995
|
data: call2.data,
|
|
5851
3996
|
to: call2.to,
|
|
5852
3997
|
value: call2.value ? hexToBigInt(call2.value) : void 0
|
|
@@ -5866,7 +4011,7 @@ async function sendCalls(client, parameters) {
|
|
|
5866
4011
|
return {
|
|
5867
4012
|
id: concat([
|
|
5868
4013
|
...hashes2,
|
|
5869
|
-
numberToHex(
|
|
4014
|
+
numberToHex(chain.id, { size: 32 }),
|
|
5870
4015
|
fallbackMagicIdentifier
|
|
5871
4016
|
])
|
|
5872
4017
|
};
|
|
@@ -6019,16 +4164,16 @@ function uid(length = 11) {
|
|
|
6019
4164
|
|
|
6020
4165
|
// ../../node_modules/.pnpm/viem@2.47.6_typescript@6.0.2/node_modules/viem/_esm/clients/createClient.js
|
|
6021
4166
|
function createClient(parameters) {
|
|
6022
|
-
const { batch, chain
|
|
6023
|
-
const experimental_blockTag = parameters.experimental_blockTag ?? (typeof
|
|
6024
|
-
const blockTime =
|
|
4167
|
+
const { batch, chain, ccipRead, dataSuffix, key = "base", name = "Base Client", type = "base" } = parameters;
|
|
4168
|
+
const experimental_blockTag = parameters.experimental_blockTag ?? (typeof chain?.experimental_preconfirmationTime === "number" ? "pending" : void 0);
|
|
4169
|
+
const blockTime = chain?.blockTime ?? 12e3;
|
|
6025
4170
|
const defaultPollingInterval = Math.min(Math.max(Math.floor(blockTime / 2), 500), 4e3);
|
|
6026
4171
|
const pollingInterval = parameters.pollingInterval ?? defaultPollingInterval;
|
|
6027
4172
|
const cacheTime = parameters.cacheTime ?? pollingInterval;
|
|
6028
4173
|
const account = parameters.account ? parseAccount(parameters.account) : void 0;
|
|
6029
4174
|
const { config, request, value } = parameters.transport({
|
|
6030
4175
|
account,
|
|
6031
|
-
chain
|
|
4176
|
+
chain,
|
|
6032
4177
|
pollingInterval
|
|
6033
4178
|
});
|
|
6034
4179
|
const transport = { ...config, ...value };
|
|
@@ -6037,7 +4182,7 @@ function createClient(parameters) {
|
|
|
6037
4182
|
batch,
|
|
6038
4183
|
cacheTime,
|
|
6039
4184
|
ccipRead,
|
|
6040
|
-
chain
|
|
4185
|
+
chain,
|
|
6041
4186
|
dataSuffix,
|
|
6042
4187
|
key,
|
|
6043
4188
|
name,
|
|
@@ -6147,19 +4292,19 @@ function packetToBytes(packet) {
|
|
|
6147
4292
|
// ../../node_modules/.pnpm/viem@2.47.6_typescript@6.0.2/node_modules/viem/_esm/actions/ens/getEnsAddress.js
|
|
6148
4293
|
async function getEnsAddress(client, parameters) {
|
|
6149
4294
|
const { blockNumber, blockTag, coinType, name, gatewayUrls, strict } = parameters;
|
|
6150
|
-
const { chain
|
|
4295
|
+
const { chain } = client;
|
|
6151
4296
|
const universalResolverAddress = (() => {
|
|
6152
4297
|
if (parameters.universalResolverAddress)
|
|
6153
4298
|
return parameters.universalResolverAddress;
|
|
6154
|
-
if (!
|
|
4299
|
+
if (!chain)
|
|
6155
4300
|
throw new Error("client chain not configured. universalResolverAddress is required.");
|
|
6156
4301
|
return getChainContractAddress({
|
|
6157
4302
|
blockNumber,
|
|
6158
|
-
chain
|
|
4303
|
+
chain,
|
|
6159
4304
|
contract: "ensUniversalResolver"
|
|
6160
4305
|
});
|
|
6161
4306
|
})();
|
|
6162
|
-
const tlds =
|
|
4307
|
+
const tlds = chain?.ensTlds;
|
|
6163
4308
|
if (tlds && !tlds.some((tld) => name.endsWith(tld)))
|
|
6164
4309
|
return null;
|
|
6165
4310
|
const args = (() => {
|
|
@@ -6444,19 +4589,19 @@ async function parseNftAvatarUri(client, { gatewayUrls, record: record2 }) {
|
|
|
6444
4589
|
// ../../node_modules/.pnpm/viem@2.47.6_typescript@6.0.2/node_modules/viem/_esm/actions/ens/getEnsText.js
|
|
6445
4590
|
async function getEnsText(client, parameters) {
|
|
6446
4591
|
const { blockNumber, blockTag, key, name, gatewayUrls, strict } = parameters;
|
|
6447
|
-
const { chain
|
|
4592
|
+
const { chain } = client;
|
|
6448
4593
|
const universalResolverAddress = (() => {
|
|
6449
4594
|
if (parameters.universalResolverAddress)
|
|
6450
4595
|
return parameters.universalResolverAddress;
|
|
6451
|
-
if (!
|
|
4596
|
+
if (!chain)
|
|
6452
4597
|
throw new Error("client chain not configured. universalResolverAddress is required.");
|
|
6453
4598
|
return getChainContractAddress({
|
|
6454
4599
|
blockNumber,
|
|
6455
|
-
chain
|
|
4600
|
+
chain,
|
|
6456
4601
|
contract: "ensUniversalResolver"
|
|
6457
4602
|
});
|
|
6458
4603
|
})();
|
|
6459
|
-
const tlds =
|
|
4604
|
+
const tlds = chain?.ensTlds;
|
|
6460
4605
|
if (tlds && !tlds.some((tld) => name.endsWith(tld)))
|
|
6461
4606
|
return null;
|
|
6462
4607
|
try {
|
|
@@ -6521,15 +4666,15 @@ async function getEnsAvatar(client, { blockNumber, blockTag, assetGatewayUrls, n
|
|
|
6521
4666
|
// ../../node_modules/.pnpm/viem@2.47.6_typescript@6.0.2/node_modules/viem/_esm/actions/ens/getEnsName.js
|
|
6522
4667
|
async function getEnsName(client, parameters) {
|
|
6523
4668
|
const { address, blockNumber, blockTag, coinType = 60n, gatewayUrls, strict } = parameters;
|
|
6524
|
-
const { chain
|
|
4669
|
+
const { chain } = client;
|
|
6525
4670
|
const universalResolverAddress = (() => {
|
|
6526
4671
|
if (parameters.universalResolverAddress)
|
|
6527
4672
|
return parameters.universalResolverAddress;
|
|
6528
|
-
if (!
|
|
4673
|
+
if (!chain)
|
|
6529
4674
|
throw new Error("client chain not configured. universalResolverAddress is required.");
|
|
6530
4675
|
return getChainContractAddress({
|
|
6531
4676
|
blockNumber,
|
|
6532
|
-
chain
|
|
4677
|
+
chain,
|
|
6533
4678
|
contract: "ensUniversalResolver"
|
|
6534
4679
|
});
|
|
6535
4680
|
})();
|
|
@@ -6557,21 +4702,21 @@ async function getEnsName(client, parameters) {
|
|
|
6557
4702
|
// ../../node_modules/.pnpm/viem@2.47.6_typescript@6.0.2/node_modules/viem/_esm/actions/ens/getEnsResolver.js
|
|
6558
4703
|
async function getEnsResolver(client, parameters) {
|
|
6559
4704
|
const { blockNumber, blockTag, name } = parameters;
|
|
6560
|
-
const { chain
|
|
4705
|
+
const { chain } = client;
|
|
6561
4706
|
const universalResolverAddress = (() => {
|
|
6562
4707
|
if (parameters.universalResolverAddress)
|
|
6563
4708
|
return parameters.universalResolverAddress;
|
|
6564
|
-
if (!
|
|
4709
|
+
if (!chain)
|
|
6565
4710
|
throw new Error("client chain not configured. universalResolverAddress is required.");
|
|
6566
4711
|
return getChainContractAddress({
|
|
6567
4712
|
blockNumber,
|
|
6568
|
-
chain
|
|
4713
|
+
chain,
|
|
6569
4714
|
contract: "ensUniversalResolver"
|
|
6570
4715
|
});
|
|
6571
4716
|
})();
|
|
6572
|
-
const tlds =
|
|
4717
|
+
const tlds = chain?.ensTlds;
|
|
6573
4718
|
if (tlds && !tlds.some((tld) => name.endsWith(tld)))
|
|
6574
|
-
throw new Error(`${name} is not a valid ENS TLD (${tlds?.join(", ")}) for chain "${
|
|
4719
|
+
throw new Error(`${name} is not a valid ENS TLD (${tlds?.join(", ")}) for chain "${chain.name}" (id: ${chain.id}).`);
|
|
6575
4720
|
const [resolverAddress] = await getAction(client, readContract, "readContract")({
|
|
6576
4721
|
address: universalResolverAddress,
|
|
6577
4722
|
abi: [
|
|
@@ -7373,12 +5518,12 @@ function shouldRetry(error) {
|
|
|
7373
5518
|
}
|
|
7374
5519
|
|
|
7375
5520
|
// ../../node_modules/.pnpm/viem@2.47.6_typescript@6.0.2/node_modules/viem/_esm/utils/chain/defineChain.js
|
|
7376
|
-
function defineChain(
|
|
5521
|
+
function defineChain(chain) {
|
|
7377
5522
|
const chainInstance = {
|
|
7378
5523
|
formatters: void 0,
|
|
7379
5524
|
fees: void 0,
|
|
7380
5525
|
serializers: void 0,
|
|
7381
|
-
...
|
|
5526
|
+
...chain
|
|
7382
5527
|
};
|
|
7383
5528
|
function extend(base2) {
|
|
7384
5529
|
return (fnOrExtended) => {
|
|
@@ -7868,7 +6013,7 @@ function assert(publicKey, options = {}) {
|
|
|
7868
6013
|
function from3(value) {
|
|
7869
6014
|
const publicKey = (() => {
|
|
7870
6015
|
if (validate2(value))
|
|
7871
|
-
return
|
|
6016
|
+
return fromHex3(value);
|
|
7872
6017
|
if (validate(value))
|
|
7873
6018
|
return fromBytes2(value);
|
|
7874
6019
|
const { prefix, x, y } = value;
|
|
@@ -7880,9 +6025,9 @@ function from3(value) {
|
|
|
7880
6025
|
return publicKey;
|
|
7881
6026
|
}
|
|
7882
6027
|
function fromBytes2(publicKey) {
|
|
7883
|
-
return
|
|
6028
|
+
return fromHex3(fromBytes(publicKey));
|
|
7884
6029
|
}
|
|
7885
|
-
function
|
|
6030
|
+
function fromHex3(publicKey) {
|
|
7886
6031
|
if (publicKey.length !== 132 && publicKey.length !== 130 && publicKey.length !== 68)
|
|
7887
6032
|
throw new InvalidSerializedSizeError({ publicKey });
|
|
7888
6033
|
if (publicKey.length === 130) {
|
|
@@ -7911,7 +6056,7 @@ function fromHex4(publicKey) {
|
|
|
7911
6056
|
x
|
|
7912
6057
|
};
|
|
7913
6058
|
}
|
|
7914
|
-
function
|
|
6059
|
+
function toHex3(publicKey, options = {}) {
|
|
7915
6060
|
assert(publicKey);
|
|
7916
6061
|
const { prefix, x, y } = publicKey;
|
|
7917
6062
|
const { includePrefix = true } = options;
|
|
@@ -8038,7 +6183,7 @@ function from4(address, options = {}) {
|
|
|
8038
6183
|
return address;
|
|
8039
6184
|
}
|
|
8040
6185
|
function fromPublicKey(publicKey, options = {}) {
|
|
8041
|
-
const address = keccak2562(`0x${
|
|
6186
|
+
const address = keccak2562(`0x${toHex3(publicKey).slice(4)}`).substring(26);
|
|
8042
6187
|
return from4(`0x${address}`, options);
|
|
8043
6188
|
}
|
|
8044
6189
|
function validate3(address, options = {}) {
|
|
@@ -8990,7 +7135,7 @@ function from6(value, options) {
|
|
|
8990
7135
|
return fromBytes(cursor.bytes);
|
|
8991
7136
|
return cursor.bytes;
|
|
8992
7137
|
}
|
|
8993
|
-
function
|
|
7138
|
+
function fromHex4(hex, options = {}) {
|
|
8994
7139
|
const { as = "Hex" } = options;
|
|
8995
7140
|
return from6(hex, { as });
|
|
8996
7141
|
}
|
|
@@ -9091,9 +7236,9 @@ function assert3(signature, options = {}) {
|
|
|
9091
7236
|
throw new InvalidYParityError({ value: signature.yParity });
|
|
9092
7237
|
}
|
|
9093
7238
|
function fromBytes3(signature) {
|
|
9094
|
-
return
|
|
7239
|
+
return fromHex5(fromBytes(signature));
|
|
9095
7240
|
}
|
|
9096
|
-
function
|
|
7241
|
+
function fromHex5(signature) {
|
|
9097
7242
|
if (signature.length !== 130 && signature.length !== 132)
|
|
9098
7243
|
throw new InvalidSerializedSizeError2({ signature });
|
|
9099
7244
|
const r = BigInt(slice3(signature, 0, 32));
|
|
@@ -9129,7 +7274,7 @@ function extract2(value) {
|
|
|
9129
7274
|
function from7(signature) {
|
|
9130
7275
|
const signature_ = (() => {
|
|
9131
7276
|
if (typeof signature === "string")
|
|
9132
|
-
return
|
|
7277
|
+
return fromHex5(signature);
|
|
9133
7278
|
if (signature instanceof Uint8Array)
|
|
9134
7279
|
return fromBytes3(signature);
|
|
9135
7280
|
if (typeof signature.r === "string")
|
|
@@ -9278,7 +7423,7 @@ function getSignPayload(authorization) {
|
|
|
9278
7423
|
}
|
|
9279
7424
|
function hash2(authorization, options = {}) {
|
|
9280
7425
|
const { presign } = options;
|
|
9281
|
-
return keccak2562(concat2("0x05",
|
|
7426
|
+
return keccak2562(concat2("0x05", fromHex4(toTuple2(presign ? {
|
|
9282
7427
|
address: authorization.address,
|
|
9283
7428
|
chainId: authorization.chainId,
|
|
9284
7429
|
nonce: authorization.nonce
|
|
@@ -9827,7 +7972,7 @@ function fromAbi(abi2, name, options) {
|
|
|
9827
7972
|
return "name" in abiItem2 && abiItem2.name === name;
|
|
9828
7973
|
});
|
|
9829
7974
|
if (abiItems.length === 0)
|
|
9830
|
-
throw new
|
|
7975
|
+
throw new NotFoundError2({ name });
|
|
9831
7976
|
if (abiItems.length === 1)
|
|
9832
7977
|
return {
|
|
9833
7978
|
...abiItems[0],
|
|
@@ -9879,7 +8024,7 @@ function fromAbi(abi2, name, options) {
|
|
|
9879
8024
|
return { ...abiItem2, overloads };
|
|
9880
8025
|
})();
|
|
9881
8026
|
if (!abiItem)
|
|
9882
|
-
throw new
|
|
8027
|
+
throw new NotFoundError2({ name });
|
|
9883
8028
|
return {
|
|
9884
8029
|
...abiItem,
|
|
9885
8030
|
...prepare ? { hash: getSignatureHash(abiItem) } : {}
|
|
@@ -9942,7 +8087,7 @@ var AmbiguityError = class extends BaseError2 {
|
|
|
9942
8087
|
});
|
|
9943
8088
|
}
|
|
9944
8089
|
};
|
|
9945
|
-
var
|
|
8090
|
+
var NotFoundError2 = class extends BaseError2 {
|
|
9946
8091
|
constructor({ name, data, type = "item" }) {
|
|
9947
8092
|
const selector = (() => {
|
|
9948
8093
|
if (name)
|
|
@@ -9979,7 +8124,7 @@ function from11(abiConstructor) {
|
|
|
9979
8124
|
function fromAbi2(abi2) {
|
|
9980
8125
|
const item = abi2.find((item2) => item2.type === "constructor");
|
|
9981
8126
|
if (!item)
|
|
9982
|
-
throw new
|
|
8127
|
+
throw new NotFoundError2({ name: "constructor" });
|
|
9983
8128
|
return item;
|
|
9984
8129
|
}
|
|
9985
8130
|
|
|
@@ -10007,7 +8152,7 @@ function from12(abiFunction, options = {}) {
|
|
|
10007
8152
|
function fromAbi3(abi2, name, options) {
|
|
10008
8153
|
const item = fromAbi(abi2, name, options);
|
|
10009
8154
|
if (item.type !== "function")
|
|
10010
|
-
throw new
|
|
8155
|
+
throw new NotFoundError2({ name, type: "function" });
|
|
10011
8156
|
return item;
|
|
10012
8157
|
}
|
|
10013
8158
|
function getSelector2(abiItem) {
|
|
@@ -10333,9 +8478,9 @@ function serializeSignature({ r, s, to = "hex", v, yParity }) {
|
|
|
10333
8478
|
|
|
10334
8479
|
// ../../node_modules/.pnpm/viem@2.47.6_typescript@6.0.2/node_modules/viem/_esm/actions/public/verifyHash.js
|
|
10335
8480
|
async function verifyHash(client, parameters) {
|
|
10336
|
-
const { address, chain
|
|
10337
|
-
if (
|
|
10338
|
-
return await
|
|
8481
|
+
const { address, chain = client.chain, hash: hash3, erc6492VerifierAddress: verifierAddress = parameters.universalSignatureVerifierAddress ?? chain?.contracts?.erc6492Verifier?.address, multicallAddress = parameters.multicallAddress ?? chain?.contracts?.multicall3?.address, mode = "auto" } = parameters;
|
|
8482
|
+
if (chain?.verifyHash)
|
|
8483
|
+
return await chain.verifyHash(client, parameters);
|
|
10339
8484
|
const signature = (() => {
|
|
10340
8485
|
const signature2 = parameters.signature;
|
|
10341
8486
|
if (isHex(signature2))
|
|
@@ -11272,8 +9417,8 @@ function createPublicClient(parameters) {
|
|
|
11272
9417
|
}
|
|
11273
9418
|
|
|
11274
9419
|
// ../../node_modules/.pnpm/viem@2.47.6_typescript@6.0.2/node_modules/viem/_esm/actions/wallet/addChain.js
|
|
11275
|
-
async function addChain(client, { chain
|
|
11276
|
-
const { id, name, nativeCurrency, rpcUrls, blockExplorers } =
|
|
9420
|
+
async function addChain(client, { chain }) {
|
|
9421
|
+
const { id, name, nativeCurrency, rpcUrls, blockExplorers } = chain;
|
|
11277
9422
|
await client.request({
|
|
11278
9423
|
method: "wallet_addEthereumChain",
|
|
11279
9424
|
params: [
|
|
@@ -11383,8 +9528,8 @@ async function requestPermissions(client, permissions) {
|
|
|
11383
9528
|
|
|
11384
9529
|
// ../../node_modules/.pnpm/viem@2.47.6_typescript@6.0.2/node_modules/viem/_esm/actions/wallet/sendCallsSync.js
|
|
11385
9530
|
async function sendCallsSync(client, parameters) {
|
|
11386
|
-
const { chain
|
|
11387
|
-
const timeout = parameters.timeout ?? Math.max((
|
|
9531
|
+
const { chain = client.chain } = parameters;
|
|
9532
|
+
const timeout = parameters.timeout ?? Math.max((chain?.blockTime ?? 0) * 3, 5e3);
|
|
11388
9533
|
const result2 = await getAction(client, sendCalls, "sendCalls")(parameters);
|
|
11389
9534
|
const status = await getAction(client, waitForCallsStatus, "waitForCallsStatus")({
|
|
11390
9535
|
...parameters,
|
|
@@ -11397,8 +9542,8 @@ async function sendCallsSync(client, parameters) {
|
|
|
11397
9542
|
// ../../node_modules/.pnpm/viem@2.47.6_typescript@6.0.2/node_modules/viem/_esm/actions/wallet/sendTransactionSync.js
|
|
11398
9543
|
var supportsWalletNamespace2 = new LruMap(128);
|
|
11399
9544
|
async function sendTransactionSync(client, parameters) {
|
|
11400
|
-
const { account: account_ = client.account, assertChainId = true, chain
|
|
11401
|
-
const timeout = parameters.timeout ?? Math.max((
|
|
9545
|
+
const { account: account_ = client.account, assertChainId = true, chain = client.chain, accessList, authorizationList, blobs, data, dataSuffix = typeof client.dataSuffix === "string" ? client.dataSuffix : client.dataSuffix?.value, gas, gasPrice, maxFeePerBlobGas, maxFeePerGas, maxPriorityFeePerGas, nonce, pollingInterval, throwOnReceiptRevert, type, value, ...rest } = parameters;
|
|
9546
|
+
const timeout = parameters.timeout ?? Math.max((chain?.blockTime ?? 0) * 3, 5e3);
|
|
11402
9547
|
if (typeof account_ === "undefined")
|
|
11403
9548
|
throw new AccountNotFoundError2({
|
|
11404
9549
|
docsPath: "/docs/actions/wallet/sendTransactionSync"
|
|
@@ -11421,12 +9566,12 @@ async function sendTransactionSync(client, parameters) {
|
|
|
11421
9566
|
})();
|
|
11422
9567
|
if (account?.type === "json-rpc" || account === null) {
|
|
11423
9568
|
let chainId;
|
|
11424
|
-
if (
|
|
9569
|
+
if (chain !== null) {
|
|
11425
9570
|
chainId = await getAction(client, getChainId, "getChainId")({});
|
|
11426
9571
|
if (assertChainId)
|
|
11427
9572
|
assertCurrentChain({
|
|
11428
9573
|
currentChainId: chainId,
|
|
11429
|
-
chain
|
|
9574
|
+
chain
|
|
11430
9575
|
});
|
|
11431
9576
|
}
|
|
11432
9577
|
const chainFormat = client.chain?.formatters?.transactionRequest?.format;
|
|
@@ -11497,7 +9642,7 @@ async function sendTransactionSync(client, parameters) {
|
|
|
11497
9642
|
accessList,
|
|
11498
9643
|
authorizationList,
|
|
11499
9644
|
blobs,
|
|
11500
|
-
chain
|
|
9645
|
+
chain,
|
|
11501
9646
|
data: data ? concat([data, dataSuffix ?? "0x"]) : data,
|
|
11502
9647
|
gas,
|
|
11503
9648
|
gasPrice,
|
|
@@ -11512,7 +9657,7 @@ async function sendTransactionSync(client, parameters) {
|
|
|
11512
9657
|
...rest,
|
|
11513
9658
|
to
|
|
11514
9659
|
});
|
|
11515
|
-
const serializer =
|
|
9660
|
+
const serializer = chain?.serializers?.transaction;
|
|
11516
9661
|
const serializedTransaction = await account.signTransaction(request, {
|
|
11517
9662
|
serializer
|
|
11518
9663
|
});
|
|
@@ -11599,7 +9744,7 @@ async function signMessage2(client, { account: account_ = client.account, messag
|
|
|
11599
9744
|
|
|
11600
9745
|
// ../../node_modules/.pnpm/viem@2.47.6_typescript@6.0.2/node_modules/viem/_esm/actions/wallet/signTransaction.js
|
|
11601
9746
|
async function signTransaction(client, parameters) {
|
|
11602
|
-
const { account: account_ = client.account, chain
|
|
9747
|
+
const { account: account_ = client.account, chain = client.chain, ...transaction } = parameters;
|
|
11603
9748
|
if (!account_)
|
|
11604
9749
|
throw new AccountNotFoundError2({
|
|
11605
9750
|
docsPath: "/docs/actions/wallet/signTransaction"
|
|
@@ -11610,12 +9755,12 @@ async function signTransaction(client, parameters) {
|
|
|
11610
9755
|
...parameters
|
|
11611
9756
|
});
|
|
11612
9757
|
const chainId = await getAction(client, getChainId, "getChainId")({});
|
|
11613
|
-
if (
|
|
9758
|
+
if (chain !== null)
|
|
11614
9759
|
assertCurrentChain({
|
|
11615
9760
|
currentChainId: chainId,
|
|
11616
|
-
chain
|
|
9761
|
+
chain
|
|
11617
9762
|
});
|
|
11618
|
-
const formatters2 =
|
|
9763
|
+
const formatters2 = chain?.formatters || client.chain?.formatters;
|
|
11619
9764
|
const format = formatters2?.transactionRequest?.format || formatTransactionRequest;
|
|
11620
9765
|
if (account.signTransaction)
|
|
11621
9766
|
return account.signTransaction({
|
|
@@ -11764,11 +9909,11 @@ var UrlRequiredError = class extends BaseError {
|
|
|
11764
9909
|
// ../../node_modules/.pnpm/viem@2.47.6_typescript@6.0.2/node_modules/viem/_esm/clients/transports/http.js
|
|
11765
9910
|
function http(url, config = {}) {
|
|
11766
9911
|
const { batch, fetchFn, fetchOptions, key = "http", methods, name = "HTTP JSON-RPC", onFetchRequest, onFetchResponse, retryDelay, raw } = config;
|
|
11767
|
-
return ({ chain
|
|
9912
|
+
return ({ chain, retryCount: retryCount_, timeout: timeout_ }) => {
|
|
11768
9913
|
const { batchSize = 1e3, wait: wait2 = 0 } = typeof batch === "object" ? batch : {};
|
|
11769
9914
|
const retryCount = config.retryCount ?? retryCount_;
|
|
11770
9915
|
const timeout = timeout_ ?? config.timeout ?? 1e4;
|
|
11771
|
-
const url_ = url ||
|
|
9916
|
+
const url_ = url || chain?.rpcUrls.default.http[0];
|
|
11772
9917
|
if (!url_)
|
|
11773
9918
|
throw new UrlRequiredError();
|
|
11774
9919
|
const rpcClient = getHttpRpcClient(url_, {
|
|
@@ -12329,7 +10474,7 @@ var sepolia = /* @__PURE__ */ defineChain({
|
|
|
12329
10474
|
});
|
|
12330
10475
|
|
|
12331
10476
|
// ../../packages/allset-sdk/dist/index.js
|
|
12332
|
-
import { Schema as
|
|
10477
|
+
import { Schema as Schema5 } from "effect";
|
|
12333
10478
|
function fastAddressToBytes(address) {
|
|
12334
10479
|
try {
|
|
12335
10480
|
return fromFastAddress(address);
|
|
@@ -12338,7 +10483,7 @@ function fastAddressToBytes(address) {
|
|
|
12338
10483
|
}
|
|
12339
10484
|
}
|
|
12340
10485
|
function fastAddressToBytes32(address) {
|
|
12341
|
-
return
|
|
10486
|
+
return toHex2(fastAddressToBytes(address));
|
|
12342
10487
|
}
|
|
12343
10488
|
var INTENT_CLAIM_ABI_PARAMS = [
|
|
12344
10489
|
{
|
|
@@ -12663,26 +10808,26 @@ var CHAIN_MAP = {
|
|
|
12663
10808
|
8453: base
|
|
12664
10809
|
};
|
|
12665
10810
|
function createEvmExecutor(account, rpcUrl, chainOrId) {
|
|
12666
|
-
const
|
|
10811
|
+
const chain = typeof chainOrId === "number" ? resolveChain(chainOrId) : chainOrId;
|
|
12667
10812
|
const walletClient = createWalletClient({
|
|
12668
10813
|
account,
|
|
12669
|
-
chain
|
|
10814
|
+
chain,
|
|
12670
10815
|
transport: http(rpcUrl)
|
|
12671
10816
|
});
|
|
12672
10817
|
const publicClient = createPublicClient({
|
|
12673
|
-
chain
|
|
10818
|
+
chain,
|
|
12674
10819
|
transport: http(rpcUrl)
|
|
12675
10820
|
});
|
|
12676
10821
|
return { walletClient, publicClient };
|
|
12677
10822
|
}
|
|
12678
10823
|
function resolveChain(chainId) {
|
|
12679
|
-
const
|
|
12680
|
-
if (!
|
|
10824
|
+
const chain = CHAIN_MAP[chainId];
|
|
10825
|
+
if (!chain) {
|
|
12681
10826
|
throw new Error(
|
|
12682
10827
|
`Unsupported EVM chain ID: ${chainId}. Supported: ${Object.keys(CHAIN_MAP).join(", ")}. Pass a viem Chain object directly to avoid this restriction.`
|
|
12683
10828
|
);
|
|
12684
10829
|
}
|
|
12685
|
-
return
|
|
10830
|
+
return chain;
|
|
12686
10831
|
}
|
|
12687
10832
|
async function getEvmErc20Balance(rpcUrl, tokenAddress, ownerAddress) {
|
|
12688
10833
|
const client = createPublicClient({ transport: http(rpcUrl) });
|
|
@@ -12865,7 +11010,7 @@ async function approveErc20(clients, token, spender, amount) {
|
|
|
12865
11010
|
}
|
|
12866
11011
|
}
|
|
12867
11012
|
async function evmSign(certificate, crossSignUrl) {
|
|
12868
|
-
const wireFormat =
|
|
11013
|
+
const wireFormat = Schema5.encodeSync(TransactionCertificateFromRpc)(
|
|
12869
11014
|
certificate
|
|
12870
11015
|
);
|
|
12871
11016
|
const serialized = bigIntToNumber(wireFormat);
|
|
@@ -13182,9 +11327,9 @@ var FastRpcLive = Layer3.effect(
|
|
|
13182
11327
|
const config = yield* ClientConfig;
|
|
13183
11328
|
const getRpcUrl = () => networkConfig.resolve(config.network).pipe(
|
|
13184
11329
|
Effect8.map((n) => {
|
|
13185
|
-
if (config.debug) process.stderr.write(`[debug]
|
|
11330
|
+
if (config.debug) process.stderr.write(`[debug] url: ${n.url}
|
|
13186
11331
|
`);
|
|
13187
|
-
return n.
|
|
11332
|
+
return n.url;
|
|
13188
11333
|
}),
|
|
13189
11334
|
Effect8.mapError(
|
|
13190
11335
|
(e) => new FastSdkError({ message: e.message, cause: e })
|
|
@@ -13228,7 +11373,7 @@ var FastRpcLive = Layer3.effect(
|
|
|
13228
11373
|
|
|
13229
11374
|
// ../../packages/x402-client/dist/bridge.js
|
|
13230
11375
|
async function getFastBalance(wallet, options) {
|
|
13231
|
-
const provider = new FastProvider({
|
|
11376
|
+
const provider = new FastProvider({ url: options.rpcUrl, networkId: options.networkId });
|
|
13232
11377
|
const signer = new Signer(wallet.privateKey);
|
|
13233
11378
|
const publicKey = await signer.getPublicKey();
|
|
13234
11379
|
try {
|
|
@@ -13242,7 +11387,7 @@ async function getFastBalance(wallet, options) {
|
|
|
13242
11387
|
if (!tokenBalance)
|
|
13243
11388
|
return 0n;
|
|
13244
11389
|
for (const [tokenIdBytes, balance] of tokenBalance) {
|
|
13245
|
-
const normalizedId =
|
|
11390
|
+
const normalizedId = toHex2(tokenIdBytes).replace(/^0x/, "");
|
|
13246
11391
|
if (normalizedId === options.tokenId) {
|
|
13247
11392
|
return balance;
|
|
13248
11393
|
}
|
|
@@ -13265,7 +11410,7 @@ async function bridgeFastusdcToUsdc(params) {
|
|
|
13265
11410
|
log(` From: ${fastWallet.address}`);
|
|
13266
11411
|
log(` To: ${evmReceiverAddress}`);
|
|
13267
11412
|
try {
|
|
13268
|
-
const provider = new FastProvider({ rpcUrl });
|
|
11413
|
+
const provider = new FastProvider({ url: rpcUrl, networkId });
|
|
13269
11414
|
const signer = new Signer(fastWallet.privateKey);
|
|
13270
11415
|
const publicKey = await signer.getPublicKey();
|
|
13271
11416
|
const derivedAddress = toFastAddress(publicKey);
|
|
@@ -13298,12 +11443,13 @@ async function bridgeFastusdcToUsdc(params) {
|
|
|
13298
11443
|
}
|
|
13299
11444
|
|
|
13300
11445
|
// ../../packages/x402-client/dist/fast.js
|
|
11446
|
+
import { Schema as Schema6 } from "effect";
|
|
13301
11447
|
var fastProviders = {};
|
|
13302
|
-
function getFastProvider(
|
|
13303
|
-
if (!fastProviders[
|
|
13304
|
-
fastProviders[
|
|
11448
|
+
function getFastProvider(url) {
|
|
11449
|
+
if (!fastProviders[url]) {
|
|
11450
|
+
fastProviders[url] = new FastProvider({ url });
|
|
13305
11451
|
}
|
|
13306
|
-
return fastProviders[
|
|
11452
|
+
return fastProviders[url];
|
|
13307
11453
|
}
|
|
13308
11454
|
function toHuman(rawAmount, decimals) {
|
|
13309
11455
|
return (Number(rawAmount) / Math.pow(10, decimals)).toString();
|
|
@@ -13340,7 +11486,14 @@ function stringifyPaymentPayload(data) {
|
|
|
13340
11486
|
return serialized;
|
|
13341
11487
|
}
|
|
13342
11488
|
function resolveNetworkId(network2) {
|
|
13343
|
-
|
|
11489
|
+
switch (network2) {
|
|
11490
|
+
case "fast-mainnet":
|
|
11491
|
+
return "fast:mainnet";
|
|
11492
|
+
case "fast-testnet":
|
|
11493
|
+
return "fast:testnet";
|
|
11494
|
+
default:
|
|
11495
|
+
throw new Error(`Unknown Fast network: "${network2}"`);
|
|
11496
|
+
}
|
|
13344
11497
|
}
|
|
13345
11498
|
async function handleFastPayment(url, method, customHeaders, requestBody, paymentRequired, fastReq, wallet, verbose = false, logs = []) {
|
|
13346
11499
|
const log = (msg) => {
|
|
@@ -13378,12 +11531,12 @@ async function handleFastPayment(url, method, customHeaders, requestBody, paymen
|
|
|
13378
11531
|
let tokenId;
|
|
13379
11532
|
if (fastReq.asset) {
|
|
13380
11533
|
const assetHex = fastReq.asset.startsWith("0x") ? fastReq.asset.slice(2) : fastReq.asset;
|
|
13381
|
-
tokenId =
|
|
11534
|
+
tokenId = fromHex2(assetHex);
|
|
13382
11535
|
log(` Token: ${fastReq.asset} (from payment requirement)`);
|
|
13383
11536
|
} else {
|
|
13384
11537
|
throw new Error("No token asset specified in payment requirement");
|
|
13385
11538
|
}
|
|
13386
|
-
const recipientBytes = fastReq.payTo.startsWith("fast1") ? fromFastAddress(fastReq.payTo) :
|
|
11539
|
+
const recipientBytes = fastReq.payTo.startsWith("fast1") ? fromFastAddress(fastReq.payTo) : fromHex2(fastReq.payTo);
|
|
13387
11540
|
const amountHuman = toHuman(fastReq.maxAmountRequired, 6);
|
|
13388
11541
|
log(`[Fast] Building transaction via TransactionBuilder...`);
|
|
13389
11542
|
log(` Amount: ${fastReq.maxAmountRequired} raw \u2192 ${amountHuman} USDC`);
|
|
@@ -13408,8 +11561,7 @@ async function handleFastPayment(url, method, customHeaders, requestBody, paymen
|
|
|
13408
11561
|
}
|
|
13409
11562
|
log(` Transaction complete in ${Date.now() - txStartTime}ms`);
|
|
13410
11563
|
const certificate = submitResult.value;
|
|
13411
|
-
const
|
|
13412
|
-
const bcsInput = { [tx.type]: tx.value };
|
|
11564
|
+
const bcsInput = Schema6.encodeSync(VersionedTransactionFromBcs)(certificate.envelope.transaction);
|
|
13413
11565
|
const txHash = await hashHex2(bcs_layout_exports.VersionedTransaction, bcsInput);
|
|
13414
11566
|
log(` txHash: ${txHash}`);
|
|
13415
11567
|
log(`[Fast] Building x402 payment payload...`);
|
|
@@ -13527,7 +11679,8 @@ async function handleEvmPayment(url, method, customHeaders, requestBody, payment
|
|
|
13527
11679
|
log(`[EVM] Checking Fast USDC balance...`);
|
|
13528
11680
|
const fastBalance = await getFastBalance(fastWallet, {
|
|
13529
11681
|
rpcUrl: bridgeConfig.rpcUrl,
|
|
13530
|
-
tokenId: bridgeConfig.tokenFastTokenId
|
|
11682
|
+
tokenId: bridgeConfig.tokenFastTokenId,
|
|
11683
|
+
networkId: bridgeConfig.networkId
|
|
13531
11684
|
});
|
|
13532
11685
|
log(` Fast USDC balance: ${Number(fastBalance) / 1e6}`);
|
|
13533
11686
|
const shortfall = requiredAmount - currentBalance;
|
|
@@ -14348,13 +12501,13 @@ function validateObject(object2, fields = {}, optFields = {}) {
|
|
|
14348
12501
|
iter(optFields, true);
|
|
14349
12502
|
}
|
|
14350
12503
|
function memoized(fn) {
|
|
14351
|
-
const
|
|
12504
|
+
const map = /* @__PURE__ */ new WeakMap();
|
|
14352
12505
|
return (arg, ...args) => {
|
|
14353
|
-
const val =
|
|
12506
|
+
const val = map.get(arg);
|
|
14354
12507
|
if (val !== void 0)
|
|
14355
12508
|
return val;
|
|
14356
12509
|
const computed = fn(arg, ...args);
|
|
14357
|
-
|
|
12510
|
+
map.set(arg, computed);
|
|
14358
12511
|
return computed;
|
|
14359
12512
|
};
|
|
14360
12513
|
}
|
|
@@ -14527,9 +12680,9 @@ function validateField(field) {
|
|
|
14527
12680
|
BYTES: "number",
|
|
14528
12681
|
BITS: "number"
|
|
14529
12682
|
};
|
|
14530
|
-
const opts = FIELD_FIELDS.reduce((
|
|
14531
|
-
|
|
14532
|
-
return
|
|
12683
|
+
const opts = FIELD_FIELDS.reduce((map, val) => {
|
|
12684
|
+
map[val] = "function";
|
|
12685
|
+
return map;
|
|
14533
12686
|
}, initial);
|
|
14534
12687
|
validateObject(field, opts);
|
|
14535
12688
|
return field;
|
|
@@ -14541,15 +12694,15 @@ function FpPow(Fp, num, power) {
|
|
|
14541
12694
|
return Fp.ONE;
|
|
14542
12695
|
if (power === _1n3)
|
|
14543
12696
|
return num;
|
|
14544
|
-
let
|
|
12697
|
+
let p = Fp.ONE;
|
|
14545
12698
|
let d = num;
|
|
14546
12699
|
while (power > _0n3) {
|
|
14547
12700
|
if (power & _1n3)
|
|
14548
|
-
|
|
12701
|
+
p = Fp.mul(p, d);
|
|
14549
12702
|
d = Fp.sqr(d);
|
|
14550
12703
|
power >>= _1n3;
|
|
14551
12704
|
}
|
|
14552
|
-
return
|
|
12705
|
+
return p;
|
|
14553
12706
|
}
|
|
14554
12707
|
function FpInvertBatch(Fp, nums, passZero = false) {
|
|
14555
12708
|
const inverted = new Array(nums.length).fill(passZero ? Fp.ZERO : void 0);
|
|
@@ -14753,8 +12906,8 @@ function negateCt(condition, item) {
|
|
|
14753
12906
|
return condition ? neg : item;
|
|
14754
12907
|
}
|
|
14755
12908
|
function normalizeZ(c, points) {
|
|
14756
|
-
const invertedZs = FpInvertBatch(c.Fp, points.map((
|
|
14757
|
-
return points.map((
|
|
12909
|
+
const invertedZs = FpInvertBatch(c.Fp, points.map((p) => p.Z));
|
|
12910
|
+
return points.map((p, i) => c.fromAffine(p.toAffine(invertedZs[i])));
|
|
14758
12911
|
}
|
|
14759
12912
|
function validateW(W2, bits) {
|
|
14760
12913
|
if (!Number.isSafeInteger(W2) || W2 <= 0 || W2 > bits)
|
|
@@ -14807,15 +12960,15 @@ var wNAF2 = class {
|
|
|
14807
12960
|
this.bits = bits;
|
|
14808
12961
|
}
|
|
14809
12962
|
// non-const time multiplication ladder
|
|
14810
|
-
_unsafeLadder(elm, n,
|
|
12963
|
+
_unsafeLadder(elm, n, p = this.ZERO) {
|
|
14811
12964
|
let d = elm;
|
|
14812
12965
|
while (n > _0n4) {
|
|
14813
12966
|
if (n & _1n4)
|
|
14814
|
-
|
|
12967
|
+
p = p.add(d);
|
|
14815
12968
|
d = d.double();
|
|
14816
12969
|
n >>= _1n4;
|
|
14817
12970
|
}
|
|
14818
|
-
return
|
|
12971
|
+
return p;
|
|
14819
12972
|
}
|
|
14820
12973
|
/**
|
|
14821
12974
|
* Creates a wNAF precomputation window. Used for caching.
|
|
@@ -14832,16 +12985,16 @@ var wNAF2 = class {
|
|
|
14832
12985
|
precomputeWindow(point, W2) {
|
|
14833
12986
|
const { windows, windowSize } = calcWOpts(W2, this.bits);
|
|
14834
12987
|
const points = [];
|
|
14835
|
-
let
|
|
14836
|
-
let base2 =
|
|
12988
|
+
let p = point;
|
|
12989
|
+
let base2 = p;
|
|
14837
12990
|
for (let window = 0; window < windows; window++) {
|
|
14838
|
-
base2 =
|
|
12991
|
+
base2 = p;
|
|
14839
12992
|
points.push(base2);
|
|
14840
12993
|
for (let i = 1; i < windowSize; i++) {
|
|
14841
|
-
base2 = base2.add(
|
|
12994
|
+
base2 = base2.add(p);
|
|
14842
12995
|
points.push(base2);
|
|
14843
12996
|
}
|
|
14844
|
-
|
|
12997
|
+
p = base2.double();
|
|
14845
12998
|
}
|
|
14846
12999
|
return points;
|
|
14847
13000
|
}
|
|
@@ -14854,7 +13007,7 @@ var wNAF2 = class {
|
|
|
14854
13007
|
wNAF(W2, precomputes, n) {
|
|
14855
13008
|
if (!this.Fn.isValid(n))
|
|
14856
13009
|
throw new Error("invalid scalar");
|
|
14857
|
-
let
|
|
13010
|
+
let p = this.ZERO;
|
|
14858
13011
|
let f = this.BASE;
|
|
14859
13012
|
const wo = calcWOpts(W2, this.bits);
|
|
14860
13013
|
for (let window = 0; window < wo.windows; window++) {
|
|
@@ -14863,11 +13016,11 @@ var wNAF2 = class {
|
|
|
14863
13016
|
if (isZero) {
|
|
14864
13017
|
f = f.add(negateCt(isNegF, precomputes[offsetF]));
|
|
14865
13018
|
} else {
|
|
14866
|
-
|
|
13019
|
+
p = p.add(negateCt(isNeg, precomputes[offset]));
|
|
14867
13020
|
}
|
|
14868
13021
|
}
|
|
14869
13022
|
assert0(n);
|
|
14870
|
-
return { p
|
|
13023
|
+
return { p, f };
|
|
14871
13024
|
}
|
|
14872
13025
|
/**
|
|
14873
13026
|
* Implements ec unsafe (non const-time) multiplication using precomputed tables and w-ary non-adjacent form.
|
|
@@ -14928,17 +13081,17 @@ var wNAF2 = class {
|
|
|
14928
13081
|
function mulEndoUnsafe(Point2, point, k1, k2) {
|
|
14929
13082
|
let acc = point;
|
|
14930
13083
|
let p1 = Point2.ZERO;
|
|
14931
|
-
let
|
|
13084
|
+
let p2 = Point2.ZERO;
|
|
14932
13085
|
while (k1 > _0n4 || k2 > _0n4) {
|
|
14933
13086
|
if (k1 & _1n4)
|
|
14934
13087
|
p1 = p1.add(acc);
|
|
14935
13088
|
if (k2 & _1n4)
|
|
14936
|
-
|
|
13089
|
+
p2 = p2.add(acc);
|
|
14937
13090
|
acc = acc.double();
|
|
14938
13091
|
k1 >>= _1n4;
|
|
14939
13092
|
k2 >>= _1n4;
|
|
14940
13093
|
}
|
|
14941
|
-
return { p1, p2
|
|
13094
|
+
return { p1, p2 };
|
|
14942
13095
|
}
|
|
14943
13096
|
function createField(order, field, isLE3) {
|
|
14944
13097
|
if (field) {
|
|
@@ -14955,18 +13108,18 @@ function createCurveFields(type, CURVE, curveOpts = {}, FpFnLE) {
|
|
|
14955
13108
|
FpFnLE = type === "edwards";
|
|
14956
13109
|
if (!CURVE || typeof CURVE !== "object")
|
|
14957
13110
|
throw new Error(`expected valid ${type} CURVE object`);
|
|
14958
|
-
for (const
|
|
14959
|
-
const val = CURVE[
|
|
13111
|
+
for (const p of ["p", "n", "h"]) {
|
|
13112
|
+
const val = CURVE[p];
|
|
14960
13113
|
if (!(typeof val === "bigint" && val > _0n4))
|
|
14961
|
-
throw new Error(`CURVE.${
|
|
13114
|
+
throw new Error(`CURVE.${p} must be positive bigint`);
|
|
14962
13115
|
}
|
|
14963
13116
|
const Fp = createField(CURVE.p, curveOpts.Fp, FpFnLE);
|
|
14964
13117
|
const Fn = createField(CURVE.n, curveOpts.Fn, FpFnLE);
|
|
14965
13118
|
const _b = type === "weierstrass" ? "b" : "d";
|
|
14966
13119
|
const params = ["Gx", "Gy", "a", _b];
|
|
14967
|
-
for (const
|
|
14968
|
-
if (!Fp.isValid(CURVE[
|
|
14969
|
-
throw new Error(`CURVE.${
|
|
13120
|
+
for (const p of params) {
|
|
13121
|
+
if (!Fp.isValid(CURVE[p]))
|
|
13122
|
+
throw new Error(`CURVE.${p} must be valid field element of CURVE.Fp`);
|
|
14970
13123
|
}
|
|
14971
13124
|
CURVE = Object.freeze(Object.assign({}, CURVE));
|
|
14972
13125
|
return { CURVE, Fp, Fn };
|
|
@@ -15298,11 +13451,11 @@ function weierstrass(params, extraOpts = {}) {
|
|
|
15298
13451
|
throw new Error("no endo");
|
|
15299
13452
|
return _splitEndoScalar(k, endo.basises, Fn.ORDER);
|
|
15300
13453
|
}
|
|
15301
|
-
const toAffineMemo = memoized((
|
|
15302
|
-
const { X, Y, Z } =
|
|
13454
|
+
const toAffineMemo = memoized((p, iz) => {
|
|
13455
|
+
const { X, Y, Z } = p;
|
|
15303
13456
|
if (Fp.eql(Z, Fp.ONE))
|
|
15304
13457
|
return { x: X, y: Y };
|
|
15305
|
-
const is0 =
|
|
13458
|
+
const is0 = p.is0();
|
|
15306
13459
|
if (iz == null)
|
|
15307
13460
|
iz = is0 ? Fp.ONE : Fp.inv(Z);
|
|
15308
13461
|
const x = Fp.mul(X, iz);
|
|
@@ -15314,18 +13467,18 @@ function weierstrass(params, extraOpts = {}) {
|
|
|
15314
13467
|
throw new Error("invZ was invalid");
|
|
15315
13468
|
return { x, y };
|
|
15316
13469
|
});
|
|
15317
|
-
const assertValidMemo = memoized((
|
|
15318
|
-
if (
|
|
15319
|
-
if (extraOpts.allowInfinityPoint && !Fp.is0(
|
|
13470
|
+
const assertValidMemo = memoized((p) => {
|
|
13471
|
+
if (p.is0()) {
|
|
13472
|
+
if (extraOpts.allowInfinityPoint && !Fp.is0(p.Y))
|
|
15320
13473
|
return;
|
|
15321
13474
|
throw new Error("bad point: ZERO");
|
|
15322
13475
|
}
|
|
15323
|
-
const { x, y } =
|
|
13476
|
+
const { x, y } = p.toAffine();
|
|
15324
13477
|
if (!Fp.isValid(x) || !Fp.isValid(y))
|
|
15325
13478
|
throw new Error("bad point: x or y not field elements");
|
|
15326
13479
|
if (!isValidXY(x, y))
|
|
15327
13480
|
throw new Error("bad point: equation left != right");
|
|
15328
|
-
if (!
|
|
13481
|
+
if (!p.isTorsionFree())
|
|
15329
13482
|
throw new Error("bad point: not in prime-order subgroup");
|
|
15330
13483
|
return true;
|
|
15331
13484
|
});
|
|
@@ -15359,11 +13512,11 @@ function weierstrass(params, extraOpts = {}) {
|
|
|
15359
13512
|
return CURVE;
|
|
15360
13513
|
}
|
|
15361
13514
|
/** Does NOT validate if the point is valid. Use `.assertValidity()`. */
|
|
15362
|
-
static fromAffine(
|
|
15363
|
-
const { x, y } =
|
|
15364
|
-
if (!
|
|
13515
|
+
static fromAffine(p) {
|
|
13516
|
+
const { x, y } = p || {};
|
|
13517
|
+
if (!p || !Fp.isValid(x) || !Fp.isValid(y))
|
|
15365
13518
|
throw new Error("invalid affine point");
|
|
15366
|
-
if (
|
|
13519
|
+
if (p instanceof Point2)
|
|
15367
13520
|
throw new Error("projective point not allowed");
|
|
15368
13521
|
if (Fp.is0(x) && Fp.is0(y))
|
|
15369
13522
|
return Point2.ZERO;
|
|
@@ -15534,7 +13687,7 @@ function weierstrass(params, extraOpts = {}) {
|
|
|
15534
13687
|
if (!Fn.isValidNot0(scalar))
|
|
15535
13688
|
throw new Error("invalid scalar: out of range");
|
|
15536
13689
|
let point, fake;
|
|
15537
|
-
const mul3 = (n) => wnaf.cached(this, n, (
|
|
13690
|
+
const mul3 = (n) => wnaf.cached(this, n, (p) => normalizeZ(Point2, p));
|
|
15538
13691
|
if (endo2) {
|
|
15539
13692
|
const { k1neg, k1, k2neg, k2 } = splitEndoScalarN(scalar);
|
|
15540
13693
|
const { p: k1p, f: k1f } = mul3(k1);
|
|
@@ -15542,8 +13695,8 @@ function weierstrass(params, extraOpts = {}) {
|
|
|
15542
13695
|
fake = k1f.add(k2f);
|
|
15543
13696
|
point = finishEndo(endo2.beta, k1p, k2p, k1neg, k2neg);
|
|
15544
13697
|
} else {
|
|
15545
|
-
const { p
|
|
15546
|
-
point =
|
|
13698
|
+
const { p, f } = mul3(scalar);
|
|
13699
|
+
point = p;
|
|
15547
13700
|
fake = f;
|
|
15548
13701
|
}
|
|
15549
13702
|
return normalizeZ(Point2, [point, fake])[0];
|
|
@@ -15555,21 +13708,21 @@ function weierstrass(params, extraOpts = {}) {
|
|
|
15555
13708
|
*/
|
|
15556
13709
|
multiplyUnsafe(sc) {
|
|
15557
13710
|
const { endo: endo2 } = extraOpts;
|
|
15558
|
-
const
|
|
13711
|
+
const p = this;
|
|
15559
13712
|
if (!Fn.isValid(sc))
|
|
15560
13713
|
throw new Error("invalid scalar: out of range");
|
|
15561
|
-
if (sc === _0n5 ||
|
|
13714
|
+
if (sc === _0n5 || p.is0())
|
|
15562
13715
|
return Point2.ZERO;
|
|
15563
13716
|
if (sc === _1n5)
|
|
15564
|
-
return
|
|
13717
|
+
return p;
|
|
15565
13718
|
if (wnaf.hasCache(this))
|
|
15566
13719
|
return this.multiply(sc);
|
|
15567
13720
|
if (endo2) {
|
|
15568
13721
|
const { k1neg, k1, k2neg, k2 } = splitEndoScalarN(sc);
|
|
15569
|
-
const { p1, p2
|
|
15570
|
-
return finishEndo(endo2.beta, p1,
|
|
13722
|
+
const { p1, p2 } = mulEndoUnsafe(Point2, p, k1, k2);
|
|
13723
|
+
return finishEndo(endo2.beta, p1, p2, k1neg, k2neg);
|
|
15571
13724
|
} else {
|
|
15572
|
-
return wnaf.unsafe(
|
|
13725
|
+
return wnaf.unsafe(p, sc);
|
|
15573
13726
|
}
|
|
15574
13727
|
}
|
|
15575
13728
|
/**
|
|
@@ -15729,7 +13882,7 @@ function ecdsa(Point2, hash3, ecdsaOpts = {}) {
|
|
|
15729
13882
|
const sizer = format === "compact" ? size5 : format === "recovered" ? size5 + 1 : void 0;
|
|
15730
13883
|
return abytes(bytes, sizer);
|
|
15731
13884
|
}
|
|
15732
|
-
class
|
|
13885
|
+
class Signature {
|
|
15733
13886
|
r;
|
|
15734
13887
|
s;
|
|
15735
13888
|
recovery;
|
|
@@ -15749,7 +13902,7 @@ function ecdsa(Point2, hash3, ecdsaOpts = {}) {
|
|
|
15749
13902
|
let recid;
|
|
15750
13903
|
if (format === "der") {
|
|
15751
13904
|
const { r: r2, s: s2 } = DER.toSig(abytes(bytes));
|
|
15752
|
-
return new
|
|
13905
|
+
return new Signature(r2, s2);
|
|
15753
13906
|
}
|
|
15754
13907
|
if (format === "recovered") {
|
|
15755
13908
|
recid = bytes[0];
|
|
@@ -15759,7 +13912,7 @@ function ecdsa(Point2, hash3, ecdsaOpts = {}) {
|
|
|
15759
13912
|
const L2 = lengths.signature / 2;
|
|
15760
13913
|
const r = bytes.subarray(0, L2);
|
|
15761
13914
|
const s = bytes.subarray(L2, L2 * 2);
|
|
15762
|
-
return new
|
|
13915
|
+
return new Signature(Fn.fromBytes(r), Fn.fromBytes(s), recid);
|
|
15763
13916
|
}
|
|
15764
13917
|
static fromHex(hex, format) {
|
|
15765
13918
|
return this.fromBytes(hexToBytes2(hex), format);
|
|
@@ -15771,7 +13924,7 @@ function ecdsa(Point2, hash3, ecdsaOpts = {}) {
|
|
|
15771
13924
|
return recovery;
|
|
15772
13925
|
}
|
|
15773
13926
|
addRecoveryBit(recovery) {
|
|
15774
|
-
return new
|
|
13927
|
+
return new Signature(this.r, this.s, recovery);
|
|
15775
13928
|
}
|
|
15776
13929
|
recoverPublicKey(messageHash) {
|
|
15777
13930
|
const { r, s } = this;
|
|
@@ -15863,7 +14016,7 @@ function ecdsa(Point2, hash3, ecdsaOpts = {}) {
|
|
|
15863
14016
|
normS = Fn.neg(s);
|
|
15864
14017
|
recovery ^= 1;
|
|
15865
14018
|
}
|
|
15866
|
-
return new
|
|
14019
|
+
return new Signature(r, normS, hasLargeCofactor ? void 0 : recovery);
|
|
15867
14020
|
}
|
|
15868
14021
|
return { seed, k2sig };
|
|
15869
14022
|
}
|
|
@@ -15878,12 +14031,12 @@ function ecdsa(Point2, hash3, ecdsaOpts = {}) {
|
|
|
15878
14031
|
publicKey = abytes(publicKey, void 0, "publicKey");
|
|
15879
14032
|
message2 = validateMsgAndHash(message2, prehash);
|
|
15880
14033
|
if (!isBytes(signature)) {
|
|
15881
|
-
const end = signature instanceof
|
|
14034
|
+
const end = signature instanceof Signature ? ", use sig.toBytes()" : "";
|
|
15882
14035
|
throw new Error("verify expects Uint8Array signature" + end);
|
|
15883
14036
|
}
|
|
15884
14037
|
validateSigLength(signature, format);
|
|
15885
14038
|
try {
|
|
15886
|
-
const sig =
|
|
14039
|
+
const sig = Signature.fromBytes(signature, format);
|
|
15887
14040
|
const P2 = Point2.fromBytes(publicKey);
|
|
15888
14041
|
if (lowS && sig.hasHighS())
|
|
15889
14042
|
return false;
|
|
@@ -15904,7 +14057,7 @@ function ecdsa(Point2, hash3, ecdsaOpts = {}) {
|
|
|
15904
14057
|
function recoverPublicKey3(signature, message2, opts = {}) {
|
|
15905
14058
|
const { prehash } = validateSigOpts(opts, defaultSigOpts);
|
|
15906
14059
|
message2 = validateMsgAndHash(message2, prehash);
|
|
15907
|
-
return
|
|
14060
|
+
return Signature.fromBytes(signature, "recovered").recoverPublicKey(message2).toBytes();
|
|
15908
14061
|
}
|
|
15909
14062
|
return Object.freeze({
|
|
15910
14063
|
keygen,
|
|
@@ -15916,7 +14069,7 @@ function ecdsa(Point2, hash3, ecdsaOpts = {}) {
|
|
|
15916
14069
|
sign: sign2,
|
|
15917
14070
|
verify: verify2,
|
|
15918
14071
|
recoverPublicKey: recoverPublicKey3,
|
|
15919
|
-
Signature
|
|
14072
|
+
Signature,
|
|
15920
14073
|
hash: hash3
|
|
15921
14074
|
});
|
|
15922
14075
|
}
|
|
@@ -15976,11 +14129,11 @@ import { Effect as Effect12, Option as Option3 } from "effect";
|
|
|
15976
14129
|
import { timingSafeEqual } from "crypto";
|
|
15977
14130
|
|
|
15978
14131
|
// ../../node_modules/.pnpm/@noble+ciphers@1.3.0/node_modules/@noble/ciphers/esm/utils.js
|
|
15979
|
-
function
|
|
14132
|
+
function isBytes3(a) {
|
|
15980
14133
|
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
15981
14134
|
}
|
|
15982
14135
|
function abytes3(b, ...lengths) {
|
|
15983
|
-
if (!
|
|
14136
|
+
if (!isBytes3(b))
|
|
15984
14137
|
throw new Error("Uint8Array expected");
|
|
15985
14138
|
if (lengths.length > 0 && !lengths.includes(b.length))
|
|
15986
14139
|
throw new Error("Uint8Array expected of length " + lengths + ", got length=" + b.length);
|
|
@@ -16124,10 +14277,10 @@ function genTtable(sbox2, fn) {
|
|
|
16124
14277
|
}
|
|
16125
14278
|
var tableEncoding = /* @__PURE__ */ genTtable(sbox, (s) => mul(s, 3) << 24 | s << 16 | s << 8 | mul(s, 2));
|
|
16126
14279
|
var xPowers = /* @__PURE__ */ (() => {
|
|
16127
|
-
const
|
|
14280
|
+
const p = new Uint8Array(16);
|
|
16128
14281
|
for (let i = 0, x = 1; i < 16; i++, x = mul2(x))
|
|
16129
|
-
|
|
16130
|
-
return
|
|
14282
|
+
p[i] = x;
|
|
14283
|
+
return p;
|
|
16131
14284
|
})();
|
|
16132
14285
|
function expandKeyLE(key) {
|
|
16133
14286
|
abytes3(key);
|
|
@@ -16360,10 +14513,10 @@ function scryptInit(password, salt, _opts) {
|
|
|
16360
14513
|
asyncTick: 10,
|
|
16361
14514
|
maxmem: 1024 ** 3 + 1024
|
|
16362
14515
|
}, _opts);
|
|
16363
|
-
const { N: N2, r, p
|
|
14516
|
+
const { N: N2, r, p, dkLen, asyncTick, maxmem, onProgress } = opts;
|
|
16364
14517
|
anumber(N2, "N");
|
|
16365
14518
|
anumber(r, "r");
|
|
16366
|
-
anumber(
|
|
14519
|
+
anumber(p, "p");
|
|
16367
14520
|
anumber(dkLen, "dkLen");
|
|
16368
14521
|
anumber(asyncTick, "asyncTick");
|
|
16369
14522
|
anumber(maxmem, "maxmem");
|
|
@@ -16374,21 +14527,21 @@ function scryptInit(password, salt, _opts) {
|
|
|
16374
14527
|
const pow32 = Math.pow(2, 32);
|
|
16375
14528
|
if (N2 <= 1 || (N2 & N2 - 1) !== 0 || N2 > pow32)
|
|
16376
14529
|
throw new Error('"N" expected a power of 2, and 2^1 <= N <= 2^32');
|
|
16377
|
-
if (
|
|
14530
|
+
if (p < 1 || p > (pow32 - 1) * 32 / blockSize)
|
|
16378
14531
|
throw new Error('"p" expected integer 1..((2^32 - 1) * 32) / (128 * r)');
|
|
16379
14532
|
if (dkLen < 1 || dkLen > (pow32 - 1) * 32)
|
|
16380
14533
|
throw new Error('"dkLen" expected integer 1..(2^32 - 1) * 32');
|
|
16381
|
-
const memUsed = blockSize * (N2 +
|
|
14534
|
+
const memUsed = blockSize * (N2 + p);
|
|
16382
14535
|
if (memUsed > maxmem)
|
|
16383
14536
|
throw new Error('"maxmem" limit was hit, expected 128*r*(N+p) <= "maxmem"=' + maxmem);
|
|
16384
|
-
const B = pbkdf2(sha2564, password, salt, { c: 1, dkLen: blockSize *
|
|
14537
|
+
const B = pbkdf2(sha2564, password, salt, { c: 1, dkLen: blockSize * p });
|
|
16385
14538
|
const B32 = u32(B);
|
|
16386
14539
|
const V = u32(new Uint8Array(blockSize * N2));
|
|
16387
14540
|
const tmp = u32(new Uint8Array(blockSize));
|
|
16388
14541
|
let blockMixCb = () => {
|
|
16389
14542
|
};
|
|
16390
14543
|
if (onProgress) {
|
|
16391
|
-
const totalBlockMix = 2 * N2 *
|
|
14544
|
+
const totalBlockMix = 2 * N2 * p;
|
|
16392
14545
|
const callbackPer = Math.max(Math.floor(totalBlockMix / 1e4), 1);
|
|
16393
14546
|
let blockMixCnt = 0;
|
|
16394
14547
|
blockMixCb = () => {
|
|
@@ -16397,7 +14550,7 @@ function scryptInit(password, salt, _opts) {
|
|
|
16397
14550
|
onProgress(blockMixCnt / totalBlockMix);
|
|
16398
14551
|
};
|
|
16399
14552
|
}
|
|
16400
|
-
return { N: N2, r, p
|
|
14553
|
+
return { N: N2, r, p, dkLen, blockSize32, V, B32, B, tmp, blockMixCb, asyncTick };
|
|
16401
14554
|
}
|
|
16402
14555
|
function scryptOutput(password, dkLen, B, V, tmp) {
|
|
16403
14556
|
const res = pbkdf2(sha2564, password, B, { c: 1, dkLen });
|
|
@@ -16405,9 +14558,9 @@ function scryptOutput(password, dkLen, B, V, tmp) {
|
|
|
16405
14558
|
return res;
|
|
16406
14559
|
}
|
|
16407
14560
|
async function scryptAsync(password, salt, opts) {
|
|
16408
|
-
const { N: N2, r, p
|
|
14561
|
+
const { N: N2, r, p, dkLen, blockSize32, V, B32, B, tmp, blockMixCb, asyncTick } = scryptInit(password, salt, opts);
|
|
16409
14562
|
swap32IfBE(B32);
|
|
16410
|
-
for (let pi = 0; pi <
|
|
14563
|
+
for (let pi = 0; pi < p; pi++) {
|
|
16411
14564
|
const Pi = blockSize32 * pi;
|
|
16412
14565
|
for (let i = 0; i < blockSize32; i++)
|
|
16413
14566
|
V[i] = B32[Pi + i];
|
|
@@ -16453,10 +14606,10 @@ var encryptSeed = async (seed, password) => {
|
|
|
16453
14606
|
const mac = computeMac(derivedKey, ciphertext);
|
|
16454
14607
|
const blob = {
|
|
16455
14608
|
v: 1,
|
|
16456
|
-
salt:
|
|
16457
|
-
iv:
|
|
16458
|
-
mac:
|
|
16459
|
-
ct:
|
|
14609
|
+
salt: toHex2(salt),
|
|
14610
|
+
iv: toHex2(iv),
|
|
14611
|
+
mac: toHex2(mac),
|
|
14612
|
+
ct: toHex2(ciphertext),
|
|
16460
14613
|
kdf: { n: SCRYPT_N, r: SCRYPT_R, p: SCRYPT_P }
|
|
16461
14614
|
};
|
|
16462
14615
|
return encryptJson(blob);
|
|
@@ -16467,10 +14620,10 @@ var storeSeed = async (seed, password) => {
|
|
|
16467
14620
|
};
|
|
16468
14621
|
var decryptSeed = async (blob, password) => {
|
|
16469
14622
|
const parsed2 = decryptJson(blob);
|
|
16470
|
-
const salt =
|
|
16471
|
-
const iv =
|
|
16472
|
-
const ciphertext =
|
|
16473
|
-
const storedMac =
|
|
14623
|
+
const salt = fromHex2(parsed2.salt);
|
|
14624
|
+
const iv = fromHex2(parsed2.iv);
|
|
14625
|
+
const ciphertext = fromHex2(parsed2.ct);
|
|
14626
|
+
const storedMac = fromHex2(parsed2.mac);
|
|
16474
14627
|
const derivedKey = await scryptAsync(encodePassword(password), salt, {
|
|
16475
14628
|
N: parsed2.kdf.n,
|
|
16476
14629
|
r: parsed2.kdf.r,
|
|
@@ -16504,7 +14657,7 @@ var rowToInfo = (row) => ({
|
|
|
16504
14657
|
var deriveEvmAddress = (seed) => {
|
|
16505
14658
|
const pubkey = secp256k12.getPublicKey(seed, false);
|
|
16506
14659
|
const hash3 = keccak_2562(pubkey.slice(1));
|
|
16507
|
-
return
|
|
14660
|
+
return toHex2(hash3.slice(-20));
|
|
16508
14661
|
};
|
|
16509
14662
|
var getAccountByName = (db, name) => db.select().from(accounts).where(eq(accounts.name, name)).get();
|
|
16510
14663
|
var getDefaultAccount = (db) => db.select().from(accounts).where(eq(accounts.isDefault, true)).get();
|
|
@@ -16814,41 +14967,41 @@ var runHandler = (opts, program) => {
|
|
|
16814
14967
|
import { merge, object, or as or2 } from "@optique/core/constructs";
|
|
16815
14968
|
import { message } from "@optique/core/message";
|
|
16816
14969
|
import { multiple, optional, withDefault } from "@optique/core/modifiers";
|
|
16817
|
-
import { argument, command, constant, option
|
|
14970
|
+
import { argument, command, constant, option, passThrough } from "@optique/core/primitives";
|
|
16818
14971
|
import { integer, string } from "@optique/core/valueparser";
|
|
16819
14972
|
var globalPreParser = object({
|
|
16820
|
-
json: withDefault(
|
|
16821
|
-
help: withDefault(
|
|
16822
|
-
version: withDefault(
|
|
14973
|
+
json: withDefault(option("--json"), false),
|
|
14974
|
+
help: withDefault(option("--help"), false),
|
|
14975
|
+
version: withDefault(option("--version"), false),
|
|
16823
14976
|
_rest: passThrough({ format: "greedy" })
|
|
16824
14977
|
});
|
|
16825
14978
|
var globalOptions = object({
|
|
16826
14979
|
json: withDefault(
|
|
16827
|
-
|
|
14980
|
+
option("--json", { description: message`Emit machine-parseable JSON to stdout` }),
|
|
16828
14981
|
false
|
|
16829
14982
|
),
|
|
16830
14983
|
debug: withDefault(
|
|
16831
|
-
|
|
14984
|
+
option("--debug", { description: message`Enable verbose logging to stderr` }),
|
|
16832
14985
|
false
|
|
16833
14986
|
),
|
|
16834
14987
|
nonInteractive: withDefault(
|
|
16835
|
-
|
|
14988
|
+
option("--non-interactive", {
|
|
16836
14989
|
description: message`Auto-confirm dangerous operations; fail when input is missing`
|
|
16837
14990
|
}),
|
|
16838
14991
|
false
|
|
16839
14992
|
),
|
|
16840
14993
|
network: optional(
|
|
16841
|
-
|
|
14994
|
+
option("--network", string({ metavar: "NAME" }), {
|
|
16842
14995
|
description: message`Override the network for this command`
|
|
16843
14996
|
})
|
|
16844
14997
|
),
|
|
16845
14998
|
account: optional(
|
|
16846
|
-
|
|
14999
|
+
option("--account", string({ metavar: "NAME" }), {
|
|
16847
15000
|
description: message`Use the named account for signing operations`
|
|
16848
15001
|
})
|
|
16849
15002
|
),
|
|
16850
15003
|
password: withDefault(
|
|
16851
|
-
|
|
15004
|
+
option("--password", string({ metavar: "PASSWORD" }), {
|
|
16852
15005
|
description: message`Keystore password for decrypting the account key`
|
|
16853
15006
|
}),
|
|
16854
15007
|
() => process.env.FAST_PASSWORD
|
|
@@ -16859,7 +15012,7 @@ var accountCreateParser = command(
|
|
|
16859
15012
|
object({
|
|
16860
15013
|
cmd: constant("account-create"),
|
|
16861
15014
|
name: optional(
|
|
16862
|
-
|
|
15015
|
+
option("--name", string({ metavar: "NAME" }), {
|
|
16863
15016
|
description: message`Alias for the account`
|
|
16864
15017
|
})
|
|
16865
15018
|
)
|
|
@@ -16871,17 +15024,17 @@ var accountImportParser = command(
|
|
|
16871
15024
|
object({
|
|
16872
15025
|
cmd: constant("account-import"),
|
|
16873
15026
|
name: optional(
|
|
16874
|
-
|
|
15027
|
+
option("--name", string({ metavar: "NAME" }), {
|
|
16875
15028
|
description: message`Alias for the account`
|
|
16876
15029
|
})
|
|
16877
15030
|
),
|
|
16878
15031
|
privateKey: optional(
|
|
16879
|
-
|
|
15032
|
+
option("--private-key", string({ metavar: "HEX" }), {
|
|
16880
15033
|
description: message`Hex-encoded Ed25519 seed (0x-prefixed or raw)`
|
|
16881
15034
|
})
|
|
16882
15035
|
),
|
|
16883
15036
|
keyFile: optional(
|
|
16884
|
-
|
|
15037
|
+
option("--key-file", string({ metavar: "PATH" }), {
|
|
16885
15038
|
description: message`Path to a JSON file containing a privateKey field`
|
|
16886
15039
|
})
|
|
16887
15040
|
)
|
|
@@ -16953,7 +15106,7 @@ var networkAddParser = command(
|
|
|
16953
15106
|
name: argument(string({ metavar: "NAME" }), {
|
|
16954
15107
|
description: message`Name for the custom network`
|
|
16955
15108
|
}),
|
|
16956
|
-
config:
|
|
15109
|
+
config: option("--config", string({ metavar: "PATH" }), {
|
|
16957
15110
|
description: message`Path to network config JSON file`
|
|
16958
15111
|
})
|
|
16959
15112
|
}),
|
|
@@ -17001,7 +15154,7 @@ var infoBalanceParser = command(
|
|
|
17001
15154
|
object({
|
|
17002
15155
|
cmd: constant("info-balance"),
|
|
17003
15156
|
token: optional(
|
|
17004
|
-
|
|
15157
|
+
option("--token", string({ metavar: "TOKEN" }), {
|
|
17005
15158
|
description: message`Filter by token name or token ID`
|
|
17006
15159
|
})
|
|
17007
15160
|
)
|
|
@@ -17023,28 +15176,28 @@ var infoHistoryParser = command(
|
|
|
17023
15176
|
object({
|
|
17024
15177
|
cmd: constant("info-history"),
|
|
17025
15178
|
from: optional(
|
|
17026
|
-
|
|
15179
|
+
option("--from", string({ metavar: "ADDRESS" }), {
|
|
17027
15180
|
description: message`Filter by sender account name or address`
|
|
17028
15181
|
})
|
|
17029
15182
|
),
|
|
17030
15183
|
to: optional(
|
|
17031
|
-
|
|
15184
|
+
option("--to", string({ metavar: "ADDRESS" }), {
|
|
17032
15185
|
description: message`Filter by recipient address`
|
|
17033
15186
|
})
|
|
17034
15187
|
),
|
|
17035
15188
|
token: optional(
|
|
17036
|
-
|
|
15189
|
+
option("--token", string({ metavar: "TOKEN" }), {
|
|
17037
15190
|
description: message`Filter by token`
|
|
17038
15191
|
})
|
|
17039
15192
|
),
|
|
17040
15193
|
limit: withDefault(
|
|
17041
|
-
|
|
15194
|
+
option("--limit", integer(), {
|
|
17042
15195
|
description: message`Max number of records to return`
|
|
17043
15196
|
}),
|
|
17044
15197
|
20
|
|
17045
15198
|
),
|
|
17046
15199
|
offset: withDefault(
|
|
17047
|
-
|
|
15200
|
+
option("--offset", integer(), {
|
|
17048
15201
|
description: message`Number of records to skip`
|
|
17049
15202
|
}),
|
|
17050
15203
|
0
|
|
@@ -17082,22 +15235,22 @@ var sendParser = command(
|
|
|
17082
15235
|
description: message`Human-readable amount (e.g., 10.5)`
|
|
17083
15236
|
}),
|
|
17084
15237
|
token: optional(
|
|
17085
|
-
|
|
15238
|
+
option("--token", string({ metavar: "TOKEN" }), {
|
|
17086
15239
|
description: message`Token to send (e.g., testUSDC, USDC)`
|
|
17087
15240
|
})
|
|
17088
15241
|
),
|
|
17089
15242
|
fromChain: optional(
|
|
17090
|
-
|
|
15243
|
+
option("--from-chain", string({ metavar: "CHAIN" }), {
|
|
17091
15244
|
description: message`Source EVM chain for bridge-in (e.g., arbitrum-sepolia)`
|
|
17092
15245
|
})
|
|
17093
15246
|
),
|
|
17094
15247
|
toChain: optional(
|
|
17095
|
-
|
|
15248
|
+
option("--to-chain", string({ metavar: "CHAIN" }), {
|
|
17096
15249
|
description: message`Destination EVM chain for bridge-out (e.g., arbitrum-sepolia)`
|
|
17097
15250
|
})
|
|
17098
15251
|
),
|
|
17099
15252
|
eip7702: withDefault(
|
|
17100
|
-
|
|
15253
|
+
option("--eip-7702", {
|
|
17101
15254
|
description: message`Use EIP-7702 smart deposit for EVM → Fast (gas paid in USDC, no ETH required)`
|
|
17102
15255
|
}),
|
|
17103
15256
|
false
|
|
@@ -17110,7 +15263,7 @@ var fundFiatParser = command(
|
|
|
17110
15263
|
object({
|
|
17111
15264
|
cmd: constant("fund-fiat"),
|
|
17112
15265
|
address: optional(
|
|
17113
|
-
|
|
15266
|
+
option("--address", string({ metavar: "ADDRESS" }), {
|
|
17114
15267
|
description: message`Fast address to fund (default: default account)`
|
|
17115
15268
|
})
|
|
17116
15269
|
)
|
|
@@ -17124,16 +15277,16 @@ var fundCryptoParser = command(
|
|
|
17124
15277
|
amount: argument(string({ metavar: "AMOUNT" }), {
|
|
17125
15278
|
description: message`Human-readable amount to fund (e.g., 100.00)`
|
|
17126
15279
|
}),
|
|
17127
|
-
chain:
|
|
15280
|
+
chain: option("--chain", string({ metavar: "CHAIN" }), {
|
|
17128
15281
|
description: message`EVM chain to bridge from (see fast info bridge-chains)`
|
|
17129
15282
|
}),
|
|
17130
15283
|
token: optional(
|
|
17131
|
-
|
|
15284
|
+
option("--token", string({ metavar: "TOKEN" }), {
|
|
17132
15285
|
description: message`Token to bridge (default: USDC / testUSDC)`
|
|
17133
15286
|
})
|
|
17134
15287
|
),
|
|
17135
15288
|
eip7702: withDefault(
|
|
17136
|
-
|
|
15289
|
+
option("--eip-7702", {
|
|
17137
15290
|
description: message`Use EIP-7702 smart deposit (gas paid in USDC via paymaster, no ETH required)`
|
|
17138
15291
|
}),
|
|
17139
15292
|
false
|
|
@@ -17154,27 +15307,27 @@ var payParser = command(
|
|
|
17154
15307
|
description: message`URL of the x402-protected resource`
|
|
17155
15308
|
}),
|
|
17156
15309
|
dryRun: withDefault(
|
|
17157
|
-
|
|
15310
|
+
option("--dry-run", {
|
|
17158
15311
|
description: message`Inspect payment requirements without paying`
|
|
17159
15312
|
}),
|
|
17160
15313
|
false
|
|
17161
15314
|
),
|
|
17162
15315
|
method: withDefault(
|
|
17163
|
-
|
|
15316
|
+
option("--method", string({ metavar: "METHOD" }), {
|
|
17164
15317
|
description: message`HTTP method (default: GET)`
|
|
17165
15318
|
}),
|
|
17166
15319
|
"GET"
|
|
17167
15320
|
),
|
|
17168
15321
|
header: withDefault(
|
|
17169
15322
|
multiple(
|
|
17170
|
-
|
|
15323
|
+
option("--header", string({ metavar: "KEY: VALUE" }), {
|
|
17171
15324
|
description: message`Custom header (repeatable)`
|
|
17172
15325
|
})
|
|
17173
15326
|
),
|
|
17174
15327
|
[]
|
|
17175
15328
|
),
|
|
17176
15329
|
body: optional(
|
|
17177
|
-
|
|
15330
|
+
option("--body", string({ metavar: "DATA" }), {
|
|
17178
15331
|
description: message`Request body (prefix with @ to read from file)`
|
|
17179
15332
|
})
|
|
17180
15333
|
)
|
|
@@ -17306,7 +15459,7 @@ var accountExport = {
|
|
|
17306
15459
|
const accountInfo = yield* accounts2.get(accountName);
|
|
17307
15460
|
const pwd = accountInfo.encrypted ? yield* prompt.password() : null;
|
|
17308
15461
|
const { seed, entry } = yield* accounts2.export(accountName, pwd);
|
|
17309
|
-
const privateKeyHex =
|
|
15462
|
+
const privateKeyHex = toHex2(seed);
|
|
17310
15463
|
yield* output.humanLine(`\u26A0 Private key for "${entry.name}":`);
|
|
17311
15464
|
yield* output.humanLine(privateKeyHex);
|
|
17312
15465
|
yield* output.ok({
|
|
@@ -17335,7 +15488,7 @@ var accountImport = {
|
|
|
17335
15488
|
);
|
|
17336
15489
|
}
|
|
17337
15490
|
const parseHexSeed = (hex) => Effect18.try({
|
|
17338
|
-
try: () =>
|
|
15491
|
+
try: () => fromHex2(hex),
|
|
17339
15492
|
catch: (e) => new InvalidUsageError({
|
|
17340
15493
|
message: `Invalid hex in private key: ${e instanceof Error ? e.message : String(e)}`
|
|
17341
15494
|
})
|
|
@@ -17453,13 +15606,13 @@ var accountSetDefault = {
|
|
|
17453
15606
|
};
|
|
17454
15607
|
|
|
17455
15608
|
// src/commands/info/balance.ts
|
|
17456
|
-
import { bech32m as
|
|
15609
|
+
import { bech32m as bech32m2 } from "bech32";
|
|
17457
15610
|
import { Effect as Effect21 } from "effect";
|
|
17458
15611
|
var fromFastAddress2 = (address) => {
|
|
17459
|
-
const { prefix, words } =
|
|
15612
|
+
const { prefix, words } = bech32m2.decode(address);
|
|
17460
15613
|
if (prefix !== "fast")
|
|
17461
15614
|
throw new Error(`Expected "fast" prefix, got "${prefix}"`);
|
|
17462
|
-
return new Uint8Array(
|
|
15615
|
+
return new Uint8Array(bech32m2.fromWords(words));
|
|
17463
15616
|
};
|
|
17464
15617
|
var bytesToHex4 = (bytes) => Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
17465
15618
|
var formatAmount = (amount, decimals) => {
|
|
@@ -17531,12 +15684,12 @@ var infoBalance = {
|
|
|
17531
15684
|
const rows = [
|
|
17532
15685
|
{ network: "Fast", balance: formatAmount(fastRaw, decimals) }
|
|
17533
15686
|
];
|
|
17534
|
-
for (const
|
|
15687
|
+
for (const chain of token.chains) {
|
|
17535
15688
|
const evmRaw = yield* Effect21.promise(
|
|
17536
|
-
() => getEvmErc20Balance(
|
|
15689
|
+
() => getEvmErc20Balance(chain.evmRpcUrl, chain.evmAddress, evmAddress).catch(() => null)
|
|
17537
15690
|
);
|
|
17538
15691
|
rows.push({
|
|
17539
|
-
network:
|
|
15692
|
+
network: chain.chainName,
|
|
17540
15693
|
balance: evmRaw !== null ? formatAmount(evmRaw, decimals) : "-"
|
|
17541
15694
|
});
|
|
17542
15695
|
}
|
|
@@ -17780,13 +15933,13 @@ var infoStatus = {
|
|
|
17780
15933
|
const defaultLabel = isDefault ? " (default)" : "";
|
|
17781
15934
|
yield* output.humanLine(`Network: ${config.network}${defaultLabel}`);
|
|
17782
15935
|
yield* output.humanLine(
|
|
17783
|
-
` Fast RPC: ${network2.
|
|
15936
|
+
` Fast RPC: ${network2.url} ${healthy ? "\u2713 healthy" : "\u2717 unreachable"}`
|
|
17784
15937
|
);
|
|
17785
15938
|
yield* output.humanLine(` Explorer: ${network2.explorerUrl}`);
|
|
17786
15939
|
yield* output.ok({
|
|
17787
15940
|
network: config.network,
|
|
17788
15941
|
fast: {
|
|
17789
|
-
|
|
15942
|
+
url: network2.url,
|
|
17790
15943
|
explorerUrl: network2.explorerUrl,
|
|
17791
15944
|
healthy
|
|
17792
15945
|
}
|
|
@@ -17898,22 +16051,22 @@ var makeHistoryEntry = (fields) => ({
|
|
|
17898
16051
|
});
|
|
17899
16052
|
|
|
17900
16053
|
// src/services/token-resolver.ts
|
|
17901
|
-
function resolveToken(tokenName, networkConfig,
|
|
16054
|
+
function resolveToken(tokenName, networkConfig, chain) {
|
|
17902
16055
|
const allset = networkConfig.allSet;
|
|
17903
16056
|
if (!allset) {
|
|
17904
16057
|
throw new TokenNotFoundError({ token: tokenName });
|
|
17905
16058
|
}
|
|
17906
|
-
if (
|
|
17907
|
-
const chainConfig2 = allset.chains[
|
|
16059
|
+
if (chain) {
|
|
16060
|
+
const chainConfig2 = allset.chains[chain];
|
|
17908
16061
|
if (!chainConfig2) {
|
|
17909
|
-
throw new UnsupportedChainError({ chain
|
|
16062
|
+
throw new UnsupportedChainError({ chain });
|
|
17910
16063
|
}
|
|
17911
16064
|
const token = chainConfig2.tokens[tokenName];
|
|
17912
16065
|
if (!token) {
|
|
17913
16066
|
throw new TokenNotFoundError({ token: tokenName });
|
|
17914
16067
|
}
|
|
17915
16068
|
return {
|
|
17916
|
-
fastTokenId:
|
|
16069
|
+
fastTokenId: fromHex2(token.fastTokenId),
|
|
17917
16070
|
decimals: token.decimals,
|
|
17918
16071
|
evmAddress: token.evmAddress
|
|
17919
16072
|
};
|
|
@@ -17922,7 +16075,7 @@ function resolveToken(tokenName, networkConfig, chain2) {
|
|
|
17922
16075
|
const token = chainConfig2.tokens[tokenName];
|
|
17923
16076
|
if (token) {
|
|
17924
16077
|
return {
|
|
17925
|
-
fastTokenId:
|
|
16078
|
+
fastTokenId: fromHex2(token.fastTokenId),
|
|
17926
16079
|
decimals: token.decimals
|
|
17927
16080
|
};
|
|
17928
16081
|
}
|
|
@@ -18051,7 +16204,7 @@ var fundCrypto = {
|
|
|
18051
16204
|
});
|
|
18052
16205
|
const smartResult = yield* Effect31.tryPromise({
|
|
18053
16206
|
try: () => smartDeposit({
|
|
18054
|
-
privateKey:
|
|
16207
|
+
privateKey: toHex2(seed),
|
|
18055
16208
|
rpcUrl: chainCfg.evmRpcUrl,
|
|
18056
16209
|
allsetApiUrl: network2.allSet.portalApiUrl,
|
|
18057
16210
|
tokenAddress: tokenInfo.evmAddress,
|
|
@@ -18076,7 +16229,7 @@ var fundCrypto = {
|
|
|
18076
16229
|
amount: amountRaw.toString(),
|
|
18077
16230
|
formatted: args.amount,
|
|
18078
16231
|
tokenName,
|
|
18079
|
-
tokenId:
|
|
16232
|
+
tokenId: toHex2(tokenInfo.fastTokenId),
|
|
18080
16233
|
network: config.network,
|
|
18081
16234
|
status: "pending",
|
|
18082
16235
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -18104,7 +16257,7 @@ var fundCrypto = {
|
|
|
18104
16257
|
});
|
|
18105
16258
|
return;
|
|
18106
16259
|
}
|
|
18107
|
-
const evmAccount = bridge.createWallet(
|
|
16260
|
+
const evmAccount = bridge.createWallet(toHex2(seed));
|
|
18108
16261
|
const evmClients = bridge.createExecutor(
|
|
18109
16262
|
evmAccount,
|
|
18110
16263
|
chainCfg.evmRpcUrl,
|
|
@@ -18130,7 +16283,7 @@ var fundCrypto = {
|
|
|
18130
16283
|
amount: amountRaw.toString(),
|
|
18131
16284
|
formatted: args.amount,
|
|
18132
16285
|
tokenName,
|
|
18133
|
-
tokenId:
|
|
16286
|
+
tokenId: toHex2(tokenInfo.fastTokenId),
|
|
18134
16287
|
network: config.network,
|
|
18135
16288
|
status: "pending",
|
|
18136
16289
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -18285,32 +16438,32 @@ var pay2 = {
|
|
|
18285
16438
|
try: () => signer.getPublicKey(),
|
|
18286
16439
|
catch: () => new InvalidPaymentLinkError({ message: "Failed to derive public key" })
|
|
18287
16440
|
});
|
|
18288
|
-
const publicKey =
|
|
16441
|
+
const publicKey = toHex2(publicKeyBytes);
|
|
18289
16442
|
const fastAddress = yield* Effect33.tryPromise({
|
|
18290
16443
|
try: () => signer.getFastAddress(),
|
|
18291
16444
|
catch: () => new InvalidPaymentLinkError({ message: "Failed to derive Fast address" })
|
|
18292
16445
|
});
|
|
18293
16446
|
const fastWallet = {
|
|
18294
16447
|
type: "fast",
|
|
18295
|
-
privateKey:
|
|
16448
|
+
privateKey: toHex2(seed),
|
|
18296
16449
|
publicKey,
|
|
18297
16450
|
address: fastAddress,
|
|
18298
|
-
rpcUrl: network2.
|
|
16451
|
+
rpcUrl: network2.url
|
|
18299
16452
|
};
|
|
18300
16453
|
const evmWallet = {
|
|
18301
16454
|
type: "evm",
|
|
18302
|
-
privateKey:
|
|
16455
|
+
privateKey: toHex2(seed),
|
|
18303
16456
|
address: accountInfo.evmAddress
|
|
18304
16457
|
};
|
|
18305
16458
|
const evmNetworks = {};
|
|
18306
16459
|
const allset = network2.allSet;
|
|
18307
16460
|
if (allset) {
|
|
18308
|
-
for (const [name,
|
|
18309
|
-
const usdcToken =
|
|
16461
|
+
for (const [name, chain] of Object.entries(allset.chains)) {
|
|
16462
|
+
const usdcToken = chain.tokens.USDC ?? chain.tokens.testUSDC;
|
|
18310
16463
|
if (usdcToken?.evmAddress) {
|
|
18311
16464
|
evmNetworks[name] = {
|
|
18312
|
-
chainId:
|
|
18313
|
-
rpcUrl:
|
|
16465
|
+
chainId: chain.chainId,
|
|
16466
|
+
rpcUrl: chain.evmRpcUrl,
|
|
18314
16467
|
usdcAddress: usdcToken.evmAddress
|
|
18315
16468
|
};
|
|
18316
16469
|
}
|
|
@@ -18330,31 +16483,31 @@ var pay2 = {
|
|
|
18330
16483
|
);
|
|
18331
16484
|
}
|
|
18332
16485
|
if (result2.payment) {
|
|
18333
|
-
const
|
|
16486
|
+
const p = result2.payment;
|
|
18334
16487
|
yield* historyStore.record(
|
|
18335
16488
|
makeHistoryEntry({
|
|
18336
|
-
hash:
|
|
16489
|
+
hash: p.txHash,
|
|
18337
16490
|
type: "transfer",
|
|
18338
16491
|
from: accountInfo.fastAddress,
|
|
18339
|
-
to:
|
|
18340
|
-
amount:
|
|
18341
|
-
formatted:
|
|
16492
|
+
to: p.recipient,
|
|
16493
|
+
amount: p.amount,
|
|
16494
|
+
formatted: p.amount,
|
|
18342
16495
|
tokenName: "USDC",
|
|
18343
16496
|
tokenId: "",
|
|
18344
|
-
network:
|
|
16497
|
+
network: p.network,
|
|
18345
16498
|
status: "confirmed",
|
|
18346
16499
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
18347
16500
|
explorerUrl: "",
|
|
18348
|
-
route:
|
|
16501
|
+
route: p.network.includes("fast") ? "fast" : "fast-to-evm"
|
|
18349
16502
|
})
|
|
18350
16503
|
);
|
|
18351
16504
|
}
|
|
18352
16505
|
if (result2.payment) {
|
|
18353
|
-
const
|
|
18354
|
-
yield* output.humanLine(`Payment successful (${
|
|
18355
|
-
yield* output.humanLine(` Amount: ${
|
|
18356
|
-
yield* output.humanLine(` Recipient: ${
|
|
18357
|
-
yield* output.humanLine(` Tx hash: ${
|
|
16506
|
+
const p = result2.payment;
|
|
16507
|
+
yield* output.humanLine(`Payment successful (${p.network})`);
|
|
16508
|
+
yield* output.humanLine(` Amount: ${p.amount}`);
|
|
16509
|
+
yield* output.humanLine(` Recipient: ${p.recipient}`);
|
|
16510
|
+
yield* output.humanLine(` Tx hash: ${p.txHash}`);
|
|
18358
16511
|
yield* output.humanLine("");
|
|
18359
16512
|
}
|
|
18360
16513
|
yield* output.ok({
|
|
@@ -18369,8 +16522,8 @@ var pay2 = {
|
|
|
18369
16522
|
};
|
|
18370
16523
|
|
|
18371
16524
|
// src/commands/send.ts
|
|
18372
|
-
import { bech32m as
|
|
18373
|
-
import { Effect as Effect34, Schema as
|
|
16525
|
+
import { bech32m as bech32m3 } from "bech32";
|
|
16526
|
+
import { Effect as Effect34, Schema as Schema7 } from "effect";
|
|
18374
16527
|
var send = {
|
|
18375
16528
|
cmd: "send",
|
|
18376
16529
|
handler: (args) => Effect34.gen(function* () {
|
|
@@ -18499,7 +16652,7 @@ var send = {
|
|
|
18499
16652
|
});
|
|
18500
16653
|
const smartResult = yield* Effect34.tryPromise({
|
|
18501
16654
|
try: () => smartDeposit({
|
|
18502
|
-
privateKey:
|
|
16655
|
+
privateKey: toHex2(seed),
|
|
18503
16656
|
rpcUrl: chainCfg.evmRpcUrl,
|
|
18504
16657
|
allsetApiUrl: allset.portalApiUrl,
|
|
18505
16658
|
tokenAddress: tokenInfo.evmAddress,
|
|
@@ -18520,7 +16673,7 @@ var send = {
|
|
|
18520
16673
|
txHash = smartResult.txHash;
|
|
18521
16674
|
evmExplorerUrl = chainCfg.evmExplorerUrl;
|
|
18522
16675
|
} else {
|
|
18523
|
-
const evmAccount = bridge.createWallet(
|
|
16676
|
+
const evmAccount = bridge.createWallet(toHex2(seed));
|
|
18524
16677
|
const evmClients = bridge.createExecutor(
|
|
18525
16678
|
evmAccount,
|
|
18526
16679
|
chainCfg.evmRpcUrl,
|
|
@@ -18553,13 +16706,13 @@ var send = {
|
|
|
18553
16706
|
);
|
|
18554
16707
|
}
|
|
18555
16708
|
const signer = new Signer(seed);
|
|
18556
|
-
const provider = new FastProvider(
|
|
16709
|
+
const provider = new FastProvider(network2);
|
|
18557
16710
|
const bridgeResult = yield* bridge.withdraw({
|
|
18558
16711
|
fastBridgeAddress: chainCfg.fastBridgeAddress,
|
|
18559
16712
|
relayerUrl: chainCfg.relayerUrl,
|
|
18560
16713
|
crossSignUrl: allset.crossSignUrl,
|
|
18561
16714
|
tokenEvmAddress: tokenInfo.evmAddress,
|
|
18562
|
-
tokenFastTokenId:
|
|
16715
|
+
tokenFastTokenId: toHex2(tokenInfo.fastTokenId).slice(2),
|
|
18563
16716
|
amount: amountRaw.toString(),
|
|
18564
16717
|
receiverEvmAddress: args.address,
|
|
18565
16718
|
signer,
|
|
@@ -18585,7 +16738,7 @@ var send = {
|
|
|
18585
16738
|
});
|
|
18586
16739
|
const nonce = accountInfoRpc?.nextNonce ?? 0n;
|
|
18587
16740
|
const recipientBytes = new Uint8Array(
|
|
18588
|
-
|
|
16741
|
+
bech32m3.fromWords(bech32m3.decode(args.address).words)
|
|
18589
16742
|
);
|
|
18590
16743
|
const builder = new TransactionBuilder({
|
|
18591
16744
|
networkId: network2.networkId,
|
|
@@ -18605,7 +16758,7 @@ var send = {
|
|
|
18605
16758
|
})
|
|
18606
16759
|
});
|
|
18607
16760
|
yield* rpc.submitTransaction(envelope);
|
|
18608
|
-
const bcsInput = yield*
|
|
16761
|
+
const bcsInput = yield* Schema7.encode(VersionedTransactionFromBcs)(
|
|
18609
16762
|
envelope.transaction
|
|
18610
16763
|
).pipe(
|
|
18611
16764
|
Effect34.mapError(
|
|
@@ -18633,7 +16786,7 @@ var send = {
|
|
|
18633
16786
|
amount: amountRaw.toString(),
|
|
18634
16787
|
formatted: args.amount,
|
|
18635
16788
|
tokenName: resolvedTokenName,
|
|
18636
|
-
tokenId:
|
|
16789
|
+
tokenId: toHex2(tokenInfo.fastTokenId),
|
|
18637
16790
|
network: config.network,
|
|
18638
16791
|
status: route === "fast" ? "confirmed" : "pending",
|
|
18639
16792
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -19001,9 +17154,9 @@ var resolveNetwork = async () => {
|
|
|
19001
17154
|
if (parsed.network) return parsed.network;
|
|
19002
17155
|
try {
|
|
19003
17156
|
const { Effect: Eff, ManagedRuntime, Layer: Layer7 } = await import("effect");
|
|
19004
|
-
const { NetworkConfigService: NetworkConfigService2 } = await import("./network-
|
|
17157
|
+
const { NetworkConfigService: NetworkConfigService2 } = await import("./network-GHRVPGMD.js");
|
|
19005
17158
|
const { DatabaseLive: DatabaseLive2 } = await import("./database-NXA7GQKE.js");
|
|
19006
|
-
const { AppConfigLive: AppConfigLive2 } = await import("./app-
|
|
17159
|
+
const { AppConfigLive: AppConfigLive2 } = await import("./app-ZXKQBKVM.js");
|
|
19007
17160
|
const layer = Layer7.provide(NetworkConfigService2.Default, Layer7.merge(DatabaseLive2, AppConfigLive2));
|
|
19008
17161
|
const runtime = ManagedRuntime.make(layer);
|
|
19009
17162
|
const name = await runtime.runPromise(
|
|
@@ -19066,9 +17219,6 @@ dispatch().catch((err2) => {
|
|
|
19066
17219
|
@noble/hashes/utils.js:
|
|
19067
17220
|
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
19068
17221
|
|
|
19069
|
-
@scure/base/index.js:
|
|
19070
|
-
(*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
19071
|
-
|
|
19072
17222
|
@noble/ed25519/index.js:
|
|
19073
17223
|
(*! noble-ed25519 - MIT License (c) 2019 Paul Miller (paulmillr.com) *)
|
|
19074
17224
|
|