@ouronet/ouronet-core 4.3.6

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 (101) hide show
  1. package/CHANGELOG.md +3043 -0
  2. package/README.md +1940 -0
  3. package/dist/codex/codec.d.ts +77 -0
  4. package/dist/codex/codec.js +123 -0
  5. package/dist/codex/errors.d.ts +14 -0
  6. package/dist/codex/errors.js +20 -0
  7. package/dist/codex/index.d.ts +27 -0
  8. package/dist/codex/index.js +25 -0
  9. package/dist/codex/seedTypeMigration.d.ts +35 -0
  10. package/dist/codex/seedTypeMigration.js +45 -0
  11. package/dist/codex/types.d.ts +100 -0
  12. package/dist/codex/types.js +19 -0
  13. package/dist/constants/index.d.ts +2 -0
  14. package/dist/constants/index.js +3 -0
  15. package/dist/constants/ouronet.d.ts +33 -0
  16. package/dist/constants/ouronet.js +59 -0
  17. package/dist/constants/tokenIds.d.ts +13 -0
  18. package/dist/constants/tokenIds.js +21 -0
  19. package/dist/index.d.ts +18 -0
  20. package/dist/index.js +1 -0
  21. package/dist/interactions/activateFunctions.d.ts +67 -0
  22. package/dist/interactions/activateFunctions.js +154 -0
  23. package/dist/interactions/addLiquidityFunctions.d.ts +140 -0
  24. package/dist/interactions/addLiquidityFunctions.js +485 -0
  25. package/dist/interactions/coilFunctions.d.ts +73 -0
  26. package/dist/interactions/coilFunctions.js +213 -0
  27. package/dist/interactions/crossChainFunctions.d.ts +211 -0
  28. package/dist/interactions/crossChainFunctions.js +463 -0
  29. package/dist/interactions/dexAcquisitionPoolFunctions.d.ts +18 -0
  30. package/dist/interactions/dexAcquisitionPoolFunctions.js +18 -0
  31. package/dist/interactions/dexCollectablesFunctions.d.ts +28 -0
  32. package/dist/interactions/dexCollectablesFunctions.js +227 -0
  33. package/dist/interactions/dexFunctions.d.ts +23 -0
  34. package/dist/interactions/dexFunctions.js +23 -0
  35. package/dist/interactions/dexOrtoFungibleFunctions.d.ts +33 -0
  36. package/dist/interactions/dexOrtoFungibleFunctions.js +171 -0
  37. package/dist/interactions/dexParseFunctions.d.ts +150 -0
  38. package/dist/interactions/dexParseFunctions.js +316 -0
  39. package/dist/interactions/dexSwapPairAdminFunctions.d.ts +75 -0
  40. package/dist/interactions/dexSwapPairAdminFunctions.js +255 -0
  41. package/dist/interactions/dexSwapPairCalcFunctions.d.ts +55 -0
  42. package/dist/interactions/dexSwapPairCalcFunctions.js +218 -0
  43. package/dist/interactions/dexSwapPairDashboardFunctions.d.ts +47 -0
  44. package/dist/interactions/dexSwapPairDashboardFunctions.js +179 -0
  45. package/dist/interactions/dexSwapPairExecuteFunctions.d.ts +40 -0
  46. package/dist/interactions/dexSwapPairExecuteFunctions.js +301 -0
  47. package/dist/interactions/dexSwapPairSmartSwapFunctions.d.ts +25 -0
  48. package/dist/interactions/dexSwapPairSmartSwapFunctions.js +166 -0
  49. package/dist/interactions/dexTrueFungibleFunctions.d.ts +52 -0
  50. package/dist/interactions/dexTrueFungibleFunctions.js +220 -0
  51. package/dist/interactions/dexTypes.d.ts +465 -0
  52. package/dist/interactions/dexTypes.js +6 -0
  53. package/dist/interactions/errors.d.ts +12 -0
  54. package/dist/interactions/errors.js +13 -0
  55. package/dist/interactions/guardFunctions.d.ts +33 -0
  56. package/dist/interactions/guardFunctions.js +110 -0
  57. package/dist/interactions/index.d.ts +1 -0
  58. package/dist/interactions/index.js +20 -0
  59. package/dist/interactions/infoOneFunctions.d.ts +133 -0
  60. package/dist/interactions/infoOneFunctions.js +566 -0
  61. package/dist/interactions/kadenaFunctions.d.ts +11 -0
  62. package/dist/interactions/kadenaFunctions.js +40 -0
  63. package/dist/interactions/kpayFunctions.d.ts +45 -0
  64. package/dist/interactions/kpayFunctions.js +191 -0
  65. package/dist/interactions/ouroAccountFunctions.d.ts +64 -0
  66. package/dist/interactions/ouroAccountFunctions.js +229 -0
  67. package/dist/interactions/ouroBalanceFunctions.d.ts +39 -0
  68. package/dist/interactions/ouroBalanceFunctions.js +100 -0
  69. package/dist/interactions/ouroCoilFunctions.d.ts +33 -0
  70. package/dist/interactions/ouroCoilFunctions.js +190 -0
  71. package/dist/interactions/ouroFunctions.d.ts +23 -0
  72. package/dist/interactions/ouroFunctions.js +23 -0
  73. package/dist/interactions/ouroMovieBoosterFunctions.d.ts +18 -0
  74. package/dist/interactions/ouroMovieBoosterFunctions.js +203 -0
  75. package/dist/interactions/ouroPriceFunctions.d.ts +38 -0
  76. package/dist/interactions/ouroPriceFunctions.js +96 -0
  77. package/dist/interactions/ouroPrimordialsFunctions.d.ts +10 -0
  78. package/dist/interactions/ouroPrimordialsFunctions.js +480 -0
  79. package/dist/interactions/ouroRotateFunctions.d.ts +22 -0
  80. package/dist/interactions/ouroRotateFunctions.js +114 -0
  81. package/dist/interactions/ouroSubCompressFunctions.d.ts +23 -0
  82. package/dist/interactions/ouroSubCompressFunctions.js +191 -0
  83. package/dist/interactions/ouroTransferFunctions.d.ts +14 -0
  84. package/dist/interactions/ouroTransferFunctions.js +87 -0
  85. package/dist/interactions/ouroTypes.d.ts +113 -0
  86. package/dist/interactions/ouroTypes.js +6 -0
  87. package/dist/interactions/ouroUrStoaFunctions.d.ts +16 -0
  88. package/dist/interactions/ouroUrStoaFunctions.js +121 -0
  89. package/dist/interactions/ouroWrapFunctions.d.ts +22 -0
  90. package/dist/interactions/ouroWrapFunctions.js +234 -0
  91. package/dist/interactions/pensionFunctions.d.ts +12 -0
  92. package/dist/interactions/pensionFunctions.js +127 -0
  93. package/dist/interactions/urStoaFunctions.d.ts +104 -0
  94. package/dist/interactions/urStoaFunctions.js +475 -0
  95. package/dist/interactions/wrapFunctions.d.ts +46 -0
  96. package/dist/interactions/wrapFunctions.js +221 -0
  97. package/dist/pact/cfmBuilders.d.ts +807 -0
  98. package/dist/pact/cfmBuilders.js +812 -0
  99. package/dist/pact/index.d.ts +1 -0
  100. package/dist/pact/index.js +10 -0
  101. package/package.json +64 -0
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Codex serialization / deserialization — the shared codec between
3
+ * OuronetUI's "Export Codex" button and any future consumer that reads
4
+ * the same backup JSON (HUB's codex-import flow, CLI recovery tools,
5
+ * etc.).
6
+ *
7
+ * The written format is now `CodexExportV1_3` — the `"version": "1.3"`
8
+ * string. This was an INTENTIONAL 1.2→1.3 bump made under strict
9
+ * reader-before-writer discipline: `deserializeCodex` was widened to
10
+ * accept BOTH "1.2" and "1.3" (and to allow-list the optional
11
+ * `foreignKeys` block) BEFORE this writer began stamping "1.3". That
12
+ * ordering is what makes the bump safe — every previously downloaded
13
+ * `OuronetCodex_*.json` (still "1.2") keeps importing, and every new
14
+ * export ("1.3") deserializes through the same reader.
15
+ *
16
+ * Do NOT revert the writer to "1.2" in isolation, and do NOT narrow the
17
+ * reader back to "1.2"-only: emitting a version the reader rejects (or
18
+ * rejecting the version the writer emits) is a funds-loss inversion — a
19
+ * user's own fresh backup would fail to restore. Any future format change
20
+ * must keep the reader ahead of the writer.
21
+ *
22
+ * All pure. No password handling in here — the BYTES INSIDE the JSON are
23
+ * already encrypted at the codex-entry level (each wallet's `secret` field
24
+ * is a V1 or V2 blob). Serializing the codex doesn't touch those blobs;
25
+ * it just wraps them in the portable envelope.
26
+ */
27
+ import type { CodexExportV1_2, CodexExportV1_3, PlaintextCodex } from "./types.js";
28
+ /**
29
+ * Build a codex-export payload from a PlaintextCodex. Stamps the current
30
+ * `"1.3"` envelope version and `exportedAt` with the current ISO time.
31
+ * Returns the object — the caller stringifies it (so callers in a
32
+ * memory-constrained environment can stream it out instead of holding the
33
+ * whole string in RAM).
34
+ *
35
+ * The return type is the `CodexExportV1_2 | CodexExportV1_3` union so
36
+ * consumers written against the historical 1.2 shape still type-check
37
+ * against the widened output; the runtime value is always a 1.3 envelope.
38
+ *
39
+ * The optional `foreignKeys` block is EMITTED only when the source codex
40
+ * carries foreign keys. ouronet's `PlaintextCodex` has no foreign-key
41
+ * source field today, so the practical output is a bare 1.3 envelope with
42
+ * `foreignKeys` omitted — no mandatory empty block.
43
+ *
44
+ * Fields left out intentionally: `pureKeypairs`, `schemaVersion`,
45
+ * `lastUpdatedAt`, `lastUpdatedDevice` — see CodexExportV1_3 JSDoc for
46
+ * the rationale (historical shape, device-local fields don't travel).
47
+ */
48
+ export declare function buildCodexExport<KS, OA, PK, AB, UI>(codex: PlaintextCodex<KS, OA, PK, AB, UI>): CodexExportV1_2<KS, OA, AB, UI> | CodexExportV1_3<KS, OA, AB, UI>;
49
+ /**
50
+ * Stringify a PlaintextCodex into the `"1.3"` backup JSON format, the
51
+ * exact output of OuronetUI's LocalStorageCodexAdapter.downloadAsJson.
52
+ * Pretty-prints with 2-space indent because the file lands on disk and
53
+ * a human occasionally opens it to sanity-check account addresses.
54
+ */
55
+ export declare function serializeCodex<KS, OA, PK, AB, UI>(codex: PlaintextCodex<KS, OA, PK, AB, UI>): string;
56
+ /**
57
+ * Parse a codex-export JSON string. Does NOT decrypt any enclosed blobs
58
+ * — the returned object's `kadenaWallets[i].secret` etc. are still V1/V2
59
+ * encrypted strings. Caller is responsible for decrypting them with the
60
+ * codex password once they've validated the parse.
61
+ *
62
+ * Throws on:
63
+ * - invalid JSON
64
+ * - missing `"version"` field (malformed)
65
+ * - version mismatch (not `"1.2"`)
66
+ * - shape mismatch (kadenaWallets, ouronetWallets, addressBook not arrays; uiSettings not an object)
67
+ *
68
+ * The version check exists to fail-fast rather than silently mis-decoding
69
+ * a future V2 export format. Callers that want best-effort partial reads
70
+ * can catch the throw and fall through to a recovery path.
71
+ *
72
+ * Shape-validation errors NAME the offending field but never echo its
73
+ * value — a codex envelope can carry encrypted secrets and account
74
+ * addresses, and surfacing those into telemetry/logs would breach the
75
+ * codec's information-disclosure boundary.
76
+ */
77
+ export declare function deserializeCodex<KS = unknown, OA = unknown, AB = unknown, UI = unknown>(json: string): CodexExportV1_2<KS, OA, AB, UI>;
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Codex serialization / deserialization — the shared codec between
3
+ * OuronetUI's "Export Codex" button and any future consumer that reads
4
+ * the same backup JSON (HUB's codex-import flow, CLI recovery tools,
5
+ * etc.).
6
+ *
7
+ * The written format is now `CodexExportV1_3` — the `"version": "1.3"`
8
+ * string. This was an INTENTIONAL 1.2→1.3 bump made under strict
9
+ * reader-before-writer discipline: `deserializeCodex` was widened to
10
+ * accept BOTH "1.2" and "1.3" (and to allow-list the optional
11
+ * `foreignKeys` block) BEFORE this writer began stamping "1.3". That
12
+ * ordering is what makes the bump safe — every previously downloaded
13
+ * `OuronetCodex_*.json` (still "1.2") keeps importing, and every new
14
+ * export ("1.3") deserializes through the same reader.
15
+ *
16
+ * Do NOT revert the writer to "1.2" in isolation, and do NOT narrow the
17
+ * reader back to "1.2"-only: emitting a version the reader rejects (or
18
+ * rejecting the version the writer emits) is a funds-loss inversion — a
19
+ * user's own fresh backup would fail to restore. Any future format change
20
+ * must keep the reader ahead of the writer.
21
+ *
22
+ * All pure. No password handling in here — the BYTES INSIDE the JSON are
23
+ * already encrypted at the codex-entry level (each wallet's `secret` field
24
+ * is a V1 or V2 blob). Serializing the codex doesn't touch those blobs;
25
+ * it just wraps them in the portable envelope.
26
+ */
27
+ import { CodexUnknownFieldError } from "./errors.js";
28
+ /**
29
+ * Build a codex-export payload from a PlaintextCodex. Stamps the current
30
+ * `"1.3"` envelope version and `exportedAt` with the current ISO time.
31
+ * Returns the object — the caller stringifies it (so callers in a
32
+ * memory-constrained environment can stream it out instead of holding the
33
+ * whole string in RAM).
34
+ *
35
+ * The return type is the `CodexExportV1_2 | CodexExportV1_3` union so
36
+ * consumers written against the historical 1.2 shape still type-check
37
+ * against the widened output; the runtime value is always a 1.3 envelope.
38
+ *
39
+ * The optional `foreignKeys` block is EMITTED only when the source codex
40
+ * carries foreign keys. ouronet's `PlaintextCodex` has no foreign-key
41
+ * source field today, so the practical output is a bare 1.3 envelope with
42
+ * `foreignKeys` omitted — no mandatory empty block.
43
+ *
44
+ * Fields left out intentionally: `pureKeypairs`, `schemaVersion`,
45
+ * `lastUpdatedAt`, `lastUpdatedDevice` — see CodexExportV1_3 JSDoc for
46
+ * the rationale (historical shape, device-local fields don't travel).
47
+ */
48
+ export function buildCodexExport(codex) {
49
+ return {
50
+ version: "1.3",
51
+ exportedAt: new Date().toISOString(),
52
+ kadenaWallets: codex.kadenaWallets,
53
+ ouronetWallets: codex.ouronetWallets,
54
+ addressBook: codex.addressBook,
55
+ uiSettings: codex.uiSettings,
56
+ };
57
+ }
58
+ /**
59
+ * Stringify a PlaintextCodex into the `"1.3"` backup JSON format, the
60
+ * exact output of OuronetUI's LocalStorageCodexAdapter.downloadAsJson.
61
+ * Pretty-prints with 2-space indent because the file lands on disk and
62
+ * a human occasionally opens it to sanity-check account addresses.
63
+ */
64
+ export function serializeCodex(codex) {
65
+ return JSON.stringify(buildCodexExport(codex), null, 2);
66
+ }
67
+ /**
68
+ * Parse a codex-export JSON string. Does NOT decrypt any enclosed blobs
69
+ * — the returned object's `kadenaWallets[i].secret` etc. are still V1/V2
70
+ * encrypted strings. Caller is responsible for decrypting them with the
71
+ * codex password once they've validated the parse.
72
+ *
73
+ * Throws on:
74
+ * - invalid JSON
75
+ * - missing `"version"` field (malformed)
76
+ * - version mismatch (not `"1.2"`)
77
+ * - shape mismatch (kadenaWallets, ouronetWallets, addressBook not arrays; uiSettings not an object)
78
+ *
79
+ * The version check exists to fail-fast rather than silently mis-decoding
80
+ * a future V2 export format. Callers that want best-effort partial reads
81
+ * can catch the throw and fall through to a recovery path.
82
+ *
83
+ * Shape-validation errors NAME the offending field but never echo its
84
+ * value — a codex envelope can carry encrypted secrets and account
85
+ * addresses, and surfacing those into telemetry/logs would breach the
86
+ * codec's information-disclosure boundary.
87
+ */
88
+ export function deserializeCodex(json) {
89
+ const parsed = JSON.parse(json);
90
+ if (!parsed || typeof parsed !== "object") {
91
+ throw new Error("deserializeCodex: not an object");
92
+ }
93
+ // Strict-equality membership only. No trim/normalize/prefix matching: a
94
+ // version string that merely LOOKS like an accepted one (" 1.3 ", "1.3.0",
95
+ // "1.3\n") must fail closed, so the reader never silently mis-decodes a
96
+ // format it doesn't actually understand.
97
+ const ACCEPTED_VERSIONS = new Set(["1.2", "1.3"]);
98
+ if (!ACCEPTED_VERSIONS.has(parsed.version)) {
99
+ throw new Error(`deserializeCodex: unsupported version ${String(parsed.version)} — expected "1.2" or "1.3"`);
100
+ }
101
+ const KNOWN_TOP_LEVEL_FIELDS = new Set([
102
+ "version", "exportedAt", "kadenaWallets", "ouronetWallets", "addressBook", "uiSettings", "foreignKeys",
103
+ ]);
104
+ const unknownFields = Object.keys(parsed).filter(k => !KNOWN_TOP_LEVEL_FIELDS.has(k));
105
+ if (unknownFields.length > 0) {
106
+ throw new CodexUnknownFieldError(`Codex envelope contains unknown top-level field(s): ${unknownFields.join(", ")}`);
107
+ }
108
+ if (!Array.isArray(parsed.kadenaWallets)) {
109
+ throw new Error("deserializeCodex: kadenaWallets must be an array");
110
+ }
111
+ if (!Array.isArray(parsed.ouronetWallets)) {
112
+ throw new Error("deserializeCodex: ouronetWallets must be an array");
113
+ }
114
+ if (!Array.isArray(parsed.addressBook)) {
115
+ throw new Error("deserializeCodex: addressBook must be an array");
116
+ }
117
+ if (typeof parsed.uiSettings !== "object" ||
118
+ parsed.uiSettings === null ||
119
+ Array.isArray(parsed.uiSettings)) {
120
+ throw new Error("deserializeCodex: uiSettings must be an object");
121
+ }
122
+ return parsed;
123
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Typed errors for codex validation. Covers strict-shape enforcement on
3
+ * deserialized codex payloads and seed-type migration input validation.
4
+ *
5
+ * Both classes follow the ES2022 Error.cause pattern mirroring WrongPasswordError
6
+ * in stoa-core/src/crypto/errors.ts. `this.name` is set explicitly so
7
+ * error-name-based branching works regardless of bundler minification.
8
+ */
9
+ export declare class CodexUnknownFieldError extends Error {
10
+ constructor(message?: string, options?: ErrorOptions);
11
+ }
12
+ export declare class UnknownSeedTypeError extends Error {
13
+ constructor(message?: string, options?: ErrorOptions);
14
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Typed errors for codex validation. Covers strict-shape enforcement on
3
+ * deserialized codex payloads and seed-type migration input validation.
4
+ *
5
+ * Both classes follow the ES2022 Error.cause pattern mirroring WrongPasswordError
6
+ * in stoa-core/src/crypto/errors.ts. `this.name` is set explicitly so
7
+ * error-name-based branching works regardless of bundler minification.
8
+ */
9
+ export class CodexUnknownFieldError extends Error {
10
+ constructor(message, options) {
11
+ super(message, options);
12
+ this.name = "CodexUnknownFieldError";
13
+ }
14
+ }
15
+ export class UnknownSeedTypeError extends Error {
16
+ constructor(message, options) {
17
+ super(message, options);
18
+ this.name = "UnknownSeedTypeError";
19
+ }
20
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @ouronet/ouronet-core/codex — portable Codex types + serialization
3
+ * codec + seed-type migration.
4
+ *
5
+ * Three small pieces that every codex consumer (OuronetUI, future HUB,
6
+ * any CLI/recovery tool) needs:
7
+ *
8
+ * - `PlaintextCodex<...>` — generic in-memory shape. Consumer plugs
9
+ * its own wallet/account/keypair types via the type params.
10
+ * - `CodexExportV1_2` / `CodexExportV1_3` + `serializeCodex` /
11
+ * `deserializeCodex` / `buildCodexExport` — the backup-JSON codec.
12
+ * The writer now stamps `"1.3"`; the reader accepts both `"1.2"` and
13
+ * `"1.3"` (reader-before-writer discipline — see codec.ts JSDoc).
14
+ * - `SeedType` + `migrateSeedType` — the legacy↔canonical name
15
+ * mapping, idempotent. Was inlined in OuronetUI's WalletStorage
16
+ * before; lives here now so HUB doesn't have to rediscover it.
17
+ *
18
+ * Intentionally does NOT handle encryption. Each entry's `secret` field
19
+ * inside a codex is already an encrypted blob at rest; serializing /
20
+ * deserializing the codex doesn't touch those. For encryption see
21
+ * `@ouronet/ouronet-core/crypto`.
22
+ */
23
+ export type { PlaintextCodex, CodexExportV1_2, CodexExportV1_3, CodexForeignKeyV1_3, CodexForeignKeysBlockV1_3, } from "./types.js";
24
+ export { buildCodexExport, serializeCodex, deserializeCodex, } from "./codec.js";
25
+ export type { SeedType, RawSeedType } from "./seedTypeMigration.js";
26
+ export { migrateSeedType } from "./seedTypeMigration.js";
27
+ export { CodexUnknownFieldError, UnknownSeedTypeError } from "./errors.js";
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @ouronet/ouronet-core/codex — portable Codex types + serialization
3
+ * codec + seed-type migration.
4
+ *
5
+ * Three small pieces that every codex consumer (OuronetUI, future HUB,
6
+ * any CLI/recovery tool) needs:
7
+ *
8
+ * - `PlaintextCodex<...>` — generic in-memory shape. Consumer plugs
9
+ * its own wallet/account/keypair types via the type params.
10
+ * - `CodexExportV1_2` / `CodexExportV1_3` + `serializeCodex` /
11
+ * `deserializeCodex` / `buildCodexExport` — the backup-JSON codec.
12
+ * The writer now stamps `"1.3"`; the reader accepts both `"1.2"` and
13
+ * `"1.3"` (reader-before-writer discipline — see codec.ts JSDoc).
14
+ * - `SeedType` + `migrateSeedType` — the legacy↔canonical name
15
+ * mapping, idempotent. Was inlined in OuronetUI's WalletStorage
16
+ * before; lives here now so HUB doesn't have to rediscover it.
17
+ *
18
+ * Intentionally does NOT handle encryption. Each entry's `secret` field
19
+ * inside a codex is already an encrypted blob at rest; serializing /
20
+ * deserializing the codex doesn't touch those. For encryption see
21
+ * `@ouronet/ouronet-core/crypto`.
22
+ */
23
+ export { buildCodexExport, serializeCodex, deserializeCodex, } from "./codec.js";
24
+ export { migrateSeedType } from "./seedTypeMigration.js";
25
+ export { CodexUnknownFieldError, UnknownSeedTypeError } from "./errors.js";
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Seed-type migration — the naming layer between historical codex blobs
3
+ * and the current canonical names.
4
+ *
5
+ * Background. Early OuronetUI wallets were written with `seedType: "legacy"`
6
+ * (Chainweaver-derived WASM path) and `seedType: "new"` (Koala HD-wallet
7
+ * nacl path). When ecko-wallet landed the third variant got a clean name
8
+ * ("eckowallet"), but the existing "legacy" / "new" strings stayed live in
9
+ * users' localStorage. Rather than break those codexes we migrate on load:
10
+ * `legacy → chainweaver`, `new → koala`, everything else passes through.
11
+ *
12
+ * Canonical seed types are `"koala" | "chainweaver" | "eckowallet"`. The
13
+ * migration is idempotent — applying it twice yields the same result.
14
+ *
15
+ * Moved out of OuronetUI's WalletStorage in Phase 4. It had no business
16
+ * being there; it's a pure string-to-string mapping that every codex
17
+ * consumer (UI + future HUB) needs.
18
+ */
19
+ import type { SeedType } from "@stoachain/stoa-core/wallet";
20
+ export type { SeedType } from "@stoachain/stoa-core/wallet";
21
+ /** The string you might find in a raw codex blob — includes legacy names. */
22
+ export type RawSeedType = SeedType | "legacy" | "new" | string;
23
+ /**
24
+ * Migrate a raw seed-type string from a v1.x codex into a canonical SeedType.
25
+ *
26
+ * Throws `UnknownSeedTypeError` if the input is not in the recognized migration
27
+ * map — strict-by-default contract per REQ-12 (F-BUG-010, v4.1.1). Replaces the
28
+ * pre-v4.1.1 silent `|| "koala"` fallback that could route unknown seed types
29
+ * through koala derivation, masking codex-import drift.
30
+ *
31
+ * @param rawType - The seed-type string from the v1.x codex envelope
32
+ * @returns Canonical SeedType ("koala" | "chainweaver" | "eckowallet")
33
+ * @throws UnknownSeedTypeError when rawType is not in SEED_TYPE_MIGRATION
34
+ */
35
+ export declare function migrateSeedType(rawType: string): SeedType;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Seed-type migration — the naming layer between historical codex blobs
3
+ * and the current canonical names.
4
+ *
5
+ * Background. Early OuronetUI wallets were written with `seedType: "legacy"`
6
+ * (Chainweaver-derived WASM path) and `seedType: "new"` (Koala HD-wallet
7
+ * nacl path). When ecko-wallet landed the third variant got a clean name
8
+ * ("eckowallet"), but the existing "legacy" / "new" strings stayed live in
9
+ * users' localStorage. Rather than break those codexes we migrate on load:
10
+ * `legacy → chainweaver`, `new → koala`, everything else passes through.
11
+ *
12
+ * Canonical seed types are `"koala" | "chainweaver" | "eckowallet"`. The
13
+ * migration is idempotent — applying it twice yields the same result.
14
+ *
15
+ * Moved out of OuronetUI's WalletStorage in Phase 4. It had no business
16
+ * being there; it's a pure string-to-string mapping that every codex
17
+ * consumer (UI + future HUB) needs.
18
+ */
19
+ import { UnknownSeedTypeError } from "./errors.js";
20
+ const SEED_TYPE_MIGRATION = {
21
+ "legacy": "chainweaver",
22
+ "new": "koala",
23
+ "chainweaver": "chainweaver",
24
+ "koala": "koala",
25
+ "eckowallet": "eckowallet",
26
+ };
27
+ /**
28
+ * Migrate a raw seed-type string from a v1.x codex into a canonical SeedType.
29
+ *
30
+ * Throws `UnknownSeedTypeError` if the input is not in the recognized migration
31
+ * map — strict-by-default contract per REQ-12 (F-BUG-010, v4.1.1). Replaces the
32
+ * pre-v4.1.1 silent `|| "koala"` fallback that could route unknown seed types
33
+ * through koala derivation, masking codex-import drift.
34
+ *
35
+ * @param rawType - The seed-type string from the v1.x codex envelope
36
+ * @returns Canonical SeedType ("koala" | "chainweaver" | "eckowallet")
37
+ * @throws UnknownSeedTypeError when rawType is not in SEED_TYPE_MIGRATION
38
+ */
39
+ export function migrateSeedType(rawType) {
40
+ const result = SEED_TYPE_MIGRATION[rawType];
41
+ if (result === undefined) {
42
+ throw new UnknownSeedTypeError(`Unknown seed type: "${rawType}". Expected one of: ${Object.keys(SEED_TYPE_MIGRATION).join(", ")}`);
43
+ }
44
+ return result;
45
+ }
@@ -0,0 +1,100 @@
1
+ /**
2
+ * PlaintextCodex — the portable shape of an Ouronet user's in-memory
3
+ * codex state. Consumers decide the concrete element types for each list
4
+ * via generics (OuronetUI plugs in its IKadenaSeed / IOuroAccount / etc;
5
+ * the future HUB can supply its own if it prefers, or reuse UI's via a
6
+ * shared `@ouronet/shared-types` package later).
7
+ *
8
+ * Why generic? Because the codec (serialize / deserialize) and any other
9
+ * core-side consumer only cares about the SHAPE — "there are N wallets,
10
+ * M accounts, K pure keypairs, an address book, and some ui settings".
11
+ * The field contents are consumer-defined. Generics let the type carry
12
+ * information without forcing core to own every wallet-domain type.
13
+ *
14
+ * Default type params are `unknown` so downstream code that doesn't need
15
+ * field-level types still works — `PlaintextCodex` with no args treats
16
+ * each list as `unknown[]`, which TypeScript allows assignment TO but
17
+ * nothing structured FROM (exactly right for a generic serializer).
18
+ */
19
+ export interface PlaintextCodex<KadenaSeed = unknown, OuroAccount = unknown, PureKeypair = unknown, AddressBookEntry = unknown, UiSettings = unknown> {
20
+ /** HD seeds (koala / chainweaver / eckowallet variants) known to this codex. */
21
+ readonly kadenaWallets: KadenaSeed[];
22
+ /** Resident OURO accounts the user controls. */
23
+ readonly ouronetWallets: OuroAccount[];
24
+ /** Address-book entries (cached or user-added). */
25
+ readonly addressBook: AddressBookEntry[];
26
+ /** Raw pure Pact keypairs stored directly (encrypted privateKey). */
27
+ readonly pureKeypairs: PureKeypair[];
28
+ /** Non-sensitive UI preferences (dock position, zone state, etc). */
29
+ readonly uiSettings: UiSettings;
30
+ /**
31
+ * Schema version of this codex. `0` = pre-upgrade V1-encrypted; `1+` =
32
+ * post-upgrade V2-encrypted. Consumers can read this to decide whether
33
+ * to run the encryption upgrade on unlock.
34
+ */
35
+ readonly schemaVersion: number;
36
+ /** ISO timestamp of the last write to this codex (across any device). */
37
+ readonly lastUpdatedAt: string | null;
38
+ /** Which device family last wrote — used for dev/main cross-sync UX. */
39
+ readonly lastUpdatedDevice: "dev" | "main";
40
+ }
41
+ /**
42
+ * The exported-backup JSON shape (`version: "1.2"` — the historical string
43
+ * that OuronetUI has written since well before the extraction began).
44
+ *
45
+ * A codex backup is a subset of PlaintextCodex: no schemaVersion /
46
+ * lastUpdatedAt / lastUpdatedDevice (those are device-local), and no
47
+ * pureKeypairs in this historical shape (they ship inside `cloud-backup`
48
+ * alongside user settings — see the `downloadAsJson` → `exportForCloud`
49
+ * split in OuronetUI's LocalStorageCodexAdapter). The `"1.2"` label
50
+ * stays because a bump would break every existing user's recovery file.
51
+ */
52
+ export interface CodexExportV1_2<KadenaSeed = unknown, OuroAccount = unknown, AddressBookEntry = unknown, UiSettings = unknown> {
53
+ readonly version: "1.2";
54
+ readonly exportedAt: string;
55
+ readonly kadenaWallets: KadenaSeed[];
56
+ readonly ouronetWallets: OuroAccount[];
57
+ readonly addressBook: AddressBookEntry[];
58
+ readonly uiSettings: UiSettings;
59
+ }
60
+ /**
61
+ * A single foreign (cross-chain) key entry inside a `foreignKeys` block. The
62
+ * `encryptedKeyfile` is already-encrypted at rest — this envelope only carries
63
+ * the ciphertext, never a plaintext key.
64
+ *
65
+ * This mirrors the codex-core (`@ancientpantheon`) V1_3 foreign-key shape by
66
+ * VALUE, not by import: the two orgs share no dependency edge, so the shape is
67
+ * an intentionally-duplicated peer kept structurally identical by hand.
68
+ */
69
+ export interface CodexForeignKeyV1_3 {
70
+ readonly id: string;
71
+ readonly label?: string;
72
+ readonly chainId: string;
73
+ readonly encryptedKeyfile: string;
74
+ }
75
+ /** The optional `foreignKeys` block on a 1.3 envelope. */
76
+ export interface CodexForeignKeysBlockV1_3 {
77
+ readonly schemaVersion: 1;
78
+ readonly keys: readonly CodexForeignKeyV1_3[];
79
+ }
80
+ /**
81
+ * The exported-backup JSON shape at `version: "1.3"`. Structurally identical to
82
+ * `CodexExportV1_2` except for the version literal and an OPTIONAL `foreignKeys`
83
+ * block. The bump was made under reader-before-writer discipline: the reader
84
+ * (`deserializeCodex`) was widened to accept "1.3" and to allow-list the
85
+ * `foreignKeys` field BEFORE the writer began stamping "1.3".
86
+ *
87
+ * ouronet's `PlaintextCodex` has no foreign-key source field, so the live
88
+ * writer emits `foreignKeys`-ABSENT (a bare 1.3 envelope). The block is typed
89
+ * as optional so the writer can emit it if a source is ever wired up, without a
90
+ * mandatory empty-block lie on every export.
91
+ */
92
+ export interface CodexExportV1_3<KadenaSeed = unknown, OuroAccount = unknown, AddressBookEntry = unknown, UiSettings = unknown> {
93
+ readonly version: "1.3";
94
+ readonly exportedAt: string;
95
+ readonly kadenaWallets: KadenaSeed[];
96
+ readonly ouronetWallets: OuroAccount[];
97
+ readonly addressBook: AddressBookEntry[];
98
+ readonly uiSettings: UiSettings;
99
+ readonly foreignKeys?: CodexForeignKeysBlockV1_3;
100
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * PlaintextCodex — the portable shape of an Ouronet user's in-memory
3
+ * codex state. Consumers decide the concrete element types for each list
4
+ * via generics (OuronetUI plugs in its IKadenaSeed / IOuroAccount / etc;
5
+ * the future HUB can supply its own if it prefers, or reuse UI's via a
6
+ * shared `@ouronet/shared-types` package later).
7
+ *
8
+ * Why generic? Because the codec (serialize / deserialize) and any other
9
+ * core-side consumer only cares about the SHAPE — "there are N wallets,
10
+ * M accounts, K pure keypairs, an address book, and some ui settings".
11
+ * The field contents are consumer-defined. Generics let the type carry
12
+ * information without forcing core to own every wallet-domain type.
13
+ *
14
+ * Default type params are `unknown` so downstream code that doesn't need
15
+ * field-level types still works — `PlaintextCodex` with no args treats
16
+ * each list as `unknown[]`, which TypeScript allows assignment TO but
17
+ * nothing structured FROM (exactly right for a generic serializer).
18
+ */
19
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from "./ouronet.js";
2
+ export * from "./tokenIds.js";
@@ -0,0 +1,3 @@
1
+ // @ouronet/ouronet-core/constants
2
+ export * from "./ouronet.js";
3
+ export * from "./tokenIds.js";
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Ouronet-specific protocol constants — the `ouronet-ns` Pact namespace,
3
+ * the protocol-level autonomic accounts, the canonical token list.
4
+ *
5
+ * Lives in `@ouronet/ouronet-core/constants`. Pulled in by every
6
+ * `interactions/*` file that constructs `${KADENA_NAMESPACE}.<module>.*`
7
+ * Pact code, plus by the cfmBuilders Pact-code string assembler.
8
+ *
9
+ * Chain-generic constants (`KADENA_NETWORK`, `KADENA_CHAIN_ID`,
10
+ * `getPactUrl`, `getSpvUrl`, `STOA_CHAIN_COUNT`, `STOA_CHAINS`,
11
+ * `KADENA_CHAINS`) live in `@stoachain/stoa-core/constants` — they're
12
+ * re-exported here for backwards-compatibility with internal imports
13
+ * from `../constants` and pre-v4 consumer imports from
14
+ * `@ouronet/ouronet-core/constants`. Public-API consumers SHOULD
15
+ * import them from `@stoachain/stoa-core/constants` directly to make
16
+ * the chain-generic vs Ouronet-specific boundary explicit.
17
+ */
18
+ export { KADENA_NETWORK, KADENA_CHAIN_ID, STOA_CHAIN_COUNT, STOA_CHAINS, KADENA_CHAINS, getPactUrl, getSpvUrl, } from "@stoachain/stoa-core/constants";
19
+ /**
20
+ * The Pact module namespace prefix for every Ouronet smart contract.
21
+ * Every interaction file builds Pact code as `${KADENA_NAMESPACE}.<module>.*`.
22
+ */
23
+ export declare const KADENA_NAMESPACE = "ouronet-ns";
24
+ /** Ouroboros protocol account (staking/rewards engine) */
25
+ export declare const STOA_AUTONOMIC_OUROBOROS = "c:XM-pkmuB5XUQlp87ZYSbfKt8qzmHY6O2EHAzMRVBt3k";
26
+ /** LiquidPot account (native STOA vault — source of unwrapped tokens) */
27
+ export declare const STOA_AUTONOMIC_LIQUIDPOT = "c:ZNfuj3iZI83n7MUSKGuoXoSxFg1cyMxCzB3szUHVvrI";
28
+ /** Ouronet Gas Station (pays Kadena gas fees for all transactions) */
29
+ export declare const STOA_AUTONOMIC_OURONETGASSTATION = "c:iQQFWj6gWtpGEzhM_O5ekW1QtnQQy55R8BRPGhj_0FU";
30
+ export declare const MAIN_TOKENS: {
31
+ id: string;
32
+ name: string;
33
+ }[];
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Ouronet-specific protocol constants — the `ouronet-ns` Pact namespace,
3
+ * the protocol-level autonomic accounts, the canonical token list.
4
+ *
5
+ * Lives in `@ouronet/ouronet-core/constants`. Pulled in by every
6
+ * `interactions/*` file that constructs `${KADENA_NAMESPACE}.<module>.*`
7
+ * Pact code, plus by the cfmBuilders Pact-code string assembler.
8
+ *
9
+ * Chain-generic constants (`KADENA_NETWORK`, `KADENA_CHAIN_ID`,
10
+ * `getPactUrl`, `getSpvUrl`, `STOA_CHAIN_COUNT`, `STOA_CHAINS`,
11
+ * `KADENA_CHAINS`) live in `@stoachain/stoa-core/constants` — they're
12
+ * re-exported here for backwards-compatibility with internal imports
13
+ * from `../constants` and pre-v4 consumer imports from
14
+ * `@ouronet/ouronet-core/constants`. Public-API consumers SHOULD
15
+ * import them from `@stoachain/stoa-core/constants` directly to make
16
+ * the chain-generic vs Ouronet-specific boundary explicit.
17
+ */
18
+ // Chain-generic re-exports (canonical home: @stoachain/stoa-core/constants)
19
+ export { KADENA_NETWORK, KADENA_CHAIN_ID, STOA_CHAIN_COUNT, STOA_CHAINS, KADENA_CHAINS, getPactUrl, getSpvUrl, } from "@stoachain/stoa-core/constants";
20
+ /**
21
+ * The Pact module namespace prefix for every Ouronet smart contract.
22
+ * Every interaction file builds Pact code as `${KADENA_NAMESPACE}.<module>.*`.
23
+ */
24
+ export const KADENA_NAMESPACE = "ouronet-ns";
25
+ // ─── Stoa Autonomic Accounts ───────────────────────────────────────────────
26
+ // Canonical names for all protocol-level Stoa accounts.
27
+ // Always reference these — never hardcode the address strings directly.
28
+ /** Ouroboros protocol account (staking/rewards engine) */
29
+ export const STOA_AUTONOMIC_OUROBOROS = "c:XM-pkmuB5XUQlp87ZYSbfKt8qzmHY6O2EHAzMRVBt3k";
30
+ /** LiquidPot account (native STOA vault — source of unwrapped tokens) */
31
+ export const STOA_AUTONOMIC_LIQUIDPOT = "c:ZNfuj3iZI83n7MUSKGuoXoSxFg1cyMxCzB3szUHVvrI";
32
+ /** Ouronet Gas Station (pays Kadena gas fees for all transactions) */
33
+ export const STOA_AUTONOMIC_OURONETGASSTATION = "c:iQQFWj6gWtpGEzhM_O5ekW1QtnQQy55R8BRPGhj_0FU";
34
+ // v4.0.0: removed deprecated aliases.
35
+ // - `KADENA_BASE_URL` and `PACT_URL` (pinned to node2; use the failover
36
+ // accessors `getPactUrl(chainId)` / `getSpvUrl(chainId)` from
37
+ // `@stoachain/stoa-core/constants` instead — they delegate to the
38
+ // v2.1.0 failover layer)
39
+ // - `GAS_STATION` and `NATIVE_TOKEN_VAULT` (use the canonical
40
+ // `STOA_AUTONOMIC_*` names above directly).
41
+ export const MAIN_TOKENS = [
42
+ { id: "AURYN-8Nh-JO8JO4F5", name: "AURYN" },
43
+ {
44
+ id: "ELITEAURYN-8Nh-JO8JO4F5",
45
+ name: "ELITEAURYN",
46
+ },
47
+ {
48
+ id: "SSTOA-8Nh-JO8JO4F5",
49
+ name: "SSTOA",
50
+ },
51
+ {
52
+ id: "OURO-8Nh-JO8JO4F5",
53
+ name: "OURO",
54
+ },
55
+ {
56
+ id: "VST-8Nh-JO8JO4F5",
57
+ name: "VST",
58
+ },
59
+ ];
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Ouronet DPTF token IDs — global constants.
3
+ * All share the same suffix: -8Nh-JO8JO4F5
4
+ */
5
+ export declare const TOKEN_ID_OURO = "OURO-8Nh-JO8JO4F5";
6
+ export declare const TOKEN_ID_IGNIS = "GAS-8Nh-JO8JO4F5";
7
+ export declare const TOKEN_ID_AURYN = "AURYN-8Nh-JO8JO4F5";
8
+ export declare const TOKEN_ID_ELITEAURYN = "ELITEAURYN-8Nh-JO8JO4F5";
9
+ export declare const TOKEN_ID_WSTOA = "WSTOA-8Nh-JO8JO4F5";
10
+ export declare const TOKEN_ID_SSTOA = "SSTOA-8Nh-JO8JO4F5";
11
+ export declare const TOKEN_ID_GSTOA = "GSTOA-8Nh-JO8JO4F5";
12
+ /** Ordered array — same order as primordials tokens[] */
13
+ export declare const ALL_TOKEN_IDS: readonly ["OURO-8Nh-JO8JO4F5", "GAS-8Nh-JO8JO4F5", "AURYN-8Nh-JO8JO4F5", "ELITEAURYN-8Nh-JO8JO4F5", "WSTOA-8Nh-JO8JO4F5", "SSTOA-8Nh-JO8JO4F5", "GSTOA-8Nh-JO8JO4F5"];
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Ouronet DPTF token IDs — global constants.
3
+ * All share the same suffix: -8Nh-JO8JO4F5
4
+ */
5
+ export const TOKEN_ID_OURO = "OURO-8Nh-JO8JO4F5";
6
+ export const TOKEN_ID_IGNIS = "GAS-8Nh-JO8JO4F5";
7
+ export const TOKEN_ID_AURYN = "AURYN-8Nh-JO8JO4F5";
8
+ export const TOKEN_ID_ELITEAURYN = "ELITEAURYN-8Nh-JO8JO4F5";
9
+ export const TOKEN_ID_WSTOA = "WSTOA-8Nh-JO8JO4F5";
10
+ export const TOKEN_ID_SSTOA = "SSTOA-8Nh-JO8JO4F5";
11
+ export const TOKEN_ID_GSTOA = "GSTOA-8Nh-JO8JO4F5";
12
+ /** Ordered array — same order as primordials tokens[] */
13
+ export const ALL_TOKEN_IDS = [
14
+ TOKEN_ID_OURO,
15
+ TOKEN_ID_IGNIS,
16
+ TOKEN_ID_AURYN,
17
+ TOKEN_ID_ELITEAURYN,
18
+ TOKEN_ID_WSTOA,
19
+ TOKEN_ID_SSTOA,
20
+ TOKEN_ID_GSTOA,
21
+ ];
@@ -0,0 +1,18 @@
1
+ /**
2
+ * `@ouronet/ouronet-core` — Ouronet protocol business logic on top of
3
+ * `@stoachain/stoa-core`.
4
+ *
5
+ * This root entry is intentionally near-empty. Consumers MUST reach
6
+ * the domain layers through subpath exports, which the package.json
7
+ * `exports` field enumerates:
8
+ *
9
+ * import { ... } from "@ouronet/ouronet-core/codex";
10
+ * import { ... } from "@ouronet/ouronet-core/interactions";
11
+ * import { COIL_CONFIGS } from "@ouronet/ouronet-core/interactions/coilFunctions";
12
+ * // ... etc.
13
+ *
14
+ * Chain-generic infrastructure (signing, wallet, crypto, network, gas,
15
+ * guard, reads, observability, dalos, errors) lives in
16
+ * `@stoachain/stoa-core` and is consumed via its subpaths.
17
+ */
18
+ export {};