Skip to content

Commit

Permalink
🧹 Reintroduce strict mode for typescript in ua-devtools (#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
janjakubnanista authored Jan 3, 2024
1 parent 8ac903c commit 793b0e6
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 34 deletions.
5 changes: 5 additions & 0 deletions .changeset/few-foxes-rush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@layerzerolabs/ua-devtools-evm-hardhat": patch
---

Reintroduce strict mode and relax some of the return types as a consequence
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ export const getDefaultConfig: ActionType<TaskArgs> = async (taskArgs) => {
configs[localNetworkName] = {}
for (const remoteNetworkName of networks) {
if (remoteNetworkName === localNetworkName) continue
const [sendLibrary, sendUlnConfig, sendExecutorConfig] = await getSendConfig(
localNetworkName,
remoteNetworkName
)
const [receiveLibrary, receiveUlnConfig] = await getReceiveConfig(localNetworkName, remoteNetworkName)

configs[localNetworkName][remoteNetworkName] = {
const receiveConfig = await getReceiveConfig(localNetworkName, remoteNetworkName)
const sendConfig = await getSendConfig(localNetworkName, remoteNetworkName)

const [sendLibrary, sendUlnConfig, sendExecutorConfig] = sendConfig ?? []
const [receiveLibrary, receiveUlnConfig] = receiveConfig ?? []

configs[localNetworkName]![remoteNetworkName] = {
defaultSendLibrary: sendLibrary,
defaultReceiveLibrary: receiveLibrary,
sendUlnConfig,
Expand Down
18 changes: 7 additions & 11 deletions packages/ua-devtools-evm-hardhat/src/tasks/oapp/getOAppConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,14 @@ export const getOAppConfig: ActionType<TaskArgs> = async (taskArgs) => {
configs[localNetworkName] = {}
for (const remoteNetworkName of networks) {
if (remoteNetworkName === localNetworkName) continue
const [sendLibrary, sendUlnConfig, sendExecutorConfig] = await getSendConfig(
localNetworkName,
remoteNetworkName,
addresses[index]
)
const [receiveLibrary, receiveUlnConfig] = await getReceiveConfig(
localNetworkName,
remoteNetworkName,
addresses[index]
)

configs[localNetworkName][remoteNetworkName] = {
const receiveConfig = await getReceiveConfig(localNetworkName, remoteNetworkName, addresses[index])
const sendConfig = await getSendConfig(localNetworkName, remoteNetworkName, addresses[index])

const [sendLibrary, sendUlnConfig, sendExecutorConfig] = sendConfig ?? []
const [receiveLibrary, receiveUlnConfig] = receiveConfig ?? []

configs[localNetworkName]![remoteNetworkName] = {
defaultSendLibrary: sendLibrary,
defaultReceiveLibrary: receiveLibrary,
sendUlnConfig,
Expand Down
28 changes: 14 additions & 14 deletions packages/ua-devtools-evm-hardhat/src/utils/taskHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export async function getSendConfig(
localNetworkName: string,
remoteNetworkName: string,
address?: Address
): Promise<[Address, Uln302UlnConfig, Uln302ExecutorConfig]> {
): Promise<[Address, Uln302UlnConfig, Uln302ExecutorConfig] | undefined> {
const localEid = getEidForNetworkName(localNetworkName)
const remoteEid = getEidForNetworkName(remoteNetworkName)
const contractFactory = createConnectedContractFactory()
Expand All @@ -16,12 +16,12 @@ export async function getSendConfig(
const localEndpointSDK = await endpointFactory({ eid: localEid, contractName: 'EndpointV2' })

// First we get the SDK for the local send library
let sendLibrary: Address
if (address) {
sendLibrary = await localEndpointSDK.getSendLibrary(address, remoteEid)
} else {
sendLibrary = await localEndpointSDK.getDefaultSendLibrary(remoteEid)
}
const sendLibrary =
address == null
? await localEndpointSDK.getDefaultSendLibrary(remoteEid)
: await localEndpointSDK.getSendLibrary(address, remoteEid)

if (sendLibrary == null) return undefined

const localSendUlnSDK = await localEndpointSDK.getUln302SDK(sendLibrary)
const sendUlnConfig = await localSendUlnSDK.getUlnConfig(remoteEid)
Expand All @@ -34,7 +34,7 @@ export async function getReceiveConfig(
localNetworkName: string,
remoteNetworkName: string,
address?: Address
): Promise<[Address, Uln302UlnConfig, Timeout]> {
): Promise<[Address, Uln302UlnConfig, Timeout] | undefined> {
const localEid = getEidForNetworkName(localNetworkName)
const remoteEid = getEidForNetworkName(remoteNetworkName)
const contractFactory = createConnectedContractFactory()
Expand All @@ -43,12 +43,12 @@ export async function getReceiveConfig(
const localEndpointSDK = await endpointFactory({ eid: localEid, contractName: 'EndpointV2' })

// First we get the SDK for the local send library
let receiveLibrary: Address
if (address) {
receiveLibrary = (await localEndpointSDK.getReceiveLibrary(address, remoteEid))[0]
} else {
receiveLibrary = await localEndpointSDK.getDefaultReceiveLibrary(remoteEid)
}
const receiveLibrary =
address == null
? await localEndpointSDK.getDefaultReceiveLibrary(remoteEid)
: await localEndpointSDK.getReceiveLibrary(address, remoteEid).then(([address]) => address)

if (receiveLibrary == null) return undefined

let receiveLibraryTimeout: Timeout
if (address) {
Expand Down
3 changes: 0 additions & 3 deletions packages/ua-devtools-evm-hardhat/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
"extends": "../../tsconfig.json",
"exclude": ["dist", "node_modules"],
"compilerOptions": {
"noImplicitReturns": false,
"strictNullChecks": false,
"strictPropertyInitialization": false,
"types": ["node", "jest"],
"paths": {
"@/*": ["./src/*"]
Expand Down

0 comments on commit 793b0e6

Please sign in to comment.