Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions contracts/token/DSTokenMTS.sol
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ contract DSTokenMTS is DSToken {
return code != 0;
}

function isBankTransferHookSuppressed() external view returns (bool) {
return suppressPostTransferRecord;
}

function postTransfer(
address _from,
address _to,
Expand Down
28 changes: 27 additions & 1 deletion test/dstoken-injective-mts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ describeInjective('DS Token Injective MTS integration', function() {
it('uses the Bank precompile and permissions hooks for regulated transfers', async function() {
assertInjectivedKeys();

const [owner, holder, blocked] = await hre.ethers.getSigners();
const [owner, holder, blocked, issuerWallet] = await hre.ethers.getSigners();

const contracts = await hre.run('deploy-all', {
name: 'Token Example 1',
Expand All @@ -204,6 +204,7 @@ describeInjective('DS Token Injective MTS integration', function() {
const registryService = contracts.registryService;
const complianceService = contracts.complianceService;
const complianceConfigurationService = contracts.complianceConfigurationService;
const walletManager = contracts.walletManager;
const tokenAddress = await dsToken.getAddress();
const denom = `erc20:${tokenAddress}`;

Expand Down Expand Up @@ -256,5 +257,30 @@ describeInjective('DS Token Injective MTS integration', function() {

expect(await dsToken.balanceOf(holder.address)).to.equal(375);
expect(await dsToken.balanceOf(blocked.address)).to.equal(0);

await (await walletManager.addIssuerWallet(issuerWallet.address)).wait();

await expect(dsToken.connect(holder).transfer(issuerWallet.address, 1)).to.be.reverted;
expect(() => bankSend('user1', injAddressFromEth(issuerWallet.address), denom, 1n)).to.throw(/transfer is restricted by EVM hook/i);

await (await dsToken.seize(holder.address, issuerWallet.address, 100, 'test partial seize')).wait();

expect(await dsToken.totalSupply()).to.equal(500);
expect(await dsToken.balanceOf(holder.address)).to.equal(275);
expect(await dsToken.balanceOf(issuerWallet.address)).to.equal(100);
expect(await dsToken.balanceOfInvestor(INVESTORS.INVESTOR_ID.INVESTOR_ID_1)).to.equal(275);
expect(await dsToken.walletCount()).to.equal(3);
expect(await complianceService.getTotalInvestorsCount()).to.equal(2);

await (await dsToken.seize(holder.address, issuerWallet.address, 275, 'test full seize')).wait();

expect(await dsToken.totalSupply()).to.equal(500);
expect(await dsToken.balanceOf(holder.address)).to.equal(0);
expect(await dsToken.balanceOf(owner.address)).to.equal(125);
expect(await dsToken.balanceOf(issuerWallet.address)).to.equal(375);
expect(await dsToken.balanceOfInvestor(INVESTORS.INVESTOR_ID.INVESTOR_ID_1)).to.equal(0);
expect(await dsToken.balanceOfInvestor(INVESTORS.INVESTOR_ID.INVESTOR_ID_2)).to.equal(125);
expect(await dsToken.walletCount()).to.equal(2);
expect(await complianceService.getTotalInvestorsCount()).to.equal(1);
Comment on lines +268 to +284

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail
rg -n '"ethers"\s*:' --glob 'package*.json' --glob '*lock*'
rg -n 'to\.equal\([0-9]+' test/dstoken-injective-mts.test.ts

Repository: InjectiveLabs/dstoken

Length of output: 159


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail
printf '%s\n' '--- candidate files ---'
git ls-files | rg '(^|/)(package[^/]*\.json|.*lock.*|dstoken-injective-mts\.test\.ts)$' || true
printf '%s\n' '--- test file matches ---'
test_file="$(git ls-files | rg '(^|/)dstoken-injective-mts\.test\.ts$' | head -n 1)"
printf 'test_file=%s\n' "$test_file"
rg -n -C 3 'to\.equal\([0-9]+|totalSupply|walletCount|getTotalInvestorsCount|balanceOfInvestor' "$test_file" || true
printf '%s\n' '--- dependency declarations ---'
while IFS= read -r f; do
  printf '\n[%s]\n' "$f"
  rg -n -C 2 '"ethers"\s*:' "$f" || true
done < <(git ls-files | rg '(^|/)(package[^/]*\.json|.*lock.*)$')

Repository: InjectiveLabs/dstoken

Length of output: 3828


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail
printf '%s\n' '--- package.json ethers declaration ---'
rg -n -C 3 '"ethers"\s*:' package.json
printf '%s\n' '--- package-lock ethers entries ---'
rg -n -C 3 '"node_modules/ethers"|"ethers"\s*:' package-lock.json | head -n 80
printf '%s\n' '--- pnpm-lock ethers entries ---'
rg -n -C 3 '(^|/| )ethers(@|:)|ethers:' pnpm-lock.yaml | head -n 80
printf '%s\n' '--- numeric equality assertions in the test ---'
rg -n 'to\.equal\([0-9]+[n]?\)' test/dstoken-injective-mts.test.ts
printf '%s\n' '--- return types for asserted contract methods ---'
rg -n -C 4 'function (totalSupply|balanceOf|balanceOfInvestor|walletCount|getTotalInvestorsCount)|totalSupply\(|balanceOfInvestor\(|walletCount\(|getTotalInvestorsCount\(' contracts interfaces src test | head -n 240

Repository: InjectiveLabs/dstoken

Length of output: 28384


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail
python3 - <<'PY'
import json
import re
from pathlib import Path

package = json.loads(Path("package.json").read_text())
lock = json.loads(Path("package-lock.json").read_text())
test = Path("test/dstoken-injective-mts.test.ts").read_text()
source = Path("contracts/token/IDSToken.sol").read_text()

declared = package["devDependencies"]["ethers"]
locked = lock["packages"]["node_modules/ethers"]["version"]
block = "\n".join(test.splitlines()[267:284])
assertions = re.findall(r"\.to\.equal\((\d+)\)", block)
uint256_methods = {
    name: bool(re.search(
        rf"function\s+{name}\b[\s\S]*?returns\s*\(\s*uint256",
        source,
    ))
    for name in ("walletCount", "balanceOfInvestor")
}
print({
    "declared_ethers": declared,
    "locked_ethers": locked,
    "bare_numeric_assertions_in_lines_268_284": len(assertions),
    "asserted_values": assertions,
    "IDSToken_uint256_methods": uint256_methods,
})
assert locked.startswith("6.")
assert len(assertions) == 16
assert all(uint256_methods.values())
PY

Repository: InjectiveLabs/dstoken

Length of output: 539


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail
printf '%s\n' '--- asserted function declarations ---'
rg -n -U 'function (totalSupply|balanceOf|balanceOfInvestor|walletCount|getTotalInvestorsCount)\b[\s\S]{0,180}?returns\s*\(\s*uint256' contracts
printf '%s\n' '--- corrected read-only invariant check ---'
python3 - <<'PY'
import json
import re
from pathlib import Path

package = json.loads(Path("package.json").read_text())
lock = json.loads(Path("package-lock.json").read_text())
test_lines = Path("test/dstoken-injective-mts.test.ts").read_text().splitlines()
block = "\n".join(test_lines[267:284])
values = re.findall(r"\.to\.equal\((\d+)\)", block)

print("declared ethers:", package["devDependencies"]["ethers"])
print("locked ethers:", lock["packages"]["node_modules/ethers"]["version"])
print("bare numeric assertions at lines 268-284:", len(values))
print("values:", values)

assert lock["packages"]["node_modules/ethers"]["version"].startswith("6.")
assert len(values) == 14
PY

Repository: InjectiveLabs/dstoken

Length of output: 2191


Use bigint values in the numeric assertions. Ethers 6 returns these uint256 values as bigint, so update all 14 expected values in lines 268–284 with the n suffix.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/dstoken-injective-mts.test.ts` around lines 268 - 284, Update every
numeric expected value in the assertions surrounding dsToken.totalSupply,
balanceOf, balanceOfInvestor, walletCount, and
complianceService.getTotalInvestorsCount to bigint literals by adding the n
suffix, including all 14 values before and after seize.

});
});