chore: remove ethers dep from wallet

This commit is contained in:
Matthew Russell 2024-03-08 21:27:39 +00:00
parent 1d721dc748
commit 2d98205028
No known key found for this signature in database
2 changed files with 8 additions and 11 deletions

View File

@ -4,7 +4,6 @@
"dependencies": {
"@vegaprotocol/types": "0.0.7",
"@vegaprotocol/utils": "0.0.11",
"ethers": "^5.6.0",
"eventemitter3": "^5.0.1",
"js-sha3": "^0.8.0",
"zustand": "^4.5.0"

View File

@ -1,4 +1,3 @@
import { ethers } from 'ethers';
import { sha3_256 } from 'js-sha3';
import {
type ApplyReferralCode,
@ -20,17 +19,16 @@ import {
* Can match up the newly created order with incoming orders via a subscription
*/
export const determineId = (sig: string) => {
return sha3_256(ethers.utils.arrayify('0x' + sig));
return sha3_256(new Uint8Array(hexToBytes(sig)));
};
/**
* Base64 encode a transaction object
*/
export const encodeTransaction = (tx: Transaction): string => {
return ethers.utils.base64.encode(
ethers.utils.toUtf8Bytes(JSON.stringify(tx))
);
};
function hexToBytes(hex: string) {
const bytes = [];
for (let i = 0; i < hex.length; i += 2) {
bytes.push(parseInt(hex.substr(i, 2), 16));
}
return bytes;
}
/**
* TODO: We may want to create a package similar to @metamask/detect-ethereum-provider as this wont suffice