n8n-nodes-bittensor 1.0.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/LICENSE +46 -0
- package/README.md +329 -0
- package/dist/credentials/BittensorApi.credentials.d.ts +8 -0
- package/dist/credentials/BittensorApi.credentials.js +75 -0
- package/dist/credentials/BittensorApi.credentials.js.map +1 -0
- package/dist/credentials/BittensorNetwork.credentials.d.ts +8 -0
- package/dist/credentials/BittensorNetwork.credentials.js +117 -0
- package/dist/credentials/BittensorNetwork.credentials.js.map +1 -0
- package/dist/credentials/SubnetCredentials.credentials.d.ts +8 -0
- package/dist/credentials/SubnetCredentials.credentials.js +81 -0
- package/dist/credentials/SubnetCredentials.credentials.js.map +1 -0
- package/dist/nodes/Bittensor/Bittensor.node.d.ts +5 -0
- package/dist/nodes/Bittensor/Bittensor.node.js +938 -0
- package/dist/nodes/Bittensor/Bittensor.node.js.map +1 -0
- package/dist/nodes/Bittensor/bittensor.svg +4 -0
- package/dist/nodes/Bittensor/constants/hyperparameters.d.ts +23 -0
- package/dist/nodes/Bittensor/constants/hyperparameters.js +127 -0
- package/dist/nodes/Bittensor/constants/hyperparameters.js.map +1 -0
- package/dist/nodes/Bittensor/constants/networks.d.ts +31 -0
- package/dist/nodes/Bittensor/constants/networks.js +54 -0
- package/dist/nodes/Bittensor/constants/networks.js.map +1 -0
- package/dist/nodes/Bittensor/constants/pallets.d.ts +73 -0
- package/dist/nodes/Bittensor/constants/pallets.js +99 -0
- package/dist/nodes/Bittensor/constants/pallets.js.map +1 -0
- package/dist/nodes/Bittensor/constants/subnets.d.ts +25 -0
- package/dist/nodes/Bittensor/constants/subnets.js +55 -0
- package/dist/nodes/Bittensor/constants/subnets.js.map +1 -0
- package/dist/nodes/Bittensor/transport/metagraphSync.d.ts +63 -0
- package/dist/nodes/Bittensor/transport/metagraphSync.js +153 -0
- package/dist/nodes/Bittensor/transport/metagraphSync.js.map +1 -0
- package/dist/nodes/Bittensor/transport/queryClient.d.ts +93 -0
- package/dist/nodes/Bittensor/transport/queryClient.js +144 -0
- package/dist/nodes/Bittensor/transport/queryClient.js.map +1 -0
- package/dist/nodes/Bittensor/transport/subtensorClient.d.ts +138 -0
- package/dist/nodes/Bittensor/transport/subtensorClient.js +414 -0
- package/dist/nodes/Bittensor/transport/subtensorClient.js.map +1 -0
- package/dist/nodes/Bittensor/transport/taostatsApi.d.ts +133 -0
- package/dist/nodes/Bittensor/transport/taostatsApi.js +139 -0
- package/dist/nodes/Bittensor/transport/taostatsApi.js.map +1 -0
- package/dist/nodes/Bittensor/utils/addressUtils.d.ts +25 -0
- package/dist/nodes/Bittensor/utils/addressUtils.js +70 -0
- package/dist/nodes/Bittensor/utils/addressUtils.js.map +1 -0
- package/dist/nodes/Bittensor/utils/metagraphUtils.d.ts +103 -0
- package/dist/nodes/Bittensor/utils/metagraphUtils.js +113 -0
- package/dist/nodes/Bittensor/utils/metagraphUtils.js.map +1 -0
- package/dist/nodes/Bittensor/utils/unitConverter.d.ts +48 -0
- package/dist/nodes/Bittensor/utils/unitConverter.js +109 -0
- package/dist/nodes/Bittensor/utils/unitConverter.js.map +1 -0
- package/dist/nodes/Bittensor/utils/weightUtils.d.ts +49 -0
- package/dist/nodes/Bittensor/utils/weightUtils.js +90 -0
- package/dist/nodes/Bittensor/utils/weightUtils.js.map +1 -0
- package/package.json +87 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) Velocity BPA, LLC
|
|
4
|
+
* Licensed under the Business Source License 1.1
|
|
5
|
+
* Commercial use requires a separate commercial license.
|
|
6
|
+
* See LICENSE file for details.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.normalizeWeights = normalizeWeights;
|
|
10
|
+
exports.percentagesToWeights = percentagesToWeights;
|
|
11
|
+
exports.validateWeights = validateWeights;
|
|
12
|
+
exports.sortWeightsByUid = sortWeightsByUid;
|
|
13
|
+
exports.filterZeroWeights = filterZeroWeights;
|
|
14
|
+
exports.getTopWeights = getTopWeights;
|
|
15
|
+
exports.prepareWeightsForSubmission = prepareWeightsForSubmission;
|
|
16
|
+
/**
|
|
17
|
+
* Normalize weights to sum to max weight
|
|
18
|
+
*/
|
|
19
|
+
function normalizeWeights(weights, maxWeight = 65535) {
|
|
20
|
+
const totalWeight = weights.reduce((sum, w) => sum + w.weight, 0);
|
|
21
|
+
if (totalWeight === 0)
|
|
22
|
+
return weights;
|
|
23
|
+
return weights.map(w => ({
|
|
24
|
+
uid: w.uid,
|
|
25
|
+
weight: Math.floor((w.weight / totalWeight) * maxWeight),
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Convert percentages to weights
|
|
30
|
+
*/
|
|
31
|
+
function percentagesToWeights(percentages, maxWeight = 65535) {
|
|
32
|
+
return percentages.map(p => ({
|
|
33
|
+
uid: p.uid,
|
|
34
|
+
weight: Math.floor((p.percentage / 100) * maxWeight),
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Validate weights
|
|
39
|
+
*/
|
|
40
|
+
function validateWeights(weights, minAllowedWeights, maxWeightLimit) {
|
|
41
|
+
const errors = [];
|
|
42
|
+
if (weights.length < minAllowedWeights) {
|
|
43
|
+
errors.push(`Minimum ${minAllowedWeights} weights required, got ${weights.length}`);
|
|
44
|
+
}
|
|
45
|
+
const overLimit = weights.filter(w => w.weight > maxWeightLimit);
|
|
46
|
+
if (overLimit.length > 0) {
|
|
47
|
+
errors.push(`${overLimit.length} weights exceed max limit of ${maxWeightLimit}`);
|
|
48
|
+
}
|
|
49
|
+
const negativeWeights = weights.filter(w => w.weight < 0);
|
|
50
|
+
if (negativeWeights.length > 0) {
|
|
51
|
+
errors.push('Negative weights are not allowed');
|
|
52
|
+
}
|
|
53
|
+
const duplicateUids = weights.filter((w, i, arr) => arr.findIndex(x => x.uid === w.uid) !== i);
|
|
54
|
+
if (duplicateUids.length > 0) {
|
|
55
|
+
errors.push('Duplicate UIDs found');
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
valid: errors.length === 0,
|
|
59
|
+
errors,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Sort weights by UID
|
|
64
|
+
*/
|
|
65
|
+
function sortWeightsByUid(weights) {
|
|
66
|
+
return [...weights].sort((a, b) => a.uid - b.uid);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Filter zero weights
|
|
70
|
+
*/
|
|
71
|
+
function filterZeroWeights(weights) {
|
|
72
|
+
return weights.filter(w => w.weight > 0);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Get top weights by value
|
|
76
|
+
*/
|
|
77
|
+
function getTopWeights(weights, n) {
|
|
78
|
+
return [...weights].sort((a, b) => b.weight - a.weight).slice(0, n);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Prepare weights for submission
|
|
82
|
+
*/
|
|
83
|
+
function prepareWeightsForSubmission(weights) {
|
|
84
|
+
const sorted = sortWeightsByUid(filterZeroWeights(weights));
|
|
85
|
+
return {
|
|
86
|
+
uids: sorted.map(w => w.uid),
|
|
87
|
+
values: sorted.map(w => w.weight),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=weightUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"weightUtils.js","sourceRoot":"","sources":["../../../../nodes/Bittensor/utils/weightUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAmBH,4CAQC;AAKD,oDAQC;AAKD,0CAgCC;AAKD,4CAEC;AAKD,8CAEC;AAKD,sCAEC;AAKD,kEAQC;AA/FD;;GAEG;AACH,SAAgB,gBAAgB,CAAC,OAAsB,EAAE,SAAS,GAAG,KAAK;IACzE,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,CAA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CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACrE,CAAC;AAED;;GAEG;AACH,SAAgB,2BAA2B,CAC1C,OAAsB;IAEtB,MAAM,MAAM,GAAG,gBAAgB,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC;IAC5D,OAAO;QACN,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;QAC5B,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;KACjC,CAAC;AACH,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "n8n-nodes-bittensor",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A comprehensive n8n community node for Bittensor blockchain providing 16 resources and 80+ operations for TAO staking, delegation, subnet queries, validator operations, and AI network interactions.",
|
|
5
|
+
"license": "BUSL-1.1",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "Velocity BPA",
|
|
8
|
+
"email": "licensing@velobpa.com",
|
|
9
|
+
"url": "https://velobpa.com"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/Velocity-BPA/n8n-nodes-bittensor.git"
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://velobpa.com",
|
|
16
|
+
"keywords": [
|
|
17
|
+
"n8n",
|
|
18
|
+
"n8n-community-node-package",
|
|
19
|
+
"bittensor",
|
|
20
|
+
"tao",
|
|
21
|
+
"blockchain",
|
|
22
|
+
"ai",
|
|
23
|
+
"staking",
|
|
24
|
+
"delegation",
|
|
25
|
+
"subnet",
|
|
26
|
+
"validator",
|
|
27
|
+
"miner",
|
|
28
|
+
"metagraph",
|
|
29
|
+
"polkadot",
|
|
30
|
+
"substrate",
|
|
31
|
+
"decentralized-ai"
|
|
32
|
+
],
|
|
33
|
+
"main": "dist/index.js",
|
|
34
|
+
"n8n": {
|
|
35
|
+
"n8nNodesApiVersion": 1,
|
|
36
|
+
"credentials": [
|
|
37
|
+
"dist/credentials/BittensorNetwork.credentials.js",
|
|
38
|
+
"dist/credentials/BittensorApi.credentials.js",
|
|
39
|
+
"dist/credentials/SubnetCredentials.credentials.js"
|
|
40
|
+
],
|
|
41
|
+
"nodes": [
|
|
42
|
+
"dist/nodes/Bittensor/Bittensor.node.js"
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
"files": [
|
|
46
|
+
"dist"
|
|
47
|
+
],
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@types/jest": "^29.5.0",
|
|
50
|
+
"@types/node": "^20.10.0",
|
|
51
|
+
"@types/ws": "^8.5.10",
|
|
52
|
+
"@typescript-eslint/eslint-plugin": "^7.0.0",
|
|
53
|
+
"@typescript-eslint/parser": "^7.0.0",
|
|
54
|
+
"eslint": "^8.56.0",
|
|
55
|
+
"gulp": "^4.0.2",
|
|
56
|
+
"jest": "^29.7.0",
|
|
57
|
+
"n8n-workflow": "^1.23.0",
|
|
58
|
+
"prettier": "^3.2.0",
|
|
59
|
+
"rimraf": "^5.0.5",
|
|
60
|
+
"ts-jest": "^29.1.0",
|
|
61
|
+
"typescript": "^5.3.0"
|
|
62
|
+
},
|
|
63
|
+
"dependencies": {
|
|
64
|
+
"@polkadot/api": "^10.12.0",
|
|
65
|
+
"@polkadot/keyring": "^12.6.0",
|
|
66
|
+
"@polkadot/util": "^12.6.0",
|
|
67
|
+
"@polkadot/util-crypto": "^12.6.0",
|
|
68
|
+
"axios": "^1.6.0",
|
|
69
|
+
"ws": "^8.16.0"
|
|
70
|
+
},
|
|
71
|
+
"peerDependencies": {
|
|
72
|
+
"n8n-workflow": "*"
|
|
73
|
+
},
|
|
74
|
+
"engines": {
|
|
75
|
+
"node": ">=18.0.0"
|
|
76
|
+
},
|
|
77
|
+
"scripts": {
|
|
78
|
+
"prebuild": "rimraf dist",
|
|
79
|
+
"build": "tsc && gulp build:icons",
|
|
80
|
+
"dev": "tsc --watch",
|
|
81
|
+
"format": "prettier nodes credentials --write",
|
|
82
|
+
"lint": "eslint . --ext .ts",
|
|
83
|
+
"lint:fix": "eslint . --ext .ts --fix",
|
|
84
|
+
"test": "jest",
|
|
85
|
+
"test:coverage": "jest --coverage"
|
|
86
|
+
}
|
|
87
|
+
}
|