Skip to content

Commit

Permalink
Fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashuaidehao committed Sep 27, 2020
1 parent fceda2a commit 04eb648
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public static byte[] Upgrade(byte[] newScript, byte[] paramList, byte returnType
Assert(Runtime.CheckWitness(GetAdmin()), "upgrade: CheckWitness failed!");

byte[] newContractHash = Hash160(newScript);
Assert(Blockchain.GetContract(newContractHash).Serialize().Equals(new byte[] { 0x00, 0x00 }), "upgrade: The contract already exists");

Contract newContract = Contract.Migrate(newScript, paramList, returnType, cps, name, version, author, email, description);
Runtime.Notify("upgrade", ExecutionEngine.ExecutingScriptHash, newContractHash);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public static byte[] Upgrade(byte[] newScript, byte[] paramList, byte returnType

var me = ExecutionEngine.ExecutingScriptHash;
byte[] newContractHash = Hash160(newScript);
Assert(Blockchain.GetContract(newContractHash).Serialize().Equals(new byte[] { 0x00, 0x00 }), "upgrade: The contract already exists");

var r = ReservePair;
SafeTransfer(Token0, me, newContractHash, r.Reserve0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ partial class FlamingoSwapPairContract
[DisplayName("name")]
public static string Name() => "Exchange Pair"; //name of the token

[DisplayName("symbol")]
public static string Symbol() => "Temp-AB"; //symbol of the token


[DisplayName("supportedStandards")]
Expand Down Expand Up @@ -70,7 +68,7 @@ private static bool Transfer(byte[] from, byte[] to, BigInteger amount, byte[] c
{
//Check parameters
Assert(from.Length == 20 && to.Length == 20, "The parameters from and to SHOULD be 20-byte addresses.");
Assert(amount > 0, "The parameter amount MUST be greater than 0.");
Assert(amount >= 0, "The parameter amount MUST be greater than 0.");

if (!Runtime.CheckWitness(from) && from.AsBigInteger() != callscript.AsBigInteger())
return false;
Expand All @@ -81,6 +79,7 @@ private static bool Transfer(byte[] from, byte[] to, BigInteger amount, byte[] c
if (from == to)
return true;


//Reduce payer balances
if (fromAmount == amount)
asset.Delete(from);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ partial class FlamingoSwapPairContract : SmartContract
/// </summary>
static readonly byte[] Token1 = "cbad1e6082cb71f336939934f21e5929a5c6d7ff".HexToBytes();


[DisplayName("symbol")]
public static string Symbol() => "E-AB"; //symbol of the token

#endregion


Expand All @@ -45,6 +49,9 @@ partial class FlamingoSwapPairContract : SmartContract
///// </summary>
//static readonly byte[] Token1 = "7c76490fc79a8a47068b904e83d78c0292590fd4".HexToBytes();

//[DisplayName("symbol")]
//public static string Symbol() => "E-BC"; //symbol of the token

#endregion


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public static byte[] Upgrade(byte[] newScript, byte[] paramList, byte returnType
Assert(Runtime.CheckWitness(GetAdmin()), "upgrade: CheckWitness failed!");

byte[] newContractHash = Hash160(newScript);
Assert(Blockchain.GetContract(newContractHash).Serialize().Equals(new byte[] { 0x00, 0x00 }), "upgrade: The contract already exists");

Contract newContract = Contract.Migrate(newScript, paramList, returnType, cps, name, version, author, email, description);
Runtime.Notify("upgrade", ExecutionEngine.ExecutingScriptHash, newContractHash);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public static BigInteger[] AddLiquidity(byte[] sender, byte[] tokenA, byte[] tok
{
//B超出期望最大值,按照 TokenB 期望最大值计算 TokenA 的注入量
var estimatedA = Quote(amountBDesired, reserveB, reserveA);
Assert(estimatedA <= amountADesired, "Excess A Amount");
Assert(estimatedA >= amountAMin, "Insufficient A Amount");
amountA = estimatedA;
amountB = amountBDesired;
Expand Down

0 comments on commit 04eb648

Please sign in to comment.