@x1id/resolve 0.18.0 → 0.19.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/README.md CHANGED
@@ -564,6 +564,11 @@ const createIx = buildCreateRecordIx({
564
564
  programId, payer, owner, handle, record,
565
565
  coinType: 60, // ETH, per SLIP-44
566
566
  value: ethAddressBytes,
567
+ // TOKENIZED handle (the default)? pass the holder's NFT associated token
568
+ // account too, or create_record fails NotCurrentAuthority (6018). The verify
569
+ // builders below take the same `holderTokenAccount`. Omit for an untokenized
570
+ // handle. (A delegated writer passes `recordDelegate` instead.)
571
+ holderTokenAccount, // = getAssociatedTokenAddressSync(nftMint, owner)
567
572
  });
568
573
 
569
574
  // 2. build the challenge and have the wallet sign it (personal_sign)
@@ -44,9 +44,20 @@ export declare const NAMESPACE_MAX_LEN = 16;
44
44
  export type NamespaceStatus = "Active" | "Paused" | "Retired";
45
45
  export interface CreateNamespaceParams {
46
46
  readonly programId: AddressLike;
47
- /** admin — signs AND pays rent; writable. */
48
- readonly admin: AddressLike;
47
+ /** The creator — signs AND pays rent + the creation fee; writable.
48
+ * Permissionless: any wallet, not an admin. (Was mis-named `admin` and
49
+ * built with too few accounts, so the ix failed AccountNotEnoughKeys 3005 —
50
+ * W169.) */
51
+ readonly payer: AddressLike;
49
52
  readonly config: AddressLike;
53
+ /** `Config.treasury` — receives the creation fee; writable. */
54
+ readonly treasury: AddressLike;
55
+ /** The creator's chosen payout wallet, recorded on the namespace for future
56
+ * 75% primary/secondary cuts. An arbitrary pubkey; never signs. */
57
+ readonly creatorPayout: AddressLike;
58
+ /** `["reserved_namespace", label]` PDA — the denylist shadow the handler
59
+ * refuses creation against if it exists; read-only, never written. */
60
+ readonly reserved: AddressLike;
50
61
  /** `["namespace", label]` PDA — init, writable. */
51
62
  readonly namespace: AddressLike;
52
63
  /** Canonical ASCII label (a-z 0-9 -), 1..=16 bytes — an instruction ARG. */
@@ -111,9 +111,14 @@ export function buildCreateNamespaceIx(p) {
111
111
  throw new Error(`label must be 1..=${NAMESPACE_MAX_LEN} chars`);
112
112
  }
113
113
  const data = concat([CREATE_NAMESPACE_DISCRIMINATOR, borshString(p.label)]);
114
+ // Account order matches the program's `CreateNamespace` context exactly:
115
+ // payer, config, treasury, creator_payout, reserved, namespace, system.
114
116
  const keys = [
115
- { pubkey: toBase58(p.admin, "admin"), isSigner: true, isWritable: true },
117
+ { pubkey: toBase58(p.payer, "payer"), isSigner: true, isWritable: true },
116
118
  { pubkey: toBase58(p.config, "config"), isSigner: false, isWritable: false },
119
+ { pubkey: toBase58(p.treasury, "treasury"), isSigner: false, isWritable: true },
120
+ { pubkey: toBase58(p.creatorPayout, "creatorPayout"), isSigner: false, isWritable: false },
121
+ { pubkey: toBase58(p.reserved, "reserved"), isSigner: false, isWritable: false },
117
122
  { pubkey: toBase58(p.namespace, "namespace"), isSigner: false, isWritable: true },
118
123
  { pubkey: toBase58(p.systemProgram ?? SYSTEM_PROGRAM_ID, "systemProgram"), isSigner: false, isWritable: false },
119
124
  ];
package/dist/base58.js CHANGED
@@ -65,5 +65,13 @@ export function decodeBase58_32(s) {
65
65
  out[i] = Number(n & 255n);
66
66
  n >>= 8n;
67
67
  }
68
+ // W167: reject anything that isn't the canonical base58 of EXACTLY these 32
69
+ // bytes. Without this, a short valid-base58 string ("notakey") decodes to a
70
+ // small number and is silently LEFT-PADDED into a bogus 32-byte "address",
71
+ // so builders / sign-in / resolve / MCP prepare_register accept garbage as a
72
+ // pubkey. The round-trip also correctly accepts a real key with leading zero
73
+ // bytes (encodeBase58 re-emits its leading '1's).
74
+ if (encodeBase58(out) !== s)
75
+ return null;
68
76
  return out;
69
77
  }
@@ -83,7 +83,7 @@ export declare function splitBtcSignature(sig65: Uint8Array): {
83
83
  header: number;
84
84
  signature: Uint8Array;
85
85
  };
86
- export interface CreateRecordParams {
86
+ export interface CreateRecordParams extends RecordEditAuthorityParams {
87
87
  readonly programId: AddressLike;
88
88
  readonly payer: AddressLike;
89
89
  readonly owner: AddressLike;
@@ -171,6 +171,12 @@ export function buildCreateRecordIx(p) {
171
171
  { pubkey: toBase58(p.record, "record"), isSigner: false, isWritable: true },
172
172
  { pubkey: SYSTEM_PROGRAM, isSigner: false, isWritable: false },
173
173
  ];
174
+ // W165: create_record uses the same `require_current_authority` check as the
175
+ // verify builders, so a TOKENIZED handle (the default) needs the holder's NFT
176
+ // token account (and/or the record-delegate PDA) in the trailing accounts —
177
+ // without it create_record fails NotCurrentAuthority (6018). This was the one
178
+ // record builder missing the tail; now it matches buildVerifyRecord*Ix.
179
+ pushAuthorityTail(keys, p.programId, p);
174
180
  return { programId: toBase58(p.programId, "programId"), keys, data };
175
181
  }
176
182
  export function buildVerifyRecordEthIx(p) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@x1id/resolve",
3
- "version": "0.18.0",
3
+ "version": "0.19.1",
4
4
  "description": "Resolve @handles and X1NS names on X1. Never silently picks between namespaces.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",