1
+ import { selectors } from '@boostxyz/signatures/events' ;
1
2
import {
2
3
loadFixture ,
3
- reset ,
4
+ mine ,
4
5
} from '@nomicfoundation/hardhat-toolbox-viem/network-helpers' ;
5
- import { type Address , type Hex , parseEther } from 'viem' ;
6
+ import hre from 'hardhat' ;
7
+ import {
8
+ type Address ,
9
+ type Hex ,
10
+ type PublicClient ,
11
+ type WalletClient ,
12
+ parseEther ,
13
+ } from 'viem' ;
6
14
import { beforeAll , beforeEach , describe , expect , test , vi } from 'vitest' ;
7
15
import { BoostCore } from '../src/BoostCore' ;
8
16
import {
@@ -19,53 +27,66 @@ import {
19
27
deployFixtures ,
20
28
fundBudget ,
21
29
} from './helpers' ;
30
+ import { setupConfig , testAccount } from './viem' ;
22
31
23
32
let fixtures : Fixtures , budgets : BudgetFixtures ;
24
33
25
34
describe ( 'Boost with NFT Minting Incentive' , ( ) => {
26
- const ZORA_CHAIN_URL = process . env . VITE_BASE_MAINNET_RPC ;
27
- const ZORA_CHAIN_BLOCK = 19694536 ; // Replace with actual block number
35
+ // We take the address of the imposter from the transaction above
36
+ const boostImpostor = '0xE59C9Ca7FFA00471AA2ADA42C0a65C6CaabD06B8' as Address ;
28
37
38
+ const selector = selectors [
39
+ 'Purchased(address,address,uint256,uint256,uint256)'
40
+ ] as Hex ;
29
41
beforeAll ( async ( ) => {
30
- await reset ( ZORA_CHAIN_URL , ZORA_CHAIN_BLOCK ) ;
42
+ // await reset(BASE_CHAIN_URL, BASE_CHAIN_BLOCK );
31
43
fixtures = await loadFixture ( deployFixtures ) ;
32
44
} ) ;
45
+
33
46
beforeEach ( async ( ) => {
34
47
budgets = await loadFixture ( fundBudget ( defaultOptions , fixtures ) ) ;
35
48
} ) ;
36
49
37
50
test ( 'should create a boost for incentivizing NFT minting' , async ( ) => {
38
51
const { budget, erc20 } = budgets ;
39
52
const targetContract = '0xDa8dD2807A33FDA5983F56812765a88B46f0B90B' ;
53
+ const walletClient = await hre . viem . getWalletClient ( testAccount . address ) ;
40
54
55
+ // This is the zora contract we're going to push a transaction against
56
+ //const contractEntryPoint = '0x9D2FC5fFE5939Efd1d573f975BC5EEFd364779ae';
41
57
const { core, bases } = fixtures ;
42
58
const client = new BoostCore ( {
43
- ...defaultOptions ,
59
+ // biome-ignore lint/suspicious/noExplicitAny: The hardhat and wagmi wallet clients are compatible
60
+ config : setupConfig ( walletClient as any ) ,
61
+ account : testAccount ,
44
62
address : core . assertValidAddress ( ) ,
45
63
} ) ;
46
64
const owner = defaultOptions . account . address ;
65
+ // This is a workaround to this known issue: https://github.com/NomicFoundation/hardhat/issues/5511
66
+ await mine ( ) ;
47
67
48
68
// Step defining the action for Transfer event
49
69
const eventActionStep : ActionStep = {
50
- signature : '0xddf252ad' , // Transfer(address,address,uint256) event signature
70
+ signature : selector , // Transfer(address,address,uint256) event signature
51
71
signatureType : SignatureType . EVENT , // We're working with an event
52
72
actionType : 0 , // Custom action type (set as 0 for now)
53
73
targetContract : targetContract , // Address of the ERC20 contract
74
+ // We want to target the Minter property on the Purchase event
54
75
actionParameter : {
55
76
filterType : FilterType . EQUAL , // Filter to check for equality
56
77
fieldType : PrimitiveType . ADDRESS , // The field we're filtering is an address
57
- fieldIndex : 0 , // Field 0 is the 'from' address in the event
58
- filterData : targetContract , // Filtering based on the core address
78
+ fieldIndex : 1 , // Might need to be 2, we'll see - let's log this
79
+ filterData : boostImpostor , // Filtering based on the core address
59
80
} ,
60
81
} ;
61
82
62
83
// Define EventActionPayload manually
63
84
const eventActionPayload = {
64
85
actionClaimant : {
65
86
signatureType : SignatureType . EVENT ,
66
- signature : '0xddf252ad' as Hex , // Transfer(address,address,uint256) event signature
87
+ signature : selector , // Transfer(address,address,uint256) event signature
67
88
fieldIndex : 0 , // Targeting the 'from' address
68
- targetContract : targetContract as Address , // The ERC20 contract we're monitoring
89
+ targetContract : boostImpostor , // The ERC20 contract we're monitoring
69
90
} ,
70
91
actionStepOne : eventActionStep , // Use the custom step for action
71
92
actionStepTwo : eventActionStep , // Repeat the action step if necessary
@@ -79,11 +100,6 @@ describe('Boost with NFT Minting Incentive', () => {
79
100
eventActionPayload ,
80
101
) ;
81
102
82
- console . log ( 'Creating boost with EventAction' ) ;
83
- console . log ( 'owner:' , owner ) ;
84
- console . log ( 'budget:' , budget ) ;
85
- console . log ( 'eventAction:' , eventAction ) ;
86
- console . log ( 'erc20:' , erc20 ) ;
87
103
// Create the boost using the custom EventAction
88
104
await client . createBoost ( {
89
105
protocolFee : 1n ,
0 commit comments