@donezone/cli 0.1.46 → 0.1.49

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.
Binary file
package/dist/index.js CHANGED
@@ -34,6 +34,7 @@ var require_constants = __commonJS((exports, module) => {
34
34
  var path = __require("path");
35
35
  var WIN_SLASH = "\\\\/";
36
36
  var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
37
+ var DEFAULT_MAX_EXTGLOB_RECURSION = 0;
37
38
  var DOT_LITERAL = "\\.";
38
39
  var PLUS_LITERAL = "\\+";
39
40
  var QMARK_LITERAL = "\\?";
@@ -81,6 +82,7 @@ var require_constants = __commonJS((exports, module) => {
81
82
  END_ANCHOR: `(?:[${WIN_SLASH}]|\$)`
82
83
  };
83
84
  var POSIX_REGEX_SOURCE = {
85
+ __proto__: null,
84
86
  alnum: "a-zA-Z0-9",
85
87
  alpha: "a-zA-Z",
86
88
  ascii: "\\x00-\\x7F",
@@ -97,6 +99,7 @@ var require_constants = __commonJS((exports, module) => {
97
99
  xdigit: "A-Fa-f0-9"
98
100
  };
99
101
  module.exports = {
102
+ DEFAULT_MAX_EXTGLOB_RECURSION,
100
103
  MAX_LENGTH: 1024 * 64,
101
104
  POSIX_REGEX_SOURCE,
102
105
  REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
@@ -106,6 +109,7 @@ var require_constants = __commonJS((exports, module) => {
106
109
  REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
107
110
  REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
108
111
  REPLACEMENTS: {
112
+ __proto__: null,
109
113
  "***": "*",
110
114
  "**/**": "**",
111
115
  "**/**/**": "**"
@@ -571,6 +575,213 @@ var require_parse = __commonJS((exports, module) => {
571
575
  var syntaxError = (type, char) => {
572
576
  return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
573
577
  };
578
+ var splitTopLevel = (input) => {
579
+ const parts = [];
580
+ let bracket = 0;
581
+ let paren = 0;
582
+ let quote = 0;
583
+ let value = "";
584
+ let escaped = false;
585
+ for (const ch of input) {
586
+ if (escaped === true) {
587
+ value += ch;
588
+ escaped = false;
589
+ continue;
590
+ }
591
+ if (ch === "\\") {
592
+ value += ch;
593
+ escaped = true;
594
+ continue;
595
+ }
596
+ if (ch === '"') {
597
+ quote = quote === 1 ? 0 : 1;
598
+ value += ch;
599
+ continue;
600
+ }
601
+ if (quote === 0) {
602
+ if (ch === "[") {
603
+ bracket++;
604
+ } else if (ch === "]" && bracket > 0) {
605
+ bracket--;
606
+ } else if (bracket === 0) {
607
+ if (ch === "(") {
608
+ paren++;
609
+ } else if (ch === ")" && paren > 0) {
610
+ paren--;
611
+ } else if (ch === "|" && paren === 0) {
612
+ parts.push(value);
613
+ value = "";
614
+ continue;
615
+ }
616
+ }
617
+ }
618
+ value += ch;
619
+ }
620
+ parts.push(value);
621
+ return parts;
622
+ };
623
+ var isPlainBranch = (branch) => {
624
+ let escaped = false;
625
+ for (const ch of branch) {
626
+ if (escaped === true) {
627
+ escaped = false;
628
+ continue;
629
+ }
630
+ if (ch === "\\") {
631
+ escaped = true;
632
+ continue;
633
+ }
634
+ if (/[?*+@!()[\]{}]/.test(ch)) {
635
+ return false;
636
+ }
637
+ }
638
+ return true;
639
+ };
640
+ var normalizeSimpleBranch = (branch) => {
641
+ let value = branch.trim();
642
+ let changed = true;
643
+ while (changed === true) {
644
+ changed = false;
645
+ if (/^@\([^\\()[\]{}|]+\)$/.test(value)) {
646
+ value = value.slice(2, -1);
647
+ changed = true;
648
+ }
649
+ }
650
+ if (!isPlainBranch(value)) {
651
+ return;
652
+ }
653
+ return value.replace(/\\(.)/g, "$1");
654
+ };
655
+ var hasRepeatedCharPrefixOverlap = (branches) => {
656
+ const values = branches.map(normalizeSimpleBranch).filter(Boolean);
657
+ for (let i = 0;i < values.length; i++) {
658
+ for (let j = i + 1;j < values.length; j++) {
659
+ const a = values[i];
660
+ const b = values[j];
661
+ const char = a[0];
662
+ if (!char || a !== char.repeat(a.length) || b !== char.repeat(b.length)) {
663
+ continue;
664
+ }
665
+ if (a === b || a.startsWith(b) || b.startsWith(a)) {
666
+ return true;
667
+ }
668
+ }
669
+ }
670
+ return false;
671
+ };
672
+ var parseRepeatedExtglob = (pattern, requireEnd = true) => {
673
+ if (pattern[0] !== "+" && pattern[0] !== "*" || pattern[1] !== "(") {
674
+ return;
675
+ }
676
+ let bracket = 0;
677
+ let paren = 0;
678
+ let quote = 0;
679
+ let escaped = false;
680
+ for (let i = 1;i < pattern.length; i++) {
681
+ const ch = pattern[i];
682
+ if (escaped === true) {
683
+ escaped = false;
684
+ continue;
685
+ }
686
+ if (ch === "\\") {
687
+ escaped = true;
688
+ continue;
689
+ }
690
+ if (ch === '"') {
691
+ quote = quote === 1 ? 0 : 1;
692
+ continue;
693
+ }
694
+ if (quote === 1) {
695
+ continue;
696
+ }
697
+ if (ch === "[") {
698
+ bracket++;
699
+ continue;
700
+ }
701
+ if (ch === "]" && bracket > 0) {
702
+ bracket--;
703
+ continue;
704
+ }
705
+ if (bracket > 0) {
706
+ continue;
707
+ }
708
+ if (ch === "(") {
709
+ paren++;
710
+ continue;
711
+ }
712
+ if (ch === ")") {
713
+ paren--;
714
+ if (paren === 0) {
715
+ if (requireEnd === true && i !== pattern.length - 1) {
716
+ return;
717
+ }
718
+ return {
719
+ type: pattern[0],
720
+ body: pattern.slice(2, i),
721
+ end: i
722
+ };
723
+ }
724
+ }
725
+ }
726
+ };
727
+ var getStarExtglobSequenceOutput = (pattern) => {
728
+ let index = 0;
729
+ const chars = [];
730
+ while (index < pattern.length) {
731
+ const match = parseRepeatedExtglob(pattern.slice(index), false);
732
+ if (!match || match.type !== "*") {
733
+ return;
734
+ }
735
+ const branches = splitTopLevel(match.body).map((branch2) => branch2.trim());
736
+ if (branches.length !== 1) {
737
+ return;
738
+ }
739
+ const branch = normalizeSimpleBranch(branches[0]);
740
+ if (!branch || branch.length !== 1) {
741
+ return;
742
+ }
743
+ chars.push(branch);
744
+ index += match.end + 1;
745
+ }
746
+ if (chars.length < 1) {
747
+ return;
748
+ }
749
+ const source = chars.length === 1 ? utils.escapeRegex(chars[0]) : `[${chars.map((ch) => utils.escapeRegex(ch)).join("")}]`;
750
+ return `${source}*`;
751
+ };
752
+ var repeatedExtglobRecursion = (pattern) => {
753
+ let depth = 0;
754
+ let value = pattern.trim();
755
+ let match = parseRepeatedExtglob(value);
756
+ while (match) {
757
+ depth++;
758
+ value = match.body.trim();
759
+ match = parseRepeatedExtglob(value);
760
+ }
761
+ return depth;
762
+ };
763
+ var analyzeRepeatedExtglob = (body, options) => {
764
+ if (options.maxExtglobRecursion === false) {
765
+ return { risky: false };
766
+ }
767
+ const max = typeof options.maxExtglobRecursion === "number" ? options.maxExtglobRecursion : constants.DEFAULT_MAX_EXTGLOB_RECURSION;
768
+ const branches = splitTopLevel(body).map((branch) => branch.trim());
769
+ if (branches.length > 1) {
770
+ if (branches.some((branch) => branch === "") || branches.some((branch) => /^[*?]+$/.test(branch)) || hasRepeatedCharPrefixOverlap(branches)) {
771
+ return { risky: true };
772
+ }
773
+ }
774
+ for (const branch of branches) {
775
+ const safeOutput = getStarExtglobSequenceOutput(branch);
776
+ if (safeOutput) {
777
+ return { risky: true, safeOutput };
778
+ }
779
+ if (repeatedExtglobRecursion(branch) > max) {
780
+ return { risky: true };
781
+ }
782
+ }
783
+ return { risky: false };
784
+ };
574
785
  var parse = (input, options) => {
575
786
  if (typeof input !== "string") {
576
787
  throw new TypeError("Expected a string");
@@ -703,6 +914,8 @@ var require_parse = __commonJS((exports, module) => {
703
914
  token.prev = prev;
704
915
  token.parens = state.parens;
705
916
  token.output = state.output;
917
+ token.startIndex = state.index;
918
+ token.tokensIndex = tokens.length;
706
919
  const output = (opts.capture ? "(" : "") + token.open;
707
920
  increment("parens");
708
921
  push({ type, value: value2, output: state.output ? "" : ONE_CHAR });
@@ -710,6 +923,26 @@ var require_parse = __commonJS((exports, module) => {
710
923
  extglobs.push(token);
711
924
  };
712
925
  const extglobClose = (token) => {
926
+ const literal = input.slice(token.startIndex, state.index + 1);
927
+ const body = input.slice(token.startIndex + 2, state.index);
928
+ const analysis = analyzeRepeatedExtglob(body, opts);
929
+ if ((token.type === "plus" || token.type === "star") && analysis.risky) {
930
+ const safeOutput = analysis.safeOutput ? (token.output ? "" : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput) : undefined;
931
+ const open = tokens[token.tokensIndex];
932
+ open.type = "text";
933
+ open.value = literal;
934
+ open.output = safeOutput || utils.escapeRegex(literal);
935
+ for (let i = token.tokensIndex + 1;i < tokens.length; i++) {
936
+ tokens[i].value = "";
937
+ tokens[i].output = "";
938
+ delete tokens[i].suffix;
939
+ }
940
+ state.output = token.output + open.output;
941
+ state.backtrack = true;
942
+ push({ type: "paren", extglob: true, value, output: "" });
943
+ decrement("parens");
944
+ return;
945
+ }
713
946
  let output = token.close + (opts.capture ? ")" : "");
714
947
  let rest;
715
948
  if (token.type === "negate") {
@@ -21452,6 +21685,452 @@ var require_dist2 = __commonJS((exports) => {
21452
21685
  global.eddsa = () => global._eddsa || (global._eddsa = new elliptic_1.eddsa("ed25519"));
21453
21686
  });
21454
21687
 
21688
+ // ../done-local-chain/node_modules/@cosmjs/encoding/build/ascii.js
21689
+ var require_ascii2 = __commonJS((exports) => {
21690
+ function toAscii(input) {
21691
+ const toNums = (str) => str.split("").map((x) => {
21692
+ const charCode = x.charCodeAt(0);
21693
+ if (charCode < 32 || charCode > 126) {
21694
+ throw new Error("Cannot encode character that is out of printable ASCII range: " + charCode);
21695
+ }
21696
+ return charCode;
21697
+ });
21698
+ return Uint8Array.from(toNums(input));
21699
+ }
21700
+ function fromAscii(data) {
21701
+ const fromNums = (listOfNumbers) => listOfNumbers.map((x) => {
21702
+ if (x < 32 || x > 126) {
21703
+ throw new Error("Cannot decode character that is out of printable ASCII range: " + x);
21704
+ }
21705
+ return String.fromCharCode(x);
21706
+ });
21707
+ return fromNums(Array.from(data)).join("");
21708
+ }
21709
+ Object.defineProperty(exports, "__esModule", { value: true });
21710
+ exports.fromAscii = exports.toAscii = undefined;
21711
+ exports.toAscii = toAscii;
21712
+ exports.fromAscii = fromAscii;
21713
+ });
21714
+
21715
+ // ../done-local-chain/node_modules/@cosmjs/encoding/build/base64.js
21716
+ var require_base642 = __commonJS((exports) => {
21717
+ function toBase64(data) {
21718
+ return base64js.fromByteArray(data);
21719
+ }
21720
+ function fromBase64(base64String) {
21721
+ if (!base64String.match(/^[a-zA-Z0-9+/]*={0,2}$/)) {
21722
+ throw new Error("Invalid base64 string format");
21723
+ }
21724
+ return base64js.toByteArray(base64String);
21725
+ }
21726
+ var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
21727
+ if (k2 === undefined)
21728
+ k2 = k;
21729
+ var desc = Object.getOwnPropertyDescriptor(m, k);
21730
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21731
+ desc = { enumerable: true, get: function() {
21732
+ return m[k];
21733
+ } };
21734
+ }
21735
+ Object.defineProperty(o, k2, desc);
21736
+ } : function(o, m, k, k2) {
21737
+ if (k2 === undefined)
21738
+ k2 = k;
21739
+ o[k2] = m[k];
21740
+ });
21741
+ var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
21742
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
21743
+ } : function(o, v) {
21744
+ o["default"] = v;
21745
+ });
21746
+ var __importStar = exports && exports.__importStar || function(mod) {
21747
+ if (mod && mod.__esModule)
21748
+ return mod;
21749
+ var result = {};
21750
+ if (mod != null) {
21751
+ for (var k in mod)
21752
+ if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
21753
+ __createBinding(result, mod, k);
21754
+ }
21755
+ __setModuleDefault(result, mod);
21756
+ return result;
21757
+ };
21758
+ Object.defineProperty(exports, "__esModule", { value: true });
21759
+ exports.fromBase64 = exports.toBase64 = undefined;
21760
+ var base64js = __importStar(require_base64_js());
21761
+ exports.toBase64 = toBase64;
21762
+ exports.fromBase64 = fromBase64;
21763
+ });
21764
+
21765
+ // ../done-local-chain/node_modules/@cosmjs/encoding/node_modules/bech32/index.js
21766
+ var require_bech323 = __commonJS((exports, module) => {
21767
+ function polymodStep(pre) {
21768
+ var b = pre >> 25;
21769
+ return (pre & 33554431) << 5 ^ -(b >> 0 & 1) & 996825010 ^ -(b >> 1 & 1) & 642813549 ^ -(b >> 2 & 1) & 513874426 ^ -(b >> 3 & 1) & 1027748829 ^ -(b >> 4 & 1) & 705979059;
21770
+ }
21771
+ function prefixChk(prefix) {
21772
+ var chk = 1;
21773
+ for (var i = 0;i < prefix.length; ++i) {
21774
+ var c = prefix.charCodeAt(i);
21775
+ if (c < 33 || c > 126)
21776
+ return "Invalid prefix (" + prefix + ")";
21777
+ chk = polymodStep(chk) ^ c >> 5;
21778
+ }
21779
+ chk = polymodStep(chk);
21780
+ for (i = 0;i < prefix.length; ++i) {
21781
+ var v = prefix.charCodeAt(i);
21782
+ chk = polymodStep(chk) ^ v & 31;
21783
+ }
21784
+ return chk;
21785
+ }
21786
+ function encode(prefix, words, LIMIT) {
21787
+ LIMIT = LIMIT || 90;
21788
+ if (prefix.length + 7 + words.length > LIMIT)
21789
+ throw new TypeError("Exceeds length limit");
21790
+ prefix = prefix.toLowerCase();
21791
+ var chk = prefixChk(prefix);
21792
+ if (typeof chk === "string")
21793
+ throw new Error(chk);
21794
+ var result = prefix + "1";
21795
+ for (var i = 0;i < words.length; ++i) {
21796
+ var x2 = words[i];
21797
+ if (x2 >> 5 !== 0)
21798
+ throw new Error("Non 5-bit word");
21799
+ chk = polymodStep(chk) ^ x2;
21800
+ result += ALPHABET.charAt(x2);
21801
+ }
21802
+ for (i = 0;i < 6; ++i) {
21803
+ chk = polymodStep(chk);
21804
+ }
21805
+ chk ^= 1;
21806
+ for (i = 0;i < 6; ++i) {
21807
+ var v = chk >> (5 - i) * 5 & 31;
21808
+ result += ALPHABET.charAt(v);
21809
+ }
21810
+ return result;
21811
+ }
21812
+ function __decode(str, LIMIT) {
21813
+ LIMIT = LIMIT || 90;
21814
+ if (str.length < 8)
21815
+ return str + " too short";
21816
+ if (str.length > LIMIT)
21817
+ return "Exceeds length limit";
21818
+ var lowered = str.toLowerCase();
21819
+ var uppered = str.toUpperCase();
21820
+ if (str !== lowered && str !== uppered)
21821
+ return "Mixed-case string " + str;
21822
+ str = lowered;
21823
+ var split = str.lastIndexOf("1");
21824
+ if (split === -1)
21825
+ return "No separator character for " + str;
21826
+ if (split === 0)
21827
+ return "Missing prefix for " + str;
21828
+ var prefix = str.slice(0, split);
21829
+ var wordChars = str.slice(split + 1);
21830
+ if (wordChars.length < 6)
21831
+ return "Data too short";
21832
+ var chk = prefixChk(prefix);
21833
+ if (typeof chk === "string")
21834
+ return chk;
21835
+ var words = [];
21836
+ for (var i = 0;i < wordChars.length; ++i) {
21837
+ var c = wordChars.charAt(i);
21838
+ var v = ALPHABET_MAP[c];
21839
+ if (v === undefined)
21840
+ return "Unknown character " + c;
21841
+ chk = polymodStep(chk) ^ v;
21842
+ if (i + 6 >= wordChars.length)
21843
+ continue;
21844
+ words.push(v);
21845
+ }
21846
+ if (chk !== 1)
21847
+ return "Invalid checksum for " + str;
21848
+ return { prefix, words };
21849
+ }
21850
+ function decodeUnsafe() {
21851
+ var res = __decode.apply(null, arguments);
21852
+ if (typeof res === "object")
21853
+ return res;
21854
+ }
21855
+ function decode(str) {
21856
+ var res = __decode.apply(null, arguments);
21857
+ if (typeof res === "object")
21858
+ return res;
21859
+ throw new Error(res);
21860
+ }
21861
+ function convert(data, inBits, outBits, pad) {
21862
+ var value = 0;
21863
+ var bits = 0;
21864
+ var maxV = (1 << outBits) - 1;
21865
+ var result = [];
21866
+ for (var i = 0;i < data.length; ++i) {
21867
+ value = value << inBits | data[i];
21868
+ bits += inBits;
21869
+ while (bits >= outBits) {
21870
+ bits -= outBits;
21871
+ result.push(value >> bits & maxV);
21872
+ }
21873
+ }
21874
+ if (pad) {
21875
+ if (bits > 0) {
21876
+ result.push(value << outBits - bits & maxV);
21877
+ }
21878
+ } else {
21879
+ if (bits >= inBits)
21880
+ return "Excess padding";
21881
+ if (value << outBits - bits & maxV)
21882
+ return "Non-zero padding";
21883
+ }
21884
+ return result;
21885
+ }
21886
+ function toWordsUnsafe(bytes2) {
21887
+ var res = convert(bytes2, 8, 5, true);
21888
+ if (Array.isArray(res))
21889
+ return res;
21890
+ }
21891
+ function toWords(bytes2) {
21892
+ var res = convert(bytes2, 8, 5, true);
21893
+ if (Array.isArray(res))
21894
+ return res;
21895
+ throw new Error(res);
21896
+ }
21897
+ function fromWordsUnsafe(words) {
21898
+ var res = convert(words, 5, 8, false);
21899
+ if (Array.isArray(res))
21900
+ return res;
21901
+ }
21902
+ function fromWords(words) {
21903
+ var res = convert(words, 5, 8, false);
21904
+ if (Array.isArray(res))
21905
+ return res;
21906
+ throw new Error(res);
21907
+ }
21908
+ var ALPHABET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";
21909
+ var ALPHABET_MAP = {};
21910
+ for (z = 0;z < ALPHABET.length; z++) {
21911
+ x = ALPHABET.charAt(z);
21912
+ if (ALPHABET_MAP[x] !== undefined)
21913
+ throw new TypeError(x + " is ambiguous");
21914
+ ALPHABET_MAP[x] = z;
21915
+ }
21916
+ var x;
21917
+ var z;
21918
+ module.exports = {
21919
+ decodeUnsafe,
21920
+ decode,
21921
+ encode,
21922
+ toWordsUnsafe,
21923
+ toWords,
21924
+ fromWordsUnsafe,
21925
+ fromWords
21926
+ };
21927
+ });
21928
+
21929
+ // ../done-local-chain/node_modules/@cosmjs/encoding/build/bech32.js
21930
+ var require_bech324 = __commonJS((exports) => {
21931
+ function toBech32(prefix, data, limit) {
21932
+ const address = bech32.encode(prefix, bech32.toWords(data), limit);
21933
+ return address;
21934
+ }
21935
+ function fromBech32(address, limit = Infinity) {
21936
+ const decodedAddress = bech32.decode(address, limit);
21937
+ return {
21938
+ prefix: decodedAddress.prefix,
21939
+ data: new Uint8Array(bech32.fromWords(decodedAddress.words))
21940
+ };
21941
+ }
21942
+ function normalizeBech32(address) {
21943
+ const { prefix, data } = fromBech32(address);
21944
+ return toBech32(prefix, data);
21945
+ }
21946
+ var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
21947
+ if (k2 === undefined)
21948
+ k2 = k;
21949
+ var desc = Object.getOwnPropertyDescriptor(m, k);
21950
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21951
+ desc = { enumerable: true, get: function() {
21952
+ return m[k];
21953
+ } };
21954
+ }
21955
+ Object.defineProperty(o, k2, desc);
21956
+ } : function(o, m, k, k2) {
21957
+ if (k2 === undefined)
21958
+ k2 = k;
21959
+ o[k2] = m[k];
21960
+ });
21961
+ var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
21962
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
21963
+ } : function(o, v) {
21964
+ o["default"] = v;
21965
+ });
21966
+ var __importStar = exports && exports.__importStar || function(mod) {
21967
+ if (mod && mod.__esModule)
21968
+ return mod;
21969
+ var result = {};
21970
+ if (mod != null) {
21971
+ for (var k in mod)
21972
+ if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
21973
+ __createBinding(result, mod, k);
21974
+ }
21975
+ __setModuleDefault(result, mod);
21976
+ return result;
21977
+ };
21978
+ Object.defineProperty(exports, "__esModule", { value: true });
21979
+ exports.normalizeBech32 = exports.fromBech32 = exports.toBech32 = undefined;
21980
+ var bech32 = __importStar(require_bech323());
21981
+ exports.toBech32 = toBech32;
21982
+ exports.fromBech32 = fromBech32;
21983
+ exports.normalizeBech32 = normalizeBech32;
21984
+ });
21985
+
21986
+ // ../done-local-chain/node_modules/@cosmjs/encoding/build/hex.js
21987
+ var require_hex2 = __commonJS((exports) => {
21988
+ function toHex(data) {
21989
+ let out = "";
21990
+ for (const byte of data) {
21991
+ out += ("0" + byte.toString(16)).slice(-2);
21992
+ }
21993
+ return out;
21994
+ }
21995
+ function fromHex(hexstring) {
21996
+ if (hexstring.length % 2 !== 0) {
21997
+ throw new Error("hex string length must be a multiple of 2");
21998
+ }
21999
+ const out = new Uint8Array(hexstring.length / 2);
22000
+ for (let i = 0;i < out.length; i++) {
22001
+ const j = 2 * i;
22002
+ const hexByteAsString = hexstring.slice(j, j + 2);
22003
+ if (!hexByteAsString.match(/[0-9a-f]{2}/i)) {
22004
+ throw new Error("hex string contains invalid characters");
22005
+ }
22006
+ out[i] = parseInt(hexByteAsString, 16);
22007
+ }
22008
+ return out;
22009
+ }
22010
+ Object.defineProperty(exports, "__esModule", { value: true });
22011
+ exports.fromHex = exports.toHex = undefined;
22012
+ exports.toHex = toHex;
22013
+ exports.fromHex = fromHex;
22014
+ });
22015
+
22016
+ // ../done-local-chain/node_modules/@cosmjs/encoding/build/rfc3339.js
22017
+ var require_rfc33392 = __commonJS((exports) => {
22018
+ function padded(integer, length = 2) {
22019
+ return integer.toString().padStart(length, "0");
22020
+ }
22021
+ function fromRfc3339(str) {
22022
+ const matches = rfc3339Matcher.exec(str);
22023
+ if (!matches) {
22024
+ throw new Error("Date string is not in RFC3339 format");
22025
+ }
22026
+ const year = +matches[1];
22027
+ const month = +matches[2];
22028
+ const day = +matches[3];
22029
+ const hour = +matches[4];
22030
+ const minute = +matches[5];
22031
+ const second = +matches[6];
22032
+ const milliSeconds = matches[7] ? Math.floor(+matches[7] * 1000) : 0;
22033
+ let tzOffsetSign;
22034
+ let tzOffsetHours;
22035
+ let tzOffsetMinutes;
22036
+ if (matches[8] === "Z") {
22037
+ tzOffsetSign = 1;
22038
+ tzOffsetHours = 0;
22039
+ tzOffsetMinutes = 0;
22040
+ } else {
22041
+ tzOffsetSign = matches[8].substring(0, 1) === "-" ? -1 : 1;
22042
+ tzOffsetHours = +matches[8].substring(1, 3);
22043
+ tzOffsetMinutes = +matches[8].substring(4, 6);
22044
+ }
22045
+ const tzOffset = tzOffsetSign * (tzOffsetHours * 60 + tzOffsetMinutes) * 60;
22046
+ const date = new Date;
22047
+ date.setUTCFullYear(year, month - 1, day);
22048
+ date.setUTCHours(hour, minute, second, milliSeconds);
22049
+ return new Date(date.getTime() - tzOffset * 1000);
22050
+ }
22051
+ function toRfc3339(date) {
22052
+ const year = date.getUTCFullYear();
22053
+ const month = padded(date.getUTCMonth() + 1);
22054
+ const day = padded(date.getUTCDate());
22055
+ const hour = padded(date.getUTCHours());
22056
+ const minute = padded(date.getUTCMinutes());
22057
+ const second = padded(date.getUTCSeconds());
22058
+ const ms = padded(date.getUTCMilliseconds(), 3);
22059
+ return `${year}-${month}-${day}T${hour}:${minute}:${second}.${ms}Z`;
22060
+ }
22061
+ Object.defineProperty(exports, "__esModule", { value: true });
22062
+ exports.toRfc3339 = exports.fromRfc3339 = undefined;
22063
+ var rfc3339Matcher = /^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2}):(\d{2})(\.\d{1,9})?((?:[+-]\d{2}:\d{2})|Z)$/;
22064
+ exports.fromRfc3339 = fromRfc3339;
22065
+ exports.toRfc3339 = toRfc3339;
22066
+ });
22067
+
22068
+ // ../done-local-chain/node_modules/@cosmjs/encoding/build/utf8.js
22069
+ var require_utf82 = __commonJS((exports) => {
22070
+ function toUtf8(str) {
22071
+ return new TextEncoder().encode(str);
22072
+ }
22073
+ function fromUtf8(data, lossy = false) {
22074
+ const fatal = !lossy;
22075
+ return new TextDecoder("utf-8", { fatal }).decode(data);
22076
+ }
22077
+ Object.defineProperty(exports, "__esModule", { value: true });
22078
+ exports.fromUtf8 = exports.toUtf8 = undefined;
22079
+ exports.toUtf8 = toUtf8;
22080
+ exports.fromUtf8 = fromUtf8;
22081
+ });
22082
+
22083
+ // ../done-local-chain/node_modules/@cosmjs/encoding/build/index.js
22084
+ var require_build2 = __commonJS((exports) => {
22085
+ Object.defineProperty(exports, "__esModule", { value: true });
22086
+ exports.toUtf8 = exports.fromUtf8 = exports.toRfc3339 = exports.fromRfc3339 = exports.toHex = exports.fromHex = exports.toBech32 = exports.normalizeBech32 = exports.fromBech32 = exports.toBase64 = exports.fromBase64 = exports.toAscii = exports.fromAscii = undefined;
22087
+ var ascii_1 = require_ascii2();
22088
+ Object.defineProperty(exports, "fromAscii", { enumerable: true, get: function() {
22089
+ return ascii_1.fromAscii;
22090
+ } });
22091
+ Object.defineProperty(exports, "toAscii", { enumerable: true, get: function() {
22092
+ return ascii_1.toAscii;
22093
+ } });
22094
+ var base64_1 = require_base642();
22095
+ Object.defineProperty(exports, "fromBase64", { enumerable: true, get: function() {
22096
+ return base64_1.fromBase64;
22097
+ } });
22098
+ Object.defineProperty(exports, "toBase64", { enumerable: true, get: function() {
22099
+ return base64_1.toBase64;
22100
+ } });
22101
+ var bech32_1 = require_bech324();
22102
+ Object.defineProperty(exports, "fromBech32", { enumerable: true, get: function() {
22103
+ return bech32_1.fromBech32;
22104
+ } });
22105
+ Object.defineProperty(exports, "normalizeBech32", { enumerable: true, get: function() {
22106
+ return bech32_1.normalizeBech32;
22107
+ } });
22108
+ Object.defineProperty(exports, "toBech32", { enumerable: true, get: function() {
22109
+ return bech32_1.toBech32;
22110
+ } });
22111
+ var hex_1 = require_hex2();
22112
+ Object.defineProperty(exports, "fromHex", { enumerable: true, get: function() {
22113
+ return hex_1.fromHex;
22114
+ } });
22115
+ Object.defineProperty(exports, "toHex", { enumerable: true, get: function() {
22116
+ return hex_1.toHex;
22117
+ } });
22118
+ var rfc3339_1 = require_rfc33392();
22119
+ Object.defineProperty(exports, "fromRfc3339", { enumerable: true, get: function() {
22120
+ return rfc3339_1.fromRfc3339;
22121
+ } });
22122
+ Object.defineProperty(exports, "toRfc3339", { enumerable: true, get: function() {
22123
+ return rfc3339_1.toRfc3339;
22124
+ } });
22125
+ var utf8_1 = require_utf82();
22126
+ Object.defineProperty(exports, "fromUtf8", { enumerable: true, get: function() {
22127
+ return utf8_1.fromUtf8;
22128
+ } });
22129
+ Object.defineProperty(exports, "toUtf8", { enumerable: true, get: function() {
22130
+ return utf8_1.toUtf8;
22131
+ } });
22132
+ });
22133
+
21455
22134
  // ../../node_modules/fast-decode-uri-component/index.js
21456
22135
  var require_fast_decode_uri_component = __commonJS((exports, module) => {
21457
22136
  function decodeURIComponent2(uri) {
@@ -26835,6 +27514,7 @@ import { existsSync as existsSync2, readFileSync as readFileSync3 } from "node:f
26835
27514
  import * as fs2 from "node:fs/promises";
26836
27515
  import path from "node:path";
26837
27516
  import { TextDecoder as TextDecoder2 } from "node:util";
27517
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
26838
27518
 
26839
27519
  // ../../node_modules/commander/esm.mjs
26840
27520
  var import__ = __toESM(require_commander(), 1);
@@ -27911,6 +28591,7 @@ class DoneInstance {
27911
28591
  var Done = new DoneInstance;
27912
28592
  // ../done-local-chain/src/chain.ts
27913
28593
  var import_cosmwasm_vm_js = __toESM(require_dist2(), 1);
28594
+ var import_encoding = __toESM(require_build2(), 1);
27914
28595
  var import_backend = __toESM(require_backend(), 1);
27915
28596
  var import_bech32 = __toESM(require_dist(), 1);
27916
28597
 
@@ -28416,7 +29097,7 @@ class DoneLocalChain {
28416
29097
  buildEnv(address, override) {
28417
29098
  const block = {
28418
29099
  height: this.blockHeight,
28419
- time: this.blockTime.toString(),
29100
+ time: (BigInt(this.blockTime) * 1000000000n).toString(),
28420
29101
  chain_id: this.chainId
28421
29102
  };
28422
29103
  if (override?.block) {
@@ -28441,7 +29122,7 @@ class DoneLocalChain {
28441
29122
  const height = this.blockHeight;
28442
29123
  const blockTime = this.blockTime;
28443
29124
  try {
28444
- const region = record.vm[entrypoint](env, info, msg);
29125
+ const region = entrypoint === "query" ? record.vm[entrypoint](env, msg) : record.vm[entrypoint](env, info, msg);
28445
29126
  const json = region?.json ?? { err: "contract returned empty response" };
28446
29127
  this.emitContractEvent(record, entrypoint, env, info, json, height, blockTime);
28447
29128
  return json;
@@ -28489,6 +29170,23 @@ class DoneLocalChain {
28489
29170
  view.setUint32(28, this.nextAddressNonce++);
28490
29171
  return import_bech32.bech32.encode(this.bech32Prefix, import_bech32.bech32.toWords(data));
28491
29172
  }
29173
+ restoreStorage(address, entries) {
29174
+ const record = this.contracts.get(address);
29175
+ if (!record) {
29176
+ throw new Error(`contract ${address} not found`);
29177
+ }
29178
+ const storage = record.backend.storage;
29179
+ if (!(storage instanceof import_backend.BasicKVIterStorage)) {
29180
+ return;
29181
+ }
29182
+ for (const entry of entries) {
29183
+ if (!entry.key || !entry.value)
29184
+ continue;
29185
+ const keyBytes = import_encoding.fromBase64(entry.key);
29186
+ const valueBytes = import_encoding.fromBase64(entry.value);
29187
+ storage.set(keyBytes, valueBytes);
29188
+ }
29189
+ }
28492
29190
  }
28493
29191
  // ../done-local-chain/src/js-contract.ts
28494
29192
  import { readFileSync as readFileSync2 } from "node:fs";
@@ -43271,6 +43969,9 @@ function unwrapQueryResult(result) {
43271
43969
  if (result.err) {
43272
43970
  throw new Error(result.err);
43273
43971
  }
43972
+ if (typeof result.ok === "string") {
43973
+ return decodeData(result.ok);
43974
+ }
43274
43975
  if (result.ok?.data) {
43275
43976
  return decodeData(result.ok.data);
43276
43977
  }
@@ -43772,8 +44473,7 @@ interface SetGreetingBody {
43772
44473
 
43773
44474
  export default Done.serve()
43774
44475
  .instantiate(async () => {
43775
- const existing = await Greeting.load();
43776
- if (!existing) {
44476
+ if (!(await Greeting.exists())) {
43777
44477
  await Greeting.save("${defaultGreeting}");
43778
44478
  }
43779
44479
  })
@@ -43912,7 +44612,7 @@ function updateDependencyIfPresent(pkg, name, version) {
43912
44612
  }
43913
44613
  async function syncWorkspaceDependencyVersions(targetDir) {
43914
44614
  await updatePackageJson(path.join(targetDir, "package.json"), (pkg) => {
43915
- ensureDependency(pkg, "devDependencies", "@donezone/cli", CLI_VERSION_RANGE);
44615
+ ensureDependency(pkg, "devDependencies", "@donezone/cli", CLI_DEPENDENCY_SPEC);
43916
44616
  ensureDependency(pkg, "devDependencies", "done.zone", DONE_ZONE_VERSION_RANGE);
43917
44617
  });
43918
44618
  await updatePackageJson(path.join(targetDir, "frontend", "package.json"), (pkg) => {
@@ -44234,6 +44934,31 @@ async function readDevEnvFile(file2) {
44234
44934
  }
44235
44935
  return entries;
44236
44936
  }
44937
+ async function readStorageSnapshot(file2) {
44938
+ try {
44939
+ const raw = await fs2.readFile(file2, "utf8");
44940
+ return JSON.parse(raw);
44941
+ } catch (error) {
44942
+ if (error.code === "ENOENT") {
44943
+ return null;
44944
+ }
44945
+ throw error;
44946
+ }
44947
+ }
44948
+ function extractStorageEntries(snapshot) {
44949
+ if (!snapshot?.entries) {
44950
+ return [];
44951
+ }
44952
+ const entries = [];
44953
+ for (const entry of snapshot.entries) {
44954
+ const keyBase64 = entry.key?.base64;
44955
+ const valueBase64 = entry.value?.base64;
44956
+ if (!keyBase64 || !valueBase64)
44957
+ continue;
44958
+ entries.push({ key: keyBase64, value: valueBase64 });
44959
+ }
44960
+ return entries;
44961
+ }
44237
44962
  function toEnvVarKey(name) {
44238
44963
  return name.replace(/[^a-zA-Z0-9]+/g, "_").replace(/([a-z0-9])([A-Z])/g, "$1_$2").toUpperCase();
44239
44964
  }
@@ -44262,6 +44987,7 @@ function openBrowser(url) {
44262
44987
  var packageMetadata = readCliPackageMetadata();
44263
44988
  var CLI_VERSION = normalizeVersion(packageMetadata.version) ?? "0.0.0-spec";
44264
44989
  var CLI_VERSION_RANGE = toCaretRange(CLI_VERSION);
44990
+ var CLI_DEPENDENCY_SPEC = process.env.DONE_CLI_LOCAL_SPEC ?? CLI_VERSION_RANGE;
44265
44991
  var DONE_ZONE_VERSION = normalizeVersion(packageMetadata.doneZoneVersion) ?? CLI_VERSION;
44266
44992
  var DONE_ZONE_VERSION_RANGE = toCaretRange(DONE_ZONE_VERSION);
44267
44993
  var DONE_CLIENT_VERSION = normalizeVersion(packageMetadata.doneClientVersion) ?? CLI_VERSION;
@@ -44279,6 +45005,11 @@ if (typeof bunRuntime === "undefined") {
44279
45005
  process.exit(rerun.status ?? 1);
44280
45006
  }
44281
45007
  var DEFAULT_TEMPLATE_REPO = "https://github.com/mccallofthewild/done-template.git";
45008
+ var CLI_DIR = path.dirname(fileURLToPath2(import.meta.url));
45009
+ var CLI_ARTIFACTS_DIR = path.resolve(CLI_DIR, "..", "artifacts");
45010
+ if (!process.env.DONE_ARTIFACTS_DIR && existsSync2(CLI_ARTIFACTS_DIR)) {
45011
+ process.env.DONE_ARTIFACTS_DIR = CLI_ARTIFACTS_DIR;
45012
+ }
44282
45013
  var program2 = new Command;
44283
45014
  program2.name("done").description("Done developer toolkit (spec-first stub)").version(CLI_VERSION);
44284
45015
  program2.command("build").description("Bundle Done contracts defined in done.json").option("-j, --contracts <path>", "Path to done.json").option("-n, --name <name...>", "Filter contract names").action(async (options) => {
@@ -44480,9 +45211,13 @@ class DoneDevOrchestrator {
44480
45211
  if (deployment.result.err) {
44481
45212
  throw new Error(`Failed to deploy ${contract.name}: ${deployment.result.err}`);
44482
45213
  }
45214
+ const restored = await this.restoreStorageFromSnapshot(contract, deployment.address);
44483
45215
  contract.address = deployment.address;
44484
45216
  this.chain.advanceBlock();
44485
45217
  this.logInfo(`${import_picocolors.default.green("\u2022")} ${contract.name} deployed at ${deployment.address}`);
45218
+ if (restored) {
45219
+ this.logInfo(` ${import_picocolors.default.dim("\u21BA state")}: restored snapshot for ${contract.name}`);
45220
+ }
44486
45221
  await this.dumpContractStorage(contract);
44487
45222
  }
44488
45223
  }
@@ -44577,6 +45312,30 @@ class DoneDevOrchestrator {
44577
45312
  const filePath = path.join(storageDir, `${contract.slug}.json`);
44578
45313
  await writeJson(filePath, snapshot);
44579
45314
  }
45315
+ async restoreStorageFromSnapshot(contract, address) {
45316
+ if (!this.chain) {
45317
+ return false;
45318
+ }
45319
+ const filePath = this.resolveStorageSnapshotPath(contract);
45320
+ try {
45321
+ const snapshot = await readStorageSnapshot(filePath);
45322
+ const entries = extractStorageEntries(snapshot);
45323
+ if (entries.length === 0) {
45324
+ return false;
45325
+ }
45326
+ this.chain.restoreStorage(address, entries);
45327
+ return true;
45328
+ } catch (error) {
45329
+ if (error.code !== "ENOENT") {
45330
+ this.logWarn(`Unable to restore storage for ${contract.name}: ${error.message}`);
45331
+ }
45332
+ return false;
45333
+ }
45334
+ }
45335
+ resolveStorageSnapshotPath(contract) {
45336
+ const storageDir = path.join(this.options.workspace.root, ".done", "storage");
45337
+ return path.join(storageDir, `${contract.slug}.json`);
45338
+ }
44580
45339
  async launchFrontend() {
44581
45340
  const frontend = this.options.devConfig.frontend;
44582
45341
  if (!existsSync2(frontend.cwd)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@donezone/cli",
3
- "version": "0.1.46",
3
+ "version": "0.1.49",
4
4
  "doneZoneVersion": "0.1.41",
5
5
  "doneClientVersion": "0.1.41",
6
6
  "private": false,