Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix barge connection #1729

Merged
merged 50 commits into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
d7c841f
adding network 8896 (barge)
EnzoVezzaro Oct 5, 2022
89d737c
Update ocean.ts
EnzoVezzaro Oct 5, 2022
8a4cd6a
development network with env variable
EnzoVezzaro Oct 6, 2022
1f0b933
temp patch for provider url check
EnzoVezzaro Oct 6, 2022
65cf594
removed logs
EnzoVezzaro Oct 6, 2022
5f7070b
fix typing error
EnzoVezzaro Oct 6, 2022
404fda0
set local provider url to asset metadata
EnzoVezzaro Oct 10, 2022
41389f8
clean development config
EnzoVezzaro Oct 10, 2022
f0c25ad
Merge branch 'main' into fix/issue-fix-barge-connection
bogdanfazakas Oct 10, 2022
6cc857a
wip make use of barge addresses
bogdanfazakas Oct 12, 2022
b017988
update env vars from script
bogdanfazakas Oct 13, 2022
b434678
merge main
bogdanfazakas Nov 9, 2022
789c345
more fixes
bogdanfazakas Nov 10, 2022
662e257
merge main
bogdanfazakas Nov 10, 2022
40daa64
cleanup
bogdanfazakas Nov 11, 2022
7a056bd
update readme
bogdanfazakas Nov 14, 2022
da21d3f
more readme updates
bogdanfazakas Nov 14, 2022
b4a7f11
cleanup fixes
bogdanfazakas Nov 14, 2022
381bb2b
more fixes
bogdanfazakas Nov 14, 2022
ef9117c
script readme updates
bogdanfazakas Nov 15, 2022
eba86ae
update readme
bogdanfazakas Nov 15, 2022
f82d516
update readme
bogdanfazakas Nov 16, 2022
0088eb8
bump oceanjs
bogdanfazakas Nov 16, 2022
1a5164c
merge main
bogdanfazakas Nov 16, 2022
1cfdc77
fix tests after oceanjs upgrade
bogdanfazakas Nov 16, 2022
84c62b4
adding custom provider for mac barge
EnzoVezzaro Nov 17, 2022
415eef1
fix test app.config path
EnzoVezzaro Nov 17, 2022
06add21
remove log
EnzoVezzaro Nov 17, 2022
e646818
added NEXT_PUBLIC_PROVIDER_URL to load dev env
EnzoVezzaro Nov 21, 2022
2857733
added env variable for mac on load dev env
EnzoVezzaro Nov 21, 2022
4028e2f
fre fixes
bogdanfazakas Nov 23, 2022
7da67c1
merge main fix merge conflicts
bogdanfazakas Nov 28, 2022
3d4360d
merge main
bogdanfazakas Dec 12, 2022
77080cd
review suggestions
bogdanfazakas Dec 12, 2022
a13fa70
Update README.md
bogdanfazakas Dec 12, 2022
315f071
add private key example
bogdanfazakas Dec 12, 2022
d0e2bae
Merge branch 'main' into fix/issue-1726-fix-barge-connection
EnzoVezzaro Jan 26, 2023
7fe7280
merge main
bogdanfazakas Feb 16, 2023
897d08c
bump oceanlib
bogdanfazakas Feb 16, 2023
4cb0a48
merge main and fix conflicts
bogdanfazakas Mar 6, 2023
2d6705f
fix build
bogdanfazakas Mar 6, 2023
365f52b
merge main fix conflicts
bogdanfazakas Apr 20, 2023
3728c7a
fix provider uri for mac
EnzoVezzaro Apr 27, 2023
439f134
add custom rpc env var example
bogdanfazakas Apr 28, 2023
d0a0ddf
fix build
bogdanfazakas Apr 28, 2023
bcf9b1a
merge main and fix conflicts
bogdanfazakas Jul 6, 2023
f182c68
update barge env vars script
bogdanfazakas Jul 7, 2023
b9eccd9
remove brage from supported and default chainIds by default
bogdanfazakas Jul 11, 2023
6d8cdb1
merge main fix conflicts
bogdanfazakas Jul 17, 2023
6d83147
remove log
bogdanfazakas Jul 17, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,14 @@

# Privacy Preference Center
#NEXT_PUBLIC_PRIVACY_PREFERENCE_CENTER="true"

