Skip to content

Commit 710219e

Browse files
committed
refactor: updated README.md and env example file
1 parent 50855ee commit 710219e

File tree

2 files changed

+26
-15
lines changed

2 files changed

+26
-15
lines changed

plugins/dpsn/README.md

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,25 +50,32 @@ The `DpsnPlugin` is designed to be used within the Virtuals Protocol Game SDK fr
5050

5151
```python
5252
# Import the pre-instantiated plugin (recommended)
53-
from plugins.dpsn.dpsn_plugin_gamesdk.dpsn_plugin import plugin
53+
from plugins.dpsn.dpsn_plugin_gamesdk.dpsn_plugin import DpsnPlugin
54+
load_dotenv()
55+
56+
dpsn_plugin=DpsnPlugin(
57+
dpsn_url=os.getenv("DPSN_URL"),
58+
pvt_key=os.getenv("PVT_KEY")
59+
)
60+
5461
# Define a simple message handler
5562
def handle_message(message_data):
5663
topic = message_data.get('topic', 'unknown')
5764
payload = message_data.get('payload', {})
5865
print(f"Message on {topic}: {payload}")
5966

6067
# Register the message handler
61-
plugin.set_message_callback(handle_message)
68+
dpsn_plugin.set_message_callback(handle_message)
6269

6370
# Subscribe to a topic
64-
status, message, details = plugin.subscribe(
71+
status, message, details = dpsn_plugin.subscribe(
6572
topic="0xe14768a6d8798e4390ec4cb8a4c991202c2115a5cd7a6c0a7ababcaf93b4d2d4/BTCUSDT/ticker"
6673
)
6774
print(f"Subscription status: {status}, Message: {message}")
6875

6976
# Later when done:
70-
# plugin.unsubscribe(topic="0xe14768a6d8798e4390ec4cb8a4c991202c2115a5cd7a6c0a7ababcaf93b4d2d4/BTCUSDT/ticker")
71-
# plugin.shutdown()
77+
dpsn_plugin.unsubscribe(topic="0xe14768a6d8798e4390ec4cb8a4c991202c2115a5cd7a6c0a7ababcaf93b4d2d4/BTCUSDT/ticker")
78+
dpsn_plugin.shutdown()
7279

7380
```
7481

@@ -79,8 +86,14 @@ The Game Agent interacts with the plugin by executing tasks that map to the plug
7986
```python
8087
from game_sdk.game.agent import Agent, WorkerConfig
8188
from game_sdk.game.custom_types import FunctionResult
82-
from dpsn_plugin_gamesdk.dpsn_plugin import plugin
89+
from dpsn_plugin_gamesdk.dpsn_plugin import DpsnPlugin
90+
91+
load_dotenv()
8392

93+
dpsn_plugin=DpsnPlugin(
94+
dpsn_url=os.getenv("DPSN_URL"),
95+
pvt_key=os.getenv("PVT_KEY")
96+
)
8497
# --- Add Message Handler ---
8598
def handle_incoming_message(message_data: dict):
8699
"""Callback function to process messages received via the plugin."""
@@ -102,7 +115,7 @@ def handle_incoming_message(message_data: dict):
102115
print(f"Error in message handler: {e}")
103116

104117
# Set the callback in the plugin instance *before* running the agent
105-
plugin.set_message_callback(handle_incoming_message)
118+
dpsn_plugin.set_message_callback(handle_incoming_message)
106119

107120
def get_agent_state_fn(function_result: FunctionResult, current_state: dict) -> dict:
108121
"""Update state based on the function results"""
@@ -134,9 +147,9 @@ subscription_worker = WorkerConfig(
134147
worker_description="Worker specialized in managing DPSN topic subscriptions, unsubscriptions, message handling, and shutdown.",
135148
get_state_fn=get_worker_state,
136149
action_space=[
137-
plugin.get_function("subscribe"),
138-
plugin.get_function("unsubscribe"),
139-
plugin.get_function("shutdown")
150+
dpsn_plugin.get_function("subscribe"),
151+
dpsn_plugin.get_function("unsubscribe"),
152+
dpsn_plugin.get_function("shutdown")
140153
],
141154
)
142155

@@ -188,6 +201,4 @@ The plugin exposes the following functions intended to be called via the Game Ag
188201

189202

190203

191-
> In case of any queries regarding DPSN, please reach out to the team on [Telegram](https://t.me/dpsn_dev) 📥.
192-
193-
204+
> In case of any queries regarding DPSN, please reach out to the team on [Telegram](https://t.me/dpsn_dev) 📥.

plugins/dpsn/examples/.env.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
DPSN_URL=betanet.dpsn.org
2-
PVT_KEY=9192c2aa125bde2ed2e861f973a6124e0796722dc263dacac70719579df8d98b
3-
GAME_API_KEY=apt-e52b807bf0a05d47cfdcd88413e7099c
2+
PVT_KEY=<your-wallet-private-key>
3+
GAME_API_KEY=apt-<your-game-api-key>

0 commit comments

Comments
 (0)