@miden-sdk/miden-wallet-adapter-base 0.13.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 (104) hide show
  1. package/adapter.ts +146 -0
  2. package/dist/adapter.d.ts +69 -0
  3. package/dist/adapter.js +74 -0
  4. package/dist/adapter.js.map +1 -0
  5. package/dist/errors.d.ts +70 -0
  6. package/dist/errors.js +75 -0
  7. package/dist/errors.js.map +1 -0
  8. package/dist/helpers.d.ts +2 -0
  9. package/dist/helpers.js +32 -0
  10. package/dist/helpers.js.map +1 -0
  11. package/dist/index.d.ts +6 -0
  12. package/dist/index.js +7 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/signer.d.ts +34 -0
  15. package/dist/signer.js +6 -0
  16. package/dist/signer.js.map +1 -0
  17. package/dist/transaction.d.ts +67 -0
  18. package/dist/transaction.js +74 -0
  19. package/dist/transaction.js.map +1 -0
  20. package/dist/types.d.ts +47 -0
  21. package/dist/types.js +19 -0
  22. package/dist/types.js.map +1 -0
  23. package/docs/@miden-sdk/namespaces/EventEmitter/README.md +24 -0
  24. package/docs/@miden-sdk/namespaces/EventEmitter/interfaces/EventEmitterStatic.md +17 -0
  25. package/docs/@miden-sdk/namespaces/EventEmitter/interfaces/ListenerFn.md +25 -0
  26. package/docs/@miden-sdk/namespaces/EventEmitter/type-aliases/ArgumentMap.md +15 -0
  27. package/docs/@miden-sdk/namespaces/EventEmitter/type-aliases/EventArgs.md +19 -0
  28. package/docs/@miden-sdk/namespaces/EventEmitter/type-aliases/EventListener.md +19 -0
  29. package/docs/@miden-sdk/namespaces/EventEmitter/type-aliases/EventNames.md +15 -0
  30. package/docs/@miden-sdk/namespaces/EventEmitter/type-aliases/ValidEventTypes.md +17 -0
  31. package/docs/@miden-sdk/namespaces/EventEmitter/variables/EventEmitter.md +9 -0
  32. package/docs/README.md +88 -0
  33. package/docs/classes/BaseMessageSignerWalletAdapter.md +755 -0
  34. package/docs/classes/BaseSignerWalletAdapter.md +579 -0
  35. package/docs/classes/BaseWalletAdapter.md +535 -0
  36. package/docs/classes/ConsumeTransaction.md +93 -0
  37. package/docs/classes/CustomTransaction.md +93 -0
  38. package/docs/classes/EventEmitter.md +305 -0
  39. package/docs/classes/SendTransaction.md +107 -0
  40. package/docs/classes/Transaction.md +151 -0
  41. package/docs/classes/WalletAccountError.md +223 -0
  42. package/docs/classes/WalletAddressError.md +223 -0
  43. package/docs/classes/WalletConfigError.md +223 -0
  44. package/docs/classes/WalletConnectionError.md +223 -0
  45. package/docs/classes/WalletDecryptionError.md +223 -0
  46. package/docs/classes/WalletDecryptionNotAllowedError.md +223 -0
  47. package/docs/classes/WalletDisconnectedError.md +223 -0
  48. package/docs/classes/WalletDisconnectionError.md +223 -0
  49. package/docs/classes/WalletError.md +244 -0
  50. package/docs/classes/WalletKeypairError.md +223 -0
  51. package/docs/classes/WalletLoadError.md +223 -0
  52. package/docs/classes/WalletNotConnectedError.md +223 -0
  53. package/docs/classes/WalletNotReadyError.md +223 -0
  54. package/docs/classes/WalletNotSelectedError.md +223 -0
  55. package/docs/classes/WalletPrivateDataPermissionError.md +223 -0
  56. package/docs/classes/WalletRecordsError.md +223 -0
  57. package/docs/classes/WalletSendTransactionError.md +223 -0
  58. package/docs/classes/WalletSignMessageError.md +223 -0
  59. package/docs/classes/WalletSignTransactionError.md +223 -0
  60. package/docs/classes/WalletTimeoutError.md +223 -0
  61. package/docs/classes/WalletTransactionError.md +223 -0
  62. package/docs/classes/WalletWindowBlockedError.md +223 -0
  63. package/docs/classes/WalletWindowClosedError.md +223 -0
  64. package/docs/enumerations/AllowedPrivateData.md +37 -0
  65. package/docs/enumerations/PrivateDataPermission.md +19 -0
  66. package/docs/enumerations/TransactionType.md +25 -0
  67. package/docs/enumerations/WalletAdapterNetwork.md +19 -0
  68. package/docs/enumerations/WalletReadyState.md +49 -0
  69. package/docs/functions/b64ToU8.md +19 -0
  70. package/docs/functions/scopePollingDetectionStrategy.md +19 -0
  71. package/docs/functions/u8ToB64.md +19 -0
  72. package/docs/interfaces/Asset.md +19 -0
  73. package/docs/interfaces/IFailedTransactionOutput.md +13 -0
  74. package/docs/interfaces/MessageSignerWalletAdapterProps.md +293 -0
  75. package/docs/interfaces/MidenConsumeTransaction.md +37 -0
  76. package/docs/interfaces/MidenCustomTransaction.md +37 -0
  77. package/docs/interfaces/MidenSendTransaction.md +43 -0
  78. package/docs/interfaces/MidenTransaction.md +19 -0
  79. package/docs/interfaces/SignerWalletAdapterProps.md +149 -0
  80. package/docs/interfaces/TransactionOutput.md +19 -0
  81. package/docs/interfaces/WalletAdapterEvents.md +69 -0
  82. package/docs/interfaces/WalletAdapterProps.md +106 -0
  83. package/docs/interfaces/WalletTransactionSuccessOutput.md +19 -0
  84. package/docs/type-aliases/Adapter.md +9 -0
  85. package/docs/type-aliases/FungibleAssetDetails.md +21 -0
  86. package/docs/type-aliases/InputNoteDetails.md +45 -0
  87. package/docs/type-aliases/MessageSignerWalletAdapter.md +15 -0
  88. package/docs/type-aliases/NoteTypeString.md +9 -0
  89. package/docs/type-aliases/SignKind.md +9 -0
  90. package/docs/type-aliases/SignerWalletAdapter.md +15 -0
  91. package/docs/type-aliases/SupportedTransactionVersions.md +9 -0
  92. package/docs/type-aliases/TransactionOrVersionedTransaction.md +15 -0
  93. package/docs/type-aliases/TransactionPayload.md +9 -0
  94. package/docs/type-aliases/WalletAdapter.md +15 -0
  95. package/docs/type-aliases/WalletName.md +21 -0
  96. package/docs/type-aliases/WalletTransactionOutput.md +9 -0
  97. package/errors.ts +97 -0
  98. package/helpers.ts +28 -0
  99. package/index.ts +6 -0
  100. package/package.json +21 -0
  101. package/signer.ts +71 -0
  102. package/transaction.ts +178 -0
  103. package/tsconfig.json +15 -0
  104. package/types.ts +68 -0