# Development Preference Center
#NEXT_PUBLIC_NFT_FACTORY_ADDRESS='0xxx'
#NEXT_PUBLIC_OPF_COMMUNITY_FEE_COLECTOR='0xxx'
#NEXT_PUBLIC_FIXED_RATE_EXCHANGE_ADDRESS='0xxx'
#NEXT_PUBLIC_DISPENSER_ADDRESS='0xxx'
#NEXT_PUBLIC_OCEAN_TOKEN_ADDRESS='0xxx'
#NEXT_PUBLIC_MARKET_DEVELOPMENT='true'
#NEXT_PUBLIC_PROVIDER_URL="http://xxx:xxx"
#NEXT_PUBLIC_SUBGRAPH_URI="http://xxx:xxx"
#NEXT_PUBLIC_METADATACACHE_URI="http://xxx:xxx"
20 changes: 7 additions & 13 deletions .jest/__fixtures__/assetsWithAccessDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ export const assets: AssetExtended[] = [
allocated: 45554.69921875,
orders: 1,
price: {
value: 3231343254,
tokenAddress: '0xCfDdA22C9837aE76E0faA845354f33C62E03653a',
tokenSymbol: 'OCEAN'
tokenAddress: '0x282d8efCe846A88B159800bd4130ad77443Fa1A1',
tokenSymbol: 'mOCEAN',
value: 100
}
},
version: '4.1.0',
Expand Down Expand Up @@ -1113,9 +1113,7 @@ export const assets: AssetExtended[] = [
allocated: 11159.279296875,
orders: 1,
price: {
value: 3231343254,
tokenAddress: '0xCfDdA22C9837aE76E0faA845354f33C62E03653a',
tokenSymbol: 'OCEAN'
value: 0
}
},
version: '4.1.0',
Expand Down Expand Up @@ -1198,9 +1196,7 @@ export const assets: AssetExtended[] = [
stats: {
orders: 0,
price: {
value: 3231343254,
tokenAddress: '0xCfDdA22C9837aE76E0faA845354f33C62E03653a',
tokenSymbol: 'OCEAN'
value: 0
}
},
version: '4.1.0',
Expand Down Expand Up @@ -1448,9 +1444,7 @@ export const assets: AssetExtended[] = [
stats: {
orders: 0,
price: {
value: 3231343254,
tokenAddress: '0xCfDdA22C9837aE76E0faA845354f33C62E03653a',
tokenSymbol: 'OCEAN'
value: 0
}
},
version: '4.1.0',
Expand Down Expand Up @@ -1574,4 +1568,4 @@ export const assets: AssetExtended[] = [
validOrderTx: null
}
}
]
]
24 changes: 9 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,34 +65,28 @@ This will start the development server under

### Local components with Barge

