@opaquecash/stealth-chain-solana 0.2.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.
Files changed (51) hide show
  1. package/README.md +69 -0
  2. package/dist/adapter.d.ts +76 -0
  3. package/dist/adapter.d.ts.map +1 -0
  4. package/dist/adapter.js +114 -0
  5. package/dist/adapter.js.map +1 -0
  6. package/dist/announcer.d.ts +92 -0
  7. package/dist/announcer.d.ts.map +1 -0
  8. package/dist/announcer.js +164 -0
  9. package/dist/announcer.js.map +1 -0
  10. package/dist/bytes.d.ts +35 -0
  11. package/dist/bytes.d.ts.map +1 -0
  12. package/dist/bytes.js +78 -0
  13. package/dist/bytes.js.map +1 -0
  14. package/dist/index.d.ts +24 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +24 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/ons.d.ts +122 -0
  19. package/dist/ons.d.ts.map +1 -0
  20. package/dist/ons.js +167 -0
  21. package/dist/ons.js.map +1 -0
  22. package/dist/programs.d.ts +60 -0
  23. package/dist/programs.d.ts.map +1 -0
  24. package/dist/programs.js +69 -0
  25. package/dist/programs.js.map +1 -0
  26. package/dist/registry.d.ts +39 -0
  27. package/dist/registry.d.ts.map +1 -0
  28. package/dist/registry.js +69 -0
  29. package/dist/registry.js.map +1 -0
  30. package/dist/relay.d.ts +71 -0
  31. package/dist/relay.d.ts.map +1 -0
  32. package/dist/relay.js +102 -0
  33. package/dist/relay.js.map +1 -0
  34. package/dist/sns.d.ts +16 -0
  35. package/dist/sns.d.ts.map +1 -0
  36. package/dist/sns.js +38 -0
  37. package/dist/sns.js.map +1 -0
  38. package/dist/stealth.d.ts +22 -0
  39. package/dist/stealth.d.ts.map +1 -0
  40. package/dist/stealth.js +38 -0
  41. package/dist/stealth.js.map +1 -0
  42. package/dist/sweep.d.ts +41 -0
  43. package/dist/sweep.d.ts.map +1 -0
  44. package/dist/sweep.js +76 -0
  45. package/dist/sweep.js.map +1 -0
  46. package/dist/uab-receiver.d.ts +57 -0
  47. package/dist/uab-receiver.d.ts.map +1 -0
  48. package/dist/uab-receiver.js +121 -0
  49. package/dist/uab-receiver.js.map +1 -0
  50. package/idl/stealth_announcer.json +460 -0
  51. package/package.json +42 -0
