Skip to content

Conversation

raksha-r7
Copy link
Contributor

Ticket: SC-3017

import { assert as SinonAssert, spy } from 'sinon';
import { MoveStakeBuilder } from '../../../src/lib/moveStakeBuilder';
import utils from '../../../src/lib/utils';
import { accounts, mockTssSignature, rawTx, genesisHash, chainName } from '../../resources';

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note test

Unused import rawTx.

Copilot Autofix

AI 1 day ago

To fix the problem, we should remove the unused import rawTx from the import statement on line 6 in modules/sdk-coin-tao/test/unit/transactionBuilder/moveStakeBuilder.ts.

  • Specifically, edit the import statement to exclude rawTx, retaining the other imports if they are used.
  • Only the import line needs modification; no further code edits are required unless other unused imports exist (but CodeQL flagged only rawTx).

Suggested changeset 1
modules/sdk-coin-tao/test/unit/transactionBuilder/moveStakeBuilder.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/modules/sdk-coin-tao/test/unit/transactionBuilder/moveStakeBuilder.ts b/modules/sdk-coin-tao/test/unit/transactionBuilder/moveStakeBuilder.ts
--- a/modules/sdk-coin-tao/test/unit/transactionBuilder/moveStakeBuilder.ts
+++ b/modules/sdk-coin-tao/test/unit/transactionBuilder/moveStakeBuilder.ts
@@ -3,7 +3,7 @@
 import { assert as SinonAssert, spy } from 'sinon';
 import { MoveStakeBuilder } from '../../../src/lib/moveStakeBuilder';
 import utils from '../../../src/lib/utils';
-import { accounts, mockTssSignature, rawTx, genesisHash, chainName } from '../../resources';
+import { accounts, mockTssSignature, genesisHash, chainName } from '../../resources';
 import { buildTestConfig } from './base';
 import { testnetMaterial } from '../../../src/resources';
 import { InvalidTransactionError } from '@bitgo/sdk-core';
EOF
@@ -3,7 +3,7 @@
import { assert as SinonAssert, spy } from 'sinon';
import { MoveStakeBuilder } from '../../../src/lib/moveStakeBuilder';
import utils from '../../../src/lib/utils';
import { accounts, mockTssSignature, rawTx, genesisHash, chainName } from '../../resources';
import { accounts, mockTssSignature, genesisHash, chainName } from '../../resources';
import { buildTestConfig } from './base';
import { testnetMaterial } from '../../../src/resources';
import { InvalidTransactionError } from '@bitgo/sdk-core';
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved

@raksha-r7
Copy link
Contributor Author

@claude review

@raksha-r7 raksha-r7 marked this pull request as ready for review September 9, 2025 15:21
@raksha-r7 raksha-r7 requested a review from a team as a code owner September 9, 2025 15:21
@Doddanna17 Doddanna17 requested a review from Copilot September 10, 2025 03:40
Copilot

This comment was marked as outdated.

Copy link
Contributor

@Doddanna17 Doddanna17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the comments

@raksha-r7 raksha-r7 force-pushed the SC-3017 branch 3 times, most recently from d196a1b to 68ad0d3 Compare September 10, 2025 10:17
@Doddanna17 Doddanna17 requested a review from Copilot September 10, 2025 11:54
Copilot

This comment was marked as outdated.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for moving stake between hotkeys in the TAO network by implementing a new moveStakeBuilder transaction builder.

  • Adds MoveStakeBuilder and MoveStakeTransaction classes to handle move stake operations
  • Extends transaction factory to support move stake transaction type
  • Adds comprehensive test coverage for the move stake functionality

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
modules/sdk-coin-tao/test/unit/transactionBuilder/moveStakeBuilder.ts Comprehensive test suite for MoveStakeBuilder functionality
modules/sdk-coin-tao/src/lib/transactionBuilderFactory.ts Adds getMoveStakeBuilder method and factory routing
modules/sdk-coin-tao/src/lib/moveStakeTransaction.ts Transaction class for move stake operations
modules/sdk-coin-tao/src/lib/moveStakeBuilder.ts Builder class for constructing move stake transactions
modules/sdk-coin-tao/src/lib/index.ts Exports new move stake classes
modules/sdk-coin-tao/src/lib/iface.ts Adds MoveStakeTxData interface
modules/sdk-coin-tao/src/lib/constants.ts Defines TAO network constants
modules/abstract-substrate/src/lib/utils.ts Adds isMoveStake utility method
modules/abstract-substrate/src/lib/txnSchema.ts Adds validation schema for move stake transactions
modules/abstract-substrate/src/lib/iface.ts Adds move stake interfaces and method names

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +103 to +107
explanation.outputs[0].should.deepEqual({
address: '5Ffp1wJCPu4hzVDTo7XaMLqZSvSadyUQmxWPDw74CBjECSoq',
amount: '9007199254740995',
tokenName: 'ttao:apex',
});
Copy link
Preview

Copilot AI Sep 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded tokenName 'ttao:apex' appears to be a magic value. Consider using a constant or deriving it from the test data to make the test more maintainable and less brittle.

Copilot uses AI. Check for mistakes.

Comment on lines +362 to +366
mockBuilder['_method'] = {
name: 'transferKeepAlive',
args: { dest: { id: 'test' }, value: '1000' },
pallet: 'balances',
};
Copy link
Preview

Copilot AI Sep 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct access to private fields using bracket notation makes the test brittle and violates encapsulation. Consider adding a test-only setter method or refactoring the builder to support this test scenario more cleanly.

Copilot uses AI. Check for mistakes.

Comment on lines +144 to +151
private validateNetuid(netuid: string): void {
const netuidNum = Number(netuid);
if (isNaN(netuidNum) || !Number.isInteger(netuidNum) || netuidNum < 0 || netuidNum > TAO_CONSTANTS.MAX_NETUID) {
throw new InvalidTransactionError(
`Invalid netuid: ${netuid}. Netuid must be between 0 and ${TAO_CONSTANTS.MAX_NETUID}.`
);
}
}
Copy link
Preview

Copilot AI Sep 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The validation allows decimal numbers that convert to integers (e.g., '5.0' becomes 5). Use parseInt() with radix 10 and check if the result equals the original input, or use a regex to ensure the input contains only digits.

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants