Socket
Socket
Sign inDemoInstall

reverse-mirage

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reverse-mirage - npm Package Compare versions

Comparing version 1.0.3 to 1.1.0

amount/index.ts

683

dist/index.js

@@ -1,9 +0,23 @@

import invariant3 from 'tiny-invariant';
import { parseUnits, getAddress } from 'viem/utils';
import { readContract, signTypedData, simulateContract, getBalance } from 'viem/actions';
import { getAddress as getAddress$1 } from 'viem';
import { readContract, signTypedData, simulateContract, getBalance } from 'viem/actions';
// src/amount/utils.ts
// amount/utils.ts
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 isTokenEqual = (a, b) => {
if (a === b)
return true;
const keysA = Object.keys(a).sort();
const keysB = Object.keys(b).sort();
if (keysA.length !== keysB.length)
return false;
for (let i = 0; i < keysA.length; i++) {
if (keysA[i] !== keysB[i])
return false;
if (a[keysA[i]] !== b[keysB[i]])
return false;
}
return true;
};
var isAmount = (x) => typeof x === "object";

@@ -27,3 +41,4 @@ var createAmountFromString = (token, amount) => ({

if (isAmount(b)) {
invariant3(a.token === b.token);
if (!isTokenEqual(a.token, b.token))
throw Error("Cannot add amounts of two different tokens.");
}

@@ -34,3 +49,4 @@ return isAmount(b) ? { ...a, amount: a.amount + b.amount } : { ...a, amount: a.amount + scaleUp(a.token, BigInt(b)) };

if (isAmount(b)) {
invariant3(a.token === b.token);
if (!isTokenEqual(a.token, b.token))
throw Error("Cannot subtract amounts of two different tokens.");
}

@@ -41,3 +57,4 @@ return isAmount(b) ? { ...a, amount: a.amount - b.amount } : { ...a, amount: a.amount - scaleUp(a.token, BigInt(b)) };

if (isAmount(b)) {
invariant3(a.token === b.token);
if (!isTokenEqual(a.token, b.token))
throw Error("Cannot multiply amounts of two different tokens.");
}

@@ -48,3 +65,4 @@ return isAmount(b) ? { ...a, amount: scaleDown(a.token, a.amount * b.amount) } : { ...a, amount: a.amount * BigInt(b) };

if (isAmount(b)) {
invariant3(a.token === b.token);
if (!isTokenEqual(a.token, b.token))
throw Error("Cannot divide amounts of two different tokens.");
}

@@ -55,3 +73,4 @@ return isAmount(b) ? { ...a, amount: scaleUp(a.token, a.amount) / b.amount } : { ...a, amount: a.amount / BigInt(b) };

if (isAmount(b)) {
invariant3(a.token === b.token);
if (!isTokenEqual(a.token, b.token))
throw Error("Cannot compare amounts of two different tokens.");
}

@@ -62,3 +81,4 @@ return isAmount(b) ? a.amount < b.amount : a.amount < scaleUp(a.token, BigInt(b));

if (isAmount(b)) {
invariant3(a.token === b.token);
if (!isTokenEqual(a.token, b.token))
throw Error("Cannot compare amounts of two different tokens.");
}

@@ -69,3 +89,4 @@ return isAmount(b) ? a.amount === b.amount : a.amount === scaleUp(a.token, BigInt(b));

if (isAmount(b)) {
invariant3(a.token === b.token);
if (!isTokenEqual(a.token, b.token))
throw Error("Cannot compare amounts of two different tokens.");
}

@@ -76,3 +97,3 @@ return isAmount(b) ? a.amount > b.amount : a.amount > scaleUp(a.token, BigInt(b));

// src/native/utils.ts
// native/utils.ts
var createNativeCurrency = (name, symbol, decimals, chainID) => ({

@@ -95,3 +116,3 @@ type: "nativeCurrency",

// src/chains/arbitrum.ts
// chains/arbitrum.ts
var arbitrumTokens = {

@@ -109,3 +130,3 @@ native: createNativeCurrency("Ether", "ETH", 18, 42161),

// src/chains/arbitrumGoerli.ts
// chains/arbitrumGoerli.ts
var arbitrumGoerliTokens = {

@@ -123,3 +144,3 @@ native: createNativeCurrency("Ether", "ETH", 18, 421613),

// src/chains/base.ts
// chains/base.ts
var baseTokens = {

@@ -136,3 +157,3 @@ native: createNativeCurrency("Ether", "ETH", 18, 8453),

// src/chains/baseGoerli.ts
// chains/baseGoerli.ts
var baseGoerliTokens = {

@@ -149,3 +170,3 @@ native: createNativeCurrency("Ether", "ETH", 18, 84531),

// src/chains/celo.ts
// chains/celo.ts
var celoTokens = {

@@ -163,3 +184,3 @@ native: createNativeCurrency("Celo Native Asset", "CELO", 18, 42220),

// src/chains/celoAlfajores.ts
// chains/celoAlfajores.ts
var celoAlfajoresTokens = {

@@ -176,3 +197,3 @@ native: createNativeCurrency("Celo Native Asset", "CELO", 18, 44787),

// src/chains/foundry.ts
// chains/foundry.ts
var foundryTokens = {

@@ -182,3 +203,3 @@ native: createNativeCurrency("Ether", "ETH", 18, 31337)

// src/chains/goerli.ts
// chains/goerli.ts
var goerliTokens = {

@@ -196,3 +217,3 @@ native: createNativeCurrency("Ether", "ETH", 18, 5),

// src/chains/mainnet.ts
// chains/mainnet.ts
var mainnetTokens = {

@@ -210,3 +231,3 @@ native: createNativeCurrency("Ether", "ETH", 18, 1),

// src/chains/optimism.ts
// chains/optimism.ts
var optimismTokens = {

@@ -223,3 +244,3 @@ native: createNativeCurrency("Ether", "ETH", 18, 10),

// src/chains/optimismGoerli.ts
// chains/optimismGoerli.ts
var optimismGoerliTokens = {

@@ -236,3 +257,3 @@ native: createNativeCurrency("Ether", "ETH", 18, 420),

// src/chains/sepolia.ts
// chains/sepolia.ts
var sepoliaTokens = {

@@ -296,17 +317,16 @@ native: createNativeCurrency("Ether", "ETH", 18, 11155111),

// src/generated.ts
var weth9ABI = [
// generated.ts
var weth9Abi = [
{ type: "fallback", stateMutability: "payable" },
{
constant: true,
payable: false,
stateMutability: "view",
type: "function",
inputs: [],
name: "name",
outputs: [{ name: "", type: "string" }]
inputs: [
{ name: "", type: "address" },
{ name: "", type: "address" }
],
name: "allowance",
outputs: [{ name: "", type: "uint256" }],
stateMutability: "view"
},
{
constant: false,
payable: false,
stateMutability: "nonpayable",
type: "function",

@@ -318,66 +338,48 @@ inputs: [

name: "approve",
outputs: [{ name: "", type: "bool" }]
outputs: [{ name: "", type: "bool" }],
stateMutability: "nonpayable"
},
{
constant: true,
payable: false,
stateMutability: "view",
type: "function",
inputs: [],
name: "totalSupply",
outputs: [{ name: "", type: "uint256" }]
inputs: [{ name: "", type: "address" }],
name: "balanceOf",
outputs: [{ name: "", type: "uint256" }],
stateMutability: "view"
},
{
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" }]
inputs: [],
name: "decimals",
outputs: [{ name: "", type: "uint8" }],
stateMutability: "view"
},
{
constant: false,
payable: false,
stateMutability: "nonpayable",
type: "function",
inputs: [{ name: "wad", type: "uint256" }],
name: "withdraw",
outputs: []
inputs: [],
name: "deposit",
outputs: [],
stateMutability: "payable"
},
{
constant: true,
payable: false,
stateMutability: "view",
type: "function",
inputs: [],
name: "decimals",
outputs: [{ name: "", type: "uint8" }]
name: "name",
outputs: [{ name: "", type: "string" }],
stateMutability: "view"
},
{
constant: true,
payable: false,
stateMutability: "view",
type: "function",
inputs: [{ name: "", type: "address" }],
name: "balanceOf",
outputs: [{ name: "", type: "uint256" }]
inputs: [],
name: "symbol",
outputs: [{ name: "", type: "string" }],
stateMutability: "view"
},
{
constant: true,
payable: false,
stateMutability: "view",
type: "function",
inputs: [],
name: "symbol",
outputs: [{ name: "", type: "string" }]
name: "totalSupply",
outputs: [{ name: "", type: "uint256" }],
stateMutability: "view"
},
{
constant: false,
payable: false,
stateMutability: "nonpayable",
type: "function",

@@ -389,26 +391,23 @@ inputs: [

name: "transfer",
outputs: [{ name: "", type: "bool" }]
outputs: [{ name: "", type: "bool" }],
stateMutability: "nonpayable"
},
{
constant: false,
payable: true,
stateMutability: "payable",
type: "function",
inputs: [],
name: "deposit",
outputs: []
inputs: [
{ name: "src", type: "address" },
{ name: "dst", type: "address" },
{ name: "wad", type: "uint256" }
],
name: "transferFrom",
outputs: [{ name: "", type: "bool" }],
stateMutability: "nonpayable"
},
{
constant: true,
payable: false,
stateMutability: "view",
type: "function",
inputs: [
{ name: "", type: "address" },
{ name: "", type: "address" }
],
name: "allowance",
outputs: [{ name: "", type: "uint256" }]
inputs: [{ name: "wad", type: "uint256" }],
name: "withdraw",
outputs: [],
stateMutability: "nonpayable"
},
{ payable: true, stateMutability: "payable", type: "fallback" },
{

@@ -428,7 +427,6 @@ type: "event",

inputs: [
{ name: "src", type: "address", indexed: true },
{ name: "dst", type: "address", indexed: true },
{ name: "wad", type: "uint256", indexed: false }
],
name: "Transfer"
name: "Deposit"
},

@@ -439,6 +437,7 @@ {

inputs: [
{ name: "src", type: "address", indexed: true },
{ name: "dst", type: "address", indexed: true },
{ name: "wad", type: "uint256", indexed: false }
],
name: "Deposit"
name: "Transfer"
},

@@ -455,83 +454,4 @@ {

];
var solmateErc1155ABI = [
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",

@@ -543,6 +463,6 @@ inputs: [

name: "balanceOf",
outputs: [{ name: "", internalType: "uint256", type: "uint256" }]
outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
stateMutability: "view"
},
{
stateMutability: "view",
type: "function",

@@ -556,6 +476,6 @@ inputs: [

{ name: "balances", internalType: "uint256[]", type: "uint256[]" }
]
],
stateMutability: "view"
},
{
stateMutability: "view",
type: "function",

@@ -567,6 +487,6 @@ inputs: [

name: "isApprovedForAll",
outputs: [{ name: "", internalType: "bool", type: "bool" }]
outputs: [{ name: "", internalType: "bool", type: "bool" }],
stateMutability: "view"
},
{
stateMutability: "nonpayable",
type: "function",

@@ -581,6 +501,6 @@ inputs: [

name: "safeBatchTransferFrom",
outputs: []
outputs: [],
stateMutability: "nonpayable"
},
{
stateMutability: "nonpayable",
type: "function",

@@ -595,6 +515,6 @@ inputs: [

name: "safeTransferFrom",
outputs: []
outputs: [],
stateMutability: "nonpayable"
},
{
stateMutability: "nonpayable",
type: "function",

@@ -606,20 +526,19 @@ inputs: [

name: "setApprovalForAll",
outputs: []
outputs: [],
stateMutability: "nonpayable"
},
{
stateMutability: "view",
type: "function",
inputs: [{ name: "interfaceId", internalType: "bytes4", type: "bytes4" }],
name: "supportsInterface",
outputs: [{ name: "", internalType: "bool", type: "bool" }]
outputs: [{ name: "", internalType: "bool", type: "bool" }],
stateMutability: "view"
},
{
stateMutability: "view",
type: "function",
inputs: [{ name: "id", internalType: "uint256", type: "uint256" }],
name: "uri",
outputs: [{ name: "", internalType: "string", type: "string" }]
}
];
var solmateErc20ABI = [
outputs: [{ name: "", internalType: "string", type: "string" }],
stateMutability: "view"
},
{

@@ -636,3 +555,3 @@ type: "event",

{
name: "spender",
name: "operator",
internalType: "address",

@@ -642,10 +561,32 @@ type: "address",

},
{ name: "approved", internalType: "bool", type: "bool", indexed: false }
],
name: "ApprovalForAll"
},
{
type: "event",
anonymous: false,
inputs: [
{
name: "amount",
internalType: "uint256",
type: "uint256",
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: "Approval"
name: "TransferBatch"
},

@@ -656,4 +597,11 @@ {

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 },
{

@@ -666,13 +614,23 @@ name: "amount",

],
name: "Transfer"
name: "TransferSingle"
},
{
stateMutability: "view",
type: "event",
anonymous: false,
inputs: [
{ name: "value", internalType: "string", type: "string", indexed: false },
{ name: "id", internalType: "uint256", type: "uint256", indexed: true }
],
name: "URI"
}
];
var solmateErc20Abi = [
{
type: "function",
inputs: [],
name: "DOMAIN_SEPARATOR",
outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }]
outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }],
stateMutability: "view"
},
{
stateMutability: "view",
type: "function",

@@ -684,6 +642,6 @@ inputs: [

name: "allowance",
outputs: [{ name: "", internalType: "uint256", type: "uint256" }]
outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
stateMutability: "view"
},
{
stateMutability: "nonpayable",
type: "function",

@@ -695,34 +653,34 @@ inputs: [

name: "approve",
outputs: [{ name: "", internalType: "bool", type: "bool" }]
outputs: [{ name: "", internalType: "bool", type: "bool" }],
stateMutability: "nonpayable"
},
{
stateMutability: "view",
type: "function",
inputs: [{ name: "", internalType: "address", type: "address" }],
name: "balanceOf",
outputs: [{ name: "", internalType: "uint256", type: "uint256" }]
outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
stateMutability: "view"
},
{
stateMutability: "view",
type: "function",
inputs: [],
name: "decimals",
outputs: [{ name: "", internalType: "uint8", type: "uint8" }]
outputs: [{ name: "", internalType: "uint8", type: "uint8" }],
stateMutability: "view"
},
{
stateMutability: "view",
type: "function",
inputs: [],
name: "name",
outputs: [{ name: "", internalType: "string", type: "string" }]
outputs: [{ name: "", internalType: "string", type: "string" }],
stateMutability: "view"
},
{
stateMutability: "view",
type: "function",
inputs: [{ name: "", internalType: "address", type: "address" }],
name: "nonces",
outputs: [{ name: "", internalType: "uint256", type: "uint256" }]
outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
stateMutability: "view"
},
{
stateMutability: "nonpayable",
type: "function",

@@ -739,20 +697,20 @@ inputs: [

name: "permit",
outputs: []
outputs: [],
stateMutability: "nonpayable"
},
{
stateMutability: "view",
type: "function",
inputs: [],
name: "symbol",
outputs: [{ name: "", internalType: "string", type: "string" }]
outputs: [{ name: "", internalType: "string", type: "string" }],
stateMutability: "view"
},
{
stateMutability: "view",
type: "function",
inputs: [],
name: "totalSupply",
outputs: [{ name: "", internalType: "uint256", type: "uint256" }]
outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
stateMutability: "view"
},
{
stateMutability: "nonpayable",
type: "function",

@@ -764,6 +722,6 @@ inputs: [

name: "transfer",
outputs: [{ name: "", internalType: "bool", type: "bool" }]
outputs: [{ name: "", internalType: "bool", type: "bool" }],
stateMutability: "nonpayable"
},
{
stateMutability: "nonpayable",
type: "function",

@@ -776,6 +734,5 @@ inputs: [

name: "transferFrom",
outputs: [{ name: "", internalType: "bool", type: "bool" }]
}
];
var solmateErc721ABI = [
outputs: [{ name: "", internalType: "bool", type: "bool" }],
stateMutability: "nonpayable"
},
{

@@ -797,3 +754,8 @@ type: "event",

},
{ name: "id", internalType: "uint256", type: "uint256", indexed: true }
{
name: "amount",
internalType: "uint256",
type: "uint256",
indexed: false
}
],

@@ -806,30 +768,16 @@ name: "Approval"

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: "amount",
internalType: "uint256",
type: "uint256",
indexed: false
}
],
name: "Transfer"
},
}
];
var solmateErc721Abi = [
{
stateMutability: "nonpayable",
type: "function",

@@ -841,20 +789,20 @@ inputs: [

name: "approve",
outputs: []
outputs: [],
stateMutability: "nonpayable"
},
{
stateMutability: "view",
type: "function",
inputs: [{ name: "owner", internalType: "address", type: "address" }],
name: "balanceOf",
outputs: [{ name: "", internalType: "uint256", type: "uint256" }]
outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
stateMutability: "view"
},
{
stateMutability: "view",
type: "function",
inputs: [{ name: "", internalType: "uint256", type: "uint256" }],
name: "getApproved",
outputs: [{ name: "", internalType: "address", type: "address" }]
outputs: [{ name: "", internalType: "address", type: "address" }],
stateMutability: "view"
},
{
stateMutability: "view",
type: "function",

@@ -866,20 +814,20 @@ inputs: [

name: "isApprovedForAll",
outputs: [{ name: "", internalType: "bool", type: "bool" }]
outputs: [{ name: "", internalType: "bool", type: "bool" }],
stateMutability: "view"
},
{
stateMutability: "view",
type: "function",
inputs: [],
name: "name",
outputs: [{ name: "", internalType: "string", type: "string" }]
outputs: [{ name: "", internalType: "string", type: "string" }],
stateMutability: "view"
},
{
stateMutability: "view",
type: "function",
inputs: [{ name: "id", internalType: "uint256", type: "uint256" }],
name: "ownerOf",
outputs: [{ name: "owner", internalType: "address", type: "address" }]
outputs: [{ name: "owner", internalType: "address", type: "address" }],
stateMutability: "view"
},
{
stateMutability: "nonpayable",
type: "function",

@@ -892,6 +840,6 @@ inputs: [

name: "safeTransferFrom",
outputs: []
outputs: [],
stateMutability: "nonpayable"
},
{
stateMutability: "nonpayable",
type: "function",

@@ -905,6 +853,6 @@ inputs: [

name: "safeTransferFrom",
outputs: []
outputs: [],
stateMutability: "nonpayable"
},
{
stateMutability: "nonpayable",
type: "function",

@@ -916,27 +864,27 @@ inputs: [

name: "setApprovalForAll",
outputs: []
outputs: [],
stateMutability: "nonpayable"
},
{
stateMutability: "view",
type: "function",
inputs: [{ name: "interfaceId", internalType: "bytes4", type: "bytes4" }],
name: "supportsInterface",
outputs: [{ name: "", internalType: "bool", type: "bool" }]
outputs: [{ name: "", internalType: "bool", type: "bool" }],
stateMutability: "view"
},
{
stateMutability: "view",
type: "function",
inputs: [],
name: "symbol",
outputs: [{ name: "", internalType: "string", type: "string" }]
outputs: [{ name: "", internalType: "string", type: "string" }],
stateMutability: "view"
},
{
stateMutability: "view",
type: "function",
inputs: [{ name: "id", internalType: "uint256", type: "uint256" }],
name: "tokenURI",
outputs: [{ name: "", internalType: "string", type: "string" }]
outputs: [{ name: "", internalType: "string", type: "string" }],
stateMutability: "view"
},
{
stateMutability: "nonpayable",
type: "function",

@@ -949,7 +897,58 @@ inputs: [

name: "transferFrom",
outputs: []
outputs: [],
stateMutability: "nonpayable"
},
{
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"
}
];
var getERC20Decimals = (client, { erc20, ...request }) => readContract(client, {
abi: solmateErc20ABI,
abi: solmateErc20Abi,
address: erc20.address,

@@ -960,3 +959,3 @@ functionName: "decimals",

var getERC20Name = (client, { erc20, ...request }) => readContract(client, {
abi: solmateErc20ABI,
abi: solmateErc20Abi,
address: erc20.address,

@@ -967,3 +966,3 @@ functionName: "name",

var getERC20Symbol = (client, { erc20, ...request }) => readContract(client, {
abi: solmateErc20ABI,
abi: solmateErc20Abi,
address: erc20.address,

@@ -974,3 +973,3 @@ functionName: "symbol",

// src/erc20/publicActions/getERC20.ts
// erc20/publicActions/getERC20.ts
var getERC20 = (client, { erc20, ...request }) => Promise.all([

@@ -991,3 +990,3 @@ getERC20Name(client, { erc20, ...request }),

var getERC20Allowance = (client, { erc20, owner, spender, ...request }) => readContract(client, {
abi: solmateErc20ABI,
abi: solmateErc20Abi,
address: erc20.address,

@@ -999,3 +998,3 @@ functionName: "allowance",

var getERC20BalanceOf = (client, { erc20, address, ...request }) => readContract(client, {
abi: solmateErc20ABI,
abi: solmateErc20Abi,
address: erc20.address,

@@ -1007,3 +1006,3 @@ functionName: "balanceOf",

var getERC20DomainSeparator = (client, { erc20, ...request }) => readContract(client, {
abi: solmateErc20ABI,
abi: solmateErc20Abi,
address: erc20.address,

@@ -1014,3 +1013,3 @@ functionName: "DOMAIN_SEPARATOR",

// src/erc20/publicActions/getERC20Permit.ts
// erc20/publicActions/getERC20Permit.ts
var getERC20Permit = (client, { erc20, ...request }) => Promise.all([

@@ -1033,3 +1032,3 @@ getERC20Name(client, { erc20, ...request }),

readContract(client, {
abi: solmateErc20ABI,
abi: solmateErc20Abi,
address: erc20.address,

@@ -1041,3 +1040,3 @@ functionName: "balanceOf",

readContract(client, {
abi: solmateErc20ABI,
abi: solmateErc20Abi,
address: erc20.address,

@@ -1052,3 +1051,3 @@ functionName: "nonces",

var getERC20PermitNonce = (client, { erc20, address, ...request }) => readContract(client, {
abi: solmateErc20ABI,
abi: solmateErc20Abi,
address: erc20.address,

@@ -1060,3 +1059,3 @@ functionName: "nonces",

var getERC20TotalSupply = (client, { erc20, ...request }) => readContract(client, {
abi: solmateErc20ABI,
abi: solmateErc20Abi,
address: erc20.address,

@@ -1067,3 +1066,3 @@ functionName: "totalSupply",

// src/erc20/publicActions/getIsERC20Permit.ts
// erc20/publicActions/getIsERC20Permit.ts
var getIsERC20Permit = (client, { erc20, ...request }) => Promise.all([

@@ -1107,3 +1106,3 @@ getERC20Permit(client, { erc20, ...request }),

address: amount.token.address,
abi: solmateErc20ABI,
abi: solmateErc20Abi,
functionName: "approve",

@@ -1122,3 +1121,3 @@ args: [spender, amount.amount],

address: permitData.token.address,
abi: solmateErc20ABI,
abi: solmateErc20Abi,
functionName: "permit",

@@ -1134,3 +1133,3 @@ args: [owner, spender, permitData.amount, deadline, v, r, s],

address: amount.token.address,
abi: solmateErc20ABI,
abi: solmateErc20Abi,
functionName: "transfer",

@@ -1145,3 +1144,3 @@ args: [to, amount.amount],

address: amount.token.address,
abi: solmateErc20ABI,
abi: solmateErc20Abi,
functionName: "transferFrom",

@@ -1166,3 +1165,3 @@ args: [from, to, amount.amount],

var getERC721Name = (client, { erc721, ...request }) => readContract(client, {
abi: solmateErc721ABI,
abi: solmateErc721Abi,
address: erc721.address,

@@ -1173,3 +1172,3 @@ functionName: "name",

var getERC721Symbol = (client, { erc721, ...request }) => readContract(client, {
abi: solmateErc721ABI,
abi: solmateErc721Abi,
address: erc721.address,

@@ -1180,3 +1179,3 @@ functionName: "symbol",

// src/erc721/publicActions/getERC721.ts
// erc721/publicActions/getERC721.ts
var getERC721 = (client, { erc721, ...request }) => Promise.all([

@@ -1195,3 +1194,3 @@ getERC721Name(client, { erc721, ...request }),

var getERC721Approved = (client, { erc721, id, ...request }) => readContract(client, {
abi: solmateErc721ABI,
abi: solmateErc721Abi,
address: erc721.address,

@@ -1203,3 +1202,3 @@ functionName: "getApproved",

var getERC721BalanceOf = (client, { erc721, address, ...request }) => readContract(client, {
abi: solmateErc721ABI,
abi: solmateErc721Abi,
address: erc721.address,

@@ -1211,3 +1210,3 @@ functionName: "balanceOf",

// src/erc721/publicActions/getERC721Data.ts
// erc721/publicActions/getERC721Data.ts
var getERC721Data = (client, { erc721, address, ...request }) => getERC721BalanceOf(client, { erc721, address, ...request }).then((data) => {

@@ -1219,3 +1218,3 @@ if (data > Number.MAX_SAFE_INTEGER)

var getERC721IsApprovedForAll = (client, { erc721, owner, spender, ...request }) => readContract(client, {
abi: solmateErc721ABI,
abi: solmateErc721Abi,
address: erc721.address,

@@ -1227,3 +1226,3 @@ functionName: "isApprovedForAll",

var getERC721OwnerOf = (client, { erc721, id, ...request }) => readContract(client, {
abi: solmateErc721ABI,
abi: solmateErc721Abi,
address: erc721.address,

@@ -1235,3 +1234,3 @@ functionName: "ownerOf",

var getERC721SupportsInterface = (client, { erc721, interfaceID, ...request }) => readContract(client, {
abi: solmateErc721ABI,
abi: solmateErc721Abi,
address: erc721.address,

@@ -1243,3 +1242,3 @@ functionName: "supportsInterface",

var getERC721TokenURI = (client, { erc721, id, ...request }) => readContract(client, {
abi: solmateErc721ABI,
abi: solmateErc721Abi,
address: erc721.address,

@@ -1255,3 +1254,3 @@ functionName: "tokenURI",

address: erc721.address,
abi: solmateErc721ABI,
abi: solmateErc721Abi,
functionName: "transferFrom",

@@ -1266,3 +1265,3 @@ args: [

address: erc721.address,
abi: solmateErc721ABI,
abi: solmateErc721Abi,
functionName: "safeTransferFrom",

@@ -1277,3 +1276,3 @@ args: [

address: erc721.address,
abi: solmateErc721ABI,
abi: solmateErc721Abi,
functionName: "safeTransferFrom",

@@ -1293,3 +1292,3 @@ args: [

address: erc721.address,
abi: solmateErc721ABI,
abi: solmateErc721Abi,
functionName: "approve",

@@ -1304,3 +1303,3 @@ args: [spender, id],

address: erc721.address,
abi: solmateErc721ABI,
abi: solmateErc721Abi,
functionName: "setApprovalForAll",

@@ -1324,3 +1323,3 @@ args: [spender, approved],

var getERC1155 = (client, { erc1155, ...request }) => readContract(client, {
abi: solmateErc1155ABI,
abi: solmateErc1155Abi,
address: erc1155.address,

@@ -1340,3 +1339,3 @@ functionName: "uri",

var getERC1155BalanceOf = (client, { erc1155, address, ...request }) => readContract(client, {
abi: solmateErc1155ABI,
abi: solmateErc1155Abi,
address: erc1155.address,

@@ -1348,3 +1347,3 @@ functionName: "balanceOf",

var getERC1155IsApprovedForAll = (client, { erc1155, owner, spender, ...request }) => readContract(client, {
abi: solmateErc1155ABI,
abi: solmateErc1155Abi,
address: erc1155.address,

@@ -1356,3 +1355,3 @@ functionName: "isApprovedForAll",

var getERC1155URI = (client, { erc1155, ...request }) => readContract(client, {
abi: solmateErc1155ABI,
abi: solmateErc1155Abi,
address: erc1155.address,

@@ -1368,3 +1367,3 @@ functionName: "uri",

address: erc1155Data.token.address,
abi: solmateErc1155ABI,
abi: solmateErc1155Abi,
functionName: "safeTransferFrom",

@@ -1387,6 +1386,5 @@ args: [

return getAddress$1(cur.token.address);
else if (addr !== getAddress$1(cur.token.address))
if (addr !== getAddress$1(cur.token.address))
throw Error("Tokens refering to different addresses");
else
return addr;
return addr;
}, void 0);

@@ -1397,3 +1395,3 @@ if (address === void 0)

address,
abi: solmateErc1155ABI,
abi: solmateErc1155Abi,
functionName: "safeBatchTransferFrom",

@@ -1415,3 +1413,3 @@ args: [

address: erc1155.address,
abi: solmateErc1155ABI,
abi: solmateErc1155Abi,
functionName: "setApprovalForAll",

@@ -1421,6 +1419,23 @@ args: [spender, approved],

});
// ../node_modules/.pnpm/tiny-invariant@1.3.3/node_modules/tiny-invariant/dist/esm/tiny-invariant.js
var isProduction = process.env.NODE_ENV === "production";
var prefix = "Invariant failed";
function invariant(condition, message) {
if (condition) {
return;
}
if (isProduction) {
throw new Error(prefix);
}
var provided = typeof message === "function" ? message() : message;
var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
throw new Error(value);
}
// fraction/utils.ts
var isFraction = (x) => typeof x === "object";
var createFraction = (numerator, denominator = 1) => {
const d = BigInt(denominator);
invariant3(d !== 0n, "Fraction: denominator equal to 0");
invariant(d !== 0n, "Fraction: denominator equal to 0");
return { type: "fraction", numerator: BigInt(numerator), denominator: d };

@@ -1431,3 +1446,3 @@ };

var fractionInvert = (fraction) => {
invariant3(fraction.numerator !== 0n, "Fraction: denominator equal to 0");
invariant(fraction.numerator !== 0n, "Fraction: denominator equal to 0");
return {

@@ -1486,2 +1501,4 @@ type: "fraction",

);
// price/utils.ts
var isPrice = (x) => typeof x === "object";

@@ -1517,3 +1534,3 @@ var createPriceFromFraction = (quote, base, price) => ({

if (isPrice(b))
invariant3(a.base === b.base && a.quote === b.quote);
invariant(a.base === b.base && a.quote === b.quote);
return isPrice(b) ? {

@@ -1532,3 +1549,3 @@ ...fractionAdd(rawPrice(a), rawPrice(b)),

if (isPrice(b))
invariant3(a.base === b.base && a.quote === b.quote);
invariant(a.base === b.base && a.quote === b.quote);
return isPrice(b) ? {

@@ -1547,3 +1564,3 @@ ...fractionSubtract(rawPrice(a), rawPrice(b)),

if (isPrice(b))
invariant3(a.base === b.base && a.quote === b.quote);
invariant(a.base === b.base && a.quote === b.quote);
return isPrice(b) ? {

@@ -1569,3 +1586,3 @@ type: "price",

if (isPrice(b))
invariant3(a.base === b.base && a.quote === b.quote);
invariant(a.base === b.base && a.quote === b.quote);
return isPrice(b) ? {

@@ -1591,3 +1608,3 @@ type: "price",

if (isPrice(b))
invariant3(a.base === b.base && a.quote === b.quote);
invariant(a.base === b.base && a.quote === b.quote);
return isPrice(b) ? fractionLessThan(rawPrice(a), rawPrice(b)) : fractionLessThan(adjustedPrice(a), b);

@@ -1597,3 +1614,3 @@ };

if (isPrice(b))
invariant3(a.base === b.base && a.quote === b.quote);
invariant(a.base === b.base && a.quote === b.quote);
return isPrice(b) ? fractionEqualTo(rawPrice(a), rawPrice(b)) : fractionEqualTo(adjustedPrice(a), b);

@@ -1603,7 +1620,7 @@ };

if (isPrice(b))
invariant3(a.base === b.base && a.quote === b.quote);
invariant(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);
invariant(price.base === amount.token);
return createAmountFromRaw(

@@ -1630,3 +1647,3 @@ price.quote,

address: amount.token.address,
abi: weth9ABI,
abi: weth9Abi,
functionName: "deposit",

@@ -1641,3 +1658,3 @@ value: amount.amount,

address: amount.token.address,
abi: weth9ABI,
abi: weth9Abi,
functionName: "withdraw",

@@ -1648,3 +1665,3 @@ args: [amount.amount],

// src/decorator/publicActions.ts
// decorator/publicActions.ts
var publicActionReverseMirage = (client) => ({

@@ -1692,3 +1709,3 @@ getNativeBalance: (args) => getNativeBalance(client, args),

// src/decorator/walletActions.ts
// decorator/walletActions.ts
var walletActionReverseMirage = (client) => ({

@@ -1698,4 +1715,4 @@ 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, solmateErc1155ABI as erc1155ABI, solmateErc20ABI as erc20ABI, solmateErc721ABI as erc721ABI, 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, 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, walletActionReverseMirage, weth9ABI };
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, solmateErc1155Abi as erc1155Abi, solmateErc20Abi as erc20Abi, solmateErc721Abi as erc721Abi, 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, 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, walletActionReverseMirage, weth9Abi };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.js.map
{
"name": "reverse-mirage",
"version": "1.0.3",
"version": "1.1.0",
"description": "Application level typescript utilities for Ethereum",

@@ -14,6 +14,6 @@ "type": "module",

"!dist/**/*.tsbuildinfo",
"src/**/*.ts",
"!src/**/*.test.ts",
"!src/**/*.bench.ts",
"!src/_test/**/*"
"**/*.ts",
"!**/*.test.ts",
"!**/*.bench.ts",
"!_test/**/*"
],

@@ -49,21 +49,10 @@ "keywords": [

},
"dependencies": {
"tiny-invariant": "^1.3.1"
},
"peerDependencies": {
"viem": ">=1"
"typescript": ">=5.0.4",
"viem": ">=2"
},
"devDependencies": {
"@biomejs/biome": "^1.2.2",
"@size-limit/preset-small-lib": "^9.0.0",
"@uniswap/sdk-core": "^4.0.7",
"@viem/anvil": "^0.0.6",
"@vitest/coverage-v8": "^0.34.6",
"bun": "^1.0.6",
"mitata": "^0.1.6",
"size-limit": "^9.0.0",
"tsup": "^7.2.0",
"typescript": "^5.2.2",
"viem": "^1.16.4",
"vitest": "^0.34.6"
"peerDependenciesMeta": {
"typescript": {
"optional": true
}
},

@@ -73,10 +62,6 @@ "packageManager": "pnpm@8.6.10",

"build": "tsup",
"format": "biome format . --write",
"lint": "biome check .",
"lint:fix": "pnpm lint --apply",
"typecheck": "tsc --noEmit",
"test": "vitest",
"test:ci": "CI=true vitest --coverage",
"test:cov": "vitest --coverage"
}
}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc