-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
243 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,51 @@ | ||
import getPrice from '../../functions/public/getPrice.js' | ||
import commitName from '../../functions/wallet/commitName.js' | ||
import registerName from '../../functions/wallet/registerName.js' | ||
import { waitForTransaction } from '../addTestContracts.js' | ||
import { walletClient } from '../addTestContracts.js' | ||
import { publicClient } from '../addTestContracts.js' | ||
import { testClient } from '../addTestContracts.js' | ||
import type { RegistrationParameters } from '../../utils/registerHelpers.js' | ||
import { | ||
publicClient, | ||
testClient, | ||
waitForTransaction, | ||
walletClient, | ||
} from '../addTestContracts.js' | ||
|
||
// const accounts = await walletClient.getAddresses() | ||
// type accountType = typeof accounts[0] | ||
export const commitAndRegisterName = async (params: RegistrationParameters, account: any): Promise<string> => { | ||
const commitTx = await commitName(walletClient, { | ||
...params, | ||
account: account, | ||
}) | ||
expect(commitTx).toBeTruthy() | ||
const commitReceipt = await waitForTransaction(commitTx) | ||
|
||
expect(commitReceipt.status).toBe('success') | ||
|
||
await testClient.increaseTime({ seconds: 61 }) | ||
await testClient.mine({ blocks: 1 }) | ||
|
||
const price = await getPrice(publicClient, { | ||
nameOrNames: params.name, | ||
duration: params.duration, | ||
}) | ||
const total = price!.base + price!.premium | ||
|
||
const tx = await registerName(walletClient, { | ||
...params, | ||
account: account, | ||
value: total, | ||
}) | ||
expect(tx).toBeTruthy() | ||
const receipt = await waitForTransaction(tx) | ||
expect(receipt.status).toBe('success') | ||
export const commitAndRegisterName = async ( | ||
params: RegistrationParameters, | ||
account: any, | ||
): Promise<string> => { | ||
const commitTx = await commitName(walletClient, { | ||
...params, | ||
account, | ||
}) | ||
expect(commitTx).toBeTruthy() | ||
const commitReceipt = await waitForTransaction(commitTx) | ||
|
||
return tx | ||
} | ||
expect(commitReceipt.status).toBe('success') | ||
|
||
await testClient.increaseTime({ seconds: 61 }) | ||
await testClient.mine({ blocks: 1 }) | ||
|
||
const price = await getPrice(publicClient, { | ||
nameOrNames: params.name, | ||
duration: params.duration, | ||
}) | ||
const total = price!.base + price!.premium | ||
|
||
const tx = await registerName(walletClient, { | ||
...params, | ||
account, | ||
value: total, | ||
}) | ||
expect(tx).toBeTruthy() | ||
const receipt = await waitForTransaction(tx) | ||
expect(receipt.status).toBe('success') | ||
|
||
return tx | ||
} | ||
|
||
export const wait = (ms: number) => | ||
new Promise((resolve) => { | ||
setTimeout(resolve, ms) | ||
}) |
Oops, something went wrong.