@parity/product-deploy 0.9.0 → 0.10.0-rc.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.
Files changed (61) hide show
  1. package/DEPLOYMENT.md +124 -0
  2. package/README.md +73 -6
  3. package/assets/environments.json +41 -0
  4. package/bin/bulletin-deploy +49 -21
  5. package/dist/allocations-CEPeZr6T.d.ts +111 -0
  6. package/dist/auth/index.d.ts +3 -2
  7. package/dist/auth/index.js +5 -1
  8. package/dist/auth/vendor/index.d.ts +3 -2
  9. package/dist/auth/vendor/index.js +5 -1
  10. package/dist/auth/vendor/ui/index.d.ts +2 -1
  11. package/dist/auth-CA_YKtM2.d.ts +128 -0
  12. package/dist/auth-config.d.ts +13 -8
  13. package/dist/auth-config.js +4 -4
  14. package/dist/bug-report.js +4 -4
  15. package/dist/{chunk-56QBW25C.js → chunk-2GDPXSW3.js} +5 -5
  16. package/dist/{chunk-GCKWJS2T.js → chunk-4ADUQDYJ.js} +140 -32
  17. package/dist/{chunk-DHY2ZXVZ.js → chunk-5OKB3TEB.js} +8 -1
  18. package/dist/{chunk-C7UJ6WZR.js → chunk-64RSUZN4.js} +10 -2
  19. package/dist/{chunk-D7KZZDU7.js → chunk-HA7BNUK3.js} +1 -1
  20. package/dist/{chunk-5UE2IWNB.js → chunk-HEUKYXEZ.js} +1 -1
  21. package/dist/{chunk-UC2AYO2P.js → chunk-HOO5NKN3.js} +1 -1
  22. package/dist/{chunk-GL3U7K2B.js → chunk-QRKI6MMK.js} +41 -0
  23. package/dist/{chunk-A3O7TLCS.js → chunk-RX3ZUVVS.js} +4 -3
  24. package/dist/{chunk-FNCBSJ6R.js → chunk-S42FFXAR.js} +2 -2
  25. package/dist/{chunk-AQHBKIFF.js → chunk-VHAKRWRH.js} +3 -3
  26. package/dist/{chunk-WAKSNE7F.js → chunk-ZF2SEY7S.js} +115 -29
  27. package/dist/chunk-probe.js +3 -3
  28. package/dist/commands/login.d.ts +42 -6
  29. package/dist/commands/login.js +89 -37
  30. package/dist/commands/logout.d.ts +2 -1
  31. package/dist/commands/logout.js +6 -6
  32. package/dist/commands/transfer.d.ts +14 -0
  33. package/dist/commands/transfer.js +67 -0
  34. package/dist/commands/whoami.d.ts +2 -1
  35. package/dist/commands/whoami.js +4 -4
  36. package/dist/deploy-actors.d.ts +24 -0
  37. package/dist/deploy-actors.js +44 -0
  38. package/dist/deploy.d.ts +20 -1
  39. package/dist/deploy.js +15 -10
  40. package/dist/dotns.d.ts +42 -7
  41. package/dist/dotns.js +15 -6
  42. package/dist/environments.js +1 -1
  43. package/dist/index.js +16 -15
  44. package/dist/manifest/publish.js +12 -11
  45. package/dist/memory-report.js +2 -2
  46. package/dist/merkle.js +11 -10
  47. package/dist/personhood/bootstrap.js +11 -11
  48. package/dist/personhood/people-client.js +5 -4
  49. package/dist/run-state.js +1 -1
  50. package/dist/{signer-vR6KKC7V.d.ts → signer-Duup0hgQ.d.ts} +1 -1
  51. package/dist/sss-allowance-cache.js +5 -5
  52. package/dist/storage-signer.js +11 -10
  53. package/dist/telemetry.d.ts +17 -1
  54. package/dist/telemetry.js +4 -2
  55. package/dist/version-check.js +3 -3
  56. package/docs/bootstrap.md +1 -1
  57. package/docs/e2e-bootstrap.md +34 -12
  58. package/docs/telemetry.md +10 -11
  59. package/docs/testing.md +2 -0
  60. package/package.json +4 -3
  61. package/dist/auth-C-Pel0AT.d.ts +0 -235
@@ -1,23 +1,27 @@
1
1
  import {
2
+ BULLETIN_RESOURCE,
2
3
  DEFAULT_RESOURCES,
3
4
  INCOMPLETE_SESSION_MESSAGE,
4
5
  SignerNotAvailableError,
5
6
  createAuthClient,
6
7
  createSessionSigner,
8
+ createSlotAccountSigner,
7
9
  deriveProductPublicKey,
8
10
  parseDevAccountName,
9
11
  requestResourceAllocation,
10
12
  resolveSigner,
11
13
  sessionRootPublicKey,
12
14
  summarizeOutcomes
13
- } from "../../chunk-DHY2ZXVZ.js";
15
+ } from "../../chunk-5OKB3TEB.js";
14
16
  import "../../chunk-ZOC4GITL.js";
