From 91f281f032cdbd8121c8b9d60019be846f2291f7 Mon Sep 17 00:00:00 2001 From: dlaxcess Date: Tue, 30 Apr 2024 12:18:12 +0200 Subject: [PATCH] fix review 1 --- common/src/common/networks.ts | 2 ++ common/src/common/provider-get.ts | 5 ++--- common/src/common/types.ts | 21 +++++++++++---------- config/src/mainnets.handlebars.json | 3 ++- config/src/testnets.handlebars.json | 1 + gulp/src/scss/_networks.scss | 2 +- skale/src/skaleReceiveFunds.ts | 6 +++++- sveltekit/turbo.json | 2 +- 8 files changed, 25 insertions(+), 17 deletions(-) diff --git a/common/src/common/networks.ts b/common/src/common/networks.ts index 1c24f7b80..989b23877 100644 --- a/common/src/common/networks.ts +++ b/common/src/common/networks.ts @@ -46,6 +46,7 @@ const networks = (() => { const getRpcUrl = (chainId: chainIdish): string => get(chainId)?.rpcUrls[0] || ""; const has = (chainId: chainIdish): boolean => _networksMap?.has(Number(chainId)); + const hasPaymaster = (chainId: chainIdish): boolean => get(chainId)?.paymaster || false; const isActive = (chainId: chainIdish): boolean => get(chainId)?.active || true; const isEip1559 = (chainId: chainIdish): boolean => Boolean(get(chainId)?.eip1559); @@ -67,6 +68,7 @@ const networks = (() => { return { has, + hasPaymaster, get, getAllActive, diff --git a/common/src/common/provider-get.ts b/common/src/common/provider-get.ts index e5429b363..7f6b74b99 100644 --- a/common/src/common/provider-get.ts +++ b/common/src/common/provider-get.ts @@ -9,14 +9,13 @@ import { getChecksumAddress, sleep } from "../common/config"; import { ethers } from "ethers"; import { networks } from "./networks"; import { receiveFunds } from "@kredeum/skale"; -import { Address } from "viem"; let _providerSetting = false; // Cache providers per chainId const _providersPerChainId: Map = new Map(); -const providerGetWindow = async (chainId = 0): Promise => { +const providerGetWindow = async (chainId: number = 0): Promise => { const externalProvider = (window as WindowExternalProvider).ethereum || undefined; if (!externalProvider) return undefined; @@ -36,7 +35,7 @@ const providerGetSigner = async (chainId = 0, accountOrIndex: string | number = if (!provider) return; const signer = provider.getSigner(accountOrIndex); - const signerAddress = (await signer.getAddress()) as Address; + const signerAddress = (await signer.getAddress()); await receiveFunds(signerAddress, chainId); diff --git a/common/src/common/types.ts b/common/src/common/types.ts index 49067ca3c..2c81df81e 100644 --- a/common/src/common/types.ts +++ b/common/src/common/types.ts @@ -5,10 +5,10 @@ import { BigNumber } from "ethers"; type _handleChainId = (chainId: string) => void; type _handleAccounts = (accounts: Array) => void; type _onFunction = (label: string, func: _handleChainId | _handleAccounts) => void; -type EthereumProvider = ExternalProvider & { on?: _onFunction }; +type EthereumProvider = ExternalProvider & { on?: _onFunction; }; -type WindowEthereumProvider = Window & typeof globalThis & { ethereum: EthereumProvider }; -type WindowExternalProvider = Window & typeof globalThis & { ethereum: ExternalProvider }; +type WindowEthereumProvider = Window & typeof globalThis & { ethereum: EthereumProvider; }; +type WindowExternalProvider = Window & typeof globalThis & { ethereum: ExternalProvider; }; type AddressesType = { OpenNFTs: string; @@ -28,19 +28,20 @@ type NetworkType = { chainLabel?: string; rpcUrls: Array; iconUrls?: Array; - nativeCurrency: { name: string; symbol: string; decimals: number }; + nativeCurrency: { name: string; symbol: string; decimals: number; }; blockExplorerUrls: Array; etherscanApiKey?: string; hardhatOptions?: unknown; - subgraph?: { url?: string; startBlock?: number; active?: boolean }; - infura?: { url?: string; active: boolean }; - alchemy?: { url?: string; active: boolean }; - covalent?: { active: boolean; url?: string; key?: string }; + subgraph?: { url?: string; startBlock?: number; active?: boolean; }; + infura?: { url?: string; active: boolean; }; + alchemy?: { url?: string; active: boolean; }; + covalent?: { active: boolean; url?: string; key?: string; }; linkedLayer1?: number; linkedMainnet?: number; opstack?: boolean; active?: boolean; create?: boolean; + paymaster?: boolean; admin?: string; blur?: string; openSea?: string; @@ -74,7 +75,7 @@ type CollectionType = { price?: BigNumber; }; -type CollectionFilterType = { owner?: string; tokenID?: string; offset?: number; limit?: number }; +type CollectionFilterType = { owner?: string; tokenID?: string; offset?: number; limit?: number; }; /////////////////////////////////////////////////// // Exclusives storage parameters for Ipfs | Swarm @@ -168,7 +169,7 @@ type Property = { display_value: string; }; -type Properties = { [k: string]: Property }; +type Properties = { [k: string]: Property; }; type RefPageType = { chainId?: number; diff --git a/config/src/mainnets.handlebars.json b/config/src/mainnets.handlebars.json index 87c0824c4..adcea19e1 100644 --- a/config/src/mainnets.handlebars.json +++ b/config/src/mainnets.handlebars.json @@ -429,7 +429,8 @@ "https://honorable-steel-rasalhague.explorer.mainnet.skalenodes.com/" ], "active": false, - "create": true + "create": true, + "paymaster": true }, { "chainId": 169, diff --git a/config/src/testnets.handlebars.json b/config/src/testnets.handlebars.json index 2b3e23672..aff7bbc9d 100644 --- a/config/src/testnets.handlebars.json +++ b/config/src/testnets.handlebars.json @@ -324,6 +324,7 @@ ], "eip1559": false, "create": false, + "paymaster": true, "linkedMainnet": 1564830818 }, { diff --git a/gulp/src/scss/_networks.scss b/gulp/src/scss/_networks.scss index c86be926e..a6f9ee0d3 100644 --- a/gulp/src/scss/_networks.scss +++ b/gulp/src/scss/_networks.scss @@ -1 +1 @@ -$networks: "mainnet", "arbitrum", "optimism", "base", "linea", "mantle", "blast", "polygon-zkevm", "mode", "manta-pacific", "polygon", "gnosis", "avalanche", "fantom", "bsc", "scroll", "zora", "celo", "telos", "taiko", "skale", "skale-calypso", "local"; \ No newline at end of file +$networks: "mainnet", "arbitrum", "optimism", "base", "linea", "mantle", "blast", "polygon-zkevm", "mode", "manta-pacific", "polygon", "gnosis", "avalanche", "fantom", "bsc", "scroll", "zora", "celo", "telos", "taiko", "skale-calypso", "local"; diff --git a/skale/src/skaleReceiveFunds.ts b/skale/src/skaleReceiveFunds.ts index ff5e2ff8d..82ea46e96 100644 --- a/skale/src/skaleReceiveFunds.ts +++ b/skale/src/skaleReceiveFunds.ts @@ -59,7 +59,11 @@ const _functionSignatureGet = (chainId: number): Address => { const _rmBytesSymbol = (address: string) => address.replace(/^0x/, ""); //////////////////////////////////////////////// +<<<<<<< HEAD const receiveFunds = async (account: Address, chainId: number): Promise => { +======= +const receiveFunds = async (account: string, chainId: number): Promise => { +>>>>>>> wip if (!isSkaleChain(chainId)) { console.info("@kredeum/Skale receiveFunds : ", "Not on a Skale chain, no sFuel to claim"); return; @@ -69,7 +73,7 @@ const receiveFunds = async (account: Address, chainId: number): Promise= _faucetThresholdGet(chainId)) return; if (!_sessionPrivateKey) { diff --git a/sveltekit/turbo.json b/sveltekit/turbo.json index 230c5328e..09ff8612c 100644 --- a/sveltekit/turbo.json +++ b/sveltekit/turbo.json @@ -10,7 +10,7 @@ "inputs": ["src/**", "../contracts/addresses.json"] }, "build": { - "dependsOn": ["check", "@kredeum/gulp#build"], + "dependsOn": ["check", "@kredeum/gulp#build", "@kredeum/skale#build"], "inputs": ["src/**"], "outputs": ["web/dapp/index.html", "web/dapp/_app/**.*"] }