Skip to content

Commit

Permalink
Support alph_signAndSubmitUnsignedTx in mobile wallet
Browse files Browse the repository at this point in the history
Closes #1083
  • Loading branch information
nop33 committed Jan 9, 2025
1 parent 694d610 commit 6ff6222
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/red-cows-fly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@alephium/mobile-wallet": patch
---

Support alph_signAndSubmitUnsignedTx
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,8 @@ export const WalletConnectContextProvider = ({ children }: { children: ReactNode

break
}
case 'alph_signUnsignedTx': {
case 'alph_signUnsignedTx':
case 'alph_signAndSubmitUnsignedTx': {
const { signerAddress, signerKeyType, unsignedTx } = requestEvent.params.request
.params as SignUnsignedTxParams

Expand Down Expand Up @@ -725,7 +726,8 @@ export const WalletConnectContextProvider = ({ children }: { children: ReactNode
requestData: {
type: 'sign-unsigned-tx',
wcData: wcTxData,
unsignedTxData: decodedResult
unsignedTxData: decodedResult,
submit: requestEvent.params.request.method === 'alph_signAndSubmitUnsignedTx'
}
}
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { getHumanReadableError, SessionRequestEvent, WALLETCONNECT_ERRORS, WalletConnectError } from '@alephium/shared'
import {
client,
getHumanReadableError,
SessionRequestEvent,
WALLETCONNECT_ERRORS,
WalletConnectError
} from '@alephium/shared'
import { ALPH } from '@alephium/token-list'
import {
binToHex,
Expand Down Expand Up @@ -212,6 +218,13 @@ const WalletConnectSessionRequestModal = withModal(
await getAddressAsymetricKey(signAddress.hash, 'private')
)

if (requestData.submit) {
await client.node.transactions.postTransactionsSubmit({
unsignedTx: requestData.wcData.unsignedTx,
signature
})
}

signResult = {
...requestData.unsignedTxData,
signature,
Expand Down
1 change: 1 addition & 0 deletions apps/mobile-wallet/src/types/walletConnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ export type SessionRequestData =
type: 'sign-unsigned-tx'
wcData: SignUnsignedTxData
unsignedTxData: DecodeUnsignedTxResult
submit: boolean
}

0 comments on commit 6ff6222

Please sign in to comment.