sushi 6.6.7 → 6.6.9

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.
Files changed (45) hide show
  1. package/_cjs/evm/config/subgraphs/subgraphs/sushiswap-v2.js +2 -7
  2. package/_cjs/evm/config/subgraphs/subgraphs/sushiswap-v2.js.map +1 -1
  3. package/_cjs/evm/config/subgraphs/subgraphs/sushiswap-v3.js +2 -7
  4. package/_cjs/evm/config/subgraphs/subgraphs/sushiswap-v3.js.map +1 -1
  5. package/_cjs/generic/currency/for-chain.js +66 -0
  6. package/_cjs/generic/currency/for-chain.js.map +1 -0
  7. package/_cjs/generic/currency/index.js +1 -0
  8. package/_cjs/generic/currency/index.js.map +1 -1
  9. package/_esm/evm/config/subgraphs/subgraphs/sushiswap-v2.js +2 -7
  10. package/_esm/evm/config/subgraphs/subgraphs/sushiswap-v2.js.map +1 -1
  11. package/_esm/evm/config/subgraphs/subgraphs/sushiswap-v3.js +2 -7
  12. package/_esm/evm/config/subgraphs/subgraphs/sushiswap-v3.js.map +1 -1
  13. package/_esm/generic/currency/for-chain.js +62 -0
  14. package/_esm/generic/currency/for-chain.js.map +1 -0
  15. package/_esm/generic/currency/index.js +1 -0
  16. package/_esm/generic/currency/index.js.map +1 -1
  17. package/_types/evm/config/subgraphs/subgraphs/sushiswap-v2.d.ts +1 -1
  18. package/_types/evm/config/subgraphs/subgraphs/sushiswap-v2.d.ts.map +1 -1
  19. package/_types/evm/config/subgraphs/subgraphs/sushiswap-v3.d.ts +1 -1
  20. package/_types/evm/config/subgraphs/subgraphs/sushiswap-v3.d.ts.map +1 -1
  21. package/_types/evm/currency/currency.d.ts +1 -1
  22. package/_types/evm/currency/currency.d.ts.map +1 -1
  23. package/_types/generic/currency/currency.d.ts +1 -1
  24. package/_types/generic/currency/currency.d.ts.map +1 -1
  25. package/_types/generic/currency/for-chain.d.ts +33 -0
  26. package/_types/generic/currency/for-chain.d.ts.map +1 -0
  27. package/_types/generic/currency/index.d.ts +1 -0
  28. package/_types/generic/currency/index.d.ts.map +1 -1
  29. package/_types/generic/types/for-chain.d.ts +4 -0
  30. package/_types/generic/types/for-chain.d.ts.map +1 -1
  31. package/_types/svm/currency/currency.d.ts +1 -1
  32. package/_types/svm/currency/currency.d.ts.map +1 -1
  33. package/evm/config/subgraphs/subgraphs/sushiswap-v2.ts +5 -8
  34. package/evm/config/subgraphs/subgraphs/sushiswap-v3.ts +5 -8
  35. package/evm/currency/currency.ts +1 -1
  36. package/generic/currency/currency.test-d.ts +41 -0
  37. package/generic/currency/currency.ts +1 -1
  38. package/generic/currency/for-chain.test-d.ts +248 -0
  39. package/generic/currency/for-chain.test.ts +108 -0
  40. package/generic/currency/for-chain.ts +152 -0
  41. package/generic/currency/index.ts +1 -0
  42. package/generic/types/for-chain.test-d.ts +112 -1
  43. package/generic/types/for-chain.ts +13 -0
  44. package/package.json +1 -1
  45. package/svm/currency/currency.ts +1 -1
@@ -1,12 +1,123 @@
1
1
  import { describe, expectTypeOf, it } from 'vitest'
2
+ import type { EvmChainId } from '../../evm/chain/chains.js'
3
+ import type { EvmCurrency } from '../../evm/currency/currency.js'
4
+ import type { EvmNative } from '../../evm/currency/native.js'
5
+ import type { EvmToken } from '../../evm/currency/token.js'
6
+ import type { MvmChainId } from '../../mvm/chain/chains.js'
7
+ import type { MvmToken } from '../../mvm/currency/token.js'
2
8
  import type { StellarAddress } from '../../stellar/address.js'
