Skip to content
Draft
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
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@
"@walletconnect/modal": "2.5.9",
"@walletconnect/types": "2.8.6",
"@walletconnect/utils": "2.8.6",
"@ylide/ethereum": "0.9.0-beta.2",
"@ylide/everscale": "0.9.0-beta.3",
"@ylide/sdk": "0.9.0-beta.2",
"@ylide/ethereum": "0.9.0-beta.5",
"@ylide/everscale": "file:../everscale",
"@ylide/sdk": "0.9.0-beta.4",
"@ylide/smart-buffer": "0.0.17",
"clsx": "1.2.1",
"core-decorators": "0.20.0",
Expand Down
47 changes: 24 additions & 23 deletions pnpm-lock.yaml

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

11 changes: 5 additions & 6 deletions src/api/feedManagerApi.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { REACT_APP__FEED_MANAGER } from '../env';
import { MainviewKeyPayload } from '../types';
import { createCleanSerachParams } from '../utils/url';
import { FeedReason } from './feedServerApi';

Expand Down Expand Up @@ -86,20 +87,18 @@ export namespace FeedManagerApi {
token: string;
}

export async function authAddress(address: string, signature: string, messageTimestamp: number, invite?: string) {
export async function authAddress(payload: MainviewKeyPayload) {
return await request<AuthAddressResponse>(`/auth-address`, undefined, {
address,
signature,
messageTimestamp,
invite: invite || '',
...payload,
});
}

//

export async function init(token: string) {
export async function init(token: string, tvm?: string) {
return await request(`/init`, {
token,
tvm,
});
}

Expand Down
19 changes: 10 additions & 9 deletions src/components/TransactionPopup/TransactionPopup.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { EVMNetwork } from '@ylide/ethereum';
import clsx from 'clsx';
import { observer } from 'mobx-react';
import { useEffect, useState } from 'react';
Expand Down Expand Up @@ -71,23 +72,23 @@ export const TransactionPopup = observer(() => {
<div className={css.central}>
{domain.txWithBonus
? `Your ${
domain.txChain === 'fantom'
domain.txChain === EVMNetwork.FANTOM
? '$FTM'
: domain.txChain === 'gnosis'
: domain.txChain === EVMNetwork.GNOSIS
? '$xDAI'
: domain.txChain === 'polygon'
: domain.txChain === EVMNetwork.POLYGON
? '$MATIC'
: 'tokens'
} has been sent`
: `Successfully processed`}
</div>
<ActionButton
onClick={() => {
if (domain.txChain === 'fantom') {
if (domain.txChain === EVMNetwork.FANTOM) {
window.open(`https://ftmscan.com/tx/${domain.publishingTxHash}`, '_blank');
} else if (domain.txChain === 'gnosis') {
} else if (domain.txChain === EVMNetwork.GNOSIS) {
window.open(`https://gnosisscan.io/tx/${domain.publishingTxHash}`, '_blank');
} else if (domain.txChain === 'polygon') {
} else if (domain.txChain === EVMNetwork.POLYGON) {
window.open(`https://polygonscan.com/tx/${domain.publishingTxHash}`, '_blank');
}
}}
Expand All @@ -101,11 +102,11 @@ export const TransactionPopup = observer(() => {
<h4 className={css.header}>
{domain.txWithBonus
? `Your ${
domain.txChain === 'fantom'
domain.txChain === EVMNetwork.FANTOM
? '$FTM'
: domain.txChain === 'gnosis'
: domain.txChain === EVMNetwork.GNOSIS
? '$xDAI'
: domain.txChain === 'polygon'
: domain.txChain === EVMNetwork.POLYGON
? '$MATIC'
: 'tokens'
} are on the way`
Expand Down
5 changes: 3 additions & 2 deletions src/components/coverageModal/coverageModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ export const CoverageModal = observer(({ onClose, account }: Props) => {
const unique: FeedManagerApi.CoverageItem[] = [];
const seenValues = new Set();
for (const item of items) {
if (!seenValues.has(item.projectName)) {
seenValues.add(item.projectName);
const feature = item.projectName || item.symbol || item.tokenId;
if (!seenValues.has(feature)) {
seenValues.add(feature);
unique.push(item);
}
}
Expand Down
13 changes: 4 additions & 9 deletions src/components/mainViewOnboarding/mainViewOnboarding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,14 @@ export const MainViewOnboarding = observer(() => {
async function doAuthorize() {
setStep(Step.SIGN_AUTH);

const key = await account.makeMainViewKey();
invariant(key);
const payload = await account.makeMainViewKey(invite);
invariant(payload);

const { token } = await FeedManagerApi.authAddress(
account.account.address,
key.signature,
key.timestamp,
invite,
);
const { token } = await FeedManagerApi.authAddress(payload);

setStep(Step.BUILDING_FEED);

await FeedManagerApi.init(token);
await FeedManagerApi.init(token, payload.tvmType);

// Update keys after Feed Manager initialized
account.mainViewKey = token;
Expand Down
84 changes: 57 additions & 27 deletions src/components/newPasswordModal/newPasswordModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ enum Step {
}

interface NewPasswordModalProps {
faucetType: null | 'polygon' | 'gnosis' | 'fantom';
faucetType: null | EVMNetwork.POLYGON | EVMNetwork.GNOSIS | EVMNetwork.FANTOM;
bonus: boolean;
wallet: Wallet;
account: WalletAccount;
Expand Down Expand Up @@ -108,18 +108,52 @@ export function NewPasswordModal({
const account = domainAccountRef.current;
invariant(account);

await Promise.all([
account.publishPublicKey(key, network),
// Display loader after 3 seconds
asyncDelay(3000).then(() => setStep(Step.LOADING)),
]);

const justPublishedKey = await domain.waitForPublicKey(
false,
network ? EVM_NAMES[network] : account.wallet.currentBlockchain,
account.account.address,
key.publicKey.keyBytes,
);
const justPublishedKey = await new Promise<RemotePublicKey | null>((resolve, reject) => {
let isDone = false;

asyncDelay(3000).then(() => (!isDone ? setStep(Step.LOADING) : null));

account.publishPublicKey(key, network).then(() => {
if (isDone) {
return;
}

domain.ylide.core
.waitForPublicKey(
network ? EVM_NAMES[network] : account.wallet.currentBlockchain,
account.account.address,
key.publicKey.keyBytes,
)
.then(foundKey => {
if (isDone) {
return;
}

isDone = true;

resolve(foundKey);
});
});

asyncDelay(3000).then(() =>
domain.ylide.core
.waitForPublicKey(
network ? EVM_NAMES[network] : account.wallet.currentBlockchain,
account.account.address,
key.publicKey.keyBytes,
)
.then(foundKey => {
if (isDone) {
return;
}
if (foundKey) {
isDone = true;
resolve(foundKey);
}
}),
);
});

if (justPublishedKey) {
await domain.keyRegistry.addRemotePublicKey(justPublishedKey);
account.reloadKeys();
Expand Down Expand Up @@ -164,8 +198,13 @@ export function NewPasswordModal({
}
} else {
// strange... I'm not sure Qamon keys work here
console.log('createLocalKey', 'INSECURE_KEY_V1');
tempLocalKey = await wallet.constructLocalKeyV1(account, password);
if (forceSecond) {
console.log('createLocalKey', 'INSECURE_KEY_V2 non-venom');
tempLocalKey = await wallet.constructLocalKeyV2(account, password);
} else {
console.log('createLocalKey', 'INSECURE_KEY_V1 non-venom');
tempLocalKey = await wallet.constructLocalKeyV1(account, password);
}
}
} else if (freshestKey?.key.publicKey.keyVersion === YlideKeyVersion.KEY_V2) {
// if user already using password - we should use it too
Expand All @@ -190,11 +229,11 @@ export function NewPasswordModal({
if (!freshestKey || needToRepublishKey) {
const domainAccount = await createDomainAccount(wallet, account, tempLocalKey);
if (faucetType && wallet.factory.blockchainGroup === 'evm') {
const actualFaucetType = needToRepublishKey ? 'polygon' : faucetType;
const actualFaucetType = needToRepublishKey ? EVMNetwork.POLYGON : faucetType;

setStep(Step.GENERATE_KEY);

const { chainId, timestampLock, registrar, signature } = await domain.getFaucetSignature(
const faucetData = await domain.getFaucetSignature(
domainAccount,
tempLocalKey.publicKey,
actualFaucetType,
Expand All @@ -209,16 +248,7 @@ export function NewPasswordModal({
domain.txPlateVisible = true;
domain.txWithBonus = bonus;

const promise = domain.publishThroughFaucet(
domainAccount,
tempLocalKey.publicKey,
actualFaucetType,
bonus,
chainId,
timestampLock,
registrar,
signature,
);
const promise = domain.publishThroughFaucet(faucetData);

if (waitTxPublishing) {
await promise;
Expand Down
8 changes: 4 additions & 4 deletions src/pages/AdminPage/contract-modals/EVMMailerV8Modal.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
EthereumMailerV8Wrapper,
EthereumWalletController,
EVM_NAMES,
EVMMailerV8Wrapper,
EVMNetwork,
EVMWalletController,
IEVMMailerContractLink,
IEVMRegistryContractLink,
} from '@ylide/ethereum';
Expand Down Expand Up @@ -36,10 +36,10 @@ export const EVMMailerV8Modal: FC<EVMMailerV8ModalProps> = ({ contract, isModern
useEffect(() => {
if (contract.contract) {
(async () => {
const mailer = await (account.wallet.controller as EthereumWalletController).mailers.find(
const mailer = await (account.wallet.controller as EVMWalletController).mailers.find(
m => m.link.id === contract.contract?.id,
)!;
const wrapper = mailer.wrapper as EthereumMailerV8Wrapper;
const wrapper = mailer.wrapper as EVMMailerV8Wrapper;
const owner = await wrapper.globals.getOwner(mailer.link);
const beneficiary = await wrapper.globals.getBeneficiary(mailer.link);
const fees = await wrapper.globals.getFees(mailer.link);
Expand Down
Loading