@helios-lang/contract-utils 0.3.22 → 0.3.23
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 +6 -0
- package/package.json +2 -1
- package/src/cli/config.mjs +1 -1
- package/src/cli/wallet-file.mjs +14 -0
- package/src/cli/wallet.mjs +51 -0
- package/src/helios.mjs +4 -1
- package/types/cli/config.d.mts +1 -0
- package/types/cli/config.d.mts.map +1 -1
package/README.md
CHANGED
|
@@ -46,3 +46,9 @@ Generated JS/TS exports `$debugger: {projectId,name,apiKey,endpoint,sources}` an
|
|
|
46
46
|
With the corresponding tx-utils release and ledger evaluation-observer support, `spendWithRedeemer()`, minting/staking methods, and attached programs automatically deliver failed builds to that project. No explicit `makeDebuggerService()` call is needed. `makeTxBuilder({isMainnet, debugger:false})` disables automatic capture; an explicit debugger service overrides bundle configuration. Unannotated bundles retain their existing behavior.
|
|
47
47
|
|
|
48
48
|
The API key is intentionally embedded in generated bundles, including browser bundles, and grants upload **and read** access to that project's feed. Use project-specific keys appropriate for that distribution. The key is sent in the authorization header, not in capture payloads. Omitting `--project` embeds no debugger credentials.
|
|
49
|
+
|
|
50
|
+
### Offline wallet generation
|
|
51
|
+
|
|
52
|
+
`helios wallet create --network preprod` prints JSON containing a cryptographically random 24-word recovery phrase and its base address. It does not contact a service. Supported networks are `preprod` (default), `preview`, and `mainnet`.
|
|
53
|
+
|
|
54
|
+
Use `helios wallet create --network preprod --out wallet.json` to write a new private file instead of printing the phrase. Existing files are never overwritten. The output phrase can be pasted into a demo’s ignored `.env.local` file.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helios-lang/contract-utils",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.23",
|
|
4
4
|
"description": "Convenience and type-safety utilities for using Helios validators from within Typescript",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"@helios-lang/compiler-utils": "^0.5.15",
|
|
43
43
|
"@helios-lang/crypto": "0.2.3",
|
|
44
44
|
"@helios-lang/ledger": "^0.7.8",
|
|
45
|
+
"@helios-lang/tx-utils": "^0.6.41",
|
|
45
46
|
"@helios-lang/type-utils": "^0.3.0",
|
|
46
47
|
"@helios-lang/uplc": "^0.7.15",
|
|
47
48
|
"open": "^10.2.0"
|
package/src/cli/config.mjs
CHANGED
|
@@ -13,7 +13,7 @@ import { randomUUID } from "node:crypto"
|
|
|
13
13
|
import { execFile } from "node:child_process"
|
|
14
14
|
import { promisify } from "node:util"
|
|
15
15
|
const exec = promisify(execFile)
|
|
16
|
-
async function windowsAcl(path, directory, set = false) {
|
|
16
|
+
export async function windowsAcl(path, directory, set = false) {
|
|
17
17
|
// Pass paths through the environment, never interpolate them into PowerShell.
|
|
18
18
|
const script = `
|
|
19
19
|
$ErrorActionPreference = 'Stop'
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { open, unlink } from "node:fs/promises"
|
|
2
|
+
import { windowsAcl } from "./config.mjs"
|
|
3
|
+
export async function writePrivateWallet(path, json) {
|
|
4
|
+
const file = await open(path, "wx", 0o600)
|
|
5
|
+
try {
|
|
6
|
+
if (process.platform === "win32") await windowsAcl(path, false, true)
|
|
7
|
+
await file.writeFile(json, "utf8")
|
|
8
|
+
} catch (error) {
|
|
9
|
+
await file.close()
|
|
10
|
+
await unlink(path)
|
|
11
|
+
throw error
|
|
12
|
+
}
|
|
13
|
+
await file.close()
|
|
14
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { randomBytes } from "node:crypto"
|
|
2
|
+
import { parseArgs } from "node:util"
|
|
3
|
+
import { makeRootPrivateKey } from "@helios-lang/tx-utils"
|
|
4
|
+
import { makeShelleyAddress } from "@helios-lang/ledger"
|
|
5
|
+
|
|
6
|
+
export function createWallet(network = "preprod") {
|
|
7
|
+
if (!["preprod", "preview", "mainnet"].includes(network))
|
|
8
|
+
throw new Error("Network must be preprod, preview, or mainnet")
|
|
9
|
+
const key = makeRootPrivateKey([...randomBytes(32)])
|
|
10
|
+
const address = makeShelleyAddress(
|
|
11
|
+
network === "mainnet",
|
|
12
|
+
key.deriveSpendingKey().derivePubKey().hash(),
|
|
13
|
+
key.deriveStakingKey().derivePubKey().hash()
|
|
14
|
+
)
|
|
15
|
+
return {
|
|
16
|
+
network,
|
|
17
|
+
phrase: key.toPhrase().join(" "),
|
|
18
|
+
address: address.toBech32()
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export async function walletCommand(args) {
|
|
22
|
+
const [command, ...rest] = args
|
|
23
|
+
if (["--help", "-h", "help"].includes(command)) {
|
|
24
|
+
console.log(
|
|
25
|
+
"helios wallet create [--network preprod|preview|mainnet] [--out wallet.json]\nGenerates a 24-word recovery phrase and address offline. Without --out, prints the secret phrase as JSON. --out creates a new owner-only file and never overwrites an existing file."
|
|
26
|
+
)
|
|
27
|
+
return
|
|
28
|
+
}
|
|
29
|
+
if (command !== "create")
|
|
30
|
+
throw new Error(
|
|
31
|
+
"Usage: helios wallet create [--network preprod|preview|mainnet] [--out wallet.json]"
|
|
32
|
+
)
|
|
33
|
+
const { values } = parseArgs({
|
|
34
|
+
args: rest,
|
|
35
|
+
options: {
|
|
36
|
+
network: { type: "string", default: "preprod" },
|
|
37
|
+
out: { type: "string" }
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
const wallet = createWallet(values.network)
|
|
41
|
+
const json = JSON.stringify(wallet, null, 2) + "\n"
|
|
42
|
+
if (values.out !== undefined) {
|
|
43
|
+
if (!values.out.trim()) throw new Error("--out requires a file path")
|
|
44
|
+
// Reuse credential-file ACL protection on Windows, before storing secrets.
|
|
45
|
+
const { writePrivateWallet } = await import("./wallet-file.mjs")
|
|
46
|
+
await writePrivateWallet(values.out, json)
|
|
47
|
+
console.log(
|
|
48
|
+
`Created ${wallet.network} wallet: ${wallet.address}\nRecovery phrase saved in ${values.out}`
|
|
49
|
+
)
|
|
50
|
+
} else console.log(json)
|
|
51
|
+
}
|
package/src/helios.mjs
CHANGED
|
@@ -7,6 +7,9 @@ try {
|
|
|
7
7
|
await compile(
|
|
8
8
|
args.map((arg) => (["--help", "-h"].includes(arg) ? "help" : arg))
|
|
9
9
|
)
|
|
10
|
+
} else if (command === "wallet") {
|
|
11
|
+
const { walletCommand } = await import("./cli/wallet.mjs")
|
|
12
|
+
await walletCommand(args)
|
|
10
13
|
} else if (command === "login") {
|
|
11
14
|
if (args.some((arg) => arg !== "--no-browser"))
|
|
12
15
|
throw new Error("Usage: helios login [--no-browser]")
|
|
@@ -38,7 +41,7 @@ try {
|
|
|
38
41
|
)
|
|
39
42
|
} else if (!command || ["--help", "-h", "help"].includes(command)) {
|
|
40
43
|
console.log(
|
|
41
|
-
"Helios CLI\n\n helios compile [options] Compile contracts (same options as hl2ts)\n helios login [--no-browser] Install project API keys through the Console\n helios --version"
|
|
44
|
+
"Helios CLI\n\n helios compile [options] Compile contracts (same options as hl2ts)\n helios login [--no-browser] Install project API keys through the Console\n helios wallet create [--network preprod] [--out wallet.json] Generate a wallet offline\n helios --version"
|
|
42
45
|
)
|
|
43
46
|
} else throw new Error(`Unknown command: ${command}. Run helios --help.`)
|
|
44
47
|
} catch (error) {
|
package/types/cli/config.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export function windowsAcl(path: any, directory: any, set?: boolean): Promise<void>;
|
|
1
2
|
export function configPath(platform?: NodeJS.Platform, env?: NodeJS.ProcessEnv, home?: string): string;
|
|
2
3
|
export function readConfig(path?: string): Promise<any>;
|
|
3
4
|
export function installProjects(wallet: any, projects: any, endpoint: any, path?: string): Promise<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.mts","sourceRoot":"","sources":["../../src/cli/config.mjs"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.mts","sourceRoot":"","sources":["../../src/cli/config.mjs"],"names":[],"mappings":"AAeA,oFAiCC;AACD,uGAcC;AAqBD,wDAaC;AACD,2GA2DC"}
|