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

New metaport architecture #184

Merged
merged 55 commits into from
Sep 25, 2023
Merged
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
2a9202b
New metaport architecture
dmytrotkk Aug 7, 2023
4809ea9
Merge develop branch
dmytrotkk Aug 7, 2023
6e646b1
Update skale-network
dmytrotkk Aug 7, 2023
517e451
Fix path to regression icons
dmytrotkk Aug 7, 2023
186ba3b
Comment out metamask wallet
dmytrotkk Aug 7, 2023
e3e0025
Update webpack-cli, move packages to dependencies, add regression
dmytrotkk Aug 8, 2023
c467f56
Update webpack config
dmytrotkk Aug 11, 2023
1a28ee3
Update React imports
dmytrotkk Aug 11, 2023
4fea232
Migrate builder to rollup.js
dmytrotkk Aug 14, 2023
b7b85e7
Split injected metaport and mp component
dmytrotkk Aug 14, 2023
fda6a4b
Add chain icons support for vite
dmytrotkk Aug 14, 2023
476a9d4
Add token icons in vite build
dmytrotkk Aug 14, 2023
dc2dce7
Add prepare_meta script
dmytrotkk Aug 14, 2023
1f201fb
Run prettier
dmytrotkk Aug 14, 2023
1bee1af
Move theming logic to metaport provider
dmytrotkk Aug 14, 2023
4c3f9d1
Make tokenIcon exportable, add external interfaces
dmytrotkk Aug 15, 2023
035c133
Fix storybook build - add react-dom
dmytrotkk Aug 15, 2023
b8d45b4
Update vercel build command
dmytrotkk Aug 15, 2023
2c4c4fe
Remove reduntant scss ts modules, add transfer ETA and ETF modules
dmytrotkk Aug 16, 2023
de8a4c1
New amount input, export amount error module
dmytrotkk Aug 16, 2023
69baad4
Add dest token balance module
dmytrotkk Aug 17, 2023
b3333d6
Fix dest token balance, export proxy endpoints
dmytrotkk Aug 17, 2023
90078c7
Update dest chains filtering logic, update config
dmytrotkk Aug 18, 2023
c2546e4
Update styling system, add community pool management
dmytrotkk Aug 22, 2023
a390b5f
Add recharge community pool function
dmytrotkk Aug 22, 2023
d55550f
Update storybook, update vercel script
dmytrotkk Aug 22, 2023
d7bd049
Use default token icons
dmytrotkk Aug 22, 2023
78234c8
Fix community pool logic for hub chains
dmytrotkk Aug 22, 2023
f4d687c
Add sFUEL station, fix community pool errors
dmytrotkk Aug 23, 2023
a463b13
PoW sFUEL faucet
dmytrotkk Aug 28, 2023
4eb413f
Remove web3-utils
dmytrotkk Aug 28, 2023
480fa55
Optimize miner script, update prettier rules
dmytrotkk Aug 28, 2023
6a9889f
Drop bn.js requirement
dmytrotkk Aug 28, 2023
5219de7
Update miner scirpt
dmytrotkk Aug 28, 2023
69d6ac6
Update sFUEL logic, add vibrant mode
dmytrotkk Aug 29, 2023
b76537a
Add ETH M2S, S2M methods, add ETH balance check
dmytrotkk Aug 30, 2023
7540661
Update eth unlock step, update wallet connector
dmytrotkk Aug 31, 2023
e890973
Run prettier
dmytrotkk Aug 31, 2023
7ea7643
Add wrapped tokens module
dmytrotkk Sep 5, 2023
4fd6009
Run prettier
dmytrotkk Sep 5, 2023
abe40aa
Add an ability to select apps
dmytrotkk Sep 7, 2023
ff97ca4
Update dependencies
dmytrotkk Sep 8, 2023
d4b47d0
Refactor tokens and chains state
dmytrotkk Sep 10, 2023
ef5b195
Fix get ETH token balance
dmytrotkk Sep 10, 2023
e074d18
Update prettier rules, fix routed ETH transfers
dmytrotkk Sep 11, 2023
4dcf13b
Add unwrap for eth token
dmytrotkk Sep 11, 2023
c9c04fe
Restructure CSS imports
dmytrotkk Sep 11, 2023
b3c224d
Update components folder structure
dmytrotkk Sep 11, 2023
f0aba33
Integrate addToken module
dmytrotkk Sep 11, 2023
ae6ec21
Add transfer history, add transaction logs
dmytrotkk Sep 14, 2023
788fefd
Add dynamic skale chains support, move chains metadata
dmytrotkk Sep 15, 2023
08042cb
Restructure imports
dmytrotkk Sep 15, 2023
2c47869
Update submodules
dmytrotkk Sep 20, 2023
e51339a
Minor changes
dmytrotkk Sep 21, 2023
53c91ae
Update WS endpoint func, general cleanup
dmytrotkk Sep 22, 2023
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: 3 additions & 1 deletion src/Metaport.tsx
Original file line number Diff line number Diff line change
@@ -39,11 +39,13 @@ export { ChainIcon };
import WidgetUI from './components/WidgetUI';
export { WidgetUI };

