• Create a unique identifier for a parameter within a given method. This is typically used to create hashmap keys for method to parameter mappings.

    Parameters

    • method: MethodObject

      The OpenRPC Method which encloses the content descriptor

    • contentDescriptor: ContentDescriptorObject

      The OpenRPC Content Descriptor that is a param in the method

    Returns string

    an ID for the param/method combo. It follows the format {method.name}/{indexWithinParams}|{contentDescriptor.name} where:

    1. if the method's parameter structure is "by-name", the format returned uses the contentDescriptor.name
    2. otherwise, the return value will use the params index in the list of params.

    Throws

    [[ContentDescriptorNotFoundInMethodError]]

    Example


    const { generateMethodParamId }
    const methodObject = {
    name: "foo",
    params: [{
    name: "fooParam",
    schema: { type: "integer" }
    }],
    result: {}
    };
    const paramId = generateMethodParamId(methodObject, methodObject.params[0]);
    console.log(paramId);
    // outputs:
    // "foo/0/fooParam"