From 2b2330c6f6a77245ab68d7c9392b9fbe37159405 Mon Sep 17 00:00:00 2001 From: Luke Steyn Date: Fri, 3 Jan 2025 08:53:51 +0800 Subject: [PATCH] Prettify --- .../accounts/grpcProgramAccountSubscriber.ts | 2 +- .../accounts/webSocketAccountSubscriber.ts | 33 +++-- .../webSocketProgramAccountSubscriber.ts | 33 +++-- sdk/src/driftClient.ts | 10 +- sdk/src/marinade/types.ts | 140 +++++++++--------- sdk/src/tx/txHandler.ts | 10 +- sdk/src/tx/types.ts | 5 +- 7 files changed, 120 insertions(+), 113 deletions(-) diff --git a/sdk/src/accounts/grpcProgramAccountSubscriber.ts b/sdk/src/accounts/grpcProgramAccountSubscriber.ts index 164153ed1..972e47fb1 100644 --- a/sdk/src/accounts/grpcProgramAccountSubscriber.ts +++ b/sdk/src/accounts/grpcProgramAccountSubscriber.ts @@ -14,7 +14,7 @@ import { } from '../isomorphic/grpc'; export class grpcProgramAccountSubscriber< - T + T, > extends WebSocketProgramAccountSubscriber { client: Client; stream: ClientDuplexStream; diff --git a/sdk/src/accounts/webSocketAccountSubscriber.ts b/sdk/src/accounts/webSocketAccountSubscriber.ts index 5cc686dce..fc2b61bb2 100644 --- a/sdk/src/accounts/webSocketAccountSubscriber.ts +++ b/sdk/src/accounts/webSocketAccountSubscriber.ts @@ -98,23 +98,26 @@ export class WebSocketAccountSubscriber implements AccountSubscriber { 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` - ); + 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); } - await this.unsubscribe(true); - this.receivingData = false; - await this.subscribe(this.onChange); - } - }, this.resubOpts?.resubTimeoutMs); + }, + this.resubOpts?.resubTimeoutMs + ); } async fetch(): Promise { diff --git a/sdk/src/accounts/webSocketProgramAccountSubscriber.ts b/sdk/src/accounts/webSocketProgramAccountSubscriber.ts index adb86e47c..ef3543a3d 100644 --- a/sdk/src/accounts/webSocketProgramAccountSubscriber.ts +++ b/sdk/src/accounts/webSocketProgramAccountSubscriber.ts @@ -97,23 +97,26 @@ export class WebSocketProgramAccountSubscriber 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` - ); + 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); } - await this.unsubscribe(true); - this.receivingData = false; - await this.subscribe(this.onChange); - } - }, this.resubOpts?.resubTimeoutMs); + }, + this.resubOpts?.resubTimeoutMs + ); } handleRpcResponse( diff --git a/sdk/src/driftClient.ts b/sdk/src/driftClient.ts index 172b07244..f2bfd28a7 100644 --- a/sdk/src/driftClient.ts +++ b/sdk/src/driftClient.ts @@ -3936,9 +3936,8 @@ export class DriftClient { subAccountId?: number ): Promise { const { txSig } = await this.sendTransaction( - ( - await this.preparePlaceOrdersTx(params, txParams, subAccountId) - ).placeOrdersTx, + (await this.preparePlaceOrdersTx(params, txParams, subAccountId)) + .placeOrdersTx, [], this.opts, false @@ -4156,9 +4155,8 @@ export class DriftClient { subAccountId?: number ): Promise { const { txSig, slot } = await this.sendTransaction( - ( - await this.preparePlaceSpotOrderTx(orderParams, txParams, subAccountId) - ).placeSpotOrderTx, + (await this.preparePlaceSpotOrderTx(orderParams, txParams, subAccountId)) + .placeSpotOrderTx, [], this.opts, false diff --git a/sdk/src/marinade/types.ts b/sdk/src/marinade/types.ts index 57561d670..58e9e7afe 100644 --- a/sdk/src/marinade/types.ts +++ b/sdk/src/marinade/types.ts @@ -57,7 +57,7 @@ export type MarinadeFinance = { name: 'msolLeg'; isMut: false; isSigner: false; - } + }, ]; }, { @@ -74,7 +74,7 @@ export type MarinadeFinance = { name: 'rent'; isMut: false; isSigner: false; - } + }, ]; args: [ { @@ -82,7 +82,7 @@ export type MarinadeFinance = { type: { defined: 'InitializeData'; }; - } + }, ]; }, { @@ -97,7 +97,7 @@ export type MarinadeFinance = { name: 'adminAuthority'; isMut: false; isSigner: true; - } + }, ]; args: [ { @@ -105,7 +105,7 @@ export type MarinadeFinance = { type: { defined: 'ChangeAuthorityData'; }; - } + }, ]; }, { @@ -155,13 +155,13 @@ export type MarinadeFinance = { name: 'systemProgram'; isMut: false; isSigner: false; - } + }, ]; args: [ { name: 'score'; type: 'u32'; - } + }, ]; }, { @@ -191,7 +191,7 @@ export type MarinadeFinance = { name: 'operationalSolAccount'; isMut: true; isSigner: false; - } + }, ]; args: [ { @@ -201,7 +201,7 @@ export type MarinadeFinance = { { name: 'validatorVote'; type: 'publicKey'; - } + }, ]; }, { @@ -221,7 +221,7 @@ export type MarinadeFinance = { name: 'validatorList'; isMut: true; isSigner: false; - } + }, ]; args: [ { @@ -235,7 +235,7 @@ export type MarinadeFinance = { { name: 'score'; type: 'u32'; - } + }, ]; }, { @@ -250,13 +250,13 @@ export type MarinadeFinance = { name: 'managerAuthority'; isMut: false; isSigner: true; - } + }, ]; args: [ { name: 'extraRuns'; type: 'u32'; - } + }, ]; }, { @@ -316,13 +316,13 @@ export type MarinadeFinance = { name: 'tokenProgram'; isMut: false; isSigner: false; - } + }, ]; args: [ { name: 'lamports'; type: 'u64'; - } + }, ]; }, { @@ -402,13 +402,13 @@ export type MarinadeFinance = { name: 'stakeProgram'; isMut: false; isSigner: false; - } + }, ]; args: [ { name: 'validatorIndex'; type: 'u32'; - } + }, ]; }, { @@ -463,13 +463,13 @@ export type MarinadeFinance = { name: 'tokenProgram'; isMut: false; isSigner: false; - } + }, ]; args: [ { name: 'msolAmount'; type: 'u64'; - } + }, ]; }, { @@ -519,13 +519,13 @@ export type MarinadeFinance = { name: 'tokenProgram'; isMut: false; isSigner: false; - } + }, ]; args: [ { name: 'lamports'; type: 'u64'; - } + }, ]; }, { @@ -585,13 +585,13 @@ export type MarinadeFinance = { name: 'tokenProgram'; isMut: false; isSigner: false; - } + }, ]; args: [ { name: 'tokens'; type: 'u64'; - } + }, ]; }, { @@ -606,7 +606,7 @@ export type MarinadeFinance = { name: 'adminAuthority'; isMut: false; isSigner: true; - } + }, ]; args: [ { @@ -614,7 +614,7 @@ export type MarinadeFinance = { type: { defined: 'ConfigLpParams'; }; - } + }, ]; }, { @@ -629,7 +629,7 @@ export type MarinadeFinance = { name: 'adminAuthority'; isMut: false; isSigner: true; - } + }, ]; args: [ { @@ -637,7 +637,7 @@ export type MarinadeFinance = { type: { defined: 'ConfigMarinadeParams'; }; - } + }, ]; }, { @@ -682,13 +682,13 @@ export type MarinadeFinance = { name: 'tokenProgram'; isMut: false; isSigner: false; - } + }, ]; args: [ { name: 'msolAmount'; type: 'u64'; - } + }, ]; }, { @@ -723,7 +723,7 @@ export type MarinadeFinance = { name: 'systemProgram'; isMut: false; isSigner: false; - } + }, ]; args: []; }, @@ -799,13 +799,13 @@ export type MarinadeFinance = { name: 'stakeProgram'; isMut: false; isSigner: false; - } + }, ]; args: [ { name: 'validatorIndex'; type: 'u32'; - } + }, ]; }, { @@ -873,14 +873,14 @@ export type MarinadeFinance = { name: 'tokenProgram'; isMut: false; isSigner: false; - } + }, ]; }, { name: 'validatorList'; isMut: true; isSigner: false; - } + }, ]; args: [ { @@ -890,7 +890,7 @@ export type MarinadeFinance = { { name: 'validatorIndex'; type: 'u32'; - } + }, ]; }, { @@ -958,7 +958,7 @@ export type MarinadeFinance = { name: 'tokenProgram'; isMut: false; isSigner: false; - } + }, ]; }, { @@ -970,13 +970,13 @@ export type MarinadeFinance = { name: 'systemProgram'; isMut: false; isSigner: false; - } + }, ]; args: [ { name: 'stakeIndex'; type: 'u32'; - } + }, ]; }, { @@ -1051,7 +1051,7 @@ export type MarinadeFinance = { name: 'stakeProgram'; isMut: false; isSigner: false; - } + }, ]; args: [ { @@ -1061,7 +1061,7 @@ export type MarinadeFinance = { { name: 'validatorIndex'; type: 'u32'; - } + }, ]; }, { @@ -1106,7 +1106,7 @@ export type MarinadeFinance = { name: 'stakeProgram'; isMut: false; isSigner: false; - } + }, ]; args: [ { @@ -1116,7 +1116,7 @@ export type MarinadeFinance = { { name: 'validatorIndex'; type: 'u32'; - } + }, ]; }, { @@ -1191,7 +1191,7 @@ export type MarinadeFinance = { name: 'stakeProgram'; isMut: false; isSigner: false; - } + }, ]; args: [ { @@ -1205,7 +1205,7 @@ export type MarinadeFinance = { { name: 'desiredUnstakeAmount'; type: 'u64'; - } + }, ]; }, { @@ -1265,7 +1265,7 @@ export type MarinadeFinance = { name: 'stakeProgram'; isMut: false; isSigner: false; - } + }, ]; args: [ { @@ -1279,9 +1279,9 @@ export type MarinadeFinance = { { name: 'validatorIndex'; type: 'u32'; - } + }, ]; - } + }, ]; accounts: [ { @@ -1361,7 +1361,7 @@ export type MarinadeFinance = { { name: 'circulatingTicketBalance'; docs: [ - 'total lamports amount of generated and not claimed yet tickets' + 'total lamports amount of generated and not claimed yet tickets', ]; type: 'u64'; }, @@ -1384,7 +1384,7 @@ export type MarinadeFinance = { { name: 'emergencyCoolingDown'; type: 'u64'; - } + }, ]; }; }, @@ -1408,10 +1408,10 @@ export type MarinadeFinance = { { name: 'createdEpoch'; type: 'u64'; - } + }, ]; }; - } + }, ]; types: [ { @@ -1442,7 +1442,7 @@ export type MarinadeFinance = { { name: 'lpLiquidityTarget'; docs: [ - 'Liquidity target. If the Liquidity reach this amount, the fee reaches lp_min_discount_fee' + 'Liquidity target. If the Liquidity reach this amount, the fee reaches lp_min_discount_fee', ]; type: 'u64'; }, @@ -1478,7 +1478,7 @@ export type MarinadeFinance = { { name: 'liquiditySolCap'; type: 'u64'; - } + }, ]; }; }, @@ -1506,7 +1506,7 @@ export type MarinadeFinance = { { name: 'copiedCount'; type: 'u32'; - } + }, ]; }; }, @@ -1530,7 +1530,7 @@ export type MarinadeFinance = { { name: 'isEmergencyUnstaking'; type: 'u8'; - } + }, ]; }; }, @@ -1560,7 +1560,7 @@ export type MarinadeFinance = { { name: 'slotsForStakeDelta'; docs: [ - 'set by admin, how much slots before the end of the epoch, stake-delta can start' + 'set by admin, how much slots before the end of the epoch, stake-delta can start', ]; type: 'u64'; }, @@ -1569,7 +1569,7 @@ export type MarinadeFinance = { docs: [ 'Marks the start of stake-delta operations, meaning that if somebody starts a delayed-unstake ticket', 'after this var is set with epoch_num the ticket will have epoch_created = current_epoch+1', - '(the user must wait one more epoch, because their unstake-delta will be execute in this epoch)' + '(the user must wait one more epoch, because their unstake-delta will be execute in this epoch)', ]; type: 'u64'; }, @@ -1581,10 +1581,10 @@ export type MarinadeFinance = { name: 'extraStakeDeltaRuns'; docs: [ 'can be set by validator-manager-auth to allow a second run of stake-delta to stake late stakers in the last minute of the epoch', - "so we maximize user's rewards" + "so we maximize user's rewards", ]; type: 'u32'; - } + }, ]; }; }, @@ -1614,7 +1614,7 @@ export type MarinadeFinance = { { name: 'duplicationFlagBumpSeed'; type: 'u8'; - } + }, ]; }; }, @@ -1645,10 +1645,10 @@ export type MarinadeFinance = { { name: 'autoAddValidatorEnabled'; docs: [ - 'allow & auto-add validator when a user deposits a stake-account of a non-listed validator' + 'allow & auto-add validator when a user deposits a stake-account of a non-listed validator', ]; type: 'u8'; - } + }, ]; }; }, @@ -1660,7 +1660,7 @@ export type MarinadeFinance = { { name: 'basisPoints'; type: 'u32'; - } + }, ]; }; }, @@ -1704,7 +1704,7 @@ export type MarinadeFinance = { { name: 'slotsForStakeDelta'; type: 'u64'; - } + }, ]; }; }, @@ -1734,7 +1734,7 @@ export type MarinadeFinance = { type: { defined: 'Fee'; }; - } + }, ]; }; }, @@ -1766,7 +1766,7 @@ export type MarinadeFinance = { type: { option: 'publicKey'; }; - } + }, ]; }; }, @@ -1804,7 +1804,7 @@ export type MarinadeFinance = { defined: 'Fee'; }; }; - } + }, ]; }; }, @@ -1862,7 +1862,7 @@ export type MarinadeFinance = { type: { option: 'bool'; }; - } + }, ]; }; }, @@ -1954,10 +1954,10 @@ export type MarinadeFinance = { }, { name: 'InvalidValidator'; - } + }, ]; }; - } + }, ]; }; diff --git a/sdk/src/tx/txHandler.ts b/sdk/src/tx/txHandler.ts index 19f953822..110a453a4 100644 --- a/sdk/src/tx/txHandler.ts +++ b/sdk/src/tx/txHandler.ts @@ -138,7 +138,7 @@ export class TxHandler { private getProps = (wallet?: IWallet, confirmationOpts?: ConfirmOptions) => [wallet ?? this.wallet, confirmationOpts ?? this.confirmationOptions] as [ IWallet, - ConfirmOptions + ConfirmOptions, ]; public updateWallet(wallet: IWallet) { @@ -595,7 +595,7 @@ export class TxHandler { * @returns */ public async getPreparedAndSignedLegacyTransactionMap< - T extends Record + T extends Record, >( txsMap: T, wallet?: IWallet, @@ -628,7 +628,7 @@ export class TxHandler { * @returns */ public async getSignedTransactionMap< - T extends Record + T extends Record, >( txsToSignMap: T, wallet?: IWallet @@ -693,7 +693,7 @@ export class TxHandler { * @returns */ public async buildTransactionsMap< - T extends Record + T extends Record, >( props: Omit & { instructionsMap: T; @@ -716,7 +716,7 @@ export class TxHandler { * @returns */ public async buildAndSignTransactionMap< - T extends Record + T extends Record, >( props: Omit & { instructionsMap: T; diff --git a/sdk/src/tx/types.ts b/sdk/src/tx/types.ts index c23af6c23..300512b7c 100644 --- a/sdk/src/tx/types.ts +++ b/sdk/src/tx/types.ts @@ -59,7 +59,10 @@ export interface TxSender { } export class TxSendError extends Error { - constructor(public message: string, public code: number) { + constructor( + public message: string, + public code: number + ) { super(message); if (Error.captureStackTrace) { Error.captureStackTrace(this, TxSendError);