Skip to content

Commit 3b41320

Browse files
refactor!: refactor the SDK to use the new crypto package
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.
1 parent 030753d commit 3b41320

File tree

127 files changed

+718
-764
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+718
-764
lines changed

.github/workflows/continuous-integration-e2e.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
FAUCET_PROVIDER: 'cardano-wallet'
5353
FAUCET_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:8090/v2","mnemonic":"fire method repair aware foot tray accuse brother popular olive find account sick rocket next"}'
5454
KEY_MANAGEMENT_PROVIDER: 'inMemory'
55-
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"}'
55+
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"}'
5656
ASSET_PROVIDER: 'http'
5757
ASSET_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4000/asset"}'
5858
CHAIN_HISTORY_PROVIDER: 'http'

.github/workflows/nightly-e2e.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
FAUCET_PROVIDER: 'cardano-wallet'
6565
FAUCET_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:8090/v2","mnemonic":"fire method repair aware foot tray accuse brother popular olive find account sick rocket next"}'
6666
KEY_MANAGEMENT_PROVIDER: 'inMemory'
67-
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"}'
67+
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"}'
6868
ASSET_PROVIDER: 'http'
6969
ASSET_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4000/asset"}'
7070
CHAIN_HISTORY_PROVIDER: 'http'

Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ COPY --from=cardano-services-builder /app/packages/ogmios/dist /app/packages/ogm
4545
COPY --from=cardano-services-builder /app/packages/ogmios/package.json /app/packages/ogmios/package.json
4646
COPY --from=cardano-services-builder /app/packages/util/dist /app/packages/util/dist
4747
COPY --from=cardano-services-builder /app/packages/util/package.json /app/packages/util/package.json
48+
COPY --from=cardano-services-builder /app/packages/crypto/dist /app/packages/crypto/dist
49+
COPY --from=cardano-services-builder /app/packages/crypto/package.json /app/packages/crypto/package.json
4850

4951
FROM cardano-services as http-server
5052
ARG NETWORK=mainnet

