-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'tx-builders' into tx-signing-js
# Conflicts: # sdk/shared/src/main/scala/org/ergoplatform/sdk/AppkitProvingInterpreter.scala
- Loading branch information
Showing
27 changed files
with
844 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 22 additions & 26 deletions
48
sdk/js/src/main/scala/org/ergoplatform/sdk/js/BlockchainParameters.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,30 @@ | ||
package org.ergoplatform.sdk.js | ||
|
||
import org.ergoplatform.sdk.wallet.protocol.context.ErgoLikeParameters | ||
import org.ergoplatform.sdk | ||
|
||
import scala.scalajs.js.UndefOr | ||
import scala.scalajs.js.annotation.JSExportTopLevel | ||
import org.ergoplatform.sdk.Iso._ | ||
|
||
/** JS exported version of the [[sdk.BlockchainParameters]] class with the same fields. | ||
* @see sdk.BlockchainParameters | ||
*/ | ||
@JSExportTopLevel("BlockchainParameters") | ||
class BlockchainParameters( | ||
val storageFeeFactor: Int, | ||
val minValuePerByte: Int, | ||
val maxBlockSize: Int, | ||
val tokenAccessCost: Int, | ||
val inputCost: Int, | ||
val dataInputCost: Int, | ||
val outputCost: Int, | ||
val maxBlockCost: Int, | ||
val _softForkStartingHeight: UndefOr[Int], | ||
val _softForkVotesCollected: UndefOr[Int], | ||
val blockVersion: Byte | ||
) extends ErgoLikeParameters { | ||
import org.ergoplatform.sdk.Iso._ | ||
/** | ||
* @return height when voting for a soft-fork had been started | ||
*/ | ||
override def softForkStartingHeight: Option[Int] = | ||
Isos.isoUndefOr[Int, Int](identityIso).to(_softForkStartingHeight) | ||
|
||
/** | ||
* @return votes for soft-fork collected in previous epochs | ||
*/ | ||
override def softForkVotesCollected: Option[Int] = | ||
Isos.isoUndefOr[Int, Int](identityIso).to(_softForkVotesCollected) | ||
} | ||
storageFeeFactor: Int, | ||
minValuePerByte: Int, | ||
maxBlockSize: Int, | ||
tokenAccessCost: Int, | ||
inputCost: Int, | ||
dataInputCost: Int, | ||
outputCost: Int, | ||
maxBlockCost: Int, | ||
_softForkStartingHeight: UndefOr[Int], | ||
_softForkVotesCollected: UndefOr[Int], | ||
blockVersion: Byte | ||
) extends sdk.BlockchainParameters( | ||
storageFeeFactor, minValuePerByte, maxBlockSize, tokenAccessCost, inputCost, dataInputCost, | ||
outputCost, maxBlockCost, | ||
Isos.isoUndefOr[Int, Int](identityIso).to(_softForkStartingHeight), | ||
Isos.isoUndefOr[Int, Int](identityIso).to(_softForkVotesCollected), blockVersion | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
sdk/shared/src/main/scala/org/ergoplatform/sdk/BlockchainContext.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.ergoplatform.sdk | ||
|
||
import org.ergoplatform.sdk.wallet.protocol.context.BlockchainStateContext | ||
import special.collection.Coll | ||
import special.sigma.Header | ||
|
||
/** Represents a specific context of blockchain for execution | ||
* of transaction building scenario. | ||
* It contains methods for accessing blockchain data, current blockchain state, | ||
* node information etc. | ||
* An instance of this class can also be used to create new builders | ||
* for creating new transactions and provers (used for transaction signing). | ||
*/ | ||
case class BlockchainContext( | ||
networkType: NetworkType, | ||
parameters: BlockchainParameters, | ||
stateContext: BlockchainStateContext | ||
) { | ||
def headers: Coll[Header] = stateContext.sigmaLastHeaders | ||
|
||
def height: Int = headers(0).height | ||
} |
52 changes: 52 additions & 0 deletions
52
sdk/shared/src/main/scala/org/ergoplatform/sdk/BlockchainParameters.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package org.ergoplatform.sdk | ||
|
||
/** Blockchain parameters re-adjustable via miners voting and voting-related data. | ||
* All these fields are included into extension section of a first block of a voting epoch. | ||
* | ||
* @param storageFeeFactor cost of storing 1 byte in UTXO for four years, in nanoErgs | ||
* @param minValuePerByte cost of a transaction output, in computation unit | ||
* @param maxBlockSize max block size, in bytes | ||
* @param tokenAccessCost cost of a token contained in a transaction, in computation unit | ||
* @param inputCost cost of a transaction input, in computation unit | ||
* @param dataInputCost cost of a transaction data input, in computation unit | ||
* @param outputCost cost of a transaction output, in computation unit | ||
* @param maxBlockCost computation units limit per block | ||
* @param softForkStartingHeight height when voting for a soft-fork had been started | ||
* @param softForkVotesCollected votes for soft-fork collected in previous epochs | ||
* @param blockVersion Protocol version activated on the network | ||
*/ | ||
case class BlockchainParameters( | ||
storageFeeFactor: Int, | ||
minValuePerByte: Int, | ||
maxBlockSize: Int, | ||
tokenAccessCost: Int, | ||
inputCost: Int, | ||
dataInputCost: Int, | ||
outputCost: Int, | ||
maxBlockCost: Int, | ||
softForkStartingHeight: Option[Int], | ||
softForkVotesCollected: Option[Int], | ||
blockVersion: Byte | ||
) | ||
|
||
/** Global parameters used by SDK */ | ||
object BlockchainParameters { | ||
/** A number of blocks a miner should wait before he/she can spend block reward. | ||
* This is part of Ergo protocol and cannot be changed. | ||
*/ | ||
val MinerRewardDelay_Mainnet = 720 | ||
|
||
val MinerRewardDelay_Testnet = 720 | ||
|
||
/** One Erg is 10^9 NanoErg */ | ||
val OneErg: Long = 1000 * 1000 * 1000 | ||
|
||
/** Minimum transaction fee in NanoErgs as it is defined in Ergo protocol. */ | ||
val MinFee: Long = 1000 * 1000 | ||
|
||
/** Minimum value for a change. It can be used to compute change output value. | ||
* If computed change is less than this value, it is added to the fee | ||
* and `change` output in not added to the transaction. | ||
*/ | ||
val MinChangeValue: Long = 1000 * 1000 | ||
} |
15 changes: 15 additions & 0 deletions
15
sdk/shared/src/main/scala/org/ergoplatform/sdk/BoxSelectionResult.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.ergoplatform.sdk | ||
|
||
import org.ergoplatform.ErgoBoxAssets | ||
|
||
/** | ||
* Containter for box selector output | ||
* | ||
* @param inputBoxes - transaction inputs chosen by a selector | ||
* @param changeBoxes - change outputs | ||
* @param payToReemissionBox - pay-to-reemission output mde according to EIP-27, if needed | ||
*/ | ||
class BoxSelectionResult[T <: ErgoBoxAssets]( | ||
val inputBoxes: Seq[T], | ||
val changeBoxes: Seq[ErgoBoxAssets], | ||
val payToReemissionBox: Option[ErgoBoxAssets]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.