Skip to content

Commit

Permalink
renamed hashed address function
Browse files Browse the repository at this point in the history
  • Loading branch information
sampocs committed Dec 28, 2023
1 parent 208eac7 commit 2c22d17
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions x/autopilot/keeper/liquidstake.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,22 +118,28 @@ func (k Keeper) IBCTransferStToken(
// Note: The channel ID here is different than the one used in PFM
// (we use the outbound channelID, they use the inbound channelID)
// DOUBLE CHECK ME that it shouldn't matter
hashedAddress, err := types.GenerateHashedSender(channelId, transferMetadata.Sender)
hashedAddress, err := types.GenerateHashedAddress(channelId, transferMetadata.Sender)
if err != nil {
return err
}

// First we need to bank send to the hashed address
originalReceiver := sdk.MustAccAddressFromBech32(transferMetadata.Receiver)
hashedAccount := sdk.MustAccAddressFromBech32(hashedAddress)
if err := k.bankKeeper.SendCoins(ctx, originalReceiver, hashedAccount, sdk.NewCoins(stToken)); err != nil {
originalReceiver, err := sdk.AccAddressFromBech32(transferMetadata.Receiver)
if err != nil {
return err
}
hashedSender, err := sdk.AccAddressFromBech32(hashedAddress)
if err != nil {
return err
}
if err := k.bankKeeper.SendCoins(ctx, originalReceiver, hashedSender, sdk.NewCoins(stToken)); err != nil {
return err
}

// Use the default transfer timeout of 10 minutes
timeoutTimestamp := uint64(ctx.BlockTime().UnixNano()) + transfertypes.DefaultRelativePacketTimeoutTimestamp

// Submit the transfer from the hashed sender
// Submit the transfer from the hashed address
transferMsg := &transfertypes.MsgTransfer{
SourcePort: transfertypes.PortID,
SourceChannel: channelId,
Expand Down
2 changes: 1 addition & 1 deletion x/autopilot/types/autopilot.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type ModuleRoutingInfo interface {
// when moving to the next hop (i.e. receiver of one hop, becomes sender of next)
//
// This function was borrowed from PFM
func GenerateHashedSender(channelId, originalSender string) (string, error) {
func GenerateHashedAddress(channelId, originalSender string) (string, error) {
senderStr := fmt.Sprintf("%s/%s", channelId, originalSender)
senderHash32 := address.Hash(ModuleName, []byte(senderStr))
sender := sdk.AccAddress(senderHash32[:20])
Expand Down

0 comments on commit 2c22d17

Please sign in to comment.