Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hotfix deploy #905

Merged
merged 11 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
NEXT_PUBLIC_LOCAL_ENVIRONMENT=true
NEXT_PUBLIC_NETWORK_ID=mainnet
NEXT_PUBLIC_HOSTNAME=https://near.org
# endpoint to fetch TOS and Privacy Policy from IPFS
Expand All @@ -9,3 +10,6 @@ NEXT_PUBLIC_PRIVACY_CID=
NEXT_PUBLIC_NOTIFICATIONS_HOSTNAME=
NEXT_PUBLIC_NOTIFICATIONS_APPLICATION_SERVER_KEY=
NEXT_PUBLIC_NOTIFICATIONS_GATEWAY_URL=
# commit modal bypass
NEXT_PUBLIC_COMMIT_MODAL_BYPASS_AUTHOR_IDS=near,discom.testnet,discom-dev.testnet
NEXT_PUBLIC_COMMIT_MODAL_BYPASS_SOURCES=
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"local-storage": "^2.0.0",
"lodash": "^4.17.21",
"near-fastauth-wallet": "^0.0.10",
"near-social-vm": "github:NearSocial/VM#0285e7ca7126ebb865492bd6c8523338d09f99f1",
"near-social-vm": "github:NearSocial/VM#1344e8650e8f9a1b5781271183536bcfc815493f",
"next": "^13.5.6",
"react": "^18.2.0",
"react-bootstrap": "^2.5.0",
Expand Down
16 changes: 8 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion src/components/sandbox/Sandbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,15 @@ export const Sandbox = ({ onboarding = false }) => {
const pathNew = nameToPath(path.type, newName);
const jpathNew = fileToJpath(pathNew);

const onboardingId = onboarding && 'near';
const src = getSrcByNameOrPath(pathNew.name, onboardingId || accountId, pathNew.type);

setFilesObject((state) => {
const newState = {
...state,
[jpathNew]: {
...state[jpath],
src,
name: newName,
},
};
Expand Down Expand Up @@ -410,10 +414,18 @@ export const Sandbox = ({ onboarding = false }) => {
name: file.name,
}));

const newName = generateNewName(type, files).name;

const onboardingId = onboarding && 'near';
const src = getSrcByNameOrPath(newName, onboardingId || accountId, type);
const path = toPath(type, newName);

const newFile = {
...fileObjectDefault,
...path,
src,
type,
name: generateNewName(type, files).name,
name: newName,
codeMain: '',
codeDraft: '',
codeLocalStorage: newCode,
Expand Down
22 changes: 18 additions & 4 deletions src/components/vm/VmInitializer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { isValidAttribute } from 'dompurify';
import { setupKeypom } from '@keypom/selector';
import type { WalletSelector } from '@near-wallet-selector/core';
import { setupWalletSelector } from '@near-wallet-selector/core';
Expand All @@ -15,6 +14,8 @@ import { setupNightly } from '@near-wallet-selector/nightly';
import { setupSender } from '@near-wallet-selector/sender';
import { setupWelldoneWallet } from '@near-wallet-selector/welldone-wallet';
import Big from 'big.js';
import { isValidAttribute } from 'dompurify';
import { mapValues } from 'lodash';
import { setupFastAuthWallet } from 'near-fastauth-wallet';
import {
CommitButton,
Expand All @@ -36,9 +37,14 @@ import { useAuthStore } from '@/stores/auth';
import { useIdosStore } from '@/stores/idosStore';
import { useVmStore } from '@/stores/vm';
import { recordWalletConnect, reset as resetAnalytics } from '@/utils/analytics';
import { networkId, signInContractId } from '@/utils/config';
import {
commitModalBypassAuthorIds,
commitModalBypassSources,
isLocalEnvironment,
networkId,
signInContractId,
} from '@/utils/config';
import { KEYPOM_OPTIONS } from '@/utils/keypom-options';
import { mapValues } from 'lodash';

export default function VmInitializer() {
const [signedIn, setSignedIn] = useState(false);
Expand Down Expand Up @@ -106,13 +112,21 @@ export default function VmInitializer() {
Link: ({ to, href, ...rest }: { to: string | object | undefined; href: string | object }) => {
const cleanProps = mapValues({ to, href, ...rest }, (val: any, key: string) => {
if (!['to', 'href'].includes(key)) return val;
if (key === 'href' && !val) val = to;
return typeof val === 'string' && isValidAttribute('a', 'href', val) ? val : 'about:blank';
});

return <Link {...cleanProps} />;
},
},
features: { enableComponentSrcDataKey: true },
features: {
commitModalBypass: {
authorIds: commitModalBypassAuthorIds,
sources: commitModalBypassSources,
},
enableComponentSrcDataKey: true,
enableWidgetSrcWithCodeOverride: isLocalEnvironment,
},
});
}, [initNear]);

Expand Down
18 changes: 14 additions & 4 deletions src/pages/signin.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { getKeys, isPassKeyAvailable } from '@near-js/biometric-ed25519';
import { useRouter } from 'next/router';
import { useSearchParams } from 'next/navigation';
import { useEffect } from 'react';
import { useForm } from 'react-hook-form';
import styled from 'styled-components';

import { Button } from '@/components/lib/Button';
import { openToast } from '@/components/lib/Toast';
import { useClearCurrentComponent } from '@/hooks/useClearCurrentComponent';
import { useDefaultLayout } from '@/hooks/useLayout';
import { useSignInRedirect } from '@/hooks/useSignInRedirect';
Expand All @@ -17,10 +15,10 @@ import { isValidEmail } from '../utils/form-validation';

const SignInPage: NextPageWithLayout = () => {
const { register, handleSubmit, setValue } = useForm();
const router = useRouter();
const requestSignInWithWallet = useAuthStore((store) => store.requestSignInWithWallet);
const signedIn = useAuthStore((store) => store.signedIn);
const vmNear = useAuthStore((store) => store.vmNear);
const searchParams = useSearchParams();
const { redirect } = useSignInRedirect();

useEffect(() => {
Expand All @@ -29,6 +27,18 @@ const SignInPage: NextPageWithLayout = () => {
}
}, [redirect, signedIn]);

useEffect(() => {
if (vmNear?.selector && searchParams.get('account_id') && searchParams.get('public_key')) {
vmNear.selector
.then((selector: any) => selector.wallet('fast-auth-wallet'))
.then((fastAuthWallet: any) =>
fastAuthWallet.signIn({
contractId: vmNear.config.contractName,
}),
);
}
}, [searchParams, vmNear]);

useClearCurrentComponent();

const onSubmit = handleSubmit(async (data) => {
Expand Down
8 changes: 8 additions & 0 deletions src/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,11 @@ export const notificationsHostName = process.env.NEXT_PUBLIC_NOTIFICATIONS_HOSTN
export const notificationsGatewayUrl = process.env.NEXT_PUBLIC_NOTIFICATIONS_GATEWAY_URL ?? 'https://near.org';
export const notificationsLocalStorageKey = 'push-notifications-v0';
export const localStorageAccountIdKey = 'near-social-vm:v01::accountId:';
export const isLocalEnvironment = process.env.NEXT_PUBLIC_LOCAL_ENVIRONMENT === 'true';

export const commitModalBypassAuthorIds = (process.env.NEXT_PUBLIC_COMMIT_MODAL_BYPASS_AUTHOR_IDS ?? '')
.split(',')
.filter((item) => !!item);
export const commitModalBypassSources = (process.env.NEXT_PUBLIC_COMMIT_MODAL_BYPASS_SOURCES ?? '')
.split(',')
.filter((item) => !!item);
Loading