Skip to content

Commit

Permalink
Merge pull request #941 from input-output-hk/feat/remove_CML_from_cor…
Browse files Browse the repository at this point in the history
…e_package

Feat/remove cml from core package
  • Loading branch information
rhyslbw committed Oct 9, 2023
2 parents 7c11c58 + 51545ed commit fc6950a
Show file tree
Hide file tree
Showing 16 changed files with 26 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
/* eslint-disable max-depth */

import * as Crypto from '@cardano-sdk/crypto';
import { CML } from '@cardano-sdk/core';
import { CustomError } from 'ts-custom-error';
import { HexBlob } from '@cardano-sdk/util';
import { Logger } from 'ts-log';
Expand Down Expand Up @@ -125,7 +124,7 @@ export const createHttpStakePoolMetadataService = (
const signature = (await axiosClient.get<Crypto.Ed25519SignatureHex>(metadata.extSigUrl)).data;
const message = HexBlob.fromBytes(Buffer.from(JSON.stringify(extMetadata)));
const publicKey = Crypto.Ed25519PublicKeyHex(metadata.extVkey);
const bip32Ed25519 = new Crypto.CmlBip32Ed25519(CML);
const bip32Ed25519 = new Crypto.SodiumBip32Ed25519();

// Verify the signature
const isSignatureValid = await bip32Ed25519.verify(signature, message, publicKey);
Expand Down
1 change: 0 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
"@cardano-ogmios/schema": "5.6.0",
"@cardano-sdk/crypto": "workspace:~",
"@cardano-sdk/util": "workspace:~",
"@dcspark/cardano-multiplatform-lib-nodejs": "^3.1.1",
"@foxglove/crc": "^0.0.3",
"@scure/base": "^1.1.1",
"fraction.js": "4.0.1",
Expand Down
4 changes: 0 additions & 4 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +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;

export * as Asset from './Asset';
export * as Cardano from './Cardano';
export * from './Provider';
Expand Down
1 change: 1 addition & 0 deletions packages/e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
"@cardano-sdk/util-dev": "workspace:~",
"@cardano-sdk/util-rxjs": "workspace:~",
"@cardano-sdk/wallet": "workspace:~",
"@dcspark/cardano-multiplatform-lib-nodejs": "^3.1.1",
"@vespaiach/axios-fetch-adapter": "^0.3.0",
"axios": "^0.27.2",
"bunyan": "^1.8.15",
Expand Down
2 changes: 1 addition & 1 deletion packages/e2e/src/factories.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import * as CML from '@dcspark/cardano-multiplatform-lib-nodejs';
import * as Crypto from '@cardano-sdk/crypto';
import {
AddressDiscovery,
Expand All @@ -14,7 +15,6 @@ import {
} from '@cardano-sdk/wallet';
import {
AssetProvider,
CML,
Cardano,
ChainHistoryProvider,
HandleProvider,
Expand Down
4 changes: 2 additions & 2 deletions packages/hardware-ledger/test/LedgerKeyAgent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import * as Crypto from '@cardano-sdk/crypto';
import * as Ledger from '@cardano-foundation/ledgerjs-hw-app-cardano';
import { Ada, InvalidDataReason } from '@cardano-foundation/ledgerjs-hw-app-cardano';
import { CML, Cardano } from '@cardano-sdk/core';
import { Cardano } from '@cardano-sdk/core';
import { CardanoKeyConst, CommunicationType, util } from '@cardano-sdk/key-management';
import { LedgerKeyAgent } from '../src';
import { dummyLogger } from 'ts-log';
Expand Down Expand Up @@ -378,7 +378,7 @@ describe('LedgerKeyAgent', () => {
knownAddresses: []
},
{
bip32Ed25519: new Crypto.CmlBip32Ed25519(CML),
bip32Ed25519: new Crypto.SodiumBip32Ed25519(),
inputResolver: {
resolveInput: jest.fn().mockResolvedValue(null)
},
Expand Down
4 changes: 2 additions & 2 deletions packages/key-management/test/cip8/cip30signData.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as Crypto from '@cardano-sdk/crypto';
import { AddressType, AsyncKeyAgent, GroupedAddress, KeyAgent, KeyRole, cip8 } from '../../src';
import { CML, Cardano, util } from '@cardano-sdk/core';
import { COSEKey, COSESign1, SigStructure } from '@emurgo/cardano-message-signing-nodejs';
import { Cardano, util } from '@cardano-sdk/core';
import { CoseLabel } from '../../src/cip8/util';
import { HexBlob } from '@cardano-sdk/util';
import { testAsyncKeyAgent, testKeyAgent } from '../mocks';
Expand All @@ -11,7 +11,7 @@ describe('cip30signData', () => {
let keyAgent: KeyAgent;
let asyncKeyAgent: AsyncKeyAgent;
let address: GroupedAddress;
const cryptoProvider = new Crypto.CmlBip32Ed25519(CML);
const cryptoProvider = new Crypto.SodiumBip32Ed25519();

beforeAll(async () => {
const keyAgentReady = testKeyAgent();
Expand Down
4 changes: 2 additions & 2 deletions packages/key-management/test/util/ensureStakeKeys.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as Crypto from '@cardano-sdk/crypto';
import { AddressType, AsyncKeyAgent, InMemoryKeyAgent, util } from '../../src';
import { CML, Cardano } from '@cardano-sdk/core';
import { Cardano } from '@cardano-sdk/core';
import { Logger, dummyLogger } from 'ts-log';
import { firstValueFrom } from 'rxjs';

Expand All @@ -20,7 +20,7 @@ describe('ensureStakeKeys', () => {
getPassphrase,
mnemonicWords
},
{ bip32Ed25519: new Crypto.CmlBip32Ed25519(CML), inputResolver, logger: dummyLogger }
{ bip32Ed25519: new Crypto.SodiumBip32Ed25519(), inputResolver, logger: dummyLogger }
)
);
});
Expand Down
4 changes: 2 additions & 2 deletions packages/tx-construction/test/tx-builder/TxBuilder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
util
} from '@cardano-sdk/key-management';
import { AssetId, mockProviders as mocks } from '@cardano-sdk/util-dev';
import { CML, Cardano, Handle, ProviderError, ProviderFailure } from '@cardano-sdk/core';
import { Cardano, Handle, ProviderError, ProviderFailure } from '@cardano-sdk/core';
import {
GenericTxBuilder,
HandleNotFoundError,
Expand Down Expand Up @@ -68,7 +68,7 @@ describe('GenericTxBuilder', () => {
getPassphrase: async () => Buffer.from('passphrase'),
mnemonicWords: util.generateMnemonicWords()
},
{ bip32Ed25519: new Crypto.CmlBip32Ed25519(CML), inputResolver, logger: dummyLogger }
{ bip32Ed25519: new Crypto.SodiumBip32Ed25519(), inputResolver, logger: dummyLogger }
);
await keyAgent.deriveAddress({ index: 0, type: AddressType.External }, 0);
keyAgent.knownAddresses[0].address = mocks.utxo[0][1].address;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable sonarjs/no-duplicate-string */
import * as Crypto from '@cardano-sdk/crypto';
import { AddressType, GroupedAddress, InMemoryKeyAgent, util } from '@cardano-sdk/key-management';
import { CML, Cardano } from '@cardano-sdk/core';
import { Cardano } from '@cardano-sdk/core';
import {
GenericTxBuilder,
OutOfSyncRewardAccounts,
Expand Down Expand Up @@ -129,7 +129,7 @@ describe('TxBuilder/delegatePortfolio', () => {
getPassphrase: async () => Buffer.from('passphrase'),
mnemonicWords: util.generateMnemonicWords()
},
{ bip32Ed25519: new Crypto.CmlBip32Ed25519(CML), inputResolver, logger: dummyLogger }
{ bip32Ed25519: new Crypto.SodiumBip32Ed25519(), inputResolver, logger: dummyLogger }
);
});

Expand Down
8 changes: 4 additions & 4 deletions packages/wallet/test/PersonalWallet/methods.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as Crypto from '@cardano-sdk/crypto';
import { AddressType, AsyncKeyAgent, GroupedAddress } from '@cardano-sdk/key-management';
import { AssetId, StubKeyAgent, createStubStakePoolProvider, mockProviders as mocks } from '@cardano-sdk/util-dev';
import { BehaviorSubject, Subscription, firstValueFrom, skip } from 'rxjs';
import { CML, Cardano, CardanoNodeErrors, ProviderError, ProviderFailure, TxCBOR } from '@cardano-sdk/core';
import { Cardano, CardanoNodeErrors, ProviderError, ProviderFailure, TxCBOR } from '@cardano-sdk/core';
import { HexBlob } from '@cardano-sdk/util';
import { InitializeTxProps, InitializeTxResult } from '@cardano-sdk/tx-construction';
import { PersonalWallet, TxInFlight, setupWallet } from '../../src';
Expand Down Expand Up @@ -73,7 +73,7 @@ describe('PersonalWallet methods', () => {
type: AddressType.External
};
({ wallet } = await setupWallet({
bip32Ed25519: new Crypto.CmlBip32Ed25519(CML),
bip32Ed25519: new Crypto.SodiumBip32Ed25519(),
createKeyAgent: async (dependencies) => {
const asyncKeyAgent = await testAsyncKeyAgent([groupedAddress], dependencies);
asyncKeyAgent.deriveAddress = jest.fn().mockResolvedValue(groupedAddress);
Expand Down Expand Up @@ -220,7 +220,7 @@ describe('PersonalWallet methods', () => {
const mockKeyAgent = new StubKeyAgent(inputResolver);

setupWallet({
bip32Ed25519: new Crypto.CmlBip32Ed25519(CML),
bip32Ed25519: new Crypto.SodiumBip32Ed25519(),
createKeyAgent: async () => mockKeyAgent,
createWallet: async (keyAgent) =>
new PersonalWallet(
Expand Down Expand Up @@ -532,7 +532,7 @@ describe('PersonalWallet methods', () => {
it('will retry deriving pubDrepKey if one does not exist', async () => {
let walletKeyAgent: AsyncKeyAgent;
({ wallet, keyAgent: walletKeyAgent } = await setupWallet({
bip32Ed25519: new Crypto.CmlBip32Ed25519(CML),
bip32Ed25519: new Crypto.SodiumBip32Ed25519(),
createKeyAgent: async (dependencies) => {
const asyncKeyAgent = await testAsyncKeyAgent([], dependencies);
asyncKeyAgent.derivePublicKey = jest.fn().mockRejectedValueOnce('error').mockResolvedValue('string');
Expand Down
4 changes: 2 additions & 2 deletions packages/wallet/test/hardware/ledger/LedgerKeyAgent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import * as Crypto from '@cardano-sdk/crypto';
import { AddressType, CommunicationType, SerializableLedgerKeyAgentData, util } from '@cardano-sdk/key-management';
import { AssetId, createStubStakePoolProvider, mockProviders as mocks } from '@cardano-sdk/util-dev';
import { CML, Cardano, Serialization } from '@cardano-sdk/core';
import { Cardano, Serialization } from '@cardano-sdk/core';
import { Hash32ByteBase16 } from '@cardano-sdk/crypto';
import { HexBlob } from '@cardano-sdk/util';
import { InitializeTxProps, InitializeTxResult } from '@cardano-sdk/tx-construction';
Expand All @@ -20,7 +20,7 @@ describe('LedgerKeyAgent', () => {
beforeAll(async () => {
txSubmitProvider = mocks.mockTxSubmitProvider();
({ keyAgent, wallet } = await setupWallet({
bip32Ed25519: new Crypto.CmlBip32Ed25519(CML),
bip32Ed25519: new Crypto.SodiumBip32Ed25519(),
createKeyAgent: async (dependencies) =>
await LedgerKeyAgent.createWithDevice(
{
Expand Down
4 changes: 2 additions & 2 deletions packages/wallet/test/integration/cip30mapping.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import {
} from '@cardano-sdk/dapp-connector';
import { AddressType, GroupedAddress } from '@cardano-sdk/key-management';
import { AssetId, createStubStakePoolProvider, mockProviders as mocks } from '@cardano-sdk/util-dev';
import { CML, Cardano, CardanoNodeErrors, Serialization, TxCBOR, coalesceValueQuantities } from '@cardano-sdk/core';
import { CallbackConfirmation, GetCollateralCallbackParams } from '../../src/cip30';
import { Cardano, CardanoNodeErrors, Serialization, TxCBOR, coalesceValueQuantities } from '@cardano-sdk/core';
import { HexBlob, ManagedFreeableScope } from '@cardano-sdk/util';
import { InMemoryUnspendableUtxoStore, createInMemoryWalletStores } from '../../src/persistence';
import { InitializeTxProps, InitializeTxResult } from '@cardano-sdk/tx-construction';
Expand Down Expand Up @@ -673,7 +673,7 @@ describe('cip30', () => {
type: AddressType.External
};
({ wallet: mockWallet } = await setupWallet({
bip32Ed25519: new Crypto.CmlBip32Ed25519(CML),
bip32Ed25519: new Crypto.SodiumBip32Ed25519(),
createKeyAgent: async (dependencies) => {
const asyncKeyAgent = await testAsyncKeyAgent([groupedAddress], dependencies);
asyncKeyAgent.deriveAddress = jest.fn().mockResolvedValue(groupedAddress);
Expand Down
4 changes: 2 additions & 2 deletions packages/wallet/test/services/WalletUtil.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as Crypto from '@cardano-sdk/crypto';
import { AddressType, GroupedAddress } from '@cardano-sdk/key-management';
import { CML, Cardano } from '@cardano-sdk/core';
import { Cardano } from '@cardano-sdk/core';
import {
PersonalWallet,
WalletUtilContext,
Expand Down Expand Up @@ -103,7 +103,7 @@ describe('WalletUtil', () => {
type: AddressType.External
};
({ wallet } = await setupWallet({
bip32Ed25519: new Crypto.CmlBip32Ed25519(CML),
bip32Ed25519: new Crypto.SodiumBip32Ed25519(),
createKeyAgent: async (dependencies) => {
const asyncKeyAgent = await testAsyncKeyAgent([groupedAddress], dependencies);
asyncKeyAgent.deriveAddress = jest.fn().mockResolvedValue(groupedAddress);
Expand Down
4 changes: 2 additions & 2 deletions packages/wallet/test/services/addressDiscovery/mockData.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as Crypto from '@cardano-sdk/crypto';
import { AddressType, AsyncKeyAgent, GroupedAddress, KeyRole } from '@cardano-sdk/key-management';
import { BehaviorSubject } from 'rxjs';
import { CML, Cardano, ChainHistoryProvider, Paginated, TransactionsByAddressesArgs } from '@cardano-sdk/core';
import { Cardano, ChainHistoryProvider, Paginated, TransactionsByAddressesArgs } from '@cardano-sdk/core';

const NOT_IMPLEMENTED = 'Not implemented';

Expand All @@ -19,7 +19,7 @@ const createMockAsyncKeyAgent = (knownAddresses: Array<Array<GroupedAddress>>):
return address;
},
derivePublicKey: () => Promise.resolve('00' as unknown as Crypto.Ed25519PublicKeyHex),
getBip32Ed25519: () => Promise.resolve(new Crypto.CmlBip32Ed25519(CML)),
getBip32Ed25519: () => Promise.resolve(new Crypto.SodiumBip32Ed25519()),
getChainId: () =>
Promise.resolve({
networkId: 0,
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3099,7 +3099,6 @@ __metadata:
"@cardano-ogmios/schema": 5.6.0
"@cardano-sdk/crypto": "workspace:~"
"@cardano-sdk/util": "workspace:~"
"@dcspark/cardano-multiplatform-lib-nodejs": ^3.1.1
"@foxglove/crc": ^0.0.3
"@scure/base": ^1.1.1
"@types/lodash": ^4.14.182
Expand Down Expand Up @@ -3217,6 +3216,7 @@ __metadata:
"@cardano-sdk/wallet": "workspace:~"
"@cardano-sdk/web-extension": "workspace:~"
"@dcspark/cardano-multiplatform-lib-browser": ^3.1.1
"@dcspark/cardano-multiplatform-lib-nodejs": ^3.1.1
"@emurgo/cardano-message-signing-asmjs": ^1.0.1
"@types/bunyan": ^1.8.8
"@types/chalk": ^2.2.0
Expand Down

0 comments on commit fc6950a

Please sign in to comment.