-
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
Domain Manager Multi-select and Portfolio Actions Preview #631
Open
rithvikvibhu
wants to merge
10
commits into
kyokan:master
Choose a base branch
from
rithvikvibhu:multiselect-and-bulkconfirm
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c6660c1
domain-manager: refactor css and add checkboxes
rithvikvibhu 0365c95
domain-manager: multiselect action buttons
rithvikvibhu c830d46
domain-manager: working multiselect transfer
rithvikvibhu f301c4a
domain-manager: update bulk transfer text
rithvikvibhu ac998d8
portfolio: bulk action multiselect preview modal
rithvikvibhu 1ffc82a
domain-manager: remove finalize all
rithvikvibhu ceca95d
domain-manager: bulk renew
rithvikvibhu 97ea918
wallet: remove unused create-register-all.js
rithvikvibhu 10690c0
i18n: extract strings for bulk actions
rithvikvibhu 225cc8a
domain-manager: update bulk transfer batch size
rithvikvibhu 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
const { states } = require('hsd/lib/covenants/namestate'); | ||
|
||
// From hsd/lib/wallet/wallet.js make*() | ||
|
||
/** @param {import('hsd/lib/wallet/wallet')} wallet */ | ||
export const getNamesForRegisterAll = async (wallet) => { | ||
const height = wallet.wdb.height + 1; | ||
const network = wallet.network; | ||
const names = await wallet.txdb.getNames(); | ||
const namesToRegister = []; | ||
|
||
for (let i = 0; i < names.length; i++) { | ||
const ns = names[i]; | ||
const { owner } = ns; | ||
|
||
const coin = await wallet.getUnspentCoin(owner.hash, owner.index); | ||
|
||
if (coin) { | ||
if (!coin) | ||
continue; | ||
|
||
if (ns.isExpired(height, network)) | ||
continue; | ||
|
||
// Is local? | ||
if (coin.height < ns.height) | ||
continue; | ||
|
||
if (!coin.covenant.isReveal() && !coin.covenant.isClaim()) | ||
continue; | ||
|
||
if (coin.covenant.isClaim()) { | ||
if (height < coin.height + network.coinbaseMaturity) | ||
continue; | ||
} | ||
|
||
const state = ns.state(height, network); | ||
|
||
if (state !== states.CLOSED) | ||
continue; | ||
|
||
namesToRegister.push({ | ||
name: ns.name.toString('binary'), | ||
}); | ||
} | ||
} | ||
|
||
return namesToRegister; | ||
} | ||
|
||
/** @param {import('hsd/lib/wallet/wallet')} wallet */ | ||
export const getNamesForFinalizeAll = async (wallet) => { | ||
const height = wallet.wdb.height + 1; | ||
const network = wallet.network; | ||
const names = await wallet.txdb.getNames(); | ||
const namesToFinalize = []; | ||
|
||
for (const ns of names) { | ||
// Easiest check is for transfer state, do that first | ||
if (!ns.transfer) | ||
continue; | ||
|
||
const blocksLeft = (ns.transfer + network.names.transferLockup) - height; | ||
if (blocksLeft > 0) | ||
continue; | ||
|
||
// Then check for expiration | ||
if (ns.isExpired(height, network)) | ||
continue; | ||
|
||
// Now do the db lookups to see if we own the name | ||
const { hash, index } = ns.owner; | ||
const coin = await wallet.getUnspentCoin(hash, index); | ||
if (!coin) | ||
continue; | ||
|
||
namesToFinalize.push({ | ||
name: ns.name.toString('binary'), | ||
finalizableSinceBlocks: -blocksLeft, | ||
}); | ||
} | ||
|
||
return namesToFinalize; | ||
} | ||
|
||
/** @param {import('hsd/lib/wallet/wallet')} wallet */ | ||
export const getNamesForRenewAll = async (wallet) => { | ||
const height = wallet.wdb.height + 1; | ||
const network = wallet.network; | ||
const names = await wallet.txdb.getNames(); | ||
const namesToRenew = []; | ||
|
||
for (const ns of names) { | ||
// Easiest check is for expiring time, do that first | ||
if (ns.isExpired(height, network)) | ||
continue; | ||
|
||
// About 90 days on main (1.75 years after REGISTER) | ||
// 625 blocks on regtest (4375 blocks after REGISTER) | ||
const blocksLeft = (ns.renewal + network.names.renewalWindow) - height; | ||
if (blocksLeft >= network.names.renewalWindow / 8) | ||
continue; | ||
|
||
if (height < ns.renewal + network.names.treeInterval) | ||
continue; // Can not renew yet | ||
|
||
// Now do the db lookups to see if we own the name | ||
const { hash, index } = ns.owner; | ||
const coin = await wallet.getUnspentCoin(hash, index); | ||
if (!coin) | ||
continue; | ||
|
||
if (!coin.covenant.isRegister() | ||
&& !coin.covenant.isUpdate() | ||
&& !coin.covenant.isRenew() | ||
&& !coin.covenant.isFinalize()) { | ||
continue; // Name is not yet registered | ||
} | ||
|
||
namesToRenew.push({ | ||
name: ns.name.toString('binary'), | ||
renewInBlocks: blocksLeft, | ||
}); | ||
} | ||
|
||
// Sort by urgency, oldest/lowest renewal heights go first | ||
namesToRenew.sort((a, b) => { | ||
return a.blocksLeft - b.blocksLeft; | ||
}); | ||
|
||
return namesToRenew; | ||
} | ||
|
||
/** @param {import('hsd/lib/wallet/wallet')} wallet */ | ||
export const getNamesInTransfer = async (wallet) => { | ||
const height = wallet.wdb.height + 1; | ||
const network = wallet.network; | ||
const names = await wallet.txdb.getNames(); | ||
const namesInTransfer = []; | ||
|
||
for (const ns of names) { | ||
// Easiest check is for transfer state, do that first | ||
if (!ns.transfer) | ||
continue; | ||
|
||
const blocksLeft = (ns.transfer + network.names.transferLockup) - height; | ||
if (blocksLeft <= 0) | ||
continue; | ||
|
||
// Then check for expiration | ||
if (ns.isExpired(height, network)) | ||
continue; | ||
|
||
// Now do the db lookups to see if we own the name | ||
const { hash, index } = ns.owner; | ||
const coin = await wallet.getUnspentCoin(hash, index); | ||
if (!coin) | ||
continue; | ||
|
||
namesInTransfer.push({ | ||
name: ns.name.toString('binary'), | ||
finalizableInBlocks: blocksLeft, | ||
}); | ||
} | ||
|
||
return namesInTransfer; | ||
} |
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 was deleted.
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
93 changes: 93 additions & 0 deletions
93
app/components/BulkActionConfirmModal/bulk-action-confirm-modal.scss
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,93 @@ | ||
@import '../../variables.scss'; | ||
|
||
.bulk-action { | ||
.mini-modal__content { | ||
flex-grow: 1; | ||
display: flex; | ||
flex-direction: column; | ||
overflow: auto; | ||
padding-left: 1px; | ||
padding-right: 1px; | ||
} | ||
|
||
p { | ||
&:nth-of-type(1) { | ||
margin-top: 0; | ||
} | ||
} | ||
|
||
&__label { | ||
color: rgba($black, 0.4); | ||
font-weight: 600; | ||
font-size: 0.8rem; | ||
margin-bottom: 0.75rem; | ||
} | ||
|
||
&__table { | ||
flex-grow: 1; | ||
overflow: auto; | ||
|
||
.table { | ||
&__header { | ||
min-height: 28px; | ||
|
||
&__item { | ||
&--checkbox { | ||
flex: 0 0 2rem; | ||
} | ||
&--domain { | ||
flex: 0 0 8rem; | ||
flex-grow: 1; | ||
} | ||
&--time { | ||
text-align: right; | ||
flex: 0 0 10rem; | ||
} | ||
} | ||
} | ||
|
||
&__row { | ||
transition: background-color 250ms ease-in-out; | ||
|
||
&:hover { | ||
background-color: rgba($black, .025); | ||
} | ||
|
||
&:active { | ||
background-color: rgba($black, .05); | ||
} | ||
|
||
&__item { | ||
&--checkbox { | ||
flex: 0 0 2rem; | ||
} | ||
&--domain { | ||
flex: 0 0 8rem; | ||
flex-grow: 1; | ||
} | ||
&--time { | ||
text-align: right; | ||
flex: 0 0 10rem; | ||
} | ||
} | ||
} | ||
} | ||
|
||
&__body { | ||
overflow: auto; | ||
flex-grow: 1; | ||
} | ||
} | ||
|
||
&__actions { | ||
@extend %row-nowrap; | ||
justify-content: center; | ||
width: 100%; | ||
margin-top: 1rem; | ||
|
||
button { | ||
@extend %btn-primary; | ||
flex: 1 0 auto; | ||
} | ||
} | ||
} |
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.
found by @Falci