Skip to content

Commit

Permalink
🪚 OmniGraph™ Sign transactions in wire task (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
janjakubnanista authored Dec 15, 2023
1 parent e27e39f commit f99f174
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions packages/ua-utils-evm-hardhat/src/tasks/oapp/wire.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,17 @@ import {
promptToContinue,
printJson,
pluralizeNoun,
printBoolean,
} from '@layerzerolabs/io-utils'
import { OAppOmniGraphHardhat, OAppOmniGraphHardhatSchema } from '@/oapp'
import { OAppOmniGraph, configureOApp } from '@layerzerolabs/ua-utils'
import { createOAppFactory } from '@layerzerolabs/ua-utils-evm'
import { OmniGraphBuilderHardhat, createConnectedContractFactory } from '@layerzerolabs/utils-evm-hardhat'
import { OmniTransaction } from '@layerzerolabs/utils'
import {
OmniGraphBuilderHardhat,
createConnectedContractFactory,
createSignerFactory,
} from '@layerzerolabs/utils-evm-hardhat'
import { createSignAndSend, OmniTransaction } from '@layerzerolabs/utils'
import { printTransactions } from '@layerzerolabs/utils'
import { resolve } from 'path'

Expand Down Expand Up @@ -106,6 +111,28 @@ const action: ActionType<TaskArgs> = async ({ oappConfig: oappConfigPath, logLev
: true
if (!shouldSubmit) return logger.verbose(`User cancelled the operation, exiting`), undefined

// The last step is to execute those transactions
//
// For now we are only allowing sign & send using the accounts confgiured in hardhat config
const signAndSend = createSignAndSend(createSignerFactory())

logger.verbose(`Sending the transactions`)
const results = await signAndSend(transactions)

logger.verbose(`Sent the transactions`)
logger.debug(`Received the following output:\n\n${printJson(results)}`)

// FIXME We need to check whether we got any errors and display those to the user
logger.info(
pluralizeNoun(
transactions.length,
`Successfully sent 1 transaction`,
`Successfully sent ${transactions.length} transactions`
)
)
logger.info(`${printBoolean(true)} Your OApp is now configured`)

// FIXME We need to return the results
return []
}
task(TASK_LZ_WIRE_OAPP, 'Wire LayerZero OApp')
Expand Down

0 comments on commit f99f174

Please sign in to comment.