在Corda中,“getPaper()”在教程中是什么意思;编写合同测试”;?

在Corda中,“getPaper()”在教程中是什么意思;编写合同测试”;?,corda,Corda,我正在学习以下Corda教程: 有人能解释一下这行代码吗?它不会出现在此页面之前。这只是一种返回新商业票据状态的测试方法 目前,超越了你好,世界!教程(和),这些教程不应该相互重复来创建完整的CorDapp。它们只是各种功能如何工作的示例 查看此处定义的各种示例CordApp也可能会有所帮助:。一种简单的方法如下所示 private companion object { val testIssuance = bigCorp.ref(111) val testPounds: Cas

我正在学习以下Corda教程:


有人能解释一下这行代码吗?它不会出现在此页面之前。

这只是一种返回新商业票据状态的测试方法

目前,超越了你好,世界!教程(和),这些教程不应该相互重复来创建完整的CorDapp。它们只是各种功能如何工作的示例


查看此处定义的各种示例CordApp也可能会有所帮助:。

一种简单的方法如下所示

private companion object {
    val testIssuance = bigCorp.ref(111)
    val testPounds: Cash.State = 1999.POUNDS.CASH issuedBy testIssuance

}

fun getPaper(): CommercialPaperState {
    return CommercialPaperState(testIssuance, testIssuance.party, testPounds.amount , Instant.now()+10.days)
    }
或者,下面是另一种更复杂的方法,不使用随Corda 4一起提供的作为财务CorDapp一部分的现金

import net.corda.finance.`issued by`

private companion object {
     val bigCorp = TestIdentity((CordaX500Name("BigCorp", "New York", "GB")))
     val testIssuance = bigCorp.ref((("JoinKey").toByte()))
     val testAmount = Amount<Currency>(1000,Currency.getInstance(Locale.GERMANY))

}

fun getPaper(): CommercialPaperState {
    return CommercialPaperState(testIssuance, testIssuance.party, testAmount `issued by` testIssuance, Instant.now()+10.days)
}
import net.corda.finance.``
私人伴侣对象{
val bigCorp=证明身份((CordaX500Name(“bigCorp”、“纽约”、“GB”))
val testIssuance=bigCorp.ref(((“JoinKey”).toByte())
val testAmount=金额(1000,Currency.getInstance(Locale.GERMANY))
}
fun getPaper():CommercialPaperState{
返回商业票据状态(testIssuance,testIssuance.party,testAmount`由` testIssuance,Instant.now()+10.天发布)
}
我找到了

    override fun getPaper(): ICommercialPaperState = JavaCommercialPaper.State(
            megaCorp.ref(123),
            megaCorp.party,
            1000.DOLLARS `issued by` megaCorp.ref(123),
            TEST_TX_TIME + 7.days
    )
有用的(来自)

我将此翻译为:

    private OwnableState getPaper() {
        PartyAndReference partyAndReference = new PartyAndReference((AbstractParty) this.megaCorp.getParty(), OpaqueBytes.of((byte) 0));
        Amount<Issued<Currency>> issuedAmount = Amount.fromDecimal(new BigDecimal(1000), new Issued<Currency> (partyAndReference, Currency.getInstance(Locale.US)));
        return (OwnableState) new CommercialPaper.State(this.megaCorp.ref((byte) 123), this.megaCorp.getParty(), issuedAmount, Instant.now().plus(7, ChronoUnit.DAYS));
    }
private-owneablestate-getPaper(){
PartyAndReference PartyAndReference=新的PartyAndReference((AbstractParty)this.megaCorp.getParty(),OpaqueBytes.of((字节)0));
Amount issuedAmount=Amount.fromDecimal(新的bigdecim(1000),新发布的(partyAndReference,Currency.getInstance(Locale.US));
return(OwnableState)new CommercialPaper.State(this.megaCorp.ref((byte)123),this.megaCorp.getParty(),issuedAmount,Instant.now().plus(7,ChronoUnit.DAYS));
}