Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
NashMiao authored and xizho10 committed Nov 6, 2019
1 parent 299e26c commit 5cfe174
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
10 changes: 4 additions & 6 deletions src/main/java/com/github/ontio/core/transaction/Transaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public abstract class Transaction extends Inventory {
public Address payer = new Address();
public Attribute[] attributes;
public Sig[] sigs = new Sig[0];

protected Transaction(TransactionType type) {
this.txType = type;
}
Expand Down Expand Up @@ -82,7 +81,6 @@ public static Transaction deserializeFrom(BinaryReader reader) throws IOExceptio
throw new IOException(ex);
}
}

@Override
public void deserialize(BinaryReader reader) throws IOException {
deserializeUnsigned(reader);
Expand Down Expand Up @@ -178,11 +176,11 @@ public Object json() {
Map json = new HashMap();
json.put("Hash", hash().toString());
json.put("Version", (int) version);
json.put("Nonce", nonce & 0xFFFFFFFF);
json.put("Nonce", nonce& 0xFFFFFFFF);
json.put("TxType", txType.value() & 0xFF);
json.put("GasPrice", gasPrice);
json.put("GasLimit", gasLimit);
json.put("Payer", payer.toBase58());
json.put("GasPrice",gasPrice);
json.put("GasLimit",gasLimit);
json.put("Payer",payer.toBase58());
json.put("Attributes", Arrays.stream(attributes).map(p -> p.json()).toArray(Object[]::new));
json.put("Sigs", Arrays.stream(sigs).map(p -> p.json()).toArray(Object[]::new));
return json;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/github/ontio/network/rest/http.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ public static String delete(String url, Map<String, String> params, Map<String,
}

public static String post(String url, Map<String, String> params, Map<String, Object> body) throws Exception {
//System.out.println(String.format("POST url=%s,%s,%s", url,JSON.toJSONString(params),JSON.toJSONString(body)));
if(url.startsWith("https")){
return post(url+cvtParams(params), JSON.toJSONString(body), true);
}else{
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/demo/MakeTxWithoutWalletDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,26 @@

package demo;

import com.alibaba.fastjson.JSON;
import com.github.ontio.OntSdk;
import com.github.ontio.common.Address;
import com.github.ontio.common.Helper;
import com.github.ontio.core.VmType;
import com.github.ontio.core.asset.Contract;
import com.github.ontio.core.asset.State;
import com.github.ontio.core.asset.Transfers;
import com.github.ontio.core.payload.InvokeCode;
import com.github.ontio.core.transaction.Transaction;
import com.github.ontio.crypto.KeyType;
import com.github.ontio.sdk.info.AccountInfo;
import com.github.ontio.sdk.manager.WalletMgr;
import com.github.ontio.sdk.wallet.Account;
import com.github.ontio.sdk.wallet.Identity;

import java.math.BigInteger;
import java.security.Key;
import java.util.HashMap;
import java.util.Map;

public class MakeTxWithoutWalletDemo {
public static String privatekey1 = "49855b16636e70f100cc5f4f42bc20a6535d7414fb8845e7310f8dd065a97221";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package com.github.ontio.core.payload;

import com.github.ontio.core.VmType;
import com.github.ontio.io.BinaryReader;
import com.github.ontio.io.BinaryWriter;
import org.junit.Test;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.*;

public class DeployCodeTest {

Expand Down

0 comments on commit 5cfe174

Please sign in to comment.