@shapeshiftoss/types 8.6.0 → 8.6.2

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.
@@ -0,0 +1,272 @@
1
+ import type { AppDataRootSchema as AppDataRootSchemaLegacy } from '@cowprotocol/app-data/dist/generatedTypes/v0.4.0';
2
+ import type { AppDataRootSchema as AppDataRootSchemaLatest } from '@cowprotocol/app-data/dist/generatedTypes/v1.3.0';
3
+ import type { Nominal } from '@shapeshiftoss/caip';
4
+ import type { TypedDataField } from 'ethers5';
5
+ import type { Address } from 'viem';
6
+ import type { KnownChainIds } from './base.js';
7
+ export type AppDataHash = Nominal<string, 'AppDataHash'>;
8
+ export type AppData = Nominal<string, 'AppData'>;
9
+ export type OrderId = Nominal<string, 'OrderId'>;
10
+ export type CowSwapQuoteId = Nominal<number, 'CowSwapQuoteId'>;
11
+ export declare enum TypedDataPrimaryType {
12
+ Order = "Order",
13
+ OrderCancellations = "OrderCancellations"
14
+ }
15
+ export declare enum OrderKind {
16
+ BUY = "buy",
17
+ SELL = "sell"
18
+ }
19
+ export declare enum SellTokenSource {
20
+ ERC20 = "erc20",
21
+ INTERNAL = "internal",
22
+ EXTERNAL = "external"
23
+ }
24
+ export declare enum BuyTokenDestination {
25
+ ERC20 = "erc20",
26
+ INTERNAL = "internal"
27
+ }
28
+ export declare enum SigningScheme {
29
+ EIP712 = "eip712",
30
+ ETHSIGN = "ethsign",
31
+ PRESIGN = "presign",
32
+ EIP1271 = "eip1271"
33
+ }
34
+ export declare enum EcdsaSigningScheme {
35
+ EIP712 = "eip712",
36
+ ETHSIGN = "ethsign"
37
+ }
38
+ export declare enum OrderClass {
39
+ MARKET = "market",
40
+ LIMIT = "limit",
41
+ LIQUIDITY = "liquidity"
42
+ }
43
+ export declare enum PlacementError {
44
+ QUOTE_NOT_FOUND = "QuoteNotFound",
45
+ VALID_TO_TOO_FAR_IN_FUTURE = "ValidToTooFarInFuture",
46
+ PRE_VALIDATION_ERROR = "PreValidationError"
47
+ }
48
+ export declare enum OrderQuoteSideKindSell {
49
+ SELL = "sell"
50
+ }
51
+ export declare enum OrderQuoteSideKindBuy {
52
+ BUY = "buy"
53
+ }
54
+ export declare enum PriceQuality {
55
+ FAST = "fast",
56
+ OPTIMAL = "optimal",
57
+ VERIFIED = "verified"
58
+ }
59
+ export declare enum OrderError {
60
+ DUPLICATED_ORDER = "DuplicatedOrder",
61
+ QUOTE_NOT_FOUND = "QuoteNotFound",
62
+ QUOTE_NOT_VERIFIED = "QuoteNotVerified",
63
+ INVALID_QUOTE = "InvalidQuote",
64
+ MISSING_FROM = "MissingFrom",
65
+ WRONG_OWNER = "WrongOwner",
66
+ INVALID_EIP1271SIGNATURE = "InvalidEip1271Signature",
67
+ INSUFFICIENT_BALANCE = "InsufficientBalance",
68
+ INSUFFICIENT_ALLOWANCE = "InsufficientAllowance",
69
+ INVALID_SIGNATURE = "InvalidSignature",
70
+ SELL_AMOUNT_OVERFLOW = "SellAmountOverflow",
71
+ TRANSFER_SIMULATION_FAILED = "TransferSimulationFailed",
72
+ ZERO_AMOUNT = "ZeroAmount",
73
+ INCOMPATIBLE_SIGNING_SCHEME = "IncompatibleSigningScheme",
74
+ TOO_MANY_LIMIT_ORDERS = "TooManyLimitOrders",
75
+ TOO_MUCH_GAS = "TooMuchGas",
76
+ UNSUPPORTED_BUY_TOKEN_DESTINATION = "UnsupportedBuyTokenDestination",
77
+ UNSUPPORTED_SELL_TOKEN_SOURCE = "UnsupportedSellTokenSource",
78
+ UNSUPPORTED_ORDER_TYPE = "UnsupportedOrderType",
79
+ INSUFFICIENT_VALID_TO = "InsufficientValidTo",
80
+ EXCESSIVE_VALID_TO = "ExcessiveValidTo",
81
+ INVALID_NATIVE_SELL_TOKEN = "InvalidNativeSellToken",
82
+ SAME_BUY_AND_SELL_TOKEN = "SameBuyAndSellToken",
83
+ UNSUPPORTED_TOKEN = "UnsupportedToken",
84
+ INVALID_APP_DATA = "InvalidAppData",
85
+ APP_DATA_HASH_MISMATCH = "AppDataHashMismatch",
86
+ APPDATA_FROM_MISMATCH = "AppdataFromMismatch",
87
+ SELL_AMOUNT_DOES_NOT_COVER_FEE = "SellAmountDoesNotCoverFee",
88
+ NO_LIQUIDITY = "NoLiquidity"
89
+ }
90
+ export declare enum CompetitionOrderStatusType {
91
+ OPEN = "open",
92
+ SCHEDULED = "scheduled",
93
+ ACTIVE = "active",
94
+ SOLVED = "solved",
95
+ EXECUTING = "executing",
96
+ TRADED = "traded",
97
+ CANCELLED = "cancelled"
98
+ }
99
+ export declare enum OrderStatus {
100
+ PRESIGNATURE_PENDING = "presignaturePending",
101
+ OPEN = "open",
102
+ FULFILLED = "fulfilled",
103
+ CANCELLED = "cancelled",
104
+ EXPIRED = "expired"
105
+ }
106
+ export type OrderCreation = {
107
+ sellToken: Address;
108
+ buyToken: Address;
109
+ receiver?: Address | null;
110
+ sellAmount: string;
111
+ buyAmount: string;
112
+ validTo: number;
113
+ feeAmount: string;
114
+ kind: OrderKind;
115
+ partiallyFillable: boolean;
116
+ sellTokenBalance?: SellTokenSource;
117
+ buyTokenBalance?: BuyTokenDestination;
118
+ signingScheme: SigningScheme;
119
+ signature: string;
120
+ from?: Address | null;
121
+ quoteId?: CowSwapQuoteId | null;
122
+ appData: AppData | AppDataHash;
123
+ appDataHash?: AppDataHash | null;
124
+ };
125
+ export type UnsignedOrderCreation = Omit<OrderCreation, 'signature'> & Partial<Pick<OrderCreation, 'signature'>>;
126
+ export type EthflowData = {
127
+ refundTxHash: string | null;
128
+ userValidTo: number;
129
+ };
130
+ export type OnchainOrderData = {
131
+ sender: Address;
132
+ placementError?: PlacementError;
133
+ };
134
+ export type OrderMetaData = {
135
+ creationDate: string;
136
+ class: OrderClass;
137
+ owner: Address;
138
+ uid: string;
139
+ availableBalance?: string | null;
140
+ sellAmount: string;
141
+ executedSellAmount: string;
142
+ executedSellAmountBeforeFees: string;
143
+ executedBuyAmount: string;
144
+ isLiquidityOrder?: boolean;
145
+ ethflowData?: EthflowData;
146
+ onchainUser?: Address;
147
+ onchainOrderData?: OnchainOrderData;
148
+ executedSurplusFee?: string | null;
149
+ fullAppData?: string | null;
150
+ };
151
+ export type Order = OrderCreation & OrderMetaData & {
152
+ status: OrderStatus;
153
+ };
154
+ export type OrderParameters = {
155
+ sellToken: Address;
156
+ buyToken: Address;
157
+ receiver?: Address | null;
158
+ sellAmount: string;
159
+ buyAmount: string;
160
+ validTo: number;
161
+ appData: AppDataHash;
162
+ feeAmount: string;
163
+ kind: OrderKind;
164
+ partiallyFillable: boolean;
165
+ sellTokenBalance?: SellTokenSource;
166
+ buyTokenBalance?: BuyTokenDestination;
167
+ signingScheme?: SigningScheme;
168
+ };
169
+ export type OrderQuoteResponse = {
170
+ quote: OrderParameters;
171
+ from?: Address;
172
+ expiration: string;
173
+ id?: CowSwapQuoteId;
174
+ verified: boolean;
175
+ };
176
+ export type OrderQuoteSide = {
177
+ kind: OrderQuoteSideKindSell;
178
+ sellAmountBeforeFee: string;
179
+ } | {
180
+ kind: OrderQuoteSideKindSell;
181
+ sellAmountAfterFee: string;
182
+ } | {
183
+ kind: OrderQuoteSideKindBuy;
184
+ buyAmountAfterFee: string;
185
+ };
186
+ export type OrderQuoteValidity = {
187
+ validTo?: number;
188
+ } | {
189
+ validFor?: number;
190
+ };
191
+ export type OrderQuoteRequest = OrderQuoteSide & OrderQuoteValidity & {
192
+ sellToken: Address;
193
+ buyToken: Address;
194
+ receiver?: Address | null;
195
+ appData?: AppData | AppDataHash;
196
+ appDataHash?: AppDataHash;
197
+ sellTokenBalance?: SellTokenSource;
198
+ buyTokenBalance?: BuyTokenDestination;
199
+ from: Address;
200
+ priceQuality?: PriceQuality;
201
+ signingScheme?: SigningScheme;
202
+ onchainOrder?: any;
203
+ };
204
+ export type OrderCancellation = {
205
+ orderUids: string[];
206
+ signature: string;
207
+ signingScheme: EcdsaSigningScheme;
208
+ };
209
+ export type ExecutedAmounts = {
210
+ sell: string;
211
+ buy: string;
212
+ };
213
+ export type CompetitionOrderStatus = {
214
+ type: CompetitionOrderStatusType;
215
+ value?: {
216
+ solver: string;
217
+ executedAmounts?: ExecutedAmounts;
218
+ }[];
219
+ };
220
+ export type Quote = {
221
+ sellAmount?: string;
222
+ buyAmount?: string;
223
+ fee?: string;
224
+ };
225
+ export type PriceImprovement = {
226
+ factor: number;
227
+ maxVolumeFactor: number;
228
+ quote: Quote;
229
+ };
230
+ export type Surplus = {
231
+ factor: number;
232
+ maxVolumeFactor: number;
233
+ };
234
+ export type Volume = {
235
+ factor: number;
236
+ };
237
+ export type FeePolicy = Surplus | Volume | PriceImprovement;
238
+ export type ExecutedProtocolFee = {
239
+ policy?: FeePolicy;
240
+ amount?: string;
241
+ token?: Address;
242
+ };
243
+ export type Trade = {
244
+ blockNumber: number;
245
+ logIndex: number;
246
+ orderUid: string;
247
+ owner: Address;
248
+ sellToken: Address;
249
+ buyToken: Address;
250
+ sellAmount: string;
251
+ sellAmountBeforeFees: string;
252
+ buyAmount: string;
253
+ txHash: string | null;
254
+ executedProtocolFees?: ExecutedProtocolFee[];
255
+ };
256
+ export type CowSwapError = {
257
+ errorType: OrderError;
258
+ description: string;
259
+ data?: unknown;
260
+ };
261
+ export declare enum CowNetwork {
262
+ Mainnet = "mainnet",
263
+ Xdai = "xdai",
264
+ ArbitrumOne = "arbitrum_one",
265
+ Base = "base",
266
+ Avalanche = "avalanche",
267
+ Polygon = "polygon"
268
+ }
269
+ export type CowChainId = KnownChainIds.EthereumMainnet | KnownChainIds.GnosisMainnet | KnownChainIds.ArbitrumMainnet;
270
+ export type TypedDataTypes = Record<string, TypedDataField[]>;
271
+ export type ParsedAppData = AppDataRootSchemaLatest | AppDataRootSchemaLegacy;
272
+ export declare const isLegacyAppData: (appData: ParsedAppData) => appData is AppDataRootSchemaLegacy;
@@ -0,0 +1,125 @@
1
+ // The following are lifted directly out of the cowprotocol source code because ethers version conflicts prevent us importing the SDK directly.
2
+ // https://github.dev/cowprotocol/cow-sdk/blob/main/src/order-book/generated/models/
3
+ export var TypedDataPrimaryType;
4
+ (function (TypedDataPrimaryType) {
5
+ TypedDataPrimaryType["Order"] = "Order";
6
+ TypedDataPrimaryType["OrderCancellations"] = "OrderCancellations";
7
+ })(TypedDataPrimaryType || (TypedDataPrimaryType = {}));
8
+ export var OrderKind;
9
+ (function (OrderKind) {
10
+ OrderKind["BUY"] = "buy";
11
+ OrderKind["SELL"] = "sell";
12
+ })(OrderKind || (OrderKind = {}));
13
+ export var SellTokenSource;
14
+ (function (SellTokenSource) {
15
+ SellTokenSource["ERC20"] = "erc20";
16
+ SellTokenSource["INTERNAL"] = "internal";
17
+ SellTokenSource["EXTERNAL"] = "external";
18
+ })(SellTokenSource || (SellTokenSource = {}));
19
+ export var BuyTokenDestination;
20
+ (function (BuyTokenDestination) {
21
+ BuyTokenDestination["ERC20"] = "erc20";
22
+ BuyTokenDestination["INTERNAL"] = "internal";
23
+ })(BuyTokenDestination || (BuyTokenDestination = {}));
24
+ export var SigningScheme;
25
+ (function (SigningScheme) {
26
+ SigningScheme["EIP712"] = "eip712";
27
+ SigningScheme["ETHSIGN"] = "ethsign";
28
+ SigningScheme["PRESIGN"] = "presign";
29
+ SigningScheme["EIP1271"] = "eip1271";
30
+ })(SigningScheme || (SigningScheme = {}));
31
+ export var EcdsaSigningScheme;
32
+ (function (EcdsaSigningScheme) {
33
+ EcdsaSigningScheme["EIP712"] = "eip712";
34
+ EcdsaSigningScheme["ETHSIGN"] = "ethsign";
35
+ })(EcdsaSigningScheme || (EcdsaSigningScheme = {}));
36
+ export var OrderClass;
37
+ (function (OrderClass) {
38
+ OrderClass["MARKET"] = "market";
39
+ OrderClass["LIMIT"] = "limit";
40
+ OrderClass["LIQUIDITY"] = "liquidity";
41
+ })(OrderClass || (OrderClass = {}));
42
+ export var PlacementError;
43
+ (function (PlacementError) {
44
+ PlacementError["QUOTE_NOT_FOUND"] = "QuoteNotFound";
45
+ PlacementError["VALID_TO_TOO_FAR_IN_FUTURE"] = "ValidToTooFarInFuture";
46
+ PlacementError["PRE_VALIDATION_ERROR"] = "PreValidationError";
47
+ })(PlacementError || (PlacementError = {}));
48
+ export var OrderQuoteSideKindSell;
49
+ (function (OrderQuoteSideKindSell) {
50
+ OrderQuoteSideKindSell["SELL"] = "sell";
51
+ })(OrderQuoteSideKindSell || (OrderQuoteSideKindSell = {}));
52
+ export var OrderQuoteSideKindBuy;
53
+ (function (OrderQuoteSideKindBuy) {
54
+ OrderQuoteSideKindBuy["BUY"] = "buy";
55
+ })(OrderQuoteSideKindBuy || (OrderQuoteSideKindBuy = {}));
56
+ export var PriceQuality;
57
+ (function (PriceQuality) {
58
+ PriceQuality["FAST"] = "fast";
59
+ PriceQuality["OPTIMAL"] = "optimal";
60
+ PriceQuality["VERIFIED"] = "verified";
61
+ })(PriceQuality || (PriceQuality = {}));
62
+ export var OrderError;
63
+ (function (OrderError) {
64
+ OrderError["DUPLICATED_ORDER"] = "DuplicatedOrder";
65
+ OrderError["QUOTE_NOT_FOUND"] = "QuoteNotFound";
66
+ OrderError["QUOTE_NOT_VERIFIED"] = "QuoteNotVerified";
67
+ OrderError["INVALID_QUOTE"] = "InvalidQuote";
68
+ OrderError["MISSING_FROM"] = "MissingFrom";
69
+ OrderError["WRONG_OWNER"] = "WrongOwner";
70
+ OrderError["INVALID_EIP1271SIGNATURE"] = "InvalidEip1271Signature";
71
+ OrderError["INSUFFICIENT_BALANCE"] = "InsufficientBalance";
72
+ OrderError["INSUFFICIENT_ALLOWANCE"] = "InsufficientAllowance";
73
+ OrderError["INVALID_SIGNATURE"] = "InvalidSignature";
74
+ OrderError["SELL_AMOUNT_OVERFLOW"] = "SellAmountOverflow";
75
+ OrderError["TRANSFER_SIMULATION_FAILED"] = "TransferSimulationFailed";
76
+ OrderError["ZERO_AMOUNT"] = "ZeroAmount";
77
+ OrderError["INCOMPATIBLE_SIGNING_SCHEME"] = "IncompatibleSigningScheme";
78
+ OrderError["TOO_MANY_LIMIT_ORDERS"] = "TooManyLimitOrders";
79
+ OrderError["TOO_MUCH_GAS"] = "TooMuchGas";
80
+ OrderError["UNSUPPORTED_BUY_TOKEN_DESTINATION"] = "UnsupportedBuyTokenDestination";
81
+ OrderError["UNSUPPORTED_SELL_TOKEN_SOURCE"] = "UnsupportedSellTokenSource";
82
+ OrderError["UNSUPPORTED_ORDER_TYPE"] = "UnsupportedOrderType";
83
+ OrderError["INSUFFICIENT_VALID_TO"] = "InsufficientValidTo";
84
+ OrderError["EXCESSIVE_VALID_TO"] = "ExcessiveValidTo";
85
+ OrderError["INVALID_NATIVE_SELL_TOKEN"] = "InvalidNativeSellToken";
86
+ OrderError["SAME_BUY_AND_SELL_TOKEN"] = "SameBuyAndSellToken";
87
+ OrderError["UNSUPPORTED_TOKEN"] = "UnsupportedToken";
88
+ OrderError["INVALID_APP_DATA"] = "InvalidAppData";
89
+ OrderError["APP_DATA_HASH_MISMATCH"] = "AppDataHashMismatch";
90
+ OrderError["APPDATA_FROM_MISMATCH"] = "AppdataFromMismatch";
91
+ // Not documented in API docs, but exists.
92
+ // Most likely non-exhaustive, see https://github.com/cowprotocol/contracts/blob/aaffdc55b2a13738b7c32de96f487d3eb5b4f8c6/src/ts/api.ts#L110
93
+ OrderError["SELL_AMOUNT_DOES_NOT_COVER_FEE"] = "SellAmountDoesNotCoverFee";
94
+ OrderError["NO_LIQUIDITY"] = "NoLiquidity";
95
+ })(OrderError || (OrderError = {}));
96
+ export var CompetitionOrderStatusType;
97
+ (function (CompetitionOrderStatusType) {
98
+ CompetitionOrderStatusType["OPEN"] = "open";
99
+ CompetitionOrderStatusType["SCHEDULED"] = "scheduled";
100
+ CompetitionOrderStatusType["ACTIVE"] = "active";
101
+ CompetitionOrderStatusType["SOLVED"] = "solved";
102
+ CompetitionOrderStatusType["EXECUTING"] = "executing";
103
+ CompetitionOrderStatusType["TRADED"] = "traded";
104
+ CompetitionOrderStatusType["CANCELLED"] = "cancelled";
105
+ })(CompetitionOrderStatusType || (CompetitionOrderStatusType = {}));
106
+ export var OrderStatus;
107
+ (function (OrderStatus) {
108
+ OrderStatus["PRESIGNATURE_PENDING"] = "presignaturePending";
109
+ OrderStatus["OPEN"] = "open";
110
+ OrderStatus["FULFILLED"] = "fulfilled";
111
+ OrderStatus["CANCELLED"] = "cancelled";
112
+ OrderStatus["EXPIRED"] = "expired";
113
+ })(OrderStatus || (OrderStatus = {}));
114
+ export var CowNetwork;
115
+ (function (CowNetwork) {
116
+ CowNetwork["Mainnet"] = "mainnet";
117
+ CowNetwork["Xdai"] = "xdai";
118
+ CowNetwork["ArbitrumOne"] = "arbitrum_one";
119
+ CowNetwork["Base"] = "base";
120
+ CowNetwork["Avalanche"] = "avalanche";
121
+ CowNetwork["Polygon"] = "polygon";
122
+ })(CowNetwork || (CowNetwork = {}));
123
+ export const isLegacyAppData = (appData) => {
124
+ return appData.version === 'v0.4.0';
125
+ };
@@ -0,0 +1,5 @@
1
+ export * from './cowSwap.js';
2
+ export * from './base.js';
3
+ export * from './market.js';
4
+ export * from './utility.js';
5
+ export * from './zerion.js';
@@ -0,0 +1,5 @@
1
+ export * from './cowSwap.js';
2
+ export * from './base.js';
3
+ export * from './market.js';
4
+ export * from './utility.js';
5
+ export * from './zerion.js';
@@ -0,0 +1,36 @@
1
+ import type { AssetId } from '@shapeshiftoss/caip';
2
+ export type MarketData = {
3
+ price: string;
4
+ marketCap: string;
5
+ volume: string;
6
+ changePercent24Hr: number;
7
+ supply?: string;
8
+ maxSupply?: string;
9
+ };
10
+ export declare enum HistoryTimeframe {
11
+ HOUR = "1H",
12
+ DAY = "24H",
13
+ WEEK = "1W",
14
+ MONTH = "1M",
15
+ YEAR = "1Y",
16
+ ALL = "All"
17
+ }
18
+ export type HistoryData = {
19
+ price: number;
20
+ date: number;
21
+ };
22
+ export type PriceHistoryArgs = {
23
+ assetId: string;
24
+ timeframe: HistoryTimeframe;
25
+ };
26
+ export type MarketDataArgs = {
27
+ assetId: string;
28
+ };
29
+ export type FindAllMarketType = (args: FindAllMarketArgs) => Promise<MarketCapResult>;
30
+ export type PriceHistoryType = (args: PriceHistoryArgs) => Promise<HistoryData[]>;
31
+ export type FindAllMarketArgs = {
32
+ count: number;
33
+ };
34
+ export type MarketCapResult = {
35
+ [k: AssetId]: MarketData;
36
+ };
@@ -0,0 +1,9 @@
1
+ export var HistoryTimeframe;
2
+ (function (HistoryTimeframe) {
3
+ HistoryTimeframe["HOUR"] = "1H";
4
+ HistoryTimeframe["DAY"] = "24H";
5
+ HistoryTimeframe["WEEK"] = "1W";
6
+ HistoryTimeframe["MONTH"] = "1M";
7
+ HistoryTimeframe["YEAR"] = "1Y";
8
+ HistoryTimeframe["ALL"] = "All";
9
+ })(HistoryTimeframe || (HistoryTimeframe = {}));
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Further reading on ideas behind these utility types
3
+ *
4
+ * See: https://stackoverflow.com/questions/55904032/how-to-get-optional-property-from-union
5
+ */
6
+ /** Get specific type for key(K) in union(T) */
7
+ export type ValueOfUnion<T, K> = T extends unknown ? (K extends keyof T ? T[K] : undefined) : never;
8
+ /** Get all keys in union(T) as union */
9
+ export type KeysOfUnion<T> = T extends unknown ? keyof T : never;
10
+ /**
11
+ * Create mapping of all keys in union(T) with proper type values
12
+ *
13
+ * _note: `| keyof T` index is simply to tell typescript that T is definitely a sub type of KeysOfUnion_
14
+ */
15
+ export type UnionMapping<T> = {
16
+ [K in KeysOfUnion<T> | keyof T]: ValueOfUnion<T, K>;
17
+ };
18
+ /** Pick out the elements we know for sure and make everything else optional */
19
+ export type UnionMerge<T> = Pick<UnionMapping<T>, keyof T> & Partial<UnionMapping<T>>;
20
+ /** Adds all possible values of union(T) as a nested object under a `chainSpecific` key */
21
+ export type ChainSpecific<T, M> = UnionMerge<T extends unknown ? (T extends keyof M ? {
22
+ chainSpecific: M[T];
23
+ } : undefined) : never>;
24
+ export type PartialRecord<K extends keyof any, V> = Partial<Record<K, V>>;
25
+ export type NestedArray<T> = PartialRecord<keyof any, PartialRecord<keyof any, T[]>>;
26
+ type Head<T extends string> = T extends `${infer First}.${string}` ? First : T;
27
+ type Tail<T extends string> = T extends `${string}.${infer Rest}` ? Rest : never;
28
+ export type DeepPick<T, K extends string> = T extends object ? {
29
+ [P in Extract<Head<K>, keyof T>]: Tail<Extract<K, `${P}.${string}`>> extends never ? T[P] : DeepPick<T[P], Tail<Extract<K, `${P}.${string}`>>>;
30
+ } : T;
31
+ export {};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Further reading on ideas behind these utility types
3
+ *
4
+ * See: https://stackoverflow.com/questions/55904032/how-to-get-optional-property-from-union
5
+ */
6
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { ChainId } from '@shapeshiftoss/caip';
2
+ export declare const ZERION_CHAINS: readonly ["avalanche", "binance-smart-chain", "ethereum", "optimism", "polygon", "arbitrum", "xdai", "base"];
3
+ export type ZerionChainId = (typeof ZERION_CHAINS)[number];
4
+ export declare const ZERION_CHAINS_MAP: Record<ZerionChainId, ChainId>;
5
+ export declare const zerionChainIdToChainId: (chainId: ZerionChainId) => ChainId | undefined;
@@ -0,0 +1,27 @@
1
+ import { arbitrumChainId, avalancheChainId, baseChainId, bscChainId, ethChainId, gnosisChainId, optimismChainId, polygonChainId, } from '@shapeshiftoss/caip';
2
+ export const ZERION_CHAINS = [
3
+ // shapeshift supported
4
+ 'avalanche',
5
+ 'binance-smart-chain',
6
+ 'ethereum',
7
+ 'optimism',
8
+ 'polygon',
9
+ 'arbitrum',
10
+ 'xdai',
11
+ 'base',
12
+ // not yet
13
+ // 'aurora',
14
+ // 'fantom',
15
+ // 'solana',
16
+ ];
17
+ export const ZERION_CHAINS_MAP = {
18
+ avalanche: avalancheChainId,
19
+ 'binance-smart-chain': bscChainId,
20
+ ethereum: ethChainId,
21
+ optimism: optimismChainId,
22
+ polygon: polygonChainId,
23
+ arbitrum: arbitrumChainId,
24
+ xdai: gnosisChainId,
25
+ base: baseChainId,
26
+ };
27
+ export const zerionChainIdToChainId = (chainId) => ZERION_CHAINS_MAP[chainId];
package/package.json CHANGED
@@ -1,11 +1,20 @@
1
1
  {
2
2
  "name": "@shapeshiftoss/types",
3
- "version": "8.6.0",
3
+ "version": "8.6.2",
4
4
  "description": "Common types shared across packages",
5
- "repository": "https://github.com/shapeshift/lib",
5
+ "repository": "https://github.com/shapeshift/web",
6
6
  "license": "MIT",
7
- "main": "./dist/index.js",
8
- "types": "./dist/index.d.ts",
7
+ "type": "module",
8
+ "main": "dist/cjs/index.js",
9
+ "module": "dist/esm/index.js",
10
+ "types": "dist/esm/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "import": "./dist/esm/index.js",
14
+ "require": "./dist/cjs/index.js",
15
+ "types": "./dist/esm/index.d.ts"
16
+ }
17
+ },
9
18
  "files": [
10
19
  "dist"
11
20
  ],
