@sats-connect/core 0.0.4 → 0.0.5-bf6378b

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
@@ -427,6 +427,16 @@ type CreateEtchOrderRequest = {
427
427
  appServiceFeeAddress?: string;
428
428
  };
429
429
  type EstimateEtchOrderRequest = Omit<CreateEtchOrderRequest, 'refundAddress'>;
430
+ type GetOrderRequest = {
431
+ id: string;
432
+ };
433
+ type GetOrderResponse = {
434
+ id: string;
435
+ orderType: 'rune_mint' | 'rune_etch';
436
+ state: 'new' | 'pending' | 'executing' | 'complete' | 'failed' | 'refunded' | 'stale';
437
+ reason?: string;
438
+ createdAt: string;
439
+ };
430
440
 
431
441
  interface EstimateRunesMintParams extends EstimateMintOrderRequest {
432
442
  network?: BitcoinNetworkType;
@@ -454,6 +464,10 @@ type EtchRunesResult = {
454
464
  fundTransactionId: string;
455
465
  };
456
466
  type EtchRunes = MethodParamsAndResult<EtchRunesParams, EtchRunesResult>;
467
+ interface GetOrderParams extends GetOrderRequest {
468
+ network?: BitcoinNetworkType;
469
+ }
470
+ type GetOrder = MethodParamsAndResult<GetOrderParams, GetOrderResponse>;
457
471
 
458
472
  interface Pubkey {
459
473
  /**
@@ -660,6 +674,7 @@ interface RunesRequests {
660
674
  runes_mint: MintRunes;
661
675
  runes_estimateEtch: EstimateRunesEtch;
662
676
  runes_etch: EtchRunes;
677
+ runes_getOrder: GetOrder;
663
678
  }
664
679
  type RunesRequestMethod = keyof RunesRequests;
665
680
  type Requests = BtcRequests & StxRequests & RunesRequests;
@@ -674,6 +689,7 @@ declare abstract class SatsConnectAdapter {
674
689
  private etchRunes;
675
690
  private estimateMint;
676
691
  private estimateEtch;
692
+ private getOrder;
677
693
  request<Method extends keyof Requests>(method: Method, params: Params<Method>): Promise<RpcResult<Method> | undefined>;
678
694
  protected abstract requestInternal<Method extends keyof Requests>(method: Method, params: Params<Method>): Promise<RpcResult<Method> | undefined>;
679
695
  }
@@ -687,9 +703,4 @@ declare class BaseAdapter extends SatsConnectAdapter {
687
703
  declare const DefaultAdaptersInfo: Record<string, Provider>;
688
704
  declare const defaultAdapters: Record<string, new () => SatsConnectAdapter>;
689
705
 
690
- interface Config {
691
- providers: SupportedWallet[];
692
- }
693
- declare function createDefaultConfig(providers: SupportedWallet[]): Config;
694
-
695
- export { type Address$1 as Address, AddressPurpose, AddressType, BaseAdapter, type BitcoinNetwork, BitcoinNetworkType, type BitcoinProvider, type BtcRequestMethod, type BtcRequests, type CallContractParams, type CallContractResult, type Capability, type Config, type CreateInscriptionOptions, type CreateInscriptionPayload, type CreateInscriptionResponse, type CreateRepeatInscriptionsOptions, type CreateRepeatInscriptionsPayload, type CreateRepeatInscriptionsResponse, DefaultAdaptersInfo, type DeployContractParams, type DeployContractResult, type GetAccountResult, type GetAccounts, type GetAccountsParams, type GetAccountsResult, type GetAddressOptions, type GetAddressPayload, type GetAddressResponse, type GetAddresses, type GetAddressesParams, type GetAddressesResult, type GetCapabilitiesOptions, type GetCapabilitiesPayload, type GetCapabilitiesResponse, type GetInfo, type InputToSign, type MethodParamsAndResult, type Params, type Provider, type PsbtPayload, type Recipient$2 as Recipient, type RequestOptions, type RequestPayload, type Requests, type Return, type RpcBase, type RpcError, RpcErrorCode, type RpcErrorResponse, type RpcId, type RpcRequest, type RpcResponse, type RpcResult, type RpcSuccessResponse, type RunesRequestMethod, type RunesRequests, SatsConnectAdapter, type SendBtcTransactionOptions, type SendBtcTransactionPayload, type SendBtcTransactionResponse, type SendTransfer, type SendTransferParams, type SerializedRecipient, type SerializedSendBtcTransactionPayload, type SignMessage, type SignMessageOptions, type SignMessageParams, type SignMessagePayload, type SignMessageResponse, type SignMultiplePsbtPayload, type SignMultipleTransactionOptions, type SignMultipleTransactionsPayload, type SignMultipleTransactionsResponse, type SignPsbt, type SignPsbtParams, type SignPsbtResult, type SignStructuredMessageResult, type SignStxMessageParams, type SignStxMessageResult, type SignTransactionOptions, type SignTransactionParams, type SignTransactionPayload, type SignTransactionResponse, type SignTransactionResult, type StxCallContract, type StxDeployContract, type StxGetAccounts, type StxGetAddresses, type StxRequestMethod, type StxRequests, type StxSignStructuredMessage, type StxSignStxMessage, type StxSignTransaction, type StxTransferStx, type SupportedWallet, type TransferStxParams, type TransferStxResult, createDefaultConfig, createInscription, createRepeatInscriptions, defaultAdapters, getAddress, getCapabilities, getDefaultProvider, getProviderById, getProviderOrThrow, getProviders, getSupportedWallets, isProviderInstalled, removeDefaultProvider, request, sendBtcTransaction, setDefaultProvider, signMessage, signMultipleTransactions, signTransaction };
706
+ export { type Address$1 as Address, AddressPurpose, AddressType, BaseAdapter, type BitcoinNetwork, BitcoinNetworkType, type BitcoinProvider, type BtcRequestMethod, type BtcRequests, type CallContractParams, type CallContractResult, type Capability, type CreateInscriptionOptions, type CreateInscriptionPayload, type CreateInscriptionResponse, type CreateRepeatInscriptionsOptions, type CreateRepeatInscriptionsPayload, type CreateRepeatInscriptionsResponse, DefaultAdaptersInfo, type DeployContractParams, type DeployContractResult, type GetAccountResult, type GetAccounts, type GetAccountsParams, type GetAccountsResult, type GetAddressOptions, type GetAddressPayload, type GetAddressResponse, type GetAddresses, type GetAddressesParams, type GetAddressesResult, type GetCapabilitiesOptions, type GetCapabilitiesPayload, type GetCapabilitiesResponse, type GetInfo, type InputToSign, type MethodParamsAndResult, type Params, type Provider, type PsbtPayload, type Recipient$2 as Recipient, type RequestOptions, type RequestPayload, type Requests, type Return, type RpcBase, type RpcError, RpcErrorCode, type RpcErrorResponse, type RpcId, type RpcRequest, type RpcResponse, type RpcResult, type RpcSuccessResponse, type RunesRequestMethod, type RunesRequests, SatsConnectAdapter, type SendBtcTransactionOptions, type SendBtcTransactionPayload, type SendBtcTransactionResponse, type SendTransfer, type SendTransferParams, type SerializedRecipient, type SerializedSendBtcTransactionPayload, type SignMessage, type SignMessageOptions, type SignMessageParams, type SignMessagePayload, type SignMessageResponse, type SignMultiplePsbtPayload, type SignMultipleTransactionOptions, type SignMultipleTransactionsPayload, type SignMultipleTransactionsResponse, type SignPsbt, type SignPsbtParams, type SignPsbtResult, type SignStructuredMessageResult, type SignStxMessageParams, type SignStxMessageResult, type SignTransactionOptions, type SignTransactionParams, type SignTransactionPayload, type SignTransactionResponse, type SignTransactionResult, type StxCallContract, type StxDeployContract, type StxGetAccounts, type StxGetAddresses, type StxRequestMethod, type StxRequests, type StxSignStructuredMessage, type StxSignStxMessage, type StxSignTransaction, type StxTransferStx, type SupportedWallet, type TransferStxParams, type TransferStxResult, createInscription, createRepeatInscriptions, defaultAdapters, getAddress, getCapabilities, getDefaultProvider, getProviderById, getProviderOrThrow, getProviders, getSupportedWallets, isProviderInstalled, removeDefaultProvider, request, sendBtcTransaction, setDefaultProvider, signMessage, signMultipleTransactions, signTransaction };
package/dist/index.mjs CHANGED
@@ -4,25 +4,25 @@ var BitcoinNetworkType = /* @__PURE__ */ ((BitcoinNetworkType2) => {
4
4
  BitcoinNetworkType2["Testnet"] = "Testnet";
5
5
  return BitcoinNetworkType2;
6
6
  })(BitcoinNetworkType || {});
7
- var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode3) => {
8
- RpcErrorCode3[RpcErrorCode3["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
9
- RpcErrorCode3[RpcErrorCode3["INVALID_REQUEST"] = -32600] = "INVALID_REQUEST";
10
- RpcErrorCode3[RpcErrorCode3["METHOD_NOT_FOUND"] = -32601] = "METHOD_NOT_FOUND";
11
- RpcErrorCode3[RpcErrorCode3["INVALID_PARAMS"] = -32602] = "INVALID_PARAMS";
12
- RpcErrorCode3[RpcErrorCode3["INTERNAL_ERROR"] = -32603] = "INTERNAL_ERROR";
13
- RpcErrorCode3[RpcErrorCode3["USER_REJECTION"] = -32e3] = "USER_REJECTION";
14
- RpcErrorCode3[RpcErrorCode3["METHOD_NOT_SUPPORTED"] = -32001] = "METHOD_NOT_SUPPORTED";
15
- return RpcErrorCode3;
7
+ var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
8
+ RpcErrorCode2[RpcErrorCode2["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
9
+ RpcErrorCode2[RpcErrorCode2["INVALID_REQUEST"] = -32600] = "INVALID_REQUEST";
10
+ RpcErrorCode2[RpcErrorCode2["METHOD_NOT_FOUND"] = -32601] = "METHOD_NOT_FOUND";
11
+ RpcErrorCode2[RpcErrorCode2["INVALID_PARAMS"] = -32602] = "INVALID_PARAMS";
12
+ RpcErrorCode2[RpcErrorCode2["INTERNAL_ERROR"] = -32603] = "INTERNAL_ERROR";
13
+ RpcErrorCode2[RpcErrorCode2["USER_REJECTION"] = -32e3] = "USER_REJECTION";
14
+ RpcErrorCode2[RpcErrorCode2["METHOD_NOT_SUPPORTED"] = -32001] = "METHOD_NOT_SUPPORTED";
15
+ return RpcErrorCode2;
16
16
  })(RpcErrorCode || {});
17
17
 
18
18
  // src/runes/index.ts
19
19
  import axios from "axios";
20
- var RUNES_API_BASE_URL = (network = "Mainnet" /* Mainnet */) => `https://ordinals${network === "Testnet" /* Testnet */ ? "-testnet" : ""}.xverse.app/v1/runes`;
20
+ var ORDINALS_API_BASE_URL = (network = "Mainnet" /* Mainnet */) => `https://ordinals${network === "Testnet" /* Testnet */ ? "-testnet" : ""}.xverse.app/v1`;
21
21
  var RunesApi = class {
22
22
  client;
23
23
  constructor(network) {
24
24
  this.client = axios.create({
25
- baseURL: `${RUNES_API_BASE_URL(network)}`
25
+ baseURL: ORDINALS_API_BASE_URL(network)
26
26
  });
27
27
  }
28
28
  parseError = (error) => {
@@ -33,7 +33,7 @@ var RunesApi = class {
33
33
  };
34
34
  estimateMintCost = async (mintParams) => {
35
35
  try {
36
- const response = await this.client.post("/mint/estimate", {
36
+ const response = await this.client.post("/runes/mint/estimate", {
37
37
  ...mintParams
38
38
  });
39
39
  return {
@@ -48,7 +48,7 @@ var RunesApi = class {
48
48
  };
49
49
  estimateEtchCost = async (etchParams) => {
50
50
  try {
51
- const response = await this.client.post("/etch/estimate", {
51
+ const response = await this.client.post("/runes/etch/estimate", {
52
52
  ...etchParams
53
53
  });
54
54
  return {
@@ -63,7 +63,7 @@ var RunesApi = class {
63
63
  };
64
64
  createMintOrder = async (mintOrderParams) => {
65
65
  try {
66
- const response = await this.client.post("/mint/orders", {
66
+ const response = await this.client.post("/runes/mint/orders", {
67
67
  ...mintOrderParams
68
68
  });
69
69
  return {
@@ -78,7 +78,7 @@ var RunesApi = class {
78
78
  };
79
79
  createEtchOrder = async (etchOrderParams) => {
80
80
  try {
81
- const response = await this.client.post("/etch/orders", {
81
+ const response = await this.client.post("/runes/etch/orders", {
82
82
  ...etchOrderParams
83
83
  });
84
84
  return {
@@ -93,7 +93,7 @@ var RunesApi = class {
93
93
  };
94
94
  executeMint = async (orderId, fundTransactionId) => {
95
95
  try {
96
- const response = await this.client.post(`/mint/orders/${orderId}/execute`, {
96
+ const response = await this.client.post(`/runes/mint/orders/${orderId}/execute`, {
97
97
  fundTransactionId
98
98
  });
99
99
  return {
@@ -108,7 +108,7 @@ var RunesApi = class {
108
108
  };
109
109
  executeEtch = async (orderId, fundTransactionId) => {
110
110
  try {
111
- const response = await this.client.post(`/etch/orders/${orderId}/execute`, {
111
+ const response = await this.client.post(`/runes/etch/orders/${orderId}/execute`, {
112
112
  fundTransactionId
113
113
  });
114
114
  return {
@@ -121,6 +121,19 @@ var RunesApi = class {
121
121
  };
122
122
  }
123
123
  };
124
+ getOrder = async (orderId) => {
125
+ try {
126
+ const response = await this.client.get(`/orders/${orderId}`);
127
+ return {
128
+ data: response.data
129
+ };
130
+ } catch (error) {
131
+ const err = error;
132
+ return {
133
+ error: this.parseError(err)
134
+ };
135
+ }
136
+ };
124
137
  };
125
138
  var testnetClient = new RunesApi("Testnet" /* Testnet */);
126
139
  var mainnetClient = new RunesApi("Mainnet" /* Mainnet */);
@@ -308,6 +321,22 @@ var SatsConnectAdapter = class {
308
321
  }
309
322
  };
310
323
  }
324
+ async getOrder(params) {
325
+ const response = await getRunesApiClient(params.network).getOrder(params.id);
326
+ if (response.data) {
327
+ return {
328
+ status: "success",
329
+ result: response.data
330
+ };
331
+ }
332
+ return {
333
+ status: "error",
334
+ error: {
335
+ code: response.error.code === 400 ? -32600 /* INVALID_REQUEST */ : -32603 /* INTERNAL_ERROR */,
336
+ message: response.error.message
337
+ }
338
+ };
339
+ }
311
340
  async request(method, params) {
312
341
  switch (method) {
313
342
  case "runes_mint":
@@ -318,6 +347,9 @@ var SatsConnectAdapter = class {
318
347
  return this.estimateMint(params);
319
348
  case "runes_estimateEtch":
320
349
  return this.estimateEtch(params);
350
+ case "runes_getOrder": {
351
+ return this.getOrder(params);
352
+ }
321
353
  default:
322
354
  return this.requestInternal(method, params);
323
355
  }
@@ -845,30 +877,6 @@ var signMultipleTransactions = async (options) => {
845
877
  options.onCancel?.();
846
878
  }
847
879
  };
848
-
849
- // src/ui/index.ts
850
- function createDefaultConfig(providers) {
851
- const config = { providers: [] };
852
- const xverseProvider = providers.find(
853
- (provider) => provider.id === DefaultAdaptersInfo.xverse.id
854
- );
855
- config.providers.push(
856
- xverseProvider ? xverseProvider : {
857
- ...DefaultAdaptersInfo.xverse,
858
- isInstalled: false
859
- }
860
- );
861
- const unisatProvider = providers.find((provider) => provider.id === "unisat");
862
- if (unisatProvider && unisatProvider.isInstalled) {
863
- config.providers.push(unisatProvider);
864
- }
865
- config.providers.concat(
866
- providers.filter((provider) => {
867
- return provider.id !== DefaultAdaptersInfo.xverse.id && provider.id !== "unisat";
868
- })
869
- );
870
- return config;
871
- }
872
880
  export {
873
881
  AddressPurpose,
874
882
  AddressType,
@@ -877,7 +885,6 @@ export {
877
885
  DefaultAdaptersInfo,
878
886
  RpcErrorCode,
879
887
  SatsConnectAdapter,
880
- createDefaultConfig,
881
888
  createInscription,
882
889
  createRepeatInscriptions,
883
890
  defaultAdapters,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sats-connect/core",
3
- "version": "0.0.4",
3
+ "version": "0.0.5-bf6378b",
4
4
  "main": "dist/index.mjs",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.mts",