@zktx.io/sui-move-builder 0.2.5 → 0.2.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/README.md +40 -9
- package/dist/full/index.cjs +22 -19
- package/dist/full/index.d.cts +42 -2
- package/dist/full/index.d.ts +42 -2
- package/dist/full/index.js +22 -19
- package/dist/full/sui_move_wasm.d.ts +15 -2
- package/dist/full/sui_move_wasm.js +35 -2
- package/dist/full/sui_move_wasm_bg.wasm +0 -0
- package/dist/full/sui_move_wasm_bg.wasm.d.ts +2 -1
- package/dist/lite/index.cjs +22 -19
- package/dist/lite/index.d.cts +42 -2
- package/dist/lite/index.d.ts +42 -2
- package/dist/lite/index.js +22 -19
- package/dist/lite/sui_move_wasm.d.ts +15 -2
- package/dist/lite/sui_move_wasm.js +39 -2
- package/dist/lite/sui_move_wasm_bg.wasm +0 -0
- package/dist/lite/sui_move_wasm_bg.wasm.d.ts +2 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @zktx.io/sui-move-builder
|
|
2
2
|
|
|
3
|
-
> **Upstream source:** [MystenLabs/sui](https://github.com/MystenLabs/sui) (
|
|
3
|
+
> **Upstream source:** [MystenLabs/sui](https://github.com/MystenLabs/sui) (see `sui-version.json`)
|
|
4
4
|
|
|
5
5
|
Build Move packages in web or Node.js with Sui CLI-compatible dependency resolution and compilation.
|
|
6
6
|
|
|
@@ -10,6 +10,7 @@ Build Move packages in web or Node.js with Sui CLI-compatible dependency resolut
|
|
|
10
10
|
- ✅ **Verified Parity**: Audited against `sui-04dd` source code (Jan 2026), byte-level module comparison
|
|
11
11
|
- ✅ **Address Resolution**: Supports `original_id` for compilation, `published_at` for metadata (CLI-identical)
|
|
12
12
|
- ✅ **Lockfile Support**: Reads `Move.lock` v0/v3/v4 for faster, deterministic builds
|
|
13
|
+
- ✅ **Move.lock V4 Output**: Generates **V4 format** with CLI-compatible **lexicographical sorting** and `manifest_digest`
|
|
13
14
|
- ✅ **Published.toml Support**: Reads deployment records per environment
|
|
14
15
|
- ✅ **Per-Package Editions**: Each package can use its own Move edition (legacy, 2024.alpha, 2024.beta)
|
|
15
16
|
- ✅ **Monorepo Support**: Handles local dependencies in monorepo structures
|
|
@@ -91,13 +92,35 @@ const result = await buildMovePackage({
|
|
|
91
92
|
});
|
|
92
93
|
|
|
93
94
|
if (result.success) {
|
|
94
|
-
|
|
95
|
-
console.log("Modules:", result.modules); // Base64-encoded bytecode
|
|
95
|
+
// Compilation outputs
|
|
96
|
+
console.log("Modules:", result.modules); // Array<string>: Base64-encoded bytecode
|
|
97
|
+
console.log("Dependencies:", result.dependencies); // Array<string>: Hex-encoded package IDs
|
|
98
|
+
console.log("Digest:", result.digest); // Array<number>: Package digest bytes
|
|
99
|
+
|
|
100
|
+
// Lockfile outputs
|
|
101
|
+
console.log("Move.lock:", result.moveLock); // string: V4 lockfile content (CLI-compatible)
|
|
102
|
+
console.log("Environment:", result.environment); // string: e.g., "mainnet"
|
|
103
|
+
|
|
104
|
+
// Migration output (V3 → V4)
|
|
105
|
+
if (result.publishedToml) {
|
|
106
|
+
console.log("Published.toml:", result.publishedToml); // string: Migrated from legacy Move.lock
|
|
107
|
+
}
|
|
96
108
|
} else {
|
|
97
109
|
console.error("Build failed:", result.error);
|
|
98
110
|
}
|
|
99
111
|
```
|
|
100
112
|
|
|
113
|
+
### Build Output Reference
|
|
114
|
+
|
|
115
|
+
| Field | Type | Description |
|
|
116
|
+
| --------------- | ---------- | ---------------------------------------------- |
|
|
117
|
+
| `modules` | `string[]` | Base64-encoded compiled bytecode modules |
|
|
118
|
+
| `dependencies` | `string[]` | Hex-encoded package IDs for linking |
|
|
119
|
+
| `digest` | `number[]` | Package digest bytes (32 bytes) |
|
|
120
|
+
| `moveLock` | `string` | Generated Move.lock V4 content |
|
|
121
|
+
| `environment` | `string` | Build environment (e.g., "mainnet", "testnet") |
|
|
122
|
+
| `publishedToml` | `string?` | Migrated Published.toml (if V3→V4 migration) |
|
|
123
|
+
|
|
101
124
|
## Fetching packages from GitHub
|
|
102
125
|
|
|
103
126
|
```ts
|
|
@@ -257,18 +280,26 @@ npm run test:lite # Run fidelity tests (lite version)
|
|
|
257
280
|
npm test # Run full integration tests
|
|
258
281
|
```
|
|
259
282
|
|
|
260
|
-
**Test Cases (verified against
|
|
283
|
+
**Test Cases (verified against sui-mainnet-v1.63.3):**
|
|
261
284
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
285
|
+
| Package | Modules | Dependencies | Digest | Lockfile |
|
|
286
|
+
| ----------- | ------- | ------------ | ------ | ---------------------- |
|
|
287
|
+
| `nautilus` | ✅ | ✅ | ✅ | ✅ |
|
|
288
|
+
| `deepbook` | ✅ | ✅ | ✅ | ✅ (mainnet + testnet) |
|
|
289
|
+
| `deeptrade` | ✅ | ✅ | ✅ | ✅ (diamond deps) |
|
|
265
290
|
|
|
266
291
|
All tests verify:
|
|
267
292
|
|
|
268
293
|
- ✅ Module bytecode (identical to CLI `.mv` output)
|
|
269
294
|
- ✅ Dependency IDs (exact match with CLI)
|
|
270
|
-
- ✅
|
|
295
|
+
- ✅ Package digest (identical hash)
|
|
296
|
+
- ✅ Move.lock V4 content (all environments preserved)
|
|
297
|
+
- ✅ manifest_digest calculation (CLI-compatible)
|
|
271
298
|
|
|
272
299
|
## Roadmap
|
|
273
300
|
|
|
274
|
-
- **
|
|
301
|
+
- ✅ **Move.lock V4 Generation**: CLI-compatible with deterministic sorting and manifest_digest
|
|
302
|
+
- ✅ **Multi-Environment Support**: Preserves all environments from existing Move.lock
|
|
303
|
+
- ✅ **V3→V4 Migration**: Automatically generates Published.toml from legacy Move.lock
|
|
304
|
+
- **Published.toml Generation**: Generate Published.toml after successful deployment
|
|
305
|
+
- **Bytecode Dependencies**: Support for .mv-only dependencies (CLI fallback path)
|
package/dist/full/index.cjs
CHANGED
|
@@ -1,24 +1,27 @@
|
|
|
1
|
-
"use strict";var J=Object.create;var x=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var Q=Object.getPrototypeOf,X=Object.prototype.hasOwnProperty;var Y=(d,e)=>{for(var t in e)x(d,t,{get:e[t],enumerable:!0})},j=(d,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of q(e))!X.call(d,s)&&s!==t&&x(d,s,{get:()=>e[s],enumerable:!(i=K(e,s))||i.enumerable});return d};var Z=(d,e,t)=>(t=d!=null?J(Q(d)):{},j(e||!d||!d.__esModule?x(t,"default",{value:d,enumerable:!0}):t,d)),ee=d=>j(x({},"__esModule",{value:!0}),d);var ge={};Y(ge,{buildMovePackage:()=>re,compileRaw:()=>le,fetchPackageFromGitHub:()=>z,getSuiMoveVersion:()=>ae,getSuiVersion:()=>ce,getWasmBindings:()=>de,initMoveCompiler:()=>ie,resolveDependencies:()=>G,testMovePackage:()=>oe});module.exports=ee(ge);var N=class{async fetch(e,t,i){throw new Error("Not implemented")}async fetchFile(e,t,i){throw new Error("Not implemented")}},A=class extends N{constructor(t){super();this.rateLimitRemaining=60;this.rateLimitReset=0;this.cache=new Map,this.treeCache=new Map,this.token=t}updateRateLimit(t){let i=t.headers.get("x-ratelimit-remaining"),s=t.headers.get("x-ratelimit-reset");i&&(this.rateLimitRemaining=parseInt(i,10)),s&&(this.rateLimitReset=parseInt(s,10)*1e3)}async fetch(t,i,s,n){let{owner:r,repo:o}=this.parseGitUrl(t);if(!r||!o)throw new Error(`Invalid git URL: ${t}`);let a=`${r}/${o}@${i}`,p=`https://api.github.com/repos/${r}/${o}/git/trees/${i}?recursive=1`,c;if(this.treeCache.has(a))c=this.treeCache.get(a);else{let f=null;for(let h=1;h<=3;h++)try{if(h>1){let b=Math.pow(2,h-1)*1e3;await new Promise(k=>setTimeout(k,b))}let y={};this.token&&(y.Authorization=`Bearer ${this.token}`);let v=await fetch(p,{headers:y});if(this.updateRateLimit(v),!v.ok){if(v.status===403||v.status===429){let b=new Date(this.rateLimitReset);throw new Error(`GitHub API rate limit exceeded. Resets at ${b.toLocaleTimeString()}`)}if(v.status>=500&&v.status<600&&h<3){f=new Error(`Failed to fetch tree: ${v.statusText}`);continue}throw new Error(`Failed to fetch tree: ${v.statusText}`)}c=await v.json(),this.treeCache.set(a,c);break}catch(y){if(f=y instanceof Error?y:new Error(String(y)),h===3)return{}}if(f)return{}}let l=new Map,u={},g=[];for(let m of c.tree){if(m.type!=="blob")continue;let f=m.path;if(s){let v=s.endsWith("/")?s:s+"/";if(!m.path.startsWith(v))continue;f=m.path.slice(v.length)}if(!f.endsWith(".move")&&f!=="Move.toml"&&f!=="Move.lock"&&!f.match(/^Move\.(mainnet|testnet|devnet)\.toml$/))continue;f==="Move.toml"&&m.mode&&l.set("Move.toml",m.mode);let h=`https://raw.githubusercontent.com/${r}/${o}/${i}/${m.path}`,y=this.fetchContent(h).then(v=>{v&&(u[f]=v)});g.push(y)}if(await Promise.all(g),u["Move.toml"]&&l.get("Move.toml")==="120000"){let f=u["Move.toml"].trim(),h=s?`${s}/${f}`.replace(/\/+/g,"/"):f,y=`https://raw.githubusercontent.com/${r}/${o}/${i}/${h}`,v=await this.fetchContent(y);v&&(u["Move.toml"]=v)}return u}async fetchFile(t,i,s){let{owner:n,repo:r}=this.parseGitUrl(t);if(!n||!r)throw new Error(`Invalid git URL: ${t}`);let o=`https://raw.githubusercontent.com/${n}/${r}/${i}/${s}`;return this.fetchContent(o)}async fetchContent(t){if(this.cache.has(t))return this.cache.get(t)??null;try{let i={},s=typeof window<"u",n=t.startsWith("https://api.github.com/");this.token&&(!s||n)&&(i.Authorization=`Bearer ${this.token}`);let r=await fetch(t,{headers:i});if(!r.ok)return null;let o=await r.text();return this.cache.set(t,o),o}catch{return null}}parseGitUrl(t){try{let s=new URL(t).pathname.split("/").filter(n=>n);if(s.length>=2){let n=s[1];return n.endsWith(".git")&&(n=n.slice(0,-4)),{owner:s[0],repo:n}}}catch{}return{owner:null,repo:null}}};function F(d){let e=!1,t="";for(let i=0;i<d.length;i++){let s=d[i];if((s==='"'||s==="'")&&(!e||s===t)&&(e=!e,t=s),!e&&s==="#")return d.slice(0,i)}return d}function C(d){let e=d.trim();if(!e)return"";if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1);if(e==="true")return!0;if(e==="false")return!1;let t=Number(e);return Number.isNaN(t)?e:t}function U(d){let e={},t=d.trim().replace(/^\{/,"").replace(/\}$/,""),i="",s=!1,n="",r=[];for(let o=0;o<t.length;o++){let a=t[o];if((a==='"'||a==="'")&&(!s||a===n)&&(s=!s,n=a),!s&&a===","){r.push(i),i="";continue}i+=a}i.trim()&&r.push(i);for(let o of r){let a=o.indexOf("=");if(a===-1)continue;let p=o.slice(0,a).trim(),c=o.slice(a+1).trim();e[p]=C(c)}return e}function te(d){let e=[],t=d.trim().replace(/^\[/,"").replace(/\]$/,""),i="",s=!1,n="",r=0;for(let o=0;o<t.length;o++){let a=t[o];if((a==='"'||a==="'")&&(!s||a===n)&&(s=!s,n=s?a:""),!s&&(a==="{"&&r++,a==="}"&&r--,a===","&&r===0)){i.trim()&&e.push(_(i.trim())),i="";continue}i+=a}return i.trim()&&e.push(_(i.trim())),e}function _(d){return d.startsWith("{")?U(d):C(d)}function S(d){let e={},t=null,i=!1,s=d.split(/\r?\n/),n=[],r=0;for(;r<s.length;){let a=F(s[r]);if(a.match(/=\s*\[\s*$/)||a.includes("=")&&a.includes("[")&&!a.includes("]")){let p=a;for(r++;r<s.length&&!p.includes("]");)p+=" "+F(s[r]).trim(),r++;r<s.length&&p.includes("[")&&!p.includes("]")&&(p+=" "+F(s[r]).trim(),r++),n.push(p)}else n.push(a),r++}function o(a,p){let c=a;for(let l of p){if(!(l in c))return;c=c[l]}return c}for(let a of n){let p=F(a).trim();if(!p)continue;let c=p.match(/^\[\[([^\]]+)\]\]$/);if(c){t=c[1].trim(),i=!0;let h=t.split("."),y=e;for(let b=0;b<h.length-1;b++){let k=h[b];k in y||(y[k]={}),y=y[k]}let v=h[h.length-1];Array.isArray(y[v])||(y[v]=[]),y[v].push({});continue}let l=p.match(/^\[([^\]]+)\]$/);if(l){t=l[1].trim(),i=!1;continue}let u=p.indexOf("=");if(u===-1||!t)continue;let g=p.slice(0,u).trim(),m=p.slice(u+1).trim(),f;if(m.startsWith("{")?f=U(m):m.startsWith("[")?f=te(m):f=C(m),i){let h=t.split("."),y=o(e,h);if(Array.isArray(y)&&y.length>0){let v=y[y.length-1];v[g]=f}}else{let h=t.split("."),y=e;for(let b of h)b in y||(y[b]={}),y=y[b];let v=t==="package"?g.replace(/-/g,"_"):g;y[v]=f}}return e}var O=class{constructor(e){this.packageTable=new Map;this.graph=new Map;this.alwaysDeps=new Set(["Sui","MoveStdlib"]);this.lockfileOrder=[];this.root=e}setLockfileOrder(e){this.lockfileOrder=e}addPackage(e){this.packageTable.set(e.id.name,e),this.graph.has(e.id.name)||this.graph.set(e.id.name,new Set)}addDependency(e,t,i){this.graph.has(e)||this.graph.set(e,new Set),this.graph.get(e).add(t)}getPackage(e){return this.packageTable.get(e)}getAllPackages(){return Array.from(this.packageTable.values())}getImmediateDependencies(e){return this.graph.get(e)||new Set}getTransitiveDependencies(e){let t=new Set,i=new Set,s=n=>{if(i.has(n))return;i.add(n),t.add(n);let r=this.graph.get(n);if(r)for(let o of r)s(o)};return s(e),t.delete(e),t}topologicalOrder(){let e=new Set,t=[],i=s=>{if(e.has(s))return;e.add(s);let n=this.graph.get(s);if(n){let r=Array.from(n).sort();for(let o of r)i(o)}t.push(s)};return i(this.root),t.filter(s=>s!==this.root)}compilerInputOrder(){let e=new Set,t=[],i=s=>{if(e.has(s))return;e.add(s);let n=this.graph.get(s);if(n){let r=Array.from(n).sort();for(let o of r)i(o)}t.push(s)};return i(this.root),t}topologicalOrderDFS(){let e=new Set,t=[],i=s=>{if(e.has(s))return;e.add(s);let n=this.graph.get(s);if(n)for(let r of Array.from(n))i(r);t.push(s)};i(this.root);for(let s of this.packageTable.keys())i(s);return t}detectCycle(){let e=new Set,t=new Set,i=new Map,s=n=>{e.add(n),t.add(n);let r=this.graph.get(n);if(r)for(let o of r)if(e.has(o)){if(t.has(o)){let a=[o],p=n;for(;p!==o;)a.unshift(p),p=i.get(p);return a.unshift(o),a}}else{i.set(o,n);let a=s(o);if(a)return a}return t.delete(n),null};for(let n of this.packageTable.keys())if(!e.has(n)){let r=s(n);if(r)return r}return null}getRootPackage(){return this.packageTable.get(this.root)}getRootName(){return this.root}isAlwaysDep(e){return this.alwaysDeps.has(e)}};var $=class{constructor(e,t={}){this.unifiedAddressTable=new Map;this.packageResolvedTables=new Map;this.graph=e,this.buildConfig=t}async resolve(){let t=[this.graph.getRootName(),...this.graph.topologicalOrder()];for(let i of t){let s=this.graph.getPackage(i);if(s)for(let[n,r]of Object.entries(s.manifest.addresses)){let o=this.normalizeAddress(r);this.unifiedAddressTable.has(n)&&this.unifiedAddressTable.get(n)!==o||this.unifiedAddressTable.set(n,o)}}for(let i of this.graph.getAllPackages()){let s={};for(let[n,r]of this.unifiedAddressTable.entries())s[n]=r;this.packageResolvedTables.set(i.id.name,s),i.resolvedTable=s}}normalizeAddress(e){if(!e)return e;let t=e.trim();return t.startsWith("0x")&&(t=t.slice(2)),/^[0-9a-fA-F]+$/.test(t)?"0x"+t.padStart(64,"0"):e}getUnifiedAddressTable(){let e={};for(let[t,i]of this.unifiedAddressTable.entries())e[t]=i;return e}getPackageResolvedTable(e){return this.packageResolvedTables.get(e)}getGraph(){return this.graph}topologicalOrder(){return this.graph.topologicalOrder()}compilerInputOrder(){return this.graph.compilerInputOrder()}getRootName(){return this.graph.getRootName()}getPackage(e){return this.graph.getPackage(e)}getImmediateDependencies(e){return this.graph.getImmediateDependencies(e)}};var T=class{constructor(e){this.dependencies=[];this.resolvedGraph=e,this.rootPackageName=e.getRootName()}async compute(e){if(!this.resolvedGraph.getPackage(this.rootPackageName))throw new Error(`Root package '${this.rootPackageName}' not found`);let i=this.resolvedGraph.getImmediateDependencies(this.rootPackageName),s=this.resolvedGraph.compilerInputOrder(),n=new Map;for(let r of s){if(r===this.rootPackageName)continue;let o=this.resolvedGraph.getPackage(r);if(!o)continue;let a=e.get(r)||{},p=this.extractSourcePaths(r,a),c=o.manifest.edition||"legacy",l=o.manifest.latestPublishedId||o.manifest.publishedAt||o.manifest.originalId||o.resolvedTable?.[r],u=o.manifest.originalId;!u&&o.manifest.publishedAt&&(u=o.manifest.publishedAt),u||(u="0x0000000000000000000000000000000000000000000000000000000000000000",l||(l=u)),n.set(r,u),n.set(r.toLowerCase(),u);let g={...o.resolvedTable||{}};for(let[f,h]of Object.entries(g)){let y=n.get(f)||n.get(f.toLowerCase());y&&(g[f]=y)}u&&r!=="Sui"&&r!=="MoveStdlib"&&(g[r]=u,g[r.toLowerCase()]=u);let m={name:r,isImmediate:i.has(r),sourcePaths:p,addressMapping:g,compilerConfig:{edition:c,flavor:"sui"},moduleFormat:p.length>0?"Source":"Bytecode",edition:c,publishedIdForOutput:l};this.dependencies.push(m)}}getDependencyAddress(e){return this.dependencies.find(t=>t.name===e)?.publishedIdForOutput}extractSourcePaths(e,t){return Object.keys(t).filter(s=>s.endsWith("Move.toml")||s.endsWith("Move.lock")?!1:s.endsWith(".move"))}toPackageGroupedFormat(e){let t=[];for(let i of this.dependencies){let s=e.get(i.name)||{},n={};for(let[r,o]of Object.entries(s)){if(r.endsWith("Move.lock"))continue;let a=`dependencies/${i.name}/${r}`;r.endsWith("Move.toml")?n[a]=this.reconstructDependencyMoveToml(i.name,o,i.edition,i.addressMapping):n[a]=o}t.push({name:i.name,files:n,edition:i.edition,addressMapping:i.addressMapping,publishedIdForOutput:i.publishedIdForOutput})}return t}reconstructDependencyMoveToml(e,t,i,s){let n=(t||"").split(`
|
|
2
|
-
`),
|
|
3
|
-
`;
|
|
4
|
-
`,
|
|
5
|
-
`,
|
|
6
|
-
`,
|
|
7
|
-
`,
|
|
8
|
-
`),
|
|
1
|
+
"use strict";var ne=Object.create;var F=Object.defineProperty;var ie=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames;var oe=Object.getPrototypeOf,ae=Object.prototype.hasOwnProperty;var ce=(u,e)=>{for(var t in e)F(u,t,{get:e[t],enumerable:!0})},z=(u,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of re(e))!ae.call(u,i)&&i!==t&&F(u,i,{get:()=>e[i],enumerable:!(n=ie(e,i))||n.enumerable});return u};var de=(u,e,t)=>(t=u!=null?ne(oe(u)):{},z(e||!u||!u.__esModule?F(t,"default",{value:u,enumerable:!0}):t,u)),le=u=>z(F({},"__esModule",{value:!0}),u);var Se={};ce(Se,{buildMovePackage:()=>ke,compileRaw:()=>Ie,fetchPackageFromGitHub:()=>Z,getSuiMoveVersion:()=>be,getSuiVersion:()=>Pe,getWasmBindings:()=>we,initMoveCompiler:()=>ve,resolveDependencies:()=>U,testMovePackage:()=>ye});module.exports=le(Se);var W=class{async fetch(e,t,n){throw new Error("Not implemented")}async fetchFile(e,t,n){throw new Error("Not implemented")}getResolvedSha(e,t){}},D=class extends W{constructor(t){super();this.rateLimitRemaining=60;this.rateLimitReset=0;this.cache=new Map,this.treeCache=new Map,this.resolvedShaCache=new Map,this.token=t}getResolvedSha(t,n){let{owner:i,repo:s}=this.parseGitUrl(t);if(!i||!s)return;let o=`${i}/${s}@${n}`;return this.resolvedShaCache.get(o)}updateRateLimit(t){let n=t.headers.get("x-ratelimit-remaining"),i=t.headers.get("x-ratelimit-reset");n&&(this.rateLimitRemaining=parseInt(n,10)),i&&(this.rateLimitReset=parseInt(i,10)*1e3)}async fetch(t,n,i,s){let{owner:o,repo:a}=this.parseGitUrl(t);if(!o||!a)throw new Error(`Invalid git URL: ${t}`);let r=`${o}/${a}@${n}`,p=`https://api.github.com/repos/${o}/${a}/git/trees/${n}?recursive=1`,c;if(this.treeCache.has(r))c=this.treeCache.get(r);else{let h=null;for(let m=1;m<=3;m++)try{if(m>1){let b=Math.pow(2,m-1)*1e3;await new Promise(P=>setTimeout(P,b))}let v={};this.token&&(v.Authorization=`Bearer ${this.token}`);let k=await fetch(p,{headers:v});if(this.updateRateLimit(k),!k.ok){if(k.status===403||k.status===429){let b=new Date(this.rateLimitReset);throw new Error(`GitHub API rate limit exceeded. Resets at ${b.toLocaleTimeString()}`)}if(k.status>=500&&k.status<600&&m<3){h=new Error(`Failed to fetch tree: ${k.statusText}`);continue}throw new Error(`Failed to fetch tree: ${k.statusText}`)}c=await k.json(),this.treeCache.set(r,c),c.sha&&this.resolvedShaCache.set(r,c.sha);break}catch(v){if(h=v instanceof Error?v:new Error(String(v)),m===3)return{}}if(h)return{}}let g=new Map,d={},l=[];for(let f of c.tree){if(f.type!=="blob")continue;let h=f.path;if(i){let k=i.endsWith("/")?i:i+"/";if(!f.path.startsWith(k))continue;h=f.path.slice(k.length)}if(!h.endsWith(".move")&&h!=="Move.toml"&&h!=="Move.lock"&&!h.match(/^Move\.(mainnet|testnet|devnet)\.toml$/))continue;h==="Move.toml"&&f.mode&&g.set("Move.toml",f.mode);let m=`https://raw.githubusercontent.com/${o}/${a}/${n}/${f.path}`,v=this.fetchContent(m).then(k=>{k&&(d[h]=k)});l.push(v)}if(await Promise.all(l),d["Move.toml"]&&g.get("Move.toml")==="120000"){let h=d["Move.toml"].trim(),m=i?`${i}/${h}`.replace(/\/+/g,"/"):h,v=`https://raw.githubusercontent.com/${o}/${a}/${n}/${m}`,k=await this.fetchContent(v);k&&(d["Move.toml"]=k)}return d}async fetchFile(t,n,i){let{owner:s,repo:o}=this.parseGitUrl(t);if(!s||!o)throw new Error(`Invalid git URL: ${t}`);let a=`https://raw.githubusercontent.com/${s}/${o}/${n}/${i}`;return this.fetchContent(a)}async fetchContent(t){if(this.cache.has(t))return this.cache.get(t)??null;try{let n={},i=typeof window<"u",s=t.startsWith("https://api.github.com/");this.token&&(!i||s)&&(n.Authorization=`Bearer ${this.token}`);let o=await fetch(t,{headers:n});if(!o.ok)return null;let a=await o.text();return this.cache.set(t,a),a}catch{return null}}parseGitUrl(t){try{let i=new URL(t).pathname.split("/").filter(s=>s);if(i.length>=2){let s=i[1];return s.endsWith(".git")&&(s=s.slice(0,-4)),{owner:i[0],repo:s}}}catch{}return{owner:null,repo:null}}};function N(u){let e=!1,t="";for(let n=0;n<u.length;n++){let i=u[n];if((i==='"'||i==="'")&&(!e||i===t)&&(e=!e,t=i),!e&&i==="#")return u.slice(0,n)}return u}function G(u){let e=u.trim();if(!e)return"";if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1);if(e==="true")return!0;if(e==="false")return!1;let t=Number(e);return Number.isNaN(t)?e:t}function J(u){let e={},t=u.trim().replace(/^\{/,"").replace(/\}$/,""),n="",i=!1,s="",o=[];for(let a=0;a<t.length;a++){let r=t[a];if((r==='"'||r==="'")&&(!i||r===s)&&(i=!i,s=r),!i&&r===","){o.push(n),n="";continue}n+=r}n.trim()&&o.push(n);for(let a of o){let r=a.indexOf("=");if(r===-1)continue;let p=a.slice(0,r).trim(),c=a.slice(r+1).trim();e[p]=G(c)}return e}function ue(u){let e=[],t=u.trim().replace(/^\[/,"").replace(/\]$/,""),n="",i=!1,s="",o=0;for(let a=0;a<t.length;a++){let r=t[a];if((r==='"'||r==="'")&&(!i||r===s)&&(i=!i,s=i?r:""),!i&&(r==="{"&&o++,r==="}"&&o--,r===","&&o===0)){n.trim()&&e.push(H(n.trim())),n="";continue}n+=r}return n.trim()&&e.push(H(n.trim())),e}function H(u){return u.startsWith("{")?J(u):G(u)}function $(u){let e={},t=null,n=!1,i=u.split(/\r?\n/),s=[],o=0;for(;o<i.length;){let r=N(i[o]);if(r.match(/=\s*\[\s*$/)||r.includes("=")&&r.includes("[")&&!r.includes("]")){let p=r;for(o++;o<i.length&&!p.includes("]");)p+=" "+N(i[o]).trim(),o++;o<i.length&&p.includes("[")&&!p.includes("]")&&(p+=" "+N(i[o]).trim(),o++),s.push(p)}else s.push(r),o++}function a(r,p){let c=r;for(let g of p){if(!(g in c))return;c=c[g]}return c}for(let r of s){let p=N(r).trim();if(!p)continue;let c=p.match(/^\[\[([^\]]+)\]\]$/);if(c){t=c[1].trim(),n=!0;let m=t.split("."),v=e;for(let b=0;b<m.length-1;b++){let P=m[b];P in v||(v[P]={}),v=v[P]}let k=m[m.length-1];Array.isArray(v[k])||(v[k]=[]),v[k].push({});continue}let g=p.match(/^\[([^\]]+)\]$/);if(g){t=g[1].trim(),n=!1;continue}let d=p.indexOf("=");if(d===-1||!t)continue;let l=p.slice(0,d).trim(),f=p.slice(d+1).trim(),h;if(f.startsWith("{")?h=J(f):f.startsWith("[")?h=ue(f):h=G(f),n){let m=t.split("."),v=a(e,m);if(Array.isArray(v)&&v.length>0){let k=v[v.length-1];k[l]=h}}else{let m=t.split("."),v=e;for(let b of m)b in v||(v[b]={}),v=v[b];let k=t==="package"?l.replace(/-/g,"_"):l;v[k]=h}}return e}var O=class{constructor(e){this.packages=[];this.edges=new Map;this.nameToFirstIndex=new Map;this.lockfileOrder=[];this.root=e}setLockfileOrder(e){this.lockfileOrder=e}addPackage(e){let t=this.packages.length;return this.packages.push(e),this.edges.set(t,new Set),this.nameToFirstIndex.has(e.id.name)||this.nameToFirstIndex.set(e.id.name,t),t}addDependency(e,t,n){let i=this.nameToFirstIndex.get(e),s=this.nameToFirstIndex.get(t);i!==void 0&&s!==void 0&&this.edges.get(i)?.add(s)}addDependencyByIndex(e,t){this.edges.get(e)?.add(t)}getPackage(e){let t=this.nameToFirstIndex.get(e);return t!==void 0?this.packages[t]:void 0}getAllPackages(){return this.packages}createIds(){let e=new Map,t=new Map;for(let n=0;n<this.packages.length;n++){let i=this.packages[n];if(!i)continue;let s=i.id.name,o=e.get(s)??0,a=o===0?s:`${s}_${o}`;t.set(n,a),e.set(s,o+1)}return t}getPackageByIndex(e){return this.packages[e]}getImmediateDependenciesOf(e){return this.edges.get(e)||new Set}getImmediateDependencies(e){let t=this.nameToFirstIndex.get(e);if(t===void 0)return new Set;let n=this.edges.get(t)||new Set,i=new Set;for(let s of n)this.packages[s]&&i.add(this.packages[s].id.name);return i}getTransitiveDependencies(e){let t=new Set,n=new Set,i=s=>{if(n.has(s))return;n.add(s),t.add(s);let o=this.nameToFirstIndex.get(s);if(o!==void 0){let a=this.edges.get(o);if(a)for(let r of a)this.packages[r]&&i(this.packages[r].id.name)}};return i(e),t.delete(e),t}topologicalOrder(){let e=new Set,t=[],n=i=>{if(e.has(i))return;e.add(i);let s=this.nameToFirstIndex.get(i);if(s!==void 0){let o=this.edges.get(s);if(o){let a=Array.from(o).map(r=>this.packages[r]?.id.name).filter(r=>r!==void 0).sort();for(let r of a)n(r)}}t.push(i)};return n(this.root),t.filter(i=>i!==this.root)}compilerInputOrder(){let e=new Set,t=[],n=a=>{if(e.has(a))return;e.add(a);let r=this.edges.get(a);if(r){let p=Array.from(r).sort((c,g)=>{let d=this.packages[c]?.id.name||"",l=this.packages[g]?.id.name||"";return d.localeCompare(l)});for(let c of p)n(c)}t.push(a)},i=this.nameToFirstIndex.get(this.root)??0;n(i);let s=this.createIds();return t.map(a=>s.get(a)||this.packages[a]?.id.name||"")}compilerInputOrderWithIndices(){let e=new Map,t=(g,d)=>{let l=this.packages[g];if(!l)return;let f=l.manifest.originalId||l.manifest.publishedAt||l.id.name,h=e.get(f);if(h&&h.depth<=d)return;e.set(f,{depth:d,idx:g});let m=this.edges.get(g);if(m)for(let v of m)t(v,d+1)},n=this.nameToFirstIndex.get(this.root)??0;t(n,0);let i=new Set,s=[],o=g=>{if(i.has(g)||(i.add(g),!this.packages[g]))return;let l=this.edges.get(g);if(l){let f=Array.from(l).sort((h,m)=>{let v=this.packages[h]?.id.name||"",k=this.packages[m]?.id.name||"";return v.localeCompare(k)});for(let h of f){let m=this.packages[h];if(!m)continue;let v=m.manifest.originalId||m.manifest.publishedAt||m.id.name,k=e.get(v);k&&o(k.idx)}}s.push(g)};o(n);let a=[],r=new Set;for(let g of s)r.has(g)||(r.add(g),a.push(g));let p=this.createIds();return{ids:a.map(g=>p.get(g)||this.packages[g]?.id.name||""),indices:a}}allPackagesOrderWithIndices(){let e=new Set,t=[],n=a=>{if(e.has(a)||(e.add(a),!this.packages[a]))return;let p=this.edges.get(a);if(p)for(let c of p)n(c);t.push(a)},i=this.nameToFirstIndex.get(this.root)??0;n(i);let s=this.createIds();return{ids:t.map(a=>s.get(a)||this.packages[a]?.id.name||""),indices:t}}topologicalOrderDFS(){let e=new Set,t=[],n=i=>{if(e.has(i))return;e.add(i);let s=this.nameToFirstIndex.get(i);if(s!==void 0){let o=this.edges.get(s);if(o)for(let a of o)this.packages[a]&&n(this.packages[a].id.name)}t.push(i)};n(this.root);for(let i of this.packages)n(i.id.name);return t}detectCycle(){let e=new Set,t=new Set,n=new Map,i=s=>{e.add(s),t.add(s);let o=this.nameToFirstIndex.get(s);if(o!==void 0){let a=this.edges.get(o);if(a)for(let r of a){let p=this.packages[r]?.id.name;if(p)if(e.has(p)){if(t.has(p)){let c=[p],g=s;for(;g!==p;)c.unshift(g),g=n.get(g);return c.unshift(p),c}}else{n.set(p,s);let c=i(p);if(c)return c}}}return t.delete(s),null};for(let s of this.packages)if(!e.has(s.id.name)){let o=i(s.id.name);if(o)return o}return null}getRootPackage(){return this.getPackage(this.root)}getRootName(){return this.root}};var L=class{constructor(e,t={}){this.unifiedAddressTable=new Map;this.packageResolvedTables=new Map;this.graph=e,this.buildConfig=t}async resolve(){let t=[this.graph.getRootName(),...this.graph.topologicalOrder()];for(let n of t){let i=this.graph.getPackage(n);if(i)for(let[s,o]of Object.entries(i.manifest.addresses)){let a=this.normalizeAddress(o);this.unifiedAddressTable.has(s)&&this.unifiedAddressTable.get(s)!==a||this.unifiedAddressTable.set(s,a)}}for(let n of this.graph.getAllPackages()){let i={};for(let[s,o]of this.unifiedAddressTable.entries())i[s]=o;this.packageResolvedTables.set(n.id.name,i),n.resolvedTable=i}}normalizeAddress(e){if(!e)return e;let t=e.trim();return t.startsWith("0x")&&(t=t.slice(2)),/^[0-9a-fA-F]+$/.test(t)?"0x"+t.padStart(64,"0"):e}getUnifiedAddressTable(){let e={};for(let[t,n]of this.unifiedAddressTable.entries())e[t]=n;return e}getPackageResolvedTable(e){return this.packageResolvedTables.get(e)}getGraph(){return this.graph}topologicalOrder(){return this.graph.topologicalOrder()}compilerInputOrder(){return this.graph.compilerInputOrder()}getRootName(){return this.graph.getRootName()}getPackage(e){return this.graph.getPackage(e)}getImmediateDependencies(e){return this.graph.getImmediateDependencies(e)}getPackageByIndex(e){return this.graph.getPackageByIndex(e)}compilerInputOrderWithIndices(){return this.graph.compilerInputOrderWithIndices()}allPackagesOrderWithIndices(){return this.graph.allPackagesOrderWithIndices()}};var _=class{constructor(e){this.dependencies=[];this.lockfileDependencies=[];this.resolvedGraph=e,this.rootPackageName=e.getRootName()}async compute(e){if(!this.resolvedGraph.getPackage(this.rootPackageName))throw new Error(`Root package '${this.rootPackageName}' not found`);let n=this.resolvedGraph.getImmediateDependencies(this.rootPackageName),{ids:i,indices:s}=this.resolvedGraph.compilerInputOrderWithIndices(),o=new Map;for(let p=0;p<i.length;p++){let c=i[p],g=s[p],d=this.resolvedGraph.getPackageByIndex(g);if(!d)continue;let l=d.id.name;if(l===this.rootPackageName)continue;let f=e.has(l);console.log(`[Compile] pkgId=${c}, pkgName=${l}, hasFiles=${f}, manifestName=${d.manifest.name}`);let h=e.get(l)||{},m=this.extractSourcePaths(l,h),v=d.manifest.edition||"legacy",k=d.manifest.latestPublishedId||d.manifest.publishedAt||d.manifest.originalId||d.resolvedTable?.[l],b=d.manifest.originalId;!b&&d.manifest.publishedAt&&(b=d.manifest.publishedAt),b||(b="0x0000000000000000000000000000000000000000000000000000000000000000",k||(k=b)),o.set(l,b),o.set(l.toLowerCase(),b);let P={...d.resolvedTable||{}};for(let[w,T]of Object.entries(P)){let A=o.get(w)||o.get(w.toLowerCase());A&&(P[w]=A)}b&&l!=="Sui"&&l!=="MoveStdlib"&&(P[l]=b,P[l.toLowerCase()]=b);let R=d.id.source,I={type:R.type,git:R.git,rev:R.rev,subdir:R.subdir,local:R.local},S=Object.keys(d.manifest.dependencies||{}),y={name:c,isImmediate:n.has(l),sourcePaths:m,addressMapping:P,compilerConfig:{edition:v,flavor:"sui"},moduleFormat:m.length>0?"Source":"Bytecode",edition:v,publishedIdForOutput:k,source:I,manifestDeps:S,manifest:{name:d.manifest.name,dependencies:d.manifest.dependencies},depAliasToPackageName:d.depAliasToPackageName};this.dependencies.push(y)}let{ids:a,indices:r}=this.resolvedGraph.allPackagesOrderWithIndices();for(let p=0;p<a.length;p++){let c=a[p],g=r[p],d=this.resolvedGraph.getPackageByIndex(g);if(!d)continue;let l=d.id.name;if(l===this.rootPackageName)continue;let f=e.get(l)||{},h=this.extractSourcePaths(l,f),m=d.manifest.edition||"legacy",v=d.manifest.latestPublishedId||d.manifest.publishedAt||d.manifest.originalId||d.resolvedTable?.[l],k=d.id.source,b={type:k.type,git:k.git,rev:k.rev,subdir:k.subdir,local:k.local},P=Object.keys(d.manifest.dependencies),R={};for(let[S,y]of Object.entries(d.manifest.addresses))y&&(R[S]=y);d.manifest.originalId&&(R[l]=d.manifest.originalId);let I={name:c,isImmediate:n.has(l),sourcePaths:h,addressMapping:R,compilerConfig:{edition:m,flavor:"sui"},moduleFormat:h.length>0?"Source":"Bytecode",edition:m,publishedIdForOutput:v,source:b,manifestDeps:P,manifest:{name:d.manifest.name,dependencies:d.manifest.dependencies},depAliasToPackageName:d.depAliasToPackageName};this.lockfileDependencies.push(I)}}getDependencyAddress(e){return this.dependencies.find(t=>t.name===e)?.publishedIdForOutput}extractSourcePaths(e,t){return Object.keys(t).filter(i=>i.endsWith("Move.toml")||i.endsWith("Move.lock")?!1:i.endsWith(".move"))}toPackageGroupedFormat(e){let t=[];for(let n of this.dependencies){let i=e.get(n.name)||{},s={};for(let[o,a]of Object.entries(i)){if(o.endsWith("Move.lock"))continue;let r=`dependencies/${n.name}/${o}`;o.endsWith("Move.toml")?s[r]=this.reconstructDependencyMoveToml(n.name,a,n.edition,n.addressMapping):s[r]=a}t.push({name:n.name,files:s,edition:n.edition,addressMapping:n.addressMapping,publishedIdForOutput:n.publishedIdForOutput,source:n.source,manifestDeps:n.manifestDeps,manifest:n.manifest,depAliasToPackageName:n.depAliasToPackageName})}return t}toPackageGroupedFormatForLockfile(e){let t=[];for(let n of this.lockfileDependencies){let i=n.name.replace(/_\d+$/,""),s=e.get(i)||{},o={};for(let[a,r]of Object.entries(s)){if(a.endsWith("Move.lock"))continue;let p=`dependencies/${n.name}/${a}`;o[p]=r}t.push({name:n.name,files:o,edition:n.edition,addressMapping:n.addressMapping,publishedIdForOutput:n.publishedIdForOutput,source:n.source,manifestDeps:n.manifestDeps,manifest:n.manifest,depAliasToPackageName:n.depAliasToPackageName})}return t}reconstructDependencyMoveToml(e,t,n,i){let s=(t||"").split(`
|
|
2
|
+
`),o=[],a="none";for(let c of s){let g=c.trim();if(g.startsWith("[")){g.startsWith("[package]")?a="package":g.startsWith("[addresses]")?a="addresses":g.startsWith("[dependencies")||g.startsWith("[dev-dependencies")?a="dependencies":(a="other",o.push(c));continue}if(a==="package")(g.startsWith("name")||g.startsWith("version")||g.startsWith("edition")||g.startsWith("published-at")||g.startsWith("original-published-id"))&&(g.startsWith("published-at")||g.startsWith("original-published-id"))&&o.push(c);else{if(a==="addresses")continue;if(a==="dependencies")continue;a!=="none"&&o.push(c)}}let r=`[package]
|
|
3
|
+
`;r+=`name = "${e}"
|
|
4
|
+
`,r+=`version = "0.0.0"
|
|
5
|
+
`,r+=`edition = "${n}"
|
|
6
|
+
`,r+=`
|
|
7
|
+
`,r+=o.join(`
|
|
8
|
+
`),r+=`
|
|
9
9
|
[addresses]
|
|
10
|
-
`;let p=Object.entries(
|
|
11
|
-
`;return a}};var W=class{constructor(e,t="mainnet",i=null){this.visited=new Set;this.packageNameCache=new Map;this.packageFiles=new Map;this.fetcher=e,this.network=t,this.rootSource=i}async resolve(e,t){let i=S(e),s=i.package?.name||"RootPackage",n=i.package?.edition,r=new O(s),o=await this.buildPackage(s,this.rootSource,e,t);n&&(o.manifest.edition=n);let a=o.manifest.addresses[s];this.normalizeAddress(a||"")==="0x0000000000000000000000000000000000000000000000000000000000000000"&&o.manifest.originalId&&(o.manifest.addresses[s]=this.normalizeAddress(o.manifest.originalId)),r.addPackage(o),this.packageFiles.set(s,t);let c=await this.loadFromLockfile(r,o,t),l=Array.from(o.dependencies.keys()).filter(k=>!r.getPackage(k));(!c||l.length>0)&&await this.buildDependencyGraph(r,o);let u=r.detectCycle();if(u)throw new Error(`Dependency cycle detected: ${u.join(" \u2192 ")}`);let g=new $(r,{});await g.resolve();let m=`Move.${this.network}.toml`;for(let[k,w]of this.packageFiles)w[m]&&(w["Move.toml"]=w[m]);let f=new T(g);await f.compute(this.packageFiles);let h=g.getUnifiedAddressTable();for(let k of r.getAllPackages()){let w=k.manifest.originalId||k.manifest.publishedAt||k.manifest.latestPublishedId;if(k.manifest.name===o.manifest.name){let P=Object.keys(k.manifest.addresses).find(D=>D.toLowerCase()===k.manifest.name.toLowerCase());if(P&&k.manifest.addresses[P]){let D=this.normalizeAddress(k.manifest.addresses[P]);h[k.manifest.name]=D,h[k.manifest.name.toLowerCase()]=D;continue}}if(w&&w!=="0x0"&&!w.startsWith("0x0000000000000000000000000000000000000000000000000000000000000000")){let P=this.normalizeAddress(w);h[k.manifest.name]=P,h[k.manifest.name.toLowerCase()]=P;continue}let M=Object.keys(k.manifest.addresses).find(P=>P.toLowerCase()===k.manifest.name.toLowerCase());if(M&&k.manifest.addresses[M]){let P=this.normalizeAddress(k.manifest.addresses[M]);h[k.manifest.name]=P,h[k.manifest.name.toLowerCase()]=P;continue}}let y=this.reconstructMoveToml(i,o.manifest.dependencies,h,!0,n),v={...t};delete v["Move.lock"],v["Move.toml"]=y;let b=f.toPackageGroupedFormat(this.packageFiles);return{files:JSON.stringify(v),dependencies:JSON.stringify(b)}}async buildPackage(e,t,i,s){let n=S(i),r=s["Move.lock"],o=this.getChainIdForNetwork(this.network),a=this.resolvePublishedAt(i,r,o,this.network),p=a.latestId?this.normalizeAddress(a.latestId):void 0,c=s["Published.toml"],l,u;if(c)try{let I=S(c).published?.[this.network];I&&(I["published-at"]&&(l=this.normalizeAddress(I["published-at"])),I["original-id"]&&(u=this.normalizeAddress(I["original-id"])))}catch{}a.error;let g={name:n.package?.name||e,version:n.package?.version||"0.0.0",edition:n.package?.edition,publishedAt:l||a.publishedAt,originalId:u||a.originalId,latestPublishedId:p,addresses:n.addresses||{},dependencies:this.injectImplicitDependencies(n.dependencies||{},n.package?.name),devDependencies:n["dev-dependencies"]},m=Object.keys(g.addresses).find(w=>w.toLowerCase()===g.name.toLowerCase());if(m&&g.addresses[m]){let w=this.normalizeAddress(g.addresses[m]);w!=="0x0000000000000000000000000000000000000000000000000000000000000000"&&(g.originalId=w)}let f=g.originalId||g.publishedAt,h=f&&f!=="0x0"?this.normalizeAddress(f):void 0,y=g.addresses[g.name]||(m?g.addresses[m]:void 0),v=y?this.normalizeAddress(y):void 0;h?y||(g.addresses[g.name]=h):v?g.addresses[g.name]=v:g.addresses[g.name]="0x0";let b=new Map;if(g.dependencies)for(let[w,I]of Object.entries(g.dependencies)){let M=this.parseDependencyInfo(I);M&&b.set(w,M)}return{id:{name:g.name,version:g.version,source:t||{type:"local"}},manifest:g,dependencies:b,devDependencies:new Map}}parseDependencyInfo(e){if(!e)return null;let t={source:{type:"local"}};if(e.git&&e.rev)t.source={type:"git",git:e.git,rev:e.rev,subdir:e.subdir},e.isImplicit&&(t.source.isImplicit=!0);else if(e.local)t.source={type:"local",local:e.local};else return null;if(e["addr-subst"]||e.addr_subst){let i=e["addr-subst"]||e.addr_subst,s={};for(let[n,r]of Object.entries(i))typeof r=="string"&&(r.startsWith("0x")||/^[0-9a-fA-F]+$/.test(r)?s[n]={type:"assign",address:r}:s[n]={type:"renameFrom",name:r});Object.keys(s).length>0&&(t.subst=s)}return t}async buildDependencyGraph(e,t){let i=Array.from(t.dependencies.entries()).sort(([,s],[,n])=>{let r=s.source.isImplicit?1:0;return(n.source.isImplicit?1:0)-r});for(let[s,n]of i){if(n.source.type==="local")if(t.id.source.type==="git"&&n.source.local){let u=t.id.source.subdir||"",g=n.source.local,m=this.resolveRelativePath(u,g);n.source={type:"git",git:t.id.source.git,rev:t.id.source.rev,subdir:m}}else continue;if(n.source.type!=="git")continue;let r=`${n.source.git}|${n.source.rev}|${n.source.subdir||""}`;if(this.visited.has(r)){let u=this.findPackageBySource(e,n.source);u&&e.addDependency(t.id.name,u.id.name,n);continue}this.visited.add(r);let o=n.source.subdir;!o&&n.source.git&&this.isSuiRepo(n.source.git)&&(o=this.inferSuiFrameworkSubdir(s),o&&(n.source.subdir=o));let a=await this.fetcher.fetch(n.source.git,n.source.rev,o),p=null,c=`Move.${this.network}.toml`;for(let[u,g]of Object.entries(a))if(u.endsWith(c)){p=g;break}if(!p){for(let[u,g]of Object.entries(a))if(u.endsWith("Move.toml")){p=g;break}}if(!p)continue;let l=await this.buildPackage(s,n.source,p,a);if(!this.lockfileVersion||this.lockfileVersion<4){let u=this.packageNameCache.get(l.manifest.name);if(u){let g=u.isImplicit,m=n.source.isImplicit;if(g&&!m)continue;if(!(!g&&m)){if(JSON.stringify(u)!==JSON.stringify(n.source)){let f=h=>JSON.stringify(h);throw new Error([`Conflicting versions of package '${l.manifest.name}' found`,`Existing: ${f(u)}`,`New: ${f(n.source)}`,`When resolving dependencies for '${t.id.name}' -> '${s}'`].join(`
|
|
12
|
-
`))}}}this.packageNameCache.set(l.manifest.name,n.source)}l.manifest.edition||(l.manifest.edition="legacy"),e.addPackage(l),e.addDependency(t.id.name,l.id.name,n),this.packageFiles.set(l.id.name,a),await this.buildDependencyGraph(e,l)}}getChainIdForNetwork(e){return{mainnet:"35834a8a",testnet:"4c78adac",devnet:"2",localnet:"localnet"}[e]||e}resolvePublishedAt(e,t,i,s){let n=S(e),r=n.package?.published_at||n.package?.["published-at"],o=r&&r!=="0x0"?r:void 0,a=o?this.normalizeAddress(o):void 0,p=n.package?.["original-id"],c,l;if(t)try{let f=S(t),h=i&&f.env?.[i]||f.env?.[s];h&&(h["original-published-id"]&&(c=this.normalizeAddress(h["original-published-id"])),h["latest-published-id"]&&(l=this.normalizeAddress(h["latest-published-id"])))}catch{}let u=a||l||c;return{publishedAt:u,originalId:p||c,latestId:u}}findPackageBySource(e,t){for(let i of e.getAllPackages()){let s=i.id.source;if(s.type===t.type&&s.git===t.git&&s.rev===t.rev&&s.subdir===t.subdir)return i}}resolveRelativePath(e,t){let i=e?e.split("/").filter(Boolean):[],s=t.split("/").filter(Boolean),n=[...i];for(let r of s)r===".."?n.length>0&&n.pop():r!=="."&&n.push(r);return n.join("/")}async computeManifestDigest(e){let i=new TextEncoder().encode(e),s=await crypto.subtle.digest("SHA-256",i);return Array.from(new Uint8Array(s)).map(o=>o.toString(16).padStart(2,"0")).join("").toUpperCase()}async loadFromLockfile(e,t,i){let s=i["Move.lock"];if(!s)return!1;let n=S(s);this.lockfileVersion=n.move?.version;let r=n.move?.version;return r===3?await this.loadFromLockfileV3(e,n,t):r&&r>=4?n.pinned?await this.loadFromLockfileV4(e,n,i,t):!1:await this.loadFromLockfileV0(e,n,t)}async loadFromLockfileV0(e,t,i){let s=t.move?.package;if(!s||!Array.isArray(s))return!1;let n=Array.isArray(t.move?.dependencies)?t.move.dependencies.map(c=>c.name||c.id||c).filter(Boolean):[],r=s.map(c=>c.name||c.id).filter(Boolean),o=[...n,...r.filter(c=>!n.includes(c))],a=new Map,p=new Map;for(let c of s){let l=c.id||c.name,u=c.source;if(!l||!u)continue;let g=null;if(u.git&&u.rev)g={type:"git",git:u.git,rev:u.rev,subdir:u.subdir};else if(u.local&&this.rootSource?.type==="git"){let y=this.resolveRelativePath(this.rootSource.subdir||"",u.local);g={type:"git",git:this.rootSource.git,rev:this.rootSource.rev,subdir:y}}else continue;let m=await this.fetcher.fetch(g.git,g.rev,g.subdir);if(Object.keys(m).length===0)continue;let f=m["Move.toml"];if(!f)continue;let h=await this.buildPackage(l,g,f,m);a.set(l,h),p.set(h.manifest.name,h),this.packageFiles.set(h.manifest.name,m),e.addPackage(h)}o.length&&e.setLockfileOrder(o);for(let c of s){let l=c.id||c.name,u=a.get(l);if(!u)continue;let g=c.dependencies;if(g&&Array.isArray(g))for(let m of g){let f=m.id||m.name,h=a.get(f)||p.get(f);if(h){let y={source:h.id.source};e.addDependency(u.id.name,h.id.name,y)}}}for(let c of i.dependencies.keys()){let l=p.get(c);if(l){let u=i.dependencies.get(c);e.addDependency(i.id.name,l.id.name,u)}}return a.size>0}async loadFromLockfileV3(e,t,i){let s=t.move?.package;if(!s||!Array.isArray(s))return!1;let n=new Map,r=new Map,o=[];for(let a of s)a.id&&r.set(a.id,a);for(let a of s){let p=a.id,c=a.source;o.push(p);let l=null;if(c?.git&&c.rev)l={type:"git",git:c.git,rev:c.rev,subdir:c.subdir};else if(c?.local&&this.rootSource?.type==="git"){let f=this.resolveRelativePath(this.rootSource.subdir||"",c.local);l={type:"git",git:this.rootSource.git,rev:this.rootSource.rev,subdir:f}}else continue;if(!l.git||!l.rev)continue;let u=await this.fetcher.fetch(l.git,l.rev,l.subdir);if(Object.keys(u).length===0)continue;let g=u["Move.toml"];if(!g)continue;let m=await this.buildPackage(p,l,g,u);n.set(p,m),this.packageFiles.set(m.manifest.name,u),e.addPackage(m)}e.setLockfileOrder(o);for(let a of s){let p=a.id,c=n.get(p);if(!c)continue;let l=a.dependencies;if(!(!l||!Array.isArray(l)))for(let u of l){let g=u.id,m=n.get(g);if(!m){let f=r.get(g);if(f?.source?.local&&c.id.source.type==="git"){let h=this.resolveRelativePath(c.id.source.subdir||"",f.source.local),y={type:"git",git:c.id.source.git,rev:c.id.source.rev,subdir:h},v=await this.fetcher.fetch(y.git,y.rev,y.subdir),b=v["Move.toml"];if(b){let k=await this.buildPackage(g,y,b,v);n.set(g,k),this.packageFiles.set(k.manifest.name,v),e.addPackage(k),m=k}}}if(m){let f={source:m.id.source};e.addDependency(c.id.name,m.id.name,f)}}}for(let a of i.dependencies.keys()){let p=n.get(a);if(p){let c=i.dependencies.get(a);e.addDependency(i.id.name,p.id.name,c)}}return!0}async loadFromLockfileV4(e,t,i,s){let n=t.pinned?.[this.network];if(!n)return!1;let r=i["Move.toml"];if(r&&t.move?.manifest_digest&&await this.computeManifestDigest(r)!==t.move.manifest_digest)return!1;let o=new Map,a=new Map,p=[];for(let[c,l]of Object.entries(n)){p.push(c);let u=this.lockfileSourceToDependencySource(l.source);if(!u)continue;let g=await this.fetchFromSource(u);if(!g)return!1;let m=g["Move.toml"];if(!m||l["manifest-digest"]&&await this.computeManifestDigest(m)!==l["manifest-digest"])return!1;let f=await this.buildPackage(c,u,m,g);o.set(c,f),a.set(f.manifest.name,f),this.packageFiles.set(f.manifest.name,g),(u.type!=="local"||!("root"in l.source))&&e.addPackage(f)}p.length>0&&e.setLockfileOrder(p);for(let[c,l]of Object.entries(n)){let u=o.get(c);if(u&&l.deps)for(let[g,m]of Object.entries(l.deps)){let f=o.get(m);if(f){let h=u.dependencies.get(g);h&&e.addDependency(u.id.name,f.id.name,h)}}}if(t.move?.dependencies&&Array.isArray(t.move.dependencies))for(let c of t.move.dependencies){let l=c.id,u=o.get(l);if(u){let g={source:u.id.source};e.addDependency(s.id.name,u.id.name,g)}}else for(let c of s.dependencies.keys()){let l=a.get(c)||o.get(c);if(l){let u=s.dependencies.get(c);e.addDependency(s.id.name,l.id.name,u)}}return!0}lockfileSourceToDependencySource(e){return"git"in e?{type:"git",git:e.git,rev:e.rev,subdir:e.subdir}:"local"in e?{type:"local",local:e.local}:"root"in e?{type:"local"}:null}async fetchFromSource(e){if(e.type==="git"&&e.git&&e.rev)try{return await this.fetcher.fetch(e.git,e.rev,e.subdir)}catch{return null}return null}reconstructMoveToml(e,t,i,s,n){let o=`[package]
|
|
10
|
+
`;let p=Object.entries(i);for(let[c,g]of p)r+=`${c} = "${g}"
|
|
11
|
+
`;return r}};var K={version:"1.63.3",commit:"04dd28d5c5d92bff685ddfecb86f8acce18ce6df",tag:"framework/mainnet"};var pe=K.commit,B=class{constructor(e,t="mainnet",n=null){this.visited=new Set;this.packageNameToSuffix=new Map;this.repoRevToSuiRev=new Map;this.suiTagToShaCache=new Map;this.packageFiles=new Map;this.diamondPackages=new Map;this.fetcher=e,this.network=t,this.rootSource=n}async resolve(e,t){let n=$(e),i=n.package?.name||"RootPackage",s=n.package?.edition,o=new O(i),a=await this.buildPackage(i,this.rootSource,e,t,!0);s&&(a.manifest.edition=s);let r=a.manifest.addresses[i];this.normalizeAddress(r||"")==="0x0000000000000000000000000000000000000000000000000000000000000000"&&a.manifest.originalId&&(a.manifest.addresses[i]=this.normalizeAddress(a.manifest.originalId)),o.addPackage(a),this.packageFiles.set(i,t),await this.loadFromLockfile(o,a,t)||await this.buildDependencyGraph(o,a);let g=o.detectCycle();if(g)throw new Error(`Dependency cycle detected: ${g.join(" \u2192 ")}`);let d=new L(o,{});await d.resolve();let l=`Move.${this.network}.toml`;for(let[P,R]of this.packageFiles)R[l]&&(R["Move.toml"]=R[l]);let f=new _(d);await f.compute(this.packageFiles);let h=d.getUnifiedAddressTable();for(let P of o.getAllPackages()){let R=P.manifest.originalId||P.manifest.publishedAt||P.manifest.latestPublishedId;if(P.manifest.name===a.manifest.name){let y=Object.keys(P.manifest.addresses).find(w=>w.toLowerCase()===P.manifest.name.toLowerCase());if(y&&P.manifest.addresses[y]){let w=this.normalizeAddress(P.manifest.addresses[y]);h[P.manifest.name]=w,h[P.manifest.name.toLowerCase()]=w;continue}}if(R&&R!=="0x0"&&!R.startsWith("0x0000000000000000000000000000000000000000000000000000000000000000")){let y=this.normalizeAddress(R);h[P.manifest.name]=y,h[P.manifest.name.toLowerCase()]=y;continue}let S=Object.keys(P.manifest.addresses).find(y=>y.toLowerCase()===P.manifest.name.toLowerCase());if(S&&P.manifest.addresses[S]){let y=this.normalizeAddress(P.manifest.addresses[S]);h[P.manifest.name]=y,h[P.manifest.name.toLowerCase()]=y;continue}}let m=this.reconstructMoveToml(n,a.manifest.dependencies,h,!0,s),v={...t};delete v["Move.lock"],v["Move.toml"]=m;let k=f.toPackageGroupedFormat(this.packageFiles),b=f.toPackageGroupedFormatForLockfile(this.packageFiles);return{files:JSON.stringify(v),dependencies:JSON.stringify(k),lockfileDependencies:JSON.stringify(b)}}async buildPackage(e,t,n,i,s=!1){let o=$(n),a=i["Move.lock"],r=this.getChainIdForNetwork(this.network),p=this.resolvePublishedAt(n,a,r,this.network),c=p.latestId?this.normalizeAddress(p.latestId):void 0,g=i["Published.toml"],d,l;if(g)try{let S=$(g).published?.[this.network];S&&(S["published-at"]&&(d=this.normalizeAddress(S["published-at"])),S["original-id"]&&(l=this.normalizeAddress(S["original-id"])))}catch{}p.error;let f={name:o.package?.name||e,version:o.package?.version||"0.0.0",edition:o.package?.edition,publishedAt:d||p.publishedAt,originalId:l||p.originalId,latestPublishedId:c,addresses:o.addresses||{},dependencies:s?this.injectImplicitDependencies(o.dependencies||{},o.package?.name):o.dependencies||{},devDependencies:o["dev-dependencies"]},h=Object.keys(f.addresses).find(I=>I.toLowerCase()===f.name.toLowerCase());if(h&&f.addresses[h]){let I=this.normalizeAddress(f.addresses[h]);I!=="0x0000000000000000000000000000000000000000000000000000000000000000"&&(f.originalId=I)}let m=f.originalId||f.publishedAt,v=m&&m!=="0x0"?this.normalizeAddress(m):void 0,k=f.addresses[f.name]||(h?f.addresses[h]:void 0),b=k?this.normalizeAddress(k):void 0;v?k?k==="0x0000000000000000000000000000000000000000000000000000000000000000"&&(f.addresses[f.name]=v):f.addresses[f.name]=v:b?f.addresses[f.name]=b:f.addresses[f.name]="0x0";let P=new Map;if(f.dependencies)for(let[I,S]of Object.entries(f.dependencies)){let y=this.parseDependencyInfo(S);y&&P.set(I,y)}return{id:{name:f.name,version:f.version,source:t||{type:"local"}},manifest:f,dependencies:P,devDependencies:new Map}}parseDependencyInfo(e){if(!e)return null;let t={source:{type:"local"}};if(e.git&&e.rev)t.source={type:"git",git:e.git,rev:e.rev,subdir:e.subdir},e.isImplicit&&(t.source.isImplicit=!0);else if(e.local)t.source={type:"local",local:e.local};else return null;if(e["addr-subst"]||e.addr_subst){let n=e["addr-subst"]||e.addr_subst,i={};for(let[s,o]of Object.entries(n))typeof o=="string"&&(o.startsWith("0x")||/^[0-9a-fA-F]+$/.test(o)?i[s]={type:"assign",address:o}:i[s]={type:"renameFrom",name:o});Object.keys(i).length>0&&(t.subst=i)}return t}async buildDependencyGraph(e,t){let n=Array.from(t.dependencies.entries()).sort(([i,s],[o,a])=>{let r=s.source.isImplicit?1:0,p=a.source.isImplicit?1:0;return r!==p?p-r:i<o?-1:i>o?1:0});for(let[i,s]of n){if(s.source.type==="local")if(t.id.source.type==="git"&&s.source.local){let m=t.id.source.subdir||"",v=s.source.local,k=this.resolveRelativePath(m,v);s.source={type:"git",git:t.id.source.git,rev:t.id.source.rev,subdir:k}}else continue;if(s.source.type!=="git")continue;if(s.source.git&&this.isSuiRepo(s.source.git)){if(!s.source.subdir){let b=this.inferSuiFrameworkSubdir(i);b&&(s.source.subdir=b)}let m=t.id.source.type==="git"?`${t.id.source.git}|${t.id.source.rev}`:null;if(m){let b=this.repoRevToSuiRev.get(m);b&&s.source.rev!==b&&(s.source.rev=b)}let v=`${s.source.git}|${s.source.rev}|${s.source.subdir||""}`,k=this.suiTagToShaCache.get(v);if(k)s.source.rev=k;else{await this.fetcher.fetch(s.source.git,s.source.rev,s.source.subdir);let b=this.fetcher.getResolvedSha(s.source.git,s.source.rev);b&&b!==s.source.rev&&(this.suiTagToShaCache.set(v,b),s.source.rev=b)}}let o=`${s.source.git}|${s.source.rev}|${s.source.subdir||""}`;if(this.visited.has(o)){let m=this.findPackageBySource(e,s.source);m&&(e.addDependency(t.id.name,m.id.name,s),t.depAliasToPackageName||(t.depAliasToPackageName={}),t.depAliasToPackageName[i]=m.id.name,t.depAliasToSource||(t.depAliasToSource={}),t.depAliasToSource[i]={name:m.id.name,git:s.source.git,rev:s.source.rev,subdir:s.source.subdir});continue}this.visited.add(o);let a=s.source.subdir,r=await this.fetcher.fetch(s.source.git,s.source.rev,a),p=this.fetcher.getResolvedSha(s.source.git,s.source.rev);if(p&&(s.source.rev=p),s.source.git&&this.isSuiRepo(s.source.git)){let m=t.id.source.type==="git"?`${t.id.source.git}|${t.id.source.rev}`:null;m&&s.source.rev&&(this.repoRevToSuiRev.has(m)||this.repoRevToSuiRev.set(m,s.source.rev))}let c=null,g=`Move.${this.network}.toml`;for(let[m,v]of Object.entries(r))if(m.endsWith(g)){c=v;break}if(!c){for(let[m,v]of Object.entries(r))if(m.endsWith("Move.toml")){c=v;break}}if(!c)continue;let d=await this.buildPackage(i,s.source,c,r),l=d.manifest.name,f=this.packageNameToSuffix.get(l)??0,h=f===0?l:`${l}_${f}`;this.packageNameToSuffix.set(l,f+1),d.id.name=h,d.manifest.edition||(d.manifest.edition="legacy"),e.addPackage(d),e.addDependency(t.id.name,d.id.name,s),t.depAliasToPackageName||(t.depAliasToPackageName={}),t.depAliasToPackageName[i]=d.id.name,t.depAliasToSource||(t.depAliasToSource={}),t.depAliasToSource[i]={name:d.id.name,git:s.source.git,rev:s.source.rev,subdir:s.source.subdir},console.log(`[V3 Files] Storing: ${d.id.name} (manifest: ${d.manifest.name})`),this.packageFiles.set(d.id.name,r),await this.buildDependencyGraph(e,d)}}getChainIdForNetwork(e){return{mainnet:"35834a8a",testnet:"4c78adac",devnet:"2",localnet:"localnet"}[e]||e}resolvePublishedAt(e,t,n,i){let s=$(e),o=s.package?.published_at||s.package?.["published-at"],a=o&&o!=="0x0"?o:void 0,r=a?this.normalizeAddress(a):void 0,p=s.package?.["original-id"],c,g;if(t)try{let h=$(t),m=n&&h.env?.[n]||h.env?.[i];m&&(m["original-published-id"]&&(c=this.normalizeAddress(m["original-published-id"])),m["latest-published-id"]&&(g=this.normalizeAddress(m["latest-published-id"])))}catch{}let d=r||g||c;return{publishedAt:d,originalId:p||c,latestId:d}}findPackageBySource(e,t){for(let n of e.getAllPackages()){let i=n.id.source;if(i.type===t.type&&i.git===t.git&&i.rev===t.rev&&i.subdir===t.subdir)return n}}resolveRelativePath(e,t){let n=e?e.split("/").filter(Boolean):[],i=t.split("/").filter(Boolean),s=[...n];for(let o of i)o===".."?s.length>0&&s.pop():o!=="."&&s.push(o);return s.join("/")}async computeManifestDigest(e){let n=new TextEncoder().encode(e),i=await crypto.subtle.digest("SHA-256",n);return Array.from(new Uint8Array(i)).map(a=>a.toString(16).padStart(2,"0")).join("").toUpperCase()}async loadFromLockfile(e,t,n){let i=n["Move.lock"];if(!i)return!1;let s=$(i);this.lockfileVersion=s.move?.version,console.log(`[Lockfile] version=${this.lockfileVersion}, hasPinned=${!!s.pinned}`);let o=s.move?.version;return o===3?!1:o&&o>=4?s.pinned?await this.loadFromLockfileV4(e,s,n,t):!1:await this.loadFromLockfileV0(e,s,t)}async loadFromLockfileV0(e,t,n){let i=t.move?.package;if(!i||!Array.isArray(i))return!1;let s=Array.isArray(t.move?.dependencies)?t.move.dependencies.map(c=>c.name||c.id||c).filter(Boolean):[],o=i.map(c=>c.name||c.id).filter(Boolean),a=[...s,...o.filter(c=>!s.includes(c))],r=new Map,p=new Map;for(let c of i){let g=c.id||c.name,d=c.source;if(!g||!d)continue;let l=null;if(d.git&&d.rev)l={type:"git",git:d.git,rev:d.rev,subdir:d.subdir};else if(d.local&&this.rootSource?.type==="git"){let k=this.resolveRelativePath(this.rootSource.subdir||"",d.local);l={type:"git",git:this.rootSource.git,rev:this.rootSource.rev,subdir:k}}else continue;let f=await this.fetcher.fetch(l.git,l.rev,l.subdir);if(Object.keys(f).length===0)continue;let h=this.fetcher.getResolvedSha(l.git,l.rev);h&&(l.rev=h);let m=f["Move.toml"];if(!m)continue;let v=await this.buildPackage(g,l,m,f);r.set(g,v),p.set(v.manifest.name,v),this.packageFiles.set(v.manifest.name,f),e.addPackage(v)}a.length&&e.setLockfileOrder(a);for(let c of i){let g=c.id||c.name,d=r.get(g);if(!d)continue;let l=c.dependencies;if(l&&Array.isArray(l))for(let f of l){let h=f.id||f.name,m=r.get(h)||p.get(h);if(m){let v={source:m.id.source};e.addDependency(d.id.name,m.id.name,v),d.depAliasToPackageName||(d.depAliasToPackageName={});let k=f.name||h;d.depAliasToPackageName[k]=m.id.name}}}for(let c of n.dependencies.keys()){let g=p.get(c);if(g){let d=n.dependencies.get(c);e.addDependency(n.id.name,g.id.name,d)}}return r.size>0}async loadFromLockfileV3(e,t,n){let i=t.move?.package;if(!i||!Array.isArray(i))return!1;let s=new Map,o=new Map,a=[];for(let r of i)r.id&&o.set(r.id,r);for(let r of i){let p=r.id,c=r.source;a.push(p);let g=null;if(c?.git&&c.rev)g={type:"git",git:c.git,rev:c.rev,subdir:c.subdir};else if(c?.local&&this.rootSource?.type==="git"){let m=this.resolveRelativePath(this.rootSource.subdir||"",c.local);g={type:"git",git:this.rootSource.git,rev:this.rootSource.rev,subdir:m}}else continue;if(!g.git||!g.rev)continue;let d=await this.fetcher.fetch(g.git,g.rev,g.subdir);if(Object.keys(d).length===0)continue;let l=this.fetcher.getResolvedSha(g.git,g.rev);l&&(g.rev=l);let f=d["Move.toml"];if(!f)continue;let h=await this.buildPackage(p,g,f,d);s.set(p,h),this.packageFiles.set(h.manifest.name,d),e.addPackage(h)}e.setLockfileOrder(a);for(let r of i){let p=r.id,c=s.get(p);if(!c)continue;let g=r.dependencies;if(!(!g||!Array.isArray(g)))for(let d of g){let l=d.id,f=s.get(l);if(!f){let h=o.get(l);if(h?.source?.local&&c.id.source.type==="git"){let m=this.resolveRelativePath(c.id.source.subdir||"",h.source.local),v={type:"git",git:c.id.source.git,rev:c.id.source.rev,subdir:m},k=await this.fetcher.fetch(v.git,v.rev,v.subdir),b=k["Move.toml"];if(b){let P=await this.buildPackage(l,v,b,k);s.set(l,P),this.packageFiles.set(P.manifest.name,k),e.addPackage(P),f=P}}}if(f){let h={source:f.id.source};e.addDependency(c.id.name,f.id.name,h),c.depAliasToPackageName||(c.depAliasToPackageName={});let m=d.name||l;c.depAliasToPackageName[m]=f.id.name}}}for(let r of n.dependencies.keys()){let p=s.get(r);if(p){let c=n.dependencies.get(r);e.addDependency(n.id.name,p.id.name,c)}}return!0}async loadFromLockfileV4(e,t,n,i){let s=t.pinned?.[this.network];if(!s)return!1;let o=n["Move.toml"];if(o&&t.move?.manifest_digest&&await this.computeManifestDigest(o)!==t.move.manifest_digest)return!1;let a=new Map,r=new Map,p=[];console.log(`[V4 Load] Loading ${Object.keys(s).length} packages from lockfile`);for(let[c,g]of Object.entries(s)){console.log(`[V4 Load] Processing: ${c}`),p.push(c);let d=this.lockfileSourceToDependencySource(g.source);if(!d)continue;if("root"in g.source){a.set(c,i),r.set(i.manifest.name,i);continue}let l=await this.fetchFromSource(d);if(!l)return!1;let f=l["Move.toml"];if(!f)return!1;let h=await this.buildPackage(c,d,f,l);h.id.name=c,a.set(c,h),r.set(c,h),console.log(`[V4 Files] Storing: ${c} (manifest: ${h.manifest.name})`),this.packageFiles.set(c,l),(d.type!=="local"||!("root"in g.source))&&e.addPackage(h)}p.length>0&&e.setLockfileOrder(p);for(let[c,g]of Object.entries(s)){let d=a.get(c);if(d&&g.deps)for(let[l,f]of Object.entries(g.deps)){let h=a.get(f);if(h){let m=d.dependencies.get(l)||{source:h.id.source};e.addDependency(d.id.name,h.id.name,m),d.depAliasToPackageName||(d.depAliasToPackageName={}),d.depAliasToPackageName[l]=h.id.name}}}if(t.move?.dependencies&&Array.isArray(t.move.dependencies))for(let c of t.move.dependencies){let g=c.id,d=a.get(g);if(d){let l={source:d.id.source};e.addDependency(i.id.name,d.id.name,l)}}else for(let c of i.dependencies.keys()){let g=r.get(c)||a.get(c);if(g){let d=i.dependencies.get(c);e.addDependency(i.id.name,g.id.name,d)}}return!0}lockfileSourceToDependencySource(e){return"git"in e?{type:"git",git:e.git,rev:e.rev,subdir:e.subdir}:"local"in e?{type:"local",local:e.local}:"root"in e?{type:"local"}:null}async fetchFromSource(e){if(e.type==="git"&&e.git&&e.rev)try{return await this.fetcher.fetch(e.git,e.rev,e.subdir)}catch{return null}return null}reconstructMoveToml(e,t,n,i,s){let a=`[package]
|
|
13
12
|
name = "${e.package.name}"
|
|
14
13
|
version = "${e.package.version}"
|
|
15
|
-
`,
|
|
16
|
-
`),
|
|
14
|
+
`,r=s||e.package.edition;if(r&&(a+=`edition = "${r}"
|
|
15
|
+
`),a+=`
|
|
17
16
|
[dependencies]
|
|
18
|
-
`,t){let c=Object.entries(t);for(let[
|
|
19
|
-
`:
|
|
20
|
-
`:
|
|
21
|
-
`)}}
|
|
17
|
+
`,t){let c=Object.entries(t);for(let[g,d]of c){let l=d;l.local?a+=`${g} = { local = "${l.local}" }
|
|
18
|
+
`:l.git&&l.rev&&(l.subdir?a+=`${g} = { git = "${l.git}", subdir = "${l.subdir}", rev = "${l.rev}" }
|
|
19
|
+
`:a+=`${g} = { git = "${l.git}", rev = "${l.rev}" }
|
|
20
|
+
`)}}a+=`
|
|
22
21
|
[addresses]
|
|
23
|
-
`;let p=Object.entries(
|
|
24
|
-
`;return
|
|
22
|
+
`;let p=Object.entries(n);for(let[c,g]of p)a+=`${c} = "${g}"
|
|
23
|
+
`;return a}normalizeAddress(e){if(!e)return e;let t=e.trim();return t.startsWith("0x")&&(t=t.slice(2)),/^[0-9a-fA-F]+$/.test(t)?"0x"+t.toLowerCase().padStart(64,"0"):e}isSuiRepo(e){return e.includes("github.com/MystenLabs/sui")}inferSuiFrameworkSubdir(e){let t={Sui:"crates/sui-framework/packages/sui-framework",MoveStdlib:"crates/sui-framework/packages/move-stdlib",SuiSystem:"crates/sui-framework/packages/sui-system",Bridge:"crates/sui-framework/packages/bridge",SuiFramework:"crates/sui-framework/packages/sui-framework"};return t[e]||t[e.toLowerCase()]}injectImplicitDependencies(e,t){return t==="Sui"||t==="MoveStdlib"||t==="SuiSystem"||t==="sui"||!e.Sui&&!e.sui&&(e.Sui={git:"https://github.com/MystenLabs/sui.git",subdir:"crates/sui-framework/packages/sui-framework",rev:pe,isImplicit:!0}),e}};async function q(u,e,t,n="mainnet",i){return new B(t,n,i||null).resolve(u,e)}var fe=4;function C(u){return u.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}function Q(u,e,t,n,i,s,o,a){let r=[];r.push("# Generated by move; do not edit"),r.push("# This file should be checked in."),r.push(""),r.push("[move]"),r.push(`version = ${fe}`),r.push("");try{let p=JSON.parse(u),c=new Map(p.map(l=>[l.name,l])),g=(l,f,h)=>{let m=f.map(S=>{let y=l?.[S];if(y?.git)return{name:S,git:y.git,subdir:y.subdir||"",rev:y.rev||"",use_environment:t};if(y?.local)return{name:S,local:y.local,use_environment:t};let w=S.toLowerCase();return w==="sui"||w==="std"||w==="movestdlib"?{name:S,system:w==="movestdlib"?"std":w,is_override:!0,use_environment:t}:{name:S,use_environment:t}}),k=f.some(S=>{let y=S.toLowerCase();return y==="sui"||y==="std"||y==="movestdlib"}),b=h.toLowerCase(),P=[],R=b==="sui"||b.startsWith("sui_")||b==="std"||b==="movestdlib"||b.startsWith("movestdlib_");!k&&!R&&(P.push({name:"sui",system:"sui",is_override:!0,use_environment:t}),P.push({name:"std",system:"std",is_override:!0,use_environment:t}));let I=[...m,...P];return JSON.stringify({deps:I})},d=[];d.push({name:e,isRoot:!0});for(let l of p)d.push({name:l.name,isRoot:!1,dep:l});d.sort((l,f)=>l.name<f.name?-1:l.name>f.name?1:0);for(let l of d){let f=`pinned.${t}.${l.name}`;r.push(`[${f}]`);let h=l.isRoot?s?Object.keys(s).map(R=>s[R]):[]:[],m=l.isRoot?n||[]:l.dep.depAliasToPackageName?Object.keys(l.dep.depAliasToPackageName):l.dep.manifestDeps||Object.keys(l.dep.manifest?.dependencies||{}),v=m.some(R=>{let I=R.toLowerCase();return I==="sui"||I==="std"||I==="movestdlib"}),k=l.name.toLowerCase(),b=[],P=k==="sui"||k.startsWith("sui_")||k==="std"||k==="movestdlib"||k.startsWith("movestdlib_");if(!v&&!P&&(b.push("sui"),b.push("std")),l.isRoot){r.push("source = { root = true }"),r.push(`use_environment = "${t}"`);let R=i?i(g(s,m,e)):"";r.push(`manifest_digest = "${R}"`);let I=[...m,...b].sort();if(I.length>0){let S=o||{},y=I.map(w=>{let T=S[w]||w;return w==="sui"&&!S[w]&&c.has("Sui")&&(T="Sui"),w==="std"&&!S[w]&&c.has("MoveStdlib")&&(T="MoveStdlib"),`${w} = "${T}"`});r.push(`deps = { ${y.join(", ")} }`)}else r.push("deps = {}")}else{let R=l.dep,I=R.source;I?.type==="git"&&I?.git&&I?.rev?r.push(`source = { git = "${C(I?.git)}", subdir = "${C(I?.subdir||"")}", rev = "${C(I?.rev)}" }`):I?.type==="local"&&I?.local?r.push(`source = { local = "${C(I?.local)}" }`):r.push("source = { root = true }"),r.push(`use_environment = "${t}"`);let S=i?i(g(R.manifest?.dependencies,m,l.name)):"";r.push(`manifest_digest = "${S}"`);let y=[...m,...b].sort();if(y.length>0){let w=R.depAliasToPackageName||{},T=y.map(A=>{let x=w[A]||A;return A==="sui"&&!w[A]&&c.has("Sui")&&(x="Sui"),A==="std"&&!w[A]&&c.has("MoveStdlib")&&(x="MoveStdlib"),`${A} = "${x}"`});r.push(`deps = { ${T.join(", ")} }`)}else r.push("deps = {}")}r.push("")}}catch(p){console.error("Lockfile generation error:",p),r.push(`[pinned.${t}.${e}]`),r.push("source = { root = true }"),r.push(`use_environment = "${t}"`),r.push('manifest_digest = ""'),r.push("deps = {}"),r.push("")}if(a)try{let p=a.split(`
|
|
24
|
+
`),c=[],g="",d=!1;for(let l of p){let f=l.match(/^\[pinned\.([^.]+)\./);f?(d&&c.length>0&&(r.push(...c),r.push("")),g=f[1],d=g!==t,c=d?[l]:[]):d&&(l.trim()!==""||c.length>0)&&c.push(l)}d&&c.length>0&&(r.push(...c),r.push(""))}catch{}return r.join(`
|
|
25
|
+
`)}function V(u,e,t){try{let n=$(u);if((n.move?.version??0)>3)return null;let s=n.env;if(!s||typeof s!="object")return null;let o=[];for(let[r,p]of Object.entries(s)){if(!p||typeof p!="object")continue;let c=p,g=c["chain-id"],d=c["original-published-id"],l=c["latest-published-id"],f=c["published-version"];if(!g||!d||!l||!f)continue;let h=parseInt(f,10);isNaN(h)||o.push({network:r,chainId:g,originalId:X(d),publishedAt:X(l),version:h})}if(o.length===0)return null;o.sort((r,p)=>r.network.localeCompare(p.network));let a=["# Generated by Move","# This file contains metadata about published versions of this package in different environments","# This file SHOULD be committed to source control",""];for(let r of o)a.push(`[published.${r.network}]`),a.push(`chain-id = "${r.chainId}"`),a.push(`published-at = "${r.publishedAt}"`),a.push(`original-id = "${r.originalId}"`),a.push(`version = ${r.version}`),a.push("");return a.join(`
|
|
26
|
+
`)}catch(n){return console.warn("Failed to migrate legacy lockfile:",n),null}}function X(u){if(!u)return u;let e=u.trim();return e.startsWith("0x")&&(e=e.slice(2)),/^[0-9a-fA-F]+$/.test(e)?"0x"+e.toLowerCase().padStart(64,"0"):u}function Y(u){try{let e=$(u);if((e.move?.version??0)>3||!e.env||typeof e.env!="object")return null;let n=[];if(n.push("[move]"),n.push("version = 4"),n.push(""),e.dependencies&&typeof e.dependencies=="object"){n.push("[dependencies]");for(let[i,s]of Object.entries(e.dependencies))if(typeof s=="object"&&s!==null){let o=s,a=[];o.name&&a.push(`name = "${o.name}"`),o.source&&a.push(`source = "${o.source}"`),n.push(`${i} = { ${a.join(", ")} }`)}n.push("")}return n.join(`
|
|
27
|
+
`)}catch(e){return console.warn("Failed to strip env sections from V3 lockfile:",e),null}}function me(u){try{let e=new URL(u);if(e.hostname!=="github.com")return null;let t=e.pathname.split("/").filter(Boolean);if(t.length<2)return null;let n=t[0],i=t[1],s="main",o;return t.length>=4&&t[2]==="tree"&&(s=t[3],t.length>4&&(o=t.slice(4).join("/"))),{owner:n,repo:i,ref:s,subdir:o}}catch{return null}}async function Z(u,e){let t=me(u);if(!t)throw new Error(`Invalid GitHub URL: ${u}`);let n=e?.fetcher||new D(e?.githubToken),i=e?.includeLock!==!1,s=`https://github.com/${t.owner}/${t.repo}.git`,o=await n.fetch(s,t.ref,t.subdir,`root:${t.owner}/${t.repo}`);if(Object.defineProperty(o,"__rootGit",{value:{git:s,rev:t.ref,subdir:t.subdir},enumerable:!1}),!i&&o["Move.lock"]){let{"Move.lock":a,...r}=o;return r}return o}var ee={mainnet:"35834a8a",testnet:"4c78adac",devnet:"2",localnet:"localnet"},E;async function M(u){return E||(E=import("./sui_move_wasm.js").then(async e=>(u?await e.default(u):await e.default(),e))),E}function j(u){return{error:u instanceof Error?u.message:typeof u=="string"?u:"Unknown error"}}function te(u){if(typeof u!="object"||u===null)throw new Error("Unexpected compile result shape from wasm");let e=u;if(typeof e.success=="function"&&typeof e.output=="function")return e;if(typeof e.success=="boolean"&&typeof e.output=="string")return{success:()=>e.success,output:()=>e.output};throw new Error("Unexpected compile result shape from wasm")}function he(u,e,t,n){let i=s=>{let o=s.startsWith("0x")?s.slice(2):s,a=o.length%2===0?o:`0${o}`,r=[];for(let p=0;p<a.length;p+=2){let c=parseInt(a.slice(p,p+2),16);if(Number.isNaN(c))throw new Error("invalid hex digest");r.push(c)}return r};try{let s=JSON.parse(u);if(!s.modules||!s.dependencies||!s.digest)throw new Error("missing fields in compiler output");let o=typeof s.digest=="string"?i(s.digest):Array.from(s.digest),a=s.dependencies;return e&&(a=Array.from(e.keys()).filter(r=>r!=="0x0000000000000000000000000000000000000000000000000000000000000000"),a.sort((r,p)=>{let c=e.get(r)||"",g=e.get(p)||"";return c<g?-1:c>g?1:0})),{modules:s.modules,dependencies:a,digest:o,moveLock:t||"",environment:n||"mainnet"}}catch(s){return j(s)}}function se(u){try{let e=JSON.parse(u);for(let t of e){let n=t.addressMapping?.[t.name]??(()=>{let i=Object.entries(t.files).find(([o])=>o.endsWith("Move.toml"));if(!i)return;let s=$(i[1]);return s.addresses&&s.addresses[t.name]||s.package?.published_at||s.package?.["published-at"]})()}}catch{}}async function ve(u){await M(u?.wasm)}async function U(u){let e=u.files["Move.toml"]||"",t=u.rootGit||u.files.__rootGit,n=await q(e,{...u.files,"Move.toml":e},new D(u.githubToken),u.network,t?{type:"git",git:t.git,rev:t.rev,subdir:t.subdir}:void 0);return{files:n.files,dependencies:n.dependencies,lockfileDependencies:n.lockfileDependencies}}async function ke(u){let e=u.network||"mainnet";try{let t={};for(let[y,w]of Object.entries(u.files))(y.endsWith(".move")||y.endsWith("Move.toml")||y.endsWith("Move.lock")||y.endsWith("Published.toml"))&&(t[y]=w);u.files=t;let n,i=u.files["Move.lock"];if(i){let y=ee[e]||e;if(n=V(i,e,y)??void 0,n){u.files["Published.toml"]||(u.files["Published.toml"]=n);let T=Y(i);T&&(u.files["Move.lock"]=T)}}u.onProgress?.({type:"resolve_start"});let s=u.resolvedDependencies?u.resolvedDependencies:await U(u),o=0;try{o=JSON.parse(s.dependencies).length}catch{}u.onProgress?.({type:"resolve_complete",count:o});let a=await M(u.wasm);se(s.dependencies);let r=new Map,p="Package";try{let y=JSON.parse(s.dependencies),w=u.files["Move.toml"],T=[];if(w){let A=$(w);A.package?.name&&(p=A.package.name),A.dependencies&&(T=Object.keys(A.dependencies))}for(let A of y)!A.publishedIdForOutput||A.publishedIdForOutput==="0x0000000000000000000000000000000000000000000000000000000000000000"||["0x0000000000000000000000000000000000000000000000000000000000000003","0x000000000000000000000000000000000000000000000000000000000000000b"].includes(A.publishedIdForOutput)||r.set(A.publishedIdForOutput,A.name)}catch{}u.onProgress?.({type:"compile_start"});let c=JSON.parse(s.dependencies),g=new Map,d=c.map(y=>{let w=g.get(y.name)??0,T=w===0?y.name:`${y.name}_${w}`;return g.set(y.name,w+1),{id:T,name:y.name,source:y.source??{root:!0},deps:y.deps??{},manifestDigest:y.manifestDigest??"",is_root:!1}});d.unshift({id:p,name:p,source:{root:!0},deps:{},manifestDigest:"",is_root:!0}),d.sort((y,w)=>y.id.localeCompare(w.id));let l={environment:e,root:p,packages:d},f=a.compile(s.files,s.dependencies,JSON.stringify({silenceWarnings:u.silenceWarnings,testMode:u.testMode,lintFlag:u.lintFlag,stripMetadata:u.stripMetadata}),JSON.stringify(l)),h=te(f),m=h.success(),v=h.output();if(u.onProgress?.({type:"compile_complete"}),!m)return j(v);u.onProgress?.({type:"lockfile_generate"});let k=[],b,P;try{let y=u.files["Move.toml"];if(y){let w=$(y);w.dependencies&&(k=Object.keys(w.dependencies),b=w.dependencies)}}catch{}try{let w=JSON.parse(s.dependencies).find(T=>T.name===p);w?.depAliasToPackageName&&(P=w.depAliasToPackageName)}catch{}let R=u.files["Move.lock"],I=Q(s.lockfileDependencies,p,e,k,a.compute_manifest_digest,b,P,R),S=he(v,r,I,e);if(!("error"in S)){let y=u.files["Move.lock"];if(y){let w=ee[e]||e,T=V(y,e,w);T&&(S.publishedToml=T)}}return S}catch(t){return j(t)}}async function ye(u){try{let e=u.resolvedDependencies?u.resolvedDependencies:await U(u),t=await M(u.wasm);se(e.dependencies);let n=u.ansiColor&&typeof t.test_with_color=="function"?t.test_with_color(e.files,e.dependencies,!0):t.test(e.files,e.dependencies);if(typeof n.passed=="boolean"&&typeof n.output=="string")return{passed:n.passed,output:n.output};let i=typeof n.passed=="function"?n.passed():n.passed,s=typeof n.output=="function"?n.output():n.output;return{passed:i,output:s}}catch(e){return j(e)}}async function be(u){return(await M(u?.wasm)).sui_move_version()}async function Pe(u){return(await M(u?.wasm)).sui_version()}async function we(u){return M(u?.wasm)}async function Ie(u,e,t){let n=await M(t?.wasm),i=t?.ansiColor&&typeof n.compile_with_color=="function"?n.compile_with_color(u,e,!0):n.compile(u,e,JSON.stringify({silenceWarnings:!1})),s=te(i);return{success:s.success(),output:s.output()}}0&&(module.exports={buildMovePackage,compileRaw,fetchPackageFromGitHub,getSuiMoveVersion,getSuiVersion,getWasmBindings,initMoveCompiler,resolveDependencies,testMovePackage});
|
package/dist/full/index.d.cts
CHANGED
|
@@ -6,15 +6,24 @@ declare class Fetcher {
|
|
|
6
6
|
fetch(_gitUrl: string, _rev: string, _subdir?: string): Promise<Record<string, string>>;
|
|
7
7
|
/** Fetch a single file from a repository. */
|
|
8
8
|
fetchFile(_gitUrl: string, _rev: string, _path: string): Promise<string | null>;
|
|
9
|
+
/** Get the resolved commit SHA for a git URL and rev (after fetch). */
|
|
10
|
+
getResolvedSha(_gitUrl: string, _rev: string): string | undefined;
|
|
9
11
|
}
|
|
10
12
|
/** Fetcher that retrieves files from public GitHub repositories via fetch(). */
|
|
11
13
|
declare class GitHubFetcher extends Fetcher {
|
|
12
14
|
private cache;
|
|
13
15
|
private treeCache;
|
|
16
|
+
private resolvedShaCache;
|
|
14
17
|
private rateLimitRemaining;
|
|
15
18
|
private rateLimitReset;
|
|
16
19
|
private token;
|
|
17
20
|
constructor(token?: string);
|
|
21
|
+
/**
|
|
22
|
+
* Get the resolved commit SHA for a git URL and rev.
|
|
23
|
+
* This returns the actual commit SHA that was fetched, resolving tags/branches.
|
|
24
|
+
* Must be called after fetch() to get the resolved SHA.
|
|
25
|
+
*/
|
|
26
|
+
getResolvedSha(gitUrl: string, rev: string): string | undefined;
|
|
18
27
|
/**
|
|
19
28
|
* Update rate limit info from response headers
|
|
20
29
|
*/
|
|
@@ -59,11 +68,34 @@ declare function fetchPackageFromGitHub(url: string, options?: {
|
|
|
59
68
|
includeLock?: boolean;
|
|
60
69
|
}): Promise<Record<string, string>>;
|
|
61
70
|
|
|
71
|
+
/** Build progress event types for tracking build status */
|
|
72
|
+
type BuildProgressEvent = {
|
|
73
|
+
type: "resolve_start";
|
|
74
|
+
} | {
|
|
75
|
+
type: "resolve_dep";
|
|
76
|
+
name: string;
|
|
77
|
+
source: string;
|
|
78
|
+
current: number;
|
|
79
|
+
total: number;
|
|
80
|
+
} | {
|
|
81
|
+
type: "resolve_complete";
|
|
82
|
+
count: number;
|
|
83
|
+
} | {
|
|
84
|
+
type: "compile_start";
|
|
85
|
+
} | {
|
|
86
|
+
type: "compile_complete";
|
|
87
|
+
} | {
|
|
88
|
+
type: "lockfile_generate";
|
|
89
|
+
};
|
|
90
|
+
/** Callback function for receiving build progress events */
|
|
91
|
+
type OnProgressCallback = (event: BuildProgressEvent) => void;
|
|
62
92
|
interface ResolvedDependencies {
|
|
63
93
|
/** JSON string of resolved files for the root package */
|
|
64
94
|
files: string;
|
|
65
|
-
/** JSON string of resolved dependencies */
|
|
95
|
+
/** JSON string of resolved dependencies (linkage applied, for compilation) */
|
|
66
96
|
dependencies: string;
|
|
97
|
+
/** JSON string of all dependencies including diamond duplicates (for lockfile) */
|
|
98
|
+
lockfileDependencies: string;
|
|
67
99
|
}
|
|
68
100
|
interface BuildInput {
|
|
69
101
|
/** Virtual file system contents. Keys are paths (e.g. "Move.toml", "sources/Module.move"). */
|
|
@@ -92,6 +124,8 @@ interface BuildInput {
|
|
|
92
124
|
lintFlag?: string;
|
|
93
125
|
/** Use this option to strip metadata from the output (e.g. for mainnet dep matching). */
|
|
94
126
|
stripMetadata?: boolean;
|
|
127
|
+
/** Optional progress callback for build events */
|
|
128
|
+
onProgress?: OnProgressCallback;
|
|
95
129
|
}
|
|
96
130
|
interface BuildSuccess {
|
|
97
131
|
/** Base64-encoded bytecode modules. */
|
|
@@ -100,6 +134,12 @@ interface BuildSuccess {
|
|
|
100
134
|
dependencies: string[];
|
|
101
135
|
/** Blake2b-256 package digest as byte array (matches Sui CLI JSON). */
|
|
102
136
|
digest: number[];
|
|
137
|
+
/** Move.lock V4 content (TOML string) */
|
|
138
|
+
moveLock: string;
|
|
139
|
+
/** Build environment used */
|
|
140
|
+
environment: string;
|
|
141
|
+
/** Generated Published.toml content (if migration occurred) */
|
|
142
|
+
publishedToml?: string;
|
|
103
143
|
}
|
|
104
144
|
interface BuildFailure {
|
|
105
145
|
error: string;
|
|
@@ -146,4 +186,4 @@ declare function compileRaw(filesJson: string, depsJson: string, options?: {
|
|
|
146
186
|
}>;
|
|
147
187
|
type BuildResult = BuildSuccess | BuildFailure;
|
|
148
188
|
|
|
149
|
-
export { type BuildFailure, type BuildInput, type BuildResult, type BuildSuccess, type ResolvedDependencies, type TestSuccess, buildMovePackage, compileRaw, fetchPackageFromGitHub, getSuiMoveVersion, getSuiVersion, getWasmBindings, initMoveCompiler, resolveDependencies, testMovePackage };
|
|
189
|
+
export { type BuildFailure, type BuildInput, type BuildProgressEvent, type BuildResult, type BuildSuccess, type OnProgressCallback, type ResolvedDependencies, type TestSuccess, buildMovePackage, compileRaw, fetchPackageFromGitHub, getSuiMoveVersion, getSuiVersion, getWasmBindings, initMoveCompiler, resolveDependencies, testMovePackage };
|
package/dist/full/index.d.ts
CHANGED
|
@@ -6,15 +6,24 @@ declare class Fetcher {
|
|
|
6
6
|
fetch(_gitUrl: string, _rev: string, _subdir?: string): Promise<Record<string, string>>;
|
|
7
7
|
/** Fetch a single file from a repository. */
|
|
8
8
|
fetchFile(_gitUrl: string, _rev: string, _path: string): Promise<string | null>;
|
|
9
|
+
/** Get the resolved commit SHA for a git URL and rev (after fetch). */
|
|
10
|
+
getResolvedSha(_gitUrl: string, _rev: string): string | undefined;
|
|
9
11
|
}
|
|
10
12
|
/** Fetcher that retrieves files from public GitHub repositories via fetch(). */
|
|
11
13
|
declare class GitHubFetcher extends Fetcher {
|
|
12
14
|
private cache;
|
|
13
15
|
private treeCache;
|
|
16
|
+
private resolvedShaCache;
|
|
14
17
|
private rateLimitRemaining;
|
|
15
18
|
private rateLimitReset;
|
|
16
19
|
private token;
|
|
17
20
|
constructor(token?: string);
|
|
21
|
+
/**
|
|
22
|
+
* Get the resolved commit SHA for a git URL and rev.
|
|
23
|
+
* This returns the actual commit SHA that was fetched, resolving tags/branches.
|
|
24
|
+
* Must be called after fetch() to get the resolved SHA.
|
|
25
|
+
*/
|
|
26
|
+
getResolvedSha(gitUrl: string, rev: string): string | undefined;
|
|
18
27
|
/**
|
|
19
28
|
* Update rate limit info from response headers
|
|
20
29
|
*/
|
|
@@ -59,11 +68,34 @@ declare function fetchPackageFromGitHub(url: string, options?: {
|
|
|
59
68
|
includeLock?: boolean;
|
|
60
69
|
}): Promise<Record<string, string>>;
|
|
61
70
|
|
|
71
|
+
/** Build progress event types for tracking build status */
|
|
72
|
+
type BuildProgressEvent = {
|
|
73
|
+
type: "resolve_start";
|
|
74
|
+
} | {
|
|
75
|
+
type: "resolve_dep";
|
|
76
|
+
name: string;
|
|
77
|
+
source: string;
|
|
78
|
+
current: number;
|
|
79
|
+
total: number;
|
|
80
|
+
} | {
|
|
81
|
+
type: "resolve_complete";
|
|
82
|
+
count: number;
|
|
83
|
+
} | {
|
|
84
|
+
type: "compile_start";
|
|
85
|
+
} | {
|
|
86
|
+
type: "compile_complete";
|
|
87
|
+
} | {
|
|
88
|
+
type: "lockfile_generate";
|
|
89
|
+
};
|
|
90
|
+
/** Callback function for receiving build progress events */
|
|
91
|
+
type OnProgressCallback = (event: BuildProgressEvent) => void;
|
|
62
92
|
interface ResolvedDependencies {
|
|
63
93
|
/** JSON string of resolved files for the root package */
|
|
64
94
|
files: string;
|
|
65
|
-
/** JSON string of resolved dependencies */
|
|
95
|
+
/** JSON string of resolved dependencies (linkage applied, for compilation) */
|
|
66
96
|
dependencies: string;
|
|
97
|
+
/** JSON string of all dependencies including diamond duplicates (for lockfile) */
|
|
98
|
+
lockfileDependencies: string;
|
|
67
99
|
}
|
|
68
100
|
interface BuildInput {
|
|
69
101
|
/** Virtual file system contents. Keys are paths (e.g. "Move.toml", "sources/Module.move"). */
|
|
@@ -92,6 +124,8 @@ interface BuildInput {
|
|
|
92
124
|
lintFlag?: string;
|
|
93
125
|
/** Use this option to strip metadata from the output (e.g. for mainnet dep matching). */
|
|
94
126
|
stripMetadata?: boolean;
|
|
127
|
+
/** Optional progress callback for build events */
|
|
128
|
+
onProgress?: OnProgressCallback;
|
|
95
129
|
}
|
|
96
130
|
interface BuildSuccess {
|
|
97
131
|
/** Base64-encoded bytecode modules. */
|
|
@@ -100,6 +134,12 @@ interface BuildSuccess {
|
|
|
100
134
|
dependencies: string[];
|
|
101
135
|
/** Blake2b-256 package digest as byte array (matches Sui CLI JSON). */
|
|
102
136
|
digest: number[];
|
|
137
|
+
/** Move.lock V4 content (TOML string) */
|
|
138
|
+
moveLock: string;
|
|
139
|
+
/** Build environment used */
|
|
140
|
+
environment: string;
|
|
141
|
+
/** Generated Published.toml content (if migration occurred) */
|
|
142
|
+
publishedToml?: string;
|
|
103
143
|
}
|
|
104
144
|
interface BuildFailure {
|
|
105
145
|
error: string;
|
|
@@ -146,4 +186,4 @@ declare function compileRaw(filesJson: string, depsJson: string, options?: {
|
|
|
146
186
|
}>;
|
|
147
187
|
type BuildResult = BuildSuccess | BuildFailure;
|
|
148
188
|
|
|
149
|
-
export { type BuildFailure, type BuildInput, type BuildResult, type BuildSuccess, type ResolvedDependencies, type TestSuccess, buildMovePackage, compileRaw, fetchPackageFromGitHub, getSuiMoveVersion, getSuiVersion, getWasmBindings, initMoveCompiler, resolveDependencies, testMovePackage };
|
|
189
|
+
export { type BuildFailure, type BuildInput, type BuildProgressEvent, type BuildResult, type BuildSuccess, type OnProgressCallback, type ResolvedDependencies, type TestSuccess, buildMovePackage, compileRaw, fetchPackageFromGitHub, getSuiMoveVersion, getSuiVersion, getWasmBindings, initMoveCompiler, resolveDependencies, testMovePackage };
|