15
17
  export {
18
+ BULLETIN_RESOURCE,
16
19
  DEFAULT_RESOURCES,
17
20
  INCOMPLETE_SESSION_MESSAGE,
18
21
  SignerNotAvailableError,
19
22
  createAuthClient,
20
23
  createSessionSigner,
24
+ createSlotAccountSigner,
21
25
  deriveProductPublicKey,
22
26
  parseDevAccountName,
23
27
  requestResourceAllocation,
@@ -1,6 +1,7 @@
1
1
  export { renderQrCode } from '@parity/product-sdk-terminal';
2
- import { e as LoginStatus, g as LogoutStatus } from '../../../auth-C-Pel0AT.js';
2
+ import { b as LoginStatus, d as LogoutStatus } from '../../../auth-CA_YKtM2.js';
3
3
  import 'polkadot-api';
4
+ import '../../../allocations-CEPeZr6T.js';
4
5
 
5
6
  /**
6
7
  * Pure formatters that map the `LoginStatus` / `LogoutStatus` streams to
@@ -0,0 +1,128 @@
1
+ import { TerminalAdapter, UserSession } from '@parity/product-sdk-terminal';
2
+ import { PolkadotSigner } from 'polkadot-api';
3
+ import { A as AllocatableResource, O as OnExistingAllowancePolicy, a as AllocationOutcome } from './allocations-CEPeZr6T.js';
4
+
5
+ /**
6
+ * Per-product configuration injected into `createAuthClient`. Lifting the
7
+ * sign-in glue out of playground-cli (issue #411) means the env-specific
8
+ * constants playground hard-coded in its `config.ts` (DAPP_ID, product id,
9
+ * metadata URL, People-chain endpoints) become consumer-supplied so the same
10
+ * package serves `playground` and `dot` (and future products) unchanged.
11
+ */
12
+ interface AuthConfig {
13
+ /** The dApp identity string. Scopes the on-disk session namespace
14
+ * (`~/.polkadot-apps/${dappId}_*`) and the SSO pairing — each product
15
+ * gets its own, independently-revocable session. */
16
+ dappId: string;
17
+ /** Product id used to derive the product account (`/product/{productId}/{index}`). */
18
+ productId: string;
19
+ /** Derivation index of the product account (0 = default). */
20
+ derivationIndex: number;
21
+ /** Wallet-facing app name shown on the Sign-In screen (sent inline at pairing). */
22
+ hostName: string;
23
+ /** Host app version sent inline at pairing. */
24
+ hostVersion: string;
25
+ /** People-parachain RPC endpoints the terminal adapter connects to. */
26
+ peopleEndpoints: string[];
27
+ }
28
+
29
+ /**
30
+ * The three addresses we surface from a paired session.
31
+ *
32
+ * - `rootAddress` — SS58 of `session.rootAccountId`, the `rootUserAccountId`
33
+ * the mobile app sent over the SSO handshake (bare-mnemonic sr25519 root on
34
+ * current mobile builds). Keyed by `Resources.Consumers` on the People
35
+ * parachain, so it's the right input for `lookupUsername`.
36
+ * - `productAddress` — SS58 of the product account derived via
37
+ * `product/{productId}/{index}` from `rootAccountId`. This is what actually
38
+ * signs on-chain transactions from the CLI.
39
+ * - `productH160` — the same product pubkey as a 20-byte EVM address (Revive /
40
+ * contracts view). Derived from the SAME pubkey as `productAddress`.
41
+ */
42
+ interface SessionAddresses {
43
+ rootAddress: string;
44
+ productAddress: string;
45
+ productH160: `0x${string}`;
46
+ }
47
+ type ConnectResult = {
48
+ kind: "existing";
49
+ address: string;
50
+ addresses: SessionAddresses;
51
+ } | {
52
+ kind: "qr";
53
+ qrCode: string;
54
+ login: LoginHandle;
55
+ };
56
+ type LoginStatus = {
57
+ step: "waiting";
58
+ } | {
59
+ step: "paired";
60
+ } | {
61
+ step: "pending";
62
+ stage: string;
63
+ } | {
64
+ step: "success";
65
+ address: string;
66
+ addresses: SessionAddresses;
67
+ } | {
68
+ step: "error";
69
+ message: string;
70
+ };
71
+ interface LoginHandle {
72
+ adapter: TerminalAdapter;
73
+ /** The authenticate() promise — already running since connect(). */
74
+ authPromise: ReturnType<TerminalAdapter["sso"]["authenticate"]>;
75
+ }
76
+ /**
77
+ * A session signer bundle — the signer plus an explicit `destroy()` that tears
78
+ * down the long-lived adapter the signer depends on. Callers MUST invoke
79
+ * `destroy()` once done — the WebSocket keeps the event loop alive.
80
+ *
81
+ * `adapter` is exposed so callers that need to send a host request (e.g.
82
+ * `requestResourceAllocation`) can pass it without creating a second WebSocket.
83
+ */
84
+ interface SessionHandle {
85
+ address: string;
86
+ addresses: SessionAddresses;
87
+ signer: PolkadotSigner;
88
+ userSession: UserSession;
89
+ adapter: TerminalAdapter;
90
+ destroy(): void;
91
+ }
92
+ type LogoutStatus = {
93
+ step: "disconnecting";
94
+ address: string;
95
+ } | {
96
+ step: "success";
97
+ address: string;
98
+ } | {
99
+ step: "partial";
100
+ address: string;
101
+ reason: string;
102
+ } | {
103
+ step: "error";
104
+ message: string;
105
+ };
106
+ interface LogoutHandle {
107
+ adapter: TerminalAdapter;
108
+ address: string;
109
+ session: UserSession;
110
+ }
111
+ /** The product-bound auth surface returned by `createAuthClient`. */
112
+ interface AuthClient {
113
+ connect(): Promise<ConnectResult>;
114
+ waitForLogin(handle: LoginHandle, onStatus: (status: LoginStatus) => void): Promise<SessionHandle | null>;
115
+ getSessionSigner(): Promise<SessionHandle | null>;
116
+ findSession(): Promise<LogoutHandle | null>;
117
+ waitForLogout(handle: LogoutHandle, onStatus: (status: LogoutStatus) => void): Promise<void>;
118
+ requestAllocation(session: UserSession, adapter: TerminalAdapter, resources?: AllocatableResource[], onExisting?: OnExistingAllowancePolicy): Promise<AllocationOutcome[]>;
119
+ clearLocalAppStorage(dir?: string): Promise<void>;
120
+ }
121
+ /**
122
+ * Build an auth client bound to a product's `AuthConfig`. All adapter creation,
123
+ * address derivation, and session-storage scoping read from `config`, so the
124
+ * same code serves any product.
125
+ */
126
+ declare function createAuthClient(config: AuthConfig): AuthClient;
127
+
128
+ export { type AuthClient as A, type ConnectResult as C, type LoginHandle as L, type SessionAddresses as S, type AuthConfig as a, type LoginStatus as b, type LogoutHandle as c, type LogoutStatus as d, type SessionHandle as e, createAuthClient as f };
@@ -1,18 +1,23 @@
1
- import { d as AuthConfig, c as AuthClient } from './auth-C-Pel0AT.js';
1
+ import { a as AuthConfig, A as AuthClient } from './auth-CA_YKtM2.js';
2
2
  import { EnvironmentsDoc } from './environments.js';
3
3
  import '@parity/product-sdk-terminal';
4
4
  import 'polkadot-api';
5
+ import './allocations-CEPeZr6T.js';
5
6
 
6
- /** dApp identity that scopes the SSO session namespace on disk. Currently reuses
7
- * playground's identity for dev; swap to e.g. "dot-deploy" when the package is renamed. */
8
- declare const DOT_DAPP_ID = "dot-cli";
7
+ /** dApp identity: scopes the SSO session namespace + terminal allowance cache on disk
8
+ * and the wallet pairing product. Aligned to the app's dedicated id "polkadot-app-deploy". */
9
+ declare const DOT_DAPP_ID = "polkadot-app-deploy";
9
10
  /** Product id used for product-account derivation (`/product/{productId}/{index}`).
10
- * Reuses playground's product id so dev sessions are shared. */
11
- declare const DOT_PRODUCT_ID = "playground.dot";
11
+ * UNIFIED with DOT_DAPP_ID (#885): the wallet funds PGAS to product/{appId}/{index},
12
+ * so deriving the signer/owner under the same id lands the account where PGAS sits —
13
+ * one account is owner + AH signer + PGAS-funded. Requires a fresh re-pairing so the
14
+ * Bulletin/statement allowance is also claimed under this id (verify the wallet serves
15
+ * "polkadot-app-deploy"; that's the open mobile-side question). */
16
+ declare const DOT_PRODUCT_ID = "polkadot-app-deploy";
12
17
  /** Derivation index (0 = default product account). */
13
18
  declare const DOT_DERIVATION_INDEX = 0;
14
- /** Wallet-facing app name shown on the Sign-In screen; #850 flips this at the package rename. */
15
- declare const DOT_HOST_NAME = "bulletin-deploy";
19
+ /** Wallet-facing app name shown on the Sign-In screen. Aligned to the unified identity. */
20
+ declare const DOT_HOST_NAME = "polkadot-app-deploy";
16
21
  /**
17
22
  * Shown when a persisted session file exists but the V2 codec cannot decode it —
18
23
  * typically a v0.7 SCALE blob that is structurally incompatible with the V2 wire format.
@@ -9,10 +9,10 @@ import {
9
9
  getPeopleChainEndpoints,
10
10
  hasPersistedSession,
11
11
  resolveBulletinEndpoints
12
- } from "./chunk-56QBW25C.js";
13
- import "./chunk-C7UJ6WZR.js";
14
- import "./chunk-A3O7TLCS.js";
15
- import "./chunk-GL3U7K2B.js";
12
+ } from "./chunk-2GDPXSW3.js";
13
+ import "./chunk-64RSUZN4.js";
14
+ import "./chunk-RX3ZUVVS.js";
15
+ import "./chunk-QRKI6MMK.js";
16
16
  import "./chunk-ZOC4GITL.js";
17
17
  export {
18
18
  DOT_DAPP_ID,
@@ -9,10 +9,10 @@ import {
9
9
  offerBugReport,
10
10
  scrubSecrets,
11
11
  setDeployContext
12
- } from "./chunk-FNCBSJ6R.js";
13
- import "./chunk-UC2AYO2P.js";
14
- import "./chunk-C7UJ6WZR.js";
15
- import "./chunk-A3O7TLCS.js";
12
+ } from "./chunk-S42FFXAR.js";
13
+ import "./chunk-HOO5NKN3.js";
14
+ import "./chunk-64RSUZN4.js";
15
+ import "./chunk-RX3ZUVVS.js";
16
16
  export {
17
17
  buildCliFlagsSummary,
18
18
  buildLabels,
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  VERSION
3
- } from "./chunk-C7UJ6WZR.js";
3
+ } from "./chunk-64RSUZN4.js";
4
4
  import {
5
5
  loadEnvironments
6
- } from "./chunk-GL3U7K2B.js";
6
+ } from "./chunk-QRKI6MMK.js";
7
7
 
8
8
  // src/auth-config.ts
9
9
  import { existsSync, readdirSync } from "fs";
10
10
  import { homedir } from "os";
11
11
  import { join } from "path";
12
- var DOT_DAPP_ID = "dot-cli";
13
- var DOT_PRODUCT_ID = "playground.dot";
12
+ var DOT_DAPP_ID = "polkadot-app-deploy";
13
+ var DOT_PRODUCT_ID = DOT_DAPP_ID;
14
14
  var DOT_DERIVATION_INDEX = 0;
15
- var DOT_HOST_NAME = "bulletin-deploy";
15
+ var DOT_HOST_NAME = "polkadot-app-deploy";
16
16
  var STALE_SESSION_MESSAGE = 'Stored login session could not be read \u2014 it may have been written by an older version. Run "bulletin-deploy logout", then "bulletin-deploy login" to pair again.';
17
17
  function hasPersistedSession() {
18
18
  const dir = join(homedir(), ".polkadot-apps");
@@ -1,3 +1,6 @@
1
+ import {
2
+ PGAS_ASSET_LOCATION
3
+ } from "./chunk-SI2ZUOYD.js";
1
4
  import {
2
5
  isTestnetSpecName
3
6
  } from "./chunk-4PVJ2JBZ.js";
@@ -8,10 +11,10 @@ import {
8
11
  setDeploySentryTag,
9
12
  truncateAddress,
10
13
  withSpan
11
- } from "./chunk-C7UJ6WZR.js";
14
+ } from "./chunk-64RSUZN4.js";
12
15
  import {
13
16
  validateContractAddresses
14
- } from "./chunk-GL3U7K2B.js";
17
+ } from "./chunk-QRKI6MMK.js";
15
18
  import {
16
19
  NonRetryableError
17
20
  } from "./chunk-ZOC4GITL.js";
@@ -60,9 +63,16 @@ var FEE_FLOOR_REGISTER = ONE_PAS / 10n;
60
63
  var TOP_UP_TARGET = ONE_PAS / 2n;
61
64
  var SOURCE_BUFFER = ONE_PAS;
62
65
  var MINIMUM_REGISTER_STORAGE_DEPOSIT = 2000000000000n;
63
- var REGISTER_RENT_PRICE_WEI = 10n * 10n ** 18n;
64
- function bufferedRentNative(nativeToEthRatio) {
65
- return REGISTER_RENT_PRICE_WEI * 110n / (100n * nativeToEthRatio);
66
+ function registerDepositWei(userStatus, startingPriceWei) {
67
+ return userStatus === ProofOfPersonhoodStatus.NoStatus ? startingPriceWei : 0n;
68
+ }
69
+ function bufferedWeiToNative(weiValue, nativeToEthRatio) {
70
+ return weiToNative(weiValue * 110n / 100n, nativeToEthRatio);
71
+ }
72
+ function weiToNative(feeWei, nativeToEthRatio) {
73
+ if (feeWei === 0n) return 0n;
74
+ const native = feeWei / nativeToEthRatio;
75
+ return feeWei % nativeToEthRatio === 0n ? native : native + 1n;
66
76
  }
67
77
  var REPROVE_FEE_ESTIMATE = ONE_PAS / 100n;
68
78
  var REPROVE_FEE_SAFETY_MARGIN_PCT = 110n;
@@ -78,13 +88,16 @@ function resolveNativeTokenSymbol(envId) {
78
88
  if (envId.includes("rococo")) return "ROC";
79
89
  return "PAS";
80
90
  }
81
- function feeFloorFor(plannedAction, storageDeposit = MINIMUM_REGISTER_STORAGE_DEPOSIT, rentPriceNative = 0n) {
82
- if (plannedAction === "already-owned-by-us") return FEE_FLOOR_OWNED;
83
- return FEE_FLOOR_REGISTER + storageDeposit + rentPriceNative;
91
+ function isOwnedAction(plannedAction) {
92
+ return plannedAction === "already-owned-by-us" || plannedAction === "already-owned-by-recipient";
84
93
  }
85
- function topUpTargetFor(plannedAction, storageDeposit = MINIMUM_REGISTER_STORAGE_DEPOSIT, rentPriceNative = 0n) {
86
- if (plannedAction === "already-owned-by-us") return TOP_UP_TARGET;
87
- return TOP_UP_TARGET + storageDeposit + rentPriceNative;
94
+ function feeFloorFor(plannedAction, storageDeposit = MINIMUM_REGISTER_STORAGE_DEPOSIT, rentPriceNative = 0n, transferFeeNative = 0n) {
95
+ if (isOwnedAction(plannedAction)) return FEE_FLOOR_OWNED + transferFeeNative;
96
+ return FEE_FLOOR_REGISTER + storageDeposit + rentPriceNative + transferFeeNative;
97
+ }
98
+ function topUpTargetFor(plannedAction, storageDeposit = MINIMUM_REGISTER_STORAGE_DEPOSIT, rentPriceNative = 0n, transferFeeNative = 0n) {
99
+ if (isOwnedAction(plannedAction)) return TOP_UP_TARGET + transferFeeNative;
100
+ return TOP_UP_TARGET + storageDeposit + rentPriceNative + transferFeeNative;
88
101
  }
89
102
  var RPC_ENDPOINTS = [
90
103
  "wss://asset-hub-paseo.dotters.network",
@@ -130,6 +143,9 @@ function dotnsRetryBackoffMs(attempt, rand = Math.random) {
130
143
  const ceil = Math.min(DOTNS_RETRY_BASE_MS * 2 ** (attempt - 1), DOTNS_RETRY_MAX_MS);
131
144
  return Math.round(ceil * (0.5 + rand() * 0.5));
132
145
  }
146
+ function shouldRetryTxAttempt(attempt, maxAttempts, decision) {
147
+ return decision === "retry" && attempt < maxAttempts;
148
+ }
133
149
  function makeRetryStatusFilter(sink) {
134
150
  let buffered = false;
135
151
  return {
@@ -211,12 +227,18 @@ var DOTNS_REGISTRAR_CONTROLLER_ABI = [
211
227
  var DOTNS_REGISTRAR_ABI = [
212
228
  { inputs: [{ name: "tokenId", type: "uint256" }], name: "ownerOf", outputs: [{ name: "", type: "address" }], stateMutability: "view", type: "function" }
213
229
  ];
230
+ var DOTNS_REGISTRAR_TRANSFER_ABI = [
231
+ ...DOTNS_REGISTRAR_ABI,
232
+ { inputs: [{ name: "from", type: "address" }, { name: "to", type: "address" }, { name: "tokenId", type: "uint256" }], name: "transferFrom", outputs: [], stateMutability: "payable", type: "function" }
233
+ ];
214
234
  var POP_RULES_ABI = [
215
235
  { inputs: [{ name: "name", type: "string" }], name: "classifyName", outputs: [{ name: "requirement", type: "uint8" }, { name: "message", type: "string" }], stateMutability: "pure", type: "function" },
216
236
  { inputs: [{ name: "name", type: "string" }], name: "price", outputs: [{ name: "", type: "uint256" }], stateMutability: "view", type: "function" },
217
237
  { inputs: [{ name: "name", type: "string" }, { name: "userAddress", type: "address" }], name: "priceWithCheck", outputs: [{ name: "metadata", type: "tuple", components: [{ name: "price", type: "uint256" }, { name: "status", type: "uint8" }, { name: "userStatus", type: "uint8" }, { name: "message", type: "string" }] }], stateMutability: "view", type: "function" },
218
238
  { inputs: [{ name: "name", type: "string" }, { name: "userAddress", type: "address" }], name: "priceWithoutCheck", outputs: [{ name: "metadata", type: "tuple", components: [{ name: "price", type: "uint256" }, { name: "status", type: "uint8" }, { name: "userStatus", type: "uint8" }, { name: "message", type: "string" }] }], stateMutability: "view", type: "function" },
219
- { inputs: [{ name: "name", type: "string" }], name: "isBaseNameReserved", outputs: [{ name: "isReserved", type: "bool" }, { name: "reservationOwner", type: "address" }, { name: "expiryTimestamp", type: "uint64" }], stateMutability: "view", type: "function" }
239
+ { inputs: [{ name: "name", type: "string" }], name: "isBaseNameReserved", outputs: [{ name: "isReserved", type: "bool" }, { name: "reservationOwner", type: "address" }, { name: "expiryTimestamp", type: "uint64" }], stateMutability: "view", type: "function" },
240
+ { inputs: [{ name: "name", type: "string" }, { name: "from", type: "address" }, { name: "to", type: "address" }], name: "transferFloor", outputs: [{ name: "", type: "uint256" }], stateMutability: "view", type: "function" },
241
+ { inputs: [], name: "startingPrice", outputs: [{ name: "", type: "uint256" }], stateMutability: "view", type: "function" }
220
242
  ];
221
243
  var PERSONHOOD_ABI = [
222
244
  {
@@ -343,6 +365,9 @@ function formatWeight(weight) {
343
365
  return `ref_time=${weight.referenceTime.toString()} proof_size=${weight.proofSize.toString()}`;
344
366
  }
345
367
  var BARE_REVERT_DIAGNOSTIC_FUNCTIONS = /* @__PURE__ */ new Set(["register", "commit", "setContenthash", "setSubnodeOwner", "setResolver"]);
368
+ var PGAS_FEE_OPTIONS = {
369
+ customSignedExtensions: { ChargeAssetTxPayment: { value: { tip: 0n, asset_id: PGAS_ASSET_LOCATION } } }
370
+ };
346
371
  function formatContractDryRunFailure(gasEstimate, context) {
347
372
  const functionName = context.functionName ?? "unknown";
348
373
  const contractName = dotnsContractName(context.contractAddress, context.contracts);
@@ -698,7 +723,7 @@ var ReviveClientWrapper = class _ReviveClientWrapper {
698
723
  };
699
724
  deadlinePoller = setTimeout(poll, 6e3);
700
725
  try {
701
- sub = extrinsic.signSubmitAndWatch(signer, { mortality: { mortal: true, period: 256 } }).subscribe({
726
+ sub = extrinsic.signSubmitAndWatch(signer, { mortality: { mortal: true, period: 256 }, ...opts.feeAsset === "pgas" ? PGAS_FEE_OPTIONS : {} }).subscribe({
702
727
  next: (event) => {
703
728
  lastEventAt = Date.now();
704
729
  lastEventType = event.type;
@@ -757,9 +782,13 @@ var ReviveClientWrapper = class _ReviveClientWrapper {
757
782
  } catch (e) {
758
783
  lastError = e;
759
784
  const decision = classifyTxRetryDecision(e);
760
- if (decision === "abort" || attempt === DOTNS_TX_MAX_ATTEMPTS) break;
761
- const ms = dotnsRetryBackoffMs(attempt);
762
785
  const msg = e?.message ?? String(e);
786
+ if (!shouldRetryTxAttempt(attempt, DOTNS_TX_MAX_ATTEMPTS, decision)) {
787
+ const reason = decision === "abort" ? "not retryable" : "out of attempts";
788
+ console.log(` ${label}: attempt ${attempt}/${DOTNS_TX_MAX_ATTEMPTS} failed (${msg}) \u2014 giving up (${reason})`);
789
+ break;
790
+ }
791
+ const ms = dotnsRetryBackoffMs(attempt);
763
792
  console.log(` ${label}: attempt ${attempt}/${DOTNS_TX_MAX_ATTEMPTS} failed (${msg}), retrying in ${ms}ms\u2026`);
764
793
  await new Promise((r) => setTimeout(r, ms));
765
794
  }
@@ -795,7 +824,7 @@ var ReviveClientWrapper = class _ReviveClientWrapper {
795
824
  storage_deposit_limit: storageDepositLimit
796
825
  };
797
826
  }
798
- async submitTransaction(contractAddress, value, encodedData, signerSubstrateAddress, signer, statusCallback, { rpcs, useNoncePolling, functionName, args, contracts, verifyEffect }) {
827
+ async submitTransaction(contractAddress, value, encodedData, signerSubstrateAddress, signer, statusCallback, { rpcs, useNoncePolling, functionName, args, contracts, verifyEffect, feeAsset }) {
799
828
  await this.ensureAccountMapped(signerSubstrateAddress, signer);
800
829
  if (functionName === "register") {
801
830
  try {
@@ -827,7 +856,7 @@ var ReviveClientWrapper = class _ReviveClientWrapper {
827
856
  "chain.tx.submit",
828
857
  `sign+submit ${functionName ?? "Revive.call"}`,
829
858
  { "chain.function_name": functionName ?? "Revive.call", "chain.use_nonce_polling": Boolean(useNoncePolling) },
830
- () => this.signAndSubmitWithRetry(buildExtrinsic, signer, statusCallback, "Revive.call", { nonceFallback, verifyEffect })
859
+ () => this.signAndSubmitWithRetry(buildExtrinsic, signer, statusCallback, "Revive.call", { nonceFallback, verifyEffect, feeAsset })
831
860
  );
832
861
  }
833
862
  // Dry-runs each call individually, then wraps them in a single
@@ -1429,13 +1458,13 @@ var DotNS = class {
1429
1458
  return decodeFunctionResult({ abi: contractAbi, functionName, data: rawData });
1430
1459
  }
1431
1460
  async contractTransaction(contractAddress, value, contractAbi, functionName, args = [], statusCallback = () => {
1432
- }, { useNoncePolling, verifyEffect } = {}) {
1461
+ }, { useNoncePolling, verifyEffect, feeAsset } = {}) {
1433
1462
  this.ensureConnected();
1434
1463
  if (!this.clientWrapper) throw new Error("contractTransaction: polkadot-api client not available");
1435
1464
  const encodedCallData = encodeFunctionData({ abi: contractAbi, functionName, args });
1436
1465
  const rpcs = this.rpc ? [this.rpc, ...this.assetHubEndpoints.filter((ep) => ep !== this.rpc)] : this.assetHubEndpoints;
1437
1466
  return await withTimeout(
1438
- this.clientWrapper.submitTransaction(contractAddress, value, encodedCallData, this.substrateAddress, this.signer, statusCallback, { rpcs, useNoncePolling, functionName, args, contracts: this._contracts, verifyEffect }),
1467
+ this.clientWrapper.submitTransaction(contractAddress, value, encodedCallData, this.substrateAddress, this.signer, statusCallback, { rpcs, useNoncePolling, functionName, args, contracts: this._contracts, verifyEffect, feeAsset }),
1439
1468
  OPERATION_TIMEOUT_MS,
1440
1469
  functionName
1441
1470
  );
@@ -1453,6 +1482,49 @@ var DotNS = class {
1453
1482
  return { owned: false, owner: null };
1454
1483
  }
1455
1484
  }
1485
+ /** Live transfer-fee quote. transferFloor is a pure PopRules view — it
1486
+ * classifies the label and reads both tiers, so it works BEFORE the name is
1487
+ * registered (unlike quoteTransferFee, which reverts on an unregistered token). */
1488
+ async quoteTransferFloorNative(label, fromH160, toH160) {
1489
+ this.ensureConnected();
1490
+ const feeWei = await withTimeout(
1491
+ this.contractCall(this._contracts.POP_RULES, POP_RULES_ABI, "transferFloor", [validateDomainLabel(label), fromH160, toH160]),
1492
+ 3e4,
1493
+ "transferFloor"
1494
+ );
1495
+ return { feeWei, feeNative: weiToNative(feeWei, this._nativeToEthRatio) };
1496
+ }
1497
+ /** Hand `label`.dot from the connected signer (the worker, current owner) to
1498
+ * `toH160`, paying the transferFloor friction fee. Idempotent: a no-op if the
1499
+ * recipient already owns it; errors if a third party does. */
1500
+ async transferName(label, toH160, statusCallback = () => {
1501
+ }) {
1502
+ this.ensureConnected();
1503
+ const validated = validateDomainLabel(label);
1504
+ const tokenId = computeDomainTokenId(validated);
1505
+ const owner = await withTimeout(this.contractCall(this._contracts.DOTNS_REGISTRAR, DOTNS_REGISTRAR_TRANSFER_ABI, "ownerOf", [tokenId]), 3e4, "ownerOf");
1506
+ if (owner.toLowerCase() === toH160.toLowerCase()) {
1507
+ statusCallback("already owned by recipient");
1508
+ return { status: "skipped-already-owned" };
1509
+ }
1510
+ if (owner.toLowerCase() !== this.evmAddress.toLowerCase()) {
1511
+ throw new Error(`Cannot transfer ${validated}.dot: it is owned by ${owner}, not the worker ${this.evmAddress}.`);
1512
+ }
1513
+ const { feeWei, feeNative } = await this.quoteTransferFloorNative(validated, this.evmAddress, toH160);
1514
+ const txRes = await this.contractTransaction(
1515
+ this._contracts.DOTNS_REGISTRAR,
1516
+ feeNative,
1517
+ DOTNS_REGISTRAR_TRANSFER_ABI,
1518
+ "transferFrom",
1519
+ [this.evmAddress, toH160, tokenId],
1520
+ statusCallback
1521
+ );
1522
+ const after = await withTimeout(this.contractCall(this._contracts.DOTNS_REGISTRAR, DOTNS_REGISTRAR_TRANSFER_ABI, "ownerOf", [tokenId]), 3e4, "ownerOf");
1523
+ if (after.toLowerCase() !== toH160.toLowerCase()) {
1524
+ throw new Error(`Transfer of ${validated}.dot did not land: owner is ${after}, expected ${toH160}.`);
1525
+ }
1526
+ return { status: "ok", txHash: txRes.kind === TX_KIND_HASH ? txRes.hash : void 0, feeWei };
1527
+ }
1456
1528
  async getUserPopStatus(ownerAddress = null) {
1457
1529
  if (this._userPopStatusOverrideForTest !== null) {
1458
1530
  const result = this._userPopStatusOverrideForTest;
@@ -1610,7 +1682,7 @@ var DotNS = class {
1610
1682
  label
1611
1683
  );
1612
1684
  }
1613
- async setContenthash(domainName, contenthashHex) {
1685
+ async setContenthash(domainName, contenthashHex, opts = {}) {
1614
1686
  return withSpan("deploy.dotns.set-contenthash", "2b. set-contenthash", {}, async () => {
1615
1687
  this.ensureConnected();
1616
1688
  const node = namehash(`${domainName}.dot`);
@@ -1664,7 +1736,7 @@ var DotNS = class {
1664
1736
  console.log(`
1665
1737
  Linking content...`);
1666
1738
  this._onPhoneSigningRequired?.("Link content");
1667
- const txRes = await this.contractTransaction(this._contracts.DOTNS_CONTENT_RESOLVER, 0n, DOTNS_CONTENT_RESOLVER_ABI, "setContenthash", [node, contenthashHex], (s) => console.log(` ${s}`), { useNoncePolling: true, verifyEffect });
1739
+ const txRes = await this.contractTransaction(this._contracts.DOTNS_CONTENT_RESOLVER, 0n, DOTNS_CONTENT_RESOLVER_ABI, "setContenthash", [node, contenthashHex], (s) => console.log(` ${s}`), { useNoncePolling: true, verifyEffect, feeAsset: opts.feeAsset });
1668
1740
  const finalOnChain = (await this.getContenthash(domainName) || "0x").toLowerCase();
1669
1741
  if (finalOnChain !== expected) {
1670
1742
  throw new Error(
@@ -2112,7 +2184,6 @@ var DotNS = class {
2112
2184
  );
2113
2185
  }
2114
2186
  const priceWei = typeof priceRaw === "bigint" ? priceRaw : BigInt(priceRaw);
2115
- console.log(` Required status: ${popStatusName(requiredStatus)}`);
2116
2187
  console.log(` User status: ${popStatusName(userStatus)}`);
2117
2188
  console.log(` Price: ${formatEther(priceWei)} PAS`);
2118
2189
  return { priceWei, requiredStatus, userStatus, message };
@@ -2161,10 +2232,10 @@ var DotNS = class {
2161
2232
  // View-only readiness check. Runs every chain read needed to predict whether
2162
2233
  // `register(label)` will succeed, so the caller can fail-fast BEFORE the
2163
2234
  // Bulletin chunk upload. Never writes to chain. See issue #100.
2164
- async preflight(label) {
2165
- return this._preflightInternal(label, false);
2235
+ async preflight(label, opts = {}) {
2236
+ return this._preflightInternal(label, false, opts.transferRecipientH160);
2166
2237
  }
2167
- async _preflightInternal(label, reproveAttempted) {
2238
+ async _preflightInternal(label, reproveAttempted, transferRecipientH160) {
2168
2239
  return withSpan("deploy.dotns.preflight", `preflight ${label}.dot`, {}, async () => {
2169
2240
  setDeployAttribute("deploy.dotns.reprove.auto", "false");
2170
2241
  this.ensureConnected();
@@ -2204,6 +2275,24 @@ var DotNS = class {
2204
2275
  const ownerRaw = ownership.owner?.toLowerCase() ?? null;
2205
2276
  const existingOwner = ownerRaw && ownerRaw !== zeroAddress ? ownerRaw : null;
2206
2277
  const selfAddress = this.evmAddress.toLowerCase();
2278
+ if (transferRecipientH160 && existingOwner !== null && existingOwner === transferRecipientH160.toLowerCase()) {
2279
+ return {
2280
+ label: validated,
2281
+ classification,
2282
+ userStatus,
2283
+ trailingDigits,
2284
+ baselength,
2285
+ isAvailable: false,
2286
+ existingOwner,
2287
+ isBaseNameReserved: isReserved,
2288
+ reservationOwner,
2289
+ isTestnet,
2290
+ canProceed: true,
2291
+ plannedAction: "already-owned-by-recipient",
2292
+ needsPopUpgrade: false,
2293
+ signerFreeBalance
2294
+ };
2295
+ }
2207
2296
  if (existingOwner !== null && existingOwner !== selfAddress) {
2208
2297
  return {
2209
2298
  label: validated,
@@ -2223,6 +2312,13 @@ var DotNS = class {
2223
2312
  signerFreeBalance
2224
2313
  };
2225
2314
  }
2315
+ let transferFeeNative = 0n;
2316
+ if (transferRecipientH160) {
2317
+ try {
2318
+ ({ feeNative: transferFeeNative } = await this.quoteTransferFloorNative(validated, this.evmAddress, transferRecipientH160));
2319
+ } catch {
2320
+ }
2321
+ }
2226
2322
  if (existingOwner !== null && existingOwner === selfAddress) {
2227
2323
  return await this.gateOnFeeBalance({
2228
2324
  label: validated,
@@ -2238,7 +2334,7 @@ var DotNS = class {
2238
2334
  canProceed: true,
2239
2335
  plannedAction: "already-owned-by-us",
2240
2336
  needsPopUpgrade: false
2241
- }, signerFreeBalance, isTestnet);
2337
+ }, signerFreeBalance, isTestnet, transferFeeNative);
2242
2338
  }
2243
2339
  if (isReserved && reservationOwner !== selfAddress) {
2244
2340
  return {
@@ -2307,7 +2403,7 @@ var DotNS = class {
2307
2403
  }
2308
2404
  if (reproveSucceeded) {
2309
2405
  console.log(` Continuing with registration of ${validated}.dot.`);
2310
- return this._preflightInternal(label, true);
2406
+ return this._preflightInternal(label, true, transferRecipientH160);
2311
2407
  }
2312
2408
  }
2313
2409
  const remediationMessage = formatPersonhoodRemediation(aliasState, this._popSelfServe, this._environmentId);
@@ -2377,7 +2473,7 @@ var DotNS = class {
2377
2473
  plannedAction: "register",
2378
2474
  needsPopUpgrade: false,
2379
2475
  targetPopStatus
2380
- }, signerFreeBalance, isTestnet);
2476
+ }, signerFreeBalance, isTestnet, transferFeeNative);
2381
2477
  });
2382
2478
  }
2383
2479
  // Final preflight stage: check the DotNS signer can pay tx fees on the
@@ -2386,15 +2482,23 @@ var DotNS = class {
2386
2482
  // phrase's Alice or Bob if the signer is short. Replaces the original
2387
2483
  // canProceed:true result with an actionable canProceed:false when even the
2388
2484
  // top-up can't get the signer above the threshold.
2389
- async gateOnFeeBalance(candidate, signerFreeBalance, isTestnet) {
2390
- const rentPriceNative = candidate.plannedAction === "register" ? bufferedRentNative(this._nativeToEthRatio) : 0n;
2391
- const feeFloor = feeFloorFor(candidate.plannedAction, this._registerStorageDeposit, rentPriceNative);
2485
+ async gateOnFeeBalance(candidate, signerFreeBalance, isTestnet, transferFeeNative = 0n) {
2486
+ let rentPriceNative = 0n;
2487
+ if (candidate.plannedAction === "register" && candidate.userStatus === ProofOfPersonhoodStatus.NoStatus) {
2488
+ const startingPriceWei = await withTimeout(
2489
+ this.contractCall(this._contracts.POP_RULES, POP_RULES_ABI, "startingPrice", []),
2490
+ 3e4,
2491
+ "startingPrice"
2492
+ );
2493
+ rentPriceNative = bufferedWeiToNative(startingPriceWei, this._nativeToEthRatio);
2494
+ }
2495
+ const feeFloor = feeFloorFor(candidate.plannedAction, this._registerStorageDeposit, rentPriceNative, transferFeeNative);
2392
2496
  let effectiveBalance = signerFreeBalance;
2393
2497
  let toppedUp;
2394
2498
  if (effectiveBalance < feeFloor && isTestnet) {
2395
2499
  setDeployAttribute("deploy.dotns.signer_below_floor", "true");
2396
2500
  console.log(` DotNS signer ${this.substrateAddress?.slice(0, 8)}... balance ${fmtPas(effectiveBalance)} PAS < ${fmtPas(feeFloor)} PAS floor \u2014 attempting testnet auto top-up...`);
2397
- const result = await this.attemptTestnetTopUp(this.substrateAddress, topUpTargetFor(candidate.plannedAction, this._registerStorageDeposit, rentPriceNative));
2501
+ const result = await this.attemptTestnetTopUp(this.substrateAddress, topUpTargetFor(candidate.plannedAction, this._registerStorageDeposit, rentPriceNative, transferFeeNative));
2398
2502
  if (result) {
2399
2503
  console.log(` Topped up ${fmtPas(result.transferred)} PAS from ${result.source}`);
2400
2504
  effectiveBalance += result.transferred;
@@ -2565,6 +2669,9 @@ export {
2565
2669
  TX_KIND_NONCE_ADVANCED,
2566
2670
  ATTR_TX_RESOLUTION_KIND,
2567
2671
  MINIMUM_REGISTER_STORAGE_DEPOSIT,
2672
+ registerDepositWei,
2673
+ bufferedWeiToNative,
2674
+ weiToNative,
2568
2675
  fmtPas,
2569
2676
  feeFloorFor,
2570
2677
  RPC_ENDPOINTS,
@@ -2581,6 +2688,7 @@ export {
2581
2688
  DOTNS_TX_MAX_ATTEMPTS,
2582
2689
  classifyTxRetryDecision,
2583
2690
  dotnsRetryBackoffMs,
2691
+ shouldRetryTxAttempt,
2584
2692
  makeRetryStatusFilter,
2585
2693
  DEFAULT_MNEMONIC,
2586
2694
  fetchNonce,
@@ -96,7 +96,8 @@ function createSessionSigner(session, ref) {
96
96
 
97
97
  // src/auth/vendor/allocations.ts
98
98
  import {
99
- requestResourceAllocation as terminalRequestResourceAllocation
99
+ requestResourceAllocation as terminalRequestResourceAllocation,
100
+ createSlotAccountSigner as terminalCreateSlotAccountSigner
100
101
  } from "@parity/product-sdk-terminal/host";
101
102
  var DEFAULT_RESOURCES = [
102
103
  { tag: "BulletInAllowance", value: void 0 },
@@ -104,6 +105,7 @@ var DEFAULT_RESOURCES = [
104
105
  // derivation index 0 = the default product account.
105
106
  { tag: "SmartContractAllowance", value: 0 }
106
107
  ];
108
+ var BULLETIN_RESOURCE = { tag: "BulletInAllowance", value: void 0 };
107
109
  async function requestResourceAllocation(session, adapter, resources = DEFAULT_RESOURCES, onExisting = "Ignore") {
108
110
  const outcomes = await terminalRequestResourceAllocation(session, adapter, resources, { onExisting });
109
111
  return outcomes;
@@ -121,6 +123,9 @@ function summarizeOutcomes(outcomes, resources) {
121
123
  });
122
124
  return { granted, rejected, unavailable };
123
125
  }
126
+ async function createSlotAccountSigner(adapter, resource) {
127
+ return terminalCreateSlotAccountSigner(adapter, resource);
128
+ }
124
129
 
125
130
  // src/auth/vendor/auth.ts
126
131
  var QR_TIMEOUT_MS = 6e4;
@@ -409,8 +414,10 @@ export {
409
414
  deriveProductPublicKey,
410
415
  createSessionSigner,
411
416
  DEFAULT_RESOURCES,
417
+ BULLETIN_RESOURCE,
412
418
  requestResourceAllocation,
413
419
  summarizeOutcomes,
420
+ createSlotAccountSigner,
414
421
  createAuthClient,
415
422
  SignerNotAvailableError,
416
423
  parseDevAccountName,