Skip to content

Commit

Permalink
fix: erc20 card closing after transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
micwallace committed Nov 26, 2024
1 parent cb5422d commit c7d544b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions javascript/engine-js/src/view/ViewController.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ITransactionListener, ITransactionStatus} from "../ITokenScript";
import {ITransactionListener, ITransactionStatus, TokenMetadataMap} from "../ITokenScript";
import {TokenScript} from "../TokenScript";
import {Card} from "../tokenScript/Card";
import {RpcRequest, RpcResponse} from "../wallet/IWalletAdapter";
Expand Down Expand Up @@ -136,7 +136,7 @@ export class ViewController {

if (txOptions.triggers?.length) {

let tokens;
let tokens: TokenMetadataMap;
if (txOptions.triggers.indexOf("refreshTokens") > -1) {
// Pause to let token discovery service update
await new Promise(resolve => setTimeout(resolve, 3000));
Expand All @@ -151,7 +151,15 @@ export class ViewController {
// The card is reloaded based on the following criteria
// - The card is still available based on isEnabledOrReason
// - Tokens have not been reloaded OR the card is an onboarding card OR the token still exists (not burnt or transferred)
if (reloadCard && (!context || !tokens || tokens[context.originId]?.tokenDetails?.[context.selectedTokenIndex])){
if (
reloadCard &&
(
!context ||
!tokens ||
tokens[context.originId]?.tokenType === "erc20" ||
tokens[context.originId]?.tokenDetails?.[context.selectedTokenIndex]
)
){
await this.updateCardData();
} else {
await this.unloadTokenCard();
Expand Down

0 comments on commit c7d544b

Please sign in to comment.