@hashgraphonline/standards-sdk 0.1.143-feat-solana-register.canary.8527a8c.77 → 0.1.143-feat-solana-register.canary.1c6f446.78
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/cjs/services/registry-broker/client/feedback.d.ts +1 -8
- package/dist/cjs/services/registry-broker/client/feedback.d.ts.map +1 -1
- package/dist/cjs/services/registry-broker/client.d.ts +0 -1
- package/dist/cjs/services/registry-broker/client.d.ts.map +1 -1
- package/dist/cjs/standards-sdk.cjs +1 -1
- package/dist/cjs/standards-sdk.cjs.map +1 -1
- package/dist/es/services/registry-broker/client/feedback.d.ts +1 -8
- package/dist/es/services/registry-broker/client/feedback.d.ts.map +1 -1
- package/dist/es/services/registry-broker/client.d.ts +0 -1
- package/dist/es/services/registry-broker/client.d.ts.map +1 -1
- package/dist/es/standards-sdk.es.js +8 -10
- package/dist/es/standards-sdk.es.js.map +1 -1
- package/dist/es/standards-sdk.es100.js +1 -1
- package/dist/es/standards-sdk.es102.js +1 -1
- package/dist/es/standards-sdk.es104.js +1 -1
- package/dist/es/standards-sdk.es110.js +2 -2
- package/dist/es/standards-sdk.es111.js +5 -5
- package/dist/es/standards-sdk.es12.js +1 -1
- package/dist/es/standards-sdk.es121.js +1 -1
- package/dist/es/standards-sdk.es122.js +1 -1
- package/dist/es/standards-sdk.es123.js +5 -5
- package/dist/es/standards-sdk.es125.js +1 -1
- package/dist/es/standards-sdk.es126.js +1 -1
- package/dist/es/standards-sdk.es128.js +3 -3
- package/dist/es/standards-sdk.es129.js +4 -4
- package/dist/es/standards-sdk.es13.js +1 -1
- package/dist/es/standards-sdk.es130.js +3 -3
- package/dist/es/standards-sdk.es131.js +4 -4
- package/dist/es/standards-sdk.es132.js +4 -4
- package/dist/es/standards-sdk.es133.js +4 -4
- package/dist/es/standards-sdk.es134.js +2 -2
- package/dist/es/standards-sdk.es135.js +4 -4
- package/dist/es/standards-sdk.es136.js +464 -8
- package/dist/es/standards-sdk.es136.js.map +1 -1
- package/dist/es/standards-sdk.es137.js +14 -461
- package/dist/es/standards-sdk.es137.js.map +1 -1
- package/dist/es/standards-sdk.es138.js +79 -15
- package/dist/es/standards-sdk.es138.js.map +1 -1
- package/dist/es/standards-sdk.es139.js +77 -71
- package/dist/es/standards-sdk.es139.js.map +1 -1
- package/dist/es/standards-sdk.es140.js +152 -80
- package/dist/es/standards-sdk.es140.js.map +1 -1
- package/dist/es/standards-sdk.es141.js +7 -159
- package/dist/es/standards-sdk.es141.js.map +1 -1
- package/dist/es/standards-sdk.es142.js +86 -7
- package/dist/es/standards-sdk.es142.js.map +1 -1
- package/dist/es/standards-sdk.es143.js +43 -64
- package/dist/es/standards-sdk.es143.js.map +1 -1
- package/dist/es/standards-sdk.es144.js +30 -65
- package/dist/es/standards-sdk.es144.js.map +1 -1
- package/dist/es/standards-sdk.es145.js +34 -30
- package/dist/es/standards-sdk.es145.js.map +1 -1
- package/dist/es/standards-sdk.es146.js +28 -34
- package/dist/es/standards-sdk.es146.js.map +1 -1
- package/dist/es/standards-sdk.es147.js +138 -28
- package/dist/es/standards-sdk.es147.js.map +1 -1
- package/dist/es/standards-sdk.es148.js +37 -133
- package/dist/es/standards-sdk.es148.js.map +1 -1
- package/dist/es/standards-sdk.es149.js +958 -42
- package/dist/es/standards-sdk.es149.js.map +1 -1
- package/dist/es/standards-sdk.es150.js +12269 -938
- package/dist/es/standards-sdk.es150.js.map +1 -1
- package/dist/es/standards-sdk.es151.js +12 -12284
- package/dist/es/standards-sdk.es151.js.map +1 -1
- package/dist/es/standards-sdk.es152.js +167 -51
- package/dist/es/standards-sdk.es152.js.map +1 -1
- package/dist/es/standards-sdk.es153.js +309 -69
- package/dist/es/standards-sdk.es153.js.map +1 -1
- package/dist/es/standards-sdk.es154.js +294 -120
- package/dist/es/standards-sdk.es154.js.map +1 -1
- package/dist/es/standards-sdk.es155.js +322 -191
- package/dist/es/standards-sdk.es155.js.map +1 -1
- package/dist/es/standards-sdk.es156.js +279 -294
- package/dist/es/standards-sdk.es156.js.map +1 -1
- package/dist/es/standards-sdk.es157.js +63 -440
- package/dist/es/standards-sdk.es157.js.map +1 -1
- package/dist/es/standards-sdk.es158.js +55 -330
- package/dist/es/standards-sdk.es158.js.map +1 -1
- package/dist/es/standards-sdk.es159.js +66 -60
- package/dist/es/standards-sdk.es159.js.map +1 -1
- package/dist/es/standards-sdk.es160.js +236 -14
- package/dist/es/standards-sdk.es160.js.map +1 -1
- package/dist/es/standards-sdk.es161.js +223 -218
- package/dist/es/standards-sdk.es161.js.map +1 -1
- package/dist/es/standards-sdk.es17.js +2 -2
- package/dist/es/standards-sdk.es19.js +5 -5
- package/dist/es/standards-sdk.es20.js +3 -3
- package/dist/es/standards-sdk.es23.js +1 -1
- package/dist/es/standards-sdk.es28.js +5 -5
- 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.es57.js +1 -1
- package/dist/es/standards-sdk.es59.js +1 -1
- package/dist/es/standards-sdk.es60.js +1 -1
- package/dist/es/standards-sdk.es61.js +3 -3
- package/dist/es/standards-sdk.es63.js +1 -1
- 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 +2 -2
- 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.es88.js +3 -3
- package/dist/es/standards-sdk.es92.js +2 -2
- package/dist/es/standards-sdk.es92.js.map +1 -1
- package/dist/es/standards-sdk.es93.js +1 -1
- package/dist/es/standards-sdk.es98.js +1 -1
- package/package.json +1 -1
- package/dist/es/standards-sdk.es162.js +0 -247
- package/dist/es/standards-sdk.es162.js.map +0 -1
|
@@ -12,9 +12,9 @@ import "buffer";
|
|
|
12
12
|
import "crypto";
|
|
13
13
|
import "@noble/curves/secp256k1.js";
|
|
14
14
|
import "zod";
|
|
15
|
+
import "./standards-sdk.es149.js";
|
|
16
|
+
import "./standards-sdk.es139.js";
|
|
15
17
|
import "./standards-sdk.es150.js";
|
|
16
|
-
import "./standards-sdk.es140.js";
|
|
17
|
-
import "./standards-sdk.es151.js";
|
|
18
18
|
import "@hashgraph/proto";
|
|
19
19
|
import "@hashgraph/sdk";
|
|
20
20
|
import "ethers";
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { Client } from "@hashgraph/sdk";
|
|
2
2
|
import { HCS12BaseClient } from "./standards-sdk.es36.js";
|
|
3
|
-
import { createNodeOperatorContext } from "./standards-sdk.
|
|
3
|
+
import { createNodeOperatorContext } from "./standards-sdk.es147.js";
|
|
4
4
|
import { RegistryType } from "./standards-sdk.es30.js";
|
|
5
5
|
import { inscribe } from "./standards-sdk.es125.js";
|
|
6
|
-
import { InscriptionSDK } from "./standards-sdk.
|
|
6
|
+
import { InscriptionSDK } from "./standards-sdk.es150.js";
|
|
7
7
|
import { ActionRegistry } from "./standards-sdk.es32.js";
|
|
8
8
|
import { BlockLoader } from "./standards-sdk.es33.js";
|
|
9
9
|
import { AssemblyRegistry } from "./standards-sdk.es34.js";
|
|
10
10
|
import { HashLinksRegistry } from "./standards-sdk.es35.js";
|
|
11
11
|
import * as mime from "mime-types";
|
|
12
|
-
import { buildTopicCreateTx, buildMessageTx } from "./standards-sdk.
|
|
12
|
+
import { buildTopicCreateTx, buildMessageTx } from "./standards-sdk.es148.js";
|
|
13
13
|
class HCS12Client extends HCS12BaseClient {
|
|
14
14
|
constructor(config) {
|
|
15
15
|
super(config);
|
|
@@ -2,7 +2,7 @@ import { TopicCreateTransaction, TransactionId, AccountId, PublicKey, KeyList, T
|
|
|
2
2
|
import { HCS12BaseClient } from "./standards-sdk.es36.js";
|
|
3
3
|
import { RegistryType } from "./standards-sdk.es30.js";
|
|
4
4
|
import { inscribeWithSigner } from "./standards-sdk.es125.js";
|
|
5
|
-
import { InscriptionSDK } from "./standards-sdk.
|
|
5
|
+
import { InscriptionSDK } from "./standards-sdk.es150.js";
|
|
6
6
|
import { ActionRegistry } from "./standards-sdk.es32.js";
|
|
7
7
|
import { BlockLoader } from "./standards-sdk.es33.js";
|
|
8
8
|
import { AssemblyRegistry } from "./standards-sdk.es34.js";
|
|
@@ -2,7 +2,7 @@ import { HCS6BaseClient } from "./standards-sdk.es7.js";
|
|
|
2
2
|
import { buildHcs6Hrl } from "./standards-sdk.es4.js";
|
|
3
3
|
import { AccountId, Client, TopicMessageSubmitTransaction, TopicId, PrivateKey, PublicKey, TokenMintTransaction, TokenId } from "@hashgraph/sdk";
|
|
4
4
|
import { buildHcs6CreateRegistryTx } from "./standards-sdk.es8.js";
|
|
5
|
-
import { createNodeOperatorContext, NodeOperatorResolver } from "./standards-sdk.
|
|
5
|
+
import { createNodeOperatorContext, NodeOperatorResolver } from "./standards-sdk.es147.js";
|
|
6
6
|
import { inscribe } from "./standards-sdk.es125.js";
|
|
7
7
|
class HCS6Client extends HCS6BaseClient {
|
|
8
8
|
constructor(config) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getCryptoAdapter } from "./standards-sdk.es120.js";
|
|
2
|
-
import { base58Encode } from "./standards-sdk.
|
|
2
|
+
import { base58Encode } from "./standards-sdk.es158.js";
|
|
3
3
|
import { canonicalizeAgentData } from "./standards-sdk.es56.js";
|
|
4
4
|
function encodeMultibaseB58btc(input) {
|
|
5
5
|
const bytes = Buffer.from(input, "utf8");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HieroDidResolver } from "./standards-sdk.es60.js";
|
|
2
2
|
import { parseHcs14Did } from "./standards-sdk.es57.js";
|
|
3
|
-
import { multibaseB58btcDecode } from "./standards-sdk.
|
|
3
|
+
import { multibaseB58btcDecode } from "./standards-sdk.es158.js";
|
|
4
4
|
class ResolverRegistry {
|
|
5
5
|
constructor() {
|
|
6
6
|
this.resolvers = [];
|
|
@@ -22,13 +22,13 @@ import "buffer";
|
|
|
22
22
|
import "crypto";
|
|
23
23
|
import "@noble/curves/secp256k1.js";
|
|
24
24
|
import "zod";
|
|
25
|
-
import "./standards-sdk.
|
|
26
|
-
import "./standards-sdk.
|
|
25
|
+
import "./standards-sdk.es149.js";
|
|
26
|
+
import "./standards-sdk.es139.js";
|
|
27
27
|
import "@hashgraph/proto";
|
|
28
28
|
import "ethers";
|
|
29
29
|
import "./standards-sdk.es123.js";
|
|
30
30
|
import "./standards-sdk.es114.js";
|
|
31
|
-
import { createNodeOperatorContext } from "./standards-sdk.
|
|
31
|
+
import { createNodeOperatorContext } from "./standards-sdk.es147.js";
|
|
32
32
|
import { HCS10Client } from "./standards-sdk.es19.js";
|
|
33
33
|
class HCS14Client {
|
|
34
34
|
constructor(options) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HCS5BaseClient } from "./standards-sdk.
|
|
1
|
+
import { HCS5BaseClient } from "./standards-sdk.es151.js";
|
|
2
2
|
import { buildHcs1Hrl } from "./standards-sdk.es64.js";
|
|
3
3
|
import { PrivateKey } from "@hashgraph/sdk";
|
|
4
4
|
import { inscribeWithSigner } from "./standards-sdk.es125.js";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { HCS5BaseClient } from "./standards-sdk.
|
|
1
|
+
import { HCS5BaseClient } from "./standards-sdk.es151.js";
|
|
2
2
|
import { buildHcs1Hrl } from "./standards-sdk.es64.js";
|
|
3
3
|
import { AccountId } from "@hashgraph/sdk";
|
|
4
4
|
import { inscribe } from "./standards-sdk.es125.js";
|
|
5
5
|
import { buildHcs5MintTx } from "./standards-sdk.es67.js";
|
|
6
|
-
import { createNodeOperatorContext, NodeOperatorResolver } from "./standards-sdk.
|
|
6
|
+
import { createNodeOperatorContext, NodeOperatorResolver } from "./standards-sdk.es147.js";
|
|
7
7
|
class HCS5Client extends HCS5BaseClient {
|
|
8
8
|
constructor(config) {
|
|
9
9
|
super(config);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AccountId, Client, PublicKey } from "@hashgraph/sdk";
|
|
2
2
|
import { HCS2BaseClient } from "./standards-sdk.es71.js";
|
|
3
3
|
import { HCS2Operation, HCS2RegistryType } from "./standards-sdk.es68.js";
|
|
4
|
-
import { createNodeOperatorContext } from "./standards-sdk.
|
|
5
|
-
import { buildMessageTx } from "./standards-sdk.
|
|
4
|
+
import { createNodeOperatorContext } from "./standards-sdk.es147.js";
|
|
5
|
+
import { buildMessageTx } from "./standards-sdk.es148.js";
|
|
6
6
|
import { buildHcs2CreateRegistryTx } from "./standards-sdk.es72.js";
|
|
7
7
|
const _HCS2Client = class _HCS2Client extends HCS2BaseClient {
|
|
8
8
|
/**
|
|
@@ -3,7 +3,7 @@ import { HCS2BaseClient } from "./standards-sdk.es71.js";
|
|
|
3
3
|
import { HCS2RegistryType, HCS2Operation } from "./standards-sdk.es68.js";
|
|
4
4
|
import { isBrowser } from "./standards-sdk.es119.js";
|
|
5
5
|
import { KeyTypeDetector } from "./standards-sdk.es114.js";
|
|
6
|
-
import { buildMessageTx } from "./standards-sdk.
|
|
6
|
+
import { buildMessageTx } from "./standards-sdk.es148.js";
|
|
7
7
|
class BrowserHCS2Client extends HCS2BaseClient {
|
|
8
8
|
/**
|
|
9
9
|
* Create a new browser HCS-2 client
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { buildTopicCreateTx, buildMessageTx, encodeHcs2RegistryMemo } from "./standards-sdk.
|
|
1
|
+
import { buildTopicCreateTx, buildMessageTx, encodeHcs2RegistryMemo } from "./standards-sdk.es148.js";
|
|
2
2
|
import { HCS2Operation } from "./standards-sdk.es68.js";
|
|
3
3
|
function buildHcs2CreateRegistryTx(params) {
|
|
4
4
|
const memo = params.memoOverride ?? encodeHcs2RegistryMemo(params.registryType, params.ttl);
|
|
@@ -2,7 +2,7 @@ import { AccountId, Client, Status, TopicCreateTransaction } from "@hashgraph/sd
|
|
|
2
2
|
import { HCS20BaseClient } from "./standards-sdk.es75.js";
|
|
3
3
|
import { PointsDeploymentError, PointsValidationError, PointsTransferError, PointsBurnError } from "./standards-sdk.es74.js";
|
|
4
4
|
import { sleep } from "./standards-sdk.es116.js";
|
|
5
|
-
import { createNodeOperatorContext } from "./standards-sdk.
|
|
5
|
+
import { createNodeOperatorContext } from "./standards-sdk.es147.js";
|
|
6
6
|
import { HCS2Client } from "./standards-sdk.es69.js";
|
|
7
7
|
import { buildHcs20DeployTx, buildHcs20MintTx, buildHcs20TransferTx, buildHcs20BurnTx, buildHcs20RegisterTx } from "./standards-sdk.es79.js";
|
|
8
8
|
class HCS20Client extends HCS20BaseClient {
|
|
@@ -12,8 +12,8 @@ import "buffer";
|
|
|
12
12
|
import "crypto";
|
|
13
13
|
import "@noble/curves/secp256k1.js";
|
|
14
14
|
import "zod";
|
|
15
|
-
import "./standards-sdk.
|
|
16
|
-
import "./standards-sdk.
|
|
15
|
+
import "./standards-sdk.es149.js";
|
|
16
|
+
import "./standards-sdk.es139.js";
|
|
17
17
|
import { HCS20_CONSTANTS, HCS20MessageSchema } from "./standards-sdk.es73.js";
|
|
18
18
|
class HCS20PointsIndexer {
|
|
19
19
|
constructor(network, logger, mirrorNodeUrl) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { buildMessageTx } from "./standards-sdk.
|
|
1
|
+
import { buildMessageTx } from "./standards-sdk.es148.js";
|
|
2
2
|
function buildHcs20SubmitMessageTx(params) {
|
|
3
3
|
const msg = typeof params.payload === "string" ? params.payload : JSON.stringify(params.payload);
|
|
4
4
|
return buildMessageTx({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { buildTopicCreateTx, buildMessageTx } from "./standards-sdk.
|
|
1
|
+
import { buildTopicCreateTx, buildMessageTx } from "./standards-sdk.es148.js";
|
|
2
2
|
import { HCS6Operation } from "./standards-sdk.es4.js";
|
|
3
3
|
function encodeHcs6NonIndexedMemo(ttl) {
|
|
4
4
|
return `hcs-6:1:${ttl}`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { buildTopicCreateTx, buildMessageTx } from "./standards-sdk.
|
|
1
|
+
import { buildTopicCreateTx, buildMessageTx } from "./standards-sdk.es148.js";
|
|
2
2
|
import { HCS21TopicType, HCS21MetadataPointerPattern, HCS21_SAFE_MESSAGE_BYTES, HCS21_MAX_MESSAGE_BYTES } from "./standards-sdk.es80.js";
|
|
3
3
|
import { HCS21ValidationError } from "./standards-sdk.es81.js";
|
|
4
4
|
function buildHcs21RegistryMemo(params) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Client, Status } from "@hashgraph/sdk";
|
|
2
|
-
import { createNodeOperatorContext } from "./standards-sdk.
|
|
2
|
+
import { createNodeOperatorContext } from "./standards-sdk.es147.js";
|
|
3
3
|
import { Logger } from "./standards-sdk.es106.js";
|
|
4
4
|
import { HCS21BaseClient } from "./standards-sdk.es83.js";
|
|
5
5
|
import { metadataDocumentSchema, HCS21TopicType, HCS21ManifestPointerPattern } from "./standards-sdk.es80.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AccountId, Client, PrivateKey, Hbar } from "@hashgraph/sdk";
|
|
2
|
-
import { createNodeOperatorContext } from "./standards-sdk.
|
|
2
|
+
import { createNodeOperatorContext } from "./standards-sdk.es147.js";
|
|
3
3
|
import { buildHcs15BaseAccountCreateTx, buildHcs15PetalAccountCreateTx } from "./standards-sdk.es87.js";
|
|
4
4
|
import { HCS15BaseClient } from "./standards-sdk.es90.js";
|
|
5
5
|
class HCS15Client extends HCS15BaseClient {
|
|
@@ -92,8 +92,8 @@ class HCS15Client extends HCS15BaseClient {
|
|
|
92
92
|
return { accountId, receipt, profile };
|
|
93
93
|
}
|
|
94
94
|
async createPetalProfile(params) {
|
|
95
|
-
const { HCS10Client } = await import("./standards-sdk.
|
|
96
|
-
const { PersonBuilder } = await import("./standards-sdk.
|
|
95
|
+
const { HCS10Client } = await import("./standards-sdk.es144.js");
|
|
96
|
+
const { PersonBuilder } = await import("./standards-sdk.es145.js");
|
|
97
97
|
const hcs10 = new HCS10Client({
|
|
98
98
|
network: this.network,
|
|
99
99
|
operatorId: params.accountId,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AccountId, TopicCreateTransaction, CustomFixedFee, TokenId, AccountCreateTransaction, Hbar, AccountUpdateTransaction, ScheduleCreateTransaction, TopicUpdateTransaction } from "@hashgraph/sdk";
|
|
2
|
-
import { buildTopicCreateTx, buildMessageTx } from "./standards-sdk.
|
|
2
|
+
import { buildTopicCreateTx, buildMessageTx } from "./standards-sdk.es148.js";
|
|
3
3
|
import { FloraOperation, FloraTopicType } from "./standards-sdk.es91.js";
|
|
4
4
|
const HCS16_FLORA_ACCOUNT_CREATE_TRANSACTION_MEMO = "hcs-16:op:0:0";
|
|
5
5
|
const HCS17_STATE_HASH_TRANSACTION_MEMO = "hcs-17:op:6:2";
|
|
@@ -15,7 +15,7 @@ function encodeHcs16FloraMemo(params) {
|
|
|
15
15
|
return `hcs-16:${params.floraAccountId}:${params.topicType}`;
|
|
16
16
|
}
|
|
17
17
|
function encodeHcs16TopicCreateTransactionMemo(topicType) {
|
|
18
|
-
return `hcs-16:op
|
|
18
|
+
return `hcs-16:op:${HCS16_OPERATION_ENUM_BY_OP[FloraOperation.FLORA_CREATED]}:${topicType}`;
|
|
19
19
|
}
|
|
20
20
|
const HCS16_OPERATION_ENUM_BY_OP = {
|
|
21
21
|
[FloraOperation.FLORA_CREATED]: 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-sdk.es92.js","sources":["../../src/hcs-16/tx.ts"],"sourcesContent":["import {\n TopicCreateTransaction,\n TopicMessageSubmitTransaction,\n TopicUpdateTransaction,\n AccountCreateTransaction,\n AccountUpdateTransaction,\n ScheduleCreateTransaction,\n Hbar,\n PublicKey,\n KeyList,\n AccountId,\n CustomFixedFee,\n TokenId,\n} from '@hashgraph/sdk';\nimport {\n buildTopicCreateTx,\n buildMessageTx,\n type MaybeKey,\n} from '../common/tx/tx-utils';\nimport { FloraOperation, FloraTopicType, type FloraMessage } from './types';\n\nexport const HCS16_FLORA_ACCOUNT_CREATE_TRANSACTION_MEMO = 'hcs-16:op:0:0';\nexport const HCS17_STATE_HASH_TRANSACTION_MEMO = 'hcs-17:op:6:2';\nexport const HCS16_ACCOUNT_KEY_UPDATE_TRANSACTION_MEMO = 'hcs-16:op:1:1';\nexport const HCS16_TOPIC_KEY_UPDATE_TRANSACTION_MEMO = 'hcs-16:op:1:1';\n\nfunction normalizeTransactionMemo(\n value: string | undefined,\n fallback: string,\n): string {\n if (typeof value !== 'string') return fallback;\n const trimmed = value.trim();\n if (!trimmed) return fallback;\n return trimmed;\n}\n\nfunction encodeHcs16FloraMemo(params: {\n floraAccountId: string;\n topicType: FloraTopicType;\n}): string {\n return `hcs-16:${params.floraAccountId}:${params.topicType}`;\n}\n\nfunction encodeHcs16TopicCreateTransactionMemo(\n topicType: FloraTopicType,\n): string {\n return `hcs-16:op:topic_create:${topicType}`;\n}\n\nconst HCS16_OPERATION_ENUM_BY_OP: Record<FloraOperation, number> = {\n [FloraOperation.FLORA_CREATED]: 0,\n [FloraOperation.TRANSACTION]: 1,\n [FloraOperation.STATE_UPDATE]: 2,\n [FloraOperation.FLORA_JOIN_REQUEST]: 3,\n [FloraOperation.FLORA_JOIN_VOTE]: 4,\n [FloraOperation.FLORA_JOIN_ACCEPTED]: 5,\n};\n\nconst HCS16_TOPIC_TYPE_BY_OP: Record<FloraOperation, FloraTopicType> = {\n [FloraOperation.FLORA_CREATED]: FloraTopicType.COMMUNICATION,\n [FloraOperation.TRANSACTION]: FloraTopicType.TRANSACTION,\n [FloraOperation.STATE_UPDATE]: FloraTopicType.STATE,\n [FloraOperation.FLORA_JOIN_REQUEST]: FloraTopicType.COMMUNICATION,\n [FloraOperation.FLORA_JOIN_VOTE]: FloraTopicType.COMMUNICATION,\n [FloraOperation.FLORA_JOIN_ACCEPTED]: FloraTopicType.STATE,\n};\n\nfunction encodeHcs16MessageSubmitTransactionMemo(op: FloraOperation): string {\n return `hcs-16:op:${HCS16_OPERATION_ENUM_BY_OP[op]}:${HCS16_TOPIC_TYPE_BY_OP[op]}`;\n}\n\n/**\n * Build a TopicCreateTransaction for HCS‑16 Flora topics (communication/transaction/state).\n */\nexport function buildHcs16CreateFloraTopicTx(params: {\n floraAccountId: string;\n topicType: FloraTopicType;\n adminKey?: MaybeKey;\n submitKey?: MaybeKey;\n operatorPublicKey?: PublicKey;\n autoRenewAccountId?: string;\n transactionMemo?: string;\n}): TopicCreateTransaction {\n const memo = encodeHcs16FloraMemo({\n floraAccountId: params.floraAccountId,\n topicType: params.topicType,\n });\n const tx = buildTopicCreateTx({\n memo,\n adminKey: params.adminKey,\n submitKey: params.submitKey,\n operatorPublicKey: params.operatorPublicKey,\n });\n tx.setTransactionMemo(\n normalizeTransactionMemo(\n params.transactionMemo,\n encodeHcs16TopicCreateTransactionMemo(params.topicType),\n ),\n );\n if (params.autoRenewAccountId) {\n tx.setAutoRenewAccountId(AccountId.fromString(params.autoRenewAccountId));\n }\n return tx;\n}\n\n/**\n * Build a TopicCreateTransaction for a generic HCS‑16 transaction topic with HIP‑991 fees.\n */\nexport function buildHcs16CreateTransactionTopicTx(params: {\n memo: string;\n adminKey?: KeyList | PublicKey;\n submitKey?: KeyList | PublicKey;\n feeScheduleKey?: KeyList | PublicKey;\n customFees?: Array<{\n amount: number;\n feeCollectorAccountId: string;\n denominatingTokenId?: string;\n }>;\n feeExemptKeys?: PublicKey[];\n}): TopicCreateTransaction {\n const tx = new TopicCreateTransaction().setTopicMemo(params.memo);\n if (params.adminKey) {\n tx.setAdminKey(params.adminKey);\n }\n if (params.submitKey) {\n tx.setSubmitKey(params.submitKey);\n }\n if (params.feeScheduleKey) {\n tx.setFeeScheduleKey(params.feeScheduleKey);\n }\n if (params.customFees && params.customFees.length > 0) {\n const fees = params.customFees.map(fee => {\n const cf = new CustomFixedFee()\n .setAmount(fee.amount)\n .setFeeCollectorAccountId(\n AccountId.fromString(fee.feeCollectorAccountId),\n );\n if (fee.denominatingTokenId) {\n cf.setDenominatingTokenId(TokenId.fromString(fee.denominatingTokenId));\n }\n return cf;\n });\n tx.setCustomFees(fees);\n }\n if (params.feeExemptKeys && params.feeExemptKeys.length > 0) {\n throw new Error('feeExemptKeys not supported by installed @hashgraph/sdk');\n }\n return tx;\n}\n\n/**\n * Build an AccountCreateTransaction for a Flora account given a KeyList and optional params.\n */\nexport function buildHcs16CreateAccountTx(params: {\n keyList: KeyList;\n initialBalanceHbar?: number;\n maxAutomaticTokenAssociations?: number;\n transactionMemo?: string;\n}): AccountCreateTransaction {\n const tx = new AccountCreateTransaction().setKey(params.keyList);\n const initial =\n typeof params.initialBalanceHbar === 'number'\n ? params.initialBalanceHbar\n : 1;\n tx.setInitialBalance(new Hbar(initial));\n const maxAssoc =\n typeof params.maxAutomaticTokenAssociations === 'number'\n ? params.maxAutomaticTokenAssociations\n : -1;\n tx.setMaxAutomaticTokenAssociations(maxAssoc);\n tx.setTransactionMemo(\n normalizeTransactionMemo(\n params.transactionMemo,\n HCS16_FLORA_ACCOUNT_CREATE_TRANSACTION_MEMO,\n ),\n );\n return tx;\n}\n\n/**\n * Build a ScheduleCreateTransaction that wraps an AccountUpdateTransaction to rotate the Flora account KeyList.\n * Members will sign this scheduled transaction until threshold is reached and it executes.\n */\nexport function buildHcs16ScheduleAccountKeyUpdateTx(params: {\n floraAccountId: string;\n newKeyList: KeyList;\n memo?: string;\n transactionMemo?: string;\n}): ScheduleCreateTransaction {\n const inner = new AccountUpdateTransaction()\n .setAccountId(AccountId.fromString(params.floraAccountId))\n .setKey(params.newKeyList);\n inner.setTransactionMemo(\n normalizeTransactionMemo(\n params.transactionMemo ?? params.memo,\n HCS16_ACCOUNT_KEY_UPDATE_TRANSACTION_MEMO,\n ),\n );\n return new ScheduleCreateTransaction().setScheduledTransaction(inner);\n}\n\n/**\n * Build a ScheduleCreateTransaction that wraps a TopicUpdateTransaction to rotate topic admin/submit keys.\n * Repeat for CTopic, TTopic, and STopic as needed for membership changes.\n */\nexport function buildHcs16ScheduleTopicKeyUpdateTx(params: {\n topicId: string;\n adminKey?: KeyList | PublicKey;\n submitKey?: KeyList | PublicKey;\n memo?: string;\n transactionMemo?: string;\n}): ScheduleCreateTransaction {\n const inner = new TopicUpdateTransaction().setTopicId(params.topicId);\n if (params.adminKey) {\n inner.setAdminKey(params.adminKey);\n }\n if (params.submitKey) {\n inner.setSubmitKey(params.submitKey);\n }\n inner.setTransactionMemo(\n normalizeTransactionMemo(\n params.transactionMemo ?? params.memo,\n HCS16_TOPIC_KEY_UPDATE_TRANSACTION_MEMO,\n ),\n );\n return new ScheduleCreateTransaction().setScheduledTransaction(inner);\n}\n\n/**\n * Build a TopicMessageSubmitTransaction for generic HCS‑16 messages.\n * Body fields are merged into the envelope `{ p: 'hcs-16', op, operator_id }`.\n */\nexport function buildHcs16MessageTx(params: {\n topicId: string;\n operatorId: string;\n op: FloraOperation;\n body?: Record<string, unknown>;\n transactionMemo?: string;\n}): TopicMessageSubmitTransaction {\n const payload: FloraMessage = {\n p: 'hcs-16',\n op: params.op,\n operator_id: params.operatorId,\n ...(params.body || {}),\n } as FloraMessage;\n\n return buildMessageTx({\n topicId: params.topicId,\n message: JSON.stringify(payload),\n transactionMemo: normalizeTransactionMemo(\n params.transactionMemo,\n encodeHcs16MessageSubmitTransactionMemo(params.op),\n ),\n });\n}\n\n/**\n * Build HCS‑16 flora_created message.\n */\nexport function buildHcs16FloraCreatedTx(params: {\n topicId: string;\n operatorId: string;\n floraAccountId: string;\n topics: { communication: string; transaction: string; state: string };\n}): TopicMessageSubmitTransaction {\n return buildHcs16MessageTx({\n topicId: params.topicId,\n operatorId: params.operatorId,\n op: FloraOperation.FLORA_CREATED,\n body: {\n flora_account_id: params.floraAccountId,\n topics: params.topics,\n },\n });\n}\n\n/**\n * Build HCS‑16 transaction message.\n */\nexport function buildHcs16TransactionTx(params: {\n topicId: string;\n operatorId: string;\n scheduleId: string;\n data?: string;\n}): TopicMessageSubmitTransaction {\n return buildHcs16MessageTx({\n topicId: params.topicId,\n operatorId: params.operatorId,\n op: FloraOperation.TRANSACTION,\n body: {\n schedule_id: params.scheduleId,\n data: params.data,\n m: params.data,\n },\n });\n}\n\n/**\n * Build HCS‑17 state_hash message for Flora STopic state updates.\n */\nexport function buildHcs16StateUpdateTx(params: {\n topicId: string;\n operatorId: string;\n hash: string;\n epoch?: number;\n accountId?: string;\n topics?: string[];\n memo?: string;\n transactionMemo?: string;\n}): TopicMessageSubmitTransaction {\n const payload = {\n p: 'hcs-17',\n op: 'state_hash',\n state_hash: params.hash,\n topics: params.topics ?? [],\n account_id: params.accountId ?? params.operatorId,\n epoch: params.epoch,\n timestamp: new Date().toISOString(),\n m: params.memo,\n };\n return buildMessageTx({\n topicId: params.topicId,\n message: JSON.stringify(payload),\n transactionMemo: normalizeTransactionMemo(\n params.transactionMemo,\n HCS17_STATE_HASH_TRANSACTION_MEMO,\n ),\n });\n}\n\n/**\n * Build HCS‑16 flora_join_request message.\n */\nexport function buildHcs16FloraJoinRequestTx(params: {\n topicId: string;\n operatorId: string;\n accountId: string;\n connectionRequestId: number;\n connectionTopicId: string;\n connectionSeq: number;\n}): TopicMessageSubmitTransaction {\n return buildHcs16MessageTx({\n topicId: params.topicId,\n operatorId: params.operatorId,\n op: FloraOperation.FLORA_JOIN_REQUEST,\n body: {\n account_id: params.accountId,\n connection_request_id: params.connectionRequestId,\n connection_topic_id: params.connectionTopicId,\n connection_seq: params.connectionSeq,\n },\n });\n}\n\n/**\n * Build HCS‑16 flora_join_vote message.\n */\nexport function buildHcs16FloraJoinVoteTx(params: {\n topicId: string;\n operatorId: string;\n accountId: string;\n approve: boolean;\n connectionRequestId: number;\n connectionSeq: number;\n}): TopicMessageSubmitTransaction {\n return buildHcs16MessageTx({\n topicId: params.topicId,\n operatorId: params.operatorId,\n op: FloraOperation.FLORA_JOIN_VOTE,\n body: {\n account_id: params.accountId,\n approve: params.approve,\n connection_request_id: params.connectionRequestId,\n connection_seq: params.connectionSeq,\n },\n });\n}\n\n/**\n * Build HCS‑16 flora_join_accepted message.\n */\nexport function buildHcs16FloraJoinAcceptedTx(params: {\n topicId: string;\n operatorId: string;\n members: string[];\n epoch?: number;\n}): TopicMessageSubmitTransaction {\n return buildHcs16MessageTx({\n topicId: params.topicId,\n operatorId: params.operatorId,\n op: FloraOperation.FLORA_JOIN_ACCEPTED,\n body: {\n members: params.members,\n epoch: params.epoch,\n },\n });\n}\n"],"names":[],"mappings":";;;AAqBO,MAAM,8CAA8C;AACpD,MAAM,oCAAoC;AAC1C,MAAM,4CAA4C;AAClD,MAAM,0CAA0C;AAEvD,SAAS,yBACP,OACA,UACQ;AACR,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,QAAM,UAAU,MAAM,KAAA;AACtB,MAAI,CAAC,QAAS,QAAO;AACrB,SAAO;AACT;AAEA,SAAS,qBAAqB,QAGnB;AACT,SAAO,UAAU,OAAO,cAAc,IAAI,OAAO,SAAS;AAC5D;AAEA,SAAS,sCACP,WACQ;AACR,SAAO,0BAA0B,SAAS;AAC5C;AAEA,MAAM,6BAA6D;AAAA,EACjE,CAAC,eAAe,aAAa,GAAG;AAAA,EAChC,CAAC,eAAe,WAAW,GAAG;AAAA,EAC9B,CAAC,eAAe,YAAY,GAAG;AAAA,EAC/B,CAAC,eAAe,kBAAkB,GAAG;AAAA,EACrC,CAAC,eAAe,eAAe,GAAG;AAAA,EAClC,CAAC,eAAe,mBAAmB,GAAG;AACxC;AAEA,MAAM,yBAAiE;AAAA,EACrE,C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,SAAS,KAAK,UAAU,OAAO;AAAA,IAC/B,iBAAiB;AAAA,MACf,OAAO;AAAA,MACP;AAAA,IAAA;AAAA,EACF,CACD;AACH;AAKO,SAAS,6BAA6B,QAOX;AAChC,SAAO,oBAAoB;AAAA,IACzB,SAAS,OAAO;AAAA,IAChB,YAAY,OAAO;AAAA,IACnB,IAAI,eAAe;AAAA,IACnB,MAAM;AAAA,MACJ,YAAY,OAAO;AAAA,MACnB,uBAAuB,OAAO;AAAA,MAC9B,qBAAqB,OAAO;AAAA,MAC5B,gBAAgB,OAAO;AAAA,IAAA;AAAA,EACzB,CACD;AACH;AAKO,SAAS,0BAA0B,QAOR;AAChC,SAAO,oBAAoB;AAAA,IACzB,SAAS,OAAO;AAAA,IAChB,YAAY,OAAO;AAAA,IACnB,IAAI,eAAe;AAAA,IACnB,MAAM;AAAA,MACJ,YAAY,OAAO;AAAA,MACnB,SAAS,OAAO;AAAA,MAChB,uBAAuB,OAAO;AAAA,MAC9B,gBAAgB,OAAO;AAAA,IAAA;AAAA,EACzB,CACD;AACH;AAKO,SAAS,8BAA8B,QAKZ;AAChC,SAAO,oBAAoB;AAAA,IACzB,SAAS,OAAO;AAAA,IAChB,YAAY,OAAO;AAAA,IACnB,IAAI,eAAe;AAAA,IACnB,MAAM;AAAA,MACJ,SAAS,OAAO;AAAA,MAChB,OAAO,OAAO;AAAA,IAAA;AAAA,EAChB,CACD;AACH;"}
|
|
1
|
+
{"version":3,"file":"standards-sdk.es92.js","sources":["../../src/hcs-16/tx.ts"],"sourcesContent":["import {\n TopicCreateTransaction,\n TopicMessageSubmitTransaction,\n TopicUpdateTransaction,\n AccountCreateTransaction,\n AccountUpdateTransaction,\n ScheduleCreateTransaction,\n Hbar,\n PublicKey,\n KeyList,\n AccountId,\n CustomFixedFee,\n TokenId,\n} from '@hashgraph/sdk';\nimport {\n buildTopicCreateTx,\n buildMessageTx,\n type MaybeKey,\n} from '../common/tx/tx-utils';\nimport { FloraOperation, FloraTopicType, type FloraMessage } from './types';\n\nexport const HCS16_FLORA_ACCOUNT_CREATE_TRANSACTION_MEMO = 'hcs-16:op:0:0';\nexport const HCS17_STATE_HASH_TRANSACTION_MEMO = 'hcs-17:op:6:2';\nexport const HCS16_ACCOUNT_KEY_UPDATE_TRANSACTION_MEMO = 'hcs-16:op:1:1';\nexport const HCS16_TOPIC_KEY_UPDATE_TRANSACTION_MEMO = 'hcs-16:op:1:1';\n\nfunction normalizeTransactionMemo(\n value: string | undefined,\n fallback: string,\n): string {\n if (typeof value !== 'string') return fallback;\n const trimmed = value.trim();\n if (!trimmed) return fallback;\n return trimmed;\n}\n\nfunction encodeHcs16FloraMemo(params: {\n floraAccountId: string;\n topicType: FloraTopicType;\n}): string {\n return `hcs-16:${params.floraAccountId}:${params.topicType}`;\n}\n\nfunction encodeHcs16TopicCreateTransactionMemo(\n topicType: FloraTopicType,\n): string {\n return `hcs-16:op:${HCS16_OPERATION_ENUM_BY_OP[FloraOperation.FLORA_CREATED]}:${topicType}`;\n}\n\nconst HCS16_OPERATION_ENUM_BY_OP: Record<FloraOperation, number> = {\n [FloraOperation.FLORA_CREATED]: 0,\n [FloraOperation.TRANSACTION]: 1,\n [FloraOperation.STATE_UPDATE]: 2,\n [FloraOperation.FLORA_JOIN_REQUEST]: 3,\n [FloraOperation.FLORA_JOIN_VOTE]: 4,\n [FloraOperation.FLORA_JOIN_ACCEPTED]: 5,\n};\n\nconst HCS16_TOPIC_TYPE_BY_OP: Record<FloraOperation, FloraTopicType> = {\n [FloraOperation.FLORA_CREATED]: FloraTopicType.COMMUNICATION,\n [FloraOperation.TRANSACTION]: FloraTopicType.TRANSACTION,\n [FloraOperation.STATE_UPDATE]: FloraTopicType.STATE,\n [FloraOperation.FLORA_JOIN_REQUEST]: FloraTopicType.COMMUNICATION,\n [FloraOperation.FLORA_JOIN_VOTE]: FloraTopicType.COMMUNICATION,\n [FloraOperation.FLORA_JOIN_ACCEPTED]: FloraTopicType.STATE,\n};\n\nfunction encodeHcs16MessageSubmitTransactionMemo(op: FloraOperation): string {\n return `hcs-16:op:${HCS16_OPERATION_ENUM_BY_OP[op]}:${HCS16_TOPIC_TYPE_BY_OP[op]}`;\n}\n\n/**\n * Build a TopicCreateTransaction for HCS‑16 Flora topics (communication/transaction/state).\n */\nexport function buildHcs16CreateFloraTopicTx(params: {\n floraAccountId: string;\n topicType: FloraTopicType;\n adminKey?: MaybeKey;\n submitKey?: MaybeKey;\n operatorPublicKey?: PublicKey;\n autoRenewAccountId?: string;\n transactionMemo?: string;\n}): TopicCreateTransaction {\n const memo = encodeHcs16FloraMemo({\n floraAccountId: params.floraAccountId,\n topicType: params.topicType,\n });\n const tx = buildTopicCreateTx({\n memo,\n adminKey: params.adminKey,\n submitKey: params.submitKey,\n operatorPublicKey: params.operatorPublicKey,\n });\n tx.setTransactionMemo(\n normalizeTransactionMemo(\n params.transactionMemo,\n encodeHcs16TopicCreateTransactionMemo(params.topicType),\n ),\n );\n if (params.autoRenewAccountId) {\n tx.setAutoRenewAccountId(AccountId.fromString(params.autoRenewAccountId));\n }\n return tx;\n}\n\n/**\n * Build a TopicCreateTransaction for a generic HCS‑16 transaction topic with HIP‑991 fees.\n */\nexport function buildHcs16CreateTransactionTopicTx(params: {\n memo: string;\n adminKey?: KeyList | PublicKey;\n submitKey?: KeyList | PublicKey;\n feeScheduleKey?: KeyList | PublicKey;\n customFees?: Array<{\n amount: number;\n feeCollectorAccountId: string;\n denominatingTokenId?: string;\n }>;\n feeExemptKeys?: PublicKey[];\n}): TopicCreateTransaction {\n const tx = new TopicCreateTransaction().setTopicMemo(params.memo);\n if (params.adminKey) {\n tx.setAdminKey(params.adminKey);\n }\n if (params.submitKey) {\n tx.setSubmitKey(params.submitKey);\n }\n if (params.feeScheduleKey) {\n tx.setFeeScheduleKey(params.feeScheduleKey);\n }\n if (params.customFees && params.customFees.length > 0) {\n const fees = params.customFees.map(fee => {\n const cf = new CustomFixedFee()\n .setAmount(fee.amount)\n .setFeeCollectorAccountId(\n AccountId.fromString(fee.feeCollectorAccountId),\n );\n if (fee.denominatingTokenId) {\n cf.setDenominatingTokenId(TokenId.fromString(fee.denominatingTokenId));\n }\n return cf;\n });\n tx.setCustomFees(fees);\n }\n if (params.feeExemptKeys && params.feeExemptKeys.length > 0) {\n throw new Error('feeExemptKeys not supported by installed @hashgraph/sdk');\n }\n return tx;\n}\n\n/**\n * Build an AccountCreateTransaction for a Flora account given a KeyList and optional params.\n */\nexport function buildHcs16CreateAccountTx(params: {\n keyList: KeyList;\n initialBalanceHbar?: number;\n maxAutomaticTokenAssociations?: number;\n transactionMemo?: string;\n}): AccountCreateTransaction {\n const tx = new AccountCreateTransaction().setKey(params.keyList);\n const initial =\n typeof params.initialBalanceHbar === 'number'\n ? params.initialBalanceHbar\n : 1;\n tx.setInitialBalance(new Hbar(initial));\n const maxAssoc =\n typeof params.maxAutomaticTokenAssociations === 'number'\n ? params.maxAutomaticTokenAssociations\n : -1;\n tx.setMaxAutomaticTokenAssociations(maxAssoc);\n tx.setTransactionMemo(\n normalizeTransactionMemo(\n params.transactionMemo,\n HCS16_FLORA_ACCOUNT_CREATE_TRANSACTION_MEMO,\n ),\n );\n return tx;\n}\n\n/**\n * Build a ScheduleCreateTransaction that wraps an AccountUpdateTransaction to rotate the Flora account KeyList.\n * Members will sign this scheduled transaction until threshold is reached and it executes.\n */\nexport function buildHcs16ScheduleAccountKeyUpdateTx(params: {\n floraAccountId: string;\n newKeyList: KeyList;\n memo?: string;\n transactionMemo?: string;\n}): ScheduleCreateTransaction {\n const inner = new AccountUpdateTransaction()\n .setAccountId(AccountId.fromString(params.floraAccountId))\n .setKey(params.newKeyList);\n inner.setTransactionMemo(\n normalizeTransactionMemo(\n params.transactionMemo ?? params.memo,\n HCS16_ACCOUNT_KEY_UPDATE_TRANSACTION_MEMO,\n ),\n );\n return new ScheduleCreateTransaction().setScheduledTransaction(inner);\n}\n\n/**\n * Build a ScheduleCreateTransaction that wraps a TopicUpdateTransaction to rotate topic admin/submit keys.\n * Repeat for CTopic, TTopic, and STopic as needed for membership changes.\n */\nexport function buildHcs16ScheduleTopicKeyUpdateTx(params: {\n topicId: string;\n adminKey?: KeyList | PublicKey;\n submitKey?: KeyList | PublicKey;\n memo?: string;\n transactionMemo?: string;\n}): ScheduleCreateTransaction {\n const inner = new TopicUpdateTransaction().setTopicId(params.topicId);\n if (params.adminKey) {\n inner.setAdminKey(params.adminKey);\n }\n if (params.submitKey) {\n inner.setSubmitKey(params.submitKey);\n }\n inner.setTransactionMemo(\n normalizeTransactionMemo(\n params.transactionMemo ?? params.memo,\n HCS16_TOPIC_KEY_UPDATE_TRANSACTION_MEMO,\n ),\n );\n return new ScheduleCreateTransaction().setScheduledTransaction(inner);\n}\n\n/**\n * Build a TopicMessageSubmitTransaction for generic HCS‑16 messages.\n * Body fields are merged into the envelope `{ p: 'hcs-16', op, operator_id }`.\n */\nexport function buildHcs16MessageTx(params: {\n topicId: string;\n operatorId: string;\n op: FloraOperation;\n body?: Record<string, unknown>;\n transactionMemo?: string;\n}): TopicMessageSubmitTransaction {\n const payload: FloraMessage = {\n p: 'hcs-16',\n op: params.op,\n operator_id: params.operatorId,\n ...(params.body || {}),\n } as FloraMessage;\n\n return buildMessageTx({\n topicId: params.topicId,\n message: JSON.stringify(payload),\n transactionMemo: normalizeTransactionMemo(\n params.transactionMemo,\n encodeHcs16MessageSubmitTransactionMemo(params.op),\n ),\n });\n}\n\n/**\n * Build HCS‑16 flora_created message.\n */\nexport function buildHcs16FloraCreatedTx(params: {\n topicId: string;\n operatorId: string;\n floraAccountId: string;\n topics: { communication: string; transaction: string; state: string };\n}): TopicMessageSubmitTransaction {\n return buildHcs16MessageTx({\n topicId: params.topicId,\n operatorId: params.operatorId,\n op: FloraOperation.FLORA_CREATED,\n body: {\n flora_account_id: params.floraAccountId,\n topics: params.topics,\n },\n });\n}\n\n/**\n * Build HCS‑16 transaction message.\n */\nexport function buildHcs16TransactionTx(params: {\n topicId: string;\n operatorId: string;\n scheduleId: string;\n data?: string;\n}): TopicMessageSubmitTransaction {\n return buildHcs16MessageTx({\n topicId: params.topicId,\n operatorId: params.operatorId,\n op: FloraOperation.TRANSACTION,\n body: {\n schedule_id: params.scheduleId,\n data: params.data,\n m: params.data,\n },\n });\n}\n\n/**\n * Build HCS‑17 state_hash message for Flora STopic state updates.\n */\nexport function buildHcs16StateUpdateTx(params: {\n topicId: string;\n operatorId: string;\n hash: string;\n epoch?: number;\n accountId?: string;\n topics?: string[];\n memo?: string;\n transactionMemo?: string;\n}): TopicMessageSubmitTransaction {\n const payload = {\n p: 'hcs-17',\n op: 'state_hash',\n state_hash: params.hash,\n topics: params.topics ?? [],\n account_id: params.accountId ?? params.operatorId,\n epoch: params.epoch,\n timestamp: new Date().toISOString(),\n m: params.memo,\n };\n return buildMessageTx({\n topicId: params.topicId,\n message: JSON.stringify(payload),\n transactionMemo: normalizeTransactionMemo(\n params.transactionMemo,\n HCS17_STATE_HASH_TRANSACTION_MEMO,\n ),\n });\n}\n\n/**\n * Build HCS‑16 flora_join_request message.\n */\nexport function buildHcs16FloraJoinRequestTx(params: {\n topicId: string;\n operatorId: string;\n accountId: string;\n connectionRequestId: number;\n connectionTopicId: string;\n connectionSeq: number;\n}): TopicMessageSubmitTransaction {\n return buildHcs16MessageTx({\n topicId: params.topicId,\n operatorId: params.operatorId,\n op: FloraOperation.FLORA_JOIN_REQUEST,\n body: {\n account_id: params.accountId,\n connection_request_id: params.connectionRequestId,\n connection_topic_id: params.connectionTopicId,\n connection_seq: params.connectionSeq,\n },\n });\n}\n\n/**\n * Build HCS‑16 flora_join_vote message.\n */\nexport function buildHcs16FloraJoinVoteTx(params: {\n topicId: string;\n operatorId: string;\n accountId: string;\n approve: boolean;\n connectionRequestId: number;\n connectionSeq: number;\n}): TopicMessageSubmitTransaction {\n return buildHcs16MessageTx({\n topicId: params.topicId,\n operatorId: params.operatorId,\n op: FloraOperation.FLORA_JOIN_VOTE,\n body: {\n account_id: params.accountId,\n approve: params.approve,\n connection_request_id: params.connectionRequestId,\n connection_seq: params.connectionSeq,\n },\n });\n}\n\n/**\n * Build HCS‑16 flora_join_accepted message.\n */\nexport function buildHcs16FloraJoinAcceptedTx(params: {\n topicId: string;\n operatorId: string;\n members: string[];\n epoch?: number;\n}): TopicMessageSubmitTransaction {\n return buildHcs16MessageTx({\n topicId: params.topicId,\n operatorId: params.operatorId,\n op: FloraOperation.FLORA_JOIN_ACCEPTED,\n body: {\n members: params.members,\n epoch: params.epoch,\n },\n });\n}\n"],"names":[],"mappings":";;;AAqBO,MAAM,8CAA8C;AACpD,MAAM,oCAAoC;AAC1C,MAAM,4CAA4C;AAClD,MAAM,0CAA0C;AAEvD,SAAS,yBACP,OACA,UACQ;AACR,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,QAAM,UAAU,MAAM,KAAA;AACtB,MAAI,CAAC,QAAS,QAAO;AACrB,SAAO;AACT;AAEA,SAAS,qBAAqB,QAGnB;AACT,SAAO,UAAU,OAAO,cAAc,IAAI,OAAO,SAAS;AAC5D;AAEA,SAAS,sCACP,WACQ;AACR,SAAO,aAAa,2BAA2B,eAAe,aAAa,CAAC,IAAI,SAAS;AAC3F;AAEA,MAAM,6BAA6D;AAAA,EACjE,CAAC,eAAe,aAAa,GAAG;AAAA,EAChC,CAAC,eAAe,WAAW,GAAG;AAAA,EAC9B,CAAC,eAAe,YAAY,GAAG;AAAA,EAC/B,CAAC,eAAe,kBAAkB,GAAG;AAAA,EACrC,CAAC,eAAe,eAAe,GAAG;AAAA,EAClC,CAAC,eAAe,mBAAmB,GAAG;AACxC;AAEA,MAAM,yBAAiE;AAAA,EACrE,CAAC,eAAe,aAAa,GAAG,eAAe;AAAA,EAC/C,CAAC,eAAe,WAAW,GAAG,eAAe;AAAA,EAC7C,CAAC,eAAe,YAAY,GAAG,eAAe;AAAA,EAC9C,CAAC,eAAe,kBAAkB,GAAG,eAAe;AAAA,EACpD,CAAC,eAAe,eAAe,GAAG,eAAe;AAAA,EACjD,CAAC,eAAe,mBAAmB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nB,MAAM;AAAA,MACJ,YAAY,OAAO;AAAA,MACnB,uBAAuB,OAAO;AAAA,MAC9B,qBAAqB,OAAO;AAAA,MAC5B,gBAAgB,OAAO;AAAA,IAAA;AAAA,EACzB,CACD;AACH;AAKO,SAAS,0BAA0B,QAOR;AAChC,SAAO,oBAAoB;AAAA,IACzB,SAAS,OAAO;AAAA,IAChB,YAAY,OAAO;AAAA,IACnB,IAAI,eAAe;AAAA,IACnB,MAAM;AAAA,MACJ,YAAY,OAAO;AAAA,MACnB,SAAS,OAAO;AAAA,MAChB,uBAAuB,OAAO;AAAA,MAC9B,gBAAgB,OAAO;AAAA,IAAA;AAAA,EACzB,CACD;AACH;AAKO,SAAS,8BAA8B,QAKZ;AAChC,SAAO,oBAAoB;AAAA,IACzB,SAAS,OAAO;AAAA,IAChB,YAAY,OAAO;AAAA,IACnB,IAAI,eAAe;AAAA,IACnB,MAAM;AAAA,MACJ,SAAS,OAAO;AAAA,MAChB,OAAO,OAAO;AAAA,IAAA;AAAA,EAChB,CACD;AACH;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AccountId, Client, ScheduleSignTransaction } from "@hashgraph/sdk";
|
|
2
2
|
import "./standards-sdk.es106.js";
|
|
3
3
|
import { HCS11Client } from "./standards-sdk.es28.js";
|
|
4
|
-
import { createNodeOperatorContext } from "./standards-sdk.
|
|
4
|
+
import { createNodeOperatorContext } from "./standards-sdk.es147.js";
|
|
5
5
|
import { HederaMirrorNode } from "./standards-sdk.es127.js";
|
|
6
6
|
import { HCS16BaseClient } from "./standards-sdk.es95.js";
|
|
7
7
|
import { buildHcs16CreateFloraTopicTx, buildHcs16CreateAccountTx, buildHcs16FloraCreatedTx, buildHcs16TransactionTx, buildHcs16StateUpdateTx, buildHcs16FloraJoinRequestTx, buildHcs16FloraJoinVoteTx, buildHcs16FloraJoinAcceptedTx } from "./standards-sdk.es92.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AccountId, Client } from "@hashgraph/sdk";
|
|
2
2
|
import { HCS17BaseClient } from "./standards-sdk.es97.js";
|
|
3
3
|
import { buildHcs17CreateTopicTx, buildHcs17MessageTx } from "./standards-sdk.es100.js";
|
|
4
|
-
import { createNodeOperatorContext } from "./standards-sdk.
|
|
4
|
+
import { createNodeOperatorContext } from "./standards-sdk.es147.js";
|
|
5
5
|
class HCS17Client extends HCS17BaseClient {
|
|
6
6
|
constructor(config) {
|
|
7
7
|
super(config);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hashgraphonline/standards-sdk",
|
|
3
|
-
"version": "0.1.143-feat-solana-register.canary.
|
|
3
|
+
"version": "0.1.143-feat-solana-register.canary.1c6f446.78",
|
|
4
4
|
"description": "The Hashgraph Online Standards SDK provides a complete implementation of the Hiero Consensus Standards (HCS), giving developers all the tools needed to build wonderful decentralized applications on the Hashgraph network.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
class EncryptionUnavailableError extends Error {
|
|
2
|
-
constructor(sessionId, summary) {
|
|
3
|
-
super("Encryption is not enabled for this session");
|
|
4
|
-
this.sessionId = sessionId;
|
|
5
|
-
this.summary = summary;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
class EncryptedChatManager {
|
|
9
|
-
constructor(client) {
|
|
10
|
-
this.client = client;
|
|
11
|
-
}
|
|
12
|
-
registerConversationContext(context) {
|
|
13
|
-
this.client.registerConversationContextForEncryption(context);
|
|
14
|
-
}
|
|
15
|
-
async startSession(options) {
|
|
16
|
-
await this.client.encryptionReady();
|
|
17
|
-
const session = await this.client.chat.createSession({
|
|
18
|
-
uaid: options.uaid,
|
|
19
|
-
senderUaid: options.senderUaid,
|
|
20
|
-
encryptionRequested: true,
|
|
21
|
-
historyTtlSeconds: options.historyTtlSeconds,
|
|
22
|
-
auth: options.auth
|
|
23
|
-
});
|
|
24
|
-
options.onSessionCreated?.(session.sessionId);
|
|
25
|
-
const summary = session.encryption;
|
|
26
|
-
if (!summary?.enabled) {
|
|
27
|
-
throw new EncryptionUnavailableError(
|
|
28
|
-
session.sessionId,
|
|
29
|
-
session.encryption ?? null
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
const handle = await this.establishRequesterContext({
|
|
33
|
-
sessionId: session.sessionId,
|
|
34
|
-
summary,
|
|
35
|
-
senderUaid: options.senderUaid,
|
|
36
|
-
handshakeTimeoutMs: options.handshakeTimeoutMs,
|
|
37
|
-
pollIntervalMs: options.pollIntervalMs
|
|
38
|
-
});
|
|
39
|
-
return handle;
|
|
40
|
-
}
|
|
41
|
-
async acceptSession(options) {
|
|
42
|
-
await this.client.encryptionReady();
|
|
43
|
-
const summary = await this.waitForEncryptionSummary(
|
|
44
|
-
options.sessionId,
|
|
45
|
-
options.handshakeTimeoutMs,
|
|
46
|
-
options.pollIntervalMs
|
|
47
|
-
);
|
|
48
|
-
const handle = await this.establishResponderContext({
|
|
49
|
-
sessionId: options.sessionId,
|
|
50
|
-
summary,
|
|
51
|
-
responderUaid: options.responderUaid,
|
|
52
|
-
handshakeTimeoutMs: options.handshakeTimeoutMs,
|
|
53
|
-
pollIntervalMs: options.pollIntervalMs
|
|
54
|
-
});
|
|
55
|
-
return handle;
|
|
56
|
-
}
|
|
57
|
-
async establishRequesterContext(params) {
|
|
58
|
-
const keyPair = this.client.encryption.generateEphemeralKeyPair();
|
|
59
|
-
await this.client.chat.submitEncryptionHandshake(params.sessionId, {
|
|
60
|
-
role: "requester",
|
|
61
|
-
keyType: "secp256k1",
|
|
62
|
-
ephemeralPublicKey: keyPair.publicKey,
|
|
63
|
-
uaid: params.senderUaid ?? params.summary.requester?.uaid ?? void 0
|
|
64
|
-
});
|
|
65
|
-
const { summary, record } = await this.waitForHandshakeCompletion(
|
|
66
|
-
params.sessionId,
|
|
67
|
-
params.handshakeTimeoutMs,
|
|
68
|
-
params.pollIntervalMs
|
|
69
|
-
);
|
|
70
|
-
const responderKey = record.responder?.ephemeralPublicKey;
|
|
71
|
-
if (!responderKey) {
|
|
72
|
-
throw new Error("Responder handshake was not completed in time");
|
|
73
|
-
}
|
|
74
|
-
const sharedSecret = this.client.encryption.deriveSharedSecret({
|
|
75
|
-
privateKey: keyPair.privateKey,
|
|
76
|
-
peerPublicKey: responderKey
|
|
77
|
-
}).subarray();
|
|
78
|
-
const recipients = this.buildRecipients(summary);
|
|
79
|
-
return this.createHandle({
|
|
80
|
-
sessionId: params.sessionId,
|
|
81
|
-
sharedSecret,
|
|
82
|
-
summary,
|
|
83
|
-
recipients,
|
|
84
|
-
identity: summary.requester ?? void 0
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
async establishResponderContext(params) {
|
|
88
|
-
const keyPair = this.client.encryption.generateEphemeralKeyPair();
|
|
89
|
-
await this.client.chat.submitEncryptionHandshake(params.sessionId, {
|
|
90
|
-
role: "responder",
|
|
91
|
-
keyType: "secp256k1",
|
|
92
|
-
ephemeralPublicKey: keyPair.publicKey,
|
|
93
|
-
uaid: params.responderUaid ?? params.summary.responder?.uaid ?? void 0
|
|
94
|
-
});
|
|
95
|
-
const { summary, record } = await this.waitForHandshakeCompletion(
|
|
96
|
-
params.sessionId,
|
|
97
|
-
params.handshakeTimeoutMs,
|
|
98
|
-
params.pollIntervalMs
|
|
99
|
-
);
|
|
100
|
-
const requesterKey = record.requester?.ephemeralPublicKey;
|
|
101
|
-
if (!requesterKey) {
|
|
102
|
-
throw new Error("Requester handshake was not detected in time");
|
|
103
|
-
}
|
|
104
|
-
const sharedSecret = this.client.encryption.deriveSharedSecret({
|
|
105
|
-
privateKey: keyPair.privateKey,
|
|
106
|
-
peerPublicKey: requesterKey
|
|
107
|
-
}).subarray();
|
|
108
|
-
const recipients = this.buildRecipients(summary);
|
|
109
|
-
return this.createHandle({
|
|
110
|
-
sessionId: params.sessionId,
|
|
111
|
-
sharedSecret,
|
|
112
|
-
summary,
|
|
113
|
-
recipients,
|
|
114
|
-
identity: summary.responder ?? void 0
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
async waitForHandshakeCompletion(sessionId, timeoutMs = 3e4, pollIntervalMs = 1e3) {
|
|
118
|
-
const deadline = Date.now() + timeoutMs;
|
|
119
|
-
while (true) {
|
|
120
|
-
const status = await this.client.chat.getEncryptionStatus(sessionId);
|
|
121
|
-
const summary = status.encryption;
|
|
122
|
-
const record = summary?.handshake;
|
|
123
|
-
if (summary && record && record.status === "complete") {
|
|
124
|
-
return { summary, record };
|
|
125
|
-
}
|
|
126
|
-
if (Date.now() >= deadline) {
|
|
127
|
-
throw new Error("Timed out waiting for encrypted handshake completion");
|
|
128
|
-
}
|
|
129
|
-
await this.delay(pollIntervalMs);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
async waitForEncryptionSummary(sessionId, _timeoutMs = 3e4, _pollIntervalMs = 1e3) {
|
|
133
|
-
const status = await this.client.chat.getEncryptionStatus(sessionId);
|
|
134
|
-
if (!status.encryption?.enabled) {
|
|
135
|
-
throw new EncryptionUnavailableError(
|
|
136
|
-
sessionId,
|
|
137
|
-
status.encryption ?? null
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
return status.encryption;
|
|
141
|
-
}
|
|
142
|
-
buildRecipients(summary) {
|
|
143
|
-
const candidates = [summary.requester, summary.responder].filter(Boolean);
|
|
144
|
-
const normalized = candidates.map((candidate) => {
|
|
145
|
-
if (!candidate) {
|
|
146
|
-
return null;
|
|
147
|
-
}
|
|
148
|
-
const recipient = {};
|
|
149
|
-
if (candidate.uaid) {
|
|
150
|
-
recipient.uaid = candidate.uaid;
|
|
151
|
-
}
|
|
152
|
-
if (candidate.ledgerAccountId) {
|
|
153
|
-
recipient.ledgerAccountId = candidate.ledgerAccountId;
|
|
154
|
-
}
|
|
155
|
-
if (candidate.userId) {
|
|
156
|
-
recipient.userId = candidate.userId;
|
|
157
|
-
}
|
|
158
|
-
if (candidate.email) {
|
|
159
|
-
recipient.email = candidate.email;
|
|
160
|
-
}
|
|
161
|
-
return recipient;
|
|
162
|
-
}).filter(
|
|
163
|
-
(entry) => Boolean(
|
|
164
|
-
entry?.uaid || entry?.ledgerAccountId || entry?.userId || entry?.email
|
|
165
|
-
)
|
|
166
|
-
);
|
|
167
|
-
if (normalized.length > 0) {
|
|
168
|
-
return normalized;
|
|
169
|
-
}
|
|
170
|
-
if (summary.responder?.uaid) {
|
|
171
|
-
return [{ uaid: summary.responder.uaid }];
|
|
172
|
-
}
|
|
173
|
-
return [];
|
|
174
|
-
}
|
|
175
|
-
createHandle(context) {
|
|
176
|
-
const sharedSecret = context.sharedSecret;
|
|
177
|
-
const uaid = context.summary.requester?.uaid ?? context.summary.responder?.uaid ?? context.identity?.uaid;
|
|
178
|
-
const handle = {
|
|
179
|
-
sessionId: context.sessionId,
|
|
180
|
-
mode: "encrypted",
|
|
181
|
-
summary: context.summary,
|
|
182
|
-
send: async (options) => {
|
|
183
|
-
const recipients = options.recipients ?? context.recipients;
|
|
184
|
-
return this.client.chat.sendMessage({
|
|
185
|
-
sessionId: context.sessionId,
|
|
186
|
-
message: options.message ?? "[ciphertext omitted]",
|
|
187
|
-
streaming: options.streaming,
|
|
188
|
-
auth: options.auth,
|
|
189
|
-
uaid,
|
|
190
|
-
encryption: {
|
|
191
|
-
plaintext: options.plaintext,
|
|
192
|
-
sharedSecret: Buffer.from(sharedSecret),
|
|
193
|
-
recipients
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
},
|
|
197
|
-
decryptHistoryEntry: (entry) => this.decryptEntry(entry, context.identity, sharedSecret)
|
|
198
|
-
};
|
|
199
|
-
this.registerConversationContext({
|
|
200
|
-
sessionId: context.sessionId,
|
|
201
|
-
sharedSecret,
|
|
202
|
-
identity: context.identity
|
|
203
|
-
});
|
|
204
|
-
return handle;
|
|
205
|
-
}
|
|
206
|
-
decryptEntry(entry, identity, fallbackSecret) {
|
|
207
|
-
const envelope = entry.cipherEnvelope;
|
|
208
|
-
if (!envelope) {
|
|
209
|
-
return null;
|
|
210
|
-
}
|
|
211
|
-
const secret = Buffer.from(fallbackSecret);
|
|
212
|
-
try {
|
|
213
|
-
return this.client.encryption.decryptCipherEnvelope({
|
|
214
|
-
envelope,
|
|
215
|
-
sharedSecret: secret
|
|
216
|
-
});
|
|
217
|
-
} catch (_error) {
|
|
218
|
-
return null;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
recipientMatches(candidate, target) {
|
|
222
|
-
if (target.uaid && candidate.uaid?.toLowerCase() === target.uaid.toLowerCase()) {
|
|
223
|
-
return true;
|
|
224
|
-
}
|
|
225
|
-
if (target.ledgerAccountId && candidate.ledgerAccountId?.toLowerCase() === target.ledgerAccountId.toLowerCase()) {
|
|
226
|
-
return true;
|
|
227
|
-
}
|
|
228
|
-
if (target.userId && candidate.userId === target.userId) {
|
|
229
|
-
return true;
|
|
230
|
-
}
|
|
231
|
-
if (target.email && candidate.email?.toLowerCase() === target.email.toLowerCase()) {
|
|
232
|
-
return true;
|
|
233
|
-
}
|
|
234
|
-
return false;
|
|
235
|
-
}
|
|
236
|
-
async delay(ms) {
|
|
237
|
-
if (ms <= 0) {
|
|
238
|
-
return;
|
|
239
|
-
}
|
|
240
|
-
await new Promise((resolve) => setTimeout(resolve, ms));
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
export {
|
|
244
|
-
EncryptedChatManager,
|
|
245
|
-
EncryptionUnavailableError
|
|
246
|
-
};
|
|
247
|
-
//# sourceMappingURL=standards-sdk.es162.js.map
|