-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(evm-funtoken-precompile): Implement "balance", "bankBalance", an…
…d "whoAmI" methods (#2107)
- Loading branch information
1 parent
94db838
commit 8907a61
Showing
26 changed files
with
872 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ontracts/TestERC20TransferThenPrecompileSend.sol/TestERC20TransferThenPrecompileSend.json
Large diffs are not rendered by default.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
...rtifacts/contracts/TestFunTokenPrecompileLocalGas.sol/TestFunTokenPrecompileLocalGas.json
Large diffs are not rendered by default.
Oops, something went wrong.
22 changes: 20 additions & 2 deletions
22
...acts/contracts/TestNativeSendThenPrecompileSend.sol/TestNativeSendThenPrecompileSend.json
Large diffs are not rendered by default.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
...ds/artifacts/contracts/TestPrecompileSelfCallRevert.sol/TestPrecompileSelfCallRevert.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,53 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity >=0.8.19; | ||
|
||
/// @dev Implements the "bankSend" functionality for sending ERC20 tokens as bank | ||
/// coins to a Nibiru bech32 address using the "FunToken" mapping between the | ||
/// ERC20 and bank. | ||
address constant FUNTOKEN_PRECOMPILE_ADDRESS = 0x0000000000000000000000000000000000000800; | ||
IFunToken constant FUNTOKEN_PRECOMPILE = IFunToken(FUNTOKEN_PRECOMPILE_ADDRESS); | ||
|
||
/// @dev Implements the functionality for sending ERC20 tokens and bank | ||
/// coins to various Nibiru accounts using either the Nibiru Bech32 address | ||
/// using the "FunToken" mapping between the ERC20 and bank. | ||
interface IFunToken { | ||
/// @dev bankSend sends ERC20 tokens as coins to a Nibiru base account | ||
/// @dev sendToBank sends ERC20 tokens as coins to a Nibiru base account | ||
/// @param erc20 - the address of the ERC20 token contract | ||
/// @param amount - the amount of tokens to send | ||
/// @param to - the receiving Nibiru base account address as a string | ||
/// @return sentAmount - amount of tokens received by the recipient. This may | ||
/// not be equal to `amount` if the corresponding ERC20 contract has a fee or | ||
/// deduction on transfer. | ||
function bankSend( | ||
function sendToBank( | ||
address erc20, | ||
uint256 amount, | ||
string memory to | ||
string calldata to | ||
) external returns (uint256 sentAmount); | ||
} | ||
|
||
address constant FUNTOKEN_PRECOMPILE_ADDRESS = 0x0000000000000000000000000000000000000800; | ||
struct NibiruAccount { | ||
address ethAddr; | ||
string bech32Addr; | ||
} | ||
struct FunToken { | ||
address erc20; | ||
string bankDenom; | ||
} | ||
|
||
IFunToken constant FUNTOKEN_PRECOMPILE = IFunToken(FUNTOKEN_PRECOMPILE_ADDRESS); | ||
function balance( | ||
address who, | ||
address funtoken | ||
) | ||
external | ||
returns ( | ||
uint256 erc20Balance, | ||
uint256 bankBalance, | ||
FunToken memory token, | ||
NibiruAccount memory whoAddrs | ||
); | ||
|
||
function bankBalance( | ||
address who, | ||
string calldata bankDenom | ||
) external returns (uint256 bankBalance, NibiruAccount memory whoAddrs); | ||
|
||
function whoAmI( | ||
string calldata who | ||
) external returns (NibiruAccount memory whoAddrs); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.