Skip to content

Commit b54e107

Browse files
committed
[acp plugin] add handling for response code 204, add reset states helper script
1 parent c75aa7b commit b54e107

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

plugins/acp/acp_plugin_gamesdk/acp_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,5 +179,5 @@ def reset_state(self, wallet_address: str ) -> None:
179179
headers={"x-api-key": self.api_key}
180180
)
181181

182-
if response.status_code != 200:
182+
if response.status_code not in [200, 204]:
183183
raise Exception(f"Failed to reset state: {response.status_code} {response.text}")

plugins/acp/tools/reset_states.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import os
2+
from acp_plugin_gamesdk.acp_plugin import AcpToken, AcpPlugin, AdNetworkPluginOptions
3+
4+
5+
def reset_acp_states() -> None:
6+
"""Reset plugin state for all configured ACP tokens."""
7+
acp_tokens = [
8+
os.environ.get("ACP_TOKEN_BUYER"),
9+
os.environ.get("ACP_TOKEN_SELLER")
10+
]
11+
12+
for token in acp_tokens:
13+
try:
14+
acp_plugin = AcpPlugin(
15+
options=AdNetworkPluginOptions(
16+
api_key=os.environ.get("GAME_DEV_API_KEY"),
17+
acp_token_client=AcpToken(
18+
token,
19+
"https://base-sepolia-rpc.publicnode.com/"
20+
)
21+
)
22+
)
23+
acp_plugin.reset_state()
24+
print(f"Successfully reset state for token: {token}")
25+
except Exception as e:
26+
print(f"Failed to reset state for token {token}: {e}")
27+
28+
29+
if __name__ == "__main__":
30+
reset_acp_states()

0 commit comments

Comments
 (0)