Skip to content

Commit 8dc81c8

Browse files
committed
resolved conflict and added IPNS APIs
1 parent 6b7c846 commit 8dc81c8

File tree

1 file changed

+50
-1
lines changed

1 file changed

+50
-1
lines changed

src/lighthouseweb3/__init__.py

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
download as _download,
1010
get_file_info as getFileInfo,
1111
get_balance as getBalance,
12-
get_api_key as getApiKey
12+
get_api_key as getApiKey,
13+
ipns_generate_key as ipnsGenerateKey,
14+
ipns_publish_record as ipnsPublishRecord,
15+
get_ipns_record as getIpnsRecord,
16+
remove_ipns_record as removeIpnsRecord,
1317
)
1418

1519

@@ -57,6 +61,51 @@ def getBalance(self):
5761
return getBalance.get_balance(self.token)
5862
except Exception as e:
5963
raise e
64+
65+
def generateKey(self):
66+
"""
67+
Generate a new IPNS key for the authenticated user.
68+
:return: dict, The generated IPNS key information.
69+
"""
70+
try:
71+
return ipnsGenerateKey.ipns_generate_key(self.token)
72+
except Exception as e:
73+
raise e
74+
75+
def publishRecord(self, cid: str, keyName: str):
76+
"""
77+
Publish an IPNS record for a given CID and key name.
78+
:param cid: str, Content Identifier to publish
79+
:param keyName: str, Name of the IPNS key to use
80+
:return: dict, The published IPNS record information
81+
"""
82+
try:
83+
return ipnsPublishRecord.ipns_publish_record(self.token, cid, keyName)
84+
except Exception as e:
85+
raise e
86+
87+
def getAllKeys(self):
88+
"""
89+
Retrieves all IPNS records associated with the current token.
90+
return: list A list of IPNS records retrieved using the provided token.
91+
"""
92+
93+
try:
94+
return getIpnsRecord.get_ipns_records(self.token)
95+
except Exception as e:
96+
raise e
97+
98+
def removeKey(self, keyName: str):
99+
"""
100+
Remove IPNS record of the given keyName
101+
:param keyName: str, Name of the IPNS key to use
102+
:return: dict, A dict of removed IPNS record.
103+
"""
104+
105+
try:
106+
return removeIpnsRecord.remove_ipns_record(self.token, keyName)
107+
except Exception as e:
108+
raise e
60109

61110
@staticmethod
62111
def downloadBlob(dist: io.BufferedWriter, cid: str, chunk_size=1024*1024*10):

0 commit comments

Comments
 (0)