Skip to content
This repository has been archived by the owner on May 28, 2022. It is now read-only.

Commit

Permalink
rename scripts into sub-folder of governance
Browse files Browse the repository at this point in the history
  • Loading branch information
anna-carroll committed Jan 26, 2022
1 parent ff58d1e commit 5212e12
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 68 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as rinkeby from '../../../config/testnets/rinkeby';
import * as kovan from '../../../config/testnets/kovan';
import { ExistingCoreDeploy } from '../../../src/core/CoreDeploy';
import { ExistingBridgeDeploy } from '../../../src/bridge/BridgeDeploy';
import { getPathToDeployConfig } from '../../../src/verification/readDeployOutput';
import { deploysToSDK } from '../../../src/incremental/utils';
import { checkHubAndSpokeConnections } from '../../../src/incremental/checks';
import * as rinkeby from '../../../../config/testnets/rinkeby';
import * as kovan from '../../../../config/testnets/kovan';
import { ExistingCoreDeploy } from '../../../../src/core/CoreDeploy';
import { ExistingBridgeDeploy } from '../../../../src/bridge/BridgeDeploy';
import { getPathToDeployConfig } from '../../../../src/verification/readDeployOutput';
import { deploysToSDK } from '../../../../src/governance/utils';
import { checkHubAndSpokeConnections } from '../../../../src/governance/enrollChain/checks';
import { NomadContext } from '@nomad-xyz/sdk';

const path = getPathToDeployConfig('dev');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as rinkeby from '../../../config/testnets/rinkeby';
import * as kovan from '../../../config/testnets/kovan';
import * as rinkeby from '../../../../config/testnets/rinkeby';
import * as kovan from '../../../../config/testnets/kovan';
import {
BridgeDeploy,
ExistingBridgeDeploy,
} from '../../../src/bridge/BridgeDeploy';
import { deployNewChainBridge } from '../../../src/bridge';
import { getPathToDeployConfig } from '../../../src/verification/readDeployOutput';
} from '../../../../src/bridge/BridgeDeploy';
import { deployNewChainBridge } from '../../../../src/bridge';
import { getPathToDeployConfig } from '../../../../src/verification/readDeployOutput';

const path = getPathToDeployConfig('dev');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import * as rinkeby from '../../../config/testnets/rinkeby';
import * as kovan from '../../../config/testnets/kovan';
import * as moonbasealpha from '../../../config/testnets/moonbasealpha';
import { CoreDeploy, ExistingCoreDeploy } from '../../../src/core/CoreDeploy';
import { deployNewChain } from '../../../src/core';
import { getPathToDeployConfig } from '../../../src/verification/readDeployOutput';
import * as rinkeby from '../../../../config/testnets/rinkeby';
import * as kovan from '../../../../config/testnets/kovan';
import * as moonbasealpha from '../../../../config/testnets/moonbasealpha';
import {
CoreDeploy,
ExistingCoreDeploy,
} from '../../../../src/core/CoreDeploy';
import { deployNewChain } from '../../../../src/core';
import { getPathToDeployConfig } from '../../../../src/verification/readDeployOutput';

const path = getPathToDeployConfig('dev');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as rinkeby from '../../../config/testnets/rinkeby';
import * as kovan from '../../../config/testnets/kovan';
import { ExistingCoreDeploy } from '../../../src/core/CoreDeploy';
import { ExistingBridgeDeploy } from '../../../src/bridge/BridgeDeploy';
import { getPathToDeployConfig } from '../../../src/verification/readDeployOutput';
import { deploysToSDK } from '../../../src/incremental/utils';
import { enrollSpoke } from '../../../src/incremental';
import * as rinkeby from '../../../../config/testnets/rinkeby';
import * as kovan from '../../../../config/testnets/kovan';
import { ExistingCoreDeploy } from '../../../../src/core/CoreDeploy';
import { ExistingBridgeDeploy } from '../../../../src/bridge/BridgeDeploy';
import { getPathToDeployConfig } from '../../../../src/verification/readDeployOutput';
import { deploysToSDK } from '../../../../src/governance/utils';
import { enrollSpoke } from '../../../../src/governance/enrollChain';
import { NomadContext } from '@nomad-xyz/sdk';

const path = getPathToDeployConfig('dev');
Expand Down Expand Up @@ -45,4 +45,4 @@ sdkCores.forEach((core) => {
});

// enroll spoke then check enrollment
enrollSpoke(sdk, kovanDomain.id, kovan.devConfig);
enrollSpoke(sdk, kovanCoreDeploy);
8 changes: 4 additions & 4 deletions typescript/nomad-deploy/scripts/local/connect.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as tom from '../../config/local/tom';
import * as daffy from '../../config/local/jerry';
import { enrollSpoke } from '../../src/incremental';
import { deploysToSDK } from '../../src/incremental/utils';
import { enrollSpoke } from '../../src/governance/enrollChain';
import { checkHubToSpokeConnectionWithWaiter } from '../../src/governance/enrollChain/checks';
import { deploysToSDK } from '../../src/governance/utils';
import { getPathToDeployConfig } from '../../src/verification/readDeployOutput';
import { ExistingCoreDeploy } from '../../src/core/CoreDeploy';
import { ExistingBridgeDeploy } from '../../src/bridge/BridgeDeploy';
import { NomadContext } from '@nomad-xyz/sdk';
import { checkHubToSpokeConnectionWithWaiter } from '../../src/incremental/checks';

const path = getPathToDeployConfig('dev');

