diff --git a/src/services/Provider.ts b/src/services/Provider.ts index f2260429..f4be11f5 100644 --- a/src/services/Provider.ts +++ b/src/services/Provider.ts @@ -114,19 +114,22 @@ export class Provider { * @returns {Promise} A promise that resolves with the signature. */ public async signProviderRequest(signer: Signer, message: string): Promise { + // const isMetaMask = web3 && web3.currentProvider && (web3.currentProvider as any).isMetaMask + // if (isMetaMask) return await web3.eth.personal.sign(consumerMessage, accountId, password) + // await web3.eth.sign(consumerMessage, await signer.getAddress()) const consumerMessage = ethers.utils.solidityKeccak256( ['bytes'], [ethers.utils.hexlify(ethers.utils.toUtf8Bytes(message))] ) - // const isMetaMask = web3 && web3.currentProvider && (web3.currentProvider as any).isMetaMask - // if (isMetaMask) return await web3.eth.personal.sign(consumerMessage, accountId, password) - // await web3.eth.sign(consumerMessage, await signer.getAddress()) - const messageHashBytes = ethers.utils.arrayify(consumerMessage) - const newSignature = await (signer as providers.JsonRpcSigner)._legacySignMessage( - messageHashBytes - ) - return newSignature + + const chainId = await signer.getChainId() + if (chainId == 8996) { + return await (signer as providers.JsonRpcSigner)._legacySignMessage( + messageHashBytes + ) + } + return await signer.signMessage(messageHashBytes) } /** diff --git a/src/utils/ContractUtils.ts b/src/utils/ContractUtils.ts index 333cac55..a180bfe7 100644 --- a/src/utils/ContractUtils.ts +++ b/src/utils/ContractUtils.ts @@ -50,6 +50,7 @@ export async function getTokenDecimals(signer: Signer, token: string) { /** * Converts an amount of units to tokens + * @param {Signer} signer - The signer object to use. * @param {string} token - The token to convert * @param {string} amount - The amount of units to convert * @param {number} [tokenDecimals] - The number of decimals in the token @@ -72,6 +73,7 @@ export async function unitsToAmount( /** * Converts an amount of tokens to units + * @param {Signer} signer - The signer object to use. * @param {string} token - The token to convert * @param {string} amount - The amount of tokens to convert * @param {number} [tokenDecimals] - The number of decimals of the token