diff --git a/libs/cypress/src/lib/capsule/create-market.ts b/libs/cypress/src/lib/capsule/create-market.ts index 580d39ff8..37f80610a 100644 --- a/libs/cypress/src/lib/capsule/create-market.ts +++ b/libs/cypress/src/lib/capsule/create-market.ts @@ -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'; diff --git a/libs/cypress/src/lib/capsule/submit-proposal.ts b/libs/cypress/src/lib/capsule/submit-proposal.ts index e93324aef..d90efbfdd 100644 --- a/libs/cypress/src/lib/capsule/submit-proposal.ts +++ b/libs/cypress/src/lib/capsule/submit-proposal.ts @@ -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) { diff --git a/libs/cypress/src/lib/utils.ts b/libs/cypress/src/lib/utils.ts index 5ddfe555f..d035269b4 100644 --- a/libs/cypress/src/lib/utils.ts +++ b/libs/cypress/src/lib/utils.ts @@ -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 diff --git a/libs/wallet/package.json b/libs/wallet/package.json index f10d9a9c0..abe6a0db7 100644 --- a/libs/wallet/package.json +++ b/libs/wallet/package.json @@ -3,7 +3,6 @@ "version": "0.0.3", "dependencies": { "@vegaprotocol/types": "0.0.7", - "@vegaprotocol/utils": "0.0.11", "eventemitter3": "^5.0.1", "js-sha3": "^0.8.0", "zustand": "^4.5.0" diff --git a/libs/wallet/project.json b/libs/wallet/project.json index 828e11399..90c787eb1 100644 --- a/libs/wallet/project.json +++ b/libs/wallet/project.json @@ -15,7 +15,7 @@ "project": "libs/wallet/package.json", "compiler": "swc", "format": ["esm"], - "external": ["@vegaprotocol/types", "@vegaprotocol/utils"] + "external": ["@vegaprotocol/types"] } }, "publish": { diff --git a/libs/wallet/src/connectors/view-party-connector.ts b/libs/wallet/src/connectors/view-party-connector.ts index 0a708691f..deb842635 100644 --- a/libs/wallet/src/connectors/view-party-connector.ts +++ b/libs/wallet/src/connectors/view-party-connector.ts @@ -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'; diff --git a/libs/wallet/src/utils.ts b/libs/wallet/src/utils.ts index d901d2885..8473ae31a 100644 --- a/libs/wallet/src/utils.ts +++ b/libs/wallet/src/utils.ts @@ -25,11 +25,16 @@ export const determineId = (sig: string) => { function hexToBytes(hex: string) { const bytes = []; for (let i = 0; i < hex.length; i += 2) { - bytes.push(parseInt(hex.substr(i, 2), 16)); + 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); +}; + /** * TODO: We may want to create a package similar to @metamask/detect-ethereum-provider as this wont suffice * if called immeidately, and before the extension has been able to add the vega object to the window