@basedone/core 0.1.10 → 0.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.
Files changed (53) hide show
  1. package/dist/chunk-4GAKANLT.mjs +1987 -0
  2. package/dist/chunk-4UEJOM6W.mjs +1 -3
  3. package/dist/chunk-VBC6EQ7Q.mjs +235 -0
  4. package/dist/client-CgmiTuEX.d.mts +179 -0
  5. package/dist/client-CgmiTuEX.d.ts +179 -0
  6. package/dist/ecommerce.d.mts +3732 -0
  7. package/dist/ecommerce.d.ts +3732 -0
  8. package/dist/ecommerce.js +2031 -0
  9. package/dist/ecommerce.mjs +2 -0
  10. package/dist/index.d.mts +51 -43
  11. package/dist/index.d.ts +51 -43
  12. package/dist/index.js +2691 -205
  13. package/dist/index.mjs +68 -90
  14. package/dist/{meta-FVJIMALT.mjs → meta-JB5ITE27.mjs} +4 -10
  15. package/dist/meta-UOGUG3OW.mjs +3 -7
  16. package/dist/{perpDexs-GGL32HT4.mjs → perpDexs-3LRJ5ZHM.mjs} +37 -8
  17. package/dist/{perpDexs-G7V2QIM6.mjs → perpDexs-4ISLD7NX.mjs} +177 -32
  18. package/dist/react.d.mts +39 -0
  19. package/dist/react.d.ts +39 -0
  20. package/dist/react.js +268 -0
  21. package/dist/react.mjs +31 -0
  22. package/dist/{spotMeta-OD7S6HGW.mjs → spotMeta-GHXX7C5M.mjs} +24 -9
  23. package/dist/{spotMeta-PCN4Z4R3.mjs → spotMeta-IBBUP2SG.mjs} +54 -6
  24. package/dist/staticMeta-GM7T3OYL.mjs +3 -6
  25. package/dist/staticMeta-QV2KMX57.mjs +3 -6
  26. package/ecommerce.ts +15 -0
  27. package/index.ts +6 -0
  28. package/lib/ecommerce/QUICK_REFERENCE.md +211 -0
  29. package/lib/ecommerce/README.md +385 -0
  30. package/lib/ecommerce/USAGE_EXAMPLES.md +704 -0
  31. package/lib/ecommerce/client/base.ts +272 -0
  32. package/lib/ecommerce/client/customer.ts +522 -0
  33. package/lib/ecommerce/client/merchant.ts +1341 -0
  34. package/lib/ecommerce/index.ts +51 -0
  35. package/lib/ecommerce/types/entities.ts +722 -0
  36. package/lib/ecommerce/types/enums.ts +270 -0
  37. package/lib/ecommerce/types/index.ts +18 -0
  38. package/lib/ecommerce/types/requests.ts +525 -0
  39. package/lib/ecommerce/types/responses.ts +805 -0
  40. package/lib/ecommerce/utils/errors.ts +113 -0
  41. package/lib/ecommerce/utils/helpers.ts +131 -0
  42. package/lib/hip3/market-info.ts +1 -1
  43. package/lib/instrument/client.ts +351 -0
  44. package/lib/meta/data/mainnet/perpDexs.json +34 -4
  45. package/lib/meta/data/mainnet/spotMeta.json +21 -3
  46. package/lib/meta/data/testnet/meta.json +1 -3
  47. package/lib/meta/data/testnet/perpDexs.json +174 -28
  48. package/lib/meta/data/testnet/spotMeta.json +51 -0
  49. package/lib/react/InstrumentProvider.tsx +69 -0
  50. package/lib/utils/flooredDateTime.ts +55 -0
  51. package/lib/utils/time.ts +51 -0
  52. package/package.json +37 -11
  53. package/react.ts +1 -0
