@t2000/sdk 5.1.0 → 5.3.0
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/browser.cjs +0 -43
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +1 -42
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +198 -154
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +100 -19
- package/dist/index.d.ts +100 -19
- package/dist/index.js +187 -152
- package/dist/index.js.map +1 -1
- package/dist/{types-C01EGu76.d.cts → simulate-BTIIpnXc.d.cts} +3 -39
- package/dist/{types-C01EGu76.d.ts → simulate-BTIIpnXc.d.ts} +3 -39
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1759,170 +1759,198 @@ async function normalizeAddressInput(value, ctx = {}) {
|
|
|
1759
1759
|
|
|
1760
1760
|
// src/t2000.ts
|
|
1761
1761
|
init_errors();
|
|
1762
|
+
var DEFAULT_CONFIG_DIR = join(homedir(), ".t2000");
|
|
1763
|
+
function resolveConfigPath(configDir) {
|
|
1764
|
+
return join(configDir ?? DEFAULT_CONFIG_DIR, "config.json");
|
|
1765
|
+
}
|
|
1766
|
+
function todayUtc() {
|
|
1767
|
+
return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
1768
|
+
}
|
|
1769
|
+
function readLimitsFile(configDir) {
|
|
1770
|
+
const path = resolveConfigPath(configDir);
|
|
1771
|
+
try {
|
|
1772
|
+
return sanitize(JSON.parse(readFileSync(path, "utf-8")));
|
|
1773
|
+
} catch {
|
|
1774
|
+
return {};
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
function writeLimitsFile(file, configDir) {
|
|
1778
|
+
const path = resolveConfigPath(configDir);
|
|
1779
|
+
let existing = {};
|
|
1780
|
+
try {
|
|
1781
|
+
existing = JSON.parse(readFileSync(path, "utf-8"));
|
|
1782
|
+
} catch {
|
|
1783
|
+
existing = {};
|
|
1784
|
+
}
|
|
1785
|
+
for (const dead of ["maxPerTx", "maxDailySend", "dailyUsed", "dailyResetDate", "locked"]) {
|
|
1786
|
+
delete existing[dead];
|
|
1787
|
+
}
|
|
1788
|
+
const merged = { ...existing };
|
|
1789
|
+
if (file.limits && (file.limits.perTxUsd !== void 0 || file.limits.dailyUsd !== void 0)) {
|
|
1790
|
+
merged.limits = file.limits;
|
|
1791
|
+
} else {
|
|
1792
|
+
delete merged.limits;
|
|
1793
|
+
}
|
|
1794
|
+
if (file.dailySpend) merged.dailySpend = file.dailySpend;
|
|
1795
|
+
else delete merged.dailySpend;
|
|
1796
|
+
const dir = dirname(path);
|
|
1797
|
+
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
1798
|
+
writeFileSync(path, JSON.stringify(merged, null, 2) + "\n", { mode: 384 });
|
|
1799
|
+
return path;
|
|
1800
|
+
}
|
|
1801
|
+
function getLimits(configDir) {
|
|
1802
|
+
return readLimitsFile(configDir).limits;
|
|
1803
|
+
}
|
|
1804
|
+
function hasLimits(configDir) {
|
|
1805
|
+
const l = readLimitsFile(configDir).limits;
|
|
1806
|
+
return !!l && (l.perTxUsd !== void 0 || l.dailyUsd !== void 0);
|
|
1807
|
+
}
|
|
1808
|
+
function setLimits(limits, configDir) {
|
|
1809
|
+
const file = readLimitsFile(configDir);
|
|
1810
|
+
const merged = { ...file.limits };
|
|
1811
|
+
if (limits.perTxUsd !== void 0) merged.perTxUsd = limits.perTxUsd;
|
|
1812
|
+
if (limits.dailyUsd !== void 0) merged.dailyUsd = limits.dailyUsd;
|
|
1813
|
+
return writeLimitsFile({ ...file, limits: merged }, configDir);
|
|
1814
|
+
}
|
|
1815
|
+
function clearLimits(configDir) {
|
|
1816
|
+
const file = readLimitsFile(configDir);
|
|
1817
|
+
return writeLimitsFile({ ...file, limits: void 0 }, configDir);
|
|
1818
|
+
}
|
|
1819
|
+
function dailySpentToday(configDir) {
|
|
1820
|
+
const { dailySpend } = readLimitsFile(configDir);
|
|
1821
|
+
if (!dailySpend || dailySpend.date !== todayUtc()) return 0;
|
|
1822
|
+
return dailySpend.usd;
|
|
1823
|
+
}
|
|
1824
|
+
function recordDailySpend(usd, configDir) {
|
|
1825
|
+
if (!Number.isFinite(usd) || usd <= 0) return;
|
|
1826
|
+
const file = readLimitsFile(configDir);
|
|
1827
|
+
const today = todayUtc();
|
|
1828
|
+
const prior = file.dailySpend && file.dailySpend.date === today ? file.dailySpend.usd : 0;
|
|
1829
|
+
writeLimitsFile({ ...file, dailySpend: { date: today, usd: prior + usd } }, configDir);
|
|
1830
|
+
}
|
|
1831
|
+
function sanitize(raw) {
|
|
1832
|
+
if (typeof raw !== "object" || raw === null) return {};
|
|
1833
|
+
const r = raw;
|
|
1834
|
+
const out = {};
|
|
1835
|
+
if (typeof r.limits === "object" && r.limits !== null) {
|
|
1836
|
+
const l = r.limits;
|
|
1837
|
+
const limits = {};
|
|
1838
|
+
if (typeof l.perTxUsd === "number" && l.perTxUsd > 0) limits.perTxUsd = l.perTxUsd;
|
|
1839
|
+
if (typeof l.dailyUsd === "number" && l.dailyUsd > 0) limits.dailyUsd = l.dailyUsd;
|
|
1840
|
+
else if (typeof l.dailySendUsd === "number" && l.dailySendUsd > 0) limits.dailyUsd = l.dailySendUsd;
|
|
1841
|
+
if (limits.perTxUsd !== void 0 || limits.dailyUsd !== void 0) out.limits = limits;
|
|
1842
|
+
}
|
|
1843
|
+
if (typeof r.dailySpend === "object" && r.dailySpend !== null) {
|
|
1844
|
+
const d = r.dailySpend;
|
|
1845
|
+
if (typeof d.date === "string" && typeof d.usd === "number" && d.usd >= 0) {
|
|
1846
|
+
out.dailySpend = { date: d.date, usd: d.usd };
|
|
1847
|
+
}
|
|
1848
|
+
}
|
|
1849
|
+
return out;
|
|
1850
|
+
}
|
|
1762
1851
|
|
|
1763
|
-
// src/
|
|
1764
|
-
var
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
this.name = "SafeguardError";
|
|
1781
|
-
this.rule = rule;
|
|
1782
|
-
this.details = details;
|
|
1852
|
+
// src/limits/errors.ts
|
|
1853
|
+
var LimitExceededError = class extends Error {
|
|
1854
|
+
code = "LIMIT_EXCEEDED";
|
|
1855
|
+
operation;
|
|
1856
|
+
limitKind;
|
|
1857
|
+
limit;
|
|
1858
|
+
attempted;
|
|
1859
|
+
constructor(params) {
|
|
1860
|
+
const label = params.limitKind === "perTxUsd" ? "per-transaction limit" : "daily spend limit";
|
|
1861
|
+
super(
|
|
1862
|
+
`Exceeds ${label} ($${params.limit}). Attempted $${params.attempted.toFixed(2)}. Use --force / force:true to override.`
|
|
1863
|
+
);
|
|
1864
|
+
this.name = "LimitExceededError";
|
|
1865
|
+
this.operation = params.operation;
|
|
1866
|
+
this.limitKind = params.limitKind;
|
|
1867
|
+
this.limit = params.limit;
|
|
1868
|
+
this.attempted = params.attempted;
|
|
1783
1869
|
}
|
|
1784
1870
|
toJSON() {
|
|
1785
1871
|
return {
|
|
1786
|
-
error:
|
|
1872
|
+
error: this.code,
|
|
1787
1873
|
message: this.message,
|
|
1788
|
-
|
|
1789
|
-
|
|
1874
|
+
operation: this.operation,
|
|
1875
|
+
limitKind: this.limitKind,
|
|
1876
|
+
limit: this.limit,
|
|
1877
|
+
attempted: this.attempted
|
|
1790
1878
|
};
|
|
1791
1879
|
}
|
|
1792
1880
|
};
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1881
|
+
|
|
1882
|
+
// src/limits/enforce.ts
|
|
1883
|
+
function approxUsdValue(asset, amount) {
|
|
1884
|
+
const symbol = asset.toUpperCase();
|
|
1885
|
+
if (symbol === "USDC" || symbol === "USDSUI") return amount;
|
|
1886
|
+
return null;
|
|
1887
|
+
}
|
|
1888
|
+
function assertLimitConfig(input) {
|
|
1889
|
+
if (input.force) return;
|
|
1890
|
+
if (!Number.isFinite(input.amountUsd) || input.amountUsd <= 0) return;
|
|
1891
|
+
const { limits } = input;
|
|
1892
|
+
if (!limits) return;
|
|
1893
|
+
if (limits.perTxUsd !== void 0 && input.amountUsd > limits.perTxUsd) {
|
|
1894
|
+
throw new LimitExceededError({
|
|
1895
|
+
operation: input.operation,
|
|
1896
|
+
limitKind: "perTxUsd",
|
|
1897
|
+
limit: limits.perTxUsd,
|
|
1898
|
+
attempted: input.amountUsd
|
|
1899
|
+
});
|
|
1900
|
+
}
|
|
1901
|
+
if (limits.dailyUsd !== void 0 && input.spentTodayUsd + input.amountUsd > limits.dailyUsd) {
|
|
1902
|
+
throw new LimitExceededError({
|
|
1903
|
+
operation: input.operation,
|
|
1904
|
+
limitKind: "dailyUsd",
|
|
1905
|
+
// The cap is total/day; report the cap (attempted is THIS write's USD).
|
|
1906
|
+
limit: limits.dailyUsd,
|
|
1907
|
+
attempted: input.spentTodayUsd + input.amountUsd
|
|
1908
|
+
});
|
|
1801
1909
|
}
|
|
1802
1910
|
}
|
|
1803
|
-
|
|
1804
|
-
// src/safeguards/enforcer.ts
|
|
1805
|
-
var SafeguardEnforcer = class {
|
|
1806
|
-
config;
|
|
1807
|
-
configPath;
|
|
1911
|
+
var LimitEnforcer = class {
|
|
1808
1912
|
constructor(configDir) {
|
|
1809
|
-
this.
|
|
1810
|
-
|
|
1913
|
+
this.configDir = configDir;
|
|
1914
|
+
}
|
|
1915
|
+
/** Throws `LimitExceededError` when the write exceeds an opted-in cap. */
|
|
1916
|
+
assert(input) {
|
|
1917
|
+
assertLimitConfig({
|
|
1918
|
+
limits: getLimits(this.configDir),
|
|
1919
|
+
spentTodayUsd: dailySpentToday(this.configDir),
|
|
1920
|
+
operation: input.operation,
|
|
1921
|
+
amountUsd: input.amountUsd,
|
|
1922
|
+
force: input.force
|
|
1923
|
+
});
|
|
1811
1924
|
}
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
const raw = JSON.parse(readFileSync(this.configPath, "utf-8"));
|
|
1816
|
-
this.config = {
|
|
1817
|
-
...DEFAULT_SAFEGUARD_CONFIG,
|
|
1818
|
-
locked: raw.locked ?? false,
|
|
1819
|
-
maxPerTx: raw.maxPerTx ?? 0,
|
|
1820
|
-
maxDailySend: raw.maxDailySend ?? 0,
|
|
1821
|
-
dailyUsed: raw.dailyUsed ?? 0,
|
|
1822
|
-
dailyResetDate: raw.dailyResetDate ?? ""
|
|
1823
|
-
};
|
|
1824
|
-
} catch {
|
|
1825
|
-
this.config = { ...DEFAULT_SAFEGUARD_CONFIG };
|
|
1826
|
-
}
|
|
1925
|
+
/** Add a settled write's USD value to today's cumulative total. */
|
|
1926
|
+
record(amountUsd) {
|
|
1927
|
+
recordDailySpend(amountUsd, this.configDir);
|
|
1827
1928
|
}
|
|
1828
|
-
|
|
1829
|
-
this.
|
|
1830
|
-
if (this.config.locked) {
|
|
1831
|
-
throw new SafeguardError("locked", {});
|
|
1832
|
-
}
|
|
1929
|
+
getLimits() {
|
|
1930
|
+
return getLimits(this.configDir);
|
|
1833
1931
|
}
|
|
1834
|
-
|
|
1835
|
-
this.
|
|
1836
|
-
if (this.config.locked) {
|
|
1837
|
-
throw new SafeguardError("locked", {});
|
|
1838
|
-
}
|
|
1839
|
-
const amount = metadata.amount ?? 0;
|
|
1840
|
-
if (this.config.maxPerTx > 0 && amount > this.config.maxPerTx) {
|
|
1841
|
-
throw new SafeguardError("maxPerTx", {
|
|
1842
|
-
attempted: amount,
|
|
1843
|
-
limit: this.config.maxPerTx
|
|
1844
|
-
});
|
|
1845
|
-
}
|
|
1846
|
-
this.resetDailyIfNewDay();
|
|
1847
|
-
if (this.config.maxDailySend > 0 && this.config.dailyUsed + amount > this.config.maxDailySend) {
|
|
1848
|
-
throw new SafeguardError("maxDailySend", {
|
|
1849
|
-
attempted: amount,
|
|
1850
|
-
limit: this.config.maxDailySend,
|
|
1851
|
-
current: this.config.dailyUsed
|
|
1852
|
-
});
|
|
1853
|
-
}
|
|
1932
|
+
hasLimits() {
|
|
1933
|
+
return hasLimits(this.configDir);
|
|
1854
1934
|
}
|
|
1855
|
-
|
|
1856
|
-
this.
|
|
1857
|
-
this.config.dailyUsed += amount;
|
|
1858
|
-
this.save();
|
|
1859
|
-
}
|
|
1860
|
-
lock() {
|
|
1861
|
-
this.config.locked = true;
|
|
1862
|
-
this.save();
|
|
1863
|
-
}
|
|
1864
|
-
unlock() {
|
|
1865
|
-
this.config.locked = false;
|
|
1866
|
-
this.save();
|
|
1867
|
-
}
|
|
1868
|
-
set(key, value) {
|
|
1869
|
-
if (key === "locked" && typeof value === "boolean") {
|
|
1870
|
-
this.config.locked = value;
|
|
1871
|
-
} else if (key === "maxPerTx" && typeof value === "number") {
|
|
1872
|
-
this.config.maxPerTx = value;
|
|
1873
|
-
} else if (key === "maxDailySend" && typeof value === "number") {
|
|
1874
|
-
this.config.maxDailySend = value;
|
|
1875
|
-
}
|
|
1876
|
-
this.save();
|
|
1877
|
-
}
|
|
1878
|
-
getConfig() {
|
|
1879
|
-
this.load();
|
|
1880
|
-
this.resetDailyIfNewDay();
|
|
1881
|
-
return { ...this.config };
|
|
1882
|
-
}
|
|
1883
|
-
isConfigured() {
|
|
1884
|
-
return this.config.maxPerTx > 0 || this.config.maxDailySend > 0;
|
|
1885
|
-
}
|
|
1886
|
-
resetDailyIfNewDay() {
|
|
1887
|
-
const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
1888
|
-
if (this.config.dailyResetDate !== today) {
|
|
1889
|
-
this.config.dailyUsed = 0;
|
|
1890
|
-
this.config.dailyResetDate = today;
|
|
1891
|
-
this.save();
|
|
1892
|
-
}
|
|
1935
|
+
setLimits(limits) {
|
|
1936
|
+
setLimits(limits, this.configDir);
|
|
1893
1937
|
}
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
existing = JSON.parse(readFileSync(this.configPath, "utf-8"));
|
|
1900
|
-
} catch {
|
|
1901
|
-
}
|
|
1902
|
-
const merged = {
|
|
1903
|
-
...existing,
|
|
1904
|
-
locked: this.config.locked,
|
|
1905
|
-
maxPerTx: this.config.maxPerTx,
|
|
1906
|
-
maxDailySend: this.config.maxDailySend,
|
|
1907
|
-
dailyUsed: this.config.dailyUsed,
|
|
1908
|
-
dailyResetDate: this.config.dailyResetDate
|
|
1909
|
-
};
|
|
1910
|
-
const dir = this.configPath.replace(/[/\\][^/\\]+$/, "");
|
|
1911
|
-
if (!existsSync(dir)) {
|
|
1912
|
-
mkdirSync(dir, { recursive: true });
|
|
1913
|
-
}
|
|
1914
|
-
writeFileSync(this.configPath, JSON.stringify(merged, null, 2) + "\n");
|
|
1915
|
-
} catch {
|
|
1916
|
-
}
|
|
1938
|
+
clearLimits() {
|
|
1939
|
+
clearLimits(this.configDir);
|
|
1940
|
+
}
|
|
1941
|
+
dailySpentToday() {
|
|
1942
|
+
return dailySpentToday(this.configDir);
|
|
1917
1943
|
}
|
|
1918
1944
|
};
|
|
1919
|
-
var
|
|
1945
|
+
var DEFAULT_CONFIG_DIR2 = join(homedir(), ".t2000");
|
|
1920
1946
|
var T2000 = class _T2000 extends EventEmitter {
|
|
1921
1947
|
_signer;
|
|
1922
1948
|
_keypair;
|
|
1923
1949
|
client;
|
|
1924
1950
|
_address;
|
|
1925
|
-
|
|
1951
|
+
/** Unified spending-limit gate (per-tx + cumulative daily, USD). Shared by
|
|
1952
|
+
* CLI + MCP + programmatic writes — one gate, no bypass (R-0 Finding 1). */
|
|
1953
|
+
limits;
|
|
1926
1954
|
constructor(keypairOrSigner, client, configDir, isSignerMode) {
|
|
1927
1955
|
super();
|
|
1928
1956
|
if (isSignerMode) {
|
|
@@ -1936,8 +1964,7 @@ var T2000 = class _T2000 extends EventEmitter {
|
|
|
1936
1964
|
this._address = getAddress(kp);
|
|
1937
1965
|
}
|
|
1938
1966
|
this.client = client;
|
|
1939
|
-
this.
|
|
1940
|
-
this.enforcer.load();
|
|
1967
|
+
this.limits = new LimitEnforcer(configDir);
|
|
1941
1968
|
}
|
|
1942
1969
|
static async create(options = {}) {
|
|
1943
1970
|
const { keyPath, rpcUrl } = options;
|
|
@@ -1950,7 +1977,7 @@ var T2000 = class _T2000 extends EventEmitter {
|
|
|
1950
1977
|
);
|
|
1951
1978
|
}
|
|
1952
1979
|
const keypair = await loadKey(void 0, keyPath);
|
|
1953
|
-
return new _T2000(keypair, client,
|
|
1980
|
+
return new _T2000(keypair, client, DEFAULT_CONFIG_DIR2);
|
|
1954
1981
|
}
|
|
1955
1982
|
static fromPrivateKey(privateKey, options = {}) {
|
|
1956
1983
|
const keypair = keypairFromPrivateKey(privateKey);
|
|
@@ -1961,7 +1988,7 @@ var T2000 = class _T2000 extends EventEmitter {
|
|
|
1961
1988
|
const keypair = generateKeypair();
|
|
1962
1989
|
await saveKey(keypair, void 0, options.keyPath);
|
|
1963
1990
|
const client = getSuiClient();
|
|
1964
|
-
const agent = new _T2000(keypair, client,
|
|
1991
|
+
const agent = new _T2000(keypair, client, DEFAULT_CONFIG_DIR2);
|
|
1965
1992
|
const address = agent.address();
|
|
1966
1993
|
return { agent, address };
|
|
1967
1994
|
}
|
|
@@ -1983,11 +2010,10 @@ var T2000 = class _T2000 extends EventEmitter {
|
|
|
1983
2010
|
}
|
|
1984
2011
|
// -- MPP Payments --
|
|
1985
2012
|
async pay(options) {
|
|
1986
|
-
this.
|
|
1987
|
-
this.enforcer.check({ operation: "pay", amount: options.maxPrice ?? 1 });
|
|
2013
|
+
this.limits.assert({ operation: "pay", amountUsd: options.maxPrice ?? 0, force: options.force });
|
|
1988
2014
|
const result = await payWithMpp({ signer: this._signer, client: this.client, options });
|
|
1989
2015
|
if (result.paid) {
|
|
1990
|
-
this.
|
|
2016
|
+
this.limits.record(result.cost ?? options.maxPrice ?? 0);
|
|
1991
2017
|
}
|
|
1992
2018
|
return result;
|
|
1993
2019
|
}
|
|
@@ -2001,7 +2027,11 @@ var T2000 = class _T2000 extends EventEmitter {
|
|
|
2001
2027
|
// and the S.323 build-tracker entry.
|
|
2002
2028
|
// -- Swap --
|
|
2003
2029
|
async swap(params) {
|
|
2004
|
-
this.
|
|
2030
|
+
this.limits.assert({
|
|
2031
|
+
operation: "swap",
|
|
2032
|
+
amountUsd: approxUsdValue(params.from, params.amount) ?? 0,
|
|
2033
|
+
force: params.force
|
|
2034
|
+
});
|
|
2005
2035
|
const { findSwapRoute: findSwapRoute2, buildSwapTx: buildSwapTx2, resolveTokenType: resolveTokenType2 } = await Promise.resolve().then(() => (init_cetus_swap(), cetus_swap_exports));
|
|
2006
2036
|
const fromType = resolveTokenType2(params.from);
|
|
2007
2037
|
const toType = resolveTokenType2(params.to);
|
|
@@ -2093,6 +2123,7 @@ var T2000 = class _T2000 extends EventEmitter {
|
|
|
2093
2123
|
const fromName = resolveSymbol(fromType);
|
|
2094
2124
|
const toName = resolveSymbol(toType);
|
|
2095
2125
|
const routeDesc = route.routerData.paths?.map((p) => p.provider).filter(Boolean).slice(0, 3).join(" + ") ?? "Cetus Aggregator";
|
|
2126
|
+
this.limits.record(approxUsdValue(params.from, params.amount) ?? 0);
|
|
2096
2127
|
return {
|
|
2097
2128
|
success: true,
|
|
2098
2129
|
tx: gasResult.digest,
|
|
@@ -2149,7 +2180,6 @@ var T2000 = class _T2000 extends EventEmitter {
|
|
|
2149
2180
|
* the "build via gRPC, execute via JSON-RPC" hybrid).
|
|
2150
2181
|
*/
|
|
2151
2182
|
async send(params) {
|
|
2152
|
-
this.enforcer.assertNotLocked();
|
|
2153
2183
|
const asset = params.asset;
|
|
2154
2184
|
if (!asset) {
|
|
2155
2185
|
throw new T2000Error(
|
|
@@ -2159,6 +2189,11 @@ var T2000 = class _T2000 extends EventEmitter {
|
|
|
2159
2189
|
}
|
|
2160
2190
|
assertAllowedAsset("send", asset);
|
|
2161
2191
|
const sendableAsset = asset;
|
|
2192
|
+
this.limits.assert({
|
|
2193
|
+
operation: "send",
|
|
2194
|
+
amountUsd: approxUsdValue(sendableAsset, params.amount) ?? 0,
|
|
2195
|
+
force: params.force
|
|
2196
|
+
});
|
|
2162
2197
|
const resolved = await this.resolveRecipient(params.to);
|
|
2163
2198
|
const sendAmount = params.amount;
|
|
2164
2199
|
const sendTo = resolved.address;
|
|
@@ -2170,7 +2205,7 @@ var T2000 = class _T2000 extends EventEmitter {
|
|
|
2170
2205
|
() => buildSendTx({ client: this.client, address: this._address, to: sendTo, amount: sendAmount, asset: sendableAsset }),
|
|
2171
2206
|
{ buildClient }
|
|
2172
2207
|
);
|
|
2173
|
-
this.
|
|
2208
|
+
this.limits.record(approxUsdValue(sendableAsset, sendAmount) ?? 0);
|
|
2174
2209
|
const balance = await this.balance();
|
|
2175
2210
|
this.emitBalanceChange(sendableAsset, sendAmount, "send", gasResult.digest);
|
|
2176
2211
|
return {
|
|
@@ -2722,6 +2757,6 @@ function displayHandle(label) {
|
|
|
2722
2757
|
return `${label}@${parentDisplay}`;
|
|
2723
2758
|
}
|
|
2724
2759
|
|
|
2725
|
-
export { AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, CETUS_USDC_SUI_POOL, CLOCK_ID, COIN_REGISTRY, DEFAULT_GRPC_URL, DEFAULT_NETWORK,
|
|
2760
|
+
export { AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, CETUS_USDC_SUI_POOL, CLOCK_ID, COIN_REGISTRY, DEFAULT_GRPC_URL, DEFAULT_NETWORK, ETH_TYPE, GASLESS_MIN_STABLE_AMOUNT, GASLESS_STABLE_TYPES, GAS_RESERVE_MIN, IKA_TYPE, InvalidAddressError, KNOWN_TARGETS, KeypairSigner, LABEL_PATTERNS, LOFI_TYPE, LimitEnforcer, LimitExceededError, MANIFEST_TYPE, MIST_PER_SUI, NAVX_TYPE, OPERATION_ASSETS, OVERLAY_FEE_RATE, SENDABLE_ASSETS, SPONSORED_PYTH_DEPENDENT_PROVIDERS, STABLE_ASSETS, SUINS_NAME_REGEX, SUI_ADDRESS_REGEX, SUI_ADDRESS_STRICT_REGEX, SUI_DECIMALS, SUI_TYPE, SUPPORTED_ASSETS, SuinsNotRegisteredError, SuinsRpcError, T2000, T2000Error, T2000_OVERLAY_FEE_WALLET, TOKEN_MAP, USDC_DECIMALS, USDC_TYPE, USDE_TYPE, USDSUI_TYPE, USDT_TYPE, WAL_TYPE, WBTC_TYPE, WRITE_APPENDER_REGISTRY, ZkLoginSigner, addSendToTx, addSwapToTx, approxUsdValue, assertAllowedAsset, assertLimitConfig, buildAddLeafTx, buildRevokeLeafTx, buildSendTx, buildSwapTx, classifyAction, classifyLabel, classifyTransaction, clearLimits, composeTx, dailySpentToday, deriveAllowedAddressesFromPtb, deserializeCetusRoute, displayHandle, executeTx, exportPrivateKey, extractAllUserLegs, extractTransferDetails, extractTxCommands, extractTxSender, fallbackLabel, fetchAllCoins, findSwapRoute, formatAssetAmount, formatSui, formatUsd, fullHandle, generateKeypair, getAddress, getCoinMeta, getDecimals, getDecimalsForCoinType, getLimits, getSponsoredSwapProviders, getSuiClient, getSuiGrpcClient, getSwapQuote, hasLimits, isAllowedAsset, isCetusRouteFresh, isInRegistry, keypairFromPrivateKey, loadKey, looksLikeSuiNs, mapMoveAbortCode, mapWalletError, mistToSui, normalizeAddressInput, normalizeAsset, normalizeCoinType, parseSuiRpcTx, payWithMpp, queryHistory, queryTransaction, rawToStable, rawToUsdc, readLimitsFile, recordDailySpend, refineLendingLabel, resolveAddressToSuinsViaRpc, resolveSuinsViaRpc, resolveSymbol, resolveTokenType, saveBech32, saveKey, selectAndSplitCoin, selectSuiCoin, serializeCetusRoute, setLimits, simulateTransaction, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, validateLabel, verifyCetusRouteCoinMatch, walletExists, writeLimitsFile };
|
|
2726
2761
|
//# sourceMappingURL=index.js.map
|
|
2727
2762
|
//# sourceMappingURL=index.js.map
|