Skip to content

Commit c878085

Browse files
committed
Fixed account not properly loading after unlock and loading of some account based auths
1 parent a0fde43 commit c878085

File tree

6 files changed

+46
-9
lines changed

6 files changed

+46
-9
lines changed

app/modules/handler/actions/uri.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { find } from 'lodash';
22
import { get } from 'dot-prop-immutable';
33
import { Serialize } from 'eosjs2';
4-
import { PrivateKey, Signature } from '@greymass/eosio';
4+
import { PrivateKey, PublicKey, Signature } from '@greymass/eosio';
55

66
import * as types from '../../../shared/actions/types';
77
import eos from '../../../shared/actions/helpers/eos';
@@ -357,9 +357,10 @@ export function signIdentityRequest(
357357
const signer = eos(networkConfig, true, true);
358358
setTimeout(async () => {
359359
try {
360+
const requiredKeys = [String(PublicKey.from(wallet.pubkey))]
360361
const signed = await signer.sign({
361362
chainId: blockchain.chainId,
362-
requiredKeys: [signer.convert(wallet.pubkey)],
363+
requiredKeys,
363364
serializedTransaction: prompt.resolved.serializedTransaction,
364365
});
365366
const callbackParams = prompt.resolved.getCallback(signed.signatures, 0);

app/modules/handler/containers/Prompt.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,15 @@ class PromptContainer extends Component<Props> {
160160
}
161161
};
162162
swapAccount = (e, { value }) => {
163-
const { actions } = this.props;
163+
const { actions, wallets } = this.props;
164164
const { blockchain } = this.state;
165-
const wallet = pick(value, ['account', 'authorization', 'mode', 'path', 'pubkey']);
165+
const wallet = pick(value, ['account', 'authorization', 'authAccount', 'authAuthorization', 'chainId', 'mode', 'path', 'pubkey']);
166+
if (!wallet.pubkey && wallet.authAccount && wallet.authAuthorization) {
167+
const authority = find(wallets, { chainId: wallet.chainId, account: wallet.authAccount, authorization: wallet.authAuthorization })
168+
if (authority) {
169+
wallet.pubkey = authority.pubkey
170+
}
171+
}
166172
this.setState({
167173
displayShareLink: initialState.displayShareLink,
168174
enableWhitelist: initialState.enableWhitelist,

app/modules/handler/containers/Stage.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,9 @@ class PromptStage extends Component<Props> {
175175
password,
176176
blockchain.chainId,
177177
// callback
178-
() => actions.signURI(resolved.transaction, blockchain, wallet, broadcast, prompt.callback)
178+
() => actions.signURI(resolved.transaction, blockchain, wallet, broadcast, prompt.callback),
179+
wallet.authAccount,
180+
wallet.authAuthorization
179181
);
180182
}
181183
onUnlockAndSignIdentity= (password) => {
@@ -195,7 +197,9 @@ class PromptStage extends Component<Props> {
195197
prompt,
196198
blockchain,
197199
wallet,
198-
)
200+
),
201+
wallet.authAccount,
202+
wallet.authAuthorization
199203
);
200204
}
201205
render() {
@@ -264,8 +268,9 @@ class PromptStage extends Component<Props> {
264268
([reqType] = prompt.req);
265269
}
266270

267-
268-
const hasWallet = !!(wallet.account && wallet.authorization && wallet.mode && wallet.pubkey);
271+
const hasPublicKey = !!wallet.pubkey
272+
const hasAccountAuth = !!(wallet.authAccount && wallet.authAuthorization)
273+
const hasWallet = !!(wallet.account && wallet.authorization && wallet.mode && (hasPublicKey || hasAccountAuth));
269274
const hasCallback = !!(prompt && prompt.callback);
270275

271276
const hasForegroundCallback = !!(

app/modules/handler/containers/Stage/Identity.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ class PromptStageIdentity extends Component<Props> {
5555
const {
5656
account,
5757
authorization,
58+
authAccount,
59+
authAuthorization,
5860
mode,
5961
pubkey,
6062
} = wallet;
@@ -99,6 +101,8 @@ class PromptStageIdentity extends Component<Props> {
99101
<GlobalAccountDropdownSelect
100102
account={account}
101103
authorization={authorization}
104+
authAccount={authAccount}
105+
authAuthorization={authAuthorization}
102106
mode={mode}
103107
pubkey={pubkey}
104108
chainId={chainId}

app/shared/actions/wallet.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,15 @@ export function unlockWallet(password, useWallet = false, unlockAll = true) {
289289
};
290290
}
291291

292-
export function unlockWalletByAuth(account, authorization, password, chainId = false, callback = false) {
292+
export function unlockWalletByAuth(
293+
account,
294+
authorization,
295+
password,
296+
chainId = false,
297+
callback = false,
298+
authAccount = false,
299+
authAuthorization = false,
300+
) {
293301
return async (dispatch: () => void, getState) => {
294302
const state = getState();
295303
const {
@@ -306,6 +314,15 @@ export function unlockWalletByAuth(account, authorization, password, chainId = f
306314
query.chainId = chainId;
307315
}
308316
const wallet = find(wallets, query);
317+
// get the appropriate public key if this is account based auth
318+
if (authAccount && authAuthorization) {
319+
const authority = find(wallets, {
320+
...query,
321+
account: authAccount,
322+
authorization: authAuthorization,
323+
});
324+
wallet.pubkey = authority.pubkey;
325+
}
309326

310327
const accountData = accounts[wallet.account];
311328
const blockchain = find(blockchains, { chainId: wallet.chainId });

app/shared/containers/Global/Account/Dropdown/Select.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ class GlobalAccountDropdownSelect extends Component<Props> {
2525
const {
2626
account,
2727
authorization,
28+
authAccount,
29+
authAuthorization,
2830
chainId,
2931
disabled,
3032
fluid,
@@ -48,6 +50,8 @@ class GlobalAccountDropdownSelect extends Component<Props> {
4850
<GlobalFragmentWallet
4951
account={account}
5052
authorization={authorization}
53+
authAccount={authAccount}
54+
authAuthorization={authAuthorization}
5155
mode={mode}
5256
pubkey={pubkey}
5357
/>

0 commit comments

Comments
 (0)