fix(blockchain-service): 扩大充值金额字段精度
- amount 字段从 Decimal(36,18) 改为 Decimal(78,0) 支持超大金额 - amountFormatted 字段从 Decimal(20,8) 改为 Decimal(36,8) 修复问题:100亿 USDT 充值导致 numeric field overflow 错误 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
e95ac15605
commit
1d817a5be2
|
|
@ -409,7 +409,12 @@
|
|||
"Bash(npx ts-node:*)",
|
||||
"Bash(node -e \"\nconst { ethers } = require\\(''ethers''\\);\n\nconst KAVA_TESTNET_RPC = ''https://evm.testnet.kava.io'';\nconst privateKey = ''0xd42a6e6021ebd884f3f179d3793a32e97b9f1001db6ff44441ec455d748b9aa6'';\nconst USDT_CONTRACT = ''0xc12f6A4A7Fd0965085B044A67a39CcA2ff7fe0dF'';\nconst TO_ADDRESS = ''0xab2ecb00ef473cfbbf3df13faa7ed3ff84eea229'';\n\nasync function transfer\\(\\) {\n const provider = new ethers.JsonRpcProvider\\(KAVA_TESTNET_RPC\\);\n const wallet = new ethers.Wallet\\(privateKey, provider\\);\n \n const abi = [''function transfer\\(address to, uint256 amount\\) returns \\(bool\\)'', ''function balanceOf\\(address\\) view returns \\(uint256\\)''];\n const contract = new ethers.Contract\\(USDT_CONTRACT, abi, wallet\\);\n \n const amount = BigInt\\(1000000\\) * BigInt\\(1000000\\);\n \n console.log\\(''Transferring 1,000,000 USDT to'', TO_ADDRESS\\);\n const tx = await contract.transfer\\(TO_ADDRESS, amount, { gasLimit: 100000 }\\);\n console.log\\(''TX Hash:'', tx.hash\\);\n await tx.wait\\(\\);\n \n const newBalance = await contract.balanceOf\\(TO_ADDRESS\\);\n console.log\\(''New balance:'', Number\\(newBalance\\) / 1e6, ''USDT''\\);\n}\n\ntransfer\\(\\).catch\\(e => console.error\\(''Error:'', e.message\\)\\);\n\")",
|
||||
"Bash(node -e \"\nconst { ethers } = require\\(''ethers''\\);\n\nconst KAVA_TESTNET_RPC = ''https://evm.testnet.kava.io'';\nconst privateKey = ''0xd42a6e6021ebd884f3f179d3793a32e97b9f1001db6ff44441ec455d748b9aa6'';\nconst USDT_CONTRACT = ''0xc12f6A4A7Fd0965085B044A67a39CcA2ff7fe0dF'';\nconst TO_ADDRESS = ''0x17e9109ac3d2921c7731f3e72749bc13043a076c'';\n\nasync function transfer\\(\\) {\n const provider = new ethers.JsonRpcProvider\\(KAVA_TESTNET_RPC\\);\n const wallet = new ethers.Wallet\\(privateKey, provider\\);\n \n const abi = [''function transfer\\(address to, uint256 amount\\) returns \\(bool\\)'', ''function balanceOf\\(address\\) view returns \\(uint256\\)''];\n const contract = new ethers.Contract\\(USDT_CONTRACT, abi, wallet\\);\n \n const amount = BigInt\\(1000000\\) * BigInt\\(1000000\\);\n \n console.log\\(''Transferring 1,000,000 USDT to'', TO_ADDRESS\\);\n const tx = await contract.transfer\\(TO_ADDRESS, amount, { gasLimit: 100000 }\\);\n console.log\\(''TX Hash:'', tx.hash\\);\n await tx.wait\\(\\);\n \n const newBalance = await contract.balanceOf\\(TO_ADDRESS\\);\n console.log\\(''New balance:'', Number\\(newBalance\\) / 1e6, ''USDT''\\);\n}\n\ntransfer\\(\\).catch\\(e => console.error\\(''Error:'', e.message\\)\\);\n\")",
|
||||
"Bash(powershell -Command \"\\(Get-Content ''reward-application.service.ts''\\) -replace \"\"this\\\\.logger\\\\.log\\\\\\(\\\\`Distributing rewards for order \\\\$\\\\{params\\\\.sourceOrderNo\\\\}, accountSequence=\\\\$\\\\{params\\\\.sourceAccountSequence\\\\}\\\\`\\\\\\);\\\\r?\\\\n\\\\r?\\\\n // 1\\\\. 计算所有奖励\"\", \"\"this.logger.log\\(\\\\`Distributing rewards for order \\\\$\\\\{params.sourceOrderNo\\\\}, accountSequence=\\\\$\\\\{params.sourceAccountSequence\\\\}\\\\`\\);\\\\`n\\\\`n // 幂等性检查:如果该订单已经分配过奖励,跳过处理\\\\`n const existingRewards = await this.rewardLedgerEntryRepository.findBySourceOrderNo\\(params.sourceOrderNo\\);\\\\`n if \\(existingRewards.length > 0\\) {\\\\`n this.logger.warn\\(\\\\`Order \\\\$\\\\{params.sourceOrderNo\\\\} already has \\\\$\\\\{existingRewards.length\\\\} rewards distributed, skipping \\(idempotent\\)\\\\`\\);\\\\`n return;\\\\`n }\\\\`n\\\\`n // 1. 计算所有奖励\"\" | Set-Content ''reward-application.service.ts'' -Encoding UTF8\")"
|
||||
"Bash(powershell -Command \"\\(Get-Content ''reward-application.service.ts''\\) -replace \"\"this\\\\.logger\\\\.log\\\\\\(\\\\`Distributing rewards for order \\\\$\\\\{params\\\\.sourceOrderNo\\\\}, accountSequence=\\\\$\\\\{params\\\\.sourceAccountSequence\\\\}\\\\`\\\\\\);\\\\r?\\\\n\\\\r?\\\\n // 1\\\\. 计算所有奖励\"\", \"\"this.logger.log\\(\\\\`Distributing rewards for order \\\\$\\\\{params.sourceOrderNo\\\\}, accountSequence=\\\\$\\\\{params.sourceAccountSequence\\\\}\\\\`\\);\\\\`n\\\\`n // 幂等性检查:如果该订单已经分配过奖励,跳过处理\\\\`n const existingRewards = await this.rewardLedgerEntryRepository.findBySourceOrderNo\\(params.sourceOrderNo\\);\\\\`n if \\(existingRewards.length > 0\\) {\\\\`n this.logger.warn\\(\\\\`Order \\\\$\\\\{params.sourceOrderNo\\\\} already has \\\\$\\\\{existingRewards.length\\\\} rewards distributed, skipping \\(idempotent\\)\\\\`\\);\\\\`n return;\\\\`n }\\\\`n\\\\`n // 1. 计算所有奖励\"\" | Set-Content ''reward-application.service.ts'' -Encoding UTF8\")",
|
||||
"Bash(git commit -m \"$\\(cat <<''EOF''\nfix\\(reward-service\\): 添加奖励分配幂等性检查\n\n- distributeRewards 方法添加幂等性检查,防止同一订单重复分配奖励\n- distributeRewardsForExpiredContract 方法同样添加幂等性检查\n- 通过 findBySourceOrderNo 检查订单是否已分配过奖励\n\n修复问题:recovery job 重复触发导致同一订单奖励被多次分配\n\n🤖 Generated with [Claude Code]\\(https://claude.com/claude-code\\)\n\nCo-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>\nEOF\n\\)\")",
|
||||
"Bash(node -e \"\nconst { ethers } = require\\(''ethers''\\);\n\nconst KAVA_TESTNET_RPC = ''https://evm.testnet.kava.io'';\nconst privateKey = ''0xd42a6e6021ebd884f3f179d3793a32e97b9f1001db6ff44441ec455d748b9aa6'';\nconst USDT_CONTRACT = ''0xc12f6A4A7Fd0965085B044A67a39CcA2ff7fe0dF'';\nconst TO_ADDRESS = ''0x184571959d74a6e771ad4e5b2fbe006951dd29ec'';\n\nasync function transfer\\(\\) {\n const provider = new ethers.JsonRpcProvider\\(KAVA_TESTNET_RPC\\);\n const wallet = new ethers.Wallet\\(privateKey, provider\\);\n \n const abi = [''function transfer\\(address to, uint256 amount\\) returns \\(bool\\)'', ''function balanceOf\\(address\\) view returns \\(uint256\\)''];\n const contract = new ethers.Contract\\(USDT_CONTRACT, abi, wallet\\);\n \n // 10,000,000 USDT = 10000000 * 1e6 \\(6 decimals\\)\n const amount = BigInt\\(10000000\\) * BigInt\\(1000000\\);\n \n console.log\\(''Transferring 10,000,000 USDT to'', TO_ADDRESS\\);\n const tx = await contract.transfer\\(TO_ADDRESS, amount, { gasLimit: 100000 }\\);\n console.log\\(''TX Hash:'', tx.hash\\);\n await tx.wait\\(\\);\n \n const newBalance = await contract.balanceOf\\(TO_ADDRESS\\);\n console.log\\(''New balance:'', Number\\(newBalance\\) / 1e6, ''USDT''\\);\n}\n\ntransfer\\(\\).catch\\(e => console.error\\(''Error:'', e.message\\)\\);\n\")",
|
||||
"Bash(node -e \"\nconst { ethers } = require\\(''ethers''\\);\n\nconst KAVA_TESTNET_RPC = ''https://evm.testnet.kava.io'';\nconst privateKey = ''0xd42a6e6021ebd884f3f179d3793a32e97b9f1001db6ff44441ec455d748b9aa6'';\nconst USDT_CONTRACT = ''0xc12f6A4A7Fd0965085B044A67a39CcA2ff7fe0dF'';\nconst TO_ADDRESS = ''0x184571959d74a6e771ad4e5b2fbe006951dd29ec'';\n\nasync function transfer\\(\\) {\n const provider = new ethers.JsonRpcProvider\\(KAVA_TESTNET_RPC\\);\n const wallet = new ethers.Wallet\\(privateKey, provider\\);\n \n const abi = [''function transfer\\(address to, uint256 amount\\) returns \\(bool\\)'', ''function balanceOf\\(address\\) view returns \\(uint256\\)''];\n const contract = new ethers.Contract\\(USDT_CONTRACT, abi, wallet\\);\n \n // 10,000,000,000 USDT \\(100亿\\) = 10000000000 * 1e6 \\(6 decimals\\)\n const amount = BigInt\\(10000000000\\) * BigInt\\(1000000\\);\n \n console.log\\(''Transferring 10,000,000,000 USDT to'', TO_ADDRESS\\);\n const tx = await contract.transfer\\(TO_ADDRESS, amount, { gasLimit: 100000 }\\);\n console.log\\(''TX Hash:'', tx.hash\\);\n await tx.wait\\(\\);\n \n const newBalance = await contract.balanceOf\\(TO_ADDRESS\\);\n console.log\\(''New balance:'', Number\\(newBalance\\) / 1e6, ''USDT''\\);\n}\n\ntransfer\\(\\).catch\\(e => console.error\\(''Error:'', e.message\\)\\);\n\")",
|
||||
"Bash(node -e \"\nconst { ethers } = require\\(''ethers''\\);\n\nconst KAVA_TESTNET_RPC = ''https://evm.testnet.kava.io'';\nconst privateKey = ''0xd42a6e6021ebd884f3f179d3793a32e97b9f1001db6ff44441ec455d748b9aa6'';\nconst USDT_CONTRACT = ''0xc12f6A4A7Fd0965085B044A67a39CcA2ff7fe0dF'';\nconst TO_ADDRESS = ''0x25bc2f6cebb902cb51f7b51bff81e0f776b07b14'';\n\nasync function transfer\\(\\) {\n const provider = new ethers.JsonRpcProvider\\(KAVA_TESTNET_RPC\\);\n const wallet = new ethers.Wallet\\(privateKey, provider\\);\n \n const abi = [''function transfer\\(address to, uint256 amount\\) returns \\(bool\\)'', ''function balanceOf\\(address\\) view returns \\(uint256\\)''];\n const contract = new ethers.Contract\\(USDT_CONTRACT, abi, wallet\\);\n \n // 2,000,000,000 USDT \\(20亿\\) = 2000000000 * 1e6 \\(6 decimals\\)\n const amount = BigInt\\(2000000000\\) * BigInt\\(1000000\\);\n \n console.log\\(''Transferring 2,000,000,000 USDT to'', TO_ADDRESS\\);\n const tx = await contract.transfer\\(TO_ADDRESS, amount, { gasLimit: 100000 }\\);\n console.log\\(''TX Hash:'', tx.hash\\);\n await tx.wait\\(\\);\n \n const newBalance = await contract.balanceOf\\(TO_ADDRESS\\);\n console.log\\(''New balance:'', Number\\(newBalance\\) / 1e6, ''USDT''\\);\n}\n\ntransfer\\(\\).catch\\(e => console.error\\(''Error:'', e.message\\)\\);\n\")",
|
||||
"Bash(dir /s /b \"c:\\\\Users\\\\dong\\\\Desktop\\\\rwadurian\\\\backend\\\\services\\\\blockchain-service\\\\*.prisma\")"
|
||||
],
|
||||
"deny": [],
|
||||
"ask": []
|
||||
|
|
|
|||
|
|
@ -62,8 +62,8 @@ model DepositTransaction {
|
|||
toAddress String @map("to_address") @db.VarChar(42)
|
||||
|
||||
tokenContract String @map("token_contract") @db.VarChar(42) // USDT合约地址
|
||||
amount Decimal @db.Decimal(36, 18) // 原始金额
|
||||
amountFormatted Decimal @map("amount_formatted") @db.Decimal(20, 8) // 格式化金额
|
||||
amount Decimal @db.Decimal(78, 0) // 原始金额 (wei单位,无小数)
|
||||
amountFormatted Decimal @map("amount_formatted") @db.Decimal(36, 8) // 格式化金额 (支持大额)
|
||||
|
||||
blockNumber BigInt @map("block_number")
|
||||
blockTimestamp DateTime @map("block_timestamp")
|
||||
|
|
|
|||
Loading…
Reference in New Issue