Skip to content

Commit

Permalink
Use borc package instead of cbor
Browse files Browse the repository at this point in the history
I was running into [this bug](hildjj/node-cbor#43)
  • Loading branch information
masonforest committed Oct 25, 2019
1 parent b6778c0 commit e079c6f
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"@fortawesome/react-fontawesome": "^0.1.4",
"base64url": "^3.0.1",
"bootstrap": "^4.1.3",
"cbor": "^4.1.3",
"borc": "^2.1.1",
"che-react-number-easing": "^0.1.2",
"long": "^4.0.0",
"query-string": "^6.1.0",
Expand Down
3 changes: 2 additions & 1 deletion src/Transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
import AddressLink from "./AddressLink";
import TransactionLink from "./TransactionLink";
import "./Transaction.css";
import base64url from "base64url";
import {
contractName,
contractCreatedBy,
Expand Down Expand Up @@ -32,7 +33,7 @@ export default class Transaction extends Component {
</tr>
<tr>
<th>Contract Address</th>
<td><div>{this.props.transaction.contract_address.toString("base64")}</div></td>
<td><div>{base64url(this.props.transaction.contract_address)}</div></td>
</tr>
<tr>
<th>Contract Created By</th>
Expand Down
2 changes: 1 addition & 1 deletion src/TransactionLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import React from 'react';
import base64url from "base64url";

const AddressLink = (transactionHash) => (
<a href={`/transactions/${base64url(transactionHash)}`}>{transactionHash.toString("base64")}</a>
<a href={`/transactions/${base64url(transactionHash)}`}>{base64url(transactionHash)}</a>
)
export default AddressLink;
4 changes: 2 additions & 2 deletions src/actions/actions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as types from './actionTypes';
import cbor from 'cbor';
import cbor from 'borc';
import queryString from 'query-string';
import base64url from "base64url";
import { toKey, balanceKey, bytesToNumber } from "../helpers.js"
Expand Down Expand Up @@ -128,4 +128,4 @@ export function subscribeToBlocks(dispatch) {



const decodeBytes = (bytes) => cbor.decodeFirstSync(Buffer.from(bytes));
const decodeBytes = (bytes) => cbor.decode(Buffer.from(bytes));
4 changes: 3 additions & 1 deletion src/helpers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Long = require("long");
const cbor = require("cbor");
const cbor = require("borc");
const crypto = require("crypto");
const _ = require("lodash");

Expand All @@ -11,6 +11,8 @@ export function contractName(contractAddress) {
}

export function transactionHash(transaction) {
console.log(["doubler_coin", new Uint8Array(50000), [150000]])
console.log(objectHash(["doubler_coin", new Uint8Array(50000), [150000]]).toString("base64"))
return objectHash(_.omit(transaction, [
"hash",
"block_hash",
Expand Down
30 changes: 28 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1909,6 +1909,11 @@ bignumber.js@^8.0.2:
resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-8.1.1.tgz#4b072ae5aea9c20f6730e4e5d529df1271c4d885"
integrity sha512-QD46ppGintwPGuL1KqmwhR0O+N2cZUg8JG/VzwI2e28sM9TqHjQB10lI4QAaMHVbLzwVLLAwEglpKPViWX+5NQ==

bignumber.js@^9.0.0:
version "9.0.0"
resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.0.0.tgz#805880f84a329b5eac6e7cb6f8274b6d82bdf075"
integrity sha512-t/OYhhJ2SD+YGBQcjY8GzzDHEk9f3nerxjtfa6tlMXfe7frs/WozhvCNoGvpM0P3bNf3Gq5ZRMlGr5f3r4/N8A==

binary-extensions@^1.0.0:
version "1.13.1"
resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-1.13.1.tgz#598afe54755b2868a5330d2aff9d4ebb53209b65"
Expand Down Expand Up @@ -1962,6 +1967,17 @@ bootstrap@^4.1.3:
resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-4.3.1.tgz#280ca8f610504d99d7b6b4bfc4b68cec601704ac"
integrity sha512-rXqOmH1VilAt2DyPzluTi2blhk17bO7ef+zLLPlWvG494pDxcM234pJ8wTc/6R40UWizAIIMgxjvxZg5kmsbag==

borc@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/borc/-/borc-2.1.1.tgz#df1a4ec063b9913f2fff5e07c9377eeeff47914a"
integrity sha512-vPLLC2/gS0QN4O3cnPh+8jLshkMMD4qIfs+B1TPGPh30WrtcfItaO6j4k9alsqu/hIgKi8dVdmMvTcbq4tIF7A==
dependencies:
bignumber.js "^9.0.0"
commander "^2.15.0"
ieee754 "^1.1.8"
iso-url "~0.4.4"
json-text-sequence "~0.1.0"

brace-expansion@^1.1.7:
version "1.1.11"
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
Expand Down Expand Up @@ -2500,6 +2516,11 @@ commander@^2.11.0, commander@^2.19.0, commander@~2.20.0:
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.0.tgz#d58bb2b5c1ee8f87b0d340027e9e94e222c5a422"
integrity sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==

commander@^2.15.0:
version "2.20.3"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==

commander@~2.19.0:
version "2.19.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.19.0.tgz#f6198aa84e5b83c46054b94ddedbfed5ee9ff12a"
Expand Down Expand Up @@ -4781,7 +4802,7 @@ [email protected]:
dependencies:
harmony-reflect "^1.4.6"

ieee754@^1.1.4:
ieee754@^1.1.4, ieee754@^1.1.8:
version "1.1.13"
resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.13.tgz#ec168558e95aa181fd87d37f55c32bbcb6708b84"
integrity sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==
Expand Down Expand Up @@ -5324,6 +5345,11 @@ isexe@^2.0.0:
resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=

iso-url@~0.4.4:
version "0.4.6"
resolved "https://registry.yarnpkg.com/iso-url/-/iso-url-0.4.6.tgz#45005c4af4984cad4f8753da411b41b74cf0a8a6"
integrity sha512-YQO7+aIe6l1aSJUKOx+Vrv08DlhZeLFIVfehG2L29KLSEb9RszqPXilxJRVpp57px36BddKR5ZsebacO5qG0tg==

isobject@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/isobject/-/isobject-2.1.0.tgz#f065561096a3f1da2ef46272f815c840d87e0c89"
Expand Down Expand Up @@ -5869,7 +5895,7 @@ json-stringify-safe@~5.0.1:
resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb"
integrity sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=

json-text-sequence@^0.1:
json-text-sequence@^0.1, json-text-sequence@~0.1.0:
version "0.1.1"
resolved "https://registry.yarnpkg.com/json-text-sequence/-/json-text-sequence-0.1.1.tgz#a72f217dc4afc4629fff5feb304dc1bd51a2f3d2"
integrity sha1-py8hfcSvxGKf/1/rME3BvVGi89I=
Expand Down

0 comments on commit e079c6f

Please sign in to comment.