@@ -0,0 +1,106 @@
1
+ [**@miden-sdk/miden-wallet-adapter-base**](../README.md)
2
+
3
+ ***
4
+
5
+ [@miden-sdk/miden-wallet-adapter-base](../README.md) / WalletAdapterProps
6
+
7
+ # Interface: WalletAdapterProps\<Name\>
8
+
9
+ ## Extended by
10
+
11
+ - [`SignerWalletAdapterProps`](SignerWalletAdapterProps.md)
12
+ - [`MessageSignerWalletAdapterProps`](MessageSignerWalletAdapterProps.md)
13
+
14
+ ## Type Parameters
15
+
16
+ ### Name
17
+
18
+ `Name` *extends* `string` = `string`
19
+
20
+ ## Properties
21
+
22
+ ### address
23
+
24
+ > **address**: `string`
25
+
26
+ ***
27
+
28
+ ### connected
29
+
30
+ > **connected**: `boolean`
31
+
32
+ ***
33
+
34
+ ### connecting
35
+
36
+ > **connecting**: `boolean`
37
+
38
+ ***
39
+
40
+ ### icon
41
+
42
+ > **icon**: `string`
43
+
44
+ ***
45
+
46
+ ### name
47
+
48
+ > **name**: [`WalletName`](../type-aliases/WalletName.md)\<`Name`\>
49
+
50
+ ***
51
+
52
+ ### publicKey
53
+
54
+ > **publicKey**: `Uint8Array`\<`ArrayBufferLike`\>
55
+
56
+ ***
57
+
58
+ ### readyState
59
+
60
+ > **readyState**: [`WalletReadyState`](../enumerations/WalletReadyState.md)
61
+
62
+ ***
63
+
64
+ ### supportedTransactionVersions
65
+
66
+ > **supportedTransactionVersions**: `ReadonlySet`
67
+
68
+ ***
69
+
70
+ ### url
71
+
72
+ > **url**: `string`
73
+
74
+ ## Methods
75
+
76
+ ### connect()
77
+
78
+ > **connect**(`privateDataPermission`, `network`, `allowedPrivateData?`): `Promise`\<`void`\>
79
+
80
+ #### Parameters
81
+
82
+ ##### privateDataPermission
83
+
84
+ [`PrivateDataPermission`](../enumerations/PrivateDataPermission.md)
85
+
86
+ ##### network
87
+
88
+ [`WalletAdapterNetwork`](../enumerations/WalletAdapterNetwork.md)
89
+
90
+ ##### allowedPrivateData?
91
+
92
+ [`AllowedPrivateData`](../enumerations/AllowedPrivateData.md)
93
+
94
+ #### Returns
95
+
96
+ `Promise`\<`void`\>
97
+
98
+ ***
99
+
100
+ ### disconnect()
101
+
102
+ > **disconnect**(): `Promise`\<`void`\>
103
+
104
+ #### Returns
105
+
106
+ `Promise`\<`void`\>
@@ -0,0 +1,19 @@
1
+ [**@miden-sdk/miden-wallet-adapter-base**](../README.md)
2
+
3
+ ***
4
+
5
+ [@miden-sdk/miden-wallet-adapter-base](../README.md) / WalletTransactionSuccessOutput
6
+
7
+ # Interface: WalletTransactionSuccessOutput
8
+
9
+ ## Properties
10
+
11
+ ### outputNotes
12
+
13
+ > **outputNotes**: `string`[]
14
+
15
+ ***
16
+
17
+ ### txHash
18
+
19
+ > **txHash**: `string`
@@ -0,0 +1,9 @@
1
+ [**@miden-sdk/miden-wallet-adapter-base**](../README.md)
2
+
3
+ ***
4
+
5
+ [@miden-sdk/miden-wallet-adapter-base](../README.md) / Adapter
6
+
7
+ # Type Alias: Adapter
8
+
9
+ > **Adapter** = [`WalletAdapter`](WalletAdapter.md) \| [`SignerWalletAdapter`](SignerWalletAdapter.md) \| [`MessageSignerWalletAdapter`](MessageSignerWalletAdapter.md)
@@ -0,0 +1,21 @@
1
+ [**@miden-sdk/miden-wallet-adapter-base**](../README.md)
2
+
3
+ ***
4
+
5
+ [@miden-sdk/miden-wallet-adapter-base](../README.md) / FungibleAssetDetails
6
+
7
+ # Type Alias: FungibleAssetDetails
8
+
9
+ > **FungibleAssetDetails** = `object`
10
+
11
+ ## Properties
12
+
13
+ ### amount
14
+
15
+ > **amount**: `string`
16
+
17
+ ***
18
+
19
+ ### faucetId
20
+
21
+ > **faucetId**: `string`
@@ -0,0 +1,45 @@
1
+ [**@miden-sdk/miden-wallet-adapter-base**](../README.md)
2
+
3
+ ***
4
+
5
+ [@miden-sdk/miden-wallet-adapter-base](../README.md) / InputNoteDetails
6
+
7
+ # Type Alias: InputNoteDetails
8
+
9
+ > **InputNoteDetails** = `object`
10
+
11
+ ## Properties
12
+
13
+ ### assets
14
+
15
+ > **assets**: [`FungibleAssetDetails`](FungibleAssetDetails.md)[]
16
+
17
+ ***
18
+
19
+ ### noteId
20
+
21
+ > **noteId**: `string`
22
+
23
+ ***
24
+
25
+ ### noteType
26
+
27
+ > **noteType**: `NoteType` \| `undefined`
28
+
29
+ ***
30
+
31
+ ### nullifier
32
+
33
+ > **nullifier**: `string`
34
+
35
+ ***
36
+
37
+ ### senderAccountId
38
+
39
+ > **senderAccountId**: `string` \| `undefined`
40
+
41
+ ***
42
+
43
+ ### state
44
+
45
+ > **state**: `InputNoteState`
@@ -0,0 +1,15 @@
1
+ [**@miden-sdk/miden-wallet-adapter-base**](../README.md)
2
+
3
+ ***
4
+
5
+ [@miden-sdk/miden-wallet-adapter-base](../README.md) / MessageSignerWalletAdapter
6
+
7
+ # Type Alias: MessageSignerWalletAdapter\<Name\>
8
+
9
+ > **MessageSignerWalletAdapter**\<`Name`\> = [`WalletAdapter`](WalletAdapter.md)\<`Name`\> & [`MessageSignerWalletAdapterProps`](../interfaces/MessageSignerWalletAdapterProps.md)\<`Name`\>
10
+
11
+ ## Type Parameters
12
+
13
+ ### Name
14
+
15
+ `Name` *extends* `string` = `string`
@@ -0,0 +1,9 @@
1
+ [**@miden-sdk/miden-wallet-adapter-base**](../README.md)
2
+
3
+ ***
4
+
5
+ [@miden-sdk/miden-wallet-adapter-base](../README.md) / NoteTypeString
6
+
7
+ # Type Alias: NoteTypeString
8
+
9
+ > **NoteTypeString** = `"public"` \| `"private"`
@@ -0,0 +1,9 @@
1
+ [**@miden-sdk/miden-wallet-adapter-base**](../README.md)
2
+
3
+ ***
4
+
5
+ [@miden-sdk/miden-wallet-adapter-base](../README.md) / SignKind
6
+
7
+ # Type Alias: SignKind
8
+
9
+ > **SignKind** = `"word"` \| `"signingInputs"`
@@ -0,0 +1,15 @@
1
+ [**@miden-sdk/miden-wallet-adapter-base**](../README.md)
2
+
3
+ ***
4
+
5
+ [@miden-sdk/miden-wallet-adapter-base](../README.md) / SignerWalletAdapter
6
+
7
+ # Type Alias: SignerWalletAdapter\<Name\>
8
+
9
+ > **SignerWalletAdapter**\<`Name`\> = [`WalletAdapter`](WalletAdapter.md)\<`Name`\> & [`SignerWalletAdapterProps`](../interfaces/SignerWalletAdapterProps.md)\<`Name`\>
10
+
11
+ ## Type Parameters
12
+
13
+ ### Name
14
+
15
+ `Name` *extends* `string` = `string`
@@ -0,0 +1,9 @@
1
+ [**@miden-sdk/miden-wallet-adapter-base**](../README.md)
2
+
3
+ ***
4
+
5
+ [@miden-sdk/miden-wallet-adapter-base](../README.md) / SupportedTransactionVersions
6
+
7
+ # Type Alias: SupportedTransactionVersions
8
+
9
+ > **SupportedTransactionVersions** = `ReadonlySet`\<`any`\> \| `null`
@@ -0,0 +1,15 @@
1
+ [**@miden-sdk/miden-wallet-adapter-base**](../README.md)
2
+
3
+ ***
4
+
5
+ [@miden-sdk/miden-wallet-adapter-base](../README.md) / TransactionOrVersionedTransaction
6
+
7
+ # Type Alias: TransactionOrVersionedTransaction\<S\>
8
+
9
+ > **TransactionOrVersionedTransaction**\<`S`\> = `S` *extends* `null` ? `any` : `any` \| `any`
10
+
11
+ ## Type Parameters
12
+
13
+ ### S
14
+
15
+ `S` *extends* [`SupportedTransactionVersions`](SupportedTransactionVersions.md)
@@ -0,0 +1,9 @@
1
+ [**@miden-sdk/miden-wallet-adapter-base**](../README.md)
2
+
3
+ ***
4
+
5
+ [@miden-sdk/miden-wallet-adapter-base](../README.md) / TransactionPayload
6
+
7
+ # Type Alias: TransactionPayload
8
+
9
+ > **TransactionPayload** = [`MidenSendTransaction`](../interfaces/MidenSendTransaction.md) \| [`MidenConsumeTransaction`](../interfaces/MidenConsumeTransaction.md) \| [`MidenCustomTransaction`](../interfaces/MidenCustomTransaction.md)
@@ -0,0 +1,15 @@
1
+ [**@miden-sdk/miden-wallet-adapter-base**](../README.md)
2
+
3
+ ***
4
+
5
+ [@miden-sdk/miden-wallet-adapter-base](../README.md) / WalletAdapter
6
+
7
+ # Type Alias: WalletAdapter\<Name\>
8
+
9
+ > **WalletAdapter**\<`Name`\> = [`WalletAdapterProps`](../interfaces/WalletAdapterProps.md)\<`Name`\> & [`EventEmitter`](../classes/EventEmitter.md)\<[`WalletAdapterEvents`](../interfaces/WalletAdapterEvents.md)\>
10
+
11
+ ## Type Parameters
12
+
13
+ ### Name
14
+
15
+ `Name` *extends* `string` = `string`
@@ -0,0 +1,21 @@
1
+ [**@miden-sdk/miden-wallet-adapter-base**](../README.md)
2
+
3
+ ***
4
+
5
+ [@miden-sdk/miden-wallet-adapter-base](../README.md) / WalletName
6
+
7
+ # Type Alias: WalletName\<T\>
8
+
9
+ > **WalletName**\<`T`\> = `T` & `object`
10
+
11
+ ## Type declaration
12
+
13
+ ### \_\_brand\_\_
14
+
15
+ > **\_\_brand\_\_**: `"WalletName"`
16
+
17
+ ## Type Parameters
18
+
19
+ ### T
20
+
21
+ `T` *extends* `string` = `string`
@@ -0,0 +1,9 @@
1
+ [**@miden-sdk/miden-wallet-adapter-base**](../README.md)
2
+
3
+ ***
4
+
5
+ [@miden-sdk/miden-wallet-adapter-base](../README.md) / WalletTransactionOutput
6
+
7
+ # Type Alias: WalletTransactionOutput
8
+
9
+ > **WalletTransactionOutput** = [`WalletTransactionSuccessOutput`](../interfaces/WalletTransactionSuccessOutput.md) \| [`IFailedTransactionOutput`](../interfaces/IFailedTransactionOutput.md)
package/errors.ts ADDED
@@ -0,0 +1,97 @@
1
+ export class WalletError extends Error {
2
+ error: any;
3
+
4
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
5
+ constructor(message?: string, error?: any) {
6
+ super(message);
7
+ this.error = error;
8
+ }
9
+ }
10
+
11
+ export class WalletNotReadyError extends WalletError {
12
+ name = 'WalletNotReadyError';
13
+ }
14
+
15
+ export class WalletLoadError extends WalletError {
16
+ name = 'WalletLoadError';
17
+ }
18
+
19
+ export class WalletConfigError extends WalletError {
20
+ name = 'WalletConfigError';
21
+ }
22
+
23
+ export class WalletConnectionError extends WalletError {
24
+ name = 'WalletConnectionError';
25
+ }
26
+
27
+ export class WalletNotSelectedError extends WalletError {
28
+ name = 'WalletNotSelectedError';
29
+ }
30
+
31
+ export class WalletDisconnectedError extends WalletError {
32
+ name = 'WalletDisconnectedError';
33
+ }
34
+
35
+ export class WalletDisconnectionError extends WalletError {
36
+ name = 'WalletDisconnectionError';
37
+ }
38
+
39
+ export class WalletAccountError extends WalletError {
40
+ name = 'WalletAccountError';
41
+ }
42
+
43
+ export class WalletAddressError extends WalletError {
44
+ name = 'WalletAddressError';
45
+ }
46
+
47
+ export class WalletKeypairError extends WalletError {
48
+ name = 'WalletKeypairError';
49
+ }
50
+
51
+ export class WalletNotConnectedError extends WalletError {
52
+ name = 'WalletNotConnectedError';
53
+ }
54
+
55
+ export class WalletSendTransactionError extends WalletError {
56
+ name = 'WalletSendTransactionError';
57
+ }
58
+
59
+ export class WalletSignMessageError extends WalletError {
60
+ name = 'WalletSignMessageError';
61
+ }
62
+
63
+ export class WalletSignTransactionError extends WalletError {
64
+ name = 'WalletSignTransactionError';
65
+ }
66
+
67
+ export class WalletTimeoutError extends WalletError {
68
+ name = 'WalletTimeoutError';
69
+ }
70
+
71
+ export class WalletWindowBlockedError extends WalletError {
72
+ name = 'WalletWindowBlockedError';
73
+ }
74
+
75
+ export class WalletWindowClosedError extends WalletError {
76
+ name = 'WalletWindowClosedError';
77
+ }
78
+
79
+ export class WalletDecryptionNotAllowedError extends WalletError {
80
+ name = 'WalletDecryptionNotAllowedError';
81
+ }
82
+
83
+ export class WalletPrivateDataPermissionError extends WalletError {
84
+ name = 'WalletPrivateDataPermissionError';
85
+ }
86
+
87
+ export class WalletDecryptionError extends WalletError {
88
+ name = 'WalletDecryptionError';
89
+ }
90
+
91
+ export class WalletRecordsError extends WalletError {
92
+ name = 'WalletRecordsError';
93
+ }
94
+
95
+ export class WalletTransactionError extends WalletError {
96
+ name = 'WalletTransactionError';
97
+ }
package/helpers.ts ADDED
@@ -0,0 +1,28 @@
1
+ // Encode a Uint8Array to base64
2
+ export function u8ToB64(u8: Uint8Array): string {
3
+ // Prefer browser builtins (no polyfills)
4
+ if (typeof globalThis.btoa === 'function') {
5
+ let s = '';
6
+ for (let i = 0; i < u8.length; i++) s += String.fromCharCode(u8[i]);
7
+ return globalThis.btoa(s);
8
+ }
9
+ // Node/Buffer fallback (won’t be bundled if never executed in browsers)
10
+ const Buf: any = (globalThis as any).Buffer;
11
+ if (Buf) return Buf.from(u8).toString('base64');
12
+ throw new Error('No base64 encoder available in this environment');
13
+ }
14
+
15
+ // Decode base64 to Uint8Array
16
+ export function b64ToU8(b64: string): Uint8Array {
17
+ // Prefer browser builtins (no polyfills)
18
+ if (typeof globalThis.atob === 'function') {
19
+ const bin = globalThis.atob(b64);
20
+ const out = new Uint8Array(bin.length);
21
+ for (let i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i);
22
+ return out;
23
+ }
24
+ // Node/Buffer fallback (won’t be bundled if never executed in browsers)
25
+ const Buf: any = (globalThis as any).Buffer;
26
+ if (Buf) return new Uint8Array(Buf.from(b64, 'base64'));
27
+ throw new Error('No base64 decoder available in this environment');
28
+ }
package/index.ts ADDED
@@ -0,0 +1,6 @@
1
+ export * from './adapter';
2
+ export * from './errors';
3
+ export * from './signer';
4
+ export * from './types';
5
+ export * from './transaction';
6
+ export * from './helpers';
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@miden-sdk/miden-wallet-adapter-base",
3
+ "version": "0.13.0",
4
+ "description": "Core infrastructure for connecting Miden-compatible wallets to your dApp.",
5
+ "module": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "scripts": {
8
+ "build": "tsc",
9
+ "clean": "rimraf dist/ node_modules/",
10
+ "doc": "typedoc --disableSources --tsconfig ./tsconfig.json --plugin typedoc-plugin-markdown --entryPoints index.ts"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/demox-labs/miden-wallet-adapter.git"
15
+ },
16
+ "author": "Demox Labs",
17
+ "license": "MIT",
18
+ "dependencies": {
19
+ "eventemitter3": "^5.0.1"
20
+ }
21
+ }
package/signer.ts ADDED
@@ -0,0 +1,71 @@
1
+ import type { NoteFilterTypes } from '@miden-sdk/miden-sdk';
2
+ import type { WalletAdapter, WalletAdapterProps } from './adapter';
3
+ import { BaseWalletAdapter } from './adapter';
4
+ import {
5
+ MidenConsumeTransaction,
6
+ MidenSendTransaction,
7
+ MidenTransaction,
8
+ } from './transaction';
9
+ import { Asset, InputNoteDetails, SignKind, TransactionOutput } from './types';
10
+
11
+ export type Adapter =
12
+ | WalletAdapter
13
+ | SignerWalletAdapter
14
+ | MessageSignerWalletAdapter;
15
+
16
+ export interface SignerWalletAdapterProps<Name extends string = string>
17
+ extends WalletAdapterProps<Name> {}
18
+
19
+ export type SignerWalletAdapter<Name extends string = string> =
20
+ WalletAdapter<Name> & SignerWalletAdapterProps<Name>;
21
+
22
+ export abstract class BaseSignerWalletAdapter<Name extends string = string>
23
+ extends BaseWalletAdapter<Name>
24
+ implements SignerWalletAdapter<Name> {}
25
+
26
+ export interface MessageSignerWalletAdapterProps<Name extends string = string>
27
+ extends WalletAdapterProps<Name> {
28
+ requestTransaction(transaction: MidenTransaction): Promise<string>;
29
+ requestAssets(): Promise<Asset[]>;
30
+ requestPrivateNotes(
31
+ noteFilterType: NoteFilterTypes,
32
+ noteIds?: string[]
33
+ ): Promise<InputNoteDetails[]>;
34
+ signBytes(data: Uint8Array, kind: SignKind): Promise<Uint8Array>;
35
+ importPrivateNote(note: Uint8Array): Promise<string>;
36
+ requestConsumableNotes(): Promise<InputNoteDetails[]>;
37
+ waitForTransaction(
38
+ txId: string,
39
+ timeout?: number
40
+ ): Promise<TransactionOutput>;
41
+ requestSend(transaction: MidenSendTransaction): Promise<string>;
42
+ requestConsume(transaction: MidenConsumeTransaction): Promise<string>;
43
+ }
44
+
45
+ export type MessageSignerWalletAdapter<Name extends string = string> =
46
+ WalletAdapter<Name> & MessageSignerWalletAdapterProps<Name>;
47
+
48
+ export abstract class BaseMessageSignerWalletAdapter<
49
+ Name extends string = string
50
+ >
51
+ extends BaseSignerWalletAdapter<Name>
52
+ implements MessageSignerWalletAdapter<Name>
53
+ {
54
+ abstract requestSend(transaction: MidenSendTransaction): Promise<string>;
55
+ abstract requestConsume(
56
+ transaction: MidenConsumeTransaction
57
+ ): Promise<string>;
58
+ abstract requestTransaction(transaction: MidenTransaction): Promise<string>;
59
+ abstract requestAssets(): Promise<Asset[]>;
60
+ abstract requestPrivateNotes(
61
+ noteFilterType: NoteFilterTypes,
62
+ noteIds?: string[]
63
+ ): Promise<InputNoteDetails[]>;
64
+ abstract signBytes(data: Uint8Array, kind: SignKind): Promise<Uint8Array>;
65
+ abstract importPrivateNote(note: Uint8Array): Promise<string>;
66
+ abstract requestConsumableNotes(): Promise<InputNoteDetails[]>;
67
+ abstract waitForTransaction(
68
+ txId: string,
69
+ timeout?: number
70
+ ): Promise<TransactionOutput>;
71
+ }