@dimcool/dimclaw 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 (3) hide show
  1. package/dist/index.js +45 -32
  2. package/index.ts +8 -2
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -53700,6 +53700,27 @@ var VoteAccountLayout2 = BufferLayout2.struct([
53700
53700
  BufferLayout2.seq(BufferLayout2.struct([BufferLayout2.nu64("epoch"), BufferLayout2.nu64("credits"), BufferLayout2.nu64("prevCredits")]), BufferLayout2.offset(BufferLayout2.u32(), -8), "epochCredits"),
53701
53701
  BufferLayout2.struct([BufferLayout2.nu64("slot"), BufferLayout2.nu64("timestamp")], "lastTimestamp")
53702
53702
  ]);
53703
+ function base64ToBytes(base64) {
53704
+ if (typeof Buffer !== "undefined") {
53705
+ return Buffer.from(base64, "base64");
53706
+ }
53707
+ const binary = atob(base64);
53708
+ const bytes = new Uint8Array(binary.length);
53709
+ for (let i = 0; i < binary.length; i++) {
53710
+ bytes[i] = binary.charCodeAt(i);
53711
+ }
53712
+ return bytes;
53713
+ }
53714
+ function bytesToBase64(bytes) {
53715
+ if (typeof Buffer !== "undefined") {
53716
+ return Buffer.from(bytes).toString("base64");
53717
+ }
53718
+ let binary = "";
53719
+ for (let i = 0; i < bytes.length; i++) {
53720
+ binary += String.fromCharCode(bytes[i]);
53721
+ }
53722
+ return btoa(binary);
53723
+ }
53703
53724
  var HttpClient = class {
53704
53725
  constructor(baseUrl, storage, logger2, appId, autoPayConfig) {
53705
53726
  this.baseUrl = baseUrl.replace(/\/$/, "");
@@ -53971,11 +53992,11 @@ var HttpClient = class {
53971
53992
  }
53972
53993
  }
53973
53994
  );
53974
- const unsignedTx = Transaction2.from(
53975
- Buffer.from(prepare.transaction, "base64")
53976
- );
53995
+ const unsignedTx = Transaction2.from(base64ToBytes(prepare.transaction));
53977
53996
  const signedTx = await this.signTransactionHandler(unsignedTx);
