chore(wallet): reduce bundle size by removing unnecessary deps (#5955)
This commit is contained in:
parent
a77858c1c0
commit
2e28a175ce
@ -1,5 +1,5 @@
|
||||
import * as Schema from '@vegaprotocol/types';
|
||||
import { determineId } from '../utils';
|
||||
import { determineId } from '@vegaprotocol/wallet';
|
||||
import { setGraphQLEndpoint } from './request';
|
||||
import { vote } from './vote';
|
||||
import { stakeForVegaPublicKey } from './ethereum-setup';
|
||||
|
@ -1,7 +1,6 @@
|
||||
import type { ProposalSubmissionBody } from '@vegaprotocol/wallet';
|
||||
import { determineId, type ProposalSubmissionBody } from '@vegaprotocol/wallet';
|
||||
import { sendVegaTx } from './wallet-client';
|
||||
import { waitForProposal } from './propose-market';
|
||||
import { determineId } from '../utils';
|
||||
const vegaPubKey = Cypress.env('VEGA_PUBLIC_KEY');
|
||||
|
||||
export async function submitProposal(proposalTx: ProposalSubmissionBody) {
|
||||
|
@ -1,15 +1,5 @@
|
||||
import { ethers } from 'ethers';
|
||||
import sha3 from 'js-sha3';
|
||||
import BigNumber from 'bignumber.js';
|
||||
|
||||
/**
|
||||
* copy of determineId in libs/wallet/src/utils.ts
|
||||
* to avoid pulling in any jsx files which will cypress is not set up to compile
|
||||
*/
|
||||
export function determineId(sig: string) {
|
||||
return sha3.sha3_256(ethers.utils.arrayify('0x' + sig));
|
||||
}
|
||||
|
||||
/**
|
||||
* copy of removeDecimal from libs/react-helpers/src/lib/format/number.tsx
|
||||
* to avoid pulling in any jsx files which will cypress is not set up to compile
|
||||
|
@ -3,8 +3,6 @@
|
||||
"version": "0.0.3",
|
||||
"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"
|
||||
|
@ -15,7 +15,7 @@
|
||||
"project": "libs/wallet/package.json",
|
||||
"compiler": "swc",
|
||||
"format": ["esm"],
|
||||
"external": ["@vegaprotocol/types", "@vegaprotocol/utils"]
|
||||
"external": ["@vegaprotocol/types"]
|
||||
}
|
||||
},
|
||||
"publish": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { type StoreApi } from 'zustand';
|
||||
import { type Store, type Connector } from '../types';
|
||||
import { isValidVegaPublicKey } from '@vegaprotocol/utils';
|
||||
import { type TransactionResponse } from '../transaction-types';
|
||||
import {
|
||||
ConnectorError,
|
||||
chainIdError,
|
||||
@ -9,7 +9,7 @@ import {
|
||||
sendTransactionError,
|
||||
userRejectedError,
|
||||
} from '../errors';
|
||||
import { type TransactionResponse } from '../transaction-types';
|
||||
import { isValidVegaPublicKey } from '../utils';
|
||||
|
||||
export class ViewPartyConnector implements Connector {
|
||||
readonly id = 'viewParty';
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { ethers } from 'ethers';
|
||||
import { sha3_256 } from 'js-sha3';
|
||||
import {
|
||||
type ApplyReferralCode,
|
||||
@ -20,16 +19,20 @@ 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.substring(i, i + 2), 16));
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
/* Validates string is 64 chars hex string */
|
||||
export const isValidVegaPublicKey = (value: string) => {
|
||||
return /^[A-Fa-f0-9]{64}$/i.test(value);
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user