1
1
import { expect } from 'chai'
2
- import { constants , BigNumber } from 'ethers'
2
+ import { constants , BigNumber , PopulatedTransaction } from 'ethers'
3
3
4
4
import { Curation } from '../../build/types/Curation'
5
5
import { EpochManager } from '../../build/types/EpochManager'
@@ -67,7 +67,8 @@ describe('Staking:Allocation', () => {
67
67
const allocate = async ( tokens : BigNumber ) => {
68
68
return staking
69
69
. connect ( indexer . signer )
70
- . allocate (
70
+ . allocateFrom (
71
+ indexer . address ,
71
72
subgraphDeploymentID ,
72
73
tokens ,
73
74
allocationID ,
@@ -206,7 +207,14 @@ describe('Staking:Allocation', () => {
206
207
it ( 'reject allocate with invalid allocationID' , async function ( ) {
207
208
const tx = staking
208
209
. 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
+ )
210
218
await expect ( tx ) . revertedWith ( '!alloc' )
211
219
} )
212
220
@@ -273,7 +281,8 @@ describe('Staking:Allocation', () => {
273
281
const invalidProof = await channelKey . generateProof ( randomHexBytes ( 20 ) )
274
282
const tx = staking
275
283
. connect ( indexer . signer )
276
- . allocate (
284
+ . allocateFrom (
285
+ indexer . address ,
277
286
subgraphDeploymentID ,
278
287
tokensToAllocate ,
279
288
indexer . address ,
@@ -286,7 +295,8 @@ describe('Staking:Allocation', () => {
286
295
it ( 'invalid proof signature format' , async function ( ) {
287
296
const tx = staking
288
297
. connect ( indexer . signer )
289
- . allocate (
298
+ . allocateFrom (
299
+ indexer . address ,
290
300
subgraphDeploymentID ,
291
301
tokensToAllocate ,
292
302
indexer . address ,
@@ -631,7 +641,8 @@ describe('Staking:Allocation', () => {
631
641
const allocationID2 = channelKey2 . address
632
642
await staking
633
643
. connect ( indexer . signer )
634
- . allocate (
644
+ . allocateFrom (
645
+ indexer . address ,
635
646
subgraphDeploymentID ,
636
647
tokensToAllocate ,
637
648
allocationID2 ,
@@ -644,17 +655,21 @@ describe('Staking:Allocation', () => {
644
655
await advanceToNextEpoch ( epochManager )
645
656
646
657
// 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 )
658
673
} )
659
674
} )
660
675
@@ -672,19 +687,22 @@ describe('Staking:Allocation', () => {
672
687
// Close and allocate
673
688
const newChannelKey = deriveChannelKey ( )
674
689
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 )
688
706
} )
689
707
} )
690
708
@@ -870,7 +888,10 @@ describe('Staking:Allocation', () => {
870
888
871
889
// Claim with restake
872
890
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 ] )
874
895
875
896
// Verify that the claimed tokens are restaked
876
897
const afterIndexerStake = await staking . getIndexerStakedTokens ( indexer . address )
0 commit comments