@t2000/sdk 5.6.1 → 5.7.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/index.cjs +30 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +33 -5
- package/dist/index.d.ts +33 -5
- package/dist/index.js +27 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2832,6 +2832,16 @@ init_cetus_swap();
|
|
|
2832
2832
|
init_token_registry();
|
|
2833
2833
|
var AUDRIC_PARENT_NAME = "audric.sui";
|
|
2834
2834
|
var AUDRIC_PARENT_NFT_ID = "0x070456e283ec988b6302bdd6cc5172bbdcb709998cf116586fb98d19b0870198";
|
|
2835
|
+
var AUDRIC_PARENT = {
|
|
2836
|
+
name: AUDRIC_PARENT_NAME,
|
|
2837
|
+
nftId: AUDRIC_PARENT_NFT_ID
|
|
2838
|
+
};
|
|
2839
|
+
var AGENT_ID_PARENT_NAME = "agent-id.sui";
|
|
2840
|
+
var AGENT_ID_PARENT_NFT_ID = process.env.AGENT_ID_PARENT_NFT_ID ?? "0xc8c13f5b5a6d4c47c04877014794f65e67e2745d3bfa089b736eb54b0ebd5d1f";
|
|
2841
|
+
var AGENT_ID_PARENT = {
|
|
2842
|
+
name: AGENT_ID_PARENT_NAME,
|
|
2843
|
+
nftId: AGENT_ID_PARENT_NFT_ID
|
|
2844
|
+
};
|
|
2835
2845
|
var LABEL_PATTERN = /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/;
|
|
2836
2846
|
function validateLabel(label) {
|
|
2837
2847
|
if (typeof label !== "string") {
|
|
@@ -2854,7 +2864,7 @@ function validateLabel(label) {
|
|
|
2854
2864
|
}
|
|
2855
2865
|
return { valid: true };
|
|
2856
2866
|
}
|
|
2857
|
-
function buildAddLeafTx(suinsClient, { label, targetAddress }) {
|
|
2867
|
+
function buildAddLeafTx(suinsClient, { label, targetAddress, parent = AUDRIC_PARENT }) {
|
|
2858
2868
|
const labelCheck = validateLabel(label);
|
|
2859
2869
|
if (!labelCheck.valid) {
|
|
2860
2870
|
throw new Error(`buildAddLeafTx: invalid label "${label}" \u2014 ${labelCheck.reason}`);
|
|
@@ -2862,39 +2872,49 @@ function buildAddLeafTx(suinsClient, { label, targetAddress }) {
|
|
|
2862
2872
|
if (typeof targetAddress !== "string" || !utils.isValidSuiAddress(utils.normalizeSuiAddress(targetAddress))) {
|
|
2863
2873
|
throw new Error(`buildAddLeafTx: invalid targetAddress "${targetAddress}"`);
|
|
2864
2874
|
}
|
|
2875
|
+
if (!parent.nftId) {
|
|
2876
|
+
throw new Error(`buildAddLeafTx: parent NFT id not configured for "${parent.name}"`);
|
|
2877
|
+
}
|
|
2865
2878
|
const tx = new transactions.Transaction();
|
|
2866
2879
|
const suinsTx = new suins.SuinsTransaction(suinsClient, tx);
|
|
2867
2880
|
suinsTx.createLeafSubName({
|
|
2868
|
-
parentNft:
|
|
2869
|
-
name: `${label}.${
|
|
2881
|
+
parentNft: parent.nftId,
|
|
2882
|
+
name: `${label}.${parent.name}`,
|
|
2870
2883
|
targetAddress: utils.normalizeSuiAddress(targetAddress)
|
|
2871
2884
|
});
|
|
2872
2885
|
return tx;
|
|
2873
2886
|
}
|
|
2874
|
-
function buildRevokeLeafTx(suinsClient, { label }) {
|
|
2887
|
+
function buildRevokeLeafTx(suinsClient, { label, parent = AUDRIC_PARENT }) {
|
|
2875
2888
|
const labelCheck = validateLabel(label);
|
|
2876
2889
|
if (!labelCheck.valid) {
|
|
2877
2890
|
throw new Error(`buildRevokeLeafTx: invalid label "${label}" \u2014 ${labelCheck.reason}`);
|
|
2878
2891
|
}
|
|
2892
|
+
if (!parent.nftId) {
|
|
2893
|
+
throw new Error(`buildRevokeLeafTx: parent NFT id not configured for "${parent.name}"`);
|
|
2894
|
+
}
|
|
2879
2895
|
const tx = new transactions.Transaction();
|
|
2880
2896
|
const suinsTx = new suins.SuinsTransaction(suinsClient, tx);
|
|
2881
2897
|
suinsTx.removeLeafSubName({
|
|
2882
|
-
parentNft:
|
|
2883
|
-
name: `${label}.${
|
|
2898
|
+
parentNft: parent.nftId,
|
|
2899
|
+
name: `${label}.${parent.name}`
|
|
2884
2900
|
});
|
|
2885
2901
|
return tx;
|
|
2886
2902
|
}
|
|
2887
|
-
function fullHandle(label) {
|
|
2888
|
-
return `${label}.${
|
|
2903
|
+
function fullHandle(label, parentName = AUDRIC_PARENT_NAME) {
|
|
2904
|
+
return `${label}.${parentName}`;
|
|
2889
2905
|
}
|
|
2890
|
-
function displayHandle(label) {
|
|
2891
|
-
const parentDisplay =
|
|
2906
|
+
function displayHandle(label, parentName = AUDRIC_PARENT_NAME) {
|
|
2907
|
+
const parentDisplay = parentName.replace(/\.sui$/, "");
|
|
2892
2908
|
return `${label}@${parentDisplay}`;
|
|
2893
2909
|
}
|
|
2894
2910
|
|
|
2895
2911
|
// src/index.ts
|
|
2896
2912
|
init_preflight();
|
|
2897
2913
|
|
|
2914
|
+
exports.AGENT_ID_PARENT = AGENT_ID_PARENT;
|
|
2915
|
+
exports.AGENT_ID_PARENT_NAME = AGENT_ID_PARENT_NAME;
|
|
2916
|
+
exports.AGENT_ID_PARENT_NFT_ID = AGENT_ID_PARENT_NFT_ID;
|
|
2917
|
+
exports.AUDRIC_PARENT = AUDRIC_PARENT;
|
|
2898
2918
|
exports.AUDRIC_PARENT_NAME = AUDRIC_PARENT_NAME;
|
|
2899
2919
|
exports.AUDRIC_PARENT_NFT_ID = AUDRIC_PARENT_NFT_ID;
|
|
2900
2920
|
exports.CETUS_USDC_SUI_POOL = CETUS_USDC_SUI_POOL;
|