From 48fe1fd4edf67fb9f54ae56148673de185fa32e3 Mon Sep 17 00:00:00 2001 From: Denis Davidyuk Date: Fri, 8 Apr 2022 19:22:44 +0300 Subject: [PATCH] refactor(aepp): drop transaction broadcasting by wallet --- .../aepp-wallet-communication/rpc/aepp-rpc.js | 27 ------------------- test/integration/rpc.js | 21 +++------------ 2 files changed, 4 insertions(+), 44 deletions(-) diff --git a/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js b/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js index a6ecf5f2dd..97b6353b24 100644 --- a/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +++ b/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js @@ -122,7 +122,6 @@ export default Ae.compose({ await this.connectToWallet(connection) } }, - deepProps: { Ae: { defaults: { walletBroadcast: true } } }, methods: { sign () { }, @@ -251,32 +250,6 @@ export default Ae.compose({ } ) }, - /** - * Overwriting of `send` AE method - * All sdk API which use it will be send notification to wallet and wait for callBack - * This method will sign, broadcast and wait until transaction will be accepted using rpc - * communication with wallet - * @function send - * @instance - * @rtype (tx: String, options = {}) => Promise - * @param {String} tx - * @param {Object} [options={}] - * @param {Object} [options.walletBroadcast=true] - * @return {Promise} Transaction broadcast result - */ - async send (tx, options = {}) { - this._ensureConnected() - this._ensureAccountAccess(options.onAccount) - const opt = { ...this.Ae.defaults, ...options } - if (!opt.walletBroadcast) { - const signed = await this.signTransaction(tx, { onAccount: opt.onAccount }) - return this.sendTransaction(signed, opt) - } - return this.rpcClient.request( - METHODS.sign, - { onAccount: opt.onAccount, tx, returnSigned: false, networkId: this.getNetworkId() } - ) - }, _ensureConnected () { if (this.rpcClient?.isConnected()) return throw new NoWalletConnectedError('You are not connected to Wallet') diff --git a/test/integration/rpc.js b/test/integration/rpc.js index 762b2801ac..188fcdc7d8 100644 --- a/test/integration/rpc.js +++ b/test/integration/rpc.js @@ -286,19 +286,6 @@ describe('Aepp<->Wallet', function () { .with.property('code', 11) }) - it('Sign and broadcast transaction by wallet', async () => { - const address = await aepp.address() - const tx = await aepp.spendTx({ - senderId: address, - recipientId: address, - amount: 0, - payload: 'zerospend' - }) - - const { blockHeight } = await aepp.send(tx) - blockHeight.should.be.a('number') - }) - it('Sign by wallet and broadcast transaction by aepp ', async () => { const address = await aepp.address() wallet.onSign = (aepp, action) => { @@ -316,7 +303,7 @@ describe('Aepp<->Wallet', function () { amount: 0, payload: 'zerospend' }) - const res = await aepp.send(tx, { walletBroadcast: false }) + const res = await aepp.send(tx) decode(res.tx.payload).toString().should.be.equal('zerospend2') res.blockHeight.should.be.a('number') }) @@ -375,8 +362,8 @@ describe('Aepp<->Wallet', function () { payload: 'zerospend' }) - await expect(aepp.send(tx)).to.be.eventually - .rejectedWith('Invalid transaction').with.property('code', 2) + await expect(aepp.send(tx)).to.be + .rejectedWith('Transaction verification errors: Fee 123 is too low, minimum fee for this transaction is 16840000000000') }) it('Add new account to wallet: receive notification for update accounts', async () => { @@ -619,7 +606,7 @@ describe('Aepp<->Wallet', function () { amount: 0, payload: 'zerospend' }) - const res = await aepp.send(tx, { walletBroadcast: false }) + const res = await aepp.send(tx) decode(res.tx.payload).toString().should.be.equal('zerospend2') res.blockHeight.should.be.a('number') })