mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
Fix ipfs CID. (#1851)
* Fix ipfs CID. * fix lint * tweaks. * Upgrade Github actions. * fix graphql asset url. * Fix cov. * remove duplicate test. * Surround by it block. * debug log. * added docker logs only for ipfs * increase timeout. * debug log. * Changed to ipfs cluster. * roll back. * put in the same test with arweave. * debug. * Log initialize url. * logs. * tweak condition. * changed cid with the one from cluster. * Rename test. Added back uploading in ipfs. * Fix review.
This commit is contained in:
parent
9cb2ea0a02
commit
9c25342c8e
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -224,7 +224,7 @@ jobs:
|
|||||||
# needs: [test_unit, test_integration]
|
# needs: [test_unit, test_integration]
|
||||||
# steps:
|
# steps:
|
||||||
# - uses: actions/checkout@v3
|
# - uses: actions/checkout@v3
|
||||||
# - uses: actions/setup-node@v2
|
# - uses: actions/setup-node@v4
|
||||||
# with:
|
# with:
|
||||||
# node-version: '16'
|
# node-version: '16'
|
||||||
|
|
||||||
|
@ -394,7 +394,7 @@ export class Provider {
|
|||||||
LoggerInstance.error(e)
|
LoggerInstance.error(e)
|
||||||
throw new Error(`Provider initialize failed url: ${initializeUrl} `)
|
throw new Error(`Provider initialize failed url: ${initializeUrl} `)
|
||||||
}
|
}
|
||||||
if (response?.ok) {
|
if (response?.status === 200) {
|
||||||
const results: ProviderInitialize = await response.json()
|
const results: ProviderInitialize = await response.json()
|
||||||
return results
|
return results
|
||||||
}
|
}
|
||||||
|
@ -72,17 +72,6 @@ const arweaveFile: Files = {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
const ifpsFile: Files = {
|
|
||||||
datatokenAddress: '0x0',
|
|
||||||
nftAddress: '0x0',
|
|
||||||
files: [
|
|
||||||
{
|
|
||||||
type: 'ipfs',
|
|
||||||
hash: 'QmRhsp7eghZtW4PktPC2wAHdKoy2LiF1n6UXMKmAhqQJUA'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
const onchainFile: Files = {
|
const onchainFile: Files = {
|
||||||
datatokenAddress: '0x0',
|
datatokenAddress: '0x0',
|
||||||
nftAddress: '0x0',
|
nftAddress: '0x0',
|
||||||
@ -146,6 +135,29 @@ function delay(interval: number) {
|
|||||||
}).timeout(interval + 100)
|
}).timeout(interval + 100)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function uploadToIpfs(data: any): Promise<string> {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
fetch('http://172.15.0.16:5001/api/v0/add', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type':
|
||||||
|
'multipart/form-data; boundary=------------------------a28d68b1c872c96f'
|
||||||
|
},
|
||||||
|
body:
|
||||||
|
'--------------------------a28d68b1c872c96f\r\nContent-Disposition: form-data; name="file"; filename="ddo.json"\r\nContent-Type: application/octet-stream\r\n\r\n' +
|
||||||
|
data +
|
||||||
|
'\r\n--------------------------a28d68b1c872c96f--\r\n'
|
||||||
|
})
|
||||||
|
.then(function (response: any) {
|
||||||
|
const resp = response.json()
|
||||||
|
resolve(resp.Hash)
|
||||||
|
})
|
||||||
|
.catch(function (error: any) {
|
||||||
|
reject(error)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
describe('Publish consume test', async () => {
|
describe('Publish consume test', async () => {
|
||||||
before(async () => {
|
before(async () => {
|
||||||
publisherAccount = (await provider.getSigner(0)) as Signer
|
publisherAccount = (await provider.getSigner(0)) as Signer
|
||||||
@ -210,25 +222,10 @@ describe('Publish consume test', async () => {
|
|||||||
)
|
)
|
||||||
assert(urlAssetId, 'Failed to publish url DDO')
|
assert(urlAssetId, 'Failed to publish url DDO')
|
||||||
})
|
})
|
||||||
|
it('Should publish arweave asset', async () => {
|
||||||
it('Should publish ipfs asset', async () => {
|
|
||||||
ipfsAssetId = await createAsset(
|
|
||||||
'IpfsDatatoken',
|
|
||||||
'IPFSDT',
|
|
||||||
publisherAccount,
|
|
||||||
ifpsFile,
|
|
||||||
assetDdo,
|
|
||||||
providerUrl,
|
|
||||||
addresses.ERC721Factory,
|
|
||||||
aquarius
|
|
||||||
)
|
|
||||||
assert(ipfsAssetId, 'Failed to publish ipfs DDO')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('Should publish arwave asset', async () => {
|
|
||||||
arweaveAssetId = await createAsset(
|
arweaveAssetId = await createAsset(
|
||||||
'ArweaveDatatoken',
|
'ArwaveDatatoken',
|
||||||
'ARWEAVEDT',
|
'ARWAVEDT',
|
||||||
publisherAccount,
|
publisherAccount,
|
||||||
arweaveFile,
|
arweaveFile,
|
||||||
assetDdo,
|
assetDdo,
|
||||||
@ -236,7 +233,31 @@ describe('Publish consume test', async () => {
|
|||||||
addresses.ERC721Factory,
|
addresses.ERC721Factory,
|
||||||
aquarius
|
aquarius
|
||||||
)
|
)
|
||||||
assert(arweaveAssetId, 'Failed to publish ipfs DDO')
|
assert(arweaveAssetId, 'Failed to arwave publish DDO')
|
||||||
|
})
|
||||||
|
it('Should publish ipfs asset', async () => {
|
||||||
|
const ipfsCID = await uploadToIpfs(JSON.stringify(assetDdo))
|
||||||
|
const ipfsFile: Files = {
|
||||||
|
datatokenAddress: '0x0',
|
||||||
|
nftAddress: '0x0',
|
||||||
|
files: [
|
||||||
|
{
|
||||||
|
type: 'ipfs',
|
||||||
|
hash: ipfsCID
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
ipfsAssetId = await createAsset(
|
||||||
|
'IpfsDatatoken',
|
||||||
|
'IPFSDT',
|
||||||
|
publisherAccount,
|
||||||
|
ipfsFile,
|
||||||
|
assetDdo,
|
||||||
|
providerUrl,
|
||||||
|
addresses.ERC721Factory,
|
||||||
|
aquarius
|
||||||
|
)
|
||||||
|
assert(ipfsAssetId, 'Failed to publish ipfs DDO')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should publish onchain asset', async () => {
|
it('Should publish onchain asset', async () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user