Skip to content

Commit

Permalink
open source website
Browse files Browse the repository at this point in the history
  • Loading branch information
RPate97 committed Jun 10, 2024
1 parent d5c0da2 commit 42b2a7d
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 393 deletions.
7 changes: 0 additions & 7 deletions packages/core/config/local.ts

This file was deleted.

14 changes: 0 additions & 14 deletions packages/core/config/standard.ts

This file was deleted.

71 changes: 30 additions & 41 deletions packages/core/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Wallet } from 'ethers'
import ora from 'ora'

import { SphinxJsonRpcProvider } from './src/provider'
import { SphinxSystemConfig, deploySphinxSystem } from './src/languages'
import { deploySphinxSystem } from './src/languages'
import { verifySphinxSystem } from './src/etherscan'
import { ExecutionMode } from './src/constants'
import { isVerificationSupportedForNetwork } from './src/networks'
Expand Down Expand Up @@ -61,49 +61,38 @@ const config: HardhatUserConfig = {

task('deploy-system')
.setDescription('Deploys the Sphinx contracts to the specified network')
.addParam('systemConfig', 'Path to a Sphinx system config file')
.setAction(
async (
args: {
systemConfig: string
},
hre: HardhatRuntimeEnvironment
) => {
// Throw an error if we're on the Hardhat network. This ensures that the `url` field is
// defined for this network.
if (!('url' in hre.network.config)) {
throw new Error(
`Cannot deploy Sphinx on the Hardhat network using this task.`
)
}
const provider = new SphinxJsonRpcProvider(hre.network.config.url)
const signer = new Wallet(process.env.PRIVATE_KEY!).connect(provider)

const systemConfig: SphinxSystemConfig =
require(args.systemConfig).default
.setAction(async (_, hre: HardhatRuntimeEnvironment) => {
// Throw an error if we're on the Hardhat network. This ensures that the `url` field is
// defined for this network.
if (!('url' in hre.network.config)) {
throw new Error(
`Cannot deploy Sphinx on the Hardhat network using this task.`
)
}
const provider = new SphinxJsonRpcProvider(hre.network.config.url)
const signer = new Wallet(process.env.PRIVATE_KEY!).connect(provider)

const spinner = ora()
const logger = new Logger({
name: 'Logger',
})
const spinner = ora()
const logger = new Logger({
name: 'Logger',
})

await deploySphinxSystem(
provider,
signer,
systemConfig.relayers,
ExecutionMode.LiveNetworkCLI,
true,
spinner
)
await deploySphinxSystem(
provider,
signer,
[],
ExecutionMode.LiveNetworkCLI,
true,
spinner
)

if (
isVerificationSupportedForNetwork((await provider.getNetwork()).chainId)
) {
await verifySphinxSystem(provider, logger)
} else {
spinner.info('Verification unsupported on this network')
}
if (
isVerificationSupportedForNetwork((await provider.getNetwork()).chainId)
) {
await verifySphinxSystem(provider, logger)
} else {
spinner.info('Verification unsupported on this network')
}
)
})

export default config
10 changes: 7 additions & 3 deletions packages/core/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,13 @@ export const getDuplicateElements = (arr: Array<string>): Array<string> => {
}

export const fetchSphinxManagedBaseUrl = () => {
return process.env.SPHINX_MANAGED_BASE_URL
? process.env.SPHINX_MANAGED_BASE_URL
: 'https://www.sphinx.dev'
if (process.env.SPHINX_MANAGED_BASE_URL) {
return process.env.SPHINX_MANAGED_BASE_URL
} else {
throw new Error(
'You must define a SPHINX_MANAGED_BASE_URL environment variable pointing to your Sphinx instance.'
)
}
}

export const readSphinxLock = async (): Promise<SphinxLock> => {
Expand Down
3 changes: 1 addition & 2 deletions packages/plugins/src/cli/propose/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,7 @@ export const propose = async (
networks,
testnets,
mainnets,
foundryToml.rpcEndpoints,
sphinxContext.isLiveNetwork
foundryToml.rpcEndpoints
)

spinner.succeed(`Validated networks.`)
Expand Down
17 changes: 1 addition & 16 deletions packages/plugins/src/foundry/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,12 @@ import {
import { AssertNoLinkedLibraries } from '../../cli/types'
import { BuildInfoTemplate, trimObjectToType } from './trim'
import { assertValidNodeVersion } from '../../cli/utils'
import { SphinxContext } from '../../cli/context'
import {
InvalidFirstSigArgumentErrorMessage,
SigCalledWithNoArgsErrorMessage,
SphinxConfigMainnetsContainsTestnetsErrorMessage,
SphinxConfigTestnetsContainsMainnetsErrorMessage,
getFailedRequestErrorMessage,
getLocalNetworkErrorMessage,
getMissingEndpointErrorMessage,
getMixedNetworkTypeErrorMessage,
getUnsupportedNetworkErrorMessage,
Expand Down Expand Up @@ -1497,8 +1495,7 @@ export const validateProposalNetworks = async (
cliNetworks: Array<string>,
configTestnets: Array<string>,
configMainnets: Array<string>,
rpcEndpoints: FoundryToml['rpcEndpoints'],
isLiveNetwork: SphinxContext['isLiveNetwork']
rpcEndpoints: FoundryToml['rpcEndpoints']
): Promise<{ rpcUrls: Array<string>; isTestnet: boolean }> => {
if (cliNetworks.length === 0) {
throw new Error(`Expected at least one network, but none were supplied.`)
Expand Down Expand Up @@ -1552,12 +1549,6 @@ export const validateProposalNetworks = async (
}
}

if (!(await isLiveNetwork(provider))) {
if (process.env.SPHINX_INTERNAL__ALLOW_LOCAL_NODES !== 'true') {
return { type: 'localNetwork', network }
}
}

return {
type: 'valid',
rpcUrl,
Expand Down Expand Up @@ -1624,12 +1615,6 @@ export const validateProposalNetworks = async (
throw new Error(getUnsupportedNetworkErrorMessage(unsupported))
}

if (localNetwork.length > 0) {
if (process.env.SPHINX_INTERNAL__ALLOW_LOCAL_NODES !== 'true') {
throw new Error(getLocalNetworkErrorMessage(localNetwork))
}
}

// Check if the array contains a mix of test networks and production networks. We check this after
// resolving the promises above because we need to know all of the network types.
const networkTypes = valid.map(({ networkType }) => networkType)
Expand Down
Loading

0 comments on commit 42b2a7d

Please sign in to comment.