@ape.swap/bonds-sdk 5.1.3 → 5.1.5-test.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/constants/networks.d.ts +2 -0
- package/dist/config/constants/networks.js +7 -2
- package/dist/config/constants/networks.js.map +1 -1
- package/dist/main.d.ts +2 -1
- package/dist/main.js +1 -0
- package/dist/main.js.map +1 -1
- package/dist/state/balance/useCurrencyBalanceSolana.js +1 -2
- package/dist/state/balance/useCurrencyBalanceSolana.js.map +1 -1
- package/dist/state/useSDKConfig.d.ts +2 -0
- package/dist/state/useSDKConfig.js +8 -0
- package/dist/state/useSDKConfig.js.map +1 -1
- package/dist/utils/multicall.js +2 -2
- package/dist/utils/multicall.js.map +1 -1
- package/package.json +5 -1
|
@@ -3,4 +3,6 @@ export declare const PUBLIC_RPC_URLS: Partial<Record<ChainId, string[]>>;
|
|
|
3
3
|
export declare const HELIUS_SOL_RPC_ENDPOINTS: string[];
|
|
4
4
|
export declare const getRandomHeliusRPC: () => string;
|
|
5
5
|
export declare const HELIUS_SOL_RPC: string;
|
|
6
|
+
export declare const setCustomRPCS: (urls: Partial<Record<ChainId, string[]>>) => void;
|
|
7
|
+
export declare const getCustomRPCS: () => Partial<Record<ChainId, string[]>>;
|
|
6
8
|
export declare const getRPC: (chain: ChainId) => string;
|
|
@@ -79,9 +79,14 @@ const getRandomHeliusRPC = () => {
|
|
|
79
79
|
};
|
|
80
80
|
// Keep the current export for backward compatibility
|
|
81
81
|
const HELIUS_SOL_RPC = getRandomHeliusRPC();
|
|
82
|
+
// Custom RPC registry — set by the consumer via the `customRPCS` prop
|
|
83
|
+
let _customRPCS = {};
|
|
84
|
+
const setCustomRPCS = (urls) => {
|
|
85
|
+
_customRPCS = urls;
|
|
86
|
+
};
|
|
82
87
|
const getRPC = (chain) => {
|
|
83
|
-
return PUBLIC_RPC_URLS?.[chain]?.[0];
|
|
88
|
+
return _customRPCS?.[chain]?.[0] ?? PUBLIC_RPC_URLS?.[chain]?.[0];
|
|
84
89
|
};
|
|
85
90
|
|
|
86
|
-
export { HELIUS_SOL_RPC, HELIUS_SOL_RPC_ENDPOINTS, PUBLIC_RPC_URLS, getRPC, getRandomHeliusRPC };
|
|
91
|
+
export { HELIUS_SOL_RPC, HELIUS_SOL_RPC_ENDPOINTS, PUBLIC_RPC_URLS, getRPC, getRandomHeliusRPC, setCustomRPCS };
|
|
87
92
|
//# sourceMappingURL=networks.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"networks.js","sources":["../../../src/config/constants/networks.ts"],"sourcesContent":["import { ChainId } from '@ape.swap/apeswap-lists'\n\nexport const PUBLIC_RPC_URLS: Partial<Record<ChainId, string[]>> = {\n [ChainId.BSC]: [\n 'https://bsc-dataseed.binance.org/',\n 'https://bsc-dataseed1.defibit.io',\n 'https://endpoints.omniatech.io/v1/bsc/mainnet/public',\n ],\n [ChainId.ARBITRUM]: ['https://arb1.arbitrum.io/rpc'],\n [ChainId.BSC_TESTNET]: ['https://data-seed-prebsc-2-s3.binance.org:8545/'],\n [ChainId.MATIC]: [\n 'https://polygon.drpc.org',\n 'https://polygon-rpc.com/', // this is now freemium\n 'https://polygon-mainnet.public.blastapi.io/',\n 'https://rpc-mainnet.matic.network',\n 'https://matic-mainnet.chainstacklabs.com',\n ],\n [ChainId.MAINNET]: [\n 'https://ethereum-rpc.publicnode.com',\n 'https://eth.drpc.org',\n 'https://eth-mainnet.public.blastapi.io',\n 'https://rpc.ankr.com/eth',\n ],\n [ChainId.TLOS]: ['https://mainnet.telos.net/evm'],\n [ChainId.INEVM]: ['https://mainnet.rpc.inevm.com/http'],\n [ChainId.SEPOLIA]: ['https://eth-sepolia-public.unifra.io'],\n [ChainId.LINEA]: [\n 'https://rpc.linea.build',\n 'https://linea.drpc.org',\n 'https://linea.blockpi.network/v1/rpc/public',\n 'https://linea.decubate.com',\n ],\n [ChainId.LIGHTLINK]: [\n 'https://replicator.phoenix.lightlink.io/rpc/v1',\n 'https://endpoints.omniatech.io/v1/lightlink/phoenix/public',\n ],\n [ChainId.IOTA]: ['https://json-rpc.evm.iotaledger.net/'],\n [ChainId.IOTA_TESTNET]: ['https://json-rpc.evm.testnet.iotaledger.net/'],\n [ChainId.BASE]: ['https://base-rpc.publicnode.com', 'https://mainnet.base.org'],\n [ChainId.GRAPHLINQ]: ['https://glq-dataseed.graphlinq.io'],\n [ChainId.AVAX]: ['https://avalanche-c-chain-rpc.publicnode.com', 'https://avax.meowrpc.com'],\n [ChainId.BLAST]: ['https://rpc.blast.io'],\n [ChainId.CROSSFI]: ['https://rpc.mainnet.ms'],\n [ChainId.MONAD_TESTNET]: ['https://testnet-rpc2.monad.xyz/52227f026fa8fac9e2014c58fbf5643369b3bfc6'],\n [ChainId.MONAD]: [\n 'https://rpc.monad.xyz',\n 'https://rpc1.monad.xyz',\n 'https://rpc2.monad.xyz',\n 'https://rpc3.monad.xyz',\n 'https://rpc4.monad.xyz',\n ],\n [ChainId.SONIC]: ['https://rpc.soniclabs.com'],\n [ChainId.BERACHAIN]: ['https://rpc.berachain.com', 'https://berachain.drpc.org'],\n [ChainId.KATANA]: ['https://rpc-katana.t.conduit.xyz/NRcSLqEG4Hw55GzTSu6Sratq94kKtUGfH'],\n [ChainId.UNICHAIN]: ['https://unichain-rpc.publicnode.com', 'https://unichain.drpc.org'],\n [ChainId.MEGAETH_TESTNET]: ['https://carrot.megaeth.com/rpc'],\n [ChainId.HYPEREVM]: ['https://rpc.hyperliquid.xyz/evm'],\n\n // SOL RPC is not public. Production URL (morning-autumn-dream) is domain-protected, development URL (ancient-cold-sailboat) is free, use with caution.\n [ChainId.SOL]:\n process.env.NODE_ENV === 'production'\n ? ['https://morning-autumn-dream.solana-mainnet.quiknode.pro/1ef6069950c798a43a112c0fe5eb157309427db8']\n : [\n 'https://ancient-cold-sailboat.solana-mainnet.quiknode.pro/da13400ad8d0035313f3e71c6a37c107d0d0334b',\n 'https://mainnet.helius-rpc.com/?api-key=d80b11e0-692f-4da0-91d6-830799c8c385',\n ], // mainnet\n // [ChainId.SOL]: ['https://devnet.helius-rpc.com/?api-key=095f6fc7-1be0-4d94-a737-4a5ee0d82ea5'], // devnet\n}\n\n// Multiple Helius SOL RPC endpoints for rotation\nexport const HELIUS_SOL_RPC_ENDPOINTS = [\n 'https://mainnet.helius-rpc.com/?api-key=d80b11e0-692f-4da0-91d6-830799c8c385', // apefede09@gmail.com\n 'https://mainnet.helius-rpc.com/?api-key=8631ce42-9000-490d-9ac3-f3a81de508b2', // apebond.design@gmail.com\n 'https://mainnet.helius-rpc.com/?api-key=c097651d-ae13-4ab4-ae4c-fef7e48d4561', // n0mbr3al3at0r10@gmail.com\n 'https://mainnet.helius-rpc.com/?api-key=a5c4ea36-fa6b-4bcc-a7a4-e10012b9ea7e', // RandomApe personal mail\n]\n\n// export const HELIUS_SOL_RPC_ENDPOINTS = ['https://devnet.helius-rpc.com/?api-key=095f6fc7-1be0-4d94-a737-4a5ee0d82ea5'] //devnet\n\n// Function to get a random Helius SOL RPC endpoint\nexport const getRandomHeliusRPC = (): string => {\n const randomIndex = Math.floor(Math.random() * HELIUS_SOL_RPC_ENDPOINTS.length)\n return HELIUS_SOL_RPC_ENDPOINTS[randomIndex]\n}\n\n// Keep the current export for backward compatibility\nexport const HELIUS_SOL_RPC = getRandomHeliusRPC()\n\nexport const getRPC = (chain: ChainId) => {\n return PUBLIC_RPC_URLS?.[chain]?.[0] as string\n}\n"],"names":[],"mappings":";;AAEO,MAAM,eAAe,GAAuC;AACjE,IAAA,CAAC,OAAO,CAAC,GAAG,GAAG;QACb,mCAAmC;QACnC,kCAAkC;QAClC,sDAAsD;AACvD,KAAA;AACD,IAAA,CAAC,OAAO,CAAC,QAAQ,GAAG,CAAC,8BAA8B,CAAC;AACpD,IAAA,CAAC,OAAO,CAAC,WAAW,GAAG,CAAC,iDAAiD,CAAC;AAC1E,IAAA,CAAC,OAAO,CAAC,KAAK,GAAG;QACf,0BAA0B;AA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AAC,OAAO,CAAC,KAAK,GAAG,CAAC,2BAA2B,CAAC;IAC9C,CAAC,OAAO,CAAC,SAAS,GAAG,CAAC,2BAA2B,EAAE,4BAA4B,CAAC;AAChF,IAAA,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,oEAAoE,CAAC;IACxF,CAAC,OAAO,CAAC,QAAQ,GAAG,CAAC,qCAAqC,EAAE,2BAA2B,CAAC;AACxF,IAAA,CAAC,OAAO,CAAC,eAAe,GAAG,CAAC,gCAAgC,CAAC;AAC7D,IAAA,CAAC,OAAO,CAAC,QAAQ,GAAG,CAAC,iCAAiC,CAAC;;IAGvD,CAAC,OAAO,CAAC,GAAG,GACV,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK;UACrB,CAAC,mGAAmG;AACtG,UAAE;YACE,oGAAoG;YACpG,8EAA8E;AAC/E,SAAA;;;AAIT;AACO,MAAM,wBAAwB,GAAG;AACtC,IAAA,8EAA8E;AAC9E,IAAA,8EAA8E;AAC9E,IAAA,8EAA8E;AAC9E,IAAA,8EAA8E;;AAGhF;AAEA;AACO,MAAM,kBAAkB,GAAG,MAAa;AAC7C,IAAA,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,wBAAwB,CAAC,MAAM,CAAC;AAC/E,IAAA,OAAO,wBAAwB,CAAC,WAAW,CAAC;AAC9C;AAEA;AACO,MAAM,cAAc,GAAG,kBAAkB;
|
|
1
|
+
{"version":3,"file":"networks.js","sources":["../../../src/config/constants/networks.ts"],"sourcesContent":["import { ChainId } from '@ape.swap/apeswap-lists'\n\nexport const PUBLIC_RPC_URLS: Partial<Record<ChainId, string[]>> = {\n [ChainId.BSC]: [\n 'https://bsc-dataseed.binance.org/',\n 'https://bsc-dataseed1.defibit.io',\n 'https://endpoints.omniatech.io/v1/bsc/mainnet/public',\n ],\n [ChainId.ARBITRUM]: ['https://arb1.arbitrum.io/rpc'],\n [ChainId.BSC_TESTNET]: ['https://data-seed-prebsc-2-s3.binance.org:8545/'],\n [ChainId.MATIC]: [\n 'https://polygon.drpc.org',\n 'https://polygon-rpc.com/', // this is now freemium\n 'https://polygon-mainnet.public.blastapi.io/',\n 'https://rpc-mainnet.matic.network',\n 'https://matic-mainnet.chainstacklabs.com',\n ],\n [ChainId.MAINNET]: [\n 'https://ethereum-rpc.publicnode.com',\n 'https://eth.drpc.org',\n 'https://eth-mainnet.public.blastapi.io',\n 'https://rpc.ankr.com/eth',\n ],\n [ChainId.TLOS]: ['https://mainnet.telos.net/evm'],\n [ChainId.INEVM]: ['https://mainnet.rpc.inevm.com/http'],\n [ChainId.SEPOLIA]: ['https://eth-sepolia-public.unifra.io'],\n [ChainId.LINEA]: [\n 'https://rpc.linea.build',\n 'https://linea.drpc.org',\n 'https://linea.blockpi.network/v1/rpc/public',\n 'https://linea.decubate.com',\n ],\n [ChainId.LIGHTLINK]: [\n 'https://replicator.phoenix.lightlink.io/rpc/v1',\n 'https://endpoints.omniatech.io/v1/lightlink/phoenix/public',\n ],\n [ChainId.IOTA]: ['https://json-rpc.evm.iotaledger.net/'],\n [ChainId.IOTA_TESTNET]: ['https://json-rpc.evm.testnet.iotaledger.net/'],\n [ChainId.BASE]: ['https://base-rpc.publicnode.com', 'https://mainnet.base.org'],\n [ChainId.GRAPHLINQ]: ['https://glq-dataseed.graphlinq.io'],\n [ChainId.AVAX]: ['https://avalanche-c-chain-rpc.publicnode.com', 'https://avax.meowrpc.com'],\n [ChainId.BLAST]: ['https://rpc.blast.io'],\n [ChainId.CROSSFI]: ['https://rpc.mainnet.ms'],\n [ChainId.MONAD_TESTNET]: ['https://testnet-rpc2.monad.xyz/52227f026fa8fac9e2014c58fbf5643369b3bfc6'],\n [ChainId.MONAD]: [\n 'https://rpc.monad.xyz',\n 'https://rpc1.monad.xyz',\n 'https://rpc2.monad.xyz',\n 'https://rpc3.monad.xyz',\n 'https://rpc4.monad.xyz',\n ],\n [ChainId.SONIC]: ['https://rpc.soniclabs.com'],\n [ChainId.BERACHAIN]: ['https://rpc.berachain.com', 'https://berachain.drpc.org'],\n [ChainId.KATANA]: ['https://rpc-katana.t.conduit.xyz/NRcSLqEG4Hw55GzTSu6Sratq94kKtUGfH'],\n [ChainId.UNICHAIN]: ['https://unichain-rpc.publicnode.com', 'https://unichain.drpc.org'],\n [ChainId.MEGAETH_TESTNET]: ['https://carrot.megaeth.com/rpc'],\n [ChainId.HYPEREVM]: ['https://rpc.hyperliquid.xyz/evm'],\n\n // SOL RPC is not public. Production URL (morning-autumn-dream) is domain-protected, development URL (ancient-cold-sailboat) is free, use with caution.\n [ChainId.SOL]:\n process.env.NODE_ENV === 'production'\n ? ['https://morning-autumn-dream.solana-mainnet.quiknode.pro/1ef6069950c798a43a112c0fe5eb157309427db8']\n : [\n 'https://ancient-cold-sailboat.solana-mainnet.quiknode.pro/da13400ad8d0035313f3e71c6a37c107d0d0334b',\n 'https://mainnet.helius-rpc.com/?api-key=d80b11e0-692f-4da0-91d6-830799c8c385',\n ], // mainnet\n // [ChainId.SOL]: ['https://devnet.helius-rpc.com/?api-key=095f6fc7-1be0-4d94-a737-4a5ee0d82ea5'], // devnet\n}\n\n// Multiple Helius SOL RPC endpoints for rotation\nexport const HELIUS_SOL_RPC_ENDPOINTS = [\n 'https://mainnet.helius-rpc.com/?api-key=d80b11e0-692f-4da0-91d6-830799c8c385', // apefede09@gmail.com\n 'https://mainnet.helius-rpc.com/?api-key=8631ce42-9000-490d-9ac3-f3a81de508b2', // apebond.design@gmail.com\n 'https://mainnet.helius-rpc.com/?api-key=c097651d-ae13-4ab4-ae4c-fef7e48d4561', // n0mbr3al3at0r10@gmail.com\n 'https://mainnet.helius-rpc.com/?api-key=a5c4ea36-fa6b-4bcc-a7a4-e10012b9ea7e', // RandomApe personal mail\n]\n\n// export const HELIUS_SOL_RPC_ENDPOINTS = ['https://devnet.helius-rpc.com/?api-key=095f6fc7-1be0-4d94-a737-4a5ee0d82ea5'] //devnet\n\n// Function to get a random Helius SOL RPC endpoint\nexport const getRandomHeliusRPC = (): string => {\n const randomIndex = Math.floor(Math.random() * HELIUS_SOL_RPC_ENDPOINTS.length)\n return HELIUS_SOL_RPC_ENDPOINTS[randomIndex]\n}\n\n// Keep the current export for backward compatibility\nexport const HELIUS_SOL_RPC = getRandomHeliusRPC()\n\n// Custom RPC registry — set by the consumer via the `customRPCS` prop\nlet _customRPCS: Partial<Record<ChainId, string[]>> = {}\n\nexport const setCustomRPCS = (urls: Partial<Record<ChainId, string[]>>) => {\n _customRPCS = urls\n}\n\nexport const getCustomRPCS = () => _customRPCS\n\nexport const getRPC = (chain: ChainId): string => {\n return _customRPCS?.[chain]?.[0] ?? (PUBLIC_RPC_URLS?.[chain]?.[0] as string)\n}\n"],"names":[],"mappings":";;AAEO,MAAM,eAAe,GAAuC;AACjE,IAAA,CAAC,OAAO,CAAC,GAAG,GAAG;QACb,mCAAmC;QACnC,kCAAkC;QAClC,sDAAsD;AACvD,KAAA;AACD,IAAA,CAAC,OAAO,CAAC,QAAQ,GAAG,CAAC,8BAA8B,CAAC;AACpD,IAAA,CAAC,OAAO,CAAC,WAAW,GAAG,CAAC,iDAAiD,CAAC;AAC1E,IAAA,CAAC,OAAO,CAAC,KAAK,GAAG;QACf,0BAA0B;AAC1B,QAAA,0BAA0B;QAC1B,6CAA6C;QAC7C,mCAAmC;QACnC,0CAA0C;AAC3C,KAAA;AACD,IAAA,CAAC,OAAO,CAAC,OAAO,GAAG;QACjB,qCAAqC;QACrC,sBAAsB;QACtB,wCAAwC;QACxC,0BAA0B;AAC3B,KAAA;AACD,IAAA,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,+BAA+B,CAAC;AACjD,IAAA,CAAC,OAAO,CAAC,KAAK,GAAG,CAAC,oCAAoC,CAAC;AACvD,IAAA,CAAC,OAAO,CAAC,OAAO,GAAG,CAAC,sCAAsC,CAAC;AAC3D,IAAA,CAAC,OAAO,CAAC,KAAK,GAAG;QACf,yBAAyB;QACzB,wBAAwB;QACxB,6CA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;UACrB,CAAC,mGAAmG;AACtG,UAAE;YACE,oGAAoG;YACpG,8EAA8E;AAC/E,SAAA;;;AAIT;AACO,MAAM,wBAAwB,GAAG;AACtC,IAAA,8EAA8E;AAC9E,IAAA,8EAA8E;AAC9E,IAAA,8EAA8E;AAC9E,IAAA,8EAA8E;;AAGhF;AAEA;AACO,MAAM,kBAAkB,GAAG,MAAa;AAC7C,IAAA,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,wBAAwB,CAAC,MAAM,CAAC;AAC/E,IAAA,OAAO,wBAAwB,CAAC,WAAW,CAAC;AAC9C;AAEA;AACO,MAAM,cAAc,GAAG,kBAAkB;AAEhD;AACA,IAAI,WAAW,GAAuC,EAAE;AAEjD,MAAM,aAAa,GAAG,CAAC,IAAwC,KAAI;IACxE,WAAW,GAAG,IAAI;AACpB;AAIO,MAAM,MAAM,GAAG,CAAC,KAAc,KAAY;AAC/C,IAAA,OAAO,WAAW,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAK,eAAe,GAAG,KAAK,CAAC,GAAG,CAAC,CAAY;AAC/E;;;;"}
|
package/dist/main.d.ts
CHANGED
|
@@ -33,7 +33,8 @@ import useTokenPrices from './state/tokenPrices/useTokenPrices';
|
|
|
33
33
|
import { useSDKConfig } from './state/useSDKConfig';
|
|
34
34
|
import { BLOCK_EXPLORER } from './config/constants/chains';
|
|
35
35
|
import useCurrencyBalance from './state/balance/useCurrencyBalance';
|
|
36
|
+
import useUserTokensBalance from './state/balance/useUserTokensBalance';
|
|
36
37
|
import TokenImage from './components/uikit-sdk/TokenImage';
|
|
37
38
|
import { useApproval } from './state/allowance/useAllowance';
|
|
38
39
|
import useBondsData from './state/bonds/useBondsData';
|
|
39
|
-
export { Bonds, BuyBondModal, YourBonds, FullBondsView, ProjectView, generateImageFromTemplate, ChainId, SingleBond, useTokenPrices, useBondsData, useSDKConfig, BLOCK_EXPLORER, useCurrencyBalance, TokenImage, useApproval, };
|
|
40
|
+
export { Bonds, BuyBondModal, YourBonds, FullBondsView, ProjectView, generateImageFromTemplate, ChainId, SingleBond, useTokenPrices, useBondsData, useSDKConfig, BLOCK_EXPLORER, useCurrencyBalance, useUserTokensBalance, TokenImage, useApproval, };
|
package/dist/main.js
CHANGED
|
@@ -10,6 +10,7 @@ export { default as useTokenPrices } from './state/tokenPrices/useTokenPrices.js
|
|
|
10
10
|
export { useSDKConfig } from './state/useSDKConfig.js';
|
|
11
11
|
export { BLOCK_EXPLORER } from './config/constants/chains.js';
|
|
12
12
|
export { default as useCurrencyBalance } from './state/balance/useCurrencyBalance.js';
|
|
13
|
+
export { default as useUserTokensBalance } from './state/balance/useUserTokensBalance.js';
|
|
13
14
|
export { default as TokenImage } from './components/uikit-sdk/TokenImage/index.js';
|
|
14
15
|
export { useApproval } from './state/allowance/useAllowance.js';
|
|
15
16
|
export { default as useBondsData } from './state/bonds/useBondsData.js';
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"main.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}
|
|
@@ -7,11 +7,10 @@ import { getRPC } from '../../config/constants/networks.js';
|
|
|
7
7
|
import { getTokenProgramForMint } from '../../utils/solanaAtaHelper.js';
|
|
8
8
|
|
|
9
9
|
// Use devnet or your custom cluster URL
|
|
10
|
-
const SOLANA_RPC_URL = getRPC(ChainId.SOL);
|
|
11
|
-
const connection = new Connection(SOLANA_RPC_URL, 'confirmed');
|
|
12
10
|
const getTokenBalanceSolana = async (currency, account) => {
|
|
13
11
|
if (!account || !currency)
|
|
14
12
|
return null;
|
|
13
|
+
const connection = new Connection(getRPC(ChainId.SOL), 'confirmed');
|
|
15
14
|
const userPubkey = new PublicKey(account);
|
|
16
15
|
try {
|
|
17
16
|
if (currency === 'NATIVE') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCurrencyBalanceSolana.js","sources":["../../../src/state/balance/useCurrencyBalanceSolana.ts"],"sourcesContent":["import { useQuery, UseQueryResult } from '@tanstack/react-query'\nimport { QUERY_KEYS } from '../../config/constants/queryKeys'\n\nimport { Connection, PublicKey } from '@solana/web3.js'\nimport { getAccount } from '@solana/spl-token'\nimport { ChainId, Token } from '@ape.swap/apeswap-lists'\nimport BigNumber from 'bignumber.js'\nimport { getRPC } from '../../config/constants/networks'\nimport { getTokenProgramForMint } from '../../utils/solanaAtaHelper'\nimport { getAssociatedTokenAddress } from '@solana/spl-token'\n\nexport default function useCurrencyBalanceSolana(\n currency: 'NATIVE' | Token | null,\n account: string | null,\n): UseQueryResult<string | null> {\n return useQuery({\n queryKey: [QUERY_KEYS.CURRENCY_BALANCE, account ?? '', currency === 'NATIVE' ? currency : currency?.symbol],\n queryFn: () => getTokenBalanceSolana(currency, account),\n refetchInterval: 10000,\n refetchOnWindowFocus: false,\n retry: 1,\n })\n}\n\n// Use devnet or your custom cluster URL\
|
|
1
|
+
{"version":3,"file":"useCurrencyBalanceSolana.js","sources":["../../../src/state/balance/useCurrencyBalanceSolana.ts"],"sourcesContent":["import { useQuery, UseQueryResult } from '@tanstack/react-query'\nimport { QUERY_KEYS } from '../../config/constants/queryKeys'\n\nimport { Connection, PublicKey } from '@solana/web3.js'\nimport { getAccount } from '@solana/spl-token'\nimport { ChainId, Token } from '@ape.swap/apeswap-lists'\nimport BigNumber from 'bignumber.js'\nimport { getRPC } from '../../config/constants/networks'\nimport { getTokenProgramForMint } from '../../utils/solanaAtaHelper'\nimport { getAssociatedTokenAddress } from '@solana/spl-token'\n\nexport default function useCurrencyBalanceSolana(\n currency: 'NATIVE' | Token | null,\n account: string | null,\n): UseQueryResult<string | null> {\n return useQuery({\n queryKey: [QUERY_KEYS.CURRENCY_BALANCE, account ?? '', currency === 'NATIVE' ? currency : currency?.symbol],\n queryFn: () => getTokenBalanceSolana(currency, account),\n refetchInterval: 10000,\n refetchOnWindowFocus: false,\n retry: 1,\n })\n}\n\n// Use devnet or your custom cluster URL\nexport const getTokenBalanceSolana = async (\n currency: 'NATIVE' | Token | null,\n account: string | null,\n): Promise<string | null> => {\n if (!account || !currency) return null\n\n const connection = new Connection(getRPC(ChainId.SOL), 'confirmed')\n const userPubkey = new PublicKey(account)\n\n try {\n if (currency === 'NATIVE') {\n const lamports = await connection.getBalance(userPubkey)\n const sol = new BigNumber(lamports).dividedBy(1e9)\n return sol.toString()\n } else {\n const mint = new PublicKey(currency?.address?.[ChainId.SOL] as string)\n // Detect token program to get correct ATA (supports Token-2022)\n const tokenProgram = await getTokenProgramForMint(connection, mint)\n const ata = await getAssociatedTokenAddress(mint, userPubkey, true, tokenProgram)\n if (!ata) return '0'\n const tokenAccount = await getAccount(connection, ata, undefined, tokenProgram)\n const amount = new BigNumber(tokenAccount.amount.toString()).dividedBy(\n new BigNumber(10).pow(currency?.decimals?.[ChainId.SOL] as number),\n )\n return amount.toString()\n }\n } catch {\n // If account doesn't exist (e.g. never received that token)\n return '0'\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAwBA;AACO,MAAM,qBAAqB,GAAG,OACnC,QAAiC,EACjC,OAAsB,KACI;AAC1B,IAAA,IAAI,CAAC,OAAO,IAAI,CAAC,QAAQ;AAAE,QAAA,OAAO,IAAI;AAEtC,IAAA,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,WAAW,CAAC;AACnE,IAAA,MAAM,UAAU,GAAG,IAAI,SAAS,CAAC,OAAO,CAAC;AAEzC,IAAA,IAAI;AACF,QAAA,IAAI,QAAQ,KAAK,QAAQ,EAAE;YACzB,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC;AACxD,YAAA,MAAM,GAAG,GAAG,IAAI,SAAS,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC;AAClD,YAAA,OAAO,GAAG,CAAC,QAAQ,EAAE;QACvB;aAAO;AACL,YAAA,MAAM,IAAI,GAAG,IAAI,SAAS,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,GAAG,CAAW,CAAC;;YAEtE,MAAM,YAAY,GAAG,MAAM,sBAAsB,CAAC,UAAU,EAAE,IAAI,CAAC;AACnE,YAAA,MAAM,GAAG,GAAG,MAAM,yBAAyB,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,CAAC;AACjF,YAAA,IAAI,CAAC,GAAG;AAAE,gBAAA,OAAO,GAAG;AACpB,YAAA,MAAM,YAAY,GAAG,MAAM,UAAU,CAAC,UAAU,EAAE,GAAG,EAAE,SAAS,EAAE,YAAY,CAAC;AAC/E,YAAA,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,SAAS,CACpE,IAAI,SAAS,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAW,CAAC,CACnE;AACD,YAAA,OAAO,MAAM,CAAC,QAAQ,EAAE;QAC1B;IACF;AAAE,IAAA,MAAM;;AAEN,QAAA,OAAO,GAAG;IACZ;AACF;;;;"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ChainId } from '@ape.swap/apeswap-lists';
|
|
1
2
|
export interface SDKPropsDTO {
|
|
2
3
|
referenceId: string;
|
|
3
4
|
chains: number[];
|
|
@@ -16,6 +17,7 @@ export interface SDKPropsDTO {
|
|
|
16
17
|
blockSales?: boolean;
|
|
17
18
|
customBranch?: string;
|
|
18
19
|
highlightedBond?: string;
|
|
20
|
+
customRPCS?: Partial<Record<ChainId, string[]>>;
|
|
19
21
|
}
|
|
20
22
|
export interface SDKProps {
|
|
21
23
|
referenceId: string;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
1
2
|
import { useQuery } from '@tanstack/react-query';
|
|
2
3
|
import { QUERY_KEYS } from '../config/constants/queryKeys.js';
|
|
3
4
|
import { ChainId } from '@ape.swap/apeswap-lists';
|
|
5
|
+
import { setCustomRPCS } from '../config/constants/networks.js';
|
|
4
6
|
|
|
5
7
|
// Prod URLS. Do not make changes here
|
|
6
8
|
const defaultUrls = {
|
|
@@ -36,6 +38,12 @@ const useSDKConfig = (config) => {
|
|
|
36
38
|
urls: { ...urls, ...config?.urls },
|
|
37
39
|
highestCompatibleVersion: '2.2.0',
|
|
38
40
|
};
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (config?.customRPCS) {
|
|
43
|
+
console.log('Setting custom RPCs:', config.customRPCS);
|
|
44
|
+
setCustomRPCS(config.customRPCS);
|
|
45
|
+
}
|
|
46
|
+
}, [config?.customRPCS]);
|
|
39
47
|
const { data } = useQuery({
|
|
40
48
|
queryKey: [QUERY_KEYS.SDK_CONFIG],
|
|
41
49
|
queryFn: () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSDKConfig.js","sources":["../../src/state/useSDKConfig.ts"],"sourcesContent":["import { useQuery } from '@tanstack/react-query'\nimport { QUERY_KEYS } from '../config/constants/queryKeys'\nimport { ChainId } from '@ape.swap/apeswap-lists'\n\n// Prod URLS. Do not make changes here\nconst defaultUrls = {\n apiV2: 'https://api.ape.bond',\n realTimeApi: 'https://realtime-api.ape.bond',\n mainUrl: 'https://ape.bond',\n priceApi: 'https://price-api.ape.bond',\n}\n\n// Staging URLS.\nconst stagingUrls = {\n apiV2: 'https://staging-api.ape.bond',\n realTimeApi: 'https://realtime-api-staging.ape.bond',\n mainUrl: 'https://staging.ape.bond',\n priceApi: 'https://price-api.ape.bond',\n}\n\nexport interface SDKPropsDTO {\n referenceId: string\n chains: number[]\n hotBondChains?: number[]\n connector?: 'rainbowkit' | 'appkit' | 'default'\n useHotBonds?: boolean\n useTiers?: boolean\n useTGEBonds?: boolean\n useCardsView?: boolean\n showLowValueBonds?: boolean\n bondPartner?: string\n namingPreference?: 'Discount' | 'Bonus'\n urls?: Partial<Record<URLKeys, string>>\n theme?: any\n highestCompatibleVersion?: string\n blockSales?: boolean\n customBranch?: string\n highlightedBond?: string\n}\n\nexport interface SDKProps {\n referenceId: string\n chains: number[]\n hotBondChains: number[]\n connector?: 'rainbowkit' | 'appkit' | 'default'\n useHotBonds: boolean\n useTiers: boolean\n useTGEBonds: boolean\n showLowValueBonds: boolean\n bondPartner?: string\n namingPreference: 'Discount' | 'Bonus'\n urls: Record<URLKeys, string>\n theme?: any\n highestCompatibleVersion?: string\n evmAddress?: string\n solAddress?: string\n useCardsView?: boolean\n blockSales?: boolean\n customBranch?: string\n highlightedBond?: string\n}\n\nexport const useSDKConfig = (config?: SDKPropsDTO): SDKProps => {\n const urls = process.env.NODE_ENV === 'production' ? defaultUrls : stagingUrls\n\n const initialData: SDKProps = {\n referenceId: '',\n chains: [],\n hotBondChains: [ChainId.BSC, ChainId.MATIC],\n useHotBonds: true,\n connector: 'default',\n useTiers: false,\n useTGEBonds: false,\n showLowValueBonds: false,\n bondPartner: undefined,\n namingPreference: 'Bonus',\n useCardsView: false,\n blockSales: false,\n customBranch: '',\n ...config,\n urls: { ...urls, ...config?.urls },\n highestCompatibleVersion: '2.2.0',\n }\n const { data } = useQuery({\n queryKey: [QUERY_KEYS.SDK_CONFIG],\n queryFn: () => {\n throw new Error('Just a hotfix for latest versions of react-query that make queryFn a required prop')\n },\n initialData,\n })\n return data as SDKProps\n}\n\nexport type URLKeys = 'apiV2' | 'realTimeApi' | 'mainUrl' | 'priceApi'\n\nexport const useURLByEnvironment = (key: URLKeys) => {\n const config = useSDKConfig()\n return config?.urls?.[key] as string\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useSDKConfig.js","sources":["../../src/state/useSDKConfig.ts"],"sourcesContent":["import { useEffect } from 'react'\nimport { useQuery } from '@tanstack/react-query'\nimport { QUERY_KEYS } from '../config/constants/queryKeys'\nimport { ChainId } from '@ape.swap/apeswap-lists'\nimport { setCustomRPCS } from '../config/constants/networks'\n\n// Prod URLS. Do not make changes here\nconst defaultUrls = {\n apiV2: 'https://api.ape.bond',\n realTimeApi: 'https://realtime-api.ape.bond',\n mainUrl: 'https://ape.bond',\n priceApi: 'https://price-api.ape.bond',\n}\n\n// Staging URLS.\nconst stagingUrls = {\n apiV2: 'https://staging-api.ape.bond',\n realTimeApi: 'https://realtime-api-staging.ape.bond',\n mainUrl: 'https://staging.ape.bond',\n priceApi: 'https://price-api.ape.bond',\n}\n\nexport interface SDKPropsDTO {\n referenceId: string\n chains: number[]\n hotBondChains?: number[]\n connector?: 'rainbowkit' | 'appkit' | 'default'\n useHotBonds?: boolean\n useTiers?: boolean\n useTGEBonds?: boolean\n useCardsView?: boolean\n showLowValueBonds?: boolean\n bondPartner?: string\n namingPreference?: 'Discount' | 'Bonus'\n urls?: Partial<Record<URLKeys, string>>\n theme?: any\n highestCompatibleVersion?: string\n blockSales?: boolean\n customBranch?: string\n highlightedBond?: string\n customRPCS?: Partial<Record<ChainId, string[]>>\n}\n\nexport interface SDKProps {\n referenceId: string\n chains: number[]\n hotBondChains: number[]\n connector?: 'rainbowkit' | 'appkit' | 'default'\n useHotBonds: boolean\n useTiers: boolean\n useTGEBonds: boolean\n showLowValueBonds: boolean\n bondPartner?: string\n namingPreference: 'Discount' | 'Bonus'\n urls: Record<URLKeys, string>\n theme?: any\n highestCompatibleVersion?: string\n evmAddress?: string\n solAddress?: string\n useCardsView?: boolean\n blockSales?: boolean\n customBranch?: string\n highlightedBond?: string\n}\n\nexport const useSDKConfig = (config?: SDKPropsDTO): SDKProps => {\n const urls = process.env.NODE_ENV === 'production' ? defaultUrls : stagingUrls\n\n const initialData: SDKProps = {\n referenceId: '',\n chains: [],\n hotBondChains: [ChainId.BSC, ChainId.MATIC],\n useHotBonds: true,\n connector: 'default',\n useTiers: false,\n useTGEBonds: false,\n showLowValueBonds: false,\n bondPartner: undefined,\n namingPreference: 'Bonus',\n useCardsView: false,\n blockSales: false,\n customBranch: '',\n ...config,\n urls: { ...urls, ...config?.urls },\n highestCompatibleVersion: '2.2.0',\n }\n\n useEffect(() => {\n if (config?.customRPCS) {\n console.log('Setting custom RPCs:', config.customRPCS)\n setCustomRPCS(config.customRPCS)\n }\n }, [config?.customRPCS])\n\n const { data } = useQuery({\n queryKey: [QUERY_KEYS.SDK_CONFIG],\n queryFn: () => {\n throw new Error('Just a hotfix for latest versions of react-query that make queryFn a required prop')\n },\n initialData,\n })\n return data as SDKProps\n}\n\nexport type URLKeys = 'apiV2' | 'realTimeApi' | 'mainUrl' | 'priceApi'\n\nexport const useURLByEnvironment = (key: URLKeys) => {\n const config = useSDKConfig()\n return config?.urls?.[key] as string\n}\n"],"names":[],"mappings":";;;;;;AAMA;AACA,MAAM,WAAW,GAAG;AAClB,IAAA,KAAK,EAAE,sBAAsB;AAC7B,IAAA,WAAW,EAAE,+BAA+B;AAC5C,IAAA,OAAO,EAAE,kBAAkB;AAC3B,IAAA,QAAQ,EAAE,4BAA4B;CACvC;AAED;AACA,MAAM,WAAW,GAAG;AAClB,IAAA,KAAK,EAAE,8BAA8B;AACrC,IAAA,WAAW,EAAE,uCAAuC;AACpD,IAAA,OAAO,EAAE,0BAA0B;AACnC,IAAA,QAAQ,EAAE,4BAA4B;CACvC;AA6CM,MAAM,YAAY,GAAG,CAAC,MAAoB,KAAc;AAC7D,IAAA,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,GAAG,WAAW,GAAG,WAAW;AAE9E,IAAA,MAAM,WAAW,GAAa;AAC5B,QAAA,WAAW,EAAE,EAAE;AACf,QAAA,MAAM,EAAE,EAAE;QACV,aAAa,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,KAAK,CAAC;AAC3C,QAAA,WAAW,EAAE,IAAI;AACjB,QAAA,SAAS,EAAE,SAAS;AACpB,QAAA,QAAQ,EAAE,KAAK;AACf,QAAA,WAAW,EAAE,KAAK;AAClB,QAAA,iBAAiB,EAAE,KAAK;AACxB,QAAA,WAAW,EAAE,SAAS;AACtB,QAAA,gBAAgB,EAAE,OAAO;AACzB,QAAA,YAAY,EAAE,KAAK;AACnB,QAAA,UAAU,EAAE,KAAK;AACjB,QAAA,YAAY,EAAE,EAAE;AAChB,QAAA,GAAG,MAAM;QACT,IAAI,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE;AAClC,QAAA,wBAAwB,EAAE,OAAO;KAClC;IAED,SAAS,CAAC,MAAK;AACb,QAAA,IAAI,MAAM,EAAE,UAAU,EAAE;YACtB,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE,MAAM,CAAC,UAAU,CAAC;AACtD,YAAA,aAAa,CAAC,MAAM,CAAC,UAAU,CAAC;QAClC;AACF,IAAA,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAExB,IAAA,MAAM,EAAE,IAAI,EAAE,GAAG,QAAQ,CAAC;AACxB,QAAA,QAAQ,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC;QACjC,OAAO,EAAE,MAAK;AACZ,YAAA,MAAM,IAAI,KAAK,CAAC,oFAAoF,CAAC;QACvG,CAAC;QACD,WAAW;AACZ,KAAA,CAAC;AACF,IAAA,OAAO,IAAgB;AACzB;AAIO,MAAM,mBAAmB,GAAG,CAAC,GAAY,KAAI;AAClD,IAAA,MAAM,MAAM,GAAG,YAAY,EAAE;AAC7B,IAAA,OAAO,MAAM,EAAE,IAAI,GAAG,GAAG,CAAW;AACtC;;;;"}
|
package/dist/utils/multicall.js
CHANGED
|
@@ -3,7 +3,7 @@ import multicallV2Abi from '../config/abi/multicallv2.json.js';
|
|
|
3
3
|
import { ethers } from 'ethers';
|
|
4
4
|
import chunk from 'lodash-es/chunk.js';
|
|
5
5
|
import flatten from 'lodash-es/flatten.js';
|
|
6
|
-
import {
|
|
6
|
+
import { getRPC } from '../config/constants/networks.js';
|
|
7
7
|
import { MULTICALL_V2 } from '../config/constants/addresses.js';
|
|
8
8
|
import { ChainId } from '@ape.swap/apeswap-lists';
|
|
9
9
|
|
|
@@ -15,7 +15,7 @@ const multicall = async (chainId, abi, calls, batch, batchSize) => {
|
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
17
|
const multicallAddress = MULTICALL_V2[chainId];
|
|
18
|
-
const provider = new ethers.providers.JsonRpcProvider(
|
|
18
|
+
const provider = new ethers.providers.JsonRpcProvider(getRPC(chainId), chainId);
|
|
19
19
|
const multi = new ethers.Contract(multicallAddress, multicallV2Abi, provider);
|
|
20
20
|
const itf = new Interface(abi);
|
|
21
21
|
const calldata = calls.map((call) => [call.address.toLowerCase(), itf.encodeFunctionData(call.name, call.params)]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multicall.js","sources":["../../src/utils/multicall.ts"],"sourcesContent":["import { Interface } from '@ethersproject/abi'\nimport multicallV2Abi from '../config/abi/multicallv2.json'\nimport { ethers } from 'ethers'\nimport chunk from 'lodash-es/chunk.js'\nimport flatten from 'lodash-es/flatten.js'\nimport {
|
|
1
|
+
{"version":3,"file":"multicall.js","sources":["../../src/utils/multicall.ts"],"sourcesContent":["import { Interface } from '@ethersproject/abi'\nimport multicallV2Abi from '../config/abi/multicallv2.json'\nimport { ethers } from 'ethers'\nimport chunk from 'lodash-es/chunk.js'\nimport flatten from 'lodash-es/flatten.js'\nimport { getRPC } from '../config/constants/networks'\nimport { MULTICALL_V2 } from '../config/constants/addresses'\nimport { ChainId } from '@ape.swap/apeswap-lists'\n\nexport interface Call {\n address: string // Address of the contract\n name: string // Function name on the contract (exemple: balanceOf)\n params?: any[] // Function params\n}\n\n// This is the legacy multicall\n// Try to use multicall hooks\nconst multicall = async (chainId: number, abi: any[], calls: Call[], batch?: boolean, batchSize?: number) => {\n try {\n if (chainId === ChainId.SOL) {\n return\n }\n const multicallAddress = MULTICALL_V2[chainId]\n const provider = new ethers.providers.JsonRpcProvider(getRPC(chainId as ChainId), chainId)\n const multi = new ethers.Contract(multicallAddress, multicallV2Abi, provider)\n const itf = new Interface(abi)\n const calldata = calls.map((call) => [call.address.toLowerCase(), itf.encodeFunctionData(call.name, call.params)])\n if (batch) {\n const chunkedCalls = chunk(calldata, batchSize)\n const chunkedCallNames = chunk(calls, batchSize)\n const chunkedData = chunkedCalls.flatMap(async (chunkedCallSet, i) => {\n const { returnData } = await multi.aggregate(chunkedCallSet)\n return returnData.map((call: any, j: number) => itf.decodeFunctionResult(chunkedCallNames[i][j].name, call))\n })\n const resolveCall = await Promise.all(chunkedData)\n const flattenCalls = flatten(resolveCall)\n return flattenCalls\n } else {\n const { returnData } = await multi.aggregate(calldata)\n return returnData.map((call: any, i: number) => itf.decodeFunctionResult(calls[i].name, call))\n }\n } catch (e) {\n console.error(e)\n console.error(chainId)\n console.error(calls)\n }\n}\n\nexport default multicall\n"],"names":[],"mappings":";;;;;;;;;AAeA;AACA;AACA,MAAM,SAAS,GAAG,OAAO,OAAe,EAAE,GAAU,EAAE,KAAa,EAAE,KAAe,EAAE,SAAkB,KAAI;AAC1G,IAAA,IAAI;AACF,QAAA,IAAI,OAAO,KAAK,OAAO,CAAC,GAAG,EAAE;YAC3B;QACF;AACA,QAAA,MAAM,gBAAgB,GAAG,YAAY,CAAC,OAAO,CAAC;AAC9C,QAAA,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC,MAAM,CAAC,OAAkB,CAAC,EAAE,OAAO,CAAC;AAC1F,QAAA,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,QAAQ,CAAC,gBAAgB,EAAE,cAAc,EAAE,QAAQ,CAAC;AAC7E,QAAA,MAAM,GAAG,GAAG,IAAI,SAAS,CAAC,GAAG,CAAC;AAC9B,QAAA,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,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|
|
|
3
3
|
"description": "Ape Bond SDK",
|
|
4
4
|
"author": "Ape Bond",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "5.1.
|
|
6
|
+
"version": "5.1.5-test.0",
|
|
7
7
|
"module": "dist/main.js",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"types": "dist/main.d.ts",
|
|
@@ -57,6 +57,10 @@
|
|
|
57
57
|
"types": "./dist/state/balance/useCurrencyBalance.d.ts",
|
|
58
58
|
"import": "./dist/state/balance/useCurrencyBalance.js"
|
|
59
59
|
},
|
|
60
|
+
"./hooks/useUserTokensBalance": {
|
|
61
|
+
"types": "./dist/state/balance/useUserTokensBalance.d.ts",
|
|
62
|
+
"import": "./dist/state/balance/useUserTokensBalance.js"
|
|
63
|
+
},
|
|
60
64
|
"./hooks/useApproval": {
|
|
61
65
|
"types": "./dist/state/allowance/useAllowance.d.ts",
|
|
62
66
|
"import": "./dist/state/allowance/useAllowance.js"
|