@dynamic-labs/global-wallet-client 4.0.0-alpha.52 → 4.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/CHANGELOG.md +79 -1
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +11 -7
- package/src/lib/actions/connectAction/createConnectAction.cjs +17 -6
- package/src/lib/actions/connectAction/createConnectAction.d.ts +2 -1
- package/src/lib/actions/connectAction/createConnectAction.js +17 -6
- package/src/lib/createGlobalWalletClient.cjs +2 -0
- package/src/lib/createGlobalWalletClient.d.ts +5 -0
- package/src/lib/createGlobalWalletClient.js +2 -0
- package/src/lib/ethereum/functions/eip1193Provider/createEIP1193Provider.cjs +86 -57
- package/src/lib/ethereum/functions/eip1193Provider/createEIP1193Provider.js +87 -58
- package/src/lib/ethereum/functions/isNetworkSupported/index.d.ts +1 -0
- package/src/lib/ethereum/functions/isNetworkSupported/isNetworkSupported.cjs +8 -0
- package/src/lib/ethereum/functions/isNetworkSupported/isNetworkSupported.d.ts +3 -0
- package/src/lib/ethereum/functions/isNetworkSupported/isNetworkSupported.js +4 -0
- package/src/lib/functions/createEthereumModule/createEthereumModule.cjs +3 -0
- package/src/lib/functions/createEthereumModule/createEthereumModule.d.ts +1 -0
- package/src/lib/functions/createEthereumModule/createEthereumModule.js +3 -0
- package/src/lib/functions/createPopupOpener/createPopupOpener.cjs +2 -1
- package/src/lib/functions/createPopupOpener/createPopupOpener.js +2 -1
- package/src/lib/functions/createSolanaModule/createSolanaModule.cjs +17 -0
- package/src/lib/functions/createSolanaModule/createSolanaModule.d.ts +9 -0
- package/src/lib/functions/createSolanaModule/createSolanaModule.js +13 -0
- package/src/lib/functions/createSolanaModule/index.d.ts +1 -0
- package/src/lib/solana/functions/convertBaseWalletToWalletAccount/convertBaseWalletToWalletAccount.cjs +36 -0
- package/src/lib/solana/functions/convertBaseWalletToWalletAccount/convertBaseWalletToWalletAccount.d.ts +4 -0
- package/src/lib/solana/functions/convertBaseWalletToWalletAccount/convertBaseWalletToWalletAccount.js +32 -0
- package/src/lib/solana/functions/convertBaseWalletToWalletAccount/index.d.ts +1 -0
- package/src/lib/solana/functions/createSolanaSignAndSendTransactionFeature/createSolanaSignAndSendTransactionFeature.cjs +14 -0
- package/src/lib/solana/functions/createSolanaSignAndSendTransactionFeature/createSolanaSignAndSendTransactionFeature.d.ts +2 -0
- package/src/lib/solana/functions/createSolanaSignAndSendTransactionFeature/createSolanaSignAndSendTransactionFeature.js +10 -0
- package/src/lib/solana/functions/createSolanaSignAndSendTransactionFeature/index.d.ts +1 -0
- package/src/lib/solana/functions/createSolanaSignMessageFeature/createSolanaSignMessageFeature.cjs +29 -0
- package/src/lib/solana/functions/createSolanaSignMessageFeature/createSolanaSignMessageFeature.d.ts +3 -0
- package/src/lib/solana/functions/createSolanaSignMessageFeature/createSolanaSignMessageFeature.js +25 -0
- package/src/lib/solana/functions/createSolanaSignMessageFeature/index.d.ts +1 -0
- package/src/lib/solana/functions/createSolanaSignTransactionFeature/createSolanaSignTransactionFeature.cjs +14 -0
- package/src/lib/solana/functions/createSolanaSignTransactionFeature/createSolanaSignTransactionFeature.d.ts +2 -0
- package/src/lib/solana/functions/createSolanaSignTransactionFeature/createSolanaSignTransactionFeature.js +10 -0
- package/src/lib/solana/functions/createSolanaSignTransactionFeature/index.d.ts +1 -0
- package/src/lib/solana/functions/createSolanaWallet/createSolanaWallet.cjs +47 -0
- package/src/lib/solana/functions/createSolanaWallet/createSolanaWallet.d.ts +17 -0
- package/src/lib/solana/functions/createSolanaWallet/createSolanaWallet.js +43 -0
- package/src/lib/solana/functions/createSolanaWallet/index.d.ts +1 -0
- package/src/lib/solana/functions/createStandardConnectFeature/createStandardConnectFeature.cjs +21 -0
- package/src/lib/solana/functions/createStandardConnectFeature/createStandardConnectFeature.d.ts +3 -0
- package/src/lib/solana/functions/createStandardConnectFeature/createStandardConnectFeature.js +17 -0
- package/src/lib/solana/functions/createStandardConnectFeature/index.d.ts +1 -0
- package/src/lib/solana/functions/createStandardDisconnectFeature/createStandardDisconnectFeature.cjs +13 -0
- package/src/lib/solana/functions/createStandardDisconnectFeature/createStandardDisconnectFeature.d.ts +3 -0
- package/src/lib/solana/functions/createStandardDisconnectFeature/createStandardDisconnectFeature.js +9 -0
- package/src/lib/solana/functions/createStandardDisconnectFeature/index.d.ts +1 -0
- package/src/lib/solana/functions/createStandardEventsFeature/createStandardEventsFeature.cjs +38 -0
- package/src/lib/solana/functions/createStandardEventsFeature/createStandardEventsFeature.d.ts +13 -0
- package/src/lib/solana/functions/createStandardEventsFeature/createStandardEventsFeature.js +34 -0
- package/src/lib/solana/functions/createStandardEventsFeature/index.d.ts +1 -0
- package/src/lib/solana/functions/getSolanaChains/getSolanaChains.cjs +13 -0
- package/src/lib/solana/functions/getSolanaChains/getSolanaChains.d.ts +2 -0
- package/src/lib/solana/functions/getSolanaChains/getSolanaChains.js +9 -0
- package/src/lib/solana/functions/getSolanaChains/index.d.ts +1 -0
- package/src/lib/solana/index.d.ts +1 -0
- package/src/lib/store/createClientStore.cjs +24 -2
- package/src/lib/store/createClientStore.d.ts +18 -1
- package/src/lib/store/createClientStore.js +24 -2
- package/src/solana.cjs +10 -0
- package/src/solana.d.ts +1 -0
- package/src/solana.js +2 -0
|
@@ -8,6 +8,9 @@ const createEthereumModule = ({ store }) => ({
|
|
|
8
8
|
var _a, _b;
|
|
9
9
|
return (_b = (_a = store.ethereum) === null || _a === void 0 ? void 0 : _a.supportedNetworks) !== null && _b !== void 0 ? _b : [];
|
|
10
10
|
},
|
|
11
|
+
switchNetwork: (network) => {
|
|
12
|
+
store.switchEthereumNetwork(network);
|
|
13
|
+
},
|
|
11
14
|
get wallets() {
|
|
12
15
|
var _a;
|
|
13
16
|
return (_a = store.wallets.filter(({ chain }) => chain === 'EVM')) !== null && _a !== void 0 ? _a : [];
|
|
@@ -9,7 +9,8 @@ var waitForPopupResponse = require('../waitForPopupResponse/waitForPopupResponse
|
|
|
9
9
|
var onPopupClose = require('../onPopupClose/onPopupClose.cjs');
|
|
10
10
|
var mergeAndEncryptParams = require('../mergeAndEncryptParams/mergeAndEncryptParams.cjs');
|
|
11
11
|
|
|
12
|
-
const createPopupOpener = ({ environmentId, popupInfo, store, popupActionTimeout =
|
|
12
|
+
const createPopupOpener = ({ environmentId, popupInfo, store, popupActionTimeout = 1000, // Wait page up to 1 second for new actions before closing
|
|
13
|
+
}) => {
|
|
13
14
|
let popup = null;
|
|
14
15
|
let didOpenPopup = false;
|
|
15
16
|
let lastActionId = null;
|
|
@@ -5,7 +5,8 @@ import { waitForPopupResponse } from '../waitForPopupResponse/waitForPopupRespon
|
|
|
5
5
|
import { onPopupClose } from '../onPopupClose/onPopupClose.js';
|
|
6
6
|
import { mergeAndEncryptParams } from '../mergeAndEncryptParams/mergeAndEncryptParams.js';
|
|
7
7
|
|
|
8
|
-
const createPopupOpener = ({ environmentId, popupInfo, store, popupActionTimeout =
|
|
8
|
+
const createPopupOpener = ({ environmentId, popupInfo, store, popupActionTimeout = 1000, // Wait page up to 1 second for new actions before closing
|
|
9
|
+
}) => {
|
|
9
10
|
let popup = null;
|
|
10
11
|
let didOpenPopup = false;
|
|
11
12
|
let lastActionId = null;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
const createSolanaModule = ({ store }) => ({
|
|
7
|
+
get currentNetwork() {
|
|
8
|
+
var _a, _b;
|
|
9
|
+
return (_b = (_a = store.solana) === null || _a === void 0 ? void 0 : _a.currentNetwork) !== null && _b !== void 0 ? _b : null;
|
|
10
|
+
},
|
|
11
|
+
get wallets() {
|
|
12
|
+
var _a;
|
|
13
|
+
return (_a = store.wallets.filter(({ chain }) => chain === 'SOL')) !== null && _a !== void 0 ? _a : [];
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
exports.createSolanaModule = createSolanaModule;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ClientStore } from '../../store';
|
|
2
|
+
type CreateSolanaModuleProps = {
|
|
3
|
+
store: ClientStore;
|
|
4
|
+
};
|
|
5
|
+
export declare const createSolanaModule: ({ store }: CreateSolanaModuleProps) => {
|
|
6
|
+
readonly currentNetwork: string | null;
|
|
7
|
+
readonly wallets: import("dist/packages/types/src").BaseWallet[];
|
|
8
|
+
};
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
const createSolanaModule = ({ store }) => ({
|
|
3
|
+
get currentNetwork() {
|
|
4
|
+
var _a, _b;
|
|
5
|
+
return (_b = (_a = store.solana) === null || _a === void 0 ? void 0 : _a.currentNetwork) !== null && _b !== void 0 ? _b : null;
|
|
6
|
+
},
|
|
7
|
+
get wallets() {
|
|
8
|
+
var _a;
|
|
9
|
+
return (_a = store.wallets.filter(({ chain }) => chain === 'SOL')) !== null && _a !== void 0 ? _a : [];
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export { createSolanaModule };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createSolanaModule } from './createSolanaModule';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var web3_js = require('@solana/web3.js');
|
|
7
|
+
var getSolanaChains = require('../getSolanaChains/getSolanaChains.cjs');
|
|
8
|
+
|
|
9
|
+
const convertBaseWalletToWalletAccount = (wallet, client) => {
|
|
10
|
+
try {
|
|
11
|
+
const publicKey = new web3_js.PublicKey(wallet.address);
|
|
12
|
+
// Validate the public key is valid base58
|
|
13
|
+
if (!web3_js.PublicKey.isOnCurve(publicKey.toBytes())) {
|
|
14
|
+
throw new Error('Invalid public key');
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
address: publicKey.toBase58(),
|
|
18
|
+
get chains() {
|
|
19
|
+
return getSolanaChains.getSolanaChains(client);
|
|
20
|
+
},
|
|
21
|
+
features: [
|
|
22
|
+
'solana:signAndSendTransaction',
|
|
23
|
+
'solana:signTransaction',
|
|
24
|
+
'standard:connect',
|
|
25
|
+
'standard:disconnect',
|
|
26
|
+
'standard:events',
|
|
27
|
+
],
|
|
28
|
+
publicKey: publicKey.toBytes(),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
throw new Error(`Invalid Solana address: ${wallet.address}`);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
exports.convertBaseWalletToWalletAccount = convertBaseWalletToWalletAccount;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { WalletAccount } from '@wallet-standard/base';
|
|
2
|
+
import { BaseWallet } from '@dynamic-labs/types';
|
|
3
|
+
import { GlobalWalletClient } from '../../../createGlobalWalletClient';
|
|
4
|
+
export declare const convertBaseWalletToWalletAccount: (wallet: BaseWallet, client: GlobalWalletClient) => WalletAccount;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { PublicKey } from '@solana/web3.js';
|
|
3
|
+
import { getSolanaChains } from '../getSolanaChains/getSolanaChains.js';
|
|
4
|
+
|
|
5
|
+
const convertBaseWalletToWalletAccount = (wallet, client) => {
|
|
6
|
+
try {
|
|
7
|
+
const publicKey = new PublicKey(wallet.address);
|
|
8
|
+
// Validate the public key is valid base58
|
|
9
|
+
if (!PublicKey.isOnCurve(publicKey.toBytes())) {
|
|
10
|
+
throw new Error('Invalid public key');
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
address: publicKey.toBase58(),
|
|
14
|
+
get chains() {
|
|
15
|
+
return getSolanaChains(client);
|
|
16
|
+
},
|
|
17
|
+
features: [
|
|
18
|
+
'solana:signAndSendTransaction',
|
|
19
|
+
'solana:signTransaction',
|
|
20
|
+
'standard:connect',
|
|
21
|
+
'standard:disconnect',
|
|
22
|
+
'standard:events',
|
|
23
|
+
],
|
|
24
|
+
publicKey: publicKey.toBytes(),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
throw new Error(`Invalid Solana address: ${wallet.address}`);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { convertBaseWalletToWalletAccount };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { convertBaseWalletToWalletAccount } from './convertBaseWalletToWalletAccount';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
7
|
+
|
|
8
|
+
const createSolanaSignAndSendTransactionFeature = () => ({
|
|
9
|
+
signAndSendTransaction: () => _tslib.__awaiter(void 0, void 0, void 0, function* () { return []; }),
|
|
10
|
+
supportedTransactionVersions: ['legacy', 0],
|
|
11
|
+
version: '1.0.0',
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
exports.createSolanaSignAndSendTransactionFeature = createSolanaSignAndSendTransactionFeature;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
+
|
|
4
|
+
const createSolanaSignAndSendTransactionFeature = () => ({
|
|
5
|
+
signAndSendTransaction: () => __awaiter(void 0, void 0, void 0, function* () { return []; }),
|
|
6
|
+
supportedTransactionVersions: ['legacy', 0],
|
|
7
|
+
version: '1.0.0',
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export { createSolanaSignAndSendTransactionFeature };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createSolanaSignAndSendTransactionFeature } from './createSolanaSignAndSendTransactionFeature';
|
package/src/lib/solana/functions/createSolanaSignMessageFeature/createSolanaSignMessageFeature.cjs
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
7
|
+
var utils = require('@dynamic-labs/utils');
|
|
8
|
+
|
|
9
|
+
const createSolanaSignMessageFeature = (client) => ({
|
|
10
|
+
signMessage: (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ account, message }) {
|
|
11
|
+
const params = {
|
|
12
|
+
address: account.address,
|
|
13
|
+
message: utils.uint8ArrayToBase64(message),
|
|
14
|
+
};
|
|
15
|
+
const { signature, signedMessage } = yield client.invoke({
|
|
16
|
+
params,
|
|
17
|
+
pathname: 'solana_signMessage',
|
|
18
|
+
});
|
|
19
|
+
return [
|
|
20
|
+
{
|
|
21
|
+
signature: utils.uint8ArrayFromBase64(signature),
|
|
22
|
+
signedMessage: utils.uint8ArrayFromBase64(signedMessage),
|
|
23
|
+
},
|
|
24
|
+
];
|
|
25
|
+
}),
|
|
26
|
+
version: '1.0.0',
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
exports.createSolanaSignMessageFeature = createSolanaSignMessageFeature;
|
package/src/lib/solana/functions/createSolanaSignMessageFeature/createSolanaSignMessageFeature.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { SolanaSignMessageFeature } from '@solana/wallet-standard-features';
|
|
2
|
+
import { GlobalWalletClient } from '../../../createGlobalWalletClient';
|
|
3
|
+
export declare const createSolanaSignMessageFeature: (client: GlobalWalletClient) => SolanaSignMessageFeature['solana:signMessage'];
|
package/src/lib/solana/functions/createSolanaSignMessageFeature/createSolanaSignMessageFeature.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
+
import { uint8ArrayToBase64, uint8ArrayFromBase64 } from '@dynamic-labs/utils';
|
|
4
|
+
|
|
5
|
+
const createSolanaSignMessageFeature = (client) => ({
|
|
6
|
+
signMessage: (_a) => __awaiter(void 0, [_a], void 0, function* ({ account, message }) {
|
|
7
|
+
const params = {
|
|
8
|
+
address: account.address,
|
|
9
|
+
message: uint8ArrayToBase64(message),
|
|
10
|
+
};
|
|
11
|
+
const { signature, signedMessage } = yield client.invoke({
|
|
12
|
+
params,
|
|
13
|
+
pathname: 'solana_signMessage',
|
|
14
|
+
});
|
|
15
|
+
return [
|
|
16
|
+
{
|
|
17
|
+
signature: uint8ArrayFromBase64(signature),
|
|
18
|
+
signedMessage: uint8ArrayFromBase64(signedMessage),
|
|
19
|
+
},
|
|
20
|
+
];
|
|
21
|
+
}),
|
|
22
|
+
version: '1.0.0',
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export { createSolanaSignMessageFeature };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createSolanaSignMessageFeature } from './createSolanaSignMessageFeature';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
7
|
+
|
|
8
|
+
const createSolanaSignTransactionFeature = () => ({
|
|
9
|
+
signTransaction: () => _tslib.__awaiter(void 0, void 0, void 0, function* () { return []; }),
|
|
10
|
+
supportedTransactionVersions: ['legacy', 0],
|
|
11
|
+
version: '1.0.0',
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
exports.createSolanaSignTransactionFeature = createSolanaSignTransactionFeature;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
+
|
|
4
|
+
const createSolanaSignTransactionFeature = () => ({
|
|
5
|
+
signTransaction: () => __awaiter(void 0, void 0, void 0, function* () { return []; }),
|
|
6
|
+
supportedTransactionVersions: ['legacy', 0],
|
|
7
|
+
version: '1.0.0',
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export { createSolanaSignTransactionFeature };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createSolanaSignTransactionFeature } from './createSolanaSignTransactionFeature';
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var convertBaseWalletToWalletAccount = require('../convertBaseWalletToWalletAccount/convertBaseWalletToWalletAccount.cjs');
|
|
7
|
+
var getSolanaChains = require('../getSolanaChains/getSolanaChains.cjs');
|
|
8
|
+
var createStandardEventsFeature = require('../createStandardEventsFeature/createStandardEventsFeature.cjs');
|
|
9
|
+
var createSolanaSignMessageFeature = require('../createSolanaSignMessageFeature/createSolanaSignMessageFeature.cjs');
|
|
10
|
+
var createSolanaSignTransactionFeature = require('../createSolanaSignTransactionFeature/createSolanaSignTransactionFeature.cjs');
|
|
11
|
+
var createStandardConnectFeature = require('../createStandardConnectFeature/createStandardConnectFeature.cjs');
|
|
12
|
+
var createStandardDisconnectFeature = require('../createStandardDisconnectFeature/createStandardDisconnectFeature.cjs');
|
|
13
|
+
var createSolanaSignAndSendTransactionFeature = require('../createSolanaSignAndSendTransactionFeature/createSolanaSignAndSendTransactionFeature.cjs');
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Creates a Solana wallet that implements the Wallet Standard specification
|
|
17
|
+
*
|
|
18
|
+
* @param {CreateSolanaWalletProps} props - Configuration properties for the wallet
|
|
19
|
+
* @param {string} props.name - The name of the wallet
|
|
20
|
+
* @param {WalletIcon} props.icon - The wallet's icon
|
|
21
|
+
* @param {GlobalWalletClient} client - The global wallet client instance
|
|
22
|
+
* @returns {Wallet} A wallet object conforming to the Wallet Standard specification with Solana features
|
|
23
|
+
*/
|
|
24
|
+
const createSolanaWallet = ({ icon, name }, client) => {
|
|
25
|
+
const features = {
|
|
26
|
+
'solana:signAndSendTransaction': createSolanaSignAndSendTransactionFeature.createSolanaSignAndSendTransactionFeature(),
|
|
27
|
+
'solana:signMessage': createSolanaSignMessageFeature.createSolanaSignMessageFeature(client),
|
|
28
|
+
'solana:signTransaction': createSolanaSignTransactionFeature.createSolanaSignTransactionFeature(),
|
|
29
|
+
'standard:connect': createStandardConnectFeature.createStandardConnectFeature(client),
|
|
30
|
+
'standard:disconnect': createStandardDisconnectFeature.createStandardDisconnectFeature(client),
|
|
31
|
+
'standard:events': createStandardEventsFeature.createStandardEventsFeature(client),
|
|
32
|
+
};
|
|
33
|
+
return {
|
|
34
|
+
get accounts() {
|
|
35
|
+
return client.solana.wallets.map((wallet) => convertBaseWalletToWalletAccount.convertBaseWalletToWalletAccount(wallet, client));
|
|
36
|
+
},
|
|
37
|
+
get chains() {
|
|
38
|
+
return getSolanaChains.getSolanaChains(client);
|
|
39
|
+
},
|
|
40
|
+
features,
|
|
41
|
+
icon,
|
|
42
|
+
name,
|
|
43
|
+
version: '1.0.0',
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
exports.createSolanaWallet = createSolanaWallet;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Wallet, WalletIcon } from '@wallet-standard/base';
|
|
2
|
+
import { GlobalWalletClient } from '../../../createGlobalWalletClient';
|
|
3
|
+
type CreateSolanaWalletProps = {
|
|
4
|
+
name: string;
|
|
5
|
+
icon: WalletIcon;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Creates a Solana wallet that implements the Wallet Standard specification
|
|
9
|
+
*
|
|
10
|
+
* @param {CreateSolanaWalletProps} props - Configuration properties for the wallet
|
|
11
|
+
* @param {string} props.name - The name of the wallet
|
|
12
|
+
* @param {WalletIcon} props.icon - The wallet's icon
|
|
13
|
+
* @param {GlobalWalletClient} client - The global wallet client instance
|
|
14
|
+
* @returns {Wallet} A wallet object conforming to the Wallet Standard specification with Solana features
|
|
15
|
+
*/
|
|
16
|
+
export declare const createSolanaWallet: ({ icon, name }: CreateSolanaWalletProps, client: GlobalWalletClient) => Wallet;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { convertBaseWalletToWalletAccount } from '../convertBaseWalletToWalletAccount/convertBaseWalletToWalletAccount.js';
|
|
3
|
+
import { getSolanaChains } from '../getSolanaChains/getSolanaChains.js';
|
|
4
|
+
import { createStandardEventsFeature } from '../createStandardEventsFeature/createStandardEventsFeature.js';
|
|
5
|
+
import { createSolanaSignMessageFeature } from '../createSolanaSignMessageFeature/createSolanaSignMessageFeature.js';
|
|
6
|
+
import { createSolanaSignTransactionFeature } from '../createSolanaSignTransactionFeature/createSolanaSignTransactionFeature.js';
|
|
7
|
+
import { createStandardConnectFeature } from '../createStandardConnectFeature/createStandardConnectFeature.js';
|
|
8
|
+
import { createStandardDisconnectFeature } from '../createStandardDisconnectFeature/createStandardDisconnectFeature.js';
|
|
9
|
+
import { createSolanaSignAndSendTransactionFeature } from '../createSolanaSignAndSendTransactionFeature/createSolanaSignAndSendTransactionFeature.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Creates a Solana wallet that implements the Wallet Standard specification
|
|
13
|
+
*
|
|
14
|
+
* @param {CreateSolanaWalletProps} props - Configuration properties for the wallet
|
|
15
|
+
* @param {string} props.name - The name of the wallet
|
|
16
|
+
* @param {WalletIcon} props.icon - The wallet's icon
|
|
17
|
+
* @param {GlobalWalletClient} client - The global wallet client instance
|
|
18
|
+
* @returns {Wallet} A wallet object conforming to the Wallet Standard specification with Solana features
|
|
19
|
+
*/
|
|
20
|
+
const createSolanaWallet = ({ icon, name }, client) => {
|
|
21
|
+
const features = {
|
|
22
|
+
'solana:signAndSendTransaction': createSolanaSignAndSendTransactionFeature(),
|
|
23
|
+
'solana:signMessage': createSolanaSignMessageFeature(client),
|
|
24
|
+
'solana:signTransaction': createSolanaSignTransactionFeature(),
|
|
25
|
+
'standard:connect': createStandardConnectFeature(client),
|
|
26
|
+
'standard:disconnect': createStandardDisconnectFeature(client),
|
|
27
|
+
'standard:events': createStandardEventsFeature(client),
|
|
28
|
+
};
|
|
29
|
+
return {
|
|
30
|
+
get accounts() {
|
|
31
|
+
return client.solana.wallets.map((wallet) => convertBaseWalletToWalletAccount(wallet, client));
|
|
32
|
+
},
|
|
33
|
+
get chains() {
|
|
34
|
+
return getSolanaChains(client);
|
|
35
|
+
},
|
|
36
|
+
features,
|
|
37
|
+
icon,
|
|
38
|
+
name,
|
|
39
|
+
version: '1.0.0',
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export { createSolanaWallet };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createSolanaWallet } from './createSolanaWallet';
|
package/src/lib/solana/functions/createStandardConnectFeature/createStandardConnectFeature.cjs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
7
|
+
var convertBaseWalletToWalletAccount = require('../convertBaseWalletToWalletAccount/convertBaseWalletToWalletAccount.cjs');
|
|
8
|
+
|
|
9
|
+
const createStandardConnectFeature = (client) => ({
|
|
10
|
+
connect: () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
11
|
+
if (!client.solana.wallets.length) {
|
|
12
|
+
yield client.connect({ chain: 'solana' });
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
accounts: client.solana.wallets.map((wallet) => convertBaseWalletToWalletAccount.convertBaseWalletToWalletAccount(wallet, client)),
|
|
16
|
+
};
|
|
17
|
+
}),
|
|
18
|
+
version: '1.0.0',
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
exports.createStandardConnectFeature = createStandardConnectFeature;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
+
import { convertBaseWalletToWalletAccount } from '../convertBaseWalletToWalletAccount/convertBaseWalletToWalletAccount.js';
|
|
4
|
+
|
|
5
|
+
const createStandardConnectFeature = (client) => ({
|
|
6
|
+
connect: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
7
|
+
if (!client.solana.wallets.length) {
|
|
8
|
+
yield client.connect({ chain: 'solana' });
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
accounts: client.solana.wallets.map((wallet) => convertBaseWalletToWalletAccount(wallet, client)),
|
|
12
|
+
};
|
|
13
|
+
}),
|
|
14
|
+
version: '1.0.0',
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export { createStandardConnectFeature };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createStandardConnectFeature } from './createStandardConnectFeature';
|
package/src/lib/solana/functions/createStandardDisconnectFeature/createStandardDisconnectFeature.cjs
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
7
|
+
|
|
8
|
+
const createStandardDisconnectFeature = (client) => ({
|
|
9
|
+
disconnect: () => _tslib.__awaiter(void 0, void 0, void 0, function* () { return client.disconnect(); }),
|
|
10
|
+
version: '1.0.0',
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
exports.createStandardDisconnectFeature = createStandardDisconnectFeature;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { StandardDisconnectFeature } from '@wallet-standard/features';
|
|
2
|
+
import { GlobalWalletClient } from '../../../createGlobalWalletClient';
|
|
3
|
+
export declare const createStandardDisconnectFeature: (client: GlobalWalletClient) => StandardDisconnectFeature['standard:disconnect'];
|
package/src/lib/solana/functions/createStandardDisconnectFeature/createStandardDisconnectFeature.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
+
|
|
4
|
+
const createStandardDisconnectFeature = (client) => ({
|
|
5
|
+
disconnect: () => __awaiter(void 0, void 0, void 0, function* () { return client.disconnect(); }),
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export { createStandardDisconnectFeature };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createStandardDisconnectFeature } from './createStandardDisconnectFeature';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var eventemitter3 = require('eventemitter3');
|
|
7
|
+
var convertBaseWalletToWalletAccount = require('../convertBaseWalletToWalletAccount/convertBaseWalletToWalletAccount.cjs');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Creates a Standard Events Feature compliant with the Wallet Standard specification.
|
|
11
|
+
* This feature enables wallet clients to listen for account changes through a standardized event system.
|
|
12
|
+
*
|
|
13
|
+
* @param {GlobalWalletClient} client - The global wallet client instance to attach events to
|
|
14
|
+
* @returns {StandardEventsFeature['standard:events']} A standard events feature implementation
|
|
15
|
+
* that provides event subscription capabilities for wallet account changes
|
|
16
|
+
*/
|
|
17
|
+
const createStandardEventsFeature = (client) => {
|
|
18
|
+
const eventEmitter = new eventemitter3.EventEmitter();
|
|
19
|
+
const emitChanges = () => {
|
|
20
|
+
eventEmitter.emit('change', {
|
|
21
|
+
accounts: client.solana.wallets.map((wallet) => convertBaseWalletToWalletAccount.convertBaseWalletToWalletAccount(wallet, client)),
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
client.on('connect', emitChanges);
|
|
25
|
+
client.on('disconnect', emitChanges);
|
|
26
|
+
const eventsFeature = {
|
|
27
|
+
on: (event, listener) => {
|
|
28
|
+
eventEmitter.on(event, listener);
|
|
29
|
+
return () => {
|
|
30
|
+
eventEmitter.off(event, listener);
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
version: '1.0.0',
|
|
34
|
+
};
|
|
35
|
+
return eventsFeature;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
exports.createStandardEventsFeature = createStandardEventsFeature;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { GlobalWalletClient } from '../../../createGlobalWalletClient';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a Standard Events Feature compliant with the Wallet Standard specification.
|
|
4
|
+
* This feature enables wallet clients to listen for account changes through a standardized event system.
|
|
5
|
+
*
|
|
6
|
+
* @param {GlobalWalletClient} client - The global wallet client instance to attach events to
|
|
7
|
+
* @returns {StandardEventsFeature['standard:events']} A standard events feature implementation
|
|
8
|
+
* that provides event subscription capabilities for wallet account changes
|
|
9
|
+
*/
|
|
10
|
+
export declare const createStandardEventsFeature: (client: GlobalWalletClient) => {
|
|
11
|
+
readonly version: "1.0.0";
|
|
12
|
+
readonly on: import("@wallet-standard/features").StandardEventsOnMethod;
|
|
13
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { EventEmitter } from 'eventemitter3';
|
|
3
|
+
import { convertBaseWalletToWalletAccount } from '../convertBaseWalletToWalletAccount/convertBaseWalletToWalletAccount.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Creates a Standard Events Feature compliant with the Wallet Standard specification.
|
|
7
|
+
* This feature enables wallet clients to listen for account changes through a standardized event system.
|
|
8
|
+
*
|
|
9
|
+
* @param {GlobalWalletClient} client - The global wallet client instance to attach events to
|
|
10
|
+
* @returns {StandardEventsFeature['standard:events']} A standard events feature implementation
|
|
11
|
+
* that provides event subscription capabilities for wallet account changes
|
|
12
|
+
*/
|
|
13
|
+
const createStandardEventsFeature = (client) => {
|
|
14
|
+
const eventEmitter = new EventEmitter();
|
|
15
|
+
const emitChanges = () => {
|
|
16
|
+
eventEmitter.emit('change', {
|
|
17
|
+
accounts: client.solana.wallets.map((wallet) => convertBaseWalletToWalletAccount(wallet, client)),
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
client.on('connect', emitChanges);
|
|
21
|
+
client.on('disconnect', emitChanges);
|
|
22
|
+
const eventsFeature = {
|
|
23
|
+
on: (event, listener) => {
|
|
24
|
+
eventEmitter.on(event, listener);
|
|
25
|
+
return () => {
|
|
26
|
+
eventEmitter.off(event, listener);
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
version: '1.0.0',
|
|
30
|
+
};
|
|
31
|
+
return eventsFeature;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export { createStandardEventsFeature };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createStandardEventsFeature } from './createStandardEventsFeature';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
const getSolanaChains = (client) => {
|
|
7
|
+
if (client.solana.currentNetwork) {
|
|
8
|
+
return [`solana:${client.solana.currentNetwork}`];
|
|
9
|
+
}
|
|
10
|
+
return [];
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
exports.getSolanaChains = getSolanaChains;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getSolanaChains } from './getSolanaChains';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createSolanaWallet } from './functions/createSolanaWallet';
|