Skip to content

Commit

Permalink
fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
crodriguezvega committed Jul 23, 2024
1 parent be7b6d5 commit d58dfa0
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 788 deletions.
5 changes: 0 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,8 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Features

<<<<<<< HEAD
=======
* (apps/transfer) [\#6492](https://github.com/cosmos/ibc-go/pull/6492) Added new `Tokens` field to `MsgTransfer` to enable sending of multiple denoms, and deprecated the `Token` field.
* (apps/transfer) [\#6693](https://github.com/cosmos/ibc-go/pull/6693) Added new `Forwarding` field to `MsgTransfer` to enable forwarding tokens through multiple intermediary chains with a single transaction. This also enables automatic unwinding of tokens to their native chain. `x/authz` support for transfer allows granters to specify a set of possible forwarding hops that are allowed for grantees.
* (apps/transfer) [\#6877](https://github.com/cosmos/ibc-go/pull/6877) Added the possibility to transfer the entire user balance of a particular denomination by using [`UnboundedSpendLimit`](https://github.com/cosmos/ibc-go/blob/715f00eef8727da41db25fdd4763b709bdbba07e/modules/apps/transfer/types/transfer_authorization.go#L253-L255) as the token amount.

>>>>>>> 92e1f387 ((feat) Add possibility to transfer entire balance. (#6877))
### Bug Fixes

## [v7.6.0](https://github.com/cosmos/ibc-go/releases/tag/v7.6.0) - 2024-06-20
Expand Down
644 changes: 0 additions & 644 deletions e2e/tests/transfer/base_test.go

This file was deleted.

15 changes: 5 additions & 10 deletions modules/apps/transfer/keeper/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,12 @@ func (k Keeper) sendTransfer(
// NOTE: denomination and hex hash correctness checked during msg.ValidateBasic
fullDenomPath := token.Denom

<<<<<<< HEAD
var err error

// deconstruct the token denomination into the denomination trace info
// to determine if the sender is the source chain
if strings.HasPrefix(token.Denom, "ibc/") {
fullDenomPath, err = k.DenomPathFromHash(ctx, token.Denom)
=======
for _, coin := range coins {
// Using types.UnboundedSpendLimit allows us to send the entire balance of a given denom.
if coin.Amount.Equal(types.UnboundedSpendLimit()) {
coin.Amount = k.bankKeeper.GetBalance(ctx, sender, coin.Denom).Amount
}

token, err := k.tokenFromCoin(ctx, coin)
>>>>>>> 92e1f387 ((feat) Add possibility to transfer entire balance. (#6877))
if err != nil {
return 0, err
}
Expand All @@ -103,6 +93,11 @@ func (k Keeper) sendTransfer(
telemetry.NewLabel(coretypes.LabelDestinationChannel, destinationChannel),
}

// Using types.UnboundedSpendLimit allows us to send the entire balance of a given denom.
if token.Amount.Equal(types.UnboundedSpendLimit()) {
token.Amount = k.bankKeeper.GetBalance(ctx, sender, token.Denom).Amount
}

// NOTE: SendTransfer simply sends the denomination as it exists on its own
// chain inside the packet data. The receiving chain will perform denom
// prefixing as necessary.
Expand Down
35 changes: 3 additions & 32 deletions modules/apps/transfer/keeper/relay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,45 +59,16 @@ func (suite *KeeperTestSuite) TestSendTransfer() {
}, true,
},
{
<<<<<<< HEAD
"source channel not found",
=======
"successful transfer of native token with ics20-1",
func() {
coins = sdk.NewCoins(coins[0])

// Set version to isc20-1.
path.EndpointA.UpdateChannel(func(channel *channeltypes.Channel) {
channel.Version = types.V1
})
},
nil,
},
{
"successful transfer with empty forwarding hops and ics20-1",
func() {
coins = sdk.NewCoins(coins[0])

// Set version to isc20-1.
path.EndpointA.UpdateChannel(func(channel *channeltypes.Channel) {
channel.Version = types.V1
})
},
nil,
},
{
"successful transfer of entire balance",
func() {
coins = sdk.NewCoins(sdk.NewCoin(coins[0].Denom, types.UnboundedSpendLimit()))
coin.Amount = types.UnboundedSpendLimit()
var ok bool
expEscrowAmounts[0], ok = sdkmath.NewIntFromString(ibctesting.DefaultGenesisAccBalance)
expEscrowAmount, ok = sdk.NewIntFromString(ibctesting.DefaultGenesisAccBalance)
suite.Require().True(ok)
},
nil,
}, true,
},
{
"failure: source channel not found",
>>>>>>> 92e1f387 ((feat) Add possibility to transfer entire balance. (#6877))
func() {
// channel references wrong ID
path.EndpointA.ChannelID = ibctesting.InvalidID
Expand Down
14 changes: 14 additions & 0 deletions modules/apps/transfer/types/coin.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@ package types

import (
"fmt"
"math/big"
"strings"

"cosmossdk.io/math"

Check failure on line 8 in modules/apps/transfer/types/coin.go

View workflow job for this annotation

GitHub Actions / lint

ST1019: package "cosmossdk.io/math" is being imported more than once (stylecheck)
sdkmath "cosmossdk.io/math"

Check failure on line 9 in modules/apps/transfer/types/coin.go

View workflow job for this annotation

GitHub Actions / lint

ST1019(related information): other import of "cosmossdk.io/math" (stylecheck)
sdk "github.com/cosmos/cosmos-sdk/types"
)

// maxUint256 is the maximum value for a 256 bit unsigned integer.
var maxUint256 = new(big.Int).Sub(new(big.Int).Lsh(big.NewInt(1), 256), big.NewInt(1))

// SenderChainIsSource returns false if the denomination originally came
// from the receiving chain and true otherwise.
func SenderChainIsSource(sourcePort, sourceChannel, denom string) bool {
Expand Down Expand Up @@ -46,3 +51,12 @@ func GetTransferCoin(portID, channelID, baseDenom string, amount math.Int) sdk.C
denomTrace := ParseDenomTrace(GetPrefixedDenom(portID, channelID, baseDenom))
return sdk.NewCoin(denomTrace.IBCDenom(), amount)
}

// UnboundedSpendLimit returns the sentinel value that can be used
// as the amount for a denomination's spend limit for which spend limit updating
// should be disabled. Please note that using this sentinel value means that a grantee
// will be granted the privilege to do ICS20 token transfers for the total amount
// of the denomination available at the granter's account.
func UnboundedSpendLimit() sdkmath.Int {
return sdkmath.NewIntFromBigInt(maxUint256)
}
58 changes: 0 additions & 58 deletions modules/apps/transfer/types/token.go

This file was deleted.

33 changes: 0 additions & 33 deletions modules/apps/transfer/types/transfer_authorization.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
package types

import (
<<<<<<< HEAD
"math/big"
"strings"

sdkmath "cosmossdk.io/math"
=======
"context"
"slices"
"strings"

"github.com/cosmos/gogoproto/proto"

errorsmod "cosmossdk.io/errors"

>>>>>>> 92e1f387 ((feat) Add possibility to transfer entire balance. (#6877))
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/authz"
Expand Down Expand Up @@ -182,23 +169,3 @@ func validateMemo(ctx sdk.Context, memo string, allowedMemos []string) error {

return sdkerrors.Wrapf(ErrInvalidAuthorization, "not allowed memo: %s", memo)
}

<<<<<<< HEAD
// UnboundedSpendLimit returns the sentinel value that can be used
// as the amount for a denomination's spend limit for which spend limit updating
// should be disabled. Please note that using this sentinel value means that a grantee
// will be granted the privilege to do ICS20 token transfers for the total amount
// of the denomination available at the granter's account.
func UnboundedSpendLimit() sdkmath.Int {
return sdk.NewIntFromBigInt(maxUint256)
=======
// getAllocationIndex ranges through a set of allocations, and returns the index of the allocation if found. If not, returns -1.
func getAllocationIndex(msg MsgTransfer, allocations []Allocation) int {
for index, allocation := range allocations {
if allocation.SourceChannel == msg.SourceChannel && allocation.SourcePort == msg.SourcePort {
return index
}
}
return allocationNotFound
>>>>>>> 92e1f387 ((feat) Add possibility to transfer entire balance. (#6877))
}
7 changes: 1 addition & 6 deletions testing/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,8 @@ func NewTestChainWithValSet(t *testing.T, coord *Coordinator, chainID string, va
for i := 0; i < MaxAccounts; i++ {
senderPrivKey := secp256k1.GenPrivKey()
acc := authtypes.NewBaseAccount(senderPrivKey.PubKey().Address().Bytes(), senderPrivKey.PubKey(), uint64(i), 0)
<<<<<<< HEAD
amount, ok := sdk.NewIntFromString("10000000000000000000")
amount, ok := sdk.NewIntFromString(DefaultGenesisAccBalance)
require.True(t, ok)
=======
amount, ok := sdkmath.NewIntFromString(DefaultGenesisAccBalance)
require.True(tb, ok)
>>>>>>> 92e1f387 ((feat) Add possibility to transfer entire balance. (#6877))

// add sender account
balance := banktypes.Balance{
Expand Down

0 comments on commit d58dfa0

Please sign in to comment.