@@ -31,45 +31,47 @@ export const registerUpkeep = task(
3131 } : { streamsUpkeep : string ; logEmitter : string } ,
3232 hre : HardhatRuntimeEnvironment
3333 ) => {
34- // Connect to network and get wallet client
3534 const { viem } = await hre . network . connect ( ) ;
3635 const [ walletClient ] = await viem . getWalletClients ( ) ;
37- const account = walletClient . account . address ;
3836
39- // Define registration parameters for the upkeep
40- const name = "Prog. Streams Upkeep" ;
41- const encryptedEmail = "0x" as `0x${string } `;
42- const gasLimit = 500000 ;
43- const triggerType = 1 ; // Log Trigger
44- const checkData = "0x" as `0x${string } `;
45- const offchainConfig = "0x" as `0x${string } `;
46- const amount = parseEther ( "1" ) ; // 1 LINK
37+ // Retrieve the deployer's (admin's) signer object to sign transactions.
38+ const admin = walletClient . account . address ;
4739
48- // Event signature hash and placeholder topics for the LogEmitter trigger
40+ // Define registration parameters for the upkeep.
41+ // See more information on https://docs.chain.link/chainlink-automation/guides/register-upkeep-in-contract.
42+ const name = "Prog. Streams Upkeep" ; // Name of the upkeep registration.
43+ const encryptedEmail = "0x" as `0x${string } `; // Placeholder for an encrypted email (optional).
44+ const gasLimit = 500000 ; // Maximum gas allowance for the upkeep execution.
45+ const triggerType = 1 ; // Type of trigger, where `1` represents a Log Trigger.
46+ const checkData = "0x" as `0x${string } `; // Data passed to checkUpkeep; placeholder in this context.
47+ const offchainConfig = "0x" as `0x${string } `; // Off-chain configuration data; placeholder in this context.
48+ const amount = parseEther ( "1" ) ; // Funding amount in LINK tokens.
49+
50+ // Event signature hash and placeholder topics for the LogEmitter trigger.
4951 const topic0 =
50- "0xb8a00d6d8ca1be30bfec34d8f97e55f0f0fd9eeb7fb46e030516363d4cfe1ad6" ;
52+ "0xb8a00d6d8ca1be30bfec34d8f97e55f0f0fd9eeb7fb46e030516363d4cfe1ad6" ; // Event signature hash.
5153 const topic1 =
52- "0x0000000000000000000000000000000000000000000000000000000000000000" ;
54+ "0x0000000000000000000000000000000000000000000000000000000000000000" ; // Placeholder topics.
5355 const topic2 =
5456 "0x0000000000000000000000000000000000000000000000000000000000000000" ;
5557 const topic3 =
5658 "0x0000000000000000000000000000000000000000000000000000000000000000" ;
5759
58- // ABI-encode the trigger configuration data
60+ // ABI-encode the trigger configuration data.
5961 const triggerConfig = encodeAbiParameters (
6062 parseAbiParameters (
6163 "address, uint8, bytes32, bytes32, bytes32, bytes32"
6264 ) ,
6365 [ logEmitter as `0x${string } `, 0 , topic0 , topic1 , topic2 , topic3 ]
6466 ) ;
6567
66- // Construct the parameters for registration
68+ // Construct the parameters for registration, combining all previously defined values.
6769 const params = {
6870 name,
6971 encryptedEmail,
7072 upkeepContract : streamsUpkeep as `0x${string } `,
7173 gasLimit,
72- adminAddress : account ,
74+ adminAddress : admin ,
7375 triggerType,
7476 checkData,
7577 triggerConfig,
@@ -78,18 +80,17 @@ export const registerUpkeep = task(
7880 } ;
7981
8082 const spinner = spin ( ) ;
83+ // Interact with the deployed StreamsUpkeep contract to register the upkeep.
8184 spinner . start (
82- `Registering upkeep with Chainlink Automation using account: ${ account } `
85+ `Registering upkeep with Chainlink Automation using account: ${ admin } `
8386 ) ;
84-
85- // Interact with the deployed StreamsUpkeep contract to register the upkeep
86- const streamsUpkeepContract = await viem . getContractAt (
87+ const StreamsUpkeepContract = await viem . getContractAt (
8788 "StreamsUpkeepRegistrar" ,
8889 streamsUpkeep as `0x${string } `
8990 ) ;
9091
9192 try {
92- await streamsUpkeepContract . write . registerAndPredictID ( [ params ] ) ;
93+ await StreamsUpkeepContract . write . registerAndPredictID ( [ params ] ) ;
9394 spinner . succeed (
9495 "Upkeep registered and funded with 1 LINK successfully."
9596 ) ;
0 commit comments