Skip to content

Commit

Permalink
feat: cardano-serialization-lib added to the repo as a tar
Browse files Browse the repository at this point in the history
While we wait for multiassets support on cardano-serialization-lib and
for it to be pushed to the npm registry, we will import as a library
that's pushed to the repo. Building and importing the repo is out of the
scope as the preferred way is to impor the library from the registry
itself.
  • Loading branch information
AlanVerbner committed Jan 14, 2021
1 parent 9219731 commit f0adf3c
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 23 deletions.
2 changes: 1 addition & 1 deletion cardano-rosetta-server/package.json
Expand Up @@ -73,7 +73,7 @@
"typescript": "3.9.5"
},
"dependencies": {
"@emurgo/cardano-serialization-lib-nodejs": "4.3.0",
"cardano-serialization-lib": "file:./packages-cache/cardano-serialization-lib-5.0.0-98fdbfacef9e24dfb90b955dfadb1a3ff8e1425d-rc.0.tgz",
"cbor": "5.1.0",
"dotenv": "8.2.0",
"envalid": "6.0.2",
Expand Down
Binary file not shown.
Binary file not shown.
@@ -1,12 +1,6 @@
/* eslint-disable camelcase */
/* eslint-disable wrap-regex */
import CardanoWasm, {
BigNum,
Ed25519Signature,
PublicKey,
StakeCredential,
Vkey
} from '@emurgo/cardano-serialization-lib-nodejs';
import CardanoWasm, { BigNum, Ed25519Signature, PublicKey, StakeCredential, Vkey } from 'cardano-serialization-lib';
import cbor from 'cbor';
import { Logger } from 'fastify';
import { generateBaseAddress, generateEnterpriseAddress, generateRewardAddress } from '../utils/cardano/addresses';
Expand Down
@@ -1,4 +1,4 @@
import CardanoWasm, { StakeCredential } from '@emurgo/cardano-serialization-lib-nodejs';
import CardanoWasm, { StakeCredential } from 'cardano-serialization-lib';
import { Logger } from 'fastify';
import { NetworkIdentifier } from '../constants';

Expand Down
Expand Up @@ -3,8 +3,9 @@ import CardanoWasm, {
BigNum,
StakeDelegation,
StakeDeregistration,
StakeRegistration
} from '@emurgo/cardano-serialization-lib-nodejs';
StakeRegistration,
Value
} from 'cardano-serialization-lib';
import { Logger } from 'fastify';
import { NetworkIdentifier, OperationType } from '../constants';
import { ErrorFactory } from '../errors';
Expand All @@ -26,17 +27,18 @@ const validateAndParseTransactionOutput = (
logger.error('[validateAndParseTransactionOutput] Output has missing address field');
throw ErrorFactory.transactionOutputsParametersMissingError('Output has missing address field');
}
const value = output.amount?.value;
if (!output.amount || !value) {
const outputValue = output.amount?.value;
if (!output.amount || !outputValue) {
logger.error('[validateAndParseTransactionOutput] Output has missing amount value field');
throw ErrorFactory.transactionOutputsParametersMissingError('Output has missing amount value field');
}
if (/^-\d+/.test(value)) {
if (/^-\d+/.test(outputValue)) {
logger.error('[validateAndParseTransactionOutput] Output has negative value');
throw ErrorFactory.transactionOutputsParametersMissingError('Output has negative amount value');
}
try {
return CardanoWasm.TransactionOutput.new(address, BigNum.from_str(output.amount?.value));
const value = Value.new(BigNum.from_str(output.amount?.value));
return CardanoWasm.TransactionOutput.new(address, value);
} catch (error) {
throw ErrorFactory.transactionOutputDeserializationError(error.toString());
}
Expand Down
@@ -1,5 +1,5 @@
/* eslint-disable camelcase */
import CardanoWasm, { StakeCredential } from '@emurgo/cardano-serialization-lib-nodejs';
import CardanoWasm, { StakeCredential } from 'cardano-serialization-lib';
import { Logger } from 'fastify';
import { ErrorFactory } from '../errors';
import { isKeyValid } from '../validations';
Expand Down
@@ -1,4 +1,4 @@
import CardanoWasm from '@emurgo/cardano-serialization-lib-nodejs';
import CardanoWasm from 'cardano-serialization-lib';
import { Logger } from 'fastify';
import { ADA, ADA_DECIMALS, CurveType, OperationType } from '../constants';
import { ErrorFactory } from '../errors';
Expand Down Expand Up @@ -29,7 +29,13 @@ const parseOutputToOperation = (
operation_identifier: { index },
related_operations: relatedOperations,
account: { address: output.address().to_bech32(addressPrefix) },
amount: { value: output.amount().to_str(), currency: { symbol: ADA, decimals: ADA_DECIMALS } },
amount: {
value: output
.amount()
.coin()
.to_str(),
currency: { symbol: ADA, decimals: ADA_DECIMALS }
},
status: '',
type: OperationType.OUTPUT
});
Expand Down
9 changes: 4 additions & 5 deletions cardano-rosetta-server/yarn.lock
Expand Up @@ -324,11 +324,6 @@
exec-sh "^0.3.2"
minimist "^1.2.0"

"@emurgo/cardano-serialization-lib-nodejs@4.3.0":
version "4.3.0"
resolved "https://registry.yarnpkg.com/@emurgo/cardano-serialization-lib-nodejs/-/cardano-serialization-lib-nodejs-4.3.0.tgz#38134fa547af7211bb4988dca3f4da307159f758"
integrity sha512-sS3AuAtzetUkJy9eDNyMG7/RYrjwz7h573uLEpTePpw3vuXMf8Z32nxngca7Cibp1sVZ2DTyY9afTb92uRuptQ==

"@istanbuljs/load-nyc-config@^1.0.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz#fd3db1d59ecf7cf121e80650bb86712f9b55eced"
Expand Down Expand Up @@ -1880,6 +1875,10 @@ capture-exit@^2.0.0:
dependencies:
rsvp "^4.8.4"

"cardano-serialization-lib@file:./lib/cardano-serialization-lib-5.0.0-98fdbfacef9e24dfb90b955dfadb1a3ff8e1425d-rc.0.tgz":
version "5.0.0-rc.0"
resolved "file:./lib/cardano-serialization-lib-5.0.0-98fdbfacef9e24dfb90b955dfadb1a3ff8e1425d-rc.0.tgz#271675fcd46fd5abb527e59d7c507e66c93c2fc1"

caseless@~0.12.0:
version "0.12.0"
resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc"
Expand Down

0 comments on commit f0adf3c

Please sign in to comment.