---
# System prepended metadata

title: Type Decoding 26-jan

---

# Type Decoding 26-jan

```javascriot
const method = e?.values?.string_values?.message;
const accountInfoEncoded =
    method === 'clear'
        ? 'no-account'
        : (e?.values?.string_values?.res as string);

let accountInfo;
try {
    if (method === 'clear') {
        // Account was likely dusted. For now lets just assume we are ok
        // with the account balance
        // being zero. In the future this can have richer information
        accountInfo = this.registry.createType('AccountInfo');
    } else if (accountInfoEncoded.includes('None')) {
        accountInfo = this.registry.createType('AccountInfo');
    } else if (accountInfoEncoded?.slice(0, 5) === 'Some(') {
        // With the most recent PR to substrate state tracing only `get`
        // methods are wrapped in an options
        const len = accountInfoEncoded.length;
        const scale = accountInfoEncoded.slice(5, len - 1);
        accountInfo = (this.registry.createType(
            'AccountInfo',
            `0x${scale}`
        ) as unknown) as AccountInfo;
    } else {
        // This is likeley a `set` method (formely `put`) and as far as I 
        // can tell it is never wrapped in an option
        accountInfo = (this.registry.createType(
            'AccountInfo',
            `0x${accountInfoEncoded}`
        ) as unknown) as AccountInfo;
    }
} catch {
    throw new Error(
        'Expect there to always be some AccountInfo'
    );
}

```