@miden-sdk/miden-wallet-adapter-base 0.13.1 → 0.13.2

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.
@@ -0,0 +1,82 @@
1
+ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
2
+ import {
3
+ WalletReadyState,
4
+ BaseWalletAdapter,
5
+ scopePollingDetectionStrategy,
6
+ } from '../adapter';
7
+
8
+ describe('WalletReadyState enum', () => {
9
+ it('has correct values', () => {
10
+ expect(WalletReadyState.Installed).toBe('Installed');
11
+ expect(WalletReadyState.NotDetected).toBe('NotDetected');
12
+ expect(WalletReadyState.Loadable).toBe('Loadable');
13
+ expect(WalletReadyState.Unsupported).toBe('Unsupported');
14
+ });
15
+ });
16
+
17
+ describe('BaseWalletAdapter', () => {
18
+ // Concrete subclass for testing
19
+ class TestAdapter extends BaseWalletAdapter {
20
+ name = 'Test' as any;
21
+ url = 'https://test.com';
22
+ icon = 'icon';
23
+ readyState = WalletReadyState.Installed;
24
+ address: string | null = null;
25
+ publicKey: Uint8Array | null = null;
26
+ connecting = false;
27
+ supportedTransactionVersions = null;
28
+
29
+ async connect() {}
30
+ async disconnect() {}
31
+ }
32
+
33
+ it('connected returns true when address is set', () => {
34
+ const adapter = new TestAdapter();
35
+ adapter.address = '0xabc';
36
+ expect(adapter.connected).toBe(true);
37
+ });
38
+
39
+ it('connected returns false when address is null', () => {
40
+ const adapter = new TestAdapter();
41
+ expect(adapter.connected).toBe(false);
42
+ });
43
+ });
44
+
45
+ describe('scopePollingDetectionStrategy', () => {
46
+ beforeEach(() => {
47
+ vi.useFakeTimers();
48
+ });
49
+
50
+ afterEach(() => {
51
+ vi.useRealTimers();
52
+ });
53
+
54
+ it('calls detect immediately and cleans up on detection', () => {
55
+ const detect = vi.fn().mockReturnValue(true);
56
+ scopePollingDetectionStrategy(detect);
57
+ expect(detect).toHaveBeenCalled();
58
+ });
59
+
60
+ it('sets up polling interval when not immediately detected', () => {
61
+ let callCount = 0;
62
+ const detect = vi.fn(() => {
63
+ callCount++;
64
+ return callCount >= 3;
65
+ });
66
+
67
+ scopePollingDetectionStrategy(detect);
68
+ // First call is immediate (returns false)
69
+ expect(detect).toHaveBeenCalledTimes(1);
70
+
71
+ // Advance timer to trigger interval
72
+ vi.advanceTimersByTime(1000);
73
+ expect(detect).toHaveBeenCalledTimes(2);
74
+
75
+ vi.advanceTimersByTime(1000);
76
+ expect(detect).toHaveBeenCalledTimes(3);
77
+
78
+ // After detection (callCount >= 3), interval should be cleared
79
+ vi.advanceTimersByTime(1000);
80
+ expect(detect).toHaveBeenCalledTimes(3);
81
+ });
82
+ });
@@ -0,0 +1,100 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import {
3
+ WalletError,
4
+ WalletNotReadyError,
5
+ WalletLoadError,
6
+ WalletConfigError,
7
+ WalletConnectionError,
8
+ WalletNotSelectedError,
9
+ WalletDisconnectedError,
10
+ WalletDisconnectionError,
11
+ WalletAccountError,
12
+ WalletAddressError,
13
+ WalletKeypairError,
14
+ WalletNotConnectedError,
15
+ WalletSendTransactionError,
16
+ WalletSignMessageError,
17
+ WalletSignTransactionError,
18
+ WalletTimeoutError,
19
+ WalletWindowBlockedError,
20
+ WalletWindowClosedError,
21
+ WalletDecryptionNotAllowedError,
22
+ WalletPrivateDataPermissionError,
23
+ WalletDecryptionError,
24
+ WalletRecordsError,
25
+ WalletTransactionError,
26
+ } from '../errors';
27
+
28
+ const errorClasses = [
29
+ { Class: WalletNotReadyError, name: 'WalletNotReadyError' },
30
+ { Class: WalletLoadError, name: 'WalletLoadError' },
31
+ { Class: WalletConfigError, name: 'WalletConfigError' },
32
+ { Class: WalletConnectionError, name: 'WalletConnectionError' },
33
+ { Class: WalletNotSelectedError, name: 'WalletNotSelectedError' },
34
+ { Class: WalletDisconnectedError, name: 'WalletDisconnectedError' },
35
+ { Class: WalletDisconnectionError, name: 'WalletDisconnectionError' },
36
+ { Class: WalletAccountError, name: 'WalletAccountError' },
37
+ { Class: WalletAddressError, name: 'WalletAddressError' },
38
+ { Class: WalletKeypairError, name: 'WalletKeypairError' },
39
+ { Class: WalletNotConnectedError, name: 'WalletNotConnectedError' },
40
+ { Class: WalletSendTransactionError, name: 'WalletSendTransactionError' },
41
+ { Class: WalletSignMessageError, name: 'WalletSignMessageError' },
42
+ { Class: WalletSignTransactionError, name: 'WalletSignTransactionError' },
43
+ { Class: WalletTimeoutError, name: 'WalletTimeoutError' },
44
+ { Class: WalletWindowBlockedError, name: 'WalletWindowBlockedError' },
45
+ { Class: WalletWindowClosedError, name: 'WalletWindowClosedError' },
46
+ {
47
+ Class: WalletDecryptionNotAllowedError,
48
+ name: 'WalletDecryptionNotAllowedError',
49
+ },
50
+ {
51
+ Class: WalletPrivateDataPermissionError,
52
+ name: 'WalletPrivateDataPermissionError',
53
+ },
54
+ { Class: WalletDecryptionError, name: 'WalletDecryptionError' },
55
+ { Class: WalletRecordsError, name: 'WalletRecordsError' },
56
+ { Class: WalletTransactionError, name: 'WalletTransactionError' },
57
+ ] as const;
58
+
59
+ describe('WalletError', () => {
60
+ it('extends Error', () => {
61
+ const err = new WalletError('test message');
62
+ expect(err).toBeInstanceOf(Error);
63
+ expect(err).toBeInstanceOf(WalletError);
64
+ });
65
+
66
+ it('sets message property', () => {
67
+ const err = new WalletError('my message');
68
+ expect(err.message).toBe('my message');
69
+ });
70
+
71
+ it('stores inner error', () => {
72
+ const inner = new Error('inner');
73
+ const err = new WalletError('outer', inner);
74
+ expect(err.error).toBe(inner);
75
+ });
76
+ });
77
+
78
+ describe('error subclasses', () => {
79
+ for (const { Class, name } of errorClasses) {
80
+ describe(name, () => {
81
+ it('extends WalletError and Error', () => {
82
+ const err = new Class();
83
+ expect(err).toBeInstanceOf(WalletError);
84
+ expect(err).toBeInstanceOf(Error);
85
+ });
86
+
87
+ it('has correct name property', () => {
88
+ const err = new Class();
89
+ expect(err.name).toBe(name);
90
+ });
91
+
92
+ it('stores inner error', () => {
93
+ const inner = new Error('cause');
94
+ const err = new Class('msg', inner);
95
+ expect(err.error).toBe(inner);
96
+ expect(err.message).toBe('msg');
97
+ });
98
+ });
99
+ }
100
+ });
@@ -0,0 +1,39 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { u8ToB64, b64ToU8 } from '../helpers';
3
+
4
+ describe('u8ToB64', () => {
5
+ it('encodes a known value correctly', () => {
6
+ const bytes = new Uint8Array([72, 101, 108, 108, 111]); // "Hello"
7
+ expect(u8ToB64(bytes)).toBe('SGVsbG8=');
8
+ });
9
+
10
+ it('encodes an empty array', () => {
11
+ expect(u8ToB64(new Uint8Array([]))).toBe('');
12
+ });
13
+ });
14
+
15
+ describe('b64ToU8', () => {
16
+ it('decodes a known value correctly', () => {
17
+ const result = b64ToU8('SGVsbG8=');
18
+ expect(result).toEqual(new Uint8Array([72, 101, 108, 108, 111]));
19
+ });
20
+
21
+ it('decodes an empty string', () => {
22
+ expect(b64ToU8('')).toEqual(new Uint8Array([]));
23
+ });
24
+ });
25
+
26
+ describe('roundtrip', () => {
27
+ it('encode then decode returns original bytes', () => {
28
+ const original = new Uint8Array([0, 1, 127, 128, 255]);
29
+ const decoded = b64ToU8(u8ToB64(original));
30
+ expect(decoded).toEqual(original);
31
+ });
32
+
33
+ it('handles a large array (256 bytes)', () => {
34
+ const original = new Uint8Array(256);
35
+ for (let i = 0; i < 256; i++) original[i] = i;
36
+ const decoded = b64ToU8(u8ToB64(original));
37
+ expect(decoded).toEqual(original);
38
+ });
39
+ });
@@ -0,0 +1,166 @@
1
+ import { describe, it, expect, vi } from 'vitest';
2
+ import {
3
+ SendTransaction,
4
+ ConsumeTransaction,
5
+ CustomTransaction,
6
+ Transaction,
7
+ TransactionType,
8
+ } from '../transaction';
9
+ import { u8ToB64 } from '../helpers';
10
+
11
+ describe('TransactionType enum', () => {
12
+ it('has correct values', () => {
13
+ expect(TransactionType.Send).toBe('send');
14
+ expect(TransactionType.Consume).toBe('consume');
15
+ expect(TransactionType.Custom).toBe('custom');
16
+ });
17
+ });
18
+
19
+ describe('SendTransaction', () => {
20
+ it('sets all fields correctly', () => {
21
+ const tx = new SendTransaction(
22
+ 'sender-addr',
23
+ 'recipient-addr',
24
+ 'faucet-123',
25
+ 'public',
26
+ 1000
27
+ );
28
+ expect(tx.senderAddress).toBe('sender-addr');
29
+ expect(tx.recipientAddress).toBe('recipient-addr');
30
+ expect(tx.faucetId).toBe('faucet-123');
31
+ expect(tx.noteType).toBe('public');
32
+ expect(tx.amount).toBe(1000);
33
+ expect(tx.recallBlocks).toBeUndefined();
34
+ });
35
+
36
+ it('sets optional recallBlocks', () => {
37
+ const tx = new SendTransaction(
38
+ 'sender',
39
+ 'recipient',
40
+ 'faucet',
41
+ 'private',
42
+ 500,
43
+ 10
44
+ );
45
+ expect(tx.recallBlocks).toBe(10);
46
+ });
47
+ });
48
+
49
+ describe('ConsumeTransaction', () => {
50
+ it('sets fields correctly', () => {
51
+ const tx = new ConsumeTransaction('faucet-1', 'note-1', 'public', 100);
52
+ expect(tx.faucetId).toBe('faucet-1');
53
+ expect(tx.noteId).toBe('note-1');
54
+ expect(tx.noteType).toBe('public');
55
+ expect(tx.amount).toBe(100);
56
+ expect(tx.noteBytes).toBeUndefined();
57
+ });
58
+
59
+ it('converts noteBytes Uint8Array to base64', () => {
60
+ const bytes = new Uint8Array([1, 2, 3]);
61
+ const tx = new ConsumeTransaction('faucet', 'note', 'private', 50, bytes);
62
+ expect(tx.noteBytes).toBe(u8ToB64(bytes));
63
+ });
64
+
65
+ it('leaves noteBytes undefined when not provided', () => {
66
+ const tx = new ConsumeTransaction('faucet', 'note', 'public', 50);
67
+ expect(tx.noteBytes).toBeUndefined();
68
+ });
69
+ });
70
+
71
+ describe('CustomTransaction', () => {
72
+ it('serializes transactionRequest to base64', () => {
73
+ const mockBytes = new Uint8Array([10, 20, 30]);
74
+ const mockRequest = {
75
+ serialize: vi.fn().mockReturnValue(mockBytes),
76
+ } as any;
77
+
78
+ const tx = new CustomTransaction('addr', 'recipient', mockRequest);
79
+ expect(mockRequest.serialize).toHaveBeenCalled();
80
+ expect(tx.transactionRequest).toBe(u8ToB64(mockBytes));
81
+ expect(tx.address).toBe('addr');
82
+ expect(tx.recipientAddress).toBe('recipient');
83
+ });
84
+
85
+ it('sets optional inputNoteIds', () => {
86
+ const mockRequest = {
87
+ serialize: vi.fn().mockReturnValue(new Uint8Array([1])),
88
+ } as any;
89
+ const tx = new CustomTransaction('addr', 'recipient', mockRequest, [
90
+ 'id1',
91
+ 'id2',
92
+ ]);
93
+ expect(tx.inputNoteIds).toEqual(['id1', 'id2']);
94
+ });
95
+
96
+ it('converts importNotes from Uint8Array[] to base64 strings', () => {
97
+ const mockRequest = {
98
+ serialize: vi.fn().mockReturnValue(new Uint8Array([1])),
99
+ } as any;
100
+ const noteBytes = [new Uint8Array([4, 5]), new Uint8Array([6, 7])];
101
+ const tx = new CustomTransaction(
102
+ 'addr',
103
+ 'recipient',
104
+ mockRequest,
105
+ ['id1'],
106
+ noteBytes
107
+ );
108
+ expect(tx.importNotes).toEqual([
109
+ u8ToB64(noteBytes[0]),
110
+ u8ToB64(noteBytes[1]),
111
+ ]);
112
+ });
113
+
114
+ it('leaves optional fields undefined when not provided', () => {
115
+ const mockRequest = {
116
+ serialize: vi.fn().mockReturnValue(new Uint8Array([1])),
117
+ } as any;
118
+ const tx = new CustomTransaction('addr', 'recipient', mockRequest);
119
+ expect(tx.inputNoteIds).toBeUndefined();
120
+ expect(tx.importNotes).toBeUndefined();
121
+ });
122
+ });
123
+
124
+ describe('Transaction factory', () => {
125
+ it('createSendTransaction returns correct type and payload', () => {
126
+ const tx = Transaction.createSendTransaction(
127
+ 'sender',
128
+ 'recipient',
129
+ 'faucet',
130
+ 'public',
131
+ 100
132
+ );
133
+ expect(tx.type).toBe(TransactionType.Send);
134
+ expect(tx.payload).toBeInstanceOf(SendTransaction);
135
+ const payload = tx.payload as SendTransaction;
136
+ expect(payload.senderAddress).toBe('sender');
137
+ expect(payload.amount).toBe(100);
138
+ });
139
+
140
+ it('createConsumeTransaction returns correct type and payload', () => {
141
+ const tx = Transaction.createConsumeTransaction(
142
+ 'faucet',
143
+ 'note-id',
144
+ 'private',
145
+ 200
146
+ );
147
+ expect(tx.type).toBe(TransactionType.Consume);
148
+ expect(tx.payload).toBeInstanceOf(ConsumeTransaction);
149
+ const payload = tx.payload as ConsumeTransaction;
150
+ expect(payload.faucetId).toBe('faucet');
151
+ expect(payload.noteId).toBe('note-id');
152
+ });
153
+
154
+ it('createCustomTransaction returns correct type and payload', () => {
155
+ const mockRequest = {
156
+ serialize: vi.fn().mockReturnValue(new Uint8Array([1, 2])),
157
+ } as any;
158
+ const tx = Transaction.createCustomTransaction(
159
+ 'addr',
160
+ 'recipient',
161
+ mockRequest
162
+ );
163
+ expect(tx.type).toBe(TransactionType.Custom);
164
+ expect(tx.payload).toBeInstanceOf(CustomTransaction);
165
+ });
166
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,66 @@
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
@@ -0,0 +1 @@
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,gBAAgB,EAChB,iBAAiB,EACjB,6BAA6B,GAC9B,MAAM,YAAY,CAAC;AAEpB,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACrC,EAAE,CAAC,oBAAoB,EAAE,GAAG,EAAE;QAC5B,MAAM,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,IAAI,CAA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}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,70 @@
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
@@ -0,0 +1 @@
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,uBAAu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IAAI,EAAE,IAAI,YAAY,EAAE,CAAC;QAC3C,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE;YAClB,EAAE,CAAC,+BAA+B,EAAE,GAAG,EAAE;gBACvC,MAAM,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC;gBACxB,MAAM,CAAC,GAAG,CAAC,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;gBACxC,MAAM,CAAC,GAAG,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YACpC,CAAC,CAAC,CAAC;YAEH,EAAE,CAAC,2BAA2B,EAAE,GAAG,EAAE;gBACnC,MAAM,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC;gBACxB,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,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"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,35 @@
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
@@ -0,0 +1 @@
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,E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;QAC9C,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC3C,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,113 @@
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
@@ -0,0 +1 @@
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,CAA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Z,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"}
@@ -0,0 +1,2 @@
1
+ declare const _default: import("vite").UserConfig;
2
+ export default _default;
@@ -0,0 +1,8 @@
1
+ import { defineConfig } from 'vitest/config';
2
+ export default defineConfig({
3
+ test: {
4
+ environment: 'jsdom',
5
+ globals: true,
6
+ },
7
+ });
8
+ //# sourceMappingURL=vitest.config.js.map
@@ -0,0 +1 @@
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"}
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@miden-sdk/miden-wallet-adapter-base",
3
- "version": "0.13.1",
3
+ "version": "0.13.2",
4
4
  "description": "Core infrastructure for connecting Miden-compatible wallets to your dApp.",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "scripts": {
8
8
  "build": "tsc",
9
9
  "clean": "rimraf dist/ node_modules/",
10
- "doc": "typedoc --disableSources --tsconfig ./tsconfig.json --plugin typedoc-plugin-markdown --entryPoints index.ts"
10
+ "doc": "typedoc --disableSources --tsconfig ./tsconfig.json --plugin typedoc-plugin-markdown --entryPoints index.ts",
11
+ "test": "vitest run"
11
12
  },
12
13
  "repository": {
13
14
  "type": "git",
@@ -17,5 +18,9 @@
17
18
  "license": "MIT",
18
19
  "dependencies": {
19
20
  "eventemitter3": "^5.0.1"
21
+ },
22
+ "devDependencies": {
23
+ "jsdom": "^24.0.0",
24
+ "vitest": "^1.0.0"
20
25
  }
21
26
  }
@@ -0,0 +1,8 @@
1
+ import { defineConfig } from 'vitest/config';
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ environment: 'jsdom',
6
+ globals: true,
7
+ },
8
+ });