Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
54 changes: 54 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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 }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# @wdk/core
# @tetherto/wdk
25 changes: 13 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand All @@ -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": {
Expand All @@ -39,6 +42,10 @@
"default": "./package.json"
}
},
"publishConfig": {
"access": "restricted",
"registry": "https://registry.npmjs.org/"
},
"standard": {
"ignore": [
"bare.js",
Expand Down
8 changes: 4 additions & 4 deletions src/wallet-account-with-protocols.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
26 changes: 13 additions & 13 deletions src/wdk-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {<A extends IWalletAccount>(account: A) => Promise<void>} 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.')
}

Expand Down Expand Up @@ -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<W>[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)
Expand All @@ -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).
Expand All @@ -103,7 +103,7 @@ export default class WdkManager {
* @param {string} label - The label.
* @param {P} Protocol - The protocol class.
* @param {ConstructorParameters<P>[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) {
Expand All @@ -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] ??= []
Expand Down
4 changes: 2 additions & 2 deletions tests/wdk-manager.test.js
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
10 changes: 5 additions & 5 deletions types/src/wallet-account-with-protocols.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
12 changes: 6 additions & 6 deletions types/src/wdk-manager.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <A extends IWalletAccount>(account: A) => Promise<void>;
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";
Loading