-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'PermitTx,-GetPermitBuilder,-ReturnPermitBuilder-classes…
…' into 'dev' Permit tx, get permit builder, return permit builder classes Closes #196 See merge request ergo/rosen-bridge/watcher!214
- Loading branch information
Showing
6 changed files
with
160 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { AbstractLogger } from '@rosen-bridge/abstract-logger'; | ||
import { RWTRepo } from '@rosen-bridge/rwt-repo'; | ||
|
||
export class GetPermitBuilder { | ||
constructor( | ||
private permitAddress: string, | ||
private collateralAddress: string, | ||
private changeAddress: string, | ||
private rsn: string, | ||
private rwt: string, | ||
private txFee: string, | ||
private rwtRepo: RWTRepo, | ||
private logger?: AbstractLogger | ||
) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import { AbstractLogger } from '@rosen-bridge/abstract-logger'; | ||
import { RWTRepo } from '@rosen-bridge/rwt-repo'; | ||
import { GetPermitBuilder } from './GetPermitBuilder'; | ||
import { ReturnPermitBuilder } from './ReturnPermitBuilder'; | ||
|
||
export class PermitTx { | ||
private static instance?: PermitTx; | ||
|
||
private constructor( | ||
private permitAddress: string, | ||
private collateralAddress: string, | ||
private changeAddress: string, | ||
private rsn: string, | ||
private rwt: string, | ||
private txFee: string, | ||
private rwtRepo: RWTRepo, | ||
private logger?: AbstractLogger | ||
) {} | ||
|
||
/** | ||
* initializes the singleton instance of PermitTx | ||
* | ||
* @static | ||
* @param {string} permitAddress | ||
* @param {string} collateralAddress | ||
* @param {string} changeAddress | ||
* @param {string} rsn | ||
* @param {string} rwt | ||
* @param {string} txFee | ||
* @param {RWTRepo} rwtRepo | ||
* @param {AbstractLogger} [logger] | ||
*/ | ||
static init = ( | ||
permitAddress: string, | ||
collateralAddress: string, | ||
changeAddress: string, | ||
rsn: string, | ||
rwt: string, | ||
txFee: string, | ||
rwtRepo: RWTRepo, | ||
logger?: AbstractLogger | ||
): void => { | ||
if (PermitTx.instance != undefined) { | ||
throw new Error('The singleton instance is already initialized.'); | ||
} | ||
|
||
PermitTx.instance = new PermitTx( | ||
permitAddress, | ||
collateralAddress, | ||
changeAddress, | ||
rsn, | ||
rwt, | ||
txFee, | ||
rwtRepo, | ||
logger | ||
); | ||
}; | ||
|
||
/** | ||
* return the singleton instance of PermitTx | ||
* | ||
* @static | ||
* @return {PermitTx} | ||
*/ | ||
static getInstance = (): PermitTx => { | ||
if (!this.instance) { | ||
throw new Error('PermitTx instance is not initialized yet'); | ||
} | ||
return this.instance; | ||
}; | ||
|
||
/** | ||
* creates a new instance of GetPermitBuilder | ||
* | ||
* @return {GetPermitBuilder} | ||
*/ | ||
newGetPermitBuilder = (): GetPermitBuilder => { | ||
return new GetPermitBuilder( | ||
this.permitAddress, | ||
this.collateralAddress, | ||
this.changeAddress, | ||
this.rsn, | ||
this.rwt, | ||
this.txFee, | ||
this.rwtRepo, | ||
this.logger | ||
); | ||
}; | ||
|
||
/** | ||
* creates a new instance of ReturnPermitBuilder | ||
* | ||
* @return {ReturnPermitBuilder} | ||
*/ | ||
newًReturnPermitBuilder = (): ReturnPermitBuilder => { | ||
return new ReturnPermitBuilder( | ||
this.permitAddress, | ||
this.collateralAddress, | ||
this.changeAddress, | ||
this.rsn, | ||
this.rwt, | ||
this.txFee, | ||
this.rwtRepo, | ||
this.logger | ||
); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { AbstractLogger } from '@rosen-bridge/abstract-logger'; | ||
import { RWTRepo } from '@rosen-bridge/rwt-repo'; | ||
|
||
export class ReturnPermitBuilder { | ||
constructor( | ||
private permitAddress: string, | ||
private collateralAddress: string, | ||
private changeAddress: string, | ||
private rsn: string, | ||
private rwt: string, | ||
private txFee: string, | ||
private rwtRepo: RWTRepo, | ||
private logger?: AbstractLogger | ||
) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './GetPermitBuilder'; | ||
export * from './PermitTx'; | ||
export * from './ReturnPermitBuilder'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters