@cowprotocol/cow-sdk 2.0.0-alpha.0 → 2.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/README.md +411 -0
- package/dist/common/chains.d.ts +5 -0
- package/dist/common/chains.js +10 -0
- package/dist/common/chains.js.map +1 -0
- package/dist/common/configs.d.ts +17 -0
- package/dist/common/configs.js +7 -0
- package/dist/common/configs.js.map +1 -0
- package/dist/common/cow-error.d.ts +5 -0
- package/dist/common/cow-error.js +12 -0
- package/dist/common/cow-error.js.map +1 -0
- package/dist/common/index.d.ts +4 -0
- package/dist/common/index.js +8 -0
- package/dist/common/index.js.map +1 -0
- package/dist/common/ipfs.d.ts +2 -0
- package/dist/common/ipfs.js +6 -0
- package/dist/common/ipfs.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/metadata/api.d.ts +56 -0
- package/dist/metadata/api.js +149 -0
- package/dist/metadata/api.js.map +1 -0
- package/dist/metadata/index.d.ts +2 -0
- package/dist/metadata/index.js +6 -0
- package/dist/metadata/index.js.map +1 -0
- package/dist/metadata/types.d.ts +22 -0
- package/dist/metadata/types.js +3 -0
- package/dist/metadata/types.js.map +1 -0
- package/dist/metadata/utils/appData.d.ts +3 -0
- package/dist/metadata/utils/appData.js +36 -0
- package/dist/metadata/utils/appData.js.map +1 -0
- package/dist/metadata/utils/ipfs.d.ts +16 -0
- package/dist/metadata/utils/ipfs.js +45 -0
- package/dist/metadata/utils/ipfs.js.map +1 -0
- package/dist/order-book/api.d.ts +31 -0
- package/dist/order-book/api.js +127 -0
- package/dist/order-book/api.js.map +1 -0
- package/dist/order-book/generated/OrderBookClient.d.ts +10 -0
- package/dist/order-book/generated/OrderBookClient.js +24 -0
- package/dist/order-book/generated/OrderBookClient.js.map +1 -0
- package/dist/order-book/generated/core/ApiError.d.ts +10 -0
- package/dist/order-book/generated/core/ApiError.js +16 -0
- package/dist/order-book/generated/core/ApiError.js.map +1 -0
- package/dist/order-book/generated/core/ApiRequestOptions.d.ts +13 -0
- package/dist/order-book/generated/core/ApiRequestOptions.js +3 -0
- package/dist/order-book/generated/core/ApiRequestOptions.js.map +1 -0
- package/dist/order-book/generated/core/ApiResult.d.ts +7 -0
- package/dist/order-book/generated/core/ApiResult.js +3 -0
- package/dist/order-book/generated/core/ApiResult.js.map +1 -0
- package/dist/order-book/generated/core/BaseHttpRequest.d.ts +8 -0
- package/dist/order-book/generated/core/BaseHttpRequest.js +10 -0
- package/dist/order-book/generated/core/BaseHttpRequest.js.map +1 -0
- package/dist/order-book/generated/core/CancelablePromise.d.ts +26 -0
- package/dist/order-book/generated/core/CancelablePromise.js +95 -0
- package/dist/order-book/generated/core/CancelablePromise.js.map +1 -0
- package/dist/order-book/generated/core/FetchHttpRequest.d.ts +14 -0
- package/dist/order-book/generated/core/FetchHttpRequest.js +21 -0
- package/dist/order-book/generated/core/FetchHttpRequest.js.map +1 -0
- package/dist/order-book/generated/core/OpenAPI.d.ts +16 -0
- package/dist/order-book/generated/core/OpenAPI.js +15 -0
- package/dist/order-book/generated/core/OpenAPI.js.map +1 -0
- package/dist/order-book/generated/core/request.d.ts +13 -0
- package/dist/order-book/generated/core/request.js +254 -0
- package/dist/order-book/generated/core/request.js.map +1 -0
- package/dist/order-book/generated/index.d.ts +50 -0
- package/dist/order-book/generated/index.js +48 -0
- package/dist/order-book/generated/index.js.map +1 -0
- package/dist/order-book/generated/models/Address.d.ts +4 -0
- package/dist/order-book/generated/models/Address.js +6 -0
- package/dist/order-book/generated/models/Address.js.map +1 -0
- package/dist/order-book/generated/models/AmountEstimate.d.ts +16 -0
- package/dist/order-book/generated/models/AmountEstimate.js +6 -0
- package/dist/order-book/generated/models/AmountEstimate.js.map +1 -0
- package/dist/order-book/generated/models/AppData.d.ts +4 -0
- package/dist/order-book/generated/models/AppData.js +6 -0
- package/dist/order-book/generated/models/AppData.js.map +1 -0
- package/dist/order-book/generated/models/Auction.d.ts +40 -0
- package/dist/order-book/generated/models/Auction.js +6 -0
- package/dist/order-book/generated/models/Auction.js.map +1 -0
- package/dist/order-book/generated/models/BigUint.d.ts +4 -0
- package/dist/order-book/generated/models/BigUint.js +6 -0
- package/dist/order-book/generated/models/BigUint.js.map +1 -0
- package/dist/order-book/generated/models/BuyTokenDestination.d.ts +7 -0
- package/dist/order-book/generated/models/BuyTokenDestination.js +15 -0
- package/dist/order-book/generated/models/BuyTokenDestination.js.map +1 -0
- package/dist/order-book/generated/models/EcdsaSignature.d.ts +4 -0
- package/dist/order-book/generated/models/EcdsaSignature.js +6 -0
- package/dist/order-book/generated/models/EcdsaSignature.js.map +1 -0
- package/dist/order-book/generated/models/EcdsaSigningScheme.d.ts +7 -0
- package/dist/order-book/generated/models/EcdsaSigningScheme.js +15 -0
- package/dist/order-book/generated/models/EcdsaSigningScheme.js.map +1 -0
- package/dist/order-book/generated/models/EthflowData.d.ts +20 -0
- package/dist/order-book/generated/models/EthflowData.js +6 -0
- package/dist/order-book/generated/models/EthflowData.js.map +1 -0
- package/dist/order-book/generated/models/FeeAndQuoteBuyResponse.d.ts +9 -0
- package/dist/order-book/generated/models/FeeAndQuoteBuyResponse.js +6 -0
- package/dist/order-book/generated/models/FeeAndQuoteBuyResponse.js.map +1 -0
- package/dist/order-book/generated/models/FeeAndQuoteError.d.ts +12 -0
- package/dist/order-book/generated/models/FeeAndQuoteError.js +17 -0
- package/dist/order-book/generated/models/FeeAndQuoteError.js.map +1 -0
- package/dist/order-book/generated/models/FeeAndQuoteSellResponse.d.ts +9 -0
- package/dist/order-book/generated/models/FeeAndQuoteSellResponse.js +6 -0
- package/dist/order-book/generated/models/FeeAndQuoteSellResponse.js.map +1 -0
- package/dist/order-book/generated/models/FeeInformation.d.ts +17 -0
- package/dist/order-book/generated/models/FeeInformation.js +6 -0
- package/dist/order-book/generated/models/FeeInformation.js.map +1 -0
- package/dist/order-book/generated/models/NativePriceResponse.d.ts +10 -0
- package/dist/order-book/generated/models/NativePriceResponse.js +6 -0
- package/dist/order-book/generated/models/NativePriceResponse.js.map +1 -0
- package/dist/order-book/generated/models/OnchainOrderData.d.ts +30 -0
- package/dist/order-book/generated/models/OnchainOrderData.js +22 -0
- package/dist/order-book/generated/models/OnchainOrderData.js.map +1 -0
- package/dist/order-book/generated/models/Order.d.ts +3 -0
- package/dist/order-book/generated/models/Order.js +6 -0
- package/dist/order-book/generated/models/Order.js.map +1 -0
- package/dist/order-book/generated/models/OrderCancellation.d.ts +13 -0
- package/dist/order-book/generated/models/OrderCancellation.js +6 -0
- package/dist/order-book/generated/models/OrderCancellation.js.map +1 -0
- package/dist/order-book/generated/models/OrderCancellationError.d.ts +15 -0
- package/dist/order-book/generated/models/OrderCancellationError.js +20 -0
- package/dist/order-book/generated/models/OrderCancellationError.js.map +1 -0
- package/dist/order-book/generated/models/OrderCancellations.d.ts +18 -0
- package/dist/order-book/generated/models/OrderCancellations.js +6 -0
- package/dist/order-book/generated/models/OrderCancellations.js.map +1 -0
- package/dist/order-book/generated/models/OrderClass.d.ts +8 -0
- package/dist/order-book/generated/models/OrderClass.js +16 -0
- package/dist/order-book/generated/models/OrderClass.js.map +1 -0
- package/dist/order-book/generated/models/OrderCreation.d.ts +25 -0
- package/dist/order-book/generated/models/OrderCreation.js +6 -0
- package/dist/order-book/generated/models/OrderCreation.js.map +1 -0
- package/dist/order-book/generated/models/OrderKind.d.ts +7 -0
- package/dist/order-book/generated/models/OrderKind.js +15 -0
- package/dist/order-book/generated/models/OrderKind.js.map +1 -0
- package/dist/order-book/generated/models/OrderMetaData.d.ts +86 -0
- package/dist/order-book/generated/models/OrderMetaData.js +6 -0
- package/dist/order-book/generated/models/OrderMetaData.js.map +1 -0
- package/dist/order-book/generated/models/OrderParameters.d.ts +60 -0
- package/dist/order-book/generated/models/OrderParameters.js +6 -0
- package/dist/order-book/generated/models/OrderParameters.js.map +1 -0
- package/dist/order-book/generated/models/OrderPostError.d.ts +27 -0
- package/dist/order-book/generated/models/OrderPostError.js +32 -0
- package/dist/order-book/generated/models/OrderPostError.js.map +1 -0
- package/dist/order-book/generated/models/OrderQuoteRequest.d.ts +47 -0
- package/dist/order-book/generated/models/OrderQuoteRequest.js +6 -0
- package/dist/order-book/generated/models/OrderQuoteRequest.js.map +1 -0
- package/dist/order-book/generated/models/OrderQuoteResponse.d.ts +23 -0
- package/dist/order-book/generated/models/OrderQuoteResponse.js +6 -0
- package/dist/order-book/generated/models/OrderQuoteResponse.js.map +1 -0
- package/dist/order-book/generated/models/OrderQuoteSide.d.ts +30 -0
- package/dist/order-book/generated/models/OrderQuoteSide.js +14 -0
- package/dist/order-book/generated/models/OrderQuoteSide.js.map +1 -0
- package/dist/order-book/generated/models/OrderQuoteValidity.d.ts +14 -0
- package/dist/order-book/generated/models/OrderQuoteValidity.js +6 -0
- package/dist/order-book/generated/models/OrderQuoteValidity.js.map +1 -0
- package/dist/order-book/generated/models/OrderStatus.d.ts +10 -0
- package/dist/order-book/generated/models/OrderStatus.js +18 -0
- package/dist/order-book/generated/models/OrderStatus.js.map +1 -0
- package/dist/order-book/generated/models/PreSignature.d.ts +4 -0
- package/dist/order-book/generated/models/PreSignature.js +6 -0
- package/dist/order-book/generated/models/PreSignature.js.map +1 -0
- package/dist/order-book/generated/models/PriceQuality.d.ts +9 -0
- package/dist/order-book/generated/models/PriceQuality.js +17 -0
- package/dist/order-book/generated/models/PriceQuality.js.map +1 -0
- package/dist/order-book/generated/models/ReplaceOrderError.d.ts +29 -0
- package/dist/order-book/generated/models/ReplaceOrderError.js +34 -0
- package/dist/order-book/generated/models/ReplaceOrderError.js.map +1 -0
- package/dist/order-book/generated/models/SellTokenSource.d.ts +8 -0
- package/dist/order-book/generated/models/SellTokenSource.js +16 -0
- package/dist/order-book/generated/models/SellTokenSource.js.map +1 -0
- package/dist/order-book/generated/models/Signature.d.ts +6 -0
- package/dist/order-book/generated/models/Signature.js +6 -0
- package/dist/order-book/generated/models/Signature.js.map +1 -0
- package/dist/order-book/generated/models/SigningScheme.d.ts +9 -0
- package/dist/order-book/generated/models/SigningScheme.js +17 -0
- package/dist/order-book/generated/models/SigningScheme.js.map +1 -0
- package/dist/order-book/generated/models/SolverCompetitionResponse.d.ts +28 -0
- package/dist/order-book/generated/models/SolverCompetitionResponse.js +6 -0
- package/dist/order-book/generated/models/SolverCompetitionResponse.js.map +1 -0
- package/dist/order-book/generated/models/SolverSettlement.d.ts +34 -0
- package/dist/order-book/generated/models/SolverSettlement.js +6 -0
- package/dist/order-book/generated/models/SolverSettlement.js.map +1 -0
- package/dist/order-book/generated/models/TokenAmount.d.ts +4 -0
- package/dist/order-book/generated/models/TokenAmount.js +6 -0
- package/dist/order-book/generated/models/TokenAmount.js.map +1 -0
- package/dist/order-book/generated/models/Trade.d.ts +51 -0
- package/dist/order-book/generated/models/Trade.js +6 -0
- package/dist/order-book/generated/models/Trade.js.map +1 -0
- package/dist/order-book/generated/models/TransactionHash.d.ts +4 -0
- package/dist/order-book/generated/models/TransactionHash.js +6 -0
- package/dist/order-book/generated/models/TransactionHash.js.map +1 -0
- package/dist/order-book/generated/models/UID.d.ts +7 -0
- package/dist/order-book/generated/models/UID.js +6 -0
- package/dist/order-book/generated/models/UID.js.map +1 -0
- package/dist/order-book/generated/models/VersionResponse.d.ts +18 -0
- package/dist/order-book/generated/models/VersionResponse.js +6 -0
- package/dist/order-book/generated/models/VersionResponse.js.map +1 -0
- package/dist/order-book/generated/services/DefaultService.d.ts +164 -0
- package/dist/order-book/generated/services/DefaultService.js +314 -0
- package/dist/order-book/generated/services/DefaultService.js.map +1 -0
- package/dist/order-book/index.d.ts +3 -0
- package/dist/order-book/index.js +7 -0
- package/dist/order-book/index.js.map +1 -0
- package/dist/order-book/transformOrder.d.ts +3 -0
- package/dist/order-book/transformOrder.js +37 -0
- package/dist/order-book/transformOrder.js.map +1 -0
- package/dist/order-book/types.d.ts +4 -0
- package/dist/order-book/types.js +3 -0
- package/dist/order-book/types.js.map +1 -0
- package/dist/package.json +84 -0
- package/dist/subgraph/api.d.ts +18 -0
- package/dist/subgraph/api.js +65 -0
- package/dist/subgraph/api.js.map +1 -0
- package/dist/subgraph/graphql.d.ts +3195 -0
- package/dist/subgraph/graphql.js +421 -0
- package/dist/subgraph/graphql.js.map +1 -0
- package/dist/subgraph/index.d.ts +1 -0
- package/dist/subgraph/index.js +5 -0
- package/dist/subgraph/index.js.map +1 -0
- package/dist/subgraph/queries.d.ts +3 -0
- package/dist/subgraph/queries.js +35 -0
- package/dist/subgraph/queries.js.map +1 -0
- package/package.json +9 -1
package/dist/README.md
ADDED
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img width="400" src="./docs/images/CoW.png">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
# CoW SDK
|
|
6
|
+
|
|
7
|
+
[](https://prettier.io/)
|
|
8
|
+
[](https://coveralls.io/github/cowprotocol/cow-sdk?branch=main)
|
|
9
|
+
|
|
10
|
+
## Getting started
|
|
11
|
+
|
|
12
|
+
Install the SDK:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
yarn add @cowprotocol/cow-sdk
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Instantiate the SDK:
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
import { CowSdk } from '@cowprotocol/cow-sdk'
|
|
22
|
+
|
|
23
|
+
const chainId = 100 // Gnosis chain
|
|
24
|
+
const cowSdk = new CowSdk(chainId)
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
The SDK will expose:
|
|
28
|
+
|
|
29
|
+
- The CoW API (`cowSdk.cowApi`)
|
|
30
|
+
- The CoW Subgraph (`cowSdk.cowSubgraphApi`)
|
|
31
|
+
- Convenient method to facilitate signing orders (i.e `cowSdk.signOrder`)
|
|
32
|
+
|
|
33
|
+
> For a quick snippet with the full process on posting an order see the [Post an Order Example](./docs/post-order-example.ts)
|
|
34
|
+
|
|
35
|
+
## CoW API
|
|
36
|
+
|
|
37
|
+
The SDK provides access to the CoW API. The CoW API allows you:
|
|
38
|
+
|
|
39
|
+
- Post orders
|
|
40
|
+
- Get fee quotes
|
|
41
|
+
- Get order details
|
|
42
|
+
- Get history of orders: i.e. filtering by account, transaction hash, etc.
|
|
43
|
+
|
|
44
|
+
For example, you can easily get the last 5 order of a trader:
|
|
45
|
+
|
|
46
|
+
```js
|
|
47
|
+
// i.e. Get last 5 orders for a given trader
|
|
48
|
+
const trades = await cowSdk.cowApi.getOrders({
|
|
49
|
+
owner: '0x00000000005ef87f8ca7014309ece7260bbcdaeb', // Trader
|
|
50
|
+
limit: 5,
|
|
51
|
+
offset: 0,
|
|
52
|
+
})
|
|
53
|
+
console.log(trades)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
> For more information about the API methods, you can check [api.cow.fi/docs](https://api.cow.fi/docs).
|
|
57
|
+
|
|
58
|
+
## Sign and Post orders
|
|
59
|
+
|
|
60
|
+
In order to trade, you will need to create a valid order first.
|
|
61
|
+
|
|
62
|
+
On the contraty to other decentralised exchanges, creating orders is free in CoW Protocol. This is because, one of the
|
|
63
|
+
most common ways to do it is by created offchain signed messages (meta-transactions, uses `EIP-712` or `EIP-1271`).
|
|
64
|
+
|
|
65
|
+
Posting orders is a three steps process:
|
|
66
|
+
|
|
67
|
+
- 1. **Get Market Pricea**: Fee & Price
|
|
68
|
+
- 2. **Sign the order**: Using off-chain signing or Meta-transactions
|
|
69
|
+
- 3. **Post the signed order to the API**: So, the order becomes `OPEN`
|
|
70
|
+
|
|
71
|
+
The next sections will guide you through the process of creating a valid order.
|
|
72
|
+
|
|
73
|
+
> For a quick snippet with the full process on posting an order see the [Post an Order Example](./docs/post-order-example.ts).
|
|
74
|
+
|
|
75
|
+
### Enable tokens (token approval)
|
|
76
|
+
Because of the use of off-chain signing (meta-transactions), users will need to **Enable the sell token** before signed
|
|
77
|
+
orders can be considered as valid ones.
|
|
78
|
+
|
|
79
|
+
This enabling is technically an `ERC-20` approval, and is something that needs to be done only once. After this all
|
|
80
|
+
order creation can be done for free using offchain signing.
|
|
81
|
+
|
|
82
|
+
> For more details see https://docs.cow.fi/tutorials/how-to-submit-orders-via-the-api/1.-set-allowance-for-the-sell-token
|
|
83
|
+
|
|
84
|
+
### Instantiate SDK with a signer
|
|
85
|
+
|
|
86
|
+
Before you can sign any transaction, you have to instantiate the SDK with a [Ethers.JS signer](https://docs.ethers.io/v5/api/signer/):
|
|
87
|
+
|
|
88
|
+
```js
|
|
89
|
+
import { Wallet } from 'ethers'
|
|
90
|
+
import { CowSdk, OrderKind } from '@cowprotocol/cow-sdk'
|
|
91
|
+
|
|
92
|
+
const mnemonic = 'fall dirt bread cactus...'
|
|
93
|
+
const wallet = Wallet.fromMnemonic(mnemonic)
|
|
94
|
+
|
|
95
|
+
const cowSdk = new CowSdk(
|
|
96
|
+
100, { // Leaving chainId empty will default to MAINNET
|
|
97
|
+
signer: wallet // Provide a signer, so you can sign order
|
|
98
|
+
})
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### STEP 1: Get Market Price
|
|
102
|
+
|
|
103
|
+
To create an order, you need to get a price/fee quote first:
|
|
104
|
+
|
|
105
|
+
* The SDK will give you easy access to the API, which returns the `Market Price` and the `Fee` for any given trade you intent to do.
|
|
106
|
+
* The returned `Market Price` is not strictly needed, you can use your own pricing logic.
|
|
107
|
+
* You can choose a price that is below this Market price (**Market Order**), or above Market Price (**Limit Order**).
|
|
108
|
+
* The `Fee` however is very important.
|
|
109
|
+
* It is the required amount in sell token the trader agrees on paying for executing the order onchain.
|
|
110
|
+
* Normally, its value is proportional to the current Gas Price of the network.
|
|
111
|
+
* This fee is never charged if you don't trade.
|
|
112
|
+
|
|
113
|
+
To get the quote, you simply specify the trade you intent to do:
|
|
114
|
+
|
|
115
|
+
```js
|
|
116
|
+
const quoteResponse = await cowSdk.cowApi.getQuote({
|
|
117
|
+
kind: OrderKind.SELL, // Sell order (could also be BUY)
|
|
118
|
+
sellToken: '0xc778417e063141139fce010982780140aa0cd5ab', // WETH
|
|
119
|
+
buyToken: '0x4dbcdf9b62e891a7cec5a2568c3f4faf9e8abe2b', // USDC
|
|
120
|
+
amount: '1000000000000000000', // 1 WETH
|
|
121
|
+
userAddress: '0x1811be0994930fe9480eaede25165608b093ad7a', // Trader
|
|
122
|
+
validTo: 2524608000,
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
const { sellToken, buyToken, validTo, buyAmount, sellAmount, receiver, feeAmount } = quoteResponse.quote
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### STEP 2: Sign the order
|
|
129
|
+
|
|
130
|
+
Once you know the price and fee, we can create the order and sign it:
|
|
131
|
+
|
|
132
|
+
- Technically the order is just a signed message with your intent to trade, and contains your `Limit Price` and `Fee`.
|
|
133
|
+
- As explained before, you can choose your `Limit Price`, but some general approach is to take the current Market Price
|
|
134
|
+
and apply some slippage tolerance to it. `Received Amount = Expected Amount * (1 - Slippage Tolerance)`
|
|
135
|
+
- The SDK will provide an easy way to sign orders given the raw data
|
|
136
|
+
|
|
137
|
+
```js
|
|
138
|
+
const { sellToken, buyToken, validTo, buyAmount, sellAmount, receiver, feeAmount } = quoteResponse.quote
|
|
139
|
+
|
|
140
|
+
// Prepare the RAW order
|
|
141
|
+
const order = {
|
|
142
|
+
kind: OrderKind.SELL, // SELL || BUY
|
|
143
|
+
receiver, // Your account or any other
|
|
144
|
+
sellToken,
|
|
145
|
+
buyToken,
|
|
146
|
+
|
|
147
|
+
partiallyFillable: false, // ("false" is for a "Fill or Kill" order, "true" for allowing "Partial execution" which is not supported yet)
|
|
148
|
+
|
|
149
|
+
// Deadline
|
|
150
|
+
validTo,
|
|
151
|
+
|
|
152
|
+
// Limit Price
|
|
153
|
+
// You can apply some slippage tolerance here to make sure the trade is executed.
|
|
154
|
+
// CoW protocol protects from MEV, so it can work with higher slippages
|
|
155
|
+
sellAmount,
|
|
156
|
+
buyAmount,
|
|
157
|
+
|
|
158
|
+
// Use the fee you received from the API
|
|
159
|
+
feeAmount,
|
|
160
|
+
|
|
161
|
+
// The appData allows you to attach arbitrary information (meta-data) to the order. Its explained in their own section. For now, you can use this 0x0 value
|
|
162
|
+
appData: '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Sign the order
|
|
166
|
+
const signedOrder = await cowSdk.signOrder(order)
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
At this point, you have a signed order. So next step will be to post it to the API so it's considered by the solvers and executed.
|
|
170
|
+
|
|
171
|
+
## STEP 3: **Post the signed order to the API**:
|
|
172
|
+
|
|
173
|
+
Once you have a signed order, last step is to send it to the API.
|
|
174
|
+
|
|
175
|
+
- The API will accept the order if its correctly signed, the deadline is correct, and the fee is enough to settle it
|
|
176
|
+
- Once accepted, the order will be `OPEN` until the specified `validTo` date (expiration)
|
|
177
|
+
- The possible outcomes once accepted is:
|
|
178
|
+
- The order is `EXECUTED`: you will pay the signed fee, and get at least the `buyAmount` tokens you specified, although you will probably get more! (you will probably get a so-called **Surplus**).
|
|
179
|
+
- The order `EXPIRES`: If your price is not good enough, and the order is out of the market price before
|
|
180
|
+
expiration, your order will expire. This doesn't have any cost to the user, which **only pays the fee if the trade is executed**.
|
|
181
|
+
- You cancel the order, so it becomes `CANCELLED`. Cancelling an order can be done both as a free meta-transaction
|
|
182
|
+
(**soft cancelations**) or as a regular on-chain transaction (**hard cancelations**).
|
|
183
|
+
- The API will return an `orderId` which identifies the order, and is created as a summary (hash) of it. In other words, the `orderId` is deterministic given all the order parameters.
|
|
184
|
+
|
|
185
|
+
Post an order using the SDK:
|
|
186
|
+
|
|
187
|
+
```js
|
|
188
|
+
const orderId = await cowSdk.cowApi.sendOrder({
|
|
189
|
+
order: { ...order, ...signedOrder },
|
|
190
|
+
owner: '0x1811be0994930fe9480eaede25165608b093ad7a',
|
|
191
|
+
})
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### BONUS: Show link to Explorer
|
|
195
|
+
Once the order is posted, its good to allow to check the state of it.
|
|
196
|
+
|
|
197
|
+
One easy is to check in the CoW Explorer. You can create a CoW Explorer link if you have the `orderId`:
|
|
198
|
+
|
|
199
|
+
```js
|
|
200
|
+
// View order in explorer
|
|
201
|
+
console.log(`https://explorer.cow.fi/gc/orders/${orderId}`)
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## Create a meta-data document for attaching to an order
|
|
205
|
+
|
|
206
|
+
Orders in CoW Protocol can contain arbitrary data in a field called `AppData`.
|
|
207
|
+
|
|
208
|
+
The SDK facilitates the creation of these documents, and getting the `AppData` Hex number that summarizes it.
|
|
209
|
+
|
|
210
|
+
The most important thing to define in the meta-data is the name of your app, so the order-flow can be credited to it.
|
|
211
|
+
|
|
212
|
+
```js
|
|
213
|
+
const appDataDoc = cowSdk.metadataApi.generateAppDataDoc({
|
|
214
|
+
appDataParams: { appCode: 'YourApp' },
|
|
215
|
+
})
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
This will create a document similar to:
|
|
219
|
+
|
|
220
|
+
```json
|
|
221
|
+
{
|
|
222
|
+
"version": "0.4.0",
|
|
223
|
+
"appCode": "YourApp",
|
|
224
|
+
"metadata": {}
|
|
225
|
+
}
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
After creating the most basic document, you can see how to attach additional meta-data items.
|
|
229
|
+
|
|
230
|
+
For example, you could give information about who referred the user creating the order.
|
|
231
|
+
|
|
232
|
+
```js
|
|
233
|
+
const appDataDoc = cowSdk.metadataApi.generateAppDataDoc({
|
|
234
|
+
appDataParams: { appCode: 'YourApp' },
|
|
235
|
+
metadataParas: {
|
|
236
|
+
referrerParams: {
|
|
237
|
+
address: '0x1f5B740436Fc5935622e92aa3b46818906F416E9',
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
})
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
This will create a document similar to:
|
|
244
|
+
|
|
245
|
+
```json
|
|
246
|
+
{
|
|
247
|
+
"version": "0.4.0",
|
|
248
|
+
"appCode": "YourApp",
|
|
249
|
+
"metadata": {
|
|
250
|
+
"referrer": {
|
|
251
|
+
"address": "0x1f5B740436Fc5935622e92aa3b46818906F416E9",
|
|
252
|
+
"version": "0.1.0"
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
The method `cowSdk.metadataApi.generateAppDataDoc` will always create the latest schema version.
|
|
259
|
+
|
|
260
|
+
For a complete list of metadata that can be attached and for previous versions
|
|
261
|
+
check `@cowprotocol/app-data` [repository](https://github.com/cowprotocol/app-data)
|
|
262
|
+
and [NPM package](https://www.npmjs.com/package/@cowprotocol/app-data)
|
|
263
|
+
|
|
264
|
+
## Get the AppData Hex
|
|
265
|
+
|
|
266
|
+
The `AppData` Hex points to an IPFS document with the meta-data attached to the order.
|
|
267
|
+
|
|
268
|
+
You can calculate the `AppData` Hex, and its corresponding `cidV0` using the SDK:
|
|
269
|
+
|
|
270
|
+
```js
|
|
271
|
+
const { appDataHash, cidv0 } = await cowSdk.metadataApi.calculateAppDataHash(appDataDoc)
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
Note how this operation is deterministic, so given the same document, it will always generate the same hash.
|
|
275
|
+
|
|
276
|
+
This method can be used to calculate the actual hash before uploading the document to IPFS.
|
|
277
|
+
|
|
278
|
+
## Get meta-data document uploaded to IPFS from AppData
|
|
279
|
+
|
|
280
|
+
Given the `AppData` of a document that has been uploaded to IPFS, you can easily retrieve the document.
|
|
281
|
+
|
|
282
|
+
```js
|
|
283
|
+
const appDataDoc = await cowSdk.metadataApi.decodeAppData(
|
|
284
|
+
'0x5ddb2c8207c10b96fac92cb934ef9ba004bc007a073c9e5b13edc422f209ed80'
|
|
285
|
+
)
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
This will return a document similar to:
|
|
289
|
+
|
|
290
|
+
```json
|
|
291
|
+
{
|
|
292
|
+
"version": "0.1.0",
|
|
293
|
+
"appCode": "YourApp",
|
|
294
|
+
"metadata": {
|
|
295
|
+
"referrer": {
|
|
296
|
+
"address": "0x1f5B740436Fc5935622e92aa3b46818906F416E9",
|
|
297
|
+
"version": "0.1.0"
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
## Upload document to IPFS
|
|
304
|
+
|
|
305
|
+
The SDK uses Pinata to upload it to IPFS, so you will need an API Key in order to upload it using the SDK.
|
|
306
|
+
|
|
307
|
+
Alternatively, you can upload the document on your own using any other service.
|
|
308
|
+
|
|
309
|
+
```js
|
|
310
|
+
// Make sure you provide the IPFS params when instantiating the SDK
|
|
311
|
+
const cowSdk = new CowSdk(100, {
|
|
312
|
+
ipfs: {
|
|
313
|
+
pinataApiKey: 'YOUR_PINATA_API_KEY',
|
|
314
|
+
pinataApiSecret: 'YOUR_PINATA_API_SECRET',
|
|
315
|
+
},
|
|
316
|
+
})
|
|
317
|
+
|
|
318
|
+
// Upload to IPFS
|
|
319
|
+
const uploadedAppDataHash = await cowSdk.metadataApi.uploadMetadataDocToIpfs(appDataDoc)
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
## Convert IPFS CIDv0 to AppData (and back)
|
|
323
|
+
Given an IPFS CIDv0 you can convert it to an `AppData`
|
|
324
|
+
|
|
325
|
+
```js
|
|
326
|
+
const decodedAppDataHex = await cowSdk.metadataApi.cidToAppDataHex('QmUf2TrpSANVXdgcYfAAACe6kg551cY3rAemB7xfEMjYvs')
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
This will return an `AppData` hex: `0x5ddb2c8207c10b96fac92cb934ef9ba004bc007a073c9e5b13edc422f209ed80`
|
|
330
|
+
|
|
331
|
+
> This might be handy if you decide to upload the document to IPFS yourself and then you need the AppData to post your order
|
|
332
|
+
|
|
333
|
+
Similarly, you can do the opposite and convert an `AppData` into an IPFS document:
|
|
334
|
+
|
|
335
|
+
```js
|
|
336
|
+
const decodedAppDataHex = await cowSdk.metadataApi.appDataHexToCid(hash)
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
This will return an IPFS CIDv0: `QmUf2TrpSANVXdgcYfAAACe6kg551cY3rAemB7xfEMjYvs`
|
|
340
|
+
|
|
341
|
+
## Getting appData schema files
|
|
342
|
+
|
|
343
|
+
It's possible to get schema files directly for each exported version using `getAppDataSchema`
|
|
344
|
+
|
|
345
|
+
```js
|
|
346
|
+
const schema = await cowSdk.metadataApi.getAppDataSchema('0.4.0')
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
## Validating appDataDocs
|
|
350
|
+
|
|
351
|
+
If for some reason you decide to create an `appDataDoc` without using the helper function, you can use `validateAppDataDoc` to validate it against the schema
|
|
352
|
+
|
|
353
|
+
```js
|
|
354
|
+
const { success, error } = await cowSdk.metadataApi.validateAppDataDoc({ version: '0.1.0', ... })
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
## Querying the Cow Subgraph
|
|
358
|
+
|
|
359
|
+
You can query the Cow Subgraph either by running some common queries exposed by the `CowSubgraphApi` or by building your own ones:
|
|
360
|
+
|
|
361
|
+
```js
|
|
362
|
+
const chainId = 1 // Mainnet
|
|
363
|
+
const cowSdk = new CowSdk(chainId)
|
|
364
|
+
|
|
365
|
+
// Get Cow Protocol totals
|
|
366
|
+
const { tokens, orders, traders, settlements, volumeUsd, volumeEth, feesUsd, feesEth } =
|
|
367
|
+
await cowSdk.cowSubgraphApi.getTotals()
|
|
368
|
+
console.log({ tokens, orders, traders, settlements, volumeUsd, volumeEth, feesUsd, feesEth })
|
|
369
|
+
|
|
370
|
+
// Get last 24 hours volume in usd
|
|
371
|
+
const { hourlyTotals } = await cowSdk.cowSubgraphApi.getLastHoursVolume(24)
|
|
372
|
+
console.log(hourlyTotals)
|
|
373
|
+
|
|
374
|
+
// Get last week volume in usd
|
|
375
|
+
const { dailyTotals } = await cowSdk.cowSubgraphApi.getLastDaysVolume(7)
|
|
376
|
+
console.log(dailyTotals)
|
|
377
|
+
|
|
378
|
+
// Get the last 5 batches
|
|
379
|
+
const query = `
|
|
380
|
+
query LastBatches($n: Int!) {
|
|
381
|
+
settlements(orderBy: firstTradeTimestamp, orderDirection: desc, first: $n) {
|
|
382
|
+
txHash
|
|
383
|
+
firstTradeTimestamp
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
`
|
|
387
|
+
const variables = { n: 5 }
|
|
388
|
+
const response = await cowSdk.cowSubgraphApi.runQuery(query, variables)
|
|
389
|
+
console.log(response)
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
### Install Dependencies
|
|
393
|
+
|
|
394
|
+
```bash
|
|
395
|
+
yarn
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
### Build
|
|
399
|
+
|
|
400
|
+
```bash
|
|
401
|
+
yarn build
|
|
402
|
+
|
|
403
|
+
# Build in watch mode
|
|
404
|
+
yarn start
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
### Unit testing
|
|
408
|
+
|
|
409
|
+
```bash
|
|
410
|
+
yarn test
|
|
411
|
+
```
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SupportedChainId = void 0;
|
|
4
|
+
var SupportedChainId;
|
|
5
|
+
(function (SupportedChainId) {
|
|
6
|
+
SupportedChainId[SupportedChainId["MAINNET"] = 1] = "MAINNET";
|
|
7
|
+
SupportedChainId[SupportedChainId["GOERLI"] = 5] = "GOERLI";
|
|
8
|
+
SupportedChainId[SupportedChainId["GNOSIS_CHAIN"] = 100] = "GNOSIS_CHAIN";
|
|
9
|
+
})(SupportedChainId = exports.SupportedChainId || (exports.SupportedChainId = {}));
|
|
10
|
+
//# sourceMappingURL=chains.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chains.js","sourceRoot":"","sources":["../../src/common/chains.ts"],"names":[],"mappings":";;;AAAA,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC1B,6DAAW,CAAA;IACX,2DAAU,CAAA;IACV,yEAAkB,CAAA;AACpB,CAAC,EAJW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAI3B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SupportedChainId } from './chains';
|
|
2
|
+
export interface IpfsConfig {
|
|
3
|
+
uri?: string;
|
|
4
|
+
writeUri?: string;
|
|
5
|
+
readUri?: string;
|
|
6
|
+
pinataApiKey?: string;
|
|
7
|
+
pinataApiSecret?: string;
|
|
8
|
+
}
|
|
9
|
+
export type CowEnv = 'prod' | 'staging';
|
|
10
|
+
export type PartialApiContext = Partial<ApiContext>;
|
|
11
|
+
export type EnvConfigs = Record<SupportedChainId, string>;
|
|
12
|
+
export interface ApiContext {
|
|
13
|
+
chainId: SupportedChainId;
|
|
14
|
+
env: CowEnv;
|
|
15
|
+
}
|
|
16
|
+
export declare const ENVS_LIST: CowEnv[];
|
|
17
|
+
export declare const DEFAULT_COW_API_CONTEXT: ApiContext;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_COW_API_CONTEXT = exports.ENVS_LIST = void 0;
|
|
4
|
+
const chains_1 = require("./chains");
|
|
5
|
+
exports.ENVS_LIST = ['prod', 'staging'];
|
|
6
|
+
exports.DEFAULT_COW_API_CONTEXT = { env: 'prod', chainId: chains_1.SupportedChainId.MAINNET };
|
|
7
|
+
//# sourceMappingURL=configs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configs.js","sourceRoot":"","sources":["../../src/common/configs.ts"],"names":[],"mappings":";;;AAAA,qCAA2C;AAqB9B,QAAA,SAAS,GAAa,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;AAEzC,QAAA,uBAAuB,GAAe,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,yBAAgB,CAAC,OAAO,EAAE,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.logPrefix = exports.CowError = void 0;
|
|
4
|
+
class CowError extends Error {
|
|
5
|
+
constructor(message, error_code) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.error_code = error_code;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.CowError = CowError;
|
|
11
|
+
exports.logPrefix = 'cow-sdk:';
|
|
12
|
+
//# sourceMappingURL=cow-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cow-error.js","sourceRoot":"","sources":["../../src/common/cow-error.ts"],"names":[],"mappings":";;;AAAA,MAAa,QAAS,SAAQ,KAAK;IAGjC,YAAY,OAAe,EAAE,UAAmB;QAC9C,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;CACF;AAPD,4BAOC;AAEY,QAAA,SAAS,GAAG,UAAU,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./chains"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./configs"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./cow-error"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./ipfs"), exports);
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":";;;AAAA,mDAAwB;AACxB,oDAAyB;AACzB,sDAA2B;AAC3B,iDAAsB"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_IPFS_WRITE_URI = exports.DEFAULT_IPFS_READ_URI = void 0;
|
|
4
|
+
exports.DEFAULT_IPFS_READ_URI = 'https://gnosis.mypinata.cloud/ipfs';
|
|
5
|
+
exports.DEFAULT_IPFS_WRITE_URI = 'https://api.pinata.cloud';
|
|
6
|
+
//# sourceMappingURL=ipfs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ipfs.js","sourceRoot":"","sources":["../../src/common/ipfs.ts"],"names":[],"mappings":";;;AAAa,QAAA,qBAAqB,GAAG,oCAAoC,CAAA;AAC5D,QAAA,sBAAsB,GAAG,0BAA0B,CAAA"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./common"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./metadata"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./order-book"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./subgraph"), exports);
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mDAAwB;AACxB,qDAA0B;AAC1B,uDAA4B;AAC5B,qDAA0B"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { AnyAppDataDocVersion, LatestAppDataDocVersion, IpfsHashInfo, GenerateAppDataDocParams } from './types';
|
|
2
|
+
import { IpfsConfig } from '../common/configs';
|
|
3
|
+
import type { ValidationResult } from '@cowprotocol/app-data';
|
|
4
|
+
export declare class MetadataApi {
|
|
5
|
+
/**
|
|
6
|
+
* Creates an appDataDoc with the latest version format
|
|
7
|
+
*
|
|
8
|
+
* Without params creates a default minimum appData doc
|
|
9
|
+
* Optionally creates metadata docs
|
|
10
|
+
*/
|
|
11
|
+
generateAppDataDoc(params?: GenerateAppDataDocParams): Promise<LatestAppDataDocVersion>;
|
|
12
|
+
/**
|
|
13
|
+
* Wrapper around @cowprotocol/app-data getAppDataSchema
|
|
14
|
+
*
|
|
15
|
+
* Returns the appData schema for given version, if any
|
|
16
|
+
* Throws CowError when version doesn't exist
|
|
17
|
+
*/
|
|
18
|
+
getAppDataSchema(version: string): Promise<AnyAppDataDocVersion>;
|
|
19
|
+
/**
|
|
20
|
+
* Wrapper around @cowprotocol/app-data validateAppDataDoc
|
|
21
|
+
*
|
|
22
|
+
* Validates given doc against the doc's own version
|
|
23
|
+
*/
|
|
24
|
+
validateAppDataDoc(appDataDoc: AnyAppDataDocVersion): Promise<ValidationResult>;
|
|
25
|
+
decodeAppData(hash: string): Promise<void | AnyAppDataDocVersion>;
|
|
26
|
+
cidToAppDataHex(ipfsHash: string): Promise<string | void>;
|
|
27
|
+
appDataHexToCid(hash: string): Promise<string | void>;
|
|
28
|
+
/**
|
|
29
|
+
* Calculates appDataHash WITHOUT publishing file to IPFS
|
|
30
|
+
*
|
|
31
|
+
* This method is intended to quickly generate the appDataHash independent
|
|
32
|
+
* of IPFS upload/pinning
|
|
33
|
+
* The hash is deterministic thus uploading it to IPFS will give you the same
|
|
34
|
+
* result
|
|
35
|
+
*
|
|
36
|
+
* WARNING!
|
|
37
|
+
* One important caveat is that - like `uploadMetadataDocToIpfs` method - the
|
|
38
|
+
* calculation is done with a stringified file without a new line at the end.
|
|
39
|
+
* That means that you will get different results if the file is uploaded
|
|
40
|
+
* directly as a file. For example:
|
|
41
|
+
*
|
|
42
|
+
* Consider the content `hello world`.
|
|
43
|
+
*
|
|
44
|
+
* Using IPFS's cli tool to updload a file with the contents above
|
|
45
|
+
* (`ipfs add file`), it'll have the line ending and result in this CIDv0:
|
|
46
|
+
* QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o
|
|
47
|
+
*
|
|
48
|
+
* While using this method - and `uploadMetadataDocToIpfs` - will give you
|
|
49
|
+
* this CIDv0:
|
|
50
|
+
* Qmf412jQZiuVUtdgnB36FXFX7xg5V6KEbSJ4dpQuhkLyfD
|
|
51
|
+
*
|
|
52
|
+
* @param appData
|
|
53
|
+
*/
|
|
54
|
+
calculateAppDataHash(appData: AnyAppDataDocVersion): Promise<IpfsHashInfo | void>;
|
|
55
|
+
uploadMetadataDocToIpfs(appDataDoc: AnyAppDataDocVersion, ipfsConfig: IpfsConfig): Promise<string | void>;
|
|
56
|
+
}
|