@cowprotocol/cow-sdk 0.0.15 → 1.0.0-RC.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +247 -103
- package/dist/CowSdk.d.ts +4 -0
- package/dist/api/0x/error/index.d.ts +21 -0
- package/dist/api/0x/index.d.ts +11 -0
- package/dist/api/0x/utils.d.ts +17 -0
- package/dist/api/base/index.d.ts +25 -0
- package/dist/api/cow/index.d.ts +4 -16
- package/dist/api/cow/types.d.ts +4 -1
- package/dist/api/cow-subgraph/graphql.d.ts +24 -2
- package/dist/api/metadata/index.d.ts +11 -5
- package/dist/api/metadata/types.d.ts +8 -21
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +4 -4
- package/dist/index.modern.js.map +1 -1
- package/dist/index.module.js +4 -4
- package/dist/index.module.js.map +1 -1
- package/dist/utils/appData.d.ts +3 -3
- package/dist/utils/context.d.ts +5 -9
- package/dist/utils/ipfs.d.ts +2 -2
- package/dist/utils/market.d.ts +16 -0
- package/package.json +2 -1
- package/dist/appData.schema-42d10730.js +0 -2
- package/dist/appData.schema-42d10730.js.map +0 -1
- package/dist/appData.schema-b8f018d7.js +0 -2
- package/dist/appData.schema-b8f018d7.js.map +0 -1
package/dist/utils/appData.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AnyAppDataDocVersion } from '../types';
|
|
2
2
|
interface ValidationResult {
|
|
3
3
|
result: boolean;
|
|
4
4
|
errors?: string;
|
|
5
5
|
}
|
|
6
6
|
export declare function getSerializedCID(hash: string): Promise<void | string>;
|
|
7
|
-
export declare function loadIpfsFromCid(cid: string, ipfsUri?: string): Promise<
|
|
8
|
-
export declare function validateAppDataDocument(appDataDocument: unknown): Promise<ValidationResult>;
|
|
7
|
+
export declare function loadIpfsFromCid(cid: string, ipfsUri?: string): Promise<AnyAppDataDocVersion>;
|
|
8
|
+
export declare function validateAppDataDocument(appDataDocument: unknown, version: string): Promise<ValidationResult>;
|
|
9
9
|
export {};
|
package/dist/utils/context.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Signer } from 'ethers';
|
|
2
2
|
import { SupportedChainId as ChainId } from '../constants/chains';
|
|
3
|
+
export declare type Env = 'prod' | 'staging';
|
|
3
4
|
export interface Ipfs {
|
|
4
5
|
uri?: string;
|
|
5
6
|
writeUri?: string;
|
|
@@ -9,19 +10,14 @@ export interface Ipfs {
|
|
|
9
10
|
}
|
|
10
11
|
export interface CowContext {
|
|
11
12
|
appDataHash?: string;
|
|
12
|
-
|
|
13
|
+
env?: Env;
|
|
13
14
|
signer?: Signer;
|
|
14
15
|
ipfs?: Ipfs;
|
|
15
16
|
}
|
|
16
17
|
export declare const DefaultCowContext: {
|
|
17
18
|
appDataHash: string;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
readUri: string;
|
|
21
|
-
writeUri: string;
|
|
22
|
-
apiKey: undefined;
|
|
23
|
-
apiSecret: undefined;
|
|
24
|
-
};
|
|
19
|
+
ipfs: Ipfs;
|
|
20
|
+
env: Env;
|
|
25
21
|
};
|
|
26
22
|
/**
|
|
27
23
|
*
|
|
@@ -38,7 +34,7 @@ export declare class Context implements Partial<CowContext> {
|
|
|
38
34
|
updateChainId(chainId: ChainId): ChainId;
|
|
39
35
|
get chainId(): Promise<ChainId>;
|
|
40
36
|
get appDataHash(): string;
|
|
41
|
-
get
|
|
37
|
+
get env(): Env;
|
|
42
38
|
get signer(): Signer | undefined;
|
|
43
39
|
get ipfs(): Ipfs;
|
|
44
40
|
}
|
package/dist/utils/ipfs.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Ipfs } from './context';
|
|
2
|
-
import {
|
|
2
|
+
import { AnyAppDataDocVersion } from '../api/metadata/types';
|
|
3
3
|
declare type PinataPinResponse = {
|
|
4
4
|
IpfsHash: string;
|
|
5
5
|
PinSize: number;
|
|
6
6
|
Timestamp: string;
|
|
7
7
|
};
|
|
8
8
|
export declare function pinJSONToIPFS(file: unknown, { writeUri, pinataApiKey, pinataApiSecret }: Ipfs): Promise<PinataPinResponse>;
|
|
9
|
-
export declare function calculateIpfsCidV0(doc:
|
|
9
|
+
export declare function calculateIpfsCidV0(doc: AnyAppDataDocVersion): Promise<string>;
|
|
10
10
|
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { OrderKind } from '@cowprotocol/contracts';
|
|
2
|
+
interface Market<T = string> {
|
|
3
|
+
baseToken: T;
|
|
4
|
+
quoteToken: T;
|
|
5
|
+
}
|
|
6
|
+
export interface CanonicalMarketParams<T> {
|
|
7
|
+
sellToken: T;
|
|
8
|
+
buyToken: T;
|
|
9
|
+
kind: OrderKind;
|
|
10
|
+
}
|
|
11
|
+
export interface TokensFromMarketParams<T> extends Market<T> {
|
|
12
|
+
kind: OrderKind;
|
|
13
|
+
}
|
|
14
|
+
export declare function getCanonicalMarket<T>({ sellToken, buyToken, kind }: CanonicalMarketParams<T>): Market<T>;
|
|
15
|
+
export declare function getTokensFromMarket<T>({ quoteToken, baseToken, kind, }: TokensFromMarketParams<T>): Omit<CanonicalMarketParams<T>, 'kind'>;
|
|
16
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cowprotocol/cow-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "1.0.0-RC.0",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"graphql:codegen": "graphql-codegen --config graphql-codegen.yml"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
+
"@cowprotocol/app-data": "^0.0.1-RC.1",
|
|
28
29
|
"@cowprotocol/contracts": "^1.3.1",
|
|
29
30
|
"ajv": "^8.8.2",
|
|
30
31
|
"cross-fetch": "^3.1.5",
|
|
@@ -1,2 +0,0 @@
|
|
|
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"],s="AppData Root Schema",o={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"}}}},n={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:["version","slippageBips"],title:"Quote",type:"object",properties:{version:{$ref:"#/definitions/version"},slippageBips:{$id:"#/definitions/quote/slippageBips",title:"Slippage tolerance that was applied to the order to get the limit price. Expressed in Basis Points (BIPS)",examples:["5","10","20","100"],pattern:"^\\d+(\\.\\d+)?$",type:"string"}}}}},d={$id:e,$schema:t,description:i,required:r,title:s,type:"object",properties:o,definitions:n};exports.$id=e,exports.$schema=t,exports.default=d,exports.definitions=n,exports.description=i,exports.properties=o,exports.required=r,exports.title=s,exports.type="object";
|
|
2
|
-
//# sourceMappingURL=appData.schema-42d10730.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"appData.schema-42d10730.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,2 +0,0 @@
|
|
|
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",s="object",o={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:["version","slippageBips"],title:"Quote",type:"object",properties:{version:{$ref:"#/definitions/version"},slippageBips:{$id:"#/definitions/quote/slippageBips",title:"Slippage tolerance that was applied to the order to get the limit price. Expressed in Basis Points (BIPS)",examples:["5","10","20","100"],pattern:"^\\d+(\\.\\d+)?$",type:"string"}}}}},a={$id:e,$schema:t,description:i,required:r,title:n,type:"object",properties:o,definitions:d};export{e as $id,t as $schema,a as default,d as definitions,i as description,o as properties,r as required,n as title,s as type};
|
|
2
|
-
//# sourceMappingURL=appData.schema-b8f018d7.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"appData.schema-b8f018d7.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|