@dynamic-labs-sdk/stellar 1.14.0 → 1.17.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/dist/StellarProvider.types.d.ts +15 -6
- package/dist/StellarProvider.types.d.ts.map +1 -1
- package/dist/addStellarExtension/addStellarExtension.d.ts +11 -0
- package/dist/addStellarExtension/addStellarExtension.d.ts.map +1 -0
- package/dist/addStellarExtension/index.d.ts +2 -0
- package/dist/addStellarExtension/index.d.ts.map +1 -0
- package/dist/errors/NotOneKeyProviderError/NotOneKeyProviderError.d.ts +5 -0
- package/dist/errors/NotOneKeyProviderError/NotOneKeyProviderError.d.ts.map +1 -0
- package/dist/errors/NotOneKeyProviderError/index.d.ts +2 -0
- package/dist/errors/NotOneKeyProviderError/index.d.ts.map +1 -0
- package/dist/exports/index.d.ts +2 -0
- package/dist/exports/index.d.ts.map +1 -1
- package/dist/index.cjs +724 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +724 -3
- package/dist/index.esm.js.map +1 -1
- package/dist/injected/addStellarInjectedWalletsExtension/addStellarInjectedWalletsExtension.d.ts +16 -0
- package/dist/injected/addStellarInjectedWalletsExtension/addStellarInjectedWalletsExtension.d.ts.map +1 -0
- package/dist/injected/addStellarInjectedWalletsExtension/index.d.ts +2 -0
- package/dist/injected/addStellarInjectedWalletsExtension/index.d.ts.map +1 -0
- package/dist/injected/utils/createFreighterProvider/createFreighterProvider.d.ts +9 -0
- package/dist/injected/utils/createFreighterProvider/createFreighterProvider.d.ts.map +1 -0
- package/dist/injected/utils/createFreighterProvider/index.d.ts +2 -0
- package/dist/injected/utils/createFreighterProvider/index.d.ts.map +1 -0
- package/dist/injected/utils/createLobstrProvider/createLobstrProvider.d.ts +9 -0
- package/dist/injected/utils/createLobstrProvider/createLobstrProvider.d.ts.map +1 -0
- package/dist/injected/utils/createLobstrProvider/index.d.ts +2 -0
- package/dist/injected/utils/createLobstrProvider/index.d.ts.map +1 -0
- package/dist/injected/utils/createOneKeyProvider/createOneKeyProvider.d.ts +9 -0
- package/dist/injected/utils/createOneKeyProvider/createOneKeyProvider.d.ts.map +1 -0
- package/dist/injected/utils/createOneKeyProvider/index.d.ts +2 -0
- package/dist/injected/utils/createOneKeyProvider/index.d.ts.map +1 -0
- package/dist/injected/utils/createWalletProviderFromStellarProvider/createWalletProviderFromStellarProvider.d.ts +23 -0
- package/dist/injected/utils/createWalletProviderFromStellarProvider/createWalletProviderFromStellarProvider.d.ts.map +1 -0
- package/dist/injected/utils/createWalletProviderFromStellarProvider/index.d.ts +2 -0
- package/dist/injected/utils/createWalletProviderFromStellarProvider/index.d.ts.map +1 -0
- package/dist/injected/utils/getOneKeyStellarProvider/getOneKeyStellarProvider.d.ts +37 -0
- package/dist/injected/utils/getOneKeyStellarProvider/getOneKeyStellarProvider.d.ts.map +1 -0
- package/dist/injected/utils/getOneKeyStellarProvider/index.d.ts +2 -0
- package/dist/injected/utils/getOneKeyStellarProvider/index.d.ts.map +1 -0
- package/dist/registerStellarNetworkProviderBuilder/index.d.ts +2 -0
- package/dist/registerStellarNetworkProviderBuilder/index.d.ts.map +1 -0
- package/dist/registerStellarNetworkProviderBuilder/registerStellarNetworkProviderBuilder.d.ts +9 -0
- package/dist/registerStellarNetworkProviderBuilder/registerStellarNetworkProviderBuilder.d.ts.map +1 -0
- package/dist/signTransaction/index.d.ts +2 -0
- package/dist/signTransaction/index.d.ts.map +1 -0
- package/dist/signTransaction/signTransaction.d.ts +19 -0
- package/dist/signTransaction/signTransaction.d.ts.map +1 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/utils/buildPaymentTransaction/buildPaymentTransaction.d.ts +22 -0
- package/dist/utils/buildPaymentTransaction/buildPaymentTransaction.d.ts.map +1 -0
- package/dist/utils/buildPaymentTransaction/index.d.ts +2 -0
- package/dist/utils/buildPaymentTransaction/index.d.ts.map +1 -0
- package/dist/utils/checkTrustline/checkTrustline.d.ts +17 -0
- package/dist/utils/checkTrustline/checkTrustline.d.ts.map +1 -0
- package/dist/utils/checkTrustline/index.d.ts +2 -0
- package/dist/utils/checkTrustline/index.d.ts.map +1 -0
- package/dist/utils/constants.d.ts +12 -0
- package/dist/utils/constants.d.ts.map +1 -1
- package/dist/utils/createPaymentAsset/createPaymentAsset.d.ts +15 -0
- package/dist/utils/createPaymentAsset/createPaymentAsset.d.ts.map +1 -0
- package/dist/utils/createPaymentAsset/index.d.ts +2 -0
- package/dist/utils/createPaymentAsset/index.d.ts.map +1 -0
- package/dist/utils/getNetworkPassphrase/getNetworkPassphrase.d.ts +7 -5
- package/dist/utils/getNetworkPassphrase/getNetworkPassphrase.d.ts.map +1 -1
- package/dist/utils/getStellarNetworkId/getStellarNetworkId.d.ts +22 -0
- package/dist/utils/getStellarNetworkId/getStellarNetworkId.d.ts.map +1 -0
- package/dist/utils/getStellarNetworkId/index.d.ts +2 -0
- package/dist/utils/getStellarNetworkId/index.d.ts.map +1 -0
- package/dist/utils/stellarTransferAmount/index.d.ts +2 -0
- package/dist/utils/stellarTransferAmount/index.d.ts.map +1 -0
- package/dist/utils/stellarTransferAmount/stellarTransferAmount.d.ts +22 -0
- package/dist/utils/stellarTransferAmount/stellarTransferAmount.d.ts.map +1 -0
- package/package.json +4 -4
package/dist/index.esm.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { assertPackageVersion } from "@dynamic-labs-sdk/assert-package-version";
|
|
2
|
-
import { BaseError } from "@dynamic-labs-sdk/client";
|
|
2
|
+
import { BaseError, InvalidParamError, assertWalletAccountSigningAvailability, getActiveNetworkData, getDefaultClient } from "@dynamic-labs-sdk/client";
|
|
3
|
+
import { WalletProviderPriority, assertDefined, createBaseNetworkProvider, createWalletProviderEventEmitter, formatWalletProviderGroupKey, formatWalletProviderKey, getBuffer, getCore, getDefaultClient as getDefaultClient$1, getNetworkProviderBuilderRegistry, getWalletProviderFromWalletAccount, getWalletProviderRegistry, hasExtension, registerExtension } from "@dynamic-labs-sdk/client/core";
|
|
4
|
+
import { WatchWalletChanges, getNetwork, isConnected, requestAccess, signMessage, signTransaction as signTransaction$1 } from "@stellar/freighter-api";
|
|
5
|
+
import { getPublicKey, isConnected as isConnected$1, signMessage as signMessage$1, signTransaction as signTransaction$2 } from "@lobstrco/signer-extension-api";
|
|
6
|
+
import { Asset, BASE_FEE, Horizon, Operation, TransactionBuilder, hash } from "@stellar/stellar-sdk";
|
|
7
|
+
import { WalletProviderEnum } from "@dynamic-labs/sdk-api-core";
|
|
3
8
|
|
|
4
9
|
//#region package.json
|
|
5
10
|
var name = "@dynamic-labs-sdk/stellar";
|
|
6
|
-
var version = "1.
|
|
11
|
+
var version = "1.17.0";
|
|
7
12
|
|
|
8
13
|
//#endregion
|
|
9
14
|
//#region src/errors/NotStellarProviderError/NotStellarProviderError.ts
|
|
@@ -34,10 +39,726 @@ const isStellarWalletAccount = (walletAccount) => {
|
|
|
34
39
|
return walletAccount.chain === "STELLAR";
|
|
35
40
|
};
|
|
36
41
|
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/errors/FetchStellarBalanceError/FetchStellarBalanceError.ts
|
|
44
|
+
var FetchStellarBalanceError = class extends BaseError {
|
|
45
|
+
address;
|
|
46
|
+
constructor(params) {
|
|
47
|
+
super({
|
|
48
|
+
cause: params.cause ?? null,
|
|
49
|
+
code: "fetch_stellar_balance_error",
|
|
50
|
+
docsUrl: null,
|
|
51
|
+
name: "FetchStellarBalanceError",
|
|
52
|
+
shortMessage: `Failed to fetch Stellar balance for address ${params.address}`
|
|
53
|
+
});
|
|
54
|
+
this.address = params.address;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/utils/fetchStellarBalance/fetchStellarBalance.ts
|
|
60
|
+
/**
|
|
61
|
+
* Fetches the native XLM balance for an address from Horizon.
|
|
62
|
+
* Returns '0' when the account has no native balance, and throws a
|
|
63
|
+
* FetchStellarBalanceError when the balance cannot be retrieved.
|
|
64
|
+
*
|
|
65
|
+
* @param address - The Stellar public key.
|
|
66
|
+
* @param networkData - Network data carrying the Horizon RPC URL.
|
|
67
|
+
* @notInstrumented
|
|
68
|
+
*/
|
|
69
|
+
const fetchStellarBalance = async ({ address, networkData }) => {
|
|
70
|
+
const server = new Horizon.Server(networkData.rpcUrls.http[0]);
|
|
71
|
+
try {
|
|
72
|
+
const nativeBalance = (await server.loadAccount(address)).balances.find((balance) => balance.asset_type === "native");
|
|
73
|
+
if (!nativeBalance || !("balance" in nativeBalance)) return "0";
|
|
74
|
+
return Number(nativeBalance.balance).toString();
|
|
75
|
+
} catch (error) {
|
|
76
|
+
throw new FetchStellarBalanceError({
|
|
77
|
+
address,
|
|
78
|
+
cause: error instanceof Error ? error : null
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
//#endregion
|
|
84
|
+
//#region src/utils/createStellarNetworkProvider/createStellarNetworkProvider.ts
|
|
85
|
+
/**
|
|
86
|
+
* Creates a Stellar network provider from network data.
|
|
87
|
+
*
|
|
88
|
+
* @param networkData - The network data for the Stellar network.
|
|
89
|
+
* @notInstrumented
|
|
90
|
+
*/
|
|
91
|
+
const createStellarNetworkProvider = (networkData) => ({
|
|
92
|
+
...createBaseNetworkProvider("STELLAR", networkData),
|
|
93
|
+
cluster: networkData.cluster,
|
|
94
|
+
getBalance: async ({ address }) => ({ balance: await fetchStellarBalance({
|
|
95
|
+
address,
|
|
96
|
+
networkData
|
|
97
|
+
}) })
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region src/registerStellarNetworkProviderBuilder/registerStellarNetworkProviderBuilder.ts
|
|
102
|
+
/**
|
|
103
|
+
* Registers the Stellar network provider builder on the client (idempotent).
|
|
104
|
+
*
|
|
105
|
+
* @param client - The Dynamic client instance.
|
|
106
|
+
* @notInstrumented
|
|
107
|
+
*/
|
|
108
|
+
const registerStellarNetworkProviderBuilder = (client) => {
|
|
109
|
+
const networkProviderBuilderRegistry = getNetworkProviderBuilderRegistry(client);
|
|
110
|
+
if (networkProviderBuilderRegistry.get().get("STELLAR")) return;
|
|
111
|
+
networkProviderBuilderRegistry.register({
|
|
112
|
+
builder: createStellarNetworkProvider,
|
|
113
|
+
chain: "STELLAR"
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
//#endregion
|
|
118
|
+
//#region src/injected/utils/createFreighterProvider/createFreighterProvider.ts
|
|
119
|
+
/**
|
|
120
|
+
* Freighter Wallet provider adapter that implements IStellarProvider
|
|
121
|
+
* using the Freighter API.
|
|
122
|
+
*
|
|
123
|
+
* @notInstrumented
|
|
124
|
+
*/
|
|
125
|
+
const createFreighterProvider = () => {
|
|
126
|
+
let watcher;
|
|
127
|
+
const eventCallbacks = /* @__PURE__ */ new Map();
|
|
128
|
+
let isWatcherStarted = false;
|
|
129
|
+
const startWatcher = () => {
|
|
130
|
+
if (isWatcherStarted) return;
|
|
131
|
+
if (!watcher) watcher = new WatchWalletChanges();
|
|
132
|
+
watcher.watch((params) => {
|
|
133
|
+
const accountChangedCallbacks = eventCallbacks.get("accountChanged");
|
|
134
|
+
const networkChangedCallbacks = eventCallbacks.get("networkChanged");
|
|
135
|
+
if (accountChangedCallbacks && params.address !== void 0) accountChangedCallbacks.forEach((callback) => {
|
|
136
|
+
callback(params.address);
|
|
137
|
+
});
|
|
138
|
+
if (networkChangedCallbacks && params.network !== void 0) networkChangedCallbacks.forEach((callback) => {
|
|
139
|
+
callback(params.network);
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
isWatcherStarted = true;
|
|
143
|
+
};
|
|
144
|
+
return {
|
|
145
|
+
close: () => {
|
|
146
|
+
watcher?.stop();
|
|
147
|
+
watcher = void 0;
|
|
148
|
+
eventCallbacks.clear();
|
|
149
|
+
isWatcherStarted = false;
|
|
150
|
+
},
|
|
151
|
+
connect: async () => {
|
|
152
|
+
return (await requestAccess()).address ?? "";
|
|
153
|
+
},
|
|
154
|
+
disconnect: async () => void 0,
|
|
155
|
+
getNetwork: async () => {
|
|
156
|
+
return (await getNetwork()).network ?? "PUBLIC";
|
|
157
|
+
},
|
|
158
|
+
isUnlocked: async () => {
|
|
159
|
+
return (await isConnected()).isConnected ?? false;
|
|
160
|
+
},
|
|
161
|
+
on: ({ event, callback }) => {
|
|
162
|
+
if (!eventCallbacks.has(event)) eventCallbacks.set(event, /* @__PURE__ */ new Set());
|
|
163
|
+
eventCallbacks.get(event).add(callback);
|
|
164
|
+
startWatcher();
|
|
165
|
+
},
|
|
166
|
+
sign: async ({ transactionXdr, options }) => {
|
|
167
|
+
return (await signTransaction$1(transactionXdr, { networkPassphrase: options?.networkPassphrase })).signedTxXdr ?? "";
|
|
168
|
+
},
|
|
169
|
+
signMessage: async ({ message }) => {
|
|
170
|
+
const response = await signMessage(message);
|
|
171
|
+
return String(response.signedMessage ?? "");
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region src/injected/utils/createLobstrProvider/createLobstrProvider.ts
|
|
178
|
+
/**
|
|
179
|
+
* Lobstr Wallet provider adapter that implements IStellarProvider
|
|
180
|
+
* using the Lobstr signer extension API.
|
|
181
|
+
*
|
|
182
|
+
* @notInstrumented
|
|
183
|
+
*/
|
|
184
|
+
const createLobstrProvider = () => ({
|
|
185
|
+
connect: async () => {
|
|
186
|
+
return await getPublicKey() ?? "";
|
|
187
|
+
},
|
|
188
|
+
getNetwork: async () => "PUBLIC",
|
|
189
|
+
isUnlocked: async () => isConnected$1(),
|
|
190
|
+
sign: async ({ transactionXdr }) => {
|
|
191
|
+
return await signTransaction$2(transactionXdr);
|
|
192
|
+
},
|
|
193
|
+
signMessage: async ({ message }) => {
|
|
194
|
+
return (await signMessage$1(message))?.signedMessage ?? "";
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
//#endregion
|
|
199
|
+
//#region src/errors/NotOneKeyProviderError/NotOneKeyProviderError.ts
|
|
200
|
+
var NotOneKeyProviderError = class extends BaseError {
|
|
201
|
+
constructor() {
|
|
202
|
+
super({
|
|
203
|
+
cause: null,
|
|
204
|
+
code: "not_onekey_provider_error",
|
|
205
|
+
docsUrl: null,
|
|
206
|
+
name: "NotOneKeyProviderError",
|
|
207
|
+
shortMessage: "OneKey Stellar provider not found"
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
//#endregion
|
|
213
|
+
//#region src/utils/normalizeNetworkName/normalizeNetworkName.ts
|
|
214
|
+
/**
|
|
215
|
+
* Normalize network name to standard format
|
|
216
|
+
*
|
|
217
|
+
* @param network - Raw network name from wallet
|
|
218
|
+
* @returns Normalized network name (PUBLIC, TESTNET, or FUTURENET)
|
|
219
|
+
*
|
|
220
|
+
* @example
|
|
221
|
+
* ```typescript
|
|
222
|
+
* normalizeNetworkName({ network: 'mainnet' }) // 'PUBLIC'
|
|
223
|
+
* normalizeNetworkName({ network: 'testnet' }) // 'TESTNET'
|
|
224
|
+
* normalizeNetworkName({ network: 'Test SDF Network ; September 2015' }) // 'TESTNET'
|
|
225
|
+
* ```
|
|
226
|
+
* @notInstrumented
|
|
227
|
+
*/
|
|
228
|
+
const normalizeNetworkName = ({ network }) => {
|
|
229
|
+
const networkUpper = network.toUpperCase();
|
|
230
|
+
if (networkUpper.includes("FUTURENET") || networkUpper.includes("FUTURE")) return "FUTURENET";
|
|
231
|
+
if (networkUpper.includes("TESTNET") || networkUpper.includes("TEST SDF")) return "TESTNET";
|
|
232
|
+
if (networkUpper.includes("PUBLIC") || networkUpper.includes("MAINNET")) return "PUBLIC";
|
|
233
|
+
return "PUBLIC";
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
//#endregion
|
|
237
|
+
//#region src/injected/utils/getOneKeyStellarProvider/getOneKeyStellarProvider.ts
|
|
238
|
+
/**
|
|
239
|
+
* Methods the injected OneKey Stellar object must expose to be trusted.
|
|
240
|
+
* `signAuthEntry` is intentionally excluded because it is optional.
|
|
241
|
+
*/
|
|
242
|
+
const REQUIRED_ONEKEY_METHODS = [
|
|
243
|
+
"disconnect",
|
|
244
|
+
"getAddress",
|
|
245
|
+
"getNetwork",
|
|
246
|
+
"on",
|
|
247
|
+
"removeListener",
|
|
248
|
+
"signMessage",
|
|
249
|
+
"signTransaction"
|
|
250
|
+
];
|
|
251
|
+
/**
|
|
252
|
+
* Gets the OneKey Stellar provider from the window object.
|
|
253
|
+
*
|
|
254
|
+
* The injected `$onekey.stellar` object comes from an untrusted browser global
|
|
255
|
+
* (any extension or script could inject a fake one), so its shape is validated
|
|
256
|
+
* before use: every required method must be a function. Anything that does not
|
|
257
|
+
* conform is rejected rather than trusted.
|
|
258
|
+
*
|
|
259
|
+
* @returns The OneKey Stellar provider, or undefined if it is unavailable or malformed.
|
|
260
|
+
* @notInstrumented
|
|
261
|
+
*/
|
|
262
|
+
const getOneKeyStellarProvider = () => {
|
|
263
|
+
if (typeof globalThis.window === "undefined") return;
|
|
264
|
+
const stellar = globalThis.window.$onekey?.stellar;
|
|
265
|
+
if (!stellar) return;
|
|
266
|
+
if (!REQUIRED_ONEKEY_METHODS.every((method) => typeof stellar[method] === "function")) return;
|
|
267
|
+
return stellar;
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
//#endregion
|
|
271
|
+
//#region src/injected/utils/createOneKeyProvider/createOneKeyProvider.ts
|
|
272
|
+
/**
|
|
273
|
+
* OneKey Wallet provider adapter that implements IStellarProvider
|
|
274
|
+
* using the OneKey Stellar API.
|
|
275
|
+
*
|
|
276
|
+
* @notInstrumented
|
|
277
|
+
*/
|
|
278
|
+
const createOneKeyProvider = () => {
|
|
279
|
+
const oneKeyProvider = getOneKeyStellarProvider();
|
|
280
|
+
if (!oneKeyProvider) throw new NotOneKeyProviderError();
|
|
281
|
+
const eventListeners = /* @__PURE__ */ new Map();
|
|
282
|
+
const wrappedCallbacks = /* @__PURE__ */ new Map();
|
|
283
|
+
const oneKeyEventMap = {
|
|
284
|
+
accountChanged: "accountChanged",
|
|
285
|
+
networkChanged: "networkChanged"
|
|
286
|
+
};
|
|
287
|
+
return {
|
|
288
|
+
close: () => {
|
|
289
|
+
eventListeners.forEach((callbacks, event) => {
|
|
290
|
+
const oneKeyEvent = oneKeyEventMap[event];
|
|
291
|
+
callbacks.forEach((callback) => {
|
|
292
|
+
const wrappedCallback = wrappedCallbacks.get(event)?.get(callback);
|
|
293
|
+
if (wrappedCallback) oneKeyProvider.removeListener(oneKeyEvent, wrappedCallback);
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
eventListeners.clear();
|
|
297
|
+
wrappedCallbacks.clear();
|
|
298
|
+
},
|
|
299
|
+
connect: async () => {
|
|
300
|
+
return (await oneKeyProvider.getAddress())?.address ?? "";
|
|
301
|
+
},
|
|
302
|
+
disconnect: async () => {
|
|
303
|
+
oneKeyProvider.disconnect();
|
|
304
|
+
},
|
|
305
|
+
getNetwork: async () => {
|
|
306
|
+
return normalizeNetworkName({ network: await oneKeyProvider.getNetwork() });
|
|
307
|
+
},
|
|
308
|
+
isUnlocked: async () => {
|
|
309
|
+
try {
|
|
310
|
+
await oneKeyProvider.getAddress();
|
|
311
|
+
return true;
|
|
312
|
+
} catch {
|
|
313
|
+
return false;
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
on: ({ event, callback }) => {
|
|
317
|
+
if (!eventListeners.has(event)) eventListeners.set(event, /* @__PURE__ */ new Set());
|
|
318
|
+
const callbacks = eventListeners.get(event);
|
|
319
|
+
if (callbacks?.has(callback)) return;
|
|
320
|
+
callbacks?.add(callback);
|
|
321
|
+
const oneKeyEvent = oneKeyEventMap[event];
|
|
322
|
+
const wrappedCallback = (...args) => {
|
|
323
|
+
callback(args[0]);
|
|
324
|
+
};
|
|
325
|
+
if (!wrappedCallbacks.has(event)) wrappedCallbacks.set(event, /* @__PURE__ */ new Map());
|
|
326
|
+
wrappedCallbacks.get(event)?.set(callback, wrappedCallback);
|
|
327
|
+
oneKeyProvider.on(oneKeyEvent, wrappedCallback);
|
|
328
|
+
},
|
|
329
|
+
sign: async ({ transactionXdr, options }) => {
|
|
330
|
+
return await oneKeyProvider.signTransaction(transactionXdr, {
|
|
331
|
+
network: options?.network,
|
|
332
|
+
networkPassphrase: options?.networkPassphrase
|
|
333
|
+
}) ?? "";
|
|
334
|
+
},
|
|
335
|
+
signMessage: async ({ message }) => {
|
|
336
|
+
const signature = await oneKeyProvider.signMessage(message);
|
|
337
|
+
return String(signature?.signedMessage ?? "");
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
//#endregion
|
|
343
|
+
//#region src/utils/constants.ts
|
|
344
|
+
/**
|
|
345
|
+
* Stellar network passphrase for mainnet
|
|
346
|
+
*/
|
|
347
|
+
const STELLAR_PUBLIC_NETWORK_PASSPHRASE = "Public Global Stellar Network ; September 2015";
|
|
348
|
+
/**
|
|
349
|
+
* Stellar network passphrase for testnet
|
|
350
|
+
*/
|
|
351
|
+
const STELLAR_TESTNET_NETWORK_PASSPHRASE = "Test SDF Network ; September 2015";
|
|
352
|
+
/**
|
|
353
|
+
* Stellar network passphrase for futurenet
|
|
354
|
+
*/
|
|
355
|
+
const STELLAR_FUTURENET_NETWORK_PASSPHRASE = "Test SDF Future Network ; October 2022";
|
|
356
|
+
/**
|
|
357
|
+
* Network passphrase keyed by Stellar network name. The SDK's network
|
|
358
|
+
* identifier (chain ID) is the SHA-256 hash of these passphrases.
|
|
359
|
+
*/
|
|
360
|
+
const STELLAR_PASSPHRASE_BY_NAME = {
|
|
361
|
+
FUTURENET: STELLAR_FUTURENET_NETWORK_PASSPHRASE,
|
|
362
|
+
PUBLIC: STELLAR_PUBLIC_NETWORK_PASSPHRASE,
|
|
363
|
+
TESTNET: STELLAR_TESTNET_NETWORK_PASSPHRASE
|
|
364
|
+
};
|
|
365
|
+
/**
|
|
366
|
+
* Public Horizon server URL keyed by Stellar network name. Transaction
|
|
367
|
+
* submission must target a write-capable Horizon server (not an arbitrary RPC
|
|
368
|
+
* URL, which returns 405 on POST /transactions).
|
|
369
|
+
*/
|
|
370
|
+
const STELLAR_HORIZON_URL_BY_NAME = {
|
|
371
|
+
FUTURENET: "https://horizon-futurenet.stellar.org",
|
|
372
|
+
PUBLIC: "https://horizon.stellar.org",
|
|
373
|
+
TESTNET: "https://horizon-testnet.stellar.org"
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
//#endregion
|
|
377
|
+
//#region src/utils/getStellarNetworkId/getStellarNetworkId.ts
|
|
378
|
+
/**
|
|
379
|
+
* Maps a wallet-reported Stellar network (name or passphrase) to its Dynamic
|
|
380
|
+
* network identifier: the hex-encoded SHA-256 hash of the network passphrase
|
|
381
|
+
* (Stellar's canonical Network ID), which is how the backend identifies the
|
|
382
|
+
* network.
|
|
383
|
+
*
|
|
384
|
+
* @param network - Raw network value reported by the wallet.
|
|
385
|
+
* @returns The hex SHA-256 hash of the network passphrase.
|
|
386
|
+
*
|
|
387
|
+
* @example
|
|
388
|
+
* ```typescript
|
|
389
|
+
* // pubnet -> 7ac33997544e3175d266bd022439b22cdb16508c01163f26e5cb2a3e1045a979
|
|
390
|
+
* getStellarNetworkId({ network: 'PUBLIC' });
|
|
391
|
+
* ```
|
|
392
|
+
* @notInstrumented
|
|
393
|
+
*/
|
|
394
|
+
const getStellarNetworkId = ({ network }) => {
|
|
395
|
+
const passphrase = STELLAR_PASSPHRASE_BY_NAME[normalizeNetworkName({ network })];
|
|
396
|
+
return hash(getBuffer().from(passphrase)).toString("hex");
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
//#endregion
|
|
400
|
+
//#region src/utils/getNetworkPassphrase/getNetworkPassphrase.ts
|
|
401
|
+
/**
|
|
402
|
+
* Gets the network passphrase for a given Dynamic Stellar network id (the
|
|
403
|
+
* SHA-256 hash of a network passphrase). Defaults to the public network when
|
|
404
|
+
* the id is unknown.
|
|
405
|
+
*
|
|
406
|
+
* @param networkId - The network id (hex SHA-256 hash of the passphrase).
|
|
407
|
+
* @returns The matching network passphrase.
|
|
408
|
+
* @notInstrumented
|
|
409
|
+
*/
|
|
410
|
+
const getNetworkPassphrase = ({ networkId }) => Object.values(STELLAR_PASSPHRASE_BY_NAME).find((passphrase) => getStellarNetworkId({ network: passphrase }) === networkId) ?? STELLAR_PUBLIC_NETWORK_PASSPHRASE;
|
|
411
|
+
|
|
412
|
+
//#endregion
|
|
413
|
+
//#region src/isStellarWalletProvider/isStellarWalletProvider.ts
|
|
414
|
+
/**
|
|
415
|
+
* Type guard to check if a wallet provider is a Stellar wallet provider.
|
|
416
|
+
*
|
|
417
|
+
* @param provider - The wallet provider to check.
|
|
418
|
+
* @returns True if the wallet provider is a Stellar wallet provider.
|
|
419
|
+
* @notInstrumented
|
|
420
|
+
*/
|
|
421
|
+
const isStellarWalletProvider = (provider) => {
|
|
422
|
+
return provider.chain === "STELLAR";
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
//#endregion
|
|
426
|
+
//#region src/signTransaction/signTransaction.ts
|
|
427
|
+
/**
|
|
428
|
+
* Signs a Stellar transaction
|
|
429
|
+
* @param params.transactionXdr - The transaction XDR to sign
|
|
430
|
+
* @param params.walletAccount - The wallet account to sign the transaction with
|
|
431
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
432
|
+
*
|
|
433
|
+
* @returns An object containing the signed XDR
|
|
434
|
+
* @notInstrumented
|
|
435
|
+
*/
|
|
436
|
+
const signTransaction = async ({ transactionXdr, walletAccount }, client = getDefaultClient()) => {
|
|
437
|
+
const provider = getWalletProviderFromWalletAccount({ walletAccount }, client);
|
|
438
|
+
if (!isStellarWalletProvider(provider)) throw new NotStellarProviderError({ providerKey: provider.key });
|
|
439
|
+
return provider.signTransaction({
|
|
440
|
+
transactionXdr,
|
|
441
|
+
walletAccount
|
|
442
|
+
});
|
|
443
|
+
};
|
|
444
|
+
|
|
445
|
+
//#endregion
|
|
446
|
+
//#region src/utils/buildPaymentTransaction/buildPaymentTransaction.ts
|
|
447
|
+
const DEFAULT_TIMEOUT_SECONDS = 180;
|
|
448
|
+
/**
|
|
449
|
+
* Builds a Stellar payment transaction sending `amount` of `asset` from the
|
|
450
|
+
* source account to the recipient.
|
|
451
|
+
*
|
|
452
|
+
* @param amount - Amount to send, as a decimal string in the asset's units.
|
|
453
|
+
* @param asset - The asset to send (native or custom).
|
|
454
|
+
* @param networkPassphrase - The network passphrase to sign against.
|
|
455
|
+
* @param recipient - The destination account address.
|
|
456
|
+
* @param sourceAccount - The sender's account loaded from Horizon.
|
|
457
|
+
* @notInstrumented
|
|
458
|
+
*/
|
|
459
|
+
const buildPaymentTransaction = ({ amount, asset, networkPassphrase, recipient, sourceAccount }) => new TransactionBuilder(sourceAccount, {
|
|
460
|
+
fee: BASE_FEE,
|
|
461
|
+
networkPassphrase
|
|
462
|
+
}).addOperation(Operation.payment({
|
|
463
|
+
amount,
|
|
464
|
+
asset,
|
|
465
|
+
destination: recipient
|
|
466
|
+
})).setTimeout(DEFAULT_TIMEOUT_SECONDS).build();
|
|
467
|
+
|
|
468
|
+
//#endregion
|
|
469
|
+
//#region src/utils/checkTrustline/checkTrustline.ts
|
|
470
|
+
/**
|
|
471
|
+
* Returns whether an account can receive the given asset. The native asset
|
|
472
|
+
* (XLM) never needs a trustline; non-native assets require a matching
|
|
473
|
+
* credit balance (trustline) on the account.
|
|
474
|
+
*
|
|
475
|
+
* @param account - The destination account loaded from Horizon.
|
|
476
|
+
* @param asset - The asset being sent.
|
|
477
|
+
* @notInstrumented
|
|
478
|
+
*/
|
|
479
|
+
const checkTrustline = ({ account, asset }) => {
|
|
480
|
+
if (asset.isNative()) return true;
|
|
481
|
+
const assetCode = asset.getCode();
|
|
482
|
+
const assetIssuer = asset.getIssuer();
|
|
483
|
+
return account.balances.some((balance) => (balance.asset_type === "credit_alphanum4" || balance.asset_type === "credit_alphanum12") && balance.asset_code === assetCode && balance.asset_issuer === assetIssuer);
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
//#endregion
|
|
487
|
+
//#region src/utils/createPaymentAsset/createPaymentAsset.ts
|
|
488
|
+
/**
|
|
489
|
+
* Creates a Stellar Asset for a payment operation. Returns the native asset
|
|
490
|
+
* (XLM) when no code/issuer is provided, otherwise a custom asset.
|
|
491
|
+
*
|
|
492
|
+
* @param asset - Optional `{ code, issuer }` for a non-native asset.
|
|
493
|
+
* @notInstrumented
|
|
494
|
+
*/
|
|
495
|
+
const createPaymentAsset = (asset) => asset ? new Asset(asset.code, asset.issuer) : Asset.native();
|
|
496
|
+
|
|
497
|
+
//#endregion
|
|
498
|
+
//#region src/utils/stellarTransferAmount/stellarTransferAmount.ts
|
|
499
|
+
/**
|
|
500
|
+
* Transfers native XLM or a custom Stellar asset from a wallet account.
|
|
501
|
+
*
|
|
502
|
+
* A custom asset is identified by `token.address` in the form `CODE:ISSUER`
|
|
503
|
+
* (or `CODE-ISSUER`). Amounts are decimal strings in the asset's display
|
|
504
|
+
* units. The destination account must exist, and for non-native assets it must
|
|
505
|
+
* already hold a trustline for the asset.
|
|
506
|
+
*
|
|
507
|
+
* @param amount - Amount to send, as a decimal string (e.g. "1.5").
|
|
508
|
+
* @param recipient - Destination Stellar account address.
|
|
509
|
+
* @param token - Optional non-native asset (`address: "CODE:ISSUER"`).
|
|
510
|
+
* @param walletAccount - The Stellar wallet account to send from.
|
|
511
|
+
* @param client - The Dynamic client instance.
|
|
512
|
+
* @returns The submitted transaction hash.
|
|
513
|
+
* @notInstrumented
|
|
514
|
+
*/
|
|
515
|
+
const stellarTransferAmount = async ({ amount, recipient, token, walletAccount }, client) => {
|
|
516
|
+
if (!isStellarWalletAccount(walletAccount)) throw new InvalidParamError("Wallet account is not a Stellar wallet account");
|
|
517
|
+
const { networkData } = await getActiveNetworkData({ walletAccount }, client);
|
|
518
|
+
assertDefined(networkData, "No active network data found");
|
|
519
|
+
const networkPassphrase = getNetworkPassphrase({ networkId: networkData.networkId });
|
|
520
|
+
const horizonUrl = STELLAR_HORIZON_URL_BY_NAME[normalizeNetworkName({ network: networkPassphrase })];
|
|
521
|
+
const server = new Horizon.Server(horizonUrl);
|
|
522
|
+
let asset;
|
|
523
|
+
if (token?.address) {
|
|
524
|
+
const [code, issuer] = token.address.split(/[:-]/);
|
|
525
|
+
if (!code || !issuer) throw new InvalidParamError("Invalid token address. Expected \"CODE:ISSUER\" (e.g. \"USDC:GA5Z...\").");
|
|
526
|
+
asset = createPaymentAsset({
|
|
527
|
+
code,
|
|
528
|
+
issuer
|
|
529
|
+
});
|
|
530
|
+
} else asset = createPaymentAsset();
|
|
531
|
+
const sourceAccount = await server.loadAccount(walletAccount.address);
|
|
532
|
+
let destinationAccount;
|
|
533
|
+
try {
|
|
534
|
+
destinationAccount = await server.loadAccount(recipient);
|
|
535
|
+
} catch {
|
|
536
|
+
throw new InvalidParamError(`Destination account ${recipient} does not exist or is not funded.`);
|
|
537
|
+
}
|
|
538
|
+
if (!asset.isNative() && !checkTrustline({
|
|
539
|
+
account: destinationAccount,
|
|
540
|
+
asset
|
|
541
|
+
})) throw new InvalidParamError(`Destination ${recipient} has no trustline for ${asset.getCode()}:${asset.getIssuer()}.`);
|
|
542
|
+
const { signedXdr } = await signTransaction({
|
|
543
|
+
transactionXdr: buildPaymentTransaction({
|
|
544
|
+
amount,
|
|
545
|
+
asset,
|
|
546
|
+
networkPassphrase,
|
|
547
|
+
recipient,
|
|
548
|
+
sourceAccount
|
|
549
|
+
}).toXDR(),
|
|
550
|
+
walletAccount
|
|
551
|
+
}, client);
|
|
552
|
+
const signedTransaction = TransactionBuilder.fromXDR(signedXdr, networkPassphrase);
|
|
553
|
+
return { transactionHash: (await server.submitTransaction(signedTransaction)).hash };
|
|
554
|
+
};
|
|
555
|
+
|
|
556
|
+
//#endregion
|
|
557
|
+
//#region src/injected/utils/createWalletProviderFromStellarProvider/createWalletProviderFromStellarProvider.ts
|
|
558
|
+
/**
|
|
559
|
+
* Builds a Stellar wallet provider from an injected Stellar provider adapter.
|
|
560
|
+
*
|
|
561
|
+
* @param dynamicClient - The Dynamic client instance.
|
|
562
|
+
* @param stellarProvider - The injected Stellar provider adapter.
|
|
563
|
+
* @param walletInfo - Display metadata for the wallet (name, icon, key).
|
|
564
|
+
* @notInstrumented
|
|
565
|
+
*/
|
|
566
|
+
const createWalletProviderFromStellarProvider = ({ dynamicClient, stellarProvider, walletInfo }) => {
|
|
567
|
+
const walletProviderType = WalletProviderEnum.BrowserExtension;
|
|
568
|
+
const key = formatWalletProviderKey({
|
|
569
|
+
chain: "STELLAR",
|
|
570
|
+
displayName: walletInfo.displayName,
|
|
571
|
+
walletProviderType
|
|
572
|
+
});
|
|
573
|
+
const connect = async () => {
|
|
574
|
+
return { addresses: [{ address: await stellarProvider.connect() }] };
|
|
575
|
+
};
|
|
576
|
+
const getActiveNetworkId = async () => {
|
|
577
|
+
return { networkId: getStellarNetworkId({ network: await stellarProvider.getNetwork() }) };
|
|
578
|
+
};
|
|
579
|
+
const getConnectedAddresses = async () => {
|
|
580
|
+
return { addresses: [await stellarProvider.connect()] };
|
|
581
|
+
};
|
|
582
|
+
const signMessage$2 = async ({ message, walletAccount }) => {
|
|
583
|
+
assertDefined(walletAccount, "Wallet account not found");
|
|
584
|
+
await assertWalletAccountSigningAvailability({ walletAccount }, dynamicClient);
|
|
585
|
+
return { signature: await stellarProvider.signMessage({ message }) };
|
|
586
|
+
};
|
|
587
|
+
const signTransaction$3 = async ({ transactionXdr, walletAccount }) => {
|
|
588
|
+
assertDefined(walletAccount, "Wallet account not found");
|
|
589
|
+
await assertWalletAccountSigningAvailability({ walletAccount }, dynamicClient);
|
|
590
|
+
const { networkData } = await getActiveNetworkData({ walletAccount }, dynamicClient);
|
|
591
|
+
assertDefined(networkData, "No active network data found");
|
|
592
|
+
const networkPassphrase = getNetworkPassphrase({ networkId: networkData.networkId });
|
|
593
|
+
return { signedXdr: await stellarProvider.sign({
|
|
594
|
+
options: { networkPassphrase },
|
|
595
|
+
transactionXdr
|
|
596
|
+
}) };
|
|
597
|
+
};
|
|
598
|
+
const { getEventEmitter, cleanupEventEmitter } = createWalletProviderEventEmitter({
|
|
599
|
+
removeEventListeners: ({ setupReturnValue }) => {
|
|
600
|
+
assertDefined(setupReturnValue, "Setup return value not defined");
|
|
601
|
+
setupReturnValue.removeNetworkChangeListener();
|
|
602
|
+
setupReturnValue.removeAccountChangeListener();
|
|
603
|
+
},
|
|
604
|
+
setupEventListeners: ({ handleAccountsChanged, handleNetworkChanged }) => {
|
|
605
|
+
const onAccountsChanged = (address) => {
|
|
606
|
+
if (typeof address === "string") handleAccountsChanged({ addresses: [address] });
|
|
607
|
+
};
|
|
608
|
+
stellarProvider.on?.({
|
|
609
|
+
callback: onAccountsChanged,
|
|
610
|
+
event: "accountChanged"
|
|
611
|
+
});
|
|
612
|
+
const removeAccountChangeListener = () => {};
|
|
613
|
+
const onNetworkChanged = (network) => {
|
|
614
|
+
if (typeof network === "string") handleNetworkChanged({ networkId: getStellarNetworkId({ network }) });
|
|
615
|
+
};
|
|
616
|
+
stellarProvider.on?.({
|
|
617
|
+
callback: onNetworkChanged,
|
|
618
|
+
event: "networkChanged"
|
|
619
|
+
});
|
|
620
|
+
const removeNetworkChangeListener = () => {};
|
|
621
|
+
return {
|
|
622
|
+
removeAccountChangeListener,
|
|
623
|
+
removeNetworkChangeListener
|
|
624
|
+
};
|
|
625
|
+
},
|
|
626
|
+
supportedEvents: ["accountsChanged", "networkChanged"]
|
|
627
|
+
});
|
|
628
|
+
const destroy = async () => {
|
|
629
|
+
cleanupEventEmitter();
|
|
630
|
+
stellarProvider.close?.();
|
|
631
|
+
};
|
|
632
|
+
const disconnectWalletAccount = async () => {
|
|
633
|
+
await stellarProvider.disconnect?.();
|
|
634
|
+
};
|
|
635
|
+
return {
|
|
636
|
+
chain: "STELLAR",
|
|
637
|
+
connect,
|
|
638
|
+
destroy,
|
|
639
|
+
disconnectWalletAccount,
|
|
640
|
+
get events() {
|
|
641
|
+
return getEventEmitter();
|
|
642
|
+
},
|
|
643
|
+
getActiveNetworkId,
|
|
644
|
+
getConnectedAddresses,
|
|
645
|
+
groupKey: formatWalletProviderGroupKey(walletInfo.displayName),
|
|
646
|
+
key,
|
|
647
|
+
metadata: {
|
|
648
|
+
displayName: walletInfo.displayName,
|
|
649
|
+
icon: walletInfo.icon
|
|
650
|
+
},
|
|
651
|
+
signMessage: signMessage$2,
|
|
652
|
+
signTransaction: signTransaction$3,
|
|
653
|
+
transferAmount: (args) => stellarTransferAmount(args, dynamicClient),
|
|
654
|
+
walletProviderType
|
|
655
|
+
};
|
|
656
|
+
};
|
|
657
|
+
|
|
658
|
+
//#endregion
|
|
659
|
+
//#region src/injected/addStellarInjectedWalletsExtension/addStellarInjectedWalletsExtension.ts
|
|
660
|
+
const STELLAR_INJECTED_WALLETS_EXTENSION_KEY = "stellarInjectedWallets";
|
|
661
|
+
/**
|
|
662
|
+
* Adds the Stellar Injected Wallets extension to the Dynamic client.
|
|
663
|
+
*
|
|
664
|
+
* This extension enables integration with Stellar wallets, including Freighter, Lobstr, and OneKey.
|
|
665
|
+
*
|
|
666
|
+
* Internal: consumers should call `addStellarExtension`, which supplies the
|
|
667
|
+
* client. The client is required here (no `getDefaultClient()` default) per the
|
|
668
|
+
* internal-function client-param rule.
|
|
669
|
+
*
|
|
670
|
+
* @param client - The Dynamic client instance.
|
|
671
|
+
* @notInstrumented
|
|
672
|
+
*/
|
|
673
|
+
const addStellarInjectedWalletsExtension = (client) => {
|
|
674
|
+
if (hasExtension({ extensionKey: STELLAR_INJECTED_WALLETS_EXTENSION_KEY }, client)) return;
|
|
675
|
+
registerExtension({ extensionKey: STELLAR_INJECTED_WALLETS_EXTENSION_KEY }, client);
|
|
676
|
+
registerStellarNetworkProviderBuilder(client);
|
|
677
|
+
const walletProviderRegistry = getWalletProviderRegistry(client);
|
|
678
|
+
isConnected().then((response) => {
|
|
679
|
+
if (response.isConnected) try {
|
|
680
|
+
const walletProvider = createWalletProviderFromStellarProvider({
|
|
681
|
+
dynamicClient: client,
|
|
682
|
+
stellarProvider: createFreighterProvider(),
|
|
683
|
+
walletInfo: {
|
|
684
|
+
displayName: "Freighter",
|
|
685
|
+
icon: "https://stellar.creit.tech/wallet-icons/freighter.png",
|
|
686
|
+
key: "freighter"
|
|
687
|
+
}
|
|
688
|
+
});
|
|
689
|
+
walletProviderRegistry.register({
|
|
690
|
+
priority: WalletProviderPriority.WINDOW_INJECT,
|
|
691
|
+
walletProvider
|
|
692
|
+
});
|
|
693
|
+
} catch (error) {
|
|
694
|
+
getCore(client).logger.error("Error creating Freighter provider", error);
|
|
695
|
+
}
|
|
696
|
+
}).catch((error) => {
|
|
697
|
+
getCore(client).logger.error("Error checking Freighter connection", error);
|
|
698
|
+
});
|
|
699
|
+
isConnected$1().then(() => {
|
|
700
|
+
try {
|
|
701
|
+
const walletProvider = createWalletProviderFromStellarProvider({
|
|
702
|
+
dynamicClient: client,
|
|
703
|
+
stellarProvider: createLobstrProvider(),
|
|
704
|
+
walletInfo: {
|
|
705
|
+
displayName: "Lobstr",
|
|
706
|
+
icon: "https://stellar.creit.tech/wallet-icons/lobstr.svg",
|
|
707
|
+
key: "lobstr"
|
|
708
|
+
}
|
|
709
|
+
});
|
|
710
|
+
walletProviderRegistry.register({
|
|
711
|
+
priority: WalletProviderPriority.WINDOW_INJECT,
|
|
712
|
+
walletProvider
|
|
713
|
+
});
|
|
714
|
+
} catch (error) {
|
|
715
|
+
getCore(client).logger.error("Error creating Lobstr provider", error);
|
|
716
|
+
}
|
|
717
|
+
}).catch((error) => {
|
|
718
|
+
getCore(client).logger.error("Error checking Lobstr connection", error);
|
|
719
|
+
});
|
|
720
|
+
Promise.resolve().then(() => {
|
|
721
|
+
if (getOneKeyStellarProvider()) try {
|
|
722
|
+
const walletProvider = createWalletProviderFromStellarProvider({
|
|
723
|
+
dynamicClient: client,
|
|
724
|
+
stellarProvider: createOneKeyProvider(),
|
|
725
|
+
walletInfo: {
|
|
726
|
+
displayName: "OneKey",
|
|
727
|
+
icon: "https://uni.onekey-asset.com/static/logo/onekey.png",
|
|
728
|
+
key: "onekey"
|
|
729
|
+
}
|
|
730
|
+
});
|
|
731
|
+
walletProviderRegistry.register({
|
|
732
|
+
priority: WalletProviderPriority.WINDOW_INJECT,
|
|
733
|
+
walletProvider
|
|
734
|
+
});
|
|
735
|
+
} catch (error) {
|
|
736
|
+
getCore(client).logger.error("Error creating OneKey provider", error);
|
|
737
|
+
}
|
|
738
|
+
}).catch((error) => {
|
|
739
|
+
getCore(client).logger.error("Error checking OneKey connection", error);
|
|
740
|
+
});
|
|
741
|
+
};
|
|
742
|
+
|
|
743
|
+
//#endregion
|
|
744
|
+
//#region src/addStellarExtension/addStellarExtension.ts
|
|
745
|
+
/**
|
|
746
|
+
* Adds the Stellar extension to the Dynamic client.
|
|
747
|
+
*
|
|
748
|
+
* This is a convenience function that adds support for Stellar wallets,
|
|
749
|
+
* including Freighter, Lobstr, and OneKey.
|
|
750
|
+
*
|
|
751
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
752
|
+
* @notInstrumented
|
|
753
|
+
*/
|
|
754
|
+
const addStellarExtension = (client = getDefaultClient$1()) => {
|
|
755
|
+
addStellarInjectedWalletsExtension(client);
|
|
756
|
+
};
|
|
757
|
+
|
|
37
758
|
//#endregion
|
|
38
759
|
//#region src/exports/index.ts
|
|
39
760
|
assertPackageVersion(name, version);
|
|
40
761
|
|
|
41
762
|
//#endregion
|
|
42
|
-
export { NotStellarProviderError, isStellarWalletAccount };
|
|
763
|
+
export { NotStellarProviderError, addStellarExtension, isStellarWalletAccount, signTransaction };
|
|
43
764
|
//# sourceMappingURL=index.esm.js.map
|