mirror of
https://github.com/bigchaindb/js-bigchaindb-driver.git
synced 2024-11-26 12:28:55 +01:00
remove signature in details and rename subfulfillments to subconditions
This commit is contained in:
parent
49c91a0916
commit
529c18a753
@ -17,7 +17,7 @@ export default function makeOutput(condition, amount = '1') {
|
|||||||
publicKeys.push(details.public_key)
|
publicKeys.push(details.public_key)
|
||||||
}
|
}
|
||||||
} else if (details.type === 'threshold-sha-256') {
|
} else if (details.type === 'threshold-sha-256') {
|
||||||
details.subfulfillments.map(getPublicKeys)
|
details.subconditions.map(getPublicKeys)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getPublicKeys(condition.details)
|
getPublicKeys(condition.details)
|
||||||
|
@ -22,12 +22,12 @@ export default function ccJsonLoad(conditionJson) {
|
|||||||
if (conditionJson.type === 'threshold-sha-256') {
|
if (conditionJson.type === 'threshold-sha-256') {
|
||||||
fulfillment = new cc.ThresholdSha256()
|
fulfillment = new cc.ThresholdSha256()
|
||||||
fulfillment.threshold = conditionJson.threshold
|
fulfillment.threshold = conditionJson.threshold
|
||||||
conditionJson.subfulfillments.forEach((subfulfillmentJson) => {
|
conditionJson.subconditions.forEach((subconditionJson) => {
|
||||||
const subfulfillment = ccJsonLoad(subfulfillmentJson)
|
const subcondition = ccJsonLoad(subconditionJson)
|
||||||
if ('getConditionUri' in subfulfillment) {
|
if ('getConditionUri' in subcondition) {
|
||||||
fulfillment.addSubfulfillment(subfulfillment)
|
fulfillment.addSubfulfillment(subcondition)
|
||||||
} else if ('serializeUri' in subfulfillment) {
|
} else if ('serializeUri' in subcondition) {
|
||||||
fulfillment.addSubcondition(subfulfillment)
|
fulfillment.addSubcondition(subcondition)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -35,9 +35,6 @@ export default function ccJsonLoad(conditionJson) {
|
|||||||
if (conditionJson.type === 'ed25519-sha-256') {
|
if (conditionJson.type === 'ed25519-sha-256') {
|
||||||
fulfillment = new cc.Ed25519Sha256()
|
fulfillment = new cc.Ed25519Sha256()
|
||||||
fulfillment.publicKey = new Buffer(base58.decode(conditionJson.public_key))
|
fulfillment.publicKey = new Buffer(base58.decode(conditionJson.public_key))
|
||||||
if (conditionJson.signature) {
|
|
||||||
fulfillment.signature = new Buffer(base58.decode(conditionJson.signature))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return fulfillment
|
return fulfillment
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ export default function ccJsonify(fulfillment) {
|
|||||||
'details': {
|
'details': {
|
||||||
'type': 'threshold-sha-256',
|
'type': 'threshold-sha-256',
|
||||||
'threshold': fulfillment.threshold,
|
'threshold': fulfillment.threshold,
|
||||||
'subfulfillments': fulfillment.subconditions.map((subcondition) => {
|
'subconditions': fulfillment.subconditions.map((subcondition) => {
|
||||||
const subconditionJson = ccJsonify(subcondition.body)
|
const subconditionJson = ccJsonify(subcondition.body)
|
||||||
return subconditionJson.details
|
return subconditionJson.details
|
||||||
})
|
})
|
||||||
@ -48,7 +48,6 @@ export default function ccJsonify(fulfillment) {
|
|||||||
jsonBody.details.type = 'ed25519-sha-256'
|
jsonBody.details.type = 'ed25519-sha-256'
|
||||||
|
|
||||||
if ('publicKey' in fulfillment) {
|
if ('publicKey' in fulfillment) {
|
||||||
jsonBody.details.signature = null
|
|
||||||
jsonBody.details.public_key = base58.encode(fulfillment.publicKey)
|
jsonBody.details.public_key = base58.encode(fulfillment.publicKey)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ test('Ed25519 condition encoding', t => {
|
|||||||
details: {
|
details: {
|
||||||
type: 'ed25519-sha-256',
|
type: 'ed25519-sha-256',
|
||||||
public_key: publicKey,
|
public_key: publicKey,
|
||||||
signature: null,
|
|
||||||
},
|
},
|
||||||
uri: 'ni:///sha-256;uLdVX7FEjLWVDkAkfMAkEqPPwFqZj7qfiGE152t_x5c?fpt=ed25519-sha-256&cost=131072'
|
uri: 'ni:///sha-256;uLdVX7FEjLWVDkAkfMAkEqPPwFqZj7qfiGE152t_x5c?fpt=ed25519-sha-256&cost=131072'
|
||||||
}
|
}
|
||||||
@ -28,16 +27,14 @@ test('Threshold condition encoding', t => {
|
|||||||
details: {
|
details: {
|
||||||
type: 'threshold-sha-256',
|
type: 'threshold-sha-256',
|
||||||
threshold: 1,
|
threshold: 1,
|
||||||
subfulfillments: [
|
subconditions: [
|
||||||
{
|
{
|
||||||
type: 'ed25519-sha-256',
|
type: 'ed25519-sha-256',
|
||||||
public_key: publicKey,
|
public_key: publicKey,
|
||||||
signature: null,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'ed25519-sha-256',
|
type: 'ed25519-sha-256',
|
||||||
public_key: publicKey,
|
public_key: publicKey,
|
||||||
signature: null,
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user