Skip to content

Commit

Permalink
refactor(aepp): drop transaction broadcasting by wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
davidyuk committed Apr 8, 2022
1 parent 6d1f738 commit 48fe1fd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 44 deletions.
27 changes: 0 additions & 27 deletions src/utils/aepp-wallet-communication/rpc/aepp-rpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ export default Ae.compose({
await this.connectToWallet(connection)
}
},
deepProps: { Ae: { defaults: { walletBroadcast: true } } },
methods: {
sign () {
},
Expand Down Expand Up @@ -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<Object>} 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')
Expand Down
21 changes: 4 additions & 17 deletions test/integration/rpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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')
})
Expand Down Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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')
})
Expand Down

0 comments on commit 48fe1fd

Please sign in to comment.