@vue-solana/core 1.1.0 → 2.0.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 +44 -35
- package/dist/address.cjs +10 -10
- package/dist/address.d.cts +14 -10
- package/dist/address.d.mts +14 -10
- package/dist/address.d.ts +14 -10
- package/dist/address.mjs +10 -10
- package/dist/buffer-polyfill.d.cts +0 -1
- package/dist/buffer-polyfill.d.mts +0 -1
- package/dist/buffer-polyfill.d.ts +0 -1
- package/dist/clusters.d.cts +2 -4
- package/dist/clusters.d.mts +2 -4
- package/dist/clusters.d.ts +2 -4
- package/dist/index.cjs +9 -19
- package/dist/index.d.cts +5 -8
- package/dist/index.d.mts +5 -8
- package/dist/index.d.ts +5 -8
- package/dist/index.mjs +7 -6
- package/dist/ios-wallet.cjs +2 -2
- package/dist/ios-wallet.d.cts +2 -4
- package/dist/ios-wallet.d.mts +2 -4
- package/dist/ios-wallet.d.ts +2 -4
- package/dist/ios-wallet.mjs +2 -2
- package/dist/kit.cjs +21 -0
- package/dist/kit.d.cts +2 -0
- package/dist/kit.d.mts +2 -0
- package/dist/kit.d.ts +2 -0
- package/dist/kit.mjs +18 -0
- package/dist/mobile-wallet.d.cts +2 -4
- package/dist/mobile-wallet.d.mts +2 -4
- package/dist/mobile-wallet.d.ts +2 -4
- package/dist/rpc.cjs +4 -12
- package/dist/rpc.d.cts +3 -6
- package/dist/rpc.d.mts +3 -6
- package/dist/rpc.d.ts +3 -6
- package/dist/rpc.mjs +5 -12
- package/dist/shared/{core.BBMCTQpw.mjs → core.BOHiMZiM.mjs} +7 -30
- package/dist/shared/{core.Ch_Z7_17.mjs → core.BwW4HVQI.mjs} +12 -28
- package/dist/shared/{core.BsekSwcZ.cjs → core.Cb48vQvC.cjs} +12 -28
- package/dist/shared/{core.BU9rgxEj.cjs → core.Cu_gaUSn.cjs} +20 -43
- package/dist/shared/core.DMgTrB_2.d.cts +102 -0
- package/dist/shared/core.DMgTrB_2.d.mts +102 -0
- package/dist/shared/core.DMgTrB_2.d.ts +102 -0
- package/dist/token-accounts.cjs +44 -28
- package/dist/token-accounts.d.cts +26 -8
- package/dist/token-accounts.d.mts +26 -8
- package/dist/token-accounts.d.ts +26 -8
- package/dist/token-accounts.mjs +44 -28
- package/dist/transaction.cjs +50 -31
- package/dist/transaction.d.cts +14 -6
- package/dist/transaction.d.mts +14 -6
- package/dist/transaction.d.ts +14 -6
- package/dist/transaction.mjs +51 -32
- package/dist/types.d.cts +2 -80
- package/dist/types.d.mts +2 -80
- package/dist/types.d.ts +2 -80
- package/dist/wallet-standard.cjs +1 -4
- package/dist/wallet-standard.d.cts +2 -4
- package/dist/wallet-standard.d.mts +2 -4
- package/dist/wallet-standard.d.ts +2 -4
- package/dist/wallet-standard.mjs +1 -4
- package/dist/wallet.d.cts +2 -4
- package/dist/wallet.d.mts +2 -4
- package/dist/wallet.d.ts +2 -4
- package/package.json +9 -14
- package/dist/spl-token.cjs +0 -12
- package/dist/spl-token.d.cts +0 -4
- package/dist/spl-token.d.mts +0 -4
- package/dist/spl-token.d.ts +0 -4
- package/dist/spl-token.mjs +0 -1
- package/dist/web3.cjs +0 -13
- package/dist/web3.d.cts +0 -3
- package/dist/web3.d.mts +0 -3
- package/dist/web3.d.ts +0 -3
- package/dist/web3.mjs +0 -1
- package/types/web3-compat.d.ts +0 -140
package/dist/ios-wallet.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { SolanaChain, SolanaCluster, SolanaWalletInfo, SolanaWallet } from './types.js';
|
|
4
|
-
import '@solana/web3-compat';
|
|
1
|
+
import { a as SolanaChain, c as SolanaCluster, i as SolanaWalletInfo, h as SolanaWallet } from './shared/core.DMgTrB_2.js';
|
|
2
|
+
import '@solana/kit';
|
|
5
3
|
|
|
6
4
|
interface SolanaIosWalletAppIdentity {
|
|
7
5
|
name: string;
|
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.
|
|
2
|
-
import '@solana/
|
|
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.BwW4HVQI.mjs';
|
|
2
|
+
import '@solana/kit';
|
|
3
3
|
import 'bs58';
|
|
4
4
|
import 'tweetnacl';
|
package/dist/kit.cjs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const kit = require('@solana/kit');
|
|
4
|
+
const kitPluginRpc = require('@solana/kit-plugin-rpc');
|
|
5
|
+
const clusters = require('./clusters.cjs');
|
|
6
|
+
|
|
7
|
+
function createSolanaClient(config = {}) {
|
|
8
|
+
const cluster = config.cluster ?? clusters.DEFAULT_CLUSTER;
|
|
9
|
+
const endpoint = config.endpoint ?? clusters.getClusterEndpoint(cluster);
|
|
10
|
+
const wsEndpoint = config.wsEndpoint ?? (config.endpoint ? clusters.getWebSocketEndpoint(endpoint) : clusters.getClusterWebSocketEndpoint(cluster));
|
|
11
|
+
return kit.createClient().use(
|
|
12
|
+
kitPluginRpc.solanaRpcConnection({
|
|
13
|
+
rpcUrl: endpoint,
|
|
14
|
+
rpcSubscriptionsUrl: wsEndpoint
|
|
15
|
+
})
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
exports.address = kit.address;
|
|
20
|
+
exports.lamports = kit.lamports;
|
|
21
|
+
exports.createSolanaClient = createSolanaClient;
|
package/dist/kit.d.cts
ADDED
package/dist/kit.d.mts
ADDED
package/dist/kit.d.ts
ADDED
package/dist/kit.mjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createClient } from '@solana/kit';
|
|
2
|
+
export { address, lamports } from '@solana/kit';
|
|
3
|
+
import { solanaRpcConnection } from '@solana/kit-plugin-rpc';
|
|
4
|
+
import { DEFAULT_CLUSTER, getClusterEndpoint, getWebSocketEndpoint, getClusterWebSocketEndpoint } from './clusters.mjs';
|
|
5
|
+
|
|
6
|
+
function createSolanaClient(config = {}) {
|
|
7
|
+
const cluster = config.cluster ?? DEFAULT_CLUSTER;
|
|
8
|
+
const endpoint = config.endpoint ?? getClusterEndpoint(cluster);
|
|
9
|
+
const wsEndpoint = config.wsEndpoint ?? (config.endpoint ? getWebSocketEndpoint(endpoint) : getClusterWebSocketEndpoint(cluster));
|
|
10
|
+
return createClient().use(
|
|
11
|
+
solanaRpcConnection({
|
|
12
|
+
rpcUrl: endpoint,
|
|
13
|
+
rpcSubscriptionsUrl: wsEndpoint
|
|
14
|
+
})
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { createSolanaClient };
|
package/dist/mobile-wallet.d.cts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { SolanaChain } from './types.cjs';
|
|
4
|
-
import '@solana/web3-compat';
|
|
1
|
+
import { a as SolanaChain } from './shared/core.DMgTrB_2.cjs';
|
|
2
|
+
import '@solana/kit';
|
|
5
3
|
|
|
6
4
|
interface SolanaMobileWalletAppIdentity {
|
|
7
5
|
name: string;
|
package/dist/mobile-wallet.d.mts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { SolanaChain } from './types.mjs';
|
|
4
|
-
import '@solana/web3-compat';
|
|
1
|
+
import { a as SolanaChain } from './shared/core.DMgTrB_2.mjs';
|
|
2
|
+
import '@solana/kit';
|
|
5
3
|
|
|
6
4
|
interface SolanaMobileWalletAppIdentity {
|
|
7
5
|
name: string;
|
package/dist/mobile-wallet.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { SolanaChain } from './types.js';
|
|
4
|
-
import '@solana/web3-compat';
|
|
1
|
+
import { a as SolanaChain } from './shared/core.DMgTrB_2.js';
|
|
2
|
+
import '@solana/kit';
|
|
5
3
|
|
|
6
4
|
interface SolanaMobileWalletAppIdentity {
|
|
7
5
|
name: string;
|
package/dist/rpc.cjs
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const web3Compat = require('@solana/web3-compat');
|
|
4
3
|
const clusters = require('./clusters.cjs');
|
|
4
|
+
const kit = require('./kit.cjs');
|
|
5
|
+
require('@solana/kit');
|
|
6
|
+
require('@solana/kit-plugin-rpc');
|
|
5
7
|
|
|
6
|
-
function createSolanaConnection(config = {}) {
|
|
7
|
-
const cluster = config.cluster ?? clusters.DEFAULT_CLUSTER;
|
|
8
|
-
const endpoint = config.endpoint ?? clusters.getClusterEndpoint(cluster);
|
|
9
|
-
const wsEndpoint = config.wsEndpoint ?? (config.endpoint ? clusters.getWebSocketEndpoint(endpoint) : clusters.getClusterWebSocketEndpoint(cluster));
|
|
10
|
-
return new web3Compat.Connection(endpoint, {
|
|
11
|
-
commitment: config.commitment,
|
|
12
|
-
wsEndpoint
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
8
|
function createSolanaContext(config = {}) {
|
|
16
9
|
const cluster = config.cluster ?? clusters.DEFAULT_CLUSTER;
|
|
17
10
|
const endpoint = config.endpoint ?? clusters.getClusterEndpoint(cluster);
|
|
@@ -20,9 +13,8 @@ function createSolanaContext(config = {}) {
|
|
|
20
13
|
cluster,
|
|
21
14
|
endpoint,
|
|
22
15
|
wsEndpoint,
|
|
23
|
-
|
|
16
|
+
client: kit.createSolanaClient(config)
|
|
24
17
|
};
|
|
25
18
|
}
|
|
26
19
|
|
|
27
|
-
exports.createSolanaConnection = createSolanaConnection;
|
|
28
20
|
exports.createSolanaContext = createSolanaContext;
|
package/dist/rpc.d.cts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { Connection } from '@solana/web3-compat';
|
|
4
|
-
import { SolanaConfig, SolanaContext } from './types.cjs';
|
|
1
|
+
import { d as SolanaConfig, e as SolanaContext } from './shared/core.DMgTrB_2.cjs';
|
|
2
|
+
import '@solana/kit';
|
|
5
3
|
|
|
6
|
-
declare function createSolanaConnection(config?: SolanaConfig): Connection;
|
|
7
4
|
declare function createSolanaContext(config?: SolanaConfig): SolanaContext;
|
|
8
5
|
|
|
9
|
-
export {
|
|
6
|
+
export { createSolanaContext };
|
package/dist/rpc.d.mts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { Connection } from '@solana/web3-compat';
|
|
4
|
-
import { SolanaConfig, SolanaContext } from './types.mjs';
|
|
1
|
+
import { d as SolanaConfig, e as SolanaContext } from './shared/core.DMgTrB_2.mjs';
|
|
2
|
+
import '@solana/kit';
|
|
5
3
|
|
|
6
|
-
declare function createSolanaConnection(config?: SolanaConfig): Connection;
|
|
7
4
|
declare function createSolanaContext(config?: SolanaConfig): SolanaContext;
|
|
8
5
|
|
|
9
|
-
export {
|
|
6
|
+
export { createSolanaContext };
|
package/dist/rpc.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { Connection } from '@solana/web3-compat';
|
|
4
|
-
import { SolanaConfig, SolanaContext } from './types.js';
|
|
1
|
+
import { d as SolanaConfig, e as SolanaContext } from './shared/core.DMgTrB_2.js';
|
|
2
|
+
import '@solana/kit';
|
|
5
3
|
|
|
6
|
-
declare function createSolanaConnection(config?: SolanaConfig): Connection;
|
|
7
4
|
declare function createSolanaContext(config?: SolanaConfig): SolanaContext;
|
|
8
5
|
|
|
9
|
-
export {
|
|
6
|
+
export { createSolanaContext };
|
package/dist/rpc.mjs
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
import { Connection } from '@solana/web3-compat';
|
|
2
1
|
import { DEFAULT_CLUSTER, getClusterEndpoint, getWebSocketEndpoint, getClusterWebSocketEndpoint } from './clusters.mjs';
|
|
2
|
+
import { createSolanaClient } from './kit.mjs';
|
|
3
|
+
import '@solana/kit';
|
|
4
|
+
import '@solana/kit-plugin-rpc';
|
|
3
5
|
|
|
4
|
-
function createSolanaConnection(config = {}) {
|
|
5
|
-
const cluster = config.cluster ?? DEFAULT_CLUSTER;
|
|
6
|
-
const endpoint = config.endpoint ?? getClusterEndpoint(cluster);
|
|
7
|
-
const wsEndpoint = config.wsEndpoint ?? (config.endpoint ? getWebSocketEndpoint(endpoint) : getClusterWebSocketEndpoint(cluster));
|
|
8
|
-
return new Connection(endpoint, {
|
|
9
|
-
commitment: config.commitment,
|
|
10
|
-
wsEndpoint
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
6
|
function createSolanaContext(config = {}) {
|
|
14
7
|
const cluster = config.cluster ?? DEFAULT_CLUSTER;
|
|
15
8
|
const endpoint = config.endpoint ?? getClusterEndpoint(cluster);
|
|
@@ -18,8 +11,8 @@ function createSolanaContext(config = {}) {
|
|
|
18
11
|
cluster,
|
|
19
12
|
endpoint,
|
|
20
13
|
wsEndpoint,
|
|
21
|
-
|
|
14
|
+
client: createSolanaClient(config)
|
|
22
15
|
};
|
|
23
16
|
}
|
|
24
17
|
|
|
25
|
-
export {
|
|
18
|
+
export { createSolanaContext };
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { StandardEvents, StandardDisconnect, StandardConnect } from '@wallet-standard/features';
|
|
2
2
|
import { SolanaSignAndSendTransaction, SolanaSignTransaction, SolanaSignMessage } from '@solana/wallet-standard-features';
|
|
3
|
-
import { Transaction, VersionedTransaction, PublicKey } from '@solana/web3-compat';
|
|
4
3
|
import bs58 from 'bs58';
|
|
5
|
-
import { SolanaWalletError } from '../wallet.mjs';
|
|
6
4
|
import { getWallets } from '@wallet-standard/app';
|
|
7
5
|
|
|
8
6
|
const SOLANA_CHAINS = [
|
|
@@ -28,19 +26,6 @@ function hasSignMessage(wallet) {
|
|
|
28
26
|
return SolanaSignMessage in wallet.features;
|
|
29
27
|
}
|
|
30
28
|
|
|
31
|
-
function serializeTransaction(transaction) {
|
|
32
|
-
if (transaction instanceof Transaction) {
|
|
33
|
-
return transaction.serialize({ requireAllSignatures: false, verifySignatures: false });
|
|
34
|
-
}
|
|
35
|
-
return transaction.serialize();
|
|
36
|
-
}
|
|
37
|
-
function deserializeTransaction(source, bytes) {
|
|
38
|
-
if (source instanceof Transaction) {
|
|
39
|
-
return Transaction.from(bytes);
|
|
40
|
-
}
|
|
41
|
-
return VersionedTransaction.deserialize(bytes);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
29
|
function adaptSolanaStandardWallet(walletInfo, options = {}) {
|
|
45
30
|
const wallet = walletInfo.wallet;
|
|
46
31
|
let accounts = wallet.accounts;
|
|
@@ -61,7 +46,7 @@ function adaptSolanaStandardWallet(walletInfo, options = {}) {
|
|
|
61
46
|
platform: walletInfo.platform,
|
|
62
47
|
source: walletInfo.source,
|
|
63
48
|
get publicKey() {
|
|
64
|
-
return account ?
|
|
49
|
+
return account ? account.address : null;
|
|
65
50
|
},
|
|
66
51
|
get connected() {
|
|
67
52
|
return Boolean(account);
|
|
@@ -126,20 +111,20 @@ function adaptSolanaStandardWallet(walletInfo, options = {}) {
|
|
|
126
111
|
const activeAccount = getActiveAccount(account);
|
|
127
112
|
const [result] = await wallet.features[SolanaSignTransaction].signTransaction({
|
|
128
113
|
account: activeAccount,
|
|
129
|
-
transaction
|
|
114
|
+
transaction,
|
|
130
115
|
chain: options.chain
|
|
131
116
|
});
|
|
132
117
|
if (!result) {
|
|
133
118
|
throw new Error("Solana wallet did not return a signed transaction");
|
|
134
119
|
}
|
|
135
|
-
return
|
|
120
|
+
return result.signedTransaction;
|
|
136
121
|
} : void 0,
|
|
137
122
|
signAllTransactions: hasSignTransaction(wallet) ? async (transactions) => {
|
|
138
123
|
const activeAccount = getActiveAccount(account);
|
|
139
124
|
const results = await wallet.features[SolanaSignTransaction].signTransaction(
|
|
140
125
|
...transactions.map((transaction) => ({
|
|
141
126
|
account: activeAccount,
|
|
142
|
-
transaction
|
|
127
|
+
transaction,
|
|
143
128
|
chain: options.chain
|
|
144
129
|
}))
|
|
145
130
|
);
|
|
@@ -148,26 +133,18 @@ function adaptSolanaStandardWallet(walletInfo, options = {}) {
|
|
|
148
133
|
`Solana wallet returned ${results.length} signed transactions for ${transactions.length} requested transactions`
|
|
149
134
|
);
|
|
150
135
|
}
|
|
151
|
-
return results.map((result
|
|
136
|
+
return results.map((result) => {
|
|
152
137
|
if (!result) {
|
|
153
138
|
throw new Error("Solana wallet did not return a signed transaction");
|
|
154
139
|
}
|
|
155
|
-
|
|
156
|
-
if (!transaction) {
|
|
157
|
-
throw new SolanaWalletError(
|
|
158
|
-
"WALLET_FEATURE_UNSUPPORTED",
|
|
159
|
-
"Solana wallet returned a signed transaction without a matching request",
|
|
160
|
-
{ feature: "signTransaction" }
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
|
-
return deserializeTransaction(transaction, result.signedTransaction);
|
|
140
|
+
return result.signedTransaction;
|
|
164
141
|
});
|
|
165
142
|
} : void 0,
|
|
166
143
|
signAndSendTransaction: hasSignAndSendTransaction(wallet) ? async (transaction, sendOptions) => {
|
|
167
144
|
const activeAccount = getActiveAccount(account);
|
|
168
145
|
const [result] = await wallet.features[SolanaSignAndSendTransaction].signAndSendTransaction({
|
|
169
146
|
account: activeAccount,
|
|
170
|
-
transaction
|
|
147
|
+
transaction,
|
|
171
148
|
chain: options.chain ?? getSolanaAccountChain(activeAccount),
|
|
172
149
|
options: sendOptions
|
|
173
150
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isAddress } from '@solana/kit';
|
|
2
2
|
import bs58 from 'bs58';
|
|
3
3
|
import * as naclModule from 'tweetnacl';
|
|
4
4
|
|
|
@@ -206,7 +206,7 @@ function getStoredIosWalletAccount(walletId, chains) {
|
|
|
206
206
|
return [
|
|
207
207
|
{
|
|
208
208
|
address: session.publicKey,
|
|
209
|
-
publicKey:
|
|
209
|
+
publicKey: bs58.decode(session.publicKey),
|
|
210
210
|
chains
|
|
211
211
|
}
|
|
212
212
|
];
|
|
@@ -218,7 +218,9 @@ function getStoredSession(walletId) {
|
|
|
218
218
|
}
|
|
219
219
|
try {
|
|
220
220
|
const session = JSON.parse(value);
|
|
221
|
-
|
|
221
|
+
if (!isAddress(session.publicKey)) {
|
|
222
|
+
throw new Error("Invalid stored public key");
|
|
223
|
+
}
|
|
222
224
|
return session;
|
|
223
225
|
} catch {
|
|
224
226
|
removeStoredSession(walletId);
|
|
@@ -371,27 +373,12 @@ function getStringField(payload, field) {
|
|
|
371
373
|
}
|
|
372
374
|
function getPublicKeyField(payload, field) {
|
|
373
375
|
const value = getStringField(payload, field);
|
|
374
|
-
|
|
375
|
-
new PublicKey(value);
|
|
376
|
-
} catch {
|
|
376
|
+
if (!isAddress(value)) {
|
|
377
377
|
throw new Error(`iOS wallet callback returned an invalid ${field}`);
|
|
378
378
|
}
|
|
379
379
|
return value;
|
|
380
380
|
}
|
|
381
381
|
|
|
382
|
-
function serializeTransaction(transaction) {
|
|
383
|
-
if (transaction instanceof Transaction) {
|
|
384
|
-
return transaction.serialize({ requireAllSignatures: false, verifySignatures: false });
|
|
385
|
-
}
|
|
386
|
-
return transaction.serialize();
|
|
387
|
-
}
|
|
388
|
-
function deserializeTransaction(source, bytes) {
|
|
389
|
-
if (source instanceof Transaction) {
|
|
390
|
-
return Transaction.from(bytes);
|
|
391
|
-
}
|
|
392
|
-
return VersionedTransaction.deserialize(bytes);
|
|
393
|
-
}
|
|
394
|
-
|
|
395
382
|
function launchConnect(definition, options) {
|
|
396
383
|
const keyPair = nacl.box.keyPair();
|
|
397
384
|
const pending = createPendingRequest(definition.id, "connect", keyPair, options.redirectUrl);
|
|
@@ -408,7 +395,7 @@ function launchConnect(definition, options) {
|
|
|
408
395
|
}
|
|
409
396
|
async function launchSignTransaction(definition, transaction, options) {
|
|
410
397
|
const response = await launchEncryptedWalletRequest(definition, "signTransaction", options, {
|
|
411
|
-
transaction: bs58.encode(
|
|
398
|
+
transaction: bs58.encode(transaction)
|
|
412
399
|
});
|
|
413
400
|
if (!response.transaction) {
|
|
414
401
|
throw new Error("iOS wallet did not return a signed transaction");
|
|
@@ -417,7 +404,7 @@ async function launchSignTransaction(definition, transaction, options) {
|
|
|
417
404
|
}
|
|
418
405
|
async function launchSignAllTransactions(definition, transactions, options) {
|
|
419
406
|
const response = await launchEncryptedWalletRequest(definition, "signAllTransactions", options, {
|
|
420
|
-
transactions: transactions.map((transaction) => bs58.encode(
|
|
407
|
+
transactions: transactions.map((transaction) => bs58.encode(transaction))
|
|
421
408
|
});
|
|
422
409
|
if (!response.transactions) {
|
|
423
410
|
throw new Error("iOS wallet did not return signed transactions");
|
|
@@ -430,7 +417,7 @@ async function launchSignAndSendTransaction(definition, transaction, sendOptions
|
|
|
430
417
|
"signAndSendTransaction",
|
|
431
418
|
options,
|
|
432
419
|
{
|
|
433
|
-
transaction: bs58.encode(
|
|
420
|
+
transaction: bs58.encode(transaction),
|
|
434
421
|
sendOptions
|
|
435
422
|
}
|
|
436
423
|
);
|
|
@@ -515,7 +502,7 @@ function adaptSolanaIosWallet(walletInfo, options = {}) {
|
|
|
515
502
|
}
|
|
516
503
|
return {
|
|
517
504
|
get publicKey() {
|
|
518
|
-
return session?.publicKey ?
|
|
505
|
+
return session?.publicKey ? session.publicKey : null;
|
|
519
506
|
},
|
|
520
507
|
get connected() {
|
|
521
508
|
return Boolean(session?.publicKey && session.session);
|
|
@@ -554,8 +541,7 @@ function adaptSolanaIosWallet(walletInfo, options = {}) {
|
|
|
554
541
|
}
|
|
555
542
|
},
|
|
556
543
|
signTransaction: definition.signTransactionUrl ? async (transaction) => {
|
|
557
|
-
|
|
558
|
-
return deserializeTransaction(transaction, signedTransaction);
|
|
544
|
+
return launchSignTransaction(definition, transaction, options);
|
|
559
545
|
} : void 0,
|
|
560
546
|
signAllTransactions: definition.signAllTransactionsUrl ? async (transactions) => {
|
|
561
547
|
const signedTransactions = await launchSignAllTransactions(
|
|
@@ -568,9 +554,7 @@ function adaptSolanaIosWallet(walletInfo, options = {}) {
|
|
|
568
554
|
`iOS wallet returned ${signedTransactions.length} signed transactions for ${transactions.length} requested transactions`
|
|
569
555
|
);
|
|
570
556
|
}
|
|
571
|
-
return signedTransactions
|
|
572
|
-
(transaction, index) => deserializeTransaction(transactions[index], transaction)
|
|
573
|
-
);
|
|
557
|
+
return signedTransactions;
|
|
574
558
|
} : void 0,
|
|
575
559
|
signAndSendTransaction: definition.signAndSendTransactionUrl ? async (transaction, sendOptions) => launchSignAndSendTransaction(definition, transaction, sendOptions, options) : void 0
|
|
576
560
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const kit = require('@solana/kit');
|
|
4
4
|
const bs58 = require('bs58');
|
|
5
5
|
const naclModule = require('tweetnacl');
|
|
6
6
|
|
|
@@ -225,7 +225,7 @@ function getStoredIosWalletAccount(walletId, chains) {
|
|
|
225
225
|
return [
|
|
226
226
|
{
|
|
227
227
|
address: session.publicKey,
|
|
228
|
-
publicKey:
|
|
228
|
+
publicKey: bs58__default.decode(session.publicKey),
|
|
229
229
|
chains
|
|
230
230
|
}
|
|
231
231
|
];
|
|
@@ -237,7 +237,9 @@ function getStoredSession(walletId) {
|
|
|
237
237
|
}
|
|
238
238
|
try {
|
|
239
239
|
const session = JSON.parse(value);
|
|
240
|
-
|
|
240
|
+
if (!kit.isAddress(session.publicKey)) {
|
|
241
|
+
throw new Error("Invalid stored public key");
|
|
242
|
+
}
|
|
241
243
|
return session;
|
|
242
244
|
} catch {
|
|
243
245
|
removeStoredSession(walletId);
|
|
@@ -390,27 +392,12 @@ function getStringField(payload, field) {
|
|
|
390
392
|
}
|
|
391
393
|
function getPublicKeyField(payload, field) {
|
|
392
394
|
const value = getStringField(payload, field);
|
|
393
|
-
|
|
394
|
-
new web3Compat.PublicKey(value);
|
|
395
|
-
} catch {
|
|
395
|
+
if (!kit.isAddress(value)) {
|
|
396
396
|
throw new Error(`iOS wallet callback returned an invalid ${field}`);
|
|
397
397
|
}
|
|
398
398
|
return value;
|
|
399
399
|
}
|
|
400
400
|
|
|
401
|
-
function serializeTransaction(transaction) {
|
|
402
|
-
if (transaction instanceof web3Compat.Transaction) {
|
|
403
|
-
return transaction.serialize({ requireAllSignatures: false, verifySignatures: false });
|
|
404
|
-
}
|
|
405
|
-
return transaction.serialize();
|
|
406
|
-
}
|
|
407
|
-
function deserializeTransaction(source, bytes) {
|
|
408
|
-
if (source instanceof web3Compat.Transaction) {
|
|
409
|
-
return web3Compat.Transaction.from(bytes);
|
|
410
|
-
}
|
|
411
|
-
return web3Compat.VersionedTransaction.deserialize(bytes);
|
|
412
|
-
}
|
|
413
|
-
|
|
414
401
|
function launchConnect(definition, options) {
|
|
415
402
|
const keyPair = nacl.box.keyPair();
|
|
416
403
|
const pending = createPendingRequest(definition.id, "connect", keyPair, options.redirectUrl);
|
|
@@ -427,7 +414,7 @@ function launchConnect(definition, options) {
|
|
|
427
414
|
}
|
|
428
415
|
async function launchSignTransaction(definition, transaction, options) {
|
|
429
416
|
const response = await launchEncryptedWalletRequest(definition, "signTransaction", options, {
|
|
430
|
-
transaction: bs58__default.encode(
|
|
417
|
+
transaction: bs58__default.encode(transaction)
|
|
431
418
|
});
|
|
432
419
|
if (!response.transaction) {
|
|
433
420
|
throw new Error("iOS wallet did not return a signed transaction");
|
|
@@ -436,7 +423,7 @@ async function launchSignTransaction(definition, transaction, options) {
|
|
|
436
423
|
}
|
|
437
424
|
async function launchSignAllTransactions(definition, transactions, options) {
|
|
438
425
|
const response = await launchEncryptedWalletRequest(definition, "signAllTransactions", options, {
|
|
439
|
-
transactions: transactions.map((transaction) => bs58__default.encode(
|
|
426
|
+
transactions: transactions.map((transaction) => bs58__default.encode(transaction))
|
|
440
427
|
});
|
|
441
428
|
if (!response.transactions) {
|
|
442
429
|
throw new Error("iOS wallet did not return signed transactions");
|
|
@@ -449,7 +436,7 @@ async function launchSignAndSendTransaction(definition, transaction, sendOptions
|
|
|
449
436
|
"signAndSendTransaction",
|
|
450
437
|
options,
|
|
451
438
|
{
|
|
452
|
-
transaction: bs58__default.encode(
|
|
439
|
+
transaction: bs58__default.encode(transaction),
|
|
453
440
|
sendOptions
|
|
454
441
|
}
|
|
455
442
|
);
|
|
@@ -534,7 +521,7 @@ function adaptSolanaIosWallet(walletInfo, options = {}) {
|
|
|
534
521
|
}
|
|
535
522
|
return {
|
|
536
523
|
get publicKey() {
|
|
537
|
-
return session?.publicKey ?
|
|
524
|
+
return session?.publicKey ? session.publicKey : null;
|
|
538
525
|
},
|
|
539
526
|
get connected() {
|
|
540
527
|
return Boolean(session?.publicKey && session.session);
|
|
@@ -573,8 +560,7 @@ function adaptSolanaIosWallet(walletInfo, options = {}) {
|
|
|
573
560
|
}
|
|
574
561
|
},
|
|
575
562
|
signTransaction: definition.signTransactionUrl ? async (transaction) => {
|
|
576
|
-
|
|
577
|
-
return deserializeTransaction(transaction, signedTransaction);
|
|
563
|
+
return launchSignTransaction(definition, transaction, options);
|
|
578
564
|
} : void 0,
|
|
579
565
|
signAllTransactions: definition.signAllTransactionsUrl ? async (transactions) => {
|
|
580
566
|
const signedTransactions = await launchSignAllTransactions(
|
|
@@ -587,9 +573,7 @@ function adaptSolanaIosWallet(walletInfo, options = {}) {
|
|
|
587
573
|
`iOS wallet returned ${signedTransactions.length} signed transactions for ${transactions.length} requested transactions`
|
|
588
574
|
);
|
|
589
575
|
}
|
|
590
|
-
return signedTransactions
|
|
591
|
-
(transaction, index) => deserializeTransaction(transactions[index], transaction)
|
|
592
|
-
);
|
|
576
|
+
return signedTransactions;
|
|
593
577
|
} : void 0,
|
|
594
578
|
signAndSendTransaction: definition.signAndSendTransactionUrl ? async (transaction, sendOptions) => launchSignAndSendTransaction(definition, transaction, sendOptions, options) : void 0
|
|
595
579
|
};
|