@vleap/warps-adapter-fastset 0.1.0-beta.45 → 0.1.0-beta.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +37 -573
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -575
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __export = (target, all) => {
|
|
4
|
-
for (var name in all)
|
|
5
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
6
|
-
};
|
|
7
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
8
4
|
|
|
9
5
|
// src/main.ts
|
|
@@ -1527,7 +1523,7 @@ var FastsetTokens = [
|
|
|
1527
1523
|
name: "Wrapped SET",
|
|
1528
1524
|
symbol: "WSET",
|
|
1529
1525
|
decimals: 18,
|
|
1530
|
-
logoUrl: "https://
|
|
1526
|
+
logoUrl: "https://joai.ai/images/tokens/set-black.svg",
|
|
1531
1527
|
amount: 0n
|
|
1532
1528
|
}
|
|
1533
1529
|
];
|
|
@@ -1705,8 +1701,8 @@ var WarpFastsetExplorer = class {
|
|
|
1705
1701
|
getAccountUrl(address) {
|
|
1706
1702
|
return `${this.explorerUrl}/account/${address}`;
|
|
1707
1703
|
}
|
|
1708
|
-
getTransactionUrl(
|
|
1709
|
-
return `${this.explorerUrl}/txs/${HEX_PREFIX}${
|
|
1704
|
+
getTransactionUrl(hash) {
|
|
1705
|
+
return `${this.explorerUrl}/txs/${HEX_PREFIX}${hash}`;
|
|
1710
1706
|
}
|
|
1711
1707
|
getAssetUrl(identifier) {
|
|
1712
1708
|
return `${this.explorerUrl}/asset/${HEX_PREFIX}${identifier}`;
|
|
@@ -1942,549 +1938,15 @@ import {
|
|
|
1942
1938
|
getWarpWalletPrivateKeyFromConfig
|
|
1943
1939
|
} from "@vleap/warps";
|
|
1944
1940
|
|
|
1945
|
-
//
|
|
1946
|
-
|
|
1947
|
-
__export(ed25519_exports, {
|
|
1948
|
-
Point: () => Point,
|
|
1949
|
-
etc: () => etc,
|
|
1950
|
-
getPublicKey: () => getPublicKey,
|
|
1951
|
-
getPublicKeyAsync: () => getPublicKeyAsync,
|
|
1952
|
-
hash: () => hash,
|
|
1953
|
-
hashes: () => hashes,
|
|
1954
|
-
keygen: () => keygen,
|
|
1955
|
-
keygenAsync: () => keygenAsync,
|
|
1956
|
-
sign: () => sign,
|
|
1957
|
-
signAsync: () => signAsync,
|
|
1958
|
-
utils: () => utils,
|
|
1959
|
-
verify: () => verify,
|
|
1960
|
-
verifyAsync: () => verifyAsync
|
|
1961
|
-
});
|
|
1962
|
-
var ed25519_CURVE = {
|
|
1963
|
-
p: 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,
|
|
1964
|
-
n: 0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,
|
|
1965
|
-
h: 8n,
|
|
1966
|
-
a: 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,
|
|
1967
|
-
d: 0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,
|
|
1968
|
-
Gx: 0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,
|
|
1969
|
-
Gy: 0x6666666666666666666666666666666666666666666666666666666666666658n
|
|
1970
|
-
};
|
|
1971
|
-
var { p: P, n: N, Gx, Gy, a: _a, d: _d, h } = ed25519_CURVE;
|
|
1972
|
-
var L = 32;
|
|
1973
|
-
var L2 = 64;
|
|
1974
|
-
var captureTrace = (...args) => {
|
|
1975
|
-
if ("captureStackTrace" in Error && typeof Error.captureStackTrace === "function") {
|
|
1976
|
-
Error.captureStackTrace(...args);
|
|
1977
|
-
}
|
|
1978
|
-
};
|
|
1979
|
-
var err = (message = "") => {
|
|
1980
|
-
const e = new Error(message);
|
|
1981
|
-
captureTrace(e, err);
|
|
1982
|
-
throw e;
|
|
1983
|
-
};
|
|
1984
|
-
var isBig = (n) => typeof n === "bigint";
|
|
1985
|
-
var isStr = (s) => typeof s === "string";
|
|
1986
|
-
var isBytes2 = (a) => a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
1987
|
-
var abytes = (value, length, title = "") => {
|
|
1988
|
-
const bytes = isBytes2(value);
|
|
1989
|
-
const len = value?.length;
|
|
1990
|
-
const needsLen = length !== void 0;
|
|
1991
|
-
if (!bytes || needsLen && len !== length) {
|
|
1992
|
-
const prefix = title && `"${title}" `;
|
|
1993
|
-
const ofLen = needsLen ? ` of length ${length}` : "";
|
|
1994
|
-
const got = bytes ? `length=${len}` : `type=${typeof value}`;
|
|
1995
|
-
err(prefix + "expected Uint8Array" + ofLen + ", got " + got);
|
|
1996
|
-
}
|
|
1997
|
-
return value;
|
|
1998
|
-
};
|
|
1999
|
-
var u8n = (len) => new Uint8Array(len);
|
|
2000
|
-
var u8fr = (buf) => Uint8Array.from(buf);
|
|
2001
|
-
var padh = (n, pad) => n.toString(16).padStart(pad, "0");
|
|
2002
|
-
var bytesToHex = (b) => Array.from(abytes(b)).map((e) => padh(e, 2)).join("");
|
|
2003
|
-
var C = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
|
|
2004
|
-
var _ch = (ch) => {
|
|
2005
|
-
if (ch >= C._0 && ch <= C._9)
|
|
2006
|
-
return ch - C._0;
|
|
2007
|
-
if (ch >= C.A && ch <= C.F)
|
|
2008
|
-
return ch - (C.A - 10);
|
|
2009
|
-
if (ch >= C.a && ch <= C.f)
|
|
2010
|
-
return ch - (C.a - 10);
|
|
2011
|
-
return;
|
|
2012
|
-
};
|
|
2013
|
-
var hexToBytes = (hex) => {
|
|
2014
|
-
const e = "hex invalid";
|
|
2015
|
-
if (!isStr(hex))
|
|
2016
|
-
return err(e);
|
|
2017
|
-
const hl = hex.length;
|
|
2018
|
-
const al = hl / 2;
|
|
2019
|
-
if (hl % 2)
|
|
2020
|
-
return err(e);
|
|
2021
|
-
const array = u8n(al);
|
|
2022
|
-
for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
|
|
2023
|
-
const n1 = _ch(hex.charCodeAt(hi));
|
|
2024
|
-
const n2 = _ch(hex.charCodeAt(hi + 1));
|
|
2025
|
-
if (n1 === void 0 || n2 === void 0)
|
|
2026
|
-
return err(e);
|
|
2027
|
-
array[ai] = n1 * 16 + n2;
|
|
2028
|
-
}
|
|
2029
|
-
return array;
|
|
2030
|
-
};
|
|
2031
|
-
var cr = () => globalThis?.crypto;
|
|
2032
|
-
var subtle = () => cr()?.subtle ?? err("crypto.subtle must be defined, consider polyfill");
|
|
2033
|
-
var concatBytes = (...arrs) => {
|
|
2034
|
-
const r = u8n(arrs.reduce((sum, a) => sum + abytes(a).length, 0));
|
|
2035
|
-
let pad = 0;
|
|
2036
|
-
arrs.forEach((a) => {
|
|
2037
|
-
r.set(a, pad);
|
|
2038
|
-
pad += a.length;
|
|
2039
|
-
});
|
|
2040
|
-
return r;
|
|
2041
|
-
};
|
|
2042
|
-
var randomBytes = (len = L) => {
|
|
2043
|
-
const c = cr();
|
|
2044
|
-
return c.getRandomValues(u8n(len));
|
|
2045
|
-
};
|
|
2046
|
-
var big = BigInt;
|
|
2047
|
-
var assertRange = (n, min, max, msg = "bad number: out of range") => isBig(n) && min <= n && n < max ? n : err(msg);
|
|
2048
|
-
var M = (a, b = P) => {
|
|
2049
|
-
const r = a % b;
|
|
2050
|
-
return r >= 0n ? r : b + r;
|
|
2051
|
-
};
|
|
2052
|
-
var modN = (a) => M(a, N);
|
|
2053
|
-
var invert = (num, md) => {
|
|
2054
|
-
if (num === 0n || md <= 0n)
|
|
2055
|
-
err("no inverse n=" + num + " mod=" + md);
|
|
2056
|
-
let a = M(num, md), b = md, x = 0n, y = 1n, u = 1n, v = 0n;
|
|
2057
|
-
while (a !== 0n) {
|
|
2058
|
-
const q = b / a, r = b % a;
|
|
2059
|
-
const m = x - u * q, n = y - v * q;
|
|
2060
|
-
b = a, a = r, x = u, y = v, u = m, v = n;
|
|
2061
|
-
}
|
|
2062
|
-
return b === 1n ? M(x, md) : err("no inverse");
|
|
2063
|
-
};
|
|
2064
|
-
var callHash = (name) => {
|
|
2065
|
-
const fn = hashes[name];
|
|
2066
|
-
if (typeof fn !== "function")
|
|
2067
|
-
err("hashes." + name + " not set");
|
|
2068
|
-
return fn;
|
|
2069
|
-
};
|
|
2070
|
-
var hash = (msg) => callHash("sha512")(msg);
|
|
2071
|
-
var apoint = (p) => p instanceof Point ? p : err("Point expected");
|
|
2072
|
-
var B256 = 2n ** 256n;
|
|
2073
|
-
var _Point = class _Point {
|
|
2074
|
-
constructor(X, Y, Z, T) {
|
|
2075
|
-
__publicField(this, "X");
|
|
2076
|
-
__publicField(this, "Y");
|
|
2077
|
-
__publicField(this, "Z");
|
|
2078
|
-
__publicField(this, "T");
|
|
2079
|
-
const max = B256;
|
|
2080
|
-
this.X = assertRange(X, 0n, max);
|
|
2081
|
-
this.Y = assertRange(Y, 0n, max);
|
|
2082
|
-
this.Z = assertRange(Z, 1n, max);
|
|
2083
|
-
this.T = assertRange(T, 0n, max);
|
|
2084
|
-
Object.freeze(this);
|
|
2085
|
-
}
|
|
2086
|
-
static CURVE() {
|
|
2087
|
-
return ed25519_CURVE;
|
|
2088
|
-
}
|
|
2089
|
-
static fromAffine(p) {
|
|
2090
|
-
return new _Point(p.x, p.y, 1n, M(p.x * p.y));
|
|
2091
|
-
}
|
|
2092
|
-
/** RFC8032 5.1.3: Uint8Array to Point. */
|
|
2093
|
-
static fromBytes(hex, zip215 = false) {
|
|
2094
|
-
const d = _d;
|
|
2095
|
-
const normed = u8fr(abytes(hex, L));
|
|
2096
|
-
const lastByte = hex[31];
|
|
2097
|
-
normed[31] = lastByte & ~128;
|
|
2098
|
-
const y = bytesToNumLE(normed);
|
|
2099
|
-
const max = zip215 ? B256 : P;
|
|
2100
|
-
assertRange(y, 0n, max);
|
|
2101
|
-
const y2 = M(y * y);
|
|
2102
|
-
const u = M(y2 - 1n);
|
|
2103
|
-
const v = M(d * y2 + 1n);
|
|
2104
|
-
let { isValid, value: x } = uvRatio(u, v);
|
|
2105
|
-
if (!isValid)
|
|
2106
|
-
err("bad point: y not sqrt");
|
|
2107
|
-
const isXOdd = (x & 1n) === 1n;
|
|
2108
|
-
const isLastByteOdd = (lastByte & 128) !== 0;
|
|
2109
|
-
if (!zip215 && x === 0n && isLastByteOdd)
|
|
2110
|
-
err("bad point: x==0, isLastByteOdd");
|
|
2111
|
-
if (isLastByteOdd !== isXOdd)
|
|
2112
|
-
x = M(-x);
|
|
2113
|
-
return new _Point(x, y, 1n, M(x * y));
|
|
2114
|
-
}
|
|
2115
|
-
static fromHex(hex, zip215) {
|
|
2116
|
-
return _Point.fromBytes(hexToBytes(hex), zip215);
|
|
2117
|
-
}
|
|
2118
|
-
get x() {
|
|
2119
|
-
return this.toAffine().x;
|
|
2120
|
-
}
|
|
2121
|
-
get y() {
|
|
2122
|
-
return this.toAffine().y;
|
|
2123
|
-
}
|
|
2124
|
-
/** Checks if the point is valid and on-curve. */
|
|
2125
|
-
assertValidity() {
|
|
2126
|
-
const a = _a;
|
|
2127
|
-
const d = _d;
|
|
2128
|
-
const p = this;
|
|
2129
|
-
if (p.is0())
|
|
2130
|
-
return err("bad point: ZERO");
|
|
2131
|
-
const { X, Y, Z, T } = p;
|
|
2132
|
-
const X2 = M(X * X);
|
|
2133
|
-
const Y2 = M(Y * Y);
|
|
2134
|
-
const Z2 = M(Z * Z);
|
|
2135
|
-
const Z4 = M(Z2 * Z2);
|
|
2136
|
-
const aX2 = M(X2 * a);
|
|
2137
|
-
const left = M(Z2 * M(aX2 + Y2));
|
|
2138
|
-
const right = M(Z4 + M(d * M(X2 * Y2)));
|
|
2139
|
-
if (left !== right)
|
|
2140
|
-
return err("bad point: equation left != right (1)");
|
|
2141
|
-
const XY = M(X * Y);
|
|
2142
|
-
const ZT = M(Z * T);
|
|
2143
|
-
if (XY !== ZT)
|
|
2144
|
-
return err("bad point: equation left != right (2)");
|
|
2145
|
-
return this;
|
|
2146
|
-
}
|
|
2147
|
-
/** Equality check: compare points P&Q. */
|
|
2148
|
-
equals(other) {
|
|
2149
|
-
const { X: X1, Y: Y1, Z: Z1 } = this;
|
|
2150
|
-
const { X: X2, Y: Y2, Z: Z2 } = apoint(other);
|
|
2151
|
-
const X1Z2 = M(X1 * Z2);
|
|
2152
|
-
const X2Z1 = M(X2 * Z1);
|
|
2153
|
-
const Y1Z2 = M(Y1 * Z2);
|
|
2154
|
-
const Y2Z1 = M(Y2 * Z1);
|
|
2155
|
-
return X1Z2 === X2Z1 && Y1Z2 === Y2Z1;
|
|
2156
|
-
}
|
|
2157
|
-
is0() {
|
|
2158
|
-
return this.equals(I);
|
|
2159
|
-
}
|
|
2160
|
-
/** Flip point over y coordinate. */
|
|
2161
|
-
negate() {
|
|
2162
|
-
return new _Point(M(-this.X), this.Y, this.Z, M(-this.T));
|
|
2163
|
-
}
|
|
2164
|
-
/** Point doubling. Complete formula. Cost: `4M + 4S + 1*a + 6add + 1*2`. */
|
|
2165
|
-
double() {
|
|
2166
|
-
const { X: X1, Y: Y1, Z: Z1 } = this;
|
|
2167
|
-
const a = _a;
|
|
2168
|
-
const A = M(X1 * X1);
|
|
2169
|
-
const B = M(Y1 * Y1);
|
|
2170
|
-
const C2 = M(2n * M(Z1 * Z1));
|
|
2171
|
-
const D = M(a * A);
|
|
2172
|
-
const x1y1 = X1 + Y1;
|
|
2173
|
-
const E = M(M(x1y1 * x1y1) - A - B);
|
|
2174
|
-
const G2 = D + B;
|
|
2175
|
-
const F = G2 - C2;
|
|
2176
|
-
const H = D - B;
|
|
2177
|
-
const X3 = M(E * F);
|
|
2178
|
-
const Y3 = M(G2 * H);
|
|
2179
|
-
const T3 = M(E * H);
|
|
2180
|
-
const Z3 = M(F * G2);
|
|
2181
|
-
return new _Point(X3, Y3, Z3, T3);
|
|
2182
|
-
}
|
|
2183
|
-
/** Point addition. Complete formula. Cost: `8M + 1*k + 8add + 1*2`. */
|
|
2184
|
-
add(other) {
|
|
2185
|
-
const { X: X1, Y: Y1, Z: Z1, T: T1 } = this;
|
|
2186
|
-
const { X: X2, Y: Y2, Z: Z2, T: T2 } = apoint(other);
|
|
2187
|
-
const a = _a;
|
|
2188
|
-
const d = _d;
|
|
2189
|
-
const A = M(X1 * X2);
|
|
2190
|
-
const B = M(Y1 * Y2);
|
|
2191
|
-
const C2 = M(T1 * d * T2);
|
|
2192
|
-
const D = M(Z1 * Z2);
|
|
2193
|
-
const E = M((X1 + Y1) * (X2 + Y2) - A - B);
|
|
2194
|
-
const F = M(D - C2);
|
|
2195
|
-
const G2 = M(D + C2);
|
|
2196
|
-
const H = M(B - a * A);
|
|
2197
|
-
const X3 = M(E * F);
|
|
2198
|
-
const Y3 = M(G2 * H);
|
|
2199
|
-
const T3 = M(E * H);
|
|
2200
|
-
const Z3 = M(F * G2);
|
|
2201
|
-
return new _Point(X3, Y3, Z3, T3);
|
|
2202
|
-
}
|
|
2203
|
-
subtract(other) {
|
|
2204
|
-
return this.add(apoint(other).negate());
|
|
2205
|
-
}
|
|
2206
|
-
/**
|
|
2207
|
-
* Point-by-scalar multiplication. Scalar must be in range 1 <= n < CURVE.n.
|
|
2208
|
-
* Uses {@link wNAF} for base point.
|
|
2209
|
-
* Uses fake point to mitigate side-channel leakage.
|
|
2210
|
-
* @param n scalar by which point is multiplied
|
|
2211
|
-
* @param safe safe mode guards against timing attacks; unsafe mode is faster
|
|
2212
|
-
*/
|
|
2213
|
-
multiply(n, safe = true) {
|
|
2214
|
-
if (!safe && (n === 0n || this.is0()))
|
|
2215
|
-
return I;
|
|
2216
|
-
assertRange(n, 1n, N);
|
|
2217
|
-
if (n === 1n)
|
|
2218
|
-
return this;
|
|
2219
|
-
if (this.equals(G))
|
|
2220
|
-
return wNAF(n).p;
|
|
2221
|
-
let p = I;
|
|
2222
|
-
let f = G;
|
|
2223
|
-
for (let d = this; n > 0n; d = d.double(), n >>= 1n) {
|
|
2224
|
-
if (n & 1n)
|
|
2225
|
-
p = p.add(d);
|
|
2226
|
-
else if (safe)
|
|
2227
|
-
f = f.add(d);
|
|
2228
|
-
}
|
|
2229
|
-
return p;
|
|
2230
|
-
}
|
|
2231
|
-
multiplyUnsafe(scalar) {
|
|
2232
|
-
return this.multiply(scalar, false);
|
|
2233
|
-
}
|
|
2234
|
-
/** Convert point to 2d xy affine point. (X, Y, Z) ∋ (x=X/Z, y=Y/Z) */
|
|
2235
|
-
toAffine() {
|
|
2236
|
-
const { X, Y, Z } = this;
|
|
2237
|
-
if (this.equals(I))
|
|
2238
|
-
return { x: 0n, y: 1n };
|
|
2239
|
-
const iz = invert(Z, P);
|
|
2240
|
-
if (M(Z * iz) !== 1n)
|
|
2241
|
-
err("invalid inverse");
|
|
2242
|
-
const x = M(X * iz);
|
|
2243
|
-
const y = M(Y * iz);
|
|
2244
|
-
return { x, y };
|
|
2245
|
-
}
|
|
2246
|
-
toBytes() {
|
|
2247
|
-
const { x, y } = this.assertValidity().toAffine();
|
|
2248
|
-
const b = numTo32bLE(y);
|
|
2249
|
-
b[31] |= x & 1n ? 128 : 0;
|
|
2250
|
-
return b;
|
|
2251
|
-
}
|
|
2252
|
-
toHex() {
|
|
2253
|
-
return bytesToHex(this.toBytes());
|
|
2254
|
-
}
|
|
2255
|
-
clearCofactor() {
|
|
2256
|
-
return this.multiply(big(h), false);
|
|
2257
|
-
}
|
|
2258
|
-
isSmallOrder() {
|
|
2259
|
-
return this.clearCofactor().is0();
|
|
2260
|
-
}
|
|
2261
|
-
isTorsionFree() {
|
|
2262
|
-
let p = this.multiply(N / 2n, false).double();
|
|
2263
|
-
if (N % 2n)
|
|
2264
|
-
p = p.add(this);
|
|
2265
|
-
return p.is0();
|
|
2266
|
-
}
|
|
2267
|
-
};
|
|
2268
|
-
__publicField(_Point, "BASE");
|
|
2269
|
-
__publicField(_Point, "ZERO");
|
|
2270
|
-
var Point = _Point;
|
|
2271
|
-
var G = new Point(Gx, Gy, 1n, M(Gx * Gy));
|
|
2272
|
-
var I = new Point(0n, 1n, 1n, 0n);
|
|
2273
|
-
Point.BASE = G;
|
|
2274
|
-
Point.ZERO = I;
|
|
2275
|
-
var numTo32bLE = (num) => hexToBytes(padh(assertRange(num, 0n, B256), L2)).reverse();
|
|
2276
|
-
var bytesToNumLE = (b) => big("0x" + bytesToHex(u8fr(abytes(b)).reverse()));
|
|
2277
|
-
var pow2 = (x, power) => {
|
|
2278
|
-
let r = x;
|
|
2279
|
-
while (power-- > 0n) {
|
|
2280
|
-
r *= r;
|
|
2281
|
-
r %= P;
|
|
2282
|
-
}
|
|
2283
|
-
return r;
|
|
2284
|
-
};
|
|
2285
|
-
var pow_2_252_3 = (x) => {
|
|
2286
|
-
const x2 = x * x % P;
|
|
2287
|
-
const b2 = x2 * x % P;
|
|
2288
|
-
const b4 = pow2(b2, 2n) * b2 % P;
|
|
2289
|
-
const b5 = pow2(b4, 1n) * x % P;
|
|
2290
|
-
const b10 = pow2(b5, 5n) * b5 % P;
|
|
2291
|
-
const b20 = pow2(b10, 10n) * b10 % P;
|
|
2292
|
-
const b40 = pow2(b20, 20n) * b20 % P;
|
|
2293
|
-
const b80 = pow2(b40, 40n) * b40 % P;
|
|
2294
|
-
const b160 = pow2(b80, 80n) * b80 % P;
|
|
2295
|
-
const b240 = pow2(b160, 80n) * b80 % P;
|
|
2296
|
-
const b250 = pow2(b240, 10n) * b10 % P;
|
|
2297
|
-
const pow_p_5_8 = pow2(b250, 2n) * x % P;
|
|
2298
|
-
return { pow_p_5_8, b2 };
|
|
2299
|
-
};
|
|
2300
|
-
var RM1 = 0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n;
|
|
2301
|
-
var uvRatio = (u, v) => {
|
|
2302
|
-
const v3 = M(v * v * v);
|
|
2303
|
-
const v7 = M(v3 * v3 * v);
|
|
2304
|
-
const pow = pow_2_252_3(u * v7).pow_p_5_8;
|
|
2305
|
-
let x = M(u * v3 * pow);
|
|
2306
|
-
const vx2 = M(v * x * x);
|
|
2307
|
-
const root1 = x;
|
|
2308
|
-
const root2 = M(x * RM1);
|
|
2309
|
-
const useRoot1 = vx2 === u;
|
|
2310
|
-
const useRoot2 = vx2 === M(-u);
|
|
2311
|
-
const noRoot = vx2 === M(-u * RM1);
|
|
2312
|
-
if (useRoot1)
|
|
2313
|
-
x = root1;
|
|
2314
|
-
if (useRoot2 || noRoot)
|
|
2315
|
-
x = root2;
|
|
2316
|
-
if ((M(x) & 1n) === 1n)
|
|
2317
|
-
x = M(-x);
|
|
2318
|
-
return { isValid: useRoot1 || useRoot2, value: x };
|
|
2319
|
-
};
|
|
2320
|
-
var modL_LE = (hash2) => modN(bytesToNumLE(hash2));
|
|
2321
|
-
var sha512a = (...m) => hashes.sha512Async(concatBytes(...m));
|
|
2322
|
-
var sha512s = (...m) => callHash("sha512")(concatBytes(...m));
|
|
2323
|
-
var hash2extK = (hashed) => {
|
|
2324
|
-
const head = hashed.slice(0, L);
|
|
2325
|
-
head[0] &= 248;
|
|
2326
|
-
head[31] &= 127;
|
|
2327
|
-
head[31] |= 64;
|
|
2328
|
-
const prefix = hashed.slice(L, L2);
|
|
2329
|
-
const scalar = modL_LE(head);
|
|
2330
|
-
const point = G.multiply(scalar);
|
|
2331
|
-
const pointBytes = point.toBytes();
|
|
2332
|
-
return { head, prefix, scalar, point, pointBytes };
|
|
2333
|
-
};
|
|
2334
|
-
var getExtendedPublicKeyAsync = (secretKey) => sha512a(abytes(secretKey, L)).then(hash2extK);
|
|
2335
|
-
var getExtendedPublicKey = (secretKey) => hash2extK(sha512s(abytes(secretKey, L)));
|
|
2336
|
-
var getPublicKeyAsync = (secretKey) => getExtendedPublicKeyAsync(secretKey).then((p) => p.pointBytes);
|
|
2337
|
-
var getPublicKey = (priv) => getExtendedPublicKey(priv).pointBytes;
|
|
2338
|
-
var hashFinishA = (res) => sha512a(res.hashable).then(res.finish);
|
|
2339
|
-
var hashFinishS = (res) => res.finish(sha512s(res.hashable));
|
|
2340
|
-
var _sign = (e, rBytes, msg) => {
|
|
2341
|
-
const { pointBytes: P2, scalar: s } = e;
|
|
2342
|
-
const r = modL_LE(rBytes);
|
|
2343
|
-
const R = G.multiply(r).toBytes();
|
|
2344
|
-
const hashable = concatBytes(R, P2, msg);
|
|
2345
|
-
const finish = (hashed) => {
|
|
2346
|
-
const S = modN(r + modL_LE(hashed) * s);
|
|
2347
|
-
return abytes(concatBytes(R, numTo32bLE(S)), L2);
|
|
2348
|
-
};
|
|
2349
|
-
return { hashable, finish };
|
|
2350
|
-
};
|
|
2351
|
-
var signAsync = async (message, secretKey) => {
|
|
2352
|
-
const m = abytes(message);
|
|
2353
|
-
const e = await getExtendedPublicKeyAsync(secretKey);
|
|
2354
|
-
const rBytes = await sha512a(e.prefix, m);
|
|
2355
|
-
return hashFinishA(_sign(e, rBytes, m));
|
|
2356
|
-
};
|
|
2357
|
-
var sign = (message, secretKey) => {
|
|
2358
|
-
const m = abytes(message);
|
|
2359
|
-
const e = getExtendedPublicKey(secretKey);
|
|
2360
|
-
const rBytes = sha512s(e.prefix, m);
|
|
2361
|
-
return hashFinishS(_sign(e, rBytes, m));
|
|
2362
|
-
};
|
|
2363
|
-
var defaultVerifyOpts = { zip215: true };
|
|
2364
|
-
var _verify = (sig, msg, pub, opts = defaultVerifyOpts) => {
|
|
2365
|
-
sig = abytes(sig, L2);
|
|
2366
|
-
msg = abytes(msg);
|
|
2367
|
-
pub = abytes(pub, L);
|
|
2368
|
-
const { zip215 } = opts;
|
|
2369
|
-
let A;
|
|
2370
|
-
let R;
|
|
2371
|
-
let s;
|
|
2372
|
-
let SB;
|
|
2373
|
-
let hashable = Uint8Array.of();
|
|
2374
|
-
try {
|
|
2375
|
-
A = Point.fromBytes(pub, zip215);
|
|
2376
|
-
R = Point.fromBytes(sig.slice(0, L), zip215);
|
|
2377
|
-
s = bytesToNumLE(sig.slice(L, L2));
|
|
2378
|
-
SB = G.multiply(s, false);
|
|
2379
|
-
hashable = concatBytes(R.toBytes(), A.toBytes(), msg);
|
|
2380
|
-
} catch (error) {
|
|
2381
|
-
}
|
|
2382
|
-
const finish = (hashed) => {
|
|
2383
|
-
if (SB == null)
|
|
2384
|
-
return false;
|
|
2385
|
-
if (!zip215 && A.isSmallOrder())
|
|
2386
|
-
return false;
|
|
2387
|
-
const k = modL_LE(hashed);
|
|
2388
|
-
const RkA = R.add(A.multiply(k, false));
|
|
2389
|
-
return RkA.add(SB.negate()).clearCofactor().is0();
|
|
2390
|
-
};
|
|
2391
|
-
return { hashable, finish };
|
|
2392
|
-
};
|
|
2393
|
-
var verifyAsync = async (signature, message, publicKey, opts = defaultVerifyOpts) => hashFinishA(_verify(signature, message, publicKey, opts));
|
|
2394
|
-
var verify = (signature, message, publicKey, opts = defaultVerifyOpts) => hashFinishS(_verify(signature, message, publicKey, opts));
|
|
2395
|
-
var etc = {
|
|
2396
|
-
bytesToHex,
|
|
2397
|
-
hexToBytes,
|
|
2398
|
-
concatBytes,
|
|
2399
|
-
mod: M,
|
|
2400
|
-
invert,
|
|
2401
|
-
randomBytes
|
|
2402
|
-
};
|
|
2403
|
-
var hashes = {
|
|
2404
|
-
sha512Async: async (message) => {
|
|
2405
|
-
const s = subtle();
|
|
2406
|
-
const m = concatBytes(message);
|
|
2407
|
-
return u8n(await s.digest("SHA-512", m.buffer));
|
|
2408
|
-
},
|
|
2409
|
-
sha512: void 0
|
|
2410
|
-
};
|
|
2411
|
-
var randomSecretKey = (seed = randomBytes(L)) => seed;
|
|
2412
|
-
var keygen = (seed) => {
|
|
2413
|
-
const secretKey = randomSecretKey(seed);
|
|
2414
|
-
const publicKey = getPublicKey(secretKey);
|
|
2415
|
-
return { secretKey, publicKey };
|
|
2416
|
-
};
|
|
2417
|
-
var keygenAsync = async (seed) => {
|
|
2418
|
-
const secretKey = randomSecretKey(seed);
|
|
2419
|
-
const publicKey = await getPublicKeyAsync(secretKey);
|
|
2420
|
-
return { secretKey, publicKey };
|
|
2421
|
-
};
|
|
2422
|
-
var utils = {
|
|
2423
|
-
getExtendedPublicKeyAsync,
|
|
2424
|
-
getExtendedPublicKey,
|
|
2425
|
-
randomSecretKey
|
|
2426
|
-
};
|
|
2427
|
-
var W = 8;
|
|
2428
|
-
var scalarBits = 256;
|
|
2429
|
-
var pwindows = Math.ceil(scalarBits / W) + 1;
|
|
2430
|
-
var pwindowSize = 2 ** (W - 1);
|
|
2431
|
-
var precompute = () => {
|
|
2432
|
-
const points = [];
|
|
2433
|
-
let p = G;
|
|
2434
|
-
let b = p;
|
|
2435
|
-
for (let w = 0; w < pwindows; w++) {
|
|
2436
|
-
b = p;
|
|
2437
|
-
points.push(b);
|
|
2438
|
-
for (let i = 1; i < pwindowSize; i++) {
|
|
2439
|
-
b = b.add(p);
|
|
2440
|
-
points.push(b);
|
|
2441
|
-
}
|
|
2442
|
-
p = b.double();
|
|
2443
|
-
}
|
|
2444
|
-
return points;
|
|
2445
|
-
};
|
|
2446
|
-
var Gpows = void 0;
|
|
2447
|
-
var ctneg = (cnd, p) => {
|
|
2448
|
-
const n = p.negate();
|
|
2449
|
-
return cnd ? n : p;
|
|
2450
|
-
};
|
|
2451
|
-
var wNAF = (n) => {
|
|
2452
|
-
const comp = Gpows || (Gpows = precompute());
|
|
2453
|
-
let p = I;
|
|
2454
|
-
let f = G;
|
|
2455
|
-
const pow_2_w = 2 ** W;
|
|
2456
|
-
const maxNum = pow_2_w;
|
|
2457
|
-
const mask = big(pow_2_w - 1);
|
|
2458
|
-
const shiftBy = big(W);
|
|
2459
|
-
for (let w = 0; w < pwindows; w++) {
|
|
2460
|
-
let wbits = Number(n & mask);
|
|
2461
|
-
n >>= shiftBy;
|
|
2462
|
-
if (wbits > pwindowSize) {
|
|
2463
|
-
wbits -= maxNum;
|
|
2464
|
-
n += 1n;
|
|
2465
|
-
}
|
|
2466
|
-
const off = w * pwindowSize;
|
|
2467
|
-
const offF = off;
|
|
2468
|
-
const offP = off + Math.abs(wbits) - 1;
|
|
2469
|
-
const isEven = w % 2 !== 0;
|
|
2470
|
-
const isNeg = wbits < 0;
|
|
2471
|
-
if (wbits === 0) {
|
|
2472
|
-
f = f.add(ctneg(isEven, comp[offF]));
|
|
2473
|
-
} else {
|
|
2474
|
-
p = p.add(ctneg(isNeg, comp[offP]));
|
|
2475
|
-
}
|
|
2476
|
-
}
|
|
2477
|
-
if (n !== 0n)
|
|
2478
|
-
err("invalid wnaf");
|
|
2479
|
-
return { p, f };
|
|
2480
|
-
};
|
|
1941
|
+
// src/sdk/ed25519-setup.ts
|
|
1942
|
+
import * as ed25519 from "@noble/ed25519";
|
|
2481
1943
|
|
|
2482
1944
|
// node_modules/@noble/hashes/utils.js
|
|
2483
|
-
function
|
|
1945
|
+
function isBytes2(a) {
|
|
2484
1946
|
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
2485
1947
|
}
|
|
2486
|
-
function
|
|
2487
|
-
const bytes =
|
|
1948
|
+
function abytes(value, length, title = "") {
|
|
1949
|
+
const bytes = isBytes2(value);
|
|
2488
1950
|
const len = value?.length;
|
|
2489
1951
|
const needsLen = length !== void 0;
|
|
2490
1952
|
if (!bytes || needsLen && len !== length) {
|
|
@@ -2502,7 +1964,7 @@ function aexists(instance, checkFinished = true) {
|
|
|
2502
1964
|
throw new Error("Hash#digest() has already been called");
|
|
2503
1965
|
}
|
|
2504
1966
|
function aoutput(out, instance) {
|
|
2505
|
-
|
|
1967
|
+
abytes(out, void 0, "digestInto() output");
|
|
2506
1968
|
const min = instance.outputLen;
|
|
2507
1969
|
if (out.length < min) {
|
|
2508
1970
|
throw new Error('"digestInto() output" expected to be of length >=' + min);
|
|
@@ -2552,7 +2014,7 @@ var HashMD = class {
|
|
|
2552
2014
|
}
|
|
2553
2015
|
update(data) {
|
|
2554
2016
|
aexists(this);
|
|
2555
|
-
|
|
2017
|
+
abytes(data);
|
|
2556
2018
|
const { view, buffer, blockLen } = this;
|
|
2557
2019
|
const len = data.length;
|
|
2558
2020
|
for (let pos = 0; pos < len; ) {
|
|
@@ -2657,17 +2119,17 @@ function split(lst, le = false) {
|
|
|
2657
2119
|
let Ah = new Uint32Array(len);
|
|
2658
2120
|
let Al = new Uint32Array(len);
|
|
2659
2121
|
for (let i = 0; i < len; i++) {
|
|
2660
|
-
const { h
|
|
2661
|
-
[Ah[i], Al[i]] = [
|
|
2122
|
+
const { h, l } = fromBig(lst[i], le);
|
|
2123
|
+
[Ah[i], Al[i]] = [h, l];
|
|
2662
2124
|
}
|
|
2663
2125
|
return [Ah, Al];
|
|
2664
2126
|
}
|
|
2665
|
-
var shrSH = (
|
|
2666
|
-
var shrSL = (
|
|
2667
|
-
var rotrSH = (
|
|
2668
|
-
var rotrSL = (
|
|
2669
|
-
var rotrBH = (
|
|
2670
|
-
var rotrBL = (
|
|
2127
|
+
var shrSH = (h, _l, s) => h >>> s;
|
|
2128
|
+
var shrSL = (h, l, s) => h << 32 - s | l >>> s;
|
|
2129
|
+
var rotrSH = (h, l, s) => h >>> s | l << 32 - s;
|
|
2130
|
+
var rotrSL = (h, l, s) => h << 32 - s | l >>> s;
|
|
2131
|
+
var rotrBH = (h, l, s) => h << 64 - s | l >>> s - 32;
|
|
2132
|
+
var rotrBL = (h, l, s) => h >>> s - 32 | l << 64 - s;
|
|
2671
2133
|
function add(Ah, Al, Bh, Bl) {
|
|
2672
2134
|
const l = (Al >>> 0) + (Bl >>> 0);
|
|
2673
2135
|
return { h: Ah + Bh + (l / 2 ** 32 | 0) | 0, l: l | 0 };
|
|
@@ -2888,7 +2350,8 @@ var sha512 = /* @__PURE__ */ createHasher(
|
|
|
2888
2350
|
);
|
|
2889
2351
|
|
|
2890
2352
|
// src/sdk/ed25519-setup.ts
|
|
2891
|
-
hashes.sha512 = sha512;
|
|
2353
|
+
ed25519.hashes.sha512 = sha512;
|
|
2354
|
+
var ed = ed25519;
|
|
2892
2355
|
|
|
2893
2356
|
// src/WarpFastsetWallet.ts
|
|
2894
2357
|
var WarpFastsetWallet = class {
|
|
@@ -2907,7 +2370,7 @@ var WarpFastsetWallet = class {
|
|
|
2907
2370
|
const privateKey = getWarpWalletPrivateKeyFromConfig(this.config, this.chain.name);
|
|
2908
2371
|
if (!privateKey) throw new Error("Wallet not initialized - no private key provided");
|
|
2909
2372
|
const privateKeyBytes = hexToUint8Array(privateKey);
|
|
2910
|
-
const signature =
|
|
2373
|
+
const signature = ed.sign(dataToSign, privateKeyBytes);
|
|
2911
2374
|
return { ...tx, signature };
|
|
2912
2375
|
}
|
|
2913
2376
|
async signMessage(message) {
|
|
@@ -2915,7 +2378,7 @@ var WarpFastsetWallet = class {
|
|
|
2915
2378
|
const privateKey = getWarpWalletPrivateKeyFromConfig(this.config, this.chain.name);
|
|
2916
2379
|
if (!privateKey) throw new Error("Wallet not initialized - no private key provided");
|
|
2917
2380
|
const privateKeyBytes = hexToUint8Array(privateKey);
|
|
2918
|
-
const signature =
|
|
2381
|
+
const signature = ed.sign(messageBytes, privateKeyBytes);
|
|
2919
2382
|
return uint8ArrayToHex(signature);
|
|
2920
2383
|
}
|
|
2921
2384
|
async signTransactions(txs) {
|
|
@@ -2932,15 +2395,15 @@ var WarpFastsetWallet = class {
|
|
|
2932
2395
|
create(mnemonic) {
|
|
2933
2396
|
const seed = bip39.mnemonicToSeedSync(mnemonic);
|
|
2934
2397
|
const privateKey = seed.slice(0, 32);
|
|
2935
|
-
const publicKey =
|
|
2398
|
+
const publicKey = ed.getPublicKey(privateKey);
|
|
2936
2399
|
const address = FastsetClient.encodeBech32Address(publicKey);
|
|
2937
|
-
return { address, privateKey: uint8ArrayToHex(privateKey), mnemonic };
|
|
2400
|
+
return { provider: "privateKey", address, privateKey: uint8ArrayToHex(privateKey), mnemonic };
|
|
2938
2401
|
}
|
|
2939
2402
|
generate() {
|
|
2940
|
-
const privateKey =
|
|
2941
|
-
const publicKey =
|
|
2403
|
+
const privateKey = ed.utils.randomSecretKey();
|
|
2404
|
+
const publicKey = ed.getPublicKey(privateKey);
|
|
2942
2405
|
const address = FastsetClient.encodeBech32Address(publicKey);
|
|
2943
|
-
return { address, privateKey: uint8ArrayToHex(privateKey), mnemonic: null };
|
|
2406
|
+
return { provider: "privateKey", address, privateKey: uint8ArrayToHex(privateKey), mnemonic: null };
|
|
2944
2407
|
}
|
|
2945
2408
|
getAddress() {
|
|
2946
2409
|
return getWarpWalletAddressFromConfig3(this.config, this.chain.name);
|
|
@@ -2949,7 +2412,7 @@ var WarpFastsetWallet = class {
|
|
|
2949
2412
|
const privateKey = getWarpWalletPrivateKeyFromConfig(this.config, this.chain.name);
|
|
2950
2413
|
if (privateKey) {
|
|
2951
2414
|
const privateKeyBytes = hexToUint8Array(privateKey);
|
|
2952
|
-
const publicKey =
|
|
2415
|
+
const publicKey = ed.getPublicKey(privateKeyBytes);
|
|
2953
2416
|
return uint8ArrayToHex(publicKey);
|
|
2954
2417
|
}
|
|
2955
2418
|
const address = getWarpWalletAddressFromConfig3(this.config, this.chain.name);
|
|
@@ -2970,7 +2433,7 @@ var NativeTokenSet = {
|
|
|
2970
2433
|
name: "SET",
|
|
2971
2434
|
symbol: "SET",
|
|
2972
2435
|
decimals: 0,
|
|
2973
|
-
logoUrl: "https://
|
|
2436
|
+
logoUrl: "https://joai.ai/images/tokens/set-black.svg"
|
|
2974
2437
|
};
|
|
2975
2438
|
function createFastsetAdapter(chainName, chainInfos) {
|
|
2976
2439
|
return (config, fallback) => {
|
|
@@ -2992,7 +2455,7 @@ function createFastsetAdapter(chainName, chainInfos) {
|
|
|
2992
2455
|
};
|
|
2993
2456
|
};
|
|
2994
2457
|
}
|
|
2995
|
-
var
|
|
2458
|
+
var FastsetAdapter = createFastsetAdapter(WarpChainName.Fastset, {
|
|
2996
2459
|
mainnet: {
|
|
2997
2460
|
name: WarpChainName.Fastset,
|
|
2998
2461
|
displayName: "FastSet",
|
|
@@ -3000,7 +2463,7 @@ var getFastsetAdapter = createFastsetAdapter(WarpChainName.Fastset, {
|
|
|
3000
2463
|
blockTime: 1e3,
|
|
3001
2464
|
addressHrp: "set",
|
|
3002
2465
|
defaultApiUrl: "https://proxy.fastset.xyz",
|
|
3003
|
-
logoUrl: "https://
|
|
2466
|
+
logoUrl: "https://joai.ai/images/chains/fastset-black.svg",
|
|
3004
2467
|
nativeToken: NativeTokenSet
|
|
3005
2468
|
},
|
|
3006
2469
|
testnet: {
|
|
@@ -3010,7 +2473,7 @@ var getFastsetAdapter = createFastsetAdapter(WarpChainName.Fastset, {
|
|
|
3010
2473
|
blockTime: 1e3,
|
|
3011
2474
|
addressHrp: "set",
|
|
3012
2475
|
defaultApiUrl: "https://proxy.fastset.xyz",
|
|
3013
|
-
logoUrl: "https://
|
|
2476
|
+
logoUrl: "https://joai.ai/images/chains/fastset-black.svg",
|
|
3014
2477
|
nativeToken: NativeTokenSet
|
|
3015
2478
|
},
|
|
3016
2479
|
devnet: {
|
|
@@ -3020,24 +2483,21 @@ var getFastsetAdapter = createFastsetAdapter(WarpChainName.Fastset, {
|
|
|
3020
2483
|
blockTime: 1e3,
|
|
3021
2484
|
addressHrp: "set",
|
|
3022
2485
|
defaultApiUrl: "https://proxy.fastset.xyz",
|
|
3023
|
-
logoUrl: "https://
|
|
2486
|
+
logoUrl: "https://joai.ai/images/chains/fastset-black.svg",
|
|
3024
2487
|
nativeToken: NativeTokenSet
|
|
3025
2488
|
}
|
|
3026
2489
|
});
|
|
3027
2490
|
export {
|
|
2491
|
+
FastsetAdapter,
|
|
3028
2492
|
NativeTokenSet,
|
|
3029
2493
|
WarpFastsetExecutor,
|
|
3030
|
-
WarpFastsetWallet
|
|
3031
|
-
getFastsetAdapter
|
|
2494
|
+
WarpFastsetWallet
|
|
3032
2495
|
};
|
|
3033
2496
|
/*! Bundled license information:
|
|
3034
2497
|
|
|
3035
2498
|
@scure/base/lib/esm/index.js:
|
|
3036
2499
|
(*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
3037
2500
|
|
|
3038
|
-
@noble/ed25519/index.js:
|
|
3039
|
-
(*! noble-ed25519 - MIT License (c) 2019 Paul Miller (paulmillr.com) *)
|
|
3040
|
-
|
|
3041
2501
|
@noble/hashes/utils.js:
|
|
3042
2502
|
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
3043
2503
|
*/
|