From 349b29aa697b4daba312b858ac8b910025cc6e41 Mon Sep 17 00:00:00 2001 From: janniks <6362150+janniks@users.noreply.github.com> Date: Mon, 18 Mar 2024 14:10:56 +0100 Subject: [PATCH] build: fix circular dep issue (#1658) --- packages/transactions/src/index.ts | 1 + packages/transactions/src/keys.ts | 2 +- packages/transactions/src/message-types.ts | 8 ++++++++ packages/transactions/src/structuredDataSignature.ts | 6 +----- 4 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 packages/transactions/src/message-types.ts diff --git a/packages/transactions/src/index.ts b/packages/transactions/src/index.ts index 7bea2f327..6fb3e41f6 100644 --- a/packages/transactions/src/index.ts +++ b/packages/transactions/src/index.ts @@ -100,4 +100,5 @@ export * from './signer'; export * from './structuredDataSignature'; export { StacksTransaction, deserializeTransaction } from './transaction'; export * from './types'; +export * from './message-types'; export * from './utils'; diff --git a/packages/transactions/src/keys.ts b/packages/transactions/src/keys.ts index 0562185cc..834e0f002 100644 --- a/packages/transactions/src/keys.ts +++ b/packages/transactions/src/keys.ts @@ -38,7 +38,7 @@ import { UNCOMPRESSED_PUBKEY_LENGTH_BYTES, } from './constants'; import { hash160, hashP2PKH } from './utils'; -import { StructuredDataSignature } from './structuredDataSignature'; +import { StructuredDataSignature } from './message-types'; /** * To use secp256k1.signSync set utils.hmacSha256Sync to a function using noble-hashes diff --git a/packages/transactions/src/message-types.ts b/packages/transactions/src/message-types.ts new file mode 100644 index 000000000..dfad1f84c --- /dev/null +++ b/packages/transactions/src/message-types.ts @@ -0,0 +1,8 @@ +// todo: this file should hold the type definitions for more message types later +// needed now to fix a circular dependency issue in structuredDataSignature +import { StacksMessageType } from './constants'; + +export interface StructuredDataSignature { + readonly type: StacksMessageType.StructuredDataSignature; + data: string; +} diff --git a/packages/transactions/src/structuredDataSignature.ts b/packages/transactions/src/structuredDataSignature.ts index 3870a919d..b39228e21 100644 --- a/packages/transactions/src/structuredDataSignature.ts +++ b/packages/transactions/src/structuredDataSignature.ts @@ -4,6 +4,7 @@ import { bytesToHex, concatBytes, utf8ToBytes } from '@stacks/common'; import { ClarityType, ClarityValue, serializeCV } from './clarity'; import { StacksMessageType } from './constants'; import { signMessageHashRsv, StacksPrivateKey } from './keys'; +import { StructuredDataSignature } from './message-types'; // Refer to SIP018 https://github.com/stacksgov/sips/ // > asciiToBytes('SIP018') @@ -66,11 +67,6 @@ export function decodeStructuredDataSignature( }; } -export interface StructuredDataSignature { - readonly type: StacksMessageType.StructuredDataSignature; - data: string; -} - /** * Signs a structured message (ClarityValue) and a domain (ClarityValue) using a private key. * The resulting signature along with the original message can be verified using {@link verifyMessageSignature}