@ape.swap/bonds-sdk 3.1.9-test.6 → 3.2.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/README.md CHANGED
@@ -20,10 +20,10 @@ To install the package via npm or yarn, run the following command:
20
20
 
21
21
  ```textmate
22
22
  # With npm
23
- npm install @ape.swap/bonds-sdk
23
+ npm install @ape.swap/bonds-sdk@evm
24
24
 
25
25
  # With yarn
26
- yarn add @ape.swap/bonds-sdk
26
+ yarn add @ape.swap/bonds-sdk@evm
27
27
  ```
28
28
 
29
29
  ---
@@ -83,14 +83,15 @@ export default MyBondsComponent
83
83
 
84
84
  The core of the SDK lies in its config object params, passed as a prop to its components. Below is a breakdown of key options:
85
85
 
86
- | Property | Type | Description |
87
- |-----------------|---------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
88
- | `referenceId` | `string` | A unique identifier for the bonds, shall be provided by ApeBond team. |
89
- | `chains` | `Array` | An array of supported chain IDs (e.g., `56`, `1`, `137`, etc). It also determines the order of the chains on the bond list. |
90
- | `useRainbowKit` | `boolean` | Whether to enable RainbowKit for wallet connections. Might be replaced for an enum in the near future. |
91
- | `useHotBonds` | `boolean` | Whether to show the "hot bonds" component. |
92
- | `theme` | `Object (optional)` | This is how you can customize the styles of the SDK. Override styles like colors, typography, and layout settings to match your project's branding. |
93
- | `tokenSymbol` | `string[]` | This parameter is specific to the `<SingleBond />` component. It defines the token(s) to display in the UI. Currently, only a single token (one element in the array) is supported.|
86
+ | Property | Type | Description |
87
+ |-----------------|---------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|
88
+ | `referenceId` | `string` | A unique identifier for the bonds, shall be provided by ApeBond team. |
89
+ | `chains` | `Array` | An array of supported chain IDs (e.g., `56`, `1`, `137`, etc). It also determines the order of the chains on the bond list. |
90
+ | `useRainbowKit` | `boolean` | Whether to enable RainbowKit for wallet connections. Might be replaced for an enum in the near future. |
91
+ | `useHotBonds` | `boolean` | Whether to show the "hot bonds" component. |
92
+ | `theme` | `Object (optional)` | This is how you can customize the styles of the SDK. Override styles like colors, typography, and layout settings to match your project's branding. |
93
+ | `tokenSymbol` | `string[]` | This parameter is specific to the `<SingleBond />` component. It defines the token(s) to display in the UI. Currently, only a single token (one element in the array) is supported.|
94
+ | `customRPCS` | `Partial<Record<ChainId, string[]>> (optional)` | Override the default public RPC URLs for any supported chain. Useful when you have a private or dedicated RPC endpoint. |
94
95
 
95
96
  ### Chain Support
96
97
 
@@ -57,6 +57,14 @@ const PUBLIC_RPC_URLS = {
57
57
  [ChainId.MEGAETH_TESTNET]: ['https://carrot.megaeth.com/rpc'],
58
58
  [ChainId.HYPEREVM]: ['https://rpc.hyperliquid.xyz/evm'],
59
59
  };
60
+ // Custom RPC registry — set by the consumer via the `customRPCS` prop
61
+ let _customRPCS = {};
62
+ const setCustomRPCS = (urls) => {
63
+ _customRPCS = urls;
64
+ };
65
+ const getRPC = (chain) => {
66
+ return _customRPCS?.[chain]?.[0] ?? PUBLIC_RPC_URLS?.[chain]?.[0];
67
+ };
60
68
 
61
- export { PUBLIC_RPC_URLS };
69
+ export { PUBLIC_RPC_URLS, getRPC, setCustomRPCS };
62
70
  //# 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://1rpc.io/matic',\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\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 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;QAC1B,uBAAuB;AACvB,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,6CAA6C;QAC7C,4B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eswap-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://1rpc.io/matic',\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\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 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;QAC1B,uBAAuB;AACvB,QAAA,0BAA0B;QAC1B,6CAA6C;QAC7C,mCAAmC;QACnC,0CAA0C;AAC3C,KAAA;AACD,IAAA,CAAC,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AA2B,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;;AAGzD;AACA,IAAI,WAAW,GAAuC,EAAE;AAEjD,MAAM,aAAa,GAAG,CAAC,IAAwC,KAAI;IACxE,WAAW,GAAG,IAAI;AACpB;AAEO,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;;;;"}
@@ -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[];
@@ -12,6 +13,7 @@ export interface SDKPropsDTO {
12
13
  urls?: Partial<Record<URLKeys, string>>;
13
14
  theme?: any;
14
15
  highestCompatibleVersion?: string;
16
+ customRPCS?: Partial<Record<ChainId, string[]>>;
15
17
  }
