Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/actions/bulletin/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ inputs:
bulletin-rpc:
description: 'Bulletin chain WebSocket RPC endpoint (default: CLI built-in)'
required: false
env:
description: 'DotNS environment used by cache/store operations'
required: false
default: 'paseo-v2'
build-path:
description: 'Path to the build directory to upload'
required: false
Expand Down Expand Up @@ -68,6 +72,7 @@ runs:
rm -f "$RESULT_FILE"
env:
DOTNS_MNEMONIC: ${{ inputs.mnemonic }}
DOTNS_ENV: ${{ inputs.env }}
BULLETIN_RPC: ${{ inputs.bulletin-rpc }}
CI: "true"
FORCE_COLOR: "0"
Expand Down Expand Up @@ -122,6 +127,7 @@ runs:
exit 1
env:
DOTNS_MNEMONIC: ${{ inputs.mnemonic }}
DOTNS_ENV: ${{ inputs.env }}
BULLETIN_RPC: ${{ inputs.bulletin-rpc }}
BUILD_PATH: ${{ inputs.build-path }}
UPLOAD_CONCURRENCY: ${{ inputs.upload-concurrency }}
Expand Down
14 changes: 12 additions & 2 deletions .github/actions/dotns/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ inputs:
rpc:
description: 'WebSocket RPC endpoint (default: CLI built-in)'
required: false
env:
description: 'DotNS environment'
required: false
default: 'paseo-v2'
basename:
description: 'Base domain without .dot'
required: true
Expand Down Expand Up @@ -59,6 +63,7 @@ runs:
fi
env:
BASENAME: ${{ inputs.basename }}
DOTNS_ENV: ${{ inputs.env }}

- name: Fail if base domain not registered
if: steps.check-base.outputs.exists != 'true' && inputs.register-base != 'true'
Expand All @@ -76,10 +81,11 @@ runs:
echo "To have this workflow register it automatically, set register-base: true."
echo ""
echo "If registration requires Proof-of-Personhood, ensure your account has"
echo "the correct POP status first. See: dotns pop set --help"
echo "the correct POP status first. See: dotns pop status --help"
exit 1
env:
BASENAME: ${{ inputs.basename }}
DOTNS_ENV: ${{ inputs.env }}

- name: Register base domain
if: steps.check-base.outputs.exists != 'true' && inputs.register-base == 'true'
Expand All @@ -106,13 +112,14 @@ runs:
echo ""
echo "To fix this:"
echo " 1. Check your POP status: dotns pop status"
echo " 2. Set POP if needed: dotns pop set --help"
echo " 2. Complete personhood verification outside DotNS if needed."
echo " 3. Then re-run this workflow."
echo ""
echo "You can also register manually at https://dotns.paseo.li"
exit 1
env:
DOTNS_MNEMONIC: ${{ inputs.mnemonic }}
DOTNS_ENV: ${{ inputs.env }}
BASENAME: ${{ inputs.basename }}
MAX_RETRIES: ${{ inputs.max-retries }}
RETRY_DELAY: ${{ inputs.retry-delay }}
Expand Down Expand Up @@ -144,6 +151,7 @@ runs:
env:
SUBNAME: ${{ inputs.subname }}
BASENAME: ${{ inputs.basename }}
DOTNS_ENV: ${{ inputs.env }}

- name: Register subname
if: inputs.mode == 'preview' && steps.check-subname.outputs.exists != 'true'
Expand Down Expand Up @@ -195,6 +203,7 @@ runs:
exit 1
env:
DOTNS_MNEMONIC: ${{ inputs.mnemonic }}
DOTNS_ENV: ${{ inputs.env }}
SUBNAME: ${{ inputs.subname }}
BASENAME: ${{ inputs.basename }}
MAX_RETRIES: ${{ inputs.max-retries }}
Expand Down Expand Up @@ -227,6 +236,7 @@ runs:
exit 1
env:
DOTNS_MNEMONIC: ${{ inputs.mnemonic }}
DOTNS_ENV: ${{ inputs.env }}
DOMAIN: ${{ inputs.domain }}
CID: ${{ inputs.cid }}
RPC: ${{ inputs.rpc }}
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ on:
required: false
type: string

env:
description: 'DotNS environment'
required: false
type: string
default: 'paseo-v2'

