scripts/helpers/parsed-rpc-traits.js
function parseMethodsFromRust (source) {
  // Matching the custom `rpc` attribute with it's doc comment
  const attributePattern = /((?:\s*\/\/\/.*$)*)\s*#\[rpc\(([^)]+)\)]/gm;
  const commentPattern = /\s*\/\/\/\s*/g;
  const separatorPattern = /\s*,\s*/g;
  const assignPattern = /([\S]+)\s*=\s*"([^"]*)"/;
  const ignorePattern = /@(ignore|deprecated|unimplemented|alias)\b/i;

  const methods = [];

  source.toString().replace(attributePattern, (match, comment, props) => {
    comment = comment.replace(commentPattern, '\n').trim();

    // Skip deprecated methods
    if (ignorePattern.test(comment)) {
      return match;
    }

    props.split(separatorPattern).forEach((prop) => {
      const [, key, value] = prop.split(assignPattern) || [];

      if (key === 'name' && value != null) {
        methods.push(value);
      }
    });

    return match;
  });

  return methods;
}
function parseMethodsFromRust (source) {
  // Matching the custom `rpc` attribute with it's doc comment
  const attributePattern = /((?:\s*\/\/\/.*$)*)\s*#\[rpc\(([^)]+)\)]/gm;
  const commentPattern = /\s*\/\/\/\s*/g;
  const separatorPattern = /\s*,\s*/g;
  const assignPattern = /([\S]+)\s*=\s*"([^"]*)"/;
  const ignorePattern = /@(ignore|deprecated|unimplemented|alias)\b/i;

  const methods = [];

  source.toString().replace(attributePattern, (match, comment, props) => {
    comment = comment.replace(commentPattern, '\n').trim();

    // Skip deprecated methods
    if (ignorePattern.test(comment)) {
      return match;
    }

    props.split(separatorPattern).forEach((prop) => {
      const [, key, value] = prop.split(assignPattern) || [];

      if (key === 'name' && value != null) {
        methods.push(value);
      }
    });

    return match;
  });

  return methods;
}
function parseMethodsFromRust ( source ) { // Matching the custom `rpc` attribute with it's doc comment const attributePattern = / ((?:\s*\/\/\/.*$)*)\s*#\[rpc\(([^)]+)\)] / gm ; const commentPattern = / \s*\/\/\/\s* / g ; const separatorPattern = / \s*,\s* / g ; const assignPattern = / ([\S]+)\s*=\s*"([^"]*)" / ; const ignorePattern = / @(ignore|deprecated|unimplemented|alias)\b / i ; const methods = [ ] ; source . toString ( ) . replace ( attributePattern , ( match , comment , props ) => { comment = comment . replace ( commentPattern , '\n' ) . trim ( ) ; // Skip deprecated methods if ( ignorePattern . test ( comment ) ) { return match ; } props . split ( separatorPattern ) . forEach ( ( prop ) => { const [ , key , value ] = prop . split ( assignPattern ) || [ ] ; if ( key === 'name' && value != null ) { methods . push ( value ) ; } } ) ; return match ; } ) ; return methods ; }
Get a list of JSON-RPC from Rust trait source code
Get a list of JSON - RPC from Rust trait source code