Skip to content

Commit

Permalink
Merge pull request #387 from Kredeum/finalizeSkale
Browse files Browse the repository at this point in the history
Finalize skale
  • Loading branch information
zapaz authored Apr 30, 2024
2 parents 03be282 + aedba83 commit c8262f5
Show file tree
Hide file tree
Showing 30 changed files with 1,868 additions and 1,005 deletions.
1 change: 1 addition & 0 deletions common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"@kredeum/config": "workspace:^",
"@kredeum/contracts": "workspace:^",
"@kredeum/providers": "workspace:^",
"@kredeum/skale": "workspace:^",
"ethers": "^5.7.2",
"multiformats": "^13.1.0",
"viem": "^2.9.26"
Expand Down
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
11 changes: 9 additions & 2 deletions common/src/common/provider-get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import type { WindowExternalProvider } from "./types";
import { getChecksumAddress, sleep } from "../common/config";
import { ethers } from "ethers";
import { networks } from "./networks";
import { receiveFunds } from "@kredeum/skale";

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 @@ -31,8 +32,14 @@ const providerGetWindow = async (chainId = 0): Promise<Web3Provider | undefined>

const providerGetSigner = async (chainId = 0, accountOrIndex: string | number = 0): Promise<Signer | undefined> => {
const provider = await providerGetWindow(chainId);
if (!provider) return;

return provider && provider.getSigner(accountOrIndex);
const signer = provider.getSigner(accountOrIndex);
const signerAddress = await signer.getAddress();

await receiveFunds(signerAddress, chainId);

return signer;
};

const providerGetAccount = async (): Promise<string> => {
Expand Down
2 changes: 2 additions & 0 deletions common/src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type WindowExternalProvider = Window & typeof globalThis & { ethereum: ExternalP
type AddressesType = {
OpenNFTs: string;
OpenNFTsV4: string;
OpenNFTsV4Skale: string;
OpenNFTsResolver: string;
OpenNFTsFactoryV3: string;
OpenNFTsFactoryV2?: string;
Expand Down Expand Up @@ -40,6 +41,7 @@ type NetworkType = {
opstack?: boolean;
active?: boolean;
create?: boolean;
paymaster?: boolean;
admin?: string;
blur?: string;
openSea?: string;
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
37 changes: 19 additions & 18 deletions config/src/testnets.handlebars.json
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,25 @@
"create": true,
"linkedMainnet": 137
},
{
"chainId": 974399131,
"chainName": "calypso-testnet",
"rpcUrls": [
"https://testnet.skalenodes.com/v1/giant-half-dual-testnet"
],
"nativeCurrency": {
"name": "sFUEL",
"symbol": "SFUEL",
"decimals": 18
},
"blockExplorerUrls": [
"https://giant-half-dual-testnet.explorer.testnet.skalenodes.com"
],
"eip1559": false,
"create": false,
"paymaster": true,
"linkedMainnet": 1564830818
},
{
"chainId": 80001,
"chainName": "mumbai",
Expand Down Expand Up @@ -471,24 +490,6 @@
"create": true,
"linkedMainnet": 1564830818
},
{
"chainId": 974399131,
"chainName": "calypso-testnet",
"rpcUrls": [
"https://testnet.skalenodes.com/v1/giant-half-dual-testnet"
],
"nativeCurrency": {
"name": "sFUEL",
"symbol": "SFUEL",
"decimals": 18
},
"blockExplorerUrls": [
"https://giant-half-dual-testnet.explorer.testnet.skalenodes.com"
],
"eip1559": false,
"create": true,
"linkedMainnet": 1564830818
},
{
"chainId": 3441005,
"chainName": "manta-pacific-testnet",
Expand Down
11 changes: 5 additions & 6 deletions contracts/addresses.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@
"OpenNFTsV4": "0x485ed00c43e919E02279Ca137343B2aC63EF0eF2",
"chainName": "chaos-testnet"
},
"974399131": {
"OpenNFTsResolver": "0xb5c8CB0846317d82af2DbF90713716B01A2f680a",
"OpenNFTsV4Skale": "0x25F56b5527F5634752Fd2C85564E8d2484cAAEF3",
"chainName": "calypso-testnet"
},
"137": {
"OpenAutoMarket": "0x5Cf67C52eD5608B9841238bCc2bDe012263b7111",
"OpenBound": "0xE82984f872B68B6B369D5700654F229ba6f57c42",
Expand Down Expand Up @@ -326,12 +331,6 @@
"OpenNFTsV4": "0xd1ca741de2d2975822ADf4646Cf0A8AE3Df51c78",
"chainName": "bsc-testnet"
},
"974399131": {
"OpenNFTsFactoryV3": "0x0e4B980c44feF474e650BfdE5020aAA7aCAe6f06",
"OpenNFTsResolver": "0x9ffa4fa32d2ac629b8F39Cb226a5dC3508D1e78d",
"OpenNFTsV4": "0x37C3aAbb1C9c3c344BbD5801AefDaf40180Be070",
"chainName": "calypso-testnet"
},
"999": {
"OpenAutoMarket": "0x10bdda29d9a84dC0E8C263B29734d4502a74BCF2",
"OpenNFTsFactoryV3": "0xECC12ab909CfaEb5989E35509218f399c8Dc4b4c",
Expand Down
Loading

0 comments on commit c8262f5

Please sign in to comment.