difftreelog
feat balanceOfCross for fingible
in: master
8 files changed
pallets/fungible/src/erc.rsdiffbeforeafterboth--- a/pallets/fungible/src/erc.rs
+++ b/pallets/fungible/src/erc.rs
@@ -327,6 +327,15 @@
fn collection_helper_address(&self) -> Result<Address> {
Ok(T::ContractAddress::get())
}
+
+ /// @notice Balance of account
+ /// @param owner An cross address for whom to query the balance
+ /// @return The number of fingibles owned by `owner`, possibly zero
+ fn balance_of_cross(&self, owner: CrossAddress) -> Result<U256> {
+ self.consume_store_reads(1)?;
+ let balance = <Balance<T>>::get((self.id, owner.into_sub_cross_account::<T>()?));
+ Ok(balance.into())
+ }
}
#[solidity_interface(
pallets/fungible/src/stubs/UniqueFungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth--- a/pallets/fungible/src/stubs/UniqueFungible.sol
+++ b/pallets/fungible/src/stubs/UniqueFungible.sol
@@ -511,7 +511,7 @@
bytes value;
}
-/// @dev the ERC-165 identifier for this interface is 0x85d7dea6
+/// @dev the ERC-165 identifier for this interface is 0x69d14d3e
contract ERC20UniqueExtensions is Dummy, ERC165 {
/// @dev Function to check the amount of tokens that an owner allowed to a spender.
/// @param owner crossAddress The address which owns the funds.
@@ -630,6 +630,18 @@
dummy;
return 0x0000000000000000000000000000000000000000;
}
+
+ /// @notice Balance of account
+ /// @param owner An cross address for whom to query the balance
+ /// @return The number of fingibles owned by `owner`, possibly zero
+ /// @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;
+ }
}
struct AmountForAddress {
tests/src/eth/abi/fungible.jsondiffbeforeafterboth1[2 {3 "anonymous": false,4 "inputs": [5 {6 "indexed": true,7 "internalType": "address",8 "name": "owner",9 "type": "address"10 },11 {12 "indexed": true,13 "internalType": "address",14 "name": "spender",15 "type": "address"16 },17 {18 "indexed": false,19 "internalType": "uint256",20 "name": "value",21 "type": "uint256"22 }23 ],24 "name": "Approval",25 "type": "event"26 },27 {28 "anonymous": false,29 "inputs": [30 {31 "indexed": true,32 "internalType": "address",33 "name": "from",34 "type": "address"35 },36 {37 "indexed": true,38 "internalType": "address",39 "name": "to",40 "type": "address"41 },42 {43 "indexed": false,44 "internalType": "uint256",45 "name": "value",46 "type": "uint256"47 }48 ],49 "name": "Transfer",50 "type": "event"51 },52 {53 "inputs": [54 {55 "components": [56 { "internalType": "address", "name": "eth", "type": "address" },57 { "internalType": "uint256", "name": "sub", "type": "uint256" }58 ],59 "internalType": "struct CrossAddress",60 "name": "newAdmin",61 "type": "tuple"62 }63 ],64 "name": "addCollectionAdminCross",65 "outputs": [],66 "stateMutability": "nonpayable",67 "type": "function"68 },69 {70 "inputs": [71 {72 "components": [73 { "internalType": "address", "name": "eth", "type": "address" },74 { "internalType": "uint256", "name": "sub", "type": "uint256" }75 ],76 "internalType": "struct CrossAddress",77 "name": "user",78 "type": "tuple"79 }80 ],81 "name": "addToCollectionAllowListCross",82 "outputs": [],83 "stateMutability": "nonpayable",84 "type": "function"85 },86 {87 "inputs": [88 { "internalType": "address", "name": "owner", "type": "address" },89 { "internalType": "address", "name": "spender", "type": "address" }90 ],91 "name": "allowance",92 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],93 "stateMutability": "view",94 "type": "function"95 },96 {97 "inputs": [98 {99 "components": [100 { "internalType": "address", "name": "eth", "type": "address" },101 { "internalType": "uint256", "name": "sub", "type": "uint256" }102 ],103 "internalType": "struct CrossAddress",104 "name": "owner",105 "type": "tuple"106 },107 {108 "components": [109 { "internalType": "address", "name": "eth", "type": "address" },110 { "internalType": "uint256", "name": "sub", "type": "uint256" }111 ],112 "internalType": "struct CrossAddress",113 "name": "spender",114 "type": "tuple"115 }116 ],117 "name": "allowanceCross",118 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],119 "stateMutability": "view",120 "type": "function"121 },122 {123 "inputs": [124 {125 "components": [126 { "internalType": "address", "name": "eth", "type": "address" },127 { "internalType": "uint256", "name": "sub", "type": "uint256" }128 ],129 "internalType": "struct CrossAddress",130 "name": "user",131 "type": "tuple"132 }133 ],134 "name": "allowlistedCross",135 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],136 "stateMutability": "view",137 "type": "function"138 },139 {140 "inputs": [141 { "internalType": "address", "name": "spender", "type": "address" },142 { "internalType": "uint256", "name": "amount", "type": "uint256" }143 ],144 "name": "approve",145 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],146 "stateMutability": "nonpayable",147 "type": "function"148 },149 {150 "inputs": [151 {152 "components": [153 { "internalType": "address", "name": "eth", "type": "address" },154 { "internalType": "uint256", "name": "sub", "type": "uint256" }155 ],156 "internalType": "struct CrossAddress",157 "name": "spender",158 "type": "tuple"159 },160 { "internalType": "uint256", "name": "amount", "type": "uint256" }161 ],162 "name": "approveCross",163 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],164 "stateMutability": "nonpayable",165 "type": "function"166 },167 {168 "inputs": [169 { "internalType": "address", "name": "owner", "type": "address" }170 ],171 "name": "balanceOf",172 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],173 "stateMutability": "view",174 "type": "function"175 },176 {177 "inputs": [178 {179 "components": [180 { "internalType": "address", "name": "eth", "type": "address" },181 { "internalType": "uint256", "name": "sub", "type": "uint256" }182 ],183 "internalType": "struct CrossAddress",184 "name": "from",185 "type": "tuple"186 },187 { "internalType": "uint256", "name": "amount", "type": "uint256" }188 ],189 "name": "burnFromCross",190 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],191 "stateMutability": "nonpayable",192 "type": "function"193 },194 {195 "inputs": [196 {197 "components": [198 { "internalType": "address", "name": "eth", "type": "address" },199 { "internalType": "uint256", "name": "sub", "type": "uint256" }200 ],201 "internalType": "struct CrossAddress",202 "name": "newOwner",203 "type": "tuple"204 }205 ],206 "name": "changeCollectionOwnerCross",207 "outputs": [],208 "stateMutability": "nonpayable",209 "type": "function"210 },211 {212 "inputs": [],213 "name": "collectionAdmins",214 "outputs": [215 {216 "components": [217 { "internalType": "address", "name": "eth", "type": "address" },218 { "internalType": "uint256", "name": "sub", "type": "uint256" }219 ],220 "internalType": "struct CrossAddress[]",221 "name": "",222 "type": "tuple[]"223 }224 ],225 "stateMutability": "view",226 "type": "function"227 },228 {229 "inputs": [],230 "name": "collectionHelperAddress",231 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],232 "stateMutability": "view",233 "type": "function"234 },235 {236 "inputs": [],237 "name": "collectionLimits",238 "outputs": [239 {240 "components": [241 {242 "internalType": "enum CollectionLimitField",243 "name": "field",244 "type": "uint8"245 },246 {247 "components": [248 { "internalType": "bool", "name": "status", "type": "bool" },249 { "internalType": "uint256", "name": "value", "type": "uint256" }250 ],251 "internalType": "struct OptionUint256",252 "name": "value",253 "type": "tuple"254 }255 ],256 "internalType": "struct CollectionLimit[]",257 "name": "",258 "type": "tuple[]"259 }260 ],261 "stateMutability": "view",262 "type": "function"263 },264 {265 "inputs": [],266 "name": "collectionNestingPermissions",267 "outputs": [268 {269 "components": [270 {271 "internalType": "enum CollectionPermissionField",272 "name": "field",273 "type": "uint8"274 },275 { "internalType": "bool", "name": "value", "type": "bool" }276 ],277 "internalType": "struct CollectionNestingPermission[]",278 "name": "",279 "type": "tuple[]"280 }281 ],282 "stateMutability": "view",283 "type": "function"284 },285 {286 "inputs": [],287 "name": "collectionNestingRestrictedCollectionIds",288 "outputs": [289 {290 "components": [291 { "internalType": "bool", "name": "token_owner", "type": "bool" },292 { "internalType": "uint256[]", "name": "ids", "type": "uint256[]" }293 ],294 "internalType": "struct CollectionNesting",295 "name": "",296 "type": "tuple"297 }298 ],299 "stateMutability": "view",300 "type": "function"301 },302 {303 "inputs": [],304 "name": "collectionOwner",305 "outputs": [306 {307 "components": [308 { "internalType": "address", "name": "eth", "type": "address" },309 { "internalType": "uint256", "name": "sub", "type": "uint256" }310 ],311 "internalType": "struct CrossAddress",312 "name": "",313 "type": "tuple"314 }315 ],316 "stateMutability": "view",317 "type": "function"318 },319 {320 "inputs": [321 { "internalType": "string[]", "name": "keys", "type": "string[]" }322 ],323 "name": "collectionProperties",324 "outputs": [325 {326 "components": [327 { "internalType": "string", "name": "key", "type": "string" },328 { "internalType": "bytes", "name": "value", "type": "bytes" }329 ],330 "internalType": "struct Property[]",331 "name": "",332 "type": "tuple[]"333 }334 ],335 "stateMutability": "view",336 "type": "function"337 },338 {339 "inputs": [{ "internalType": "string", "name": "key", "type": "string" }],340 "name": "collectionProperty",341 "outputs": [{ "internalType": "bytes", "name": "", "type": "bytes" }],342 "stateMutability": "view",343 "type": "function"344 },345 {346 "inputs": [],347 "name": "collectionSponsor",348 "outputs": [349 {350 "components": [351 { "internalType": "address", "name": "eth", "type": "address" },352 { "internalType": "uint256", "name": "sub", "type": "uint256" }353 ],354 "internalType": "struct CrossAddress",355 "name": "",356 "type": "tuple"357 }358 ],359 "stateMutability": "view",360 "type": "function"361 },362 {363 "inputs": [],364 "name": "confirmCollectionSponsorship",365 "outputs": [],366 "stateMutability": "nonpayable",367 "type": "function"368 },369 {370 "inputs": [],371 "name": "contractAddress",372 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],373 "stateMutability": "view",374 "type": "function"375 },376 {377 "inputs": [],378 "name": "decimals",379 "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }],380 "stateMutability": "view",381 "type": "function"382 },383 {384 "inputs": [385 { "internalType": "string[]", "name": "keys", "type": "string[]" }386 ],387 "name": "deleteCollectionProperties",388 "outputs": [],389 "stateMutability": "nonpayable",390 "type": "function"391 },392 {393 "inputs": [],394 "name": "description",395 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],396 "stateMutability": "view",397 "type": "function"398 },399 {400 "inputs": [],401 "name": "hasCollectionPendingSponsor",402 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],403 "stateMutability": "view",404 "type": "function"405 },406 {407 "inputs": [408 {409 "components": [410 { "internalType": "address", "name": "eth", "type": "address" },411 { "internalType": "uint256", "name": "sub", "type": "uint256" }412 ],413 "internalType": "struct CrossAddress",414 "name": "user",415 "type": "tuple"416 }417 ],418 "name": "isOwnerOrAdminCross",419 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],420 "stateMutability": "view",421 "type": "function"422 },423 {424 "inputs": [425 { "internalType": "address", "name": "to", "type": "address" },426 { "internalType": "uint256", "name": "amount", "type": "uint256" }427 ],428 "name": "mint",429 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],430 "stateMutability": "nonpayable",431 "type": "function"432 },433 {434 "inputs": [435 {436 "components": [437 { "internalType": "address", "name": "to", "type": "address" },438 { "internalType": "uint256", "name": "amount", "type": "uint256" }439 ],440 "internalType": "struct AmountForAddress[]",441 "name": "amounts",442 "type": "tuple[]"443 }444 ],445 "name": "mintBulk",446 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],447 "stateMutability": "nonpayable",448 "type": "function"449 },450 {451 "inputs": [452 {453 "components": [454 { "internalType": "address", "name": "eth", "type": "address" },455 { "internalType": "uint256", "name": "sub", "type": "uint256" }456 ],457 "internalType": "struct CrossAddress",458 "name": "to",459 "type": "tuple"460 },461 { "internalType": "uint256", "name": "amount", "type": "uint256" }462 ],463 "name": "mintCross",464 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],465 "stateMutability": "nonpayable",466 "type": "function"467 },468 {469 "inputs": [],470 "name": "name",471 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],472 "stateMutability": "view",473 "type": "function"474 },475 {476 "inputs": [477 {478 "components": [479 { "internalType": "address", "name": "eth", "type": "address" },480 { "internalType": "uint256", "name": "sub", "type": "uint256" }481 ],482 "internalType": "struct CrossAddress",483 "name": "admin",484 "type": "tuple"485 }486 ],487 "name": "removeCollectionAdminCross",488 "outputs": [],489 "stateMutability": "nonpayable",490 "type": "function"491 },492 {493 "inputs": [],494 "name": "removeCollectionSponsor",495 "outputs": [],496 "stateMutability": "nonpayable",497 "type": "function"498 },499 {500 "inputs": [501 {502 "components": [503 { "internalType": "address", "name": "eth", "type": "address" },504 { "internalType": "uint256", "name": "sub", "type": "uint256" }505 ],506 "internalType": "struct CrossAddress",507 "name": "user",508 "type": "tuple"509 }510 ],511 "name": "removeFromCollectionAllowListCross",512 "outputs": [],513 "stateMutability": "nonpayable",514 "type": "function"515 },516 {517 "inputs": [518 { "internalType": "enum AccessMode", "name": "mode", "type": "uint8" }519 ],520 "name": "setCollectionAccess",521 "outputs": [],522 "stateMutability": "nonpayable",523 "type": "function"524 },525 {526 "inputs": [527 {528 "components": [529 {530 "internalType": "enum CollectionLimitField",531 "name": "field",532 "type": "uint8"533 },534 {535 "components": [536 { "internalType": "bool", "name": "status", "type": "bool" },537 { "internalType": "uint256", "name": "value", "type": "uint256" }538 ],539 "internalType": "struct OptionUint256",540 "name": "value",541 "type": "tuple"542 }543 ],544 "internalType": "struct CollectionLimit",545 "name": "limit",546 "type": "tuple"547 }548 ],549 "name": "setCollectionLimit",550 "outputs": [],551 "stateMutability": "nonpayable",552 "type": "function"553 },554 {555 "inputs": [{ "internalType": "bool", "name": "mode", "type": "bool" }],556 "name": "setCollectionMintMode",557 "outputs": [],558 "stateMutability": "nonpayable",559 "type": "function"560 },561 {562 "inputs": [{ "internalType": "bool", "name": "enable", "type": "bool" }],563 "name": "setCollectionNesting",564 "outputs": [],565 "stateMutability": "nonpayable",566 "type": "function"567 },568 {569 "inputs": [570 { "internalType": "bool", "name": "enable", "type": "bool" },571 {572 "internalType": "address[]",573 "name": "collections",574 "type": "address[]"575 }576 ],577 "name": "setCollectionNesting",578 "outputs": [],579 "stateMutability": "nonpayable",580 "type": "function"581 },582 {583 "inputs": [584 {585 "components": [586 { "internalType": "string", "name": "key", "type": "string" },587 { "internalType": "bytes", "name": "value", "type": "bytes" }588 ],589 "internalType": "struct Property[]",590 "name": "properties",591 "type": "tuple[]"592 }593 ],594 "name": "setCollectionProperties",595 "outputs": [],596 "stateMutability": "nonpayable",597 "type": "function"598 },599 {600 "inputs": [601 {602 "components": [603 { "internalType": "address", "name": "eth", "type": "address" },604 { "internalType": "uint256", "name": "sub", "type": "uint256" }605 ],606 "internalType": "struct CrossAddress",607 "name": "sponsor",608 "type": "tuple"609 }610 ],611 "name": "setCollectionSponsorCross",612 "outputs": [],613 "stateMutability": "nonpayable",614 "type": "function"615 },616 {617 "inputs": [618 { "internalType": "bytes4", "name": "interfaceID", "type": "bytes4" }619 ],620 "name": "supportsInterface",621 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],622 "stateMutability": "view",623 "type": "function"624 },625 {626 "inputs": [],627 "name": "symbol",628 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],629 "stateMutability": "view",630 "type": "function"631 },632 {633 "inputs": [],634 "name": "totalSupply",635 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],636 "stateMutability": "view",637 "type": "function"638 },639 {640 "inputs": [641 { "internalType": "address", "name": "to", "type": "address" },642 { "internalType": "uint256", "name": "amount", "type": "uint256" }643 ],644 "name": "transfer",645 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],646 "stateMutability": "nonpayable",647 "type": "function"648 },649 {650 "inputs": [651 {652 "components": [653 { "internalType": "address", "name": "eth", "type": "address" },654 { "internalType": "uint256", "name": "sub", "type": "uint256" }655 ],656 "internalType": "struct CrossAddress",657 "name": "to",658 "type": "tuple"659 },660 { "internalType": "uint256", "name": "amount", "type": "uint256" }661 ],662 "name": "transferCross",663 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],664 "stateMutability": "nonpayable",665 "type": "function"666 },667 {668 "inputs": [669 { "internalType": "address", "name": "from", "type": "address" },670 { "internalType": "address", "name": "to", "type": "address" },671 { "internalType": "uint256", "name": "amount", "type": "uint256" }672 ],673 "name": "transferFrom",674 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],675 "stateMutability": "nonpayable",676 "type": "function"677 },678 {679 "inputs": [680 {681 "components": [682 { "internalType": "address", "name": "eth", "type": "address" },683 { "internalType": "uint256", "name": "sub", "type": "uint256" }684 ],685 "internalType": "struct CrossAddress",686 "name": "from",687 "type": "tuple"688 },689 {690 "components": [691 { "internalType": "address", "name": "eth", "type": "address" },692 { "internalType": "uint256", "name": "sub", "type": "uint256" }693 ],694 "internalType": "struct CrossAddress",695 "name": "to",696 "type": "tuple"697 },698 { "internalType": "uint256", "name": "amount", "type": "uint256" }699 ],700 "name": "transferFromCross",701 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],702 "stateMutability": "nonpayable",703 "type": "function"704 },705 {706 "inputs": [],707 "name": "uniqueCollectionType",708 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],709 "stateMutability": "view",710 "type": "function"711 }712]1[2 {3 "anonymous": false,4 "inputs": [5 {6 "indexed": true,7 "internalType": "address",8 "name": "owner",9 "type": "address"10 },11 {12 "indexed": true,13 "internalType": "address",14 "name": "spender",15 "type": "address"16 },17 {18 "indexed": false,19 "internalType": "uint256",20 "name": "value",21 "type": "uint256"22 }23 ],24 "name": "Approval",25 "type": "event"26 },27 {28 "anonymous": false,29 "inputs": [30 {31 "indexed": true,32 "internalType": "address",33 "name": "from",34 "type": "address"35 },36 {37 "indexed": true,38 "internalType": "address",39 "name": "to",40 "type": "address"41 },42 {43 "indexed": false,44 "internalType": "uint256",45 "name": "value",46 "type": "uint256"47 }48 ],49 "name": "Transfer",50 "type": "event"51 },52 {53 "inputs": [54 {55 "components": [56 { "internalType": "address", "name": "eth", "type": "address" },57 { "internalType": "uint256", "name": "sub", "type": "uint256" }58 ],59 "internalType": "struct CrossAddress",60 "name": "newAdmin",61 "type": "tuple"62 }63 ],64 "name": "addCollectionAdminCross",65 "outputs": [],66 "stateMutability": "nonpayable",67 "type": "function"68 },69 {70 "inputs": [71 {72 "components": [73 { "internalType": "address", "name": "eth", "type": "address" },74 { "internalType": "uint256", "name": "sub", "type": "uint256" }75 ],76 "internalType": "struct CrossAddress",77 "name": "user",78 "type": "tuple"79 }80 ],81 "name": "addToCollectionAllowListCross",82 "outputs": [],83 "stateMutability": "nonpayable",84 "type": "function"85 },86 {87 "inputs": [88 { "internalType": "address", "name": "owner", "type": "address" },89 { "internalType": "address", "name": "spender", "type": "address" }90 ],91 "name": "allowance",92 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],93 "stateMutability": "view",94 "type": "function"95 },96 {97 "inputs": [98 {99 "components": [100 { "internalType": "address", "name": "eth", "type": "address" },101 { "internalType": "uint256", "name": "sub", "type": "uint256" }102 ],103 "internalType": "struct CrossAddress",104 "name": "owner",105 "type": "tuple"106 },107 {108 "components": [109 { "internalType": "address", "name": "eth", "type": "address" },110 { "internalType": "uint256", "name": "sub", "type": "uint256" }111 ],112 "internalType": "struct CrossAddress",113 "name": "spender",114 "type": "tuple"115 }116 ],117 "name": "allowanceCross",118 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],119 "stateMutability": "view",120 "type": "function"121 },122 {123 "inputs": [124 {125 "components": [126 { "internalType": "address", "name": "eth", "type": "address" },127 { "internalType": "uint256", "name": "sub", "type": "uint256" }128 ],129 "internalType": "struct CrossAddress",130 "name": "user",131 "type": "tuple"132 }133 ],134 "name": "allowlistedCross",135 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],136 "stateMutability": "view",137 "type": "function"138 },139 {140 "inputs": [141 { "internalType": "address", "name": "spender", "type": "address" },142 { "internalType": "uint256", "name": "amount", "type": "uint256" }143 ],144 "name": "approve",145 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],146 "stateMutability": "nonpayable",147 "type": "function"148 },149 {150 "inputs": [151 {152 "components": [153 { "internalType": "address", "name": "eth", "type": "address" },154 { "internalType": "uint256", "name": "sub", "type": "uint256" }155 ],156 "internalType": "struct CrossAddress",157 "name": "spender",158 "type": "tuple"159 },160 { "internalType": "uint256", "name": "amount", "type": "uint256" }161 ],162 "name": "approveCross",163 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],164 "stateMutability": "nonpayable",165 "type": "function"166 },167 {168 "inputs": [169 { "internalType": "address", "name": "owner", "type": "address" }170 ],171 "name": "balanceOf",172 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],173 "stateMutability": "view",174 "type": "function"175 },176 {177 "inputs": [178 {179 "components": [180 { "internalType": "address", "name": "eth", "type": "address" },181 { "internalType": "uint256", "name": "sub", "type": "uint256" }182 ],183 "internalType": "struct CrossAddress",184 "name": "owner",185 "type": "tuple"186 }187 ],188 "name": "balanceOfCross",189 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],190 "stateMutability": "view",191 "type": "function"192 },193 {194 "inputs": [195 {196 "components": [197 { "internalType": "address", "name": "eth", "type": "address" },198 { "internalType": "uint256", "name": "sub", "type": "uint256" }199 ],200 "internalType": "struct CrossAddress",201 "name": "from",202 "type": "tuple"203 },204 { "internalType": "uint256", "name": "amount", "type": "uint256" }205 ],206 "name": "burnFromCross",207 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],208 "stateMutability": "nonpayable",209 "type": "function"210 },211 {212 "inputs": [213 {214 "components": [215 { "internalType": "address", "name": "eth", "type": "address" },216 { "internalType": "uint256", "name": "sub", "type": "uint256" }217 ],218 "internalType": "struct CrossAddress",219 "name": "newOwner",220 "type": "tuple"221 }222 ],223 "name": "changeCollectionOwnerCross",224 "outputs": [],225 "stateMutability": "nonpayable",226 "type": "function"227 },228 {229 "inputs": [],230 "name": "collectionAdmins",231 "outputs": [232 {233 "components": [234 { "internalType": "address", "name": "eth", "type": "address" },235 { "internalType": "uint256", "name": "sub", "type": "uint256" }236 ],237 "internalType": "struct CrossAddress[]",238 "name": "",239 "type": "tuple[]"240 }241 ],242 "stateMutability": "view",243 "type": "function"244 },245 {246 "inputs": [],247 "name": "collectionHelperAddress",248 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],249 "stateMutability": "view",250 "type": "function"251 },252 {253 "inputs": [],254 "name": "collectionLimits",255 "outputs": [256 {257 "components": [258 {259 "internalType": "enum CollectionLimitField",260 "name": "field",261 "type": "uint8"262 },263 {264 "components": [265 { "internalType": "bool", "name": "status", "type": "bool" },266 { "internalType": "uint256", "name": "value", "type": "uint256" }267 ],268 "internalType": "struct OptionUint256",269 "name": "value",270 "type": "tuple"271 }272 ],273 "internalType": "struct CollectionLimit[]",274 "name": "",275 "type": "tuple[]"276 }277 ],278 "stateMutability": "view",279 "type": "function"280 },281 {282 "inputs": [],283 "name": "collectionNestingPermissions",284 "outputs": [285 {286 "components": [287 {288 "internalType": "enum CollectionPermissionField",289 "name": "field",290 "type": "uint8"291 },292 { "internalType": "bool", "name": "value", "type": "bool" }293 ],294 "internalType": "struct CollectionNestingPermission[]",295 "name": "",296 "type": "tuple[]"297 }298 ],299 "stateMutability": "view",300 "type": "function"301 },302 {303 "inputs": [],304 "name": "collectionNestingRestrictedCollectionIds",305 "outputs": [306 {307 "components": [308 { "internalType": "bool", "name": "token_owner", "type": "bool" },309 { "internalType": "uint256[]", "name": "ids", "type": "uint256[]" }310 ],311 "internalType": "struct CollectionNesting",312 "name": "",313 "type": "tuple"314 }315 ],316 "stateMutability": "view",317 "type": "function"318 },319 {320 "inputs": [],321 "name": "collectionOwner",322 "outputs": [323 {324 "components": [325 { "internalType": "address", "name": "eth", "type": "address" },326 { "internalType": "uint256", "name": "sub", "type": "uint256" }327 ],328 "internalType": "struct CrossAddress",329 "name": "",330 "type": "tuple"331 }332 ],333 "stateMutability": "view",334 "type": "function"335 },336 {337 "inputs": [338 { "internalType": "string[]", "name": "keys", "type": "string[]" }339 ],340 "name": "collectionProperties",341 "outputs": [342 {343 "components": [344 { "internalType": "string", "name": "key", "type": "string" },345 { "internalType": "bytes", "name": "value", "type": "bytes" }346 ],347 "internalType": "struct Property[]",348 "name": "",349 "type": "tuple[]"350 }351 ],352 "stateMutability": "view",353 "type": "function"354 },355 {356 "inputs": [{ "internalType": "string", "name": "key", "type": "string" }],357 "name": "collectionProperty",358 "outputs": [{ "internalType": "bytes", "name": "", "type": "bytes" }],359 "stateMutability": "view",360 "type": "function"361 },362 {363 "inputs": [],364 "name": "collectionSponsor",365 "outputs": [366 {367 "components": [368 { "internalType": "address", "name": "eth", "type": "address" },369 { "internalType": "uint256", "name": "sub", "type": "uint256" }370 ],371 "internalType": "struct CrossAddress",372 "name": "",373 "type": "tuple"374 }375 ],376 "stateMutability": "view",377 "type": "function"378 },379 {380 "inputs": [],381 "name": "confirmCollectionSponsorship",382 "outputs": [],383 "stateMutability": "nonpayable",384 "type": "function"385 },386 {387 "inputs": [],388 "name": "contractAddress",389 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],390 "stateMutability": "view",391 "type": "function"392 },393 {394 "inputs": [],395 "name": "decimals",396 "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }],397 "stateMutability": "view",398 "type": "function"399 },400 {401 "inputs": [402 { "internalType": "string[]", "name": "keys", "type": "string[]" }403 ],404 "name": "deleteCollectionProperties",405 "outputs": [],406 "stateMutability": "nonpayable",407 "type": "function"408 },409 {410 "inputs": [],411 "name": "description",412 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],413 "stateMutability": "view",414 "type": "function"415 },416 {417 "inputs": [],418 "name": "hasCollectionPendingSponsor",419 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],420 "stateMutability": "view",421 "type": "function"422 },423 {424 "inputs": [425 {426 "components": [427 { "internalType": "address", "name": "eth", "type": "address" },428 { "internalType": "uint256", "name": "sub", "type": "uint256" }429 ],430 "internalType": "struct CrossAddress",431 "name": "user",432 "type": "tuple"433 }434 ],435 "name": "isOwnerOrAdminCross",436 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],437 "stateMutability": "view",438 "type": "function"439 },440 {441 "inputs": [442 { "internalType": "address", "name": "to", "type": "address" },443 { "internalType": "uint256", "name": "amount", "type": "uint256" }444 ],445 "name": "mint",446 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],447 "stateMutability": "nonpayable",448 "type": "function"449 },450 {451 "inputs": [452 {453 "components": [454 { "internalType": "address", "name": "to", "type": "address" },455 { "internalType": "uint256", "name": "amount", "type": "uint256" }456 ],457 "internalType": "struct AmountForAddress[]",458 "name": "amounts",459 "type": "tuple[]"460 }461 ],462 "name": "mintBulk",463 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],464 "stateMutability": "nonpayable",465 "type": "function"466 },467 {468 "inputs": [469 {470 "components": [471 { "internalType": "address", "name": "eth", "type": "address" },472 { "internalType": "uint256", "name": "sub", "type": "uint256" }473 ],474 "internalType": "struct CrossAddress",475 "name": "to",476 "type": "tuple"477 },478 { "internalType": "uint256", "name": "amount", "type": "uint256" }479 ],480 "name": "mintCross",481 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],482 "stateMutability": "nonpayable",483 "type": "function"484 },485 {486 "inputs": [],487 "name": "name",488 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],489 "stateMutability": "view",490 "type": "function"491 },492 {493 "inputs": [494 {495 "components": [496 { "internalType": "address", "name": "eth", "type": "address" },497 { "internalType": "uint256", "name": "sub", "type": "uint256" }498 ],499 "internalType": "struct CrossAddress",500 "name": "admin",501 "type": "tuple"502 }503 ],504 "name": "removeCollectionAdminCross",505 "outputs": [],506 "stateMutability": "nonpayable",507 "type": "function"508 },509 {510 "inputs": [],511 "name": "removeCollectionSponsor",512 "outputs": [],513 "stateMutability": "nonpayable",514 "type": "function"515 },516 {517 "inputs": [518 {519 "components": [520 { "internalType": "address", "name": "eth", "type": "address" },521 { "internalType": "uint256", "name": "sub", "type": "uint256" }522 ],523 "internalType": "struct CrossAddress",524 "name": "user",525 "type": "tuple"526 }527 ],528 "name": "removeFromCollectionAllowListCross",529 "outputs": [],530 "stateMutability": "nonpayable",531 "type": "function"532 },533 {534 "inputs": [535 { "internalType": "enum AccessMode", "name": "mode", "type": "uint8" }536 ],537 "name": "setCollectionAccess",538 "outputs": [],539 "stateMutability": "nonpayable",540 "type": "function"541 },542 {543 "inputs": [544 {545 "components": [546 {547 "internalType": "enum CollectionLimitField",548 "name": "field",549 "type": "uint8"550 },551 {552 "components": [553 { "internalType": "bool", "name": "status", "type": "bool" },554 { "internalType": "uint256", "name": "value", "type": "uint256" }555 ],556 "internalType": "struct OptionUint256",557 "name": "value",558 "type": "tuple"559 }560 ],561 "internalType": "struct CollectionLimit",562 "name": "limit",563 "type": "tuple"564 }565 ],566 "name": "setCollectionLimit",567 "outputs": [],568 "stateMutability": "nonpayable",569 "type": "function"570 },571 {572 "inputs": [{ "internalType": "bool", "name": "mode", "type": "bool" }],573 "name": "setCollectionMintMode",574 "outputs": [],575 "stateMutability": "nonpayable",576 "type": "function"577 },578 {579 "inputs": [{ "internalType": "bool", "name": "enable", "type": "bool" }],580 "name": "setCollectionNesting",581 "outputs": [],582 "stateMutability": "nonpayable",583 "type": "function"584 },585 {586 "inputs": [587 { "internalType": "bool", "name": "enable", "type": "bool" },588 {589 "internalType": "address[]",590 "name": "collections",591 "type": "address[]"592 }593 ],594 "name": "setCollectionNesting",595 "outputs": [],596 "stateMutability": "nonpayable",597 "type": "function"598 },599 {600 "inputs": [601 {602 "components": [603 { "internalType": "string", "name": "key", "type": "string" },604 { "internalType": "bytes", "name": "value", "type": "bytes" }605 ],606 "internalType": "struct Property[]",607 "name": "properties",608 "type": "tuple[]"609 }610 ],611 "name": "setCollectionProperties",612 "outputs": [],613 "stateMutability": "nonpayable",614 "type": "function"615 },616 {617 "inputs": [618 {619 "components": [620 { "internalType": "address", "name": "eth", "type": "address" },621 { "internalType": "uint256", "name": "sub", "type": "uint256" }622 ],623 "internalType": "struct CrossAddress",624 "name": "sponsor",625 "type": "tuple"626 }627 ],628 "name": "setCollectionSponsorCross",629 "outputs": [],630 "stateMutability": "nonpayable",631 "type": "function"632 },633 {634 "inputs": [635 { "internalType": "bytes4", "name": "interfaceID", "type": "bytes4" }636 ],637 "name": "supportsInterface",638 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],639 "stateMutability": "view",640 "type": "function"641 },642 {643 "inputs": [],644 "name": "symbol",645 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],646 "stateMutability": "view",647 "type": "function"648 },649 {650 "inputs": [],651 "name": "totalSupply",652 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],653 "stateMutability": "view",654 "type": "function"655 },656 {657 "inputs": [658 { "internalType": "address", "name": "to", "type": "address" },659 { "internalType": "uint256", "name": "amount", "type": "uint256" }660 ],661 "name": "transfer",662 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],663 "stateMutability": "nonpayable",664 "type": "function"665 },666 {667 "inputs": [668 {669 "components": [670 { "internalType": "address", "name": "eth", "type": "address" },671 { "internalType": "uint256", "name": "sub", "type": "uint256" }672 ],673 "internalType": "struct CrossAddress",674 "name": "to",675 "type": "tuple"676 },677 { "internalType": "uint256", "name": "amount", "type": "uint256" }678 ],679 "name": "transferCross",680 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],681 "stateMutability": "nonpayable",682 "type": "function"683 },684 {685 "inputs": [686 { "internalType": "address", "name": "from", "type": "address" },687 { "internalType": "address", "name": "to", "type": "address" },688 { "internalType": "uint256", "name": "amount", "type": "uint256" }689 ],690 "name": "transferFrom",691 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],692 "stateMutability": "nonpayable",693 "type": "function"694 },695 {696 "inputs": [697 {698 "components": [699 { "internalType": "address", "name": "eth", "type": "address" },700 { "internalType": "uint256", "name": "sub", "type": "uint256" }701 ],702 "internalType": "struct CrossAddress",703 "name": "from",704 "type": "tuple"705 },706 {707 "components": [708 { "internalType": "address", "name": "eth", "type": "address" },709 { "internalType": "uint256", "name": "sub", "type": "uint256" }710 ],711 "internalType": "struct CrossAddress",712 "name": "to",713 "type": "tuple"714 },715 { "internalType": "uint256", "name": "amount", "type": "uint256" }716 ],717 "name": "transferFromCross",718 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],719 "stateMutability": "nonpayable",720 "type": "function"721 },722 {723 "inputs": [],724 "name": "uniqueCollectionType",725 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],726 "stateMutability": "view",727 "type": "function"728 }729]tests/src/eth/api/UniqueFungible.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueFungible.sol
+++ b/tests/src/eth/api/UniqueFungible.sol
@@ -353,7 +353,7 @@
bytes value;
}
-/// @dev the ERC-165 identifier for this interface is 0x85d7dea6
+/// @dev the ERC-165 identifier for this interface is 0x69d14d3e
interface ERC20UniqueExtensions is Dummy, ERC165 {
/// @dev Function to check the amount of tokens that an owner allowed to a spender.
/// @param owner crossAddress The address which owns the funds.
@@ -416,6 +416,13 @@
/// @dev EVM selector for this function is: 0x1896cce6,
/// or in textual repr: collectionHelperAddress()
function collectionHelperAddress() external view returns (address);
+
+ /// @notice Balance of account
+ /// @param owner An cross address for whom to query the balance
+ /// @return The number of fingibles owned by `owner`, possibly zero
+ /// @dev EVM selector for this function is: 0xec069398,
+ /// or in textual repr: balanceOfCross((address,uint256))
+ function balanceOfCross(CrossAddress memory owner) external view returns (uint256);
}
struct AmountForAddress {
tests/src/eth/fungible.test.tsdiffbeforeafterboth--- a/tests/src/eth/fungible.test.ts
+++ b/tests/src/eth/fungible.test.ts
@@ -427,6 +427,22 @@
const toBalanceAfter = await collection.getBalance({Ethereum: receiver});
expect(toBalanceAfter - toBalanceBefore).to.be.eq(51n);
});
+
+ itEth('Check balanceOfCross()', async ({helper}) => {
+ const collection = await helper.ft.mintCollection(alice, {});
+ const owner = await helper.ethCrossAccount.createAccountWithBalance(donor);
+ const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);
+ const collectionEvm = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner.eth);
+
+ expect(BigInt(await collectionEvm.methods.balanceOfCross(owner).call({from: owner.eth})) === 0n).to.be.true;
+
+ let sum = 0n;
+ for (let i = 1n; i < 100n; i++) {
+ await collection.mint(alice, 100n, {Ethereum: owner.eth});
+ sum += 100n;
+ expect(BigInt(await collectionEvm.methods.balanceOfCross(owner).call({from: owner.eth})) === sum).to.be.true;
+ }
+ });
});
describe('Fungible: Fees', () => {
tests/src/eth/reFungible.test.tsdiffbeforeafterboth--- a/tests/src/eth/reFungible.test.ts
+++ b/tests/src/eth/reFungible.test.ts
@@ -585,7 +585,7 @@
expect(event.returnValues.tokenId).to.equal(tokenId.toString());
});
- itEth('Check crossBalanceOf()', async ({helper}) => {
+ itEth('Check balanceOfCross()', async ({helper}) => {
const collection = await helper.rft.mintCollection(minter, {});
const owner = await helper.ethCrossAccount.createAccountWithBalance(donor);
const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);
tests/src/eth/tokens/minting.test.tsdiffbeforeafterboth--- a/tests/src/eth/tokens/minting.test.ts
+++ b/tests/src/eth/tokens/minting.test.ts
@@ -19,7 +19,7 @@
import {expect, itEth, usingEthPlaygrounds} from '../util';
-describe.only('Minting tokens', () => {
+describe('Minting tokens', () => {
let donor: IKeyringPair;
let alice: IKeyringPair;