Compare commits

...

2 Commits

Author SHA1 Message Date
Matthew Russell
a4bc1cf95d
chore: remove dependency on utils and ethers from wallet 2024-03-08 21:38:45 +00:00
Matthew Russell
2d98205028
chore: remove ethers dep from wallet 2024-03-08 21:27:39 +00:00
7 changed files with 17 additions and 27 deletions

View File

@ -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';

View File

@ -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) {

View File

@ -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

View File

@ -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"

View File

@ -15,7 +15,7 @@
"project": "libs/wallet/package.json",
"compiler": "swc",
"format": ["esm"],
"external": ["@vegaprotocol/types", "@vegaprotocol/utils"]
"external": ["@vegaprotocol/types"]
}
},
"publish": {

View File

@ -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';

View File

@ -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);
};
/**