@dynamic-labs/sui 4.19.5 → 4.19.7
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 +27 -0
- package/README.md +1 -1
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +4 -11
- package/src/SuiWalletConnectors.cjs +13 -0
- package/src/SuiWalletConnectors.d.ts +1 -0
- package/src/SuiWalletConnectors.js +9 -0
- package/src/index.cjs +7 -17
- package/src/index.d.ts +2 -7
- package/src/index.js +2 -13
- package/_virtual/_tslib.cjs +0 -36
- package/_virtual/_tslib.js +0 -32
- package/src/SuiWalletConnector.cjs +0 -306
- package/src/SuiWalletConnector.d.ts +0 -75
- package/src/SuiWalletConnector.js +0 -302
- package/src/types.d.ts +0 -27
- package/src/utils/SuiUiTransaction/SuiUiTransaction.cjs +0 -125
- package/src/utils/SuiUiTransaction/SuiUiTransaction.d.ts +0 -47
- package/src/utils/SuiUiTransaction/SuiUiTransaction.js +0 -121
- package/src/utils/SuiUiTransaction/index.d.ts +0 -1
- package/src/utils/constants/constants.cjs +0 -8
- package/src/utils/constants/constants.d.ts +0 -1
- package/src/utils/constants/constants.js +0 -4
- package/src/utils/constants/index.d.ts +0 -1
- package/src/utils/network/index.d.ts +0 -1
- package/src/utils/network/networkHelpers.cjs +0 -34
- package/src/utils/network/networkHelpers.d.ts +0 -19
- package/src/utils/network/networkHelpers.js +0 -29
- package/src/wallet/SuiWallet.cjs +0 -116
- package/src/wallet/SuiWallet.d.ts +0 -40
- package/src/wallet/SuiWallet.js +0 -112
- package/src/wallet/index.d.ts +0 -1
- package/src/wallet/isSuiWallet/index.d.ts +0 -1
- package/src/wallet/isSuiWallet/isSuiWallet.cjs +0 -8
- package/src/wallet/isSuiWallet/isSuiWallet.d.ts +0 -3
- package/src/wallet/isSuiWallet/isSuiWallet.js +0 -4
- package/src/wallets/injected/fetchSuiInjectedWalletConnectors.cjs +0 -64
- package/src/wallets/injected/fetchSuiInjectedWalletConnectors.d.ts +0 -5
- package/src/wallets/injected/fetchSuiInjectedWalletConnectors.js +0 -60
- package/src/wallets/injected/index.d.ts +0 -1
- package/src/wallets/injected/injected.cjs +0 -19
- package/src/wallets/injected/injected.d.ts +0 -13
- package/src/wallets/injected/injected.js +0 -15
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { GenericNetwork } from '@dynamic-labs/types';
|
|
2
|
-
/**
|
|
3
|
-
* Get the Sui network id from the network name
|
|
4
|
-
*
|
|
5
|
-
* The Wallet Standard API returns Sui networks in the format `sui:mainnet`,
|
|
6
|
-
* so we need to map that to our network id.
|
|
7
|
-
*
|
|
8
|
-
* @param name - The network name
|
|
9
|
-
* @param networks - The list of networks
|
|
10
|
-
* @returns The Sui network id
|
|
11
|
-
*/
|
|
12
|
-
export declare const getSuiNetworkIdFromName: (name: string, networks: GenericNetwork[]) => string | undefined;
|
|
13
|
-
/**
|
|
14
|
-
* Get the preferred RPC URL for a given network
|
|
15
|
-
*
|
|
16
|
-
* @param network - The network
|
|
17
|
-
* @returns The preferred RPC URL
|
|
18
|
-
*/
|
|
19
|
-
export declare const getPreferredRpcUrl: (network: GenericNetwork) => string;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
/**
|
|
3
|
-
* Get the Sui network id from the network name
|
|
4
|
-
*
|
|
5
|
-
* The Wallet Standard API returns Sui networks in the format `sui:mainnet`,
|
|
6
|
-
* so we need to map that to our network id.
|
|
7
|
-
*
|
|
8
|
-
* @param name - The network name
|
|
9
|
-
* @param networks - The list of networks
|
|
10
|
-
* @returns The Sui network id
|
|
11
|
-
*/
|
|
12
|
-
const getSuiNetworkIdFromName = (name, networks) => {
|
|
13
|
-
var _a;
|
|
14
|
-
const suiNetworkName = name.split(':').pop();
|
|
15
|
-
if (!suiNetworkName) {
|
|
16
|
-
return undefined;
|
|
17
|
-
}
|
|
18
|
-
const chainId = (_a = networks.find((network) => network.name.toLowerCase().includes(suiNetworkName.toLowerCase()))) === null || _a === void 0 ? void 0 : _a.chainId;
|
|
19
|
-
return chainId ? String(chainId) : undefined;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Get the preferred RPC URL for a given network
|
|
23
|
-
*
|
|
24
|
-
* @param network - The network
|
|
25
|
-
* @returns The preferred RPC URL
|
|
26
|
-
*/
|
|
27
|
-
const getPreferredRpcUrl = (network) => { var _a, _b, _c; return (_b = (_a = network.privateCustomerRpcUrls) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : (_c = network.rpcUrls) === null || _c === void 0 ? void 0 : _c[0]; };
|
|
28
|
-
|
|
29
|
-
export { getPreferredRpcUrl, getSuiNetworkIdFromName };
|
package/src/wallet/SuiWallet.cjs
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
-
|
|
6
|
-
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
7
|
-
var transactions = require('@mysten/sui/transactions');
|
|
8
|
-
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
9
|
-
var utils = require('@dynamic-labs/utils');
|
|
10
|
-
var constants = require('../utils/constants/constants.cjs');
|
|
11
|
-
|
|
12
|
-
class SuiWallet extends walletConnectorCore.Wallet {
|
|
13
|
-
/**
|
|
14
|
-
* Sends the native balance of the wallet to the given address.
|
|
15
|
-
* @param amount - The amount of balance
|
|
16
|
-
* @param toAddress - The address to send the balance to.
|
|
17
|
-
* @returns The transaction as base64 encoded bcs.
|
|
18
|
-
*/
|
|
19
|
-
sendBalance(_a) {
|
|
20
|
-
return _tslib.__awaiter(this, arguments, void 0, function* ({ amount, toAddress, }) {
|
|
21
|
-
var _b;
|
|
22
|
-
yield this._connector.connect();
|
|
23
|
-
const account = yield this._connector.getWalletAccount();
|
|
24
|
-
const chain = account === null || account === void 0 ? void 0 : account.chains[0];
|
|
25
|
-
if (!account) {
|
|
26
|
-
throw new utils.DynamicError('Unable to retrieve Sui wallet account');
|
|
27
|
-
}
|
|
28
|
-
if (!chain) {
|
|
29
|
-
throw new utils.DynamicError('Unable to retrieve Sui active network');
|
|
30
|
-
}
|
|
31
|
-
const transactionFeature = (_b = this._connector.getFeatures()) === null || _b === void 0 ? void 0 : _b['sui:signAndExecuteTransaction'];
|
|
32
|
-
if (!transactionFeature) {
|
|
33
|
-
throw new utils.DynamicError('Wallet does not support sui:signAndExecuteTransaction');
|
|
34
|
-
}
|
|
35
|
-
const transaction = new transactions.Transaction();
|
|
36
|
-
const mistAmount = Number(amount) * constants.MIST_PER_SUI;
|
|
37
|
-
// Let the transaction calculate gas automatically
|
|
38
|
-
// https://sdk.mystenlabs.com/typescript/transaction-building/gas#gas-price
|
|
39
|
-
const [coin] = transaction.splitCoins(transaction.gas, [mistAmount]);
|
|
40
|
-
transaction.transferObjects([coin], toAddress);
|
|
41
|
-
const { bytes } = yield transactionFeature.signAndExecuteTransaction({
|
|
42
|
-
account,
|
|
43
|
-
chain,
|
|
44
|
-
transaction,
|
|
45
|
-
});
|
|
46
|
-
return bytes;
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Returns the Sui Client object initialized for the wallet's current network.
|
|
51
|
-
* @returns The [SuiClient] object.
|
|
52
|
-
*/
|
|
53
|
-
getSuiClient() {
|
|
54
|
-
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
return this._connector.getSuiClient();
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* @deprecated Use `getSuiClient` instead
|
|
60
|
-
*/
|
|
61
|
-
getWalletClient() {
|
|
62
|
-
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
return this._connector.getSuiClient();
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Returns the wallet's current active account.
|
|
68
|
-
* @returns a readonly [WalletAccount] object.
|
|
69
|
-
*/
|
|
70
|
-
getWalletAccount() {
|
|
71
|
-
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
72
|
-
return this._connector.getWalletAccount();
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Returns the wallet's current active network.
|
|
77
|
-
* @returns a string representing the active network, i.e. 'sui:devnet'.
|
|
78
|
-
*/
|
|
79
|
-
getActiveNetwork() {
|
|
80
|
-
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
81
|
-
const account = yield this._connector.getWalletAccount();
|
|
82
|
-
return account === null || account === void 0 ? void 0 : account.chains[0];
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Signs a Sui [Transaction].
|
|
87
|
-
* @param tx - The [Transaction] to sign.
|
|
88
|
-
* @returns The signature of the signed transaction.
|
|
89
|
-
*/
|
|
90
|
-
signTransaction(transaction) {
|
|
91
|
-
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
92
|
-
var _a;
|
|
93
|
-
yield this._connector.connect();
|
|
94
|
-
const account = yield this._connector.getWalletAccount();
|
|
95
|
-
const chain = account === null || account === void 0 ? void 0 : account.chains[0];
|
|
96
|
-
if (!account) {
|
|
97
|
-
throw new utils.DynamicError('Unable to retrieve Sui wallet account');
|
|
98
|
-
}
|
|
99
|
-
if (!chain) {
|
|
100
|
-
throw new utils.DynamicError('Unable to retrieve Sui active network');
|
|
101
|
-
}
|
|
102
|
-
const transactionFeature = (_a = this._connector.getFeatures()) === null || _a === void 0 ? void 0 : _a['sui:signTransaction'];
|
|
103
|
-
if (!transactionFeature) {
|
|
104
|
-
throw new utils.DynamicError('Wallet does not support sui:signTransaction');
|
|
105
|
-
}
|
|
106
|
-
const signedTransaction = yield transactionFeature.signTransaction({
|
|
107
|
-
account,
|
|
108
|
-
chain,
|
|
109
|
-
transaction,
|
|
110
|
-
});
|
|
111
|
-
return signedTransaction;
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
exports.SuiWallet = SuiWallet;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { Transaction } from '@mysten/sui/transactions';
|
|
2
|
-
import { SuiClient } from '@mysten/sui/client';
|
|
3
|
-
import { SignedTransaction, WalletAccount } from '@mysten/wallet-standard';
|
|
4
|
-
import { Wallet } from '@dynamic-labs/wallet-connector-core';
|
|
5
|
-
import { SuiWalletConnector } from '../SuiWalletConnector';
|
|
6
|
-
import { SuiSendBalanceProps } from '../types';
|
|
7
|
-
export declare class SuiWallet extends Wallet<SuiWalletConnector> {
|
|
8
|
-
/**
|
|
9
|
-
* Sends the native balance of the wallet to the given address.
|
|
10
|
-
* @param amount - The amount of balance
|
|
11
|
-
* @param toAddress - The address to send the balance to.
|
|
12
|
-
* @returns The transaction as base64 encoded bcs.
|
|
13
|
-
*/
|
|
14
|
-
sendBalance({ amount, toAddress, }: SuiSendBalanceProps): Promise<string>;
|
|
15
|
-
/**
|
|
16
|
-
* Returns the Sui Client object initialized for the wallet's current network.
|
|
17
|
-
* @returns The [SuiClient] object.
|
|
18
|
-
*/
|
|
19
|
-
getSuiClient(): Promise<SuiClient | undefined>;
|
|
20
|
-
/**
|
|
21
|
-
* @deprecated Use `getSuiClient` instead
|
|
22
|
-
*/
|
|
23
|
-
getWalletClient(): Promise<SuiClient | undefined>;
|
|
24
|
-
/**
|
|
25
|
-
* Returns the wallet's current active account.
|
|
26
|
-
* @returns a readonly [WalletAccount] object.
|
|
27
|
-
*/
|
|
28
|
-
getWalletAccount(): Promise<WalletAccount | undefined>;
|
|
29
|
-
/**
|
|
30
|
-
* Returns the wallet's current active network.
|
|
31
|
-
* @returns a string representing the active network, i.e. 'sui:devnet'.
|
|
32
|
-
*/
|
|
33
|
-
getActiveNetwork(): Promise<string | undefined>;
|
|
34
|
-
/**
|
|
35
|
-
* Signs a Sui [Transaction].
|
|
36
|
-
* @param tx - The [Transaction] to sign.
|
|
37
|
-
* @returns The signature of the signed transaction.
|
|
38
|
-
*/
|
|
39
|
-
signTransaction(transaction: Transaction): Promise<SignedTransaction>;
|
|
40
|
-
}
|
package/src/wallet/SuiWallet.js
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
3
|
-
import { Transaction } from '@mysten/sui/transactions';
|
|
4
|
-
import { Wallet } from '@dynamic-labs/wallet-connector-core';
|
|
5
|
-
import { DynamicError } from '@dynamic-labs/utils';
|
|
6
|
-
import { MIST_PER_SUI } from '../utils/constants/constants.js';
|
|
7
|
-
|
|
8
|
-
class SuiWallet extends Wallet {
|
|
9
|
-
/**
|
|
10
|
-
* Sends the native balance of the wallet to the given address.
|
|
11
|
-
* @param amount - The amount of balance
|
|
12
|
-
* @param toAddress - The address to send the balance to.
|
|
13
|
-
* @returns The transaction as base64 encoded bcs.
|
|
14
|
-
*/
|
|
15
|
-
sendBalance(_a) {
|
|
16
|
-
return __awaiter(this, arguments, void 0, function* ({ amount, toAddress, }) {
|
|
17
|
-
var _b;
|
|
18
|
-
yield this._connector.connect();
|
|
19
|
-
const account = yield this._connector.getWalletAccount();
|
|
20
|
-
const chain = account === null || account === void 0 ? void 0 : account.chains[0];
|
|
21
|
-
if (!account) {
|
|
22
|
-
throw new DynamicError('Unable to retrieve Sui wallet account');
|
|
23
|
-
}
|
|
24
|
-
if (!chain) {
|
|
25
|
-
throw new DynamicError('Unable to retrieve Sui active network');
|
|
26
|
-
}
|
|
27
|
-
const transactionFeature = (_b = this._connector.getFeatures()) === null || _b === void 0 ? void 0 : _b['sui:signAndExecuteTransaction'];
|
|
28
|
-
if (!transactionFeature) {
|
|
29
|
-
throw new DynamicError('Wallet does not support sui:signAndExecuteTransaction');
|
|
30
|
-
}
|
|
31
|
-
const transaction = new Transaction();
|
|
32
|
-
const mistAmount = Number(amount) * MIST_PER_SUI;
|
|
33
|
-
// Let the transaction calculate gas automatically
|
|
34
|
-
// https://sdk.mystenlabs.com/typescript/transaction-building/gas#gas-price
|
|
35
|
-
const [coin] = transaction.splitCoins(transaction.gas, [mistAmount]);
|
|
36
|
-
transaction.transferObjects([coin], toAddress);
|
|
37
|
-
const { bytes } = yield transactionFeature.signAndExecuteTransaction({
|
|
38
|
-
account,
|
|
39
|
-
chain,
|
|
40
|
-
transaction,
|
|
41
|
-
});
|
|
42
|
-
return bytes;
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Returns the Sui Client object initialized for the wallet's current network.
|
|
47
|
-
* @returns The [SuiClient] object.
|
|
48
|
-
*/
|
|
49
|
-
getSuiClient() {
|
|
50
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
-
return this._connector.getSuiClient();
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* @deprecated Use `getSuiClient` instead
|
|
56
|
-
*/
|
|
57
|
-
getWalletClient() {
|
|
58
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
-
return this._connector.getSuiClient();
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Returns the wallet's current active account.
|
|
64
|
-
* @returns a readonly [WalletAccount] object.
|
|
65
|
-
*/
|
|
66
|
-
getWalletAccount() {
|
|
67
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
return this._connector.getWalletAccount();
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Returns the wallet's current active network.
|
|
73
|
-
* @returns a string representing the active network, i.e. 'sui:devnet'.
|
|
74
|
-
*/
|
|
75
|
-
getActiveNetwork() {
|
|
76
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
-
const account = yield this._connector.getWalletAccount();
|
|
78
|
-
return account === null || account === void 0 ? void 0 : account.chains[0];
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Signs a Sui [Transaction].
|
|
83
|
-
* @param tx - The [Transaction] to sign.
|
|
84
|
-
* @returns The signature of the signed transaction.
|
|
85
|
-
*/
|
|
86
|
-
signTransaction(transaction) {
|
|
87
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
88
|
-
var _a;
|
|
89
|
-
yield this._connector.connect();
|
|
90
|
-
const account = yield this._connector.getWalletAccount();
|
|
91
|
-
const chain = account === null || account === void 0 ? void 0 : account.chains[0];
|
|
92
|
-
if (!account) {
|
|
93
|
-
throw new DynamicError('Unable to retrieve Sui wallet account');
|
|
94
|
-
}
|
|
95
|
-
if (!chain) {
|
|
96
|
-
throw new DynamicError('Unable to retrieve Sui active network');
|
|
97
|
-
}
|
|
98
|
-
const transactionFeature = (_a = this._connector.getFeatures()) === null || _a === void 0 ? void 0 : _a['sui:signTransaction'];
|
|
99
|
-
if (!transactionFeature) {
|
|
100
|
-
throw new DynamicError('Wallet does not support sui:signTransaction');
|
|
101
|
-
}
|
|
102
|
-
const signedTransaction = yield transactionFeature.signTransaction({
|
|
103
|
-
account,
|
|
104
|
-
chain,
|
|
105
|
-
transaction,
|
|
106
|
-
});
|
|
107
|
-
return signedTransaction;
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export { SuiWallet };
|
package/src/wallet/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './SuiWallet';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './isSuiWallet';
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
-
|
|
6
|
-
var walletStandard = require('@mysten/wallet-standard');
|
|
7
|
-
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
8
|
-
var utils = require('@dynamic-labs/utils');
|
|
9
|
-
var injected = require('./injected.cjs');
|
|
10
|
-
|
|
11
|
-
const fetchSuiInjectedWalletConnectors = ({ walletBook, }) => {
|
|
12
|
-
var _a;
|
|
13
|
-
const walletStandardWallets = walletStandard.getWallets().get();
|
|
14
|
-
const suiWalletStandardWallets = walletStandardWallets.filter((wallet) => walletStandard.isWalletWithRequiredFeatureSet(wallet, ['sui:signPersonalMessage']));
|
|
15
|
-
const suiWalletsByKey = Object.fromEntries(suiWalletStandardWallets.map((wallet) => [wallet.name, wallet]));
|
|
16
|
-
const walletBookConnectors = Object.entries((_a = walletBook === null || walletBook === void 0 ? void 0 : walletBook.wallets) !== null && _a !== void 0 ? _a : {})
|
|
17
|
-
.filter(([, wallet]) => {
|
|
18
|
-
var _a, _b;
|
|
19
|
-
const injectedConfig = (_a = wallet.injectedConfig) === null || _a === void 0 ? void 0 : _a.find((config) => config.chain === 'sui');
|
|
20
|
-
const isSuiWallet = Boolean(injectedConfig);
|
|
21
|
-
const walletStandardName = (_b = injectedConfig === null || injectedConfig === void 0 ? void 0 : injectedConfig.walletStandard) === null || _b === void 0 ? void 0 : _b.name;
|
|
22
|
-
// If the wallet is injected via wallet standard, use that over the wallet book entry
|
|
23
|
-
const shouldBeFiltered = walletStandardName && suiWalletsByKey[walletStandardName];
|
|
24
|
-
return isSuiWallet && !shouldBeFiltered;
|
|
25
|
-
})
|
|
26
|
-
.map(([key, wallet]) => {
|
|
27
|
-
// Wallet book wallets are not currently installed on the browser
|
|
28
|
-
const isInstalled = false;
|
|
29
|
-
const metadata = walletConnectorCore.getWalletMetadataFromWalletBook({
|
|
30
|
-
walletBook,
|
|
31
|
-
walletBookWallet: wallet,
|
|
32
|
-
walletKey: key,
|
|
33
|
-
});
|
|
34
|
-
return class extends injected.Injected {
|
|
35
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
36
|
-
constructor(props) {
|
|
37
|
-
super(wallet.name, isInstalled, Object.assign({ metadata, overrideKey: key, wallet: wallet, walletBookEntry: wallet }, props));
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
});
|
|
41
|
-
// The remaining wallets are wallet standard wallets injected from the browser
|
|
42
|
-
const isInstalled = true;
|
|
43
|
-
// Wallet standard wallets don't always have injectedConfig from wallet book,
|
|
44
|
-
// so we filter them by checking if they support critical sui features.
|
|
45
|
-
const walletStandardConnectors = walletStandardWallets
|
|
46
|
-
.filter((wallet) => { var _a; return (_a = wallet.features) === null || _a === void 0 ? void 0 : _a['sui:signPersonalMessage']; })
|
|
47
|
-
.map((wallet) => {
|
|
48
|
-
const sanitizedName = utils.sanitizeName(wallet.name);
|
|
49
|
-
return class extends injected.Injected {
|
|
50
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
51
|
-
constructor(props) {
|
|
52
|
-
super(wallet.name, isInstalled, Object.assign({ metadata: {
|
|
53
|
-
groupKey: sanitizedName,
|
|
54
|
-
icon: wallet.icon,
|
|
55
|
-
id: wallet.name,
|
|
56
|
-
name: wallet.name,
|
|
57
|
-
}, name: wallet.name, overrideKey: `${sanitizedName}sui`, wallet: wallet }, props));
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
});
|
|
61
|
-
return [...walletBookConnectors, ...walletStandardConnectors];
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
exports.fetchSuiInjectedWalletConnectors = fetchSuiInjectedWalletConnectors;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { WalletConnectorConstructor } from '@dynamic-labs/wallet-connector-core';
|
|
2
|
-
import { WalletBookSchema } from '@dynamic-labs/wallet-book';
|
|
3
|
-
export declare const fetchSuiInjectedWalletConnectors: ({ walletBook, }: {
|
|
4
|
-
walletBook?: WalletBookSchema;
|
|
5
|
-
}) => WalletConnectorConstructor[];
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
import { getWallets, isWalletWithRequiredFeatureSet } from '@mysten/wallet-standard';
|
|
3
|
-
import { getWalletMetadataFromWalletBook } from '@dynamic-labs/wallet-connector-core';
|
|
4
|
-
import { sanitizeName } from '@dynamic-labs/utils';
|
|
5
|
-
import { Injected } from './injected.js';
|
|
6
|
-
|
|
7
|
-
const fetchSuiInjectedWalletConnectors = ({ walletBook, }) => {
|
|
8
|
-
var _a;
|
|
9
|
-
const walletStandardWallets = getWallets().get();
|
|
10
|
-
const suiWalletStandardWallets = walletStandardWallets.filter((wallet) => isWalletWithRequiredFeatureSet(wallet, ['sui:signPersonalMessage']));
|
|
11
|
-
const suiWalletsByKey = Object.fromEntries(suiWalletStandardWallets.map((wallet) => [wallet.name, wallet]));
|
|
12
|
-
const walletBookConnectors = Object.entries((_a = walletBook === null || walletBook === void 0 ? void 0 : walletBook.wallets) !== null && _a !== void 0 ? _a : {})
|
|
13
|
-
.filter(([, wallet]) => {
|
|
14
|
-
var _a, _b;
|
|
15
|
-
const injectedConfig = (_a = wallet.injectedConfig) === null || _a === void 0 ? void 0 : _a.find((config) => config.chain === 'sui');
|
|
16
|
-
const isSuiWallet = Boolean(injectedConfig);
|
|
17
|
-
const walletStandardName = (_b = injectedConfig === null || injectedConfig === void 0 ? void 0 : injectedConfig.walletStandard) === null || _b === void 0 ? void 0 : _b.name;
|
|
18
|
-
// If the wallet is injected via wallet standard, use that over the wallet book entry
|
|
19
|
-
const shouldBeFiltered = walletStandardName && suiWalletsByKey[walletStandardName];
|
|
20
|
-
return isSuiWallet && !shouldBeFiltered;
|
|
21
|
-
})
|
|
22
|
-
.map(([key, wallet]) => {
|
|
23
|
-
// Wallet book wallets are not currently installed on the browser
|
|
24
|
-
const isInstalled = false;
|
|
25
|
-
const metadata = getWalletMetadataFromWalletBook({
|
|
26
|
-
walletBook,
|
|
27
|
-
walletBookWallet: wallet,
|
|
28
|
-
walletKey: key,
|
|
29
|
-
});
|
|
30
|
-
return class extends Injected {
|
|
31
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
32
|
-
constructor(props) {
|
|
33
|
-
super(wallet.name, isInstalled, Object.assign({ metadata, overrideKey: key, wallet: wallet, walletBookEntry: wallet }, props));
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
});
|
|
37
|
-
// The remaining wallets are wallet standard wallets injected from the browser
|
|
38
|
-
const isInstalled = true;
|
|
39
|
-
// Wallet standard wallets don't always have injectedConfig from wallet book,
|
|
40
|
-
// so we filter them by checking if they support critical sui features.
|
|
41
|
-
const walletStandardConnectors = walletStandardWallets
|
|
42
|
-
.filter((wallet) => { var _a; return (_a = wallet.features) === null || _a === void 0 ? void 0 : _a['sui:signPersonalMessage']; })
|
|
43
|
-
.map((wallet) => {
|
|
44
|
-
const sanitizedName = sanitizeName(wallet.name);
|
|
45
|
-
return class extends Injected {
|
|
46
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
|
-
constructor(props) {
|
|
48
|
-
super(wallet.name, isInstalled, Object.assign({ metadata: {
|
|
49
|
-
groupKey: sanitizedName,
|
|
50
|
-
icon: wallet.icon,
|
|
51
|
-
id: wallet.name,
|
|
52
|
-
name: wallet.name,
|
|
53
|
-
}, name: wallet.name, overrideKey: `${sanitizedName}sui`, wallet: wallet }, props));
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
});
|
|
57
|
-
return [...walletBookConnectors, ...walletStandardConnectors];
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export { fetchSuiInjectedWalletConnectors };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './injected';
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
-
|
|
6
|
-
var SuiWalletConnector = require('../../SuiWalletConnector.cjs');
|
|
7
|
-
|
|
8
|
-
class Injected extends SuiWalletConnector.SuiWalletConnector {
|
|
9
|
-
constructor(name, isInstalledOnBrowser, props) {
|
|
10
|
-
super(name, props);
|
|
11
|
-
this._isInstalledOnBrowser = isInstalledOnBrowser;
|
|
12
|
-
this.overrideKey = props.overrideKey;
|
|
13
|
-
}
|
|
14
|
-
isInstalledOnBrowser() {
|
|
15
|
-
return this._isInstalledOnBrowser;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
exports.Injected = Injected;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { SuiWalletConnector } from '../../SuiWalletConnector';
|
|
2
|
-
import { SuiWalletConnectorProps } from '../../types';
|
|
3
|
-
export declare class Injected extends SuiWalletConnector {
|
|
4
|
-
/**
|
|
5
|
-
* Tracks whether the injected wallet is installed on the browser
|
|
6
|
-
*
|
|
7
|
-
* If the wallet is in wallet book but not found with getWallets().get(),
|
|
8
|
-
* it's not installed on the browser.
|
|
9
|
-
*/
|
|
10
|
-
private _isInstalledOnBrowser;
|
|
11
|
-
constructor(name: string, isInstalledOnBrowser: boolean, props: SuiWalletConnectorProps);
|
|
12
|
-
isInstalledOnBrowser(): boolean;
|
|
13
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
import { SuiWalletConnector } from '../../SuiWalletConnector.js';
|
|
3
|
-
|
|
4
|
-
class Injected extends SuiWalletConnector {
|
|
5
|
-
constructor(name, isInstalledOnBrowser, props) {
|
|
6
|
-
super(name, props);
|
|
7
|
-
this._isInstalledOnBrowser = isInstalledOnBrowser;
|
|
8
|
-
this.overrideKey = props.overrideKey;
|
|
9
|
-
}
|
|
10
|
-
isInstalledOnBrowser() {
|
|
11
|
-
return this._isInstalledOnBrowser;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export { Injected };
|