11import { expect } from 'chai'
2- import { constants , BigNumber } from 'ethers'
2+ import { constants , BigNumber , PopulatedTransaction } from 'ethers'
33
44import { Curation } from '../../build/types/Curation'
55import { EpochManager } from '../../build/types/EpochManager'
@@ -67,7 +67,8 @@ describe('Staking:Allocation', () => {
6767 const allocate = async ( tokens : BigNumber ) => {
6868 return staking
6969 . connect ( indexer . signer )
70- . allocate (
70+ . allocateFrom (
71+ indexer . address ,
7172 subgraphDeploymentID ,
7273 tokens ,
7374 allocationID ,
@@ -206,7 +207,14 @@ describe('Staking:Allocation', () => {
206207 it ( 'reject allocate with invalid allocationID' , async function ( ) {
207208 const tx = staking
208209 . connect ( indexer . signer )
209- . allocate ( subgraphDeploymentID , tokensToAllocate , AddressZero , metadata , randomHexBytes ( 20 ) )
210+ . allocateFrom (
211+ indexer . address ,
212+ subgraphDeploymentID ,
213+ tokensToAllocate ,
214+ AddressZero ,
215+ metadata ,
216+ randomHexBytes ( 20 ) ,
217+ )
210218 await expect ( tx ) . revertedWith ( '!alloc' )
211219 } )
212220
@@ -273,7 +281,8 @@ describe('Staking:Allocation', () => {
273281 const invalidProof = await channelKey . generateProof ( randomHexBytes ( 20 ) )
274282 const tx = staking
275283 . connect ( indexer . signer )
276- . allocate (
284+ . allocateFrom (
285+ indexer . address ,
277286 subgraphDeploymentID ,
278287 tokensToAllocate ,
279288 indexer . address ,
@@ -286,7 +295,8 @@ describe('Staking:Allocation', () => {
286295 it ( 'invalid proof signature format' , async function ( ) {
287296 const tx = staking
288297 . connect ( indexer . signer )
289- . allocate (
298+ . allocateFrom (
299+ indexer . address ,
290300 subgraphDeploymentID ,
291301 tokensToAllocate ,
292302 indexer . address ,
@@ -631,7 +641,8 @@ describe('Staking:Allocation', () => {
631641 const allocationID2 = channelKey2 . address
632642 await staking
633643 . connect ( indexer . signer )
634- . allocate (
644+ . allocateFrom (
645+ indexer . address ,
635646 subgraphDeploymentID ,
636647 tokensToAllocate ,
637648 allocationID2 ,
@@ -644,17 +655,21 @@ describe('Staking:Allocation', () => {
644655 await advanceToNextEpoch ( epochManager )
645656
646657 // Close multiple allocations in one tx
647- const requests = [
648- {
649- allocationID : allocationID ,
650- poi : poi ,
651- } ,
652- {
653- allocationID : allocationID2 ,
654- poi : poi ,
655- } ,
656- ]
657- await staking . connect ( indexer . signer ) . closeAllocationMany ( requests )
658+ const requests = await Promise . all (
659+ [
660+ {
661+ allocationID : allocationID ,
662+ poi : poi ,
663+ } ,
664+ {
665+ allocationID : allocationID2 ,
666+ poi : poi ,
667+ } ,
668+ ] . map ( ( { allocationID, poi } ) =>
669+ staking . connect ( indexer . signer ) . populateTransaction . closeAllocation ( allocationID , poi ) ,
670+ ) ,
671+ ) . then ( ( e ) => e . map ( ( e : PopulatedTransaction ) => e . data ) )
672+ await staking . connect ( indexer . signer ) . multicall ( requests )
658673 } )
659674 } )
660675
@@ -672,19 +687,22 @@ describe('Staking:Allocation', () => {
672687 // Close and allocate
673688 const newChannelKey = deriveChannelKey ( )
674689 const newAllocationID = newChannelKey . address
675- const tx = staking
676- . connect ( indexer . signer )
677- . closeAndAllocate (
678- allocationID ,
679- HashZero ,
680- indexer . address ,
681- subgraphDeploymentID ,
682- tokensToAllocate ,
683- newAllocationID ,
684- metadata ,
685- await newChannelKey . generateProof ( indexer . address ) ,
686- )
687- await tx
690+
691+ // Close multiple allocations in one tx
692+ const requests = await Promise . all ( [
693+ staking . connect ( indexer . signer ) . populateTransaction . closeAllocation ( allocationID , poi ) ,
694+ staking
695+ . connect ( indexer . signer )
696+ . populateTransaction . allocateFrom (
697+ indexer . address ,
698+ subgraphDeploymentID ,
699+ tokensToAllocate ,
700+ newAllocationID ,
701+ metadata ,
702+ await newChannelKey . generateProof ( indexer . address ) ,
703+ ) ,
704+ ] ) . then ( ( e ) => e . map ( ( e : PopulatedTransaction ) => e . data ) )
705+ await staking . connect ( indexer . signer ) . multicall ( requests )
688706 } )
689707 } )
690708
@@ -870,7 +888,10 @@ describe('Staking:Allocation', () => {
870888
871889 // Claim with restake
872890 expect ( await staking . getAllocationState ( allocationID ) ) . eq ( AllocationState . Finalized )
873- await staking . connect ( indexer . signer ) . claimMany ( [ allocationID ] , true )
891+ const tx = await staking
892+ . connect ( indexer . signer )
893+ . populateTransaction . claim ( allocationID , true )
894+ await staking . connect ( indexer . signer ) . multicall ( [ tx . data ] )
874895
875896 // Verify that the claimed tokens are restaked
876897 const afterIndexerStake = await staking . getIndexerStakedTokens ( indexer . address )
0 commit comments