From bebd84fbc4a44064faa773e5ebf76e2632f60200 Mon Sep 17 00:00:00 2001 From: Jonathan Dunne <37194960+jonathunne@users.noreply.github.com> Date: Fri, 26 Sep 2025 00:01:16 +0100 Subject: [PATCH 1/4] feat: rename to WDK, publish workflow --- .github/workflows/build.yml | 14 +++-- .github/workflows/publish.yml | 54 ++++++++++++++++++++ README.md | 2 +- package-lock.json | 25 ++++----- package.json | 13 +++-- src/wallet-account-with-protocols.js | 8 +-- src/wdk-manager.js | 26 +++++----- tests/wdk-manager.test.js | 4 +- types/src/wallet-account-with-protocols.d.ts | 10 ++-- types/src/wdk-manager.d.ts | 12 ++--- 10 files changed, 118 insertions(+), 50 deletions(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6e9a08d..faa3a5f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,16 +10,22 @@ jobs: build: runs-on: ubuntu-latest - steps: + steps: - uses: actions/checkout@v3 - name: Set up Node 22.19.0 uses: actions/setup-node@v4 with: - node-version: "22.19.0" - cache: "npm" + node-version: '22.19.0' + cache: 'npm' + registry-url: 'https://registry.npmjs.org' + - name: Install dependencies run: npm clean-install + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + - name: Lint code with standard run: npm run lint + - name: Run tests - run: npm test + run: npm test \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..1dae277 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,54 @@ +name: publish + +on: + release: + types: [published] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up Node 22.19.0 + uses: actions/setup-node@v4 + with: + node-version: '22.19.0' + cache: 'npm' + registry-url: 'https://registry.npmjs.org' + + - name: Install dependencies + run: npm clean-install + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Lint code with standard + run: npm run lint + + - name: Run tests + run: npm test + + publish: + needs: test + runs-on: ubuntu-latest + environment: npm-publish + + steps: + - uses: actions/checkout@v3 + + - name: Set up Node 22.19.0 + uses: actions/setup-node@v4 + with: + node-version: '22.19.0' + cache: 'npm' + registry-url: 'https://registry.npmjs.org' + + - name: Install dependencies + run: npm clean-install + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Publish to npm + run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file diff --git a/README.md b/README.md index 289a442..07f93fa 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -# @wdk/core +# @tetherto/wdk diff --git a/package-lock.json b/package-lock.json index 7d3988d..0d5eee3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { - "name": "@wdk/core", + "name": "@tetherto/wdk", "version": "1.0.0-beta.2", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "@wdk/core", + "name": "@tetherto/wdk", "version": "1.0.0-beta.2", "license": "Apache-2.0", "dependencies": { - "@wdk/wallet": "https://github.com/davi0kprogramsthings/wdk-wallet#develop", + "@tetherto/wdk-wallet": "^1.0.0-beta.1", "bare-wdk-runtime": "2.0.0" }, "devDependencies": { @@ -1276,6 +1276,16 @@ "@sinonjs/commons": "^3.0.1" } }, + "node_modules/@tetherto/wdk-wallet": { + "version": "1.0.0-beta.1", + "resolved": "https://registry.npmjs.org/@tetherto/wdk-wallet/-/wdk-wallet-1.0.0-beta.1.tgz", + "integrity": "sha512-vs+WyQwrr0RY115WAfq6LuvE424j5gy/ulH1+BgD3O4LToW82u89T9+hLC1Y8snriASoGw8MYPRJbH4Hv/9kMA==", + "license": "Apache-2.0", + "dependencies": { + "bare-wdk-runtime": "2.0.0", + "bip39": "3.1.0" + } + }, "node_modules/@tybys/wasm-util": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.1.tgz", @@ -1676,15 +1686,6 @@ "win32" ] }, - "node_modules/@wdk/wallet": { - "version": "1.0.0-beta.1", - "resolved": "git+ssh://git@github.com/davi0kprogramsthings/wdk-wallet.git#1ad2bb750b5959f5e44bd224eb6ea37cbd08288f", - "license": "Apache-2.0", - "dependencies": { - "bare-wdk-runtime": "2.0.0", - "bip39": "3.1.0" - } - }, "node_modules/abort-controller": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", diff --git a/package.json b/package.json index 8608704..948e0ed 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,11 @@ { - "name": "@wdk/core", + "name": "@tetherto/wdk", "version": "1.0.0-beta.2", "description": "A flexible manager that can register and manage multiple wallet instances for different blockchains dynamically.", - "keywords": ["wdk", "core"], + "keywords": [ + "wdk", + "core" + ], "author": "Tether", "license": "Apache-2.0", "repository": { @@ -20,7 +23,7 @@ "test:coverage": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --coverage" }, "dependencies": { - "@wdk/wallet": "https://github.com/davi0kprogramsthings/wdk-wallet#develop", + "@tetherto/wdk-wallet": "^1.0.0-beta.1", "bare-wdk-runtime": "2.0.0" }, "devDependencies": { @@ -39,6 +42,10 @@ "default": "./package.json" } }, + "publishConfig": { + "access": "restricted", + "registry": "https://registry.npmjs.org/" + }, "standard": { "ignore": [ "bare.js", diff --git a/src/wallet-account-with-protocols.js b/src/wallet-account-with-protocols.js index 0450e0c..b490df6 100644 --- a/src/wallet-account-with-protocols.js +++ b/src/wallet-account-with-protocols.js @@ -14,13 +14,13 @@ 'use strict' -import { IWalletAccount, NotImplementedError } from '@wdk/wallet' +import { IWalletAccount, NotImplementedError } from '@tetherto/wdk-wallet' -/** @typedef {import('@wdk/wallet/protocols').ISwapProtocol} ISwapProtocol */ +/** @typedef {import('@tetherto/wdk-wallet/protocols').ISwapProtocol} ISwapProtocol */ -/** @typedef {import('@wdk/wallet/protocols').IBridgeProtocol} IBridgeProtocol */ +/** @typedef {import('@tetherto/wdk-wallet/protocols').IBridgeProtocol} IBridgeProtocol */ -/** @typedef {import('@wdk/wallet/protocols').ILendingProtocol} ILendingProtocol */ +/** @typedef {import('@tetherto/wdk-wallet/protocols').ILendingProtocol} ILendingProtocol */ /** @interface */ export class IWalletAccountWithProtocols extends IWalletAccount { diff --git a/src/wdk-manager.js b/src/wdk-manager.js index 2e64784..3ae6fa3 100644 --- a/src/wdk-manager.js +++ b/src/wdk-manager.js @@ -14,27 +14,27 @@ 'use strict' -import WalletManager from '@wdk/wallet' +import WalletManager from '@tetherto/wdk-wallet' -import { SwapProtocol, BridgeProtocol, LendingProtocol } from '@wdk/wallet/protocols' +import { SwapProtocol, BridgeProtocol, LendingProtocol } from '@tetherto/wdk-wallet/protocols' -/** @typedef {import('@wdk/wallet').IWalletAccount} IWalletAccount */ +/** @typedef {import('@tetherto/wdk-wallet').IWalletAccount} IWalletAccount */ -/** @typedef {import('@wdk/wallet').FeeRates} FeeRates */ +/** @typedef {import('@tetherto/wdk-wallet').FeeRates} FeeRates */ /** @typedef {import('./wallet-account-with-protocols.js').IWalletAccountWithProtocols} IWalletAccountWithProtocols */ /** @typedef {(account: A) => Promise} MiddlewareFunction */ -export default class WdkManager { +export default class WDK { /** - * Creates a new wallet development kit manager. + * Creates a new wallet development kit instance. * * @param {string | Uint8Array} seed - The wallet's BIP-39 seed phrase. * @throws {Error} If the seed is not valid. */ constructor (seed) { - if (!WdkManager.isValidSeed(seed)) { + if (!WDK.isValidSeed(seed)) { throw new Error('Invalid seed.') } @@ -75,13 +75,13 @@ export default class WdkManager { } /** - * Registers a new wallet to the wdk manager. + * Registers a new wallet to WDK. * * @template {typeof WalletManager} W * @param {string} blockchain - The name of the blockchain the wallet must be bound to. Can be any string (e.g., "ethereum"). * @param {W} WalletManager - The wallet manager class. * @param {ConstructorParameters[1]} config - The configuration object. - * @returns {WdkManager} The wdk manager. + * @returns {WDK} The wdk instance. */ registerWallet (blockchain, WalletManager, config) { const wallet = new WalletManager(this._seed, config) @@ -92,7 +92,7 @@ export default class WdkManager { } /** - * Registers a new protocol to the wdk manager. + * Registers a new protocol to WDK. * * The label must be unique in the scope of the blockchain and the type of protocol (i.e., there can't be two protocols of the * same type bound to the same blockchain with the same label). @@ -103,7 +103,7 @@ export default class WdkManager { * @param {string} label - The label. * @param {P} Protocol - The protocol class. * @param {ConstructorParameters

[1]} config - The protocol configuration. - * @returns {WdkManager} The wdk manager. + * @returns {WDK} The wdk instance. */ registerProtocol (blockchain, label, Protocol, config) { if (Protocol.prototype instanceof SwapProtocol) { @@ -124,13 +124,13 @@ export default class WdkManager { } /** - * Registers a new middleware to the wdk manager. + * Registers a new middleware to WDK. * * It's possible to register multiple middlewares for the same blockchain, which will be called sequentially. * * @param {string} blockchain - The name of the blockchain the middleware must be bound to. Can be any string (e.g., "ethereum"). * @param {MiddlewareFunction} middleware - A callback function that is called each time the user derives a new account. - * @returns {WdkManager} The wdk manager. + * @returns {WDK} The wdk instance. */ registerMiddleware (blockchain, middleware) { this._middlewares[blockchain] ??= [] diff --git a/tests/wdk-manager.test.js b/tests/wdk-manager.test.js index a93610f..5dc3c3e 100644 --- a/tests/wdk-manager.test.js +++ b/tests/wdk-manager.test.js @@ -1,8 +1,8 @@ import { beforeEach, describe, expect, jest, test } from '@jest/globals' -import WalletManager from '@wdk/wallet' +import WalletManager from '@tetherto/wdk-wallet' -import { BridgeProtocol, LendingProtocol, SwapProtocol } from '@wdk/wallet/protocols' +import { BridgeProtocol, LendingProtocol, SwapProtocol } from '@tetherto/wdk-wallet/protocols' import WdkManager from '../index.js' diff --git a/types/src/wallet-account-with-protocols.d.ts b/types/src/wallet-account-with-protocols.d.ts index b99b7cc..70d8fc1 100644 --- a/types/src/wallet-account-with-protocols.d.ts +++ b/types/src/wallet-account-with-protocols.d.ts @@ -38,8 +38,8 @@ export interface IWalletAccountWithProtocols extends IWalletAccount { */ getLendingProtocol(label: string): ILendingProtocol; } -export type ISwapProtocol = import("@wdk/wallet/protocols").ISwapProtocol; -export type IBridgeProtocol = import("@wdk/wallet/protocols").IBridgeProtocol; -export type ILendingProtocol = import("@wdk/wallet/protocols").ILendingProtocol; -import { IWalletAccount } from "@wdk/wallet"; -import { SwapProtocol, BridgeProtocol, LendingProtocol } from "@wdk/wallet/protocols"; +export type ISwapProtocol = import("@tetherto/wdk-wallet/protocols").ISwapProtocol; +export type IBridgeProtocol = import("@tetherto/wdk-wallet/protocols").IBridgeProtocol; +export type ILendingProtocol = import("@tetherto/wdk-wallet/protocols").ILendingProtocol; +import { IWalletAccount } from "@tetherto/wdk-wallet"; +import { SwapProtocol, BridgeProtocol, LendingProtocol } from "@tetherto/wdk-wallet/protocols"; diff --git a/types/src/wdk-manager.d.ts b/types/src/wdk-manager.d.ts index d3caf3c..f82c2d4 100644 --- a/types/src/wdk-manager.d.ts +++ b/types/src/wdk-manager.d.ts @@ -97,11 +97,11 @@ export default class WdkManager { /** @private */ private _registerProtocols; } -export type IWalletAccount = import("@wdk/wallet").IWalletAccount; -export type FeeRates = import("@wdk/wallet").FeeRates; +export type IWalletAccount = import("@tetherto/wdk-wallet").IWalletAccount; +export type FeeRates = import("@tetherto/wdk-wallet").FeeRates; export type IWalletAccountWithProtocols = import("./wallet-account-with-protocols.js").IWalletAccountWithProtocols; export type MiddlewareFunction = (account: A) => Promise; -import WalletManager from "@wdk/wallet"; -import { SwapProtocol } from "@wdk/wallet/protocols"; -import { BridgeProtocol } from "@wdk/wallet/protocols"; -import { LendingProtocol } from "@wdk/wallet/protocols"; +import WalletManager from "@tetherto/wdk-wallet"; +import { SwapProtocol } from "@tetherto/wdk-wallet/protocols"; +import { BridgeProtocol } from "@tetherto/wdk-wallet/protocols"; +import { LendingProtocol } from "@tetherto/wdk-wallet/protocols"; From acfb95d6fb09cd94cd5fa174e4150afaa24e6f09 Mon Sep 17 00:00:00 2001 From: Jonathan Dunne Date: Fri, 26 Sep 2025 19:18:26 +1000 Subject: [PATCH 2/4] Update tests/wdk-manager.test.js Co-authored-by: Chetas Murali --- tests/wdk-manager.test.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/wdk-manager.test.js b/tests/wdk-manager.test.js index 5dc3c3e..2e0a573 100644 --- a/tests/wdk-manager.test.js +++ b/tests/wdk-manager.test.js @@ -1,3 +1,5 @@ +'use strict' + import { beforeEach, describe, expect, jest, test } from '@jest/globals' import WalletManager from '@tetherto/wdk-wallet' From dc8dc2ad1e638e12acbf8fb32e4f9b751ed8dd0b Mon Sep 17 00:00:00 2001 From: Jonathan Dunne Date: Fri, 26 Sep 2025 19:18:44 +1000 Subject: [PATCH 3/4] Update .github/workflows/build.yml Co-authored-by: Chetas Murali --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index faa3a5f..9bcd9b0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,7 @@ jobs: build: runs-on: ubuntu-latest - steps: + steps: - uses: actions/checkout@v3 - name: Set up Node 22.19.0 uses: actions/setup-node@v4 From d9d39f97edb1b572c0ab96caef8313382c1cb489 Mon Sep 17 00:00:00 2001 From: Jonathan Dunne <37194960+jonathunne@users.noreply.github.com> Date: Fri, 26 Sep 2025 14:39:07 +0100 Subject: [PATCH 4/4] add README --- README.md | 154 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 153 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 07f93fa..fc48823 100644 --- a/README.md +++ b/README.md @@ -1 +1,153 @@ -# @tetherto/wdk +# WDK Core + +**WDK** is a simple tool that enables you to manage the WDK wallet and protocol modules through a single object. + +### Modules Managed + +**Wallet Modules** - Add wallet support for any blockchain: +- `@tetherto/wdk-wallet-evm` - Ethereum, Polygon, Arbitrum +- `@tetherto/wdk-wallet-evm-erc4337` - EVM with no gas fees +- `@tetherto/wdk-wallet-ton` - TON blockchain +- `@tetherto/wdk-wallet-ton-gasless` - TON with no gas fees +- `@tetherto/wdk-wallet-btc` - Bitcoin +- `@tetherto/wdk-wallet-tron` - TRON blockchain +- `@tetherto/wdk-wallet-solana` - Solana blockchain + +**Service Modules** - Add swap, bridge, and lending services: +- `@tetherto/wdk-protocol-swap-paraswap-evm` - Token swaps on EVM +- `@tetherto/wdk-protocol-bridge-usdt0-evm` - Bridge tokens between EVM chains +- `@tetherto/wdk-protocol-bridge-usdt0-ton` - Bridge tokens from TON to other chains +- `@tetherto/wdk-protocol-lending-aave-evm` - Lending and borrowing on EVM + +**📚 Full module list and docs:** [docs.wallet.tether.io](https://docs.wallet.tether.io) + +## Features + +- **Module Manager**: Controls and connects all WDK wallet and service modules +- **Wallet Modules**: Works with `@tetherto/wdk-wallet-evm`, `@tetherto/wdk-wallet-evm-erc-4337`, `@tetherto/wdk-wallet-tron` and other wallet packages +- **Service Modules**: Manages `@tetherto/wdk-protocol-bridge-usdt0-evm`, `@tetherto/wdk-protocol-bridge-usdt0-ton` and other service packages +- **One Setup**: Add any WDK module when you need it for any blockchain +- **Simple Control**: Manage all your wallet and service modules in one place + +## How to Install + +```bash +npm install @tetherto/wdk +``` + +## Quick Start + +```typescript +import WDK from '@tetherto/wdk' +import WalletManagerEvm from '@tetherto/wdk-wallet-evm' +import WalletManagerTon from '@tetherto/wdk-wallet-ton' +import ParaswapProtocolEvm from '@tetherto/wdk-protocol-swap-paraswap-evm' +import Usdt0ProtocolTon from '@tetherto/wdk-protocol-bridge-usdt0-ton' + +// Set up WDK with wallets and services +const wdk = new WDK(seed) //seed are your twelve word phrase + .registerWallet('ethereum', WalletManagerEvm, ethereumWalletConfig) + .registerWallet('ton', WalletManagerTon, tonWalletConfig) + .registerProtocol('ethereum', 'paraswap', ParaswapProtocolEvm, paraswapProtocolConfig) + .registerProtocol('ton', 'usdt0', Usdt0ProtocolTon, usdt0ProtocolConfig) + +// Get accounts using different ways +const ethAccount = await wdk.getAccount('ethereum', 3) +const tonAccount = await wdk.getAccountByPath('ton', "1'/2/3") + +// Send transactions directly +const { hash: txHash, fee: txFee } = await ethAccount.sendTransaction(tx) + +// Use swap service +const paraswap = ethAccount.getSwapProtocol('paraswap') +const { hash: swapHash, fee: swapFee } = await paraswap.swap(swapOptions) + +// Use bridge service +const usdt0 = tonAccount.getBridgeProtocol('usdt0') +const { hash: bridgeHash, fee: bridgeFee } = await usdt0.bridge(bridgeOptions) + +// These will throw errors: +// const accountTron = await wdk.getAccount('tron', 5) // no tron wallet added +// const badBridge = accountEth.getBridgeProtocol('usdt0') // no usdt0 for ethereum +// const badSwap = tonAccount.getSwapProtocol('dedust') // no dedust for ton +``` + +## How to Use + +### WDK + +#### Start +```typescript +constructor(seed: string | Uint8Array) +``` + +#### Add Things +- `registerWallet(blockchain: string, wallet: W, config: WalletConfig): WDK` +- `registerProtocol

(blockchain: string, label: string, protocol: P, config: ProtocolConfig): WDK` +- `registerMiddleware(blockchain: string, middleware: MiddlewareFunction): WDK` + +#### Get Accounts +- `getAccount(blockchain: string, index?: number): Promise` +- `getAccountByPath(blockchain: string, path: string): Promise` +- `getFeeRates(blockchain: string): Promise` + +#### Other Tools +- `dispose(): void` + +#### Helper Tools +- `getRandomSeedPhrase(): string` +- `isValidSeedPhrase(seedPhrase: string): boolean` + +### Account with Services + +Works with a basic wallet account but adds service management: + +- `registerProtocol

(label: string, protocol: P, config: ProtocolConfig): IWalletAccountWithProtocols` +- `getSwapProtocol(label: string): ISwapProtocol` - Gets the swap service with the given name +- `getBridgeProtocol(label: string): IBridgeProtocol` - Gets the bridge service with the given name +- `getLendingProtocol(label: string): ILendingProtocol` - Gets the lending service with the given name + +## How to Use It + +### Add Many Blockchains +```typescript +const wdk = new WDK(seed) //seed are your twelve word phrase + .registerWallet('ethereum', WalletManagerEvm, ethereumWalletConfig) + .registerWallet('arbitrum', WalletManagerEvm, arbitrumWalletConfig) + .registerWallet('ton', WalletManagerTon, tonWalletConfig) +``` + +### Add Services to One Account +```typescript +const account = await wdk.getAccount('ethereum', 0) +account.registerProtocol('paraswap', ParaswapProtocolEvm, paraswapProtocolConfig) + +const paraswap = account.getSwapProtocol('paraswap') +const { hash, fee } = await paraswap.swap(swapOptions) + +// This will throw an error - no service with this name: +// const uniswap = account.getSwapProtocol('uniswap') +``` + +### Add Extra Tools to Accounts +```typescript +wdk.registerMiddleware('ethereum', async (account) => { + console.log('New account:', await account.getAddress()) +}) +``` + +## License + +This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details. + +## Contributing + +Contributions are welcome! Please feel free to submit a Pull Request. + +## Support + +For support, please open an issue on the GitHub repository. + +## Learn More + +For full docs, visit [docs.wallet.tether.io](https://docs.wallet.tether.io) \ No newline at end of file