Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/Issue-166' into kon…
Browse files Browse the repository at this point in the history
…i/dev/issue-174
  • Loading branch information
lw-cdm committed Nov 20, 2024
2 parents 611a2cd + 373966c commit 63f0a1d
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,10 @@ const Component: React.FC<Props> = (props: Props) => {
}

apiSDK
.fetchStoryBadgeEligibility(address)
.then(resolve)
.nftMintingCheckEligible(address)
.then((rs) => {
resolve(!rs.mintedNft && rs.inWhiteList);
})
.catch((error: Error) => {
console.error('Error fetching eligibility:', error);
resolve(false);
Expand Down
21 changes: 15 additions & 6 deletions packages/extension-koni-ui/src/connector/booka/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { GameState } from '@playnation/game-sdk/dist/types';
import { SWStorage } from '@subwallet/extension-base/storage';
import { createPromiseHandler, detectTranslate, wait } from '@subwallet/extension-base/utils';
import { AppMetadata, MetadataHandler } from '@subwallet/extension-koni-ui/connector/booka/metadata';
import { AccountRankType, AirdropCampaign, AirdropEligibility, AirdropRaffle, AirdropRewardHistoryLog, BookaAccount, EnergyConfig, Game, GameInventoryItem, GameItem, GamePlay, IAirdropNftMinting, LeaderboardPerson, RankInfo, ReferralRecord, Task, TaskCategory } from '@subwallet/extension-koni-ui/connector/booka/types';
import { AccountRankType, AirdropCampaign, AirdropEligibility, AirdropRaffle, AirdropRewardHistoryLog, APIResponse, BookaAccount, EnergyConfig, Game, GameInventoryItem, GameItem, GamePlay, IAirdropNftMinting, LeaderboardPerson, NftMintingEligibility, NftMintingLog, RankInfo, ReferralRecord, Task, TaskCategory } from '@subwallet/extension-koni-ui/connector/booka/types';
import { TelegramConnector } from '@subwallet/extension-koni-ui/connector/telegram';
import { signRaw } from '@subwallet/extension-koni-ui/messaging';
import { populateTemplateString } from '@subwallet/extension-koni-ui/utils';
Expand Down Expand Up @@ -1005,13 +1005,22 @@ export class BookaSdk {
return promise;
}

async fetchStoryBadgeEligibility (address: string) {
const data = await this.postRequest<boolean>(`${GAME_API_HOST}/api/mint-nft/eligible`, { address });
async nftMintingCheckEligible (address: string, campaign = 'default') {
const data = await this.postRequest<APIResponse<NftMintingEligibility>>(`${GAME_API_HOST}/api/mint-nft/check-eligible`, { address, campaign });

console.log(data);
return data.data;
}

async nftMintingRequestSignature (address: string, campaign = 'default') {
const data = await this.postRequest<APIResponse<NftMintingLog>>(`${GAME_API_HOST}/api/mint-nft/request-signature`, { address, campaign });

return data.data;
}

async nftMintingStart (campaign = 'default', extrinsicHash?: string) {
const data = await this.postRequest<APIResponse<NftMintingLog>>(`${GAME_API_HOST}/api/mint-nft/start-mint`, { campaign, extrinsicHash });

// TODO: Implement later
return true;
return data.data;
}

// Singleton
Expand Down
23 changes: 23 additions & 0 deletions packages/extension-koni-ui/src/connector/booka/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,3 +411,26 @@ export interface AirdropRaffle {
export interface AirdropClaim {
airdropRecordLogId: number,
}

export interface APIResponse<T> {
success: boolean;
message?: string;
data: T;
}

export interface NftMintingEligibility {
inWhiteList: boolean
mintedNft: boolean
}

export interface NftMintingLog {
id: number,
accountId: number,
campaign: string,
status: string
network: string,
contractAddress: string,
address: string,
signature: string,
extrinsicHash?: string,
}

0 comments on commit 63f0a1d

Please sign in to comment.