-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #324 from SocketDotTech/feat/scripts
Feat/scripts
- Loading branch information
Showing
11 changed files
with
357 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import { ContractFactory } from "ethers"; | ||
import { network, ethers, run } from "hardhat"; | ||
|
||
import { DeployParams, getOrDeploy, storeAddresses } from "../utils"; | ||
|
||
import { | ||
CORE_CONTRACTS, | ||
ChainSocketAddresses, | ||
DeploymentMode, | ||
ChainSlugToKey, | ||
version, | ||
DeploymentAddresses, | ||
getAllAddresses, | ||
ChainSlug, | ||
IntegrationTypes, | ||
} from "../../../src"; | ||
import deploySwitchboards from "./deploySwitchboard"; | ||
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers"; | ||
import { socketOwner, executionManagerVersion, mode, chains } from "../config"; | ||
import { | ||
getProviderFromChainSlug, | ||
maxAllowedPacketLength, | ||
} from "../../constants"; | ||
|
||
const main = async ( | ||
srcChains: ChainSlug[], | ||
dstChains: ChainSlug[], | ||
integrationTypes: IntegrationTypes[] | ||
) => { | ||
try { | ||
let addresses: DeploymentAddresses; | ||
try { | ||
addresses = getAllAddresses(mode); | ||
} catch (error) { | ||
addresses = {} as DeploymentAddresses; | ||
} | ||
let srcChainSlugs = srcChains ?? chains; | ||
|
||
await Promise.all( | ||
srcChainSlugs.map(async (chainSlug) => { | ||
let integrations = addresses[chainSlug as ChainSlug]?.integrations; | ||
if (!integrations) return; | ||
|
||
let siblingChains = dstChains ?? Object.keys(integrations); | ||
|
||
await Promise.all( | ||
siblingChains.map(async (siblingChain) => { | ||
let siblingIntegrations = | ||
integrations?.[Number(siblingChain) as ChainSlug]; | ||
if (!siblingIntegrations) return; | ||
let integrationTypesArray = | ||
integrationTypes ?? Object.keys(siblingIntegrations); | ||
|
||
await Promise.all( | ||
integrationTypesArray.map(async (integrationType) => { | ||
let integration = | ||
siblingIntegrations?.[integrationType as IntegrationTypes]; | ||
if (!integration) return; | ||
let capacitor = integration.capacitor; | ||
if (!capacitor) return; | ||
let provider = getProviderFromChainSlug(chainSlug as ChainSlug); | ||
let Contract = await ethers.getContractFactory( | ||
"SingleCapacitor" | ||
); | ||
let instance = Contract.attach(capacitor).connect(provider); | ||
let result = await instance.getNextPacketToBeSealed(); | ||
console.log( | ||
chainSlug, | ||
" ", | ||
Number(siblingChain), | ||
" ", | ||
integrationType, | ||
" ", | ||
result[1].toNumber(), | ||
" ", | ||
result[0].toString() | ||
); | ||
}) | ||
); | ||
}) | ||
); | ||
}) | ||
); | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
}; | ||
|
||
// let srcChains; | ||
// let dstChains; | ||
let integrationTypes; | ||
|
||
let srcChains = [ChainSlug.OPTIMISM_GOERLI]; | ||
let dstChains = [ChainSlug.ARBITRUM_GOERLI]; | ||
// let integrationTypes = [IntegrationTypes.fast2]; | ||
|
||
main(srcChains, dstChains, integrationTypes); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { config as dotenvConfig } from "dotenv"; | ||
import axios from "axios"; | ||
|
||
dotenvConfig(); | ||
import { ChainSlugToKey } from "../../../src"; | ||
import { utils } from "ethers"; | ||
|
||
import { chains, mode } from "../config"; | ||
import { getProviderFromChainName } from "../../constants/networks"; | ||
|
||
// check balance of owner address on all chains | ||
export const checkBalance = async () => { | ||
try { | ||
// parallelize chains | ||
await Promise.all( | ||
chains.map(async (chainSlug) => { | ||
const provider = await getProviderFromChainName( | ||
ChainSlugToKey[chainSlug] | ||
); | ||
// let ownerAddress = process.env.SOCKET_OWNER_ADDRESS; | ||
let ownerAddress = "0x752B38FA38F53dF7fa60e6113CFd9094b7e040Aa"; | ||
if (!ownerAddress) throw Error("owner address not present"); | ||
console.log( | ||
chainSlug, | ||
" ", | ||
ChainSlugToKey[chainSlug], | ||
" : ", | ||
utils.formatEther(await provider.getBalance(ownerAddress)) | ||
); | ||
}) | ||
); | ||
} catch (error) { | ||
console.log("Error while checking balance", error); | ||
} | ||
}; | ||
|
||
const main = async () => { | ||
await checkBalance(); | ||
}; | ||
|
||
main() | ||
.then(() => process.exit(0)) | ||
.catch((error: Error) => { | ||
console.error(error); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { ContractFactory } from "ethers"; | ||
import { network, ethers, run } from "hardhat"; | ||
|
||
import { DeployParams, getOrDeploy, storeAddresses } from "../utils"; | ||
|
||
import { | ||
CORE_CONTRACTS, | ||
ChainSocketAddresses, | ||
DeploymentMode, | ||
ChainSlugToKey, | ||
version, | ||
DeploymentAddresses, | ||
getAllAddresses, | ||
ChainSlug, | ||
IntegrationTypes, | ||
} from "../../../src"; | ||
import deploySwitchboards from "./deploySwitchboard"; | ||
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers"; | ||
import { socketOwner, executionManagerVersion, mode, chains } from "../config"; | ||
import { | ||
getProviderFromChainSlug, | ||
maxAllowedPacketLength, | ||
} from "../../constants"; | ||
|
||
const main = async (srcChains: ChainSlug[], dstChains: ChainSlug[]) => { | ||
try { | ||
let addresses: DeploymentAddresses; | ||
try { | ||
addresses = getAllAddresses(mode); | ||
} catch (error) { | ||
addresses = {} as DeploymentAddresses; | ||
} | ||
let srcChainSlugs = srcChains ?? chains; | ||
let data: any[] = []; | ||
await Promise.all( | ||
srcChainSlugs.map(async (chainSlug) => { | ||
let fastSwitchboardAddress = | ||
addresses[chainSlug as ChainSlug]?.FastSwitchboard2; | ||
if (!fastSwitchboardAddress) return; | ||
|
||
let siblingChains = dstChains ?? chains.filter((s) => chainSlug !== s); | ||
|
||
await Promise.all( | ||
siblingChains.map(async (siblingChain) => { | ||
let provider = getProviderFromChainSlug(chainSlug as ChainSlug); | ||
let Contract = await ethers.getContractFactory("FastSwitchboard"); | ||
let instance = Contract.attach(fastSwitchboardAddress).connect( | ||
provider | ||
); | ||
// console.log(instance);÷\ | ||
let result = await instance["totalWatchers(uint32)"](siblingChain); | ||
// console.log(result); | ||
data.push({ | ||
chainSlug, | ||
siblingChain, | ||
totalWatchers: result.toNumber(), | ||
}); | ||
}) | ||
); | ||
}) | ||
); | ||
console.table(data); | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
}; | ||
|
||
// let srcChains; | ||
// let dstChains; | ||
|
||
let srcChains = [ChainSlug.ARBITRUM_GOERLI]; | ||
let dstChains = [ChainSlug.AEVO_TESTNET]; | ||
// let integrationTypes = [IntegrationTypes.fast2]; | ||
|
||
main(srcChains, dstChains); |
Oops, something went wrong.