Skip to content

Commit

Permalink
Change order of functions in SignTransactionApi
Browse files Browse the repository at this point in the history
  • Loading branch information
sisou committed Feb 28, 2019
1 parent 2661502 commit 77aa78a
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions src/request/sign-transaction/SignTransactionApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,6 @@
/* global Errors */

class SignTransactionApi extends TopLevelApi {
/**
* Checks that the given layout is valid
* @param {any} layout
* @returns {any}
*/
parseLayout(layout) {
if (!layout) {
return SignTransactionApi.Layouts.STANDARD;
}
// @ts-ignore (Property 'values' does not exist on type 'ObjectConstructor'.)
if (Object.values(SignTransactionApi.Layouts).indexOf(layout) === -1) {
throw new Errors.InvalidRequestError('Invalid selected layout');
}
return layout;
}

/**
* @param {KeyguardRequest.SignTransactionRequest} request
* @returns {Promise<Parsed<KeyguardRequest.SignTransactionRequest>>}
Expand Down Expand Up @@ -52,17 +36,33 @@ class SignTransactionApi extends TopLevelApi {
}

/**
* @param {Parsed<KeyguardRequest.SignTransactionRequest>} parsedRequest
* Checks that the given layout is valid
* @param {any} layout
* @returns {any}
*/
async onBeforeRun(parsedRequest) {
if (parsedRequest.layout === SignTransactionApi.Layouts.CHECKOUT) {
this.setGlobalCloseButtonText(I18n.translatePhrase('sign-tx-cancel-payment'));
parseLayout(layout) {
if (!layout) {
return SignTransactionApi.Layouts.STANDARD;
}
// @ts-ignore (Property 'values' does not exist on type 'ObjectConstructor'.)
if (Object.values(SignTransactionApi.Layouts).indexOf(layout) === -1) {
throw new Errors.InvalidRequestError('Invalid selected layout');
}
return layout;
}

get Handler() {
return SignTransaction;
}

/**
* @param {Parsed<KeyguardRequest.SignTransactionRequest>} parsedRequest
*/
async onBeforeRun(parsedRequest) {
if (parsedRequest.layout === SignTransactionApi.Layouts.CHECKOUT) {
this.setGlobalCloseButtonText(I18n.translatePhrase('sign-tx-cancel-payment'));
}
}
}

/** @type {{[layout: string]: string}} */
Expand Down

0 comments on commit 77aa78a

Please sign in to comment.