Skip to content

Commit

Permalink
[Issue-173] Fetch mythical balance from client
Browse files Browse the repository at this point in the history
  • Loading branch information
saltict committed Nov 23, 2024
1 parent 637e60d commit 461b4f9
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions packages/extension-koni-ui/src/connector/booka/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,19 @@ export class BookaSdk {
return this.nflRivalCardListSubject.value;
}

async fetchMythicalBalance (token?: string) {
try {
const rs = await this.postRequest<MythicalWallet>(`${GAME_API_HOST}/api/mythical-account/fetch`, { token: token });

if (rs) {
this.mythicalWalletSubject.next(rs);
}
} catch (error) {
console.error('Error in fetchMythicalBalance:', error);
throw error;
}
}

getDailyRewardAchievements () {
return this.dailyRewardAchievementsSubject.value;
}
Expand Down Expand Up @@ -1049,26 +1062,6 @@ export class BookaSdk {
return this.airdropCampaignSubject;
}

async fetchMythicalBalance (token: string) {
const request = await fetch(`${MYTHICAL_API_HOST}/player/wallet-balance`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`
}
});

if (request.status === 200 || request.status === 304) {
const balance = (await request.json()) as unknown as MythicalWallet;

this.mythicalWalletSubject.next(balance);

return balance;
} else {
return undefined;
}
}

getMythicalWallet () {
return this.mythicalWalletSubject.value;
}
Expand Down

0 comments on commit 461b4f9

Please sign in to comment.