difftreelog
feat impl balance_of_cross
in: master
5 files changed
pallets/balances-adapter/src/erc.rsdiffbeforeafterboth--- a/pallets/balances-adapter/src/erc.rs
+++ b/pallets/balances-adapter/src/erc.rs
@@ -58,6 +58,7 @@
// self.consume_store_reads(1)?;
Err("Approve not supported now".into())
}
+
fn balance_of(&self, owner: Address) -> Result<U256> {
// self.consume_store_reads(1)?;
let owner = T::CrossAccountId::from_eth(owner);
@@ -141,6 +142,13 @@
where
T::AccountId: From<[u8; 32]>,
{
+ fn balance_of_cross(&self, owner: CrossAddress) -> Result<U256> {
+ // self.consume_store_reads(1)?;
+ let owner = owner.into_sub_cross_account::<T>()?;
+ let balance = <T as Config>::Currency::free_balance(owner.as_sub());
+ Ok(balance.into())
+ }
+
// #[weight(<SelfWeightOf<T>>::transfer())]
fn transfer_cross(&mut self, caller: Caller, to: CrossAddress, amount: U256) -> Result<bool> {
let caller = T::CrossAccountId::from_eth(caller);
pallets/balances-adapter/src/stubs/UniqueNativeFungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/balances-adapter/src/stubs/UniqueNativeFungible.soldiffbeforeafterboth--- a/pallets/balances-adapter/src/stubs/UniqueNativeFungible.sol
+++ b/pallets/balances-adapter/src/stubs/UniqueNativeFungible.sol
@@ -17,8 +17,17 @@
}
}
-/// @dev the ERC-165 identifier for this interface is 0xff15c6f4
+/// @dev the ERC-165 identifier for this interface is 0x1313556c
contract ERC20UniqueExtensions is Dummy, ERC165 {
+ /// @dev EVM selector for this function is: 0xec069398,
+ /// or in textual repr: balanceOfCross((address,uint256))
+ function balanceOfCross(CrossAddress memory owner) public view returns (uint256) {
+ require(false, stub_error);
+ owner;
+ dummy;
+ return 0;
+ }
+
/// @dev EVM selector for this function is: 0x2ada85ff,
/// or in textual repr: transferCross((address,uint256),uint256)
function transferCross(CrossAddress memory to, uint256 amount) public returns (bool) {
tests/src/eth/abi/nativeFungible.jsondiffbeforeafterboth--- a/tests/src/eth/abi/nativeFungible.json
+++ b/tests/src/eth/abi/nativeFungible.json
@@ -79,6 +79,23 @@
"type": "function"
},
{
+ "inputs": [
+ {
+ "components": [
+ { "internalType": "address", "name": "eth", "type": "address" },
+ { "internalType": "uint256", "name": "sub", "type": "uint256" }
+ ],
+ "internalType": "struct CrossAddress",
+ "name": "owner",
+ "type": "tuple"
+ }
+ ],
+ "name": "balanceOfCross",
+ "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
"inputs": [],
"name": "decimals",
"outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }],
tests/src/eth/api/UniqueNativeFungible.soldiffbeforeafterboth12 function supportsInterface(bytes4 interfaceID) external view returns (bool);12 function supportsInterface(bytes4 interfaceID) external view returns (bool);13}13}141415/// @dev the ERC-165 identifier for this interface is 0xff15c6f415/// @dev the ERC-165 identifier for this interface is 0x1313556c16interface ERC20UniqueExtensions is Dummy, ERC165 {16interface ERC20UniqueExtensions is Dummy, ERC165 {17 /// @dev EVM selector for this function is: 0xec069398,18 /// or in textual repr: balanceOfCross((address,uint256))19 function balanceOfCross(CrossAddress memory owner) external view returns (uint256);2017 /// @dev EVM selector for this function is: 0x2ada85ff,21 /// @dev EVM selector for this function is: 0x2ada85ff,18 /// or in textual repr: transferCross((address,uint256),uint256)22 /// or in textual repr: transferCross((address,uint256),uint256)