Skip to content

Commit

Permalink
Merge pull request #2094 from Emurgo/release/4.5.0
Browse files Browse the repository at this point in the history
Release/4.5.0
  • Loading branch information
vsubhuman authored May 13, 2021
2 parents 9f12c6a + 25e8aa1 commit 8a6c247
Show file tree
Hide file tree
Showing 16 changed files with 233 additions and 66 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Publish to Nightly
on:
push:
branches:
- develop
- nightly

jobs:
build:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules
npm-debug.log
.DS_Store
.vscode/
.idea/
4 changes: 0 additions & 4 deletions packages/yoroi-ergo-connector/src/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ class ErgoAPI {
return this._ergo_rpc_call("get_utxos", [amount, token_id, paginate]);
}
sign_tx(tx) {
return this._ergo_rpc_call("sign_tx", [tx]);
}
get_used_addresses(paginate = undefined) {
return this._ergo_rpc_call("get_used_addresses", [paginate]);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/yoroi-extension/app/actions/ada/voting-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { PublicDeriver } from '../../api/ada/lib/storage/models/PublicDeriver/in

export default class VotingActions {
generateCatalystKey: AsyncAction<void> = new AsyncAction();
createTransaction: AsyncAction<string> = new AsyncAction();
createTransaction: AsyncAction<null | string> = new AsyncAction();
signTransaction: AsyncAction<{|
password?: string,
publicDeriver: PublicDeriver<>,
|}> = new AsyncAction();
cancel: Action<void> = new Action();
submitGenerate: Action<void> = new Action();
goBackToGenerate: Action<void> = new Action();
submitConfirm: Action<void> = new Action();
submitConfirm: AsyncAction<void> = new AsyncAction();
submitConfirmError: Action<void> = new Action();
submitRegister: Action<void> = new Action();
submitRegisterError: Action<Error> = new Action();
Expand Down
35 changes: 31 additions & 4 deletions packages/yoroi-extension/app/api/ada/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,12 +374,24 @@ export type CreateDelegationTxRequest = {|
valueInAccount: MultiToken,
|};

export type CreateVotingRegTxRequest = {|
type CreateVotingRegTxRequestCommon = {|
publicDeriver: IPublicDeriver<ConceptualWallet> & IGetAllUtxos & IHasUtxoChains,
absSlotNumber: BigNumber,
metadata: RustModule.WalletV4.GeneralTransactionMetadata,
|};

export type CreateVotingRegTxRequest = {|
...CreateVotingRegTxRequestCommon,
normalWallet: {|
metadata: RustModule.WalletV4.GeneralTransactionMetadata,
|}
|} | {|
...CreateVotingRegTxRequestCommon,
trezorTWallet: {|
votingPublicKey: string,
|}
|};


export type CreateDelegationTxResponse = {|
signTxRequest: HaskellShelleyTxSignRequest,
totalAmountToDelegate: MultiToken,
Expand Down Expand Up @@ -849,7 +861,6 @@ export default class AdaApi {
Number.parseInt(config.ChainNetworkId, 10),
);
Logger.debug(`${nameof(AdaApi)}::${nameof(this.createTrezorSignTxData)} success: ` + stringifyData(trezorSignTxPayload));

return {
trezorSignTxPayload,
};
Expand Down Expand Up @@ -1400,7 +1411,16 @@ export default class AdaApi {
if (changeAddr == null) {
throw new Error(`${nameof(this.createVotingRegTx)} no internal addresses left. Should never happen`);
}
const trxMetadata = RustModule.WalletV4.TransactionMetadata.new(request.metadata);
let trxMetadata;
if (request.trezorTWallet) {
trxMetadata = undefined;
} else {
// Mnemonic wallet
trxMetadata = RustModule.WalletV4.TransactionMetadata.new(
request.normalWallet.metadata
);
}

const unsignedTx = shelleyNewAdaUnsignedTx(
[],
{
Expand Down Expand Up @@ -1431,6 +1451,13 @@ export default class AdaApi {
neededHashes: new Set(),
wits: new Set(),
},
trezorTCatalystRegistrationTxSignData:
request.trezorTWallet ?
{
votingPublicKey: request.trezorTWallet.votingPublicKey,
nonce: request.absSlotNumber,
} :
undefined,
});
} catch (error) {
Logger.error(`${nameof(AdaApi)}::${nameof(this.createVotingRegTx)} error: ` + stringifyError(error));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ implements ISignRequest<RustModule.WalletV4.TransactionBuilder> {
neededHashes: Set<string>, // StakeCredential
wits: Set<string>, // Vkeywitness
|};
trezorTCatalystRegistrationTxSignData: void | {|
votingPublicKey: string,
nonce: BigNumber,
|};

constructor(data: {|
senderUtxos: Array<CardanoAddressedUtxo>,
Expand All @@ -56,13 +60,19 @@ implements ISignRequest<RustModule.WalletV4.TransactionBuilder> {
neededHashes: Set<string>, // StakeCredential
wits: Set<string>, // Vkeywitness
|},
trezorTCatalystRegistrationTxSignData?: void | {|
votingPublicKey: string,
nonce: BigNumber,
|};
|}) {
this.senderUtxos = data.senderUtxos;
this.unsignedTx = data.unsignedTx;
this.changeAddr = data.changeAddr;
this.metadata = data.metadata;
this.networkSettingSnapshot = data.networkSettingSnapshot;
this.neededStakingKeyHashes = data.neededStakingKeyHashes;
this.trezorTCatalystRegistrationTxSignData =
data.trezorTCatalystRegistrationTxSignData;
}

txId(): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,26 @@ export async function createTrezorSignTxPayload(
metadata: Buffer.from(metadata.to_bytes()).toString('hex')
};

if (signRequest.trezorTCatalystRegistrationTxSignData) {
const { votingPublicKey, nonce } = signRequest.trezorTCatalystRegistrationTxSignData;
request = {
...request,
auxiliaryData: {
catalystRegistrationParameters: {
votingPublicKey,
stakingPath: getStakingKeyPath(),
rewardAddressParameters: {
addressType: ADDRESS_TYPE.Reward,
stakingPath: getStakingKeyPath(),
},
nonce,
},
}
};
}
// trezor-connect v8.1.26 doesn't support auxiliaryData. When it does, we
// can remove the next line:
// $FlowFixMe[prop-missing]
return request;
}

Expand Down
25 changes: 25 additions & 0 deletions packages/yoroi-extension/app/components/wallet/voting/Voting.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,21 @@ const messages = defineMessages({
id: 'wallet.voting.line4',
defaultMessage: '!!!Open the Catalyst Voting App and click on the Complete registration button.',
},
notDelegated: {
id: 'wallet.voting.notDelegated',
defaultMessage: '!!!You have not delegated. Your voting power is how much you delegate and the voting rewards will be distributed to your delegation reward address. Please make sure to delegate before voting.',
},
keepDelegated: {
id: 'wallet.voting.keepDelegated',
defaultMessage: '!!!Your voting power is how much you delegate and the voting rewards will be distributed to your delegation reward address. Please keep delegated until the voting ends.',
},
});

type Props = {|
+start: void => void,
+onExternalLinkClick: MouseEvent => void,
+hasAnyPending: boolean,
+isDelegated: boolean,
|};

@observer
Expand Down Expand Up @@ -108,6 +117,22 @@ export default class Voting extends Component<Props> {
</div>
</div>
</div>
<div className={styles.delegationStatus}>
{this.props.isDelegated ?
(
<div className={styles.lineText}>
{intl.formatMessage(messages.keepDelegated)}
</div>
) :
(
<div className={styles.warningBox}>
<WarningBox>
{intl.formatMessage(messages.notDelegated)}
</WarningBox>
</div>
)
}
</div>
<div className={styles.registerButton}>
<Button
className={buttonClasses}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,9 @@
text-align: center;
margin-bottom: 32px;
}

.delegationStatus {
text-align: center;
margin-bottom: 32px;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export default class VotingRegistrationDialogContainer extends Component<Props>
trigger: actions.ada.voting.goBackToGenerate.trigger,
},
submitConfirm: {
trigger: actions.ada.voting.submitConfirm.trigger,
trigger: () => { actions.ada.voting.submitConfirm.trigger() },
},
submitConfirmError: {
trigger: actions.ada.voting.submitConfirmError.trigger,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@ import environment from '../../../environment';
import { MultiToken } from '../../../api/common/lib/MultiToken';
import RegistrationOver from './RegistrationOver';
import { networks, } from '../../../api/ada/lib/storage/database/prepackaged/networks';
import type { DelegationRequests } from '../../../stores/toplevel/DelegationStore';

export type GeneratedData = typeof VotingPage.prototype.generated;
type Props = {|
...InjectedOrGenerated<GeneratedData>,
|};

const roundInfo = {
startDate: new Date(Date.parse('13 May 2021 19:00:00 GMT')),
endDate: new Date(Date.parse('20 May 2021 19:00:00 GMT')),
startDate: new Date(Date.parse('2021-05-20T19:00:00Z')),
endDate: new Date(Date.parse('2021-05-27T19:00:00Z')),
nextRound: 4,
};

Expand All @@ -47,6 +48,36 @@ export default class VotingPage extends Component<Props> {
this.generated.actions.dialogs.open.trigger({ dialog: VotingRegistrationDialogContainer });
};

get isDelegated(): ?boolean {
const publicDeriver = this.generated.stores.wallets.selected;
const delegationStore = this.generated.stores.delegation;

if (!publicDeriver) {
throw new Error(`${nameof(this.isDelegated)} no public deriver. Should never happen`);
}

const delegationRequests = delegationStore.getDelegationRequests(publicDeriver);
if (delegationRequests == null) {
throw new Error(`${nameof(this.isDelegated)} called for non-reward wallet`);
}
const currentDelegation = delegationRequests.getCurrentDelegation;

if (
!currentDelegation.wasExecuted ||
currentDelegation.isExecuting ||
currentDelegation.result == null
) {
return undefined;
}
if(
!currentDelegation.result.currEpoch ||
currentDelegation.result.currEpoch.pools.length === 0
) {
return false;
}
return true;
}

render(): Node {
const {
uiDialogs,
Expand Down Expand Up @@ -120,6 +151,7 @@ export default class VotingPage extends Component<Props> {
start={this.start}
hasAnyPending={this.generated.hasAnyPending}
onExternalLinkClick={handleExternalLinkClick}
isDelegated={this.isDelegated === true}
/>
</div>
);
Expand Down Expand Up @@ -152,6 +184,9 @@ export default class VotingPage extends Component<Props> {
wallets: {|
selected: null | PublicDeriver<>,
|},
delegation: {|
getDelegationRequests: (PublicDeriver<>) => void | DelegationRequests,
|},
|},
|} {
if (this.props.generated !== undefined) {
Expand Down Expand Up @@ -197,6 +232,9 @@ export default class VotingPage extends Component<Props> {
tokenInfoStore: {
tokenInfo: stores.tokenInfoStore.tokenInfo,
},
delegation: {
getDelegationRequests: stores.delegation.getDelegationRequests,
},
},
VotingRegistrationDialogProps: ({
actions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ const defaultProps: ({|
tokenInfoStore: {
tokenInfo: mockFromDefaults(defaultAssets),
},
delegation: {
getDelegationRequests: walletLookup([request.wallet]).getDelegation,
},
},
actions: {
dialogs: {
Expand Down
2 changes: 2 additions & 0 deletions packages/yoroi-extension/app/i18n/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -779,10 +779,12 @@
"wallet.voting.dialog.stepQrCode": "QR Code",
"wallet.voting.dialog.title": "Register for Voting",
"wallet.voting.dialog.transactionLabel": "Transaction",
"wallet.voting.keepDelegated": "Your voting power is how much you delegate and the voting rewards will be distributed to your delegation reward address. Please keep delegated until the voting ends.",
"wallet.voting.line2": "Before you begin, make sure to complete steps below",
"wallet.voting.line3": "Download the Catalyst Voting App.",
"wallet.voting.line4": "Open the Catalyst Voting App and click on the Complete registration button.",
"wallet.voting.lineTitle": "Register to vote on Fund 3",
"wallet.voting.notDelegated": "You have not delegated. Your voting power is how much you delegate and the voting rewards will be distributed to your delegation reward address. Please make sure to delegate before voting.",
"wallet.withdrawal.transaction.unregister": "This transaction will unregister one or more staking keys, giving you back your {refundAmount} {ticker} from your deposit",
"widgets.copyableaddress.addressCopyTooltipMessage": "Copy to clipboard",
"widgets.explorer.tooltip": "Go to {websiteName}",
Expand Down
Loading

0 comments on commit 8a6c247

Please sign in to comment.