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

Metis #1421

Closed
wants to merge 6 commits into from
Closed

Metis #1421

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
27 changes: 27 additions & 0 deletions src/lib/components/icons/networks/Metis.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<script lang="ts">
import IconWrapper from '../IconWrapper.svelte';

export let style: string | undefined = undefined;
</script>

<IconWrapper on:click {style}>
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_13649_19861)">
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M12 23.9999C5.4 23.9999 0 18.5999 0 11.9399C0.06 5.33994 5.4 -0.0600617 12.06 -6.17314e-05C18.66 0.0599383 24 5.39994 24 12.1199C23.94 18.6599 18.6 23.9999 12 23.9999Z"
fill="#00D2FF"
/>
<path
d="M19.9964 11.0215C19.9964 10.9928 19.4694 10.659 19.1919 10.4847C19.0719 10.4101 18.9605 10.3229 18.8595 10.2244C18.652 10.0209 18.306 9.66533 18.1932 9.44656C18.1209 9.30663 18.1506 9.05484 18.2068 8.81451C18.3042 8.39284 18.2305 7.95012 18.0015 7.58186L17.6409 6.99945C17.4747 6.73384 17.3413 6.44949 17.2432 6.15245C17.1188 5.77064 16.9021 5.42475 16.612 5.14486C16.0253 4.57728 14.4008 4.29786 13.0514 4.25317C12.968 4.22844 12.8832 4.20849 12.7974 4.19342C12.1964 4.0919 11.5559 3.92816 10.9809 4.03462C10.127 4.19185 9.26378 4.45734 8.61967 5.11274C8.48962 5.24481 8.28685 5.30725 8.14684 5.43236C7.86953 5.68055 7.49593 5.68055 7.24943 5.95637C7.10511 6.11697 7.0385 6.64187 6.66037 6.84245C6.03484 7.17487 5.57288 7.54098 5.42018 7.72808C5.30554 7.86846 5.21628 8.03287 5.10504 8.1773C4.99176 8.32464 4.45231 8.57395 4.29553 8.72983C4.13875 8.88571 3.92896 9.2653 4.02366 9.71384C4.0325 9.75472 4.03975 9.78841 4.04632 9.81581C4.10794 10.0438 4.2756 10.4571 4.23686 10.6469C4.19154 10.8715 3.60996 12.5428 4.90997 12.9882C5.18184 13.0812 5.29512 13.262 5.32503 13.5371C5.35174 13.76 5.416 13.9768 5.51511 14.1786C5.63337 14.4257 5.86651 14.5604 5.88554 14.5771C5.96393 14.6444 6.32869 15.0231 6.35882 15.0782C6.8201 15.9234 6.69051 16.3456 7.57341 16.6329C7.80029 16.7072 8.01814 16.8063 8.22296 16.9283C8.47266 17.0769 8.74001 17.1943 9.01887 17.2777C9.02703 17.28 9.03926 17.2843 9.05376 17.2894C9.24996 16.8195 9.44888 16.3739 9.64712 15.9544C8.05757 14.3387 8.47558 12.5286 8.6276 12.0437C8.63204 12.0293 8.64008 12.0161 8.65099 12.0056C8.66189 11.995 8.6753 11.9874 8.68998 11.9833C8.70466 11.9793 8.72014 11.979 8.73497 11.9824C8.74981 11.9859 8.76353 11.993 8.77486 12.003C9.10836 12.2928 10.1224 13.3377 10.0035 15.2244C10.3542 14.5299 10.6952 13.9194 11.0067 13.3979C9.85986 11.471 10.7144 9.78167 10.9841 9.3365C10.9918 9.32317 11.0028 9.31202 11.0162 9.30414C11.0295 9.29625 11.0446 9.29188 11.0601 9.29145C11.0756 9.29103 11.091 9.29455 11.1047 9.30169C11.1184 9.30883 11.1301 9.31935 11.1386 9.33223C11.3724 9.67633 12.0079 10.8045 11.6143 12.4298C11.8996 11.9977 12.1311 11.6776 12.2825 11.4768C12.693 8.79003 14.7398 7.90754 15.2776 7.72157C15.292 7.71636 15.3075 7.71486 15.3227 7.71722C15.3379 7.71957 15.3522 7.72571 15.3643 7.73505C15.3764 7.74439 15.3859 7.75662 15.392 7.77061C15.398 7.78459 15.4004 7.79987 15.3988 7.815C15.3492 8.37046 15.0037 10.5103 12.6298 11.6089C12.3443 11.9815 12.0695 12.3737 11.8067 12.7768C12.7145 12.0736 13.9864 11.7436 15.0438 11.9968C15.0587 12.0001 15.0726 12.0071 15.0841 12.0171C15.0956 12.0271 15.1044 12.0398 15.1097 12.054C15.115 12.0683 15.1166 12.0836 15.1145 12.0986C15.1123 12.1136 15.1064 12.1279 15.0973 12.1401C14.7934 12.539 13.5847 13.8841 11.3076 13.576C10.9224 14.219 10.5701 14.8708 10.257 15.4939C11.2405 14.7565 12.6771 14.474 13.7914 14.8452C13.8062 14.8499 13.8197 14.8583 13.8304 14.8695C13.8412 14.8807 13.8489 14.8943 13.853 14.9093C13.857 14.9242 13.8572 14.9399 13.8535 14.9549C13.8498 14.97 13.8424 14.9838 13.8319 14.9953C13.4857 15.3645 12.1529 16.577 9.96136 16.0959C9.75587 16.5262 9.44956 17.2339 9.30003 17.5837C9.2486 17.7041 9.20125 17.8256 9.15911 17.9493C9.06214 18.2341 8.93142 18.5895 8.77577 18.9452C8.75382 18.996 8.74262 19.0507 8.74287 19.1059C8.74312 19.1611 8.75482 19.2157 8.77723 19.2662C8.79964 19.3168 8.8323 19.3622 8.87316 19.3997C8.91403 19.4372 8.96224 19.466 9.01479 19.4843C10.7441 20.0963 12.6217 20.1654 14.392 19.682C14.4505 19.6655 14.5045 19.6362 14.5499 19.5962C14.5954 19.5561 14.6312 19.5065 14.6546 19.4508C14.6915 19.3641 14.728 19.2819 14.728 19.2819C14.728 19.2819 15.4933 17.5208 15.6059 16.7533C15.638 16.5114 15.7138 16.2772 15.8297 16.0619C15.8894 15.9544 15.9758 15.8637 16.0806 15.7984C16.1855 15.7331 16.3053 15.6953 16.429 15.6886C17.0115 15.6581 18.2519 15.5775 18.7032 15.4357C19.3029 15.2468 19.043 14.1638 19.0106 14.0472C18.9782 13.9306 19.2993 13.6591 19.3652 13.5007C19.4311 13.3424 19.203 13.288 19.1099 13.114C19.0168 12.9399 19.3412 12.8152 19.3874 12.6573C19.4336 12.4994 19.2818 12.326 19.2204 12.2095C19.1794 12.1264 19.1508 12.0379 19.1353 11.9467C19.1353 11.9467 19.5741 11.6282 19.8072 11.4272C20.0404 11.2261 19.9971 11.0606 19.9964 11.0215Z"
fill="black"
/>
</g>
<defs>
<clipPath id="clip0_13649_19861">
<rect width="24" height="24" fill="white" />
</clipPath>
</defs>
</svg>
</IconWrapper>
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import OneTimeDonationReviewCard from './components/one-time-donation-review-card.svelte';
import Heart from '$lib/components/icons/Heart.svelte';
import network from '$lib/stores/wallet/network';
import { invalidateAll } from '$lib/stores/fetched-data-cache/invalidate';
import invalidateAccountCache from '$lib/utils/cache/remote/invalidate-account-cache';

