reverse-mirage
Advanced tools
Comparing version 0.1.0 to 0.1.1
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.erc20BalanceOf = exports.readAndParse = exports.adjustedPrice = exports.rawPrice = exports.priceQuote = exports.priceGreaterThan = exports.priceEqualTo = exports.priceLessThan = exports.priceDivide = exports.priceMultiply = exports.priceSubtract = exports.priceAdd = exports.priceInvert = exports.makePrice = exports.makePriceFromAmounts = exports.makePriceFromFraction = exports.isPrice = exports.fractionGreaterThan = exports.fractionEqualTo = exports.fractionLessThan = exports.fractionDivide = exports.fractionMultiply = exports.fractionSubtract = exports.fractionAdd = exports.fractionInvert = exports.fractionRemainder = exports.fractionQuotient = exports.makeFraction = exports.isFraction = exports.currencySortsBefore = exports.currencyEqualTo = exports.isNativeCurrency = exports.isToken = exports.currencyAmountGreaterThan = exports.currencyAmountEqualTo = exports.currencyAmountLessThan = exports.currencyAmountDivide = exports.currencyAmountMultiply = exports.currencyAmountSubtract = exports.currencyAmountAdd = exports.makeCurrencyAmountFromRaw = exports.makeCurrencyAmountFromFraction = exports.makeCurrencyAmountFromString = exports.isCurrencyAmount = exports.MaxUint8 = exports.MaxUint16 = exports.MaxUint32 = exports.MaxUint64 = exports.MaxUint128 = exports.MaxUint256 = void 0; | ||
exports.nativeTransfer = exports.nativeBalance = exports.erc20TransferFrom = exports.erc20Approve = exports.erc20Transfer = exports.erc20GetToken = exports.erc20Decimals = exports.erc20Symbol = exports.erc20Name = exports.erc20TotalSupply = exports.erc20Allowance = void 0; | ||
exports.nativeBalance = exports.erc20TransferFrom = exports.erc20Approve = exports.erc20Transfer = exports.erc20GetToken = exports.erc20Decimals = exports.erc20Symbol = exports.erc20Name = exports.erc20TotalSupply = exports.erc20Allowance = void 0; | ||
var constants_js_1 = require("./constants.js"); | ||
@@ -74,4 +74,2 @@ Object.defineProperty(exports, "MaxUint256", { enumerable: true, get: function () { return constants_js_1.MaxUint256; } }); | ||
Object.defineProperty(exports, "nativeBalance", { enumerable: true, get: function () { return reads_js_2.nativeBalance; } }); | ||
var writes_js_2 = require("./native/writes.js"); | ||
Object.defineProperty(exports, "nativeTransfer", { enumerable: true, get: function () { return writes_js_2.nativeTransfer; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -5,4 +5,4 @@ "use strict"; | ||
const erc20Abi_js_1 = require("./erc20Abi.js"); | ||
const erc20Transfer = (args) => { | ||
return { | ||
const erc20Transfer = async (publicClient, walletClient, account, args) => { | ||
const { request, result } = await publicClient.simulateContract({ | ||
address: args.amount.currency.address, | ||
@@ -12,7 +12,10 @@ abi: erc20Abi_js_1.erc20ABI, | ||
args: [args.to, args.amount.amount], | ||
}; | ||
account, | ||
}); | ||
const hash = await walletClient.writeContract(request); | ||
return { hash, result, request }; | ||
}; | ||
exports.erc20Transfer = erc20Transfer; | ||
const erc20Approve = (args) => { | ||
return { | ||
const erc20Approve = async (publicClient, walletClient, account, args) => { | ||
const { request, result } = await publicClient.simulateContract({ | ||
address: args.amount.currency.address, | ||
@@ -22,7 +25,10 @@ abi: erc20Abi_js_1.erc20ABI, | ||
args: [args.spender, args.amount.amount], | ||
}; | ||
account, | ||
}); | ||
const hash = await walletClient.writeContract(request); | ||
return { hash, result, request }; | ||
}; | ||
exports.erc20Approve = erc20Approve; | ||
const erc20TransferFrom = (args) => { | ||
return { | ||
const erc20TransferFrom = async (publicClient, walletClient, account, args) => { | ||
const { request, result } = await publicClient.simulateContract({ | ||
address: args.amount.currency.address, | ||
@@ -32,5 +38,8 @@ abi: erc20Abi_js_1.erc20ABI, | ||
args: [args.to, args.from, args.amount.amount], | ||
}; | ||
account, | ||
}); | ||
const hash = await walletClient.writeContract(request); | ||
return { hash, result, request }; | ||
}; | ||
exports.erc20TransferFrom = erc20TransferFrom; | ||
//# sourceMappingURL=writes.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.erc20BalanceOf = exports.readAndParse = exports.adjustedPrice = exports.rawPrice = exports.priceQuote = exports.priceGreaterThan = exports.priceEqualTo = exports.priceLessThan = exports.priceDivide = exports.priceMultiply = exports.priceSubtract = exports.priceAdd = exports.priceInvert = exports.makePrice = exports.makePriceFromAmounts = exports.makePriceFromFraction = exports.isPrice = exports.fractionGreaterThan = exports.fractionEqualTo = exports.fractionLessThan = exports.fractionDivide = exports.fractionMultiply = exports.fractionSubtract = exports.fractionAdd = exports.fractionInvert = exports.fractionRemainder = exports.fractionQuotient = exports.makeFraction = exports.isFraction = exports.currencySortsBefore = exports.currencyEqualTo = exports.isNativeCurrency = exports.isToken = exports.currencyAmountGreaterThan = exports.currencyAmountEqualTo = exports.currencyAmountLessThan = exports.currencyAmountDivide = exports.currencyAmountMultiply = exports.currencyAmountSubtract = exports.currencyAmountAdd = exports.makeCurrencyAmountFromRaw = exports.makeCurrencyAmountFromFraction = exports.makeCurrencyAmountFromString = exports.isCurrencyAmount = exports.MaxUint8 = exports.MaxUint16 = exports.MaxUint32 = exports.MaxUint64 = exports.MaxUint128 = exports.MaxUint256 = void 0; | ||
exports.nativeTransfer = exports.nativeBalance = exports.erc20TransferFrom = exports.erc20Approve = exports.erc20Transfer = exports.erc20GetToken = exports.erc20Decimals = exports.erc20Symbol = exports.erc20Name = exports.erc20TotalSupply = exports.erc20Allowance = void 0; | ||
exports.nativeBalance = exports.erc20TransferFrom = exports.erc20Approve = exports.erc20Transfer = exports.erc20GetToken = exports.erc20Decimals = exports.erc20Symbol = exports.erc20Name = exports.erc20TotalSupply = exports.erc20Allowance = void 0; | ||
var constants_js_1 = require("./constants.js"); | ||
@@ -74,4 +74,2 @@ Object.defineProperty(exports, "MaxUint256", { enumerable: true, get: function () { return constants_js_1.MaxUint256; } }); | ||
Object.defineProperty(exports, "nativeBalance", { enumerable: true, get: function () { return reads_js_2.nativeBalance; } }); | ||
var writes_js_2 = require("./native/writes.js"); | ||
Object.defineProperty(exports, "nativeTransfer", { enumerable: true, get: function () { return writes_js_2.nativeTransfer; } }); | ||
//# sourceMappingURL=index.js.map |
import { erc20ABI } from "./erc20Abi.js"; | ||
export const erc20Transfer = (args) => { | ||
return { | ||
export const erc20Transfer = async (publicClient, walletClient, account, args) => { | ||
const { request, result } = await publicClient.simulateContract({ | ||
address: args.amount.currency.address, | ||
@@ -8,6 +8,9 @@ abi: erc20ABI, | ||
args: [args.to, args.amount.amount], | ||
}; | ||
account, | ||
}); | ||
const hash = await walletClient.writeContract(request); | ||
return { hash, result, request }; | ||
}; | ||
export const erc20Approve = (args) => { | ||
return { | ||
export const erc20Approve = async (publicClient, walletClient, account, args) => { | ||
const { request, result } = await publicClient.simulateContract({ | ||
address: args.amount.currency.address, | ||
@@ -17,6 +20,9 @@ abi: erc20ABI, | ||
args: [args.spender, args.amount.amount], | ||
}; | ||
account, | ||
}); | ||
const hash = await walletClient.writeContract(request); | ||
return { hash, result, request }; | ||
}; | ||
export const erc20TransferFrom = (args) => { | ||
return { | ||
export const erc20TransferFrom = async (publicClient, walletClient, account, args) => { | ||
const { request, result } = await publicClient.simulateContract({ | ||
address: args.amount.currency.address, | ||
@@ -26,4 +32,7 @@ abi: erc20ABI, | ||
args: [args.to, args.from, args.amount.amount], | ||
}; | ||
account, | ||
}); | ||
const hash = await walletClient.writeContract(request); | ||
return { hash, result, request }; | ||
}; | ||
//# sourceMappingURL=writes.js.map |
@@ -10,3 +10,2 @@ export { MaxUint256, MaxUint128, MaxUint64, MaxUint32, MaxUint16, MaxUint8, } from "./constants.js"; | ||
export { nativeBalance } from "./native/reads.js"; | ||
export { nativeTransfer } from "./native/writes.js"; | ||
//# sourceMappingURL=index.js.map |
@@ -1,460 +0,18 @@ | ||
import type { CurrencyAmount, Token } from "../types.js"; | ||
import type { CurrencyAmount, ReverseMirageWrite, Token } from "../types.js"; | ||
import { erc20ABI } from "./erc20Abi.js"; | ||
import type { Account, PublicClient, WalletClient } from "viem"; | ||
import type { Address } from "viem/accounts"; | ||
export declare const erc20Transfer: (args: { | ||
export declare const erc20Transfer: (publicClient: PublicClient, walletClient: WalletClient, account: Account | Address, args: { | ||
to: Address; | ||
amount: CurrencyAmount<Token>; | ||
}) => { | ||
address: `0x${string}`; | ||
abi: readonly [{ | ||
readonly type: "event"; | ||
readonly name: "Approval"; | ||
readonly inputs: readonly [{ | ||
readonly indexed: true; | ||
readonly name: "owner"; | ||
readonly type: "address"; | ||
}, { | ||
readonly indexed: true; | ||
readonly name: "spender"; | ||
readonly type: "address"; | ||
}, { | ||
readonly indexed: false; | ||
readonly name: "value"; | ||
readonly type: "uint256"; | ||
}]; | ||
}, { | ||
readonly type: "event"; | ||
readonly name: "Transfer"; | ||
readonly inputs: readonly [{ | ||
readonly indexed: true; | ||
readonly name: "from"; | ||
readonly type: "address"; | ||
}, { | ||
readonly indexed: true; | ||
readonly name: "to"; | ||
readonly type: "address"; | ||
}, { | ||
readonly indexed: false; | ||
readonly name: "value"; | ||
readonly type: "uint256"; | ||
}]; | ||
}, { | ||
readonly type: "function"; | ||
readonly name: "allowance"; | ||
readonly stateMutability: "view"; | ||
readonly inputs: readonly [{ | ||
readonly name: "owner"; | ||
readonly type: "address"; | ||
}, { | ||
readonly name: "spender"; | ||
readonly type: "address"; | ||
}]; | ||
readonly outputs: readonly [{ | ||
readonly name: ""; | ||
readonly type: "uint256"; | ||
}]; | ||
}, { | ||
readonly type: "function"; | ||
readonly name: "approve"; | ||
readonly stateMutability: "nonpayable"; | ||
readonly inputs: readonly [{ | ||
readonly name: "spender"; | ||
readonly type: "address"; | ||
}, { | ||
readonly name: "amount"; | ||
readonly type: "uint256"; | ||
}]; | ||
readonly outputs: readonly [{ | ||
readonly name: ""; | ||
readonly type: "bool"; | ||
}]; | ||
}, { | ||
readonly type: "function"; | ||
readonly name: "balanceOf"; | ||
readonly stateMutability: "view"; | ||
readonly inputs: readonly [{ | ||
readonly name: "account"; | ||
readonly type: "address"; | ||
}]; | ||
readonly outputs: readonly [{ | ||
readonly name: ""; | ||
readonly type: "uint256"; | ||
}]; | ||
}, { | ||
readonly type: "function"; | ||
readonly name: "decimals"; | ||
readonly stateMutability: "view"; | ||
readonly inputs: readonly []; | ||
readonly outputs: readonly [{ | ||
readonly name: ""; | ||
readonly type: "uint8"; | ||
}]; | ||
}, { | ||
readonly type: "function"; | ||
readonly name: "name"; | ||
readonly stateMutability: "view"; | ||
readonly inputs: readonly []; | ||
readonly outputs: readonly [{ | ||
readonly name: ""; | ||
readonly type: "string"; | ||
}]; | ||
}, { | ||
readonly type: "function"; | ||
readonly name: "symbol"; | ||
readonly stateMutability: "view"; | ||
readonly inputs: readonly []; | ||
readonly outputs: readonly [{ | ||
readonly name: ""; | ||
readonly type: "string"; | ||
}]; | ||
}, { | ||
readonly type: "function"; | ||
readonly name: "totalSupply"; | ||
readonly stateMutability: "view"; | ||
readonly inputs: readonly []; | ||
readonly outputs: readonly [{ | ||
readonly name: ""; | ||
readonly type: "uint256"; | ||
}]; | ||
}, { | ||
readonly type: "function"; | ||
readonly name: "transfer"; | ||
readonly stateMutability: "nonpayable"; | ||
readonly inputs: readonly [{ | ||
readonly name: "recipient"; | ||
readonly type: "address"; | ||
}, { | ||
readonly name: "amount"; | ||
readonly type: "uint256"; | ||
}]; | ||
readonly outputs: readonly [{ | ||
readonly name: ""; | ||
readonly type: "bool"; | ||
}]; | ||
}, { | ||
readonly type: "function"; | ||
readonly name: "transferFrom"; | ||
readonly stateMutability: "nonpayable"; | ||
readonly inputs: readonly [{ | ||
readonly name: "sender"; | ||
readonly type: "address"; | ||
}, { | ||
readonly name: "recipient"; | ||
readonly type: "address"; | ||
}, { | ||
readonly name: "amount"; | ||
readonly type: "uint256"; | ||
}]; | ||
readonly outputs: readonly [{ | ||
readonly name: ""; | ||
readonly type: "bool"; | ||
}]; | ||
}]; | ||
functionName: "transfer"; | ||
args: [`0x${string}`, bigint]; | ||
}; | ||
export declare const erc20Approve: (args: { | ||
}) => Promise<ReverseMirageWrite<typeof erc20ABI, "transfer">>; | ||
export declare const erc20Approve: (publicClient: PublicClient, walletClient: WalletClient, account: Account | Address, args: { | ||
spender: Address; | ||
amount: CurrencyAmount<Token>; | ||
}) => { | ||
address: `0x${string}`; | ||
abi: readonly [{ | ||
readonly type: "event"; | ||
readonly name: "Approval"; | ||
readonly inputs: readonly [{ | ||
readonly indexed: true; | ||
readonly name: "owner"; | ||
readonly type: "address"; | ||
}, { | ||
readonly indexed: true; | ||
readonly name: "spender"; | ||
readonly type: "address"; | ||
}, { | ||
readonly indexed: false; | ||
readonly name: "value"; | ||
readonly type: "uint256"; | ||
}]; | ||
}, { | ||
readonly type: "event"; | ||
readonly name: "Transfer"; | ||
readonly inputs: readonly [{ | ||
readonly indexed: true; | ||
readonly name: "from"; | ||
readonly type: "address"; | ||
}, { | ||
readonly indexed: true; | ||
readonly name: "to"; | ||
readonly type: "address"; | ||
}, { | ||
readonly indexed: false; | ||
readonly name: "value"; | ||
readonly type: "uint256"; | ||
}]; | ||
}, { | ||
readonly type: "function"; | ||
readonly name: "allowance"; | ||
readonly stateMutability: "view"; | ||
readonly inputs: readonly [{ | ||
readonly name: "owner"; | ||
readonly type: "address"; | ||
}, { | ||
readonly name: "spender"; | ||
readonly type: "address"; | ||
}]; | ||
readonly outputs: readonly [{ | ||
readonly name: ""; | ||
readonly type: "uint256"; | ||
}]; | ||
}, { | ||
readonly type: "function"; | ||
readonly name: "approve"; | ||
readonly stateMutability: "nonpayable"; | ||
readonly inputs: readonly [{ | ||
readonly name: "spender"; | ||
readonly type: "address"; | ||
}, { | ||
readonly name: "amount"; | ||
readonly type: "uint256"; | ||
}]; | ||
readonly outputs: readonly [{ | ||
readonly name: ""; | ||
readonly type: "bool"; | ||
}]; | ||
}, { | ||
readonly type: "function"; | ||
readonly name: "balanceOf"; | ||
readonly stateMutability: "view"; | ||
readonly inputs: readonly [{ | ||
readonly name: "account"; | ||
readonly type: "address"; | ||
}]; | ||
readonly outputs: readonly [{ | ||
readonly name: ""; | ||
readonly type: "uint256"; | ||
}]; | ||
}, { | ||
readonly type: "function"; | ||
readonly name: "decimals"; | ||
readonly stateMutability: "view"; | ||
readonly inputs: readonly []; | ||
readonly outputs: readonly [{ | ||
readonly name: ""; | ||
readonly type: "uint8"; | ||
}]; | ||
}, { | ||
readonly type: "function"; | ||
readonly name: "name"; | ||
readonly stateMutability: "view"; | ||
readonly inputs: readonly []; | ||
readonly outputs: readonly [{ | ||
readonly name: ""; | ||
readonly type: "string"; | ||
}]; | ||
}, { | ||
readonly type: "function"; | ||
readonly name: "symbol"; | ||
readonly stateMutability: "view"; | ||
readonly inputs: readonly []; | ||
readonly outputs: readonly [{ | ||
readonly name: ""; | ||
readonly type: "string"; | ||
}]; | ||
}, { | ||
readonly type: "function"; | ||
readonly name: "totalSupply"; | ||
readonly stateMutability: "view"; | ||
readonly inputs: readonly []; | ||
readonly outputs: readonly [{ | ||
readonly name: ""; | ||
readonly type: "uint256"; | ||
}]; | ||
}, { | ||
readonly type: "function"; | ||
readonly name: "transfer"; | ||
readonly stateMutability: "nonpayable"; | ||
readonly inputs: readonly [{ | ||
readonly name: "recipient"; | ||
readonly type: "address"; | ||
}, { | ||
readonly name: "amount"; | ||
readonly type: "uint256"; | ||
}]; | ||
readonly outputs: readonly [{ | ||
readonly name: ""; | ||
readonly type: "bool"; | ||
}]; | ||
}, { | ||
readonly type: "function"; | ||
readonly name: "transferFrom"; | ||
readonly stateMutability: "nonpayable"; | ||
readonly inputs: readonly [{ | ||
readonly name: "sender"; | ||
readonly type: "address"; | ||
}, { | ||
readonly name: "recipient"; | ||
readonly type: "address"; | ||
}, { | ||
readonly name: "amount"; | ||
readonly type: "uint256"; | ||
}]; | ||
readonly outputs: readonly [{ | ||
readonly name: ""; | ||
readonly type: "bool"; | ||
}]; | ||
}]; | ||
functionName: "approve"; | ||
args: [`0x${string}`, bigint]; | ||
}; | ||
export declare const erc20TransferFrom: (args: { | ||
}) => Promise<ReverseMirageWrite<typeof erc20ABI, "approve">>; | ||
export declare const erc20TransferFrom: (publicClient: PublicClient, walletClient: WalletClient, account: Account | Address, args: { | ||
from: Address; | ||
to: Address; | ||
amount: CurrencyAmount<Token>; | ||
}) => { | ||
address: `0x${string}`; | ||
abi: readonly [{ | ||
readonly type: "event"; | ||
readonly name: "Approval"; | ||
readonly inputs: readonly [{ | ||
readonly indexed: true; | ||
readonly name: "owner"; | ||
readonly type: "address"; | ||
}, { | ||
readonly indexed: true; | ||
readonly name: "spender"; | ||
readonly type: "address"; | ||
}, { | ||
readonly indexed: false; | ||
readonly name: "value"; | ||
readonly type: "uint256"; | ||
}]; | ||
}, { | ||
readonly type: "event"; | ||
readonly name: "Transfer"; | ||
readonly inputs: readonly [{ | ||
readonly indexed: true; | ||
readonly name: "from"; | ||
readonly type: "address"; | ||
}, { | ||
readonly indexed: true; | ||
readonly name: "to"; | ||
readonly type: "address"; | ||
}, { | ||
readonly indexed: false; | ||
readonly name: "value"; | ||
readonly type: "uint256"; | ||
}]; | ||
}, { | ||
readonly type: "function"; | ||
readonly name: "allowance"; | ||
readonly stateMutability: "view"; | ||
readonly inputs: readonly [{ | ||
readonly name: "owner"; | ||
readonly type: "address"; | ||
}, { | ||
readonly name: "spender"; | ||
readonly type: "address"; | ||
}]; | ||
readonly outputs: readonly [{ | ||
readonly name: ""; | ||
readonly type: "uint256"; | ||
}]; | ||
}, { | ||
readonly type: "function"; | ||
readonly name: "approve"; | ||
readonly stateMutability: "nonpayable"; | ||
readonly inputs: readonly [{ | ||
readonly name: "spender"; | ||
readonly type: "address"; | ||
}, { | ||
readonly name: "amount"; | ||
readonly type: "uint256"; | ||
}]; | ||
readonly outputs: readonly [{ | ||
readonly name: ""; | ||
readonly type: "bool"; | ||
}]; | ||
}, { | ||
readonly type: "function"; | ||
readonly name: "balanceOf"; | ||
readonly stateMutability: "view"; | ||
readonly inputs: readonly [{ | ||
readonly name: "account"; | ||
readonly type: "address"; | ||
}]; | ||
readonly outputs: readonly [{ | ||
readonly name: ""; | ||
readonly type: "uint256"; | ||
}]; | ||
}, { | ||
readonly type: "function"; | ||
readonly name: "decimals"; | ||
readonly stateMutability: "view"; | ||
readonly inputs: readonly []; | ||
readonly outputs: readonly [{ | ||
readonly name: ""; | ||
readonly type: "uint8"; | ||
}]; | ||
}, { | ||
readonly type: "function"; | ||
readonly name: "name"; | ||
readonly stateMutability: "view"; | ||
readonly inputs: readonly []; | ||
readonly outputs: readonly [{ | ||
readonly name: ""; | ||
readonly type: "string"; | ||
}]; | ||
}, { | ||
readonly type: "function"; | ||
readonly name: "symbol"; | ||
readonly stateMutability: "view"; | ||
readonly inputs: readonly []; | ||
readonly outputs: readonly [{ | ||
readonly name: ""; | ||
readonly type: "string"; | ||
}]; | ||
}, { | ||
readonly type: "function"; | ||
readonly name: "totalSupply"; | ||
readonly stateMutability: "view"; | ||
readonly inputs: readonly []; | ||
readonly outputs: readonly [{ | ||
readonly name: ""; | ||
readonly type: "uint256"; | ||
}]; | ||
}, { | ||
readonly type: "function"; | ||
readonly name: "transfer"; | ||
readonly stateMutability: "nonpayable"; | ||
readonly inputs: readonly [{ | ||
readonly name: "recipient"; | ||
readonly type: "address"; | ||
}, { | ||
readonly name: "amount"; | ||
readonly type: "uint256"; | ||
}]; | ||
readonly outputs: readonly [{ | ||
readonly name: ""; | ||
readonly type: "bool"; | ||
}]; | ||
}, { | ||
readonly type: "function"; | ||
readonly name: "transferFrom"; | ||
readonly stateMutability: "nonpayable"; | ||
readonly inputs: readonly [{ | ||
readonly name: "sender"; | ||
readonly type: "address"; | ||
}, { | ||
readonly name: "recipient"; | ||
readonly type: "address"; | ||
}, { | ||
readonly name: "amount"; | ||
readonly type: "uint256"; | ||
}]; | ||
readonly outputs: readonly [{ | ||
readonly name: ""; | ||
readonly type: "bool"; | ||
}]; | ||
}]; | ||
functionName: "transferFrom"; | ||
args: [`0x${string}`, `0x${string}`, bigint]; | ||
}; | ||
}) => Promise<ReverseMirageWrite<typeof erc20ABI, "transferFrom">>; | ||
//# sourceMappingURL=writes.d.ts.map |
@@ -10,4 +10,3 @@ export { MaxUint256, MaxUint128, MaxUint64, MaxUint32, MaxUint16, MaxUint8, } from "./constants.js"; | ||
export { nativeBalance } from "./native/reads.js"; | ||
export { nativeTransfer } from "./native/writes.js"; | ||
export type { Fraction, BigIntIsh, NativeCurrency, Token, Currency, CurrencyAmount, Price, ReverseMirageRead, } from "./types.js"; | ||
export type { Fraction, BigIntIsh, NativeCurrency, Token, Currency, CurrencyAmount, Price, ReverseMirageRead, ReverseMirageWrite, } from "./types.js"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,2 +0,2 @@ | ||
import type { Address } from "viem"; | ||
import type { Abi, Address, Hash, SimulateContractReturnType } from "viem"; | ||
export type Fraction = { | ||
@@ -34,2 +34,7 @@ type: "fraction"; | ||
}; | ||
export type ReverseMirageWrite<TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = string> = Promise<{ | ||
hash: Hash; | ||
request: SimulateContractReturnType<TAbi, TFunctionName>["request"]; | ||
result: SimulateContractReturnType<TAbi, TFunctionName>["result"]; | ||
}>; | ||
//# sourceMappingURL=types.d.ts.map |
{ | ||
"name": "reverse-mirage", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "", | ||
@@ -29,5 +29,7 @@ "type": "module", | ||
"dependencies": { | ||
"tiny-invariant": "^1.3.1", | ||
"viem": "^1.3.0" | ||
"tiny-invariant": "^1.3.1" | ||
}, | ||
"peerDependencies": { | ||
"viem": ">=0.3.35" | ||
}, | ||
"devDependencies": { | ||
@@ -34,0 +36,0 @@ "@uniswap/sdk-core": "^4.0.3", |
@@ -1,11 +0,16 @@ | ||
import type { CurrencyAmount, Token } from "../types.js"; | ||
import type { CurrencyAmount, ReverseMirageWrite, Token } from "../types.js"; | ||
import { erc20ABI } from "./erc20Abi.js"; | ||
import type { Account, PublicClient, WalletClient } from "viem"; | ||
import type { Address } from "viem/accounts"; | ||
import type { SimulateContractParameters } from "viem/actions"; | ||
export const erc20Transfer = (args: { | ||
to: Address; | ||
amount: CurrencyAmount<Token>; | ||
}) => { | ||
return { | ||
export const erc20Transfer = async ( | ||
publicClient: PublicClient, | ||
walletClient: WalletClient, | ||
account: Account | Address, | ||
args: { | ||
to: Address; | ||
amount: CurrencyAmount<Token>; | ||
}, | ||
): Promise<ReverseMirageWrite<typeof erc20ABI, "transfer">> => { | ||
const { request, result } = await publicClient.simulateContract({ | ||
address: args.amount.currency.address, | ||
@@ -15,10 +20,18 @@ abi: erc20ABI, | ||
args: [args.to, args.amount.amount], | ||
} satisfies SimulateContractParameters<typeof erc20ABI, "transfer">; | ||
account, | ||
}); | ||
const hash = await walletClient.writeContract(request); | ||
return { hash, result, request }; | ||
}; | ||
export const erc20Approve = (args: { | ||
spender: Address; | ||
amount: CurrencyAmount<Token>; | ||
}) => { | ||
return { | ||
export const erc20Approve = async ( | ||
publicClient: PublicClient, | ||
walletClient: WalletClient, | ||
account: Account | Address, | ||
args: { | ||
spender: Address; | ||
amount: CurrencyAmount<Token>; | ||
}, | ||
): Promise<ReverseMirageWrite<typeof erc20ABI, "approve">> => { | ||
const { request, result } = await publicClient.simulateContract({ | ||
address: args.amount.currency.address, | ||
@@ -28,11 +41,19 @@ abi: erc20ABI, | ||
args: [args.spender, args.amount.amount], | ||
} satisfies SimulateContractParameters<typeof erc20ABI, "approve">; | ||
account, | ||
}); | ||
const hash = await walletClient.writeContract(request); | ||
return { hash, result, request }; | ||
}; | ||
export const erc20TransferFrom = (args: { | ||
from: Address; | ||
to: Address; | ||
amount: CurrencyAmount<Token>; | ||
}) => { | ||
return { | ||
export const erc20TransferFrom = async ( | ||
publicClient: PublicClient, | ||
walletClient: WalletClient, | ||
account: Account | Address, | ||
args: { | ||
from: Address; | ||
to: Address; | ||
amount: CurrencyAmount<Token>; | ||
}, | ||
): Promise<ReverseMirageWrite<typeof erc20ABI, "transferFrom">> => { | ||
const { request, result } = await publicClient.simulateContract({ | ||
address: args.amount.currency.address, | ||
@@ -42,3 +63,6 @@ abi: erc20ABI, | ||
args: [args.to, args.from, args.amount.amount], | ||
} satisfies SimulateContractParameters<typeof erc20ABI, "transferFrom">; | ||
account, | ||
}); | ||
const hash = await walletClient.writeContract(request); | ||
return { hash, result, request }; | ||
}; |
@@ -84,4 +84,2 @@ export { | ||
export { nativeTransfer } from "./native/writes.js"; | ||
export type { | ||
@@ -96,2 +94,3 @@ Fraction, | ||
ReverseMirageRead, | ||
ReverseMirageWrite, | ||
} from "./types.js"; |
@@ -1,2 +0,2 @@ | ||
import type { Address } from "viem"; | ||
import type { Abi, Address, Hash, SimulateContractReturnType } from "viem"; | ||
@@ -45,1 +45,10 @@ export type Fraction = { | ||
}; | ||
export type ReverseMirageWrite< | ||
TAbi extends Abi | readonly unknown[] = Abi, | ||
TFunctionName extends string = string, | ||
> = Promise<{ | ||
hash: Hash; | ||
request: SimulateContractReturnType<TAbi, TFunctionName>["request"]; | ||
result: SimulateContractReturnType<TAbi, TFunctionName>["result"]; | ||
}>; |
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 not supported yet
Sorry, the diff of this file is not supported yet
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
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
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
1
11
232865
4410
+ Added@adraffy/ens-normalize@1.11.0(transitive)
+ Added@noble/curves@1.6.0(transitive)
+ Added@noble/hashes@1.5.0(transitive)
+ Added@scure/bip32@1.5.0(transitive)
+ Added@scure/bip39@1.4.0(transitive)
+ Addedabitype@1.0.6(transitive)
+ Addedeventemitter3@5.0.1(transitive)
+ Addedisows@1.0.6(transitive)
+ Addedox@0.1.0(transitive)
+ Addedviem@2.21.43(transitive)
+ Addedwebauthn-p256@0.0.10(transitive)
+ Addedws@8.18.0(transitive)
- Removedviem@^1.3.0
- Removed@adraffy/ens-normalize@1.10.0(transitive)
- Removed@noble/curves@1.2.0(transitive)
- Removed@noble/hashes@1.3.2(transitive)
- Removed@scure/bip32@1.3.2(transitive)
- Removed@scure/bip39@1.2.1(transitive)
- Removedabitype@0.9.8(transitive)
- Removedisows@1.0.3(transitive)
- Removedviem@1.21.4(transitive)
- Removedws@8.13.0(transitive)