@fedimint/react 0.1.0 → 0.2.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.
package/README.md CHANGED
@@ -11,7 +11,7 @@
11
11
  ## Install
12
12
 
13
13
  ```bash
14
- pnpm install @fedimint/core-web @fedimint/react
14
+ pnpm install @fedimint/core @fedimint/react
15
15
  ```
16
16
 
17
17
  ## Usage
@@ -1,7 +1,8 @@
1
- import { FedimintWallet } from '@fedimint/core-web';
1
+ import { FedimintWallet, Transport } from '@fedimint/core';
2
2
  type FedimintWalletConfig = {
3
3
  lazy?: boolean;
4
4
  debug?: boolean;
5
+ transport: Transport;
5
6
  };
6
7
  export type WalletStatus = 'open' | 'closed' | 'opening';
7
8
  export declare const setupFedimintWallet: (config: FedimintWalletConfig) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"FedimintWalletContext.d.ts","sourceRoot":"","sources":["../../lib/contexts/FedimintWalletContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAYnE,KAAK,oBAAoB,GAAG;IAC1B,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAA;AAExD,eAAO,MAAM,mBAAmB,GAAI,QAAQ,oBAAoB,SAO/D,CAAA;AAED,eAAO,MAAM,qBAAqB;YAEpB,cAAc;kBACR,YAAY;qBACT,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI;cAGzC,CAAA;AAEZ,MAAM,MAAM,2BAA2B,GAAG,EAAE,CAAA;AAE5C,eAAO,MAAM,sBAAsB,GACjC,YAAY,KAAK,CAAC,iBAAiB,CAAC,2BAA2B,CAAC;YAVpD,cAAc;kBACR,YAAY;qBACT,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI;eAsCpD,CAAA"}
