From 88a51b06670e188deae36a2c8339cd7f7342f86a Mon Sep 17 00:00:00 2001 From: Kyle Scott Date: Fri, 22 Sep 2023 12:29:09 -0400 Subject: [PATCH] pass full request to reads --- .../src/erc1155/publicActions/getERC1155.ts | 28 ++++++++------- .../publicActions/getERC1155BalanceOf.ts | 16 +++++---- .../getERC1155IsApprovedForAll.ts | 12 ++++--- .../erc1155/publicActions/getERC1155URI.ts | 12 ++++--- .../core/src/erc20/publicActions/getERC20.ts | 26 +++++++------- .../erc20/publicActions/getERC20Allowance.ts | 16 +++++---- .../erc20/publicActions/getERC20BalanceOf.ts | 16 +++++---- .../erc20/publicActions/getERC20Decimals.ts | 8 +++-- .../publicActions/getERC20DomainSeparator.ts | 8 +++-- .../src/erc20/publicActions/getERC20Name.ts | 8 +++-- .../src/erc20/publicActions/getERC20Permit.ts | 30 ++++++++-------- .../erc20/publicActions/getERC20PermitData.ts | 26 ++++++++------ .../publicActions/getERC20PermitNonce.ts | 12 ++++--- .../src/erc20/publicActions/getERC20Symbol.ts | 8 +++-- .../publicActions/getERC20TotalSupply.ts | 12 ++++--- .../erc20/publicActions/getIsERC20Permit.ts | 34 +++++++++++-------- .../erc20/walletActions/signERC20Permit.ts | 2 ++ .../src/erc721/publicActions/getERC721.ts | 22 ++++++------ .../erc721/publicActions/getERC721Approved.ts | 12 ++++--- .../publicActions/getERC721BalanceOf.ts | 12 ++++--- .../src/erc721/publicActions/getERC721Data.ts | 23 ++++++++----- .../getERC721IsApprovedForAll.ts | 12 ++++--- .../src/erc721/publicActions/getERC721Name.ts | 8 +++-- .../erc721/publicActions/getERC721OwnerOf.ts | 12 ++++--- .../getERC721SupportsInterface.ts | 12 ++++--- .../erc721/publicActions/getERC721Symbol.ts | 8 +++-- .../erc721/publicActions/getERC721TokenURI.ts | 12 ++++--- .../native/publicActions/getNativeBalance.ts | 14 +++++--- 28 files changed, 242 insertions(+), 179 deletions(-) diff --git a/packages/core/src/erc1155/publicActions/getERC1155.ts b/packages/core/src/erc1155/publicActions/getERC1155.ts index 2ff4b85..1dfdcbf 100644 --- a/packages/core/src/erc1155/publicActions/getERC1155.ts +++ b/packages/core/src/erc1155/publicActions/getERC1155.ts @@ -20,38 +20,40 @@ export const getERC1155 = < T extends "select" | undefined, >( client: Client, - args: GetERC1155Parameters, + { erc1155, ...request }: GetERC1155Parameters, type?: T, ): ReverseMirage => (type === undefined ? readContract(client, { abi: solmateERC1155ABI, - address: args.erc1155.address, + address: erc1155.address, functionName: "uri", - args: [args.erc1155.id], + args: [erc1155.id], + ...request, }).then((data) => createERC1155( - args.erc1155.address, - args.erc1155.id, + erc1155.address, + erc1155.id, data, - args.erc1155.chainID, - args.blockNumber, + erc1155.chainID, + erc1155.blockCreated, ), ) : { read: () => readContract(client, { abi: solmateERC1155ABI, - address: args.erc1155.address, + address: erc1155.address, functionName: "uri", - args: [args.erc1155.id], + args: [erc1155.id], + ...request, }), parse: (data) => createERC1155( - args.erc1155.address, - args.erc1155.id, + erc1155.address, + erc1155.id, data, - args.erc1155.chainID, - args.blockNumber, + erc1155.chainID, + erc1155.blockCreated, ), }) as ReverseMirage; diff --git a/packages/core/src/erc1155/publicActions/getERC1155BalanceOf.ts b/packages/core/src/erc1155/publicActions/getERC1155BalanceOf.ts index c5a91ca..aef8698 100644 --- a/packages/core/src/erc1155/publicActions/getERC1155BalanceOf.ts +++ b/packages/core/src/erc1155/publicActions/getERC1155BalanceOf.ts @@ -25,23 +25,25 @@ export const getERC1155BalanceOf = < T extends "select" | undefined, >( client: Client, - args: GetERC1155BalanceOfParameters, + { erc1155, address, ...request }: GetERC1155BalanceOfParameters, type?: T, ): ReverseMirage, T> => (type === undefined ? readContract(client, { abi: solmateERC1155ABI, - address: args.erc1155.address, + address: erc1155.address, functionName: "balanceOf", - args: [args.address, args.erc1155.id], - }).then((data) => createERC1155Data(args.erc1155, data)) + args: [address, erc1155.id], + ...request, + }).then((data) => createERC1155Data(erc1155, data)) : { read: () => readContract(client, { abi: solmateERC1155ABI, - address: args.erc1155.address, + address: erc1155.address, functionName: "balanceOf", - args: [args.address, args.erc1155.id], + args: [address, erc1155.id], + ...request, }), - parse: (data) => createERC1155Data(args.erc1155, data), + parse: (data) => createERC1155Data(erc1155, data), }) as ReverseMirage, T>; diff --git a/packages/core/src/erc1155/publicActions/getERC1155IsApprovedForAll.ts b/packages/core/src/erc1155/publicActions/getERC1155IsApprovedForAll.ts index 05b885c..5bed0d9 100644 --- a/packages/core/src/erc1155/publicActions/getERC1155IsApprovedForAll.ts +++ b/packages/core/src/erc1155/publicActions/getERC1155IsApprovedForAll.ts @@ -22,23 +22,25 @@ export const getERC1155IsApprovedForAll = < T extends "select" | undefined, >( client: Client, - args: GetERC1155IsApprovedForAllParameters, + { erc1155, owner, spender, ...request }: GetERC1155IsApprovedForAllParameters, type?: T, ): ReverseMirage => (type === undefined ? readContract(client, { abi: solmateERC1155ABI, - address: args.erc1155.address, + address: erc1155.address, functionName: "isApprovedForAll", - args: [args.owner, args.spender], + args: [owner, spender], + ...request, }) : { read: () => readContract(client, { abi: solmateERC1155ABI, - address: args.erc1155.address, + address: erc1155.address, functionName: "isApprovedForAll", - args: [args.owner, args.spender], + args: [owner, spender], + ...request, }), parse: (data) => data, }) as ReverseMirage; diff --git a/packages/core/src/erc1155/publicActions/getERC1155URI.ts b/packages/core/src/erc1155/publicActions/getERC1155URI.ts index 6eb0eaa..8a36ae7 100644 --- a/packages/core/src/erc1155/publicActions/getERC1155URI.ts +++ b/packages/core/src/erc1155/publicActions/getERC1155URI.ts @@ -16,23 +16,25 @@ export const getERC1155URI = < T extends "select" | undefined, >( client: Client, - args: GetERC1155URIParameters, + { erc1155, ...request }: GetERC1155URIParameters, type?: T, ): ReverseMirage => (type === undefined ? readContract(client, { abi: solmateERC1155ABI, - address: args.erc1155.address, + address: erc1155.address, functionName: "uri", - args: [args.erc1155.id], + args: [erc1155.id], + ...request, }) : { read: () => readContract(client, { abi: solmateERC1155ABI, - address: args.erc1155.address, + address: erc1155.address, functionName: "uri", - args: [args.erc1155.id], + args: [erc1155.id], + ...request, }), parse: (data) => data, }) as ReverseMirage; diff --git a/packages/core/src/erc20/publicActions/getERC20.ts b/packages/core/src/erc20/publicActions/getERC20.ts index 1352bc8..1d071ac 100644 --- a/packages/core/src/erc20/publicActions/getERC20.ts +++ b/packages/core/src/erc20/publicActions/getERC20.ts @@ -22,38 +22,38 @@ export const getERC20 = < T extends "select" | undefined, >( client: Client, - args: GetERC20Parameters, + { erc20, ...request }: GetERC20Parameters, type?: T, ): ReverseMirage<[string, string, number], GetERC20NameReturnType, T> => (type === undefined ? Promise.all([ - getERC20Name(client, args), - getERC20Symbol(client, args), - getERC20Decimals(client, args), + getERC20Name(client, { erc20, ...request }), + getERC20Symbol(client, { erc20, ...request }), + getERC20Decimals(client, { erc20, ...request }), ]).then(([name, symbol, decimals]) => createERC20( - args.erc20.address, + erc20.address, name, symbol, decimals, - args.erc20.chainID, - args.erc20.blockCreated, + erc20.chainID, + erc20.blockCreated, ), ) : { read: () => Promise.all([ - getERC20Name(client, args, "select").read(), - getERC20Symbol(client, args, "select").read(), - getERC20Decimals(client, args, "select").read(), + getERC20Name(client, { erc20, ...request }, "select").read(), + getERC20Symbol(client, { erc20, ...request }, "select").read(), + getERC20Decimals(client, { erc20, ...request }, "select").read(), ]), parse: ([name, symbol, decimals]) => createERC20( - args.erc20.address, + erc20.address, name, symbol, decimals, - args.erc20.chainID, - args.erc20.blockCreated, + erc20.chainID, + erc20.blockCreated, ), }) as ReverseMirage<[string, string, number], GetERC20NameReturnType, T>; diff --git a/packages/core/src/erc20/publicActions/getERC20Allowance.ts b/packages/core/src/erc20/publicActions/getERC20Allowance.ts index 696bac0..dcba31a 100644 --- a/packages/core/src/erc20/publicActions/getERC20Allowance.ts +++ b/packages/core/src/erc20/publicActions/getERC20Allowance.ts @@ -25,23 +25,25 @@ export const getERC20Allowance = < T extends "select" | undefined, >( client: Client, - args: GetERC20AllowanceParameters, + { erc20, owner, spender, ...request }: GetERC20AllowanceParameters, type?: T, ): ReverseMirage, T> => (type === undefined ? readContract(client, { abi: solmateERC20ABI, - address: args.erc20.address, + address: erc20.address, functionName: "allowance", - args: [args.owner, args.spender], - }).then((data) => createAmountFromRaw(args.erc20, data)) + args: [owner, spender], + ...request, + }).then((data) => createAmountFromRaw(erc20, data)) : { read: () => readContract(client, { abi: solmateERC20ABI, - address: args.erc20.address, + address: erc20.address, functionName: "allowance", - args: [args.owner, args.spender], + args: [owner, spender], + ...request, }), - parse: (data) => createAmountFromRaw(args.erc20, data), + parse: (data) => createAmountFromRaw(erc20, data), }) as ReverseMirage, T>; diff --git a/packages/core/src/erc20/publicActions/getERC20BalanceOf.ts b/packages/core/src/erc20/publicActions/getERC20BalanceOf.ts index 2beac48..cab772e 100644 --- a/packages/core/src/erc20/publicActions/getERC20BalanceOf.ts +++ b/packages/core/src/erc20/publicActions/getERC20BalanceOf.ts @@ -25,23 +25,25 @@ export const getERC20BalanceOf = < T extends "select" | undefined, >( client: Client, - args: GetERC20BalanceOfParameters, + { erc20, address, ...request }: GetERC20BalanceOfParameters, type?: T, ): ReverseMirage, T> => (type === undefined ? readContract(client, { abi: solmateERC20ABI, - address: args.erc20.address, + address: erc20.address, functionName: "balanceOf", - args: [args.address], - }).then((data) => createAmountFromRaw(args.erc20, data)) + args: [address], + ...request, + }).then((data) => createAmountFromRaw(erc20, data)) : { read: () => readContract(client, { abi: solmateERC20ABI, - address: args.erc20.address, + address: erc20.address, functionName: "balanceOf", - args: [args.address], + args: [address], + ...request, }), - parse: (data) => createAmountFromRaw(args.erc20, data), + parse: (data) => createAmountFromRaw(erc20, data), }) as ReverseMirage, T>; diff --git a/packages/core/src/erc20/publicActions/getERC20Decimals.ts b/packages/core/src/erc20/publicActions/getERC20Decimals.ts index aaf7871..881c6bd 100644 --- a/packages/core/src/erc20/publicActions/getERC20Decimals.ts +++ b/packages/core/src/erc20/publicActions/getERC20Decimals.ts @@ -16,21 +16,23 @@ export const getERC20Decimals = < T extends "select" | undefined, >( client: Client, - args: GetERC20DecimalsParameters, + { erc20, ...request }: GetERC20DecimalsParameters, type?: T, ): ReverseMirage => (type === undefined ? readContract(client, { abi: solmateERC20ABI, - address: args.erc20.address, + address: erc20.address, functionName: "decimals", + ...request, }) : { read: () => readContract(client, { abi: solmateERC20ABI, - address: args.erc20.address, + address: erc20.address, functionName: "decimals", + ...request, }), parse: (data) => data, }) as ReverseMirage; diff --git a/packages/core/src/erc20/publicActions/getERC20DomainSeparator.ts b/packages/core/src/erc20/publicActions/getERC20DomainSeparator.ts index a42097f..4044b30 100644 --- a/packages/core/src/erc20/publicActions/getERC20DomainSeparator.ts +++ b/packages/core/src/erc20/publicActions/getERC20DomainSeparator.ts @@ -22,21 +22,23 @@ export const getERC20DomainSeparator = < T extends "select" | undefined, >( client: Client, - args: GetERC20DomainSeparatorParameters, + { erc20, ...request }: GetERC20DomainSeparatorParameters, type?: T, ): ReverseMirage => (type === undefined ? readContract(client, { abi: solmateERC20ABI, - address: args.erc20.address, + address: erc20.address, functionName: "DOMAIN_SEPARATOR", + ...request, }) : { read: () => readContract(client, { abi: solmateERC20ABI, - address: args.erc20.address, + address: erc20.address, functionName: "DOMAIN_SEPARATOR", + ...request, }), parse: (data) => data, }) as ReverseMirage; diff --git a/packages/core/src/erc20/publicActions/getERC20Name.ts b/packages/core/src/erc20/publicActions/getERC20Name.ts index 38df44c..db5e4e8 100644 --- a/packages/core/src/erc20/publicActions/getERC20Name.ts +++ b/packages/core/src/erc20/publicActions/getERC20Name.ts @@ -16,21 +16,23 @@ export const getERC20Name = < T extends "select" | undefined, >( client: Client, - args: GetERC20NameParameters, + { erc20, ...request }: GetERC20NameParameters, type?: T, ): ReverseMirage => (type === undefined ? readContract(client, { abi: solmateERC20ABI, - address: args.erc20.address, + address: erc20.address, functionName: "name", + ...request, }) : { read: () => readContract(client, { abi: solmateERC20ABI, - address: args.erc20.address, + address: erc20.address, functionName: "name", + ...request, }), parse: (data) => data, }) as ReverseMirage; diff --git a/packages/core/src/erc20/publicActions/getERC20Permit.ts b/packages/core/src/erc20/publicActions/getERC20Permit.ts index 682031f..6b9adc9 100644 --- a/packages/core/src/erc20/publicActions/getERC20Permit.ts +++ b/packages/core/src/erc20/publicActions/getERC20Permit.ts @@ -22,41 +22,41 @@ export const getERC20Permit = < T extends "select" | undefined, >( client: Client, - args: GetERC20PermitParameters, + { erc20, ...request }: GetERC20PermitParameters, type?: T, ): ReverseMirage<[string, string, number], GetERC20PermitReturnType, T> => (type === undefined ? Promise.all([ - getERC20Name(client, args), - getERC20Symbol(client, args), - getERC20Decimals(client, args), + getERC20Name(client, { erc20, ...request }), + getERC20Symbol(client, { erc20, ...request }), + getERC20Decimals(client, { erc20, ...request }), ]).then(([name, symbol, decimals]) => createERC20Permit( - args.erc20.address, + erc20.address, name, symbol, decimals, - args.erc20.version ?? "1", - args.erc20.chainID, - args.erc20.blockCreated, + erc20.version ?? "1", + erc20.chainID, + erc20.blockCreated, ), ) : { read: () => Promise.all([ - getERC20Name(client, args, "select").read(), - getERC20Symbol(client, args, "select").read(), - getERC20Decimals(client, args, "select").read(), + getERC20Name(client, { erc20, ...request }, "select").read(), + getERC20Symbol(client, { erc20, ...request }, "select").read(), + getERC20Decimals(client, { erc20, ...request }, "select").read(), ]), parse: ([name, symbol, decimals]) => createERC20Permit( - args.erc20.address, + erc20.address, name, symbol, decimals, - args.erc20.version ?? "1", - args.erc20.chainID, - args.erc20.blockCreated, + erc20.version ?? "1", + erc20.chainID, + erc20.blockCreated, ), }) as ReverseMirage< [string, string, number], diff --git a/packages/core/src/erc20/publicActions/getERC20PermitData.ts b/packages/core/src/erc20/publicActions/getERC20PermitData.ts index 4c643b7..cc11c77 100644 --- a/packages/core/src/erc20/publicActions/getERC20PermitData.ts +++ b/packages/core/src/erc20/publicActions/getERC20PermitData.ts @@ -25,44 +25,48 @@ export const getERC20PermitData = < T extends "select" | undefined, >( client: Client, - args: GetERC20PermitDataParameters, + { erc20, address, ...request }: GetERC20PermitDataParameters, type?: T, ): ReverseMirage<[bigint, bigint], GetERC20PermitDataReturnType, T> => (type === undefined ? Promise.all([ readContract(client, { abi: solmateERC20ABI, - address: args.erc20.address, + address: erc20.address, functionName: "balanceOf", - args: [args.address], + args: [address], + ...request, }), readContract(client, { abi: solmateERC20ABI, - address: args.erc20.address, + address: erc20.address, functionName: "nonces", - args: [args.address], + args: [address], + ...request, }), ]).then(([balance, nonce]) => - createERC20PermitDataFromRaw(args.erc20, balance, nonce), + createERC20PermitDataFromRaw(erc20, balance, nonce), ) : { read: () => Promise.all([ readContract(client, { abi: solmateERC20ABI, - address: args.erc20.address, + address: erc20.address, functionName: "balanceOf", - args: [args.address], + args: [address], + ...request, }), readContract(client, { abi: solmateERC20ABI, - address: args.erc20.address, + address: erc20.address, functionName: "nonces", - args: [args.address], + args: [address], + ...request, }), ]), parse: ([balance, nonce]) => - createERC20PermitDataFromRaw(args.erc20, balance, nonce), + createERC20PermitDataFromRaw(erc20, balance, nonce), }) as ReverseMirage< [bigint, bigint], GetERC20PermitDataReturnType, diff --git a/packages/core/src/erc20/publicActions/getERC20PermitNonce.ts b/packages/core/src/erc20/publicActions/getERC20PermitNonce.ts index e99b751..fd7353d 100644 --- a/packages/core/src/erc20/publicActions/getERC20PermitNonce.ts +++ b/packages/core/src/erc20/publicActions/getERC20PermitNonce.ts @@ -22,23 +22,25 @@ export const getERC20PermitNonce = < T extends "select" | undefined, >( client: Client, - args: GetERC20PermitNonceParameters, + { erc20, address, ...request }: GetERC20PermitNonceParameters, type?: T, ): ReverseMirage => (type === undefined ? readContract(client, { abi: solmateERC20ABI, - address: args.erc20.address, + address: erc20.address, functionName: "nonces", - args: [args.address], + args: [address], + ...request, }) : { read: () => readContract(client, { abi: solmateERC20ABI, - address: args.erc20.address, + address: erc20.address, functionName: "nonces", - args: [args.address], + args: [address], + ...request, }), parse: (data) => data, }) as ReverseMirage; diff --git a/packages/core/src/erc20/publicActions/getERC20Symbol.ts b/packages/core/src/erc20/publicActions/getERC20Symbol.ts index e014c39..ec0d21a 100644 --- a/packages/core/src/erc20/publicActions/getERC20Symbol.ts +++ b/packages/core/src/erc20/publicActions/getERC20Symbol.ts @@ -16,21 +16,23 @@ export const getERC20Symbol = < T extends "select" | undefined, >( client: Client, - args: GetERC20SymbolParameters, + { erc20, ...request }: GetERC20SymbolParameters, type?: T, ): ReverseMirage => (type === undefined ? readContract(client, { abi: solmateERC20ABI, - address: args.erc20.address, + address: erc20.address, functionName: "symbol", + ...request, }) : { read: () => readContract(client, { abi: solmateERC20ABI, - address: args.erc20.address, + address: erc20.address, functionName: "symbol", + ...request, }), parse: (data: string) => data, }) as ReverseMirage; diff --git a/packages/core/src/erc20/publicActions/getERC20TotalSupply.ts b/packages/core/src/erc20/publicActions/getERC20TotalSupply.ts index 0fc5bbe..f2b9d2d 100644 --- a/packages/core/src/erc20/publicActions/getERC20TotalSupply.ts +++ b/packages/core/src/erc20/publicActions/getERC20TotalSupply.ts @@ -19,21 +19,23 @@ export const getERC20TotalSupply = < T extends "select" | undefined, >( client: Client, - args: GetERC20TotalSupplyParameters, + { erc20, ...request }: GetERC20TotalSupplyParameters, type?: T, ): ReverseMirage, T> => (type === undefined ? readContract(client, { abi: solmateERC20ABI, - address: args.erc20.address, + address: erc20.address, functionName: "totalSupply", - }).then((data) => createAmountFromRaw(args.erc20, data)) + ...request, + }).then((data) => createAmountFromRaw(erc20, data)) : { read: () => readContract(client, { abi: solmateERC20ABI, - address: args.erc20.address, + address: erc20.address, functionName: "totalSupply", + ...request, }), - parse: (data) => createAmountFromRaw(args.erc20, data), + parse: (data) => createAmountFromRaw(erc20, data), }) as ReverseMirage, T>; diff --git a/packages/core/src/erc20/publicActions/getIsERC20Permit.ts b/packages/core/src/erc20/publicActions/getIsERC20Permit.ts index 1fcce79..8f597cf 100644 --- a/packages/core/src/erc20/publicActions/getIsERC20Permit.ts +++ b/packages/core/src/erc20/publicActions/getIsERC20Permit.ts @@ -34,7 +34,7 @@ export const getIsERC20Permit = < T extends "select" | undefined, >( client: Client, - args: GetIsERC20PermitParameters, + { erc20, ...request }: GetIsERC20PermitParameters, type?: T, ): ReverseMirage< [[string, string, number], Hex] | [[string, string, number]], @@ -43,40 +43,46 @@ export const getIsERC20Permit = < > => (type === undefined ? Promise.all([ - getERC20Permit(client, args), - getERC20DomainSeparator(client, args), + getERC20Permit(client, { erc20, ...request }), + getERC20DomainSeparator(client, { erc20, ...request }), ]) .then(([erc20]) => erc20) - .catch(() => getERC20(client, args)) + .catch(() => getERC20(client, { erc20, ...request })) : { read: async () => { try { return await Promise.all([ - getERC20Permit(client, args, "select").read(), - getERC20DomainSeparator(client, args, "select").read(), + getERC20Permit(client, { erc20, ...request }, "select").read(), + getERC20DomainSeparator( + client, + { erc20, ...request }, + "select", + ).read(), ]); } catch { - return await Promise.all([getERC20(client, args, "select").read()]); + return await Promise.all([ + getERC20(client, { erc20, ...request }, "select").read(), + ]); } }, parse: (data) => data.length === 1 ? createERC20( - args.erc20.address, + erc20.address, data[0][0], data[0][1], data[0][2], - args.erc20.chainID, - args.erc20.blockCreated, + erc20.chainID, + erc20.blockCreated, ) : createERC20Permit( - args.erc20.address, + erc20.address, data[0][0], data[0][1], data[0][2], - args.erc20.version ?? "1", - args.erc20.chainID, - args.erc20.blockCreated, + erc20.version ?? "1", + erc20.chainID, + erc20.blockCreated, ), }) as ReverseMirage< [[string, string, number], Hex] | [[string, string, number]], diff --git a/packages/core/src/erc20/walletActions/signERC20Permit.ts b/packages/core/src/erc20/walletActions/signERC20Permit.ts index 2ee2fa7..24dc037 100644 --- a/packages/core/src/erc20/walletActions/signERC20Permit.ts +++ b/packages/core/src/erc20/walletActions/signERC20Permit.ts @@ -31,6 +31,7 @@ export const signERC20Permit = < spender, deadline, account = client.account, + ...request }: SignERC20PermitParameters, ) => { const domain = { @@ -56,5 +57,6 @@ export const signERC20Permit = < nonce: permitData.nonce, }, account: account!, + ...request, }); }; diff --git a/packages/core/src/erc721/publicActions/getERC721.ts b/packages/core/src/erc721/publicActions/getERC721.ts index 0e001f4..7c4d27b 100644 --- a/packages/core/src/erc721/publicActions/getERC721.ts +++ b/packages/core/src/erc721/publicActions/getERC721.ts @@ -21,34 +21,34 @@ export const getERC721 = < T extends "select" | undefined, >( client: Client, - args: GetERC721Parameters, + { erc721, ...request }: GetERC721Parameters, type?: T, ): ReverseMirage<[string, string], GetERC721ReturnType, T> => (type === undefined ? Promise.all([ - getERC721Name(client, args), - getERC721Symbol(client, args), + getERC721Name(client, { erc721, ...request }), + getERC721Symbol(client, { erc721, ...request }), ]).then(([name, symbol]) => createERC721( - args.erc721.address, + erc721.address, name, symbol, - args.erc721.chainID, - args.blockNumber, + erc721.chainID, + erc721.blockCreated, ), ) : { read: () => Promise.all([ - getERC721Name(client, args, "select").read(), - getERC721Symbol(client, args, "select").read(), + getERC721Name(client, { erc721, ...request }, "select").read(), + getERC721Symbol(client, { erc721, ...request }, "select").read(), ]), parse: ([name, symbol]) => createERC721( - args.erc721.address, + erc721.address, name, symbol, - args.erc721.chainID, - args.blockNumber, + erc721.chainID, + erc721.blockCreated, ), }) as ReverseMirage<[string, string], GetERC721ReturnType, T>; diff --git a/packages/core/src/erc721/publicActions/getERC721Approved.ts b/packages/core/src/erc721/publicActions/getERC721Approved.ts index 3407d61..8ef832e 100644 --- a/packages/core/src/erc721/publicActions/getERC721Approved.ts +++ b/packages/core/src/erc721/publicActions/getERC721Approved.ts @@ -22,23 +22,25 @@ export const getERC721Approved = < T extends "select" | undefined, >( client: Client, - args: GetERC721ApprovedParameters, + { erc721, id, ...request }: GetERC721ApprovedParameters, type?: T, ): ReverseMirage => (type === undefined ? readContract(client, { abi: solmateERC721ABI, - address: args.erc721.address, + address: erc721.address, functionName: "getApproved", - args: [args.id], + args: [id], + ...request, }) : { read: () => readContract(client, { abi: solmateERC721ABI, - address: args.erc721.address, + address: erc721.address, functionName: "getApproved", - args: [args.id], + args: [id], + ...request, }), parse: (data) => data, }) as ReverseMirage; diff --git a/packages/core/src/erc721/publicActions/getERC721BalanceOf.ts b/packages/core/src/erc721/publicActions/getERC721BalanceOf.ts index 2f5d90c..00e05c2 100644 --- a/packages/core/src/erc721/publicActions/getERC721BalanceOf.ts +++ b/packages/core/src/erc721/publicActions/getERC721BalanceOf.ts @@ -22,23 +22,25 @@ export const getERC721BalanceOf = < T extends "select" | undefined, >( client: Client, - args: GetERC721BalanceOfParameters, + { erc721, address, ...request }: GetERC721BalanceOfParameters, type?: T, ): ReverseMirage => (type === undefined ? readContract(client, { abi: solmateERC721ABI, - address: args.erc721.address, + address: erc721.address, functionName: "balanceOf", - args: [args.address], + args: [address], + ...request, }) : { read: () => readContract(client, { abi: solmateERC721ABI, - address: args.erc721.address, + address: erc721.address, functionName: "balanceOf", - args: [args.address], + args: [address], + ...request, }), parse: (data) => data, }) as ReverseMirage; diff --git a/packages/core/src/erc721/publicActions/getERC721Data.ts b/packages/core/src/erc721/publicActions/getERC721Data.ts index c1bcb1a..455d8c7 100644 --- a/packages/core/src/erc721/publicActions/getERC721Data.ts +++ b/packages/core/src/erc721/publicActions/getERC721Data.ts @@ -25,20 +25,27 @@ export const getERC721Data = < T extends "select" | undefined, >( client: Client, - args: GetERC721DataParameters, + { erc721, address, ...request }: GetERC721DataParameters, type?: T, ): ReverseMirage, T> => (type === undefined - ? getERC721BalanceOf(client, args).then((data) => { - if (data > Number.MAX_SAFE_INTEGER) - throw Error("balance exceeds maximum representable number"); - return createERC721Data(args.erc721, Number(data)); - }) + ? 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)); + }, + ) : { - read: () => getERC721BalanceOf(client, args, "select").read(), + read: () => + getERC721BalanceOf( + client, + { erc721, address, ...request }, + "select", + ).read(), parse: (data) => { if (data > Number.MAX_SAFE_INTEGER) throw Error("balance exceeds maximum representable number"); - return createERC721Data(args.erc721, Number(data)); + return createERC721Data(erc721, Number(data)); }, }) as ReverseMirage, T>; diff --git a/packages/core/src/erc721/publicActions/getERC721IsApprovedForAll.ts b/packages/core/src/erc721/publicActions/getERC721IsApprovedForAll.ts index 8f81ce0..420df7a 100644 --- a/packages/core/src/erc721/publicActions/getERC721IsApprovedForAll.ts +++ b/packages/core/src/erc721/publicActions/getERC721IsApprovedForAll.ts @@ -22,23 +22,25 @@ export const getERC721IsApprovedForAll = < T extends "select" | undefined, >( client: Client, - args: GetERC721IsApprovedForAllParameters, + { erc721, owner, spender, ...request }: GetERC721IsApprovedForAllParameters, type?: T, ): ReverseMirage => (type === undefined ? readContract(client, { abi: solmateERC721ABI, - address: args.erc721.address, + address: erc721.address, functionName: "isApprovedForAll", - args: [args.owner, args.spender], + args: [owner, spender], + ...request, }) : { read: () => readContract(client, { abi: solmateERC721ABI, - address: args.erc721.address, + address: erc721.address, functionName: "isApprovedForAll", - args: [args.owner, args.spender], + args: [owner, spender], + ...request, }), parse: (data) => data, }) as ReverseMirage; diff --git a/packages/core/src/erc721/publicActions/getERC721Name.ts b/packages/core/src/erc721/publicActions/getERC721Name.ts index 4d26aad..6494551 100644 --- a/packages/core/src/erc721/publicActions/getERC721Name.ts +++ b/packages/core/src/erc721/publicActions/getERC721Name.ts @@ -16,21 +16,23 @@ export const getERC721Name = < T extends "select" | undefined, >( client: Client, - args: GetERC721NameParameters, + { erc721, ...request }: GetERC721NameParameters, type?: T, ): ReverseMirage => (type === undefined ? readContract(client, { abi: solmateERC721ABI, - address: args.erc721.address, + address: erc721.address, functionName: "name", + ...request, }) : { read: () => readContract(client, { abi: solmateERC721ABI, - address: args.erc721.address, + address: erc721.address, functionName: "name", + ...request, }), parse: (data) => data, }) as ReverseMirage; diff --git a/packages/core/src/erc721/publicActions/getERC721OwnerOf.ts b/packages/core/src/erc721/publicActions/getERC721OwnerOf.ts index 42eb31b..5e70660 100644 --- a/packages/core/src/erc721/publicActions/getERC721OwnerOf.ts +++ b/packages/core/src/erc721/publicActions/getERC721OwnerOf.ts @@ -22,23 +22,25 @@ export const getERC721OwnerOf = < T extends "select" | undefined, >( client: Client, - args: GetERC721OwnerOfParameters, + { erc721, id, ...request }: GetERC721OwnerOfParameters, type?: T, ): ReverseMirage => (type === undefined ? readContract(client, { abi: solmateERC721ABI, - address: args.erc721.address, + address: erc721.address, functionName: "ownerOf", - args: [args.id], + args: [id], + ...request, }) : { read: () => readContract(client, { abi: solmateERC721ABI, - address: args.erc721.address, + address: erc721.address, functionName: "ownerOf", - args: [args.id], + args: [id], + ...request, }), parse: (data) => data, }) as ReverseMirage; diff --git a/packages/core/src/erc721/publicActions/getERC721SupportsInterface.ts b/packages/core/src/erc721/publicActions/getERC721SupportsInterface.ts index 6ff1892..3ba0392 100644 --- a/packages/core/src/erc721/publicActions/getERC721SupportsInterface.ts +++ b/packages/core/src/erc721/publicActions/getERC721SupportsInterface.ts @@ -22,23 +22,25 @@ export const getERC721SupportsInterface = < T extends "select" | undefined, >( client: Client, - args: GetERC721SupportsInterfaceParameters, + { erc721, interfaceID, ...request }: GetERC721SupportsInterfaceParameters, type?: T, ): ReverseMirage => (type === undefined ? readContract(client, { abi: solmateERC721ABI, - address: args.erc721.address, + address: erc721.address, functionName: "supportsInterface", - args: [args.interfaceID], + args: [interfaceID], + ...request, }) : { read: () => readContract(client, { abi: solmateERC721ABI, - address: args.erc721.address, + address: erc721.address, functionName: "supportsInterface", - args: [args.interfaceID], + args: [interfaceID], + ...request, }), parse: (data) => data, }) as ReverseMirage; diff --git a/packages/core/src/erc721/publicActions/getERC721Symbol.ts b/packages/core/src/erc721/publicActions/getERC721Symbol.ts index 81bbea2..41b4aff 100644 --- a/packages/core/src/erc721/publicActions/getERC721Symbol.ts +++ b/packages/core/src/erc721/publicActions/getERC721Symbol.ts @@ -16,21 +16,23 @@ export const getERC721Symbol = < T extends "select" | undefined, >( client: Client, - args: GetERC721SymbolParameters, + { erc721, ...request }: GetERC721SymbolParameters, type?: T, ): ReverseMirage => (type === undefined ? readContract(client, { abi: solmateERC721ABI, - address: args.erc721.address, + address: erc721.address, functionName: "symbol", + ...request, }) : { read: () => readContract(client, { abi: solmateERC721ABI, - address: args.erc721.address, + address: erc721.address, functionName: "symbol", + ...request, }), parse: (data) => data, }) as ReverseMirage; diff --git a/packages/core/src/erc721/publicActions/getERC721TokenURI.ts b/packages/core/src/erc721/publicActions/getERC721TokenURI.ts index 3f2ad96..50f3b83 100644 --- a/packages/core/src/erc721/publicActions/getERC721TokenURI.ts +++ b/packages/core/src/erc721/publicActions/getERC721TokenURI.ts @@ -16,23 +16,25 @@ export const getERC721TokenURI = < T extends "select" | undefined, >( client: Client, - args: GetERC721TokenURIParameters, + { erc721, id, ...request }: GetERC721TokenURIParameters, type?: T, ): ReverseMirage => (type === undefined ? readContract(client, { abi: solmateERC721ABI, - address: args.erc721.address, + address: erc721.address, functionName: "tokenURI", - args: [args.id], + args: [id], + ...request, }) : { read: () => readContract(client, { abi: solmateERC721ABI, - address: args.erc721.address, + address: erc721.address, functionName: "tokenURI", - args: [args.id], + args: [id], + ...request, }), parse: (data) => data, }) as ReverseMirage; diff --git a/packages/core/src/native/publicActions/getNativeBalance.ts b/packages/core/src/native/publicActions/getNativeBalance.ts index f316404..acda95c 100644 --- a/packages/core/src/native/publicActions/getNativeBalance.ts +++ b/packages/core/src/native/publicActions/getNativeBalance.ts @@ -18,16 +18,20 @@ export const getNativeBalance = < T extends "select" | undefined, >( client: Client, - args: GetNativeBalanceParameters, + { + address, + nativeCurrency, + ...request + }: GetNativeBalanceParameters, type?: T, ): ReverseMirage, T> => (type === undefined - ? getBalance(client, { address: args.address }).then((data) => - createAmountFromRaw(args.nativeCurrency, data), + ? getBalance(client, { address: address, ...request }).then((data) => + createAmountFromRaw(nativeCurrency, data), ) : { - read: () => getBalance(client, { address: args.address }), - parse: (data: bigint) => createAmountFromRaw(args.nativeCurrency, data), + read: () => getBalance(client, { address: address, ...request }), + parse: (data: bigint) => createAmountFromRaw(nativeCurrency, data), }) as ReverseMirage< bigint, GetNativeBalanceReturnType,