Skip to content

Commit f020a35

Browse files
committed
fix: improve imports
Signed-off-by: getlarge <ed@getlarge.eu>
1 parent 9b395c1 commit f020a35

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ conn.postTransactionCommit(txSigned)
124124
<meta charset="utf-8">
125125
<title>BigchainDB boilerplate</title>
126126
<!-- Adjust version to your needs -->
127-
<script src="https://unpkg.com/bigchaindb-driver@4.0.0/dist/browser/bigchaindb-driver.window.min.js"></script>
127+
<script src="https://unpkg.com/bigchaindb-driver@4.2.0/dist/browser/bigchaindb-driver.window.min.js"></script>
128128

129129
<script>
130130
// BigchainDB server instance (e.g. https://example.com/api/v1/)

Diff for: src/sha256Hash.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
// SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
33
// Code is Apache-2.0 and docs are CC-BY-4.0
44

5-
import sha3 from 'js-sha3'
5+
/* eslint-disable camelcase */
6+
import { sha3_256 } from 'js-sha3'
67

78
export default function sha256Hash(data) {
8-
return sha3.sha3_256
9+
return sha3_256
910
.create()
1011
.update(data)
1112
.hex()
1213
}
14+
/* eslint-enable camelcase */

Diff for: src/transaction.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Buffer } from 'buffer'
66
import stableStringify from 'json-stable-stringify'
77
import clone from 'clone'
88
import base58 from 'bs58'
9-
import cc from 'crypto-conditions'
9+
import { Ed25519Sha256, PreimageSha256, ThresholdSha256 } from 'crypto-conditions'
1010
import ccJsonify from './utils/ccJsonify'
1111
import sha256Hash from './sha256Hash'
1212

@@ -96,7 +96,7 @@ export default class Transaction {
9696
static makeEd25519Condition(publicKey, json = true) {
9797
const publicKeyBuffer = base58.decode(publicKey)
9898

99-
const ed25519Fulfillment = new cc.Ed25519Sha256()
99+
const ed25519Fulfillment = new Ed25519Sha256()
100100
ed25519Fulfillment.setPublicKey(publicKeyBuffer)
101101

102102
if (json) {
@@ -143,7 +143,7 @@ export default class Transaction {
143143
* @returns {Object} Preimage-Sha256 Condition (that will need to wrapped in an Output)
144144
*/
145145
static makeSha256Condition(preimage, json = true) {
146-
const sha256Fulfillment = new cc.PreimageSha256()
146+
const sha256Fulfillment = new PreimageSha256()
147147
sha256Fulfillment.setPreimage(Buffer.from(preimage))
148148

149149
if (json) {
@@ -160,7 +160,7 @@ export default class Transaction {
160160
* @returns {Object} Sha256 Threshold Condition (that will need to wrapped in an Output)
161161
*/
162162
static makeThresholdCondition(threshold, subconditions = [], json = true) {
163-
const thresholdCondition = new cc.ThresholdSha256()
163+
const thresholdCondition = new ThresholdSha256()
164164
thresholdCondition.setThreshold(threshold)
165165

166166
subconditions.forEach((subcondition) => {
@@ -244,7 +244,7 @@ export default class Transaction {
244244
.concat(input.fulfills.transaction_id)
245245
.concat(input.fulfills.output_index) : serializedTransaction
246246
const transactionHash = sha256Hash(transactionUniqueFulfillment)
247-
const ed25519Fulfillment = new cc.Ed25519Sha256()
247+
const ed25519Fulfillment = new Ed25519Sha256()
248248
ed25519Fulfillment.sign(Buffer.from(transactionHash, 'hex'), privateKeyBuffer)
249249
const fulfillmentUri = ed25519Fulfillment.serializeUri()
250250

0 commit comments

Comments
 (0)