package/dist/react.mjs ADDED
@@ -0,0 +1,31 @@
1
+ import { InstrumentClient } from './chunk-VBC6EQ7Q.mjs';
2
+ import './chunk-4UEJOM6W.mjs';
3
+ import { createContext, useMemo, useContext } from 'react';
4
+ import { jsx } from 'react/jsx-runtime';
5
+
6
+ var InstrumentContext = createContext(null);
7
+ function InstrumentsProvider({
8
+ spotMeta,
9
+ allPerpsMeta,
10
+ children
11
+ }) {
12
+ const client = useMemo(
13
+ () => new InstrumentClient(spotMeta, allPerpsMeta).init(),
14
+ [spotMeta, allPerpsMeta]
15
+ );
16
+ return /* @__PURE__ */ jsx(InstrumentContext.Provider, { value: client, children });
17
+ }
18
+ function useInstruments() {
19
+ const client = useContext(InstrumentContext);
20
+ if (!client) {
21
+ throw new Error(
22
+ "useInstruments must be used within an InstrumentsProvider"
23
+ );
24
+ }
25
+ return client;
26
+ }
27
+ function useInstrumentsOptional() {
28
+ return useContext(InstrumentContext);
29
+ }
30
+
31
+ export { InstrumentsProvider, useInstruments, useInstrumentsOptional };
@@ -1,4 +1,4 @@
1
- import "./chunk-4UEJOM6W.mjs";
1
+ import './chunk-4UEJOM6W.mjs';
2
2
 
3
3
  // lib/meta/data/mainnet/spotMeta.json
4
4
  var universe = [
@@ -2179,6 +2179,15 @@ var universe = [
2179
2179
  name: "@257",
2180
2180
  index: 257,
2181
2181
  isCanonical: false
2182
+ },
2183
+ {
2184
+ tokens: [
2185
+ 398,
2186
+ 0
2187
+ ],
2188
+ name: "@258",
2189
+ index: 258,
2190
+ isCanonical: false
2182
2191
  }
2183
2192
  ];
