@decibeltrade/sdk 0.2.6 → 0.2.8

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 (66) hide show
  1. package/package.json +7 -1
  2. package/.github/workflows/npm_publish.yml +0 -26
  3. package/eslint.config.mjs +0 -25
  4. package/src/abi/generate-abis.ts +0 -164
  5. package/src/abi/json/netna.json +0 -1325
  6. package/src/abi/json/testnet.json +0 -1328
  7. package/src/abi/types.ts +0 -23
  8. package/src/admin.ts +0 -287
  9. package/src/base.ts +0 -226
  10. package/src/constants.ts +0 -131
  11. package/src/fee-pay.ts +0 -39
  12. package/src/gas/gas-price-manager.ts +0 -115
  13. package/src/index.ts +0 -11
  14. package/src/order-event.types.ts +0 -65
  15. package/src/order-status.ts +0 -89
  16. package/src/read/account-overview/account-overview.reader.ts +0 -47
  17. package/src/read/account-overview/account-overview.types.ts +0 -47
  18. package/src/read/base-reader.ts +0 -41
  19. package/src/read/candlesticks/candlesticks.reader.ts +0 -61
  20. package/src/read/candlesticks/candlesticks.types.ts +0 -46
  21. package/src/read/delegations/delegations.reader.ts +0 -22
  22. package/src/read/delegations/delegations.types.ts +0 -19
  23. package/src/read/index.ts +0 -288
  24. package/src/read/leaderboard/leaderboard.reader.ts +0 -21
  25. package/src/read/leaderboard/leaderboard.types.ts +0 -26
  26. package/src/read/market-contexts/market-contexts.reader.ts +0 -26
  27. package/src/read/market-contexts/market-contexts.types.ts +0 -17
  28. package/src/read/market-depth/market-depth.reader.ts +0 -60
  29. package/src/read/market-depth/market-depth.types.ts +0 -24
  30. package/src/read/market-prices/market-prices.reader.ts +0 -74
  31. package/src/read/market-prices/market-prices.types.ts +0 -41
  32. package/src/read/market-trades/market-trades.reader.ts +0 -46
  33. package/src/read/market-trades/market-trades.types.ts +0 -34
  34. package/src/read/markets/markets.reader.ts +0 -82
  35. package/src/read/markets/markets.types.ts +0 -54
  36. package/src/read/pagination.types.ts +0 -18
  37. package/src/read/portfolio-chart/portfolio-chart.reader.ts +0 -20
  38. package/src/read/portfolio-chart/portfolio-chart.types.ts +0 -21
  39. package/src/read/types.ts +0 -130
  40. package/src/read/user-active-twaps/user-active-twaps.reader.ts +0 -36
  41. package/src/read/user-active-twaps/user-active-twaps.types.ts +0 -33
  42. package/src/read/user-bulk-orders/user-bulk-orders.reader.ts +0 -37
  43. package/src/read/user-bulk-orders/user-bulk-orders.types.ts +0 -32
  44. package/src/read/user-funding-history/user-funding-history.reader.ts +0 -38
  45. package/src/read/user-funding-history/user-funding-history.types.ts +0 -29
  46. package/src/read/user-notifications/user-notifications.reader.ts +0 -17
  47. package/src/read/user-notifications/user-notifications.types.ts +0 -61
  48. package/src/read/user-open-orders/user-open-orders.reader.ts +0 -36
  49. package/src/read/user-open-orders/user-open-orders.types.ts +0 -42
  50. package/src/read/user-order-history/user-order-history.reader.ts +0 -34
  51. package/src/read/user-order-history/user-order-history.types.ts +0 -48
  52. package/src/read/user-positions/user-positions.reader.ts +0 -55
  53. package/src/read/user-positions/user-positions.types.ts +0 -42
  54. package/src/read/user-subaccounts/user-subaccounts.reader.ts +0 -30
  55. package/src/read/user-subaccounts/user-subaccounts.types.ts +0 -21
  56. package/src/read/user-trade-history/user-trade-history.reader.ts +0 -38
  57. package/src/read/user-trade-history/user-trade-history.types.ts +0 -33
  58. package/src/read/vaults/vaults.reader.ts +0 -81
  59. package/src/read/vaults/vaults.types.ts +0 -109
  60. package/src/read/ws-subscription.ts +0 -206
  61. package/src/release-config.ts +0 -47
  62. package/src/subaccount-types.ts +0 -31
  63. package/src/transaction-builder.ts +0 -76
  64. package/src/utils.ts +0 -289
  65. package/src/write.ts +0 -979
  66. package/tsconfig.json +0 -8
