@privy-io/react-auth 1.54.3 → 1.54.4-beta-20240126231538
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -2081,7 +2081,7 @@ You will need this password to access your ${e} wallet on a new device. Please k
|
|
|
2081
2081
|
overflow: hidden;
|
|
2082
2082
|
max-width: 275px;
|
|
2083
2083
|
text-overflow: ellipsis;
|
|
2084
|
-
`;import{VoidSigner as E0}from"@ethersproject/abstract-signer";import{BigNumber as Rt}from"@ethersproject/bignumber";import{Contract as P0}from"@ethersproject/contracts";import{EtherscanProvider as oW}from"@ethersproject/providers";import{serialize as T0}from"@ethersproject/transactions";var Na={id:42161,name:"Arbitrum One",network:"arbitrum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://arb-mainnet.g.alchemy.com/v2"],webSocket:["wss://arb-mainnet.g.alchemy.com/v2"]},infura:{http:["https://arbitrum-mainnet.infura.io/v3"],webSocket:["wss://arbitrum-mainnet.infura.io/ws/v3"]},default:{http:["https://arb1.arbitrum.io/rpc"]},public:{http:["https://arb1.arbitrum.io/rpc"]}},blockExplorers:{etherscan:{name:"Arbiscan",url:"https://arbiscan.io"},default:{name:"Arbiscan",url:"https://arbiscan.io"}}};var Oa={id:421613,name:"Arbitrum Goerli",network:"arbitrum-goerli",nativeCurrency:{name:"Goerli Ether",symbol:"AGOR",decimals:18},rpcUrls:{alchemy:{http:["https://arb-goerli.g.alchemy.com/v2"],webSocket:["wss://arb-goerli.g.alchemy.com/v2"]},infura:{http:["https://arbitrum-goerli.infura.io/v3"],webSocket:["wss://arbitrum-goerli.infura.io/ws/v3"]},default:{http:["https://goerli-rollup.arbitrum.io/rpc"]},public:{http:["https://goerli-rollup.arbitrum.io/rpc"]}},blockExplorers:{etherscan:{name:"Arbiscan",url:"https://goerli.arbiscan.io/"},default:{name:"Arbiscan",url:"https://goerli.arbiscan.io/"}},testnet:!0};var Da={id:421614,name:"Arbitrum Sepolia",network:"arbitrum-sepolia",nativeCurrency:{name:"Arbitrum Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia-rollup.arbitrum.io/rpc"]},public:{http:["https://sepolia-rollup.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Blockscout",url:"https://sepolia-explorer.arbitrum.io"}},testnet:!0};var Ua={id:8453,network:"base",name:"Base",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{blast:{http:["https://base-mainnet.blastapi.io"],webSocket:["wss://base-mainnet.blastapi.io"]},default:{http:["https://mainnet.base.org"]},public:{http:["https://mainnet.base.org"]}},blockExplorers:{etherscan:{name:"Basescan",url:"https://basescan.org"},default:{name:"Basescan",url:"https://basescan.org"}},testnet:!0};var Fa={id:84531,network:"base-goerli",name:"Base Goerli Testnet",nativeCurrency:{name:"Goerli Ether",symbol:"ETH",decimals:18},rpcUrls:{blast:{http:["https://base-goerli.blastapi.io"],webSocket:["wss://base-goerli.blastapi.io"]},default:{http:["https://goerli.base.org"]},public:{http:["https://goerli.base.org"]}},blockExplorers:{etherscan:{name:"Basescan",url:"https://goerli.basescan.org"},default:{name:"Basescan",url:"https://goerli.basescan.org"}},testnet:!0};var Ba={id:84532,network:"base-sepolia",name:"Base Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia.base.org"]},public:{http:["https://sepolia.base.org"]}},blockExplorers:{default:{name:"Blockscout",url:"https://base-sepolia.blockscout.com"}},testnet:!0};var Ha={id:10,name:"OP Mainnet",network:"optimism",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://opt-mainnet.g.alchemy.com/v2"],webSocket:["wss://opt-mainnet.g.alchemy.com/v2"]},infura:{http:["https://optimism-mainnet.infura.io/v3"],webSocket:["wss://optimism-mainnet.infura.io/ws/v3"]},default:{http:["https://mainnet.optimism.io"]},public:{http:["https://mainnet.optimism.io"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://optimistic.etherscan.io"},default:{name:"Optimism Explorer",url:"https://explorer.optimism.io"}}};var Ga={id:420,name:"Optimism Goerli Testnet",network:"optimism-goerli",nativeCurrency:{name:"Goerli Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://opt-goerli.g.alchemy.com/v2"],webSocket:["wss://opt-goerli.g.alchemy.com/v2"]},infura:{http:["https://optimism-goerli.infura.io/v3"],webSocket:["wss://optimism-goerli.infura.io/ws/v3"]},default:{http:["https://goerli.optimism.io"]},public:{http:["https://goerli.optimism.io"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://goerli-optimism.etherscan.io"},default:{name:"Etherscan",url:"https://goerli-optimism.etherscan.io"}},testnet:!0};var za={id:11155420,name:"Optimism Sepolia",network:"optimism-sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia.optimism.io"]},public:{http:["https://sepolia.optimism.io"]},infura:{http:["https://optimism-sepolia.infura.io/v3"]}},blockExplorers:{default:{name:"Blockscout",url:"https://optimism-sepolia.blockscout.com"}},testnet:!0};var Va={id:7777777,name:"Zora",network:"zora",nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"},rpcUrls:{default:{http:["https://rpc.zora.energy"],webSocket:["wss://rpc.zora.energy"]},public:{http:["https://rpc.zora.energy"],webSocket:["wss://rpc.zora.energy"]}},blockExplorers:{default:{name:"Explorer",url:"https://explorer.zora.energy"}}};var $a={id:999999999,name:"Zora Sepolia",network:"zora-sepolia",nativeCurrency:{decimals:18,name:"Zora Sepolia",symbol:"ETH"},rpcUrls:{default:{http:["https://sepolia.rpc.zora.energy"],webSocket:["wss://sepolia.rpc.zora.energy"]},public:{http:["https://sepolia.rpc.zora.energy"],webSocket:["wss://sepolia.rpc.zora.energy"]}},blockExplorers:{default:{name:"Zora Sepolia Explorer",url:"https://sepolia.explorer.zora.energy/"}},testnet:!0};var qa={id:999,name:"Zora Goerli Testnet",network:"zora-testnet",nativeCurrency:{decimals:18,name:"Zora Goerli",symbol:"ETH"},rpcUrls:{default:{http:["https://testnet.rpc.zora.energy"],webSocket:["wss://testnet.rpc.zora.energy"]},public:{http:["https://testnet.rpc.zora.energy"],webSocket:["wss://testnet.rpc.zora.energy"]}},blockExplorers:{default:{name:"Explorer",url:"https://testnet.explorer.zora.energy"}},testnet:!0};import{parseUnits as $m}from"@ethersproject/units";import{ofetch as C0}from"ofetch";var ei={id:137,name:"Polygon Mainnet",network:"matic",nativeCurrency:{name:"MATIC",symbol:"MATIC",decimals:18},rpcUrls:{alchemy:{http:["https://polygon-mainnet.g.alchemy.com/v2"],webSocket:["wss://polygon-mainnet.g.alchemy.com/v2"]},infura:{http:["https://polygon-mainnet.infura.io/v3"],webSocket:["wss://polygon-mainnet.infura.io/ws/v3"]},default:{http:["https://polygon-rpc.com"]},public:{http:["https://polygon-rpc.com"]}},blockExplorers:{etherscan:{name:"PolygonScan",url:"https://polygonscan.com"},default:{name:"PolygonScan",url:"https://polygonscan.com"}}};var ti={id:80001,name:"Mumbai",network:"maticmum",nativeCurrency:{name:"MATIC",symbol:"MATIC",decimals:18},rpcUrls:{alchemy:{http:["https://polygon-mumbai.g.alchemy.com/v2"],webSocket:["wss://polygon-mumbai.g.alchemy.com/v2"]},infura:{http:["https://polygon-mumbai.infura.io/v3"],webSocket:["wss://polygon-mumbai.infura.io/ws/v3"]},default:{http:["https://matic-mumbai.chainstacklabs.com"]},public:{http:["https://matic-mumbai.chainstacklabs.com"]}},blockExplorers:{etherscan:{name:"PolygonScan",url:"https://mumbai.polygonscan.com"},default:{name:"PolygonScan",url:"https://mumbai.polygonscan.com"}},testnet:!0};var qm=[ei.id,ti.id],Ll=e=>({maxPriorityFee:$m(e.maxPriorityFee.toFixed(9),"gwei").toHexString(),maxFee:$m(e.maxFee.toFixed(9),"gwei").toHexString()}),b0=e=>({safeLow:Ll(e.safeLow),standard:Ll(e.standard),fast:Ll(e.fast)}),jm=async e=>{let t="";switch(e){case ei.id:t="https://gasstation.polygon.technology/v2";break;case ti.id:t="https://gasstation-testnet.polygon.technology/v2";break;default:throw Error(`chainId ${e} does not support polygon gas stations`)}return b0(await C0(t))};function ho(e){if(typeof e=="number"||typeof e=="bigint"||typeof e=="string")return e;if(typeof e.toHexString=="function")return e.toHexString();throw new Error(`Expected numeric value but received ${e}`)}function x0(e){let t={};return e.to!==void 0&&(t.to=e.to),e.data!==void 0&&(t.data=e.data),e.chainId!==void 0&&(t.chainId=e.chainId),e.type!==void 0&&(t.type=e.type),e.accessList!==void 0&&(t.accessList=e.accessList),e.nonce!==void 0&&(t.nonce=ho(e.nonce)),e.gasLimit!==void 0&&(t.gasLimit=ho(e.gasLimit)),e.gasPrice!==void 0&&(t.gasPrice=ho(e.gasPrice)),e.value!==void 0&&(t.value=ho(e.value)),e.maxFeePerGas!==void 0&&(t.maxFeePerGas=ho(e.maxFeePerGas)),e.maxPriorityFeePerGas!==void 0&&(t.maxPriorityFeePerGas=ho(e.maxPriorityFeePerGas)),t}function S0(e){let t={};return e.to!==void 0&&(t.to=e.to),e.data!==void 0&&(t.data=e.data),e.chainId!==void 0&&(t.chainId=e.chainId),e.type!==void 0&&(t.type=e.type),e.accessList!==void 0&&(t.accessList=e.accessList),e.nonce!==void 0&&(t.nonce=pe(e.nonce).toNumber()),e.gasLimit!==void 0&&(t.gasLimit=pe(e.gasLimit)),e.gasPrice!==void 0&&(t.gasPrice=pe(e.gasPrice)),e.value!==void 0&&(t.value=pe(e.value)),e.maxFeePerGas!==void 0&&(t.maxFeePerGas=pe(e.maxFeePerGas)),e.maxPriorityFeePerGas!==void 0&&(t.maxPriorityFeePerGas=pe(e.maxPriorityFeePerGas)),t}async function an(e,t,o){t.chainId=Number(t.chainId),Ym(t);let r=new E0(e,o);if(t.gas&&(t.gasLimit=t.gas,delete t.gas),qm.includes(t.chainId)&&(!t.maxPriorityFeePerGas||!t.maxFeePerGas))try{let{standard:i}=await jm(t.chainId);t.maxPriorityFeePerGas||(t.maxPriorityFeePerGas=i.maxPriorityFee),t.maxFeePerGas||(t.maxFeePerGas=i.maxFee)}catch(i){throw new Error(`Failed to set gas prices from Polygon gas station with error: ${i}.`)}if(_0(t.chainId)&&!t.maxFeePerGas)try{let{lastBaseFeePerGas:i}=await r.getFeeData();if(i){let a=i.mul(Rt.from(120)).div(Rt.from(100));t.maxFeePerGas=ho(a),t.maxPriorityFeePerGas=ho(Rt.from(0))}}catch(i){throw new Error(`Failed to set gas price for Arbitrum transaction: ${i}.`)}if(Nl(t.chainId)&&(!t.maxPriorityFeePerGas||!t.maxFeePerGas)&&!t.gasPrice)try{if(t.type=2,!t.maxPriorityFeePerGas){let i=await o.send("eth_maxPriorityFeePerGas",[]);t.maxPriorityFeePerGas=i}if(t.maxFeePerGas&&(console.warn("maxFeePerGas is specified without maxPriorityFeePerGas - this can result in hung transactions."),t.maxPriorityFeePerGas>=t.maxFeePerGas))throw new Error("Overridden maxFeePerGas is less than or equal to the calculated maxPriorityFeePerGas. Please set both values or maxPriorityFeePerGas alone for correct gas estimation.");if(!t.maxFeePerGas){let{lastBaseFeePerGas:i}=await r.getFeeData();if(!i)throw new Error("Unable to fetch baseFee for last block.");let s=Rt.from(i).mul(Rt.from(126)).div(Rt.from(100)).add(Rt.from(t.maxPriorityFeePerGas));t.maxFeePerGas=ho(s)}}catch(i){throw new Error(`Failed to set gas price for OP stack transaction: ${i}.`)}k0(t.chainId)&&t.type!=0&&((t.type==1||t.type==2)&&console.warn("Transaction request type specified is incompatible for chain and will result in undefined behavior. Please use transaction type 0."),t.type===void 0&&(t.type=0));let n=await r.populateTransaction({to:t.to,from:t.from,nonce:t.nonce,gasLimit:t.gasLimit,gasPrice:t.gasPrice,data:t.data,value:t.value,chainId:t.chainId,type:t.type,accessList:t.accessList,maxFeePerGas:t.maxFeePerGas,maxPriorityFeePerGas:t.maxPriorityFeePerGas});return x0(n)}async function ja(e,t,o,r,n){r=Object.assign({chainId:to},r),Ym(r);let a=(await o.rpc({address:t,accessToken:e,request:{method:"eth_signTransaction",params:[r]}})).response.data;return await n.sendTransaction(a)}async function Km(e,t,o){let r=await o.getBalance(e),n=t.value||0,i=r.sub(pe(n)),a=!i.isNegative()&&!i.isZero();return{balance:r,hasSufficientFunds:a}}function Nl(e){return[Ua.id,Fa.id,Ba.id,Ha.id,Ga.id,za.id,Va.id,qa.id,$a.id].includes(e)}function _0(e){return[Na.id,Oa.id,Da.id].includes(e)}function k0(e){return[56,97].includes(e)}async function Ol(e,t){if(!e.chainId||e.chainId&&!Nl(e.chainId))return Rt.from(0);let o=Rt.from(0);try{let r=new P0(Lc,Nc,t),n=S0(e),i=T0(n);o=await r.getL1Fee(i)}catch{}return o}async function Ka(e,t){delete e.from;let o=Rt.from(0),r=Rt.from(0);if(e.gasLimit?o=pe(e.gasLimit):o=await t.estimateGas(e),e.type==2)if(e.maxFeePerGas)r=pe(e.maxFeePerGas);else{let i=await t.getFeeData();i.maxFeePerGas&&(r=i.maxFeePerGas)}else if(e.type==0||e.type==1)if(e.gasPrice)r=pe(e.gasPrice);else{let i=await t.getFeeData();i.gasPrice&&(r=i.gasPrice)}else if(e.gasPrice)r=pe(e.gasPrice);else{let i=await t.getFeeData();i.gasPrice&&(r=i.gasPrice)}let n=o.mul(r);if(e.chainId&&Nl(e.chainId))try{let i=await Ol(e,t);n=n.add(i)}catch{}return n}function Ym(e){let t=["gasLimit","gasPrice","value","maxPriorityFeePerGas","maxFeePerGas"];for(let o of t){let r=e[o];if(!(typeof r>"u")&&!A0(r))throw new Error(`Transaction request property '${o}' must be a valid number, bigint, or hex string representing a quantity`)}if(typeof e.chainId!="number")throw new Error("Transaction request property 'chainId' must be a number")}function A0(e){let t=typeof e=="number",o=typeof e=="bigint",r=typeof e=="string"&&R0(e);return t||o||r}function R0(e){return/^-?0x[a-f0-9]+$/i.test(e)}function Ya(e){return{to:e.to,from:e.from,contractAddress:e.contractAddress,transactionIndex:e.transactionIndex,root:e.root,logsBloom:e.logsBloom,blockHash:e.blockHash,transactionHash:e.transactionHash,logs:e.logs,blockNumber:e.blockNumber,confirmations:e.confirmations,byzantium:e.byzantium,type:e.type,status:e.status,gasUsed:e.gasUsed.toHexString(),cumulativeGasUsed:e.cumulativeGasUsed.toHexString(),effectiveGasPrice:e.effectiveGasPrice?e.effectiveGasPrice.toHexString():void 0}}import{useState as Dl,useEffect as I0}from"react";var Ja=e=>{let{showFiatPrices:t,getUsdTokenPrice:o,chains:r}=R(),[n,i]=Dl(!0),[a,l]=Dl(void 0),[s,c]=Dl(void 0);return I0(()=>{let u=e.chainId||to,f=r.find(g=>g.id===Number(u));if(!f)throw new z(`Unsupported chain: ${u}`);(async()=>{if(!t){i(!1);return}try{i(!0);let g=await o(f);g?c(g):l(new Error(`Unable to fetch token price on chain id ${f.id}`))}catch(g){l(g)}finally{i(!1)}})()},[e.chainId]),{tokenPrice:s,isTokenPriceLoading:n,tokenPriceError:a}};import{createContext as W0,useContext as M0}from"react";var Ul=W0({wallets:[],ready:!1});function oi(){return M0(Ul)}import{jsx as Qm}from"react/jsx-runtime";var Fl=({pendingTransaction:e})=>{let{getAccessToken:t}=U(),{wallets:o}=oi(),{walletProxy:r,rpcConfig:n,chains:i,nativeTokenSymbolForChainId:a}=R(),[l,s]=Jm(e),{tokenPrice:c}=Ja(l),[u,f]=Jm(null),v=a(e.chainId)||"ETH",g=N0(()=>o.find(y=>y.walletClientType==="privy"),[o]);return O0(()=>{async function y(){if(!await t()||!r||!g)return l;let E=new L0(Pt(l.chainId,i,n)),w=await Ka(l,E);return f(pe(w.toBigInt()).toHexString()),an(g.address,l,E)}y().then(T=>{s(T)})},[r]),g?Qm(U0,{children:Qm(nn,{from:g.address,to:l.to,txn:l,gas:u??void 0,tokenPrice:c,tokenSymbol:v})}):null},U0=D0.div`
|
|
2084
|
+
`;import{VoidSigner as E0}from"@ethersproject/abstract-signer";import{BigNumber as Rt}from"@ethersproject/bignumber";import{Contract as P0}from"@ethersproject/contracts";import{EtherscanProvider as oW}from"@ethersproject/providers";import{serialize as T0}from"@ethersproject/transactions";var Na={id:42161,name:"Arbitrum One",network:"arbitrum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://arb-mainnet.g.alchemy.com/v2"],webSocket:["wss://arb-mainnet.g.alchemy.com/v2"]},infura:{http:["https://arbitrum-mainnet.infura.io/v3"],webSocket:["wss://arbitrum-mainnet.infura.io/ws/v3"]},default:{http:["https://arb1.arbitrum.io/rpc"]},public:{http:["https://arb1.arbitrum.io/rpc"]}},blockExplorers:{etherscan:{name:"Arbiscan",url:"https://arbiscan.io"},default:{name:"Arbiscan",url:"https://arbiscan.io"}}};var Oa={id:421613,name:"Arbitrum Goerli",network:"arbitrum-goerli",nativeCurrency:{name:"Goerli Ether",symbol:"AGOR",decimals:18},rpcUrls:{alchemy:{http:["https://arb-goerli.g.alchemy.com/v2"],webSocket:["wss://arb-goerli.g.alchemy.com/v2"]},infura:{http:["https://arbitrum-goerli.infura.io/v3"],webSocket:["wss://arbitrum-goerli.infura.io/ws/v3"]},default:{http:["https://goerli-rollup.arbitrum.io/rpc"]},public:{http:["https://goerli-rollup.arbitrum.io/rpc"]}},blockExplorers:{etherscan:{name:"Arbiscan",url:"https://goerli.arbiscan.io/"},default:{name:"Arbiscan",url:"https://goerli.arbiscan.io/"}},testnet:!0};var Da={id:421614,name:"Arbitrum Sepolia",network:"arbitrum-sepolia",nativeCurrency:{name:"Arbitrum Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia-rollup.arbitrum.io/rpc"]},public:{http:["https://sepolia-rollup.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Blockscout",url:"https://sepolia-explorer.arbitrum.io"}},testnet:!0};var Ua={id:8453,network:"base",name:"Base",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{blast:{http:["https://base-mainnet.blastapi.io"],webSocket:["wss://base-mainnet.blastapi.io"]},default:{http:["https://mainnet.base.org"]},public:{http:["https://mainnet.base.org"]}},blockExplorers:{etherscan:{name:"Basescan",url:"https://basescan.org"},default:{name:"Basescan",url:"https://basescan.org"}},testnet:!0};var Fa={id:84531,network:"base-goerli",name:"Base Goerli Testnet",nativeCurrency:{name:"Goerli Ether",symbol:"ETH",decimals:18},rpcUrls:{blast:{http:["https://base-goerli.blastapi.io"],webSocket:["wss://base-goerli.blastapi.io"]},default:{http:["https://goerli.base.org"]},public:{http:["https://goerli.base.org"]}},blockExplorers:{etherscan:{name:"Basescan",url:"https://goerli.basescan.org"},default:{name:"Basescan",url:"https://goerli.basescan.org"}},testnet:!0};var Ba={id:84532,network:"base-sepolia",name:"Base Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia.base.org"]},public:{http:["https://sepolia.base.org"]}},blockExplorers:{default:{name:"Blockscout",url:"https://base-sepolia.blockscout.com"}},testnet:!0};var Ha={id:10,name:"OP Mainnet",network:"optimism",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://opt-mainnet.g.alchemy.com/v2"],webSocket:["wss://opt-mainnet.g.alchemy.com/v2"]},infura:{http:["https://optimism-mainnet.infura.io/v3"],webSocket:["wss://optimism-mainnet.infura.io/ws/v3"]},default:{http:["https://mainnet.optimism.io"]},public:{http:["https://mainnet.optimism.io"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://optimistic.etherscan.io"},default:{name:"Optimism Explorer",url:"https://explorer.optimism.io"}}};var Ga={id:420,name:"Optimism Goerli Testnet",network:"optimism-goerli",nativeCurrency:{name:"Goerli Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://opt-goerli.g.alchemy.com/v2"],webSocket:["wss://opt-goerli.g.alchemy.com/v2"]},infura:{http:["https://optimism-goerli.infura.io/v3"],webSocket:["wss://optimism-goerli.infura.io/ws/v3"]},default:{http:["https://goerli.optimism.io"]},public:{http:["https://goerli.optimism.io"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://goerli-optimism.etherscan.io"},default:{name:"Etherscan",url:"https://goerli-optimism.etherscan.io"}},testnet:!0};var za={id:11155420,name:"Optimism Sepolia",network:"optimism-sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia.optimism.io"]},public:{http:["https://sepolia.optimism.io"]},infura:{http:["https://optimism-sepolia.infura.io/v3"]}},blockExplorers:{default:{name:"Blockscout",url:"https://optimism-sepolia.blockscout.com"}},testnet:!0};var Va={id:7777777,name:"Zora",network:"zora",nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"},rpcUrls:{default:{http:["https://rpc.zora.energy"],webSocket:["wss://rpc.zora.energy"]},public:{http:["https://rpc.zora.energy"],webSocket:["wss://rpc.zora.energy"]}},blockExplorers:{default:{name:"Explorer",url:"https://explorer.zora.energy"}}};var $a={id:999999999,name:"Zora Sepolia",network:"zora-sepolia",nativeCurrency:{decimals:18,name:"Zora Sepolia",symbol:"ETH"},rpcUrls:{default:{http:["https://sepolia.rpc.zora.energy"],webSocket:["wss://sepolia.rpc.zora.energy"]},public:{http:["https://sepolia.rpc.zora.energy"],webSocket:["wss://sepolia.rpc.zora.energy"]}},blockExplorers:{default:{name:"Zora Sepolia Explorer",url:"https://sepolia.explorer.zora.energy/"}},testnet:!0};var qa={id:999,name:"Zora Goerli Testnet",network:"zora-testnet",nativeCurrency:{decimals:18,name:"Zora Goerli",symbol:"ETH"},rpcUrls:{default:{http:["https://testnet.rpc.zora.energy"],webSocket:["wss://testnet.rpc.zora.energy"]},public:{http:["https://testnet.rpc.zora.energy"],webSocket:["wss://testnet.rpc.zora.energy"]}},blockExplorers:{default:{name:"Explorer",url:"https://testnet.explorer.zora.energy"}},testnet:!0};import{parseUnits as $m}from"@ethersproject/units";import{ofetch as C0}from"ofetch";var ei={id:137,name:"Polygon Mainnet",network:"matic",nativeCurrency:{name:"MATIC",symbol:"MATIC",decimals:18},rpcUrls:{alchemy:{http:["https://polygon-mainnet.g.alchemy.com/v2"],webSocket:["wss://polygon-mainnet.g.alchemy.com/v2"]},infura:{http:["https://polygon-mainnet.infura.io/v3"],webSocket:["wss://polygon-mainnet.infura.io/ws/v3"]},default:{http:["https://polygon-rpc.com"]},public:{http:["https://polygon-rpc.com"]}},blockExplorers:{etherscan:{name:"PolygonScan",url:"https://polygonscan.com"},default:{name:"PolygonScan",url:"https://polygonscan.com"}}};var ti={id:80001,name:"Mumbai",network:"maticmum",nativeCurrency:{name:"MATIC",symbol:"MATIC",decimals:18},rpcUrls:{alchemy:{http:["https://polygon-mumbai.g.alchemy.com/v2"],webSocket:["wss://polygon-mumbai.g.alchemy.com/v2"]},infura:{http:["https://polygon-mumbai.infura.io/v3"],webSocket:["wss://polygon-mumbai.infura.io/ws/v3"]},default:{http:["https://matic-mumbai.chainstacklabs.com"]},public:{http:["https://matic-mumbai.chainstacklabs.com"]}},blockExplorers:{etherscan:{name:"PolygonScan",url:"https://mumbai.polygonscan.com"},default:{name:"PolygonScan",url:"https://mumbai.polygonscan.com"}},testnet:!0};var qm=[ei.id,ti.id],Ll=e=>({maxPriorityFee:$m(e.maxPriorityFee.toFixed(9),"gwei").toHexString(),maxFee:$m(e.maxFee.toFixed(9),"gwei").toHexString()}),b0=e=>({safeLow:Ll(e.safeLow),standard:Ll(e.standard),fast:Ll(e.fast)}),jm=async e=>{let t="";switch(e){case ei.id:t="https://gasstation.polygon.technology/v2";break;case ti.id:t="https://gasstation-testnet.polygon.technology/v2";break;default:throw Error(`chainId ${e} does not support polygon gas stations`)}return b0(await C0(t))};function ho(e){if(typeof e=="number"||typeof e=="bigint"||typeof e=="string")return e;if(typeof e.toHexString=="function")return e.toHexString();throw new Error(`Expected numeric value but received ${e}`)}function x0(e){let t={};return e.to!==void 0&&(t.to=e.to),e.data!==void 0&&(t.data=e.data),e.chainId!==void 0&&(t.chainId=e.chainId),e.type!==void 0&&(t.type=e.type),e.accessList!==void 0&&(t.accessList=e.accessList),e.nonce!==void 0&&(t.nonce=ho(e.nonce)),e.gasLimit!==void 0&&(t.gasLimit=ho(e.gasLimit)),e.gasPrice!==void 0&&(t.gasPrice=ho(e.gasPrice)),e.value!==void 0&&(t.value=ho(e.value)),e.maxFeePerGas!==void 0&&(t.maxFeePerGas=ho(e.maxFeePerGas)),e.maxPriorityFeePerGas!==void 0&&(t.maxPriorityFeePerGas=ho(e.maxPriorityFeePerGas)),t}function S0(e){let t={};return e.to!==void 0&&(t.to=e.to),e.data!==void 0&&(t.data=e.data),e.chainId!==void 0&&(t.chainId=e.chainId),e.type!==void 0&&(t.type=e.type),e.accessList!==void 0&&(t.accessList=e.accessList),e.nonce!==void 0&&(t.nonce=pe(e.nonce).toNumber()),e.gasLimit!==void 0&&(t.gasLimit=pe(e.gasLimit)),e.gasPrice!==void 0&&(t.gasPrice=pe(e.gasPrice)),e.value!==void 0&&(t.value=pe(e.value)),e.maxFeePerGas!==void 0&&(t.maxFeePerGas=pe(e.maxFeePerGas)),e.maxPriorityFeePerGas!==void 0&&(t.maxPriorityFeePerGas=pe(e.maxPriorityFeePerGas)),t}async function an(e,t,o){t.chainId=Number(t.chainId),Ym(t);let r=new E0(e,o);if(t.gas&&(t.gasLimit=t.gas,delete t.gas),qm.includes(t.chainId)&&(!t.maxPriorityFeePerGas||!t.maxFeePerGas))try{let{standard:i}=await jm(t.chainId);t.maxPriorityFeePerGas||(t.maxPriorityFeePerGas=i.maxPriorityFee),t.maxFeePerGas||(t.maxFeePerGas=i.maxFee)}catch(i){throw new Error(`Failed to set gas prices from Polygon gas station with error: ${i}.`)}if(_0(t.chainId)&&!t.maxFeePerGas)try{let{lastBaseFeePerGas:i}=await r.getFeeData();if(i){let a=i.mul(Rt.from(120)).div(Rt.from(100));t.maxFeePerGas=ho(a),t.maxPriorityFeePerGas=ho(Rt.from(0))}}catch(i){throw new Error(`Failed to set gas price for Arbitrum transaction: ${i}.`)}if(Nl(t.chainId)&&(!t.maxPriorityFeePerGas||!t.maxFeePerGas)&&!t.gasPrice)try{if(t.type=2,!t.maxPriorityFeePerGas){let i=await o.send("eth_maxPriorityFeePerGas",[]);t.maxPriorityFeePerGas=i}if(t.maxFeePerGas&&(console.warn("maxFeePerGas is specified without maxPriorityFeePerGas - this can result in hung transactions."),t.maxPriorityFeePerGas>=t.maxFeePerGas))throw new Error("Overridden maxFeePerGas is less than or equal to the calculated maxPriorityFeePerGas. Please set both values or maxPriorityFeePerGas alone for correct gas estimation.");if(!t.maxFeePerGas){let{lastBaseFeePerGas:i}=await r.getFeeData();if(!i)throw new Error("Unable to fetch baseFee for last block.");let s=Rt.from(i).mul(Rt.from(126)).div(Rt.from(100)).add(Rt.from(t.maxPriorityFeePerGas));t.maxFeePerGas=ho(s)}}catch(i){throw new Error(`Failed to set gas price for OP stack transaction: ${i}.`)}k0(t.chainId)&&t.type!=0&&((t.type==1||t.type==2)&&console.warn("Transaction request type specified is incompatible for chain and will result in undefined behavior. Please use transaction type 0."),t.type===void 0&&(t.type=0));let n=await r.populateTransaction({to:t.to,from:t.from,nonce:t.nonce,gasLimit:t.gasLimit,gasPrice:t.gasPrice,data:t.data,value:t.value,chainId:t.chainId,type:t.type,accessList:t.accessList,maxFeePerGas:t.maxFeePerGas,maxPriorityFeePerGas:t.maxPriorityFeePerGas});return x0(n)}async function ja(e,t,o,r,n){r=Object.assign({chainId:to},r),Ym(r);let a=(await o.rpc({address:t,accessToken:e,request:{method:"eth_signTransaction",params:[r]}})).response.data;return await n.sendTransaction(a)}async function Km(e,t,o){let r=await o.getBalance(e),n=t.value||0,i=r.sub(pe(n)),a=!i.isNegative()&&!i.isZero();return{balance:r,hasSufficientFunds:a}}function Nl(e){return[Ua.id,Fa.id,Ba.id,Ha.id,Ga.id,za.id,Va.id,qa.id,$a.id].includes(e)}function _0(e){return[Na.id,Oa.id,Da.id].includes(e)}function k0(e){return[56,97].includes(e)}async function Ol(e,t){if(!e.chainId||e.chainId&&!Nl(e.chainId))return Rt.from(0);let o=Rt.from(0);try{let r=new P0(Lc,Nc,t),n=S0(e),i=T0(n);o=await r.getL1Fee(i)}catch{}return o}async function Ka(e,t){delete e.from;let o=Rt.from(0),r=Rt.from(0);if(e.gasLimit?o=pe(e.gasLimit):o=await t.estimateGas(e),e.type==2)if(e.maxFeePerGas)r=pe(e.maxFeePerGas);else{let i=await t.getFeeData();i.maxFeePerGas&&(r=i.maxFeePerGas)}else if(e.type==0||e.type==1)if(e.gasPrice)r=pe(e.gasPrice);else{let i=await t.getFeeData();i.gasPrice&&(r=i.gasPrice)}else if(e.gasPrice)r=pe(e.gasPrice);else{let i=await t.getFeeData();i.gasPrice&&(r=i.gasPrice)}let n=o.mul(r);if(e.chainId&&Nl(e.chainId))try{let i=await Ol(e,t);n=n.add(i)}catch{}return n}function Ym(e){let t=["gasLimit","gasPrice","value","maxPriorityFeePerGas","maxFeePerGas"];for(let o of t){let r=e[o];if(!(typeof r>"u")&&!A0(r))throw new Error(`Transaction request property '${o}' must be a valid number, bigint, or hex string representing a quantity`)}if(typeof e.chainId!="number")throw new Error("Transaction request property 'chainId' must be a number")}function A0(e){let t=typeof e=="number",o=typeof e=="bigint",r=typeof e=="string"&&R0(e);return t||o||r}function R0(e){return/^-?0x[a-f0-9]+$/i.test(e)}function Ya(e){return{to:e.to,from:e.from,contractAddress:e.contractAddress,transactionIndex:e.transactionIndex,root:e.root,logsBloom:e.logsBloom,blockHash:e.blockHash,transactionHash:e.transactionHash,logs:e.logs,blockNumber:e.blockNumber,confirmations:e.confirmations,byzantium:e.byzantium,type:e.type,status:e.status,gasUsed:e.gasUsed.toHexString(),cumulativeGasUsed:e.cumulativeGasUsed.toHexString(),effectiveGasPrice:e.effectiveGasPrice?e.effectiveGasPrice.toHexString():void 0}}import{useState as Dl,useEffect as I0}from"react";var Ja=e=>{let{showFiatPrices:t,getUsdTokenPrice:o,chains:r}=R(),[n,i]=Dl(!0),[a,l]=Dl(void 0),[s,c]=Dl(void 0);return I0(()=>{let u=e.chainId||to,f=r.find(g=>g.id===Number(u));if(!f)throw new z(`Unsupported chain: ${u}`);(async()=>{if(!t){i(!1);return}try{i(!0);let g=await o(f);g?c(g):l(new Error(`Unable to fetch token price on chain id ${f.id}`))}catch(g){l(g)}finally{i(!1)}})()},[e.chainId]),{tokenPrice:s,isTokenPriceLoading:n,tokenPriceError:a}};import{createContext as W0,useContext as M0}from"react";var Ul=W0(null);function oi(){let e=M0(Ul);if(e===null)throw new Error("`useWallets` was called outside the PrivyProvider component");return e}import{jsx as Qm}from"react/jsx-runtime";var Fl=({pendingTransaction:e})=>{let{getAccessToken:t}=U(),{wallets:o}=oi(),{walletProxy:r,rpcConfig:n,chains:i,nativeTokenSymbolForChainId:a}=R(),[l,s]=Jm(e),{tokenPrice:c}=Ja(l),[u,f]=Jm(null),v=a(e.chainId)||"ETH",g=N0(()=>o.find(y=>y.walletClientType==="privy"),[o]);return O0(()=>{async function y(){if(!await t()||!r||!g)return l;let E=new L0(Pt(l.chainId,i,n)),w=await Ka(l,E);return f(pe(w.toBigInt()).toHexString()),an(g.address,l,E)}y().then(T=>{s(T)})},[r]),g?Qm(U0,{children:Qm(nn,{from:g.address,to:l.to,txn:l,gas:u??void 0,tokenPrice:c,tokenSymbol:v})}):null},U0=D0.div`
|
|
2085
2085
|
width: 100%;
|
|
2086
2086
|
padding: 1rem 0;
|
|
2087
2087
|
`;import{Fragment as Hl,jsx as Q,jsxs as Jt}from"react/jsx-runtime";var Gl=({open:e,onClose:t})=>{let{user:o}=U(),[r,n]=Bl(null),{init:i,cancel:a}=tn();V0(()=>{e&&o?.mfaMethods&&o.mfaMethods.length>0?l(o.mfaMethods[0]):n(null)},[o?.mfaMethods,e]);async function l(c){try{n(c),await i(c)}catch(u){console.error(u)}}let s=()=>{n(null),a(),t()};return!e||!o?null:r?Q($0,{selectedMethod:r,onClose:s,onBack:o.mfaMethods.length>1?()=>n(null):void 0}):Jt(Hl,{children:[Q(x,{onClose:s},"header"),Q(Fe,{children:Q(je,{children:Q(z0,{})})}),Q(Be,{children:"Verify your identity"}),Q(We,{children:"Choose a verification method"}),Jt(Sa,{children:[o.mfaMethods.includes("totp")&&Jt(Ce,{onClick:()=>l("totp"),children:[Q(F0,{}),"Authenticator App"]},"totp"),o.mfaMethods.includes("sms")&&Jt(Ce,{onClick:()=>l("sms"),children:[Q(B0,{}),"SMS"]},"sms")]}),Q(J,{})]})},$0=({selectedMethod:e,onClose:t,onBack:o})=>{let{app:r}=S(),{pendingTransaction:n}=R(),[i,a]=Bl(!1),[l,s]=Bl(!1),{submit:c}=tn();async function u(f){try{if(!f)return;await c(e,f),s(!0),a(!1),t()}catch(v){throw js(v)?(a(!0),new Error("You have exceeded the maximum number of attempts. Please close this window and try again in 10 seconds.")):Gr(v)?(a(!1),new Error("The code you entered is not valid")):Hr(v)?(a(!0),new Error("You have exceeded the time limit for code entry. Please try again in 30 seconds.")):(a(!1),new Error("Unknown error"))}}switch(e){case"sms":return Jt(Hl,{children:[Q(x,{onClose:t},"header"),Q(Fe,{children:Q(je,{children:Q(G0,{})})}),Q(Be,{children:"Enter verification code"}),Jt(Go,{children:[Q(en,{success:l,disabled:i,onChange:u}),Jt(We,{children:["To continue, please enter the 6-digit code sent to your ",Q("strong",{children:"mobile device"})]}),n&&Q(Fl,{pendingTransaction:n})]}),o&&Q(Pl,{theme:r?.appearance.palette.colorScheme,onClick:o,children:"Choose another method"}),Q(io,{onClick:t,children:"Not now"}),Q(J,{})]});case"totp":return Jt(Hl,{children:[Q(x,{onClose:t},"header"),Q(Fe,{children:Q(je,{children:Q(H0,{})})}),Q(Be,{children:"Enter verification code"}),Jt(Go,{children:[Q(en,{success:l,disabled:i,onChange:u}),Jt(We,{children:["To continue, please enter the 6-digit code generated from your"," ",Q("strong",{children:"authenticator app"})]}),n&&Q(Fl,{pendingTransaction:n})]}),o&&Q(Pl,{theme:r?.appearance.palette.colorScheme,onClick:o,children:"Choose another method"}),Q(io,{onClick:t,children:"Not now"}),Q(J,{})]});default:return null}};import{useEffect as Zm,useState as Xm}from"react";import tf from"styled-components";function zl(e){return e.charAt(0).toUpperCase()+e.slice(1)}import{Fragment as K0,jsx as yo,jsxs as Za}from"react/jsx-runtime";var ef={google:{name:"Google",component:Ca},discord:{name:"Discord",component:ga},github:{name:"Github",component:va},linkedin:{name:"LinkedIn",component:Ea},twitter:{name:"Twitter",component:Ta},tiktok:{name:"Tiktok",component:Pa},apple:{name:"Apple",component:ya}},Qa=()=>{let e=new URL(window.location.href);e.searchParams.delete("privy_oauth_code"),e.searchParams.delete("privy_oauth_provider"),e.searchParams.delete("privy_oauth_state"),bt.del(wr),window.history.pushState({},"",e)},of=()=>{let{ready:e,user:t,authenticated:o}=U(),{app:r,setModalData:n,navigate:i,resetNavigation:a}=S(),{getAuthMeta:l,initLoginWithOAuth:s,loginWithOAuth:c,updateWallets:u,setReadyToTrue:f,closePrivyModal:v}=R(),[g,y]=Xm(!1),[T,E]=Xm(void 0),w=l()?.provider||"google",_=ef[w].name,I=ef[w].component,L=r?.render.inDialog?ot:0;Zm(()=>{c(w).then(()=>{Qa(),y(!0)}).catch(D=>{let H={retryable:!1,message:"Authentication failed"};if(D?.privyErrorCode==="allowlist_rejected"){E(void 0),a(),i("ALLOWLIST_REJECTION_SCREEN"),Qa();return}else D?.privyErrorCode==="linked_to_another_user"?H.detail="This account has already been linked to another user.":D?.privyErrorCode==="invalid_credentials"?(H.retryable=!0,H.detail="Something went wrong. Try again."):D.privyErrorCode==="oauth_user_denied"?(H.detail=`Retry and check ${zl(w)} to finish connecting your account.`,H.retryable=!0):D?.privyErrorCode==="too_many_requests"&&(H.detail="Too many requests. Please wait before trying again.");Qa(),E(H)}).finally(()=>{f()})},[]),Zm(()=>{if(e&&o&&g&&t)if(xo(t,r?.embeddedWallets?.createOnLogin)){let H=setTimeout(()=>{n({createWallet:{onSuccess:()=>{},onFailure:j=>console.error(j),callAuthOnSuccessOnClose:!0}}),i("EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN")},L);return()=>clearTimeout(H)}else{let H=setTimeout(v,L);return u(),()=>clearTimeout(H)}},[e,o,g,t]);let k=g?`Successfully connected with ${_}`:T?T.message:`Verifying connection to ${_}`,W="";return g?W="You\u2019re good to go!":T?W=T.detail:W="Just a few moments more",Za(K0,{children:[yo(x,{}),yo(K,{}),Za(q0,{children:[yo(j0,{children:Za("div",{children:[yo(Mr,{success:g,fail:!!T}),yo(I,{style:{width:"38px",height:"38px"}})]})}),Za($t,{children:[yo("h3",{children:k}),yo("p",{children:W})]}),T&&T?.retryable?yo(Fi,{onClick:()=>{Qa(),s(w),E(void 0)},disabled:!g&&!T?.retryable,children:"Retry"}):null]}),yo(J,{})]})},q0=tf.div`
|
package/dist/index.js
CHANGED
|
@@ -2081,7 +2081,7 @@ You will need this password to access your ${e} wallet on a new device. Please k
|
|
|
2081
2081
|
overflow: hidden;
|
|
2082
2082
|
max-width: 275px;
|
|
2083
2083
|
text-overflow: ellipsis;
|
|
2084
|
-
`;var Bf=require("@ethersproject/abstract-signer"),Vt=require("@ethersproject/bignumber"),Hf=require("@ethersproject/contracts"),Tv=require("@ethersproject/providers"),Gf=require("@ethersproject/transactions");var Ws={id:42161,name:"Arbitrum One",network:"arbitrum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://arb-mainnet.g.alchemy.com/v2"],webSocket:["wss://arb-mainnet.g.alchemy.com/v2"]},infura:{http:["https://arbitrum-mainnet.infura.io/v3"],webSocket:["wss://arbitrum-mainnet.infura.io/ws/v3"]},default:{http:["https://arb1.arbitrum.io/rpc"]},public:{http:["https://arb1.arbitrum.io/rpc"]}},blockExplorers:{etherscan:{name:"Arbiscan",url:"https://arbiscan.io"},default:{name:"Arbiscan",url:"https://arbiscan.io"}}};var Ms={id:421613,name:"Arbitrum Goerli",network:"arbitrum-goerli",nativeCurrency:{name:"Goerli Ether",symbol:"AGOR",decimals:18},rpcUrls:{alchemy:{http:["https://arb-goerli.g.alchemy.com/v2"],webSocket:["wss://arb-goerli.g.alchemy.com/v2"]},infura:{http:["https://arbitrum-goerli.infura.io/v3"],webSocket:["wss://arbitrum-goerli.infura.io/ws/v3"]},default:{http:["https://goerli-rollup.arbitrum.io/rpc"]},public:{http:["https://goerli-rollup.arbitrum.io/rpc"]}},blockExplorers:{etherscan:{name:"Arbiscan",url:"https://goerli.arbiscan.io/"},default:{name:"Arbiscan",url:"https://goerli.arbiscan.io/"}},testnet:!0};var Ls={id:421614,name:"Arbitrum Sepolia",network:"arbitrum-sepolia",nativeCurrency:{name:"Arbitrum Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia-rollup.arbitrum.io/rpc"]},public:{http:["https://sepolia-rollup.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Blockscout",url:"https://sepolia-explorer.arbitrum.io"}},testnet:!0};var Ns={id:8453,network:"base",name:"Base",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{blast:{http:["https://base-mainnet.blastapi.io"],webSocket:["wss://base-mainnet.blastapi.io"]},default:{http:["https://mainnet.base.org"]},public:{http:["https://mainnet.base.org"]}},blockExplorers:{etherscan:{name:"Basescan",url:"https://basescan.org"},default:{name:"Basescan",url:"https://basescan.org"}},testnet:!0};var Os={id:84531,network:"base-goerli",name:"Base Goerli Testnet",nativeCurrency:{name:"Goerli Ether",symbol:"ETH",decimals:18},rpcUrls:{blast:{http:["https://base-goerli.blastapi.io"],webSocket:["wss://base-goerli.blastapi.io"]},default:{http:["https://goerli.base.org"]},public:{http:["https://goerli.base.org"]}},blockExplorers:{etherscan:{name:"Basescan",url:"https://goerli.basescan.org"},default:{name:"Basescan",url:"https://goerli.basescan.org"}},testnet:!0};var Ds={id:84532,network:"base-sepolia",name:"Base Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia.base.org"]},public:{http:["https://sepolia.base.org"]}},blockExplorers:{default:{name:"Blockscout",url:"https://base-sepolia.blockscout.com"}},testnet:!0};var Us={id:10,name:"OP Mainnet",network:"optimism",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://opt-mainnet.g.alchemy.com/v2"],webSocket:["wss://opt-mainnet.g.alchemy.com/v2"]},infura:{http:["https://optimism-mainnet.infura.io/v3"],webSocket:["wss://optimism-mainnet.infura.io/ws/v3"]},default:{http:["https://mainnet.optimism.io"]},public:{http:["https://mainnet.optimism.io"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://optimistic.etherscan.io"},default:{name:"Optimism Explorer",url:"https://explorer.optimism.io"}}};var Fs={id:420,name:"Optimism Goerli Testnet",network:"optimism-goerli",nativeCurrency:{name:"Goerli Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://opt-goerli.g.alchemy.com/v2"],webSocket:["wss://opt-goerli.g.alchemy.com/v2"]},infura:{http:["https://optimism-goerli.infura.io/v3"],webSocket:["wss://optimism-goerli.infura.io/ws/v3"]},default:{http:["https://goerli.optimism.io"]},public:{http:["https://goerli.optimism.io"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://goerli-optimism.etherscan.io"},default:{name:"Etherscan",url:"https://goerli-optimism.etherscan.io"}},testnet:!0};var Bs={id:11155420,name:"Optimism Sepolia",network:"optimism-sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia.optimism.io"]},public:{http:["https://sepolia.optimism.io"]},infura:{http:["https://optimism-sepolia.infura.io/v3"]}},blockExplorers:{default:{name:"Blockscout",url:"https://optimism-sepolia.blockscout.com"}},testnet:!0};var Hs={id:7777777,name:"Zora",network:"zora",nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"},rpcUrls:{default:{http:["https://rpc.zora.energy"],webSocket:["wss://rpc.zora.energy"]},public:{http:["https://rpc.zora.energy"],webSocket:["wss://rpc.zora.energy"]}},blockExplorers:{default:{name:"Explorer",url:"https://explorer.zora.energy"}}};var Gs={id:999999999,name:"Zora Sepolia",network:"zora-sepolia",nativeCurrency:{decimals:18,name:"Zora Sepolia",symbol:"ETH"},rpcUrls:{default:{http:["https://sepolia.rpc.zora.energy"],webSocket:["wss://sepolia.rpc.zora.energy"]},public:{http:["https://sepolia.rpc.zora.energy"],webSocket:["wss://sepolia.rpc.zora.energy"]}},blockExplorers:{default:{name:"Zora Sepolia Explorer",url:"https://sepolia.explorer.zora.energy/"}},testnet:!0};var zs={id:999,name:"Zora Goerli Testnet",network:"zora-testnet",nativeCurrency:{decimals:18,name:"Zora Goerli",symbol:"ETH"},rpcUrls:{default:{http:["https://testnet.rpc.zora.energy"],webSocket:["wss://testnet.rpc.zora.energy"]},public:{http:["https://testnet.rpc.zora.energy"],webSocket:["wss://testnet.rpc.zora.energy"]}},blockExplorers:{default:{name:"Explorer",url:"https://testnet.explorer.zora.energy"}},testnet:!0};var wc=require("@ethersproject/units"),Df=require("ofetch");var Vi={id:137,name:"Polygon Mainnet",network:"matic",nativeCurrency:{name:"MATIC",symbol:"MATIC",decimals:18},rpcUrls:{alchemy:{http:["https://polygon-mainnet.g.alchemy.com/v2"],webSocket:["wss://polygon-mainnet.g.alchemy.com/v2"]},infura:{http:["https://polygon-mainnet.infura.io/v3"],webSocket:["wss://polygon-mainnet.infura.io/ws/v3"]},default:{http:["https://polygon-rpc.com"]},public:{http:["https://polygon-rpc.com"]}},blockExplorers:{etherscan:{name:"PolygonScan",url:"https://polygonscan.com"},default:{name:"PolygonScan",url:"https://polygonscan.com"}}};var $i={id:80001,name:"Mumbai",network:"maticmum",nativeCurrency:{name:"MATIC",symbol:"MATIC",decimals:18},rpcUrls:{alchemy:{http:["https://polygon-mumbai.g.alchemy.com/v2"],webSocket:["wss://polygon-mumbai.g.alchemy.com/v2"]},infura:{http:["https://polygon-mumbai.infura.io/v3"],webSocket:["wss://polygon-mumbai.infura.io/ws/v3"]},default:{http:["https://matic-mumbai.chainstacklabs.com"]},public:{http:["https://matic-mumbai.chainstacklabs.com"]}},blockExplorers:{etherscan:{name:"PolygonScan",url:"https://mumbai.polygonscan.com"},default:{name:"PolygonScan",url:"https://mumbai.polygonscan.com"}},testnet:!0};var Uf=[Vi.id,$i.id],vc=e=>({maxPriorityFee:(0,wc.parseUnits)(e.maxPriorityFee.toFixed(9),"gwei").toHexString(),maxFee:(0,wc.parseUnits)(e.maxFee.toFixed(9),"gwei").toHexString()}),Pv=e=>({safeLow:vc(e.safeLow),standard:vc(e.standard),fast:vc(e.fast)}),Ff=async e=>{let t="";switch(e){case Vi.id:t="https://gasstation.polygon.technology/v2";break;case $i.id:t="https://gasstation-testnet.polygon.technology/v2";break;default:throw Error(`chainId ${e} does not support polygon gas stations`)}return Pv(await(0,Df.ofetch)(t))};function or(e){if(typeof e=="number"||typeof e=="bigint"||typeof e=="string")return e;if(typeof e.toHexString=="function")return e.toHexString();throw new Error(`Expected numeric value but received ${e}`)}function xv(e){let t={};return e.to!==void 0&&(t.to=e.to),e.data!==void 0&&(t.data=e.data),e.chainId!==void 0&&(t.chainId=e.chainId),e.type!==void 0&&(t.type=e.type),e.accessList!==void 0&&(t.accessList=e.accessList),e.nonce!==void 0&&(t.nonce=or(e.nonce)),e.gasLimit!==void 0&&(t.gasLimit=or(e.gasLimit)),e.gasPrice!==void 0&&(t.gasPrice=or(e.gasPrice)),e.value!==void 0&&(t.value=or(e.value)),e.maxFeePerGas!==void 0&&(t.maxFeePerGas=or(e.maxFeePerGas)),e.maxPriorityFeePerGas!==void 0&&(t.maxPriorityFeePerGas=or(e.maxPriorityFeePerGas)),t}function Sv(e){let t={};return e.to!==void 0&&(t.to=e.to),e.data!==void 0&&(t.data=e.data),e.chainId!==void 0&&(t.chainId=e.chainId),e.type!==void 0&&(t.type=e.type),e.accessList!==void 0&&(t.accessList=e.accessList),e.nonce!==void 0&&(t.nonce=_e(e.nonce).toNumber()),e.gasLimit!==void 0&&(t.gasLimit=_e(e.gasLimit)),e.gasPrice!==void 0&&(t.gasPrice=_e(e.gasPrice)),e.value!==void 0&&(t.value=_e(e.value)),e.maxFeePerGas!==void 0&&(t.maxFeePerGas=_e(e.maxFeePerGas)),e.maxPriorityFeePerGas!==void 0&&(t.maxPriorityFeePerGas=_e(e.maxPriorityFeePerGas)),t}async function ri(e,t,o){t.chainId=Number(t.chainId),Vf(t);let r=new Bf.VoidSigner(e,o);if(t.gas&&(t.gasLimit=t.gas,delete t.gas),Uf.includes(t.chainId)&&(!t.maxPriorityFeePerGas||!t.maxFeePerGas))try{let{standard:i}=await Ff(t.chainId);t.maxPriorityFeePerGas||(t.maxPriorityFeePerGas=i.maxPriorityFee),t.maxFeePerGas||(t.maxFeePerGas=i.maxFee)}catch(i){throw new Error(`Failed to set gas prices from Polygon gas station with error: ${i}.`)}if(_v(t.chainId)&&!t.maxFeePerGas)try{let{lastBaseFeePerGas:i}=await r.getFeeData();if(i){let a=i.mul(Vt.BigNumber.from(120)).div(Vt.BigNumber.from(100));t.maxFeePerGas=or(a),t.maxPriorityFeePerGas=or(Vt.BigNumber.from(0))}}catch(i){throw new Error(`Failed to set gas price for Arbitrum transaction: ${i}.`)}if(Cc(t.chainId)&&(!t.maxPriorityFeePerGas||!t.maxFeePerGas)&&!t.gasPrice)try{if(t.type=2,!t.maxPriorityFeePerGas){let i=await o.send("eth_maxPriorityFeePerGas",[]);t.maxPriorityFeePerGas=i}if(t.maxFeePerGas&&(console.warn("maxFeePerGas is specified without maxPriorityFeePerGas - this can result in hung transactions."),t.maxPriorityFeePerGas>=t.maxFeePerGas))throw new Error("Overridden maxFeePerGas is less than or equal to the calculated maxPriorityFeePerGas. Please set both values or maxPriorityFeePerGas alone for correct gas estimation.");if(!t.maxFeePerGas){let{lastBaseFeePerGas:i}=await r.getFeeData();if(!i)throw new Error("Unable to fetch baseFee for last block.");let s=Vt.BigNumber.from(i).mul(Vt.BigNumber.from(126)).div(Vt.BigNumber.from(100)).add(Vt.BigNumber.from(t.maxPriorityFeePerGas));t.maxFeePerGas=or(s)}}catch(i){throw new Error(`Failed to set gas price for OP stack transaction: ${i}.`)}kv(t.chainId)&&t.type!=0&&((t.type==1||t.type==2)&&console.warn("Transaction request type specified is incompatible for chain and will result in undefined behavior. Please use transaction type 0."),t.type===void 0&&(t.type=0));let n=await r.populateTransaction({to:t.to,from:t.from,nonce:t.nonce,gasLimit:t.gasLimit,gasPrice:t.gasPrice,data:t.data,value:t.value,chainId:t.chainId,type:t.type,accessList:t.accessList,maxFeePerGas:t.maxFeePerGas,maxPriorityFeePerGas:t.maxPriorityFeePerGas});return xv(n)}async function Vs(e,t,o,r,n){r=Object.assign({chainId:Fo},r),Vf(r);let a=(await o.rpc({address:t,accessToken:e,request:{method:"eth_signTransaction",params:[r]}})).response.data;return await n.sendTransaction(a)}async function zf(e,t,o){let r=await o.getBalance(e),n=t.value||0,i=r.sub(_e(n)),a=!i.isNegative()&&!i.isZero();return{balance:r,hasSufficientFunds:a}}function Cc(e){return[Ns.id,Os.id,Ds.id,Us.id,Fs.id,Bs.id,Hs.id,zs.id,Gs.id].includes(e)}function _v(e){return[Ws.id,Ms.id,Ls.id].includes(e)}function kv(e){return[56,97].includes(e)}async function bc(e,t){if(!e.chainId||e.chainId&&!Cc(e.chainId))return Vt.BigNumber.from(0);let o=Vt.BigNumber.from(0);try{let r=new Hf.Contract(vd,wd,t),n=Sv(e),i=(0,Gf.serialize)(n);o=await r.getL1Fee(i)}catch{}return o}async function $s(e,t){delete e.from;let o=Vt.BigNumber.from(0),r=Vt.BigNumber.from(0);if(e.gasLimit?o=_e(e.gasLimit):o=await t.estimateGas(e),e.type==2)if(e.maxFeePerGas)r=_e(e.maxFeePerGas);else{let i=await t.getFeeData();i.maxFeePerGas&&(r=i.maxFeePerGas)}else if(e.type==0||e.type==1)if(e.gasPrice)r=_e(e.gasPrice);else{let i=await t.getFeeData();i.gasPrice&&(r=i.gasPrice)}else if(e.gasPrice)r=_e(e.gasPrice);else{let i=await t.getFeeData();i.gasPrice&&(r=i.gasPrice)}let n=o.mul(r);if(e.chainId&&Cc(e.chainId))try{let i=await bc(e,t);n=n.add(i)}catch{}return n}function Vf(e){let t=["gasLimit","gasPrice","value","maxPriorityFeePerGas","maxFeePerGas"];for(let o of t){let r=e[o];if(!(typeof r>"u")&&!Av(r))throw new Error(`Transaction request property '${o}' must be a valid number, bigint, or hex string representing a quantity`)}if(typeof e.chainId!="number")throw new Error("Transaction request property 'chainId' must be a number")}function Av(e){let t=typeof e=="number",o=typeof e=="bigint",r=typeof e=="string"&&Rv(e);return t||o||r}function Rv(e){return/^-?0x[a-f0-9]+$/i.test(e)}function qs(e){return{to:e.to,from:e.from,contractAddress:e.contractAddress,transactionIndex:e.transactionIndex,root:e.root,logsBloom:e.logsBloom,blockHash:e.blockHash,transactionHash:e.transactionHash,logs:e.logs,blockNumber:e.blockNumber,confirmations:e.confirmations,byzantium:e.byzantium,type:e.type,status:e.status,gasUsed:e.gasUsed.toHexString(),cumulativeGasUsed:e.cumulativeGasUsed.toHexString(),effectiveGasPrice:e.effectiveGasPrice?e.effectiveGasPrice.toHexString():void 0}}var ni=require("react");var js=e=>{let{showFiatPrices:t,getUsdTokenPrice:o,chains:r}=I(),[n,i]=(0,ni.useState)(!0),[a,l]=(0,ni.useState)(void 0),[s,c]=(0,ni.useState)(void 0);return(0,ni.useEffect)(()=>{let m=e.chainId||Fo,h=r.find(g=>g.id===Number(m));if(!h)throw new q(`Unsupported chain: ${m}`);(async()=>{if(!t){i(!1);return}try{i(!0);let g=await o(h);g?c(g):l(new Error(`Unable to fetch token price on chain id ${h.id}`))}catch(g){l(g)}finally{i(!1)}})()},[e.chainId]),{tokenPrice:s,isTokenPriceLoading:n,tokenPriceError:a}};var Ks=require("react"),Ec=(0,Ks.createContext)({wallets:[],ready:!1});function ii(){return(0,Ks.useContext)(Ec)}var Pc=require("react/jsx-runtime"),Tc=({pendingTransaction:e})=>{let{getAccessToken:t}=H(),{wallets:o}=ii(),{walletProxy:r,rpcConfig:n,chains:i,nativeTokenSymbolForChainId:a}=I(),[l,s]=(0,en.useState)(e),{tokenPrice:c}=js(l),[m,h]=(0,en.useState)(null),v=a(e.chainId)||"ETH",g=(0,en.useMemo)(()=>o.find(y=>y.walletClientType==="privy"),[o]);return(0,en.useEffect)(()=>{async function y(){if(!await t()||!r||!g)return l;let E=new $f.StaticJsonRpcProvider(Jt(l.chainId,i,n)),w=await $s(l,E);return h(_e(w.toBigInt()).toHexString()),ri(g.address,l,E)}y().then(T=>{s(T)})},[r]),g?(0,Pc.jsx)(Iv,{children:(0,Pc.jsx)(ti,{from:g.address,to:l.to,txn:l,gas:m??void 0,tokenPrice:c,tokenSymbol:v})}):null},Iv=qf.default.div`
|
|
2084
|
+
`;var Bf=require("@ethersproject/abstract-signer"),Vt=require("@ethersproject/bignumber"),Hf=require("@ethersproject/contracts"),Tv=require("@ethersproject/providers"),Gf=require("@ethersproject/transactions");var Ws={id:42161,name:"Arbitrum One",network:"arbitrum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://arb-mainnet.g.alchemy.com/v2"],webSocket:["wss://arb-mainnet.g.alchemy.com/v2"]},infura:{http:["https://arbitrum-mainnet.infura.io/v3"],webSocket:["wss://arbitrum-mainnet.infura.io/ws/v3"]},default:{http:["https://arb1.arbitrum.io/rpc"]},public:{http:["https://arb1.arbitrum.io/rpc"]}},blockExplorers:{etherscan:{name:"Arbiscan",url:"https://arbiscan.io"},default:{name:"Arbiscan",url:"https://arbiscan.io"}}};var Ms={id:421613,name:"Arbitrum Goerli",network:"arbitrum-goerli",nativeCurrency:{name:"Goerli Ether",symbol:"AGOR",decimals:18},rpcUrls:{alchemy:{http:["https://arb-goerli.g.alchemy.com/v2"],webSocket:["wss://arb-goerli.g.alchemy.com/v2"]},infura:{http:["https://arbitrum-goerli.infura.io/v3"],webSocket:["wss://arbitrum-goerli.infura.io/ws/v3"]},default:{http:["https://goerli-rollup.arbitrum.io/rpc"]},public:{http:["https://goerli-rollup.arbitrum.io/rpc"]}},blockExplorers:{etherscan:{name:"Arbiscan",url:"https://goerli.arbiscan.io/"},default:{name:"Arbiscan",url:"https://goerli.arbiscan.io/"}},testnet:!0};var Ls={id:421614,name:"Arbitrum Sepolia",network:"arbitrum-sepolia",nativeCurrency:{name:"Arbitrum Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia-rollup.arbitrum.io/rpc"]},public:{http:["https://sepolia-rollup.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Blockscout",url:"https://sepolia-explorer.arbitrum.io"}},testnet:!0};var Ns={id:8453,network:"base",name:"Base",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{blast:{http:["https://base-mainnet.blastapi.io"],webSocket:["wss://base-mainnet.blastapi.io"]},default:{http:["https://mainnet.base.org"]},public:{http:["https://mainnet.base.org"]}},blockExplorers:{etherscan:{name:"Basescan",url:"https://basescan.org"},default:{name:"Basescan",url:"https://basescan.org"}},testnet:!0};var Os={id:84531,network:"base-goerli",name:"Base Goerli Testnet",nativeCurrency:{name:"Goerli Ether",symbol:"ETH",decimals:18},rpcUrls:{blast:{http:["https://base-goerli.blastapi.io"],webSocket:["wss://base-goerli.blastapi.io"]},default:{http:["https://goerli.base.org"]},public:{http:["https://goerli.base.org"]}},blockExplorers:{etherscan:{name:"Basescan",url:"https://goerli.basescan.org"},default:{name:"Basescan",url:"https://goerli.basescan.org"}},testnet:!0};var Ds={id:84532,network:"base-sepolia",name:"Base Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia.base.org"]},public:{http:["https://sepolia.base.org"]}},blockExplorers:{default:{name:"Blockscout",url:"https://base-sepolia.blockscout.com"}},testnet:!0};var Us={id:10,name:"OP Mainnet",network:"optimism",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://opt-mainnet.g.alchemy.com/v2"],webSocket:["wss://opt-mainnet.g.alchemy.com/v2"]},infura:{http:["https://optimism-mainnet.infura.io/v3"],webSocket:["wss://optimism-mainnet.infura.io/ws/v3"]},default:{http:["https://mainnet.optimism.io"]},public:{http:["https://mainnet.optimism.io"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://optimistic.etherscan.io"},default:{name:"Optimism Explorer",url:"https://explorer.optimism.io"}}};var Fs={id:420,name:"Optimism Goerli Testnet",network:"optimism-goerli",nativeCurrency:{name:"Goerli Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://opt-goerli.g.alchemy.com/v2"],webSocket:["wss://opt-goerli.g.alchemy.com/v2"]},infura:{http:["https://optimism-goerli.infura.io/v3"],webSocket:["wss://optimism-goerli.infura.io/ws/v3"]},default:{http:["https://goerli.optimism.io"]},public:{http:["https://goerli.optimism.io"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://goerli-optimism.etherscan.io"},default:{name:"Etherscan",url:"https://goerli-optimism.etherscan.io"}},testnet:!0};var Bs={id:11155420,name:"Optimism Sepolia",network:"optimism-sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia.optimism.io"]},public:{http:["https://sepolia.optimism.io"]},infura:{http:["https://optimism-sepolia.infura.io/v3"]}},blockExplorers:{default:{name:"Blockscout",url:"https://optimism-sepolia.blockscout.com"}},testnet:!0};var Hs={id:7777777,name:"Zora",network:"zora",nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"},rpcUrls:{default:{http:["https://rpc.zora.energy"],webSocket:["wss://rpc.zora.energy"]},public:{http:["https://rpc.zora.energy"],webSocket:["wss://rpc.zora.energy"]}},blockExplorers:{default:{name:"Explorer",url:"https://explorer.zora.energy"}}};var Gs={id:999999999,name:"Zora Sepolia",network:"zora-sepolia",nativeCurrency:{decimals:18,name:"Zora Sepolia",symbol:"ETH"},rpcUrls:{default:{http:["https://sepolia.rpc.zora.energy"],webSocket:["wss://sepolia.rpc.zora.energy"]},public:{http:["https://sepolia.rpc.zora.energy"],webSocket:["wss://sepolia.rpc.zora.energy"]}},blockExplorers:{default:{name:"Zora Sepolia Explorer",url:"https://sepolia.explorer.zora.energy/"}},testnet:!0};var zs={id:999,name:"Zora Goerli Testnet",network:"zora-testnet",nativeCurrency:{decimals:18,name:"Zora Goerli",symbol:"ETH"},rpcUrls:{default:{http:["https://testnet.rpc.zora.energy"],webSocket:["wss://testnet.rpc.zora.energy"]},public:{http:["https://testnet.rpc.zora.energy"],webSocket:["wss://testnet.rpc.zora.energy"]}},blockExplorers:{default:{name:"Explorer",url:"https://testnet.explorer.zora.energy"}},testnet:!0};var wc=require("@ethersproject/units"),Df=require("ofetch");var Vi={id:137,name:"Polygon Mainnet",network:"matic",nativeCurrency:{name:"MATIC",symbol:"MATIC",decimals:18},rpcUrls:{alchemy:{http:["https://polygon-mainnet.g.alchemy.com/v2"],webSocket:["wss://polygon-mainnet.g.alchemy.com/v2"]},infura:{http:["https://polygon-mainnet.infura.io/v3"],webSocket:["wss://polygon-mainnet.infura.io/ws/v3"]},default:{http:["https://polygon-rpc.com"]},public:{http:["https://polygon-rpc.com"]}},blockExplorers:{etherscan:{name:"PolygonScan",url:"https://polygonscan.com"},default:{name:"PolygonScan",url:"https://polygonscan.com"}}};var $i={id:80001,name:"Mumbai",network:"maticmum",nativeCurrency:{name:"MATIC",symbol:"MATIC",decimals:18},rpcUrls:{alchemy:{http:["https://polygon-mumbai.g.alchemy.com/v2"],webSocket:["wss://polygon-mumbai.g.alchemy.com/v2"]},infura:{http:["https://polygon-mumbai.infura.io/v3"],webSocket:["wss://polygon-mumbai.infura.io/ws/v3"]},default:{http:["https://matic-mumbai.chainstacklabs.com"]},public:{http:["https://matic-mumbai.chainstacklabs.com"]}},blockExplorers:{etherscan:{name:"PolygonScan",url:"https://mumbai.polygonscan.com"},default:{name:"PolygonScan",url:"https://mumbai.polygonscan.com"}},testnet:!0};var Uf=[Vi.id,$i.id],vc=e=>({maxPriorityFee:(0,wc.parseUnits)(e.maxPriorityFee.toFixed(9),"gwei").toHexString(),maxFee:(0,wc.parseUnits)(e.maxFee.toFixed(9),"gwei").toHexString()}),Pv=e=>({safeLow:vc(e.safeLow),standard:vc(e.standard),fast:vc(e.fast)}),Ff=async e=>{let t="";switch(e){case Vi.id:t="https://gasstation.polygon.technology/v2";break;case $i.id:t="https://gasstation-testnet.polygon.technology/v2";break;default:throw Error(`chainId ${e} does not support polygon gas stations`)}return Pv(await(0,Df.ofetch)(t))};function or(e){if(typeof e=="number"||typeof e=="bigint"||typeof e=="string")return e;if(typeof e.toHexString=="function")return e.toHexString();throw new Error(`Expected numeric value but received ${e}`)}function xv(e){let t={};return e.to!==void 0&&(t.to=e.to),e.data!==void 0&&(t.data=e.data),e.chainId!==void 0&&(t.chainId=e.chainId),e.type!==void 0&&(t.type=e.type),e.accessList!==void 0&&(t.accessList=e.accessList),e.nonce!==void 0&&(t.nonce=or(e.nonce)),e.gasLimit!==void 0&&(t.gasLimit=or(e.gasLimit)),e.gasPrice!==void 0&&(t.gasPrice=or(e.gasPrice)),e.value!==void 0&&(t.value=or(e.value)),e.maxFeePerGas!==void 0&&(t.maxFeePerGas=or(e.maxFeePerGas)),e.maxPriorityFeePerGas!==void 0&&(t.maxPriorityFeePerGas=or(e.maxPriorityFeePerGas)),t}function Sv(e){let t={};return e.to!==void 0&&(t.to=e.to),e.data!==void 0&&(t.data=e.data),e.chainId!==void 0&&(t.chainId=e.chainId),e.type!==void 0&&(t.type=e.type),e.accessList!==void 0&&(t.accessList=e.accessList),e.nonce!==void 0&&(t.nonce=_e(e.nonce).toNumber()),e.gasLimit!==void 0&&(t.gasLimit=_e(e.gasLimit)),e.gasPrice!==void 0&&(t.gasPrice=_e(e.gasPrice)),e.value!==void 0&&(t.value=_e(e.value)),e.maxFeePerGas!==void 0&&(t.maxFeePerGas=_e(e.maxFeePerGas)),e.maxPriorityFeePerGas!==void 0&&(t.maxPriorityFeePerGas=_e(e.maxPriorityFeePerGas)),t}async function ri(e,t,o){t.chainId=Number(t.chainId),Vf(t);let r=new Bf.VoidSigner(e,o);if(t.gas&&(t.gasLimit=t.gas,delete t.gas),Uf.includes(t.chainId)&&(!t.maxPriorityFeePerGas||!t.maxFeePerGas))try{let{standard:i}=await Ff(t.chainId);t.maxPriorityFeePerGas||(t.maxPriorityFeePerGas=i.maxPriorityFee),t.maxFeePerGas||(t.maxFeePerGas=i.maxFee)}catch(i){throw new Error(`Failed to set gas prices from Polygon gas station with error: ${i}.`)}if(_v(t.chainId)&&!t.maxFeePerGas)try{let{lastBaseFeePerGas:i}=await r.getFeeData();if(i){let a=i.mul(Vt.BigNumber.from(120)).div(Vt.BigNumber.from(100));t.maxFeePerGas=or(a),t.maxPriorityFeePerGas=or(Vt.BigNumber.from(0))}}catch(i){throw new Error(`Failed to set gas price for Arbitrum transaction: ${i}.`)}if(Cc(t.chainId)&&(!t.maxPriorityFeePerGas||!t.maxFeePerGas)&&!t.gasPrice)try{if(t.type=2,!t.maxPriorityFeePerGas){let i=await o.send("eth_maxPriorityFeePerGas",[]);t.maxPriorityFeePerGas=i}if(t.maxFeePerGas&&(console.warn("maxFeePerGas is specified without maxPriorityFeePerGas - this can result in hung transactions."),t.maxPriorityFeePerGas>=t.maxFeePerGas))throw new Error("Overridden maxFeePerGas is less than or equal to the calculated maxPriorityFeePerGas. Please set both values or maxPriorityFeePerGas alone for correct gas estimation.");if(!t.maxFeePerGas){let{lastBaseFeePerGas:i}=await r.getFeeData();if(!i)throw new Error("Unable to fetch baseFee for last block.");let s=Vt.BigNumber.from(i).mul(Vt.BigNumber.from(126)).div(Vt.BigNumber.from(100)).add(Vt.BigNumber.from(t.maxPriorityFeePerGas));t.maxFeePerGas=or(s)}}catch(i){throw new Error(`Failed to set gas price for OP stack transaction: ${i}.`)}kv(t.chainId)&&t.type!=0&&((t.type==1||t.type==2)&&console.warn("Transaction request type specified is incompatible for chain and will result in undefined behavior. Please use transaction type 0."),t.type===void 0&&(t.type=0));let n=await r.populateTransaction({to:t.to,from:t.from,nonce:t.nonce,gasLimit:t.gasLimit,gasPrice:t.gasPrice,data:t.data,value:t.value,chainId:t.chainId,type:t.type,accessList:t.accessList,maxFeePerGas:t.maxFeePerGas,maxPriorityFeePerGas:t.maxPriorityFeePerGas});return xv(n)}async function Vs(e,t,o,r,n){r=Object.assign({chainId:Fo},r),Vf(r);let a=(await o.rpc({address:t,accessToken:e,request:{method:"eth_signTransaction",params:[r]}})).response.data;return await n.sendTransaction(a)}async function zf(e,t,o){let r=await o.getBalance(e),n=t.value||0,i=r.sub(_e(n)),a=!i.isNegative()&&!i.isZero();return{balance:r,hasSufficientFunds:a}}function Cc(e){return[Ns.id,Os.id,Ds.id,Us.id,Fs.id,Bs.id,Hs.id,zs.id,Gs.id].includes(e)}function _v(e){return[Ws.id,Ms.id,Ls.id].includes(e)}function kv(e){return[56,97].includes(e)}async function bc(e,t){if(!e.chainId||e.chainId&&!Cc(e.chainId))return Vt.BigNumber.from(0);let o=Vt.BigNumber.from(0);try{let r=new Hf.Contract(vd,wd,t),n=Sv(e),i=(0,Gf.serialize)(n);o=await r.getL1Fee(i)}catch{}return o}async function $s(e,t){delete e.from;let o=Vt.BigNumber.from(0),r=Vt.BigNumber.from(0);if(e.gasLimit?o=_e(e.gasLimit):o=await t.estimateGas(e),e.type==2)if(e.maxFeePerGas)r=_e(e.maxFeePerGas);else{let i=await t.getFeeData();i.maxFeePerGas&&(r=i.maxFeePerGas)}else if(e.type==0||e.type==1)if(e.gasPrice)r=_e(e.gasPrice);else{let i=await t.getFeeData();i.gasPrice&&(r=i.gasPrice)}else if(e.gasPrice)r=_e(e.gasPrice);else{let i=await t.getFeeData();i.gasPrice&&(r=i.gasPrice)}let n=o.mul(r);if(e.chainId&&Cc(e.chainId))try{let i=await bc(e,t);n=n.add(i)}catch{}return n}function Vf(e){let t=["gasLimit","gasPrice","value","maxPriorityFeePerGas","maxFeePerGas"];for(let o of t){let r=e[o];if(!(typeof r>"u")&&!Av(r))throw new Error(`Transaction request property '${o}' must be a valid number, bigint, or hex string representing a quantity`)}if(typeof e.chainId!="number")throw new Error("Transaction request property 'chainId' must be a number")}function Av(e){let t=typeof e=="number",o=typeof e=="bigint",r=typeof e=="string"&&Rv(e);return t||o||r}function Rv(e){return/^-?0x[a-f0-9]+$/i.test(e)}function qs(e){return{to:e.to,from:e.from,contractAddress:e.contractAddress,transactionIndex:e.transactionIndex,root:e.root,logsBloom:e.logsBloom,blockHash:e.blockHash,transactionHash:e.transactionHash,logs:e.logs,blockNumber:e.blockNumber,confirmations:e.confirmations,byzantium:e.byzantium,type:e.type,status:e.status,gasUsed:e.gasUsed.toHexString(),cumulativeGasUsed:e.cumulativeGasUsed.toHexString(),effectiveGasPrice:e.effectiveGasPrice?e.effectiveGasPrice.toHexString():void 0}}var ni=require("react");var js=e=>{let{showFiatPrices:t,getUsdTokenPrice:o,chains:r}=I(),[n,i]=(0,ni.useState)(!0),[a,l]=(0,ni.useState)(void 0),[s,c]=(0,ni.useState)(void 0);return(0,ni.useEffect)(()=>{let m=e.chainId||Fo,h=r.find(g=>g.id===Number(m));if(!h)throw new q(`Unsupported chain: ${m}`);(async()=>{if(!t){i(!1);return}try{i(!0);let g=await o(h);g?c(g):l(new Error(`Unable to fetch token price on chain id ${h.id}`))}catch(g){l(g)}finally{i(!1)}})()},[e.chainId]),{tokenPrice:s,isTokenPriceLoading:n,tokenPriceError:a}};var Ks=require("react"),Ec=(0,Ks.createContext)(null);function ii(){let e=(0,Ks.useContext)(Ec);if(e===null)throw new Error("`useWallets` was called outside the PrivyProvider component");return e}var Pc=require("react/jsx-runtime"),Tc=({pendingTransaction:e})=>{let{getAccessToken:t}=H(),{wallets:o}=ii(),{walletProxy:r,rpcConfig:n,chains:i,nativeTokenSymbolForChainId:a}=I(),[l,s]=(0,en.useState)(e),{tokenPrice:c}=js(l),[m,h]=(0,en.useState)(null),v=a(e.chainId)||"ETH",g=(0,en.useMemo)(()=>o.find(y=>y.walletClientType==="privy"),[o]);return(0,en.useEffect)(()=>{async function y(){if(!await t()||!r||!g)return l;let E=new $f.StaticJsonRpcProvider(Jt(l.chainId,i,n)),w=await $s(l,E);return h(_e(w.toBigInt()).toHexString()),ri(g.address,l,E)}y().then(T=>{s(T)})},[r]),g?(0,Pc.jsx)(Iv,{children:(0,Pc.jsx)(ti,{from:g.address,to:l.to,txn:l,gas:m??void 0,tokenPrice:c,tokenSymbol:v})}):null},Iv=qf.default.div`
|
|
2085
2085
|
width: 100%;
|
|
2086
2086
|
padding: 1rem 0;
|
|
2087
2087
|
`;var B=require("react/jsx-runtime"),xc=({open:e,onClose:t})=>{let{user:o}=H(),[r,n]=(0,ai.useState)(null),{init:i,cancel:a}=Zr();(0,ai.useEffect)(()=>{e&&o?.mfaMethods&&o.mfaMethods.length>0?l(o.mfaMethods[0]):n(null)},[o?.mfaMethods,e]);async function l(c){try{n(c),await i(c)}catch(m){console.error(m)}}let s=()=>{n(null),a(),t()};return!e||!o?null:r?(0,B.jsx)(Wv,{selectedMethod:r,onClose:s,onBack:o.mfaMethods.length>1?()=>n(null):void 0}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(x,{onClose:s},"header"),(0,B.jsx)(at,{children:(0,B.jsx)(ut,{children:(0,B.jsx)(jf.ShieldCheckIcon,{})})}),(0,B.jsx)(st,{children:"Verify your identity"}),(0,B.jsx)(Qe,{children:"Choose a verification method"}),(0,B.jsxs)(Es,{children:[o.mfaMethods.includes("totp")&&(0,B.jsxs)(Oe,{onClick:()=>l("totp"),children:[(0,B.jsx)(Ys.DevicePhoneMobileIcon,{}),"Authenticator App"]},"totp"),o.mfaMethods.includes("sms")&&(0,B.jsxs)(Oe,{onClick:()=>l("sms"),children:[(0,B.jsx)(Ys.PhoneIcon,{}),"SMS"]},"sms")]}),(0,B.jsx)(ee,{})]})},Wv=({selectedMethod:e,onClose:t,onBack:o})=>{let{app:r}=S(),{pendingTransaction:n}=I(),[i,a]=(0,ai.useState)(!1),[l,s]=(0,ai.useState)(!1),{submit:c}=Zr();async function m(h){try{if(!h)return;await c(e,h),s(!0),a(!1),t()}catch(v){throw Ja(v)?(a(!0),new Error("You have exceeded the maximum number of attempts. Please close this window and try again in 10 seconds.")):Vr(v)?(a(!1),new Error("The code you entered is not valid")):zr(v)?(a(!0),new Error("You have exceeded the time limit for code entry. Please try again in 30 seconds.")):(a(!1),new Error("Unknown error"))}}switch(e){case"sms":return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(x,{onClose:t},"header"),(0,B.jsx)(at,{children:(0,B.jsx)(ut,{children:(0,B.jsx)(Js.PhoneIcon,{})})}),(0,B.jsx)(st,{children:"Enter verification code"}),(0,B.jsxs)(kr,{children:[(0,B.jsx)(Qn,{success:l,disabled:i,onChange:m}),(0,B.jsxs)(Qe,{children:["To continue, please enter the 6-digit code sent to your ",(0,B.jsx)("strong",{children:"mobile device"})]}),n&&(0,B.jsx)(Tc,{pendingTransaction:n})]}),o&&(0,B.jsx)(lc,{theme:r?.appearance.palette.colorScheme,onClick:o,children:"Choose another method"}),(0,B.jsx)(Vo,{onClick:t,children:"Not now"}),(0,B.jsx)(ee,{})]});case"totp":return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(x,{onClose:t},"header"),(0,B.jsx)(at,{children:(0,B.jsx)(ut,{children:(0,B.jsx)(Js.DevicePhoneMobileIcon,{})})}),(0,B.jsx)(st,{children:"Enter verification code"}),(0,B.jsxs)(kr,{children:[(0,B.jsx)(Qn,{success:l,disabled:i,onChange:m}),(0,B.jsxs)(Qe,{children:["To continue, please enter the 6-digit code generated from your"," ",(0,B.jsx)("strong",{children:"authenticator app"})]}),n&&(0,B.jsx)(Tc,{pendingTransaction:n})]}),o&&(0,B.jsx)(lc,{theme:r?.appearance.palette.colorScheme,onClick:o,children:"Choose another method"}),(0,B.jsx)(Vo,{onClick:t,children:"Not now"}),(0,B.jsx)(ee,{})]});default:return null}};var si=require("react"),_c=_(require("styled-components"));function Sc(e){return e.charAt(0).toUpperCase()+e.slice(1)}var Xe=require("react/jsx-runtime"),Kf={google:{name:"Google",component:fs},discord:{name:"Discord",component:us},github:{name:"Github",component:ms},linkedin:{name:"LinkedIn",component:hs},twitter:{name:"Twitter",component:gs},tiktok:{name:"Tiktok",component:ys},apple:{name:"Apple",component:ps}},Qs=()=>{let e=new URL(window.location.href);e.searchParams.delete("privy_oauth_code"),e.searchParams.delete("privy_oauth_provider"),e.searchParams.delete("privy_oauth_state"),Kt.del(ln),window.history.pushState({},"",e)},Yf=()=>{let{ready:e,user:t,authenticated:o}=H(),{app:r,setModalData:n,navigate:i,resetNavigation:a}=S(),{getAuthMeta:l,initLoginWithOAuth:s,loginWithOAuth:c,updateWallets:m,setReadyToTrue:h,closePrivyModal:v}=I(),[g,y]=(0,si.useState)(!1),[T,E]=(0,si.useState)(void 0),w=l()?.provider||"google",k=Kf[w].name,W=Kf[w].component,N=r?.render.inDialog?Tt:0;(0,si.useEffect)(()=>{c(w).then(()=>{Qs(),y(!0)}).catch(U=>{let $={retryable:!1,message:"Authentication failed"};if(U?.privyErrorCode==="allowlist_rejected"){E(void 0),a(),i("ALLOWLIST_REJECTION_SCREEN"),Qs();return}else U?.privyErrorCode==="linked_to_another_user"?$.detail="This account has already been linked to another user.":U?.privyErrorCode==="invalid_credentials"?($.retryable=!0,$.detail="Something went wrong. Try again."):U.privyErrorCode==="oauth_user_denied"?($.detail=`Retry and check ${Sc(w)} to finish connecting your account.`,$.retryable=!0):U?.privyErrorCode==="too_many_requests"&&($.detail="Too many requests. Please wait before trying again.");Qs(),E($)}).finally(()=>{h()})},[]),(0,si.useEffect)(()=>{if(e&&o&&g&&t)if(dr(t,r?.embeddedWallets?.createOnLogin)){let $=setTimeout(()=>{n({createWallet:{onSuccess:()=>{},onFailure:Y=>console.error(Y),callAuthOnSuccessOnClose:!0}}),i("EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN")},N);return()=>clearTimeout($)}else{let $=setTimeout(v,N);return m(),()=>clearTimeout($)}},[e,o,g,t]);let A=g?`Successfully connected with ${k}`:T?T.message:`Verifying connection to ${k}`,M="";return g?M="You\u2019re good to go!":T?M=T.detail:M="Just a few moments more",(0,Xe.jsxs)(Xe.Fragment,{children:[(0,Xe.jsx)(x,{}),(0,Xe.jsx)(Z,{}),(0,Xe.jsxs)(Mv,{children:[(0,Xe.jsx)(Lv,{children:(0,Xe.jsxs)("div",{children:[(0,Xe.jsx)(xn,{success:g,fail:!!T}),(0,Xe.jsx)(W,{style:{width:"38px",height:"38px"}})]})}),(0,Xe.jsxs)(wo,{children:[(0,Xe.jsx)("h3",{children:A}),(0,Xe.jsx)("p",{children:M})]}),T&&T?.retryable?(0,Xe.jsx)(Da,{onClick:()=>{Qs(),s(w),E(void 0)},disabled:!g&&!T?.retryable,children:"Retry"}):null]}),(0,Xe.jsx)(ee,{})]})},Mv=_c.default.div`
|
package/package.json
CHANGED