@sats-connect/core 0.0.4-caef0cb → 0.0.5-4f78052
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 +16 -0
- package/dist/index.mjs +51 -21
- package/package.json +1 -1
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
|
}
|
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__ */ ((
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return
|
|
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
|
|
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:
|
|
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
|
}
|
|
@@ -468,10 +500,8 @@ var UnisatAdapter = class extends SatsConnectAdapter {
|
|
|
468
500
|
if (!purposes.includes("stacks" /* Stacks */)) {
|
|
469
501
|
throw new Error("Only bitcoin addresses are supported");
|
|
470
502
|
}
|
|
471
|
-
const
|
|
472
|
-
|
|
473
|
-
window.unisat.getPublicKey()
|
|
474
|
-
]);
|
|
503
|
+
const accounts = await window.unisat.requestAccounts();
|
|
504
|
+
const publicKey = await window.unisat.getPublicKey();
|
|
475
505
|
const address = accounts[0];
|
|
476
506
|
const addressType = getAddressInfo(accounts[0]).type;
|
|
477
507
|
const pk = addressType === AddressType2.p2tr ? publicKey.slice(2) : publicKey;
|