@miden-sdk/miden-wallet-adapter-base 0.16.2 → 0.16.3
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/dist/adapter.js.map +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/helpers.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/signer.js.map +1 -1
- package/dist/transaction.js.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +9 -3
- package/__tests__/adapter.test.ts +0 -82
- package/__tests__/errors.test.ts +0 -100
- package/__tests__/helpers.test.ts +0 -39
- package/__tests__/signer.test.ts +0 -20
- package/__tests__/transaction.test.ts +0 -166
- package/adapter.ts +0 -146
- package/dist/__tests__/adapter.test.d.ts +0 -1
- package/dist/__tests__/adapter.test.js +0 -66
- package/dist/__tests__/adapter.test.js.map +0 -1
- package/dist/__tests__/errors.test.d.ts +0 -1
- package/dist/__tests__/errors.test.js +0 -70
- package/dist/__tests__/errors.test.js.map +0 -1
- package/dist/__tests__/helpers.test.d.ts +0 -1
- package/dist/__tests__/helpers.test.js +0 -35
- package/dist/__tests__/helpers.test.js.map +0 -1
- package/dist/__tests__/signer.test.d.ts +0 -1
- package/dist/__tests__/signer.test.js +0 -18
- package/dist/__tests__/signer.test.js.map +0 -1
- package/dist/__tests__/transaction.test.d.ts +0 -1
- package/dist/__tests__/transaction.test.js +0 -113
- package/dist/__tests__/transaction.test.js.map +0 -1
- package/dist/vitest.config.d.ts +0 -2
- package/dist/vitest.config.js +0 -8
- package/dist/vitest.config.js.map +0 -1
- package/docs/@miden-sdk/namespaces/EventEmitter/README.md +0 -24
- package/docs/@miden-sdk/namespaces/EventEmitter/interfaces/EventEmitterStatic.md +0 -17
- package/docs/@miden-sdk/namespaces/EventEmitter/interfaces/ListenerFn.md +0 -25
- package/docs/@miden-sdk/namespaces/EventEmitter/type-aliases/ArgumentMap.md +0 -15
- package/docs/@miden-sdk/namespaces/EventEmitter/type-aliases/EventArgs.md +0 -19
- package/docs/@miden-sdk/namespaces/EventEmitter/type-aliases/EventListener.md +0 -19
- package/docs/@miden-sdk/namespaces/EventEmitter/type-aliases/EventNames.md +0 -15
- package/docs/@miden-sdk/namespaces/EventEmitter/type-aliases/ValidEventTypes.md +0 -17
- package/docs/@miden-sdk/namespaces/EventEmitter/variables/EventEmitter.md +0 -9
- package/docs/README.md +0 -88
- package/docs/classes/BaseMessageSignerWalletAdapter.md +0 -755
- package/docs/classes/BaseSignerWalletAdapter.md +0 -579
- package/docs/classes/BaseWalletAdapter.md +0 -535
- package/docs/classes/ConsumeTransaction.md +0 -93
- package/docs/classes/CustomTransaction.md +0 -93
- package/docs/classes/EventEmitter.md +0 -305
- package/docs/classes/SendTransaction.md +0 -107
- package/docs/classes/Transaction.md +0 -151
- package/docs/classes/WalletAccountError.md +0 -223
- package/docs/classes/WalletAddressError.md +0 -223
- package/docs/classes/WalletConfigError.md +0 -223
- package/docs/classes/WalletConnectionError.md +0 -223
- package/docs/classes/WalletDecryptionError.md +0 -223
- package/docs/classes/WalletDecryptionNotAllowedError.md +0 -223
- package/docs/classes/WalletDisconnectedError.md +0 -223
- package/docs/classes/WalletDisconnectionError.md +0 -223
- package/docs/classes/WalletError.md +0 -244
- package/docs/classes/WalletKeypairError.md +0 -223
- package/docs/classes/WalletLoadError.md +0 -223
- package/docs/classes/WalletNotConnectedError.md +0 -223
- package/docs/classes/WalletNotReadyError.md +0 -223
- package/docs/classes/WalletNotSelectedError.md +0 -223
- package/docs/classes/WalletPrivateDataPermissionError.md +0 -223
- package/docs/classes/WalletRecordsError.md +0 -223
- package/docs/classes/WalletSendTransactionError.md +0 -223
- package/docs/classes/WalletSignMessageError.md +0 -223
- package/docs/classes/WalletSignTransactionError.md +0 -223
- package/docs/classes/WalletTimeoutError.md +0 -223
- package/docs/classes/WalletTransactionError.md +0 -223
- package/docs/classes/WalletWindowBlockedError.md +0 -223
- package/docs/classes/WalletWindowClosedError.md +0 -223
- package/docs/enumerations/AllowedPrivateData.md +0 -37
- package/docs/enumerations/PrivateDataPermission.md +0 -19
- package/docs/enumerations/TransactionType.md +0 -25
- package/docs/enumerations/WalletAdapterNetwork.md +0 -19
- package/docs/enumerations/WalletReadyState.md +0 -49
- package/docs/functions/b64ToU8.md +0 -19
- package/docs/functions/scopePollingDetectionStrategy.md +0 -19
- package/docs/functions/u8ToB64.md +0 -19
- package/docs/interfaces/Asset.md +0 -19
- package/docs/interfaces/IFailedTransactionOutput.md +0 -13
- package/docs/interfaces/MessageSignerWalletAdapterProps.md +0 -293
- package/docs/interfaces/MidenConsumeTransaction.md +0 -37
- package/docs/interfaces/MidenCustomTransaction.md +0 -37
- package/docs/interfaces/MidenSendTransaction.md +0 -43
- package/docs/interfaces/MidenTransaction.md +0 -19
- package/docs/interfaces/SignerWalletAdapterProps.md +0 -149
- package/docs/interfaces/TransactionOutput.md +0 -19
- package/docs/interfaces/WalletAdapterEvents.md +0 -69
- package/docs/interfaces/WalletAdapterProps.md +0 -106
- package/docs/interfaces/WalletTransactionSuccessOutput.md +0 -19
- package/docs/type-aliases/Adapter.md +0 -9
- package/docs/type-aliases/FungibleAssetDetails.md +0 -21
- package/docs/type-aliases/InputNoteDetails.md +0 -45
- package/docs/type-aliases/MessageSignerWalletAdapter.md +0 -15
- package/docs/type-aliases/NoteTypeString.md +0 -9
- package/docs/type-aliases/SignKind.md +0 -9
- package/docs/type-aliases/SignerWalletAdapter.md +0 -15
- package/docs/type-aliases/SupportedTransactionVersions.md +0 -9
- package/docs/type-aliases/TransactionOrVersionedTransaction.md +0 -15
- package/docs/type-aliases/TransactionPayload.md +0 -9
- package/docs/type-aliases/WalletAdapter.md +0 -15
- package/docs/type-aliases/WalletName.md +0 -21
- package/docs/type-aliases/WalletTransactionOutput.md +0 -9
- package/errors.ts +0 -97
- package/helpers.ts +0 -28
- package/index.ts +0 -6
- package/signer.ts +0 -84
- package/transaction.ts +0 -178
- package/tsconfig.json +0 -15
- package/types.ts +0 -93
- package/vitest.config.ts +0 -8
package/adapter.ts
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import EventEmitter from "eventemitter3";
|
|
2
|
-
import type { WalletError } from "./errors";
|
|
3
|
-
import type {
|
|
4
|
-
AllowedPrivateData,
|
|
5
|
-
PrivateDataPermission,
|
|
6
|
-
SupportedTransactionVersions,
|
|
7
|
-
WalletAdapterNetwork,
|
|
8
|
-
} from "./types";
|
|
9
|
-
|
|
10
|
-
export { EventEmitter };
|
|
11
|
-
|
|
12
|
-
export interface WalletAdapterEvents {
|
|
13
|
-
connect(address: string, allowedPrivateData?: AllowedPrivateData): void;
|
|
14
|
-
disconnect(): void;
|
|
15
|
-
error(error: WalletError): void;
|
|
16
|
-
readyStateChange(readyState: WalletReadyState): void;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// WalletName is a nominal type that wallet adapters should use, e.g. `'MyCryptoWallet' as WalletName<'MyCryptoWallet'>`
|
|
20
|
-
// https://medium.com/@KevinBGreene/surviving-the-typescript-ecosystem-branding-and-type-tagging-6cf6e516523d
|
|
21
|
-
export type WalletName<T extends string = string> = T & {
|
|
22
|
-
__brand__: "WalletName";
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export interface WalletAdapterProps<Name extends string = string> {
|
|
26
|
-
name: WalletName<Name>;
|
|
27
|
-
url: string;
|
|
28
|
-
icon: string;
|
|
29
|
-
readyState: WalletReadyState;
|
|
30
|
-
address: string | null;
|
|
31
|
-
publicKey: Uint8Array | null;
|
|
32
|
-
connecting: boolean;
|
|
33
|
-
connected: boolean;
|
|
34
|
-
supportedTransactionVersions: SupportedTransactionVersions;
|
|
35
|
-
|
|
36
|
-
connect(
|
|
37
|
-
privateDataPermission: PrivateDataPermission,
|
|
38
|
-
network: WalletAdapterNetwork,
|
|
39
|
-
allowedPrivateData?: AllowedPrivateData
|
|
40
|
-
): Promise<void>;
|
|
41
|
-
disconnect(): Promise<void>;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export type WalletAdapter<Name extends string = string> =
|
|
45
|
-
WalletAdapterProps<Name> & EventEmitter<WalletAdapterEvents>;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* A wallet's readiness describes a series of states that the wallet can be in,
|
|
49
|
-
* depending on what kind of wallet it is. An installable wallet (eg. a browser
|
|
50
|
-
* extension like Phantom) might be `Installed` if we've found the Phantom API
|
|
51
|
-
* in the global scope, or `NotDetected` otherwise. A loadable, zero-install
|
|
52
|
-
* runtime (eg. Torus Wallet) might simply signal that it's `Loadable`. Use this
|
|
53
|
-
* metadata to personalize the wallet list for each user (eg. to show their
|
|
54
|
-
* installed wallets first).
|
|
55
|
-
*/
|
|
56
|
-
export enum WalletReadyState {
|
|
57
|
-
/**
|
|
58
|
-
* User-installable wallets can typically be detected by scanning for an API
|
|
59
|
-
* that they've injected into the global context. If such an API is present,
|
|
60
|
-
* we consider the wallet to have been installed.
|
|
61
|
-
*/
|
|
62
|
-
Installed = "Installed",
|
|
63
|
-
NotDetected = "NotDetected",
|
|
64
|
-
/**
|
|
65
|
-
* Loadable wallets are always available to you. Since you can load them at
|
|
66
|
-
* any time, it's meaningless to say that they have been detected.
|
|
67
|
-
*/
|
|
68
|
-
Loadable = "Loadable",
|
|
69
|
-
/**
|
|
70
|
-
* If a wallet is not supported on a given platform (eg. server-rendering, or
|
|
71
|
-
* mobile) then it will stay in the `Unsupported` state.
|
|
72
|
-
*/
|
|
73
|
-
Unsupported = "Unsupported",
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export abstract class BaseWalletAdapter<Name extends string = string>
|
|
77
|
-
extends EventEmitter<WalletAdapterEvents>
|
|
78
|
-
implements WalletAdapter<Name>
|
|
79
|
-
{
|
|
80
|
-
abstract name: WalletName<Name>;
|
|
81
|
-
abstract url: string;
|
|
82
|
-
abstract icon: string;
|
|
83
|
-
abstract readyState: WalletReadyState;
|
|
84
|
-
abstract address: string | null;
|
|
85
|
-
abstract publicKey: Uint8Array | null;
|
|
86
|
-
abstract connecting: boolean;
|
|
87
|
-
abstract supportedTransactionVersions: SupportedTransactionVersions;
|
|
88
|
-
|
|
89
|
-
get connected() {
|
|
90
|
-
return !!this.address;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
abstract connect(
|
|
94
|
-
privateDataPermission: PrivateDataPermission,
|
|
95
|
-
network: WalletAdapterNetwork,
|
|
96
|
-
allowedPrivateData?: AllowedPrivateData
|
|
97
|
-
): Promise<void>;
|
|
98
|
-
abstract disconnect(): Promise<void>;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export function scopePollingDetectionStrategy(detect: () => boolean): void {
|
|
102
|
-
// Early return when server-side rendering
|
|
103
|
-
if (typeof window === "undefined" || typeof document === "undefined") return;
|
|
104
|
-
|
|
105
|
-
const disposers: (() => void)[] = [];
|
|
106
|
-
|
|
107
|
-
function detectAndDispose() {
|
|
108
|
-
const detected = detect();
|
|
109
|
-
if (detected) {
|
|
110
|
-
for (const dispose of disposers) {
|
|
111
|
-
dispose();
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// Strategy #1: Try detecting every second.
|
|
117
|
-
const interval =
|
|
118
|
-
// TODO: #334 Replace with idle callback strategy.
|
|
119
|
-
setInterval(detectAndDispose, 1000);
|
|
120
|
-
disposers.push(() => clearInterval(interval));
|
|
121
|
-
|
|
122
|
-
// Strategy #2: Detect as soon as the DOM becomes 'ready'/'interactive'.
|
|
123
|
-
if (
|
|
124
|
-
// Implies that `DOMContentLoaded` has not yet fired.
|
|
125
|
-
document.readyState === "loading"
|
|
126
|
-
) {
|
|
127
|
-
document.addEventListener("DOMContentLoaded", detectAndDispose, {
|
|
128
|
-
once: true,
|
|
129
|
-
});
|
|
130
|
-
disposers.push(() =>
|
|
131
|
-
document.removeEventListener("DOMContentLoaded", detectAndDispose)
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// Strategy #3: Detect after the `window` has fully loaded.
|
|
136
|
-
if (
|
|
137
|
-
// If the `complete` state has been reached, we're too late.
|
|
138
|
-
document.readyState !== "complete"
|
|
139
|
-
) {
|
|
140
|
-
window.addEventListener("load", detectAndDispose, { once: true });
|
|
141
|
-
disposers.push(() => window.removeEventListener("load", detectAndDispose));
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// Strategy #4: Detect synchronously, now.
|
|
145
|
-
detectAndDispose();
|
|
146
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|
2
|
-
import { WalletReadyState, BaseWalletAdapter, scopePollingDetectionStrategy, } from "../adapter";
|
|
3
|
-
describe("WalletReadyState enum", () => {
|
|
4
|
-
it("has correct values", () => {
|
|
5
|
-
expect(WalletReadyState.Installed).toBe("Installed");
|
|
6
|
-
expect(WalletReadyState.NotDetected).toBe("NotDetected");
|
|
7
|
-
expect(WalletReadyState.Loadable).toBe("Loadable");
|
|
8
|
-
expect(WalletReadyState.Unsupported).toBe("Unsupported");
|
|
9
|
-
});
|
|
10
|
-
});
|
|
11
|
-
describe("BaseWalletAdapter", () => {
|
|
12
|
-
// Concrete subclass for testing
|
|
13
|
-
class TestAdapter extends BaseWalletAdapter {
|
|
14
|
-
name = "Test";
|
|
15
|
-
url = "https://test.com";
|
|
16
|
-
icon = "icon";
|
|
17
|
-
readyState = WalletReadyState.Installed;
|
|
18
|
-
address = null;
|
|
19
|
-
publicKey = null;
|
|
20
|
-
connecting = false;
|
|
21
|
-
supportedTransactionVersions = null;
|
|
22
|
-
async connect() { }
|
|
23
|
-
async disconnect() { }
|
|
24
|
-
}
|
|
25
|
-
it("connected returns true when address is set", () => {
|
|
26
|
-
const adapter = new TestAdapter();
|
|
27
|
-
adapter.address = "0xabc";
|
|
28
|
-
expect(adapter.connected).toBe(true);
|
|
29
|
-
});
|
|
30
|
-
it("connected returns false when address is null", () => {
|
|
31
|
-
const adapter = new TestAdapter();
|
|
32
|
-
expect(adapter.connected).toBe(false);
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
describe("scopePollingDetectionStrategy", () => {
|
|
36
|
-
beforeEach(() => {
|
|
37
|
-
vi.useFakeTimers();
|
|
38
|
-
});
|
|
39
|
-
afterEach(() => {
|
|
40
|
-
vi.useRealTimers();
|
|
41
|
-
});
|
|
42
|
-
it("calls detect immediately and cleans up on detection", () => {
|
|
43
|
-
const detect = vi.fn().mockReturnValue(true);
|
|
44
|
-
scopePollingDetectionStrategy(detect);
|
|
45
|
-
expect(detect).toHaveBeenCalled();
|
|
46
|
-
});
|
|
47
|
-
it("sets up polling interval when not immediately detected", () => {
|
|
48
|
-
let callCount = 0;
|
|
49
|
-
const detect = vi.fn(() => {
|
|
50
|
-
callCount++;
|
|
51
|
-
return callCount >= 3;
|
|
52
|
-
});
|
|
53
|
-
scopePollingDetectionStrategy(detect);
|
|
54
|
-
// First call is immediate (returns false)
|
|
55
|
-
expect(detect).toHaveBeenCalledTimes(1);
|
|
56
|
-
// Advance timer to trigger interval
|
|
57
|
-
vi.advanceTimersByTime(1000);
|
|
58
|
-
expect(detect).toHaveBeenCalledTimes(2);
|
|
59
|
-
vi.advanceTimersByTime(1000);
|
|
60
|
-
expect(detect).toHaveBeenCalledTimes(3);
|
|
61
|
-
// After detection (callCount >= 3), interval should be cleared
|
|
62
|
-
vi.advanceTimersByTime(1000);
|
|
63
|
-
expect(detect).toHaveBeenCalledTimes(3);
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
//# sourceMappingURL=adapter.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.test.js","sourceRoot":"","sources":["../../__tests__/adapter.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EACL,gBA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qB,CAAC,CAAC,CAAC,CAAC;QAExC,+DAA+D;QAC/D,EAAE,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;QAC7B,MAAM,CAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { WalletError, WalletNotReadyError, WalletLoadError, WalletConfigError, WalletConnectionError, WalletNotSelectedError, WalletDisconnectedError, WalletDisconnectionError, WalletAccountError, WalletAddressError, WalletKeypairError, WalletNotConnectedError, WalletSendTransactionError, WalletSignMessageError, WalletSignTransactionError, WalletTimeoutError, WalletWindowBlockedError, WalletWindowClosedError, WalletDecryptionNotAllowedError, WalletPrivateDataPermissionError, WalletDecryptionError, WalletRecordsError, WalletTransactionError, } from "../errors";
|
|
3
|
-
const errorClasses = [
|
|
4
|
-
{ Class: WalletNotReadyError, name: "WalletNotReadyError" },
|
|
5
|
-
{ Class: WalletLoadError, name: "WalletLoadError" },
|
|
6
|
-
{ Class: WalletConfigError, name: "WalletConfigError" },
|
|
7
|
-
{ Class: WalletConnectionError, name: "WalletConnectionError" },
|
|
8
|
-
{ Class: WalletNotSelectedError, name: "WalletNotSelectedError" },
|
|
9
|
-
{ Class: WalletDisconnectedError, name: "WalletDisconnectedError" },
|
|
10
|
-
{ Class: WalletDisconnectionError, name: "WalletDisconnectionError" },
|
|
11
|
-
{ Class: WalletAccountError, name: "WalletAccountError" },
|
|
12
|
-
{ Class: WalletAddressError, name: "WalletAddressError" },
|
|
13
|
-
{ Class: WalletKeypairError, name: "WalletKeypairError" },
|
|
14
|
-
{ Class: WalletNotConnectedError, name: "WalletNotConnectedError" },
|
|
15
|
-
{ Class: WalletSendTransactionError, name: "WalletSendTransactionError" },
|
|
16
|
-
{ Class: WalletSignMessageError, name: "WalletSignMessageError" },
|
|
17
|
-
{ Class: WalletSignTransactionError, name: "WalletSignTransactionError" },
|
|
18
|
-
{ Class: WalletTimeoutError, name: "WalletTimeoutError" },
|
|
19
|
-
{ Class: WalletWindowBlockedError, name: "WalletWindowBlockedError" },
|
|
20
|
-
{ Class: WalletWindowClosedError, name: "WalletWindowClosedError" },
|
|
21
|
-
{
|
|
22
|
-
Class: WalletDecryptionNotAllowedError,
|
|
23
|
-
name: "WalletDecryptionNotAllowedError",
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
Class: WalletPrivateDataPermissionError,
|
|
27
|
-
name: "WalletPrivateDataPermissionError",
|
|
28
|
-
},
|
|
29
|
-
{ Class: WalletDecryptionError, name: "WalletDecryptionError" },
|
|
30
|
-
{ Class: WalletRecordsError, name: "WalletRecordsError" },
|
|
31
|
-
{ Class: WalletTransactionError, name: "WalletTransactionError" },
|
|
32
|
-
];
|
|
33
|
-
describe("WalletError", () => {
|
|
34
|
-
it("extends Error", () => {
|
|
35
|
-
const err = new WalletError("test message");
|
|
36
|
-
expect(err).toBeInstanceOf(Error);
|
|
37
|
-
expect(err).toBeInstanceOf(WalletError);
|
|
38
|
-
});
|
|
39
|
-
it("sets message property", () => {
|
|
40
|
-
const err = new WalletError("my message");
|
|
41
|
-
expect(err.message).toBe("my message");
|
|
42
|
-
});
|
|
43
|
-
it("stores inner error", () => {
|
|
44
|
-
const inner = new Error("inner");
|
|
45
|
-
const err = new WalletError("outer", inner);
|
|
46
|
-
expect(err.error).toBe(inner);
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
describe("error subclasses", () => {
|
|
50
|
-
for (const { Class, name } of errorClasses) {
|
|
51
|
-
describe(name, () => {
|
|
52
|
-
it("extends WalletError and Error", () => {
|
|
53
|
-
const err = new Class();
|
|
54
|
-
expect(err).toBeInstanceOf(WalletError);
|
|
55
|
-
expect(err).toBeInstanceOf(Error);
|
|
56
|
-
});
|
|
57
|
-
it("has correct name property", () => {
|
|
58
|
-
const err = new Class();
|
|
59
|
-
expect(err.name).toBe(name);
|
|
60
|
-
});
|
|
61
|
-
it("stores inner error", () => {
|
|
62
|
-
const inner = new Error("cause");
|
|
63
|
-
const err = new Class("msg", inner);
|
|
64
|
-
expect(err.error).toBe(inner);
|
|
65
|
-
expect(err.message).toBe("msg");
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
//# sourceMappingURL=errors.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.test.js","sourceRoot":"","sources":["../../__tests__/errors.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,EACxB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EACvB,0BAA0B,EAC1B,sBAAsB,EACtB,0BAA0B,EAC1B,kBAAkB,EAClB,wBAAwB,EACxB,uBAAuB,EACvB,+BAA+B,EAC/B,gCAAgC,EAChC,qBAAqB,EACrB,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,WAAW,CAAC;AAEnB,MAAM,YAAY,GAAG;IACnB,EAAE,KAAK,EAAE,mBAAmB,EAAE,IAAI,EAAE,qBAAqB,EAAE;IAC3D,EAAE,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,iBAAiB,EAAE;IACnD,EAAE,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,mBAAmB,EAAE;IACvD,EAAE,KAAK,EAAE,qBAAqB,EAAE,IAAI,EAAE,uBAAuB,EAAE;IAC/D,EAAE,KAAK,EAAE,sBAAsB,EAAE,IAAI,EAAE,wBAAwB,EAAE;IACjE,EAAE,KAAK,EAAE,uBAAuB,E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AAC,IAAI,CAAC,CAAC;YAC9B,CAAC,CAAC,CAAC;YAEH,EAAE,CAAC,oBAAoB,EAAE,GAAG,EAAE;gBAC5B,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;gBACjC,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;gBACpC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBAC9B,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAClC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { u8ToB64, b64ToU8 } from "../helpers";
|
|
3
|
-
describe("u8ToB64", () => {
|
|
4
|
-
it("encodes a known value correctly", () => {
|
|
5
|
-
const bytes = new Uint8Array([72, 101, 108, 108, 111]); // "Hello"
|
|
6
|
-
expect(u8ToB64(bytes)).toBe("SGVsbG8=");
|
|
7
|
-
});
|
|
8
|
-
it("encodes an empty array", () => {
|
|
9
|
-
expect(u8ToB64(new Uint8Array([]))).toBe("");
|
|
10
|
-
});
|
|
11
|
-
});
|
|
12
|
-
describe("b64ToU8", () => {
|
|
13
|
-
it("decodes a known value correctly", () => {
|
|
14
|
-
const result = b64ToU8("SGVsbG8=");
|
|
15
|
-
expect(result).toEqual(new Uint8Array([72, 101, 108, 108, 111]));
|
|
16
|
-
});
|
|
17
|
-
it("decodes an empty string", () => {
|
|
18
|
-
expect(b64ToU8("")).toEqual(new Uint8Array([]));
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
describe("roundtrip", () => {
|
|
22
|
-
it("encode then decode returns original bytes", () => {
|
|
23
|
-
const original = new Uint8Array([0, 1, 127, 128, 255]);
|
|
24
|
-
const decoded = b64ToU8(u8ToB64(original));
|
|
25
|
-
expect(decoded).toEqual(original);
|
|
26
|
-
});
|
|
27
|
-
it("handles a large array (256 bytes)", () => {
|
|
28
|
-
const original = new Uint8Array(256);
|
|
29
|
-
for (let i = 0; i < 256; i++)
|
|
30
|
-
original[i] = i;
|
|
31
|
-
const decoded = b64ToU8(u8ToB64(original));
|
|
32
|
-
expect(decoded).toEqual(original);
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
//# sourceMappingURL=helpers.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.test.js","sourceRoot":"","sources":["../../__tests__/helpers.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE9C,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;IACvB,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE;QACzC,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU;QAClE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wBAAwB,EAAE,GAAG,EAAE;QAChC,MAAM,CAAC,OAAO,CAAC,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;IACvB,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE;Q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|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
describe("GuardianInfo", () => {
|
|
3
|
-
it("has the agreed shape", () => {
|
|
4
|
-
const g = {
|
|
5
|
-
isGuardianAccount: false,
|
|
6
|
-
guardianEndpoint: null,
|
|
7
|
-
guardianProvider: null,
|
|
8
|
-
guardianSyncStatus: null,
|
|
9
|
-
};
|
|
10
|
-
expect(Object.keys(g).sort()).toEqual([
|
|
11
|
-
"guardianEndpoint",
|
|
12
|
-
"guardianProvider",
|
|
13
|
-
"guardianSyncStatus",
|
|
14
|
-
"isGuardianAccount",
|
|
15
|
-
]);
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
//# sourceMappingURL=signer.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"signer.test.js","sourceRoot":"","sources":["../../__tests__/signer.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAG9C,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,EAAE,CAAC,sBAAsB,EAAE,GAAG,EAAE;QAC9B,MAAM,CAAC,GAAiB;YACtB,iBAAiB,EAAE,KAAK;YACxB,gBAAgB,EAAE,IAAI;YACtB,gBAAgB,EAAE,IAAI;YACtB,kBAAkB,EAAE,IAAI;SACzB,CAAC;QAEF,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC;YACpC,kBAAkB;YAClB,kBAAkB;YAClB,oBAAoB;YACpB,mBAAmB;SACpB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi } from "vitest";
|
|
2
|
-
import { SendTransaction, ConsumeTransaction, CustomTransaction, Transaction, TransactionType, } from "../transaction";
|
|
3
|
-
import { u8ToB64 } from "../helpers";
|
|
4
|
-
describe("TransactionType enum", () => {
|
|
5
|
-
it("has correct values", () => {
|
|
6
|
-
expect(TransactionType.Send).toBe("send");
|
|
7
|
-
expect(TransactionType.Consume).toBe("consume");
|
|
8
|
-
expect(TransactionType.Custom).toBe("custom");
|
|
9
|
-
});
|
|
10
|
-
});
|
|
11
|
-
describe("SendTransaction", () => {
|
|
12
|
-
it("sets all fields correctly", () => {
|
|
13
|
-
const tx = new SendTransaction("sender-addr", "recipient-addr", "faucet-123", "public", 1000);
|
|
14
|
-
expect(tx.senderAddress).toBe("sender-addr");
|
|
15
|
-
expect(tx.recipientAddress).toBe("recipient-addr");
|
|
16
|
-
expect(tx.faucetId).toBe("faucet-123");
|
|
17
|
-
expect(tx.noteType).toBe("public");
|
|
18
|
-
expect(tx.amount).toBe(1000);
|
|
19
|
-
expect(tx.recallBlocks).toBeUndefined();
|
|
20
|
-
});
|
|
21
|
-
it("sets optional recallBlocks", () => {
|
|
22
|
-
const tx = new SendTransaction("sender", "recipient", "faucet", "private", 500, 10);
|
|
23
|
-
expect(tx.recallBlocks).toBe(10);
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
describe("ConsumeTransaction", () => {
|
|
27
|
-
it("sets fields correctly", () => {
|
|
28
|
-
const tx = new ConsumeTransaction("faucet-1", "note-1", "public", 100);
|
|
29
|
-
expect(tx.faucetId).toBe("faucet-1");
|
|
30
|
-
expect(tx.noteId).toBe("note-1");
|
|
31
|
-
expect(tx.noteType).toBe("public");
|
|
32
|
-
expect(tx.amount).toBe(100);
|
|
33
|
-
expect(tx.noteBytes).toBeUndefined();
|
|
34
|
-
});
|
|
35
|
-
it("converts noteBytes Uint8Array to base64", () => {
|
|
36
|
-
const bytes = new Uint8Array([1, 2, 3]);
|
|
37
|
-
const tx = new ConsumeTransaction("faucet", "note", "private", 50, bytes);
|
|
38
|
-
expect(tx.noteBytes).toBe(u8ToB64(bytes));
|
|
39
|
-
});
|
|
40
|
-
it("leaves noteBytes undefined when not provided", () => {
|
|
41
|
-
const tx = new ConsumeTransaction("faucet", "note", "public", 50);
|
|
42
|
-
expect(tx.noteBytes).toBeUndefined();
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
describe("CustomTransaction", () => {
|
|
46
|
-
it("serializes transactionRequest to base64", () => {
|
|
47
|
-
const mockBytes = new Uint8Array([10, 20, 30]);
|
|
48
|
-
const mockRequest = {
|
|
49
|
-
serialize: vi.fn().mockReturnValue(mockBytes),
|
|
50
|
-
};
|
|
51
|
-
const tx = new CustomTransaction("addr", "recipient", mockRequest);
|
|
52
|
-
expect(mockRequest.serialize).toHaveBeenCalled();
|
|
53
|
-
expect(tx.transactionRequest).toBe(u8ToB64(mockBytes));
|
|
54
|
-
expect(tx.address).toBe("addr");
|
|
55
|
-
expect(tx.recipientAddress).toBe("recipient");
|
|
56
|
-
});
|
|
57
|
-
it("sets optional inputNoteIds", () => {
|
|
58
|
-
const mockRequest = {
|
|
59
|
-
serialize: vi.fn().mockReturnValue(new Uint8Array([1])),
|
|
60
|
-
};
|
|
61
|
-
const tx = new CustomTransaction("addr", "recipient", mockRequest, [
|
|
62
|
-
"id1",
|
|
63
|
-
"id2",
|
|
64
|
-
]);
|
|
65
|
-
expect(tx.inputNoteIds).toEqual(["id1", "id2"]);
|
|
66
|
-
});
|
|
67
|
-
it("converts importNotes from Uint8Array[] to base64 strings", () => {
|
|
68
|
-
const mockRequest = {
|
|
69
|
-
serialize: vi.fn().mockReturnValue(new Uint8Array([1])),
|
|
70
|
-
};
|
|
71
|
-
const noteBytes = [new Uint8Array([4, 5]), new Uint8Array([6, 7])];
|
|
72
|
-
const tx = new CustomTransaction("addr", "recipient", mockRequest, ["id1"], noteBytes);
|
|
73
|
-
expect(tx.importNotes).toEqual([
|
|
74
|
-
u8ToB64(noteBytes[0]),
|
|
75
|
-
u8ToB64(noteBytes[1]),
|
|
76
|
-
]);
|
|
77
|
-
});
|
|
78
|
-
it("leaves optional fields undefined when not provided", () => {
|
|
79
|
-
const mockRequest = {
|
|
80
|
-
serialize: vi.fn().mockReturnValue(new Uint8Array([1])),
|
|
81
|
-
};
|
|
82
|
-
const tx = new CustomTransaction("addr", "recipient", mockRequest);
|
|
83
|
-
expect(tx.inputNoteIds).toBeUndefined();
|
|
84
|
-
expect(tx.importNotes).toBeUndefined();
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
describe("Transaction factory", () => {
|
|
88
|
-
it("createSendTransaction returns correct type and payload", () => {
|
|
89
|
-
const tx = Transaction.createSendTransaction("sender", "recipient", "faucet", "public", 100);
|
|
90
|
-
expect(tx.type).toBe(TransactionType.Send);
|
|
91
|
-
expect(tx.payload).toBeInstanceOf(SendTransaction);
|
|
92
|
-
const payload = tx.payload;
|
|
93
|
-
expect(payload.senderAddress).toBe("sender");
|
|
94
|
-
expect(payload.amount).toBe(100);
|
|
95
|
-
});
|
|
96
|
-
it("createConsumeTransaction returns correct type and payload", () => {
|
|
97
|
-
const tx = Transaction.createConsumeTransaction("faucet", "note-id", "private", 200);
|
|
98
|
-
expect(tx.type).toBe(TransactionType.Consume);
|
|
99
|
-
expect(tx.payload).toBeInstanceOf(ConsumeTransaction);
|
|
100
|
-
const payload = tx.payload;
|
|
101
|
-
expect(payload.faucetId).toBe("faucet");
|
|
102
|
-
expect(payload.noteId).toBe("note-id");
|
|
103
|
-
});
|
|
104
|
-
it("createCustomTransaction returns correct type and payload", () => {
|
|
105
|
-
const mockRequest = {
|
|
106
|
-
serialize: vi.fn().mockReturnValue(new Uint8Array([1, 2])),
|
|
107
|
-
};
|
|
108
|
-
const tx = Transaction.createCustomTransaction("addr", "recipient", mockRequest);
|
|
109
|
-
expect(tx.type).toBe(TransactionType.Custom);
|
|
110
|
-
expect(tx.payload).toBeInstanceOf(CustomTransaction);
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
//# sourceMappingURL=transaction.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.test.js","sourceRoot":"","sources":["../../__tests__/transaction.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,WAAW,EACX,eAAe,GAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,EAAE,CAAC,oBAAoB,EAAE,GAAG,EAAE;QAC5B,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC1C,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAChD,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,EAAE,CAAC,2BAA2B,EAAE,GAAG,EAAE;QACnC,MAAM,EAAE,GAAG,IAAI,eAAe,CAC5B,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,QAAQ,EACR,IAAI,CACL,CAAC;QACF,MAAM,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC7C,MAAM,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACnD,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACvC,MAAM,CAAC,EAAE,C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AAC,kBAAkB,CAAC,CAAC;QACtD,MAAM,OAAO,GAAG,EAAE,CAAC,OAA6B,CAAC;QACjD,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACxC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,0DAA0D,EAAE,GAAG,EAAE;QAClE,MAAM,WAAW,GAAG;YAClB,SAAS,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;SACpD,CAAC;QACT,MAAM,EAAE,GAAG,WAAW,CAAC,uBAAuB,CAC5C,MAAM,EACN,WAAW,EACX,WAAW,CACZ,CAAC;QACF,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;QAC7C,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/vitest.config.d.ts
DELETED
package/dist/vitest.config.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.config.js","sourceRoot":"","sources":["../vitest.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,eAAe,YAAY,CAAC;IAC1B,IAAI,EAAE;QACJ,WAAW,EAAE,OAAO;QACpB,OAAO,EAAE,IAAI;KACd;CACF,CAAC,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
[**@miden-sdk/miden-wallet-adapter-base**](../../../README.md)
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[@miden-sdk/miden-wallet-adapter-base](../../../README.md) / EventEmitter
|
|
6
|
-
|
|
7
|
-
# EventEmitter
|
|
8
|
-
|
|
9
|
-
## Interfaces
|
|
10
|
-
|
|
11
|
-
- [EventEmitterStatic](interfaces/EventEmitterStatic.md)
|
|
12
|
-
- [ListenerFn](interfaces/ListenerFn.md)
|
|
13
|
-
|
|
14
|
-
## Type Aliases
|
|
15
|
-
|
|
16
|
-
- [ArgumentMap](type-aliases/ArgumentMap.md)
|
|
17
|
-
- [EventArgs](type-aliases/EventArgs.md)
|
|
18
|
-
- [EventListener](type-aliases/EventListener.md)
|
|
19
|
-
- [EventNames](type-aliases/EventNames.md)
|
|
20
|
-
- [ValidEventTypes](type-aliases/ValidEventTypes.md)
|
|
21
|
-
|
|
22
|
-
## Variables
|
|
23
|
-
|
|
24
|
-
- [EventEmitter](variables/EventEmitter.md)
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
[**@miden-sdk/miden-wallet-adapter-base**](../../../../README.md)
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[@miden-sdk/miden-wallet-adapter-base](../../../../README.md) / [EventEmitter](../README.md) / EventEmitterStatic
|
|
6
|
-
|
|
7
|
-
# Interface: EventEmitterStatic
|
|
8
|
-
|
|
9
|
-
## Constructors
|
|
10
|
-
|
|
11
|
-
### Constructor
|
|
12
|
-
|
|
13
|
-
> **new EventEmitterStatic**\<`EventTypes`, `Context`\>(): [`EventEmitter`](../../../../classes/EventEmitter.md)\<`EventTypes`, `Context`\>
|
|
14
|
-
|
|
15
|
-
#### Returns
|
|
16
|
-
|
|
17
|
-
[`EventEmitter`](../../../../classes/EventEmitter.md)\<`EventTypes`, `Context`\>
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
[**@miden-sdk/miden-wallet-adapter-base**](../../../../README.md)
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[@miden-sdk/miden-wallet-adapter-base](../../../../README.md) / [EventEmitter](../README.md) / ListenerFn
|
|
6
|
-
|
|
7
|
-
# Interface: ListenerFn()\<Args\>
|
|
8
|
-
|
|
9
|
-
## Type Parameters
|
|
10
|
-
|
|
11
|
-
### Args
|
|
12
|
-
|
|
13
|
-
`Args` *extends* `any`[] = `any`[]
|
|
14
|
-
|
|
15
|
-
> **ListenerFn**(...`args`): `void`
|
|
16
|
-
|
|
17
|
-
## Parameters
|
|
18
|
-
|
|
19
|
-
### args
|
|
20
|
-
|
|
21
|
-
...`Args`
|
|
22
|
-
|
|
23
|
-
## Returns
|
|
24
|
-
|
|
25
|
-
`void`
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
[**@miden-sdk/miden-wallet-adapter-base**](../../../../README.md)
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[@miden-sdk/miden-wallet-adapter-base](../../../../README.md) / [EventEmitter](../README.md) / ArgumentMap
|
|
6
|
-
|
|
7
|
-
# Type Alias: ArgumentMap\<T\>
|
|
8
|
-
|
|
9
|
-
> **ArgumentMap**\<`T`\> = `{ [K in keyof T]: T[K] extends (args: any[]) => void ? Parameters<T[K]> : T[K] extends any[] ? T[K] : any[] }`
|
|
10
|
-
|
|
11
|
-
## Type Parameters
|
|
12
|
-
|
|
13
|
-
### T
|
|
14
|
-
|
|
15
|
-
`T` *extends* `object`
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
[**@miden-sdk/miden-wallet-adapter-base**](../../../../README.md)
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[@miden-sdk/miden-wallet-adapter-base](../../../../README.md) / [EventEmitter](../README.md) / EventArgs
|
|
6
|
-
|
|
7
|
-
# Type Alias: EventArgs\<T, K\>
|
|
8
|
-
|
|
9
|
-
> **EventArgs**\<`T`, `K`\> = `Parameters`\<[`EventListener`](EventListener.md)\<`T`, `K`\>\>
|
|
10
|
-
|
|
11
|
-
## Type Parameters
|
|
12
|
-
|
|
13
|
-
### T
|
|
14
|
-
|
|
15
|
-
`T` *extends* [`ValidEventTypes`](ValidEventTypes.md)
|
|
16
|
-
|
|
17
|
-
### K
|
|
18
|
-
|
|
19
|
-
`K` *extends* [`EventNames`](EventNames.md)\<`T`\>
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
[**@miden-sdk/miden-wallet-adapter-base**](../../../../README.md)
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[@miden-sdk/miden-wallet-adapter-base](../../../../README.md) / [EventEmitter](../README.md) / EventListener
|
|
6
|
-
|
|
7
|
-
# Type Alias: EventListener\<T, K\>
|
|
8
|
-
|
|
9
|
-
> **EventListener**\<`T`, `K`\> = `T` *extends* `string` \| `symbol` ? (...`args`) => `void` : (...`args`) => `void`
|
|
10
|
-
|
|
11
|
-
## Type Parameters
|
|
12
|
-
|
|
13
|
-
### T
|
|
14
|
-
|
|
15
|
-
`T` *extends* [`ValidEventTypes`](ValidEventTypes.md)
|
|
16
|
-
|
|
17
|
-
### K
|
|
18
|
-
|
|
19
|
-
`K` *extends* [`EventNames`](EventNames.md)\<`T`\>
|