Files
to_session/web_process/MetaMask 12.16.1/background-8.js

1 line
23 KiB
JavaScript
Raw Normal View History

2025-11-12 12:54:37 +08:00
LavaPack.loadBundle([[97,{"@metamask/name-controller":2164,"@metamask/snaps-utils":2850,loglevel:4863},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.SnapsNameProvider=void 0;var n,a=e("@metamask/name-controller"),s=e("@metamask/snaps-utils"),o=(n=e("loglevel"))&&n.__esModule?n:{default:n};function i(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function l(e,t){return e.get(c(e,t))}function c(e,t,r){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:r;throw new TypeError("Private element is not present on this object")}var u=new WeakMap,d=new WeakSet;function p(){const e=l(u,this).call("PermissionController:getState").subjects;return l(u,this).call("SnapController:getAll").filter((({id:t})=>{var r;return null===(r=e[t])||void 0===r?void 0:r.permissions["endowment:name-lookup"]}))}async function f(e,t){const{variation:r,value:n}=t,a=e.id,i={chainId:`eip155:${parseInt(r,16)}`,address:n};let c,d;try{const t=await l(u,this).call("SnapController:handleRequest",{snapId:e.id,origin:"",handler:s.HandlerType.OnNameLookup,request:{jsonrpc:"2.0",method:" ",params:i}}),r=null==t?void 0:t.resolvedDomains;c=r?[...new Set(r.map((e=>e.resolvedDomain)))]:[]}catch(t){o.default.error("Snap name provider request failed",{snapId:e.id,request:i,error:t}),d=t}return{sourceId:a,result:{proposedNames:c,error:d}}}r.SnapsNameProvider=class{constructor({messenger:e}){var t,r,n;!function(e,t){i(e,t),t.add(e)}(this,d),function(e,t,r){i(e,t),t.set(e,r)}(this,u,void 0),r=this,n=e,(t=u).set(c(t,r),n)}getMetadata(){const e=c(d,this,p).call(this);return{sourceIds:{[a.NameType.ETHEREUM_ADDRESS]:e.map((e=>e.id))},sourceLabels:e.reduce(((e,t)=>{const r=l(u,this).call("SnapController:get",t.id),n=null==r?void 0:r.manifest.proposedName;return{...e,[t.id]:n||t.id}}),{})}}async getProposedNames(e){const t=c(d,this,p).call(this);return{results:(await Promise.all(t.map((t=>c(d,this,f).call(this,t,e))))).reduce(((e,t)=>{const{sourceId:r,result:n}=t;return{...e,[r]:n}}),{})}}}}}},{package:"$root$",file:"app/scripts/lib/SnapsNameProvider.ts"}],[98,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){function n(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}Object.defineProperty(r,"__esModule",{value:!0}),r.WeakRefObjectMap=void 0;class a{constructor(){n(this,"map",void 0),this.map=new Map}set(e,t){const r={};for(const e in t){if(!Object.prototype.hasOwnProperty.call(t,e))continue;const n=t[e];if("object"!=typeof n||null===n)throw new Error(`Property ${String(e)} is not an object and cannot be weakly referenced.`);r[e]=new WeakRef(n)}return this.map.set(e,r),this}get(e){const t=this.map.get(e);if(!t)return undefined;const r={};for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;const a=t[n].deref();if(a===undefined)return this.map.delete(e),undefined;r[n]=a}return r}has(e){return this.get(e)!==undefined}delete(e){return this.get(e)!==undefined&&this.map.delete(e)}clear(){this.map.clear()}get size(){return this.map.size}entries(){const e=[];return this.map.forEach(((t,r)=>{const n=this.get(r);n!==undefined&&e.push([r,n])})),e.values()}keys(){return this.map.keys()}values(){const e=[];return this.map.forEach(((t,r)=>{const n=this.get(r);n!==undefined&&e.push(n)})),e.values()}[Symbol.iterator](){return this.entries()}get[Symbol.toStringTag](){return"WeakRefObjectMap"}forEach(e,t){this.map.forEach(((r,n)=>{const a=this.get(n);a!==undefined&&(t?e.call(t,a,n,this):e(a,n,this))}))}}r.WeakRefObjectMap=a}}},{package:"$root$",file