Skip to content

Commit

Permalink
✨ feat(core): Add walletPassword to defineWalletSetup (#959)
Browse files Browse the repository at this point in the history
  • Loading branch information
duckception authored Oct 26, 2023
1 parent e0189fb commit b574923
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions packages/core/src/defineWalletSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import { getWalletSetupFuncHash } from './utils/getWalletSetupFuncHash'
export type WalletSetupFunction = (context: BrowserContext, walletPage: Page) => Promise<void>

// TODO: This runs at least twice. Should we cache it somehow?
export function defineWalletSetup(fn: WalletSetupFunction) {
export function defineWalletSetup(walletPassword: string, fn: WalletSetupFunction) {
const hash = getWalletSetupFuncHash(fn)

return {
hash,
fn
fn,
walletPassword
}
}
6 changes: 4 additions & 2 deletions packages/core/test/defineWalletSetup.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { describe, expect, it } from 'vitest'
import { defineWalletSetup } from '../src/defineWalletSetup'

const PASSWORD = 'Quack Quack! 🦆'
const EXPECTED_HASH = '69620d59802a61c6900f'

const testWalletSetupFunction = async (): Promise<void> => {
Expand All @@ -13,9 +14,10 @@ const testWalletSetupFunction = async (): Promise<void> => {
}

describe('defineWalletSetup', () => {
it('returns both hash and function', async () => {
const { hash, fn } = defineWalletSetup(testWalletSetupFunction)
it('returns hash, function and wallet password', async () => {
const { hash, fn, walletPassword } = defineWalletSetup(PASSWORD, testWalletSetupFunction)
expect(hash).toEqual(EXPECTED_HASH)
expect(fn.toString()).toEqual(testWalletSetupFunction.toString())
expect(walletPassword).toEqual(PASSWORD)
})
})

0 comments on commit b574923

Please sign in to comment.