Skip to content

Commit

Permalink
chore(wallet-ui): code style and import const
Browse files Browse the repository at this point in the history
  • Loading branch information
samsiegart committed Sep 21, 2022
1 parent 1edfdd0 commit db9966c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
1 change: 1 addition & 0 deletions packages/wallet/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"@agoric/nat": "^4.1.0",
"@agoric/notifier": "^0.5.0",
"@agoric/ui-components": "^0.3.0",
"@agoric/vats": "0.11.0",
"@agoric/wallet-backend": "^0.13.0",
"@cosmjs/crypto": "0.28.13",
"@cosmjs/encoding": "0.28.13",
Expand Down
32 changes: 17 additions & 15 deletions packages/wallet/ui/src/components/ProvisionDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,33 @@ const CREATION_FEE = '10 BLD';

const ProvisionDialog = ({ onClose, open, address, href, keplrConnection }) => {
const [currentStep, setCurrentStep] = useState(steps.INITIAL);
const [error, setError] = useState('');
const [error, setError] = useState(null);

const provisionWallet = async () => {
const {
signers: { interactiveSigner },
} = keplrConnection;
if (!interactiveSigner) {
setError(errors.NO_SIGNER);
return;
}

setError('');
const provisionWallet = async signer => {
setError(null);
setCurrentStep(steps.AWAITING_APPROVAL);

try {
await interactiveSigner.submitProvision();
await signer.submitProvision();
} catch (e) {
setCurrentStep(steps.INITIAL);
setError(e.message);
return;
}

setCurrentStep(steps.IN_PROGRESS);
};

const handleCreateButtonClicked = () => {
const {
signers: { interactiveSigner },
} = keplrConnection;
if (!interactiveSigner) {
setError(errors.NO_SIGNER);
return;
}

provisionWallet(interactiveSigner);
};

const progressIndicator = text => (
<Box>
<Box
Expand Down Expand Up @@ -114,7 +116,7 @@ const ProvisionDialog = ({ onClose, open, address, href, keplrConnection }) => {
<Button color="cancel" onClick={onClose}>
Change Connection
</Button>
<Button onClick={provisionWallet}>Create</Button>
<Button onClick={handleCreateButtonClicked}>Create</Button>
</DialogActions>
)}
</Dialog>
Expand Down
4 changes: 2 additions & 2 deletions packages/wallet/ui/src/util/keyManagement.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @ts-check
import { PowerFlags } from '@agoric/vats/src/core/basic-behaviors.js';
import { fromBech32, toBech32, fromBase64, toBase64 } from '@cosmjs/encoding';
import { DirectSecp256k1Wallet, Registry } from '@cosmjs/proto-signing';
import {
Expand Down Expand Up @@ -433,8 +434,7 @@ export const makeInteractiveSigner = async (
value: {
address: b64address,
nickname: 'my wallet',
// XXX dry with PowerFlags const
powerFlags: ['SMART_WALLET'],
powerFlags: [PowerFlags.SMART_WALLET],
submitter: b64address,
},
};
Expand Down

0 comments on commit db9966c

Please sign in to comment.