@t2000/sdk 10.24.0 → 10.25.1
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 +37 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -1
- package/dist/index.d.ts +24 -1
- package/dist/index.js +34 -7
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1942,10 +1942,19 @@ var REVERSE_NAME_QUERY = `query ReverseSuins($address: SuiAddress!) {
|
|
|
1942
1942
|
var SUI_ADDRESS_REGEX = /^0x[a-fA-F0-9]{1,64}$/i;
|
|
1943
1943
|
var SUI_ADDRESS_STRICT_REGEX = /^0x[a-fA-F0-9]{64}$/i;
|
|
1944
1944
|
var SUINS_NAME_REGEX = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.sui$/;
|
|
1945
|
+
var AUDRIC_HANDLE_RE = /^([a-z0-9-]+)@audric$/i;
|
|
1946
|
+
function canonicalizeRecipientInput(raw) {
|
|
1947
|
+
const trimmed = raw.trim();
|
|
1948
|
+
const m = AUDRIC_HANDLE_RE.exec(trimmed);
|
|
1949
|
+
if (m) {
|
|
1950
|
+
return `${m[1].toLowerCase()}.audric.sui`;
|
|
1951
|
+
}
|
|
1952
|
+
return trimmed;
|
|
1953
|
+
}
|
|
1945
1954
|
var InvalidAddressError = class extends Error {
|
|
1946
1955
|
constructor(raw) {
|
|
1947
1956
|
super(
|
|
1948
|
-
`"${raw}" isn't a valid Sui address or SuiNS name. Pass a 0x-prefixed hex address (e.g. 0x40cd\u20263e62)
|
|
1957
|
+
`"${raw}" isn't a valid Sui address or SuiNS name. Pass a 0x-prefixed hex address (e.g. 0x40cd\u20263e62), a SuiNS name ending in .sui (e.g. alex.sui), or a Passport handle (e.g. alex@audric).`
|
|
1949
1958
|
);
|
|
1950
1959
|
this.raw = raw;
|
|
1951
1960
|
this.name = "InvalidAddressError";
|
|
@@ -1969,10 +1978,10 @@ var SuinsRpcError = class extends Error {
|
|
|
1969
1978
|
};
|
|
1970
1979
|
function looksLikeSuiNs(value) {
|
|
1971
1980
|
if (!value) return false;
|
|
1972
|
-
return SUINS_NAME_REGEX.test(value
|
|
1981
|
+
return SUINS_NAME_REGEX.test(canonicalizeRecipientInput(value).toLowerCase());
|
|
1973
1982
|
}
|
|
1974
1983
|
async function resolveSuinsViaRpc(rawName, ctx = {}) {
|
|
1975
|
-
const name = rawName
|
|
1984
|
+
const name = canonicalizeRecipientInput(rawName).toLowerCase();
|
|
1976
1985
|
if (!SUINS_NAME_REGEX.test(name)) {
|
|
1977
1986
|
throw new InvalidAddressError(rawName);
|
|
1978
1987
|
}
|
|
@@ -2017,7 +2026,7 @@ async function resolveAddressToSuinsViaRpc(rawAddress, ctx = {}) {
|
|
|
2017
2026
|
return domain ? [domain] : [];
|
|
2018
2027
|
}
|
|
2019
2028
|
async function normalizeAddressInput(value, ctx = {}) {
|
|
2020
|
-
const trimmed = value
|
|
2029
|
+
const trimmed = canonicalizeRecipientInput(value);
|
|
2021
2030
|
if (SUI_ADDRESS_REGEX.test(trimmed)) {
|
|
2022
2031
|
return { address: trimmed.toLowerCase(), suinsName: null, raw: value };
|
|
2023
2032
|
}
|
|
@@ -3080,7 +3089,7 @@ var T2000 = class _T2000 extends eventemitter3.EventEmitter {
|
|
|
3080
3089
|
* with the live execute path (never resolve the same input two ways).
|
|
3081
3090
|
*/
|
|
3082
3091
|
async resolveRecipient(input) {
|
|
3083
|
-
const trimmed = input
|
|
3092
|
+
const trimmed = canonicalizeRecipientInput(input);
|
|
3084
3093
|
if (SUI_ADDRESS_REGEX.test(trimmed)) {
|
|
3085
3094
|
return { address: trimmed.toLowerCase() };
|
|
3086
3095
|
}
|
|
@@ -3104,7 +3113,7 @@ var T2000 = class _T2000 extends eventemitter3.EventEmitter {
|
|
|
3104
3113
|
}
|
|
3105
3114
|
throw new exports.T2000Error(
|
|
3106
3115
|
"INVALID_ADDRESS",
|
|
3107
|
-
`Cannot resolve recipient "${input}". Provide a 0x address
|
|
3116
|
+
`Cannot resolve recipient "${input}". Provide a 0x address, a .sui name, or a Passport handle (name@audric).`
|
|
3108
3117
|
);
|
|
3109
3118
|
}
|
|
3110
3119
|
async balance() {
|
|
@@ -3771,6 +3780,24 @@ function refundOpenJob(base, signer, openingId) {
|
|
|
3771
3780
|
});
|
|
3772
3781
|
}
|
|
3773
3782
|
|
|
3783
|
+
// src/utils/resolve-created.ts
|
|
3784
|
+
var OPENING_TYPE_MARKER = "::opening::Opening<";
|
|
3785
|
+
var ESCROW_JOB_TYPE_MARKER = "::escrow::Job<";
|
|
3786
|
+
async function resolveCreatedObjectId(client, digest, marker, opts = {}) {
|
|
3787
|
+
try {
|
|
3788
|
+
const result = await client.core.waitForTransaction({
|
|
3789
|
+
digest,
|
|
3790
|
+
include: { objectTypes: true },
|
|
3791
|
+
timeout: opts.timeoutMs ?? 15e3
|
|
3792
|
+
});
|
|
3793
|
+
const txn = result.$kind === "Transaction" ? result.Transaction : result.FailedTransaction;
|
|
3794
|
+
const types = txn.objectTypes ?? {};
|
|
3795
|
+
return Object.keys(types).find((id) => types[id]?.includes(marker));
|
|
3796
|
+
} catch {
|
|
3797
|
+
return void 0;
|
|
3798
|
+
}
|
|
3799
|
+
}
|
|
3800
|
+
|
|
3774
3801
|
// src/index.ts
|
|
3775
3802
|
init_coinSelection();
|
|
3776
3803
|
|
|
@@ -4204,6 +4231,7 @@ exports.DEFAULT_API_BASE = DEFAULT_API_BASE;
|
|
|
4204
4231
|
exports.DEFAULT_COMMERCE_API_BASE = DEFAULT_COMMERCE_API_BASE;
|
|
4205
4232
|
exports.DEFAULT_GRPC_URL = DEFAULT_GRPC_URL;
|
|
4206
4233
|
exports.DEFAULT_NETWORK = DEFAULT_NETWORK;
|
|
4234
|
+
exports.ESCROW_JOB_TYPE_MARKER = ESCROW_JOB_TYPE_MARKER;
|
|
4207
4235
|
exports.GASLESS_MIN_STABLE_AMOUNT = GASLESS_MIN_STABLE_AMOUNT;
|
|
4208
4236
|
exports.GASLESS_STABLE_TYPES = GASLESS_STABLE_TYPES;
|
|
4209
4237
|
exports.GAS_RESERVE_MIN = GAS_RESERVE_MIN;
|
|
@@ -4220,6 +4248,7 @@ exports.MAX_OPEN_WINDOW_MS = MAX_OPEN_WINDOW_MS;
|
|
|
4220
4248
|
exports.MAX_REVIEW_WINDOW_MS = MAX_REVIEW_WINDOW_MS;
|
|
4221
4249
|
exports.MIST_PER_SUI = MIST_PER_SUI;
|
|
4222
4250
|
exports.OPENING_CLAIM_POLICY_ANY_ACTIVE = OPENING_CLAIM_POLICY_ANY_ACTIVE;
|
|
4251
|
+
exports.OPENING_TYPE_MARKER = OPENING_TYPE_MARKER;
|
|
4223
4252
|
exports.OPERATION_ASSETS = OPERATION_ASSETS;
|
|
4224
4253
|
exports.SENDABLE_ASSETS = SENDABLE_ASSETS;
|
|
4225
4254
|
exports.SPONSORED_PYTH_DEPENDENT_PROVIDERS = SPONSORED_PYTH_DEPENDENT_PROVIDERS;
|
|
@@ -4257,6 +4286,7 @@ exports.buildRevokeLeafTx = buildRevokeLeafTx;
|
|
|
4257
4286
|
exports.buildSendTx = buildSendTx;
|
|
4258
4287
|
exports.buildSwapTx = buildSwapTx;
|
|
4259
4288
|
exports.cancelOpenJob = cancelOpenJob;
|
|
4289
|
+
exports.canonicalizeRecipientInput = canonicalizeRecipientInput;
|
|
4260
4290
|
exports.chatCompletion = chatCompletion;
|
|
4261
4291
|
exports.chatCompletionStream = chatCompletionStream;
|
|
4262
4292
|
exports.checkPositiveAmount = checkPositiveAmount;
|
|
@@ -4337,6 +4367,7 @@ exports.refineLendingLabel = refineLendingLabel;
|
|
|
4337
4367
|
exports.refundOpenJob = refundOpenJob;
|
|
4338
4368
|
exports.reportX402Activity = reportX402Activity;
|
|
4339
4369
|
exports.resolveAddressToSuinsViaRpc = resolveAddressToSuinsViaRpc;
|
|
4370
|
+
exports.resolveCreatedObjectId = resolveCreatedObjectId;
|
|
4340
4371
|
exports.resolveSuinsViaRpc = resolveSuinsViaRpc;
|
|
4341
4372
|
exports.resolveSymbol = resolveSymbol;
|
|
4342
4373
|
exports.resolveTokenType = resolveTokenType;
|