{"version":3,"sources":["../../src/dappCore/sendRequestProxy.ts"],"sourcesContent":["import type {SendRequest} from './types'\n\nexport const sendRequestProxy = (\n  sendRequest: SendRequest,\n  obj = {},\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): {[_ in string]: (...args: any[]) => Promise<any>} =>\n  // This simply proxies all `api.foo(...args)` calls into `sendRequest('foo', args)`\n  new Proxy(obj, {\n    get(target, prop, receiver) {\n      const method = prop.toString()\n      // `target` most of the time will just be an empty object with the\n      // default prototype `Object.prototype`. This check is here so that we\n      // don't proxy stuff like `toString` for instance, because that can cause\n      // weird behavior in some situations. (For example if you try to print\n      // the proxy to the console.)\n      if (!Reflect.has(target, prop)) {\n        return (...args: any[]) => sendRequest(method, args)\n      }\n\n      // Make the empty object handle everything else, so that we can access\n      // stuff like the default object prototype properties. This is not\n      // necessarily needed in theory, but should be a safe default.\n      return Reflect.get(target, prop, receiver)\n    },\n  })\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,IAAM,mBAAmB,CAC9B,aACA,MAAM,CAAC;AAAA;AAAA,EAIP,IAAI,MAAM,KAAK;AAAA,IACb,IAAI,QAAQ,MAAM,UAAU;AAC1B,YAAM,SAAS,KAAK,SAAS;AAM7B,UAAI,CAAC,QAAQ,IAAI,QAAQ,IAAI,GAAG;AAC9B,eAAO,IAAI,SAAgB,YAAY,QAAQ,IAAI;AAAA,MACrD;AAKA,aAAO,QAAQ,IAAI,QAAQ,MAAM,QAAQ;AAAA,IAC3C;AAAA,EACF,CAAC;AAAA;","names":[]}