diff --git a/core/base/src/emitter/index.ts b/core/base/src/emitter/index.ts index d64e6b2..38f4d78 100644 --- a/core/base/src/emitter/index.ts +++ b/core/base/src/emitter/index.ts @@ -251,13 +251,13 @@ class Emitter { return this.RPCMethod.typedSign(typedData); }; - public addChain: T['addChain'] = (params: unknown) => { + public addChain = (params: Parameters[0], needConnected = true) => { if (!this.RPCMethod.addChain) { throw new Error(`Current Wallet does'nt have addChain method.`); } - this.checkConnected('addChain'); - return this.RPCMethod.addChain(params); + needConnected && this.checkConnected('addChain'); + return this.RPCMethod.addChain(params) as ReturnType; }; public switchChain: T['switchChain'] = (params: unknown) => { diff --git a/core/react/build/dts/chain.d.ts b/core/react/build/dts/chain.d.ts index e93ca82..4363d9e 100644 --- a/core/react/build/dts/chain.d.ts +++ b/core/react/build/dts/chain.d.ts @@ -19,7 +19,7 @@ export declare const connect: () => Promise; export declare const sendTransaction: (params: Omit) => Promise; export declare const personalSign: (message: string) => Promise; export declare const typedSign: (typedData: import("./type").TypedSignParams) => Promise; -export declare const addChain: (params: import("./type").AddChainParameter) => Promise; +export declare const addChain: (params: import('./type').AddChainParameter, needConnected?: boolean) => Promise; export declare const switchChain: (chainId: string) => Promise; export declare const watchAsset: (param: import("./type").WatchAssetParams) => Promise; export declare const provider: import("./type").Provider | undefined; diff --git a/core/react/build/dts/wallet.d.ts b/core/react/build/dts/wallet.d.ts index 5a478aa..ae1997a 100644 --- a/core/react/build/dts/wallet.d.ts +++ b/core/react/build/dts/wallet.d.ts @@ -23,7 +23,7 @@ export declare const connect: () => Promise; export declare const sendTransaction: (params: Omit) => Promise; export declare const personalSign: (message: string) => Promise; export declare const typedSign: (typedData: import('./type').TypedSignParams) => Promise; -export declare const addChain: (params: import('./type').AddChainParameter) => Promise; +export declare const addChain: (params: import('./type').AddChainParameter, needConnected?: boolean) => Promise; export declare const switchChain: (chainId: string) => Promise; export declare const watchAsset: (param: import('./type').WatchAssetParams) => Promise; export declare const provider: import('./type').Provider | undefined; diff --git a/core/react/package.json b/core/react/package.json index 8e0a9e1..74efa16 100644 --- a/core/react/package.json +++ b/core/react/package.json @@ -1,6 +1,6 @@ { "name": "react", - "version": "0.0.2-5", + "version": "0.0.2-6", "type": "module", "scripts": { "build": "rimraf dist && node ./build/index.js", diff --git a/core/vue3/build/dts/chain.d.ts b/core/vue3/build/dts/chain.d.ts index 8737279..70261a5 100644 --- a/core/vue3/build/dts/chain.d.ts +++ b/core/vue3/build/dts/chain.d.ts @@ -16,7 +16,7 @@ export declare const connect: () => Promise; export declare const sendTransaction: (params: Omit) => Promise; export declare const personalSign: (message: string) => Promise; export declare const typedSign: (typedData: Record) => Promise; -export declare const addChain: (params: import("./type").AddChainParameter) => Promise; +export declare const addChain: (params: import('./type').AddChainParameter, needConnected?: boolean) => Promise; export declare const switchChain: (chainId: string) => Promise; export declare const watchAsset: (param: import("./type").WatchAssetParams) => Promise; export declare const provider: import("./type").Provider | undefined; diff --git a/core/vue3/build/dts/wallet.d.ts b/core/vue3/build/dts/wallet.d.ts index e61d86c..8c5ca6e 100644 --- a/core/vue3/build/dts/wallet.d.ts +++ b/core/vue3/build/dts/wallet.d.ts @@ -16,7 +16,7 @@ export declare const connect: () => Promise; export declare const sendTransaction: (params: Omit) => Promise; export declare const personalSign: (message: string) => Promise; export declare const typedSign: (typedData: Record) => Promise; -export declare const addChain: (params: import("./type").AddChainParameter) => Promise; +export declare const addChain: (params: import('./type').AddChainParameter, needConnected?: boolean) => Promise; export declare const switchChain: (chainId: string) => Promise; export declare const watchAsset: (param: import("./type").WatchAssetParams) => Promise; export declare const provider: import("./type").Provider | undefined; diff --git a/core/vue3/package.json b/core/vue3/package.json index 4fc74f1..c5816a2 100644 --- a/core/vue3/package.json +++ b/core/vue3/package.json @@ -1,6 +1,6 @@ { "name": "vue3", - "version": "0.0.2-5", + "version": "0.0.2-6", "type": "module", "scripts": { "build": "rimraf dist && node ./build/index.js",