Submitted by 0xTheC0der
According to the documentation (online and in-line), the availability of the balance_of() method (see code below) should be any contract instead of system only which is caused by the present ensure_system check.
The ensure_system() method returns a BadOrigin error in case the caller/origin is not the system contract.
The availability of the balance_of() method is limited to the system contract instead of being accessible to anyone. Therefore, user contracts relying on this method will inevitably fail.
For comparison:
The import_latest_system_code(...) method has consistent system only availability according to the implementation and documentation.
Please add the test case below to  phala-blockchain/crates/pink/runtime/tests/test_pink_contract.rs and run it with cargo test test_balance_of -- --nocapture.
The test will fail with a BadOrigin error as discussed above:
Remove the ensure_system check from the balance_of() method to ensure availability for any contract.
Invalid Validation
kvinwang (Phala) confirmed
