Skip to content

Commit

Permalink
chore: misc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rossbulat committed Oct 26, 2024
1 parent 52f2219 commit a36401d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/app/src/hooks/useBuildPayload/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ export const useBuildPayload = ({
signedExtensions: api.registry.signedExtensions,
tip: api.registry.createType('Compact<Balance>', 0).toHex(),
version: tx.version,
withSignedTransaction: true,
};

// If the source is `ledger`, add the metadata hash to the payload.
if (source === 'ledger') {
const metadataHash = await fetchMetadataHash();
payload.mode = 1;
payload.metadataHash = metadataHash;
payload.withSignedTransaction = true;
}

// Create the payload bytes.
Expand Down
4 changes: 2 additions & 2 deletions packages/app/src/library/ConnectOverlay/QrReader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const QrReader = ({
const valid =
isValidAddress(qrData) &&
!vaultAccountExists(directoryId, qrData) &&
!formatAccountSs58(qrData, ss58);
formatAccountSs58(qrData, ss58) !== null;

useEffect(() => {
// Add account and close overlay if valid.
Expand All @@ -54,7 +54,7 @@ export const QrReader = ({
qrData === undefined
? 'Waiting for QR Code'
: isValidAddress(qrData)
? formatAccountSs58(qrData, ss58)
? formatAccountSs58(qrData, ss58) === null
? 'Different Network Address'
: exists
? 'Account Already Imported'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ export const WalletConnect = ({
const { signWcTx, wcSessionActive, fetchAccounts, connectProvider } =
useWalletConnect();

const from = getSender(instanceId);

// Store whether the user is currently signing a transaction.
const [isSgning, setIsSigning] = useState<boolean>(false);

Expand All @@ -62,6 +60,8 @@ export const WalletConnect = ({
buttonOnClick = async () => {
setIsSigning(true);

const sender = getSender(instanceId);

// If Wallet Connect session is not active, re-connect.
if (!wcSessionActive) {
await connectProvider();
Expand All @@ -71,16 +71,17 @@ export const WalletConnect = ({
const wcAccounts = await fetchAccounts(chainId as ChainId);

// Re-fetch accounts here to ensure that the signer address still exists.
const accountExists = from && wcAccounts.includes(from);
const accountExists = sender && wcAccounts.includes(sender);

const payload = getTxPayloadValue(instanceId);
if (!from || !payload || !accountExists) {
setIsSigning(false);
if (!sender || !payload || !accountExists) {
return;
}

setIsSigning(true);

try {
const signature = await signWcTx(caip, payload, from);
const signature = await signWcTx(caip, payload, sender);
if (signature) {
setTxSignature(instanceId, signature);
}
Expand Down

0 comments on commit a36401d

Please sign in to comment.