const dispatch = createEventDispatcher<StepComponentEvents>();

Expand Down Expand Up @@ -116,7 +118,8 @@
1000,
);

// TODO(streams): invalidate appropriate load function
await invalidateAccountCache(dripListId);
await invalidateAll();

$context.dripListId = dripListId;
},
Expand Down
8 changes: 8 additions & 0 deletions src/lib/stores/tokens/additional-tokens.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@
"symbol": "WFIL",
"decimals": 18,
"logoURI": "https://cryptologos.cc/logos/filecoin-fil-logo.png"
},
{
"chainId": 1088,
"address": "0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000",
"name": "Metis",
"symbol": "METIS",
"decimals": 18,
"logoURI": "https://cryptologos.cc/logos/metisdao-metis-logo.png"
}
]
}
80 changes: 79 additions & 1 deletion src/lib/stores/wallet/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { PUBLIC_NETWORK } from '$env/static/public';
import Base from '$lib/components/icons/networks/Base.svelte';
import Ethereum from '$lib/components/icons/networks/Ethereum.svelte';
import Filecoin from '$lib/components/icons/networks/Filecoin.svelte';
import Metis from '$lib/components/icons/networks/Metis.svelte';
import Optimism from '$lib/components/icons/networks/Optimism.svelte';
import Polygon from '$lib/components/icons/networks/Polygon.svelte';
import { SupportedChain } from '$lib/graphql/__generated__/base-types';
Expand All @@ -10,7 +11,7 @@ import { BASE_URL } from '$lib/utils/base-url';
import { nextMainnetSettlementDate } from '$lib/utils/settlement-date';
import type { ComponentType } from 'svelte';

