@dimcool/mcp 0.1.12 → 0.1.14

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.
Files changed (2) hide show
  1. package/dist/index.js +46 -41
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -21539,6 +21539,27 @@ var VoteAccountLayout = BufferLayout.struct([
21539
21539
  BufferLayout.seq(BufferLayout.struct([BufferLayout.nu64("epoch"), BufferLayout.nu64("credits"), BufferLayout.nu64("prevCredits")]), BufferLayout.offset(BufferLayout.u32(), -8), "epochCredits"),
21540
21540
  BufferLayout.struct([BufferLayout.nu64("slot"), BufferLayout.nu64("timestamp")], "lastTimestamp")
21541
21541
  ]);
21542
+ function base64ToBytes(base64) {
21543
+ if (typeof Buffer !== "undefined") {
21544
+ return Buffer.from(base64, "base64");
21545
+ }
21546
+ const binary = atob(base64);
21547
+ const bytes = new Uint8Array(binary.length);
21548
+ for (let i = 0; i < binary.length; i++) {
21549
+ bytes[i] = binary.charCodeAt(i);
21550
+ }
21551
+ return bytes;
21552
+ }
21553
+ function bytesToBase64(bytes) {
21554
+ if (typeof Buffer !== "undefined") {
21555
+ return Buffer.from(bytes).toString("base64");
21556
+ }
21557
+ let binary = "";
21558
+ for (let i = 0; i < bytes.length; i++) {
21559
+ binary += String.fromCharCode(bytes[i]);
21560
+ }
21561
+ return btoa(binary);
21562
+ }
21542
21563
  var HttpClient = class {
21543
21564
  constructor(baseUrl, storage, logger2, appId, autoPayConfig) {
21544
21565
  this.baseUrl = baseUrl.replace(/\/$/, "");
@@ -21810,11 +21831,11 @@ var HttpClient = class {
21810
21831
  }
21811
21832
  }
21812
21833
  );
21813
- const unsignedTx = Transaction.from(
21814
- Buffer.from(prepare.transaction, "base64")
21815
- );
21834
+ const unsignedTx = Transaction.from(base64ToBytes(prepare.transaction));
21816
21835
  const signedTx = await this.signTransactionHandler(unsignedTx);
