Skip to content

Commit

Permalink
Transfer bug fix (neo-project#429)
Browse files Browse the repository at this point in the history
* [RpcServer] Querying contracts by ID/name (neo-project#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 <[email protected]>

* update

* a

* More fix

* fix

* Fixed UT

* Simplify Code

* Simplify Code 2

* Update RpcServer

* update

Co-authored-by: Shargon <[email protected]>
Co-authored-by: Owen Zhang <[email protected]>
Co-authored-by: superboyiii <[email protected]>
Co-authored-by: Vitor Nazário Coelho <[email protected]>
Co-authored-by: Luchuan <[email protected]>

* MPT in StateService from core (neo-project#410)

* Unify GetUnclaimedGas and GetWalletUnclaimedGas with decimal (neo-project#413)

* Unify GetUnclaimedGas and GetWalletUnclaimedGas with decimal

* fix

* Fixed UT (Neo CI01089) (neo-project#416)

* [RpcServer] Querying contracts by ID/name (neo-project#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 <[email protected]>

* update

* a

* More fix

* fix

* Fixed UT

* Simplify Code

* Simplify Code 2

* Update RpcServer

* update

Co-authored-by: Shargon <[email protected]>
Co-authored-by: Owen Zhang <[email protected]>
Co-authored-by: superboyiii <[email protected]>
Co-authored-by: Vitor Nazário Coelho <[email protected]>
Co-authored-by: Luchuan <[email protected]>

* MPT in StateService from core (neo-project#410)

* Unify GetUnclaimedGas and GetWalletUnclaimedGas with decimal (neo-project#413)

* Unify GetUnclaimedGas and GetWalletUnclaimedGas with decimal

* fix

* Fixed UT (Neo CI01089)

Co-authored-by: Shargon <[email protected]>
Co-authored-by: Owen Zhang <[email protected]>
Co-authored-by: superboyiii <[email protected]>
Co-authored-by: Vitor Nazário Coelho <[email protected]>
Co-authored-by: Luchuan <[email protected]>
Co-authored-by: ZhangTao <[email protected]>

* Nep17 (neo-project#412)

* [RpcServer] Querying contracts by ID/name (neo-project#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 <[email protected]>

* update

* a

* More fix

* fix

* Fixed UT

* Simplify Code

* Simplify Code 2

* Update RpcServer

* update

Co-authored-by: Shargon <[email protected]>
Co-authored-by: Owen Zhang <[email protected]>
Co-authored-by: superboyiii <[email protected]>
Co-authored-by: Vitor Nazário Coelho <[email protected]>
Co-authored-by: Luchuan <[email protected]>

* String Substitution

* Modify filename and name methods

* update

* update

* Update src/RpcClient/Models/RpcNep5TokenInfo.cs

Co-authored-by: Vitor Nazário Coelho <[email protected]>

* Update src/RpcClient/Nep17API.cs

Co-authored-by: Vitor Nazário Coelho <[email protected]>

* MPT in StateService from core (neo-project#410)

* Unify GetUnclaimedGas and GetWalletUnclaimedGas with decimal (neo-project#413)

* Unify GetUnclaimedGas and GetWalletUnclaimedGas with decimal

* fix

* Fixed UT (Neo CI01089)

* Update Nep17API.cs

* Update README.md

Co-authored-by: Owen Zhang <[email protected]>

* update filename

* Fix UT

* Format

* fix

* update

* update UT

* Add Unit Tests

* update

Co-authored-by: Shargon <[email protected]>
Co-authored-by: Owen Zhang <[email protected]>
Co-authored-by: superboyiii <[email protected]>
Co-authored-by: Vitor Nazário Coelho <[email protected]>
Co-authored-by: Luchuan <[email protected]>
Co-authored-by: ZhangTao <[email protected]>

* merge

* fixed bug

* clear

* UT

* Add a little code coverage

Co-authored-by: Shargon <[email protected]>
Co-authored-by: Owen Zhang <[email protected]>
Co-authored-by: superboyiii <[email protected]>
Co-authored-by: Vitor Nazário Coelho <[email protected]>
Co-authored-by: Luchuan <[email protected]>
Co-authored-by: ZhangTao <[email protected]>
  • Loading branch information
7 people authored and joeqian10 committed Apr 7, 2021
1 parent 80bd19c commit 7f9b4ae
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Neo" Version="3.0.0-CI01105" />
<PackageReference Include="Neo" Version="3.0.0-CI01113" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions src/RpcClient/Nep17API.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public async Task<Transaction> CreateTransferTxAsync(UInt160 scriptHash, KeyPair
var sender = Contract.CreateSignatureRedeemScript(fromKey.PublicKey).ToScriptHash();
Signer[] signers = new[] { new Signer { Scopes = WitnessScope.CalledByEntry, Account = sender } };

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

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

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

TransactionManagerFactory factory = new TransactionManagerFactory(rpcClient, magic);
TransactionManager manager = await factory.MakeTransactionAsync(script, signers).ConfigureAwait(false);
Expand Down
8 changes: 4 additions & 4 deletions tests/Neo.Network.RPC.Tests/RpcTestCases.json
Original file line number Diff line number Diff line change
Expand Up @@ -433,18 +433,18 @@
"jsonrpc": "2.0",
"id": 1,
"method": "getcontractstate",
"params": [ "0x74c21a1ca66b7a190bf2a65db83ba6fe550cea64" ]
"params": [ "0x0a46e2e37c9987f570b4af253fb77e7eef0f72b6" ]
},
"Response": {
"jsonrpc": "2.0",
"id": 1,
"result": {
"id": -1,
"updatecounter": 0,
"hash": "0x74c21a1ca66b7a190bf2a65db83ba6fe550cea64",
"script": "DANORU9BGvd7Zw==",
"hash": "0x0a46e2e37c9987f570b4af253fb77e7eef0f72b6",
"script": "DAhOZW9Ub2tlbkEa93tn",
"manifest": {
"name": "NEO",
"name": "NeoToken",
"groups": [],
"supportedstandards": [
"NEP-17"
Expand Down
10 changes: 5 additions & 5 deletions tests/Neo.Network.RPC.Tests/UT_Nep17API.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,29 +98,29 @@ public async Task TestGetTokenInfo()
.ReturnsAsync(test.Response.Result)
.Verifiable();

if (test.Request.Params[0].AsString() == "0xb399c051778cf37a1e4ef88509b2e054d0420a32")
if (test.Request.Params[0].AsString() == "0xa6a6c15dcdc9b997dac448b6926522d22efeedfb")
{
var result = await nep17API.GetTokenInfoAsync(NativeContract.GAS.Hash);
Assert.AreEqual(NativeContract.GAS.Symbol, result.Symbol);
Assert.AreEqual(8, (int)result.Decimals);
Assert.AreEqual(1_00000000, (int)result.TotalSupply);
Assert.AreEqual("GAS", result.Name);
Assert.AreEqual("GasToken", result.Name);
}
else if (test.Request.Params[0].AsString() == "0x74c21a1ca66b7a190bf2a65db83ba6fe550cea64")
else if (test.Request.Params[0].AsString() == "0x0a46e2e37c9987f570b4af253fb77e7eef0f72b6")
{
var result = await nep17API.GetTokenInfoAsync(NativeContract.NEO.Hash);
Assert.AreEqual(NativeContract.NEO.Symbol, result.Symbol);
Assert.AreEqual(0, (int)result.Decimals);
Assert.AreEqual(1_00000000, (int)result.TotalSupply);
Assert.AreEqual("NEO", result.Name);
Assert.AreEqual("NeoToken", result.Name);
}
}
}

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

var result = await nep17API.CreateTransferTxAsync(NativeContract.GAS.Hash, keyPair1, UInt160.Zero, new BigInteger(1_00000000));
Expand Down
1 change: 1 addition & 0 deletions tests/Neo.Network.RPC.Tests/UT_RpcClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ public async Task TestGetUnclaimedGas()
{
var test = TestUtils.RpcTestCases.Find(p => p.Name == nameof(rpc.GetUnclaimedGasAsync).ToLower());
var result = await rpc.GetUnclaimedGasAsync(test.Request.Params[0].AsString());
Assert.AreEqual(result.ToJson().AsString(), RpcUnclaimedGas.FromJson(result.ToJson()).ToJson().AsString());
Assert.AreEqual(test.Response.Result["unclaimed"].AsString(), result.Unclaimed.ToString());
}

Expand Down
6 changes: 3 additions & 3 deletions tests/Neo.Network.RPC.Tests/UT_WalletAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public async Task TestClaimGas()
byte[] balanceScript = NativeContract.NEO.Hash.MakeScript("balanceOf", sender);
UT_TransactionManager.MockInvokeScript(rpcClientMock, balanceScript, new ContractParameter { Type = ContractParameterType.Integer, Value = new BigInteger(1_00000000) });

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

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

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

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

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

var json = new JObject();
Expand Down

0 comments on commit 7f9b4ae

Please sign in to comment.