This repository has been archived by the owner on May 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
15006c8
commit 47baae6
Showing
5 changed files
with
163 additions
and
67 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { NomadContext } from '@nomad-xyz/sdk'; | ||
import { CallBatch } from '@nomad-xyz/sdk/nomad'; | ||
import { getBatch, writeBatch } from './utils'; | ||
import { DeployEnvironment } from '../chain'; | ||
|
||
// execute a batch on the Governor Chain | ||
export async function executeBatch( | ||
batch: CallBatch, | ||
environment: DeployEnvironment, | ||
reason: string, | ||
): Promise<void> { | ||
// persist the call batch to a local file | ||
await writeBatch(batch, environment, reason); | ||
// send the batch transaction, | ||
// either directly on-chain or to gnosis safe | ||
if (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 { | ||
// TODO: send to gnosis safe directly | ||
} | ||
} | ||
|
||
// execute the remote Call Batches on each non-Governor chain | ||
export async function executeRemoteBatches( | ||
sdk: NomadContext, | ||
environment: string, | ||
reason: string, | ||
) { | ||
const batch = await getBatch(sdk, environment, reason); | ||
// ensure that all batch hashes have landed on each remote domain | ||
await batch.waitAll(); | ||
console.log('All Batch Hashes Ready.'); | ||
// for each domain, execute the batch calls | ||
for (const domain of batch.domains) { | ||
const domainName = sdk.resolveDomainName(domain); | ||
console.log(`Executing Batch on ${domainName}...`); | ||
const tx = await batch.executeDomain(domain); | ||
const receipt = await tx.wait(); | ||
console.log(`Executed Batch on ${domainName}:`, receipt.transactionHash); | ||
} | ||
} | ||
|
||
// log the progress of batches on all domains | ||
export async function waitBatches( | ||
sdk: NomadContext, | ||
environment: string, | ||
reason: string, | ||
): Promise<void[]> { | ||
const batch = await getBatch(sdk, environment, reason); | ||
return Promise.all( | ||
batch.domains.map(async (domain: number) => { | ||
const domainName = sdk.resolveDomainName(domain); | ||
console.log(`Waiting for batch to be received on ${domainName}...`); | ||
await batch.waitDomain(domain); | ||
console.log(`Batch received on ${domainName}!`); | ||
}), | ||
); | ||
} |
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 |
---|---|---|
|
@@ -16,5 +16,6 @@ | |
"./src/bridge/*.ts", | ||
"./src/verification/*.ts", | ||
"./src/incremental/*.ts", | ||
"./src/governance/**/*.ts" | ||
] | ||
} |