@moon-x/react-sdk 0.1.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 +241 -0
- package/dist/assets/Sons-Black.ttf +0 -0
- package/dist/assets/Sons-Bold.ttf +0 -0
- package/dist/assets/Sons-Extrabold.ttf +0 -0
- package/dist/assets/Sons-Light.ttf +0 -0
- package/dist/assets/Sons-Medium.ttf +0 -0
- package/dist/assets/Sons-Regular.ttf +0 -0
- package/dist/assets/Sons-Semibold.ttf +0 -0
- package/dist/assets/Sons-Thin.ttf +0 -0
- package/dist/base-wallet-CzJLpndu.d.mts +119 -0
- package/dist/base-wallet-CzJLpndu.d.ts +119 -0
- package/dist/chunk-73TEXNFX.js +1018 -0
- package/dist/chunk-7BCQAHO6.mjs +1561 -0
- package/dist/chunk-CDSNBPXB.js +1988 -0
- package/dist/chunk-MYWXMCMO.mjs +662 -0
- package/dist/chunk-PCEN5CH6.mjs +169 -0
- package/dist/chunk-SPXMMQ7Z.js +248 -0
- package/dist/ethereum-BRGKpUFH.d.ts +311 -0
- package/dist/ethereum-DobH9IQl.d.mts +311 -0
- package/dist/index.css +169 -0
- package/dist/index.d.mts +298 -0
- package/dist/index.d.ts +298 -0
- package/dist/index.js +24365 -0
- package/dist/index.mjs +18194 -0
- package/dist/solana-CzXRbze_.d.mts +236 -0
- package/dist/solana-D7BgQ4c0.d.ts +236 -0
- package/dist/style.css +169 -0
- package/dist/wallets/ethereum.d.mts +4 -0
- package/dist/wallets/ethereum.d.ts +4 -0
- package/dist/wallets/ethereum.js +21 -0
- package/dist/wallets/ethereum.mjs +4 -0
- package/dist/wallets/solana.d.mts +4 -0
- package/dist/wallets/solana.d.ts +4 -0
- package/dist/wallets/solana.js +17 -0
- package/dist/wallets/solana.mjs +4 -0
- package/package.json +70 -0
|
@@ -0,0 +1,662 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
3
|
+
try {
|
|
4
|
+
var info = gen[key](arg);
|
|
5
|
+
var value = info.value;
|
|
6
|
+
} catch (error) {
|
|
7
|
+
reject(error);
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
if (info.done) {
|
|
11
|
+
resolve(value);
|
|
12
|
+
} else {
|
|
13
|
+
Promise.resolve(value).then(_next, _throw);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function _async_to_generator(fn) {
|
|
17
|
+
return function() {
|
|
18
|
+
var self = this, args = arguments;
|
|
19
|
+
return new Promise(function(resolve, reject) {
|
|
20
|
+
var gen = fn.apply(self, args);
|
|
21
|
+
function _next(value) {
|
|
22
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
23
|
+
}
|
|
24
|
+
function _throw(err) {
|
|
25
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
26
|
+
}
|
|
27
|
+
_next(undefined);
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function _define_property(obj, key, value) {
|
|
32
|
+
if (key in obj) {
|
|
33
|
+
Object.defineProperty(obj, key, {
|
|
34
|
+
value: value,
|
|
35
|
+
enumerable: true,
|
|
36
|
+
configurable: true,
|
|
37
|
+
writable: true
|
|
38
|
+
});
|
|
39
|
+
} else {
|
|
40
|
+
obj[key] = value;
|
|
41
|
+
}
|
|
42
|
+
return obj;
|
|
43
|
+
}
|
|
44
|
+
function _instanceof(left, right) {
|
|
45
|
+
"@swc/helpers - instanceof";
|
|
46
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
47
|
+
return !!right[Symbol.hasInstance](left);
|
|
48
|
+
} else {
|
|
49
|
+
return left instanceof right;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function _object_spread(target) {
|
|
53
|
+
for(var i = 1; i < arguments.length; i++){
|
|
54
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
55
|
+
var ownKeys = Object.keys(source);
|
|
56
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
57
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
58
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
ownKeys.forEach(function(key) {
|
|
62
|
+
_define_property(target, key, source[key]);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return target;
|
|
66
|
+
}
|
|
67
|
+
function ownKeys(object, enumerableOnly) {
|
|
68
|
+
var keys = Object.keys(object);
|
|
69
|
+
if (Object.getOwnPropertySymbols) {
|
|
70
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
71
|
+
if (enumerableOnly) {
|
|
72
|
+
symbols = symbols.filter(function(sym) {
|
|
73
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
keys.push.apply(keys, symbols);
|
|
77
|
+
}
|
|
78
|
+
return keys;
|
|
79
|
+
}
|
|
80
|
+
function _object_spread_props(target, source) {
|
|
81
|
+
source = source != null ? source : {};
|
|
82
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
83
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
84
|
+
} else {
|
|
85
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
86
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
return target;
|
|
90
|
+
}
|
|
91
|
+
function _ts_generator(thisArg, body) {
|
|
92
|
+
var f, y, t, _ = {
|
|
93
|
+
label: 0,
|
|
94
|
+
sent: function() {
|
|
95
|
+
if (t[0] & 1) throw t[1];
|
|
96
|
+
return t[1];
|
|
97
|
+
},
|
|
98
|
+
trys: [],
|
|
99
|
+
ops: []
|
|
100
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
101
|
+
return d(g, "next", {
|
|
102
|
+
value: verb(0)
|
|
103
|
+
}), d(g, "throw", {
|
|
104
|
+
value: verb(1)
|
|
105
|
+
}), d(g, "return", {
|
|
106
|
+
value: verb(2)
|
|
107
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
108
|
+
value: function() {
|
|
109
|
+
return this;
|
|
110
|
+
}
|
|
111
|
+
}), g;
|
|
112
|
+
function verb(n) {
|
|
113
|
+
return function(v) {
|
|
114
|
+
return step([
|
|
115
|
+
n,
|
|
116
|
+
v
|
|
117
|
+
]);
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function step(op) {
|
|
121
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
122
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
123
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
124
|
+
if (y = 0, t) op = [
|
|
125
|
+
op[0] & 2,
|
|
126
|
+
t.value
|
|
127
|
+
];
|
|
128
|
+
switch(op[0]){
|
|
129
|
+
case 0:
|
|
130
|
+
case 1:
|
|
131
|
+
t = op;
|
|
132
|
+
break;
|
|
133
|
+
case 4:
|
|
134
|
+
_.label++;
|
|
135
|
+
return {
|
|
136
|
+
value: op[1],
|
|
137
|
+
done: false
|
|
138
|
+
};
|
|
139
|
+
case 5:
|
|
140
|
+
_.label++;
|
|
141
|
+
y = op[1];
|
|
142
|
+
op = [
|
|
143
|
+
0
|
|
144
|
+
];
|
|
145
|
+
continue;
|
|
146
|
+
case 7:
|
|
147
|
+
op = _.ops.pop();
|
|
148
|
+
_.trys.pop();
|
|
149
|
+
continue;
|
|
150
|
+
default:
|
|
151
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
152
|
+
_ = 0;
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
156
|
+
_.label = op[1];
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
160
|
+
_.label = t[1];
|
|
161
|
+
t = op;
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
if (t && _.label < t[2]) {
|
|
165
|
+
_.label = t[2];
|
|
166
|
+
_.ops.push(op);
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
if (t[2]) _.ops.pop();
|
|
170
|
+
_.trys.pop();
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
op = body.call(thisArg, _);
|
|
174
|
+
} catch (e) {
|
|
175
|
+
op = [
|
|
176
|
+
6,
|
|
177
|
+
e
|
|
178
|
+
];
|
|
179
|
+
y = 0;
|
|
180
|
+
} finally{
|
|
181
|
+
f = t = 0;
|
|
182
|
+
}
|
|
183
|
+
if (op[0] & 5) throw op[1];
|
|
184
|
+
return {
|
|
185
|
+
value: op[0] ? op[1] : void 0,
|
|
186
|
+
done: true
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
import { __export, dispatchSignOp, shouldShowWalletUI, useAuthSDK } from "./chunk-PCEN5CH6.mjs";
|
|
191
|
+
// src/wallets/solana.ts
|
|
192
|
+
var solana_exports = {};
|
|
193
|
+
__export(solana_exports, {
|
|
194
|
+
useCreateWallet: function useCreateWallet1() {
|
|
195
|
+
return useCreateWallet;
|
|
196
|
+
},
|
|
197
|
+
useExportKey: function useExportKey1() {
|
|
198
|
+
return useExportKey;
|
|
199
|
+
},
|
|
200
|
+
useFundWallet: function useFundWallet1() {
|
|
201
|
+
return useFundWallet;
|
|
202
|
+
},
|
|
203
|
+
useGetBalance: function useGetBalance1() {
|
|
204
|
+
return useGetBalance;
|
|
205
|
+
},
|
|
206
|
+
useGetTokenAccounts: function useGetTokenAccounts1() {
|
|
207
|
+
return useGetTokenAccounts;
|
|
208
|
+
},
|
|
209
|
+
useImportKey: function useImportKey1() {
|
|
210
|
+
return useImportKey;
|
|
211
|
+
},
|
|
212
|
+
useSendTransaction: function useSendTransaction1() {
|
|
213
|
+
return useSendTransaction;
|
|
214
|
+
},
|
|
215
|
+
useSignMessage: function useSignMessage1() {
|
|
216
|
+
return useSignMessage;
|
|
217
|
+
},
|
|
218
|
+
useSignTransaction: function useSignTransaction1() {
|
|
219
|
+
return useSignTransaction;
|
|
220
|
+
},
|
|
221
|
+
useWallets: function useWallets1() {
|
|
222
|
+
return useWallets;
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
import { useSignMessage as useSharedSolSignMessage, useSignTransaction as useSharedSolSignTransaction, useSendTransaction as useSharedSolSendTransaction, useGetBalance as useSharedSolGetBalance } from "@moon-x/core/react/solana";
|
|
226
|
+
import { useCreateWallet as useSharedCreateWallet, useImportKey as useSharedImportKey, useWallets as useSharedWallets } from "@moon-x/core/react";
|
|
227
|
+
// src/wallets/solana/use-fund-wallet.ts
|
|
228
|
+
var useFundWallet = function useFundWallet() {
|
|
229
|
+
var sdk = useAuthSDK();
|
|
230
|
+
var fundWallet = function fundWallet(address, options) {
|
|
231
|
+
return _async_to_generator(function() {
|
|
232
|
+
return _ts_generator(this, function(_state) {
|
|
233
|
+
if (!sdk.fundWallet) {
|
|
234
|
+
throw new Error("fundWallet method not available in SDK");
|
|
235
|
+
}
|
|
236
|
+
return [
|
|
237
|
+
2,
|
|
238
|
+
sdk.fundWallet({
|
|
239
|
+
address: address,
|
|
240
|
+
options: options
|
|
241
|
+
})
|
|
242
|
+
];
|
|
243
|
+
});
|
|
244
|
+
})();
|
|
245
|
+
};
|
|
246
|
+
return {
|
|
247
|
+
fundWallet: fundWallet
|
|
248
|
+
};
|
|
249
|
+
};
|
|
250
|
+
// src/wallets/solana.ts
|
|
251
|
+
var useCreateWallet = function useCreateWallet(callbacks) {
|
|
252
|
+
var createWallet = useSharedCreateWallet().createWallet;
|
|
253
|
+
return {
|
|
254
|
+
createWallet: function createWallet1(options) {
|
|
255
|
+
return _async_to_generator(function() {
|
|
256
|
+
var _callbacks_onSuccess, response, error, _callbacks_onError, errorObj;
|
|
257
|
+
return _ts_generator(this, function(_state) {
|
|
258
|
+
switch(_state.label){
|
|
259
|
+
case 0:
|
|
260
|
+
_state.trys.push([
|
|
261
|
+
0,
|
|
262
|
+
2,
|
|
263
|
+
,
|
|
264
|
+
3
|
|
265
|
+
]);
|
|
266
|
+
return [
|
|
267
|
+
4,
|
|
268
|
+
createWallet("solana", options)
|
|
269
|
+
];
|
|
270
|
+
case 1:
|
|
271
|
+
response = _state.sent();
|
|
272
|
+
callbacks === null || callbacks === void 0 ? void 0 : (_callbacks_onSuccess = callbacks.onSuccess) === null || _callbacks_onSuccess === void 0 ? void 0 : _callbacks_onSuccess.call(callbacks, response);
|
|
273
|
+
return [
|
|
274
|
+
2,
|
|
275
|
+
response
|
|
276
|
+
];
|
|
277
|
+
case 2:
|
|
278
|
+
error = _state.sent();
|
|
279
|
+
errorObj = _instanceof(error, Error) ? error : new Error("Unknown error");
|
|
280
|
+
callbacks === null || callbacks === void 0 ? void 0 : (_callbacks_onError = callbacks.onError) === null || _callbacks_onError === void 0 ? void 0 : _callbacks_onError.call(callbacks, errorObj);
|
|
281
|
+
throw errorObj;
|
|
282
|
+
case 3:
|
|
283
|
+
return [
|
|
284
|
+
2
|
|
285
|
+
];
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
})();
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
};
|
|
292
|
+
var useWallets = function useWallets() {
|
|
293
|
+
var _r_error;
|
|
294
|
+
var r = useSharedWallets("solana");
|
|
295
|
+
return {
|
|
296
|
+
wallets: r.wallets,
|
|
297
|
+
loading: r.loading,
|
|
298
|
+
error: (_r_error = r.error) !== null && _r_error !== void 0 ? _r_error : void 0,
|
|
299
|
+
refetch: r.refetch
|
|
300
|
+
};
|
|
301
|
+
};
|
|
302
|
+
var useSignMessage = function useSignMessage() {
|
|
303
|
+
var coreSDK = useAuthSDK();
|
|
304
|
+
var shared = useSharedSolSignMessage();
|
|
305
|
+
return {
|
|
306
|
+
signMessage: function signMessage(params) {
|
|
307
|
+
return _async_to_generator(function() {
|
|
308
|
+
var _params_options, _coreSDK_config_signMessageConfig, _coreSDK_config, showWalletUI, error;
|
|
309
|
+
return _ts_generator(this, function(_state) {
|
|
310
|
+
switch(_state.label){
|
|
311
|
+
case 0:
|
|
312
|
+
_state.trys.push([
|
|
313
|
+
0,
|
|
314
|
+
2,
|
|
315
|
+
,
|
|
316
|
+
3
|
|
317
|
+
]);
|
|
318
|
+
showWalletUI = shouldShowWalletUI((_params_options = params.options) === null || _params_options === void 0 ? void 0 : _params_options.uiOptions, (_coreSDK_config = coreSDK.config) === null || _coreSDK_config === void 0 ? void 0 : (_coreSDK_config_signMessageConfig = _coreSDK_config.signMessageConfig) === null || _coreSDK_config_signMessageConfig === void 0 ? void 0 : _coreSDK_config_signMessageConfig.uiConfig);
|
|
319
|
+
return [
|
|
320
|
+
4,
|
|
321
|
+
dispatchSignOp({
|
|
322
|
+
params: _object_spread_props(_object_spread({}, params), {
|
|
323
|
+
// Solana's iframe surface takes a string; decode the Uint8Array
|
|
324
|
+
// input on the parent side so the wire shape stays UTF-8 text.
|
|
325
|
+
message: new TextDecoder().decode(params.message)
|
|
326
|
+
}),
|
|
327
|
+
showWalletUI: showWalletUI,
|
|
328
|
+
headless: shared.signMessage,
|
|
329
|
+
withUI: coreSDK.signSolanaMessageWithUI
|
|
330
|
+
})
|
|
331
|
+
];
|
|
332
|
+
case 1:
|
|
333
|
+
return [
|
|
334
|
+
2,
|
|
335
|
+
_state.sent()
|
|
336
|
+
];
|
|
337
|
+
case 2:
|
|
338
|
+
error = _state.sent();
|
|
339
|
+
throw new Error("Sign message failed: ".concat(_instanceof(error, Error) ? error.message : "Unknown error"));
|
|
340
|
+
case 3:
|
|
341
|
+
return [
|
|
342
|
+
2
|
|
343
|
+
];
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
})();
|
|
347
|
+
},
|
|
348
|
+
loading: false,
|
|
349
|
+
error: void 0
|
|
350
|
+
};
|
|
351
|
+
};
|
|
352
|
+
var useSignTransaction = function useSignTransaction() {
|
|
353
|
+
var coreSDK = useAuthSDK();
|
|
354
|
+
var shared = useSharedSolSignTransaction();
|
|
355
|
+
return {
|
|
356
|
+
signTransaction: function signTransaction(params) {
|
|
357
|
+
return _async_to_generator(function() {
|
|
358
|
+
var _params_options, _coreSDK_config_signTransactionConfig, _coreSDK_config, _params_options1, _params_options2, _params_options3, bs58, transactionString, showWalletUI, error;
|
|
359
|
+
return _ts_generator(this, function(_state) {
|
|
360
|
+
switch(_state.label){
|
|
361
|
+
case 0:
|
|
362
|
+
_state.trys.push([
|
|
363
|
+
0,
|
|
364
|
+
3,
|
|
365
|
+
,
|
|
366
|
+
4
|
|
367
|
+
]);
|
|
368
|
+
return [
|
|
369
|
+
4,
|
|
370
|
+
import("bs58")
|
|
371
|
+
];
|
|
372
|
+
case 1:
|
|
373
|
+
bs58 = _state.sent();
|
|
374
|
+
transactionString = bs58.default.encode(params.transaction);
|
|
375
|
+
showWalletUI = shouldShowWalletUI((_params_options = params.options) === null || _params_options === void 0 ? void 0 : _params_options.uiOptions, (_coreSDK_config = coreSDK.config) === null || _coreSDK_config === void 0 ? void 0 : (_coreSDK_config_signTransactionConfig = _coreSDK_config.signTransactionConfig) === null || _coreSDK_config_signTransactionConfig === void 0 ? void 0 : _coreSDK_config_signTransactionConfig.uiConfig);
|
|
376
|
+
return [
|
|
377
|
+
4,
|
|
378
|
+
dispatchSignOp({
|
|
379
|
+
params: _object_spread_props(_object_spread({}, params), {
|
|
380
|
+
transaction: transactionString,
|
|
381
|
+
// Iframe surface needs the standard options shape; the
|
|
382
|
+
// headless path doesn't surface uiOptions but accepts a
|
|
383
|
+
// superset, so passing both is safe.
|
|
384
|
+
options: {
|
|
385
|
+
preflightCommitment: (_params_options1 = params.options) === null || _params_options1 === void 0 ? void 0 : _params_options1.preflightCommitment,
|
|
386
|
+
minContextSlot: (_params_options2 = params.options) === null || _params_options2 === void 0 ? void 0 : _params_options2.minContextSlot,
|
|
387
|
+
uiOptions: (_params_options3 = params.options) === null || _params_options3 === void 0 ? void 0 : _params_options3.uiOptions
|
|
388
|
+
}
|
|
389
|
+
}),
|
|
390
|
+
showWalletUI: showWalletUI,
|
|
391
|
+
headless: shared.signTransaction,
|
|
392
|
+
withUI: coreSDK.signSolanaTransactionWithUI
|
|
393
|
+
})
|
|
394
|
+
];
|
|
395
|
+
case 2:
|
|
396
|
+
return [
|
|
397
|
+
2,
|
|
398
|
+
_state.sent()
|
|
399
|
+
];
|
|
400
|
+
case 3:
|
|
401
|
+
error = _state.sent();
|
|
402
|
+
throw new Error("Sign transaction failed: ".concat(_instanceof(error, Error) ? error.message : "Unknown error"));
|
|
403
|
+
case 4:
|
|
404
|
+
return [
|
|
405
|
+
2
|
|
406
|
+
];
|
|
407
|
+
}
|
|
408
|
+
});
|
|
409
|
+
})();
|
|
410
|
+
},
|
|
411
|
+
loading: false,
|
|
412
|
+
error: void 0
|
|
413
|
+
};
|
|
414
|
+
};
|
|
415
|
+
var useSendTransaction = function useSendTransaction() {
|
|
416
|
+
var coreSDK = useAuthSDK();
|
|
417
|
+
var shared = useSharedSolSendTransaction();
|
|
418
|
+
return {
|
|
419
|
+
sendTransaction: function sendTransaction(params) {
|
|
420
|
+
return _async_to_generator(function() {
|
|
421
|
+
var _params_chain, _coreSDK_config_solana_rpcs, _coreSDK_config_solana, _coreSDK_config, _params_options, _coreSDK_config_sendTransactionConfig, _coreSDK_config1, chain, rpcConfig, rpcUrl, wsEndpoint, bs58, transactionString, showWalletUI, error;
|
|
422
|
+
return _ts_generator(this, function(_state) {
|
|
423
|
+
switch(_state.label){
|
|
424
|
+
case 0:
|
|
425
|
+
_state.trys.push([
|
|
426
|
+
0,
|
|
427
|
+
3,
|
|
428
|
+
,
|
|
429
|
+
4
|
|
430
|
+
]);
|
|
431
|
+
chain = (_params_chain = params.chain) !== null && _params_chain !== void 0 ? _params_chain : "solana:mainnet";
|
|
432
|
+
rpcConfig = (_coreSDK_config = coreSDK.config) === null || _coreSDK_config === void 0 ? void 0 : (_coreSDK_config_solana = _coreSDK_config.solana) === null || _coreSDK_config_solana === void 0 ? void 0 : (_coreSDK_config_solana_rpcs = _coreSDK_config_solana.rpcs) === null || _coreSDK_config_solana_rpcs === void 0 ? void 0 : _coreSDK_config_solana_rpcs[chain];
|
|
433
|
+
rpcUrl = rpcConfig === null || rpcConfig === void 0 ? void 0 : rpcConfig.rpc;
|
|
434
|
+
wsEndpoint = rpcConfig === null || rpcConfig === void 0 ? void 0 : rpcConfig.rpcSubscriptions;
|
|
435
|
+
if (!rpcUrl) {
|
|
436
|
+
throw new Error("No RPC URL configured for chain: ".concat(chain));
|
|
437
|
+
}
|
|
438
|
+
return [
|
|
439
|
+
4,
|
|
440
|
+
import("bs58")
|
|
441
|
+
];
|
|
442
|
+
case 1:
|
|
443
|
+
bs58 = _state.sent();
|
|
444
|
+
transactionString = bs58.default.encode(params.transaction);
|
|
445
|
+
showWalletUI = shouldShowWalletUI((_params_options = params.options) === null || _params_options === void 0 ? void 0 : _params_options.uiOptions, (_coreSDK_config1 = coreSDK.config) === null || _coreSDK_config1 === void 0 ? void 0 : (_coreSDK_config_sendTransactionConfig = _coreSDK_config1.sendTransactionConfig) === null || _coreSDK_config_sendTransactionConfig === void 0 ? void 0 : _coreSDK_config_sendTransactionConfig.uiConfig);
|
|
446
|
+
return [
|
|
447
|
+
4,
|
|
448
|
+
dispatchSignOp({
|
|
449
|
+
params: {
|
|
450
|
+
transaction: transactionString,
|
|
451
|
+
wallet: params.wallet,
|
|
452
|
+
rpcUrl: rpcUrl,
|
|
453
|
+
requireFreshAssertion: params.requireFreshAssertion,
|
|
454
|
+
options: _object_spread_props(_object_spread({}, params.options), {
|
|
455
|
+
wsEndpoint: wsEndpoint
|
|
456
|
+
})
|
|
457
|
+
},
|
|
458
|
+
showWalletUI: showWalletUI,
|
|
459
|
+
headless: shared.sendTransaction,
|
|
460
|
+
withUI: coreSDK.sendSolanaTransactionWithUI
|
|
461
|
+
})
|
|
462
|
+
];
|
|
463
|
+
case 2:
|
|
464
|
+
return [
|
|
465
|
+
2,
|
|
466
|
+
_state.sent()
|
|
467
|
+
];
|
|
468
|
+
case 3:
|
|
469
|
+
error = _state.sent();
|
|
470
|
+
throw new Error("Send transaction failed: ".concat(_instanceof(error, Error) ? error.message : "Unknown error"));
|
|
471
|
+
case 4:
|
|
472
|
+
return [
|
|
473
|
+
2
|
|
474
|
+
];
|
|
475
|
+
}
|
|
476
|
+
});
|
|
477
|
+
})();
|
|
478
|
+
},
|
|
479
|
+
loading: false,
|
|
480
|
+
error: void 0
|
|
481
|
+
};
|
|
482
|
+
};
|
|
483
|
+
var useGetBalance = function useGetBalance() {
|
|
484
|
+
var coreSDK = useAuthSDK();
|
|
485
|
+
var shared = useSharedSolGetBalance();
|
|
486
|
+
return {
|
|
487
|
+
getBalance: function getBalance(params) {
|
|
488
|
+
return _async_to_generator(function() {
|
|
489
|
+
var _coreSDK_config_solana_rpcs, _coreSDK_config_solana, _coreSDK_config, chain, rpcConfig, rpcUrl, wsEndpoint, error;
|
|
490
|
+
return _ts_generator(this, function(_state) {
|
|
491
|
+
switch(_state.label){
|
|
492
|
+
case 0:
|
|
493
|
+
_state.trys.push([
|
|
494
|
+
0,
|
|
495
|
+
2,
|
|
496
|
+
,
|
|
497
|
+
3
|
|
498
|
+
]);
|
|
499
|
+
chain = params.chain || "solana:mainnet";
|
|
500
|
+
rpcConfig = (_coreSDK_config = coreSDK.config) === null || _coreSDK_config === void 0 ? void 0 : (_coreSDK_config_solana = _coreSDK_config.solana) === null || _coreSDK_config_solana === void 0 ? void 0 : (_coreSDK_config_solana_rpcs = _coreSDK_config_solana.rpcs) === null || _coreSDK_config_solana_rpcs === void 0 ? void 0 : _coreSDK_config_solana_rpcs[chain];
|
|
501
|
+
rpcUrl = rpcConfig === null || rpcConfig === void 0 ? void 0 : rpcConfig.rpc;
|
|
502
|
+
wsEndpoint = rpcConfig === null || rpcConfig === void 0 ? void 0 : rpcConfig.rpcSubscriptions;
|
|
503
|
+
if (!rpcUrl) {
|
|
504
|
+
throw new Error("No RPC URL configured for chain: ".concat(params.chain));
|
|
505
|
+
}
|
|
506
|
+
return [
|
|
507
|
+
4,
|
|
508
|
+
shared.getBalance({
|
|
509
|
+
wallet: params.wallet,
|
|
510
|
+
rpcUrl: rpcUrl,
|
|
511
|
+
chain: chain,
|
|
512
|
+
options: _object_spread_props(_object_spread({}, params.options), {
|
|
513
|
+
wsEndpoint: wsEndpoint
|
|
514
|
+
})
|
|
515
|
+
})
|
|
516
|
+
];
|
|
517
|
+
case 1:
|
|
518
|
+
return [
|
|
519
|
+
2,
|
|
520
|
+
_state.sent()
|
|
521
|
+
];
|
|
522
|
+
case 2:
|
|
523
|
+
error = _state.sent();
|
|
524
|
+
throw new Error("Get balance failed: ".concat(_instanceof(error, Error) ? error.message : "Unknown error"));
|
|
525
|
+
case 3:
|
|
526
|
+
return [
|
|
527
|
+
2
|
|
528
|
+
];
|
|
529
|
+
}
|
|
530
|
+
});
|
|
531
|
+
})();
|
|
532
|
+
},
|
|
533
|
+
loading: false,
|
|
534
|
+
error: void 0
|
|
535
|
+
};
|
|
536
|
+
};
|
|
537
|
+
var useGetTokenAccounts = function useGetTokenAccounts() {
|
|
538
|
+
var coreSDK = useAuthSDK();
|
|
539
|
+
return {
|
|
540
|
+
getTokenAccounts: function getTokenAccounts(params) {
|
|
541
|
+
return _async_to_generator(function() {
|
|
542
|
+
var _coreSDK_config_solana_rpcs, _coreSDK_config_solana, _coreSDK_config, _params_options, _params_options1, _params_options2, _params_options3, chain, rpcConfig, rpcUrl, wsEndpoint, error;
|
|
543
|
+
return _ts_generator(this, function(_state) {
|
|
544
|
+
switch(_state.label){
|
|
545
|
+
case 0:
|
|
546
|
+
_state.trys.push([
|
|
547
|
+
0,
|
|
548
|
+
2,
|
|
549
|
+
,
|
|
550
|
+
3
|
|
551
|
+
]);
|
|
552
|
+
chain = params.chain || "solana:mainnet";
|
|
553
|
+
rpcConfig = (_coreSDK_config = coreSDK.config) === null || _coreSDK_config === void 0 ? void 0 : (_coreSDK_config_solana = _coreSDK_config.solana) === null || _coreSDK_config_solana === void 0 ? void 0 : (_coreSDK_config_solana_rpcs = _coreSDK_config_solana.rpcs) === null || _coreSDK_config_solana_rpcs === void 0 ? void 0 : _coreSDK_config_solana_rpcs[chain];
|
|
554
|
+
rpcUrl = rpcConfig === null || rpcConfig === void 0 ? void 0 : rpcConfig.rpc;
|
|
555
|
+
wsEndpoint = rpcConfig === null || rpcConfig === void 0 ? void 0 : rpcConfig.rpcSubscriptions;
|
|
556
|
+
if (!rpcUrl) {
|
|
557
|
+
throw new Error("No RPC URL configured for chain: ".concat(params.chain));
|
|
558
|
+
}
|
|
559
|
+
return [
|
|
560
|
+
4,
|
|
561
|
+
coreSDK.getSolanaTokenAccountsByOwner({
|
|
562
|
+
wallet: params.wallet,
|
|
563
|
+
rpcUrl: rpcUrl,
|
|
564
|
+
options: {
|
|
565
|
+
programId: params.programId,
|
|
566
|
+
mint: params.mint,
|
|
567
|
+
commitment: (_params_options = params.options) === null || _params_options === void 0 ? void 0 : _params_options.commitment,
|
|
568
|
+
minContextSlot: (_params_options1 = params.options) === null || _params_options1 === void 0 ? void 0 : _params_options1.minContextSlot,
|
|
569
|
+
dataSlice: (_params_options2 = params.options) === null || _params_options2 === void 0 ? void 0 : _params_options2.dataSlice,
|
|
570
|
+
wsEndpoint: wsEndpoint,
|
|
571
|
+
encoding: (_params_options3 = params.options) === null || _params_options3 === void 0 ? void 0 : _params_options3.encoding
|
|
572
|
+
}
|
|
573
|
+
})
|
|
574
|
+
];
|
|
575
|
+
case 1:
|
|
576
|
+
return [
|
|
577
|
+
2,
|
|
578
|
+
_state.sent()
|
|
579
|
+
];
|
|
580
|
+
case 2:
|
|
581
|
+
error = _state.sent();
|
|
582
|
+
throw new Error("Get token accounts failed: ".concat(_instanceof(error, Error) ? error.message : "Unknown error"));
|
|
583
|
+
case 3:
|
|
584
|
+
return [
|
|
585
|
+
2
|
|
586
|
+
];
|
|
587
|
+
}
|
|
588
|
+
});
|
|
589
|
+
})();
|
|
590
|
+
},
|
|
591
|
+
loading: false,
|
|
592
|
+
error: void 0
|
|
593
|
+
};
|
|
594
|
+
};
|
|
595
|
+
var useExportKey = function useExportKey() {
|
|
596
|
+
var coreSDK = useAuthSDK();
|
|
597
|
+
return {
|
|
598
|
+
exportKey: function exportKey(param) {
|
|
599
|
+
var wallet = param.wallet;
|
|
600
|
+
return _async_to_generator(function() {
|
|
601
|
+
return _ts_generator(this, function(_state) {
|
|
602
|
+
return [
|
|
603
|
+
2,
|
|
604
|
+
coreSDK.exportKey(wallet)
|
|
605
|
+
];
|
|
606
|
+
});
|
|
607
|
+
})();
|
|
608
|
+
}
|
|
609
|
+
};
|
|
610
|
+
};
|
|
611
|
+
var useImportKey = function useImportKey() {
|
|
612
|
+
var _useSharedImportKey = useSharedImportKey(), sharedImportKey = _useSharedImportKey.importKey;
|
|
613
|
+
var coreSDK = useAuthSDK();
|
|
614
|
+
return {
|
|
615
|
+
// Both modes are supported: pass `key` for headless (delegates to
|
|
616
|
+
// the shared hook), omit for UI (opens the SDK's ImportWallet modal
|
|
617
|
+
// — modal-driven path stays on coreSDK so the override in
|
|
618
|
+
// create-sdk-instance.ts can dispatch the WithUI flow).
|
|
619
|
+
//
|
|
620
|
+
// Both branches go through SDK methods that return
|
|
621
|
+
// `{ wallet: PublicWallet }` (matching the headless contract); we
|
|
622
|
+
// unwrap to `PublicWallet` here so consumer code can write
|
|
623
|
+
// `const wallet = await importKey(...)` and access
|
|
624
|
+
// `wallet.public_address` directly.
|
|
625
|
+
importKey: function importKey(params) {
|
|
626
|
+
return _async_to_generator(function() {
|
|
627
|
+
var result2, result;
|
|
628
|
+
return _ts_generator(this, function(_state) {
|
|
629
|
+
switch(_state.label){
|
|
630
|
+
case 0:
|
|
631
|
+
if (!((params === null || params === void 0 ? void 0 : params.key) !== void 0)) return [
|
|
632
|
+
3,
|
|
633
|
+
2
|
|
634
|
+
];
|
|
635
|
+
return [
|
|
636
|
+
4,
|
|
637
|
+
sharedImportKey("solana", params.key)
|
|
638
|
+
];
|
|
639
|
+
case 1:
|
|
640
|
+
result2 = _state.sent();
|
|
641
|
+
return [
|
|
642
|
+
2,
|
|
643
|
+
result2.wallet
|
|
644
|
+
];
|
|
645
|
+
case 2:
|
|
646
|
+
return [
|
|
647
|
+
4,
|
|
648
|
+
coreSDK.importKey("solana", void 0)
|
|
649
|
+
];
|
|
650
|
+
case 3:
|
|
651
|
+
result = _state.sent();
|
|
652
|
+
return [
|
|
653
|
+
2,
|
|
654
|
+
result.wallet
|
|
655
|
+
];
|
|
656
|
+
}
|
|
657
|
+
});
|
|
658
|
+
})();
|
|
659
|
+
}
|
|
660
|
+
};
|
|
661
|
+
};
|
|
662
|
+
export { useFundWallet, useCreateWallet, useWallets, useSignMessage, useSignTransaction, useSendTransaction, useGetBalance, useGetTokenAccounts, useExportKey, useImportKey, solana_exports };
|