chore: bump wallet client (#2662)
This commit is contained in:
parent
5e5cc1c587
commit
ae84e16b9b
@ -37,7 +37,7 @@ describe('vega wallet v1', { tags: '@smoke' }, () => {
|
||||
cy.getByTestId(form).find('#wallet').click().type('invalid name');
|
||||
cy.getByTestId(form).find('#passphrase').click().type('invalid password');
|
||||
cy.getByTestId('rest-connector-form').find('button[type=submit]').click();
|
||||
cy.getByTestId('form-error').should('have.text', 'No wallet detected');
|
||||
cy.getByTestId('form-error').should('have.text', 'Invalid credentials');
|
||||
});
|
||||
|
||||
it('doesnt connect with invalid fields', () => {
|
||||
|
@ -58,14 +58,17 @@ export const testOrderCancellation = (
|
||||
|
||||
const vegaWalletTransaction = (transaction: Transaction) => {
|
||||
cy.wait('@VegaWalletTransaction')
|
||||
.its('request.body.params')
|
||||
.should('deep.equal', {
|
||||
token: JSON.parse(localStorage.getItem('vega_wallet_config') || '{}')
|
||||
?.token,
|
||||
.its('request')
|
||||
.then((req) => {
|
||||
expect(req.body.params).to.deep.equal({
|
||||
publicKey: Cypress.env('VEGA_PUBLIC_KEY'),
|
||||
sendingMode: 'TYPE_SYNC',
|
||||
transaction,
|
||||
});
|
||||
expect(req.headers.authorization).to.equal(
|
||||
`VWT ${Cypress.env('VEGA_WALLET_API_TOKEN')}`
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
const verifyToast = () => {
|
||||
|
@ -38,7 +38,6 @@ export function request(
|
||||
params: {
|
||||
...params,
|
||||
sendingMode: 'TYPE_SYNC',
|
||||
token,
|
||||
},
|
||||
id: (requestId++).toString(),
|
||||
};
|
||||
@ -47,6 +46,7 @@ export function request(
|
||||
body: JSON.stringify(body),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `VWT ${token}`,
|
||||
Origin: 'market-setup',
|
||||
Referer: 'market-setup',
|
||||
},
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { aliasWalletQuery } from '../mock-rest';
|
||||
import { aliasWalletConnectQuery } from '../mock-rest';
|
||||
|
||||
declare global {
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
@ -15,12 +15,8 @@ declare global {
|
||||
}
|
||||
|
||||
export const mockConnectWallet = () => {
|
||||
const data = {
|
||||
token: Cypress.env('VEGA_WALLET_API_TOKEN'),
|
||||
};
|
||||
console.log('mockConnectWallet', data);
|
||||
cy.mockWallet((req) => {
|
||||
aliasWalletQuery(req, 'client.connect_wallet', data);
|
||||
aliasWalletConnectQuery(req, Cypress.env('VEGA_WALLET_API_TOKEN'));
|
||||
});
|
||||
};
|
||||
|
||||
@ -50,7 +46,7 @@ export function addSetVegaWallet() {
|
||||
win.localStorage.setItem(
|
||||
'vega_wallet_config',
|
||||
JSON.stringify({
|
||||
token: Cypress.env('VEGA_WALLET_API_TOKEN'),
|
||||
token: `VWT ${Cypress.env('VEGA_WALLET_API_TOKEN')}`,
|
||||
connector: 'jsonRpc',
|
||||
url: 'http://localhost:1789',
|
||||
})
|
||||
|
@ -43,3 +43,23 @@ export const aliasWalletQuery = (
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const aliasWalletConnectQuery = (
|
||||
req: CyHttpMessages.IncomingHttpRequest,
|
||||
token: string
|
||||
) => {
|
||||
if (hasMethod(req, 'client.connect_wallet')) {
|
||||
req.alias = 'client.connect_wallet';
|
||||
req.reply({
|
||||
statusCode: 200,
|
||||
headers: {
|
||||
'Access-Control-Expose-Headers': 'Authorization',
|
||||
Authorization: `VWT ${token}`,
|
||||
},
|
||||
body: {
|
||||
jsonrpc: '2.0',
|
||||
id: '0',
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -223,7 +223,7 @@ describe('VegaConnectDialog', () => {
|
||||
.mockImplementation(() => delayedResolve({ chainID: mockChainId }));
|
||||
spyOnConnectWallet = jest
|
||||
.spyOn(connectors.jsonRpc, 'connectWallet')
|
||||
.mockImplementation(() => delayedResolve({ token: 'token' }));
|
||||
.mockImplementation(() => delayedResolve(null));
|
||||
spyOnConnect = jest
|
||||
.spyOn(connectors.jsonRpc, 'connect')
|
||||
.mockImplementation(() =>
|
||||
|
@ -46,6 +46,13 @@ export class JsonRpcConnector implements VegaConnector {
|
||||
this.client = new WalletClient({
|
||||
address: cfg.url,
|
||||
token: cfg.token ?? undefined,
|
||||
onTokenChange: (token) => {
|
||||
setConfig({
|
||||
token,
|
||||
connector: 'jsonRpc',
|
||||
url: this._url,
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -55,6 +62,12 @@ export class JsonRpcConnector implements VegaConnector {
|
||||
this.client = new WalletClient({
|
||||
address: url,
|
||||
token: this.token ?? undefined,
|
||||
onTokenChange: (token) =>
|
||||
setConfig({
|
||||
token,
|
||||
url,
|
||||
connector: 'jsonRpc',
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
@ -76,13 +89,8 @@ export class JsonRpcConnector implements VegaConnector {
|
||||
}
|
||||
|
||||
try {
|
||||
const { result } = await this.client.ConnectWallet();
|
||||
setConfig({
|
||||
token: result.token,
|
||||
connector: 'jsonRpc',
|
||||
url: this._url,
|
||||
});
|
||||
return result;
|
||||
await this.client.ConnectWallet();
|
||||
return null;
|
||||
} catch (err) {
|
||||
const clientErr =
|
||||
err instanceof WalletClientError && err.code === 3001
|
||||
|
@ -36,7 +36,7 @@
|
||||
"@sentry/nextjs": "^6.19.3",
|
||||
"@sentry/react": "^6.19.2",
|
||||
"@sentry/tracing": "^6.19.2",
|
||||
"@vegaprotocol/wallet-client": "0.1.5",
|
||||
"@vegaprotocol/wallet-client": "0.1.8",
|
||||
"@walletconnect/ethereum-provider": "^1.7.5",
|
||||
"@web3-react/core": "8.0.20-beta.0",
|
||||
"@web3-react/metamask": "8.0.16-beta.0",
|
||||
|
@ -42,11 +42,11 @@ GatewayEnabled = true
|
||||
[Broker.SocketConfig]
|
||||
Port = {{add 300 .NodeNumber}}5
|
||||
|
||||
[DeHistory]
|
||||
[NetworkHistory]
|
||||
Enabled = true
|
||||
[DeHistory.Store]
|
||||
PeerID = "{{.GetDehistoryPeerID .NodeNumber}}"
|
||||
PrivKey = "{{.GetDehistoryPrivKey .NodeNumber}}"
|
||||
[NetworkHistory.Store]
|
||||
PeerID = "{{.GetNetworkHistoryPeerID .NodeNumber}}"
|
||||
PrivKey = "{{.GetNetworkHistoryPrivKey .NodeNumber}}"
|
||||
|
||||
BootstrapPeers = [{{- range $i, $peer := .IPSFPeers -}}
|
||||
{{- if ne $i 0 }},{{end -}}
|
||||
|
@ -41,15 +41,15 @@ GatewayEnabled = true
|
||||
[Broker.SocketConfig]
|
||||
Port = {{add 300 .NodeNumber}}5
|
||||
|
||||
[DeHistory]
|
||||
[NetworkHistory]
|
||||
Level = "Info"
|
||||
Enabled = true
|
||||
WipeOnStartup = true
|
||||
AddSnapshotsToStore = true
|
||||
AddSnapshotsInterval = "5s"
|
||||
[DeHistory.Store]
|
||||
PeerID = "{{.GetDehistoryPeerID .NodeNumber}}"
|
||||
PrivKey = "{{.GetDehistoryPrivKey .NodeNumber}}"
|
||||
[NetworkHistory.Store]
|
||||
PeerID = "{{.GetNetworkHistoryPeerID .NodeNumber}}"
|
||||
PrivKey = "{{.GetNetworkHistoryPrivKey .NodeNumber}}"
|
||||
|
||||
BootstrapPeers = [{{- range $i, $peer := .IPSFPeers -}}
|
||||
{{- if ne $i 0 }},{{end -}}
|
||||
@ -60,6 +60,6 @@ GatewayEnabled = true
|
||||
SwarmPort = {{add 400 .NodeNumber}}5
|
||||
StartWebUI = false
|
||||
WebUIPort = {{add 500 .NodeNumber}}5
|
||||
[DeHistory.Snapshot]
|
||||
[NetworkHistory.Snapshot]
|
||||
PanicOnSnapshotCreationError = true
|
||||
WaitForCreationLockTimeout = "5s"
|
||||
|
@ -7559,10 +7559,10 @@
|
||||
"@typescript-eslint/types" "5.40.0"
|
||||
eslint-visitor-keys "^3.3.0"
|
||||
|
||||
"@vegaprotocol/wallet-client@0.1.5":
|
||||
version "0.1.5"
|
||||
resolved "https://registry.yarnpkg.com/@vegaprotocol/wallet-client/-/wallet-client-0.1.5.tgz#9d72a7fc9ceb9767f5119c9b7eebe29a2c30f682"
|
||||
integrity sha512-7FmIBFxissr3h2QsEjvD+HXEXJ3u/oaVUg055IgZ08dmy1+4Nx22BOffFyidLBmaH1xJYjyiqxHnhLGnN5BfwA==
|
||||
"@vegaprotocol/wallet-client@0.1.8":
|
||||
version "0.1.8"
|
||||
resolved "https://registry.yarnpkg.com/@vegaprotocol/wallet-client/-/wallet-client-0.1.8.tgz#38ca8566d78b9f6694b12ad9364bb34d6482935d"
|
||||
integrity sha512-FVvDvvlccKyXn0ujhivPUCVnkZYQJxtI1q8OgipNnbmAjU1mLyeuRTBw0Isu330yPI1KppNbW6Qicd8OTHBmxw==
|
||||
dependencies:
|
||||
express "4.18.2"
|
||||
nanoid "3.3.4"
|
||||
|
Loading…
Reference in New Issue
Block a user