@gardenfi/core 0.2.0-beta.75 → 0.2.0-beta.77
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.cjs +31 -1
- package/dist/index.js +7813 -28
- package/package.json +1 -1
- package/dist/index10.cjs +0 -1
- package/dist/index10.js +0 -112
- package/dist/index100.cjs +0 -1
- package/dist/index100.js +0 -23
- package/dist/index101.cjs +0 -1
- package/dist/index101.js +0 -9
- package/dist/index102.cjs +0 -1
- package/dist/index102.js +0 -35
- package/dist/index103.cjs +0 -1
- package/dist/index103.js +0 -4
- package/dist/index104.cjs +0 -1
- package/dist/index104.js +0 -40
- package/dist/index105.cjs +0 -1
- package/dist/index105.js +0 -31
- package/dist/index106.cjs +0 -1
- package/dist/index106.js +0 -9
- package/dist/index107.cjs +0 -1
- package/dist/index107.js +0 -7
- package/dist/index108.cjs +0 -1
- package/dist/index108.js +0 -13
- package/dist/index109.cjs +0 -1
- package/dist/index109.js +0 -4
- package/dist/index11.cjs +0 -20
- package/dist/index11.js +0 -380
- package/dist/index110.cjs +0 -1
- package/dist/index110.js +0 -60
- package/dist/index111.cjs +0 -1
- package/dist/index111.js +0 -4
- package/dist/index112.cjs +0 -1
- package/dist/index112.js +0 -42
- package/dist/index113.cjs +0 -1
- package/dist/index113.js +0 -45
- package/dist/index114.cjs +0 -1
- package/dist/index114.js +0 -20
- package/dist/index115.cjs +0 -1
- package/dist/index115.js +0 -111
- package/dist/index116.cjs +0 -1
- package/dist/index116.js +0 -23
- package/dist/index117.cjs +0 -1
- package/dist/index117.js +0 -228
- package/dist/index118.cjs +0 -1
- package/dist/index118.js +0 -6
- package/dist/index119.cjs +0 -1
- package/dist/index119.js +0 -160
- package/dist/index12.cjs +0 -1
- package/dist/index12.js +0 -22
- package/dist/index120.cjs +0 -1
- package/dist/index120.js +0 -4
- package/dist/index121.cjs +0 -1
- package/dist/index121.js +0 -75
- package/dist/index122.cjs +0 -1
- package/dist/index122.js +0 -64
- package/dist/index123.cjs +0 -1
- package/dist/index123.js +0 -37
- package/dist/index124.cjs +0 -1
- package/dist/index124.js +0 -7
- package/dist/index125.cjs +0 -1
- package/dist/index125.js +0 -107
- package/dist/index126.cjs +0 -1
- package/dist/index126.js +0 -15
- package/dist/index127.cjs +0 -1
- package/dist/index127.js +0 -35
- package/dist/index128.cjs +0 -1
- package/dist/index128.js +0 -4
- package/dist/index129.cjs +0 -1
- package/dist/index129.js +0 -32
- package/dist/index13.cjs +0 -1
- package/dist/index13.js +0 -396
- package/dist/index130.cjs +0 -1
- package/dist/index130.js +0 -4
- package/dist/index131.cjs +0 -1
- package/dist/index131.js +0 -358
- package/dist/index132.cjs +0 -1
- package/dist/index132.js +0 -241
- package/dist/index133.cjs +0 -1
- package/dist/index133.js +0 -70
- package/dist/index134.cjs +0 -1
- package/dist/index134.js +0 -64
- package/dist/index135.cjs +0 -1
- package/dist/index135.js +0 -14
- package/dist/index136.cjs +0 -1
- package/dist/index136.js +0 -47
- package/dist/index137.cjs +0 -1
- package/dist/index137.js +0 -65
- package/dist/index138.cjs +0 -1
- package/dist/index138.js +0 -21
- package/dist/index139.cjs +0 -1
- package/dist/index139.js +0 -228
- package/dist/index14.cjs +0 -1
- package/dist/index14.js +0 -28
- package/dist/index140.cjs +0 -1
- package/dist/index140.js +0 -5
- package/dist/index141.cjs +0 -1
- package/dist/index141.js +0 -171
- package/dist/index142.cjs +0 -1
- package/dist/index142.js +0 -30
- package/dist/index143.cjs +0 -1
- package/dist/index143.js +0 -23
- package/dist/index144.cjs +0 -1
- package/dist/index144.js +0 -72
- package/dist/index145.cjs +0 -1
- package/dist/index145.js +0 -130
- package/dist/index146.cjs +0 -1
- package/dist/index146.js +0 -9
- package/dist/index147.cjs +0 -1
- package/dist/index147.js +0 -4
- package/dist/index148.cjs +0 -1
- package/dist/index148.js +0 -28
- package/dist/index149.cjs +0 -1
- package/dist/index149.js +0 -4
- package/dist/index15.cjs +0 -1
- package/dist/index15.js +0 -34
- package/dist/index16.cjs +0 -1
- package/dist/index16.js +0 -27
- package/dist/index17.cjs +0 -1
- package/dist/index17.js +0 -33
- package/dist/index18.cjs +0 -1
- package/dist/index18.js +0 -32
- package/dist/index19.cjs +0 -1
- package/dist/index19.js +0 -55
- package/dist/index2.cjs +0 -1
- package/dist/index2.js +0 -412
- package/dist/index20.cjs +0 -1
- package/dist/index20.js +0 -28
- package/dist/index21.cjs +0 -1
- package/dist/index21.js +0 -4
- package/dist/index22.cjs +0 -1
- package/dist/index22.js +0 -140
- package/dist/index23.cjs +0 -1
- package/dist/index23.js +0 -4
- package/dist/index24.cjs +0 -1
- package/dist/index24.js +0 -11
- package/dist/index25.cjs +0 -1
- package/dist/index25.js +0 -11
- package/dist/index26.cjs +0 -3
- package/dist/index26.js +0 -30
- package/dist/index27.cjs +0 -1
- package/dist/index27.js +0 -17
- package/dist/index28.cjs +0 -2
- package/dist/index28.js +0 -27
- package/dist/index29.cjs +0 -1
- package/dist/index29.js +0 -43
- package/dist/index3.cjs +0 -1
- package/dist/index3.js +0 -5
- package/dist/index30.cjs +0 -1
- package/dist/index30.js +0 -201
- package/dist/index31.cjs +0 -1
- package/dist/index31.js +0 -4
- package/dist/index32.cjs +0 -1
- package/dist/index32.js +0 -4
- package/dist/index33.cjs +0 -1
- package/dist/index33.js +0 -4
- package/dist/index34.cjs +0 -1
- package/dist/index34.js +0 -15
- package/dist/index35.cjs +0 -1
- package/dist/index35.js +0 -39
- package/dist/index36.cjs +0 -1
- package/dist/index36.js +0 -44
- package/dist/index37.cjs +0 -1
- package/dist/index37.js +0 -30
- package/dist/index38.cjs +0 -1
- package/dist/index38.js +0 -17
- package/dist/index39.cjs +0 -1
- package/dist/index39.js +0 -26
- package/dist/index4.cjs +0 -1
- package/dist/index4.js +0 -18
- package/dist/index40.cjs +0 -1
- package/dist/index40.js +0 -28
- package/dist/index41.cjs +0 -1
- package/dist/index41.js +0 -57
- package/dist/index42.cjs +0 -1
- package/dist/index42.js +0 -30
- package/dist/index43.cjs +0 -1
- package/dist/index43.js +0 -177
- package/dist/index44.cjs +0 -1
- package/dist/index44.js +0 -4
- package/dist/index45.cjs +0 -1
- package/dist/index45.js +0 -37
- package/dist/index46.cjs +0 -1
- package/dist/index46.js +0 -11
- package/dist/index47.cjs +0 -1
- package/dist/index47.js +0 -15
- package/dist/index48.cjs +0 -1
- package/dist/index48.js +0 -14
- package/dist/index49.cjs +0 -1
- package/dist/index49.js +0 -6
- package/dist/index5.cjs +0 -1
- package/dist/index5.js +0 -99
- package/dist/index50.cjs +0 -1
- package/dist/index50.js +0 -48
- package/dist/index51.cjs +0 -1
- package/dist/index51.js +0 -45
- package/dist/index52.cjs +0 -1
- package/dist/index52.js +0 -174
- package/dist/index53.cjs +0 -1
- package/dist/index53.js +0 -15
- package/dist/index54.cjs +0 -1
- package/dist/index54.js +0 -7
- package/dist/index55.cjs +0 -1
- package/dist/index55.js +0 -19
- package/dist/index56.cjs +0 -1
- package/dist/index56.js +0 -14
- package/dist/index57.cjs +0 -1
- package/dist/index57.js +0 -22
- package/dist/index58.cjs +0 -1
- package/dist/index58.js +0 -34
- package/dist/index59.cjs +0 -1
- package/dist/index59.js +0 -4
- package/dist/index6.cjs +0 -1
- package/dist/index6.js +0 -5
- package/dist/index60.cjs +0 -6
- package/dist/index60.js +0 -949
- package/dist/index61.cjs +0 -1
- package/dist/index61.js +0 -4
- package/dist/index62.cjs +0 -1
- package/dist/index62.js +0 -64
- package/dist/index63.cjs +0 -1
- package/dist/index63.js +0 -35
- package/dist/index64.cjs +0 -1
- package/dist/index64.js +0 -89
- package/dist/index65.cjs +0 -1
- package/dist/index65.js +0 -58
- package/dist/index66.cjs +0 -2
- package/dist/index66.js +0 -62
- package/dist/index67.cjs +0 -1
- package/dist/index67.js +0 -6
- package/dist/index68.cjs +0 -1
- package/dist/index68.js +0 -37
- package/dist/index69.cjs +0 -1
- package/dist/index69.js +0 -130
- package/dist/index7.cjs +0 -1
- package/dist/index7.js +0 -76
- package/dist/index70.cjs +0 -2
- package/dist/index70.js +0 -45
- package/dist/index71.cjs +0 -1
- package/dist/index71.js +0 -11
- package/dist/index72.cjs +0 -1
- package/dist/index72.js +0 -13
- package/dist/index73.cjs +0 -1
- package/dist/index73.js +0 -14
- package/dist/index74.cjs +0 -1
- package/dist/index74.js +0 -16
- package/dist/index75.cjs +0 -1
- package/dist/index75.js +0 -9
- package/dist/index76.cjs +0 -1
- package/dist/index76.js +0 -20
- package/dist/index77.cjs +0 -1
- package/dist/index77.js +0 -81
- package/dist/index78.cjs +0 -1
- package/dist/index78.js +0 -17
- package/dist/index79.cjs +0 -1
- package/dist/index79.js +0 -21
- package/dist/index8.cjs +0 -1
- package/dist/index8.js +0 -61
- package/dist/index80.cjs +0 -1
- package/dist/index80.js +0 -24
- package/dist/index81.cjs +0 -1
- package/dist/index81.js +0 -16
- package/dist/index82.cjs +0 -1
- package/dist/index82.js +0 -9
- package/dist/index83.cjs +0 -1
- package/dist/index83.js +0 -4
- package/dist/index84.cjs +0 -1
- package/dist/index84.js +0 -4
- package/dist/index85.cjs +0 -2
- package/dist/index85.js +0 -37
- package/dist/index86.cjs +0 -1
- package/dist/index86.js +0 -8
- package/dist/index87.cjs +0 -1
- package/dist/index87.js +0 -22
- package/dist/index88.cjs +0 -1
- package/dist/index88.js +0 -37
- package/dist/index89.cjs +0 -1
- package/dist/index89.js +0 -369
- package/dist/index9.cjs +0 -1
- package/dist/index9.js +0 -63
- package/dist/index90.cjs +0 -1
- package/dist/index90.js +0 -23
- package/dist/index91.cjs +0 -1
- package/dist/index91.js +0 -58
- package/dist/index92.cjs +0 -1
- package/dist/index92.js +0 -5
- package/dist/index93.cjs +0 -1
- package/dist/index93.js +0 -51
- package/dist/index94.cjs +0 -1
- package/dist/index94.js +0 -28
- package/dist/index95.cjs +0 -1
- package/dist/index95.js +0 -4
- package/dist/index96.cjs +0 -1
- package/dist/index96.js +0 -4
- package/dist/index97.cjs +0 -1
- package/dist/index97.js +0 -15
- package/dist/index98.cjs +0 -1
- package/dist/index98.js +0 -9
- package/dist/index99.cjs +0 -1
- package/dist/index99.js +0 -115
package/package.json
CHANGED
package/dist/index10.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("@gardenfi/utils");const u=require("@gardenfi/orderbook"),o=require("viem"),p=require("varuint-bitcoin"),i=require("@catalogfi/utils"),b=require("tiny-secp256k1"),w=require("bitcoinjs-lib"),g=require("./index15.cjs"),O=require("./index16.cjs"),y=require("./index17.cjs"),S=require("./index18.cjs"),_=require("./index19.cjs");function a(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const l=a(p),f=a(b),d=a(w);function q(e){return typeof e=="string"&&(e=Buffer.from(e,"hex")),e.length===32?e:e.subarray(1,33)}function v(e,t){if(!e)throw new Error(t)}function C(e){return Buffer.concat([Uint8Array.from([192]),h(e)])}function h(e){const t=l.encodingLength(e.length),r=Buffer.allocUnsafe(t);return l.encode(e.length,r),Buffer.concat([r,e])}function L(e,t){if(e.compare(t)>0){const r=e;e=t,t=r}return[e,t]}const B=e=>e.length===64?e:e.slice(2),P=e=>{if(!e)return!1;try{const t=Buffer.from(e,"hex");return f.isPoint(t)}catch{return!1}},m={ethereum:g.mainnet,ethereum_arbitrum:O.arbitrum,ethereum_sepolia:y.sepolia,arbitrum_sepolia:S.arbitrumSepolia,ethereum_localnet:u.EthereumLocalnet,arbitrum_localnet:u.ArbitrumLocalnet,base_sepolia:_.baseSepolia},k=async(e,t)=>{var n;const r=m[e];if(r)try{if(r.id===((n=t.chain)==null?void 0:n.id))return i.Ok({message:"Already on the network",walletClient:t});await t.switchChain({id:r.id});const c=o.createWalletClient({account:t.account,chain:r,transport:o.custom(window.ethereum)});return i.Ok({message:"Switched chain",walletClient:c})}catch(c){if(A(c))try{await t.addChain({chain:r});const s=o.createWalletClient({account:t.account,chain:r,transport:o.custom(window.ethereum)});return i.Ok({message:"Added network",walletClient:s})}catch{return i.Err("Failed to add network")}else return i.Err("Failed to switch network")}else return i.Err("Chain not supported")},A=e=>typeof e=="object"&&e!==null&&"code"in e&&e.code===4902,E=(e,t,r,n)=>e+":"+t.toLowerCase()+"::"+r+":"+n.toLowerCase();function j(e,t){if(!e)return!1;d.initEccLib(f);try{return d.address.toOutputScript(e,t),!0}catch{return!1}}exports.assert=v;exports.constructOrderPair=E;exports.evmToViemChainMap=m;exports.isValidBitcoinPubKey=P;exports.prefixScriptLength=h;exports.serializeScript=C;exports.sortLeaves=L;exports.switchOrAddNetwork=k;exports.toXOnly=B;exports.validateBTCAddress=j;exports.xOnlyPubkey=q;
|
package/dist/index10.js
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import "@gardenfi/utils";
|
|
2
|
-
import { EthereumLocalnet as d, ArbitrumLocalnet as l } from "@gardenfi/orderbook";
|
|
3
|
-
import { createWalletClient as s, custom as u } from "viem";
|
|
4
|
-
import * as m from "varuint-bitcoin";
|
|
5
|
-
import { Ok as i, Err as a } from "@catalogfi/utils";
|
|
6
|
-
import * as h from "tiny-secp256k1";
|
|
7
|
-
import * as f from "bitcoinjs-lib";
|
|
8
|
-
import { mainnet as p } from "./index15.js";
|
|
9
|
-
import { arbitrum as w } from "./index16.js";
|
|
10
|
-
import { sepolia as g } from "./index17.js";
|
|
11
|
-
import { arbitrumSepolia as L } from "./index18.js";
|
|
12
|
-
import { baseSepolia as b } from "./index19.js";
|
|
13
|
-
function W(t) {
|
|
14
|
-
return typeof t == "string" && (t = Buffer.from(t, "hex")), t.length === 32 ? t : t.subarray(1, 33);
|
|
15
|
-
}
|
|
16
|
-
function k(t, r) {
|
|
17
|
-
if (!t) throw new Error(r);
|
|
18
|
-
}
|
|
19
|
-
function N(t) {
|
|
20
|
-
return Buffer.concat([
|
|
21
|
-
Uint8Array.from([192]),
|
|
22
|
-
B(t)
|
|
23
|
-
]);
|
|
24
|
-
}
|
|
25
|
-
function B(t) {
|
|
26
|
-
const r = m.encodingLength(t.length), e = Buffer.allocUnsafe(r);
|
|
27
|
-
return m.encode(t.length, e), Buffer.concat([e, t]);
|
|
28
|
-
}
|
|
29
|
-
function T(t, r) {
|
|
30
|
-
if (t.compare(r) > 0) {
|
|
31
|
-
const e = t;
|
|
32
|
-
t = r, r = e;
|
|
33
|
-
}
|
|
34
|
-
return [t, r];
|
|
35
|
-
}
|
|
36
|
-
const U = (t) => t.length === 64 ? t : t.slice(2), V = (t) => {
|
|
37
|
-
if (!t) return !1;
|
|
38
|
-
try {
|
|
39
|
-
const r = Buffer.from(t, "hex");
|
|
40
|
-
return h.isPoint(r);
|
|
41
|
-
} catch {
|
|
42
|
-
return !1;
|
|
43
|
-
}
|
|
44
|
-
}, C = {
|
|
45
|
-
ethereum: p,
|
|
46
|
-
ethereum_arbitrum: w,
|
|
47
|
-
ethereum_sepolia: g,
|
|
48
|
-
arbitrum_sepolia: L,
|
|
49
|
-
ethereum_localnet: d,
|
|
50
|
-
arbitrum_localnet: l,
|
|
51
|
-
base_sepolia: b
|
|
52
|
-
}, j = async (t, r) => {
|
|
53
|
-
var n;
|
|
54
|
-
const e = C[t];
|
|
55
|
-
if (e)
|
|
56
|
-
try {
|
|
57
|
-
if (e.id === ((n = r.chain) == null ? void 0 : n.id))
|
|
58
|
-
return i({ message: "Already on the network", walletClient: r });
|
|
59
|
-
await r.switchChain({ id: e.id });
|
|
60
|
-
const o = s({
|
|
61
|
-
account: r.account,
|
|
62
|
-
chain: e,
|
|
63
|
-
transport: u(window.ethereum)
|
|
64
|
-
});
|
|
65
|
-
return i({
|
|
66
|
-
message: "Switched chain",
|
|
67
|
-
walletClient: o
|
|
68
|
-
});
|
|
69
|
-
} catch (o) {
|
|
70
|
-
if (y(o))
|
|
71
|
-
try {
|
|
72
|
-
await r.addChain({ chain: e });
|
|
73
|
-
const c = s({
|
|
74
|
-
account: r.account,
|
|
75
|
-
chain: e,
|
|
76
|
-
transport: u(window.ethereum)
|
|
77
|
-
});
|
|
78
|
-
return i({
|
|
79
|
-
message: "Added network",
|
|
80
|
-
walletClient: c
|
|
81
|
-
});
|
|
82
|
-
} catch {
|
|
83
|
-
return a("Failed to add network");
|
|
84
|
-
}
|
|
85
|
-
else
|
|
86
|
-
return a("Failed to switch network");
|
|
87
|
-
}
|
|
88
|
-
else
|
|
89
|
-
return a("Chain not supported");
|
|
90
|
-
}, y = (t) => typeof t == "object" && t !== null && "code" in t && t.code === 4902, z = (t, r, e, n) => t + ":" + r.toLowerCase() + "::" + e + ":" + n.toLowerCase();
|
|
91
|
-
function D(t, r) {
|
|
92
|
-
if (!t) return !1;
|
|
93
|
-
f.initEccLib(h);
|
|
94
|
-
try {
|
|
95
|
-
return f.address.toOutputScript(t, r), !0;
|
|
96
|
-
} catch {
|
|
97
|
-
return !1;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
export {
|
|
101
|
-
k as assert,
|
|
102
|
-
z as constructOrderPair,
|
|
103
|
-
C as evmToViemChainMap,
|
|
104
|
-
V as isValidBitcoinPubKey,
|
|
105
|
-
B as prefixScriptLength,
|
|
106
|
-
N as serializeScript,
|
|
107
|
-
T as sortLeaves,
|
|
108
|
-
j as switchOrAddNetwork,
|
|
109
|
-
U as toXOnly,
|
|
110
|
-
D as validateBTCAddress,
|
|
111
|
-
W as xOnlyPubkey
|
|
112
|
-
};
|
package/dist/index100.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index66.cjs");class t extends o.BaseError{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`,{name:"NegativeOffsetError"})}}class i extends o.BaseError{constructor({length:e,position:r}){super(`Position \`${r}\` is out of bounds (\`0 < position < ${e}\`).`,{name:"PositionOutOfBoundsError"})}}class n extends o.BaseError{constructor({count:e,limit:r}){super(`Recursive read limit of \`${r}\` exceeded (recursive read count: \`${e}\`).`,{name:"RecursiveReadLimitExceededError"})}}exports.NegativeOffsetError=t;exports.PositionOutOfBoundsError=i;exports.RecursiveReadLimitExceededError=n;
|
package/dist/index100.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { BaseError as o } from "./index66.js";
|
|
2
|
-
class i extends o {
|
|
3
|
-
constructor({ offset: e }) {
|
|
4
|
-
super(`Offset \`${e}\` cannot be negative.`, {
|
|
5
|
-
name: "NegativeOffsetError"
|
|
6
|
-
});
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
class n extends o {
|
|
10
|
-
constructor({ length: e, position: r }) {
|
|
11
|
-
super(`Position \`${r}\` is out of bounds (\`0 < position < ${e}\`).`, { name: "PositionOutOfBoundsError" });
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
class c extends o {
|
|
15
|
-
constructor({ count: e, limit: r }) {
|
|
16
|
-
super(`Recursive read limit of \`${r}\` exceeded (recursive read count: \`${e}\`).`, { name: "RecursiveReadLimitExceededError" });
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
export {
|
|
20
|
-
i as NegativeOffsetError,
|
|
21
|
-
n as PositionOutOfBoundsError,
|
|
22
|
-
c as RecursiveReadLimitExceededError
|
|
23
|
-
};
|
package/dist/index101.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index50.cjs"),r=require("./index98.cjs");function c(t){const{commitment:o,version:s=1}=t,n=t.to??(typeof o=="string"?"hex":"bytes"),e=r.sha256(o);return e.set([s],0),n==="bytes"?e:i.bytesToHex(e)}exports.commitmentToVersionedHash=c;
|
package/dist/index101.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { bytesToHex as i } from "./index50.js";
|
|
2
|
-
import { sha256 as m } from "./index98.js";
|
|
3
|
-
function f(t) {
|
|
4
|
-
const { commitment: e, version: s = 1 } = t, n = t.to ?? (typeof e == "string" ? "hex" : "bytes"), o = m(e);
|
|
5
|
-
return o.set([s], 0), n === "bytes" ? o : i(o);
|
|
6
|
-
}
|
|
7
|
-
export {
|
|
8
|
-
f as commitmentToVersionedHash
|
|
9
|
-
};
|
package/dist/index102.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index124.cjs"),y=require("./index104.cjs"),u=require("./index69.cjs"),B=require("./index54.cjs"),h=require("./index65.cjs"),d=require("./index50.cjs");function f(t){const a=t.to??(typeof t.data=="string"?"hex":"bytes"),n=typeof t.data=="string"?h.hexToBytes(t.data):t.data,s=B.size(n);if(!s)throw new y.EmptyBlobError;if(s>o.maxBytesPerTransaction)throw new y.BlobSizeTooLargeError({maxSize:o.maxBytesPerTransaction,size:s});const r=[];let b=!0,i=0;for(;b;){const e=u.createCursor(new Uint8Array(o.bytesPerBlob));let l=0;for(;l<o.fieldElementsPerBlob;){const c=n.slice(i,i+(o.bytesPerFieldElement-1));if(e.pushByte(0),e.pushBytes(c),c.length<31){e.pushByte(128),b=!1;break}l++,i+=31}r.push(e)}return a==="bytes"?r.map(e=>e.bytes):r.map(e=>d.bytesToHex(e.bytes))}exports.toBlobs=f;
|
package/dist/index102.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { maxBytesPerTransaction as y, bytesPerBlob as a, fieldElementsPerBlob as f, bytesPerFieldElement as p } from "./index124.js";
|
|
2
|
-
import { EmptyBlobError as c, BlobSizeTooLargeError as h } from "./index104.js";
|
|
3
|
-
import { createCursor as B } from "./index69.js";
|
|
4
|
-
import { size as u } from "./index54.js";
|
|
5
|
-
import { hexToBytes as x } from "./index65.js";
|
|
6
|
-
import { bytesToHex as d } from "./index50.js";
|
|
7
|
-
function S(e) {
|
|
8
|
-
const m = e.to ?? (typeof e.data == "string" ? "hex" : "bytes"), i = typeof e.data == "string" ? x(e.data) : e.data, o = u(i);
|
|
9
|
-
if (!o)
|
|
10
|
-
throw new c();
|
|
11
|
-
if (o > y)
|
|
12
|
-
throw new h({
|
|
13
|
-
maxSize: y,
|
|
14
|
-
size: o
|
|
15
|
-
});
|
|
16
|
-
const s = [];
|
|
17
|
-
let n = !0, r = 0;
|
|
18
|
-
for (; n; ) {
|
|
19
|
-
const t = B(new Uint8Array(a));
|
|
20
|
-
let l = 0;
|
|
21
|
-
for (; l < f; ) {
|
|
22
|
-
const b = i.slice(r, r + (p - 1));
|
|
23
|
-
if (t.pushByte(0), t.pushBytes(b), b.length < 31) {
|
|
24
|
-
t.pushByte(128), n = !1;
|
|
25
|
-
break;
|
|
26
|
-
}
|
|
27
|
-
l++, r += 31;
|
|
28
|
-
}
|
|
29
|
-
s.push(t);
|
|
30
|
-
}
|
|
31
|
-
return m === "bytes" ? s.map((t) => t.bytes) : s.map((t) => d(t.bytes));
|
|
32
|
-
}
|
|
33
|
-
export {
|
|
34
|
-
S as toBlobs
|
|
35
|
-
};
|
package/dist/index103.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=1;exports.versionedHashVersionKzg=e;
|
package/dist/index103.js
DELETED
package/dist/index104.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index103.cjs"),s=require("./index66.cjs");class i extends s.BaseError{constructor({maxSize:e,size:r}){super("Blob size is too large.",{metaMessages:[`Max: ${e} bytes`,`Given: ${r} bytes`],name:"BlobSizeTooLargeError"})}}class n extends s.BaseError{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}class t extends s.BaseError{constructor({hash:e,size:r}){super(`Versioned hash "${e}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${r}`],name:"InvalidVersionedHashSizeError"})}}class d extends s.BaseError{constructor({hash:e,version:r}){super(`Versioned hash "${e}" version is invalid.`,{metaMessages:[`Expected: ${a.versionedHashVersionKzg}`,`Received: ${r}`],name:"InvalidVersionedHashVersionError"})}}exports.BlobSizeTooLargeError=i;exports.EmptyBlobError=n;exports.InvalidVersionedHashSizeError=t;exports.InvalidVersionedHashVersionError=d;
|
package/dist/index104.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { versionedHashVersionKzg as a } from "./index103.js";
|
|
2
|
-
import { BaseError as s } from "./index66.js";
|
|
3
|
-
class t extends s {
|
|
4
|
-
constructor({ maxSize: e, size: r }) {
|
|
5
|
-
super("Blob size is too large.", {
|
|
6
|
-
metaMessages: [`Max: ${e} bytes`, `Given: ${r} bytes`],
|
|
7
|
-
name: "BlobSizeTooLargeError"
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
class d extends s {
|
|
12
|
-
constructor() {
|
|
13
|
-
super("Blob data must not be empty.", { name: "EmptyBlobError" });
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
class l extends s {
|
|
17
|
-
constructor({ hash: e, size: r }) {
|
|
18
|
-
super(`Versioned hash "${e}" size is invalid.`, {
|
|
19
|
-
metaMessages: ["Expected: 32", `Received: ${r}`],
|
|
20
|
-
name: "InvalidVersionedHashSizeError"
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
class c extends s {
|
|
25
|
-
constructor({ hash: e, version: r }) {
|
|
26
|
-
super(`Versioned hash "${e}" version is invalid.`, {
|
|
27
|
-
metaMessages: [
|
|
28
|
-
`Expected: ${a}`,
|
|
29
|
-
`Received: ${r}`
|
|
30
|
-
],
|
|
31
|
-
name: "InvalidVersionedHashVersionError"
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
export {
|
|
36
|
-
t as BlobSizeTooLargeError,
|
|
37
|
-
d as EmptyBlobError,
|
|
38
|
-
l as InvalidVersionedHashSizeError,
|
|
39
|
-
c as InvalidVersionedHashVersionError
|
|
40
|
-
};
|
package/dist/index105.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./index97.cjs"),l=require("./index67.cjs"),r=require("./index54.cjs");function x(i,s,e,{strict:t}={}){return l.isHex(i,{strict:!1})?f(i,s,e,{strict:t}):o(i,s,e,{strict:t})}function n(i,s,e){if(r.size(i)!==e-s)throw new u.SliceOffsetOutOfBoundsError({offset:e,position:"end",size:r.size(i)})}function o(i,s,e,{strict:t}={}){const c=i.slice(s,e);return t&&n(c,s,e),c}function f(i,s,e,{strict:t}={}){const c=`0x${i.replace("0x","").slice(s*2,e*2)}`;return t&&n(c,s,e),c}exports.slice=x;exports.sliceBytes=o;exports.sliceHex=f;
|
package/dist/index105.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { SliceOffsetOutOfBoundsError as n } from "./index97.js";
|
|
2
|
-
import { isHex as c } from "./index67.js";
|
|
3
|
-
import { size as s } from "./index54.js";
|
|
4
|
-
function O(e, f, i, { strict: o } = {}) {
|
|
5
|
-
return c(e, { strict: !1 }) ? l(e, f, i, {
|
|
6
|
-
strict: o
|
|
7
|
-
}) : u(e, f, i, {
|
|
8
|
-
strict: o
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
function t(e, f, i) {
|
|
12
|
-
if (s(e) !== i - f)
|
|
13
|
-
throw new n({
|
|
14
|
-
offset: i,
|
|
15
|
-
position: "end",
|
|
16
|
-
size: s(e)
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
function u(e, f, i, { strict: o } = {}) {
|
|
20
|
-
const r = e.slice(f, i);
|
|
21
|
-
return o && t(r, f, i), r;
|
|
22
|
-
}
|
|
23
|
-
function l(e, f, i, { strict: o } = {}) {
|
|
24
|
-
const r = `0x${e.replace("0x", "").slice(f * 2, i * 2)}`;
|
|
25
|
-
return o && t(r, f, i), r;
|
|
26
|
-
}
|
|
27
|
-
export {
|
|
28
|
-
O as slice,
|
|
29
|
-
u as sliceBytes,
|
|
30
|
-
l as sliceHex
|
|
31
|
-
};
|
package/dist/index106.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index125.cjs"),s=require("./index67.cjs"),c=require("./index65.cjs");function r(e,o){return t.keccak_256(s.isHex(e,{strict:!1})?c.toBytes(e):e)}exports.keccak256=r;
|
package/dist/index106.js
DELETED
package/dist/index107.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={ether:-9,wei:9};exports.gweiUnits=e;
|
package/dist/index107.js
DELETED
package/dist/index108.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function o(r,i){let t=r.toString();const n=t.startsWith("-");n&&(t=t.slice(1)),t=t.padStart(i,"0");let[l,e]=[t.slice(0,t.length-i),t.slice(t.length-i)];return e=e.replace(/(0+)$/,""),`${n?"-":""}${l||"0"}${e?`.${e}`:""}`}exports.formatUnits=o;
|
package/dist/index108.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
function a(r, n) {
|
|
2
|
-
let t = r.toString();
|
|
3
|
-
const i = t.startsWith("-");
|
|
4
|
-
i && (t = t.slice(1)), t = t.padStart(n, "0");
|
|
5
|
-
let [l, e] = [
|
|
6
|
-
t.slice(0, t.length - n),
|
|
7
|
-
t.slice(t.length - n)
|
|
8
|
-
];
|
|
9
|
-
return e = e.replace(/(0+)$/, ""), `${i ? "-" : ""}${l || "0"}${e ? `.${e}` : ""}`;
|
|
10
|
-
}
|
|
11
|
-
export {
|
|
12
|
-
a as formatUnits
|
|
13
|
-
};
|
package/dist/index109.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e={exports:{}};exports.__module=e;
|
package/dist/index109.js
DELETED
package/dist/index11.cjs
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("@catalogfi/wallets"),H=require("bitcoinjs-lib"),O=require("tiny-secp256k1"),P=require("./index37.cjs"),f=require("./index10.cjs"),u=require("./index38.cjs");function S(p){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(p){for(const r in p)if(r!=="default"){const t=Object.getOwnPropertyDescriptor(p,r);Object.defineProperty(e,r,t.get?t:{enumerable:!0,get:()=>p[r]})}}return e.default=p,Object.freeze(e)}const h=S(H),k=S(O),m=192;h.initEccLib(k);class v{constructor(e,r,t,s,i,a,d,o){this.secretHash=t,this.redeemerPubkey=s,this.initiatorPubkey=i,this.expiry=a,this.signer=e,this.network=d,this.internalPubkey=P.generateInternalkey(),this.initiateAmount=r,this.utxoHashes=o}static async from(e,r,t,s,i,a,d){t=t.startsWith("0x")?t.slice(2):t,f.assert(t.length===64,u.htlcErrors.secretHashLenMismatch),f.assert(s.length===64||s.length===66,`initiator ${u.htlcErrors.pubkeyLenMismatch}`),f.assert(i.length===64||i.length===66,`redeemer ${u.htlcErrors.pubkeyLenMismatch}`),f.assert(a>0,u.htlcErrors.zeroOrNegativeExpiry);const o=await e.getNetwork();return new v(e,r,t,f.xOnlyPubkey(i).toString("hex"),f.xOnlyPubkey(s).toString("hex"),a,o,d)}address(){const{address:e}=h.payments.p2tr({internalPubkey:this.internalPubkey,network:this.network,scriptTree:this.leaves()});if(!e)throw new Error(u.htlcErrors.htlcAddressGenerationFailed);return e}id(){return this.address()}async _buildRawTx(e,r){const t=new h.Transaction;t.version=2;const s=this.address(),i=await this.signer.getProvider();let a=[];if(this.utxoHashes&&this.utxoHashes.length>0)for(const o of this.utxoHashes){const l=await i.getTransaction(o);for(let g=0;g<l.vout.length;g++){const n=l.vout[g];n.scriptpubkey_address===s&&a.push({txid:l.txid,vout:g,value:n.value,status:{confirmed:!1}})}}else a=await i.getUTXOs(s);const d=a.reduce((o,l)=>o+l.value,0);if(d===0)throw new Error(`${s} ${u.htlcErrors.notFunded}`);for(let o=0;o<a.length;o++)t.addInput(Buffer.from(a[o].txid,"hex").reverse(),a[o].vout);return r??(r=await i.suggestFee(s,d,b.Urgency.MEDIUM)),t.addOutput(h.address.toOutputScript(e,this.network),d-r),{tx:t,usedUtxos:a}}async buildRawTx(e){return await this._buildRawTx(await this.signer.getAddress(),e)}getOutputScript(){return h.address.toOutputScript(this.address(),this.network)}async init(e){return e??(e=await(await this.signer.getProvider()).suggestFee(await this.signer.getAddress(),this.initiateAmount,b.Urgency.MEDIUM)),await this.signer.send(this.address(),this.initiateAmount,e)}async instantRefund(e,r){f.assert(e.length>0,u.htlcErrors.noCounterpartySigs);const{tx:t,usedUtxos:s}=await this.buildRawTx(r);for(const n of s)if(!e.find(c=>c.utxo===n.txid))throw new Error(u.htlcErrors.counterPartySigNotFound(n.txid));const i=this.getOutputScript(),a=h.Transaction.SIGHASH_DEFAULT,d=this.leafHash(2),o=s.map(n=>n.value),l=y(i,s.length);for(let n=0;n<t.ins.length;n++){const c=t.hashForWitnessV1(n,l,o,a,d);if(!k.verifySchnorr(c,Buffer.from(this.redeemerPubkey,"hex"),Buffer.from(e[n].sig,"hex")))throw new Error(u.htlcErrors.invalidCounterpartySigForUTXO(e[n].utxo));const w=await this.signer.signSchnorr(c),x=Buffer.from(t.ins[n].hash).reverse().toString("hex"),E=e.find(L=>L.utxo===x);if(!E)throw new Error(u.htlcErrors.counterPartySigNotFound(x));t.setWitness(n,[Buffer.from(E.sig,"hex"),w,this.instantRefundLeaf(),this.generateControlBlockFor(2)])}return await(await this.signer.getProvider()).broadcast(t.toHex())}async redeem(e,r,t){f.assert(h.crypto.sha256(Buffer.from(e,"hex")).toString("hex")===this.secretHash,u.htlcErrors.secretMismatch);const{tx:s,usedUtxos:i}=await this._buildRawTx(r??await this.signer.getAddress(),t),a=this.leafHash(1),d=i.map(n=>n.value),o=y(this.getOutputScript(),i.length),l=h.Transaction.SIGHASH_DEFAULT;for(let n=0;n<s.ins.length;n++){const c=s.hashForWitnessV1(n,o,d,l,a),w=await this.signer.signSchnorr(c);s.setWitness(n,[w,Buffer.from(e,"hex"),this.redeemLeaf(),this.generateControlBlockFor(1)])}return await(await this.signer.getProvider()).broadcast(s.toHex())}async refund(e,r){const{tx:t,usedUtxos:s}=await this._buildRawTx(e??await this.signer.getAddress(),r),[i,a]=await this.canRefund(s);if(!i)throw new Error(u.htlcErrors.htlcNotExpired(a));const d=this.leafHash(0),o=s.map(c=>c.value),l=y(this.getOutputScript(),s.length),g=h.Transaction.SIGHASH_DEFAULT;for(let c=0;c<t.ins.length;c++){t.ins[c].sequence=this.expiry;const w=t.hashForWitnessV1(c,l,o,g,d),x=await this.signer.signSchnorr(w);t.setWitness(c,[x,this.refundLeaf(),this.generateControlBlockFor(0)])}return await(await this.signer.getProvider()).broadcast(t.toHex())}async canRefund(e){const t=await(await this.signer.getProvider()).getLatestTip();for(const s of e){let i=0;if(s.status.confirmed&&s.status.block_height+this.expiry>t?i=s.status.block_height+this.expiry-t+1:s.status.confirmed||(i=this.expiry+1),i>0)return[!1,i]}return[!0,0]}generateControlBlockFor(e){let r;switch(e){case 1:r=this.redeemLeaf();break;case 0:r=this.refundLeaf();break;case 2:r=this.instantRefundLeaf();break;default:throw new Error(u.htlcErrors.invalidLeaf)}const t=h.payments.p2tr({internalPubkey:this.internalPubkey,network:this.network,scriptTree:this.leaves(),redeem:{output:r,redeemVersion:m}});if(!t.witness)throw new Error(u.htlcErrors.controlBlockGenerationFailed);return t.witness[t.witness.length-1]}leafHash(e){let r=this.redeemLeaf();return e===0&&(r=this.refundLeaf()),e===2&&(r=this.instantRefundLeaf()),h.crypto.taggedHash("TapLeaf",f.serializeScript(r))}refundLeaf(){return h.script.fromASM(`
|
|
2
|
-
${h.script.number.encode(this.expiry).toString("hex")}
|
|
3
|
-
OP_CHECKSEQUENCEVERIFY
|
|
4
|
-
OP_DROP
|
|
5
|
-
${this.initiatorPubkey}
|
|
6
|
-
OP_CHECKSIG
|
|
7
|
-
`.trim().replace(/\s+/g," "))}redeemLeaf(){return h.script.fromASM(`
|
|
8
|
-
OP_SHA256
|
|
9
|
-
${this.secretHash}
|
|
10
|
-
OP_EQUALVERIFY
|
|
11
|
-
${this.redeemerPubkey}
|
|
12
|
-
OP_CHECKSIG
|
|
13
|
-
`.trim().replace(/\s+/g," "))}instantRefundLeaf(){return h.script.fromASM(`
|
|
14
|
-
${this.initiatorPubkey}
|
|
15
|
-
OP_CHECKSIG
|
|
16
|
-
${this.redeemerPubkey}
|
|
17
|
-
OP_CHECKSIGADD
|
|
18
|
-
OP_2
|
|
19
|
-
OP_NUMEQUAL
|
|
20
|
-
`.trim().replace(/\s+/g," "))}leaves(){return[{version:m,output:this.redeemLeaf()},[{version:m,output:this.refundLeaf()},{version:m,output:this.instantRefundLeaf()}]]}generateMerkleProofFor(e){const r=this.leafHash(1),t=this.leafHash(2),s=this.leafHash(0);switch(e){case 1:{const i=f.sortLeaves(s,t);return[h.crypto.taggedHash("TapBranch",Buffer.concat(i))]}case 0:return[t,r];case 2:return[s,r];default:throw new Error(u.htlcErrors.invalidLeaf)}}}function y(p,e){const r=[];for(let t=0;t<e;t++)r.push(p);return r}exports.GardenHTLC=v;
|