Skip to content

Commit

Permalink
feat: export start/stop trackBalance
Browse files Browse the repository at this point in the history
  • Loading branch information
SSSensational committed Jan 12, 2024
1 parent a4ae9d7 commit e3a5fef
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 4 deletions.
5 changes: 3 additions & 2 deletions core/base/src/emitter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ class Emitter<T extends RPCMethod> {

public completeDetect = () => this.detectPromise;

public startTrackBalance = () => {
public startTrackBalance = (interval = 1500) => {
this.stopTrackBalance();
const getAndSetBalance = () => {
const account = this.state.accounts?.[0];
const chainId = this.state.chainId;
Expand All @@ -192,7 +193,7 @@ class Emitter<T extends RPCMethod> {
};

getAndSetBalance();
this.trackBalanceInterval = setInterval(getAndSetBalance, 1500) as unknown as number;
this.trackBalanceInterval = setInterval(getAndSetBalance, interval) as unknown as number;
};

public stopTrackBalance = () => {
Expand Down
2 changes: 2 additions & 0 deletions core/react/build/dts/chain.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export declare const addChain: (params: import("./type").AddChainParameter) => P
export declare const switchChain: (chainId: string) => Promise<string>;
export declare const watchAsset: (param: import("./type").WatchAssetParams) => Promise<string>;
export declare const provider: import("./type").Provider | undefined;
export declare const startTrackBalance: (interval?: number) => void;
export declare const stopTrackBalance: () => void;
export declare const trackBalanceChangeOnce: (callback: VoidFunction) => void;
export declare const completeDetect: () => Promise<void>;
export declare const requestPermissions: (params: Record<string, any>) => Promise<Record<string, string>>
Expand Down
2 changes: 2 additions & 0 deletions core/react/build/dts/wallet.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export declare const addChain: (params: import('./type').AddChainParameter) => P
export declare const switchChain: (chainId: string) => Promise<string>;
export declare const watchAsset: (param: import('./type').WatchAssetParams) => Promise<string>;
export declare const provider: import('./type').Provider | undefined;
export declare const startTrackBalance: (interval?: number) => void;
export declare const stopTrackBalance: () => void;
export declare const trackBalanceChangeOnce: (callback: VoidFunction) => void;
export declare const completeDetect: () => Promise<void>;
export declare const requestPermissions: (params: Record<string, any>) => Promise<Record<string, string>>;
Expand Down
2 changes: 1 addition & 1 deletion core/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react",
"version": "0.0.2-3",
"version": "0.0.2-5",
"type": "module",
"scripts": {
"build": "rimraf dist && node ./build/index.js",
Expand Down
2 changes: 2 additions & 0 deletions core/react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export const useBalance = () => {
return store(selectors.balance);
};

export const startTrackBalance = Emitter.startTrackBalance;
export const stopTrackBalance = Emitter.stopTrackBalance;
export const trackBalanceChangeOnce = Emitter.trackBalanceChangeOnce;
export const completeDetect = Emitter.completeDetect;

Expand Down
2 changes: 2 additions & 0 deletions core/vue3/build/dts/chain.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export declare const addChain: (params: import("./type").AddChainParameter) => P
export declare const switchChain: (chainId: string) => Promise<string>;
export declare const watchAsset: (param: import("./type").WatchAssetParams) => Promise<string>;
export declare const provider: import("./type").Provider | undefined;
export declare const startTrackBalance: (interval?: number) => void;
export declare const stopTrackBalance: () => void;
export declare const trackBalanceChangeOnce: (callback: VoidFunction) => void;
export declare const completeDetect: () => Promise<void>;
export declare const requestPermissions: (params: Record<string, any>) => Promise<Record<string, string>>
Expand Down
2 changes: 2 additions & 0 deletions core/vue3/build/dts/wallet.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export declare const addChain: (params: import("./type").AddChainParameter) => P
export declare const switchChain: (chainId: string) => Promise<string>;
export declare const watchAsset: (param: import("./type").WatchAssetParams) => Promise<string>;
export declare const provider: import("./type").Provider | undefined;
export declare const startTrackBalance: (interval?: number) => void;
export declare const stopTrackBalance: () => void;
export declare const trackBalanceChangeOnce: (callback: VoidFunction) => void;
export declare const completeDetect: () => Promise<void>;
export declare const requestPermissions: (params: Record<string, any>) => Promise<Record<string, string>>
Expand Down
2 changes: 1 addition & 1 deletion core/vue3/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue3",
"version": "0.0.1-0",
"version": "0.0.2-5",
"type": "module",
"scripts": {
"build": "rimraf dist && node ./build/index.js",
Expand Down
2 changes: 2 additions & 0 deletions core/vue3/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export const useBalance = () => {
return readonly(toRef(store, 'balance'));
}

export const startTrackBalance = Emitter.startTrackBalance;
export const stopTrackBalance = Emitter.stopTrackBalance;
export const trackBalanceChangeOnce = Emitter.trackBalanceChangeOnce;
export const completeDetect = Emitter.completeDetect;

Expand Down

0 comments on commit e3a5fef

Please sign in to comment.