lib/serializer/src/types.js
function(reserved_spaces, object_type){
    v.required(reserved_spaces, "reserved_spaces");
    v.required(object_type, "object_type");
    return {fromByteBuffer(b){
        return b.readVarint32();
    },
    appendByteBuffer(b, object){
        v.required(object);
        if (object.resolve !== undefined) { object = object.resolve; }
        // convert 1.2.n into just n
        if (/^[0-9]+\.[0-9]+\.[0-9]+$/.test(object)) {
            object = v.get_instance(reserved_spaces, object_type, object);
        }
        b.writeVarint32(v.to_number(object));
        return;
    },
    fromObject(object){
        v.required(object);
        if (object.resolve !== undefined) { object = object.resolve; }
        if (v.is_digits(object)) {
            return v.to_number(object);
        }
        return v.get_instance(reserved_spaces, object_type, object);
    },
    toObject(object, debug = {}){
        var object_type_id = ChainTypes.object_type[object_type];
        if (debug.use_default && object === undefined) {
            return `${reserved_spaces}.${object_type_id}.0`;
        }
        v.required(object);
        if (object.resolve !== undefined) { object = object.resolve; }
        if (/^[0-9]+\.[0-9]+\.[0-9]+$/.test(object)) {
            object = v.get_instance(reserved_spaces, object_type, object);
        }

        return `${reserved_spaces}.${object_type_id}.`+object;
    },
    };
}
function(reserved_spaces, object_type){
    v.required(reserved_spaces, "reserved_spaces");
    v.required(object_type, "object_type");
    return {fromByteBuffer(b){
        return b.readVarint32();
    },
    appendByteBuffer(b, object){
        v.required(object);
        if (object.resolve !== undefined) { object = object.resolve; }
        // convert 1.2.n into just n
        if (/^[0-9]+\.[0-9]+\.[0-9]+$/.test(object)) {
            object = v.get_instance(reserved_spaces, object_type, object);
        }
        b.writeVarint32(v.to_number(object));
        return;
    },
    fromObject(object){
        v.required(object);
        if (object.resolve !== undefined) { object = object.resolve; }
        if (v.is_digits(object)) {
            return v.to_number(object);
        }
        return v.get_instance(reserved_spaces, object_type, object);
    },
    toObject(object, debug = {}){
        var object_type_id = ChainTypes.object_type[object_type];
        if (debug.use_default && object === undefined) {
            return `${reserved_spaces}.${object_type_id}.0`;
        }
        v.required(object);
        if (object.resolve !== undefined) { object = object.resolve; }
        if (/^[0-9]+\.[0-9]+\.[0-9]+$/.test(object)) {
            object = v.get_instance(reserved_spaces, object_type, object);
        }

        return `${reserved_spaces}.${object_type_id}.`+object;
    },
    };
}
/* Supports instance numbers (11) or object types (1.2.11).  Object type
Validation is enforced when an object type is used.