@rozoai/intent-pay 0.1.22-beta.5 → 0.1.22-beta.7
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/build/assets/chains.d.ts +2 -1
- package/build/package.json.js +4 -4
- package/build/provider/RozoPayProvider.d.ts +3 -6
- package/build/provider/StellarContextProvider.d.ts +6 -10
- package/build/src/assets/chains.js +3 -2
- package/build/src/assets/chains.js.map +1 -1
- package/build/src/components/Pages/Stellar/ConnectStellar/index.js +23 -13
- package/build/src/components/Pages/Stellar/ConnectStellar/index.js.map +1 -1
- package/build/src/components/Pages/Stellar/PayWithStellarToken/index.js +4 -4
- package/build/src/components/Pages/Stellar/PayWithStellarToken/index.js.map +1 -1
- package/build/src/defaultConfig.js +2 -5
- package/build/src/defaultConfig.js.map +1 -1
- package/build/src/hooks/usePaymentState.js +2 -2
- package/build/src/hooks/usePaymentState.js.map +1 -1
- package/build/src/provider/RozoPayProvider.js.map +1 -1
- package/build/src/provider/StellarContextProvider.js +79 -90
- package/build/src/provider/StellarContextProvider.js.map +1 -1
- package/build/src/utils/index.js +11 -1
- package/build/src/utils/index.js.map +1 -1
- package/build/src/utils/stellar/singleton-import.js +60 -29
- package/build/src/utils/stellar/singleton-import.js.map +1 -1
- package/build/utils/stellar/index.d.ts +0 -1
- package/build/utils/stellar/singleton-import.d.ts +10 -11
- package/build/utils/stellar/walletconnect.module.d.ts +69 -14
- package/package.json +103 -102
- package/src/index.ts +0 -52
|
@@ -4,10 +4,11 @@ import { Horizon, Asset } from '@stellar/stellar-sdk';
|
|
|
4
4
|
import { createContext, useState, useMemo, useEffect, useContext } from 'react';
|
|
5
5
|
import { DEFAULT_STELLAR_RPC_URL } from '../constants/rozoConfig.js';
|
|
6
6
|
import { get, clear, add } from '../utils/localstorage.js';
|
|
7
|
-
import {
|
|
7
|
+
import { getStellarKitInstance } from '../utils/stellar/singleton-import.js';
|
|
8
8
|
|
|
9
9
|
const STELLAR_WALLET_STORAGE_KEY = "rozo-stellar-wallet";
|
|
10
10
|
const initialContext = {
|
|
11
|
+
kit: undefined,
|
|
11
12
|
isExternalKit: false,
|
|
12
13
|
stellarWalletPersistence: true,
|
|
13
14
|
server: undefined,
|
|
@@ -24,18 +25,25 @@ const initialContext = {
|
|
|
24
25
|
convertXlmToUsdc: () => Promise.resolve(""),
|
|
25
26
|
};
|
|
26
27
|
const StellarContext = createContext(initialContext);
|
|
27
|
-
const StellarContextProvider = ({ children, rpcUrl, kit:
|
|
28
|
+
const StellarContextProvider = ({ children, rpcUrl, kit: externalKit, stellarWalletPersistence: _stellarWalletPersistence, log, }) => {
|
|
29
|
+
// Set persistence: default true
|
|
28
30
|
const stellarWalletPersistence = _stellarWalletPersistence !== undefined ? _stellarWalletPersistence : true;
|
|
29
31
|
const [publicKey, setPublicKey] = useState(undefined);
|
|
30
32
|
const [accountInfo, setAccountInfo] = useState(undefined);
|
|
31
33
|
const [connector, setConnector] = useState(undefined);
|
|
32
34
|
const [isAccountExists, setIsAccountExists] = useState(false);
|
|
33
|
-
const [
|
|
35
|
+
const [internalKit, setInternalKit] = useState(undefined);
|
|
34
36
|
const [kitError, setKitError] = useState(undefined);
|
|
35
|
-
const
|
|
37
|
+
const kit = externalKit || internalKit;
|
|
38
|
+
const isUsingExternalKit = useMemo(() => {
|
|
39
|
+
return !!externalKit;
|
|
40
|
+
}, [externalKit]);
|
|
36
41
|
const server = useMemo(() => {
|
|
37
|
-
|
|
42
|
+
const s = new Horizon.Server(rpcUrl ?? DEFAULT_STELLAR_RPC_URL);
|
|
43
|
+
return s;
|
|
38
44
|
}, [rpcUrl]);
|
|
45
|
+
// Debug: on kit (external/internal) assign/change
|
|
46
|
+
useEffect(() => { }, [externalKit, internalKit]);
|
|
39
47
|
const getAccountInfo = async () => {
|
|
40
48
|
try {
|
|
41
49
|
if (!publicKey)
|
|
@@ -77,9 +85,10 @@ const StellarContextProvider = ({ children, rpcUrl, kit: externalKitReady, stell
|
|
|
77
85
|
if (stellarWalletPersistence) {
|
|
78
86
|
clear(STELLAR_WALLET_STORAGE_KEY);
|
|
79
87
|
}
|
|
80
|
-
if (
|
|
81
|
-
|
|
82
|
-
|
|
88
|
+
if (kit) {
|
|
89
|
+
if (!isUsingExternalKit) {
|
|
90
|
+
await kit.disconnect();
|
|
91
|
+
}
|
|
83
92
|
}
|
|
84
93
|
}
|
|
85
94
|
catch (error) {
|
|
@@ -87,23 +96,25 @@ const StellarContextProvider = ({ children, rpcUrl, kit: externalKitReady, stell
|
|
|
87
96
|
}
|
|
88
97
|
};
|
|
89
98
|
const setWallet = async (option) => {
|
|
90
|
-
if (!
|
|
99
|
+
if (!kit) {
|
|
91
100
|
throw new Error("Stellar kit not initialized yet. Please wait...");
|
|
92
101
|
}
|
|
93
102
|
if (!option)
|
|
94
103
|
return;
|
|
95
|
-
// Idempotent: already connected with this wallet — skip kit calls to avoid
|
|
96
|
-
// double WalletConnect confirmation.
|
|
104
|
+
// Idempotent: already connected with this wallet (e.g. React Strict Mode remount or payWithStellarToken) — skip kit calls to avoid double WalletConnect confirmation.
|
|
97
105
|
if (connector?.id === option.id && publicKey) {
|
|
98
106
|
setConnector(option);
|
|
99
107
|
log?.(`[Rozo] setWallet skipped (already connected): ${option.name}`);
|
|
100
108
|
return;
|
|
101
109
|
}
|
|
102
110
|
try {
|
|
103
|
-
|
|
111
|
+
let pk = publicKey;
|
|
112
|
+
// Connect wallet via kit (same flow for internal or consumer-provided kit).
|
|
113
|
+
// Consumer-provided kit only supplies the instance; we still run setWallet/getAddress when user picks a wallet in the modal.
|
|
104
114
|
log?.(`[Rozo] Connecting wallet: ${option.id} (externalKit: ${isUsingExternalKit})`);
|
|
105
|
-
|
|
106
|
-
const { address } = await
|
|
115
|
+
kit.setWallet(option.id);
|
|
116
|
+
const { address } = await kit.getAddress();
|
|
117
|
+
pk = address;
|
|
107
118
|
setPublicKey(address);
|
|
108
119
|
log?.(`[Rozo] Connected, publicKey: ${address}`);
|
|
109
120
|
setConnector(option);
|
|
@@ -112,7 +123,7 @@ const StellarContextProvider = ({ children, rpcUrl, kit: externalKitReady, stell
|
|
|
112
123
|
walletId: option.id,
|
|
113
124
|
walletName: option.name,
|
|
114
125
|
walletIcon: option.icon,
|
|
115
|
-
publicKey:
|
|
126
|
+
publicKey: pk,
|
|
116
127
|
});
|
|
117
128
|
}
|
|
118
129
|
log?.(`[Rozo] setWallet completed successfully for: ${option.name}`);
|
|
@@ -122,102 +133,79 @@ const StellarContextProvider = ({ children, rpcUrl, kit: externalKitReady, stell
|
|
|
122
133
|
throw new Error(err.message || "Failed to set wallet");
|
|
123
134
|
}
|
|
124
135
|
};
|
|
125
|
-
// Initialize
|
|
136
|
+
// Initialize kit using singleton pattern
|
|
126
137
|
useEffect(() => {
|
|
127
|
-
|
|
138
|
+
// Skip on server-side
|
|
139
|
+
if (typeof window === "undefined") {
|
|
128
140
|
return;
|
|
141
|
+
}
|
|
142
|
+
// Skip if external kit provided or already initialized
|
|
143
|
+
if (isUsingExternalKit) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
129
146
|
let mounted = true;
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
if (mounted)
|
|
136
|
-
setIsKitReady(true);
|
|
147
|
+
getStellarKitInstance({ log })
|
|
148
|
+
.then((kitInstance) => {
|
|
149
|
+
if (mounted) {
|
|
150
|
+
setInternalKit(kitInstance);
|
|
137
151
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
152
|
+
})
|
|
153
|
+
.catch((error) => {
|
|
154
|
+
console.error("[Rozo] Failed to initialize Stellar kit (singleton):", error);
|
|
155
|
+
if (mounted) {
|
|
156
|
+
setKitError(error.message);
|
|
142
157
|
}
|
|
143
|
-
};
|
|
144
|
-
setup();
|
|
158
|
+
});
|
|
145
159
|
return () => {
|
|
146
160
|
mounted = false;
|
|
147
161
|
};
|
|
148
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
149
162
|
}, []);
|
|
150
|
-
//
|
|
151
|
-
// (picks up connections made externally via consumer's own SWK usage)
|
|
152
|
-
useEffect(() => {
|
|
153
|
-
if (!isKitReady || typeof window === "undefined")
|
|
154
|
-
return;
|
|
155
|
-
let cleanupFn;
|
|
156
|
-
const subscribe = async () => {
|
|
157
|
-
const { StellarWalletsKit, KitEventType } = await import('@creit.tech/stellar-wallets-kit');
|
|
158
|
-
const unsubState = StellarWalletsKit.on(KitEventType.STATE_UPDATED, (event) => {
|
|
159
|
-
const addr = event.payload?.address;
|
|
160
|
-
if (addr)
|
|
161
|
-
setPublicKey(addr);
|
|
162
|
-
});
|
|
163
|
-
const unsubDisconnect = StellarWalletsKit.on(KitEventType.DISCONNECT, () => {
|
|
164
|
-
setPublicKey(undefined);
|
|
165
|
-
setConnector(undefined);
|
|
166
|
-
setAccountInfo(undefined);
|
|
167
|
-
});
|
|
168
|
-
cleanupFn = () => {
|
|
169
|
-
unsubState?.();
|
|
170
|
-
unsubDisconnect?.();
|
|
171
|
-
};
|
|
172
|
-
};
|
|
173
|
-
subscribe();
|
|
174
|
-
return () => cleanupFn?.();
|
|
175
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
176
|
-
}, [isKitReady]);
|
|
163
|
+
// Show error if kit initialization failed
|
|
177
164
|
useEffect(() => {
|
|
178
165
|
if (kitError) {
|
|
179
166
|
console.error("❌ Stellar kit initialization failed:\n" +
|
|
180
167
|
kitError +
|
|
181
168
|
"\n\n" +
|
|
182
|
-
"To fix this,
|
|
183
|
-
'import { StellarWalletsKit,
|
|
184
|
-
"StellarWalletsKit
|
|
185
|
-
"
|
|
169
|
+
"To fix this, provide your own kit instance:\n\n" +
|
|
170
|
+
'import { StellarWalletsKit, WalletNetwork, allowAllModules } from "@creit.tech/stellar-wallets-kit";\n\n' +
|
|
171
|
+
"const kit = new StellarWalletsKit({\n" +
|
|
172
|
+
" network: WalletNetwork.PUBLIC,\n" +
|
|
173
|
+
" modules: allowAllModules(),\n" +
|
|
174
|
+
"});\n\n" +
|
|
175
|
+
"<RozoPayProvider stellarKit={kit}>{children}</RozoPayProvider>");
|
|
186
176
|
}
|
|
187
177
|
}, [kitError]);
|
|
188
|
-
// Auto-reconnect to previously connected wallet
|
|
178
|
+
// Auto-reconnect to previously connected wallet - only if persistence is true
|
|
189
179
|
useEffect(() => {
|
|
190
|
-
if (
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
console.error("[Rozo] Auto-reconnect failed:", error);
|
|
208
|
-
disconnect();
|
|
180
|
+
if (kit && typeof window !== "undefined" && stellarWalletPersistence) {
|
|
181
|
+
const savedWallet = get(STELLAR_WALLET_STORAGE_KEY);
|
|
182
|
+
if (savedWallet && savedWallet.length > 0) {
|
|
183
|
+
const lastWallet = savedWallet[0];
|
|
184
|
+
if (lastWallet.walletId && lastWallet.publicKey) {
|
|
185
|
+
try {
|
|
186
|
+
setWallet({
|
|
187
|
+
id: lastWallet.walletId,
|
|
188
|
+
name: lastWallet.walletName,
|
|
189
|
+
icon: lastWallet.walletIcon,
|
|
190
|
+
...lastWallet,
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
console.error("[Rozo] Auto-reconnect failed:", error);
|
|
195
|
+
disconnect();
|
|
196
|
+
}
|
|
209
197
|
}
|
|
210
198
|
}
|
|
211
199
|
}
|
|
212
|
-
|
|
213
|
-
}, [isKitReady, stellarWalletPersistence]);
|
|
200
|
+
}, [kit, stellarWalletPersistence]);
|
|
214
201
|
useEffect(() => {
|
|
215
|
-
if (publicKey)
|
|
202
|
+
if (publicKey) {
|
|
216
203
|
getAccountInfo();
|
|
217
|
-
|
|
204
|
+
}
|
|
218
205
|
}, [publicKey]);
|
|
219
206
|
const contextValue = useMemo(() => {
|
|
220
|
-
|
|
207
|
+
const context = {
|
|
208
|
+
kit,
|
|
221
209
|
isExternalKit: isUsingExternalKit,
|
|
222
210
|
stellarWalletPersistence,
|
|
223
211
|
publicKey,
|
|
@@ -233,16 +221,16 @@ const StellarContextProvider = ({ children, rpcUrl, kit: externalKitReady, stell
|
|
|
233
221
|
disconnect,
|
|
234
222
|
convertXlmToUsdc,
|
|
235
223
|
};
|
|
224
|
+
return context;
|
|
236
225
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
237
226
|
}, [
|
|
238
|
-
|
|
227
|
+
kit,
|
|
239
228
|
stellarWalletPersistence,
|
|
240
229
|
publicKey,
|
|
241
230
|
server,
|
|
242
231
|
accountInfo,
|
|
243
232
|
isAccountExists,
|
|
244
233
|
connector,
|
|
245
|
-
isKitReady,
|
|
246
234
|
]);
|
|
247
235
|
return (jsx(StellarContext.Provider, { value: contextValue, children: children }));
|
|
248
236
|
};
|
|
@@ -254,8 +242,9 @@ const useStellar = () => {
|
|
|
254
242
|
return context;
|
|
255
243
|
};
|
|
256
244
|
const useRozoConnectStellar = () => {
|
|
257
|
-
const { publicKey, account, isConnected, connector, disconnect, setPublicKey, setWallet: setConnector, } = useStellar();
|
|
245
|
+
const { kit, publicKey, account, isConnected, connector, disconnect, setPublicKey, setWallet: setConnector, } = useStellar();
|
|
258
246
|
return {
|
|
247
|
+
kit,
|
|
259
248
|
isConnected,
|
|
260
249
|
publicKey,
|
|
261
250
|
account,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StellarContextProvider.js","sources":["../../../src/provider/StellarContextProvider.tsx"],"sourcesContent":[null],"names":["LocalStorage.clear","LocalStorage.add","LocalStorage.get","_jsx"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"StellarContextProvider.js","sources":["../../../src/provider/StellarContextProvider.tsx"],"sourcesContent":[null],"names":["LocalStorage.clear","LocalStorage.add","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AC;AACF,QAAA,OAAO,OAAO,CAAC;;AAEjB,KAAC,EAAE;QACD,GAAG;QACH,wBAAwB;QACxB,SAAS;QACT,MAAM;QACN,WAAW;QACX,eAAe;QACf,SAAS;AACV,KAAA,CAAC,CAAC;AAEH,IAAA,QACEC,GAAA,CAAC,cAAc,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,YAAY,EAAA,QAAA,EACzC,QAAQ,EAAA,CACe,EAC1B;AACJ,EAAE;AAEK,MAAM,UAAU,GAAG,MAAK;AAC7B,IAAA,MAAM,OAAO,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;IAC3C,IAAI,CAAC,OAAO,EAAE;AACZ,QAAA,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;KAC5E;AACD,IAAA,OAAO,OAAO,CAAC;AACjB,EAAE;AAEK,MAAM,qBAAqB,GAAG,MAAK;IACxC,MAAM,EACJ,GAAG,EACH,SAAS,EACT,OAAO,EACP,WAAW,EACX,SAAS,EACT,UAAU,EACV,YAAY,EACZ,SAAS,EAAE,YAAY,GACxB,GAAG,UAAU,EAAE,CAAC;IAEjB,OAAO;QACL,GAAG;QACH,WAAW;QACX,SAAS;QACT,OAAO;QACP,SAAS;QACT,YAAY;QACZ,YAAY;QACZ,UAAU;KACX,CAAC;AACJ;;;;"}
|
package/build/src/utils/index.js
CHANGED
|
@@ -35,6 +35,16 @@ const isCoinbaseWalletConnector = (connectorId) => connectorId === "coinbaseWall
|
|
|
35
35
|
const isPhantomConnector = (connectorId) => connectorId === "phantom";
|
|
36
36
|
const isSafeConnector = (connectorId) => connectorId === "safe";
|
|
37
37
|
const isInjectedConnector = (connectorId) => connectorId === "injected";
|
|
38
|
+
function parseError(e) {
|
|
39
|
+
return {
|
|
40
|
+
code: e?.error?.code || e?.code || -1,
|
|
41
|
+
message: e?.error?.message ||
|
|
42
|
+
e?.message ||
|
|
43
|
+
(typeof e === "string" && e) ||
|
|
44
|
+
"Unhandled error from the wallet",
|
|
45
|
+
ext: e?.error?.ext || e?.ext,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
38
48
|
|
|
39
|
-
export { detectBrowser, detectOS, flattenChildren, isAndroid, isCoinbaseWalletConnector, isIOS, isInjectedConnector, isMobile, isPhantomConnector, isSafeConnector };
|
|
49
|
+
export { detectBrowser, detectOS, flattenChildren, isAndroid, isCoinbaseWalletConnector, isIOS, isInjectedConnector, isMobile, isPhantomConnector, isSafeConnector, parseError };
|
|
40
50
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/utils/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AA4CO,MAAM,aAAa,GAAG,MAAK;AAChC,IAAA,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC;AACzB,IAAA,OAAO,OAAO,EAAE,IAAI,IAAI,EAAE,CAAC;AAC7B,EAAE;AACK,MAAM,QAAQ,GAAG,MAAK;AAC3B,IAAA,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC;AACzB,IAAA,OAAO,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC;AAC3B,EAAE;AAEK,MAAM,KAAK,GAAG,MAAK;AACxB,IAAA,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAC;IACtB,OAAO,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC1C,EAAE;AACK,MAAM,SAAS,GAAG,MAAK;AAC5B,IAAA,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAC;IACtB,OAAO,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;AAC9C,EAAE;AACK,MAAM,QAAQ,GAAG,MAAK;AAC3B,IAAA,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAC,WAAW,EAAE,CAAC;AACpC,IAAA,OAAO,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,KA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AAA;IAC/B,OAAO;AACL,QAAA,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,CAAC;AACrC,QAAA,OAAO,EACL,CAAC,EAAE,KAAK,EAAE,OAAO;AACjB,YAAA,CAAC,EAAE,OAAO;AACV,aAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC;YAC5B,iCAAiC;QACnC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,EAAE,GAAG;KAC7B,CAAC;AACJ;;;;"}
|
|
@@ -1,52 +1,83 @@
|
|
|
1
|
+
import '@reown/appkit/networks';
|
|
2
|
+
import { WalletConnectModule } from './walletconnect.module.js';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* Consumer can skip this entirely by calling StellarWalletsKit.init() themselves
|
|
5
|
-
* and passing stellarKit={true} to RozoPayProvider.
|
|
5
|
+
* Creates or returns existing StellarWalletsKit instance
|
|
6
|
+
* This prevents duplicate custom element registration errors
|
|
6
7
|
*/
|
|
7
|
-
async function
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
config?.log?.("[Rozo] StellarWalletsKit
|
|
12
|
-
return;
|
|
8
|
+
async function getStellarKitInstance(config) {
|
|
9
|
+
// Return existing instance if available
|
|
10
|
+
if (typeof window !== "undefined" &&
|
|
11
|
+
globalThis.__ROZO_STELLAR_KIT_INSTANCE__) {
|
|
12
|
+
config?.log?.("[Rozo] Using existing StellarWalletsKit instance");
|
|
13
|
+
return globalThis.__ROZO_STELLAR_KIT_INSTANCE__;
|
|
13
14
|
}
|
|
14
|
-
|
|
15
|
+
// If already loading, wait for it
|
|
16
|
+
if (typeof window !== "undefined" &&
|
|
17
|
+
globalThis.__ROZO_STELLAR_KIT_LOADING__) {
|
|
15
18
|
config?.log?.("[Rozo] Waiting for StellarWalletsKit initialization...");
|
|
16
19
|
return globalThis.__ROZO_STELLAR_KIT_LOADING__;
|
|
17
20
|
}
|
|
21
|
+
// Check if custom element is already registered
|
|
22
|
+
if (typeof window !== "undefined" &&
|
|
23
|
+
customElements.get("stellar-wallets-modal")) {
|
|
24
|
+
throw new Error("⚠️ StellarWalletsKit custom element is already registered.\n\n" +
|
|
25
|
+
"This usually means the library was initialized elsewhere in your app.\n" +
|
|
26
|
+
"To fix this:\n\n" +
|
|
27
|
+
"1. Create ONE StellarWalletsKit instance at your app root\n" +
|
|
28
|
+
'2. Pass it to RozoPayProvider via the "stellarKit" prop\n\n' +
|
|
29
|
+
"Example:\n\n" +
|
|
30
|
+
'import { StellarWalletsKit, WalletNetwork, allowAllModules } from "@creit.tech/stellar-wallets-kit";\n\n' +
|
|
31
|
+
"const stellarKit = new StellarWalletsKit({\n" +
|
|
32
|
+
" network: WalletNetwork.PUBLIC,\n" +
|
|
33
|
+
" modules: allowAllModules(),\n" +
|
|
34
|
+
"});\n\n" +
|
|
35
|
+
"<RozoPayProvider stellarKit={stellarKit}>\n" +
|
|
36
|
+
" {children}\n" +
|
|
37
|
+
"</RozoPayProvider>");
|
|
38
|
+
}
|
|
39
|
+
// Start loading
|
|
18
40
|
const loadingPromise = (async () => {
|
|
19
41
|
try {
|
|
20
|
-
const
|
|
21
|
-
const {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
name: "Rozo",
|
|
29
|
-
description: "Visa Layer for Stablecoins",
|
|
42
|
+
const module = await import('@creit.tech/stellar-wallets-kit');
|
|
43
|
+
const { StellarWalletsKit, WalletNetwork, allowAllModules } = module;
|
|
44
|
+
const newKit = new StellarWalletsKit({
|
|
45
|
+
network: config?.network || WalletNetwork.PUBLIC,
|
|
46
|
+
selectedWalletId: config?.selectedWalletId || "freighter",
|
|
47
|
+
modules: config?.modules || [
|
|
48
|
+
...allowAllModules(),
|
|
49
|
+
new WalletConnectModule({
|
|
30
50
|
url: "https://rozo.ai",
|
|
51
|
+
projectId: "7440dd8acf85933ffcc775ec6675d4a9",
|
|
52
|
+
description: `Visa Layer for Stablecoins`,
|
|
53
|
+
name: "Rozo",
|
|
31
54
|
icons: ["https://rozo.ai/rozo-logo.png"],
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
55
|
+
network: WalletNetwork.PUBLIC,
|
|
56
|
+
}),
|
|
57
|
+
],
|
|
58
|
+
});
|
|
59
|
+
// Store globally
|
|
60
|
+
if (typeof window !== "undefined") {
|
|
61
|
+
globalThis.__ROZO_STELLAR_KIT_INSTANCE__ = newKit;
|
|
62
|
+
}
|
|
37
63
|
config?.log?.("[Rozo] StellarWalletsKit initialized successfully");
|
|
64
|
+
return newKit;
|
|
38
65
|
}
|
|
39
66
|
catch (error) {
|
|
40
67
|
config?.log?.(`[Rozo] Failed to initialize StellarWalletsKit: ${error}`);
|
|
41
68
|
throw error;
|
|
42
69
|
}
|
|
43
70
|
finally {
|
|
44
|
-
|
|
71
|
+
if (typeof window !== "undefined") {
|
|
72
|
+
globalThis.__ROZO_STELLAR_KIT_LOADING__ = undefined;
|
|
73
|
+
}
|
|
45
74
|
}
|
|
46
75
|
})();
|
|
47
|
-
|
|
76
|
+
if (typeof window !== "undefined") {
|
|
77
|
+
globalThis.__ROZO_STELLAR_KIT_LOADING__ = loadingPromise;
|
|
78
|
+
}
|
|
48
79
|
return loadingPromise;
|
|
49
80
|
}
|
|
50
81
|
|
|
51
|
-
export {
|
|
82
|
+
export { getStellarKitInstance };
|
|
52
83
|
//# sourceMappingURL=singleton-import.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"singleton-import.js","sources":["../../../../src/utils/stellar/singleton-import.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"singleton-import.js","sources":["../../../../src/utils/stellar/singleton-import.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AASA;;;AAGG;AACI,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G,EAAE,iBAAiB;AACtB,wBAAA,SAAS,EAAE,kCAAkC;AAC7C,wBAAA,WAAW,EAAE,CAA4B,0BAAA,CAAA;AACzC,wBAAA,IAAI,EAAE,MAAM;wBACZ,KAAK,EAAE,CAAC,+BAA+B,CAAC;wBACxC,OAAO,EAAE,aAAa,CAAC,MAAM;qBAC9B,CAAC;AACH,iBAAA;AACF,aAAA,CAAC,CAAC;;AAGH,YAAA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;AAChC,gBAAA,UAAkB,CAAC,6BAA6B,GAAG,MAAM,CAAC;aAC5D;AAED,YAAA,MAAM,EAAE,GAAG,GAAG,mDAAmD,CAAC,CAAC;AACnE,YAAA,OAAO,MAAM,CAAC;SACf;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,EAAE,GAAG,GAAG,kDAAkD,KAAK,CAAA,CAAE,CAAC,CAAC;AACzE,YAAA,MAAM,KAAK,CAAC;SACb;gBAAS;AACR,YAAA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;AAChC,gBAAA,UAAkB,CAAC,4BAA4B,GAAG,SAAS,CAAC;aAC9D;SACF;KACF,GAAG,CAAC;AAEL,IAAA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;AAChC,QAAA,UAAkB,CAAC,4BAA4B,GAAG,cAAc,CAAC;KACnE;AAED,IAAA,OAAO,cAAc,CAAC;AACxB;;;;"}
|
|
@@ -4,4 +4,3 @@ export { defineStellarChain, isStellarChain, STELLAR_NETWORKS } from "./types";
|
|
|
4
4
|
export type { StellarChainConfig } from "./types";
|
|
5
5
|
export { WalletConnectAllowedMethods, WalletConnectModule, WalletConnectTargetChain, } from "./walletconnect.module";
|
|
6
6
|
export type { IParsedWalletConnectSession, IWalletConnectConstructorParams, } from "./walletconnect.module";
|
|
7
|
-
export { initStellarKit, isStellarKitInitialized } from "./singleton-import";
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { StellarWalletsKit } from "@creit.tech/stellar-wallets-kit";
|
|
2
2
|
declare global {
|
|
3
|
-
let
|
|
4
|
-
let __ROZO_STELLAR_KIT_LOADING__: Promise<
|
|
3
|
+
let __ROZO_STELLAR_KIT_INSTANCE__: StellarWalletsKit | undefined;
|
|
4
|
+
let __ROZO_STELLAR_KIT_LOADING__: Promise<StellarWalletsKit> | undefined;
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* Consumer can skip this entirely by calling StellarWalletsKit.init() themselves
|
|
10
|
-
* and passing stellarKit={true} to RozoPayProvider.
|
|
7
|
+
* Creates or returns existing StellarWalletsKit instance
|
|
8
|
+
* This prevents duplicate custom element registration errors
|
|
11
9
|
*/
|
|
12
|
-
export declare function
|
|
10
|
+
export declare function getStellarKitInstance(config?: {
|
|
13
11
|
log?: (msg: string) => void;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
network?: any;
|
|
13
|
+
selectedWalletId?: string;
|
|
14
|
+
modules?: any[];
|
|
15
|
+
}): Promise<StellarWalletsKit>;
|
|
@@ -1,12 +1,53 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ModuleInterface, ModuleType } from "@creit.tech/stellar-wallets-kit";
|
|
2
|
+
import { CreateAppKit, createAppKit } from "@reown/appkit";
|
|
3
|
+
import type { SignClientTypes } from "@walletconnect/types";
|
|
4
|
+
import { type default as Client } from "@walletconnect/sign-client";
|
|
2
5
|
export declare const WALLET_CONNECT_ID = "wallet_connect";
|
|
3
|
-
export declare
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
export declare class WalletConnectModule implements ModuleInterface {
|
|
7
|
+
wcParams: IWalletConnectConstructorParams;
|
|
8
|
+
moduleType: ModuleType;
|
|
9
|
+
productId: string;
|
|
10
|
+
productName: string;
|
|
11
|
+
productUrl: string;
|
|
12
|
+
productIcon: string;
|
|
13
|
+
modal: ReturnType<typeof createAppKit>;
|
|
14
|
+
signClient: Client;
|
|
15
|
+
constructor(wcParams: IWalletConnectConstructorParams);
|
|
16
|
+
isAvailable(): Promise<boolean>;
|
|
17
|
+
isPlatformWrapper(): Promise<boolean>;
|
|
18
|
+
private runChecks;
|
|
19
|
+
getAddress(): Promise<{
|
|
20
|
+
address: string;
|
|
21
|
+
}>;
|
|
22
|
+
signTransaction(xdr: string, opts?: {
|
|
23
|
+
networkPassphrase?: string;
|
|
24
|
+
address?: string;
|
|
25
|
+
path?: string;
|
|
26
|
+
submit?: boolean;
|
|
27
|
+
submitUrl?: string;
|
|
28
|
+
}): Promise<{
|
|
29
|
+
signedTxXdr: string;
|
|
30
|
+
signerAddress?: string;
|
|
31
|
+
}>;
|
|
32
|
+
signAuthEntry(): Promise<{
|
|
33
|
+
signedAuthEntry: string;
|
|
34
|
+
signerAddress?: string;
|
|
35
|
+
}>;
|
|
36
|
+
signMessage(): Promise<{
|
|
37
|
+
signedMessage: string;
|
|
38
|
+
signerAddress?: string;
|
|
39
|
+
}>;
|
|
40
|
+
getNetwork(): Promise<{
|
|
41
|
+
network: string;
|
|
42
|
+
networkPassphrase: string;
|
|
43
|
+
}>;
|
|
44
|
+
setSession(sessionId: string): void;
|
|
45
|
+
onSessionDeleted(cb: (sessionId: string) => void): void;
|
|
46
|
+
/** @deprecated Use getAddress() which handles connection automatically. */
|
|
47
|
+
connectWalletConnect(): Promise<IParsedWalletConnectSession>;
|
|
48
|
+
disconnect(): Promise<void>;
|
|
49
|
+
closeSession(sessionId: string, reason?: string): Promise<void>;
|
|
50
|
+
getSessions(): Promise<IParsedWalletConnectSession[]>;
|
|
10
51
|
}
|
|
11
52
|
export interface IParsedWalletConnectSession {
|
|
12
53
|
id: string;
|
|
@@ -21,10 +62,24 @@ export interface IParsedWalletConnectSession {
|
|
|
21
62
|
}
|
|
22
63
|
export interface IWalletConnectConstructorParams {
|
|
23
64
|
projectId: string;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
65
|
+
name: string;
|
|
66
|
+
description: string;
|
|
67
|
+
url: string;
|
|
68
|
+
icons: string[];
|
|
69
|
+
/** @deprecated method is now always SIGN; kept for backwards compat */
|
|
70
|
+
method?: WalletConnectAllowedMethods;
|
|
71
|
+
network: string;
|
|
72
|
+
allowedChains?: WalletConnectTargetChain[];
|
|
73
|
+
sessionId?: string;
|
|
74
|
+
signClientOptions?: SignClientTypes.Options;
|
|
75
|
+
appKitOptions?: Partial<CreateAppKit>;
|
|
76
|
+
onSessionDeleted?: (sessionId: string) => void;
|
|
77
|
+
}
|
|
78
|
+
export declare enum WalletConnectTargetChain {
|
|
79
|
+
PUBLIC = "stellar:pubnet",
|
|
80
|
+
TESTNET = "stellar:testnet"
|
|
81
|
+
}
|
|
82
|
+
export declare enum WalletConnectAllowedMethods {
|
|
83
|
+
SIGN = "stellar_signXDR",
|
|
84
|
+
SIGN_AND_SUBMIT = "stellar_signAndSubmitXDR"
|
|
30
85
|
}
|