Skip to content

Commit

Permalink
feat: further adjust api
Browse files Browse the repository at this point in the history
  • Loading branch information
izri16 committed Jan 24, 2024
1 parent 474e4de commit 66b6a4a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
16 changes: 8 additions & 8 deletions components/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import type { User } from "next-auth"
import type { SupportedWallets } from '../types/types'
import { getContext, getWidgetApi } from '@nufi/dapp-client-core';
import nufiCoreSdk from '@nufi/dapp-client-core';
import { initNufiDappCardanoSdk } from '@nufi/dapp-client-cardano';
import { useState, useRef, useEffect } from 'react';
import NextLink from 'next/link';
Expand Down Expand Up @@ -159,13 +159,13 @@ const ConnectButton = () => {
const hasWalletExtension = (walletName: SupportedWallets) => (!!window.cardano?.[walletName])

const disconnecting = async () => {
const {hideWidget} = getWidgetApi()
const coreSdkApi = nufiCoreSdk.getApi()

setIsDisconnecting(true);
resetStatus();
await signOut({ redirect: false });
setIsDisconnecting(false);
hideWidget()
coreSdkApi?.hideWidget()
setIsConnecting(false)
_setWalletName(null)
}
Expand All @@ -175,7 +175,7 @@ const ConnectButton = () => {
const fn = async () => {
setIsEnabledLoading(true)

initNufiDappCardanoSdk(getContext, 'sso', {provider: 'google'})
initNufiDappCardanoSdk(nufiCoreSdk, 'sso', {provider: 'google'})
const isEnabled = await window.cardano['nufiSSO'].isEnabled()
setIsEnabledLoading(false)

Expand Down Expand Up @@ -212,10 +212,10 @@ const ConnectButton = () => {
setCandidateWallet(walletName === 'nufiSSO' ? 'sso' : 'standard')

if (walletName === 'nufiSSO') {
initNufiDappCardanoSdk(getContext, 'sso', {provider: 'google'});
initNufiDappCardanoSdk(nufiCoreSdk, 'sso', {provider: 'google'});
}
if (walletName === 'nufiSnap') {
initNufiDappCardanoSdk(getContext, 'snap')
initNufiDappCardanoSdk(nufiCoreSdk, 'snap')
}

if (!hasWalletExtension(walletName)) {
Expand Down Expand Up @@ -270,7 +270,7 @@ const ConnectButton = () => {
style={{background: '#333', width: 250}}
label={isConnecting ? 'Connecting ...' : isEnabledLoading ? 'Loading ...' : 'Sign in with Google'}
onClick={() => {
initNufiDappCardanoSdk(getContext, 'sso', {provider: 'google'});
initNufiDappCardanoSdk(nufiCoreSdk, 'sso', {provider: 'google'});
_setWalletName('nufiSSO')
connectWallet('nufiSSO')
}}
Expand Down Expand Up @@ -366,7 +366,7 @@ const ConnectButton = () => {
<div style={{display: 'flex', alignItems: 'center'}}>
<GoogleButton
style={{background: '#333', width: 250}}
label={getWidgetApi()?.getSocialLoginInfo()?.email || 'Connected'}
label={nufiCoreSdk.getApi().getSocialLoginInfo()?.email || 'Connected'}
onClick={() => connectWallet('nufiSSO')}
/>
<Button {...connectbuttonStyle} height="50px" marginLeft="8px" onClick={() => disconnecting()} isLoading={isDisconnecting} >
Expand Down
14 changes: 7 additions & 7 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useState } from 'react';
import { useEffect } from 'react';
import type { AppProps } from 'next/app'
import { ChakraProvider, extendTheme, Container } from '@chakra-ui/react'
import Head from 'next/head'
Expand All @@ -7,7 +7,7 @@ import Navbar from '../components/navbar'
import { SessionProvider } from "next-auth/react"
import { Session } from 'next-auth'
import { headingTheme } from 'theme/components/heading'
import { initNufiDappSdk, getWidgetApi} from '@nufi/dapp-client-core';
import nufiCoreSdk from '@nufi/dapp-client-core';

const theme = extendTheme({
fonts: {
Expand All @@ -23,12 +23,12 @@ const theme = extendTheme({
function MyApp({ Component, pageProps }: AppProps<{ session: Session }>) {

useEffect(() => {
initNufiDappSdk('https://localhost:8091');
const widgetApi = getWidgetApi()
nufiCoreSdk.init('https://localhost:8091');
const widgetApi = nufiCoreSdk.getApi()

widgetApi!.onSocialLoginInfoChanged((data) => {
console.log('Social login info changed', data)
})
widgetApi.onSocialLoginInfoChanged((data) => {
console.log('Social login info changed', data)
})
}, []);

return (
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1144,8 +1144,8 @@
version "0.0.0"
uid ""

"@nufi/dapp-client-core@8.0.1":
version "8.0.1"
"@nufi/dapp-client-core@8.1.0":
version "8.1.0"

"@nufi/dapp-client-core@link:../nufi/packages/dapp-client/core":
version "0.0.0"
Expand Down

0 comments on commit 66b6a4a

Please sign in to comment.