Skip to content

Commit

Permalink
Fix pinata ipfs upload
Browse files Browse the repository at this point in the history
  • Loading branch information
tsudmi committed Oct 20, 2023
1 parent 544471d commit 55d8672
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "sw-utils"
version = "0.3.28"
version = "0.3.29"
description = "StakeWise Python utils"
authors = ["StakeWise Labs <[email protected]>"]
license = "GPL-3.0-or-later"
Expand Down
11 changes: 1 addition & 10 deletions sw_utils/ipfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,7 @@ async def upload_bytes(self, data: bytes) -> str:
async def upload_json(self, data: dict | list) -> str:
if not data:
raise ValueError('Empty data provided')
headers = self.headers.copy()
headers['Content-Type'] = 'application/json'
async with ClientSession(headers=headers) as session:
async with session.post(
url=self.json_endpoint,
data=_dump_json({'pinataOptions': {'cidVersion': 1}, 'pinataContent': data}),
) as response:
response.raise_for_status()
ipfs_id = (await response.json())['IpfsHash']
return _strip_ipfs_prefix(ipfs_id)
return await self.upload_bytes(Json().encode(data))

async def remove(self, ipfs_hash: str) -> None:
if not ipfs_hash:
Expand Down

0 comments on commit 55d8672

Please sign in to comment.