@vue-solana/core 4.1.4 → 4.1.5

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/index.mjs CHANGED
@@ -12,4 +12,4 @@ export { createSolanaPayReference, findTransactionSignaturesByReference, verifyS
12
12
  export { getSolanaPayPaymentStatus } from './solana-pay-status.mjs';
13
13
  export * from '@solana/kit';
14
14
  export { C as CreateTransferError, H as HTTPS_PROTOCOL, M as MEMO_PROGRAM_ID, P as ParseURLError, S as SOLANA_PROTOCOL, a as SOL_DECIMALS, T as TEN, b as TOKEN_PROGRAM_ID, c as createQR, d as createQRCanvas, e as createQRDataURL, f as createQROptions, g as createRecipient, h as createSPLToken, i as createStyledQRCode, j as encodeTransactionRequestURL, k as encodeTransferRequestURL, l as encodeURL, m as isValidSolanaAddress, p as parseURL } from './shared/core.CQFtdLrA.mjs';
15
- export { S as SOLANA_CHAINS, a as SOLANA_MOBILE_WALLET_ADAPTER_WALLET_NAME, b as adaptSolanaStandardWallet, d as disconnectSolanaStandardWallet, g as getRegisteredSolanaWallets, c as getSolanaChain, i as isSolanaStandardWallet, s as subscribeSolanaWallets } from './shared/core.D8oIzL0q.mjs';
15
+ export { S as SOLANA_CHAINS, a as SOLANA_MOBILE_WALLET_ADAPTER_WALLET_NAME, b as adaptSolanaStandardWallet, d as disconnectSolanaStandardWallet, g as getRegisteredSolanaWallets, c as getSolanaChain, i as isSolanaStandardWallet, s as subscribeSolanaWallets } from './shared/core.Fb0vU7a_.mjs';
@@ -78,10 +78,14 @@ function adaptSolanaStandardWallet(walletInfo, options = {}) {
78
78
  let manuallyDisconnected = false;
79
79
  let signingIn = false;
80
80
  const isMobileWalletAdapter = walletInfo.source === "mobile-wallet-adapter";
81
+ const pendingMobileWalletRequests = /* @__PURE__ */ new Set();
81
82
  const eventsFeature = wallet.features[StandardEvents];
82
83
  const unsubscribeChange = eventsFeature?.on("change", (properties) => {
83
84
  if (properties.accounts) {
84
85
  accounts = properties.accounts;
86
+ if (accounts.length === 0) {
87
+ rejectPendingMobileWalletRequests();
88
+ }
85
89
  if (!signingIn) {
86
90
  account = allowAccountUpdates && !manuallyDisconnected ? getSolanaAccount(accounts, options.chain) : void 0;
87
91
  }
@@ -91,6 +95,30 @@ function adaptSolanaStandardWallet(walletInfo, options = {}) {
91
95
  function dispose() {
92
96
  unsubscribeChange?.();
93
97
  }
98
+ function whileMobileWalletAuthorized(request) {
99
+ if (!isMobileWalletAdapter) {
100
+ return request();
101
+ }
102
+ let reject;
103
+ const deauthorized = new Promise((_, rejectRequest) => {
104
+ reject = rejectRequest;
105
+ });
106
+ pendingMobileWalletRequests.add(reject);
107
+ return Promise.race([request(), deauthorized]).finally(() => {
108
+ pendingMobileWalletRequests.delete(reject);
109
+ });
110
+ }
111
+ function rejectPendingMobileWalletRequests() {
112
+ for (const reject of pendingMobileWalletRequests) {
113
+ reject(
114
+ createSolanaError(
115
+ "WALLET_NOT_CONNECTED",
116
+ "The wallet ended this app's session instead of signing, usually because it no longer accepts the saved authorization. Connect the wallet again and retry."
117
+ )
118
+ );
119
+ }
120
+ pendingMobileWalletRequests.clear();
121
+ }
94
122
  async function verifySignInResult(result, requestedAddress) {
95
123
  if (!result) {
96
124
  throw new Error("Solana wallet did not return a sign-in result");
@@ -242,10 +270,12 @@ function adaptSolanaStandardWallet(walletInfo, options = {}) {
242
270
  } : void 0,
243
271
  signMessage: hasSignMessage(wallet) ? async (message) => {
244
272
  const activeAccount = getActiveAccount(account);
245
- const [result] = await wallet.features[SolanaSignMessage].signMessage({
246
- account: activeAccount,
247
- message
248
- });
273
+ const [result] = await whileMobileWalletAuthorized(
274
+ () => wallet.features[SolanaSignMessage].signMessage({
275
+ account: activeAccount,
276
+ message
277
+ })
278
+ );
249
279
  if (!result) {
250
280
  throw new Error("Solana wallet did not return a message signature");
251
281
  }
@@ -264,36 +294,44 @@ function adaptSolanaStandardWallet(walletInfo, options = {}) {
264
294
  } : void 0,
265
295
  signTransaction: hasSignTransaction(wallet) ? async (transaction) => {
266
296
  const activeAccount = getActiveAccount(account);
267
- const [result] = await wallet.features[SolanaSignTransaction].signTransaction({
268
- account: activeAccount,
269
- transaction: new Uint8Array(transaction),
270
- chain: options.chain
271
- });
297
+ const [result] = await whileMobileWalletAuthorized(
298
+ () => wallet.features[SolanaSignTransaction].signTransaction({
299
+ account: activeAccount,
300
+ transaction: new Uint8Array(transaction),
301
+ chain: options.chain
302
+ })
303
+ );
272
304
  if (!result) {
273
305
  throw new Error("Solana wallet did not return a signed transaction");
274
306
  }
275
307
  return result.signedTransaction;
276
308
  } : void 0,
277
- signAllTransactions: hasSignTransaction(wallet) ? async (transactions) => signAllThroughFeature(
278
- wallet,
279
- () => getActiveAccount(account),
280
- transactions,
281
- options.chain
309
+ signAllTransactions: hasSignTransaction(wallet) ? async (transactions) => whileMobileWalletAuthorized(
310
+ () => signAllThroughFeature(
311
+ wallet,
312
+ () => getActiveAccount(account),
313
+ transactions,
314
+ options.chain
315
+ )
282
316
  ) : void 0,
283
- signTransactions: hasSignTransaction(wallet) ? async (transactions) => signAllThroughFeature(
284
- wallet,
285
- () => getActiveAccount(account),
286
- transactions,
287
- options.chain
317
+ signTransactions: hasSignTransaction(wallet) ? async (transactions) => whileMobileWalletAuthorized(
318
+ () => signAllThroughFeature(
319
+ wallet,
320
+ () => getActiveAccount(account),
321
+ transactions,
322
+ options.chain
323
+ )
288
324
  ) : void 0,
289
325
  signAndSendTransaction: hasSignAndSendTransaction(wallet) ? async (transaction, sendOptions) => {
290
326
  const activeAccount = getActiveAccount(account);
291
- const [result] = await wallet.features[SolanaSignAndSendTransaction].signAndSendTransaction({
292
- account: activeAccount,
293
- transaction: new Uint8Array(transaction),
294
- chain: options.chain ?? getSolanaAccountChain(activeAccount),
295
- options: sendOptions
296
- });
327
+ const [result] = await whileMobileWalletAuthorized(
328
+ () => wallet.features[SolanaSignAndSendTransaction].signAndSendTransaction({
329
+ account: activeAccount,
330
+ transaction: new Uint8Array(transaction),
331
+ chain: options.chain ?? getSolanaAccountChain(activeAccount),
332
+ options: sendOptions
333
+ })
334
+ );
297
335
  if (!result) {
298
336
  throw new Error("Solana wallet did not return a transaction signature");
299
337
  }
@@ -302,21 +340,20 @@ function adaptSolanaStandardWallet(walletInfo, options = {}) {
302
340
  signAndSendTransactions: hasSignAndSendTransaction(wallet) ? async (transactions, sendOptions) => {
303
341
  const activeAccount = getActiveAccount(account);
304
342
  if (isMobileWalletAdapter && options.sendTransaction && transactions.length > 1 && hasSignTransaction(wallet)) {
305
- const signedTransactions = await signAllThroughFeature(
306
- wallet,
307
- () => activeAccount,
308
- transactions,
309
- options.chain
343
+ const signedTransactions = await whileMobileWalletAuthorized(
344
+ () => signAllThroughFeature(wallet, () => activeAccount, transactions, options.chain)
310
345
  );
311
346
  return sendSequentially(signedTransactions, options.sendTransaction, sendOptions);
312
347
  }
313
- const results = await wallet.features[SolanaSignAndSendTransaction].signAndSendTransaction(
314
- ...transactions.map((transaction) => ({
315
- account: activeAccount,
316
- transaction: new Uint8Array(transaction),
317
- chain: options.chain ?? getSolanaAccountChain(activeAccount),
318
- options: sendOptions
319
- }))
348
+ const results = await whileMobileWalletAuthorized(
349
+ () => wallet.features[SolanaSignAndSendTransaction].signAndSendTransaction(
350
+ ...transactions.map((transaction) => ({
351
+ account: activeAccount,
352
+ transaction: new Uint8Array(transaction),
353
+ chain: options.chain ?? getSolanaAccountChain(activeAccount),
354
+ options: sendOptions
355
+ }))
356
+ )
320
357
  );
321
358
  if (results.length !== transactions.length) {
322
359
  throw new Error(
@@ -1 +1 @@
1
- export { S as SOLANA_CHAINS, a as SOLANA_MOBILE_WALLET_ADAPTER_WALLET_NAME, b as adaptSolanaStandardWallet, d as disconnectSolanaStandardWallet, g as getRegisteredSolanaWallets, c as getSolanaChain, i as isSolanaStandardWallet, s as subscribeSolanaWallets } from './shared/core.D8oIzL0q.mjs';
1
+ export { S as SOLANA_CHAINS, a as SOLANA_MOBILE_WALLET_ADAPTER_WALLET_NAME, b as adaptSolanaStandardWallet, d as disconnectSolanaStandardWallet, g as getRegisteredSolanaWallets, c as getSolanaChain, i as isSolanaStandardWallet, s as subscribeSolanaWallets } from './shared/core.Fb0vU7a_.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue-solana/core",
3
- "version": "4.1.4",
3
+ "version": "4.1.5",
4
4
  "description": "Framework-agnostic primitives for Vue Solana libraries.",
5
5
  "license": "MIT",
6
6
  "keywords": [