reverse-mirage
Advanced tools
Comparing version 1.0.0-next.2 to 1.0.0-next.3
1853
dist/index.js
@@ -1,1848 +0,11 @@ | ||
// src/amount/utils.ts | ||
import invariant from "tiny-invariant"; | ||
import { parseUnits } from "viem/utils"; | ||
var scaleUp = (token, amount) => token.decimals ? amount * 10n ** BigInt(token.decimals) : amount; | ||
var scaleDown = (token, amount) => token.decimals ? amount / 10n ** BigInt(token.decimals) : amount; | ||
var isAmount = (x) => typeof x === "object"; | ||
var createAmountFromString = (token, amount) => ({ | ||
type: `${token.type}Amount`, | ||
token, | ||
amount: token.decimals ? parseUnits(amount, token.decimals) : BigInt(amount) | ||
}); | ||
var createAmountFromFraction = (token, amount) => ({ | ||
type: `${token.type}Amount`, | ||
token, | ||
amount: scaleUp(token, amount.numerator) / amount.denominator | ||
}); | ||
var createAmountFromRaw = (token, amount) => ({ | ||
type: `${token.type}Amount`, | ||
token, | ||
amount | ||
}); | ||
var amountAdd = (a, b) => { | ||
if (isAmount(b)) { | ||
invariant(a.token === b.token); | ||
} | ||
return isAmount(b) ? { ...a, amount: a.amount + b.amount } : { ...a, amount: a.amount + scaleUp(a.token, BigInt(b)) }; | ||
}; | ||
var amountSubtract = (a, b) => { | ||
if (isAmount(b)) { | ||
invariant(a.token === b.token); | ||
} | ||
return isAmount(b) ? { ...a, amount: a.amount - b.amount } : { ...a, amount: a.amount - scaleUp(a.token, BigInt(b)) }; | ||
}; | ||
var amountMultiply = (a, b) => { | ||
if (isAmount(b)) { | ||
invariant(a.token === b.token); | ||
} | ||
return isAmount(b) ? { ...a, amount: scaleDown(a.token, a.amount * b.amount) } : { ...a, amount: a.amount * BigInt(b) }; | ||
}; | ||
var amountDivide = (a, b) => { | ||
if (isAmount(b)) { | ||
invariant(a.token === b.token); | ||
} | ||
return isAmount(b) ? { ...a, amount: scaleUp(a.token, a.amount) / b.amount } : { ...a, amount: a.amount / BigInt(b) }; | ||
}; | ||
var amountLessThan = (a, b) => { | ||
if (isAmount(b)) { | ||
invariant(a.token === b.token); | ||
} | ||
return isAmount(b) ? a.amount < b.amount : a.amount < scaleUp(a.token, BigInt(b)); | ||
}; | ||
var amountEqualTo = (a, b) => { | ||
if (isAmount(b)) { | ||
invariant(a.token === b.token); | ||
} | ||
return isAmount(b) ? a.amount === b.amount : a.amount === scaleUp(a.token, BigInt(b)); | ||
}; | ||
var amountGreaterThan = (a, b) => { | ||
if (isAmount(b)) { | ||
invariant(a.token === b.token); | ||
} | ||
return isAmount(b) ? a.amount > b.amount : a.amount > scaleUp(a.token, BigInt(b)); | ||
}; | ||
var amountToNumber = (amount) => Number(amount.amount) / 10 ** (amount.token.decimals ?? 0); | ||
import h from 'tiny-invariant'; | ||
import { parseUnits } from 'viem/utils'; | ||
import { getAddress } from 'viem'; | ||
import { readContract, writeContract } from 'viem/contract'; | ||
import { signTypedData, getBalance } from 'viem/actions'; | ||
// src/native/utils.ts | ||
var createNativeCurrency = (name, symbol, decimals, chainID) => ({ | ||
type: "nativeCurrency", | ||
name, | ||
symbol, | ||
decimals, | ||
chainID | ||
}); | ||
var T=(t,e)=>t.decimals?e*10n**BigInt(t.decimals):e,xt=(t,e)=>t.decimals?e/10n**BigInt(t.decimals):e,y=t=>typeof t=="object",Q=(t,e)=>({type:`${t.type}Amount`,token:t,amount:t.decimals?parseUnits(e,t.decimals):BigInt(e)}),U=(t,e)=>({type:`${t.type}Amount`,token:t,amount:T(t,e.numerator)/e.denominator}),l=(t,e)=>({type:`${t.type}Amount`,token:t,amount:e}),Fe=(t,e)=>(y(e)&&h(t.token===e.token),y(e)?{...t,amount:t.amount+e.amount}:{...t,amount:t.amount+T(t.token,BigInt(e))}),Oe=(t,e)=>(y(e)&&h(t.token===e.token),y(e)?{...t,amount:t.amount-e.amount}:{...t,amount:t.amount-T(t.token,BigInt(e))}),Ne=(t,e)=>(y(e)&&h(t.token===e.token),y(e)?{...t,amount:xt(t.token,t.amount*e.amount)}:{...t,amount:t.amount*BigInt(e)}),Ge=(t,e)=>(y(e)&&h(t.token===e.token),y(e)?{...t,amount:T(t.token,t.amount)/e.amount}:{...t,amount:t.amount/BigInt(e)}),We=(t,e)=>(y(e)&&h(t.token===e.token),y(e)?t.amount<e.amount:t.amount<T(t.token,BigInt(e))),De=(t,e)=>(y(e)&&h(t.token===e.token),y(e)?t.amount===e.amount:t.amount===T(t.token,BigInt(e))),Me=(t,e)=>(y(e)&&h(t.token===e.token),y(e)?t.amount>e.amount:t.amount>T(t.token,BigInt(e))),Se=t=>Number(t.amount)/10**(t.token.decimals??0);var s=(t,e,n,r)=>({type:"nativeCurrency",name:t,symbol:e,decimals:n,chainID:r});var m=(t,e,n,r,a,o=0n)=>({type:"weth",address:getAddress(t),name:e,symbol:n,decimals:r,chainID:a,blockCreated:o});var je={native:s("Ether","ETH",18,42161),weth:m("0x82aF49447D8a07e3bd95BD0d56f35241523fBab1","Wrapped Ether","WETH",18,42161,55n)};var He={native:s("Ether","ETH",18,421613),weth:m("0xe39Ab88f8A4777030A534146A9Ca3B52bd5D43A3","Wrapped Ether","WETH",18,421613,16n)};var Qe={native:s("Ether","ETH",18,8453),weth:m("0x4200000000000000000000000000000000000006","Wrapped Ether","WETH",18,8453)};var Ue={native:s("Ether","ETH",18,84531),weth:m("0x4200000000000000000000000000000000000006","Wrapped Ether","WETH",18,84531)};var _e={native:s("Celo Native Asset","CELO",18,42220),weth:m("0x471EcE3750Da237f93B8E339c536989b8978a438","Celo Native Asset","CELO",18,42220,2919n)};var qe={native:s("Celo Native Asset","CELO",18,44787),weth:m("0xF194afDf50B03e69Bd7D057c1Aa9e10c9954E4C9","Celo Native Asset","CELO",18,44787)};var Le={native:s("Ether","ETH",18,31337)};var $e={native:s("Ether","ETH",18,5),weth:m("0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6","Wrapped Ether","WETH",18,5,1036651n)};var Ke={native:s("Ether","ETH",18,1),weth:m("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2","Wrapped Ether","WETH",18,1,4719568n)};var Xe={native:s("Ether","ETH",18,10),weth:m("0x4200000000000000000000000000000000000006","Wrapped Ether","WETH",18,10)};var ze={native:s("Ether","ETH",18,420),weth:m("0x4200000000000000000000000000000000000006","Wrapped Ether","WETH",18,420)};var Je={native:s("Ether","ETH",18,11155111),weth:m("0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14","Wrapped Ether","WETH",18,11155111,3518216n)};var _=(t,e,n,r,a,o=0n)=>({type:"erc20",address:getAddress(t),name:e,symbol:n,decimals:r,chainID:a,blockCreated:o}),q=(t,e,n,r,a,o,d=0n)=>({type:"erc20Permit",address:getAddress(t),name:e,symbol:n,decimals:r,version:a,chainID:o,blockCreated:d}),Ye=(t,e,n)=>({...Q(t,e),type:`${t.type}Data`,nonce:n}),Ze=(t,e,n)=>({...U(t,e),type:`${t.type}Data`,nonce:n}),L=(t,e,n)=>({...l(t,e),type:`${t.type}Data`,nonce:n}),$={Permit:[{name:"owner",type:"address"},{name:"spender",type:"address"},{name:"value",type:"uint256"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]};var g=[{constant:!0,payable:!1,stateMutability:"view",type:"function",inputs:[],name:"name",outputs:[{name:"",type:"string"}]},{constant:!1,payable:!1,stateMutability:"nonpayable",type:"function",inputs:[{name:"guy",type:"address"},{name:"wad",type:"uint256"}],name:"approve",outputs:[{name:"",type:"bool"}]},{constant:!0,payable:!1,stateMutability:"view",type:"function",inputs:[],name:"totalSupply",outputs:[{name:"",type:"uint256"}]},{constant:!1,payable:!1,stateMutability:"nonpayable",type:"function",inputs:[{name:"src",type:"address"},{name:"dst",type:"address"},{name:"wad",type:"uint256"}],name:"transferFrom",outputs:[{name:"",type:"bool"}]},{constant:!1,payable:!1,stateMutability:"nonpayable",type:"function",inputs:[{name:"wad",type:"uint256"}],name:"withdraw",outputs:[]},{constant:!0,payable:!1,stateMutability:"view",type:"function",inputs:[],name:"decimals",outputs:[{name:"",type:"uint8"}]},{constant:!0,payable:!1,stateMutability:"view",type:"function",inputs:[{name:"",type:"address"}],name:"balanceOf",outputs:[{name:"",type:"uint256"}]},{constant:!0,payable:!1,stateMutability:"view",type:"function",inputs:[],name:"symbol",outputs:[{name:"",type:"string"}]},{constant:!1,payable:!1,stateMutability:"nonpayable",type:"function",inputs:[{name:"dst",type:"address"},{name:"wad",type:"uint256"}],name:"transfer",outputs:[{name:"",type:"bool"}]},{constant:!1,payable:!0,stateMutability:"payable",type:"function",inputs:[],name:"deposit",outputs:[]},{constant:!0,payable:!1,stateMutability:"view",type:"function",inputs:[{name:"",type:"address"},{name:"",type:"address"}],name:"allowance",outputs:[{name:"",type:"uint256"}]},{payable:!0,stateMutability:"payable",type:"fallback"},{type:"event",anonymous:!1,inputs:[{name:"src",type:"address",indexed:!0},{name:"guy",type:"address",indexed:!0},{name:"wad",type:"uint256",indexed:!1}],name:"Approval"},{type:"event",anonymous:!1,inputs:[{name:"src",type:"address",indexed:!0},{name:"dst",type:"address",indexed:!0},{name:"wad",type:"uint256",indexed:!1}],name:"Transfer"},{type:"event",anonymous:!1,inputs:[{name:"dst",type:"address",indexed:!0},{name:"wad",type:"uint256",indexed:!1}],name:"Deposit"},{type:"event",anonymous:!1,inputs:[{name:"src",type:"address",indexed:!0},{name:"wad",type:"uint256",indexed:!1}],name:"Withdrawal"}],c=[{type:"event",anonymous:!1,inputs:[{name:"owner",internalType:"address",type:"address",indexed:!0},{name:"operator",internalType:"address",type:"address",indexed:!0},{name:"approved",internalType:"bool",type:"bool",indexed:!1}],name:"ApprovalForAll"},{type:"event",anonymous:!1,inputs:[{name:"operator",internalType:"address",type:"address",indexed:!0},{name:"from",internalType:"address",type:"address",indexed:!0},{name:"to",internalType:"address",type:"address",indexed:!0},{name:"ids",internalType:"uint256[]",type:"uint256[]",indexed:!1},{name:"amounts",internalType:"uint256[]",type:"uint256[]",indexed:!1}],name:"TransferBatch"},{type:"event",anonymous:!1,inputs:[{name:"operator",internalType:"address",type:"address",indexed:!0},{name:"from",internalType:"address",type:"address",indexed:!0},{name:"to",internalType:"address",type:"address",indexed:!0},{name:"id",internalType:"uint256",type:"uint256",indexed:!1},{name:"amount",internalType:"uint256",type:"uint256",indexed:!1}],name:"TransferSingle"},{type:"event",anonymous:!1,inputs:[{name:"value",internalType:"string",type:"string",indexed:!1},{name:"id",internalType:"uint256",type:"uint256",indexed:!0}],name:"URI"},{stateMutability:"view",type:"function",inputs:[{name:"",internalType:"address",type:"address"},{name:"",internalType:"uint256",type:"uint256"}],name:"balanceOf",outputs:[{name:"",internalType:"uint256",type:"uint256"}]},{stateMutability:"view",type:"function",inputs:[{name:"owners",internalType:"address[]",type:"address[]"},{name:"ids",internalType:"uint256[]",type:"uint256[]"}],name:"balanceOfBatch",outputs:[{name:"balances",internalType:"uint256[]",type:"uint256[]"}]},{stateMutability:"view",type:"function",inputs:[{name:"",internalType:"address",type:"address"},{name:"",internalType:"address",type:"address"}],name:"isApprovedForAll",outputs:[{name:"",internalType:"bool",type:"bool"}]},{stateMutability:"nonpayable",type:"function",inputs:[{name:"from",internalType:"address",type:"address"},{name:"to",internalType:"address",type:"address"},{name:"ids",internalType:"uint256[]",type:"uint256[]"},{name:"amounts",internalType:"uint256[]",type:"uint256[]"},{name:"data",internalType:"bytes",type:"bytes"}],name:"safeBatchTransferFrom",outputs:[]},{stateMutability:"nonpayable",type:"function",inputs:[{name:"from",internalType:"address",type:"address"},{name:"to",internalType:"address",type:"address"},{name:"id",internalType:"uint256",type:"uint256"},{name:"amount",internalType:"uint256",type:"uint256"},{name:"data",internalType:"bytes",type:"bytes"}],name:"safeTransferFrom",outputs:[]},{stateMutability:"nonpayable",type:"function",inputs:[{name:"operator",internalType:"address",type:"address"},{name:"approved",internalType:"bool",type:"bool"}],name:"setApprovalForAll",outputs:[]},{stateMutability:"view",type:"function",inputs:[{name:"interfaceId",internalType:"bytes4",type:"bytes4"}],name:"supportsInterface",outputs:[{name:"",internalType:"bool",type:"bool"}]},{stateMutability:"view",type:"function",inputs:[{name:"id",internalType:"uint256",type:"uint256"}],name:"uri",outputs:[{name:"",internalType:"string",type:"string"}]}],i=[{type:"event",anonymous:!1,inputs:[{name:"owner",internalType:"address",type:"address",indexed:!0},{name:"spender",internalType:"address",type:"address",indexed:!0},{name:"amount",internalType:"uint256",type:"uint256",indexed:!1}],name:"Approval"},{type:"event",anonymous:!1,inputs:[{name:"from",internalType:"address",type:"address",indexed:!0},{name:"to",internalType:"address",type:"address",indexed:!0},{name:"amount",internalType:"uint256",type:"uint256",indexed:!1}],name:"Transfer"},{stateMutability:"view",type:"function",inputs:[],name:"DOMAIN_SEPARATOR",outputs:[{name:"",internalType:"bytes32",type:"bytes32"}]},{stateMutability:"view",type:"function",inputs:[{name:"",internalType:"address",type:"address"},{name:"",internalType:"address",type:"address"}],name:"allowance",outputs:[{name:"",internalType:"uint256",type:"uint256"}]},{stateMutability:"nonpayable",type:"function",inputs:[{name:"spender",internalType:"address",type:"address"},{name:"amount",internalType:"uint256",type:"uint256"}],name:"approve",outputs:[{name:"",internalType:"bool",type:"bool"}]},{stateMutability:"view",type:"function",inputs:[{name:"",internalType:"address",type:"address"}],name:"balanceOf",outputs:[{name:"",internalType:"uint256",type:"uint256"}]},{stateMutability:"view",type:"function",inputs:[],name:"decimals",outputs:[{name:"",internalType:"uint8",type:"uint8"}]},{stateMutability:"view",type:"function",inputs:[],name:"name",outputs:[{name:"",internalType:"string",type:"string"}]},{stateMutability:"view",type:"function",inputs:[{name:"",internalType:"address",type:"address"}],name:"nonces",outputs:[{name:"",internalType:"uint256",type:"uint256"}]},{stateMutability:"nonpayable",type:"function",inputs:[{name:"owner",internalType:"address",type:"address"},{name:"spender",internalType:"address",type:"address"},{name:"value",internalType:"uint256",type:"uint256"},{name:"deadline",internalType:"uint256",type:"uint256"},{name:"v",internalType:"uint8",type:"uint8"},{name:"r",internalType:"bytes32",type:"bytes32"},{name:"s",internalType:"bytes32",type:"bytes32"}],name:"permit",outputs:[]},{stateMutability:"view",type:"function",inputs:[],name:"symbol",outputs:[{name:"",internalType:"string",type:"string"}]},{stateMutability:"view",type:"function",inputs:[],name:"totalSupply",outputs:[{name:"",internalType:"uint256",type:"uint256"}]},{stateMutability:"nonpayable",type:"function",inputs:[{name:"to",internalType:"address",type:"address"},{name:"amount",internalType:"uint256",type:"uint256"}],name:"transfer",outputs:[{name:"",internalType:"bool",type:"bool"}]},{stateMutability:"nonpayable",type:"function",inputs:[{name:"from",internalType:"address",type:"address"},{name:"to",internalType:"address",type:"address"},{name:"amount",internalType:"uint256",type:"uint256"}],name:"transferFrom",outputs:[{name:"",internalType:"bool",type:"bool"}]}],p=[{type:"event",anonymous:!1,inputs:[{name:"owner",internalType:"address",type:"address",indexed:!0},{name:"spender",internalType:"address",type:"address",indexed:!0},{name:"id",internalType:"uint256",type:"uint256",indexed:!0}],name:"Approval"},{type:"event",anonymous:!1,inputs:[{name:"owner",internalType:"address",type:"address",indexed:!0},{name:"operator",internalType:"address",type:"address",indexed:!0},{name:"approved",internalType:"bool",type:"bool",indexed:!1}],name:"ApprovalForAll"},{type:"event",anonymous:!1,inputs:[{name:"from",internalType:"address",type:"address",indexed:!0},{name:"to",internalType:"address",type:"address",indexed:!0},{name:"id",internalType:"uint256",type:"uint256",indexed:!0}],name:"Transfer"},{stateMutability:"nonpayable",type:"function",inputs:[{name:"spender",internalType:"address",type:"address"},{name:"id",internalType:"uint256",type:"uint256"}],name:"approve",outputs:[]},{stateMutability:"view",type:"function",inputs:[{name:"owner",internalType:"address",type:"address"}],name:"balanceOf",outputs:[{name:"",internalType:"uint256",type:"uint256"}]},{stateMutability:"view",type:"function",inputs:[{name:"",internalType:"uint256",type:"uint256"}],name:"getApproved",outputs:[{name:"",internalType:"address",type:"address"}]},{stateMutability:"view",type:"function",inputs:[{name:"",internalType:"address",type:"address"},{name:"",internalType:"address",type:"address"}],name:"isApprovedForAll",outputs:[{name:"",internalType:"bool",type:"bool"}]},{stateMutability:"view",type:"function",inputs:[],name:"name",outputs:[{name:"",internalType:"string",type:"string"}]},{stateMutability:"view",type:"function",inputs:[{name:"id",internalType:"uint256",type:"uint256"}],name:"ownerOf",outputs:[{name:"owner",internalType:"address",type:"address"}]},{stateMutability:"nonpayable",type:"function",inputs:[{name:"from",internalType:"address",type:"address"},{name:"to",internalType:"address",type:"address"},{name:"id",internalType:"uint256",type:"uint256"}],name:"safeTransferFrom",outputs:[]},{stateMutability:"nonpayable",type:"function",inputs:[{name:"from",internalType:"address",type:"address"},{name:"to",internalType:"address",type:"address"},{name:"id",internalType:"uint256",type:"uint256"},{name:"data",internalType:"bytes",type:"bytes"}],name:"safeTransferFrom",outputs:[]},{stateMutability:"nonpayable",type:"function",inputs:[{name:"operator",internalType:"address",type:"address"},{name:"approved",internalType:"bool",type:"bool"}],name:"setApprovalForAll",outputs:[]},{stateMutability:"view",type:"function",inputs:[{name:"interfaceId",internalType:"bytes4",type:"bytes4"}],name:"supportsInterface",outputs:[{name:"",internalType:"bool",type:"bool"}]},{stateMutability:"view",type:"function",inputs:[],name:"symbol",outputs:[{name:"",internalType:"string",type:"string"}]},{stateMutability:"view",type:"function",inputs:[{name:"id",internalType:"uint256",type:"uint256"}],name:"tokenURI",outputs:[{name:"",internalType:"string",type:"string"}]},{stateMutability:"nonpayable",type:"function",inputs:[{name:"from",internalType:"address",type:"address"},{name:"to",internalType:"address",type:"address"},{name:"id",internalType:"uint256",type:"uint256"}],name:"transferFrom",outputs:[]}];var A=(t,{erc20:e,...n})=>readContract(t,{abi:i,address:e.address,functionName:"decimals",...n});var x=(t,{erc20:e,...n})=>readContract(t,{abi:i,address:e.address,functionName:"name",...n});var b=(t,{erc20:e,...n})=>readContract(t,{abi:i,address:e.address,functionName:"symbol",...n});var v=(t,{erc20:e,...n})=>Promise.all([x(t,{erc20:e,...n}),b(t,{erc20:e,...n}),A(t,{erc20:e,...n})]).then(([r,a,o])=>_(e.address,r,a,o,e.chainID,e.blockCreated));var K=(t,{erc20:e,owner:n,spender:r,...a})=>readContract(t,{abi:i,address:e.address,functionName:"allowance",args:[n,r],...a}).then(o=>l(e,o));var X=(t,{erc20:e,address:n,...r})=>readContract(t,{abi:i,address:e.address,functionName:"balanceOf",args:[n],...r}).then(a=>l(e,a));var B=(t,{erc20:e,...n})=>readContract(t,{abi:i,address:e.address,functionName:"DOMAIN_SEPARATOR",...n});var I=(t,{erc20:e,...n})=>Promise.all([x(t,{erc20:e,...n}),b(t,{erc20:e,...n}),A(t,{erc20:e,...n})]).then(([r,a,o])=>q(e.address,r,a,o,e.version??"1",e.chainID,e.blockCreated));var z=(t,{erc20:e,address:n,...r})=>Promise.all([readContract(t,{abi:i,address:e.address,functionName:"balanceOf",args:[n],...r}),readContract(t,{abi:i,address:e.address,functionName:"nonces",args:[n],...r})]).then(([a,o])=>L(e,a,o));var J=(t,{erc20:e,address:n,...r})=>readContract(t,{abi:i,address:e.address,functionName:"nonces",args:[n],...r});var V=(t,{erc20:e,...n})=>readContract(t,{abi:i,address:e.address,functionName:"totalSupply",...n}).then(r=>l(e,r));var Y=(t,{erc20:e,...n})=>Promise.all([I(t,{erc20:e,...n}),B(t,{erc20:e,...n})]).then(([r])=>r).catch(()=>v(t,{erc20:e,...n}));var Z=(t,{permitData:e,spender:n,deadline:r,account:a=t.account,...o})=>{let d={name:e.token.name,version:e.token.version,chainId:e.token.chainID,verifyingContract:getAddress(e.token.address)},f=t.account?.address??(typeof a=="object"?a.address:a);return signTypedData(t,{domain:d,types:$,primaryType:"Permit",message:{owner:f,spender:n,value:e.amount,deadline:r,nonce:e.nonce},account:a,...o})};var ee=(t,{args:{amount:e,spender:n},...r})=>writeContract(t,{address:e.token.address,abi:i,functionName:"approve",args:[n,e.amount],...r});var te=(t,{args:{owner:e,spender:n,signature:r,permitData:a,deadline:o},...d})=>{let f=`0x${r.substring(2,66)}`,H=`0x${r.substring(2+64,2+64+64)}`,Et=+`0x${r.substring(2+64+64)}`;return writeContract(t,{address:a.token.address,abi:i,functionName:"permit",args:[e,n,a.amount,o,Et,f,H],...d})};var ne=(t,{args:{amount:e,to:n},...r})=>writeContract(t,{address:e.token.address,abi:i,functionName:"transfer",args:[n,e.amount],...r});var re=(t,{args:{amount:e,from:n,to:r},...a})=>writeContract(t,{address:e.token.address,abi:i,functionName:"transferFrom",args:[n,r,e.amount],...a});var ae=(t,e,n,r,a=0n)=>({type:"erc721",address:getAddress(t),name:e,symbol:n,chainID:r,blockCreated:a}),oe=(t,e,n)=>({type:`${t.type}Data`,token:t,balance:e,ids:n});var w=(t,{erc721:e,...n})=>readContract(t,{abi:p,address:e.address,functionName:"name",...n});var k=(t,{erc721:e,...n})=>readContract(t,{abi:p,address:e.address,functionName:"symbol",...n});var ie=(t,{erc721:e,...n})=>Promise.all([w(t,{erc721:e,...n}),k(t,{erc721:e,...n})]).then(([r,a])=>ae(e.address,r,a,e.chainID,e.blockCreated));var se=(t,{erc721:e,id:n,...r})=>readContract(t,{abi:p,address:e.address,functionName:"getApproved",args:[n],...r});var F=(t,{erc721:e,address:n,...r})=>readContract(t,{abi:p,address:e.address,functionName:"balanceOf",args:[n],...r});var pe=(t,{erc721:e,address:n,...r})=>F(t,{erc721:e,address:n,...r}).then(a=>{if(a>Number.MAX_SAFE_INTEGER)throw Error("balance exceeds maximum representable number");return oe(e,Number(a))});var me=(t,{erc721:e,owner:n,spender:r,...a})=>readContract(t,{abi:p,address:e.address,functionName:"isApprovedForAll",args:[n,r],...a});var de=(t,{erc721:e,id:n,...r})=>readContract(t,{abi:p,address:e.address,functionName:"ownerOf",args:[n],...r});var ue=(t,{erc721:e,interfaceID:n,...r})=>readContract(t,{abi:p,address:e.address,functionName:"supportsInterface",args:[n],...r});var ye=(t,{erc721:e,id:n,...r})=>readContract(t,{abi:p,address:e.address,functionName:"tokenURI",args:[n],...r});var ce=(t,{args:{erc721:e,from:n,to:r,data:a,id:o},...d})=>a===void 0?writeContract(t,{address:e.address,abi:p,functionName:"transferFrom",args:[n??t.account?.address??(typeof d.account=="object"?d.account.address:d.account),r,o],...d}):a==="safe"?writeContract(t,{address:e.address,abi:p,functionName:"safeTransferFrom",args:[n??t.account?.address??(typeof d.account=="object"?d.account.address:d.account),r,o],...d}):writeContract(t,{address:e.address,abi:p,functionName:"safeTransferFrom",args:[n??t.account?.address??(typeof d.account=="object"?d.account.address:d.account),r,o,a],...d});var Ce=(t,{args:{erc721:e,spender:n,id:r},...a})=>writeContract(t,{address:e.address,abi:p,functionName:"approve",args:[n,r],...a});var le=(t,{args:{erc721:e,spender:n,approved:r},...a})=>writeContract(t,{address:e.address,abi:p,functionName:"setApprovalForAll",args:[n,r],...a});var Te=(t,e,n,r,a=0n)=>({type:"erc1155",address:getAddress(t),id:e,uri:n,chainID:r,blockCreated:a}),fe=(t,e)=>({type:`${t.type}Data`,token:t,amount:e});var Re=(t,{erc1155:e,...n})=>readContract(t,{abi:c,address:e.address,functionName:"uri",args:[e.id],...n}).then(r=>Te(e.address,e.id,r,e.chainID,e.blockCreated));var Ee=(t,{erc1155:e,address:n,...r})=>readContract(t,{abi:c,address:e.address,functionName:"balanceOf",args:[n,e.id],...r}).then(a=>fe(e,a));var Ae=(t,{erc1155:e,owner:n,spender:r,...a})=>readContract(t,{abi:c,address:e.address,functionName:"isApprovedForAll",args:[n,r],...a});var xe=(t,{erc1155:e,...n})=>readContract(t,{abi:c,address:e.address,functionName:"uri",args:[e.id],...n});var be=(t,{args:{erc1155Data:e,to:n,from:r,data:a},...o})=>writeContract(t,{address:e.token.address,abi:c,functionName:"safeTransferFrom",args:[r??t.account?.address??(typeof o.account=="object"?o.account.address:o.account),n,e.token.id,e.amount,a??"0x"],...o});var he=(t,{args:{erc1155Data:e,to:n,from:r,data:a},...o})=>{let d=e.reduce((f,H)=>{if(f===void 0)return getAddress(H.token.address);if(f!==getAddress(H.token.address))throw Error("Tokens refering to different addresses");return f},void 0);if(d===void 0)throw Error("No tokens passed to transfer");return writeContract(t,{address:d,abi:c,functionName:"safeBatchTransferFrom",args:[r??t.account?.address??(typeof o.account=="object"?o.account.address:o.account),n,e.map(f=>f.token.id),e.map(f=>f.amount),a??"0x"],...o})};var Pe=(t,{args:{erc1155:e,spender:n,approved:r},...a})=>writeContract(t,{address:e.address,abi:c,functionName:"setApprovalForAll",args:[n,r],...a});var E=t=>typeof t=="object",rt=(t,e=1)=>{let n=BigInt(e);return h(n!==0n,"Fraction: denominator equal to 0"),{type:"fraction",numerator:BigInt(t),denominator:n}},at=t=>t.numerator/t.denominator,ot=t=>t.numerator%t.denominator,ge=t=>(h(t.numerator!==0n,"Fraction: denominator equal to 0"),{type:"fraction",numerator:t.denominator,denominator:t.numerator}),W=(t,e)=>E(e)?{type:"fraction",numerator:t.numerator*e.denominator+e.numerator*t.denominator,denominator:t.denominator*e.denominator}:{type:"fraction",numerator:t.numerator+t.denominator*BigInt(e),denominator:t.denominator},D=(t,e)=>E(e)?{type:"fraction",numerator:t.numerator*e.denominator-e.numerator*t.denominator,denominator:t.denominator*e.denominator}:{type:"fraction",numerator:t.numerator-t.denominator*BigInt(e),denominator:t.denominator},O=(t,e)=>E(e)?{type:"fraction",numerator:t.numerator*e.numerator,denominator:t.denominator*e.denominator}:{type:"fraction",numerator:t.numerator*BigInt(e),denominator:t.denominator},N=(t,e)=>E(e)?{type:"fraction",numerator:t.numerator*e.denominator,denominator:t.denominator*e.numerator}:{type:"fraction",numerator:t.numerator,denominator:t.denominator*BigInt(e)},M=(t,e)=>E(e)?t.numerator*e.denominator<t.denominator*e.numerator:t.numerator<t.denominator*BigInt(e),S=(t,e)=>E(e)?t.numerator*e.denominator>t.denominator*e.numerator:t.numerator>t.denominator*BigInt(e),j=(t,e)=>E(e)?t.numerator*e.denominator===t.denominator*e.numerator:t.numerator===t.denominator*BigInt(e),ve=t=>Number(t.numerator)/Number(t.denominator);var Be=(t,{address:e,nativeCurrency:n,...r})=>getBalance(t,{address:e,...r}).then(a=>l(n,a));var C=t=>typeof t=="object",G=(t,e,n)=>({type:"price",quote:t,base:e,numerator:t.decimals?n.numerator*10n**BigInt(t.decimals):n.numerator,denominator:e.decimals?n.denominator*10n**BigInt(e.decimals):n.denominator}),it=(t,e)=>({type:"price",quote:t.token,base:e.token,numerator:e.amount,denominator:t.amount}),st=(t,e,n,r=1)=>({type:"price",quote:t,base:e,numerator:t.decimals?BigInt(n)*10n**BigInt(t.decimals):BigInt(n),denominator:e.decimals?BigInt(r)*10n**BigInt(e.decimals):BigInt(r)}),pt=t=>({...ge(u(t)),type:"price",quote:t.base,base:t.quote}),mt=(t,e)=>(C(e)&&h(t.base===e.base&&t.quote===e.quote),C(e)?{...W(u(t),u(e)),type:"price",quote:t.quote,base:t.base}:G(t.quote,t.base,W(R(t),e))),dt=(t,e)=>(C(e)&&h(t.base===e.base&&t.quote===e.quote),C(e)?{...D(u(t),u(e)),type:"price",quote:t.quote,base:t.base}:G(t.quote,t.base,D(R(t),e))),ut=(t,e)=>(C(e)&&h(t.base===e.base&&t.quote===e.quote),C(e)?{type:"price",quote:t.quote,base:t.base,numerator:T(t.base,O(u(t),u(e)).numerator),denominator:T(t.quote,O(u(t),u(e)).denominator)}:G(t.quote,t.base,O(R(t),e))),yt=(t,e)=>(C(e)&&h(t.base===e.base&&t.quote===e.quote),C(e)?{type:"price",quote:t.quote,base:t.base,numerator:T(t.quote,N(u(t),u(e)).numerator),denominator:T(t.base,N(u(t),u(e)).denominator)}:G(t.quote,t.base,N(R(t),e))),ct=(t,e)=>(C(e)&&h(t.base===e.base&&t.quote===e.quote),C(e)?M(u(t),u(e)):M(R(t),e)),Ct=(t,e)=>(C(e)&&h(t.base===e.base&&t.quote===e.quote),C(e)?j(u(t),u(e)):j(R(t),e)),lt=(t,e)=>(C(e)&&h(t.base===e.base&&t.quote===e.quote),C(e)?S(u(t),u(e)):S(R(t),e)),Tt=(t,e)=>(h(t.base===e.token),l(t.quote,t.numerator*e.amount/t.denominator)),u=t=>({type:"fraction",numerator:t.numerator,denominator:t.denominator}),R=t=>({type:"fraction",numerator:t.base.decimals?t.numerator*10n**BigInt(t.base.decimals):t.numerator,denominator:t.quote.decimals?t.denominator*10n**BigInt(t.quote.decimals):t.denominator}),ft=t=>ve(R(t));var Rt=(t,e,n)=>[{chainID:n,read:{name:t.name,args:e}}];var Ie=(t,{args:{amount:e},...n})=>writeContract(t,{address:e.token.address,abi:g,functionName:"deposit",value:e.amount,...n});var we=(t,{args:{amount:e},...n})=>writeContract(t,{address:e.token.address,abi:g,functionName:"withdraw",args:[e.amount],...n});var on=t=>({getNativeBalance:e=>Be(t,e),getERC20:e=>v(t,e),getERC20Allowance:e=>K(t,e),getERC20BalanceOf:e=>X(t,e),getERC20TotalSupply:e=>V(t,e),getERC20Name:e=>x(t,e),getERC20Symbol:e=>b(t,e),getERC20Decimals:e=>A(t,e),getERC20DomainSeparator:e=>B(t,e),getERC20Permit:e=>I(t,e),getERC20PermitNonce:e=>J(t,e),getERC20PermitData:e=>z(t,e),getIsERC20Permit:e=>Y(t,e),getERC721:e=>ie(t,e),getERC721Approved:e=>se(t,e),getERC721BalanceOf:e=>F(t,e),getERC721OwnerOf:e=>de(t,e),getERC721Data:e=>pe(t,e),getERC721Name:e=>w(t,e),getERC721Symbol:e=>k(t,e),getERC721TokenURI:e=>ye(t,e),getERC721IsApprovedForAll:e=>me(t,e),getERC721SupportsInterface:e=>ue(t,e),getERC1155:e=>Re(t,e),getERC1155BalanceOf:e=>Ee(t,e),getERC1155IsApprovedForAll:e=>Ae(t,e),getERC1155URI:e=>xe(t,e)});var sn=t=>({signERC20Permit:e=>Z(t,e),writeWETHDeposit:e=>Ie(t,e),writeWETHWithdraw:e=>we(t,e),writeERC20Approve:e=>ee(t,e),writeERC20Permit:e=>te(t,e),writeERC20Transfer:e=>ne(t,e),writeERC20TransferFrom:e=>re(t,e),writeERC721Approve:e=>Ce(t,e),writeERC721SetApprovalForAll:e=>le(t,e),writeERC721Transfer:e=>ce(t,e),writeERC1155SetApprovalForAll:e=>Pe(t,e),writeERC1155Transfer:e=>be(t,e),writeERC1155TransferBatch:e=>he(t,e)}); | ||
// src/weth/utils.ts | ||
import { getAddress } from "viem"; | ||
var createWETH = (address, name, symbol, decimals, chainID, blockCreated = 0n) => ({ | ||
type: "weth", | ||
address: getAddress(address), | ||
name, | ||
symbol, | ||
decimals, | ||
chainID, | ||
blockCreated | ||
}); | ||
// src/chains/arbitrum.ts | ||
var arbitrumTokens = { | ||
native: createNativeCurrency("Ether", "ETH", 18, 42161), | ||
weth: createWETH( | ||
"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1", | ||
"Wrapped Ether", | ||
"WETH", | ||
18, | ||
42161, | ||
55n | ||
) | ||
}; | ||
// src/chains/arbitrumGoerli.ts | ||
var arbitrumGoerliTokens = { | ||
native: createNativeCurrency("Ether", "ETH", 18, 421613), | ||
weth: createWETH( | ||
"0xe39Ab88f8A4777030A534146A9Ca3B52bd5D43A3", | ||
"Wrapped Ether", | ||
"WETH", | ||
18, | ||
421613, | ||
16n | ||
) | ||
}; | ||
// src/chains/base.ts | ||
var baseTokens = { | ||
native: createNativeCurrency("Ether", "ETH", 18, 8453), | ||
weth: createWETH( | ||
"0x4200000000000000000000000000000000000006", | ||
"Wrapped Ether", | ||
"WETH", | ||
18, | ||
8453 | ||
) | ||
}; | ||
// src/chains/baseGoerli.ts | ||
var baseGoerliTokens = { | ||
native: createNativeCurrency("Ether", "ETH", 18, 84531), | ||
weth: createWETH( | ||
"0x4200000000000000000000000000000000000006", | ||
"Wrapped Ether", | ||
"WETH", | ||
18, | ||
84531 | ||
) | ||
}; | ||
// src/chains/celo.ts | ||
var celoTokens = { | ||
native: createNativeCurrency("Celo Native Asset", "CELO", 18, 42220), | ||
weth: createWETH( | ||
"0x471EcE3750Da237f93B8E339c536989b8978a438", | ||
"Celo Native Asset", | ||
"CELO", | ||
18, | ||
42220, | ||
2919n | ||
) | ||
}; | ||
// src/chains/celoAlfajores.ts | ||
var celoAlfajoresTokens = { | ||
native: createNativeCurrency("Celo Native Asset", "CELO", 18, 44787), | ||
weth: createWETH( | ||
"0xF194afDf50B03e69Bd7D057c1Aa9e10c9954E4C9", | ||
"Celo Native Asset", | ||
"CELO", | ||
18, | ||
44787 | ||
) | ||
}; | ||
// src/chains/foundry.ts | ||
var foundryTokens = { | ||
native: createNativeCurrency("Ether", "ETH", 18, 31337) | ||
}; | ||
// src/chains/goerli.ts | ||
var goerliTokens = { | ||
native: createNativeCurrency("Ether", "ETH", 18, 5), | ||
weth: createWETH( | ||
"0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6", | ||
"Wrapped Ether", | ||
"WETH", | ||
18, | ||
5, | ||
1036651n | ||
) | ||
}; | ||
// src/chains/mainnet.ts | ||
var mainnetTokens = { | ||
native: createNativeCurrency("Ether", "ETH", 18, 1), | ||
weth: createWETH( | ||
"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", | ||
"Wrapped Ether", | ||
"WETH", | ||
18, | ||
1, | ||
4719568n | ||
) | ||
}; | ||
// src/chains/optimism.ts | ||
var optimismTokens = { | ||
native: createNativeCurrency("Ether", "ETH", 18, 10), | ||
weth: createWETH( | ||
"0x4200000000000000000000000000000000000006", | ||
"Wrapped Ether", | ||
"WETH", | ||
18, | ||
10 | ||
) | ||
}; | ||
// src/chains/optimismGoerli.ts | ||
var optimismGoerliTokens = { | ||
native: createNativeCurrency("Ether", "ETH", 18, 420), | ||
weth: createWETH( | ||
"0x4200000000000000000000000000000000000006", | ||
"Wrapped Ether", | ||
"WETH", | ||
18, | ||
420 | ||
) | ||
}; | ||
// src/chains/sepolia.ts | ||
var sepoliaTokens = { | ||
native: createNativeCurrency("Ether", "ETH", 18, 11155111), | ||
weth: createWETH( | ||
"0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14", | ||
"Wrapped Ether", | ||
"WETH", | ||
18, | ||
11155111, | ||
3518216n | ||
) | ||
}; | ||
// src/erc20/utils.ts | ||
import { getAddress as getAddress2 } from "viem"; | ||
var createERC20 = (address, name, symbol, decimals, chainID, blockCreated = 0n) => ({ | ||
type: "erc20", | ||
address: getAddress2(address), | ||
name, | ||
symbol, | ||
decimals, | ||
chainID, | ||
blockCreated | ||
}); | ||
var createERC20Permit = (address, name, symbol, decimals, version, chainID, blockCreated = 0n) => ({ | ||
type: "erc20Permit", | ||
address: getAddress2(address), | ||
name, | ||
symbol, | ||
decimals, | ||
version, | ||
chainID, | ||
blockCreated | ||
}); | ||
var createERC20PermitDataFromString = (erc20Permit, amount, nonce) => ({ | ||
...createAmountFromString(erc20Permit, amount), | ||
type: `${erc20Permit.type}Data`, | ||
nonce | ||
}); | ||
var createERC20PermitDataFromFraction = (erc20Permit, amount, nonce) => ({ | ||
...createAmountFromFraction(erc20Permit, amount), | ||
type: `${erc20Permit.type}Data`, | ||
nonce | ||
}); | ||
var createERC20PermitDataFromRaw = (erc20Permit, amount, nonce) => ({ | ||
...createAmountFromRaw(erc20Permit, amount), | ||
type: `${erc20Permit.type}Data`, | ||
nonce | ||
}); | ||
var PermitType = { | ||
Permit: [ | ||
{ | ||
name: "owner", | ||
type: "address" | ||
}, | ||
{ name: "spender", type: "address" }, | ||
{ name: "value", type: "uint256" }, | ||
{ name: "nonce", type: "uint256" }, | ||
{ name: "deadline", type: "uint256" } | ||
] | ||
}; | ||
// src/generated.ts | ||
var weth9ABI = [ | ||
{ | ||
constant: true, | ||
payable: false, | ||
stateMutability: "view", | ||
type: "function", | ||
inputs: [], | ||
name: "name", | ||
outputs: [{ name: "", type: "string" }] | ||
}, | ||
{ | ||
constant: false, | ||
payable: false, | ||
stateMutability: "nonpayable", | ||
type: "function", | ||
inputs: [ | ||
{ name: "guy", type: "address" }, | ||
{ name: "wad", type: "uint256" } | ||
], | ||
name: "approve", | ||
outputs: [{ name: "", type: "bool" }] | ||
}, | ||
{ | ||
constant: true, | ||
payable: false, | ||
stateMutability: "view", | ||
type: "function", | ||
inputs: [], | ||
name: "totalSupply", | ||
outputs: [{ name: "", type: "uint256" }] | ||
}, | ||
{ | ||
constant: false, | ||
payable: false, | ||
stateMutability: "nonpayable", | ||
type: "function", | ||
inputs: [ | ||
{ name: "src", type: "address" }, | ||
{ name: "dst", type: "address" }, | ||
{ name: "wad", type: "uint256" } | ||
], | ||
name: "transferFrom", | ||
outputs: [{ name: "", type: "bool" }] | ||
}, | ||
{ | ||
constant: false, | ||
payable: false, | ||
stateMutability: "nonpayable", | ||
type: "function", | ||
inputs: [{ name: "wad", type: "uint256" }], | ||
name: "withdraw", | ||
outputs: [] | ||
}, | ||
{ | ||
constant: true, | ||
payable: false, | ||
stateMutability: "view", | ||
type: "function", | ||
inputs: [], | ||
name: "decimals", | ||
outputs: [{ name: "", type: "uint8" }] | ||
}, | ||
{ | ||
constant: true, | ||
payable: false, | ||
stateMutability: "view", | ||
type: "function", | ||
inputs: [{ name: "", type: "address" }], | ||
name: "balanceOf", | ||
outputs: [{ name: "", type: "uint256" }] | ||
}, | ||
{ | ||
constant: true, | ||
payable: false, | ||
stateMutability: "view", | ||
type: "function", | ||
inputs: [], | ||
name: "symbol", | ||
outputs: [{ name: "", type: "string" }] | ||
}, | ||
{ | ||
constant: false, | ||
payable: false, | ||
stateMutability: "nonpayable", | ||
type: "function", | ||
inputs: [ | ||
{ name: "dst", type: "address" }, | ||
{ name: "wad", type: "uint256" } | ||
], | ||
name: "transfer", | ||
outputs: [{ name: "", type: "bool" }] | ||
}, | ||
{ | ||
constant: false, | ||
payable: true, | ||
stateMutability: "payable", | ||
type: "function", | ||
inputs: [], | ||
name: "deposit", | ||
outputs: [] | ||
}, | ||
{ | ||
constant: true, | ||
payable: false, | ||
stateMutability: "view", | ||
type: "function", | ||
inputs: [ | ||
{ name: "", type: "address" }, | ||
{ name: "", type: "address" } | ||
], | ||
name: "allowance", | ||
outputs: [{ name: "", type: "uint256" }] | ||
}, | ||
{ payable: true, stateMutability: "payable", type: "fallback" }, | ||
{ | ||
type: "event", | ||
anonymous: false, | ||
inputs: [ | ||
{ name: "src", type: "address", indexed: true }, | ||
{ name: "guy", type: "address", indexed: true }, | ||
{ name: "wad", type: "uint256", indexed: false } | ||
], | ||
name: "Approval" | ||
}, | ||
{ | ||
type: "event", | ||
anonymous: false, | ||
inputs: [ | ||
{ name: "src", type: "address", indexed: true }, | ||
{ name: "dst", type: "address", indexed: true }, | ||
{ name: "wad", type: "uint256", indexed: false } | ||
], | ||
name: "Transfer" | ||
}, | ||
{ | ||
type: "event", | ||
anonymous: false, | ||
inputs: [ | ||
{ name: "dst", type: "address", indexed: true }, | ||
{ name: "wad", type: "uint256", indexed: false } | ||
], | ||
name: "Deposit" | ||
}, | ||
{ | ||
type: "event", | ||
anonymous: false, | ||
inputs: [ | ||
{ name: "src", type: "address", indexed: true }, | ||
{ name: "wad", type: "uint256", indexed: false } | ||
], | ||
name: "Withdrawal" | ||
} | ||
]; | ||
var solmateErc1155ABI = [ | ||
{ | ||
type: "event", | ||
anonymous: false, | ||
inputs: [ | ||
{ | ||
name: "owner", | ||
internalType: "address", | ||
type: "address", | ||
indexed: true | ||
}, | ||
{ | ||
name: "operator", | ||
internalType: "address", | ||
type: "address", | ||
indexed: true | ||
}, | ||
{ name: "approved", internalType: "bool", type: "bool", indexed: false } | ||
], | ||
name: "ApprovalForAll" | ||
}, | ||
{ | ||
type: "event", | ||
anonymous: false, | ||
inputs: [ | ||
{ | ||
name: "operator", | ||
internalType: "address", | ||
type: "address", | ||
indexed: true | ||
}, | ||
{ name: "from", internalType: "address", type: "address", indexed: true }, | ||
{ name: "to", internalType: "address", type: "address", indexed: true }, | ||
{ | ||
name: "ids", | ||
internalType: "uint256[]", | ||
type: "uint256[]", | ||
indexed: false | ||
}, | ||
{ | ||
name: "amounts", | ||
internalType: "uint256[]", | ||
type: "uint256[]", | ||
indexed: false | ||
} | ||
], | ||
name: "TransferBatch" | ||
}, | ||
{ | ||
type: "event", | ||
anonymous: false, | ||
inputs: [ | ||
{ | ||
name: "operator", | ||
internalType: "address", | ||
type: "address", | ||
indexed: true | ||
}, | ||
{ name: "from", internalType: "address", type: "address", indexed: true }, | ||
{ name: "to", internalType: "address", type: "address", indexed: true }, | ||
{ name: "id", internalType: "uint256", type: "uint256", indexed: false }, | ||
{ | ||
name: "amount", | ||
internalType: "uint256", | ||
type: "uint256", | ||
indexed: false | ||
} | ||
], | ||
name: "TransferSingle" | ||
}, | ||
{ | ||
type: "event", | ||
anonymous: false, | ||
inputs: [ | ||
{ name: "value", internalType: "string", type: "string", indexed: false }, | ||
{ name: "id", internalType: "uint256", type: "uint256", indexed: true } | ||
], | ||
name: "URI" | ||
}, | ||
{ | ||
stateMutability: "view", | ||
type: "function", | ||
inputs: [ | ||
{ name: "", internalType: "address", type: "address" }, | ||
{ name: "", internalType: "uint256", type: "uint256" } | ||
], | ||
name: "balanceOf", | ||
outputs: [{ name: "", internalType: "uint256", type: "uint256" }] | ||
}, | ||
{ | ||
stateMutability: "view", | ||
type: "function", | ||
inputs: [ | ||
{ name: "owners", internalType: "address[]", type: "address[]" }, | ||
{ name: "ids", internalType: "uint256[]", type: "uint256[]" } | ||
], | ||
name: "balanceOfBatch", | ||
outputs: [ | ||
{ name: "balances", internalType: "uint256[]", type: "uint256[]" } | ||
] | ||
}, | ||
{ | ||
stateMutability: "view", | ||
type: "function", | ||
inputs: [ | ||
{ name: "", internalType: "address", type: "address" }, | ||
{ name: "", internalType: "address", type: "address" } | ||
], | ||
name: "isApprovedForAll", | ||
outputs: [{ name: "", internalType: "bool", type: "bool" }] | ||
}, | ||
{ | ||
stateMutability: "nonpayable", | ||
type: "function", | ||
inputs: [ | ||
{ name: "from", internalType: "address", type: "address" }, | ||
{ name: "to", internalType: "address", type: "address" }, | ||
{ name: "ids", internalType: "uint256[]", type: "uint256[]" }, | ||
{ name: "amounts", internalType: "uint256[]", type: "uint256[]" }, | ||
{ name: "data", internalType: "bytes", type: "bytes" } | ||
], | ||
name: "safeBatchTransferFrom", | ||
outputs: [] | ||
}, | ||
{ | ||
stateMutability: "nonpayable", | ||
type: "function", | ||
inputs: [ | ||
{ name: "from", internalType: "address", type: "address" }, | ||
{ name: "to", internalType: "address", type: "address" }, | ||
{ name: "id", internalType: "uint256", type: "uint256" }, | ||
{ name: "amount", internalType: "uint256", type: "uint256" }, | ||
{ name: "data", internalType: "bytes", type: "bytes" } | ||
], | ||
name: "safeTransferFrom", | ||
outputs: [] | ||
}, | ||
{ | ||
stateMutability: "nonpayable", | ||
type: "function", | ||
inputs: [ | ||
{ name: "operator", internalType: "address", type: "address" }, | ||
{ name: "approved", internalType: "bool", type: "bool" } | ||
], | ||
name: "setApprovalForAll", | ||
outputs: [] | ||
}, | ||
{ | ||
stateMutability: "view", | ||
type: "function", | ||
inputs: [{ name: "interfaceId", internalType: "bytes4", type: "bytes4" }], | ||
name: "supportsInterface", | ||
outputs: [{ name: "", internalType: "bool", type: "bool" }] | ||
}, | ||
{ | ||
stateMutability: "view", | ||
type: "function", | ||
inputs: [{ name: "id", internalType: "uint256", type: "uint256" }], | ||
name: "uri", | ||
outputs: [{ name: "", internalType: "string", type: "string" }] | ||
} | ||
]; | ||
var solmateErc20ABI = [ | ||
{ | ||
type: "event", | ||
anonymous: false, | ||
inputs: [ | ||
{ | ||
name: "owner", | ||
internalType: "address", | ||
type: "address", | ||
indexed: true | ||
}, | ||
{ | ||
name: "spender", | ||
internalType: "address", | ||
type: "address", | ||
indexed: true | ||
}, | ||
{ | ||
name: "amount", | ||
internalType: "uint256", | ||
type: "uint256", | ||
indexed: false | ||
} | ||
], | ||
name: "Approval" | ||
}, | ||
{ | ||
type: "event", | ||
anonymous: false, | ||
inputs: [ | ||
{ name: "from", internalType: "address", type: "address", indexed: true }, | ||
{ name: "to", internalType: "address", type: "address", indexed: true }, | ||
{ | ||
name: "amount", | ||
internalType: "uint256", | ||
type: "uint256", | ||
indexed: false | ||
} | ||
], | ||
name: "Transfer" | ||
}, | ||
{ | ||
stateMutability: "view", | ||
type: "function", | ||
inputs: [], | ||
name: "DOMAIN_SEPARATOR", | ||
outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }] | ||
}, | ||
{ | ||
stateMutability: "view", | ||
type: "function", | ||
inputs: [ | ||
{ name: "", internalType: "address", type: "address" }, | ||
{ name: "", internalType: "address", type: "address" } | ||
], | ||
name: "allowance", | ||
outputs: [{ name: "", internalType: "uint256", type: "uint256" }] | ||
}, | ||
{ | ||
stateMutability: "nonpayable", | ||
type: "function", | ||
inputs: [ | ||
{ name: "spender", internalType: "address", type: "address" }, | ||
{ name: "amount", internalType: "uint256", type: "uint256" } | ||
], | ||
name: "approve", | ||
outputs: [{ name: "", internalType: "bool", type: "bool" }] | ||
}, | ||
{ | ||
stateMutability: "view", | ||
type: "function", | ||
inputs: [{ name: "", internalType: "address", type: "address" }], | ||
name: "balanceOf", | ||
outputs: [{ name: "", internalType: "uint256", type: "uint256" }] | ||
}, | ||
{ | ||
stateMutability: "view", | ||
type: "function", | ||
inputs: [], | ||
name: "decimals", | ||
outputs: [{ name: "", internalType: "uint8", type: "uint8" }] | ||
}, | ||
{ | ||
stateMutability: "view", | ||
type: "function", | ||
inputs: [], | ||
name: "name", | ||
outputs: [{ name: "", internalType: "string", type: "string" }] | ||
}, | ||
{ | ||
stateMutability: "view", | ||
type: "function", | ||
inputs: [{ name: "", internalType: "address", type: "address" }], | ||
name: "nonces", | ||
outputs: [{ name: "", internalType: "uint256", type: "uint256" }] | ||
}, | ||
{ | ||
stateMutability: "nonpayable", | ||
type: "function", | ||
inputs: [ | ||
{ name: "owner", internalType: "address", type: "address" }, | ||
{ name: "spender", internalType: "address", type: "address" }, | ||
{ name: "value", internalType: "uint256", type: "uint256" }, | ||
{ name: "deadline", internalType: "uint256", type: "uint256" }, | ||
{ name: "v", internalType: "uint8", type: "uint8" }, | ||
{ name: "r", internalType: "bytes32", type: "bytes32" }, | ||
{ name: "s", internalType: "bytes32", type: "bytes32" } | ||
], | ||
name: "permit", | ||
outputs: [] | ||
}, | ||
{ | ||
stateMutability: "view", | ||
type: "function", | ||
inputs: [], | ||
name: "symbol", | ||
outputs: [{ name: "", internalType: "string", type: "string" }] | ||
}, | ||
{ | ||
stateMutability: "view", | ||
type: "function", | ||
inputs: [], | ||
name: "totalSupply", | ||
outputs: [{ name: "", internalType: "uint256", type: "uint256" }] | ||
}, | ||
{ | ||
stateMutability: "nonpayable", | ||
type: "function", | ||
inputs: [ | ||
{ name: "to", internalType: "address", type: "address" }, | ||
{ name: "amount", internalType: "uint256", type: "uint256" } | ||
], | ||
name: "transfer", | ||
outputs: [{ name: "", internalType: "bool", type: "bool" }] | ||
}, | ||
{ | ||
stateMutability: "nonpayable", | ||
type: "function", | ||
inputs: [ | ||
{ name: "from", internalType: "address", type: "address" }, | ||
{ name: "to", internalType: "address", type: "address" }, | ||
{ name: "amount", internalType: "uint256", type: "uint256" } | ||
], | ||
name: "transferFrom", | ||
outputs: [{ name: "", internalType: "bool", type: "bool" }] | ||
} | ||
]; | ||
var solmateErc721ABI = [ | ||
{ | ||
type: "event", | ||
anonymous: false, | ||
inputs: [ | ||
{ | ||
name: "owner", | ||
internalType: "address", | ||
type: "address", | ||
indexed: true | ||
}, | ||
{ | ||
name: "spender", | ||
internalType: "address", | ||
type: "address", | ||
indexed: true | ||
}, | ||
{ name: "id", internalType: "uint256", type: "uint256", indexed: true } | ||
], | ||
name: "Approval" | ||
}, | ||
{ | ||
type: "event", | ||
anonymous: false, | ||
inputs: [ | ||
{ | ||
name: "owner", | ||
internalType: "address", | ||
type: "address", | ||
indexed: true | ||
}, | ||
{ | ||
name: "operator", | ||
internalType: "address", | ||
type: "address", | ||
indexed: true | ||
}, | ||
{ name: "approved", internalType: "bool", type: "bool", indexed: false } | ||
], | ||
name: "ApprovalForAll" | ||
}, | ||
{ | ||
type: "event", | ||
anonymous: false, | ||
inputs: [ | ||
{ name: "from", internalType: "address", type: "address", indexed: true }, | ||
{ name: "to", internalType: "address", type: "address", indexed: true }, | ||
{ name: "id", internalType: "uint256", type: "uint256", indexed: true } | ||
], | ||
name: "Transfer" | ||
}, | ||
{ | ||
stateMutability: "nonpayable", | ||
type: "function", | ||
inputs: [ | ||
{ name: "spender", internalType: "address", type: "address" }, | ||
{ name: "id", internalType: "uint256", type: "uint256" } | ||
], | ||
name: "approve", | ||
outputs: [] | ||
}, | ||
{ | ||
stateMutability: "view", | ||
type: "function", | ||
inputs: [{ name: "owner", internalType: "address", type: "address" }], | ||
name: "balanceOf", | ||
outputs: [{ name: "", internalType: "uint256", type: "uint256" }] | ||
}, | ||
{ | ||
stateMutability: "view", | ||
type: "function", | ||
inputs: [{ name: "", internalType: "uint256", type: "uint256" }], | ||
name: "getApproved", | ||
outputs: [{ name: "", internalType: "address", type: "address" }] | ||
}, | ||
{ | ||
stateMutability: "view", | ||
type: "function", | ||
inputs: [ | ||
{ name: "", internalType: "address", type: "address" }, | ||
{ name: "", internalType: "address", type: "address" } | ||
], | ||
name: "isApprovedForAll", | ||
outputs: [{ name: "", internalType: "bool", type: "bool" }] | ||
}, | ||
{ | ||
stateMutability: "view", | ||
type: "function", | ||
inputs: [], | ||
name: "name", | ||
outputs: [{ name: "", internalType: "string", type: "string" }] | ||
}, | ||
{ | ||
stateMutability: "view", | ||
type: "function", | ||
inputs: [{ name: "id", internalType: "uint256", type: "uint256" }], | ||
name: "ownerOf", | ||
outputs: [{ name: "owner", internalType: "address", type: "address" }] | ||
}, | ||
{ | ||
stateMutability: "nonpayable", | ||
type: "function", | ||
inputs: [ | ||
{ name: "from", internalType: "address", type: "address" }, | ||
{ name: "to", internalType: "address", type: "address" }, | ||
{ name: "id", internalType: "uint256", type: "uint256" } | ||
], | ||
name: "safeTransferFrom", | ||
outputs: [] | ||
}, | ||
{ | ||
stateMutability: "nonpayable", | ||
type: "function", | ||
inputs: [ | ||
{ name: "from", internalType: "address", type: "address" }, | ||
{ name: "to", internalType: "address", type: "address" }, | ||
{ name: "id", internalType: "uint256", type: "uint256" }, | ||
{ name: "data", internalType: "bytes", type: "bytes" } | ||
], | ||
name: "safeTransferFrom", | ||
outputs: [] | ||
}, | ||
{ | ||
stateMutability: "nonpayable", | ||
type: "function", | ||
inputs: [ | ||
{ name: "operator", internalType: "address", type: "address" }, | ||
{ name: "approved", internalType: "bool", type: "bool" } | ||
], | ||
name: "setApprovalForAll", | ||
outputs: [] | ||
}, | ||
{ | ||
stateMutability: "view", | ||
type: "function", | ||
inputs: [{ name: "interfaceId", internalType: "bytes4", type: "bytes4" }], | ||
name: "supportsInterface", | ||
outputs: [{ name: "", internalType: "bool", type: "bool" }] | ||
}, | ||
{ | ||
stateMutability: "view", | ||
type: "function", | ||
inputs: [], | ||
name: "symbol", | ||
outputs: [{ name: "", internalType: "string", type: "string" }] | ||
}, | ||
{ | ||
stateMutability: "view", | ||
type: "function", | ||
inputs: [{ name: "id", internalType: "uint256", type: "uint256" }], | ||
name: "tokenURI", | ||
outputs: [{ name: "", internalType: "string", type: "string" }] | ||
}, | ||
{ | ||
stateMutability: "nonpayable", | ||
type: "function", | ||
inputs: [ | ||
{ name: "from", internalType: "address", type: "address" }, | ||
{ name: "to", internalType: "address", type: "address" }, | ||
{ name: "id", internalType: "uint256", type: "uint256" } | ||
], | ||
name: "transferFrom", | ||
outputs: [] | ||
} | ||
]; | ||
// src/erc20/publicActions/getERC20Decimals.ts | ||
import { readContract } from "viem/contract"; | ||
var getERC20Decimals = (client, { erc20, ...request }) => readContract(client, { | ||
abi: solmateErc20ABI, | ||
address: erc20.address, | ||
functionName: "decimals", | ||
...request | ||
}); | ||
// src/erc20/publicActions/getERC20Name.ts | ||
import { readContract as readContract2 } from "viem/contract"; | ||
var getERC20Name = (client, { erc20, ...request }) => readContract2(client, { | ||
abi: solmateErc20ABI, | ||
address: erc20.address, | ||
functionName: "name", | ||
...request | ||
}); | ||
// src/erc20/publicActions/getERC20Symbol.ts | ||
import { readContract as readContract3 } from "viem/contract"; | ||
var getERC20Symbol = (client, { erc20, ...request }) => readContract3(client, { | ||
abi: solmateErc20ABI, | ||
address: erc20.address, | ||
functionName: "symbol", | ||
...request | ||
}); | ||
// src/erc20/publicActions/getERC20.ts | ||
var getERC20 = (client, { erc20, ...request }) => Promise.all([ | ||
getERC20Name(client, { erc20, ...request }), | ||
getERC20Symbol(client, { erc20, ...request }), | ||
getERC20Decimals(client, { erc20, ...request }) | ||
]).then( | ||
([name, symbol, decimals]) => createERC20( | ||
erc20.address, | ||
name, | ||
symbol, | ||
decimals, | ||
erc20.chainID, | ||
erc20.blockCreated | ||
) | ||
); | ||
// src/erc20/publicActions/getERC20Allowance.ts | ||
import { readContract as readContract4 } from "viem/contract"; | ||
var getERC20Allowance = (client, { erc20, owner, spender, ...request }) => readContract4(client, { | ||
abi: solmateErc20ABI, | ||
address: erc20.address, | ||
functionName: "allowance", | ||
args: [owner, spender], | ||
...request | ||
}).then((data) => createAmountFromRaw(erc20, data)); | ||
// src/erc20/publicActions/getERC20BalanceOf.ts | ||
import { readContract as readContract5 } from "viem/contract"; | ||
var getERC20BalanceOf = (client, { erc20, address, ...request }) => readContract5(client, { | ||
abi: solmateErc20ABI, | ||
address: erc20.address, | ||
functionName: "balanceOf", | ||
args: [address], | ||
...request | ||
}).then((data) => createAmountFromRaw(erc20, data)); | ||
// src/erc20/publicActions/getERC20DomainSeparator.ts | ||
import { readContract as readContract6 } from "viem/contract"; | ||
var getERC20DomainSeparator = (client, { erc20, ...request }) => readContract6(client, { | ||
abi: solmateErc20ABI, | ||
address: erc20.address, | ||
functionName: "DOMAIN_SEPARATOR", | ||
...request | ||
}); | ||
// src/erc20/publicActions/getERC20Permit.ts | ||
var getERC20Permit = (client, { erc20, ...request }) => Promise.all([ | ||
getERC20Name(client, { erc20, ...request }), | ||
getERC20Symbol(client, { erc20, ...request }), | ||
getERC20Decimals(client, { erc20, ...request }) | ||
]).then( | ||
([name, symbol, decimals]) => createERC20Permit( | ||
erc20.address, | ||
name, | ||
symbol, | ||
decimals, | ||
erc20.version ?? "1", | ||
erc20.chainID, | ||
erc20.blockCreated | ||
) | ||
); | ||
// src/erc20/publicActions/getERC20PermitData.ts | ||
import { readContract as readContract7 } from "viem/contract"; | ||
var getERC20PermitData = (client, { erc20, address, ...request }) => Promise.all([ | ||
readContract7(client, { | ||
abi: solmateErc20ABI, | ||
address: erc20.address, | ||
functionName: "balanceOf", | ||
args: [address], | ||
...request | ||
}), | ||
readContract7(client, { | ||
abi: solmateErc20ABI, | ||
address: erc20.address, | ||
functionName: "nonces", | ||
args: [address], | ||
...request | ||
}) | ||
]).then( | ||
([balance, nonce]) => createERC20PermitDataFromRaw(erc20, balance, nonce) | ||
); | ||
// src/erc20/publicActions/getERC20PermitNonce.ts | ||
import { readContract as readContract8 } from "viem/contract"; | ||
var getERC20PermitNonce = (client, { erc20, address, ...request }) => readContract8(client, { | ||
abi: solmateErc20ABI, | ||
address: erc20.address, | ||
functionName: "nonces", | ||
args: [address], | ||
...request | ||
}); | ||
// src/erc20/publicActions/getERC20TotalSupply.ts | ||
import { readContract as readContract9 } from "viem/contract"; | ||
var getERC20TotalSupply = (client, { erc20, ...request }) => readContract9(client, { | ||
abi: solmateErc20ABI, | ||
address: erc20.address, | ||
functionName: "totalSupply", | ||
...request | ||
}).then((data) => createAmountFromRaw(erc20, data)); | ||
// src/erc20/publicActions/getIsERC20Permit.ts | ||
var getIsERC20Permit = (client, { erc20, ...request }) => Promise.all([ | ||
getERC20Permit(client, { erc20, ...request }), | ||
getERC20DomainSeparator(client, { erc20, ...request }) | ||
]).then(([erc202]) => erc202).catch(() => getERC20(client, { erc20, ...request })); | ||
// src/erc20/walletActions/signERC20Permit.ts | ||
import { | ||
getAddress as getAddress3 | ||
} from "viem"; | ||
import { signTypedData } from "viem/actions"; | ||
var signERC20Permit = (client, { | ||
permitData, | ||
spender, | ||
deadline, | ||
account = client.account, | ||
...request | ||
}) => { | ||
const domain = { | ||
name: permitData.token.name, | ||
version: permitData.token.version, | ||
chainId: permitData.token.chainID, | ||
verifyingContract: getAddress3(permitData.token.address) | ||
}; | ||
const owner = client.account?.address ?? (typeof account === "object" ? account.address : account); | ||
return signTypedData(client, { | ||
domain, | ||
types: PermitType, | ||
primaryType: "Permit", | ||
message: { | ||
owner, | ||
spender, | ||
value: permitData.amount, | ||
deadline, | ||
nonce: permitData.nonce | ||
}, | ||
account, | ||
...request | ||
}); | ||
}; | ||
// src/erc20/walletActions/simulateERC20Approve.ts | ||
import { simulateContract } from "viem/contract"; | ||
var simulateERC20Approve = (client, { | ||
args: { amount, spender }, | ||
...request | ||
}) => simulateContract(client, { | ||
address: amount.token.address, | ||
abi: solmateErc20ABI, | ||
functionName: "approve", | ||
args: [spender, amount.amount], | ||
...request | ||
}); | ||
// src/erc20/walletActions/simulateERC20Permit.ts | ||
import { simulateContract as simulateContract2 } from "viem/contract"; | ||
var simulateERC20Permit = (client, { | ||
args: { owner, spender, signature, permitData, deadline }, | ||
...request | ||
}) => { | ||
const r = `0x${signature.substring(2, 2 + 64)}`; | ||
const s = `0x${signature.substring(2 + 64, 2 + 64 + 64)}`; | ||
const v = Number(`0x${signature.substring(2 + 64 + 64)}`); | ||
return simulateContract2(client, { | ||
address: permitData.token.address, | ||
abi: solmateErc20ABI, | ||
functionName: "permit", | ||
args: [owner, spender, permitData.amount, deadline, v, r, s], | ||
...request | ||
}); | ||
}; | ||
// src/erc20/walletActions/simulateERC20Transfer.ts | ||
import { simulateContract as simulateContract3 } from "viem/contract"; | ||
var simulateERC20Transfer = (client, { | ||
args: { amount, to }, | ||
...request | ||
}) => simulateContract3(client, { | ||
address: amount.token.address, | ||
abi: solmateErc20ABI, | ||
functionName: "transfer", | ||
args: [to, amount.amount], | ||
...request | ||
}); | ||
// src/erc20/walletActions/simulateERC20TransferFrom.ts | ||
import { simulateContract as simulateContract4 } from "viem/contract"; | ||
var simulateERC20TransferFrom = (client, { | ||
args: { amount, from, to }, | ||
...request | ||
}) => simulateContract4(client, { | ||
address: amount.token.address, | ||
abi: solmateErc20ABI, | ||
functionName: "transferFrom", | ||
args: [from, to, amount.amount], | ||
...request | ||
}); | ||
// src/erc721/utils.ts | ||
import { getAddress as getAddress4 } from "viem"; | ||
var createERC721 = (address, name, symbol, chainID, blockCreated = 0n) => ({ | ||
type: "erc721", | ||
address: getAddress4(address), | ||
name, | ||
symbol, | ||
chainID, | ||
blockCreated | ||
}); | ||
var createERC721Data = (erc721, balance, ids) => ({ | ||
type: `${erc721.type}Data`, | ||
token: erc721, | ||
balance, | ||
ids | ||
}); | ||
// src/erc721/publicActions/getERC721Name.ts | ||
import { readContract as readContract10 } from "viem/contract"; | ||
var getERC721Name = (client, { erc721, ...request }) => readContract10(client, { | ||
abi: solmateErc721ABI, | ||
address: erc721.address, | ||
functionName: "name", | ||
...request | ||
}); | ||
// src/erc721/publicActions/getERC721Symbol.ts | ||
import { readContract as readContract11 } from "viem/contract"; | ||
var getERC721Symbol = (client, { erc721, ...request }) => readContract11(client, { | ||
abi: solmateErc721ABI, | ||
address: erc721.address, | ||
functionName: "symbol", | ||
...request | ||
}); | ||
// src/erc721/publicActions/getERC721.ts | ||
var getERC721 = (client, { erc721, ...request }) => Promise.all([ | ||
getERC721Name(client, { erc721, ...request }), | ||
getERC721Symbol(client, { erc721, ...request }) | ||
]).then( | ||
([name, symbol]) => createERC721( | ||
erc721.address, | ||
name, | ||
symbol, | ||
erc721.chainID, | ||
erc721.blockCreated | ||
) | ||
); | ||
// src/erc721/publicActions/getERC721Approved.ts | ||
import { readContract as readContract12 } from "viem/contract"; | ||
var getERC721Approved = (client, { erc721, id, ...request }) => readContract12(client, { | ||
abi: solmateErc721ABI, | ||
address: erc721.address, | ||
functionName: "getApproved", | ||
args: [id], | ||
...request | ||
}); | ||
// src/erc721/publicActions/getERC721BalanceOf.ts | ||
import { readContract as readContract13 } from "viem/contract"; | ||
var getERC721BalanceOf = (client, { erc721, address, ...request }) => readContract13(client, { | ||
abi: solmateErc721ABI, | ||
address: erc721.address, | ||
functionName: "balanceOf", | ||
args: [address], | ||
...request | ||
}); | ||
// src/erc721/publicActions/getERC721Data.ts | ||
var getERC721Data = (client, { erc721, address, ...request }) => getERC721BalanceOf(client, { erc721, address, ...request }).then((data) => { | ||
if (data > Number.MAX_SAFE_INTEGER) | ||
throw Error("balance exceeds maximum representable number"); | ||
return createERC721Data(erc721, Number(data)); | ||
}); | ||
// src/erc721/publicActions/getERC721IsApprovedForAll.ts | ||
import { readContract as readContract14 } from "viem/contract"; | ||
var getERC721IsApprovedForAll = (client, { erc721, owner, spender, ...request }) => readContract14(client, { | ||
abi: solmateErc721ABI, | ||
address: erc721.address, | ||
functionName: "isApprovedForAll", | ||
args: [owner, spender], | ||
...request | ||
}); | ||
// src/erc721/publicActions/getERC721OwnerOf.ts | ||
import { readContract as readContract15 } from "viem/contract"; | ||
var getERC721OwnerOf = (client, { erc721, id, ...request }) => readContract15(client, { | ||
abi: solmateErc721ABI, | ||
address: erc721.address, | ||
functionName: "ownerOf", | ||
args: [id], | ||
...request | ||
}); | ||
// src/erc721/publicActions/getERC721SupportsInterface.ts | ||
import { readContract as readContract16 } from "viem/contract"; | ||
var getERC721SupportsInterface = (client, { erc721, interfaceID, ...request }) => readContract16(client, { | ||
abi: solmateErc721ABI, | ||
address: erc721.address, | ||
functionName: "supportsInterface", | ||
args: [interfaceID], | ||
...request | ||
}); | ||
// src/erc721/publicActions/getERC721TokenURI.ts | ||
import { readContract as readContract17 } from "viem/contract"; | ||
var getERC721TokenURI = (client, { erc721, id, ...request }) => readContract17(client, { | ||
abi: solmateErc721ABI, | ||
address: erc721.address, | ||
functionName: "tokenURI", | ||
args: [id], | ||
...request | ||
}); | ||
// src/erc721/walletActions/simulateERC721Transfer.ts | ||
import { simulateContract as simulateContract5 } from "viem/contract"; | ||
var simulateERC721Transfer = (client, { | ||
args: { erc721, from, to, data, id }, | ||
...request | ||
}) => data === void 0 ? simulateContract5(client, { | ||
address: erc721.address, | ||
abi: solmateErc721ABI, | ||
functionName: "transferFrom", | ||
args: [ | ||
from ?? client.account?.address ?? (typeof request.account === "object" ? request.account.address : request.account), | ||
to, | ||
id | ||
], | ||
...request | ||
}) : data === "safe" ? simulateContract5(client, { | ||
address: erc721.address, | ||
abi: solmateErc721ABI, | ||
functionName: "safeTransferFrom", | ||
args: [ | ||
from ?? client.account?.address ?? (typeof request.account === "object" ? request.account.address : request.account), | ||
to, | ||
id | ||
], | ||
...request | ||
}) : simulateContract5(client, { | ||
address: erc721.address, | ||
abi: solmateErc721ABI, | ||
functionName: "safeTransferFrom", | ||
args: [ | ||
from ?? client.account?.address ?? (typeof request.account === "object" ? request.account.address : request.account), | ||
to, | ||
id, | ||
data | ||
], | ||
...request | ||
}); | ||
// src/erc721/walletActions/simulateERC721Approve.ts | ||
import { simulateContract as simulateContract6 } from "viem/contract"; | ||
var simulateERC721Approve = (client, { | ||
args: { erc721, spender, id }, | ||
...request | ||
}) => simulateContract6(client, { | ||
address: erc721.address, | ||
abi: solmateErc721ABI, | ||
functionName: "approve", | ||
args: [spender, id], | ||
...request | ||
}); | ||
// src/erc721/walletActions/simulateERC721SetApprovalForAll.ts | ||
import { simulateContract as simulateContract7 } from "viem/contract"; | ||
var simulateERC721SetApprovalForAll = (client, { | ||
args: { erc721, spender, approved }, | ||
...request | ||
}) => simulateContract7(client, { | ||
address: erc721.address, | ||
abi: solmateErc721ABI, | ||
functionName: "setApprovalForAll", | ||
args: [spender, approved], | ||
...request | ||
}); | ||
// src/erc1155/utils.ts | ||
import { getAddress as getAddress5 } from "viem"; | ||
var createERC1155 = (address, id, uri, chainID, blockCreated = 0n) => ({ | ||
type: "erc1155", | ||
address: getAddress5(address), | ||
id, | ||
uri, | ||
chainID, | ||
blockCreated | ||
}); | ||
var createERC1155Data = (erc1155, amount) => ({ | ||
type: `${erc1155.type}Data`, | ||
token: erc1155, | ||
amount | ||
}); | ||
// src/erc1155/publicActions/getERC1155.ts | ||
import { readContract as readContract18 } from "viem/contract"; | ||
var getERC1155 = (client, { erc1155, ...request }) => readContract18(client, { | ||
abi: solmateErc1155ABI, | ||
address: erc1155.address, | ||
functionName: "uri", | ||
args: [erc1155.id], | ||
...request | ||
}).then( | ||
(data) => createERC1155( | ||
erc1155.address, | ||
erc1155.id, | ||
data, | ||
erc1155.chainID, | ||
erc1155.blockCreated | ||
) | ||
); | ||
// src/erc1155/publicActions/getERC1155BalanceOf.ts | ||
import { readContract as readContract19 } from "viem/contract"; | ||
var getERC1155BalanceOf = (client, { erc1155, address, ...request }) => readContract19(client, { | ||
abi: solmateErc1155ABI, | ||
address: erc1155.address, | ||
functionName: "balanceOf", | ||
args: [address, erc1155.id], | ||
...request | ||
}).then((data) => createERC1155Data(erc1155, data)); | ||
// src/erc1155/publicActions/getERC1155IsApprovedForAll.ts | ||
import { readContract as readContract20 } from "viem/contract"; | ||
var getERC1155IsApprovedForAll = (client, { erc1155, owner, spender, ...request }) => readContract20(client, { | ||
abi: solmateErc1155ABI, | ||
address: erc1155.address, | ||
functionName: "isApprovedForAll", | ||
args: [owner, spender], | ||
...request | ||
}); | ||
// src/erc1155/publicActions/getERC1155URI.ts | ||
import { readContract as readContract21 } from "viem/contract"; | ||
var getERC1155URI = (client, { erc1155, ...request }) => readContract21(client, { | ||
abi: solmateErc1155ABI, | ||
address: erc1155.address, | ||
functionName: "uri", | ||
args: [erc1155.id], | ||
...request | ||
}); | ||
// src/erc1155/walletActions/simulateERC1155Transfer.ts | ||
import { simulateContract as simulateContract8 } from "viem/contract"; | ||
var simulateERC1155Transfer = (client, { | ||
args: { erc1155Data, to, from, data }, | ||
...request | ||
}) => simulateContract8(client, { | ||
address: erc1155Data.token.address, | ||
abi: solmateErc1155ABI, | ||
functionName: "safeTransferFrom", | ||
args: [ | ||
from ?? client.account?.address ?? (typeof request.account === "object" ? request.account.address : request.account), | ||
to, | ||
erc1155Data.token.id, | ||
erc1155Data.amount, | ||
data ?? "0x" | ||
], | ||
...request | ||
}); | ||
// src/erc1155/walletActions/simulateERC1155TransferBatch.ts | ||
import { | ||
getAddress as getAddress6 | ||
} from "viem"; | ||
import { simulateContract as simulateContract9 } from "viem/contract"; | ||
var simulateERC1155TransferBatch = (client, { | ||
args: { erc1155Data, to, from, data }, | ||
...request | ||
}) => { | ||
const address = erc1155Data.reduce((addr, cur) => { | ||
if (addr === void 0) | ||
return getAddress6(cur.token.address); | ||
else if (addr !== getAddress6(cur.token.address)) | ||
throw Error("Tokens refering to different addresses"); | ||
else | ||
return addr; | ||
}, void 0); | ||
if (address === void 0) | ||
throw Error("No tokens passed to transfer"); | ||
return simulateContract9(client, { | ||
address, | ||
abi: solmateErc1155ABI, | ||
functionName: "safeBatchTransferFrom", | ||
args: [ | ||
from ?? client.account?.address ?? (typeof request.account === "object" ? request.account.address : request.account), | ||
to, | ||
erc1155Data.map((t) => t.token.id), | ||
erc1155Data.map((t) => t.amount), | ||
data ?? "0x" | ||
], | ||
...request | ||
}); | ||
}; | ||
// src/erc1155/walletActions/simulateERC1155SetApprovalForAll.ts | ||
import { simulateContract as simulateContract10 } from "viem/contract"; | ||
var simulateERC1155SetApprovalForAll = (client, { | ||
args: { erc1155, spender, approved }, | ||
...request | ||
}) => simulateContract10(client, { | ||
address: erc1155.address, | ||
abi: solmateErc1155ABI, | ||
functionName: "setApprovalForAll", | ||
args: [spender, approved], | ||
...request | ||
}); | ||
// src/fraction/utils.ts | ||
import invariant2 from "tiny-invariant"; | ||
var isFraction = (x) => typeof x === "object"; | ||
var createFraction = (numerator, denominator = 1) => { | ||
const d = BigInt(denominator); | ||
invariant2(d !== 0n, "Fraction: denominator equal to 0"); | ||
return { type: "fraction", numerator: BigInt(numerator), denominator: d }; | ||
}; | ||
var fractionQuotient = (fraction) => fraction.numerator / fraction.denominator; | ||
var fractionRemainder = (fraction) => fraction.numerator % fraction.denominator; | ||
var fractionInvert = (fraction) => { | ||
invariant2(fraction.numerator !== 0n, "Fraction: denominator equal to 0"); | ||
return { | ||
type: "fraction", | ||
numerator: fraction.denominator, | ||
denominator: fraction.numerator | ||
}; | ||
}; | ||
var fractionAdd = (a, b) => isFraction(b) ? { | ||
type: "fraction", | ||
numerator: a.numerator * b.denominator + b.numerator * a.denominator, | ||
denominator: a.denominator * b.denominator | ||
} : { | ||
type: "fraction", | ||
numerator: a.numerator + a.denominator * BigInt(b), | ||
denominator: a.denominator | ||
}; | ||
var fractionSubtract = (a, b) => isFraction(b) ? { | ||
type: "fraction", | ||
numerator: a.numerator * b.denominator - b.numerator * a.denominator, | ||
denominator: a.denominator * b.denominator | ||
} : { | ||
type: "fraction", | ||
numerator: a.numerator - a.denominator * BigInt(b), | ||
denominator: a.denominator | ||
}; | ||
var fractionMultiply = (a, b) => isFraction(b) ? { | ||
type: "fraction", | ||
numerator: a.numerator * b.numerator, | ||
denominator: a.denominator * b.denominator | ||
} : { | ||
type: "fraction", | ||
numerator: a.numerator * BigInt(b), | ||
denominator: a.denominator | ||
}; | ||
var fractionDivide = (a, b) => isFraction(b) ? { | ||
type: "fraction", | ||
numerator: a.numerator * b.denominator, | ||
denominator: a.denominator * b.numerator | ||
} : { | ||
type: "fraction", | ||
numerator: a.numerator, | ||
denominator: a.denominator * BigInt(b) | ||
}; | ||
var fractionLessThan = (a, b) => isFraction(b) ? a.numerator * b.denominator < a.denominator * b.numerator : a.numerator < a.denominator * BigInt(b); | ||
var fractionGreaterThan = (a, b) => isFraction(b) ? a.numerator * b.denominator > a.denominator * b.numerator : a.numerator > a.denominator * BigInt(b); | ||
var fractionEqualTo = (a, b) => isFraction(b) ? a.numerator * b.denominator === a.denominator * b.numerator : a.numerator === a.denominator * BigInt(b); | ||
var fractionToNumber = (fraction) => Number(fraction.numerator) / Number(fraction.denominator); | ||
// src/native/publicActions/getNativeBalance.ts | ||
import { getBalance } from "viem/actions"; | ||
var getNativeBalance = (client, { | ||
address, | ||
nativeCurrency, | ||
...request | ||
}) => getBalance(client, { address, ...request }).then( | ||
(data) => createAmountFromRaw(nativeCurrency, data) | ||
); | ||
// src/price/utils.ts | ||
import invariant3 from "tiny-invariant"; | ||
var isPrice = (x) => typeof x === "object"; | ||
var createPriceFromFraction = (quote, base, price) => ({ | ||
type: "price", | ||
quote, | ||
base, | ||
numerator: quote.decimals ? price.numerator * 10n ** BigInt(quote.decimals) : price.numerator, | ||
denominator: base.decimals ? price.denominator * 10n ** BigInt(base.decimals) : price.denominator | ||
}); | ||
var createPriceFromAmounts = (quote, base) => ({ | ||
type: "price", | ||
quote: quote.token, | ||
base: base.token, | ||
numerator: base.amount, | ||
denominator: quote.amount | ||
}); | ||
var createPrice = (quote, base, numerator, denominator = 1) => ({ | ||
type: "price", | ||
quote, | ||
base, | ||
numerator: quote.decimals ? BigInt(numerator) * 10n ** BigInt(quote.decimals) : BigInt(numerator), | ||
denominator: base.decimals ? BigInt(denominator) * 10n ** BigInt(base.decimals) : BigInt(denominator) | ||
}); | ||
var priceInvert = (price) => ({ | ||
...fractionInvert(rawPrice(price)), | ||
type: "price", | ||
quote: price.base, | ||
base: price.quote | ||
}); | ||
var priceAdd = (a, b) => { | ||
if (isPrice(b)) | ||
invariant3(a.base === b.base && a.quote === b.quote); | ||
return isPrice(b) ? { | ||
...fractionAdd(rawPrice(a), rawPrice(b)), | ||
type: "price", | ||
quote: a.quote, | ||
base: a.base | ||
} : createPriceFromFraction( | ||
a.quote, | ||
a.base, | ||
fractionAdd(adjustedPrice(a), b) | ||
); | ||
}; | ||
var priceSubtract = (a, b) => { | ||
if (isPrice(b)) | ||
invariant3(a.base === b.base && a.quote === b.quote); | ||
return isPrice(b) ? { | ||
...fractionSubtract(rawPrice(a), rawPrice(b)), | ||
type: "price", | ||
quote: a.quote, | ||
base: a.base | ||
} : createPriceFromFraction( | ||
a.quote, | ||
a.base, | ||
fractionSubtract(adjustedPrice(a), b) | ||
); | ||
}; | ||
var priceMultiply = (a, b) => { | ||
if (isPrice(b)) | ||
invariant3(a.base === b.base && a.quote === b.quote); | ||
return isPrice(b) ? { | ||
type: "price", | ||
quote: a.quote, | ||
base: a.base, | ||
numerator: scaleUp( | ||
a.base, | ||
fractionMultiply(rawPrice(a), rawPrice(b)).numerator | ||
), | ||
denominator: scaleUp( | ||
a.quote, | ||
fractionMultiply(rawPrice(a), rawPrice(b)).denominator | ||
) | ||
} : createPriceFromFraction( | ||
a.quote, | ||
a.base, | ||
fractionMultiply(adjustedPrice(a), b) | ||
); | ||
}; | ||
var priceDivide = (a, b) => { | ||
if (isPrice(b)) | ||
invariant3(a.base === b.base && a.quote === b.quote); | ||
return isPrice(b) ? { | ||
type: "price", | ||
quote: a.quote, | ||
base: a.base, | ||
numerator: scaleUp( | ||
a.quote, | ||
fractionDivide(rawPrice(a), rawPrice(b)).numerator | ||
), | ||
denominator: scaleUp( | ||
a.base, | ||
fractionDivide(rawPrice(a), rawPrice(b)).denominator | ||
) | ||
} : createPriceFromFraction( | ||
a.quote, | ||
a.base, | ||
fractionDivide(adjustedPrice(a), b) | ||
); | ||
}; | ||
var priceLessThan = (a, b) => { | ||
if (isPrice(b)) | ||
invariant3(a.base === b.base && a.quote === b.quote); | ||
return isPrice(b) ? fractionLessThan(rawPrice(a), rawPrice(b)) : fractionLessThan(adjustedPrice(a), b); | ||
}; | ||
var priceEqualTo = (a, b) => { | ||
if (isPrice(b)) | ||
invariant3(a.base === b.base && a.quote === b.quote); | ||
return isPrice(b) ? fractionEqualTo(rawPrice(a), rawPrice(b)) : fractionEqualTo(adjustedPrice(a), b); | ||
}; | ||
var priceGreaterThan = (a, b) => { | ||
if (isPrice(b)) | ||
invariant3(a.base === b.base && a.quote === b.quote); | ||
return isPrice(b) ? fractionGreaterThan(rawPrice(a), rawPrice(b)) : fractionGreaterThan(adjustedPrice(a), b); | ||
}; | ||
var priceQuote = (price, amount) => { | ||
invariant3(price.base === amount.token); | ||
return createAmountFromRaw( | ||
price.quote, | ||
price.numerator * amount.amount / price.denominator | ||
); | ||
}; | ||
var rawPrice = (price) => ({ | ||
type: "fraction", | ||
numerator: price.numerator, | ||
denominator: price.denominator | ||
}); | ||
var adjustedPrice = (price) => ({ | ||
type: "fraction", | ||
numerator: price.base.decimals ? price.numerator * 10n ** BigInt(price.base.decimals) : price.numerator, | ||
denominator: price.quote.decimals ? price.denominator * 10n ** BigInt(price.quote.decimals) : price.denominator | ||
}); | ||
var priceToNumber = (price) => fractionToNumber(adjustedPrice(price)); | ||
// src/utils/getQueryKey.ts | ||
var getQueryKey = (get, args, chainID) => { | ||
return [ | ||
{ | ||
chainID, | ||
read: { | ||
name: get.name, | ||
args | ||
} | ||
} | ||
]; | ||
}; | ||
// src/weth/walletActions/simulateWETHDeposit.ts | ||
import { simulateContract as simulateContract11 } from "viem/contract"; | ||
var simulateWETHDeposit = (client, { | ||
args: { amount }, | ||
...request | ||
}) => simulateContract11(client, { | ||
address: amount.token.address, | ||
abi: weth9ABI, | ||
functionName: "deposit", | ||
value: amount.amount, | ||
...request | ||
}); | ||
// src/weth/walletActions/simulateWETHWithdraw.ts | ||
import { simulateContract as simulateContract12 } from "viem/contract"; | ||
var simulateWETHWithdraw = (client, { | ||
args: { amount }, | ||
...request | ||
}) => simulateContract12(client, { | ||
address: amount.token.address, | ||
abi: weth9ABI, | ||
functionName: "withdraw", | ||
args: [amount.amount], | ||
...request | ||
}); | ||
// src/decorator/publicActions.ts | ||
var publicActionReverseMirage = (client) => ({ | ||
getNativeBalance: (args) => getNativeBalance(client, args), | ||
getERC20: (args) => getERC20(client, args), | ||
getERC20Allowance: (args) => getERC20Allowance(client, args), | ||
getERC20BalanceOf: (args) => getERC20BalanceOf(client, args), | ||
getERC20TotalSupply: (args) => getERC20TotalSupply(client, args), | ||
getERC20Name: (args) => getERC20Name(client, args), | ||
getERC20Symbol: (args) => getERC20Symbol(client, args), | ||
getERC20Decimals: (args) => getERC20Decimals(client, args), | ||
getERC20DomainSeparator: (args) => getERC20DomainSeparator(client, args), | ||
getERC20Permit: (args) => getERC20Permit(client, args), | ||
getERC20PermitNonce: (args) => getERC20PermitNonce(client, args), | ||
getERC20PermitData: (args) => getERC20PermitData(client, args), | ||
getIsERC20Permit: (args) => getIsERC20Permit(client, args), | ||
getERC721: (args) => getERC721(client, args), | ||
getERC721Approved: (args) => getERC721Approved(client, args), | ||
getERC721BalanceOf: (args) => getERC721BalanceOf(client, args), | ||
getERC721OwnerOf: (args) => getERC721OwnerOf(client, args), | ||
getERC721Data: (args) => getERC721Data(client, args), | ||
getERC721Name: (args) => getERC721Name(client, args), | ||
getERC721Symbol: (args) => getERC721Symbol(client, args), | ||
getERC721TokenURI: (args) => getERC721TokenURI(client, args), | ||
getERC721IsApprovedForAll: (args) => getERC721IsApprovedForAll(client, args), | ||
getERC721SupportsInterface: (args) => getERC721SupportsInterface(client, args), | ||
getERC1155: (args) => getERC1155(client, args), | ||
getERC1155BalanceOf: (args) => getERC1155BalanceOf(client, args), | ||
getERC1155IsApprovedForAll: (args) => getERC1155IsApprovedForAll(client, args), | ||
getERC1155URI: (args) => getERC1155URI(client, args), | ||
simulateWETHDeposit: (args) => simulateWETHDeposit(client, args), | ||
simulateWETHWithdraw: (args) => simulateWETHWithdraw(client, args), | ||
simulateERC20Approve: (args) => simulateERC20Approve(client, args), | ||
simulateERC20Permit: (args) => simulateERC20Permit(client, args), | ||
simulateERC20Transfer: (args) => simulateERC20Transfer(client, args), | ||
simulateERC20TransferFrom: (args) => simulateERC20TransferFrom(client, args), | ||
simulateERC721Approve: (args) => simulateERC721Approve(client, args), | ||
simulateERC721SetApprovalForAll: (args) => simulateERC721SetApprovalForAll(client, args), | ||
simulateERC721Transfer: (args) => simulateERC721Transfer(client, args), | ||
simulateERC1155SetApprovalForAll: (args) => simulateERC1155SetApprovalForAll(client, args), | ||
simulateERC1155Transfer: (args) => simulateERC1155Transfer(client, args), | ||
simulateERC1155TransferBatch: (args) => simulateERC1155TransferBatch(client, args) | ||
}); | ||
// src/decorator/walletActions.ts | ||
var walletActionReverseMirage = (client) => ({ | ||
signERC20Permit: (args) => signERC20Permit(client, args) | ||
}); | ||
export { | ||
PermitType, | ||
adjustedPrice, | ||
amountAdd, | ||
amountDivide, | ||
amountEqualTo, | ||
amountGreaterThan, | ||
amountLessThan, | ||
amountMultiply, | ||
amountSubtract, | ||
amountToNumber, | ||
arbitrumGoerliTokens, | ||
arbitrumTokens, | ||
baseGoerliTokens, | ||
baseTokens, | ||
celoAlfajoresTokens, | ||
celoTokens, | ||
createAmountFromFraction, | ||
createAmountFromRaw, | ||
createAmountFromString, | ||
createERC1155, | ||
createERC1155Data, | ||
createERC20, | ||
createERC20Permit, | ||
createERC20PermitDataFromFraction, | ||
createERC20PermitDataFromRaw, | ||
createERC20PermitDataFromString, | ||
createERC721, | ||
createERC721Data, | ||
createFraction, | ||
createNativeCurrency, | ||
createPrice, | ||
createPriceFromAmounts, | ||
createPriceFromFraction, | ||
createWETH, | ||
foundryTokens, | ||
fractionAdd, | ||
fractionDivide, | ||
fractionEqualTo, | ||
fractionGreaterThan, | ||
fractionInvert, | ||
fractionLessThan, | ||
fractionMultiply, | ||
fractionQuotient, | ||
fractionRemainder, | ||
fractionSubtract, | ||
fractionToNumber, | ||
getERC1155, | ||
getERC1155BalanceOf, | ||
getERC1155IsApprovedForAll, | ||
getERC1155URI, | ||
getERC20, | ||
getERC20Allowance, | ||
getERC20BalanceOf, | ||
getERC20Decimals, | ||
getERC20DomainSeparator, | ||
getERC20Name, | ||
getERC20Permit, | ||
getERC20PermitData, | ||
getERC20PermitNonce, | ||
getERC20Symbol, | ||
getERC20TotalSupply, | ||
getERC721, | ||
getERC721Approved, | ||
getERC721BalanceOf, | ||
getERC721Data, | ||
getERC721IsApprovedForAll, | ||
getERC721Name, | ||
getERC721OwnerOf, | ||
getERC721SupportsInterface, | ||
getERC721Symbol, | ||
getERC721TokenURI, | ||
getIsERC20Permit, | ||
getNativeBalance, | ||
getQueryKey, | ||
goerliTokens, | ||
isAmount, | ||
isFraction, | ||
isPrice, | ||
mainnetTokens, | ||
optimismGoerliTokens, | ||
optimismTokens, | ||
priceAdd, | ||
priceDivide, | ||
priceEqualTo, | ||
priceGreaterThan, | ||
priceInvert, | ||
priceLessThan, | ||
priceMultiply, | ||
priceQuote, | ||
priceSubtract, | ||
priceToNumber, | ||
publicActionReverseMirage, | ||
rawPrice, | ||
sepoliaTokens, | ||
signERC20Permit, | ||
simulateERC1155SetApprovalForAll, | ||
simulateERC1155Transfer, | ||
simulateERC1155TransferBatch, | ||
simulateERC20Approve, | ||
simulateERC20Permit, | ||
simulateERC20Transfer, | ||
simulateERC20TransferFrom, | ||
simulateERC721Approve, | ||
simulateERC721SetApprovalForAll, | ||
simulateERC721Transfer, | ||
simulateWETHDeposit, | ||
simulateWETHWithdraw, | ||
solmateErc1155ABI as solmateERC1155ABI, | ||
solmateErc20ABI as solmateERC20ABI, | ||
solmateErc721ABI as solmateERC721ABI, | ||
walletActionReverseMirage, | ||
weth9ABI | ||
}; | ||
export { $ as PermitType, R as adjustedPrice, Fe as amountAdd, Ge as amountDivide, De as amountEqualTo, Me as amountGreaterThan, We as amountLessThan, Ne as amountMultiply, Oe as amountSubtract, Se as amountToNumber, He as arbitrumGoerliTokens, je as arbitrumTokens, Ue as baseGoerliTokens, Qe as baseTokens, qe as celoAlfajoresTokens, _e as celoTokens, U as createAmountFromFraction, l as createAmountFromRaw, Q as createAmountFromString, Te as createERC1155, fe as createERC1155Data, _ as createERC20, q as createERC20Permit, Ze as createERC20PermitDataFromFraction, L as createERC20PermitDataFromRaw, Ye as createERC20PermitDataFromString, ae as createERC721, oe as createERC721Data, rt as createFraction, s as createNativeCurrency, st as createPrice, it as createPriceFromAmounts, G as createPriceFromFraction, m as createWETH, c as erc1155ABI, i as erc20ABI, p as erc721ABI, Le as foundryTokens, W as fractionAdd, N as fractionDivide, j as fractionEqualTo, S as fractionGreaterThan, ge as fractionInvert, M as fractionLessThan, O as fractionMultiply, at as fractionQuotient, ot as fractionRemainder, D as fractionSubtract, ve as fractionToNumber, Re as getERC1155, Ee as getERC1155BalanceOf, Ae as getERC1155IsApprovedForAll, xe as getERC1155URI, v as getERC20, K as getERC20Allowance, X as getERC20BalanceOf, A as getERC20Decimals, B as getERC20DomainSeparator, x as getERC20Name, I as getERC20Permit, z as getERC20PermitData, J as getERC20PermitNonce, b as getERC20Symbol, V as getERC20TotalSupply, ie as getERC721, se as getERC721Approved, F as getERC721BalanceOf, pe as getERC721Data, me as getERC721IsApprovedForAll, w as getERC721Name, de as getERC721OwnerOf, ue as getERC721SupportsInterface, k as getERC721Symbol, ye as getERC721TokenURI, Y as getIsERC20Permit, Be as getNativeBalance, Rt as getQueryKey, $e as goerliTokens, y as isAmount, E as isFraction, C as isPrice, Ke as mainnetTokens, ze as optimismGoerliTokens, Xe as optimismTokens, mt as priceAdd, yt as priceDivide, Ct as priceEqualTo, lt as priceGreaterThan, pt as priceInvert, ct as priceLessThan, ut as priceMultiply, Tt as priceQuote, dt as priceSubtract, ft as priceToNumber, on as publicActionReverseMirage, u as rawPrice, Je as sepoliaTokens, Z as signERC20Permit, sn as walletActionReverseMirage, g as weth9ABI, Pe as writeERC1155SetApprovalForAll, be as writeERC1155Transfer, he as writeERC1155TransferBatch, ee as writeERC20Approve, te as writeERC20Permit, ne as writeERC20Transfer, re as writeERC20TransferFrom, Ce as writeERC721Approve, le as writeERC721SetApprovalForAll, ce as writeERC721Transfer, Ie as writeWETHDeposit, we as writeWETHWithdraw }; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "reverse-mirage", | ||
"version": "1.0.0-next.2", | ||
"version": "1.0.0-next.3", | ||
"description": "Application level typescript utilities for Ethereum", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -30,19 +30,4 @@ import type { Chain, Client, Transport } from "viem"; | ||
import type { GetIsERC20PermitParameters } from "../erc20/publicActions/getIsERC20Permit.js"; | ||
import { | ||
type SimulateERC20ApproveParameters, | ||
simulateERC20Approve, | ||
} from "../erc20/walletActions/simulateERC20Approve.js"; | ||
import { | ||
type SimulateERC20PermitParameters, | ||
simulateERC20Permit, | ||
} from "../erc20/walletActions/simulateERC20Permit.js"; | ||
import { | ||
type SimulateERC20TransferParameters, | ||
simulateERC20Transfer, | ||
} from "../erc20/walletActions/simulateERC20Transfer.js"; | ||
import { | ||
type SimulateERC20TransferFromParameters, | ||
simulateERC20TransferFrom, | ||
} from "../erc20/walletActions/simulateERC20TransferFrom.js"; | ||
import { | ||
type BaseERC721, | ||
@@ -71,14 +56,2 @@ getERC721, | ||
import { | ||
type SimulateERC721ApproveParameters, | ||
simulateERC721Approve, | ||
} from "../erc721/walletActions/simulateERC721Approve.js"; | ||
import { | ||
type SimulateERC721SetApprovalForAllParameters, | ||
simulateERC721SetApprovalForAll, | ||
} from "../erc721/walletActions/simulateERC721SetApprovalForAll.js"; | ||
import { | ||
type SimulateERC721TransferParameters, | ||
simulateERC721Transfer, | ||
} from "../erc721/walletActions/simulateERC721Transfer.js"; | ||
import { | ||
type BaseERC1155, | ||
@@ -95,26 +68,6 @@ getERC1155, | ||
import { | ||
type SimulateERC1155SetApprovalForAllParameters, | ||
simulateERC1155SetApprovalForAll, | ||
} from "../erc1155/walletActions/simulateERC1155SetApprovalForAll.js"; | ||
import { | ||
type SimulateERC1155TransferParameters, | ||
simulateERC1155Transfer, | ||
} from "../erc1155/walletActions/simulateERC1155Transfer.js"; | ||
import { | ||
type SimulateERC1155TransferBatchParameters, | ||
simulateERC1155TransferBatch, | ||
} from "../erc1155/walletActions/simulateERC1155TransferBatch.js"; | ||
import { | ||
type GetNativeBalanceParameters, | ||
type NativeCurrency, | ||
getNativeBalance, | ||
} from "../native/publicActions/getNativeBalance.js"; | ||
import type { NativeCurrency } from "../native/types.js"; | ||
import { | ||
type SimulateWETHDepositParameters, | ||
simulateWETHDeposit, | ||
} from "../weth/walletActions/simulateWETHDeposit.js"; | ||
import { | ||
type SimulateWETHWithdrawParameters, | ||
simulateWETHWithdraw, | ||
} from "../weth/walletActions/simulateWETHWithdraw.js"; | ||
} from "../native/index.js"; | ||
@@ -184,33 +137,2 @@ export const publicActionReverseMirage = < | ||
getERC1155URI: (args: GetERC1155URIParameters) => getERC1155URI(client, args), | ||
simulateWETHDeposit: (args: SimulateWETHDepositParameters<TChain>) => | ||
simulateWETHDeposit(client, args), | ||
simulateWETHWithdraw: (args: SimulateWETHWithdrawParameters) => | ||
simulateWETHWithdraw(client, args), | ||
simulateERC20Approve: (args: SimulateERC20ApproveParameters) => | ||
simulateERC20Approve(client, args), | ||
simulateERC20Permit: (args: SimulateERC20PermitParameters) => | ||
simulateERC20Permit(client, args), | ||
simulateERC20Transfer: (args: SimulateERC20TransferParameters) => | ||
simulateERC20Transfer(client, args), | ||
simulateERC20TransferFrom: (args: SimulateERC20TransferFromParameters) => | ||
simulateERC20TransferFrom(client, args), | ||
simulateERC721Approve: (args: SimulateERC721ApproveParameters) => | ||
simulateERC721Approve(client, args), | ||
simulateERC721SetApprovalForAll: ( | ||
args: SimulateERC721SetApprovalForAllParameters, | ||
) => simulateERC721SetApprovalForAll(client, args), | ||
simulateERC721Transfer: (args: SimulateERC721TransferParameters) => | ||
simulateERC721Transfer(client, args), | ||
simulateERC1155SetApprovalForAll: ( | ||
args: SimulateERC1155SetApprovalForAllParameters, | ||
) => simulateERC1155SetApprovalForAll(client, args), | ||
simulateERC1155Transfer: (args: SimulateERC1155TransferParameters) => | ||
simulateERC1155Transfer(client, args), | ||
simulateERC1155TransferBatch: ( | ||
args: SimulateERC1155TransferBatchParameters, | ||
) => simulateERC1155TransferBatch(client, args), | ||
}); |
@@ -6,3 +6,52 @@ import type { Account, Chain, Client, Transport } from "viem"; | ||
} from "../erc20/walletActions/signERC20Permit.js"; | ||
import { | ||
type WriteERC1155TransferParameters, | ||
writeERC1155Transfer, | ||
} from "../erc1155/walletActions/writeERC1155Transfer.js"; | ||
import { | ||
type WriteERC1155TransferBatchParameters, | ||
writeERC1155TransferBatch, | ||
} from "../erc1155/walletActions/writeERC1155TransferBatch.js"; | ||
import { | ||
type WriteWETHDepositParameters, | ||
writeWETHDeposit, | ||
} from "../weth/walletActions/writeWETHDeposit.js"; | ||
import { | ||
type WriteWETHWithdrawParameters, | ||
writeWETHWithdraw, | ||
} from "../weth/walletActions/writeWETHWithdraw.js"; | ||
import { | ||
type WriteERC20ApproveParameters, | ||
writeERC20Approve, | ||
} from "../erc20/walletActions/writeERC20Approve.js"; | ||
import { | ||
type WriteERC20PermitParameters, | ||
writeERC20Permit, | ||
} from "../erc20/walletActions/writeERC20Permit.js"; | ||
import { | ||
type WriteERC20TransferParameters, | ||
writeERC20Transfer, | ||
} from "../erc20/walletActions/writeERC20Transfer.js"; | ||
import { | ||
type WriteERC20TransferFromParameters, | ||
writeERC20TransferFrom, | ||
} from "../erc20/walletActions/writeERC20TransferFrom.js"; | ||
import { | ||
type WriteERC721ApproveParameters, | ||
writeERC721Approve, | ||
} from "../erc721/walletActions/writeERC721Approve.js"; | ||
import { | ||
type WriteERC721SetApprovalForAllParameters, | ||
writeERC721SetApprovalForAll, | ||
} from "../erc721/walletActions/writeERC721SetApprovalForAll.js"; | ||
import { | ||
type WriteERC721TransferParameters, | ||
writeERC721Transfer, | ||
} from "../erc721/walletActions/writeERC721Transfer.js"; | ||
import { | ||
type WriteERC1155SetApprovalForAllParameters, | ||
writeERC1155SetApprovalForAll, | ||
} from "../erc1155/walletActions/writeERC1155SetApprovalForAll.js"; | ||
export const walletActionReverseMirage = < | ||
@@ -16,2 +65,36 @@ TChain extends Chain = Chain, | ||
signERC20Permit(client, args), | ||
writeWETHDeposit: (args: WriteWETHDepositParameters<TChain, TAccount>) => | ||
writeWETHDeposit(client, args), | ||
writeWETHWithdraw: (args: WriteWETHWithdrawParameters<TChain, TAccount>) => | ||
writeWETHWithdraw(client, args), | ||
writeERC20Approve: (args: WriteERC20ApproveParameters<TChain, TAccount>) => | ||
writeERC20Approve(client, args), | ||
writeERC20Permit: (args: WriteERC20PermitParameters<TChain, TAccount>) => | ||
writeERC20Permit(client, args), | ||
writeERC20Transfer: (args: WriteERC20TransferParameters<TChain, TAccount>) => | ||
writeERC20Transfer(client, args), | ||
writeERC20TransferFrom: ( | ||
args: WriteERC20TransferFromParameters<TChain, TAccount>, | ||
) => writeERC20TransferFrom(client, args), | ||
writeERC721Approve: (args: WriteERC721ApproveParameters<TChain, TAccount>) => | ||
writeERC721Approve(client, args), | ||
writeERC721SetApprovalForAll: ( | ||
args: WriteERC721SetApprovalForAllParameters<TChain, TAccount>, | ||
) => writeERC721SetApprovalForAll(client, args), | ||
writeERC721Transfer: ( | ||
args: WriteERC721TransferParameters<TChain, TAccount>, | ||
) => writeERC721Transfer(client, args), | ||
writeERC1155SetApprovalForAll: ( | ||
args: WriteERC1155SetApprovalForAllParameters<TChain, TAccount>, | ||
) => writeERC1155SetApprovalForAll(client, args), | ||
writeERC1155Transfer: ( | ||
args: WriteERC1155TransferParameters<TChain, TAccount>, | ||
) => writeERC1155Transfer(client, args), | ||
writeERC1155TransferBatch: ( | ||
args: WriteERC1155TransferBatchParameters<TChain, TAccount>, | ||
) => writeERC1155TransferBatch(client, args), | ||
}); |
@@ -16,4 +16,4 @@ export type { | ||
export { simulateERC1155Transfer } from "./walletActions/simulateERC1155Transfer.js"; | ||
export { simulateERC1155TransferBatch } from "./walletActions/simulateERC1155TransferBatch.js"; | ||
export { simulateERC1155SetApprovalForAll } from "./walletActions/simulateERC1155SetApprovalForAll.js"; | ||
export { writeERC1155Transfer } from "./walletActions/writeERC1155Transfer.js"; | ||
export { writeERC1155TransferBatch } from "./walletActions/writeERC1155TransferBatch.js"; | ||
export { writeERC1155SetApprovalForAll } from "./walletActions/writeERC1155SetApprovalForAll.js"; |
@@ -35,5 +35,5 @@ export type { | ||
export { signERC20Permit } from "./walletActions/signERC20Permit.js"; | ||
export { simulateERC20Approve } from "./walletActions/simulateERC20Approve.js"; | ||
export { simulateERC20Permit } from "./walletActions/simulateERC20Permit.js"; | ||
export { simulateERC20Transfer } from "./walletActions/simulateERC20Transfer.js"; | ||
export { simulateERC20TransferFrom } from "./walletActions/simulateERC20TransferFrom.js"; | ||
export { writeERC20Approve } from "./walletActions/writeERC20Approve.js"; | ||
export { writeERC20Permit } from "./walletActions/writeERC20Permit.js"; | ||
export { writeERC20Transfer } from "./walletActions/writeERC20Transfer.js"; | ||
export { writeERC20TransferFrom } from "./walletActions/writeERC20TransferFrom.js"; |
@@ -22,4 +22,4 @@ export type { | ||
export { simulateERC721Transfer } from "./walletActions/simulateERC721Transfer.js"; | ||
export { simulateERC721Approve } from "./walletActions/simulateERC721Approve.js"; | ||
export { simulateERC721SetApprovalForAll } from "./walletActions/simulateERC721SetApprovalForAll.js"; | ||
export { writeERC721Transfer } from "./walletActions/writeERC721Transfer.js"; | ||
export { writeERC721Approve } from "./walletActions/writeERC721Approve.js"; | ||
export { writeERC721SetApprovalForAll } from "./walletActions/writeERC721SetApprovalForAll.js"; |
@@ -46,3 +46,3 @@ export { | ||
PermitType, | ||
solmateERC20ABI, | ||
solmateERC20ABI as erc20ABI, | ||
getERC20, | ||
@@ -61,6 +61,6 @@ getERC20Allowance, | ||
signERC20Permit, | ||
simulateERC20Approve, | ||
simulateERC20Permit, | ||
simulateERC20Transfer, | ||
simulateERC20TransferFrom, | ||
writeERC20Approve, | ||
writeERC20Permit, | ||
writeERC20Transfer, | ||
writeERC20TransferFrom, | ||
} from "./erc20/index.js"; | ||
@@ -74,3 +74,3 @@ | ||
createERC721Data, | ||
solmateERC721ABI, | ||
solmateERC721ABI as erc721ABI, | ||
getERC721, | ||
@@ -86,5 +86,5 @@ getERC721Approved, | ||
getERC721TokenURI, | ||
simulateERC721Transfer, | ||
simulateERC721Approve, | ||
simulateERC721SetApprovalForAll, | ||
writeERC721Transfer, | ||
writeERC721Approve, | ||
writeERC721SetApprovalForAll, | ||
} from "./erc721/index.js"; | ||
@@ -98,3 +98,3 @@ | ||
createERC1155Data, | ||
solmateERC1155ABI, | ||
solmateERC1155ABI as erc1155ABI, | ||
getERC1155, | ||
@@ -104,5 +104,5 @@ getERC1155BalanceOf, | ||
getERC1155URI, | ||
simulateERC1155Transfer, | ||
simulateERC1155TransferBatch, | ||
simulateERC1155SetApprovalForAll, | ||
writeERC1155Transfer, | ||
writeERC1155TransferBatch, | ||
writeERC1155SetApprovalForAll, | ||
} from "./erc1155/index.js"; | ||
@@ -170,4 +170,4 @@ | ||
weth9ABI, | ||
simulateWETHDeposit, | ||
simulateWETHWithdraw, | ||
writeWETHDeposit, | ||
writeWETHWithdraw, | ||
} from "./weth/index.js"; | ||
@@ -174,0 +174,0 @@ |
@@ -7,3 +7,3 @@ export type { WETH } from "./types.js"; | ||
export { simulateWETHDeposit } from "./walletActions/simulateWETHDeposit.js"; | ||
export { simulateWETHWithdraw } from "./walletActions/simulateWETHWithdraw.js"; | ||
export { writeWETHDeposit } from "./walletActions/writeWETHDeposit.js"; | ||
export { writeWETHWithdraw } from "./walletActions/writeWETHWithdraw.js"; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
768843
7286
4