-
Notifications
You must be signed in to change notification settings - Fork 50
feat(x/erc20): add allowance state #90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
da2a912
04e0de8
80036a6
fcae5bb
c6e9436
00fb0ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package evmd | ||
|
||
import ( | ||
"cosmossdk.io/math" | ||
|
||
erc20types "github.com/cosmos/evm/x/erc20/types" | ||
) | ||
|
||
const ( | ||
ExampleSpender = "0x1e0DE5DB1a39F99cBc67B00fA3415181b3509e42" | ||
ExampleOwner = "0x0AFc8e15F0A74E98d0AEC6C67389D2231384D4B2" | ||
) | ||
|
||
// ExampleAllowances creates a slice of allowance, that contains an allowance for the native denom of the example chain | ||
// implementation. | ||
var ExampleAllowances = []erc20types.Allowance{ | ||
{ | ||
Erc20Address: WEVMOSContractMainnet, | ||
Owner: ExampleOwner, | ||
Spender: ExampleSpender, | ||
Value: math.NewInt(100), | ||
}, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,11 @@ package erc20 | |
|
||
import ( | ||
"fmt" | ||
"math/big" | ||
|
||
"github.com/cosmos/evm/x/erc20/keeper" | ||
"github.com/cosmos/evm/x/erc20/types" | ||
"github.com/ethereum/go-ethereum/common" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" | ||
|
@@ -31,12 +33,23 @@ func InitGenesis( | |
for _, pair := range data.TokenPairs { | ||
k.SetToken(ctx, pair) | ||
} | ||
|
||
var erc20, owner, spender common.Address | ||
var value *big.Int | ||
for _, allowance := range data.Allowances { | ||
erc20 = common.HexToAddress(allowance.Erc20Address) | ||
owner = common.HexToAddress(allowance.Owner) | ||
spender = common.HexToAddress(allowance.Spender) | ||
value = allowance.Value.BigInt() | ||
k.SetAllowance(ctx, erc20, owner, spender, value) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cloudgray There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. applied in 80036a6 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cloudgray Right now, we simply continue when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
} | ||
|
||
// ExportGenesis export module status | ||
func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { | ||
return &types.GenesisState{ | ||
Params: k.GetParams(ctx), | ||
TokenPairs: k.GetTokenPairs(ctx), | ||
Allowances: k.GetAllowances(ctx), | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.