Skip to content

Commit

Permalink
Update airlyft client login
Browse files Browse the repository at this point in the history
  • Loading branch information
anhnhu committed Jul 16, 2024
1 parent ade3156 commit 35144fe
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
17 changes: 13 additions & 4 deletions packages/extension-koni-ui/src/Popup/Home/Mission/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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');

Expand All @@ -117,7 +126,7 @@ const Component = ({ className }: Props): React.ReactElement => {
triggerButton.parentNode.style.height = 'auto';
}

resolve(widgetModal);
resolve(instance);
} else {
resolve(null);
}
Expand Down
8 changes: 8 additions & 0 deletions packages/extension-koni-ui/src/connector/booka/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 35144fe

Please sign in to comment.