@cardano-slips/flow 0.2.0 → 0.3.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 +53 -9
- package/dist/address.d.ts +12 -0
- package/dist/address.d.ts.map +1 -1
- package/dist/address.js +43 -0
- package/dist/address.js.map +1 -1
- package/dist/card.css +492 -0
- package/dist/card.d.ts +41 -0
- package/dist/card.d.ts.map +1 -0
- package/dist/card.js +69 -0
- package/dist/card.js.map +1 -0
- package/dist/complete-error.d.ts +8 -1
- package/dist/complete-error.d.ts.map +1 -1
- package/dist/complete-error.js +6 -1
- package/dist/complete-error.js.map +1 -1
- package/dist/complete.d.ts +29 -10
- package/dist/complete.d.ts.map +1 -1
- package/dist/complete.js +83 -9
- package/dist/complete.js.map +1 -1
- package/dist/derived.d.ts +8 -0
- package/dist/derived.d.ts.map +1 -0
- package/dist/derived.js +2 -0
- package/dist/derived.js.map +1 -0
- package/dist/effects-panel.d.ts +37 -0
- package/dist/effects-panel.d.ts.map +1 -0
- package/dist/effects-panel.js +64 -0
- package/dist/effects-panel.js.map +1 -0
- package/dist/effects.css +629 -0
- package/dist/exchange.d.ts +54 -0
- package/dist/exchange.d.ts.map +1 -0
- package/dist/exchange.js +136 -0
- package/dist/exchange.js.map +1 -0
- package/dist/explain.d.ts +39 -0
- package/dist/explain.d.ts.map +1 -0
- package/dist/explain.js +172 -0
- package/dist/explain.js.map +1 -0
- package/dist/index.d.ts +19 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/ledger.d.ts +74 -0
- package/dist/ledger.d.ts.map +1 -0
- package/dist/ledger.js +402 -0
- package/dist/ledger.js.map +1 -0
- package/dist/outcome-panel.d.ts +63 -0
- package/dist/outcome-panel.d.ts.map +1 -0
- package/dist/outcome-panel.js +40 -0
- package/dist/outcome-panel.js.map +1 -0
- package/dist/parameter-form.d.ts +26 -0
- package/dist/parameter-form.d.ts.map +1 -0
- package/dist/parameter-form.js +42 -0
- package/dist/parameter-form.js.map +1 -0
- package/dist/slip-card.d.ts +55 -0
- package/dist/slip-card.d.ts.map +1 -0
- package/dist/slip-card.js +89 -0
- package/dist/slip-card.js.map +1 -0
- package/dist/tokens.css +57 -32
- package/package.json +9 -5
- package/src/address.ts +53 -0
- package/src/card.css +492 -0
- package/src/card.ts +86 -0
- package/src/complete-error.ts +14 -2
- package/src/complete.ts +128 -19
- package/src/derived.ts +8 -0
- package/src/effects-panel.tsx +386 -0
- package/src/effects.css +629 -0
- package/src/exchange.ts +212 -0
- package/src/explain.ts +211 -0
- package/src/index.ts +39 -3
- package/src/ledger.ts +503 -0
- package/src/outcome-panel.tsx +263 -0
- package/src/parameter-form.tsx +138 -0
- package/src/slip-card.tsx +244 -0
- package/src/tokens.css +57 -32
package/dist/exchange.js
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The two HTTP exchanges a client makes: `GET` for the Slip and `POST` for the
|
|
3
|
+
* partial intent. Every way either can fail arrives as one error in the spec's
|
|
4
|
+
* vocabulary, classified by the rules in "Failure responses".
|
|
5
|
+
*/
|
|
6
|
+
import { boundedRequest, checkTemplates, classifyErrorCode, classifyStatus, decodePartialIntent, decodeSlip, decodeSlipError, fetchDomainMapping, PROTOCOL_VERSION, resolveSlipUrl } from "@cardano-slips/core";
|
|
7
|
+
import { Data, Effect, Either } from "effect";
|
|
8
|
+
/**
|
|
9
|
+
* `code` is a spec code, or one an endpoint sent that the spec does not define.
|
|
10
|
+
* It is absent only where the body could not be read, and then `status` is all
|
|
11
|
+
* there is to go on.
|
|
12
|
+
*/
|
|
13
|
+
export class ExchangeError extends Data.TaggedError("ExchangeError") {
|
|
14
|
+
get message() {
|
|
15
|
+
return this.detail;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const clientFailure = (code, detail, status) => new ExchangeError({
|
|
19
|
+
code,
|
|
20
|
+
errorClass: classifyErrorCode(code),
|
|
21
|
+
detail,
|
|
22
|
+
...(status === undefined ? {} : { status })
|
|
23
|
+
});
|
|
24
|
+
/** Whole seconds or an HTTP date, per RFC 9110; anything else says nothing. */
|
|
25
|
+
const readRetryAfter = (header, now) => {
|
|
26
|
+
if (header === null)
|
|
27
|
+
return undefined;
|
|
28
|
+
const trimmed = header.trim();
|
|
29
|
+
if (/^\d+$/.test(trimmed))
|
|
30
|
+
return Number(trimmed);
|
|
31
|
+
const at = Date.parse(trimmed);
|
|
32
|
+
return Number.isNaN(at) ? undefined : Math.max(0, Math.ceil((at - now) / 1000));
|
|
33
|
+
};
|
|
34
|
+
const parseJson = (text) => {
|
|
35
|
+
try {
|
|
36
|
+
return JSON.parse(text);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
/** A major version is checked before the shape, so a newer protocol is not reported as a broken one. */
|
|
43
|
+
const newerVersion = (body) => {
|
|
44
|
+
if (typeof body !== "object" || body === null)
|
|
45
|
+
return undefined;
|
|
46
|
+
const version = body.version;
|
|
47
|
+
return typeof version === "string" && /^[1-9][0-9]*$/.test(version) && version !== PROTOCOL_VERSION
|
|
48
|
+
? version
|
|
49
|
+
: undefined;
|
|
50
|
+
};
|
|
51
|
+
const failureFrom = (response, text) => {
|
|
52
|
+
const status = response.status;
|
|
53
|
+
const retryAfter = readRetryAfter(response.headers.get("retry-after"), Date.now());
|
|
54
|
+
const retry = retryAfter === undefined ? {} : { retryAfter };
|
|
55
|
+
const body = parseJson(text);
|
|
56
|
+
const version = newerVersion(body);
|
|
57
|
+
if (version !== undefined) {
|
|
58
|
+
return clientFailure("UNSUPPORTED_VERSION", `the failure body speaks version ${version}`, status);
|
|
59
|
+
}
|
|
60
|
+
const read = decodeSlipError(body);
|
|
61
|
+
// Unreadable, so classified by status and never rendered: it is as likely an
|
|
62
|
+
// intermediary's error page as the publisher's words.
|
|
63
|
+
if (Either.isLeft(read)) {
|
|
64
|
+
return new ExchangeError({
|
|
65
|
+
errorClass: classifyStatus(status),
|
|
66
|
+
status,
|
|
67
|
+
detail: `answered ${status} with a body that is not a failure response`,
|
|
68
|
+
...retry
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return new ExchangeError({
|
|
72
|
+
code: read.right.code,
|
|
73
|
+
errorClass: classifyErrorCode(read.right.code),
|
|
74
|
+
endpointMessage: read.right.message,
|
|
75
|
+
status,
|
|
76
|
+
detail: `answered ${status} ${read.right.code}`,
|
|
77
|
+
...(read.right.field === undefined ? {} : { field: read.right.field }),
|
|
78
|
+
...retry
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* One request, through core's bounded request. Anything that stops a usable
|
|
83
|
+
* answer arriving — DNS, TLS, a refused CORS read, the clock, the size — is `UNREACHABLE`.
|
|
84
|
+
*/
|
|
85
|
+
const exchange = (url, init, options) => boundedRequest(url, init, options).pipe(Effect.mapError((failure) => clientFailure(failure.code, failure.detail)));
|
|
86
|
+
const successBody = ({ response, text }) => {
|
|
87
|
+
if (response.status !== 200)
|
|
88
|
+
return Effect.fail(failureFrom(response, text));
|
|
89
|
+
const body = parseJson(text);
|
|
90
|
+
if (body === undefined) {
|
|
91
|
+
return Effect.fail(clientFailure("MALFORMED_RESPONSE", `${response.url} answered 200 with something not JSON`));
|
|
92
|
+
}
|
|
93
|
+
const version = newerVersion(body);
|
|
94
|
+
if (version !== undefined) {
|
|
95
|
+
return Effect.fail(clientFailure("UNSUPPORTED_VERSION", `the response speaks version ${version}`));
|
|
96
|
+
}
|
|
97
|
+
return Effect.succeed(body);
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* The link to a Slip a person can be shown, or why not. `slips.json` is read
|
|
101
|
+
* first, because the link a person shares is not always the endpoint. A link
|
|
102
|
+
* that is not `https:` fails as `InsecureSlipUrl`, before anything is fetched.
|
|
103
|
+
*/
|
|
104
|
+
export const fetchSlip = (link, options = {}) => Effect.gen(function* () {
|
|
105
|
+
const mapping = yield* fetchDomainMapping(link, options).pipe(Effect.catchTag("DomainMappingFailure", (failure) => Effect.fail(clientFailure(failure.code, failure.detail))));
|
|
106
|
+
const discoveryUrl = yield* resolveSlipUrl(link, mapping);
|
|
107
|
+
const answer = yield* exchange(discoveryUrl, { method: "GET", headers: { accept: "application/json" } }, options);
|
|
108
|
+
const body = yield* successBody(answer);
|
|
109
|
+
const slip = decodeSlip(body);
|
|
110
|
+
if (Either.isLeft(slip)) {
|
|
111
|
+
return yield* Effect.fail(clientFailure("MALFORMED_RESPONSE", `${discoveryUrl} did not answer with a Slip`));
|
|
112
|
+
}
|
|
113
|
+
const defects = checkTemplates(slip.right, discoveryUrl);
|
|
114
|
+
if (defects.length > 0) {
|
|
115
|
+
return yield* Effect.fail(clientFailure("MALFORMED_RESPONSE", `${discoveryUrl} answered a Slip with ${defects[0]?._tag ?? "a defect"}`));
|
|
116
|
+
}
|
|
117
|
+
return { slip: slip.right, discoveryUrl };
|
|
118
|
+
});
|
|
119
|
+
/**
|
|
120
|
+
* The partial intent for one action. The body is the change address and the
|
|
121
|
+
* network and nothing else: Mode A never tells an endpoint what a wallet holds.
|
|
122
|
+
*/
|
|
123
|
+
export const requestIntent = ({ changeAddress, href, network }, options = {}) => Effect.gen(function* () {
|
|
124
|
+
const answer = yield* exchange(href, {
|
|
125
|
+
method: "POST",
|
|
126
|
+
headers: { accept: "application/json", "content-type": "application/json" },
|
|
127
|
+
body: JSON.stringify({ changeAddress, network })
|
|
128
|
+
}, options);
|
|
129
|
+
const body = yield* successBody(answer);
|
|
130
|
+
const intent = decodePartialIntent(body);
|
|
131
|
+
if (Either.isLeft(intent)) {
|
|
132
|
+
return yield* Effect.fail(clientFailure("MALFORMED_RESPONSE", `${href} did not answer with a partial intent`));
|
|
133
|
+
}
|
|
134
|
+
return intent.right;
|
|
135
|
+
});
|
|
136
|
+
//# sourceMappingURL=exchange.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,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AAA;IACD,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;IAEvC,MAAM,MAAM,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAA;IACxC,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1B,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,oBAAoB,EAAE,GAAG,IAAI,uCAAuC,CAAC,CAAC,CAAA;IAChH,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAA;AACrB,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The words the effects panel puts in front of a person: exact figures, and a
|
|
3
|
+
* plain account of each mismatch. Nothing here rounds, and nothing guesses a
|
|
4
|
+
* token's decimals — the CIP requires base units where they are not known.
|
|
5
|
+
*/
|
|
6
|
+
import type { Reason } from "@cardano-slips/verifier";
|
|
7
|
+
/** Lovelace as ADA, to the lovelace. The sign is dropped: "you pay" and "you receive" carry the direction. */
|
|
8
|
+
export declare const formatAda: (lovelace: bigint) => string;
|
|
9
|
+
/** A token quantity in base units, unsigned for the same reason as `formatAda`. */
|
|
10
|
+
export declare const formatQuantity: (quantity: bigint) => string;
|
|
11
|
+
/** The asset name as text, or null where it is not text a person could read — which is then no name at all. */
|
|
12
|
+
export declare const assetLabel: (assetName: string) => string | null;
|
|
13
|
+
/** Unix milliseconds as a UTC instant. UTC so that the publisher and the person read the same moment. */
|
|
14
|
+
export declare const formatInstant: (time: bigint) => string;
|
|
15
|
+
/** Whole seconds until `until`, never below zero. */
|
|
16
|
+
export declare const secondsLeft: (until: bigint, now: bigint) => number;
|
|
17
|
+
/** The sheet's clock: `4m 12s`, and hours in front once there are any. */
|
|
18
|
+
export declare const formatCountdown: (seconds: number) => string;
|
|
19
|
+
/**
|
|
20
|
+
* A bech32 string cut to what a column can hold: the prefix, three characters,
|
|
21
|
+
* and the last four. Only where the full string is a click away.
|
|
22
|
+
*/
|
|
23
|
+
export declare const shortened: (text: string) => string;
|
|
24
|
+
/**
|
|
25
|
+
* What the block shows for one reason, in the sheet's voice: the transaction
|
|
26
|
+
* is held to "the link", and a sentence never carries an address — `where` does,
|
|
27
|
+
* in full, beside it. The CIP asks for the difference, not the rule: `declared`
|
|
28
|
+
* is what the link asked for and `actual` is what the transaction does, where
|
|
29
|
+
* the reason has a figure for each.
|
|
30
|
+
*/
|
|
31
|
+
export type Explanation = {
|
|
32
|
+
readonly summary: string;
|
|
33
|
+
readonly declared?: string;
|
|
34
|
+
readonly actual?: string;
|
|
35
|
+
/** The address or reward account the reason is about. */
|
|
36
|
+
readonly where?: string;
|
|
37
|
+
};
|
|
38
|
+
export declare const explainReason: (reason: Reason) => Explanation;
|
|
39
|
+
//# sourceMappingURL=explain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"explain.d.ts","sourceRoot":"","sources":["../src/explain.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,MAAM,EAAqB,MAAM,yBAAyB,CAAA;AAQxE,8GAA8G;AAC9G,eAAO,MAAM,SAAS,GAAI,UAAU,MAAM,KAAG,MAK5C,CAAA;AAED,mFAAmF;AACnF,eAAO,MAAM,cAAc,GAAI,UAAU,MAAM,KAAG,MAAiD,CAAA;AAKnG,+GAA+G;AAC/G,eAAO,MAAM,UAAU,GAAI,WAAW,MAAM,KAAG,MAAM,GAAG,IAQvD,CAAA;AAWD,yGAAyG;AACzG,eAAO,MAAM,aAAa,GAAI,MAAM,MAAM,KAAG,MAI5C,CAAA;AAED,qDAAqD;AACrD,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,EAAE,KAAK,MAAM,KAAG,MACE,CAAA;AAE3D,0EAA0E;AAC1E,eAAO,MAAM,eAAe,GAAI,SAAS,MAAM,KAAG,MAKjD,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,KAAG,MAIxC,CAAA;AAkBD;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,yDAAyD;IACzD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,QAAQ,MAAM,KAAG,WAuG9C,CAAA"}
|
package/dist/explain.js
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
const lovelacePerAda = 1000000n;
|
|
2
|
+
const grouped = (digits) => digits.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
3
|
+
const magnitude = (value) => (value < 0n ? -value : value);
|
|
4
|
+
/** Lovelace as ADA, to the lovelace. The sign is dropped: "you pay" and "you receive" carry the direction. */
|
|
5
|
+
export const formatAda = (lovelace) => {
|
|
6
|
+
const amount = magnitude(lovelace);
|
|
7
|
+
const whole = grouped((amount / lovelacePerAda).toString());
|
|
8
|
+
const fraction = (amount % lovelacePerAda).toString().padStart(6, "0").replace(/0+$/, "");
|
|
9
|
+
return `${fraction === "" ? whole : `${whole}.${fraction}`} ADA`;
|
|
10
|
+
};
|
|
11
|
+
/** A token quantity in base units, unsigned for the same reason as `formatAda`. */
|
|
12
|
+
export const formatQuantity = (quantity) => grouped(magnitude(quantity).toString());
|
|
13
|
+
const bytesOf = (hex) => Uint8Array.from({ length: hex.length / 2 }, (_, index) => Number.parseInt(hex.slice(index * 2, index * 2 + 2), 16));
|
|
14
|
+
/** The asset name as text, or null where it is not text a person could read — which is then no name at all. */
|
|
15
|
+
export const assetLabel = (assetName) => {
|
|
16
|
+
if (assetName === "")
|
|
17
|
+
return null;
|
|
18
|
+
try {
|
|
19
|
+
const text = new TextDecoder("utf-8", { fatal: true }).decode(bytesOf(assetName));
|
|
20
|
+
return /\p{C}/u.test(text) ? null : text;
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const tokenAmount = (quantity, policyId, assetName) => {
|
|
27
|
+
const label = assetLabel(assetName);
|
|
28
|
+
return label === null
|
|
29
|
+
? `${formatQuantity(quantity)} of token ${assetName || "with no name"} under policy ${policyId}`
|
|
30
|
+
: `${formatQuantity(quantity)} ${label}`;
|
|
31
|
+
};
|
|
32
|
+
const months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
|
33
|
+
/** Unix milliseconds as a UTC instant. UTC so that the publisher and the person read the same moment. */
|
|
34
|
+
export const formatInstant = (time) => {
|
|
35
|
+
const date = new Date(Number(time));
|
|
36
|
+
const two = (value) => value.toString().padStart(2, "0");
|
|
37
|
+
return `${date.getUTCDate()} ${months[date.getUTCMonth()]} ${date.getUTCFullYear()}, ${two(date.getUTCHours())}:${two(date.getUTCMinutes())} UTC`;
|
|
38
|
+
};
|
|
39
|
+
/** Whole seconds until `until`, never below zero. */
|
|
40
|
+
export const secondsLeft = (until, now) => until <= now ? 0 : Math.floor(Number(until - now) / 1000);
|
|
41
|
+
/** The sheet's clock: `4m 12s`, and hours in front once there are any. */
|
|
42
|
+
export const formatCountdown = (seconds) => {
|
|
43
|
+
const hours = Math.floor(seconds / 3600);
|
|
44
|
+
const minutes = Math.floor((seconds % 3600) / 60);
|
|
45
|
+
const rest = `${(seconds % 60).toString().padStart(2, "0")}s`;
|
|
46
|
+
return hours > 0 ? `${hours}h ${minutes.toString().padStart(2, "0")}m ${rest}` : `${minutes}m ${rest}`;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* A bech32 string cut to what a column can hold: the prefix, three characters,
|
|
50
|
+
* and the last four. Only where the full string is a click away.
|
|
51
|
+
*/
|
|
52
|
+
export const shortened = (text) => {
|
|
53
|
+
const separator = text.lastIndexOf("1");
|
|
54
|
+
if (separator < 1 || text.length - separator <= 12)
|
|
55
|
+
return text;
|
|
56
|
+
return `${text.slice(0, separator + 4)}…${text.slice(-4)}`;
|
|
57
|
+
};
|
|
58
|
+
const unsupportedWords = {
|
|
59
|
+
"reference-input": "reads another output without spending it",
|
|
60
|
+
collateral: "puts up collateral",
|
|
61
|
+
"required-signer": "asks for an extra signature",
|
|
62
|
+
vote: "casts a governance vote",
|
|
63
|
+
proposal: "submits a governance proposal",
|
|
64
|
+
donation: "donates to the treasury",
|
|
65
|
+
"treasury-value": "states the treasury's value",
|
|
66
|
+
script: "runs a script",
|
|
67
|
+
datum: "attaches data to an output"
|
|
68
|
+
};
|
|
69
|
+
const payments = (count) => (count === 1 ? "1 payment" : `${count} payments`);
|
|
70
|
+
const certificates = (count) => (count === 1 ? "1 certificate" : `${count} certificates`);
|
|
71
|
+
export const explainReason = (reason) => {
|
|
72
|
+
switch (reason.code) {
|
|
73
|
+
case "output.missing":
|
|
74
|
+
return {
|
|
75
|
+
summary: "The transaction leaves out a payment the link asks for.",
|
|
76
|
+
declared: payments(reason.declared),
|
|
77
|
+
actual: payments(reason.paid),
|
|
78
|
+
where: reason.address
|
|
79
|
+
};
|
|
80
|
+
case "output.undeclared":
|
|
81
|
+
return reason.declared === 0
|
|
82
|
+
? { summary: "The transaction pays an address the link never mentions.", where: reason.address }
|
|
83
|
+
: {
|
|
84
|
+
summary: "The transaction pays one address more times than the link asks for.",
|
|
85
|
+
declared: payments(reason.declared),
|
|
86
|
+
actual: payments(reason.paid),
|
|
87
|
+
where: reason.address
|
|
88
|
+
};
|
|
89
|
+
case "output.lovelace":
|
|
90
|
+
return {
|
|
91
|
+
summary: "The transaction pays a different amount of ADA from the one the link asks for.",
|
|
92
|
+
declared: formatAda(reason.declared),
|
|
93
|
+
actual: formatAda(reason.paid),
|
|
94
|
+
where: reason.address
|
|
95
|
+
};
|
|
96
|
+
case "output.assets":
|
|
97
|
+
return {
|
|
98
|
+
summary: "The transaction pays a different amount of a token from the one the link asks for.",
|
|
99
|
+
declared: tokenAmount(reason.declared, reason.policyId, reason.assetName),
|
|
100
|
+
actual: tokenAmount(reason.paid, reason.policyId, reason.assetName),
|
|
101
|
+
where: reason.address
|
|
102
|
+
};
|
|
103
|
+
case "certificate.missing":
|
|
104
|
+
return {
|
|
105
|
+
summary: "A certificate the link asks for is missing from the transaction.",
|
|
106
|
+
declared: certificates(reason.declared),
|
|
107
|
+
actual: certificates(reason.carried)
|
|
108
|
+
};
|
|
109
|
+
case "certificate.undeclared":
|
|
110
|
+
return {
|
|
111
|
+
summary: "The transaction carries a certificate the link never mentions.",
|
|
112
|
+
declared: certificates(reason.declared),
|
|
113
|
+
actual: certificates(reason.carried)
|
|
114
|
+
};
|
|
115
|
+
case "certificate.order":
|
|
116
|
+
return { summary: "The transaction's certificates are in a different order from the link's." };
|
|
117
|
+
case "certificate.target":
|
|
118
|
+
return {
|
|
119
|
+
summary: `Certificate ${reason.index + 1} names a different pool or DRep from the one the link asks for.`,
|
|
120
|
+
declared: reason.declared,
|
|
121
|
+
actual: reason.carried
|
|
122
|
+
};
|
|
123
|
+
case "certificate.credential":
|
|
124
|
+
return { summary: `Certificate ${reason.index + 1} acts on a stake key this wallet does not hold.` };
|
|
125
|
+
case "certificate.deposit":
|
|
126
|
+
return {
|
|
127
|
+
summary: `Certificate ${reason.index + 1} takes a deposit other than the one the network sets.`,
|
|
128
|
+
declared: formatAda(reason.parameter),
|
|
129
|
+
actual: formatAda(reason.stated)
|
|
130
|
+
};
|
|
131
|
+
case "withdrawal.missing":
|
|
132
|
+
return { summary: "The link asks to withdraw your rewards, and the transaction does not." };
|
|
133
|
+
case "withdrawal.undeclared":
|
|
134
|
+
return { summary: "The transaction withdraws rewards the link never mentions." };
|
|
135
|
+
case "withdrawal.account":
|
|
136
|
+
return {
|
|
137
|
+
summary: "The transaction withdraws from a reward account that is not this wallet's.",
|
|
138
|
+
where: reason.account
|
|
139
|
+
};
|
|
140
|
+
case "mint.undeclared":
|
|
141
|
+
return {
|
|
142
|
+
summary: "The transaction creates or destroys tokens, which no link can ask for.",
|
|
143
|
+
actual: reason.assets
|
|
144
|
+
.map((asset) => `${asset.quantity < 0n ? "Destroys" : "Creates"} ${tokenAmount(asset.quantity, asset.policyId, asset.assetName)}`)
|
|
145
|
+
.join(", ")
|
|
146
|
+
};
|
|
147
|
+
case "body.unsupported":
|
|
148
|
+
return {
|
|
149
|
+
summary: `The transaction does things a link cannot describe: it ${reason.members
|
|
150
|
+
.map((member) => unsupportedWords[member])
|
|
151
|
+
.join(", ")}.`
|
|
152
|
+
};
|
|
153
|
+
case "fee.excessive":
|
|
154
|
+
return {
|
|
155
|
+
summary: "The network fee is higher than this transaction needs.",
|
|
156
|
+
declared: `At most ${formatAda(reason.ceiling)}`,
|
|
157
|
+
actual: formatAda(reason.fee)
|
|
158
|
+
};
|
|
159
|
+
case "interval.beyond-declared":
|
|
160
|
+
return {
|
|
161
|
+
summary: "The transaction stays valid for longer than the link says.",
|
|
162
|
+
declared: `Until ${formatInstant(reason.declared)}`,
|
|
163
|
+
actual: reason.validUntil === null ? "Never expires" : `Until ${formatInstant(reason.validUntil)}`
|
|
164
|
+
};
|
|
165
|
+
case "interval.not-yet-valid":
|
|
166
|
+
return {
|
|
167
|
+
summary: "The transaction cannot be submitted yet.",
|
|
168
|
+
actual: `Valid from ${formatInstant(reason.validFrom)}`
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
//# sourceMappingURL=explain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"explain.js","sourceRoot":"","sources":["../src/explain.ts"],"names":[],"mappings":"AAOA,MAAM,cAAc,GAAG,QAAU,CAAA;AAEjC,MAAM,OAAO,GAAG,CAAC,MAAc,EAAU,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,uBAAuB,EAAE,GAAG,CAAC,CAAA;AAExF,MAAM,SAAS,GAAG,CAAC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;qBAC9E,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;qBACzC,IAAI,CAAC,IAAI,CAAC,GAAG;aACjB,CAAA;QACH,KAAK,eAAe;YAClB,OAAO;gBACL,OAAO,EAAE,wDAAwD;gBACjE,QAAQ,EAAE,WAAW,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE;gBAChD,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC;aAC9B,CAAA;QACH,KAAK,0BAA0B;YAC7B,OAAO;gBACL,OAAO,EAAE,4DAA4D;gBACrE,QAAQ,EAAE,SAAS,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE;gBACnD,MAAM,EAAE,MAAM,CAAC,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE;aACnG,CAAA;QACH,KAAK,wBAAwB;YAC3B,OAAO;gBACL,OAAO,EAAE,0CAA0C;gBACnD,MAAM,EAAE,cAAc,aAAa,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE;aACxD,CAAA;IACL,CAAC;AACH,CAAC,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,22 +2,36 @@
|
|
|
2
2
|
* The public entry point of `@cardano-slips/flow`. The `exports` map exposes
|
|
3
3
|
* this module and nothing else, so moving a file is never a breaking change.
|
|
4
4
|
*/
|
|
5
|
-
export type { NetworkId, WalletAddress } from "./address.js";
|
|
6
|
-
export { readWalletAddress } from "./address.js";
|
|
5
|
+
export type { NetworkId, OwnAddress, WalletAddress } from "./address.js";
|
|
6
|
+
export { readOwnAddress, readWalletAddress } from "./address.js";
|
|
7
7
|
export type { BalancedTransaction, BalanceInputs, BalancingParameters } from "./balance.js";
|
|
8
8
|
export { balanceIntent } from "./balance.js";
|
|
9
9
|
export type { BalanceRefusal } from "./balance-error.js";
|
|
10
10
|
export { BalanceError, balanceRefusals, slipErrorCodeFor as balanceErrorCodeFor } from "./balance-error.js";
|
|
11
|
+
export { actionLabel, actionsOf, blockedLabel, closureOf, monogramOf, originOf } from "./card.js";
|
|
11
12
|
export type { CborHex, Cip30Api, Cip30ApiError, Cip30Provider, Paginate, SignedData } from "./cip30.js";
|
|
12
13
|
export { apiErrorNames, describeApiError, isCip30Api, isCip30Provider, readApiError, REFUSED, txSendErrorNames, txSignErrorNames, USER_DECLINED } from "./cip30.js";
|
|
13
|
-
export type { Attempt, CompletionRequest, Receipt } from "./complete.js";
|
|
14
|
+
export type { Attempt, CompletionRequest, Progress, Receipt } from "./complete.js";
|
|
14
15
|
export { completeIntent } from "./complete.js";
|
|
15
16
|
export type { CompletionRefusal } from "./complete-error.js";
|
|
16
17
|
export { CompletionError, completionRefusals, slipErrorCodeFor as completionErrorCodeFor } from "./complete-error.js";
|
|
17
18
|
export type { ConnectedWallet, ConnectOptions } from "./connect.js";
|
|
18
19
|
export { connectWallet, networkIdFor } from "./connect.js";
|
|
20
|
+
export type { Derived } from "./derived.js";
|
|
19
21
|
export type { DiscoveredWallet, WalletHost } from "./discovery.js";
|
|
20
22
|
export { discoverWallets, findWallet, injectedUnder } from "./discovery.js";
|
|
23
|
+
export type { EffectsPanelProps } from "./effects-panel.js";
|
|
24
|
+
export { EffectsPanel } from "./effects-panel.js";
|
|
25
|
+
export type { ExchangeOptions, FetchedSlip, IntentRequest } from "./exchange.js";
|
|
26
|
+
export { ExchangeError, fetchSlip, requestIntent } from "./exchange.js";
|
|
27
|
+
export type { Explanation } from "./explain.js";
|
|
28
|
+
export { assetLabel, explainReason, formatAda, formatCountdown, formatInstant, formatQuantity, secondsLeft, shortened } from "./explain.js";
|
|
29
|
+
export type { Amount, Evidence, Group, Headline, Mark, Row, Tone } from "./ledger.js";
|
|
30
|
+
export { blockedLine, describeCertificate, evidenceOf, groupsOf, headlineOf, isCollapsed, isGrouped, ledgerOf, matchLine, rawLines } from "./ledger.js";
|
|
31
|
+
export type { Outcome, OutcomePanelProps, SlipReceiptProps } from "./outcome-panel.js";
|
|
32
|
+
export { networkNames, OutcomePanel, SlipReceipt } from "./outcome-panel.js";
|
|
33
|
+
export type { FieldError, ParameterFormProps } from "./parameter-form.js";
|
|
34
|
+
export { boundsOf, ParameterForm } from "./parameter-form.js";
|
|
21
35
|
export type { KnownWallet } from "./registry.js";
|
|
22
36
|
export { knownWallet, knownWallets } from "./registry.js";
|
|
23
37
|
export { asResolvedInput, asResolvedInputs } from "./resolve.js";
|
|
@@ -25,6 +39,8 @@ export type { SignedTransaction, SignRequest } from "./sign.js";
|
|
|
25
39
|
export { signTransaction, submitTransaction } from "./sign.js";
|
|
26
40
|
export type { SignRefusal } from "./sign-error.js";
|
|
27
41
|
export { signRefusals, SigningError, slipErrorCodeFor as signErrorCodeFor } from "./sign-error.js";
|
|
42
|
+
export type { SlipCardErrorProps, SlipCardProps, SlipSubmission } from "./slip-card.js";
|
|
43
|
+
export { SlipCard, SlipCardError, SlipCardSkeleton } from "./slip-card.js";
|
|
28
44
|
export { readWalletUtxos } from "./utxo.js";
|
|
29
45
|
export type { ConnectRefusal } from "./wallet-error.js";
|
|
30
46
|
export { connectRefusals, slipErrorCodeFor, WalletConnectError } from "./wallet-error.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AACxE,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAChE,YAAY,EAAE,mBAAmB,EAAE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WAAW,CAAA;AAC9D,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,gBAAgB,IAAI,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClG,YAAY,EAAE,kBAAkB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACvF,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAC3C,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AACzF,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,23 @@
|
|
|
1
|
-
export { readWalletAddress } from "./address.js";
|
|
1
|
+
export { readOwnAddress, readWalletAddress } from "./address.js";
|
|
2
2
|
export { balanceIntent } from "./balance.js";
|
|
3
3
|
export { BalanceError, balanceRefusals, slipErrorCodeFor as balanceErrorCodeFor } from "./balance-error.js";
|
|
4
|
+
export { actionLabel, actionsOf, blockedLabel, closureOf, monogramOf, originOf } from "./card.js";
|
|
4
5
|
export { apiErrorNames, describeApiError, isCip30Api, isCip30Provider, readApiError, REFUSED, txSendErrorNames, txSignErrorNames, USER_DECLINED } from "./cip30.js";
|
|
5
6
|
export { completeIntent } from "./complete.js";
|
|
6
7
|
export { CompletionError, completionRefusals, slipErrorCodeFor as completionErrorCodeFor } from "./complete-error.js";
|
|
7
8
|
export { connectWallet, networkIdFor } from "./connect.js";
|
|
8
9
|
export { discoverWallets, findWallet, injectedUnder } from "./discovery.js";
|
|
10
|
+
export { EffectsPanel } from "./effects-panel.js";
|
|
11
|
+
export { ExchangeError, fetchSlip, requestIntent } from "./exchange.js";
|
|
12
|
+
export { assetLabel, explainReason, formatAda, formatCountdown, formatInstant, formatQuantity, secondsLeft, shortened } from "./explain.js";
|
|
13
|
+
export { blockedLine, describeCertificate, evidenceOf, groupsOf, headlineOf, isCollapsed, isGrouped, ledgerOf, matchLine, rawLines } from "./ledger.js";
|
|
14
|
+
export { networkNames, OutcomePanel, SlipReceipt } from "./outcome-panel.js";
|
|
15
|
+
export { boundsOf, ParameterForm } from "./parameter-form.js";
|
|
9
16
|
export { knownWallet, knownWallets } from "./registry.js";
|
|
10
17
|
export { asResolvedInput, asResolvedInputs } from "./resolve.js";
|
|
11
18
|
export { signTransaction, submitTransaction } from "./sign.js";
|
|
12
19
|
export { signRefusals, SigningError, slipErrorCodeFor as signErrorCodeFor } from "./sign-error.js";
|
|
20
|
+
export { SlipCard, SlipCardError, SlipCardSkeleton } from "./slip-card.js";
|
|
13
21
|
export { readWalletUtxos } from "./utxo.js";
|
|
14
22
|
export { connectRefusals, slipErrorCodeFor, WalletConnectError } from "./wallet-error.js";
|
|
15
23
|
export { assembleWitnesses, requireSameBody, transactionIdOf } from "./witness.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAEhE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAE5C,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,gBAAgB,IAAI,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAC3G,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MA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B,EAAE,MAAM,iBAAiB,CAAA;AAElG,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAE3C,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AACzF,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA"}
|
package/dist/ledger.d.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the effects panel draws, worked out without React: the headline figure,
|
|
3
|
+
* one row per effect, which rows a mismatch marks, and the line that states
|
|
4
|
+
* the verdict. Every figure comes from the derived effects, never the claim.
|
|
5
|
+
*/
|
|
6
|
+
import { type CertificateEffect, type Reason } from "@cardano-slips/verifier";
|
|
7
|
+
import type { Derived } from "./derived.js";
|
|
8
|
+
/** How an amount reads: gone for good, arriving, taken by the network, held to be given back, or only claimed. */
|
|
9
|
+
export type Tone = "spent" | "gained" | "fee" | "held" | "stated";
|
|
10
|
+
export type Amount = {
|
|
11
|
+
readonly text: string;
|
|
12
|
+
readonly tone: Tone;
|
|
13
|
+
};
|
|
14
|
+
export type Group = "arriving" | "leaving" | "unmoved";
|
|
15
|
+
/** A row the link did not describe, or described otherwise. Only these rows take colour. */
|
|
16
|
+
export type Mark = "not-in-the-link" | "not-as-the-link-says";
|
|
17
|
+
export type Row = {
|
|
18
|
+
readonly key: string;
|
|
19
|
+
readonly label: string;
|
|
20
|
+
readonly detail?: string;
|
|
21
|
+
readonly amounts: ReadonlyArray<Amount>;
|
|
22
|
+
/** A pool or DRep, where the row moves no value and the amount column carries a name instead. */
|
|
23
|
+
readonly identifier?: string;
|
|
24
|
+
/** `refundable` where the ledger guarantees the figure, `as-stated` where only the transaction claims it. */
|
|
25
|
+
readonly chip?: "refundable" | "as-stated";
|
|
26
|
+
/** The line under a deposit or refund saying what brings it back, or who claims it. */
|
|
27
|
+
readonly note?: string;
|
|
28
|
+
readonly group: Group;
|
|
29
|
+
readonly mark?: Mark;
|
|
30
|
+
};
|
|
31
|
+
export type Headline = {
|
|
32
|
+
readonly label: string;
|
|
33
|
+
readonly amount: string;
|
|
34
|
+
readonly tone: "spent" | "gained";
|
|
35
|
+
/** Only beside what leaves for someone else, where the fee is the smaller figure and is said once. */
|
|
36
|
+
readonly fee?: string;
|
|
37
|
+
/** What is locked or handed back, beside the headline and never counted in it. */
|
|
38
|
+
readonly held?: {
|
|
39
|
+
readonly label: string;
|
|
40
|
+
readonly amount: string;
|
|
41
|
+
readonly tone: "held" | "stated";
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
/** What the "The transaction does" box says for one reason. */
|
|
45
|
+
export type Evidence = {
|
|
46
|
+
readonly figure?: string;
|
|
47
|
+
readonly lines: ReadonlyArray<string>;
|
|
48
|
+
};
|
|
49
|
+
/** What a certificate does, in words. "Your" only where the wallet holds the key it acts on. */
|
|
50
|
+
export declare const describeCertificate: (certificate: CertificateEffect) => string;
|
|
51
|
+
/** The rows, with each mismatch marked on the row it is about. */
|
|
52
|
+
export declare const ledgerOf: (derived: Derived, reasons?: ReadonlyArray<Reason>) => ReadonlyArray<Row>;
|
|
53
|
+
export declare const isGrouped: (rows: ReadonlyArray<Row>) => boolean;
|
|
54
|
+
export declare const isCollapsed: (rows: ReadonlyArray<Row>) => boolean;
|
|
55
|
+
/** The sheet's grouped order: what arrives, what leaves, what moves nothing. Empty groups are left out. */
|
|
56
|
+
export declare const groupsOf: (rows: ReadonlyArray<Row>) => ReadonlyArray<{
|
|
57
|
+
readonly group: Group;
|
|
58
|
+
readonly rows: ReadonlyArray<Row>;
|
|
59
|
+
}>;
|
|
60
|
+
/**
|
|
61
|
+
* The one large figure. What goes to someone else, where anything does;
|
|
62
|
+
* otherwise what the person ends up with or spends. A deposit and a refund are
|
|
63
|
+
* never counted in it — one comes back and the other is only claimed.
|
|
64
|
+
*/
|
|
65
|
+
export declare const headlineOf: (derived: Derived) => Headline;
|
|
66
|
+
/** The one sentence a match gets, above the buttons. */
|
|
67
|
+
export declare const matchLine: (derived: Derived, rows: ReadonlyArray<Row>) => string;
|
|
68
|
+
/** The opening of the block: what differs, then the reassurance, before any detail. */
|
|
69
|
+
export declare const blockedLine: (reasons: ReadonlyArray<Reason>) => string;
|
|
70
|
+
/** For one reason: the figure the transaction carries, and where it goes or what the link asked instead. */
|
|
71
|
+
export declare const evidenceOf: (reason: Reason, derived: Derived) => Evidence;
|
|
72
|
+
/** The transaction as its outputs, fee and expiry, for the collapsed raw detail. Addresses in full. */
|
|
73
|
+
export declare const rawLines: (derived: Derived) => ReadonlyArray<string>;
|
|
74
|
+
//# sourceMappingURL=ledger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ledger.d.ts","sourceRoot":"","sources":["../src/ledger.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAEL,KAAK,iBAAiB,EAItB,KAAK,MAAM,EACZ,MAAM,yBAAyB,CAAA;AAEhC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAG3C,kHAAkH;AAClH,MAAM,MAAM,IAAI,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAA;AAEjE,MAAM,MAAM,MAAM,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;CAAE,CAAA;AAEnE,MAAM,MAAM,KAAK,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,CAAA;AAEtD,4FAA4F;AAC5F,MAAM,MAAM,IAAI,GAAG,iBAAiB,GAAG,sBAAsB,CAAA;AAE7D,MAAM,MAAM,GAAG,GAAG;IAChB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,KAAK,EAAE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