import Metaport from './components/Metaport';
export { Metaport };

// export * as sfuel from './core/sfuel';


export class Metaport {
export class InjectedMetaport {
constructor(config: interfaces.MetaportConfig) {
if (config.openButton === undefined) config.openButton = true;
if (config.autoLookup === undefined) config.autoLookup = true;
109 changes: 109 additions & 0 deletions src/components/Metaport/Metaport.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@

/**
* @license
* SKALE Metaport
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* @file Metaport.ts
* @copyright SKALE Labs 2023-Present
*/

import {
RainbowKitProvider
} from '@rainbow-me/rainbowkit';
import { configureChains, createConfig, WagmiConfig } from 'wagmi';
import { mainnet, goerli } from 'wagmi/chains';
import { jsonRpcProvider } from 'wagmi/providers/jsonRpc';
import { connectorsForWallets } from '@rainbow-me/rainbowkit';

import {
injectedWallet,
coinbaseWallet,
metaMaskWallet
} from '@rainbow-me/rainbowkit/wallets';

import { MetaportConfig } from "../../core/interfaces"

import WidgetUI from '../WidgetUI'

import '@rainbow-me/rainbowkit/styles.css';

import { constructWagmiChain, getWebSocketUrl } from '../../core/wagmi_network';


const { chains, webSocketPublicClient } = configureChains(
[
mainnet,
goerli,
constructWagmiChain('staging', "staging-legal-crazy-castor"),
constructWagmiChain('staging', "staging-utter-unripe-menkar"),
constructWagmiChain('staging', "staging-faint-slimy-achird"),
constructWagmiChain('staging', "staging-perfect-parallel-gacrux"),
constructWagmiChain('staging', "staging-severe-violet-wezen"),
constructWagmiChain('staging', "staging-weepy-fitting-caph"),

constructWagmiChain('mainnet', 'honorable-steel-rasalhague'),
constructWagmiChain('mainnet', 'elated-tan-skat'),
constructWagmiChain('mainnet', 'affectionate-immediate-pollux')
],
[
jsonRpcProvider({
rpc: chain => ({
http: chain.rpcUrls.default.http[0],
webSocket: getWebSocketUrl(chain)
}),
})
]
);


const connectors = connectorsForWallets([
{
groupName: 'Supported Wallets',
wallets: [
metaMaskWallet({ chains, projectId: '' }),
injectedWallet({ chains }),
coinbaseWallet({ chains, appName: 'TEST' })
],
}
]);


const wagmiConfig = createConfig({
autoConnect: true,
connectors,
publicClient: webSocketPublicClient
});


export default function Widget(props: {
config: MetaportConfig
}) {
return (
<WagmiConfig config={wagmiConfig}>
<RainbowKitProvider
coolMode
appInfo={{
appName: 'SKALE Metaport'
}}
showRecentTransactions={true}
chains={chains}
>
<WidgetUI config={props.config} />
</RainbowKitProvider>
</WagmiConfig>
)
}
1 change: 1 addition & 0 deletions src/components/Metaport/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "./Metaport";
27 changes: 24 additions & 3 deletions src/components/WidgetUI/WidgetUI.tsx
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@
* @copyright SKALE Labs 2023-Present
*/

import React from 'react';
import React, { useEffect } from 'react';
import { StyledEngineProvider } from '@mui/material/styles';

import { useAccount } from 'wagmi';
@@ -47,17 +47,38 @@ import styles from "../../styles/styles.module.scss";
import common from "../../styles/common.module.scss";
import { PaletteMode } from '@mui/material';

import { getWidgetTheme } from '../../core/themes';

import SkConnect from '../SkConnect';
import ErrorMessage from '../ErrorMessage';
import { MetaportConfig } from '../../core/interfaces';
import MetaportCore from '../../core/metaport'


export function WidgetUI(props: { config: MetaportConfig }) {

const widgetTheme = getWidgetTheme(props.config.theme);

const setTheme = useUIStore((state) => state.setTheme);
const setMpc = useMetaportStore((state) => state.setMpc);
const setOpen = useUIStore((state) => state.setOpen);

useEffect(() => {
setOpen(props.config.openOnLoad);
}, []);

export function WidgetUI(props) {
useEffect(() => {
setTheme(widgetTheme);
}, [setTheme]);

useEffect(() => {
setMpc(new MetaportCore(props.config));
}, [setMpc]);

const { address } = useAccount();

const metaportTheme = useUIStore((state) => state.theme);
const isOpen = useUIStore((state) => state.open);
const setOpen = useUIStore((state) => state.setOpen);

const errorMessage = useMetaportStore((state) => state.errorMessage);