@rosen-chains/cardano
Advanced tools
Comparing version 0.1.2 to 0.1.3
import * as CardanoWasm from '@emurgo/cardano-serialization-lib-nodejs'; | ||
import { default as CIP14 } from '@emurgo/cip14-js'; | ||
import { CARDANO_CHAIN } from './constants'; | ||
import blake2b from 'blake2b'; | ||
import { bech32 } from 'bech32'; | ||
class CardanoUtils { | ||
@@ -85,3 +86,9 @@ /** | ||
static createFingerprint = (policyId, assetName) => { | ||
return CIP14.fromParts(policyId.to_bytes(), Buffer.from(assetName.to_js_value(), 'hex')).fingerprint(); | ||
const policyIdBytes = policyId.to_bytes(); | ||
const assetNameBytes = Buffer.from(assetName.to_js_value(), 'hex'); | ||
const hashBuf = blake2b(20) | ||
.update(new Uint8Array([...policyIdBytes, ...assetNameBytes])) | ||
.digest('binary'); | ||
const words = bech32.toWords(hashBuf); | ||
return bech32.encode('asset', words); | ||
}; | ||
@@ -102,2 +109,2 @@ /** | ||
export default CardanoUtils; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQ2FyZGFub1V0aWxzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vbGliL0NhcmRhbm9VdGlscy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFFQSxPQUFPLEtBQUssV0FBVyxNQUFNLDBDQUEwQyxDQUFDO0FBQ3hFLE9BQU8sRUFBRSxPQUFPLElBQUksS0FBSyxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFFcEQsT0FBTyxFQUFFLGFBQWEsRUFBRSxNQUFNLGFBQWEsQ0FBQztBQUc1QyxNQUFNLFlBQVk7SUFDaEI7OztPQUdHO0lBQ0gsTUFBTSxDQUFDLHlCQUF5QixHQUFHLENBQ2pDLEtBQW9CLEVBQ0gsRUFBRTtRQUNuQixNQUFNLE1BQU0sR0FBa0MsSUFBSSxHQUFHLEVBQUUsQ0FBQztRQUN4RCxJQUFJLGlCQUFpQixHQUF1QixXQUFX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ge1xuICAgIHJldHVybiBDSVAxNC5mcm9tUGFydHMoXG4gICAgICBwb2xpY3lJZC50b19ieXRlcygpLFxuICAgICAgQnVmZmVyLmZyb20oYXNzZXROYW1lLnRvX2pzX3ZhbHVlKCksICdoZXgnKVxuICAgICkuZmluZ2VycHJpbnQoKTtcbiAgfTtcblxuICAvKipcbiAgICogZ2V0IGJveCBpZCBmcm9tIENhcmRhbm9XYXNtLlRyYW5zYWN0aW9uSW5wdXQgb3IgQ2FyZGFub1V0eG9cbiAgICogQHBhcmFtIGJveCB0byBmZXRjaCBkXG4gICAqIEByZXR1cm5zIHR4X2hhc2guaW5kZXggYXMgYm94IGlkXG4gICAqL1xuICBzdGF0aWMgZ2V0Qm94SWQgPSAoXG4gICAgYm94OiBDYXJkYW5vVXR4byB8IENhcmRhbm9XYXNtLlRyYW5zYWN0aW9uSW5wdXRcbiAgKTogc3RyaW5nID0+IHtcbiAgICBpZiAoYm94IGluc3RhbmNlb2YgQ2FyZGFub1dhc20uVHJhbnNhY3Rpb25JbnB1dCkge1xuICAgICAgY29uc3QgYm94SlMgPSBib3gudG9fanNfdmFsdWUoKTtcbiAgICAgIHJldHVybiBib3hKUy50cmFuc2FjdGlvbl9pZCArICcuJyArIGJveEpTLmluZGV4O1xuICAgIH1cbiAgICByZXR1cm4gYm94LnR4SWQgKyAnLicgKyBib3guaW5kZXg7XG4gIH07XG59XG5cbmV4cG9ydCBkZWZhdWx0IENhcmRhbm9VdGlscztcbiJdfQ== | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQ2FyZGFub1V0aWxzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vbGliL0NhcmRhbm9VdGlscy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFFQSxPQUFPLEtBQUssV0FBVyxNQUFNLDBDQUEwQyxDQUFDO0FBRXhFLE9BQU8sRUFBRSxhQUFhLEVBQUUsTUFBT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2FyZGFubyBib3hcbiAgICovXG4gIHN0YXRpYyBnZXRCb3hBc3NldHMgPSAoYm94OiBDYXJkYW5vV2FzbS5UcmFuc2FjdGlvbk91dHB1dCk6IEFzc2V0QmFsYW5jZSA9PiB7XG4gICAgY29uc3QgdG9rZW5zOiBBcnJheTxUb2tlbkluZm8+ID0gW107XG4gICAgY29uc3QgYm94VmFsdWUgPSBib3guYW1vdW50KCk7XG4gICAgY29uc3QgYm94QXNzZXRzID0gYm94VmFsdWUubXVsdGlhc3NldCgpO1xuICAgIGlmIChib3hBc3NldHMpIHtcbiAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgYm94QXNzZXRzLmtleXMoKS5sZW4oKTsgaSsrKSB7XG4gICAgICAgIGNvbnN0IHNjcmlwdEhhc2ggPSBib3hBc3NldHMua2V5cygpLmdldChpKTtcbiAgICAgICAgY29uc3QgYXNzZXQgPSBib3hBc3NldHMuZ2V0KHNjcmlwdEhhc2gpITtcbiAgICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCBhc3NldC5rZXlzKCkubGVuKCk7IGorKykge1xuICAgICAgICAgIGNvbnN0IGFzc2V0TmFtZSA9IGFzc2V0LmtleXMoKS5nZXQoaik7XG4gICAgICAgICAgY29uc3QgYXNzZXRBbW91bnQgPSBhc3NldC5nZXQoYXNzZXROYW1lKSE7XG4gICAgICAgICAgY29uc3QgZmluZ2VycHJpbnQgPSB0aGlzLmNyZWF0ZUZpbmdlcnByaW50KHNjcmlwdEhhc2gsIGFzc2V0TmFtZSk7XG4gICAgICAgICAgdG9rZW5zLnB1c2goe1xuICAgICAgICAgICAgaWQ6IGZpbmdlcnByaW50LFxuICAgICAgICAgICAgdmFsdWU6IEJpZ0ludChhc3NldEFtb3VudC50b19zdHIoKSksXG4gICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9XG4gICAgcmV0dXJuIHtcbiAgICAgIG5hdGl2ZVRva2VuOiBCaWdJbnQoYm94VmFsdWUuY29pb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RzKGhhc2hCdWYpO1xuICAgIHJldHVybiBiZWNoMzIuZW5jb2RlKCdhc3NldCcsIHdvcmRzKTtcbiAgfTtcblxuICAvKipcbiAgICogZ2V0IGJveCBpZCBmcm9tIENhcmRhbm9XYXNtLlRyYW5zYWN0aW9uSW5wdXQgb3IgQ2FyZGFub1V0eG9cbiAgICogQHBhcmFtIGJveCB0byBmZXRjaCBkXG4gICAqIEByZXR1cm5zIHR4X2hhc2guaW5kZXggYXMgYm94IGlkXG4gICAqL1xuICBzdGF0aWMgZ2V0Qm94SWQgPSAoXG4gICAgYm94OiBDYXJkYW5vVXR4byB8IENhcmRhbm9XYXNtLlRyYW5zYWN0aW9uSW5wdXRcbiAgKTogc3RyaW5nID0+IHtcbiAgICBpZiAoYm94IGluc3RhbmNlb2YgQ2FyZGFub1dhc20uVHJhbnNhY3Rpb25JbnB1dCkge1xuICAgICAgY29uc3QgYm94SlMgPSBib3gudG9fanNfdmFsdWUoKTtcbiAgICAgIHJldHVybiBib3hKUy50cmFuc2FjdGlvbl9pZCArICcuJyArIGJveEpTLmluZGV4O1xuICAgIH1cbiAgICByZXR1cm4gYm94LnR4SWQgKyAnLicgKyBib3guaW5kZXg7XG4gIH07XG59XG5cbmV4cG9ydCBkZWZhdWx0IENhcmRhbm9VdGlscztcbiJdfQ== |
import { CardanoUtxo, CardanoAssetInfo, UtxoBoxesAssets } from './types'; | ||
import { AssetBalance, TokenInfo } from '@rosen-chains/abstract-chain'; | ||
import * as CardanoWasm from '@emurgo/cardano-serialization-lib-nodejs'; | ||
import { default as CIP14 } from '@emurgo/cip14-js'; | ||
import { TokenMap } from '@rosen-bridge/tokens'; | ||
import { CARDANO_CHAIN } from './constants'; | ||
import { BigNum } from '@emurgo/cardano-serialization-lib-nodejs'; | ||
import blake2b from 'blake2b'; | ||
import { bech32 } from 'bech32'; | ||
@@ -112,6 +113,9 @@ class CardanoUtils { | ||
): string => { | ||
return CIP14.fromParts( | ||
policyId.to_bytes(), | ||
Buffer.from(assetName.to_js_value(), 'hex') | ||
).fingerprint(); | ||
const policyIdBytes = policyId.to_bytes(); | ||
const assetNameBytes = Buffer.from(assetName.to_js_value(), 'hex'); | ||
const hashBuf = blake2b(20) | ||
.update(new Uint8Array([...policyIdBytes, ...assetNameBytes])) | ||
.digest('binary'); | ||
const words = bech32.toWords(hashBuf); | ||
return bech32.encode('asset', words); | ||
}; | ||
@@ -118,0 +122,0 @@ |
{ | ||
"name": "@rosen-chains/cardano", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "this project contains cardano chain for Rosen-bridge", | ||
@@ -24,6 +24,7 @@ "main": "dist/lib/index.js", | ||
"@emurgo/cardano-serialization-lib-nodejs": "^11.3.1", | ||
"@emurgo/cip14-js": "^3.0.1", | ||
"@rosen-bridge/logger-interface": "^0.1.0", | ||
"@rosen-bridge/rosen-extractor": "^0.1.7", | ||
"@rosen-chains/abstract-chain": "^0.1.7", | ||
"bech32": "^2.0.0", | ||
"blake2b": "^2.1.3", | ||
"json-bigint": "^1.0.0" | ||
@@ -33,2 +34,3 @@ }, | ||
"@babel/preset-env": "^7.19.0", | ||
"@types/blake2b": "^2.1.0", | ||
"@types/jest": "^29.4.0", | ||
@@ -35,0 +37,0 @@ "@types/jest-when": "^3.5.2", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
274562
3813
7
14
+ Addedbech32@^2.0.0
+ Addedblake2b@^2.1.3
+ Addedb4a@1.6.7(transitive)
+ Addedblake2b@2.1.4(transitive)
+ Addedblake2b-wasm@2.4.0(transitive)
+ Addednanoassert@2.0.0(transitive)
- Removed@emurgo/cip14-js@^3.0.1
- Removed@emurgo/cip14-js@3.0.1(transitive)
- Removedblake2b@2.1.3(transitive)
- Removedblake2b-wasm@1.1.7(transitive)
- Removednanoassert@1.1.0(transitive)