Skip to content

Commit

Permalink
Prettier fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lukecaan committed Dec 10, 2024
1 parent 3f25f6f commit 6c69091
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 123 deletions.
2 changes: 1 addition & 1 deletion sdk/src/accounts/grpcProgramAccountSubscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
} from '../isomorphic/grpc';

export class grpcProgramAccountSubscriber<
T,
T
> extends WebSocketProgramAccountSubscriber<T> {
client: Client;
stream: ClientDuplexStream<SubscribeRequest, SubscribeUpdate>;
Expand Down
33 changes: 15 additions & 18 deletions sdk/src/accounts/webSocketAccountSubscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,26 +98,23 @@ export class WebSocketAccountSubscriber<T> implements AccountSubscriber<T> {
if (!this.onChange) {
throw new Error('onChange callback function must be set');
}
this.timeoutId = setTimeout(
async () => {
if (this.isUnsubscribing) {
// If we are in the process of unsubscribing, do not attempt to resubscribe
return;
}
this.timeoutId = setTimeout(async () => {
if (this.isUnsubscribing) {
// If we are in the process of unsubscribing, do not attempt to resubscribe
return;
}

if (this.receivingData) {
if (this.resubOpts?.logResubMessages) {
console.log(
`No ws data from ${this.accountName} in ${this.resubOpts.resubTimeoutMs}ms, resubscribing`
);
}
await this.unsubscribe(true);
this.receivingData = false;
await this.subscribe(this.onChange);
if (this.receivingData) {
if (this.resubOpts?.logResubMessages) {
console.log(
`No ws data from ${this.accountName} in ${this.resubOpts.resubTimeoutMs}ms, resubscribing`
);
}
},
this.resubOpts?.resubTimeoutMs
);
await this.unsubscribe(true);
this.receivingData = false;
await this.subscribe(this.onChange);
}
}, this.resubOpts?.resubTimeoutMs);
}

async fetch(): Promise<void> {
Expand Down
33 changes: 15 additions & 18 deletions sdk/src/accounts/webSocketProgramAccountSubscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,26 +97,23 @@ export class WebSocketProgramAccountSubscriber<T>
if (!this.onChange) {
throw new Error('onChange callback function must be set');
}
this.timeoutId = setTimeout(
async () => {
if (this.isUnsubscribing) {
// If we are in the process of unsubscribing, do not attempt to resubscribe
return;
}
this.timeoutId = setTimeout(async () => {
if (this.isUnsubscribing) {
// If we are in the process of unsubscribing, do not attempt to resubscribe
return;
}

if (this.receivingData) {
if (this.resubOpts?.logResubMessages) {
console.log(
`No ws data from ${this.subscriptionName} in ${this.resubOpts?.resubTimeoutMs}ms, resubscribing`
);
}
await this.unsubscribe(true);
this.receivingData = false;
await this.subscribe(this.onChange);
if (this.receivingData) {
if (this.resubOpts?.logResubMessages) {
console.log(
`No ws data from ${this.subscriptionName} in ${this.resubOpts?.resubTimeoutMs}ms, resubscribing`
);
}
},
this.resubOpts?.resubTimeoutMs
);
await this.unsubscribe(true);
this.receivingData = false;
await this.subscribe(this.onChange);
}
}, this.resubOpts?.resubTimeoutMs);
}

handleRpcResponse(
Expand Down
10 changes: 6 additions & 4 deletions sdk/src/driftClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3914,8 +3914,9 @@ export class DriftClient {
subAccountId?: number
): Promise<TransactionSignature> {
const { txSig } = await this.sendTransaction(
(await this.preparePlaceOrdersTx(params, txParams, subAccountId))
.placeOrdersTx,
(
await this.preparePlaceOrdersTx(params, txParams, subAccountId)
).placeOrdersTx,
[],
this.opts,
false
Expand Down Expand Up @@ -4108,8 +4109,9 @@ export class DriftClient {
subAccountId?: number
): Promise<TransactionSignature> {
const { txSig, slot } = await this.sendTransaction(
(await this.preparePlaceSpotOrderTx(orderParams, txParams, subAccountId))
.placeSpotOrderTx,
(
await this.preparePlaceSpotOrderTx(orderParams, txParams, subAccountId)
).placeSpotOrderTx,
[],
this.opts,
false
Expand Down
9 changes: 6 additions & 3 deletions sdk/src/factory/bigNum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,15 +405,18 @@ export class BigNum {
// Get significant digits starting after leading zeros
const significantPart = rightSide.slice(leadingZeros);
let significantDigits = significantPart.slice(0, fixedPrecision);

// Remove trailing zeros if not requested
if (!trailingZeroes) {
significantDigits = significantDigits.replace(/0+$/, '');
}

// Only return result if we have significant digits
if (significantDigits.length > 0) {
const result = `${isNeg ? '-' : ''}0${BigNum.delim}${rightSide.slice(0, leadingZeros)}${significantDigits}`;
const result = `${isNeg ? '-' : ''}0${BigNum.delim}${rightSide.slice(
0,
leadingZeros
)}${significantDigits}`;
return result;
}
}
Expand Down
Loading

0 comments on commit 6c69091

Please sign in to comment.