@ouronet/talos-registry 1.3.0 → 2.0.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 +2 -2
- package/TOOLTIP-CANON.md +63 -15
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/tooltip.d.ts +51 -10
- package/dist/tooltip.js +89 -35
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -178,10 +178,10 @@ import { tooltipModel, signatureRows } from "@ouronet/talos-registry";
|
|
|
178
178
|
const m = tooltipModel("TS01-C1.DPTF|C_Transfer", { id: '"OURO-8Nh-JO8JO4F5"' });
|
|
179
179
|
// m.slots -> EVERY execution parameter, in order, with type, value and flags
|
|
180
180
|
// m.preview -> the INFO_ call with ITS OWN parameter list
|
|
181
|
-
// m.kind -> "ouronet" | "
|
|
181
|
+
// m.kind -> "ouronet" | "stoa" | "kadena" (only ouronet has a cost section)
|
|
182
182
|
```
|
|
183
183
|
|
|
184
|
-
|
|
184
|
+
Seven rules, each there because it was got wrong first — most recently a six-parameter transfer
|
|
185
185
|
whose tooltip showed five arguments, because it was rendering the preview's list under the
|
|
186
186
|
execution's heading. Read the canon before building one.
|
|
187
187
|
|
package/TOOLTIP-CANON.md
CHANGED
|
@@ -21,6 +21,19 @@ This file explains **why** each rule exists. Every one is here because it was go
|
|
|
21
21
|
|
|
22
22
|
---
|
|
23
23
|
|
|
24
|
+
## Rule 0 — this tooltip is for CHAINWEB calls only
|
|
25
|
+
|
|
26
|
+
It describes a **Pact call on a Chainweb chain**: what function, what arguments, what it costs. A
|
|
27
|
+
button that transacts on **Arweave**, or any other non-Chainweb chain, has none of those things in
|
|
28
|
+
this shape.
|
|
29
|
+
|
|
30
|
+
**Such a button gets no tooltip of this kind — not an empty one.** An empty panel reads as "the
|
|
31
|
+
price failed to load"; absence reads as "this is a different kind of thing", which is the truth.
|
|
32
|
+
If you want an affordance there, write a different one; do not stretch this model over it.
|
|
33
|
+
|
|
34
|
+
`chainOf(key)` returns `undefined` for anything this model cannot describe, and `tooltipModels()`
|
|
35
|
+
drops such keys rather than throwing. That is how a caller learns to render nothing.
|
|
36
|
+
|
|
24
37
|
## Rule 1 — show every execution parameter
|
|
25
38
|
|
|
26
39
|
All of them, always, in declared order.
|
|
@@ -74,19 +87,37 @@ already the widest thing on screen when it opens. A parallel row costs one line.
|
|
|
74
87
|
|
|
75
88
|
`signatureRows(m)` returns `{ names, types }` as equal-length arrays for exactly this.
|
|
76
89
|
|
|
77
|
-
## Rule 4 —
|
|
90
|
+
## Rule 4 — three worlds, and they must be distinguishable
|
|
91
|
+
|
|
92
|
+
`kind` is `"ouronet"`, `"stoa"` or `"kadena"`. Only the first is in this registry; the other two
|
|
93
|
+
are transcribed by hand in `STOA_SIGNATURES` and `KADENA_SIGNATURES`.
|
|
94
|
+
|
|
95
|
+
| | `ouronet` | `stoa` | `kadena` |
|
|
96
|
+
|---|---|---|---|
|
|
97
|
+
| what it is | the `ouronet-ns` surface | StoaChain's own `coin` | **Kadena mainnet's `coin`** |
|
|
98
|
+
| INFO_ preview | yes | **no** | **no** |
|
|
99
|
+
| IGNIS | collected | **none** | **none** |
|
|
100
|
+
| accounts | Ouronet glyph strings | `k:` `c:` `u:` `w:` | `k:` principals |
|
|
101
|
+
| gas | station pays | **station pays** | **a different chain's gas entirely** |
|
|
78
102
|
|
|
79
|
-
|
|
80
|
-
|
|
103
|
+
**`kadena` is not a variant of the other two.** Different chain, different gas, different balances;
|
|
104
|
+
nothing about Ouronet's gas station or IGNIS applies to it. Getting this wrong is worse than the
|
|
105
|
+
other confusions on this page, because a user who thinks a Kadena transfer is sponsored is wrong
|
|
106
|
+
about their own money.
|
|
81
107
|
|
|
82
|
-
|
|
108
|
+
**Both chains call their contract `coin`.** StoaChain uses Ouronet-style names (`C_Transfer`,
|
|
109
|
+
`C_URV|Stake`); Kadena uses KIP-0002 kebab-case (`transfer`, `transfer-create`). Nothing collides
|
|
110
|
+
today, and `chainOf` **throws** rather than guesses if anything ever does — picking wrong would
|
|
111
|
+
describe a call on the wrong chain, which is the kind of wrong that looks right.
|
|
83
112
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
113
|
+
Note `coin.transfer-crosschain` is a **`defpact`** — a multi-step continuation. Worth saying out
|
|
114
|
+
loud in a renderer: its later steps are not sponsored by anybody.
|
|
115
|
+
|
|
116
|
+
**The sponsorship row is the one to get right.** An earlier version of this claimed a StoaChain
|
|
117
|
+
native call was not sponsored and that the signing account paid its own gas. Both false: every
|
|
118
|
+
native modal carries `GAS_PAYER` on the gas-station key and says so in its own header comment. The
|
|
119
|
+
claim had been *inferred* from "this is not an Ouronet operation", which says nothing about who
|
|
120
|
+
pays the host chain — and it was wrong in the direction that matters.
|
|
90
121
|
|
|
91
122
|
**That last row is the one to get right.** An earlier version of this claimed a native call was
|
|
92
123
|
not sponsored and that the signing account paid its own STOA gas. Both false: every native modal
|
|
@@ -95,9 +126,21 @@ header comment. The claim had been *inferred* from "this is not an Ouronet opera
|
|
|
95
126
|
nothing about who pays the host chain — and it was wrong in the direction that matters, telling a
|
|
96
127
|
user they were about to spend when they were not.
|
|
97
128
|
|
|
98
|
-
**
|
|
99
|
-
|
|
100
|
-
|
|
129
|
+
**Make the two visually distinct — the palette is yours.** The distinction is mandatory because
|
|
130
|
+
the two differ in what they cost and what can be previewed; the specific colour is presentation,
|
|
131
|
+
and this package does not get a vote on your design language. A rule that mandates a palette in
|
|
132
|
+
someone else's application is a rule that gets ignored, and an ignored rule weakens the ones that
|
|
133
|
+
matter.
|
|
134
|
+
|
|
135
|
+
In practice:
|
|
136
|
+
|
|
137
|
+
| | `stoa` | `ouronet` | `kadena` |
|
|
138
|
+
|---|---|---|---|
|
|
139
|
+
| OuronetUI | gold `#ceac5f` | blue `#3b82f6` | *(not surfaced)* |
|
|
140
|
+
| Codex | *its own* | violet | **green** |
|
|
141
|
+
|
|
142
|
+
Whatever you choose, make it carry meaning rather than decoration, and **say what is missing**
|
|
143
|
+
rather than leaving the cost panel empty — an empty panel reads as "the price failed to load".
|
|
101
144
|
|
|
102
145
|
Suggested footer, which is what OuronetUI ships:
|
|
103
146
|
|
|
@@ -106,8 +149,13 @@ no IGNIS — this is not an Ouronet operation
|
|
|
106
149
|
a StoaChain `coin` call, so nothing prices it. Gas is still sponsored.
|
|
107
150
|
```
|
|
108
151
|
|
|
109
|
-
Signatures
|
|
110
|
-
|
|
152
|
+
Signatures are in `STOA_SIGNATURES` and `KADENA_SIGNATURES`, transcribed from the deployed
|
|
153
|
+
contracts with line numbers. Use them rather than typing your own.
|
|
154
|
+
|
|
155
|
+
**Make the distinction run in every direction.** We coloured `stoa` gold and left `ouronet` on the
|
|
156
|
+
panel's ordinary grey — so the distinction existed one way only, and a reader who never hovered a
|
|
157
|
+
native button learned no rule at all. Gold then reads as "something is odd about this one" rather
|
|
158
|
+
than as a category. Give every kind a colour and a label, not just the exceptional ones.
|
|
111
159
|
|
|
112
160
|
## Rule 5 — a ghost is not data
|
|
113
161
|
|
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,6 @@ export type { CallPlan } from "./plan.js";
|
|
|
16
16
|
export { parseCapability, parseCapabilities, capabilityRecipe } from "./caps.js";
|
|
17
17
|
export type { ParsedCapability, CapabilityRecipe } from "./caps.js";
|
|
18
18
|
export { formatForType, formatDecimal, formatInteger, formatString, formatBool } from "./format.js";
|
|
19
|
-
export { tooltipModel, tooltipModels, signatureRows, isNativeKey, isPlaceholder, PLACEHOLDER, NATIVE_SIGNATURES } from "./tooltip.js";
|
|
19
|
+
export { tooltipModel, tooltipModels, signatureRows, chainOf, isOffRegistryKey, isNativeKey, isPlaceholder, PLACEHOLDER, STOA_SIGNATURES, KADENA_SIGNATURES, NATIVE_SIGNATURES } from "./tooltip.js";
|
|
20
20
|
export type { TooltipModel, TooltipSlot, TooltipPreview } from "./tooltip.js";
|
|
21
21
|
export type * from "./types.js";
|
package/dist/index.js
CHANGED
|
@@ -15,4 +15,4 @@ export { parseCapability, parseCapabilities, capabilityRecipe } from "./caps.js"
|
|
|
15
15
|
export { formatForType, formatDecimal, formatInteger, formatString, formatBool } from "./format.js";
|
|
16
16
|
// THE TOOLTIP CANON. Shared implementation rather than a shared document -- see TOOLTIP-CANON.md
|
|
17
17
|
// for why each rule exists, and `tooltip.ts` for the rules themselves.
|
|
18
|
-
export { tooltipModel, tooltipModels, signatureRows, isNativeKey, isPlaceholder, PLACEHOLDER, NATIVE_SIGNATURES } from "./tooltip.js";
|
|
18
|
+
export { tooltipModel, tooltipModels, signatureRows, chainOf, isOffRegistryKey, isNativeKey, isPlaceholder, PLACEHOLDER, STOA_SIGNATURES, KADENA_SIGNATURES, NATIVE_SIGNATURES } from "./tooltip.js";
|
package/dist/tooltip.d.ts
CHANGED
|
@@ -25,8 +25,25 @@ export interface TooltipPreview {
|
|
|
25
25
|
call: string;
|
|
26
26
|
}
|
|
27
27
|
export interface TooltipModel {
|
|
28
|
-
/**
|
|
29
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Which world this call belongs to -- rule 4.
|
|
30
|
+
*
|
|
31
|
+
* ouronet the `ouronet-ns` surface. Priced by an INFO_ reader, collects IGNIS.
|
|
32
|
+
* stoa StoaChain's own root-namespace `coin`. No preview, no IGNIS, gas still sponsored.
|
|
33
|
+
* kadena Kadena mainnet's `coin`. A DIFFERENT CHAIN -- different gas, different accounts,
|
|
34
|
+
* and nothing about Ouronet applies to it.
|
|
35
|
+
*
|
|
36
|
+
* A renderer MUST make these visually distinct, because they differ in what they cost and what
|
|
37
|
+
* can be previewed. It is NOT told how: OuronetUI uses gold/blue, the Codex violet for Ouronet
|
|
38
|
+
* and green for Kadena, and all are conformant. Mandating a palette in a package consumed by
|
|
39
|
+
* applications with their own design languages is a rule that gets ignored, and an ignored rule
|
|
40
|
+
* weakens the ones that matter.
|
|
41
|
+
*
|
|
42
|
+
* RENAMED from `"native"` in 2.0.0. With only two worlds "native" was unambiguous; with three
|
|
43
|
+
* it silently invited the question "native to WHAT" -- and both candidate answers are a
|
|
44
|
+
* contract called `coin`.
|
|
45
|
+
*/
|
|
46
|
+
kind: "ouronet" | "stoa" | "kadena";
|
|
30
47
|
/** fully qualified execution, as it would be typed in a transaction. */
|
|
31
48
|
exec: string;
|
|
32
49
|
/** EVERY execution parameter, in declared order -- rule 1. */
|
|
@@ -46,18 +63,42 @@ export interface TooltipModel {
|
|
|
46
63
|
/** The registry's generic placeholder: an entity id for something that does not exist on chain. */
|
|
47
64
|
export declare const PLACEHOLDER = "\"example\"";
|
|
48
65
|
export declare const isPlaceholder: (rendered: string) => boolean;
|
|
49
|
-
/** A `coin.*` key is StoaChain's root-namespace contract -- outside this registry by design. */
|
|
50
|
-
export declare const isNativeKey: (key: string) => boolean;
|
|
51
66
|
/**
|
|
52
|
-
*
|
|
67
|
+
* Off-registry signatures, by chain.
|
|
53
68
|
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
69
|
+
* Neither chain's `coin` contract is in the generated registry -- that describes `ouronet-ns`
|
|
70
|
+
* only -- so these are transcribed by hand with their source lines. They live HERE rather than in
|
|
71
|
+
* each consumer so both applications render the same signatures instead of each keeping a copy.
|
|
57
72
|
*
|
|
58
|
-
*
|
|
73
|
+
* BOTH CHAINS CALL THEIR CONTRACT `coin`, which is the one real hazard in this table. StoaChain's
|
|
74
|
+
* uses Ouronet-style names (`C_Transfer`, `C_URV|Stake`); Kadena's uses KIP-0002 kebab-case
|
|
75
|
+
* (`transfer`, `transfer-create`). No key collides TODAY, and `chainOf` refuses rather than
|
|
76
|
+
* guesses if one ever does -- the same posture `resolveByName` takes for the four SWP names that
|
|
77
|
+
* resolve to two modules. Guessing wrong here would price a call on the wrong chain.
|
|
59
78
|
*/
|
|
60
|
-
|
|
79
|
+
/** StoaChain's root-namespace `coin`. source: 0_Stoa/coin-contract/coin-live.pact */
|
|
80
|
+
export declare const STOA_SIGNATURES: Readonly<Record<string, ReadonlyArray<[string, string]>>>;
|
|
81
|
+
/**
|
|
82
|
+
* Kadena mainnet's `coin`. source: 00_KadenaSandbox/kda-env/kadena/coin-v6.pact
|
|
83
|
+
*
|
|
84
|
+
* A DIFFERENT CHAIN. Different gas, different accounts, and nothing about Ouronet's gas station
|
|
85
|
+
* or IGNIS applies. `transfer-crosschain` is a `defpact` -- a multi-step continuation -- which a
|
|
86
|
+
* renderer may want to say out loud, because its later steps are not sponsored by anyone.
|
|
87
|
+
*/
|
|
88
|
+
export declare const KADENA_SIGNATURES: Readonly<Record<string, ReadonlyArray<[string, string]>>>;
|
|
89
|
+
/** Back-compat alias. `NATIVE_SIGNATURES` meant StoaChain's before Kadena joined the model. */
|
|
90
|
+
export declare const NATIVE_SIGNATURES: Readonly<Record<string, readonly [string, string][]>>;
|
|
91
|
+
/**
|
|
92
|
+
* Which chain a key belongs to, or `undefined` for a key this model does not describe.
|
|
93
|
+
*
|
|
94
|
+
* Refuses an AMBIGUOUS key rather than picking: both chains have a `coin`, and pricing a call on
|
|
95
|
+
* the wrong chain is the kind of wrong that looks right.
|
|
96
|
+
*/
|
|
97
|
+
export declare function chainOf(key: string): "ouronet" | "stoa" | "kadena" | undefined;
|
|
98
|
+
/** True for any key this model can describe at all. Arweave and friends answer false -- rule 0. */
|
|
99
|
+
export declare const isOffRegistryKey: (key: string) => boolean;
|
|
100
|
+
/** @deprecated use `chainOf(key) === "stoa"`. Kept so 1.x callers keep compiling. */
|
|
101
|
+
export declare const isNativeKey: (key: string) => boolean;
|
|
61
102
|
/**
|
|
62
103
|
* Everything a renderer needs for one entrypoint.
|
|
63
104
|
*
|
package/dist/tooltip.js
CHANGED
|
@@ -22,10 +22,18 @@
|
|
|
22
22
|
* 3. TYPES GO ON THEIR OWN ROW. `patron:string executor:string ...` doubles the width of the
|
|
23
23
|
* widest line in the panel. A parallel row under the names costs one line and reads better.
|
|
24
24
|
*
|
|
25
|
-
* 4.
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
25
|
+
* 4. THREE WORLDS, and they must be distinguishable at a glance. `ouronet` (the ouronet-ns
|
|
26
|
+
* surface), `stoa` (StoaChain's own `coin` contract) and `kadena` (Kadena mainnet's `coin`).
|
|
27
|
+
* They differ in what they cost and what can be previewed. Only `ouronet` has an INFO_ reader
|
|
28
|
+
* and collects IGNIS; gas is sponsored on the Stoa side regardless -- claiming otherwise tells
|
|
29
|
+
* a user they are about to spend when they are not. HOW you distinguish them is yours: `kind`
|
|
30
|
+
* is the canon, the palette is not.
|
|
31
|
+
*
|
|
32
|
+
* 0. CHAINWEB ONLY -- the rule that decides whether a tooltip exists at all. This model describes
|
|
33
|
+
* a PACT call on a Chainweb chain: what function, what arguments, what it costs. A button that
|
|
34
|
+
* transacts on Arweave, or any non-Chainweb chain, has none of those things in this shape and
|
|
35
|
+
* gets NO tooltip of this kind rather than an empty one. An empty panel reads as a failure to
|
|
36
|
+
* load; absence reads as "this is a different kind of thing", which is the truth.
|
|
29
37
|
*
|
|
30
38
|
* 5. A GHOST IS NOT DATA. An unresolved argument must LOOK unresolved, and a tooltip whose
|
|
31
39
|
* arguments are placeholders must not fire the preview read at all: the answer is a foregone
|
|
@@ -36,19 +44,21 @@ import { formatForType } from "./format.js";
|
|
|
36
44
|
/** The registry's generic placeholder: an entity id for something that does not exist on chain. */
|
|
37
45
|
export const PLACEHOLDER = '"example"';
|
|
38
46
|
export const isPlaceholder = (rendered) => rendered === PLACEHOLDER;
|
|
39
|
-
/** A `coin.*` key is StoaChain's root-namespace contract -- outside this registry by design. */
|
|
40
|
-
export const isNativeKey = (key) => key.startsWith("coin.");
|
|
41
47
|
/**
|
|
42
|
-
*
|
|
48
|
+
* Off-registry signatures, by chain.
|
|
43
49
|
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
50
|
+
* Neither chain's `coin` contract is in the generated registry -- that describes `ouronet-ns`
|
|
51
|
+
* only -- so these are transcribed by hand with their source lines. They live HERE rather than in
|
|
52
|
+
* each consumer so both applications render the same signatures instead of each keeping a copy.
|
|
47
53
|
*
|
|
48
|
-
*
|
|
54
|
+
* BOTH CHAINS CALL THEIR CONTRACT `coin`, which is the one real hazard in this table. StoaChain's
|
|
55
|
+
* uses Ouronet-style names (`C_Transfer`, `C_URV|Stake`); Kadena's uses KIP-0002 kebab-case
|
|
56
|
+
* (`transfer`, `transfer-create`). No key collides TODAY, and `chainOf` refuses rather than
|
|
57
|
+
* guesses if one ever does -- the same posture `resolveByName` takes for the four SWP names that
|
|
58
|
+
* resolve to two modules. Guessing wrong here would price a call on the wrong chain.
|
|
49
59
|
*/
|
|
50
|
-
|
|
51
|
-
|
|
60
|
+
/** StoaChain's root-namespace `coin`. source: 0_Stoa/coin-contract/coin-live.pact */
|
|
61
|
+
export const STOA_SIGNATURES = {
|
|
52
62
|
"coin.C_Transfer": [["sender", "string"], ["receiver", "string"], ["amount", "decimal"]], // :583
|
|
53
63
|
"coin.C_Transmit": [["sender", "string"], ["receiver", "string"], ["amount", "decimal"]], // :593
|
|
54
64
|
"coin.C_TransferAnew": [["sender", "string"], ["receiver", "string"], ["receiver-guard", "guard"], ["amount", "decimal"]], // :586
|
|
@@ -59,37 +69,82 @@ export const NATIVE_SIGNATURES = {
|
|
|
59
69
|
"coin.C_URV|Unstake": [["account", "string"], ["urstoa-amount", "decimal"]], // :1439
|
|
60
70
|
"coin.C_URV|Collect": [["account", "string"]], // :1467
|
|
61
71
|
};
|
|
62
|
-
/**
|
|
63
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Kadena mainnet's `coin`. source: 00_KadenaSandbox/kda-env/kadena/coin-v6.pact
|
|
74
|
+
*
|
|
75
|
+
* A DIFFERENT CHAIN. Different gas, different accounts, and nothing about Ouronet's gas station
|
|
76
|
+
* or IGNIS applies. `transfer-crosschain` is a `defpact` -- a multi-step continuation -- which a
|
|
77
|
+
* renderer may want to say out loud, because its later steps are not sponsored by anyone.
|
|
78
|
+
*/
|
|
79
|
+
export const KADENA_SIGNATURES = {
|
|
80
|
+
"coin.transfer": [["sender", "string"], ["receiver", "string"], ["amount", "decimal"]], // :329
|
|
81
|
+
"coin.transfer-create": [["sender", "string"], ["receiver", "string"], ["receiver-guard", "guard"], ["amount", "decimal"]], // :356
|
|
82
|
+
"coin.transfer-crosschain": [["sender", "string"], ["receiver", "string"], ["receiver-guard", "guard"], ["target-chain", "string"], ["amount", "decimal"]], // :528 (defpact)
|
|
83
|
+
"coin.create-account": [["account", "string"], ["guard", "guard"]], // :278
|
|
84
|
+
"coin.rotate": [["account", "string"], ["new-guard", "guard"]], // :307
|
|
85
|
+
};
|
|
86
|
+
/** Back-compat alias. `NATIVE_SIGNATURES` meant StoaChain's before Kadena joined the model. */
|
|
87
|
+
export const NATIVE_SIGNATURES = STOA_SIGNATURES;
|
|
88
|
+
/**
|
|
89
|
+
* Which chain a key belongs to, or `undefined` for a key this model does not describe.
|
|
90
|
+
*
|
|
91
|
+
* Refuses an AMBIGUOUS key rather than picking: both chains have a `coin`, and pricing a call on
|
|
92
|
+
* the wrong chain is the kind of wrong that looks right.
|
|
93
|
+
*/
|
|
94
|
+
export function chainOf(key) {
|
|
95
|
+
const inStoa = key in STOA_SIGNATURES;
|
|
96
|
+
const inKda = key in KADENA_SIGNATURES;
|
|
97
|
+
if (inStoa && inKda)
|
|
98
|
+
throw new Error(`tooltip: "${key}" is declared for BOTH StoaChain and Kadena. Both chains have a \`coin\` ` +
|
|
99
|
+
`contract, so this cannot be resolved by name -- and choosing wrong would describe a call ` +
|
|
100
|
+
`on the wrong chain. Remove the duplicate or key it explicitly.`);
|
|
101
|
+
if (inStoa)
|
|
102
|
+
return "stoa";
|
|
103
|
+
if (inKda)
|
|
104
|
+
return "kadena";
|
|
105
|
+
return tryGetEntrypoint(key) ? "ouronet" : undefined;
|
|
106
|
+
}
|
|
107
|
+
/** True for any key this model can describe at all. Arweave and friends answer false -- rule 0. */
|
|
108
|
+
export const isOffRegistryKey = (key) => key in STOA_SIGNATURES || key in KADENA_SIGNATURES;
|
|
109
|
+
/** @deprecated use `chainOf(key) === "stoa"`. Kept so 1.x callers keep compiling. */
|
|
110
|
+
export const isNativeKey = (key) => key in STOA_SIGNATURES;
|
|
111
|
+
/** StoaChain `coin` accounts are k:/c:/u:/w: shaped, NOT Ouronet glyph strings. */
|
|
112
|
+
const STOA_GHOST = {
|
|
113
|
+
string: '"k:1ac0d8b0a4f6e2c9d3b5a7e1f4c6089d2b3e5a7c9f1d3b5e7a9c1f3d5b7e9a1c"',
|
|
114
|
+
decimal: "1.0",
|
|
115
|
+
integer: "1",
|
|
116
|
+
bool: "false",
|
|
117
|
+
guard: '(read-keyset "ks")',
|
|
118
|
+
};
|
|
119
|
+
/** Kadena accounts are `k:` principals. Same shape, different chain -- and a different balance. */
|
|
120
|
+
const KADENA_GHOST = {
|
|
64
121
|
string: '"k:1ac0d8b0a4f6e2c9d3b5a7e1f4c6089d2b3e5a7c9f1d3b5e7a9c1f3d5b7e9a1c"',
|
|
65
122
|
decimal: "1.0",
|
|
66
123
|
integer: "1",
|
|
67
124
|
bool: "false",
|
|
68
125
|
guard: '(read-keyset "ks")',
|
|
69
126
|
};
|
|
70
|
-
function
|
|
71
|
-
|
|
72
|
-
// Asserted rather than assumed: a non-null assertion here would make a future direct caller
|
|
73
|
-
// fail with a property access on undefined instead of a sentence naming the problem.
|
|
74
|
-
const sig = NATIVE_SIGNATURES[key];
|
|
127
|
+
function offRegistryModel(key, kind, values) {
|
|
128
|
+
const sig = (kind === "stoa" ? STOA_SIGNATURES : KADENA_SIGNATURES)[key];
|
|
75
129
|
if (!sig)
|
|
76
|
-
throw new Error(`
|
|
130
|
+
throw new Error(`offRegistryModel: no signature for "${key}"`);
|
|
131
|
+
const ghost = kind === "stoa" ? STOA_GHOST : KADENA_GHOST;
|
|
77
132
|
return {
|
|
78
|
-
kind
|
|
133
|
+
kind,
|
|
79
134
|
exec: key,
|
|
80
135
|
slots: sig.map(([name, type], i) => ({
|
|
81
136
|
index: i + 1,
|
|
82
137
|
name,
|
|
83
138
|
type,
|
|
84
|
-
value: values[name] ??
|
|
85
|
-
isPlaceholder: values[name] === undefined &&
|
|
139
|
+
value: values[name] ?? ghost[type] ?? PLACEHOLDER,
|
|
140
|
+
isPlaceholder: values[name] === undefined && ghost[type] === undefined,
|
|
86
141
|
isPreflightFed: false,
|
|
87
|
-
// A guard is never prefillable,
|
|
142
|
+
// A guard is never prefillable, on any chain. Same rule, same reason.
|
|
88
143
|
prefillable: type !== "guard",
|
|
89
144
|
})),
|
|
90
|
-
// No preview, deliberately.
|
|
91
|
-
// show and a renderer must
|
|
92
|
-
// failed load.
|
|
145
|
+
// No preview, deliberately. Neither chain's `coin` has a reader that prices a call, so there
|
|
146
|
+
// is no cost to show -- and a renderer must SAY that rather than leaving an empty panel,
|
|
147
|
+
// which reads as "the price failed to load".
|
|
93
148
|
shouldRead: false,
|
|
94
149
|
warnings: [],
|
|
95
150
|
};
|
|
@@ -106,12 +161,11 @@ function nativeModel(key, values) {
|
|
|
106
161
|
* must never take down the page it annotates.
|
|
107
162
|
*/
|
|
108
163
|
export function tooltipModel(key, values = {}) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
164
|
+
const chain = chainOf(key);
|
|
165
|
+
if (chain === "stoa" || chain === "kadena")
|
|
166
|
+
return offRegistryModel(key, chain, values);
|
|
167
|
+
if (chain === undefined && isOffRegistryKey(key))
|
|
168
|
+
throw new Error(`tooltipModel: "${key}" matched no chain. This is a bug in chainOf.`);
|
|
115
169
|
const ep = getEntrypoint(key); // throws, and names near matches, on a stale key
|
|
116
170
|
const warnings = [];
|
|
117
171
|
const use = ep.ghost.use ?? {};
|
|
@@ -212,7 +266,7 @@ export function tooltipModel(key, values = {}) {
|
|
|
212
266
|
*/
|
|
213
267
|
export function tooltipModels(keys, values = {}) {
|
|
214
268
|
return keys
|
|
215
|
-
.filter((k) =>
|
|
269
|
+
.filter((k) => chainOf(k) !== undefined)
|
|
216
270
|
.map((k) => tooltipModel(k, values));
|
|
217
271
|
}
|
|
218
272
|
/**
|
package/package.json
CHANGED