Skip to content

Commit 8579ee1

Browse files
committed
fix: Fix emulator loading issue
1 parent b52b0d3 commit 8579ee1

File tree

3 files changed

+22
-15
lines changed

3 files changed

+22
-15
lines changed

javascript/engine-js/src/TokenScript.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export class TokenScript {
122122
public getSourceInfo(){
123123
return {
124124
// TODO: Use better UID for non-resolved tokenscripts
125-
tsId: this.sourceId + (this.scriptInfo.scriptId ? '-' + this.scriptInfo.scriptId : '') ?? this.getName(),
125+
tsId: this.sourceId + (this.scriptInfo?.scriptId ? '-' + this.scriptInfo.scriptId : '') ?? this.getName(),
126126
source: this.source,
127127
sourceUrl: this.sourceUrl,
128128
scriptInfo: this.scriptInfo

javascript/engine-js/src/tokenScript/Origin.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,6 @@ export class Origin {
204204
const scriptSource = this.tokenScript.getSourceInfo();
205205
const [chain, contractAddress] = (scriptSource.tsId ?? "").split("-");
206206

207-
console.log("Script Info ", scriptSource.scriptInfo);
208-
209207
// The same script Cid should be specified for all addresses in the same contract scriptUri in order to be valid
210208
const addresses = contract.getAddresses();
211209

javascript/tokenscript-viewer/src/components/viewers/new/viewer-popover/viewer-popover.tsx

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ export class ViewerPopover {
5757
private overflowCardButtons: JSX.Element[];
5858
private overflowDialog: HTMLActionOverflowModalElement;
5959

60+
@State()
61+
private otherScripts: ScriptInfo[];
6062

6163
@Method()
6264
async open(tokenScript: TokenScript){
@@ -76,7 +78,7 @@ export class ViewerPopover {
7678
try {
7779
const enabled = await card.isEnabledOrReason();
7880

79-
console.log("Card enabled: ", enabled);
81+
//console.log("Card enabled: ", enabled);
8082

8183
if (enabled === false)
8284
continue;
@@ -128,6 +130,21 @@ export class ViewerPopover {
128130
location.search = params.toString();
129131

130132
history.pushState(undefined, undefined, location);
133+
134+
await this.reloadOtherScripts();
135+
}
136+
137+
private async reloadOtherScripts(){
138+
this.otherScripts = null;
139+
140+
if ([ScriptSourceType.SCRIPT_URI, ScriptSourceType.SCRIPT_REGISTRY].indexOf(this.tokenScript.getSourceInfo().source) === -1)
141+
return;
142+
143+
try {
144+
this.otherScripts = await this.tokenScript.getEngine().resolveAllScripts(this.tokenScript.getSourceInfo().tsId);
145+
} catch (e){
146+
console.warn(e);
147+
}
131148
}
132149

133150
private async showCard(card: Card, token?: TokenGridContext, cardIndex?: number){
@@ -192,17 +209,9 @@ export class ViewerPopover {
192209
<h3>{this.tokenScript.getLabel(2) ?? this.tokenScript.getName()}</h3>
193210
</div>
194211
<div class="view-toolbar-buttons">
195-
<button class="btn btn-secondary" style={{marginRight: "15px", minWidth: "35px", fontSize: "16px"}} onClick={async () =>{
196-
this.showLoader.emit();
197-
try {
198-
const scripts = await this.tokenScript.getEngine().resolveAllScripts(this.tokenScript.getSourceInfo().tsId);
199-
this.showScriptSelector.emit(scripts);
200-
} catch (e){
201-
202-
}
203-
this.hideLoader.emit();
204-
205-
}}>Other TApps</button>
212+
{this.otherScripts?.length > 1 ? <button class="btn btn-secondary" style={{marginRight: "15px", minWidth: "35px", fontSize: "16px"}} onClick={async () =>{
213+
this.showScriptSelector.emit(this.otherScripts);
214+
}}>Other TApps</button> : ''}
206215
<share-to-tg-button></share-to-tg-button>
207216
<security-status tokenScript={this.tokenScript}/>
208217
<div>

0 commit comments

Comments
 (0)