2184
2193
  var tokens = [
@@ -2189,7 +2198,10 @@ var tokens = [
2189
2198
  index: 0,
2190
2199
  tokenId: "0x6d1e7cde53ba9467b783cb7c530ce054",
2191
2200
  isCanonical: true,
2192
- evmContract: null,
2201
+ evmContract: {
2202
+ address: "0x6b9e773128f453f5c2c60935ee2de2cbc5390a24",
2203
+ evm_extra_wei_decimals: -2
2204
+ },
2193
2205
  fullName: null,
2194
2206
  deployerTradingFeeShare: "0.0"
2195
2207
  },
@@ -6683,7 +6695,10 @@ var tokens = [
6683
6695
  index: 381,
6684
6696
  tokenId: "0xbd6af8c18f3e56d2da95a3c81d18e814",
6685
6697
  isCanonical: false,
6686
- evmContract: null,
6698
+ evmContract: {
6699
+ address: "0x99603f5cb890faca5cc5495ccc74391cdffa28bc",
6700
+ evm_extra_wei_decimals: 10
6701
+ },
6687
6702
  fullName: "Funnel BNB",
6688
6703
  deployerTradingFeeShare: "1.0"
6689
6704
  },
@@ -6882,7 +6897,10 @@ var tokens = [
6882
6897
  index: 398,
6883
6898
  tokenId: "0xec43194f64d555bdaef5afb5b6c6c686",
6884
6899
  isCanonical: false,
6885
- evmContract: null,
6900
+ evmContract: {
6901
+ address: "0xa51dc81944a15623874981181a99d6c56b20ed56",
6902
+ evm_extra_wei_decimals: 11
6903
+ },
6886
6904
  fullName: "Stable",
6887
6905
  deployerTradingFeeShare: "1.0"
6888
6906
  },
@@ -6946,8 +6964,5 @@ var spotMeta_default = {
6946
6964
  universe,
6947
6965
  tokens
6948
6966
  };
6949
- export {
6950
- spotMeta_default as default,
6951
- tokens,
6952
- universe
6953
- };
6967
+
6968
+ export { spotMeta_default as default, tokens, universe };
@@ -1,4 +1,4 @@
1
- import "./chunk-4UEJOM6W.mjs";
1
+ import './chunk-4UEJOM6W.mjs';
2
2
 
3
3
  // lib/meta/data/testnet/spotMeta.json
4
4
  var universe = [
@@ -10648,6 +10648,24 @@ var universe = [
10648
10648
  name: "@1378",
10649
10649
  index: 1378,
10650
10650
  isCanonical: false
10651
+ },
10652
+ {
10653
+ tokens: [
10654
+ 1498,
10655
+ 0
10656
+ ],
10657
+ name: "@1379",
10658
+ index: 1379,
10659
+ isCanonical: false
10660
+ },
10661
+ {
10662
+ tokens: [
10663
+ 1498,
10664
+ 1452
10665
+ ],
10666
+ name: "@1380",
10667
+ index: 1380,
10668
+ isCanonical: false
10651
10669
  }
10652
10670
  ];
10653
10671
  var tokens = [
@@ -27531,14 +27549,44 @@ aa aaa\\aaaaaa"aaaa'aaaaa{}`,
27531
27549
  evmContract: null,
27532
27550
  fullName: "$WASH launchpad 2025-12-02T20:17:18.214Z",
27533
27551
  deployerTradingFeeShare: "1.0"
27552
+ },
27553
+ {
27554
+ name: "RNSZPK",
27555
+ szDecimals: 0,
27556
+ weiDecimals: 10,
27557
+ index: 1496,
27558
+ tokenId: "0x699de51e4fc0e6d7a6e450d2c3d92a1a",
27559
+ isCanonical: false,
27560
+ evmContract: null,
27561
+ fullName: "$WASH launchpad 2025-12-04T03:17:21.132Z",
27562
+ deployerTradingFeeShare: "1.0"
27563
+ },
27564
+ {
27565
+ name: "VENAHX",
27566
+ szDecimals: 1,
27567
+ weiDecimals: 9,
27568
+ index: 1497,
27569
+ tokenId: "0x43513901b952fcb6d8d5697ce17fa58f",
27570
+ isCanonical: false,
27571
+ evmContract: null,
27572
+ fullName: "$WASH launchpad 2025-12-05T10:17:24.096Z",
27573
+ deployerTradingFeeShare: "1.0"
27574
+ },
27575
+ {
27576
+ name: "LMB",
27577
+ szDecimals: 2,
27578
+ weiDecimals: 8,
27579
+ index: 1498,
27580
+ tokenId: "0x9f416264220c915ec41b6c4c0b11fab1",
27581
+ isCanonical: false,
27582
+ evmContract: null,
27583
+ fullName: "LMB",
27584
+ deployerTradingFeeShare: "1.0"
27534
27585
  }
27535
27586
  ];
27536
27587
  var spotMeta_default = {
27537
27588
  universe,
27538
27589
  tokens
27539
27590
  };
27540
- export {
27541
- spotMeta_default as default,
27542
- tokens,
27543
- universe
27544
- };
27591
+
27592
+ export { spotMeta_default as default, tokens, universe };
@@ -1,4 +1,4 @@
1
- import "./chunk-4UEJOM6W.mjs";
1
+ import './chunk-4UEJOM6W.mjs';
2
2
 
3
3
  // lib/meta/data/testnet/staticMeta.json
