C:\Dapp\workshops\workshops\25-defender-metatx-api\app\src is used to be upgrade because eth-sig-util is now deprecated

:computer: Environment
i am using workshops\25-defender-metatx-api

:memo:Details
your package.json file is using eth-util-sig which is now deprecated and i an unable to test the contracts of registry kindly update your code

:1234: Code to reproduce


const ethSigUtil = require('eth-sig-util');
src/signer.js
const EIP712Domain = [
{ name: 'name', type: 'string' },
{ name: 'version', type: 'string' },
{ name: 'chainId', type: 'uint256' },
{ name: 'verifyingContract', type: 'address' }
];

const ForwardRequest = [
{ name: 'from', type: 'address' },
{ name: 'to', type: 'address' },
{ name: 'value', type: 'uint256' },
{ name: 'gas', type: 'uint256' },
{ name: 'nonce', type: 'uint256' },
{ name: 'data', type: 'bytes' },
];

function getMetaTxTypeData(chainId, verifyingContract) {
return {
types: {
EIP712Domain,
ForwardRequest,
},
domain: {
name: 'MinimalForwarder',
version: '0.0.1',
chainId,
verifyingContract,
},
primaryType: 'ForwardRequest',
}
};

async function signTypedData(signer, from, data) {
// If signer is a private key, use it to sign
if (typeof(signer) === 'string') {
const privateKey = Buffer.from(signer.replace(/^0x/, ''), 'hex');
return ethSigUtil.signTypedMessage(privateKey, { data });
}

// Otherwise, send the signTypedData RPC call
// Note that hardhatvm and metamask require different EIP712 input
const isHardhat = data.domain.chainId == 31337;
const [method, argData] = isHardhat ? ['eth_signTypedData', data]: ['eth_signTypedData_v4', JSON.stringify(data)]
return await signer.send(method, [from, argData]);

}

async function buildRequest(forwarder, input) {
const nonce = await forwarder.getNonce(input.from).then(nonce => nonce.toString());
return { value: 0, gas: 1e6, nonce, ...input };
}

async function buildTypedData(forwarder, request) {
const chainId = await forwarder.provider.getNetwork().then(n => n.chainId);
const typeData = getMetaTxTypeData(chainId, forwarder.address);
return { ...typeData, message: request };
}

async function signMetaTxRequest(signer, forwarder, input) {
const request = await buildRequest(forwarder, input);
const toSign = await buildTypedData(forwarder, request);
const signature = await signTypedData(signer, input.from, toSign);
return { signature, request };
}

module.exports = {
signMetaTxRequest,
buildRequest,
buildTypedData,
};