diff --git a/.changeset/kind-fans-jog.md b/.changeset/kind-fans-jog.md
new file mode 100644
index 0000000..9408a19
--- /dev/null
+++ b/.changeset/kind-fans-jog.md
@@ -0,0 +1,5 @@
+---
+'@fedimint/core-web': patch
+---
+
+Added Example projects to docs containing Stackblitz previews
diff --git a/.github/workflows/deploy-preview.yml b/.github/workflows/deploy-preview.yml
index f25baf4..d879cbd 100644
--- a/.github/workflows/deploy-preview.yml
+++ b/.github/workflows/deploy-preview.yml
@@ -1,3 +1,4 @@
+# NO LONGER USED - the docs site is now being deployed to github pages instead of the example
name: Deploy Vite-Core Example to GitHub Pages
on:
diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts
index 5e6239e..11cf78b 100644
--- a/docs/.vitepress/config.ts
+++ b/docs/.vitepress/config.ts
@@ -49,7 +49,7 @@ export default withMermaid({
},
nav: [
{ text: 'Documentation', link: '/core/getting-started' },
- { text: 'Examples', link: '/examples' },
+ { text: 'Examples', link: '/examples/vite-react' },
{
text: 'More',
items: [
diff --git a/docs/.vitepress/sidebar.ts b/docs/.vitepress/sidebar.ts
index 9d4b135..ecb1911 100644
--- a/docs/.vitepress/sidebar.ts
+++ b/docs/.vitepress/sidebar.ts
@@ -22,6 +22,16 @@ export function getSidebar() {
],
},
],
+ '/examples/': [
+ {
+ base: '/examples/',
+ text: 'Examples',
+ items: [
+ { text: 'Vite + React', link: 'vite-react' },
+ { text: 'Vanilla JS', link: 'bare-js' },
+ ],
+ },
+ ],
} satisfies DefaultTheme.Sidebar
}
diff --git a/docs/core/FedimintWallet/constructor.md b/docs/core/FedimintWallet/constructor.md
index 9328369..124697a 100644
--- a/docs/core/FedimintWallet/constructor.md
+++ b/docs/core/FedimintWallet/constructor.md
@@ -1,4 +1,4 @@
-# FedimintWallet
+# new FedimintWallet()t
Creates a new instance of FedimintWallet.
@@ -39,15 +39,13 @@ until needed. Default is false.
import { FedimintWallet } from '@fedimint/core-web'
// Create a wallet with immediate initialization
-const wallet = new FedimintWallet()
+const wallet = new FedimintWallet() // wasm gets initialized here
wallet.open()
// Create a wallet with lazy initialization
-const lazyWallet = new FedimintWallet(true)
+const lazyWallet = new FedimintWallet(true) // lazy = true
// Some time later...
-lazyWallet.initialize().then(() => {
- lazyWallet.open()
-})
+lazyWallet.open() // wasm gets initialized here
```
#### Defined in
diff --git a/docs/core/FedimintWallet/index.md b/docs/core/FedimintWallet/index.md
index 73d5b42..30e72e0 100644
--- a/docs/core/FedimintWallet/index.md
+++ b/docs/core/FedimintWallet/index.md
@@ -1,4 +1,4 @@
-# Wallet Overview
+# FedimintWallet Overview
The `FedimintWallet` class serves as the main entry point for the library. It orchestrates the various services and the WorkerClient.
diff --git a/docs/core/getting-started.md b/docs/core/getting-started.md
index e6a61c7..ac45d72 100644
--- a/docs/core/getting-started.md
+++ b/docs/core/getting-started.md
@@ -87,6 +87,8 @@ Currently requires modifying the library and utilizing the `@fedimint/wasm-web`
See the [bare-js sample app](https://github.com/fedimint/fedimint-web-sdk/tree/main/examples/bare-js) for a full working example.
+:::
+
### Webpack
::: details Webpack Setup
@@ -187,12 +189,6 @@ Check out the Vite + React example in the [`examples/vite-core`](https://github.
For a list of public federations with invite codes, visit [Bitcoin Mints](https://bitcoinmints.com/?tab=mints&showFedimint=true).
-## Next Steps
-
-- **API Reference**: Browse the collection of available methods and learn how to use them.
-- **Advanced Usage**: Discover more complex scenarios and best practices for using @fedimint/core-web.
-- **Framework Integration**: Learn how to integrate @fedimint/core-web with popular front-end frameworks.
-
## What's Next?
- To see the sdk in action, check out the [examples](../examples/index.md)
diff --git a/docs/examples/bare-js.md b/docs/examples/bare-js.md
new file mode 100644
index 0000000..0b4d640
--- /dev/null
+++ b/docs/examples/bare-js.md
@@ -0,0 +1,23 @@
+# Bare JS Example
+
+This example shows how to use the `core-web` package in a bare javascript environment (no bundler).
+
+There's no ui, so open your browser's console to see the library in action.
+
+## Live Preview
+
+
+
+[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/fedimint/fedimint-web-sdk/tree/main/examples/bare-js)
+
+## Running the Example Locally
+
+```bash
+# from the root of the repo
+
+# install dependencies
+pnpm i
+
+# run the dev server
+pnpm run dev:bare
+```
diff --git a/docs/examples/index.md b/docs/examples/index.md
deleted file mode 100644
index e69de29..0000000
diff --git a/docs/examples/vite-react.md b/docs/examples/vite-react.md
new file mode 100644
index 0000000..7c5c496
--- /dev/null
+++ b/docs/examples/vite-react.md
@@ -0,0 +1,21 @@
+# Vite + React Example
+
+This is an example application demonstrating the usage of Fedimint client in React Application application.
+
+## Live Preview
+
+
+
+[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/fedimint/fedimint-web-sdk/tree/main/examples/vite-core)
+
+## Running the Example Locally
+
+```bash
+# from the root of the repo
+
+# install dependencies
+pnpm i
+
+# run the dev server
+pnpm run dev:vite
+```
diff --git a/examples/bare-js/README.md b/examples/bare-js/README.md
index f2377d9..0b4d640 100644
--- a/examples/bare-js/README.md
+++ b/examples/bare-js/README.md
@@ -2,11 +2,22 @@
This example shows how to use the `core-web` package in a bare javascript environment (no bundler).
-## Running the example
+There's no ui, so open your browser's console to see the library in action.
+
+## Live Preview
+
+
+
+[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/fedimint/fedimint-web-sdk/tree/main/examples/bare-js)
+
+## Running the Example Locally
```bash
# from the root of the repo
+
+# install dependencies
+pnpm i
+
+# run the dev server
pnpm run dev:bare
```
-
-There's no ui, so open your browser's console to see the library in action.
\ No newline at end of file
diff --git a/examples/bare-js/index.html b/examples/bare-js/index.html
index 994b36e..e18a6b4 100644
--- a/examples/bare-js/index.html
+++ b/examples/bare-js/index.html
@@ -2,19 +2,58 @@
@@ -270,6 +291,12 @@ const GenerateLightningInvoice = () => {
{generating ? 'Generating...' : 'Generate Invoice'}
+
{invoice && (
Generated Invoice:
diff --git a/examples/vite-core/src/index.css b/examples/vite-core/src/index.css
index bc3c1e9..dac231d 100644
--- a/examples/vite-core/src/index.css
+++ b/examples/vite-core/src/index.css
@@ -37,6 +37,12 @@ header {
text-align: center;
}
+.steps {
+ text-align: left;
+ display: inline-block;
+ font-size: 1.2rem;
+}
+
main {
display: flex;
flex-direction: column;
diff --git a/package.json b/package.json
index b1ccb20..804ccff 100644
--- a/package.json
+++ b/package.json
@@ -3,11 +3,10 @@
"type": "module",
"scripts": {
"build": "pnpm run --r --filter \"./packages/**\" build",
- "build:pages": "pnpm --filter vite-core build:pages",
"clean": "pnpm run --r --parallel clean && rm -rf packages/**/*.json.tmp",
"clean:deep": "rm -rf node_modules && pnpm run --r --parallel clean:deep",
"deps": "pnpx taze -r",
- "dev": "pnpm dev:vite",
+ "dev": "pnpm build && pnpm dev:vite",
"dev:vite": "pnpm --filter vite-core dev",
"dev:bare": "pnpm run --filter bare-js server",
"docs:dev": "pnpm run --filter docs docs:dev",
@@ -21,7 +20,7 @@
"prepare": "pnpm simple-git-hooks",
"preview": "pnpm --filter vite-core preview",
"release": "pnpm run build && pnpm changeset publish",
- "reset": "pnpm clean && pnpm build && pnpm build:pages && pnpm preview",
+ "reset": "pnpm clean && pnpm build && pnpm preview",
"changeset": "changeset",
"version": "changeset version",
"typecheck": "pnpm run --r --parallel typecheck",
diff --git a/packages/core-web/README.md b/packages/core-web/README.md
index 7e401cd..46fff7a 100644
--- a/packages/core-web/README.md
+++ b/packages/core-web/README.md
@@ -69,7 +69,7 @@ const unsubscribe = wallet.balance.subscribeBalance((balance: number) => {
await wallet.mint.reissueNotes('A11qgqpw9thwvaz7t...')
// Pay Lightning Invoice
-await wallet.lightning.payBolt11Invoice('lnbc...')
+await wallet.lightning.payInvoice('lnbc...')
```
### Check out the example
diff --git a/packages/core-web/src/FedimintWallet.test.ts b/packages/core-web/src/FedimintWallet.test.ts
index e3d579c..f0bede3 100644
--- a/packages/core-web/src/FedimintWallet.test.ts
+++ b/packages/core-web/src/FedimintWallet.test.ts
@@ -1,18 +1,15 @@
-import { test, expect, vi } from 'vitest'
-import { FedimintWallet } from './FedimintWallet'
+import { test, expect } from 'vitest'
+import { TestFedimintWallet } from './test/TestFedimintWallet'
import { beforeAll } from 'vitest'
let randomTestingId: string
-let wallet: FedimintWallet
-// Testnet
-const TESTING_FEDERATION =
- 'fed11qgqrgvnhwden5te0v9k8q6rp9ekh2arfdeukuet595cr2ttpd3jhq6rzve6zuer9wchxvetyd938gcewvdhk6tcqqysptkuvknc7erjgf4em3zfh90kffqf9srujn6q53d6r056e4apze5cw27h75'
+let wallet: TestFedimintWallet
beforeAll(() => {
randomTestingId = Math.random().toString(36).substring(2, 15)
- wallet = new FedimintWallet()
- expect(wallet._testing).toBeDefined()
- expect(wallet._testing!.getRequestCounter()).toBe(1)
+ wallet = new TestFedimintWallet()
+ expect(wallet.testing).toBeDefined()
+ expect(wallet.testing.getRequestCounter()).toBe(1)
expect(wallet).toBeDefined()
// Cleanup after all tests
@@ -32,11 +29,11 @@ test('initial open & join', async () => {
// On initial open, it should return false
// because no federations have been joined
await expect(wallet.open(randomTestingId)).resolves.toBe(false)
- const beforeJoin = wallet._testing!.getRequestCounter()
+ const beforeJoin = wallet.testing.getRequestCounter()
await expect(
- wallet.joinFederation(TESTING_FEDERATION, randomTestingId),
+ wallet.joinFederation(wallet.testing.TESTING_INVITE, randomTestingId),
).resolves.toBeUndefined()
- expect(wallet._testing!.getRequestCounter()).toBe(beforeJoin + 1)
+ expect(wallet.testing.getRequestCounter()).toBe(beforeJoin + 1)
expect(wallet.isOpen()).toBe(true)
await expect(wallet.waitForOpen()).resolves.toBeUndefined()
})
@@ -56,7 +53,7 @@ test('Error on open & join if wallet is already open', async () => {
// Test joining federation on an already open wallet
try {
- await wallet.joinFederation(TESTING_FEDERATION, randomTestingId)
+ await wallet.joinFederation(wallet.testing.TESTING_INVITE, randomTestingId)
expect.unreachable('Joining a federation should fail on an open wallet')
} catch (error) {
expect(error).toBeInstanceOf(Error)
diff --git a/packages/core-web/src/FedimintWallet.ts b/packages/core-web/src/FedimintWallet.ts
index bd81da4..ab2de2a 100644
--- a/packages/core-web/src/FedimintWallet.ts
+++ b/packages/core-web/src/FedimintWallet.ts
@@ -7,7 +7,6 @@ import {
RecoveryService,
} from './services'
import { logger, type LogLevel } from './utils/logger'
-import { TestingService } from './services/TestingService'
const DEFAULT_CLIENT_NAME = 'fm-default' as const
@@ -20,8 +19,6 @@ export class FedimintWallet {
public federation: FederationService
public recovery: RecoveryService
- public _testing?: TestingService
-
private _openPromise: Promise | null = null
private _resolveOpen: () => void = () => {}
private _isOpen: boolean = false
@@ -65,9 +62,6 @@ export class FedimintWallet {
this.balance = new BalanceService(this._client)
this.federation = new FederationService(this._client)
this.recovery = new RecoveryService(this._client)
- if (process.env.NODE_ENV === 'test') {
- this._testing = new TestingService(this._client)
- }
logger.info('FedimintWallet instantiated')
diff --git a/packages/core-web/src/services/BalanceService.test.ts b/packages/core-web/src/services/BalanceService.test.ts
index 1612586..8f01186 100644
--- a/packages/core-web/src/services/BalanceService.test.ts
+++ b/packages/core-web/src/services/BalanceService.test.ts
@@ -1,19 +1,16 @@
import { test, expect } from 'vitest'
-import { FedimintWallet } from '../FedimintWallet'
+import { TestFedimintWallet } from '../test/TestFedimintWallet'
import { beforeAll } from 'vitest'
let randomTestingId: string
-let wallet: FedimintWallet
-// Testnet
-const TESTING_FEDERATION =
- 'fed11qgqrgvnhwden5te0v9k8q6rp9ekh2arfdeukuet595cr2ttpd3jhq6rzve6zuer9wchxvetyd938gcewvdhk6tcqqysptkuvknc7erjgf4em3zfh90kffqf9srujn6q53d6r056e4apze5cw27h75'
+let wallet: TestFedimintWallet
beforeAll(async () => {
randomTestingId = Math.random().toString(36).substring(2, 15)
- wallet = new FedimintWallet()
+ wallet = new TestFedimintWallet()
expect(wallet).toBeDefined()
await expect(
- wallet.joinFederation(TESTING_FEDERATION, randomTestingId),
+ wallet.joinFederation(wallet.testing.TESTING_INVITE, randomTestingId),
).resolves.toBeUndefined()
expect(wallet.isOpen()).toBe(true)
@@ -31,24 +28,22 @@ beforeAll(async () => {
test('getBalance should be initially zero', async () => {
expect(wallet).toBeDefined()
expect(wallet.isOpen()).toBe(true)
- const beforeGetBalance = wallet._testing!.getRequestCounter()
+ const beforeGetBalance = wallet.testing.getRequestCounter()
await expect(wallet.balance.getBalance()).resolves.toEqual(0)
- expect(wallet._testing!.getRequestCounter()).toBe(beforeGetBalance + 1)
+ expect(wallet.testing.getRequestCounter()).toBe(beforeGetBalance + 1)
})
test('subscribe balance', async () => {
expect(wallet).toBeDefined()
expect(wallet.isOpen()).toBe(true)
- const counterBefore = wallet._testing!.getRequestCounter()
- const callbacksBefore = wallet._testing!.getRequestCallbackMap().size
+ const counterBefore = wallet.testing.getRequestCounter()
+ const callbacksBefore = wallet.testing.getRequestCallbackMap().size
const unsubscribe = await wallet.balance.subscribeBalance((balance) => {
expect(balance).toEqual(0)
})
- expect(wallet._testing!.getRequestCounter()).toBe(counterBefore + 1)
- expect(wallet._testing!.getRequestCallbackMap().size).toBe(
- callbacksBefore + 1,
- )
+ expect(wallet.testing.getRequestCounter()).toBe(counterBefore + 1)
+ expect(wallet.testing.getRequestCallbackMap().size).toBe(callbacksBefore + 1)
await expect(wallet.balance.getBalance()).resolves.toEqual(0)
expect(unsubscribe()).toBeUndefined()
diff --git a/packages/core-web/src/services/FederationService.test.ts b/packages/core-web/src/services/FederationService.test.ts
index 5807324..33986be 100644
--- a/packages/core-web/src/services/FederationService.test.ts
+++ b/packages/core-web/src/services/FederationService.test.ts
@@ -1,19 +1,16 @@
import { test, expect } from 'vitest'
-import { FedimintWallet } from '../FedimintWallet'
+import { TestFedimintWallet } from '../test/TestFedimintWallet'
import { beforeAll } from 'vitest'
let randomTestingId: string
-let wallet: FedimintWallet
-// Testnet
-const TESTING_FEDERATION =
- 'fed11qgqrgvnhwden5te0v9k8q6rp9ekh2arfdeukuet595cr2ttpd3jhq6rzve6zuer9wchxvetyd938gcewvdhk6tcqqysptkuvknc7erjgf4em3zfh90kffqf9srujn6q53d6r056e4apze5cw27h75'
+let wallet: TestFedimintWallet
beforeAll(async () => {
randomTestingId = Math.random().toString(36).substring(2, 15)
- wallet = new FedimintWallet()
+ wallet = new TestFedimintWallet()
expect(wallet).toBeDefined()
await expect(
- wallet.joinFederation(TESTING_FEDERATION, randomTestingId),
+ wallet.joinFederation(wallet.testing.TESTING_INVITE, randomTestingId),
).resolves.toBeUndefined()
expect(wallet.isOpen()).toBe(true)
@@ -31,7 +28,7 @@ beforeAll(async () => {
test('getConfig should return the federation config', async () => {
expect(wallet).toBeDefined()
expect(wallet.isOpen()).toBe(true)
- const counterBefore = wallet._testing!.getRequestCounter()
+ const counterBefore = wallet.testing.getRequestCounter()
await expect(wallet.federation.getConfig()).resolves.toMatchObject({
api_endpoints: expect.any(Object),
broadcast_public_keys: expect.any(Object),
@@ -39,36 +36,35 @@ test('getConfig should return the federation config', async () => {
meta: expect.any(Object),
modules: expect.any(Object),
})
- expect(wallet._testing!.getRequestCounter()).toBe(counterBefore + 1)
+ expect(wallet.testing.getRequestCounter()).toBe(counterBefore + 1)
})
test('getFederationId should return the federation id', async () => {
expect(wallet).toBeDefined()
expect(wallet.isOpen()).toBe(true)
- const counterBefore = wallet._testing!.getRequestCounter()
+ const counterBefore = wallet.testing.getRequestCounter()
const federationId = await wallet.federation.getFederationId()
expect(federationId).toBeTypeOf('string')
expect(federationId).toHaveLength(64)
- expect(wallet._testing!.getRequestCounter()).toBe(counterBefore + 1)
+ expect(wallet.testing.getRequestCounter()).toBe(counterBefore + 1)
})
test('getInviteCode should return the invite code', async () => {
expect(wallet).toBeDefined()
expect(wallet.isOpen()).toBe(true)
- const counterBefore = wallet._testing!.getRequestCounter()
+ const counterBefore = wallet.testing.getRequestCounter()
const inviteCode = await wallet.federation.getInviteCode(0)
expect(inviteCode).toBeTypeOf('string')
- expect(inviteCode).toHaveLength(154)
- expect(wallet._testing!.getRequestCounter()).toBe(counterBefore + 1)
+ expect(wallet.testing.getRequestCounter()).toBe(counterBefore + 1)
})
test('listOperations should return the list of operations', async () => {
expect(wallet).toBeDefined()
expect(wallet.isOpen()).toBe(true)
- const counterBefore = wallet._testing!.getRequestCounter()
+ const counterBefore = wallet.testing.getRequestCounter()
await expect(wallet.federation.listOperations()).resolves.toMatchObject([])
- expect(wallet._testing!.getRequestCounter()).toBe(counterBefore + 1)
+ expect(wallet.testing.getRequestCounter()).toBe(counterBefore + 1)
})
diff --git a/packages/core-web/src/services/LightningService.test.ts b/packages/core-web/src/services/LightningService.test.ts
index 8d91390..3e9b7aa 100644
--- a/packages/core-web/src/services/LightningService.test.ts
+++ b/packages/core-web/src/services/LightningService.test.ts
@@ -1,19 +1,16 @@
import { test, expect } from 'vitest'
-import { FedimintWallet } from '../FedimintWallet'
+import { TestFedimintWallet } from '../test/TestFedimintWallet'
import { beforeAll } from 'vitest'
let randomTestingId: string
-let wallet: FedimintWallet
-// Testnet
-const TESTING_FEDERATION =
- 'fed11qgqrgvnhwden5te0v9k8q6rp9ekh2arfdeukuet595cr2ttpd3jhq6rzve6zuer9wchxvetyd938gcewvdhk6tcqqysptkuvknc7erjgf4em3zfh90kffqf9srujn6q53d6r056e4apze5cw27h75'
+let wallet: TestFedimintWallet
beforeAll(async () => {
randomTestingId = Math.random().toString(36).substring(2, 15)
- wallet = new FedimintWallet()
+ wallet = new TestFedimintWallet()
expect(wallet).toBeDefined()
await expect(
- wallet.joinFederation(TESTING_FEDERATION, randomTestingId),
+ wallet.joinFederation(wallet.testing.TESTING_INVITE, randomTestingId),
).resolves.toBeUndefined()
expect(wallet.isOpen()).toBe(true)
@@ -32,7 +29,7 @@ test('createInvoice should create a bolt11 invoice', async () => {
expect(wallet).toBeDefined()
expect(wallet.isOpen()).toBe(true)
- const counterBefore = wallet._testing!.getRequestCounter()
+ const counterBefore = wallet.testing.getRequestCounter()
const invoice = await wallet.lightning.createInvoice(100, 'test')
expect(invoice).toBeDefined()
expect(invoice).toMatchObject({
@@ -41,7 +38,7 @@ test('createInvoice should create a bolt11 invoice', async () => {
})
// 3 requests were made, one for the invoice, one for refreshing the
// gateway cache, one for getting the gateway info
- expect(wallet._testing!.getRequestCounter()).toBe(counterBefore + 3)
+ expect(wallet.testing.getRequestCounter()).toBe(counterBefore + 3)
// Test with expiry time
await expect(
@@ -53,9 +50,9 @@ test('listGateways should return a list of gateways', async () => {
expect(wallet).toBeDefined()
expect(wallet.isOpen()).toBe(true)
- const counterBefore = wallet._testing!.getRequestCounter()
+ const counterBefore = wallet.testing.getRequestCounter()
const gateways = await wallet.lightning.listGateways()
- expect(wallet._testing!.getRequestCounter()).toBe(counterBefore + 1)
+ expect(wallet.testing.getRequestCounter()).toBe(counterBefore + 1)
expect(gateways).toBeDefined()
expect(gateways).toMatchObject([
{
@@ -68,18 +65,18 @@ test('updateGatewayCache should update the gateway cache', async () => {
expect(wallet).toBeDefined()
expect(wallet.isOpen()).toBe(true)
- const counterBefore = wallet._testing!.getRequestCounter()
+ const counterBefore = wallet.testing.getRequestCounter()
await expect(wallet.lightning.updateGatewayCache()).resolves.toBeDefined()
- expect(wallet._testing!.getRequestCounter()).toBe(counterBefore + 1)
+ expect(wallet.testing.getRequestCounter()).toBe(counterBefore + 1)
})
test('getGateway should return a gateway', async () => {
expect(wallet).toBeDefined()
expect(wallet.isOpen()).toBe(true)
- const counterBefore = wallet._testing!.getRequestCounter()
+ const counterBefore = wallet.testing.getRequestCounter()
const gateway = await wallet.lightning.getGateway()
- expect(wallet._testing!.getRequestCounter()).toBe(counterBefore + 1)
+ expect(wallet.testing.getRequestCounter()).toBe(counterBefore + 1)
expect(gateway).toMatchObject({
api: expect.any(String),
fees: expect.any(Object),
@@ -100,7 +97,7 @@ test('createInvoiceWithGateway should create a bolt11 invoice with a gateway', a
const gateway = gateways[0]
expect(gateway).toBeDefined()
- const counterBefore = wallet._testing!.getRequestCounter()
+ const counterBefore = wallet.testing.getRequestCounter()
const invoice = await wallet.lightning.createInvoiceWithGateway(
100,
'test',
@@ -113,7 +110,7 @@ test('createInvoiceWithGateway should create a bolt11 invoice with a gateway', a
invoice: expect.any(String),
operation_id: expect.any(String),
})
- expect(wallet._testing!.getRequestCounter()).toBe(counterBefore + 1)
+ expect(wallet.testing.getRequestCounter()).toBe(counterBefore + 1)
await expect(
wallet.lightning.createInvoiceWithGateway(
100,
@@ -136,7 +133,7 @@ test('payInvoice should pay a bolt11 invoice', async () => {
operation_id: expect.any(String),
})
- const counterBefore = wallet._testing!.getRequestCounter()
+ const counterBefore = wallet.testing.getRequestCounter()
// Insufficient funds
try {
await wallet.lightning.payInvoice(invoice.invoice, {})
@@ -146,5 +143,5 @@ test('payInvoice should pay a bolt11 invoice', async () => {
}
// 3 requests were made, one for paying the invoice, one for refreshing the
// gateway cache, one for getting the gateway info
- expect(wallet._testing!.getRequestCounter()).toBe(counterBefore + 3)
+ expect(wallet.testing.getRequestCounter()).toBe(counterBefore + 3)
})
diff --git a/packages/core-web/src/test/TestFedimintWallet.ts b/packages/core-web/src/test/TestFedimintWallet.ts
new file mode 100644
index 0000000..38458fc
--- /dev/null
+++ b/packages/core-web/src/test/TestFedimintWallet.ts
@@ -0,0 +1,17 @@
+import { FedimintWallet } from '../FedimintWallet'
+import { WorkerClient } from '../worker/WorkerClient'
+import { TestingService } from './TestingService'
+
+export class TestFedimintWallet extends FedimintWallet {
+ public testing: TestingService
+
+ constructor() {
+ super()
+ this.testing = new TestingService(this.getWorkerClient())
+ }
+
+ // Method to expose the WorkerClient
+ getWorkerClient(): WorkerClient {
+ return this['_client']
+ }
+}
diff --git a/packages/core-web/src/services/TestingService.ts b/packages/core-web/src/test/TestingService.ts
similarity index 54%
rename from packages/core-web/src/services/TestingService.ts
rename to packages/core-web/src/test/TestingService.ts
index 3ef5fbc..42932d4 100644
--- a/packages/core-web/src/services/TestingService.ts
+++ b/packages/core-web/src/test/TestingService.ts
@@ -3,7 +3,12 @@ import { WorkerClient } from '../worker'
// This is a testing service that allows for inspecting the internals
// of the WorkerClient. It is not intended for use in production.
export class TestingService {
- constructor(private client: WorkerClient) {}
+ public TESTING_INVITE: string
+ constructor(private client: WorkerClient) {
+ // Solo Mint on mutinynet
+ this.TESTING_INVITE =
+ 'fed11qgqrsdnhwden5te0v9cxjtt4dekxzamxw4kz6mmjvvkhydted9ukg6r9xfsnx7th0fhn26tf093juamwv4u8gtnpwpcz7qqpyz0e327ua8geceutfrcaezwt22mk6s2rdy09kg72jrcmncng2gn0kp2m5sk'
+ }
getRequestCounter() {
return this.client._getRequestCounter()
diff --git a/packages/core-web/tsconfig.json b/packages/core-web/tsconfig.json
index b4c474d..da5a3d7 100644
--- a/packages/core-web/tsconfig.json
+++ b/packages/core-web/tsconfig.json
@@ -10,5 +10,5 @@
"types": ["node"]
},
"include": ["src/**/*.ts"],
- "exclude": ["node_modules", "src/**/*.test.ts"]
+ "exclude": ["node_modules", "src/**/*.test.ts", "src/test"]
}
diff --git a/packages/react/package.json b/packages/react/package.json
index da33d1e..7700924 100644
--- a/packages/react/package.json
+++ b/packages/react/package.json
@@ -8,7 +8,7 @@
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
- "dependencies": {
+ "peerDependencies": {
"react": "^18.3.1",
"react-dom": ">=18.3.1"
},
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 13fc15f..909ff1a 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -61,16 +61,12 @@ importers:
version: 11.2.1
vitepress:
specifier: ^1.3.4
- version: 1.3.4(@algolia/client-search@4.24.0)(@types/node@22.5.5)(@types/react@18.3.4)(postcss@8.4.47)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(search-insights@2.17.2)(terser@5.32.0)(typescript@5.5.4)
+ version: 1.3.4(@algolia/client-search@4.24.0)(@types/node@22.5.5)(@types/react@18.3.10)(postcss@8.4.47)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(search-insights@2.17.2)(terser@5.32.0)(typescript@5.5.4)
vitepress-plugin-mermaid:
specifier: ^2.0.17
- version: 2.0.17(mermaid@11.2.1)(vitepress@1.3.4(@algolia/client-search@4.24.0)(@types/node@22.5.5)(@types/react@18.3.4)(postcss@8.4.47)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(search-insights@2.17.2)(terser@5.32.0)(typescript@5.5.4))
+ version: 2.0.17(mermaid@11.2.1)(vitepress@1.3.4(@algolia/client-search@4.24.0)(@types/node@22.5.5)(@types/react@18.3.10)(postcss@8.4.47)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(search-insights@2.17.2)(terser@5.32.0)(typescript@5.5.4))
examples/bare-js:
- dependencies:
- '@fedimint/core-web':
- specifier: workspace:*
- version: link:../../packages/core-web
devDependencies:
http-server:
specifier: ^14.1.1
@@ -79,33 +75,36 @@ importers:
examples/vite-core:
dependencies:
'@fedimint/core-web':
- specifier: workspace:*
- version: link:../../packages/core-web
+ specifier: canary
+ version: 0.0.0-canary-20240927003217
react:
specifier: ^18.3.1
version: 18.3.1
react-dom:
- specifier: '>=18.3.1'
+ specifier: ^18.3.1
version: 18.3.1(react@18.3.1)
devDependencies:
'@types/react':
specifier: '>=18.3.1'
- version: 18.3.4
+ version: 18.3.10
'@types/react-dom':
specifier: ^18.3.0
version: 18.3.0
'@vitejs/plugin-react':
specifier: ^4.3.1
- version: 4.3.1(vite@5.4.2(@types/node@22.5.5)(terser@5.32.0))
+ version: 4.3.1(vite@5.4.8(@types/node@22.5.5)(terser@5.32.0))
buffer:
specifier: ^6.0.3
version: 6.0.3
+ typescript:
+ specifier: ^5.2.2
+ version: 5.5.2
vite:
specifier: ^5.3.2
- version: 5.4.2(@types/node@22.5.5)(terser@5.32.0)
+ version: 5.4.8(@types/node@22.5.5)(terser@5.32.0)
vite-plugin-wasm:
specifier: ^3.3.0
- version: 3.3.0(vite@5.4.2(@types/node@22.5.5)(terser@5.32.0))
+ version: 3.3.0(vite@5.4.8(@types/node@22.5.5)(terser@5.32.0))
packages/core-web:
dependencies:
@@ -614,6 +613,12 @@ packages:
resolution: {integrity: sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
+ '@fedimint/core-web@0.0.0-canary-20240927003217':
+ resolution: {integrity: sha512-fuFuCktNP7HYSLDL5DYNkgbHsRseRXN026+wXPS6K9qr7m+HebPGRSIzMSm7ieg5mdg6c34z4BMDa/4Y1kAr9w==}
+
+ '@fedimint/fedimint-client-wasm-bundler@0.0.0-canary-20240927003217':
+ resolution: {integrity: sha512-dwFVFBSrDqGzhRuXKDxTuYFFRJ5zIh3zpLz7185+nb3m8jxktQFGrf8LRTjZHv9BajmI6AtpAbI6QUuQfURduA==}
+
'@humanwhocodes/config-array@0.11.14':
resolution: {integrity: sha512-3T8LkOmg45BV5FICb15QQMsyUSWrQ8AygVfC7ZG32zOalnqrilm018ZVCw0eapXux8FtA33q8PSRSstjee3jSg==}
engines: {node: '>=10.10.0'}
@@ -929,6 +934,9 @@ packages:
'@types/react-dom@18.3.0':
resolution: {integrity: sha512-EhwApuTmMBmXuFOikhQLIBUn6uFg81SwLMOAUgodJF14SOBOCMdU04gDoYi0WOJJHD144TL32z4yDqCW3dnkQg==}
+ '@types/react@18.3.10':
+ resolution: {integrity: sha512-02sAAlBnP39JgXwkAq3PeU9DVaaGpZyF3MGcC0MKgQVkZor5IiiDAipVaxQHtDJAmO4GIy/rVBy/LzVj76Cyqg==}
+
'@types/react@18.3.4':
resolution: {integrity: sha512-J7W30FTdfCxDDjmfRM+/JqLHBIyl7xUIp9kwK637FGmY7+mkSFSe6L4jpZzhj5QMfLssSDP4/i75AKkrdC7/Jw==}
@@ -2995,6 +3003,37 @@ packages:
terser:
optional: true
+ vite@5.4.8:
+ resolution: {integrity: sha512-FqrItQ4DT1NC4zCUqMB4c4AZORMKIa0m8/URVCZ77OZ/QSNeJ54bU1vrFADbDsuwfIPcgknRkmqakQcgnL4GiQ==}
+ engines: {node: ^18.0.0 || >=20.0.0}
+ hasBin: true
+ peerDependencies:
+ '@types/node': ^18.0.0 || >=20.0.0
+ less: '*'
+ lightningcss: ^1.21.0
+ sass: '*'
+ sass-embedded: '*'
+ stylus: '*'
+ sugarss: '*'
+ terser: ^5.4.0
+ peerDependenciesMeta:
+ '@types/node':
+ optional: true
+ less:
+ optional: true
+ lightningcss:
+ optional: true
+ sass:
+ optional: true
+ sass-embedded:
+ optional: true
+ stylus:
+ optional: true
+ sugarss:
+ optional: true
+ terser:
+ optional: true
+
vitepress-plugin-mermaid@2.0.17:
resolution: {integrity: sha512-IUzYpwf61GC6k0XzfmAmNrLvMi9TRrVRMsUyCA8KNXhg/mQ1VqWnO0/tBVPiX5UoKF1mDUwqn5QV4qAJl6JnUg==}
peerDependencies:
@@ -3608,9 +3647,9 @@ snapshots:
'@docsearch/css@3.6.1': {}
- '@docsearch/js@3.6.1(@algolia/client-search@4.24.0)(@types/react@18.3.4)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(search-insights@2.17.2)':
+ '@docsearch/js@3.6.1(@algolia/client-search@4.24.0)(@types/react@18.3.10)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(search-insights@2.17.2)':
dependencies:
- '@docsearch/react': 3.6.1(@algolia/client-search@4.24.0)(@types/react@18.3.4)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(search-insights@2.17.2)
+ '@docsearch/react': 3.6.1(@algolia/client-search@4.24.0)(@types/react@18.3.10)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(search-insights@2.17.2)
preact: 10.24.1
transitivePeerDependencies:
- '@algolia/client-search'
@@ -3619,14 +3658,14 @@ snapshots:
- react-dom
- search-insights
- '@docsearch/react@3.6.1(@algolia/client-search@4.24.0)(@types/react@18.3.4)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(search-insights@2.17.2)':
+ '@docsearch/react@3.6.1(@algolia/client-search@4.24.0)(@types/react@18.3.10)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(search-insights@2.17.2)':
dependencies:
'@algolia/autocomplete-core': 1.9.3(@algolia/client-search@4.24.0)(algoliasearch@4.24.0)(search-insights@2.17.2)
'@algolia/autocomplete-preset-algolia': 1.9.3(@algolia/client-search@4.24.0)(algoliasearch@4.24.0)
'@docsearch/css': 3.6.1
algoliasearch: 4.24.0
optionalDependencies:
- '@types/react': 18.3.4
+ '@types/react': 18.3.10
react: 18.3.1
react-dom: 18.3.1(react@18.3.1)
search-insights: 2.17.2
@@ -3725,6 +3764,12 @@ snapshots:
'@eslint/js@8.57.0': {}
+ '@fedimint/core-web@0.0.0-canary-20240927003217':
+ dependencies:
+ '@fedimint/fedimint-client-wasm-bundler': 0.0.0-canary-20240927003217
+
+ '@fedimint/fedimint-client-wasm-bundler@0.0.0-canary-20240927003217': {}
+
'@humanwhocodes/config-array@0.11.14':
dependencies:
'@humanwhocodes/object-schema': 2.0.3
@@ -4074,7 +4119,12 @@ snapshots:
'@types/react-dom@18.3.0':
dependencies:
- '@types/react': 18.3.4
+ '@types/react': 18.3.10
+
+ '@types/react@18.3.10':
+ dependencies:
+ '@types/prop-types': 15.7.12
+ csstype: 3.1.3
'@types/react@18.3.4':
dependencies:
@@ -4191,6 +4241,17 @@ snapshots:
transitivePeerDependencies:
- supports-color
+ '@vitejs/plugin-react@4.3.1(vite@5.4.8(@types/node@22.5.5)(terser@5.32.0))':
+ dependencies:
+ '@babel/core': 7.25.2
+ '@babel/plugin-transform-react-jsx-self': 7.24.7(@babel/core@7.25.2)
+ '@babel/plugin-transform-react-jsx-source': 7.24.7(@babel/core@7.25.2)
+ '@types/babel__core': 7.20.5
+ react-refresh: 0.14.2
+ vite: 5.4.8(@types/node@22.5.5)(terser@5.32.0)
+ transitivePeerDependencies:
+ - supports-color
+
'@vitejs/plugin-vue@5.1.4(vite@5.4.2(@types/node@22.5.5)(terser@5.32.0))(vue@3.5.8(typescript@5.5.4))':
dependencies:
vite: 5.4.2(@types/node@22.5.5)(terser@5.32.0)
@@ -6205,7 +6266,7 @@ snapshots:
cac: 6.7.14
debug: 4.3.6
pathe: 1.1.2
- vite: 5.4.2(@types/node@20.16.1)(terser@5.32.0)
+ vite: 5.4.8(@types/node@20.16.1)(terser@5.32.0)
transitivePeerDependencies:
- '@types/node'
- less
@@ -6221,9 +6282,9 @@ snapshots:
dependencies:
vite: 5.4.2(@types/node@20.16.1)(terser@5.32.0)
- vite-plugin-wasm@3.3.0(vite@5.4.2(@types/node@22.5.5)(terser@5.32.0)):
+ vite-plugin-wasm@3.3.0(vite@5.4.8(@types/node@22.5.5)(terser@5.32.0)):
dependencies:
- vite: 5.4.2(@types/node@22.5.5)(terser@5.32.0)
+ vite: 5.4.8(@types/node@22.5.5)(terser@5.32.0)
vite@5.4.2(@types/node@20.16.1)(terser@5.32.0):
dependencies:
@@ -6245,17 +6306,37 @@ snapshots:
fsevents: 2.3.3
terser: 5.32.0
- vitepress-plugin-mermaid@2.0.17(mermaid@11.2.1)(vitepress@1.3.4(@algolia/client-search@4.24.0)(@types/node@22.5.5)(@types/react@18.3.4)(postcss@8.4.47)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(search-insights@2.17.2)(terser@5.32.0)(typescript@5.5.4)):
+ vite@5.4.8(@types/node@20.16.1)(terser@5.32.0):
+ dependencies:
+ esbuild: 0.21.5
+ postcss: 8.4.47
+ rollup: 4.21.2
+ optionalDependencies:
+ '@types/node': 20.16.1
+ fsevents: 2.3.3
+ terser: 5.32.0
+
+ vite@5.4.8(@types/node@22.5.5)(terser@5.32.0):
+ dependencies:
+ esbuild: 0.21.5
+ postcss: 8.4.47
+ rollup: 4.21.2
+ optionalDependencies:
+ '@types/node': 22.5.5
+ fsevents: 2.3.3
+ terser: 5.32.0
+
+ vitepress-plugin-mermaid@2.0.17(mermaid@11.2.1)(vitepress@1.3.4(@algolia/client-search@4.24.0)(@types/node@22.5.5)(@types/react@18.3.10)(postcss@8.4.47)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(search-insights@2.17.2)(terser@5.32.0)(typescript@5.5.4)):
dependencies:
mermaid: 11.2.1
- vitepress: 1.3.4(@algolia/client-search@4.24.0)(@types/node@22.5.5)(@types/react@18.3.4)(postcss@8.4.47)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(search-insights@2.17.2)(terser@5.32.0)(typescript@5.5.4)
+ vitepress: 1.3.4(@algolia/client-search@4.24.0)(@types/node@22.5.5)(@types/react@18.3.10)(postcss@8.4.47)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(search-insights@2.17.2)(terser@5.32.0)(typescript@5.5.4)
optionalDependencies:
'@mermaid-js/mermaid-mindmap': 9.3.0
- vitepress@1.3.4(@algolia/client-search@4.24.0)(@types/node@22.5.5)(@types/react@18.3.4)(postcss@8.4.47)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(search-insights@2.17.2)(terser@5.32.0)(typescript@5.5.4):
+ vitepress@1.3.4(@algolia/client-search@4.24.0)(@types/node@22.5.5)(@types/react@18.3.10)(postcss@8.4.47)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(search-insights@2.17.2)(terser@5.32.0)(typescript@5.5.4):
dependencies:
'@docsearch/css': 3.6.1
- '@docsearch/js': 3.6.1(@algolia/client-search@4.24.0)(@types/react@18.3.4)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(search-insights@2.17.2)
+ '@docsearch/js': 3.6.1(@algolia/client-search@4.24.0)(@types/react@18.3.10)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(search-insights@2.17.2)
'@shikijs/core': 1.18.0
'@shikijs/transformers': 1.18.0
'@types/markdown-it': 14.1.2