From 8317ce39de0b0fd1ecc40cd52cfdb1f6aca7526c Mon Sep 17 00:00:00 2001 From: Sebastian Pape <0xneo11@gmail.com> Date: Thu, 10 Oct 2024 10:23:51 +0200 Subject: [PATCH] v17.5.0: add accepted to World App --- README.md | 8 +++++--- dist/esm/index.evm.js | 7 ++++++- dist/esm/index.js | 7 ++++++- dist/esm/index.solana.js | 4 +++- dist/umd/index.evm.js | 7 ++++++- dist/umd/index.js | 7 ++++++- dist/umd/index.solana.js | 4 +++- package.evm.json | 2 +- package.json | 2 +- package.solana.json | 2 +- src/Transaction.js | 4 +++- src/wallets/WorldApp.js | 3 +++ 12 files changed, 44 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index b219cb48..b85143f6 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 50ece8c5..3d438736 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 40b9f1d3..c1bc79dd 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 c7ac4b00..0e5e61a3 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 c8374b0e..6ac421b8 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 0111fa6c..c1220f60 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 915e5ac9..aeab113b 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 e43f285d..b834d608 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 a9ea91be..53fcb5b3 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 4482c21b..f9824deb 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 8189a067..daa38850 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 1b2e7c38..c04218d8 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)