Skip to content

Commit c4d81c8

Browse files
author
Konstantin Shuplenkov
committed
WIP
1 parent d0f963b commit c4d81c8

File tree

1 file changed

+35
-31
lines changed

1 file changed

+35
-31
lines changed

packages/js-drive/lib/identity/masternode/synchronizeMasternodeIdentitiesFactory.js

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -89,44 +89,48 @@ function synchronizeMasternodeIdentitiesFactory(
8989
);
9090
}
9191

92-
const mnEntryWithChangedPayoutAddress = previousMNList.find((previousMnListEntry) => (
93-
previousMnListEntry.proRegTxHash === mnEntry.proRegTxHash
94-
&& previousMnListEntry.payoutAddress !== mnEntry.payoutAddress
95-
));
96-
97-
if (mnEntryWithChangedPayoutAddress) {
98-
const newPayoutAddress = Address.fromString(mnEntry.payoutAddress);
99-
const previousPayoutAddress = mnEntryWithChangedPayoutAddress.payoutAddress
100-
? Address.fromString(mnEntryWithChangedPayoutAddress.payoutAddress)
101-
: undefined;
92+
if (mnEntry.payoutAddress) {
93+
const mnEntryWithChangedPayoutAddress = previousMNList.find((previousMnListEntry) => (
94+
previousMnListEntry.proRegTxHash === mnEntry.proRegTxHash
95+
&& previousMnListEntry.payoutAddress !== mnEntry.payoutAddress
96+
));
10297

103-
await handleUpdatedScriptPayout(
104-
Identifier.from(Buffer.from(mnEntry.proRegTxHash, 'hex')),
105-
new Script(newPayoutAddress).toBuffer(),
106-
new Script(previousPayoutAddress).toBuffer(),
107-
);
98+
if (mnEntryWithChangedPayoutAddress) {
99+
const newPayoutAddress = Address.fromString(mnEntry.payoutAddress);
100+
const previousPayoutAddress = mnEntryWithChangedPayoutAddress.payoutAddress
101+
? Address.fromString(mnEntryWithChangedPayoutAddress.payoutAddress)
102+
: undefined;
103+
104+
await handleUpdatedScriptPayout(
105+
Identifier.from(Buffer.from(mnEntry.proRegTxHash, 'hex')),
106+
new Script(newPayoutAddress).toBuffer(),
107+
new Script(previousPayoutAddress).toBuffer(),
108+
);
109+
}
108110
}
109111

110-
const mnEntryWithChangedOperatorPayoutAddress = previousMNList
111-
.find((previousMnListEntry) => (
112-
previousMnListEntry.proRegTxHash === mnEntry.proRegTxHash
113-
&& previousMnListEntry.operatorPayoutAddress !== mnEntry.operatorPayoutAddress
114-
));
112+
if (mnEntry.operatorPayoutAddress) {
113+
const mnEntryWithChangedOperatorPayoutAddress = previousMNList
114+
.find((previousMnListEntry) => (
115+
previousMnListEntry.proRegTxHash === mnEntry.proRegTxHash
116+
&& previousMnListEntry.operatorPayoutAddress !== mnEntry.operatorPayoutAddress
117+
));
115118

116-
if (mnEntryWithChangedOperatorPayoutAddress) {
117-
const newOperatorPayoutAddress = Address.fromString(mnEntry.operatorPayoutAddress);
119+
if (mnEntryWithChangedOperatorPayoutAddress) {
120+
const newOperatorPayoutAddress = Address.fromString(mnEntry.operatorPayoutAddress);
118121

119-
const { operatorPayoutAddress } = mnEntryWithChangedOperatorPayoutAddress;
122+
const { operatorPayoutAddress } = mnEntryWithChangedOperatorPayoutAddress;
120123

121-
const previousOperatorPayoutAddress = operatorPayoutAddress
122-
? Address.fromString(operatorPayoutAddress)
123-
: undefined;
124+
const previousOperatorPayoutAddress = operatorPayoutAddress
125+
? Address.fromString(operatorPayoutAddress)
126+
: undefined;
124127

125-
await handleUpdatedScriptPayout(
126-
createOperatorIdentifier(mnEntry),
127-
new Script(newOperatorPayoutAddress).toBuffer(),
128-
new Script(previousOperatorPayoutAddress).toBuffer(),
129-
);
128+
await handleUpdatedScriptPayout(
129+
createOperatorIdentifier(mnEntry),
130+
new Script(newOperatorPayoutAddress).toBuffer(),
131+
new Script(previousOperatorPayoutAddress).toBuffer(),
132+
);
133+
}
130134
}
131135
}
132136
}

0 commit comments

Comments
 (0)