@arkade-os/sdk 0.4.78 → 0.4.79
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 +1 -1
- package/dist/adapters/expo.cjs +5 -5
- package/dist/adapters/expo.d.cts +3 -3
- package/dist/adapters/expo.d.ts +3 -3
- package/dist/adapters/expo.js +3 -3
- package/dist/{asyncStorageTaskQueue-YW2t31_o.d.ts → asyncStorageTaskQueue-C5yQLJhm.d.ts} +1 -1
- package/dist/{asyncStorageTaskQueue-DiXxP-nQ.d.cts → asyncStorageTaskQueue-Shsih-1l.d.cts} +1 -1
- package/dist/{chunk-ZOCJ7E6M.js → chunk-4MXW2NDN.js} +10 -515
- package/dist/chunk-4MXW2NDN.js.map +1 -0
- package/dist/{chunk-KEEZSFLI.cjs → chunk-54FXLZ3T.cjs} +10 -10
- package/dist/{chunk-KEEZSFLI.cjs.map → chunk-54FXLZ3T.cjs.map} +1 -1
- package/dist/{chunk-PWIESIO6.cjs → chunk-DAYCCIRO.cjs} +372 -198
- package/dist/chunk-DAYCCIRO.cjs.map +1 -0
- package/dist/{chunk-Y7BVR6SQ.cjs → chunk-FUW3OM5X.cjs} +76 -561
- package/dist/chunk-FUW3OM5X.cjs.map +1 -0
- package/dist/{chunk-VJ7M6WKB.cjs → chunk-HAM3SHBV.cjs} +587 -532
- package/dist/chunk-HAM3SHBV.cjs.map +1 -0
- package/dist/{chunk-7KIGEOYT.js → chunk-JCPVP7TJ.js} +373 -201
- package/dist/chunk-JCPVP7TJ.js.map +1 -0
- package/dist/{chunk-DFWLP3MD.cjs → chunk-LASRYLMQ.cjs} +17 -17
- package/dist/{chunk-DFWLP3MD.cjs.map → chunk-LASRYLMQ.cjs.map} +1 -1
- package/dist/{chunk-CTFYT24G.js → chunk-QDXOTONI.js} +3 -3
- package/dist/{chunk-CTFYT24G.js.map → chunk-QDXOTONI.js.map} +1 -1
- package/dist/{chunk-IAM5IEVT.cjs → chunk-SJPPBR2V.cjs} +17 -17
- package/dist/{chunk-IAM5IEVT.cjs.map → chunk-SJPPBR2V.cjs.map} +1 -1
- package/dist/{chunk-P766MOPU.js → chunk-SK4OZRMB.js} +4 -4
- package/dist/{chunk-P766MOPU.js.map → chunk-SK4OZRMB.js.map} +1 -1
- package/dist/{chunk-OUHUC26M.js → chunk-VAFNWP3I.js} +4 -4
- package/dist/{chunk-OUHUC26M.js.map → chunk-VAFNWP3I.js.map} +1 -1
- package/dist/{chunk-LKAASQTL.js → chunk-YPQ37P3H.js} +128 -73
- package/dist/chunk-YPQ37P3H.js.map +1 -0
- package/dist/contracts/handlers/index.cjs +9 -9
- package/dist/contracts/handlers/index.d.cts +4 -4
- package/dist/contracts/handlers/index.d.ts +4 -4
- package/dist/contracts/handlers/index.js +2 -2
- package/dist/{delegate-DaNNUI_B.d.cts → delegate-B4bKASut.d.cts} +1 -1
- package/dist/{delegate-b2Wiymoj.d.ts → delegate-C9lpdrb0.d.ts} +1 -1
- package/dist/{hdWalletCapable-B2XVTOvu.d.ts → hdWalletCapable-CUJDKRKO.d.cts} +2 -3
- package/dist/{hdWalletCapable-D6PqWpuW.d.cts → hdWalletCapable-DJClhYMC.d.ts} +2 -3
- package/dist/{index-CAS4GyN-.d.ts → index-Ctul0N3Y.d.cts} +27 -6
- package/dist/{index-CAS4GyN-.d.cts → index-Ctul0N3Y.d.ts} +27 -6
- package/dist/{index-CYsKAXog.d.ts → index-D0qe2qVY.d.ts} +2 -2
- package/dist/{index-BlB97fYl.d.cts → index-YBFmScVS.d.cts} +2 -2
- package/dist/index.cjs +304 -304
- package/dist/index.d.cts +123 -123
- package/dist/index.d.ts +123 -123
- package/dist/index.js +4 -4
- package/dist/repositories/realm/index.cjs +20 -20
- package/dist/repositories/realm/index.d.cts +3 -3
- package/dist/repositories/realm/index.d.ts +3 -3
- package/dist/repositories/realm/index.js +5 -5
- package/dist/repositories/sqlite/index.cjs +19 -19
- package/dist/repositories/sqlite/index.d.cts +3 -3
- package/dist/repositories/sqlite/index.d.ts +3 -3
- package/dist/repositories/sqlite/index.js +5 -5
- package/dist/{taskRunner-BJj7xe35.d.ts → taskRunner-C08egG5a.d.ts} +1 -1
- package/dist/{taskRunner-HS2d2oda.d.cts → taskRunner-DB17db5n.d.cts} +1 -1
- package/dist/wallet/expo/background.cjs +14 -14
- package/dist/wallet/expo/background.d.cts +4 -4
- package/dist/wallet/expo/background.d.ts +4 -4
- package/dist/wallet/expo/background.js +6 -6
- package/dist/wallet/expo/index.cjs +14 -14
- 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/worker/expo/index.cjs +9 -9
- package/dist/worker/expo/index.d.cts +5 -5
- package/dist/worker/expo/index.d.ts +5 -5
- package/dist/worker/expo/index.js +5 -5
- package/package.json +6 -5
- package/dist/chunk-7KIGEOYT.js.map +0 -1
- package/dist/chunk-LKAASQTL.js.map +0 -1
- package/dist/chunk-PWIESIO6.cjs.map +0 -1
- package/dist/chunk-VJ7M6WKB.cjs.map +0 -1
- package/dist/chunk-Y7BVR6SQ.cjs.map +0 -1
- package/dist/chunk-ZOCJ7E6M.js.map +0 -1
package/README.md
CHANGED
|
@@ -1555,7 +1555,7 @@ For integration tests, use the root commands (`pnpm run test:integration:ts-sdk`
|
|
|
1555
1555
|
|
|
1556
1556
|
### Releasing
|
|
1557
1557
|
|
|
1558
|
-
Package-local releases are disabled. Releases run from the monorepo root and are package-scoped: `pnpm run release -- sdk patch` bumps `@arkade-os/sdk`, creates a `@arkade-os/sdk/<version>` tag, and also bumps `@arkade-os/
|
|
1558
|
+
Package-local releases are disabled. Releases run from the monorepo root and are package-scoped: `pnpm run release -- sdk patch` bumps `@arkade-os/sdk`, creates a `@arkade-os/sdk/<version>` tag, and also bumps `@arkade-os/swap` (which depends on SDK via `workspace:*`). See the [root README](../../README.md#releasing) for full flags and `pnpm run release -- --help`.
|
|
1559
1559
|
|
|
1560
1560
|
## License
|
|
1561
1561
|
|
package/dist/adapters/expo.cjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
5
|
-
require('../chunk-
|
|
3
|
+
var chunkLASRYLMQ_cjs = require('../chunk-LASRYLMQ.cjs');
|
|
4
|
+
require('../chunk-SJPPBR2V.cjs');
|
|
5
|
+
require('../chunk-DAYCCIRO.cjs');
|
|
6
6
|
require('../chunk-5BLDMQED.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
Object.defineProperty(exports, "ExpoArkProvider", {
|
|
11
11
|
enumerable: true,
|
|
12
|
-
get: function () { return
|
|
12
|
+
get: function () { return chunkLASRYLMQ_cjs.ExpoArkProvider; }
|
|
13
13
|
});
|
|
14
14
|
Object.defineProperty(exports, "ExpoIndexerProvider", {
|
|
15
15
|
enumerable: true,
|
|
16
|
-
get: function () { return
|
|
16
|
+
get: function () { return chunkLASRYLMQ_cjs.ExpoIndexerProvider; }
|
|
17
17
|
});
|
|
18
18
|
//# sourceMappingURL=expo.cjs.map
|
|
19
19
|
//# sourceMappingURL=expo.cjs.map
|
package/dist/adapters/expo.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { o as RestArkProvider, l as SettlementEvent, T as TxNotificationEvent, p as RestIndexerProvider, q as SubscriptionResponse } from '../index-
|
|
2
|
-
export { r as ArkProvider, s as IndexerProvider } from '../index-
|
|
1
|
+
import { o as RestArkProvider, l as SettlementEvent, T as TxNotificationEvent, p as RestIndexerProvider, q as SubscriptionResponse } from '../index-Ctul0N3Y.cjs';
|
|
2
|
+
export { r as ArkProvider, s as IndexerProvider } from '../index-Ctul0N3Y.cjs';
|
|
3
3
|
import '@scure/btc-signer/utils.js';
|
|
4
|
-
import '@scure/btc-signer/transaction.js';
|
|
5
4
|
import '@scure/btc-signer';
|
|
5
|
+
import '@scure/btc-signer/transaction.js';
|
|
6
6
|
import '@scure/btc-signer/psbt.js';
|
|
7
7
|
|
|
8
8
|
/**
|
package/dist/adapters/expo.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { o as RestArkProvider, l as SettlementEvent, T as TxNotificationEvent, p as RestIndexerProvider, q as SubscriptionResponse } from '../index-
|
|
2
|
-
export { r as ArkProvider, s as IndexerProvider } from '../index-
|
|
1
|
+
import { o as RestArkProvider, l as SettlementEvent, T as TxNotificationEvent, p as RestIndexerProvider, q as SubscriptionResponse } from '../index-Ctul0N3Y.js';
|
|
2
|
+
export { r as ArkProvider, s as IndexerProvider } from '../index-Ctul0N3Y.js';
|
|
3
3
|
import '@scure/btc-signer/utils.js';
|
|
4
|
-
import '@scure/btc-signer/transaction.js';
|
|
5
4
|
import '@scure/btc-signer';
|
|
5
|
+
import '@scure/btc-signer/transaction.js';
|
|
6
6
|
import '@scure/btc-signer/psbt.js';
|
|
7
7
|
|
|
8
8
|
/**
|
package/dist/adapters/expo.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { ExpoArkProvider, ExpoIndexerProvider } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
1
|
+
export { ExpoArkProvider, ExpoIndexerProvider } from '../chunk-VAFNWP3I.js';
|
|
2
|
+
import '../chunk-QDXOTONI.js';
|
|
3
|
+
import '../chunk-JCPVP7TJ.js';
|
|
4
4
|
import '../chunk-NSBPE2FW.js';
|
|
5
5
|
//# sourceMappingURL=expo.js.map
|
|
6
6
|
//# sourceMappingURL=expo.js.map
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { VtxoScript, MultisigTapscript, CSVMultisigTapscript, timelockToSequence, sequenceToTimelock, ConditionMultisigTapscript, CLTVMultisigTapscript, ConditionCSVMultisigTapscript, SCRIPT_QUERY_CHUNK_SIZE, getNormalizedVtxos, DEFAULT_PAGE_SIZE } from './chunk-
|
|
1
|
+
import { VtxoScript, MultisigTapscript, CSVMultisigTapscript, timelockToSequence, sequenceToTimelock, ConditionMultisigTapscript, CLTVMultisigTapscript, ConditionCSVMultisigTapscript, SCRIPT_QUERY_CHUNK_SIZE, getNormalizedVtxos, DEFAULT_PAGE_SIZE } from './chunk-JCPVP7TJ.js';
|
|
2
2
|
import { __export } from './chunk-NSBPE2FW.js';
|
|
3
3
|
import { hex } from '@scure/base';
|
|
4
4
|
import { networks, expand } from '@bitcoinerlab/descriptors-scure';
|
|
5
5
|
import { ScriptNum, OP, Script } from '@scure/btc-signer';
|
|
6
|
+
import * as P from 'micro-packed';
|
|
6
7
|
import { schnorr, secp256k1 } from '@noble/curves/secp256k1.js';
|
|
7
8
|
import { bytesToNumberBE } from '@noble/curves/utils.js';
|
|
8
9
|
|
|
@@ -617,512 +618,6 @@ function discoverDelegateRange(entries, deps) {
|
|
|
617
618
|
(c, index, descriptor) => ({ ...c, ...rotatedReceiveMetadata(index, descriptor) })
|
|
618
619
|
);
|
|
619
620
|
}
|
|
620
|
-
function equalBytes(a, b) {
|
|
621
|
-
if (a.length !== b.length)
|
|
622
|
-
return false;
|
|
623
|
-
for (let i = 0; i < a.length; i++)
|
|
624
|
-
if (a[i] !== b[i])
|
|
625
|
-
return false;
|
|
626
|
-
return true;
|
|
627
|
-
}
|
|
628
|
-
function isBytes(a) {
|
|
629
|
-
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
630
|
-
}
|
|
631
|
-
var createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
632
|
-
function isPlainObject(obj) {
|
|
633
|
-
return Object.prototype.toString.call(obj) === "[object Object]";
|
|
634
|
-
}
|
|
635
|
-
function isNum(num) {
|
|
636
|
-
return Number.isSafeInteger(num);
|
|
637
|
-
}
|
|
638
|
-
var Bitset = {
|
|
639
|
-
BITS: 32,
|
|
640
|
-
FULL_MASK: -1 >>> 0,
|
|
641
|
-
// 1<<32 will overflow
|
|
642
|
-
len: (len) => Math.ceil(len / 32),
|
|
643
|
-
create: (len) => new Uint32Array(Bitset.len(len)),
|
|
644
|
-
clean: (bs) => bs.fill(0),
|
|
645
|
-
debug: (bs) => Array.from(bs).map((i) => (i >>> 0).toString(2).padStart(32, "0")),
|
|
646
|
-
checkLen: (bs, len) => {
|
|
647
|
-
if (Bitset.len(len) === bs.length)
|
|
648
|
-
return;
|
|
649
|
-
throw new Error(`wrong length=${bs.length}. Expected: ${Bitset.len(len)}`);
|
|
650
|
-
},
|
|
651
|
-
chunkLen: (bsLen, pos, len) => {
|
|
652
|
-
if (pos < 0)
|
|
653
|
-
throw new Error(`wrong pos=${pos}`);
|
|
654
|
-
if (pos + len > bsLen)
|
|
655
|
-
throw new Error(`wrong range=${pos}/${len} of ${bsLen}`);
|
|
656
|
-
},
|
|
657
|
-
set: (bs, chunk, value, allowRewrite = true) => {
|
|
658
|
-
if (!allowRewrite && (bs[chunk] & value) !== 0)
|
|
659
|
-
return false;
|
|
660
|
-
bs[chunk] |= value;
|
|
661
|
-
return true;
|
|
662
|
-
},
|
|
663
|
-
pos: (pos, i) => ({
|
|
664
|
-
chunk: Math.floor((pos + i) / 32),
|
|
665
|
-
mask: 1 << 32 - (pos + i) % 32 - 1
|
|
666
|
-
}),
|
|
667
|
-
indices: (bs, len, invert = false) => {
|
|
668
|
-
Bitset.checkLen(bs, len);
|
|
669
|
-
const { FULL_MASK, BITS } = Bitset;
|
|
670
|
-
const left = BITS - len % BITS;
|
|
671
|
-
const lastMask = left ? FULL_MASK >>> left << left : FULL_MASK;
|
|
672
|
-
const res = [];
|
|
673
|
-
for (let i = 0; i < bs.length; i++) {
|
|
674
|
-
let c = bs[i];
|
|
675
|
-
if (invert)
|
|
676
|
-
c = ~c;
|
|
677
|
-
if (i === bs.length - 1)
|
|
678
|
-
c &= lastMask;
|
|
679
|
-
if (c === 0)
|
|
680
|
-
continue;
|
|
681
|
-
for (let j = 0; j < BITS; j++) {
|
|
682
|
-
const m = 1 << BITS - j - 1;
|
|
683
|
-
if (c & m)
|
|
684
|
-
res.push(i * BITS + j);
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
return res;
|
|
688
|
-
},
|
|
689
|
-
range: (arr) => {
|
|
690
|
-
const res = [];
|
|
691
|
-
let cur;
|
|
692
|
-
for (const i of arr) {
|
|
693
|
-
if (cur === void 0 || i !== cur.pos + cur.length)
|
|
694
|
-
res.push(cur = { pos: i, length: 1 });
|
|
695
|
-
else
|
|
696
|
-
cur.length += 1;
|
|
697
|
-
}
|
|
698
|
-
return res;
|
|
699
|
-
},
|
|
700
|
-
rangeDebug: (bs, len, invert = false) => `[${Bitset.range(Bitset.indices(bs, len, invert)).map((i) => `(${i.pos}/${i.length})`).join(", ")}]`,
|
|
701
|
-
setRange: (bs, bsLen, pos, len, allowRewrite = true) => {
|
|
702
|
-
Bitset.chunkLen(bsLen, pos, len);
|
|
703
|
-
const { FULL_MASK, BITS } = Bitset;
|
|
704
|
-
const first = pos % BITS ? Math.floor(pos / BITS) : void 0;
|
|
705
|
-
const lastPos = pos + len;
|
|
706
|
-
const last = lastPos % BITS ? Math.floor(lastPos / BITS) : void 0;
|
|
707
|
-
if (first !== void 0 && first === last)
|
|
708
|
-
return Bitset.set(bs, first, FULL_MASK >>> BITS - len << BITS - len - pos, allowRewrite);
|
|
709
|
-
if (first !== void 0) {
|
|
710
|
-
if (!Bitset.set(bs, first, FULL_MASK >>> pos % BITS, allowRewrite))
|
|
711
|
-
return false;
|
|
712
|
-
}
|
|
713
|
-
const start = first !== void 0 ? first + 1 : pos / BITS;
|
|
714
|
-
const end = last !== void 0 ? last : lastPos / BITS;
|
|
715
|
-
for (let i = start; i < end; i++)
|
|
716
|
-
if (!Bitset.set(bs, i, FULL_MASK, allowRewrite))
|
|
717
|
-
return false;
|
|
718
|
-
if (last !== void 0 && first !== last) {
|
|
719
|
-
if (!Bitset.set(bs, last, FULL_MASK << BITS - lastPos % BITS, allowRewrite))
|
|
720
|
-
return false;
|
|
721
|
-
}
|
|
722
|
-
return true;
|
|
723
|
-
}
|
|
724
|
-
};
|
|
725
|
-
var Path = {
|
|
726
|
-
/**
|
|
727
|
-
* Internal method for handling stack of paths (debug, errors, dynamic fields via path)
|
|
728
|
-
* This is looks ugly (callback), but allows us to force stack cleaning by construction (.pop always after function).
|
|
729
|
-
* Also, this makes impossible:
|
|
730
|
-
* - pushing field when stack is empty
|
|
731
|
-
* - pushing field inside of field (real bug)
|
|
732
|
-
* NOTE: we don't want to do '.pop' on error!
|
|
733
|
-
*/
|
|
734
|
-
pushObj: (stack, obj, objFn) => {
|
|
735
|
-
const last = { obj };
|
|
736
|
-
stack.push(last);
|
|
737
|
-
objFn((field, fieldFn) => {
|
|
738
|
-
last.field = field;
|
|
739
|
-
fieldFn();
|
|
740
|
-
last.field = void 0;
|
|
741
|
-
});
|
|
742
|
-
stack.pop();
|
|
743
|
-
},
|
|
744
|
-
path: (stack) => {
|
|
745
|
-
const res = [];
|
|
746
|
-
for (const i of stack)
|
|
747
|
-
if (i.field !== void 0)
|
|
748
|
-
res.push(i.field);
|
|
749
|
-
return res.join("/");
|
|
750
|
-
},
|
|
751
|
-
err: (name, stack, msg) => {
|
|
752
|
-
const err = new Error(`${name}(${Path.path(stack)}): ${typeof msg === "string" ? msg : msg.message}`);
|
|
753
|
-
if (msg instanceof Error && msg.stack)
|
|
754
|
-
err.stack = msg.stack;
|
|
755
|
-
return err;
|
|
756
|
-
},
|
|
757
|
-
resolve: (stack, path) => {
|
|
758
|
-
const parts = path.split("/");
|
|
759
|
-
const objPath = stack.map((i2) => i2.obj);
|
|
760
|
-
let i = 0;
|
|
761
|
-
for (; i < parts.length; i++) {
|
|
762
|
-
if (parts[i] === "..")
|
|
763
|
-
objPath.pop();
|
|
764
|
-
else
|
|
765
|
-
break;
|
|
766
|
-
}
|
|
767
|
-
let cur = objPath.pop();
|
|
768
|
-
for (; i < parts.length; i++) {
|
|
769
|
-
if (!cur || cur[parts[i]] === void 0)
|
|
770
|
-
return void 0;
|
|
771
|
-
cur = cur[parts[i]];
|
|
772
|
-
}
|
|
773
|
-
return cur;
|
|
774
|
-
}
|
|
775
|
-
};
|
|
776
|
-
var _Reader = class __Reader {
|
|
777
|
-
pos = 0;
|
|
778
|
-
data;
|
|
779
|
-
opts;
|
|
780
|
-
stack;
|
|
781
|
-
parent;
|
|
782
|
-
parentOffset;
|
|
783
|
-
bitBuf = 0;
|
|
784
|
-
bitPos = 0;
|
|
785
|
-
bs;
|
|
786
|
-
// bitset
|
|
787
|
-
view;
|
|
788
|
-
constructor(data, opts = {}, stack = [], parent = void 0, parentOffset = 0) {
|
|
789
|
-
this.data = data;
|
|
790
|
-
this.opts = opts;
|
|
791
|
-
this.stack = stack;
|
|
792
|
-
this.parent = parent;
|
|
793
|
-
this.parentOffset = parentOffset;
|
|
794
|
-
this.view = createView(data);
|
|
795
|
-
}
|
|
796
|
-
/** Internal method for pointers. */
|
|
797
|
-
_enablePointers() {
|
|
798
|
-
if (this.parent)
|
|
799
|
-
return this.parent._enablePointers();
|
|
800
|
-
if (this.bs)
|
|
801
|
-
return;
|
|
802
|
-
this.bs = Bitset.create(this.data.length);
|
|
803
|
-
Bitset.setRange(this.bs, this.data.length, 0, this.pos, this.opts.allowMultipleReads);
|
|
804
|
-
}
|
|
805
|
-
markBytesBS(pos, len) {
|
|
806
|
-
if (this.parent)
|
|
807
|
-
return this.parent.markBytesBS(this.parentOffset + pos, len);
|
|
808
|
-
if (!len)
|
|
809
|
-
return true;
|
|
810
|
-
if (!this.bs)
|
|
811
|
-
return true;
|
|
812
|
-
return Bitset.setRange(this.bs, this.data.length, pos, len, false);
|
|
813
|
-
}
|
|
814
|
-
markBytes(len) {
|
|
815
|
-
const pos = this.pos;
|
|
816
|
-
this.pos += len;
|
|
817
|
-
const res = this.markBytesBS(pos, len);
|
|
818
|
-
if (!this.opts.allowMultipleReads && !res)
|
|
819
|
-
throw this.err(`multiple read pos=${this.pos} len=${len}`);
|
|
820
|
-
return res;
|
|
821
|
-
}
|
|
822
|
-
pushObj(obj, objFn) {
|
|
823
|
-
return Path.pushObj(this.stack, obj, objFn);
|
|
824
|
-
}
|
|
825
|
-
readView(n, fn) {
|
|
826
|
-
if (!Number.isFinite(n))
|
|
827
|
-
throw this.err(`readView: wrong length=${n}`);
|
|
828
|
-
if (this.pos + n > this.data.length)
|
|
829
|
-
throw this.err("readView: Unexpected end of buffer");
|
|
830
|
-
const res = fn(this.view, this.pos);
|
|
831
|
-
this.markBytes(n);
|
|
832
|
-
return res;
|
|
833
|
-
}
|
|
834
|
-
// read bytes by absolute offset
|
|
835
|
-
absBytes(n) {
|
|
836
|
-
if (n > this.data.length)
|
|
837
|
-
throw new Error("Unexpected end of buffer");
|
|
838
|
-
return this.data.subarray(n);
|
|
839
|
-
}
|
|
840
|
-
finish() {
|
|
841
|
-
if (this.opts.allowUnreadBytes)
|
|
842
|
-
return;
|
|
843
|
-
if (this.bitPos) {
|
|
844
|
-
throw this.err(`${this.bitPos} bits left after unpack: ${hex.encode(this.data.slice(this.pos))}`);
|
|
845
|
-
}
|
|
846
|
-
if (this.bs && !this.parent) {
|
|
847
|
-
const notRead = Bitset.indices(this.bs, this.data.length, true);
|
|
848
|
-
if (notRead.length) {
|
|
849
|
-
const formatted = Bitset.range(notRead).map(({ pos, length }) => `(${pos}/${length})[${hex.encode(this.data.subarray(pos, pos + length))}]`).join(", ");
|
|
850
|
-
throw this.err(`unread byte ranges: ${formatted} (total=${this.data.length})`);
|
|
851
|
-
} else
|
|
852
|
-
return;
|
|
853
|
-
}
|
|
854
|
-
if (!this.isEnd()) {
|
|
855
|
-
throw this.err(`${this.leftBytes} bytes ${this.bitPos} bits left after unpack: ${hex.encode(this.data.slice(this.pos))}`);
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
// User methods
|
|
859
|
-
err(msg) {
|
|
860
|
-
return Path.err("Reader", this.stack, msg);
|
|
861
|
-
}
|
|
862
|
-
offsetReader(n) {
|
|
863
|
-
if (n > this.data.length)
|
|
864
|
-
throw this.err("offsetReader: Unexpected end of buffer");
|
|
865
|
-
return new __Reader(this.absBytes(n), this.opts, this.stack, this, n);
|
|
866
|
-
}
|
|
867
|
-
bytes(n, peek = false) {
|
|
868
|
-
if (this.bitPos)
|
|
869
|
-
throw this.err("readBytes: bitPos not empty");
|
|
870
|
-
if (!Number.isFinite(n))
|
|
871
|
-
throw this.err(`readBytes: wrong length=${n}`);
|
|
872
|
-
if (this.pos + n > this.data.length)
|
|
873
|
-
throw this.err("readBytes: Unexpected end of buffer");
|
|
874
|
-
const slice = this.data.subarray(this.pos, this.pos + n);
|
|
875
|
-
if (!peek)
|
|
876
|
-
this.markBytes(n);
|
|
877
|
-
return slice;
|
|
878
|
-
}
|
|
879
|
-
byte(peek = false) {
|
|
880
|
-
if (this.bitPos)
|
|
881
|
-
throw this.err("readByte: bitPos not empty");
|
|
882
|
-
if (this.pos + 1 > this.data.length)
|
|
883
|
-
throw this.err("readBytes: Unexpected end of buffer");
|
|
884
|
-
const data = this.data[this.pos];
|
|
885
|
-
if (!peek)
|
|
886
|
-
this.markBytes(1);
|
|
887
|
-
return data;
|
|
888
|
-
}
|
|
889
|
-
get leftBytes() {
|
|
890
|
-
return this.data.length - this.pos;
|
|
891
|
-
}
|
|
892
|
-
get totalBytes() {
|
|
893
|
-
return this.data.length;
|
|
894
|
-
}
|
|
895
|
-
isEnd() {
|
|
896
|
-
return this.pos >= this.data.length && !this.bitPos;
|
|
897
|
-
}
|
|
898
|
-
// bits are read in BE mode (left to right): (0b1000_0000).readBits(1) == 1
|
|
899
|
-
bits(bits) {
|
|
900
|
-
if (bits > 32)
|
|
901
|
-
throw this.err("BitReader: cannot read more than 32 bits in single call");
|
|
902
|
-
let out = 0;
|
|
903
|
-
while (bits) {
|
|
904
|
-
if (!this.bitPos) {
|
|
905
|
-
this.bitBuf = this.byte();
|
|
906
|
-
this.bitPos = 8;
|
|
907
|
-
}
|
|
908
|
-
const take = Math.min(bits, this.bitPos);
|
|
909
|
-
this.bitPos -= take;
|
|
910
|
-
out = out << take | this.bitBuf >> this.bitPos & 2 ** take - 1;
|
|
911
|
-
this.bitBuf &= 2 ** this.bitPos - 1;
|
|
912
|
-
bits -= take;
|
|
913
|
-
}
|
|
914
|
-
return out >>> 0;
|
|
915
|
-
}
|
|
916
|
-
find(needle, pos = this.pos) {
|
|
917
|
-
if (!isBytes(needle))
|
|
918
|
-
throw this.err(`find: needle is not bytes! ${needle}`);
|
|
919
|
-
if (this.bitPos)
|
|
920
|
-
throw this.err("findByte: bitPos not empty");
|
|
921
|
-
if (!needle.length)
|
|
922
|
-
throw this.err(`find: needle is empty`);
|
|
923
|
-
for (let idx = pos; (idx = this.data.indexOf(needle[0], idx)) !== -1; idx++) {
|
|
924
|
-
if (idx === -1)
|
|
925
|
-
return;
|
|
926
|
-
const leftBytes = this.data.length - idx;
|
|
927
|
-
if (leftBytes < needle.length)
|
|
928
|
-
return;
|
|
929
|
-
if (equalBytes(needle, this.data.subarray(idx, idx + needle.length)))
|
|
930
|
-
return idx;
|
|
931
|
-
}
|
|
932
|
-
return;
|
|
933
|
-
}
|
|
934
|
-
};
|
|
935
|
-
var _Writer = class {
|
|
936
|
-
pos = 0;
|
|
937
|
-
stack;
|
|
938
|
-
// We could have a single buffer here and re-alloc it with
|
|
939
|
-
// x1.5-2 size each time it full, but it will be slower:
|
|
940
|
-
// basic/encode bench: 395ns -> 560ns
|
|
941
|
-
buffers = [];
|
|
942
|
-
ptrs = [];
|
|
943
|
-
bitBuf = 0;
|
|
944
|
-
bitPos = 0;
|
|
945
|
-
viewBuf = new Uint8Array(8);
|
|
946
|
-
view;
|
|
947
|
-
finished = false;
|
|
948
|
-
constructor(stack = []) {
|
|
949
|
-
this.stack = stack;
|
|
950
|
-
this.view = createView(this.viewBuf);
|
|
951
|
-
}
|
|
952
|
-
pushObj(obj, objFn) {
|
|
953
|
-
return Path.pushObj(this.stack, obj, objFn);
|
|
954
|
-
}
|
|
955
|
-
writeView(len, fn) {
|
|
956
|
-
if (this.finished)
|
|
957
|
-
throw this.err("buffer: finished");
|
|
958
|
-
if (!isNum(len) || len > 8)
|
|
959
|
-
throw new Error(`wrong writeView length=${len}`);
|
|
960
|
-
fn(this.view);
|
|
961
|
-
this.bytes(this.viewBuf.slice(0, len));
|
|
962
|
-
this.viewBuf.fill(0);
|
|
963
|
-
}
|
|
964
|
-
// User methods
|
|
965
|
-
err(msg) {
|
|
966
|
-
if (this.finished)
|
|
967
|
-
throw this.err("buffer: finished");
|
|
968
|
-
return Path.err("Reader", this.stack, msg);
|
|
969
|
-
}
|
|
970
|
-
bytes(b) {
|
|
971
|
-
if (this.finished)
|
|
972
|
-
throw this.err("buffer: finished");
|
|
973
|
-
if (this.bitPos)
|
|
974
|
-
throw this.err("writeBytes: ends with non-empty bit buffer");
|
|
975
|
-
this.buffers.push(b);
|
|
976
|
-
this.pos += b.length;
|
|
977
|
-
}
|
|
978
|
-
byte(b) {
|
|
979
|
-
if (this.finished)
|
|
980
|
-
throw this.err("buffer: finished");
|
|
981
|
-
if (this.bitPos)
|
|
982
|
-
throw this.err("writeByte: ends with non-empty bit buffer");
|
|
983
|
-
this.buffers.push(new Uint8Array([b]));
|
|
984
|
-
this.pos++;
|
|
985
|
-
}
|
|
986
|
-
finish(clean = true) {
|
|
987
|
-
if (this.finished)
|
|
988
|
-
throw this.err("buffer: finished");
|
|
989
|
-
if (this.bitPos)
|
|
990
|
-
throw this.err("buffer: ends with non-empty bit buffer");
|
|
991
|
-
const buffers = this.buffers.concat(this.ptrs.map((i) => i.buffer));
|
|
992
|
-
const sum = buffers.map((b) => b.length).reduce((a, b) => a + b, 0);
|
|
993
|
-
const buf = new Uint8Array(sum);
|
|
994
|
-
for (let i = 0, pad = 0; i < buffers.length; i++) {
|
|
995
|
-
const a = buffers[i];
|
|
996
|
-
buf.set(a, pad);
|
|
997
|
-
pad += a.length;
|
|
998
|
-
}
|
|
999
|
-
for (let pos = this.pos, i = 0; i < this.ptrs.length; i++) {
|
|
1000
|
-
const ptr = this.ptrs[i];
|
|
1001
|
-
buf.set(ptr.ptr.encode(pos), ptr.pos);
|
|
1002
|
-
pos += ptr.buffer.length;
|
|
1003
|
-
}
|
|
1004
|
-
if (clean) {
|
|
1005
|
-
this.buffers = [];
|
|
1006
|
-
for (const p of this.ptrs)
|
|
1007
|
-
p.buffer.fill(0);
|
|
1008
|
-
this.ptrs = [];
|
|
1009
|
-
this.finished = true;
|
|
1010
|
-
this.bitBuf = 0;
|
|
1011
|
-
}
|
|
1012
|
-
return buf;
|
|
1013
|
-
}
|
|
1014
|
-
bits(value, bits) {
|
|
1015
|
-
if (bits > 32)
|
|
1016
|
-
throw this.err("writeBits: cannot write more than 32 bits in single call");
|
|
1017
|
-
if (value >= 2 ** bits)
|
|
1018
|
-
throw this.err(`writeBits: value (${value}) >= 2**bits (${bits})`);
|
|
1019
|
-
while (bits) {
|
|
1020
|
-
const take = Math.min(bits, 8 - this.bitPos);
|
|
1021
|
-
this.bitBuf = this.bitBuf << take | value >> bits - take;
|
|
1022
|
-
this.bitPos += take;
|
|
1023
|
-
bits -= take;
|
|
1024
|
-
value &= 2 ** bits - 1;
|
|
1025
|
-
if (this.bitPos === 8) {
|
|
1026
|
-
this.bitPos = 0;
|
|
1027
|
-
this.buffers.push(new Uint8Array([this.bitBuf]));
|
|
1028
|
-
this.pos++;
|
|
1029
|
-
}
|
|
1030
|
-
}
|
|
1031
|
-
}
|
|
1032
|
-
};
|
|
1033
|
-
function _wrap(inner) {
|
|
1034
|
-
return {
|
|
1035
|
-
// NOTE: we cannot export validate here, since it is likely mistake.
|
|
1036
|
-
encodeStream: inner.encodeStream,
|
|
1037
|
-
decodeStream: inner.decodeStream,
|
|
1038
|
-
size: inner.size,
|
|
1039
|
-
encode: (value) => {
|
|
1040
|
-
const w = new _Writer();
|
|
1041
|
-
inner.encodeStream(w, value);
|
|
1042
|
-
return w.finish();
|
|
1043
|
-
},
|
|
1044
|
-
decode: (data, opts = {}) => {
|
|
1045
|
-
const r = new _Reader(data, opts);
|
|
1046
|
-
const res = inner.decodeStream(r);
|
|
1047
|
-
r.finish();
|
|
1048
|
-
return res;
|
|
1049
|
-
}
|
|
1050
|
-
};
|
|
1051
|
-
}
|
|
1052
|
-
function validate(inner, fn) {
|
|
1053
|
-
if (!isCoder(inner))
|
|
1054
|
-
throw new Error(`validate: invalid inner value ${inner}`);
|
|
1055
|
-
if (typeof fn !== "function")
|
|
1056
|
-
throw new Error("validate: fn should be function");
|
|
1057
|
-
return _wrap({
|
|
1058
|
-
size: inner.size,
|
|
1059
|
-
encodeStream: (w, value) => {
|
|
1060
|
-
let res;
|
|
1061
|
-
try {
|
|
1062
|
-
res = fn(value);
|
|
1063
|
-
} catch (e) {
|
|
1064
|
-
throw w.err(e);
|
|
1065
|
-
}
|
|
1066
|
-
inner.encodeStream(w, res);
|
|
1067
|
-
},
|
|
1068
|
-
decodeStream: (r) => {
|
|
1069
|
-
const res = inner.decodeStream(r);
|
|
1070
|
-
try {
|
|
1071
|
-
return fn(res);
|
|
1072
|
-
} catch (e) {
|
|
1073
|
-
throw r.err(e);
|
|
1074
|
-
}
|
|
1075
|
-
}
|
|
1076
|
-
});
|
|
1077
|
-
}
|
|
1078
|
-
var wrap = (inner) => {
|
|
1079
|
-
const res = _wrap(inner);
|
|
1080
|
-
return inner.validate ? validate(res, inner.validate) : res;
|
|
1081
|
-
};
|
|
1082
|
-
var isBaseCoder = (elm) => isPlainObject(elm) && typeof elm.decode === "function" && typeof elm.encode === "function";
|
|
1083
|
-
function isCoder(elm) {
|
|
1084
|
-
return isPlainObject(elm) && isBaseCoder(elm) && typeof elm.encodeStream === "function" && typeof elm.decodeStream === "function" && (elm.size === void 0 || isNum(elm.size));
|
|
1085
|
-
}
|
|
1086
|
-
var view = (len, opts) => wrap({
|
|
1087
|
-
size: len,
|
|
1088
|
-
encodeStream: (w, value) => w.writeView(len, (view2) => opts.write(view2, value)),
|
|
1089
|
-
decodeStream: (r) => r.readView(len, opts.read),
|
|
1090
|
-
validate: (value) => {
|
|
1091
|
-
if (typeof value !== "number")
|
|
1092
|
-
throw new Error(`viewCoder: expected number, got ${typeof value}`);
|
|
1093
|
-
if (opts.validate)
|
|
1094
|
-
opts.validate(value);
|
|
1095
|
-
return value;
|
|
1096
|
-
}
|
|
1097
|
-
});
|
|
1098
|
-
var intView = (len, signed, opts) => {
|
|
1099
|
-
const bits = len * 8;
|
|
1100
|
-
const maxVal = 2 ** bits;
|
|
1101
|
-
const validateUnsigned = (value) => {
|
|
1102
|
-
if (!isNum(value))
|
|
1103
|
-
throw new Error(`uintView: value is not safe integer: ${value}`);
|
|
1104
|
-
if (0 > value || value >= maxVal) {
|
|
1105
|
-
throw new Error(`uintView: value out of bounds. Expected 0 <= ${value} < ${maxVal}`);
|
|
1106
|
-
}
|
|
1107
|
-
};
|
|
1108
|
-
return view(len, {
|
|
1109
|
-
write: opts.write,
|
|
1110
|
-
read: opts.read,
|
|
1111
|
-
validate: validateUnsigned
|
|
1112
|
-
});
|
|
1113
|
-
};
|
|
1114
|
-
var U32LE = /* @__PURE__ */ intView(4, false, {
|
|
1115
|
-
read: (view2, pos) => view2.getUint32(pos, true),
|
|
1116
|
-
write: (view2, value) => view2.setUint32(0, value, true)
|
|
1117
|
-
});
|
|
1118
|
-
var U16LE = /* @__PURE__ */ intView(2, false, {
|
|
1119
|
-
read: (view2, pos) => view2.getUint16(pos, true),
|
|
1120
|
-
write: (view2, value) => view2.setUint16(0, value, true)
|
|
1121
|
-
});
|
|
1122
|
-
var U8 = /* @__PURE__ */ intView(1, false, {
|
|
1123
|
-
read: (view2, pos) => view2.getUint8(pos),
|
|
1124
|
-
write: (view2, value) => view2.setUint8(0, value)
|
|
1125
|
-
});
|
|
1126
621
|
var ARKADE_OP = {
|
|
1127
622
|
// Merkle Branch Verification (0xb3 — repurposed NOP4 slot)
|
|
1128
623
|
MERKLEBRANCHVERIFY: 179,
|
|
@@ -1288,7 +783,7 @@ var ArkadeOPNames = {};
|
|
|
1288
783
|
for (const [k, v] of Object.entries(ARKADE_OPS)) {
|
|
1289
784
|
if (typeof v === "number") ArkadeOPNames[v] = k;
|
|
1290
785
|
}
|
|
1291
|
-
var ArkadeScript = wrap({
|
|
786
|
+
var ArkadeScript = P.wrap({
|
|
1292
787
|
encodeStream: (w, value) => {
|
|
1293
788
|
for (let o of value) {
|
|
1294
789
|
if (typeof o === "string") {
|
|
@@ -1314,10 +809,10 @@ var ArkadeScript = wrap({
|
|
|
1314
809
|
w.byte(len);
|
|
1315
810
|
} else if (len <= 65535) {
|
|
1316
811
|
w.byte(OP.PUSHDATA2);
|
|
1317
|
-
w.bytes(U16LE.encode(len));
|
|
812
|
+
w.bytes(P.U16LE.encode(len));
|
|
1318
813
|
} else {
|
|
1319
814
|
w.byte(OP.PUSHDATA4);
|
|
1320
|
-
w.bytes(U32LE.encode(len));
|
|
815
|
+
w.bytes(P.U32LE.encode(len));
|
|
1321
816
|
}
|
|
1322
817
|
w.bytes(o);
|
|
1323
818
|
}
|
|
@@ -1329,9 +824,9 @@ var ArkadeScript = wrap({
|
|
|
1329
824
|
if (OP.OP_0 < cur && cur <= OP.PUSHDATA4) {
|
|
1330
825
|
let len;
|
|
1331
826
|
if (cur < OP.PUSHDATA1) len = cur;
|
|
1332
|
-
else if (cur === OP.PUSHDATA1) len = U8.decodeStream(r);
|
|
1333
|
-
else if (cur === OP.PUSHDATA2) len = U16LE.decodeStream(r);
|
|
1334
|
-
else if (cur === OP.PUSHDATA4) len = U32LE.decodeStream(r);
|
|
827
|
+
else if (cur === OP.PUSHDATA1) len = P.U8.decodeStream(r);
|
|
828
|
+
else if (cur === OP.PUSHDATA2) len = P.U16LE.decodeStream(r);
|
|
829
|
+
else if (cur === OP.PUSHDATA4) len = P.U32LE.decodeStream(r);
|
|
1335
830
|
else throw new Error("Should be not possible");
|
|
1336
831
|
out.push(r.bytes(len));
|
|
1337
832
|
} else if (cur === 0) {
|
|
@@ -3027,5 +2522,5 @@ contractHandlers.register(BoardingContractHandler);
|
|
|
3027
2522
|
contractHandlers.register(ArkadeContractHandler);
|
|
3028
2523
|
|
|
3029
2524
|
export { ARKADE_OP, ARKADE_OPCODES, ARKADE_OPCODE_NAMES, ARKADE_OPCODE_VALUES, ARKADE_OPS, ArkadeContractHandler, ArkadeProgramScript, ArkadeScript, BoardingContractHandler, DefaultContractHandler, DefaultVtxo, DelegateContractHandler, DelegateVtxo, OPCODE_NAMES, OPCODE_VALUES, SUPPORTED_PROGRAM_VERSION, VHTLC, VHTLCContractHandler, VHTLCV2ContractHandler, WALLET_RECEIVE_SOURCE, arkadeScriptHash, arkadeWitnessHash, asmToBytes, bignum_exports, bytesToASM, computeArkadeScriptPublicKey, contractHandlers, deriveDescriptorLeafCompressedPubKey, deriveDescriptorLeafPubKey, descriptorIsOurs, deserializeArkadeContractParams, fromASM, getOpcodeName, getOpcodeValue, identityDescriptor, inputName, isCltvSatisfied, isCsvSpendable, isMainnetDescriptor, normalizeToDescriptor, parseArtifact, parseHDDescriptor, resolveAsm, serializeArkadeContractParams, speculativeReceiveMetadata, stringifyArtifact, toASM, toXOnly, validateProgram, witnessRefToBytes };
|
|
3030
|
-
//# sourceMappingURL=chunk-
|
|
3031
|
-
//# sourceMappingURL=chunk-
|
|
2525
|
+
//# sourceMappingURL=chunk-4MXW2NDN.js.map
|
|
2526
|
+
//# sourceMappingURL=chunk-4MXW2NDN.js.map
|