From fa5cde5c1eb3cf3901a742390359d9aaf1e17d9d Mon Sep 17 00:00:00 2001 From: Armani Ferrante Date: Thu, 20 May 2021 00:17:46 -0700 Subject: [PATCH] Add sendAll hook for the anchor provider (#13) --- package.json | 2 +- src/App.tsx | 16 ++++++++++++++++ yarn.lock | 8 ++++---- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 81ae359..f1c162d 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "dependencies": { "react-async-hook": "^3.6.2", "@project-serum/serum": "^0.13.34", - "@project-serum/swap": "^0.1.0-alpha.11", + "@project-serum/swap": "^0.1.0-alpha.12", "@solana/spl-token": "^0.1.4" }, "peerDependencies": { diff --git a/src/App.tsx b/src/App.tsx index 7247434..1dad332 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -154,6 +154,22 @@ class NotifyingProvider extends Provider { return ""; } } + + async sendAll( + txs: Array<{ tx: Transaction; signers: Array }>, + opts?: ConfirmOptions + ): Promise> { + try { + const txSigs = await super.sendAll(txs, opts); + txSigs.forEach((sig) => { + this.onTransaction(sig); + }); + return txSigs; + } catch (err) { + this.onTransaction(undefined, err); + return []; + } + } } export default App; diff --git a/yarn.lock b/yarn.lock index fb7f4b4..d96eced 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1588,10 +1588,10 @@ bs58 "^4.0.1" eventemitter3 "^4.0.4" -"@project-serum/swap@^0.1.0-alpha.11": - version "0.1.0-alpha.11" - resolved "https://registry.yarnpkg.com/@project-serum/swap/-/swap-0.1.0-alpha.11.tgz#65c6393bdc511208453c853095eba32e0748191b" - integrity sha512-cxjxweWrZWcxfazkxSjDXqLquKlCCOoJ7z+cfAky/l29gRet+rLbGjyd+TAcZRDrIfh+kut9svPlL/bXK9vIOw== +"@project-serum/swap@^0.1.0-alpha.12": + version "0.1.0-alpha.12" + resolved "https://registry.yarnpkg.com/@project-serum/swap/-/swap-0.1.0-alpha.12.tgz#085055c1bbed66d8e9a9f8da9e23d2315ad09181" + integrity sha512-iIFBbwkIVAJaUPx3Wn240gba6tpAtBHHfcEbInz+O+enCUUHCCIi96SY1R6nBHKNWiH2qY+nlPfXR62Lra/cyw== dependencies: "@project-serum/anchor" "^0.5.1-beta.2" "@project-serum/serum" "^0.13.34"