@sats-connect/core 0.0.9 → 0.0.10-294372d

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.
package/dist/index.d.mts CHANGED
@@ -730,14 +730,14 @@ declare abstract class SatsConnectAdapter {
730
730
  private getOrder;
731
731
  private estimateRbfOrder;
732
732
  private rbfOrder;
733
- request<Method extends keyof Requests>(method: Method, params: Params<Method>): Promise<RpcResult<Method> | undefined>;
734
- protected abstract requestInternal<Method extends keyof Requests>(method: Method, params: Params<Method>): Promise<RpcResult<Method> | undefined>;
733
+ request<Method extends keyof Requests>(method: Method, params: Params<Method>): Promise<RpcResult<Method>>;
734
+ protected abstract requestInternal<Method extends keyof Requests>(method: Method, params: Params<Method>): Promise<RpcResult<Method>>;
735
735
  }
736
736
 
737
737
  declare class BaseAdapter extends SatsConnectAdapter {
738
738
  id: string;
739
739
  constructor(providerId: string);
740
- requestInternal: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests>(method: Method, params: Params<Method>) => Promise<RpcResult<Method> | undefined>;
740
+ requestInternal: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests>(method: Method, params: Params<Method>) => Promise<RpcResult<Method>>;
741
741
  }
742
742
 
743
743
  declare const DefaultAdaptersInfo: Record<string, Provider>;
package/dist/index.mjs CHANGED
@@ -159,6 +159,16 @@ var getRunesApiClient = (network = "Mainnet" /* Mainnet */) => network === "Main
159
159
  var SatsConnectAdapter = class {
160
160
  async mintRunes(params) {
161
161
  try {
162
+ const walletInfo = await this.requestInternal("getInfo", null).catch(() => null);
163
+ if (walletInfo && walletInfo.status === "success") {
164
+ const isMintSupported = walletInfo.result.methods?.includes("runes_mint");
165
+ if (isMintSupported) {
166
+ const response = await this.requestInternal("runes_mint", params);
167
+ if (response) {
168
+ return response;
169
+ }
170
+ }
171
+ }
162
172
  const mintRequest = {
163
173
  destinationAddress: params.destinationAddress,
164
174
  feeRate: params.feeRate,
@@ -186,14 +196,8 @@ var SatsConnectAdapter = class {
186
196
  }
187
197
  ]
188
198
  });
189
- if (paymentResponse?.status !== "success") {
190
- return {
191
- status: "error",
192
- error: {
193
- code: -32e3 /* USER_REJECTION */,
194
- message: "User rejected the payment request"
195
- }
196
- };
199
+ if (paymentResponse.status !== "success") {
200
+ return paymentResponse;
197
201
  }
198
202
  await new RunesApi(params.network).executeMint(
199
203
  orderResponse.data.orderId,
@@ -234,6 +238,16 @@ var SatsConnectAdapter = class {
234
238
  appServiceFeeAddress: params.appServiceFeeAddress
235
239
  };
236
240
  try {
241
+ const walletInfo = await this.requestInternal("getInfo", null).catch(() => null);
242
+ if (walletInfo && walletInfo.status === "success") {
243
+ const isEtchSupported = walletInfo.result.methods?.includes("runes_etch");
244
+ if (isEtchSupported) {
245
+ const response = await this.requestInternal("runes_etch", params);
246
+ if (response) {
247
+ return response;
248
+ }
249
+ }
250
+ }
237
251
  const orderResponse = await new RunesApi(params.network).createEtchOrder(etchRequest);
238
252
  if (!orderResponse.data) {
239
253
  return {
@@ -252,14 +266,8 @@ var SatsConnectAdapter = class {
252
266
  }
253
267
  ]
254
268
  });
255
- if (paymentResponse?.status !== "success") {
256
- return {
257
- status: "error",
258
- error: {
259
- code: -32e3 /* USER_REJECTION */,
260
- message: "User rejected the payment request"
261
- }
262
- };
269
+ if (paymentResponse.status !== "success") {
270
+ return paymentResponse;
263
271
  }
264
272
  await new RunesApi(params.network).executeEtch(
265
273
  orderResponse.data.orderId,
@@ -402,14 +410,8 @@ var SatsConnectAdapter = class {
402
410
  }
403
411
  ]
404
412
  });
405
- if (paymentResponse?.status !== "success") {
406
- return {
407
- status: "error",
408
- error: {
409
- code: -32e3 /* USER_REJECTION */,
410
- message: "User rejected the payment request"
411
- }
412
- };
413
+ if (paymentResponse.status !== "success") {
414
+ return paymentResponse;
413
415
  }
414
416
  return {
415
417
  status: "success",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sats-connect/core",
3
- "version": "0.0.9",
3
+ "version": "0.0.10-294372d",
4
4
  "main": "dist/index.mjs",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.mts",