From 9b8503321d3d6786ebe5bf538338197792e8885c Mon Sep 17 00:00:00 2001 From: Shingo Konnai Date: Mon, 20 Apr 2020 11:01:39 -0700 Subject: [PATCH 1/3] add client type into Sologenic Tx Handlerand add a new interface Client into type/utils --- src/lib/txhandler.ts | 16 +++++++++++++++- src/types/utils.ts | 8 ++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/lib/txhandler.ts b/src/lib/txhandler.ts index abd0a7c..acc4d85 100644 --- a/src/lib/txhandler.ts +++ b/src/lib/txhandler.ts @@ -97,6 +97,11 @@ export class SologenicTxHandler extends EventEmitter { {} ); + /** + * Type of client application using Sologenic Tx Handler + */ + protected clientType: string = 'mobile'; + /** * Constructor for an instance of sologenic tx handler. * @@ -115,7 +120,8 @@ export class SologenicTxHandler extends EventEmitter { */ constructor( rippleApiOptions: SologenicTypes.RippleAPIOptions, - sologenicOptions: SologenicTypes.TransactionHandlerOptions + sologenicOptions: SologenicTypes.TransactionHandlerOptions, + clientOptions: SologenicTypes.Client, ) { /** * Event emitter constructor @@ -187,6 +193,14 @@ export class SologenicTxHandler extends EventEmitter { if (typeof sologenicOptions.signingMechanism !== 'undefined') this.signingMechanism = sologenicOptions.signingMechanism; + + /** + * Initialize client type + */ + + if (typeof clientOptions.clientType !== 'undefined') { + this.clientType = clientOptions.clientType; + } } catch (error) { throw new SologenicError('1001', error); diff --git a/src/types/utils.ts b/src/types/utils.ts index 333de55..8e8af28 100644 --- a/src/types/utils.ts +++ b/src/types/utils.ts @@ -17,3 +17,11 @@ export interface IFaucet { account: IFaucetAccount; balance: number; } + +/** + * Supporting interface for xumm so that XummSigner can switch + * the API key and secret for mobile and desktop + */ +export interface Client { + clientType: string; +} From 3dc65d4c238e2e02ce64ce9c516e8fc98a4bf856 Mon Sep 17 00:00:00 2001 From: Shingo Konnai Date: Mon, 20 Apr 2020 15:25:33 -0700 Subject: [PATCH 2/3] remove clientOptions from types/utils and add clientType into TransactionHandlerOptions --- src/lib/txhandler.ts | 9 ++++----- src/types/queues.ts | 1 + src/types/utils.ts | 7 ------- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/lib/txhandler.ts b/src/lib/txhandler.ts index acc4d85..bf5cc98 100644 --- a/src/lib/txhandler.ts +++ b/src/lib/txhandler.ts @@ -100,7 +100,7 @@ export class SologenicTxHandler extends EventEmitter { /** * Type of client application using Sologenic Tx Handler */ - protected clientType: string = 'mobile'; + protected clientType: string = ''; /** * Constructor for an instance of sologenic tx handler. @@ -120,8 +120,7 @@ export class SologenicTxHandler extends EventEmitter { */ constructor( rippleApiOptions: SologenicTypes.RippleAPIOptions, - sologenicOptions: SologenicTypes.TransactionHandlerOptions, - clientOptions: SologenicTypes.Client, + sologenicOptions: SologenicTypes.TransactionHandlerOptions ) { /** * Event emitter constructor @@ -198,8 +197,8 @@ export class SologenicTxHandler extends EventEmitter { * Initialize client type */ - if (typeof clientOptions.clientType !== 'undefined') { - this.clientType = clientOptions.clientType; + if (typeof sologenicOptions.clientType !== 'undefined') { + this.clientType = sologenicOptions.clientType; } } catch (error) { diff --git a/src/types/queues.ts b/src/types/queues.ts index 4e1f21f..1e45bd5 100644 --- a/src/types/queues.ts +++ b/src/types/queues.ts @@ -29,6 +29,7 @@ export interface TransactionHandlerOptions { hash?: HashTransactionHandlerOptions maximumTimeToLive?: number; signingMechanism?: ISologenicTxSigner; + clientType?: string; } export interface MQTX { diff --git a/src/types/utils.ts b/src/types/utils.ts index 8e8af28..4cf0063 100644 --- a/src/types/utils.ts +++ b/src/types/utils.ts @@ -18,10 +18,3 @@ export interface IFaucet { balance: number; } -/** - * Supporting interface for xumm so that XummSigner can switch - * the API key and secret for mobile and desktop - */ -export interface Client { - clientType: string; -} From 319ae5c7818ea8cbe05a4beb6fe50a65907e0650 Mon Sep 17 00:00:00 2001 From: Shingo Konnai Date: Tue, 21 Apr 2020 09:43:37 -0700 Subject: [PATCH 3/3] create a new file for TransactionHandlerOptions --- src/lib/queues/index.ts | 2 +- src/types/index.ts | 1 + src/types/queues.ts | 11 ----------- src/types/txhandleroptions.ts | 12 ++++++++++++ 4 files changed, 14 insertions(+), 12 deletions(-) create mode 100644 src/types/txhandleroptions.ts diff --git a/src/lib/queues/index.ts b/src/lib/queues/index.ts index f30695c..f1b6ef4 100644 --- a/src/lib/queues/index.ts +++ b/src/lib/queues/index.ts @@ -3,8 +3,8 @@ import { IQueue, QUEUE_TYPE_STXMQ_REDIS, QUEUE_TYPE_STXMQ_HASH, - TransactionHandlerOptions } from '../../types/queues'; +import { TransactionHandlerOptions } from '../../types/txhandleroptions'; /** * Import redis queue implementation diff --git a/src/types/index.ts b/src/types/index.ts index 252f65c..dcb4244 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -3,3 +3,4 @@ export * from './queues'; export * from './txhandler'; export * from './utils'; export * from './xrpl'; +export * from './txhandleroptions'; \ No newline at end of file diff --git a/src/types/queues.ts b/src/types/queues.ts index 1e45bd5..7f27a32 100644 --- a/src/types/queues.ts +++ b/src/types/queues.ts @@ -1,4 +1,3 @@ -import { ISologenicTxSigner } from "./txhandler"; export interface IQueue { add(queue: string, data: MQTX, id?: string): Promise; @@ -22,16 +21,6 @@ export interface RedisTransactionHandlerOptions { db?: number; } -export interface TransactionHandlerOptions { - queueType?: string; - clearCache?: boolean; - redis?: RedisTransactionHandlerOptions - hash?: HashTransactionHandlerOptions - maximumTimeToLive?: number; - signingMechanism?: ISologenicTxSigner; - clientType?: string; -} - export interface MQTX { id: string; data: any; diff --git a/src/types/txhandleroptions.ts b/src/types/txhandleroptions.ts new file mode 100644 index 0000000..cade2ff --- /dev/null +++ b/src/types/txhandleroptions.ts @@ -0,0 +1,12 @@ +import { ISologenicTxSigner } from "./txhandler"; +import { RedisTransactionHandlerOptions, HashTransactionHandlerOptions } from "./queues"; + +export interface TransactionHandlerOptions { + queueType?: string; + clearCache?: boolean; + redis?: RedisTransactionHandlerOptions; + hash?: HashTransactionHandlerOptions; + maximumTimeToLive?: number; + signingMechanism?: ISologenicTxSigner; + clientType?: string; +} \ No newline at end of file