@earthworm/wallet-sdk 0.2.3 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/account-sync-EPEP5KUV.js +2 -0
- package/dist/{chunk-Z2EMFRMV.js → chunk-F7UNIZSN.js} +21 -7
- package/dist/chunk-HLZ3QZTH.js +19 -0
- package/dist/{chunk-TPFOHQNS.js → chunk-XTONTXHH.js} +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/dist/{network-WJN3S7KB.js → network-BRDZGVT6.js} +2 -2
- package/package.json +1 -1
- package/dist/account-sync-77HMBIWC.js +0 -2
- package/dist/chunk-BUZ26NFL.js +0 -48
|
@@ -705,8 +705,8 @@ var DEFAULT_RETRY = {
|
|
|
705
705
|
emptyAccountsRetryIntervalMs: 0
|
|
706
706
|
};
|
|
707
707
|
var TRONLINK_RETRY = {
|
|
708
|
-
emptyAccountsRetryAttempts:
|
|
709
|
-
emptyAccountsRetryIntervalMs:
|
|
708
|
+
emptyAccountsRetryAttempts: 0,
|
|
709
|
+
emptyAccountsRetryIntervalMs: 0
|
|
710
710
|
};
|
|
711
711
|
var walletEventAdapters = {
|
|
712
712
|
metamask: {
|
|
@@ -777,9 +777,23 @@ function unbindTronLinkLegacyMessages() {
|
|
|
777
777
|
tronLinkMessageListener = null;
|
|
778
778
|
}
|
|
779
779
|
async function handleAccountsChanged(wallet, nativeEvent) {
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
780
|
+
if (nativeEvent.name === "disconnectWeb") {
|
|
781
|
+
const { applyWalletDisconnectEffect } = await import('./account-sync-EPEP5KUV.js');
|
|
782
|
+
const result2 = applyWalletDisconnectEffect();
|
|
783
|
+
if (result2.action === "disconnected") {
|
|
784
|
+
dispatch("accountsChanged", wallet, nativeEvent);
|
|
785
|
+
}
|
|
786
|
+
return;
|
|
787
|
+
}
|
|
788
|
+
const { applyWalletAccountsChangedEffect } = await import('./account-sync-EPEP5KUV.js');
|
|
789
|
+
const result = await applyWalletAccountsChangedEffect(wallet, nativeEvent.payload);
|
|
790
|
+
if (result.action !== "synced" || !result.address) {
|
|
791
|
+
return;
|
|
792
|
+
}
|
|
793
|
+
dispatch("accountsChanged", wallet, {
|
|
794
|
+
...nativeEvent,
|
|
795
|
+
payload: [result.address]
|
|
796
|
+
});
|
|
783
797
|
}
|
|
784
798
|
function bindTronLinkLegacyMessages(wallet) {
|
|
785
799
|
if (!isBrowser || wallet !== "tronlink" || tronLinkMessageListener) {
|
|
@@ -974,7 +988,7 @@ async function connectWallet(eip1193, options = {}) {
|
|
|
974
988
|
}
|
|
975
989
|
);
|
|
976
990
|
if (options.chainId && isActiveConnectionSession(runtime, session)) {
|
|
977
|
-
const { switchToConfiguredNetwork } = await import('./network-
|
|
991
|
+
const { switchToConfiguredNetwork } = await import('./network-BRDZGVT6.js');
|
|
978
992
|
await switchToConfiguredNetwork(options.chainId);
|
|
979
993
|
}
|
|
980
994
|
return result;
|
|
@@ -1062,4 +1076,4 @@ function disconnectWallet() {
|
|
|
1062
1076
|
setWalletReadProvider(null);
|
|
1063
1077
|
}
|
|
1064
1078
|
|
|
1065
|
-
export { BSC_NETWORK, BSC_TESTNET_NETWORK, ERC20_ABI, ERC20_DECIMALS, ERC20_DECIMALS_ABI, SUPPORTED_BSC_CHAIN_IDS, USDT_CONFIG, WalletEvents, assertBrowser, bindBrowserProvider, bindWalletProvider, clearJsonRpcReadProviderCache, clearWalletRuntime, connectWallet, connectWalletAccount, createJsonRpcReadProvider, disconnectWallet, emitWalletEvent, getActiveWalletKey, getConfiguredReadProvider, getConnectedAddress, getContractDecimals, getContractPrice, getReadProviderWithFallback, getSelectedWalletProvider, getSharedBrowserProvider, getWalletAccounts, getWalletBrowserProvider,
|
|
1079
|
+
export { BSC_NETWORK, BSC_TESTNET_NETWORK, ERC20_ABI, ERC20_DECIMALS, ERC20_DECIMALS_ABI, SUPPORTED_BSC_CHAIN_IDS, USDT_CONFIG, WalletEvents, assertBrowser, bindBrowserProvider, bindWalletProvider, clearJsonRpcReadProviderCache, clearWalletRuntime, connectWallet, connectWalletAccount, createJsonRpcReadProvider, disconnectWallet, emitWalletEvent, getActiveWalletKey, getConfiguredReadProvider, getConnectedAddress, getContractDecimals, getContractPrice, getReadProviderWithFallback, getSelectedWalletProvider, getSharedBrowserProvider, getWalletAccounts, getWalletBrowserProvider, getWalletEventProvider, getWalletSdkConfig, getWalletSigner, hasDeployedContract, initWalletSdk, isBrowser, isContractDeployed, isWalletConnected, isWalletSdkInitialized, normalizeSupportedBscChainId, readConfiguredUsdtDecimals, readErc20Balance, readErc20Decimals, readUsdtBalance, refreshWalletAccounts, refreshWalletReadProvider, requestWallet, resetWalletSdkConfig, resolveChainConfig, resolveWalletKey, setWalletEventProvider, setWalletReadProvider, switchWalletAccount, syncConnectedWalletAccount, syncWalletAccountAddress, syncWalletRuntimeProvider, toChainIdDecimal, walletEvents };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { syncConnectedWalletAccount, isWalletConnected, disconnectWallet } from './chunk-F7UNIZSN.js';
|
|
2
|
+
|
|
3
|
+
// src/wallet/account-sync.ts
|
|
4
|
+
async function applyWalletAccountsChangedEffect(wallet, accounts) {
|
|
5
|
+
if (!accounts.length) {
|
|
6
|
+
return { action: "ignored" };
|
|
7
|
+
}
|
|
8
|
+
const result = await syncConnectedWalletAccount(accounts[0]);
|
|
9
|
+
return { action: "synced", address: result.address };
|
|
10
|
+
}
|
|
11
|
+
function applyWalletDisconnectEffect() {
|
|
12
|
+
if (!isWalletConnected()) {
|
|
13
|
+
return { action: "ignored" };
|
|
14
|
+
}
|
|
15
|
+
disconnectWallet();
|
|
16
|
+
return { action: "disconnected" };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { applyWalletAccountsChangedEffect, applyWalletDisconnectEffect };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getWalletEventProvider, resolveChainConfig, requestWallet, syncWalletRuntimeProvider, emitWalletEvent, getActiveWalletKey } from './chunk-
|
|
1
|
+
import { getWalletEventProvider, resolveChainConfig, requestWallet, syncWalletRuntimeProvider, emitWalletEvent, getActiveWalletKey } from './chunk-F7UNIZSN.js';
|
|
2
2
|
|
|
3
3
|
// src/core/network.ts
|
|
4
4
|
async function ensureTargetNetwork(options) {
|
package/dist/index.d.ts
CHANGED
|
@@ -572,8 +572,8 @@ type WalletAccountsSyncResult = {
|
|
|
572
572
|
address?: string;
|
|
573
573
|
};
|
|
574
574
|
/**
|
|
575
|
-
* @en
|
|
576
|
-
* @zh
|
|
575
|
+
* @en Sync signer when payload includes an account address; ignore empty payloads.
|
|
576
|
+
* @zh 仅当 payload 含账户地址时同步 signer;空 payload 忽略,不清空连接。
|
|
577
577
|
*/
|
|
578
578
|
declare function applyWalletAccountsChangedEffect(wallet: SupportedWalletKey, accounts: string[]): Promise<WalletAccountsSyncResult>;
|
|
579
579
|
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { applyWalletAccountsChangedEffect } from './chunk-
|
|
2
|
-
export { ensureTargetNetwork, switchToConfiguredNetwork } from './chunk-
|
|
3
|
-
import { isBrowser } from './chunk-
|
|
4
|
-
export { BSC_NETWORK, BSC_TESTNET_NETWORK, ERC20_ABI, ERC20_DECIMALS, ERC20_DECIMALS_ABI, SUPPORTED_BSC_CHAIN_IDS, USDT_CONFIG, WalletEvents, assertBrowser, bindBrowserProvider, bindWalletProvider, clearJsonRpcReadProviderCache, clearWalletRuntime, connectWallet, connectWalletAccount, createJsonRpcReadProvider, disconnectWallet, emitWalletEvent, getActiveWalletKey, getConfiguredReadProvider, getConnectedAddress, getContractDecimals, getContractPrice, getReadProviderWithFallback, getSelectedWalletProvider, getSharedBrowserProvider, getWalletAccounts, getWalletBrowserProvider, getWalletEventProvider, getWalletSdkConfig, getWalletSigner, hasDeployedContract, initWalletSdk, isBrowser, isContractDeployed, isWalletConnected, isWalletSdkInitialized, normalizeSupportedBscChainId, readConfiguredUsdtDecimals, readErc20Balance, readErc20Decimals, readUsdtBalance, refreshWalletAccounts, refreshWalletReadProvider, requestWallet, resetWalletSdkConfig, resolveChainConfig, resolveWalletKey, setWalletEventProvider, setWalletReadProvider, switchWalletAccount, syncConnectedWalletAccount, syncWalletAccountAddress, syncWalletRuntimeProvider, toChainIdDecimal, walletEvents } from './chunk-
|
|
1
|
+
export { applyWalletAccountsChangedEffect } from './chunk-HLZ3QZTH.js';
|
|
2
|
+
export { ensureTargetNetwork, switchToConfiguredNetwork } from './chunk-XTONTXHH.js';
|
|
3
|
+
import { isBrowser } from './chunk-F7UNIZSN.js';
|
|
4
|
+
export { BSC_NETWORK, BSC_TESTNET_NETWORK, ERC20_ABI, ERC20_DECIMALS, ERC20_DECIMALS_ABI, SUPPORTED_BSC_CHAIN_IDS, USDT_CONFIG, WalletEvents, assertBrowser, bindBrowserProvider, bindWalletProvider, clearJsonRpcReadProviderCache, clearWalletRuntime, connectWallet, connectWalletAccount, createJsonRpcReadProvider, disconnectWallet, emitWalletEvent, getActiveWalletKey, getConfiguredReadProvider, getConnectedAddress, getContractDecimals, getContractPrice, getReadProviderWithFallback, getSelectedWalletProvider, getSharedBrowserProvider, getWalletAccounts, getWalletBrowserProvider, getWalletEventProvider, getWalletSdkConfig, getWalletSigner, hasDeployedContract, initWalletSdk, isBrowser, isContractDeployed, isWalletConnected, isWalletSdkInitialized, normalizeSupportedBscChainId, readConfiguredUsdtDecimals, readErc20Balance, readErc20Decimals, readUsdtBalance, refreshWalletAccounts, refreshWalletReadProvider, requestWallet, resetWalletSdkConfig, resolveChainConfig, resolveWalletKey, setWalletEventProvider, setWalletReadProvider, switchWalletAccount, syncConnectedWalletAccount, syncWalletAccountAddress, syncWalletRuntimeProvider, toChainIdDecimal, walletEvents } from './chunk-F7UNIZSN.js';
|
|
5
5
|
|
|
6
6
|
// src/wallet/eip6963.ts
|
|
7
7
|
var EIP6963_ANNOUNCE = "eip6963:announceProvider";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { ensureTargetNetwork, switchToConfiguredNetwork } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { ensureTargetNetwork, switchToConfiguredNetwork } from './chunk-XTONTXHH.js';
|
|
2
|
+
import './chunk-F7UNIZSN.js';
|
package/package.json
CHANGED
package/dist/chunk-BUZ26NFL.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { syncConnectedWalletAccount, isWalletConnected, getWalletEventAdapter, disconnectWallet, getSelectedWalletProvider, getWalletAccounts } from './chunk-Z2EMFRMV.js';
|
|
2
|
-
|
|
3
|
-
// src/wallet/account-sync.ts
|
|
4
|
-
function delay(ms) {
|
|
5
|
-
return new Promise((resolve) => {
|
|
6
|
-
setTimeout(resolve, ms);
|
|
7
|
-
});
|
|
8
|
-
}
|
|
9
|
-
async function recoverAccountsForWallet(wallet) {
|
|
10
|
-
const adapter = getWalletEventAdapter(wallet);
|
|
11
|
-
for (let attempt = 0; attempt < adapter.emptyAccountsRetryAttempts; attempt++) {
|
|
12
|
-
if (attempt > 0) {
|
|
13
|
-
await delay(adapter.emptyAccountsRetryIntervalMs);
|
|
14
|
-
}
|
|
15
|
-
if (!getSelectedWalletProvider()) {
|
|
16
|
-
return [];
|
|
17
|
-
}
|
|
18
|
-
try {
|
|
19
|
-
const accounts = await getWalletAccounts();
|
|
20
|
-
if (accounts.length > 0) {
|
|
21
|
-
return accounts;
|
|
22
|
-
}
|
|
23
|
-
} catch {
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return [];
|
|
27
|
-
}
|
|
28
|
-
async function applyWalletAccountsChangedEffect(wallet, accounts) {
|
|
29
|
-
if (accounts.length > 0) {
|
|
30
|
-
const result = await syncConnectedWalletAccount(accounts[0]);
|
|
31
|
-
return { action: "synced", address: result.address };
|
|
32
|
-
}
|
|
33
|
-
if (!isWalletConnected()) {
|
|
34
|
-
return { action: "ignored" };
|
|
35
|
-
}
|
|
36
|
-
const adapter = getWalletEventAdapter(wallet);
|
|
37
|
-
if (adapter.emptyAccountsRetryAttempts > 0) {
|
|
38
|
-
const recovered = await recoverAccountsForWallet(wallet);
|
|
39
|
-
if (recovered.length > 0) {
|
|
40
|
-
const result = await syncConnectedWalletAccount(recovered[0]);
|
|
41
|
-
return { action: "synced", address: result.address };
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
disconnectWallet();
|
|
45
|
-
return { action: "disconnected" };
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export { applyWalletAccountsChangedEffect };
|