@fedimint/react 0.1.0 → 0.2.1
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 +1 -1
- package/dist/contexts/FedimintWalletContext.d.ts +2 -1
- package/dist/contexts/FedimintWalletContext.d.ts.map +1 -1
- package/dist/hooks/useFedimintWallet.d.ts +1 -1
- package/dist/hooks/useFedimintWallet.d.ts.map +1 -1
- package/dist/hooks/useOpenWallet.d.ts.map +1 -1
- package/dist/hooks/useReceiveEcash.d.ts +1 -1
- package/dist/hooks/useReceiveEcash.d.ts.map +1 -1
- package/dist/hooks/useReceiveLightning.d.ts +1 -1
- package/dist/hooks/useReceiveLightning.d.ts.map +1 -1
- package/dist/hooks/useSendLightning.d.ts +1 -1
- package/dist/hooks/useSendLightning.d.ts.map +1 -1
- package/dist/hooks/useSpendEcash.d.ts +1 -1
- package/dist/hooks/useSpendEcash.d.ts.map +1 -1
- package/dist/index.js +42 -40
- package/dist/init.d.ts +2 -1
- package/dist/init.d.ts.map +1 -1
- package/lib/contexts/FedimintWalletContext.ts +4 -2
- package/lib/hooks/useOpenWallet.ts +8 -3
- package/lib/hooks/useReceiveEcash.ts +1 -1
- package/lib/hooks/useReceiveLightning.ts +1 -1
- package/lib/hooks/useSendLightning.ts +1 -4
- package/lib/hooks/useSpendEcash.ts +1 -1
- package/lib/init.ts +7 -3
- package/package.json +10 -16
package/README.md
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { FedimintWallet } from '@fedimint/core
|
|
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,
|
|
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
|
|
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,
|
|
1
|
+
{"version":3,"file":"useFedimintWallet.d.ts","sourceRoot":"","sources":["../../lib/hooks/useFedimintWallet.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,iBAAiB,+CAQ7B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOpenWallet.d.ts","sourceRoot":"","sources":["../../lib/hooks/useOpenWallet.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,aAAa;;;
|
|
1
|
+
{"version":3,"file":"useOpenWallet.d.ts","sourceRoot":"","sources":["../../lib/hooks/useOpenWallet.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,aAAa;;;6BA0BP,MAAM;CAaxB,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReissueExternalNotesState } from '@fedimint/core
|
|
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,
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useReceiveLightning.d.ts","sourceRoot":"","sources":["../../lib/hooks/useReceiveLightning.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAA6B,MAAM,
|
|
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
|
|
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,
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSpendEcash.d.ts","sourceRoot":"","sources":["../../lib/hooks/useSpendEcash.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,
|
|
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,8 +1,8 @@
|
|
|
1
|
-
import { useState as r, useEffect as
|
|
2
|
-
import { WalletDirector as P } from "@fedimint/core
|
|
1
|
+
import { useState as r, useEffect as h, 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";
|
|
3
3
|
const R = () => {
|
|
4
4
|
const e = g(), { walletStatus: t } = E(), [n, o] = r();
|
|
5
|
-
return
|
|
5
|
+
return h(() => {
|
|
6
6
|
if (t !== "open") return;
|
|
7
7
|
const a = e.balance.subscribeBalance((c) => {
|
|
8
8
|
o(c);
|
|
@@ -12,12 +12,12 @@ const R = () => {
|
|
|
12
12
|
};
|
|
13
13
|
}, [t]), n;
|
|
14
14
|
};
|
|
15
|
-
let b;
|
|
16
|
-
const
|
|
17
|
-
|
|
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 &&
|
|
20
|
-
},
|
|
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(
|
|
@@ -31,43 +31,45 @@ const f = new P(), O = (e) => {
|
|
|
31
31
|
}),
|
|
32
32
|
[t]
|
|
33
33
|
);
|
|
34
|
-
return
|
|
34
|
+
return h(() => {
|
|
35
35
|
b.waitForOpen().then(() => {
|
|
36
36
|
n("open");
|
|
37
37
|
});
|
|
38
38
|
}, [b]), I(
|
|
39
|
-
|
|
39
|
+
f.Provider,
|
|
40
40
|
{ value: a },
|
|
41
41
|
o
|
|
42
42
|
);
|
|
43
43
|
}, E = () => {
|
|
44
|
-
const e = W(
|
|
44
|
+
const e = W(f);
|
|
45
45
|
if (!e)
|
|
46
46
|
throw new Error(
|
|
47
47
|
"useOpenWallet must be used within a FedimintWalletProvider"
|
|
48
48
|
);
|
|
49
49
|
const { wallet: t, walletStatus: n, setWalletStatus: o } = e, a = w(() => {
|
|
50
|
-
n !== "open" && (o("opening"), t.open().then((
|
|
51
|
-
o(
|
|
50
|
+
n !== "open" && (o("opening"), t.open().then(() => {
|
|
51
|
+
o("open");
|
|
52
|
+
}).catch(() => {
|
|
53
|
+
o("closed");
|
|
52
54
|
}));
|
|
53
55
|
}, [t]), c = w(
|
|
54
|
-
async (
|
|
55
|
-
n !== "open" && (o("opening"), await t.joinFederation(
|
|
56
|
-
o(
|
|
56
|
+
async (u) => {
|
|
57
|
+
n !== "open" && (o("opening"), await t.joinFederation(u).then((l) => {
|
|
58
|
+
o(l ? "open" : "closed");
|
|
57
59
|
}));
|
|
58
60
|
},
|
|
59
61
|
[t]
|
|
60
62
|
);
|
|
61
63
|
return { walletStatus: n, openWallet: a, joinFederation: c };
|
|
62
64
|
}, g = () => {
|
|
63
|
-
const e = W(
|
|
65
|
+
const e = W(f);
|
|
64
66
|
if (!(e != null && e.wallet))
|
|
65
67
|
throw new Error(
|
|
66
68
|
"useFedimintWallet must be used within a FedimintWalletProvider"
|
|
67
69
|
);
|
|
68
70
|
return e.wallet;
|
|
69
71
|
}, N = () => {
|
|
70
|
-
const e = g(), { walletStatus: t } = E(), [n, o] = r(), [a, c] = r(), [
|
|
72
|
+
const e = g(), { walletStatus: t } = E(), [n, o] = r(), [a, c] = r(), [u, l] = r(), p = w(
|
|
71
73
|
async (i, s) => {
|
|
72
74
|
if (t !== "open") throw new Error("Wallet is not open");
|
|
73
75
|
const d = await e.lightning.createInvoice(i, s);
|
|
@@ -75,7 +77,7 @@ const f = new P(), O = (e) => {
|
|
|
75
77
|
},
|
|
76
78
|
[e, t]
|
|
77
79
|
);
|
|
78
|
-
return
|
|
80
|
+
return h(() => {
|
|
79
81
|
if (t !== "open" || !n) return;
|
|
80
82
|
const i = e.lightning.subscribeLnReceive(
|
|
81
83
|
n.operation_id,
|
|
@@ -83,7 +85,7 @@ const f = new P(), O = (e) => {
|
|
|
83
85
|
c(s);
|
|
84
86
|
},
|
|
85
87
|
(s) => {
|
|
86
|
-
|
|
88
|
+
l(s);
|
|
87
89
|
}
|
|
88
90
|
);
|
|
89
91
|
return () => {
|
|
@@ -93,10 +95,10 @@ const f = new P(), O = (e) => {
|
|
|
93
95
|
generateInvoice: p,
|
|
94
96
|
bolt11: n == null ? void 0 : n.invoice,
|
|
95
97
|
invoiceStatus: a,
|
|
96
|
-
error:
|
|
98
|
+
error: u
|
|
97
99
|
};
|
|
98
100
|
}, B = () => {
|
|
99
|
-
const e = g(), { walletStatus: t } = E(), [n, o] = r(), [a, c] = r(), [
|
|
101
|
+
const e = g(), { walletStatus: t } = E(), [n, o] = r(), [a, c] = r(), [u, l] = r(), p = w(
|
|
100
102
|
async (i) => {
|
|
101
103
|
if (t !== "open") throw new Error("Wallet is not open");
|
|
102
104
|
const s = await e.lightning.payInvoice(i);
|
|
@@ -104,7 +106,7 @@ const f = new P(), O = (e) => {
|
|
|
104
106
|
},
|
|
105
107
|
[e, t]
|
|
106
108
|
);
|
|
107
|
-
return
|
|
109
|
+
return h(() => {
|
|
108
110
|
if (t !== "open" || !n) return;
|
|
109
111
|
const i = e.lightning.subscribeLnPay(
|
|
110
112
|
// @ts-ignore
|
|
@@ -113,7 +115,7 @@ const f = new P(), O = (e) => {
|
|
|
113
115
|
c(s);
|
|
114
116
|
},
|
|
115
117
|
(s) => {
|
|
116
|
-
|
|
118
|
+
l(s);
|
|
117
119
|
}
|
|
118
120
|
);
|
|
119
121
|
return () => {
|
|
@@ -123,19 +125,19 @@ const f = new P(), O = (e) => {
|
|
|
123
125
|
payInvoice: p,
|
|
124
126
|
payment: n,
|
|
125
127
|
paymentStatus: a,
|
|
126
|
-
paymentError:
|
|
128
|
+
paymentError: u
|
|
127
129
|
};
|
|
128
130
|
}, _ = () => {
|
|
129
|
-
const e = g(), { walletStatus: t } = E(), [n, o] = r(), [a, c] = r(), [
|
|
130
|
-
return
|
|
131
|
+
const e = g(), { walletStatus: t } = E(), [n, o] = r(), [a, c] = r(), [u, l] = r(), [p, i] = r();
|
|
132
|
+
return h(() => {
|
|
131
133
|
if (!n) return;
|
|
132
134
|
const d = e.mint.subscribeSpendNotes(
|
|
133
135
|
n,
|
|
134
|
-
(
|
|
135
|
-
|
|
136
|
+
(m) => {
|
|
137
|
+
l(m);
|
|
136
138
|
},
|
|
137
|
-
(
|
|
138
|
-
|
|
139
|
+
(m) => {
|
|
140
|
+
l("Error"), i(m);
|
|
139
141
|
}
|
|
140
142
|
);
|
|
141
143
|
return () => {
|
|
@@ -143,23 +145,23 @@ const f = new P(), O = (e) => {
|
|
|
143
145
|
};
|
|
144
146
|
}, [n]), {
|
|
145
147
|
spendEcash: w(
|
|
146
|
-
async (d,
|
|
148
|
+
async (d, m) => {
|
|
147
149
|
if (t !== "open") throw new Error("Wallet is not open");
|
|
148
150
|
const S = await e.mint.spendNotes(
|
|
149
151
|
d * 1e3,
|
|
150
|
-
|
|
152
|
+
m
|
|
151
153
|
);
|
|
152
154
|
return o(S.operation_id), c(S.notes), S.notes;
|
|
153
155
|
},
|
|
154
156
|
[e, t]
|
|
155
157
|
),
|
|
156
158
|
notes: a,
|
|
157
|
-
state:
|
|
159
|
+
state: u,
|
|
158
160
|
error: p
|
|
159
161
|
};
|
|
160
162
|
}, j = () => {
|
|
161
|
-
const e = g(), { walletStatus: t } = E(), [n, o] = r(), [a, c] = r(), [
|
|
162
|
-
return
|
|
163
|
+
const e = g(), { walletStatus: t } = E(), [n, o] = r(), [a, c] = r(), [u, l] = r();
|
|
164
|
+
return h(() => {
|
|
163
165
|
if (!n) return;
|
|
164
166
|
const i = e.mint.subscribeReissueExternalNotes(
|
|
165
167
|
n,
|
|
@@ -167,7 +169,7 @@ const f = new P(), O = (e) => {
|
|
|
167
169
|
c(s);
|
|
168
170
|
},
|
|
169
171
|
(s) => {
|
|
170
|
-
|
|
172
|
+
l(s);
|
|
171
173
|
}
|
|
172
174
|
);
|
|
173
175
|
return () => {
|
|
@@ -181,17 +183,17 @@ const f = new P(), O = (e) => {
|
|
|
181
183
|
const s = await e.mint.redeemEcash(i);
|
|
182
184
|
o(s);
|
|
183
185
|
} catch (s) {
|
|
184
|
-
c("Error"),
|
|
186
|
+
c("Error"), l(s);
|
|
185
187
|
}
|
|
186
188
|
},
|
|
187
189
|
[e, t]
|
|
188
190
|
),
|
|
189
191
|
state: a,
|
|
190
|
-
error:
|
|
192
|
+
error: u
|
|
191
193
|
};
|
|
192
194
|
};
|
|
193
195
|
export {
|
|
194
|
-
|
|
196
|
+
f as FedimintWalletContext,
|
|
195
197
|
C as FedimintWalletProvider,
|
|
196
198
|
O as setupFedimintWallet,
|
|
197
199
|
R as useBalance,
|
package/dist/init.d.ts
CHANGED
package/dist/init.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../lib/init.ts"],"names":[],"mappings":"
|
|
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
|
|
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
|
-
|
|
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
|
})
|
|
@@ -16,9 +16,14 @@ export const useOpenWallet = () => {
|
|
|
16
16
|
if (walletStatus === 'open') return
|
|
17
17
|
|
|
18
18
|
setWalletStatus('opening')
|
|
19
|
-
wallet
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
wallet
|
|
20
|
+
.open()
|
|
21
|
+
.then(() => {
|
|
22
|
+
setWalletStatus('open')
|
|
23
|
+
})
|
|
24
|
+
.catch(() => {
|
|
25
|
+
setWalletStatus('closed')
|
|
26
|
+
})
|
|
22
27
|
}, [wallet])
|
|
23
28
|
|
|
24
29
|
const joinFederation = useCallback(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallback, useEffect, useState } from 'react'
|
|
2
2
|
import { useFedimintWallet, useOpenWallet } from '.'
|
|
3
|
-
import { ReissueExternalNotesState } from '@fedimint/core
|
|
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
|
|
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
|
|
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
|
|
1
|
+
import { FedimintWallet, Transport, WalletDirector } from '@fedimint/core'
|
|
2
2
|
|
|
3
3
|
let wallet: FedimintWallet | undefined
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
let walletDirector: WalletDirector
|
|
6
6
|
|
|
7
|
-
export const initFedimintReact = (
|
|
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
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -9,28 +9,22 @@
|
|
|
9
9
|
"main": "./dist/index.js",
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
11
|
"peerDependencies": {
|
|
12
|
-
"react": "
|
|
13
|
-
"@fedimint/core
|
|
12
|
+
"react": ">=19.2.0",
|
|
13
|
+
"@fedimint/core": "0.1.3"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@types/react": ">=19.
|
|
17
|
-
"@types/react-dom": "
|
|
18
|
-
"@
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"eslint-plugin-react-hooks": "^4.6.2",
|
|
23
|
-
"eslint-plugin-react-refresh": "^0.4.20",
|
|
24
|
-
"react-dom": ">=19.1.0",
|
|
25
|
-
"typescript": "^5.8.3",
|
|
26
|
-
"vite": "^5.4.20",
|
|
16
|
+
"@types/react": ">=19.2.2",
|
|
17
|
+
"@types/react-dom": ">=19.2.1",
|
|
18
|
+
"@vitejs/plugin-react": "^4.7.0",
|
|
19
|
+
"react-dom": ">=19.2.0",
|
|
20
|
+
"typescript": "^5.9.3",
|
|
21
|
+
"vite": "^6.3.6",
|
|
27
22
|
"vite-plugin-dts": "^4.5.4",
|
|
28
|
-
"vite-plugin-wasm": "^3.
|
|
23
|
+
"vite-plugin-wasm": "^3.5.0"
|
|
29
24
|
},
|
|
30
25
|
"scripts": {
|
|
31
26
|
"dev": "vite",
|
|
32
27
|
"build": "tsc --p ./tsconfig.build.json && vite build",
|
|
33
|
-
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
|
34
28
|
"preview": "vite preview"
|
|
35
29
|
}
|
|
36
30
|
}
|