Skip to content

Commit

Permalink
fix review 1
Browse files Browse the repository at this point in the history
  • Loading branch information
dlaxcess committed Apr 30, 2024
1 parent 84da7fc commit 91f281f
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 17 deletions.
2 changes: 2 additions & 0 deletions common/src/common/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -67,6 +68,7 @@ const networks = (() => {

return {
has,
hasPaymaster,
get,

getAllActive,
Expand Down
5 changes: 2 additions & 3 deletions common/src/common/provider-get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<number, Provider> = new Map();

const providerGetWindow = async (chainId = 0): Promise<Web3Provider | undefined> => {
const providerGetWindow = async (chainId: number = 0): Promise<Web3Provider | undefined> => {
const externalProvider = (window as WindowExternalProvider).ethereum || undefined;
if (!externalProvider) return undefined;

Expand All @@ -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);

Expand Down
21 changes: 11 additions & 10 deletions common/src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { BigNumber } from "ethers";
type _handleChainId = (chainId: string) => void;
type _handleAccounts = (accounts: Array<string>) => 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;
Expand All @@ -28,19 +28,20 @@ type NetworkType = {
chainLabel?: string;
rpcUrls: Array<string>;
iconUrls?: Array<string>;
nativeCurrency: { name: string; symbol: string; decimals: number };
nativeCurrency: { name: string; symbol: string; decimals: number; };
blockExplorerUrls: Array<string>;
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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -168,7 +169,7 @@ type Property = {
display_value: string;
};

type Properties = { [k: string]: Property };
type Properties = { [k: string]: Property; };

type RefPageType = {
chainId?: number;
Expand Down
3 changes: 2 additions & 1 deletion config/src/mainnets.handlebars.json
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,8 @@
"https://honorable-steel-rasalhague.explorer.mainnet.skalenodes.com/"
],
"active": false,
"create": true
"create": true,
"paymaster": true
},
{
"chainId": 169,
Expand Down
1 change: 1 addition & 0 deletions config/src/testnets.handlebars.json
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@
],
"eip1559": false,
"create": false,
"paymaster": true,
"linkedMainnet": 1564830818
},
{
Expand Down
2 changes: 1 addition & 1 deletion gulp/src/scss/_networks.scss
Original file line number Diff line number Diff line change
@@ -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";
$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";
6 changes: 5 additions & 1 deletion skale/src/skaleReceiveFunds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<TransactionReceipt | undefined> => {
=======
const receiveFunds = async (account: string, chainId: number): Promise<TransactionReceipt | undefined> => {
>>>>>>> wip
if (!isSkaleChain(chainId)) {
console.info("@kredeum/Skale receiveFunds : ", "Not on a Skale chain, no sFuel to claim");
return;
Expand All @@ -69,7 +73,7 @@ const receiveFunds = async (account: Address, chainId: number): Promise<Transact
const chain = _getChainFromId(chainId);
const publicClient: PublicClient = createPublicClient({ chain, transport: http() });

const receiverBalance = await publicClient.getBalance({ address: account });
const receiverBalance = await publicClient.getBalance({ address: account as Address });
if (receiverBalance >= _faucetThresholdGet(chainId)) return;

if (!_sessionPrivateKey) {
Expand Down
2 changes: 1 addition & 1 deletion sveltekit/turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/**.*"]
}
Expand Down

0 comments on commit 91f281f

Please sign in to comment.