upload-concurrency:
description: 'Adaptive scheduler max window (max: 4)'
required: false
Expand Down Expand Up @@ -285,6 +291,7 @@ jobs:
uses: ./.github/actions/bulletin
with:
mnemonic: ${{ secrets.bulletin-mnemonic || 'bottom drive obey lake curtain smoke basket hold race lonely fit walk' }}
env: ${{ inputs.env }}
bulletin-rpc: ${{ inputs.bulletin-rpc }}
build-path: ${{ inputs.use-car && './build.car' || './build' }}
upload-concurrency: ${{ steps.upload-settings.outputs.upload-concurrency }}
Expand Down Expand Up @@ -319,6 +326,7 @@ jobs:
uses: ./.github/actions/dotns
with:
mnemonic: ${{ secrets.dotns-mnemonic }}
env: ${{ inputs.env }}
rpc: ${{ inputs.rpc }}
basename: ${{ inputs.basename }}
mode: ${{ inputs.mode }}
Expand Down
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
"module": "index.ts",
"type": "module",
"private": true,
"scripts": {
"hooks:install": "git config core.hooksPath .githooks",
"prepare": "git config core.hooksPath .githooks || true",
"format": "bun run --cwd packages/cli format && bun run --cwd packages/ui format",
"format:fix": "bun run --cwd packages/cli format:fix && bun run --cwd packages/ui format:fix",
"lint": "bun run --cwd packages/cli lint && bun run --cwd packages/ui lint",
"lint:fix": "bun run --cwd packages/cli lint:fix && bun run --cwd packages/ui lint:fix",
"precommit": "bun run format:fix && bun run lint:fix && bun run format && bun run lint"
},
"devDependencies": {
"@types/bun": "latest",
"@types/ws": "^8.18.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/abis/PopRules.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@parity/dotns-cli",
"module": "index.ts",
"version": "0.6.0",
"version": "0.6.2",
"type": "module",
"private": true,
"packageManager": "bun@1.2.6",
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/src/cli/commands/authOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import type { AuthOptionValues } from "../../types/types";

export function addAuthOptions(cmd: Command): Command {
return cmd
.option("--env <environment>", `DotNS environment: paseo-v2 (env: ${ENV.DOTNS_ENV})`)
.option("--network <environment>", "Alias for --env")
.option("--rpc <wsUrl>", `WebSocket RPC endpoint (env: ${ENV.RPC})`)
.option("--keystore-path <path>", `Keystore path (env: ${ENV.KEYSTORE_PATH})`)
.option("--min-balance <pas>", `Minimum balance in PAS (env: ${ENV.MIN_BALANCE_PAS})`)
Expand Down
8 changes: 6 additions & 2 deletions packages/cli/src/cli/commands/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ export function attachAccountCommands(root: Command) {
try {
const mergedOptions = getMergedOptions(command, options);

const rpc = resolveRpc(mergedOptions.rpc);
const environment = mergedOptions.env ?? mergedOptions.network;
const rpc = resolveRpc(mergedOptions.rpc, environment);
const keystorePath = resolveKeystorePath(mergedOptions.keystorePath);

const client = await step(`Connecting RPC ${rpc}`, async () =>
Expand Down Expand Up @@ -90,6 +91,8 @@ export function attachAccountCommands(root: Command) {
client as PolkadotApiClient,
evmAddress,
context.substrateAddress,
context.nativeTokenDecimals,
context.nativeTokenSymbol,
);

console.log(chalk.green("\n✓ Complete\n"));
Expand All @@ -108,7 +111,8 @@ export function attachAccountCommands(root: Command) {
try {
const mergedOptions = getMergedOptions(command, options);

const rpc = resolveRpc(mergedOptions.rpc);
const environment = mergedOptions.env ?? mergedOptions.network;
const rpc = resolveRpc(mergedOptions.rpc, environment);

const client = await step(`Connecting RPC ${rpc}`, async () =>
createClient(getWsProvider(rpc)).getTypedApi(paseo),
Expand Down
64 changes: 49 additions & 15 deletions packages/cli/src/cli/commands/lookup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { paseo } from "@polkadot-api/descriptors";
import { ReviveClientWrapper, type PolkadotApiClient } from "../../client/polkadotClient";
import { performDomainLookup, performOwnerOfLookup } from "../../commands/lookup";
import { verifyDomainOwnership } from "../../commands/register";
import { resolveRpc } from "../env";
import { resolveDotnsEnvironment, resolveRpc } from "../env";
import { formatErrorMessage } from "../../utils/formatting";
import {
resolveAuthSourceReadOnly,
Expand All @@ -17,7 +17,7 @@ import {
} from "../../commands/auth";
import { addAuthOptions, getAuthOptions } from "./authOptions";
import { step } from "../ui";
import { prepareAssetHubContext } from "../context";
import { getChainTokenInfo, prepareAssetHubContext } from "../context";
import { resolveTransferRecipient, transferDomain } from "../transfer";
import { classifyTransferDestination, isValidTransferDestination } from "./register";
import type {
Expand All @@ -29,9 +29,14 @@ import type {
import { getJsonFlag, maybeQuiet } from "./jsonHelpers";
import type { Address } from "viem";

function createClientWrapper(rpc: string) {
const client = createClient(getWsProvider(rpc)).getTypedApi(paseo);
return new ReviveClientWrapper(client as PolkadotApiClient);
async function createReadOnlyChainContext(rpc: string) {
const rawClient = createClient(getWsProvider(rpc));
const client = rawClient.getTypedApi(paseo);
const tokenInfo = await getChainTokenInfo(rawClient);
return {
clientWrapper: new ReviveClientWrapper(client as PolkadotApiClient),
...tokenInfo,
};
}

function hasAnyAuthHint(opts: AuthSource): boolean {
Expand Down Expand Up @@ -59,9 +64,13 @@ function withReadOnlyPasswordFallback<T extends AuthSource>(opts: T): T {
export async function prepareReadOnlyContext(
options: AuthSource & { rpc?: string },
): Promise<ReadOnlyContext> {
const rpc = resolveRpc(options.rpc);
const environment = resolveDotnsEnvironment(options.env ?? options.network);
const rpc = resolveRpc(options.rpc, environment.id);

const clientWrapper = await step(`Connecting RPC ${rpc}`, async () => createClientWrapper(rpc));
const readOnlyContext = await step(`Connecting RPC ${rpc}`, async () =>
createReadOnlyChainContext(rpc),
);
const { clientWrapper, nativeTokenDecimals, nativeTokenSymbol } = readOnlyContext;

const auth = await step("Resolving read-only account", async () => {
if (hasAnyAuthHint(options)) {
Expand Down Expand Up @@ -94,9 +103,22 @@ export async function prepareReadOnlyContext(
);

console.log(chalk.gray("\n RPC: ") + chalk.white(rpc));
console.log(chalk.gray(" Env: ") + chalk.white(environment.label));
console.log(
chalk.gray(" Token: ") +
chalk.white(`${nativeTokenSymbol} (${nativeTokenDecimals} decimals)`),
);
console.log(chalk.gray(" Account: ") + chalk.white(keypair.address));

return { clientWrapper, account: { address: keypair.address }, rpc, evmAddress };
return {
clientWrapper,
account: { address: keypair.address },
rpc,
environment: environment.id,
nativeTokenDecimals,
nativeTokenSymbol,
evmAddress,
};
}

export async function ensureAccountMappedWhenAuthenticated(
Expand Down Expand Up @@ -170,14 +192,21 @@ export function attachLookupCommands(root: Command): void {
process.exit(1);
}

const { clientWrapper, account } = await maybeQuiet(jsonOutput, () =>
prepareReadOnlyContext(merged),
const { clientWrapper, account, nativeTokenDecimals, nativeTokenSymbol } = await maybeQuiet(
jsonOutput,
() => prepareReadOnlyContext(merged),
);

if (!jsonOutput) console.log(chalk.bold("\n▶ Domain Lookup\n"));

const result = await maybeQuiet(jsonOutput, () =>
performDomainLookup(label, account.address, clientWrapper),
performDomainLookup(
label,
account.address,
clientWrapper,
nativeTokenDecimals,
nativeTokenSymbol,
),
);

if (jsonOutput) {
Expand Down Expand Up @@ -214,14 +243,19 @@ export function attachLookupCommands(root: Command): void {
const merged = { ...(options ?? {}), ...getAuthOptions(cmd) } as LookupActionOptions;
const jsonOutput = getJsonFlag(cmd);

const { clientWrapper, account } = await maybeQuiet(jsonOutput, () =>
prepareReadOnlyContext(merged),
);
const { clientWrapper, account, nativeTokenDecimals, nativeTokenSymbol } =
await maybeQuiet(jsonOutput, () => prepareReadOnlyContext(merged));

if (!jsonOutput) console.log(chalk.bold("\n▶ Domain Lookup\n"));

const result = await maybeQuiet(jsonOutput, () =>
performDomainLookup(merged.name as string, account.address, clientWrapper),
performDomainLookup(
merged.name as string,
account.address,
clientWrapper,
nativeTokenDecimals,
nativeTokenSymbol,
),
);

if (jsonOutput) {
Expand Down
Loading
Loading