@sorandomains/owner 0.3.0 → 0.4.0

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
@@ -34,11 +34,12 @@ for (const o of batch.outcomes) if (!o.issued) console.warn(o.label, o.reason);
34
34
  | `makePermanent` | The one-way door — irreversible, guarded by `{ confirmIrreversible: true }` |
35
35
  | `proposeNamespaceTransfer` / `acceptNamespaceTransfer` / `cancelNamespaceTransfer` | Two-step, accept-to-move namespace transfer |
36
36
  | `setResolver` | Point the namespace at a resolver (frozen once permanent) |
37
- | `policy` / `isPermanent` / `nameState` / `pendingNamespaceTransfer` / `namespaceOwner` | Reads that support the write flows |
37
+ | `policy` / `isPermanent` / `nameState` / `pendingNamespaceTransfer` / `namespaceOwner` / `registrarOf` / `assertOwner` | Reads that support the write flows |
38
38
 
39
39
  Name-**holder** powers (transferring an individual name, re-pointing it,
40
40
  electing a primary name) are deliberately absent: the contracts grant them to
41
- holders, not owners, and they will ship in a holder-side module.
41
+ holders, not owners — they live in
42
+ [`@sorandomains/holder`](https://www.npmjs.com/package/@sorandomains/holder).
42
43
 
43
44
  ## Signing
44
45
 
package/dist/index.d.ts CHANGED
@@ -20,7 +20,7 @@
20
20
  * `acceptNamespaceTransfer`, which the proposed NEW owner signs. Name-holder
21
21
  * powers (transferring an individual name, pointing it at a new address,
22
22
  * electing a primary name) are the holder's alone — they live in the contracts'
23
- * holder-authorized entry points and will ship in a holder-side module; this
23
+ * holder-authorized entry points and live in `@sorandomains/holder`; this
24
24
  * package deliberately cannot exercise them.
25
25
  *
26
26
  * SIGNING. Supply a `TxSigner`: `keypairSigner(secret)` for backends, or wrap a
package/dist/index.js CHANGED
@@ -20,7 +20,7 @@
20
20
  * `acceptNamespaceTransfer`, which the proposed NEW owner signs. Name-holder
21
21
  * powers (transferring an individual name, pointing it at a new address,
22
22
  * electing a primary name) are the holder's alone — they live in the contracts'
23
- * holder-authorized entry points and will ship in a holder-side module; this
23
+ * holder-authorized entry points and live in `@sorandomains/holder`; this
24
24
  * package deliberately cannot exercise them.
25
25
  *
26
26
  * SIGNING. Supply a `TxSigner`: `keypairSigner(secret)` for backends, or wrap a
@@ -42,13 +42,15 @@ function extractContractEvents(meta) {
42
42
  try {
43
43
  if (!meta)
44
44
  return [];
45
- if (meta.switch() === 3)
46
- return meta.v3().sorobanMeta()?.events() ?? [];
47
- if (meta.switch() === 4) {
48
- const v4 = meta.v4();
45
+ // (SDK17/js-xdr v5) TransactionMeta discriminates on `.type`; the arm value
46
+ // is `.value`; struct fields (sorobanMeta, operations, events) are properties.
47
+ if (meta.type === "v3")
48
+ return meta.value.sorobanMeta?.events ?? [];
49
+ if (meta.type === "v4") {
50
+ const v4 = meta.value;
49
51
  return [
50
- ...v4.operations().flatMap((op) => op.events()),
51
- ...v4.events().map((te) => te.event()),
52
+ ...v4.operations.flatMap((op) => op.events),
53
+ ...v4.events.map((te) => te.event),
52
54
  ];
53
55
  }
54
56
  return [];
@@ -62,16 +64,16 @@ function decodeIssuedEvents(events, registrarId) {
62
64
  const out = [];
63
65
  for (const ev of events) {
64
66
  try {
65
- const cid = ev.contractId();
67
+ const cid = ev.contractId; // (SDK17) property, ContractId | null
66
68
  if (!cid)
67
69
  continue;
68
- if (Address.contract(cid).toString() !== registrarId)
70
+ if (Address.contract(cid.toBytes()).toString() !== registrarId)
69
71
  continue;
70
- const body = ev.body().v0();
71
- const topics = body.topics();
72
+ const body = ev.body.value; // ContractEventBody → ContractEventV0
73
+ const topics = body.topics;
72
74
  if (topics.length < 1 || scValToNative(topics[0]) !== "issued")
73
75
  continue;
74
- const data = scValToNative(body.data());
76
+ const data = scValToNative(body.data);
75
77
  if (!(data?.[0] instanceof Uint8Array) || typeof data?.[1] !== "string")
76
78
  continue;
77
79
  out.push({ label: new TextDecoder().decode(data[0]), holder: data[1] });
@@ -598,12 +600,12 @@ export class SoranOwner {
598
600
  assertSatisfiableAuth(prepared, pub, contractId, fn) {
599
601
  const op = prepared.operations[0];
600
602
  for (const entry of op?.auth ?? []) {
601
- const cred = entry.credentials();
602
- if (cred.switch() !== xdr.SorobanCredentialsType.sorobanCredentialsAddress())
603
+ const cred = entry.credentials;
604
+ if (cred.type !== "sorobanCredentialsAddress")
603
605
  continue;
604
606
  let required;
605
607
  try {
606
- required = Address.fromScAddress(cred.address().address()).toString();
608
+ required = Address.fromScAddress(cred.address.address).toString();
607
609
  }
608
610
  catch {
609
611
  continue; // unreadable credential — let the chain be the judge
@@ -621,7 +623,10 @@ export class SoranOwner {
621
623
  .setTimeout(this.timeoutSecs)
622
624
  .build();
623
625
  let tx = build(await this.sourceAccount(pub, fn));
624
- let sim = await this.server.simulateTransaction(tx);
626
+ // (SDK17/P28) useUpgradedAuth=false keeps legacy V1 SorobanCredentials rather
627
+ // than CAP-71 address-bound V2 — valid against P27 (pre-vote) and P28 (post),
628
+ // and keeps assertSatisfiableAuth's `sorobanCredentialsAddress` check exact.
629
+ let sim = await this.server.simulateTransaction(tx, undefined, undefined, false);
625
630
  // Archived entries (e.g. a dormant Registrar's instance) need restoring
626
631
  // before the call can run. Each restore is its own owner-signed
627
632
  // transaction; two rounds cover an entry archiving mid-flow, and beyond
@@ -632,7 +637,7 @@ export class SoranOwner {
632
637
  }
633
638
  await this.restore(sim, pub);
634
639
  tx = build(await this.sourceAccount(pub, fn));
635
- sim = await this.server.simulateTransaction(tx);
640
+ sim = await this.server.simulateTransaction(tx, undefined, undefined, false);
636
641
  }
637
642
  if (rpc.Api.isSimulationError(sim)) {
638
643
  throw typedError(contractId, fn, sim.error, errNames);
@@ -641,7 +646,7 @@ export class SoranOwner {
641
646
  this.assertSatisfiableAuth(prepared, pub, contractId, fn);
642
647
  // The hash is fixed before signatures — compute it now so every failure
643
648
  // past this point can carry it (the "re-check before retrying" contract).
644
- const txHash = prepared.hash().toString("hex");
649
+ const txHash = toHex(prepared.hash()); // (SDK17) hash() is Uint8Array
645
650
  const signed = await this.signEnvelope(prepared.toXDR());
646
651
  const envelope = TransactionBuilder.fromXDR(signed, this.passphrase);
647
652
  let sent;
@@ -722,18 +727,18 @@ export class SoranOwner {
722
727
  let code = null;
723
728
  try {
724
729
  const meta = got.resultMetaXdr;
725
- const diags = got.diagnosticEventsXdr ?? (meta && meta.switch() === 3
726
- ? (meta.v3().sorobanMeta()?.diagnosticEvents() ?? [])
727
- : meta && meta.switch() === 4
728
- ? meta.v4().diagnosticEvents()
730
+ const diags = got.diagnosticEventsXdr ?? (meta && meta.type === "v3"
731
+ ? (meta.value.sorobanMeta?.diagnosticEvents ?? [])
732
+ : meta && meta.type === "v4"
733
+ ? meta.value.diagnosticEvents
729
734
  : []);
730
735
  outer: for (const d of diags) {
731
- const body = d.event().body().v0();
732
- for (const v of [...body.topics(), body.data()]) {
733
- if (v.switch() === xdr.ScValType.scvError()) {
734
- const err = v.error();
735
- if (err.switch() === xdr.ScErrorType.sceContract()) {
736
- code = err.contractCode();
736
+ const body = d.event.body.value;
737
+ for (const v of [...body.topics, body.data]) {
738
+ if (v.type === "scvError") {
739
+ const err = v.error;
740
+ if (err.type === "sceContract") {
741
+ code = err.contractCode;
737
742
  break outer;
738
743
  }
739
744
  }
@@ -745,7 +750,7 @@ export class SoranOwner {
745
750
  }
746
751
  let resultCode = `tx status ${got.status}`;
747
752
  try {
748
- resultCode = got.resultXdr?.result().switch().name ?? resultCode;
753
+ resultCode = got.resultXdr?.result.type ?? resultCode;
749
754
  }
750
755
  catch {
751
756
  /* keep the plain status */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sorandomains/owner",
3
- "version": "0.3.0",
4
- "description": "Run your Soran namespace on Stellar \u2014 issue names, manage lifecycle, transfer, and walk the one-way permanence door.",
3
+ "version": "0.4.0",
4
+ "description": "Run your Soran namespace on Stellar — issue names, manage lifecycle, transfer, and walk the one-way permanence door.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
@@ -33,14 +33,14 @@
33
33
  "issuance"
34
34
  ],
35
35
  "peerDependencies": {
36
- "@stellar/stellar-sdk": ">=13 <17"
36
+ "@stellar/stellar-sdk": ">=17 <18"
37
37
  },
38
38
  "devDependencies": {
39
- "@stellar/stellar-sdk": "^16.2.0",
39
+ "@stellar/stellar-sdk": "^17.0.1",
40
40
  "@types/node": "^22.20.1",
41
+ "esbuild": "^0.25.0",
41
42
  "tsx": "^4.19.2",
42
- "typescript": "^5.7.3",
43
- "esbuild": "^0.25.0"
43
+ "typescript": "^5.7.3"
44
44
  },
45
45
  "exports": {
46
46
  ".": {