@unconfirmed/publish 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +246 -0
- package/dist/args.d.ts +5 -0
- package/dist/args.d.ts.map +1 -0
- package/dist/args.js +185 -0
- package/dist/args.js.map +1 -0
- package/dist/cli-types.d.ts +24 -0
- package/dist/cli-types.d.ts.map +1 -0
- package/dist/cli-types.js +2 -0
- package/dist/cli-types.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +192 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +12 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +21 -0
- package/dist/config.js.map +1 -0
- package/dist/errors.d.ts +17 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +22 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/move-build.d.ts +17 -0
- package/dist/move-build.d.ts.map +1 -0
- package/dist/move-build.js +189 -0
- package/dist/move-build.js.map +1 -0
- package/dist/onara-client.d.ts +36 -0
- package/dist/onara-client.d.ts.map +1 -0
- package/dist/onara-client.js +119 -0
- package/dist/onara-client.js.map +1 -0
- package/dist/published-file.d.ts +16 -0
- package/dist/published-file.d.ts.map +1 -0
- package/dist/published-file.js +79 -0
- package/dist/published-file.js.map +1 -0
- package/dist/result.d.ts +12 -0
- package/dist/result.d.ts.map +1 -0
- package/dist/result.js +86 -0
- package/dist/result.js.map +1 -0
- package/dist/transaction.d.ts +13 -0
- package/dist/transaction.d.ts.map +1 -0
- package/dist/transaction.js +36 -0
- package/dist/transaction.js.map +1 -0
- package/dist/types.d.ts +60 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/workflow.d.ts +19 -0
- package/dist/workflow.d.ts.map +1 -0
- package/dist/workflow.js +241 -0
- package/dist/workflow.js.map +1 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 unconfirmedlabs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
# publish
|
|
2
|
+
|
|
3
|
+
An SDK for composing immutable Sui Move package publishes, plus a thin CLI that
|
|
4
|
+
publishes one package with a fresh in-memory signer and
|
|
5
|
+
[Onara](https://github.com/unconfirmedlabs/onara)-sponsored gas.
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
publish . --network testnet --onara-url <URL> --dry-run
|
|
9
|
+
publish . --network testnet --onara-url <URL>
|
|
10
|
+
|
|
11
|
+
publish . --network mainnet --onara-url <URL> --dry-run
|
|
12
|
+
publish . --network mainnet --onara-url <URL> --yes
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Every successful publish is one atomic programmable transaction:
|
|
16
|
+
|
|
17
|
+
```text
|
|
18
|
+
Publish(modules, dependencies) -> UpgradeCap
|
|
19
|
+
0x2::package::make_immutable(UpgradeCap)
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
If either command fails, neither takes effect. The Ed25519 key is generated only
|
|
23
|
+
after compilation, kept in process memory, used to sign that transaction, and
|
|
24
|
+
never printed or written to disk. Onara pays gas from its address balance.
|
|
25
|
+
|
|
26
|
+
## SDK
|
|
27
|
+
|
|
28
|
+
`@unconfirmed/publish` exposes transaction composition separately from build,
|
|
29
|
+
signing, gas selection, execution, and deployment metadata:
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { Transaction } from '@mysten/sui/transactions'
|
|
33
|
+
import { addImmutablePublish } from '@unconfirmed/publish'
|
|
34
|
+
|
|
35
|
+
const transaction = new Transaction()
|
|
36
|
+
addImmutablePublish(transaction, artifact)
|
|
37
|
+
|
|
38
|
+
// The caller chooses the sender, gas strategy, signer, and executor.
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
For independent package batches, `createImmutablePublishTransaction(artifacts)`
|
|
42
|
+
creates the complete PTB. It accepts one through five artifacts, matching Sui's
|
|
43
|
+
publish-command limit, and adds one `make_immutable` call immediately after each
|
|
44
|
+
publish. Neither transaction helper sets sender or gas data.
|
|
45
|
+
|
|
46
|
+
The root export also provides:
|
|
47
|
+
|
|
48
|
+
- `buildMovePackage` and `parseBuildOutput` for argv-safe stock Sui builds;
|
|
49
|
+
- `OnaraHttpClient` and `createBoundedFetch` for sponsored execution;
|
|
50
|
+
- `extractExecutionResult` and `extractPublishedPackageIds` for execution-effect
|
|
51
|
+
normalization, including all package IDs from a batch;
|
|
52
|
+
- `transactionStatus` and `sponsorshipError` for digest-based reconciliation;
|
|
53
|
+
- `updatePublishedFile` and `updatePublishedText` for explicit, atomic deployment
|
|
54
|
+
metadata updates; and
|
|
55
|
+
- `publishPackage` as the one-package ephemeral-signer convenience workflow used
|
|
56
|
+
by the CLI.
|
|
57
|
+
|
|
58
|
+
The core publishing options contain network and execution inputs only. CLI
|
|
59
|
+
presentation, confirmation, and metadata-write switches are intentionally not
|
|
60
|
+
part of the SDK contract. `Published.toml` is never changed by transaction
|
|
61
|
+
composition or effect parsing; callers invoke the metadata helper explicitly
|
|
62
|
+
after an applied publish.
|
|
63
|
+
|
|
64
|
+
Mutation receipts and errors use `effect: "applied" | "not_applied" |
|
|
65
|
+
"unknown"`. An unknown outcome carries the locally derived digest whenever one
|
|
66
|
+
is available and must be reconciled before retrying.
|
|
67
|
+
|
|
68
|
+
## Why the CLI builds the package
|
|
69
|
+
|
|
70
|
+
The package directory—not prebuilt bytecode—is the primary input. `publish`
|
|
71
|
+
invokes the installed stock Sui CLI as an argv-safe child process:
|
|
72
|
+
|
|
73
|
+
```sh
|
|
74
|
+
sui move build \
|
|
75
|
+
--path <PACKAGE_PATH> \
|
|
76
|
+
--dump-bytecode-as-base64 \
|
|
77
|
+
--build-env <NETWORK>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
This is preferable to accepting an arbitrary bytecode file by default:
|
|
81
|
+
|
|
82
|
+
- the bytecode and transitive dependency IDs come from the same build;
|
|
83
|
+
- the chosen network is used for both compilation and submission;
|
|
84
|
+
- already-published root packages are rebuilt at `0x0`, so republishing does not
|
|
85
|
+
require deleting or editing `Published.toml` first;
|
|
86
|
+
- compiler failures stop before a key is generated or Onara is contacted; and
|
|
87
|
+
- the exact Sui CLI version and package digest are recorded in the result.
|
|
88
|
+
|
|
89
|
+
The CLI creates a temporary, empty Sui client configuration pointed at the
|
|
90
|
+
selected RPC. It never uses an ambient Sui address or keystore. The compiler
|
|
91
|
+
still uses the package's normal `Move.lock`, dependency cache, and `build/`
|
|
92
|
+
directory.
|
|
93
|
+
|
|
94
|
+
After a successful transaction, the selected network section in
|
|
95
|
+
`Published.toml` is updated atomically. Other networks and surrounding comments
|
|
96
|
+
are preserved. The new record intentionally has no `upgrade-capability` field.
|
|
97
|
+
Use `--no-write-published` for a read-only checkout.
|
|
98
|
+
|
|
99
|
+
## Install
|
|
100
|
+
|
|
101
|
+
Requirements:
|
|
102
|
+
|
|
103
|
+
- Node.js 22 or newer (Bun also works);
|
|
104
|
+
- the `sui` CLI on `PATH`; and
|
|
105
|
+
- network access to the chosen Sui RPC and Onara endpoint.
|
|
106
|
+
|
|
107
|
+
From a checkout:
|
|
108
|
+
|
|
109
|
+
```sh
|
|
110
|
+
bun install --frozen-lockfile
|
|
111
|
+
bun run build
|
|
112
|
+
bun link
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
The package name is `@unconfirmed/publish` and the installed executable is
|
|
116
|
+
`publish`.
|
|
117
|
+
|
|
118
|
+
## Networks
|
|
119
|
+
|
|
120
|
+
`--network` and `--onara-url` are always required. There are no ambient
|
|
121
|
+
defaults for either one; callers bring their own Onara deployment.
|
|
122
|
+
|
|
123
|
+
| Network | Default Sui gRPC |
|
|
124
|
+
| --- | --- |
|
|
125
|
+
| testnet | `https://fullnode.testnet.sui.io:443` |
|
|
126
|
+
| mainnet | `https://fullnode.mainnet.sui.io:443` |
|
|
127
|
+
|
|
128
|
+
The CLI verifies both endpoints' immutable chain identifiers before generating
|
|
129
|
+
the signer. Override private or mirrored Sui infrastructure explicitly with
|
|
130
|
+
`--rpc-url`; the network identity checks still apply.
|
|
131
|
+
|
|
132
|
+
The resolved Onara and RPC URLs are included in every JSON publish receipt.
|
|
133
|
+
|
|
134
|
+
Mainnet execution requires `--yes` and never opens a prompt. A mainnet dry run
|
|
135
|
+
does not require `--yes`.
|
|
136
|
+
|
|
137
|
+
The client uses Onara's versioned HTTP surface directly (`/status`, `/sponsor`,
|
|
138
|
+
and `/sponsor/:digest/status`), so it runs consistently under both Node and Bun.
|
|
139
|
+
|
|
140
|
+
## Dry runs
|
|
141
|
+
|
|
142
|
+
```sh
|
|
143
|
+
publish ./move/my-package --network testnet --onara-url <URL> --dry-run --json
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
A dry run compiles the package, constructs the full transaction, lets the Sui
|
|
147
|
+
SDK simulate it while resolving the gas budget, signs it with a new ephemeral
|
|
148
|
+
key, and asks Onara to validate its sponsorship policy. Onara does not submit or
|
|
149
|
+
sponsor-sign it. The receipt reports `effect: "not_applied"`.
|
|
150
|
+
|
|
151
|
+
Each invocation deliberately gets a new sender. A later executable invocation
|
|
152
|
+
therefore has different transaction bytes, while retaining the same modules,
|
|
153
|
+
dependencies, package digest, and command shape.
|
|
154
|
+
|
|
155
|
+
## Machine contract
|
|
156
|
+
|
|
157
|
+
Use `--json` for one JSON result document on stdout. Progress is JSONL on stderr
|
|
158
|
+
and can be disabled with `--quiet`. Before a result is available, stdout stays
|
|
159
|
+
empty on failure.
|
|
160
|
+
|
|
161
|
+
```sh
|
|
162
|
+
publish . --network testnet --onara-url <URL> --dry-run --json --quiet
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
```json
|
|
166
|
+
{
|
|
167
|
+
"schemaVersion": 1,
|
|
168
|
+
"operation": "publish",
|
|
169
|
+
"outcome": "validated",
|
|
170
|
+
"effect": "not_applied",
|
|
171
|
+
"network": "testnet",
|
|
172
|
+
"packagePath": "/absolute/path/to/package",
|
|
173
|
+
"packageDigest": "0x...",
|
|
174
|
+
"moduleCount": 1,
|
|
175
|
+
"dependencyCount": 2,
|
|
176
|
+
"sender": "0x...",
|
|
177
|
+
"sponsor": "0x...",
|
|
178
|
+
"immutable": true,
|
|
179
|
+
"onaraUrl": "<URL>",
|
|
180
|
+
"rpcUrl": "https://fullnode.testnet.sui.io:443",
|
|
181
|
+
"suiCliVersion": "sui 1.78.1-...",
|
|
182
|
+
"policy": "allow-all"
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
An executed receipt additionally includes `transactionDigest`, `packageId`, and
|
|
187
|
+
the `Published.toml` update state. Field names and enum values are part of the
|
|
188
|
+
CLI's public protocol; additive fields may be introduced in schema version 1.
|
|
189
|
+
|
|
190
|
+
Errors are structured on stderr:
|
|
191
|
+
|
|
192
|
+
```json
|
|
193
|
+
{
|
|
194
|
+
"type": "error",
|
|
195
|
+
"error": {
|
|
196
|
+
"code": "SPONSORSHIP_DENIED",
|
|
197
|
+
"message": "Transaction is not eligible for sponsorship.",
|
|
198
|
+
"effect": "not_applied"
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Exit statuses are typed:
|
|
204
|
+
|
|
205
|
+
| Status | Meaning |
|
|
206
|
+
| --- | --- |
|
|
207
|
+
| `0` | Publish, dry run, or status read succeeded. |
|
|
208
|
+
| `1` | Operational failure with a known applied/not-applied outcome. |
|
|
209
|
+
| `2` | Invalid usage or missing mainnet confirmation. |
|
|
210
|
+
| `3` | Submission outcome is unknown; reconcile before retrying. |
|
|
211
|
+
|
|
212
|
+
The CLI does not retry the publish request. A timeout or lost response can hide
|
|
213
|
+
a committed transaction, and retrying with a fresh key would create another
|
|
214
|
+
package. The locally derived transaction digest is returned whenever possible.
|
|
215
|
+
|
|
216
|
+
```sh
|
|
217
|
+
publish status <TRANSACTION_DIGEST> --network testnet --onara-url <URL> --json
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## Important package constraints
|
|
221
|
+
|
|
222
|
+
Immutability is permanent. A successful package cannot be upgraded, rolled back,
|
|
223
|
+
or repaired through an upgrade.
|
|
224
|
+
|
|
225
|
+
The transaction sender is a disposable address. If a package `init` function
|
|
226
|
+
creates an admin capability or any other address-owned object for
|
|
227
|
+
`tx_context::sender`, that object will be owned by the ephemeral address and
|
|
228
|
+
become inaccessible after the process exits. Use this tool only for packages
|
|
229
|
+
whose initialization leaves no authority or assets that must remain controlled.
|
|
230
|
+
|
|
231
|
+
`Published.toml` is local deployment metadata, not proof that the transaction
|
|
232
|
+
succeeded. The onchain transaction digest and package ID in the success receipt
|
|
233
|
+
are authoritative.
|
|
234
|
+
|
|
235
|
+
## Full help
|
|
236
|
+
|
|
237
|
+
```text
|
|
238
|
+
publish --help
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Help, version, and argument errors are local and do not initialize the SDK,
|
|
242
|
+
inspect credentials, or contact a network.
|
|
243
|
+
|
|
244
|
+
## License
|
|
245
|
+
|
|
246
|
+
MIT
|
package/dist/args.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CliOptions } from './cli-types.js';
|
|
2
|
+
export declare const VERSION = "0.1.0";
|
|
3
|
+
export declare const HELP = "Publish a Sui Move package immutably with an ephemeral signer and Onara-sponsored gas.\n\nUsage:\n publish [PACKAGE_PATH] --network <testnet|mainnet> --onara-url <url> [options]\n publish status <TRANSACTION_DIGEST> --network <testnet|mainnet> --onara-url <url> [options]\n\nThe publish operation runs the stock Sui compiler, publishes the resulting modules,\nand consumes the returned UpgradeCap with 0x2::package::make_immutable in one atomic\ntransaction. PACKAGE_PATH defaults to the current directory.\n\nPublish options:\n --network <network> Required. Either testnet or mainnet.\n --dry-run Build, sign, simulate for gas resolution, and validate with Onara;\n do not submit the transaction.\n --yes Required for a mainnet submission. Never prompts.\n --sui <path> Sui CLI executable (default: sui).\n --no-write-published Do not update Published.toml after a successful publish.\n\nConnection options:\n --rpc-url <url> Override the selected network's Sui gRPC endpoint.\n --onara-url <url> Required. Onara sponsorship service endpoint.\n --timeout-ms <ms> Per-request client timeout (default: 70000).\n\nOutput options:\n --json Emit one JSON document on stdout; structured errors go to stderr.\n --quiet Suppress progress diagnostics on stderr.\n --help Show this help without network access.\n --version Show the version without network access.\n\nExit status:\n 0 Success, including a successful dry run or status lookup.\n 1 Operational failure with a known applied/not-applied outcome.\n 2 Invalid usage or missing mainnet confirmation.\n 3 Mutation outcome is unknown; reconcile with \"publish status\" before retrying.\n";
|
|
4
|
+
export declare function parseArgs(argv: string[]): CliOptions;
|
|
5
|
+
//# sourceMappingURL=args.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAEhD,eAAO,MAAM,OAAO,UAAU,CAAA;AAE9B,eAAO,MAAM,IAAI,mwDAkChB,CAAA;AAiHD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CA2CpD"}
|
package/dist/args.js
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { PublishError } from './errors.js';
|
|
2
|
+
export const VERSION = '0.1.0';
|
|
3
|
+
export const HELP = `Publish a Sui Move package immutably with an ephemeral signer and Onara-sponsored gas.
|
|
4
|
+
|
|
5
|
+
Usage:
|
|
6
|
+
publish [PACKAGE_PATH] --network <testnet|mainnet> --onara-url <url> [options]
|
|
7
|
+
publish status <TRANSACTION_DIGEST> --network <testnet|mainnet> --onara-url <url> [options]
|
|
8
|
+
|
|
9
|
+
The publish operation runs the stock Sui compiler, publishes the resulting modules,
|
|
10
|
+
and consumes the returned UpgradeCap with 0x2::package::make_immutable in one atomic
|
|
11
|
+
transaction. PACKAGE_PATH defaults to the current directory.
|
|
12
|
+
|
|
13
|
+
Publish options:
|
|
14
|
+
--network <network> Required. Either testnet or mainnet.
|
|
15
|
+
--dry-run Build, sign, simulate for gas resolution, and validate with Onara;
|
|
16
|
+
do not submit the transaction.
|
|
17
|
+
--yes Required for a mainnet submission. Never prompts.
|
|
18
|
+
--sui <path> Sui CLI executable (default: sui).
|
|
19
|
+
--no-write-published Do not update Published.toml after a successful publish.
|
|
20
|
+
|
|
21
|
+
Connection options:
|
|
22
|
+
--rpc-url <url> Override the selected network's Sui gRPC endpoint.
|
|
23
|
+
--onara-url <url> Required. Onara sponsorship service endpoint.
|
|
24
|
+
--timeout-ms <ms> Per-request client timeout (default: 70000).
|
|
25
|
+
|
|
26
|
+
Output options:
|
|
27
|
+
--json Emit one JSON document on stdout; structured errors go to stderr.
|
|
28
|
+
--quiet Suppress progress diagnostics on stderr.
|
|
29
|
+
--help Show this help without network access.
|
|
30
|
+
--version Show the version without network access.
|
|
31
|
+
|
|
32
|
+
Exit status:
|
|
33
|
+
0 Success, including a successful dry run or status lookup.
|
|
34
|
+
1 Operational failure with a known applied/not-applied outcome.
|
|
35
|
+
2 Invalid usage or missing mainnet confirmation.
|
|
36
|
+
3 Mutation outcome is unknown; reconcile with "publish status" before retrying.
|
|
37
|
+
`;
|
|
38
|
+
const VALUE_FLAGS = new Set(['--network', '--sui', '--rpc-url', '--onara-url', '--timeout-ms']);
|
|
39
|
+
function usageError(message) {
|
|
40
|
+
throw new PublishError('INVALID_USAGE', message, { exitCode: 2 });
|
|
41
|
+
}
|
|
42
|
+
function readValue(argv, index, inline) {
|
|
43
|
+
if (inline !== undefined) {
|
|
44
|
+
if (!inline)
|
|
45
|
+
usageError(`Missing value for ${argv[index]?.split('=')[0]}.`);
|
|
46
|
+
return [inline, index];
|
|
47
|
+
}
|
|
48
|
+
const value = argv[index + 1];
|
|
49
|
+
if (value === undefined)
|
|
50
|
+
usageError(`Missing value for ${argv[index]}.`);
|
|
51
|
+
return [value, index + 1];
|
|
52
|
+
}
|
|
53
|
+
function parseFlags(argv) {
|
|
54
|
+
const parsed = {
|
|
55
|
+
json: false,
|
|
56
|
+
quiet: false,
|
|
57
|
+
dryRun: false,
|
|
58
|
+
confirm: false,
|
|
59
|
+
suiBinary: 'sui',
|
|
60
|
+
writePublished: true,
|
|
61
|
+
timeoutMs: 70_000,
|
|
62
|
+
positionals: [],
|
|
63
|
+
};
|
|
64
|
+
let operandsOnly = false;
|
|
65
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
66
|
+
const token = argv[index];
|
|
67
|
+
if (operandsOnly) {
|
|
68
|
+
parsed.positionals.push(token);
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (token === '--') {
|
|
72
|
+
operandsOnly = true;
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if (!token.startsWith('--')) {
|
|
76
|
+
parsed.positionals.push(token);
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
const equals = token.indexOf('=');
|
|
80
|
+
const name = equals === -1 ? token : token.slice(0, equals);
|
|
81
|
+
const inline = equals === -1 ? undefined : token.slice(equals + 1);
|
|
82
|
+
if (inline !== undefined && !VALUE_FLAGS.has(name)) {
|
|
83
|
+
usageError(`${name} does not take a value.`);
|
|
84
|
+
}
|
|
85
|
+
if (name === '--json')
|
|
86
|
+
parsed.json = true;
|
|
87
|
+
else if (name === '--quiet')
|
|
88
|
+
parsed.quiet = true;
|
|
89
|
+
else if (name === '--dry-run')
|
|
90
|
+
parsed.dryRun = true;
|
|
91
|
+
else if (name === '--yes')
|
|
92
|
+
parsed.confirm = true;
|
|
93
|
+
else if (name === '--no-write-published')
|
|
94
|
+
parsed.writePublished = false;
|
|
95
|
+
else if (name === '--help' || name === '--version') {
|
|
96
|
+
usageError(`${name} must be handled before argument parsing.`);
|
|
97
|
+
}
|
|
98
|
+
else if (VALUE_FLAGS.has(name)) {
|
|
99
|
+
const [value, valueIndex] = readValue(argv, index, inline);
|
|
100
|
+
index = valueIndex;
|
|
101
|
+
if (name === '--network') {
|
|
102
|
+
if (value !== 'mainnet' && value !== 'testnet') {
|
|
103
|
+
usageError('--network must be either "testnet" or "mainnet".');
|
|
104
|
+
}
|
|
105
|
+
parsed.network = value;
|
|
106
|
+
}
|
|
107
|
+
else if (name === '--sui')
|
|
108
|
+
parsed.suiBinary = value;
|
|
109
|
+
else if (name === '--rpc-url')
|
|
110
|
+
parsed.rpcUrl = validateUrl(name, value);
|
|
111
|
+
else if (name === '--onara-url')
|
|
112
|
+
parsed.onaraUrl = validateUrl(name, value);
|
|
113
|
+
else {
|
|
114
|
+
const timeout = Number(value);
|
|
115
|
+
if (!Number.isSafeInteger(timeout) || timeout < 1_000 || timeout > 300_000) {
|
|
116
|
+
usageError('--timeout-ms must be an integer from 1000 through 300000.');
|
|
117
|
+
}
|
|
118
|
+
parsed.timeoutMs = timeout;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
usageError(`Unknown option: ${name}`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return parsed;
|
|
126
|
+
}
|
|
127
|
+
function validateUrl(flag, value) {
|
|
128
|
+
let url;
|
|
129
|
+
try {
|
|
130
|
+
url = new URL(value);
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
usageError(`${flag} must be an absolute HTTP or HTTPS URL.`);
|
|
134
|
+
}
|
|
135
|
+
if (url.protocol !== 'http:' && url.protocol !== 'https:') {
|
|
136
|
+
usageError(`${flag} must use http or https.`);
|
|
137
|
+
}
|
|
138
|
+
return url.toString().replace(/\/$/, '');
|
|
139
|
+
}
|
|
140
|
+
export function parseArgs(argv) {
|
|
141
|
+
const flags = parseFlags(argv);
|
|
142
|
+
if (!flags.network)
|
|
143
|
+
usageError('--network is required.');
|
|
144
|
+
if (!flags.onaraUrl)
|
|
145
|
+
usageError('--onara-url is required.');
|
|
146
|
+
if (flags.positionals[0] === 'status') {
|
|
147
|
+
if (flags.dryRun || flags.confirm || flags.suiBinary !== 'sui' || !flags.writePublished || flags.rpcUrl) {
|
|
148
|
+
usageError('--dry-run, --yes, --sui, --no-write-published, and --rpc-url apply only to publishing.');
|
|
149
|
+
}
|
|
150
|
+
if (flags.positionals.length !== 2) {
|
|
151
|
+
usageError('status requires exactly one transaction digest.');
|
|
152
|
+
}
|
|
153
|
+
if (!/^[1-9A-HJ-NP-Za-km-z]{32,64}$/.test(flags.positionals[1])) {
|
|
154
|
+
usageError('status requires a base58 Sui transaction digest.');
|
|
155
|
+
}
|
|
156
|
+
return {
|
|
157
|
+
operation: 'status',
|
|
158
|
+
network: flags.network,
|
|
159
|
+
digest: flags.positionals[1],
|
|
160
|
+
json: flags.json,
|
|
161
|
+
quiet: flags.quiet,
|
|
162
|
+
timeoutMs: flags.timeoutMs,
|
|
163
|
+
onaraUrl: flags.onaraUrl,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
if (flags.positionals.length > 1)
|
|
167
|
+
usageError('Publish accepts at most one package path.');
|
|
168
|
+
if (flags.dryRun && flags.confirm)
|
|
169
|
+
usageError('--yes is not used with --dry-run.');
|
|
170
|
+
return {
|
|
171
|
+
operation: 'publish',
|
|
172
|
+
network: flags.network,
|
|
173
|
+
packagePath: flags.positionals[0] ?? '.',
|
|
174
|
+
dryRun: flags.dryRun,
|
|
175
|
+
confirm: flags.confirm,
|
|
176
|
+
suiBinary: flags.suiBinary,
|
|
177
|
+
writePublished: flags.writePublished,
|
|
178
|
+
json: flags.json,
|
|
179
|
+
quiet: flags.quiet,
|
|
180
|
+
timeoutMs: flags.timeoutMs,
|
|
181
|
+
...(flags.rpcUrl ? { rpcUrl: flags.rpcUrl } : {}),
|
|
182
|
+
onaraUrl: flags.onaraUrl,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=args.js.map
|
package/dist/args.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"args.js","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG1C,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAA;AAE9B,MAAM,CAAC,MAAM,IAAI,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkCnB,CAAA;AAgBD,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,CAAC,CAAC,CAAA;AAE/F,SAAS,U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AAE,KAAK,CAAC,OAAO;YACtB,MAAM,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC,CAAE;YAC7B,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,QAAQ,EAAE,KAAK,CAAC,QAAQ;SACzB,CAAA;IACH,CAAC;IAED,IAAI,KAAK,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC;QAAE,UAAU,CAAC,2CAA2C,CAAC,CAAA;IACzF,IAAI,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,OAAO;QAAE,UAAU,CAAC,mCAAmC,CAAC,CAAA;IAElF,OAAO;QACL,SAAS,EAAE,SAAS;QACpB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,WAAW,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,GAAG;QACxC,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,cAAc,EAAE,KAAK,CAAC,cAAc;QACpC,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACjD,QAAQ,EAAE,KAAK,CAAC,QAAQ;KACzB,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Network } from './config.js';
|
|
2
|
+
type CommonCliOptions = {
|
|
3
|
+
network: Network;
|
|
4
|
+
json: boolean;
|
|
5
|
+
quiet: boolean;
|
|
6
|
+
onaraUrl: string;
|
|
7
|
+
timeoutMs: number;
|
|
8
|
+
};
|
|
9
|
+
export type CliPublishOptions = CommonCliOptions & {
|
|
10
|
+
operation: 'publish';
|
|
11
|
+
packagePath: string;
|
|
12
|
+
dryRun: boolean;
|
|
13
|
+
confirm: boolean;
|
|
14
|
+
suiBinary: string;
|
|
15
|
+
writePublished: boolean;
|
|
16
|
+
rpcUrl?: string;
|
|
17
|
+
};
|
|
18
|
+
export type CliStatusOptions = CommonCliOptions & {
|
|
19
|
+
operation: 'status';
|
|
20
|
+
digest: string;
|
|
21
|
+
};
|
|
22
|
+
export type CliOptions = CliPublishOptions | CliStatusOptions;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=cli-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-types.d.ts","sourceRoot":"","sources":["../src/cli-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAE1C,KAAK,gBAAgB,GAAG;IACtB,OAAO,EAAE,OAAO,CAAA;IAChB,IAAI,EAAE,OAAO,CAAA;IACb,KAAK,EAAE,OAAO,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG,gBAAgB,GAAG;IACjD,SAAS,EAAE,SAAS,CAAA;IACpB,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,OAAO,CAAA;IACf,OAAO,EAAE,OAAO,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,EAAE,OAAO,CAAA;IACvB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG,gBAAgB,GAAG;IAChD,SAAS,EAAE,QAAQ,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,UAAU,GAAG,iBAAiB,GAAG,gBAAgB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-types.js","sourceRoot":"","sources":["../src/cli-types.ts"],"names":[],"mappings":""}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|