3
9
  import type { StellarChainId } from '../../stellar/chain/chains.js'
10
+ import type { StellarCurrency } from '../../stellar/currency/currency.js'
11
+ import type { StellarToken } from '../../stellar/currency/token.js'
4
12
  import type { StellarID } from '../../stellar/types/id.js'
13
+ import type { SvmCurrency } from '../../svm/currency/currency.js'
14
+ import type { SvmNative } from '../../svm/currency/native.js'
15
+ import type { SvmToken } from '../../svm/currency/token.js'
5
16
  import type { SvmChainId } from '../../svm/index.js'
6
17
  import type { SvmID } from '../../svm/types/id.js'
7
- import type { IDFor } from './for-chain.js'
18
+ import type {
19
+ CurrencyFor,
20
+ IDFor,
21
+ NativeChainId,
22
+ NativeFor,
23
+ TokenFor,
24
+ } from './for-chain.js'
8
25
 
9
26
  describe('generic/types/for-chain.ts types', () => {
27
+ type Metadata = {
28
+ coingeckoId: string
29
+ verified: boolean
30
+ }
31
+
32
+ describe('TokenFor', () => {
33
+ it('should return the correct token type for each chain family', () => {
34
+ expectTypeOf<TokenFor<EvmChainId, Metadata>>().toEqualTypeOf<
35
+ EvmToken<Metadata>
36
+ >()
37
+ expectTypeOf<TokenFor<MvmChainId, Metadata>>().toEqualTypeOf<
38
+ MvmToken<Metadata>
39
+ >()
40
+ expectTypeOf<TokenFor<SvmChainId, Metadata>>().toEqualTypeOf<
41
+ SvmToken<Metadata>
42
+ >()
43
+ expectTypeOf<TokenFor<StellarChainId, Metadata>>().toEqualTypeOf<
44
+ StellarToken<Metadata>
45
+ >()
46
+ })
47
+
48
+ it('should distribute over chain id unions', () => {
49
+ expectTypeOf<TokenFor<EvmChainId | SvmChainId, Metadata>>().toEqualTypeOf<
50
+ EvmToken<Metadata> | SvmToken<Metadata>
51
+ >()
52
+ })
53
+ })
54
+
55
+ describe('CurrencyFor', () => {
56
+ it('should return the correct currency type for each chain family', () => {
57
+ expectTypeOf<CurrencyFor<EvmChainId, Metadata>>().toEqualTypeOf<
58
+ EvmCurrency<Metadata>
59
+ >()
60
+ expectTypeOf<CurrencyFor<MvmChainId, Metadata>>().toEqualTypeOf<
61
+ MvmToken<Metadata>
62
+ >()
63
+ expectTypeOf<CurrencyFor<SvmChainId, Metadata>>().toEqualTypeOf<
64
+ SvmCurrency<Metadata>
65
+ >()
66
+ expectTypeOf<CurrencyFor<StellarChainId, Metadata>>().toEqualTypeOf<
67
+ StellarCurrency<Metadata>
68
+ >()
69
+ })
70
+
71
+ it('should distribute over chain id unions', () => {
72
+ expectTypeOf<
73
+ CurrencyFor<EvmChainId | SvmChainId, Metadata>
74
+ >().toEqualTypeOf<EvmCurrency<Metadata> | SvmCurrency<Metadata>>()
75
+ })
76
+ })
77
+
78
+ describe('NativeFor', () => {
79
+ it('should only support chain families with native currency classes', () => {
80
+ expectTypeOf<NativeChainId>().toEqualTypeOf<EvmChainId | SvmChainId>()
81
+ expectTypeOf<NativeFor<EvmChainId, Metadata>>().toEqualTypeOf<
82
+ EvmNative<Metadata>
83
+ >()
84
+ expectTypeOf<NativeFor<SvmChainId, Metadata>>().toEqualTypeOf<
85
+ SvmNative<Metadata>
86
+ >()
87
+ expectTypeOf<NativeFor<NativeChainId, Metadata>>().toEqualTypeOf<
88
+ EvmNative<Metadata> | SvmNative<Metadata>
89
+ >()
90
+ })
91
+
92
+ it('should be assignable to CurrencyFor for native chain families', () => {
93
+ expectTypeOf<NativeFor<EvmChainId, Metadata>>().toMatchTypeOf<
94
+ CurrencyFor<EvmChainId, Metadata>
95
+ >()
96
+ expectTypeOf<NativeFor<SvmChainId, Metadata>>().toMatchTypeOf<
97
+ CurrencyFor<SvmChainId, Metadata>
98
+ >()
99
+ expectTypeOf<NativeFor<NativeChainId, Metadata>>().toMatchTypeOf<
100
+ CurrencyFor<NativeChainId, Metadata>
101
+ >()
102
+ })
103
+
104
+ it('should reject token-only chain families', () => {
105
+ type NativeForMvm = NativeFor<
106
+ // @ts-expect-error MVM is intentionally excluded from NativeChainId.
107
+ MvmChainId,
108
+ Metadata
109
+ >
110
+ type NativeForStellar = NativeFor<
111
+ // @ts-expect-error Stellar is intentionally excluded from NativeChainId.
112
+ StellarChainId,
113
+ Metadata
114
+ >
115
+
116
+ expectTypeOf<NativeForMvm>().toEqualTypeOf<never>()
117
+ expectTypeOf<NativeForStellar>().toEqualTypeOf<never>()
118
+ })
119
+ })
120
+
10
121
  describe('IDFor', () => {
11
122
  it('should return the correct id type for SVM chains', () => {
12
123
  expectTypeOf<IDFor<SvmChainId>>().toEqualTypeOf<SvmID>()
@@ -1,5 +1,6 @@
1
1
  import type { EvmChainId } from '../../evm/chain/chains.js'
2
2
  import type { EvmCurrency } from '../../evm/currency/currency.js'
3
+ import type { EvmNative } from '../../evm/currency/native.js'
3
4
  import type {
4
5
  EvmAddress,
5
6
  EvmToken,
@@ -19,6 +20,7 @@ import type { StellarToken } from '../../stellar/currency/token.js'
19
20
  import type { StellarID } from '../../stellar/types/id.js'
20
21
  import type { SvmChainId } from '../../svm/chain/chains.js'
21
22
  import type { SvmCurrency } from '../../svm/currency/currency.js'
23
+ import type { SvmNative } from '../../svm/currency/native.js'
22
24
  import type {
23
25
  SvmAddress,
24
26
  SvmToken,
@@ -54,6 +56,17 @@ export type CurrencyFor<
54
56
  ? StellarCurrency<Metadata>
55
57
  : never
56
58
 
59
+ export type NativeChainId = EvmChainId | SvmChainId
60
+
61
+ export type NativeFor<
62
+ TChainId extends NativeChainId,
63
+ Metadata extends CurrencyMetadata = CurrencyMetadata,
64
+ > = TChainId extends EvmChainId
65
+ ? EvmNative<Metadata>
66
+ : TChainId extends SvmChainId
67
+ ? SvmNative<Metadata>
68
+ : never
69
+
57
70
  export type AddressFor<TChainId extends ChainId> = TChainId extends EvmChainId
58
71
  ? EvmAddress
59
72
  : TChainId extends MvmChainId
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sushi",
3
3
  "description": "Sushi",
4
- "version": "6.6.7",
4
+ "version": "6.6.9",
5
5
  "type": "module",
6
6
  "main": "./_cjs/generic/index.js",
7
7
  "module": "./_esm/generic/index.js",
@@ -6,7 +6,7 @@ import { type SvmToken, serializedSvmTokenSchema } from './token.js'
6
6
 
7
7
  export type SvmCurrency<
8
8
  TMetadata extends CurrencyMetadata = Record<string, unknown>,
9
- > = SvmToken<TMetadata> | SvmNative
9
+ > = SvmToken<TMetadata> | SvmNative<TMetadata>
10
10
 
11
11
  export const serializedSvmCurrencySchema = <
12
12
  TMetadata extends {} = CurrencyMetadata,