Eliminates redundant `await`s. (#98)

* Eliminates redundant `await`s.

* Adds a couple of missing `await`s.
This commit is contained in:
scnale 2023-02-21 18:17:39 -03:00 committed by GitHub
parent eb531a9105
commit a1df44b3ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 44 deletions

View File

@ -30,10 +30,9 @@ export async function deployRelayProviderImplementation(
//@ts-ignore //@ts-ignore
const factory = new ethers.ContractFactory(contractInterface, bytecode, signer) const factory = new ethers.ContractFactory(contractInterface, bytecode, signer)
const contract = await factory.deploy() const contract = await factory.deploy()
return await contract.deployed().then((result) => { const result = await contract.deployed()
console.log("Successfully deployed contract at " + result.address) console.log("Successfully deployed contract at " + result.address)
return { address: result.address, chainId: chain.chainId } return { address: result.address, chainId: chain.chainId }
})
} }
export async function deployRelayProviderSetup(chain: ChainInfo): Promise<Deployment> { export async function deployRelayProviderSetup(chain: ChainInfo): Promise<Deployment> {
@ -44,10 +43,9 @@ export async function deployRelayProviderSetup(chain: ChainInfo): Promise<Deploy
//@ts-ignore //@ts-ignore
const factory = new ethers.ContractFactory(contractInterface, bytecode, signer) const factory = new ethers.ContractFactory(contractInterface, bytecode, signer)
const contract = await factory.deploy() const contract = await factory.deploy()
return await contract.deployed().then((result) => { const result = await contract.deployed()
console.log("Successfully deployed contract at " + result.address) console.log("Successfully deployed contract at " + result.address)
return { address: result.address, chainId: chain.chainId } return { address: result.address, chainId: chain.chainId }
})
} }
export async function deployRelayProviderProxy( export async function deployRelayProviderProxy(
chain: ChainInfo, chain: ChainInfo,
@ -70,10 +68,9 @@ export async function deployRelayProviderProxy(
]) ])
const contract = await factory.deploy(relayProviderSetupAddress, encodedData) const contract = await factory.deploy(relayProviderSetupAddress, encodedData)
return await contract.deployed().then((result) => { const result = await contract.deployed()
console.log("Successfully deployed contract at " + result.address) console.log("Successfully deployed contract at " + result.address)
return { address: result.address, chainId: chain.chainId } return { address: result.address, chainId: chain.chainId }
})
} }
export async function deployMockIntegration(chain: ChainInfo): Promise<Deployment> { export async function deployMockIntegration(chain: ChainInfo): Promise<Deployment> {
@ -87,10 +84,9 @@ export async function deployMockIntegration(chain: ChainInfo): Promise<Deploymen
chain.wormholeAddress, chain.wormholeAddress,
getCoreRelayerAddress(chain) getCoreRelayerAddress(chain)
) )
return await contract.deployed().then((result) => { const result = await contract.deployed()
console.log("Successfully deployed contract at " + result.address) console.log("Successfully deployed contract at " + result.address)
return { address: result.address, chainId: chain.chainId } return { address: result.address, chainId: chain.chainId }
})
} }
export async function deployCoreRelayerLibrary(chain: ChainInfo): Promise<Deployment> { export async function deployCoreRelayerLibrary(chain: ChainInfo): Promise<Deployment> {
@ -101,10 +97,9 @@ export async function deployCoreRelayerLibrary(chain: ChainInfo): Promise<Deploy
const bytecode = CoreRelayerLibrary__factory.bytecode const bytecode = CoreRelayerLibrary__factory.bytecode
const factory = new ethers.ContractFactory(contractInterface, bytecode, signer) const factory = new ethers.ContractFactory(contractInterface, bytecode, signer)
const contract = await factory.deploy() const contract = await factory.deploy()
return await contract.deployed().then((result) => { const result = await contract.deployed()
console.log("Successfully deployed contract at " + result.address) console.log("Successfully deployed contract at " + result.address)
return { address: result.address, chainId: chain.chainId } return { address: result.address, chainId: chain.chainId }
})
} }
export async function deployCoreRelayerImplementation( export async function deployCoreRelayerImplementation(
@ -135,10 +130,9 @@ export async function deployCoreRelayerImplementation(
signer signer
) )
const contract = await factory.deploy() const contract = await factory.deploy()
return await contract.deployed().then((result) => { const result = await contract.deployed()
console.log("Successfully deployed contract at " + result.address) console.log("Successfully deployed contract at " + result.address)
return { address: result.address, chainId: chain.chainId } return { address: result.address, chainId: chain.chainId }
})
} }
export async function deployCoreRelayerSetup(chain: ChainInfo): Promise<Deployment> { export async function deployCoreRelayerSetup(chain: ChainInfo): Promise<Deployment> {
console.log("deployCoreRelayerSetup " + chain.chainId) console.log("deployCoreRelayerSetup " + chain.chainId)
@ -148,10 +142,9 @@ export async function deployCoreRelayerSetup(chain: ChainInfo): Promise<Deployme
//@ts-ignore //@ts-ignore
const factory = new ethers.ContractFactory(contractInterface, bytecode, signer) const factory = new ethers.ContractFactory(contractInterface, bytecode, signer)
const contract = await factory.deploy() const contract = await factory.deploy()
return await contract.deployed().then((result) => { const result = await contract.deployed()
console.log("Successfully deployed contract at " + result.address) console.log("Successfully deployed contract at " + result.address)
return { address: result.address, chainId: chain.chainId } return { address: result.address, chainId: chain.chainId }
})
} }
export async function deployCoreRelayerProxy( export async function deployCoreRelayerProxy(
chain: ChainInfo, chain: ChainInfo,
@ -184,10 +177,9 @@ export async function deployCoreRelayerProxy(
]) ])
const contract = await factory.deploy(coreRelayerSetupAddress, encodedData) const contract = await factory.deploy(coreRelayerSetupAddress, encodedData)
return await contract.deployed().then((result) => { const result = await contract.deployed()
console.log("Successfully deployed contract at " + result.address) console.log("Successfully deployed contract at " + result.address)
return { address: result.address, chainId: chain.chainId } return { address: result.address, chainId: chain.chainId }
})
} }
function link(bytecode: string, libName: String, libAddress: string) { function link(bytecode: string, libName: String, libAddress: string) {
//This doesn't handle the libName, because Forge embed a psuedonym into the bytecode, like //This doesn't handle the libName, because Forge embed a psuedonym into the bytecode, like

View File

@ -154,10 +154,10 @@ export async function encodeEmitterAddress(
emitterAddressStr: string emitterAddressStr: string
): Promise<string> { ): Promise<string> {
if (myChainId === wh.CHAIN_ID_SOLANA || myChainId === wh.CHAIN_ID_PYTHNET) { if (myChainId === wh.CHAIN_ID_SOLANA || myChainId === wh.CHAIN_ID_PYTHNET) {
return await wh.getEmitterAddressSolana(emitterAddressStr) return wh.getEmitterAddressSolana(emitterAddressStr)
} }
if (wh.isTerraChain(myChainId)) { if (wh.isTerraChain(myChainId)) {
return await wh.getEmitterAddressTerra(emitterAddressStr) return wh.getEmitterAddressTerra(emitterAddressStr)
} }
if (wh.isEVMChain(myChainId)) { if (wh.isEVMChain(myChainId)) {
return wh.getEmitterAddressEth(emitterAddressStr) return wh.getEmitterAddressEth(emitterAddressStr)

View File

@ -442,18 +442,18 @@ export class GenericRelayerPlugin implements Plugin<WorkflowPayload> {
(log) => log.args.sequence.toString() === sequence.toString() (log) => log.args.sequence.toString() === sequence.toString()
) )
if (log) { if (log) {
return await log.getTransactionReceipt() return log.getTransactionReceipt()
} }
} }
try { try {
return await retryAsyncUntilDefined( return retryAsyncUntilDefined(
async () => { async () => {
const paginatedLogs = await coreWHContract.queryFilter(filter, -50) const paginatedLogs = await coreWHContract.queryFilter(filter, -50)
const log = paginatedLogs.find( const log = paginatedLogs.find(
(log) => log.args.sequence.toString() === sequence.toString() (log) => log.args.sequence.toString() === sequence.toString()
) )
if (log) { if (log) {
return await log.getTransactionReceipt() return log.getTransactionReceipt()
} }
return undefined return undefined
}, },
@ -517,14 +517,13 @@ export class GenericRelayerPlugin implements Plugin<WorkflowPayload> {
const payload = this.parseWorkflowPayload(workflow) const payload = this.parseWorkflowPayload(workflow)
switch (payload.payloadId) { switch (payload.payloadId) {
case RelayerPayloadId.Delivery: case RelayerPayloadId.Delivery:
if(payload.deliveryInstructionsContainer.sufficientlyFunded) { if (payload.deliveryInstructionsContainer.sufficientlyFunded) {
return this.handleDeliveryWorkflow(payload, execute)
return await this.handleDeliveryWorkflow(payload, execute)
} }
this.logger.info("Delivery instruction is not sufficiently funded") this.logger.info("Delivery instruction is not sufficiently funded")
return return
case RelayerPayloadId.Redelivery: case RelayerPayloadId.Redelivery:
return await this.handleRedeliveryWorkflow(payload, execute) return this.handleRedeliveryWorkflow(payload, execute)
} }
} }
@ -560,7 +559,7 @@ export class GenericRelayerPlugin implements Plugin<WorkflowPayload> {
return return
} }
relayProvider await relayProvider
.deliverSingle(input, { value: budget, gasLimit: 3000000 }) .deliverSingle(input, { value: budget, gasLimit: 3000000 })
.then((x) => x.wait()) .then((x) => x.wait())
@ -604,7 +603,7 @@ export class GenericRelayerPlugin implements Plugin<WorkflowPayload> {
relayerRefundAddress: wallet.address, relayerRefundAddress: wallet.address,
} }
relayProvider await relayProvider
.redeliverSingle(input, { value: budget, gasLimit: 3000000 }) .redeliverSingle(input, { value: budget, gasLimit: 3000000 })
.then((x) => x.wait()) .then((x) => x.wait())