mint-day 0.4.1 → 0.4.2

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.
@@ -97,19 +97,14 @@ async function sponsoredMint(result, recipient) {
97
97
  sponsored: true,
98
98
  };
99
99
  }
100
- catch {
101
- return null;
100
+ catch (err) {
101
+ const message = err instanceof Error ? err.message : String(err);
102
+ return { error: `Sponsor request failed: ${message}` };
102
103
  }
103
104
  }
104
105
  export async function handleMint(params, calldataService, defaultRecipient, userKey = "", tryit = { tryitKey: "", tryitContract: "", tryitRpc: "", tryitChain: 84532 }) {
105
- // Determine mode:
106
- // 1. User has private key: mainnet, sign + submit locally
107
- // 2. No key but recipient provided: mainnet, sponsored gas via server
108
- // 3. No key, no recipient: testnet try-it mode
109
- const hasRecipient = !!params.recipient;
110
- const isTestnet = !userKey && !hasRecipient;
111
- const privateKey = userKey || (isTestnet ? tryit.tryitKey : "");
112
106
  // Confirmation path: replay cached intent
107
+ // Check cache first so we can use cached recipient for mode detection
113
108
  if (params.mintId) {
114
109
  const entry = getCachedEntry(params.mintId);
115
110
  if (!entry) {
@@ -123,6 +118,10 @@ export async function handleMint(params, calldataService, defaultRecipient, user
123
118
  const cached = entry.intent;
124
119
  const cachedPlatform = entry.platform;
125
120
  intentCache.delete(params.mintId);
121
+ // Mode detection using cached recipient
122
+ const hasRecipient = !!cached.recipient;
123
+ const isTestnet = !userKey && !hasRecipient;
124
+ const privateKey = userKey || (isTestnet ? tryit.tryitKey : "");
126
125
  // Rare Protocol path: mint via SuperRare contracts on Base
127
126
  if (cachedPlatform === "superrare") {
128
127
  if (!privateKey) {
@@ -257,6 +256,8 @@ export async function handleMint(params, calldataService, defaultRecipient, user
257
256
  };
258
257
  }
259
258
  const recipient = params.recipient || defaultRecipient;
259
+ const hasRecipient = !!recipient;
260
+ const isTestnet = !userKey && !hasRecipient;
260
261
  if (!recipient) {
261
262
  return {
262
263
  content: [{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mint-day",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Agent-native minting on Base. One tool call, any token type.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
package/src/tools/mint.ts CHANGED
@@ -110,8 +110,9 @@ async function sponsoredMint(result: { to: string; calldata: string; value: stri
110
110
  explorer: data.explorer,
111
111
  sponsored: true,
112
112
  };
113
- } catch {
114
- return null;
113
+ } catch (err) {
114
+ const message = err instanceof Error ? err.message : String(err);
115
+ return { error: `Sponsor request failed: ${message}` };
115
116
  }
116
117
  }
117
118
 
@@ -132,14 +133,8 @@ export async function handleMint(
132
133
  userKey: string = "",
133
134
  tryit: TryitConfig = { tryitKey: "", tryitContract: "", tryitRpc: "", tryitChain: 84532 },
134
135
  ) {
135
- // Determine mode:
136
- // 1. User has private key: mainnet, sign + submit locally
137
- // 2. No key but recipient provided: mainnet, sponsored gas via server
138
- // 3. No key, no recipient: testnet try-it mode
139
- const hasRecipient = !!params.recipient;
140
- const isTestnet = !userKey && !hasRecipient;
141
- const privateKey = userKey || (isTestnet ? tryit.tryitKey : "");
142
136
  // Confirmation path: replay cached intent
137
+ // Check cache first so we can use cached recipient for mode detection
143
138
  if (params.mintId) {
144
139
  const entry = getCachedEntry(params.mintId);
145
140
  if (!entry) {
@@ -154,6 +149,11 @@ export async function handleMint(
154
149
  const cachedPlatform = entry.platform;
155
150
  intentCache.delete(params.mintId);
156
151
 
152
+ // Mode detection using cached recipient
153
+ const hasRecipient = !!cached.recipient;
154
+ const isTestnet = !userKey && !hasRecipient;
155
+ const privateKey = userKey || (isTestnet ? tryit.tryitKey : "");
156
+
157
157
  // Rare Protocol path: mint via SuperRare contracts on Base
158
158
  if (cachedPlatform === "superrare") {
159
159
  if (!privateKey) {
@@ -292,6 +292,8 @@ export async function handleMint(
292
292
  }
293
293
 
294
294
  const recipient = params.recipient || defaultRecipient;
295
+ const hasRecipient = !!recipient;
296
+ const isTestnet = !userKey && !hasRecipient;
295
297
 
296
298
  if (!recipient) {
297
299
  return {