-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADHOC] feat(sdk): add OpenAllowList as zero config extension of Simp…
…leDenyList (#112)
- Loading branch information
Showing
17 changed files
with
147 additions
and
28 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@boostxyz/sdk": minor | ||
--- | ||
|
||
add `OpenAllowList`, for zero config allow list support |
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
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,40 @@ | ||
import { loadFixture } from '@nomicfoundation/hardhat-network-helpers'; | ||
import { isAddress, zeroAddress } from 'viem'; | ||
import { beforeAll, describe, expect, test } from 'vitest'; | ||
import { accounts } from '../../test/accounts'; | ||
import { | ||
type Fixtures, | ||
defaultOptions, | ||
deployFixtures, | ||
} from '../../test/helpers'; | ||
import { OpenAllowList } from './OpenAllowList'; | ||
|
||
let fixtures: Fixtures; | ||
|
||
beforeAll(async () => { | ||
fixtures = await loadFixture(deployFixtures); | ||
}); | ||
|
||
function freshOpenAllowList(fixtures: Fixtures) { | ||
return function freshOpenAllowList() { | ||
return fixtures.registry.initialize( | ||
crypto.randomUUID(), | ||
new fixtures.bases.OpenAllowList(defaultOptions), | ||
); | ||
}; | ||
} | ||
|
||
describe('OpenAllowList', () => { | ||
test('can successfully be deployed', async () => { | ||
const denyList = new OpenAllowList(defaultOptions); | ||
await denyList.deploy(); | ||
expect(isAddress(denyList.assertValidAddress())).toBe(true); | ||
}); | ||
|
||
test('allows anyone', async () => { | ||
const denyList = await loadFixture(freshOpenAllowList(fixtures)); | ||
expect(await denyList.isAllowed(defaultOptions.account.address)).toBe(true); | ||
expect(await denyList.isAllowed(zeroAddress)).toBe(true); | ||
expect(await denyList.isAllowed(accounts.at(1)!.account)).toBe(true); | ||
}); | ||
}); |
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,45 @@ | ||
import { simpleDenyListAbi } from '@boostxyz/evm'; | ||
import { bytecode } from '@boostxyz/evm/artifacts/contracts/allowlists/SimpleDenyList.sol/SimpleDenyList.json'; | ||
import { type Hex, zeroAddress } from 'viem'; | ||
import type { | ||
DeployableOptions, | ||
GenericDeployableParams, | ||
} from '../Deployable/Deployable'; | ||
import { | ||
SimpleDenyList, | ||
type SimpleDenyListPayload, | ||
prepareSimpleDenyListPayload, | ||
} from './SimpleDenyList'; | ||
|
||
export const openAllowListAbi = simpleDenyListAbi; | ||
|
||
/** | ||
* A simple AllowList, extending {@link DenyList}, that is ownerless and allows anyone to claim. | ||
* | ||
* @export | ||
* @class OpenAllowList | ||
* @typedef {OpenAllowList} | ||
* @extends {DeployableTarget<OpenAllowListPayload>} | ||
*/ | ||
export class OpenAllowList extends SimpleDenyList<undefined> { | ||
/** | ||
* @inheritdoc | ||
* | ||
* @public | ||
* @param {?SimpleDenyListPayload} [_payload] | ||
* @param {?DeployableOptions} [_options] | ||
* @returns {GenericDeployableParams} | ||
*/ | ||
public override buildParameters( | ||
_payload?: SimpleDenyListPayload, | ||
_options?: DeployableOptions, | ||
): GenericDeployableParams { | ||
const [_, options] = this.validateDeploymentConfig({}, _options); | ||
return { | ||
abi: openAllowListAbi, | ||
bytecode: bytecode as Hex, | ||
args: [prepareSimpleDenyListPayload({ owner: zeroAddress, denied: [] })], | ||
...this.optionallyAttachAccount(options.account), | ||
}; | ||
} | ||
} |
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
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