@0xobelisk/sui-common 1.1.5 → 1.1.7
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/dist/index.d.ts +18 -8
- package/dist/index.js +54 -54
- package/dist/index.js.map +1 -1
- package/package.json +10 -4
- package/src/codegen/debug.ts +3 -3
- package/src/codegen/index.ts +2 -2
- package/src/codegen/modules.d.ts +1 -1
- package/src/codegen/types/index.ts +25 -17
- package/src/codegen/utils/config.ts +14 -24
- package/src/codegen/utils/errors.ts +3 -4
- package/src/codegen/utils/format.ts +29 -32
- package/src/codegen/utils/formatAndWrite.ts +22 -19
- package/src/codegen/utils/posixPath.ts +1 -1
- package/src/codegen/utils/renderMove/common.ts +33 -41
- package/src/codegen/utils/renderMove/generateDappKey.ts +12 -15
- package/src/codegen/utils/renderMove/generateDefaultSchema.ts +20 -36
- package/src/codegen/utils/renderMove/generateError.ts +30 -33
- package/src/codegen/utils/renderMove/generateEvent.ts +66 -77
- package/src/codegen/utils/renderMove/generateInit.ts +17 -22
- package/src/codegen/utils/renderMove/generateSchema.ts +160 -196
- package/src/codegen/utils/renderMove/generateSchemaHub.ts +12 -15
- package/src/codegen/utils/renderMove/generateScript.ts +20 -31
- package/src/codegen/utils/renderMove/generateSystem.ts +7 -13
- package/src/codegen/utils/renderMove/generateToml.ts +10 -15
- package/src/codegen/utils/renderMove/schemaGen.ts +39 -47
- package/src/debug.ts +3 -3
- package/src/index.ts +3 -2
- package/src/modules.d.ts +2 -2
- package/src/parseData/index.ts +1 -1
- package/src/parseData/parser/index.ts +42 -42
- package/src/primitives/index.ts +8 -0
package/dist/index.d.ts
CHANGED
|
@@ -32,12 +32,10 @@ type SchemaData = Record<string, string> | string[];
|
|
|
32
32
|
type SchemaType = string;
|
|
33
33
|
type EventData = Record<string, string>;
|
|
34
34
|
type ErrorData = Record<string, string>;
|
|
35
|
-
type
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
rev: string;
|
|
40
|
-
};
|
|
35
|
+
type DataType = any;
|
|
36
|
+
declare function storage<T extends DataType>(value: T): SchemaType;
|
|
37
|
+
declare function storage<K extends DataType, V extends DataType>(key: K, value: V): SchemaType;
|
|
38
|
+
declare function storage<K1 extends DataType, K2 extends DataType, V extends DataType>(key1: K1, key2: K2, value: V): SchemaType;
|
|
41
39
|
type DubheConfig = {
|
|
42
40
|
name: string;
|
|
43
41
|
description: string;
|
|
@@ -45,7 +43,6 @@ type DubheConfig = {
|
|
|
45
43
|
schemas: Record<string, SchemaType>;
|
|
46
44
|
events?: Record<string, EventData>;
|
|
47
45
|
errors?: ErrorData;
|
|
48
|
-
dependencies: DependencyType[];
|
|
49
46
|
};
|
|
50
47
|
type MoveType = 'string' | 'vector<string>' | 'String' | 'vector<String>' | 'address' | 'bool' | 'u8' | 'u32' | 'u64' | 'u128' | 'vector<address>' | 'vector<bool>' | 'vector<u8>' | 'vector<vector<u8>>' | 'vector<u32>' | 'vector<u64>' | 'vector<u128>';
|
|
51
48
|
|
|
@@ -56,4 +53,17 @@ declare function resolveConfigPath(configPath: string | undefined, toFileURL?: b
|
|
|
56
53
|
|
|
57
54
|
declare const parseData: (data: any) => any;
|
|
58
55
|
|
|
59
|
-
|
|
56
|
+
declare enum SubscriptionKind {
|
|
57
|
+
Event = "event",
|
|
58
|
+
Schema = "schema"
|
|
59
|
+
}
|
|
60
|
+
type SubscribableType = {
|
|
61
|
+
kind: SubscriptionKind.Event;
|
|
62
|
+
name?: string;
|
|
63
|
+
sender?: string;
|
|
64
|
+
} | {
|
|
65
|
+
kind: SubscriptionKind.Schema;
|
|
66
|
+
name?: string;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export { BaseType, BaseValueType, DubheConfig, ErrorData, EventData, MoveType, SchemaData, SchemaType, StorageDataType, StorageMapType, SubscribableType, SubscriptionKind, formatAndWriteMove, formatAndWriteTypescript, formatMove, formatTypescript, loadConfig, parseData, posixPath, resolveConfigPath, schemaGen, storage };
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import v from"prettier";import q from"prettier-plugin-move-js";async function T(e,t){let r;t&&(r=await v.resolveConfig(t));try{return v.format(e,{plugins:[q],parser:"move-parse",printWidth:120,semi:!0,tabWidth:2,useTabs:!1,bracketSpacing:!0,...r})}catch(a){let n;return a instanceof Error?n=a.message:n=a,console.log(`Error during output formatting: ${n}`),e}}async function V(e){return v.format(e,{parser:"typescript"})}import y from"node:fs/promises";import R from"node:path";import E from"debug";var b=E("dubhe:common"),J=E("dubhe:common");b.log=console.debug.bind(console);J.log=console.error.bind(console);var $=b.extend("codegen"),P=b.extend("codegen");$.log=console.debug.bind(console);P.log=console.error.bind(console);async function c(e,t,r){let a=await T(e),n=` // Copyright (c) Obelisk Labs, Inc.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
#[allow(unused_use)]
|
|
4
4
|
|
|
5
5
|
/* Autogenerated file. Do not edit manually. */
|
|
6
6
|
|
|
7
|
-
`,
|
|
7
|
+
`,o="#[test_only]",s=n+a,i="#[allow(lint(share_owned))]";t.includes(".toml")||t.includes("system")||t.includes("migrate")?s=a:t.includes("init")?s=o+a:t.includes("genesis")&&(s=i+a),await y.mkdir(R.dirname(t),{recursive:!0}),await y.writeFile(t,s),$(`${r}: ${t}`)}async function Te(e,t,r){let a=await V(e);await y.mkdir(R.dirname(t),{recursive:!0}),await y.writeFile(t,a),$(`${r}: ${t}`)}function Ee(e){return e.replace(/\\/g,"/")}import{existsSync as A}from"fs";import g from"fs";function x(e){g.existsSync(e)&&(g.readdirSync(e).forEach(t=>{let r=`${e}/${t}`;g.lstatSync(r).isDirectory()?x(r):g.unlinkSync(r)}),g.rmdirSync(e))}function f(e){return Object.entries(e).map(([t,r])=>`${t}`).join(",")}function U(e){return`(${Object.entries(e).map(([t,r])=>`${r}`)})`}function u(e){return Object.entries(e).map(([t,r])=>`${t}: ${r}`)}function O(e){return Object.entries(e).map(([t,r])=>`self.${t}`)}function W(e,t){for(let r in e)if(e.hasOwnProperty(r)){let a=e[r];if(typeof a=="string"&&a===t)return!0}return!1}async function G(e,t){console.log(`
|
|
8
8
|
\u{1F4C4} Starting Move.toml Generation...`),console.log(` \u2514\u2500 Output path: ${t}/contracts/${e.name}/Move.toml`);let r=`[package]
|
|
9
9
|
name = "${e.name}"
|
|
10
10
|
version = "1.0.0"
|
|
@@ -24,42 +24,42 @@ ${e.name} = "0x0"
|
|
|
24
24
|
`)}function te(e,t){return`public(package) fun set(self: &mut ${e}, ${u(t)}) {
|
|
25
25
|
${Object.entries(t).map(([r])=>`self.${r} = ${r};`).join(`
|
|
26
26
|
`)}
|
|
27
|
-
}`}function re(e,t){return`public fun get(self: &${e}): ${
|
|
28
|
-
(${
|
|
27
|
+
}`}function re(e,t){return`public fun get(self: &${e}): ${U(t)} {
|
|
28
|
+
(${O(t)})
|
|
29
29
|
}`}function ae(e,t){return Object.entries(t).map(([r,a])=>`public fun get_${r}(self: &${e}): ${a} {
|
|
30
30
|
self.${r}
|
|
31
31
|
}`).join(`
|
|
32
|
-
`)}function d(e){return e.replace(/([A-Z])/g,"_$1").toLowerCase().replace(/^_/,"")}async function
|
|
33
|
-
\u{1F4E6} Starting Schema Data Generation...`);for(let a of Object.keys(t)){let n=a,
|
|
32
|
+
`)}function d(e){return e.replace(/([A-Z])/g,"_$1").toLowerCase().replace(/^_/,"")}async function j(e,t,r){console.log(`
|
|
33
|
+
\u{1F4E6} Starting Schema Data Generation...`);for(let a of Object.keys(t)){let n=a,o=t[a];console.log(` \u2514\u2500 Generating ${n} ${Array.isArray(o)?"(enum)":"(struct)"}`);let s="",i=Object.keys(t).filter(p=>Array.isArray(t[p])).map(p=>p);if(console.log(i),Array.isArray(o)){let p=N(o);s=`module ${e}::${e}_${d(n)} {
|
|
34
34
|
public enum ${n} has copy, drop , store {
|
|
35
35
|
${p}
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
${p.map(
|
|
39
|
-
${n}::${
|
|
40
|
-
}`).join("")}`}else
|
|
38
|
+
${p.map(m=>`public fun new_${d(m)}(): ${n} {
|
|
39
|
+
${n}::${m}
|
|
40
|
+
}`).join("")}`}else s=`module ${e}::${e}_${d(n)} {
|
|
41
41
|
use std::ascii::String;
|
|
42
42
|
|
|
43
|
-
${Object.keys(t).map(p=>{if(
|
|
43
|
+
${Object.keys(t).map(p=>{if(W(o,p))return`use ${e}::${e}_${d(p)}::${p};`}).filter(Boolean).join(`
|
|
44
44
|
`)}
|
|
45
45
|
|
|
46
46
|
public struct ${n} has copy, drop , store {
|
|
47
|
-
${u(
|
|
47
|
+
${u(o)}
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
public fun new(${u(
|
|
50
|
+
public fun new(${u(o)}): ${n} {
|
|
51
51
|
${n} {
|
|
52
|
-
${f(
|
|
52
|
+
${f(o)}
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
${re(n,
|
|
57
|
-
${ae(n,
|
|
58
|
-
${ee(n,
|
|
59
|
-
${te(n,
|
|
60
|
-
}`;await c(
|
|
61
|
-
`)}function
|
|
62
|
-
`):""}async function
|
|
56
|
+
${re(n,o)}
|
|
57
|
+
${ae(n,o)}
|
|
58
|
+
${ee(n,o)}
|
|
59
|
+
${te(n,o)}
|
|
60
|
+
}`;await c(s,`${r}/contracts/${e}/sources/codegen/data/${d(n)}.move`,"formatAndWriteMove")}console.log(`\u2705 Schema Data Generation Complete
|
|
61
|
+
`)}function oe(e,t){return t!=null?Object.keys(t).map(a=>`use ${e}::${e}_${d(a)}::${a};`).join(`
|
|
62
|
+
`):""}async function w(e,t,r,a){console.log(`
|
|
63
63
|
\u{1F528} Starting Schema Structure Generation...`),console.log(` \u251C\u2500 Output path: ${a}/contracts/${e}/sources/codegen/schema.move`),console.log(` \u2514\u2500 Structure fields: ${Object.values(r).length}`);let n=`module ${e}::${e}_schema {
|
|
64
64
|
use std::ascii::String;
|
|
65
65
|
use std::ascii::string;
|
|
@@ -71,23 +71,23 @@ ${e.name} = "0x0"
|
|
|
71
71
|
use dubhe::storage_double_map::{Self, StorageDoubleMap};
|
|
72
72
|
use sui::dynamic_field as df;
|
|
73
73
|
|
|
74
|
-
${
|
|
74
|
+
${oe(e,t)}
|
|
75
75
|
|
|
76
76
|
public struct Schema has key, store { id: UID }
|
|
77
77
|
|
|
78
|
-
${Object.entries(r).map(([s
|
|
79
|
-
storage::borrow_field(&self.id, b"${
|
|
78
|
+
${Object.entries(r).map(([o,s])=>`public fun borrow_${o}(self: &Schema) : &${s} {
|
|
79
|
+
storage::borrow_field(&self.id, b"${o}")
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
public(package) fun ${
|
|
83
|
-
storage::borrow_mut_field(&mut self.id, b"${
|
|
82
|
+
public(package) fun ${o}(self: &mut Schema): &mut ${s} {
|
|
83
|
+
storage::borrow_mut_field(&mut self.id, b"${o}")
|
|
84
84
|
}
|
|
85
85
|
`).join("")}
|
|
86
86
|
|
|
87
87
|
|
|
88
88
|
public(package) fun create(ctx: &mut TxContext): Schema {
|
|
89
89
|
let mut id = object::new(ctx);
|
|
90
|
-
${Object.entries(r).map(([s
|
|
90
|
+
${Object.entries(r).map(([o,s])=>{let i="";return s.includes("StorageValue")?i=`storage_value::new(b"${o}", ctx)`:s.includes("StorageMap")?i=`storage_map::new(b"${o}", ctx)`:s.includes("StorageDoubleMap")&&(i=`storage_double_map::new(b"${o}", ctx)`),`storage::add_field<${s}>(&mut id, b"${o}", ${i});`}).join(`
|
|
91
91
|
`)}
|
|
92
92
|
|
|
93
93
|
Schema { id }
|
|
@@ -105,71 +105,71 @@ ${e.name} = "0x0"
|
|
|
105
105
|
|
|
106
106
|
|
|
107
107
|
// ======================================== View Functions ========================================
|
|
108
|
-
${Object.entries(r).map(([s
|
|
109
|
-
self.borrow_${
|
|
108
|
+
${Object.entries(r).map(([o,s])=>{let i=s.match(/<(.+)>/)[1].split(",").map(Y=>Y.trim()),p=[],m="",_="";return s.includes("StorageValue")?(p=[],m=`${i[0]}`,_="get()"):s.includes("StorageMap")?(p=[`key: ${i[0]}`],m=`${i[1]}`,_="get(key)"):s.includes("StorageDoubleMap")&&(p=[`key1: ${i[0]}`,`key2: ${i[1]}`],m=`${i[2]}`,_="get(key1, key2)"),`public fun get_${o}(self: &Schema, ${p}) : &${m} {
|
|
109
|
+
self.borrow_${o}().${_}
|
|
110
110
|
}`}).join(`
|
|
111
111
|
`)}
|
|
112
112
|
// =========================================================================================================
|
|
113
113
|
}`;await c(n,`${a}/contracts/${e}/sources/codegen/schema.move`,"formatAndWriteMove"),console.log(`\u2705 Schema Structure Generation Complete
|
|
114
|
-
`)}import{existsSync as
|
|
115
|
-
\u{1F4DD} Starting Deploy Hook Generation...`),console.log(` \u2514\u2500 Output path: ${t}/contracts/${e.name}/sources/scripts/deploy_hook.move`);let r=`${t}/contracts/${e.name}/sources/scripts/deploy_hook.move`;if(!
|
|
114
|
+
`)}import{existsSync as I}from"fs";async function F(e,t){console.log(`
|
|
115
|
+
\u{1F4DD} Starting Deploy Hook Generation...`),console.log(` \u2514\u2500 Output path: ${t}/contracts/${e.name}/sources/scripts/deploy_hook.move`);let r=`${t}/contracts/${e.name}/sources/scripts/deploy_hook.move`;if(!I(r)){let a=`module ${e.name}::${e.name}_deploy_hook {
|
|
116
116
|
use ${e.name}::${e.name}_schema::Schema;
|
|
117
117
|
|
|
118
118
|
public(package) fun run(_schema: &mut Schema, _ctx: &mut TxContext) {
|
|
119
119
|
|
|
120
120
|
}
|
|
121
121
|
}`;await c(a,r,"formatAndWriteMove")}console.log(`\u2705 Deploy Hook Generation Complete
|
|
122
|
-
`)}async function
|
|
122
|
+
`)}async function L(e,t){if(!I(`${t}/contracts/${e.name}/sources/scripts/migrate.move`)){let r=`module ${e.name}::${e.name}_migrate {
|
|
123
123
|
const ON_CHAIN_VERSION: u32 = 1;
|
|
124
124
|
|
|
125
125
|
public fun on_chain_version(): u32 {
|
|
126
126
|
ON_CHAIN_VERSION
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
`;await c(r,`${t}/contracts/${e.name}/sources/scripts/migrate.move`,"formatAndWriteMove")}}function
|
|
129
|
+
`;await c(r,`${t}/contracts/${e.name}/sources/scripts/migrate.move`,"formatAndWriteMove")}}function l(e){return e.split("_").map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join("")}function ne(e){return e.replace(/([A-Z])/g,"_$1").toLowerCase().replace(/^_/,"")}function B(e,t){return t!=null?Object.keys(t).map(a=>`use ${e}::${e}_${ne(a)}::${a};`).join(`
|
|
130
130
|
`):""}async function D(e,t,r,a){console.log(`
|
|
131
|
-
\u{1F4E6} Starting Schema Event Generation...`);for(let
|
|
131
|
+
\u{1F4E6} Starting Schema Event Generation...`);for(let o of Object.keys(r)){let s=o,i=r[o];console.log(` \u2514\u2500 Generating ${s} event: ${i}`);let p=`module ${e}::${e}_${s}_event {
|
|
132
132
|
use sui::event;
|
|
133
133
|
use std::ascii::String;
|
|
134
134
|
${B(e,t)}
|
|
135
135
|
|
|
136
|
-
public struct ${
|
|
136
|
+
public struct ${l(s)}Event has copy, drop {
|
|
137
137
|
${u(i)}
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
public fun new(${u(i)}): ${
|
|
141
|
-
${
|
|
140
|
+
public fun new(${u(i)}): ${l(s)}Event {
|
|
141
|
+
${l(s)}Event {
|
|
142
142
|
${f(i)}
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
|
-
}`;await c(p,`${a}/contracts/${e}/sources/codegen/data/${
|
|
145
|
+
}`;await c(p,`${a}/contracts/${e}/sources/codegen/data/${s}_event.move`,"formatAndWriteMove")}let n=`module ${e}::${e}_events {
|
|
146
146
|
use std::ascii::{String, string};
|
|
147
147
|
${B(e,t)}
|
|
148
|
-
${Object.entries(r).map(([s
|
|
149
|
-
use ${e}::${e}_${
|
|
150
|
-
use ${e}::${e}_${
|
|
151
|
-
public fun ${
|
|
152
|
-
dubhe::storage_event::emit_set_record<${
|
|
153
|
-
string(b"${
|
|
148
|
+
${Object.entries(r).map(([o,s])=>`
|
|
149
|
+
use ${e}::${e}_${o}_event::${l(o)}Event;
|
|
150
|
+
use ${e}::${e}_${o}_event;
|
|
151
|
+
public fun ${o}_event(${u(s)}) {
|
|
152
|
+
dubhe::storage_event::emit_set_record<${l(o)}Event, ${l(o)}Event, ${l(o)}Event>(
|
|
153
|
+
string(b"${o}_event"),
|
|
154
154
|
option::none(),
|
|
155
155
|
option::none(),
|
|
156
|
-
option::some(${e}_${
|
|
156
|
+
option::some(${e}_${o}_event::new(${f(s)}))
|
|
157
157
|
)
|
|
158
158
|
}
|
|
159
159
|
`).join(`
|
|
160
160
|
`)}
|
|
161
161
|
}`;await c(n,`${a}/contracts/${e}/sources/codegen/events.move`,"formatAndWriteMove"),console.log(`\u2705 Schema Event Generation Complete
|
|
162
|
-
`)}import{existsSync as
|
|
163
|
-
\u2699\uFE0F Starting System Generation...`),console.log(" \u251C\u2500 Generating systems"),console.log(` \u2514\u2500 Output path: ${t}/contracts/${e.name}/sources/systems`),
|
|
164
|
-
`)}
|
|
162
|
+
`)}import{existsSync as se}from"fs";import ie from"node:fs/promises";async function K(e,t){console.log(`
|
|
163
|
+
\u2699\uFE0F Starting System Generation...`),console.log(" \u251C\u2500 Generating systems"),console.log(` \u2514\u2500 Output path: ${t}/contracts/${e.name}/sources/systems`),se(`${t}/contracts/${e.name}/sources/systems`)||await ie.mkdir(`${t}/contracts/${e.name}/sources/systems`,{recursive:!0}),console.log(`\u2705 System Generation Complete
|
|
164
|
+
`)}async function H(e,t,r){console.log(`
|
|
165
165
|
\u{1F4E6} Starting Schema Error Generation...`);let a=`module ${e}::${e}_errors {
|
|
166
|
-
${Object.entries(t).map(([n,
|
|
167
|
-
const ${n}: vector<u8> = b"${
|
|
168
|
-
public fun ${
|
|
166
|
+
${Object.entries(t).map(([n,o])=>(console.log(` \u251C\u2500 Generating Error: ${n}`),console.log(` \u2502 \u2514\u2500 Message: ${o}`),`#[error]
|
|
167
|
+
const ${n.toUpperCase()}: vector<u8> = b"${o}";
|
|
168
|
+
public fun ${n}_error(condition: bool) { assert!(condition, ${n.toUpperCase()}) }
|
|
169
169
|
`)).join(`
|
|
170
170
|
`)}
|
|
171
171
|
}`;await c(a,`${r}/contracts/${e}/sources/codegen/errors.move`,"formatAndWriteMove"),console.log(`\u2705 Schema Error Generation Complete
|
|
172
|
-
`)}import{existsSync as k}from"fs";async function
|
|
172
|
+
`)}import{existsSync as k}from"fs";async function z(e,t){await ce(e,t),await pe(e,t),await ue(e,t)}async function ce(e,t){let r=`${t}/contracts/${e.name}/sources/codegen/dapp/metadata.move`;if(!k(r)){let a=`module ${e.name}::${e.name}_dapp_metadata {
|
|
173
173
|
use std::ascii::String;
|
|
174
174
|
|
|
175
175
|
public struct DappMetadata has drop, copy, store {
|
|
@@ -491,7 +491,7 @@ use ${e}::${e}_${m(s)}_event;
|
|
|
491
491
|
}
|
|
492
492
|
}
|
|
493
493
|
`;await c(a,`${t}/contracts/${e.name}/sources/codegen/genesis.move`,"formatAndWriteMove"),console.log(`\u2705 Init Generation Complete
|
|
494
|
-
`)}async function
|
|
495
|
-
\u{1F680} Starting Schema Generation Process...`),console.log("\u{1F4CB} Project Configuration:"),console.log(` \u251C\u2500 Name: ${e.name}`),console.log(` \u251C\u2500 Description: ${e.description||"No description provided"}`),console.log(` \u251C\u2500 Network: ${r||"testnet"}`);let a=t??process.cwd();A(`${a}/contracts/${e.name}`)&&
|
|
496
|
-
`)}import{findUp as me}from"find-up";import C from"path";import le from"esbuild";var
|
|
494
|
+
`)}async function _t(e,t,r){console.log(`
|
|
495
|
+
\u{1F680} Starting Schema Generation Process...`),console.log("\u{1F4CB} Project Configuration:"),console.log(` \u251C\u2500 Name: ${e.name}`),console.log(` \u251C\u2500 Description: ${e.description||"No description provided"}`),console.log(` \u251C\u2500 Network: ${r||"testnet"}`);let a=t??process.cwd();A(`${a}/contracts/${e.name}`)&&x(`${a}/contracts/${e.name}/sources/codegen`),A(`${a}/contracts/${e.name}/Move.toml`)||await G(e,a),A(`${a}/contracts/${e.name}/sources/script/deploy_hook.move`)||await F(e,a),e.events&&(e.data?await D(e.name,e.data,e.events,a):await D(e.name,null,e.events,a)),e.data?(await j(e.name,e.data,a),await w(e.name,e.data,e.schemas,a)):await w(e.name,null,e.schemas,a),e.errors&&await H(e.name,e.errors,a),await z(e,a),await Q(e,a),await K(e,a),await L(e,a),console.log(`\u2705 Schema Generation Process Complete!
|
|
496
|
+
`)}import{findUp as me}from"find-up";import C from"path";import le from"esbuild";var h=class extends Error{name="NotInsideProjectError";message="You are not inside a Dubhe project"};import{rmSync as de}from"fs";import{pathToFileURL as ge}from"url";import fe from"os";var _e=["dubhe.config.js","dubhe.config.mjs","dubhe.config.ts","dubhe.config.mts"],M="dubhe.config.example.mjs";async function kt(e){e=await Z(e);try{return await le.build({entryPoints:[e],format:"esm",outfile:M,platform:"node",bundle:!0,packages:"external"}),e=await Z(M,!0),(await import(e+`?update=${Date.now()}`)).dubheConfig}finally{de(M,{force:!0})}}async function Z(e,t){return e===void 0?e=await be():C.isAbsolute(e)||(e=C.join(process.cwd(),e),e=C.normalize(e)),t&&fe.platform()==="win32"?ge(e).href:e}async function be(){let e=await me(_e);if(e===void 0)throw new h;return e}function Ut(...e){if(e.length===1)return`StorageValue<${e[0]}>`;if(e.length===2)return`StorageMap<${e[0]}, ${e[1]}>`;if(e.length===3)return`StorageDoubleMap<${e[0]}, ${e[1]}, ${e[2]}>`;throw new Error("Invalid number of arguments for storage()")}var S=e=>{if(typeof e!="object"||e===null)return e;let t={};for(let r in e)if(e.hasOwnProperty(r)){let a=e[r];typeof a=="object"&&a!==null?Array.isArray(a)?t[r]=X(a):a.hasOwnProperty("variant")?t[r]={[a.variant]:{}}:a.hasOwnProperty("fields")?t[r]=S(a.fields):t[r]=S(a):t[r]=a}return t},X=e=>{let t=[];return e.forEach(r=>{typeof r=="object"&&r!==null?Array.isArray(r)?t.push(X(r)):r.hasOwnProperty("variant")?t.push({[r.variant]:{}}):r.hasOwnProperty("fields")?t.push(S(r.fields)):t.push(S(r)):t.push(r)}),t};var $e=(r=>(r.Event="event",r.Schema="schema",r))($e||{});export{$e as SubscriptionKind,c as formatAndWriteMove,Te as formatAndWriteTypescript,T as formatMove,V as formatTypescript,kt as loadConfig,S as parseData,Ee as posixPath,Z as resolveConfigPath,_t as schemaGen,Ut as storage};
|
|
497
497
|
//# sourceMappingURL=index.js.map
|