-
Notifications
You must be signed in to change notification settings - Fork 413
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
19 changed files
with
1,983 additions
and
46 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
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
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
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export const FUSES = { | ||
CAN_DO_EVERYTHING: 0, | ||
CANNOT_UNWRAP: 1, | ||
CANNOT_BURN_FUSES: 2, | ||
CANNOT_TRANSFER: 4, | ||
CANNOT_SET_RESOLVER: 8, | ||
CANNOT_SET_TTL: 16, | ||
CANNOT_CREATE_SUBDOMAIN: 32, | ||
CANNOT_APPROVE: 64, | ||
PARENT_CANNOT_CONTROL: 2 ** 16, | ||
IS_DOT_ETH: 2 ** 17, | ||
CAN_EXTEND_EXPIRY: 2 ** 18, | ||
} as const | ||
|
||
export const DAY = 24n * 60n * 60n |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { hexToBigInt, labelhash, namehash, type Hex } from 'viem' | ||
|
||
export const toTokenId = (hash: Hex) => hexToBigInt(hash) | ||
export const toLabelId = (label: string) => toTokenId(labelhash(label)) | ||
export const toNameId = (name: string) => toTokenId(namehash(name)) |
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { loadFixture } from '@nomicfoundation/hardhat-toolbox-viem/network-helpers.js' | ||
import { expect } from 'chai' | ||
import hre from 'hardhat' | ||
|
||
async function fixture() { | ||
const accounts = await hre.viem | ||
.getWalletClients() | ||
.then((clients) => clients.map((c) => c.account)) | ||
const erc20Recoverable = await hre.viem.deployContract('ERC20Recoverable', []) | ||
const erc20Token = await hre.viem.deployContract('MockERC20', [ | ||
'Ethereum Name Service Token', | ||
'ENS', | ||
[], | ||
]) | ||
|
||
return { erc20Recoverable, erc20Token, accounts } | ||
} | ||
|
||
describe('ERC20Recoverable', () => { | ||
it('should recover ERC20 token', async () => { | ||
const { erc20Recoverable, erc20Token, accounts } = await loadFixture( | ||
fixture, | ||
) | ||
|
||
await erc20Token.write.transfer([erc20Recoverable.address, 1000n]) | ||
await expect( | ||
erc20Token.read.balanceOf([erc20Recoverable.address]), | ||
).resolves.toEqual(1000n) | ||
|
||
await erc20Recoverable.write.recoverFunds([ | ||
erc20Token.address, | ||
accounts[0].address, | ||
1000n, | ||
]) | ||
await expect( | ||
erc20Token.read.balanceOf([erc20Recoverable.address]), | ||
).resolves.toEqual(0n) | ||
}) | ||
|
||
it('should not allow non-owner to call', async () => { | ||
const { erc20Recoverable, erc20Token, accounts } = await loadFixture( | ||
fixture, | ||
) | ||
|
||
await erc20Token.write.transfer([erc20Recoverable.address, 1000n]) | ||
await expect( | ||
erc20Token.read.balanceOf([erc20Recoverable.address]), | ||
).resolves.toEqual(1000n) | ||
|
||
await expect(erc20Recoverable) | ||
.write('recoverFunds', [erc20Token.address, accounts[1].address, 1000n], { | ||
account: accounts[1], | ||
}) | ||
.toBeRevertedWithString('Ownable: caller is not the owner') | ||
}) | ||
}) |
Oops, something went wrong.