Skip to content
This repository was archived by the owner on Apr 14, 2025. It is now read-only.

Commit 62340e1

Browse files
authored
Merge pull request #77 from gateway-fm/feat/accounts-func
feat: services to recieve data for account
2 parents 8cbdb5b + 94c5f76 commit 62340e1

File tree

12 files changed

+525
-38
lines changed

12 files changed

+525
-38
lines changed

events/events.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package events
22

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

6+
"github.com/gateway-fm/perpsv3-Go/contracts/Account"
7+
78
"github.com/ethereum/go-ethereum/ethclient"
89
"github.com/ethereum/go-ethereum/event"
910

mocks/service/mockService.go

Lines changed: 192 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

models/permissions.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,7 @@ func decodePermissionsCore(perm core.IAccountModuleAccountPermissions) (res []Pe
8080

8181
return res
8282
}
83+
84+
func DecodePermissionCore(perm [32]byte) (Permission, error) {
85+
return PermissionFromString(strings.TrimRight(string(perm[:]), string(rune(0))))
86+
}

perpsv3.go

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,18 @@ type IPerpsv3 interface {
354354
// limit. For most public RPC providers the value for limit is 20 000 blocks
355355
FormatAccountsCore(fromBlock, toBlock, limit uint64) ([]*models.Account, error)
356356

357+
// RetrieveChangeOwner is used to get all owner changes and additional data from the contract with given start block, end block and block search
358+
// limit. For most public RPC providers the value for limit is 20 000 blocks
359+
RetrieveChangeOwner(fromBlock, toBlock, limit uint64) ([]*models.AccountTransfer, error)
360+
361+
// RetrievePermissionRevoked is used to get all the revoked permission and additional data from the contract with given start block, end block and block search
362+
// limit. For most public RPC providers the value for limit is 20 000 blocks
363+
RetrievePermissionRevoked(fromBlock, toBlock, limit uint64) ([]*models.PermissionChanged, error)
364+
365+
// RetrievePermissionGranted is used to get all the granted permission and additional data from the contract with given start block, end block and block search
366+
// limit. For most public RPC providers the value for limit is 20 000 blocks
367+
RetrievePermissionGranted(fromBlock, toBlock, limit uint64) ([]*models.PermissionChanged, error)
368+
357369
// Config is used to get current lib config
358370
Config() *config.PerpsvConfig
359371

@@ -537,6 +549,18 @@ func (p *Perpsv3) RetrieveLiquidationsCore(fromBlock uint64, toBlock uint64, lim
537549
func (p *Perpsv3) RetrieveVaultLiquidationsCore(fromBlock uint64, toBlock uint64, limit uint64) ([]*models.CoreVaultLiquidation, error) {
538550
return p.service.RetrieveVaultLiquidationsCore(fromBlock, toBlock, limit)
539551
}
552+
553+
func (p *Perpsv3) RetrieveChangeOwner(fromBlock, toBlock, limit uint64) ([]*models.AccountTransfer, error) {
554+
return p.service.RetrieveChangeOwner(fromBlock, toBlock, limit)
555+
}
556+
557+
func (p *Perpsv3) RetrievePermissionRevoked(fromBlock, toBlock, limit uint64) ([]*models.PermissionChanged, error) {
558+
return p.service.RetrievePermissionRevoked(fromBlock, toBlock, limit)
559+
}
560+
561+
func (p *Perpsv3) RetrievePermissionGranted(fromBlock, toBlock, limit uint64) ([]*models.PermissionChanged, error) {
562+
return p.service.RetrievePermissionGranted(fromBlock, toBlock, limit)
563+
}
540564
func (p *Perpsv3) ListenTrades() (*events.TradeSubscription, error) {
541565
return p.events.ListenTrades()
542566
}
@@ -790,7 +814,7 @@ func (p *Perpsv3) init() error {
790814
return err
791815
}
792816

793-
srv, err := services.NewService(rpcClient, p.config, coreContact, perpsMarketContract)
817+
srv, err := services.NewService(rpcClient, p.config, coreContact, perpsMarketContract, accountContract)
794818
if err != nil {
795819
return err
796820
}

0 commit comments

Comments
 (0)