@tetherto/wdk-wallet 1.0.0-beta.6 → 1.0.0-beta.7
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/AGENTS.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Agent Guide
|
|
2
|
+
|
|
3
|
+
This repository is part of the Tether WDK (Wallet Development Kit) ecosystem. It follows strict coding conventions and tooling standards to ensure consistency, reliability, and cross-platform compatibility (Node.js and Bare runtime).
|
|
4
|
+
|
|
5
|
+
## Project Overview
|
|
6
|
+
- **Architecture:** Modular architecture with clear separation between Core, Wallet managers, and Protocols.
|
|
7
|
+
- **Runtime:** Supports both Node.js and Bare runtime.
|
|
8
|
+
|
|
9
|
+
## Tech Stack & Tooling
|
|
10
|
+
- **Language:** JavaScript (ES2015+).
|
|
11
|
+
- **Module System:** ES Modules (`"type": "module"` in package.json).
|
|
12
|
+
- **Type Checking:** TypeScript is used purely for generating type declarations (`.d.ts`). The source code remains JavaScript.
|
|
13
|
+
- Command: `npm run build:types`
|
|
14
|
+
- **Linting:** `standard` (JavaScript Standard Style).
|
|
15
|
+
- Command: `npm run lint` / `npm run lint:fix`
|
|
16
|
+
- **Testing:** `jest` (configured with `experimental-vm-modules` for ESM support).
|
|
17
|
+
- Command: `npm test`
|
|
18
|
+
- **Dependencies:** `cross-env` is consistently used for environment variable management in scripts.
|
|
19
|
+
|
|
20
|
+
## Coding Conventions
|
|
21
|
+
- **File Naming:** Kebab-case (e.g., `wallet-manager.js`).
|
|
22
|
+
- **Class Naming:** PascalCase (e.g., `WdkManager`).
|
|
23
|
+
- **Private Members:** Prefixed with `_` (underscore) and explicitly documented with `@private`.
|
|
24
|
+
- **Imports:** Explicit file extensions are mandatory (e.g., `import ... from './file.js'`).
|
|
25
|
+
- **Copyright:** All source files must include the standard Tether copyright header.
|
|
26
|
+
|
|
27
|
+
## Documentation (JSDoc)
|
|
28
|
+
Source code must be strictly typed using JSDoc comments to support the `build:types` process.
|
|
29
|
+
- **Types:** Use `@typedef` to define or import types.
|
|
30
|
+
- **Methods:** Use `@param`, `@returns`, `@throws`.
|
|
31
|
+
- **Generics:** Use `@template`.
|
|
32
|
+
|
|
33
|
+
## Development Workflow
|
|
34
|
+
1. **Install:** `npm install`
|
|
35
|
+
2. **Lint:** `npm run lint`
|
|
36
|
+
3. **Test:** `npm test`
|
|
37
|
+
4. **Build Types:** `npm run build:types`
|
|
38
|
+
|
|
39
|
+
## Key Files
|
|
40
|
+
- `index.js`: Main entry point.
|
|
41
|
+
- `bare.js`: Entry point for Bare runtime optimization.
|
|
42
|
+
- `src/`: Core logic.
|
|
43
|
+
- `types/`: Generated type definitions (do not edit manually).
|
|
44
|
+
|
|
45
|
+
## Repository Specifics
|
|
46
|
+
- **Domain:** Base Abstract Classes.
|
|
47
|
+
- **Role:** Defines the standard interfaces and base classes for all specific blockchain wallet implementations.
|
|
48
|
+
- **Key Classes:** `WalletManager`, `WalletAccount`, `WalletAccountReadOnly`, `Protocol`.
|
|
49
|
+
- **Usage:** Primarily a dependency for other `@tetherto/wdk-wallet-*` packages.
|
package/package.json
CHANGED
|
@@ -51,6 +51,18 @@ export class IWalletAccountReadOnly {
|
|
|
51
51
|
throw new NotImplementedError('getAddress()')
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
/**
|
|
55
|
+
* Verifies a message's signature.
|
|
56
|
+
*
|
|
57
|
+
* @param {string} message - The original message.
|
|
58
|
+
* @param {string} signature - The signature to verify.
|
|
59
|
+
* @returns {Promise<boolean>} True if the signature is valid.
|
|
60
|
+
* @throws {Error} If the read-only wallet account class is not able to provide an implementation for the method.
|
|
61
|
+
*/
|
|
62
|
+
async verify (message, signature) {
|
|
63
|
+
throw new NotImplementedError('verify(message, signature)')
|
|
64
|
+
}
|
|
65
|
+
|
|
54
66
|
/**
|
|
55
67
|
* Returns the account's native token balance.
|
|
56
68
|
*
|
|
@@ -139,6 +151,19 @@ export default class WalletAccountReadOnly {
|
|
|
139
151
|
return this._address
|
|
140
152
|
}
|
|
141
153
|
|
|
154
|
+
/**
|
|
155
|
+
* Verifies a message's signature.
|
|
156
|
+
*
|
|
157
|
+
* @abstract
|
|
158
|
+
* @param {string} message - The original message.
|
|
159
|
+
* @param {string} signature - The signature to verify.
|
|
160
|
+
* @returns {Promise<boolean>} True if the signature is valid.
|
|
161
|
+
* @throws {Error} If the read-only wallet account class is not able to provide an implementation for the method.
|
|
162
|
+
*/
|
|
163
|
+
async verify (message, signature) {
|
|
164
|
+
throw new NotImplementedError('verify(message, signature)')
|
|
165
|
+
}
|
|
166
|
+
|
|
142
167
|
/**
|
|
143
168
|
* Returns the account's native token balance.
|
|
144
169
|
*
|
package/src/wallet-manager.js
CHANGED
|
@@ -72,10 +72,12 @@ export default class WalletManager {
|
|
|
72
72
|
/**
|
|
73
73
|
* Returns a random [BIP-39](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki) seed phrase.
|
|
74
74
|
*
|
|
75
|
+
* @param {12 | 24} [wordCount=12] - The number of words in the seed phrase.
|
|
75
76
|
* @returns {string} The seed phrase.
|
|
76
77
|
*/
|
|
77
|
-
static getRandomSeedPhrase () {
|
|
78
|
-
|
|
78
|
+
static getRandomSeedPhrase (wordCount = 12) {
|
|
79
|
+
const strength = wordCount === 24 ? 256 : 128
|
|
80
|
+
return bip39.generateMnemonic(strength)
|
|
79
81
|
}
|
|
80
82
|
|
|
81
83
|
/**
|
|
@@ -6,6 +6,15 @@ export interface IWalletAccountReadOnly {
|
|
|
6
6
|
* @returns {Promise<string>} The account's address.
|
|
7
7
|
*/
|
|
8
8
|
getAddress(): Promise<string>;
|
|
9
|
+
/**
|
|
10
|
+
* Verifies a message's signature.
|
|
11
|
+
*
|
|
12
|
+
* @param {string} message - The original message.
|
|
13
|
+
* @param {string} signature - The signature to verify.
|
|
14
|
+
* @returns {Promise<boolean>} True if the signature is valid.
|
|
15
|
+
* @throws {Error} If the read-only wallet account class is not able to provide an implementation for the method.
|
|
16
|
+
*/
|
|
17
|
+
verify(message: string, signature: string): Promise<boolean>;
|
|
9
18
|
/**
|
|
10
19
|
* Returns the account's native token balance.
|
|
11
20
|
*
|
|
@@ -67,6 +76,16 @@ export default abstract class WalletAccountReadOnly implements IWalletAccountRea
|
|
|
67
76
|
* @returns {Promise<string>} The account's address.
|
|
68
77
|
*/
|
|
69
78
|
getAddress(): Promise<string>;
|
|
79
|
+
/**
|
|
80
|
+
* Verifies a message's signature.
|
|
81
|
+
*
|
|
82
|
+
* @abstract
|
|
83
|
+
* @param {string} message - The original message.
|
|
84
|
+
* @param {string} signature - The signature to verify.
|
|
85
|
+
* @returns {Promise<boolean>} True if the signature is valid.
|
|
86
|
+
* @throws {Error} If the read-only wallet account class is not able to provide an implementation for the method.
|
|
87
|
+
*/
|
|
88
|
+
abstract verify(message: string, signature: string): Promise<boolean>;
|
|
70
89
|
/**
|
|
71
90
|
* Returns the account's native token balance.
|
|
72
91
|
*
|
|
@@ -3,9 +3,10 @@ export default abstract class WalletManager {
|
|
|
3
3
|
/**
|
|
4
4
|
* Returns a random [BIP-39](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki) seed phrase.
|
|
5
5
|
*
|
|
6
|
+
* @param {12 | 24} [wordCount=12] - The number of words in the seed phrase.
|
|
6
7
|
* @returns {string} The seed phrase.
|
|
7
8
|
*/
|
|
8
|
-
static getRandomSeedPhrase(): string;
|
|
9
|
+
static getRandomSeedPhrase(wordCount?: 12 | 24): string;
|
|
9
10
|
/**
|
|
10
11
|
* Checks if a seed phrase is valid.
|
|
11
12
|
*
|