packages/cardano-services/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
},
9696
"dependencies": {
9797
"@cardano-sdk/core": "^0.7.0",
98+
"@cardano-sdk/crypto": "^0.1.0",
9899
"@cardano-sdk/ogmios": "^0.7.0",
99100
"@cardano-sdk/util": "^0.7.0",
100101
"amqplib": "^0.10.0",

packages/cardano-services/src/ChainHistory/DbSyncChainHistory/mappers.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Asset, Cardano } from '@cardano-sdk/core';
2-
import { BigIntMath, Hash32ByteBase16, HexBlob } from '@cardano-sdk/util';
2+
import { BigIntMath, HexBlob } from '@cardano-sdk/util';
33
import {
44
BlockModel,
55
BlockOutputModel,
@@ -19,6 +19,7 @@ import {
1919
WithCertType,
2020
WithdrawalModel
2121
} from './types';
22+
import { Hash32ByteBase16 } from '@cardano-sdk/crypto';
2223
import {
2324
isDelegationCertModel,
2425
isMirCertModel,
@@ -140,15 +141,15 @@ export const mapCertificate = (
140141
? Cardano.CertificateType.StakeKeyRegistration
141142
: Cardano.CertificateType.StakeKeyDeregistration,
142143
cert_index: certModel.cert_index,
143-
stakeKeyHash: Cardano.Ed25519KeyHash.fromRewardAccount(certModel.address as unknown as Cardano.RewardAccount)
144+
stakeKeyHash: Cardano.RewardAccount.toHash(Cardano.RewardAccount(certModel.address))
144145
} as WithCertIndex<Cardano.StakeAddressCertificate>;
145146

146147
if (isDelegationCertModel(certModel))
147148
return {
148149
__typename: Cardano.CertificateType.StakeDelegation,
149150
cert_index: certModel.cert_index,
150151
poolId: certModel.pool_id as unknown as Cardano.PoolId,
151-
stakeKeyHash: Cardano.Ed25519KeyHash.fromRewardAccount(certModel.address as unknown as Cardano.RewardAccount)
152+
stakeKeyHash: Cardano.RewardAccount.toHash(Cardano.RewardAccount(certModel.address))
152153
} as WithCertIndex<Cardano.StakeDelegationCertificate>;
153154

154155
return null;

packages/cardano-services/src/StakePool/DbSyncStakePoolProvider/mappers.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ import {
2626
StakePoolResults,
2727
StakePoolStatsModel
2828
} from './types';
29-
import { Hash32ByteBase16, bufferToHexString, isNotNil } from '@cardano-sdk/util';
29+
import { Hash32ByteBase16 } from '@cardano-sdk/crypto';
30+
import { bufferToHexString, isNotNil } from '@cardano-sdk/util';
3031
import Fraction from 'fraction.js';
3132

3233
const getPoolStatus = (

packages/cardano-services/src/Utxo/DbSyncUtxoProvider/mappers.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Cardano, SerializationError, SerializationFailure, createUtxoId, jsonToNativeScript } from '@cardano-sdk/core';
2-
import { Hash32ByteBase16, HexBlob, isNotNil } from '@cardano-sdk/util';
2+
import { Hash32ByteBase16 } from '@cardano-sdk/crypto';
3+
import { HexBlob, isNotNil } from '@cardano-sdk/util';
34
import { ReferenceScriptType, UtxoModel } from './types';
45
import { generateAssetId } from './util';
56

packages/cardano-services/test/ChainHistory/DbSyncChainHistoryProvider/mappers.test.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ import {
2525
WithdrawalModel
2626
} from '../../../src/ChainHistory/DbSyncChainHistory/types';
2727
import { Cardano } from '@cardano-sdk/core';
28-
import { Hash32ByteBase16, HexBlob } from '@cardano-sdk/util';
28+
import { Hash32ByteBase16 } from '@cardano-sdk/crypto';
29+
import { HexBlob } from '@cardano-sdk/util';
2930

3031
const blockHash = '7a48b034645f51743550bbaf81f8a14771e58856e031eb63844738ca8ad72298';
3132
const poolId = 'pool1zuevzm3xlrhmwjw87ec38mzs02tlkwec9wxpgafcaykmwg7efhh';
@@ -252,12 +253,12 @@ describe('chain history mappers', () => {
252253
expect(registrationResult).toEqual<WithCertIndex<Cardano.StakeAddressCertificate>>({
253254
__typename: Cardano.CertificateType.StakeKeyRegistration,
254255
cert_index: 0,
255-
stakeKeyHash: Cardano.Ed25519KeyHash.fromRewardAccount(Cardano.RewardAccount(stakeAddress))
256+
stakeKeyHash: Cardano.RewardAccount.toHash(Cardano.RewardAccount(stakeAddress))
256257
});
257258
expect(deregistrationResult).toEqual<WithCertIndex<Cardano.StakeAddressCertificate>>({
258259
__typename: Cardano.CertificateType.StakeKeyDeregistration,
259260
cert_index: 0,
260-
stakeKeyHash: Cardano.Ed25519KeyHash.fromRewardAccount(Cardano.RewardAccount(stakeAddress))
261+
stakeKeyHash: Cardano.RewardAccount.toHash(Cardano.RewardAccount(stakeAddress))
261262
});
262263
});
263264
test('map DelegationCertModel to Cardano.StakeDelegationCertificate', () => {
@@ -271,7 +272,7 @@ describe('chain history mappers', () => {
271272
__typename: Cardano.CertificateType.StakeDelegation,
272273
cert_index: 0,
273274
poolId: Cardano.PoolId(poolId),
274-
stakeKeyHash: Cardano.Ed25519KeyHash.fromRewardAccount(Cardano.RewardAccount(stakeAddress))
275+
stakeKeyHash: Cardano.RewardAccount.toHash(Cardano.RewardAccount(stakeAddress))
275276
});
276277
});
277278
});
@@ -315,7 +316,7 @@ describe('chain history mappers', () => {
315316
const certificates: Cardano.Certificate[] = [
316317
{
317318
__typename: Cardano.CertificateType.StakeKeyRegistration,
318-
stakeKeyHash: Cardano.Ed25519KeyHash.fromRewardAccount(Cardano.RewardAccount(stakeAddress))
319+
stakeKeyHash: Cardano.RewardAccount.toHash(Cardano.RewardAccount(stakeAddress))
319320
}
320321
];
321322

packages/cardano-services/test/StakePool/DbSyncStakePoolProvider/mappers.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
mapRelay,
1616
toStakePoolResults
1717
} from '../../../src';
18-
import { Hash32ByteBase16 } from '@cardano-sdk/util';
18+
import { Hash32ByteBase16 } from '@cardano-sdk/crypto';
1919
import { mockStakeDistribution } from '../../../../core/test/CardanoNode/mocks';
2020

2121
// eslint-disable-next-line max-statements

packages/cardano-services/test/StakePool/StakePoolHttpService.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
UNLIMITED_CACHE_TTL,
2121
createHttpStakePoolExtMetadataService
2222
} from '../../src';
23-
import { Hash32ByteBase16 } from '@cardano-sdk/util';
23+
import { Hash32ByteBase16 } from '@cardano-sdk/crypto';
2424
import { INFO, createLogger } from 'bunyan';
2525
import { LedgerTipModel, findLedgerTip } from '../../src/util/DbSyncProvider';
2626
import { OgmiosCardanoNode } from '@cardano-sdk/ogmios';

