Skip to content

Commit e3af74d

Browse files
committed
backend/aopp: provide account code to the frontend
So it can use it in the 'Verify address' button. Before, it used the frontend accountCode state var set in the choosing-account step, but that step is skipped if there is only one account.
1 parent a9e59d6 commit e3af74d

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

backend/aopp.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ type AOPP struct {
8686
ErrorCode ErrorCode `json:"errorCode"`
8787
// Accounts is the list of accounts the user can choose from. Only applies if State == aoppStateChoosingAccount.
8888
Accounts []account `json:"accounts"`
89+
// AccountCode is the code of the chosen account from which an address will be taken. Only
90+
// applies for states after (and excluding) `aoppStateChoosingAccount`.
91+
AccountCode accounts.Code `json:"accountCode"`
8992
// Address that will be delivered to the requesting party via the callback. Only applies if
9093
// State == aoppStateSigning or aoppStateSuccess.
9194
Address string `json:"address"`
@@ -266,6 +269,7 @@ func (backend *Backend) aoppChooseAccount(code accounts.Code) {
266269
return
267270
}
268271

272+
backend.aopp.AccountCode = code
269273
backend.aopp.State = aoppStateSyncing
270274
backend.notifyAOPP()
271275

backend/aopp_test.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,13 @@ func TestAOPPSuccess(t *testing.T) {
221221
{Name: test.accountName, Code: test.accountCode},
222222
{Name: "Second account", Code: regularAccountCode(rootFingerprint, test.coinCode, 1)},
223223
},
224-
Address: test.address,
225-
AddressID: test.addressID,
226-
Callback: callback,
227-
Message: dummyMsg,
228-
coinCode: test.coinCode,
229-
format: test.format,
224+
AccountCode: test.accountCode,
225+
Address: test.address,
226+
AddressID: test.addressID,
227+
Callback: callback,
228+
Message: dummyMsg,
229+
coinCode: test.coinCode,
230+
format: test.format,
230231
},
231232
b.AOPP(),
232233
)

frontends/web/src/api/aopp.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export type Aopp = {
4747
addressID: string;
4848
message: string;
4949
callback: string;
50+
accountCode: AccountCode;
5051
};
5152

5253
export const cancel = (): Promise<null> => {

frontends/web/src/components/aopp/aopp.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ class Aopp extends Component<Props, State> {
228228
<FullscreenButtons>
229229
<Button primary onClick={aoppAPI.cancel}>{t('button.done')}</Button>
230230
<VerifyAddress
231-
accountCode={accountCode}
231+
accountCode={aopp.accountCode}
232232
address={aopp.address}
233233
addressID={aopp.addressID} />
234234
</FullscreenButtons>

0 commit comments

Comments
 (0)