diff --git a/README.md b/README.md index ea2215a4..5b7a4c8e 100644 --- a/README.md +++ b/README.md @@ -214,7 +214,6 @@ let sentTransaction = await wallet.sendTransaction({ value: "0", sent: function(transaction){}, confirmed: function(transaction){}, - ensured: function(transaction){}, failed: function(transaction){} }) @@ -232,7 +231,6 @@ let sentTransaction = await wallet.sendTransaction({ value: "1000000000000000", sent: function(transaction){}, confirmed: function(transaction){}, - ensured: function(transaction){}, failed: function(transaction){} }) @@ -255,8 +253,6 @@ Arguments for `sendTransaction`: `confirmed: Function`: Callback to be executed if transaction has been confirmed once by the network. -`ensured: Function`: Callback to be executed if transaction has been reached safe amount of confirmations (successful transaction confirmation can be ensured). - `failed: Function`: Callback to be executed if transaction failed to confirm on the network (aka reverted). #### value @@ -295,7 +291,7 @@ in case wallet is connected to the wrong network and network cant be switched au #### Transaction -Returned instances of `Transaction` (e.g. via `sendTransaction`, or `sent`, `confirmed`, `ensured` or `failed` callback) have the following format: +Returned instances of `Transaction` (e.g. via `sendTransaction`, or `sent`, `confirmed` or `failed` callback) have the following format: `blockchain: string`: Blockchain the transaction belongs to. @@ -319,8 +315,6 @@ Returned instances of `Transaction` (e.g. via `sendTransaction`, or `sent`, `con `confirmation: Promise`: Returns a promise that resolves once the transaction confirms. -`ensurance: Promise`: Returns a promise that resolves once the transaction confirms enough times to consider it ensured. - `failure: Promise`: Returns a promise that resolves once the transaction fails. ### Estimations diff --git a/dist/esm/index.js b/dist/esm/index.js index 6f0960c2..399bed23 100644 --- a/dist/esm/index.js +++ b/dist/esm/index.js @@ -17760,7 +17760,7 @@ function parseUnits(value, unitName) { function _optionalChain$5(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } class Transaction { - constructor({ blockchain, from, nonce, to, api, method, params, value, sent, confirmed, ensured, failed }) { + constructor({ blockchain, from, nonce, to, api, method, params, value, sent, confirmed, failed }) { this.blockchain = blockchain; this.from = from; @@ -17772,10 +17772,8 @@ class Transaction { this.value = _optionalChain$5([Transaction, 'access', _ => _.bigNumberify, 'call', _2 => _2(value, blockchain), 'optionalAccess', _3 => _3.toString, 'call', _4 => _4()]); this.sent = sent; this.confirmed = confirmed; - this.ensured = ensured; this.failed = failed; this._confirmed = false; - this._ensured = false; this._failed = false; } @@ -17822,19 +17820,6 @@ class Transaction { }) } - ensurance() { - if (this._ensured) { - return Promise.resolve(this) - } - return new Promise((resolve, reject) => { - let originalEnsured = this.ensured; - this.ensured = () => { - if (originalEnsured) originalEnsured(this); - resolve(this); - }; - }) - } - failure() { if (this._failed) { return Promise.resolve(this) @@ -17879,15 +17864,22 @@ const sendTransaction$1 = async ({ transaction, wallet })=> { transaction._confirmed = true; if (transaction.confirmed) transaction.confirmed(transaction); }).catch((error)=>{ - transaction._failed = true; - if(transaction.failed) transaction.failed(transaction, error); - }); - sentTransaction.wait(12).then(() => { - transaction._ensured = true; - if (transaction.ensured) transaction.ensured(transaction); - }).catch((error)=>{ - transaction._failed = true; - if(transaction.failed) transaction.failed(transaction, error); + if(error && error.code && error.code == 'TRANSACTION_REPLACED') { + if(error.replacement && error.replacement.hash) { + transaction.id = error.replacement.hash; + transaction.url = Blockchain.findByName(transaction.blockchain).explorerUrlFor({ transaction }); + } + if(error.replacement && error.replacement.hash && error.receipt && error.receipt.status == 1) { + transaction._confirmed = true; + if (transaction.confirmed) transaction.confirmed(transaction); + } else if(error.replacement && error.replacement.hash && error.receipt && error.receipt.status == 0) { + transaction._failed = true; + if(transaction.failed) transaction.failed(transaction, error); + } + } else { + transaction._failed = true; + if(transaction.failed) transaction.failed(transaction, error); + } }); } else { throw('Submitting transaction failed!') @@ -18128,15 +18120,20 @@ const sendTransaction = async ({ transaction, wallet })=> { transaction._confirmed = true; if (transaction.confirmed) transaction.confirmed(transaction); }).catch((error)=>{ - transaction._failed = true; - if(transaction.failed) transaction.failed(transaction, error); - }); - sentTransaction.wait(12).then(() => { - transaction._ensured = true; - if (transaction.ensured) transaction.ensured(transaction); - }).catch((error)=>{ - transaction._failed = true; - if(transaction.failed) transaction.failed(transaction, error); + if(error && error.code && error.code == 'TRANSACTION_REPLACED') { + if(error.replacement && error.replacement.hash && error.receipt && error.receipt.status == 1) { + transaction.id = error.replacement.hash; + transaction._confirmed = true; + if (transaction.confirmed) transaction.confirmed(transaction); + } else if(error.replacement && error.replacement.hash && error.receipt && error.receipt.status == 0) { + transaction.id = error.replacement.hash; + transaction._failed = true; + if(transaction.failed) transaction.failed(transaction, error); + } + } else { + transaction._failed = true; + if(transaction.failed) transaction.failed(transaction, error); + } }); } } else { diff --git a/dist/umd/index.js b/dist/umd/index.js index abfd702b..8d5d3975 100644 --- a/dist/umd/index.js +++ b/dist/umd/index.js @@ -17764,7 +17764,7 @@ function _optionalChain$5(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } class Transaction { - constructor({ blockchain, from, nonce, to, api, method, params, value, sent, confirmed, ensured, failed }) { + constructor({ blockchain, from, nonce, to, api, method, params, value, sent, confirmed, failed }) { this.blockchain = blockchain; this.from = from; @@ -17776,10 +17776,8 @@ this.value = _optionalChain$5([Transaction, 'access', _ => _.bigNumberify, 'call', _2 => _2(value, blockchain), 'optionalAccess', _3 => _3.toString, 'call', _4 => _4()]); this.sent = sent; this.confirmed = confirmed; - this.ensured = ensured; this.failed = failed; this._confirmed = false; - this._ensured = false; this._failed = false; } @@ -17826,19 +17824,6 @@ }) } - ensurance() { - if (this._ensured) { - return Promise.resolve(this) - } - return new Promise((resolve, reject) => { - let originalEnsured = this.ensured; - this.ensured = () => { - if (originalEnsured) originalEnsured(this); - resolve(this); - }; - }) - } - failure() { if (this._failed) { return Promise.resolve(this) @@ -17883,15 +17868,22 @@ transaction._confirmed = true; if (transaction.confirmed) transaction.confirmed(transaction); }).catch((error)=>{ - transaction._failed = true; - if(transaction.failed) transaction.failed(transaction, error); - }); - sentTransaction.wait(12).then(() => { - transaction._ensured = true; - if (transaction.ensured) transaction.ensured(transaction); - }).catch((error)=>{ - transaction._failed = true; - if(transaction.failed) transaction.failed(transaction, error); + if(error && error.code && error.code == 'TRANSACTION_REPLACED') { + if(error.replacement && error.replacement.hash) { + transaction.id = error.replacement.hash; + transaction.url = web3Blockchains.Blockchain.findByName(transaction.blockchain).explorerUrlFor({ transaction }); + } + if(error.replacement && error.replacement.hash && error.receipt && error.receipt.status == 1) { + transaction._confirmed = true; + if (transaction.confirmed) transaction.confirmed(transaction); + } else if(error.replacement && error.replacement.hash && error.receipt && error.receipt.status == 0) { + transaction._failed = true; + if(transaction.failed) transaction.failed(transaction, error); + } + } else { + transaction._failed = true; + if(transaction.failed) transaction.failed(transaction, error); + } }); } else { throw('Submitting transaction failed!') @@ -18132,15 +18124,20 @@ transaction._confirmed = true; if (transaction.confirmed) transaction.confirmed(transaction); }).catch((error)=>{ - transaction._failed = true; - if(transaction.failed) transaction.failed(transaction, error); - }); - sentTransaction.wait(12).then(() => { - transaction._ensured = true; - if (transaction.ensured) transaction.ensured(transaction); - }).catch((error)=>{ - transaction._failed = true; - if(transaction.failed) transaction.failed(transaction, error); + if(error && error.code && error.code == 'TRANSACTION_REPLACED') { + if(error.replacement && error.replacement.hash && error.receipt && error.receipt.status == 1) { + transaction.id = error.replacement.hash; + transaction._confirmed = true; + if (transaction.confirmed) transaction.confirmed(transaction); + } else if(error.replacement && error.replacement.hash && error.receipt && error.receipt.status == 0) { + transaction.id = error.replacement.hash; + transaction._failed = true; + if(transaction.failed) transaction.failed(transaction, error); + } + } else { + transaction._failed = true; + if(transaction.failed) transaction.failed(transaction, error); + } }); } } else { diff --git a/package.json b/package.json index d5654079..e3efad1f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@depay/web3-wallets", "moduleName": "Web3Wallets", - "version": "8.1.0", + "version": "9.0.0", "description": "One-Stop-Shop JavaScript library to integrate various web3 crypto wallets and multiple blockchains at once with a single interface.", "main": "dist/umd/index.js", "module": "dist/esm/index.js", @@ -50,7 +50,7 @@ "@depay/web3-blockchains": "^4.2.0", "@depay/web3-client": "^8.0.0", "@depay/web3-constants": "^5.0.0", - "@depay/web3-mock": "^11.2.1", + "@depay/web3-mock": "^11.6.0", "@rollup/plugin-commonjs": "^18.0.0", "@rollup/plugin-node-resolve": "^11.2.1", "@rollup/plugin-replace": "^2.4.2", diff --git a/src/Transaction.js b/src/Transaction.js index 99b789ed..09a8fe57 100644 --- a/src/Transaction.js +++ b/src/Transaction.js @@ -3,7 +3,7 @@ import { CONSTANTS } from '@depay/web3-constants' class Transaction { - constructor({ blockchain, from, nonce, to, api, method, params, value, sent, confirmed, ensured, failed }) { + constructor({ blockchain, from, nonce, to, api, method, params, value, sent, confirmed, failed }) { this.blockchain = blockchain this.from = from @@ -15,10 +15,8 @@ class Transaction { this.value = Transaction.bigNumberify(value, blockchain)?.toString() this.sent = sent this.confirmed = confirmed - this.ensured = ensured this.failed = failed this._confirmed = false - this._ensured = false this._failed = false } @@ -65,19 +63,6 @@ class Transaction { }) } - ensurance() { - if (this._ensured) { - return Promise.resolve(this) - } - return new Promise((resolve, reject) => { - let originalEnsured = this.ensured - this.ensured = () => { - if (originalEnsured) originalEnsured(this) - resolve(this) - } - }) - } - failure() { if (this._failed) { return Promise.resolve(this) diff --git a/src/wallets/WalletConnect/transaction.js b/src/wallets/WalletConnect/transaction.js index 6e1afd57..e5c36c1d 100644 --- a/src/wallets/WalletConnect/transaction.js +++ b/src/wallets/WalletConnect/transaction.js @@ -26,15 +26,20 @@ const sendTransaction = async ({ transaction, wallet })=> { transaction._confirmed = true if (transaction.confirmed) transaction.confirmed(transaction) }).catch((error)=>{ - transaction._failed = true - if(transaction.failed) transaction.failed(transaction, error) - }) - sentTransaction.wait(12).then(() => { - transaction._ensured = true - if (transaction.ensured) transaction.ensured(transaction) - }).catch((error)=>{ - transaction._failed = true - if(transaction.failed) transaction.failed(transaction, error) + if(error && error.code && error.code == 'TRANSACTION_REPLACED') { + if(error.replacement && error.replacement.hash && error.receipt && error.receipt.status == 1) { + transaction.id = error.replacement.hash + transaction._confirmed = true + if (transaction.confirmed) transaction.confirmed(transaction) + } else if(error.replacement && error.replacement.hash && error.receipt && error.receipt.status == 0) { + transaction.id = error.replacement.hash + transaction._failed = true + if(transaction.failed) transaction.failed(transaction, error) + } + } else { + transaction._failed = true + if(transaction.failed) transaction.failed(transaction, error) + } }) } } else { diff --git a/src/wallets/Web3Wallet/transaction.js b/src/wallets/Web3Wallet/transaction.js index ee36399e..93038777 100644 --- a/src/wallets/Web3Wallet/transaction.js +++ b/src/wallets/Web3Wallet/transaction.js @@ -20,15 +20,22 @@ const sendTransaction = async ({ transaction, wallet })=> { transaction._confirmed = true if (transaction.confirmed) transaction.confirmed(transaction) }).catch((error)=>{ - transaction._failed = true - if(transaction.failed) transaction.failed(transaction, error) - }) - sentTransaction.wait(12).then(() => { - transaction._ensured = true - if (transaction.ensured) transaction.ensured(transaction) - }).catch((error)=>{ - transaction._failed = true - if(transaction.failed) transaction.failed(transaction, error) + if(error && error.code && error.code == 'TRANSACTION_REPLACED') { + if(error.replacement && error.replacement.hash) { + transaction.id = error.replacement.hash + transaction.url = Blockchain.findByName(transaction.blockchain).explorerUrlFor({ transaction }) + } + if(error.replacement && error.replacement.hash && error.receipt && error.receipt.status == 1) { + transaction._confirmed = true + if (transaction.confirmed) transaction.confirmed(transaction) + } else if(error.replacement && error.replacement.hash && error.receipt && error.receipt.status == 0) { + transaction._failed = true + if(transaction.failed) transaction.failed(transaction, error) + } + } else { + transaction._failed = true + if(transaction.failed) transaction.failed(transaction, error) + } }) } else { throw('Submitting transaction failed!') diff --git a/tests/units/wallets/WalletConnect/sendTransaction.spec.js b/tests/units/wallets/WalletConnect/sendTransaction.spec.js index 44c2e275..2aaa325b 100644 --- a/tests/units/wallets/WalletConnect/sendTransaction.spec.js +++ b/tests/units/wallets/WalletConnect/sendTransaction.spec.js @@ -158,40 +158,21 @@ describe('sendTransaction with wallet connect', () => { expect(confirmedCallbackTransaction.params).toEqual(params) }) - it("calls the transaction's ensured callback", async ()=> { - let ensuredCallbackTransaction - transaction.ensured = function(transaction){ ensuredCallbackTransaction = transaction } - let submittedTransaction = await getWallet().sendTransaction(transaction) - confirm(mockedTransaction) - await submittedTransaction.confirmation() - increaseBlock(12) - await submittedTransaction.ensurance() - expect(ensuredCallbackTransaction.id).toBeDefined() - expect(ensuredCallbackTransaction.url).toBeDefined() - expect(ensuredCallbackTransaction.blockchain).toEqual(blockchain) - expect(ensuredCallbackTransaction.from).toEqual(accounts[0]) - expect(ensuredCallbackTransaction.nonce).toEqual(0) - expect(ensuredCallbackTransaction.to).toEqual('0xae60aC8e69414C2Dc362D0e6a03af643d1D85b92') - expect(ensuredCallbackTransaction.api).toEqual(api) - expect(ensuredCallbackTransaction.method).toEqual(method) - expect(ensuredCallbackTransaction.params).toEqual(params) - }) - it("calls the transaction's failed callback", async ()=> { - // let failedCallbackTransaction - // transaction.failed = function(transaction){ failedCallbackTransaction = transaction } - // let submittedTransaction = await getWallet().sendTransaction(transaction) - // fail(mockedTransaction) - // await submittedTransaction.failure() - // expect(failedCallbackTransaction.id).toBeDefined() - // expect(failedCallbackTransaction.url).toBeDefined() - // expect(failedCallbackTransaction.blockchain).toEqual(blockchain) - // expect(failedCallbackTransaction.from).toEqual(accounts[0]) - // expect(failedCallbackTransaction.nonce).toEqual(0) - // expect(failedCallbackTransaction.to).toEqual('0xae60aC8e69414C2Dc362D0e6a03af643d1D85b92') - // expect(failedCallbackTransaction.api).toEqual(api) - // expect(failedCallbackTransaction.method).toEqual(method) - // expect(failedCallbackTransaction.params).toEqual(params) + let failedCallbackTransaction + transaction.failed = function(transaction){ failedCallbackTransaction = transaction } + let submittedTransaction = await getWallet().sendTransaction(transaction) + fail(mockedTransaction) + await submittedTransaction.failure() + expect(failedCallbackTransaction.id).toBeDefined() + expect(failedCallbackTransaction.url).toBeDefined() + expect(failedCallbackTransaction.blockchain).toEqual(blockchain) + expect(failedCallbackTransaction.from).toEqual(accounts[0]) + expect(failedCallbackTransaction.nonce).toEqual(0) + expect(failedCallbackTransaction.to).toEqual('0xae60aC8e69414C2Dc362D0e6a03af643d1D85b92') + expect(failedCallbackTransaction.api).toEqual(api) + expect(failedCallbackTransaction.method).toEqual(method) + expect(failedCallbackTransaction.params).toEqual(params) }) }) @@ -313,23 +294,6 @@ describe('sendTransaction with wallet connect', () => { expect(confirmedCallbackTransaction.value.toString()).toEqual('1000000000000000000') }) - it("calls the transaction's ensured callback", async ()=> { - let ensuredCallbackTransaction - transaction.ensured = function(transaction){ ensuredCallbackTransaction = transaction } - let submittedTransaction = await getWallet().sendTransaction(transaction) - confirm(mockedTransaction) - await submittedTransaction.confirmation() - increaseBlock(12) - await submittedTransaction.ensurance() - expect(ensuredCallbackTransaction.id).toBeDefined() - expect(ensuredCallbackTransaction.url).toBeDefined() - expect(ensuredCallbackTransaction.blockchain).toEqual(blockchain) - expect(ensuredCallbackTransaction.from).toEqual(accounts[0]) - expect(ensuredCallbackTransaction.nonce).toEqual(0) - expect(ensuredCallbackTransaction.to).toEqual('0xae60aC8e69414C2Dc362D0e6a03af643d1D85b92') - expect(ensuredCallbackTransaction.value.toString()).toEqual('1000000000000000000') - }) - it("calls the transaction's failed callback", async ()=> { let failedCallbackTransaction transaction.failed = function(transaction){ failedCallbackTransaction = transaction } diff --git a/tests/units/wallets/Web3Wallet/replacedTransaction.spec.js b/tests/units/wallets/Web3Wallet/replacedTransaction.spec.js new file mode 100644 index 00000000..3c84c86b --- /dev/null +++ b/tests/units/wallets/Web3Wallet/replacedTransaction.spec.js @@ -0,0 +1,108 @@ +import { ethers } from 'ethers' +import { getWallet } from 'src' +import { mock, connect, resetMocks, confirm, increaseBlock, fail, replace } from '@depay/web3-mock' + +describe('calls "confirmed" and "failed" even for replaced transactions', () => { + + ['ethereum', 'bsc'].forEach((blockchain)=>{ + + describe(blockchain, ()=> { + + const accounts = ['0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'] + let wallet + beforeEach(resetMocks) + afterEach(resetMocks) + beforeEach(()=>mock({ blockchain, accounts: { return: accounts } })) + beforeEach(()=>{ wallet = getWallet() }) + + let address = '0xae60aC8e69414C2Dc362D0e6a03af643d1D85b92'; + let api = [{"inputs":[{"internalType":"address","name":"_configuration","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ETH","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"configuration","outputs":[{"internalType":"contract DePayRouterV1Configuration","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"pluginAddress","type":"address"}],"name":"isApproved","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"address[]","name":"addresses","type":"address[]"},{"internalType":"address[]","name":"plugins","type":"address[]"},{"internalType":"string[]","name":"data","type":"string[]"}],"name":"route","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]; + let method = 'route'; + let params = { + path: ['0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE', '0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb'], + amounts: ['7640757987460190', '10000000000000000000', '1623407305'], + addresses: ['0x65aBbdEd9B937E38480A50eca85A8E4D2c8350E4'], + plugins: ['0xe04b08Dfc6CaA0F4Ec523a3Ae283Ece7efE00019', '0x99F3F4685a7178F26EB4F4Ca8B75a1724F1577B9'], + data: [] + }; + + let transaction; + let mockedTransaction; + let replacingTransactionMock; + + describe('a replacing transaction was mined successfully', ()=>{ + + beforeEach(()=>{ + + transaction = { + blockchain, + from: accounts[0], + to: address, + api: api, + method: method, + params: params + }; + + mockedTransaction = mock({ + blockchain, + transaction + }) + + replacingTransactionMock = mock({ + blockchain, + transaction + }) + + }) + + it('calls the "confirmed" callback with the replacing transaction', async ()=> { + let confirmedTransaction + let submittedTransaction = await wallet.sendTransaction({... transaction, confirmed: (_confirmedTransaction)=>{ + confirmedTransaction = _confirmedTransaction + }}) + replace(mockedTransaction, replacingTransactionMock) + await new Promise((r) => setTimeout(r, 2000)); + expect(confirmedTransaction.id).toEqual(replacingTransactionMock.transaction._id) + expect(confirmedTransaction.url).toMatch(replacingTransactionMock.transaction._id) + }) + }) + + describe('a replacing transaction was mined but failed', ()=>{ + + beforeEach(()=>{ + + transaction = { + blockchain, + from: accounts[0], + to: address, + api: api, + method: method, + params: params + }; + + mockedTransaction = mock({ + blockchain, + transaction + }) + + replacingTransactionMock = mock({ + blockchain, + transaction + }) + + }) + + it('calls the "failed" callback with the replacing transaction', async ()=> { + let failedTransaction + let submittedTransaction = await wallet.sendTransaction({... transaction, failed: (_failedTransaction)=>{ + failedTransaction = _failedTransaction + }}) + replace(mockedTransaction, replacingTransactionMock, false) + await new Promise((r) => setTimeout(r, 2000)); + expect(failedTransaction.id).toEqual(replacingTransactionMock.transaction._id) + expect(failedTransaction.url).toMatch(replacingTransactionMock.transaction._id) + }) + }) + }) + }) +}) diff --git a/tests/units/wallets/Web3Wallet/sendTransaction.spec.js b/tests/units/wallets/Web3Wallet/sendTransaction.spec.js index 25a86eb2..9d83b8d5 100644 --- a/tests/units/wallets/Web3Wallet/sendTransaction.spec.js +++ b/tests/units/wallets/Web3Wallet/sendTransaction.spec.js @@ -153,25 +153,6 @@ describe('sendTransaction with web3 wallet', () => { expect(confirmedCallbackTransaction.params).toEqual(params) }) - it("calls the transaction's ensured callback", async ()=> { - let ensuredCallbackTransaction - transaction.ensured = function(transaction){ ensuredCallbackTransaction = transaction } - let submittedTransaction = await wallet.sendTransaction(transaction) - confirm(mockedTransaction) - await submittedTransaction.confirmation() - increaseBlock(12) - await submittedTransaction.ensurance() - expect(ensuredCallbackTransaction.id).toBeDefined() - expect(ensuredCallbackTransaction.url).toBeDefined() - expect(ensuredCallbackTransaction.blockchain).toEqual(blockchain) - expect(ensuredCallbackTransaction.from).toEqual(accounts[0]) - expect(ensuredCallbackTransaction.nonce).toEqual(0) - expect(ensuredCallbackTransaction.to).toEqual('0xae60aC8e69414C2Dc362D0e6a03af643d1D85b92') - expect(ensuredCallbackTransaction.api).toEqual(api) - expect(ensuredCallbackTransaction.method).toEqual(method) - expect(ensuredCallbackTransaction.params).toEqual(params) - }) - it("calls the transaction's failed callback", async ()=> { let failedCallbackTransaction transaction.failed = function(transaction){ failedCallbackTransaction = transaction } @@ -308,23 +289,6 @@ describe('sendTransaction with web3 wallet', () => { expect(confirmedCallbackTransaction.value.toString()).toEqual('1000000000000000000') }) - it("calls the transaction's ensured callback", async ()=> { - let ensuredCallbackTransaction - transaction.ensured = function(transaction){ ensuredCallbackTransaction = transaction } - let submittedTransaction = await wallet.sendTransaction(transaction) - confirm(mockedTransaction) - await submittedTransaction.confirmation() - increaseBlock(12) - await submittedTransaction.ensurance() - expect(ensuredCallbackTransaction.id).toBeDefined() - expect(ensuredCallbackTransaction.url).toBeDefined() - expect(ensuredCallbackTransaction.blockchain).toEqual(blockchain) - expect(ensuredCallbackTransaction.from).toEqual(accounts[0]) - expect(ensuredCallbackTransaction.nonce).toEqual(0) - expect(ensuredCallbackTransaction.to).toEqual('0xae60aC8e69414C2Dc362D0e6a03af643d1D85b92') - expect(ensuredCallbackTransaction.value.toString()).toEqual('1000000000000000000') - }) - it("calls the transaction's failed callback", async ()=> { let failedCallbackTransaction transaction.failed = function(transaction){ failedCallbackTransaction = transaction } diff --git a/yarn.lock b/yarn.lock index 2ca90446..300b315c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -883,10 +883,10 @@ "@walletconnect/client" "^1.6.5" "@walletconnect/qrcode-modal" "^1.6.5" -"@depay/web3-blockchains@^4.0.0": - version "4.0.0" - resolved "https://registry.yarnpkg.com/@depay/web3-blockchains/-/web3-blockchains-4.0.0.tgz#049f3132d309f90401f138485b5257e6f1a98650" - integrity sha512-mMtWwubtYhjygJso3iVAYrRBmANH3VbBHkvtOwOc2rPHoTAS3uYZTMfbNc9sFVCyxXo+hsa8453rsxFNJi9Y3A== +"@depay/web3-blockchains@^4.2.0": + version "4.2.0" + resolved "https://registry.yarnpkg.com/@depay/web3-blockchains/-/web3-blockchains-4.2.0.tgz#953824e179455dd408fccb267f1651460ea08173" + integrity sha512-AD456GyAQaLfp21D04XqiEebn/cPc3358GJZpBMa676zVv7+FJdTpuwmPNq3+MQdVNs0zRCGe5SkXh/HFWzw7Q== "@depay/web3-client@^8.0.0": version "8.0.0" @@ -898,10 +898,10 @@ resolved "https://registry.yarnpkg.com/@depay/web3-constants/-/web3-constants-5.0.0.tgz#89a8392586a619d63ab73f483b341ba17f03dd51" integrity sha512-P7GnRdykODAJUH9EC1d6/ZektPmL42hVcklUsub8oGmngDCa+AFz+Pyf1TcL3jaVaznlUTcRZt0fu+r+5MJBew== -"@depay/web3-mock@^11.0.0": - version "11.0.0" - resolved "https://registry.yarnpkg.com/@depay/web3-mock/-/web3-mock-11.0.0.tgz#e5768ca934e000d67e60d8b62937815f5c63974e" - integrity sha512-73jlVh6lDbAGREqdXMeom76NBofJZLysNuo4meuJeVOaGn+mJf6U8ware5XbjysC+Rk11NhMvN4MJyOZCUMpDA== +"@depay/web3-mock@^11.6.0": + version "11.6.0" + resolved "https://registry.yarnpkg.com/@depay/web3-mock/-/web3-mock-11.6.0.tgz#84bd99c431848cf50ec70f6c6551701d1039f5b3" + integrity sha512-c4w0QOHFsLqMqKYeXNOxjUA4BhhwuokzC8/XW/5tWHx9FZGjCf6QBv3vk9eQQPsh1BgkKUqU6wk7ZclqI+8iXA== "@eslint/eslintrc@^0.4.3": version "0.4.3"