@@ -13,12 +22,14 @@
13
22
  "access": "public"
14
23
  },
15
24
  "scripts": {
16
- "build": "yarn clean && yarn compile",
17
- "dev": "tsc --watch",
18
- "clean": "rm -rf dist && rm -rf tsconfig.build.tsbuildinfo",
19
- "compile": "tsc -p tsconfig.build.json",
20
- "prepare": "yarn build",
21
- "test": "jest test",
22
- "type-check": "tsc --project ./tsconfig.build.json --noEmit"
25
+ "build": "yarn clean && yarn run -T tsc --build && yarn postbuild",
26
+ "clean": "rm -rf dist",
27
+ "dev": "yarn run -T tsc --build --watch",
28
+ "postbuild": "yarn postbuild:esm && yarn postbuild:cjs",
29
+ "postbuild:esm": "yarn run -T tsc-esm-fix --target=dist/esm --ext=.js",
30
+ "postbuild:cjs": "echo '{\"type\": \"commonjs\"}' > dist/cjs/package.json"
31
+ },
32
+ "devDependencies": {
33
+ "@shapeshiftoss/caip": "workspace:^"
23
34
  }
24
35
  }
package/dist/base.d.ts DELETED
@@ -1,29 +0,0 @@
1
- export declare type BIP44Params = {
2
- purpose: number;
3
- coinType: number;
4
- accountNumber: number;
5
- isChange?: boolean;
6
- index?: number;
7
- };
8
- export declare enum KnownChainIds {
9
- EthereumMainnet = "eip155:1",
10
- AvalancheMainnet = "eip155:43114",
11
- OptimismMainnet = "eip155:10",
12
- BnbSmartChainMainnet = "eip155:56",
13
- BitcoinMainnet = "bip122:000000000019d6689c085ae165831e93",
14
- BitcoinCashMainnet = "bip122:000000000000000000651ef99cb9fcbe",
15
- DogecoinMainnet = "bip122:00000000001a91e3dace36e2be3bf030",
16
- LitecoinMainnet = "bip122:12a765e31ffd4059bada1e25190f6e98",
17
- CosmosMainnet = "cosmos:cosmoshub-4",
18
- OsmosisMainnet = "cosmos:osmosis-1",
19
- ThorchainMainnet = "cosmos:thorchain-mainnet-v1"
20
- }
21
- export declare enum WithdrawType {
22
- DELAYED = 0,
23
- INSTANT = 1
24
- }
25
- export declare enum UtxoAccountType {
26
- SegwitNative = "SegwitNative",
27
- SegwitP2sh = "SegwitP2sh",
28
- P2pkh = "P2pkh"
29
- }
package/dist/market.d.ts DELETED
@@ -1,35 +0,0 @@
1
- export declare type MarketData = {
2
- price: string;
3
- marketCap: string;
4
- volume: string;
5
- changePercent24Hr: number;
6
- supply?: string;
7
- maxSupply?: string;
8
- };
9
- export declare enum HistoryTimeframe {
10
- HOUR = "1H",
11
- DAY = "24H",
12
- WEEK = "1W",
13
- MONTH = "1M",
14
- YEAR = "1Y",
15
- ALL = "All"
16
- }
17
- export declare type HistoryData = {
18
- price: number;
19
- date: number;
20
- };
21
- export declare type PriceHistoryArgs = {
22
- assetId: string;
23
- timeframe: HistoryTimeframe;
24
- };
25
- export declare type MarketDataArgs = {
26
- assetId: string;
27
- };
28
- export declare type FindAllMarketType = (args: FindAllMarketArgs) => Promise<MarketCapResult>;
29
- export declare type PriceHistoryType = (args: PriceHistoryArgs) => Promise<HistoryData[]>;
30
- export declare type FindAllMarketArgs = {
31
- count: number;
32
- };
33
- export declare type MarketCapResult = {
34
- [k: string]: MarketData;
35
- };
package/dist/utility.d.ts DELETED
@@ -1,24 +0,0 @@
1
- /**
2
- * Further reading on ideas behind these utility types
3
- *
4
- * See: https://stackoverflow.com/questions/55904032/how-to-get-optional-property-from-union
5
- */
6
- /** Get specific type for key(K) in union(T) */
7
- export declare type ValueOfUnion<T, K> = T extends unknown ? (K extends keyof T ? T[K] : undefined) : never;
8
- /** Get all keys in union(T) as union */
9
- export declare type KeysOfUnion<T> = T extends unknown ? keyof T : never;
10
- /**
11
- * Create mapping of all keys in union(T) with proper type values
12
- *
13
- * _note: `| keyof T` index is simply to tell typescript that T is definitely a sub type of KeysOfUnion_
14
- */
15
- export declare type UnionMapping<T> = {
16
- [K in KeysOfUnion<T> | keyof T]: ValueOfUnion<T, K>;
17
- };
18
- /** Pick out the elements we know for sure and make everything else optional */
19
- export declare type UnionMerge<T> = Pick<UnionMapping<T>, keyof T> & Partial<UnionMapping<T>>;
20
- /** Adds all possible values of union(T) as a nested object under a `chainSpecific` key */
21
- export declare type ChainSpecific<T, M> = UnionMerge<T extends unknown ? (T extends keyof M ? {
22
- chainSpecific: M[T];
23
- } : undefined) : never>;
24
- export declare type PartialRecord<K extends keyof any, V> = Partial<Record<K, V>>;
File without changes