Skip to content

Commit

Permalink
feat: make rejected tx
Browse files Browse the repository at this point in the history
  • Loading branch information
devchenyan committed Jul 14, 2024
1 parent 79df3c0 commit 8dd0008
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 12 deletions.
4 changes: 4 additions & 0 deletions packages/neuron-ui/src/components/History/RowExtend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ const RowExtend = ({ column, columns, isMainnet, id, bestBlockNumber, isWatchOnl

useEffect(() => {
setAmendabled(false)
// @ts-ignore
getOnChainTransaction(hash).then(res => {
console.log('OnChainTransaction----', res)
})
if (status !== 'success' && column.type !== 'receive' && !isWatchOnly) {
getOnChainTransaction(hash).then(tx => {
// @ts-expect-error Replace-By-Fee (RBF)
Expand Down
60 changes: 48 additions & 12 deletions packages/neuron-wallet/src/services/transaction-sender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ interface PathAndPrivateKey {
privateKey: string
}

// @ts-ignore
let arr = []

export default class TransactionSender {
static MULTI_SIGN_ARGS_LENGTH = 58

Expand Down Expand Up @@ -97,24 +100,57 @@ export default class TransactionSender {
}

public async broadcastTx(walletID: string = '', tx: Transaction, amendHash = '') {
arr.push({ walletID, tx, amendHash })
// @ts-ignore
logger.info('arr----', arr)
if (arr.length < 2) {
return Promise.resolve('')
}
// @ts-ignore
logger.info('arr--process---', arr)
const currentNetwork = NetworksService.getInstance().getCurrent()
const rpc = generateRPC(currentNetwork.remote, currentNetwork.type)
await rpc.sendTransaction(tx.toSDKRawTransaction(), 'passthrough')
const txHash = tx.hash!

await TransactionPersistor.saveSentTx(tx, txHash)
await MultisigService.saveSentMultisigOutput(tx)
if (amendHash) {
await AmendTransactionService.save(txHash, amendHash)
}
// @ts-ignore
arr.forEach(async item => {
// @ts-ignore
await rpc.sendTransaction(item.tx.toSDKRawTransaction(), 'passthrough')
const txHash = item.tx.hash!

if (walletID) {
const wallet = WalletService.getInstance().get(walletID)
await wallet.checkAndGenerateAddresses()
}
return txHash
await TransactionPersistor.saveSentTx(item.tx, txHash)
await MultisigService.saveSentMultisigOutput(item.tx)
if (item.amendHash) {
await AmendTransactionService.save(txHash, item.amendHash)
}

if (item.walletID) {
const wallet = WalletService.getInstance().get(item.walletID)
await wallet.checkAndGenerateAddresses()
}
})
arr = []
return tx.hash!
}

// public async broadcastTx(walletID: string = '', tx: Transaction, amendHash = '') {
// const currentNetwork = NetworksService.getInstance().getCurrent()
// const rpc = generateRPC(currentNetwork.remote, currentNetwork.type)
// await rpc.sendTransaction(tx.toSDKRawTransaction(), 'passthrough')
// const txHash = tx.hash!

// await TransactionPersistor.saveSentTx(tx, txHash)
// await MultisigService.saveSentMultisigOutput(tx)
// if (amendHash) {
// await AmendTransactionService.save(txHash, amendHash)
// }

// if (walletID) {
// const wallet = WalletService.getInstance().get(walletID)
// await wallet.checkAndGenerateAddresses()
// }
// return txHash
// }

public async sign(
walletID: string = '',
transaction: Transaction,
Expand Down

1 comment on commit 8dd0008

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Packaging for test is done in 9928765069

Please sign in to comment.