Skip to content

Commit

Permalink
Merge pull request #77 from gateway-fm/feat/accounts-func
Browse files Browse the repository at this point in the history
feat: services to recieve data for account
  • Loading branch information
xfiendx4life authored Sep 4, 2024
2 parents 8cbdb5b + 94c5f76 commit 62340e1
Show file tree
Hide file tree
Showing 12 changed files with 525 additions and 38 deletions.
3 changes: 2 additions & 1 deletion events/events.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package events

import (
"github.com/gateway-fm/perpsv3-Go/contracts/Account"
"math/big"

"github.com/gateway-fm/perpsv3-Go/contracts/Account"

"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/event"

Expand Down
204 changes: 192 additions & 12 deletions mocks/service/mockService.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions models/permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,7 @@ func decodePermissionsCore(perm core.IAccountModuleAccountPermissions) (res []Pe

return res
}

func DecodePermissionCore(perm [32]byte) (Permission, error) {
return PermissionFromString(strings.TrimRight(string(perm[:]), string(rune(0))))
}
26 changes: 25 additions & 1 deletion perpsv3.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,18 @@ type IPerpsv3 interface {
// limit. For most public RPC providers the value for limit is 20 000 blocks
FormatAccountsCore(fromBlock, toBlock, limit uint64) ([]*models.Account, error)

// RetrieveChangeOwner is used to get all owner changes and additional data from the contract with given start block, end block and block search
// limit. For most public RPC providers the value for limit is 20 000 blocks
RetrieveChangeOwner(fromBlock, toBlock, limit uint64) ([]*models.AccountTransfer, error)

// RetrievePermissionRevoked is used to get all the revoked permission and additional data from the contract with given start block, end block and block search
// limit. For most public RPC providers the value for limit is 20 000 blocks
RetrievePermissionRevoked(fromBlock, toBlock, limit uint64) ([]*models.PermissionChanged, error)

// RetrievePermissionGranted is used to get all the granted permission and additional data from the contract with given start block, end block and block search
// limit. For most public RPC providers the value for limit is 20 000 blocks
RetrievePermissionGranted(fromBlock, toBlock, limit uint64) ([]*models.PermissionChanged, error)

// Config is used to get current lib config
Config() *config.PerpsvConfig

Expand Down Expand Up @@ -537,6 +549,18 @@ func (p *Perpsv3) RetrieveLiquidationsCore(fromBlock uint64, toBlock uint64, lim
func (p *Perpsv3) RetrieveVaultLiquidationsCore(fromBlock uint64, toBlock uint64, limit uint64) ([]*models.CoreVaultLiquidation, error) {
return p.service.RetrieveVaultLiquidationsCore(fromBlock, toBlock, limit)
}

func (p *Perpsv3) RetrieveChangeOwner(fromBlock, toBlock, limit uint64) ([]*models.AccountTransfer, error) {
return p.service.RetrieveChangeOwner(fromBlock, toBlock, limit)
}

func (p *Perpsv3) RetrievePermissionRevoked(fromBlock, toBlock, limit uint64) ([]*models.PermissionChanged, error) {
return p.service.RetrievePermissionRevoked(fromBlock, toBlock, limit)
}

func (p *Perpsv3) RetrievePermissionGranted(fromBlock, toBlock, limit uint64) ([]*models.PermissionChanged, error) {
return p.service.RetrievePermissionGranted(fromBlock, toBlock, limit)
}
func (p *Perpsv3) ListenTrades() (*events.TradeSubscription, error) {
return p.events.ListenTrades()
}
Expand Down Expand Up @@ -790,7 +814,7 @@ func (p *Perpsv3) init() error {
return err
}

srv, err := services.NewService(rpcClient, p.config, coreContact, perpsMarketContract)
srv, err := services.NewService(rpcClient, p.config, coreContact, perpsMarketContract, accountContract)
if err != nil {
return err
}
Expand Down
Loading

0 comments on commit 62340e1

Please sign in to comment.