-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
2,000 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { BondExtra } from './ui/BondExtra'; | ||
export { bondExtraModel } from './model/bond-extra-model'; |
65 changes: 65 additions & 0 deletions
65
src/renderer/widgets/Staking/BondExtra/lib/bond-extra-utils.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,65 @@ | ||
import { Step } from './types'; | ||
import { walletUtils, accountUtils } from '@entities/wallet'; | ||
import { dictionary } from '@shared/lib/utils'; | ||
import { transactionService } from '@entities/transaction'; | ||
import { Wallet, Account, Chain } from '@shared/core'; | ||
|
||
export const bondExtraUtils = { | ||
isNoneStep, | ||
isInitStep, | ||
isConfirmStep, | ||
isSignStep, | ||
isSubmitStep, | ||
|
||
getTxWrappers, | ||
}; | ||
|
||
function isNoneStep(step: Step): boolean { | ||
return step === Step.NONE; | ||
} | ||
|
||
function isInitStep(step: Step): boolean { | ||
return step === Step.INIT; | ||
} | ||
|
||
function isConfirmStep(step: Step): boolean { | ||
return step === Step.CONFIRM; | ||
} | ||
|
||
function isSignStep(step: Step): boolean { | ||
return step === Step.SIGN; | ||
} | ||
|
||
function isSubmitStep(step: Step): boolean { | ||
return step === Step.SUBMIT; | ||
} | ||
|
||
type TxWrapperParams = { | ||
chain: Chain; | ||
wallet: Wallet; | ||
wallets: Wallet[]; | ||
account: Account; | ||
accounts: Account[]; | ||
signatories: Account[]; | ||
}; | ||
function getTxWrappers({ chain, wallet, wallets, account, accounts, signatories }: TxWrapperParams) { | ||
const walletFiltered = wallets.filter((wallet) => { | ||
return !walletUtils.isProxied(wallet) && !walletUtils.isWatchOnly(wallet); | ||
}); | ||
const walletsMap = dictionary(walletFiltered, 'id'); | ||
const chainFilteredAccounts = accounts.filter((account) => { | ||
if (accountUtils.isBaseAccount(account) && walletUtils.isPolkadotVault(walletsMap[account.walletId])) { | ||
return false; | ||
} | ||
|
||
return accountUtils.isChainAndCryptoMatch(account, chain); | ||
}); | ||
|
||
return transactionService.getTxWrappers({ | ||
wallet, | ||
wallets: walletFiltered, | ||
account, | ||
accounts: chainFilteredAccounts, | ||
signatories, | ||
}); | ||
} |
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,28 @@ | ||
import type { Account, Chain, Wallet } from '@shared/core'; | ||
|
||
export const enum Step { | ||
NONE, | ||
INIT, | ||
CONFIRM, | ||
SIGN, | ||
SUBMIT, | ||
} | ||
|
||
export type WalletData = { | ||
wallet: Wallet; | ||
shards: Account[]; | ||
chain: Chain; | ||
}; | ||
|
||
export type BondData = { | ||
shards: Account[]; | ||
signatory?: Account; | ||
amount: string; | ||
description: string; | ||
}; | ||
|
||
export type FeeData = { | ||
fee: string; | ||
totalFee: string; | ||
multisigDeposit: string; | ||
}; |
Oops, something went wrong.