Skip to content

Commit

Permalink
refactor!: refactor the SDK to use the new crypto package
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
 - Bip32PublicKey removed from core and replaced by the Bip32PublicKeyHex type from the crypto package.
 - Bip32PrivateKey removed from core and replaced by the Bip32PrivateKeyHex type from the crypto package.
 - Ed25519PublicKey removed from core and replaced by the Ed25519PublicKeyHex type from the crypto package.
 - Ed25519PrivateKey removed from core and replaced by the Ed25519PrivateKeyHex type from the crypto package.
 - Ed25519KeyHash removed from core and replaced by the Ed25519KeyHashHex type from the the crypto package.
 - Ed25519Signature removed from core and replaced by the Ed25519SignatureHex type from the crypto package.
 - Hash32ByteBase16 removed from core and replaced by the Hash32ByteBase16 type from the crypto package.
 - Hash28ByteBase16 removed from core and replaced by the Hash28ByteBase16 type from the crypto package.
 - The KeyAgent interface now has a new field bip32Ed25519.
 - The KeyAgentBase class and all its derived classes (InMemoryKeyAgent, LedgerKeyAgent and TrezorKeyAgent)  must now be provided with a Bip32Ed25519 implementation on their constructors.
 - Bip32Path type was removed from the key-management package and replaced by the Bip32Path from the crypto package.
  • Loading branch information
AngelCastilloB committed Feb 3, 2023
1 parent 030753d commit 3b41320
Show file tree
Hide file tree
Showing 127 changed files with 718 additions and 764 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/continuous-integration-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
FAUCET_PROVIDER: 'cardano-wallet'
FAUCET_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:8090/v2","mnemonic":"fire method repair aware foot tray accuse brother popular olive find account sick rocket next"}'
KEY_MANAGEMENT_PROVIDER: 'inMemory'
KEY_MANAGEMENT_PARAMS: '{"accountIndex": 0, "chainId":{"networkId": 0, "networkMagic": 888}, "password":"some_password","mnemonic":"vacant violin soft weird deliver render brief always monitor general maid smart jelly core drastic erode echo there clump dizzy card filter option defense"}'
KEY_MANAGEMENT_PARAMS: '{"bip32Ed25519": "CML", "accountIndex": 0, "chainId":{"networkId": 0, "networkMagic": 888}, "password":"some_password","mnemonic":"vacant violin soft weird deliver render brief always monitor general maid smart jelly core drastic erode echo there clump dizzy card filter option defense"}'
ASSET_PROVIDER: 'http'
ASSET_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4000/asset"}'
CHAIN_HISTORY_PROVIDER: 'http'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
FAUCET_PROVIDER: 'cardano-wallet'
FAUCET_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:8090/v2","mnemonic":"fire method repair aware foot tray accuse brother popular olive find account sick rocket next"}'
KEY_MANAGEMENT_PROVIDER: 'inMemory'
KEY_MANAGEMENT_PARAMS: '{"accountIndex": 0, "chainId":{"networkId": 0, "networkMagic": 888}, "password":"some_password","mnemonic":"vacant violin soft weird deliver render brief always monitor general maid smart jelly core drastic erode echo there clump dizzy card filter option defense"}'
KEY_MANAGEMENT_PARAMS: '{"bip32Ed25519": "CML", "accountIndex": 0, "chainId":{"networkId": 0, "networkMagic": 888}, "password":"some_password","mnemonic":"vacant violin soft weird deliver render brief always monitor general maid smart jelly core drastic erode echo there clump dizzy card filter option defense"}'
ASSET_PROVIDER: 'http'
ASSET_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4000/asset"}'
CHAIN_HISTORY_PROVIDER: 'http'
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ COPY --from=cardano-services-builder /app/packages/ogmios/dist /app/packages/ogm
COPY --from=cardano-services-builder /app/packages/ogmios/package.json /app/packages/ogmios/package.json
COPY --from=cardano-services-builder /app/packages/util/dist /app/packages/util/dist
COPY --from=cardano-services-builder /app/packages/util/package.json /app/packages/util/package.json
COPY --from=cardano-services-builder /app/packages/crypto/dist /app/packages/crypto/dist
COPY --from=cardano-services-builder /app/packages/crypto/package.json /app/packages/crypto/package.json