Expand Down Expand Up @@ -44,7 +44,7 @@ const sdk = NomadContext.fromDomains([tomDomain, daffyDomain]);
});

(async () => {
await enrollSpoke(sdk, daffyDomain.id, daffy.devConfig);
await enrollSpoke(sdk, daffyCoreDeploy);
await checkHubToSpokeConnectionWithWaiter(
sdk,
daffyDomain.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import * as kovan from '../../../config/testnets/kovan';
import { ExistingCoreDeploy } from '../../../src/core/CoreDeploy';
import { ExistingBridgeDeploy } from '../../../src/bridge/BridgeDeploy';
import { getPathToDeployConfig } from '../../../src/verification/readDeployOutput';
import { deploysToSDK } from '../../../src/incremental/utils';
import { checkHubAndSpokeConnections } from '../../../src/incremental/checks';
import { deploysToSDK } from '../../../src/governance/utils';
import { checkHubAndSpokeConnections } from '../../../src/governance/enrollChain/checks';
import { NomadContext } from '@nomad-xyz/sdk';

const path = getPathToDeployConfig('staging');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import * as kovan from '../../../config/testnets/kovan';
import { ExistingCoreDeploy } from '../../../src/core/CoreDeploy';
import { ExistingBridgeDeploy } from '../../../src/bridge/BridgeDeploy';
import { getPathToDeployConfig } from '../../../src/verification/readDeployOutput';
import { deploysToSDK } from '../../../src/incremental/utils';
import { enrollSpoke } from '../../../src/incremental';
import { deploysToSDK } from '../../../src/governance/utils';
import { enrollSpoke } from '../../../src/governance/enrollChain';
import { NomadContext } from '@nomad-xyz/sdk';

const path = getPathToDeployConfig('staging');
Expand Down Expand Up @@ -46,4 +46,4 @@ sdkCores.map((core) => {
});

// enroll spoke
enrollSpoke(sdk, kovanDomain.id, kovan.stagingConfig);
enrollSpoke(sdk, kovanCoreDeploy);
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NomadContext } from '@nomad-xyz/sdk/';
import { expect, AssertionError } from 'chai';
import { Waiter } from './utils';
import { Waiter } from '../utils';

export async function checkHubAndSpokeConnections(
sdk: NomadContext,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
import { NomadContext } from '@nomad-xyz/sdk/';
import { CallBatch } from '@nomad-xyz/sdk/nomad';
import { canonizeId } from '@nomad-xyz/sdk/utils';
import { CoreConfig } from '../core/CoreDeploy';
import { writeBatchOutput } from './utils';
import { CoreDeploy } from '../../core/CoreDeploy';
import { executeBatch } from '../';

/**
* Prepares and executes necessary calls to governing
* router for enrolling a spoke after core and
* bridge have been deployed
* @param sdk SDK containing new spoke domain
* @param spokeDomain domain of the spoke
* @param watchers set of watchers to be enrolled
* @param spokeDeploy the spoke CoreDeploy
*/
export async function enrollSpoke(
sdk: NomadContext,
spokeDomain: number,
spokeConfig: CoreConfig,
spokeDeploy: CoreDeploy,
): Promise<void> {
let hubCore = await sdk.governorCore();
let hubBridge = sdk.mustGetBridge(hubCore.domain);

const { domain: spokeDomain, name } = spokeDeploy.chain;
const { watchers, environment } = spokeDeploy.config;
let spokeCore = await sdk.mustGetCore(spokeDomain);
let spokeBridge = await sdk.mustGetBridge(spokeDomain);
let batch = await hubCore.newGovernanceBatch();
let batch = await CallBatch.fromContext(sdk);

// enroll watchers
await Promise.all(
spokeConfig.watchers.map(async (watcher) => {
watchers.map(async (watcher) => {
const call =
await hubCore.xAppConnectionManager.populateTransaction.setWatcherPermission(
watcher,
Expand Down Expand Up @@ -58,25 +59,6 @@ export async function enrollSpoke(
canonizeId(spokeBridge.bridgeRouter.address),
);
batch.pushLocal(enrollBridgeCall);

if (spokeConfig.environment === 'dev') {
// in dev, execute the batch directly
console.log('Sending governance transaction...');
const txResponse = await batch.execute();
const receipt = await txResponse.wait();
console.log('Governance tx mined!! ', receipt.transactionHash);
} else {
// in staging and prod, output batch to a file
const built = await batch.build();
const unbuiltStr = JSON.stringify(
{ local: batch.local, remote: batch.remote },
null,
2,
);
const builtStr = JSON.stringify(built, null, 2);
console.log('Writing governance transaction to file');
writeBatchOutput(builtStr, unbuiltStr, spokeConfig.environment);
console.log('Done!');
// TODO: send to gnosis safe directly
}
// execute the call batch
await executeBatch(batch, environment, `enroll-${name}`);
}
3 changes: 1 addition & 2 deletions typescript/nomad-deploy/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
export * as core from './core';
export * as bridge from './bridge';
export * as incremental from './incremental';

export * as governance from './governance';
export * as incremental from './governance/enrollChain';
export * as deploy from './deploy';
export * as chain from './chain';
export * as contracts from './contracts';
Expand Down
1 change: 0 additions & 1 deletion typescript/nomad-deploy/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"./src/core/*.ts",
"./src/bridge/*.ts",
"./src/verification/*.ts",
"./src/incremental/*.ts",
"./src/governance/**/*.ts"
]
}

0 comments on commit 5212e12

Please sign in to comment.