diff --git a/packages/scaffold-ui/src/modal/w3m-button/index.ts b/packages/scaffold-ui/src/modal/w3m-button/index.ts index a724ee1f2a..b1704b3f96 100644 --- a/packages/scaffold-ui/src/modal/w3m-button/index.ts +++ b/packages/scaffold-ui/src/modal/w3m-button/index.ts @@ -33,11 +33,17 @@ export class W3mButton extends LitElement { @state() private isLoading = ModalController.state.loading + @state() private balanceVal = AccountController.state.balance + + @state() private balanceSymbol = AccountController.state.balanceSymbol + // -- Lifecycle ----------------------------------------- // public override firstUpdated() { this.unsubscribe.push( - AccountController.subscribeKey('isConnected', val => { - this.isAccount = val + AccountController.subscribe(val => { + this.isAccount = val.isConnected + this.balanceVal = val.balance + this.balanceSymbol = val.balanceSymbol }), ModalController.subscribeKey('loading', val => { this.isLoading = val @@ -51,7 +57,9 @@ export class W3mButton extends LitElement { // -- Render -------------------------------------------- // public override render() { - return this.isAccount && !this.isLoading + const isBalanceFetched = this.balanceVal && this.balanceSymbol + + return isBalanceFetched && this.isAccount && !this.isLoading ? html` - ${CoreHelperUtil.formatBalance(this.balance, this.balanceSymbol)} + + ${CoreHelperUtil.formatBalance(this.balance, this.balanceSymbol)} + ${this.explorerBtnTemplate()}