16
18
  export interface SDKProps {
17
19
  referenceId: string;
@@ -27,6 +29,7 @@ export interface SDKProps {
27
29
  urls: Record<URLKeys, string>;
28
30
  theme?: any;
29
31
  highestCompatibleVersion?: string;
32
+ customRPCS?: Partial<Record<ChainId, string[]>>;
30
33
  }
31
34
  export declare const useSDKConfig: (config?: SDKPropsDTO) => SDKProps;
32
35
  export type URLKeys = 'apiV2' | 'realTimeApi' | 'mainUrl' | 'priceApi';
@@ -1,6 +1,8 @@
1
1
  import { useQuery } from '@tanstack/react-query';
2
2
  import { QUERY_KEYS } from '../config/constants/queryKeys.js';
3
3
  import { ChainId } from '@ape.swap/apeswap-lists';
4
+ import { useEffect } from 'react';
5
+ import { setCustomRPCS } from '../config/constants/networks.js';
4
6
 
5
7
  // Prod URLS. Do not make changes here
6
8
  const defaultUrls = {
@@ -33,6 +35,11 @@ const useSDKConfig = (config) => {
33
35
  urls: { ...urls, ...config?.urls },
34
36
  highestCompatibleVersion: '2.1.3',
35
37
  };
38
+ useEffect(() => {
39
+ if (config?.customRPCS) {
40
+ setCustomRPCS(config.customRPCS);
41
+ }
42
+ }, [config?.customRPCS]);
36
43
  const { data } = useQuery({
37
44
  queryKey: [QUERY_KEYS.SDK_CONFIG],
38
45
  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 showLowValueBonds?: boolean\n bondPartner?: string\n namingPreference?: 'Discount' | 'Bonus'\n urls?: Partial<Record<URLKeys, string>>\n theme?: any\n highestCompatibleVersion?: 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}\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 ...config,\n urls: { ...urls, ...config?.urls },\n highestCompatibleVersion: '2.1.3',\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":";;;;AAIA;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;AAkCM,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,GAAG,MAAM;QACT,IAAI,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE;AAClC,QAAA,wBAAwB,EAAE,OAAO;KAClC;AACD,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;;;;"}
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'\nimport { useEffect } from 'react'\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 showLowValueBonds?: boolean\n bondPartner?: string\n namingPreference?: 'Discount' | 'Bonus'\n urls?: Partial<Record<URLKeys, string>>\n theme?: any\n highestCompatibleVersion?: 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 customRPCS?: Partial<Record<ChainId, 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 ...config,\n urls: { ...urls, ...config?.urls },\n highestCompatibleVersion: '2.1.3',\n }\n\n useEffect(() => {\n if (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 useURL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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;;;;"}
@@ -2,7 +2,7 @@ import { Interface } from '@ethersproject/abi';
2
2
  import multicallV2Abi from '../config/abi/multicallv2.json.js';
3
3
  import { ethers } from 'ethers';
4
4
  import { chunk, flatten } from 'lodash';
5
- import { PUBLIC_RPC_URLS } from '../config/constants/networks.js';
5
+ import { getRPC } from '../config/constants/networks.js';
6
6
  import { MULTICALL_V2 } from '../config/constants/addresses.js';
7
7
 
8
8
  // This is the legacy multicall
@@ -10,7 +10,7 @@ import { MULTICALL_V2 } from '../config/constants/addresses.js';
10
10
  const multicall = async (chainId, abi, calls, batch, batchSize) => {
11
11
  try {
12
12
  const multicallAddress = MULTICALL_V2[chainId];
13
- const provider = new ethers.providers.JsonRpcProvider(PUBLIC_RPC_URLS[chainId]?.[0], chainId);
13
+ const provider = new ethers.providers.JsonRpcProvider(getRPC(chainId), chainId);
14
14
  const multi = new ethers.Contract(multicallAddress, multicallV2Abi, provider);
15
15
  const itf = new Interface(abi);
16
16
  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, flatten } from 'lodash'\nimport { PUBLIC_RPC_URLS } 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 const multicallAddress = MULTICALL_V2[chainId]\n const provider = new ethers.providers.JsonRpcProvider(PUBLIC_RPC_URLS[chainId as ChainId]?.[0], 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":";;;;;;;AAcA;AACA;AACA,MAAM,SAAS,GAAG,OAAO,OAAe,EAAE,GAAU,EAAE,KAAa,EAAE,KAAe,EAAE,SAAkB,KAAI;AAC1G,IAAA,IAAI;AACF,QAAA,MAAM,gBAAgB,GAAG,YAAY,CAAC,OAAO,CAAC;QAC9C,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC,eAAe,CAAC,OAAkB,CAAC,GAAG,CAAC,CAAC,E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,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAChG;IACF;IAAE,OAAO,CAAC,EAAE;AACV,QAAA,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;AAChB,QAAA,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC;AACtB,QAAA,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;IACtB;AACF;;;;"}
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, flatten } from 'lodash'\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 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) {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AAC;AAC9G,YAAA,CAAC,CAAC;YACF,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC;AAClD,YAAA,MAAM,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC;AACzC,YAAA,OAAO,YAAY;QACrB;aAAO;YACL,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC;YACtD,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,IAAS,EAAE,CAAS,KAAK,GAAG,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAChG;IACF;IAAE,OAAO,CAAC,EAAE;AACV,QAAA,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;AAChB,QAAA,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC;AACtB,QAAA,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;IACtB;AACF;;;;"}
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Ape Bond SDK",
4
4
  "author": "Ape Bond",
5
5
  "license": "MIT",
6
- "version": "3.1.9-test.6",
6
+ "version": "3.2.0",
7
7
  "module": "dist/main.js",
8
8
  "type": "module",
9
9
  "types": "dist/main.d.ts",