@binance/w3w-multichain-connector 1.0.0 → 1.0.2
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/index.d.ts +3 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/getMultichainWallet.ts +1 -1
- package/src/type.ts +7 -9
package/dist/index.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ interface IConnectedWallet {
|
|
|
37
37
|
walletType: WalletType;
|
|
38
38
|
addressList: {
|
|
39
39
|
address: string;
|
|
40
|
-
|
|
40
|
+
binanceChainId: string;
|
|
41
41
|
}[];
|
|
42
42
|
}
|
|
43
43
|
interface WalletEvents {
|
|
@@ -47,19 +47,13 @@ interface WalletEvents {
|
|
|
47
47
|
connectedChainIdChanged: (binanceChainId: string) => void;
|
|
48
48
|
}
|
|
49
49
|
interface IWallet extends EventEmitter<WalletEvents> {
|
|
50
|
-
/**
|
|
51
|
-
* 弹出连接请求
|
|
52
|
-
* 若已链接,则直接返回已连接的钱包
|
|
53
|
-
* 用户的当前活跃钱包会出现在数组的第一个
|
|
54
|
-
* 若用户拒绝,会报4001用户拒绝
|
|
55
|
-
* @param binanceChainIds 请求链接网络的binanceChainId
|
|
56
|
-
*/
|
|
57
50
|
requestConnect(binanceChainIds: string[]): Promise<IConnectedWallet[]>;
|
|
58
51
|
/**
|
|
59
52
|
* 检查当前连接的钱包
|
|
60
53
|
* 用户的当前活跃钱包会出现在数组的第一个
|
|
61
54
|
*/
|
|
62
55
|
checkConnectedWallet(): Promise<IConnectedWallet[]>;
|
|
56
|
+
getWalletInfo(address: string, binanceChainId: string): Promise<IConnectedWallet | null>;
|
|
63
57
|
/**
|
|
64
58
|
* 断开所有连接的钱包
|
|
65
59
|
*/
|
|
@@ -91,6 +85,6 @@ declare const checkExtensionInstalled: () => boolean;
|
|
|
91
85
|
* 检查当前用户安装的插件是否支持
|
|
92
86
|
*/
|
|
93
87
|
declare const checkExtensionSupported: (feature: Features) => any;
|
|
94
|
-
declare const getMultichainWallet: () => IWallet;
|
|
88
|
+
declare const getMultichainWallet: () => IWallet | null;
|
|
95
89
|
|
|
96
90
|
export { ChainType, Features, IConnectedWallet, IWallet, WalletEvents, WalletType, checkExtensionInstalled, checkExtensionSupported, getMultichainWallet };
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/enum.ts","../src/getMultichainWallet.ts"],"sourcesContent":["export const enum ChainType {\n EVM = 'EVM',\n SOL = 'SOL',\n}\n\n/**\n * privateKey:私钥钱包\n * hd: 助记词钱包\n */\nexport const enum WalletType {\n privateKey = 'privateKey',\n seedPhrase = 'hd',\n}\n\nexport const enum Features {\n requestConnect = 'requestConnect',\n checkConnectedWallet = 'checkConnectedWallet',\n disconnect = 'disconnect',\n switchChain = 'switchChain',\n requestAutoSign = 'requestAutoSign',\n eventWalletLockedChanged = 'eventWalletLockedChanged',\n eventAutoSignEnabledChanged = 'eventAutoSignEnabledChanged',\n eventConnectedWalletsChanged = 'eventConnectedWalletsChanged',\n eventConnectedChainIdChanged = 'eventConnectedChainIdChanged',\n}\n","import { Features } from './enum'\nimport type { IWallet } from './type'\n\nexport const checkExtensionInstalled = () => {\n try {\n return !!(window as any)?.binancew3w?.isExtension\n } catch (error) {\n return false\n }\n}\n\n/**\n * 检查当前用户安装的插件是否支持\n */\nexport const checkExtensionSupported = (feature: Features) => {\n const wallet = getInjectedWallet()\n if (!wallet) {\n return false\n }\n return wallet.checkSupportFeature(feature)\n}\n\nconst getInjectedWallet = () => {\n const isInstalled = checkExtensionInstalled()\n if (!isInstalled) {\n return null\n }\n return (window as any).binancew3w?.wallet\n}\n\nexport const getMultichainWallet = (): IWallet => {\n return getInjectedWallet()\n}\n"],"mappings":"AAAO,IAAWA,OAChBA,EAAA,IAAM,MACNA,EAAA,IAAM,MAFUA,OAAA,IASAC,OAChBA,EAAA,WAAa,aACbA,EAAA,WAAa,KAFGA,OAAA,IAKAC,OAChBA,EAAA,eAAiB,iBACjBA,EAAA,qBAAuB,uBACvBA,EAAA,WAAa,aACbA,EAAA,YAAc,cACdA,EAAA,gBAAkB,kBAClBA,EAAA,yBAA2B,2BAC3BA,EAAA,4BAA8B,8BAC9BA,EAAA,6BAA+B,+BAC/BA,EAAA,6BAA+B,+BATfA,OAAA,ICXX,IAAMC,EAA0B,IAAM,CAC3C,GAAI,CACF,MAAO,CAAC,CAAE,QAAgB,YAAY,WACxC,MAAE,CACA,MAAO,EACT,CACF,EAKaC,EAA2BC,GAAsB,CAC5D,IAAMC,EAASC,EAAkB,EACjC,OAAKD,EAGEA,EAAO,oBAAoBD,CAAO,EAFhC,EAGX,EAEME,EAAoB,IACJJ,EAAwB,EAIpC,OAAe,YAAY,OAF1B,KAKEK,EAAsB,IAC1BD,EAAkB","names":["ChainType","WalletType","Features","checkExtensionInstalled","checkExtensionSupported","feature","wallet","getInjectedWallet","getMultichainWallet"]}
|
|
1
|
+
{"version":3,"sources":["../src/enum.ts","../src/getMultichainWallet.ts"],"sourcesContent":["export const enum ChainType {\n EVM = 'EVM',\n SOL = 'SOL',\n}\n\n/**\n * privateKey:私钥钱包\n * hd: 助记词钱包\n */\nexport const enum WalletType {\n privateKey = 'privateKey',\n seedPhrase = 'hd',\n}\n\nexport const enum Features {\n requestConnect = 'requestConnect',\n checkConnectedWallet = 'checkConnectedWallet',\n disconnect = 'disconnect',\n switchChain = 'switchChain',\n requestAutoSign = 'requestAutoSign',\n eventWalletLockedChanged = 'eventWalletLockedChanged',\n eventAutoSignEnabledChanged = 'eventAutoSignEnabledChanged',\n eventConnectedWalletsChanged = 'eventConnectedWalletsChanged',\n eventConnectedChainIdChanged = 'eventConnectedChainIdChanged',\n}\n","import { Features } from './enum'\nimport type { IWallet } from './type'\n\nexport const checkExtensionInstalled = () => {\n try {\n return !!(window as any)?.binancew3w?.isExtension\n } catch (error) {\n return false\n }\n}\n\n/**\n * 检查当前用户安装的插件是否支持\n */\nexport const checkExtensionSupported = (feature: Features) => {\n const wallet = getInjectedWallet()\n if (!wallet) {\n return false\n }\n return wallet.checkSupportFeature(feature)\n}\n\nconst getInjectedWallet = () => {\n const isInstalled = checkExtensionInstalled()\n if (!isInstalled) {\n return null\n }\n return (window as any).binancew3w?.wallet\n}\n\nexport const getMultichainWallet = (): IWallet | null => {\n return getInjectedWallet()\n}\n"],"mappings":"AAAO,IAAWA,OAChBA,EAAA,IAAM,MACNA,EAAA,IAAM,MAFUA,OAAA,IASAC,OAChBA,EAAA,WAAa,aACbA,EAAA,WAAa,KAFGA,OAAA,IAKAC,OAChBA,EAAA,eAAiB,iBACjBA,EAAA,qBAAuB,uBACvBA,EAAA,WAAa,aACbA,EAAA,YAAc,cACdA,EAAA,gBAAkB,kBAClBA,EAAA,yBAA2B,2BAC3BA,EAAA,4BAA8B,8BAC9BA,EAAA,6BAA+B,+BAC/BA,EAAA,6BAA+B,+BATfA,OAAA,ICXX,IAAMC,EAA0B,IAAM,CAC3C,GAAI,CACF,MAAO,CAAC,CAAE,QAAgB,YAAY,WACxC,MAAE,CACA,MAAO,EACT,CACF,EAKaC,EAA2BC,GAAsB,CAC5D,IAAMC,EAASC,EAAkB,EACjC,OAAKD,EAGEA,EAAO,oBAAoBD,CAAO,EAFhC,EAGX,EAEME,EAAoB,IACJJ,EAAwB,EAIpC,OAAe,YAAY,OAF1B,KAKEK,EAAsB,IAC1BD,EAAkB","names":["ChainType","WalletType","Features","checkExtensionInstalled","checkExtensionSupported","feature","wallet","getInjectedWallet","getMultichainWallet"]}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@binance/w3w-multichain-connector",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "A multichain connector for Binance Wallet",
|
|
5
|
-
"main": "dist/index.
|
|
5
|
+
"main": "dist/index.mjs",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"keywords": [],
|
|
8
8
|
"author": "Binance",
|
package/src/type.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type EventEmitter from 'eventemitter3'
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { WalletType } from './enum'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* 链接的钱包
|
|
@@ -19,7 +19,7 @@ export interface IConnectedWallet {
|
|
|
19
19
|
|
|
20
20
|
addressList: {
|
|
21
21
|
address: string
|
|
22
|
-
|
|
22
|
+
binanceChainId: string
|
|
23
23
|
}[]
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -31,13 +31,6 @@ export interface WalletEvents {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
export interface IWallet extends EventEmitter<WalletEvents> {
|
|
34
|
-
/**
|
|
35
|
-
* 弹出连接请求
|
|
36
|
-
* 若已链接,则直接返回已连接的钱包
|
|
37
|
-
* 用户的当前活跃钱包会出现在数组的第一个
|
|
38
|
-
* 若用户拒绝,会报4001用户拒绝
|
|
39
|
-
* @param binanceChainIds 请求链接网络的binanceChainId
|
|
40
|
-
*/
|
|
41
34
|
requestConnect(binanceChainIds: string[]): Promise<IConnectedWallet[]>
|
|
42
35
|
|
|
43
36
|
/**
|
|
@@ -46,6 +39,11 @@ export interface IWallet extends EventEmitter<WalletEvents> {
|
|
|
46
39
|
*/
|
|
47
40
|
checkConnectedWallet(): Promise<IConnectedWallet[]>
|
|
48
41
|
|
|
42
|
+
getWalletInfo(
|
|
43
|
+
address: string,
|
|
44
|
+
binanceChainId: string
|
|
45
|
+
): Promise<IConnectedWallet | null>
|
|
46
|
+
|
|
49
47
|
/**
|
|
50
48
|
* 断开所有连接的钱包
|
|
51
49
|
*/
|