package/dist/bytes.js ADDED
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Little-endian integer codecs and byte helpers for Borsh-style Solana instruction data
3
+ * and Anchor event decoding. Kept dependency-light (DataView + `@noble/hashes/utils`) so
4
+ * the decoders run unchanged in Node and the browser.
5
+ */
6
+ import { bytesToHex as nobleBytesToHex, hexToBytes as nobleHexToBytes, concatBytes, } from "@noble/hashes/utils";
7
+ export { concatBytes };
8
+ /** Lowercase hex without `0x` prefix. */
9
+ export function bytesToHex(b) {
10
+ return nobleBytesToHex(b);
11
+ }
12
+ /** Parse hex (with or without `0x`) into bytes. */
13
+ export function hexToBytes(hex) {
14
+ return nobleHexToBytes(hex.startsWith("0x") ? hex.slice(2) : hex);
15
+ }
16
+ /** Encode a u64 as 8 little-endian bytes. */
17
+ export function u64le(value) {
18
+ const out = new Uint8Array(8);
19
+ new DataView(out.buffer).setBigUint64(0, value, true);
20
+ return out;
21
+ }
22
+ /** Encode a u32 as 4 little-endian bytes. */
23
+ export function u32le(value) {
24
+ const out = new Uint8Array(4);
25
+ new DataView(out.buffer).setUint32(0, value, true);
26
+ return out;
27
+ }
28
+ /** Encode a Borsh `Vec<u8>` (u32 LE length prefix + bytes). */
29
+ export function vecU8(bytes) {
30
+ return concatBytes(u32le(bytes.length), bytes);
31
+ }
32
+ /** A cursor into a byte buffer for sequential little-endian reads. */
33
+ export class ByteReader {
34
+ data;
35
+ view;
36
+ offset;
37
+ constructor(data, startOffset = 0) {
38
+ this.data = data;
39
+ this.view = new DataView(data.buffer, data.byteOffset, data.byteLength);
40
+ this.offset = startOffset;
41
+ }
42
+ get position() {
43
+ return this.offset;
44
+ }
45
+ get remaining() {
46
+ return this.data.length - this.offset;
47
+ }
48
+ skip(n) {
49
+ this.offset += n;
50
+ }
51
+ readU16() {
52
+ const v = this.view.getUint16(this.offset, true);
53
+ this.offset += 2;
54
+ return v;
55
+ }
56
+ readU32() {
57
+ const v = this.view.getUint32(this.offset, true);
58
+ this.offset += 4;
59
+ return v;
60
+ }
61
+ readU64() {
62
+ const v = this.view.getBigUint64(this.offset, true);
63
+ this.offset += 8;
64
+ return v;
65
+ }
66
+ /** Read `len` raw bytes (copied out). */
67
+ readBytes(len) {
68
+ const slice = this.data.slice(this.offset, this.offset + len);
69
+ this.offset += len;
70
+ return slice;
71
+ }
72
+ /** Read a Borsh `Vec<u8>` (u32 LE length prefix + bytes). */
73
+ readVecU8() {
74
+ const len = this.readU32();
75
+ return this.readBytes(len);
76
+ }
77
+ }
78
+ //# sourceMappingURL=bytes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bytes.js","sourceRoot":"","sources":["../src/bytes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,UAAU,IAAI,eAAe,EAC7B,UAAU,IAAI,eAAe,EAC7B,WAAW,GACZ,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,WAAW,EAAE,CAAC;AAEvB,yCAAyC;AACzC,MAAM,UAAU,UAAU,CAAC,CAAa;IACtC,OAAO,eAAe,CAAC,CAAC,CAAC,CAAC;AAC5B,CAAC;AAED,mDAAmD;AACnD,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,OAAO,eAAe,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AACpE,CAAC;AAED,6CAA6C;AAC7C,MAAM,UAAU,KAAK,CAAC,KAAa;IACjC,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;IAC9B,IAAI,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,YA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AAI,CAAC,CAAC;QACjB,OAAO,CAAC,CAAC;IACX,CAAC;IAED,OAAO;QACL,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACjD,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC;QACjB,OAAO,CAAC,CAAC;IACX,CAAC;IAED,OAAO;QACL,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACpD,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC;QACjB,OAAO,CAAC,CAAC;IACX,CAAC;IAED,yCAAyC;IACzC,SAAS,CAAC,GAAW;QACnB,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC;QAC9D,IAAI,CAAC,MAAM,IAAI,GAAG,CAAC;QACnB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,6DAA6D;IAC7D,SAAS;QACP,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAC3B,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;CACF"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * `@opaquecash/stealth-chain-solana` — Solana (web3.js) integration for the Opaque stealth
3
+ * registry and announcer.
4
+ *
5
+ * Mirrors `@opaquecash/stealth-chain` (EVM/viem): program ids and cluster config, PDA
6
+ * derivation, Anchor instruction builders, `Announcement` log decoding, and {@link SolanaAdapter}
7
+ * (an implementation of `@opaquecash/adapter`'s `ChainAdapter`). All crypto is shared with the
8
+ * EVM path via the chain-neutral DKSAP core; only chain access lives here.
9
+ *
10
+ * @packageDocumentation
11
+ */
12
+ export { type SolanaCluster, type SolanaDeployment, SOLANA_DEPLOYMENTS, getSolanaDeployment, CLUSTER_ENDPOINTS, WORMHOLE_CORE_DEVNET, SCHEME_ID_SECP256K1, ANNOUNCE_DISCRIMINATOR, ANNOUNCE_WITH_RELAY_DISCRIMINATOR, REGISTER_KEYS_DISCRIMINATOR, ANNOUNCEMENT_EVENT_DISCRIMINATOR, CROSS_CHAIN_ANNOUNCEMENT_EVENT_DISCRIMINATOR, REGISTRY_ENTRY_SEED, } from "./programs.js";
13
+ export { getRegistryEntryPda, buildRegisterKeysInstruction, decodeRegistryEntryMetaAddress, resolveMetaAddress, isRegistered, } from "./registry.js";
14
+ export { type DecodedAnnouncementEvent, buildAnnounceInstruction, encodeAnnouncementEventData, decodeAnnouncementEventData, decodeAnnouncementLogs, eventToAnnouncement, fetchAnnouncementsRange, watchAnnouncements, } from "./announcer.js";
15
+ export { deriveStealthSolanaKeypair, deriveStealthSolanaAddress, deriveStealthSolanaKeypairFromStealthPrivKey, deriveStealthSolanaAddressFromStealthPrivKey, } from "./stealth.js";
16
+ export { type StealthSweepPlan, buildStealthSweepTransaction, sweepStealthSol, } from "./sweep.js";
17
+ export { type AnnounceWithRelayInstructionParams, type AnnounceWithRelayBuild, deriveWormholeEmitterPda, deriveWormholeConfigPda, deriveWormholeFeeCollectorPda, deriveWormholeSequencePda, fetchWormholeMessageFee, buildAnnounceWithRelayInstruction, buildAnnounceWithRelay, } from "./relay.js";
18
+ export { SolanaAdapter, type SolanaAdapterConfig, } from "./adapter.js";
19
+ export { bytesToHex, hexToBytes, u64le, u32le, vecU8, concatBytes, ByteReader, } from "./bytes.js";
20
+ export { ONS_MIRROR_RECORD_SEED, ONS_CLAIM_SEED, ONS_PENDING_WINDOW_SECS, ONS_RECORD_DISCRIMINATOR, ONS_CLAIM_DISCRIMINATOR, type OnsMirrorRecord, type OnsProvisionalClaim, type OnsClaimInstructionParams, type OnsClaimState, type OnsClaimStatus, onsNameHash, getOnsMirrorRecordPda, getOnsClaimPda, decodeOnsMirrorRecord, decodeOnsProvisionalClaim, fetchOnsMirrorRecord, fetchOnsClaimStatus, buildOnsClaimInstruction, buildOnsReconcileInstruction, } from "./ons.js";
21
+ export { snsDomainName, fetchSnsTxtRecord } from "./sns.js";
22
+ export { decodeCrossChainAnnouncementEventData, decodeCrossChainAnnouncementLogs, crossChainEventToAnnouncement, fetchCrossChainAnnouncementsRange, } from "./uab-receiver.js";
23
+ export type { DecodedCrossChainAnnouncementEvent } from "./uab-receiver.js";
24
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EACtB,iCAAiC,EACjC,2BAA2B,EAC3B,gCAAgC,EAChC,4CAA4C,EAC5C,mBAAmB,GACpB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,mBAAmB,EACnB,4BAA4B,EAC5B,8BAA8B,EAC9B,kBAAkB,EAClB,YAAY,GACb,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,KAAK,wBAAwB,EAC7B,wBAAwB,EACxB,2BAA2B,EAC3B,2BAA2B,EAC3B,sBAAsB,EACtB,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,EAC1B,4CAA4C,EAC5C,4CAA4C,GAC7C,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,KAAK,gBAAgB,EACrB,4BAA4B,EAC5B,eAAe,GAChB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,KAAK,kCAAkC,EACvC,KAAK,sBAAsB,EAC3B,wBAAwB,EACxB,uBAAuB,EACvB,6BAA6B,EAC7B,yBAAyB,EACzB,uBAAuB,EACvB,iCAAiC,EACjC,sBAAsB,GACvB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,aAAa,EACb,KAAK,mBAAmB,GACzB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,UAAU,EACV,UAAU,EACV,KAAK,EACL,KAAK,EACL,KAAK,EACL,WAAW,EACX,UAAU,GACX,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,sBAAsB,EACtB,cAAc,EACd,uBAAuB,EACvB,wBAAwB,EACxB,uBAAuB,EACvB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,EAC9B,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,WAAW,EACX,qBAAqB,EACrB,cAAc,EACd,qBAAqB,EACrB,yBAAyB,EACzB,oBAAoB,EACpB,mBAAmB,EACnB,wBAAwB,EACxB,4BAA4B,GAC7B,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE5D,OAAO,EACL,qCAAqC,EACrC,gCAAgC,EAChC,6BAA6B,EAC7B,iCAAiC,GAClC,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,kCAAkC,EAAE,MAAM,mBAAmB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,24 @@
1
+ /**
2
+ * `@opaquecash/stealth-chain-solana` — Solana (web3.js) integration for the Opaque stealth
3
+ * registry and announcer.
4
+ *
5
+ * Mirrors `@opaquecash/stealth-chain` (EVM/viem): program ids and cluster config, PDA
6
+ * derivation, Anchor instruction builders, `Announcement` log decoding, and {@link SolanaAdapter}
7
+ * (an implementation of `@opaquecash/adapter`'s `ChainAdapter`). All crypto is shared with the
8
+ * EVM path via the chain-neutral DKSAP core; only chain access lives here.
9
+ *
10
+ * @packageDocumentation
11
+ */
12
+ export { SOLANA_DEPLOYMENTS, getSolanaDeployment, CLUSTER_ENDPOINTS, WORMHOLE_CORE_DEVNET, SCHEME_ID_SECP256K1, ANNOUNCE_DISCRIMINATOR, ANNOUNCE_WITH_RELAY_DISCRIMINATOR, REGISTER_KEYS_DISCRIMINATOR, ANNOUNCEMENT_EVENT_DISCRIMINATOR, CROSS_CHAIN_ANNOUNCEMENT_EVENT_DISCRIMINATOR, REGISTRY_ENTRY_SEED, } from "./programs.js";
13
+ export { getRegistryEntryPda, buildRegisterKeysInstruction, decodeRegistryEntryMetaAddress, resolveMetaAddress, isRegistered, } from "./registry.js";
14
+ export { buildAnnounceInstruction, encodeAnnouncementEventData, decodeAnnouncementEventData, decodeAnnouncementLogs, eventToAnnouncement, fetchAnnouncementsRange, watchAnnouncements, } from "./announcer.js";
15
+ export { deriveStealthSolanaKeypair, deriveStealthSolanaAddress, deriveStealthSolanaKeypairFromStealthPrivKey, deriveStealthSolanaAddressFromStealthPrivKey, } from "./stealth.js";
16
+ export { buildStealthSweepTransaction, sweepStealthSol, } from "./sweep.js";
17
+ export { deriveWormholeEmitterPda, deriveWormholeConfigPda, deriveWormholeFeeCollectorPda, deriveWormholeSequencePda, fetchWormholeMessageFee, buildAnnounceWithRelayInstruction, buildAnnounceWithRelay, } from "./relay.js";
18
+ export { SolanaAdapter, } from "./adapter.js";
19
+ // Byte helpers (handy for indexers and tests).
20
+ export { bytesToHex, hexToBytes, u64le, u32le, vecU8, concatBytes, ByteReader, } from "./bytes.js";
21
+ export { ONS_MIRROR_RECORD_SEED, ONS_CLAIM_SEED, ONS_PENDING_WINDOW_SECS, ONS_RECORD_DISCRIMINATOR, ONS_CLAIM_DISCRIMINATOR, onsNameHash, getOnsMirrorRecordPda, getOnsClaimPda, decodeOnsMirrorRecord, decodeOnsProvisionalClaim, fetchOnsMirrorRecord, fetchOnsClaimStatus, buildOnsClaimInstruction, buildOnsReconcileInstruction, } from "./ons.js";
22
+ export { snsDomainName, fetchSnsTxtRecord } from "./sns.js";
23
+ export { decodeCrossChainAnnouncementEventData, decodeCrossChainAnnouncementLogs, crossChainEventToAnnouncement, fetchCrossChainAnnouncementsRange, } from "./uab-receiver.js";
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAGL,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EACtB,iCAAiC,EACjC,2BAA2B,EAC3B,gCAAgC,EAChC,4CAA4C,EAC5C,mBAAmB,GACpB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,mBAAmB,EACnB,4BAA4B,EAC5B,8BAA8B,EAC9B,kBAAkB,EAClB,YAAY,GACb,MAAM,eAAe,CAAC;AAEvB,OAAO,EAEL,wBAAwB,EACxB,2BAA2B,EAC3B,2BAA2B,EAC3B,sBAAsB,EACtB,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,EAC1B,4CAA4C,EAC5C,4CAA4C,GAC7C,MAAM,cAAc,CAAC;AAEtB,OAAO,EAEL,4BAA4B,EAC5B,eAAe,GAChB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAGL,wBAAwB,EACxB,uBAAuB,EACvB,6BAA6B,EAC7B,yBAAyB,EACzB,uBAAuB,EACvB,iCAAiC,EACjC,sBAAsB,GACvB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,aAAa,GAEd,MAAM,cAAc,CAAC;AAEtB,+CAA+C;AAC/C,OAAO,EACL,UAAU,EACV,UAAU,EACV,KAAK,EACL,KAAK,EACL,KAAK,EACL,WAAW,EACX,UAAU,GACX,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,sBAAsB,EACtB,cAAc,EACd,uBAAuB,EACvB,wBAAwB,EACxB,uBAAuB,EAMvB,WAAW,EACX,qBAAqB,EACrB,cAAc,EACd,qBAAqB,EACrB,yBAAyB,EACzB,oBAAoB,EACpB,mBAAmB,EACnB,wBAAwB,EACxB,4BAA4B,GAC7B,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE5D,OAAO,EACL,qCAAqC,EACrC,gCAAgC,EAChC,6BAA6B,EAC7B,iCAAiC,GAClC,MAAM,mBAAmB,CAAC"}
package/dist/ons.d.ts ADDED
@@ -0,0 +1,122 @@
1
+ /**
2
+ * ONS mirror reads (spec/ONS.md §3): resolve `alice.opq.eth` from Solana with one
3
+ * account fetch and no Ethereum RPC. The `ons-mirror` program holds a read-only PDA
4
+ * per name, written exclusively from Wormhole VAAs emitted by the canonical
5
+ * OpaqueNameRegistry on Ethereum; this module derives the PDA from
6
+ * `keccak256(lowercase full name)` and parses the record.
7
+ *
8
+ * Consistency: a mirror record lags the canonical record by Wormhole end-to-end
9
+ * latency (eventually consistent, canonical-chain-wins). Clients that can also
10
+ * reach an Ethereum RPC MAY prefer canonical resolution.
11
+ */
12
+ import { Connection, PublicKey, TransactionInstruction } from "@solana/web3.js";
13
+ import type { Hex } from "@opaquecash/adapter";
14
+ /** PDA seed prefix for a mirrored name record: `["ons_mirror", keccak256(name)]`. */
15
+ export declare const ONS_MIRROR_RECORD_SEED = "ons_mirror";
16
+ /** PDA seed prefix for a provisional claim: `["ons_claim", keccak256(name)]`. */
17
+ export declare const ONS_CLAIM_SEED = "ons_claim";
18
+ /** Pending window after which an unconfirmed claim reconciles as expired (spec/ONS.md §6). */
19
+ export declare const ONS_PENDING_WINDOW_SECS: number;
20
+ /** Anchor account discriminator: `sha256("account:OnsRecord")[0..8]`. */
21
+ export declare const ONS_RECORD_DISCRIMINATOR: Uint8Array;
22
+ /** Anchor account discriminator: `sha256("account:ProvisionalClaim")[0..8]`. */
23
+ export declare const ONS_CLAIM_DISCRIMINATOR: Uint8Array;
24
+ /** A mirrored ONS name record (spec/ONS.md §3). */
25
+ export interface OnsMirrorRecord {
26
+ /** `keccak256(utf8(fullName))`. */
27
+ nameHash: Hex;
28
+ /** CSAP §2.1 66-byte meta-address, `V‖S` (viewing half first). */
29
+ metaAddressHex: Hex;
30
+ /** 33-byte compressed spending public key. */
31
+ spendPubKey: Hex;
32
+ /** 33-byte compressed viewing public key. */
33
+ viewPubKey: Hex;
34
+ /** Canonical registrant (20-byte Ethereum address; surrogate for Solana claims). */
35
+ ethOwner: Hex;
36
+ /** Claimer's Solana pubkey, or `null` when the name was claimed from Ethereum. */
37
+ solAuthority: PublicKey | null;
38
+ /** Last applied Wormhole sequence from the canonical registry. */
39
+ wormholeSequence: bigint;
40
+ /** Unix seconds of the last applied update (mirror-side clock). */
41
+ updatedAt: number;
42
+ }
43
+ /** `keccak256` of the lowercase full name — the mirror PDA key (spec/ONS.md §1.3). */
44
+ export declare function onsNameHash(fullName: string): Uint8Array;
45
+ /** Derive the mirror record PDA for a full name (e.g. `"alice.opq.eth"`). */
46
+ export declare function getOnsMirrorRecordPda(mirrorProgramId: PublicKey, fullName: string): PublicKey;
47
+ /** Parse a raw `OnsRecord` account, or return `null` when it is not one. */
48
+ export declare function decodeOnsMirrorRecord(data: Uint8Array): OnsMirrorRecord | null;
49
+ /**
50
+ * Fetch and decode the mirror record for a full name. Returns `null` when the name
51
+ * has no mirror record (unregistered, revoked, or the mirror has not caught up yet).
52
+ */
53
+ export declare function fetchOnsMirrorRecord(connection: Connection, mirrorProgramId: PublicKey, fullName: string): Promise<OnsMirrorRecord | null>;
54
+ /** A provisional claim account (`ons-registration` program). */
55
+ export interface OnsProvisionalClaim {
56
+ claimer: PublicKey;
57
+ nameHash: Hex;
58
+ /** Unix seconds the claim was created (starts the pending window). */
59
+ createdAt: number;
60
+ }
61
+ /** Derive the provisional claim PDA for a full name. */
62
+ export declare function getOnsClaimPda(registrationProgramId: PublicKey, fullName: string): PublicKey;
63
+ /** Parse a raw `ProvisionalClaim` account, or return `null` when it is not one. */
64
+ export declare function decodeOnsProvisionalClaim(data: Uint8Array): OnsProvisionalClaim | null;
65
+ /** Parameters for {@link buildOnsClaimInstruction}. */
66
+ export interface OnsClaimInstructionParams {
67
+ registrationProgramId: PublicKey;
68
+ wormholeCore: PublicKey;
69
+ /** The claiming wallet: signer, fee payer, and the claim's Solana authority. */
70
+ claimer: PublicKey;
71
+ /** The label being claimed (`alice`), lowercase LDH. */
72
+ label: string;
73
+ /** The parent name in force (`opq.eth` / `opqtest.eth`). */
74
+ parentName: string;
75
+ /** 33-byte compressed spending public key. */
76
+ spendPubKey: Uint8Array;
77
+ /** 33-byte compressed viewing public key. */
78
+ viewPubKey: Uint8Array;
79
+ /** Fresh keypair pubkey for the Wormhole message account (must also sign). */
80
+ wormholeMessage: PublicKey;
81
+ /** Wormhole batch id / nonce (default 0). */
82
+ batchId?: number;
83
+ /** Wormhole message fee in lamports (10 on devnet; see `fetchWormholeMessageFee`). */
84
+ wormholeFee?: bigint;
85
+ }
86
+ /**
87
+ * Build the `ons-registration::claim` instruction: creates the provisional PDA and
88
+ * publishes the ONS claim payload through the Wormhole Core Contract. The claim is
89
+ * PROVISIONAL (canonical-chain-wins): track it with {@link fetchOnsClaimStatus}.
90
+ */
91
+ export declare function buildOnsClaimInstruction(params: OnsClaimInstructionParams): TransactionInstruction;
92
+ /**
93
+ * Build the `ons-registration::reconcile` instruction: closes a provisional claim
94
+ * against the mirror state (confirmed / lost / expired); rent refunds to the claimer.
95
+ * Permissionless — any `payer` may submit.
96
+ */
97
+ export declare function buildOnsReconcileInstruction(params: {
98
+ registrationProgramId: PublicKey;
99
+ mirrorProgramId: PublicKey;
100
+ fullName: string;
101
+ /** The recorded claimer (rent destination). */
102
+ claimer: PublicKey;
103
+ /** The submitting signer. */
104
+ payer: PublicKey;
105
+ }): TransactionInstruction;
106
+ /** Reconciliation state of a Solana-originated claim (spec/ONS.md §6). */
107
+ export type OnsClaimState = "none" | "pending" | "confirmed" | "lost" | "expired";
108
+ /** Result of {@link fetchOnsClaimStatus}. */
109
+ export interface OnsClaimStatus {
110
+ state: OnsClaimState;
111
+ /** The open provisional claim, when one exists. */
112
+ claim: OnsProvisionalClaim | null;
113
+ /** The mirror record, when one exists (also set for `state: "none"` on taken names). */
114
+ record: OnsMirrorRecord | null;
115
+ }
116
+ /**
117
+ * Determine a name's claim state by reading the provisional-claim PDA and the mirror
118
+ * record PDA (two account fetches). `pending`/`expired` split on the 24 h window
119
+ * against the local clock. Clients MUST NOT present `pending` names as owned.
120
+ */
121
+ export declare function fetchOnsClaimStatus(connection: Connection, registrationProgramId: PublicKey, mirrorProgramId: PublicKey, fullName: string): Promise<OnsClaimStatus>;
122
+ //# sourceMappingURL=ons.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ons.d.ts","sourceRoot":"","sources":["../src/ons.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,UAAU,EACV,SAAS,EAIT,sBAAsB,EACvB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAS/C,qFAAqF;AACrF,eAAO,MAAM,sBAAsB,eAAe,CAAC;AAEnD,iFAAiF;AACjF,eAAO,MAAM,cAAc,cAAc,CAAC;AAE1C,8FAA8F;AAC9F,eAAO,MAAM,uBAAuB,QAAe,CAAC;AAEpD,yEAAyE;AACzE,eAAO,MAAM,wBAAwB,YAErB,CAAC;AAEjB,gFAAgF;AAChF,eAAO,MAAM,uBAAuB,YAEpB,CAAC;AAQjB,mDAAmD;AACnD,MAAM,WAAW,eAAe;IAC9B,mCAAmC;IACnC,QAAQ,EAAE,GAAG,CAAC;IACd,kEAAkE;IAClE,cAAc,EAAE,GAAG,CAAC;IACpB,8CAA8C;IAC9C,WAAW,EAAE,GAAG,CAAC;IACjB,6CAA6C;IAC7C,UAAU,EAAE,GAAG,CAAC;IAChB,oFAAoF;IACpF,QAAQ,EAAE,GAAG,CAAC;IACd,kFAAkF;IAClF,YAAY,EAAE,SAAS,GAAG,IAAI,CAAC;IAC/B,kEAAkE;IAClE,gBAAgB,EAAE,MAAM,CAAC;IACzB,m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,EAAE,MAAM,CAAC;IACjB,sFAAsF;IACtF,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,yBAAyB,GAChC,sBAAsB,CAqCxB;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE;IACnD,qBAAqB,EAAE,SAAS,CAAC;IACjC,eAAe,EAAE,SAAS,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,+CAA+C;IAC/C,OAAO,EAAE,SAAS,CAAC;IACnB,6BAA6B;IAC7B,KAAK,EAAE,SAAS,CAAC;CAClB,GAAG,sBAAsB,CAgBzB;AAED,0EAA0E;AAC1E,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,MAAM,GAAG,SAAS,CAAC;AAElF,6CAA6C;AAC7C,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,aAAa,CAAC;IACrB,mDAAmD;IACnD,KAAK,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAClC,wFAAwF;IACxF,MAAM,EAAE,eAAe,GAAG,IAAI,CAAC;CAChC;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CACvC,UAAU,EAAE,UAAU,EACtB,qBAAqB,EAAE,SAAS,EAChC,eAAe,EAAE,SAAS,EAC1B,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,cAAc,CAAC,CAkBzB"}
package/dist/ons.js ADDED
@@ -0,0 +1,167 @@
1
+ /**
2
+ * ONS mirror reads (spec/ONS.md §3): resolve `alice.opq.eth` from Solana with one
3
+ * account fetch and no Ethereum RPC. The `ons-mirror` program holds a read-only PDA
4
+ * per name, written exclusively from Wormhole VAAs emitted by the canonical
5
+ * OpaqueNameRegistry on Ethereum; this module derives the PDA from
6
+ * `keccak256(lowercase full name)` and parses the record.
7
+ *
8
+ * Consistency: a mirror record lags the canonical record by Wormhole end-to-end
9
+ * latency (eventually consistent, canonical-chain-wins). Clients that can also
10
+ * reach an Ethereum RPC MAY prefer canonical resolution.
11
+ */
12
+ import { PublicKey, SystemProgram, SYSVAR_CLOCK_PUBKEY, SYSVAR_RENT_PUBKEY, TransactionInstruction, } from "@solana/web3.js";
13
+ import { keccak_256 } from "@noble/hashes/sha3";
14
+ import { sha256 } from "@noble/hashes/sha256";
15
+ import { bytesToHex, concatBytes, u32le, u64le, vecU8 } from "./bytes.js";
16
+ import { deriveWormholeConfigPda, deriveWormholeEmitterPda, deriveWormholeFeeCollectorPda, deriveWormholeSequencePda, } from "./relay.js";
17
+ /** PDA seed prefix for a mirrored name record: `["ons_mirror", keccak256(name)]`. */
18
+ export const ONS_MIRROR_RECORD_SEED = "ons_mirror";
19
+ /** PDA seed prefix for a provisional claim: `["ons_claim", keccak256(name)]`. */
20
+ export const ONS_CLAIM_SEED = "ons_claim";
21
+ /** Pending window after which an unconfirmed claim reconciles as expired (spec/ONS.md §6). */
22
+ export const ONS_PENDING_WINDOW_SECS = 24 * 60 * 60;
23
+ /** Anchor account discriminator: `sha256("account:OnsRecord")[0..8]`. */
24
+ export const ONS_RECORD_DISCRIMINATOR = sha256(new TextEncoder().encode("account:OnsRecord")).subarray(0, 8);
25
+ /** Anchor account discriminator: `sha256("account:ProvisionalClaim")[0..8]`. */
26
+ export const ONS_CLAIM_DISCRIMINATOR = sha256(new TextEncoder().encode("account:ProvisionalClaim")).subarray(0, 8);
27
+ const ixDiscriminator = (name) => sha256(new TextEncoder().encode(`global:${name}`)).subarray(0, 8);
28
+ /** Total `OnsRecord` account length: 8 (discriminator) + 167 (fields). */
29
+ const ONS_RECORD_LEN = 8 + 32 + 33 + 33 + 20 + 32 + 8 + 8 + 1;
30
+ /** `keccak256` of the lowercase full name — the mirror PDA key (spec/ONS.md §1.3). */
31
+ export function onsNameHash(fullName) {
32
+ return keccak_256(new TextEncoder().encode(fullName.toLowerCase()));
33
+ }
34
+ /** Derive the mirror record PDA for a full name (e.g. `"alice.opq.eth"`). */
35
+ export function getOnsMirrorRecordPda(mirrorProgramId, fullName) {
36
+ const [pda] = PublicKey.findProgramAddressSync([new TextEncoder().encode(ONS_MIRROR_RECORD_SEED), onsNameHash(fullName)], mirrorProgramId);
37
+ return pda;
38
+ }
39
+ /** Parse a raw `OnsRecord` account, or return `null` when it is not one. */
40
+ export function decodeOnsMirrorRecord(data) {
41
+ if (data.length !== ONS_RECORD_LEN)
42
+ return null;
43
+ for (let i = 0; i < 8; i++) {
44
+ if (data[i] !== ONS_RECORD_DISCRIMINATOR[i])
45
+ return null;
46
+ }
47
+ const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
48
+ const spend = data.subarray(40, 73);
49
+ const viewKey = data.subarray(73, 106);
50
+ const authority = new PublicKey(data.subarray(126, 158));
51
+ const hex = (b) => `0x${bytesToHex(b)}`;
52
+ return {
53
+ nameHash: hex(data.subarray(8, 40)),
54
+ // CSAP §2.1 order: viewing half first.
55
+ metaAddressHex: hex(Uint8Array.from([...viewKey, ...spend])),
56
+ spendPubKey: hex(spend),
57
+ viewPubKey: hex(viewKey),
58
+ ethOwner: hex(data.subarray(106, 126)),
59
+ solAuthority: authority.equals(PublicKey.default) ? null : authority,
60
+ wormholeSequence: view.getBigUint64(158, true),
61
+ updatedAt: Number(view.getBigInt64(166, true)),
62
+ };
63
+ }
64
+ /**
65
+ * Fetch and decode the mirror record for a full name. Returns `null` when the name
66
+ * has no mirror record (unregistered, revoked, or the mirror has not caught up yet).
67
+ */
68
+ export async function fetchOnsMirrorRecord(connection, mirrorProgramId, fullName) {
69
+ const pda = getOnsMirrorRecordPda(mirrorProgramId, fullName);
70
+ const info = await connection.getAccountInfo(pda);
71
+ if (!info || !info.owner.equals(mirrorProgramId))
72
+ return null;
73
+ return decodeOnsMirrorRecord(info.data);
74
+ }
75
+ /** Derive the provisional claim PDA for a full name. */
76
+ export function getOnsClaimPda(registrationProgramId, fullName) {
77
+ const [pda] = PublicKey.findProgramAddressSync([new TextEncoder().encode(ONS_CLAIM_SEED), onsNameHash(fullName)], registrationProgramId);
78
+ return pda;
79
+ }
80
+ /** Parse a raw `ProvisionalClaim` account, or return `null` when it is not one. */
81
+ export function decodeOnsProvisionalClaim(data) {
82
+ if (data.length !== 8 + 32 + 32 + 8 + 1)
83
+ return null;
84
+ for (let i = 0; i < 8; i++) {
85
+ if (data[i] !== ONS_CLAIM_DISCRIMINATOR[i])
86
+ return null;
87
+ }
88
+ const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
89
+ return {
90
+ claimer: new PublicKey(data.subarray(8, 40)),
91
+ nameHash: `0x${bytesToHex(data.subarray(40, 72))}`,
92
+ createdAt: Number(view.getBigInt64(72, true)),
93
+ };
94
+ }
95
+ /**
96
+ * Build the `ons-registration::claim` instruction: creates the provisional PDA and
97
+ * publishes the ONS claim payload through the Wormhole Core Contract. The claim is
98
+ * PROVISIONAL (canonical-chain-wins): track it with {@link fetchOnsClaimStatus}.
99
+ */
100
+ export function buildOnsClaimInstruction(params) {
101
+ const fullName = `${params.label}.${params.parentName}`.toLowerCase();
102
+ const nameHash = onsNameHash(fullName);
103
+ const config = PublicKey.findProgramAddressSync([new TextEncoder().encode("config")], params.registrationProgramId)[0];
104
+ const emitter = deriveWormholeEmitterPda(params.registrationProgramId);
105
+ const data = concatBytes(ixDiscriminator("claim"), nameHash, vecU8(new TextEncoder().encode(params.label.toLowerCase())), // borsh String
106
+ params.spendPubKey, params.viewPubKey, u32le(params.batchId ?? 0), u64le(params.wormholeFee ?? 0n));
107
+ return new TransactionInstruction({
108
+ programId: params.registrationProgramId,
109
+ keys: [
110
+ { pubkey: config, isSigner: false, isWritable: false },
111
+ { pubkey: getOnsClaimPda(params.registrationProgramId, fullName), isSigner: false, isWritable: true },
112
+ { pubkey: params.claimer, isSigner: true, isWritable: true },
113
+ { pubkey: emitter, isSigner: false, isWritable: false },
114
+ { pubkey: deriveWormholeConfigPda(params.wormholeCore), isSigner: false, isWritable: true },
115
+ { pubkey: deriveWormholeFeeCollectorPda(params.wormholeCore), isSigner: false, isWritable: true },
116
+ { pubkey: deriveWormholeSequencePda(params.wormholeCore, emitter), isSigner: false, isWritable: true },
117
+ { pubkey: params.wormholeMessage, isSigner: true, isWritable: true },
118
+ { pubkey: params.wormholeCore, isSigner: false, isWritable: false },
119
+ { pubkey: SYSVAR_CLOCK_PUBKEY, isSigner: false, isWritable: false },
120
+ { pubkey: SYSVAR_RENT_PUBKEY, isSigner: false, isWritable: false },
121
+ { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
122
+ ],
123
+ data: Buffer.from(data),
124
+ });
125
+ }
126
+ /**
127
+ * Build the `ons-registration::reconcile` instruction: closes a provisional claim
128
+ * against the mirror state (confirmed / lost / expired); rent refunds to the claimer.
129
+ * Permissionless — any `payer` may submit.
130
+ */
131
+ export function buildOnsReconcileInstruction(params) {
132
+ const config = PublicKey.findProgramAddressSync([new TextEncoder().encode("config")], params.registrationProgramId)[0];
133
+ return new TransactionInstruction({
134
+ programId: params.registrationProgramId,
135
+ keys: [
136
+ { pubkey: config, isSigner: false, isWritable: false },
137
+ { pubkey: getOnsClaimPda(params.registrationProgramId, params.fullName), isSigner: false, isWritable: true },
138
+ { pubkey: params.claimer, isSigner: false, isWritable: true },
139
+ { pubkey: getOnsMirrorRecordPda(params.mirrorProgramId, params.fullName), isSigner: false, isWritable: false },
140
+ { pubkey: params.payer, isSigner: true, isWritable: false },
141
+ ],
142
+ data: Buffer.from(concatBytes(ixDiscriminator("reconcile"), onsNameHash(params.fullName))),
143
+ });
144
+ }
145
+ /**
146
+ * Determine a name's claim state by reading the provisional-claim PDA and the mirror
147
+ * record PDA (two account fetches). `pending`/`expired` split on the 24 h window
148
+ * against the local clock. Clients MUST NOT present `pending` names as owned.
149
+ */
150
+ export async function fetchOnsClaimStatus(connection, registrationProgramId, mirrorProgramId, fullName) {
151
+ const [claimInfo, record] = await Promise.all([
152
+ connection.getAccountInfo(getOnsClaimPda(registrationProgramId, fullName)),
153
+ fetchOnsMirrorRecord(connection, mirrorProgramId, fullName),
154
+ ]);
155
+ const claim = claimInfo && claimInfo.owner.equals(registrationProgramId)
156
+ ? decodeOnsProvisionalClaim(claimInfo.data)
157
+ : null;
158
+ if (!claim)
159
+ return { state: "none", claim: null, record };
160
+ if (record) {
161
+ const confirmed = record.solAuthority != null && record.solAuthority.equals(claim.claimer);
162
+ return { state: confirmed ? "confirmed" : "lost", claim, record };
163
+ }
164
+ const expired = Date.now() / 1000 >= claim.createdAt + ONS_PENDING_WINDOW_SECS;
165
+ return { state: expired ? "expired" : "pending", claim, record: null };
166
+ }
167
+ //# sourceMappingURL=ons.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ons.js","sourceRoot":"","sources":["../src/ons.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAEL,SAAS,EACT,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAC1E,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,6BAA6B,EAC7B,yBAAyB,GAC1B,MAAM,YAAY,CAAC;AAEpB,qFAAqF;AACrF,MAAM,CAAC,MAAM,sBAAsB,GAAG,YAAY,CAAC;AAEnD,iFAAiF;AACjF,MAAM,CAAC,MAAM,cAAc,GAAG,WAAW,CAAC;AAE1C,8FAA8F;AAC9F,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AAEpD,yEAAyE;AACzE,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAC5C,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAC9C,CAAC,QAAQ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AAE,MAAM,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QAC5C,UAAU,CAAC,cAAc,CAAC,cAAc,CAAC,qBAAqB,EAAE,QAAQ,CAAC,CAAC;QAC1E,oBAAoB,CAAC,UAAU,EAAE,eAAe,EAAE,QAAQ,CAAC;KAC5D,CAAC,CAAC;IACH,MAAM,KAAK,GACT,SAAS,IAAI,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,qBAAqB,CAAC;QACxD,CAAC,CAAC,yBAAyB,CAAC,SAAS,CAAC,IAAI,CAAC;QAC3C,CAAC,CAAC,IAAI,CAAC;IAEX,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC1D,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,SAAS,GACb,MAAM,CAAC,YAAY,IAAI,IAAI,IAAI,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3E,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IACpE,CAAC;IACD,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,IAAI,KAAK,CAAC,SAAS,GAAG,uBAAuB,CAAC;IAC/E,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;AACzE,CAAC"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Solana program ids, cluster configuration, and Anchor discriminators for the Opaque
3
+ * stealth registry and announcer.
4
+ *
5
+ * Addresses are the live devnet deployment (see `solana/` repo + memory `phase-1-uab-live`).
6
+ * Override per deployment with {@link SolanaDeployment}; nothing here reads `import.meta.env`
7
+ * or any ambient config — the SDK takes a `Connection`/cluster explicitly.
8
+ */
9
+ import { PublicKey } from "@solana/web3.js";
10
+ export type SolanaCluster = "mainnet-beta" | "devnet" | "testnet" | "localnet";
11
+ /** Wormhole Core Bridge program on Solana devnet (see memory `phase-1-uab-live`). */
12
+ export declare const WORMHOLE_CORE_DEVNET: string;
13
+ /** Resolved Opaque program ids for a Solana cluster. */
14
+ export interface SolanaDeployment {
15
+ cluster: SolanaCluster;
16
+ /** `StealthMetaAddressRegistry` program (ERC-6538 equivalent). */
17
+ stealthRegistry: PublicKey;
18
+ /** `StealthAddressAnnouncer` program (ERC-5564 equivalent). */
19
+ stealthAnnouncer: PublicKey;
20
+ /** PSR V2 schema registry program. */
21
+ schemaRegistry: PublicKey;
22
+ /** PSR V2 attestation engine program. */
23
+ attestationEngineV2: PublicKey;
24
+ /** Groth16 proof verifier program. */
25
+ groth16Verifier: PublicKey;
26
+ /** PSR reputation proof verifier program. */
27
+ reputationVerifier: PublicKey;
28
+ /** Wormhole Core Bridge program (for `announce_with_relay` cross-chain announcements). */
29
+ wormholeCore: PublicKey;
30
+ /** UAB receiver program (re-emits Ethereum-originated announcements from verified VAAs). */
31
+ uabReceiver: PublicKey;
32
+ /** ONS read-only mirror program (spec/ONS.md §3). */
33
+ onsMirror: PublicKey;
34
+ /** ONS Solana-originated claims program (spec/ONS.md §4.2). */
35
+ onsRegistration: PublicKey;
36
+ }
37
+ /** Bundled deployments by cluster (from the generated `@opaquecash/deployments`). */
38
+ export declare const SOLANA_DEPLOYMENTS: Partial<Record<SolanaCluster, SolanaDeployment>>;
39
+ /**
40
+ * Resolve the bundled {@link SolanaDeployment} for a cluster (default `devnet`), or throw
41
+ * if no addresses are bundled for it.
42
+ */
43
+ export declare function getSolanaDeployment(cluster?: SolanaCluster): SolanaDeployment;
44
+ /** Public JSON-RPC endpoint per cluster (override with your own RPC for real limits). */
45
+ export declare const CLUSTER_ENDPOINTS: Record<SolanaCluster, string>;
46
+ /** Stealth scheme id: secp256k1 with view tags (EIP-5564 scheme 1). */
47
+ export declare const SCHEME_ID_SECP256K1 = 1n;
48
+ /** `stealth_announcer::announce` instruction discriminator. */
49
+ export declare const ANNOUNCE_DISCRIMINATOR: Uint8Array;
50
+ /** `stealth_announcer::announce_with_relay` instruction discriminator (cross-chain UAB). */
51
+ export declare const ANNOUNCE_WITH_RELAY_DISCRIMINATOR: Uint8Array;
52
+ /** `stealth_registry::register_keys` instruction discriminator. */
53
+ export declare const REGISTER_KEYS_DISCRIMINATOR: Uint8Array;
54
+ /** Anchor `emit!`-ed `Announcement` event discriminator (prefixes the `Program data:` log). */
55
+ export declare const ANNOUNCEMENT_EVENT_DISCRIMINATOR: Uint8Array;
56
+ /** Anchor event discriminator: `sha256("event:CrossChainAnnouncement")[0..8]` (uab-receiver). */
57
+ export declare const CROSS_CHAIN_ANNOUNCEMENT_EVENT_DISCRIMINATOR: Uint8Array;
58
+ /** PDA seed prefix for a registry entry: `["stealth_meta", registrant, schemeId_le]`. */
59
+ export declare const REGISTRY_ENTRY_SEED = "stealth_meta";
60
+ //# sourceMappingURL=programs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"programs.d.ts","sourceRoot":"","sources":["../src/programs.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAM5C,MAAM,MAAM,aAAa,GAAG,cAAc,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,CAAC;AAE/E,qFAAqF;AACrF,eAAO,MAAM,oBAAoB,QAA4C,CAAC;AAE9E,wDAAwD;AACxD,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,aAAa,CAAC;IACvB,kEAAkE;IAClE,eAAe,EAAE,SAAS,CAAC;IAC3B,+DAA+D;IAC/D,gBAAgB,EAAE,SAAS,CAAC;IAC5B,sCAAsC;IACtC,cAAc,EAAE,SAAS,CAAC;IAC1B,yCAAyC;IACzC,mBAAmB,EAAE,SAAS,CAAC;IAC/B,sCAAsC;IACtC,eAAe,EAAE,SAAS,CAAC;IAC3B,6CAA6C;IAC7C,kBAAkB,EAAE,SAAS,CAAC;IAC9B,0FAA0F;IAC1F,YAAY,EAAE,SAAS,CAAC;IACxB,4FAA4F;IAC5F,WAAW,EAAE,SAAS,CAAC;IACvB,qDAAqD;IACrD,SAAS,EAAE,SAAS,CAAC;IACrB,+DAA+D;IAC/D,eAAe,EAAE,SAAS,CAAC;CAC5B;AAqBD,qFAAqF;AACrF,eAAO,MAAM,kBAAkB,EAAE,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,CAM7E,CAAC;AAEJ;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,aAAwB,GAAG,gBAAgB,CAQvF;AAED,yFAAyF;AACzF,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,aAAa,EAAE,MAAM,CAK3D,CAAC;AAEF,uEAAuE;AACvE,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAOtC,+DAA+D;AAC/D,eAAO,MAAM,sBAAsB,YAAuD,CAAC;AAE3F,4FAA4F;AAC5F,eAAO,MAAM,iCAAiC,YAAyD,CAAC;AAExG,mEAAmE;AACnE,eAAO,MAAM,2BAA2B,YAAoE,CAAC;AAE7G,+FAA+F;AAC/F,eAAO,MAAM,gCAAgC,YAAsD,CAAC;AAEpG,iGAAiG;AACjG,eAAO,MAAM,4CAA4C,YAAyD,CAAC;AAEnH,yFAAyF;AACzF,eAAO,MAAM,mBAAmB,iBAAiB,CAAC"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Solana program ids, cluster configuration, and Anchor discriminators for the Opaque
3
+ * stealth registry and announcer.
4
+ *
5
+ * Addresses are the live devnet deployment (see `solana/` repo + memory `phase-1-uab-live`).
6
+ * Override per deployment with {@link SolanaDeployment}; nothing here reads `import.meta.env`
7
+ * or any ambient config — the SDK takes a `Connection`/cluster explicitly.
8
+ */
9
+ import { PublicKey } from "@solana/web3.js";
10
+ import { SOLANA_PROGRAM_IDS, } from "@opaquecash/deployments";
11
+ /** Wormhole Core Bridge program on Solana devnet (see memory `phase-1-uab-live`). */
12
+ export const WORMHOLE_CORE_DEVNET = SOLANA_PROGRAM_IDS["devnet"].wormholeCore;
13
+ function deploymentFromIds(cluster, ids) {
14
+ return {
15
+ cluster,
16
+ stealthRegistry: new PublicKey(ids.stealthRegistry),
17
+ stealthAnnouncer: new PublicKey(ids.stealthAnnouncer),
18
+ schemaRegistry: new PublicKey(ids.schemaRegistry),
19
+ attestationEngineV2: new PublicKey(ids.attestationEngineV2),
20
+ groth16Verifier: new PublicKey(ids.groth16Verifier),
21
+ reputationVerifier: new PublicKey(ids.reputationVerifier),
22
+ wormholeCore: new PublicKey(ids.wormholeCore),
23
+ uabReceiver: new PublicKey(ids.uabReceiver),
24
+ onsMirror: new PublicKey(ids.onsMirror),
25
+ onsRegistration: new PublicKey(ids.onsRegistration),
26
+ };
27
+ }
28
+ /** Bundled deployments by cluster (from the generated `@opaquecash/deployments`). */
29
+ export const SOLANA_DEPLOYMENTS = Object.fromEntries(Object.entries(SOLANA_PROGRAM_IDS).map(([cluster, ids]) => [
30
+ cluster,
31
+ deploymentFromIds(cluster, ids),
32
+ ]));
33
+ /**
34
+ * Resolve the bundled {@link SolanaDeployment} for a cluster (default `devnet`), or throw
35
+ * if no addresses are bundled for it.
36
+ */
37
+ export function getSolanaDeployment(cluster = "devnet") {
38
+ const d = SOLANA_DEPLOYMENTS[cluster];
39
+ if (!d) {
40
+ throw new Error(`No bundled Opaque Solana deployment for cluster "${cluster}"; pass a deployment override.`);
41
+ }
42
+ return d;
43
+ }
44
+ /** Public JSON-RPC endpoint per cluster (override with your own RPC for real limits). */
45
+ export const CLUSTER_ENDPOINTS = {
46
+ "mainnet-beta": "https://api.mainnet-beta.solana.com",
47
+ devnet: "https://api.devnet.solana.com",
48
+ testnet: "https://api.testnet.solana.com",
49
+ localnet: "http://127.0.0.1:8899",
50
+ };
51
+ /** Stealth scheme id: secp256k1 with view tags (EIP-5564 scheme 1). */
52
+ export const SCHEME_ID_SECP256K1 = 1n;
53
+ // ---------------------------------------------------------------------------
54
+ // Anchor discriminators (from `solana/target/idl/stealth_announcer.json` and the
55
+ // deployed registry program). First 8 bytes of the instruction / event data.
56
+ // ---------------------------------------------------------------------------
57
+ /** `stealth_announcer::announce` instruction discriminator. */
58
+ export const ANNOUNCE_DISCRIMINATOR = Uint8Array.from([7, 30, 100, 250, 110, 253, 3, 149]);
59
+ /** `stealth_announcer::announce_with_relay` instruction discriminator (cross-chain UAB). */
60
+ export const ANNOUNCE_WITH_RELAY_DISCRIMINATOR = Uint8Array.from([3, 242, 201, 249, 200, 171, 146, 79]);
61
+ /** `stealth_registry::register_keys` instruction discriminator. */
62
+ export const REGISTER_KEYS_DISCRIMINATOR = Uint8Array.from([0x29, 0x44, 0x64, 0x7d, 0x76, 0x2e, 0xfc, 0x84]);
63
+ /** Anchor `emit!`-ed `Announcement` event discriminator (prefixes the `Program data:` log). */
64
+ export const ANNOUNCEMENT_EVENT_DISCRIMINATOR = Uint8Array.from([7, 44, 132, 71, 104, 35, 168, 60]);
65
+ /** Anchor event discriminator: `sha256("event:CrossChainAnnouncement")[0..8]` (uab-receiver). */
66
+ export const CROSS_CHAIN_ANNOUNCEMENT_EVENT_DISCRIMINATOR = Uint8Array.from([13, 87, 101, 171, 128, 65, 106, 220]);
67
+ /** PDA seed prefix for a registry entry: `["stealth_meta", registrant, schemeId_le]`. */
68
+ export const REGISTRY_ENTRY_SEED = "stealth_meta";
69
+ //# sourceMappingURL=programs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"programs.js","sourceRoot":"","sources":["../src/programs.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,kBAAkB,GAEnB,MAAM,yBAAyB,CAAC;AAIjC,qFAAqF;AACrF,MAAM,CAAC,MAAM,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