53978
- const signedTransaction = signedTx.serialize({ requireAllSignatures: false }).toString("base64");
53997
+ const signedTransaction = bytesToBase64(
53998
+ signedTx.serialize({ requireAllSignatures: false })
53999
+ );
53979
54000
  const submitted = await this.post(
53980
54001
  "/payments/submit",
53981
54002
  {
@@ -53989,19 +54010,6 @@ var HttpClient = class {
53989
54010
  return submitted.paymentProof;
53990
54011
  }
53991
54012
  };
53992
- function toBase64(bytes) {
53993
- if (typeof Buffer !== "undefined") {
53994
- return Buffer.from(bytes).toString("base64");
53995
- }
53996
- let binary = "";
53997
- for (let i = 0; i < bytes.length; i++) {
53998
- binary += String.fromCharCode(bytes[i]);
53999
- }
54000
- if (typeof btoa === "undefined") {
54001
- throw new Error("Base64 encoding is not available in this environment");
54002
- }
54003
- return btoa(binary);
54004
- }
54005
54013
  var Auth = class {
54006
54014
  constructor(http22, storage, wallet, logger2) {
54007
54015
  this.http = http22;
@@ -54066,7 +54074,7 @@ var Auth = class {
54066
54074
  }
54067
54075
  const { message } = await this.generateHandshake(address);
54068
54076
  const signatureResult = await this.wallet.signMessage(message);
54069
- const signedMessage = typeof signatureResult === "string" ? signatureResult : toBase64(signatureResult);
54077
+ const signedMessage = typeof signatureResult === "string" ? signatureResult : bytesToBase64(signatureResult);
54070
54078
  this.logger.debug("Auth.loginWithWallet called", {
54071
54079
  address,
54072
54080
  walletMeta: options?.walletMeta
@@ -54540,11 +54548,11 @@ var Games = class {
54540
54548
  );
54541
54549
  }
54542
54550
  const prepared = await this.prepareGameDonation(gameId, amountMinor);
54543
- const unsignedTx = Transaction2.from(
54544
- Buffer.from(prepared.transaction, "base64")
54545
- );
54551
+ const unsignedTx = Transaction2.from(base64ToBytes(prepared.transaction));
54546
54552
  const signedTx = await this.wallet.signTransaction(unsignedTx);
54547
- const signedTransaction = signedTx.serialize({ requireAllSignatures: false }).toString("base64");
54553
+ const signedTransaction = bytesToBase64(
54554
+ signedTx.serialize({ requireAllSignatures: false })
54555
+ );
54548
54556
  const result = await this.donateToGame(
54549
54557
  gameId,
54550
54558
  amountMinor,
@@ -54812,11 +54820,11 @@ var Tips = class {
54812
54820
  }
54813
54821
  const { publicKey: senderAddress } = await this.wallet.loadWallet();
54814
54822
  const prepared = await this.prepare({ recipientUsername, amount });
54815
- const unsignedTx = Transaction2.from(
54816
- Buffer.from(prepared.transaction, "base64")
54817
- );
54823
+ const unsignedTx = Transaction2.from(base64ToBytes(prepared.transaction));
54818
54824
  const signedTx = await this.wallet.signTransaction(unsignedTx);
54819
- const signedTxBase64 = signedTx.serialize({ requireAllSignatures: false }).toString("base64");
54825
+ const signedTxBase64 = bytesToBase64(
54826
+ signedTx.serialize({ requireAllSignatures: false })
54827
+ );
54820
54828
  const transfer = await this.wallet.submitTransfer(
54821
54829
  signedTxBase64,
54822
54830
  senderAddress,
@@ -55181,11 +55189,11 @@ var Wallet = class {
55181
55189
  amount,
55182
55190
  token
55183
55191
  );
55184
- const unsignedTx = Transaction2.from(
55185
- Buffer.from(prepared.transaction, "base64")
55186
- );
55192
+ const unsignedTx = Transaction2.from(base64ToBytes(prepared.transaction));
55187
55193
  const signedTx = await this.signTransaction(unsignedTx);
55188
- const signedTxBase64 = signedTx.serialize({ requireAllSignatures: false }).toString("base64");
55194
+ const signedTxBase64 = bytesToBase64(
55195
+ signedTx.serialize({ requireAllSignatures: false })
55196
+ );
55189
55197
  const submitted = await this.submitTransfer(
55190
55198
  signedTxBase64,
55191
55199
  senderAddress,
@@ -57468,6 +57476,11 @@ function register(api) {
57468
57476
  "No referrer yet \u2014 call dim_apply_referral_code for 10% fee discount"
57469
57477
  );
57470
57478
  }
57479
+ if (result.username) {
57480
+ nextSteps.push(
57481
+ `Share your referral code "${result.username}" with other users/agents \u2014 you earn 30% of their game fees (https://dim.cool/?ref=${result.username})`
57482
+ );
57483
+ }
57471
57484
  } catch {
57472
57485
  }
57473
57486
  const response = {
@@ -57622,7 +57635,7 @@ function register(api) {
57622
57635
  },
57623
57636
  {
57624
57637
  name: "dim_join_queue",
57625
- description: "Join matchmaking queue for a game type."
57638
+ description: "Join matchmaking queue. If not matched immediately, poll dim_get_lobby until gameId appears."
57626
57639
  },
57627
57640
  { name: "dim_get_lobby", description: "Get lobby details by ID." },
57628
57641
  {
@@ -58213,7 +58226,7 @@ function register(api) {
58213
58226
  });
58214
58227
  api.registerTool({
58215
58228
  name: "dim_join_queue",
58216
- description: "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).",
58229
+ description: '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.',
58217
58230
  parameters: {
58218
58231
  type: "object",
58219
58232
  properties: {
package/index.ts CHANGED
@@ -172,6 +172,11 @@ export default function register(api: {
172
172
  'No referrer yet — call dim_apply_referral_code for 10% fee discount',
173
173
  );
174
174
  }
175
+ if (result.username) {
176
+ nextSteps.push(
177
+ `Share your referral code "${result.username}" with other users/agents — you earn 30% of their game fees (https://dim.cool/?ref=${result.username})`,
178
+ );
179
+ }
175
180
  } catch {
176
181
  /* non-critical */
177
182
  }
@@ -340,7 +345,8 @@ export default function register(api: {
340
345
  },
341
346
  {
342
347
  name: 'dim_join_queue',
343
- description: 'Join matchmaking queue for a game type.',
348
+ description:
349
+ 'Join matchmaking queue. If not matched immediately, poll dim_get_lobby until gameId appears.',
344
350
  },
345
351
  { name: 'dim_get_lobby', description: 'Get lobby details by ID.' },
346
352
  {
@@ -975,7 +981,7 @@ export default function register(api: {
975
981
  api.registerTool({
976
982
  name: 'dim_join_queue',
977
983
  description:
978
- '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).',
984
+ 'Join the matchmaking queue for a lobby. If matched immediately, returns gameId start playing. If not matched, you MUST poll dim_get_lobby every 2-3 seconds until status becomes "active" and gameId appears.',
979
985
  parameters: {
980
986
  type: 'object',
981
987
  properties: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dimcool/dimclaw",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "description": "OpenClaw plugin for DIM — play games, chat, send USDC, and earn on DIM using the SDK directly (no MCP subprocess).",
5
5
  "type": "module",
6
6
  "openclaw": {