@t2000/sdk 10.25.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 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) or a SuiNS name ending in .sui (e.g. alex.sui).`
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.trim().toLowerCase());
1981
+ return SUINS_NAME_REGEX.test(canonicalizeRecipientInput(value).toLowerCase());
1973
1982
  }
1974
1983
  async function resolveSuinsViaRpc(rawName, ctx = {}) {
1975
- const name = rawName.trim().toLowerCase();
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.trim();
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.trim();
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 or a .sui name.`
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() {
@@ -4277,6 +4286,7 @@ exports.buildRevokeLeafTx = buildRevokeLeafTx;
4277
4286
  exports.buildSendTx = buildSendTx;
4278
4287
  exports.buildSwapTx = buildSwapTx;
4279
4288
  exports.cancelOpenJob = cancelOpenJob;
4289
+ exports.canonicalizeRecipientInput = canonicalizeRecipientInput;
4280
4290
  exports.chatCompletion = chatCompletion;
4281
4291
  exports.chatCompletionStream = chatCompletionStream;
4282
4292
  exports.checkPositiveAmount = checkPositiveAmount;