Skip to content

Commit

Permalink
feat: add TargetOracleUniqueID to ApprovalSharingOracleKey (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xHansLee authored Jan 4, 2023
1 parent fe97e9e commit e952de1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
9 changes: 5 additions & 4 deletions event/oracle/register_oracle_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ func (e RegisterOracleEvent) EventHandler(ctx context.Context, event ctypes.Resu
}

// generate Msg/ApproveOracleRegistration
msgApproveOracleRegistration, err := e.generateApproveOracleRegistrationMsg(oracleRegistration, targetAddress)
msgApproveOracleRegistration, err := e.generateApproveOracleRegistrationMsg(oracleRegistration, uniqueID, targetAddress)
if err != nil {
return fmt.Errorf("failed to generate MsgApproveOracleRegistration: %w", err)
}

log.Infof("new oracle registration approval info. unique ID(%s), approver address(%s), target address(%s)",
msgApproveOracleRegistration.ApprovalSharingOracleKey.UniqueId,
msgApproveOracleRegistration.ApprovalSharingOracleKey.ApproverUniqueId,
msgApproveOracleRegistration.ApprovalSharingOracleKey.ApproverOracleAddress,
msgApproveOracleRegistration.ApprovalSharingOracleKey.TargetOracleAddress,
)
Expand Down Expand Up @@ -88,7 +88,7 @@ func (e RegisterOracleEvent) verifyOracleRegistration(oracleRegistration *oracle
return nil
}

func (e RegisterOracleEvent) generateApproveOracleRegistrationMsg(oracleRegistration *oracletypes.OracleRegistration, targetAddress string) (*oracletypes.MsgApproveOracleRegistration, error) {
func (e RegisterOracleEvent) generateApproveOracleRegistrationMsg(oracleRegistration *oracletypes.OracleRegistration, targetUniqueID, targetAddress string) (*oracletypes.MsgApproveOracleRegistration, error) {
approverAddress := e.reactor.OracleAcc().GetAddress()
oraclePrivKeyBz := e.reactor.OraclePrivKey().Serialize()
approverUniqueID := e.reactor.EnclaveInfo().UniqueIDHex()
Expand All @@ -99,8 +99,9 @@ func (e RegisterOracleEvent) generateApproveOracleRegistrationMsg(oracleRegistra
}

approvalMsg := &oracletypes.ApprovalSharingOracleKey{
UniqueId: approverUniqueID,
ApproverUniqueId: approverUniqueID,
ApproverOracleAddress: approverAddress,
TargetUniqueId: targetUniqueID,
TargetOracleAddress: targetAddress,
EncryptedOraclePrivKey: encryptedOraclePrivKey,
}
Expand Down
9 changes: 5 additions & 4 deletions event/oracle/upgrade_oracle_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ func (e UpgradeOracleEvent) EventHandler(ctx context.Context, event ctypes.Resul
}

// generate Msg/ApproveOracleUpgrade
msgApproveOracleUpgrade, err := e.generateApproveOracleUpgradeMsg(oracleUpgrade, targetAddress)
msgApproveOracleUpgrade, err := e.generateApproveOracleUpgradeMsg(oracleUpgrade, uniqueID, targetAddress)
if err != nil {
return fmt.Errorf("failed to generate MsgApproveOracleUpgrade: %w", err)
}

log.Infof("oracle upgrade approval info. unique ID(%s), approver address(%s), target address(%s)",
msgApproveOracleUpgrade.ApprovalSharingOracleKey.UniqueId,
msgApproveOracleUpgrade.ApprovalSharingOracleKey.ApproverUniqueId,
msgApproveOracleUpgrade.ApprovalSharingOracleKey.ApproverOracleAddress,
msgApproveOracleUpgrade.ApprovalSharingOracleKey.TargetOracleAddress,
)
Expand Down Expand Up @@ -106,7 +106,7 @@ func (e UpgradeOracleEvent) verifyOracleUpgrade(ctx context.Context, oracleUpgra
return nil
}

func (e UpgradeOracleEvent) generateApproveOracleUpgradeMsg(oracleUpgrade *oracletypes.OracleUpgrade, targetAddress string) (*oracletypes.MsgApproveOracleUpgrade, error) {
func (e UpgradeOracleEvent) generateApproveOracleUpgradeMsg(oracleUpgrade *oracletypes.OracleUpgrade, targetUniqueID, targetAddress string) (*oracletypes.MsgApproveOracleUpgrade, error) {
approverAddress := e.reactor.OracleAcc().GetAddress()
oraclePrivKeyBz := e.reactor.OraclePrivKey().Serialize()
approverUniqueID := e.reactor.EnclaveInfo().UniqueIDHex()
Expand All @@ -118,8 +118,9 @@ func (e UpgradeOracleEvent) generateApproveOracleUpgradeMsg(oracleUpgrade *oracl
}

approvalMsg := &oracletypes.ApprovalSharingOracleKey{
UniqueId: approverUniqueID,
ApproverUniqueId: approverUniqueID,
ApproverOracleAddress: approverAddress,
TargetUniqueId: targetUniqueID,
TargetOracleAddress: targetAddress,
EncryptedOraclePrivKey: encryptedOraclePrivKey,
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
github.com/gorilla/mux v1.8.0
github.com/ipfs/go-ipfs-api v0.3.0
github.com/lestrrat-go/jwx/v2 v2.0.8
github.com/medibloc/panacea-core/v2 v2.0.6-0.20221228073329-db97922517cf
github.com/medibloc/panacea-core/v2 v2.0.6-0.20230104081432-e5cc1c5514cd
github.com/sirupsen/logrus v1.9.0
github.com/spf13/cobra v1.6.1
github.com/spf13/viper v1.13.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1382,8 +1382,8 @@ github.com/maxbrunsfeld/counterfeiter/v6 v6.2.2/go.mod h1:eD9eIE7cdwcMi9rYluz88J
github.com/mbilski/exhaustivestruct v1.2.0/go.mod h1:OeTBVxQWoEmB2J2JCHmXWPJ0aksxSUOUy+nvtVEfzXc=
github.com/medibloc/cosmos-sdk v0.45.9-panacea.1 h1:JTprXN6z/+6UjkjQU4OfDz7z+sUpzev1s9DywmWA2Sk=
github.com/medibloc/cosmos-sdk v0.45.9-panacea.1/go.mod h1:Z5M4TX7PsHNHlF/1XanI2DIpORQ+Q/st7oaeufEjnvU=
github.com/medibloc/panacea-core/v2 v2.0.6-0.20221228073329-db97922517cf h1:4AMPidYCSHzrV6avd1hxUQMnXva5/UJXLw2F/m/wdf8=
github.com/medibloc/panacea-core/v2 v2.0.6-0.20221228073329-db97922517cf/go.mod h1:YCYoLlbegqIP8fbrpvrvkK5LsQojDxukneKczbZ7hic=
github.com/medibloc/panacea-core/v2 v2.0.6-0.20230104081432-e5cc1c5514cd h1:cljJCsJwn8rbk2NZW2klZ9rId5d3Bv/h6uEx0H/uhMI=
github.com/medibloc/panacea-core/v2 v2.0.6-0.20230104081432-e5cc1c5514cd/go.mod h1:YCYoLlbegqIP8fbrpvrvkK5LsQojDxukneKczbZ7hic=
github.com/mgechev/dots v0.0.0-20210922191527-e955255bf517/go.mod h1:KQ7+USdGKfpPjXk4Ga+5XxQM4Lm4e3gAogrreFAYpOg=
github.com/mgechev/revive v1.2.1/go.mod h1:+Ro3wqY4vakcYNtkBWdZC7dBg1xSB6sp054wWwmeFm0=
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
Expand Down

0 comments on commit e952de1

Please sign in to comment.