@cardano-slips/flow 0.0.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/README.md +27 -0
  2. package/dist/address.d.ts +13 -0
  3. package/dist/address.d.ts.map +1 -0
  4. package/dist/address.js +54 -0
  5. package/dist/address.js.map +1 -0
  6. package/dist/balance-error.d.ts +48 -0
  7. package/dist/balance-error.d.ts.map +1 -0
  8. package/dist/balance-error.js +45 -0
  9. package/dist/balance-error.js.map +1 -0
  10. package/dist/balance.d.ts +54 -0
  11. package/dist/balance.d.ts.map +1 -0
  12. package/dist/balance.js +175 -0
  13. package/dist/balance.js.map +1 -0
  14. package/dist/cip30.d.ts +76 -0
  15. package/dist/cip30.d.ts.map +1 -0
  16. package/dist/cip30.js +69 -0
  17. package/dist/cip30.js.map +1 -0
  18. package/dist/complete-error.d.ts +50 -0
  19. package/dist/complete-error.d.ts.map +1 -0
  20. package/dist/complete-error.js +47 -0
  21. package/dist/complete-error.js.map +1 -0
  22. package/dist/complete.d.ts +58 -0
  23. package/dist/complete.d.ts.map +1 -0
  24. package/dist/complete.js +108 -0
  25. package/dist/complete.js.map +1 -0
  26. package/dist/connect.d.ts +45 -0
  27. package/dist/connect.d.ts.map +1 -0
  28. package/dist/connect.js +73 -0
  29. package/dist/connect.js.map +1 -0
  30. package/dist/discovery.d.ts +37 -0
  31. package/dist/discovery.d.ts.map +1 -0
  32. package/dist/discovery.js +71 -0
  33. package/dist/discovery.js.map +1 -0
  34. package/dist/index.d.ts +27 -7
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +15 -1
  37. package/dist/index.js.map +1 -1
  38. package/dist/registry.d.ts +18 -0
  39. package/dist/registry.d.ts.map +1 -0
  40. package/dist/registry.js +15 -0
  41. package/dist/registry.js.map +1 -0
  42. package/dist/resolve.d.ts +11 -0
  43. package/dist/resolve.d.ts.map +1 -0
  44. package/dist/resolve.js +21 -0
  45. package/dist/resolve.js.map +1 -0
  46. package/dist/sign-error.d.ts +62 -0
  47. package/dist/sign-error.d.ts.map +1 -0
  48. package/dist/sign-error.js +42 -0
  49. package/dist/sign-error.js.map +1 -0
  50. package/dist/sign.d.ts +38 -0
  51. package/dist/sign.d.ts.map +1 -0
  52. package/dist/sign.js +79 -0
  53. package/dist/sign.js.map +1 -0
  54. package/dist/tokens.css +133 -0
  55. package/dist/utxo.d.ts +16 -0
  56. package/dist/utxo.d.ts.map +1 -0
  57. package/dist/utxo.js +51 -0
  58. package/dist/utxo.js.map +1 -0
  59. package/dist/wallet-error.d.ts +48 -0
  60. package/dist/wallet-error.d.ts.map +1 -0
  61. package/dist/wallet-error.js +31 -0
  62. package/dist/wallet-error.js.map +1 -0
  63. package/dist/witness.d.ts +23 -0
  64. package/dist/witness.d.ts.map +1 -0
  65. package/dist/witness.js +101 -0
  66. package/dist/witness.js.map +1 -0
  67. package/package.json +10 -5
  68. package/src/address.ts +69 -0
  69. package/src/balance-error.ts +77 -0
  70. package/src/balance.ts +285 -0
  71. package/src/cip30.ts +113 -0
  72. package/src/complete-error.ts +83 -0
  73. package/src/complete.ts +198 -0
  74. package/src/connect.ts +136 -0
  75. package/src/discovery.ts +92 -0
  76. package/src/index.ts +37 -7
  77. package/src/registry.ts +32 -0
  78. package/src/resolve.ts +40 -0
  79. package/src/sign-error.ts +89 -0
  80. package/src/sign.ts +118 -0
  81. package/src/tokens.css +133 -0
  82. package/src/utxo.ts +70 -0
  83. package/src/wallet-error.ts +68 -0
  84. package/src/witness.ts +132 -0
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Why a Slip did not reach the chain, for the failures that belong to the whole
3
+ * path rather than to building, signing or submitting alone. `Blocked` is the
4
+ * one that matters: it is invariant 3 in the error channel, and there is no
5
+ * field on it that lets anyone past.
6
+ */
7
+ import { type ClientErrorCode } from "@cardano-slips/core";
8
+ import type { Reason } from "@cardano-slips/verifier";
9
+ export type CompletionRefusal =
10
+ /** The wallet reported no unspent outputs, so there is nothing to build from. */
11
+ "NoUtxos"
12
+ /** What `getUtxos` answered is not something these bytes can be read as. */
13
+ | "UnreadableUtxos"
14
+ /** The effects could not be derived from the transaction, or compared with the declaration. */
15
+ | "CannotJudge"
16
+ /** The derived effects disagree with what the endpoint declared. Nothing signs after this. */
17
+ | "Blocked"
18
+ /** The caller could not put the effects in front of a person, so nothing may be signed. */
19
+ | "NotShown"
20
+ /** The funds kept moving, and the transaction has been rebuilt as often as it will be. */
21
+ | "OutOfAttempts";
22
+ /**
23
+ * Exhaustive by type: adding a refusal above without listing it here fails to
24
+ * compile, and `test/complete.test.ts` fails if any of them stops being reachable.
25
+ */
26
+ export declare const completionRefusals: Readonly<Record<CompletionRefusal, true>>;
27
+ export declare const slipErrorCodeFor: (refusal: CompletionRefusal) => ClientErrorCode | undefined;
28
+ declare const CompletionError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
29
+ readonly _tag: "CompletionError";
30
+ } & Readonly<A>;
31
+ /**
32
+ * `reasons` is what the transaction actually does against what was declared,
33
+ * for the block to render. There is no way to carry on from one — a mismatch
34
+ * hard-blocks, with no override, no allowlist and no confirmation.
35
+ */
36
+ export declare class CompletionError extends CompletionError_base<{
37
+ readonly refusal: CompletionRefusal;
38
+ readonly detail: string;
39
+ readonly reasons?: ReadonlyArray<Reason>;
40
+ readonly cause?: unknown;
41
+ }> {
42
+ get message(): string;
43
+ get code(): ClientErrorCode | undefined;
44
+ }
45
+ export declare const refuse: (refusal: CompletionRefusal, detail: string, extra?: {
46
+ readonly reasons?: ReadonlyArray<Reason>;
47
+ readonly cause?: unknown;
48
+ }) => CompletionError;
49
+ export {};
50
+ //# sourceMappingURL=complete-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"complete-error.d.ts","sourceRoot":"","sources":["../src/complete-error.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAGrD,MAAM,MAAM,iBAAiB;AAC3B,iFAAiF;AAC/E,SAAS;AACX,4EAA4E;GAC1E,iBAAiB;AACnB,+FAA+F;GAC7F,aAAa;AACf,8FAA8F;GAC5F,SAAS;AACX,2FAA2F;GACzF,UAAU;AACZ,0FAA0F;GACxF,eAAe,CAAA;AAEnB;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,MAAM,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAOxE,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,SAAS,iBAAiB,KAAG,eAAe,GAAG,SAa/E,CAAA;;;;AAED;;;;GAIG;AACH,qBAAa,eAAgB,SAAQ,qBAAoC;IACvE,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAA;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IACxC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CACzB,CAAC;IACA,IAAa,OAAO,IAAI,MAAM,CAE7B;IAED,IAAI,IAAI,IAAI,eAAe,GAAG,SAAS,CAEtC;CACF;AAED,eAAO,MAAM,MAAM,GACjB,SAAS,iBAAiB,EAC1B,QAAQ,MAAM,EACd,QAAO;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,KACjF,eAMC,CAAA"}
@@ -0,0 +1,47 @@
1
+ import { Data } from "effect";
2
+ /**
3
+ * Exhaustive by type: adding a refusal above without listing it here fails to
4
+ * compile, and `test/complete.test.ts` fails if any of them stops being reachable.
5
+ */
6
+ export const completionRefusals = {
7
+ NoUtxos: true,
8
+ UnreadableUtxos: true,
9
+ CannotJudge: true,
10
+ Blocked: true,
11
+ NotShown: true,
12
+ OutOfAttempts: true
13
+ };
14
+ export const slipErrorCodeFor = (refusal) => {
15
+ switch (refusal) {
16
+ case "Blocked":
17
+ return "EFFECTS_MISMATCH";
18
+ case "NoUtxos":
19
+ return "INSUFFICIENT_FUNDS";
20
+ case "CannotJudge":
21
+ return "CANNOT_BALANCE";
22
+ case "UnreadableUtxos":
23
+ case "NotShown":
24
+ case "OutOfAttempts":
25
+ return undefined;
26
+ }
27
+ };
28
+ /**
29
+ * `reasons` is what the transaction actually does against what was declared,
30
+ * for the block to render. There is no way to carry on from one — a mismatch
31
+ * hard-blocks, with no override, no allowlist and no confirmation.
32
+ */
33
+ export class CompletionError extends Data.TaggedError("CompletionError") {
34
+ get message() {
35
+ return this.detail;
36
+ }
37
+ get code() {
38
+ return slipErrorCodeFor(this.refusal);
39
+ }
40
+ }
41
+ export const refuse = (refusal, detail, extra = {}) => new CompletionError({
42
+ refusal,
43
+ detail,
44
+ ...(extra.reasons === undefined ? {} : { reasons: extra.reasons }),
45
+ ...(extra.cause === undefined ? {} : { cause: extra.cause })
46
+ });
47
+ //# sourceMappingURL=complete-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"complete-error.js","sourceRoot":"","sources":["../src/complete-error.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAgB7B;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAA8C;IAC3E,OAAO,EAAE,IAAI;IACb,eAAe,EAAE,IAAI;IACrB,WAAW,EAAE,IAAI;IACjB,OAAO,EAAE,IAAI;IACb,QAAQ,EAAE,IAAI;IACd,aAAa,EAAE,IAAI;CACpB,CAAA;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAA0B,EAA+B,EAAE;IAC1F,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,SAAS;YACZ,OAAO,kBAAkB,CAAA;QAC3B,KAAK,SAAS;YACZ,OAAO,oBAAoB,CAAA;QAC7B,KAAK,aAAa;YAChB,OAAO,gBAAgB,CAAA;QACzB,KAAK,iBAAiB,CAAC;QACvB,KAAK,UAAU,CAAC;QAChB,KAAK,eAAe;YAClB,OAAO,SAAS,CAAA;IACpB,CAAC;AACH,CAAC,CAAA;AAED;;;;GAIG;AACH,MAAM,OAAO,eAAgB,SAAQ,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAKrE;IACA,IAAa,OAAO;QAClB,OAAO,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACvC,CAAC;CACF;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,CACpB,OAA0B,EAC1B,MAAc,EACd,QAAgF,EAAE,EACjE,EAAE,CACnB,IAAI,eAAe,CAAC;IAClB,OAAO;IACP,MAAM;IACN,GAAG,CAAC,KAAK,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;IAClE,GAAG,CAAC,KAAK,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;CAC7D,CAAC,CAAA"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * The whole path: build against what the wallet holds, judge it with the
3
+ * verifier's own engine, sign, submit. When the funds move underneath, every
4
+ * one of those happens again — a rebuilt transaction is a different transaction,
5
+ * and asking for a signature on it without deriving its effects first would put
6
+ * a person's name on something nobody read.
7
+ */
8
+ import type { Intent, Network } from "@cardano-slips/core";
9
+ import { type Effects } from "@cardano-slips/verifier";
10
+ import { Effect } from "effect";
11
+ import { type BalancingParameters } from "./balance.js";
12
+ import type { BalanceError } from "./balance-error.js";
13
+ import type { Cip30Api } from "./cip30.js";
14
+ import { type CompletionError } from "./complete-error.js";
15
+ import type { SigningError } from "./sign-error.js";
16
+ export type Attempt = {
17
+ /** Counting from one, so a rendered "attempt 2 of 3" reads as a person would say it. */
18
+ readonly number: number;
19
+ readonly transactionId: string;
20
+ /** What this transaction does, derived from its own bytes. */
21
+ readonly effects: Effects;
22
+ };
23
+ export type CompletionRequest = {
24
+ readonly api: Cip30Api;
25
+ /** What the endpoint declared, and what the transaction is judged against. */
26
+ readonly intent: Intent;
27
+ readonly network: Network;
28
+ readonly changeAddress: string;
29
+ /**
30
+ * Every address the wallet calls its own, its reward account included. An
31
+ * address missing from here is read as a stranger's, which turns the wallet's
32
+ * own change into an undeclared payment and blocks the Slip.
33
+ */
34
+ readonly userAddresses: ReadonlyArray<Uint8Array>;
35
+ readonly parameters: BalancingParameters;
36
+ readonly rewardBalance?: bigint;
37
+ /** Read once per attempt: a rebuilt transaction gets its own validity window. */
38
+ readonly now?: () => number;
39
+ /** How many times the transaction may be built. Beyond this the funds are moving faster than we can follow. */
40
+ readonly attempts?: number;
41
+ /** Called once per attempt, after the effects are derived and before the wallet is asked to sign. */
42
+ readonly onAttempt?: (attempt: Attempt) => void;
43
+ };
44
+ export type Receipt = {
45
+ readonly transactionId: string;
46
+ readonly effects: Effects;
47
+ /** How many transactions it took, which is how many times the funds moved plus one. */
48
+ readonly attempts: number;
49
+ };
50
+ type Failure = BalanceError | CompletionError | SigningError;
51
+ /**
52
+ * Completes the Slip, or says why not. A submission that failed because an
53
+ * input was spent is the one failure worth repeating: everything else either
54
+ * cannot be helped by a rebuild or is a person having said no.
55
+ */
56
+ export declare const completeIntent: (request: CompletionRequest) => Effect.Effect<Receipt, Failure>;
57
+ export {};
58
+ //# sourceMappingURL=complete.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"complete.d.ts","sourceRoot":"","sources":["../src/complete.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KA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C,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;CAChD,CAAA;AAED,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,uFAAuF;IACvF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAC1B,CAAA;AAED,KAAK,OAAO,GAAG,YAAY,GAAG,eAAe,GAAG,YAAY,CAAA;AAuG5D;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,SAAS,iBAAiB,KAAG,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CA4BtF,CAAA"}
@@ -0,0 +1,108 @@
1
+ import { compare, decodeTransaction, deriveEffects } from "@cardano-slips/verifier";
2
+ import { Effect, Either } from "effect";
3
+ import { balanceIntent } from "./balance.js";
4
+ import { refuse } from "./complete-error.js";
5
+ import { asResolvedInputs } from "./resolve.js";
6
+ import { signTransaction, submitTransaction } from "./sign.js";
7
+ import { readWalletUtxos } from "./utxo.js";
8
+ import { transactionIdOf } from "./witness.js";
9
+ /** Enough rebuilds to outlast an unlucky moment, few enough that nobody is asked forever. */
10
+ const defaultAttempts = 3;
11
+ const fromHex = (hex) => Uint8Array.from({ length: hex.length / 2 }, (_, index) => Number.parseInt(hex.slice(index * 2, index * 2 + 2), 16));
12
+ const walletUtxos = (api) => Effect.gen(function* () {
13
+ const answered = yield* Effect.tryPromise({
14
+ try: () => api.getUtxos(),
15
+ catch: (cause) => refuse("UnreadableUtxos", "The wallet could not say what it holds.", { cause })
16
+ });
17
+ // `null` is CIP-30's own answer for a wallet with nothing to give.
18
+ const hexes = answered ?? [];
19
+ const read = readWalletUtxos(hexes);
20
+ if (Either.isLeft(read)) {
21
+ return yield* Effect.fail(refuse("UnreadableUtxos", `The wallet's unspent outputs could not be read: ${read.left}`));
22
+ }
23
+ if (read.right.length === 0) {
24
+ return yield* Effect.fail(refuse("NoUtxos", "This wallet holds nothing to pay with."));
25
+ }
26
+ return read.right;
27
+ });
28
+ /**
29
+ * One transaction, from the wallet's outputs to a verdict. The judging happens
30
+ * here rather than at the caller so that no path reaches `signTransaction`
31
+ * without having passed it.
32
+ */
33
+ const buildAndJudge = (request, number) => Effect.gen(function* () {
34
+ const utxos = yield* walletUtxos(request.api);
35
+ const now = (request.now ?? Date.now)();
36
+ const built = yield* balanceIntent({
37
+ intent: request.intent,
38
+ network: request.network,
39
+ changeAddress: request.changeAddress,
40
+ utxos,
41
+ parameters: request.parameters,
42
+ ...(request.rewardBalance === undefined ? {} : { rewardBalance: request.rewardBalance }),
43
+ now
44
+ });
45
+ const transaction = decodeTransaction(fromHex(built.cbor));
46
+ if (Either.isLeft(transaction)) {
47
+ return yield* Effect.fail(refuse("CannotJudge", `This transaction could not be read back: ${transaction.left.message}`));
48
+ }
49
+ const effects = deriveEffects({
50
+ transaction: transaction.right,
51
+ userAddresses: request.userAddresses,
52
+ resolvedInputs: asResolvedInputs(utxos),
53
+ protocolParameters: request.parameters
54
+ });
55
+ if (Either.isLeft(effects)) {
56
+ return yield* Effect.fail(refuse("CannotJudge", `What this transaction does could not be worked out: ${effects.left.message}`));
57
+ }
58
+ const verdict = compare({
59
+ effects: effects.right,
60
+ declared: request.intent,
61
+ changeAddress: request.changeAddress,
62
+ now: BigInt(now),
63
+ protocolParameters: request.parameters
64
+ });
65
+ if (Either.isLeft(verdict)) {
66
+ return yield* Effect.fail(refuse("CannotJudge", `This transaction could not be checked against what was declared: ${verdict.left.message}`));
67
+ }
68
+ if (verdict.right._tag === "mismatch") {
69
+ return yield* Effect.fail(refuse("Blocked", "This transaction does not do what the Slip said it would, so it will not be signed.", {
70
+ reasons: verdict.right.reasons
71
+ }));
72
+ }
73
+ const transactionId = yield* transactionIdOf(built.cbor);
74
+ const attempt = { number, transactionId, effects: effects.right };
75
+ // The caller is what puts these effects in front of a person. If that
76
+ // throws, the person has not seen them, so this fails closed rather than
77
+ // carrying on to a signature — and as a refusal rather than a stack trace.
78
+ yield* Effect.try({
79
+ try: () => request.onAttempt?.(attempt),
80
+ catch: (cause) => refuse("NotShown", "This transaction could not be shown, so it will not be signed.", { cause })
81
+ });
82
+ return { cbor: built.cbor, attempt };
83
+ });
84
+ /**
85
+ * Completes the Slip, or says why not. A submission that failed because an
86
+ * input was spent is the one failure worth repeating: everything else either
87
+ * cannot be helped by a rebuild or is a person having said no.
88
+ */
89
+ export const completeIntent = (request) => Effect.gen(function* () {
90
+ const allowed = Math.max(1, request.attempts ?? defaultAttempts);
91
+ for (let number = 1; number <= allowed; number += 1) {
92
+ const { attempt, cbor } = yield* buildAndJudge(request, number);
93
+ const signed = yield* signTransaction({
94
+ api: request.api,
95
+ transaction: cbor,
96
+ transactionId: attempt.transactionId
97
+ });
98
+ const submitted = yield* Effect.either(submitTransaction(request.api, signed));
99
+ if (Either.isRight(submitted)) {
100
+ return { transactionId: submitted.right, effects: attempt.effects, attempts: number };
101
+ }
102
+ if (submitted.left.refusal !== "InputsSpent") {
103
+ return yield* Effect.fail(submitted.left);
104
+ }
105
+ }
106
+ return yield* Effect.fail(refuse("OutOfAttempts", `The wallet's funds moved every time this was built, ${allowed} times over. Try again in a moment.`));
107
+ });
108
+ //# sourceMappingURL=complete.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"complete.js","sourceRoot":"","sources":["../src/complete.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAgB,MAAM,yBAAyB,CAAA;AACjG,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAEvC,OAAO,EAAE,aAAa,EAA4B,MAAM,cAAc,CAAA;AAGtE,OAAO,EAAwB,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAE9D,O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O,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAA;QACvF,CAAC;QACD,IAAI,SAAS,CAAC,IAAI,CAAC,OAAO,KAAK,aAAa,EAAE,CAAC;YAC7C,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;QAC3C,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CACvB,MAAM,CACJ,eAAe,EACf,uDAAuD,OAAO,qCAAqC,CACpG,CACF,CAAA;AACH,CAAC,CAAC,CAAA"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * `enable()` and the three answers a connection is not usable without: the API
3
+ * object, the network, and the change address. Everything downstream of here —
4
+ * UTxOs, balancing, signing — goes through evolution-sdk with this API object
5
+ * (ADR-0004).
6
+ */
7
+ import { type Network } from "@cardano-slips/core";
8
+ import { Effect } from "effect";
9
+ import { type NetworkId } from "./address.js";
10
+ import { type Cip30Api } from "./cip30.js";
11
+ import { type DiscoveredWallet } from "./discovery.js";
12
+ import { type WalletConnectError } from "./wallet-error.js";
13
+ export type ConnectOptions = {
14
+ /** The network the Slip declares. The wallet is held to it, not asked for it. */
15
+ readonly network: Network;
16
+ /** Where `cardano` lives. Defaults to the global object, so a test never needs one. */
17
+ readonly host?: unknown;
18
+ /** CIP extensions to ask for. A wallet may grant fewer, and none of ours are required. */
19
+ readonly extensions?: ReadonlyArray<{
20
+ readonly cip: number;
21
+ }>;
22
+ };
23
+ export type ConnectedWallet = {
24
+ readonly wallet: DiscoveredWallet;
25
+ readonly api: Cip30Api;
26
+ /** The Slip's network, now known to be the wallet's as well. */
27
+ readonly network: Network;
28
+ readonly networkId: NetworkId;
29
+ /** Bech32, ready for a `BuildRequest`. */
30
+ readonly changeAddress: string;
31
+ };
32
+ /**
33
+ * A CIP-19 address separates mainnet from testnet and no further, so this is
34
+ * every network id there is — preprod and preview are one value here. Telling
35
+ * them apart is exactly why a Slip states its network by name (`core/types.ts`).
36
+ */
37
+ export declare const networkIdFor: (network: Network) => NetworkId;
38
+ /**
39
+ * Connects, or says why not. The network check happens here rather than in a
40
+ * component because it decides whether there is a connection at all: a wallet
41
+ * on another chain cannot sign this Slip's transaction, and letting the flow
42
+ * continue only moves the failure to where it costs a person more.
43
+ */
44
+ export declare const connectWallet: (key: string, options: ConnectOptions) => Effect.Effect<ConnectedWallet, WalletConnectError>;
45
+ //# sourceMappingURL=connect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,OAAO,EAAE,KAAK,SAAS,EAAqB,MAAM,cAAc,CAAA;AAChE,OAAO,EAAE,KAAK,QAAQ,EAAuD,MAAM,YAAY,CAAA;AAC/F,OAAO,EAAE,KAAK,gBAAgB,EAA6B,MAAM,gBAAgB,CAAA;AACjF,OAAO,EAAU,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAEnE,MAAM,MAAM,cAAc,GAAG;IAC3B,iFAAiF;IACjF,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,uFAAuF;IACvF,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAA;IACvB,0FAA0F;IAC1F,QAAQ,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC;QAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAC9D,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAA;IACjC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAA;IACtB,gEAAgE;IAChE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAA;IAC7B,0CAA0C;IAC1C,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;CAC/B,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,SAAS,OAAO,KAAG,SAA4C,CAAA;AAkB5F;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GACxB,KAAK,MAAM,EACX,SAAS,cAAc,KACtB,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAsEhD,CAAA"}
@@ -0,0 +1,73 @@
1
+ import { Effect } from "effect";
2
+ import { readWalletAddress } from "./address.js";
3
+ import { describeApiError, isCip30Api, readApiError, REFUSED } from "./cip30.js";
4
+ import { findWallet, injectedUnder } from "./discovery.js";
5
+ import { refuse } from "./wallet-error.js";
6
+ /**
7
+ * A CIP-19 address separates mainnet from testnet and no further, so this is
8
+ * every network id there is — preprod and preview are one value here. Telling
9
+ * them apart is exactly why a Slip states its network by name (`core/types.ts`).
10
+ */
11
+ export const networkIdFor = (network) => (network === "mainnet" ? 1 : 0);
12
+ const networkNames = { 0: "a test network", 1: "mainnet" };
13
+ const call = (key, method, run) => Effect.tryPromise({
14
+ try: run,
15
+ catch: (cause) => {
16
+ const cip30 = readApiError(cause);
17
+ return refuse("Unreadable", key, `${method} failed: ${cip30 === undefined ? String(cause) : describeApiError(cip30)}`, cip30);
18
+ }
19
+ });
20
+ /**
21
+ * Connects, or says why not. The network check happens here rather than in a
22
+ * component because it decides whether there is a connection at all: a wallet
23
+ * on another chain cannot sign this Slip's transaction, and letting the flow
24
+ * continue only moves the failure to where it costs a person more.
25
+ */
26
+ export const connectWallet = (key, options) => Effect.gen(function* () {
27
+ const host = options.host ?? globalThis;
28
+ const wallet = findWallet(key, host);
29
+ if (wallet === undefined) {
30
+ return yield* Effect.fail(injectedUnder(key, host) === undefined
31
+ ? refuse("NotInjected", key, "no wallet is installed under this name")
32
+ : refuse("NotCip30", key, "what is installed under this name does not implement CIP-30"));
33
+ }
34
+ const api = yield* Effect.tryPromise({
35
+ try: () => wallet.provider.enable(options.extensions),
36
+ catch: (cause) => {
37
+ const cip30 = readApiError(cause);
38
+ if (cip30?.code === REFUSED) {
39
+ return refuse("Refused", key, "the connection was declined in the wallet", cip30);
40
+ }
41
+ const detail = cip30 === undefined ? String(cause) : describeApiError(cip30);
42
+ return refuse("EnableFailed", key, `the wallet could not be connected: ${detail}`, cip30);
43
+ }
44
+ });
45
+ // `enable()` is typed to return the API and is under no obligation to.
46
+ if (!isCip30Api(api)) {
47
+ return yield* Effect.fail(refuse("NotCip30", key, "the wallet connected without returning a CIP-30 API"));
48
+ }
49
+ const reported = yield* call(key, "getNetworkId", () => api.getNetworkId());
50
+ if (reported !== 0 && reported !== 1) {
51
+ return yield* Effect.fail(refuse("Unreadable", key, `getNetworkId answered ${String(reported)}`));
52
+ }
53
+ const networkId = reported === 1 ? 1 : 0;
54
+ const hex = yield* call(key, "getChangeAddress", () => api.getChangeAddress());
55
+ const address = yield* readWalletAddress(hex).pipe(Effect.mapError((detail) => refuse("Unreadable", key, `getChangeAddress answered ${detail}`)));
56
+ // Two answers about one wallet. A wallet that gives both cannot be taken at
57
+ // either word, and the disagreement is not the person's to resolve.
58
+ if (address.networkId !== networkId) {
59
+ return yield* Effect.fail(refuse("Unreadable", key, `the wallet reports ${networkNames[networkId]} and its change address is on ${networkNames[address.networkId]}`));
60
+ }
61
+ const expected = networkIdFor(options.network);
62
+ if (networkId !== expected) {
63
+ return yield* Effect.fail(refuse("WrongNetwork", key, `this Slip is on ${options.network} and the wallet is on ${networkNames[networkId]}`));
64
+ }
65
+ return {
66
+ wallet,
67
+ api,
68
+ network: options.network,
69
+ networkId,
70
+ changeAddress: address.bech32
71
+ };
72
+ });
73
+ //# sourceMappingURL=connect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connect.js","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,OAAO,EA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,CAAC,OAAO,yBAAyB,YAAY,CAAC,SAAS,CAAC,EAAE,CACrF,CACF,CAAA;IACH,CAAC;IAED,OAAO;QACL,MAAM;QACN,GAAG;QACH,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,SAAS;QACT,aAAa,EAAE,OAAO,CAAC,MAAM;KAC9B,CAAA;AACH,CAAC,CAAC,CAAA"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * What is injected at `window.cardano`, read on demand. Nothing here touches a
3
+ * browser global at module scope: this SDK is imported by server-rendered pages
4
+ * we do not control, and a module that reads `window` while loading breaks them
5
+ * before any of it runs (ADR-0004).
6
+ */
7
+ import { type Cip30Provider } from "./cip30.js";
8
+ export type DiscoveredWallet = {
9
+ /** The `window.cardano` key. What `connectWallet` is asked for. */
10
+ readonly key: string;
11
+ readonly name: string;
12
+ readonly icon: string | undefined;
13
+ readonly apiVersion: string;
14
+ /** CIP numbers the provider says it supports, before `enable()` negotiates any of them. */
15
+ readonly extensions: ReadonlyArray<number>;
16
+ /** Present only for a wallet in the registry. */
17
+ readonly install: string | undefined;
18
+ readonly provider: Cip30Provider;
19
+ };
20
+ /** Anything with a `cardano` namespace: a `Window`, or a stand-in in a test. */
21
+ export type WalletHost = {
22
+ readonly cardano?: unknown;
23
+ };
24
+ /**
25
+ * Every CIP-30 provider in the namespace, by display name. Returns an empty
26
+ * list where there is no namespace at all — a page with no wallet and a page
27
+ * rendered on a server are the same case to a caller, and neither is an error.
28
+ */
29
+ export declare const discoverWallets: (host?: unknown) => ReadonlyArray<DiscoveredWallet>;
30
+ /**
31
+ * Whatever sits under the key, connector or not. Lets a caller separate a
32
+ * wallet that is not installed from one that is and does not speak CIP-30.
33
+ */
34
+ export declare const injectedUnder: (key: string, host?: unknown) => unknown;
35
+ /** The provider under one key, or `undefined` where nothing usable is there. */
36
+ export declare const findWallet: (key: string, host?: unknown) => DiscoveredWallet | undefined;
37
+ //# sourceMappingURL=discovery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,KAAK,aAAa,EAAmB,MAAM,YAAY,CAAA;AAGhE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,mEAAmE;IACnE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAA;IACjC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,2FAA2F;IAC3F,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IAC1C,iDAAiD;IACjD,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;IACpC,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAA;CACjC,CAAA;AAED,gFAAgF;AAChF,MAAM,MAAM,UAAU,GAAG;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAA;AA6BvD;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,OAAM,OAAoB,KAAG,aAAa,CAAC,gBAAgB,CAoB1F,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,aAAa,GAAI,KAAK,MAAM,EAAE,OAAM,OAAoB,KAAG,OAAmC,CAAA;AAE3G,gFAAgF;AAChF,eAAO,MAAM,UAAU,GAAI,KAAK,MAAM,EAAE,OAAM,OAAoB,KAAG,gBAAgB,GAAG,SAKvF,CAAA"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * What is injected at `window.cardano`, read on demand. Nothing here touches a
3
+ * browser global at module scope: this SDK is imported by server-rendered pages
4
+ * we do not control, and a module that reads `window` while loading breaks them
5
+ * before any of it runs (ADR-0004).
6
+ */
7
+ import { isCip30Provider } from "./cip30.js";
8
+ import { knownWallet } from "./registry.js";
9
+ const namespaceOf = (host) => {
10
+ if (typeof host !== "object" || host === null)
11
+ return undefined;
12
+ const cardano = host.cardano;
13
+ if (typeof cardano !== "object" || cardano === null)
14
+ return undefined;
15
+ return cardano;
16
+ };
17
+ const extensionsOf = (provider) => (provider.supportedExtensions ?? [])
18
+ .filter((extension) => typeof extension?.cip === "number")
19
+ .map((extension) => extension.cip);
20
+ const describe = (key, provider) => {
21
+ const known = knownWallet(key);
22
+ return {
23
+ key,
24
+ // The registry wins over the injected name so one extension reads the same
25
+ // way in every list; an unknown wallet still gets to name itself.
26
+ name: known?.name ?? (provider.name === "" ? key : provider.name),
27
+ icon: typeof provider.icon === "string" && provider.icon !== "" ? provider.icon : undefined,
28
+ apiVersion: provider.apiVersion,
29
+ extensions: extensionsOf(provider),
30
+ install: known?.install,
31
+ provider
32
+ };
33
+ };
34
+ /**
35
+ * Every CIP-30 provider in the namespace, by display name. Returns an empty
36
+ * list where there is no namespace at all — a page with no wallet and a page
37
+ * rendered on a server are the same case to a caller, and neither is an error.
38
+ */
39
+ export const discoverWallets = (host = globalThis) => {
40
+ const namespace = namespaceOf(host);
41
+ if (namespace === undefined)
42
+ return [];
43
+ const found = new Map();
44
+ for (const key of Object.keys(namespace)) {
45
+ const provider = namespace[key];
46
+ if (isCip30Provider(provider))
47
+ found.set(key, describe(key, provider));
48
+ }
49
+ // An extension injecting two keys is one wallet: listing it twice asks the
50
+ // person to choose between a wallet and itself.
51
+ for (const key of [...found.keys()]) {
52
+ const alias = knownWallet(key)?.aliasOf;
53
+ if (alias !== undefined && found.has(alias))
54
+ found.delete(key);
55
+ }
56
+ return [...found.values()].sort((left, right) => left.name.localeCompare(right.name) || left.key.localeCompare(right.key));
57
+ };
58
+ /**
59
+ * Whatever sits under the key, connector or not. Lets a caller separate a
60
+ * wallet that is not installed from one that is and does not speak CIP-30.
61
+ */
62
+ export const injectedUnder = (key, host = globalThis) => namespaceOf(host)?.[key];
63
+ /** The provider under one key, or `undefined` where nothing usable is there. */
64
+ export const findWallet = (key, host = globalThis) => {
65
+ const namespace = namespaceOf(host);
66
+ if (namespace === undefined)
67
+ return undefined;
68
+ const provider = namespace[key];
69
+ return isCip30Provider(provider) ? describe(key, provider) : undefined;
70
+ };
71
+ //# sourceMappingURL=discovery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discovery.js","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAsB,eAAe,EAAE,MAAM,YAAY,CAAA;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAkB3C,MAAM,WAAW,GAAG,CAAC,IAAa,EAAuC,EAAE;IACzE,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,SAAS,CAAA;IAC/D,MAAM,OAAO,GAAI,IAAgC,CAAC,OAAO,CAAA;IACzD,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,SAAS,CAAA;IACrE,OAAO,OAAkC,CAAA;AAC3C,CAAC,CAAA;AAED,MAAM,YAAY,GAAG,CAAC,QAAuB,EAAyB,EAAE,CACtE,CAAC,QAAQ,CAAC,mBAAmB,IAAI,EAAE,CAAC;KACjC,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,OAAO,SAAS,EAAE,GAAG,KAAK,QAAQ,CAAC;KACzD,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;AAEtC,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAE,QAAuB,EAAoB,EAAE;IAC1E,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC,CAAA;IAC9B,OAAO;QACL,GAAG;QACH,2EAA2E;QAC3E,kEAAkE;QAClE,IAAI,EAAE,KAAK,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,C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B,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAC1F,CAAA;AACH,CAAC,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,GAAW,EAAE,OAAgB,UAAU,EAAW,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAA;AAE3G,gFAAgF;AAChF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,GAAW,EAAE,OAAgB,UAAU,EAAgC,EAAE;IAClG,MAAM,SAAS,GAAG,WAAW,CAAC,IAAI,CAAC,CAAA;IACnC,IAAI,SAAS,KAAK,SAAS;QAAE,OAAO,SAAS,CAAA;IAC7C,MAAM,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC,CAAA;IAC/B,OAAO,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;AACxE,CAAC,CAAA"}
package/dist/index.d.ts CHANGED
@@ -1,12 +1,32 @@
1
1
  /**
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
- *
5
- * Two properties hold as the rest of the package arrives. It refuses but does
6
- * not decide — the comparison is `verifier`'s, and a mismatch renders as a
7
- * block with no override path to write. And it does not own the page it is
8
- * dropped into: no fixed positioning, no assumptions about the document, and
9
- * colours only from the custom properties in `tokens.css`.
10
4
  */
