@cowprotocol/cow-sdk 0.0.12 → 0.0.13
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/dist/api/cow-subgraph/graphql.d.ts +161 -21
- package/dist/api/metadata/index.d.ts +2 -2
- package/dist/api/metadata/types.d.ts +5 -2
- package/dist/appData.schema-4c010c50.js +2 -0
- package/dist/appData.schema-4c010c50.js.map +1 -0
- package/dist/appData.schema-adfc1c6f.js +2 -0
- package/dist/appData.schema-adfc1c6f.js.map +1 -0
- package/dist/constants/index.d.ts +2 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +1 -1
- package/dist/index.modern.js.map +1 -1
- package/dist/index.module.js +2 -2
- package/dist/index.module.js.map +1 -1
- package/dist/utils/context.d.ts +4 -1
- package/dist/utils/ipfs.d.ts +1 -1
- package/package.json +1 -1
- package/dist/appData.schema-0c8db23b.js +0 -2
- package/dist/appData.schema-0c8db23b.js.map +0 -1
- package/dist/appData.schema-412cbfbf.js +0 -2
- package/dist/appData.schema-412cbfbf.js.map +0 -1
|
@@ -338,7 +338,7 @@ export declare type Order = {
|
|
|
338
338
|
/** block's timestamp on invalidate event */
|
|
339
339
|
invalidateTimestamp?: Maybe<Scalars['Int']>;
|
|
340
340
|
/** Boolean value to show if the order is signed */
|
|
341
|
-
isSigned
|
|
341
|
+
isSigned?: Maybe<Scalars['Boolean']>;
|
|
342
342
|
/** Boolean value true by default unless is invalidated by the event */
|
|
343
343
|
isValid?: Maybe<Scalars['Boolean']>;
|
|
344
344
|
/** Trade's owner or presign User */
|
|
@@ -822,6 +822,8 @@ export declare type Query = {
|
|
|
822
822
|
trades: Array<Trade>;
|
|
823
823
|
uniswapPool?: Maybe<UniswapPool>;
|
|
824
824
|
uniswapPools: Array<UniswapPool>;
|
|
825
|
+
uniswapToken?: Maybe<UniswapToken>;
|
|
826
|
+
uniswapTokens: Array<UniswapToken>;
|
|
825
827
|
user?: Maybe<User>;
|
|
826
828
|
users: Array<User>;
|
|
827
829
|
};
|
|
@@ -1038,6 +1040,20 @@ export declare type QueryUniswapPoolsArgs = {
|
|
|
1038
1040
|
subgraphError?: _SubgraphErrorPolicy_;
|
|
1039
1041
|
where?: InputMaybe<UniswapPool_Filter>;
|
|
1040
1042
|
};
|
|
1043
|
+
export declare type QueryUniswapTokenArgs = {
|
|
1044
|
+
block?: InputMaybe<Block_Height>;
|
|
1045
|
+
id: Scalars['ID'];
|
|
1046
|
+
subgraphError?: _SubgraphErrorPolicy_;
|
|
1047
|
+
};
|
|
1048
|
+
export declare type QueryUniswapTokensArgs = {
|
|
1049
|
+
block?: InputMaybe<Block_Height>;
|
|
1050
|
+
first?: InputMaybe<Scalars['Int']>;
|
|
1051
|
+
orderBy?: InputMaybe<UniswapToken_OrderBy>;
|
|
1052
|
+
orderDirection?: InputMaybe<OrderDirection>;
|
|
1053
|
+
skip?: InputMaybe<Scalars['Int']>;
|
|
1054
|
+
subgraphError?: _SubgraphErrorPolicy_;
|
|
1055
|
+
where?: InputMaybe<UniswapToken_Filter>;
|
|
1056
|
+
};
|
|
1041
1057
|
export declare type QueryUserArgs = {
|
|
1042
1058
|
block?: InputMaybe<Block_Height>;
|
|
1043
1059
|
id: Scalars['ID'];
|
|
@@ -1159,6 +1175,8 @@ export declare type Subscription = {
|
|
|
1159
1175
|
trades: Array<Trade>;
|
|
1160
1176
|
uniswapPool?: Maybe<UniswapPool>;
|
|
1161
1177
|
uniswapPools: Array<UniswapPool>;
|
|
1178
|
+
uniswapToken?: Maybe<UniswapToken>;
|
|
1179
|
+
uniswapTokens: Array<UniswapToken>;
|
|
1162
1180
|
user?: Maybe<User>;
|
|
1163
1181
|
users: Array<User>;
|
|
1164
1182
|
};
|
|
@@ -1375,6 +1393,20 @@ export declare type SubscriptionUniswapPoolsArgs = {
|
|
|
1375
1393
|
subgraphError?: _SubgraphErrorPolicy_;
|
|
1376
1394
|
where?: InputMaybe<UniswapPool_Filter>;
|
|
1377
1395
|
};
|
|
1396
|
+
export declare type SubscriptionUniswapTokenArgs = {
|
|
1397
|
+
block?: InputMaybe<Block_Height>;
|
|
1398
|
+
id: Scalars['ID'];
|
|
1399
|
+
subgraphError?: _SubgraphErrorPolicy_;
|
|
1400
|
+
};
|
|
1401
|
+
export declare type SubscriptionUniswapTokensArgs = {
|
|
1402
|
+
block?: InputMaybe<Block_Height>;
|
|
1403
|
+
first?: InputMaybe<Scalars['Int']>;
|
|
1404
|
+
orderBy?: InputMaybe<UniswapToken_OrderBy>;
|
|
1405
|
+
orderDirection?: InputMaybe<OrderDirection>;
|
|
1406
|
+
skip?: InputMaybe<Scalars['Int']>;
|
|
1407
|
+
subgraphError?: _SubgraphErrorPolicy_;
|
|
1408
|
+
where?: InputMaybe<UniswapToken_Filter>;
|
|
1409
|
+
};
|
|
1378
1410
|
export declare type SubscriptionUserArgs = {
|
|
1379
1411
|
block?: InputMaybe<Block_Height>;
|
|
1380
1412
|
id: Scalars['ID'];
|
|
@@ -1393,8 +1425,6 @@ export declare type Token = {
|
|
|
1393
1425
|
__typename?: 'Token';
|
|
1394
1426
|
/** Token address */
|
|
1395
1427
|
address: Scalars['Bytes'];
|
|
1396
|
-
/** Pools token is in that are allow listed for USD pricing */
|
|
1397
|
-
allowedPools: Array<UniswapPool>;
|
|
1398
1428
|
/** Token decimals fetched by contract call */
|
|
1399
1429
|
decimals: Scalars['Int'];
|
|
1400
1430
|
/** First token trade block timestamp */
|
|
@@ -1416,16 +1446,9 @@ export declare type Token = {
|
|
|
1416
1446
|
/** Total volume managed in CowSwap */
|
|
1417
1447
|
totalVolume?: Maybe<Scalars['BigInt']>;
|
|
1418
1448
|
/** Total volume in Eth */
|
|
1419
|
-
totalVolumeEth
|
|
1449
|
+
totalVolumeEth: Scalars['BigDecimal'];
|
|
1420
1450
|
/** Total volume in Usd */
|
|
1421
|
-
totalVolumeUsd
|
|
1422
|
-
};
|
|
1423
|
-
export declare type TokenAllowedPoolsArgs = {
|
|
1424
|
-
first?: InputMaybe<Scalars['Int']>;
|
|
1425
|
-
orderBy?: InputMaybe<UniswapPool_OrderBy>;
|
|
1426
|
-
orderDirection?: InputMaybe<OrderDirection>;
|
|
1427
|
-
skip?: InputMaybe<Scalars['Int']>;
|
|
1428
|
-
where?: InputMaybe<UniswapPool_Filter>;
|
|
1451
|
+
totalVolumeUsd: Scalars['BigDecimal'];
|
|
1429
1452
|
};
|
|
1430
1453
|
export declare type TokenHistoryArgs = {
|
|
1431
1454
|
first?: InputMaybe<Scalars['Int']>;
|
|
@@ -1848,12 +1871,6 @@ export declare type Token_Filter = {
|
|
|
1848
1871
|
address_not?: InputMaybe<Scalars['Bytes']>;
|
|
1849
1872
|
address_not_contains?: InputMaybe<Scalars['Bytes']>;
|
|
1850
1873
|
address_not_in?: InputMaybe<Array<Scalars['Bytes']>>;
|
|
1851
|
-
allowedPools?: InputMaybe<Array<Scalars['String']>>;
|
|
1852
|
-
allowedPools_contains?: InputMaybe<Array<Scalars['String']>>;
|
|
1853
|
-
allowedPools_contains_nocase?: InputMaybe<Array<Scalars['String']>>;
|
|
1854
|
-
allowedPools_not?: InputMaybe<Array<Scalars['String']>>;
|
|
1855
|
-
allowedPools_not_contains?: InputMaybe<Array<Scalars['String']>>;
|
|
1856
|
-
allowedPools_not_contains_nocase?: InputMaybe<Array<Scalars['String']>>;
|
|
1857
1874
|
decimals?: InputMaybe<Scalars['Int']>;
|
|
1858
1875
|
decimals_gt?: InputMaybe<Scalars['Int']>;
|
|
1859
1876
|
decimals_gte?: InputMaybe<Scalars['Int']>;
|
|
@@ -1969,7 +1986,6 @@ export declare type Token_Filter = {
|
|
|
1969
1986
|
};
|
|
1970
1987
|
export declare enum Token_OrderBy {
|
|
1971
1988
|
Address = "address",
|
|
1972
|
-
AllowedPools = "allowedPools",
|
|
1973
1989
|
Decimals = "decimals",
|
|
1974
1990
|
FirstTradeTimestamp = "firstTradeTimestamp",
|
|
1975
1991
|
History = "history",
|
|
@@ -2331,11 +2347,11 @@ export declare type UniswapPool = {
|
|
|
2331
2347
|
/** Current tick */
|
|
2332
2348
|
tick?: Maybe<Scalars['BigInt']>;
|
|
2333
2349
|
/** Token0 */
|
|
2334
|
-
token0:
|
|
2350
|
+
token0: UniswapToken;
|
|
2335
2351
|
/** Token0 per token1 */
|
|
2336
2352
|
token0Price: Scalars['BigDecimal'];
|
|
2337
2353
|
/** Token1 */
|
|
2338
|
-
token1:
|
|
2354
|
+
token1: UniswapToken;
|
|
2339
2355
|
/** Token1 per token0 */
|
|
2340
2356
|
token1Price: Scalars['BigDecimal'];
|
|
2341
2357
|
/** Total token 0 across all ticks */
|
|
@@ -2454,6 +2470,130 @@ export declare enum UniswapPool_OrderBy {
|
|
|
2454
2470
|
TotalValueLockedToken0 = "totalValueLockedToken0",
|
|
2455
2471
|
TotalValueLockedToken1 = "totalValueLockedToken1"
|
|
2456
2472
|
}
|
|
2473
|
+
export declare type UniswapToken = {
|
|
2474
|
+
__typename?: 'UniswapToken';
|
|
2475
|
+
/** Token address */
|
|
2476
|
+
address: Scalars['Bytes'];
|
|
2477
|
+
/** Pools token is in that are allow listed for USD pricing */
|
|
2478
|
+
allowedPools: Array<UniswapToken>;
|
|
2479
|
+
/** Token decimals fetched by contract call */
|
|
2480
|
+
decimals: Scalars['Int'];
|
|
2481
|
+
/** Token address to hexString */
|
|
2482
|
+
id: Scalars['ID'];
|
|
2483
|
+
/** Token name fetched by ERC20 contract call */
|
|
2484
|
+
name: Scalars['String'];
|
|
2485
|
+
/** Derived price in ETH */
|
|
2486
|
+
priceEth?: Maybe<Scalars['BigDecimal']>;
|
|
2487
|
+
/** Derived price in USD */
|
|
2488
|
+
priceUsd?: Maybe<Scalars['BigDecimal']>;
|
|
2489
|
+
/** Token symbol fetched by contract call */
|
|
2490
|
+
symbol: Scalars['String'];
|
|
2491
|
+
};
|
|
2492
|
+
export declare type UniswapTokenAllowedPoolsArgs = {
|
|
2493
|
+
first?: InputMaybe<Scalars['Int']>;
|
|
2494
|
+
orderBy?: InputMaybe<UniswapToken_OrderBy>;
|
|
2495
|
+
orderDirection?: InputMaybe<OrderDirection>;
|
|
2496
|
+
skip?: InputMaybe<Scalars['Int']>;
|
|
2497
|
+
where?: InputMaybe<UniswapToken_Filter>;
|
|
2498
|
+
};
|
|
2499
|
+
export declare type UniswapToken_Filter = {
|
|
2500
|
+
/** Filter for the block changed event. */
|
|
2501
|
+
_change_block?: InputMaybe<BlockChangedFilter>;
|
|
2502
|
+
address?: InputMaybe<Scalars['Bytes']>;
|
|
2503
|
+
address_contains?: InputMaybe<Scalars['Bytes']>;
|
|
2504
|
+
address_in?: InputMaybe<Array<Scalars['Bytes']>>;
|
|
2505
|
+
address_not?: InputMaybe<Scalars['Bytes']>;
|
|
2506
|
+
address_not_contains?: InputMaybe<Scalars['Bytes']>;
|
|
2507
|
+
address_not_in?: InputMaybe<Array<Scalars['Bytes']>>;
|
|
2508
|
+
allowedPools?: InputMaybe<Array<Scalars['String']>>;
|
|
2509
|
+
allowedPools_contains?: InputMaybe<Array<Scalars['String']>>;
|
|
2510
|
+
allowedPools_contains_nocase?: InputMaybe<Array<Scalars['String']>>;
|
|
2511
|
+
allowedPools_not?: InputMaybe<Array<Scalars['String']>>;
|
|
2512
|
+
allowedPools_not_contains?: InputMaybe<Array<Scalars['String']>>;
|
|
2513
|
+
allowedPools_not_contains_nocase?: InputMaybe<Array<Scalars['String']>>;
|
|
2514
|
+
decimals?: InputMaybe<Scalars['Int']>;
|
|
2515
|
+
decimals_gt?: InputMaybe<Scalars['Int']>;
|
|
2516
|
+
decimals_gte?: InputMaybe<Scalars['Int']>;
|
|
2517
|
+
decimals_in?: InputMaybe<Array<Scalars['Int']>>;
|
|
2518
|
+
decimals_lt?: InputMaybe<Scalars['Int']>;
|
|
2519
|
+
decimals_lte?: InputMaybe<Scalars['Int']>;
|
|
2520
|
+
decimals_not?: InputMaybe<Scalars['Int']>;
|
|
2521
|
+
decimals_not_in?: InputMaybe<Array<Scalars['Int']>>;
|
|
2522
|
+
id?: InputMaybe<Scalars['ID']>;
|
|
2523
|
+
id_gt?: InputMaybe<Scalars['ID']>;
|
|
2524
|
+
id_gte?: InputMaybe<Scalars['ID']>;
|
|
2525
|
+
id_in?: InputMaybe<Array<Scalars['ID']>>;
|
|
2526
|
+
id_lt?: InputMaybe<Scalars['ID']>;
|
|
2527
|
+
id_lte?: InputMaybe<Scalars['ID']>;
|
|
2528
|
+
id_not?: InputMaybe<Scalars['ID']>;
|
|
2529
|
+
id_not_in?: InputMaybe<Array<Scalars['ID']>>;
|
|
2530
|
+
name?: InputMaybe<Scalars['String']>;
|
|
2531
|
+
name_contains?: InputMaybe<Scalars['String']>;
|
|
2532
|
+
name_contains_nocase?: InputMaybe<Scalars['String']>;
|
|
2533
|
+
name_ends_with?: InputMaybe<Scalars['String']>;
|
|
2534
|
+
name_ends_with_nocase?: InputMaybe<Scalars['String']>;
|
|
2535
|
+
name_gt?: InputMaybe<Scalars['String']>;
|
|
2536
|
+
name_gte?: InputMaybe<Scalars['String']>;
|
|
2537
|
+
name_in?: InputMaybe<Array<Scalars['String']>>;
|
|
2538
|
+
name_lt?: InputMaybe<Scalars['String']>;
|
|
2539
|
+
name_lte?: InputMaybe<Scalars['String']>;
|
|
2540
|
+
name_not?: InputMaybe<Scalars['String']>;
|
|
2541
|
+
name_not_contains?: InputMaybe<Scalars['String']>;
|
|
2542
|
+
name_not_contains_nocase?: InputMaybe<Scalars['String']>;
|
|
2543
|
+
name_not_ends_with?: InputMaybe<Scalars['String']>;
|
|
2544
|
+
name_not_ends_with_nocase?: InputMaybe<Scalars['String']>;
|
|
2545
|
+
name_not_in?: InputMaybe<Array<Scalars['String']>>;
|
|
2546
|
+
name_not_starts_with?: InputMaybe<Scalars['String']>;
|
|
2547
|
+
name_not_starts_with_nocase?: InputMaybe<Scalars['String']>;
|
|
2548
|
+
name_starts_with?: InputMaybe<Scalars['String']>;
|
|
2549
|
+
name_starts_with_nocase?: InputMaybe<Scalars['String']>;
|
|
2550
|
+
priceEth?: InputMaybe<Scalars['BigDecimal']>;
|
|
2551
|
+
priceEth_gt?: InputMaybe<Scalars['BigDecimal']>;
|
|
2552
|
+
priceEth_gte?: InputMaybe<Scalars['BigDecimal']>;
|
|
2553
|
+
priceEth_in?: InputMaybe<Array<Scalars['BigDecimal']>>;
|
|
2554
|
+
priceEth_lt?: InputMaybe<Scalars['BigDecimal']>;
|
|
2555
|
+
priceEth_lte?: InputMaybe<Scalars['BigDecimal']>;
|
|
2556
|
+
priceEth_not?: InputMaybe<Scalars['BigDecimal']>;
|
|
2557
|
+
priceEth_not_in?: InputMaybe<Array<Scalars['BigDecimal']>>;
|
|
2558
|
+
priceUsd?: InputMaybe<Scalars['BigDecimal']>;
|
|
2559
|
+
priceUsd_gt?: InputMaybe<Scalars['BigDecimal']>;
|
|
2560
|
+
priceUsd_gte?: InputMaybe<Scalars['BigDecimal']>;
|
|
2561
|
+
priceUsd_in?: InputMaybe<Array<Scalars['BigDecimal']>>;
|
|
2562
|
+
priceUsd_lt?: InputMaybe<Scalars['BigDecimal']>;
|
|
2563
|
+
priceUsd_lte?: InputMaybe<Scalars['BigDecimal']>;
|
|
2564
|
+
priceUsd_not?: InputMaybe<Scalars['BigDecimal']>;
|
|
2565
|
+
priceUsd_not_in?: InputMaybe<Array<Scalars['BigDecimal']>>;
|
|
2566
|
+
symbol?: InputMaybe<Scalars['String']>;
|
|
2567
|
+
symbol_contains?: InputMaybe<Scalars['String']>;
|
|
2568
|
+
symbol_contains_nocase?: InputMaybe<Scalars['String']>;
|
|
2569
|
+
symbol_ends_with?: InputMaybe<Scalars['String']>;
|
|
2570
|
+
symbol_ends_with_nocase?: InputMaybe<Scalars['String']>;
|
|
2571
|
+
symbol_gt?: InputMaybe<Scalars['String']>;
|
|
2572
|
+
symbol_gte?: InputMaybe<Scalars['String']>;
|
|
2573
|
+
symbol_in?: InputMaybe<Array<Scalars['String']>>;
|
|
2574
|
+
symbol_lt?: InputMaybe<Scalars['String']>;
|
|
2575
|
+
symbol_lte?: InputMaybe<Scalars['String']>;
|
|
2576
|
+
symbol_not?: InputMaybe<Scalars['String']>;
|
|
2577
|
+
symbol_not_contains?: InputMaybe<Scalars['String']>;
|
|
2578
|
+
symbol_not_contains_nocase?: InputMaybe<Scalars['String']>;
|
|
2579
|
+
symbol_not_ends_with?: InputMaybe<Scalars['String']>;
|
|
2580
|
+
symbol_not_ends_with_nocase?: InputMaybe<Scalars['String']>;
|
|
2581
|
+
symbol_not_in?: InputMaybe<Array<Scalars['String']>>;
|
|
2582
|
+
symbol_not_starts_with?: InputMaybe<Scalars['String']>;
|
|
2583
|
+
symbol_not_starts_with_nocase?: InputMaybe<Scalars['String']>;
|
|
2584
|
+
symbol_starts_with?: InputMaybe<Scalars['String']>;
|
|
2585
|
+
symbol_starts_with_nocase?: InputMaybe<Scalars['String']>;
|
|
2586
|
+
};
|
|
2587
|
+
export declare enum UniswapToken_OrderBy {
|
|
2588
|
+
Address = "address",
|
|
2589
|
+
AllowedPools = "allowedPools",
|
|
2590
|
+
Decimals = "decimals",
|
|
2591
|
+
Id = "id",
|
|
2592
|
+
Name = "name",
|
|
2593
|
+
PriceEth = "priceEth",
|
|
2594
|
+
PriceUsd = "priceUsd",
|
|
2595
|
+
Symbol = "symbol"
|
|
2596
|
+
}
|
|
2457
2597
|
export declare type User = {
|
|
2458
2598
|
__typename?: 'User';
|
|
2459
2599
|
/** Owner's address */
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Context } from '../../utils/context';
|
|
2
|
-
import { AppDataDoc, IpfsHashInfo, MetadataDoc } from './types';
|
|
2
|
+
import { AppDataDoc, IpfsHashInfo, MetadataDoc, OptionalAppDataProperties } from './types';
|
|
3
3
|
export declare class MetadataApi {
|
|
4
4
|
context: Context;
|
|
5
5
|
constructor(context: Context);
|
|
6
|
-
generateAppDataDoc(metadata?: MetadataDoc,
|
|
6
|
+
generateAppDataDoc(metadata?: MetadataDoc, optionalProperties?: OptionalAppDataProperties): AppDataDoc;
|
|
7
7
|
decodeAppData(hash: string): Promise<void | AppDataDoc>;
|
|
8
8
|
cidToAppDataHex(ipfsHash: string): Promise<string | void>;
|
|
9
9
|
appDataHexToCid(hash: string): Promise<string | void>;
|
|
@@ -13,11 +13,14 @@ export declare type MetadataDoc = {
|
|
|
13
13
|
referrer?: ReferralMetadata;
|
|
14
14
|
quote?: QuoteMetadata;
|
|
15
15
|
};
|
|
16
|
+
export declare type OptionalAppDataProperties = {
|
|
17
|
+
appCode?: string;
|
|
18
|
+
environment?: string;
|
|
19
|
+
};
|
|
16
20
|
export declare type AppDataDoc = {
|
|
17
21
|
version: string;
|
|
18
|
-
appCode?: string;
|
|
19
22
|
metadata: MetadataDoc;
|
|
20
|
-
};
|
|
23
|
+
} & OptionalAppDataProperties;
|
|
21
24
|
export declare type IpfsHashInfo = {
|
|
22
25
|
/**
|
|
23
26
|
* IPFS's content identifier v0
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e="https://cowswap.exchange/appdata.schema.json",t="http://json-schema.org/draft-07/schema",i="Metadata JSON document for adding information to orders.",r=["version","metadata"],o="AppData Root Schema",n={version:{$id:"#/properties/version",description:"Semantic versioning of document",examples:["1.0.0","1.2.3"],title:"Semantic Versioning",type:"string"},appCode:{$id:"#/properties/appCode",description:"The code identifying the CLI, UI, service generating the order.",examples:["CowSwap"],title:"App Code",type:"string"},environment:{$id:"#/properties/environment",description:"Environment from which the order came from",title:"Environment",type:"string",examples:["production","development","staging","ens"]},metadata:{$id:"#/properties/metadata",default:{},description:"Each metadata will specify one aspect of the order.",required:[],title:"Metadata descriptors",type:"object",properties:{referrer:{$ref:"#/definitions/kindMetadata/referrer"},quote:{$ref:"#/definitions/kindMetadata/quote"}}}},s={version:{$id:"#/definitions/version",description:"Semantic versioning of document",examples:["1.0.0","1.2.3"],title:"Semantic Versioning",type:"string"},ethereumAddress:{$id:"#/definitions/ethereumAddress",pattern:"^0x[a-fA-F0-9]{40}$",title:"Ethereum compatible address",examples:["0xb6BAd41ae76A11D10f7b0E664C5007b908bC77C9"],type:"string"},bigNumber:{$id:"#/definitions/bigNumber",pattern:"\\d+",title:"BigNumber",examples:["90741097240912730913, 0, 75891372"],type:"string"},kindMetadata:{referrer:{$id:"#/definitions/referrer",required:["version","address"],title:"Referrer",type:"object",properties:{version:{$ref:"#/definitions/version"},address:{$ref:"#/definitions/ethereumAddress",title:"Referrer address"}}},quote:{$id:"#/definitions/quote",required:["sellAmount","buyAmount","version"],title:"Quote",type:"object",properties:{id:{$id:"#/definitions/quote/id",title:"Quote id",examples:["XA23443543534FF"],type:"string"},sellAmount:{$ref:"#/definitions/bigNumber",title:"Quote sell amount"},buyAmount:{$ref:"#/definitions/bigNumber",title:"Quote buy amount"},version:{$ref:"#/definitions/version"}}}}},d={$id:e,$schema:t,description:i,required:r,title:o,type:"object",properties:n,definitions:s};exports.$id=e,exports.$schema=t,exports.default=d,exports.definitions=s,exports.description=i,exports.properties=n,exports.required=r,exports.title=o,exports.type="object";
|
|
2
|
+
//# sourceMappingURL=appData.schema-4c010c50.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appData.schema-4c010c50.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e="https://cowswap.exchange/appdata.schema.json",t="http://json-schema.org/draft-07/schema",i="Metadata JSON document for adding information to orders.",r=["version","metadata"],n="AppData Root Schema",o="object",s={version:{$id:"#/properties/version",description:"Semantic versioning of document",examples:["1.0.0","1.2.3"],title:"Semantic Versioning",type:"string"},appCode:{$id:"#/properties/appCode",description:"The code identifying the CLI, UI, service generating the order.",examples:["CowSwap"],title:"App Code",type:"string"},environment:{$id:"#/properties/environment",description:"Environment from which the order came from",title:"Environment",type:"string",examples:["production","development","staging","ens"]},metadata:{$id:"#/properties/metadata",default:{},description:"Each metadata will specify one aspect of the order.",required:[],title:"Metadata descriptors",type:"object",properties:{referrer:{$ref:"#/definitions/kindMetadata/referrer"},quote:{$ref:"#/definitions/kindMetadata/quote"}}}},d={version:{$id:"#/definitions/version",description:"Semantic versioning of document",examples:["1.0.0","1.2.3"],title:"Semantic Versioning",type:"string"},ethereumAddress:{$id:"#/definitions/ethereumAddress",pattern:"^0x[a-fA-F0-9]{40}$",title:"Ethereum compatible address",examples:["0xb6BAd41ae76A11D10f7b0E664C5007b908bC77C9"],type:"string"},bigNumber:{$id:"#/definitions/bigNumber",pattern:"\\d+",title:"BigNumber",examples:["90741097240912730913, 0, 75891372"],type:"string"},kindMetadata:{referrer:{$id:"#/definitions/referrer",required:["version","address"],title:"Referrer",type:"object",properties:{version:{$ref:"#/definitions/version"},address:{$ref:"#/definitions/ethereumAddress",title:"Referrer address"}}},quote:{$id:"#/definitions/quote",required:["sellAmount","buyAmount","version"],title:"Quote",type:"object",properties:{id:{$id:"#/definitions/quote/id",title:"Quote id",examples:["XA23443543534FF"],type:"string"},sellAmount:{$ref:"#/definitions/bigNumber",title:"Quote sell amount"},buyAmount:{$ref:"#/definitions/bigNumber",title:"Quote buy amount"},version:{$ref:"#/definitions/version"}}}}},a={$id:e,$schema:t,description:i,required:r,title:n,type:"object",properties:s,definitions:d};export{e as $id,t as $schema,a as default,d as definitions,i as description,s as properties,r as required,n as title,o as type};
|
|
2
|
+
//# sourceMappingURL=appData.schema-adfc1c6f.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appData.schema-adfc1c6f.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const GP_SETTLEMENT_CONTRACT_ADDRESS: Partial<Record<number, string>>;
|
|
2
2
|
export declare const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
3
3
|
export declare const DEFAULT_APP_DATA_HASH = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const DEFAULT_IPFS_READ_URI = "https://gnosis.mypinata.cloud/ipfs";
|
|
5
|
+
export declare const DEFAULT_IPFS_WRITE_URI = "https://api.pinata.cloud";
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var e=require("loglevel"),r=require("cross-fetch"),t=require("@gnosis.pm/gp-v2-contracts"),n=require("@gnosis.pm/gp-v2-contracts/networks.json"),o=require("graphql-request"),i=require("ajv");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function a(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach(function(t){if("default"!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}}),r.default=e,r}var u=/*#__PURE__*/s(e),c=/*#__PURE__*/s(r),d=/*#__PURE__*/s(n),l=/*#__PURE__*/s(i);class h extends Error{constructor(e,r){super(e),this.error_code=void 0,this.error_code=r}}function p(e){if(!e)return"";const r=new URLSearchParams;for(const t of Object.keys(e)){const n=e[t];n&&r.append(t,n.toString())}const t=r.toString();return t?`?${t}`:""}const m="cow-sdk:";var f;exports.SupportedChainId=void 0,(f=exports.SupportedChainId||(exports.SupportedChainId={}))[f.MAINNET=1]="MAINNET",f[f.RINKEBY=4]="RINKEBY",f[f.GNOSIS_CHAIN=100]="GNOSIS_CHAIN";const g=[exports.SupportedChainId.MAINNET,exports.SupportedChainId.RINKEBY,exports.SupportedChainId.GNOSIS_CHAIN],{GPv2Settlement:T}=d.default,v={[exports.SupportedChainId.MAINNET]:T[exports.SupportedChainId.MAINNET].address,[exports.SupportedChainId.RINKEBY]:T[exports.SupportedChainId.RINKEBY].address,[exports.SupportedChainId.GNOSIS_CHAIN]:T[exports.SupportedChainId.GNOSIS_CHAIN].address},E=function(e,r,n,o="v4"){try{let s;function i(e){var r;return s?e:{signature:null==(r=d)?void 0:r.data.toString(),signingScheme:a}}const a="eth_sign"===o?t.SigningScheme.ETHSIGN:t.SigningScheme.EIP712;let c,d=null;try{switch(o){case"v3":c=new t.TypedDataV3Signer(n);break;case"int_v4":c=new t.IntChainIdTypedDataV4Signer(n);break;default:c=n}}catch(p){throw u.default.error(m,"Wallet not supported:",p),new h("Wallet not supported")}const l=function(t,n){try{var o=Promise.resolve(r({...e,signer:c,signingScheme:a})).then(function(e){d=e})}catch(e){return n(e)}return o&&o.then?o.then(void 0,n):o}(0,function(t){if(void 0===(i=t).code&&void 0===i.message)throw u.default.error(m,t),t;var i;if(t.code===A||S.test(t.message))switch(o){case"v4":const o=E(e,r,n,"v3");return s=1,o;case"v3":const i=E(e,r,n,"eth_sign");return s=1,i;default:throw t}else{if(k.test(t.message)){const t=E(e,r,n,"int_v4");return s=1,t}if(t.code===I){const t=E(e,r,n,"eth_sign");return s=1,t}if(w.test(t.message)){const t=E(e,r,n,"v3");return s=1,t}if(N.test(t.message)){const t=E(e,r,n,"eth_sign");return s=1,t}}});return Promise.resolve(l&&l.then?l.then(i):i(l))}catch(f){return Promise.reject(f)}},P=function(e){try{const{chainId:r,signer:n,signingScheme:o,orderId:i}=e,s=C(r);return Promise.resolve(t.signOrderCancellation(s,i,n,x(o)))}catch(e){return Promise.reject(e)}},y=function(e){try{const{chainId:r,signer:n,order:o,signingScheme:i}=e,s=C(r);return Promise.resolve(t.signOrder(s,o,n,x(i)))}catch(e){return Promise.reject(e)}},I=-32603,A=-32601,w=/eth_signTypedData_v4 does not exist/i,N=/eth_signTypedData_v3 does not exist/i,S=/RPC request failed/i,k=/provided chainid .* must match the active chainid/i,D=new Map([[t.SigningScheme.EIP712,{libraryValue:0,apiValue:"eip712"}],[t.SigningScheme.ETHSIGN,{libraryValue:1,apiValue:"ethsign"}],[t.SigningScheme.EIP1271,{libraryValue:2,apiValue:"eip1271"}],[t.SigningScheme.PRESIGN,{libraryValue:3,apiValue:"presign"}]]);function O(e){const r=D.get(e);if(void 0===r)throw new h("Unknown schema "+e);return r}function _(e){return O(e).apiValue}function x(e){return O(e).libraryValue}function C(e){const r=v[e];if(!r)throw new h("Unsupported network. Settlement contract is not deployed");return t.domain(e,r)}var b,U,R,j;!function(e){e.DuplicateOrder="DuplicateOrder",e.InvalidSignature="InvalidSignature",e.MissingOrderData="MissingOrderData",e.InsufficientValidTo="InsufficientValidTo",e.InsufficientAllowance="InsufficientAllowance",e.InsufficientBalance="InsufficientBalance",e.InsufficientFee="InsufficientFee",e.WrongOwner="WrongOwner",e.NotFound="NotFound",e.OrderNotFound="OrderNotFound",e.AlreadyCancelled="AlreadyCancelled",e.OrderFullyExecuted="OrderFullyExecuted",e.OrderExpired="OrderExpired",e.NoLiquidity="NoLiquidity",e.UnsupportedToken="UnsupportedToken",e.AmountIsZero="AmountIsZero",e.SellAmountDoesNotCoverFee="SellAmountDoesNotCoverFee",e.TransferEthToContract="TransferEthToContract",e.UNHANDLED_GET_ERROR="UNHANDLED_GET_ERROR",e.UNHANDLED_CREATE_ERROR="UNHANDLED_CREATE_ERROR",e.UNHANDLED_DELETE_ERROR="UNHANDLED_DELETE_ERROR"}(b||(b={})),function(e){e.DuplicateOrder="There was another identical order already submitted. Please try again.",e.InsufficientFee="The signed fee is insufficient. It's possible that is higher now due to a change in the gas price, ether price, or the sell token price. Please try again to get an updated fee quote.",e.InvalidSignature="The order signature is invalid. Check whether your Wallet app supports off-chain signing.",e.MissingOrderData="The order has missing information",e.InsufficientValidTo="The order you are signing is already expired. This can happen if you set a short expiration in the settings and waited too long before signing the transaction. Please try again.",e.InsufficientAllowance="The account doesn't have enough funds",e.InsufficientBalance="The account needs to approve the selling token in order to trade",e.WrongOwner="The signature is invalid.\n\nIt's likely that the signing method provided by your wallet doesn't comply with the standards required by CowSwap.\n\nCheck whether your Wallet app supports off-chain signing (EIP-712 or ETHSIGN).",e.NotFound="Token pair selected has insufficient liquidity",e.OrderNotFound="The order you are trying to cancel does not exist",e.AlreadyCancelled="Order is already cancelled",e.OrderFullyExecuted="Order is already filled",e.OrderExpired="Order is expired",e.NoLiquidity="Token pair selected has insufficient liquidity",e.UnsupportedToken="One of the tokens you are trading is unsupported. Please read the FAQ for more info.",e.AmountIsZero="Amount is zero",e.SellAmountDoesNotCoverFee="Sell amount does not sufficiently cover the current fee",e.TransferEthToContract="Sending the native currency to smart contract wallets is not currently supported",e.UNHANDLED_GET_ERROR="Order fetch failed. This may be due to a server or network connectivity issue. Please try again later.",e.UNHANDLED_CREATE_ERROR="The order was not accepted by the network",e.UNHANDLED_DELETE_ERROR="The order cancellation was not accepted by the network"}(U||(U={}));class H extends h{static getErrorMessage(e,r){try{return Promise.resolve(function(r,t){try{var n=Promise.resolve(e.json()).then(function(e){return e.errorType?H.apiErrorDetails[e.errorType]||e.errorType:(u.default.error(m,"Unknown reason for bad order submission",e),e.description)})}catch(e){return t()}return n&&n.then?n.then(void 0,t):n}(0,function(){return u.default.error(m,"Error handling a 400 error. Likely a problem deserialising the JSON response"),function(e){switch(e){case"get":return U.UNHANDLED_GET_ERROR;case"create":return U.UNHANDLED_CREATE_ERROR;case"delete":return U.UNHANDLED_DELETE_ERROR;default:return u.default.error(m,"[OperatorError::_mapActionToErrorDetails] Uncaught error mapping error action type to server error. Please try again later."),"Something failed. Please try again later."}}(r)}))}catch(e){return Promise.reject(e)}}static getErrorFromStatusCode(e,r){try{const t=this;switch(e.status){case 400:case 404:return Promise.resolve(t.getErrorMessage(e,r));case 403:return Promise.resolve(`The order cannot be ${"create"===r?"accepted":"cancelled"}. Your account is deny-listed.`);case 429:return Promise.resolve(`The order cannot be ${"create"===r?"accepted. Too many order placements":"cancelled. Too many order cancellations"}. Please, retry in a minute`);default:return u.default.error(m,`[OperatorError::getErrorFromStatusCode] Error ${"create"===r?"creating":"cancelling"} the order, status code:`,e.status||"unknown"),Promise.resolve(`Error ${"create"===r?"creating":"cancelling"} the order`)}return Promise.resolve()}catch(e){return Promise.reject(e)}}constructor(e){super(e.description,e.errorType),this.name="OperatorError",this.description=void 0,this.description=e.description,this.message=U[e.errorType]}}H.apiErrorDetails=U,function(e){e.UnsupportedToken="UnsupportedToken",e.InsufficientLiquidity="InsufficientLiquidity",e.FeeExceedsFrom="FeeExceedsFrom",e.ZeroPrice="ZeroPrice",e.UNHANDLED_ERROR="UNHANDLED_ERROR"}(R||(R={})),function(e){e.UnsupportedToken="One of the tokens you are trading is unsupported. Please read the FAQ for more info.",e.InsufficientLiquidity="Token pair selected has insufficient liquidity",e.FeeExceedsFrom='Current fee exceeds entered "from" amount',e.ZeroPrice="Quoted price is zero. This is likely due to a significant price difference between the two tokens. Please try increasing amounts.",e.UNHANDLED_ERROR="Quote fetch failed. This may be due to a server or network connectivity issue. Please try again later."}(j||(j={}));class L extends h{static getErrorMessage(e){try{return Promise.resolve(function(r,t){try{var n=Promise.resolve(e.json()).then(function(e){return e.errorType?L.quoteErrorDetails[e.errorType]||e.errorType:(u.default.error(m,"Unknown reason for bad quote fetch",e),e.description)})}catch(e){return t()}return n&&n.then?n.then(void 0,t):n}(0,function(){return u.default.error(m,"Error handling 400/404 error. Likely a problem deserialising the JSON response"),L.quoteErrorDetails.UNHANDLED_ERROR}))}catch(e){return Promise.reject(e)}}static getErrorFromStatusCode(e){try{const r=this;switch(e.status){case 400:case 404:return Promise.resolve(r.getErrorMessage(e));default:return u.default.error(m,"[QuoteError::getErrorFromStatusCode] Error fetching quote, status code:",e.status||"unknown"),Promise.resolve("Error fetching quote")}return Promise.resolve()}catch(e){return Promise.reject(e)}}constructor(e){super(e.description,e.errorType),this.name="QuoteErrorObject",this.description=void 0,this.data=void 0,this.description=e.description,this.message=L.quoteErrorDetails[e.errorType],this.data=null==e?void 0:e.data}}L.quoteErrorDetails=j;class V{constructor(e,r){this.symbol=void 0,this.address=void 0,this.symbol=e,this.address=r}}const F={[exports.SupportedChainId.MAINNET]:new V("WETH","0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"),[exports.SupportedChainId.RINKEBY]:new V("WETH","0xc778417E063141139Fce010982780140Aa0cD5Ab"),[exports.SupportedChainId.GNOSIS_CHAIN]:new V("WXDAI","0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d")},B={[exports.SupportedChainId.MAINNET]:"ETH",[exports.SupportedChainId.RINKEBY]:"ETH",[exports.SupportedChainId.GNOSIS_CHAIN]:"XDAI"};function $(e,r){let t=e;return e===B[r]&&(t=F[r].address),t}function q(e,r){try{var t=e()}catch(e){return r(e)}return t&&t.then?t.then(void 0,r):t}const M=function(e,r){try{return e.ok?Promise.resolve(e.json()):Promise.resolve(e.json()).then(function(e){const t=function(e){switch(null==e?void 0:e.errorType){case b.NotFound:case b.NoLiquidity:return{errorType:R.InsufficientLiquidity,description:j.InsufficientLiquidity};case b.SellAmountDoesNotCoverFee:return{errorType:R.FeeExceedsFrom,description:j.FeeExceedsFrom,data:null==e?void 0:e.data};case b.UnsupportedToken:return{errorType:R.UnsupportedToken,description:e.description};case b.SellAmountDoesNotCoverFee:return{errorType:R.FeeExceedsFrom,description:e.description};default:return{errorType:R.UNHANDLED_ERROR,description:j.UNHANDLED_ERROR}}}(e),n=new L(t);if(r){const{sellToken:e,buyToken:t}=r;u.default.error(m,`Error querying fee from API - sellToken: ${e}, buyToken: ${t}`)}throw n})}catch(e){return Promise.reject(e)}},G={errorType:R.UNHANDLED_ERROR,description:j.UNHANDLED_ERROR},K={errorType:b.UNHANDLED_CREATE_ERROR,description:U.UNHANDLED_CREATE_ERROR};class Q{constructor(e){this.context=void 0,this.API_NAME="CoW Protocol",this.context=e}get DEFAULT_HEADERS(){return{"Content-Type":"application/json","X-AppId":this.context.appDataHash}}get API_BASE_URL(){return this.context.isDevEnvironment?{[exports.SupportedChainId.MAINNET]:"https://barn.api.cow.fi/mainnet/api",[exports.SupportedChainId.RINKEBY]:"https://barn.api.cow.fi/rinkeby/api",[exports.SupportedChainId.GNOSIS_CHAIN]:"https://barn.api.cow.fi/xdai/api"}:{[exports.SupportedChainId.MAINNET]:"https://api.cow.fi/mainnet/api",[exports.SupportedChainId.RINKEBY]:"https://api.cow.fi/rinkeby/api",[exports.SupportedChainId.GNOSIS_CHAIN]:"https://api.cow.fi/xdai/api"}}get PROFILE_API_BASE_URL(){return this.context.isDevEnvironment?{[exports.SupportedChainId.MAINNET]:"https://barn.api.cow.fi/affiliate/api"}:{[exports.SupportedChainId.MAINNET]:"https://api.cow.fi/affiliate/api"}}getProfileData(e){try{const r=this;return Promise.resolve(r.context.chainId).then(function(t){return u.default.debug(m,`[api:${r.API_NAME}] Get profile data for`,t,e),t!==exports.SupportedChainId.MAINNET?(u.default.info(m,"Profile data is only available for mainnet"),null):Promise.resolve(r.getProfile(`/profile/${e}`)).then(function(e){return e.ok?e.json():Promise.resolve(e.json()).then(function(e){throw u.default.error(m,e),new h(null==e?void 0:e.description)})})})}catch(e){return Promise.reject(e)}}getTrades(e){try{const r=this,{owner:t,limit:n,offset:o}=e,i=p({owner:t,limit:n,offset:o});return Promise.resolve(r.context.chainId).then(function(e){return u.default.debug(m,"[util:operator] Get trades for",e,t,{limit:n,offset:o}),q(function(){return Promise.resolve(r.get(`/trades${i}`)).then(function(e){return e.ok?e.json():Promise.resolve(e.json()).then(function(e){throw new H(e)})})},function(e){if(u.default.error(m,"Error getting trades:",e),e instanceof H)throw e;throw new h("Error getting trades: "+e)})})}catch(e){return Promise.reject(e)}}getOrders(e){try{const r=this,{owner:t,limit:n=1e3,offset:o=0}=e,i=p({limit:n,offset:o});return Promise.resolve(r.context.chainId).then(function(e){return u.default.debug(m,`[api:${r.API_NAME}] Get orders for `,e,t,n,o),q(function(){return Promise.resolve(r.get(`/account/${t}/orders/${i}`)).then(function(e){return e.ok?e.json():Promise.resolve(e.json()).then(function(e){throw new H(e)})})},function(e){if(u.default.error(m,"Error getting orders information:",e),e instanceof H)throw e;throw new H(K)})})}catch(e){return Promise.reject(e)}}getTxOrders(e){try{const r=this;return Promise.resolve(r.context.chainId).then(function(t){return u.default.debug(`[api:${r.API_NAME}] Get tx orders for `,t,e),q(function(){return Promise.resolve(r.get(`/transactions/${e}/orders`)).then(function(e){return e.ok?e.json():Promise.resolve(e.json()).then(function(e){throw new H(e)})})},function(e){if(u.default.error("Error getting transaction orders information:",e),e instanceof H)throw e;throw new H(K)})})}catch(e){return Promise.reject(e)}}getOrder(e){try{const r=this;return Promise.resolve(r.context.chainId).then(function(t){return u.default.debug(m,`[api:${r.API_NAME}] Get order for `,t,e),q(function(){return Promise.resolve(r.get(`/orders/${e}`)).then(function(e){return e.ok?e.json():Promise.resolve(e.json()).then(function(e){throw new H(e)})})},function(e){if(u.default.error(m,"Error getting order information:",e),e instanceof H)throw e;throw new H(K)})})}catch(e){return Promise.reject(e)}}getPriceQuoteLegacy(e){try{const r=this,{baseToken:t,quoteToken:n,amount:o,kind:i}=e;return Promise.resolve(r.context.chainId).then(function(s){return u.default.debug(m,`[api:${r.API_NAME}] Get price from API`,e,"for",s),Promise.resolve(r.get(`/markets/${$(t,s)}-${$(n,s)}/${i}/${o}`).catch(e=>{throw u.default.error(m,"Error getting price quote:",e),new L(G)})).then(M)})}catch(e){return Promise.reject(e)}}getQuote(e){try{const r=this;return Promise.resolve(r.context.chainId).then(function(t){const n=r.mapNewToLegacyParams(e,t);return Promise.resolve(r.post("/quote",n)).then(M)})}catch(e){return Promise.reject(e)}}sendSignedOrderCancellation(e){try{const r=this,{cancellation:t,owner:n}=e;return Promise.resolve(r.context.chainId).then(function(e){return u.default.debug(m,`[api:${r.API_NAME}] Delete signed order for network`,e,t),Promise.resolve(r.delete(`/orders/${t.orderUid}`,{signature:t.signature,signingScheme:_(t.signingScheme),from:n})).then(function(n){function o(n){u.default.debug(m,`[api:${r.API_NAME}] Cancelled order`,t.orderUid,e)}const i=function(){if(!n.ok)return Promise.resolve(H.getErrorFromStatusCode(n,"delete")).then(function(e){throw new h(e)})}();return i&&i.then?i.then(o):o()})})}catch(e){return Promise.reject(e)}}sendOrder(e){try{const r=this,t={...e.order,appData:r.context.appDataHash};return Promise.resolve(r.context.chainId).then(function(n){const{owner:o}=e;return u.default.debug(m,`[api:${r.API_NAME}] Post signed order for network`,n,t),Promise.resolve(r.post("/orders",{...t,signingScheme:_(t.signingScheme),from:o})).then(function(e){function t(t){return Promise.resolve(e.json()).then(function(e){return u.default.debug(m,`[api:${r.API_NAME}] Success posting the signed order`,e),e})}const n=function(){if(!e.ok)return Promise.resolve(H.getErrorFromStatusCode(e,"create")).then(function(e){throw new h(e)})}();return n&&n.then?n.then(t):t()})})}catch(e){return Promise.reject(e)}}getOrderLink(e){return this.getApiBaseUrl()+`/orders/${e}`}mapNewToLegacyParams(e,r){const{amount:n,kind:o,userAddress:i,receiver:s,validTo:a,sellToken:u,buyToken:c}=e,d=i||"0x0000000000000000000000000000000000000000",l={sellToken:$(u,r),buyToken:$(c,r),from:d,receiver:s||d,appData:this.context.appDataHash,validTo:a,partiallyFillable:!1};return o===t.OrderKind.SELL?{kind:t.OrderKind.SELL,sellAmountBeforeFee:n,...l}:{kind:t.OrderKind.BUY,buyAmountAfterFee:n,...l}}getApiBaseUrl(){try{const e=this;return Promise.resolve(e.context.chainId).then(function(r){const t=e.API_BASE_URL[r];if(t)return t+"/v1";throw new h(`Unsupported Network. The ${e.API_NAME} API is not deployed in the Network `+r)})}catch(e){return Promise.reject(e)}}getProfileApiBaseUrl(){try{const e=this;return Promise.resolve(e.context.chainId).then(function(r){const t=e.PROFILE_API_BASE_URL[r];if(t)return t+"/v1";throw new h(`Unsupported Network. The ${e.API_NAME} API is not deployed in the Network `+r)})}catch(e){return Promise.reject(e)}}fetch(e,r,t){try{const n=this;return Promise.resolve(n.getApiBaseUrl()).then(function(o){return c.default(o+e,{headers:n.DEFAULT_HEADERS,method:r,body:void 0!==t?JSON.stringify(t):t})})}catch(e){return Promise.reject(e)}}fetchProfile(e,r,t){try{const n=this;return Promise.resolve(n.getProfileApiBaseUrl()).then(function(o){return c.default(o+e,{headers:n.DEFAULT_HEADERS,method:r,body:void 0!==t?JSON.stringify(t):t})})}catch(e){return Promise.reject(e)}}post(e,r){return this.fetch(e,"POST",r)}get(e){return this.fetch(e,"GET")}getProfile(e){return this.fetchProfile(e,"GET")}delete(e,r){return this.fetch(e,"DELETE",r)}}const Y=o.gql`
|
|
1
|
+
var e=require("loglevel"),r=require("cross-fetch"),t=require("@gnosis.pm/gp-v2-contracts"),n=require("@gnosis.pm/gp-v2-contracts/networks.json"),o=require("graphql-request"),i=require("ajv");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function a(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach(function(t){if("default"!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}}),r.default=e,r}var u=/*#__PURE__*/s(e),c=/*#__PURE__*/s(r),d=/*#__PURE__*/s(n),l=/*#__PURE__*/s(i);class h extends Error{constructor(e,r){super(e),this.error_code=void 0,this.error_code=r}}function p(e){if(!e)return"";const r=new URLSearchParams;for(const t of Object.keys(e)){const n=e[t];n&&r.append(t,n.toString())}const t=r.toString();return t?`?${t}`:""}const m="cow-sdk:";var f;exports.SupportedChainId=void 0,(f=exports.SupportedChainId||(exports.SupportedChainId={}))[f.MAINNET=1]="MAINNET",f[f.RINKEBY=4]="RINKEBY",f[f.GNOSIS_CHAIN=100]="GNOSIS_CHAIN";const g=[exports.SupportedChainId.MAINNET,exports.SupportedChainId.RINKEBY,exports.SupportedChainId.GNOSIS_CHAIN],{GPv2Settlement:T}=d.default,v={[exports.SupportedChainId.MAINNET]:T[exports.SupportedChainId.MAINNET].address,[exports.SupportedChainId.RINKEBY]:T[exports.SupportedChainId.RINKEBY].address,[exports.SupportedChainId.GNOSIS_CHAIN]:T[exports.SupportedChainId.GNOSIS_CHAIN].address},E=function(e,r,n,o="v4"){try{let s;function i(e){var r;return s?e:{signature:null==(r=d)?void 0:r.data.toString(),signingScheme:a}}const a="eth_sign"===o?t.SigningScheme.ETHSIGN:t.SigningScheme.EIP712;let c,d=null;try{switch(o){case"v3":c=new t.TypedDataV3Signer(n);break;case"int_v4":c=new t.IntChainIdTypedDataV4Signer(n);break;default:c=n}}catch(p){throw u.default.error(m,"Wallet not supported:",p),new h("Wallet not supported")}const l=function(t,n){try{var o=Promise.resolve(r({...e,signer:c,signingScheme:a})).then(function(e){d=e})}catch(e){return n(e)}return o&&o.then?o.then(void 0,n):o}(0,function(t){if(void 0===(i=t).code&&void 0===i.message)throw u.default.error(m,t),t;var i;if(t.code===A||S.test(t.message))switch(o){case"v4":const o=E(e,r,n,"v3");return s=1,o;case"v3":const i=E(e,r,n,"eth_sign");return s=1,i;default:throw t}else{if(k.test(t.message)){const t=E(e,r,n,"int_v4");return s=1,t}if(t.code===I){const t=E(e,r,n,"eth_sign");return s=1,t}if(w.test(t.message)){const t=E(e,r,n,"v3");return s=1,t}if(N.test(t.message)){const t=E(e,r,n,"eth_sign");return s=1,t}}});return Promise.resolve(l&&l.then?l.then(i):i(l))}catch(f){return Promise.reject(f)}},P=function(e){try{const{chainId:r,signer:n,signingScheme:o,orderId:i}=e,s=C(r);return Promise.resolve(t.signOrderCancellation(s,i,n,x(o)))}catch(e){return Promise.reject(e)}},y=function(e){try{const{chainId:r,signer:n,order:o,signingScheme:i}=e,s=C(r);return Promise.resolve(t.signOrder(s,o,n,x(i)))}catch(e){return Promise.reject(e)}},I=-32603,A=-32601,w=/eth_signTypedData_v4 does not exist/i,N=/eth_signTypedData_v3 does not exist/i,S=/RPC request failed/i,k=/provided chainid .* must match the active chainid/i,D=new Map([[t.SigningScheme.EIP712,{libraryValue:0,apiValue:"eip712"}],[t.SigningScheme.ETHSIGN,{libraryValue:1,apiValue:"ethsign"}],[t.SigningScheme.EIP1271,{libraryValue:2,apiValue:"eip1271"}],[t.SigningScheme.PRESIGN,{libraryValue:3,apiValue:"presign"}]]);function O(e){const r=D.get(e);if(void 0===r)throw new h("Unknown schema "+e);return r}function _(e){return O(e).apiValue}function x(e){return O(e).libraryValue}function C(e){const r=v[e];if(!r)throw new h("Unsupported network. Settlement contract is not deployed");return t.domain(e,r)}var U,b,R,j;!function(e){e.DuplicateOrder="DuplicateOrder",e.InvalidSignature="InvalidSignature",e.MissingOrderData="MissingOrderData",e.InsufficientValidTo="InsufficientValidTo",e.InsufficientAllowance="InsufficientAllowance",e.InsufficientBalance="InsufficientBalance",e.InsufficientFee="InsufficientFee",e.WrongOwner="WrongOwner",e.NotFound="NotFound",e.OrderNotFound="OrderNotFound",e.AlreadyCancelled="AlreadyCancelled",e.OrderFullyExecuted="OrderFullyExecuted",e.OrderExpired="OrderExpired",e.NoLiquidity="NoLiquidity",e.UnsupportedToken="UnsupportedToken",e.AmountIsZero="AmountIsZero",e.SellAmountDoesNotCoverFee="SellAmountDoesNotCoverFee",e.TransferEthToContract="TransferEthToContract",e.UNHANDLED_GET_ERROR="UNHANDLED_GET_ERROR",e.UNHANDLED_CREATE_ERROR="UNHANDLED_CREATE_ERROR",e.UNHANDLED_DELETE_ERROR="UNHANDLED_DELETE_ERROR"}(U||(U={})),function(e){e.DuplicateOrder="There was another identical order already submitted. Please try again.",e.InsufficientFee="The signed fee is insufficient. It's possible that is higher now due to a change in the gas price, ether price, or the sell token price. Please try again to get an updated fee quote.",e.InvalidSignature="The order signature is invalid. Check whether your Wallet app supports off-chain signing.",e.MissingOrderData="The order has missing information",e.InsufficientValidTo="The order you are signing is already expired. This can happen if you set a short expiration in the settings and waited too long before signing the transaction. Please try again.",e.InsufficientAllowance="The account doesn't have enough funds",e.InsufficientBalance="The account needs to approve the selling token in order to trade",e.WrongOwner="The signature is invalid.\n\nIt's likely that the signing method provided by your wallet doesn't comply with the standards required by CowSwap.\n\nCheck whether your Wallet app supports off-chain signing (EIP-712 or ETHSIGN).",e.NotFound="Token pair selected has insufficient liquidity",e.OrderNotFound="The order you are trying to cancel does not exist",e.AlreadyCancelled="Order is already cancelled",e.OrderFullyExecuted="Order is already filled",e.OrderExpired="Order is expired",e.NoLiquidity="Token pair selected has insufficient liquidity",e.UnsupportedToken="One of the tokens you are trading is unsupported. Please read the FAQ for more info.",e.AmountIsZero="Amount is zero",e.SellAmountDoesNotCoverFee="Sell amount does not sufficiently cover the current fee",e.TransferEthToContract="Sending the native currency to smart contract wallets is not currently supported",e.UNHANDLED_GET_ERROR="Order fetch failed. This may be due to a server or network connectivity issue. Please try again later.",e.UNHANDLED_CREATE_ERROR="The order was not accepted by the network",e.UNHANDLED_DELETE_ERROR="The order cancellation was not accepted by the network"}(b||(b={}));class H extends h{static getErrorMessage(e,r){try{return Promise.resolve(function(r,t){try{var n=Promise.resolve(e.json()).then(function(e){return e.errorType?H.apiErrorDetails[e.errorType]||e.errorType:(u.default.error(m,"Unknown reason for bad order submission",e),e.description)})}catch(e){return t()}return n&&n.then?n.then(void 0,t):n}(0,function(){return u.default.error(m,"Error handling a 400 error. Likely a problem deserialising the JSON response"),function(e){switch(e){case"get":return b.UNHANDLED_GET_ERROR;case"create":return b.UNHANDLED_CREATE_ERROR;case"delete":return b.UNHANDLED_DELETE_ERROR;default:return u.default.error(m,"[OperatorError::_mapActionToErrorDetails] Uncaught error mapping error action type to server error. Please try again later."),"Something failed. Please try again later."}}(r)}))}catch(e){return Promise.reject(e)}}static getErrorFromStatusCode(e,r){try{const t=this;switch(e.status){case 400:case 404:return Promise.resolve(t.getErrorMessage(e,r));case 403:return Promise.resolve(`The order cannot be ${"create"===r?"accepted":"cancelled"}. Your account is deny-listed.`);case 429:return Promise.resolve(`The order cannot be ${"create"===r?"accepted. Too many order placements":"cancelled. Too many order cancellations"}. Please, retry in a minute`);default:return u.default.error(m,`[OperatorError::getErrorFromStatusCode] Error ${"create"===r?"creating":"cancelling"} the order, status code:`,e.status||"unknown"),Promise.resolve(`Error ${"create"===r?"creating":"cancelling"} the order`)}return Promise.resolve()}catch(e){return Promise.reject(e)}}constructor(e){super(e.description,e.errorType),this.name="OperatorError",this.description=void 0,this.description=e.description,this.message=b[e.errorType]}}H.apiErrorDetails=b,function(e){e.UnsupportedToken="UnsupportedToken",e.InsufficientLiquidity="InsufficientLiquidity",e.FeeExceedsFrom="FeeExceedsFrom",e.ZeroPrice="ZeroPrice",e.UNHANDLED_ERROR="UNHANDLED_ERROR"}(R||(R={})),function(e){e.UnsupportedToken="One of the tokens you are trading is unsupported. Please read the FAQ for more info.",e.InsufficientLiquidity="Token pair selected has insufficient liquidity",e.FeeExceedsFrom='Current fee exceeds entered "from" amount',e.ZeroPrice="Quoted price is zero. This is likely due to a significant price difference between the two tokens. Please try increasing amounts.",e.UNHANDLED_ERROR="Quote fetch failed. This may be due to a server or network connectivity issue. Please try again later."}(j||(j={}));class L extends h{static getErrorMessage(e){try{return Promise.resolve(function(r,t){try{var n=Promise.resolve(e.json()).then(function(e){return e.errorType?L.quoteErrorDetails[e.errorType]||e.errorType:(u.default.error(m,"Unknown reason for bad quote fetch",e),e.description)})}catch(e){return t()}return n&&n.then?n.then(void 0,t):n}(0,function(){return u.default.error(m,"Error handling 400/404 error. Likely a problem deserialising the JSON response"),L.quoteErrorDetails.UNHANDLED_ERROR}))}catch(e){return Promise.reject(e)}}static getErrorFromStatusCode(e){try{const r=this;switch(e.status){case 400:case 404:return Promise.resolve(r.getErrorMessage(e));default:return u.default.error(m,"[QuoteError::getErrorFromStatusCode] Error fetching quote, status code:",e.status||"unknown"),Promise.resolve("Error fetching quote")}return Promise.resolve()}catch(e){return Promise.reject(e)}}constructor(e){super(e.description,e.errorType),this.name="QuoteErrorObject",this.description=void 0,this.data=void 0,this.description=e.description,this.message=L.quoteErrorDetails[e.errorType],this.data=null==e?void 0:e.data}}L.quoteErrorDetails=j;class V{constructor(e,r){this.symbol=void 0,this.address=void 0,this.symbol=e,this.address=r}}const F={[exports.SupportedChainId.MAINNET]:new V("WETH","0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"),[exports.SupportedChainId.RINKEBY]:new V("WETH","0xc778417E063141139Fce010982780140Aa0cD5Ab"),[exports.SupportedChainId.GNOSIS_CHAIN]:new V("WXDAI","0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d")},B={[exports.SupportedChainId.MAINNET]:"ETH",[exports.SupportedChainId.RINKEBY]:"ETH",[exports.SupportedChainId.GNOSIS_CHAIN]:"XDAI"};function $(e,r){let t=e;return e===B[r]&&(t=F[r].address),t}function q(e,r){try{var t=e()}catch(e){return r(e)}return t&&t.then?t.then(void 0,r):t}const M=function(e,r){try{return e.ok?Promise.resolve(e.json()):Promise.resolve(e.json()).then(function(e){const t=function(e){switch(null==e?void 0:e.errorType){case U.NotFound:case U.NoLiquidity:return{errorType:R.InsufficientLiquidity,description:j.InsufficientLiquidity};case U.SellAmountDoesNotCoverFee:return{errorType:R.FeeExceedsFrom,description:j.FeeExceedsFrom,data:null==e?void 0:e.data};case U.UnsupportedToken:return{errorType:R.UnsupportedToken,description:e.description};case U.SellAmountDoesNotCoverFee:return{errorType:R.FeeExceedsFrom,description:e.description};default:return{errorType:R.UNHANDLED_ERROR,description:j.UNHANDLED_ERROR}}}(e),n=new L(t);if(r){const{sellToken:e,buyToken:t}=r;u.default.error(m,`Error querying fee from API - sellToken: ${e}, buyToken: ${t}`)}throw n})}catch(e){return Promise.reject(e)}},G={errorType:R.UNHANDLED_ERROR,description:j.UNHANDLED_ERROR},K={errorType:U.UNHANDLED_CREATE_ERROR,description:b.UNHANDLED_CREATE_ERROR};class Q{constructor(e){this.context=void 0,this.API_NAME="CoW Protocol",this.context=e}get DEFAULT_HEADERS(){return{"Content-Type":"application/json","X-AppId":this.context.appDataHash}}get API_BASE_URL(){return this.context.isDevEnvironment?{[exports.SupportedChainId.MAINNET]:"https://barn.api.cow.fi/mainnet/api",[exports.SupportedChainId.RINKEBY]:"https://barn.api.cow.fi/rinkeby/api",[exports.SupportedChainId.GNOSIS_CHAIN]:"https://barn.api.cow.fi/xdai/api"}:{[exports.SupportedChainId.MAINNET]:"https://api.cow.fi/mainnet/api",[exports.SupportedChainId.RINKEBY]:"https://api.cow.fi/rinkeby/api",[exports.SupportedChainId.GNOSIS_CHAIN]:"https://api.cow.fi/xdai/api"}}get PROFILE_API_BASE_URL(){return this.context.isDevEnvironment?{[exports.SupportedChainId.MAINNET]:"https://barn.api.cow.fi/affiliate/api"}:{[exports.SupportedChainId.MAINNET]:"https://api.cow.fi/affiliate/api"}}getProfileData(e){try{const r=this;return Promise.resolve(r.context.chainId).then(function(t){return u.default.debug(m,`[api:${r.API_NAME}] Get profile data for`,t,e),t!==exports.SupportedChainId.MAINNET?(u.default.info(m,"Profile data is only available for mainnet"),null):Promise.resolve(r.getProfile(`/profile/${e}`)).then(function(e){return e.ok?e.json():Promise.resolve(e.json()).then(function(e){throw u.default.error(m,e),new h(null==e?void 0:e.description)})})})}catch(e){return Promise.reject(e)}}getTrades(e){try{const r=this,{owner:t,limit:n,offset:o}=e,i=p({owner:t,limit:n,offset:o});return Promise.resolve(r.context.chainId).then(function(e){return u.default.debug(m,"[util:operator] Get trades for",e,t,{limit:n,offset:o}),q(function(){return Promise.resolve(r.get(`/trades${i}`)).then(function(e){return e.ok?e.json():Promise.resolve(e.json()).then(function(e){throw new H(e)})})},function(e){if(u.default.error(m,"Error getting trades:",e),e instanceof H)throw e;throw new h("Error getting trades: "+e)})})}catch(e){return Promise.reject(e)}}getOrders(e){try{const r=this,{owner:t,limit:n=1e3,offset:o=0}=e,i=p({limit:n,offset:o});return Promise.resolve(r.context.chainId).then(function(e){return u.default.debug(m,`[api:${r.API_NAME}] Get orders for `,e,t,n,o),q(function(){return Promise.resolve(r.get(`/account/${t}/orders/${i}`)).then(function(e){return e.ok?e.json():Promise.resolve(e.json()).then(function(e){throw new H(e)})})},function(e){if(u.default.error(m,"Error getting orders information:",e),e instanceof H)throw e;throw new H(K)})})}catch(e){return Promise.reject(e)}}getTxOrders(e){try{const r=this;return Promise.resolve(r.context.chainId).then(function(t){return u.default.debug(`[api:${r.API_NAME}] Get tx orders for `,t,e),q(function(){return Promise.resolve(r.get(`/transactions/${e}/orders`)).then(function(e){return e.ok?e.json():Promise.resolve(e.json()).then(function(e){throw new H(e)})})},function(e){if(u.default.error("Error getting transaction orders information:",e),e instanceof H)throw e;throw new H(K)})})}catch(e){return Promise.reject(e)}}getOrder(e){try{const r=this;return Promise.resolve(r.context.chainId).then(function(t){return u.default.debug(m,`[api:${r.API_NAME}] Get order for `,t,e),q(function(){return Promise.resolve(r.get(`/orders/${e}`)).then(function(e){return e.ok?e.json():Promise.resolve(e.json()).then(function(e){throw new H(e)})})},function(e){if(u.default.error(m,"Error getting order information:",e),e instanceof H)throw e;throw new H(K)})})}catch(e){return Promise.reject(e)}}getPriceQuoteLegacy(e){try{const r=this,{baseToken:t,quoteToken:n,amount:o,kind:i}=e;return Promise.resolve(r.context.chainId).then(function(s){return u.default.debug(m,`[api:${r.API_NAME}] Get price from API`,e,"for",s),Promise.resolve(r.get(`/markets/${$(t,s)}-${$(n,s)}/${i}/${o}`).catch(e=>{throw u.default.error(m,"Error getting price quote:",e),new L(G)})).then(M)})}catch(e){return Promise.reject(e)}}getQuote(e){try{const r=this;return Promise.resolve(r.context.chainId).then(function(t){const n=r.mapNewToLegacyParams(e,t);return Promise.resolve(r.post("/quote",n)).then(M)})}catch(e){return Promise.reject(e)}}sendSignedOrderCancellation(e){try{const r=this,{cancellation:t,owner:n}=e;return Promise.resolve(r.context.chainId).then(function(e){return u.default.debug(m,`[api:${r.API_NAME}] Delete signed order for network`,e,t),Promise.resolve(r.delete(`/orders/${t.orderUid}`,{signature:t.signature,signingScheme:_(t.signingScheme),from:n})).then(function(n){function o(n){u.default.debug(m,`[api:${r.API_NAME}] Cancelled order`,t.orderUid,e)}const i=function(){if(!n.ok)return Promise.resolve(H.getErrorFromStatusCode(n,"delete")).then(function(e){throw new h(e)})}();return i&&i.then?i.then(o):o()})})}catch(e){return Promise.reject(e)}}sendOrder(e){try{const r=this,t={...e.order,appData:r.context.appDataHash};return Promise.resolve(r.context.chainId).then(function(n){const{owner:o}=e;return u.default.debug(m,`[api:${r.API_NAME}] Post signed order for network`,n,t),Promise.resolve(r.post("/orders",{...t,signingScheme:_(t.signingScheme),from:o})).then(function(e){function t(t){return Promise.resolve(e.json()).then(function(e){return u.default.debug(m,`[api:${r.API_NAME}] Success posting the signed order`,e),e})}const n=function(){if(!e.ok)return Promise.resolve(H.getErrorFromStatusCode(e,"create")).then(function(e){throw new h(e)})}();return n&&n.then?n.then(t):t()})})}catch(e){return Promise.reject(e)}}getOrderLink(e){return this.getApiBaseUrl()+`/orders/${e}`}mapNewToLegacyParams(e,r){const{amount:n,kind:o,userAddress:i,receiver:s,validTo:a,sellToken:u,buyToken:c}=e,d=i||"0x0000000000000000000000000000000000000000",l={sellToken:$(u,r),buyToken:$(c,r),from:d,receiver:s||d,appData:this.context.appDataHash,validTo:a,partiallyFillable:!1};return o===t.OrderKind.SELL?{kind:t.OrderKind.SELL,sellAmountBeforeFee:n,...l}:{kind:t.OrderKind.BUY,buyAmountAfterFee:n,...l}}getApiBaseUrl(){try{const e=this;return Promise.resolve(e.context.chainId).then(function(r){const t=e.API_BASE_URL[r];if(t)return t+"/v1";throw new h(`Unsupported Network. The ${e.API_NAME} API is not deployed in the Network `+r)})}catch(e){return Promise.reject(e)}}getProfileApiBaseUrl(){try{const e=this;return Promise.resolve(e.context.chainId).then(function(r){const t=e.PROFILE_API_BASE_URL[r];if(t)return t+"/v1";throw new h(`Unsupported Network. The ${e.API_NAME} API is not deployed in the Network `+r)})}catch(e){return Promise.reject(e)}}fetch(e,r,t){try{const n=this;return Promise.resolve(n.getApiBaseUrl()).then(function(o){return c.default(o+e,{headers:n.DEFAULT_HEADERS,method:r,body:void 0!==t?JSON.stringify(t):t})})}catch(e){return Promise.reject(e)}}fetchProfile(e,r,t){try{const n=this;return Promise.resolve(n.getProfileApiBaseUrl()).then(function(o){return c.default(o+e,{headers:n.DEFAULT_HEADERS,method:r,body:void 0!==t?JSON.stringify(t):t})})}catch(e){return Promise.reject(e)}}post(e,r){return this.fetch(e,"POST",r)}get(e){return this.fetch(e,"GET")}getProfile(e){return this.fetchProfile(e,"GET")}delete(e,r){return this.fetch(e,"DELETE",r)}}const Y=o.gql`
|
|
2
2
|
query Totals {
|
|
3
3
|
totals {
|
|
4
4
|
tokens
|
|
@@ -25,5 +25,5 @@ var e=require("loglevel"),r=require("cross-fetch"),t=require("@gnosis.pm/gp-v2-c
|
|
|
25
25
|
volumeUsd
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
`,Z={[exports.SupportedChainId.MAINNET]:"https://api.thegraph.com/subgraphs/name/cowprotocol/cow",[exports.SupportedChainId.RINKEBY]:"https://api.thegraph.com/subgraphs/name/cowprotocol/cow-rinkeby",[exports.SupportedChainId.GNOSIS_CHAIN]:"https://api.thegraph.com/subgraphs/name/cowprotocol/cow-gc"};class z{constructor(e){this.context=void 0,this.clients=void 0,this.API_NAME="CoW Protocol Subgraph",this.context=e,this.clients=this.createClients()}createClients(){return{[exports.SupportedChainId.MAINNET]:new o.GraphQLClient(Z[exports.SupportedChainId.MAINNET],{fetch:c.default}),[exports.SupportedChainId.RINKEBY]:new o.GraphQLClient(Z[exports.SupportedChainId.RINKEBY],{fetch:c.default}),[exports.SupportedChainId.GNOSIS_CHAIN]:new o.GraphQLClient(Z[exports.SupportedChainId.GNOSIS_CHAIN],{fetch:c.default})}}getBaseUrl(){try{return Promise.resolve(this.context.chainId).then(function(e){return Z[e]})}catch(e){return Promise.reject(e)}}getTotals(){try{const e=this;return Promise.resolve(e.context.chainId).then(function(r){return u.default.debug(`[subgraph:${e.API_NAME}] Get totals for:`,r),Promise.resolve(e.runQuery(Y)).then(function(e){return e.totals[0]})})}catch(e){return Promise.reject(e)}}getLastDaysVolume(e){try{const r=this;return Promise.resolve(r.context.chainId).then(function(t){return u.default.debug(`[subgraph:${r.API_NAME}] Get last ${e} days volume for:`,t),r.runQuery(W,{days:e})})}catch(e){return Promise.reject(e)}}getLastHoursVolume(e){try{const r=this;return Promise.resolve(r.context.chainId).then(function(t){return u.default.debug(`[subgraph:${r.API_NAME}] Get last ${e} hours volume for:`,t),r.runQuery(J,{hours:e})})}catch(e){return Promise.reject(e)}}runQuery(e,r){try{const t=this;return Promise.resolve(function(n,o){try{var i=Promise.resolve(t.context.chainId).then(function(n){return Promise.resolve(t.clients[n].request(e,r))})}catch(e){return o(e)}return i&&i.then?i.then(void 0,o):i}(0,function(n){return u.default.error(n),Promise.resolve(t.getBaseUrl()).then(function(t){throw new h(`Error running query: ${e}. Variables: ${JSON.stringify(r)}. API: ${t}. Inner Error: ${n}`)})}))}catch(e){return Promise.reject(e)}}}const X=function(e){return Promise.resolve(re()).then(function({ajv:r,validate:t}){return{result:!!t(e),errors:r.errors?r.errorsText(r.errors):void 0}})},ee=function(e){try{const r=1,t=112,n=18,o=32,i=function(e){const r=e.match(/.{1,2}/g);if(r)return new Uint8Array(r.map(e=>parseInt(e,16)))}(e.replace(/(^0x)/,""));if(!i)return Promise.resolve();const s=Uint8Array.from([r,t,n,o,...i]);return Promise.resolve(Promise.resolve().then(function(){/*#__PURE__*/return a(require("multiformats/cid"))})).then(function({CID:e}){return e.decode(s).toV0().toString()})}catch(e){return Promise.reject(e)}},re=function(){try{function e(){return{ajv:ne,validate:te}}ne||(ne=new l.default);const r=function(){if(!te)return Promise.resolve(Promise.resolve().then(function(){return require("./appData.schema-412cbfbf.js")})).then(function(e){te=ne.compile(e)})}();return Promise.resolve(r&&r.then?r.then(e):e())}catch(t){return Promise.reject(t)}};let te,ne;function oe(e,r){try{var t=e()}catch(e){return r(e)}return t&&t.then?t.then(void 0,r):t}class ie{constructor(e){this.context=void 0,this.context=e}generateAppDataDoc(e={},r="CowSwap"){return{version:"0.2.0",appCode:r,metadata:{...e}}}decodeAppData(e){try{return Promise.resolve(oe(function(){return Promise.resolve(ee(e)).then(function(e){if(!e)throw new h("Error getting serialized CID");return function(e,r="https://gnosis.mypinata.cloud/ipfs"){try{return Promise.resolve(Promise.resolve().then(function(){/*#__PURE__*/return a(require("cross-fetch"))})).then(function({default:t}){return Promise.resolve(t(`${r}/${e}`)).then(function(e){return Promise.resolve(e.json())})})}catch(e){return Promise.reject(e)}}(e)})},function(e){const r=e;throw u.default.error("Error decoding AppData:",r),new h("Error decoding AppData: "+r.message)}))}catch(e){return Promise.reject(e)}}cidToAppDataHex(e){try{return Promise.resolve(Promise.resolve().then(function(){/*#__PURE__*/return a(require("multiformats/cid"))})).then(function({CID:r}){const{digest:t}=r.parse(e).multihash;return`0x${Buffer.from(t).toString("hex")}`})}catch(e){return Promise.reject(e)}}appDataHexToCid(e){try{return Promise.resolve(ee(e)).then(function(e){if(!e)throw new h("Error getting serialized CID");return e})}catch(e){return Promise.reject(e)}}calculateAppDataHash(e){try{const r=this;return Promise.resolve(X(e)).then(function(t){if(null==t||!t.result)throw new h("Invalid appData provided",null==t?void 0:t.errors);return oe(function(){return Promise.resolve(function(e){try{const r=JSON.stringify(e);return Promise.resolve(Promise.resolve().then(function(){/*#__PURE__*/return a(require("ipfs-only-hash"))})).then(function({of:e}){return e(r,{cidVersion:0})})}catch(e){return Promise.reject(e)}}(e)).then(function(e){return Promise.resolve(r.cidToAppDataHex(e)).then(function(r){if(!r)throw new h(`Could not extract appDataHash from calculated cidV0 ${e}`);return{cidV0:e,appDataHash:r}})})},function(e){throw new h("Failed to calculate appDataHash",e.message)})})}catch(e){return Promise.reject(e)}}uploadMetadataDocToIpfs(e){try{const r=this;return Promise.resolve(function(e,{uri:r,pinataApiKey:t="",pinataApiSecret:n=""}){try{return Promise.resolve(Promise.resolve().then(function(){/*#__PURE__*/return a(require("cross-fetch"))})).then(function({default:o}){if(!t||!n)throw new h("You need to pass IPFS api credentials.");const i=JSON.stringify({pinataContent:e,pinataMetadata:{name:"appData-affiliate"}});return Promise.resolve(o(`${r}/pinning/pinJSONToIPFS`,{method:"POST",body:i,headers:{"Content-Type":"application/json",pinata_api_key:t,pinata_secret_api_key:n}})).then(function(e){return Promise.resolve(e.json()).then(function(r){if(200!==e.status)throw new Error(r.error.details||r.error);return r})})})}catch(e){return Promise.reject(e)}}(e,r.context.ipfs)).then(function({IpfsHash:e}){return r.cidToAppDataHex(e)})}catch(e){return Promise.reject(e)}}}var se=0;function ae(e){return"__private_"+se+++"_"+e}function ue(e,r){if(!Object.prototype.hasOwnProperty.call(e,r))throw new TypeError("attempted to use private field on non-instance");return e}const ce={appDataHash:"0x0000000000000000000000000000000000000000000000000000000000000000",isDevEnvironment:!1,ipfs:{uri:"https://gnosis.mypinata.cloud/ipfs",apiKey:void 0,apiSecret:void 0}};var de,le,he,pe,me,fe,ge,Te,ve,Ee,Pe,ye,Ie,Ae,we,Ne,Se,ke,De=/*#__PURE__*/ae("context"),Oe=/*#__PURE__*/ae("chainId");class _e{constructor(e,r){Object.defineProperty(this,De,{writable:!0,value:void 0}),Object.defineProperty(this,Oe,{writable:!0,value:void 0}),ue(this,Oe)[Oe]=this.updateChainId(e),ue(this,De)[De]={...ce,...r}}updateChainId(e){if(!exports.SupportedChainId[e])throw new h(`Invalid chainId: ${e}`);return u.default.debug(m,`Updating chainId to: ${e}`),ue(this,Oe)[Oe]=e,e}get chainId(){const e=this;var r;const t=null==(r=ue(this,De)[De].signer)?void 0:r.provider;return t?(u.default.debug(m,"Getting chainId from provider"),function(){try{return Promise.resolve(t.getNetwork()).then(function(r){const t=r.chainId;return t!==ue(e,Oe)[Oe]&&(u.default.debug(m,`ChainId mismatch: Provider's chainId: ${t} vs Context's chainId: ${ue(e,Oe)[Oe]}. Updating Context's chainId`),e.updateChainId(t)),t})}catch(e){return Promise.reject(e)}}()):Promise.resolve(ue(this,Oe)[Oe])}get appDataHash(){var e;return null!==(e=ue(this,De)[De].appDataHash)&&void 0!==e?e:ce.appDataHash}get isDevEnvironment(){var e;return null!==(e=ue(this,De)[De].isDevEnvironment)&&void 0!==e?e:ce.isDevEnvironment}get signer(){return ue(this,De)[De].signer}get ipfs(){var e;return null!==(e=ue(this,De)[De].ipfs)&&void 0!==e?e:ce.ipfs}}!function(e){e.EthPriceUsd="ethPriceUSD",e.Id="id"}(de||(de={})),function(e){e.FeesEth="feesEth",e.FeesUsd="feesUsd",e.Id="id",e.NumberOfTrades="numberOfTrades",e.Orders="orders",e.Settlements="settlements",e.Timestamp="timestamp",e.Tokens="tokens",e.TotalTokens="totalTokens",e.VolumeEth="volumeEth",e.VolumeUsd="volumeUsd"}(le||(le={})),function(e){e.FeesEth="feesEth",e.FeesUsd="feesUsd",e.Id="id",e.NumberOfTrades="numberOfTrades",e.Orders="orders",e.Settlements="settlements",e.Timestamp="timestamp",e.Tokens="tokens",e.TotalTokens="totalTokens",e.VolumeEth="volumeEth",e.VolumeUsd="volumeUsd"}(he||(he={})),function(e){e.Asc="asc",e.Desc="desc"}(pe||(pe={})),function(e){e.Id="id",e.InvalidateTimestamp="invalidateTimestamp",e.IsSigned="isSigned",e.IsValid="isValid",e.Owner="owner",e.PresignTimestamp="presignTimestamp",e.Trades="trades",e.TradesTimestamp="tradesTimestamp"}(me||(me={})),function(e){e.Id="id",e.Timestamp="timestamp",e.Token0="token0",e.Token1="token1",e.VolumeToken0="volumeToken0",e.VolumeToken1="volumeToken1",e.VolumeTradedEth="volumeTradedEth",e.VolumeTradedUsd="volumeTradedUsd"}(fe||(fe={})),function(e){e.Id="id",e.Timestamp="timestamp",e.Token0="token0",e.Token1="token1",e.VolumeToken0="volumeToken0",e.VolumeToken1="volumeToken1",e.VolumeTradedEth="volumeTradedEth",e.VolumeTradedUsd="volumeTradedUsd"}(ge||(ge={})),function(e){e.Id="id",e.Token0="token0",e.Token1="token1",e.VolumeToken0="volumeToken0",e.VolumeToken1="volumeToken1",e.VolumeTradedEth="volumeTradedEth",e.VolumeTradedUsd="volumeTradedUsd"}(Te||(Te={})),function(e){e.FirstTradeTimestamp="firstTradeTimestamp",e.Id="id",e.Solver="solver",e.Trades="trades",e.TxHash="txHash"}(ve||(ve={})),function(e){e.AveragePrice="averagePrice",e.ClosePrice="closePrice",e.HigherPrice="higherPrice",e.Id="id",e.LowerPrice="lowerPrice",e.OpenPrice="openPrice",e.Timestamp="timestamp",e.Token="token",e.TotalTrades="totalTrades",e.TotalVolume="totalVolume",e.TotalVolumeEth="totalVolumeEth",e.TotalVolumeUsd="totalVolumeUsd"}(Ee||(Ee={})),function(e){e.AveragePrice="averagePrice",e.ClosePrice="closePrice",e.HigherPrice="higherPrice",e.Id="id",e.LowerPrice="lowerPrice",e.OpenPrice="openPrice",e.Timestamp="timestamp",e.Token="token",e.TotalTrades="totalTrades",e.TotalVolume="totalVolume",e.TotalVolumeEth="totalVolumeEth",e.TotalVolumeUsd="totalVolumeUsd"}(Pe||(Pe={})),function(e){e.AmountEth="amountEth",e.AmountUsd="amountUsd",e.Id="id",e.Timestamp="timestamp",e.Token="token",e.Trade="trade"}(ye||(ye={})),function(e){e.Address="address",e.AllowedPools="allowedPools",e.Decimals="decimals",e.FirstTradeTimestamp="firstTradeTimestamp",e.History="history",e.Id="id",e.Name="name",e.NumberOfTrades="numberOfTrades",e.PriceEth="priceEth",e.PriceUsd="priceUsd",e.Symbol="symbol",e.TotalVolume="totalVolume",e.TotalVolumeEth="totalVolumeEth",e.TotalVolumeUsd="totalVolumeUsd"}(Ie||(Ie={})),function(e){e.FeesEth="feesEth",e.FeesUsd="feesUsd",e.Id="id",e.NumberOfTrades="numberOfTrades",e.Orders="orders",e.Settlements="settlements",e.Tokens="tokens",e.Traders="traders",e.VolumeEth="volumeEth",e.VolumeUsd="volumeUsd"}(Ae||(Ae={})),function(e){e.BuyAmount="buyAmount",e.BuyAmountEth="buyAmountEth",e.BuyAmountUsd="buyAmountUsd",e.BuyToken="buyToken",e.FeeAmount="feeAmount",e.GasPrice="gasPrice",e.Id="id",e.Order="order",e.SellAmount="sellAmount",e.SellAmountEth="sellAmountEth",e.SellAmountUsd="sellAmountUsd",e.SellToken="sellToken",e.Settlement="settlement",e.Timestamp="timestamp",e.TxHash="txHash"}(we||(we={})),function(e){e.Id="id",e.Liquidity="liquidity",e.Tick="tick",e.Token0="token0",e.Token0Price="token0Price",e.Token1="token1",e.Token1Price="token1Price",e.TotalValueLockedToken0="totalValueLockedToken0",e.TotalValueLockedToken1="totalValueLockedToken1"}(Ne||(Ne={})),function(e){e.Address="address",e.FirstTradeTimestamp="firstTradeTimestamp",e.Id="id",e.IsSolver="isSolver",e.NumberOfTrades="numberOfTrades",e.OrdersPlaced="ordersPlaced",e.SolvedAmountEth="solvedAmountEth",e.SolvedAmountUsd="solvedAmountUsd",e.TradedAmountEth="tradedAmountEth",e.TradedAmountUsd="tradedAmountUsd"}(Se||(Se={})),function(e){e.Allow="allow",e.Deny="deny"}(ke||(ke={}));var xe={__proto__:null,get Bundle_OrderBy(){return de},get DailyTotal_OrderBy(){return le},get HourlyTotal_OrderBy(){return he},get OrderDirection(){return pe},get Order_OrderBy(){return me},get PairDaily_OrderBy(){return fe},get PairHourly_OrderBy(){return ge},get Pair_OrderBy(){return Te},get Settlement_OrderBy(){return ve},get TokenDailyTotal_OrderBy(){return Ee},get TokenHourlyTotal_OrderBy(){return Pe},get TokenTradingEvent_OrderBy(){return ye},get Token_OrderBy(){return Ie},get Total_OrderBy(){return Ae},get Trade_OrderBy(){return we},get UniswapPool_OrderBy(){return Ne},get User_OrderBy(){return Se},get _SubgraphErrorPolicy_(){return ke}};Object.defineProperty(exports,"OrderKind",{enumerable:!0,get:function(){return t.OrderKind}}),exports.ALL_SUPPORTED_CHAIN_IDS=g,exports.CowError=h,exports.CowSdk=class{constructor(e,r={},t={}){this.context=void 0,this.cowApi=void 0,this.metadataApi=void 0,this.cowSubgraphApi=void 0,this.updateChainId=e=>{this.context.updateChainId(e)},this.validateAppDataDocument=X,this.context=new _e(e,{...r}),this.cowApi=new Q(this.context),this.cowSubgraphApi=new z(this.context),this.metadataApi=new ie(this.context),u.default.setLevel(t.loglevel||"error")}signOrder(e){try{const r=this,t=r._checkSigner();return Promise.resolve(r.context.chainId).then(function(n){return function(e,r,t){return E({order:e,chainId:r},y,t)}({...e,appData:r.context.appDataHash},n,t)})}catch(e){return Promise.reject(e)}}signOrderCancellation(e){try{const r=this,t=r._checkSigner();return Promise.resolve(r.context.chainId).then(function(r){return function(e,r,t){return E({orderId:e,chainId:r},P,t)}(e,r,t)})}catch(e){return Promise.reject(e)}}_checkSigner(e=this.context.signer){if(!e)throw new h("No signer available");return e}},exports.GraphQL=xe,exports.Token=V;
|
|
28
|
+
`,Z={[exports.SupportedChainId.MAINNET]:"https://api.thegraph.com/subgraphs/name/cowprotocol/cow",[exports.SupportedChainId.RINKEBY]:"https://api.thegraph.com/subgraphs/name/cowprotocol/cow-rinkeby",[exports.SupportedChainId.GNOSIS_CHAIN]:"https://api.thegraph.com/subgraphs/name/cowprotocol/cow-gc"};class z{constructor(e){this.context=void 0,this.clients=void 0,this.API_NAME="CoW Protocol Subgraph",this.context=e,this.clients=this.createClients()}createClients(){return{[exports.SupportedChainId.MAINNET]:new o.GraphQLClient(Z[exports.SupportedChainId.MAINNET],{fetch:c.default}),[exports.SupportedChainId.RINKEBY]:new o.GraphQLClient(Z[exports.SupportedChainId.RINKEBY],{fetch:c.default}),[exports.SupportedChainId.GNOSIS_CHAIN]:new o.GraphQLClient(Z[exports.SupportedChainId.GNOSIS_CHAIN],{fetch:c.default})}}getBaseUrl(){try{return Promise.resolve(this.context.chainId).then(function(e){return Z[e]})}catch(e){return Promise.reject(e)}}getTotals(){try{const e=this;return Promise.resolve(e.context.chainId).then(function(r){return u.default.debug(`[subgraph:${e.API_NAME}] Get totals for:`,r),Promise.resolve(e.runQuery(Y)).then(function(e){return e.totals[0]})})}catch(e){return Promise.reject(e)}}getLastDaysVolume(e){try{const r=this;return Promise.resolve(r.context.chainId).then(function(t){return u.default.debug(`[subgraph:${r.API_NAME}] Get last ${e} days volume for:`,t),r.runQuery(W,{days:e})})}catch(e){return Promise.reject(e)}}getLastHoursVolume(e){try{const r=this;return Promise.resolve(r.context.chainId).then(function(t){return u.default.debug(`[subgraph:${r.API_NAME}] Get last ${e} hours volume for:`,t),r.runQuery(J,{hours:e})})}catch(e){return Promise.reject(e)}}runQuery(e,r){try{const t=this;return Promise.resolve(function(n,o){try{var i=Promise.resolve(t.context.chainId).then(function(n){return Promise.resolve(t.clients[n].request(e,r))})}catch(e){return o(e)}return i&&i.then?i.then(void 0,o):i}(0,function(n){return u.default.error(n),Promise.resolve(t.getBaseUrl()).then(function(t){throw new h(`Error running query: ${e}. Variables: ${JSON.stringify(r)}. API: ${t}. Inner Error: ${n}`)})}))}catch(e){return Promise.reject(e)}}}const X=function(e){return Promise.resolve(re()).then(function({ajv:r,validate:t}){return{result:!!t(e),errors:r.errors?r.errorsText(r.errors):void 0}})},ee=function(e){try{const r=1,t=112,n=18,o=32,i=function(e){const r=e.match(/.{1,2}/g);if(r)return new Uint8Array(r.map(e=>parseInt(e,16)))}(e.replace(/(^0x)/,""));if(!i)return Promise.resolve();const s=Uint8Array.from([r,t,n,o,...i]);return Promise.resolve(Promise.resolve().then(function(){/*#__PURE__*/return a(require("multiformats/cid"))})).then(function({CID:e}){return e.decode(s).toV0().toString()})}catch(e){return Promise.reject(e)}},re=function(){try{function e(){return{ajv:ne,validate:te}}ne||(ne=new l.default);const r=function(){if(!te)return Promise.resolve(Promise.resolve().then(function(){return require("./appData.schema-4c010c50.js")})).then(function(e){te=ne.compile(e)})}();return Promise.resolve(r&&r.then?r.then(e):e())}catch(t){return Promise.reject(t)}};let te,ne;function oe(e,r){try{var t=e()}catch(e){return r(e)}return t&&t.then?t.then(void 0,r):t}const ie="CowSwap";class se{constructor(e){this.context=void 0,this.context=e}generateAppDataDoc(e={},r){const{appCode:t=ie,environment:n}=r||{};return{version:"0.3.0",appCode:t,environment:n,metadata:{...e}}}decodeAppData(e){try{return Promise.resolve(oe(function(){return Promise.resolve(ee(e)).then(function(e){if(!e)throw new h("Error getting serialized CID");return function(e,r="https://gnosis.mypinata.cloud/ipfs"){try{return Promise.resolve(Promise.resolve().then(function(){/*#__PURE__*/return a(require("cross-fetch"))})).then(function({default:t}){return Promise.resolve(t(`${r}/${e}`)).then(function(e){return Promise.resolve(e.json())})})}catch(e){return Promise.reject(e)}}(e)})},function(e){const r=e;throw u.default.error("Error decoding AppData:",r),new h("Error decoding AppData: "+r.message)}))}catch(e){return Promise.reject(e)}}cidToAppDataHex(e){try{return Promise.resolve(Promise.resolve().then(function(){/*#__PURE__*/return a(require("multiformats/cid"))})).then(function({CID:r}){const{digest:t}=r.parse(e).multihash;return`0x${Buffer.from(t).toString("hex")}`})}catch(e){return Promise.reject(e)}}appDataHexToCid(e){try{return Promise.resolve(ee(e)).then(function(e){if(!e)throw new h("Error getting serialized CID");return e})}catch(e){return Promise.reject(e)}}calculateAppDataHash(e){try{const r=this;return Promise.resolve(X(e)).then(function(t){if(null==t||!t.result)throw new h("Invalid appData provided",null==t?void 0:t.errors);return oe(function(){return Promise.resolve(function(e){try{const r=JSON.stringify(e);return Promise.resolve(Promise.resolve().then(function(){/*#__PURE__*/return a(require("ipfs-only-hash"))})).then(function({of:e}){return e(r,{cidVersion:0})})}catch(e){return Promise.reject(e)}}(e)).then(function(e){return Promise.resolve(r.cidToAppDataHex(e)).then(function(r){if(!r)throw new h(`Could not extract appDataHash from calculated cidV0 ${e}`);return{cidV0:e,appDataHash:r}})})},function(e){throw new h("Failed to calculate appDataHash",e.message)})})}catch(e){return Promise.reject(e)}}uploadMetadataDocToIpfs(e){try{const r=this;return Promise.resolve(function(e,{writeUri:r="https://api.pinata.cloud",pinataApiKey:t="",pinataApiSecret:n=""}){try{return Promise.resolve(Promise.resolve().then(function(){/*#__PURE__*/return a(require("cross-fetch"))})).then(function({default:o}){if(!t||!n)throw new h("You need to pass IPFS api credentials.");const i=JSON.stringify({pinataContent:e,pinataMetadata:{name:"appData"}});return Promise.resolve(o(`${r}/pinning/pinJSONToIPFS`,{method:"POST",body:i,headers:{"Content-Type":"application/json",pinata_api_key:t,pinata_secret_api_key:n}})).then(function(e){return Promise.resolve(e.json()).then(function(r){if(200!==e.status)throw new Error(r.error.details||r.error);return r})})})}catch(e){return Promise.reject(e)}}(e,r.context.ipfs)).then(function({IpfsHash:e}){return r.cidToAppDataHex(e)})}catch(e){return Promise.reject(e)}}}var ae=0;function ue(e){return"__private_"+ae+++"_"+e}function ce(e,r){if(!Object.prototype.hasOwnProperty.call(e,r))throw new TypeError("attempted to use private field on non-instance");return e}const de={appDataHash:"0x0000000000000000000000000000000000000000000000000000000000000000",isDevEnvironment:!1,ipfs:{readUri:"https://gnosis.mypinata.cloud/ipfs",writeUri:"https://api.pinata.cloud",apiKey:void 0,apiSecret:void 0}};var le,he,pe,me,fe,ge,Te,ve,Ee,Pe,ye,Ie,Ae,we,Ne,Se,ke,De,Oe,_e=/*#__PURE__*/ue("context"),xe=/*#__PURE__*/ue("chainId");class Ce{constructor(e,r){Object.defineProperty(this,_e,{writable:!0,value:void 0}),Object.defineProperty(this,xe,{writable:!0,value:void 0}),ce(this,xe)[xe]=this.updateChainId(e),ce(this,_e)[_e]={...de,...r,ipfs:{...de.ipfs,...r.ipfs}}}updateChainId(e){if(!exports.SupportedChainId[e])throw new h(`Invalid chainId: ${e}`);return u.default.debug(m,`Updating chainId to: ${e}`),ce(this,xe)[xe]=e,e}get chainId(){const e=this;var r;const t=null==(r=ce(this,_e)[_e].signer)?void 0:r.provider;return t?(u.default.debug(m,"Getting chainId from provider"),function(){try{return Promise.resolve(t.getNetwork()).then(function(r){const t=r.chainId;return t!==ce(e,xe)[xe]&&(u.default.debug(m,`ChainId mismatch: Provider's chainId: ${t} vs Context's chainId: ${ce(e,xe)[xe]}. Updating Context's chainId`),e.updateChainId(t)),t})}catch(e){return Promise.reject(e)}}()):Promise.resolve(ce(this,xe)[xe])}get appDataHash(){var e;return null!==(e=ce(this,_e)[_e].appDataHash)&&void 0!==e?e:de.appDataHash}get isDevEnvironment(){var e;return null!==(e=ce(this,_e)[_e].isDevEnvironment)&&void 0!==e?e:de.isDevEnvironment}get signer(){return ce(this,_e)[_e].signer}get ipfs(){var e;return null!==(e=ce(this,_e)[_e].ipfs)&&void 0!==e?e:de.ipfs}}!function(e){e.EthPriceUsd="ethPriceUSD",e.Id="id"}(le||(le={})),function(e){e.FeesEth="feesEth",e.FeesUsd="feesUsd",e.Id="id",e.NumberOfTrades="numberOfTrades",e.Orders="orders",e.Settlements="settlements",e.Timestamp="timestamp",e.Tokens="tokens",e.TotalTokens="totalTokens",e.VolumeEth="volumeEth",e.VolumeUsd="volumeUsd"}(he||(he={})),function(e){e.FeesEth="feesEth",e.FeesUsd="feesUsd",e.Id="id",e.NumberOfTrades="numberOfTrades",e.Orders="orders",e.Settlements="settlements",e.Timestamp="timestamp",e.Tokens="tokens",e.TotalTokens="totalTokens",e.VolumeEth="volumeEth",e.VolumeUsd="volumeUsd"}(pe||(pe={})),function(e){e.Asc="asc",e.Desc="desc"}(me||(me={})),function(e){e.Id="id",e.InvalidateTimestamp="invalidateTimestamp",e.IsSigned="isSigned",e.IsValid="isValid",e.Owner="owner",e.PresignTimestamp="presignTimestamp",e.Trades="trades",e.TradesTimestamp="tradesTimestamp"}(fe||(fe={})),function(e){e.Id="id",e.Timestamp="timestamp",e.Token0="token0",e.Token1="token1",e.VolumeToken0="volumeToken0",e.VolumeToken1="volumeToken1",e.VolumeTradedEth="volumeTradedEth",e.VolumeTradedUsd="volumeTradedUsd"}(ge||(ge={})),function(e){e.Id="id",e.Timestamp="timestamp",e.Token0="token0",e.Token1="token1",e.VolumeToken0="volumeToken0",e.VolumeToken1="volumeToken1",e.VolumeTradedEth="volumeTradedEth",e.VolumeTradedUsd="volumeTradedUsd"}(Te||(Te={})),function(e){e.Id="id",e.Token0="token0",e.Token1="token1",e.VolumeToken0="volumeToken0",e.VolumeToken1="volumeToken1",e.VolumeTradedEth="volumeTradedEth",e.VolumeTradedUsd="volumeTradedUsd"}(ve||(ve={})),function(e){e.FirstTradeTimestamp="firstTradeTimestamp",e.Id="id",e.Solver="solver",e.Trades="trades",e.TxHash="txHash"}(Ee||(Ee={})),function(e){e.AveragePrice="averagePrice",e.ClosePrice="closePrice",e.HigherPrice="higherPrice",e.Id="id",e.LowerPrice="lowerPrice",e.OpenPrice="openPrice",e.Timestamp="timestamp",e.Token="token",e.TotalTrades="totalTrades",e.TotalVolume="totalVolume",e.TotalVolumeEth="totalVolumeEth",e.TotalVolumeUsd="totalVolumeUsd"}(Pe||(Pe={})),function(e){e.AveragePrice="averagePrice",e.ClosePrice="closePrice",e.HigherPrice="higherPrice",e.Id="id",e.LowerPrice="lowerPrice",e.OpenPrice="openPrice",e.Timestamp="timestamp",e.Token="token",e.TotalTrades="totalTrades",e.TotalVolume="totalVolume",e.TotalVolumeEth="totalVolumeEth",e.TotalVolumeUsd="totalVolumeUsd"}(ye||(ye={})),function(e){e.AmountEth="amountEth",e.AmountUsd="amountUsd",e.Id="id",e.Timestamp="timestamp",e.Token="token",e.Trade="trade"}(Ie||(Ie={})),function(e){e.Address="address",e.Decimals="decimals",e.FirstTradeTimestamp="firstTradeTimestamp",e.History="history",e.Id="id",e.Name="name",e.NumberOfTrades="numberOfTrades",e.PriceEth="priceEth",e.PriceUsd="priceUsd",e.Symbol="symbol",e.TotalVolume="totalVolume",e.TotalVolumeEth="totalVolumeEth",e.TotalVolumeUsd="totalVolumeUsd"}(Ae||(Ae={})),function(e){e.FeesEth="feesEth",e.FeesUsd="feesUsd",e.Id="id",e.NumberOfTrades="numberOfTrades",e.Orders="orders",e.Settlements="settlements",e.Tokens="tokens",e.Traders="traders",e.VolumeEth="volumeEth",e.VolumeUsd="volumeUsd"}(we||(we={})),function(e){e.BuyAmount="buyAmount",e.BuyAmountEth="buyAmountEth",e.BuyAmountUsd="buyAmountUsd",e.BuyToken="buyToken",e.FeeAmount="feeAmount",e.GasPrice="gasPrice",e.Id="id",e.Order="order",e.SellAmount="sellAmount",e.SellAmountEth="sellAmountEth",e.SellAmountUsd="sellAmountUsd",e.SellToken="sellToken",e.Settlement="settlement",e.Timestamp="timestamp",e.TxHash="txHash"}(Ne||(Ne={})),function(e){e.Id="id",e.Liquidity="liquidity",e.Tick="tick",e.Token0="token0",e.Token0Price="token0Price",e.Token1="token1",e.Token1Price="token1Price",e.TotalValueLockedToken0="totalValueLockedToken0",e.TotalValueLockedToken1="totalValueLockedToken1"}(Se||(Se={})),function(e){e.Address="address",e.AllowedPools="allowedPools",e.Decimals="decimals",e.Id="id",e.Name="name",e.PriceEth="priceEth",e.PriceUsd="priceUsd",e.Symbol="symbol"}(ke||(ke={})),function(e){e.Address="address",e.FirstTradeTimestamp="firstTradeTimestamp",e.Id="id",e.IsSolver="isSolver",e.NumberOfTrades="numberOfTrades",e.OrdersPlaced="ordersPlaced",e.SolvedAmountEth="solvedAmountEth",e.SolvedAmountUsd="solvedAmountUsd",e.TradedAmountEth="tradedAmountEth",e.TradedAmountUsd="tradedAmountUsd"}(De||(De={})),function(e){e.Allow="allow",e.Deny="deny"}(Oe||(Oe={}));var Ue={__proto__:null,get Bundle_OrderBy(){return le},get DailyTotal_OrderBy(){return he},get HourlyTotal_OrderBy(){return pe},get OrderDirection(){return me},get Order_OrderBy(){return fe},get PairDaily_OrderBy(){return ge},get PairHourly_OrderBy(){return Te},get Pair_OrderBy(){return ve},get Settlement_OrderBy(){return Ee},get TokenDailyTotal_OrderBy(){return Pe},get TokenHourlyTotal_OrderBy(){return ye},get TokenTradingEvent_OrderBy(){return Ie},get Token_OrderBy(){return Ae},get Total_OrderBy(){return we},get Trade_OrderBy(){return Ne},get UniswapPool_OrderBy(){return Se},get UniswapToken_OrderBy(){return ke},get User_OrderBy(){return De},get _SubgraphErrorPolicy_(){return Oe}};Object.defineProperty(exports,"OrderKind",{enumerable:!0,get:function(){return t.OrderKind}}),exports.ALL_SUPPORTED_CHAIN_IDS=g,exports.CowError=h,exports.CowSdk=class{constructor(e,r={},t={}){this.context=void 0,this.cowApi=void 0,this.metadataApi=void 0,this.cowSubgraphApi=void 0,this.updateChainId=e=>{this.context.updateChainId(e)},this.validateAppDataDocument=X,this.context=new Ce(e,{...r}),this.cowApi=new Q(this.context),this.cowSubgraphApi=new z(this.context),this.metadataApi=new se(this.context),u.default.setLevel(t.loglevel||"error")}signOrder(e){try{const r=this,t=r._checkSigner();return Promise.resolve(r.context.chainId).then(function(n){return function(e,r,t){return E({order:e,chainId:r},y,t)}({...e,appData:r.context.appDataHash},n,t)})}catch(e){return Promise.reject(e)}}signOrderCancellation(e){try{const r=this,t=r._checkSigner();return Promise.resolve(r.context.chainId).then(function(r){return function(e,r,t){return E({orderId:e,chainId:r},P,t)}(e,r,t)})}catch(e){return Promise.reject(e)}}_checkSigner(e=this.context.signer){if(!e)throw new h("No signer available");return e}},exports.GraphQL=Ue,exports.Token=V;
|
|
29
29
|
//# sourceMappingURL=index.js.map
|