packages/cardano-services/test/Utxo/UtxoHttpService.test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import { Asset, Cardano, ProviderError, ProviderFailure, UtxoProvider } from '@c
44
import { CreateHttpProviderConfig, utxoHttpProvider } from '@cardano-sdk/cardano-services-client';
55
import { DataMocks } from '../data-mocks';
66
import { DbSyncUtxoProvider, HttpServer, HttpServerConfig, UtxoHttpService } from '../../src';
7-
import { Hash32ByteBase16, HexBlob } from '@cardano-sdk/util';
7+
import { Hash32ByteBase16 } from '@cardano-sdk/crypto';
8+
import { HexBlob } from '@cardano-sdk/util';
89
import { INFO, createLogger } from 'bunyan';
910
import { LedgerTipModel, findLedgerTip } from '../../src/util/DbSyncProvider';
1011
import { OgmiosCardanoNode } from '@cardano-sdk/ogmios';

packages/cardano-services/test/data-mocks/tx.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Cardano } from '@cardano-sdk/core';
2-
import { Hash32ByteBase16 } from '@cardano-sdk/util';
2+
import { Ed25519KeyHashHex, Hash32ByteBase16 } from '@cardano-sdk/crypto';
3+
34
import merge from 'lodash/merge';
45

56
export const valueWithCoinOnly: Cardano.Value = {
@@ -97,7 +98,7 @@ export const withAuxiliaryData: Cardano.HydratedTx = merge(withAssets, {
9798
export const delegationCertificate: Cardano.StakeDelegationCertificate = {
9899
__typename: Cardano.CertificateType.StakeDelegation,
99100
poolId: Cardano.PoolId('pool1cjm567pd9eqj7wlpuq2mnsasw2upewq0tchg4n8gktq5k7eepvr'),
100-
stakeKeyHash: Cardano.Ed25519KeyHash('f15db05f56035465bf8900a09bdaa16c3d8b8244fea686524408dd80')
101+
stakeKeyHash: Ed25519KeyHashHex('f15db05f56035465bf8900a09bdaa16c3d8b8244fea686524408dd80')
101102
};
102103

103104
export const collateralInputs = [

packages/core/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"dependencies": {
6565
"@cardano-ogmios/client": "5.5.7",
6666
"@cardano-ogmios/schema": "5.5.7",
67+
"@cardano-sdk/crypto": "^0.1.0",
6768
"@cardano-sdk/util": "^0.7.0",
6869
"@dcspark/cardano-multiplatform-lib-nodejs": "^3.1.1",
6970
"@emurgo/cip14-js": "^3.0.1",

packages/core/src/Asset/types/NftMetadata.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable wrap-regex */
2-
import { Metadatum } from '../../Cardano';
32
import { InvalidStringError, OpaqueString } from '@cardano-sdk/util';
3+
import { Metadatum } from '../../Cardano';
44

55
export type Uri = OpaqueString<'Uri'>;
66
export const Uri = (uri: string) => {

packages/core/src/CML/address.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import { Address, Ed25519KeyHash, NetworkId, RewardAccount } from '../Cardano';
1+
import * as Crypto from '@cardano-sdk/crypto';
2+
import { Address, NetworkId, RewardAccount } from '../Cardano';
23
import { CML } from './CML';
34
import { parseCmlAddress } from './parseCmlAddress';
45
import { usingAutoFree } from '@cardano-sdk/util';
56

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

9-
export const createRewardAccount = (stakeKeyHash: Ed25519KeyHash, networkId: NetworkId) =>
10+
export const createRewardAccount = (stakeKeyHash: Crypto.Ed25519KeyHashHex, networkId: NetworkId) =>
1011
usingAutoFree((scope) => {
1112
const keyHash = scope.manage(CML.Ed25519KeyHash.from_hex(stakeKeyHash.toString()));
1213
const stakeCredential = scope.manage(CML.StakeCredential.from_keyhash(keyHash));

packages/core/src/CML/cmlToCore/certificate.ts

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import * as Crypto from '@cardano-sdk/crypto';
12
import { CML } from '../CML';
23
import {
34
Certificate,
45
CertificateType,
5-
Ed25519KeyHash,
66
EpochNo,
77
GenesisKeyDelegationCertificate,
88
PoolId,
@@ -15,22 +15,22 @@ import {
1515
StakeDelegationCertificate,
1616
VrfVkHex
1717
} from '../../Cardano/types';
18-
import { Hash28ByteBase16, Hash32ByteBase16, usingAutoFree } from '@cardano-sdk/util';
1918
import { NetworkId } from '../../Cardano/ChainId';
2019
import { NotImplementedError, SerializationError, SerializationFailure } from '../../errors';
20+
import { usingAutoFree } from '@cardano-sdk/util';
2121

2222
const stakeRegistration = (certificate: CML.StakeRegistration): StakeAddressCertificate =>
2323
usingAutoFree((scope) => ({
2424
__typename: CertificateType.StakeKeyRegistration,
25-
stakeKeyHash: Ed25519KeyHash(
25+
stakeKeyHash: Crypto.Ed25519KeyHashHex(
2626
Buffer.from(scope.manage(scope.manage(certificate.stake_credential()).to_keyhash())!.to_bytes()).toString('hex')
2727
)
2828
}));
2929

3030
const stakeDeregistration = (certificate: CML.StakeDeregistration): StakeAddressCertificate =>
3131
usingAutoFree((scope) => ({
3232
__typename: CertificateType.StakeKeyDeregistration,
33-
stakeKeyHash: Ed25519KeyHash(
33+
stakeKeyHash: Crypto.Ed25519KeyHashHex(
3434
Buffer.from(scope.manage(scope.manage(certificate.stake_credential()).to_keyhash())!.to_bytes()).toString('hex')
3535
)
3636
}));
@@ -39,7 +39,7 @@ const stakeDelegation = (certificate: CML.StakeDelegation): StakeDelegationCerti
3939
usingAutoFree((scope) => ({
4040
__typename: CertificateType.StakeDelegation,
4141
poolId: PoolId(scope.manage(certificate.pool_keyhash()).to_bech32('pool')),
42-
stakeKeyHash: Ed25519KeyHash(
42+
stakeKeyHash: Crypto.Ed25519KeyHashHex(
4343
Buffer.from(scope.manage(scope.manage(certificate.stake_credential()).to_keyhash())!.to_bytes()).toString('hex')
4444
)
4545
}));
@@ -97,7 +97,9 @@ const jsonMetadata = (poolMetadata?: CML.PoolMetadata): PoolMetadataJson | undef
9797
usingAutoFree((scope) => {
9898
if (!poolMetadata) return;
9999
return {
100-
hash: Hash32ByteBase16(Buffer.from(scope.manage(poolMetadata.pool_metadata_hash()).to_bytes()).toString('hex')),
100+
hash: Crypto.Hash32ByteBase16(
101+
Buffer.from(scope.manage(poolMetadata.pool_metadata_hash()).to_bytes()).toString('hex')
102+
),
101103
url: scope.manage(poolMetadata.url()).url()
102104
};
103105
});
@@ -135,9 +137,9 @@ const poolRetirement = (certificate: CML.PoolRetirement): PoolRetirementCertific
135137
const genesisKeyDelegation = (certificate: CML.GenesisKeyDelegation): GenesisKeyDelegationCertificate =>
136138
usingAutoFree((scope) => ({
137139
__typename: CertificateType.GenesisKeyDelegation,
138-
genesisDelegateHash: Hash28ByteBase16(scope.manage(certificate.genesis_delegate_hash()).to_hex()),
139-
genesisHash: Hash28ByteBase16(scope.manage(certificate.genesishash()).to_hex()),
140-
vrfKeyHash: Hash32ByteBase16(scope.manage(certificate.vrf_keyhash()).to_hex())
140+
genesisDelegateHash: Crypto.Hash28ByteBase16(scope.manage(certificate.genesis_delegate_hash()).to_hex()),
141+
genesisHash: Crypto.Hash28ByteBase16(scope.manage(certificate.genesishash()).to_hex()),
142+
vrfKeyHash: Crypto.Hash32ByteBase16(scope.manage(certificate.vrf_keyhash()).to_hex())
141143
}));
142144

143145
export const createCertificate = (cmlCertificate: CML.Certificate): Certificate =>

packages/core/src/CML/cmlToCore/cmlToCore.ts

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as Cardano from '../../Cardano';
2-
import { Base64Blob, Hash32ByteBase16, HexBlob, ManagedFreeableScope, usingAutoFree } from '@cardano-sdk/util';
2+
import * as Crypto from '@cardano-sdk/crypto';
3+
import { Base64Blob, HexBlob, ManagedFreeableScope, usingAutoFree } from '@cardano-sdk/util';
34
import { CML } from '../CML';
45
import { PlutusLanguageVersion, ScriptType } from '../../Cardano';
56
import { ScriptKind } from '@dcspark/cardano-multiplatform-lib-nodejs';
@@ -10,13 +11,13 @@ import { createCertificate } from './certificate';
1011

1112
export const txRequiredExtraSignatures = (
1213
signatures: CML.Ed25519KeyHashes | undefined
13-
): Cardano.Ed25519KeyHash[] | undefined =>
14+
): Crypto.Ed25519KeyHashHex[] | undefined =>
1415
usingAutoFree((scope) => {
1516
if (!signatures) return;
16-
const requiredSignatures: Cardano.Ed25519KeyHash[] = [];
17+
const requiredSignatures: Crypto.Ed25519KeyHashHex[] = [];
1718
for (let i = 0; i < signatures.len(); i++) {
1819
const signature = scope.manage(signatures.get(i));
19-
const cardanoSignature = Cardano.Ed25519KeyHash(Buffer.from(signature.to_bytes()).toString('hex'));
20+
const cardanoSignature = Crypto.Ed25519KeyHashHex(Buffer.from(signature.to_bytes()).toString('hex'));
2021
requiredSignatures.push(cardanoSignature);
2122
}
2223
return requiredSignatures;
@@ -71,7 +72,7 @@ export const nativeScript = (script: CML.NativeScript): Cardano.NativeScript =>
7172
case Cardano.NativeScriptKind.RequireSignature: {
7273
coreScript = {
7374
__type: Cardano.ScriptType.Native,
74-
keyHash: Cardano.Ed25519KeyHash(
75+
keyHash: Crypto.Ed25519KeyHashHex(
7576
bytesToHex(scope.manage(scope.manage(script.as_script_pubkey())!.addr_keyhash()).to_bytes()).toString()
7677
),
7778
kind: Cardano.NativeScriptKind.RequireSignature
@@ -188,7 +189,7 @@ export const txOut = (output: CML.TransactionOutput): Cardano.TxOut =>
188189
return {
189190
address: Cardano.Address(address),
190191
datum: inlineDatum ? bytesToHex(inlineDatum) : undefined,
191-
datumHash: dataHashBytes ? Hash32ByteBase16.fromHexBlob(bytesToHex(dataHashBytes)) : undefined,
192+
datumHash: dataHashBytes ? Crypto.Hash32ByteBase16.fromHexBlob(bytesToHex(dataHashBytes)) : undefined,
192193
scriptReference: scriptRef ? getCoreScript(scope, scope.manage(scriptRef.script())) : undefined,
193194
value: value(scope.manage(output.amount()))
194195
};
@@ -281,7 +282,7 @@ export const txBody = (body: CML.TransactionBody): Cardano.TxBody =>
281282
referenceInputs: cslReferenceInputs ? txInputs(cslReferenceInputs) : undefined,
282283
requiredExtraSignatures: txRequiredExtraSignatures(scope.manage(body.required_signers())),
283284
scriptIntegrityHash:
284-
cslScriptDataHash && Hash32ByteBase16(Buffer.from(cslScriptDataHash.to_bytes()).toString('hex')),
285+
cslScriptDataHash && Crypto.Hash32ByteBase16(Buffer.from(cslScriptDataHash.to_bytes()).toString('hex')),
285286
totalCollateral: cslTotalCollateral ? BigInt(cslTotalCollateral.to_str()) : undefined,
286287
validityInterval: validityInterval(scope, body),
287288
withdrawals: txWithdrawals(scope.manage(body.withdrawals()))
@@ -299,10 +300,10 @@ export const txWitnessBootstrap = (bootstraps?: CML.BootstrapWitnesses): Cardano
299300
result.push({
300301
addressAttributes: attributes?.length > 0 ? Base64Blob.fromBytes(attributes) : undefined,
301302
chainCode: chainCode?.length > 0 ? HexBlob.fromBytes(chainCode) : undefined,
302-
key: Cardano.Ed25519PublicKey(
303+
key: Crypto.Ed25519PublicKeyHex(
303304
Buffer.from(scope.manage(scope.manage(bootstrap.vkey()).public_key()).as_bytes()).toString('hex')
304305
),
305-
signature: Cardano.Ed25519Signature(scope.manage(bootstrap.signature()).to_hex())
306+
signature: Crypto.Ed25519SignatureHex(scope.manage(bootstrap.signature()).to_hex())
306307
});
307308
}
308309
return result;
@@ -390,10 +391,10 @@ export const txWitnessSet = (witnessSet: CML.TransactionWitnessSet): Cardano.Wit
390391
for (let i = 0; i < vkeys!.len(); i++) {
391392
const witness = scope.manage(vkeys.get(i));
392393
txSignatures.set(
393-
Cardano.Ed25519PublicKey(
394+
Crypto.Ed25519PublicKeyHex(
394395
Buffer.from(scope.manage(scope.manage(witness.vkey()).public_key()).as_bytes()).toString('hex')
395396
),
396-
Cardano.Ed25519Signature(scope.manage(witness.signature()).to_hex())
397+
Crypto.Ed25519SignatureHex(scope.manage(witness.signature()).to_hex())
397398
);
398399
}
399400
}

packages/core/src/CML/coreToCml/certificate.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as Cardano from '../../Cardano/types';
2+
import * as Crypto from '@cardano-sdk/crypto';
23
import {
34
Address,
45
BigNum,
@@ -33,7 +34,7 @@ import {
3334
import { ManagedFreeableScope } from '@cardano-sdk/util';
3435
import { NotImplementedError } from '../../errors';
3536

36-
export const stakeKeyRegistration = (scope: ManagedFreeableScope, stakeKeyHash: Cardano.Ed25519KeyHash) =>
37+
export const stakeKeyRegistration = (scope: ManagedFreeableScope, stakeKeyHash: Crypto.Ed25519KeyHashHex) =>
3738
scope.manage(
3839
Certificate.new_stake_registration(
3940
scope.manage(
@@ -48,7 +49,7 @@ export const stakeKeyRegistration = (scope: ManagedFreeableScope, stakeKeyHash:
4849
)
4950
);
5051

51-
export const stakeKeyDeregistration = (scope: ManagedFreeableScope, stakeKeyHash: Cardano.Ed25519KeyHash) =>
52+
export const stakeKeyDeregistration = (scope: ManagedFreeableScope, stakeKeyHash: Crypto.Ed25519KeyHashHex) =>
5253
scope.manage(
5354
Certificate.new_stake_deregistration(
5455
scope.manage(
@@ -166,7 +167,7 @@ export const poolRetirement = (scope: ManagedFreeableScope, poolId: Cardano.Pool
166167

167168
export const stakeDelegation = (
168169
scope: ManagedFreeableScope,
169-
stakeKeyHash: Cardano.Ed25519KeyHash,
170+
stakeKeyHash: Crypto.Ed25519KeyHashHex,
170171
delegatee: Cardano.PoolId
171172
) =>
172173
scope.manage(

0 commit comments

Comments
 (0)