@oceanprotocol/lib 1.0.0-next.9 → 1.0.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.
Files changed (63) hide show
  1. package/CHANGELOG.md +390 -1
  2. package/CodeExamples.md +918 -0
  3. package/README.md +12 -80
  4. package/dist/lib.js +1 -1
  5. package/dist/lib.js.map +1 -1
  6. package/dist/lib.modern.js +1 -1
  7. package/dist/lib.modern.js.map +1 -1
  8. package/dist/lib.module.js +1 -1
  9. package/dist/lib.module.js.map +1 -1
  10. package/dist/lib.umd.js +1 -1
  11. package/dist/lib.umd.js.map +1 -1
  12. package/dist/src/@types/Asset.d.ts +83 -0
  13. package/dist/src/@types/Compute.d.ts +18 -1
  14. package/dist/src/@types/DDO/DDO.d.ts +43 -0
  15. package/dist/src/@types/DDO/Event.d.ts +20 -0
  16. package/dist/src/@types/DDO/Metadata.d.ts +92 -0
  17. package/dist/src/@types/DDO/Service.d.ts +72 -6
  18. package/dist/src/{interfaces/DispenserInterface.d.ts → @types/Dispenser.d.ts} +0 -0
  19. package/dist/src/@types/Erc20.d.ts +21 -0
  20. package/dist/src/{interfaces/Erc721Interface.d.ts → @types/Erc721.d.ts} +2 -2
  21. package/dist/src/@types/FileMetadata.d.ts +29 -0
  22. package/dist/src/{interfaces/FixedRateInterface.d.ts → @types/FixedPrice.d.ts} +7 -1
  23. package/dist/src/{interfaces/PoolInterface.d.ts → @types/Pool.d.ts} +11 -2
  24. package/dist/src/@types/Provider.d.ts +9 -0
  25. package/dist/src/@types/Router.d.ts +59 -0
  26. package/dist/src/@types/index.d.ts +6 -0
  27. package/dist/src/aquarius/Aquarius.d.ts +23 -1
  28. package/dist/src/factories/NFTFactory.d.ts +222 -14
  29. package/dist/src/index.d.ts +1 -1
  30. package/dist/src/models/Config.d.ts +128 -0
  31. package/dist/src/pools/Router.d.ts +189 -8
  32. package/dist/src/pools/balancer/Pool.d.ts +354 -29
  33. package/dist/src/pools/dispenser/Dispenser.d.ts +109 -2
  34. package/dist/src/pools/fixedRate/FixedRateExchange.d.ts +309 -17
  35. package/dist/src/pools/index.d.ts +2 -0
  36. package/dist/src/pools/ssContracts/SideStaking.d.ts +110 -7
  37. package/dist/src/provider/Provider.d.ts +125 -6
  38. package/dist/src/tokens/Datatoken.d.ts +347 -8
  39. package/dist/src/tokens/NFT.d.ts +297 -5
  40. package/dist/src/utils/ContractUtils.d.ts +13 -4
  41. package/dist/src/utils/DatatokenName.d.ts +4 -0
  42. package/dist/src/utils/General.d.ts +4 -0
  43. package/dist/src/utils/PoolHelpers.d.ts +8 -0
  44. package/dist/src/utils/SignatureUtils.d.ts +0 -2
  45. package/dist/src/utils/TokenUtils.d.ts +65 -3
  46. package/dist/src/utils/index.d.ts +2 -0
  47. package/dist/test/TestContractHandler.d.ts +8 -36
  48. package/dist/test/config.d.ts +5 -0
  49. package/dist/test/{unit/NftFactory.test.d.ts → integration/CodeExamples.test.d.ts} +0 -0
  50. package/dist/test/unit/factories/NftFactory.test.d.ts +1 -0
  51. package/package.json +37 -32
  52. package/dist/src/interfaces/Erc20Interface.d.ts +0 -11
  53. package/dist/src/interfaces/RouterInterface.d.ts +0 -12
  54. package/dist/src/interfaces/index.d.ts +0 -5
  55. package/dist/test/integration/config.d.ts +0 -3
  56. package/dist/test/unit/config.d.ts +0 -3
  57. package/docs/beginners_guide.md +0 -338
  58. package/docs/get-test-OCEAN.md +0 -24
  59. package/docs/overview.md +0 -394
  60. package/docs/quickstart_marketplace.md +0 -423
  61. package/docs/quickstart_simple.md +0 -272
  62. package/docs/services.md +0 -94
  63. package/docs/wallets.md +0 -98
