-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ledger support for unbond and withdraw (#1158)
* Ledger support for unbond and withdraw * Warning for Ledger users * Update src/i18n/en-US/index.ts Co-authored-by: impelcrypto <[email protected]> * Message text update * Code review fixes. --------- Co-authored-by: impelcrypto <[email protected]> Co-authored-by: Gregory Luneau <[email protected]>
- Loading branch information
1 parent
c7b52f9
commit 04c5624
Showing
16 changed files
with
215 additions
and
51 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
39 changes: 39 additions & 0 deletions
39
src/staking-v3/logic/services/DappStakingServiceV2Ledger.ts
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,39 @@ | ||
import { injectable, inject } from 'inversify'; | ||
import { IDappStakingServiceV2Ledger } from './IDappStakingServiceV2Ledger'; | ||
import { SignerService } from './SignerService'; | ||
import { Symbols } from 'src/v2/symbols'; | ||
import { IDappStakingRepository } from '../repositories'; | ||
import { IWalletService } from 'src/v2/services'; | ||
import { Guard } from 'src/v2/common'; | ||
|
||
@injectable() | ||
export class DappStakingServiceV2Ledger | ||
extends SignerService | ||
implements IDappStakingServiceV2Ledger | ||
{ | ||
constructor( | ||
@inject(Symbols.DappStakingRepositoryV3) | ||
protected dappStakingRepository: IDappStakingRepository, | ||
@inject(Symbols.WalletFactory) walletFactory: () => IWalletService | ||
) { | ||
super(walletFactory); | ||
} | ||
|
||
public async unlock( | ||
senderAddress: string, | ||
amount: bigint, | ||
successMessage: string | ||
): Promise<void> { | ||
Guard.ThrowIfUndefined(senderAddress, 'senderAddress'); | ||
|
||
const call = await this.dappStakingRepository.getUnbondAndUnstakeCall(amount); | ||
await this.signCall(call, senderAddress, successMessage); | ||
} | ||
|
||
public async withdraw(senderAddress: string, successMessage: string): Promise<void> { | ||
Guard.ThrowIfUndefined(senderAddress, 'senderAddress'); | ||
|
||
const call = await this.dappStakingRepository.getWithdrawUnbondedCall(); | ||
await this.signCall(call, senderAddress, successMessage); | ||
} | ||
} |
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,8 @@ | ||
/** | ||
* Support for v2 ledger stakers to enable them to unlock and withdraw their tokens. | ||
*/ | ||
export interface IDappStakingServiceV2Ledger { | ||
unlock(senderAddress: string, amount: bigint, successMessage: string): Promise<void>; | ||
|
||
withdraw(senderAddress: string, successMessage: string): Promise<void>; | ||
} |
Oops, something went wrong.