package/package.json CHANGED
@@ -19,6 +19,12 @@
19
19
  "types": "./dist/index.d.ts"
20
20
  }
21
21
  },
22
+ "files": [
23
+ "dist",
24
+ "abi",
25
+ "readme.md",
26
+ "package.json"
27
+ ],
22
28
  "main": "dist/index.js",
23
29
  "name": "@decibeltrade/sdk",
24
30
  "peerDependencies": {
@@ -43,5 +49,5 @@
43
49
  },
44
50
  "type": "module",
45
51
  "types": "dist/index.d.ts",
46
- "version": "0.2.6"
52
+ "version": "0.2.8"
47
53
  }
@@ -1,26 +0,0 @@
1
- name: Publish to npm
2
-
3
- on:
4
- push:
5
- branches:
6
- - main
7
- workflow_dispatch:
8
-
9
- permissions:
10
- id-token: write # Required for OIDC
11
- contents: read
12
-
13
- jobs:
14
- publish:
15
- runs-on: ubuntu-latest
16
- steps:
17
- - uses: actions/checkout@v4
18
-
19
- - uses: actions/setup-node@v4
20
- with:
21
- node-version: '24'
22
- registry-url: 'https://registry.npmjs.org'
23
- - run: npm install
24
- - run: npm run build --if-present
25
- - run: npm test
26
- - run: npm publish
package/eslint.config.mjs DELETED
@@ -1,25 +0,0 @@
1
- // @ts-check
2
-
3
- import { baseConfig } from "@decibeltrade/eslint-config/base";
4
- import { dirname } from "path";
5
- import tseslint from "typescript-eslint";
6
- import { fileURLToPath } from "url";
7
-
8
- const __filename = fileURLToPath(import.meta.url);
9
- const __dirname = dirname(__filename);
10
-
11
- export default tseslint.config(
12
- {
13
- languageOptions: {
14
- parserOptions: {
15
- ecmaVersion: "latest",
16
- sourceType: "module",
17
- projectService: {
18
- allowDefaultProject: ["*.mjs"],
19
- },
20
- tsconfigRootDir: __dirname,
21
- },
22
- },
23
- },
24
- baseConfig,
25
- );
@@ -1,164 +0,0 @@
1
- /**
2
- * ABI fetcher that gets all ABIs used by the Decibel SDK
3
- * Based on actual function calls found in the SDK source code
4
- */
5
-
6
- import { Aptos, AptosConfig, MoveFunction, MoveFunctionId, Network } from "@aptos-labs/ts-sdk";
7
- import * as fs from "fs";
8
- import * as path from "path";
9
-
10
- import { DecibelConfig, NETNA_CONFIG, TESTNET_CONFIG } from "../constants";
11
- import { ABIData, ABIs } from "./types";
12
-
13
- // @Todo: There should be a global config that takes care of config across all the packages and apps
14
- // @Todo: Generate ABIs for all the networks as well, or as per global config depending upon how that will work
15
- // Remove NETNA_CONFIG and use getSdkConfig() instead once we implement it as a global config
16
- const CONFIGS = [NETNA_CONFIG, TESTNET_CONFIG];
17
-
18
- // All modules used in the SDK (extracted from source code analysis)
19
- const SDK_MODULES = [
20
- "admin_apis",
21
- "public_apis",
22
- "dex_accounts",
23
- "perp_engine",
24
- "usdc",
25
- "vault",
26
- "dex_accounts_vault_extension",
27
- ];
28
-
29
- /**
30
- * Generates a safe filename based on the network configuration
31
- */
32
- function getAbiFilename(config: DecibelConfig): string {
33
- // For CUSTOM networks, use a more descriptive name based on the config
34
- if (config.network === Network.CUSTOM) {
35
- // Check if it's NETNA by comparing package address or other unique identifier
36
- if (config.deployment.package === NETNA_CONFIG.deployment.package) {
37
- return "json/netna.json";
38
- }
39
- return "json/custom.json";
40
- }
41
- // For standard networks, use the network name
42
- return `json/${config.network.toLowerCase()}.json`;
43
- }
44
-
45
- async function fetchAllAbis(config: DecibelConfig): Promise<void> {
46
- console.log("🚀 Fetching ABIs for Decibel SDK functions...");
47
- console.log("📦 Package:", config.deployment.package);
48
- console.log("🌐 Network:", config.network);
49
- console.log("🔗 Fullnode:", config.fullnodeUrl);
50
- console.log();
51
-
52
- if (!config.deployment.package || !config.fullnodeUrl) {
53
- console.error("❌ Error: config.package or CONFIG.fullnodeUrl is not set");
54
- process.exit(1);
55
- }
56
-
57
- const aptosConfig = new AptosConfig({
58
- network: config.network,
59
- fullnode: config.fullnodeUrl,
60
- });
61
-
62
- const abis: ABIs = {};
63
- const errors: ABIData["errors"] = [];
64
- const aptos = new Aptos(aptosConfig);
65
-
66
- // Fetch entire modules at once (much more efficient!)
67
- for (const module of SDK_MODULES) {
68
- try {
69
- console.log("📡 Fetching entire module:", module);
70
-
71
- // Get the entire module ABI
72
- const moduleInfo = await aptos.getAccountModule({
73
- accountAddress: config.deployment.package,
74
- moduleName: module,
75
- });
76
-
77
- if (!moduleInfo.abi) {
78
- throw new Error("Module or ABI not found");
79
- }
80
-
81
- // Debug: Log the ABI structure
82
- console.log("📋 ABI structure for", module, ":", Object.keys(moduleInfo.abi));
83
-
84
- // Get only entry functions from the module
85
- const exposedFunctions: MoveFunction[] = moduleInfo.abi.exposed_functions;
86
- const entryFunctions = exposedFunctions.filter((f) => f.is_entry);
87
-
88
- console.log("🔍 Found", exposedFunctions.length, "exposed functions in", module);
89
- console.log("🧩 Keeping", entryFunctions.length, "entry functions in", module);
90
-
91
- for (const func of entryFunctions) {
92
- const functionId: MoveFunctionId = `${config.deployment.package}::${module}::${func.name}`;
93
- abis[functionId] = func;
94
- }
95
-
96
- console.log(
97
- "✅ Successfully collected",
98
- entryFunctions.length,
99
- "entry functions from",
100
- module,
101
- );
102
- } catch (error) {
103
- const errorMessage = error instanceof Error ? error.message : String(error);
104
- console.log("❌", module, ":", errorMessage);
105
- errors.push({ module, function: "entire_module", error: errorMessage });
106
- }
107
- }
108
-
109
- // Create the final structure
110
- const totalFunctions = Object.keys(abis).length;
111
-
112
- const result: ABIData = {
113
- packageAddress: config.deployment.package,
114
- network: config.network,
115
- fullnodeUrl: config.fullnodeUrl,
116
- fetchedAt: new Date().toISOString(),
117
- abis,
118
- errors,
119
- summary: {
120
- totalModules: SDK_MODULES.length,
121
- totalFunctions,
122
- successful: totalFunctions,
123
- failed: errors.length,
124
- },
125
- modules: SDK_MODULES,
126
- };
127
-
128
- // Write to JSON file with network-specific filename
129
- const filename = getAbiFilename(config);
130
- const outputPath = path.join(__dirname, filename);
131
- fs.writeFileSync(outputPath, JSON.stringify(result, null, 2));
132
-
133
- console.log();
134
- console.log("📊 Summary:");
135
- console.log("Total modules fetched:", SDK_MODULES.length);
136
- console.log("Total functions found:", result.summary.successful);
137
- console.log("Failed modules:", result.summary.failed);
138
-
139
- if (errors.length > 0) {
140
- console.log();
141
- console.log("❌ Errors:");
142
- errors.forEach(({ module, function: funcName, error }) => {
143
- console.log(module, "::", funcName, ":", error);
144
- console.log();
145
- });
146
- }
147
-
148
- console.log();
149
- console.log("📁 ABIs saved to:", outputPath);
150
- console.log();
151
- console.log("🎉 ABI fetching complete!");
152
- }
153
-
154
- // Run the script
155
- if (require.main === module) {
156
- // Process configs sequentially to avoid race conditions
157
- void (async () => {
158
- for (const config of CONFIGS) {
159
- await fetchAllAbis(config).catch((error: unknown) => {
160
- console.error(`❌ Failed to fetch ABIs for ${config.network}:`, error);
161
- });
162
- }
163
- })();
164
- }