Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ export {
getDeadmanSwitch,
getDeadmanSwitchConfig,
getDeadmanSwitchValidatorMockSignature,
getDeadmanSwitchTimeout,
getDeadmanSwitchNominee,
isDeadmanSwitchActive,
OWNABLE_EXECUTOR_ADDRESS,
getOwnableExecutor,
getAddOwnableExecutorOwnerAction,
Expand Down
3 changes: 3 additions & 0 deletions src/module/deadman-switch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ export { getDeadmanSwitch } from './installation'
export {
getDeadmanSwitchConfig,
getDeadmanSwitchValidatorMockSignature,
getDeadmanSwitchTimeout,
getDeadmanSwitchNominee,
isDeadmanSwitchActive,
} from './usage'
42 changes: 42 additions & 0 deletions src/module/deadman-switch/usage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,48 @@ export const getDeadmanSwitchConfig = async ({
}
}

export const getDeadmanSwitchTimeout = async ({
account,
client,
}: {
account: Account
client: PublicClient
}): Promise<number> => {
const [, timeout] = await getDeadmanSwitchConfig({
account,
client,
})
return timeout
}

export const getDeadmanSwitchNominee = async ({
account,
client,
}: {
account: Account
client: PublicClient
}): Promise<Address> => {
const [, , nominee] = await getDeadmanSwitchConfig({
account,
client,
})
return nominee
}

export const isDeadmanSwitchActive = async ({
account,
client,
}: {
account: Account
client: PublicClient
}): Promise<boolean> => {
const [isActive] = await getDeadmanSwitchConfig({
account,
client,
})
return isActive === 1
}

export const getDeadmanSwitchValidatorMockSignature = (): Hex => {
return '0xe8b94748580ca0b4993c9a1b86b5be851bfc076ff5ce3a1ff65bf16392acfcb800f9b4f1aef1555c7fce5599fffb17e7c635502154a0333ba21f3ae491839af51c'
}
3 changes: 3 additions & 0 deletions src/module/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ export {
getDeadmanSwitch,
getDeadmanSwitchConfig,
getDeadmanSwitchValidatorMockSignature,
getDeadmanSwitchTimeout,
getDeadmanSwitchNominee,
isDeadmanSwitchActive
} from './deadman-switch'

export {
Expand Down
3 changes: 3 additions & 0 deletions test/e2e/modules/deadmanSwitchValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,7 @@ export const testDeadmanSwitchValidator = async ({
)
expect(timeout).toEqual(deadmanSwitchValidator.timeout)
})



}
33 changes: 32 additions & 1 deletion test/unit/module/deadmanSwitch/deadmanSwitch.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { DEADMAN_SWITCH_ADDRESS, getDeadmanSwitchConfig } from 'src'
import { DEADMAN_SWITCH_ADDRESS, getDeadmanSwitchConfig, getDeadmanSwitchTimeout,
getDeadmanSwitchNominee,
isDeadmanSwitchActive } from 'src'
import { Address, zeroAddress } from 'viem'
import { getDeadmanSwitch } from 'src'
import { getClient } from 'src'
import { MockClient } from 'test/utils/mocks/client'
import { getAccount } from 'src'
import { MockAccountDeployed } from 'test/utils/mocks/account'



describe('Deadman switch Module', () => {
// Setup
const nominee = '0x0Cb7EAb54EB751579a82D80Fe2683687deb918f3' as Address
Expand Down Expand Up @@ -54,4 +58,31 @@ describe('Deadman switch Module', () => {
expect(timeout).toEqual(0)
expect(nominee).toEqual(zeroAddress)
})

it('should get deadman switch timeout', async () => {
const timeout = await getDeadmanSwitchTimeout({
account,
client,
})

expect(timeout).toEqual(0)
})

it('should get deadman switch nominee', async () => {
const nomineeAddress = await getDeadmanSwitchNominee({
account,
client,
})

expect(nomineeAddress).toEqual(zeroAddress)
})

it('should check if deadman switch is active', async () => {
const isActive = await isDeadmanSwitchActive({
account,
client,
})

expect(isActive).toEqual(false)
})
})