@decibeltrade/sdk 0.2.7 → 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.
- package/package.json +7 -1
- package/.github/workflows/npm_publish.yml +0 -58
- package/eslint.config.mjs +0 -25
- package/src/abi/generate-abis.ts +0 -164
- package/src/abi/json/netna.json +0 -1325
- package/src/abi/json/testnet.json +0 -1328
- package/src/abi/types.ts +0 -23
- package/src/admin.ts +0 -287
- package/src/base.ts +0 -226
- package/src/constants.ts +0 -131
- package/src/fee-pay.ts +0 -39
- package/src/gas/gas-price-manager.ts +0 -115
- package/src/index.ts +0 -11
- package/src/order-event.types.ts +0 -65
- package/src/order-status.ts +0 -89
- package/src/read/account-overview/account-overview.reader.ts +0 -47
- package/src/read/account-overview/account-overview.types.ts +0 -47
- package/src/read/base-reader.ts +0 -41
- package/src/read/candlesticks/candlesticks.reader.ts +0 -61
- package/src/read/candlesticks/candlesticks.types.ts +0 -46
- package/src/read/delegations/delegations.reader.ts +0 -22
- package/src/read/delegations/delegations.types.ts +0 -19
- package/src/read/index.ts +0 -288
- package/src/read/leaderboard/leaderboard.reader.ts +0 -21
- package/src/read/leaderboard/leaderboard.types.ts +0 -26
- package/src/read/market-contexts/market-contexts.reader.ts +0 -26
- package/src/read/market-contexts/market-contexts.types.ts +0 -17
- package/src/read/market-depth/market-depth.reader.ts +0 -60
- package/src/read/market-depth/market-depth.types.ts +0 -24
- package/src/read/market-prices/market-prices.reader.ts +0 -74
- package/src/read/market-prices/market-prices.types.ts +0 -41
- package/src/read/market-trades/market-trades.reader.ts +0 -46
- package/src/read/market-trades/market-trades.types.ts +0 -34
- package/src/read/markets/markets.reader.ts +0 -82
- package/src/read/markets/markets.types.ts +0 -54
- package/src/read/pagination.types.ts +0 -18
- package/src/read/portfolio-chart/portfolio-chart.reader.ts +0 -20
- package/src/read/portfolio-chart/portfolio-chart.types.ts +0 -21
- package/src/read/types.ts +0 -130
- package/src/read/user-active-twaps/user-active-twaps.reader.ts +0 -36
- package/src/read/user-active-twaps/user-active-twaps.types.ts +0 -33
- package/src/read/user-bulk-orders/user-bulk-orders.reader.ts +0 -37
- package/src/read/user-bulk-orders/user-bulk-orders.types.ts +0 -32
- package/src/read/user-funding-history/user-funding-history.reader.ts +0 -38
- package/src/read/user-funding-history/user-funding-history.types.ts +0 -29
- package/src/read/user-notifications/user-notifications.reader.ts +0 -17
- package/src/read/user-notifications/user-notifications.types.ts +0 -61
- package/src/read/user-open-orders/user-open-orders.reader.ts +0 -36
- package/src/read/user-open-orders/user-open-orders.types.ts +0 -42
- package/src/read/user-order-history/user-order-history.reader.ts +0 -34
- package/src/read/user-order-history/user-order-history.types.ts +0 -48
- package/src/read/user-positions/user-positions.reader.ts +0 -55
- package/src/read/user-positions/user-positions.types.ts +0 -42
- package/src/read/user-subaccounts/user-subaccounts.reader.ts +0 -30
- package/src/read/user-subaccounts/user-subaccounts.types.ts +0 -21
- package/src/read/user-trade-history/user-trade-history.reader.ts +0 -38
- package/src/read/user-trade-history/user-trade-history.types.ts +0 -33
- package/src/read/vaults/vaults.reader.ts +0 -81
- package/src/read/vaults/vaults.types.ts +0 -109
- package/src/read/ws-subscription.ts +0 -206
- package/src/release-config.ts +0 -47
- package/src/subaccount-types.ts +0 -31
- package/src/transaction-builder.ts +0 -76
- package/src/utils.ts +0 -289
- package/src/write.ts +0 -979
- 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.
|
|
52
|
+
"version": "0.2.8"
|
|
47
53
|
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
name: Publish to npm
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- main
|
|
7
|
-
workflow_dispatch:
|
|
8
|
-
|
|
9
|
-
permissions:
|
|
10
|
-
contents: read
|
|
11
|
-
id-token: write # required for npm OIDC
|
|
12
|
-
|
|
13
|
-
jobs:
|
|
14
|
-
publish:
|
|
15
|
-
runs-on: ubuntu-latest
|
|
16
|
-
|
|
17
|
-
steps:
|
|
18
|
-
- uses: actions/checkout@v4
|
|
19
|
-
|
|
20
|
-
- uses: actions/setup-node@v4
|
|
21
|
-
with:
|
|
22
|
-
node-version: "24"
|
|
23
|
-
registry-url: "https://registry.npmjs.org"
|
|
24
|
-
|
|
25
|
-
- name: Check npm version
|
|
26
|
-
id: version
|
|
27
|
-
run: |
|
|
28
|
-
PKG_NAME=$(node -p "require('./package.json').name")
|
|
29
|
-
LOCAL=$(node -p "require('./package.json').version")
|
|
30
|
-
REMOTE=$(npm view "$PKG_NAME" version || echo "0.0.0")
|
|
31
|
-
|
|
32
|
-
echo "📦 Package: $PKG_NAME"
|
|
33
|
-
echo "📄 Local version: $LOCAL"
|
|
34
|
-
echo "🌐 Published version: $REMOTE"
|
|
35
|
-
|
|
36
|
-
if npx semver "$LOCAL" -r ">$REMOTE" >/dev/null; then
|
|
37
|
-
echo "publish=true" >> "$GITHUB_OUTPUT"
|
|
38
|
-
echo "✅ Version is greater — will publish"
|
|
39
|
-
else
|
|
40
|
-
echo "publish=false" >> "$GITHUB_OUTPUT"
|
|
41
|
-
echo "⏭️ Version not greater — skipping publish"
|
|
42
|
-
fi
|
|
43
|
-
|
|
44
|
-
- name: Install dependencies
|
|
45
|
-
if: steps.version.outputs.publish == 'true'
|
|
46
|
-
run: npm install
|
|
47
|
-
|
|
48
|
-
- name: Build
|
|
49
|
-
if: steps.version.outputs.publish == 'true'
|
|
50
|
-
run: npm run build --if-present
|
|
51
|
-
|
|
52
|
-
- name: Test
|
|
53
|
-
if: steps.version.outputs.publish == 'true'
|
|
54
|
-
run: npm test --if-present
|
|
55
|
-
|
|
56
|
-
- name: Publish to npm
|
|
57
|
-
if: steps.version.outputs.publish == 'true'
|
|
58
|
-
run: npm publish --access public
|
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
|
-
);
|
package/src/abi/generate-abis.ts
DELETED
|
@@ -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
|
-
}
|