@basedone/core 0.1.8 → 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.
- package/dist/chunk-4GAKANLT.mjs +1987 -0
- package/dist/chunk-4UEJOM6W.mjs +1 -3
- package/dist/chunk-VBC6EQ7Q.mjs +235 -0
- package/dist/client-CgmiTuEX.d.mts +179 -0
- package/dist/client-CgmiTuEX.d.ts +179 -0
- package/dist/ecommerce.d.mts +3732 -0
- package/dist/ecommerce.d.ts +3732 -0
- package/dist/ecommerce.js +2031 -0
- package/dist/ecommerce.mjs +2 -0
- package/dist/index.d.mts +79 -4
- package/dist/index.d.ts +79 -4
- package/dist/index.js +3674 -331
- package/dist/index.mjs +107 -104
- package/dist/{meta-57AY44US.mjs → meta-JB5ITE27.mjs} +6 -14
- package/dist/{meta-RSZFFH63.mjs → meta-UOGUG3OW.mjs} +5 -11
- package/dist/{perpDexs-PBKWKKQU.mjs → perpDexs-3LRJ5ZHM.mjs} +100 -13
- package/dist/{perpDexs-XSB4Y2BP.mjs → perpDexs-4ISLD7NX.mjs} +798 -121
- package/dist/react.d.mts +39 -0
- package/dist/react.d.ts +39 -0
- package/dist/react.js +268 -0
- package/dist/react.mjs +31 -0
- package/dist/{spotMeta-WQ4PXRNY.mjs → spotMeta-GHXX7C5M.mjs} +85 -14
- package/dist/{spotMeta-Y7G2GI7B.mjs → spotMeta-IBBUP2SG.mjs} +249 -12
- package/dist/staticMeta-GM7T3OYL.mjs +3 -6
- package/dist/staticMeta-QV2KMX57.mjs +3 -6
- package/ecommerce.ts +15 -0
- package/index.ts +7 -0
- package/lib/cloid/cloid.ts +2 -0
- package/lib/ecommerce/QUICK_REFERENCE.md +211 -0
- package/lib/ecommerce/README.md +385 -0
- package/lib/ecommerce/USAGE_EXAMPLES.md +704 -0
- package/lib/ecommerce/client/base.ts +272 -0
- package/lib/ecommerce/client/customer.ts +522 -0
- package/lib/ecommerce/client/merchant.ts +1341 -0
- package/lib/ecommerce/index.ts +51 -0
- package/lib/ecommerce/types/entities.ts +722 -0
- package/lib/ecommerce/types/enums.ts +270 -0
- package/lib/ecommerce/types/index.ts +18 -0
- package/lib/ecommerce/types/requests.ts +525 -0
- package/lib/ecommerce/types/responses.ts +805 -0
- package/lib/ecommerce/utils/errors.ts +113 -0
- package/lib/ecommerce/utils/helpers.ts +131 -0
- package/lib/fee.ts +10 -10
- package/lib/hip3/market-info.ts +36 -8
- package/lib/hip3/utils.ts +15 -2
- package/lib/instrument/client.ts +351 -0
- package/lib/meta/data/mainnet/meta.json +2 -4
- package/lib/meta/data/mainnet/perpDexs.json +97 -9
- package/lib/meta/data/mainnet/spotMeta.json +82 -8
- package/lib/meta/data/testnet/meta.json +3 -7
- package/lib/meta/data/testnet/perpDexs.json +795 -117
- package/lib/meta/data/testnet/spotMeta.json +246 -6
- package/lib/meta/metadata.ts +8 -1
- package/lib/meta/types.ts +36 -0
- package/lib/react/InstrumentProvider.tsx +69 -0
- package/lib/utils/flooredDateTime.ts +55 -0
- package/lib/utils/time.ts +51 -0
- package/package.json +37 -11
- package/react.ts +1 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import './chunk-4UEJOM6W.mjs';
|
|
2
2
|
|
|
3
3
|
// lib/meta/data/testnet/spotMeta.json
|
|
4
4
|
var universe = [
|
|
@@ -10549,6 +10549,123 @@ var universe = [
|
|
|
10549
10549
|
name: "@1366",
|
|
10550
10550
|
index: 1366,
|
|
10551
10551
|
isCanonical: false
|
|
10552
|
+
},
|
|
10553
|
+
{
|
|
10554
|
+
tokens: [
|
|
10555
|
+
1487,
|
|
10556
|
+
0
|
|
10557
|
+
],
|
|
10558
|
+
name: "@1368",
|
|
10559
|
+
index: 1368,
|
|
10560
|
+
isCanonical: false
|
|
10561
|
+
},
|
|
10562
|
+
{
|
|
10563
|
+
tokens: [
|
|
10564
|
+
1485,
|
|
10565
|
+
0
|
|
10566
|
+
],
|
|
10567
|
+
name: "@1369",
|
|
10568
|
+
index: 1369,
|
|
10569
|
+
isCanonical: false
|
|
10570
|
+
},
|
|
10571
|
+
{
|
|
10572
|
+
tokens: [
|
|
10573
|
+
1490,
|
|
10574
|
+
0
|
|
10575
|
+
],
|
|
10576
|
+
name: "@1370",
|
|
10577
|
+
index: 1370,
|
|
10578
|
+
isCanonical: false
|
|
10579
|
+
},
|
|
10580
|
+
{
|
|
10581
|
+
tokens: [
|
|
10582
|
+
1481,
|
|
10583
|
+
0
|
|
10584
|
+
],
|
|
10585
|
+
name: "@1371",
|
|
10586
|
+
index: 1371,
|
|
10587
|
+
isCanonical: false
|
|
10588
|
+
},
|
|
10589
|
+
{
|
|
10590
|
+
tokens: [
|
|
10591
|
+
1484,
|
|
10592
|
+
0
|
|
10593
|
+
],
|
|
10594
|
+
name: "@1372",
|
|
10595
|
+
index: 1372,
|
|
10596
|
+
isCanonical: false
|
|
10597
|
+
},
|
|
10598
|
+
{
|
|
10599
|
+
tokens: [
|
|
10600
|
+
1477,
|
|
10601
|
+
1452
|
|
10602
|
+
],
|
|
10603
|
+
name: "@1373",
|
|
10604
|
+
index: 1373,
|
|
10605
|
+
isCanonical: false
|
|
10606
|
+
},
|
|
10607
|
+
{
|
|
10608
|
+
tokens: [
|
|
10609
|
+
1492,
|
|
10610
|
+
0
|
|
10611
|
+
],
|
|
10612
|
+
name: "@1374",
|
|
10613
|
+
index: 1374,
|
|
10614
|
+
isCanonical: false
|
|
10615
|
+
},
|
|
10616
|
+
{
|
|
10617
|
+
tokens: [
|
|
10618
|
+
1469,
|
|
10619
|
+
0
|
|
10620
|
+
],
|
|
10621
|
+
name: "@1375",
|
|
10622
|
+
index: 1375,
|
|
10623
|
+
isCanonical: false
|
|
10624
|
+
},
|
|
10625
|
+
{
|
|
10626
|
+
tokens: [
|
|
10627
|
+
1,
|
|
10628
|
+
1295
|
|
10629
|
+
],
|
|
10630
|
+
name: "@1376",
|
|
10631
|
+
index: 1376,
|
|
10632
|
+
isCanonical: true
|
|
10633
|
+
},
|
|
10634
|
+
{
|
|
10635
|
+
tokens: [
|
|
10636
|
+
1493,
|
|
10637
|
+
0
|
|
10638
|
+
],
|
|
10639
|
+
name: "@1377",
|
|
10640
|
+
index: 1377,
|
|
10641
|
+
isCanonical: false
|
|
10642
|
+
},
|
|
10643
|
+
{
|
|
10644
|
+
tokens: [
|
|
10645
|
+
1105,
|
|
10646
|
+
1493
|
|
10647
|
+
],
|
|
10648
|
+
name: "@1378",
|
|
10649
|
+
index: 1378,
|
|
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
|
|
10552
10669
|
}
|
|
10553
10670
|
];
|
|
10554
10671
|
var tokens = [
|
|
@@ -27092,7 +27209,10 @@ aa aaa\\aaaaaa"aaaa'aaaaa{}`,
|
|
|
27092
27209
|
index: 1469,
|
|
27093
27210
|
tokenId: "0x8e670650571a3ce604ece184eaaf01c0",
|
|
27094
27211
|
isCanonical: false,
|
|
27095
|
-
evmContract:
|
|
27212
|
+
evmContract: {
|
|
27213
|
+
address: "0x03d7cd2d64de683e07f24fd857367d7492c85b22",
|
|
27214
|
+
evm_extra_wei_decimals: 10
|
|
27215
|
+
},
|
|
27096
27216
|
fullName: null,
|
|
27097
27217
|
deployerTradingFeeShare: "1.0"
|
|
27098
27218
|
},
|
|
@@ -27248,7 +27368,10 @@ aa aaa\\aaaaaa"aaaa'aaaaa{}`,
|
|
|
27248
27368
|
index: 1481,
|
|
27249
27369
|
tokenId: "0x21a4632b44112fe0593fccbe5400a701",
|
|
27250
27370
|
isCanonical: false,
|
|
27251
|
-
evmContract:
|
|
27371
|
+
evmContract: {
|
|
27372
|
+
address: "0xed40d1ab429ff92ad66935766fb0f7025125b520",
|
|
27373
|
+
evm_extra_wei_decimals: 4
|
|
27374
|
+
},
|
|
27252
27375
|
fullName: null,
|
|
27253
27376
|
deployerTradingFeeShare: "1.0"
|
|
27254
27377
|
},
|
|
@@ -27284,7 +27407,10 @@ aa aaa\\aaaaaa"aaaa'aaaaa{}`,
|
|
|
27284
27407
|
index: 1484,
|
|
27285
27408
|
tokenId: "0x57df584e21097424d758b228e842d2ef",
|
|
27286
27409
|
isCanonical: false,
|
|
27287
|
-
evmContract:
|
|
27410
|
+
evmContract: {
|
|
27411
|
+
address: "0xe04532bd84a7ee59599a90512a8fcc8484b546b5",
|
|
27412
|
+
evm_extra_wei_decimals: 10
|
|
27413
|
+
},
|
|
27288
27414
|
fullName: null,
|
|
27289
27415
|
deployerTradingFeeShare: "1.0"
|
|
27290
27416
|
},
|
|
@@ -27295,7 +27421,10 @@ aa aaa\\aaaaaa"aaaa'aaaaa{}`,
|
|
|
27295
27421
|
index: 1485,
|
|
27296
27422
|
tokenId: "0x797f444bb03c7be19234b94ca29f3410",
|
|
27297
27423
|
isCanonical: false,
|
|
27298
|
-
evmContract:
|
|
27424
|
+
evmContract: {
|
|
27425
|
+
address: "0x2af50e43e313cfab0e7f46ac95106991cd9baea8",
|
|
27426
|
+
evm_extra_wei_decimals: 10
|
|
27427
|
+
},
|
|
27299
27428
|
fullName: "STABLE",
|
|
27300
27429
|
deployerTradingFeeShare: "1.0"
|
|
27301
27430
|
},
|
|
@@ -27317,7 +27446,10 @@ aa aaa\\aaaaaa"aaaa'aaaaa{}`,
|
|
|
27317
27446
|
index: 1487,
|
|
27318
27447
|
tokenId: "0xd55b27dcaed90223bfc3c378b98526bb",
|
|
27319
27448
|
isCanonical: false,
|
|
27320
|
-
evmContract:
|
|
27449
|
+
evmContract: {
|
|
27450
|
+
address: "0xed3eb348853a670e3bb692dd5e654ad51c2f5128",
|
|
27451
|
+
evm_extra_wei_decimals: 10
|
|
27452
|
+
},
|
|
27321
27453
|
fullName: "MONARCH TEST 1",
|
|
27322
27454
|
deployerTradingFeeShare: "1.0"
|
|
27323
27455
|
},
|
|
@@ -27339,17 +27471,122 @@ aa aaa\\aaaaaa"aaaa'aaaaa{}`,
|
|
|
27339
27471
|
index: 1489,
|
|
27340
27472
|
tokenId: "0x398e2bab402c7f3c9e214d3862d02ada",
|
|
27341
27473
|
isCanonical: false,
|
|
27342
|
-
evmContract:
|
|
27474
|
+
evmContract: {
|
|
27475
|
+
address: "0x000000000000780555bd0bca3791f89f9542c2d6",
|
|
27476
|
+
evm_extra_wei_decimals: 10
|
|
27477
|
+
},
|
|
27343
27478
|
fullName: "They HYPE beta",
|
|
27344
27479
|
deployerTradingFeeShare: "1.0"
|
|
27480
|
+
},
|
|
27481
|
+
{
|
|
27482
|
+
name: "PP",
|
|
27483
|
+
szDecimals: 2,
|
|
27484
|
+
weiDecimals: 8,
|
|
27485
|
+
index: 1490,
|
|
27486
|
+
tokenId: "0xc7a956f1c1174545c713707d2ca67b76",
|
|
27487
|
+
isCanonical: false,
|
|
27488
|
+
evmContract: {
|
|
27489
|
+
address: "0x1fc9929be618ede69b1f71a69440165c885acadc",
|
|
27490
|
+
evm_extra_wei_decimals: 10
|
|
27491
|
+
},
|
|
27492
|
+
fullName: "smol pp",
|
|
27493
|
+
deployerTradingFeeShare: "1.0"
|
|
27494
|
+
},
|
|
27495
|
+
{
|
|
27496
|
+
name: "SLIM",
|
|
27497
|
+
szDecimals: 2,
|
|
27498
|
+
weiDecimals: 8,
|
|
27499
|
+
index: 1491,
|
|
27500
|
+
tokenId: "0x45754dd4d3bb5517fa92dbbe8ccb6392",
|
|
27501
|
+
isCanonical: false,
|
|
27502
|
+
evmContract: {
|
|
27503
|
+
address: "0x719d4dee0fbefebbfbc837b2347840684b891916",
|
|
27504
|
+
evm_extra_wei_decimals: 10
|
|
27505
|
+
},
|
|
27506
|
+
fullName: "The Real Slim Shady",
|
|
27507
|
+
deployerTradingFeeShare: "1.0"
|
|
27508
|
+
},
|
|
27509
|
+
{
|
|
27510
|
+
name: "USDZ",
|
|
27511
|
+
szDecimals: 2,
|
|
27512
|
+
weiDecimals: 8,
|
|
27513
|
+
index: 1492,
|
|
27514
|
+
tokenId: "0x7f8d334fed99e32ccc7d1ef50af5f246",
|
|
27515
|
+
isCanonical: false,
|
|
27516
|
+
evmContract: null,
|
|
27517
|
+
fullName: "Z Test Token",
|
|
27518
|
+
deployerTradingFeeShare: "1.0"
|
|
27519
|
+
},
|
|
27520
|
+
{
|
|
27521
|
+
name: "TUSDC",
|
|
27522
|
+
szDecimals: 2,
|
|
27523
|
+
weiDecimals: 8,
|
|
27524
|
+
index: 1493,
|
|
27525
|
+
tokenId: "0xa8469cf6df9c92f729a4bfa0f3643479",
|
|
27526
|
+
isCanonical: false,
|
|
27527
|
+
evmContract: null,
|
|
27528
|
+
fullName: "USDC Coin",
|
|
27529
|
+
deployerTradingFeeShare: "0.0"
|
|
27530
|
+
},
|
|
27531
|
+
{
|
|
27532
|
+
name: "MQVMJW",
|
|
27533
|
+
szDecimals: 1,
|
|
27534
|
+
weiDecimals: 9,
|
|
27535
|
+
index: 1494,
|
|
27536
|
+
tokenId: "0x202ec473e3100aac31d517c0a673ceaf",
|
|
27537
|
+
isCanonical: false,
|
|
27538
|
+
evmContract: null,
|
|
27539
|
+
fullName: "$WASH launchpad 2025-12-01T19:17:15.851Z",
|
|
27540
|
+
deployerTradingFeeShare: "1.0"
|
|
27541
|
+
},
|
|
27542
|
+
{
|
|
27543
|
+
name: "TSQEBL",
|
|
27544
|
+
szDecimals: 1,
|
|
27545
|
+
weiDecimals: 10,
|
|
27546
|
+
index: 1495,
|
|
27547
|
+
tokenId: "0x5d05f06a9590464cf3555a30d2d8ffd4",
|
|
27548
|
+
isCanonical: false,
|
|
27549
|
+
evmContract: null,
|
|
27550
|
+
fullName: "$WASH launchpad 2025-12-02T20:17:18.214Z",
|
|
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"
|
|
27345
27585
|
}
|
|
27346
27586
|
];
|
|
27347
27587
|
var spotMeta_default = {
|
|
27348
27588
|
universe,
|
|
27349
27589
|
tokens
|
|
27350
27590
|
};
|
|
27351
|
-
|
|
27352
|
-
|
|
27353
|
-
tokens,
|
|
27354
|
-
universe
|
|
27355
|
-
};
|
|
27591
|
+
|
|
27592
|
+
export { spotMeta_default as default, tokens, universe };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
staticMeta_default as default,
|
|
22
|
-
dexs
|
|
23
|
-
};
|
|
19
|
+
|
|
20
|
+
export { coins, staticMeta_default as default, dexs };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
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
|
-
|
|
22
|
-
|
|
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,4 +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";
|
|
10
|
+
export * from "./lib/hip3/market-info";
|
|
11
|
+
export * from "./lib/instrument/client";
|
|
12
|
+
|
|
13
|
+
// Ecommerce SDK
|
|
14
|
+
export * from "./lib/ecommerce";
|
package/lib/cloid/cloid.ts
CHANGED
|
@@ -256,6 +256,7 @@ export const CloidClientCode = {
|
|
|
256
256
|
Desktop: 7,
|
|
257
257
|
API: 8,
|
|
258
258
|
Stream: 9,
|
|
259
|
+
Pal: 10,
|
|
259
260
|
} as const;
|
|
260
261
|
type ClientCodeType = keyof typeof CloidClientCode;
|
|
261
262
|
|
|
@@ -272,6 +273,7 @@ export const CloidClientCodeNameById: Record<number, ClientCodeType> = {
|
|
|
272
273
|
[CloidClientCode.Desktop]: "Desktop",
|
|
273
274
|
[CloidClientCode.API]: "API",
|
|
274
275
|
[CloidClientCode.Stream]: "Stream",
|
|
276
|
+
[CloidClientCode.Pal]: "Pal",
|
|
275
277
|
};
|
|
276
278
|
|
|
277
279
|
export function getClientCodeNameById(id: number): string {
|
|
@@ -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
|
+
|