If you prefer to connect to locally running components instead of remote connections, you can spin up [`barge`](https://github.com/oceanprotocol/barge) and use a local Ganache network in another terminal before running `npm start`:
Using the `ocean-market` with `barge` components is recommended for advanced users, if you are new we advice you to use the `ocean-market` first with remote networks. If you prefer to connect to locally running components instead of remote connections, you can spin up [`barge`](https://github.com/oceanprotocol/barge) and use a local Ganache network in another terminal before running `npm start`. To fully test all [The Graph](https://thegraph.com) integrations, you have to start barge with the local Graph node:

```bash
git clone [email protected]:oceanprotocol/barge.git
cd barge

# startup with local Ganache node
./start_ocean.sh
# startup with local Ganache and Graph nodes
./start_ocean.sh --with-thegraph
```

Barge will deploy contracts to the local Ganache node which will take some time. At the end the compiled artifacts need to be copied over to this project into `node_modules/@oceanprotocol/contracts/artifacts`. This script will do that for you:
Barge will deploy contracts to the local Ganache node which will take some time. At the end the compiled artifacts need to imported over to this project as environment variables. The `set-barge-env` script will do that for you and set the env variables to use this local connection in `.env` in the app.

```bash
./scripts/copy-contracts.sh
```

Finally, set environment variables to use this local connection in `.env` in the app:
If you are using `macOS` operating system you should also make same changes to the provider url since the default barge ip can not be accessed due to some network constraints on `macOs`. So we should be using the `127.0.0.1:8030` (if you have changed the provider port please use that here as well) for each direct call from the market to provider, but we should keep the internal barge url `http://172.15.0.4:8030/` (this is the default ip:port for provider in barge, if changed please use the according url). So on inside `src/@utils/provider.ts` if on `macOS` you can hardcode this env variable `NEXT_PUBLIC_PROVIDER_URL` or set
`127.0.0.1:8030` as `providerUrl` on all the methods that call `ProviderInstance` methods. (eg: `getEncryptedFiles`, `getFileDidInfo`, `downloadFile` etc). You should use the same provider url for `src/@utils/nft.ts` inside `setNFTMetadataAndTokenURI` and `setNftMetadata` and `src/components/Publish/index.tsx` inisde `encrypt` method (if you set the env variable there's no need to do this). You also need to use local ip's for the subgraph (`127.0.0.1` instead of `172.15.0.15`) and the metadatacache (`127.0.0.1` instead of `172.15.0.5`).

```bash
# modify env variables
cp .env.example .env

cd market
npm run set-barge-env
bogdanfazakas marked this conversation as resolved.
Show resolved Hide resolved
npm start
```

To use the app together with MetaMask, importing one of the accounts auto-generated by the Ganache container is the easiest way to have test ETH available. All of them have 100 ETH by default. Upon start, the `ocean_ganache_1` container will print out the private keys of multiple accounts in its logs. Pick one of them and import into MetaMask.

To fully test all [The Graph](https://thegraph.com) integrations, you have to run your own local Graph node with our [`ocean-subgraph`](https://github.com/oceanprotocol/ocean-subgraph) deployed to it. Barge does not include a local subgraph so by default, the `subgraphUri` is hardcoded to the Goerli subgraph in our [`getDevelopmentConfig` function](https://github.com/oceanprotocol/market/blob/d0b1534d105e5dcb3790c65d4bb04ff1d2dbc575/src/utils/ocean.ts#L31).
To use the app together with MetaMask, importing one of the accounts auto-generated by the Ganache container is the easiest way to have test ETH available. All of them have 100 ETH by default. Upon start, the `ocean_ganache_1` container will print out the private keys of multiple accounts in its logs. Pick one of them and import into MetaMask. Barge private key example : `0xc594c6e5def4bab63ac29eed19a134c130388f74f019bc74b8f4389df2837a58`
bogdanfazakas marked this conversation as resolved.
Show resolved Hide resolved

> Cleaning all Docker images so they are fetched freshly is often a good idea to make sure no issues are caused by old or stale images: `docker system prune --all --volumes`

Expand Down
22 changes: 20 additions & 2 deletions app.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,28 @@ module.exports = {

// List of chainIds which metadata cache queries will return by default.
// This preselects the Chains user preferences.
chainIds: [1, 137, 56, 246, 1285],
chainIds: [
1,
137,
56,
246,
1285,
process.env.NEXT_PUBLIC_MARKET_DEVELOPMENT === 'true' ? 8996 : null
],

// List of all supported chainIds. Used to populate the Chains user preferences list.
chainIdsSupported: [1, 137, 56, 246, 1285, 5, 80001],
chainIdsSupported: [
1,
137,
56,
246,
1285,
5,
80001,
process.env.NEXT_PUBLIC_MARKET_DEVELOPMENT === 'true' ? 8996 : null
],

customProviderUrl: process.env.NEXT_PUBLIC_PROVIDER_URL,

infuraProjectId: process.env.NEXT_PUBLIC_INFURA_PROJECT_ID || 'xxx',

Expand Down
76 changes: 40 additions & 36 deletions content/pages/editMetadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,44 +30,47 @@
{
"name": "files",
"label": "File",
"prominentHelp": false,
"prominentHelp": false,
"type": "tabs",
"fields": [{
"value": "ipfs",
"title": "IPFS",
"label": "CID",
"placeholder": "e.g. bafkreidgvpkjawlxz6sffxzwgooowe5yt7i6wsyg236mfoks77nywkptdq",
"help": "This CID will be stored encrypted after publishing.",
"computeHelp": "For a compute dataset, your file should match the file type required by the algorithm, and should not exceed 1 GB in file size. ",
"prominentHelp": true,
"type": "files",
"required": true
},
{
"value": "arweave",
"title": "Arweave",
"label": "Transaction ID",
"placeholder": "e.g. DBRCL94j3QqdPaUtt4VWRen8rZfJZBb7Ey40iMpXfhtd",
"help": "This Transaction ID will be stored encrypted after publishing.",
"computeHelp": "For a compute dataset, your file should match the file type required by the algorithm, and should not exceed 1 GB in file size. ",
"prominentHelp": true,
"type": "files",
"required": true
},
{
"value": "url",
"title": "URL",
"label": "File",
"placeholder": "e.g. https://file.com/file.json",
"help": "This URL will be stored encrypted after publishing. **Please make sure that the endpoint is accessible over the internet and is not protected by a firewall or by credentials.**",
"computeHelp": "For a compute dataset, your file should match the file type required by the algorithm, and should not exceed 1 GB in file size. ",
"prominentHelp": true,
"type": "files",
"required": true
}],
"fields": [
{
"value": "ipfs",
"title": "IPFS",
"label": "CID",
"placeholder": "e.g. bafkreidgvpkjawlxz6sffxzwgooowe5yt7i6wsyg236mfoks77nywkptdq",
"help": "This CID will be stored encrypted after publishing.",
"computeHelp": "For a compute dataset, your file should match the file type required by the algorithm, and should not exceed 1 GB in file size. ",
"prominentHelp": true,
"type": "files",
"required": true
},
{
"value": "arweave",
"title": "Arweave",
"label": "Transaction ID",
"placeholder": "e.g. DBRCL94j3QqdPaUtt4VWRen8rZfJZBb7Ey40iMpXfhtd",
"help": "This Transaction ID will be stored encrypted after publishing.",
"computeHelp": "For a compute dataset, your file should match the file type required by the algorithm, and should not exceed 1 GB in file size. ",
"prominentHelp": true,
"type": "files",
"required": true
},
{
"value": "url",
"title": "URL",
"label": "File",
"placeholder": "e.g. https://file.com/file.json",
"help": "This URL will be stored encrypted after publishing. **Please make sure that the endpoint is accessible over the internet and is not protected by a firewall or by credentials.**",
"computeHelp": "For a compute dataset, your file should match the file type required by the algorithm, and should not exceed 1 GB in file size. ",
"prominentHelp": true,
"type": "files",
"required": true
}
],
"sortOptions": false,
"required": true
},{
},
{
"name": "links",
"label": "Sample file",
"prominentHelp": false,
Expand All @@ -83,7 +86,8 @@
"prominentHelp": true,
"type": "files",
"required": false
}],
}
],
"required": false
},

Expand Down
94 changes: 49 additions & 45 deletions content/publish/form.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,60 +104,64 @@
{
"name": "files",
"label": "File",
"prominentHelp": false,
"prominentHelp": false,
"type": "tabs",
"fields": [{
"value": "ipfs",
"title": "IPFS",
"label": "CID",
"placeholder": "e.g. bafkreidgvpkjawlxz6sffxzwgooowe5yt7i6wsyg236mfoks77nywkptdq",
"help": "This CID will be stored encrypted after publishing.",
"computeHelp": "For a compute dataset, your file should match the file type required by the algorithm, and should not exceed 1 GB in file size. ",
"prominentHelp": true,
"type": "files",
"required": true
},
{
"value": "arweave",
"title": "Arweave",
"label": "Transaction ID",
"placeholder": "e.g. DBRCL94j3QqdPaUtt4VWRen8rZfJZBb7Ey40iMpXfhtd",
"help": "This Transaction ID will be stored encrypted after publishing.",
"computeHelp": "For a compute dataset, your file should match the file type required by the algorithm, and should not exceed 1 GB in file size. ",
"prominentHelp": true,
"type": "files",
"required": true
},
{
"value": "url",
"title": "URL",
"label": "File",
"placeholder": "e.g. https://file.com/file.json",
"help": "This URL will be stored encrypted after publishing. **Please make sure that the endpoint is accessible over the internet and is not protected by a firewall or by credentials.**",
"computeHelp": "For a compute dataset, your file should match the file type required by the algorithm, and should not exceed 1 GB in file size. ",
"prominentHelp": true,
"type": "files",
"required": true
}],
"fields": [
{
"value": "ipfs",
"title": "IPFS",
"label": "CID",
"placeholder": "e.g. bafkreidgvpkjawlxz6sffxzwgooowe5yt7i6wsyg236mfoks77nywkptdq",
"help": "This CID will be stored encrypted after publishing.",
"computeHelp": "For a compute dataset, your file should match the file type required by the algorithm, and should not exceed 1 GB in file size. ",
"prominentHelp": true,
"type": "files",
"required": true
},
{
"value": "arweave",
"title": "Arweave",
"label": "Transaction ID",
"placeholder": "e.g. DBRCL94j3QqdPaUtt4VWRen8rZfJZBb7Ey40iMpXfhtd",
"help": "This Transaction ID will be stored encrypted after publishing.",
"computeHelp": "For a compute dataset, your file should match the file type required by the algorithm, and should not exceed 1 GB in file size. ",
"prominentHelp": true,
"type": "files",
"required": true
},
{
"value": "url",
"title": "URL",
"label": "File",
"placeholder": "e.g. https://file.com/file.json",
"help": "This URL will be stored encrypted after publishing. **Please make sure that the endpoint is accessible over the internet and is not protected by a firewall or by credentials.**",
"computeHelp": "For a compute dataset, your file should match the file type required by the algorithm, and should not exceed 1 GB in file size. ",
"prominentHelp": true,
"type": "files",
"required": true
}
],
"sortOptions": false,
"required": true
},{
},
{
"name": "links",
"label": "Sample file",
"prominentHelp": false,
"type": "tabs",
"fields": [
{
"value": "url",
"title": "URL",
"label": "File",
"placeholder": "e.g. https://file.com/file.json",
"help": "This URL will be stored encrypted after publishing. **Please make sure that the endpoint is accessible over the internet and is not protected by a firewall or by credentials.**",
"computeHelp": "For a compute dataset, your file should match the file type required by the algorithm, and should not exceed 1 GB in file size. ",
"prominentHelp": true,
"type": "files",
"required": false
}],
"value": "url",
"title": "URL",
"label": "File",
"placeholder": "e.g. https://file.com/file.json",
"help": "This URL will be stored encrypted after publishing. **Please make sure that the endpoint is accessible over the internet and is not protected by a firewall or by credentials.**",
"computeHelp": "For a compute dataset, your file should match the file type required by the algorithm, and should not exceed 1 GB in file size. ",
"prominentHelp": true,
"type": "files",
"required": false
}
],
"required": false
},
{
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"build:static": "npm run build && next export",
"serve": "serve -s public/",
"pregenerate": "bash scripts/pregenerate.sh",
"set-barge-env": "bash scripts/barge-env.sh",
"test": "npm run pregenerate && npm run lint && npm run type-check && npm run jest",
"jest": "jest -c .jest/jest.config.js",
"jest:watch": "jest -c .jest/jest.config.js --watch",
Expand Down
2 changes: 2 additions & 0 deletions scripts/barge-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Set
node ./scripts/load-development-addresses.js
36 changes: 36 additions & 0 deletions scripts/load-development-addresses.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const fs = require('fs')
const os = require('os')

function getLocalAddresses() {
const data = JSON.parse(
// eslint-disable-next-line security/detect-non-literal-fs-filename
fs.readFileSync(
`${os.homedir}/.ocean/ocean-contracts/artifacts/address.json`,
'utf8'
)
)
return data.development
}

const addresses = getLocalAddresses()
const envVars = []
envVars.push(`NEXT_PUBLIC_NFT_FACTORY_ADDRESS='${addresses.ERC721Factory}'`)
envVars.push(
`NEXT_PUBLIC_OPF_COMMUNITY_FEE_COLECTOR='${addresses.OPFCommunityFeeCollector}'`
)
envVars.push(
`NEXT_PUBLIC_FIXED_RATE_EXCHANGE_ADDRESS='${addresses.FixedPrice}'`
)
envVars.push(`NEXT_PUBLIC_DISPENSER_ADDRESS='${addresses.Dispenser}'`)
envVars.push(`NEXT_PUBLIC_OCEAN_TOKEN_ADDRESS='${addresses.Ocean}'`)
envVars.push(`NEXT_PUBLIC_MARKET_DEVELOPMENT='true'`)
envVars.push(`#NEXT_PUBLIC_PROVIDER_URL='http://127.0.0.1:8030' # only for mac`)
envVars.push(`#NEXT_PUBLIC_SUBGRAPH_URI='http://127.0.0.1:9000' # only for mac`)
envVars.push(`#NEXT_PUBLIC_METADATACACHE_URI='http://127.0.0.1:5000' # only for mac`)

var stream = fs.createWriteStream('.env', { flags: 'a' })

envVars.forEach((envVar) => {
stream.write('\n' + envVar)
})
stream.end()
Loading