From a1ce8e0c158c3cbc4845ec14bc6f8a0a17b311f2 Mon Sep 17 00:00:00 2001 From: janniks Date: Mon, 11 Mar 2024 18:41:13 +0100 Subject: [PATCH] fix: update cli --- packages/cli/src/cli.ts | 14 ++++++-------- packages/cli/src/common.ts | 6 +++--- packages/cli/tests/cli.test.ts | 3 +-- packages/transactions/src/transaction.ts | 8 +------- 4 files changed, 11 insertions(+), 20 deletions(-) diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index af2b84712..8a39fc39b 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -19,7 +19,6 @@ import { ClarityValue, ContractCallPayload, SignedContractDeployOptions, - createStacksPrivateKey, cvToString, estimateTransfer, getAbi, @@ -28,8 +27,6 @@ import { makeContractDeploy, makeSTXTokenTransfer, PostConditionMode, - pubKeyfromPrivKey, - publicKeyToString, ReadOnlyFunctionOptions, SignedContractCallOptions, SignedTokenTransferOptions, @@ -44,6 +41,7 @@ import { estimateTransaction, serializePayload, estimateTransactionByteLength, + privateKeyToPublic, } from '@stacks/transactions'; import express from 'express'; import { prompt } from 'inquirer'; @@ -447,7 +445,7 @@ async function migrateSubdomains(network: CLINetworkAdapter, args: string[]): Pr * ******************************************************************************** */ const hash = crypto.createHash('sha256').update(textToSign).digest('hex'); - const sig = signWithKey(createStacksPrivateKey(account.dataPrivateKey), hash); + const sig = signWithKey(account.dataPrivateKey, hash); // https://docs.stacks.co/build-apps/references/bns#subdomain-lifecycle subDomainOp.signature = sig.data; @@ -1870,7 +1868,7 @@ async function register(network: CLINetworkAdapter, args: string[]): Promise { @@ -1905,7 +1903,7 @@ async function preorder(network: CLINetworkAdapter, args: string[]): Promise { diff --git a/packages/cli/src/common.ts b/packages/cli/src/common.ts index 3c36bca50..6dce9173f 100644 --- a/packages/cli/src/common.ts +++ b/packages/cli/src/common.ts @@ -1,9 +1,9 @@ import { publicKeyToBtcAddress } from '@stacks/encryption'; -import { pubKeyfromPrivKey } from '@stacks/transactions'; import * as bitcoinjs from 'bitcoinjs-lib'; import { TransactionSigner } from 'blockstack'; import { DEFAULT_MAX_ID_SEARCH_INDEX } from './argparse'; import { CLINetworkAdapter } from './network'; +import { privateKeyToPublic } from '@stacks/transactions/src'; let maxIDSearchIndex = DEFAULT_MAX_ID_SEARCH_INDEX; @@ -49,8 +49,8 @@ export function getPrivateKeyAddress( return privateKey.address; } - const pubKey = pubKeyfromPrivKey(privateKey); - const btcAddress = publicKeyToBtcAddress(pubKey.data); + const pubKey = privateKeyToPublic(privateKey); + const btcAddress = publicKeyToBtcAddress(pubKey); return network.coerceAddress(btcAddress); } diff --git a/packages/cli/tests/cli.test.ts b/packages/cli/tests/cli.test.ts index 61c202791..1d9efe31a 100644 --- a/packages/cli/tests/cli.test.ts +++ b/packages/cli/tests/cli.test.ts @@ -5,7 +5,6 @@ import { CLINetworkAdapter, CLI_NETWORK_OPTS, getNetwork } from '../src/network' import { Cl, ClarityAbi, - createStacksPrivateKey, publicKeyFromSignatureVrs, randomBytes, signWithKey, @@ -417,7 +416,7 @@ describe('Subdomain Migration', () => { * ******************************************************************************** */ const hash = crypto.createHash('sha256').update(textToSign).digest('hex'); - const sig = signWithKey(createStacksPrivateKey(privateKey), hash); + const sig = signWithKey(privateKey, hash); subDomainOp.signature = sig.data; // Assign signature to subDomainOp diff --git a/packages/transactions/src/transaction.ts b/packages/transactions/src/transaction.ts index 10b82b9c2..439dcf7ed 100644 --- a/packages/transactions/src/transaction.ts +++ b/packages/transactions/src/transaction.ts @@ -1,10 +1,4 @@ -import { - concatArray, - hexToBytes, - IntegerType, - intToBigInt, - writeUInt32BE, -} from '@stacks/common'; +import { concatArray, hexToBytes, IntegerType, intToBigInt, writeUInt32BE } from '@stacks/common'; import { AddressHashMode, AnchorMode,