@arcadiasol/sdk 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,298 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Arcadia SDK - Wallet Management Example</title>
7
+ <style>
8
+ body {
9
+ font-family: Arial, sans-serif;
10
+ max-width: 800px;
11
+ margin: 50px auto;
12
+ padding: 20px;
13
+ background: #050814;
14
+ color: #fff;
15
+ }
16
+ .container {
17
+ background: #1a1f2e;
18
+ padding: 30px;
19
+ border-radius: 8px;
20
+ border: 1px solid #2a2f3e;
21
+ }
22
+ h1 {
23
+ color: #1DA8FF;
24
+ margin-top: 0;
25
+ }
26
+ .status {
27
+ padding: 15px;
28
+ margin: 15px 0;
29
+ border-radius: 4px;
30
+ background: #2a2f3e;
31
+ }
32
+ .status.success {
33
+ background: #0a5d2e;
34
+ border: 1px solid #0d7a3d;
35
+ }
36
+ .status.error {
37
+ background: #5d0a0a;
38
+ border: 1px solid #7a0d0d;
39
+ }
40
+ .status.info {
41
+ background: #1a3a5d;
42
+ border: 1px solid #1d4a7a;
43
+ }
44
+ .status.warning {
45
+ background: #5d4a0a;
46
+ border: 1px solid #7a5d0d;
47
+ }
48
+ button {
49
+ background: #1DA8FF;
50
+ color: white;
51
+ border: none;
52
+ padding: 12px 24px;
53
+ border-radius: 4px;
54
+ cursor: pointer;
55
+ font-size: 16px;
56
+ margin: 5px;
57
+ }
58
+ button:hover {
59
+ background: #0d8fdf;
60
+ }
61
+ button:disabled {
62
+ background: #555;
63
+ cursor: not-allowed;
64
+ }
65
+ .wallet-info {
66
+ background: #050814;
67
+ padding: 20px;
68
+ border-radius: 4px;
69
+ margin: 20px 0;
70
+ }
71
+ .wallet-address {
72
+ word-break: break-all;
73
+ font-family: monospace;
74
+ background: #1a1f2e;
75
+ padding: 10px;
76
+ border-radius: 4px;
77
+ margin: 10px 0;
78
+ }
79
+ .event-log {
80
+ background: #050814;
81
+ padding: 15px;
82
+ border-radius: 4px;
83
+ margin: 20px 0;
84
+ max-height: 300px;
85
+ overflow-y: auto;
86
+ font-family: monospace;
87
+ font-size: 12px;
88
+ }
89
+ .event-log .event {
90
+ margin: 5px 0;
91
+ padding: 5px;
92
+ border-left: 3px solid #1DA8FF;
93
+ padding-left: 10px;
94
+ }
95
+ .event-log .event.error {
96
+ border-left-color: #ff4444;
97
+ }
98
+ .event-log .event.success {
99
+ border-left-color: #44ff44;
100
+ }
101
+ </style>
102
+ </head>
103
+ <body>
104
+ <div class="container">
105
+ <h1>Arcadia SDK - Wallet Management</h1>
106
+
107
+ <div id="status" class="status info">
108
+ Initializing SDK...
109
+ </div>
110
+
111
+ <div class="wallet-info">
112
+ <h2>Wallet Status</h2>
113
+ <p><strong>Connected:</strong> <span id="connected">Checking...</span></p>
114
+ <p><strong>Wallet Address:</strong></p>
115
+ <div id="walletAddress" class="wallet-address">Not available</div>
116
+ <p><strong>In Iframe:</strong> <span id="inIframe">Checking...</span></p>
117
+ </div>
118
+
119
+ <div>
120
+ <h2>Actions</h2>
121
+ <button onclick="getWalletAddress()">Get Wallet Address</button>
122
+ <button onclick="checkConnection()">Check Connection</button>
123
+ <button onclick="clearLog()">Clear Event Log</button>
124
+ </div>
125
+
126
+ <div>
127
+ <h2>Event Log</h2>
128
+ <div id="eventLog" class="event-log">
129
+ <div class="event">Waiting for events...</div>
130
+ </div>
131
+ </div>
132
+
133
+ <div>
134
+ <h2>Code Example</h2>
135
+ <pre style="background: #050814; padding: 15px; border-radius: 4px; overflow-x: auto;"><code>// Listen for wallet changes
136
+ arcadia.onWalletChange((connected, address) => {
137
+ if (!connected) {
138
+ // Wallet disconnected - pause game
139
+ pauseGame();
140
+ showMessage('Wallet disconnected');
141
+ } else {
142
+ // Wallet reconnected - resume game
143
+ resumeGame();
144
+ console.log('Wallet address:', address);
145
+ }
146
+ });
147
+
148
+ // Check connection status
149
+ const connected = await arcadia.isWalletConnected();
150
+ if (!connected) {
151
+ showMessage('Please connect your wallet');
152
+ }
153
+
154
+ // Get wallet address
155
+ const walletAddress = await arcadia.getWalletAddress();
156
+ if (walletAddress) {
157
+ // Use as user ID
158
+ const userId = walletAddress;
159
+ }</code></pre>
160
+ </div>
161
+ </div>
162
+
163
+ <!-- Load SDK from CDN -->
164
+ <script src="../dist/umd/arcadia-game-sdk.js"></script>
165
+
166
+ <script>
167
+ let arcadia;
168
+
169
+ // Log events
170
+ function logEvent(message, type = 'info') {
171
+ const eventLog = document.getElementById('eventLog');
172
+ const event = document.createElement('div');
173
+ event.className = `event ${type}`;
174
+ const timestamp = new Date().toLocaleTimeString();
175
+ event.textContent = `[${timestamp}] ${message}`;
176
+ eventLog.insertBefore(event, eventLog.firstChild);
177
+
178
+ // Keep only last 50 events
179
+ while (eventLog.children.length > 50) {
180
+ eventLog.removeChild(eventLog.lastChild);
181
+ }
182
+ }
183
+
184
+ // Clear log
185
+ function clearLog() {
186
+ document.getElementById('eventLog').innerHTML = '';
187
+ logEvent('Event log cleared', 'info');
188
+ }
189
+
190
+ // Initialize SDK
191
+ async function initSDK() {
192
+ try {
193
+ const statusEl = document.getElementById('status');
194
+ statusEl.textContent = 'Initializing SDK...';
195
+ statusEl.className = 'status info';
196
+ logEvent('Initializing SDK...', 'info');
197
+
198
+ arcadia = new ArcadiaGameSDK({
199
+ gameId: 'example-game',
200
+ });
201
+
202
+ // Check if in iframe
203
+ const inIframe = arcadia.isInIframe();
204
+ document.getElementById('inIframe').textContent = inIframe ? 'Yes' : 'No';
205
+ logEvent(`Running in iframe: ${inIframe}`, 'info');
206
+
207
+ await arcadia.init();
208
+ logEvent('SDK initialized successfully', 'success');
209
+
210
+ statusEl.textContent = 'SDK initialized successfully!';
211
+ statusEl.className = 'status success';
212
+
213
+ // Set up wallet change listener
214
+ arcadia.onWalletChange((connected, address) => {
215
+ logEvent(`Wallet changed: connected=${connected}, address=${address || 'null'}`, connected ? 'success' : 'error');
216
+ updateWalletDisplay(connected, address);
217
+ });
218
+
219
+ // Get initial wallet status
220
+ await getWalletAddress();
221
+ } catch (error) {
222
+ const statusEl = document.getElementById('status');
223
+ statusEl.textContent = 'SDK initialization failed: ' + error.message;
224
+ statusEl.className = 'status error';
225
+ logEvent('SDK initialization failed: ' + error.message, 'error');
226
+ console.error('SDK init error:', error);
227
+ }
228
+ }
229
+
230
+ // Get wallet address
231
+ async function getWalletAddress() {
232
+ try {
233
+ const statusEl = document.getElementById('status');
234
+ statusEl.textContent = 'Fetching wallet address...';
235
+ statusEl.className = 'status info';
236
+ logEvent('Fetching wallet address...', 'info');
237
+
238
+ const address = await arcadia.getWalletAddress();
239
+ updateWalletDisplay(address !== null, address);
240
+ logEvent(`Wallet address retrieved: ${address || 'null'}`, address ? 'success' : 'warning');
241
+
242
+ if (address) {
243
+ statusEl.textContent = 'Wallet address retrieved successfully!';
244
+ statusEl.className = 'status success';
245
+ } else {
246
+ statusEl.textContent = 'Wallet not connected. Please connect your wallet in Arcadia.';
247
+ statusEl.className = 'status warning';
248
+ }
249
+ } catch (error) {
250
+ const statusEl = document.getElementById('status');
251
+ statusEl.textContent = 'Error: ' + error.message;
252
+ statusEl.className = 'status error';
253
+ logEvent('Error getting wallet address: ' + error.message, 'error');
254
+ console.error('Get wallet error:', error);
255
+ }
256
+ }
257
+
258
+ // Check connection
259
+ async function checkConnection() {
260
+ try {
261
+ const statusEl = document.getElementById('status');
262
+ statusEl.textContent = 'Checking connection...';
263
+ statusEl.className = 'status info';
264
+ logEvent('Checking wallet connection...', 'info');
265
+
266
+ const connected = await arcadia.isWalletConnected();
267
+ logEvent(`Connection check: ${connected ? 'connected' : 'not connected'}`, connected ? 'success' : 'warning');
268
+
269
+ if (connected) {
270
+ statusEl.textContent = 'Wallet is connected!';
271
+ statusEl.className = 'status success';
272
+ } else {
273
+ statusEl.textContent = 'Wallet is not connected.';
274
+ statusEl.className = 'status warning';
275
+ }
276
+
277
+ updateWalletDisplay(connected, null);
278
+ } catch (error) {
279
+ const statusEl = document.getElementById('status');
280
+ statusEl.textContent = 'Error: ' + error.message;
281
+ statusEl.className = 'status error';
282
+ logEvent('Error checking connection: ' + error.message, 'error');
283
+ console.error('Check connection error:', error);
284
+ }
285
+ }
286
+
287
+ // Update wallet display
288
+ function updateWalletDisplay(connected, address) {
289
+ document.getElementById('connected').textContent = connected ? 'Yes' : 'No';
290
+ document.getElementById('walletAddress').textContent = address || 'Not available';
291
+ }
292
+
293
+ // Initialize on page load
294
+ window.addEventListener('DOMContentLoaded', initSDK);
295
+ </script>
296
+ </body>
297
+ </html>
298
+
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@arcadiasol/sdk",
3
+ "version": "1.1.0",
4
+ "description": "Arcadia Game SDK for wallet integration and payment processing in Web3 games",
5
+ "main": "dist/esm/index.js",
6
+ "module": "dist/esm/index.js",
7
+ "browser": "dist/umd/arcadia-game-sdk.js",
8
+ "types": "dist/esm/index.d.ts",
9
+ "files": [
10
+ "dist",
11
+ "README.md",
12
+ "examples"
13
+ ],
14
+ "engines": {
15
+ "node": ">=20.0.0",
16
+ "npm": ">=9.0.0"
17
+ },
18
+ "scripts": {
19
+ "build": "rollup -c",
20
+ "build:watch": "rollup -c -w",
21
+ "build:prod": "rollup -c --environment NODE_ENV:production",
22
+ "type-check": "tsc --noEmit",
23
+ "lint": "eslint src --ext .ts"
24
+ },
25
+ "keywords": [
26
+ "arcadia",
27
+ "game-sdk",
28
+ "web3",
29
+ "solana",
30
+ "wallet",
31
+ "payments",
32
+ "gaming"
33
+ ],
34
+ "author": "Arcadia",
35
+ "license": "MIT",
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "https://github.com/arcadia/game-sdk"
39
+ },
40
+ "devDependencies": {
41
+ "@rollup/plugin-commonjs": "^28.0.1",
42
+ "@rollup/plugin-node-resolve": "^15.3.0",
43
+ "@rollup/plugin-terser": "^0.4.1",
44
+ "@rollup/plugin-typescript": "^12.1.0",
45
+ "@types/node": "^20.19.27",
46
+ "@typescript-eslint/eslint-plugin": "^6.19.0",
47
+ "@typescript-eslint/parser": "^6.19.0",
48
+ "eslint": "^8.56.0",
49
+ "rollup": "^4.21.0",
50
+ "typescript": "^5.9.3"
51
+ }
52
+ }
53
+