21817
- const signedTransaction = signedTx.serialize({ requireAllSignatures: false }).toString("base64");
21836
+ const signedTransaction = bytesToBase64(
21837
+ signedTx.serialize({ requireAllSignatures: false })
21838
+ );
21818
21839
  const submitted = await this.post(
21819
21840
  "/payments/submit",
21820
21841
  {
@@ -21828,19 +21849,6 @@ var HttpClient = class {
21828
21849
  return submitted.paymentProof;
21829
21850
  }
21830
21851
  };
21831
- function toBase64(bytes) {
21832
- if (typeof Buffer !== "undefined") {
21833
- return Buffer.from(bytes).toString("base64");
21834
- }
21835
- let binary = "";
21836
- for (let i = 0; i < bytes.length; i++) {
21837
- binary += String.fromCharCode(bytes[i]);
21838
- }
21839
- if (typeof btoa === "undefined") {
21840
- throw new Error("Base64 encoding is not available in this environment");
21841
- }
21842
- return btoa(binary);
21843
- }
21844
21852
  var Auth = class {
21845
21853
  constructor(http2, storage, wallet, logger2) {
21846
21854
  this.http = http2;
@@ -21905,7 +21913,7 @@ var Auth = class {
21905
21913
  }
21906
21914
  const { message } = await this.generateHandshake(address);
21907
21915
  const signatureResult = await this.wallet.signMessage(message);
21908
- const signedMessage = typeof signatureResult === "string" ? signatureResult : toBase64(signatureResult);
21916
+ const signedMessage = typeof signatureResult === "string" ? signatureResult : bytesToBase64(signatureResult);
21909
21917
  this.logger.debug("Auth.loginWithWallet called", {
21910
21918
  address,
21911
21919
  walletMeta: options?.walletMeta
@@ -22379,11 +22387,11 @@ var Games = class {
22379
22387
  );
22380
22388
  }
22381
22389
  const prepared = await this.prepareGameDonation(gameId, amountMinor);
22382
- const unsignedTx = Transaction.from(
22383
- Buffer.from(prepared.transaction, "base64")
22384
- );
22390
+ const unsignedTx = Transaction.from(base64ToBytes(prepared.transaction));
22385
22391
  const signedTx = await this.wallet.signTransaction(unsignedTx);
22386
- const signedTransaction = signedTx.serialize({ requireAllSignatures: false }).toString("base64");
22392
+ const signedTransaction = bytesToBase64(
22393
+ signedTx.serialize({ requireAllSignatures: false })
22394
+ );
22387
22395
  const result = await this.donateToGame(
22388
22396
  gameId,
22389
22397
  amountMinor,
@@ -22651,11 +22659,11 @@ var Tips = class {
22651
22659
  }
22652
22660
  const { publicKey: senderAddress } = await this.wallet.loadWallet();
22653
22661
  const prepared = await this.prepare({ recipientUsername, amount });
22654
- const unsignedTx = Transaction.from(
22655
- Buffer.from(prepared.transaction, "base64")
22656
- );
22662
+ const unsignedTx = Transaction.from(base64ToBytes(prepared.transaction));
22657
22663
  const signedTx = await this.wallet.signTransaction(unsignedTx);
22658
- const signedTxBase64 = signedTx.serialize({ requireAllSignatures: false }).toString("base64");
22664
+ const signedTxBase64 = bytesToBase64(
22665
+ signedTx.serialize({ requireAllSignatures: false })
22666
+ );
22659
22667
  const transfer = await this.wallet.submitTransfer(
22660
22668
  signedTxBase64,
22661
22669
  senderAddress,
@@ -23020,11 +23028,11 @@ var Wallet = class {
23020
23028
  amount,
23021
23029
  token
23022
23030
  );
23023
- const unsignedTx = Transaction.from(
23024
- Buffer.from(prepared.transaction, "base64")
23025
- );
23031
+ const unsignedTx = Transaction.from(base64ToBytes(prepared.transaction));
23026
23032
  const signedTx = await this.signTransaction(unsignedTx);
23027
- const signedTxBase64 = signedTx.serialize({ requireAllSignatures: false }).toString("base64");
23033
+ const signedTxBase64 = bytesToBase64(
23034
+ signedTx.serialize({ requireAllSignatures: false })
23035
+ );
23028
23036
  const submitted = await this.submitTransfer(
23029
23037
  signedTxBase64,
23030
23038
  senderAddress,
@@ -25233,6 +25241,11 @@ function registerAuthTools(server2, client) {
25233
25241
  "No referrer yet \u2014 call dim_apply_referral_code for 10% fee discount"
25234
25242
  );
25235
25243
  }
25244
+ if (result.username) {
25245
+ nextSteps.push(
25246
+ `Share your referral code "${result.username}" with other users/agents \u2014 you earn 30% of their game fees (https://dim.cool/?ref=${result.username})`
25247
+ );
25248
+ }
25236
25249
  } catch {
25237
25250
  }
25238
25251
  const response = {
@@ -25882,7 +25895,7 @@ function registerGamesTools(server2, client) {
25882
25895
  );
25883
25896
  server2.tool(
25884
25897
  "dim_join_queue",
25885
- "Join the matchmaking queue for a lobby. If the lobby is full, the game starts immediately. Otherwise, waits for an opponent. Returns the lobby (and gameId if matched).",
25898
+ 'Join the matchmaking queue for a lobby. If matched immediately, returns gameId \u2014 start playing. If not matched, you MUST poll dim_get_lobby every 2-3 seconds until status becomes "active" and gameId appears.',
25886
25899
  {
25887
25900
  lobbyId: z5.string().describe("The lobby ID to join the queue for")
25888
25901
  },
@@ -26873,7 +26886,7 @@ var DIM_INSTRUCTIONS = [
26873
26886
  },
26874
26887
  {
26875
26888
  name: "dim_join_queue",
26876
- description: "Join matchmaking queue for a game type."
26889
+ description: "Join matchmaking queue. If not matched immediately, poll dim_get_lobby until gameId appears."
26877
26890
  },
26878
26891
  { name: "dim_get_lobby", description: "Get lobby details by ID." },
26879
26892
  {
@@ -26937,15 +26950,7 @@ function registerInstructionsTool(server2) {
26937
26950
  type: "text",
26938
26951
  text: JSON.stringify(
26939
26952
  {
26940
- quickstart: "Call dim_login first, then dim_get_balance. All monetary amounts are in USDC dollars (e.g., 1.00 = $1).",
26941
- game_flow: [
26942
- "1. dim_create_lobby (gameType, betAmount in dollars) \u2192 lobbyId",
26943
- "2. dim_join_queue (lobbyId) \u2192 enters matchmaking",
26944
- '3. Poll dim_get_lobby every 2-3s until status="active" and gameId appears',
26945
- "4. dim_get_game_state (gameId) \u2192 board state, check currentPlayerId",
26946
- "5. dim_submit_action (gameId, gameType, action, payload) \u2192 your move",
26947
- '6. Repeat 4-5 until status="completed"'
26948
- ],
26953
+ hint: "Game flow: dim_create_lobby \u2192 dim_join_queue \u2192 poll dim_get_lobby until gameId appears \u2192 dim_get_game_state \u2192 dim_submit_action \u2192 repeat until dim_get_game shows status=completed",
26949
26954
  move_formats: {
26950
26955
  "rock-paper-scissors": 'action: "play", payload: { action: "rock"|"paper"|"scissors" }',
26951
26956
  chess: 'action: "move", payload: { from: "e2", to: "e4" }',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dimcool/mcp",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "description": "MCP server for DIM — lets AI agents play games, chat, send USDC, and earn referral income on the DIM platform",
5
5
  "type": "module",
6
6
  "bin": {