Skip to content

Commit

Permalink
👌 IMPROVE: Add derive path support to sign transaction / preview tran…
Browse files Browse the repository at this point in the history
…saction api
  • Loading branch information
riverrun46 committed Sep 25, 2023
1 parent 8aafb43 commit 4a1d46c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion public/content.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions src/lib/actions/preview-transaction.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { mvc } from 'meta-contract'
import { getCurrentAccount, privateKey } from '../account'
import { signTransaction } from '../crypto'
import { getNetwork } from '../network'

export async function process(params: any, host: string) {
const wif = await getCurrentAccount().then(() => privateKey.value)
const { txid } = signTransaction(wif, params.transaction, true)
const account = await getCurrentAccount()
const network = await getNetwork()

const { txid } = signTransaction(account!, network, params.transaction, true)

return { txid }
}
16 changes: 4 additions & 12 deletions src/lib/actions/sign-transaction.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
import { getAddress, getCurrentAccount, privateKey } from '../account'
import connector from '../connector'
import { signTransaction } from '../crypto'
import { getNetwork } from '../network'

export async function process(params: any, host: string) {
const wif = await getCurrentAccount().then((account) => privateKey.value)
const account = await getCurrentAccount()
const network = await getNetwork()

// let sigList = []
// for (let i = 0; i < params.list.length; i++) {
// sigList[i] = sign(wif, params.list[i])
// }
if (params.returnsTransaction) {
const { txHex } = signTransaction(wif, params.transaction, params.returnsTransaction)

return { txHex }
}

const signature = signTransaction(wif, params.transaction, params.returnsTransaction)
const signature = signTransaction(account!, network, params.transaction)

return { signature }
}
Loading

0 comments on commit 4a1d46c

Please sign in to comment.