11
- export {};
5
+ export type { NetworkId, WalletAddress } from "./address.js";
6
+ export { readWalletAddress } from "./address.js";
7
+ export type { BalancedTransaction, BalanceInputs, BalancingParameters } from "./balance.js";
8
+ export { balanceIntent } from "./balance.js";
9
+ export type { BalanceRefusal } from "./balance-error.js";
10
+ export { BalanceError, balanceRefusals, slipErrorCodeFor as balanceErrorCodeFor } from "./balance-error.js";
11
+ export type { CborHex, Cip30Api, Cip30ApiError, Cip30Provider, Paginate, SignedData } from "./cip30.js";
12
+ 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 { completeIntent } from "./complete.js";
15
+ export type { CompletionRefusal } from "./complete-error.js";
16
+ export { CompletionError, completionRefusals, slipErrorCodeFor as completionErrorCodeFor } from "./complete-error.js";
17
+ export type { ConnectedWallet, ConnectOptions } from "./connect.js";
18
+ export { connectWallet, networkIdFor } from "./connect.js";
19
+ export type { DiscoveredWallet, WalletHost } from "./discovery.js";
20
+ export { discoverWallets, findWallet, injectedUnder } from "./discovery.js";
21
+ export type { KnownWallet } from "./registry.js";
22
+ export { knownWallet, knownWallets } from "./registry.js";
23
+ export { asResolvedInput, asResolvedInputs } from "./resolve.js";
24
+ export type { SignedTransaction, SignRequest } from "./sign.js";
25
+ export { signTransaction, submitTransaction } from "./sign.js";
26
+ export type { SignRefusal } from "./sign-error.js";
27
+ export { signRefusals, SigningError, slipErrorCodeFor as signErrorCodeFor } from "./sign-error.js";
28
+ export { readWalletUtxos } from "./utxo.js";
29
+ export type { ConnectRefusal } from "./wallet-error.js";
30
+ export { connectRefusals, slipErrorCodeFor, WalletConnectError } from "./wallet-error.js";
31
+ export { assembleWitnesses, requireSameBody, transactionIdOf } from "./witness.js";
12
32
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,YAAY,EAAE,SAAS,E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AAE,MAAM,eAAe,CAAA;AACzD,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAChE,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAC/D,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,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,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,2 +1,16 @@
1
- export {};
1
+ export { readWalletAddress } from "./address.js";
2
+ export { balanceIntent } from "./balance.js";
3
+ export { BalanceError, balanceRefusals, slipErrorCodeFor as balanceErrorCodeFor } from "./balance-error.js";
4
+ export { apiErrorNames, describeApiError, isCip30Api, isCip30Provider, readApiError, REFUSED, txSendErrorNames, txSignErrorNames, USER_DECLINED } from "./cip30.js";
5
+ export { completeIntent } from "./complete.js";
6
+ export { CompletionError, completionRefusals, slipErrorCodeFor as completionErrorCodeFor } from "./complete-error.js";
7
+ export { connectWallet, networkIdFor } from "./connect.js";
8
+ export { discoverWallets, findWallet, injectedUnder } from "./discovery.js";
9
+ export { knownWallet, knownWallets } from "./registry.js";
10
+ export { asResolvedInput, asResolvedInputs } from "./resolve.js";
11
+ export { signTransaction, submitTransaction } from "./sign.js";
12
+ export { signRefusals, SigningError, slipErrorCodeFor as signErrorCodeFor } from "./sign-error.js";
13
+ export { readWalletUtxos } from "./utxo.js";
14
+ export { connectRefusals, slipErrorCodeFor, WalletConnectError } from "./wallet-error.js";
15
+ export { assembleWitnesses, requireSameBody, transactionIdOf } from "./witness.js";
2
16
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAEhD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAE5C,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,gBAAgB,IAAI,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAE3G,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,YAAY,EACZ,OAAO,EACP,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACd,MAAM,YAAY,CAAA;AAEnB,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAE9C,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,gBAAgB,IAAI,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AAErH,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAE1D,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAE3E,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AACzD,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAEhE,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAE9D,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,gBAAgB,IAAI,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClG,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"}