4
4
  var coins = {
@@ -16,8 +16,5 @@ var staticMeta_default = {
16
16
  coins,
17
17
  dexs
18
18
  };
19
- export {
20
- coins,
21
- staticMeta_default as default,
22
- dexs
23
- };
19
+
20
+ export { coins, staticMeta_default as default, dexs };
@@ -1,4 +1,4 @@
1
- import "./chunk-4UEJOM6W.mjs";
1
+ import './chunk-4UEJOM6W.mjs';
2
2
 
3
3
  // lib/meta/data/mainnet/staticMeta.json
4
4
  var coins = {
@@ -18,8 +18,5 @@ var staticMeta_default = {
18
18
  coins,
19
19
  dexs
20
20
  };
21
- export {
22
- coins,
23
- staticMeta_default as default,
24
- dexs
25
- };
21
+
22
+ export { coins, staticMeta_default as default, dexs };
package/ecommerce.ts ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Ecommerce SDK Entry Point
3
+ *
4
+ * This file provides a separate entry point for the ecommerce SDK,
5
+ * allowing users to import only ecommerce functionality without
6
+ * pulling in the entire @basedone/core package.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { CustomerEcommerceClient } from "@basedone/core/ecommerce";
11
+ * ```
12
+ */
13
+
14
+ export * from "./lib/ecommerce";
15
+
package/index.ts CHANGED
@@ -4,5 +4,11 @@ export * from "./lib/pup";
4
4
  export * from "./lib/constants/tokens";
5
5
  export * from "./lib/meta/metadata";
6
6
  export * from "./lib/utils/formatter";
7
+ export * from "./lib/utils/flooredDateTime";
8
+ export * from "./lib/utils/time";
7
9
  export * from "./lib/hip3/utils";
8
10
  export * from "./lib/hip3/market-info";
11
+ export * from "./lib/instrument/client";
12
+
13
+ // Ecommerce SDK
14
+ export * from "./lib/ecommerce";
@@ -0,0 +1,211 @@
1
+ # Ecommerce SDK Quick Reference
2
+
3
+ Quick reference guide for the most commonly used API methods.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @basedone/core
9
+ ```
10
+
11
+ ## Import
12
+
13
+ ```typescript
14
+ import { CustomerEcommerceClient, MerchantEcommerceClient } from "@basedone/core/ecommerce";
15
+ ```
16
+
17
+ ## Customer Client
18
+
19
+ ### Initialize
20
+
21
+ ```typescript
22
+ const client = new CustomerEcommerceClient({
23
+ baseURL: "https://api.basedone.com",
24
+ authToken: "user-token",
25
+ });
26
+ ```
27
+
28
+ ### Common Operations
29
+
30
+ ```typescript
31
+ // Browse products
32
+ const products = await client.listProducts({ limit: 20, category: "electronics" });
33
+
34
+ // Get product details
35
+ const product = await client.getProduct("prod_123");
36
+
37
+ // Place order
38
+ const order = await client.createOrder({
39
+ items: [{ productId: "prod_123", quantity: 2 }],
40
+ paymentMethod: "USDC_ESCROW",
41
+ shippingAddress: { /* ... */ },
42
+ });
43
+
44
+ // Confirm payment
45
+ await client.confirmEscrowDeposit("ord_123");
46
+
47
+ // List orders
48
+ const orders = await client.listOrders({ limit: 10 });
49
+
50
+ // Get order details
51
+ const orderDetails = await client.getOrder("ord_123");
52
+
53
+ // Create review
54
+ await client.createReview("prod_123", {
55
+ rating: 5,
56
+ title: "Great!",
57
+ comment: "Love it!",
58
+ });
59
+
60
+ // Calculate discounts
61
+ const discounts = await client.calculateCartDiscounts({
62
+ items: [{ productId: "prod_123", quantity: 2 }],
63
+ });
64
+
65
+ // Calculate tax
66
+ const tax = await client.calculateTax({
67
+ items: [{ productId: "prod_123", quantity: 2 }],
68
+ shippingAddress: { country: "US", region: "NY" },
69
+ });
70
+ ```
71
+
72
+ ## Merchant Client
73
+
74
+ ### Initialize
75
+
76
+ ```typescript
77
+ const client = new MerchantEcommerceClient({
78
+ baseURL: "https://api.basedone.com",
79
+ authToken: "merchant-token",
80
+ });
81
+ ```
82
+
83
+ ### Common Operations
84
+
85
+ ```typescript
86
+ // Create product
87
+ const product = await client.createProduct({
88
+ title: "Product Name",
89
+ images: ["https://..."],
90
+ priceUSDC: 99.99,
91
+ inventory: 100,
92
+ });
93
+
94
+ // Update product
95
+ await client.updateProduct("prod_123", { priceUSDC: 89.99 });
96
+
97
+ // List orders
98
+ const orders = await client.listMerchantOrders({ limit: 20 });
99
+
100
+ // Update order status
101
+ await client.updateOrderStatus("ord_123", {
102
+ status: "SHIPPED",
103
+ tracking: { trackingNumber: "123", carrier: "UPS" },
104
+ });
105
+
106
+ // Get analytics
107
+ const analytics = await client.getAnalytics({ range: "30days" });
108
+
109
+ // List customers
110
+ const customers = await client.listCustomers({ limit: 100 });
111
+
112
+ // Create coupon
113
+ await client.createCoupon({
114
+ code: "SAVE20",
115
+ discountType: "PERCENTAGE",
116
+ discountValue: 20,
117
+ startsAt: "2025-01-01T00:00:00Z",
118
+ expiresAt: "2025-12-31T23:59:59Z",
119
+ });
120
+
121
+ // Upload image
122
+ const formData = new FormData();
123
+ formData.append("file", imageFile);
124
+ const asset = await client.uploadMediaAsset(formData);
125
+
126
+ // Generate tax report
127
+ const report = await client.generateTaxReport({
128
+ periodType: "MONTHLY",
129
+ year: 2025,
130
+ period: 1,
131
+ });
132
+ ```
133
+
134
+ ## Error Handling
135
+
136
+ ```typescript
137
+ import { EcommerceApiError } from "@basedone/core/ecommerce";
138
+
139
+ try {
140
+ const products = await client.listProducts();
141
+ } catch (error) {
142
+ if (error instanceof EcommerceApiError) {
143
+ if (error.isAuthError) {
144
+ // Handle auth error
145
+ } else if (error.isNetworkError) {
146
+ // Handle network error
147
+ } else if (error.isTimeoutError) {
148
+ // Handle timeout
149
+ }
150
+ }
151
+ }
152
+ ```
153
+
154
+ ## Configuration
155
+
156
+ ```typescript
157
+ const client = new CustomerEcommerceClient({
158
+ baseURL: "https://api.basedone.com",
159
+ authToken: "token",
160
+ timeout: 30000, // 30 seconds
161
+ maxRetries: 3, // Retry 3 times
162
+ retryBaseDelay: 1000, // 1 second base delay
163
+ enableRetry: true, // Enable automatic retry
164
+ headers: { // Custom headers
165
+ "X-App-Version": "1.0.0",
166
+ },
167
+ });
168
+ ```
169
+
170
+ ## React Native
171
+
172
+ ```typescript
173
+ import { CustomerEcommerceClient } from "@basedone/core/ecommerce";
174
+ import AsyncStorage from "@react-native-async-storage/async-storage";
175
+
176
+ const authToken = await AsyncStorage.getItem("authToken");
177
+
178
+ const client = new CustomerEcommerceClient({
179
+ baseURL: "https://api.basedone.com",
180
+ authToken,
181
+ });
182
+
183
+ // Use in components
184
+ const [products, setProducts] = useState([]);
185
+
186
+ useEffect(() => {
187
+ client.listProducts({ limit: 20 }).then(result => {
188
+ setProducts(result.items);
189
+ });
190
+ }, []);
191
+ ```
192
+
193
+ ## TypeScript Types
194
+
195
+ ```typescript
196
+ import type {
197
+ Product,
198
+ Order,
199
+ OrderStatus,
200
+ PaymentMethod,
201
+ CreateOrderRequest,
202
+ ListProductsParams,
203
+ } from "@basedone/core/ecommerce";
204
+ ```
205
+
206
+ ## Documentation
207
+
208
+ - Full API Reference: `lib/ecommerce/README.md`
209
+ - Usage Examples: `lib/ecommerce/USAGE_EXAMPLES.md`
210
+ - API Endpoints: `ECOMMERCE_API_ENDPOINTS.md`
211
+