| 57 | private readonly txFactory = new TxOperations(this.client, getCurrentAccount().primarySocialId).txFactory |
| 58 | |
| 59 | async tx (tx: Tx): Promise<TxResult> { |
| 60 | const preTx: Array<TxCUD<Doc>> = [] |
| 61 | const postTx: Array<TxCUD<Doc>> = [] |
| 62 | await this.handleTx(preTx, postTx, tx) |
| 63 | |
| 64 | if (preTx.length > 0 || postTx.length > 0) { |
| 65 | if (TxProcessor.isExtendsCUD(tx._class)) { |
| 66 | const applyIf = this.txFactory.createTxApplyIf( |
| 67 | core.space.Tx, |
| 68 | generateId(), |
| 69 | [], |
| 70 | [], |
| 71 | [...preTx, tx as TxCUD<Doc>, ...postTx], |
| 72 | 'process', |
| 73 | true |
| 74 | ) |
| 75 | return await this.provideTx(applyIf) |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | return await this.provideTx(tx) |
| 80 | } |
| 81 | |
| 82 | private async handleTx (preTx: Array<TxCUD<Doc>>, postTx: Array<TxCUD<Doc>>, ...txes: Tx[]): Promise<void> { |
| 83 | for (const etx of txes) { |