@fedimint/react 0.0.4 → 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 +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/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 +83 -81
- package/dist/init.d.ts +2 -1
- package/dist/init.d.ts.map +1 -1
- package/lib/contexts/FedimintWalletContext.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 +11 -3
- package/package.json +3 -3
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,
|
|
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,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,82 +1,84 @@
|
|
|
1
|
-
import { useState as r, useEffect as
|
|
2
|
-
import {
|
|
3
|
-
const
|
|
4
|
-
const e = g(), { walletStatus:
|
|
5
|
-
return
|
|
6
|
-
if (
|
|
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";
|
|
3
|
+
const R = () => {
|
|
4
|
+
const e = g(), { walletStatus: t } = E(), [n, o] = r();
|
|
5
|
+
return m(() => {
|
|
6
|
+
if (t !== "open") return;
|
|
7
7
|
const a = e.balance.subscribeBalance((c) => {
|
|
8
8
|
o(c);
|
|
9
9
|
});
|
|
10
10
|
return () => {
|
|
11
11
|
a();
|
|
12
12
|
};
|
|
13
|
-
}, [
|
|
13
|
+
}, [t]), n;
|
|
14
14
|
};
|
|
15
|
-
let
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
let b, v;
|
|
16
|
+
const O = (e) => {
|
|
17
|
+
v = new P(e.transport), v.createWallet().then((t) => {
|
|
18
|
+
b = t;
|
|
19
|
+
}), e.debug && v.setLogLevel("debug");
|
|
20
|
+
}, f = y(void 0), C = (e) => {
|
|
21
|
+
const [t, n] = r("closed"), { children: o } = e;
|
|
22
|
+
if (!b)
|
|
21
23
|
throw new Error(
|
|
22
24
|
"You must call setupFedimintWallet() first. See the getting started guide."
|
|
23
25
|
);
|
|
24
|
-
const a =
|
|
26
|
+
const a = F(
|
|
25
27
|
() => ({
|
|
26
|
-
wallet:
|
|
27
|
-
walletStatus:
|
|
28
|
-
setWalletStatus:
|
|
28
|
+
wallet: b,
|
|
29
|
+
walletStatus: t,
|
|
30
|
+
setWalletStatus: n
|
|
29
31
|
}),
|
|
30
|
-
[
|
|
32
|
+
[t]
|
|
31
33
|
);
|
|
32
|
-
return
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
return m(() => {
|
|
35
|
+
b.waitForOpen().then(() => {
|
|
36
|
+
n("open");
|
|
35
37
|
});
|
|
36
|
-
}, [
|
|
37
|
-
|
|
38
|
+
}, [b]), I(
|
|
39
|
+
f.Provider,
|
|
38
40
|
{ value: a },
|
|
39
41
|
o
|
|
40
42
|
);
|
|
41
43
|
}, E = () => {
|
|
42
|
-
const e = f
|
|
44
|
+
const e = W(f);
|
|
43
45
|
if (!e)
|
|
44
46
|
throw new Error(
|
|
45
47
|
"useOpenWallet must be used within a FedimintWalletProvider"
|
|
46
48
|
);
|
|
47
|
-
const { wallet:
|
|
48
|
-
|
|
49
|
+
const { wallet: t, walletStatus: n, setWalletStatus: o } = e, a = w(() => {
|
|
50
|
+
n !== "open" && (o("opening"), t.open().then((l) => {
|
|
49
51
|
o(l ? "open" : "closed");
|
|
50
52
|
}));
|
|
51
|
-
}, [
|
|
53
|
+
}, [t]), c = w(
|
|
52
54
|
async (l) => {
|
|
53
|
-
|
|
55
|
+
n !== "open" && (o("opening"), await t.joinFederation(l).then((u) => {
|
|
54
56
|
o(u ? "open" : "closed");
|
|
55
57
|
}));
|
|
56
58
|
},
|
|
57
|
-
[
|
|
59
|
+
[t]
|
|
58
60
|
);
|
|
59
|
-
return { walletStatus:
|
|
61
|
+
return { walletStatus: n, openWallet: a, joinFederation: c };
|
|
60
62
|
}, g = () => {
|
|
61
|
-
const e = f
|
|
63
|
+
const e = W(f);
|
|
62
64
|
if (!(e != null && e.wallet))
|
|
63
65
|
throw new Error(
|
|
64
66
|
"useFedimintWallet must be used within a FedimintWalletProvider"
|
|
65
67
|
);
|
|
66
68
|
return e.wallet;
|
|
67
|
-
},
|
|
68
|
-
const e = g(), { walletStatus:
|
|
69
|
+
}, N = () => {
|
|
70
|
+
const e = g(), { walletStatus: t } = E(), [n, o] = r(), [a, c] = r(), [l, u] = r(), p = w(
|
|
69
71
|
async (i, s) => {
|
|
70
|
-
if (
|
|
72
|
+
if (t !== "open") throw new Error("Wallet is not open");
|
|
71
73
|
const d = await e.lightning.createInvoice(i, s);
|
|
72
74
|
return o(d), d.invoice;
|
|
73
75
|
},
|
|
74
|
-
[e,
|
|
76
|
+
[e, t]
|
|
75
77
|
);
|
|
76
|
-
return
|
|
77
|
-
if (
|
|
78
|
+
return m(() => {
|
|
79
|
+
if (t !== "open" || !n) return;
|
|
78
80
|
const i = e.lightning.subscribeLnReceive(
|
|
79
|
-
|
|
81
|
+
n.operation_id,
|
|
80
82
|
(s) => {
|
|
81
83
|
c(s);
|
|
82
84
|
},
|
|
@@ -87,26 +89,26 @@ const R = (e) => {
|
|
|
87
89
|
return () => {
|
|
88
90
|
i();
|
|
89
91
|
};
|
|
90
|
-
}, [
|
|
92
|
+
}, [t, n]), {
|
|
91
93
|
generateInvoice: p,
|
|
92
|
-
bolt11:
|
|
94
|
+
bolt11: n == null ? void 0 : n.invoice,
|
|
93
95
|
invoiceStatus: a,
|
|
94
96
|
error: l
|
|
95
97
|
};
|
|
96
|
-
},
|
|
97
|
-
const e = g(), { walletStatus:
|
|
98
|
+
}, B = () => {
|
|
99
|
+
const e = g(), { walletStatus: t } = E(), [n, o] = r(), [a, c] = r(), [l, u] = r(), p = w(
|
|
98
100
|
async (i) => {
|
|
99
|
-
if (
|
|
101
|
+
if (t !== "open") throw new Error("Wallet is not open");
|
|
100
102
|
const s = await e.lightning.payInvoice(i);
|
|
101
103
|
return o(s), s;
|
|
102
104
|
},
|
|
103
|
-
[e,
|
|
105
|
+
[e, t]
|
|
104
106
|
);
|
|
105
|
-
return
|
|
106
|
-
if (
|
|
107
|
+
return m(() => {
|
|
108
|
+
if (t !== "open" || !n) return;
|
|
107
109
|
const i = e.lightning.subscribeLnPay(
|
|
108
110
|
// @ts-ignore
|
|
109
|
-
|
|
111
|
+
n.payment_type.lightning,
|
|
110
112
|
(s) => {
|
|
111
113
|
c(s);
|
|
112
114
|
},
|
|
@@ -117,50 +119,50 @@ const R = (e) => {
|
|
|
117
119
|
return () => {
|
|
118
120
|
i();
|
|
119
121
|
};
|
|
120
|
-
}, [
|
|
122
|
+
}, [t, n]), {
|
|
121
123
|
payInvoice: p,
|
|
122
|
-
payment:
|
|
124
|
+
payment: n,
|
|
123
125
|
paymentStatus: a,
|
|
124
126
|
paymentError: l
|
|
125
127
|
};
|
|
126
|
-
},
|
|
127
|
-
const e = g(), { walletStatus:
|
|
128
|
-
return
|
|
129
|
-
if (!
|
|
128
|
+
}, _ = () => {
|
|
129
|
+
const e = g(), { walletStatus: t } = E(), [n, o] = r(), [a, c] = r(), [l, u] = r(), [p, i] = r();
|
|
130
|
+
return m(() => {
|
|
131
|
+
if (!n) return;
|
|
130
132
|
const d = e.mint.subscribeSpendNotes(
|
|
131
|
-
|
|
132
|
-
(
|
|
133
|
-
u(
|
|
133
|
+
n,
|
|
134
|
+
(h) => {
|
|
135
|
+
u(h);
|
|
134
136
|
},
|
|
135
|
-
(
|
|
136
|
-
u("Error"), i(
|
|
137
|
+
(h) => {
|
|
138
|
+
u("Error"), i(h);
|
|
137
139
|
}
|
|
138
140
|
);
|
|
139
141
|
return () => {
|
|
140
142
|
d();
|
|
141
143
|
};
|
|
142
|
-
}, [
|
|
143
|
-
spendEcash:
|
|
144
|
-
async (d,
|
|
145
|
-
if (
|
|
144
|
+
}, [n]), {
|
|
145
|
+
spendEcash: w(
|
|
146
|
+
async (d, h) => {
|
|
147
|
+
if (t !== "open") throw new Error("Wallet is not open");
|
|
146
148
|
const S = await e.mint.spendNotes(
|
|
147
149
|
d * 1e3,
|
|
148
|
-
|
|
150
|
+
h
|
|
149
151
|
);
|
|
150
152
|
return o(S.operation_id), c(S.notes), S.notes;
|
|
151
153
|
},
|
|
152
|
-
[e,
|
|
154
|
+
[e, t]
|
|
153
155
|
),
|
|
154
156
|
notes: a,
|
|
155
157
|
state: l,
|
|
156
158
|
error: p
|
|
157
159
|
};
|
|
158
|
-
},
|
|
159
|
-
const e = g(), { walletStatus:
|
|
160
|
-
return
|
|
161
|
-
if (!
|
|
160
|
+
}, j = () => {
|
|
161
|
+
const e = g(), { walletStatus: t } = E(), [n, o] = r(), [a, c] = r(), [l, u] = r();
|
|
162
|
+
return m(() => {
|
|
163
|
+
if (!n) return;
|
|
162
164
|
const i = e.mint.subscribeReissueExternalNotes(
|
|
163
|
-
|
|
165
|
+
n,
|
|
164
166
|
(s) => {
|
|
165
167
|
c(s);
|
|
166
168
|
},
|
|
@@ -171,10 +173,10 @@ const R = (e) => {
|
|
|
171
173
|
return () => {
|
|
172
174
|
i();
|
|
173
175
|
};
|
|
174
|
-
}, [
|
|
175
|
-
redeemEcash:
|
|
176
|
+
}, [n]), {
|
|
177
|
+
redeemEcash: w(
|
|
176
178
|
async (i) => {
|
|
177
|
-
if (
|
|
179
|
+
if (t !== "open") throw new Error("Wallet is not open");
|
|
178
180
|
try {
|
|
179
181
|
const s = await e.mint.redeemEcash(i);
|
|
180
182
|
o(s);
|
|
@@ -182,21 +184,21 @@ const R = (e) => {
|
|
|
182
184
|
c("Error"), u(s);
|
|
183
185
|
}
|
|
184
186
|
},
|
|
185
|
-
[e,
|
|
187
|
+
[e, t]
|
|
186
188
|
),
|
|
187
189
|
state: a,
|
|
188
190
|
error: l
|
|
189
191
|
};
|
|
190
192
|
};
|
|
191
193
|
export {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
194
|
+
f as FedimintWalletContext,
|
|
195
|
+
C as FedimintWalletProvider,
|
|
196
|
+
O as setupFedimintWallet,
|
|
197
|
+
R as useBalance,
|
|
196
198
|
g as useFedimintWallet,
|
|
197
199
|
E as useOpenWallet,
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
200
|
+
j as useReceiveEcash,
|
|
201
|
+
N as useReceiveLightning,
|
|
202
|
+
B as useSendLightning,
|
|
203
|
+
_ as useSpendEcash
|
|
202
204
|
};
|
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 { FedimintWallet } from '@fedimint/core
|
|
1
|
+
import { WalletDirector, FedimintWallet, Transport } from '@fedimint/core'
|
|
2
2
|
import {
|
|
3
3
|
createContext,
|
|
4
4
|
createElement,
|
|
@@ -8,18 +8,23 @@ import {
|
|
|
8
8
|
} from 'react'
|
|
9
9
|
|
|
10
10
|
let wallet: FedimintWallet
|
|
11
|
+
let walletDirector: WalletDirector
|
|
11
12
|
|
|
12
13
|
type FedimintWalletConfig = {
|
|
13
14
|
lazy?: boolean
|
|
14
15
|
debug?: boolean
|
|
16
|
+
transport: Transport
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
export type WalletStatus = 'open' | 'closed' | 'opening'
|
|
18
20
|
|
|
19
21
|
export const setupFedimintWallet = (config: FedimintWalletConfig) => {
|
|
20
|
-
|
|
22
|
+
walletDirector = new WalletDirector(config.transport)
|
|
23
|
+
walletDirector.createWallet().then((w) => {
|
|
24
|
+
wallet = w
|
|
25
|
+
})
|
|
21
26
|
if (config.debug) {
|
|
22
|
-
|
|
27
|
+
walletDirector.setLogLevel('debug')
|
|
23
28
|
}
|
|
24
29
|
}
|
|
25
30
|
|
|
@@ -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,18 @@
|
|
|
1
|
-
import { FedimintWallet } 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
|
+
|
|
7
|
+
export const initFedimintReact = (
|
|
8
|
+
lazy: boolean = false,
|
|
9
|
+
transport: Transport,
|
|
10
|
+
) => {
|
|
11
|
+
walletDirector = new WalletDirector(transport)
|
|
6
12
|
if (!lazy) {
|
|
7
|
-
|
|
13
|
+
walletDirector.createWallet().then((w) => {
|
|
14
|
+
wallet = w
|
|
15
|
+
})
|
|
8
16
|
}
|
|
9
17
|
|
|
10
18
|
return {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedimint/react",
|
|
3
|
-
"version": "0.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
|
|
13
|
+
"@fedimint/core": "0.1.1"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@types/react": ">=19.1.4",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"eslint-plugin-react-refresh": "^0.4.20",
|
|
24
24
|
"react-dom": ">=19.1.0",
|
|
25
25
|
"typescript": "^5.8.3",
|
|
26
|
-
"vite": "^5.4.
|
|
26
|
+
"vite": "^5.4.20",
|
|
27
27
|
"vite-plugin-dts": "^4.5.4",
|
|
28
28
|
"vite-plugin-wasm": "^3.4.1"
|
|
29
29
|
},
|