@hashgraphonline/standards-sdk 0.1.141 → 0.1.143
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/README.md +24 -1
- package/dist/cjs/hcs-11/client.d.ts.map +1 -1
- package/dist/cjs/hcs-11/types.d.ts +1 -0
- package/dist/cjs/hcs-11/types.d.ts.map +1 -1
- package/dist/cjs/hcs-16/base-client.d.ts.map +1 -1
- package/dist/cjs/hcs-17/types.d.ts.map +1 -1
- package/dist/cjs/hcs-20/sdk.d.ts.map +1 -1
- package/dist/cjs/hcs-20/types.d.ts +9 -8
- package/dist/cjs/hcs-20/types.d.ts.map +1 -1
- package/dist/cjs/hcs-21/base-client.d.ts +14 -12
- package/dist/cjs/hcs-21/base-client.d.ts.map +1 -1
- package/dist/cjs/hcs-21/browser.d.ts +17 -7
- package/dist/cjs/hcs-21/browser.d.ts.map +1 -1
- package/dist/cjs/hcs-21/index.d.ts +1 -0
- package/dist/cjs/hcs-21/index.d.ts.map +1 -1
- package/dist/cjs/hcs-21/sdk.d.ts +70 -6
- package/dist/cjs/hcs-21/sdk.d.ts.map +1 -1
- package/dist/cjs/hcs-21/tx.d.ts +6 -2
- package/dist/cjs/hcs-21/tx.d.ts.map +1 -1
- package/dist/cjs/hcs-21/types.d.ts +751 -66
- package/dist/cjs/hcs-21/types.d.ts.map +1 -1
- package/dist/cjs/hcs-21/verify.d.ts +6 -0
- package/dist/cjs/hcs-21/verify.d.ts.map +1 -0
- package/dist/cjs/inscribe/inscriber.d.ts +3 -1
- package/dist/cjs/inscribe/inscriber.d.ts.map +1 -1
- package/dist/cjs/inscribe/quote-cache.d.ts.map +1 -1
- package/dist/cjs/inscribe/types.d.ts +7 -0
- package/dist/cjs/inscribe/types.d.ts.map +1 -1
- package/dist/cjs/services/registry-broker/client.d.ts +4 -3
- package/dist/cjs/services/registry-broker/client.d.ts.map +1 -1
- package/dist/cjs/services/registry-broker/private-key-signer.d.ts.map +1 -1
- package/dist/cjs/services/registry-broker/schemas.d.ts +49 -25
- package/dist/cjs/services/registry-broker/schemas.d.ts.map +1 -1
- package/dist/cjs/services/registry-broker/types.d.ts +1 -2
- package/dist/cjs/services/registry-broker/types.d.ts.map +1 -1
- package/dist/cjs/services/types.d.ts +1 -0
- package/dist/cjs/services/types.d.ts.map +1 -1
- package/dist/cjs/standards-sdk.cjs +2 -2
- package/dist/cjs/standards-sdk.cjs.map +1 -1
- package/dist/cjs/utils/dynamic-import.d.ts +1 -0
- package/dist/cjs/utils/dynamic-import.d.ts.map +1 -1
- package/dist/es/hcs-11/client.d.ts.map +1 -1
- package/dist/es/hcs-11/types.d.ts +1 -0
- package/dist/es/hcs-11/types.d.ts.map +1 -1
- package/dist/es/hcs-16/base-client.d.ts.map +1 -1
- package/dist/es/hcs-17/types.d.ts.map +1 -1
- package/dist/es/hcs-20/sdk.d.ts.map +1 -1
- package/dist/es/hcs-20/types.d.ts +9 -8
- package/dist/es/hcs-20/types.d.ts.map +1 -1
- package/dist/es/hcs-21/base-client.d.ts +14 -12
- package/dist/es/hcs-21/base-client.d.ts.map +1 -1
- package/dist/es/hcs-21/browser.d.ts +17 -7
- package/dist/es/hcs-21/browser.d.ts.map +1 -1
- package/dist/es/hcs-21/index.d.ts +1 -0
- package/dist/es/hcs-21/index.d.ts.map +1 -1
- package/dist/es/hcs-21/sdk.d.ts +70 -6
- package/dist/es/hcs-21/sdk.d.ts.map +1 -1
- package/dist/es/hcs-21/tx.d.ts +6 -2
- package/dist/es/hcs-21/tx.d.ts.map +1 -1
- package/dist/es/hcs-21/types.d.ts +751 -66
- package/dist/es/hcs-21/types.d.ts.map +1 -1
- package/dist/es/hcs-21/verify.d.ts +6 -0
- package/dist/es/hcs-21/verify.d.ts.map +1 -0
- package/dist/es/inscribe/inscriber.d.ts +3 -1
- package/dist/es/inscribe/inscriber.d.ts.map +1 -1
- package/dist/es/inscribe/quote-cache.d.ts.map +1 -1
- package/dist/es/inscribe/types.d.ts +7 -0
- package/dist/es/inscribe/types.d.ts.map +1 -1
- package/dist/es/services/registry-broker/client.d.ts +4 -3
- package/dist/es/services/registry-broker/client.d.ts.map +1 -1
- package/dist/es/services/registry-broker/private-key-signer.d.ts.map +1 -1
- package/dist/es/services/registry-broker/schemas.d.ts +49 -25
- package/dist/es/services/registry-broker/schemas.d.ts.map +1 -1
- package/dist/es/services/registry-broker/types.d.ts +1 -2
- package/dist/es/services/registry-broker/types.d.ts.map +1 -1
- package/dist/es/services/types.d.ts +1 -0
- package/dist/es/services/types.d.ts.map +1 -1
- package/dist/es/standards-sdk.es.js +64 -51
- package/dist/es/standards-sdk.es.js.map +1 -1
- package/dist/es/standards-sdk.es10.js +2 -2
- package/dist/es/standards-sdk.es100.js +26 -229
- package/dist/es/standards-sdk.es100.js.map +1 -1
- package/dist/es/standards-sdk.es101.js +228 -109
- package/dist/es/standards-sdk.es101.js.map +1 -1
- package/dist/es/standards-sdk.es102.js +94 -15
- package/dist/es/standards-sdk.es102.js.map +1 -1
- package/dist/es/standards-sdk.es103.js +30 -80
- package/dist/es/standards-sdk.es103.js.map +1 -1
- package/dist/es/standards-sdk.es104.js +80 -27
- package/dist/es/standards-sdk.es104.js.map +1 -1
- package/dist/es/standards-sdk.es105.js +25 -136
- package/dist/es/standards-sdk.es105.js.map +1 -1
- package/dist/es/standards-sdk.es106.js +140 -27
- package/dist/es/standards-sdk.es106.js.map +1 -1
- package/dist/es/standards-sdk.es107.js +27 -20
- package/dist/es/standards-sdk.es107.js.map +1 -1
- package/dist/es/standards-sdk.es108.js +18 -156
- package/dist/es/standards-sdk.es108.js.map +1 -1
- package/dist/es/standards-sdk.es109.js +148 -196
- package/dist/es/standards-sdk.es109.js.map +1 -1
- package/dist/es/standards-sdk.es110.js +160 -747
- package/dist/es/standards-sdk.es110.js.map +1 -1
- package/dist/es/standards-sdk.es111.js +786 -9
- package/dist/es/standards-sdk.es111.js.map +1 -1
- package/dist/es/standards-sdk.es112.js +13 -567
- package/dist/es/standards-sdk.es112.js.map +1 -1
- package/dist/es/standards-sdk.es113.js +541 -576
- package/dist/es/standards-sdk.es113.js.map +1 -1
- package/dist/es/standards-sdk.es114.js +601 -12
- package/dist/es/standards-sdk.es114.js.map +1 -1
- package/dist/es/standards-sdk.es115.js +13 -2
- package/dist/es/standards-sdk.es115.js.map +1 -1
- package/dist/es/standards-sdk.es116.js +2 -83
- package/dist/es/standards-sdk.es116.js.map +1 -1
- package/dist/es/standards-sdk.es117.js +80 -36
- package/dist/es/standards-sdk.es117.js.map +1 -1
- package/dist/es/standards-sdk.es118.js +39 -2
- package/dist/es/standards-sdk.es118.js.map +1 -1
- package/dist/es/standards-sdk.es119.js +2 -223
- package/dist/es/standards-sdk.es119.js.map +1 -1
- package/dist/es/standards-sdk.es12.js +1 -1
- package/dist/es/standards-sdk.es120.js +193 -1110
- package/dist/es/standards-sdk.es120.js.map +1 -1
- package/dist/es/standards-sdk.es121.js +1059 -225
- package/dist/es/standards-sdk.es121.js.map +1 -1
- package/dist/es/standards-sdk.es122.js +303 -419
- package/dist/es/standards-sdk.es122.js.map +1 -1
- package/dist/es/standards-sdk.es123.js +418 -351
- package/dist/es/standards-sdk.es123.js.map +1 -1
- package/dist/es/standards-sdk.es124.js +348 -754
- package/dist/es/standards-sdk.es124.js.map +1 -1
- package/dist/es/standards-sdk.es125.js +854 -178
- package/dist/es/standards-sdk.es125.js.map +1 -1
- package/dist/es/standards-sdk.es126.js +153 -1512
- package/dist/es/standards-sdk.es126.js.map +1 -1
- package/dist/es/standards-sdk.es127.js +1373 -1977
- package/dist/es/standards-sdk.es127.js.map +1 -1
- package/dist/es/standards-sdk.es128.js +2211 -50
- package/dist/es/standards-sdk.es128.js.map +1 -1
- package/dist/es/standards-sdk.es129.js +59 -79
- package/dist/es/standards-sdk.es129.js.map +1 -1
- package/dist/es/standards-sdk.es13.js +1 -1
- package/dist/es/standards-sdk.es130.js +80 -152
- package/dist/es/standards-sdk.es130.js.map +1 -1
- package/dist/es/standards-sdk.es131.js +159 -7
- package/dist/es/standards-sdk.es131.js.map +1 -1
- package/dist/es/standards-sdk.es132.js +7 -86
- package/dist/es/standards-sdk.es132.js.map +1 -1
- package/dist/es/standards-sdk.es133.js +65 -44
- package/dist/es/standards-sdk.es133.js.map +1 -1
- package/dist/es/standards-sdk.es134.js +65 -28
- package/dist/es/standards-sdk.es134.js.map +1 -1
- package/dist/es/standards-sdk.es135.js +28 -138
- package/dist/es/standards-sdk.es135.js.map +1 -1
- package/dist/es/standards-sdk.es136.js +133 -37
- package/dist/es/standards-sdk.es136.js.map +1 -1
- package/dist/es/standards-sdk.es137.js +42 -732
- package/dist/es/standards-sdk.es137.js.map +1 -1
- package/dist/es/standards-sdk.es138.js +746 -12254
- 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.es14.js +1 -1
- package/dist/es/standards-sdk.es141.js +20 -2
- package/dist/es/standards-sdk.es141.js.map +1 -1
- package/dist/es/standards-sdk.es142.js +13 -168
- package/dist/es/standards-sdk.es142.js.map +1 -1
- package/dist/es/standards-sdk.es143.js +139 -289
- package/dist/es/standards-sdk.es143.js.map +1 -1
- package/dist/es/standards-sdk.es144.js +274 -298
- package/dist/es/standards-sdk.es144.js.map +1 -1
- package/dist/es/standards-sdk.es145.js +262 -369
- package/dist/es/standards-sdk.es145.js.map +1 -1
- package/dist/es/standards-sdk.es146.js +316 -194
- package/dist/es/standards-sdk.es146.js.map +1 -1
- package/dist/es/standards-sdk.es147.js +319 -64
- package/dist/es/standards-sdk.es147.js.map +1 -1
- package/dist/es/standards-sdk.es148.js +79 -0
- package/dist/es/standards-sdk.es148.js.map +1 -0
- package/dist/es/standards-sdk.es15.js +1 -1
- package/dist/es/standards-sdk.es16.js +1 -1
- package/dist/es/standards-sdk.es17.js +5 -10
- package/dist/es/standards-sdk.es17.js.map +1 -1
- package/dist/es/standards-sdk.es19.js +12 -16
- package/dist/es/standards-sdk.es19.js.map +1 -1
- package/dist/es/standards-sdk.es20.js +9 -13
- package/dist/es/standards-sdk.es20.js.map +1 -1
- package/dist/es/standards-sdk.es21.js +1 -1
- package/dist/es/standards-sdk.es22.js +1 -1
- package/dist/es/standards-sdk.es23.js +1 -1
- package/dist/es/standards-sdk.es24.js +1 -1
- package/dist/es/standards-sdk.es25.js +1 -1
- package/dist/es/standards-sdk.es26.js +1 -1
- package/dist/es/standards-sdk.es27.js +1 -1
- package/dist/es/standards-sdk.es28.js +16 -18
- package/dist/es/standards-sdk.es28.js.map +1 -1
- package/dist/es/standards-sdk.es29.js.map +1 -1
- package/dist/es/standards-sdk.es3.js +2 -2
- package/dist/es/standards-sdk.es31.js +2 -2
- package/dist/es/standards-sdk.es32.js +4 -4
- package/dist/es/standards-sdk.es33.js +1 -1
- package/dist/es/standards-sdk.es36.js +8 -12
- package/dist/es/standards-sdk.es36.js.map +1 -1
- package/dist/es/standards-sdk.es37.js +4 -4
- package/dist/es/standards-sdk.es38.js +2 -2
- package/dist/es/standards-sdk.es39.js +2 -2
- package/dist/es/standards-sdk.es40.js +1 -1
- package/dist/es/standards-sdk.es41.js +1 -1
- package/dist/es/standards-sdk.es42.js +2 -2
- package/dist/es/standards-sdk.es47.js +1 -1
- package/dist/es/standards-sdk.es5.js +2 -2
- package/dist/es/standards-sdk.es52.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.es6.js +2 -2
- package/dist/es/standards-sdk.es61.js +7 -11
- package/dist/es/standards-sdk.es61.js.map +1 -1
- package/dist/es/standards-sdk.es65.js +2 -2
- package/dist/es/standards-sdk.es66.js +3 -3
- package/dist/es/standards-sdk.es69.js +2 -2
- package/dist/es/standards-sdk.es7.js +2 -2
- package/dist/es/standards-sdk.es70.js +3 -3
- package/dist/es/standards-sdk.es71.js +2 -2
- package/dist/es/standards-sdk.es72.js +1 -1
- package/dist/es/standards-sdk.es73.js.map +1 -1
- package/dist/es/standards-sdk.es75.js +2 -2
- package/dist/es/standards-sdk.es77.js +5 -3
- package/dist/es/standards-sdk.es77.js.map +1 -1
- package/dist/es/standards-sdk.es78.js +4 -10
- package/dist/es/standards-sdk.es78.js.map +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.es80.js +113 -29
- package/dist/es/standards-sdk.es80.js.map +1 -1
- package/dist/es/standards-sdk.es82.js +23 -4
- package/dist/es/standards-sdk.es82.js.map +1 -1
- package/dist/es/standards-sdk.es83.js +39 -14
- package/dist/es/standards-sdk.es83.js.map +1 -1
- package/dist/es/standards-sdk.es84.js +198 -17
- package/dist/es/standards-sdk.es84.js.map +1 -1
- package/dist/es/standards-sdk.es85.js +256 -9
- package/dist/es/standards-sdk.es85.js.map +1 -1
- package/dist/es/standards-sdk.es86.js +55 -21
- package/dist/es/standards-sdk.es86.js.map +1 -1
- package/dist/es/standards-sdk.es87.js +22 -75
- package/dist/es/standards-sdk.es87.js.map +1 -1
- package/dist/es/standards-sdk.es88.js +45 -30
- package/dist/es/standards-sdk.es88.js.map +1 -1
- package/dist/es/standards-sdk.es89.js +57 -22
- package/dist/es/standards-sdk.es89.js.map +1 -1
- package/dist/es/standards-sdk.es90.js +28 -23
- package/dist/es/standards-sdk.es90.js.map +1 -1
- package/dist/es/standards-sdk.es91.js +23 -167
- package/dist/es/standards-sdk.es91.js.map +1 -1
- package/dist/es/standards-sdk.es92.js +158 -119
- package/dist/es/standards-sdk.es92.js.map +1 -1
- package/dist/es/standards-sdk.es93.js +68 -95
- package/dist/es/standards-sdk.es93.js.map +1 -1
- package/dist/es/standards-sdk.es94.js +136 -119
- package/dist/es/standards-sdk.es94.js.map +1 -1
- package/dist/es/standards-sdk.es95.js +139 -39
- package/dist/es/standards-sdk.es95.js.map +1 -1
- package/dist/es/standards-sdk.es96.js +42 -257
- package/dist/es/standards-sdk.es96.js.map +1 -1
- package/dist/es/standards-sdk.es97.js +243 -80
- package/dist/es/standards-sdk.es97.js.map +1 -1
- package/dist/es/standards-sdk.es98.js +47 -48
- package/dist/es/standards-sdk.es98.js.map +1 -1
- package/dist/es/standards-sdk.es99.js +100 -28
- package/dist/es/standards-sdk.es99.js.map +1 -1
- package/dist/es/utils/dynamic-import.d.ts +1 -0
- package/dist/es/utils/dynamic-import.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -1,28 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import { HederaMirrorNode } from "./standards-sdk.es127.js";
|
|
2
|
+
import { Logger } from "./standards-sdk.es106.js";
|
|
3
|
+
class HCS15BaseClient {
|
|
4
|
+
constructor(config) {
|
|
5
|
+
this.network = config.network;
|
|
6
|
+
this.logger = config.logger || new Logger({
|
|
7
|
+
module: "HCS-15",
|
|
8
|
+
level: config.logLevel || "info"
|
|
9
|
+
});
|
|
10
|
+
this.mirrorNode = new HederaMirrorNode(this.network, this.logger, {
|
|
11
|
+
customUrl: config.mirrorNodeUrl
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Verify that a petal account shares the same public key as the base account.
|
|
16
|
+
*/
|
|
17
|
+
async verifyPetalAccount(petalAccountId, baseAccountId) {
|
|
18
|
+
try {
|
|
19
|
+
const petalInfo = await this.mirrorNode.requestAccount(petalAccountId);
|
|
20
|
+
const baseInfo = await this.mirrorNode.requestAccount(baseAccountId);
|
|
21
|
+
const petalKey = petalInfo?.key?.key || "";
|
|
22
|
+
const baseKey = baseInfo?.key?.key || "";
|
|
23
|
+
return petalKey !== "" && petalKey === baseKey;
|
|
24
|
+
} catch (e) {
|
|
25
|
+
this.logger.warn("verifyPetalAccount failed", { error: String(e) });
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
21
28
|
}
|
|
22
29
|
}
|
|
23
30
|
export {
|
|
24
|
-
|
|
25
|
-
FloraOperation,
|
|
26
|
-
FloraTopicType
|
|
31
|
+
HCS15BaseClient
|
|
27
32
|
};
|
|
28
33
|
//# sourceMappingURL=standards-sdk.es90.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-sdk.es90.js","sources":["../../src/hcs-
|
|
1
|
+
{"version":3,"file":"standards-sdk.es90.js","sources":["../../src/hcs-15/base-client.ts"],"sourcesContent":["import { HederaMirrorNode } from '../services/mirror-node';\nimport { Logger, ILogger } from '../utils/logger';\nimport { NetworkType } from '../utils/types';\n\n/**\n * Base client for HCS‑15 shared functionality across Node and Browser clients.\n */\nexport class HCS15BaseClient {\n protected readonly network: NetworkType;\n protected readonly mirrorNode: HederaMirrorNode;\n protected readonly logger: ILogger;\n\n constructor(config: {\n network: NetworkType;\n mirrorNodeUrl?: string;\n logger?: Logger;\n logLevel?: Parameters<Logger['setLogLevel']>[0];\n }) {\n this.network = config.network;\n this.logger =\n config.logger ||\n new Logger({\n module: 'HCS-15',\n level: (config.logLevel as any) || 'info',\n });\n this.mirrorNode = new HederaMirrorNode(this.network, this.logger, {\n customUrl: config.mirrorNodeUrl,\n });\n }\n\n /**\n * Verify that a petal account shares the same public key as the base account.\n */\n public async verifyPetalAccount(\n petalAccountId: string,\n baseAccountId: string,\n ): Promise<boolean> {\n try {\n const petalInfo = await this.mirrorNode.requestAccount(petalAccountId);\n const baseInfo = await this.mirrorNode.requestAccount(baseAccountId);\n const petalKey = petalInfo?.key?.key || '';\n const baseKey = baseInfo?.key?.key || '';\n return petalKey !== '' && petalKey === baseKey;\n } catch (e) {\n this.logger.warn('verifyPetalAccount failed', { error: String(e) });\n return false;\n }\n }\n}\n"],"names":[],"mappings":";;AAOO,MAAM,gBAAgB;AAAA,EAK3B,YAAY,QAKT;AACD,SAAK,UAAU,OAAO;AACtB,SAAK,SACH,OAAO,UACP,IAAI,OAAO;AAAA,MACT,QAAQ;AAAA,MACR,OAAQ,OAAO,YAAoB;AAAA,IAAA,CACpC;AACH,SAAK,aAAa,IAAI,iBAAiB,KAAK,SAAS,KAAK,QAAQ;AAAA,MAChE,WAAW,OAAO;AAAA,IAAA,CACnB;AAAA,EACH;AAAA;AAAA;AAAA;AAAA,EAKA,MAAa,mBACX,gBACA,eACkB;AAClB,QAAI;AACF,YAAM,YAAY,MAAM,KAAK,WAAW,eAAe,cAAc;AACrE,YAAM,WAAW,MAAM,KAAK,WAAW,eAAe,aAAa;AACnE,YAAM,WAAW,WAAW,KAAK,OAAO;AACxC,YAAM,UAAU,UAAU,KAAK,OAAO;AACtC,aAAO,aAAa,MAAM,aAAa;AAAA,IACzC,SAAS,GAAG;AACV,WAAK,OAAO,KAAK,6BAA6B,EAAE,OAAO,OAAO,CAAC,GAAG;AAClE,aAAO;AAAA,IACT;AAAA,EACF;AACF;"}
|
|
@@ -1,172 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return tx;
|
|
22
|
-
}
|
|
23
|
-
function buildHcs16CreateTransactionTopicTx(params) {
|
|
24
|
-
const tx = new TopicCreateTransaction().setTopicMemo(params.memo);
|
|
25
|
-
if (params.adminKey) {
|
|
26
|
-
tx.setAdminKey(params.adminKey);
|
|
27
|
-
}
|
|
28
|
-
if (params.submitKey) {
|
|
29
|
-
tx.setSubmitKey(params.submitKey);
|
|
30
|
-
}
|
|
31
|
-
if (params.feeScheduleKey) {
|
|
32
|
-
tx.setFeeScheduleKey(params.feeScheduleKey);
|
|
33
|
-
}
|
|
34
|
-
if (params.customFees && params.customFees.length > 0) {
|
|
35
|
-
const fees = params.customFees.map((fee) => {
|
|
36
|
-
const cf = new CustomFixedFee().setAmount(fee.amount).setFeeCollectorAccountId(
|
|
37
|
-
AccountId.fromString(fee.feeCollectorAccountId)
|
|
38
|
-
);
|
|
39
|
-
if (fee.denominatingTokenId) {
|
|
40
|
-
cf.setDenominatingTokenId(TokenId.fromString(fee.denominatingTokenId));
|
|
41
|
-
}
|
|
42
|
-
return cf;
|
|
43
|
-
});
|
|
44
|
-
tx.setCustomFees(fees);
|
|
1
|
+
var FloraTopicType = /* @__PURE__ */ ((FloraTopicType2) => {
|
|
2
|
+
FloraTopicType2[FloraTopicType2["COMMUNICATION"] = 0] = "COMMUNICATION";
|
|
3
|
+
FloraTopicType2[FloraTopicType2["TRANSACTION"] = 1] = "TRANSACTION";
|
|
4
|
+
FloraTopicType2[FloraTopicType2["STATE"] = 2] = "STATE";
|
|
5
|
+
return FloraTopicType2;
|
|
6
|
+
})(FloraTopicType || {});
|
|
7
|
+
var FloraOperation = /* @__PURE__ */ ((FloraOperation2) => {
|
|
8
|
+
FloraOperation2["FLORA_CREATED"] = "flora_created";
|
|
9
|
+
FloraOperation2["TRANSACTION"] = "transaction";
|
|
10
|
+
FloraOperation2["STATE_UPDATE"] = "state_update";
|
|
11
|
+
FloraOperation2["FLORA_JOIN_REQUEST"] = "flora_join_request";
|
|
12
|
+
FloraOperation2["FLORA_JOIN_VOTE"] = "flora_join_vote";
|
|
13
|
+
FloraOperation2["FLORA_JOIN_ACCEPTED"] = "flora_join_accepted";
|
|
14
|
+
return FloraOperation2;
|
|
15
|
+
})(FloraOperation || {});
|
|
16
|
+
class FloraError extends Error {
|
|
17
|
+
constructor(message, code) {
|
|
18
|
+
super(message);
|
|
19
|
+
this.code = code;
|
|
20
|
+
this.name = "FloraError";
|
|
45
21
|
}
|
|
46
|
-
if (params.feeExemptKeys && params.feeExemptKeys.length > 0) {
|
|
47
|
-
throw new Error("feeExemptKeys not supported by installed @hashgraph/sdk");
|
|
48
|
-
}
|
|
49
|
-
return tx;
|
|
50
|
-
}
|
|
51
|
-
function buildHcs16CreateAccountTx(params) {
|
|
52
|
-
const tx = new AccountCreateTransaction().setKey(params.keyList);
|
|
53
|
-
const initial = typeof params.initialBalanceHbar === "number" ? params.initialBalanceHbar : 1;
|
|
54
|
-
tx.setInitialBalance(new Hbar(initial));
|
|
55
|
-
const maxAssoc = typeof params.maxAutomaticTokenAssociations === "number" ? params.maxAutomaticTokenAssociations : -1;
|
|
56
|
-
tx.setMaxAutomaticTokenAssociations(maxAssoc);
|
|
57
|
-
return tx;
|
|
58
|
-
}
|
|
59
|
-
function buildHcs16ScheduleAccountKeyUpdateTx(params) {
|
|
60
|
-
const inner = new AccountUpdateTransaction().setAccountId(AccountId.fromString(params.floraAccountId)).setKey(params.newKeyList);
|
|
61
|
-
if (params.memo) {
|
|
62
|
-
inner.setTransactionMemo(params.memo);
|
|
63
|
-
}
|
|
64
|
-
return new ScheduleCreateTransaction().setScheduledTransaction(inner);
|
|
65
|
-
}
|
|
66
|
-
function buildHcs16ScheduleTopicKeyUpdateTx(params) {
|
|
67
|
-
const inner = new TopicUpdateTransaction().setTopicId(params.topicId);
|
|
68
|
-
if (params.adminKey) {
|
|
69
|
-
inner.setAdminKey(params.adminKey);
|
|
70
|
-
}
|
|
71
|
-
if (params.submitKey) {
|
|
72
|
-
inner.setSubmitKey(params.submitKey);
|
|
73
|
-
}
|
|
74
|
-
if (params.memo) {
|
|
75
|
-
inner.setTransactionMemo(params.memo);
|
|
76
|
-
}
|
|
77
|
-
return new ScheduleCreateTransaction().setScheduledTransaction(inner);
|
|
78
|
-
}
|
|
79
|
-
function buildHcs16MessageTx(params) {
|
|
80
|
-
const payload = {
|
|
81
|
-
p: "hcs-16",
|
|
82
|
-
op: params.op,
|
|
83
|
-
operator_id: params.operatorId,
|
|
84
|
-
...params.body || {}
|
|
85
|
-
};
|
|
86
|
-
return buildMessageTx({
|
|
87
|
-
topicId: params.topicId,
|
|
88
|
-
message: JSON.stringify(payload)
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
function buildHcs16FloraCreatedTx(params) {
|
|
92
|
-
return buildHcs16MessageTx({
|
|
93
|
-
topicId: params.topicId,
|
|
94
|
-
operatorId: params.operatorId,
|
|
95
|
-
op: FloraOperation.FLORA_CREATED,
|
|
96
|
-
body: {
|
|
97
|
-
flora_account_id: params.floraAccountId,
|
|
98
|
-
topics: params.topics
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
function buildHcs16TransactionTx(params) {
|
|
103
|
-
return buildHcs16MessageTx({
|
|
104
|
-
topicId: params.topicId,
|
|
105
|
-
operatorId: params.operatorId,
|
|
106
|
-
op: FloraOperation.TRANSACTION,
|
|
107
|
-
body: {
|
|
108
|
-
schedule_id: params.scheduleId,
|
|
109
|
-
data: params.data,
|
|
110
|
-
m: params.data
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
function buildHcs16StateUpdateTx(params) {
|
|
115
|
-
return buildHcs16MessageTx({
|
|
116
|
-
topicId: params.topicId,
|
|
117
|
-
operatorId: params.operatorId,
|
|
118
|
-
op: FloraOperation.STATE_UPDATE,
|
|
119
|
-
body: {
|
|
120
|
-
hash: params.hash,
|
|
121
|
-
epoch: params.epoch,
|
|
122
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
function buildHcs16FloraJoinRequestTx(params) {
|
|
127
|
-
return buildHcs16MessageTx({
|
|
128
|
-
topicId: params.topicId,
|
|
129
|
-
operatorId: params.operatorId,
|
|
130
|
-
op: FloraOperation.FLORA_JOIN_REQUEST,
|
|
131
|
-
body: {
|
|
132
|
-
candidate_account_id: params.candidateAccountId
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
function buildHcs16FloraJoinVoteTx(params) {
|
|
137
|
-
return buildHcs16MessageTx({
|
|
138
|
-
topicId: params.topicId,
|
|
139
|
-
operatorId: params.operatorId,
|
|
140
|
-
op: FloraOperation.FLORA_JOIN_VOTE,
|
|
141
|
-
body: {
|
|
142
|
-
candidate_account_id: params.candidateAccountId,
|
|
143
|
-
approve: params.approve
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
function buildHcs16FloraJoinAcceptedTx(params) {
|
|
148
|
-
return buildHcs16MessageTx({
|
|
149
|
-
topicId: params.topicId,
|
|
150
|
-
operatorId: params.operatorId,
|
|
151
|
-
op: FloraOperation.FLORA_JOIN_ACCEPTED,
|
|
152
|
-
body: {
|
|
153
|
-
members: params.members,
|
|
154
|
-
epoch: params.epoch
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
22
|
}
|
|
158
23
|
export {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
buildHcs16FloraCreatedTx,
|
|
163
|
-
buildHcs16FloraJoinAcceptedTx,
|
|
164
|
-
buildHcs16FloraJoinRequestTx,
|
|
165
|
-
buildHcs16FloraJoinVoteTx,
|
|
166
|
-
buildHcs16MessageTx,
|
|
167
|
-
buildHcs16ScheduleAccountKeyUpdateTx,
|
|
168
|
-
buildHcs16ScheduleTopicKeyUpdateTx,
|
|
169
|
-
buildHcs16StateUpdateTx,
|
|
170
|
-
buildHcs16TransactionTx
|
|
24
|
+
FloraError,
|
|
25
|
+
FloraOperation,
|
|
26
|
+
FloraTopicType
|
|
171
27
|
};
|
|
172
28
|
//# sourceMappingURL=standards-sdk.es91.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-sdk.es91.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\nfunction encodeHcs16FloraMemo(params: {\n floraAccountId: string;\n topicType: FloraTopicType;\n}): string {\n return `hcs-16:${params.floraAccountId}:${params.topicType}`;\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}): 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 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}): 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 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}): ScheduleCreateTransaction {\n const inner = new AccountUpdateTransaction()\n .setAccountId(AccountId.fromString(params.floraAccountId))\n .setKey(params.newKeyList);\n if (params.memo) {\n inner.setTransactionMemo(params.memo);\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}): 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 if (params.memo) {\n inner.setTransactionMemo(params.memo);\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}): 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 });\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‑16 state_update message.\n */\nexport function buildHcs16StateUpdateTx(params: {\n topicId: string;\n operatorId: string;\n hash: string;\n epoch?: number;\n}): TopicMessageSubmitTransaction {\n return buildHcs16MessageTx({\n topicId: params.topicId,\n operatorId: params.operatorId,\n op: FloraOperation.STATE_UPDATE,\n body: {\n hash: params.hash,\n epoch: params.epoch,\n timestamp: new Date().toISOString(),\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 candidateAccountId: string;\n}): TopicMessageSubmitTransaction {\n return buildHcs16MessageTx({\n topicId: params.topicId,\n operatorId: params.operatorId,\n op: FloraOperation.FLORA_JOIN_REQUEST,\n body: {\n candidate_account_id: params.candidateAccountId,\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 candidateAccountId: string;\n approve: boolean;\n}): TopicMessageSubmitTransaction {\n return buildHcs16MessageTx({\n topicId: params.topicId,\n operatorId: params.operatorId,\n op: FloraOperation.FLORA_JOIN_VOTE,\n body: {\n candidate_account_id: params.candidateAccountId,\n approve: params.approve,\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":"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"}
|
|
1
|
+
{"version":3,"file":"standards-sdk.es91.js","sources":["../../src/hcs-16/types.ts"],"sourcesContent":["import {\n AccountId,\n TopicId,\n PublicKey,\n Key,\n PrivateKey,\n KeyList,\n TokenId,\n} from '@hashgraph/sdk';\nimport { BaseProfile, SocialLink } from '../hcs-11/types';\n\n/**\n * HCS-16 Topic type enums\n */\nexport enum FloraTopicType {\n COMMUNICATION = 0,\n TRANSACTION = 1,\n STATE = 2,\n}\n\n/**\n * HCS-16 Flora member\n */\nexport interface FloraMember {\n accountId: string;\n publicKey?: PublicKey | string;\n privateKey?: string;\n weight?: number;\n}\n\n/**\n * HCS-16 Flora topics\n */\nexport interface FloraTopics {\n communication: TopicId;\n transaction: TopicId;\n state: TopicId;\n custom?: Array<{\n name: string;\n topicId: string;\n description?: string;\n }>;\n}\n\n/**\n * HCS-16 Flora configuration\n */\nexport interface FloraConfig {\n displayName: string;\n bio?: string;\n members: FloraMember[];\n threshold: number;\n initialBalance?: number;\n maxAutomaticTokenAssociations?: number;\n policies?: {\n membershipChange?: string;\n scheduleTxApproval?: string;\n };\n customFees?: {\n amount: number;\n feeCollectorAccountId: string;\n }[];\n metadata?: Record<string, any>;\n}\n\n/**\n * HCS-16 Flora creation result\n */\nexport interface FloraCreationResult {\n floraAccountId: AccountId;\n topics: FloraTopics;\n keyList: Key;\n transactionId: string;\n}\n\n/**\n * HCS-16 Message protocol operations\n */\nexport enum FloraOperation {\n FLORA_CREATED = 'flora_created',\n TRANSACTION = 'transaction',\n STATE_UPDATE = 'state_update',\n FLORA_JOIN_REQUEST = 'flora_join_request',\n FLORA_JOIN_VOTE = 'flora_join_vote',\n FLORA_JOIN_ACCEPTED = 'flora_join_accepted',\n}\n\n/**\n * HCS-16 Message envelope\n */\nexport interface FloraMessage {\n p: 'hcs-16';\n op: FloraOperation;\n operator_id: string;\n m?: string;\n [key: string]: unknown;\n}\n\n/**\n * HCS-16 Flora profile (extends HCS-11)\n */\nexport interface FloraProfile extends BaseProfile {\n version: string;\n type: 3;\n display_name: string;\n members: FloraMember[];\n threshold: number;\n topics: {\n communication: string;\n transaction: string;\n state: string;\n custom?: Array<{\n name: string;\n topicId: string;\n description?: string;\n }>;\n };\n alias?: string;\n bio?: string;\n socials?: SocialLink[];\n profileImage?: string;\n properties?: Record<string, unknown>;\n inboundTopicId: string;\n outboundTopicId: string;\n policies?: Record<string, string>;\n metadata?: Record<string, any>;\n}\n\n/**\n * HCS-16 errors\n */\nexport class FloraError extends Error {\n constructor(\n message: string,\n public readonly code: string,\n ) {\n super(message);\n this.name = 'FloraError';\n }\n}\n\n/**\n * Flora state update message\n */\nexport interface FloraStateUpdate {\n p: 'hcs-16';\n op: 'state_update';\n operator_id: string;\n hash: string;\n epoch?: number;\n members?: string[];\n timestamp: string;\n}\n\n/**\n * HIP-991 Custom fee configuration for transaction topics\n */\nexport interface TransactionTopicFee {\n amount: number;\n feeCollectorAccountId: string;\n denominatingTokenId?: string;\n}\n\n/**\n * Configuration for creating HCS-16 transaction topics with HIP-991 support\n */\nexport interface TransactionTopicConfig {\n memo: string;\n adminKey?: PrivateKey | KeyList;\n submitKey?: PrivateKey | KeyList;\n feeScheduleKey?: PrivateKey | KeyList;\n customFees?: TransactionTopicFee[];\n feeExemptKeys?: Key[];\n}\n\n/** credit_purchase not part of HCS-16 specification; no message type defined. */\n"],"names":["FloraTopicType","FloraOperation"],"mappings":"AAcO,IAAK,mCAAAA,oBAAL;AACLA,kBAAAA,gBAAA,mBAAgB,CAAA,IAAhB;AACAA,kBAAAA,gBAAA,iBAAc,CAAA,IAAd;AACAA,kBAAAA,gBAAA,WAAQ,CAAA,IAAR;AAHU,SAAAA;AAAA,GAAA,kBAAA,CAAA,CAAA;AAgEL,IAAK,mCAAAC,oBAAL;AACLA,kBAAA,eAAA,IAAgB;AAChBA,kBAAA,aAAA,IAAc;AACdA,kBAAA,cAAA,IAAe;AACfA,kBAAA,oBAAA,IAAqB;AACrBA,kBAAA,iBAAA,IAAkB;AAClBA,kBAAA,qBAAA,IAAsB;AANZ,SAAAA;AAAA,GAAA,kBAAA,CAAA,CAAA;AAqDL,MAAM,mBAAmB,MAAM;AAAA,EACpC,YACE,SACgB,MAChB;AACA,UAAM,OAAO;AAFG,SAAA,OAAA;AAGhB,SAAK,OAAO;AAAA,EACd;AACF;"}
|
|
@@ -1,133 +1,172 @@
|
|
|
1
|
-
import { AccountId,
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import { AccountId, TopicCreateTransaction, CustomFixedFee, TokenId, AccountCreateTransaction, Hbar, AccountUpdateTransaction, ScheduleCreateTransaction, TopicUpdateTransaction } from "@hashgraph/sdk";
|
|
2
|
+
import { buildTopicCreateTx, buildMessageTx } from "./standards-sdk.es137.js";
|
|
3
|
+
import { FloraOperation } from "./standards-sdk.es91.js";
|
|
4
|
+
function encodeHcs16FloraMemo(params) {
|
|
5
|
+
return `hcs-16:${params.floraAccountId}:${params.topicType}`;
|
|
6
|
+
}
|
|
7
|
+
function buildHcs16CreateFloraTopicTx(params) {
|
|
8
|
+
const memo = encodeHcs16FloraMemo({
|
|
9
|
+
floraAccountId: params.floraAccountId,
|
|
10
|
+
topicType: params.topicType
|
|
11
|
+
});
|
|
12
|
+
const tx = buildTopicCreateTx({
|
|
13
|
+
memo,
|
|
14
|
+
adminKey: params.adminKey,
|
|
15
|
+
submitKey: params.submitKey,
|
|
16
|
+
operatorPublicKey: params.operatorPublicKey
|
|
17
|
+
});
|
|
18
|
+
if (params.autoRenewAccountId) {
|
|
19
|
+
tx.setAutoRenewAccountId(AccountId.fromString(params.autoRenewAccountId));
|
|
20
|
+
}
|
|
21
|
+
return tx;
|
|
22
|
+
}
|
|
23
|
+
function buildHcs16CreateTransactionTopicTx(params) {
|
|
24
|
+
const tx = new TopicCreateTransaction().setTopicMemo(params.memo);
|
|
25
|
+
if (params.adminKey) {
|
|
26
|
+
tx.setAdminKey(params.adminKey);
|
|
21
27
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
if (params.submitKey) {
|
|
29
|
+
tx.setSubmitKey(params.submitKey);
|
|
30
|
+
}
|
|
31
|
+
if (params.feeScheduleKey) {
|
|
32
|
+
tx.setFeeScheduleKey(params.feeScheduleKey);
|
|
33
|
+
}
|
|
34
|
+
if (params.customFees && params.customFees.length > 0) {
|
|
35
|
+
const fees = params.customFees.map((fee) => {
|
|
36
|
+
const cf = new CustomFixedFee().setAmount(fee.amount).setFeeCollectorAccountId(
|
|
37
|
+
AccountId.fromString(fee.feeCollectorAccountId)
|
|
38
|
+
);
|
|
39
|
+
if (fee.denominatingTokenId) {
|
|
40
|
+
cf.setDenominatingTokenId(TokenId.fromString(fee.denominatingTokenId));
|
|
41
|
+
}
|
|
42
|
+
return cf;
|
|
33
43
|
});
|
|
34
|
-
|
|
35
|
-
const receipt = await resp.getReceipt(this.client);
|
|
36
|
-
if (!receipt.topicId) {
|
|
37
|
-
throw new Error("Failed to create Flora topic");
|
|
38
|
-
}
|
|
39
|
-
return receipt.topicId.toString();
|
|
44
|
+
tx.setCustomFees(fees);
|
|
40
45
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const resp = await tx.execute(this.client);
|
|
44
|
-
return resp.getReceipt(this.client);
|
|
46
|
+
if (params.feeExemptKeys && params.feeExemptKeys.length > 0) {
|
|
47
|
+
throw new Error("feeExemptKeys not supported by installed @hashgraph/sdk");
|
|
45
48
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
return tx;
|
|
50
|
+
}
|
|
51
|
+
function buildHcs16CreateAccountTx(params) {
|
|
52
|
+
const tx = new AccountCreateTransaction().setKey(params.keyList);
|
|
53
|
+
const initial = typeof params.initialBalanceHbar === "number" ? params.initialBalanceHbar : 1;
|
|
54
|
+
tx.setInitialBalance(new Hbar(initial));
|
|
55
|
+
const maxAssoc = typeof params.maxAutomaticTokenAssociations === "number" ? params.maxAutomaticTokenAssociations : -1;
|
|
56
|
+
tx.setMaxAutomaticTokenAssociations(maxAssoc);
|
|
57
|
+
return tx;
|
|
58
|
+
}
|
|
59
|
+
function buildHcs16ScheduleAccountKeyUpdateTx(params) {
|
|
60
|
+
const inner = new AccountUpdateTransaction().setAccountId(AccountId.fromString(params.floraAccountId)).setKey(params.newKeyList);
|
|
61
|
+
if (params.memo) {
|
|
62
|
+
inner.setTransactionMemo(params.memo);
|
|
53
63
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const signed = await tx.sign(params.signerKey);
|
|
61
|
-
const resp = await signed.execute(this.client);
|
|
62
|
-
return resp.getReceipt(this.client);
|
|
64
|
+
return new ScheduleCreateTransaction().setScheduledTransaction(inner);
|
|
65
|
+
}
|
|
66
|
+
function buildHcs16ScheduleTopicKeyUpdateTx(params) {
|
|
67
|
+
const inner = new TopicUpdateTransaction().setTopicId(params.topicId);
|
|
68
|
+
if (params.adminKey) {
|
|
69
|
+
inner.setAdminKey(params.adminKey);
|
|
63
70
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const resp = await tx.execute(this.client);
|
|
67
|
-
return resp.getReceipt(this.client);
|
|
71
|
+
if (params.submitKey) {
|
|
72
|
+
inner.setSubmitKey(params.submitKey);
|
|
68
73
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
*/
|
|
72
|
-
async assembleKeyList(params) {
|
|
73
|
-
return super.assembleKeyList(params);
|
|
74
|
+
if (params.memo) {
|
|
75
|
+
inner.setTransactionMemo(params.memo);
|
|
74
76
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
return new ScheduleCreateTransaction().setScheduledTransaction(inner);
|
|
78
|
+
}
|
|
79
|
+
function buildHcs16MessageTx(params) {
|
|
80
|
+
const payload = {
|
|
81
|
+
p: "hcs-16",
|
|
82
|
+
op: params.op,
|
|
83
|
+
operator_id: params.operatorId,
|
|
84
|
+
...params.body || {}
|
|
85
|
+
};
|
|
86
|
+
return buildMessageTx({
|
|
87
|
+
topicId: params.topicId,
|
|
88
|
+
message: JSON.stringify(payload)
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function buildHcs16FloraCreatedTx(params) {
|
|
92
|
+
return buildHcs16MessageTx({
|
|
93
|
+
topicId: params.topicId,
|
|
94
|
+
operatorId: params.operatorId,
|
|
95
|
+
op: FloraOperation.FLORA_CREATED,
|
|
96
|
+
body: {
|
|
97
|
+
flora_account_id: params.floraAccountId,
|
|
98
|
+
topics: params.topics
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
function buildHcs16TransactionTx(params) {
|
|
103
|
+
return buildHcs16MessageTx({
|
|
104
|
+
topicId: params.topicId,
|
|
105
|
+
operatorId: params.operatorId,
|
|
106
|
+
op: FloraOperation.TRANSACTION,
|
|
107
|
+
body: {
|
|
108
|
+
schedule_id: params.scheduleId,
|
|
109
|
+
data: params.data,
|
|
110
|
+
m: params.data
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
function buildHcs16StateUpdateTx(params) {
|
|
115
|
+
return buildHcs16MessageTx({
|
|
116
|
+
topicId: params.topicId,
|
|
117
|
+
operatorId: params.operatorId,
|
|
118
|
+
op: FloraOperation.STATE_UPDATE,
|
|
119
|
+
body: {
|
|
120
|
+
hash: params.hash,
|
|
121
|
+
epoch: params.epoch,
|
|
122
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
function buildHcs16FloraJoinRequestTx(params) {
|
|
127
|
+
return buildHcs16MessageTx({
|
|
128
|
+
topicId: params.topicId,
|
|
129
|
+
operatorId: params.operatorId,
|
|
130
|
+
op: FloraOperation.FLORA_JOIN_REQUEST,
|
|
131
|
+
body: {
|
|
132
|
+
candidate_account_id: params.candidateAccountId
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
function buildHcs16FloraJoinVoteTx(params) {
|
|
137
|
+
return buildHcs16MessageTx({
|
|
138
|
+
topicId: params.topicId,
|
|
139
|
+
operatorId: params.operatorId,
|
|
140
|
+
op: FloraOperation.FLORA_JOIN_VOTE,
|
|
141
|
+
body: {
|
|
142
|
+
candidate_account_id: params.candidateAccountId,
|
|
143
|
+
approve: params.approve
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
function buildHcs16FloraJoinAcceptedTx(params) {
|
|
148
|
+
return buildHcs16MessageTx({
|
|
149
|
+
topicId: params.topicId,
|
|
150
|
+
operatorId: params.operatorId,
|
|
151
|
+
op: FloraOperation.FLORA_JOIN_ACCEPTED,
|
|
152
|
+
body: {
|
|
81
153
|
members: params.members,
|
|
82
|
-
|
|
83
|
-
});
|
|
84
|
-
const submitList = await this.assembleSubmitKeyList(params.members);
|
|
85
|
-
const createAcc = buildHcs16CreateAccountTx({
|
|
86
|
-
keyList,
|
|
87
|
-
initialBalanceHbar: typeof params.initialBalanceHbar === "number" ? params.initialBalanceHbar : 5,
|
|
88
|
-
maxAutomaticTokenAssociations: -1
|
|
89
|
-
});
|
|
90
|
-
const accResp = await createAcc.execute(this.client);
|
|
91
|
-
const accReceipt = await accResp.getReceipt(this.client);
|
|
92
|
-
if (!accReceipt.accountId) {
|
|
93
|
-
throw new Error("Failed to create Flora account");
|
|
154
|
+
epoch: params.epoch
|
|
94
155
|
}
|
|
95
|
-
|
|
96
|
-
const {
|
|
97
|
-
communication: commTx,
|
|
98
|
-
transaction: trnTx,
|
|
99
|
-
state: stateTx
|
|
100
|
-
} = this.buildFloraTopicCreateTxs({
|
|
101
|
-
floraAccountId,
|
|
102
|
-
keyList,
|
|
103
|
-
submitList,
|
|
104
|
-
autoRenewAccountId: params.autoRenewAccountId
|
|
105
|
-
});
|
|
106
|
-
const commR = await commTx.execute(this.client).then((r) => r.getReceipt(this.client));
|
|
107
|
-
const trnR = await trnTx.execute(this.client).then((r) => r.getReceipt(this.client));
|
|
108
|
-
const stateR = await stateTx.execute(this.client).then((r) => r.getReceipt(this.client));
|
|
109
|
-
const topics = {
|
|
110
|
-
communication: commR.topicId.toString(),
|
|
111
|
-
transaction: trnR.topicId.toString(),
|
|
112
|
-
state: stateR.topicId.toString()
|
|
113
|
-
};
|
|
114
|
-
return { floraAccountId, topics };
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Convenience: publish flora_created on the communication topic.
|
|
118
|
-
*/
|
|
119
|
-
async publishFloraCreated(params) {
|
|
120
|
-
const tx = buildHcs16FloraCreatedTx({
|
|
121
|
-
topicId: params.communicationTopicId,
|
|
122
|
-
operatorId: params.operatorId,
|
|
123
|
-
floraAccountId: params.floraAccountId,
|
|
124
|
-
topics: params.topics
|
|
125
|
-
});
|
|
126
|
-
const resp = await tx.execute(this.client);
|
|
127
|
-
return resp.getReceipt(this.client);
|
|
128
|
-
}
|
|
156
|
+
});
|
|
129
157
|
}
|
|
130
158
|
export {
|
|
131
|
-
|
|
159
|
+
buildHcs16CreateAccountTx,
|
|
160
|
+
buildHcs16CreateFloraTopicTx,
|
|
161
|
+
buildHcs16CreateTransactionTopicTx,
|
|
162
|
+
buildHcs16FloraCreatedTx,
|
|
163
|
+
buildHcs16FloraJoinAcceptedTx,
|
|
164
|
+
buildHcs16FloraJoinRequestTx,
|
|
165
|
+
buildHcs16FloraJoinVoteTx,
|
|
166
|
+
buildHcs16MessageTx,
|
|
167
|
+
buildHcs16ScheduleAccountKeyUpdateTx,
|
|
168
|
+
buildHcs16ScheduleTopicKeyUpdateTx,
|
|
169
|
+
buildHcs16StateUpdateTx,
|
|
170
|
+
buildHcs16TransactionTx
|
|
132
171
|
};
|
|
133
172
|
//# sourceMappingURL=standards-sdk.es92.js.map
|