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
const factory = new ethers.ContractFactory(contractInterface, bytecode, signer)
const contract = await factory.deploy()
return await contract.deployed().then((result) => {
console.log("Successfully deployed contract at " + result.address)
return { address: result.address, chainId: chain.chainId }
})
const result = await contract.deployed()
console.log("Successfully deployed contract at " + result.address)
return { address: result.address, chainId: chain.chainId }
}
export async function deployRelayProviderSetup(chain: ChainInfo): Promise<Deployment> {
@ -44,10 +43,9 @@ export async function deployRelayProviderSetup(chain: ChainInfo): Promise<Deploy
//@ts-ignore
const factory = new ethers.ContractFactory(contractInterface, bytecode, signer)
const contract = await factory.deploy()
return await contract.deployed().then((result) => {
console.log("Successfully deployed contract at " + result.address)
return { address: result.address, chainId: chain.chainId }
})
const result = await contract.deployed()
console.log("Successfully deployed contract at " + result.address)
return { address: result.address, chainId: chain.chainId }
}
export async function deployRelayProviderProxy(
chain: ChainInfo,
@ -70,10 +68,9 @@ export async function deployRelayProviderProxy(
])
const contract = await factory.deploy(relayProviderSetupAddress, encodedData)
return await contract.deployed().then((result) => {
console.log("Successfully deployed contract at " + result.address)
return { address: result.address, chainId: chain.chainId }
})
const result = await contract.deployed()
console.log("Successfully deployed contract at " + result.address)
return { address: result.address, chainId: chain.chainId }
}
export async function deployMockIntegration(chain: ChainInfo): Promise<Deployment> {
@ -87,10 +84,9 @@ export async function deployMockIntegration(chain: ChainInfo): Promise<Deploymen
chain.wormholeAddress,
getCoreRelayerAddress(chain)
)
return await contract.deployed().then((result) => {
console.log("Successfully deployed contract at " + result.address)
return { address: result.address, chainId: chain.chainId }
})
const result = await contract.deployed()
console.log("Successfully deployed contract at " + result.address)
return { address: result.address, chainId: chain.chainId }
}
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 factory = new ethers.ContractFactory(contractInterface, bytecode, signer)
const contract = await factory.deploy()
return await contract.deployed().then((result) => {
console.log("Successfully deployed contract at " + result.address)
return { address: result.address, chainId: chain.chainId }
})
const result = await contract.deployed()
console.log("Successfully deployed contract at " + result.address)
return { address: result.address, chainId: chain.chainId }
}
export async function deployCoreRelayerImplementation(
@ -135,10 +130,9 @@ export async function deployCoreRelayerImplementation(
signer
)
const contract = await factory.deploy()
return await contract.deployed().then((result) => {
console.log("Successfully deployed contract at " + result.address)
return { address: result.address, chainId: chain.chainId }
})
const result = await contract.deployed()
console.log("Successfully deployed contract at " + result.address)
return { address: result.address, chainId: chain.chainId }
}
export async function deployCoreRelayerSetup(chain: ChainInfo): Promise<Deployment> {
console.log("deployCoreRelayerSetup " + chain.chainId)
@ -148,10 +142,9 @@ export async function deployCoreRelayerSetup(chain: ChainInfo): Promise<Deployme
//@ts-ignore
const factory = new ethers.ContractFactory(contractInterface, bytecode, signer)
const contract = await factory.deploy()
return await contract.deployed().then((result) => {
console.log("Successfully deployed contract at " + result.address)
return { address: result.address, chainId: chain.chainId }
})
const result = await contract.deployed()
console.log("Successfully deployed contract at " + result.address)
return { address: result.address, chainId: chain.chainId }
}
export async function deployCoreRelayerProxy(
chain: ChainInfo,
@ -184,10 +177,9 @@ export async function deployCoreRelayerProxy(
])
const contract = await factory.deploy(coreRelayerSetupAddress, encodedData)
return await contract.deployed().then((result) => {
console.log("Successfully deployed contract at " + result.address)
return { address: result.address, chainId: chain.chainId }
})
const result = await contract.deployed()
console.log("Successfully deployed contract at " + result.address)
return { address: result.address, chainId: chain.chainId }
}
function link(bytecode: string, libName: String, libAddress: string) {
//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
): Promise<string> {
if (myChainId === wh.CHAIN_ID_SOLANA || myChainId === wh.CHAIN_ID_PYTHNET) {
return await wh.getEmitterAddressSolana(emitterAddressStr)
return wh.getEmitterAddressSolana(emitterAddressStr)
}
if (wh.isTerraChain(myChainId)) {
return await wh.getEmitterAddressTerra(emitterAddressStr)
return wh.getEmitterAddressTerra(emitterAddressStr)
}
if (wh.isEVMChain(myChainId)) {
return wh.getEmitterAddressEth(emitterAddressStr)

View File

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