@arkade-os/sdk 0.5.0-rc.11 → 0.5.0-rc.13
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/README.md +43 -12
- package/dist/adapters/expo.cjs +5 -5
- package/dist/adapters/expo.d.cts +2 -2
- package/dist/adapters/expo.d.ts +2 -2
- package/dist/adapters/expo.js +3 -3
- package/dist/{asyncStorageTaskQueue-DBaZsltv.d.cts → asyncStorageTaskQueue-0EeSeCAt.d.cts} +1 -1
- package/dist/{asyncStorageTaskQueue-uAG3XLyg.d.ts → asyncStorageTaskQueue-DV94jhwq.d.ts} +1 -1
- package/dist/{chunk-WSQAWSEH.js → chunk-3JLYJ5KZ.js} +75 -237
- package/dist/chunk-3JLYJ5KZ.js.map +1 -0
- package/dist/{chunk-VMLLYEYM.js → chunk-4EU2Q6YT.js} +12 -14
- package/dist/chunk-4EU2Q6YT.js.map +1 -0
- package/dist/{chunk-IA32YGLH.cjs → chunk-7BACS4XK.cjs} +10 -10
- package/dist/chunk-7BACS4XK.cjs.map +1 -0
- package/dist/{chunk-5OBGYL6U.cjs → chunk-7NK6XFC3.cjs} +120 -194
- package/dist/chunk-7NK6XFC3.cjs.map +1 -0
- package/dist/{chunk-CQPQ7D4U.cjs → chunk-BFQX2KS3.cjs} +87 -248
- package/dist/chunk-BFQX2KS3.cjs.map +1 -0
- package/dist/{chunk-DD6MTNAS.js → chunk-D7JLTHSZ.js} +5 -5
- package/dist/chunk-D7JLTHSZ.js.map +1 -0
- package/dist/{chunk-CMLSTGOC.js → chunk-EJYWGTZ7.js} +119 -194
- package/dist/chunk-EJYWGTZ7.js.map +1 -0
- package/dist/{chunk-T2ILYGWE.cjs → chunk-FDQQOF3F.cjs} +327 -1080
- package/dist/chunk-FDQQOF3F.cjs.map +1 -0
- package/dist/{chunk-MGDXN74N.cjs → chunk-I4YBVHAK.cjs} +2357 -3374
- package/dist/chunk-I4YBVHAK.cjs.map +1 -0
- package/dist/{chunk-M2ZUPLKQ.js → chunk-IV2252XM.js} +1946 -2977
- package/dist/chunk-IV2252XM.js.map +1 -0
- package/dist/{chunk-OMJRW2D5.js → chunk-JOUPIZ32.js} +263 -1036
- package/dist/chunk-JOUPIZ32.js.map +1 -0
- package/dist/{chunk-PWEBQNIE.cjs → chunk-RDQSVIXD.cjs} +22 -24
- package/dist/chunk-RDQSVIXD.cjs.map +1 -0
- package/dist/contracts/handlers/index.cjs +9 -9
- package/dist/contracts/handlers/index.d.cts +3 -3
- package/dist/contracts/handlers/index.d.ts +3 -3
- package/dist/contracts/handlers/index.js +2 -2
- package/dist/{delegate-DFwlkVYR.d.cts → delegate-BgpUJW5B.d.cts} +1 -1
- package/dist/{delegate-D3YHDERL.d.ts → delegate-BuagcGnG.d.ts} +1 -1
- package/dist/{index-DTvUv5lD.d.cts → index-CKmB14Yu.d.cts} +1145 -2263
- package/dist/{index-DTvUv5lD.d.ts → index-CKmB14Yu.d.ts} +1145 -2263
- package/dist/index-D0BuYwhF.d.cts +637 -0
- package/dist/index-DbzyrqK7.d.ts +637 -0
- package/dist/index.cjs +341 -297
- package/dist/index.d.cts +379 -788
- package/dist/index.d.ts +379 -788
- package/dist/index.js +4 -4
- package/dist/repositories/realm/index.cjs +142 -101
- package/dist/repositories/realm/index.cjs.map +1 -1
- package/dist/repositories/realm/index.d.cts +13 -11
- package/dist/repositories/realm/index.d.ts +13 -11
- package/dist/repositories/realm/index.js +130 -89
- package/dist/repositories/realm/index.js.map +1 -1
- package/dist/repositories/sqlite/index.cjs +158 -118
- package/dist/repositories/sqlite/index.cjs.map +1 -1
- package/dist/repositories/sqlite/index.d.cts +14 -13
- package/dist/repositories/sqlite/index.d.ts +14 -13
- package/dist/repositories/sqlite/index.js +147 -107
- package/dist/repositories/sqlite/index.js.map +1 -1
- package/dist/{taskRunner-B5bl0YRt.d.ts → taskRunner-BX-pB0sv.d.ts} +1 -1
- package/dist/{taskRunner--sKy9Inv.d.cts → taskRunner-DJrFFyus.d.cts} +1 -1
- package/dist/wallet/expo/background.cjs +14 -14
- package/dist/wallet/expo/background.cjs.map +1 -1
- package/dist/wallet/expo/background.d.cts +8 -14
- package/dist/wallet/expo/background.d.ts +8 -14
- package/dist/wallet/expo/background.js +6 -6
- package/dist/wallet/expo/background.js.map +1 -1
- package/dist/wallet/expo/index.cjs +14 -14
- package/dist/wallet/expo/index.cjs.map +1 -1
- package/dist/wallet/expo/index.d.cts +5 -5
- package/dist/wallet/expo/index.d.ts +5 -5
- package/dist/wallet/expo/index.js +5 -5
- package/dist/wallet/expo/index.js.map +1 -1
- package/dist/wallet-BsL2G3Qb.d.cts +1542 -0
- package/dist/wallet-DXNiCmq8.d.ts +1542 -0
- package/dist/worker/expo/index.cjs +9 -9
- package/dist/worker/expo/index.d.cts +4 -4
- package/dist/worker/expo/index.d.ts +4 -4
- package/dist/worker/expo/index.js +5 -5
- package/package.json +3 -2
- package/dist/chunk-5OBGYL6U.cjs.map +0 -1
- package/dist/chunk-CMLSTGOC.js.map +0 -1
- package/dist/chunk-CQPQ7D4U.cjs.map +0 -1
- package/dist/chunk-DD6MTNAS.js.map +0 -1
- package/dist/chunk-IA32YGLH.cjs.map +0 -1
- package/dist/chunk-M2ZUPLKQ.js.map +0 -1
- package/dist/chunk-MGDXN74N.cjs.map +0 -1
- package/dist/chunk-OMJRW2D5.js.map +0 -1
- package/dist/chunk-PWEBQNIE.cjs.map +0 -1
- package/dist/chunk-T2ILYGWE.cjs.map +0 -1
- package/dist/chunk-VMLLYEYM.js.map +0 -1
- package/dist/chunk-WSQAWSEH.js.map +0 -1
- package/dist/hdWalletCapable-C350s3bP.d.ts +0 -2206
- package/dist/hdWalletCapable-rrOmXcbT.d.cts +0 -2206
- package/dist/index-C0ZyGoyP.d.cts +0 -850
- package/dist/index-DASN1cVk.d.ts +0 -850
|
@@ -97,12 +97,7 @@ function setArkPsbtField(tx, inputIndex, coder, value) {
|
|
|
97
97
|
}
|
|
98
98
|
function getArkPsbtFields(tx, inputIndex, coder) {
|
|
99
99
|
const unknown = tx.getInput(inputIndex)?.unknown ?? [];
|
|
100
|
-
|
|
101
|
-
for (const u of unknown) {
|
|
102
|
-
const v = coder.decode(u);
|
|
103
|
-
if (v !== null) fields.push(v);
|
|
104
|
-
}
|
|
105
|
-
return fields;
|
|
100
|
+
return unknown.map((u) => coder.decode(u)).filter((v) => v !== null);
|
|
106
101
|
}
|
|
107
102
|
var VtxoTaprootTree = {
|
|
108
103
|
key: "taptree" /* VtxoTaprootTree */,
|
|
@@ -184,7 +179,7 @@ var VtxoTreeExpiry = {
|
|
|
184
179
|
type: ArkPsbtFieldKeyType,
|
|
185
180
|
key: encodedPsbtFieldKey["expiry" /* VtxoTreeExpiry */]
|
|
186
181
|
},
|
|
187
|
-
btcSigner.ScriptNum(6, true).encode(value.value
|
|
182
|
+
btcSigner.ScriptNum(6, true).encode(value.value)
|
|
188
183
|
],
|
|
189
184
|
decode: (unknown) => nullIfCatch(() => {
|
|
190
185
|
if (!checkKeyMatch(unknown[0], "expiry" /* VtxoTreeExpiry */)) return null;
|
|
@@ -596,6 +591,16 @@ exports.CSVMultisigTapscript = void 0;
|
|
|
596
591
|
}
|
|
597
592
|
CSVMultisigTapscript2.isScriptValid = isScriptValid;
|
|
598
593
|
})(exports.CSVMultisigTapscript || (exports.CSVMultisigTapscript = {}));
|
|
594
|
+
function isConditionScriptValid(script) {
|
|
595
|
+
const asm = btcSigner.Script.decode(script);
|
|
596
|
+
if (asm.length < 1) {
|
|
597
|
+
return new Error(`Invalid script: too short (expected at least 1)`);
|
|
598
|
+
}
|
|
599
|
+
if (asm.lastIndexOf("VERIFY") === -1) {
|
|
600
|
+
return new Error("Invalid script: missing VERIFY operation");
|
|
601
|
+
}
|
|
602
|
+
return true;
|
|
603
|
+
}
|
|
599
604
|
exports.ConditionCSVMultisigTapscript = void 0;
|
|
600
605
|
((ConditionCSVMultisigTapscript2) => {
|
|
601
606
|
function encode2(params) {
|
|
@@ -620,7 +625,7 @@ exports.ConditionCSVMultisigTapscript = void 0;
|
|
|
620
625
|
throw isValid;
|
|
621
626
|
}
|
|
622
627
|
const asm = btcSigner.Script.decode(script);
|
|
623
|
-
|
|
628
|
+
const verifyIndex = asm.lastIndexOf("VERIFY");
|
|
624
629
|
if (verifyIndex === -1) {
|
|
625
630
|
throw Error("Invalid script: missing VERIFY operation");
|
|
626
631
|
}
|
|
@@ -655,26 +660,8 @@ exports.ConditionCSVMultisigTapscript = void 0;
|
|
|
655
660
|
return tapscript.type === "condition-csv-multisig" /* ConditionCSVMultisig */;
|
|
656
661
|
}
|
|
657
662
|
ConditionCSVMultisigTapscript2.is = is;
|
|
658
|
-
function getVerifyIndex(asm) {
|
|
659
|
-
let verifyIndex = -1;
|
|
660
|
-
for (let i = asm.length - 1; i >= 0; i--) {
|
|
661
|
-
if (asm[i] === "VERIFY") {
|
|
662
|
-
verifyIndex = i;
|
|
663
|
-
return verifyIndex;
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
return verifyIndex;
|
|
667
|
-
}
|
|
668
663
|
function isScriptValid(script) {
|
|
669
|
-
|
|
670
|
-
if (asm.length < 1) {
|
|
671
|
-
return new Error(`Invalid script: too short (expected at least 1)`);
|
|
672
|
-
}
|
|
673
|
-
let verifyIndex = getVerifyIndex(asm);
|
|
674
|
-
if (verifyIndex === -1) {
|
|
675
|
-
return new Error("Invalid script: missing VERIFY operation");
|
|
676
|
-
}
|
|
677
|
-
return true;
|
|
664
|
+
return isConditionScriptValid(script);
|
|
678
665
|
}
|
|
679
666
|
ConditionCSVMultisigTapscript2.isScriptValid = isScriptValid;
|
|
680
667
|
})(exports.ConditionCSVMultisigTapscript || (exports.ConditionCSVMultisigTapscript = {}));
|
|
@@ -702,7 +689,7 @@ exports.ConditionMultisigTapscript = void 0;
|
|
|
702
689
|
throw isValid;
|
|
703
690
|
}
|
|
704
691
|
const asm = btcSigner.Script.decode(script);
|
|
705
|
-
|
|
692
|
+
const verifyIndex = asm.lastIndexOf("VERIFY");
|
|
706
693
|
if (verifyIndex === -1) {
|
|
707
694
|
throw Error("Invalid script: missing VERIFY operation");
|
|
708
695
|
}
|
|
@@ -737,26 +724,8 @@ exports.ConditionMultisigTapscript = void 0;
|
|
|
737
724
|
return tapscript.type === "condition-multisig" /* ConditionMultisig */;
|
|
738
725
|
}
|
|
739
726
|
ConditionMultisigTapscript2.is = is;
|
|
740
|
-
function getVerifyIndex(asm) {
|
|
741
|
-
let verifyIndex = -1;
|
|
742
|
-
for (let i = asm.length - 1; i >= 0; i--) {
|
|
743
|
-
if (asm[i] === "VERIFY") {
|
|
744
|
-
verifyIndex = i;
|
|
745
|
-
return verifyIndex;
|
|
746
|
-
}
|
|
747
|
-
}
|
|
748
|
-
return verifyIndex;
|
|
749
|
-
}
|
|
750
727
|
function isScriptValid(script) {
|
|
751
|
-
|
|
752
|
-
if (asm.length < 1) {
|
|
753
|
-
return new Error(`Invalid script: too short (expected at least 1)`);
|
|
754
|
-
}
|
|
755
|
-
let verifyIndex = getVerifyIndex(asm);
|
|
756
|
-
if (verifyIndex === -1) {
|
|
757
|
-
return new Error("Invalid script: missing VERIFY operation");
|
|
758
|
-
}
|
|
759
|
-
return true;
|
|
728
|
+
return isConditionScriptValid(script);
|
|
760
729
|
}
|
|
761
730
|
ConditionMultisigTapscript2.isScriptValid = isScriptValid;
|
|
762
731
|
})(exports.ConditionMultisigTapscript || (exports.ConditionMultisigTapscript = {}));
|
|
@@ -1049,7 +1018,7 @@ function resolveEventSource(override) {
|
|
|
1049
1018
|
}
|
|
1050
1019
|
|
|
1051
1020
|
// package.json
|
|
1052
|
-
var version = "0.5.0-rc.
|
|
1021
|
+
var version = "0.5.0-rc.13";
|
|
1053
1022
|
|
|
1054
1023
|
// src/utils/fetch.ts
|
|
1055
1024
|
var buildVersion = "0.9.9";
|
|
@@ -1106,27 +1075,12 @@ function baseFetch(input, init) {
|
|
|
1106
1075
|
}
|
|
1107
1076
|
function fetch(input, init) {
|
|
1108
1077
|
const headers = new Headers(init?.headers);
|
|
1109
|
-
headers.set(
|
|
1110
|
-
headers.set("X-SDK-VERSION", sdkVersion);
|
|
1078
|
+
for (const [name, value] of Object.entries(ARKADE_VERSION_HEADERS)) headers.set(name, value);
|
|
1111
1079
|
return baseFetch(input, { ...init, headers });
|
|
1112
1080
|
}
|
|
1113
1081
|
function describeRequest(input, init) {
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
url = input;
|
|
1117
|
-
} else if (input instanceof URL) {
|
|
1118
|
-
url = input.href;
|
|
1119
|
-
} else {
|
|
1120
|
-
url = input.url;
|
|
1121
|
-
}
|
|
1122
|
-
let method;
|
|
1123
|
-
if (init?.method !== void 0) {
|
|
1124
|
-
method = init.method;
|
|
1125
|
-
} else if (input instanceof Request) {
|
|
1126
|
-
method = input.method;
|
|
1127
|
-
} else {
|
|
1128
|
-
method = "GET";
|
|
1129
|
-
}
|
|
1082
|
+
const url = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
1083
|
+
const method = init?.method !== void 0 ? init.method : input instanceof Request ? input.method : "GET";
|
|
1130
1084
|
return { url, method };
|
|
1131
1085
|
}
|
|
1132
1086
|
|
|
@@ -1150,13 +1104,10 @@ var ArkErrorName = {
|
|
|
1150
1104
|
INVALID_TX_FILTER: "INVALID_TX_FILTER",
|
|
1151
1105
|
TX_FILTERS_LIMIT_EXCEEDED: "TX_FILTERS_LIMIT_EXCEEDED",
|
|
1152
1106
|
/**
|
|
1153
|
-
* A CLTV closure was spent before its absolute locktime matured.
|
|
1154
|
-
* `
|
|
1155
|
-
*
|
|
1156
|
-
*
|
|
1157
|
-
* Self-healing, so defer and retry rather than fail: the server matures a
|
|
1158
|
-
* seconds-locktime against the **chain tip block's timestamp**, not its wall clock,
|
|
1159
|
-
* so a spend attempted promptly at maturity is rejected until a later block lands.
|
|
1107
|
+
* A CLTV closure was spent before its absolute locktime matured. `submitTx` only, with
|
|
1108
|
+
* metadata `{ locktime, current_locktime, type: "height" | "time" }`. Self-healing, so defer
|
|
1109
|
+
* and retry: the server matures a seconds-locktime against the **chain tip block's
|
|
1110
|
+
* timestamp**, not wall clock, so a prompt spend is rejected until a later block lands.
|
|
1160
1111
|
*/
|
|
1161
1112
|
FORFEIT_CLOSURE_LOCKED: "FORFEIT_CLOSURE_LOCKED"
|
|
1162
1113
|
};
|
|
@@ -1234,8 +1185,8 @@ exports.Intent = void 0;
|
|
|
1234
1185
|
}
|
|
1235
1186
|
if (ins.length == 0) throw new Error("intent proof requires at least one input");
|
|
1236
1187
|
const inputs = ins.map(prepareCoinAsIntentProofInput);
|
|
1237
|
-
|
|
1238
|
-
|
|
1188
|
+
validateInputs(inputs);
|
|
1189
|
+
validateOutputs(outputs);
|
|
1239
1190
|
const toSpend = craftToSpendTx(message, inputs[0].witnessUtxo.script);
|
|
1240
1191
|
return craftToSignTx(toSpend, inputs, outputs, message);
|
|
1241
1192
|
}
|
|
@@ -1300,7 +1251,6 @@ function validateInput(input) {
|
|
|
1300
1251
|
}
|
|
1301
1252
|
function validateInputs(inputs) {
|
|
1302
1253
|
inputs.forEach(validateInput);
|
|
1303
|
-
return true;
|
|
1304
1254
|
}
|
|
1305
1255
|
function validateOutput(output) {
|
|
1306
1256
|
if (output.amount === void 0) throw new Error("intent proof output requires amount");
|
|
@@ -1309,7 +1259,6 @@ function validateOutput(output) {
|
|
|
1309
1259
|
}
|
|
1310
1260
|
function validateOutputs(outputs) {
|
|
1311
1261
|
outputs.forEach(validateOutput);
|
|
1312
|
-
return true;
|
|
1313
1262
|
}
|
|
1314
1263
|
function craftToSpendTx(message, pkScript, tag = TAG_INTENT_PROOF) {
|
|
1315
1264
|
const messageHash = hashMessage(message, tag);
|
|
@@ -1754,6 +1703,20 @@ var RestArkProvider = class {
|
|
|
1754
1703
|
"Arkade server reported a configuration digest mismatch; server info was refreshed. Rebuild and retry the request under the new server info."
|
|
1755
1704
|
);
|
|
1756
1705
|
}
|
|
1706
|
+
async postJson(url, body, failureMessage) {
|
|
1707
|
+
const response = await this.authedFetch(url, {
|
|
1708
|
+
method: "POST",
|
|
1709
|
+
headers: {
|
|
1710
|
+
"Content-Type": "application/json"
|
|
1711
|
+
},
|
|
1712
|
+
body: JSON.stringify(body)
|
|
1713
|
+
});
|
|
1714
|
+
if (!response.ok) {
|
|
1715
|
+
const errorText = await response.text();
|
|
1716
|
+
handleError(errorText, failureMessage(errorText, response));
|
|
1717
|
+
}
|
|
1718
|
+
return response;
|
|
1719
|
+
}
|
|
1757
1720
|
async getInfo() {
|
|
1758
1721
|
const url = `${this.serverUrl}/v1/info`;
|
|
1759
1722
|
const response = await rateGate.runHttp(
|
|
@@ -1819,20 +1782,14 @@ var RestArkProvider = class {
|
|
|
1819
1782
|
}
|
|
1820
1783
|
async submitTx(signedArkTx, checkpointTxs) {
|
|
1821
1784
|
const url = `${this.serverUrl}/v1/tx/submit`;
|
|
1822
|
-
const response = await this.
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
"Content-Type": "application/json"
|
|
1826
|
-
},
|
|
1827
|
-
body: JSON.stringify({
|
|
1785
|
+
const response = await this.postJson(
|
|
1786
|
+
url,
|
|
1787
|
+
{
|
|
1828
1788
|
signedArkTx,
|
|
1829
1789
|
checkpointTxs
|
|
1830
|
-
}
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
const errorText = await response.text();
|
|
1834
|
-
handleError(errorText, `Failed to submit virtual transaction: ${errorText}`);
|
|
1835
|
-
}
|
|
1790
|
+
},
|
|
1791
|
+
(errorText) => `Failed to submit virtual transaction: ${errorText}`
|
|
1792
|
+
);
|
|
1836
1793
|
const data = await response.json();
|
|
1837
1794
|
return {
|
|
1838
1795
|
arkTxid: data.arkTxid,
|
|
@@ -1842,129 +1799,87 @@ var RestArkProvider = class {
|
|
|
1842
1799
|
}
|
|
1843
1800
|
async finalizeTx(arkTxid, finalCheckpointTxs) {
|
|
1844
1801
|
const url = `${this.serverUrl}/v1/tx/finalize`;
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
"Content-Type": "application/json"
|
|
1849
|
-
},
|
|
1850
|
-
body: JSON.stringify({
|
|
1802
|
+
await this.postJson(
|
|
1803
|
+
url,
|
|
1804
|
+
{
|
|
1851
1805
|
arkTxid,
|
|
1852
1806
|
finalCheckpointTxs
|
|
1853
|
-
}
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
const errorText = await response.text();
|
|
1857
|
-
handleError(errorText, `Failed to finalize offchain transaction: ${errorText}`);
|
|
1858
|
-
}
|
|
1807
|
+
},
|
|
1808
|
+
(errorText) => `Failed to finalize offchain transaction: ${errorText}`
|
|
1809
|
+
);
|
|
1859
1810
|
}
|
|
1860
1811
|
async registerIntent(intent) {
|
|
1861
1812
|
const url = `${this.serverUrl}/v1/batch/registerIntent`;
|
|
1862
|
-
const response = await this.
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
"Content-Type": "application/json"
|
|
1866
|
-
},
|
|
1867
|
-
body: JSON.stringify({
|
|
1813
|
+
const response = await this.postJson(
|
|
1814
|
+
url,
|
|
1815
|
+
{
|
|
1868
1816
|
intent: {
|
|
1869
1817
|
proof: intent.proof,
|
|
1870
1818
|
message: exports.Intent.encodeMessage(intent.message)
|
|
1871
1819
|
}
|
|
1872
|
-
}
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
const errorText = await response.text();
|
|
1876
|
-
handleError(errorText, `Failed to register intent: ${errorText}`);
|
|
1877
|
-
}
|
|
1820
|
+
},
|
|
1821
|
+
(errorText) => `Failed to register intent: ${errorText}`
|
|
1822
|
+
);
|
|
1878
1823
|
const data = await response.json();
|
|
1879
1824
|
return data.intentId;
|
|
1880
1825
|
}
|
|
1881
1826
|
async deleteIntent(intent) {
|
|
1882
1827
|
const url = `${this.serverUrl}/v1/batch/deleteIntent`;
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
"Content-Type": "application/json"
|
|
1887
|
-
},
|
|
1888
|
-
body: JSON.stringify({
|
|
1828
|
+
await this.postJson(
|
|
1829
|
+
url,
|
|
1830
|
+
{
|
|
1889
1831
|
intent: {
|
|
1890
1832
|
proof: intent.proof,
|
|
1891
1833
|
message: exports.Intent.encodeMessage(intent.message)
|
|
1892
1834
|
}
|
|
1893
|
-
}
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
const errorText = await response.text();
|
|
1897
|
-
handleError(errorText, `Failed to delete intent: ${errorText}`);
|
|
1898
|
-
}
|
|
1835
|
+
},
|
|
1836
|
+
(errorText) => `Failed to delete intent: ${errorText}`
|
|
1837
|
+
);
|
|
1899
1838
|
}
|
|
1900
1839
|
async confirmRegistration(intentId) {
|
|
1901
1840
|
const url = `${this.serverUrl}/v1/batch/ack`;
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
"Content-Type": "application/json"
|
|
1906
|
-
},
|
|
1907
|
-
body: JSON.stringify({
|
|
1841
|
+
await this.postJson(
|
|
1842
|
+
url,
|
|
1843
|
+
{
|
|
1908
1844
|
intentId
|
|
1909
|
-
}
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
const errorText = await response.text();
|
|
1913
|
-
handleError(errorText, `Failed to confirm registration: ${errorText}`);
|
|
1914
|
-
}
|
|
1845
|
+
},
|
|
1846
|
+
(errorText) => `Failed to confirm registration: ${errorText}`
|
|
1847
|
+
);
|
|
1915
1848
|
}
|
|
1916
1849
|
async submitTreeNonces(batchId, pubkey, nonces) {
|
|
1917
1850
|
const url = `${this.serverUrl}/v1/batch/tree/submitNonces`;
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
"Content-Type": "application/json"
|
|
1922
|
-
},
|
|
1923
|
-
body: JSON.stringify({
|
|
1851
|
+
await this.postJson(
|
|
1852
|
+
url,
|
|
1853
|
+
{
|
|
1924
1854
|
batchId,
|
|
1925
1855
|
pubkey,
|
|
1926
1856
|
treeNonces: encodeMusig2Nonces(nonces)
|
|
1927
|
-
}
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
const errorText = await response.text();
|
|
1931
|
-
handleError(errorText, `Failed to submit tree nonces: ${errorText}`);
|
|
1932
|
-
}
|
|
1857
|
+
},
|
|
1858
|
+
(errorText) => `Failed to submit tree nonces: ${errorText}`
|
|
1859
|
+
);
|
|
1933
1860
|
}
|
|
1934
1861
|
async submitTreeSignatures(batchId, pubkey, signatures) {
|
|
1935
1862
|
const url = `${this.serverUrl}/v1/batch/tree/submitSignatures`;
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
"Content-Type": "application/json"
|
|
1940
|
-
},
|
|
1941
|
-
body: JSON.stringify({
|
|
1863
|
+
await this.postJson(
|
|
1864
|
+
url,
|
|
1865
|
+
{
|
|
1942
1866
|
batchId,
|
|
1943
1867
|
pubkey,
|
|
1944
1868
|
treeSignatures: encodeMusig2Signatures(signatures)
|
|
1945
|
-
}
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
const errorText = await response.text();
|
|
1949
|
-
handleError(errorText, `Failed to submit tree signatures: ${errorText}`);
|
|
1950
|
-
}
|
|
1869
|
+
},
|
|
1870
|
+
(errorText) => `Failed to submit tree signatures: ${errorText}`
|
|
1871
|
+
);
|
|
1951
1872
|
}
|
|
1952
1873
|
async submitSignedForfeitTxs(signedForfeitTxs, signedCommitmentTx) {
|
|
1953
1874
|
const url = `${this.serverUrl}/v1/batch/submitForfeitTxs`;
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
"Content-Type": "application/json"
|
|
1958
|
-
},
|
|
1959
|
-
body: JSON.stringify({
|
|
1875
|
+
await this.postJson(
|
|
1876
|
+
url,
|
|
1877
|
+
{
|
|
1960
1878
|
signedForfeitTxs,
|
|
1961
1879
|
signedCommitmentTx
|
|
1962
|
-
}
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
const errorText = await response.text();
|
|
1966
|
-
handleError(errorText, `Failed to submit forfeit transactions: ${response.statusText}`);
|
|
1967
|
-
}
|
|
1880
|
+
},
|
|
1881
|
+
(_, res) => `Failed to submit forfeit transactions: ${res.statusText}`
|
|
1882
|
+
);
|
|
1968
1883
|
}
|
|
1969
1884
|
getEventStream(signal, topics) {
|
|
1970
1885
|
const url = `${this.serverUrl}/v1/batch/events`;
|
|
@@ -2087,22 +2002,16 @@ var RestArkProvider = class {
|
|
|
2087
2002
|
}
|
|
2088
2003
|
async getPendingTxs(intent) {
|
|
2089
2004
|
const url = `${this.serverUrl}/v1/tx/pending`;
|
|
2090
|
-
const response = await this.
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
"Content-Type": "application/json"
|
|
2094
|
-
},
|
|
2095
|
-
body: JSON.stringify({
|
|
2005
|
+
const response = await this.postJson(
|
|
2006
|
+
url,
|
|
2007
|
+
{
|
|
2096
2008
|
intent: {
|
|
2097
2009
|
proof: intent.proof,
|
|
2098
2010
|
message: exports.Intent.encodeMessage(intent.message)
|
|
2099
2011
|
}
|
|
2100
|
-
}
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
const errorText = await response.text();
|
|
2104
|
-
handleError(errorText, `Failed to get pending transactions: ${errorText}`);
|
|
2105
|
-
}
|
|
2012
|
+
},
|
|
2013
|
+
(errorText) => `Failed to get pending transactions: ${errorText}`
|
|
2014
|
+
);
|
|
2106
2015
|
const data = await response.json();
|
|
2107
2016
|
return data.pendingTxs;
|
|
2108
2017
|
}
|
|
@@ -2368,11 +2277,16 @@ async function getNormalizedVtxos(provider, opts) {
|
|
|
2368
2277
|
const { vtxos, page } = await provider.getVtxos(opts);
|
|
2369
2278
|
return { vtxos: vtxos.map(normalizeVtxo), page };
|
|
2370
2279
|
}
|
|
2280
|
+
var SCRIPT_CHUNK_CONCURRENCY = 4;
|
|
2371
2281
|
async function getAllNormalizedVtxos(provider, scripts, opts = {}) {
|
|
2372
2282
|
const { pageSize = DEFAULT_PAGE_SIZE, ...filters } = opts;
|
|
2373
2283
|
const all = [];
|
|
2284
|
+
const chunks = [];
|
|
2374
2285
|
for (let i = 0; i < scripts.length; i += SCRIPT_QUERY_CHUNK_SIZE) {
|
|
2375
|
-
|
|
2286
|
+
chunks.push(scripts.slice(i, i + SCRIPT_QUERY_CHUNK_SIZE));
|
|
2287
|
+
}
|
|
2288
|
+
const fetchChunk = async (chunk) => {
|
|
2289
|
+
const result = [];
|
|
2376
2290
|
let pageIndex = 0;
|
|
2377
2291
|
let hasMore = true;
|
|
2378
2292
|
while (hasMore) {
|
|
@@ -2382,11 +2296,18 @@ async function getAllNormalizedVtxos(provider, scripts, opts = {}) {
|
|
|
2382
2296
|
pageIndex,
|
|
2383
2297
|
pageSize
|
|
2384
2298
|
});
|
|
2385
|
-
|
|
2299
|
+
result.push(...vtxos);
|
|
2386
2300
|
hasMore = page ? vtxos.length === pageSize : false;
|
|
2387
2301
|
pageIndex++;
|
|
2388
2302
|
if (hasMore) await new Promise((r) => setTimeout(r, 500));
|
|
2389
2303
|
}
|
|
2304
|
+
return result;
|
|
2305
|
+
};
|
|
2306
|
+
for (let i = 0; i < chunks.length; i += SCRIPT_CHUNK_CONCURRENCY) {
|
|
2307
|
+
const batch = await Promise.all(
|
|
2308
|
+
chunks.slice(i, i + SCRIPT_CHUNK_CONCURRENCY).map(fetchChunk)
|
|
2309
|
+
);
|
|
2310
|
+
for (const result of batch) all.push(...result);
|
|
2390
2311
|
}
|
|
2391
2312
|
return all;
|
|
2392
2313
|
}
|
|
@@ -2409,7 +2330,7 @@ async function fetchVtxoCreatedAtByTxid(provider, txids) {
|
|
|
2409
2330
|
}
|
|
2410
2331
|
return createdAt;
|
|
2411
2332
|
}
|
|
2412
|
-
function
|
|
2333
|
+
function isVtxoSpent(vtxo) {
|
|
2413
2334
|
const n = normalizeVtxo(vtxo);
|
|
2414
2335
|
return !!n.isSpent || !!n.spentBy || !!n.settledBy;
|
|
2415
2336
|
}
|
|
@@ -2420,15 +2341,19 @@ function isPastExpiry(vtxo, now) {
|
|
|
2420
2341
|
}
|
|
2421
2342
|
function canSpendOffchain(vtxo, now) {
|
|
2422
2343
|
const n = normalizeVtxo(vtxo);
|
|
2423
|
-
return !
|
|
2344
|
+
return !isVtxoSpent(n) && !n.isUnrolled && !(n.isSwept || isPastExpiry(n, now));
|
|
2424
2345
|
}
|
|
2425
2346
|
function canRecoverOnchain(vtxo, now) {
|
|
2426
2347
|
const n = normalizeVtxo(vtxo);
|
|
2427
|
-
return !
|
|
2348
|
+
return !isVtxoSpent(n) && !n.isUnrolled && (n.isSwept || isPastExpiry(n, now));
|
|
2428
2349
|
}
|
|
2429
2350
|
function canSweepOnchain(vtxo) {
|
|
2430
2351
|
const n = normalizeVtxo(vtxo);
|
|
2431
|
-
return !
|
|
2352
|
+
return !isVtxoSpent(n) && !!n.isUnrolled;
|
|
2353
|
+
}
|
|
2354
|
+
function requiresForfeit(vtxo) {
|
|
2355
|
+
const n = normalizeVtxo(vtxo);
|
|
2356
|
+
return !n.isSwept && !n.isUnrolled;
|
|
2432
2357
|
}
|
|
2433
2358
|
function toOffchainInputFeeParams(vtxo) {
|
|
2434
2359
|
return {
|
|
@@ -2499,7 +2424,6 @@ exports.getConfiguredEventSource = getConfiguredEventSource;
|
|
|
2499
2424
|
exports.getNetwork = getNetwork;
|
|
2500
2425
|
exports.getNormalizedVtxos = getNormalizedVtxos;
|
|
2501
2426
|
exports.getSequence = getSequence;
|
|
2502
|
-
exports.hasTerminalSpend = hasTerminalSpend;
|
|
2503
2427
|
exports.isArkError = isArkError;
|
|
2504
2428
|
exports.isEventSourceError = isEventSourceError;
|
|
2505
2429
|
exports.isEventSourceUnavailableError = isEventSourceUnavailableError;
|
|
@@ -2507,11 +2431,13 @@ exports.isFetchTimeoutError = isFetchTimeoutError;
|
|
|
2507
2431
|
exports.isPastExpiry = isPastExpiry;
|
|
2508
2432
|
exports.isRetryableProviderError = isRetryableProviderError;
|
|
2509
2433
|
exports.isVirtualCoin = isVirtualCoin;
|
|
2434
|
+
exports.isVtxoSpent = isVtxoSpent;
|
|
2510
2435
|
exports.maybeArkError = maybeArkError;
|
|
2511
2436
|
exports.networkFromArkadeInfo = networkFromArkadeInfo;
|
|
2512
2437
|
exports.networks = networks;
|
|
2513
2438
|
exports.normalizeVtxo = normalizeVtxo;
|
|
2514
2439
|
exports.rateGate = rateGate;
|
|
2440
|
+
exports.requiresForfeit = requiresForfeit;
|
|
2515
2441
|
exports.resolveEmulatorPubkey = resolveEmulatorPubkey;
|
|
2516
2442
|
exports.resolveEventSource = resolveEventSource;
|
|
2517
2443
|
exports.resolveTimeHeight = resolveTimeHeight;
|
|
@@ -2523,5 +2449,5 @@ exports.throwIfHttpUnavailable = throwIfHttpUnavailable;
|
|
|
2523
2449
|
exports.timelockToSequence = timelockToSequence;
|
|
2524
2450
|
exports.toOffchainInputFeeParams = toOffchainInputFeeParams;
|
|
2525
2451
|
exports.toProviderUnavailable = toProviderUnavailable;
|
|
2526
|
-
//# sourceMappingURL=chunk-
|
|
2527
|
-
//# sourceMappingURL=chunk-
|
|
2452
|
+
//# sourceMappingURL=chunk-7NK6XFC3.cjs.map
|
|
2453
|
+
//# sourceMappingURL=chunk-7NK6XFC3.cjs.map
|