Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7b036d880b | ||
|
|
0406d05200 |
+1
-1
@@ -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": "file:/Users/jaredvu/Documents/abacus/build/packages/dydxprotocol-abacus-0.2.28.tgz",
|
||||
"@cosmjs/tendermint-rpc": "^0.31.0",
|
||||
"@dydxprotocol/v4-client": "^0.29.0",
|
||||
"@ethersproject/providers": "^5.7.2",
|
||||
|
||||
Generated
+11
-9
@@ -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/abacus/build/packages/dydxprotocol-abacus-0.2.28.tgz
|
||||
version: file:../abacus/build/packages/dydxprotocol-abacus-0.2.28.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.3.3
|
||||
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.3.3:
|
||||
resolution: {integrity: sha512-dw7R7GkbPkgC2jfEtJjvF2t3eJ/2+Pj1crKjbowhgnkMsuehYx6LUvfDG4FmWX20KYddJCZbQG8kZE9LNrf5GQ==}
|
||||
dev: false
|
||||
|
||||
/node-fetch@2.6.12:
|
||||
@@ -15840,6 +15836,12 @@ packages:
|
||||
resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==}
|
||||
dev: true
|
||||
|
||||
file:../abacus/build/packages/dydxprotocol-abacus-0.2.28.tgz:
|
||||
resolution: {integrity: sha512-tBZRaSBATUsI+Z5x9/iwg0I2hEINTI2UGlIw5oGNFm1MRgZqjHAr3mRzsmYg6jaCqjOgXWIGGAY9QjrwQU99qw==, tarball: file:../abacus/build/packages/dydxprotocol-abacus-0.2.28.tgz}
|
||||
name: '@dydxprotocol/abacus'
|
||||
version: 0.2.28
|
||||
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
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
} from '@/constants/abacus';
|
||||
|
||||
import { log } from '../telemetry';
|
||||
import { bytesToBigInt } from '../numbers';
|
||||
|
||||
class DydxChainQueries implements AbacusDydxChainQueriesProtocol {
|
||||
private compositeClient: CompositeClient | undefined;
|
||||
@@ -33,30 +34,34 @@ class DydxChainQueries implements AbacusDydxChainQueriesProtocol {
|
||||
faucetUrl: Nullable<string> | undefined,
|
||||
callback: (p0: Nullable<string>) => void
|
||||
): Promise<void> {
|
||||
this.compositeClient = await CompositeClient.connect(
|
||||
new Network(
|
||||
chainId,
|
||||
new IndexerConfig(indexerUrl, indexerSocketUrl),
|
||||
new ValidatorConfig(validatorUrl, chainId, {
|
||||
broadcastPollIntervalMs: 3_000,
|
||||
broadcastTimeoutMs: 60_000,
|
||||
})
|
||||
)
|
||||
);
|
||||
try {
|
||||
this.compositeClient = await CompositeClient.connect(
|
||||
new Network(
|
||||
chainId,
|
||||
new IndexerConfig(indexerUrl, indexerSocketUrl),
|
||||
new ValidatorConfig(validatorUrl, chainId, {
|
||||
broadcastPollIntervalMs: 3_000,
|
||||
broadcastTimeoutMs: 60_000,
|
||||
})
|
||||
)
|
||||
);
|
||||
} catch (error) {
|
||||
log('AbacusDydxChainQueries/connectNetwork', error);
|
||||
} finally {
|
||||
// Dispatch custom event to notify other parts of the app that the network has been connected
|
||||
const customEvent = new CustomEvent('abacus:connectNetwork', {
|
||||
detail: {
|
||||
indexerUrl,
|
||||
indexerSocketUrl,
|
||||
validatorUrl,
|
||||
chainId,
|
||||
faucetUrl,
|
||||
},
|
||||
});
|
||||
|
||||
// Dispatch custom event to notify other parts of the app that the network has been connected
|
||||
const customEvent = new CustomEvent('abacus:connectNetwork', {
|
||||
detail: {
|
||||
indexerUrl,
|
||||
indexerSocketUrl,
|
||||
validatorUrl,
|
||||
chainId,
|
||||
faucetUrl,
|
||||
},
|
||||
});
|
||||
|
||||
globalThis.dispatchEvent(customEvent);
|
||||
callback(JSON.stringify({ success: true }));
|
||||
globalThis.dispatchEvent(customEvent);
|
||||
callback(JSON.stringify({ success: true }));
|
||||
}
|
||||
}
|
||||
|
||||
parseToPrimitives<T>(x: T): T {
|
||||
@@ -68,6 +73,10 @@ class DydxChainQueries implements AbacusDydxChainQueriesProtocol {
|
||||
return x.map((item) => this.parseToPrimitives(item)) as T;
|
||||
}
|
||||
|
||||
if (x instanceof Uint8Array) {
|
||||
return bytesToBigInt(x).toString() as T;
|
||||
}
|
||||
|
||||
if (Long.isLong(x)) {
|
||||
return x.toString() as T;
|
||||
}
|
||||
@@ -106,6 +115,13 @@ class DydxChainQueries implements AbacusDydxChainQueriesProtocol {
|
||||
);
|
||||
callback(JSON.stringify({ url: optimalNode }));
|
||||
break;
|
||||
case QueryType.EquityTiers:
|
||||
const equityTiers =
|
||||
await this.compositeClient?.validatorClient.get.getEquityTierLimitConfiguration();
|
||||
const parsedEquityTiers = this.parseToPrimitives(equityTiers);
|
||||
console.log(parsedEquityTiers);
|
||||
callback(JSON.stringify(parsedEquityTiers));
|
||||
break;
|
||||
case QueryType.FeeTiers:
|
||||
const feeTiers = await this.compositeClient?.validatorClient.get.getFeeTiers();
|
||||
const parsedFeeTiers = this.parseToPrimitives(feeTiers);
|
||||
|
||||
@@ -65,3 +65,17 @@ export const getSeparator = ({
|
||||
Intl.NumberFormat(locale)
|
||||
.formatToParts(1000.1)
|
||||
.find?.((part) => part.type === separatorType)?.value;
|
||||
|
||||
/**
|
||||
* Converts a byte array (representing an arbitrary-size signed integer) into a bigint.
|
||||
* @param u Array of bytes represented as a Uint8Array.
|
||||
*/
|
||||
export function bytesToBigInt(u: Uint8Array): bigint {
|
||||
if (u.length <= 1) {
|
||||
return BigInt(0);
|
||||
}
|
||||
const negated: boolean = (u[0] & 1) === 1;
|
||||
const hex: string = Buffer.from(u.slice(1)).toString('hex');
|
||||
const abs: bigint = BigInt(`0x${hex}`);
|
||||
return negated ? -abs : abs;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user