FROM cardano-services as http-server
ARG NETWORK=mainnet
Expand Down
1 change: 1 addition & 0 deletions packages/cardano-services/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
},
"dependencies": {
"@cardano-sdk/core": "^0.7.0",
"@cardano-sdk/crypto": "^0.1.0",
"@cardano-sdk/ogmios": "^0.7.0",
"@cardano-sdk/util": "^0.7.0",
"amqplib": "^0.10.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Asset, Cardano } from '@cardano-sdk/core';
import { BigIntMath, Hash32ByteBase16, HexBlob } from '@cardano-sdk/util';
import { BigIntMath, HexBlob } from '@cardano-sdk/util';
import {
BlockModel,
BlockOutputModel,
Expand All @@ -19,6 +19,7 @@ import {
WithCertType,
WithdrawalModel
} from './types';
import { Hash32ByteBase16 } from '@cardano-sdk/crypto';
import {
isDelegationCertModel,
isMirCertModel,
Expand Down Expand Up @@ -140,15 +141,15 @@ export const mapCertificate = (
? Cardano.CertificateType.StakeKeyRegistration
: Cardano.CertificateType.StakeKeyDeregistration,
cert_index: certModel.cert_index,
stakeKeyHash: Cardano.Ed25519KeyHash.fromRewardAccount(certModel.address as unknown as Cardano.RewardAccount)
stakeKeyHash: Cardano.RewardAccount.toHash(Cardano.RewardAccount(certModel.address))
} as WithCertIndex<Cardano.StakeAddressCertificate>;

if (isDelegationCertModel(certModel))
return {
__typename: Cardano.CertificateType.StakeDelegation,
cert_index: certModel.cert_index,
poolId: certModel.pool_id as unknown as Cardano.PoolId,
stakeKeyHash: Cardano.Ed25519KeyHash.fromRewardAccount(certModel.address as unknown as Cardano.RewardAccount)
stakeKeyHash: Cardano.RewardAccount.toHash(Cardano.RewardAccount(certModel.address))
} as WithCertIndex<Cardano.StakeDelegationCertificate>;

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import {
StakePoolResults,
StakePoolStatsModel
} from './types';
import { Hash32ByteBase16, bufferToHexString, isNotNil } from '@cardano-sdk/util';
import { Hash32ByteBase16 } from '@cardano-sdk/crypto';
import { bufferToHexString, isNotNil } from '@cardano-sdk/util';
import Fraction from 'fraction.js';

const getPoolStatus = (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Cardano, SerializationError, SerializationFailure, createUtxoId, jsonToNativeScript } from '@cardano-sdk/core';
import { Hash32ByteBase16, HexBlob, isNotNil } from '@cardano-sdk/util';
import { Hash32ByteBase16 } from '@cardano-sdk/crypto';
import { HexBlob, isNotNil } from '@cardano-sdk/util';
import { ReferenceScriptType, UtxoModel } from './types';
import { generateAssetId } from './util';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import {
WithdrawalModel
} from '../../../src/ChainHistory/DbSyncChainHistory/types';
import { Cardano } from '@cardano-sdk/core';
import { Hash32ByteBase16, HexBlob } from '@cardano-sdk/util';
import { Hash32ByteBase16 } from '@cardano-sdk/crypto';
import { HexBlob } from '@cardano-sdk/util';

const blockHash = '7a48b034645f51743550bbaf81f8a14771e58856e031eb63844738ca8ad72298';
const poolId = 'pool1zuevzm3xlrhmwjw87ec38mzs02tlkwec9wxpgafcaykmwg7efhh';
Expand Down Expand Up @@ -252,12 +253,12 @@ describe('chain history mappers', () => {
expect(registrationResult).toEqual<WithCertIndex<Cardano.StakeAddressCertificate>>({
__typename: Cardano.CertificateType.StakeKeyRegistration,
cert_index: 0,
stakeKeyHash: Cardano.Ed25519KeyHash.fromRewardAccount(Cardano.RewardAccount(stakeAddress))
stakeKeyHash: Cardano.RewardAccount.toHash(Cardano.RewardAccount(stakeAddress))
});
expect(deregistrationResult).toEqual<WithCertIndex<Cardano.StakeAddressCertificate>>({
__typename: Cardano.CertificateType.StakeKeyDeregistration,
cert_index: 0,
stakeKeyHash: Cardano.Ed25519KeyHash.fromRewardAccount(Cardano.RewardAccount(stakeAddress))
stakeKeyHash: Cardano.RewardAccount.toHash(Cardano.RewardAccount(stakeAddress))
});
});
test('map DelegationCertModel to Cardano.StakeDelegationCertificate', () => {
Expand All @@ -271,7 +272,7 @@ describe('chain history mappers', () => {
__typename: Cardano.CertificateType.StakeDelegation,
cert_index: 0,
poolId: Cardano.PoolId(poolId),
stakeKeyHash: Cardano.Ed25519KeyHash.fromRewardAccount(Cardano.RewardAccount(stakeAddress))
stakeKeyHash: Cardano.RewardAccount.toHash(Cardano.RewardAccount(stakeAddress))
});
});
});
Expand Down Expand Up @@ -315,7 +316,7 @@ describe('chain history mappers', () => {
const certificates: Cardano.Certificate[] = [
{
__typename: Cardano.CertificateType.StakeKeyRegistration,
stakeKeyHash: Cardano.Ed25519KeyHash.fromRewardAccount(Cardano.RewardAccount(stakeAddress))
stakeKeyHash: Cardano.RewardAccount.toHash(Cardano.RewardAccount(stakeAddress))
}
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
mapRelay,
toStakePoolResults
} from '../../../src';
import { Hash32ByteBase16 } from '@cardano-sdk/util';
import { Hash32ByteBase16 } from '@cardano-sdk/crypto';
import { mockStakeDistribution } from '../../../../core/test/CardanoNode/mocks';

// eslint-disable-next-line max-statements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
UNLIMITED_CACHE_TTL,
createHttpStakePoolExtMetadataService
} from '../../src';
import { Hash32ByteBase16 } from '@cardano-sdk/util';
import { Hash32ByteBase16 } from '@cardano-sdk/crypto';
import { INFO, createLogger } from 'bunyan';
import { LedgerTipModel, findLedgerTip } from '../../src/util/DbSyncProvider';
import { OgmiosCardanoNode } from '@cardano-sdk/ogmios';
Expand Down
3 changes: 2 additions & 1 deletion packages/cardano-services/test/Utxo/UtxoHttpService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { Asset, Cardano, ProviderError, ProviderFailure, UtxoProvider } from '@c
import { CreateHttpProviderConfig, utxoHttpProvider } from '@cardano-sdk/cardano-services-client';
import { DataMocks } from '../data-mocks';
import { DbSyncUtxoProvider, HttpServer, HttpServerConfig, UtxoHttpService } from '../../src';
import { Hash32ByteBase16, HexBlob } from '@cardano-sdk/util';
import { Hash32ByteBase16 } from '@cardano-sdk/crypto';
import { HexBlob } from '@cardano-sdk/util';
import { INFO, createLogger } from 'bunyan';
import { LedgerTipModel, findLedgerTip } from '../../src/util/DbSyncProvider';
import { OgmiosCardanoNode } from '@cardano-sdk/ogmios';
Expand Down
5 changes: 3 additions & 2 deletions packages/cardano-services/test/data-mocks/tx.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Cardano } from '@cardano-sdk/core';
import { Hash32ByteBase16 } from '@cardano-sdk/util';
import { Ed25519KeyHashHex, Hash32ByteBase16 } from '@cardano-sdk/crypto';

import merge from 'lodash/merge';

export const valueWithCoinOnly: Cardano.Value = {
Expand Down Expand Up @@ -97,7 +98,7 @@ export const withAuxiliaryData: Cardano.HydratedTx = merge(withAssets, {
export const delegationCertificate: Cardano.StakeDelegationCertificate = {
__typename: Cardano.CertificateType.StakeDelegation,
poolId: Cardano.PoolId('pool1cjm567pd9eqj7wlpuq2mnsasw2upewq0tchg4n8gktq5k7eepvr'),
stakeKeyHash: Cardano.Ed25519KeyHash('f15db05f56035465bf8900a09bdaa16c3d8b8244fea686524408dd80')
stakeKeyHash: Ed25519KeyHashHex('f15db05f56035465bf8900a09bdaa16c3d8b8244fea686524408dd80')
};

export const collateralInputs = [
Expand Down
1 change: 1 addition & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"dependencies": {
"@cardano-ogmios/client": "5.5.7",
"@cardano-ogmios/schema": "5.5.7",
"@cardano-sdk/crypto": "^0.1.0",
"@cardano-sdk/util": "^0.7.0",
"@dcspark/cardano-multiplatform-lib-nodejs": "^3.1.1",
"@emurgo/cip14-js": "^3.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/Asset/types/NftMetadata.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable wrap-regex */
import { Metadatum } from '../../Cardano';
import { InvalidStringError, OpaqueString } from '@cardano-sdk/util';
import { Metadatum } from '../../Cardano';

export type Uri = OpaqueString<'Uri'>;
export const Uri = (uri: string) => {
Expand Down
5 changes: 3 additions & 2 deletions packages/core/src/CML/address.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { Address, Ed25519KeyHash, NetworkId, RewardAccount } from '../Cardano';
import * as Crypto from '@cardano-sdk/crypto';
import { Address, NetworkId, RewardAccount } from '../Cardano';
import { CML } from './CML';
import { parseCmlAddress } from './parseCmlAddress';
import { usingAutoFree } from '@cardano-sdk/util';

export const addressNetworkId = (address: RewardAccount | Address): NetworkId =>
usingAutoFree((scope) => parseCmlAddress(scope, address.toString())!.network_id());

export const createRewardAccount = (stakeKeyHash: Ed25519KeyHash, networkId: NetworkId) =>
export const createRewardAccount = (stakeKeyHash: Crypto.Ed25519KeyHashHex, networkId: NetworkId) =>
usingAutoFree((scope) => {
const keyHash = scope.manage(CML.Ed25519KeyHash.from_hex(stakeKeyHash.toString()));
const stakeCredential = scope.manage(CML.StakeCredential.from_keyhash(keyHash));
Expand Down
20 changes: 11 additions & 9 deletions packages/core/src/CML/cmlToCore/certificate.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as Crypto from '@cardano-sdk/crypto';
import { CML } from '../CML';
import {
Certificate,
CertificateType,
Ed25519KeyHash,
EpochNo,
GenesisKeyDelegationCertificate,
PoolId,
Expand All @@ -15,22 +15,22 @@ import {
StakeDelegationCertificate,
VrfVkHex
} from '../../Cardano/types';
import { Hash28ByteBase16, Hash32ByteBase16, usingAutoFree } from '@cardano-sdk/util';
import { NetworkId } from '../../Cardano/ChainId';
import { NotImplementedError, SerializationError, SerializationFailure } from '../../errors';
import { usingAutoFree } from '@cardano-sdk/util';

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

const stakeDeregistration = (certificate: CML.StakeDeregistration): StakeAddressCertificate =>
usingAutoFree((scope) => ({
__typename: CertificateType.StakeKeyDeregistration,
stakeKeyHash: Ed25519KeyHash(
stakeKeyHash: Crypto.Ed25519KeyHashHex(
Buffer.from(scope.manage(scope.manage(certificate.stake_credential()).to_keyhash())!.to_bytes()).toString('hex')
)
}));
Expand All @@ -39,7 +39,7 @@ const stakeDelegation = (certificate: CML.StakeDelegation): StakeDelegationCerti
usingAutoFree((scope) => ({
__typename: CertificateType.StakeDelegation,
poolId: PoolId(scope.manage(certificate.pool_keyhash()).to_bech32('pool')),
stakeKeyHash: Ed25519KeyHash(
stakeKeyHash: Crypto.Ed25519KeyHashHex(
Buffer.from(scope.manage(scope.manage(certificate.stake_credential()).to_keyhash())!.to_bytes()).toString('hex')
)
}));
Expand Down Expand Up @@ -97,7 +97,9 @@ const jsonMetadata = (poolMetadata?: CML.PoolMetadata): PoolMetadataJson | undef
usingAutoFree((scope) => {
if (!poolMetadata) return;
return {
hash: Hash32ByteBase16(Buffer.from(scope.manage(poolMetadata.pool_metadata_hash()).to_bytes()).toString('hex')),
hash: Crypto.Hash32ByteBase16(
Buffer.from(scope.manage(poolMetadata.pool_metadata_hash()).to_bytes()).toString('hex')
),
url: scope.manage(poolMetadata.url()).url()
};
});
Expand Down Expand Up @@ -135,9 +137,9 @@ const poolRetirement = (certificate: CML.PoolRetirement): PoolRetirementCertific
const genesisKeyDelegation = (certificate: CML.GenesisKeyDelegation): GenesisKeyDelegationCertificate =>
usingAutoFree((scope) => ({
__typename: CertificateType.GenesisKeyDelegation,
genesisDelegateHash: Hash28ByteBase16(scope.manage(certificate.genesis_delegate_hash()).to_hex()),
genesisHash: Hash28ByteBase16(scope.manage(certificate.genesishash()).to_hex()),
vrfKeyHash: Hash32ByteBase16(scope.manage(certificate.vrf_keyhash()).to_hex())
genesisDelegateHash: Crypto.Hash28ByteBase16(scope.manage(certificate.genesis_delegate_hash()).to_hex()),
genesisHash: Crypto.Hash28ByteBase16(scope.manage(certificate.genesishash()).to_hex()),
vrfKeyHash: Crypto.Hash32ByteBase16(scope.manage(certificate.vrf_keyhash()).to_hex())
}));

export const createCertificate = (cmlCertificate: CML.Certificate): Certificate =>
Expand Down
23 changes: 12 additions & 11 deletions packages/core/src/CML/cmlToCore/cmlToCore.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as Cardano from '../../Cardano';
import { Base64Blob, Hash32ByteBase16, HexBlob, ManagedFreeableScope, usingAutoFree } from '@cardano-sdk/util';
import * as Crypto from '@cardano-sdk/crypto';
import { Base64Blob, HexBlob, ManagedFreeableScope, usingAutoFree } from '@cardano-sdk/util';
import { CML } from '../CML';
import { PlutusLanguageVersion, ScriptType } from '../../Cardano';
import { ScriptKind } from '@dcspark/cardano-multiplatform-lib-nodejs';
Expand All @@ -10,13 +11,13 @@ import { createCertificate } from './certificate';

export const txRequiredExtraSignatures = (
signatures: CML.Ed25519KeyHashes | undefined
): Cardano.Ed25519KeyHash[] | undefined =>
): Crypto.Ed25519KeyHashHex[] | undefined =>
usingAutoFree((scope) => {
if (!signatures) return;
const requiredSignatures: Cardano.Ed25519KeyHash[] = [];
const requiredSignatures: Crypto.Ed25519KeyHashHex[] = [];
for (let i = 0; i < signatures.len(); i++) {
const signature = scope.manage(signatures.get(i));
const cardanoSignature = Cardano.Ed25519KeyHash(Buffer.from(signature.to_bytes()).toString('hex'));
const cardanoSignature = Crypto.Ed25519KeyHashHex(Buffer.from(signature.to_bytes()).toString('hex'));
requiredSignatures.push(cardanoSignature);
}
return requiredSignatures;
Expand Down Expand Up @@ -71,7 +72,7 @@ export const nativeScript = (script: CML.NativeScript): Cardano.NativeScript =>
case Cardano.NativeScriptKind.RequireSignature: {
coreScript = {
__type: Cardano.ScriptType.Native,
keyHash: Cardano.Ed25519KeyHash(
keyHash: Crypto.Ed25519KeyHashHex(
bytesToHex(scope.manage(scope.manage(script.as_script_pubkey())!.addr_keyhash()).to_bytes()).toString()
),
kind: Cardano.NativeScriptKind.RequireSignature
Expand Down Expand Up @@ -188,7 +189,7 @@ export const txOut = (output: CML.TransactionOutput): Cardano.TxOut =>
return {
address: Cardano.Address(address),
datum: inlineDatum ? bytesToHex(inlineDatum) : undefined,
datumHash: dataHashBytes ? Hash32ByteBase16.fromHexBlob(bytesToHex(dataHashBytes)) : undefined,
datumHash: dataHashBytes ? Crypto.Hash32ByteBase16.fromHexBlob(bytesToHex(dataHashBytes)) : undefined,
scriptReference: scriptRef ? getCoreScript(scope, scope.manage(scriptRef.script())) : undefined,
value: value(scope.manage(output.amount()))
};
Expand Down Expand Up @@ -281,7 +282,7 @@ export const txBody = (body: CML.TransactionBody): Cardano.TxBody =>
referenceInputs: cslReferenceInputs ? txInputs(cslReferenceInputs) : undefined,
requiredExtraSignatures: txRequiredExtraSignatures(scope.manage(body.required_signers())),
scriptIntegrityHash:
cslScriptDataHash && Hash32ByteBase16(Buffer.from(cslScriptDataHash.to_bytes()).toString('hex')),
cslScriptDataHash && Crypto.Hash32ByteBase16(Buffer.from(cslScriptDataHash.to_bytes()).toString('hex')),
totalCollateral: cslTotalCollateral ? BigInt(cslTotalCollateral.to_str()) : undefined,
validityInterval: validityInterval(scope, body),
withdrawals: txWithdrawals(scope.manage(body.withdrawals()))
Expand All @@ -299,10 +300,10 @@ export const txWitnessBootstrap = (bootstraps?: CML.BootstrapWitnesses): Cardano
result.push({
addressAttributes: attributes?.length > 0 ? Base64Blob.fromBytes(attributes) : undefined,
chainCode: chainCode?.length > 0 ? HexBlob.fromBytes(chainCode) : undefined,
key: Cardano.Ed25519PublicKey(
key: Crypto.Ed25519PublicKeyHex(
Buffer.from(scope.manage(scope.manage(bootstrap.vkey()).public_key()).as_bytes()).toString('hex')
),
signature: Cardano.Ed25519Signature(scope.manage(bootstrap.signature()).to_hex())
signature: Crypto.Ed25519SignatureHex(scope.manage(bootstrap.signature()).to_hex())
});
}
return result;
Expand Down Expand Up @@ -390,10 +391,10 @@ export const txWitnessSet = (witnessSet: CML.TransactionWitnessSet): Cardano.Wit
for (let i = 0; i < vkeys!.len(); i++) {
const witness = scope.manage(vkeys.get(i));
txSignatures.set(
Cardano.Ed25519PublicKey(
Crypto.Ed25519PublicKeyHex(
Buffer.from(scope.manage(scope.manage(witness.vkey()).public_key()).as_bytes()).toString('hex')
),
Cardano.Ed25519Signature(scope.manage(witness.signature()).to_hex())
Crypto.Ed25519SignatureHex(scope.manage(witness.signature()).to_hex())
);
}
}
Expand Down
7 changes: 4 additions & 3 deletions packages/core/src/CML/coreToCml/certificate.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as Cardano from '../../Cardano/types';
import * as Crypto from '@cardano-sdk/crypto';
import {
Address,
BigNum,
Expand Down Expand Up @@ -33,7 +34,7 @@ import {
import { ManagedFreeableScope } from '@cardano-sdk/util';
import { NotImplementedError } from '../../errors';

export const stakeKeyRegistration = (scope: ManagedFreeableScope, stakeKeyHash: Cardano.Ed25519KeyHash) =>
export const stakeKeyRegistration = (scope: ManagedFreeableScope, stakeKeyHash: Crypto.Ed25519KeyHashHex) =>
scope.manage(
Certificate.new_stake_registration(
scope.manage(
Expand All @@ -48,7 +49,7 @@ export const stakeKeyRegistration = (scope: ManagedFreeableScope, stakeKeyHash:
)
);

export const stakeKeyDeregistration = (scope: ManagedFreeableScope, stakeKeyHash: Cardano.Ed25519KeyHash) =>
export const stakeKeyDeregistration = (scope: ManagedFreeableScope, stakeKeyHash: Crypto.Ed25519KeyHashHex) =>
scope.manage(
Certificate.new_stake_deregistration(
scope.manage(
Expand Down Expand Up @@ -166,7 +167,7 @@ export const poolRetirement = (scope: ManagedFreeableScope, poolId: Cardano.Pool

export const stakeDelegation = (
scope: ManagedFreeableScope,
stakeKeyHash: Cardano.Ed25519KeyHash,
stakeKeyHash: Crypto.Ed25519KeyHashHex,
delegatee: Cardano.PoolId
) =>
scope.manage(
Expand Down
Loading

0 comments on commit 3b41320

Please sign in to comment.