-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move chain indexing to astra indexing (#1)
* move chain indexing to astra indexing * add metrics block height
- Loading branch information
1 parent
2c8ea0b
commit 28b751a
Showing
861 changed files
with
549,607 additions
and
123 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package cosmosapp | ||
|
||
const ACCOUNT_MODULE = "/cosmos.auth.v1beta1.ModuleAccount" | ||
const ACCOUNT_BASE = "/cosmos.auth.v1beta1.BaseAccount" | ||
const ACCOUNT_VESTING_DELAYED = "/cosmos.vesting.v1beta1.DelayedVestingAccount" | ||
const ACCOUNT_VESTING_CONTINUOUS = "/cosmos.vesting.v1beta1.ContinuousVestingAccount" | ||
const ACCOUNT_VESTING_PERIODIC = "/cosmos.vesting.v1beta1.PeriodicVestingAccount" | ||
const ACCOUNT_ETHERMINT = "/ethermint.types.v1.EthAccount" | ||
|
||
type Account struct { | ||
Type string `json:"type"` | ||
Address string `json:"address"` | ||
MaybePubkey *PubKey `json:"pubkey"` | ||
AccountNumber string `json:"account_number"` | ||
Sequence string `json:"sequence"` | ||
|
||
MaybeModuleAccount *ModuleAccount `json:"module_account"` | ||
MaybeDelayedVestingAccount *DelayedVestingAccount `json:"delayed_vesting_account"` | ||
MaybeContinuousVestingAccount *ContinuousVestingAccount `json:"continuous_vesting_account"` | ||
MaybePeriodicVestingAccount *PeriodicVestingAccount `json:"periodic_vesting_account"` | ||
} | ||
|
||
type ModuleAccount struct { | ||
Name string `json:"name"` | ||
Permissions []string `json:"permissions"` | ||
} | ||
|
||
type DelayedVestingAccount struct { | ||
OriginalVesting []VestingBalance `json:"original_vesting"` | ||
DelegatedFree []VestingBalance `json:"delegated_free"` | ||
DelegatedVesting []VestingBalance `json:"delegated_vesting"` | ||
EndTime string `json:"end_time"` | ||
} | ||
|
||
type ContinuousVestingAccount struct { | ||
OriginalVesting []VestingBalance `json:"original_vesting"` | ||
DelegatedFree []VestingBalance `json:"delegated_free"` | ||
DelegatedVesting []VestingBalance `json:"delegated_vesting"` | ||
StartTime string `json:"start_time"` | ||
EndTime string `json:"end_time"` | ||
} | ||
|
||
type PeriodicVestingAccount struct { | ||
OriginalVesting []VestingBalance `json:"original_vesting"` | ||
DelegatedFree []VestingBalance `json:"delegated_free"` | ||
DelegatedVesting []VestingBalance `json:"delegated_vesting"` | ||
StartTime string `json:"start_time"` | ||
EndTime string `json:"end_time"` | ||
VestingPeriods []VestingPeriod `json:"vesting_periods"` | ||
} | ||
|
||
type VestingPeriod struct { | ||
Amount []VestingBalance `json:"amount"` | ||
Length string `json:"length"` | ||
} | ||
|
||
type VestingBalance struct { | ||
Denom string `json:"denom"` | ||
Amount string `json:"amount"` | ||
} |
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 cosmosapp | ||
|
||
import ( | ||
"errors" | ||
|
||
"github.com/AstraProtocol/astra-indexing/usecase/coin" | ||
"github.com/AstraProtocol/astra-indexing/usecase/model" | ||
) | ||
|
||
type Client interface { | ||
Account(accountAddress string) (*Account, error) | ||
Balances(accountAddress string) (coin.Coins, error) | ||
BondedBalance(accountAddress string) (coin.Coins, error) | ||
RedelegatingBalance(accountAddress string) (coin.Coins, error) | ||
UnbondingBalance(accountAddress string) (coin.Coins, error) | ||
|
||
TotalRewards(accountAddress string) (coin.DecCoins, error) | ||
Commission(validatorAddress string) (coin.DecCoins, error) | ||
|
||
Validator(validatorAddress string) (*Validator, error) | ||
Delegation(delegator string, validator string) (*DelegationResponse, error) | ||
TotalBondedBalance() (coin.Coin, error) | ||
|
||
AnnualProvisions() (coin.DecCoin, error) | ||
|
||
Proposals() ([]Proposal, error) | ||
ProposalById(id string) (Proposal, error) | ||
ProposalTally(id string) (Tally, error) | ||
|
||
Tx(txHash string) (*model.Tx, error) | ||
} | ||
|
||
var ErrAccountNotFound = errors.New("account not found") | ||
var ErrAccountNoDelegation = errors.New("account has no delegation") | ||
var ErrProposalNotFound = errors.New("proposal not found") |
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,17 @@ | ||
package cosmosapp | ||
|
||
type DelegationResponse struct { | ||
Delegation Delegation `json:"delegation"` | ||
Balance DelegationBalance `json:"balance"` | ||
} | ||
|
||
type Delegation struct { | ||
DelegatorAddress string `json:"delegator_address"` | ||
ValidatorAddress string `json:"validator_address"` | ||
Shares string `json:"shares"` | ||
} | ||
|
||
type DelegationBalance struct { | ||
Denom string `json:"denom"` | ||
Amount string `json:"amount"` | ||
} |
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,102 @@ | ||
package cosmosapp | ||
|
||
import ( | ||
"github.com/AstraProtocol/astra-indexing/usecase/coin" | ||
"github.com/AstraProtocol/astra-indexing/usecase/model" | ||
"github.com/stretchr/testify/mock" | ||
) | ||
|
||
type MockClient struct { | ||
mock.Mock | ||
} | ||
|
||
func NewMockClient() *MockClient { | ||
return &MockClient{} | ||
} | ||
|
||
func (conn *MockClient) Account(accountAddress string) (*Account, error) { | ||
mockArgs := conn.Called(accountAddress) | ||
result, _ := mockArgs.Get(0).(*Account) | ||
return result, mockArgs.Error(1) | ||
} | ||
|
||
func (conn *MockClient) Balances(accountAddress string) (coin.Coins, error) { | ||
mockArgs := conn.Called(accountAddress) | ||
result, _ := mockArgs.Get(0).(coin.Coins) | ||
return result, mockArgs.Error(1) | ||
} | ||
|
||
func (conn *MockClient) BondedBalance(accountAddress string) (coin.Coins, error) { | ||
mockArgs := conn.Called(accountAddress) | ||
result, _ := mockArgs.Get(0).(coin.Coins) | ||
return result, mockArgs.Error(1) | ||
} | ||
|
||
func (conn *MockClient) RedelegatingBalance(accountAddress string) (coin.Coins, error) { | ||
mockArgs := conn.Called(accountAddress) | ||
result, _ := mockArgs.Get(0).(coin.Coins) | ||
return result, mockArgs.Error(1) | ||
} | ||
|
||
func (conn *MockClient) UnbondingBalance(accountAddress string) (coin.Coins, error) { | ||
mockArgs := conn.Called(accountAddress) | ||
result, _ := mockArgs.Get(0).(coin.Coins) | ||
return result, mockArgs.Error(1) | ||
} | ||
|
||
func (conn *MockClient) TotalRewards(accountAddress string) (coin.DecCoins, error) { | ||
mockArgs := conn.Called(accountAddress) | ||
result, _ := mockArgs.Get(0).(coin.DecCoins) | ||
return result, mockArgs.Error(1) | ||
} | ||
|
||
func (conn *MockClient) Commission(validatorAddress string) (coin.DecCoins, error) { | ||
mockArgs := conn.Called(validatorAddress) | ||
result, _ := mockArgs.Get(0).(coin.DecCoins) | ||
return result, mockArgs.Error(1) | ||
} | ||
|
||
func (conn *MockClient) Validator(validatorAddress string) (*Validator, error) { | ||
mockArgs := conn.Called(validatorAddress) | ||
result, _ := mockArgs.Get(0).(*Validator) | ||
return result, mockArgs.Error(1) | ||
} | ||
|
||
func (conn *MockClient) Delegation(delegator string, validator string) (*DelegationResponse, error) { | ||
mockArgs := conn.Called(delegator, validator) | ||
result, _ := mockArgs.Get(0).(*DelegationResponse) | ||
return result, mockArgs.Error(1) | ||
} | ||
|
||
func (conn *MockClient) TotalBondedBalance() (coin.Coin, error) { | ||
args := conn.Called() | ||
return args.Get(0).(coin.Coin), args.Error(1) | ||
} | ||
|
||
func (conn *MockClient) AnnualProvisions() (coin.DecCoin, error) { | ||
args := conn.Called() | ||
return args.Get(0).(coin.DecCoin), args.Error(1) | ||
} | ||
|
||
func (conn *MockClient) Proposals() ([]Proposal, error) { | ||
args := conn.Called() | ||
return args.Get(0).([]Proposal), args.Error(1) | ||
} | ||
|
||
func (conn *MockClient) ProposalById(id string) (Proposal, error) { | ||
mockArgs := conn.Called(id) | ||
result, _ := mockArgs.Get(0).(Proposal) | ||
return result, mockArgs.Error(1) | ||
} | ||
|
||
func (conn *MockClient) ProposalTally(id string) (Tally, error) { | ||
mockArgs := conn.Called(id) | ||
result, _ := mockArgs.Get(0).(Tally) | ||
return result, mockArgs.Error(1) | ||
} | ||
|
||
func (conn *MockClient) Tx(txHash string) (*model.Tx, error) { | ||
mockArgs := conn.Called(txHash) | ||
result, _ := mockArgs.Get(0).(*model.Tx) | ||
return result, mockArgs.Error(1) | ||
} |
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,45 @@ | ||
package cosmosapp | ||
|
||
type Proposal struct { | ||
ProposalID string `json:"proposal_id"` | ||
Content Content `json:"content"` | ||
Status string `json:"status"` | ||
FinalTallyResult FinalTallyResult `json:"final_tally_result"` | ||
SubmitTime string `json:"submit_time"` | ||
DepositEndTime string `json:"deposit_end_time"` | ||
TotalDeposit []TotalDeposit `json:"total_deposit"` | ||
VotingStartTime string `json:"voting_start_time"` | ||
VotingEndTime string `json:"voting_end_time"` | ||
} | ||
|
||
type Content struct { | ||
Type string `json:"@type"` | ||
Title string `json:"title"` | ||
Description string `json:"description"` | ||
Changes []Change `json:"changes"` | ||
} | ||
|
||
type Change struct { | ||
Subspace string `json:"subspace"` | ||
Key string `json:"key"` | ||
Value string `json:"value"` | ||
} | ||
|
||
type FinalTallyResult struct { | ||
Yes string `json:"yes"` | ||
Abstain string `json:"abstain"` | ||
No string `json:"no"` | ||
NoWithVeto string `json:"no_with_veto"` | ||
} | ||
|
||
type TotalDeposit struct { | ||
Denom string `json:"denom"` | ||
Amount string `json:"amount"` | ||
} | ||
|
||
type Tally struct { | ||
Yes string `json:"yes"` | ||
Abstain string `json:"abstain"` | ||
No string `json:"no"` | ||
NoWithVeto string `json:"no_with_veto"` | ||
} |
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,6 @@ | ||
package cosmosapp | ||
|
||
type PubKey struct { | ||
Type string `json:"@type"` | ||
Key string `json:"key"` | ||
} |
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,34 @@ | ||
package cosmosapp | ||
|
||
type Validator struct { | ||
OperatorAddress string `json:"operator_address"` | ||
ConsensusPubkey PubKey `json:"consensus_pubkey"` | ||
Jailed bool `json:"jailed"` | ||
Status string `json:"status"` | ||
Tokens string `json:"tokens"` | ||
DelegatorShares string `json:"delegator_shares"` | ||
Description ValidatorDescription `json:"description"` | ||
UnbondingHeight string `json:"unbonding_height"` | ||
UnbondingTime string `json:"unbonding_time"` | ||
Commission ValidatorCommission `json:"commission"` | ||
MinSelfDelegation string `json:"min_self_delegation"` | ||
} | ||
|
||
type ValidatorCommission struct { | ||
CommissionRates ValidatorCommissionRates `json:"commission_rates"` | ||
UpdateTime string `json:"update_time"` | ||
} | ||
|
||
type ValidatorCommissionRates struct { | ||
Rate string `json:"rate"` | ||
MaxRate string `json:"max_rate"` | ||
MaxChangeRate string `json:"max_change_rate"` | ||
} | ||
|
||
type ValidatorDescription struct { | ||
Moniker string `json:"moniker"` | ||
Identity string `json:"identity"` | ||
Website string `json:"website"` | ||
SecurityContact string `json:"security_contact"` | ||
Details string `json:"details"` | ||
} |
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,13 @@ | ||
package event_test | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
func TestEvent(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "Event Suite") | ||
} |
Oops, something went wrong.