@hashgraphonline/standards-sdk 0.1.141-canary.6 → 0.1.141-canary.7
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/es/standards-sdk.es101.js +1 -1
- package/dist/es/standards-sdk.es103.js +1 -1
- package/dist/es/standards-sdk.es109.js +1 -1
- package/dist/es/standards-sdk.es12.js +1 -1
- package/dist/es/standards-sdk.es124.js +1 -1
- package/dist/es/standards-sdk.es125.js +1 -1
- package/dist/es/standards-sdk.es127.js +1 -1
- package/dist/es/standards-sdk.es13.js +1 -1
- package/dist/es/standards-sdk.es135.js +17 -760
- package/dist/es/standards-sdk.es135.js.map +1 -1
- package/dist/es/standards-sdk.es136.js +105 -12241
- package/dist/es/standards-sdk.es136.js.map +1 -1
- package/dist/es/standards-sdk.es137.js +37 -133
- package/dist/es/standards-sdk.es137.js.map +1 -1
- package/dist/es/standards-sdk.es138.js +760 -42
- package/dist/es/standards-sdk.es138.js.map +1 -1
- package/dist/es/standards-sdk.es139.js +12269 -12
- package/dist/es/standards-sdk.es139.js.map +1 -1
- package/dist/es/standards-sdk.es17.js +1 -1
- package/dist/es/standards-sdk.es19.js +4 -4
- package/dist/es/standards-sdk.es20.js +2 -2
- package/dist/es/standards-sdk.es23.js +1 -1
- package/dist/es/standards-sdk.es28.js +3 -3
- package/dist/es/standards-sdk.es31.js +1 -1
- package/dist/es/standards-sdk.es32.js +1 -1
- package/dist/es/standards-sdk.es36.js +2 -2
- package/dist/es/standards-sdk.es37.js +3 -3
- package/dist/es/standards-sdk.es38.js +1 -1
- package/dist/es/standards-sdk.es5.js +1 -1
- package/dist/es/standards-sdk.es54.js +1 -1
- package/dist/es/standards-sdk.es61.js +2 -2
- package/dist/es/standards-sdk.es65.js +1 -1
- package/dist/es/standards-sdk.es66.js +2 -2
- package/dist/es/standards-sdk.es69.js +2 -2
- package/dist/es/standards-sdk.es70.js +1 -1
- package/dist/es/standards-sdk.es72.js +1 -1
- package/dist/es/standards-sdk.es77.js +1 -1
- package/dist/es/standards-sdk.es78.js +1 -1
- package/dist/es/standards-sdk.es79.js +1 -1
- package/dist/es/standards-sdk.es8.js +1 -1
- package/dist/es/standards-sdk.es82.js +1 -1
- package/dist/es/standards-sdk.es84.js +1 -1
- package/dist/es/standards-sdk.es87.js +1 -1
- package/dist/es/standards-sdk.es91.js +1 -1
- package/dist/es/standards-sdk.es92.js +1 -1
- package/dist/es/standards-sdk.es97.js +1 -1
- package/dist/es/standards-sdk.es99.js +1 -1
- package/package.json +1 -1
|
@@ -1,141 +1,45 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const pk = explicitType === "ed25519" ? PrivateKey.fromStringED25519(operatorKeyInput) : PrivateKey.fromStringECDSA(operatorKeyInput);
|
|
20
|
-
return { keyType: explicitType, privateKey: pk };
|
|
21
|
-
}
|
|
22
|
-
try {
|
|
23
|
-
const detected = detectKeyTypeFromString(operatorKeyInput);
|
|
24
|
-
return {
|
|
25
|
-
keyType: detected.detectedType,
|
|
26
|
-
privateKey: detected.privateKey
|
|
27
|
-
};
|
|
28
|
-
} catch {
|
|
29
|
-
return {
|
|
30
|
-
keyType: "ecdsa",
|
|
31
|
-
privateKey: PrivateKey.fromStringECDSA(operatorKeyInput)
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Resolve an operator key using Mirror Node for key type when possible.
|
|
37
|
-
* - If PrivateKey: return immediately.
|
|
38
|
-
* - If explicitType: parse directly.
|
|
39
|
-
* - Else: query Mirror Node; fallback to local detection.
|
|
40
|
-
*/
|
|
41
|
-
async resolveOperatorKey(operatorId, operatorKeyInput, explicitType) {
|
|
42
|
-
if (typeof operatorKeyInput !== "string") {
|
|
43
|
-
return { keyType: explicitType || "ecdsa", privateKey: operatorKeyInput };
|
|
44
|
-
}
|
|
45
|
-
if (explicitType) {
|
|
46
|
-
const pk = explicitType === "ed25519" ? PrivateKey.fromStringED25519(operatorKeyInput) : PrivateKey.fromStringECDSA(operatorKeyInput);
|
|
47
|
-
return { keyType: explicitType, privateKey: pk };
|
|
48
|
-
}
|
|
49
|
-
const account = typeof operatorId === "string" ? operatorId : operatorId.toString();
|
|
50
|
-
try {
|
|
51
|
-
const info = await this.mirror.requestAccount(account);
|
|
52
|
-
const t = info?.key?._type || "";
|
|
53
|
-
const keyType = t.includes("ED25519") ? "ed25519" : "ecdsa";
|
|
54
|
-
const privateKey = keyType === "ed25519" ? PrivateKey.fromStringED25519(operatorKeyInput) : PrivateKey.fromStringECDSA(operatorKeyInput);
|
|
55
|
-
return { keyType, privateKey };
|
|
56
|
-
} catch {
|
|
57
|
-
this.logger.warn(
|
|
58
|
-
"Mirror node key detection failed; using local detection or default ECDSA"
|
|
59
|
-
);
|
|
60
|
-
return this.bestGuessOperatorKey(operatorKeyInput);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Resolve a supply key for the given token using Mirror Node token supply_key._type when possible.
|
|
65
|
-
*/
|
|
66
|
-
async resolveSupplyKey(tokenId, keyInput, fallbackType, explicitType) {
|
|
67
|
-
try {
|
|
68
|
-
const info = await this.mirror.getTokenInfo(tokenId);
|
|
69
|
-
const t = info?.supply_key?._type || "";
|
|
70
|
-
if (typeof keyInput !== "string") {
|
|
71
|
-
return keyInput;
|
|
72
|
-
}
|
|
73
|
-
if (explicitType) {
|
|
74
|
-
return explicitType === "ed25519" ? PrivateKey.fromStringED25519(keyInput) : PrivateKey.fromStringECDSA(keyInput);
|
|
75
|
-
}
|
|
76
|
-
if (t.includes("ED25519")) {
|
|
77
|
-
return PrivateKey.fromStringED25519(keyInput);
|
|
78
|
-
}
|
|
79
|
-
if (t.includes("ECDSA")) {
|
|
80
|
-
return PrivateKey.fromStringECDSA(keyInput);
|
|
81
|
-
}
|
|
82
|
-
return fallbackType === "ed25519" ? PrivateKey.fromStringED25519(keyInput) : PrivateKey.fromStringECDSA(keyInput);
|
|
83
|
-
} catch {
|
|
84
|
-
if (typeof keyInput !== "string") {
|
|
85
|
-
return keyInput;
|
|
86
|
-
}
|
|
87
|
-
if (explicitType) {
|
|
88
|
-
return explicitType === "ed25519" ? PrivateKey.fromStringED25519(keyInput) : PrivateKey.fromStringECDSA(keyInput);
|
|
1
|
+
import { TopicMessageSubmitTransaction, TopicId, TopicCreateTransaction, PublicKey, KeyList } from "@hashgraph/sdk";
|
|
2
|
+
function encodeHcs2RegistryMemo(indexedFlag, ttl) {
|
|
3
|
+
return `hcs-2:${indexedFlag}:${ttl}`;
|
|
4
|
+
}
|
|
5
|
+
function buildTopicCreateTx(params) {
|
|
6
|
+
const { memo, adminKey, submitKey, operatorPublicKey } = params;
|
|
7
|
+
const tx = new TopicCreateTransaction().setTopicMemo(memo);
|
|
8
|
+
const coerceKey = (k) => {
|
|
9
|
+
if (!k) return void 0;
|
|
10
|
+
if (k instanceof PublicKey || k instanceof KeyList) return k;
|
|
11
|
+
if (typeof k === "boolean") {
|
|
12
|
+
return k ? operatorPublicKey : void 0;
|
|
13
|
+
}
|
|
14
|
+
if (typeof k === "string") {
|
|
15
|
+
try {
|
|
16
|
+
return PublicKey.fromString(k);
|
|
17
|
+
} catch {
|
|
18
|
+
return void 0;
|
|
89
19
|
}
|
|
90
|
-
return fallbackType === "ed25519" ? PrivateKey.fromStringED25519(keyInput) : PrivateKey.fromStringECDSA(keyInput);
|
|
91
20
|
}
|
|
21
|
+
return void 0;
|
|
22
|
+
};
|
|
23
|
+
const admin = coerceKey(adminKey);
|
|
24
|
+
if (admin) {
|
|
25
|
+
tx.setAdminKey(admin);
|
|
92
26
|
}
|
|
27
|
+
const submit = coerceKey(submitKey);
|
|
28
|
+
if (submit) {
|
|
29
|
+
tx.setSubmitKey(submit);
|
|
30
|
+
}
|
|
31
|
+
return tx;
|
|
93
32
|
}
|
|
94
|
-
function
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
});
|
|
101
|
-
let currentKeyType;
|
|
102
|
-
let currentPrivateKey;
|
|
103
|
-
const guess = resolver.bestGuessOperatorKey(
|
|
104
|
-
params.operatorKey,
|
|
105
|
-
params.keyType
|
|
106
|
-
);
|
|
107
|
-
currentKeyType = guess.keyType;
|
|
108
|
-
currentPrivateKey = guess.privateKey;
|
|
109
|
-
client.setOperator(operatorId.toString(), currentPrivateKey);
|
|
110
|
-
const initPromise = (async () => {
|
|
111
|
-
try {
|
|
112
|
-
const resolved = await resolver.resolveOperatorKey(
|
|
113
|
-
operatorId,
|
|
114
|
-
params.operatorKey,
|
|
115
|
-
params.keyType
|
|
116
|
-
);
|
|
117
|
-
currentKeyType = resolved.keyType;
|
|
118
|
-
currentPrivateKey = resolved.privateKey;
|
|
119
|
-
client.setOperator(operatorId.toString(), currentPrivateKey);
|
|
120
|
-
} catch {
|
|
121
|
-
}
|
|
122
|
-
})();
|
|
123
|
-
return {
|
|
124
|
-
client,
|
|
125
|
-
operatorId,
|
|
126
|
-
get operatorKey() {
|
|
127
|
-
return currentPrivateKey;
|
|
128
|
-
},
|
|
129
|
-
get keyType() {
|
|
130
|
-
return currentKeyType;
|
|
131
|
-
},
|
|
132
|
-
ensureInitialized: async () => {
|
|
133
|
-
await initPromise;
|
|
134
|
-
}
|
|
135
|
-
};
|
|
33
|
+
function buildMessageTx(params) {
|
|
34
|
+
const tx = new TopicMessageSubmitTransaction().setTopicId(TopicId.fromString(params.topicId)).setMessage(params.message);
|
|
35
|
+
if (params.transactionMemo) {
|
|
36
|
+
tx.setTransactionMemo(params.transactionMemo);
|
|
37
|
+
}
|
|
38
|
+
return tx;
|
|
136
39
|
}
|
|
137
40
|
export {
|
|
138
|
-
|
|
139
|
-
|
|
41
|
+
buildMessageTx,
|
|
42
|
+
buildTopicCreateTx,
|
|
43
|
+
encodeHcs2RegistryMemo
|
|
140
44
|
};
|
|
141
45
|
//# sourceMappingURL=standards-sdk.es137.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-sdk.es137.js","sources":["../../src/common/
|
|
1
|
+
{"version":3,"file":"standards-sdk.es137.js","sources":["../../src/common/tx/tx-utils.ts"],"sourcesContent":["import {\n TopicCreateTransaction,\n TopicMessageSubmitTransaction,\n PublicKey,\n KeyList,\n TopicId,\n} from '@hashgraph/sdk';\n\nexport type MaybeKey = boolean | string | PublicKey | KeyList | undefined;\n\nexport function encodeHcs2RegistryMemo(\n indexedFlag: 0 | 1,\n ttl: number,\n): string {\n return `hcs-2:${indexedFlag}:${ttl}`;\n}\n\nexport function buildTopicCreateTx(params: {\n memo: string;\n adminKey?: MaybeKey;\n submitKey?: MaybeKey;\n operatorPublicKey?: PublicKey;\n}): TopicCreateTransaction {\n const { memo, adminKey, submitKey, operatorPublicKey } = params;\n const tx = new TopicCreateTransaction().setTopicMemo(memo);\n\n const coerceKey = (k?: MaybeKey): PublicKey | KeyList | undefined => {\n if (!k) return undefined;\n if (k instanceof PublicKey || k instanceof KeyList) return k;\n if (typeof k === 'boolean') {\n return k ? operatorPublicKey : undefined;\n }\n if (typeof k === 'string') {\n try {\n return PublicKey.fromString(k);\n } catch {\n return undefined;\n }\n }\n return undefined;\n };\n\n const admin = coerceKey(adminKey);\n if (admin) {\n tx.setAdminKey(admin);\n }\n\n const submit = coerceKey(submitKey);\n if (submit) {\n tx.setSubmitKey(submit);\n }\n\n return tx;\n}\n\nexport function buildMessageTx(params: {\n topicId: string;\n message: string | Uint8Array;\n transactionMemo?: string;\n}): TopicMessageSubmitTransaction {\n const tx = new TopicMessageSubmitTransaction()\n .setTopicId(TopicId.fromString(params.topicId))\n .setMessage(params.message);\n if (params.transactionMemo) {\n tx.setTransactionMemo(params.transactionMemo);\n }\n return tx;\n}\n"],"names":[],"mappings":";AAUO,SAAS,uBACd,aACA,KACQ;AACR,SAAO,SAAS,WAAW,IAAI,GAAG;AACpC;AAEO,SAAS,mBAAmB,QAKR;AACzB,QAAM,EAAE,MAAM,UAAU,WAAW,sBAAsB;AACzD,QAAM,KAAK,IAAI,yBAAyB,aAAa,IAAI;AAEzD,QAAM,YAAY,CAAC,MAAkD;AACnE,QAAI,CAAC,EAAG,QAAO;AACf,QAAI,aAAa,aAAa,aAAa,QAAS,QAAO;AAC3D,QAAI,OAAO,MAAM,WAAW;AAC1B,aAAO,IAAI,oBAAoB;AAAA,IACjC;AACA,QAAI,OAAO,MAAM,UAAU;AACzB,UAAI;AACF,eAAO,UAAU,WAAW,CAAC;AAAA,MAC/B,QAAQ;AACN,eAAO;AAAA,MACT;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAEA,QAAM,QAAQ,UAAU,QAAQ;AAChC,MAAI,OAAO;AACT,OAAG,YAAY,KAAK;AAAA,EACtB;AAEA,QAAM,SAAS,UAAU,SAAS;AAClC,MAAI,QAAQ;AACV,OAAG,aAAa,MAAM;AAAA,EACxB;AAEA,SAAO;AACT;AAEO,SAAS,eAAe,QAIG;AAChC,QAAM,KAAK,IAAI,gCACZ,WAAW,QAAQ,WAAW,OAAO,OAAO,CAAC,EAC7C,WAAW,OAAO,OAAO;AAC5B,MAAI,OAAO,iBAAiB;AAC1B,OAAG,mBAAmB,OAAO,eAAe;AAAA,EAC9C;AACA,SAAO;AACT;"}
|