Skip to content

Commit

Permalink
v14.0.0: removes drip functionality (due to race conditions), keeps g…
Browse files Browse the repository at this point in the history
…etting full assets only
  • Loading branch information
0xNe0x1 committed Oct 22, 2024
1 parent 96d5a77 commit 374d31c
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 80 deletions.
14 changes: 0 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
11 changes: 2 additions & 9 deletions dist/esm/index.evm.js
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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 }) || []);
Expand Down
11 changes: 2 additions & 9 deletions dist/esm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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 }) || []);
Expand Down
11 changes: 2 additions & 9 deletions dist/esm/index.solana.js
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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 }) || []);
Expand Down
9 changes: 1 addition & 8 deletions dist/umd/index.evm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) || []);
Expand Down
9 changes: 1 addition & 8 deletions dist/umd/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) || []);
Expand Down
9 changes: 1 addition & 8 deletions dist/umd/index.solana.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) || []);
Expand Down
2 changes: 1 addition & 1 deletion package.evm.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion package.solana.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
15 changes: 4 additions & 11 deletions src/route.js
Original file line number Diff line number Diff line change
@@ -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'

Expand Down Expand Up @@ -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 }) || [])
Expand Down
7 changes: 6 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 374d31c

Please sign in to comment.