Calling eth_signTypedData_v4 using @openzeppelin/test-environment

Hi
I am trying to write Unit Tests for testing Signing and Verification of data payloads using eth_signTypedData_v4 .

In my unit test i write Typescript code to sign the data, and then pass that signature to the SmartContract wherein I attempt to verify it. But I am unable to sign the data in the first place using the web3 provided by @openzeppelin/test-environment.

Here is my code inside my Unit test to try and sign it.

import { accounts, contract, web3 } from "@openzeppelin/test-environment";
...
...
  async function signVoucher(payload: any, signerAddress: string) {
    return new Promise((resolve, reject) => {
      (web3.currentProvider as any).send(
        {
          method: "eth_signTypedData_v4",
          params: [signerAddress, payload],
        },
        (err: any, res: any) => {
          if (err) {
            reject(err);
          } else {
            console.log("Signature :", res);
            resolve(res);
          }
        }
      );
    });
  }

This is the error I get:

error: {
        message: 'Method eth_signTypedData_v4 not supported.',
        code: -32000,
        data: {
          stack: 'Error: Method eth_signTypedData_v4 not supported.\n' +
          :
          :
          name: 'Error'
        }

This is the version of my modules:

    "@openzeppelin/test-environment": "0.1.9",
    "@openzeppelin/test-helpers": "0.5.15",

How do I call eth_signTypedData_v4 from within my Unit Tests ?

Thanks.

Does this answers your question?

@openzeppelin/test-environment has been deprecated a long time ago. It is no longer maintained, and you should not be using it.