Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
ProviderFailure,
SubmitTxArgs,
TxSubmitProvider,
cslUtil
cmlUtil
} from '@cardano-sdk/core';
import { Channel, Connection, connect } from 'amqplib';
import { Logger } from 'ts-log';
Expand Down Expand Up @@ -171,7 +171,7 @@ export class RabbitMqTxSubmitProvider implements TxSubmitProvider {
};

try {
txId = cslUtil.deserializeTx(signedTransaction).id.toString();
txId = cmlUtil.deserializeTx(signedTransaction).id.toString();

this.#dependencies.logger.info(`${moduleName}: queuing tx id: ${txId}`);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { CONNECTION_ERROR_EVENT, TX_SUBMISSION_QUEUE, serializeError, waitForPen
import { Channel, Connection, Message, connect } from 'amqplib';
import { EventEmitter } from 'events';
import { Logger } from 'ts-log';
import { ProviderError, ProviderFailure, TxSubmitProvider, cslUtil } from '@cardano-sdk/core';
import { ProviderError, ProviderFailure, TxSubmitProvider, cmlUtil } from '@cardano-sdk/core';
import { bufferToHexString } from '@cardano-sdk/util';

const moduleName = 'TxSubmitWorker';
Expand Down Expand Up @@ -281,7 +281,7 @@ export class TxSubmitWorker extends EventEmitter {
const txBody = new Uint8Array(content);

// Register the handling of current transaction
txId = cslUtil.deserializeTx(txBody).id.toString();
txId = cmlUtil.deserializeTx(txBody).id.toString();

this.#dependencies.logger.info(`${moduleName}: submitting tx #${counter} id: ${txId}`);
this.#dependencies.logger.debug(`${moduleName}: tx #${counter} dump:`, [content.toString('hex')]);
Expand Down
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
"dependencies": {
"@cardano-ogmios/client": "5.5.5",
"@cardano-sdk/util": "^0.5.0",
"@emurgo/cardano-serialization-lib-browser": "11.0.5",
"@emurgo/cardano-serialization-lib-nodejs": "11.0.5",
"@dcspark/cardano-multiplatform-lib-browser": "^3.1.0",
"@dcspark/cardano-multiplatform-lib-nodejs": "^3.1.0",
"@emurgo/cip14-js": "^3.0.1",
"bech32": "^2.0.0",
"lodash": "^4.17.21",
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/Asset/util/assetId.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AssetId, AssetName, PolicyId } from '../../Cardano/types';
import { CSL } from '../../CSL/CSL';
import { CML } from '../../CML/CML';
import { bytesToHex } from '../../util/misc/bytesToHex';

export const policyIdFromAssetId = (assetId: AssetId): PolicyId => PolicyId(assetId.slice(0, 56));
Expand All @@ -8,7 +8,7 @@ export const assetNameFromAssetId = (assetId: AssetId): AssetName => AssetName(a
/**
* @returns {string} concatenated hex-encoded policy id and asset name
*/
export const createAssetId = (scriptHash: CSL.ScriptHash, assetName: CSL.AssetName): AssetId =>
export const createAssetId = (scriptHash: CML.ScriptHash, assetName: CML.AssetName): AssetId =>
AssetId(bytesToHex(scriptHash.to_bytes()) + bytesToHex(assetName.name()).toString());

/**
Expand All @@ -21,7 +21,7 @@ export const parseAssetId = (assetId: AssetId) => {
const policyId = policyIdFromAssetId(assetId);
const assetName = assetNameFromAssetId(assetId);
return {
assetName: CSL.AssetName.new(Buffer.from(assetName, 'hex')),
scriptHash: CSL.ScriptHash.from_bytes(Buffer.from(policyId, 'hex'))
assetName: CML.AssetName.new(Buffer.from(assetName, 'hex')),
scriptHash: CML.ScriptHash.from_bytes(Buffer.from(policyId, 'hex'))
};
};
3 changes: 3 additions & 0 deletions packages/core/src/CML/CML.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import * as CML from '@dcspark/cardano-multiplatform-lib-nodejs';
export * as CML from '@dcspark/cardano-multiplatform-lib-nodejs';
export type CardanoMultiplatformLib = typeof CML;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CSL } from '../CSL';
import { CML } from '../CML';
import {
Certificate,
CertificateType,
Expand All @@ -19,23 +19,23 @@ import { NetworkId } from '../../Cardano/NetworkId';
import { NotImplementedError, SerializationError, SerializationFailure } from '../../errors';
import { usingAutoFree } from '@cardano-sdk/util';

const stakeRegistration = (certificate: CSL.StakeRegistration): StakeAddressCertificate =>
const stakeRegistration = (certificate: CML.StakeRegistration): StakeAddressCertificate =>
usingAutoFree((scope) => ({
__typename: CertificateType.StakeKeyRegistration,
stakeKeyHash: Ed25519KeyHash(
Buffer.from(scope.manage(scope.manage(certificate.stake_credential()).to_keyhash())!.to_bytes()).toString('hex')
)
}));

const stakeDeregistration = (certificate: CSL.StakeDeregistration): StakeAddressCertificate =>
const stakeDeregistration = (certificate: CML.StakeDeregistration): StakeAddressCertificate =>
usingAutoFree((scope) => ({
__typename: CertificateType.StakeKeyDeregistration,
stakeKeyHash: Ed25519KeyHash(
Buffer.from(scope.manage(scope.manage(certificate.stake_credential()).to_keyhash())!.to_bytes()).toString('hex')
)
}));

const stakeDelegation = (certificate: CSL.StakeDelegation): StakeDelegationCertificate =>
const stakeDelegation = (certificate: CML.StakeDelegation): StakeDelegationCertificate =>
usingAutoFree((scope) => ({
__typename: CertificateType.StakeDelegation,
poolId: PoolId(scope.manage(certificate.pool_keyhash()).to_bech32('pool')),
Expand All @@ -44,7 +44,7 @@ const stakeDelegation = (certificate: CSL.StakeDelegation): StakeDelegationCerti
)
}));

const createCardanoRelays = (relays: CSL.Relays): Relay[] =>
const createCardanoRelays = (relays: CML.Relays): Relay[] =>
usingAutoFree((scope) => {
const result: Relay[] = [];
for (let i = 0; i < relays.len(); i++) {
Expand Down Expand Up @@ -81,19 +81,19 @@ const createCardanoRelays = (relays: CSL.Relays): Relay[] =>
return result;
});

const createCardanoOwners = (owners: CSL.Ed25519KeyHashes, networkId: NetworkId): RewardAccount[] =>
const createCardanoOwners = (owners: CML.Ed25519KeyHashes, networkId: NetworkId): RewardAccount[] =>
usingAutoFree((scope) => {
const result: RewardAccount[] = [];
for (let i = 0; i < owners.len(); i++) {
const keyHash = scope.manage(owners.get(i));
const stakeCredential = scope.manage(CSL.StakeCredential.from_keyhash(keyHash));
const rewardAccount = scope.manage(CSL.RewardAddress.new(networkId, stakeCredential));
const stakeCredential = scope.manage(CML.StakeCredential.from_keyhash(keyHash));
const rewardAccount = scope.manage(CML.RewardAddress.new(networkId, stakeCredential));
result.push(RewardAccount(scope.manage(rewardAccount.to_address()).to_bech32()));
}
return result;
});

const jsonMetadata = (poolMetadata?: CSL.PoolMetadata): PoolMetadataJson | undefined =>
const jsonMetadata = (poolMetadata?: CML.PoolMetadata): PoolMetadataJson | undefined =>
usingAutoFree((scope) => {
if (!poolMetadata) return;
return {
Expand All @@ -102,7 +102,7 @@ const jsonMetadata = (poolMetadata?: CSL.PoolMetadata): PoolMetadataJson | undef
};
});

export const poolRegistration = (certificate: CSL.PoolRegistration): PoolRegistrationCertificate =>
export const poolRegistration = (certificate: CML.PoolRegistration): PoolRegistrationCertificate =>
usingAutoFree((scope) => {
const poolParams = scope.manage(certificate.pool_params());
const rewardAccountAddress = scope.manage(scope.manage(poolParams.reward_account()).to_address());
Expand All @@ -125,14 +125,14 @@ export const poolRegistration = (certificate: CSL.PoolRegistration): PoolRegistr
} as PoolRegistrationCertificate;
});

const poolRetirement = (certificate: CSL.PoolRetirement): PoolRetirementCertificate =>
const poolRetirement = (certificate: CML.PoolRetirement): PoolRetirementCertificate =>
usingAutoFree((scope) => ({
__typename: CertificateType.PoolRetirement,
epoch: certificate.epoch(),
poolId: PoolId(scope.manage(certificate.pool_keyhash()).to_bech32('pool'))
}));

const genesisKeyDelegaation = (certificate: CSL.GenesisKeyDelegation): GenesisKeyDelegationCertificate =>
const genesisKeyDelegaation = (certificate: CML.GenesisKeyDelegation): GenesisKeyDelegationCertificate =>
usingAutoFree((scope) => ({
__typename: CertificateType.GenesisKeyDelegation,
genesisDelegateHash: Hash32ByteBase16(
Expand All @@ -142,22 +142,22 @@ const genesisKeyDelegaation = (certificate: CSL.GenesisKeyDelegation): GenesisKe
vrfKeyHash: Hash32ByteBase16(Buffer.from(scope.manage(certificate.vrf_keyhash()).to_bytes()).toString())
}));

export const createCertificate = (cslCertificate: CSL.Certificate): Certificate =>
export const createCertificate = (cmlCertificate: CML.Certificate): Certificate =>
usingAutoFree((scope) => {
switch (cslCertificate.kind()) {
case CSL.CertificateKind.StakeRegistration:
return stakeRegistration(scope.manage(cslCertificate.as_stake_registration()!));
case CSL.CertificateKind.StakeDeregistration:
return stakeDeregistration(scope.manage(cslCertificate.as_stake_deregistration()!));
case CSL.CertificateKind.StakeDelegation:
return stakeDelegation(scope.manage(cslCertificate.as_stake_delegation()!));
case CSL.CertificateKind.PoolRegistration:
return poolRegistration(scope.manage(cslCertificate.as_pool_registration()!));
case CSL.CertificateKind.PoolRetirement:
return poolRetirement(scope.manage(cslCertificate.as_pool_retirement()!));
case CSL.CertificateKind.GenesisKeyDelegation:
return genesisKeyDelegaation(scope.manage(cslCertificate.as_genesis_key_delegation()!));
case CSL.CertificateKind.MoveInstantaneousRewardsCert:
switch (cmlCertificate.kind()) {
case CML.CertificateKind.StakeRegistration:
return stakeRegistration(scope.manage(cmlCertificate.as_stake_registration()!));
case CML.CertificateKind.StakeDeregistration:
return stakeDeregistration(scope.manage(cmlCertificate.as_stake_deregistration()!));
case CML.CertificateKind.StakeDelegation:
return stakeDelegation(scope.manage(cmlCertificate.as_stake_delegation()!));
case CML.CertificateKind.PoolRegistration:
return poolRegistration(scope.manage(cmlCertificate.as_pool_registration()!));
case CML.CertificateKind.PoolRetirement:
return poolRetirement(scope.manage(cmlCertificate.as_pool_retirement()!));
case CML.CertificateKind.GenesisKeyDelegation:
return genesisKeyDelegaation(scope.manage(cmlCertificate.as_genesis_key_delegation()!));
case CML.CertificateKind.MoveInstantaneousRewardsCert:
throw new NotImplementedError('MIR certificate conversion'); // TODO: support this certificate type
default:
throw new SerializationError(SerializationFailure.InvalidType);
Expand Down
Loading