Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Commit

Permalink
Implement EthereumDynamicFee transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
aeharvlee committed Mar 4, 2022
1 parent ce6ea0a commit 4b92a48
Show file tree
Hide file tree
Showing 13 changed files with 2,800 additions and 13 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ buildscript {
ext.androidxJunitVersion = '1.1.2'
ext.androidxTestRunnerVersion = '1.3.0'
ext.androidxTestRulesVersion = '1.3.0'
ext.jacksonDataBindVersion = '2.13.1'
}

plugins {
Expand Down
1 change: 1 addition & 0 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ dependencies {
}

compile "com.github.ipfs:java-ipfs-http-client:$ipfsVersion"
implementation "com.fasterxml.jackson.core:jackson-databind:$jacksonDataBindVersion"
}

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.klaytn.caver.methods.response;

import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
Expand Down Expand Up @@ -87,6 +88,16 @@ public static class TransactionData {
*/
private String gasPrice;

/**
* Max priority fee per gas in peb.
*/
private String maxPriorityFeePerGas;

/**
* Max fee per gas in peb.
*/
private String maxFeePerGas;

/**
* Hash of the transaction.
*/
Expand Down Expand Up @@ -152,6 +163,7 @@ public static class TransactionData {
/**
* Chain ID.
*/
@JsonAlias({"chainId", "chainID"})
private String chainID;

/**
Expand All @@ -161,7 +173,7 @@ public static class TransactionData {

public TransactionData() {}

public TransactionData(String blockHash, String blockNumber, String codeFormat, String feePayer, List<SignatureData> feePayerSignatures, String feeRatio, String from, String gas, String gasPrice, String hash, boolean humanReadable, String key, String input, String nonce, String senderTxHash, List<SignatureData> signatures, String to, String transactionIndex, String type, String typeInt, String value, String chainID, AccessList accesslist) {
public TransactionData(String blockHash, String blockNumber, String codeFormat, String feePayer, List<SignatureData> feePayerSignatures, String feeRatio, String from, String gas, String gasPrice, String maxPriorityFeePerGas, String maxFeePerGas, String hash, boolean humanReadable, String key, String input, String nonce, String senderTxHash, List<SignatureData> signatures, String to, String transactionIndex, String type, String typeInt, String value, String chainID, AccessList accesslist) {
this.blockHash = blockHash;
this.blockNumber = blockNumber;
this.codeFormat = codeFormat;
Expand All @@ -171,6 +183,8 @@ public TransactionData(String blockHash, String blockNumber, String codeFormat,
this.from = from;
this.gas = gas;
this.gasPrice = gasPrice;
this.maxPriorityFeePerGas = maxPriorityFeePerGas;
this.maxFeePerGas = maxFeePerGas;
this.hash = hash;
this.humanReadable = humanReadable;
this.key = key;
Expand Down Expand Up @@ -260,6 +274,22 @@ public void setGasPrice(String gasPrice) {
this.gasPrice = gasPrice;
}

public String getMaxPriorityFeePerGas() {
return maxPriorityFeePerGas;
}

public void setMaxPriorityFeePerGas(String maxPriorityFeePerGas) {
this.maxPriorityFeePerGas = maxPriorityFeePerGas;
}

public String getMaxFeePerGas() {
return maxFeePerGas;
}

public void setMaxFeePerGas(String maxFeePerGas) {
this.maxFeePerGas = maxFeePerGas;
}

public String getHash() {
return hash;
}
Expand Down Expand Up @@ -429,6 +459,8 @@ public AbstractTransaction convertToCaverTransaction(Klay klay) {
return FeeDelegatedChainDataAnchoringWithRatio.create(klay, this.getFrom(), this.getNonce(), this.getGas(), this.getGasPrice(), this.getChainID(), this.getSignatures(), this.getFeePayer(), this.getFeePayerSignatures(), this.getFeeRatio(), this.getInput());
case TxTypeEthereumAccessList:
return EthereumAccessList.create(klay, this.getFrom(), this.getNonce(), this.getGas(), this.getGasPrice(), this.getChainID(), this.getSignatures(), this.getTo(), this.getInput(), this.getValue(), this.getAccessList());
case TxTypeEthereumDynamicFee:
return EthereumDynamicFee.create(klay, this.getFrom(), this.getNonce(), this.getGas(), this.getMaxPriorityFeePerGas(), this.getMaxFeePerGas(), this.getChainID(), this.getSignatures(), this.getTo(), this.getInput(), this.getValue(), this.getAccessList());
default:
throw new RuntimeException("Invalid transaction type : Cannot create a transaction instance that has Tx type :" + this.getType());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.klaytn.caver.methods.response;

import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
Expand Down Expand Up @@ -133,6 +134,16 @@ public static class TransactionReceiptData {
*/
private String gasPrice;

/**
* Max priority fee per gas in peb.
*/
private String maxPriorityFeePerGas;

/**
* Max fee per gas in peb.
*/
private String maxFeePerGas;

/**
* The amount of gas used by this specific transaction alone.
*/
Expand Down Expand Up @@ -223,6 +234,7 @@ public static class TransactionReceiptData {
/**
* Chain ID.
*/
@JsonAlias({"chainId", "chainID"})
private String chainID;

/**
Expand All @@ -233,7 +245,7 @@ public static class TransactionReceiptData {
public TransactionReceiptData() {
}

public TransactionReceiptData(String blockHash, String blockNumber, String codeFormat, String contractAddress, String feePayer, List<SignatureData> feePayerSignatures, String feeRatio, String from, String gas, String gasPrice, String gasUsed, boolean humanReadable, String key, String input, List<KlayLogs.Log> logs, String logsBloom, String nonce, String senderTxHash, List<SignatureData> signatures, String status, String to, String transactionIndex, String transactionHash, String txError, String type, String typeInt, String value, String chainID, AccessList accessList) {
public TransactionReceiptData(String blockHash, String blockNumber, String codeFormat, String contractAddress, String feePayer, List<SignatureData> feePayerSignatures, String feeRatio, String from, String gas, String gasPrice, String maxPriorityFeePerGas, String maxFeePerGas, String gasUsed, boolean humanReadable, String key, String input, List<KlayLogs.Log> logs, String logsBloom, String nonce, String senderTxHash, List<SignatureData> signatures, String status, String to, String transactionIndex, String transactionHash, String txError, String type, String typeInt, String value, String chainID, AccessList accessList) {
this.blockHash = blockHash;
this.blockNumber = blockNumber;
this.codeFormat = codeFormat;
Expand All @@ -244,6 +256,8 @@ public TransactionReceiptData(String blockHash, String blockNumber, String codeF
this.from = from;
this.gas = gas;
this.gasPrice = gasPrice;
this.maxPriorityFeePerGas = maxPriorityFeePerGas;
this.maxFeePerGas = maxFeePerGas;
this.gasUsed = gasUsed;
this.humanReadable = humanReadable;
this.key = key;
Expand Down Expand Up @@ -346,6 +360,22 @@ public void setGasPrice(String gasPrice) {
this.gasPrice = gasPrice;
}

public String getMaxPriorityFeePerGas() {
return maxPriorityFeePerGas;
}

public void setMaxPriorityFeePerGas(String maxPriorityFeePerGas) {
this.maxPriorityFeePerGas = maxPriorityFeePerGas;
}

public String getMaxFeePerGas() {
return maxFeePerGas;
}

public void setMaxFeePerGas(String maxFeePerGas) {
this.maxFeePerGas = maxFeePerGas;
}

public String getGasUsed() {
return gasUsed;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public static AbstractTransaction decode(String rlpEncoded) {
return FeeDelegatedSmartContractDeployWithRatio.decode(rlpBytes);
} else if ((rlpBytes[0] << 8 | rlpBytes[1]) == TransactionType.TxTypeEthereumAccessList.getType()) {
return EthereumAccessList.decode(rlpBytes);
} else if ((rlpBytes[0] << 8 | rlpBytes[1]) == TransactionType.TxTypeEthereumDynamicFee.getType()) {
return EthereumDynamicFee.decode(rlpBytes);
}
else {
return LegacyTransaction.decode(rlpBytes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ public static EthereumAccessList.Builder ethereumAccessList() {
return new EthereumAccessList.Builder();
}

/**
* Creates a Builder of EthereumDynamicFee
* @return EthereumDynamicFee.Builder
*/
public static EthereumDynamicFee.Builder ethereumDynamicFee() {
return new EthereumDynamicFee.Builder();
}

/**
* Creates a Builder of ValueTransfer
* @return ValueTransfer.Builder
Expand Down
Loading

0 comments on commit 4b92a48

Please sign in to comment.