package/docs/services.md DELETED
@@ -1,94 +0,0 @@
1
- <!--
2
- Copyright 2021 Ocean Protocol Foundation
3
- SPDX-License-Identifier: Apache-2.0
4
- -->
5
-
6
- # About Ocean off-chain services
7
-
8
- ## Introduction
9
-
10
- Ocean uses these off-chain services:
11
-
12
- - [Ocean Provider](https://github.com/oceanprotocol/provider) is for data services. Specifically, it's a REST API serving requests for two types of data services: static urls (for downloading data) and compute services. It's run by the marketplace or the data publisher.
13
- - [Ocean Aquarius](https://github.com/oceanprotocol/aquarius) is metadata cache REST API. This helps to aid search in marketplaces.
14
-
15
- We now describe how to use these.
16
-
17
- ## 1. Set config values for services
18
-
19
- Here we use a file to set config values.
20
-
21
- In your working directory, create a file `config.ini` and fill it with the following. It will use pre-existing services running for rinkeby testnet.
22
-
23
- [eth-network]
24
- network = https://rinkeby.infura.io/v3/<your Infura project id>
25
-
26
- [resources]
27
- aquarius.url = AQUARIUS_URL=https://aquarius.rinkeby.oceanprotocol.com
28
- provider.url = PROVIDER_URL=https://provider.rinkeby.oceanprotocol.com
29
-
30
- Ensure that envvars don't override the config file values:
31
-
32
- ```console
33
- unset NETWORK_URL AQUARIUS_URL PROVIDER_URL
34
- ```
35
-
36
- Create an envvar to point to the new config file. In the console:
37
-
38
- ```console
39
- export CONFIG_FILE=config.ini
40
- ```
41
-
42
- ## 2. Use the services within Javascrtipt
43
-
44
- In Javascript, import and configure the components / services:
45
-
46
- ```javascript
47
- const Web3 = require('web3')
48
- const web3 = new Web3('http://127.0.0.1:8545')
49
-
50
- #configure the components
51
- const config = {
52
- metadataCacheUri: 'http://aquarius:5000',
53
- providerUri: 'http://localhost:8030',
54
- nodeUri: `http://localhost:${process.env.ETH_PORT || 8545}`,
55
- verbose: LogLevel.Error,
56
- web3Provider: web3,
57
- factoryAddress: '0x123456789...'
58
- }
59
- ```
60
-
61
- Now you're ready to use the services! 🐳 The marketplace tutorial will use them in more detail.
62
-
63
- ## Alternatives on Services
64
-
65
- Above, we described a specific flow to go through configuring services. Here are some variants of that flow.
66
-
67
- ### Point to services in other networks
68
-
69
- The service urls above are for rinkeby. [Ocean's docs have urls](https://docs.oceanprotocol.com/concepts/networks) for Ethereum mainnet and other supported networks.
70
-
71
- ### Run your own services, separately
72
-
73
- Above, we pointed to existing services. Alternatively, you can run your own. Here's how.
74
-
75
- Open a new console, and get provider running:
76
-
77
- ```console
78
- docker run oceanprotocol/provider:latest
79
- ```
80
-
81
- Open another new console, and get aquarius running:
82
-
83
- ```console
84
- docker run oceanprotocol/aquarius:latest
85
- ```
86
-
87
- Here are the urls for the local services, for use in `config.ini` etc.
88
-
89
- - Provider url: `http://127.0.0.1:8030`
90
- - Aquarius url: `http://127.0.0.1:5000`
91
-
92
- ### Run your own services, all at once
93
-
94
- Above, we ran all services separately. You can also run [Ocean Barge](https://github.com/oceanprotocol/barge) to conveniently run them all at once.
package/docs/wallets.md DELETED
@@ -1,98 +0,0 @@
1
- <!--
2
- Copyright 2021 Ocean Protocol Foundation
3
- SPDX-License-Identifier: Apache-2.0
4
- -->
5
-
6
- # Wallets
7
-
8
- This page describes some basic approaches to Ethereum wallets and accounts.
9
-
10
- All you really need is a private key. From that, you can derive the Ethereum address. An Ethereum "account" is a combination of private key and Eth address.
11
-
12
- A "wallet" is a thing that stores private keys (and maybe signs transactions). This includes Metamask (browser plugin), Trezor (hardware wallet), and more. [Ocean docs on wallets](https://docs.oceanprotocol.com/tutorials/wallets/) has more information.
13
-
14
- Here we describe:
15
-
16
- 1. How to generate private keys
17
- 2. Where to store private keys
18
- 3. How your software might access accounts
19
-
20
- ## 1. How to generate private keys
21
-
22
- ### Generate in browser with Metamask
23
-
24
- The datatokens tutorial described how to install Metamask, then use one the Ethereum accounts it auto-generates (along with the private key).
25
-
26
- ### Generate in Javascript
27
-
28
- ocean-lib includes the [web3.js library](https://web3js.readthedocs.io/en/) which can generate private keys.
29
- Here's how. In Javascript:
30
-
31
- ```javascript
32
- const Web3 = require('web3');
33
- const web3Provider = new Web3js.providers.WebsocketProvider(`wss://mainnet.infura.io/ws/v3/INFURA_PROJECT_ID`);
34
- const web3 = new Web3(web3Provider);
35
- const account = await web3.eth.accounts.create();
36
- const privateKey = account.privateKey;
37
- ```
38
-
39
- ## 2. Where to store private keys
40
-
41
- The _whole point_ of crypto wallets is store private keys. Wallets have various tradeoffs of cost, convienence, and security. For example, hardware wallets tend to be more secure but less convenient and not free.
42
-
43
- It can also be useful to store private keys locally on your machine, for testing, though only with a small amount of value at stake (keep the risk down 🐙).
44
-
45
- Do _not_ store your private keys on anything public, unless you want your tokens to disappear. For example, don't store your private keys in GitHub or expose them on frontend webpage code.
46
-
47
- ## 3. How your software might access Ethereum accounts
48
-
49
- There are two main ways: (a) directly load private key, and (b) as a keyfile JSON object. Let's review each.
50
-
51
- ### 3a. Directly load private key
52
-
53
- You could grab this from a locally-stored file, or from an envvar that you copy in for a new session. Here we focus on the latter.
54
-
55
- First, make your key available as an envvar. Here's an example key. From your console:
56
-
57
- ```console
58
- export MY_TEST_KEY=0xaefd8bc8725c4b3d15fbe058d0f58f4d852e8caea2bf68e0f73acb1aeec19baa
59
- ```
60
-
61
- The Ethereum address that gets computed from the example key is `0x281269C18376010B196a928c335E495bd05eC32F`.
62
-
63
-
64
- ### 3b. Keyfile JSON object, aka EncryptedKey
65
-
66
- Here's an example JSON object. This example has the same private key as above, and password `OceanProtocol` to encrypt/decrypt the private key. The private key is stored as parameter `ciphertext` (in encrypted form, of course).
67
-
68
- ```json
69
- {
70
- "address": "281269c18376010b196a928c335e495bd05ec32f",
71
- "crypto": {
72
- "cipher": "aes-128-ctr",
73
- "cipherparams": {
74
- "iv": "ac0b74c5100bd319030d983029256250"
75
- },
76
- "ciphertext": "6e003d25869a8f84c3d055d4bda3fd0e83b89769b6513b58b2b76d0738f2ab1c",
77
- "kdf": "pbkdf2",
78
- "kdfparams": {
79
- "c": 1000000,
80
- "dklen": 32,
81
- "prf": "hmac-sha256",
82
- "salt": "423c1be88c1fadd926c1b668a5d93f74"
83
- },
84
- "mac": "6b90720ddc10d457c2e3e7e1b61550d7a7fa75e6051cb1ed4f1516fba4f0a45f"
85
- },
86
- "id": "7954ec59-6819-4e3c-b065-e6f3a9c1fe6c",
87
- "version": 3
88
- }
89
- ```
90
-
91
- Here's how you use the JSON object. In your console, export the EncryptedKey and password:
92
-
93
- ```console
94
- export MY_TEST_ENCRYPTED_KEY='{"address": "281269c18376010b196a928c335e495bd05ec32f", "crypto": {"cipher": "aes-128-ctr", "cipherparams": {"iv": "ac0b74c5100bd319030d983029256250"}, "ciphertext": "6e003d25869a8f84c3d055d4bda3fd0e83b89769b6513b58b2b76d0738f2ab1c", "kdf": "pbkdf2", "kdfparams": {"c": 1000000, "dklen": 32, "prf": "hmac-sha256", "salt": "423c1be88c1fadd926c1b668a5d93f74"}, "mac": "6b90720ddc10d457c2e3e7e1b61550d7a7fa75e6051cb1ed4f1516fba4f0a45f"}, "id": "7954ec59-6819-4e3c-b065-e6f3a9c1fe6c", "version": 3}'
95
- export MY_TEST_PASSWORD=OceanProtocol
96
- ```
97
-
98
-