@vue-solana/core 0.5.1 → 0.6.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 +6 -3
- package/dist/index.cjs +4 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +3 -3
- package/dist/ios-wallet.cjs +1 -1
- package/dist/ios-wallet.mjs +1 -1
- package/dist/shared/{core.DJZldB_x.cjs → core.BsekSwcZ.cjs} +87 -85
- package/dist/shared/{core.DSI7vIfT.mjs → core.Ch_Z7_17.mjs} +87 -85
- package/dist/shared/{core.D7olTUN_.mjs → core.DSMNiaHD.mjs} +23 -1
- package/dist/shared/{core.8V8PLE-S.cjs → core.DX2frf65.cjs} +22 -0
- package/dist/types.d.cts +8 -1
- package/dist/types.d.mts +8 -1
- package/dist/types.d.ts +8 -1
- package/dist/wallet-standard.cjs +1 -1
- package/dist/wallet-standard.mjs +1 -1
- package/dist/wallet.cjs +23 -2
- package/dist/wallet.d.cts +8 -1
- package/dist/wallet.d.mts +8 -1
- package/dist/wallet.d.ts +8 -1
- package/dist/wallet.mjs +22 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Framework-agnostic Solana primitives used by the Vue Solana packages.
|
|
4
4
|
|
|
5
|
-
Use this package directly when you want connection helpers, shared wallet types, Android Mobile Wallet Adapter registration helpers, and transaction helpers without installing the Vue plugin.
|
|
5
|
+
Use this package directly when you want connection helpers, shared wallet types, Android Mobile Wallet Adapter registration helpers, message signing support, and transaction helpers without installing the Vue plugin.
|
|
6
6
|
|
|
7
7
|
`@vue-solana/core` does not replace `@solana/web3-compat`. Use `@solana/web3-compat` for raw Solana primitives like `Connection`, `PublicKey`, and transactions. Use `@vue-solana/core` for Vue Solana shared configuration, cluster endpoint defaults, wallet interfaces, and transaction helpers.
|
|
8
8
|
|
|
@@ -101,6 +101,7 @@ Direct subpaths:
|
|
|
101
101
|
- `getWebSocketEndpoint(endpoint)`: converts `http`/`https` RPC URLs to `ws`/`wss` URLs.
|
|
102
102
|
- `isWalletConnected(wallet)`: checks whether a wallet is connected and has a public key.
|
|
103
103
|
- `assertWalletConnected(wallet)`: throws if the wallet is not connected.
|
|
104
|
+
- `assertWalletCanSignMessage(wallet)`: throws if the wallet is disconnected or cannot sign messages.
|
|
104
105
|
- `assertWalletCanSign(wallet)`: throws if the wallet cannot sign transactions.
|
|
105
106
|
- `signAndSendTransaction(connection, wallet, transaction, options?)`: signs and sends a transaction using a configured wallet. Android Mobile Wallet Adapter wallets prefer `signTransaction` plus app-side RPC submission when available so the app can reliably return the submitted signature.
|
|
106
107
|
- `confirmTransactionSignature(connection, signature, options?)`: waits for a submitted signature to reach a requested commitment. Defaults to `confirmed` commitment and a 60 second timeout.
|
|
@@ -115,17 +116,19 @@ const wallet: SolanaWallet = {
|
|
|
115
116
|
connected: false,
|
|
116
117
|
connect: async () => {},
|
|
117
118
|
disconnect: async () => {},
|
|
119
|
+
signMessage: async (message) => ({ signedMessage: message, signature: new Uint8Array() }),
|
|
118
120
|
signTransaction: async (transaction) => transaction,
|
|
119
121
|
};
|
|
120
122
|
```
|
|
121
123
|
|
|
122
|
-
Browser extension wallets discovered through the Solana Wallet Standard are adapted into `SolanaWallet`. Android Mobile Wallet Adapter is registered through `@solana-mobile/wallet-standard-mobile` and then adapted through the same Wallet Standard adapter on supported Android Chrome clients. iOS browser wallet entries for Phantom, Solflare, and Backpack are adapted through wallet-specific universal links. You can also provide a custom object that implements `SolanaWallet` for tests or custom adapters.
|
|
124
|
+
Browser extension wallets discovered through the Solana Wallet Standard are adapted into `SolanaWallet`. Android Mobile Wallet Adapter is registered through `@solana-mobile/wallet-standard-mobile` and then adapted through the same Wallet Standard adapter on supported Android Chrome clients. iOS browser wallet entries for Phantom, Solflare, and Backpack are adapted through wallet-specific universal links. Wallet capability metadata exposes whether each wallet supports message signing, transaction signing, and sign-and-send flows. You can also provide a custom object that implements `SolanaWallet` for tests or custom adapters.
|
|
123
125
|
|
|
124
126
|
Current wallet support:
|
|
125
127
|
|
|
126
128
|
- Browser extension wallets through Wallet Standard packages.
|
|
127
129
|
- Android native mobile wallets through `@solana-mobile/wallet-standard-mobile` on Android Chrome and Chrome PWAs.
|
|
128
130
|
- iOS browser wallets for Phantom, Solflare, and Backpack through wallet-specific universal links.
|
|
131
|
+
- Message signing when the active wallet exposes `signMessage`.
|
|
129
132
|
- Manual/custom wallet objects that implement `SolanaWallet`.
|
|
130
133
|
|
|
131
134
|
Planned but not supported yet:
|
|
@@ -183,4 +186,4 @@ Make sure your `tsconfig.json` includes `types/**/*.d.ts` or another pattern tha
|
|
|
183
186
|
|
|
184
187
|
## Status
|
|
185
188
|
|
|
186
|
-
This package is early-stage. RPC helpers, browser extension wallet primitives, Android mobile wallet registration, and transaction helpers are usable.
|
|
189
|
+
This package is early-stage. RPC helpers, browser extension wallet primitives, Android mobile wallet registration, message signing, and transaction helpers are usable.
|
package/dist/index.cjs
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
const clusters = require('./clusters.cjs');
|
|
4
4
|
const address = require('./address.cjs');
|
|
5
|
-
const adapter = require('./shared/core.
|
|
5
|
+
const adapter = require('./shared/core.BsekSwcZ.cjs');
|
|
6
6
|
const mobileWallet = require('./mobile-wallet.cjs');
|
|
7
7
|
const rpc = require('./rpc.cjs');
|
|
8
8
|
const transaction = require('./transaction.cjs');
|
|
9
9
|
const wallet = require('./wallet.cjs');
|
|
10
|
-
const discovery = require('./shared/core.
|
|
10
|
+
const discovery = require('./shared/core.DX2frf65.cjs');
|
|
11
11
|
require('@solana/web3-compat');
|
|
12
12
|
require('bs58');
|
|
13
13
|
require('tweetnacl');
|
|
@@ -38,7 +38,9 @@ exports.createSolanaConnection = rpc.createSolanaConnection;
|
|
|
38
38
|
exports.createSolanaContext = rpc.createSolanaContext;
|
|
39
39
|
exports.confirmTransactionSignature = transaction.confirmTransactionSignature;
|
|
40
40
|
exports.signAndSendTransaction = transaction.signAndSendTransaction;
|
|
41
|
+
exports.SolanaWalletError = wallet.SolanaWalletError;
|
|
41
42
|
exports.assertWalletCanSign = wallet.assertWalletCanSign;
|
|
43
|
+
exports.assertWalletCanSignMessage = wallet.assertWalletCanSignMessage;
|
|
42
44
|
exports.assertWalletConnected = wallet.assertWalletConnected;
|
|
43
45
|
exports.isWalletConnected = wallet.isWalletConnected;
|
|
44
46
|
exports.SOLANA_CHAINS = discovery.SOLANA_CHAINS;
|
package/dist/index.d.cts
CHANGED
|
@@ -4,8 +4,8 @@ export { AdaptSolanaIosWalletOptions, GetSolanaIosWalletsOptions, IosWalletCallb
|
|
|
4
4
|
export { RegisterSolanaMobileWalletOptions, SolanaMobileWalletAppIdentity, getDefaultMobileWalletAppIdentity, isSolanaMobileWalletSupported, registerSolanaMobileWallet } from './mobile-wallet.cjs';
|
|
5
5
|
export { createSolanaConnection, createSolanaContext } from './rpc.cjs';
|
|
6
6
|
export { confirmTransactionSignature, signAndSendTransaction } from './transaction.cjs';
|
|
7
|
-
export { ConfirmTransactionOptions, SendTransactionOptions, SolanaChain, SolanaCluster, SolanaConfig, SolanaContext, SolanaTransaction, SolanaWallet, SolanaWalletInfo, TransactionConfirmation } from './types.cjs';
|
|
8
|
-
export { assertWalletCanSign, assertWalletConnected, isWalletConnected } from './wallet.cjs';
|
|
7
|
+
export { ConfirmTransactionOptions, SendTransactionOptions, SolanaChain, SolanaCluster, SolanaConfig, SolanaContext, SolanaSignMessageResult, SolanaTransaction, SolanaWallet, SolanaWalletInfo, TransactionConfirmation } from './types.cjs';
|
|
8
|
+
export { SolanaWalletError, SolanaWalletErrorCode, assertWalletCanSign, assertWalletCanSignMessage, assertWalletConnected, isWalletConnected } from './wallet.cjs';
|
|
9
9
|
export { AdaptSolanaWalletOptions, SOLANA_CHAINS, SOLANA_MOBILE_WALLET_ADAPTER_WALLET_NAME, adaptSolanaStandardWallet, getRegisteredSolanaWallets, getSolanaChain, isSolanaStandardWallet, subscribeSolanaWallets } from './wallet-standard.cjs';
|
|
10
10
|
import '@solana/web3-compat';
|
|
11
11
|
import '@wallet-standard/base';
|
package/dist/index.d.mts
CHANGED
|
@@ -4,8 +4,8 @@ export { AdaptSolanaIosWalletOptions, GetSolanaIosWalletsOptions, IosWalletCallb
|
|
|
4
4
|
export { RegisterSolanaMobileWalletOptions, SolanaMobileWalletAppIdentity, getDefaultMobileWalletAppIdentity, isSolanaMobileWalletSupported, registerSolanaMobileWallet } from './mobile-wallet.mjs';
|
|
5
5
|
export { createSolanaConnection, createSolanaContext } from './rpc.mjs';
|
|
6
6
|
export { confirmTransactionSignature, signAndSendTransaction } from './transaction.mjs';
|
|
7
|
-
export { ConfirmTransactionOptions, SendTransactionOptions, SolanaChain, SolanaCluster, SolanaConfig, SolanaContext, SolanaTransaction, SolanaWallet, SolanaWalletInfo, TransactionConfirmation } from './types.mjs';
|
|
8
|
-
export { assertWalletCanSign, assertWalletConnected, isWalletConnected } from './wallet.mjs';
|
|
7
|
+
export { ConfirmTransactionOptions, SendTransactionOptions, SolanaChain, SolanaCluster, SolanaConfig, SolanaContext, SolanaSignMessageResult, SolanaTransaction, SolanaWallet, SolanaWalletInfo, TransactionConfirmation } from './types.mjs';
|
|
8
|
+
export { SolanaWalletError, SolanaWalletErrorCode, assertWalletCanSign, assertWalletCanSignMessage, assertWalletConnected, isWalletConnected } from './wallet.mjs';
|
|
9
9
|
export { AdaptSolanaWalletOptions, SOLANA_CHAINS, SOLANA_MOBILE_WALLET_ADAPTER_WALLET_NAME, adaptSolanaStandardWallet, getRegisteredSolanaWallets, getSolanaChain, isSolanaStandardWallet, subscribeSolanaWallets } from './wallet-standard.mjs';
|
|
10
10
|
import '@solana/web3-compat';
|
|
11
11
|
import '@wallet-standard/base';
|
package/dist/index.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ export { AdaptSolanaIosWalletOptions, GetSolanaIosWalletsOptions, IosWalletCallb
|
|
|
4
4
|
export { RegisterSolanaMobileWalletOptions, SolanaMobileWalletAppIdentity, getDefaultMobileWalletAppIdentity, isSolanaMobileWalletSupported, registerSolanaMobileWallet } from './mobile-wallet.js';
|
|
5
5
|
export { createSolanaConnection, createSolanaContext } from './rpc.js';
|
|
6
6
|
export { confirmTransactionSignature, signAndSendTransaction } from './transaction.js';
|
|
7
|
-
export { ConfirmTransactionOptions, SendTransactionOptions, SolanaChain, SolanaCluster, SolanaConfig, SolanaContext, SolanaTransaction, SolanaWallet, SolanaWalletInfo, TransactionConfirmation } from './types.js';
|
|
8
|
-
export { assertWalletCanSign, assertWalletConnected, isWalletConnected } from './wallet.js';
|
|
7
|
+
export { ConfirmTransactionOptions, SendTransactionOptions, SolanaChain, SolanaCluster, SolanaConfig, SolanaContext, SolanaSignMessageResult, SolanaTransaction, SolanaWallet, SolanaWalletInfo, TransactionConfirmation } from './types.js';
|
|
8
|
+
export { SolanaWalletError, SolanaWalletErrorCode, assertWalletCanSign, assertWalletCanSignMessage, assertWalletConnected, isWalletConnected } from './wallet.js';
|
|
9
9
|
export { AdaptSolanaWalletOptions, SOLANA_CHAINS, SOLANA_MOBILE_WALLET_ADAPTER_WALLET_NAME, adaptSolanaStandardWallet, getRegisteredSolanaWallets, getSolanaChain, isSolanaStandardWallet, subscribeSolanaWallets } from './wallet-standard.js';
|
|
10
10
|
import '@solana/web3-compat';
|
|
11
11
|
import '@wallet-standard/base';
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export { DEFAULT_CLUSTER, getClusterEndpoint, getClusterWebSocketEndpoint, getWebSocketEndpoint } from './clusters.mjs';
|
|
2
2
|
export { parsePublicKey } from './address.mjs';
|
|
3
|
-
export { a as adaptSolanaIosWallet, g as getDefaultIosWalletAppIdentity, b as getDefaultIosWalletRedirectUrl, c as getSolanaIosWallets, h as handleSolanaIosWalletCallback, i as isIosBrowser, d as isSolanaIosBrowserWalletSupported, e as isSolanaIosWalletInfo } from './shared/core.
|
|
3
|
+
export { a as adaptSolanaIosWallet, g as getDefaultIosWalletAppIdentity, b as getDefaultIosWalletRedirectUrl, c as getSolanaIosWallets, h as handleSolanaIosWalletCallback, i as isIosBrowser, d as isSolanaIosBrowserWalletSupported, e as isSolanaIosWalletInfo } from './shared/core.Ch_Z7_17.mjs';
|
|
4
4
|
export { getDefaultMobileWalletAppIdentity, isSolanaMobileWalletSupported, registerSolanaMobileWallet } from './mobile-wallet.mjs';
|
|
5
5
|
export { createSolanaConnection, createSolanaContext } from './rpc.mjs';
|
|
6
6
|
export { confirmTransactionSignature, signAndSendTransaction } from './transaction.mjs';
|
|
7
|
-
export { assertWalletCanSign, assertWalletConnected, isWalletConnected } from './wallet.mjs';
|
|
8
|
-
export { S as SOLANA_CHAINS, a as SOLANA_MOBILE_WALLET_ADAPTER_WALLET_NAME, b as adaptSolanaStandardWallet, g as getRegisteredSolanaWallets, c as getSolanaChain, i as isSolanaStandardWallet, s as subscribeSolanaWallets } from './shared/core.
|
|
7
|
+
export { SolanaWalletError, assertWalletCanSign, assertWalletCanSignMessage, assertWalletConnected, isWalletConnected } from './wallet.mjs';
|
|
8
|
+
export { S as SOLANA_CHAINS, a as SOLANA_MOBILE_WALLET_ADAPTER_WALLET_NAME, b as adaptSolanaStandardWallet, g as getRegisteredSolanaWallets, c as getSolanaChain, i as isSolanaStandardWallet, s as subscribeSolanaWallets } from './shared/core.DSMNiaHD.mjs';
|
|
9
9
|
import '@solana/web3-compat';
|
|
10
10
|
import 'bs58';
|
|
11
11
|
import 'tweetnacl';
|
package/dist/ios-wallet.cjs
CHANGED
package/dist/ios-wallet.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { a as adaptSolanaIosWallet, g as getDefaultIosWalletAppIdentity, b as getDefaultIosWalletRedirectUrl, c as getSolanaIosWallets, h as handleSolanaIosWalletCallback, i as isIosBrowser, d as isSolanaIosBrowserWalletSupported, e as isSolanaIosWalletInfo } from './shared/core.
|
|
1
|
+
export { a as adaptSolanaIosWallet, g as getDefaultIosWalletAppIdentity, b as getDefaultIosWalletRedirectUrl, c as getSolanaIosWallets, h as handleSolanaIosWalletCallback, i as isIosBrowser, d as isSolanaIosBrowserWalletSupported, e as isSolanaIosWalletInfo } from './shared/core.Ch_Z7_17.mjs';
|
|
2
2
|
import '@solana/web3-compat';
|
|
3
3
|
import 'bs58';
|
|
4
4
|
import 'tweetnacl';
|
|
@@ -411,6 +411,92 @@ function deserializeTransaction(source, bytes) {
|
|
|
411
411
|
return web3Compat.VersionedTransaction.deserialize(bytes);
|
|
412
412
|
}
|
|
413
413
|
|
|
414
|
+
function launchConnect(definition, options) {
|
|
415
|
+
const keyPair = nacl.box.keyPair();
|
|
416
|
+
const pending = createPendingRequest(definition.id, "connect", keyPair, options.redirectUrl);
|
|
417
|
+
const appIdentity = options.appIdentity ?? getDefaultIosWalletAppIdentity();
|
|
418
|
+
const url = new URL(definition.connectUrl);
|
|
419
|
+
url.searchParams.set("app_url", appIdentity.uri);
|
|
420
|
+
url.searchParams.set("dapp_encryption_public_key", pending.dappEncryptionPublicKey);
|
|
421
|
+
url.searchParams.set("redirect_link", pending.redirectUrl);
|
|
422
|
+
if (options.cluster && options.cluster !== "localnet") {
|
|
423
|
+
url.searchParams.set("cluster", options.cluster);
|
|
424
|
+
}
|
|
425
|
+
storePendingRequest(pending);
|
|
426
|
+
openIosWalletUrl(url.toString());
|
|
427
|
+
}
|
|
428
|
+
async function launchSignTransaction(definition, transaction, options) {
|
|
429
|
+
const response = await launchEncryptedWalletRequest(definition, "signTransaction", options, {
|
|
430
|
+
transaction: bs58__default.encode(serializeTransaction(transaction))
|
|
431
|
+
});
|
|
432
|
+
if (!response.transaction) {
|
|
433
|
+
throw new Error("iOS wallet did not return a signed transaction");
|
|
434
|
+
}
|
|
435
|
+
return response.transaction;
|
|
436
|
+
}
|
|
437
|
+
async function launchSignAllTransactions(definition, transactions, options) {
|
|
438
|
+
const response = await launchEncryptedWalletRequest(definition, "signAllTransactions", options, {
|
|
439
|
+
transactions: transactions.map((transaction) => bs58__default.encode(serializeTransaction(transaction)))
|
|
440
|
+
});
|
|
441
|
+
if (!response.transactions) {
|
|
442
|
+
throw new Error("iOS wallet did not return signed transactions");
|
|
443
|
+
}
|
|
444
|
+
return response.transactions;
|
|
445
|
+
}
|
|
446
|
+
async function launchSignAndSendTransaction(definition, transaction, sendOptions, options) {
|
|
447
|
+
const response = await launchEncryptedWalletRequest(
|
|
448
|
+
definition,
|
|
449
|
+
"signAndSendTransaction",
|
|
450
|
+
options,
|
|
451
|
+
{
|
|
452
|
+
transaction: bs58__default.encode(serializeTransaction(transaction)),
|
|
453
|
+
sendOptions
|
|
454
|
+
}
|
|
455
|
+
);
|
|
456
|
+
if (!response.signature) {
|
|
457
|
+
throw new Error("iOS wallet did not return a transaction signature");
|
|
458
|
+
}
|
|
459
|
+
return { signature: response.signature };
|
|
460
|
+
}
|
|
461
|
+
async function launchEncryptedWalletRequest(definition, method, options, payload) {
|
|
462
|
+
const session = getStoredSession(definition.id);
|
|
463
|
+
if (!session) {
|
|
464
|
+
throw new Error("Connect the iOS wallet before signing");
|
|
465
|
+
}
|
|
466
|
+
const methodUrl = getIosWalletMethodUrl(definition, method);
|
|
467
|
+
const pending = createPendingRequest(
|
|
468
|
+
definition.id,
|
|
469
|
+
method,
|
|
470
|
+
{
|
|
471
|
+
publicKey: bs58__default.decode(session.dappEncryptionPublicKey),
|
|
472
|
+
secretKey: bs58__default.decode(session.dappEncryptionSecretKey)
|
|
473
|
+
},
|
|
474
|
+
options.redirectUrl,
|
|
475
|
+
method === "signAllTransactions" && Array.isArray(payload.transactions) ? payload.transactions.length : void 0
|
|
476
|
+
);
|
|
477
|
+
const nonce = nacl.randomBytes(nacl.box.nonceLength);
|
|
478
|
+
const encryptedPayload = encryptPayload(
|
|
479
|
+
{ ...payload, session: session.session },
|
|
480
|
+
nonce,
|
|
481
|
+
bs58__default.decode(session.sharedSecret)
|
|
482
|
+
);
|
|
483
|
+
const url = new URL(methodUrl);
|
|
484
|
+
url.searchParams.set("dapp_encryption_public_key", session.dappEncryptionPublicKey);
|
|
485
|
+
url.searchParams.set("nonce", bs58__default.encode(nonce));
|
|
486
|
+
url.searchParams.set("redirect_link", pending.redirectUrl);
|
|
487
|
+
url.searchParams.set("payload", encryptedPayload);
|
|
488
|
+
storePendingRequest(pending);
|
|
489
|
+
openIosWalletUrl(url.toString());
|
|
490
|
+
return waitForRedirect();
|
|
491
|
+
}
|
|
492
|
+
function getIosWalletMethodUrl(definition, method) {
|
|
493
|
+
const url = definition[`${method}Url`];
|
|
494
|
+
if (!url) {
|
|
495
|
+
throw new Error(`${definition.name} does not support ${method} through iOS deeplinks`);
|
|
496
|
+
}
|
|
497
|
+
return url;
|
|
498
|
+
}
|
|
499
|
+
|
|
414
500
|
function getSolanaIosWallets(options = {}) {
|
|
415
501
|
if (!isSolanaIosBrowserWalletSupported()) {
|
|
416
502
|
return [];
|
|
@@ -428,6 +514,7 @@ function getSolanaIosWallets(options = {}) {
|
|
|
428
514
|
callbackUrl,
|
|
429
515
|
capabilities: {
|
|
430
516
|
connect: true,
|
|
517
|
+
disconnect: true,
|
|
431
518
|
signTransaction: Boolean(wallet.signTransactionUrl),
|
|
432
519
|
signAllTransactions: Boolean(wallet.signAllTransactionsUrl),
|
|
433
520
|
signAndSendTransaction: Boolean(wallet.signAndSendTransactionUrl)
|
|
@@ -510,91 +597,6 @@ function adaptSolanaIosWallet(walletInfo, options = {}) {
|
|
|
510
597
|
function isSolanaIosWalletInfo(walletInfo) {
|
|
511
598
|
return walletInfo.source === "deep-link" && isIosWalletDefinition(walletInfo.wallet);
|
|
512
599
|
}
|
|
513
|
-
function launchConnect(definition, options) {
|
|
514
|
-
const keyPair = nacl.box.keyPair();
|
|
515
|
-
const pending = createPendingRequest(definition.id, "connect", keyPair, options.redirectUrl);
|
|
516
|
-
const appIdentity = options.appIdentity ?? getDefaultIosWalletAppIdentity();
|
|
517
|
-
const url = new URL(definition.connectUrl);
|
|
518
|
-
url.searchParams.set("app_url", appIdentity.uri);
|
|
519
|
-
url.searchParams.set("dapp_encryption_public_key", pending.dappEncryptionPublicKey);
|
|
520
|
-
url.searchParams.set("redirect_link", pending.redirectUrl);
|
|
521
|
-
if (options.cluster && options.cluster !== "localnet") {
|
|
522
|
-
url.searchParams.set("cluster", options.cluster);
|
|
523
|
-
}
|
|
524
|
-
storePendingRequest(pending);
|
|
525
|
-
openIosWalletUrl(url.toString());
|
|
526
|
-
}
|
|
527
|
-
async function launchSignTransaction(definition, transaction, options) {
|
|
528
|
-
const response = await launchEncryptedWalletRequest(definition, "signTransaction", options, {
|
|
529
|
-
transaction: bs58__default.encode(serializeTransaction(transaction))
|
|
530
|
-
});
|
|
531
|
-
if (!response.transaction) {
|
|
532
|
-
throw new Error("iOS wallet did not return a signed transaction");
|
|
533
|
-
}
|
|
534
|
-
return response.transaction;
|
|
535
|
-
}
|
|
536
|
-
async function launchSignAllTransactions(definition, transactions, options) {
|
|
537
|
-
const response = await launchEncryptedWalletRequest(definition, "signAllTransactions", options, {
|
|
538
|
-
transactions: transactions.map((transaction) => bs58__default.encode(serializeTransaction(transaction)))
|
|
539
|
-
});
|
|
540
|
-
if (!response.transactions) {
|
|
541
|
-
throw new Error("iOS wallet did not return signed transactions");
|
|
542
|
-
}
|
|
543
|
-
return response.transactions;
|
|
544
|
-
}
|
|
545
|
-
async function launchSignAndSendTransaction(definition, transaction, sendOptions, options) {
|
|
546
|
-
const response = await launchEncryptedWalletRequest(
|
|
547
|
-
definition,
|
|
548
|
-
"signAndSendTransaction",
|
|
549
|
-
options,
|
|
550
|
-
{
|
|
551
|
-
transaction: bs58__default.encode(serializeTransaction(transaction)),
|
|
552
|
-
sendOptions
|
|
553
|
-
}
|
|
554
|
-
);
|
|
555
|
-
if (!response.signature) {
|
|
556
|
-
throw new Error("iOS wallet did not return a transaction signature");
|
|
557
|
-
}
|
|
558
|
-
return { signature: response.signature };
|
|
559
|
-
}
|
|
560
|
-
async function launchEncryptedWalletRequest(definition, method, options, payload) {
|
|
561
|
-
const session = getStoredSession(definition.id);
|
|
562
|
-
if (!session) {
|
|
563
|
-
throw new Error("Connect the iOS wallet before signing");
|
|
564
|
-
}
|
|
565
|
-
const methodUrl = getIosWalletMethodUrl(definition, method);
|
|
566
|
-
const pending = createPendingRequest(
|
|
567
|
-
definition.id,
|
|
568
|
-
method,
|
|
569
|
-
{
|
|
570
|
-
publicKey: bs58__default.decode(session.dappEncryptionPublicKey),
|
|
571
|
-
secretKey: bs58__default.decode(session.dappEncryptionSecretKey)
|
|
572
|
-
},
|
|
573
|
-
options.redirectUrl,
|
|
574
|
-
method === "signAllTransactions" && Array.isArray(payload.transactions) ? payload.transactions.length : void 0
|
|
575
|
-
);
|
|
576
|
-
const nonce = nacl.randomBytes(nacl.box.nonceLength);
|
|
577
|
-
const encryptedPayload = encryptPayload(
|
|
578
|
-
{ ...payload, session: session.session },
|
|
579
|
-
nonce,
|
|
580
|
-
bs58__default.decode(session.sharedSecret)
|
|
581
|
-
);
|
|
582
|
-
const url = new URL(methodUrl);
|
|
583
|
-
url.searchParams.set("dapp_encryption_public_key", session.dappEncryptionPublicKey);
|
|
584
|
-
url.searchParams.set("nonce", bs58__default.encode(nonce));
|
|
585
|
-
url.searchParams.set("redirect_link", pending.redirectUrl);
|
|
586
|
-
url.searchParams.set("payload", encryptedPayload);
|
|
587
|
-
storePendingRequest(pending);
|
|
588
|
-
openIosWalletUrl(url.toString());
|
|
589
|
-
return waitForRedirect();
|
|
590
|
-
}
|
|
591
|
-
function getIosWalletMethodUrl(definition, method) {
|
|
592
|
-
const url = definition[`${method}Url`];
|
|
593
|
-
if (!url) {
|
|
594
|
-
throw new Error(`${definition.name} does not support ${method} through iOS deeplinks`);
|
|
595
|
-
}
|
|
596
|
-
return url;
|
|
597
|
-
}
|
|
598
600
|
function getIosWalletDefinition(walletInfo) {
|
|
599
601
|
if (!isIosWalletDefinition(walletInfo.wallet)) {
|
|
600
602
|
throw new Error("Solana wallet info is not an iOS wallet");
|
|
@@ -392,6 +392,92 @@ function deserializeTransaction(source, bytes) {
|
|
|
392
392
|
return VersionedTransaction.deserialize(bytes);
|
|
393
393
|
}
|
|
394
394
|
|
|
395
|
+
function launchConnect(definition, options) {
|
|
396
|
+
const keyPair = nacl.box.keyPair();
|
|
397
|
+
const pending = createPendingRequest(definition.id, "connect", keyPair, options.redirectUrl);
|
|
398
|
+
const appIdentity = options.appIdentity ?? getDefaultIosWalletAppIdentity();
|
|
399
|
+
const url = new URL(definition.connectUrl);
|
|
400
|
+
url.searchParams.set("app_url", appIdentity.uri);
|
|
401
|
+
url.searchParams.set("dapp_encryption_public_key", pending.dappEncryptionPublicKey);
|
|
402
|
+
url.searchParams.set("redirect_link", pending.redirectUrl);
|
|
403
|
+
if (options.cluster && options.cluster !== "localnet") {
|
|
404
|
+
url.searchParams.set("cluster", options.cluster);
|
|
405
|
+
}
|
|
406
|
+
storePendingRequest(pending);
|
|
407
|
+
openIosWalletUrl(url.toString());
|
|
408
|
+
}
|
|
409
|
+
async function launchSignTransaction(definition, transaction, options) {
|
|
410
|
+
const response = await launchEncryptedWalletRequest(definition, "signTransaction", options, {
|
|
411
|
+
transaction: bs58.encode(serializeTransaction(transaction))
|
|
412
|
+
});
|
|
413
|
+
if (!response.transaction) {
|
|
414
|
+
throw new Error("iOS wallet did not return a signed transaction");
|
|
415
|
+
}
|
|
416
|
+
return response.transaction;
|
|
417
|
+
}
|
|
418
|
+
async function launchSignAllTransactions(definition, transactions, options) {
|
|
419
|
+
const response = await launchEncryptedWalletRequest(definition, "signAllTransactions", options, {
|
|
420
|
+
transactions: transactions.map((transaction) => bs58.encode(serializeTransaction(transaction)))
|
|
421
|
+
});
|
|
422
|
+
if (!response.transactions) {
|
|
423
|
+
throw new Error("iOS wallet did not return signed transactions");
|
|
424
|
+
}
|
|
425
|
+
return response.transactions;
|
|
426
|
+
}
|
|
427
|
+
async function launchSignAndSendTransaction(definition, transaction, sendOptions, options) {
|
|
428
|
+
const response = await launchEncryptedWalletRequest(
|
|
429
|
+
definition,
|
|
430
|
+
"signAndSendTransaction",
|
|
431
|
+
options,
|
|
432
|
+
{
|
|
433
|
+
transaction: bs58.encode(serializeTransaction(transaction)),
|
|
434
|
+
sendOptions
|
|
435
|
+
}
|
|
436
|
+
);
|
|
437
|
+
if (!response.signature) {
|
|
438
|
+
throw new Error("iOS wallet did not return a transaction signature");
|
|
439
|
+
}
|
|
440
|
+
return { signature: response.signature };
|
|
441
|
+
}
|
|
442
|
+
async function launchEncryptedWalletRequest(definition, method, options, payload) {
|
|
443
|
+
const session = getStoredSession(definition.id);
|
|
444
|
+
if (!session) {
|
|
445
|
+
throw new Error("Connect the iOS wallet before signing");
|
|
446
|
+
}
|
|
447
|
+
const methodUrl = getIosWalletMethodUrl(definition, method);
|
|
448
|
+
const pending = createPendingRequest(
|
|
449
|
+
definition.id,
|
|
450
|
+
method,
|
|
451
|
+
{
|
|
452
|
+
publicKey: bs58.decode(session.dappEncryptionPublicKey),
|
|
453
|
+
secretKey: bs58.decode(session.dappEncryptionSecretKey)
|
|
454
|
+
},
|
|
455
|
+
options.redirectUrl,
|
|
456
|
+
method === "signAllTransactions" && Array.isArray(payload.transactions) ? payload.transactions.length : void 0
|
|
457
|
+
);
|
|
458
|
+
const nonce = nacl.randomBytes(nacl.box.nonceLength);
|
|
459
|
+
const encryptedPayload = encryptPayload(
|
|
460
|
+
{ ...payload, session: session.session },
|
|
461
|
+
nonce,
|
|
462
|
+
bs58.decode(session.sharedSecret)
|
|
463
|
+
);
|
|
464
|
+
const url = new URL(methodUrl);
|
|
465
|
+
url.searchParams.set("dapp_encryption_public_key", session.dappEncryptionPublicKey);
|
|
466
|
+
url.searchParams.set("nonce", bs58.encode(nonce));
|
|
467
|
+
url.searchParams.set("redirect_link", pending.redirectUrl);
|
|
468
|
+
url.searchParams.set("payload", encryptedPayload);
|
|
469
|
+
storePendingRequest(pending);
|
|
470
|
+
openIosWalletUrl(url.toString());
|
|
471
|
+
return waitForRedirect();
|
|
472
|
+
}
|
|
473
|
+
function getIosWalletMethodUrl(definition, method) {
|
|
474
|
+
const url = definition[`${method}Url`];
|
|
475
|
+
if (!url) {
|
|
476
|
+
throw new Error(`${definition.name} does not support ${method} through iOS deeplinks`);
|
|
477
|
+
}
|
|
478
|
+
return url;
|
|
479
|
+
}
|
|
480
|
+
|
|
395
481
|
function getSolanaIosWallets(options = {}) {
|
|
396
482
|
if (!isSolanaIosBrowserWalletSupported()) {
|
|
397
483
|
return [];
|
|
@@ -409,6 +495,7 @@ function getSolanaIosWallets(options = {}) {
|
|
|
409
495
|
callbackUrl,
|
|
410
496
|
capabilities: {
|
|
411
497
|
connect: true,
|
|
498
|
+
disconnect: true,
|
|
412
499
|
signTransaction: Boolean(wallet.signTransactionUrl),
|
|
413
500
|
signAllTransactions: Boolean(wallet.signAllTransactionsUrl),
|
|
414
501
|
signAndSendTransaction: Boolean(wallet.signAndSendTransactionUrl)
|
|
@@ -491,91 +578,6 @@ function adaptSolanaIosWallet(walletInfo, options = {}) {
|
|
|
491
578
|
function isSolanaIosWalletInfo(walletInfo) {
|
|
492
579
|
return walletInfo.source === "deep-link" && isIosWalletDefinition(walletInfo.wallet);
|
|
493
580
|
}
|
|
494
|
-
function launchConnect(definition, options) {
|
|
495
|
-
const keyPair = nacl.box.keyPair();
|
|
496
|
-
const pending = createPendingRequest(definition.id, "connect", keyPair, options.redirectUrl);
|
|
497
|
-
const appIdentity = options.appIdentity ?? getDefaultIosWalletAppIdentity();
|
|
498
|
-
const url = new URL(definition.connectUrl);
|
|
499
|
-
url.searchParams.set("app_url", appIdentity.uri);
|
|
500
|
-
url.searchParams.set("dapp_encryption_public_key", pending.dappEncryptionPublicKey);
|
|
501
|
-
url.searchParams.set("redirect_link", pending.redirectUrl);
|
|
502
|
-
if (options.cluster && options.cluster !== "localnet") {
|
|
503
|
-
url.searchParams.set("cluster", options.cluster);
|
|
504
|
-
}
|
|
505
|
-
storePendingRequest(pending);
|
|
506
|
-
openIosWalletUrl(url.toString());
|
|
507
|
-
}
|
|
508
|
-
async function launchSignTransaction(definition, transaction, options) {
|
|
509
|
-
const response = await launchEncryptedWalletRequest(definition, "signTransaction", options, {
|
|
510
|
-
transaction: bs58.encode(serializeTransaction(transaction))
|
|
511
|
-
});
|
|
512
|
-
if (!response.transaction) {
|
|
513
|
-
throw new Error("iOS wallet did not return a signed transaction");
|
|
514
|
-
}
|
|
515
|
-
return response.transaction;
|
|
516
|
-
}
|
|
517
|
-
async function launchSignAllTransactions(definition, transactions, options) {
|
|
518
|
-
const response = await launchEncryptedWalletRequest(definition, "signAllTransactions", options, {
|
|
519
|
-
transactions: transactions.map((transaction) => bs58.encode(serializeTransaction(transaction)))
|
|
520
|
-
});
|
|
521
|
-
if (!response.transactions) {
|
|
522
|
-
throw new Error("iOS wallet did not return signed transactions");
|
|
523
|
-
}
|
|
524
|
-
return response.transactions;
|
|
525
|
-
}
|
|
526
|
-
async function launchSignAndSendTransaction(definition, transaction, sendOptions, options) {
|
|
527
|
-
const response = await launchEncryptedWalletRequest(
|
|
528
|
-
definition,
|
|
529
|
-
"signAndSendTransaction",
|
|
530
|
-
options,
|
|
531
|
-
{
|
|
532
|
-
transaction: bs58.encode(serializeTransaction(transaction)),
|
|
533
|
-
sendOptions
|
|
534
|
-
}
|
|
535
|
-
);
|
|
536
|
-
if (!response.signature) {
|
|
537
|
-
throw new Error("iOS wallet did not return a transaction signature");
|
|
538
|
-
}
|
|
539
|
-
return { signature: response.signature };
|
|
540
|
-
}
|
|
541
|
-
async function launchEncryptedWalletRequest(definition, method, options, payload) {
|
|
542
|
-
const session = getStoredSession(definition.id);
|
|
543
|
-
if (!session) {
|
|
544
|
-
throw new Error("Connect the iOS wallet before signing");
|
|
545
|
-
}
|
|
546
|
-
const methodUrl = getIosWalletMethodUrl(definition, method);
|
|
547
|
-
const pending = createPendingRequest(
|
|
548
|
-
definition.id,
|
|
549
|
-
method,
|
|
550
|
-
{
|
|
551
|
-
publicKey: bs58.decode(session.dappEncryptionPublicKey),
|
|
552
|
-
secretKey: bs58.decode(session.dappEncryptionSecretKey)
|
|
553
|
-
},
|
|
554
|
-
options.redirectUrl,
|
|
555
|
-
method === "signAllTransactions" && Array.isArray(payload.transactions) ? payload.transactions.length : void 0
|
|
556
|
-
);
|
|
557
|
-
const nonce = nacl.randomBytes(nacl.box.nonceLength);
|
|
558
|
-
const encryptedPayload = encryptPayload(
|
|
559
|
-
{ ...payload, session: session.session },
|
|
560
|
-
nonce,
|
|
561
|
-
bs58.decode(session.sharedSecret)
|
|
562
|
-
);
|
|
563
|
-
const url = new URL(methodUrl);
|
|
564
|
-
url.searchParams.set("dapp_encryption_public_key", session.dappEncryptionPublicKey);
|
|
565
|
-
url.searchParams.set("nonce", bs58.encode(nonce));
|
|
566
|
-
url.searchParams.set("redirect_link", pending.redirectUrl);
|
|
567
|
-
url.searchParams.set("payload", encryptedPayload);
|
|
568
|
-
storePendingRequest(pending);
|
|
569
|
-
openIosWalletUrl(url.toString());
|
|
570
|
-
return waitForRedirect();
|
|
571
|
-
}
|
|
572
|
-
function getIosWalletMethodUrl(definition, method) {
|
|
573
|
-
const url = definition[`${method}Url`];
|
|
574
|
-
if (!url) {
|
|
575
|
-
throw new Error(`${definition.name} does not support ${method} through iOS deeplinks`);
|
|
576
|
-
}
|
|
577
|
-
return url;
|
|
578
|
-
}
|
|
579
581
|
function getIosWalletDefinition(walletInfo) {
|
|
580
582
|
if (!isIosWalletDefinition(walletInfo.wallet)) {
|
|
581
583
|
throw new Error("Solana wallet info is not an iOS wallet");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StandardEvents, StandardDisconnect, StandardConnect } from '@wallet-standard/features';
|
|
2
|
-
import { SolanaSignAndSendTransaction, SolanaSignTransaction } from '@solana/wallet-standard-features';
|
|
2
|
+
import { SolanaSignAndSendTransaction, SolanaSignTransaction, SolanaSignMessage } from '@solana/wallet-standard-features';
|
|
3
3
|
import { Transaction, VersionedTransaction, PublicKey } from '@solana/web3-compat';
|
|
4
4
|
import bs58 from 'bs58';
|
|
5
5
|
import { getWallets } from '@wallet-standard/app';
|
|
@@ -23,6 +23,9 @@ function hasSignTransaction(wallet) {
|
|
|
23
23
|
function hasSignAndSendTransaction(wallet) {
|
|
24
24
|
return SolanaSignAndSendTransaction in wallet.features;
|
|
25
25
|
}
|
|
26
|
+
function hasSignMessage(wallet) {
|
|
27
|
+
return SolanaSignMessage in wallet.features;
|
|
28
|
+
}
|
|
26
29
|
|
|
27
30
|
function serializeTransaction(transaction) {
|
|
28
31
|
if (transaction instanceof Transaction) {
|
|
@@ -107,6 +110,17 @@ function adaptSolanaStandardWallet(walletInfo, options = {}) {
|
|
|
107
110
|
options.onChange?.();
|
|
108
111
|
}
|
|
109
112
|
},
|
|
113
|
+
signMessage: hasSignMessage(wallet) ? async (message) => {
|
|
114
|
+
const activeAccount = getActiveAccount(account);
|
|
115
|
+
const [result] = await wallet.features[SolanaSignMessage].signMessage({
|
|
116
|
+
account: activeAccount,
|
|
117
|
+
message
|
|
118
|
+
});
|
|
119
|
+
if (!result) {
|
|
120
|
+
throw new Error("Solana wallet did not return a message signature");
|
|
121
|
+
}
|
|
122
|
+
return result;
|
|
123
|
+
} : void 0,
|
|
110
124
|
signTransaction: hasSignTransaction(wallet) ? async (transaction) => {
|
|
111
125
|
const activeAccount = getActiveAccount(account);
|
|
112
126
|
const [result] = await wallet.features[SolanaSignTransaction].signTransaction({
|
|
@@ -208,6 +222,14 @@ function createSolanaWalletInfo(wallet) {
|
|
|
208
222
|
platform: isMobileWallet ? "mobile" : "browser",
|
|
209
223
|
source: isMobileWallet ? "mobile-wallet-adapter" : "wallet-standard",
|
|
210
224
|
appUrl: getWalletUrl(wallet),
|
|
225
|
+
capabilities: {
|
|
226
|
+
connect: true,
|
|
227
|
+
disconnect: true,
|
|
228
|
+
signMessage: hasSignMessage(wallet),
|
|
229
|
+
signTransaction: hasSignTransaction(wallet),
|
|
230
|
+
signAllTransactions: hasSignTransaction(wallet),
|
|
231
|
+
signAndSendTransaction: hasSignAndSendTransaction(wallet)
|
|
232
|
+
},
|
|
211
233
|
accounts: wallet.accounts.map((account) => ({
|
|
212
234
|
address: account.address,
|
|
213
235
|
publicKey: Uint8Array.from(account.publicKey),
|
|
@@ -29,6 +29,9 @@ function hasSignTransaction(wallet) {
|
|
|
29
29
|
function hasSignAndSendTransaction(wallet) {
|
|
30
30
|
return walletStandardFeatures.SolanaSignAndSendTransaction in wallet.features;
|
|
31
31
|
}
|
|
32
|
+
function hasSignMessage(wallet) {
|
|
33
|
+
return walletStandardFeatures.SolanaSignMessage in wallet.features;
|
|
34
|
+
}
|
|
32
35
|
|
|
33
36
|
function serializeTransaction(transaction) {
|
|
34
37
|
if (transaction instanceof web3Compat.Transaction) {
|
|
@@ -113,6 +116,17 @@ function adaptSolanaStandardWallet(walletInfo, options = {}) {
|
|
|
113
116
|
options.onChange?.();
|
|
114
117
|
}
|
|
115
118
|
},
|
|
119
|
+
signMessage: hasSignMessage(wallet) ? async (message) => {
|
|
120
|
+
const activeAccount = getActiveAccount(account);
|
|
121
|
+
const [result] = await wallet.features[walletStandardFeatures.SolanaSignMessage].signMessage({
|
|
122
|
+
account: activeAccount,
|
|
123
|
+
message
|
|
124
|
+
});
|
|
125
|
+
if (!result) {
|
|
126
|
+
throw new Error("Solana wallet did not return a message signature");
|
|
127
|
+
}
|
|
128
|
+
return result;
|
|
129
|
+
} : void 0,
|
|
116
130
|
signTransaction: hasSignTransaction(wallet) ? async (transaction) => {
|
|
117
131
|
const activeAccount = getActiveAccount(account);
|
|
118
132
|
const [result] = await wallet.features[walletStandardFeatures.SolanaSignTransaction].signTransaction({
|
|
@@ -214,6 +228,14 @@ function createSolanaWalletInfo(wallet) {
|
|
|
214
228
|
platform: isMobileWallet ? "mobile" : "browser",
|
|
215
229
|
source: isMobileWallet ? "mobile-wallet-adapter" : "wallet-standard",
|
|
216
230
|
appUrl: getWalletUrl(wallet),
|
|
231
|
+
capabilities: {
|
|
232
|
+
connect: true,
|
|
233
|
+
disconnect: true,
|
|
234
|
+
signMessage: hasSignMessage(wallet),
|
|
235
|
+
signTransaction: hasSignTransaction(wallet),
|
|
236
|
+
signAllTransactions: hasSignTransaction(wallet),
|
|
237
|
+
signAndSendTransaction: hasSignAndSendTransaction(wallet)
|
|
238
|
+
},
|
|
217
239
|
accounts: wallet.accounts.map((account) => ({
|
|
218
240
|
address: account.address,
|
|
219
241
|
publicKey: Uint8Array.from(account.publicKey),
|
package/dist/types.d.cts
CHANGED
|
@@ -16,6 +16,10 @@ interface SolanaContext {
|
|
|
16
16
|
connection: Connection;
|
|
17
17
|
}
|
|
18
18
|
type SolanaTransaction = Transaction | VersionedTransaction;
|
|
19
|
+
interface SolanaSignMessageResult {
|
|
20
|
+
signedMessage: Uint8Array;
|
|
21
|
+
signature: Uint8Array;
|
|
22
|
+
}
|
|
19
23
|
interface SolanaWallet {
|
|
20
24
|
publicKey: PublicKey | null;
|
|
21
25
|
connected: boolean;
|
|
@@ -25,6 +29,7 @@ interface SolanaWallet {
|
|
|
25
29
|
source?: SolanaWalletInfo["source"];
|
|
26
30
|
connect: () => Promise<void>;
|
|
27
31
|
disconnect: () => Promise<void>;
|
|
32
|
+
signMessage?: (message: Uint8Array) => Promise<SolanaSignMessageResult>;
|
|
28
33
|
signTransaction?: <T extends SolanaTransaction>(transaction: T) => Promise<T>;
|
|
29
34
|
signAllTransactions?: <T extends SolanaTransaction>(transactions: T[]) => Promise<T[]>;
|
|
30
35
|
signAndSendTransaction?: (transaction: SolanaTransaction, options?: SendOptions) => Promise<{
|
|
@@ -42,6 +47,8 @@ interface SolanaWalletInfo {
|
|
|
42
47
|
callbackUrl?: string;
|
|
43
48
|
capabilities?: {
|
|
44
49
|
connect?: boolean;
|
|
50
|
+
disconnect?: boolean;
|
|
51
|
+
signMessage?: boolean;
|
|
45
52
|
signTransaction?: boolean;
|
|
46
53
|
signAllTransactions?: boolean;
|
|
47
54
|
signAndSendTransaction?: boolean;
|
|
@@ -68,4 +75,4 @@ interface TransactionConfirmation {
|
|
|
68
75
|
result: RpcResponseAndContext<SignatureResult>;
|
|
69
76
|
}
|
|
70
77
|
|
|
71
|
-
export type { ConfirmTransactionOptions, SendTransactionOptions, SolanaChain, SolanaCluster, SolanaConfig, SolanaContext, SolanaTransaction, SolanaWallet, SolanaWalletInfo, TransactionConfirmation };
|
|
78
|
+
export type { ConfirmTransactionOptions, SendTransactionOptions, SolanaChain, SolanaCluster, SolanaConfig, SolanaContext, SolanaSignMessageResult, SolanaTransaction, SolanaWallet, SolanaWalletInfo, TransactionConfirmation };
|
package/dist/types.d.mts
CHANGED
|
@@ -16,6 +16,10 @@ interface SolanaContext {
|
|
|
16
16
|
connection: Connection;
|
|
17
17
|
}
|
|
18
18
|
type SolanaTransaction = Transaction | VersionedTransaction;
|
|
19
|
+
interface SolanaSignMessageResult {
|
|
20
|
+
signedMessage: Uint8Array;
|
|
21
|
+
signature: Uint8Array;
|
|
22
|
+
}
|
|
19
23
|
interface SolanaWallet {
|
|
20
24
|
publicKey: PublicKey | null;
|
|
21
25
|
connected: boolean;
|
|
@@ -25,6 +29,7 @@ interface SolanaWallet {
|
|
|
25
29
|
source?: SolanaWalletInfo["source"];
|
|
26
30
|
connect: () => Promise<void>;
|
|
27
31
|
disconnect: () => Promise<void>;
|
|
32
|
+
signMessage?: (message: Uint8Array) => Promise<SolanaSignMessageResult>;
|
|
28
33
|
signTransaction?: <T extends SolanaTransaction>(transaction: T) => Promise<T>;
|
|
29
34
|
signAllTransactions?: <T extends SolanaTransaction>(transactions: T[]) => Promise<T[]>;
|
|
30
35
|
signAndSendTransaction?: (transaction: SolanaTransaction, options?: SendOptions) => Promise<{
|
|
@@ -42,6 +47,8 @@ interface SolanaWalletInfo {
|
|
|
42
47
|
callbackUrl?: string;
|
|
43
48
|
capabilities?: {
|
|
44
49
|
connect?: boolean;
|
|
50
|
+
disconnect?: boolean;
|
|
51
|
+
signMessage?: boolean;
|
|
45
52
|
signTransaction?: boolean;
|
|
46
53
|
signAllTransactions?: boolean;
|
|
47
54
|
signAndSendTransaction?: boolean;
|
|
@@ -68,4 +75,4 @@ interface TransactionConfirmation {
|
|
|
68
75
|
result: RpcResponseAndContext<SignatureResult>;
|
|
69
76
|
}
|
|
70
77
|
|
|
71
|
-
export type { ConfirmTransactionOptions, SendTransactionOptions, SolanaChain, SolanaCluster, SolanaConfig, SolanaContext, SolanaTransaction, SolanaWallet, SolanaWalletInfo, TransactionConfirmation };
|
|
78
|
+
export type { ConfirmTransactionOptions, SendTransactionOptions, SolanaChain, SolanaCluster, SolanaConfig, SolanaContext, SolanaSignMessageResult, SolanaTransaction, SolanaWallet, SolanaWalletInfo, TransactionConfirmation };
|
package/dist/types.d.ts
CHANGED
|
@@ -16,6 +16,10 @@ interface SolanaContext {
|
|
|
16
16
|
connection: Connection;
|
|
17
17
|
}
|
|
18
18
|
type SolanaTransaction = Transaction | VersionedTransaction;
|
|
19
|
+
interface SolanaSignMessageResult {
|
|
20
|
+
signedMessage: Uint8Array;
|
|
21
|
+
signature: Uint8Array;
|
|
22
|
+
}
|
|
19
23
|
interface SolanaWallet {
|
|
20
24
|
publicKey: PublicKey | null;
|
|
21
25
|
connected: boolean;
|
|
@@ -25,6 +29,7 @@ interface SolanaWallet {
|
|
|
25
29
|
source?: SolanaWalletInfo["source"];
|
|
26
30
|
connect: () => Promise<void>;
|
|
27
31
|
disconnect: () => Promise<void>;
|
|
32
|
+
signMessage?: (message: Uint8Array) => Promise<SolanaSignMessageResult>;
|
|
28
33
|
signTransaction?: <T extends SolanaTransaction>(transaction: T) => Promise<T>;
|
|
29
34
|
signAllTransactions?: <T extends SolanaTransaction>(transactions: T[]) => Promise<T[]>;
|
|
30
35
|
signAndSendTransaction?: (transaction: SolanaTransaction, options?: SendOptions) => Promise<{
|
|
@@ -42,6 +47,8 @@ interface SolanaWalletInfo {
|
|
|
42
47
|
callbackUrl?: string;
|
|
43
48
|
capabilities?: {
|
|
44
49
|
connect?: boolean;
|
|
50
|
+
disconnect?: boolean;
|
|
51
|
+
signMessage?: boolean;
|
|
45
52
|
signTransaction?: boolean;
|
|
46
53
|
signAllTransactions?: boolean;
|
|
47
54
|
signAndSendTransaction?: boolean;
|
|
@@ -68,4 +75,4 @@ interface TransactionConfirmation {
|
|
|
68
75
|
result: RpcResponseAndContext<SignatureResult>;
|
|
69
76
|
}
|
|
70
77
|
|
|
71
|
-
export type { ConfirmTransactionOptions, SendTransactionOptions, SolanaChain, SolanaCluster, SolanaConfig, SolanaContext, SolanaTransaction, SolanaWallet, SolanaWalletInfo, TransactionConfirmation };
|
|
78
|
+
export type { ConfirmTransactionOptions, SendTransactionOptions, SolanaChain, SolanaCluster, SolanaConfig, SolanaContext, SolanaSignMessageResult, SolanaTransaction, SolanaWallet, SolanaWalletInfo, TransactionConfirmation };
|
package/dist/wallet-standard.cjs
CHANGED
package/dist/wallet-standard.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { S as SOLANA_CHAINS, a as SOLANA_MOBILE_WALLET_ADAPTER_WALLET_NAME, b as adaptSolanaStandardWallet, g as getRegisteredSolanaWallets, c as getSolanaChain, i as isSolanaStandardWallet, s as subscribeSolanaWallets } from './shared/core.
|
|
1
|
+
export { S as SOLANA_CHAINS, a as SOLANA_MOBILE_WALLET_ADAPTER_WALLET_NAME, b as adaptSolanaStandardWallet, g as getRegisteredSolanaWallets, c as getSolanaChain, i as isSolanaStandardWallet, s as subscribeSolanaWallets } from './shared/core.DSMNiaHD.mjs';
|
|
2
2
|
import '@wallet-standard/features';
|
|
3
3
|
import '@solana/wallet-standard-features';
|
|
4
4
|
import '@solana/web3-compat';
|
package/dist/wallet.cjs
CHANGED
|
@@ -1,20 +1,41 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
class SolanaWalletError extends Error {
|
|
4
|
+
constructor(code, message) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.code = code;
|
|
7
|
+
this.name = "SolanaWalletError";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
3
10
|
function isWalletConnected(wallet) {
|
|
4
11
|
return Boolean(wallet?.connected && wallet.publicKey);
|
|
5
12
|
}
|
|
6
13
|
function assertWalletConnected(wallet) {
|
|
7
14
|
if (!isWalletConnected(wallet)) {
|
|
8
|
-
throw new
|
|
15
|
+
throw new SolanaWalletError("WALLET_NOT_CONNECTED", "Solana wallet is not connected");
|
|
9
16
|
}
|
|
10
17
|
}
|
|
11
18
|
function assertWalletCanSign(wallet) {
|
|
12
19
|
assertWalletConnected(wallet);
|
|
13
20
|
if (!wallet.signTransaction) {
|
|
14
|
-
throw new
|
|
21
|
+
throw new SolanaWalletError(
|
|
22
|
+
"WALLET_SIGN_TRANSACTION_UNSUPPORTED",
|
|
23
|
+
"Solana wallet does not support signTransaction"
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function assertWalletCanSignMessage(wallet) {
|
|
28
|
+
assertWalletConnected(wallet);
|
|
29
|
+
if (!wallet.signMessage) {
|
|
30
|
+
throw new SolanaWalletError(
|
|
31
|
+
"WALLET_SIGN_MESSAGE_UNSUPPORTED",
|
|
32
|
+
"Solana wallet does not support signMessage"
|
|
33
|
+
);
|
|
15
34
|
}
|
|
16
35
|
}
|
|
17
36
|
|
|
37
|
+
exports.SolanaWalletError = SolanaWalletError;
|
|
18
38
|
exports.assertWalletCanSign = assertWalletCanSign;
|
|
39
|
+
exports.assertWalletCanSignMessage = assertWalletCanSignMessage;
|
|
19
40
|
exports.assertWalletConnected = assertWalletConnected;
|
|
20
41
|
exports.isWalletConnected = isWalletConnected;
|
package/dist/wallet.d.cts
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import { SolanaWallet } from './types.cjs';
|
|
2
2
|
import '@solana/web3-compat';
|
|
3
3
|
|
|
4
|
+
type SolanaWalletErrorCode = "WALLET_NOT_CONNECTED" | "WALLET_SIGN_MESSAGE_UNSUPPORTED" | "WALLET_SIGN_TRANSACTION_UNSUPPORTED";
|
|
5
|
+
declare class SolanaWalletError extends Error {
|
|
6
|
+
readonly code: SolanaWalletErrorCode;
|
|
7
|
+
constructor(code: SolanaWalletErrorCode, message: string);
|
|
8
|
+
}
|
|
4
9
|
declare function isWalletConnected(wallet: Pick<SolanaWallet, "connected" | "publicKey"> | null | undefined): boolean;
|
|
5
10
|
declare function assertWalletConnected(wallet: SolanaWallet | null | undefined): asserts wallet is SolanaWallet & {
|
|
6
11
|
publicKey: NonNullable<SolanaWallet["publicKey"]>;
|
|
7
12
|
};
|
|
8
13
|
declare function assertWalletCanSign(wallet: SolanaWallet | null | undefined): asserts wallet is SolanaWallet & Required<Pick<SolanaWallet, "signTransaction">>;
|
|
14
|
+
declare function assertWalletCanSignMessage(wallet: SolanaWallet | null | undefined): asserts wallet is SolanaWallet & Required<Pick<SolanaWallet, "signMessage">>;
|
|
9
15
|
|
|
10
|
-
export { assertWalletCanSign, assertWalletConnected, isWalletConnected };
|
|
16
|
+
export { SolanaWalletError, assertWalletCanSign, assertWalletCanSignMessage, assertWalletConnected, isWalletConnected };
|
|
17
|
+
export type { SolanaWalletErrorCode };
|
package/dist/wallet.d.mts
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import { SolanaWallet } from './types.mjs';
|
|
2
2
|
import '@solana/web3-compat';
|
|
3
3
|
|
|
4
|
+
type SolanaWalletErrorCode = "WALLET_NOT_CONNECTED" | "WALLET_SIGN_MESSAGE_UNSUPPORTED" | "WALLET_SIGN_TRANSACTION_UNSUPPORTED";
|
|
5
|
+
declare class SolanaWalletError extends Error {
|
|
6
|
+
readonly code: SolanaWalletErrorCode;
|
|
7
|
+
constructor(code: SolanaWalletErrorCode, message: string);
|
|
8
|
+
}
|
|
4
9
|
declare function isWalletConnected(wallet: Pick<SolanaWallet, "connected" | "publicKey"> | null | undefined): boolean;
|
|
5
10
|
declare function assertWalletConnected(wallet: SolanaWallet | null | undefined): asserts wallet is SolanaWallet & {
|
|
6
11
|
publicKey: NonNullable<SolanaWallet["publicKey"]>;
|
|
7
12
|
};
|
|
8
13
|
declare function assertWalletCanSign(wallet: SolanaWallet | null | undefined): asserts wallet is SolanaWallet & Required<Pick<SolanaWallet, "signTransaction">>;
|
|
14
|
+
declare function assertWalletCanSignMessage(wallet: SolanaWallet | null | undefined): asserts wallet is SolanaWallet & Required<Pick<SolanaWallet, "signMessage">>;
|
|
9
15
|
|
|
10
|
-
export { assertWalletCanSign, assertWalletConnected, isWalletConnected };
|
|
16
|
+
export { SolanaWalletError, assertWalletCanSign, assertWalletCanSignMessage, assertWalletConnected, isWalletConnected };
|
|
17
|
+
export type { SolanaWalletErrorCode };
|
package/dist/wallet.d.ts
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import { SolanaWallet } from './types.js';
|
|
2
2
|
import '@solana/web3-compat';
|
|
3
3
|
|
|
4
|
+
type SolanaWalletErrorCode = "WALLET_NOT_CONNECTED" | "WALLET_SIGN_MESSAGE_UNSUPPORTED" | "WALLET_SIGN_TRANSACTION_UNSUPPORTED";
|
|
5
|
+
declare class SolanaWalletError extends Error {
|
|
6
|
+
readonly code: SolanaWalletErrorCode;
|
|
7
|
+
constructor(code: SolanaWalletErrorCode, message: string);
|
|
8
|
+
}
|
|
4
9
|
declare function isWalletConnected(wallet: Pick<SolanaWallet, "connected" | "publicKey"> | null | undefined): boolean;
|
|
5
10
|
declare function assertWalletConnected(wallet: SolanaWallet | null | undefined): asserts wallet is SolanaWallet & {
|
|
6
11
|
publicKey: NonNullable<SolanaWallet["publicKey"]>;
|
|
7
12
|
};
|
|
8
13
|
declare function assertWalletCanSign(wallet: SolanaWallet | null | undefined): asserts wallet is SolanaWallet & Required<Pick<SolanaWallet, "signTransaction">>;
|
|
14
|
+
declare function assertWalletCanSignMessage(wallet: SolanaWallet | null | undefined): asserts wallet is SolanaWallet & Required<Pick<SolanaWallet, "signMessage">>;
|
|
9
15
|
|
|
10
|
-
export { assertWalletCanSign, assertWalletConnected, isWalletConnected };
|
|
16
|
+
export { SolanaWalletError, assertWalletCanSign, assertWalletCanSignMessage, assertWalletConnected, isWalletConnected };
|
|
17
|
+
export type { SolanaWalletErrorCode };
|
package/dist/wallet.mjs
CHANGED
|
@@ -1,16 +1,35 @@
|
|
|
1
|
+
class SolanaWalletError extends Error {
|
|
2
|
+
constructor(code, message) {
|
|
3
|
+
super(message);
|
|
4
|
+
this.code = code;
|
|
5
|
+
this.name = "SolanaWalletError";
|
|
6
|
+
}
|
|
7
|
+
}
|
|
1
8
|
function isWalletConnected(wallet) {
|
|
2
9
|
return Boolean(wallet?.connected && wallet.publicKey);
|
|
3
10
|
}
|
|
4
11
|
function assertWalletConnected(wallet) {
|
|
5
12
|
if (!isWalletConnected(wallet)) {
|
|
6
|
-
throw new
|
|
13
|
+
throw new SolanaWalletError("WALLET_NOT_CONNECTED", "Solana wallet is not connected");
|
|
7
14
|
}
|
|
8
15
|
}
|
|
9
16
|
function assertWalletCanSign(wallet) {
|
|
10
17
|
assertWalletConnected(wallet);
|
|
11
18
|
if (!wallet.signTransaction) {
|
|
12
|
-
throw new
|
|
19
|
+
throw new SolanaWalletError(
|
|
20
|
+
"WALLET_SIGN_TRANSACTION_UNSUPPORTED",
|
|
21
|
+
"Solana wallet does not support signTransaction"
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function assertWalletCanSignMessage(wallet) {
|
|
26
|
+
assertWalletConnected(wallet);
|
|
27
|
+
if (!wallet.signMessage) {
|
|
28
|
+
throw new SolanaWalletError(
|
|
29
|
+
"WALLET_SIGN_MESSAGE_UNSUPPORTED",
|
|
30
|
+
"Solana wallet does not support signMessage"
|
|
31
|
+
);
|
|
13
32
|
}
|
|
14
33
|
}
|
|
15
34
|
|
|
16
|
-
export { assertWalletCanSign, assertWalletConnected, isWalletConnected };
|
|
35
|
+
export { SolanaWalletError, assertWalletCanSign, assertWalletCanSignMessage, assertWalletConnected, isWalletConnected };
|