-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ledger support for unbond and withdraw #1158
Merged
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
28afb6a
Ledger support for unbond and withdraw
bobo-k2 2b66c84
Warning for Ledger users
bobo-k2 a8814d6
Update src/i18n/en-US/index.ts
bobo-k2 3b5d7db
Message text update
bobo-k2 e2b2be3
Merge branch 'main' into feat/staking-v3-ledger-native
gluneau d6711a6
Code review fixes.
bobo-k2 9911966
Merge branch 'feat/staking-v3-ledger-native' of github.com:AstarNetwo…
bobo-k2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use i18 here