1
+ {"version":3,"file":"FedimintWalletContext.d.ts","sourceRoot":"","sources":["../../lib/contexts/FedimintWalletContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,cAAc,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAY1E,KAAK,oBAAoB,GAAG;IAC1B,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,SAAS,EAAE,SAAS,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAA;AAExD,eAAO,MAAM,mBAAmB,GAAI,QAAQ,oBAAoB,SAQ/D,CAAA;AAED,eAAO,MAAM,qBAAqB;YAEpB,cAAc;kBACR,YAAY;qBACT,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI;cAGzC,CAAA;AAEZ,MAAM,MAAM,2BAA2B,GAAG,EAAE,CAAA;AAE5C,eAAO,MAAM,sBAAsB,GACjC,YAAY,KAAK,CAAC,iBAAiB,CAAC,2BAA2B,CAAC;YAVpD,cAAc;kBACR,YAAY;qBACT,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI;eAsCpD,CAAA"}
@@ -1,2 +1,2 @@
1
- export declare const useFedimintWallet: () => import('@fedimint/core-web').FedimintWallet;
1
+ export declare const useFedimintWallet: () => import('@fedimint/core').FedimintWallet;
2
2
  //# sourceMappingURL=useFedimintWallet.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useFedimintWallet.d.ts","sourceRoot":"","sources":["../../lib/hooks/useFedimintWallet.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,iBAAiB,mDAQ7B,CAAA"}
1
+ {"version":3,"file":"useFedimintWallet.d.ts","sourceRoot":"","sources":["../../lib/hooks/useFedimintWallet.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,iBAAiB,+CAQ7B,CAAA"}
@@ -1,4 +1,4 @@
1
- import { ReissueExternalNotesState } from '@fedimint/core-web';
1
+ import { ReissueExternalNotesState } from '@fedimint/core';
2
2
  export declare const useReceiveEcash: () => {
3
3
  redeemEcash: (notes: string) => Promise<void>;
4
4
  state: "Error" | ReissueExternalNotesState | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"useReceiveEcash.d.ts","sourceRoot":"","sources":["../../lib/hooks/useReceiveEcash.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAA;AAE9D,eAAO,MAAM,eAAe;yBA2BV,MAAM;;;CAkBvB,CAAA"}
1
+ {"version":3,"file":"useReceiveEcash.d.ts","sourceRoot":"","sources":["../../lib/hooks/useReceiveEcash.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAA;AAE1D,eAAO,MAAM,eAAe;yBA2BV,MAAM;;;CAkBvB,CAAA"}
@@ -1,4 +1,4 @@
1
- import { LnReceiveState } from '@fedimint/core-web';
1
+ import { LnReceiveState } from '@fedimint/core';
2
2
  export declare const useReceiveLightning: () => {
3
3
  generateInvoice: (amount: number, description: string) => Promise<string>;
4
4
  bolt11: string | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"useReceiveLightning.d.ts","sourceRoot":"","sources":["../../lib/hooks/useReceiveLightning.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAA6B,MAAM,oBAAoB,CAAA;AAE9E,eAAO,MAAM,mBAAmB;8BASb,MAAM,eAAe,MAAM;;;;CAgC7C,CAAA"}
1
+ {"version":3,"file":"useReceiveLightning.d.ts","sourceRoot":"","sources":["../../lib/hooks/useReceiveLightning.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAA6B,MAAM,gBAAgB,CAAA;AAE1E,eAAO,MAAM,mBAAmB;8BASb,MAAM,eAAe,MAAM;;;;CAgC7C,CAAA"}
@@ -1,4 +1,4 @@
1
- import { LnPayState, OutgoingLightningPayment } from '@fedimint/core-web';
1
+ import { LnPayState, OutgoingLightningPayment } from '@fedimint/core';
2
2
  export declare const useSendLightning: () => {
3
3
  payInvoice: (bolt11: string) => Promise<OutgoingLightningPayment>;
4
4
  payment: OutgoingLightningPayment | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"useSendLightning.d.ts","sourceRoot":"","sources":["../../lib/hooks/useSendLightning.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,wBAAwB,EAC9B,MAAM,oBAAoB,CAAA;AAE3B,eAAO,MAAM,gBAAgB;yBAQV,MAAM;;;;CAiCxB,CAAA"}
1
+ {"version":3,"file":"useSendLightning.d.ts","sourceRoot":"","sources":["../../lib/hooks/useSendLightning.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,wBAAwB,EAAE,MAAM,gBAAgB,CAAA;AAE/E,eAAO,MAAM,gBAAgB;yBAQV,MAAM;;;;CAiCxB,CAAA"}
@@ -1,4 +1,4 @@
1
- import { SpendNotesState } from '@fedimint/core-web';
1
+ import { SpendNotesState } from '@fedimint/core';
2
2
  export declare const useSpendEcash: () => {
3
3
  spendEcash: (amountSats: number, reclaimAfter?: number) => Promise<string>;
4
4
  notes: string | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"useSpendEcash.d.ts","sourceRoot":"","sources":["../../lib/hooks/useSpendEcash.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAEzD,eAAO,MAAM,aAAa;6BA8BH,MAAM,iBAAiB,MAAM;;;;CAmBnD,CAAA"}
1
+ {"version":3,"file":"useSpendEcash.d.ts","sourceRoot":"","sources":["../../lib/hooks/useSpendEcash.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAErD,eAAO,MAAM,aAAa;6BA8BH,MAAM,iBAAiB,MAAM;;;;CAmBnD,CAAA"}
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { useState as r, useEffect as m, createContext as y, useMemo as F, createElement as I, useContext as W, useCallback as w } from "react";
2
- import { WalletDirector as P } from "@fedimint/core-web";
2
+ import { WalletDirector as P } from "@fedimint/core";
3
3
  const R = () => {
4
4
  const e = g(), { walletStatus: t } = E(), [n, o] = r();
5
5
  return m(() => {
@@ -12,12 +12,12 @@ const R = () => {
12
12
  };
13
13
  }, [t]), n;
14
14
  };
15
- let b;
16
- const f = new P(), O = (e) => {
17
- f.createWallet().then((t) => {
15
+ let b, v;
16
+ const O = (e) => {
17
+ v = new P(e.transport), v.createWallet().then((t) => {
18
18
  b = t;
19
- }), e.debug && f.setLogLevel("debug");
20
- }, v = y(void 0), C = (e) => {
19
+ }), e.debug && v.setLogLevel("debug");
20
+ }, f = y(void 0), C = (e) => {
21
21
  const [t, n] = r("closed"), { children: o } = e;
22
22
  if (!b)
23
23
  throw new Error(
@@ -36,12 +36,12 @@ const f = new P(), O = (e) => {
36
36
  n("open");
37
37
  });
38
38
  }, [b]), I(
39
- v.Provider,
39
+ f.Provider,
40
40
  { value: a },
41
41
  o
42
42
  );
43
43
  }, E = () => {
44
- const e = W(v);
44
+ const e = W(f);
45
45
  if (!e)
46
46
  throw new Error(
47
47
  "useOpenWallet must be used within a FedimintWalletProvider"
@@ -60,7 +60,7 @@ const f = new P(), O = (e) => {
60
60
  );
61
61
  return { walletStatus: n, openWallet: a, joinFederation: c };
62
62
  }, g = () => {
63
- const e = W(v);
63
+ const e = W(f);
64
64
  if (!(e != null && e.wallet))
65
65
  throw new Error(
66
66
  "useFedimintWallet must be used within a FedimintWalletProvider"
@@ -191,7 +191,7 @@ const f = new P(), O = (e) => {
191
191
  };
192
192
  };
193
193
  export {
194
- v as FedimintWalletContext,
194
+ f as FedimintWalletContext,
195
195
  C as FedimintWalletProvider,
196
196
  O as setupFedimintWallet,
197
197
  R as useBalance,
package/dist/init.d.ts CHANGED
@@ -1,2 +1,3 @@
1
- export declare const initFedimintReact: (lazy?: boolean) => {};
1
+ import { Transport } from '@fedimint/core';
2
+ export declare const initFedimintReact: (lazy: boolean | undefined, transport: Transport) => {};
2
3
  //# sourceMappingURL=init.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../lib/init.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,iBAAiB,GAAI,OAAM,OAAe,OAQtD,CAAA"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../lib/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAkB,MAAM,gBAAgB,CAAA;AAM1E,eAAO,MAAM,iBAAiB,GAC5B,MAAM,OAAO,YAAQ,EACrB,WAAW,SAAS,OAUrB,CAAA"}
@@ -1,4 +1,4 @@
1
- import { WalletDirector, FedimintWallet } from '@fedimint/core-web'
1
+ import { WalletDirector, FedimintWallet, Transport } from '@fedimint/core'
2
2
  import {
3
3
  createContext,
4
4
  createElement,
@@ -8,16 +8,18 @@ import {
8
8
  } from 'react'
9
9
 
10
10
  let wallet: FedimintWallet
11
- const walletDirector = new WalletDirector()
11
+ let walletDirector: WalletDirector
12
12
 
13
13
  type FedimintWalletConfig = {
14
14
  lazy?: boolean
15
15
  debug?: boolean
16
+ transport: Transport
16
17
  }
17
18
 
18
19
  export type WalletStatus = 'open' | 'closed' | 'opening'
19
20
 
20
21
  export const setupFedimintWallet = (config: FedimintWalletConfig) => {
22
+ walletDirector = new WalletDirector(config.transport)
21
23
  walletDirector.createWallet().then((w) => {
22
24
  wallet = w
23
25
  })
@@ -1,6 +1,6 @@
1
1
  import { useCallback, useEffect, useState } from 'react'
2
2
  import { useFedimintWallet, useOpenWallet } from '.'
3
- import { ReissueExternalNotesState } from '@fedimint/core-web'
3
+ import { ReissueExternalNotesState } from '@fedimint/core'
4
4
 
5
5
  export const useReceiveEcash = () => {
6
6
  const wallet = useFedimintWallet()
@@ -1,6 +1,6 @@
1
1
  import { useCallback, useEffect, useState } from 'react'
2
2
  import { useFedimintWallet, useOpenWallet } from '.'
3
- import { LnReceiveState, type CreateBolt11Response } from '@fedimint/core-web'
3
+ import { LnReceiveState, type CreateBolt11Response } from '@fedimint/core'
4
4
 
5
5
  export const useReceiveLightning = () => {
6
6
  const wallet = useFedimintWallet()
@@ -1,9 +1,6 @@
1
1
  import { useCallback, useEffect, useState } from 'react'
2
2
  import { useFedimintWallet, useOpenWallet } from '.'
3
- import {
4
- type LnPayState,
5
- type OutgoingLightningPayment,
6
- } from '@fedimint/core-web'
3
+ import { type LnPayState, type OutgoingLightningPayment } from '@fedimint/core'
7
4
 
8
5
  export const useSendLightning = () => {
9
6
  const wallet = useFedimintWallet()
@@ -1,6 +1,6 @@
1
1
  import { useCallback, useEffect, useState } from 'react'
2
2
  import { useFedimintWallet, useOpenWallet } from '.'
3
- import { type SpendNotesState } from '@fedimint/core-web'
3
+ import { type SpendNotesState } from '@fedimint/core'
4
4
 
5
5
  export const useSpendEcash = () => {
6
6
  const wallet = useFedimintWallet()
package/lib/init.ts CHANGED
@@ -1,10 +1,14 @@
1
- import { FedimintWallet, WalletDirector } from '@fedimint/core-web'
1
+ import { FedimintWallet, Transport, WalletDirector } from '@fedimint/core'
2
2
 
3
3
  let wallet: FedimintWallet | undefined
4
4
 
5
- const walletDirector = new WalletDirector()
5
+ let walletDirector: WalletDirector
6
6
 
7
- export const initFedimintReact = (lazy: boolean = false) => {
7
+ export const initFedimintReact = (
8
+ lazy: boolean = false,
9
+ transport: Transport,
10
+ ) => {
11
+ walletDirector = new WalletDirector(transport)
8
12
  if (!lazy) {
9
13
  walletDirector.createWallet().then((w) => {
10
14
  wallet = w
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedimint/react",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -10,7 +10,7 @@
10
10
  "types": "./dist/index.d.ts",
11
11
  "peerDependencies": {
12
12
  "react": "^18.3.1",
13
- "@fedimint/core-web": "0.1.0"
13
+ "@fedimint/core": "0.1.1"
14
14
  },
15
15
  "devDependencies": {
16
16
  "@types/react": ">=19.1.4",