diff --git a/packages/extension-koni-ui/src/Popup/Home/Mission/index.tsx b/packages/extension-koni-ui/src/Popup/Home/Mission/index.tsx index 3530f94133..78accf17f1 100644 --- a/packages/extension-koni-ui/src/Popup/Home/Mission/index.tsx +++ b/packages/extension-koni-ui/src/Popup/Home/Mission/index.tsx @@ -8,7 +8,7 @@ import { HomeContext } from '@subwallet/extension-koni-ui/contexts/screen/HomeCo import { useSetCurrentPage } from '@subwallet/extension-koni-ui/hooks'; import { TaskList } from '@subwallet/extension-koni-ui/Popup/Home/Mission/TaskList'; import { ThemeProps } from '@subwallet/extension-koni-ui/types'; -import React, { useCallback, useContext, useEffect, useRef, useState } from 'react'; +import React, { useCallback, useContext, useEffect, useState } from 'react'; import styled from 'styled-components'; type Props = ThemeProps; @@ -107,8 +107,17 @@ const Component = ({ className }: Props): React.ReactElement => { // eslint-disable-next-line @typescript-eslint/no-unsafe-call const widget = await window.AirlyftWidget(widgetId); - const widgetModal = await widget.createModal({}); - const widgetRef = widgetModal.ref; + const instance = await widget.createModal({}); + const dataToken = await apiSDK.getAirlyftToken(); + + if (dataToken && dataToken.success) { + widget.authWithToken( + instance, + dataToken.token + ); + } + + const widgetRef = instance.ref; const triggerButton = widgetRef.querySelector('a'); @@ -117,7 +126,7 @@ const Component = ({ className }: Props): React.ReactElement => { triggerButton.parentNode.style.height = 'auto'; } - resolve(widgetModal); + resolve(instance); } else { resolve(null); } diff --git a/packages/extension-koni-ui/src/connector/booka/sdk.ts b/packages/extension-koni-ui/src/connector/booka/sdk.ts index 1b98073f42..226cd52361 100644 --- a/packages/extension-koni-ui/src/connector/booka/sdk.ts +++ b/packages/extension-koni-ui/src/connector/booka/sdk.ts @@ -752,6 +752,14 @@ export class BookaSdk { throw error; } } + async getAirlyftToken () { + try { + return await this.getRequest(`${GAME_API_HOST}/api/airlyft/get-token`) as unknown as Promise<{token: string, success: boolean} | undefined>; + } catch (error) { + console.error('Error in fetchAirdropHistory:', error); + throw error; + } + } subscribeAirdropCampaign () { return this.airdropCampaignSubject;