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