bulletin-deploy 0.4.5 → 0.5.1
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/package.json +1 -1
- package/src/deploy.js +4 -4
- package/src/dotns.js +6 -6
- package/test/test.js +23 -2
package/package.json
CHANGED
package/src/deploy.js
CHANGED
|
@@ -268,12 +268,12 @@ export async function merkleize(directoryPath, outputCarPath) {
|
|
|
268
268
|
|
|
269
269
|
export async function storeDirectory(directoryPath) {
|
|
270
270
|
const carPath = path.join(path.dirname(directoryPath), `${path.basename(directoryPath)}.car`);
|
|
271
|
-
const { cid: ipfsCid } = await withSpan("deploy.merkleize", "merkleize", { "deploy.directory": directoryPath }, async () => {
|
|
271
|
+
const { cid: ipfsCid } = await withSpan("deploy.merkleize", "1a. merkleize", { "deploy.directory": directoryPath }, async () => {
|
|
272
272
|
return merkleize(directoryPath, carPath);
|
|
273
273
|
});
|
|
274
274
|
const carBuffer = fs.readFileSync(carPath);
|
|
275
275
|
const carChunks = chunk(carBuffer, CHUNK_SIZE);
|
|
276
|
-
const storageCid = await withSpan("deploy.chunk-upload", "chunk-upload", { "deploy.chunks.total": carChunks.length, "deploy.car.bytes": carBuffer.length }, async () => {
|
|
276
|
+
const storageCid = await withSpan("deploy.chunk-upload", "1b. chunk-upload", { "deploy.chunks.total": carChunks.length, "deploy.car.bytes": carBuffer.length }, async () => {
|
|
277
277
|
return storeChunkedContent(carChunks);
|
|
278
278
|
});
|
|
279
279
|
return { storageCid, ipfsCid };
|
|
@@ -296,7 +296,7 @@ export async function deploy(content, domainName = null) {
|
|
|
296
296
|
console.log("Storage");
|
|
297
297
|
console.log("=".repeat(60));
|
|
298
298
|
|
|
299
|
-
await withSpan("deploy.storage", "storage", {}, async () => {
|
|
299
|
+
await withSpan("deploy.storage", "1. storage", {}, async () => {
|
|
300
300
|
if (process.env.IPFS_CID) {
|
|
301
301
|
cid = process.env.IPFS_CID;
|
|
302
302
|
ipfsCid = cid;
|
|
@@ -344,7 +344,7 @@ export async function deploy(content, domainName = null) {
|
|
|
344
344
|
console.log("DotNS");
|
|
345
345
|
console.log("=".repeat(60));
|
|
346
346
|
|
|
347
|
-
await withSpan("deploy.dotns", "dotns", { "deploy.domain": name }, async () => {
|
|
347
|
+
await withSpan("deploy.dotns", "2. dotns", { "deploy.domain": name }, async () => {
|
|
348
348
|
const dotns = new DotNS();
|
|
349
349
|
await dotns.connect();
|
|
350
350
|
const { owned, owner } = await dotns.checkOwnership(name);
|
package/src/dotns.js
CHANGED
|
@@ -160,7 +160,7 @@ export function computeDomainTokenId(label) {
|
|
|
160
160
|
return BigInt(node);
|
|
161
161
|
}
|
|
162
162
|
export function countTrailingDigits(label) { let count = 0; for (let i = label.length - 1; i >= 0; i--) { const code = label.charCodeAt(i); if (code >= 48 && code <= 57) count++; else break; } return count; }
|
|
163
|
-
export function stripTrailingDigits(label) { return label.replace(/\d+$/, ""); }
|
|
163
|
+
export function stripTrailingDigits(label) { return label.replace(/\d+$/, "").replace(/-$/, ""); }
|
|
164
164
|
|
|
165
165
|
export function validateDomainLabel(label) {
|
|
166
166
|
if (!/^[a-z0-9-]{3,}$/.test(label)) throw new Error("Invalid domain label: must contain only lowercase letters, digits, and hyphens, min 3 chars");
|
|
@@ -492,7 +492,7 @@ export class DotNS {
|
|
|
492
492
|
}
|
|
493
493
|
|
|
494
494
|
async setContenthash(domainName, contenthashHex) {
|
|
495
|
-
return withSpan("deploy.dotns.set-contenthash", "set-contenthash", {}, async () => {
|
|
495
|
+
return withSpan("deploy.dotns.set-contenthash", "2b. set-contenthash", {}, async () => {
|
|
496
496
|
this.ensureConnected();
|
|
497
497
|
const node = namehash(`${domainName}.dot`);
|
|
498
498
|
let ipfsCid = null;
|
|
@@ -512,7 +512,7 @@ export class DotNS {
|
|
|
512
512
|
}
|
|
513
513
|
|
|
514
514
|
async register(label, options = {}) {
|
|
515
|
-
return withSpan("deploy.dotns.register", `register ${label}.dot`, {}, async () => {
|
|
515
|
+
return withSpan("deploy.dotns.register", `2a. register ${label}.dot`, {}, async () => {
|
|
516
516
|
const status = parseProofOfPersonhoodStatus(options.status || process.env.DOTNS_STATUS);
|
|
517
517
|
const reverse = options.reverse ?? (process.env.DOTNS_REVERSE ?? "false").toLowerCase() === "true";
|
|
518
518
|
if (!this.connected) await this.connect(options);
|
|
@@ -523,10 +523,10 @@ export class DotNS {
|
|
|
523
523
|
this.setUserPopStatus(status),
|
|
524
524
|
]);
|
|
525
525
|
const { commitment, registration } = await this.generateCommitment(label, reverse);
|
|
526
|
-
await withSpan("deploy.dotns.submit-commitment", "submit-commitment", {}, () => this.submitCommitment(commitment));
|
|
527
|
-
await withSpan("deploy.dotns.wait-commitment-age", "wait-commitment-age", {}, () => this.waitForCommitmentAge());
|
|
526
|
+
await withSpan("deploy.dotns.submit-commitment", "2a-i. submit-commitment", {}, () => this.submitCommitment(commitment));
|
|
527
|
+
await withSpan("deploy.dotns.wait-commitment-age", "2a-ii. wait-commitment-age", {}, () => this.waitForCommitmentAge());
|
|
528
528
|
const pricing = await this.getPriceAndValidate(label);
|
|
529
|
-
await withSpan("deploy.dotns.finalize-registration", "finalize-registration", {}, () => this.finalizeRegistration(registration, pricing.priceWei));
|
|
529
|
+
await withSpan("deploy.dotns.finalize-registration", "2a-iii. finalize-registration", {}, () => this.finalizeRegistration(registration, pricing.priceWei));
|
|
530
530
|
await this.verifyOwnership(label);
|
|
531
531
|
console.log(`\n Registration complete!`);
|
|
532
532
|
return { label, owner: this.evmAddress };
|
package/test/test.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { test, describe } from "node:test";
|
|
2
2
|
import assert from "node:assert/strict";
|
|
3
3
|
import { createCID, encodeContenthash } from "../src/deploy.js";
|
|
4
|
-
import { validateDomainLabel, fetchNonce, TX_TIMEOUT_MS } from "../src/dotns.js";
|
|
4
|
+
import { validateDomainLabel, stripTrailingDigits, fetchNonce, TX_TIMEOUT_MS } from "../src/dotns.js";
|
|
5
5
|
|
|
6
6
|
// ---------------------------------------------------------------------------
|
|
7
7
|
// 1. createCID
|
|
@@ -86,7 +86,28 @@ describe("validateDomainLabel", () => {
|
|
|
86
86
|
});
|
|
87
87
|
|
|
88
88
|
// ---------------------------------------------------------------------------
|
|
89
|
-
// 4.
|
|
89
|
+
// 4. stripTrailingDigits
|
|
90
|
+
// ---------------------------------------------------------------------------
|
|
91
|
+
describe("stripTrailingDigits", () => {
|
|
92
|
+
test("strips trailing digits", () => {
|
|
93
|
+
assert.strictEqual(stripTrailingDigits("my-app00"), "my-app");
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test("strips trailing hyphen after digits", () => {
|
|
97
|
+
assert.strictEqual(stripTrailingDigits("t3rminal-app-88-pr-80"), "t3rminal-app-88-pr");
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test("handles no trailing digits", () => {
|
|
101
|
+
assert.strictEqual(stripTrailingDigits("my-app"), "my-app");
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
test("handles all digits suffix", () => {
|
|
105
|
+
assert.strictEqual(stripTrailingDigits("app-123"), "app");
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// ---------------------------------------------------------------------------
|
|
110
|
+
// 5. fetchNonce timeout
|
|
90
111
|
// ---------------------------------------------------------------------------
|
|
91
112
|
describe("fetchNonce", () => {
|
|
92
113
|
test(
|