add abacusFileSystem protocol

This commit is contained in:
jaredvu
2023-08-28 08:13:29 -07:00
parent 983128fd74
commit 628041e537
7 changed files with 56 additions and 12 deletions
+1 -1
View File
@@ -35,7 +35,7 @@
"@cosmjs/encoding": "^0.31.0",
"@cosmjs/proto-signing": "^0.31.0",
"@cosmjs/stargate": "^0.31.0",
"@dydxprotocol/abacus": "^0.2.28",
"@dydxprotocol/abacus": "^0.3.7",
"@cosmjs/tendermint-rpc": "^0.31.0",
"@dydxprotocol/v4-client": "^0.29.0",
"@ethersproject/providers": "^5.7.2",
+11 -9
View File
@@ -27,8 +27,8 @@ dependencies:
specifier: ^0.31.0
version: 0.31.0
'@dydxprotocol/abacus':
specifier: ^0.2.28
version: 0.2.28
specifier: file:/Users/jaredvu/Documents/v4-abacus/build/packages/dydxprotocol-abacus-0.3.7.tgz
version: file:../v4-abacus/build/packages/dydxprotocol-abacus-0.3.7.tgz
'@dydxprotocol/v4-client':
specifier: ^0.29.0
version: 0.29.0
@@ -1143,10 +1143,6 @@ packages:
resolution: {integrity: sha512-RpfLEtTlyIxeNPGKcokS+p3BZII/Q3bYxryFRglh5H3A3T8q9fsLYm72VYAMEOOIBLEa8o93kFLiBDUWKrwXZA==}
dev: true
/@dydxprotocol/abacus@0.2.28:
resolution: {integrity: sha512-mGmhwQM8aiV/cD+d3lvW76ysoPN7uVsDyAiVcRdzGqgj+gbM0IIJDYXG14xHruOTi+gK1Aga5MUz2pdvmPDhYA==}
dev: false
/@dydxprotocol/dydxjs@0.3.0:
resolution: {integrity: sha512-ygNeBs0f3H7sJk1qLUjfNwaXgc5TmjD+qZf7BFDbi7+boHJI9xuOWrGpjfBo7OTUZxS6O5jZG323CgU5XqMSPw==}
dependencies:
@@ -8277,7 +8273,7 @@ packages:
resolution: {integrity: sha512-WIdaQ8uW1vIbYvNnAVunkC6yxTrneJC7VQ5UUQ0kuw8b0C0A39KTIpoQHCfc8tV7o9vF4niwRhdXEdfAgQEsQQ==}
dependencies:
cosmos-directory-types: 0.0.6
node-fetch-native: 1.2.0
node-fetch-native: 1.4.0
dev: false
/cosmos-directory-types@0.0.6:
@@ -12462,8 +12458,8 @@ packages:
resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==}
engines: {node: '>=10.5.0'}
/node-fetch-native@1.2.0:
resolution: {integrity: sha512-5IAMBTl9p6PaAjYCnMv5FmqIF6GcZnawAVnzaCG0rX2aYZJ4CxEkZNtVPuTRug7fL7wyM5BQYTlAzcyMPi6oTQ==}
/node-fetch-native@1.4.0:
resolution: {integrity: sha512-F5kfEj95kX8tkDhUCYdV8dg3/8Olx/94zB8+ZNthFs6Bz31UpUi8Xh40TN3thLwXgrwXry1pEg9lJ++tLWTcqA==}
dev: false
/node-fetch@2.6.12:
@@ -15840,6 +15836,12 @@ packages:
resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==}
dev: true
file:../v4-abacus/build/packages/dydxprotocol-abacus-0.3.7.tgz:
resolution: {integrity: sha512-omUiVHcT/tHWeXKgZTk1WW8LDVHI+2yxXNM6+B756liRY/t1JwUkRzwplp09U2+mNo/FenejHFtWZ0qd+W79iw==, tarball: file:../v4-abacus/build/packages/dydxprotocol-abacus-0.3.7.tgz}
name: '@dydxprotocol/abacus'
version: 0.3.7
dev: false
github.com/release-it/conventional-changelog/a4acfeac76369937a6566d698a5ae9180eceb413(release-it@15.11.0):
resolution: {tarball: https://codeload.github.com/release-it/conventional-changelog/tar.gz/a4acfeac76369937a6566d698a5ae9180eceb413}
id: github.com/release-it/conventional-changelog/a4acfeac76369937a6566d698a5ae9180eceb413
+9
View File
@@ -36,6 +36,12 @@ export type AbacusThreadingProtocol = Omit<
Abacus.exchange.dydx.abacus.protocols.ThreadingProtocol,
'__doNotUseOrImplementIt'
>;
export type AbacusFileSystemProtocol = Omit<
Abacus.exchange.dydx.abacus.protocols.FileSystemProtocol,
'__doNotUseOrImplementIt'
>;
export type FileLocation = Abacus.exchange.dydx.abacus.protocols.FileLocation;
export type ThreadingType = Abacus.exchange.dydx.abacus.protocols.ThreadingType;
export const CoroutineTimer = Abacus.exchange.dydx.abacus.utils.CoroutineTimer;
@@ -175,6 +181,9 @@ export const RiskLevel = Abacus.exchange.dydx.abacus.utils.RiskLevel;
const riskLevels = [...RiskLevel.values()] as const;
export type RiskLevels = (typeof riskLevels)[number];
// ------ Notifications ------ //
export type AbacusNotification = Abacus.exchange.dydx.abacus.output.Notification;
// ------ Enum Conversions ------ //
type IfEquals<X, Y, A, B> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2
? A
+1 -1
View File
@@ -1,7 +1,7 @@
export enum DydxV4Network {
V4Mainnet = 'dydxprotocol-mainnet',
V4Staging = 'dydxprotocol-staging',
V4Testnet2 = 'dydxprotocol-testnet-2',
V4Testnet2 = 'dydxprotocol-testnet',
V4Local = 'dydxprotocol-dev',
}
+19
View File
@@ -0,0 +1,19 @@
import type { AbacusFileSystemProtocol, FileLocation, Nullable } from '@/constants/abacus';
class AbacusFileSystem implements AbacusFileSystemProtocol {
readTextFile(location: FileLocation, path: string): Nullable<string> {
console.log({ location, path });
if (path === 'config/staging/environments.json') {
console.log('ENVIRONMENT_CONFIGS', globalThis.ENVIRONMENT_CONFIGS);
return JSON.stringify(globalThis.ENVIRONMENT_CONFIGS);
}
return null;
}
writeTextFile(path: string, text: string): boolean {
return true;
}
}
export default AbacusFileSystem;
+4 -1
View File
@@ -34,6 +34,7 @@ import AbacusStateNotifier from './stateNotification';
import AbacusLocalizer from './localizer';
import AbacusFormatter from './formatter';
import AbacusThreading from './threading';
import AbacusFileSystem from './filesystem';
import { LocaleSeparators } from '../numbers';
class AbacusStateManager {
@@ -60,7 +61,7 @@ class AbacusStateManager {
null,
new AbacusThreading(),
new CoroutineTimer(),
null
new AbacusFileSystem()
);
const uiImplementations = new UIImplementations(
@@ -70,6 +71,8 @@ class AbacusStateManager {
);
this.stateManager = new AsyncAbacusStateManager(
import.meta.env.SHARED_RESOURCES_URI,
'config/staging/environments.json',
ioImplementations,
uiImplementations,
// @ts-ignore
+11
View File
@@ -1,5 +1,8 @@
import { kollections } from '@dydxprotocol/abacus';
import type {
AbacusApiState,
AbacusNotification,
AbacusStateNotificationProtocol,
Asset,
Nullable,
@@ -35,6 +38,14 @@ class AbacusStateNotifier implements AbacusStateNotificationProtocol {
this.store = undefined;
}
environmentsChanged(): void {
console.log('environments changed');
}
notificationsChanged(notifications: kollections.List<AbacusNotification>): void {
console.log(notifications.toArray());
}
stateChanged(
updatedState: Nullable<PerpetualState>,
incomingChanges: Nullable<PerpetualStateChanges>