From 901dea305df329c55708e3e9ff2aab8e0785c50e Mon Sep 17 00:00:00 2001 From: Marcos Kichel Date: Wed, 31 Jul 2024 15:56:41 -0300 Subject: [PATCH] refactor(types): leverage tx-signer type defs --- features/keychain/api/index.d.ts | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/features/keychain/api/index.d.ts b/features/keychain/api/index.d.ts index f47f8d04..62b84e4a 100644 --- a/features/keychain/api/index.d.ts +++ b/features/keychain/api/index.d.ts @@ -1,10 +1,10 @@ import KeyIdentifier from '@exodus/key-identifier' +import { UnsignedTransaction } from '@exodus/tx-signer' import BN from 'bn.js' type SeedId = string type KeySource = { seedId: SeedId; keyId: KeyIdentifier } -type Tx = Record type HdKeys = { privateKey: Buffer; publicKey: Buffer } type SignTxCallback = (params: { @@ -13,7 +13,7 @@ type SignTxCallback = (params: { privateKey: Buffer }) => void | Promise -type TxSignParams = KeySource & { signTxCallback: SignTxCallback; unsignedTx: Tx } +type TxSignParams = KeySource & { signTxCallback: SignTxCallback; unsignedTx: UnsignedTransaction } type EcOptions = { canonical?: boolean @@ -39,41 +39,41 @@ type PubKeyWrapper = { publicKey: Buffer } -type SignerInput = { seedId: string; keyId: string; data: Buffer } +type SignerParam = KeychainSignerParams & { seedId: string } type Encryptor = { getSodiumKeysFromSeed: ( args: KeySource ) => Promise<{ box: PubKeyWrapper; sign: PubKeyWrapper; secret: Buffer }> - sign: (args: SignerInput) => Promise - signOpen: (args: SignerInput) => Promise - signDetached: (args: SignerInput) => Promise + sign: (args: SignerParam) => Promise + signOpen: (args: SignerParam) => Promise + signDetached: (args: SignerParam) => Promise verifyDetached: ( - args: SignerInput & { + args: SignerParam & { signature: Buffer } ) => Promise - encryptSecretBox: (args: SignerInput) => Promise - decryptSecretBox: (args: SignerInput) => Promise - encryptBox: (args: SignerInput & { toPublicKey: Buffer }) => Promise + encryptSecretBox: (args: SignerParam) => Promise + decryptSecretBox: (args: SignerParam) => Promise + encryptBox: (args: SignerParam & { toPublicKey: Buffer }) => Promise decryptBox: ( - args: SignerInput & { + args: SignerParam & { fromPublicKey: Buffer } ) => Promise encryptSealedBox: (args: { data: Buffer; toPublicKey: Buffer }) => Promise - decryptSealedBox: (args: SignerInput) => Promise + decryptSealedBox: (args: SignerParam) => Promise } type KeyId = Record type Ed25519Signer = { - signBuffer: (args: SignerInput) => Promise + signBuffer: (args: SignerParam) => Promise } type Secp256k1Signer = { - signBuffer: (args: SignerInput) => Promise - signSchnorr: (args: SignerInput & { tweak: Buffer; extraEntropy: Buffer }) => Promise + signBuffer: (args: SignerParam) => Promise + signSchnorr: (args: SignerParam) => Promise } type CreateSignerArgs = {