ChainQueriesProtocol -> ChainTransactionsProtocol (#14)
This commit is contained in:
+2
-2
@@ -36,8 +36,8 @@
|
||||
"@cosmjs/proto-signing": "^0.31.0",
|
||||
"@cosmjs/stargate": "^0.31.0",
|
||||
"@cosmjs/tendermint-rpc": "^0.31.0",
|
||||
"@dydxprotocol/abacus": "^0.3.10",
|
||||
"@dydxprotocol/v4-client-js": "^0.30.3",
|
||||
"@dydxprotocol/abacus": "^0.4.1",
|
||||
"@dydxprotocol/v4-client-js": "^0.32.0",
|
||||
"@dydxprotocol/v4-localization": "^0.0.16",
|
||||
"@ethersproject/providers": "^5.7.2",
|
||||
"@js-joda/core": "^5.5.3",
|
||||
|
||||
Generated
+12
-12
@@ -1,9 +1,5 @@
|
||||
lockfileVersion: '6.0'
|
||||
|
||||
settings:
|
||||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
dependencies:
|
||||
'@0xsquid/sdk':
|
||||
specifier: ^1.7.2
|
||||
@@ -27,11 +23,11 @@ dependencies:
|
||||
specifier: ^0.31.0
|
||||
version: 0.31.0
|
||||
'@dydxprotocol/abacus':
|
||||
specifier: ^0.3.10
|
||||
version: 0.3.10
|
||||
specifier: ^0.4.1
|
||||
version: 0.4.1
|
||||
'@dydxprotocol/v4-client-js':
|
||||
specifier: ^0.30.3
|
||||
version: 0.30.3
|
||||
specifier: ^0.32.0
|
||||
version: 0.32.0
|
||||
'@dydxprotocol/v4-localization':
|
||||
specifier: ^0.0.16
|
||||
version: 0.0.16
|
||||
@@ -1146,8 +1142,8 @@ packages:
|
||||
resolution: {integrity: sha512-RpfLEtTlyIxeNPGKcokS+p3BZII/Q3bYxryFRglh5H3A3T8q9fsLYm72VYAMEOOIBLEa8o93kFLiBDUWKrwXZA==}
|
||||
dev: true
|
||||
|
||||
/@dydxprotocol/abacus@0.3.10:
|
||||
resolution: {integrity: sha512-CJV6zyoQLAoDWJdgLbP1Y2QYvSPybCGpykQY+WEWk4kQKnZkjxz25LPL0b8I9LrNDt2JknOxPJfAoUDXJPfNkg==}
|
||||
/@dydxprotocol/abacus@0.4.1:
|
||||
resolution: {integrity: sha512-+2uKbTYBM6h7e3L8OX6gYwbqfIPtzwWUz4Onw6UCk7oD966Znwoky/PQmVDGjIcxw0BGWJUfHmF3Qd3t973tLQ==}
|
||||
dev: false
|
||||
|
||||
/@dydxprotocol/dydxjs@0.3.0:
|
||||
@@ -1167,8 +1163,8 @@ packages:
|
||||
- utf-8-validate
|
||||
dev: false
|
||||
|
||||
/@dydxprotocol/v4-client-js@0.30.3:
|
||||
resolution: {integrity: sha512-h9nB2cU+6sWwfOTQz6sMKZZxVa/Iwp1JciUqKi5HDUyWl/4wfbczDlUqbMUUeXgBgfbb9CImxn+PjF0v7lcD5A==}
|
||||
/@dydxprotocol/v4-client-js@0.32.0:
|
||||
resolution: {integrity: sha512-KvKActMgWLcsRQ7RQhpi/F8xeQ7MWUp3G5+4IPNZ4wyRwAxDSbcrfYbTetI/IesHyelRPSeYxam9eYq3wXwZ1A==}
|
||||
dependencies:
|
||||
'@cosmjs/amino': 0.30.1
|
||||
'@cosmjs/proto-signing': 0.30.1
|
||||
@@ -15862,3 +15858,7 @@ packages:
|
||||
release-it: 15.11.0
|
||||
semver: 7.5.1
|
||||
dev: false
|
||||
|
||||
settings:
|
||||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
+10
-4
@@ -8,8 +8,8 @@ export type Nullable<T> = T | null | undefined;
|
||||
// ------ V4 Protocols ------ //
|
||||
export const IOImplementations = Abacus.exchange.dydx.abacus.utils.IOImplementations;
|
||||
export const UIImplementations = Abacus.exchange.dydx.abacus.utils.UIImplementations;
|
||||
export type AbacusDydxChainQueriesProtocol = Omit<
|
||||
Abacus.exchange.dydx.abacus.protocols.DYDXChainQueriesProtocol,
|
||||
export type AbacusDYDXChainTransactionsProtocol = Omit<
|
||||
Abacus.exchange.dydx.abacus.protocols.DYDXChainTransactionsProtocol,
|
||||
'__doNotUseOrImplementIt'
|
||||
>;
|
||||
export type AbacusRestProtocol = Omit<
|
||||
@@ -50,6 +50,10 @@ export const QueryType = Abacus.exchange.dydx.abacus.protocols.QueryType;
|
||||
const queryTypes = [...QueryType.values()] as const;
|
||||
export type QueryTypes = (typeof queryTypes)[number];
|
||||
|
||||
export const TransactionType = Abacus.exchange.dydx.abacus.protocols.TransactionType;
|
||||
const transactionTypes = [...TransactionType.values()] as const;
|
||||
export type TransactionTypes = (typeof transactionTypes)[number];
|
||||
|
||||
export type NetworkConfig = {
|
||||
chainId: string;
|
||||
indexerUrl: string;
|
||||
@@ -104,8 +108,10 @@ export type ClosePositionInputs = Abacus.exchange.dydx.abacus.output.input.Close
|
||||
export type TradeInputSummary = Abacus.exchange.dydx.abacus.output.input.TradeInputSummary;
|
||||
export type TransferInputs = Abacus.exchange.dydx.abacus.output.input.TransferInput;
|
||||
export type InputError = Abacus.exchange.dydx.abacus.output.input.ValidationError;
|
||||
export type TransferInputTokenResource = Abacus.exchange.dydx.abacus.output.input.TransferInputTokenResource;
|
||||
export type TransferInputChainResource = Abacus.exchange.dydx.abacus.output.input.TransferInputChainResource;
|
||||
export type TransferInputTokenResource =
|
||||
Abacus.exchange.dydx.abacus.output.input.TransferInputTokenResource;
|
||||
export type TransferInputChainResource =
|
||||
Abacus.exchange.dydx.abacus.output.input.TransferInputChainResource;
|
||||
export type SelectionOption = Abacus.exchange.dydx.abacus.output.input.SelectionOption;
|
||||
export const ErrorType = Abacus.exchange.dydx.abacus.output.input.ErrorType;
|
||||
export const InputSelectionOption = Abacus.exchange.dydx.abacus.output.input.SelectionOption;
|
||||
|
||||
@@ -3,7 +3,6 @@ import Long from 'long';
|
||||
|
||||
import {
|
||||
CompositeClient,
|
||||
FaucetClient,
|
||||
IndexerConfig,
|
||||
Network,
|
||||
NetworkOptimizer,
|
||||
@@ -11,14 +10,15 @@ import {
|
||||
} from '@dydxprotocol/v4-client-js';
|
||||
|
||||
import {
|
||||
type AbacusDydxChainQueriesProtocol,
|
||||
type AbacusDYDXChainTransactionsProtocol,
|
||||
QueryType,
|
||||
type QueryTypes,
|
||||
type TransactionTypes,
|
||||
} from '@/constants/abacus';
|
||||
|
||||
import { log } from '../telemetry';
|
||||
|
||||
class DydxChainQueries implements AbacusDydxChainQueriesProtocol {
|
||||
class DydxChainTransactions implements AbacusDYDXChainTransactionsProtocol {
|
||||
private compositeClient: CompositeClient | undefined;
|
||||
|
||||
constructor() {
|
||||
@@ -85,6 +85,16 @@ class DydxChainQueries implements AbacusDydxChainQueriesProtocol {
|
||||
throw new Error(`Unsupported data type: ${typeof x}`);
|
||||
}
|
||||
|
||||
|
||||
async transaction(
|
||||
type: TransactionTypes,
|
||||
paramsInJson: Abacus.Nullable<string>,
|
||||
callback: (p0: Abacus.Nullable<string>) => void
|
||||
): Promise<void> {
|
||||
// To be implemented
|
||||
return;
|
||||
}
|
||||
|
||||
async get(
|
||||
type: QueryTypes,
|
||||
paramsInJson: Abacus.Nullable<string>,
|
||||
@@ -131,10 +141,10 @@ class DydxChainQueries implements AbacusDydxChainQueriesProtocol {
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
log('AbacusDydxChainQueries/get', error);
|
||||
log('DydxChainTransactions/get', error);
|
||||
callback(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default DydxChainQueries;
|
||||
export default DydxChainTransactions;
|
||||
@@ -31,7 +31,7 @@ import { getTransferInputs } from '@/state/inputsSelectors';
|
||||
|
||||
import AbacusRest from './rest';
|
||||
import AbacusWebsocket from './websocket';
|
||||
import AbacusChainQuery from './dydxChainQueries';
|
||||
import AbacusChainTransaction from './dydxChainTransactions';
|
||||
import AbacusStateNotifier from './stateNotification';
|
||||
import AbacusLocalizer from './localizer';
|
||||
import AbacusFormatter from './formatter';
|
||||
@@ -58,7 +58,7 @@ class AbacusStateManager {
|
||||
// @ts-ignore
|
||||
new AbacusRest(),
|
||||
this.websocket,
|
||||
new AbacusChainQuery(),
|
||||
new AbacusChainTransaction(),
|
||||
null,
|
||||
new AbacusThreading(),
|
||||
new CoroutineTimer(),
|
||||
@@ -94,15 +94,15 @@ class AbacusStateManager {
|
||||
disconnectAccount = () => {
|
||||
this.stateManager.accountAddress = null;
|
||||
};
|
||||
|
||||
|
||||
attemptDisconnectAccount = () => {
|
||||
const state = this.store?.getState();
|
||||
const { type: transferType }= (state && getTransferInputs(state)) || {};
|
||||
const { type: transferType } = (state && getTransferInputs(state)) || {};
|
||||
// we don't want to disconnect the account if we switch network during the deposit form
|
||||
if (transferType?.rawValue !== TransferType.deposit.rawValue) {
|
||||
this.disconnectAccount();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// ------ Input Values ------ //
|
||||
clearTradeInputValues = ({ shouldResetSize }: { shouldResetSize?: boolean } = {}) => {
|
||||
|
||||
Reference in New Issue
Block a user