export const SUPPORTED_CHAIN_IDS = [1, 80002, 11155420, 11155111, 84532, 314] as const;
export const SUPPORTED_CHAIN_IDS = [1, 80002, 11155420, 11155111, 84532, 314, 1088] as const;
export type ChainId = (typeof SUPPORTED_CHAIN_IDS)[number];

export type AutoUnwrapPair = {
Expand Down Expand Up @@ -60,6 +61,17 @@ export type Network = {
ensSupported: boolean;
ensAddress: string | undefined;
gaslessClaimAndCollect: boolean;
addToWalletConfig:
| {
blockExplorerUrls: string[];
nativeCurrency: {
decimals: number;
name: string;
symbol: string;
};
rpcUrls: string[];
}
| undefined;
};

export type ValueForEachSupportedChain<T> = Record<(typeof SUPPORTED_CHAIN_IDS)[number], T>;
Expand Down Expand Up @@ -109,6 +121,7 @@ export const NETWORK_CONFIG: ValueForEachSupportedChain<Network> = {
ensSupported: true,
ensAddress: '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e',
gaslessClaimAndCollect: false,
addToWalletConfig: undefined,
},
[80002]: {
chainId: 80002,
Expand Down Expand Up @@ -149,6 +162,7 @@ export const NETWORK_CONFIG: ValueForEachSupportedChain<Network> = {
ensSupported: false,
ensAddress: undefined,
gaslessClaimAndCollect: false,
addToWalletConfig: undefined,
},
[11155420]: {
chainId: 11155420,
Expand Down Expand Up @@ -189,6 +203,7 @@ export const NETWORK_CONFIG: ValueForEachSupportedChain<Network> = {
ensSupported: false,
ensAddress: undefined,
gaslessClaimAndCollect: false,
addToWalletConfig: undefined,
},
[11155111]: {
chainId: 11155111,
Expand Down Expand Up @@ -229,6 +244,7 @@ export const NETWORK_CONFIG: ValueForEachSupportedChain<Network> = {
ensSupported: true,
ensAddress: '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e',
gaslessClaimAndCollect: true,
addToWalletConfig: undefined,
},
[84532]: {
chainId: 84532,
Expand Down Expand Up @@ -269,6 +285,7 @@ export const NETWORK_CONFIG: ValueForEachSupportedChain<Network> = {
ensSupported: false,
ensAddress: undefined,
gaslessClaimAndCollect: false,
addToWalletConfig: undefined,
},
[314]: {
chainId: 314,
Expand Down Expand Up @@ -308,6 +325,67 @@ export const NETWORK_CONFIG: ValueForEachSupportedChain<Network> = {
ensSupported: false,
ensAddress: undefined,
gaslessClaimAndCollect: true,
addToWalletConfig: {
blockExplorerUrls: ['https://filecoin.blockscout.com/'],
nativeCurrency: {
decimals: 18,
name: 'Filecoin',
symbol: 'FIL',
},
rpcUrls: [
'https://api.node.glif.io/rpc/v1',
'https://filecoin.chainup.net/rpc/v1',
'https://rpc.ankr.com/filecoin',
],
},
},
[1088]: {
chainId: 1088,
name: 'metis',
label: 'Metis',
token: 'METIS',
id: '0x440',
rpcUrl: 'https://andromeda.metis.io/?owner=1088',
icon: Metis,
color: '#00D2FF',
isTestnet: false,
subdomain: 'metis.drips.network',
gqlName: SupportedChain.Metis,
autoUnwrapPairs: [],
displayNetworkPicker: true,
applyGasBuffers: false,
explorer: {
name: 'Metis Explorer',
linkTemplate: (txHash: string) => `https://explorer.metis.io/tx/${txHash}`,
},
contracts: {
ADDRESS_DRIVER: '0x749c34e4028c89c8308c78860C659E5909204d4a',
DRIPS: '0x6dc0d80E170B0f3AeB5b7354e5deE674F02202d7',
CALLER: '0x0a7f9CeeC82fDeDd262813FFbd9F913d6a25a4b5',
REPO_DRIVER: '0x2dA9a9322BC5FFE1DEE59Ae90f2E4656Cb552BB0',
NFT_DRIVER: '0xb112E3909901BC7D1Bf81f5384a76e75364C7e67',
NATIVE_TOKEN_UNWRAPPER: undefined,
},
settlement: {
nextSettlementDate: 'daily',
recipientsExplainerHtml:
'Future incoming funds will be split to your recipients <span class="typo-text-bold">daily</span>.',
explainerText:
'Funds from projects, streams and Drip Lists on Metis settle and become collectable once per day.',
},
alternativeChainMode: true,
ensSupported: false,
ensAddress: undefined,
gaslessClaimAndCollect: true,
addToWalletConfig: {
blockExplorerUrls: ['https://explorer.metis.io/'],
nativeCurrency: {
decimals: 18,
name: 'Metis',
symbol: 'METIS',
},
rpcUrls: ['https://andromeda.metis.io/?owner=1088'],
},
},
};

Expand Down
21 changes: 8 additions & 13 deletions src/lib/stores/wallet/wallet.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import type { OxString } from '$lib/utils/sdk/sdk-types';
import { executeAddressDriverReadMethod } from '$lib/utils/sdk/address-driver/address-driver';
import FailoverJsonRpcProvider from '$lib/utils/FailoverJsonRpcProvider';
import mapFilterUndefined from '$lib/utils/map-filter-undefined';
import assert from '$lib/utils/assert';

const appsSdk = new SafeAppsSDK();

Expand Down Expand Up @@ -228,21 +229,15 @@ const walletStore = () => {
secondaryButton: {
label: `Add ${network.label} to wallet`,
handler: async () => {
assert(network.addToWalletConfig, 'Network must have an addToWalletConfig');

await provider.send('wallet_addEthereumChain', [
{
chainId: '0x13a',
blockExplorerUrls: ['https://filecoin.blockscout.com/'],
chainName: 'Filecoin',
nativeCurrency: {
decimals: 18,
name: 'Filecoin',
symbol: 'FIL',
},
rpcUrls: [
'https://api.node.glif.io/rpc/v1',
'https://filecoin.chainup.net/rpc/v1',
'https://rpc.ankr.com/filecoin',
],
chainId: network.id,
blockExplorerUrls: network.addToWalletConfig.blockExplorerUrls,
chainName: network.name,
nativeCurrency: network.addToWalletConfig.nativeCurrency,
rpcUrls: network.addToWalletConfig.rpcUrls,
},
]);

Expand Down
2 changes: 2 additions & 0 deletions src/lib/utils/fiat-estimates/fiat-estimates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ const SUBSTITUTIONS: Record<string, string> = {
const MANUAL_IDS: Record<string, string> = {
/* Map Wrapped Filecoin to Filecoin */
'0x60E1773636CF5E4A227d9AC24F20fEca034ee25A': '2280',
/* Map METIS to METIS */
'0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000': '9640',
};

/** Establish a connection to the data provider. */
Expand Down
Loading