Skip to content

Commit e2db80a

Browse files
陈志同shargonsuperboyiiivncoelhoTommo-L
authored
Transfer bug fix (#429)
* [RpcServer] Querying contracts by ID/name (#378) * fixed-bug-1021 * Update src/RpcServer/RpcServer.SmartContract.cs * 😂 * draft * draft * update * fixed bug with decimal of GAS consumed in invokefunction/invokescript * remove modify of invokescript * Querying contracts by ID/name, server side * update * Enable using native.name for search Enable using native.name for search * Using keyword instead of addressOrScriptHash * revert * _initialize * split * update * Update exception message in ApplicationLog * Update src/ApplicationLogs/LogReader.cs Co-authored-by: Luchuan <luchuan@ngd.neo.org> * update * a * More fix * fix * Fixed UT * Simplify Code * Simplify Code 2 * Update RpcServer * update Co-authored-by: Shargon <shargon@gmail.com> Co-authored-by: Owen Zhang <38493437+superboyiii@users.noreply.github.com> Co-authored-by: superboyiii <573504781@qq.com> Co-authored-by: Vitor Nazário Coelho <vncoelho@gmail.com> Co-authored-by: Luchuan <luchuan@ngd.neo.org> * MPT in StateService from core (#410) * Unify GetUnclaimedGas and GetWalletUnclaimedGas with decimal (#413) * Unify GetUnclaimedGas and GetWalletUnclaimedGas with decimal * fix * Fixed UT (Neo CI01089) (#416) * [RpcServer] Querying contracts by ID/name (#378) * fixed-bug-1021 * Update src/RpcServer/RpcServer.SmartContract.cs * 😂 * draft * draft * update * fixed bug with decimal of GAS consumed in invokefunction/invokescript * remove modify of invokescript * Querying contracts by ID/name, server side * update * Enable using native.name for search Enable using native.name for search * Using keyword instead of addressOrScriptHash * revert * _initialize * split * update * Update exception message in ApplicationLog * Update src/ApplicationLogs/LogReader.cs Co-authored-by: Luchuan <luchuan@ngd.neo.org> * update * a * More fix * fix * Fixed UT * Simplify Code * Simplify Code 2 * Update RpcServer * update Co-authored-by: Shargon <shargon@gmail.com> Co-authored-by: Owen Zhang <38493437+superboyiii@users.noreply.github.com> Co-authored-by: superboyiii <573504781@qq.com> Co-authored-by: Vitor Nazário Coelho <vncoelho@gmail.com> Co-authored-by: Luchuan <luchuan@ngd.neo.org> * MPT in StateService from core (#410) * Unify GetUnclaimedGas and GetWalletUnclaimedGas with decimal (#413) * Unify GetUnclaimedGas and GetWalletUnclaimedGas with decimal * fix * Fixed UT (Neo CI01089) Co-authored-by: Shargon <shargon@gmail.com> Co-authored-by: Owen Zhang <38493437+superboyiii@users.noreply.github.com> Co-authored-by: superboyiii <573504781@qq.com> Co-authored-by: Vitor Nazário Coelho <vncoelho@gmail.com> Co-authored-by: Luchuan <luchuan@ngd.neo.org> Co-authored-by: ZhangTao <ztgoforit@163.com> * Nep17 (#412) * [RpcServer] Querying contracts by ID/name (#378) * fixed-bug-1021 * Update src/RpcServer/RpcServer.SmartContract.cs * 😂 * draft * draft * update * fixed bug with decimal of GAS consumed in invokefunction/invokescript * remove modify of invokescript * Querying contracts by ID/name, server side * update * Enable using native.name for search Enable using native.name for search * Using keyword instead of addressOrScriptHash * revert * _initialize * split * update * Update exception message in ApplicationLog * Update src/ApplicationLogs/LogReader.cs Co-authored-by: Luchuan <luchuan@ngd.neo.org> * update * a * More fix * fix * Fixed UT * Simplify Code * Simplify Code 2 * Update RpcServer * update Co-authored-by: Shargon <shargon@gmail.com> Co-authored-by: Owen Zhang <38493437+superboyiii@users.noreply.github.com> Co-authored-by: superboyiii <573504781@qq.com> Co-authored-by: Vitor Nazário Coelho <vncoelho@gmail.com> Co-authored-by: Luchuan <luchuan@ngd.neo.org> * String Substitution * Modify filename and name methods * update * update * Update src/RpcClient/Models/RpcNep5TokenInfo.cs Co-authored-by: Vitor Nazário Coelho <vncoelho@gmail.com> * Update src/RpcClient/Nep17API.cs Co-authored-by: Vitor Nazário Coelho <vncoelho@gmail.com> * MPT in StateService from core (#410) * Unify GetUnclaimedGas and GetWalletUnclaimedGas with decimal (#413) * Unify GetUnclaimedGas and GetWalletUnclaimedGas with decimal * fix * Fixed UT (Neo CI01089) * Update Nep17API.cs * Update README.md Co-authored-by: Owen Zhang <38493437+superboyiii@users.noreply.github.com> * update filename * Fix UT * Format * fix * update * update UT * Add Unit Tests * update Co-authored-by: Shargon <shargon@gmail.com> Co-authored-by: Owen Zhang <38493437+superboyiii@users.noreply.github.com> Co-authored-by: superboyiii <573504781@qq.com> Co-authored-by: Vitor Nazário Coelho <vncoelho@gmail.com> Co-authored-by: Luchuan <luchuan@ngd.neo.org> Co-authored-by: ZhangTao <ztgoforit@163.com> * merge * fixed bug * clear * UT * Add a little code coverage Co-authored-by: Shargon <shargon@gmail.com> Co-authored-by: Owen Zhang <38493437+superboyiii@users.noreply.github.com> Co-authored-by: superboyiii <573504781@qq.com> Co-authored-by: Vitor Nazário Coelho <vncoelho@gmail.com> Co-authored-by: Luchuan <luchuan@ngd.neo.org> Co-authored-by: ZhangTao <ztgoforit@163.com>
1 parent 8403137 commit e2db80a

File tree

6 files changed

+16
-15
lines changed

6 files changed

+16
-15
lines changed

src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
</PropertyGroup>
1616

1717
<ItemGroup>
18-
<PackageReference Include="Neo" Version="3.0.0-CI01105" />
18+
<PackageReference Include="Neo" Version="3.0.0-CI01113" />
1919
</ItemGroup>
2020

2121
</Project>

src/RpcClient/Nep17API.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public async Task<Transaction> CreateTransferTxAsync(UInt160 scriptHash, KeyPair
110110
var sender = Contract.CreateSignatureRedeemScript(fromKey.PublicKey).ToScriptHash();
111111
Signer[] signers = new[] { new Signer { Scopes = WitnessScope.CalledByEntry, Account = sender } };
112112

113-
byte[] script = data is null ? scriptHash.MakeScript("transfer", sender, to, amount) : scriptHash.MakeScript("transfer", sender, to, amount, data);
113+
byte[] script = scriptHash.MakeScript("transfer", sender, to, amount, data);
114114

115115
TransactionManagerFactory factory = new TransactionManagerFactory(rpcClient, magic);
116116
TransactionManager manager = await factory.MakeTransactionAsync(script, signers).ConfigureAwait(false);
@@ -137,7 +137,7 @@ public async Task<Transaction> CreateTransferTxAsync(UInt160 scriptHash, int m,
137137
var sender = Contract.CreateMultiSigContract(m, pubKeys).ScriptHash;
138138
Signer[] signers = new[] { new Signer { Scopes = WitnessScope.CalledByEntry, Account = sender } };
139139

140-
byte[] script = data is null ? scriptHash.MakeScript("transfer", sender, to, amount) : scriptHash.MakeScript("transfer", sender, to, amount, data);
140+
byte[] script = scriptHash.MakeScript("transfer", sender, to, amount, data);
141141

142142
TransactionManagerFactory factory = new TransactionManagerFactory(rpcClient, magic);
143143
TransactionManager manager = await factory.MakeTransactionAsync(script, signers).ConfigureAwait(false);

tests/Neo.Network.RPC.Tests/RpcTestCases.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -433,18 +433,18 @@
433433
"jsonrpc": "2.0",
434434
"id": 1,
435435
"method": "getcontractstate",
436-
"params": [ "0x74c21a1ca66b7a190bf2a65db83ba6fe550cea64" ]
436+
"params": [ "0x0a46e2e37c9987f570b4af253fb77e7eef0f72b6" ]
437437
},
438438
"Response": {
439439
"jsonrpc": "2.0",
440440
"id": 1,
441441
"result": {
442442
"id": -1,
443443
"updatecounter": 0,
444-
"hash": "0x74c21a1ca66b7a190bf2a65db83ba6fe550cea64",
445-
"script": "DANORU9BGvd7Zw==",
444+
"hash": "0x0a46e2e37c9987f570b4af253fb77e7eef0f72b6",
445+
"script": "DAhOZW9Ub2tlbkEa93tn",
446446
"manifest": {
447-
"name": "NEO",
447+
"name": "NeoToken",
448448
"groups": [],
449449
"supportedstandards": [
450450
"NEP-17"

tests/Neo.Network.RPC.Tests/UT_Nep17API.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,29 +98,29 @@ public async Task TestGetTokenInfo()
9898
.ReturnsAsync(test.Response.Result)
9999
.Verifiable();
100100

101-
if (test.Request.Params[0].AsString() == "0xb399c051778cf37a1e4ef88509b2e054d0420a32")
101+
if (test.Request.Params[0].AsString() == "0xa6a6c15dcdc9b997dac448b6926522d22efeedfb")
102102
{
103103
var result = await nep17API.GetTokenInfoAsync(NativeContract.GAS.Hash);
104104
Assert.AreEqual(NativeContract.GAS.Symbol, result.Symbol);
105105
Assert.AreEqual(8, (int)result.Decimals);
106106
Assert.AreEqual(1_00000000, (int)result.TotalSupply);
107-
Assert.AreEqual("GAS", result.Name);
107+
Assert.AreEqual("GasToken", result.Name);
108108
}
109-
else if (test.Request.Params[0].AsString() == "0x74c21a1ca66b7a190bf2a65db83ba6fe550cea64")
109+
else if (test.Request.Params[0].AsString() == "0x0a46e2e37c9987f570b4af253fb77e7eef0f72b6")
110110
{
111111
var result = await nep17API.GetTokenInfoAsync(NativeContract.NEO.Hash);
112112
Assert.AreEqual(NativeContract.NEO.Symbol, result.Symbol);
113113
Assert.AreEqual(0, (int)result.Decimals);
114114
Assert.AreEqual(1_00000000, (int)result.TotalSupply);
115-
Assert.AreEqual("NEO", result.Name);
115+
Assert.AreEqual("NeoToken", result.Name);
116116
}
117117
}
118118
}
119119

120120
[TestMethod]
121121
public async Task TestTransfer()
122122
{
123-
byte[] testScript = NativeContract.GAS.Hash.MakeScript("transfer", sender, UInt160.Zero, new BigInteger(1_00000000));
123+
byte[] testScript = NativeContract.GAS.Hash.MakeScript("transfer", sender, UInt160.Zero, new BigInteger(1_00000000), null);
124124
UT_TransactionManager.MockInvokeScript(rpcClientMock, testScript, new ContractParameter());
125125

126126
var result = await nep17API.CreateTransferTxAsync(NativeContract.GAS.Hash, keyPair1, UInt160.Zero, new BigInteger(1_00000000));

tests/Neo.Network.RPC.Tests/UT_RpcClient.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ public async Task TestGetUnclaimedGas()
294294
{
295295
var test = TestUtils.RpcTestCases.Find(p => p.Name == nameof(rpc.GetUnclaimedGasAsync).ToLower());
296296
var result = await rpc.GetUnclaimedGasAsync(test.Request.Params[0].AsString());
297+
Assert.AreEqual(result.ToJson().AsString(), RpcUnclaimedGas.FromJson(result.ToJson()).ToJson().AsString());
297298
Assert.AreEqual(test.Response.Result["unclaimed"].AsString(), result.Unclaimed.ToString());
298299
}
299300

tests/Neo.Network.RPC.Tests/UT_WalletAPI.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public async Task TestClaimGas()
7979
byte[] balanceScript = NativeContract.NEO.Hash.MakeScript("balanceOf", sender);
8080
UT_TransactionManager.MockInvokeScript(rpcClientMock, balanceScript, new ContractParameter { Type = ContractParameterType.Integer, Value = new BigInteger(1_00000000) });
8181

82-
byte[] testScript = NativeContract.NEO.Hash.MakeScript("transfer", sender, sender, new BigInteger(1_00000000));
82+
byte[] testScript = NativeContract.NEO.Hash.MakeScript("transfer", sender, sender, new BigInteger(1_00000000), null);
8383
UT_TransactionManager.MockInvokeScript(rpcClientMock, testScript, new ContractParameter { Type = ContractParameterType.Integer, Value = new BigInteger(1_10000000) });
8484

8585
var json = new JObject();
@@ -96,7 +96,7 @@ public async Task TestTransfer()
9696
byte[] decimalsScript = NativeContract.GAS.Hash.MakeScript("decimals");
9797
UT_TransactionManager.MockInvokeScript(rpcClientMock, decimalsScript, new ContractParameter { Type = ContractParameterType.Integer, Value = new BigInteger(8) });
9898

99-
byte[] testScript = NativeContract.GAS.Hash.MakeScript("transfer", sender, UInt160.Zero, NativeContract.GAS.Factor * 100);
99+
byte[] testScript = NativeContract.GAS.Hash.MakeScript("transfer", sender, UInt160.Zero, NativeContract.GAS.Factor * 100, null);
100100
UT_TransactionManager.MockInvokeScript(rpcClientMock, testScript, new ContractParameter { Type = ContractParameterType.Integer, Value = new BigInteger(1_10000000) });
101101

102102
var json = new JObject();
@@ -118,7 +118,7 @@ public async Task TestTransferfromMultiSigAccount()
118118
byte[] decimalsScript = NativeContract.GAS.Hash.MakeScript("decimals");
119119
UT_TransactionManager.MockInvokeScript(rpcClientMock, decimalsScript, new ContractParameter { Type = ContractParameterType.Integer, Value = new BigInteger(8) });
120120

121-
byte[] testScript = NativeContract.GAS.Hash.MakeScript("transfer", multiSender, UInt160.Zero, NativeContract.GAS.Factor * 100);
121+
byte[] testScript = NativeContract.GAS.Hash.MakeScript("transfer", multiSender, UInt160.Zero, NativeContract.GAS.Factor * 100, null);
122122
UT_TransactionManager.MockInvokeScript(rpcClientMock, testScript, new ContractParameter { Type = ContractParameterType.Integer, Value = new BigInteger(1_10000000) });
123123

124124
var json = new JObject();

0 commit comments

Comments
 (0)