@exodus/asset-types 0.2.3 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,26 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.3.0](https://github.com/ExodusMovement/assets/compare/@exodus/asset-types@0.2.4...@exodus/asset-types@0.3.0) (2025-03-31)
7
+
8
+
9
+ ### Features
10
+
11
+
12
+ * feat: add types for schnorr signing (#5352)
13
+
14
+
15
+
16
+ ## [0.2.4](https://github.com/ExodusMovement/assets/compare/@exodus/asset-types@0.2.3...@exodus/asset-types@0.2.4) (2025-02-07)
17
+
18
+
19
+ ### Bug Fixes
20
+
21
+
22
+ * fix: require either signer or private key (#5016)
23
+
24
+
25
+
6
26
  ## [0.2.3](https://github.com/ExodusMovement/assets/compare/@exodus/asset-types@0.2.2...@exodus/asset-types@0.2.3) (2025-02-07)
7
27
 
8
28
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/asset-types",
3
- "version": "0.2.3",
3
+ "version": "0.3.0",
4
4
  "description": "Typings for Assets",
5
5
  "author": "Exodus Movement, Inc.",
6
6
  "repository": {
@@ -23,7 +23,8 @@
23
23
  },
24
24
  "scripts": {
25
25
  "lint": "run -T eslint .",
26
- "lint:fix": "yarn lint --fix"
26
+ "lint:fix": "yarn lint --fix",
27
+ "test": "tsc && echo"
27
28
  },
28
29
  "bugs": {
29
30
  "url": "https://github.com/ExodusMovement/assets/issues?q=is%3Aissue+is%3Aopen+label%3Aasset-types"
@@ -31,5 +32,5 @@
31
32
  "devDependencies": {
32
33
  "@types/bn.js": "^5"
33
34
  },
34
- "gitHead": "6cac727a12afc44b363ab1c5e82b32bbed71d1f0"
35
+ "gitHead": "c5a19c29bd6066318ca6fc83e86ba9d3c0ef5bbb"
35
36
  }
package/src/asset.d.ts CHANGED
@@ -7,7 +7,7 @@ import type BN from 'bn.js'
7
7
 
8
8
  import type { AssetMeta } from './asset-meta.js'
9
9
  import type { CreateFeeMonitorApi } from './fee-monitor.js'
10
- import type { Extendable, FreeForm, RequireOnly, WithRequired } from './helpers.js'
10
+ import type { Extendable, FreeForm, RequireOnly, WithRequired, XOR } from './helpers.js'
11
11
  import type { HistoryMonitor } from './history-monitor.js'
12
12
  import type { Logger } from './logger.js'
13
13
  import type { MoveFunds } from './move-funds.js'
@@ -138,9 +138,8 @@ export type SignTxParams = Extendable<{
138
138
  txHex?: string
139
139
  partialSign?: boolean
140
140
  hdkeys?: HDKeysMap
141
- privateKey: string
142
- signer?: Signer
143
- }>
141
+ }> &
142
+ XOR<{ privateKey: string }, { signer: Signer }>
144
143
 
145
144
  export type CommonAssetApi = {
146
145
  features: ApiFeatures
package/src/helpers.d.ts CHANGED
@@ -15,3 +15,10 @@ export type WithRequired<T, K extends keyof T> = T & { [P in K]-?: T[P] }
15
15
  * Make a set of keys of a given target type required, while making all other optional
16
16
  */
17
17
  export type RequireOnly<T, Keys extends keyof T> = Partial<T> & Pick<WithRequired<T, Keys>, Keys>
18
+
19
+ /**
20
+ * Exclusive OR
21
+ */
22
+ export type XOR<T, U> =
23
+ | (T & Partial<Record<Exclude<keyof U, keyof T>, never>>)
24
+ | (U & Partial<Record<Exclude<keyof T, keyof U>, never>>)
package/src/index.d.ts CHANGED
@@ -30,3 +30,15 @@ export type {
30
30
  AssetAddress,
31
31
  ApiFeatures,
32
32
  } from './asset.js'
33
+
34
+ export type {
35
+ EcdsaSignParams,
36
+ Ed25519SignParams,
37
+ EncodedEcdsaSignature,
38
+ SchnorrSignParams,
39
+ SignParams,
40
+ SignReturnValue,
41
+ SignatureEncoding,
42
+ SignatureType,
43
+ Signer,
44
+ } from './signer.js'
package/src/signer.d.ts CHANGED
@@ -8,28 +8,36 @@ type BaseSignParams = {
8
8
  keyId?: KeyIdentifier
9
9
  }
10
10
 
11
- export enum SignatureType {
12
- Ed25519 = 'ed25519',
13
- Ecdsa = 'ecdsa',
14
- }
11
+ export type SignatureType = 'ed25519' | 'ecdsa' | 'schnorr'
15
12
 
16
13
  export type EcdsaSignParams<Enc extends SignatureEncoding> = {
17
- signatureType: SignatureType.Ecdsa
14
+ signatureType: 'ecdsa'
18
15
  data: Buffer
19
16
  ecOptions?: { canoncial?: boolean }
20
17
  extraEntropy?: Buffer
21
18
  enc: Enc
22
19
  } & BaseSignParams
23
20
 
21
+ export type SchnorrSignParams = {
22
+ signatureType: 'schnorr'
23
+ data: Buffer
24
+ extraEntropy?: Buffer
25
+ tweak?: Buffer
26
+ } & BaseSignParams
27
+
24
28
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
25
29
  export type EncodedEcdsaSignature<Enc extends SignatureEncoding> = Enc extends 'der' ? Buffer : any
26
30
 
27
31
  export type Ed25519SignParams = {
28
- signatureType: SignatureType.Ed25519
32
+ signatureType: 'ed25519'
29
33
  data: Buffer
30
34
  } & BaseSignParams
31
35
 
32
- export type SignParams<Enc extends SignatureEncoding> = EcdsaSignParams<Enc> | Ed25519SignParams
36
+ export type SignParams<Enc extends SignatureEncoding> =
37
+ | EcdsaSignParams<Enc>
38
+ | Ed25519SignParams
39
+ | SchnorrSignParams
40
+
33
41
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
34
42
  export type SignReturnValue<T extends SignParams<any>> =
35
43
  T extends EcdsaSignParams<infer Enc> ? EncodedEcdsaSignature<Enc> : Buffer