Skip to content

Commit

Permalink
Merge pull request #905 from near/develop
Browse files Browse the repository at this point in the history
hotfix deploy
  • Loading branch information
charleslavon authored Jan 5, 2024
2 parents 95988f7 + 7ceec39 commit 50ad144
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 18 deletions.
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
21 changes: 17 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 @@ -113,7 +119,14 @@ export default function VmInitializer() {
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);

2 comments on commit 50ad144

@vercel
Copy link

@vercel vercel bot commented on 50ad144 Jan 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 50ad144 Jan 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.