library PbPool {
    using Pb for Pb.Buffer; // so we can call Pb funcs on Buffer obj

    struct WithdrawMsg {
        uint64 chainid; // tag: 1
        uint64 seqnum; // tag: 2
        address receiver; // tag: 3
        address token; // tag: 4
        uint256 amount; // tag: 5
        bytes32 refid; // tag: 6
    } // end struct WithdrawMsg

    function decWithdrawMsg(bytes memory raw) internal pure returns (WithdrawMsg memory m) {
        Pb.Buffer memory buf = Pb.fromBytes(raw);

        uint256 tag;
        Pb.WireType wire;
        while (buf.hasMore()) {
            (tag, wire) = buf.decKey();
            if (false) {}
            // solidity has no switch/case
            else if (tag == 1) {
                m.chainid = uint64(buf.decVarint());
            } else if (tag == 2) {
                m.seqnum = uint64(buf.decVarint());
            } else if (tag == 3) {
                m.receiver = Pb._address(buf.decBytes());
            } else if (tag == 4) {
                m.token = Pb._address(buf.decBytes());
            } else if (tag == 5) {
                m.amount = Pb._uint256(buf.decBytes());
            } else if (tag == 6) {
                m.refid = Pb._bytes32(buf.decBytes());
            } else {
                buf.skipValue(wire);
            } // skip value of unknown tag
        }
    } // end decoder WithdrawMsg
}
function decWithdrawMsg(bytes memory raw) internal pure returns (WithdrawMsg memory m) {
    Pb.Buffer memory buf = Pb.fromBytes(raw);

    uint256 tag;
    Pb.WireType wire;
    while (buf.hasMore()) {
        (tag, wire) = buf.decKey();
        if (false) {}
        // solidity has no switch/case
        else if (tag == 1) {
            m.chainid = uint64(buf.decVarint());
        } else if (tag == 2) {
            m.seqnum = uint64(buf.decVarint());
        } else if (tag == 3) {
            m.receiver = Pb._address(buf.decBytes());
        } else if (tag == 4) {
            m.token = Pb._address(buf.decBytes());
        } else if (tag == 5) {
            m.amount = Pb._uint256(buf.decBytes());
        } else if (tag == 6) {
            m.refid = Pb._bytes32(buf.decBytes());
        } else {
            buf.skipValue(wire);
        } // skip value of unknown tag
    }
} // end decoder WithdrawMsg

// end struct WithdrawMsg