Files
to_session/web_process/MetaMask 12.16.1/background-1.js
Administrator a0720d80dc fefdwef
2025-11-12 12:54:37 +08:00

1 line
369 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

LavaPack.loadBundle([[1792,{"./SnapKeyring.cjs":1789,"./types.cjs":1796},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){n===undefined&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){n===undefined&&(n=r),e[n]=t[r]}),s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(r,"__esModule",{value:!0}),s(e("./types.cjs"),r),s(e("./SnapKeyring.cjs"),r)}}},{package:"@metamask/eth-snap-keyring",file:"node_modules/@metamask/eth-snap-keyring/dist/index.cjs"}],[1793,{"@metamask/utils":2950},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.createModuleLogger=r.projectLogger=void 0;const n=e("@metamask/utils");Object.defineProperty(r,"createModuleLogger",{enumerable:!0,get:function(){return n.createModuleLogger}}),r.projectLogger=(0,n.createProjectLogger)("eth-snap-keyring")}}},{package:"@metamask/eth-snap-keyring",file:"node_modules/@metamask/eth-snap-keyring/dist/logger.cjs"}],[1794,{"./v1.cjs":1795},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){n===undefined&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){n===undefined&&(n=r),e[n]=t[r]}),s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(r,"__esModule",{value:!0}),s(e("./v1.cjs"),r)}}},{package:"@metamask/eth-snap-keyring",file:"node_modules/@metamask/eth-snap-keyring/dist/migrations/index.cjs"}],[1795,{"../account.cjs":1790,"@metamask/keyring-api":1983,"@metamask/keyring-utils":2064,"@metamask/superstruct":2872},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.isAccountV1=a,r.getScopesForAccountV1=l,r.transformAccountV1=function(e){const{type:t}=e;if(t===n.EthAccountType.Eoa)return{...e,scopes:l(e)};return(0,o.assertKeyringAccount)(e)},r.migrateAccountV1=function(e){if(!a(e))return e;return{...e,scopes:l(e)}};const n=e("@metamask/keyring-api"),s=e("@metamask/keyring-utils"),i=e("@metamask/superstruct"),o=e("../account.cjs");function a(e){return(0,i.is)(e,o.KeyringAccountV1Struct)}function l(e){switch(e.type){case n.EthAccountType.Eoa:return[n.EthScope.Eoa];case n.EthAccountType.Erc4337:return[n.EthScope.Testnet];case n.BtcAccountType.P2wpkh:return[(0,s.isBtcMainnetAddress)(e.address)?n.BtcScope.Mainnet:n.BtcScope.Testnet];case n.SolAccountType.DataAccount:return[n.SolScope.Mainnet,n.SolScope.Testnet,n.SolScope.Devnet];default:return[n.EthScope.Eoa]}}}}},{package:"@metamask/eth-snap-keyring",file:"node_modules/@metamask/eth-snap-keyring/dist/migrations/v1.cjs"}],[1796,{"@metamask/superstruct":2872,"@metamask/utils":2950},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.SnapMessageStruct=void 0;const n=e("@metamask/superstruct"),s=e("@metamask/utils");r.SnapMessageStruct=(0,n.object)({method:(0,n.string)(),params:(0,n.optional)((0,n.union)([(0,n.array)(s.JsonStruct),(0,n.record)((0,n.string)(),s.JsonStruct)]))})}}},{package:"@metamask/eth-snap-keyring",file:"node_modules/@metamask/eth-snap-keyring/dist/types.cjs"}],[1797,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.unique=function(e){return[...new Set(e)]},r.toJson=function(e){return JSON.parse(JSON.stringify(e))},r.ensureDefined=function(e){if(e===undefined)throw new Error("Argument is undefined")},r.throwError=function(e){throw new Error(e)},r.equalsIgnoreCase=function(e,t){return e.toLowerCase()===t.toLowerCase()},r.sanitizeUrl=function(e){return new URL(e).toString()}}}},{package:"@metamask/eth-snap-keyring",file:"node_modules/@metamask/eth-snap-keyring/dist/util.cjs"}],[1798,{"./bytes":1801,"./constants":1802,"./helpers":1804,"./internal":1806,"@ethereumjs/rlp":429,buffer:4074,"ethereum-cryptography/keccak":4300,"ethereum-cryptography/secp256k1":4317,"ethereum-cryptography/utils":4319},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){(function(t){(function(){Object.defineProperty(r,"__esModule",{value:!0}),r.accountBodyToRLP=r.accountBodyToSlim=r.accountBodyFromSlim=r.isZeroAddress=r.zeroAddress=r.importPublic=r.privateToAddress=r.privateToPublic=r.publicToAddress=r.pubToAddress=r.isValidPublic=r.isValidPrivate=r.generateAddress2=r.generateAddress=r.isValidChecksumAddress=r.toChecksumAddress=r.isValidAddress=r.Account=void 0;const n=e("@ethereumjs/rlp"),s=e("ethereum-cryptography/keccak"),i=e("ethereum-cryptography/secp256k1"),o=e("ethereum-cryptography/utils"),a=e("./bytes"),l=e("./constants"),c=e("./helpers"),u=e("./internal"),d=BigInt(0);class h{constructor(e=d,t=d,r=l.KECCAK256_RLP,n=l.KECCAK256_NULL){this.nonce=e,this.balance=t,this.storageRoot=r,this.codeHash=n,this._validate()}static fromAccountData(e){const{nonce:t,balance:r,storageRoot:n,codeHash:s}=e;return new h(t!==undefined?(0,a.bufferToBigInt)((0,a.toBuffer)(t)):undefined,r!==undefined?(0,a.bufferToBigInt)((0,a.toBuffer)(r)):undefined,n!==undefined?(0,a.toBuffer)(n):undefined,s!==undefined?(0,a.toBuffer)(s):undefined)}static fromRlpSerializedAccount(e){const t=(0,a.arrToBufArr)(n.RLP.decode(Uint8Array.from(e)));if(!Array.isArray(t))throw new Error("Invalid serialized account input. Must be array");return this.fromValuesArray(t)}static fromValuesArray(e){const[t,r,n,s]=e;return new h((0,a.bufferToBigInt)(t),(0,a.bufferToBigInt)(r),n,s)}_validate(){if(this.nonce<d)throw new Error("nonce must be greater than zero");if(this.balance<d)throw new Error("balance must be greater than zero");if(32!==this.storageRoot.length)throw new Error("storageRoot must have a length of 32");if(32!==this.codeHash.length)throw new Error("codeHash must have a length of 32")}raw(){return[(0,a.bigIntToUnpaddedBuffer)(this.nonce),(0,a.bigIntToUnpaddedBuffer)(this.balance),this.storageRoot,this.codeHash]}serialize(){return t.from(n.RLP.encode((0,a.bufArrToArr)(this.raw())))}isContract(){return!this.codeHash.equals(l.KECCAK256_NULL)}isEmpty(){return this.balance===d&&this.nonce===d&&this.codeHash.equals(l.KECCAK256_NULL)}}r.Account=h;r.isValidAddress=function(e){try{(0,c.assertIsString)(e)}catch(e){return!1}return/^0x[0-9a-fA-F]{40}$/.test(e)};r.toChecksumAddress=function(e,r){(0,c.assertIsHexString)(e);const n=(0,u.stripHexPrefix)(e).toLowerCase();let i="";if(r!==undefined){i=(0,a.bufferToBigInt)((0,a.toBuffer)(r)).toString()+"0x"}const l=t.from(i+n,"utf8"),d=(0,o.bytesToHex)((0,s.keccak256)(l));let h="0x";for(let e=0;e<n.length;e++)parseInt(d[e],16)>=8?h+=n[e].toUpperCase():h+=n[e];return h};r.isValidChecksumAddress=function(e,t){return(0,r.isValidAddress)(e)&&(0,r.toChecksumAddress)(e,t)===e};r.generateAddress=function(e,r){return(0,c.assertIsBuffer)(e),(0,c.assertIsBuffer)(r),(0,a.bufferToBigInt)(r)===BigInt(0)?t.from((0,s.keccak256)(n.RLP.encode((0,a.bufArrToArr)([e,null])))).slice(-20):t.from((0,s.keccak256)(n.RLP.encode((0,a.bufArrToArr)([e,r])))).slice(-20)};r.generateAddress2=function(e,r,n){if((0,c.assertIsBuffer)(e),(0,c.assertIsBuffer)(r),(0,c.assertIsBuffer)(n),20!==e.length)throw new Error("Expected from to be of length 20");if(32!==r.length)throw new Error("Expected salt to be of length 32");const i=(0,s.keccak256)(t.concat([t.from("ff","hex"),e,r,(0,s.keccak256)(n)]));return(0,a.toBuffer)(i).slice(-20)};r.isValidPrivate=function(e){return i.secp256k1.utils.isValidPrivateKey(e)};r.isValidPublic=function(e,r=!1){if((0,c.assertIsBuffer)(e),64===e.length)try{return i.secp256k1.ProjectivePoint.fromHex(t.concat([t.from([4]),e])),!0}catch(e){return!1}if(!r)return!1;try{return i.secp256k1.ProjectivePoint.fromHex(e),!0}catch(e){return!1}};r.pubToAddress=function(e,r=!1){if((0,c.assertIsBuffer)(e),r&&64!==e.length&&(e=t.from(i.secp256k1.ProjectivePoint.fromHex(e).toRawBytes(!1).slice(1))),64!==e.length)throw new Error("Expected pubKey to be of length 64");return t.from((0,s.keccak256)(e)).slice(-20)},r.publicToAddress=r.pubToAddress;r.privateToPublic=function(e){return(0,c.assertIsBuffer)(e),t.from(i.secp256k1.ProjectivePoint.fromPrivateKey(e).toRawBytes(!1).slice(1))};r.privateToAddress=function(e){return(0,r.publicToAddress)((0,r.privateToPublic)(e))};r.importPublic=function(e){return(0,c.assertIsBuffer)(e),64!==e.length&&(e=t.from(i.secp256k1.ProjectivePoint.fromHex(e).toRawBytes(!1).slice(1))),e};r.zeroAddress=function(){const e=(0,a.zeros)(20);return(0,a.bufferToHex)(e)};function p(e){const[t,r,n,s]=e;return[t,r,0===(0,a.arrToBufArr)(n).length?l.KECCAK256_RLP:n,0===(0,a.arrToBufArr)(s).length?l.KECCAK256_NULL:s]}r.isZeroAddress=function(e){try{(0,c.assertIsString)(e)}catch(e){return!1}return(0,r.zeroAddress)()===e},r.accountBodyFromSlim=p;const g=new Uint8Array(0);r.accountBodyToSlim=function(e){const[t,r,n,s]=e;return[t,r,(0,a.arrToBufArr)(n).equals(l.KECCAK256_RLP)?g:n,(0,a.arrToBufArr)(s).equals(l.KECCAK256_NULL)?g:s]},r.accountBodyToRLP=function(e,t=!0){const r=t?p(e):e;return(0,a.arrToBufArr)(n.RLP.encode(r))}}).call(this)}).call(this,e("buffer").Buffer)}}},{package:"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@ethereumjs/util",file:"node_modules/@metamask/eth-snap-keyring/node_modules/@ethereumjs/util/dist/account.js"}],[1799,{"./account":1798,"./bytes":1801,buffer:4074},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){(function(t){(function(){Object.defineProperty(r,"__esModule",{value:!0}),r.Address=void 0;const n=e("./account"),s=e("./bytes");class i{constructor(e){if(20!==e.length)throw new Error("Invalid address length");this.buf=e}static zero(){return new i((0,s.zeros)(20))}static fromString(e){if(!(0,n.isValidAddress)(e))throw new Error("Invalid address");return new i((0,s.toBuffer)(e))}static fromPublicKey(e){if(!t.isBuffer(e))throw new Error("Public key should be Buffer");const r=(0,n.pubToAddress)(e);return new i(r)}static fromPrivateKey(e){if(!t.isBuffer(e))throw new Error("Private key should be Buffer");const r=(0,n.privateToAddress)(e);return new i(r)}static generate(e,t){if("bigint"!=typeof t)throw new Error("Expected nonce to be a bigint");return new i((0,n.generateAddress)(e.buf,(0,s.bigIntToBuffer)(t)))}static generate2(e,r,s){if(!t.isBuffer(r))throw new Error("Expected salt to be a Buffer");if(!t.isBuffer(s))throw new Error("Expected initCode to be a Buffer");return new i((0,n.generateAddress2)(e.buf,r,s))}equals(e){return this.buf.equals(e.buf)}isZero(){return this.equals(i.zero())}isPrecompileOrSystemAddress(){const e=(0,s.bufferToBigInt)(this.buf),t=BigInt(0),r=BigInt("0xffff");return e>=t&&e<=r}toString(){return"0x"+this.buf.toString("hex")}toBuffer(){return t.from(this.buf)}}r.Address=i}).call(this)}).call(this,e("buffer").Buffer)}}},{package:"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@ethereumjs/util",file:"node_modules/@metamask/eth-snap-keyring/node_modules/@ethereumjs/util/dist/address.js"}],[18,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.getMultichainAssetsControllerMessenger=function(e){return e.getRestricted({name:"MultichainAssetsController",allowedEvents:["AccountsController:accountAdded","AccountsController:accountRemoved","AccountsController:accountAssetListUpdated"],allowedActions:["PermissionController:getPermissions","SnapController:handleRequest","SnapController:getAll","AccountsController:listMultichainAccounts"]})}}}},{package:"$root$",file:"app/scripts/controller-init/messengers/multichain/multichain-assets-controller-messenger.ts"}],[180,{"../../../../../shared/constants/network":5734,"./uniswap-commands":179,"@ethersproject/abi":484,"ethereumjs-util":4327},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.UNISWAP_UNIVERSAL_ROUTER_ADDRESSES=void 0,r.decodeUniswapRouterTransactionData=function({transactionData:e,contractAddress:t,chainId:r}){const i=c[r];if(null==i||!i.map((e=>e.toLowerCase())).includes(t.toLowerCase()))return undefined;const d=new n.Interface(u);let h;try{h=d.parseTransaction({data:e})}catch(e){return undefined}const p=h.args.commands,g=h.args.inputs;return p.slice(2).match(/.{1,2}/gu).map(((e,t)=>function(e,t){const r=parseInt(e,16),i=31&r,c=o.UNISWAP_ROUTER_COMMANDS[String(i)];if(!c)return undefined;const u=c.params.map((e=>e.type)),d=n.Interface.getAbiCoder().decode(u,t),{name:h}=c,p=c.params.map(((e,t)=>{const{name:r,type:n,description:i}=e,o=d[t];return{name:r,type:n,value:"path"===r?function(e){const t=[];let r=(0,s.stripHexPrefix)(e),n={},i=!0;for(;r.length;){if(i){const e=(0,s.addHexPrefix)(r.slice(0,a));n.firstAddress?(n.secondAddress=e,t.push(n),n={firstAddress:e}):n.firstAddress=e,r=r.slice(a)}else n.tickSpacing=parseInt(r.slice(0,l),16),r=r.slice(l);i=!i}return t}(o):o,description:i}}));return{name:h,params:p}}(e,g[t]))).filter((e=>e!==undefined))};var n=e("@ethersproject/abi"),s=e("ethereumjs-util"),i=e("../../../../../shared/constants/network"),o=e("./uniswap-commands");const a=40,l=6,c=r.UNISWAP_UNIVERSAL_ROUTER_ADDRESSES={[i.CHAIN_IDS.ARBITRUM]:["0x4C60051384bd2d3C01bfc845Cf5F4b44bcbE9de5","0xeC8B0F7Ffe3ae75d7FfAb09429e3675bb63503e4","0x5E325eDA8064b456f4781070C0738d849c824258"],[i.CHAIN_IDS.AVALANCHE]:["0x82635AF6146972cD6601161c4472ffe97237D292","0x4Dae2f939ACf50408e13d58534Ff8c2776d45265"],[i.CHAIN_IDS.BASE]:["0xeC8B0F7Ffe3ae75d7FfAb09429e3675bb63503e4","0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD"],[i.CHAIN_IDS.BSC]:["0x5Dc88340E1c5c6366864Ee415d6034cadd1A9897","0xeC8B0F7Ffe3ae75d7FfAb09429e3675bb63503e4","0x4Dae2f939ACf50408e13d58534Ff8c2776d45265"],[i.CHAIN_IDS.MAINNET]:["0xEf1c6E67703c7BD7107eed8303Fbe6EC2554BF6B","0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD"],[i.CHAIN_IDS.OPTIMISM]:["0xb555edF5dcF85f42cEeF1f3630a52A108E55A654","0xeC8B0F7Ffe3ae75d7FfAb09429e3675bb63503e4","0xCb1355ff08Ab38bBCE60111F1bb2B784bE25D7e8"],[i.CHAIN_IDS.POLYGON]:["0x4C60051384bd2d3C01bfc845Cf5F4b44bcbE9de5","0x643770E279d5D0733F21d6DC03A8efbABf3255B4","0xec7BE89e9d109e7e3Fec59c222CF297125FEFda2"],[i.CHAIN_IDS.SEPOLIA]:["0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD"]},u=[{constant:!0,inputs:[{name:"commands",type:"bytes"},{name:"inputs",type:"bytes[]"},{name:"deadline",type:"uint256"}],name:"execute",type:"function"},{constant:!0,inputs:[{name:"commands",type:"bytes"},{name:"inputs",type:"bytes[]"}],name:"execute",type:"function"}]}}},{package:"$root$",file:"app/scripts/lib/transaction/decode/uniswap.ts"}],[1800,{events:4399},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.AsyncEventEmitter=void 0;const n=e("events");class s extends n.EventEmitter{emit(e,...t){let[r,n]=t;const s=this;let i=s._events[e]??[];return n===undefined&&"function"==typeof r&&(n=r,r=undefined),"newListener"!==e&&"removeListener"!==e||(r={event:r,fn:n},n=undefined),i=Array.isArray(i)?i:[i],async function(e,t,r){let n;for await(const s of t)try{s.length<2?s.call(e,r):await new Promise(((t,n)=>{s.call(e,r,(e=>{e?n(e):t()}))}))}catch(e){n=e}if(n)throw n}(s,i.slice(),r).then(n).catch(n),s.listenerCount(e)>0}once(e,t){const r=this;let n;if("function"!=typeof t)throw new TypeError("listener must be a function");return n=t.length>=2?function(s,i){r.removeListener(e,n),t(s,i)}:function(s){r.removeListener(e,n),t(s,n)},r.on(e,n),r}first(e,t){let r=this._events[e]??[];if("function"!=typeof t)throw new TypeError("listener must be a function");return Array.isArray(r)||(this._events[e]=r=[r]),r.unshift(t),this}before(e,t,r){return this.beforeOrAfter(e,t,r)}after(e,t,r){return this.beforeOrAfter(e,t,r,"after")}beforeOrAfter(e,t,r,n){let s,i,o=this._events[e]??[];const a="after"===n?1:0;if("function"!=typeof r)throw new TypeError("listener must be a function");if("function"!=typeof t)throw new TypeError("target must be a function");for(Array.isArray(o)||(this._events[e]=o=[o]),i=o.length,s=o.length;s--;)if(o[s]===t){i=s+a;break}return o.splice(i,0,r),this}on(e,t){return super.on(e,t)}addListener(e,t){return super.addListener(e,t)}prependListener(e,t){return super.prependListener(e,t)}prependOnceListener(e,t){return super.prependOnceListener(e,t)}removeAllListeners(e){return super.removeAllListeners(e)}removeListener(e,t){return super.removeListener(e,t)}eventNames(){return super.eventNames()}listeners(e){return super.listeners(e)}listenerCount(e){return super.listenerCount(e)}getMaxListeners(){return super.getMaxListeners()}setMaxListeners(e){return super.setMaxListeners(e)}}r.AsyncEventEmitter=s}}},{package:"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@ethereumjs/util",file:"node_modules/@metamask/eth-snap-keyring/node_modules/@ethereumjs/util/dist/asyncEventEmitter.js"}],[1801,{"./helpers":1804,"./internal":1806,buffer:4074},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){(function(t){(function(){Object.defineProperty(r,"__esModule",{value:!0}),r.intToUnpaddedBuffer=r.bigIntToUnpaddedBuffer=r.bigIntToHex=r.bufArrToArr=r.arrToBufArr=r.validateNoLeadingZeroes=r.baToJSON=r.toUtf8=r.short=r.addHexPrefix=r.toUnsigned=r.fromSigned=r.bufferToInt=r.bigIntToBuffer=r.bufferToBigInt=r.bufferToHex=r.toBuffer=r.unpadHexString=r.unpadArray=r.unpadBuffer=r.setLengthRight=r.setLengthLeft=r.zeros=r.intToBuffer=r.intToHex=void 0;const n=e("./helpers"),s=e("./internal");r.intToHex=function(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Received an invalid integer type: ${e}`);return`0x${e.toString(16)}`};r.intToBuffer=function(e){const n=(0,r.intToHex)(e);return t.from((0,s.padToEven)(n.slice(2)),"hex")};r.zeros=function(e){return t.allocUnsafe(e).fill(0)};const i=function(e,t,n){const s=(0,r.zeros)(t);return n?e.length<t?(e.copy(s),s):e.slice(0,t):e.length<t?(e.copy(s,t-e.length),s):e.slice(-t)};r.setLengthLeft=function(e,t){return(0,n.assertIsBuffer)(e),i(e,t,!1)};r.setLengthRight=function(e,t){return(0,n.assertIsBuffer)(e),i(e,t,!0)};const o=function(e){let t=e[0];for(;e.length>0&&"0"===t.toString();)t=(e=e.slice(1))[0];return e};r.unpadBuffer=function(e){return(0,n.assertIsBuffer)(e),o(e)};r.unpadArray=function(e){return(0,n.assertIsArray)(e),o(e)};r.unpadHexString=function(e){return(0,n.assertIsHexString)(e),e=(0,s.stripHexPrefix)(e),"0x"+o(e)};r.toBuffer=function(e){if(null===e||e===undefined)return t.allocUnsafe(0);if(t.isBuffer(e))return t.from(e);if(Array.isArray(e)||e instanceof Uint8Array)return t.from(e);if("string"==typeof e){if(!(0,s.isHexString)(e))throw new Error(`Cannot convert string to buffer. toBuffer only supports 0x-prefixed hex strings and this string was given: ${e}`);return t.from((0,s.padToEven)((0,s.stripHexPrefix)(e)),"hex")}if("number"==typeof e)return(0,r.intToBuffer)(e);if("bigint"==typeof e){if(e<BigInt(0))throw new Error(`Cannot convert negative bigint to buffer. Given: ${e}`);let r=e.toString(16);return r.length%2&&(r="0"+r),t.from(r,"hex")}if(e.toArray)return t.from(e.toArray());if(e.toBuffer)return t.from(e.toBuffer());throw new Error("invalid type")};function a(e){const t=(0,r.bufferToHex)(e);return"0x"===t?BigInt(0):BigInt(t)}function l(e){return(0,r.toBuffer)("0x"+e.toString(16))}r.bufferToHex=function(e){return"0x"+(e=(0,r.toBuffer)(e)).toString("hex")},r.bufferToBigInt=a,r.bigIntToBuffer=l;r.bufferToInt=function(e){const t=Number(a(e));if(!Number.isSafeInteger(t))throw new Error("Number exceeds 53 bits");return t};r.fromSigned=function(e){return BigInt.asIntN(256,a(e))};r.toUnsigned=function(e){return l(BigInt.asUintN(256,e))};r.addHexPrefix=function(e){return"string"!=typeof e||(0,s.isHexPrefixed)(e)?e:"0x"+e},r.short=function(e,r=50){const n=t.isBuffer(e)?e.toString("hex"):e;return n.length<=r?n:n.slice(0,r)+"…"};r.toUtf8=function(e){if((e=(0,s.stripHexPrefix)(e)).length%2!=0)throw new Error("Invalid non-even hex string input for toUtf8() provided");return t.from(e.replace(/^(00)+|(00)+$/g,""),"hex").toString("utf8")};r.baToJSON=function(e){if(t.isBuffer(e))return`0x${e.toString("hex")}`;if(e instanceof Array){const t=[];for(let n=0;n<e.length;n++)t.push((0,r.baToJSON)(e[n]));return t}};r.validateNoLeadingZeroes=function(e){for(const[t,r]of Object.entries(e))if(r!==undefined&&r.length>0&&0===r[0])throw new Error(`${t} cannot have leading zeroes, received: ${r.toString("hex")}`)},r.arrToBufArr=function e(r){return Array.isArray(r)?r.map((t=>e(t))):t.from(r)},r.bufArrToArr=function e(t){return Array.isArray(t)?t.map((t=>e(t))):Uint8Array.from(t??[])};r.bigIntToHex=e=>"0x"+e.toString(16),r.bigIntToUnpaddedBuffer=function(e){return(0,r.unpadBuffer)(l(e))},r.intToUnpaddedBuffer=function(e){return(0,r.unpadBuffer)((0,r.intToBuffer)(e))}}).call(this)}).call(this,e("buffer").Buffer)}}},{package:"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@ethereumjs/util",file:"node_modules/@metamask/eth-snap-keyring/node_modules/@ethereumjs/util/dist/bytes.js"}],[1802,{buffer:4074,"ethereum-cryptography/secp256k1":4317},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.MAX_WITHDRAWALS_PER_PAYLOAD=r.RLP_EMPTY_STRING=r.KECCAK256_RLP=r.KECCAK256_RLP_S=r.KECCAK256_RLP_ARRAY=r.KECCAK256_RLP_ARRAY_S=r.KECCAK256_NULL=r.KECCAK256_NULL_S=r.TWO_POW256=r.SECP256K1_ORDER_DIV_2=r.SECP256K1_ORDER=r.MAX_INTEGER_BIGINT=r.MAX_INTEGER=r.MAX_UINT64=void 0;const n=e("buffer"),s=e("ethereum-cryptography/secp256k1");r.MAX_UINT64=BigInt("0xffffffffffffffff"),r.MAX_INTEGER=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),r.MAX_INTEGER_BIGINT=BigInt("115792089237316195423570985008687907853269984665640564039457584007913129639935"),r.SECP256K1_ORDER=s.secp256k1.CURVE.n,r.SECP256K1_ORDER_DIV_2=s.secp256k1.CURVE.n/BigInt(2),r.TWO_POW256=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000"),r.KECCAK256_NULL_S="c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",r.KECCAK256_NULL=n.Buffer.from(r.KECCAK256_NULL_S,"hex"),r.KECCAK256_RLP_ARRAY_S="1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",r.KECCAK256_RLP_ARRAY=n.Buffer.from(r.KECCAK256_RLP_ARRAY_S,"hex"),r.KECCAK256_RLP_S="56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",r.KECCAK256_RLP=n.Buffer.from(r.KECCAK256_RLP_S,"hex"),r.RLP_EMPTY_STRING=n.Buffer.from([128]),r.MAX_WITHDRAWALS_PER_PAYLOAD=16}}},{package:"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@ethereumjs/util",file:"node_modules/@metamask/eth-snap-keyring/node_modules/@ethereumjs/util/dist/constants.js"}],[1803,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.compactBytesToNibbles=r.bytesToNibbles=r.nibblesToCompactBytes=r.nibblesToBytes=r.hasTerminator=void 0;r.hasTerminator=e=>e.length>0&&16===e[e.length-1];r.nibblesToBytes=(e,t)=>{for(let r=0,n=0;n<e.length;r+=1,n+=2)t[r]=e[n]<<4|e[n+1]};r.nibblesToCompactBytes=e=>{let t=0;(0,r.hasTerminator)(e)&&(t=1,e=e.subarray(0,e.length-1));const n=new Uint8Array(e.length/2+1);return n[0]=t<<5,1&~e.length||(n[0]|=16,n[0]|=e[0],e=e.subarray(1)),(0,r.nibblesToBytes)(e,n.subarray(1)),n};r.bytesToNibbles=e=>{const t=2*e.length+1,r=new Uint8Array(t);for(let t=0;t<e.length;t++){const n=e[t];r[2*t]=n/16,r[2*t+1]=n%16}return r[t-1]=16,r};r.compactBytesToNibbles=e=>{if(0===e.length)return e;let t=(0,r.bytesToNibbles)(e);t[0]<2&&(t=t.subarray(0,t.length-1));const n=2-(1&t[0]);return t.subarray(n)}}}},{package:"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@ethereumjs/util",file:"node_modules/@metamask/eth-snap-keyring/node_modules/@ethereumjs/util/dist/encoding.js"}],[1804,{"../../../../../../is-buffer/index.js":4657,"./internal":1806},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){(function(t){(function(){Object.defineProperty(r,"__esModule",{value:!0}),r.assertIsString=r.assertIsArray=r.assertIsBuffer=r.assertIsHexString=void 0;const n=e("./internal");r.assertIsHexString=function(e){if(!(0,n.isHexString)(e)){throw new Error(`This method only supports 0x-prefixed hex strings but input was: ${e}`)}};r.assertIsBuffer=function(e){if(!t.isBuffer(e)){throw new Error(`This method only supports Buffer but input was: ${e}`)}};r.assertIsArray=function(e){if(!Array.isArray(e)){throw new Error(`This method only supports number arrays but input was: ${e}`)}};r.assertIsString=function(e){if("string"!=typeof e){throw new Error(`This method only supports strings but input was: ${e}`)}}}).call(this)}).call(this,{isBuffer:e("../../../../../../is-buffer/index.js")})}}},{package:"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@ethereumjs/util",file:"node_modules/@metamask/eth-snap-keyring/node_modules/@ethereumjs/util/dist/helpers.js"}],[1805,{"./account":1798,"./address":1799,"./asyncEventEmitter":1800,"./bytes":1801,"./constants":1802,"./encoding":1803,"./internal":1806,"./lock":1807,"./provider":1808,"./signature":1809,"./types":1810,"./units":1811,"./withdrawal":1812},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){n===undefined&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){n===undefined&&(n=r),e[n]=t[r]}),s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(r,"__esModule",{value:!0}),r.toAscii=r.stripHexPrefix=r.padToEven=r.isHexString=r.isHexPrefixed=r.getKeys=r.getBinarySize=r.fromUtf8=r.fromAscii=r.arrayContainsArray=void 0,s(e("./constants"),r),s(e("./units"),r),s(e("./account"),r),s(e("./address"),r),s(e("./withdrawal"),r),s(e("./signature"),r),s(e("./bytes"),r),s(e("./types"),r),s(e("./encoding"),r),s(e("./asyncEventEmitter"),r);var i=e("./internal");Object.defineProperty(r,"arrayContainsArray",{enumerable:!0,get:function(){return i.arrayContainsArray}}),Object.defineProperty(r,"fromAscii",{enumerable:!0,get:function(){return i.fromAscii}}),Object.defineProperty(r,"fromUtf8",{enumerable:!0,get:function(){return i.fromUtf8}}),Object.defineProperty(r,"getBinarySize",{enumerable:!0,get:function(){return i.getBinarySize}}),Object.defineProperty(r,"getKeys",{enumerable:!0,get:function(){return i.getKeys}}),Object.defineProperty(r,"isHexPrefixed",{enumerable:!0,get:function(){return i.isHexPrefixed}}),Object.defineProperty(r,"isHexString",{enumerable:!0,get:function(){return i.isHexString}}),Object.defineProperty(r,"padToEven",{enumerable:!0,get:function(){return i.padToEven}}),Object.defineProperty(r,"stripHexPrefix",{enumerable:!0,get:function(){return i.stripHexPrefix}}),Object.defineProperty(r,"toAscii",{enumerable:!0,get:function(){return i.toAscii}}),s(e("./lock"),r),s(e("./provider"),r)}}},{package:"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@ethereumjs/util",file:"node_modules/@metamask/eth-snap-keyring/node_modules/@ethereumjs/util/dist/index.js"}],[1806,{buffer:4074},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){(function(e){(function(){function t(e){if("string"!=typeof e)throw new Error("[isHexPrefixed] input must be type 'string', received type "+typeof e);return"0"===e[0]&&"x"===e[1]}Object.defineProperty(r,"__esModule",{value:!0}),r.isHexString=r.getKeys=r.fromAscii=r.fromUtf8=r.toAscii=r.arrayContainsArray=r.getBinarySize=r.padToEven=r.stripHexPrefix=r.isHexPrefixed=void 0,r.isHexPrefixed=t;function n(e){let t=e;if("string"!=typeof t)throw new Error("[padToEven] value must be type 'string', received "+typeof t);return t.length%2&&(t=`0${t}`),t}r.stripHexPrefix=e=>{if("string"!=typeof e)throw new Error("[stripHexPrefix] input must be type 'string', received "+typeof e);return t(e)?e.slice(2):e},r.padToEven=n,r.getBinarySize=function(t){if("string"!=typeof t)throw new Error("[getBinarySize] method requires input type 'string', received "+typeof t);return e.byteLength(t,"utf8")},r.arrayContainsArray=function(e,t,r){if(!0!==Array.isArray(e))throw new Error(`[arrayContainsArray] method requires input 'superset' to be an array, got type '${typeof e}'`);if(!0!==Array.isArray(t))throw new Error(`[arrayContainsArray] method requires input 'subset' to be an array, got type '${typeof t}'`);return t[!0===r?"some":"every"]((t=>e.indexOf(t)>=0))},r.toAscii=function(e){let t="",r=0;const n=e.length;for("0x"===e.substring(0,2)&&(r=2);r<n;r+=2){const n=parseInt(e.substr(r,2),16);t+=String.fromCharCode(n)}return t},r.fromUtf8=function(t){return`0x${n(e.from(t,"utf8").toString("hex")).replace(/^0+|0+$/g,"")}`},r.fromAscii=function(e){let t="";for(let r=0;r<e.length;r++){const n=e.charCodeAt(r).toString(16);t+=n.length<2?`0${n}`:n}return`0x${t}`},r.getKeys=function(e,t,r){if(!Array.isArray(e))throw new Error("[getKeys] method expects input 'params' to be an array, got "+typeof e);if("string"!=typeof t)throw new Error("[getKeys] method expects input 'key' to be type 'string', got "+typeof e);const n=[];for(let s=0;s<e.length;s++){let i=e[s][t];if(!0!==r||i){if("string"!=typeof i)throw new Error("invalid abi - expected type 'string', received "+typeof i)}else i="";n.push(i)}return n},r.isHexString=function(e,t){return!("string"!=typeof e||!e.match(/^0x[0-9A-Fa-f]*$/))&&!(void 0!==t&&t>0&&e.length!==2+2*t)}}).call(this)}).call(this,e("buffer").Buffer)}}},{package:"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@ethereumjs/util",file:"node_modules/@metamask/eth-snap-keyring/node_modules/@ethereumjs/util/dist/internal.js"}],[1807,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.Lock=void 0;r.Lock=class{constructor(){this.permits=1,this.promiseResolverQueue=[]}async acquire(){return this.permits>0?(this.permits-=1,Promise.resolve(!0)):new Promise((e=>this.promiseResolverQueue.push(e)))}release(){if(this.permits+=1,this.permits>1&&this.promiseResolverQueue.length>0)console.warn("Lock.permits should never be > 0 when there is someone waiting.");else if(1===this.permits&&this.promiseResolverQueue.length>0){this.permits-=1;const e=this.promiseResolverQueue.shift();e&&e(!0)}}}}}},{package:"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@ethereumjs/util",file:"node_modules/@metamask/eth-snap-keyring/node_modules/@ethereumjs/util/dist/lock.js"}],[1808,{"micro-ftch":4910},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.getProvider=r.fetchFromProvider=void 0;const n=e("micro-ftch");r.fetchFromProvider=async(e,t)=>(await(0,n.default)(e,{headers:{"content-type":"application/json"},type:"json",data:{method:t.method,params:t.params,jsonrpc:"2.0",id:1}})).result;r.getProvider=e=>{if("string"==typeof e)return e;if(e?.connection?.url!==undefined)return e.connection.url;throw new Error("Must provide valid provider URL or Web3Provider")}}}},{package:"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@ethereumjs/util",file:"node_modules/@metamask/eth-snap-keyring/node_modules/@ethereumjs/util/dist/provider.js"}],[1809,{"./bytes":1801,"./constants":1802,"./helpers":1804,buffer:4074,"ethereum-cryptography/keccak":4300,"ethereum-cryptography/secp256k1":4317},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){(function(t){(function(){Object.defineProperty(r,"__esModule",{value:!0}),r.hashPersonalMessage=r.isValidSignature=r.fromRpcSig=r.toCompactSig=r.toRpcSig=r.ecrecover=r.ecsign=void 0;const n=e("ethereum-cryptography/keccak"),s=e("ethereum-cryptography/secp256k1"),i=e("./bytes"),o=e("./constants"),a=e("./helpers");function l(e,t){return e===BigInt(0)||e===BigInt(1)?e:t===undefined?e-BigInt(27):e-(t*BigInt(2)+BigInt(35))}function c(e){return e===BigInt(0)||e===BigInt(1)}r.ecsign=function(e,r,n){const i=s.secp256k1.sign(e,r),o=i.toCompactRawBytes();return{r:t.from(o.slice(0,32)),s:t.from(o.slice(32,64)),v:n===undefined?BigInt(i.recovery+27):BigInt(i.recovery+35)+BigInt(n)*BigInt(2)}};r.ecrecover=function(e,r,n,o,a){const u=t.concat([(0,i.setLengthLeft)(n,32),(0,i.setLengthLeft)(o,32)],64),d=l(r,a);if(!c(d))throw new Error("Invalid signature v value");const h=s.secp256k1.Signature.fromCompact(u).addRecoveryBit(Number(d)).recoverPublicKey(e);return t.from(h.toRawBytes(!1).slice(1))};r.toRpcSig=function(e,r,n,s){if(!c(l(e,s)))throw new Error("Invalid signature v value");return(0,i.bufferToHex)(t.concat([(0,i.setLengthLeft)(r,32),(0,i.setLengthLeft)(n,32),(0,i.toBuffer)(e)]))};r.toCompactSig=function(e,r,n,s){if(!c(l(e,s)))throw new Error("Invalid signature v value");let o=n;return(e>BigInt(28)&&e%BigInt(2)===BigInt(1)||e===BigInt(1)||e===BigInt(28))&&(o=t.from(n),o[0]|=128),(0,i.bufferToHex)(t.concat([(0,i.setLengthLeft)(r,32),(0,i.setLengthLeft)(o,32)]))};r.fromRpcSig=function(e){const t=(0,i.toBuffer)(e);let r,n,s;if(t.length>=65)r=t.slice(0,32),n=t.slice(32,64),s=(0,i.bufferToBigInt)(t.slice(64));else{if(64!==t.length)throw new Error("Invalid signature length");r=t.slice(0,32),n=t.slice(32,64),s=BigInt((0,i.bufferToInt)(t.slice(32,33))>>7),n[0]&=127}return s<27&&(s+=BigInt(27)),{v:s,r:r,s:n}};r.isValidSignature=function(e,t,r,n=!0,s){if(32!==t.length||32!==r.length)return!1;if(!c(l(e,s)))return!1;const a=(0,i.bufferToBigInt)(t),u=(0,i.bufferToBigInt)(r);return!(a===BigInt(0)||a>=o.SECP256K1_ORDER||u===BigInt(0)||u>=o.SECP256K1_ORDER)&&!(n&&u>=o.SECP256K1_ORDER_DIV_2)};r.hashPersonalMessage=function(e){(0,a.assertIsBuffer)(e);const r=t.from(`Ethereum Signed Message:\n${e.length}`,"utf-8");return t.from((0,n.keccak256)(t.concat([r,e])))}}).call(this)}).call(this,e("buffer").Buffer)}}},{package:"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@ethereumjs/util",file:"node_modules/@metamask/eth-snap-keyring/node_modules/@ethereumjs/util/dist/signature.js"}],[181,{"../../../../../shared/types/transaction-decode":5809,"./four-byte":176,"./proxy":177,"./sourcify":178,"./uniswap":180,"@metamask/utils":2950},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.decodeTransactionData=async function({transactionData:e,contractAddress:t,chainId:r,provider:n}){c("Decoding transaction data",{transactionData:e,contractAddress:t,chainId:r});const d=(0,i.decodeUniswapRouterTransactionData)({transactionData:e,contractAddress:t,chainId:r});if(d)return c("Decoded with Uniswap commands",d),{data:u(d),source:s.DecodedTransactionDataSource.Uniswap};const h=await(0,a.getContractProxyAddress)(t,n);h&&c("Retrieved proxy implementation address",h);const p=h??t,g=(0,o.decodeTransactionDataWithSourcify)(e,p,r),f=(0,l.decodeTransactionDataWithFourByte)(e),[m,y]=await Promise.allSettled([g,f]);if("fulfilled"===m.status&&m.value)return c("Decoded data with Sourcify",m.value),{data:u([m.value]),source:s.DecodedTransactionDataSource.Sourcify};if(c("Failed to decode data with Sourcify",m),"fulfilled"===y.status&&y.value)return c("Decoded data with 4Byte",y.value),{data:u([y.value]),source:s.DecodedTransactionDataSource.FourByte};return c("Failed to decode data with 4Byte",y),undefined};var n=e("@metamask/utils"),s=e("../../../../../shared/types/transaction-decode"),i=e("./uniswap"),o=e("./sourcify"),a=e("./proxy"),l=e("./four-byte");const c=(0,n.createProjectLogger)("transaction-decode");function u(e){return e.map((e=>function(e){return{...e,params:e.params.map((e=>d(e)))}}(e)))}function d(e){var t;return{...e,value:h(e.value),children:null===(t=e.children)||void 0===t?void 0:t.map((e=>d(e)))}}function h(e){const t=e._hex;return t?parseInt(t,16):e}}}},{package:"$root$",file:"app/scripts/lib/transaction/decode/util.ts"}],[1810,{"./bytes":1801,"./internal":1806},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.toType=r.TypeOutput=void 0;const n=e("./bytes"),s=e("./internal");var i;!function(e){e[e.Number=0]="Number",e[e.BigInt=1]="BigInt",e[e.Buffer=2]="Buffer",e[e.PrefixedHexString=3]="PrefixedHexString"}(i=r.TypeOutput||(r.TypeOutput={})),r.toType=function(e,t){if(null===e)return null;if(e===undefined)return undefined;if("string"==typeof e&&!(0,s.isHexString)(e))throw new Error(`A string must be provided with a 0x-prefix, given: ${e}`);if("number"==typeof e&&!Number.isSafeInteger(e))throw new Error("The provided number is greater than MAX_SAFE_INTEGER (please use an alternative input type)");const r=(0,n.toBuffer)(e);switch(t){case i.Buffer:return r;case i.BigInt:return(0,n.bufferToBigInt)(r);case i.Number:{const e=(0,n.bufferToBigInt)(r);if(e>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("The provided number is greater than MAX_SAFE_INTEGER (please use an alternative output type)");return Number(e)}case i.PrefixedHexString:return(0,n.bufferToHex)(r);default:throw new Error("unknown outputType")}}}}},{package:"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@ethereumjs/util",file:"node_modules/@metamask/eth-snap-keyring/node_modules/@ethereumjs/util/dist/types.js"}],[1811,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.GWEI_TO_WEI=void 0,r.GWEI_TO_WEI=BigInt(1e9)}}},{package:"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@ethereumjs/util",file:"node_modules/@metamask/eth-snap-keyring/node_modules/@ethereumjs/util/dist/units.js"}],[1812,{"./address":1799,"./bytes":1801,"./types":1810,buffer:4074},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){(function(t){(function(){Object.defineProperty(r,"__esModule",{value:!0}),r.Withdrawal=void 0;const n=e("./address"),s=e("./bytes"),i=e("./types");class o{constructor(e,t,r,n){this.index=e,this.validatorIndex=t,this.address=r,this.amount=n}static fromWithdrawalData(e){const{index:t,validatorIndex:r,address:s,amount:a}=e,l=(0,i.toType)(t,i.TypeOutput.BigInt),c=(0,i.toType)(r,i.TypeOutput.BigInt),u=new n.Address((0,i.toType)(s,i.TypeOutput.Buffer)),d=(0,i.toType)(a,i.TypeOutput.BigInt);return new o(l,c,u,d)}static fromValuesArray(e){if(4!==e.length)throw Error(`Invalid withdrawalArray length expected=4 actual=${e.length}`);const[t,r,n,s]=e;return o.fromWithdrawalData({index:t,validatorIndex:r,address:n,amount:s})}static toBufferArray(e){const{index:r,validatorIndex:s,address:o,amount:a}=e,l=(0,i.toType)(r,i.TypeOutput.BigInt)===BigInt(0)?t.alloc(0):(0,i.toType)(r,i.TypeOutput.Buffer),c=(0,i.toType)(s,i.TypeOutput.BigInt)===BigInt(0)?t.alloc(0):(0,i.toType)(s,i.TypeOutput.Buffer);let u;u=o instanceof n.Address?o.buf:(0,i.toType)(o,i.TypeOutput.Buffer);return[l,c,u,(0,i.toType)(a,i.TypeOutput.BigInt)===BigInt(0)?t.alloc(0):(0,i.toType)(a,i.TypeOutput.Buffer)]}raw(){return o.toBufferArray(this)}toValue(){return{index:this.index,validatorIndex:this.validatorIndex,address:this.address.buf,amount:this.amount}}toJSON(){return{index:(0,s.bigIntToHex)(this.index),validatorIndex:(0,s.bigIntToHex)(this.validatorIndex),address:"0x"+this.address.buf.toString("hex"),amount:(0,s.bigIntToHex)(this.amount)}}}r.Withdrawal=o}).call(this)}).call(this,e("buffer").Buffer)}}},{package:"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@ethereumjs/util",file:"node_modules/@metamask/eth-snap-keyring/node_modules/@ethereumjs/util/dist/withdrawal.js"}],[1813,{"./errors":1814,"./packer":1817,"@metamask/utils":2950},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.decodeSingle=r.decode=r.encodePacked=r.encodeSingle=r.encode=void 0;const n=e("@metamask/utils"),s=e("./errors"),i=e("./packer");r.encode=(e,t,r,n)=>{try{return(0,i.pack)({types:e,values:t,packed:r,tight:n})}catch(e){if(e instanceof s.ParserError)throw new s.ParserError(`Unable to encode value: ${e.message}`,e);throw new s.ParserError(`An unexpected error occurred: ${(0,s.getErrorMessage)(e)}`,e)}};r.encodeSingle=(e,t)=>(0,r.encode)([e],[t]);r.encodePacked=(e,t,n)=>(0,r.encode)(e,t,!0,n);r.decode=(e,t)=>{const r=(0,n.createBytes)(t);try{return(0,i.unpack)(e,r)}catch(e){if(e instanceof s.ParserError)throw new s.ParserError(`Unable to decode value: ${e.message}`,e);throw new s.ParserError(`An unexpected error occurred: ${(0,s.getErrorMessage)(e)}`,e)}};r.decodeSingle=(e,t)=>{const i=(0,r.decode)([e],t);return(0,n.assert)(1===i.length,new s.ParserError("Decoded value array has unexpected length.")),i[0]}}}},{package:"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@metamask/abi-utils",file:"node_modules/@metamask/eth-snap-keyring/node_modules/@metamask/abi-utils/dist/abi.js"}],[1814,{"@metamask/utils":2950},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.ParserError=r.getErrorStack=r.getErrorMessage=void 0;const n=e("@metamask/utils");r.getErrorMessage=e=>"string"==typeof e?e:e instanceof Error||(0,n.isObject)(e)&&(0,n.hasProperty)(e,"message")&&"string"==typeof e.message?e.message:"Unknown error.";r.getErrorStack=e=>e instanceof Error?e.stack:undefined;class s extends Error{constructor(e,t){super(e),this.name="ParserError";const n=(0,r.getErrorStack)(t);n&&(this.stack=n)}}r.ParserError=s}}},{package:"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@metamask/abi-utils",file:"node_modules/@metamask/eth-snap-keyring/node_modules/@metamask/abi-utils/dist/errors.js"}],[1815,{"./abi":1813,"./errors":1814,"./types":1830},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){n===undefined&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){n===undefined&&(n=r),e[n]=t[r]}),s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(r,"__esModule",{value:!0}),s(e("./abi"),r),s(e("./errors"),r),s(e("./types"),r)}}},{package:"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@metamask/abi-utils",file:"node_modules/@metamask/eth-snap-keyring/node_modules/@metamask/abi-utils/dist/index.js"}],[1816,{"@metamask/utils":2950},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.iterate=void 0;const n=e("@metamask/utils");r.iterate=function*(e,t=32){for(let r=0;r<e.length;r+=t){const s=e=>{(0,n.assert)(e>=0,"Cannot skip a negative number of bytes."),(0,n.assert)(e%t==0,"Length must be a multiple of the size."),r+=e},i=e.subarray(r);yield{skip:s,value:i}}return{skip:()=>undefined,value:new Uint8Array}}}}},{package:"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@metamask/abi-utils",file:"node_modules/@metamask/eth-snap-keyring/node_modules/@metamask/abi-utils/dist/iterator.js"}],[1817,{"./errors":1814,"./iterator":1816,"./parsers":1824,"./utils":1832,"@metamask/utils":2950},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.unpack=r.pack=r.isDynamicParser=r.getParser=void 0;const n=e("@metamask/utils"),s=e("./errors"),i=e("./iterator"),o=e("./parsers"),a=e("./utils");r.getParser=e=>{const t={address:o.address,array:o.array,bool:o.bool,bytes:o.bytes,fixedBytes:o.fixedBytes,function:o.fn,number:o.number,string:o.string,tuple:o.tuple},r=t[e];if(r)return r;const n=Object.values(t).find((t=>t.isType(e)));if(n)return n;throw new s.ParserError(`The type "${e}" is not supported.`)};r.isDynamicParser=(e,t)=>{const{isDynamic:r}=e;return"function"==typeof r?r(t):r};r.pack=({types:e,values:t,packed:i=!1,tight:o=!1,arrayPacked:l=!1,byteArray:c=new Uint8Array})=>{(0,n.assert)(e.length===t.length,new s.ParserError(`The number of types (${e.length}) does not match the number of values (${t.length}).`));const{staticBuffer:u,dynamicBuffer:d,pointers:h}=e.reduce((({staticBuffer:e,dynamicBuffer:s,pointers:a},c,u)=>{const d=(0,r.getParser)(c),h=t[u];if(i||l||!(0,r.isDynamicParser)(d,c))return{staticBuffer:d.encode({buffer:e,value:h,type:c,packed:i,tight:o}),dynamicBuffer:s,pointers:a};return{staticBuffer:(0,n.concatBytes)([e,new Uint8Array(32)]),dynamicBuffer:d.encode({buffer:s,value:h,type:c,packed:i,tight:o}),pointers:[...a,{position:e.length,pointer:s.length}]}}),{staticBuffer:new Uint8Array,dynamicBuffer:new Uint8Array,pointers:[]});(0,n.assert)(!i&&!l||0===d.length,new s.ParserError("Invalid pack state."));const p=u.length,g=h.reduce(((e,{pointer:t,position:r})=>{const s=(0,a.padStart)((0,n.numberToBytes)(p+t));return(0,a.set)(e,s,r)}),u);return(0,n.concatBytes)([c,g,d])};r.unpack=(e,t)=>{const o=(0,i.iterate)(t);return e.map((e=>{const{value:{value:i,skip:a},done:l}=o.next();(0,n.assert)(!l,new s.ParserError(`The encoded value is invalid for the provided types. Reached end of buffer while attempting to parse "${e}".`));const c=(0,r.getParser)(e);if((0,r.isDynamicParser)(c,e)){const r=(0,n.bytesToNumber)(i.subarray(0,32)),s=t.subarray(r);return c.decode({type:e,value:s,skip:a})}return c.decode({type:e,value:i,skip:a})}))}}}},{package:"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@metamask/abi-utils",file:"node_modules/@metamask/eth-snap-keyring/node_modules/@metamask/abi-utils/dist/packer.js"}],[1818,{"../errors":1814,"../utils":1832,"@metamask/utils":2950},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.address=r.getAddress=void 0;const n=e("@metamask/utils"),s=e("../errors"),i=e("../utils");r.getAddress=e=>{const t=(0,n.createBytes)(e);return(0,n.assert)(t.length<=20,new s.ParserError(`Invalid address value. Expected address to be 20 bytes long, but received ${t.length} bytes.`)),(0,i.padStart)(t,20)},r.address={isDynamic:!1,isType:e=>"address"===e,getByteLength:()=>32,encode({buffer:e,value:t,packed:s}){const o=(0,r.getAddress)(t);if(s)return(0,n.concatBytes)([e,o]);const a=(0,i.padStart)(o);return(0,n.concatBytes)([e,a])},decode:({value:e})=>(0,n.add0x)((0,n.bytesToHex)(e.slice(12,32)))}}}},{package:"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@metamask/abi-utils",file:"node_modules/@metamask/eth-snap-keyring/node_modules/@metamask/abi-utils/dist/parsers/address.js"}],[1819,{"../errors":1814,"../packer":1817,"../utils":1832,"./fixed-bytes":1822,"./tuple":1828,"@metamask/utils":2950},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.array=r.getTupleType=r.getArrayType=r.isArrayType=void 0;const n=e("@metamask/utils"),s=e("../errors"),i=e("../packer"),o=e("../utils"),a=e("./fixed-bytes"),l=e("./tuple"),c=/^(?<type>.*)\[(?<length>\d*?)\]$/u;r.isArrayType=e=>c.test(e);r.getArrayType=e=>{const t=e.match(c);return(0,n.assert)(t?.groups?.type,new s.ParserError(`Invalid array type. Expected an array type, but received "${e}".`)),[t.groups.type,t.groups.length?parseInt(t.groups.length,10):undefined]};r.getTupleType=(e,t)=>`(${new Array(t).fill(e).join(",")})`,r.array={isDynamic(e){const[t,n]=(0,r.getArrayType)(e);return n===undefined||(0,i.isDynamicParser)((0,i.getParser)(t),t)},isType:e=>(0,r.isArrayType)(e),getByteLength(e){(0,n.assert)((0,r.isArrayType)(e),new s.ParserError(`Expected an array type, but received "${e}".`));const[t,o]=(0,r.getArrayType)(e);return(0,i.isDynamicParser)(this,e)||o===undefined?32:l.tuple.getByteLength((0,r.getTupleType)(t,o))},encode({type:e,buffer:t,value:c,packed:u,tight:d}){const[h,p]=(0,r.getArrayType)(e);if((0,n.assert)(!u||!(0,r.isArrayType)(h),new s.ParserError("Cannot pack nested arrays.")),u&&(0,i.isDynamicParser)((0,i.getParser)(h),h))return(0,i.pack)({types:new Array(c.length).fill(h),values:c,byteArray:t,packed:u,arrayPacked:!0,tight:d});if(p)return(0,n.assert)(p===c.length,new s.ParserError(`Array length does not match type length. Expected a length of ${p}, but received ${c.length}.`)),l.tuple.encode({type:(0,r.getTupleType)(h,p),buffer:t,value:c,packed:a.fixedBytes.isType(h)&&d,tight:d});if(u)return(0,i.pack)({types:new Array(c.length).fill(h),values:c,byteArray:t,packed:a.fixedBytes.isType(h)&&d,arrayPacked:!0,tight:d});const g=(0,o.padStart)((0,n.numberToBytes)(c.length));return(0,i.pack)({types:new Array(c.length).fill(h),values:c,byteArray:(0,n.concatBytes)([t,g]),packed:u,tight:d})},decode({type:e,value:t,...o}){const[a,c]=(0,r.getArrayType)(e);if(c){const e=l.tuple.decode({type:(0,r.getTupleType)(a,c),value:t,...o});return(0,n.assert)(e.length===c,new s.ParserError(`Array length does not match type length. Expected a length of ${c}, but received ${e.length}.`)),e}const u=(0,n.bytesToNumber)(t.subarray(0,32));return(0,i.unpack)(new Array(u).fill(a),t.subarray(32))}}}}},{package:"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@metamask/abi-utils",file:"node_modules/@metamask/eth-snap-keyring/node_modules/@metamask/abi-utils/dist/parsers/array.js"}],[182,{"../../../../shared/constants/transaction":5749,"../ppom/ppom-util":135,"@metamask/eth-json-rpc-middleware":1592,"@metamask/rpc-errors":2554,"@metamask/transaction-controller":2905},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.AtomicCapabilityStatus=void 0,r.getCallsStatus=function(e,t){const r=e.call("TransactionController:getState").transactions.filter((e=>e.batchId===t));if(null==r||!r.length)throw new n.JsonRpcError(a.EIP5792ErrorCode.UnknownBundleId,"No matching bundle found");const o=r[0],{chainId:l,txReceipt:u}=o,d=function(e){const{hash:t,status:r}=e;if(r===s.TransactionStatus.confirmed)return i.GetCallsStatusCode.CONFIRMED;if(r===s.TransactionStatus.failed)return t?i.GetCallsStatusCode.REVERTED:i.GetCallsStatusCode.FAILED_OFFCHAIN;if(r===s.TransactionStatus.dropped)return i.GetCallsStatusCode.REVERTED;return i.GetCallsStatusCode.PENDING}(o),h=u,p=(null==h?void 0:h.logs)??[],g=h&&[{blockHash:h.blockHash,blockNumber:h.blockNumber,gasUsed:h.gasUsed,logs:p.map((e=>({address:e.address,data:e.data,topics:e.topics}))),status:h.status,transactionHash:h.transactionHash}];return{version:c,id:t,chainId:l,atomic:!0,status:d,receipts:g}},r.getCapabilities=async function(e,t,r){const{getDisabledAccountUpgradeChains:n,isAtomicBatchSupported:s}=e,i=null==r?void 0:r.map((e=>e.toLowerCase()));return(await s({address:t,chainIds:i})).reduce(((e,t)=>{var r;const{chainId:s}=t,{delegationAddress:i,isSupported:o,upgradeContractAddress:a}=t,c=null===(r=n())||void 0===r?void 0:r.includes(s);if(!o&&!(!c&&a&&!i))return e;const u=o?l.Supported:l.Ready;return e[s]={atomic:{status:u}},e}),{})},r.processSendCalls=async function(e,t,r,s){const{addTransactionBatch:i,getDisabledAccountUpgradeChains:l,isAtomicBatchSupported:u,validateSecurity:d}=e,{calls:h,from:p}=r,{networkClientId:g,origin:f}=s,m=h.map((e=>({params:e}))),y=t.call("NetworkController:getNetworkClientById",g).configuration.chainId,b=p??t.call("AccountsController:getSelectedAccount").address,k=l(),w=await u({address:b,chainIds:[y]}),v=null==w?void 0:w[0];!function(e,t,r,s,i){(function(e){const{version:t}=e;if(t!==c)throw n.rpcErrors.invalidInput(`Version not supported: Got ${t}, expected ${c}`)})(e),function(e,t,r){const{chainId:s}=e;if(s&&s.toLowerCase()!==t.toLowerCase())throw n.rpcErrors.invalidParams(`Chain ID must match the dApp selected network: Got ${s}, expected ${t}`);if(!r)throw new n.JsonRpcError(a.EIP5792ErrorCode.UnsupportedChainId,`EIP-7702 not supported on chain: ${t}`)}(e,r,i),function(e){const{calls:t,capabilities:r}=e,s=Object.keys(r??{}).filter((e=>!0!==(null==r?void 0:r[e].optional))),i=t.flatMap((e=>Object.keys(e.capabilities??{}).filter((t=>{var r;return!0!==(null===(r=e.capabilities)||void 0===r?void 0:r[t].optional)})))),o=[...s,...i];if(null!=o&&o.length)throw new n.JsonRpcError(a.EIP5792ErrorCode.UnsupportedNonOptionalCapability,`Unsupported non-optional capabilities: ${o.join(", ")}`)}(e),function(e,t,r,s){if(null!=s&&s.delegationAddress)return;const i=t.includes(r);if(i)throw new n.JsonRpcError(a.EIP5792ErrorCode.RejectedUpgrade,`EIP-7702 upgrade rejected for this chain and account - Chain ID: ${r}, Account: ${e}`)}(t,s,r,i)}(r,b,y,k,v);const C=(0,o.generateSecurityAlertId)(),T=d.bind(null,C),{batchId:S}=await i({from:b,networkClientId:g,origin:f,securityAlertId:C,transactions:m,validateSecurity:T});return{id:S}};var n=e("@metamask/rpc-errors"),s=e("@metamask/transaction-controller"),i=e("@metamask/eth-json-rpc-middleware"),o=e("../ppom/ppom-util"),a=e("../../../../shared/constants/transaction");let l=r.AtomicCapabilityStatus=function(e){return e.Supported="supported",e.Ready="ready",e.Unsupported="unsupported",e}({});const c="2.0.0"}}},{package:"$root$",file:"app/scripts/lib/transaction/eip5792.ts"}],[1820,{"../errors":1814,"./number":1825,"@metamask/superstruct":2872,"@metamask/utils":2950},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.bool=r.getBooleanValue=void 0;const n=e("@metamask/superstruct"),s=e("@metamask/utils"),i=e("../errors"),o=e("./number"),a=(0,n.coerce)((0,n.boolean)(),(0,n.union)([(0,n.literal)("true"),(0,n.literal)("false")]),(e=>"true"===e));r.getBooleanValue=e=>{try{return(0,n.create)(e,a)?BigInt(1):BigInt(0)}catch{throw new i.ParserError(`Invalid boolean value. Expected a boolean literal, or the string "true" or "false", but received "${e}".`)}},r.bool={isDynamic:!1,isType:e=>"bool"===e,getByteLength:()=>32,encode({buffer:e,value:t,packed:n,tight:i}){const a=(0,r.getBooleanValue)(t);return n?(0,s.concatBytes)([e,(0,s.bigIntToBytes)(a)]):o.number.encode({type:"uint256",buffer:e,value:a,packed:n,tight:i})},decode:e=>o.number.decode({...e,type:"uint256"})===BigInt(1)}}}},{package:"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@metamask/abi-utils",file:"node_modules/@metamask/eth-snap-keyring/node_modules/@metamask/abi-utils/dist/parsers/bool.js"}],[1821,{"../utils":1832,"@metamask/utils":2950},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.bytes=void 0;const n=e("@metamask/utils"),s=e("../utils");r.bytes={isDynamic:!0,isType:e=>"bytes"===e,getByteLength:()=>32,encode({buffer:e,value:t,packed:r}){const i=(0,n.createBytes)(t);if(r)return(0,n.concatBytes)([e,i]);const o=32*Math.ceil(i.byteLength/32);return(0,n.concatBytes)([e,(0,s.padStart)((0,n.numberToBytes)(i.byteLength)),(0,s.padEnd)(i,o)])},decode({value:e}){const t=e.subarray(0,32),r=(0,n.bytesToNumber)(t);return e.slice(32,32+r)}}}}},{package:"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@metamask/abi-utils",file:"node_modules/@metamask/eth-snap-keyring/node_modules/@metamask/abi-utils/dist/parsers/bytes.js"}],[1822,{"../errors":1814,"../utils":1832,"@metamask/utils":2950},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.fixedBytes=r.getByteLength=void 0;const n=e("@metamask/utils"),s=e("../errors"),i=e("../utils"),o=/^bytes([0-9]{1,2})$/u;r.getByteLength=e=>{const t=e.match(o)?.[1];(0,n.assert)(t,`Invalid byte length. Expected a number between 1 and 32, but received "${e}".`);const r=Number(t);return(0,n.assert)(r>0&&r<=32,new s.ParserError(`Invalid byte length. Expected a number between 1 and 32, but received "${e}".`)),r},r.fixedBytes={isDynamic:!1,isType:e=>o.test(e),getByteLength:()=>32,encode({type:e,buffer:t,value:o,packed:a}){const l=(0,r.getByteLength)(e),c=(0,n.createBytes)(o);return(0,n.assert)(c.length<=l,new s.ParserError(`Expected a value of length ${l}, but received a value of length ${c.length}.`)),a?(0,n.concatBytes)([t,(0,i.padEnd)(c,l)]):(0,n.concatBytes)([t,(0,i.padEnd)(c)])},decode({type:e,value:t}){const n=(0,r.getByteLength)(e);return t.slice(0,n)}}}}},{package:"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@metamask/abi-utils",file:"node_modules/@metamask/eth-snap-keyring/node_modules/@metamask/abi-utils/dist/parsers/fixed-bytes.js"}],[1823,{"../errors":1814,"./fixed-bytes":1822,"@metamask/superstruct":2872,"@metamask/utils":2950},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.fn=r.getFunction=void 0;const n=e("@metamask/superstruct"),s=e("@metamask/utils"),i=e("../errors"),o=e("./fixed-bytes"),a=(0,n.coerce)((0,n.object)({address:s.StrictHexStruct,selector:s.StrictHexStruct}),(0,n.union)([s.StrictHexStruct,(0,n.instance)(Uint8Array)]),(e=>{const t=(0,s.createBytes)(e);return(0,s.assert)(24===t.length,new i.ParserError(`Invalid Solidity function. Expected function to be 24 bytes long, but received ${t.length} bytes.`)),{address:(0,s.bytesToHex)(t.subarray(0,20)),selector:(0,s.bytesToHex)(t.subarray(20,24))}}));r.getFunction=e=>{const t=(0,n.create)(e,a);return(0,s.concatBytes)([(0,s.hexToBytes)(t.address),(0,s.hexToBytes)(t.selector)])},r.fn={isDynamic:!1,isType:e=>"function"===e,getByteLength:()=>32,encode({buffer:e,value:t,packed:n,tight:s}){const i=(0,r.getFunction)(t);return o.fixedBytes.encode({type:"bytes24",buffer:e,value:i,packed:n,tight:s})},decode:({value:e})=>({address:(0,s.bytesToHex)(e.slice(0,20)),selector:(0,s.bytesToHex)(e.slice(20,24))})}}}},{package:"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@metamask/abi-utils",file:"node_modules/@metamask/eth-snap-keyring/node_modules/@metamask/abi-utils/dist/parsers/function.js"}],[1824,{"./address":1818,"./array":1819,"./bool":1820,"./bytes":1821,"./fixed-bytes":1822,"./function":1823,"./number":1825,"./parser":1826,"./string":1827,"./tuple":1828},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){n===undefined&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){n===undefined&&(n=r),e[n]=t[r]}),s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(r,"__esModule",{value:!0}),s(e("./address"),r),s(e("./array"),r),s(e("./bool"),r),s(e("./bytes"),r),s(e("./fixed-bytes"),r),s(e("./function"),r),s(e("./number"),r),s(e("./parser"),r),s(e("./string"),r),s(e("./tuple"),r)}}},{package:"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@metamask/abi-utils",file:"node_modules/@metamask/eth-snap-keyring/node_modules/@metamask/abi-utils/dist/parsers/index.js"}],[1825,{"../errors":1814,"../utils":1832,"@metamask/utils":2950},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.number=r.getBigInt=r.assertNumberLength=r.getLength=r.isSigned=void 0;const n=e("@metamask/utils"),s=e("../errors"),i=e("../utils"),o=/^u?int(?<length>[0-9]*)?$/u;r.isSigned=e=>!e.startsWith("u");r.getLength=e=>{if("int"===e||"uint"===e)return 256;const t=e.match(o);(0,n.assert)(t?.groups?.length,new s.ParserError(`Invalid number type. Expected a number type, but received "${e}".`));const r=parseInt(t.groups.length,10);return(0,n.assert)(r>=8&&r<=256,new s.ParserError(`Invalid number length. Expected a number between 8 and 256, but received "${e}".`)),(0,n.assert)(r%8==0,new s.ParserError(`Invalid number length. Expected a multiple of 8, but received "${e}".`)),r};r.assertNumberLength=(e,t)=>{const i=(0,r.getLength)(t),o=BigInt(2)**BigInt(i-((0,r.isSigned)(t)?1:0))-BigInt(1);(0,r.isSigned)(t)?(0,n.assert)(e>=-(o+BigInt(1))&&e<=o,new s.ParserError(`Number "${e}" is out of range for type "${t}".`)):(0,n.assert)(e<=o,new s.ParserError(`Number "${e}" is out of range for type "${t}".`))};r.getBigInt=e=>{try{return(0,n.createBigInt)(e)}catch{throw new s.ParserError(`Invalid number. Expected a valid number value, but received "${e}".`)}},r.number={isDynamic:!1,isType:e=>o.test(e),getByteLength:()=>32,encode({type:e,buffer:t,value:s,packed:o}){const a=(0,r.getBigInt)(s);if((0,r.assertNumberLength)(a,e),(0,r.isSigned)(e)){if(o){const s=(0,r.getLength)(e)/8;return(0,n.concatBytes)([t,(0,n.signedBigIntToBytes)(a,s)])}return(0,n.concatBytes)([t,(0,i.padStart)((0,n.signedBigIntToBytes)(a,32))])}if(o){const s=(0,r.getLength)(e)/8;return(0,n.concatBytes)([t,(0,i.padStart)((0,n.bigIntToBytes)(a),s)])}return(0,n.concatBytes)([t,(0,i.padStart)((0,n.bigIntToBytes)(a))])},decode({type:e,value:t}){const s=t.subarray(0,32);if((0,r.isSigned)(e)){const t=(0,n.bytesToSignedBigInt)(s);return(0,r.assertNumberLength)(t,e),t}const i=(0,n.bytesToBigInt)(s);return(0,r.assertNumberLength)(i,e),i}}}}},{package:"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@metamask/abi-utils",file:"node_modules/@metamask/eth-snap-keyring/node_modules/@metamask/abi-utils/dist/parsers/number.js"}],[1826,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0})}}},{package:"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@metamask/abi-utils",file:"node_modules/@metamask/eth-snap-keyring/node_modules/@metamask/abi-utils/dist/parsers/parser.js"}],[1827,{"./bytes":1821,"@metamask/utils":2950},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.string=void 0;const n=e("@metamask/utils"),s=e("./bytes");r.string={isDynamic:!0,isType:e=>"string"===e,getByteLength:()=>32,encode:({buffer:e,value:t,packed:r,tight:i})=>s.bytes.encode({type:"bytes",buffer:e,value:(0,n.stringToBytes)(t),packed:r,tight:i}),decode:e=>(0,n.bytesToString)(s.bytes.decode(e))}}}},{package:"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@metamask/abi-utils",file:"node_modules/@metamask/eth-snap-keyring/node_modules/@metamask/abi-utils/dist/parsers/string.js"}],[1828,{"../errors":1814,"../packer":1817,"@metamask/utils":2950},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.tuple=r.getTupleElements=void 0;const n=e("@metamask/utils"),s=e("../errors"),i=e("../packer"),o=/^\((.+)\)$/u;r.getTupleElements=e=>{(0,n.assert)(e.startsWith("(")&&e.endsWith(")"),new s.ParserError(`Invalid tuple type. Expected tuple type, but received "${e}".`));const t=[];let r="",i=0;for(let n=1;n<e.length-1;n++){const s=e[n];","===s&&0===i?(t.push(r.trim()),r=""):(r+=s,"("===s?i+=1:")"===s&&(i-=1))}return r.trim()&&t.push(r.trim()),t},r.tuple={isDynamic:e=>(0,r.getTupleElements)(e).some((e=>{const t=(0,i.getParser)(e);return(0,i.isDynamicParser)(t,e)})),isType:e=>(e=>o.test(e))(e),getByteLength(e){if((0,i.isDynamicParser)(this,e))return 32;return(0,r.getTupleElements)(e).reduce(((e,t)=>e+(0,i.getParser)(t).getByteLength(t)),0)},encode({type:e,buffer:t,value:n,packed:s,tight:o}){const a=(0,r.getTupleElements)(e);return(0,i.pack)({types:a,values:n,byteArray:t,packed:s,tight:o})},decode({type:e,value:t,skip:n}){const s=(0,r.getTupleElements)(e);return n(this.getByteLength(e)-32),(0,i.unpack)(s,t)}}}}},{package:"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@metamask/abi-utils",file:"node_modules/@metamask/eth-snap-keyring/node_modules/@metamask/abi-utils/dist/parsers/tuple.js"}],[1829,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0})}}},{package:"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@metamask/abi-utils",file:"node_modules/@metamask/eth-snap-keyring/node_modules/@metamask/abi-utils/dist/types/abi.js"}],[183,{"../../../../shared/constants/app":5719,"../../../../shared/constants/gas":5725,"../../../../shared/constants/metametrics":5730,"../../../../shared/constants/transaction":5749,"../../../../shared/lib/confirmation.utils":5761,"../../../../shared/lib/transactions-controller-utils":5775,"../../../../shared/modules/Numeric":5777,"../../../../shared/modules/conversion.utils":5782,"../../../../shared/modules/gas.utils":5787,"../../../../shared/modules/metametrics":5790,"../../../../shared/modules/transaction.utils":5804,"../../../../ui/helpers/utils/metrics":6805,"../snap-keyring/metrics":164,"@metamask/rpc-errors":2554,"@metamask/transaction-controller":2905,"@metamask/utils":2950,"bignumber.js":3978,"ethereumjs-util":4327},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.handleTransactionSubmitted=r.handleTransactionRejected=r.handleTransactionFailed=r.handleTransactionDropped=r.handleTransactionConfirmed=r.handleTransactionApproved=r.handleTransactionAdded=r.handlePostTransactionBalanceUpdate=r.createTransactionEventFragmentWithTxId=r.METRICS_STATUS_FAILED=void 0;var n=e("bignumber.js"),s=e("ethereumjs-util"),i=e("@metamask/transaction-controller"),o=e("@metamask/utils"),a=e("@metamask/rpc-errors"),l=e("../../../../shared/constants/app"),c=e("../../../../shared/constants/gas"),u=e("../../../../shared/constants/metametrics"),d=e("../../../../shared/constants/transaction"),h=e("../../../../shared/lib/transactions-controller-utils"),p=e("../../../../shared/modules/conversion.utils"),g=e("../../../../shared/modules/metametrics"),f=e("../../../../shared/modules/transaction.utils"),m=e("../../../../ui/helpers/utils/metrics"),y=e("../snap-keyring/metrics"),b=e("../../../../shared/lib/confirmation.utils"),k=e("../../../../shared/modules/gas.utils"),w=e("../../../../shared/modules/Numeric");const v=r.METRICS_STATUS_FAILED="failed on-chain";r.handleTransactionAdded=async(e,t)=>{if(!t.transactionMeta)return;const{properties:r,sensitiveProperties:n}=await A({transactionEventPayload:t,transactionMetricsRequest:e});C({eventName:d.TransactionMetaMetricsEvent.added,transactionEventPayload:t,transactionMetricsRequest:e,payload:{properties:r,sensitiveProperties:n}})};r.handleTransactionApproved=async(e,t)=>{t.transactionMeta&&await T({eventName:d.TransactionMetaMetricsEvent.approved,transactionEventPayload:t,transactionMetricsRequest:e})};r.handleTransactionFailed=async(e,t)=>{if(!t.transactionMeta)return;const r={};t.error&&(r.error=t.error),await T({eventName:d.TransactionMetaMetricsEvent.finalized,extraParams:r,transactionEventPayload:t,transactionMetricsRequest:e})};r.handleTransactionConfirmed=async(e,t)=>{if(0===Object.keys(t).length)return;const r={},n={...t},{txReceipt:s}=n;r.gas_used=null==s?void 0:s.gasUsed,r.block_number=(null==s?void 0:s.blockNumber)&&(0,p.hexToDecimal)(s.blockNumber);const{submittedTime:i,blockTimestamp:o}=n;i&&(r.completion_time=function(e){return Math.round((Date.now()-e)/1e3).toString()}(i)),i&&o&&(r.completion_time_onchain=function(e,t){const r=2,n=Number((0,p.hexToDecimal)(t))-e/1e3;return(Math.round(n*10**r)/10**r).toString()}(i,o)),"0x0"===(null==s?void 0:s.status)&&(r.status=v),await T({eventName:d.TransactionMetaMetricsEvent.finalized,extraParams:r,transactionEventPayload:{actionId:n.actionId,transactionMeta:n},transactionMetricsRequest:e})};r.handleTransactionDropped=async(e,t)=>{if(!t.transactionMeta)return;await T({eventName:d.TransactionMetaMetricsEvent.finalized,extraParams:{dropped:!0},transactionEventPayload:t,transactionMetricsRequest:e})};r.handleTransactionRejected=async(e,t)=>{t.transactionMeta&&await T({eventName:d.TransactionMetaMetricsEvent.rejected,transactionEventPayload:t,transactionMetricsRequest:e})};r.handleTransactionSubmitted=async(e,t)=>{if(!t.transactionMeta)return;const{properties:r,sensitiveProperties:n}=await A({transactionEventPayload:t,transactionMetricsRequest:e});C({eventName:d.TransactionMetaMetricsEvent.submitted,transactionEventPayload:t,transactionMetricsRequest:e,payload:{properties:r,sensitiveProperties:n}})};r.createTransactionEventFragmentWithTxId=async(e,{transactionId:t,actionId:r})=>{const n={...e.getTransaction(t),actionId:r},{properties:s,sensitiveProperties:i}=await A({transactionEventPayload:{transactionMeta:n},transactionMetricsRequest:e});C({eventName:d.TransactionMetaMetricsEvent.approved,transactionEventPayload:{actionId:n.actionId,transactionMeta:n},transactionMetricsRequest:e,payload:{properties:s,sensitiveProperties:i}})};function C({eventName:e,transactionEventPayload:{transactionMeta:t,actionId:r},transactionMetricsRequest:n,payload:s}){if(function(e,t,r){const n=S(t,r.id);return void 0!==e(n)}(n.getEventFragmentById,e,t)&&e!==d.TransactionMetaMetricsEvent.submitted)return;const i=S(e,t.id);switch(e){case d.TransactionMetaMetricsEvent.added:n.createEventFragment({category:u.MetaMetricsEventCategory.Transactions,initialEvent:d.TransactionMetaMetricsEvent.added,successEvent:d.TransactionMetaMetricsEvent.approved,failureEvent:d.TransactionMetaMetricsEvent.rejected,properties:s.properties,sensitiveProperties:s.sensitiveProperties,actionId:r,uniqueIdentifier:i,persist:!0});break;case d.TransactionMetaMetricsEvent.approved:case d.TransactionMetaMetricsEvent.rejected:n.createEventFragment({category:u.MetaMetricsEventCategory.Transactions,successEvent:d.TransactionMetaMetricsEvent.approved,failureEvent:d.TransactionMetaMetricsEvent.rejected,properties:s.properties,sensitiveProperties:s.sensitiveProperties,actionId:r,uniqueIdentifier:i,persist:!0});break;case d.TransactionMetaMetricsEvent.submitted:n.createEventFragment({category:u.MetaMetricsEventCategory.Transactions,initialEvent:d.TransactionMetaMetricsEvent.submitted,successEvent:d.TransactionMetaMetricsEvent.finalized,properties:s.properties,sensitiveProperties:s.sensitiveProperties,actionId:r,uniqueIdentifier:i,persist:!0});break;case d.TransactionMetaMetricsEvent.finalized:n.createEventFragment({category:u.MetaMetricsEventCategory.Transactions,successEvent:d.TransactionMetaMetricsEvent.finalized,properties:s.properties,sensitiveProperties:s.sensitiveProperties,actionId:r,uniqueIdentifier:i,persist:!0})}}async function T({eventName:e,transactionEventPayload:t,transactionMetricsRequest:r,extraParams:n={}}){const{properties:s,sensitiveProperties:i}=await A({transactionEventPayload:t,transactionMetricsRequest:r,extraParams:n});C({eventName:e,transactionEventPayload:t,transactionMetricsRequest:r,payload:{properties:s,sensitiveProperties:i}}),function({eventName:e,transactionEventPayload:{transactionMeta:t},transactionMetricsRequest:r,payload:n}){const s=S(e,t.id);switch(e){case d.TransactionMetaMetricsEvent.approved:case d.TransactionMetaMetricsEvent.rejected:case d.TransactionMetaMetricsEvent.finalized:r.updateEventFragment(s,{properties:n.properties,sensitiveProperties:n.sensitiveProperties})}}({eventName:e,transactionEventPayload:t,transactionMetricsRequest:r,payload:{properties:s,sensitiveProperties:i}}),function({eventName:e,transactionMetricsRequest:t,transactionEventPayload:{transactionMeta:r}}){const n=S(e,r.id);switch(e){case d.TransactionMetaMetricsEvent.approved:case d.TransactionMetaMetricsEvent.finalized:t.finalizeEventFragment(n);break;case d.TransactionMetaMetricsEvent.rejected:t.finalizeEventFragment(n,{abandoned:!0})}}({eventName:e,transactionEventPayload:t,transactionMetricsRequest:r})}function S(e,t){return`transaction-${e===d.TransactionMetaMetricsEvent.finalized||e===d.TransactionMetaMetricsEvent.submitted?"submitted":"added"}-${t}`}async function A({transactionEventPayload:{transactionMeta:e},transactionMetricsRequest:t,extraParams:r={}}){var v;const{type:C,time:T,status:S,chainId:A,origin:M,txParams:{gasPrice:P,gas:E,maxFeePerGas:_,maxPriorityFeePerGas:I,estimateSuggested:B,estimateUsed:N},defaultGasEstimates:x,originalType:j,replacedById:R,customTokenAmount:O,dappProposedTokenAmount:D,currentTokenBalance:L,originalApprovalAmount:U,finalApprovalAmount:F,securityProviderResponse:K,simulationFails:$,id:H,userFeeLevel:z}=e,q=M===l.ORIGIN_METAMASK?"user":"dapp",G="dappSuggested"===z?"dapp_proposed":z,{assetType:V,tokenStandard:W}=await(0,f.determineTransactionAssetType)(e,t.provider,t.getTokenStandardAndDetails);let Y;if(e.txParams.data){const r=await t.getMethodData(e.txParams.data);Y=null==r?void 0:r.name}const Q={};if((0,f.isEIP1559Transaction)(e)?(Q.max_fee_per_gas=_,Q.max_priority_fee_per_gas=I):(Q.gas_price=P,Q.default_estimate=u.MetaMetricsEventTransactionEstimateType.DefaultEstimate),x){var J,X;const{estimateType:r}=x;if(r){var Z,ee;Q.default_estimate=r===c.PriorityLevels.dAppSuggested?u.MetaMetricsEventTransactionEstimateType.DappProposed:r;let n=null===(Z=e.defaultGasEstimates)||void 0===Z?void 0:Z.maxFeePerGas,s=null===(ee=e.defaultGasEstimates)||void 0===ee?void 0:ee.maxPriorityFeePerGas;if([c.GasRecommendations.low,c.GasRecommendations.medium,c.GasRecommendations.high].includes(r)){var te,re;const{gasFeeEstimates:e}=await t.getEIP1559GasFeeEstimates();var ne,se;if(null!=e&&null!==(te=e[r])&&void 0!==te&&te.suggestedMaxFeePerGas)n=null===(ne=e[r])||void 0===ne?void 0:ne.suggestedMaxFeePerGas,Q.default_max_fee_per_gas=n;if(null!=e&&null!==(re=e[r])&&void 0!==re&&re.suggestedMaxPriorityFeePerGas)s=null===(se=e[r])||void 0===se?void 0:se.suggestedMaxPriorityFeePerGas,Q.default_max_priority_fee_per_gas=s}}null!==(J=e.defaultGasEstimates)&&void 0!==J&&J.gas&&(Q.default_gas=e.defaultGasEstimates.gas),null!==(X=e.defaultGasEstimates)&&void 0!==X&&X.gasPrice&&(Q.default_gas_price=e.defaultGasEstimates.gasPrice)}B&&(Q.estimate_suggested=B),N&&(Q.estimate_used=N),null!=r&&r.gas_used&&(Q.gas_used=r.gas_used);const ie=function(e){const t={};for(const r in e)(0,s.isHexString)(e[r])?t[r]=(0,p.hexWEIToDecGWEI)(e[r]):t[r]=e[r];return t}(Q);let oe="0";e.txParams.maxFeePerGas&&(oe="2");const ae=C&&[i.TransactionType.contractInteraction,i.TransactionType.tokenMethodApprove,i.TransactionType.tokenMethodIncreaseAllowance,i.TransactionType.tokenMethodSafeTransferFrom,i.TransactionType.tokenMethodSetApprovalForAll,i.TransactionType.tokenMethodTransfer,i.TransactionType.tokenMethodTransferFrom,i.TransactionType.swap,i.TransactionType.swapAndSend,i.TransactionType.swapApproval].includes(C),le="Approve";let ce,ue,de,he,pe,ge,fe=i.TransactionType.simpleSend;if(C===i.TransactionType.swapAndSend)fe=i.TransactionType.swapAndSend;else if(C===i.TransactionType.cancel)fe=i.TransactionType.cancel;else if(C===i.TransactionType.retry&&j)fe=j;else if(C===i.TransactionType.deployContract)fe=i.TransactionType.deployContract;else if(ae){var me,ye;fe=i.TransactionType.contractInteraction,ue=Y,pe=null===(me=e.txParams)||void 0===me?void 0:me.to,ge=null===(ye=e.txParams)||void 0===ye||null===(ye=ye.data)||void 0===ye?void 0:ye.slice(0,10),ue===le&&W===d.TokenStandard.ERC20&&("0"===D||"0"===O?ce=d.TransactionApprovalAmountType.revoke:O&&O!==D?ce=d.TransactionApprovalAmountType.custom:D&&(ce=d.TransactionApprovalAmountType.dappProposed),de=function(e,t,r){if(e===d.TransactionApprovalAmountType.custom&&t&&r)return`${new n.BigNumber(t,10).div(r,10).times(100).round(2)}`;return null}(ce,U,F),he=function(e,t,r){if((e===d.TransactionApprovalAmountType.custom||e===d.TransactionApprovalAmountType.dappProposed)&&t&&r)return`${new n.BigNumber(t,16).div(r,10).times(100).round(2)}`;return null}(ce,D,L))}const be=t.getTransaction(R),ke={RETRY:i.TransactionType.retry,CANCEL:i.TransactionType.cancel,SAME_NONCE:"other"};let we;null!=r&&r.dropped&&(we=ke.SAME_NONCE,(null==be?void 0:be.type)===i.TransactionType.cancel?we=ke.CANCEL:(null==be?void 0:be.type)===i.TransactionType.retry&&(we=ke.RETRY));const ve=[];let Ce=null;1===(null==K?void 0:K.flagAsDangerous)?ve.push(u.MetaMetricsEventUiCustomization.FlaggedAsMalicious):2===(null==K?void 0:K.flagAsDangerous)&&ve.push(u.MetaMetricsEventUiCustomization.FlaggedAsSafetyUnknown);const Te=(0,m.getBlockaidMetricsProps)(e);(null==Te||null===(v=Te.ui_customizations)||void 0===v?void 0:v.length)>0&&ve.push(...Te.ui_customizations),$&&ve.push(u.MetaMetricsEventUiCustomization.GasEstimationFailed);(0,b.shouldUseRedesignForTransactions)({transactionMetadataType:e.type})&&(ve.push(u.MetaMetricsEventUiCustomization.RedesignedConfirmation),Ce=t.getIsConfirmationAdvancedDetailsOpen());const Se=(0,g.getSmartTransactionMetricsProperties)(t,e),Ae=(0,m.getSwapAndSendMetricsProps)(e),Me={hd_entropy_index:t.getHDEntropyIndex()};let Pe={chain_id:A,referrer:M,source:q,status:S,network:`${parseInt(A,16)}`,eip_1559_version:oe,gas_edit_type:"none",gas_edit_attempted:"none",gas_estimation_failed:Boolean($),account_type:await t.getAccountType(t.getSelectedAddress()),device_model:await t.getDeviceModel(t.getSelectedAddress()),asset_type:V,token_standard:W,transaction_type:fe,transaction_speed_up:C===i.TransactionType.retry,transaction_internal_id:H,gas_fee_selected:G,...Te,ui_customizations:ve.length>0?ve:null,transaction_advanced_view:Ce,transaction_contract_method:ue?[ue]:[],...Se,...Ae,...Me};const Ee=await(0,y.getSnapAndHardwareInfoForMetrics)(t.getAccountType,t.getDeviceModel,t.getHardwareTypeForMetric,t.snapAndHardwareMessenger);Object.assign(Pe,Ee),ue===le&&(Pe={...Pe,transaction_approval_amount_type:ce});let _e={transaction_envelope_type:(0,f.isEIP1559Transaction)(e)?h.TRANSACTION_ENVELOPE_TYPE_NAMES.FEE_MARKET:h.TRANSACTION_ENVELOPE_TYPE_NAMES.LEGACY,first_seen:T,gas_limit:E,transaction_replaced:we,transaction_contract_address:pe?[pe]:[],transaction_contract_method_4byte:ge,...r,...ie};return ue===le&&(_e={..._e,transaction_approval_amount_vs_balance_ratio:he,transaction_approval_amount_vs_proposed_ratio:de}),await async function(e,t,r,n){const s=origin&&origin!==l.ORIGIN_METAMASK,{delegationAddress:o,nestedTransactions:c,txParams:u}=e,{authorizationList:d}=u,h=Boolean(null==c?void 0:c.length),p=Boolean(null==d?void 0:d.length);s&&(r.api_method=h?l.MESSAGE_TYPE.WALLET_SEND_CALLS:l.MESSAGE_TYPE.ETH_SEND_TRANSACTION);h&&(r.batch_transaction_count=null==c?void 0:c.length,r.batch_transaction_method="eip7702",r.transaction_contract_method=await async function(e,t){const r=e.filter((e=>e.type===i.TransactionType.contractInteraction&&e.data)).map((e=>e.data)),n=await Promise.all(r.map((e=>t(e))));return n.map((e=>null==e?void 0:e.name)).filter((e=>null==e?void 0:e.length))}(c??[],t),n.transaction_contract_address=null==c?void 0:c.filter((e=>{var t;return e.type===i.TransactionType.contractInteraction&&(null===(t=e.to)||void 0===t?void 0:t.length)})).map((e=>e.to)));if(e.status===i.TransactionStatus.rejected){const{error:t}=e;r.eip7702_upgrade_rejection=p&&t.code===a.errorCodes.rpc.methodNotSupported}r.eip7702_upgrade_transaction=p,n.account_eip7702_upgraded=o}(e,t.getMethodData,Pe,_e),function(e,t,r,n){var s;const{batchId:i,batchTransactions:a,gasFeeTokens:l,nestedTransactions:c,selectedGasFeeToken:u}=e;t.gas_payment_tokens_available=null==l?void 0:l.map((e=>e.symbol)),t.gas_paid_with=null==l||null===(s=l.find((e=>e.tokenAddress.toLowerCase()===(null==u?void 0:u.toLowerCase()))))||void 0===s?void 0:s.symbol,t.gas_insufficient_native_asset=function(e,t){const{chainId:r,txParams:n}=e,{from:s,gas:i,gasPrice:a,maxFeePerGas:l,value:c}=n,u=t(s,r),d=(0,k.getMaximumGasTotalInHexWei)({gasLimit:i,gasPrice:a,maxFeePerGas:l}),h=(0,o.add0x)((0,p.addHexes)(d,c??"0x0"));return new w.Numeric(h,16).greaterThan(new w.Numeric(u,16))}(e,n),!i||null!=a&&a.length||null!=c&&c.length||(t.transaction_type="gas_payment")}(e,Pe,0,t.getAccountBalance),{properties:Pe,sensitiveProperties:_e}}r.handlePostTransactionBalanceUpdate=async({getParticipateInMetrics:e,trackEvent:t,getHDEntropyIndex:r},{transactionMeta:s,approvalTransactionMeta:i})=>{var o;if(e()&&s.swapMetaData)if("0x0"===(null===(o=s.txReceipt)||void 0===o?void 0:o.status))t({event:u.MetaMetricsEventName.SwapFailed,category:u.MetaMetricsEventCategory.Swaps,sensitiveProperties:{...s.swapMetaData},properties:{hd_entropy_index:r()}});else{var a;const e=(0,h.getSwapsTokensReceivedFromTxMeta)(s.destinationTokenSymbol,s,s.destinationTokenAddress,s.txParams.from,s.destinationTokenDecimals,i,s.chainId),o=e?`${new n.BigNumber(e,10).div(s.swapMetaData.token_to_amount,10).times(100).round(2)}%`:null,l=null!==(a=s.txReceipt)&&void 0!==a&&a.gasUsed&&s.swapMetaData.estimated_gas?`${new n.BigNumber(s.txReceipt.gasUsed,16).div(s.swapMetaData.estimated_gas,10).times(100).round(2)}%`:null,c=function(e,t){var r,s;let i="0x0";null!=t&&t.txReceipt&&(i=(0,h.calcGasTotal)(t.txReceipt.gasUsed,t.txReceipt.effectiveGasPrice));const o=(0,h.calcGasTotal)(null===(r=e.txReceipt)||void 0===r?void 0:r.gasUsed,null===(s=e.txReceipt)||void 0===s?void 0:s.effectiveGasPrice),a=new n.BigNumber(o,16).plus(i,16).toString(16);return{approvalGasCostInEth:Number((0,p.hexWEIToDecETH)(i)),tradeGasCostInEth:Number((0,p.hexWEIToDecETH)(o)),tradeAndApprovalGasCostInEth:Number((0,p.hexWEIToDecETH)(a))}}(s,i);t({event:u.MetaMetricsEventName.SwapCompleted,category:u.MetaMetricsEventCategory.Swaps,sensitiveProperties:{...s.swapMetaData,token_to_amount_received:e,quote_vs_executionRatio:o,estimated_vs_used_gasRatio:l,approval_gas_cost_in_eth:c.approvalGasCostInEth,trade_gas_cost_in_eth:c.tradeGasCostInEth,trade_and_approval_gas_cost_in_eth:c.tradeAndApprovalGasCostInEth,token_to_amount:s.swapMetaData.token_to_amount.toString(10)},properties:{hd_entropy_index:r()}})}}}}},{package:"$root$",file:"app/scripts/lib/transaction/metrics.ts"}],[1830,{"./abi":1829},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){n===undefined&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){n===undefined&&(n=r),e[n]=t[r]}),s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(r,"__esModule",{value:!0}),s(e("./abi"),r)}}},{package:"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@metamask/abi-utils",file:"node_modules/@metamask/eth-snap-keyring/node_modules/@metamask/abi-utils/dist/types/index.js"}],[1831,{"@metamask/utils":2950},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.padEnd=r.padStart=r.set=void 0;const n=e("@metamask/utils");r.set=(e,t,r)=>(0,n.concatBytes)([e.subarray(0,r),t,e.subarray(r+t.length)]);r.padStart=(e,t=32)=>{const r=new Uint8Array(Math.max(t-e.length,0)).fill(0);return(0,n.concatBytes)([r,e])};r.padEnd=(e,t=32)=>{const r=new Uint8Array(Math.max(t-e.length,0)).fill(0);return(0,n.concatBytes)([e,r])}}}},{package:"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@metamask/abi-utils",file:"node_modules/@metamask/eth-snap-keyring/node_modules/@metamask/abi-utils/dist/utils/buffer.js"}],[1832,{"./buffer":1831},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){n===undefined&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){n===undefined&&(n=r),e[n]=t[r]}),s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(r,"__esModule",{value:!0}),s(e("./buffer"),r)}}},{package:"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@metamask/abi-utils",file:"node_modules/@metamask/eth-snap-keyring/node_modules/@metamask/abi-utils/dist/utils/index.js"}],[1833,{"./utils":1838,"@scure/base":3027,buffer:4074,tweetnacl:5616},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){(function(t){(function(){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){n===undefined&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){n===undefined&&(n=r),e[n]=t[r]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return s(t,e),t};Object.defineProperty(r,"__esModule",{value:!0}),r.getEncryptionPublicKey=r.decryptSafely=r.decrypt=r.encryptSafely=r.encrypt=void 0;const o=e("@scure/base"),a=i(e("tweetnacl")),l=e("./utils");function c({publicKey:e,data:t,version:r}){if((0,l.isNullish)(e))throw new Error("Missing publicKey parameter");if((0,l.isNullish)(t))throw new Error("Missing data parameter");if((0,l.isNullish)(r))throw new Error("Missing version parameter");if("x25519-xsalsa20-poly1305"===r){if("string"!=typeof t)throw new Error("Message data must be given as a string");const r=a.box.keyPair();let n;try{n=o.base64.decode(e)}catch(e){throw new Error("Bad public key")}const s=o.utf8.decode(t),i=a.randomBytes(a.box.nonceLength),l=a.box(s,i,n,r.secretKey);return{version:"x25519-xsalsa20-poly1305",nonce:o.base64.encode(i),ephemPublicKey:o.base64.encode(r.publicKey),ciphertext:o.base64.encode(l)}}throw new Error("Encryption type/version not supported")}function u({encryptedData:e,privateKey:r}){if((0,l.isNullish)(e))throw new Error("Missing encryptedData parameter");if((0,l.isNullish)(r))throw new Error("Missing privateKey parameter");if("x25519-xsalsa20-poly1305"===e.version){const n=t.from(r,"hex"),s=a.box.keyPair.fromSecretKey(n).secretKey,i=o.base64.decode(e.nonce),l=o.base64.decode(e.ciphertext),c=o.base64.decode(e.ephemPublicKey),u=a.box.open(l,i,c,s);try{if(!u)throw new Error;const e=o.utf8.encode(u);if(!e)throw new Error;return e}catch(e){if(e&&"string"==typeof e.message&&e.message.length)throw new Error(`Decryption failed: ${e.message}`);throw new Error("Decryption failed.")}}throw new Error("Encryption type/version not supported.")}r.encrypt=c,r.encryptSafely=function({publicKey:e,data:r,version:n}){if((0,l.isNullish)(e))throw new Error("Missing publicKey parameter");if((0,l.isNullish)(r))throw new Error("Missing data parameter");if((0,l.isNullish)(n))throw new Error("Missing version parameter");if("object"==typeof r&&r&&"toJSON"in r)throw new Error("Cannot encrypt with toJSON property. Please remove toJSON property");const s={data:r,padding:""},i=t.byteLength(JSON.stringify(s),"utf-8")%2048;let o=0;return i>0&&(o=2048-i-16),s.padding="0".repeat(o),c({publicKey:e,data:JSON.stringify(s),version:n})},r.decrypt=u,r.decryptSafely=function({encryptedData:e,privateKey:t}){if((0,l.isNullish)(e))throw new Error("Missing encryptedData parameter");if((0,l.isNullish)(t))throw new Error("Missing privateKey parameter");return JSON.parse(u({encryptedData:e,privateKey:t})).data},r.getEncryptionPublicKey=function(e){const r=t.from(e,"hex"),n=a.box.keyPair.fromSecretKey(r).publicKey;return o.base64.encode(n)}}).call(this)}).call(this,e("buffer").Buffer)}}},{package:"@metamask/eth-snap-keyring>@metamask/eth-sig-util",file:"node_modules/@metamask/eth-snap-keyring/node_modules/@metamask/eth-sig-util/dist/encryption.js"}],[1834,{"./encryption":1833,"./personal-sign":1835,"./sign-eip7702-authorization":1836,"./sign-typed-data":1837,"./utils":1838},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){n===undefined&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){n===undefined&&(n=r),e[n]=t[r]}),s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(r,"__esModule",{value:!0}),r.normalize=r.concatSig=void 0,s(e("./personal-sign"),r),s(e("./sign-typed-data"),r),s(e("./encryption"),r),s(e("./sign-eip7702-authorization"),r);var i=e("./utils");Object.defineProperty(r,"concatSig",{enumerable:!0,get:function(){return i.concatSig}}),Object.defineProperty(r,"normalize",{enumerable:!0,get:function(){return i.normalize}})}}},{package:"@metamask/eth-snap-keyring>@metamask/eth-sig-util",file:"node_modules/@metamask/eth-snap-keyring/node_modules/@metamask/eth-sig-util/dist/index.js"}],[1835,{"./utils":1838,"@ethereumjs/util":1805},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.extractPublicKey=r.recoverPersonalSignature=r.personalSign=void 0;const n=e("@ethereumjs/util"),s=e("./utils");function i(e,t){const r=(0,n.hashPersonalMessage)((0,s.legacyToBuffer)(e));return(0,s.recoverPublicKey)(r,t)}r.personalSign=function({privateKey:e,data:t}){if((0,s.isNullish)(t))throw new Error("Missing data parameter");if((0,s.isNullish)(e))throw new Error("Missing privateKey parameter");const r=(0,s.legacyToBuffer)(t),i=(0,n.hashPersonalMessage)(r),o=(0,n.ecsign)(i,e);return(0,s.concatSig)((0,n.toBuffer)(o.v),o.r,o.s)},r.recoverPersonalSignature=function({data:e,signature:t}){if((0,s.isNullish)(e))throw new Error("Missing data parameter");if((0,s.isNullish)(t))throw new Error("Missing signature parameter");const r=i(e,t),o=(0,n.publicToAddress)(r);return(0,n.bufferToHex)(o)},r.extractPublicKey=function({data:e,signature:t}){if((0,s.isNullish)(e))throw new Error("Missing data parameter");if((0,s.isNullish)(t))throw new Error("Missing signature parameter");return`0x${i(e,t).toString("hex")}`}}}},{package:"@metamask/eth-snap-keyring>@metamask/eth-sig-util",file:"node_modules/@metamask/eth-snap-keyring/node_modules/@metamask/eth-sig-util/dist/personal-sign.js"}],[1836,{"./utils":1838,"@ethereumjs/rlp":429,"@ethereumjs/util":1805,"@metamask/utils":2950,buffer:4074,"ethereum-cryptography/keccak":4300},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){(function(t){(function(){Object.defineProperty(r,"__esModule",{value:!0}),r.hashEIP7702Authorization=r.recoverEIP7702Authorization=r.signEIP7702Authorization=void 0;const n=e("@ethereumjs/rlp"),s=e("@ethereumjs/util"),i=e("@metamask/utils"),o=e("ethereum-cryptography/keccak"),a=e("./utils");function l(e){c(e);const r=(0,n.encode)(e),s=t.concat([t.from("05","hex"),r]);return t.from((0,o.keccak256)(s))}function c(e){if((0,a.isNullish)(e))throw new Error("Missing authorization parameter");const[t,r,n]=e;if((0,a.isNullish)(t))throw new Error("Missing chainId parameter");if((0,a.isNullish)(r))throw new Error("Missing contractAddress parameter");if((0,a.isNullish)(n))throw new Error("Missing nonce parameter")}r.signEIP7702Authorization=function({privateKey:e,authorization:t}){if(c(t),(0,a.isNullish)(e))throw new Error("Missing privateKey parameter");const r=l(t),{r:n,s:i,v:o}=(0,s.ecsign)(r,e),u=(0,s.toBuffer)(o);return(0,a.concatSig)(u,n,i)},r.recoverEIP7702Authorization=function({signature:e,authorization:t}){if(c(t),(0,a.isNullish)(e))throw new Error("Missing signature parameter");const r=l(t),n=(0,a.recoverPublicKey)(r,e),o=(0,s.publicToAddress)(n);return(0,i.bytesToHex)(o)},r.hashEIP7702Authorization=l}).call(this)}).call(this,e("buffer").Buffer)}}},{package:"@metamask/eth-snap-keyring>@metamask/eth-sig-util",file:"node_modules/@metamask/eth-snap-keyring/node_modules/@metamask/eth-sig-util/dist/sign-eip7702-authorization.js"}],[1837,{"./utils":1838,"@ethereumjs/util":1805,"@metamask/abi-utils":1815,"@metamask/abi-utils/dist/parsers":1824,"@metamask/abi-utils/dist/utils":1832,"@metamask/utils":2950,"ethereum-cryptography/keccak":4300},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.recoverTypedSignature=r.signTypedData=r.typedSignatureHash=r.TypedDataUtils=r.TYPED_MESSAGE_SCHEMA=r.SignTypedDataVersion=void 0;const n=e("@ethereumjs/util"),s=e("@metamask/abi-utils"),i=e("@metamask/abi-utils/dist/parsers"),o=e("@metamask/abi-utils/dist/utils"),a=e("@metamask/utils"),l=e("ethereum-cryptography/keccak"),c=e("./utils");var u;function d(e,t){if(!Object.keys(u).includes(e))throw new Error(`Invalid version: '${e}'`);if(t&&!t.includes(e))throw new Error(`SignTypedDataVersion not allowed: '${e}'. Allowed versions are: ${t.join(", ")}`)}function h(e,t){(0,a.assert)(null!==t,`Unable to encode value: Invalid number. Expected a valid number value, but received "${t}".`);const r=BigInt(t),n=(0,i.getLength)(e),s=BigInt(2)**BigInt(n)-BigInt(1);return(0,a.assert)(r>=-s&&r<=s,`Unable to encode value: Number "${t}" is out of range for type "${e}".`),r}function p(e){let t=BigInt(0);for(let r=0;r<e.length;r++){const n=BigInt(e.charCodeAt(r)-48);t*=BigInt(10),t+=n>=49?n-BigInt(49)+BigInt(10):n>=17?n-BigInt(17)+BigInt(10):n}return(0,o.padStart)((0,a.bigIntToBytes)(t),20)}function g(e,t,r,i,c){if(d(c,[u.V3,u.V4]),e[r]!==undefined)return["bytes32",c===u.V4&&null==i?"0x0000000000000000000000000000000000000000000000000000000000000000":(0,n.arrToBufArr)((0,l.keccak256)(f(r,i,e,c)))];if("function"===r)throw new Error('Unsupported or invalid type: "function"');if(i===undefined)throw new Error(`missing value for field ${t} of type ${r}`);if("address"===r){if("number"==typeof i)return["address",(0,o.padStart)((0,a.numberToBytes)(i),20)];if((0,a.isStrictHexString)(i))return["address",(0,a.add0x)(i)];if("string"==typeof i)return["address",p(i).subarray(0,20)]}if("bool"===r)return["bool",Boolean(i)];if("bytes"===r)return"number"==typeof i?i=(0,a.numberToBytes)(i):(0,a.isStrictHexString)(i)||"0x"===i?i=(0,a.hexToBytes)(i):"string"==typeof i&&(i=(0,a.stringToBytes)(i)),["bytes32",(0,n.arrToBufArr)((0,l.keccak256)(i))];if(r.startsWith("bytes")&&"bytes"!==r&&!r.includes("["))return"number"==typeof i?i<0?["bytes32",new Uint8Array(32)]:["bytes32",(0,a.bigIntToBytes)(BigInt(i))]:(0,a.isStrictHexString)(i)?["bytes32",(0,a.hexToBytes)(i)]:["bytes32",i];if(r.startsWith("int")&&!r.includes("[")){const e=h(r,i);return e>=BigInt(0)?["uint256",e]:["int256",e]}if("string"===r)return i="number"==typeof i?(0,a.numberToBytes)(i):(0,a.stringToBytes)(null!=i?i:""),["bytes32",(0,n.arrToBufArr)((0,l.keccak256)(i))];if(r.endsWith("]")){if(c===u.V3)throw new Error("Arrays are unimplemented in encodeData; use V4 extension");const o=r.slice(0,r.lastIndexOf("[")),a=i.map((r=>g(e,t,o,r,c)));return["bytes32",(0,n.arrToBufArr)((0,l.keccak256)((0,s.encode)(a.map((([e])=>e)),a.map((([,e])=>e)))))]}return[r,i]}function f(e,t,r,i){d(i,[u.V3,u.V4]);const o=["bytes32"],a=[k(e,r)];for(const n of r[e]){if(i===u.V3&&t[n.name]===undefined)continue;const[e,s]=g(r,n.name,n.type,t[n.name],i);o.push(e),a.push(s)}return(0,n.arrToBufArr)((0,s.encode)(o,a))}function m(e,t){let r="";const n=y(e,t);n.delete(e);const s=[e,...Array.from(n).sort()];for(const e of s){if(!t[e])throw new Error(`No type definition specified: ${e}`);r+=`${e}(${t[e].map((({name:e,type:t})=>`${t} ${e}`)).join(",")})`}return r}function y(e,t,r=new Set){if("string"!=typeof e)throw new Error(`Invalid findTypeDependencies input ${JSON.stringify(e)}`);const n=e.match(/^\w*/u);if([e]=n,r.has(e)||t[e]===undefined)return r;r.add(e);for(const n of t[e])y(n.type,t,r);return r}function b(e,t,r,s){d(s,[u.V3,u.V4]);const i=f(e,t,r,s),o=(0,l.keccak256)(i);return(0,n.arrToBufArr)(o)}function k(e,t){const r=(0,a.stringToBytes)(m(e,t));return(0,n.arrToBufArr)((0,l.keccak256)(r))}function w(e){const t={};for(const n in r.TYPED_MESSAGE_SCHEMA.properties)e[n]&&(t[n]=e[n]);return"types"in t&&(t.types=Object.assign({EIP712Domain:[]},t.types)),t}function v(e,t){d(t,[u.V3,u.V4]);const r=w(e),{domain:n}=r;return b("EIP712Domain",n,{EIP712Domain:r.types.EIP712Domain},t)}function C(e,t){if((0,i.isArrayType)(e)&&Array.isArray(t)){const[r]=(0,i.getArrayType)(e);return t.map((e=>C(r,e)))}if("address"===e){if((0,a.isStrictHexString)(t))return(0,o.padStart)((0,a.hexToBytes)(t).subarray(0,20),20);if(t instanceof Uint8Array)return(0,o.padStart)(t.subarray(0,20),20)}if("bool"===e)return Boolean(t);if(e.startsWith("bytes")&&"bytes"!==e){const r=(0,i.getByteLength)(e);if("number"==typeof t)return t<0?new Uint8Array:(0,a.numberToBytes)(t).subarray(0,r);if((0,a.isStrictHexString)(t))return(0,a.hexToBytes)(t).subarray(0,r);if(t instanceof Uint8Array)return t.subarray(0,r)}if(e.startsWith("uint")&&"number"==typeof t)return Math.abs(t);if(e.startsWith("int")&&"number"==typeof t){const r=(0,i.getLength)(e);return BigInt.asIntN(r,BigInt(t))}return t}function T(e,t){return t.map((t=>{if("string"==typeof t||"number"==typeof t||"bigint"==typeof t){const r=h(e,t);if(r>=BigInt(0))return(0,o.padStart)((0,a.bigIntToBytes)(r),32);const n=(0,i.getLength)(e),s=BigInt.asIntN(n,r);return(0,a.signedBigIntToBytes)(s,32)}return t}))}function S(e){const t=new Error("Expect argument to be non-empty array");if("object"!=typeof e||!("length"in e)||!e.length)throw t;const r=e.map((({name:e,type:t,value:r})=>{if("address[]"===t)return{name:e,type:"bytes32[]",value:(n=r,n.map((e=>"number"==typeof e?(0,o.padStart)((0,a.numberToBytes)(e),32):(0,a.isStrictHexString)(e)?(0,o.padStart)((0,a.hexToBytes)(e).subarray(0,32),32):e instanceof Uint8Array?(0,o.padStart)(e.subarray(0,32),32):e)))};var n;if(t.startsWith("int")&&(0,i.isArrayType)(t)){const[n,s]=(0,i.getArrayType)(t);return{name:e,type:`bytes32[${null!=s?s:""}]`,value:T(n,r)}}return{name:e,type:t,value:C(t,r)}})),u=r.map((e=>"bytes"!==e.type?e.value:(0,c.legacyToBuffer)(e.value))),d=r.map((e=>{if("function"===e.type)throw new Error('Unsupported or invalid type: "function"');return e.type})),h=e.map((e=>{if(!e.name)throw t;return`${e.type} ${e.name}`}));return(0,n.arrToBufArr)((0,l.keccak256)((0,s.encodePacked)(["bytes32","bytes32"],[(0,l.keccak256)((0,s.encodePacked)(["string[]"],[h],!0)),(0,l.keccak256)((0,s.encodePacked)(d,u,!0))])))}!function(e){e.V1="V1",e.V3="V3",e.V4="V4"}(u=r.SignTypedDataVersion||(r.SignTypedDataVersion={})),r.TYPED_MESSAGE_SCHEMA={type:"object",properties:{types:{type:"object",additionalProperties:{type:"array",items:{type:"object",properties:{name:{type:"string"},type:{type:"string"}},required:["name","type"]}}},primaryType:{type:"string"},domain:{type:"object"},message:{type:"object"}},required:["types","primaryType","domain","message"]},r.TypedDataUtils={encodeData:f,encodeType:m,findTypeDependencies:y,hashStruct:b,hashType:k,sanitizeData:w,eip712Hash:function(e,t){d(t,[u.V3,u.V4]);const r=w(e),s=[(0,a.hexToBytes)("1901")];return s.push(v(e,t)),"EIP712Domain"!==r.primaryType&&s.push(b(r.primaryType,r.message,r.types,t)),(0,n.arrToBufArr)((0,l.keccak256)((0,a.concatBytes)(s)))},eip712DomainHash:v},r.typedSignatureHash=function(e){const t=S(e);return(0,a.bytesToHex)(t)},r.signTypedData=function({privateKey:e,data:t,version:s}){if(d(s),(0,c.isNullish)(t))throw new Error("Missing data parameter");if((0,c.isNullish)(e))throw new Error("Missing private key parameter");const i=s===u.V1?S(t):r.TypedDataUtils.eip712Hash(t,s),o=(0,n.ecsign)(i,e);return(0,c.concatSig)((0,n.arrToBufArr)((0,a.bigIntToBytes)(o.v)),o.r,o.s)},r.recoverTypedSignature=function({data:e,signature:t,version:s}){if(d(s),(0,c.isNullish)(e))throw new Error("Missing data parameter");if((0,c.isNullish)(t))throw new Error("Missing signature parameter");const i=s===u.V1?S(e):r.TypedDataUtils.eip712Hash(e,s),o=(0,c.recoverPublicKey)(i,t),l=(0,n.publicToAddress)(o);return(0,a.bytesToHex)(l)}}}},{package:"@metamask/eth-snap-keyring>@metamask/eth-sig-util",file:"node_modules/@metamask/eth-snap-keyring/node_modules/@metamask/eth-sig-util/dist/sign-typed-data.js"}],[1838,{"@ethereumjs/util":1805,"@metamask/utils":2950,buffer:4074},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){(function(t){(function(){Object.defineProperty(r,"__esModule",{value:!0}),r.normalize=r.recoverPublicKey=r.concatSig=r.legacyToBuffer=r.isNullish=r.padWithZeroes=void 0;const n=e("@ethereumjs/util"),s=e("@metamask/utils");function i(e,t){if(""!==e&&!/^[a-f0-9]+$/iu.test(e))throw new Error(`Expected an unprefixed hex string. Received: ${e}`);if(t<0)throw new Error(`Expected a non-negative integer target length. Received: ${t}`);return String.prototype.padStart.call(e,t,"0")}function o(e){return null===e||e===undefined}r.padWithZeroes=i,r.isNullish=o,r.legacyToBuffer=function(e){return"string"!=typeof e||(0,n.isHexString)(e)?(0,n.toBuffer)(e):t.from(e)},r.concatSig=function(e,t,r){const o=(0,n.fromSigned)(t),a=(0,n.fromSigned)(r),l=(0,n.bufferToInt)(e),c=i((0,n.toUnsigned)(o).toString("hex"),64),u=i((0,n.toUnsigned)(a).toString("hex"),64),d=(0,s.remove0x)((0,s.numberToHex)(l));return(0,s.add0x)(c.concat(u,d))},r.recoverPublicKey=function(e,t){const r=(0,n.fromRpcSig)(t);return(0,n.ecrecover)(e,r.v,r.r,r.s)},r.normalize=function(e){if(o(e))return undefined;if("number"==typeof e){if(e<0)return"0x";const t=(0,s.numberToBytes)(e);e=(0,s.bytesToHex)(t)}if("string"!=typeof e){let t="eth-sig-util.normalize() requires hex string or integer input.";throw t+=` received ${typeof e}: ${e}`,new Error(t)}return(0,s.add0x)(e.toLowerCase())}}).call(this)}).call(this,e("buffer").Buffer)}}},{package:"@metamask/eth-snap-keyring>@metamask/eth-sig-util",file:"node_modules/@metamask/eth-snap-keyring/node_modules/@metamask/eth-sig-util/dist/utils.js"}],[1839,{"./nil.js":1842,"./parse.js":1843,"./stringify.js":1847,"./v1.js":1848,"./v3.js":1849,"./v4.js":1851,"./v5.js":1852,"./validate.js":1853,"./version.js":1854},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"NIL",{enumerable:!0,get:function(){return a.default}}),Object.defineProperty(r,"parse",{enumerable:!0,get:function(){return d.default}}),Object.defineProperty(r,"stringify",{enumerable:!0,get:function(){return u.default}}),Object.defineProperty(r,"v1",{enumerable:!0,get:function(){return n.default}}),Object.defineProperty(r,"v3",{enumerable:!0,get:function(){return s.default}}),Object.defineProperty(r,"v4",{enumerable:!0,get:function(){return i.default}}),Object.defineProperty(r,"v5",{enumerable:!0,get:function(){return o.default}}),Object.defineProperty(r,"validate",{enumerable:!0,get:function(){return c.default}}),Object.defineProperty(r,"version",{enumerable:!0,get:function(){return l.default}});var n=h(e("./v1.js")),s=h(e("./v3.js")),i=h(e("./v4.js")),o=h(e("./v5.js")),a=h(e("./nil.js")),l=h(e("./version.js")),c=h(e("./validate.js")),u=h(e("./stringify.js")),d=h(e("./parse.js"));function h(e){return e&&e.__esModule?e:{default:e}}}}},{package:"@metamask/eth-snap-keyring>uuid",file:"node_modules/@metamask/eth-snap-keyring/node_modules/uuid/dist/index.js"}],[184,{"../../../../shared/constants/app":5719,"../../../../shared/constants/smartTransactions":5743,"../../../../shared/modules/conversion.utils":5782,"../../../../shared/modules/transaction.utils":5804,"@metamask/smart-transactions-controller/dist/types":2628,"@metamask/transaction-controller":2905,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.submitSmartTransactionHook=r.submitBatchSmartTransactionHook=void 0;var n,s=e("@metamask/smart-transactions-controller/dist/types"),i=e("@metamask/transaction-controller"),o=(n=e("loglevel"))&&n.__esModule?n:{default:n},a=e("../../../../shared/modules/conversion.utils"),l=e("../../../../shared/constants/smartTransactions"),c=e("../../../../shared/modules/transaction.utils"),u=e("../../../../shared/constants/app");function d(e,t,r){h(e,t),t.set(e,r)}function h(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function p(e,t){return e.get(f(e,t))}function g(e,t,r){return e.set(f(e,t),r),r}function f(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 m=new WeakMap,y=new WeakMap,b=new WeakMap,k=new WeakMap,w=new WeakMap,v=new WeakMap,C=new WeakMap,T=new WeakMap,S=new WeakMap,A=new WeakMap,M=new WeakMap,P=new WeakMap,E=new WeakMap,_=new WeakMap,I=new WeakSet;class B{constructor(e){!function(e,t){h(e,t),t.add(e)}(this,I),d(this,m,void 0),d(this,y,void 0),d(this,b,void 0),d(this,k,void 0),d(this,w,void 0),d(this,v,void 0),d(this,C,void 0),d(this,T,void 0),d(this,S,void 0),d(this,A,void 0),d(this,M,void 0),d(this,P,void 0),d(this,E,void 0),d(this,_,void 0);const{transactionMeta:t,signedTransactionInHex:r,smartTransactionsController:n,transactionController:s,isSmartTransaction:o,controllerMessenger:a,featureFlags:l,transactions:c}=e;g(y,this,""),g(m,this,!1),g(A,this,t),g(M,this,r),g(T,this,n),g(S,this,s),g(C,this,o),g(k,this,a),g(w,this,l),g(v,this,t.origin!==u.ORIGIN_METAMASK),g(b,this,t.chainId),g(E,this,t.txParams),g(P,this,c),g(_,this,Boolean(t.type!==i.TransactionType.bridge||p(P,this)&&p(P,this).length>0))}async submit(){const e=!!p(A,this).type&&[i.TransactionType.swapAndSend,i.TransactionType.swapApproval,i.TransactionType.bridgeApproval].includes(p(A,this).type),t={transactionHash:undefined};if(!p(C,this)||e||(0,c.isLegacyTransaction)(p(A,this)))return t;let r;p(_,this)&&await f(I,this,j).call(this);try{r=await p(T,this).getFees({...p(E,this),chainId:p(b,this)},undefined)}catch(e){return o.default.error("Error in smart transaction publish hook, falling back to regular transaction submission",e),f(I,this,O).call(this),t}try{var n;const e=await f(I,this,K).call(this,{getFeesResponse:r}),t=null==e?void 0:e.uuid;if(!t)throw new Error("No smart transaction UUID");await f(I,this,R).call(this,t);let s;if(s=(null===(n=p(w,this))||void 0===n||null===(n=n.smartTransactions)||void 0===n?void 0:n.extensionReturnTxHashAsap)&&null!=e&&e.txHash?e.txHash:await f(I,this,F).call(this,{uuid:t}),null===s)throw new Error("Transaction does not have a transaction hash, there was a problem");return{transactionHash:s}}catch(e){throw o.default.error("Error in smart transaction publish hook",e),f(I,this,O).call(this),e}}async submitBatch(){if(!p(C,this))throw new Error("submitBatch: Smart Transaction is required for batch submissions");p(_,this)&&await f(I,this,j).call(this);try{const e=await f(I,this,K).call(this),t=null==e?void 0:e.uuid;if(!t)throw new Error("submitBatch: No smart transaction UUID");await f(I,this,R).call(this,t);if(null===await f(I,this,F).call(this,{uuid:t}))throw new Error("submitBatch: Transaction does not have a transaction hash, there was a problem");let r;return r=null!=e&&e.txHashes?{results:e.txHashes.map((e=>({transactionHash:e})))}:{results:[]},r}catch(e){throw o.default.error("submitBatch: Error in smart transaction publish batch hook",e),f(I,this,O).call(this),e}}}async function N(e){try{await p(k,this).call("ApprovalController:endFlow",{id:e})}catch(e){}}async function x(e){try{await f(I,this,N).call(this,e),await p(k,this).call("ApprovalController:acceptRequest",e),z._=""}catch(e){o.default.error("Error ending existing approval flow",e)}}async function j(){z._&&await f(I,this,x).call(this,z._);const{id:e}=await p(k,this).call("ApprovalController:startFlow");g(y,this,e),z._=e}async function R(e){p(_,this)&&(f(I,this,D).call(this,{uuid:e}),f(I,this,U).call(this,{uuid:e}))}function O(){p(_,this)&&!p(m,this)&&(g(m,this,!0),f(I,this,N).call(this,p(y,this)),z._===p(y,this)&&(z._=""))}function D({uuid:e}){const t=()=>{f(I,this,O).call(this)};p(k,this).call("ApprovalController:addRequest",{id:p(y,this),origin:origin,type:u.SMART_TRANSACTION_CONFIRMATION_TYPES.showSmartTransactionStatusPage,requestState:{smartTransaction:{status:s.SmartTransactionStatuses.PENDING,creationTime:Date.now(),uuid:e},isDapp:p(v,this),txId:p(A,this).id}},!0).then(t,t)}async function L({smartTransaction:e}){return await p(k,this).call("ApprovalController:updateRequestState",{id:p(y,this),requestState:{smartTransaction:e,isDapp:p(v,this),txId:p(A,this).id}})}async function U({uuid:e}){p(k,this).subscribe("SmartTransactionsController:smartTransaction",(async t=>{if(t.uuid===e){const{status:e}=t;if(!e||e===s.SmartTransactionStatuses.PENDING)return;p(m,this)||await f(I,this,L).call(this,{smartTransaction:t})}}))}function F({uuid:e}){return new Promise((t=>{p(k,this).subscribe("SmartTransactionsController:smartTransaction",(async r=>{if(r.uuid===e){const{status:e,statusMetadata:n}=r;if(!e||e===s.SmartTransactionStatuses.PENDING)return;o.default.debug("Smart Transaction: ",r),null!=n&&n.minedHash?(o.default.debug("Smart Transaction - Received tx hash: ",null==n?void 0:n.minedHash),t(n.minedHash)):t(null)}}))}))}async function K({getFeesResponse:e}={}){let t=[];if(p(P,this)&&Array.isArray(p(P,this))&&p(P,this).length>0)t=p(P,this).filter((e=>null==e?void 0:e.signedTx)).map((e=>e.signedTx));else if(p(M,this))t=[p(M,this)];else if(e){var r;t=await f(I,this,H).call(this,(null===(r=e.tradeTxFees)||void 0===r?void 0:r.fees)??[],!1)}return await p(T,this).submitSignedTransactions({signedTransactions:t,signedCanceledTransactions:[],txParams:p(E,this),transactionMeta:p(A,this),networkClientId:p(A,this).networkClientId})}function $(e,t){if(!p(E,this))throw new Error("Transaction params are required");const r={...p(E,this),maxFeePerGas:`0x${(0,a.decimalToHex)(e.maxFeePerGas)}`,maxPriorityFeePerGas:`0x${(0,a.decimalToHex)(e.maxPriorityFeePerGas)}`,gas:t?`0x${(0,a.decimalToHex)(l.CANCEL_GAS_LIMIT_DEC)}`:p(E,this).gas};return t&&(r.to=r.from,r.data="0x"),r}async function H(e,t){if(!p(E,this)||!p(b,this))throw new Error("Transaction params and chainId are required");const r=e.map((e=>f(I,this,$).call(this,e,t))).map((e=>({...e,chainId:e.chainId||p(b,this)})));return await p(S,this).approveTransactionsWithSameNonce(r,{hasNonce:!0})}var z={_:""};r.submitSmartTransactionHook=e=>new B(e).submit();r.submitBatchSmartTransactionHook=e=>new B(e).submitBatch()}}},{package:"$root$",file:"app/scripts/lib/transaction/smart-transactions.ts"}],[1840,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){function n(e){return 14+(e+64>>>9<<4)+1}function s(e,t){const r=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(r>>16)<<16|65535&r}function i(e,t,r,n,i,o){return s((a=s(s(t,e),s(n,o)))<<(l=i)|a>>>32-l,r);var a,l}function o(e,t,r,n,s,o,a){return i(t&r|~t&n,e,t,s,o,a)}function a(e,t,r,n,s,o,a){return i(t&n|r&~n,e,t,s,o,a)}function l(e,t,r,n,s,o,a){return i(t^r^n,e,t,s,o,a)}function c(e,t,r,n,s,o,a){return i(r^(t|~n),e,t,s,o,a)}Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var u=function(e){if("string"==typeof e){const t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(let r=0;r<t.length;++r)e[r]=t.charCodeAt(r)}return function(e){const t=[],r=32*e.length,n="0123456789abcdef";for(let s=0;s<r;s+=8){const r=e[s>>5]>>>s%32&255,i=parseInt(n.charAt(r>>>4&15)+n.charAt(15&r),16);t.push(i)}return t}(function(e,t){e[t>>5]|=128<<t%32,e[n(t)-1]=t;let r=1732584193,i=-271733879,u=-1732584194,d=271733878;for(let t=0;t<e.length;t+=16){const n=r,h=i,p=u,g=d;r=o(r,i,u,d,e[t],7,-680876936),d=o(d,r,i,u,e[t+1],12,-389564586),u=o(u,d,r,i,e[t+2],17,606105819),i=o(i,u,d,r,e[t+3],22,-1044525330),r=o(r,i,u,d,e[t+4],7,-176418897),d=o(d,r,i,u,e[t+5],12,1200080426),u=o(u,d,r,i,e[t+6],17,-1473231341),i=o(i,u,d,r,e[t+7],22,-45705983),r=o(r,i,u,d,e[t+8],7,1770035416),d=o(d,r,i,u,e[t+9],12,-1958414417),u=o(u,d,r,i,e[t+10],17,-42063),i=o(i,u,d,r,e[t+11],22,-1990404162),r=o(r,i,u,d,e[t+12],7,1804603682),d=o(d,r,i,u,e[t+13],12,-40341101),u=o(u,d,r,i,e[t+14],17,-1502002290),i=o(i,u,d,r,e[t+15],22,1236535329),r=a(r,i,u,d,e[t+1],5,-165796510),d=a(d,r,i,u,e[t+6],9,-1069501632),u=a(u,d,r,i,e[t+11],14,643717713),i=a(i,u,d,r,e[t],20,-373897302),r=a(r,i,u,d,e[t+5],5,-701558691),d=a(d,r,i,u,e[t+10],9,38016083),u=a(u,d,r,i,e[t+15],14,-660478335),i=a(i,u,d,r,e[t+4],20,-405537848),r=a(r,i,u,d,e[t+9],5,568446438),d=a(d,r,i,u,e[t+14],9,-1019803690),u=a(u,d,r,i,e[t+3],14,-187363961),i=a(i,u,d,r,e[t+8],20,1163531501),r=a(r,i,u,d,e[t+13],5,-1444681467),d=a(d,r,i,u,e[t+2],9,-51403784),u=a(u,d,r,i,e[t+7],14,1735328473),i=a(i,u,d,r,e[t+12],20,-1926607734),r=l(r,i,u,d,e[t+5],4,-378558),d=l(d,r,i,u,e[t+8],11,-2022574463),u=l(u,d,r,i,e[t+11],16,1839030562),i=l(i,u,d,r,e[t+14],23,-35309556),r=l(r,i,u,d,e[t+1],4,-1530992060),d=l(d,r,i,u,e[t+4],11,1272893353),u=l(u,d,r,i,e[t+7],16,-155497632),i=l(i,u,d,r,e[t+10],23,-1094730640),r=l(r,i,u,d,e[t+13],4,681279174),d=l(d,r,i,u,e[t],11,-358537222),u=l(u,d,r,i,e[t+3],16,-722521979),i=l(i,u,d,r,e[t+6],23,76029189),r=l(r,i,u,d,e[t+9],4,-640364487),d=l(d,r,i,u,e[t+12],11,-421815835),u=l(u,d,r,i,e[t+15],16,530742520),i=l(i,u,d,r,e[t+2],23,-995338651),r=c(r,i,u,d,e[t],6,-198630844),d=c(d,r,i,u,e[t+7],10,1126891415),u=c(u,d,r,i,e[t+14],15,-1416354905),i=c(i,u,d,r,e[t+5],21,-57434055),r=c(r,i,u,d,e[t+12],6,1700485571),d=c(d,r,i,u,e[t+3],10,-1894986606),u=c(u,d,r,i,e[t+10],15,-1051523),i=c(i,u,d,r,e[t+1],21,-2054922799),r=c(r,i,u,d,e[t+8],6,1873313359),d=c(d,r,i,u,e[t+15],10,-30611744),u=c(u,d,r,i,e[t+6],15,-1560198380),i=c(i,u,d,r,e[t+13],21,1309151649),r=c(r,i,u,d,e[t+4],6,-145523070),d=c(d,r,i,u,e[t+11],10,-1120210379),u=c(u,d,r,i,e[t+2],15,718787259),i=c(i,u,d,r,e[t+9],21,-343485551),r=s(r,n),i=s(i,h),u=s(u,p),d=s(d,g)}return[r,i,u,d]}(function(e){if(0===e.length)return[];const t=8*e.length,r=new Uint32Array(n(t));for(let n=0;n<t;n+=8)r[n>>5]|=(255&e[n/8])<<n%32;return r}(e),8*e.length))};r.default=u}}},{package:"@metamask/eth-snap-keyring>uuid",file:"node_modules/@metamask/eth-snap-keyring/node_modules/uuid/dist/md5-browser.js"}],[1841,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};r.default=n}}},{package:"@metamask/eth-snap-keyring>uuid",file:"node_modules/@metamask/eth-snap-keyring/node_modules/uuid/dist/native-browser.js"}],[1842,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;r.default="00000000-0000-0000-0000-000000000000"}}},{package:"@metamask/eth-snap-keyring>uuid",file:"node_modules/@metamask/eth-snap-keyring/node_modules/uuid/dist/nil.js"}],[1843,{"./validate.js":1853},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n,s=(n=e("./validate.js"))&&n.__esModule?n:{default:n};var i=function(e){if(!(0,s.default)(e))throw TypeError("Invalid UUID");let t;const r=new Uint8Array(16);return r[0]=(t=parseInt(e.slice(0,8),16))>>>24,r[1]=t>>>16&255,r[2]=t>>>8&255,r[3]=255&t,r[4]=(t=parseInt(e.slice(9,13),16))>>>8,r[5]=255&t,r[6]=(t=parseInt(e.slice(14,18),16))>>>8,r[7]=255&t,r[8]=(t=parseInt(e.slice(19,23),16))>>>8,r[9]=255&t,r[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,r[11]=t/4294967296&255,r[12]=t>>>24&255,r[13]=t>>>16&255,r[14]=t>>>8&255,r[15]=255&t,r};r.default=i}}},{package:"@metamask/eth-snap-keyring>uuid",file:"node_modules/@metamask/eth-snap-keyring/node_modules/uuid/dist/parse.js"}],[1844,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;r.default=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i}}},{package:"@metamask/eth-snap-keyring>uuid",file:"node_modules/@metamask/eth-snap-keyring/node_modules/uuid/dist/regex.js"}],[1845,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){let n;Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(){if(!n&&(n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!n))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return n(s)};const s=new Uint8Array(16)}}},{package:"@metamask/eth-snap-keyring>uuid",file:"node_modules/@metamask/eth-snap-keyring/node_modules/uuid/dist/rng-browser.js"}],[1846,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){function n(e,t,r,n){switch(e){case 0:return t&r^~t&n;case 1:case 3:return t^r^n;case 2:return t&r^t&n^r&n}}function s(e,t){return e<<t|e>>>32-t}Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var i=function(e){const t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof e){const t=unescape(encodeURIComponent(e));e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);const i=e.length/4+2,o=Math.ceil(i/16),a=new Array(o);for(let t=0;t<o;++t){const r=new Uint32Array(16);for(let n=0;n<16;++n)r[n]=e[64*t+4*n]<<24|e[64*t+4*n+1]<<16|e[64*t+4*n+2]<<8|e[64*t+4*n+3];a[t]=r}a[o-1][14]=8*(e.length-1)/Math.pow(2,32),a[o-1][14]=Math.floor(a[o-1][14]),a[o-1][15]=8*(e.length-1)&4294967295;for(let e=0;e<o;++e){const i=new Uint32Array(80);for(let t=0;t<16;++t)i[t]=a[e][t];for(let e=16;e<80;++e)i[e]=s(i[e-3]^i[e-8]^i[e-14]^i[e-16],1);let o=r[0],l=r[1],c=r[2],u=r[3],d=r[4];for(let e=0;e<80;++e){const r=Math.floor(e/20),a=s(o,5)+n(r,l,c,u)+d+t[r]+i[e]>>>0;d=u,u=c,c=s(l,30)>>>0,l=o,o=a}r[0]=r[0]+o>>>0,r[1]=r[1]+l>>>0,r[2]=r[2]+c>>>0,r[3]=r[3]+u>>>0,r[4]=r[4]+d>>>0}return[r[0]>>24&255,r[0]>>16&255,r[0]>>8&255,255&r[0],r[1]>>24&255,r[1]>>16&255,r[1]>>8&255,255&r[1],r[2]>>24&255,r[2]>>16&255,r[2]>>8&255,255&r[2],r[3]>>24&255,r[3]>>16&255,r[3]>>8&255,255&r[3],r[4]>>24&255,r[4]>>16&255,r[4]>>8&255,255&r[4]]};r.default=i}}},{package:"@metamask/eth-snap-keyring>uuid",file:"node_modules/@metamask/eth-snap-keyring/node_modules/uuid/dist/sha1-browser.js"}],[1847,{"./validate.js":1853},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0,r.unsafeStringify=o;var n,s=(n=e("./validate.js"))&&n.__esModule?n:{default:n};const i=[];for(let e=0;e<256;++e)i.push((e+256).toString(16).slice(1));function o(e,t=0){return i[e[t+0]]+i[e[t+1]]+i[e[t+2]]+i[e[t+3]]+"-"+i[e[t+4]]+i[e[t+5]]+"-"+i[e[t+6]]+i[e[t+7]]+"-"+i[e[t+8]]+i[e[t+9]]+"-"+i[e[t+10]]+i[e[t+11]]+i[e[t+12]]+i[e[t+13]]+i[e[t+14]]+i[e[t+15]]}var a=function(e,t=0){const r=o(e,t);if(!(0,s.default)(r))throw TypeError("Stringified UUID is invalid");return r};r.default=a}}},{package:"@metamask/eth-snap-keyring>uuid",file:"node_modules/@metamask/eth-snap-keyring/node_modules/uuid/dist/stringify.js"}],[1848,{"./rng.js":1845,"./stringify.js":1847},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n,s=(n=e("./rng.js"))&&n.__esModule?n:{default:n},i=e("./stringify.js");let o,a,l=0,c=0;var u=function(e,t,r){let n=t&&r||0;const u=t||new Array(16);let d=(e=e||{}).node||o,h=e.clockseq!==undefined?e.clockseq:a;if(null==d||null==h){const t=e.random||(e.rng||s.default)();null==d&&(d=o=[1|t[0],t[1],t[2],t[3],t[4],t[5]]),null==h&&(h=a=16383&(t[6]<<8|t[7]))}let p=e.msecs!==undefined?e.msecs:Date.now(),g=e.nsecs!==undefined?e.nsecs:c+1;const f=p-l+(g-c)/1e4;if(f<0&&e.clockseq===undefined&&(h=h+1&16383),(f<0||p>l)&&e.nsecs===undefined&&(g=0),g>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");l=p,c=g,a=h,p+=122192928e5;const m=(1e4*(268435455&p)+g)%4294967296;u[n++]=m>>>24&255,u[n++]=m>>>16&255,u[n++]=m>>>8&255,u[n++]=255&m;const y=p/4294967296*1e4&268435455;u[n++]=y>>>8&255,u[n++]=255&y,u[n++]=y>>>24&15|16,u[n++]=y>>>16&255,u[n++]=h>>>8|128,u[n++]=255&h;for(let e=0;e<6;++e)u[n+e]=d[e];return t||(0,i.unsafeStringify)(u)};r.default=u}}},{package:"@metamask/eth-snap-keyring>uuid",file:"node_modules/@metamask/eth-snap-keyring/node_modules/uuid/dist/v1.js"}],[1849,{"./md5.js":1840,"./v35.js":1850},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=i(e("./v35.js")),s=i(e("./md5.js"));function i(e){return e&&e.__esModule?e:{default:e}}var o=(0,n.default)("v3",48,s.default);r.default=o}}},{package:"@metamask/eth-snap-keyring>uuid",file:"node_modules/@metamask/eth-snap-keyring/node_modules/uuid/dist/v3.js"}],[185,{"../../../../shared/constants/security-provider":5741,"../../../../shared/lib/trace":5773,"../ppom/ppom-util":135,"@metamask/keyring-api":1983,"ethereumjs-util":4327},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.addDappTransaction=async function(e){const{dappRequest:t}=e,{id:r,method:n,origin:s}=t,{securityAlertResponse:i,traceContext:o}=t,c={actionId:r,method:n,origin:s,requireApproval:!0,securityAlertResponse:i};(0,a.endTrace)({name:a.TraceName.Middleware,id:r});const{waitForHash:u}=await l({...e,transactionOptions:{...c,traceContext:o}}),d=await u();return(0,a.endTrace)({name:a.TraceName.Transaction,id:r}),d},r.addTransaction=async function(e){await async function(e){const{chainId:t,ppomController:r,securityAlertsEnabled:n,transactionOptions:s,transactionParams:a,updateSecurityAlertResponse:l,internalAccounts:c}=e,{type:u}=s,d=o.SECURITY_PROVIDER_EXCLUDED_TRANSACTION_TYPES.includes(u);if(!n||d)return;if(c.some((({address:e})=>{var t;return e.toLowerCase()===(null===(t=a.to)||void 0===t?void 0:t.toLowerCase())})))return;try{const{from:n,to:c,value:u,data:d}=a,{actionId:h,origin:p}=s,g={method:"eth_sendTransaction",id:h??"",origin:p??"",params:[{from:n,to:c??"",value:u??"",data:d??""}],jsonrpc:"2.0"},f=(0,i.generateSecurityAlertId)();(0,i.validateRequestWithPPOM)({ppomController:r,request:g,securityAlertId:f,chainId:t,updateSecurityAlertResponse:l});const m={...o.LOADING_SECURITY_ALERT_RESPONSE,securityAlertId:f};e.transactionOptions.securityAlertResponse=m}catch(e){(0,i.handlePPOMError)(e,"Error validating JSON RPC using PPOM: ")}}(e);const{transactionMeta:t,waitForHash:r}=await l(e);if(!e.waitForSubmit)return r().catch((()=>{})),t;const n=await r();return function(e,t){return t.state.transactions.find((t=>t.hash===e))}(n,e.transactionController)},r.getTransactionById=c;var n=e("@metamask/keyring-api"),s=e("ethereumjs-util"),i=e("../ppom/ppom-util"),o=e("../../../../shared/constants/security-provider"),a=e("../../../../shared/lib/trace");async function l(e){const{selectedAccount:t}=e;return t.type===n.EthAccountType.Erc4337?async function(e){var t;const{networkClientId:r,transactionController:n,transactionOptions:i,transactionParams:o,userOperationController:a}=e,{maxFeePerGas:l,maxPriorityFeePerGas:u}=o,{origin:d,requireApproval:h,type:p}=i,g={...o,maxFeePerGas:(0,s.addHexPrefix)(l),maxPriorityFeePerGas:(0,s.addHexPrefix)(u)},f=null==i||null===(t=i.swaps)||void 0===t?void 0:t.meta;null!=f&&f.type&&delete f.type;const m={networkClientId:r,origin:d,requireApproval:h,swaps:f,type:p},y=await a.addUserOperationFromTransaction(g,m);a.startPollingByNetworkClientId(r);return{transactionMeta:c(y.id,n),waitForHash:y.transactionHash}}(e):async function(e){const{transactionController:t,transactionOptions:r,transactionParams:n,networkClientId:s}=e,{result:i,transactionMeta:o}=await t.addTransaction(n,{...r,networkClientId:s});return{transactionMeta:o,waitForHash:()=>i}}(e)}function c(e,t){return t.state.transactions.find((t=>t.id===e))}}}},{package:"$root$",file:"app/scripts/lib/transaction/util.ts"}],[1850,{"./parse.js":1843,"./stringify.js":1847},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.URL=r.DNS=void 0,r.default=function(e,t,r){function n(e,n,o,a){var l;if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));const t=[];for(let r=0;r<e.length;++r)t.push(e.charCodeAt(r));return t}(e)),"string"==typeof n&&(n=(0,i.default)(n)),16!==(null===(l=n)||void 0===l?void 0:l.length))throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let c=new Uint8Array(16+e.length);if(c.set(n),c.set(e,n.length),c=r(c),c[6]=15&c[6]|t,c[8]=63&c[8]|128,o){a=a||0;for(let e=0;e<16;++e)o[a+e]=c[e];return o}return(0,s.unsafeStringify)(c)}try{n.name=e}catch(e){}return n.DNS=o,n.URL=a,n};var n,s=e("./stringify.js"),i=(n=e("./parse.js"))&&n.__esModule?n:{default:n};const o="6ba7b810-9dad-11d1-80b4-00c04fd430c8";r.DNS=o;const a="6ba7b811-9dad-11d1-80b4-00c04fd430c8";r.URL=a}}},{package:"@metamask/eth-snap-keyring>uuid",file:"node_modules/@metamask/eth-snap-keyring/node_modules/uuid/dist/v35.js"}],[1851,{"./native.js":1841,"./rng.js":1845,"./stringify.js":1847},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=o(e("./native.js")),s=o(e("./rng.js")),i=e("./stringify.js");function o(e){return e&&e.__esModule?e:{default:e}}var a=function(e,t,r){if(n.default.randomUUID&&!t&&!e)return n.default.randomUUID();const o=(e=e||{}).random||(e.rng||s.default)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,t){r=r||0;for(let e=0;e<16;++e)t[r+e]=o[e];return t}return(0,i.unsafeStringify)(o)};r.default=a}}},{package:"@metamask/eth-snap-keyring>uuid",file:"node_modules/@metamask/eth-snap-keyring/node_modules/uuid/dist/v4.js"}],[1852,{"./sha1.js":1846,"./v35.js":1850},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=i(e("./v35.js")),s=i(e("./sha1.js"));function i(e){return e&&e.__esModule?e:{default:e}}var o=(0,n.default)("v5",80,s.default);r.default=o}}},{package:"@metamask/eth-snap-keyring>uuid",file:"node_modules/@metamask/eth-snap-keyring/node_modules/uuid/dist/v5.js"}],[1853,{"./regex.js":1844},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n,s=(n=e("./regex.js"))&&n.__esModule?n:{default:n};var i=function(e){return"string"==typeof e&&s.default.test(e)};r.default=i}}},{package:"@metamask/eth-snap-keyring>uuid",file:"node_modules/@metamask/eth-snap-keyring/node_modules/uuid/dist/validate.js"}],[1854,{"./validate.js":1853},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n,s=(n=e("./validate.js"))&&n.__esModule?n:{default:n};var i=function(e){if(!(0,s.default)(e))throw TypeError("Invalid UUID");return parseInt(e.slice(14,15),16)};r.default=i}}},{package:"@metamask/eth-snap-keyring>uuid",file:"node_modules/@metamask/eth-snap-keyring/node_modules/uuid/dist/version.js"}],[1859,{"./onekey-keyring.cjs":1860,"./trezor-connect-bridge.cjs":1861,"./trezor-keyring.cjs":1862},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){n===undefined&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){n===undefined&&(n=r),e[n]=t[r]}),s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(r,"__esModule",{value:!0}),s(e("./trezor-keyring.cjs"),r),s(e("./onekey-keyring.cjs"),r),s(e("./trezor-connect-bridge.cjs"),r)}}},{package:"@metamask/eth-trezor-keyring",file:"node_modules/@metamask/eth-trezor-keyring/dist/index.cjs"}],[186,{"../../../../shared/constants/app":5719,"../../../../shared/constants/verification":5751,"../../../../shared/modules/selectors/networks":5799,"@ethersproject/hash":513,"@ethersproject/wallet":580,"@metamask/rpc-errors":2554,"@metamask/utils":2950},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.createTxVerificationMiddleware=function(e,t=a.TRUSTED_SIGNERS){return function(r,u,d,h){if(r.method!==l.MESSAGE_TYPE.ETH_SEND_TRANSACTION||!Array.isArray(r.params)||!function(e){return(0,o.isObject)(e[0])&&"string"==typeof e[0].data&&"string"==typeof e[0].from&&"string"==typeof e[0].to&&"string"==typeof e[0].value&&(!(0,o.hasProperty)(e[0],"chainId")||"string"==typeof e[0].chainId&&e[0].chainId.startsWith("0x"))}(r.params))return d();const p=r.params[0],g="string"==typeof p.chainId?p.chainId.toLowerCase():(0,c.getCurrentChainId)({metamask:e.state}),f=(0,a.getExperience)(p.to.toLowerCase(),g);if(!f||!a.EXPERIENCES_TO_VERIFY.includes(f))return d();const m=`0x${p.data.slice(-a.TX_SIG_LEN)}`,y=(0,s.verifyMessage)(function(e){const t={to:(0,n.hashMessage)(e.to.toLowerCase()),from:(0,n.hashMessage)(e.from.toLowerCase()),data:(0,n.hashMessage)(e.data.toLowerCase().slice(0,e.data.length-a.TX_SIG_LEN)),value:(0,n.hashMessage)(e.value.toLowerCase())};return(0,n.hashMessage)(JSON.stringify(t))}(p),m);return y!==t[f]?h(i.rpcErrors.invalidParams("Invalid transaction signature.")):d()}};var n=e("@ethersproject/hash"),s=e("@ethersproject/wallet"),i=e("@metamask/rpc-errors"),o=e("@metamask/utils"),a=e("../../../../shared/constants/verification"),l=e("../../../../shared/constants/app"),c=e("../../../../shared/modules/selectors/networks")}}},{package:"$root$",file:"app/scripts/lib/tx-verification/tx-verification-middleware.ts"}],[1860,{"./trezor-keyring.cjs":1862},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.OneKeyKeyring=void 0;const n=e("./trezor-keyring.cjs"),s="OneKey Hardware";class i extends n.TrezorKeyring{constructor(){super(...arguments),this.type=s}}r.OneKeyKeyring=i,i.type=s}}},{package:"@metamask/eth-trezor-keyring",file:"node_modules/@metamask/eth-trezor-keyring/dist/onekey-keyring.cjs"}],[1861,{"@trezor/connect-web":3269},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){n===undefined&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){n===undefined&&(n=r),e[n]=t[r]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return s(t,e),t};Object.defineProperty(r,"__esModule",{value:!0}),r.TrezorConnectBridge=void 0;const o=i(e("@trezor/connect-web"));r.TrezorConnectBridge=class{constructor(){this.trezorConnectInitiated=!1}async init(e){o.default.on(o.DEVICE_EVENT,(e=>{var t;e.type===o.DEVICE.CONNECT&&(this.model=null===(t=e.payload.features)||void 0===t?void 0:t.model)})),this.trezorConnectInitiated||(await o.default.init(e),this.trezorConnectInitiated=!0)}async dispose(){return o.default.dispose(),Promise.resolve()}getPublicKey(e){return o.default.getPublicKey(e)}ethereumSignTransaction(e){return o.default.ethereumSignTransaction(e)}ethereumSignMessage(e){return o.default.ethereumSignMessage(e)}ethereumSignTypedData(e){return o.default.ethereumSignTypedData(e)}}}}},{package:"@metamask/eth-trezor-keyring",file:"node_modules/@metamask/eth-trezor-keyring/dist/trezor-connect-bridge.cjs"}],[1862,{"@ethereumjs/tx":442,"@ethereumjs/util":457,"@metamask/eth-sig-util":1884,"@metamask/utils":2950,"@trezor/connect-plugin-ethereum":1904,buffer:4074,hdkey:4632},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){(function(t){(function(){var n,s,i,o,a,l,c=this&&this.__classPrivateFieldGet||function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)},u=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.TrezorKeyring=r.TREZOR_CONNECT_MANIFEST=void 0;const d=e("@ethereumjs/tx"),h=e("@ethereumjs/util"),p=e("@metamask/eth-sig-util"),g=e("@metamask/utils"),f=e("@trezor/connect-plugin-ethereum"),m=u(e("hdkey")),y="m/44'/60'/0'/0",b={[y]:!0,"m/44'/60'/0'":!0,"m/44'/1'/0'/0":!0},k="Trezor Hardware",w=1e3;async function v(e){return new Promise((t=>setTimeout(t,e)))}function C(e){return"function"==typeof e.getChainId}r.TREZOR_CONNECT_MANIFEST={email:"support@metamask.io",appUrl:"https://metamask.io"};class T{constructor({bridge:e}){if(n.add(this),this.type=k,this.accounts=[],this.hdk=new m.default,this.hdPath=y,this.page=0,this.perPage=5,this.unlockedAccount=0,this.paths={},!e)throw new Error("Bridge is a required dependency for the keyring");this.bridge=e}getModel(){return this.bridge.model}async init(){return this.bridge.init({manifest:r.TREZOR_CONNECT_MANIFEST,lazyLoad:!0})}async destroy(){return this.bridge.dispose()}async serialize(){return Promise.resolve({hdPath:this.hdPath,accounts:this.accounts.slice(),page:this.page,paths:this.paths,perPage:this.perPage,unlockedAccount:this.unlockedAccount})}async deserialize(e){var t,r,n,s;return this.hdPath=null!==(t=e.hdPath)&&void 0!==t?t:y,this.accounts=null!==(r=e.accounts)&&void 0!==r?r:[],this.page=null!==(n=e.page)&&void 0!==n?n:0,this.perPage=null!==(s=e.perPage)&&void 0!==s?s:5,Promise.resolve()}isUnlocked(){var e;return Boolean(null===(e=this.hdk)||void 0===e?void 0:e.publicKey)}async unlock(){return this.isUnlocked()?Promise.resolve("already unlocked"):new Promise(((e,r)=>{this.bridge.getPublicKey({path:this.hdPath,coin:"ETH"}).then((n=>{var s;n.success?(this.hdk.publicKey=t.from(n.payload.publicKey,"hex"),this.hdk.chainCode=t.from(n.payload.chainCode,"hex"),e("just unlocked")):r(new Error((null===(s=n.payload)||void 0===s?void 0:s.error)||"Unknown error"))})).catch((e=>{r(new Error((null==e?void 0:e.toString())||"Unknown error"))}))}))}setAccountToUnlock(e){this.unlockedAccount=parseInt(String(e),10)}async addAccounts(e){return new Promise(((t,r)=>{this.unlock().then((r=>{const s=this.unlockedAccount,i=s+e,o=[];for(let e=s;e<i;e++){const t=c(this,n,"m",a).call(this,"m",e);this.accounts.includes(t)||(this.accounts=[...this.accounts,t],o.push(t)),this.page=0}t(o)})).catch((e=>{r(e)}))}))}async getFirstPage(){return this.page=0,c(this,n,"m",s).call(this,1)}async getNextPage(){return c(this,n,"m",s).call(this,1)}async getPreviousPage(){return c(this,n,"m",s).call(this,-1)}async getAccounts(){return Promise.resolve(this.accounts.slice())}removeAccount(e){if(!this.accounts.map((e=>e.toLowerCase())).includes(e.toLowerCase()))throw new Error(`Address ${e} not found in this keyring`);this.accounts=this.accounts.filter((t=>t.toLowerCase()!==e.toLowerCase()))}async signTransaction(e,r){return C(r)?c(this,n,"m",i).call(this,e,r.getChainId(),r,(e=>(r.v=t.from(e.v,"hex"),r.r=t.from(e.r,"hex"),r.s=t.from(e.s,"hex"),r))):c(this,n,"m",i).call(this,e,Number(r.common.chainId()),r,(e=>{const t=r.toJSON();return t.type=r.type,t.v=(0,g.add0x)(e.v),t.r=(0,g.add0x)(e.r),t.s=(0,g.add0x)(e.s),d.TransactionFactory.fromTxData(t,{common:r.common,freeze:Object.isFrozen(r)})}))}async signMessage(e,t){return this.signPersonalMessage(e,t)}async signPersonalMessage(e,t){return new Promise(((r,s)=>{this.unlock().then((i=>{setTimeout((()=>{this.bridge.ethereumSignMessage({path:c(this,n,"m",l).call(this,e),message:(0,g.remove0x)(t),hex:!0}).then((t=>{var n;if(t.success){t.payload.address!==(0,g.getChecksumAddress)(e)&&s(new Error("signature doesnt match the right address"));const n=`0x${t.payload.signature}`;r(n)}else s(new Error((null===(n=t.payload)||void 0===n?void 0:n.error)||"Unknown error"))})).catch((e=>{s(new Error((null==e?void 0:e.toString())||"Unknown error"))}))}),"just unlocked"===i?w:0)})).catch((e=>{s(new Error((null==e?void 0:e.toString())||"Unknown error"))}))}))}async signTypedData(e,t,{version:r}){var s,i;const o=(0,f.transformTypedData)(t,r===p.SignTypedDataVersion.V4),{types:a,message:u={},domain:d={},primaryType:h,domain_separator_hash:m,message_hash:y}=o,b=await this.unlock();await v("just unlocked"===b?w:0);const k=await this.bridge.ethereumSignTypedData({path:c(this,n,"m",l).call(this,e),data:{types:Object.assign(Object.assign({},a),{EIP712Domain:null!==(s=a.EIP712Domain)&&void 0!==s?s:[]}),message:u,domain:d,primaryType:h},metamask_v4_compat:!0,domain_separator_hash:m,message_hash:null!=y?y:""});if(k.success){if((0,g.getChecksumAddress)(e)!==k.payload.address)throw new Error("signature doesnt match the right address");return k.payload.signature}throw new Error((null===(i=k.payload)||void 0===i?void 0:i.error)||"Unknown error")}forgetDevice(){this.accounts=[],this.hdk=new m.default,this.page=0,this.unlockedAccount=0,this.paths={}}setHdPath(e){if(!b[e])throw new Error(`The setHdPath method does not support setting HD Path to ${e}`);this.hdPath!==e&&(this.hdk=new m.default,this.accounts=[],this.page=0,this.perPage=5,this.unlockedAccount=0,this.paths={}),this.hdPath=e}}r.TrezorKeyring=T,n=new WeakSet,s=async function(e){return this.page+=e,this.page<=0&&(this.page=1),new Promise(((e,t)=>{this.unlock().then((t=>{const r=(this.page-1)*this.perPage,s=r+this.perPage,i=[];for(let e=r;e<s;e++){const t=c(this,n,"m",a).call(this,"m",e);i.push({address:t,balance:null,index:e}),this.paths[(0,g.getChecksumAddress)(t)]=e}e(i)})).catch((e=>{t(e)}))}))},i=async function(e,r,s,i){var a,u,d,h;let p;p=C(s)?{to:c(this,n,"m",o).call(this,s.to),value:c(this,n,"m",o).call(this,s.value),data:c(this,n,"m",o).call(this,s.data),chainId:r,nonce:c(this,n,"m",o).call(this,s.nonce),gasLimit:c(this,n,"m",o).call(this,s.gasLimit),gasPrice:c(this,n,"m",o).call(this,s.gasPrice)}:Object.assign(Object.assign({},s.toJSON()),{chainId:r,to:c(this,n,"m",o).call(this,t.from(null!==(u=null===(a=s.to)||void 0===a?void 0:a.bytes)&&void 0!==u?u:[]))});try{const t=await this.unlock();await v("just unlocked"===t?w:0);const r=await this.bridge.ethereumSignTransaction({path:c(this,n,"m",l).call(this,e),transaction:p});if(r.success){const t=i(r.payload),n=(0,g.getChecksumAddress)((0,g.add0x)(t.getSenderAddress().toString("hex")));if(n!==(0,g.getChecksumAddress)(e))throw new Error("signature doesn't match the right address");return t}throw new Error((null===(d=r.payload)||void 0===d?void 0:d.error)||"Unknown error")}catch(e){throw new Error(null!==(h=null==e?void 0:e.toString())&&void 0!==h?h:"Unknown error")}},o=function(e){return(0,g.bytesToHex)(e)},a=function(e,t){const r=this.hdk.derive(`${e}/${t}`),n=(0,g.bytesToHex)((0,h.publicToAddress)(r.publicKey,!0));return(0,h.toChecksumAddress)(n)},l=function(e){const t=(0,g.getChecksumAddress)(e);let r=this.paths[t];if(void 0===r)for(let e=0;e<1e3;e++)if(t===c(this,n,"m",a).call(this,"m",e)){r=e;break}if(void 0===r)throw new Error("Unknown address");return`${this.hdPath}/${r}`},T.type=k}).call(this)}).call(this,e("buffer").Buffer)}}},{package:"@metamask/eth-trezor-keyring",file:"node_modules/@metamask/eth-trezor-keyring/dist/trezor-keyring.cjs"}],[1863,{"./errors":1864,"./packer":1867,"@metamask/utils":2950},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.decodeSingle=r.decode=r.encodePacked=r.encodeSingle=r.encode=void 0;const n=e("@metamask/utils"),s=e("./errors"),i=e("./packer");r.encode=(e,t,r,n)=>{try{return(0,i.pack)({types:e,values:t,packed:r,tight:n})}catch(e){if(e instanceof s.ParserError)throw new s.ParserError(`Unable to encode value: ${e.message}`,e);throw new s.ParserError(`An unexpected error occurred: ${(0,s.getErrorMessage)(e)}`,e)}};r.encodeSingle=(e,t)=>(0,r.encode)([e],[t]);r.encodePacked=(e,t,n)=>(0,r.encode)(e,t,!0,n);r.decode=(e,t)=>{const r=(0,n.createBytes)(t);try{return(0,i.unpack)(e,r)}catch(e){if(e instanceof s.ParserError)throw new s.ParserError(`Unable to decode value: ${e.message}`,e);throw new s.ParserError(`An unexpected error occurred: ${(0,s.getErrorMessage)(e)}`,e)}};r.decodeSingle=(e,t)=>{const i=(0,r.decode)([e],t);return(0,n.assert)(1===i.length,new s.ParserError("Decoded value array has unexpected length.")),i[0]}}}},{package:"@metamask/eth-trezor-keyring>@metamask/eth-sig-util>@metamask/abi-utils",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@metamask/abi-utils/dist/abi.js"}],[1864,{"@metamask/utils":2950},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.ParserError=r.getErrorStack=r.getErrorMessage=void 0;const n=e("@metamask/utils");r.getErrorMessage=e=>"string"==typeof e?e:e instanceof Error||(0,n.isObject)(e)&&(0,n.hasProperty)(e,"message")&&"string"==typeof e.message?e.message:"Unknown error.";r.getErrorStack=e=>e instanceof Error?e.stack:undefined;class s extends Error{constructor(e,t){super(e),this.name="ParserError";const n=(0,r.getErrorStack)(t);n&&(this.stack=n)}}r.ParserError=s}}},{package:"@metamask/eth-trezor-keyring>@metamask/eth-sig-util>@metamask/abi-utils",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@metamask/abi-utils/dist/errors.js"}],[1865,{"./abi":1863,"./errors":1864,"./types":1880},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){n===undefined&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){n===undefined&&(n=r),e[n]=t[r]}),s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(r,"__esModule",{value:!0}),s(e("./abi"),r),s(e("./errors"),r),s(e("./types"),r)}}},{package:"@metamask/eth-trezor-keyring>@metamask/eth-sig-util>@metamask/abi-utils",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@metamask/abi-utils/dist/index.js"}],[1866,{"@metamask/utils":2950},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.iterate=void 0;const n=e("@metamask/utils");r.iterate=function*(e,t=32){for(let r=0;r<e.length;r+=t){const s=e=>{(0,n.assert)(e>=0,"Cannot skip a negative number of bytes."),(0,n.assert)(e%t==0,"Length must be a multiple of the size."),r+=e},i=e.subarray(r);yield{skip:s,value:i}}return{skip:()=>undefined,value:new Uint8Array}}}}},{package:"@metamask/eth-trezor-keyring>@metamask/eth-sig-util>@metamask/abi-utils",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@metamask/abi-utils/dist/iterator.js"}],[1867,{"./errors":1864,"./iterator":1866,"./parsers":1874,"./utils":1882,"@metamask/utils":2950},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.unpack=r.pack=r.isDynamicParser=r.getParser=void 0;const n=e("@metamask/utils"),s=e("./errors"),i=e("./iterator"),o=e("./parsers"),a=e("./utils");r.getParser=e=>{const t={address:o.address,array:o.array,bool:o.bool,bytes:o.bytes,fixedBytes:o.fixedBytes,function:o.fn,number:o.number,string:o.string,tuple:o.tuple},r=t[e];if(r)return r;const n=Object.values(t).find((t=>t.isType(e)));if(n)return n;throw new s.ParserError(`The type "${e}" is not supported.`)};r.isDynamicParser=(e,t)=>{const{isDynamic:r}=e;return"function"==typeof r?r(t):r};r.pack=({types:e,values:t,packed:i=!1,tight:o=!1,arrayPacked:l=!1,byteArray:c=new Uint8Array})=>{(0,n.assert)(e.length===t.length,new s.ParserError(`The number of types (${e.length}) does not match the number of values (${t.length}).`));const{staticBuffer:u,dynamicBuffer:d,pointers:h}=e.reduce((({staticBuffer:e,dynamicBuffer:s,pointers:a},c,u)=>{const d=(0,r.getParser)(c),h=t[u];if(i||l||!(0,r.isDynamicParser)(d,c))return{staticBuffer:d.encode({buffer:e,value:h,type:c,packed:i,tight:o}),dynamicBuffer:s,pointers:a};return{staticBuffer:(0,n.concatBytes)([e,new Uint8Array(32)]),dynamicBuffer:d.encode({buffer:s,value:h,type:c,packed:i,tight:o}),pointers:[...a,{position:e.length,pointer:s.length}]}}),{staticBuffer:new Uint8Array,dynamicBuffer:new Uint8Array,pointers:[]});(0,n.assert)(!i&&!l||0===d.length,new s.ParserError("Invalid pack state."));const p=u.length,g=h.reduce(((e,{pointer:t,position:r})=>{const s=(0,a.padStart)((0,n.numberToBytes)(p+t));return(0,a.set)(e,s,r)}),u);return(0,n.concatBytes)([c,g,d])};r.unpack=(e,t)=>{const o=(0,i.iterate)(t);return e.map((e=>{const{value:{value:i,skip:a},done:l}=o.next();(0,n.assert)(!l,new s.ParserError(`The encoded value is invalid for the provided types. Reached end of buffer while attempting to parse "${e}".`));const c=(0,r.getParser)(e);if((0,r.isDynamicParser)(c,e)){const r=(0,n.bytesToNumber)(i.subarray(0,32)),s=t.subarray(r);return c.decode({type:e,value:s,skip:a})}return c.decode({type:e,value:i,skip:a})}))}}}},{package:"@metamask/eth-trezor-keyring>@metamask/eth-sig-util>@metamask/abi-utils",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@metamask/abi-utils/dist/packer.js"}],[1868,{"../errors":1864,"../utils":1882,"@metamask/utils":2950},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.address=r.getAddress=void 0;const n=e("@metamask/utils"),s=e("../errors"),i=e("../utils");r.getAddress=e=>{const t=(0,n.createBytes)(e);return(0,n.assert)(t.length<=20,new s.ParserError(`Invalid address value. Expected address to be 20 bytes long, but received ${t.length} bytes.`)),(0,i.padStart)(t,20)},r.address={isDynamic:!1,isType:e=>"address"===e,getByteLength:()=>32,encode({buffer:e,value:t,packed:s}){const o=(0,r.getAddress)(t);if(s)return(0,n.concatBytes)([e,o]);const a=(0,i.padStart)(o);return(0,n.concatBytes)([e,a])},decode:({value:e})=>(0,n.add0x)((0,n.bytesToHex)(e.slice(12,32)))}}}},{package:"@metamask/eth-trezor-keyring>@metamask/eth-sig-util>@metamask/abi-utils",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@metamask/abi-utils/dist/parsers/address.js"}],[1869,{"../errors":1864,"../packer":1867,"../utils":1882,"./fixed-bytes":1872,"./tuple":1878,"@metamask/utils":2950},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.array=r.getTupleType=r.getArrayType=r.isArrayType=void 0;const n=e("@metamask/utils"),s=e("../errors"),i=e("../packer"),o=e("../utils"),a=e("./fixed-bytes"),l=e("./tuple"),c=/^(?<type>.*)\[(?<length>\d*?)\]$/u;r.isArrayType=e=>c.test(e);r.getArrayType=e=>{const t=e.match(c);return(0,n.assert)(t?.groups?.type,new s.ParserError(`Invalid array type. Expected an array type, but received "${e}".`)),[t.groups.type,t.groups.length?parseInt(t.groups.length,10):undefined]};r.getTupleType=(e,t)=>`(${new Array(t).fill(e).join(",")})`,r.array={isDynamic(e){const[t,n]=(0,r.getArrayType)(e);return n===undefined||(0,i.isDynamicParser)((0,i.getParser)(t),t)},isType:e=>(0,r.isArrayType)(e),getByteLength(e){(0,n.assert)((0,r.isArrayType)(e),new s.ParserError(`Expected an array type, but received "${e}".`));const[t,o]=(0,r.getArrayType)(e);return(0,i.isDynamicParser)(this,e)||o===undefined?32:l.tuple.getByteLength((0,r.getTupleType)(t,o))},encode({type:e,buffer:t,value:c,packed:u,tight:d}){const[h,p]=(0,r.getArrayType)(e);if((0,n.assert)(!u||!(0,r.isArrayType)(h),new s.ParserError("Cannot pack nested arrays.")),u&&(0,i.isDynamicParser)((0,i.getParser)(h),h))return(0,i.pack)({types:new Array(c.length).fill(h),values:c,byteArray:t,packed:u,arrayPacked:!0,tight:d});if(p)return(0,n.assert)(p===c.length,new s.ParserError(`Array length does not match type length. Expected a length of ${p}, but received ${c.length}.`)),l.tuple.encode({type:(0,r.getTupleType)(h,p),buffer:t,value:c,packed:a.fixedBytes.isType(h)&&d,tight:d});if(u)return(0,i.pack)({types:new Array(c.length).fill(h),values:c,byteArray:t,packed:a.fixedBytes.isType(h)&&d,arrayPacked:!0,tight:d});const g=(0,o.padStart)((0,n.numberToBytes)(c.length));return(0,i.pack)({types:new Array(c.length).fill(h),values:c,byteArray:(0,n.concatBytes)([t,g]),packed:u,tight:d})},decode({type:e,value:t,...o}){const[a,c]=(0,r.getArrayType)(e);if(c){const e=l.tuple.decode({type:(0,r.getTupleType)(a,c),value:t,...o});return(0,n.assert)(e.length===c,new s.ParserError(`Array length does not match type length. Expected a length of ${c}, but received ${e.length}.`)),e}const u=(0,n.bytesToNumber)(t.subarray(0,32));return(0,i.unpack)(new Array(u).fill(a),t.subarray(32))}}}}},{package:"@metamask/eth-trezor-keyring>@metamask/eth-sig-util>@metamask/abi-utils",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@metamask/abi-utils/dist/parsers/array.js"}],[1870,{"../errors":1864,"./number":1875,"@metamask/superstruct":2872,"@metamask/utils":2950},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.bool=r.getBooleanValue=void 0;const n=e("@metamask/superstruct"),s=e("@metamask/utils"),i=e("../errors"),o=e("./number"),a=(0,n.coerce)((0,n.boolean)(),(0,n.union)([(0,n.literal)("true"),(0,n.literal)("false")]),(e=>"true"===e));r.getBooleanValue=e=>{try{return(0,n.create)(e,a)?BigInt(1):BigInt(0)}catch{throw new i.ParserError(`Invalid boolean value. Expected a boolean literal, or the string "true" or "false", but received "${e}".`)}},r.bool={isDynamic:!1,isType:e=>"bool"===e,getByteLength:()=>32,encode({buffer:e,value:t,packed:n,tight:i}){const a=(0,r.getBooleanValue)(t);return n?(0,s.concatBytes)([e,(0,s.bigIntToBytes)(a)]):o.number.encode({type:"uint256",buffer:e,value:a,packed:n,tight:i})},decode:e=>o.number.decode({...e,type:"uint256"})===BigInt(1)}}}},{package:"@metamask/eth-trezor-keyring>@metamask/eth-sig-util>@metamask/abi-utils",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@metamask/abi-utils/dist/parsers/bool.js"}],[1871,{"../utils":1882,"@metamask/utils":2950},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.bytes=void 0;const n=e("@metamask/utils"),s=e("../utils");r.bytes={isDynamic:!0,isType:e=>"bytes"===e,getByteLength:()=>32,encode({buffer:e,value:t,packed:r}){const i=(0,n.createBytes)(t);if(r)return(0,n.concatBytes)([e,i]);const o=32*Math.ceil(i.byteLength/32);return(0,n.concatBytes)([e,(0,s.padStart)((0,n.numberToBytes)(i.byteLength)),(0,s.padEnd)(i,o)])},decode({value:e}){const t=e.subarray(0,32),r=(0,n.bytesToNumber)(t);return e.slice(32,32+r)}}}}},{package:"@metamask/eth-trezor-keyring>@metamask/eth-sig-util>@metamask/abi-utils",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@metamask/abi-utils/dist/parsers/bytes.js"}],[1872,{"../errors":1864,"../utils":1882,"@metamask/utils":2950},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.fixedBytes=r.getByteLength=void 0;const n=e("@metamask/utils"),s=e("../errors"),i=e("../utils"),o=/^bytes([0-9]{1,2})$/u;r.getByteLength=e=>{const t=e.match(o)?.[1];(0,n.assert)(t,`Invalid byte length. Expected a number between 1 and 32, but received "${e}".`);const r=Number(t);return(0,n.assert)(r>0&&r<=32,new s.ParserError(`Invalid byte length. Expected a number between 1 and 32, but received "${e}".`)),r},r.fixedBytes={isDynamic:!1,isType:e=>o.test(e),getByteLength:()=>32,encode({type:e,buffer:t,value:o,packed:a}){const l=(0,r.getByteLength)(e),c=(0,n.createBytes)(o);return(0,n.assert)(c.length<=l,new s.ParserError(`Expected a value of length ${l}, but received a value of length ${c.length}.`)),a?(0,n.concatBytes)([t,(0,i.padEnd)(c,l)]):(0,n.concatBytes)([t,(0,i.padEnd)(c)])},decode({type:e,value:t}){const n=(0,r.getByteLength)(e);return t.slice(0,n)}}}}},{package:"@metamask/eth-trezor-keyring>@metamask/eth-sig-util>@metamask/abi-utils",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@metamask/abi-utils/dist/parsers/fixed-bytes.js"}],[1873,{"../errors":1864,"./fixed-bytes":1872,"@metamask/superstruct":2872,"@metamask/utils":2950},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.fn=r.getFunction=void 0;const n=e("@metamask/superstruct"),s=e("@metamask/utils"),i=e("../errors"),o=e("./fixed-bytes"),a=(0,n.coerce)((0,n.object)({address:s.StrictHexStruct,selector:s.StrictHexStruct}),(0,n.union)([s.StrictHexStruct,(0,n.instance)(Uint8Array)]),(e=>{const t=(0,s.createBytes)(e);return(0,s.assert)(24===t.length,new i.ParserError(`Invalid Solidity function. Expected function to be 24 bytes long, but received ${t.length} bytes.`)),{address:(0,s.bytesToHex)(t.subarray(0,20)),selector:(0,s.bytesToHex)(t.subarray(20,24))}}));r.getFunction=e=>{const t=(0,n.create)(e,a);return(0,s.concatBytes)([(0,s.hexToBytes)(t.address),(0,s.hexToBytes)(t.selector)])},r.fn={isDynamic:!1,isType:e=>"function"===e,getByteLength:()=>32,encode({buffer:e,value:t,packed:n,tight:s}){const i=(0,r.getFunction)(t);return o.fixedBytes.encode({type:"bytes24",buffer:e,value:i,packed:n,tight:s})},decode:({value:e})=>({address:(0,s.bytesToHex)(e.slice(0,20)),selector:(0,s.bytesToHex)(e.slice(20,24))})}}}},{package:"@metamask/eth-trezor-keyring>@metamask/eth-sig-util>@metamask/abi-utils",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@metamask/abi-utils/dist/parsers/function.js"}],[1874,{"./address":1868,"./array":1869,"./bool":1870,"./bytes":1871,"./fixed-bytes":1872,"./function":1873,"./number":1875,"./parser":1876,"./string":1877,"./tuple":1878},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){n===undefined&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){n===undefined&&(n=r),e[n]=t[r]}),s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(r,"__esModule",{value:!0}),s(e("./address"),r),s(e("./array"),r),s(e("./bool"),r),s(e("./bytes"),r),s(e("./fixed-bytes"),r),s(e("./function"),r),s(e("./number"),r),s(e("./parser"),r),s(e("./string"),r),s(e("./tuple"),r)}}},{package:"@metamask/eth-trezor-keyring>@metamask/eth-sig-util>@metamask/abi-utils",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@metamask/abi-utils/dist/parsers/index.js"}],[1875,{"../errors":1864,"../utils":1882,"@metamask/utils":2950},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.number=r.getBigInt=r.assertNumberLength=r.getLength=r.isSigned=void 0;const n=e("@metamask/utils"),s=e("../errors"),i=e("../utils"),o=/^u?int(?<length>[0-9]*)?$/u;r.isSigned=e=>!e.startsWith("u");r.getLength=e=>{if("int"===e||"uint"===e)return 256;const t=e.match(o);(0,n.assert)(t?.groups?.length,new s.ParserError(`Invalid number type. Expected a number type, but received "${e}".`));const r=parseInt(t.groups.length,10);return(0,n.assert)(r>=8&&r<=256,new s.ParserError(`Invalid number length. Expected a number between 8 and 256, but received "${e}".`)),(0,n.assert)(r%8==0,new s.ParserError(`Invalid number length. Expected a multiple of 8, but received "${e}".`)),r};r.assertNumberLength=(e,t)=>{const i=(0,r.getLength)(t),o=BigInt(2)**BigInt(i-((0,r.isSigned)(t)?1:0))-BigInt(1);(0,r.isSigned)(t)?(0,n.assert)(e>=-(o+BigInt(1))&&e<=o,new s.ParserError(`Number "${e}" is out of range for type "${t}".`)):(0,n.assert)(e<=o,new s.ParserError(`Number "${e}" is out of range for type "${t}".`))};r.getBigInt=e=>{try{return(0,n.createBigInt)(e)}catch{throw new s.ParserError(`Invalid number. Expected a valid number value, but received "${e}".`)}},r.number={isDynamic:!1,isType:e=>o.test(e),getByteLength:()=>32,encode({type:e,buffer:t,value:s,packed:o}){const a=(0,r.getBigInt)(s);if((0,r.assertNumberLength)(a,e),(0,r.isSigned)(e)){if(o){const s=(0,r.getLength)(e)/8;return(0,n.concatBytes)([t,(0,n.signedBigIntToBytes)(a,s)])}return(0,n.concatBytes)([t,(0,i.padStart)((0,n.signedBigIntToBytes)(a,32))])}if(o){const s=(0,r.getLength)(e)/8;return(0,n.concatBytes)([t,(0,i.padStart)((0,n.bigIntToBytes)(a),s)])}return(0,n.concatBytes)([t,(0,i.padStart)((0,n.bigIntToBytes)(a))])},decode({type:e,value:t}){const s=t.subarray(0,32);if((0,r.isSigned)(e)){const t=(0,n.bytesToSignedBigInt)(s);return(0,r.assertNumberLength)(t,e),t}const i=(0,n.bytesToBigInt)(s);return(0,r.assertNumberLength)(i,e),i}}}}},{package:"@metamask/eth-trezor-keyring>@metamask/eth-sig-util>@metamask/abi-utils",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@metamask/abi-utils/dist/parsers/number.js"}],[1876,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0})}}},{package:"@metamask/eth-trezor-keyring>@metamask/eth-sig-util>@metamask/abi-utils",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@metamask/abi-utils/dist/parsers/parser.js"}],[1877,{"./bytes":1871,"@metamask/utils":2950},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.string=void 0;const n=e("@metamask/utils"),s=e("./bytes");r.string={isDynamic:!0,isType:e=>"string"===e,getByteLength:()=>32,encode:({buffer:e,value:t,packed:r,tight:i})=>s.bytes.encode({type:"bytes",buffer:e,value:(0,n.stringToBytes)(t),packed:r,tight:i}),decode:e=>(0,n.bytesToString)(s.bytes.decode(e))}}}},{package:"@metamask/eth-trezor-keyring>@metamask/eth-sig-util>@metamask/abi-utils",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@metamask/abi-utils/dist/parsers/string.js"}],[1878,{"../errors":1864,"../packer":1867,"@metamask/utils":2950},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.tuple=r.getTupleElements=void 0;const n=e("@metamask/utils"),s=e("../errors"),i=e("../packer"),o=/^\((.+)\)$/u;r.getTupleElements=e=>{(0,n.assert)(e.startsWith("(")&&e.endsWith(")"),new s.ParserError(`Invalid tuple type. Expected tuple type, but received "${e}".`));const t=[];let r="",i=0;for(let n=1;n<e.length-1;n++){const s=e[n];","===s&&0===i?(t.push(r.trim()),r=""):(r+=s,"("===s?i+=1:")"===s&&(i-=1))}return r.trim()&&t.push(r.trim()),t},r.tuple={isDynamic:e=>(0,r.getTupleElements)(e).some((e=>{const t=(0,i.getParser)(e);return(0,i.isDynamicParser)(t,e)})),isType:e=>(e=>o.test(e))(e),getByteLength(e){if((0,i.isDynamicParser)(this,e))return 32;return(0,r.getTupleElements)(e).reduce(((e,t)=>e+(0,i.getParser)(t).getByteLength(t)),0)},encode({type:e,buffer:t,value:n,packed:s,tight:o}){const a=(0,r.getTupleElements)(e);return(0,i.pack)({types:a,values:n,byteArray:t,packed:s,tight:o})},decode({type:e,value:t,skip:n}){const s=(0,r.getTupleElements)(e);return n(this.getByteLength(e)-32),(0,i.unpack)(s,t)}}}}},{package:"@metamask/eth-trezor-keyring>@metamask/eth-sig-util>@metamask/abi-utils",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@metamask/abi-utils/dist/parsers/tuple.js"}],[1879,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0})}}},{package:"@metamask/eth-trezor-keyring>@metamask/eth-sig-util>@metamask/abi-utils",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@metamask/abi-utils/dist/types/abi.js"}],[188,{"../../development/build/constants":369,"../../shared/constants/app":5719,"../../shared/constants/bridge":5720,"../../shared/constants/hardware-wallets":5726,"../../shared/constants/keyring":5727,"../../shared/constants/logs":5729,"../../shared/constants/metametrics":5730,"../../shared/constants/methods-tags":5731,"../../shared/constants/network":5734,"../../shared/constants/permissions":5738,"../../shared/constants/smartTransactions":5743,"../../shared/constants/swaps":5745,"../../shared/constants/time":5747,"../../shared/constants/tokens":5748,"../../shared/constants/transaction":5749,"../../shared/constants/urls":5750,"../../shared/lib/fetch-with-cache":5763,"../../shared/lib/metamask-controller-utils":5766,"../../shared/lib/storage-helpers":5769,"../../shared/lib/token-util":5772,"../../shared/lib/trace":5773,"../../shared/lib/transactions-controller-utils":5775,"../../shared/modules/caip-stream":5780,"../../shared/modules/mv3.utils":5791,"../../shared/modules/network.utils":5792,"../../shared/modules/selectors":5798,"../../shared/modules/selectors/networks":5799,"../../shared/modules/string-utils":5802,"../../shared/modules/transaction.utils":5804,"../../shared/notifications":5806,"../../shared/types/bridge-status":5807,"./constants/stream":8,"./controller-init/confirmations/ppom-controller-init":9,"./controller-init/confirmations/transaction-controller-init":10,"./controller-init/identity/authentication-controller-init":11,"./controller-init/identity/user-storage-controller-init":12,"./controller-init/multichain":36,"./controller-init/notifications/notification-services-controller-init":42,"./controller-init/notifications/notification-services-push-controller-init":43,"./controller-init/snaps":46,"./controller-init/utils":53,"./controllers/account-order":54,"./controllers/account-tracker-controller":55,"./controllers/alert-controller":56,"./controllers/app-metadata":57,"./controllers/app-state-controller":58,"./controllers/bridge-status/bridge-status-controller":59,"./controllers/bridge-status/constants":60,"./controllers/decrypt-message":63,"./controllers/encryption-public-key":64,"./controllers/metametrics-controller":65,"./controllers/metametrics-data-deletion/metametrics-data-deletion":66,"./controllers/network-order":67,"./controllers/onboarding":68,"./controllers/permissions":72,"./controllers/preferences-controller":75,"./controllers/swaps":79,"./detect-multiple-instances":82,"./lib/AccountIdentitiesPetnamesBridge":93,"./lib/AddressBookPetnamesBridge":94,"./lib/ComposableObservableStore":95,"./lib/PatchStore":96,"./lib/SnapsNameProvider":97,"./lib/WeakRefObjectMap":98,"./lib/approval/utils":99,"./lib/backup":100,"./lib/bridge-status/metrics":102,"./lib/createDupeReqFilterStream":103,"./lib/createEvmMethodsToNonEvmAccountReqFilterMiddleware":104,"./lib/createLoggerMiddleware":105,"./lib/createMainFrameOriginMiddleware":106,"./lib/createMetaRPCHandler":107,"./lib/createMetamaskMiddleware":108,"./lib/createOnboardingMiddleware":109,"./lib/createOriginMiddleware":110,"./lib/createOriginThrottlingMiddleware":111,"./lib/createRPCMethodTrackingMiddleware":112,"./lib/createTabIdMiddleware":114,"./lib/createTracingMiddleware":115,"./lib/encryptor-factory":116,"./lib/hardware-keyring-builder-factory":124,"./lib/multichain/address":128,"./lib/offscreen-bridge/lattice-offscreen-keyring":130,"./lib/offscreen-bridge/ledger-offscreen-bridge":131,"./lib/offscreen-bridge/trezor-offscreen-bridge":132,"./lib/ppom/ppom-middleware":134,"./lib/ppom/ppom-util":135,"./lib/rpc-method-middleware":155,"./lib/rpc-method-middleware/handlers/wallet-createSession":150,"./lib/segment":157,"./lib/signature/util":161,"./lib/snap-keyring":162,"./lib/snap-keyring/keyring-snaps-permissions":163,"./lib/state-utils":170,"./lib/stream-utils":175,"./lib/transaction/decode/util":181,"./lib/transaction/eip5792":182,"./lib/transaction/metrics":183,"./lib/transaction/util":185,"./lib/tx-verification/tx-verification-middleware":186,"./lib/util":187,"./services/data-deletion-service":364,"./translate":366,"@ethersproject/abi":484,"@keystonehq/metamask-airgapped-keyring":687,"@metamask/accounts-controller":1291,"@metamask/address-book-controller":1294,"@metamask/announcement-controller":1296,"@metamask/approval-controller":1299,"@metamask/assets-controllers":1329,"@metamask/base-controller":1383,"@metamask/bridge-controller":1390,"@metamask/controller-utils":1474,"@metamask/ens-controller":1502,"@metamask/eth-json-rpc-filters":1557,"@metamask/eth-json-rpc-filters/subscriptionManager":1559,"@metamask/eth-json-rpc-middleware":1592,"@metamask/eth-ledger-bridge-keyring":1652,"@metamask/eth-sig-util":1703,"@metamask/eth-trezor-keyring":1859,"@metamask/gas-fee-controller":1924,"@metamask/json-rpc-engine":1933,"@metamask/json-rpc-middleware-stream":1937,"@metamask/keyring-api":1983,"@metamask/keyring-controller":1990,"@metamask/logging-controller":2070,"@metamask/metamask-eth-abis":2089,"@metamask/multichain":2146,"@metamask/name-controller":2164,"@metamask/network-controller":2176,"@metamask/notification-services-controller/notification-services":2344,"@metamask/obs-store":2386,"@metamask/obs-store/dist/asStream":2385,"@metamask/permission-controller":2393,"@metamask/permission-log-controller":2402,"@metamask/phishing-controller":2405,"@metamask/queued-request-controller":2516,"@metamask/remote-feature-flag-controller":2547,"@metamask/rpc-errors":2554,"@metamask/scure-bip39/dist/wordlists/english":2558,"@metamask/selected-network-controller":2570,"@metamask/signature-controller":2577,"@metamask/smart-transactions-controller":2627,"@metamask/smart-transactions-controller/dist/types":2628,"@metamask/snaps-rpc-methods":2700,"@metamask/snaps-utils":2850,"@metamask/transaction-controller":2905,"@metamask/user-operation-controller":2932,"@metamask/utils":2950,"@sentry/browser":3084,"await-semaphore":3917,buffer:4074,"eth-chainlist":4275,"eth-lattice-keyring":4280,events:4399,lodash:4855,loglevel:4863,nanoid:4959,"readable-stream":5274},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){(function(t){(function(){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.METAMASK_CONTROLLER_EVENTS=void 0;var n=Jt(e("events")),s=e("readable-stream"),i=e("@metamask/assets-controllers"),o=e("@metamask/json-rpc-engine"),a=e("@metamask/json-rpc-middleware-stream"),l=e("@metamask/obs-store"),c=e("@metamask/obs-store/dist/asStream"),u=e("@metamask/eth-json-rpc-middleware"),d=e("lodash"),h=e("@metamask/keyring-controller"),p=Jt(e("@metamask/eth-json-rpc-filters")),g=Jt(e("@metamask/eth-json-rpc-filters/subscriptionManager")),f=e("@metamask/rpc-errors"),m=e("await-semaphore"),y=Jt(e("loglevel")),b=e("@metamask/eth-trezor-keyring"),k=e("@metamask/eth-ledger-bridge-keyring"),w=Jt(e("eth-lattice-keyring")),v=e("eth-chainlist"),C=e("@keystonehq/metamask-airgapped-keyring"),T=e("nanoid"),S=e("@sentry/browser"),A=e("@metamask/address-book-controller"),M=e("@metamask/approval-controller"),P=e("@metamask/base-controller"),E=e("@metamask/ens-controller"),_=e("@metamask/phishing-controller"),I=e("@metamask/announcement-controller"),B=e("@metamask/network-controller"),N=e("@metamask/gas-fee-controller"),x=e("@metamask/permission-controller"),j=Jt(e("@metamask/smart-transactions-controller")),R=e("@metamask/smart-transactions-controller/dist/types"),O=e("@metamask/selected-network-controller"),D=e("@metamask/logging-controller"),L=e("@metamask/permission-log-controller"),U=e("@metamask/snaps-rpc-methods"),F=e("@metamask/controller-utils"),K=e("@metamask/accounts-controller"),$=e("@metamask/remote-feature-flag-controller"),H=e("@metamask/signature-controller"),z=e("@metamask/scure-bip39/dist/wordlists/english"),q=e("@metamask/name-controller"),G=e("@metamask/queued-request-controller"),V=e("@metamask/user-operation-controller"),W=e("@metamask/bridge-controller"),Y=e("@metamask/transaction-controller"),Q=e("@metamask/snaps-utils"),J=e("@ethersproject/abi"),X=e("@metamask/metamask-eth-abis"),Z=e("@metamask/keyring-api"),ee=e("@metamask/utils"),te=e("@metamask/eth-sig-util"),re=e("@metamask/notification-services-controller/notification-services"),ne=e("@metamask/multichain"),se=e("../../shared/constants/methods-tags"),ie=e("../../shared/constants/transaction"),oe=e("../../shared/constants/swaps"),ae=e("../../shared/constants/network"),le=e("../../shared/constants/smartTransactions"),ce=e("../../shared/constants/hardware-wallets"),ue=e("../../shared/constants/keyring"),de=e("../../shared/constants/permissions"),he=e("../../shared/notifications"),pe=e("../../shared/constants/time"),ge=e("../../shared/constants/app"),fe=e("../../shared/constants/metametrics"),me=e("../../shared/constants/logs"),ye=e("../../shared/lib/storage-helpers"),be=e("../../shared/lib/token-util"),ke=e("../../shared/modules/string-utils"),we=e("../../shared/modules/transaction.utils"),ve=e("../../shared/constants/tokens"),Ce=e("../../shared/lib/metamask-controller-utils"),Te=e("../../shared/modules/mv3.utils"),Se=e("../../shared/modules/network.utils"),Ae=e("../../shared/modules/selectors"),Me=(e("../../shared/modules/caip-stream"),e("../../shared/constants/urls")),Pe=e("../../shared/lib/transactions-controller-utils"),Ee=e("../../shared/modules/selectors/networks"),_e=e("../../shared/lib/trace"),Ie=e("../../development/build/constants"),Be=Jt(e("../../shared/lib/fetch-with-cache")),Ne=e("../../shared/constants/bridge"),xe=e("../../shared/types/bridge-status"),je=e("./lib/transaction/metrics"),Re=e("./lib/snap-keyring/keyring-snaps-permissions"),Oe=e("./lib/SnapsNameProvider"),De=e("./lib/AddressBookPetnamesBridge"),Le=e("./lib/AccountIdentitiesPetnamesBridge"),Ue=e("./lib/ppom/ppom-middleware"),Fe=e("./detect-multiple-instances"),Ke=Jt(e("./lib/ComposableObservableStore")),$e=Jt(e("./controllers/account-tracker-controller")),He=Jt(e("./lib/createDupeReqFilterStream")),ze=Jt(e("./lib/createLoggerMiddleware")),qe=e("./lib/rpc-method-middleware"),Ge=Jt(e("./lib/createOriginMiddleware")),Ve=Jt(e("./lib/createMainFrameOriginMiddleware")),We=Jt(e("./lib/createTabIdMiddleware")),Ye=e("./controllers/network-order"),Qe=e("./controllers/account-order"),Je=Jt(e("./lib/createOnboardingMiddleware")),Xe=e("./lib/stream-utils"),Ze=e("./controllers/preferences-controller"),et=e("./controllers/app-state-controller"),tt=e("./controllers/alert-controller"),rt=Jt(e("./controllers/onboarding")),nt=Jt(e("./lib/backup")),st=Jt(e("./controllers/decrypt-message")),it=Jt(e("./controllers/swaps")),ot=Jt(e("./controllers/metametrics-controller")),at=e("./lib/segment"),lt=Jt(e("./lib/createMetaRPCHandler")),ct=e("./lib/util"),ut=Jt(e("./lib/createMetamaskMiddleware")),dt=e("./lib/hardware-keyring-builder-factory"),ht=Jt(e("./controllers/encryption-public-key")),pt=Jt(e("./controllers/app-metadata")),gt=e("./controllers/permissions"),ft=e("./controllers/metametrics-data-deletion/metametrics-data-deletion"),mt=e("./services/data-deletion-service"),yt=Jt(e("./lib/createRPCMethodTrackingMiddleware")),bt=e("./translate"),kt=e("./lib/offscreen-bridge/trezor-offscreen-bridge"),wt=e("./lib/offscreen-bridge/ledger-offscreen-bridge"),vt=e("./lib/snap-keyring"),Ct=e("./lib/encryptor-factory"),Tt=e("./lib/transaction/util"),St=e("./lib/signature/util"),At=e("./lib/offscreen-bridge/lattice-offscreen-keyring"),Mt=e("./lib/WeakRefObjectMap"),Pt=e("./constants/stream"),Et=e("./lib/tx-verification/tx-verification-middleware"),_t=e("./lib/ppom/ppom-util"),It=Jt(e("./lib/createEvmMethodsToNonEvmAccountReqFilterMiddleware")),Bt=e("./lib/multichain/address"),Nt=e("./lib/transaction/decode/util"),xt=Jt(e("./lib/createTracingMiddleware")),jt=Jt(e("./lib/createOriginThrottlingMiddleware")),Rt=e("./lib/PatchStore"),Ot=e("./lib/state-utils"),Dt=(e("./lib/rpc-method-middleware/handlers/wallet-createSession"),Jt(e("./controllers/bridge-status/bridge-status-controller"))),Lt=e("./controllers/bridge-status/constants"),Ut=e("./lib/approval/utils"),Ft=e("./lib/bridge-status/metrics"),Kt=e("./controller-init/multichain"),$t=e("./controller-init/confirmations/transaction-controller-init"),Ht=e("./controller-init/confirmations/ppom-controller-init"),zt=e("./controller-init/utils"),qt=e("./controller-init/snaps"),Gt=e("./controller-init/identity/authentication-controller-init"),Vt=e("./controller-init/identity/user-storage-controller-init"),Wt=e("./lib/transaction/eip5792"),Yt=e("./controller-init/notifications/notification-services-controller-init"),Qt=e("./controller-init/notifications/notification-services-push-controller-init");function Jt(e){return e&&e.__esModule?e:{default:e}}function Xt(e,t){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.add(e)}function Zt(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}function er(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")}r.METAMASK_CONTROLLER_EVENTS={UPDATE_BADGE:"updateBadge",DECRYPT_MESSAGE_MANAGER_UPDATE_BADGE:"DecryptMessageManager:updateBadge",ENCRYPTION_PUBLIC_KEY_MANAGER_UPDATE_BADGE:"EncryptionPublicKeyManager:updateBadge",APPROVAL_STATE_CHANGE:"ApprovalController:stateChange",APP_STATE_UNLOCK_CHANGE:"AppStateController:unlockChange",QUEUED_REQUEST_STATE_CHANGE:"QueuedRequestController:stateChange",METAMASK_NOTIFICATIONS_LIST_UPDATED:"NotificationServicesController:notificationsListUpdated",METAMASK_NOTIFICATIONS_MARK_AS_READ:"NotificationServicesController:markNotificationsAsRead"};const tr="eip-1193",rr="caip-multichain",nr={[Ie.ENVIRONMENT.DEVELOPMENT]:$.EnvironmentType.Development,[Ie.ENVIRONMENT.RELEASE_CANDIDATE]:$.EnvironmentType.ReleaseCandidate,[Ie.ENVIRONMENT.PRODUCTION]:$.EnvironmentType.Production},sr={flask:$.DistributionType.Flask,main:$.DistributionType.Main,beta:$.DistributionType.Beta};var ir=new WeakSet;class or extends n.default{constructor(e){var t;super(),Xt(this,ir),Zt(this,"_trackSnapExportUsage",(0,d.wrap)((0,d.memoize)((()=>(0,d.throttle)(((e,t,r,n)=>{var s;return this.metaMetricsController.trackEvent({event:fe.MetaMetricsEventName.SnapExportUsed,category:fe.MetaMetricsEventCategory.Snaps,properties:{snap_id:e,export:t,snap_category:null===(s=this._getSnapMetadata(e))||void 0===s?void 0:s.category,success:r,origin:n}})}),60*pe.SECOND)),((e,t,r,n)=>`${e}${t}${n}`)),((e,...t)=>e(...t)(...t)))),Zt(this,"handleWatchAssetRequest",(({asset:e,type:t,origin:r,networkClientId:n})=>{switch(t){case F.ERC20:return this.tokensController.watchAsset({asset:e,type:t,networkClientId:n});case F.ERC721:case F.ERC1155:return this.nftController.watchNft(e,t,r);default:throw new Error(`Asset type ${t} not supported`)}})),Zt(this,"removePermissionsFor",(e=>{try{this.permissionController.revokePermissions(e)}catch(e){if(!(e instanceof x.PermissionsRequestNotFoundError))throw e}})),Zt(this,"updateCaveat",((e,t,r,n)=>{try{this.controllerMessenger.call("PermissionController:updateCaveat",e,t,r,n)}catch(e){if(!(e instanceof x.PermissionsRequestNotFoundError))throw e}})),Zt(this,"updateNetworksList",(e=>{try{this.networkOrderController.updateNetworksList(e)}catch(e){throw y.default.error(e.message),e}})),Zt(this,"updateAccountsList",(e=>{try{this.accountOrderController.updateAccountsList(e)}catch(e){throw y.default.error(e.message),e}})),Zt(this,"updateHiddenAccountsList",(e=>{try{this.accountOrderController.updateHiddenAccountsList(e)}catch(e){throw y.default.error(e.message),e}})),Zt(this,"rejectPermissionsRequest",(e=>{try{this.permissionController.rejectPermissionsRequest(e)}catch(e){if(!(e instanceof x.PermissionsRequestNotFoundError))throw e}})),Zt(this,"acceptPermissionsRequest",(e=>{try{this.permissionController.acceptPermissionsRequest(e)}catch(e){if(!(e instanceof x.PermissionsRequestNotFoundError))throw e}})),Zt(this,"resolvePendingApproval",(async(e,t,r)=>{try{await this.approvalController.accept(e,t,r)}catch(e){if(!(e instanceof M.ApprovalRequestNotFoundError))throw e}})),Zt(this,"rejectPendingApproval",((e,t)=>{try{this.approvalController.reject(e,new f.JsonRpcError(t.code,t.message,t.data))}catch(e){if(!(e instanceof M.ApprovalRequestNotFoundError))throw e}}));const{isFirstMetaMaskControllerSetup:r}=e;this.defaultMaxListeners=20,this.sendUpdate=(0,d.debounce)(this.privateSendUpdate.bind(this),200*pe.MILLISECOND),this.opts=e,this.extension=e.browser,this.platform=e.platform,this.notificationManager=e.notificationManager;const n=e.initState||{},s="12.16.1";this.recordFirstTimeInfo(n),this.featureFlags=e.featureFlags,this.activeControllerConnections=0,this.offscreenPromise=e.offscreenPromise??Promise.resolve(),this.getRequestAccountTabIds=e.getRequestAccountTabIds,this.getOpenMetamaskTabsIds=e.getOpenMetamaskTabsIds,this.initializeChainlist(),this.controllerMessenger=new P.Messenger,this.loggingController=new D.LoggingController({messenger:this.controllerMessenger.getRestricted({name:"LoggingController",allowedActions:[],allowedEvents:[]}),state:n.LoggingController}),this.localStoreApiWrapper=e.persistanceManager,this.currentMigrationVersion=e.currentMigrationVersion,this.store=new Ke.default({state:n,controllerMessenger:this.controllerMessenger,persist:!0}),this.connections={},this.createVaultMutex=new m.Mutex,this.extension.runtime.onInstalled.addListener((e=>{"update"===e.reason&&this.loggingController.add({type:D.LogType.GenericLog,data:{event:me.LOG_EVENT.VERSION_UPDATE,previousVersion:e.previousVersion,version:s}})})),this.appMetadataController=new pt.default({state:n.AppMetadataController,messenger:this.controllerMessenger.getRestricted({name:"AppMetadataController",allowedActions:[],allowedEvents:[]}),currentMigrationVersion:this.currentMigrationVersion,currentAppVersion:s});const o=()=>{this.encryptionPublicKeyController.clearUnapproved(),this.decryptMessageController.clearUnapproved(),this.signatureController.clearUnapproved(),this.approvalController.clear(f.providerErrors.userRejectedRequest())};this.approvalController=new M.ApprovalController({messenger:this.controllerMessenger.getRestricted({name:"ApprovalController"}),showApprovalRequest:e.showUserConfirmation,typesExcludedFromRateLimiting:[F.ApprovalType.PersonalSign,F.ApprovalType.EthSignTypedData,F.ApprovalType.Transaction,F.ApprovalType.WatchAsset,F.ApprovalType.EthGetEncryptionPublicKey,F.ApprovalType.EthDecrypt,ge.SMART_TRANSACTION_CONFIRMATION_TYPES.showSmartTransactionStatusPage]}),this.queuedRequestController=new G.QueuedRequestController({messenger:this.controllerMessenger.getRestricted({name:"QueuedRequestController",allowedActions:["NetworkController:getState","NetworkController:setActiveNetwork","SelectedNetworkController:getNetworkClientIdForDomain"],allowedEvents:["SelectedNetworkController:stateChange"]}),shouldRequestSwitchNetwork:({method:e})=>se.methodsRequiringNetworkSwitch.includes(e),canRequestSwitchNetworkWithoutApproval:({method:e})=>se.methodsThatCanSwitchNetworkWithoutApproval.includes(e),clearPendingConfirmations:o,showApprovalRequest:()=>{this.approvalController.getTotalApprovalCount()>0&&e.showUserConfirmation()}});const a=this.controllerMessenger.getRestricted({name:"NetworkController"});let l=n.NetworkController;if(!l){l=(0,B.getDefaultNetworkControllerState)();const e=l.networkConfigurationsByChainId;let t;e[ae.CHAIN_IDS.MAINNET].name=ae.MAINNET_DISPLAY_NAME,delete e[ae.CHAIN_IDS.GOERLI],delete e[ae.CHAIN_IDS.LINEA_GOERLI],e[ae.CHAIN_IDS.MEGAETH_TESTNET]=(0,d.cloneDeep)(ae.DEFAULT_CUSTOM_TESTNET_MAP[ae.CHAIN_IDS.MEGAETH_TESTNET]),Object.values(e).forEach((e=>{const t=e.rpcEndpoints[0].networkClientId;(0,ee.hasProperty)(F.BlockExplorerUrl,t)&&(e.blockExplorerUrls=[F.BlockExplorerUrl[t]]),e.defaultBlockExplorerUrlIndex=0})),t=e[ae.CHAIN_IDS.MAINNET],l.selectedNetworkClientId=t.rpcEndpoints[t.defaultRpcEndpointIndex].networkClientId}this.networkController=new B.NetworkController({messenger:a,state:l,infuraProjectId:e.infuraProjectId}),this.networkController.initializeProvider(),this.provider=this.networkController.getProviderAndBlockTracker().provider,this.blockTracker=this.networkController.getProviderAndBlockTracker().blockTracker,this.deprecatedNetworkVersions={};const c=this.controllerMessenger.getRestricted({name:"AccountsController",allowedEvents:["SnapController:stateChange","KeyringController:accountRemoved","KeyringController:stateChange","SnapKeyring:accountAssetListUpdated","SnapKeyring:accountBalancesUpdated","SnapKeyring:accountTransactionsUpdated","MultichainNetworkController:networkDidChange"],allowedActions:["KeyringController:getAccounts","KeyringController:getKeyringsByType","KeyringController:getKeyringForAccount"]});this.accountsController=new K.AccountsController({messenger:c,state:n.AccountsController});const u=this.controllerMessenger.getRestricted({name:"PreferencesController",allowedActions:["AccountsController:setSelectedAccount","AccountsController:getSelectedAccount","AccountsController:getAccountByAddress","AccountsController:setAccountName","NetworkController:getState"],allowedEvents:["AccountsController:stateChange"]});this.preferencesController=new Ze.PreferencesController({state:{currentLocale:e.initLangCode??"",...n.PreferencesController},messenger:u});const p=this.controllerMessenger.getRestricted({name:"TokenListController",allowedActions:["NetworkController:getNetworkClientById"],allowedEvents:["NetworkController:stateChange"]});this.tokenListController=new i.TokenListController({chainId:er(ir,this,ur).call(this,{metamask:this.networkController.state}),preventPollingOnNetworkRestart:!er(ir,this,cr).call(this,this.preferencesController.state),messenger:p,state:n.TokenListController});const g=this.controllerMessenger.getRestricted({name:"AssetsContractController",allowedActions:["NetworkController:getNetworkClientById","NetworkController:getNetworkConfigurationByNetworkClientId","NetworkController:getSelectedNetworkClient","NetworkController:getState"],allowedEvents:["PreferencesController:stateChange","NetworkController:networkDidChange"]});this.assetsContractController=new i.AssetsContractController({messenger:g,chainId:er(ir,this,ur).call(this)});const v=this.controllerMessenger.getRestricted({name:"TokensController",allowedActions:["ApprovalController:addRequest","NetworkController:getNetworkClientById","AccountsController:getSelectedAccount","AccountsController:getAccount"],allowedEvents:["NetworkController:networkDidChange","AccountsController:selectedEvmAccountChange","PreferencesController:stateChange","TokenListController:stateChange","NetworkController:stateChange"]});this.tokensController=new i.TokensController({state:n.TokensController,provider:this.provider,messenger:v,chainId:er(ir,this,ur).call(this)});const T=this.controllerMessenger.getRestricted({name:"NftController",allowedEvents:["PreferencesController:stateChange","NetworkController:networkDidChange","AccountsController:selectedEvmAccountChange"],allowedActions:[`${this.approvalController.name}:addRequest`,`${this.networkController.name}:getNetworkClientById`,"AccountsController:getSelectedAccount","AccountsController:getAccount","AssetsContractController:getERC721AssetName","AssetsContractController:getERC721AssetSymbol","AssetsContractController:getERC721TokenURI","AssetsContractController:getERC721OwnerOf","AssetsContractController:getERC1155BalanceOf","AssetsContractController:getERC1155TokenURI"]});this.nftController=new i.NftController({state:n.NftController,messenger:T,chainId:er(ir,this,ur).call(this),onNftAdded:({address:e,symbol:t,tokenId:r,standard:n,source:s})=>this.metaMetricsController.trackEvent({event:fe.MetaMetricsEventName.NftAdded,category:fe.MetaMetricsEventCategory.Wallet,sensitiveProperties:{token_contract_address:e,token_symbol:t,token_id:r,token_standard:n,asset_type:ie.AssetType.NFT,source:s}})});const U=this.controllerMessenger.getRestricted({name:"NftDetectionController",allowedEvents:["NetworkController:stateChange","PreferencesController:stateChange"],allowedActions:["ApprovalController:addRequest","NetworkController:getState","NetworkController:getNetworkClientById","AccountsController:getSelectedAccount"]});this.nftDetectionController=new i.NftDetectionController({messenger:U,chainId:er(ir,this,ur).call(this),getOpenSeaApiKey:()=>this.nftController.openSeaApiKey,getBalancesInSingleCall:this.assetsContractController.getBalancesInSingleCall.bind(this.assetsContractController),addNft:this.nftController.addNft.bind(this.nftController),getNftState:()=>this.nftController.state,disabled:!this.preferencesController.state.useNftDetection});const z=this.controllerMessenger.getRestricted({name:"MetaMetricsController",allowedActions:["PreferencesController:getState","NetworkController:getState","NetworkController:getNetworkClientById"],allowedEvents:["PreferencesController:stateChange","NetworkController:networkDidChange"]});this.metaMetricsController=new ot.default({state:n.MetaMetricsController,messenger:z,segment:at.segment,version:"12.16.1",environment:"production",extension:this.extension,captureException:S.captureException}),this.on("update",(e=>{this.metaMetricsController.handleMetaMaskStateUpdate(e)}));const Q=new mt.DataDeletionService,J=this.controllerMessenger.getRestricted({name:"MetaMetricsDataDeletionController",allowedActions:["MetaMetricsController:getState"],allowedEvents:[]});this.metaMetricsDataDeletionController=new ft.MetaMetricsDataDeletionController({dataDeletionService:Q,messenger:J,state:n.metaMetricsDataDeletionController});const X=this.controllerMessenger.getRestricted({name:"GasFeeController",allowedActions:["NetworkController:getEIP1559Compatibility","NetworkController:getNetworkClientById","NetworkController:getState"],allowedEvents:["NetworkController:stateChange"]}),Z=oe.GAS_API_BASE_URL;this.gasFeeController=new N.GasFeeController({state:n.GasFeeController,interval:1e4,messenger:X,clientId:oe.SWAPS_CLIENT_ID,getProvider:()=>this.networkController.getProviderAndBlockTracker().provider,onNetworkDidChange:e=>{a.subscribe("NetworkController:networkDidChange",(()=>e(this.networkController.state)))},getCurrentNetworkEIP1559Compatibility:this.networkController.getEIP1559Compatibility.bind(this.networkController),getCurrentAccountEIP1559Compatibility:this.getCurrentAccountEIP1559Compatibility.bind(this),legacyAPIEndpoint:`${Z}/networks/<chain_id>/gasPrices`,EIP1559APIEndpoint:`${Z}/networks/<chain_id>/suggestedGasFees`,getCurrentNetworkLegacyGasAPICompatibility:()=>er(ir,this,ur).call(this)===ae.CHAIN_IDS.BSC,getChainId:()=>er(ir,this,ur).call(this)}),this.appStateController=new et.AppStateController({addUnlockListener:this.on.bind(this,"unlock"),isUnlocked:this.isUnlocked.bind(this),state:n.AppStateController,onInactiveTimeout:()=>this.setLocked(),messenger:this.controllerMessenger.getRestricted({name:"AppStateController",allowedActions:[`${this.approvalController.name}:addRequest`,`${this.approvalController.name}:acceptRequest`,"PreferencesController:getState"],allowedEvents:["KeyringController:qrKeyringStateChange","PreferencesController:stateChange"]}),extension:this.extension});const te=this.controllerMessenger.getRestricted({name:"CurrencyRateController",allowedActions:[`${this.networkController.name}:getNetworkClientById`]});this.currencyRateController=new i.CurrencyRateController({includeUsdRate:!0,messenger:te,state:n.CurrencyController});const re=this.currencyRateController.fetchMultiExchangeRate.bind(this.currencyRateController);this.currencyRateController.fetchMultiExchangeRate=(...e)=>this.preferencesController.state.useCurrencyRateCheck?re(...e):{conversionRate:null,usdConversionRate:null};const ne=this.controllerMessenger.getRestricted({name:"TokenBalancesController",allowedActions:["NetworkController:getState","NetworkController:getNetworkClientById","TokensController:getState","PreferencesController:getState","AccountsController:getSelectedAccount"],allowedEvents:["PreferencesController:stateChange","TokensController:stateChange","NetworkController:stateChange"]});this.tokenBalancesController=new i.TokenBalancesController({messenger:ne,state:n.TokenBalancesController,interval:3e4});const ce=this.controllerMessenger.getRestricted({name:"PhishingController"});this.phishingController=new _.PhishingController({messenger:ce,state:n.PhishingController,hotlistRefreshInterval:undefined,stalelistRefreshInterval:undefined});const ue=this.controllerMessenger.getRestricted({name:"AnnouncementController"});this.announcementController=new I.AnnouncementController({messenger:ue,allAnnouncements:he.UI_NOTIFICATIONS,state:n.AnnouncementController});const ye=this.controllerMessenger.getRestricted({name:"NetworkOrderController",allowedEvents:["NetworkController:stateChange"]});this.networkOrderController=new Ye.NetworkOrderController({messenger:ye,state:n.NetworkOrderController});const be=this.controllerMessenger.getRestricted({name:"AccountOrderController"});this.accountOrderController=new Qe.AccountOrderController({messenger:be,state:n.AccountOrderController});const ke=this.controllerMessenger.getRestricted({name:"RatesController"});this.multichainRatesController=new i.RatesController({state:n.MultichainRatesController,messenger:ke,includeUsdRate:!0,fetchMultiExchangeRate:i.fetchMultiExchangeRate});const we=this.controllerMessenger.getRestricted({name:"TokenRatesController",allowedActions:["TokensController:getState","NetworkController:getNetworkClientById","NetworkController:getState","AccountsController:getAccount","AccountsController:getSelectedAccount"],allowedEvents:["NetworkController:stateChange","AccountsController:selectedEvmAccountChange","PreferencesController:stateChange","TokensController:stateChange"]});this.tokenRatesController=new i.TokenRatesController({state:n.TokenRatesController,messenger:we,tokenPricesService:new i.CodefiTokenPricesServiceV2,disabled:!this.preferencesController.state.useCurrencyRateCheck}),this.controllerMessenger.subscribe("PreferencesController:stateChange",(0,ct.previousValueComparator)(((e,t)=>{const{useCurrencyRateCheck:r}=e,{useCurrencyRateCheck:n}=t;n&&!r?this.tokenRatesController.enable():!n&&r&&this.tokenRatesController.disable()}),this.preferencesController.state)),this.ensController=new E.EnsController({messenger:this.controllerMessenger.getRestricted({name:"EnsController",allowedActions:["NetworkController:getNetworkClientById","NetworkController:getState"],allowedEvents:[]}),onNetworkDidChange:a.subscribe.bind(a,"NetworkController:networkDidChange")});const ve=this.controllerMessenger.getRestricted({name:"OnboardingController",allowedActions:[],allowedEvents:[]});this.onboardingController=new rt.default({messenger:ve,state:n.OnboardingController});let Ce=[(0,h.keyringBuilderFactory)(C.MetaMaskKeyring)];const Se=null===(t=this.opts.overrides)||void 0===t?void 0:t.keyrings;if(!1===Te.isManifestV3){const e=[(null==Se?void 0:Se.lattice)||w.default,C.MetaMaskKeyring],t=[{keyring:(null==Se?void 0:Se.trezor)||b.TrezorKeyring,bridge:(null==Se?void 0:Se.trezorBridge)||b.TrezorConnectBridge},{keyring:(null==Se?void 0:Se.oneKey)||b.OneKeyKeyring,bridge:(null==Se?void 0:Se.oneKeyBridge)||b.TrezorConnectBridge},{keyring:(null==Se?void 0:Se.ledger)||k.LedgerKeyring,bridge:(null==Se?void 0:Se.ledgerBridge)||k.LedgerIframeBridge}];Ce=e.map((e=>(0,h.keyringBuilderFactory)(e))),t.forEach((e=>Ce.push((0,dt.hardwareKeyringBuilderFactory)(e.keyring,e.bridge))))}else Ce.push((0,dt.hardwareKeyringBuilderFactory)(b.TrezorKeyring,(null==Se?void 0:Se.trezorBridge)||kt.TrezorOffscreenBridge),(0,dt.hardwareKeyringBuilderFactory)(b.OneKeyKeyring,(null==Se?void 0:Se.oneKey)||kt.TrezorOffscreenBridge),(0,dt.hardwareKeyringBuilderFactory)(k.LedgerKeyring,(null==Se?void 0:Se.ledgerBridge)||wt.LedgerOffscreenBridge),(0,h.keyringBuilderFactory)(At.LatticeKeyringOffscreen));const Me=this.controllerMessenger.getRestricted({name:"SnapKeyring",allowedActions:["ApprovalController:addRequest","ApprovalController:acceptRequest","ApprovalController:rejectRequest","ApprovalController:startFlow","ApprovalController:endFlow","ApprovalController:showSuccess","ApprovalController:showError","PhishingController:test","PhishingController:maybeUpdateState","KeyringController:getAccounts","AccountsController:setSelectedAccount","AccountsController:getAccountByAddress","AccountsController:setAccountName","AccountsController:listMultichainAccounts","SnapController:handleRequest","SnapController:get","PreferencesController:getState"]}),Pe=async()=>{await this.keyringController.persistAllKeyrings(),await this.accountsController.updateAccounts()};Ce.push((0,vt.snapKeyringBuilder)(Me,{persistKeyringHelper:()=>Pe(),removeAccountHelper:e=>this.removeAccount(e),trackEvent:(...e)=>this.metaMetricsController.trackEvent(...e)}));const Ie=this.controllerMessenger.getRestricted({name:"KeyringController"});this.keyringController=new h.KeyringController({cacheEncryptionKey:!0,keyringBuilders:Ce,state:n.KeyringController,encryptor:e.encryptor||(0,Ct.encryptorFactory)(6e5),messenger:Ie}),this.controllerMessenger.subscribe("KeyringController:unlock",(()=>this._onUnlock())),this.controllerMessenger.subscribe("KeyringController:lock",(()=>this._onLock())),this.controllerMessenger.subscribe("KeyringController:stateChange",(e=>{this._onKeyringControllerUpdate(e)})),this.permissionController=new x.PermissionController({messenger:this.controllerMessenger.getRestricted({name:"PermissionController",allowedActions:[`${this.approvalController.name}:addRequest`,`${this.approvalController.name}:hasRequest`,`${this.approvalController.name}:acceptRequest`,`${this.approvalController.name}:rejectRequest`,"SnapController:getPermitted","SnapController:install","SubjectMetadataController:getSubjectMetadata"]}),state:n.PermissionController,caveatSpecifications:(0,gt.getCaveatSpecifications)({listAccounts:this.accountsController.listAccounts.bind(this.accountsController),findNetworkClientIdByChainId:this.networkController.findNetworkClientIdByChainId.bind(this.networkController)}),permissionSpecifications:{...(0,gt.getPermissionSpecifications)(),...this.getSnapPermissionSpecifications()},unrestrictedMethods:gt.unrestrictedMethods}),this.selectedNetworkController=new O.SelectedNetworkController({messenger:this.controllerMessenger.getRestricted({name:"SelectedNetworkController",allowedActions:["NetworkController:getNetworkClientById","NetworkController:getState","NetworkController:getSelectedNetworkClient","PermissionController:hasPermissions","PermissionController:getSubjectNames"],allowedEvents:["NetworkController:stateChange","PermissionController:stateChange"]}),state:n.SelectedNetworkController,useRequestQueuePreference:!0,onPreferencesStateChange:()=>{},domainProxyMap:new Mt.WeakRefObjectMap}),this.permissionLogController=new L.PermissionLogController({messenger:this.controllerMessenger.getRestricted({name:"PermissionLogController"}),restrictedMethods:new Set(Object.keys(de.RestrictedMethods)),state:n.PermissionLogController}),this.subjectMetadataController=new x.SubjectMetadataController({messenger:this.controllerMessenger.getRestricted({name:"SubjectMetadataController",allowedActions:[`${this.permissionController.name}:hasPermissions`]}),state:n.SubjectMetadataController,subjectCacheLimit:100}),this.accountTrackerController=new $e.default({state:{accounts:{}},messenger:this.controllerMessenger.getRestricted({name:"AccountTrackerController",allowedActions:["AccountsController:getSelectedAccount","NetworkController:getState","NetworkController:getNetworkClientById","OnboardingController:getState","PreferencesController:getState"],allowedEvents:["AccountsController:selectedEvmAccountChange","OnboardingController:stateChange","KeyringController:accountRemoved"]}),provider:this.provider,blockTracker:this.blockTracker,getNetworkIdentifier:e=>{const{type:t,rpcUrl:r}=e??(0,Ee.getProviderConfig)({metamask:this.networkController.state});return t===ae.NETWORK_TYPES.RPC?r:t}}),this.on("controllerConnectionChanged",(e=>{const{completedOnboarding:t}=this.onboardingController.state;e>0&&t?this.triggerNetworkrequests():this.stopNetworkRequests()})),this.controllerMessenger.subscribe(`${this.onboardingController.name}:stateChange`,(0,ct.previousValueComparator)((async(e,t)=>{const{completedOnboarding:r}=e,{completedOnboarding:n}=t;if(!r&&n){const{address:e}=this.accountsController.getSelectedAccount();await this._addAccountsWithBalance(),this.postOnboardingInitialization(),this.triggerNetworkrequests(),await this.tokenDetectionController.detectTokens({selectedAddress:e})}}),this.onboardingController.state));const xe=this.controllerMessenger.getRestricted({name:"TokenDetectionController",allowedActions:["AccountsController:getAccount","AccountsController:getSelectedAccount","KeyringController:getState","NetworkController:getNetworkClientById","NetworkController:getNetworkConfigurationByNetworkClientId","NetworkController:getState","PreferencesController:getState","TokenListController:getState","TokensController:getState","TokensController:addDetectedTokens"],allowedEvents:["AccountsController:selectedEvmAccountChange","KeyringController:lock","KeyringController:unlock","NetworkController:networkDidChange","PreferencesController:stateChange","TokenListController:stateChange"]});this.tokenDetectionController=new i.TokenDetectionController({messenger:xe,getBalancesInSingleCall:this.assetsContractController.getBalancesInSingleCall.bind(this.assetsContractController),trackMetaMetricsEvent:this.metaMetricsController.trackEvent.bind(this.metaMetricsController),useAccountsAPI:!0,platform:"extension"});const je=this.controllerMessenger.getRestricted({name:"AddressBookController",allowedActions:[],allowedEvents:[]});this.addressBookController=new A.AddressBookController({messenger:je,state:n.AddressBookController}),this.alertController=new tt.AlertController({state:n.AlertController,messenger:this.controllerMessenger.getRestricted({name:"AlertController",allowedEvents:["AccountsController:selectedAccountChange"],allowedActions:["AccountsController:getSelectedAccount"]})}),this.backup=new nt.default({preferencesController:this.preferencesController,addressBookController:this.addressBookController,accountsController:this.accountsController,networkController:this.networkController,trackMetaMetricsEvent:this.metaMetricsController.trackEvent.bind(this.metaMetricsController)}),this.snapAndHardwareMetricsParams={getSelectedAccount:this.accountsController.getSelectedAccount.bind(this.accountsController),getAccountType:this.getAccountType.bind(this),getDeviceModel:this.getDeviceModel.bind(this),getHardwareTypeForMetric:this.getHardwareTypeForMetric.bind(this),snapAndHardwareMessenger:this.controllerMessenger.getRestricted({name:"SnapAndHardwareMessenger",allowedActions:["KeyringController:getKeyringForAccount","SnapController:get","AccountsController:getSelectedAccount"]})},this._addBridgeStatusControllerListeners(),this.decryptMessageController=new st.default({getState:this.getState.bind(this),messenger:this.controllerMessenger.getRestricted({name:"DecryptMessageController",allowedActions:[`${this.approvalController.name}:addRequest`,`${this.approvalController.name}:acceptRequest`,`${this.approvalController.name}:rejectRequest`,`${this.keyringController.name}:decryptMessage`],allowedEvents:["DecryptMessageManager:stateChange","DecryptMessageManager:unapprovedMessage"]}),managerMessenger:this.controllerMessenger.getRestricted({name:"DecryptMessageManager"}),metricsEvent:this.metaMetricsController.trackEvent.bind(this.metaMetricsController)}),this.encryptionPublicKeyController=new ht.default({messenger:this.controllerMessenger.getRestricted({name:"EncryptionPublicKeyController",allowedActions:[`${this.approvalController.name}:addRequest`,`${this.approvalController.name}:acceptRequest`,`${this.approvalController.name}:rejectRequest`],allowedEvents:["EncryptionPublicKeyManager:stateChange","EncryptionPublicKeyManager:unapprovedMessage"]}),managerMessenger:this.controllerMessenger.getRestricted({name:"EncryptionPublicKeyManager"}),getEncryptionPublicKey:this.keyringController.getEncryptionPublicKey.bind(this.keyringController),getAccountKeyringType:this.keyringController.getAccountKeyringType.bind(this.keyringController),getState:this.getState.bind(this),metricsEvent:this.metaMetricsController.trackEvent.bind(this.metaMetricsController)}),this.signatureController=new H.SignatureController({messenger:this.controllerMessenger.getRestricted({name:"SignatureController",allowedActions:[`${this.accountsController.name}:getState`,`${this.approvalController.name}:addRequest`,`${this.keyringController.name}:signMessage`,`${this.keyringController.name}:signPersonalMessage`,`${this.keyringController.name}:signTypedMessage`,`${this.loggingController.name}:add`,`${this.networkController.name}:getNetworkClientById`]}),trace:_e.trace,decodingApiUrl:"https://signature-insights.api.cx.metamask.io/v1",isDecodeSignatureRequestEnabled:()=>this.preferencesController.state.useTransactionSimulations}),this.signatureController.hub.on("cancelWithReason",(({metadata:e,reason:t})=>{this.metaMetricsController.trackEvent({event:t,category:fe.MetaMetricsEventCategory.Transactions,properties:{action:"Sign Request",type:e.type}})}));const Re=this.controllerMessenger.getRestricted({name:"SwapsController",allowedActions:["NetworkController:getState","NetworkController:getNetworkClientById","TokenRatesController:getState"],allowedEvents:[]});this.swapsController=new it.default({messenger:Re,getBufferedGasLimit:async(e,t)=>{const{gas:r,simulationFails:n}=await this.txController.estimateGasBuffered(e.txParams,t,er(ir,this,pr).call(this));return{gasLimit:r,simulationFails:n}},getEIP1559GasFeeEstimates:this.gasFeeController.fetchGasFeeEstimates.bind(this.gasFeeController),getLayer1GasFee:(...e)=>this.txController.getLayer1GasFee(...e),trackMetaMetricsEvent:this.metaMetricsController.trackEvent.bind(this.metaMetricsController)},n.SwapsController);const Ue=this.controllerMessenger.getRestricted({name:W.BRIDGE_CONTROLLER_NAME,allowedActions:["AccountsController:getSelectedMultichainAccount","SnapController:handleRequest","NetworkController:getState","NetworkController:getNetworkClientById","NetworkController:findNetworkClientIdByChainId"],allowedEvents:[]});this.bridgeController=new W.BridgeController({messenger:Ue,clientId:W.BridgeClientId.EXTENSION,getLayer1GasFee:(...e)=>this.txController.getLayer1GasFee(...e),fetchFn:async(e,{headers:t,signal:r,...n})=>await(0,Be.default)({url:e,fetchOptions:{method:"GET",headers:t,signal:r},...n}),config:{customBridgeApiBaseUrl:Ne.BRIDGE_API_BASE_URL}});const He=this.controllerMessenger.getRestricted({name:Lt.BRIDGE_STATUS_CONTROLLER_NAME,allowedActions:["AccountsController:getSelectedMultichainAccount","NetworkController:getNetworkClientById","NetworkController:findNetworkClientIdByChainId","NetworkController:getState","TransactionController:getState"],allowedEvents:[]});this.bridgeStatusController=new Dt.default({messenger:He,state:n.BridgeStatusController});const ze=this.controllerMessenger.getRestricted({name:"SmartTransactionsController",allowedActions:["NetworkController:getNetworkClientById","NetworkController:getState"],allowedEvents:["NetworkController:stateChange"]});this.smartTransactionsController=new j.default({supportedChainIds:(0,le.getAllowedSmartTransactionsChainIds)(),clientId:R.ClientId.Extension,getNonceLock:e=>this.txController.getNonceLock(e,er(ir,this,pr).call(this)),confirmExternalTransaction:(...e)=>this.txController.confirmExternalTransaction(...e),trackMetaMetricsEvent:this.metaMetricsController.trackEvent.bind(this.metaMetricsController),state:n.SmartTransactionsController,messenger:ze,getTransactions:(...e)=>this.txController.getTransactions(...e),updateTransaction:(...e)=>this.txController.updateTransaction(...e),getFeatureFlags:()=>{const e=this._getMetaMaskState();return(0,Ae.getFeatureFlagsByChainId)(e)},getMetaMetricsProps:async()=>{const e=this.accountsController.getSelectedAccount().address;return{accountHardwareType:await this.getHardwareTypeForMetric(e),accountType:await this.getAccountType(e),deviceModel:await this.getDeviceModel(e)}}});const qe=()=>this.preferencesController.state.useExternalNameSources;this.nameController=new q.NameController({messenger:this.controllerMessenger.getRestricted({name:"NameController",allowedActions:[]}),providers:[new q.ENSNameProvider({reverseLookup:this.ensController.reverseResolveAddress.bind(this.ensController)}),new q.EtherscanNameProvider({isEnabled:qe}),new q.TokenNameProvider({isEnabled:qe}),new q.LensNameProvider({isEnabled:qe}),new Oe.SnapsNameProvider({messenger:this.controllerMessenger.getRestricted({name:"SnapsNameProvider",allowedActions:["SnapController:getAll","SnapController:get","SnapController:handleRequest","PermissionController:getState"]})})],state:n.NameController});const Ge=this.controllerMessenger.getRestricted({name:"PetnamesBridge",allowedEvents:["NameController:stateChange","AccountsController:stateChange","AddressBookController:stateChange"],allowedActions:["AccountsController:listAccounts"]});new De.AddressBookPetnamesBridge({addressBookController:this.addressBookController,nameController:this.nameController,messenger:Ge}).init(),new Le.AccountIdentitiesPetnamesBridge({nameController:this.nameController,messenger:Ge}).init(),this.userOperationController=new V.UserOperationController({entrypoint:null,getGasFeeEstimates:this.gasFeeController.fetchGasFeeEstimates.bind(this.gasFeeController),messenger:this.controllerMessenger.getRestricted({name:"UserOperationController",allowedActions:["ApprovalController:addRequest","NetworkController:getNetworkClientById","KeyringController:prepareUserOperation","KeyringController:patchUserOperation","KeyringController:signUserOperation"]}),state:n.UserOperationController}),this.userOperationController.hub.on("user-operation-added",this._onUserOperationAdded.bind(this)),this.userOperationController.hub.on("transaction-updated",this._onUserOperationTransactionUpdated.bind(this)),a.subscribe("NetworkController:networkDidChange",(()=>{this.accountTrackerController.updateAccounts()})),a.subscribe("NetworkController:networkWillChange",o.bind(this)),this.controllerMessenger.subscribe("PreferencesController:stateChange",(0,ct.previousValueComparator)(((e,t)=>{const{useExternalServices:r}=e,{useExternalServices:n}=t;n&&!r?(this.remoteFeatureFlagController.enable(),this.remoteFeatureFlagController.updateRemoteFeatureFlags()):!n&&r&&this.remoteFeatureFlagController.disable()}),this.preferencesController.state)),this.remoteFeatureFlagController=new $.RemoteFeatureFlagController({messenger:this.controllerMessenger.getRestricted({name:"RemoteFeatureFlagController",allowedActions:[],allowedEvents:[]}),fetchInterval:9e5,disabled:!this.preferencesController.state.useExternalServices,getMetaMetricsId:()=>this.metaMetricsController.getMetaMetricsId(),clientConfigApiService:new $.ClientConfigApiService({fetch:globalThis.fetch.bind(globalThis),config:{client:$.ClientType.Extension,distribution:this._getConfigForRemoteFeatureFlagRequest().distribution,environment:this._getConfigForRemoteFeatureFlagRequest().environment}})});const Ve=[this.networkController,this.preferencesController,this.gasFeeController,this.onboardingController,this.keyringController,this.smartTransactionsController],We={ExecutionService:qt.ExecutionServiceInit,RateLimitController:qt.RateLimitControllerInit,SnapsRegistry:qt.SnapsRegistryInit,SnapController:qt.SnapControllerInit,SnapInsightsController:qt.SnapInsightsControllerInit,SnapInterfaceController:qt.SnapInterfaceControllerInit,CronjobController:qt.CronjobControllerInit,PPOMController:Ht.PPOMControllerInit,TransactionController:$t.TransactionControllerInit,MultichainNetworkController:Kt.MultichainNetworkControllerInit,AuthenticationController:Gt.AuthenticationControllerInit,UserStorageController:Vt.UserStorageControllerInit,NotificationServicesController:Yt.NotificationServicesControllerInit,NotificationServicesPushController:Qt.NotificationServicesPushControllerInit},{controllerApi:Je,controllerMemState:Xe,controllerPersistedState:lt,controllersByName:yt}=er(ir,this,gr).call(this,{existingControllers:Ve,initFunctions:We,initState:n});this.controllerApi=Je,this.controllerMemState=Xe,this.controllerPersistedState=lt,this.controllersByName=yt,this.cronjobController=yt.CronjobController,this.rateLimitController=yt.RateLimitController,this.snapController=yt.SnapController,this.snapInsightsController=yt.SnapInsightsController,this.snapInterfaceController=yt.SnapInterfaceController,this.snapsRegistry=yt.SnapsRegistry,this.ppomController=yt.PPOMController,this.txController=yt.TransactionController,this.multichainNetworkController=yt.MultichainNetworkController,this.authenticationController=yt.AuthenticationController,this.userStorageController=yt.UserStorageController,this.notificationServicesController=yt.NotificationServicesController,this.notificationServicesPushController=yt.NotificationServicesPushController,this.notificationServicesController.init(),this.controllerMessenger.subscribe("TransactionController:transactionStatusUpdated",(({transactionMeta:e})=>{this._onFinishedTransaction(e)})),this.controllerMessenger.subscribe("NotificationServicesPushController:onNewNotifications",(e=>{this.metaMetricsController.trackEvent({category:fe.MetaMetricsEventCategory.PushNotifications,event:fe.MetaMetricsEventName.PushNotificationReceived,properties:{notification_id:e.id,notification_type:e.type,chain_id:null==e?void 0:e.chain_id}})})),this.controllerMessenger.subscribe("NotificationServicesPushController:pushNotificationClicked",(e=>{this.metaMetricsController.trackEvent({category:fe.MetaMetricsEventCategory.PushNotifications,event:fe.MetaMetricsEventName.PushNotificationClicked,properties:{notification_id:e.id,notification_type:e.type,chain_id:null==e?void 0:e.chain_id}})})),this.metamaskMiddleware=(0,ut.default)({static:{eth_syncing:!1,web3_clientVersion:`MetaMask/v${s}`},version:s,getAccounts:({origin:e})=>{if(e===ge.ORIGIN_METAMASK){const e=this.accountsController.getSelectedAccount().address;return e?[e]:[]}return this.isUnlocked()?this.getPermittedAccounts(e):[]},processTransaction:(e,t)=>(0,Tt.addDappTransaction)(this.getAddTransactionRequest({transactionParams:e,dappRequest:t})),processTypedMessage:(...e)=>(0,St.addTypedMessage)({signatureController:this.signatureController,signatureParams:e}),processTypedMessageV3:(...e)=>(0,St.addTypedMessage)({signatureController:this.signatureController,signatureParams:e}),processTypedMessageV4:(...e)=>(0,St.addTypedMessage)({signatureController:this.signatureController,signatureParams:e}),processPersonalMessage:(...e)=>(0,St.addPersonalMessage)({signatureController:this.signatureController,signatureParams:e}),processEncryptionPublicKey:this.encryptionPublicKeyController.newRequestEncryptionPublicKey.bind(this.encryptionPublicKeyController),processDecryptMessage:this.decryptMessageController.newRequestDecryptMessage.bind(this.decryptMessageController),getPendingNonce:this.getPendingNonce.bind(this),getPendingTransactionByHash:e=>this.txController.state.transactions.find((t=>t.hash===e&&t.status===Y.TransactionStatus.submitted)),processSendCalls:Wt.processSendCalls.bind(null,{addTransactionBatch:this.txController.addTransactionBatch.bind(this.txController),getDisabledAccountUpgradeChains:this.preferencesController.getDisabledAccountUpgradeChains.bind(this.preferencesController),isAtomicBatchSupported:this.txController.isAtomicBatchSupported.bind(this.txController),validateSecurity:(e,t,r)=>(0,_t.validateRequestWithPPOM)({chainId:r,ppomController:this.ppomController,request:t,securityAlertId:e,updateSecurityAlertResponse:this.updateSecurityAlertResponse.bind(this)})},this.controllerMessenger),getCallsStatus:Wt.getCallsStatus.bind(null,this.controllerMessenger),getCapabilities:Wt.getCapabilities.bind(null,{getDisabledAccountUpgradeChains:this.preferencesController.getDisabledAccountUpgradeChains.bind(this.preferencesController),isAtomicBatchSupported:this.txController.isAtomicBatchSupported.bind(this.txController)})}),this.on("update",(e=>this._onStateUpdate(e)));const bt={AccountTracker:this.accountTrackerController,TokenRatesController:this.tokenRatesController,DecryptMessageController:this.decryptMessageController,EncryptionPublicKeyController:this.encryptionPublicKeyController,SignatureController:this.signatureController,SwapsController:this.swapsController,BridgeController:this.bridgeController,BridgeStatusController:this.bridgeStatusController,EnsController:this.ensController,ApprovalController:this.approvalController};this.store.updateStructure({AccountsController:this.accountsController,AppStateController:this.appStateController,AppMetadataController:this.appMetadataController,KeyringController:this.keyringController,PreferencesController:this.preferencesController,MetaMetricsController:this.metaMetricsController,MetaMetricsDataDeletionController:this.metaMetricsDataDeletionController,AddressBookController:this.addressBookController,CurrencyController:this.currencyRateController,MultichainNetworkController:this.multichainNetworkController,NetworkController:this.networkController,AlertController:this.alertController,OnboardingController:this.onboardingController,PermissionController:this.permissionController,PermissionLogController:this.permissionLogController,SubjectMetadataController:this.subjectMetadataController,AnnouncementController:this.announcementController,NetworkOrderController:this.networkOrderController,AccountOrderController:this.accountOrderController,GasFeeController:this.gasFeeController,TokenListController:this.tokenListController,TokensController:this.tokensController,TokenBalancesController:this.tokenBalancesController,SmartTransactionsController:this.smartTransactionsController,NftController:this.nftController,PhishingController:this.phishingController,SelectedNetworkController:this.selectedNetworkController,LoggingController:this.loggingController,MultichainRatesController:this.multichainRatesController,NameController:this.nameController,UserOperationController:this.userOperationController,AuthenticationController:this.authenticationController,UserStorageController:this.userStorageController,NotificationServicesController:this.notificationServicesController,NotificationServicesPushController:this.notificationServicesPushController,RemoteFeatureFlagController:this.remoteFeatureFlagController,...bt,...lt}),this.memStore=new Ke.default({config:{AccountsController:this.accountsController,AppStateController:this.appStateController,AppMetadataController:this.appMetadataController,MultichainNetworkController:this.multichainNetworkController,NetworkController:this.networkController,KeyringController:this.keyringController,PreferencesController:this.preferencesController,MetaMetricsController:this.metaMetricsController,MetaMetricsDataDeletionController:this.metaMetricsDataDeletionController,AddressBookController:this.addressBookController,CurrencyController:this.currencyRateController,AlertController:this.alertController,OnboardingController:this.onboardingController,PermissionController:this.permissionController,PermissionLogController:this.permissionLogController,SubjectMetadataController:this.subjectMetadataController,AnnouncementController:this.announcementController,NetworkOrderController:this.networkOrderController,AccountOrderController:this.accountOrderController,GasFeeController:this.gasFeeController,TokenListController:this.tokenListController,TokensController:this.tokensController,TokenBalancesController:this.tokenBalancesController,SmartTransactionsController:this.smartTransactionsController,NftController:this.nftController,SelectedNetworkController:this.selectedNetworkController,LoggingController:this.loggingController,MultichainRatesController:this.multichainRatesController,SnapController:this.snapController,CronjobController:this.cronjobController,SnapsRegistry:this.snapsRegistry,SnapInterfaceController:this.snapInterfaceController,SnapInsightsController:this.snapInsightsController,NameController:this.nameController,UserOperationController:this.userOperationController,AuthenticationController:this.authenticationController,UserStorageController:this.userStorageController,NotificationServicesController:this.notificationServicesController,QueuedRequestController:this.queuedRequestController,NotificationServicesPushController:this.notificationServicesPushController,RemoteFeatureFlagController:this.remoteFeatureFlagController,...bt,...Xe},controllerMessenger:this.controllerMessenger});const Pt=[this.accountTrackerController.resetState.bind(this.accountTrackerController),this.decryptMessageController.resetState.bind(this.decryptMessageController),this.encryptionPublicKeyController.resetState.bind(this.encryptionPublicKeyController),this.signatureController.resetState.bind(this.signatureController),this.swapsController.resetState.bind(this.swapsController),this.bridgeController.resetState.bind(this.bridgeController),this.ensController.resetState.bind(this.ensController),this.approvalController.clear.bind(this.approvalController)];Te.isManifestV3?!0===r&&(this.resetStates(Pt),this.extension.storage.session.set({isFirstMetaMaskControllerSetup:!1})):this.resetStates(Pt);!this.isUnlocked()&&this.onboardingController.state.completedOnboarding,this._startUISync(),this.extension.runtime.getPlatformInfo().then((({os:e})=>{this.appStateController.setBrowserEnvironment(e,this.extension.runtime.getBrowserInfo===undefined?"chrome":"firefox")})),this.setupControllerEventSubscriptions(),this.setupMultichainDataAndSubscriptions(),this.publicConfigStore=this.createPublicConfigStore(),this.extension.runtime.onMessageExternal.addListener(Fe.onMessageReceived),(0,Fe.checkForMultipleVersionsRunning)(),this.onboardingController.state.completedOnboarding&&this.postOnboardingInitialization()}getInfuraFeatureFlags(){(0,Be.default)({url:"https://swap.api.cx.metamask.io/featureFlags",cacheRefreshTime:20*pe.MINUTE}).then(this.onFeatureFlagResponseReceived).catch((e=>{y.default.warn("Feature flag endpoint is unreachable",e)}))}onFeatureFlagResponseReceived(e){const{multiChainAssets:t={}}=e,{pollInterval:r}=t;r>0&&this.tokenBalancesController.setIntervalLength(r*pe.SECOND)}postOnboardingInitialization(){const{usePhishDetect:e}=this.preferencesController.state;this.networkController.lookupNetwork(),e&&this.phishingController.maybeUpdateState()}triggerNetworkrequests(){er(ir,this,hr).call(this),this.tokenDetectionController.enable(),this.getInfuraFeatureFlags()}stopNetworkRequests(){this.txController.stopIncomingTransactionPolling(),this.tokenDetectionController.disable()}resetStates(e){e.forEach((e=>{try{e()}catch(e){console.error(e)}}))}async getSnapKeyring(){let[e]=this.keyringController.getKeyringsByType(ue.KeyringType.snap);return e||(await this.keyringController.addNewKeyring(ue.KeyringType.snap),[e]=this.keyringController.getKeyringsByType(ue.KeyringType.snap)),e}trackInsightSnapView(e){this.metaMetricsController.trackEvent({event:fe.MetaMetricsEventName.InsightSnapViewed,category:fe.MetaMetricsEventCategory.Snaps,properties:{snap_id:e}})}_getSnapMetadata(e){var t;return null===(t=this.snapsRegistry.state.database)||void 0===t||null===(t=t.verifiedSnaps)||void 0===t||null===(t=t[e])||void 0===t?void 0:t.metadata}async handleSnapRequest(e){try{const t=await this.controllerMessenger.call("SnapController:handleRequest",e);return this._trackSnapExportUsage(e.snapId,e.handler,!0,e.origin),t}catch(t){throw this._trackSnapExportUsage(e.snapId,e.handler,!1,e.origin),t}}getLocale(){const{currentLocale:e}=this.preferencesController.state;return e}getPreferences(){const{preferences:e,securityAlertsEnabled:t,useCurrencyRateCheck:r,useTransactionSimulations:n,useTokenDetection:s,useMultiAccountBalanceChecker:i,openSeaEnabled:o,useNftDetection:a}=this.preferencesController.state;return{privacyMode:e.privacyMode,securityAlertsEnabled:t,useCurrencyRateCheck:r,useTransactionSimulations:n,useTokenDetection:s,useMultiAccountBalanceChecker:i,openSeaEnabled:o,useNftDetection:a}}getSnapPermissionSpecifications(){return{...(0,U.buildSnapEndowmentSpecifications)(Object.keys(de.ExcludedSnapEndowments)),...(0,U.buildSnapRestrictedMethodSpecifications)(Object.keys(de.ExcludedSnapPermissions),{getPreferences:()=>{const e=this.getLocale(),t=this.currencyRateController.state.currentCurrency,{privacyMode:r,securityAlertsEnabled:n,useCurrencyRateCheck:s,useTransactionSimulations:i,useTokenDetection:o,useMultiAccountBalanceChecker:a,openSeaEnabled:l,useNftDetection:c}=this.getPreferences();return{locale:e,currency:t,hideBalances:r,useSecurityAlerts:n,useExternalPricingData:s,simulateOnChainActions:i,useTokenDetection:o,batchCheckBalances:a,displayNftMedia:l,useNftDetection:c}},clearSnapState:this.controllerMessenger.call.bind(this.controllerMessenger,"SnapController:clearSnapState"),getMnemonic:async e=>{if(!e)return this.getPrimaryKeyringMnemonic();try{const{type:t,mnemonic:r}=await this.controllerMessenger.call("KeyringController:withKeyring",{id:e},(async({keyring:e})=>({type:e.type,mnemonic:e.mnemonic})));if(t!==h.KeyringTypes.hd||!r)throw new Error(`Entropy source with ID "${e}" not found.`);return r}catch{throw new Error(`Entropy source with ID "${e}" not found.`)}},getMnemonicSeed:async e=>{if(!e)return this.getPrimaryKeyringMnemonicSeed();try{const{type:t,seed:r}=await this.controllerMessenger.call("KeyringController:withKeyring",{id:e},(async({keyring:e})=>({type:e.type,seed:e.seed})));if(t!==h.KeyringTypes.hd||!r)throw new Error(`Entropy source with ID "${e}" not found.`);return r}catch{throw new Error(`Entropy source with ID "${e}" not found.`)}},getUnlockPromise:this.appStateController.getUnlockPromise.bind(this.appStateController),getSnap:this.controllerMessenger.call.bind(this.controllerMessenger,"SnapController:get"),handleSnapRpcRequest:this.handleSnapRequest.bind(this),getSnapState:this.controllerMessenger.call.bind(this.controllerMessenger,"SnapController:getSnapState"),requestUserApproval:this.approvalController.addAndShowApprovalRequest.bind(this.approvalController),showNativeNotification:(e,t)=>this.controllerMessenger.call("RateLimitController:call",e,"showNativeNotification",e,t.message),showInAppNotification:(e,t)=>{const{message:r,title:n,footerLink:s}=t,i={interfaceId:t.content,message:r,title:n,footerLink:s};return this.controllerMessenger.call("RateLimitController:call",e,"showInAppNotification",e,i)},updateSnapState:this.controllerMessenger.call.bind(this.controllerMessenger,"SnapController:updateSnapState"),maybeUpdatePhishingList:()=>{const{usePhishDetect:e}=this.preferencesController.state;e&&this.controllerMessenger.call("PhishingController:maybeUpdateState")},isOnPhishingList:e=>{const{usePhishDetect:t}=this.preferencesController.state;return!!t&&this.controllerMessenger.call("PhishingController:testOrigin",e).result},createInterface:this.controllerMessenger.call.bind(this.controllerMessenger,"SnapInterfaceController:createInterface"),getInterface:this.controllerMessenger.call.bind(this.controllerMessenger,"SnapInterfaceController:getInterface"),getClientCryptography:()=>({}),getSnapKeyring:this.getSnapKeyring.bind(this)})}}setupControllerEventSubscriptions(){let e;this.controllerMessenger.subscribe("PreferencesController:stateChange",(0,ct.previousValueComparator)((async(e,t)=>{const{currentLocale:r}=t;er(ir,this,hr).call(this),await(0,bt.updateCurrentLocale)(r),er(ir,this,lr).call(this,t,e)}),this.preferencesController.state)),this.controllerMessenger.subscribe(`${this.accountsController.name}:selectedAccountChange`,(async t=>{t.address&&t.address!==e&&(e=t.address,await this._onAccountChange(t.address))})),this.controllerMessenger.subscribe(`${this.permissionController.name}:stateChange`,(async(e,t)=>{const r=(0,gt.diffMap)(e,t);for(const[e,t]of r.entries())this._notifyAccountsChange(e,t)}),gt.getPermittedAccountsByOrigin),this.controllerMessenger.subscribe(`${this.permissionController.name}:stateChange`,(async(e,t)=>{const r=(0,gt.diffMap)(e,t);for(const[e,t]of r.entries()){const r=this.selectedNetworkController.getNetworkClientIdForDomain(e),{chainId:n}=this.networkController.getNetworkConfigurationByNetworkClientId(r);if(t.length>0&&!t.includes(n)){const r=this.networkController.findNetworkClientIdByChainId(t[0]);this.networkController.setActiveNetwork(r),this.selectedNetworkController.setNetworkClientIdForDomain(e,r)}}}),gt.getPermittedChainsByOrigin),this.controllerMessenger.subscribe("NetworkController:networkRemoved",(({chainId:e})=>{const t=(0,ee.toCaipChainId)("eip155",(0,ee.hexToBigInt)(e).toString(10));this.removeAllScopePermissions(t)})),this.controllerMessenger.subscribe("NetworkController:networkDidChange",(async()=>{er(ir,this,dr).call(this).filter((e=>this.preferencesController.state.incomingTransactionsPreferences[e])).length>0&&(this.txController.stopIncomingTransactionPolling(),await this.txController.updateIncomingTransactions(),this.txController.startIncomingTransactionPolling())})),this.controllerMessenger.subscribe(`${this.snapController.name}:snapInstallStarted`,((e,t,r)=>{var n;const s=null===(n=this._getSnapMetadata(e))||void 0===n?void 0:n.category;this.metaMetricsController.trackEvent({event:r?fe.MetaMetricsEventName.SnapUpdateStarted:fe.MetaMetricsEventName.SnapInstallStarted,category:fe.MetaMetricsEventCategory.Snaps,properties:{snap_id:e,origin:t,snap_category:s}})})),this.controllerMessenger.subscribe(`${this.snapController.name}:snapInstallFailed`,((e,t,r,n)=>{var s;const i=n.includes("User rejected the request."),o=r?fe.MetaMetricsEventName.SnapUpdateFailed:fe.MetaMetricsEventName.SnapInstallFailed,a=r?fe.MetaMetricsEventName.SnapUpdateRejected:fe.MetaMetricsEventName.SnapInstallRejected,l=null===(s=this._getSnapMetadata(e))||void 0===s?void 0:s.category;this.metaMetricsController.trackEvent({event:i?a:o,category:fe.MetaMetricsEventCategory.Snaps,properties:{snap_id:e,origin:t,snap_category:l}})})),this.controllerMessenger.subscribe(`${this.snapController.name}:snapInstalled`,((e,t,r)=>{var n;if(r)return;const s=e.id,i=null===(n=this._getSnapMetadata(s))||void 0===n?void 0:n.category;this.metaMetricsController.trackEvent({event:fe.MetaMetricsEventName.SnapInstalled,category:fe.MetaMetricsEventCategory.Snaps,properties:{snap_id:s,version:e.version,origin:t,snap_category:i}})})),this.controllerMessenger.subscribe(`${this.snapController.name}:snapUpdated`,((e,t,r,n)=>{var s;if(n)return;const i=e.id,o=null===(s=this._getSnapMetadata(i))||void 0===s?void 0:s.category;this.metaMetricsController.trackEvent({event:fe.MetaMetricsEventName.SnapUpdated,category:fe.MetaMetricsEventCategory.Snaps,properties:{snap_id:i,old_version:t,new_version:e.version,origin:r,snap_category:o}})})),this.controllerMessenger.subscribe(`${this.snapController.name}:snapTerminated`,(e=>{const t=Object.values(this.approvalController.state.pendingApprovals).filter((t=>t.origin===e.id&&t.type.startsWith(de.RestrictedMethods.snap_dialog)));for(const e of t)this.approvalController.reject(e.id,new Error("Snap was terminated."))})),this.controllerMessenger.subscribe(`${this.snapController.name}:snapUninstalled`,(e=>{var t;const r=this.notificationServicesController.getNotificationsByType(re.TRIGGER_TYPES.SNAP).filter((t=>t.data.origin===e.id)).map((e=>e.id));this.notificationServicesController.deleteNotificationsById(r);const n=e.id,s=null===(t=this._getSnapMetadata(n))||void 0===t?void 0:t.category;this.metaMetricsController.trackEvent({event:fe.MetaMetricsEventName.SnapUninstalled,category:fe.MetaMetricsEventCategory.Snaps,properties:{snap_id:n,version:e.version,snap_category:s}})}))}setupMultichainDataAndSubscriptions(){(0,Z.isEvmAccountType)(this.accountsController.getSelectedMultichainAccount().type)||this.multichainRatesController.start(),this.controllerMessenger.subscribe("AccountsController:selectedAccountChange",(e=>{(0,Z.isEvmAccountType)(e.type)?this.multichainRatesController.stop():this.multichainRatesController.start()})),this.controllerMessenger.subscribe("CurrencyRateController:stateChange",(({currentCurrency:e})=>{e!==this.multichainRatesController.state.fiatCurrency&&this.multichainRatesController.setFiatCurrency(e)}))}addMultichainApiEthSubscriptionMiddleware({scope:e,origin:t,tabId:r}){const n=this.multichainSubscriptionManager.subscribe({scope:e,origin:t,tabId:r});this.multichainMiddlewareManager.addMiddleware({scope:e,origin:t,tabId:r,middleware:n.middleware})}removeMultichainApiEthSubscriptionMiddleware({scope:e,origin:t}){this.multichainMiddlewareManager.removeMiddlewareByScopeAndOrigin(e,t),this.multichainSubscriptionManager.unsubscribeByScopeAndOrigin(e,t)}createPublicConfigStore(){const e=new l.ObservableStore,t=async({isUnlocked:e})=>{const{chainId:t,networkVersion:r,isConnected:n}=await this.getProviderNetworkState();return{isUnlocked:e,chainId:t,networkVersion:n?r:"loading"}},r=async r=>{var n;(null===(n=r.networksMetadata[r.selectedNetworkClientId])||void 0===n?void 0:n.status)===ae.NetworkStatus.Available&&e.putState(await t(r))};return this.on("update",r),r(this.getState()),e}async getProviderState(e){const t=await this.getProviderNetworkState(e),r={};return{isUnlocked:!0,accounts:this.getPermittedAccounts(e),...r,...t}}async getProviderNetworkState(e=O.METAMASK_DOMAIN){const t=this.controllerMessenger.call("SelectedNetworkController:getNetworkClientIdForDomain",e),r=this.controllerMessenger.call("NetworkController:getNetworkClientById",t),{chainId:n}=r.configuration,{completedOnboarding:s}=this.onboardingController.state;let i=this.deprecatedNetworkVersions[t];if(i===undefined&&s){try{const e=await r.provider.request({method:"net_version"});i=(0,Se.convertNetworkId)(e)}catch(e){console.error(e),i=null}this.deprecatedNetworkVersions[t]=i}const o=this.networkController.state.networksMetadata[t];return{chainId:n,networkVersion:i??"loading",isConnected:(null==o?void 0:o.status)===ae.NetworkStatus.Available}}getState(){const{vault:e}=this.keyringController.state,t=Boolean(e),r=this.memStore.getFlatState();return{isInitialized:t,...(0,Ot.sanitizeUIState)(r)}}getApi(){const{accountsController:e,addressBookController:t,alertController:r,appStateController:n,keyringController:s,nftController:i,nftDetectionController:o,currencyRateController:a,tokenBalancesController:l,tokenDetectionController:c,ensController:u,tokenListController:d,gasFeeController:h,metaMetricsController:p,networkController:g,announcementController:f,onboardingController:m,permissionController:y,preferencesController:b,tokensController:k,smartTransactionsController:w,txController:v,assetsContractController:C,backup:T,approvalController:S,phishingController:A,tokenRatesController:M,accountTrackerController:P,authenticationController:E,userStorageController:_,notificationServicesController:I,notificationServicesPushController:B}=this;return{getState:this.getState.bind(this),setCurrentCurrency:a.setCurrentCurrency.bind(a),setUseBlockie:b.setUseBlockie.bind(b),setUsePhishDetect:b.setUsePhishDetect.bind(b),setUseMultiAccountBalanceChecker:b.setUseMultiAccountBalanceChecker.bind(b),setUseSafeChainsListValidation:b.setUseSafeChainsListValidation.bind(b),setUseTokenDetection:b.setUseTokenDetection.bind(b),setUseNftDetection:b.setUseNftDetection.bind(b),setUse4ByteResolution:b.setUse4ByteResolution.bind(b),setUseCurrencyRateCheck:b.setUseCurrencyRateCheck.bind(b),setOpenSeaEnabled:b.setOpenSeaEnabled.bind(b),getProviderConfig:()=>(0,Ee.getProviderConfig)({metamask:this.networkController.state}),grantPermissionsIncremental:this.permissionController.grantPermissionsIncremental.bind(this.permissionController),grantPermissions:this.permissionController.grantPermissions.bind(this.permissionController),setSecurityAlertsEnabled:b.setSecurityAlertsEnabled.bind(b),setAddSnapAccountEnabled:b.setAddSnapAccountEnabled.bind(b),setUseExternalNameSources:b.setUseExternalNameSources.bind(b),setUseTransactionSimulations:b.setUseTransactionSimulations.bind(b),setIpfsGateway:b.setIpfsGateway.bind(b),setIsIpfsGatewayEnabled:b.setIsIpfsGatewayEnabled.bind(b),setUseAddressBarEnsResolution:b.setUseAddressBarEnsResolution.bind(b),setParticipateInMetaMetrics:p.setParticipateInMetaMetrics.bind(p),setDataCollectionForMarketing:p.setDataCollectionForMarketing.bind(p),setMarketingCampaignCookieId:p.setMarketingCampaignCookieId.bind(p),setCurrentLocale:b.setCurrentLocale.bind(b),setIncomingTransactionsPreferences:b.setIncomingTransactionsPreferences.bind(b),setServiceWorkerKeepAlivePreference:b.setServiceWorkerKeepAlivePreference.bind(b),markPasswordForgotten:this.markPasswordForgotten.bind(this),unMarkPasswordForgotten:this.unMarkPasswordForgotten.bind(this),getRequestAccountTabIds:this.getRequestAccountTabIds,getOpenMetamaskTabsIds:this.getOpenMetamaskTabsIds,markNotificationPopupAsAutomaticallyClosed:()=>this.notificationManager.markAsAutomaticallyClosed(),getCode:this.getCode.bind(this),addNewAccount:this.addNewAccount.bind(this),getSeedPhrase:this.getSeedPhrase.bind(this),resetAccount:this.resetAccount.bind(this),removeAccount:this.removeAccount.bind(this),importAccountWithStrategy:this.importAccountWithStrategy.bind(this),getNextAvailableAccountName:e.getNextAvailableAccountName.bind(e),getAccountsBySnapId:e=>(0,vt.getAccountsBySnapId)(this.getSnapKeyring.bind(this),e),connectHardware:this.connectHardware.bind(this),forgetDevice:this.forgetDevice.bind(this),checkHardwareStatus:this.checkHardwareStatus.bind(this),unlockHardwareWalletAccount:this.unlockHardwareWalletAccount.bind(this),attemptLedgerTransportCreation:this.attemptLedgerTransportCreation.bind(this),submitQRHardwareCryptoHDKey:s.submitQRCryptoHDKey.bind(s),submitQRHardwareCryptoAccount:s.submitQRCryptoAccount.bind(s),cancelSyncQRHardware:s.cancelQRSynchronization.bind(s),submitQRHardwareSignature:s.submitQRSignature.bind(s),cancelQRHardwareSignRequest:s.cancelQRSignRequest.bind(s),submitPassword:this.submitPassword.bind(this),verifyPassword:this.verifyPassword.bind(this),setActiveNetwork:async e=>await this.multichainNetworkController.setActiveNetwork(e),setActiveNetworkConfigurationId:e=>{this.networkController.setActiveNetwork(e)},setNetworkClientIdForDomain:(e,t)=>this.selectedNetworkController.setNetworkClientIdForDomain(e,t),rollbackToPreviousProvider:g.rollbackToPreviousProvider.bind(g),addNetwork:this.networkController.addNetwork.bind(this.networkController),updateNetwork:this.networkController.updateNetwork.bind(this.networkController),removeNetwork:this.networkController.removeNetwork.bind(this.networkController),getCurrentNetworkEIP1559Compatibility:this.networkController.getEIP1559Compatibility.bind(this.networkController),getNetworkConfigurationByNetworkClientId:this.networkController.getNetworkConfigurationByNetworkClientId.bind(this.networkController),setSelectedAddress:e=>{const t=this.accountsController.getAccountByAddress(e);if(!t)throw new Error(`No account found for address: ${e}`);this.accountsController.setSelectedAccount(t.id)},toggleExternalServices:this.toggleExternalServices.bind(this),addToken:k.addToken.bind(k),updateTokenType:k.updateTokenType.bind(k),setFeatureFlag:b.setFeatureFlag.bind(b),setPreference:b.setPreference.bind(b),addKnownMethodData:b.addKnownMethodData.bind(b),setDismissSeedBackUpReminder:b.setDismissSeedBackUpReminder.bind(b),setOverrideContentSecurityPolicyHeader:b.setOverrideContentSecurityPolicyHeader.bind(b),setAdvancedGasFee:b.setAdvancedGasFee.bind(b),setTheme:b.setTheme.bind(b),disableAccountUpgradeForChain:b.disableAccountUpgradeForChain.bind(b),setSnapsAddSnapAccountModalDismissed:b.setSnapsAddSnapAccountModalDismissed.bind(b),setSelectedInternalAccount:e=>{this.accountsController.getAccount(e)&&this.accountsController.setSelectedAccount(e)},setAccountName:e.setAccountName.bind(e),setAccountLabel:(e,t)=>{const r=this.accountsController.getAccountByAddress(e);if(r===undefined)throw new Error(`No account found for address: ${e}`);this.accountsController.setAccountName(r.id,t)},getTokenStandardAndDetails:this.getTokenStandardAndDetails.bind(this),getTokenSymbol:this.getTokenSymbol.bind(this),addNft:i.addNft.bind(i),addNftVerifyOwnership:i.addNftVerifyOwnership.bind(i),removeAndIgnoreNft:i.removeAndIgnoreNft.bind(i),removeNft:i.removeNft.bind(i),checkAndUpdateAllNftsOwnershipStatus:i.checkAndUpdateAllNftsOwnershipStatus.bind(i),checkAndUpdateSingleNftOwnershipStatus:i.checkAndUpdateSingleNftOwnershipStatus.bind(i),getNFTContractInfo:i.getNFTContractInfo.bind(i),isNftOwner:i.isNftOwner.bind(i),setAddressBook:t.set.bind(t),removeFromAddressBook:t.delete.bind(t),setLastActiveTime:n.setLastActiveTime.bind(n),setCurrentExtensionPopupId:n.setCurrentExtensionPopupId.bind(n),setDefaultHomeActiveTabName:n.setDefaultHomeActiveTabName.bind(n),setConnectedStatusPopoverHasBeenShown:n.setConnectedStatusPopoverHasBeenShown.bind(n),setRecoveryPhraseReminderHasBeenShown:n.setRecoveryPhraseReminderHasBeenShown.bind(n),setRecoveryPhraseReminderLastShown:n.setRecoveryPhraseReminderLastShown.bind(n),setTermsOfUseLastAgreed:n.setTermsOfUseLastAgreed.bind(n),setSurveyLinkLastClickedOrClosed:n.setSurveyLinkLastClickedOrClosed.bind(n),setOnboardingDate:n.setOnboardingDate.bind(n),setLastViewedUserSurvey:n.setLastViewedUserSurvey.bind(n),setRampCardClosed:n.setRampCardClosed.bind(n),setNewPrivacyPolicyToastClickedOrClosed:n.setNewPrivacyPolicyToastClickedOrClosed.bind(n),setNewPrivacyPolicyToastShownDate:n.setNewPrivacyPolicyToastShownDate.bind(n),setSnapsInstallPrivacyWarningShownStatus:n.setSnapsInstallPrivacyWarningShownStatus.bind(n),setOutdatedBrowserWarningLastShown:n.setOutdatedBrowserWarningLastShown.bind(n),setShowTestnetMessageInDropdown:n.setShowTestnetMessageInDropdown.bind(n),setShowBetaHeader:n.setShowBetaHeader.bind(n),setShowPermissionsTour:n.setShowPermissionsTour.bind(n),setShowAccountBanner:n.setShowAccountBanner.bind(n),setShowNetworkBanner:n.setShowNetworkBanner.bind(n),updateNftDropDownState:n.updateNftDropDownState.bind(n),setSwitchedNetworkDetails:n.setSwitchedNetworkDetails.bind(n),clearSwitchedNetworkDetails:n.clearSwitchedNetworkDetails.bind(n),setSwitchedNetworkNeverShowMessage:n.setSwitchedNetworkNeverShowMessage.bind(n),getLastInteractedConfirmationInfo:n.getLastInteractedConfirmationInfo.bind(n),setLastInteractedConfirmationInfo:n.setLastInteractedConfirmationInfo.bind(n),updateSlides:n.updateSlides.bind(n),removeSlide:n.removeSlide.bind(n),tryReverseResolveAddress:u.reverseResolveAddress.bind(u),setLocked:this.setLocked.bind(this),createNewVaultAndKeychain:this.createNewVaultAndKeychain.bind(this),createNewVaultAndRestore:this.createNewVaultAndRestore.bind(this),exportAccount:this.exportAccount.bind(this),updateTransaction:v.updateTransaction.bind(v),approveTransactionsWithSameNonce:v.approveTransactionsWithSameNonce.bind(v),createCancelTransaction:this.createCancelTransaction.bind(this),createSpeedUpTransaction:this.createSpeedUpTransaction.bind(this),estimateGas:this.estimateGas.bind(this),estimateGasFee:v.estimateGasFee.bind(v),getNextNonce:this.getNextNonce.bind(this),addTransaction:(e,t)=>(0,Tt.addTransaction)(this.getAddTransactionRequest({transactionParams:e,transactionOptions:t,waitForSubmit:!1})),addTransactionAndWaitForPublish:(e,t)=>(0,Tt.addTransaction)(this.getAddTransactionRequest({transactionParams:e,transactionOptions:t,waitForSubmit:!0})),createTransactionEventFragment:je.createTransactionEventFragmentWithTxId.bind(null,this.getTransactionMetricsRequest()),setTransactionActive:v.setTransactionActive.bind(v),decryptMessage:this.decryptMessageController.decryptMessage.bind(this.decryptMessageController),decryptMessageInline:this.decryptMessageController.decryptMessageInline.bind(this.decryptMessageController),cancelDecryptMessage:this.decryptMessageController.cancelDecryptMessage.bind(this.decryptMessageController),encryptionPublicKey:this.encryptionPublicKeyController.encryptionPublicKey.bind(this.encryptionPublicKeyController),cancelEncryptionPublicKey:this.encryptionPublicKeyController.cancelEncryptionPublicKey.bind(this.encryptionPublicKeyController),setSeedPhraseBackedUp:m.setSeedPhraseBackedUp.bind(m),completeOnboarding:m.completeOnboarding.bind(m),setFirstTimeFlowType:m.setFirstTimeFlowType.bind(m),setAlertEnabledness:r.setAlertEnabledness.bind(r),setUnconnectedAccountAlertShown:r.setUnconnectedAccountAlertShown.bind(r),setWeb3ShimUsageAlertDismissed:r.setWeb3ShimUsageAlertDismissed.bind(r),removePermissionsFor:this.removePermissionsFor,approvePermissionsRequest:this.acceptPermissionsRequest,rejectPermissionsRequest:this.rejectPermissionsRequest,...(0,gt.getPermissionBackgroundApiMethods)({permissionController:y,approvalController:S}),disableSnap:this.controllerMessenger.call.bind(this.controllerMessenger,"SnapController:disable"),enableSnap:this.controllerMessenger.call.bind(this.controllerMessenger,"SnapController:enable"),updateSnap:(e,t)=>(this.controllerMessenger.call("SnapController:install",e,t),null),removeSnap:this.controllerMessenger.call.bind(this.controllerMessenger,"SnapController:remove"),handleSnapRequest:this.handleSnapRequest.bind(this),revokeDynamicSnapPermissions:this.controllerMessenger.call.bind(this.controllerMessenger,"SnapController:revokeDynamicPermissions"),disconnectOriginFromSnap:this.controllerMessenger.call.bind(this.controllerMessenger,"SnapController:disconnectOrigin"),updateNetworksList:this.updateNetworksList.bind(this),updateAccountsList:this.updateAccountsList.bind(this),updateHiddenAccountsList:this.updateHiddenAccountsList.bind(this),getPhishingResult:async e=>(await A.maybeUpdateState(),A.test(e)),deleteInterface:this.controllerMessenger.call.bind(this.controllerMessenger,"SnapInterfaceController:deleteInterface"),updateInterfaceState:this.controllerMessenger.call.bind(this.controllerMessenger,"SnapInterfaceController:updateInterfaceState"),fetchAndSetQuotes:this.controllerMessenger.call.bind(this.controllerMessenger,"SwapsController:fetchAndSetQuotes"),setSelectedQuoteAggId:this.controllerMessenger.call.bind(this.controllerMessenger,"SwapsController:setSelectedQuoteAggId"),resetSwapsState:this.controllerMessenger.call.bind(this.controllerMessenger,"SwapsController:resetSwapsState"),setSwapsTokens:this.controllerMessenger.call.bind(this.controllerMessenger,"SwapsController:setSwapsTokens"),clearSwapsQuotes:this.controllerMessenger.call.bind(this.controllerMessenger,"SwapsController:clearSwapsQuotes"),setApproveTxId:this.controllerMessenger.call.bind(this.controllerMessenger,"SwapsController:setApproveTxId"),setTradeTxId:this.controllerMessenger.call.bind(this.controllerMessenger,"SwapsController:setTradeTxId"),setSwapsTxGasPrice:this.controllerMessenger.call.bind(this.controllerMessenger,"SwapsController:setSwapsTxGasPrice"),setSwapsTxGasLimit:this.controllerMessenger.call.bind(this.controllerMessenger,"SwapsController:setSwapsTxGasLimit"),setSwapsTxMaxFeePerGas:this.controllerMessenger.call.bind(this.controllerMessenger,"SwapsController:setSwapsTxMaxFeePerGas"),setSwapsTxMaxFeePriorityPerGas:this.controllerMessenger.call.bind(this.controllerMessenger,"SwapsController:setSwapsTxMaxFeePriorityPerGas"),safeRefetchQuotes:this.controllerMessenger.call.bind(this.controllerMessenger,"SwapsController:safeRefetchQuotes"),stopPollingForQuotes:this.controllerMessenger.call.bind(this.controllerMessenger,"SwapsController:stopPollingForQuotes"),setBackgroundSwapRouteState:this.controllerMessenger.call.bind(this.controllerMessenger,"SwapsController:setBackgroundSwapRouteState"),resetPostFetchState:this.controllerMessenger.call.bind(this.controllerMessenger,"SwapsController:resetPostFetchState"),setSwapsErrorKey:this.controllerMessenger.call.bind(this.controllerMessenger,"SwapsController:setSwapsErrorKey"),setInitialGasEstimate:this.controllerMessenger.call.bind(this.controllerMessenger,"SwapsController:setInitialGasEstimate"),setCustomApproveTxData:this.controllerMessenger.call.bind(this.controllerMessenger,"SwapsController:setCustomApproveTxData"),setSwapsLiveness:this.controllerMessenger.call.bind(this.controllerMessenger,"SwapsController:setSwapsLiveness"),setSwapsFeatureFlags:this.controllerMessenger.call.bind(this.controllerMessenger,"SwapsController:setSwapsFeatureFlags"),setSwapsUserFeeLevel:this.controllerMessenger.call.bind(this.controllerMessenger,"SwapsController:setSwapsUserFeeLevel"),setSwapsQuotesPollingLimitEnabled:this.controllerMessenger.call.bind(this.controllerMessenger,"SwapsController:setSwapsQuotesPollingLimitEnabled"),[W.BridgeBackgroundAction.SET_FEATURE_FLAGS]:this.controllerMessenger.call.bind(this.controllerMessenger,`${W.BRIDGE_CONTROLLER_NAME}:${W.BridgeBackgroundAction.SET_FEATURE_FLAGS}`),[W.BridgeBackgroundAction.RESET_STATE]:this.controllerMessenger.call.bind(this.controllerMessenger,`${W.BRIDGE_CONTROLLER_NAME}:${W.BridgeBackgroundAction.RESET_STATE}`),[W.BridgeBackgroundAction.GET_BRIDGE_ERC20_ALLOWANCE]:this.controllerMessenger.call.bind(this.controllerMessenger,`${W.BRIDGE_CONTROLLER_NAME}:${W.BridgeBackgroundAction.GET_BRIDGE_ERC20_ALLOWANCE}`),[W.BridgeUserAction.UPDATE_QUOTE_PARAMS]:this.controllerMessenger.call.bind(this.controllerMessenger,`${W.BRIDGE_CONTROLLER_NAME}:${W.BridgeUserAction.UPDATE_QUOTE_PARAMS}`),[xe.BridgeStatusAction.START_POLLING_FOR_BRIDGE_TX_STATUS]:this.controllerMessenger.call.bind(this.controllerMessenger,`${Lt.BRIDGE_STATUS_CONTROLLER_NAME}:${xe.BridgeStatusAction.START_POLLING_FOR_BRIDGE_TX_STATUS}`),fetchSmartTransactionFees:w.getFees.bind(w),clearSmartTransactionFees:w.clearFees.bind(w),submitSignedTransactions:w.submitSignedTransactions.bind(w),cancelSmartTransaction:w.cancelSmartTransaction.bind(w),fetchSmartTransactionsLiveness:w.fetchLiveness.bind(w),updateSmartTransaction:w.updateSmartTransaction.bind(w),setStatusRefreshInterval:w.setStatusRefreshInterval.bind(w),trackMetaMetricsEvent:p.trackEvent.bind(p),trackMetaMetricsPage:p.trackPage.bind(p),createEventFragment:p.createEventFragment.bind(p),updateEventFragment:p.updateEventFragment.bind(p),finalizeEventFragment:p.finalizeEventFragment.bind(p),trackInsightSnapView:this.trackInsightSnapView.bind(this),rejectAllPendingApprovals:this.rejectAllPendingApprovals.bind(this),rejectPendingApproval:this.rejectPendingApproval,requestUserApproval:S.addAndShowApprovalRequest.bind(S),resolvePendingApproval:this.resolvePendingApproval,resetViewedNotifications:f.resetViewed.bind(f),updateViewedNotifications:f.updateViewed.bind(f),currencyRateStartPolling:a.startPolling.bind(a),currencyRateStopPollingByPollingToken:a.stopPollingByPollingToken.bind(a),tokenRatesStartPolling:M.startPolling.bind(M),tokenRatesStopPollingByPollingToken:M.stopPollingByPollingToken.bind(M),accountTrackerStartPolling:P.startPollingByNetworkClientId.bind(P),accountTrackerStopPollingByPollingToken:P.stopPollingByPollingToken.bind(P),tokenDetectionStartPolling:c.startPolling.bind(c),tokenDetectionStopPollingByPollingToken:c.stopPollingByPollingToken.bind(c),tokenListStartPolling:d.startPolling.bind(d),tokenListStopPollingByPollingToken:d.stopPollingByPollingToken.bind(d),tokenBalancesStartPolling:l.startPolling.bind(l),tokenBalancesStopPollingByPollingToken:l.stopPollingByPollingToken.bind(l),gasFeeStartPolling:h.startPolling.bind(h),gasFeeStopPollingByPollingToken:h.stopPollingByPollingToken.bind(h),getGasFeeTimeEstimate:h.getTimeEstimate.bind(h),addPollingTokenToAppState:n.addPollingToken.bind(n),removePollingTokenFromAppState:n.removePollingToken.bind(n),updateThrottledOriginState:n.updateThrottledOriginState.bind(n),backupUserData:T.backupUserData.bind(T),restoreUserData:T.restoreUserData.bind(T),detectTokens:c.detectTokens.bind(c),detectNfts:o.detectNfts.bind(o),addDetectedTokens:k.addDetectedTokens.bind(k),addImportedTokens:k.addTokens.bind(k),ignoreTokens:k.ignoreTokens.bind(k),getBalancesInSingleCall:C.getBalancesInSingleCall.bind(C),performSignIn:E.performSignIn.bind(E),performSignOut:E.performSignOut.bind(E),enableProfileSyncing:_.enableProfileSyncing.bind(_),disableProfileSyncing:_.disableProfileSyncing.bind(_),syncInternalAccountsWithUserStorage:_.syncInternalAccountsWithUserStorage.bind(_),deleteAccountSyncingDataFromUserStorage:_.performDeleteStorageAllFeatureEntries.bind(_),checkAccountsPresence:I.checkAccountsPresence.bind(I),createOnChainTriggers:I.createOnChainTriggers.bind(I),deleteOnChainTriggersByAccount:I.deleteOnChainTriggersByAccount.bind(I),updateOnChainTriggersByAccount:I.updateOnChainTriggersByAccount.bind(I),fetchAndUpdateMetamaskNotifications:I.fetchAndUpdateMetamaskNotifications.bind(I),deleteNotificationsById:I.deleteNotificationsById.bind(I),getNotificationsByType:I.getNotificationsByType.bind(I),markMetamaskNotificationsAsRead:I.markMetamaskNotificationsAsRead.bind(I),setFeatureAnnouncementsEnabled:I.setFeatureAnnouncementsEnabled.bind(I),enablePushNotifications:B.enablePushNotifications.bind(B),disablePushNotifications:B.disablePushNotifications.bind(B),updateTriggerPushNotifications:B.updateTriggerPushNotifications.bind(B),enableMetamaskNotifications:I.enableMetamaskNotifications.bind(I),disableMetamaskNotifications:I.disableNotificationServices.bind(I),throwTestError:this.throwTestError.bind(this),updateProposedNames:this.nameController.updateProposedNames.bind(this.nameController),setName:this.nameController.setName.bind(this.nameController),decodeTransactionData:e=>(0,Nt.decodeTransactionData)({...e,provider:this.provider}),createMetaMetricsDataDeletionTask:this.metaMetricsDataDeletionController.createMetaMetricsDataDeletionTask.bind(this.metaMetricsDataDeletionController),updateDataDeletionTaskStatus:this.metaMetricsDataDeletionController.updateDataDeletionTaskStatus.bind(this.metaMetricsDataDeletionController),endTrace:_e.endTrace}}rejectOriginPendingApprovals(e){(0,Ut.rejectOriginApprovals)({approvalController:this.approvalController,deleteInterface:e=>this.controllerMessenger.call("SnapInterfaceController:deleteInterface",e),origin:e})}async exportAccount(e,t){return await this.verifyPassword(t),this.keyringController.exportAccount(t,e)}async getTokenStandardAndDetails(e,t,r){var n,s;const{tokenList:i}=this.tokenListController.state,{tokens:o}=this.tokensController.state,a={...ve.STATIC_MAINNET_TOKEN_LIST[null==e?void 0:e.toLowerCase()]||{},...i[e.toLowerCase()]||{},...o.find((({address:t})=>(0,ke.isEqualCaseInsensitive)(t,e)))||{}},l=(0,ke.isEqualCaseInsensitive)(a.standard,ie.TokenStandard.ERC20)||!0===a.erc20,c=!(r||(0,ke.isEqualCaseInsensitive)(a.standard,ie.TokenStandard.ERC1155)||(0,ke.isEqualCaseInsensitive)(a.standard,ie.TokenStandard.ERC721)||a.erc721),u=a.decimals!==undefined&&a.symbol;let d;if(l||c&&u)try{const r=t?await(0,be.fetchTokenBalance)(e,t,this.provider):undefined;d={address:e,balance:r,standard:ie.TokenStandard.ERC20,decimals:a.decimals,symbol:a.symbol}}catch(e){y.default.warn(`Failed to get token balance. Error: ${e}`)}if(d===undefined)try{d=await this.assetsContractController.getTokenStandardAndDetails(e,t,r)}catch(e){y.default.warn(`Failed to get token standard and details. Error: ${e}`)}if(d){if((0,ke.isEqualCaseInsensitive)(d.standard,ie.TokenStandard.ERC1155))try{const n=await(0,be.fetchERC1155Balance)(e,t,r,this.provider),s=null!=n&&n._hex?parseInt(n._hex,16).toString():null;d={...d,balance:s}}catch(e){y.default.warn("Failed to get token balance. Error:",e)}}return{...d,decimals:null===(n=d)||void 0===n||null===(n=n.decimals)||void 0===n?void 0:n.toString(10),balance:null===(s=d)||void 0===s||null===(s=s.balance)||void 0===s?void 0:s.toString(10)}}async getTokenSymbol(e){try{const t=await this.assetsContractController.getTokenStandardAndDetails(e);return null==t?void 0:t.symbol}catch(e){return null}}async createNewVaultAndKeychain(e){const t=await this.createVaultMutex.acquire();try{return await this.keyringController.createNewVaultAndKeychain(e)}finally{t()}}async createNewVaultAndRestore(e,r){const n=await this.createVaultMutex.acquire();try{const{completedOnboarding:n}=this.onboardingController.state,s=t.from(r);this.permissionController.clearState(),this.snapController.clearState(),this.accountTrackerController.clearAccounts(),this.txController.clearUnapprovedTransactions(),n&&this.tokenDetectionController.enable(),await this.keyringController.createNewVaultAndRestore(e,this._convertMnemonicToWordlistIndices(s)),n&&(await this._addAccountsWithBalance(),er(ir,this,ar).call(this,{name:ce.HardwareDeviceNames.ledger},(async e=>this.setLedgerTransportPreference(e))))}finally{n()}}async _addAccountsWithBalance(e){try{const n=er(ir,this,ur).call(this),s=e?{id:e}:{type:h.KeyringTypes.hd},i=await this.keyringController.withKeyring(s,(async({keyring:e})=>await e.getAccounts()));let o=i[i.length-1];for(let e=i.length;;e++){if("0x0"===await this.getBalance(o,this.provider)){var t,r;await this.tokenDetectionController.detectTokens({chainIds:[n],selectedAddress:o});const s=null===(t=this.tokensController.state.allTokens)||void 0===t||null===(t=t[n])||void 0===t?void 0:t[o],i=null===(r=this.tokensController.state.allDetectedTokens)||void 0===r||null===(r=r[n])||void 0===r?void 0:r[o];if(0===((null==s?void 0:s.length)??0)&&0===((null==i?void 0:i.length)??0)){1!==e&&await this.removeAccount(o);break}}o=await this.keyringController.withKeyring(s,(async({keyring:e})=>{const[t]=await e.addAccounts(1);return t}))}}catch(e){y.default.warn(`Failed to add accounts with balance. Error: ${e}`)}finally{await this.userStorageController.setIsAccountSyncingReadyToBeDispatched(!0)}}_convertMnemonicToWordlistIndices(e){const t=e.toString().split(" ").map((e=>z.wordlist.indexOf(e)));return new Uint8Array(new Uint16Array(t).buffer)}_convertEnglishWordlistIndicesToCodepoints(e){return t.from(Array.from(new Uint16Array(e.buffer)).map((e=>z.wordlist[e])).join(" "))}async getBalance(e,t){const r=this.accountTrackerController.state.accounts[e];if(r&&r.balance)return r.balance;try{return await t.request({method:"eth_getBalance",params:[e,"latest"]})||"0x0"}catch(e){throw y.default.error(e),e}}async submitPassword(e){const{completedOnboarding:t}=this.onboardingController.state;await this.offscreenPromise,await this.keyringController.submitPassword(e);try{await this.blockTracker.checkForLatestBlock()}catch(e){y.default.error("Error while unlocking extension.",e)}await this.accountsController.updateAccounts(),t&&er(ir,this,ar).call(this,{name:ce.HardwareDeviceNames.ledger},(async e=>this.setLedgerTransportPreference(e)))}async _loginUser(e){try{await this.submitPassword(e),await this.accountTrackerController.updateAccountsAllActiveNetworks()}finally{this._startUISync()}}_startUISync(){this.emit("startUISync"),this.startUISync=!0,this.memStore.subscribe(this.sendUpdate.bind(this))}async submitEncryptionKey(){try{const{loginToken:e,loginSalt:t}=await this.extension.storage.session.get(["loginToken","loginSalt"]);if(e&&t){const{vault:r}=this.keyringController.state;if(JSON.parse(r).salt!==t)return console.warn("submitEncryptionKey: Stored salt and vault salt do not match"),void await this.clearLoginArtifacts();await this.keyringController.submitEncryptionKey(e,t)}}catch(e){throw await this.clearLoginArtifacts(),e}}async clearLoginArtifacts(){await this.extension.storage.session.remove(["loginToken","loginSalt"])}async verifyPassword(e){await this.keyringController.verifyPassword(e)}getPrimaryKeyringMnemonic(){const[e]=this.keyringController.getKeyringsByType(ue.KeyringType.hdKeyTree);if(!e.mnemonic)throw new Error("Primary keyring mnemonic unavailable.");return e.mnemonic}getPrimaryKeyringMnemonicSeed(){const[e]=this.keyringController.getKeyringsByType(ue.KeyringType.hdKeyTree);if(!e.seed)throw new Error("Primary keyring mnemonic unavailable.");return e.seed}async attemptLedgerTransportCreation(){return await er(ir,this,ar).call(this,{name:ce.HardwareDeviceNames.ledger},(async e=>e.attemptMakeApp()))}async connectHardware(e,t,r){return er(ir,this,ar).call(this,{name:e,hdPath:r},(async r=>{e===ce.HardwareDeviceNames.ledger&&await this.setLedgerTransportPreference(r);let n=[];switch(t){case-1:n=await r.getPreviousPage();break;case 1:n=await r.getNextPage();break;default:n=await r.getFirstPage()}const s=await this.keyringController.getAccounts(),i=[...new Set(s.concat(n.map((e=>e.address.toLowerCase()))))];return this.accountTrackerController.syncWithAddresses(i),n}))}async checkHardwareStatus(e,t){return er(ir,this,ar).call(this,{name:e,hdPath:t},(async e=>e.isUnlocked()))}async getHardwareTypeForMetric(e){return await this.keyringController.withKeyring({address:e},(({keyring:e})=>ce.HardwareKeyringType[e.type]))}async forgetDevice(e){return er(ir,this,ar).call(this,{name:e},(async e=>{for(const t of e.accounts)this._onAccountRemoved(t);return e.forgetDevice(),!0}))}async getAccountType(e){switch(await this.keyringController.getAccountKeyringType(e)){case ue.KeyringType.trezor:case ue.KeyringType.oneKey:case ue.KeyringType.lattice:case ue.KeyringType.qr:case ue.KeyringType.ledger:return"hardware";case ue.KeyringType.imported:return"imported";case ue.KeyringType.snap:return"snap";default:return"MetaMask"}}async getDeviceModel(e){return this.keyringController.withKeyring({address:e},(async({keyring:e})=>{switch(e.type){case ue.KeyringType.trezor:case ue.KeyringType.oneKey:return e.getModel();case ue.KeyringType.qr:return e.getName();case ue.KeyringType.ledger:return ce.HardwareDeviceNames.ledger;case ue.KeyringType.lattice:return ce.HardwareDeviceNames.lattice;default:return undefined}}))}getAccountLabel(e,t,r){return`${e[0].toUpperCase()}${e.slice(1)} ${parseInt(t,10)+1} ${r||""}`.trim()}async unlockHardwareWalletAccount(e,t,r,n){const{address:s,label:i}=await er(ir,this,ar).call(this,{name:t,hdPath:r},(async r=>{r.setAccountToUnlock(e);const[s]=await r.addAccounts(1);return{address:(0,te.normalize)(s),label:this.getAccountLabel(t===ce.HardwareDeviceNames.qr?r.getName():t,e,n)}}));this.preferencesController.setAccountLabel(s,i),this.preferencesController.setSelectedAddress(s);const o=this.accountsController.getAccountByAddress(s);this.accountsController.setAccountName(o.id,i);const a=this.accountsController.listAccounts(),{identities:l}=this.preferencesController.state;return{unlockedAccount:s,identities:l,accounts:a}}async addNewAccount(e,t){const r=await this.keyringController.getAccounts(),n=t?{id:t}:{type:h.KeyringTypes.hd},s=await this.keyringController.withKeyring(n,(async({keyring:t})=>{if(t.type!==h.KeyringTypes.hd)throw new Error("Cannot add account to non-HD keyring");const r=await t.getAccounts();if(e&&e!==r.length){if(e>r.length)throw new Error("Account out of sequence");const t=r[e];if(!t)throw new Error(`Can't find account at index ${e}`);return t}const[n]=await t.addAccounts(1);return n}));return r.includes(s)||this.preferencesController.setSelectedAddress(s),s}async getSeedPhrase(e,t){return this._convertEnglishWordlistIndicesToCodepoints(await this.keyringController.exportSeedPhrase(e))}async resetAccount(){const e=this.accountsController.getSelectedAccount().address,t=er(ir,this,ur).call(this);return this.txController.wipeTransactions({address:e,chainId:t}),this.smartTransactionsController.wipeSmartTransactions({address:e,ignoreNetwork:!1}),this.bridgeStatusController.wipeBridgeStatus({address:e,ignoreNetwork:!1}),this.networkController.resetConnection(),e}captureKeyringTypesWithMissingIdentities(e=[],t=[]){const r=t.filter((t=>!e.some((e=>e.address.toLowerCase()===t.toLowerCase())))).map((e=>this.keyringController.getAccountKeyringType(e))),n=e.length,s=Object.keys(this.accountTrackerController.state.accounts||{}).length;(0,S.captureException)(new Error(`Attempt to get permission specifications failed because their were ${t.length} accounts, but ${n} identities, and the ${r} keyrings included accounts with missing identities. Meanwhile, there are ${s} accounts in the account tracker.`))}sortAccountsByLastSelected(e){const t=this.accountsController.listAccounts();return e.sort(((r,n)=>{const s=t.find((e=>e.address.toLowerCase()===r.toLowerCase())),i=t.find((e=>e.address.toLowerCase()===n.toLowerCase()));if(!s)throw this.captureKeyringTypesWithMissingIdentities(t,e),new Error(`Missing identity for address: "${r}".`);if(!i)throw this.captureKeyringTypesWithMissingIdentities(t,e),new Error(`Missing identity for address: "${n}".`);return s.metadata.lastSelected===i.metadata.lastSelected?0:s.metadata.lastSelected===undefined?1:i.metadata.lastSelected===undefined?-1:i.metadata.lastSelected-s.metadata.lastSelected}))}getPermittedAccounts(e,{ignoreLock:t}={}){let r;try{r=this.permissionController.getCaveat(e,ne.Caip25EndowmentPermissionName,ne.Caip25CaveatType)}catch(e){if(e instanceof x.PermissionDoesNotExistError)return[];throw e}if(!this.isUnlocked()&&!t)return[];const n=(0,ne.getEthAccounts)(r.value);return this.sortAccountsByLastSelected(n)}removeAllScopePermissions(e){this.permissionController.updatePermissionsByCaveat(ne.Caip25CaveatType,(t=>ne.Caip25CaveatMutators[ne.Caip25CaveatType].removeScope(t,e)))}removeAllAccountPermissions(e){this.permissionController.updatePermissionsByCaveat(ne.Caip25CaveatType,(t=>ne.Caip25CaveatMutators[ne.Caip25CaveatType].removeAccount(t,e)))}async removeAccount(e){return this._onAccountRemoved(e),await this.keyringController.removeAccount(e),e}async importAccountWithStrategy(e,t){const r=await this.keyringController.importAccountWithStrategy(e,t);this.preferencesController.setSelectedAddress(r)}async requestPermissionApproval(e,t,r={}){const n=(0,T.nanoid)();return this.approvalController.addAndShowApprovalRequest({id:n,origin:e,requestData:{metadata:{id:n,origin:e},permissions:t,...r},type:x.MethodNames.RequestPermissions})}async requestApprovalPermittedChainsPermission(e,t){const r=(0,ne.setPermittedEthChainIds)({requiredScopes:{},optionalScopes:{},isMultichainOrigin:!1},[t]);await this.permissionController.requestPermissionsIncremental({origin:e},{[ne.Caip25EndowmentPermissionName]:{caveats:[{type:ne.Caip25CaveatType,value:r}]}})}async requestPermittedChainsPermissionIncremental({origin:e,chainId:t,autoApprove:r,metadata:n}){if((0,Q.isSnapId)(e))throw new Error(`Cannot request permittedChains permission for Snaps with origin "${e}"`);const s=(0,ne.setPermittedEthChainIds)({requiredScopes:{},optionalScopes:{},isMultichainOrigin:!1},[t]);if(!r){let t;return n&&(t={metadata:n}),void await this.permissionController.requestPermissionsIncremental({origin:e},{[ne.Caip25EndowmentPermissionName]:{caveats:[{type:ne.Caip25CaveatType,value:s}]}},t)}await this.permissionController.grantPermissionsIncremental({subject:{origin:e},approvedPermissions:{[ne.Caip25EndowmentPermissionName]:{caveats:[{type:ne.Caip25CaveatType,value:s}]}}})}getCaip25PermissionFromLegacyPermissions(e,t={}){var r,n;const s=(0,d.pick)(t,[de.RestrictedMethods.eth_accounts,gt.PermissionNames.permittedChains]);s[de.RestrictedMethods.eth_accounts]||(s[de.RestrictedMethods.eth_accounts]={}),s[gt.PermissionNames.permittedChains]||(s[gt.PermissionNames.permittedChains]={}),(0,Q.isSnapId)(e)&&delete s[gt.PermissionNames.permittedChains];const i=(null===(r=s[de.RestrictedMethods.eth_accounts])||void 0===r||null===(r=r.caveats)||void 0===r||null===(r=r.find((e=>e.type===de.CaveatTypes.restrictReturnedAccounts)))||void 0===r?void 0:r.value)??[],o=(null===(n=s[gt.PermissionNames.permittedChains])||void 0===n||null===(n=n.caveats)||void 0===n||null===(n=n.find((e=>e.type===de.CaveatTypes.restrictNetworkSwitching)))||void 0===n?void 0:n.value)??[],a=(0,ne.setPermittedEthChainIds)({requiredScopes:{},optionalScopes:{"wallet:eip155":{accounts:[]}},isMultichainOrigin:!1},(0,Q.isSnapId)(e)?[]:o),l=(0,ne.setEthAccounts)(a,i);return{[ne.Caip25EndowmentPermissionName]:{caveats:[{type:ne.Caip25CaveatType,value:l}]}}}getAddTransactionRequest({transactionParams:e,transactionOptions:t,dappRequest:r,...n}){var s;return{internalAccounts:this.accountsController.listAccounts(),dappRequest:r,networkClientId:(null==r?void 0:r.networkClientId)??(null==t?void 0:t.networkClientId),selectedAccount:this.accountsController.getAccountByAddress(e.from),transactionController:this.txController,transactionOptions:t,transactionParams:e,userOperationController:this.userOperationController,chainId:er(ir,this,ur).call(this),ppomController:this.ppomController,securityAlertsEnabled:null===(s=this.preferencesController.state)||void 0===s?void 0:s.securityAlertsEnabled,updateSecurityAlertResponse:this.updateSecurityAlertResponse.bind(this),...n}}async getCurrentAccountEIP1559Compatibility(){return!0}async createCancelTransaction(e,t,r){await this.txController.stopTransaction(e,t,r);return this.getState()}async createSpeedUpTransaction(e,t,r){await this.txController.speedUpTransaction(e,t,r);return this.getState()}async estimateGas(e){return new Promise(((t,r)=>{this.provider.request({method:"eth_estimateGas",params:[e]}).then((e=>t(e.toString(16)))).catch((e=>r(e)))}))}async updateSecurityAlertResponse(e,t,r){await(0,_t.updateSecurityAlertResponse)({appStateController:this.appStateController,method:e,securityAlertId:t,securityAlertResponse:r,signatureController:this.signatureController,transactionController:this.txController})}getHDEntropyIndex(){const e=this.accountsController.getSelectedAccount(),t=this.keyringController.state.keyrings.filter((e=>e.type===h.KeyringTypes.hd)).findIndex((t=>t.accounts.includes(e.address)));return-1===t?undefined:t}markPasswordForgotten(){this.preferencesController.setPasswordForgotten(!0),this.sendUpdate()}unMarkPasswordForgotten(){this.preferencesController.setPasswordForgotten(!1),this.sendUpdate()}setupUntrustedCommunicationEip1193({connectionStream:e,sender:t,subjectType:r}){if(t.url&&this.onboardingController.state.completedOnboarding&&this.preferencesController.state.usePhishDetect){const{hostname:r}=new URL(t.url);this.phishingController.maybeUpdateState();const n=this.phishingController.test(t.url);if(null!=n&&n.result)return this.sendPhishingWarning(e,r),void this.metaMetricsController.trackEvent({event:fe.MetaMetricsEventName.PhishingPageDisplayed,category:fe.MetaMetricsEventCategory.Phishing,properties:{url:r}})}let n;n=r||(t.id&&t.id!==this.extension.runtime.id?x.SubjectType.Extension:x.SubjectType.Website);const s=(0,Xe.setupMultiplex)(e);this.setupProviderConnectionEip1193(s.createStream("metamask-provider"),t,n),t.url&&this.setupPublicConfig(s.createStream("publicConfig"))}setupUntrustedCommunicationCaip({connectionStream:e,sender:t,subjectType:r}){}setupTrustedCommunication(e,t){const r=(0,Xe.setupMultiplex)(e);this.setupControllerConnection(r.createStream("controller")),this.setupProviderConnectionEip1193(r.createStream("provider"),t,x.SubjectType.Internal)}setupPhishingCommunication({connectionStream:e}){const{usePhishDetect:t}=this.preferencesController.state;if(!t)return;const r=(0,Xe.setupMultiplex)(e).createStream("metamask-phishing-safelist");r.on("data",(0,lt.default)({safelistPhishingDomain:this.safelistPhishingDomain.bind(this),backToSafetyPhishingWarning:this.backToSafetyPhishingWarning.bind(this)},r))}setUpCookieHandlerCommunication({connectionStream:e}){const{metaMetricsId:t,dataCollectionForMarketing:r,participateInMetaMetrics:n}=this.metaMetricsController.state;if(t&&r&&n){const t=(0,Xe.setupMultiplex)(e).createStream(Pt.METAMASK_COOKIE_HANDLER);t.on("data",(0,lt.default)({getCookieFromMarketingPage:this.getCookieFromMarketingPage.bind(this)},t))}}getCookieFromMarketingPage(e){const{ga_client_id:t}=e;this.metaMetricsController.setMarketingCampaignCookieId(t)}sendPhishingWarning(e,t){(0,Xe.setupMultiplex)(e).createStream("phishing").write({hostname:t})}setupControllerConnection(e){const t=new Rt.PatchStore(this.memStore);let r=!1;const n=()=>{if(!(0,Xe.isStreamWritable)(e)||!r)return;const n=t.flushPendingPatches();e.write({jsonrpc:"2.0",method:"sendUpdate",params:[n]})},i={...this.getApi(),...this.controllerApi,startPatches:()=>{r=!0,n()},getStatePatches:()=>t.flushPendingPatches()};this.on("update",n),this.activeControllerConnections+=1,this.emit("controllerConnectionChanged",this.activeControllerConnections),e.on("data",(0,lt.default)(i,e));const o=()=>{(0,Xe.isStreamWritable)(e)&&e.write({jsonrpc:"2.0",method:"startUISync"})};this.startUISync?o():this.once("startUISync",o);const a=()=>{e.mmFinished||(this.activeControllerConnections-=1,this.emit("controllerConnectionChanged",this.activeControllerConnections),e.mmFinished=!0,this.removeListener("update",n),t.destroy())};e.mmFinished=!1,(0,s.finished)(e,a),e.once("close",a),e.once("end",a)}setupProviderConnectionEip1193(e,t,r){let n,i;n=r===x.SubjectType.Internal?ge.ORIGIN_METAMASK:r===x.SubjectType.Snap?t.snapId:new URL(t.url).origin,t.id&&t.id!==this.extension.runtime.id&&this.subjectMetadataController.addSubjectMetadata({origin:n,extensionId:t.id,subjectType:x.SubjectType.Extension}),t.tab&&t.tab.id&&(i=t.tab.id);let o=n;t.tab&&t.tab.url&&(o=new URL(t.tab.url).origin);const l=this.setupProviderEngineEip1193({origin:n,sender:t,subjectType:r,tabId:i,mainFrameOrigin:o}),c=(0,He.default)(),u=(0,a.createEngineStream)({engine:l}),d=this.addConnection(n,{tabId:i,apiType:tr,engine:l});(0,s.pipeline)(e,c,u,e,(e=>{var t;l.destroy(),d&&this.removeConnection(n,d),!e||null!==(t=e.message)&&void 0!==t&&t.match("Premature close")||y.default.error(e)})),r!==x.SubjectType.Internal&&this._notifyChainChangeForConnection({engine:l},n)}setupProviderConnectionCaip(e,t,r){}setupProviderEngineEip1193({origin:e,subjectType:t,sender:r,tabId:n,mainFrameOrigin:s}){const i=new o.JsonRpcEngine;i.push((0,Ge.default)({origin:e})),s&&i.push((0,Ve.default)({mainFrameOrigin:s})),i.push((0,O.createSelectedNetworkMiddleware)(this.controllerMessenger));{const e=(0,G.createQueuedRequestMiddleware)({enqueueRequest:this.queuedRequestController.enqueueRequest.bind(this.queuedRequestController),shouldEnqueueRequest:e=>se.methodsThatShouldBeEnqueued.includes(e.method),useRequestQueue:()=>!0});i.push(e)}const a=this.selectedNetworkController.getProviderAndBlockTracker(e),l=(0,p.default)(a),c=(0,g.default)(a);return c.events.on("notification",(e=>i.emit("notification",e))),n&&i.push((0,We.default)({tabId:n})),i.push((0,ze.default)({origin:e})),i.push(this.permissionLogController.createMiddleware()),e===Me.BaseUrl.Portfolio&&i.push((0,Et.createTxVerificationMiddleware)(this.networkController)),i.push((0,xt.default)()),i.push((0,jt.default)({getThrottledOriginState:this.appStateController.getThrottledOriginState.bind(this.appStateController),updateThrottledOriginState:this.appStateController.updateThrottledOriginState.bind(this.appStateController)})),i.push((0,Ue.createPPOMMiddleware)(this.ppomController,this.preferencesController,this.networkController,this.appStateController,this.accountsController,this.updateSecurityAlertResponse.bind(this))),i.push((0,yt.default)({getAccountType:this.getAccountType.bind(this),getDeviceModel:this.getDeviceModel.bind(this),getHDEntropyIndex:this.getHDEntropyIndex.bind(this),getHardwareTypeForMetric:this.getHardwareTypeForMetric.bind(this),snapAndHardwareMessenger:this.controllerMessenger.getRestricted({name:"SnapAndHardwareMessenger",allowedActions:["KeyringController:getKeyringForAccount","SnapController:get","AccountsController:getSelectedAccount"]}),appStateController:this.appStateController,metaMetricsController:this.metaMetricsController})),i.push((0,qe.createUnsupportedMethodMiddleware)()),i.push((0,qe.createEthAccountsMethodMiddleware)({getAccounts:this.getPermittedAccounts.bind(this,e)})),t!==x.SubjectType.Internal&&i.push(this.permissionController.createPermissionMiddleware({origin:e})),t===x.SubjectType.Website&&i.push((0,Je.default)({location:r.url,registerOnboarding:this.onboardingController.registerOnboarding})),i.push((0,It.default)({messenger:this.controllerMessenger.getRestricted({name:"EvmMethodsToNonEvmAccountFilterMessenger",allowedActions:["AccountsController:getSelectedAccount"]})})),i.push((0,qe.createEip1193MethodMiddleware)({subjectType:t,addSubjectMetadata:this.subjectMetadataController.addSubjectMetadata.bind(this.subjectMetadataController),metamaskState:this.getState(),getProviderState:this.getProviderState.bind(this),getUnlockPromise:this.appStateController.getUnlockPromise.bind(this.appStateController),handleWatchAssetRequest:this.handleWatchAssetRequest.bind(this),requestUserApproval:this.approvalController.addAndShowApprovalRequest.bind(this.approvalController),sendMetrics:this.metaMetricsController.trackEvent.bind(this.metaMetricsController),getAccounts:this.getPermittedAccounts.bind(this,e),getCaip25PermissionFromLegacyPermissionsForOrigin:this.getCaip25PermissionFromLegacyPermissions.bind(this,e),getPermissionsForOrigin:this.permissionController.getPermissions.bind(this.permissionController,e),requestPermittedChainsPermissionIncrementalForOrigin:t=>this.requestPermittedChainsPermissionIncremental({...t,origin:e}),requestPermissionsForOrigin:t=>this.permissionController.requestPermissions({origin:e},t),revokePermissionsForOrigin:t=>{try{this.permissionController.revokePermissions({[e]:t})}catch(e){console.log(e)}},getCaveat:({target:t,caveatType:r})=>{try{return this.permissionController.getCaveat(e,t,r)}catch(e){if(!(e instanceof x.PermissionDoesNotExistError))throw e}return undefined},setActiveNetwork:async t=>{await this.networkController.setActiveNetwork(t),this.permissionController.hasPermission(e,ne.Caip25EndowmentPermissionName)&&this.selectedNetworkController.setNetworkClientIdForDomain(e,t)},addNetwork:this.networkController.addNetwork.bind(this.networkController),updateNetwork:this.networkController.updateNetwork.bind(this.networkController),getNetworkConfigurationByChainId:this.networkController.getNetworkConfigurationByChainId.bind(this.networkController),setTokenNetworkFilter:e=>{const{tokenNetworkFilter:t}=this.preferencesController.getPreferences();e&&1===Object.keys(t).length&&this.preferencesController.setPreference("tokenNetworkFilter",{[e]:!0})},getCurrentChainIdForDomain:e=>{const t=this.selectedNetworkController.getNetworkClientIdForDomain(e),{chainId:r}=this.networkController.getNetworkConfigurationByNetworkClientId(t);return r},getWeb3ShimUsageState:this.alertController.getWeb3ShimUsageState.bind(this.alertController),setWeb3ShimUsageRecorded:this.alertController.setWeb3ShimUsageRecorded.bind(this.alertController),updateCaveat:this.permissionController.updateCaveat.bind(this.permissionController,e),hasApprovalRequestsForOrigin:()=>this.approvalController.has({origin:e}),rejectApprovalRequestsForOrigin:()=>this.rejectOriginPendingApprovals(e)})),i.push((0,U.createSnapsMethodMiddleware)(t===x.SubjectType.Snap,{clearSnapState:this.controllerMessenger.call.bind(this.controllerMessenger,"SnapController:clearSnapState",e),getUnlockPromise:this.appStateController.getUnlockPromise.bind(this.appStateController),getSnaps:this.controllerMessenger.call.bind(this.controllerMessenger,"SnapController:getPermitted",e),requestPermissions:async t=>await this.permissionController.requestPermissions({origin:e},t),getPermissions:this.permissionController.getPermissions.bind(this.permissionController,e),getSnapFile:this.controllerMessenger.call.bind(this.controllerMessenger,"SnapController:getFile",e),getSnapState:this.controllerMessenger.call.bind(this.controllerMessenger,"SnapController:getSnapState",e),updateSnapState:this.controllerMessenger.call.bind(this.controllerMessenger,"SnapController:updateSnapState",e),installSnaps:this.controllerMessenger.call.bind(this.controllerMessenger,"SnapController:install",e),invokeSnap:this.permissionController.executeRestrictedMethod.bind(this.permissionController,e,de.RestrictedMethods.wallet_snap),getIsLocked:()=>!this.appStateController.isUnlocked(),getInterfaceState:(...t)=>this.controllerMessenger.call("SnapInterfaceController:getInterface",e,...t).state,getInterfaceContext:(...t)=>this.controllerMessenger.call("SnapInterfaceController:getInterface",e,...t).context,createInterface:this.controllerMessenger.call.bind(this.controllerMessenger,"SnapInterfaceController:createInterface",e),updateInterface:this.controllerMessenger.call.bind(this.controllerMessenger,"SnapInterfaceController:updateInterface",e),resolveInterface:this.controllerMessenger.call.bind(this.controllerMessenger,"SnapInterfaceController:resolveInterface",e),getSnap:this.controllerMessenger.call.bind(this.controllerMessenger,"SnapController:get"),getAllSnaps:this.controllerMessenger.call.bind(this.controllerMessenger,"SnapController:getAll"),getCurrencyRate:e=>{const t=this.multichainRatesController.state.rates[e],{fiatCurrency:r}=this.multichainRatesController.state;return t?{...t,currency:r}:undefined},getEntropySources:()=>{const e=this.controllerMessenger.call("KeyringController:getState");return e.keyrings.map(((t,r)=>t.type===h.KeyringTypes.hd?{id:e.keyringsMetadata[r].id,name:e.keyringsMetadata[r].name,type:"mnemonic",primary:0===r}:null)).filter(Boolean)},hasPermission:this.permissionController.hasPermission.bind(this.permissionController,e),scheduleBackgroundEvent:t=>this.controllerMessenger.call("CronjobController:scheduleBackgroundEvent",{...t,snapId:e}),cancelBackgroundEvent:this.controllerMessenger.call.bind(this.controllerMessenger,"CronjobController:cancelBackgroundEvent",e),getBackgroundEvents:this.controllerMessenger.call.bind(this.controllerMessenger,"CronjobController:getBackgroundEvents",e),getNetworkConfigurationByChainId:this.controllerMessenger.call.bind(this.controllerMessenger,"NetworkController:getNetworkConfigurationByChainId"),getNetworkClientById:this.controllerMessenger.call.bind(this.controllerMessenger,"NetworkController:getNetworkClientById"),handleSnapRpcRequest:t=>this.handleSnapRequest({...t,origin:e}),getAllowedKeyringMethods:(0,Re.keyringSnapPermissionsBuilder)(this.subjectMetadataController,e)})),i.push(l),i.push(c.middleware),i.push(this.metamaskMiddleware),i.push((0,u.providerAsMiddleware)(a.provider)),i}setupProviderEngineCaip({origin:e,sender:t,subjectType:r,tabId:n}){return null}setupPublicConfig(e){const t=(0,c.storeAsStream)(this.publicConfigStore);(0,s.pipeline)(t,e,(e=>{var r;t.destroy(),!e||null!==(r=e.message)&&void 0!==r&&r.match("Premature close")||y.default.error(e)}))}addConnection(e,{tabId:t,apiType:r,engine:n}){if(e===ge.ORIGIN_METAMASK)return null;this.connections[e]||(this.connections[e]={});const s=(0,T.nanoid)();return this.connections[e][s]={tabId:t,apiType:r,engine:n},s}removeConnection(e,t){const r=this.connections[e];r&&(delete r[t],0===Object.keys(r).length&&delete this.connections[e])}removeAllConnections(e){const t=this.connections[e];t&&Object.keys(t).forEach((t=>{this.removeConnection(e,t)}))}notifyConnections(e,t,r){const n=this.connections[e];n&&Object.values(n).forEach((e=>{r&&e.apiType!==r||e.engine&&e.engine.emit("notification",t)}))}notifyAllConnections(e,t){const r="function"==typeof e?t=>e(t):()=>e;Object.keys(this.connections).forEach((e=>{Object.values(this.connections[e]).forEach((async n=>{if(!t||n.apiType===t)try{this.notifyConnection(n,await r(e))}catch(e){console.error(e)}}))}))}notifyConnection(e,t){try{e.engine&&e.engine.emit("notification",t)}catch(e){console.error(e)}}async _onKeyringControllerUpdate(e){const{keyrings:t}=e,r=t.reduce(((e,{accounts:t})=>e.concat(t)),[]).filter(Bt.isEthAddress);r.length&&this.accountTrackerController.syncWithAddresses(r)}_onUnlock(){this.unMarkPasswordForgotten(),this.emit("unlock")}_onLock(){this.emit("lock")}_onStateUpdate(e){this.isClientOpenAndUnlocked=e.isUnlocked&&this._isClientOpen,this._notifyChainChange()}_onAccountRemoved(e){this.removeAllAccountPermissions(e)}privateSendUpdate(){this.emit("update",this.getState())}isUnlocked(){return this.keyringController.state.isUnlocked}getExternalPendingTransactions(e){return this.smartTransactionsController.getTransactions({addressFrom:e,status:"pending"})}async initializeChainlist(){const e=`cachedFetch:${ae.CHAIN_SPEC_URL}`,{cachedResponse:t}=await(0,ye.getStorageItem)(e)||{};t||await(0,ye.setStorageItem)(e,{cachedResponse:(0,v.rawChainData)(),cachedTime:0})}async getPendingNonce(e,t){const{nonceDetails:r,releaseLock:n}=await this.txController.getNonceLock(e,t),s=r.params.highestSuggested;return n(),s}async getNextNonce(e,t){const r=await this.txController.getNonceLock(e,t);return r.releaseLock(),r.nextNonce}throwTestError(e){setTimeout((()=>{const t=new Error(e);throw t.name="TestError",t}))}_addBridgeStatusControllerListeners(){this.controllerMessenger.subscribe("BridgeStatusController:bridgeTransactionComplete",(e=>(0,Ft.handleBridgeTransactionComplete)(e,{backgroundState:this.getState(),trackEvent:this.metaMetricsController.trackEvent.bind(this.metaMetricsController)}))),this.controllerMessenger.subscribe("BridgeStatusController:bridgeTransactionFailed",(e=>(0,Ft.handleBridgeTransactionFailed)(e,{backgroundState:this.getState(),trackEvent:this.metaMetricsController.trackEvent.bind(this.metaMetricsController)}))),this.controllerMessenger.subscribe("TransactionController:transactionFailed",(({transactionMeta:e})=>{const{type:t,status:r}=e,n=t===Y.TransactionType.bridge,s=[Y.TransactionStatus.approved,Y.TransactionStatus.signed].includes(r);n&&!s&&(0,Ft.handleTransactionFailedTypeBridge)({transactionMeta:e},{backgroundState:this.getState(),trackEvent:this.metaMetricsController.trackEvent.bind(this.metaMetricsController)})}))}getTransactionMetricsRequest(){return{...{createEventFragment:this.metaMetricsController.createEventFragment.bind(this.metaMetricsController),finalizeEventFragment:this.metaMetricsController.finalizeEventFragment.bind(this.metaMetricsController),getEventFragmentById:this.metaMetricsController.getEventFragmentById.bind(this.metaMetricsController),getParticipateInMetrics:()=>this.metaMetricsController.state.participateInMetaMetrics,trackEvent:this.metaMetricsController.trackEvent.bind(this.metaMetricsController),updateEventFragment:this.metaMetricsController.updateEventFragment.bind(this.metaMetricsController),getAccountBalance:(e,t)=>{var r;return null===(r=this.accountTrackerController.state.accountsByChainId)||void 0===r||null===(r=r[t])||void 0===r||null===(r=r[e])||void 0===r?void 0:r.balance},getAccountType:this.getAccountType.bind(this),getDeviceModel:this.getDeviceModel.bind(this),getHardwareTypeForMetric:this.getHardwareTypeForMetric.bind(this),getEIP1559GasFeeEstimates:this.gasFeeController.fetchGasFeeEstimates.bind(this.gasFeeController),getSelectedAddress:()=>this.accountsController.getSelectedAccount().address,getTokenStandardAndDetails:this.getTokenStandardAndDetails.bind(this),getTransaction:e=>this.txController.state.transactions.find((t=>t.id===e)),getIsSmartTransaction:()=>(0,Ae.getIsSmartTransaction)(this._getMetaMaskState()),getSmartTransactionByMinedTxHash:e=>this.smartTransactionsController.getSmartTransactionByMinedTxHash(e),getMethodData:e=>{if(!e)return null;const{knownMethodData:t,use4ByteResolution:r}=this.preferencesController.state,n=(0,ct.addHexPrefix)(e);return(0,ct.getMethodDataName)(t,r,n,this.preferencesController.addKnownMethodData.bind(this.preferencesController),this.provider)},getIsConfirmationAdvancedDetailsOpen:()=>this.preferencesController.state.preferences.showConfirmationAdvancedDetails,getHDEntropyIndex:this.getHDEntropyIndex.bind(this)},snapAndHardwareMessenger:this.controllerMessenger.getRestricted({name:"SnapAndHardwareMessenger",allowedActions:["KeyringController:getKeyringForAccount","SnapController:get","AccountsController:getSelectedAccount"]}),provider:this.provider}}toggleExternalServices(e){this.preferencesController.toggleExternalServices(e),this.tokenListController.updatePreventPollingOnNetworkRestart(!e),e?(this.tokenDetectionController.enable(),this.gasFeeController.enableNonRPCGasFeeApis()):(this.tokenDetectionController.disable(),this.gasFeeController.disableNonRPCGasFeeApis())}async setLedgerTransportPreference(e){const t=window.navigator.hid?ce.LedgerTransportTypes.webhid:ce.LedgerTransportTypes.u2f;return null!=e&&e.updateTransportMethod?e.updateTransportMethod(t).catch((e=>{throw e})):undefined}recordFirstTimeInfo(e){if(!("firstTimeInfo"in e)){const t="12.16.1";e.firstTimeInfo={version:t,date:Date.now()}}}set isClientOpen(e){this._isClientOpen=e}onClientClosed(){try{this.gasFeeController.stopAllPolling(),this.currencyRateController.stopAllPolling(),this.tokenRatesController.stopAllPolling(),this.tokenDetectionController.stopAllPolling(),this.tokenListController.stopAllPolling(),this.tokenBalancesController.stopAllPolling(),this.appStateController.clearPollingTokens(),this.accountTrackerController.stopAllPolling()}catch(e){console.error(e)}}onEnvironmentTypeClosed(e){const t=ge.POLLING_TOKEN_ENVIRONMENT_TYPES[e];this.appStateController.state[t].forEach((e=>{this.gasFeeController.stopPollingByPollingToken(e),this.currencyRateController.stopPollingByPollingToken(e),this.tokenRatesController.stopPollingByPollingToken(e),this.tokenDetectionController.stopPollingByPollingToken(e),this.tokenListController.stopPollingByPollingToken(e),this.tokenBalancesController.stopPollingByPollingToken(e),this.accountTrackerController.stopPollingByPollingToken(e),this.appStateController.removePollingToken(e,t)}))}safelistPhishingDomain(e){return this.metaMetricsController.trackEvent({category:fe.MetaMetricsEventCategory.Phishing,event:fe.MetaMetricsEventName.ProceedAnywayClicked,properties:{url:e,referrer:{url:e}}}),this.phishingController.bypass(e)}async backToSafetyPhishingWarning(){this.metaMetricsController.trackEvent({category:fe.MetaMetricsEventCategory.Navigation,event:fe.MetaMetricsEventName.PortfolioLinkClicked,properties:{location:"phishing_page",text:"Back to safety"}}),await this.platform.switchToAnotherURL(undefined,"https://portfolio.metamask.io/?metamaskEntry=phishing_page_portfolio_button")}setLocked(){return this.keyringController.setLocked()}rejectAllPendingApprovals(){(0,Ut.rejectAllApprovals)({approvalController:this.approvalController,deleteInterface:e=>this.controllerMessenger.call("SnapInterfaceController:deleteInterface",e)})}async getCode(e,t){const{provider:r}=this.networkController.getNetworkClientById(t);return await r.request({method:"eth_getCode",params:[e]})}async _onAccountChange(e){const t=(0,gt.getPermittedAccountsByOrigin)(this.permissionController.state);for(const[r,n]of t.entries())n.includes(e)&&this._notifyAccountsChange(r,n);await this.txController.updateIncomingTransactions()}_notifyAccountsChange(e,t){this.notifyConnections(e,{method:gt.NOTIFICATION_NAMES.accountsChanged,params:t.length<2?t:this.getPermittedAccounts(e)},tr),this.permissionLogController.updateAccountsHistory(e,t)}async _notifyAuthorizationChange(e,t){this.notifyConnections(e,{method:gt.NOTIFICATION_NAMES.sessionChanged,params:{sessionScopes:(0,ne.getSessionScopes)(t)}},rr)}async _notifyChainChange(){this.notifyAllConnections((async e=>({method:gt.NOTIFICATION_NAMES.chainChanged,params:await this.getProviderNetworkState(e)})),tr)}async _notifyChainChangeForConnection(e,t){this.notifyConnection(e,{method:gt.NOTIFICATION_NAMES.chainChanged,params:await this.getProviderNetworkState(t)})}async _onFinishedTransaction(e){[Y.TransactionStatus.confirmed,Y.TransactionStatus.failed].includes(e.status)&&(await this._createTransactionNotifcation(e),await this._updateNFTOwnership(e),this._trackTransactionFailure(e),await this.tokenBalancesController.updateBalancesByChainId({chainId:e.chainId}))}async _createTransactionNotifcation(e){const{chainId:t}=e;let r={};if(t){var n,s;const e=null===(n=this.networkController.state.networkConfigurationsByChainId)||void 0===n?void 0:n[t];r={blockExplorerUrl:null==e||null===(s=e.blockExplorerUrls)||void 0===s?void 0:s[null==e?void 0:e.defaultBlockExplorerUrlIndex]}}try{await this.platform.showTransactionNotification(e,r)}catch(e){y.default.error("Failed to create transaction notification",e)}}async _updateNFTOwnership(e){const{type:t,txParams:r,chainId:n,txReceipt:s}=e,i=this.accountsController.getSelectedAccount().address,{allNfts:o}=this.nftController.state,a=null==s?void 0:s.logs,l=t===Y.TransactionType.contractInteraction&&a,c=(t===Y.TransactionType.tokenMethodTransferFrom||t===Y.TransactionType.tokenMethodSafeTransferFrom)&&r!==undefined;if(l||c)if(c){var u;const{data:e,to:t,from:s}=r,i=(0,we.parseStandardTokenTransactionData)(e),a=(0,be.getTokenIdParam)(i)??(0,Ce.getTokenValueParam)(i),l=null==o||null===(u=o[s])||void 0===u||null===(u=u[n])||void 0===u?void 0:u.find((({address:e,tokenId:r})=>(0,ke.isEqualCaseInsensitive)(e,t)&&r===a));l&&this.nftController.checkAndUpdateSingleNftOwnershipStatus(l,!1,{userAddress:s})}else{const e=a.map((e=>{const t=e.topics&&e.topics[0]===Pe.TRANSFER_SINFLE_LOG_TOPIC_HASH,r=e.topics&&e.topics[0]===Pe.TOKEN_TRANSFER_LOG_TOPIC_HASH;let n;return t&&(n=e.topics&&e.topics[3]&&e.topics[3].match(null==i?void 0:i.slice(2))),r&&(n=e.topics&&e.topics[2]&&e.topics[2].match(null==i?void 0:i.slice(2))),{isERC1155NftTransfer:t,isERC721NftTransfer:r,isTransferToSelectedAddress:n,...e}}));if(0!==e.length){const t=[];e.forEach((e=>{if(e.isTransferToSelectedAddress&&(e.isERC1155NftTransfer||e.isERC721NftTransfer)){let r;r=e.isERC1155NftTransfer?new J.Interface(X.abiERC1155):new J.Interface(X.abiERC721);try{const n=r.parseLog({data:e.data,topics:e.topics});t.push({contract:e.address,...n})}catch(e){}}}));const r=[],s=[];t.forEach((e=>{var t;const a=(0,be.getTokenIdParam)(e),l=null==o||null===(t=o[i])||void 0===t||null===(t=t[n])||void 0===t?void 0:t.find((({address:t,tokenId:r})=>(0,ke.isEqualCaseInsensitive)(t,e.contract)&&r===a));l?r.push(l):s.push({tokenId:a,...e})}));const a=r.map((async e=>this.nftController.checkAndUpdateSingleNftOwnershipStatus(e,!1,{selectedAddress:i})));await Promise.allSettled(a);const l=s.map((async e=>this.nftController.addNft(e.contract,e.tokenId)));await Promise.allSettled(l)}}}_trackTransactionFailure(e){var t;const{txReceipt:r}=e,n=this.getState();r&&"0x0"===r.status&&this.metaMetricsController.trackEvent({event:"Tx Status Update: On-Chain Failure",category:fe.MetaMetricsEventCategory.Background,properties:{action:"Transactions",errorMessage:null===(t=e.simulationFails)||void 0===t?void 0:t.reason,numberOfTokens:n.tokens.length,numberOfAccounts:Object.keys(n.accounts).length}},{matomoEvent:!0})}_onUserOperationAdded(e){const t=this.txController.state.transactions.find((t=>t.id===e.id));t&&(t.type===Y.TransactionType.swap?this.controllerMessenger.publish("TransactionController:transactionNewSwap",{transactionMeta:t}):t.type===Y.TransactionType.swapApproval&&this.controllerMessenger.publish("TransactionController:transactionNewSwapApproval",{transactionMeta:t}))}_onUserOperationTransactionUpdated(e){const t={...e,txParams:{...e.txParams,from:this.accountsController.getSelectedAccount().address}};this.txController.state.transactions.some((e=>e.id===t.id))||this.txController.update((e=>{e.transactions.push(t)})),this.txController.updateTransaction(t,"Generated from user operation"),this.controllerMessenger.publish("TransactionController:transactionStatusUpdated",{transactionMeta:t})}_getMetaMaskState(){return{metamask:this.getState()}}_getConfigForRemoteFeatureFlagRequest(){return{distribution:sr.main||$.DistributionType.Main,environment:nr.production||$.EnvironmentType.Development}}}async function ar(e,t){var r,n,s,i,o;const a=null===(r=this.opts.overrides)||void 0===r?void 0:r.keyrings;let l=null;switch(e.name){case ce.HardwareDeviceNames.trezor:l=(null==a||null===(n=a.trezor)||void 0===n?void 0:n.type)||b.TrezorKeyring.type;break;case ce.HardwareDeviceNames.oneKey:l=(null==a||null===(s=a.oneKey)||void 0===s?void 0:s.type)||(null===b.OneKeyKeyring||void 0===b.OneKeyKeyring?void 0:b.OneKeyKeyring.type);break;case ce.HardwareDeviceNames.ledger:l=(null==a||null===(i=a.ledger)||void 0===i?void 0:i.type)||k.LedgerKeyring.type;break;case ce.HardwareDeviceNames.qr:l=C.MetaMaskKeyring.type;break;case ce.HardwareDeviceNames.lattice:l=(null==a||null===(o=a.lattice)||void 0===o?void 0:o.type)||w.default.type;break;default:throw new Error("MetamaskController:#withKeyringForDevice - Unknown device")}return this.keyringController.withKeyring({type:l},(async({keyring:r})=>{if(e.hdPath&&r.setHdPath&&r.setHdPath(e.hdPath),e.name===ce.HardwareDeviceNames.lattice&&(r.appName="MetaMask"),e.name===ce.HardwareDeviceNames.trezor||e.name===ce.HardwareDeviceNames.oneKey){const e=r.getModel();this.appStateController.setTrezorModel(e)}return r.network=(0,Ee.getProviderConfig)({metamask:this.networkController.state}).type,await t(r)}),{createIfMissing:!0})}function lr(e,t){const r=er(ir,this,cr).call(this,t),n=er(ir,this,cr).call(this,e);r!==n&&this.tokenListController.updatePreventPollingOnNetworkRestart(!n)}function cr(e){const{useTokenDetection:t,useTransactionSimulations:r,preferences:n}=e??{},{petnamesEnabled:s}=n??{};return t||s||r}function ur(){const e=er(ir,this,pr).call(this);return this.networkController.getNetworkClientById(e).configuration.chainId}function dr(){const e=this.networkController.state.networkConfigurationsByChainId;return Object.keys(e)}function hr(){const e=er(ir,this,dr).call(this).filter((e=>this.preferencesController.state.incomingTransactionsPreferences[e]));e.length>0&&(this.txController.stopIncomingTransactionPolling(),this.txController.startIncomingTransactionPolling(e))}function pr(){return this.networkController.state.selectedNetworkClientId}function gr({existingControllers:e,initFunctions:t,initState:r}){const n={getFlatState:this.getState.bind(this),getGlobalChainId:er(ir,this,ur).bind(this),getPermittedAccounts:this.getPermittedAccounts.bind(this),getProvider:()=>this.provider,getStateUI:this._getMetaMaskState.bind(this),getTransactionMetricsRequest:this.getTransactionMetricsRequest.bind(this),offscreenPromise:this.offscreenPromise,persistedState:r,removeAllConnections:this.removeAllConnections.bind(this),setupUntrustedCommunicationEip1193:this.setupUntrustedCommunicationEip1193.bind(this),showNotification:this.platform._showNotification,getMetaMetricsId:this.metaMetricsController.getMetaMetricsId.bind(this.metaMetricsController),trackEvent:this.metaMetricsController.trackEvent.bind(this.metaMetricsController)};return(0,zt.initControllers)({baseControllerMessenger:this.controllerMessenger,existingControllers:e,initFunctions:t,initRequest:n})}r.default=or}).call(this)}).call(this,e("buffer").Buffer)}}},{package:"$root$",file:"app/scripts/metamask-controller.js"}],[1880,{"./abi":1879},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){n===undefined&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){n===undefined&&(n=r),e[n]=t[r]}),s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(r,"__esModule",{value:!0}),s(e("./abi"),r)}}},{package:"@metamask/eth-trezor-keyring>@metamask/eth-sig-util>@metamask/abi-utils",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@metamask/abi-utils/dist/types/index.js"}],[1881,{"@metamask/utils":2950},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.padEnd=r.padStart=r.set=void 0;const n=e("@metamask/utils");r.set=(e,t,r)=>(0,n.concatBytes)([e.subarray(0,r),t,e.subarray(r+t.length)]);r.padStart=(e,t=32)=>{const r=new Uint8Array(Math.max(t-e.length,0)).fill(0);return(0,n.concatBytes)([r,e])};r.padEnd=(e,t=32)=>{const r=new Uint8Array(Math.max(t-e.length,0)).fill(0);return(0,n.concatBytes)([e,r])}}}},{package:"@metamask/eth-trezor-keyring>@metamask/eth-sig-util>@metamask/abi-utils",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@metamask/abi-utils/dist/utils/buffer.js"}],[1882,{"./buffer":1881},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){n===undefined&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){n===undefined&&(n=r),e[n]=t[r]}),s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(r,"__esModule",{value:!0}),s(e("./buffer"),r)}}},{package:"@metamask/eth-trezor-keyring>@metamask/eth-sig-util>@metamask/abi-utils",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@metamask/abi-utils/dist/utils/index.js"}],[1883,{"./utils":1888,"@scure/base":3027,buffer:4074,tweetnacl:5616},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){(function(t){(function(){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){n===undefined&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){n===undefined&&(n=r),e[n]=t[r]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return s(t,e),t};Object.defineProperty(r,"__esModule",{value:!0}),r.getEncryptionPublicKey=r.decryptSafely=r.decrypt=r.encryptSafely=r.encrypt=void 0;const o=e("@scure/base"),a=i(e("tweetnacl")),l=e("./utils");function c({publicKey:e,data:t,version:r}){if((0,l.isNullish)(e))throw new Error("Missing publicKey parameter");if((0,l.isNullish)(t))throw new Error("Missing data parameter");if((0,l.isNullish)(r))throw new Error("Missing version parameter");if("x25519-xsalsa20-poly1305"===r){if("string"!=typeof t)throw new Error("Message data must be given as a string");const r=a.box.keyPair();let n;try{n=o.base64.decode(e)}catch(e){throw new Error("Bad public key")}const s=o.utf8.decode(t),i=a.randomBytes(a.box.nonceLength),l=a.box(s,i,n,r.secretKey);return{version:"x25519-xsalsa20-poly1305",nonce:o.base64.encode(i),ephemPublicKey:o.base64.encode(r.publicKey),ciphertext:o.base64.encode(l)}}throw new Error("Encryption type/version not supported")}function u({encryptedData:e,privateKey:r}){if((0,l.isNullish)(e))throw new Error("Missing encryptedData parameter");if((0,l.isNullish)(r))throw new Error("Missing privateKey parameter");if("x25519-xsalsa20-poly1305"===e.version){const n=t.from(r,"hex"),s=a.box.keyPair.fromSecretKey(n).secretKey,i=o.base64.decode(e.nonce),l=o.base64.decode(e.ciphertext),c=o.base64.decode(e.ephemPublicKey),u=a.box.open(l,i,c,s);try{if(!u)throw new Error;const e=o.utf8.encode(u);if(!e)throw new Error;return e}catch(e){if(e&&"string"==typeof e.message&&e.message.length)throw new Error(`Decryption failed: ${e.message}`);throw new Error("Decryption failed.")}}throw new Error("Encryption type/version not supported.")}r.encrypt=c,r.encryptSafely=function({publicKey:e,data:r,version:n}){if((0,l.isNullish)(e))throw new Error("Missing publicKey parameter");if((0,l.isNullish)(r))throw new Error("Missing data parameter");if((0,l.isNullish)(n))throw new Error("Missing version parameter");if("object"==typeof r&&r&&"toJSON"in r)throw new Error("Cannot encrypt with toJSON property. Please remove toJSON property");const s={data:r,padding:""},i=t.byteLength(JSON.stringify(s),"utf-8")%2048;let o=0;return i>0&&(o=2048-i-16),s.padding="0".repeat(o),c({publicKey:e,data:JSON.stringify(s),version:n})},r.decrypt=u,r.decryptSafely=function({encryptedData:e,privateKey:t}){if((0,l.isNullish)(e))throw new Error("Missing encryptedData parameter");if((0,l.isNullish)(t))throw new Error("Missing privateKey parameter");return JSON.parse(u({encryptedData:e,privateKey:t})).data},r.getEncryptionPublicKey=function(e){const r=t.from(e,"hex"),n=a.box.keyPair.fromSecretKey(r).publicKey;return o.base64.encode(n)}}).call(this)}).call(this,e("buffer").Buffer)}}},{package:"@metamask/eth-trezor-keyring>@metamask/eth-sig-util",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@metamask/eth-sig-util/dist/encryption.js"}],[1884,{"./encryption":1883,"./personal-sign":1885,"./sign-eip7702-authorization":1886,"./sign-typed-data":1887,"./utils":1888},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){n===undefined&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){n===undefined&&(n=r),e[n]=t[r]}),s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(r,"__esModule",{value:!0}),r.normalize=r.concatSig=void 0,s(e("./personal-sign"),r),s(e("./sign-typed-data"),r),s(e("./encryption"),r),s(e("./sign-eip7702-authorization"),r);var i=e("./utils");Object.defineProperty(r,"concatSig",{enumerable:!0,get:function(){return i.concatSig}}),Object.defineProperty(r,"normalize",{enumerable:!0,get:function(){return i.normalize}})}}},{package:"@metamask/eth-trezor-keyring>@metamask/eth-sig-util",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@metamask/eth-sig-util/dist/index.js"}],[1885,{"./utils":1888,"@ethereumjs/util":1896},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.extractPublicKey=r.recoverPersonalSignature=r.personalSign=void 0;const n=e("@ethereumjs/util"),s=e("./utils");function i(e,t){const r=(0,n.hashPersonalMessage)((0,s.legacyToBuffer)(e));return(0,s.recoverPublicKey)(r,t)}r.personalSign=function({privateKey:e,data:t}){if((0,s.isNullish)(t))throw new Error("Missing data parameter");if((0,s.isNullish)(e))throw new Error("Missing privateKey parameter");const r=(0,s.legacyToBuffer)(t),i=(0,n.hashPersonalMessage)(r),o=(0,n.ecsign)(i,e);return(0,s.concatSig)((0,n.toBuffer)(o.v),o.r,o.s)},r.recoverPersonalSignature=function({data:e,signature:t}){if((0,s.isNullish)(e))throw new Error("Missing data parameter");if((0,s.isNullish)(t))throw new Error("Missing signature parameter");const r=i(e,t),o=(0,n.publicToAddress)(r);return(0,n.bufferToHex)(o)},r.extractPublicKey=function({data:e,signature:t}){if((0,s.isNullish)(e))throw new Error("Missing data parameter");if((0,s.isNullish)(t))throw new Error("Missing signature parameter");return`0x${i(e,t).toString("hex")}`}}}},{package:"@metamask/eth-trezor-keyring>@metamask/eth-sig-util",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@metamask/eth-sig-util/dist/personal-sign.js"}],[1886,{"./utils":1888,"@ethereumjs/rlp":429,"@ethereumjs/util":1896,"@metamask/utils":2950,buffer:4074,"ethereum-cryptography/keccak":4300},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){(function(t){(function(){Object.defineProperty(r,"__esModule",{value:!0}),r.hashEIP7702Authorization=r.recoverEIP7702Authorization=r.signEIP7702Authorization=void 0;const n=e("@ethereumjs/rlp"),s=e("@ethereumjs/util"),i=e("@metamask/utils"),o=e("ethereum-cryptography/keccak"),a=e("./utils");function l(e){c(e);const r=(0,n.encode)(e),s=t.concat([t.from("05","hex"),r]);return t.from((0,o.keccak256)(s))}function c(e){if((0,a.isNullish)(e))throw new Error("Missing authorization parameter");const[t,r,n]=e;if((0,a.isNullish)(t))throw new Error("Missing chainId parameter");if((0,a.isNullish)(r))throw new Error("Missing contractAddress parameter");if((0,a.isNullish)(n))throw new Error("Missing nonce parameter")}r.signEIP7702Authorization=function({privateKey:e,authorization:t}){if(c(t),(0,a.isNullish)(e))throw new Error("Missing privateKey parameter");const r=l(t),{r:n,s:i,v:o}=(0,s.ecsign)(r,e),u=(0,s.toBuffer)(o);return(0,a.concatSig)(u,n,i)},r.recoverEIP7702Authorization=function({signature:e,authorization:t}){if(c(t),(0,a.isNullish)(e))throw new Error("Missing signature parameter");const r=l(t),n=(0,a.recoverPublicKey)(r,e),o=(0,s.publicToAddress)(n);return(0,i.bytesToHex)(o)},r.hashEIP7702Authorization=l}).call(this)}).call(this,e("buffer").Buffer)}}},{package:"@metamask/eth-trezor-keyring>@metamask/eth-sig-util",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@metamask/eth-sig-util/dist/sign-eip7702-authorization.js"}],[1887,{"./utils":1888,"@ethereumjs/util":1896,"@metamask/abi-utils":1865,"@metamask/abi-utils/dist/parsers":1874,"@metamask/abi-utils/dist/utils":1882,"@metamask/utils":2950,"ethereum-cryptography/keccak":4300},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.recoverTypedSignature=r.signTypedData=r.typedSignatureHash=r.TypedDataUtils=r.TYPED_MESSAGE_SCHEMA=r.SignTypedDataVersion=void 0;const n=e("@ethereumjs/util"),s=e("@metamask/abi-utils"),i=e("@metamask/abi-utils/dist/parsers"),o=e("@metamask/abi-utils/dist/utils"),a=e("@metamask/utils"),l=e("ethereum-cryptography/keccak"),c=e("./utils");var u;function d(e,t){if(!Object.keys(u).includes(e))throw new Error(`Invalid version: '${e}'`);if(t&&!t.includes(e))throw new Error(`SignTypedDataVersion not allowed: '${e}'. Allowed versions are: ${t.join(", ")}`)}function h(e,t){(0,a.assert)(null!==t,`Unable to encode value: Invalid number. Expected a valid number value, but received "${t}".`);const r=BigInt(t),n=(0,i.getLength)(e),s=BigInt(2)**BigInt(n)-BigInt(1);return(0,a.assert)(r>=-s&&r<=s,`Unable to encode value: Number "${t}" is out of range for type "${e}".`),r}function p(e){let t=BigInt(0);for(let r=0;r<e.length;r++){const n=BigInt(e.charCodeAt(r)-48);t*=BigInt(10),t+=n>=49?n-BigInt(49)+BigInt(10):n>=17?n-BigInt(17)+BigInt(10):n}return(0,o.padStart)((0,a.bigIntToBytes)(t),20)}function g(e,t,r,i,c){if(d(c,[u.V3,u.V4]),e[r]!==undefined)return["bytes32",c===u.V4&&null==i?"0x0000000000000000000000000000000000000000000000000000000000000000":(0,n.arrToBufArr)((0,l.keccak256)(f(r,i,e,c)))];if("function"===r)throw new Error('Unsupported or invalid type: "function"');if(i===undefined)throw new Error(`missing value for field ${t} of type ${r}`);if("address"===r){if("number"==typeof i)return["address",(0,o.padStart)((0,a.numberToBytes)(i),20)];if((0,a.isStrictHexString)(i))return["address",(0,a.add0x)(i)];if("string"==typeof i)return["address",p(i).subarray(0,20)]}if("bool"===r)return["bool",Boolean(i)];if("bytes"===r)return"number"==typeof i?i=(0,a.numberToBytes)(i):(0,a.isStrictHexString)(i)||"0x"===i?i=(0,a.hexToBytes)(i):"string"==typeof i&&(i=(0,a.stringToBytes)(i)),["bytes32",(0,n.arrToBufArr)((0,l.keccak256)(i))];if(r.startsWith("bytes")&&"bytes"!==r&&!r.includes("["))return"number"==typeof i?i<0?["bytes32",new Uint8Array(32)]:["bytes32",(0,a.bigIntToBytes)(BigInt(i))]:(0,a.isStrictHexString)(i)?["bytes32",(0,a.hexToBytes)(i)]:["bytes32",i];if(r.startsWith("int")&&!r.includes("[")){const e=h(r,i);return e>=BigInt(0)?["uint256",e]:["int256",e]}if("string"===r)return i="number"==typeof i?(0,a.numberToBytes)(i):(0,a.stringToBytes)(null!=i?i:""),["bytes32",(0,n.arrToBufArr)((0,l.keccak256)(i))];if(r.endsWith("]")){if(c===u.V3)throw new Error("Arrays are unimplemented in encodeData; use V4 extension");const o=r.slice(0,r.lastIndexOf("[")),a=i.map((r=>g(e,t,o,r,c)));return["bytes32",(0,n.arrToBufArr)((0,l.keccak256)((0,s.encode)(a.map((([e])=>e)),a.map((([,e])=>e)))))]}return[r,i]}function f(e,t,r,i){d(i,[u.V3,u.V4]);const o=["bytes32"],a=[k(e,r)];for(const n of r[e]){if(i===u.V3&&t[n.name]===undefined)continue;const[e,s]=g(r,n.name,n.type,t[n.name],i);o.push(e),a.push(s)}return(0,n.arrToBufArr)((0,s.encode)(o,a))}function m(e,t){let r="";const n=y(e,t);n.delete(e);const s=[e,...Array.from(n).sort()];for(const e of s){if(!t[e])throw new Error(`No type definition specified: ${e}`);r+=`${e}(${t[e].map((({name:e,type:t})=>`${t} ${e}`)).join(",")})`}return r}function y(e,t,r=new Set){if("string"!=typeof e)throw new Error(`Invalid findTypeDependencies input ${JSON.stringify(e)}`);const n=e.match(/^\w*/u);if([e]=n,r.has(e)||t[e]===undefined)return r;r.add(e);for(const n of t[e])y(n.type,t,r);return r}function b(e,t,r,s){d(s,[u.V3,u.V4]);const i=f(e,t,r,s),o=(0,l.keccak256)(i);return(0,n.arrToBufArr)(o)}function k(e,t){const r=(0,a.stringToBytes)(m(e,t));return(0,n.arrToBufArr)((0,l.keccak256)(r))}function w(e){const t={};for(const n in r.TYPED_MESSAGE_SCHEMA.properties)e[n]&&(t[n]=e[n]);return"types"in t&&(t.types=Object.assign({EIP712Domain:[]},t.types)),t}function v(e,t){d(t,[u.V3,u.V4]);const r=w(e),{domain:n}=r;return b("EIP712Domain",n,{EIP712Domain:r.types.EIP712Domain},t)}function C(e,t){if((0,i.isArrayType)(e)&&Array.isArray(t)){const[r]=(0,i.getArrayType)(e);return t.map((e=>C(r,e)))}if("address"===e){if((0,a.isStrictHexString)(t))return(0,o.padStart)((0,a.hexToBytes)(t).subarray(0,20),20);if(t instanceof Uint8Array)return(0,o.padStart)(t.subarray(0,20),20)}if("bool"===e)return Boolean(t);if(e.startsWith("bytes")&&"bytes"!==e){const r=(0,i.getByteLength)(e);if("number"==typeof t)return t<0?new Uint8Array:(0,a.numberToBytes)(t).subarray(0,r);if((0,a.isStrictHexString)(t))return(0,a.hexToBytes)(t).subarray(0,r);if(t instanceof Uint8Array)return t.subarray(0,r)}if(e.startsWith("uint")&&"number"==typeof t)return Math.abs(t);if(e.startsWith("int")&&"number"==typeof t){const r=(0,i.getLength)(e);return BigInt.asIntN(r,BigInt(t))}return t}function T(e,t){return t.map((t=>{if("string"==typeof t||"number"==typeof t||"bigint"==typeof t){const r=h(e,t);if(r>=BigInt(0))return(0,o.padStart)((0,a.bigIntToBytes)(r),32);const n=(0,i.getLength)(e),s=BigInt.asIntN(n,r);return(0,a.signedBigIntToBytes)(s,32)}return t}))}function S(e){const t=new Error("Expect argument to be non-empty array");if("object"!=typeof e||!("length"in e)||!e.length)throw t;const r=e.map((({name:e,type:t,value:r})=>{if("address[]"===t)return{name:e,type:"bytes32[]",value:(n=r,n.map((e=>"number"==typeof e?(0,o.padStart)((0,a.numberToBytes)(e),32):(0,a.isStrictHexString)(e)?(0,o.padStart)((0,a.hexToBytes)(e).subarray(0,32),32):e instanceof Uint8Array?(0,o.padStart)(e.subarray(0,32),32):e)))};var n;if(t.startsWith("int")&&(0,i.isArrayType)(t)){const[n,s]=(0,i.getArrayType)(t);return{name:e,type:`bytes32[${null!=s?s:""}]`,value:T(n,r)}}return{name:e,type:t,value:C(t,r)}})),u=r.map((e=>"bytes"!==e.type?e.value:(0,c.legacyToBuffer)(e.value))),d=r.map((e=>{if("function"===e.type)throw new Error('Unsupported or invalid type: "function"');return e.type})),h=e.map((e=>{if(!e.name)throw t;return`${e.type} ${e.name}`}));return(0,n.arrToBufArr)((0,l.keccak256)((0,s.encodePacked)(["bytes32","bytes32"],[(0,l.keccak256)((0,s.encodePacked)(["string[]"],[h],!0)),(0,l.keccak256)((0,s.encodePacked)(d,u,!0))])))}!function(e){e.V1="V1",e.V3="V3",e.V4="V4"}(u=r.SignTypedDataVersion||(r.SignTypedDataVersion={})),r.TYPED_MESSAGE_SCHEMA={type:"object",properties:{types:{type:"object",additionalProperties:{type:"array",items:{type:"object",properties:{name:{type:"string"},type:{type:"string"}},required:["name","type"]}}},primaryType:{type:"string"},domain:{type:"object"},message:{type:"object"}},required:["types","primaryType","domain","message"]},r.TypedDataUtils={encodeData:f,encodeType:m,findTypeDependencies:y,hashStruct:b,hashType:k,sanitizeData:w,eip712Hash:function(e,t){d(t,[u.V3,u.V4]);const r=w(e),s=[(0,a.hexToBytes)("1901")];return s.push(v(e,t)),"EIP712Domain"!==r.primaryType&&s.push(b(r.primaryType,r.message,r.types,t)),(0,n.arrToBufArr)((0,l.keccak256)((0,a.concatBytes)(s)))},eip712DomainHash:v},r.typedSignatureHash=function(e){const t=S(e);return(0,a.bytesToHex)(t)},r.signTypedData=function({privateKey:e,data:t,version:s}){if(d(s),(0,c.isNullish)(t))throw new Error("Missing data parameter");if((0,c.isNullish)(e))throw new Error("Missing private key parameter");const i=s===u.V1?S(t):r.TypedDataUtils.eip712Hash(t,s),o=(0,n.ecsign)(i,e);return(0,c.concatSig)((0,n.arrToBufArr)((0,a.bigIntToBytes)(o.v)),o.r,o.s)},r.recoverTypedSignature=function({data:e,signature:t,version:s}){if(d(s),(0,c.isNullish)(e))throw new Error("Missing data parameter");if((0,c.isNullish)(t))throw new Error("Missing signature parameter");const i=s===u.V1?S(e):r.TypedDataUtils.eip712Hash(e,s),o=(0,c.recoverPublicKey)(i,t),l=(0,n.publicToAddress)(o);return(0,a.bytesToHex)(l)}}}},{package:"@metamask/eth-trezor-keyring>@metamask/eth-sig-util",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@metamask/eth-sig-util/dist/sign-typed-data.js"}],[1888,{"@ethereumjs/util":1896,"@metamask/utils":2950,buffer:4074},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){(function(t){(function(){Object.defineProperty(r,"__esModule",{value:!0}),r.normalize=r.recoverPublicKey=r.concatSig=r.legacyToBuffer=r.isNullish=r.padWithZeroes=void 0;const n=e("@ethereumjs/util"),s=e("@metamask/utils");function i(e,t){if(""!==e&&!/^[a-f0-9]+$/iu.test(e))throw new Error(`Expected an unprefixed hex string. Received: ${e}`);if(t<0)throw new Error(`Expected a non-negative integer target length. Received: ${t}`);return String.prototype.padStart.call(e,t,"0")}function o(e){return null===e||e===undefined}r.padWithZeroes=i,r.isNullish=o,r.legacyToBuffer=function(e){return"string"!=typeof e||(0,n.isHexString)(e)?(0,n.toBuffer)(e):t.from(e)},r.concatSig=function(e,t,r){const o=(0,n.fromSigned)(t),a=(0,n.fromSigned)(r),l=(0,n.bufferToInt)(e),c=i((0,n.toUnsigned)(o).toString("hex"),64),u=i((0,n.toUnsigned)(a).toString("hex"),64),d=(0,s.remove0x)((0,s.numberToHex)(l));return(0,s.add0x)(c.concat(u,d))},r.recoverPublicKey=function(e,t){const r=(0,n.fromRpcSig)(t);return(0,n.ecrecover)(e,r.v,r.r,r.s)},r.normalize=function(e){if(o(e))return undefined;if("number"==typeof e){if(e<0)return"0x";const t=(0,s.numberToBytes)(e);e=(0,s.bytesToHex)(t)}if("string"!=typeof e){let t="eth-sig-util.normalize() requires hex string or integer input.";throw t+=` received ${typeof e}: ${e}`,new Error(t)}return(0,s.add0x)(e.toLowerCase())}}).call(this)}).call(this,e("buffer").Buffer)}}},{package:"@metamask/eth-trezor-keyring>@metamask/eth-sig-util",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@metamask/eth-sig-util/dist/utils.js"}],[1889,{"./bytes":1892,"./constants":1893,"./helpers":1895,"./internal":1897,"@ethereumjs/rlp":429,buffer:4074,"ethereum-cryptography/keccak":4300,"ethereum-cryptography/secp256k1":4317,"ethereum-cryptography/utils":4319},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){(function(t){(function(){Object.defineProperty(r,"__esModule",{value:!0}),r.accountBodyToRLP=r.accountBodyToSlim=r.accountBodyFromSlim=r.isZeroAddress=r.zeroAddress=r.importPublic=r.privateToAddress=r.privateToPublic=r.publicToAddress=r.pubToAddress=r.isValidPublic=r.isValidPrivate=r.generateAddress2=r.generateAddress=r.isValidChecksumAddress=r.toChecksumAddress=r.isValidAddress=r.Account=void 0;const n=e("@ethereumjs/rlp"),s=e("ethereum-cryptography/keccak"),i=e("ethereum-cryptography/secp256k1"),o=e("ethereum-cryptography/utils"),a=e("./bytes"),l=e("./constants"),c=e("./helpers"),u=e("./internal"),d=BigInt(0);class h{constructor(e=d,t=d,r=l.KECCAK256_RLP,n=l.KECCAK256_NULL){this.nonce=e,this.balance=t,this.storageRoot=r,this.codeHash=n,this._validate()}static fromAccountData(e){const{nonce:t,balance:r,storageRoot:n,codeHash:s}=e;return new h(t!==undefined?(0,a.bufferToBigInt)((0,a.toBuffer)(t)):undefined,r!==undefined?(0,a.bufferToBigInt)((0,a.toBuffer)(r)):undefined,n!==undefined?(0,a.toBuffer)(n):undefined,s!==undefined?(0,a.toBuffer)(s):undefined)}static fromRlpSerializedAccount(e){const t=(0,a.arrToBufArr)(n.RLP.decode(Uint8Array.from(e)));if(!Array.isArray(t))throw new Error("Invalid serialized account input. Must be array");return this.fromValuesArray(t)}static fromValuesArray(e){const[t,r,n,s]=e;return new h((0,a.bufferToBigInt)(t),(0,a.bufferToBigInt)(r),n,s)}_validate(){if(this.nonce<d)throw new Error("nonce must be greater than zero");if(this.balance<d)throw new Error("balance must be greater than zero");if(32!==this.storageRoot.length)throw new Error("storageRoot must have a length of 32");if(32!==this.codeHash.length)throw new Error("codeHash must have a length of 32")}raw(){return[(0,a.bigIntToUnpaddedBuffer)(this.nonce),(0,a.bigIntToUnpaddedBuffer)(this.balance),this.storageRoot,this.codeHash]}serialize(){return t.from(n.RLP.encode((0,a.bufArrToArr)(this.raw())))}isContract(){return!this.codeHash.equals(l.KECCAK256_NULL)}isEmpty(){return this.balance===d&&this.nonce===d&&this.codeHash.equals(l.KECCAK256_NULL)}}r.Account=h;r.isValidAddress=function(e){try{(0,c.assertIsString)(e)}catch(e){return!1}return/^0x[0-9a-fA-F]{40}$/.test(e)};r.toChecksumAddress=function(e,r){(0,c.assertIsHexString)(e);const n=(0,u.stripHexPrefix)(e).toLowerCase();let i="";if(r!==undefined){i=(0,a.bufferToBigInt)((0,a.toBuffer)(r)).toString()+"0x"}const l=t.from(i+n,"utf8"),d=(0,o.bytesToHex)((0,s.keccak256)(l));let h="0x";for(let e=0;e<n.length;e++)parseInt(d[e],16)>=8?h+=n[e].toUpperCase():h+=n[e];return h};r.isValidChecksumAddress=function(e,t){return(0,r.isValidAddress)(e)&&(0,r.toChecksumAddress)(e,t)===e};r.generateAddress=function(e,r){return(0,c.assertIsBuffer)(e),(0,c.assertIsBuffer)(r),(0,a.bufferToBigInt)(r)===BigInt(0)?t.from((0,s.keccak256)(n.RLP.encode((0,a.bufArrToArr)([e,null])))).slice(-20):t.from((0,s.keccak256)(n.RLP.encode((0,a.bufArrToArr)([e,r])))).slice(-20)};r.generateAddress2=function(e,r,n){if((0,c.assertIsBuffer)(e),(0,c.assertIsBuffer)(r),(0,c.assertIsBuffer)(n),20!==e.length)throw new Error("Expected from to be of length 20");if(32!==r.length)throw new Error("Expected salt to be of length 32");const i=(0,s.keccak256)(t.concat([t.from("ff","hex"),e,r,(0,s.keccak256)(n)]));return(0,a.toBuffer)(i).slice(-20)};r.isValidPrivate=function(e){return i.secp256k1.utils.isValidPrivateKey(e)};r.isValidPublic=function(e,r=!1){if((0,c.assertIsBuffer)(e),64===e.length)try{return i.secp256k1.ProjectivePoint.fromHex(t.concat([t.from([4]),e])),!0}catch(e){return!1}if(!r)return!1;try{return i.secp256k1.ProjectivePoint.fromHex(e),!0}catch(e){return!1}};r.pubToAddress=function(e,r=!1){if((0,c.assertIsBuffer)(e),r&&64!==e.length&&(e=t.from(i.secp256k1.ProjectivePoint.fromHex(e).toRawBytes(!1).slice(1))),64!==e.length)throw new Error("Expected pubKey to be of length 64");return t.from((0,s.keccak256)(e)).slice(-20)},r.publicToAddress=r.pubToAddress;r.privateToPublic=function(e){return(0,c.assertIsBuffer)(e),t.from(i.secp256k1.ProjectivePoint.fromPrivateKey(e).toRawBytes(!1).slice(1))};r.privateToAddress=function(e){return(0,r.publicToAddress)((0,r.privateToPublic)(e))};r.importPublic=function(e){return(0,c.assertIsBuffer)(e),64!==e.length&&(e=t.from(i.secp256k1.ProjectivePoint.fromHex(e).toRawBytes(!1).slice(1))),e};r.zeroAddress=function(){const e=(0,a.zeros)(20);return(0,a.bufferToHex)(e)};function p(e){const[t,r,n,s]=e;return[t,r,0===(0,a.arrToBufArr)(n).length?l.KECCAK256_RLP:n,0===(0,a.arrToBufArr)(s).length?l.KECCAK256_NULL:s]}r.isZeroAddress=function(e){try{(0,c.assertIsString)(e)}catch(e){return!1}return(0,r.zeroAddress)()===e},r.accountBodyFromSlim=p;const g=new Uint8Array(0);r.accountBodyToSlim=function(e){const[t,r,n,s]=e;return[t,r,(0,a.arrToBufArr)(n).equals(l.KECCAK256_RLP)?g:n,(0,a.arrToBufArr)(s).equals(l.KECCAK256_NULL)?g:s]},r.accountBodyToRLP=function(e,t=!0){const r=t?p(e):e;return(0,a.arrToBufArr)(n.RLP.encode(r))}}).call(this)}).call(this,e("buffer").Buffer)}}},{package:"@metamask/eth-trezor-keyring>@metamask/eth-sig-util>@ethereumjs/util",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@metamask/eth-sig-util/node_modules/@ethereumjs/util/dist/account.js"}],[189,{lodash:4855},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("lodash");r.default={version:2,migrate(e){const t=(0,n.cloneDeep)(e);t.meta.version=2;try{"etherscan"===t.data.config.provider.type&&(t.data.config.provider.type="rpc",t.data.config.provider.rpcTarget="https://rpc.metamask.io/")}catch(e){}return Promise.resolve(t)}}}}},{package:"$root$",file:"app/scripts/migrations/002.js"}],[1890,{"./account":1889,"./bytes":1892,buffer:4074},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){(function(t){(function(){Object.defineProperty(r,"__esModule",{value:!0}),r.Address=void 0;const n=e("./account"),s=e("./bytes");class i{constructor(e){if(20!==e.length)throw new Error("Invalid address length");this.buf=e}static zero(){return new i((0,s.zeros)(20))}static fromString(e){if(!(0,n.isValidAddress)(e))throw new Error("Invalid address");return new i((0,s.toBuffer)(e))}static fromPublicKey(e){if(!t.isBuffer(e))throw new Error("Public key should be Buffer");const r=(0,n.pubToAddress)(e);return new i(r)}static fromPrivateKey(e){if(!t.isBuffer(e))throw new Error("Private key should be Buffer");const r=(0,n.privateToAddress)(e);return new i(r)}static generate(e,t){if("bigint"!=typeof t)throw new Error("Expected nonce to be a bigint");return new i((0,n.generateAddress)(e.buf,(0,s.bigIntToBuffer)(t)))}static generate2(e,r,s){if(!t.isBuffer(r))throw new Error("Expected salt to be a Buffer");if(!t.isBuffer(s))throw new Error("Expected initCode to be a Buffer");return new i((0,n.generateAddress2)(e.buf,r,s))}equals(e){return this.buf.equals(e.buf)}isZero(){return this.equals(i.zero())}isPrecompileOrSystemAddress(){const e=(0,s.bufferToBigInt)(this.buf),t=BigInt(0),r=BigInt("0xffff");return e>=t&&e<=r}toString(){return"0x"+this.buf.toString("hex")}toBuffer(){return t.from(this.buf)}}r.Address=i}).call(this)}).call(this,e("buffer").Buffer)}}},{package:"@metamask/eth-trezor-keyring>@metamask/eth-sig-util>@ethereumjs/util",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@metamask/eth-sig-util/node_modules/@ethereumjs/util/dist/address.js"}],[1891,{events:4399},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.AsyncEventEmitter=void 0;const n=e("events");class s extends n.EventEmitter{emit(e,...t){let[r,n]=t;const s=this;let i=s._events[e]??[];return n===undefined&&"function"==typeof r&&(n=r,r=undefined),"newListener"!==e&&"removeListener"!==e||(r={event:r,fn:n},n=undefined),i=Array.isArray(i)?i:[i],async function(e,t,r){let n;for await(const s of t)try{s.length<2?s.call(e,r):await new Promise(((t,n)=>{s.call(e,r,(e=>{e?n(e):t()}))}))}catch(e){n=e}if(n)throw n}(s,i.slice(),r).then(n).catch(n),s.listenerCount(e)>0}once(e,t){const r=this;let n;if("function"!=typeof t)throw new TypeError("listener must be a function");return n=t.length>=2?function(s,i){r.removeListener(e,n),t(s,i)}:function(s){r.removeListener(e,n),t(s,n)},r.on(e,n),r}first(e,t){let r=this._events[e]??[];if("function"!=typeof t)throw new TypeError("listener must be a function");return Array.isArray(r)||(this._events[e]=r=[r]),r.unshift(t),this}before(e,t,r){return this.beforeOrAfter(e,t,r)}after(e,t,r){return this.beforeOrAfter(e,t,r,"after")}beforeOrAfter(e,t,r,n){let s,i,o=this._events[e]??[];const a="after"===n?1:0;if("function"!=typeof r)throw new TypeError("listener must be a function");if("function"!=typeof t)throw new TypeError("target must be a function");for(Array.isArray(o)||(this._events[e]=o=[o]),i=o.length,s=o.length;s--;)if(o[s]===t){i=s+a;break}return o.splice(i,0,r),this}on(e,t){return super.on(e,t)}addListener(e,t){return super.addListener(e,t)}prependListener(e,t){return super.prependListener(e,t)}prependOnceListener(e,t){return super.prependOnceListener(e,t)}removeAllListeners(e){return super.removeAllListeners(e)}removeListener(e,t){return super.removeListener(e,t)}eventNames(){return super.eventNames()}listeners(e){return super.listeners(e)}listenerCount(e){return super.listenerCount(e)}getMaxListeners(){return super.getMaxListeners()}setMaxListeners(e){return super.setMaxListeners(e)}}r.AsyncEventEmitter=s}}},{package:"@metamask/eth-trezor-keyring>@metamask/eth-sig-util>@ethereumjs/util",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@metamask/eth-sig-util/node_modules/@ethereumjs/util/dist/asyncEventEmitter.js"}],[1892,{"./helpers":1895,"./internal":1897,buffer:4074},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){(function(t){(function(){Object.defineProperty(r,"__esModule",{value:!0}),r.intToUnpaddedBuffer=r.bigIntToUnpaddedBuffer=r.bigIntToHex=r.bufArrToArr=r.arrToBufArr=r.validateNoLeadingZeroes=r.baToJSON=r.toUtf8=r.short=r.addHexPrefix=r.toUnsigned=r.fromSigned=r.bufferToInt=r.bigIntToBuffer=r.bufferToBigInt=r.bufferToHex=r.toBuffer=r.unpadHexString=r.unpadArray=r.unpadBuffer=r.setLengthRight=r.setLengthLeft=r.zeros=r.intToBuffer=r.intToHex=void 0;const n=e("./helpers"),s=e("./internal");r.intToHex=function(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Received an invalid integer type: ${e}`);return`0x${e.toString(16)}`};r.intToBuffer=function(e){const n=(0,r.intToHex)(e);return t.from((0,s.padToEven)(n.slice(2)),"hex")};r.zeros=function(e){return t.allocUnsafe(e).fill(0)};const i=function(e,t,n){const s=(0,r.zeros)(t);return n?e.length<t?(e.copy(s),s):e.slice(0,t):e.length<t?(e.copy(s,t-e.length),s):e.slice(-t)};r.setLengthLeft=function(e,t){return(0,n.assertIsBuffer)(e),i(e,t,!1)};r.setLengthRight=function(e,t){return(0,n.assertIsBuffer)(e),i(e,t,!0)};const o=function(e){let t=e[0];for(;e.length>0&&"0"===t.toString();)t=(e=e.slice(1))[0];return e};r.unpadBuffer=function(e){return(0,n.assertIsBuffer)(e),o(e)};r.unpadArray=function(e){return(0,n.assertIsArray)(e),o(e)};r.unpadHexString=function(e){return(0,n.assertIsHexString)(e),e=(0,s.stripHexPrefix)(e),"0x"+o(e)};r.toBuffer=function(e){if(null===e||e===undefined)return t.allocUnsafe(0);if(t.isBuffer(e))return t.from(e);if(Array.isArray(e)||e instanceof Uint8Array)return t.from(e);if("string"==typeof e){if(!(0,s.isHexString)(e))throw new Error(`Cannot convert string to buffer. toBuffer only supports 0x-prefixed hex strings and this string was given: ${e}`);return t.from((0,s.padToEven)((0,s.stripHexPrefix)(e)),"hex")}if("number"==typeof e)return(0,r.intToBuffer)(e);if("bigint"==typeof e){if(e<BigInt(0))throw new Error(`Cannot convert negative bigint to buffer. Given: ${e}`);let r=e.toString(16);return r.length%2&&(r="0"+r),t.from(r,"hex")}if(e.toArray)return t.from(e.toArray());if(e.toBuffer)return t.from(e.toBuffer());throw new Error("invalid type")};function a(e){const t=(0,r.bufferToHex)(e);return"0x"===t?BigInt(0):BigInt(t)}function l(e){return(0,r.toBuffer)("0x"+e.toString(16))}r.bufferToHex=function(e){return"0x"+(e=(0,r.toBuffer)(e)).toString("hex")},r.bufferToBigInt=a,r.bigIntToBuffer=l;r.bufferToInt=function(e){const t=Number(a(e));if(!Number.isSafeInteger(t))throw new Error("Number exceeds 53 bits");return t};r.fromSigned=function(e){return BigInt.asIntN(256,a(e))};r.toUnsigned=function(e){return l(BigInt.asUintN(256,e))};r.addHexPrefix=function(e){return"string"!=typeof e||(0,s.isHexPrefixed)(e)?e:"0x"+e},r.short=function(e,r=50){const n=t.isBuffer(e)?e.toString("hex"):e;return n.length<=r?n:n.slice(0,r)+"…"};r.toUtf8=function(e){if((e=(0,s.stripHexPrefix)(e)).length%2!=0)throw new Error("Invalid non-even hex string input for toUtf8() provided");return t.from(e.replace(/^(00)+|(00)+$/g,""),"hex").toString("utf8")};r.baToJSON=function(e){if(t.isBuffer(e))return`0x${e.toString("hex")}`;if(e instanceof Array){const t=[];for(let n=0;n<e.length;n++)t.push((0,r.baToJSON)(e[n]));return t}};r.validateNoLeadingZeroes=function(e){for(const[t,r]of Object.entries(e))if(r!==undefined&&r.length>0&&0===r[0])throw new Error(`${t} cannot have leading zeroes, received: ${r.toString("hex")}`)},r.arrToBufArr=function e(r){return Array.isArray(r)?r.map((t=>e(t))):t.from(r)},r.bufArrToArr=function e(t){return Array.isArray(t)?t.map((t=>e(t))):Uint8Array.from(t??[])};r.bigIntToHex=e=>"0x"+e.toString(16),r.bigIntToUnpaddedBuffer=function(e){return(0,r.unpadBuffer)(l(e))},r.intToUnpaddedBuffer=function(e){return(0,r.unpadBuffer)((0,r.intToBuffer)(e))}}).call(this)}).call(this,e("buffer").Buffer)}}},{package:"@metamask/eth-trezor-keyring>@metamask/eth-sig-util>@ethereumjs/util",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@metamask/eth-sig-util/node_modules/@ethereumjs/util/dist/bytes.js"}],[1893,{buffer:4074,"ethereum-cryptography/secp256k1":4317},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.MAX_WITHDRAWALS_PER_PAYLOAD=r.RLP_EMPTY_STRING=r.KECCAK256_RLP=r.KECCAK256_RLP_S=r.KECCAK256_RLP_ARRAY=r.KECCAK256_RLP_ARRAY_S=r.KECCAK256_NULL=r.KECCAK256_NULL_S=r.TWO_POW256=r.SECP256K1_ORDER_DIV_2=r.SECP256K1_ORDER=r.MAX_INTEGER_BIGINT=r.MAX_INTEGER=r.MAX_UINT64=void 0;const n=e("buffer"),s=e("ethereum-cryptography/secp256k1");r.MAX_UINT64=BigInt("0xffffffffffffffff"),r.MAX_INTEGER=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),r.MAX_INTEGER_BIGINT=BigInt("115792089237316195423570985008687907853269984665640564039457584007913129639935"),r.SECP256K1_ORDER=s.secp256k1.CURVE.n,r.SECP256K1_ORDER_DIV_2=s.secp256k1.CURVE.n/BigInt(2),r.TWO_POW256=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000"),r.KECCAK256_NULL_S="c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",r.KECCAK256_NULL=n.Buffer.from(r.KECCAK256_NULL_S,"hex"),r.KECCAK256_RLP_ARRAY_S="1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",r.KECCAK256_RLP_ARRAY=n.Buffer.from(r.KECCAK256_RLP_ARRAY_S,"hex"),r.KECCAK256_RLP_S="56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",r.KECCAK256_RLP=n.Buffer.from(r.KECCAK256_RLP_S,"hex"),r.RLP_EMPTY_STRING=n.Buffer.from([128]),r.MAX_WITHDRAWALS_PER_PAYLOAD=16}}},{package:"@metamask/eth-trezor-keyring>@metamask/eth-sig-util>@ethereumjs/util",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@metamask/eth-sig-util/node_modules/@ethereumjs/util/dist/constants.js"}],[1894,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.compactBytesToNibbles=r.bytesToNibbles=r.nibblesToCompactBytes=r.nibblesToBytes=r.hasTerminator=void 0;r.hasTerminator=e=>e.length>0&&16===e[e.length-1];r.nibblesToBytes=(e,t)=>{for(let r=0,n=0;n<e.length;r+=1,n+=2)t[r]=e[n]<<4|e[n+1]};r.nibblesToCompactBytes=e=>{let t=0;(0,r.hasTerminator)(e)&&(t=1,e=e.subarray(0,e.length-1));const n=new Uint8Array(e.length/2+1);return n[0]=t<<5,1&~e.length||(n[0]|=16,n[0]|=e[0],e=e.subarray(1)),(0,r.nibblesToBytes)(e,n.subarray(1)),n};r.bytesToNibbles=e=>{const t=2*e.length+1,r=new Uint8Array(t);for(let t=0;t<e.length;t++){const n=e[t];r[2*t]=n/16,r[2*t+1]=n%16}return r[t-1]=16,r};r.compactBytesToNibbles=e=>{if(0===e.length)return e;let t=(0,r.bytesToNibbles)(e);t[0]<2&&(t=t.subarray(0,t.length-1));const n=2-(1&t[0]);return t.subarray(n)}}}},{package:"@metamask/eth-trezor-keyring>@metamask/eth-sig-util>@ethereumjs/util",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@metamask/eth-sig-util/node_modules/@ethereumjs/util/dist/encoding.js"}],[1895,{"../../../../../../../../../is-buffer/index.js":4657,"./internal":1897},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){(function(t){(function(){Object.defineProperty(r,"__esModule",{value:!0}),r.assertIsString=r.assertIsArray=r.assertIsBuffer=r.assertIsHexString=void 0;const n=e("./internal");r.assertIsHexString=function(e){if(!(0,n.isHexString)(e)){throw new Error(`This method only supports 0x-prefixed hex strings but input was: ${e}`)}};r.assertIsBuffer=function(e){if(!t.isBuffer(e)){throw new Error(`This method only supports Buffer but input was: ${e}`)}};r.assertIsArray=function(e){if(!Array.isArray(e)){throw new Error(`This method only supports number arrays but input was: ${e}`)}};r.assertIsString=function(e){if("string"!=typeof e){throw new Error(`This method only supports strings but input was: ${e}`)}}}).call(this)}).call(this,{isBuffer:e("../../../../../../../../../is-buffer/index.js")})}}},{package:"@metamask/eth-trezor-keyring>@metamask/eth-sig-util>@ethereumjs/util",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@metamask/eth-sig-util/node_modules/@ethereumjs/util/dist/helpers.js"}],[1896,{"./account":1889,"./address":1890,"./asyncEventEmitter":1891,"./bytes":1892,"./constants":1893,"./encoding":1894,"./internal":1897,"./lock":1898,"./provider":1899,"./signature":1900,"./types":1901,"./units":1902,"./withdrawal":1903},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){n===undefined&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){n===undefined&&(n=r),e[n]=t[r]}),s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(r,"__esModule",{value:!0}),r.toAscii=r.stripHexPrefix=r.padToEven=r.isHexString=r.isHexPrefixed=r.getKeys=r.getBinarySize=r.fromUtf8=r.fromAscii=r.arrayContainsArray=void 0,s(e("./constants"),r),s(e("./units"),r),s(e("./account"),r),s(e("./address"),r),s(e("./withdrawal"),r),s(e("./signature"),r),s(e("./bytes"),r),s(e("./types"),r),s(e("./encoding"),r),s(e("./asyncEventEmitter"),r);var i=e("./internal");Object.defineProperty(r,"arrayContainsArray",{enumerable:!0,get:function(){return i.arrayContainsArray}}),Object.defineProperty(r,"fromAscii",{enumerable:!0,get:function(){return i.fromAscii}}),Object.defineProperty(r,"fromUtf8",{enumerable:!0,get:function(){return i.fromUtf8}}),Object.defineProperty(r,"getBinarySize",{enumerable:!0,get:function(){return i.getBinarySize}}),Object.defineProperty(r,"getKeys",{enumerable:!0,get:function(){return i.getKeys}}),Object.defineProperty(r,"isHexPrefixed",{enumerable:!0,get:function(){return i.isHexPrefixed}}),Object.defineProperty(r,"isHexString",{enumerable:!0,get:function(){return i.isHexString}}),Object.defineProperty(r,"padToEven",{enumerable:!0,get:function(){return i.padToEven}}),Object.defineProperty(r,"stripHexPrefix",{enumerable:!0,get:function(){return i.stripHexPrefix}}),Object.defineProperty(r,"toAscii",{enumerable:!0,get:function(){return i.toAscii}}),s(e("./lock"),r),s(e("./provider"),r)}}},{package:"@metamask/eth-trezor-keyring>@metamask/eth-sig-util>@ethereumjs/util",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@metamask/eth-sig-util/node_modules/@ethereumjs/util/dist/index.js"}],[1897,{buffer:4074},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){(function(e){(function(){function t(e){if("string"!=typeof e)throw new Error("[isHexPrefixed] input must be type 'string', received type "+typeof e);return"0"===e[0]&&"x"===e[1]}Object.defineProperty(r,"__esModule",{value:!0}),r.isHexString=r.getKeys=r.fromAscii=r.fromUtf8=r.toAscii=r.arrayContainsArray=r.getBinarySize=r.padToEven=r.stripHexPrefix=r.isHexPrefixed=void 0,r.isHexPrefixed=t;function n(e){let t=e;if("string"!=typeof t)throw new Error("[padToEven] value must be type 'string', received "+typeof t);return t.length%2&&(t=`0${t}`),t}r.stripHexPrefix=e=>{if("string"!=typeof e)throw new Error("[stripHexPrefix] input must be type 'string', received "+typeof e);return t(e)?e.slice(2):e},r.padToEven=n,r.getBinarySize=function(t){if("string"!=typeof t)throw new Error("[getBinarySize] method requires input type 'string', received "+typeof t);return e.byteLength(t,"utf8")},r.arrayContainsArray=function(e,t,r){if(!0!==Array.isArray(e))throw new Error(`[arrayContainsArray] method requires input 'superset' to be an array, got type '${typeof e}'`);if(!0!==Array.isArray(t))throw new Error(`[arrayContainsArray] method requires input 'subset' to be an array, got type '${typeof t}'`);return t[!0===r?"some":"every"]((t=>e.indexOf(t)>=0))},r.toAscii=function(e){let t="",r=0;const n=e.length;for("0x"===e.substring(0,2)&&(r=2);r<n;r+=2){const n=parseInt(e.substr(r,2),16);t+=String.fromCharCode(n)}return t},r.fromUtf8=function(t){return`0x${n(e.from(t,"utf8").toString("hex")).replace(/^0+|0+$/g,"")}`},r.fromAscii=function(e){let t="";for(let r=0;r<e.length;r++){const n=e.charCodeAt(r).toString(16);t+=n.length<2?`0${n}`:n}return`0x${t}`},r.getKeys=function(e,t,r){if(!Array.isArray(e))throw new Error("[getKeys] method expects input 'params' to be an array, got "+typeof e);if("string"!=typeof t)throw new Error("[getKeys] method expects input 'key' to be type 'string', got "+typeof e);const n=[];for(let s=0;s<e.length;s++){let i=e[s][t];if(!0!==r||i){if("string"!=typeof i)throw new Error("invalid abi - expected type 'string', received "+typeof i)}else i="";n.push(i)}return n},r.isHexString=function(e,t){return!("string"!=typeof e||!e.match(/^0x[0-9A-Fa-f]*$/))&&!(void 0!==t&&t>0&&e.length!==2+2*t)}}).call(this)}).call(this,e("buffer").Buffer)}}},{package:"@metamask/eth-trezor-keyring>@metamask/eth-sig-util>@ethereumjs/util",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@metamask/eth-sig-util/node_modules/@ethereumjs/util/dist/internal.js"}],[1898,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.Lock=void 0;r.Lock=class{constructor(){this.permits=1,this.promiseResolverQueue=[]}async acquire(){return this.permits>0?(this.permits-=1,Promise.resolve(!0)):new Promise((e=>this.promiseResolverQueue.push(e)))}release(){if(this.permits+=1,this.permits>1&&this.promiseResolverQueue.length>0)console.warn("Lock.permits should never be > 0 when there is someone waiting.");else if(1===this.permits&&this.promiseResolverQueue.length>0){this.permits-=1;const e=this.promiseResolverQueue.shift();e&&e(!0)}}}}}},{package:"@metamask/eth-trezor-keyring>@metamask/eth-sig-util>@ethereumjs/util",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@metamask/eth-sig-util/node_modules/@ethereumjs/util/dist/lock.js"}],[1899,{"micro-ftch":4910},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.getProvider=r.fetchFromProvider=void 0;const n=e("micro-ftch");r.fetchFromProvider=async(e,t)=>(await(0,n.default)(e,{headers:{"content-type":"application/json"},type:"json",data:{method:t.method,params:t.params,jsonrpc:"2.0",id:1}})).result;r.getProvider=e=>{if("string"==typeof e)return e;if(e?.connection?.url!==undefined)return e.connection.url;throw new Error("Must provide valid provider URL or Web3Provider")}}}},{package:"@metamask/eth-trezor-keyring>@metamask/eth-sig-util>@ethereumjs/util",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@metamask/eth-sig-util/node_modules/@ethereumjs/util/dist/provider.js"}],[19,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.getMultichainAssetsRatesControllerMessenger=function(e){return e.getRestricted({name:"MultichainAssetsRatesController",allowedEvents:["AccountsController:accountAdded","KeyringController:lock","KeyringController:unlock","CurrencyRateController:stateChange","MultichainAssetsController:stateChange"],allowedActions:["AccountsController:listMultichainAccounts","SnapController:handleRequest","CurrencyRateController:getState","MultichainAssetsController:getState"]})}}}},{package:"$root$",file:"app/scripts/controller-init/messengers/multichain/multichain-assets-rates-controller-messenger.ts"}],[190,{lodash:4855},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("lodash");r.default={version:3,migrate(e){const t=(0,n.cloneDeep)(e);t.meta.version=3;try{"https://rawtestrpc.metamask.io/"===t.data.config.provider.rpcTarget&&(t.data.config.provider.rpcTarget="https://testrpc.metamask.io/")}catch(e){}return Promise.resolve(t)}}}}},{package:"$root$",file:"app/scripts/migrations/003.js"}],[1900,{"./bytes":1892,"./constants":1893,"./helpers":1895,buffer:4074,"ethereum-cryptography/keccak":4300,"ethereum-cryptography/secp256k1":4317},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){(function(t){(function(){Object.defineProperty(r,"__esModule",{value:!0}),r.hashPersonalMessage=r.isValidSignature=r.fromRpcSig=r.toCompactSig=r.toRpcSig=r.ecrecover=r.ecsign=void 0;const n=e("ethereum-cryptography/keccak"),s=e("ethereum-cryptography/secp256k1"),i=e("./bytes"),o=e("./constants"),a=e("./helpers");function l(e,t){return e===BigInt(0)||e===BigInt(1)?e:t===undefined?e-BigInt(27):e-(t*BigInt(2)+BigInt(35))}function c(e){return e===BigInt(0)||e===BigInt(1)}r.ecsign=function(e,r,n){const i=s.secp256k1.sign(e,r),o=i.toCompactRawBytes();return{r:t.from(o.slice(0,32)),s:t.from(o.slice(32,64)),v:n===undefined?BigInt(i.recovery+27):BigInt(i.recovery+35)+BigInt(n)*BigInt(2)}};r.ecrecover=function(e,r,n,o,a){const u=t.concat([(0,i.setLengthLeft)(n,32),(0,i.setLengthLeft)(o,32)],64),d=l(r,a);if(!c(d))throw new Error("Invalid signature v value");const h=s.secp256k1.Signature.fromCompact(u).addRecoveryBit(Number(d)).recoverPublicKey(e);return t.from(h.toRawBytes(!1).slice(1))};r.toRpcSig=function(e,r,n,s){if(!c(l(e,s)))throw new Error("Invalid signature v value");return(0,i.bufferToHex)(t.concat([(0,i.setLengthLeft)(r,32),(0,i.setLengthLeft)(n,32),(0,i.toBuffer)(e)]))};r.toCompactSig=function(e,r,n,s){if(!c(l(e,s)))throw new Error("Invalid signature v value");let o=n;return(e>BigInt(28)&&e%BigInt(2)===BigInt(1)||e===BigInt(1)||e===BigInt(28))&&(o=t.from(n),o[0]|=128),(0,i.bufferToHex)(t.concat([(0,i.setLengthLeft)(r,32),(0,i.setLengthLeft)(o,32)]))};r.fromRpcSig=function(e){const t=(0,i.toBuffer)(e);let r,n,s;if(t.length>=65)r=t.slice(0,32),n=t.slice(32,64),s=(0,i.bufferToBigInt)(t.slice(64));else{if(64!==t.length)throw new Error("Invalid signature length");r=t.slice(0,32),n=t.slice(32,64),s=BigInt((0,i.bufferToInt)(t.slice(32,33))>>7),n[0]&=127}return s<27&&(s+=BigInt(27)),{v:s,r:r,s:n}};r.isValidSignature=function(e,t,r,n=!0,s){if(32!==t.length||32!==r.length)return!1;if(!c(l(e,s)))return!1;const a=(0,i.bufferToBigInt)(t),u=(0,i.bufferToBigInt)(r);return!(a===BigInt(0)||a>=o.SECP256K1_ORDER||u===BigInt(0)||u>=o.SECP256K1_ORDER)&&!(n&&u>=o.SECP256K1_ORDER_DIV_2)};r.hashPersonalMessage=function(e){(0,a.assertIsBuffer)(e);const r=t.from(`Ethereum Signed Message:\n${e.length}`,"utf-8");return t.from((0,n.keccak256)(t.concat([r,e])))}}).call(this)}).call(this,e("buffer").Buffer)}}},{package:"@metamask/eth-trezor-keyring>@metamask/eth-sig-util>@ethereumjs/util",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@metamask/eth-sig-util/node_modules/@ethereumjs/util/dist/signature.js"}],[1901,{"./bytes":1892,"./internal":1897},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.toType=r.TypeOutput=void 0;const n=e("./bytes"),s=e("./internal");var i;!function(e){e[e.Number=0]="Number",e[e.BigInt=1]="BigInt",e[e.Buffer=2]="Buffer",e[e.PrefixedHexString=3]="PrefixedHexString"}(i=r.TypeOutput||(r.TypeOutput={})),r.toType=function(e,t){if(null===e)return null;if(e===undefined)return undefined;if("string"==typeof e&&!(0,s.isHexString)(e))throw new Error(`A string must be provided with a 0x-prefix, given: ${e}`);if("number"==typeof e&&!Number.isSafeInteger(e))throw new Error("The provided number is greater than MAX_SAFE_INTEGER (please use an alternative input type)");const r=(0,n.toBuffer)(e);switch(t){case i.Buffer:return r;case i.BigInt:return(0,n.bufferToBigInt)(r);case i.Number:{const e=(0,n.bufferToBigInt)(r);if(e>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("The provided number is greater than MAX_SAFE_INTEGER (please use an alternative output type)");return Number(e)}case i.PrefixedHexString:return(0,n.bufferToHex)(r);default:throw new Error("unknown outputType")}}}}},{package:"@metamask/eth-trezor-keyring>@metamask/eth-sig-util>@ethereumjs/util",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@metamask/eth-sig-util/node_modules/@ethereumjs/util/dist/types.js"}],[1902,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.GWEI_TO_WEI=void 0,r.GWEI_TO_WEI=BigInt(1e9)}}},{package:"@metamask/eth-trezor-keyring>@metamask/eth-sig-util>@ethereumjs/util",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@metamask/eth-sig-util/node_modules/@ethereumjs/util/dist/units.js"}],[1903,{"./address":1890,"./bytes":1892,"./types":1901,buffer:4074},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){(function(t){(function(){Object.defineProperty(r,"__esModule",{value:!0}),r.Withdrawal=void 0;const n=e("./address"),s=e("./bytes"),i=e("./types");class o{constructor(e,t,r,n){this.index=e,this.validatorIndex=t,this.address=r,this.amount=n}static fromWithdrawalData(e){const{index:t,validatorIndex:r,address:s,amount:a}=e,l=(0,i.toType)(t,i.TypeOutput.BigInt),c=(0,i.toType)(r,i.TypeOutput.BigInt),u=new n.Address((0,i.toType)(s,i.TypeOutput.Buffer)),d=(0,i.toType)(a,i.TypeOutput.BigInt);return new o(l,c,u,d)}static fromValuesArray(e){if(4!==e.length)throw Error(`Invalid withdrawalArray length expected=4 actual=${e.length}`);const[t,r,n,s]=e;return o.fromWithdrawalData({index:t,validatorIndex:r,address:n,amount:s})}static toBufferArray(e){const{index:r,validatorIndex:s,address:o,amount:a}=e,l=(0,i.toType)(r,i.TypeOutput.BigInt)===BigInt(0)?t.alloc(0):(0,i.toType)(r,i.TypeOutput.Buffer),c=(0,i.toType)(s,i.TypeOutput.BigInt)===BigInt(0)?t.alloc(0):(0,i.toType)(s,i.TypeOutput.Buffer);let u;u=o instanceof n.Address?o.buf:(0,i.toType)(o,i.TypeOutput.Buffer);return[l,c,u,(0,i.toType)(a,i.TypeOutput.BigInt)===BigInt(0)?t.alloc(0):(0,i.toType)(a,i.TypeOutput.Buffer)]}raw(){return o.toBufferArray(this)}toValue(){return{index:this.index,validatorIndex:this.validatorIndex,address:this.address.buf,amount:this.amount}}toJSON(){return{index:(0,s.bigIntToHex)(this.index),validatorIndex:(0,s.bigIntToHex)(this.validatorIndex),address:"0x"+this.address.buf.toString("hex"),amount:(0,s.bigIntToHex)(this.amount)}}}r.Withdrawal=o}).call(this)}).call(this,e("buffer").Buffer)}}},{package:"@metamask/eth-trezor-keyring>@metamask/eth-sig-util>@ethereumjs/util",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@metamask/eth-sig-util/node_modules/@ethereumjs/util/dist/withdrawal.js"}],[1904,{"@metamask/eth-sig-util":1884,tslib:5615},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.transformTypedData=void 0;const n=e("tslib").__importStar(e("@metamask/eth-sig-util"));function s(e){switch(Object.prototype.toString.call(e)){case"[object Object]":{const t=Object.keys(e).map((t=>[t,s(e[t])]));return Object.fromEntries(t)}case"[object Array]":return e.map((e=>s(e)));case"[object BigInt]":return e.toString();default:return e}}r.transformTypedData=(e,t)=>{if(!t)throw new Error("Trezor: Only version 4 of typed data signing is supported");const r=n.SignTypedDataVersion.V4,{types:i,primaryType:o,domain:a,message:l}=n.TypedDataUtils.sanitizeData(e),c=n.TypedDataUtils.hashStruct("EIP712Domain",s(a),i,r).toString("hex");let u=null;return"EIP712Domain"!==o&&(u=n.TypedDataUtils.hashStruct(o,s(l),i,r).toString("hex")),Object.assign({domain_separator_hash:c,message_hash:u},e)},r.default=r.transformTypedData}}},{package:"@metamask/eth-trezor-keyring>@trezor/connect-plugin-ethereum",file:"node_modules/@metamask/eth-trezor-keyring/node_modules/@trezor/connect-plugin-ethereum/lib/index.js"}],[191,{lodash:4855},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("lodash");r.default={version:4,migrate(e){const t=(0,n.cloneDeep)(e);t.meta.version=4;try{if("rpc"!==t.data.config.provider.type)return Promise.resolve(t);switch(t.data.config.provider.rpcTarget){case"https://testrpc.metamask.io/":t.data.config.provider={type:"testnet"};break;case"https://rpc.metamask.io/":t.data.config.provider={type:"mainnet"}}}catch(e){}return Promise.resolve(t)}}}}},{package:"$root$",file:"app/scripts/migrations/004.js"}],[192,{lodash:4855},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("lodash");r.default={version:5,migrate(e){const t=(0,n.cloneDeep)(e);t.meta.version=5;try{const e=function(e){const{config:t}=e,r={...e,KeyringController:{vault:e.vault,selectedAccount:t.selectedAccount,walletNicknames:e.walletNicknames}};return delete r.vault,delete r.walletNicknames,delete r.config.selectedAccount,r}(t.data);t.data=e}catch(e){console.warn(`MetaMask Migration #5${e.stack}`)}return Promise.resolve(t)}}}}},{package:"$root$",file:"app/scripts/migrations/005.js"}],[193,{lodash:4855},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("lodash");r.default={version:6,migrate(e){const t=(0,n.cloneDeep)(e);t.meta.version=6;try{const e=function(e){const t=e.KeyringController,r={...e,PreferencesController:{selectedAddress:t.selectedAccount}};return delete r.KeyringController.selectedAccount,r}(t.data);t.data=e}catch(e){console.warn(`MetaMask Migration #6${e.stack}`)}return Promise.resolve(t)}}}}},{package:"$root$",file:"app/scripts/migrations/006.js"}],[194,{lodash:4855},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("lodash");r.default={version:7,migrate(e){const t=(0,n.cloneDeep)(e);t.meta.version=7;try{const e=function(e){const t={...e,TransactionManager:{transactions:e.transactions||[],gasMultiplier:e.gasMultiplier||1}};return delete t.transactions,delete t.gasMultiplier,t}(t.data);t.data=e}catch(e){console.warn(`MetaMask Migration #7${e.stack}`)}return Promise.resolve(t)}}}}},{package:"$root$",file:"app/scripts/migrations/007.js"}],[195,{lodash:4855},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("lodash");r.default={version:8,migrate(e){const t=(0,n.cloneDeep)(e);t.meta.version=8;try{const e=function(e){const t={...e,NoticeController:{noticesList:e.noticesList||[]}};return delete t.noticesList,t}(t.data);t.data=e}catch(e){console.warn(`MetaMask Migration #8${e.stack}`)}return Promise.resolve(t)}}}}},{package:"$root$",file:"app/scripts/migrations/008.js"}],[196,{lodash:4855},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("lodash");r.default={version:9,migrate(e){const t=(0,n.cloneDeep)(e);t.meta.version=9;try{const e=function(e){const t=(0,n.merge)({},e,{CurrencyController:{currentCurrency:e.currentFiat||e.fiatCurrency||"USD",conversionRate:e.conversionRate,conversionDate:e.conversionDate}});return delete t.currentFiat,delete t.fiatCurrency,delete t.conversionRate,delete t.conversionDate,t}(t.data);t.data=e}catch(e){console.warn(`MetaMask Migration #9${e.stack}`)}return Promise.resolve(t)}}}}},{package:"$root$",file:"app/scripts/migrations/009.js"}],[197,{lodash:4855},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("lodash");r.default={version:10,migrate(e){const t=(0,n.cloneDeep)(e);t.meta.version=10;try{const e=function(e){const t=(0,n.merge)({},e,{ShapeShiftController:{shapeShiftTxList:e.shapeShiftTxList||[]}});return delete t.shapeShiftTxList,t}(t.data);t.data=e}catch(e){console.warn(`MetaMask Migration #10${e.stack}`)}return Promise.resolve(t)}}}}},{package:"$root$",file:"app/scripts/migrations/010.js"}],[198,{lodash:4855},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("lodash");r.default={version:11,migrate(e){const t=(0,n.cloneDeep)(e);t.meta.version=11;try{const e=function(e){const t=e;return delete t.TOSHash,delete t.isDisclaimerConfirmed,t}(t.data);t.data=e}catch(e){console.warn(`MetaMask Migration #11${e.stack}`)}return Promise.resolve(t)}}}}},{package:"$root$",file:"app/scripts/migrations/011.js"}],[199,{lodash:4855},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("lodash");r.default={version:12,migrate(e){const t=(0,n.cloneDeep)(e);t.meta.version=12;try{const e=function(e){const t=e;return t.NoticeController.noticesList.forEach((e=>{e.read&&(e.body="")})),t}(t.data);t.data=e}catch(e){console.warn(`MetaMask Migration #12${e.stack}`)}return Promise.resolve(t)}}}}},{package:"$root$",file:"app/scripts/migrations/012.js"}],[20,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.getMultichainBalancesControllerMessenger=function(e){return e.getRestricted({name:"MultichainBalancesController",allowedEvents:["AccountsController:accountAdded","AccountsController:accountRemoved","AccountsController:accountBalancesUpdated","MultichainAssetsController:stateChange"],allowedActions:["AccountsController:listMultichainAccounts","SnapController:handleRequest","MultichainAssetsController:getState","KeyringController:getState"]})}}}},{package:"$root$",file:"app/scripts/controller-init/messengers/multichain/multichain-balances-controller-messenger.ts"}],[200,{lodash:4855},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("lodash");r.default={version:13,migrate(e){const t=(0,n.cloneDeep)(e);t.meta.version=13;try{const e=function(e){const t=e,{config:r}=t;r&&r.provider&&"testnet"===r.provider.type&&(t.config.provider.type="ropsten");return t}(t.data);t.data=e}catch(e){console.warn(`MetaMask Migration #13${e.stack}`)}return Promise.resolve(t)}}}}},{package:"$root$",file:"app/scripts/migrations/013.js"}],[201,{lodash:4855},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("lodash");r.default={version:14,migrate(e){const t=(0,n.cloneDeep)(e);t.meta.version=14;try{const e=function(e){const t=e;return t.NetworkController={},t.NetworkController.provider=t.config.provider,delete t.config.provider,t}(t.data);t.data=e}catch(e){console.warn(`MetaMask Migration #14${e.stack}`)}return Promise.resolve(t)}}}}},{package:"$root$",file:"app/scripts/migrations/014.js"}],[202,{"@metamask/transaction-controller":2905,lodash:4855},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("@metamask/transaction-controller"),s=e("lodash");r.default={version:15,migrate(e){const t=(0,s.cloneDeep)(e);t.meta.version=15;try{const e=function(e){const t=e,{TransactionController:r}=t;if(r&&r.transactions){const{transactions:e}=r;t.TransactionController.transactions=e.map((e=>e.err?("Gave up submitting tx."===e.err.message&&(e.status=n.TransactionStatus.failed),e):e))}return t}(t.data);t.data=e}catch(e){console.warn(`MetaMask Migration #15${e.stack}`)}return Promise.resolve(t)}}}}},{package:"$root$",file:"app/scripts/migrations/015.js"}],[203,{"@metamask/transaction-controller":2905,lodash:4855},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("@metamask/transaction-controller"),s=e("lodash");r.default={version:16,migrate(e){const t=(0,s.cloneDeep)(e);t.meta.version=16;try{const e=function(e){const t=e,{TransactionController:r}=t;if(r&&r.transactions){const{transactions:e}=t.TransactionController;t.TransactionController.transactions=e.map((e=>e.err?("transaction with the same hash was already imported."===e.err&&(e.status=n.TransactionStatus.submitted,delete e.err),e):e))}return t}(t.data);t.data=e}catch(e){console.warn(`MetaMask Migration #16${e.stack}`)}return Promise.resolve(t)}}}}},{package:"$root$",file:"app/scripts/migrations/016.js"}],[2032,{"@metamask/keyring-snap-client":2036},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n,s,i,o,a,l=this&&this.__classPrivateFieldSet||function(e,t,r,n,s){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?s.call(e,r):s?s.value=r:t.set(e,r),r},c=this&&this.__classPrivateFieldGet||function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)};Object.defineProperty(r,"__esModule",{value:!0}),r.KeyringInternalSnapClient=void 0;const u=e("@metamask/keyring-snap-client");class d{constructor(e,t,r,a){n.set(this,void 0),s.set(this,void 0),i.set(this,void 0),o.set(this,void 0),l(this,i,e,"f"),l(this,n,t,"f"),l(this,s,r,"f"),l(this,o,a,"f")}async send(e){return c(this,i,"f").call("SnapController:handleRequest",{snapId:c(this,n,"f"),origin:c(this,s,"f"),handler:c(this,o,"f"),request:e})}}n=new WeakMap,s=new WeakMap,i=new WeakMap,o=new WeakMap;class h extends u.KeyringClient{constructor({messenger:e,snapId:t="undefined",origin:r="metamask",handler:n="onKeyringRequest"}){super(new d(e,t,r,n)),a.set(this,void 0),l(this,a,e,"f")}withSnapId(e){return new h({messenger:c(this,a,"f"),snapId:e})}}r.KeyringInternalSnapClient=h,a=new WeakMap}}},{package:"@metamask/eth-snap-keyring>@metamask/keyring-internal-snap-client",file:"node_modules/@metamask/keyring-internal-snap-client/dist/KeyringInternalSnapClient.cjs"}],[2033,{"./KeyringInternalSnapClient.cjs":2032},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){n===undefined&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){n===undefined&&(n=r),e[n]=t[r]}),s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(r,"__esModule",{value:!0}),s(e("./KeyringInternalSnapClient.cjs"),r)}}},{package:"@metamask/eth-snap-keyring>@metamask/keyring-internal-snap-client",file:"node_modules/@metamask/keyring-internal-snap-client/dist/index.cjs"}],[204,{"@metamask/transaction-controller":2905,lodash:4855},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("@metamask/transaction-controller"),s=e("lodash");r.default={version:17,migrate(e){const t=(0,s.cloneDeep)(e);t.meta.version=17;try{const e=function(e){const t=e,{TransactionController:r}=t;if(r&&r.transactions){const{transactions:e}=t.TransactionController;t.TransactionController.transactions=e.map((e=>(!e.status===n.TransactionStatus.failed||e.retryCount>0&&e.retryCount<2&&(e.status=n.TransactionStatus.submitted,delete e.err),e)))}return t}(t.data);t.data=e}catch(e){console.warn(`MetaMask Migration #17${e.stack}`)}return Promise.resolve(t)}}}}},{package:"$root$",file:"app/scripts/migrations/017.js"}],[205,{"fast-json-patch":4433,lodash:4855},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n,s=(n=e("fast-json-patch"))&&n.__esModule?n:{default:n},i=e("lodash");r.default={version:18,migrate(e){const t=(0,i.cloneDeep)(e);t.meta.version=18;try{const e=function(e){const t=e,{TransactionController:r}=t;if(r&&r.transactions){const{transactions:e}=t.TransactionController;t.TransactionController.transactions=e.map((e=>{if(!e.history||0===e.history.length){const t=function(e){const t={...e};return delete t.history,(0,i.cloneDeep)(t)}(e);return e.history=[t],e}const t=(r=e.history,r.map(((e,t)=>0===t?e:function(e,t,r){const n=s.default.compare(e,t);return n[0]&&(r&&(n[0].note=r),n[0].timestamp=Date.now()),n}(r[t-1],e)))).filter((e=>!Array.isArray(e)||e.length>0));var r;return e.history=t,e}))}return t}(t.data);t.data=e}catch(e){console.warn(`MetaMask Migration #18${e.stack}`)}return Promise.resolve(t)}}}}},{package:"$root$",file:"app/scripts/migrations/018.js"}],[206,{"@metamask/transaction-controller":2905,lodash:4855},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("@metamask/transaction-controller"),s=e("lodash");r.default={version:19,migrate(e){const t=(0,s.cloneDeep)(e);t.meta.version=19;try{const e=function(e){const t=e,{TransactionController:r}=t;if(r&&r.transactions){const{transactions:e}=t.TransactionController;t.TransactionController.transactions=e.map(((e,t,r)=>{if(e.status!==n.TransactionStatus.submitted)return e;const s=function(e){const t=e.map((e=>{const{nonce:t}=e.txParams;return parseInt(t||"0x0",16)}));return Math.max.apply(null,t)}(r.filter((e=>e.status===n.TransactionStatus.confirmed)).filter((t=>t.txParams.from===e.txParams.from)).filter((t=>t.metamaskNetworkId.from===e.metamaskNetworkId.from))),i=function(e,t){const r=e.map((e=>{const{nonce:t}=e.txParams;return parseInt(t,16)}));let n=t;for(;r.includes(n);)n+=1;return n}(r.filter((e=>e.status===n.TransactionStatus.submitted)).filter((t=>t.txParams.from===e.txParams.from)).filter((t=>t.metamaskNetworkId.from===e.metamaskNetworkId.from)),s),o=Math.max(i,s);return parseInt(e.txParams.nonce,16)>o+1&&(e.status=n.TransactionStatus.failed,e.err={message:"nonce too high",note:"migration 019 custom error"}),e}))}return t}(t.data);t.data=e}catch(e){console.warn(`MetaMask Migration #19${e.stack}`)}return Promise.resolve(t)}}}}},{package:"$root$",file:"app/scripts/migrations/019.js"}],[207,{lodash:4855},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("lodash");r.default={version:20,migrate(e){const t=(0,n.cloneDeep)(e);t.meta.version=20;try{const e=function(e){const t=e;"metamask"in t&&!("firstTimeInfo"in t.metamask)&&(t.metamask.firstTimeInfo={version:"3.12.0",date:Date.now()});return t}(t.data);t.data=e}catch(e){console.warn(`MetaMask Migration #20${e.stack}`)}return Promise.resolve(t)}}}}},{package:"$root$",file:"app/scripts/migrations/020.js"}],[2078,{"@metamask/base-controller":1383,events:4399,uuid:5663},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.AbstractMessageManager=void 0;const n=e("@metamask/base-controller"),s=e("events"),i=e("uuid"),o={unapprovedMessages:{persist:!1,anonymous:!1},unapprovedMessagesCount:{persist:!1,anonymous:!1}};class a extends n.BaseController{constructor({additionalFinishStatuses:e,messenger:t,name:r,securityProviderRequest:n,state:i={}}){super({messenger:t,metadata:o,name:r,state:{unapprovedMessages:{},unapprovedMessagesCount:0,...i}}),this.internalEvents=new s.EventEmitter,this.messages=[],this.securityProviderRequest=n,this.additionalFinishStatuses=e??[]}addRequestToMessageParams(e,t){const r={...e};return t&&(r.requestId=t.id,r.origin=t.origin),r}createUnapprovedMessage(e,t,r){return{id:(0,i.v1)(),messageParams:e,securityAlertResponse:r?.securityAlertResponse,status:"unapproved",time:Date.now(),type:t}}saveMessageList(e=!0){this.update((e=>{e.unapprovedMessages=this.getUnapprovedMessages(),e.unapprovedMessagesCount=this.getUnapprovedMessagesCount()})),e&&this.messagingSystem.publish(`${this.name}:updateBadge`)}setMessageStatus(e,t){const r=this.getMessage(e);if(!r)throw new Error(`${this.name}: Message not found for id: ${e}.`);const n={...r,status:t};this.updateMessage(n),this.internalEvents.emit(`${e}:${t}`,n),("rejected"===t||"signed"===t||"errored"===t||this.additionalFinishStatuses.includes(t))&&this.internalEvents.emit(`${e}:finished`,n)}updateMessage(e,t=!0){const r=this.messages.findIndex((t=>e.id===t.id));-1!==r&&(this.messages[r]=e),this.saveMessageList(t)}async securityCheck(e){if(this.securityProviderRequest){const t=await this.securityProviderRequest(e,e.type);return{...e,securityProviderResponse:t}}return e}clearUnapprovedMessages(){this.update((e=>{e.unapprovedMessages={},e.unapprovedMessagesCount=0}))}getUnapprovedMessagesCount(){return Object.keys(this.getUnapprovedMessages()).length}getUnapprovedMessages(){return this.messages.filter((e=>"unapproved"===e.status)).reduce(((e,t)=>(e[t.id]=t,e)),{})}async addMessage(e){const t=await this.securityCheck(e);this.messages.push(t),this.saveMessageList()}getMessage(e){return this.messages.find((t=>t.id===e))}getAllMessages(){return this.messages}approveMessage(e){return this.setMessageStatusApproved(e.metamaskId),this.prepMessageForSigning(e)}setMessageStatusApproved(e){this.setMessageStatus(e,"approved")}setMessageStatusInProgress(e){this.setMessageStatus(e,"inProgress")}setMessageStatusSigned(e,t){this.setMessageStatusAndResult(e,t,"signed")}setMessageStatusAndResult(e,t,r){this.setResult(e,t),this.setMessageStatus(e,r)}setResult(e,t){const r=this.getMessage(e);r&&this.updateMessage({...r,rawSig:t},!1)}setMetadata(e,t){const r=this.getMessage(e);if(!r)throw new Error(`${this.name}: Message not found for id: ${e}.`);this.updateMessage({...r,metadata:t},!1)}rejectMessage(e){this.setMessageStatus(e,"rejected")}async waitForFinishStatus(e,t){const{metamaskId:r,...n}=e;return new Promise(((e,s)=>{this.internalEvents.once(`${r}:finished`,(r=>{switch(r.status){case"signed":return e(r.rawSig);case"rejected":return s(new Error(`MetaMask ${t} Signature: User denied message signature.`));case"errored":return s(new Error(`MetaMask ${t} Signature: ${r.error}`));default:return s(new Error(`MetaMask ${t} Signature: Unknown problem: ${JSON.stringify(n)}`))}}))}))}}r.AbstractMessageManager=a,r.default=a}}},{package:"@metamask/message-manager",file:"node_modules/@metamask/message-manager/dist/AbstractMessageManager.cjs"}],[2079,{"./AbstractMessageManager.cjs":2078,"./utils.cjs":2083,"@metamask/controller-utils":1474},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.DecryptMessageManager=void 0;const n=e("@metamask/controller-utils"),s=e("./AbstractMessageManager.cjs"),i=e("./utils.cjs"),o="DecryptMessageManager";class a extends s.AbstractMessageManager{constructor({additionalFinishStatuses:e,messenger:t,securityProviderRequest:r,state:n}){super({additionalFinishStatuses:e,messenger:t,name:o,securityProviderRequest:r,state:n})}async addUnapprovedMessageAsync(e,t){(0,i.validateDecryptedMessageData)(e);const r=await this.addUnapprovedMessage(e,t);return new Promise(((t,n)=>{this.internalEvents.once(`${r}:finished`,(r=>{switch(r.status){case"decrypted":return t(r.rawSig);case"rejected":return n(new Error("MetaMask DecryptMessage: User denied message decryption."));case"errored":return n(new Error("MetaMask DecryptMessage: This message cannot be decrypted."));default:return n(new Error(`MetaMask DecryptMessage: Unknown problem: ${JSON.stringify(e)}`))}}))}))}async addUnapprovedMessage(e,t){const r=this.addRequestToMessageParams(e,t);e.data=(0,i.normalizeMessageData)(e.data);const s=this.createUnapprovedMessage(r,n.ApprovalType.EthDecrypt,t),a=s.id;return await this.addMessage(s),this.messagingSystem.publish(`${o}:unapprovedMessage`,{...r,metamaskId:a}),a}prepMessageForSigning(e){return delete e.metamaskId,Promise.resolve(e)}}r.DecryptMessageManager=a}}},{package:"@metamask/message-manager",file:"node_modules/@metamask/message-manager/dist/DecryptMessageManager.cjs"}],[208,{lodash:4855},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("lodash");r.default={version:21,migrate(e){const t=(0,n.cloneDeep)(e);t.meta.version=21;try{const e=function(e){const t=e;return delete t.BlacklistController,delete t.RecentBlocks,t}(t.data);t.data=e}catch(e){console.warn(`MetaMask Migration #21${e.stack}`)}return Promise.resolve(t)}}}}},{package:"$root$",file:"app/scripts/migrations/021.js"}],[2080,{"./AbstractMessageManager.cjs":2078,"./utils.cjs":2083,"@metamask/controller-utils":1474},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.EncryptionPublicKeyManager=void 0;const n=e("@metamask/controller-utils"),s=e("./AbstractMessageManager.cjs"),i=e("./utils.cjs");class o extends s.AbstractMessageManager{constructor({additionalFinishStatuses:e,messenger:t,securityProviderRequest:r,state:n}){super({additionalFinishStatuses:e,messenger:t,name:"EncryptionPublicKeyManager",securityProviderRequest:r,state:n})}async addUnapprovedMessageAsync(e,t){(0,i.validateEncryptionPublicKeyMessageData)(e);const r=await this.addUnapprovedMessage(e,t);return new Promise(((t,n)=>{this.internalEvents.once(`${r}:finished`,(r=>{switch(r.status){case"received":return t(r.rawSig);case"rejected":return n(new Error("MetaMask EncryptionPublicKey: User denied message EncryptionPublicKey."));default:return n(new Error(`MetaMask EncryptionPublicKey: Unknown problem: ${JSON.stringify(e)}`))}}))}))}async addUnapprovedMessage(e,t){const r=this.addRequestToMessageParams(e,t),s=this.createUnapprovedMessage(r,n.ApprovalType.EthGetEncryptionPublicKey,t),i=s.id;return await this.addMessage(s),this.messagingSystem.publish(`${this.name}:unapprovedMessage`,{...r,metamaskId:i}),i}prepMessageForSigning(e){return delete e.metamaskId,Promise.resolve({from:e.data})}}r.EncryptionPublicKeyManager=o,r.default=o}}},{package:"@metamask/message-manager",file:"node_modules/@metamask/message-manager/dist/EncryptionPublicKeyManager.cjs"}],[2081,{"./AbstractMessageManager.cjs":2078,"./DecryptMessageManager.cjs":2079,"./EncryptionPublicKeyManager.cjs":2080,"./types.cjs":2082},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){n===undefined&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){n===undefined&&(n=r),e[n]=t[r]}),s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(r,"__esModule",{value:!0}),s(e("./AbstractMessageManager.cjs"),r),s(e("./EncryptionPublicKeyManager.cjs"),r),s(e("./DecryptMessageManager.cjs"),r),s(e("./types.cjs"),r)}}},{package:"@metamask/message-manager",file:"node_modules/@metamask/message-manager/dist/index.cjs"}],[2082,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0})}}},{package:"@metamask/message-manager",file:"node_modules/@metamask/message-manager/dist/types.cjs"}],[2083,{"@metamask/controller-utils":1474,"@metamask/utils":2950,buffer:4074},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){(function(t){(function(){Object.defineProperty(r,"__esModule",{value:!0}),r.validateDecryptedMessageData=r.validateEncryptionPublicKeyMessageData=r.normalizeMessageData=void 0;const n=e("@metamask/controller-utils"),s=e("@metamask/utils"),i=/^[0-9A-Fa-f]+$/gu;function o(e,t){if(!e||"string"!=typeof e||!(0,n.isValidHexAddress)(e))throw new Error(`Invalid "${t}" address: ${e} must be a valid string.`)}r.normalizeMessageData=function(e){try{const t=(0,s.remove0x)(e);if(t.match(i))return(0,s.add0x)(t)}catch(e){}return(0,s.bytesToHex)(t.from(e,"utf8"))},r.validateEncryptionPublicKeyMessageData=function(e){const{from:t}=e;o(t,"from")},r.validateDecryptedMessageData=function(e){const{from:t}=e;o(t,"from")}}).call(this)}).call(this,e("buffer").Buffer)}}},{package:"@metamask/message-manager",file:"node_modules/@metamask/message-manager/dist/utils.cjs"}]],[],{});