Skip to content

Commit

Permalink
chore: merge
Browse files Browse the repository at this point in the history
  • Loading branch information
jamalavedra committed Dec 31, 2024
2 parents aaabbb1 + 2077835 commit 8a960f3
Show file tree
Hide file tree
Showing 42 changed files with 1,377 additions and 1,392 deletions.
18 changes: 12 additions & 6 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,23 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v3

- uses: actions/setup-node@v4
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 'lts/*'
node-version-file: .nvmrc
cache: 'yarn'

- name: Install dependencies
run: npm install -g yarn && yarn
run: yarn install --immutable

- name: Install dependencies on auth sample
run: yarn
- name: Lint
run: yarn lint

- name: Build
run: yarn build

- name: Install Playwright Browsers
run: yarn playwright install --with-deps
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.8.15] - 2024-12-31
### Feat
- Support for platforms not using crypto
- Support for ownerAddress returned on getAccount

## [0.8.13] - 2024-11-26
### Feat
- Add support for ERC-7715 and EIP-5792
Expand Down
2 changes: 1 addition & 1 deletion examples/apps/auth-sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"dependencies": {
"@heroicons/react": "^2.0.13",
"@openfort/openfort-js": "^0.8.13",
"@openfort/openfort-js": "^0.8.15",
"@openfort/openfort-node": "^0.6.65",
"@radix-ui/react-dialog": "^1.1.2",
"@radix-ui/react-icons": "^1.3.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {useState} from 'react';
import React, {useEffect, useState} from 'react';
import {useOpenfort} from '../../hooks/useOpenfort';
import {EmbeddedState} from '@openfort/openfort-js';
import Loading from '../Loading';
Expand All @@ -14,6 +14,21 @@ const EIP1193MintButton: React.FC<{
const [loading, setLoading] = useState(false);
const [loadingBatch, setLoadingBatch] = useState(false);

useEffect(() => {
const provider = getEvmProvider();
if (!provider) {
throw new Error('Failed to get EVM provider');
}
const walletClient = createWalletClient({
chain: polygonAmoy,
transport: custom(provider)
})
walletClient.getAddresses().then(([account]) => {
handleSetMessage(`Current account address: ${account}`);
}
)
},[])

const handleSendTransaction = async () => {
const provider = getEvmProvider();
if (!provider) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,11 @@ export default SetPairingCode;
export const SetPairingCodeWithWagmi: React.FC<{
handleSetMessage: (message: string) => void;
}> = ({handleSetMessage}) => {

const {getEvmProvider} = useOpenfort();
useEffect(() => {
if (!openfortInstance) return;
openfortInstance.getEthereumProvider(); // EIP-6963
}, [openfortInstance]);
getEvmProvider()
}, [getEvmProvider]);

const chainToWagmiChain = {
['mainnet']: mainnet,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {polygonAmoy} from 'wagmi/chains';
import React, {FunctionComponent, useState} from 'react';
import {withWagmi} from './wagmiProvider';
import {Connector, createConfig, http, useAccount, useConnect} from 'wagmi';
import {Connector, createConfig, http, useConnect} from 'wagmi';
import {Chain, WalletConnector} from '../utils/constants';
import type {Chain as WagmiChain} from 'wagmi/chains';
import {metaMask, walletConnect} from 'wagmi/connectors';
Expand Down
21 changes: 0 additions & 21 deletions examples/apps/auth-sample/src/hooks/useOpenfort.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import {
EmbeddedState,
ShieldAuthType,
ThirdPartyOAuthProvider,
TokenType,
TypedDataDomain,
TypedDataField,
type AuthPlayerResponse,
type Provider,
type RecoveryMethod,
type ShieldAuthentication,
Expand Down Expand Up @@ -36,7 +33,6 @@ interface ContextType {
chainId:number
password?: string,
}) => Promise<void>;
auth: (accessToken: string) => Promise<AuthPlayerResponse>;
setWalletRecovery: (
recoveryMethod: RecoveryMethod,
recoveryPassword?: string
Expand Down Expand Up @@ -113,22 +109,6 @@ export const OpenfortProvider: React.FC<React.PropsWithChildren<unknown>> = ({
return externalProvider as Provider;
}, []);

const auth = useCallback(
async (accessToken: string): Promise<AuthPlayerResponse> => {
try {
return await openfort.authenticateWithThirdPartyProvider({
provider: ThirdPartyOAuthProvider.SUPABASE,
token: accessToken,
tokenType: TokenType.CUSTOM_TOKEN,
});
} catch (err) {
console.error('Error authenticating:', err);
throw err;
}
},
[]
);

const signMessage = useCallback(
async (
message: string,
Expand Down Expand Up @@ -281,7 +261,6 @@ export const OpenfortProvider: React.FC<React.PropsWithChildren<unknown>> = ({

const contextValue: ContextType = {
state,
auth,
getEvmProvider,
handleRecovery,
signMessage,
Expand Down
40 changes: 36 additions & 4 deletions examples/apps/auth-sample/src/pages/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,29 @@ function LoginPage() {
if (user) loadData();
}, [user]);

const handleGuest = async () => {
setStatus({
type: "loading",
title: "Signing in...",
});

const data = await openfort
.signUpGuest()
.catch((error) => {
setStatus({
type: "error",
title: "Error signing in",
});
});
if (data) {
setStatus({
type: "success",
title: "Successfully signed in",
});
router.push("/");
}
}

const handleSubmit = async (event: React.FormEvent<HTMLFormElement>) => {
setStatus({
type: "loading",
Expand Down Expand Up @@ -162,13 +185,22 @@ function LoginPage() {
)}
</Button>
</form>
<div className="mt-6">
<Button
onClick={handleGuest}
variant="outline"
className="w-full"
>
<span>Continue as Guest</span>
</Button>
</div>
<div className="mt-6">
<div className="relative">
<div className="absolute inset-0 flex items-center">
<div className="w-full border-t border-gray-300" />
</div>
<div className="relative flex justify-center text-sm">
<span className="bg-white px-2 text-gray-500">
<span className="bg-white px-2 text-gray-500 b">
Or continue with
</span>
</div>
Expand All @@ -178,7 +210,7 @@ function LoginPage() {
<div>
<Button
onClick={async () => {
const { url } = await openfort.initOAuth({
const {url} = await openfort.initOAuth({
provider: OAuthProvider.GOOGLE,
options: {
redirectTo: getURL() + "/login",
Expand All @@ -195,7 +227,7 @@ function LoginPage() {
<div>
<Button
onClick={async () => {
const { url } = await openfort.initOAuth({
const {url} = await openfort.initOAuth({
provider: OAuthProvider.TWITTER,
options: {
redirectTo: getURL() + "/login",
Expand All @@ -212,7 +244,7 @@ function LoginPage() {
<div>
<Button
onClick={async () => {
const { url } = await openfort.initOAuth({
const {url} = await openfort.initOAuth({
provider: OAuthProvider.FACEBOOK,
options: {
redirectTo: getURL() + "/login",
Expand Down
2 changes: 1 addition & 1 deletion examples/apps/auth-sample/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ export const WalletConnector = {
} as const;

export const Chain = {
AMOY: "amoy",
AMOY: "amoy",
} as const;
3 changes: 3 additions & 0 deletions examples/apps/auth-sample/src/utils/openfortConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ const openfort = new Openfort({
shieldConfiguration: {
shieldPublishableKey: process.env.NEXT_PUBLIC_SHIELD_API_KEY!,
},
overrides: {
iframeUrl: "https://embedded.openfort.xyz",
}
});

export default openfort;
Loading

0 comments on commit 8a960f3

Please sign in to comment.