Add block & timestamp conditions to Signer (#4411)
* WIP * WIP (with lint) * Update ui/RadioButtons * transaction.condition * Date & Time selection in-place * Swap to condition-only * Fix tests, align naming * Pick error properly from validation * Update tests * condition: time sent withough ms * Format numbers as base-10 * override popup styles (zIndex) * Pass condition to signer * Update expectation (failing test typo) * Adjust min/max height for expanded bar * Fix address display * Fix name display * Number inputs for gas/gasPrice/blockNumber * Default blockNumber to 1 (align with min setting) * Update tests with min value * Add Block Number * Fix failing tests (after blockNumber intro)
This commit is contained in:
@@ -127,6 +127,18 @@ export function inNumber16 (number) {
|
||||
return inHex(bn.toString(16));
|
||||
}
|
||||
|
||||
export function inOptionsCondition (condition) {
|
||||
if (condition) {
|
||||
if (condition.block) {
|
||||
condition.block = condition.block ? inNumber10(condition.block) : null;
|
||||
} else if (condition.time) {
|
||||
condition.time = inNumber10(Math.floor(condition.time.getTime() / 1000));
|
||||
}
|
||||
}
|
||||
|
||||
return condition;
|
||||
}
|
||||
|
||||
export function inOptions (options) {
|
||||
if (options) {
|
||||
Object.keys(options).forEach((key) => {
|
||||
@@ -136,6 +148,10 @@ export function inOptions (options) {
|
||||
options[key] = inAddress(options[key]);
|
||||
break;
|
||||
|
||||
case 'condition':
|
||||
options[key] = inOptionsCondition(options[key]);
|
||||
break;
|
||||
|
||||
case 'gas':
|
||||
case 'gasPrice':
|
||||
options[key] = inNumber16((new BigNumber(options[key])).round());
|
||||
|
||||
@@ -221,6 +221,18 @@ export function outSyncing (syncing) {
|
||||
return syncing;
|
||||
}
|
||||
|
||||
export function outTransactionCondition (condition) {
|
||||
if (condition) {
|
||||
if (condition.block) {
|
||||
condition.block = outNumber(condition.block);
|
||||
} else if (condition.time) {
|
||||
condition.time = outDate(condition.time);
|
||||
}
|
||||
}
|
||||
|
||||
return condition;
|
||||
}
|
||||
|
||||
export function outTransaction (tx) {
|
||||
if (tx) {
|
||||
Object.keys(tx).forEach((key) => {
|
||||
@@ -234,8 +246,14 @@ export function outTransaction (tx) {
|
||||
tx[key] = outNumber(tx[key]);
|
||||
break;
|
||||
|
||||
case 'condition':
|
||||
tx[key] = outTransactionCondition(tx[key]);
|
||||
break;
|
||||
|
||||
case 'minBlock':
|
||||
tx[key] = tx[key] ? outNumber(tx[key]) : null;
|
||||
tx[key] = tx[key]
|
||||
? outNumber(tx[key])
|
||||
: null;
|
||||
break;
|
||||
|
||||
case 'creates':
|
||||
|
||||
Reference in New Issue
Block a user