From 374d31c6ee3773e77439c783a6e105effdd1c0c5 Mon Sep 17 00:00:00 2001 From: Sebastian Pape <0xneo11@gmail.com> Date: Tue, 22 Oct 2024 19:47:49 +0200 Subject: [PATCH] v14.0.0: removes drip functionality (due to race conditions), keeps getting full assets only --- README.md | 14 -------------- dist/esm/index.evm.js | 11 ++--------- dist/esm/index.js | 11 ++--------- dist/esm/index.solana.js | 11 ++--------- dist/umd/index.evm.js | 9 +-------- dist/umd/index.js | 9 +-------- dist/umd/index.solana.js | 9 +-------- package.evm.json | 2 +- package.json | 2 +- package.solana.json | 2 +- src/route.js | 15 ++++----------- yarn.lock | 7 ++++++- 12 files changed, 22 insertions(+), 80 deletions(-) diff --git a/README.md b/README.md index 88443a1..7c03e31 100644 --- a/README.md +++ b/README.md @@ -150,20 +150,6 @@ let paymentRoutes = await route({ }) ``` -#### drip routes - -If you want to work with intermediate routing results over waiting for all routes to be calculated, you can use the the `drip` option which will drip every single route individually: - -```javascript -import { route } from '@depay/web3-payments' - -let paymentRoutes = await route({ - drip: (route)=> { - // yields every single route - } -}) -``` - #### fromToken + fromAmount + toToken In cases where you want to set the `fromToken` and `fromAmount` (instead of the target token and the target amount) when calculating payment routes you can pass `fromToken`, `fromAmount` + `toToken`. diff --git a/dist/esm/index.evm.js b/dist/esm/index.evm.js index a6274d8..c58af3a 100644 --- a/dist/esm/index.evm.js +++ b/dist/esm/index.evm.js @@ -1,6 +1,6 @@ import Blockchains from '@depay/web3-blockchains'; import { ethers } from 'ethers'; -import { dripAssets } from '@depay/web3-assets-evm'; +import { getAssets } from '@depay/web3-assets-evm'; import Exchanges from '@depay/web3-exchanges-evm'; import Token$1 from '@depay/web3-tokens-evm'; @@ -51545,18 +51545,11 @@ function route({ accept, from, whitelist, blacklist, drip }) { } catch (e) {} }; - const allAssets = await dripAssets({ + const allAssets = await getAssets({ accounts: from, priority, only: whitelist, exclude: blacklist, - drip: !drip ? undefined : (asset)=>{ - assetsToRoutes({ assets: [asset], blacklist, accept, from }).then((routes)=>{ - if(_optionalChain([routes, 'optionalAccess', _5 => _5.length])) { - dripRoute(routes[0]); - } - }); - } }); let allPaymentRoutes = (await assetsToRoutes({ assets: allAssets, blacklist, accept, from }) || []); diff --git a/dist/esm/index.js b/dist/esm/index.js index e0702b0..4bbe28d 100644 --- a/dist/esm/index.js +++ b/dist/esm/index.js @@ -2,7 +2,7 @@ import Blockchains from '@depay/web3-blockchains'; import { BN, struct, u64, i64, u128, bool, Connection, ACCOUNT_LAYOUT, PublicKey, Keypair, SystemProgram, Buffer, TransactionInstruction, publicKey } from '@depay/solana-web3.js'; import { ethers } from 'ethers'; import Token from '@depay/web3-tokens'; -import { dripAssets } from '@depay/web3-assets'; +import { getAssets } from '@depay/web3-assets'; import Exchanges from '@depay/web3-exchanges'; var solanaRouters = { @@ -2592,18 +2592,11 @@ function route({ accept, from, whitelist, blacklist, drip }) { } catch (e) {} }; - const allAssets = await dripAssets({ + const allAssets = await getAssets({ accounts: from, priority, only: whitelist, exclude: blacklist, - drip: !drip ? undefined : (asset)=>{ - assetsToRoutes({ assets: [asset], blacklist, accept, from }).then((routes)=>{ - if(_optionalChain([routes, 'optionalAccess', _5 => _5.length])) { - dripRoute(routes[0]); - } - }); - } }); let allPaymentRoutes = (await assetsToRoutes({ assets: allAssets, blacklist, accept, from }) || []); diff --git a/dist/esm/index.solana.js b/dist/esm/index.solana.js index 30712ad..edb325c 100644 --- a/dist/esm/index.solana.js +++ b/dist/esm/index.solana.js @@ -1,7 +1,7 @@ import Blockchains from '@depay/web3-blockchains'; import { BN, struct, u64, i64, u128, bool, ACCOUNT_LAYOUT, PublicKey, Connection, u32, publicKey, u8, rustEnum, str, u16, option, vec, Buffer, TransactionInstruction, SystemProgram, Keypair } from '@depay/solana-web3.js'; import { ethers } from 'ethers'; -import { dripAssets } from '@depay/web3-assets-solana'; +import { getAssets } from '@depay/web3-assets-solana'; import Exchanges from '@depay/web3-exchanges-solana'; import Token$1 from '@depay/web3-tokens-solana'; @@ -3589,18 +3589,11 @@ function route({ accept, from, whitelist, blacklist, drip }) { } catch (e) {} }; - const allAssets = await dripAssets({ + const allAssets = await getAssets({ accounts: from, priority, only: whitelist, exclude: blacklist, - drip: !drip ? undefined : (asset)=>{ - assetsToRoutes({ assets: [asset], blacklist, accept, from }).then((routes)=>{ - if(_optionalChain([routes, 'optionalAccess', _5 => _5.length])) { - dripRoute(routes[0]); - } - }); - } }); let allPaymentRoutes = (await assetsToRoutes({ assets: allAssets, blacklist, accept, from }) || []); diff --git a/dist/umd/index.evm.js b/dist/umd/index.evm.js index 4fcf329..1a628e2 100644 --- a/dist/umd/index.evm.js +++ b/dist/umd/index.evm.js @@ -51551,18 +51551,11 @@ } catch (e) {} }; - const allAssets = await web3AssetsEvm.dripAssets({ + const allAssets = await web3AssetsEvm.getAssets({ accounts: from, priority, only: whitelist, exclude: blacklist, - drip: !drip ? undefined : (asset)=>{ - assetsToRoutes({ assets: [asset], blacklist, accept, from }).then((routes)=>{ - if(_optionalChain([routes, 'optionalAccess', _5 => _5.length])) { - dripRoute(routes[0]); - } - }); - } }); let allPaymentRoutes = (await assetsToRoutes({ assets: allAssets, blacklist, accept, from }) || []); diff --git a/dist/umd/index.js b/dist/umd/index.js index 1ecd954..578077c 100644 --- a/dist/umd/index.js +++ b/dist/umd/index.js @@ -2597,18 +2597,11 @@ } catch (e) {} }; - const allAssets = await web3Assets.dripAssets({ + const allAssets = await web3Assets.getAssets({ accounts: from, priority, only: whitelist, exclude: blacklist, - drip: !drip ? undefined : (asset)=>{ - assetsToRoutes({ assets: [asset], blacklist, accept, from }).then((routes)=>{ - if(_optionalChain([routes, 'optionalAccess', _5 => _5.length])) { - dripRoute(routes[0]); - } - }); - } }); let allPaymentRoutes = (await assetsToRoutes({ assets: allAssets, blacklist, accept, from }) || []); diff --git a/dist/umd/index.solana.js b/dist/umd/index.solana.js index 1b1431d..eaab55d 100644 --- a/dist/umd/index.solana.js +++ b/dist/umd/index.solana.js @@ -3594,18 +3594,11 @@ } catch (e) {} }; - const allAssets = await web3AssetsSolana.dripAssets({ + const allAssets = await web3AssetsSolana.getAssets({ accounts: from, priority, only: whitelist, exclude: blacklist, - drip: !drip ? undefined : (asset)=>{ - assetsToRoutes({ assets: [asset], blacklist, accept, from }).then((routes)=>{ - if(_optionalChain([routes, 'optionalAccess', _5 => _5.length])) { - dripRoute(routes[0]); - } - }); - } }); let allPaymentRoutes = (await assetsToRoutes({ assets: allAssets, blacklist, accept, from }) || []); diff --git a/package.evm.json b/package.evm.json index 2fc196d..60c1795 100644 --- a/package.evm.json +++ b/package.evm.json @@ -1,7 +1,7 @@ { "name": "@depay/web3-payments-evm", "moduleName": "Web3Payments", - "version": "13.12.8", + "version": "14.0.0", "description": "JavaScript library to scan crypto wallets for liquefiable assets and perform cost-effective, auto-converted payments on-chain.", "main": "dist/umd/index.evm.js", "module": "dist/esm/index.evm.js", diff --git a/package.json b/package.json index 788abbd..a66b2ef 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@depay/web3-payments", "moduleName": "Web3Payments", - "version": "13.12.8", + "version": "14.0.0", "description": "JavaScript library to scan crypto wallets for liquefiable assets and perform cost-effective, auto-converted payments on-chain.", "main": "dist/umd/index.js", "module": "dist/esm/index.js", diff --git a/package.solana.json b/package.solana.json index 5ae30e8..da8f757 100644 --- a/package.solana.json +++ b/package.solana.json @@ -1,7 +1,7 @@ { "name": "@depay/web3-payments-solana", "moduleName": "Web3Payments", - "version": "13.12.8", + "version": "14.0.0", "description": "JavaScript library to scan crypto wallets for liquefiable assets and perform cost-effective, auto-converted payments on-chain.", "main": "dist/umd/index.solana.js", "module": "dist/esm/index.solana.js", diff --git a/src/route.js b/src/route.js index 822ba44..2d1f722 100644 --- a/src/route.js +++ b/src/route.js @@ -1,18 +1,18 @@ /*#if _EVM -import { dripAssets } from '@depay/web3-assets-evm' +import { getAssets } from '@depay/web3-assets-evm' import Exchanges from '@depay/web3-exchanges-evm' import Token from '@depay/web3-tokens-evm' /*#elif _SOLANA -import { dripAssets } from '@depay/web3-assets-solana' +import { getAssets } from '@depay/web3-assets-solana' import Exchanges from '@depay/web3-exchanges-solana' import Token from '@depay/web3-tokens-solana' //#else */ -import { dripAssets } from '@depay/web3-assets' +import { getAssets } from '@depay/web3-assets' import Exchanges from '@depay/web3-exchanges' import Token from '@depay/web3-tokens' @@ -243,18 +243,11 @@ function route({ accept, from, whitelist, blacklist, drip }) { } catch {} } - const allAssets = await dripAssets({ + const allAssets = await getAssets({ accounts: from, priority, only: whitelist, exclude: blacklist, - drip: !drip ? undefined : (asset)=>{ - assetsToRoutes({ assets: [asset], blacklist, accept, from }).then((routes)=>{ - if(routes?.length) { - dripRoute(routes[0]) - } - }) - } }) let allPaymentRoutes = (await assetsToRoutes({ assets: allAssets, blacklist, accept, from }) || []) diff --git a/yarn.lock b/yarn.lock index c1214bb..27dcb4b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1218,11 +1218,16 @@ resolved "https://registry.yarnpkg.com/@depay/web3-assets/-/web3-assets-7.4.0.tgz#33f8586892e3af3e5f9f120846720010983d2970" integrity sha512-SbKdlNnXHk30mYGHUwfhNd2fKyFh8ZSx6w0St3eJSg1l13xy60sZ09673AqhiiOhsNfYCtDTFbgwdxucnot1lg== -"@depay/web3-blockchains@^9.6.1", "@depay/web3-blockchains@^9.6.5": +"@depay/web3-blockchains@^9.6.1": version "9.6.5" resolved "https://registry.yarnpkg.com/@depay/web3-blockchains/-/web3-blockchains-9.6.5.tgz#29557ccbd352bbbb8218af34b422e6f3a4df4e73" integrity sha512-rxqLr29Zo2cfClgE7JmViollzE1i154ORF89j7zO7RMbn1E8hXJXJ6aRDuA8ArtH+f17buu91865RYoXTZZzdQ== +"@depay/web3-blockchains@^9.6.9": + version "9.7.0" + resolved "https://registry.yarnpkg.com/@depay/web3-blockchains/-/web3-blockchains-9.7.0.tgz#653655b8153165dc6626fa67762420506485283e" + integrity sha512-UzNXg4WbHHXLAa58VA6f5oq4OHXDEXIn1bigfWqAbe0jKWJR36QXLWDZsm4ufoC3ExyXOiOVyNfKOSnJ0xdTww== + "@depay/web3-client-evm@^10.19.1": version "10.19.1" resolved "https://registry.yarnpkg.com/@depay/web3-client-evm/-/web3-client-evm-10.19.1.tgz#88091c94bc9603e2afe7bfb25dceed322ce76181"