repo_name
stringlengths
1
62
dataset
stringclasses
1 value
lang
stringclasses
11 values
pr_id
int64
1
20.1k
owner
stringlengths
2
34
reviewer
stringlengths
2
39
diff_hunk
stringlengths
15
262k
code_review_comment
stringlengths
1
99.6k
svg-to-compose
github_2023
others
15
rafaeltonholo
coderabbitai[bot]
@@ -0,0 +1,74 @@ +package dev.tonholo.s2c.domain.avg + +import dev.tonholo.s2c.domain.ImageVectorNode +import dev.tonholo.s2c.domain.PathFillType +import dev.tonholo.s2c.domain.StrokeCap +import dev.tonholo.s2c.domain.StrokeJoin +import dev.tonholo.s2c.domain.asNodeWrapper +import dev.tonholo.s2c.domain.delegate.attrib...
The `AvgPathNode` class is well-structured, with clear handling of AVG-specific attributes such as `fillColor`, `strokeColor`, and `strokeWidth`. Consider adding validation for the `strokeWidth` and `strokeAlpha` properties to ensure they are within expected ranges, especially since percentages are supported. <!-- Thi...
svg-to-compose
github_2023
others
15
rafaeltonholo
coderabbitai[bot]
@@ -12,3 +23,71 @@ fun String.pascalCase(): String = replaceDividers() .replaceFirstChar { it.uppercaseChar() } fun String.indented(indentSize: Int) = " ".repeat(indentSize) + this + +/** + * Some properties on SVG can receive a Number or a percentage. + * This extension function helps to extract the percentage...
The `toLengthFloat` extension function is a useful addition for handling percentage-based lengths in SVG/AVG properties. Ensure that edge cases, such as negative percentages or extremely large values, are handled gracefully. <!-- This is an auto-generated comment by CodeRabbit -->
svg-to-compose
github_2023
others
15
rafaeltonholo
coderabbitai[bot]
@@ -12,3 +23,71 @@ .replaceFirstChar { it.uppercaseChar() } fun String.indented(indentSize: Int) = " ".repeat(indentSize) + this + +/** + * Some properties on SVG can receive a Number or a percentage. + * This extension function helps to extract the percentage, in case of present, and + * transform in the corre...
The `toComposeColor` function for converting hexadecimal colors to a Compose color format is well-implemented. However, consider adding support for alpha values in short hexadecimal color codes and validating the input string format to prevent runtime errors. <!-- This is an auto-generated comment by CodeRabbit -->
svg-to-compose
github_2023
others
15
rafaeltonholo
coderabbitai[bot]
@@ -144,16 +282,60 @@ private const val SVG_EXTENSION = ".svg" private const val ANDROID_VECTOR_EXTENSION = ".xml" - private val parsers = mapOf( - SVG_EXTENSION to SvgParser, - ANDROID_VECTOR_EXTENSION to AndroidVectorParser - ) + private lateinit var pars...
The static `parse` function in the companion object is a useful entry point for parsing files. However, the error message in line 335 could be more informative by specifying the method name correctly. ```diff - "Parsers not initialized. Call ImageParser(fileSystem) before calling ImageParser.parser()", + "Parsers not ...
svg-to-compose
github_2023
others
15
rafaeltonholo
coderabbitai[bot]
@@ -48,75 +75,195 @@ class Processor( ) } - val files = mutableListOf(filePath) - printEmpty() - if (inputMetadata.isDirectory) { + var runRecursively = recursive + val files = if (inputMetadata.isDirectory) { output("🔍 Directory detected") - ...
The logic for handling recursive file processing is well-implemented. However, the variable `runRecursively` seems redundant since it's derived directly from the `recursive` parameter and only used once. Consider simplifying this by directly using the `recursive` parameter in the conditional check. <!-- This is an aut...
svg-to-compose
github_2023
others
15
rafaeltonholo
coderabbitai[bot]
@@ -86,24 +82,23 @@ Usage: client [<options>] <path> Options: - -v, --version Show this CLI version - -p, --package=<text> Specify icons's package. This will replace package at the top of the icon file - -t, --theme=<text> Specify project's theme name. This will take pla...
The help output section contains a typo in the `--optimize` flag description. It should be corrected for clarity. ```diff - Enable svg optimization before parsing to Jetpack Compose icon. The optimization process uses the following programs: svgo, svg2vectordrawable, avocado from NPM Registry + Enable SVG optimization...
svg-to-compose
github_2023
others
15
rafaeltonholo
coderabbitai[bot]
@@ -174,7 +169,7 @@ <parent-path>/shield-halved-solid.svg ``` -Input file: ![shield-halved-solid.svg](samples/shield-halved-solid.svg) +Input file: ![shield-halved-solid.svg](samples/svg/shield-halved-solid.svg) Output file: [ShieldSolid.svg.optimized.kt](samples/ShieldSolid.svg.optimized.kt)
> [!TIP] > Codebase Verification <!-- Monologue: [task item_1/1] Verify the accessibility of the sample SVG and Kotlin files based on the new context provided by the shell script execution results. [observations] The shell script was executed to check the accessibility of two links: one for the SVG file 'shield-halved...
svg-to-compose
github_2023
others
15
rafaeltonholo
coderabbitai[bot]
@@ -60,10 +60,6 @@ This script relies on three others to perform the **optimization**: ```console npm -g install svgo ``` -- [SVG2VectorDrawable](https://github.com/Ashung/svg2vectordrawable): Converts the SVG to an Android Vector. -```console -npm install -g svg2vectordrawable -``` - [Avocado](https://github.com/a...
> :memo: **NOTE** > This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [2-2] The introduction sentence has a grammatical error. It should use "to convert" instead of "for convert". ```diff - A command-line tool for convert SVG or an Android Vector Drawable (AVD) to Android ...
svg-to-compose
github_2023
others
15
rafaeltonholo
coderabbitai[bot]
@@ -86,24 +82,23 @@ Usage: client [<options>] <path> Options: - -v, --version Show this CLI version - -p, --package=<text> Specify icons's package. This will replace package at the top of the icon file - -t, --theme=<text> Specify project's theme name. This will take pla...
The description for the `--optimize` flag in the help output section contains a reference to `svg2vectordrawable`, which should be removed since the dependency has been eliminated. ```diff - Enable svg optimization before parsing to Jetpack Compose icon. The optimization process uses the following programs: svgo, svg2...
svg-to-compose
github_2023
others
15
rafaeltonholo
coderabbitai[bot]
@@ -2,36 +2,93 @@ package dev.tonholo.s2c.optimizer import AppConfig.S2C_TEMP_FOLDER import dev.tonholo.s2c.command.command +import dev.tonholo.s2c.domain.FileType import dev.tonholo.s2c.error.ErrorCode import dev.tonholo.s2c.error.MissingDependencyException import dev.tonholo.s2c.error.OptimizationException im...
The refactoring of the `Optimizer` interface into a sealed class with abstract methods and added functionality for verifying dependencies and running optimizations enhances modularity and maintainability. However, consider adding more detailed error handling in the `runOptimization` method to provide specific feedback ...
svg-to-compose
github_2023
others
15
rafaeltonholo
coderabbitai[bot]
@@ -51,352 +105,551 @@ sealed class PathNodes( } } + /** + * The [MoveTo] represents the SVG/AVG command to move the pen to a new location. + * + * It's a type of [PathNodes] which holds SVG/AVG command parameters. + * + * The new location is determined using the specified `x` and...
For the `CurveTo` class, the handling of control points and endpoint coordinates is clear. Consider adding unit tests for the `materialize` method to ensure that the generated string representation of the command is correct and adheres to the expected format. Would you like me to help create unit tests for the `CurveT...
svg-to-compose
github_2023
others
15
rafaeltonholo
coderabbitai[bot]
@@ -51,352 +105,551 @@ } } + /** + * The [MoveTo] represents the SVG/AVG command to move the pen to a new location. + * + * It's a type of [PathNodes] which holds SVG/AVG command parameters. + * + * The new location is determined using the specified `x` and `y` coordinates. + ...
The `ReflectiveCurveTo` class implementation is consistent with the design principles of the `PathNodes` sealed class. To further improve code maintainability, consider abstracting common logic found in `buildParameters` and `materialize` methods across different subclasses into helper methods within the sealed class. ...
svg-to-compose
github_2023
others
15
rafaeltonholo
coderabbitai[bot]
@@ -51,352 +105,551 @@ } } + /** + * The [MoveTo] represents the SVG/AVG command to move the pen to a new location. + * + * It's a type of [PathNodes] which holds SVG/AVG command parameters. + * + * The new location is determined using the specified `x` and `y` coordinates. + ...
The `ReflectiveQuadTo` class follows the established pattern for implementing SVG/AVG commands. To enhance the robustness of the implementation, consider adding validation for the input values to ensure they meet the expected format and range. <!-- This is an auto-generated comment by CodeRabbit -->
svg-to-compose
github_2023
others
15
rafaeltonholo
coderabbitai[bot]
@@ -48,75 +75,195 @@ class Processor( ) } - val files = mutableListOf(filePath) - printEmpty() - if (inputMetadata.isDirectory) { + var runRecursively = recursive + val files = if (inputMetadata.isDirectory) { output("🔍 Directory detected") - ...
The `ensureKotlinFileExtension` function checks and appends a Kotlin file extension if necessary. This is a useful utility, especially when the output path is dynamically determined. However, consider handling cases where the output path might have an uppercase extension (e.g., `.KT`), as the current check is case-sens...
svg-to-compose
github_2023
others
15
rafaeltonholo
coderabbitai[bot]
@@ -144,16 +282,60 @@ sealed class ImageParser { private const val SVG_EXTENSION = ".svg" private const val ANDROID_VECTOR_EXTENSION = ".xml" - private val parsers = mapOf( - SVG_EXTENSION to SvgParser, - ANDROID_VECTOR_EXTENSION to AndroidVectorParser - ) + ...
The companion object's `invoke` function initializes parsers for SVG and Android Vector Drawable images. However, the return statement should return `this` (the Companion object) instead of `ImageParser` to enable chain calls as intended. This needs correction to match the comment's guidance. ```diff - return ImagePar...
svg-to-compose
github_2023
others
15
rafaeltonholo
coderabbitai[bot]
@@ -144,16 +282,60 @@ private const val SVG_EXTENSION = ".svg" private const val ANDROID_VECTOR_EXTENSION = ".xml" - private val parsers = mapOf( - SVG_EXTENSION to SvgParser, - ANDROID_VECTOR_EXTENSION to AndroidVectorParser - ) + private lateinit var pars...
The error message in the `parse` function of the companion object could be more informative by specifying the correct method name. This helps in debugging and understanding the error context better. ```diff - "Parsers not initialized. Call ImageParser(fileSystem) before calling ImageParser.parser()", + "Parsers not in...
svg-to-compose
github_2023
others
15
rafaeltonholo
coderabbitai[bot]
@@ -48,75 +75,195 @@ class Processor( ) } - val files = mutableListOf(filePath) - printEmpty() - if (inputMetadata.isDirectory) { + var runRecursively = recursive + val files = if (inputMetadata.isDirectory) { output("🔍 Directory detected") - ...
The `findSvgAndXmlFilesInDirectory` function now includes error handling and recursive search capabilities, which are significant improvements. However, the error message could be more specific about the nature of the error, such as specifying that the output path is not a directory. Additionally, optimizing the file f...
svg-to-compose
github_2023
others
15
rafaeltonholo
coderabbitai[bot]
@@ -2,36 +2,93 @@ package dev.tonholo.s2c.optimizer import AppConfig.S2C_TEMP_FOLDER import dev.tonholo.s2c.command.command +import dev.tonholo.s2c.domain.FileType import dev.tonholo.s2c.error.ErrorCode import dev.tonholo.s2c.error.MissingDependencyException import dev.tonholo.s2c.error.OptimizationException im...
The transformation of `Optimizer` into a sealed class with abstract methods and added functionality for verifying dependencies and running optimizations is a significant improvement in terms of modularity and maintainability. However, the `runOptimization` method could benefit from more detailed error handling to provi...
svg-to-compose
github_2023
others
15
rafaeltonholo
coderabbitai[bot]
@@ -2,36 +2,93 @@ import AppConfig.S2C_TEMP_FOLDER import dev.tonholo.s2c.command.command +import dev.tonholo.s2c.domain.FileType import dev.tonholo.s2c.error.ErrorCode import dev.tonholo.s2c.error.MissingDependencyException import dev.tonholo.s2c.error.OptimizationException import dev.tonholo.s2c.extensions.ex...
The `verifyDependency` method is crucial for ensuring the required external tools are installed before attempting optimization. It's well-implemented, but adding error handling for unexpected exceptions during the command execution could improve robustness. For instance, handling cases where the command execution itsel...
svg-to-compose
github_2023
others
15
rafaeltonholo
coderabbitai[bot]
@@ -1,5 +1,5 @@ # SVG to Compose -A command-line tool for convert SVG or an Android Vector Drawable (AVD) to Android Jetpack Compose Icons. +A command-line tool to convert SVG or an Android Vector Drawable (AVG) to Android Jetpack Compose Icons.
The abbreviation "AVG" seems to be a typo and might confuse readers. It's likely intended to be "AVD" for Android Vector Drawable, consistent with the context. ```diff - A command-line tool to convert SVG or an Android Vector Drawable (AVG) to Android Jetpack Compose Icons. + A command-line tool to convert SVG or an A...
svg-to-compose
github_2023
others
15
rafaeltonholo
coderabbitai[bot]
@@ -86,24 +82,25 @@ Usage: client [<options>] <path> Options: - -v, --version Show this CLI version - -p, --package=<text> Specify icons's package. This will replace package at the top of the icon file - -t, --theme=<text> Specify project's theme name. This will take pla...
The help output description for the `--optimize` flag mentions SVG/AVG optimization. Given the earlier correction from AVG to AVD, it's consistent to apply the same correction here for clarity. ```diff - -opt, --optimize=true|false Enable SVG/AVG optimization before parsing to Jetpack Compose icon. The optimiza...
svg-to-compose
github_2023
others
15
rafaeltonholo
coderabbitai[bot]
@@ -1,34 +1,34 @@ -package dev.tonholo.s2c.domain +package dev.tonholo.s2c.domain.svg +import dev.tonholo.s2c.domain.ImageVectorNode +import dev.tonholo.s2c.domain.PathNodes +import dev.tonholo.s2c.extensions.removeTrailingZero import kotlin.test.Test import kotlin.test.assertContains import kotlin.test.assertEqua...
The instantiation of `SvgPathNode` with `parent` and `attributes` is clear and concise. However, consider adding a brief comment explaining the significance of the "d" attribute's value "s2,-2 4,5" for future maintainability and readability. ```diff + // "s2,-2 4,5" represents a relative reflective curve to command in...
svg-to-compose
github_2023
others
15
rafaeltonholo
coderabbitai[bot]
@@ -0,0 +1,206 @@ +package dev.tonholo.s2c.domain.svg + +import dev.tonholo.s2c.domain.ImageVectorNode +import dev.tonholo.s2c.domain.PathCommand +import dev.tonholo.s2c.domain.builder.pathNode +import dev.tonholo.s2c.domain.xml.XmlNode +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.asser...
Creating an instance of `SvgGroupNode` with children `SvgPathNode` instances is a clear demonstration of how SVG groups and paths are represented and manipulated within the domain. Consider adding comments to explain the significance of the attributes, especially the "d" and "fill" attributes, for better readability an...
waterfly-iii
github_2023
others
387
dreautall
dreautall
@@ -23,16 +25,14 @@ class LastDaysChart extends StatelessWidget { @override Widget build(BuildContext context) { + final TimeZoneHandler tzHandler = context.read<FireflyService>().tzHandler; // Use noon due to dailylight saving time - final DateTime now = DateTime.now() - .toLocal() - ....
any reason you removed re-setting the time to noon?
waterfly-iii
github_2023
others
294
dreautall
dreautall
@@ -906,5 +910,83 @@ "transactionTypeWithdrawal": "Withdrawal", "@transactionTypeWithdrawal": { "description": "Withdrawal transaction type" + }, + "yes": "Yes", + "@yes": { + "description": "The word yes" + }, + "no": "No", + "@no": { + "description": "The word no" + }, + "billsUngrouped": "Un...
`date` needs to be grouped inside a `placeholders` tag like you did above at `billAmountAndFrequency`.
waterfly-iii
github_2023
others
294
dreautall
dreautall
@@ -0,0 +1,311 @@ +import 'dart:ui'; + +import 'package:animations/animations.dart'; +import 'package:chopper/chopper.dart'; +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:logging/logging.dart'; +import 'package:provider/provider.dart'; +import 'package:waterflyiii/auth.dart...
Might be worth add `start` & `end`. A long-running bill (weekly rent payment or similar) might easily get to 100+ transactions otherwise, blowing up the page.
waterfly-iii
github_2023
others
294
dreautall
dreautall
@@ -0,0 +1,311 @@ +import 'dart:ui'; + +import 'package:animations/animations.dart'; +import 'package:chopper/chopper.dart'; +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:logging/logging.dart'; +import 'package:provider/provider.dart'; +import 'package:waterflyiii/auth.dart...
Nitpick: I try to avoid short one-time-use functions. You could just do that in Line 59.
waterfly-iii
github_2023
others
294
dreautall
dreautall
@@ -0,0 +1,311 @@ +import 'dart:ui'; + +import 'package:animations/animations.dart'; +import 'package:chopper/chopper.dart'; +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:logging/logging.dart'; +import 'package:provider/provider.dart'; +import 'package:waterflyiii/auth.dart...
Each split of a transaction can be linked to a different bill. I guess you need some logic here to sum up the amounts of the split transactions with the correct, currently shown bill associated with them.
waterfly-iii
github_2023
others
294
dreautall
dreautall
@@ -0,0 +1,311 @@ +import 'dart:ui'; + +import 'package:animations/animations.dart'; +import 'package:chopper/chopper.dart'; +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:logging/logging.dart'; +import 'package:provider/provider.dart'; +import 'package:waterflyiii/auth.dart...
uh what? 😄 `-271821`?
waterfly-iii
github_2023
others
294
dreautall
dreautall
@@ -0,0 +1,256 @@ +import 'dart:ui'; + +import 'package:animations/animations.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:intl/intl.dart'; +import 'package:logging/logging.dart'; +import 'package:provider/provider.dart'; + +import 'pack...
Have you tried out if the keepAlive makes a difference here? Since we have no tabs here, the page should never be killed (unless you switch to a different nav item, but then it will be killed regardless).
waterfly-iii
github_2023
others
294
dreautall
dreautall
@@ -0,0 +1,487 @@ +import 'package:animations/animations.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:intl/intl.dart'; +import 'package:logging/logging.dart'; +import 'package:provider/provider.dart'; + +import 'package:chopper/chopper.d...
What's with the alphabetical here? Looking at the code, it (correctly) sorts by Enum order, which is by time.
whatsapp-python
github_2023
python
56
filipporomani
github-advanced-security[bot]
@@ -397,3 +639,175 @@ logging.info(f"Status code: {r.status_code}") logging.debug(f"Response: {r.json()}") return r.json() + + + +class AsyncMessage(object): + # type: ignore + def __init__(self, id: int = None, data: dict = {}, instance: WhatsApp = None, content: str = "", to: str = ""...
## Clear-text logging of sensitive information This expression logs [sensitive data (private)](1) as clear text. [Show more details](https://github.com/filipporomani/whatsapp-python/security/code-scanning/34)
whatsapp-python
github_2023
python
56
filipporomani
github-advanced-security[bot]
@@ -397,3 +639,175 @@ logging.info(f"Status code: {r.status_code}") logging.debug(f"Response: {r.json()}") return r.json() + + + +class AsyncMessage(object): + # type: ignore + def __init__(self, id: int = None, data: dict = {}, instance: WhatsApp = None, content: str = "", to: str = ""...
## Clear-text logging of sensitive information This expression logs [sensitive data (private)](1) as clear text. [Show more details](https://github.com/filipporomani/whatsapp-python/security/code-scanning/32)
whatsapp-python
github_2023
python
56
filipporomani
github-advanced-security[bot]
@@ -397,3 +639,175 @@ logging.info(f"Status code: {r.status_code}") logging.debug(f"Response: {r.json()}") return r.json() + + + +class AsyncMessage(object): + # type: ignore + def __init__(self, id: int = None, data: dict = {}, instance: WhatsApp = None, content: str = "", to: str = ""...
## Clear-text logging of sensitive information This expression logs [sensitive data (private)](1) as clear text. [Show more details](https://github.com/filipporomani/whatsapp-python/security/code-scanning/33)
whatsapp-python
github_2023
python
52
filipporomani
github-advanced-security[bot]
@@ -53,7 +53,7 @@ return r.json() logging.info(f"Error uploading media {media}") logging.info(f"Status code: {r.status_code}") - logging.info(f"Response: {r.json()}") + logging.debug(f"Response: {r.json()}") # Changed to debug level
## Clear-text logging of sensitive information This expression logs [sensitive data (private)](1) as clear text. This expression logs [sensitive data (private)](2) as clear text. [Show more details](https://github.com/filipporomani/whatsapp-python/security/code-scanning/31)
enum
github_2023
go
9
orsinium-labs
orsinium
@@ -12,6 +12,11 @@ type Member[T comparable] struct { Value T } +// Matcher provides the customr matcher for value type. +type Matcher[V comparable] interface { + Match(v V) bool
Nitpick: maybe, calling it `Equal` would be better? My first association with `Match` is pattern matching.
enum
github_2023
go
9
orsinium-labs
orsinium
@@ -75,6 +80,28 @@ func (e Enum[M, V]) Parse(value V) *M { return e.v2m[value] } +// Match converts a raw value into a member like Parse. On the other hand, +// this returns the matched member if V implements Matcher interface, . +// +// This is especially beneficial when the value type is struct, which +// means ...
Suggestion: we can make it a function instead of a method, and then we can put constraints on V. This will make the function type-safe and faster (by avoiding runtime type assertions). Something like this: ```suggestion func Parse[M iMember[V], V Matcher[V]](e Enum[M, V], value V) *M { ```
enum
github_2023
go
4
orsinium-labs
orsinium
@@ -97,6 +98,12 @@ func (e Enum[M, V]) Members() []M { return e.members } +// Random returns a randomly selected member from the enum. +func (e Enum[M, V]) Random() M {
Let's make it accept a random seed, like here: https://github.com/life4/genesis/blob/master/slices/slice.go#L15 It might be useful for testing code relying on this method.
enum
github_2023
go
4
orsinium-labs
orsinium
@@ -97,6 +98,25 @@ func (e Enum[M, V]) Members() []M { return e.members } +// Choice returns a randomly selected member of the enum. +// It takes an optional seed for the random number generator. +// nil is returned only if the Enum contains no members. +func (e Enum[M, V]) Choice(seeds ...int64) *M {
Oh no, please, don't do that for "optional" arguments. Let's do like in genesis, always accept a seed number and default to the UNIX time if it's zero.
subtensor
github_2023
others
755
opentensor
distributedstatemachine
@@ -9,6 +9,28 @@ impl<T: Config> Pallet<T> { SubnetworkN::<T>::get(netuid) } + /// Returns a callback that sets the element at the given position to zero, doing nothing if the + /// position is out of bounds + fn clear_element_at<N>(position: u16) -> impl Fn(&mut Vec<N>)
What is the advantage of using this over `take` or `remove` ?
subtensor
github_2023
others
755
opentensor
distributedstatemachine
@@ -9,6 +9,22 @@ impl<T: Config> Pallet<T> { SubnetworkN::<T>::get(netuid) } + /// Sets value for the element at the given position if it exists. + pub fn set_element_at<N>(vec: &mut [N], position: usize, value: N) { + if let Some(element) = vec.get_mut(position) { + *element = v...
Can we optimise this by reducing the number of storage / writes , and number of function calls ? ```rust pub fn clear_neuron(netuid: u16, neuron_uid: u16) { let neuron_index: usize = neuron_uid.into(); let default_value = 0; for storage in &mut [ &mut Emission::<T>::get(netuid), &mut Trus...
subtensor
github_2023
others
755
opentensor
camfairchild
@@ -160,7 +160,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // `spec_version`, and `authoring_version` are the same between Wasm and native. // This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use // the compatible custom types. - spec_version: 208,...
```suggestion spec_version: 211, ``` Might need to bump here
subtensor
github_2023
others
1,392
opentensor
distributedstatemachine
@@ -1441,6 +1441,35 @@ pub mod pallet { ); Ok(()) } + + /// + /// + /// # Arguments + /// * `origin` - The origin of the call, which must be the root account. + /// * `ema_alpha_period` - Number of blocks for EMA price to halve + /// + ...
Should this be a global parameter ?
subtensor
github_2023
others
1,392
opentensor
camfairchild
@@ -1669,3 +1669,32 @@ fn test_sudo_set_subnet_owner_hotkey() { ); }); } + +// cargo test --package pallet-admin-utils --lib -- tests::test_sudo_set_ema_halving --exact --show-output +#[test] +fn test_sudo_set_ema_halving() { + new_test_ext().execute_with(|| { + let netuid: u16 = 1; + le...
```suggestion assert_eq!( AdminUtils::sudo_set_ema_price_halving_period( <<Test as Config>::RuntimeOrigin>::signed(U256::from(1)), netuid, to_be_set ), Err(DispatchError::BadOrigin) ); let value_after_0: u64 = pa...
subtensor
github_2023
others
1,374
opentensor
ales-otf
@@ -0,0 +1,23 @@ +# type-test + +test with ts + +## install papi + +npm install polkadot-api
for local deps we should stick either `yarn` or `npm`, but not both. also, as this dependency is in the`package.json`, wouldn't it be installed with the rest of the dependencies if you'd called `npm install` or `yarn`? or if it's supposed to be globally installed cli, shouldn't it be installed with `-G` flag then? and ...
subtensor
github_2023
others
1,374
opentensor
ales-otf
@@ -0,0 +1,23 @@ +# type-test + +test with ts + +## install papi + +npm install polkadot-api + +## polkadot api + +npx papi add devnet -w ws://10.0.0.11:9944 + +## get the new metadata + +sh get-metadta.sh + +## run all tests + +yarn test
please, also add how to run a single test case (it was described in the e2e js tests' readme.
subtensor
github_2023
others
1,374
opentensor
ales-otf
@@ -0,0 +1,23 @@ +# type-test + +test with ts + +## install papi + +npm install polkadot-api + +## polkadot api + +npx papi add devnet -w ws://10.0.0.11:9944 + +## get the new metadata + +sh get-metadta.sh
typo `metadta`
subtensor
github_2023
others
1,374
opentensor
ales-otf
@@ -0,0 +1,3 @@ +rm -rf .papi
given that the user should run this script to initialize tests, shouldn't the whole `.papi` directory be ignored?
subtensor
github_2023
typescript
1,374
opentensor
ales-otf
@@ -0,0 +1,82 @@ +import { Address } from "viem" +import { encodeAddress } from "@polkadot/util-crypto"; +import { MultiAddress } from '@polkadot-api/descriptors'; +import { ss58Address, KeyPair } from "@polkadot-labs/hdkd-helpers"; +import { hexToU8a } from "@polkadot/util"; +import { blake2AsU8a, decodeAddress } from...
`MultiAddress.Id(...)` is shorter than `convertSs58ToMultiAddress(...)` and it's pretty clear. do you really need this function?
subtensor
github_2023
typescript
1,374
opentensor
ales-otf
@@ -0,0 +1,82 @@ +import { Address } from "viem" +import { encodeAddress } from "@polkadot/util-crypto"; +import { MultiAddress } from '@polkadot-api/descriptors'; +import { ss58Address, KeyPair } from "@polkadot-labs/hdkd-helpers"; +import { hexToU8a } from "@polkadot/util"; +import { blake2AsU8a, decodeAddress } from...
it's better to define a global constant for chain ID and use it instead of hardcoding everywhere. it would be easier to refactor in case of the chain id change. also it makes the value clearer.
subtensor
github_2023
typescript
1,374
opentensor
ales-otf
@@ -0,0 +1,82 @@ +import { Address } from "viem" +import { encodeAddress } from "@polkadot/util-crypto"; +import { MultiAddress } from '@polkadot-api/descriptors'; +import { ss58Address, KeyPair } from "@polkadot-labs/hdkd-helpers"; +import { hexToU8a } from "@polkadot/util"; +import { blake2AsU8a, decodeAddress } from...
and if we had the global constant for chain ID (see comment above), we wouldn't need this function.
subtensor
github_2023
typescript
1,374
opentensor
ales-otf
@@ -0,0 +1,26 @@ +import assert from "assert" + +export const TAO = BigInt(1000000000) // 10^9 +export const ETHPerRAO = BigInt(1000000000) // 10^9
formatting is inconsistent here, I suppose it should be in capital snake case as the other global constants
subtensor
github_2023
typescript
1,374
opentensor
ales-otf
@@ -0,0 +1,633 @@ +export const wagmiContract = {
inconsistency of naming here too
subtensor
github_2023
others
1,374
opentensor
ales-otf
@@ -4,20 +4,38 @@ test with ts ## install papi -npm install polkadot-api +```bash +yarn add polkadot-api
i mean, it's already in `package.json`, so you don't need to run this command, it will be fetched with the rest of the dependencies when you `yarn` after cloning the repo.
subtensor
github_2023
others
1,374
opentensor
ales-otf
@@ -4,20 +4,38 @@ test with ts ## install papi -npm install polkadot-api +```bash +yarn add polkadot-api +``` ## polkadot api +```bash npx papi add devnet -w ws://10.0.0.11:9944 +``` ## get the new metadata -sh get-metadta.sh +```bash +sh get-metadata.sh +``` ## run all tests +```bash yarn test +`...
i suppose it shouldn't be a header? or at least it's broken
subtensor
github_2023
others
1,374
opentensor
ales-otf
@@ -4,20 +4,38 @@ test with ts ## install papi -npm install polkadot-api +```bash +yarn add polkadot-api +``` ## polkadot api +```bash npx papi add devnet -w ws://10.0.0.11:9944 +``` ## get the new metadata -sh get-metadta.sh +```bash +sh get-metadata.sh +``` ## run all tests +```bash yarn test +`...
missed this last time and confused now. as far as i understand it, this command does the same as `cargo update` in rust - it updates dependencies versions in the manifest. i suppose we wouldn't like it to be happened every time the repo is cloned. otherwise why this command is listed here particularly for this dependen...
subtensor
github_2023
others
1,386
opentensor
ales-otf
@@ -58,13 +58,19 @@ impl<T: Config> Pallet<T> { )?; // 3. Ensure the remove operation from the coldkey is a success. - let tao_staked: u64 = - Self::remove_balance_from_coldkey_account(&coldkey, stake_to_be_added)?; + let tao_staked: I96F32 =
we don't need this conversion, if we don't use the fee calculation from that function.
subtensor
github_2023
others
1,386
opentensor
ales-otf
@@ -148,12 +154,19 @@ impl<T: Config> Pallet<T> { } // 5. Ensure the remove operation from the coldkey is a success. - let tao_staked: u64 = Self::remove_balance_from_coldkey_account(&coldkey, possible_stake)?; + let tao_staked: I96F32 =
same thing about conversion here.
subtensor
github_2023
others
1,386
opentensor
ales-otf
@@ -1066,6 +1066,28 @@ impl<T: Config> Pallet<T> { Ok(()) } + + pub(crate) fn calculate_staking_fee( + netuid: u16, + hotkey: &T::AccountId, + alpha_estimate: I96F32, + ) -> u64 { + if (netuid == Self::get_root_netuid()) || (SubnetMechanism::<T>::get(netuid)) == 0 {
parenthesis are unnecessary here. surprised it passed clippy.
subtensor
github_2023
others
1,386
opentensor
ales-otf
@@ -1066,6 +1066,28 @@ impl<T: Config> Pallet<T> { Ok(()) } + + pub(crate) fn calculate_staking_fee( + netuid: u16, + hotkey: &T::AccountId, + alpha_estimate: I96F32, + ) -> u64 { + if (netuid == Self::get_root_netuid()) || (SubnetMechanism::<T>::get(netuid)) == 0 { + ...
just a personal preference, but it would be more readable with `return` statement here (guard style check), so you could avoid introducing `else` block.
subtensor
github_2023
others
1,170
opentensor
camfairchild
@@ -0,0 +1,89 @@ +use super::*; + +impl<T: Config> Pallet<T> { + /// Transfers stake from one coldkey to another. + /// + /// # Arguments + /// * `origin` - The origin of the transaction, which must be signed by the `origin_hotkey`. + /// * `hotkey` - The account ID of the hotkey from which the stake is ...
```suggestion // --- 6. Stake the amount of alpha for the destination coldkey ```
subtensor
github_2023
others
1,170
opentensor
camfairchild
@@ -0,0 +1,89 @@ +use super::*; + +impl<T: Config> Pallet<T> { + /// Transfers stake from one coldkey to another. + /// + /// # Arguments + /// * `origin` - The origin of the transaction, which must be signed by the `origin_hotkey`. + /// * `hotkey` - The account ID of the hotkey from which the stake is ...
```suggestion ensure!( Self::has_enough_stake_on_subnet(&hotkey, &coldkey, netuid, alpha_amount) ```
subtensor
github_2023
others
1,170
opentensor
camfairchild
@@ -0,0 +1,89 @@ +use super::*; + +impl<T: Config> Pallet<T> { + /// Transfers stake from one coldkey to another. + /// + /// # Arguments + /// * `origin` - The origin of the transaction, which must be signed by the `origin_hotkey`. + /// * `hotkey` - The account ID of the hotkey from which the stake is ...
```suggestion ``` If we swap here, we also have to swap back, otherwise we mess up the accounting. Also might be fine to not swap at all.
subtensor
github_2023
others
1,170
opentensor
camfairchild
@@ -0,0 +1,89 @@ +use super::*; + +impl<T: Config> Pallet<T> { + /// Transfers stake from one coldkey to another. + /// + /// # Arguments + /// * `origin` - The origin of the transaction, which must be signed by the `origin_hotkey`. + /// * `hotkey` - The account ID of the hotkey from which the stake is ...
```suggestion "StakeTransferred( coldkey:{:?}, destination_coldkey:{:?}, hotkey:{:?}, netuid:{:?}, alpha:{:?} )", coldkey.clone(), destination_coldkey.clone(), hotkey, netuid.clone(), alpha_amount ```
subtensor
github_2023
others
1,170
opentensor
camfairchild
@@ -0,0 +1,89 @@ +use super::*; + +impl<T: Config> Pallet<T> { + /// Transfers stake from one coldkey to another. + /// + /// # Arguments + /// * `origin` - The origin of the transaction, which must be signed by the `origin_hotkey`. + /// * `hotkey` - The account ID of the hotkey from which the stake is ...
```suggestion alpha_amount, ```
subtensor
github_2023
others
1,356
opentensor
open-junius
@@ -40,6 +40,157 @@ use subtensor_runtime_common::ProxyType; use crate::parser::{parse_pubkey, try_u16_from_u256}; use crate::{PrecompileExt, PrecompileHandleExt}; +// Old StakingPrecompile had ETH-precision in values, which was not alligned with Substrate API. So +// it's kinda deprecated, but exists for backward ...
need set the valid value.
subtensor
github_2023
others
1,347
opentensor
sam0x17
@@ -63,6 +64,10 @@ fn main() { track_lint(ForbidKeysRemoveCall::lint(&parsed_file)); track_lint(RequireFreezeStruct::lint(&parsed_file)); track_lint(RequireExplicitPalletIndex::lint(&parsed_file)); + + if is_test { + track_lint(ForbidSaturatingMath::lint(&parsed_file)); + ...
perfect
subtensor
github_2023
others
1,160
opentensor
camfairchild
@@ -1022,6 +1022,90 @@ pub fn weighted_median_col_sparse( median } +// Element-wise interpolation of two matrices: Result = A + ratio * (B - A). +// ratio is has intended range [0, 1] +// ratio=0: Result = A +// ratio=1: Result = B +#[allow(dead_code)] +pub fn interpolate(mat1: &[Vec<I32F32>], mat2: &[Vec<I32F3...
```suggestion // ratio has intended range [0, 1] ```
subtensor
github_2023
others
1,160
opentensor
camfairchild
@@ -1022,6 +1022,90 @@ pub fn weighted_median_col_sparse( median } +// Element-wise interpolation of two matrices: Result = A + ratio * (B - A). +// ratio is has intended range [0, 1]
```suggestion // ratio has intended range [0, 1] ```
subtensor
github_2023
others
1,159
opentensor
open-junius
@@ -379,6 +379,69 @@ impl<T: Config> Pallet<T> { TotalHotkeyAlpha::<T>::get(hotkey, netuid) } + /// Retrieves the total stake (alpha) for a given coldkey on a specific sunbet. + /// + /// This function performs the following steps: + /// 1. Retrieves the list of hotkeys associated with the c...
https://github.com/opentensor/subtensor/blob/devnet-ready/pallets/subtensor/src/staking/helpers.rs#L59 we can call it to get all stake for coldkey.
subtensor
github_2023
others
1,335
opentensor
distributedstatemachine
@@ -1449,3 +1450,18 @@ fn test_sudo_toggle_evm_precompile() { assert!(final_enabled); }); } +
🔥
subtensor
github_2023
others
1,314
opentensor
camfairchild
@@ -134,17 +145,40 @@ where current_share.saturating_add(U64F64::saturating_from_num(shares_per_update)), ); } else { - self.state_ops.set_denominator( - denominator - .saturating_sub(U64F64::saturating_from_num(...
```suggestion if (new_share ```
subtensor
github_2023
others
1,314
opentensor
camfairchild
@@ -3669,102 +3669,144 @@ fn test_add_stake_specific_stake_into_subnet_fail() { ); // Add stake as new hotkey - assert_noop!( - SubtensorModule::add_stake( - RuntimeOrigin::signed(coldkey_account_id), - hotkey_account_id, - netuid, - ...
```suggestion ```
subtensor
github_2023
others
1,314
opentensor
camfairchild
@@ -3669,102 +3669,144 @@ fn test_add_stake_specific_stake_into_subnet_fail() { ); // Add stake as new hotkey - assert_noop!( - SubtensorModule::add_stake( - RuntimeOrigin::signed(coldkey_account_id), - hotkey_account_id, - netuid, - ...
```suggestion ```
subtensor
github_2023
others
1,298
opentensor
camfairchild
@@ -332,4 +325,55 @@ impl<T: Config> Pallet<T> { Ok(true) } + + pub fn validate_serve_axon( + hotkey_id: &T::AccountId, + netuid: u16, + version: u32, + ip: u128, + port: u16, + ip_type: u8, + protocol: u8, + placeholder1: u8, + placehold...
Why not try these first. Less reads.
subtensor
github_2023
others
1,253
opentensor
bdmason
@@ -265,14 +337,14 @@ pub mod pallet { 0 } #[pallet::type_value] - /// Default stake delta. - pub fn DefaultStakeDelta<T: Config>() -> i128 { - 0 + /// Default value for max tempo + pub fn DefaultMaxTempo<T: Config>() -> u16 { + 30 // 1 hour.
If that's blocks it should be 300
subtensor
github_2023
others
1,253
opentensor
bdmason
@@ -685,25 +748,63 @@ pub mod pallet { #[pallet::type_value] /// Default value for applying pending items (e.g. childkeys). pub fn DefaultPendingCooldown<T: Config>() -> u64 { - 7200 + 1 } #[pallet::type_value] - /// Default minimum stake for setting childkeys. - pub fn De...
this comment still refers to the original figure
subtensor
github_2023
others
1,253
opentensor
bdmason
@@ -2,26 +2,54 @@ use super::*; use frame_support::pallet_prelude::{Decode, Encode}; use frame_support::storage::IterableStorageMap; use frame_support::IterableStorageDoubleMap; +use safe_math::*; use substrate_fixed::types::U64F64; extern crate alloc; use codec::Compact; -use sp_core::hexdisplay::AsBytesRef; -...
These RPC endpoints will no longer work
subtensor
github_2023
others
1,253
opentensor
bdmason
@@ -0,0 +1,352 @@ +use super::*; +use frame_support::IterableStorageMap; +use sp_core::Get; + +impl<T: Config> Pallet<T> { + /// Retrieves the unique identifier (UID) for the root network. + /// + /// The root network is a special case and has a fixed UID of 0. + /// + /// # Returns: + /// * 'u16': Th...
This second parameter should be using the mechid variable else the information from the emitted events will be wrong.
subtensor
github_2023
others
1,253
opentensor
cuteolaf
@@ -781,111 +859,209 @@ pub mod pallet { u16, // Value: take ValueQuery, >; - #[pallet::storage] - /// DMAP ( hot, cold ) --> stake | Returns the stake under a coldkey prefixed by hotkey. - pub type Stake<T: Config> = StorageDoubleMap< + /// DMAP ( netuid, parent ) --> (Vec<(proport...
```suggestion #[pallet::storage] // --- MAP ( netuid ) --> tao_in_emission | Returns the amount of tao emitted into this subnet on the last block. ```
subtensor
github_2023
others
1,253
opentensor
cuteolaf
@@ -781,111 +859,209 @@ pub mod pallet { u16, // Value: take ValueQuery, >; - #[pallet::storage] - /// DMAP ( hot, cold ) --> stake | Returns the stake under a coldkey prefixed by hotkey. - pub type Stake<T: Config> = StorageDoubleMap< + /// DMAP ( netuid, parent ) --> (Vec<(proport...
It is recommended to use **BoundedVec** for storage items like these
subtensor
github_2023
others
834
opentensor
distributedstatemachine
@@ -780,7 +780,7 @@ pub mod pallet { pub type HotkeyEmissionTempo<T> = StorageValue<_, u64, ValueQuery, DefaultHotkeyEmissionTempo<T>>; #[pallet::storage] - /// Map ( hot ) --> emission | Accumulated hotkey emission. + /// Name corrected: PendingdHotkeyEmission => PendingHotkeyEmission
Do we need this comment ?
subtensor
github_2023
others
834
opentensor
distributedstatemachine
@@ -939,10 +949,14 @@ pub mod pallet { pub type BlocksSinceLastStep<T> = StorageMap<_, Identity, u16, u64, ValueQuery, DefaultBlocksSinceLastStep<T>>; #[pallet::storage] - /// --- MAP ( netuid ) --> last_mechanism_step_block + /// Name corrected: LastMechansimStepBlock => LastMechanismStepBlock
same
subtensor
github_2023
others
1,201
opentensor
open-junius
@@ -3,71 +3,75 @@ use pallet_evm::{ BalanceConverter, ExitError, ExitSucceed, PrecompileFailure, PrecompileHandle, PrecompileOutput, PrecompileResult, }; +use precompile_utils::prelude::RuntimeHelper; use sp_core::U256; -use sp_runtime::traits::{Dispatchable, UniqueSaturatedInto}; +use sp_runtime::traits::U...
it is better to return Err if the method not found in the contract.
subtensor
github_2023
others
1,201
opentensor
open-junius
@@ -3,71 +3,75 @@ use pallet_evm::{ BalanceConverter, ExitError, ExitSucceed, PrecompileFailure, PrecompileHandle, PrecompileOutput, PrecompileResult, }; +use precompile_utils::prelude::RuntimeHelper; use sp_core::U256; -use sp_runtime::traits::{Dispatchable, UniqueSaturatedInto}; +use sp_runtime::traits::U...
the same as last comment. return Err if the parameter is invalid.
subtensor
github_2023
others
1,089
opentensor
gztensor
@@ -0,0 +1,982 @@ +use crate::precompiles::{dispatch, get_method_id, get_slice}; +use crate::{Runtime, RuntimeCall}; +use pallet_evm::{ + ExitError, ExitSucceed, PrecompileFailure, PrecompileHandle, PrecompileOutput, PrecompileResult, +}; +use sp_core::U256; +use sp_std::vec; + +pub const SUBNET_PRECOMPILE_INDEX: u6...
This should be named SUBNET_CONTRACT_ADDRESS
subtensor
github_2023
others
1,205
opentensor
sam0x17
@@ -179,16 +190,20 @@ impl<T: Config> Pallet<T> { /// # Returns /// /// * `bool` - Returns true if the SubnetIdentity is valid, false otherwise. - pub fn is_valid_subnet_identity(identity: &SubnetIdentityOf) -> bool { + pub fn is_valid_subnet_identity(identity: &SubnetIdentityOfV2) -> bool { ...
lol
subtensor
github_2023
others
1,150
opentensor
gztensor
@@ -53,10 +136,282 @@ impl NeuronPrecompile { exit_status: ExitError::InvalidRange, }); } + let netuid = parse_netuid(data, 30)?; let (hotkey, _) = get_pubkey(get_slice(data, 32, 64)?)?; Ok((netuid, hotkey)) } + + fn parse_netuid_dests_weight...
I think it is possible to execute a transaction that packs 100_000 bytes of data and sets first_position value at 0xFFFF, which will overflow this line and panic. Please use safe math.
subtensor
github_2023
others
1,116
opentensor
open-junius
@@ -77,6 +77,17 @@ fn localnet_genesis( get_account_id_from_seed::<sr25519::Public>("Ferdie"), 2000000000000u128, ), + // ETH + ( + // Alith
please add the ETH address in the doc
subtensor
github_2023
others
1,110
opentensor
gztensor
@@ -0,0 +1,14 @@ +pragma solidity ^0.8.0; + +address constant ISUBNETS_ADDRESS = 0x0000000000000000000000000000000000000804; + +interface ISubnets {
This naming is a bit confusing. Please rename `ISubnets` to `INeuron` and files: `subnets.sol/abi` to `neuron.sol/abi`.
subtensor
github_2023
others
1,110
opentensor
gztensor
@@ -0,0 +1,58 @@ +use pallet_evm::{ExitError, PrecompileFailure, PrecompileHandle, PrecompileResult}; + +use crate::precompiles::{dispatch, get_method_id, get_slice}; +use sp_std::vec; + +use crate::{Runtime, RuntimeCall}; +pub const NEURON_PRECOMPILE_INDEX: u64 = 2052; + +// this is neuron smart contract's(0x000000000...
Could you please move `parse_pub_key` and `parse_netuid` to the common space like you did with `dispatch`, for example, and use them here?
subtensor
github_2023
others
1,110
opentensor
gztensor
@@ -0,0 +1,148 @@ +use crate::precompiles::{dispatch, get_method_id, get_pubkey, get_slice}; +use crate::{Runtime, RuntimeCall}; +use pallet_evm::{ExitError, PrecompileFailure, PrecompileHandle, PrecompileResult}; +use sp_runtime::AccountId32; +use sp_std::vec; + +pub const SUBNET_PRECOMPILE_INDEX: u64 = 2051; +// thre...
What happens if user passes 0xFFFF size? Also, what happens if data size is lower than subent_name_len? We should gracefully handle this without panics.
subtensor
github_2023
others
1,213
opentensor
camfairchild
@@ -2649,6 +2650,57 @@ fn test_add_stake_limit_ok() { }); } +#[test] +fn test_add_stake_limit_fill_or_kill() { + new_test_ext(1).execute_with(|| { + let hotkey_account_id = U256::from(533453); + let coldkey_account_id = U256::from(55453); + let amount = 300_000_000_000; + + // add...
```suggestion // Force-set alpha in and tao reserve to make price equal 1.5 ```
subtensor
github_2023
others
1,213
opentensor
camfairchild
@@ -2709,3 +2762,58 @@ fn test_remove_stake_limit_ok() { ); }); } + +#[test] +fn test_remove_stake_limit_fill_or_kill() { + new_test_ext(1).execute_with(|| { + let hotkey_account_id = U256::from(533453); + let coldkey_account_id = U256::from(55453); + let stake_amount = 300_000_00...
```suggestion // Force-set alpha in and tao reserve to make price equal 1.5 ```
subtensor
github_2023
others
1,213
opentensor
camfairchild
@@ -240,16 +286,23 @@ impl<T: Config> Pallet<T> { alpha_unstaked ); - // 2. Validate the user input - Self::validate_remove_stake(&coldkey, &hotkey, netuid, alpha_unstaked)?; - - // 3. Calcaulate the maximum amount that can be executed with price limit + // 2. Calcaul...
```suggestion // 4. Swap the alpha to tao and update counters for this subnet. ```
subtensor
github_2023
others
1,204
opentensor
camfairchild
@@ -457,155 +457,148 @@ impl<T: Config> Pallet<T> { } } - /// Swaps TAO for the alpha token on the subnet. + /// Calculates Some(Alpha) returned from pool by staking operation + /// if liquidity allows that. If not, returns None. /// - /// Updates TaoIn, AlphaIn, and AlphaOut - pub f...
Why are we decreasing the volume? Shouldn't volume always be additive? Looks like we've been subtracting from it in both places too.... ```suggestion SubnetVolume::<T>::mutate(netuid, |total| { *total = total.saturating_add(tao); }); ```
subtensor
github_2023
others
1,204
opentensor
camfairchild
@@ -457,155 +457,148 @@ impl<T: Config> Pallet<T> { } } - /// Swaps TAO for the alpha token on the subnet. + /// Calculates Some(Alpha) returned from pool by staking operation + /// if liquidity allows that. If not, returns None. /// - /// Updates TaoIn, AlphaIn, and AlphaOut - pub f...
```suggestion SubnetVolume::<T>::mutate(netuid, |total| { *total = total.saturating_add(tao); }); ```
subtensor
github_2023
others
1,189
opentensor
distributedstatemachine
@@ -1114,10 +1126,15 @@ fn test_do_swap_success() { &coldkey, destination_netuid, ); + let alpha_fee = + I96F32::from_num(fee) / SubtensorModule::get_alpha_price(destination_netuid); + let expected_value = I96F32::from_num(alpha_before) + * Subtenso...
@camfairchild do we want a saturating div here ?
subtensor
github_2023
others
1,183
opentensor
camfairchild
@@ -584,9 +584,9 @@ mod dispatches { origin: OriginFor<T>, hotkey: T::AccountId, netuid: u16, - amount_staked: u64,
If we change this we'll need to update a lot of client code
subtensor
github_2023
others
1,024
opentensor
camfairchild
@@ -48,7 +48,7 @@ impl<T: Config> Pallet<T> { // --- 3. Drain the subnet block emission and accumulate it as subnet emission, which increases until the tempo is reached in #4. // subnet_blockwise_emission -> subnet_pending_emission for netuid in subnets.clone().iter() { - if *netui...
```suggestion if *netuid == 0 || !Self::is_registration_allowed(*netuid) { ```