@autonomys/auto-consensus 0.6.5 → 0.6.7
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/account.js +1 -1
- package/dist/info.d.ts +2 -2
- package/dist/info.d.ts.map +1 -1
- package/dist/info.js +12 -10
- package/dist/types/account.d.ts +1 -1
- package/dist/types/account.d.ts.map +1 -1
- package/dist/utils/parse.d.ts +2 -1
- package/dist/utils/parse.d.ts.map +1 -1
- package/dist/utils/parse.js +7 -5
- package/package.json +3 -3
package/dist/account.js
CHANGED
|
@@ -17,7 +17,7 @@ const account = (api, address) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
17
17
|
const rawAccount = yield api.query.system.account(address);
|
|
18
18
|
const { nonce, data } = rawAccount.toPrimitive();
|
|
19
19
|
return {
|
|
20
|
-
nonce,
|
|
20
|
+
nonce: (0, utils_1.parseBN)(nonce),
|
|
21
21
|
data: (0, utils_1.parseBalance)(data),
|
|
22
22
|
};
|
|
23
23
|
}
|
package/dist/info.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export declare const shouldAdjustSolutionRange: (api: Api) => Promise<boolean>;
|
|
|
15
15
|
export declare const segmentCommitment: (api: Api) => Promise<[StorageKey<AnyTuple>, Codec][]>;
|
|
16
16
|
export declare const slotProbability: (api: Api) => [number, number];
|
|
17
17
|
export declare const maxPiecesInSector: (api: Api) => bigint;
|
|
18
|
-
export declare function
|
|
19
|
-
export declare const spacePledge: (api: Api) => Promise<bigint
|
|
18
|
+
export declare function solutionRangeToPieces(solutionRange: bigint, slotProbability: [bigint, bigint]): bigint;
|
|
19
|
+
export declare const spacePledge: (api: Api) => Promise<bigint>;
|
|
20
20
|
export declare const blockchainSize: (api: Api) => Promise<bigint>;
|
|
21
21
|
//# sourceMappingURL=info.d.ts.map
|
package/dist/info.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"info.d.ts","sourceRoot":"","sources":["../src/info.ts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QAAe,GAAG,oBAGvC,CAAA;AAED,eAAO,MAAM,gBAAgB,QAAe,GAAG,mBAAiD,CAAA;AAEhG,eAAO,MAAM,cAAc,QAAe,GAAG;;;;;EAc5C,CAAA;AAED,eAAO,MAAM,yBAAyB,QAAe,GAAG,KAAG,OAAO,CAAC,OAAO,CACL,CAAA;AAErE,eAAO,MAAM,iBAAiB,QAAe,GAAG,6CACqC,CAAA;AAErF,eAAO,MAAM,eAAe,QAAS,GAAG,KAAG,CAAC,MAAM,EAAE,MAAM,CACa,CAAA;AAEvE,eAAO,MAAM,iBAAiB,QAAS,GAAG,KAAG,MAC0B,CAAA;AAEvE,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,MAAM,EACrB,eAAe,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAChC,MAAM,CAUR;AAED,eAAO,MAAM,WAAW,QAAe,GAAG,KAAG,OAAO,CAAC,MAAM,CAa1D,CAAA;AAED,eAAO,MAAM,cAAc,QAAe,GAAG,KAAG,OAAO,CAAC,MAAM,CAM7D,CAAA"}
|
package/dist/info.js
CHANGED
|
@@ -11,7 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.blockchainSize = exports.spacePledge = exports.maxPiecesInSector = exports.slotProbability = exports.segmentCommitment = exports.shouldAdjustSolutionRange = exports.solutionRanges = exports.networkTimestamp = exports.blockHash = exports.blockNumber = exports.block = exports.query = exports.rpc = void 0;
|
|
14
|
-
exports.
|
|
14
|
+
exports.solutionRangeToPieces = solutionRangeToPieces;
|
|
15
15
|
const query_1 = require("./utils/query");
|
|
16
16
|
const PIECE_SIZE = BigInt(1048576);
|
|
17
17
|
const rpc = (api_1, methodPath_1, ...args_1) => __awaiter(void 0, [api_1, methodPath_1, ...args_1], void 0, function* (api, methodPath, params = []) { return yield (0, query_1.queryMethodPath)(api, `rpc.${methodPath}`, params); });
|
|
@@ -52,22 +52,24 @@ const slotProbability = (api) => api.consts.subspace.slotProbability.toPrimitive
|
|
|
52
52
|
exports.slotProbability = slotProbability;
|
|
53
53
|
const maxPiecesInSector = (api) => BigInt(api.consts.subspace.maxPiecesInSector.toPrimitive());
|
|
54
54
|
exports.maxPiecesInSector = maxPiecesInSector;
|
|
55
|
-
function
|
|
55
|
+
function solutionRangeToPieces(solutionRange, slotProbability) {
|
|
56
56
|
const MAX_U64 = BigInt(Math.pow(2, 64) - 1);
|
|
57
57
|
const RECORD_NUM_CHUNKS = BigInt(32768);
|
|
58
58
|
const RECORD_NUM_S_BUCKETS = BigInt(65536);
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
return
|
|
59
|
+
const pieces = (((MAX_U64 / slotProbability[1]) * slotProbability[0]) / RECORD_NUM_CHUNKS) *
|
|
60
|
+
RECORD_NUM_S_BUCKETS;
|
|
61
|
+
return pieces / solutionRange;
|
|
62
62
|
}
|
|
63
63
|
const spacePledge = (api) => __awaiter(void 0, void 0, void 0, function* () {
|
|
64
64
|
const _solutionRanges = yield (0, exports.solutionRanges)(api);
|
|
65
65
|
const _slotProbability = (0, exports.slotProbability)(api);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
if (!_solutionRanges.current || !_slotProbability)
|
|
67
|
+
return BigInt(0);
|
|
68
|
+
const pieces = solutionRangeToPieces(_solutionRanges.current, [
|
|
69
|
+
BigInt(_slotProbability[0]),
|
|
70
|
+
BigInt(_slotProbability[1]),
|
|
71
|
+
]);
|
|
72
|
+
const totalSpacePledged = pieces * PIECE_SIZE;
|
|
71
73
|
return totalSpacePledged;
|
|
72
74
|
});
|
|
73
75
|
exports.spacePledge = spacePledge;
|
package/dist/types/account.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../src/types/account.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAA;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAE5D,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,EAAE,EAAE,CAAA;IACT,IAAI,EAAE,cAAc,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../src/types/account.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAA;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAE5D,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,EAAE,EAAE,CAAA;IACT,IAAI,EAAE,cAAc,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,WAAW,CAAA;CAClB,CAAA"}
|
package/dist/utils/parse.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { AnyTuple, Codec, StorageKey } from '@autonomys/auto-utils';
|
|
1
|
+
import type { AnyTuple, BN, Codec, StorageKey } from '@autonomys/auto-utils';
|
|
2
2
|
import type { BalanceData, RawBalanceData } from '../types/balance';
|
|
3
3
|
import { DomainRegistry } from '../types/domain';
|
|
4
4
|
import { Deposit, Operator, OperatorDetails, StringNumberOrBigInt, Withdrawal } from '../types/staking';
|
|
5
|
+
export declare const parseBN: (value: BN) => bigint;
|
|
5
6
|
export declare const parseBalance: (data: RawBalanceData) => BalanceData;
|
|
6
7
|
export declare const parseDomain: (domain: [StorageKey<AnyTuple>, Codec]) => DomainRegistry;
|
|
7
8
|
export declare const parseOperatorDetails: (operatorDetails: Codec) => OperatorDetails;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/utils/parse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/utils/parse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,EACL,OAAO,EACP,QAAQ,EACR,eAAe,EAOf,oBAAoB,EACpB,UAAU,EACX,MAAM,kBAAkB,CAAA;AAEzB,eAAO,MAAM,OAAO,UAAW,EAAE,KAAG,MAAkC,CAAA;AAEtE,eAAO,MAAM,YAAY,SAAU,cAAc,KAAG,WAYnD,CAAA;AAED,eAAO,MAAM,WAAW,WAAY,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,KAAG,cAMnE,CAAA;AAED,eAAO,MAAM,oBAAoB,oBAAqB,KAAK,KAAG,eAgB7D,CAAA;AAED,eAAO,MAAM,aAAa,aAAc,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,KAAG,QAKvE,CAAA;AAED,eAAO,MAAM,YAAY,YAAa,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,KAAG,OAuBrE,CAAA;AAED,eAAO,MAAM,eAAe,eAAgB,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,KAAG,UAwB3E,CAAA;AAED,eAAO,MAAM,WAAW,eAAgB,oBAAoB,KAAG,MACM,CAAA"}
|
package/dist/utils/parse.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseString = exports.parseWithdrawal = exports.parseDeposit = exports.parseOperator = exports.parseOperatorDetails = exports.parseDomain = exports.parseBalance = void 0;
|
|
3
|
+
exports.parseString = exports.parseWithdrawal = exports.parseDeposit = exports.parseOperator = exports.parseOperatorDetails = exports.parseDomain = exports.parseBalance = exports.parseBN = void 0;
|
|
4
|
+
const parseBN = (value) => BigInt(value.toString());
|
|
5
|
+
exports.parseBN = parseBN;
|
|
4
6
|
const parseBalance = (data) => {
|
|
5
7
|
try {
|
|
6
8
|
return {
|
|
7
|
-
free:
|
|
8
|
-
reserved:
|
|
9
|
-
frozen:
|
|
10
|
-
flags:
|
|
9
|
+
free: (0, exports.parseBN)(data.free),
|
|
10
|
+
reserved: (0, exports.parseBN)(data.reserved),
|
|
11
|
+
frozen: (0, exports.parseBN)(data.frozen),
|
|
12
|
+
flags: (0, exports.parseBN)(data.flags),
|
|
11
13
|
};
|
|
12
14
|
}
|
|
13
15
|
catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autonomys/auto-consensus",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.7",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"url": "https://www.autonomys.net"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@autonomys/auto-utils": "^0.6.
|
|
25
|
+
"@autonomys/auto-utils": "^0.6.7"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/jest": "^29.5.12",
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"ts-jest": "^29.1.4",
|
|
33
33
|
"typescript": "^5.4.5"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "2ba65337aa923eaac7269aaea70db97112bfc033"
|
|
36
36
|
}
|