Here is the Error Message:
Uncaught (in promise) Error: invalid type (argument="type", value="Proof", code=INVALID_ARGUMENT, version=abi/5.7.0)
Here is the solidity function
function createOffer(
address _requestorAddress,
address[] memory _requestedNftAddress,
uint[] memory _requestedNftId,
address[] memory _offeredNftAddress,
uint[] memory _offeredNftId,
Proof[] memory _proofsRequested,
Proof[] memory _proofsOffered
)
Here is the struct
struct Proof {
address nftAddress;
bytes32[] proof;
}
here is the typescript code
const tx = await contractWithSigner.createOffer(
address,
[counter_party_nfts_addresses[0]],
[counter_party_nft_ids[0]],
[my_nft_addresses[0]],
[my_nft_ids[0]],
[
[
counter_party_nfts_addresses[0],
getMerkelProof(counter_party_nfts_addresses).proof,
],
],
[[my_nft_addresses[0], getMerkelProof(my_nft_addresses).proof]]
);
and here is the getMerkleProof function:
const getMerkelProof = (addresses: string[]) => {
const leaf = keccak256(addresses[0]);
const leaves = addresses.map((x: any) => keccak256(x));
const tree = new MerkleTree(leaves, keccak256, { sortPairs: true });
const proof = tree.getProof(leaf, 0);
const root = tree.getRoot().toString("hex");
return {
proof,
root,
};
};
As the struct accepts two arguments 1 nftAddress and 2nd is merkleProof, i.e
[[address,proof]]
but unable to find the correct way to do it.
argument types should be array of Proof structs but you are passing array of arrays
instead