-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add new API route to list transactions for epoch
- Loading branch information
1 parent
ac187bf
commit 6ea2153
Showing
5 changed files
with
121 additions
and
42 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
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,35 @@ | ||
package utils | ||
|
||
import ( | ||
globalconfig "flare-indexer/config" | ||
"flare-indexer/services/config" | ||
"flare-indexer/services/context" | ||
"flare-indexer/utils/contracts/voting" | ||
"flare-indexer/utils/staking" | ||
"time" | ||
) | ||
|
||
func NewEpochInfo(ctx context.ServicesContext) (staking.EpochInfo, error) { | ||
cfg := ctx.Config() | ||
|
||
start, period, err := getEpochStartAndPeriod(cfg) | ||
if err != nil { | ||
return staking.EpochInfo{}, err | ||
} | ||
|
||
return staking.NewEpochInfo(&globalconfig.EpochConfig{}, start, period), nil | ||
} | ||
|
||
func getEpochStartAndPeriod(cfg *config.Config) (time.Time, time.Duration, error) { | ||
eth, err := cfg.Chain.DialETH() | ||
if err != nil { | ||
return time.Time{}, 0, err | ||
} | ||
|
||
votingContract, err := voting.NewVoting(cfg.ContractAddresses.Voting, eth) | ||
if err != nil { | ||
return time.Time{}, 0, err | ||
} | ||
|
||
return staking.GetEpochConfig(votingContract) | ||
} |