You have to remember that the Substrate runtime is generic over many types, including the AccountId
.
Function force_set_balance expects u64
If this is the case, then the context in which you are calling force_set_balance
has been configured for AccountId = u64
. This is usually the default configuration in tests, which is my guess where this is happening.
You can adjust your configuration to make AccountId = AccountId32
instead, and that will fix this problem.
You can find an example of that in the Polkadot integration tests: https://github.com/paritytech/polkadot-sdk/blob/master/polkadot/runtime/common/src/integration_tests.rs
Here you can see:
use sp_runtime::AccountId32;
type AccountId = AccountId32;
This being used in the configuration for frame_system
:
impl frame_system::Config for Test {
type AccountId = AccountId;
// ...
}
And some helpers to make generating unique AccountId32
more easy:
fn account_id(i: u32) -> AccountId32 {
let b4 = i.encode();
let b32 = [&b4[..], &b4[..], &b4[..], &b4[..], &b4[..], &b4[..], &b4[..], &b4[..]].concat();
let array: [u8; 32] = b32.try_into().unwrap();
array.into()
}
fn signed(i: u32) -> RuntimeOrigin {
let account_id = account_id(i);
RuntimeOrigin::signed(account_id)
}
So ultimately, go and check your frame_system
configuration and make sure your AccountId
type is what you want and expect.