diff --git a/README.md b/README.md index b219cb4..b85143f 100644 --- a/README.md +++ b/README.md @@ -222,11 +222,13 @@ await wallet.switchTo('bsc') ### Data Structure +`accepted: Function ()=>{}`: Callback that will be executed once the transaction has been accepted by the wallet but not sent to the network yet (e.g. relayer, World App). Has no transaction yet, as only sent can contain the transaction. + `api: Array`: Api of the contract (e.g. abi for Ethereum, Layout/Struct for Solana). `blockchain: String`: Name of the blockchain e.g. 'ethereum'. -`failed: Function (transaction, error)=>{}`: Callback to be executed if transaction failed (e.g. reverted). +`failed: Function (transaction, error)=>{}`: Callback that will be executed once the transaction failed onchain (reverted). `from: String`: Address of the transaction sender. @@ -242,9 +244,9 @@ await wallet.switchTo('bsc') `params: Object or Array`: Parameters passed to the method (EVM). -`sent: Function (transaction)=>{}`: Callback to be executed if transaction has been sent to the network. +`sent: Function (transaction)=>{}`: Callback that will be executed executed once the transaction has been sent to the network. -`succeeded: Function (transaction)=>{}`: Callback to be executed if transaction was successful and has been confirmed once by the network. +`succeeded: Function (transaction)=>{}`: Callback that will be executed once the transaction was successful and has been confirmed at least once by the network. `to String`: Address of the contract to be transacted with (EVM). diff --git a/dist/esm/index.evm.js b/dist/esm/index.evm.js index 50ece8c..3d43873 100644 --- a/dist/esm/index.evm.js +++ b/dist/esm/index.evm.js @@ -25,7 +25,8 @@ class Transaction { alts, sent, succeeded, - failed + failed, + accepted, }) { // required @@ -38,6 +39,7 @@ class Transaction { this.api = api; this.method = method; this.params = params; + this.accepted = accepted; this.sent = sent; this.succeeded = succeeded; this.failed = failed; @@ -1651,6 +1653,9 @@ class WorldApp { MiniKit.subscribe(ResponseEvent.MiniAppSendTransaction, (payload)=> { console.log('payload', payload); if (payload.status == "success") { + console.log('before transaction.accepted', transaction); + if (transaction.accepted) { transaction.accepted(); } + console.log('after transaction.accepted', transaction); this.fetchTransaction(transaction, payload).then((transactionHash)=>{ if(transactionHash) { resolve(transaction); diff --git a/dist/esm/index.js b/dist/esm/index.js index 40b9f1d..c1bc79d 100644 --- a/dist/esm/index.js +++ b/dist/esm/index.js @@ -22,7 +22,8 @@ class Transaction { alts, sent, succeeded, - failed + failed, + accepted, }) { // required @@ -35,6 +36,7 @@ class Transaction { this.api = api; this.method = method; this.params = params; + this.accepted = accepted; this.sent = sent; this.succeeded = succeeded; this.failed = failed; @@ -2250,6 +2252,9 @@ class WorldApp { MiniKit.subscribe(ResponseEvent.MiniAppSendTransaction, (payload)=> { console.log('payload', payload); if (payload.status == "success") { + console.log('before transaction.accepted', transaction); + if (transaction.accepted) { transaction.accepted(); } + console.log('after transaction.accepted', transaction); this.fetchTransaction(transaction, payload).then((transactionHash)=>{ if(transactionHash) { resolve(transaction); diff --git a/dist/esm/index.solana.js b/dist/esm/index.solana.js index c7ac4b0..0e5e61a 100644 --- a/dist/esm/index.solana.js +++ b/dist/esm/index.solana.js @@ -19,7 +19,8 @@ class Transaction { alts, sent, succeeded, - failed + failed, + accepted, }) { // required @@ -32,6 +33,7 @@ class Transaction { this.api = api; this.method = method; this.params = params; + this.accepted = accepted; this.sent = sent; this.succeeded = succeeded; this.failed = failed; diff --git a/dist/umd/index.evm.js b/dist/umd/index.evm.js index c8374b0..6ac421b 100644 --- a/dist/umd/index.evm.js +++ b/dist/umd/index.evm.js @@ -28,7 +28,8 @@ alts, sent, succeeded, - failed + failed, + accepted, }) { // required @@ -41,6 +42,7 @@ this.api = api; this.method = method; this.params = params; + this.accepted = accepted; this.sent = sent; this.succeeded = succeeded; this.failed = failed; @@ -1654,6 +1656,9 @@ worldcoinPrecompiled.MiniKit.subscribe(worldcoinPrecompiled.ResponseEvent.MiniAppSendTransaction, (payload)=> { console.log('payload', payload); if (payload.status == "success") { + console.log('before transaction.accepted', transaction); + if (transaction.accepted) { transaction.accepted(); } + console.log('after transaction.accepted', transaction); this.fetchTransaction(transaction, payload).then((transactionHash)=>{ if(transactionHash) { resolve(transaction); diff --git a/dist/umd/index.js b/dist/umd/index.js index 0111fa6..c1220f6 100644 --- a/dist/umd/index.js +++ b/dist/umd/index.js @@ -24,7 +24,8 @@ alts, sent, succeeded, - failed + failed, + accepted, }) { // required @@ -37,6 +38,7 @@ this.api = api; this.method = method; this.params = params; + this.accepted = accepted; this.sent = sent; this.succeeded = succeeded; this.failed = failed; @@ -2252,6 +2254,9 @@ worldcoinPrecompiled.MiniKit.subscribe(worldcoinPrecompiled.ResponseEvent.MiniAppSendTransaction, (payload)=> { console.log('payload', payload); if (payload.status == "success") { + console.log('before transaction.accepted', transaction); + if (transaction.accepted) { transaction.accepted(); } + console.log('after transaction.accepted', transaction); this.fetchTransaction(transaction, payload).then((transactionHash)=>{ if(transactionHash) { resolve(transaction); diff --git a/dist/umd/index.solana.js b/dist/umd/index.solana.js index 915e5ac..aeab113 100644 --- a/dist/umd/index.solana.js +++ b/dist/umd/index.solana.js @@ -24,7 +24,8 @@ alts, sent, succeeded, - failed + failed, + accepted, }) { // required @@ -37,6 +38,7 @@ this.api = api; this.method = method; this.params = params; + this.accepted = accepted; this.sent = sent; this.succeeded = succeeded; this.failed = failed; diff --git a/package.evm.json b/package.evm.json index e43f285..b834d60 100644 --- a/package.evm.json +++ b/package.evm.json @@ -1,7 +1,7 @@ { "name": "@depay/web3-wallets-evm", "moduleName": "Web3Wallets", - "version": "17.4.8", + "version": "17.5.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.evm.js", "module": "dist/esm/index.evm.js", diff --git a/package.json b/package.json index a9ea91b..53fcb5b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@depay/web3-wallets", "moduleName": "Web3Wallets", - "version": "17.4.8", + "version": "17.5.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", diff --git a/package.solana.json b/package.solana.json index 4482c21..f9824de 100644 --- a/package.solana.json +++ b/package.solana.json @@ -1,7 +1,7 @@ { "name": "@depay/web3-wallets-solana", "moduleName": "Web3Wallets", - "version": "17.4.8", + "version": "17.5.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.solana.js", "module": "dist/esm/index.solana.js", diff --git a/src/Transaction.js b/src/Transaction.js index 8189a06..daa3885 100644 --- a/src/Transaction.js +++ b/src/Transaction.js @@ -16,7 +16,8 @@ class Transaction { alts, sent, succeeded, - failed + failed, + accepted, }) { // required @@ -29,6 +30,7 @@ class Transaction { this.api = api this.method = method this.params = params + this.accepted = accepted this.sent = sent this.succeeded = succeeded this.failed = failed diff --git a/src/wallets/WorldApp.js b/src/wallets/WorldApp.js index 1b2e7c3..c04218d 100644 --- a/src/wallets/WorldApp.js +++ b/src/wallets/WorldApp.js @@ -56,6 +56,9 @@ export default class WorldApp { MiniKit.subscribe(ResponseEvent.MiniAppSendTransaction, (payload)=> { console.log('payload', payload) if (payload.status == "success") { + console.log('before transaction.accepted', transaction) + if (transaction.accepted) { transaction.accepted() } + console.log('after transaction.accepted', transaction) this.fetchTransaction(transaction, payload).then((transactionHash)=>{ if(transactionHash) { resolve(transaction)