@hashgraphonline/standards-sdk 0.0.15 → 0.0.17

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.
@@ -1 +1,3 @@
1
1
  export * from './logger';
2
+ export * from './mirror-node-utils';
3
+ export * from './topic-fee-utils';
@@ -0,0 +1,146 @@
1
+ import { PublicKey } from '@hashgraph/sdk';
2
+ import { Logger } from './logger';
3
+ import { HCSMessage } from '../hcs-10/base-client';
4
+ export interface Balance {
5
+ balance: number;
6
+ timestamp: string;
7
+ tokens: TokenBalance[];
8
+ }
9
+ export interface TokenBalance {
10
+ token_id: string;
11
+ balance: number;
12
+ }
13
+ export interface Key {
14
+ _type: string;
15
+ key: string;
16
+ }
17
+ export interface AccountResponse {
18
+ account: string;
19
+ alias: string;
20
+ auto_renew_period: number;
21
+ balance: Balance;
22
+ created_timestamp: string;
23
+ decline_reward: boolean;
24
+ deleted: boolean;
25
+ ethereum_nonce: number;
26
+ evm_address: string;
27
+ expiry_timestamp: string;
28
+ key: Key;
29
+ max_automatic_token_associations: number;
30
+ memo: string;
31
+ pending_reward: number;
32
+ receiver_sig_required: boolean;
33
+ staked_account_id: string | null;
34
+ staked_node_id: string | null;
35
+ stake_period_start: string | null;
36
+ transactions: Transaction[];
37
+ links: Links;
38
+ }
39
+ export interface Transaction {
40
+ bytes: string | null;
41
+ charged_tx_fee: number;
42
+ consensus_timestamp: string;
43
+ entity_id: string | null;
44
+ max_fee: string;
45
+ memo_base64: string;
46
+ name: string;
47
+ nft_transfers: NftTransfer[];
48
+ node: string;
49
+ nonce: number;
50
+ parent_consensus_timestamp: string | null;
51
+ result: string;
52
+ scheduled: boolean;
53
+ staking_reward_transfers: Transfer[];
54
+ token_transfers: TokenTransfer[];
55
+ transaction_hash: string;
56
+ transaction_id: string;
57
+ transfers: Transfer[];
58
+ valid_duration_seconds: string;
59
+ valid_start_timestamp: string;
60
+ }
61
+ export interface Transfer {
62
+ account: string;
63
+ amount: number;
64
+ is_approval: boolean;
65
+ }
66
+ export interface TokenTransfer {
67
+ token_id: string;
68
+ account: string;
69
+ amount: string;
70
+ is_approval: boolean;
71
+ }
72
+ export interface NftTransfer {
73
+ receiver_account_id: string;
74
+ sender_account_id: string;
75
+ serial_number: number;
76
+ is_approval: boolean;
77
+ }
78
+ export interface Links {
79
+ next: string;
80
+ }
81
+ export type NetworkType = 'mainnet' | 'testnet';
82
+ export interface TopicInfo {
83
+ inboundTopic: string;
84
+ outboundTopic: string;
85
+ }
86
+ export interface TopicMessage {
87
+ consensus_timestamp: string;
88
+ topic_id: string;
89
+ message: string;
90
+ sequence_number: number;
91
+ running_hash: string;
92
+ running_hash_version: number;
93
+ payer_account_id: string;
94
+ }
95
+ export interface TopicMessagesResponse {
96
+ messages: TopicMessage[];
97
+ links: {
98
+ next?: string;
99
+ };
100
+ }
101
+ export interface TopicResponse {
102
+ admin_key: AdminKey;
103
+ auto_renew_account: string;
104
+ auto_renew_period: number;
105
+ created_timestamp: string;
106
+ custom_fees: CustomFees;
107
+ deleted: boolean;
108
+ fee_exempt_key_list: AdminKey[];
109
+ fee_schedule_key: AdminKey;
110
+ memo: string;
111
+ submit_key: AdminKey;
112
+ timestamp: Timestamp;
113
+ topic_id: string;
114
+ }
115
+ export interface AdminKey {
116
+ _type: string;
117
+ key: string;
118
+ }
119
+ export interface CustomFees {
120
+ created_timestamp: string;
121
+ fixed_fees: FixedFee[];
122
+ }
123
+ export interface FixedFee {
124
+ amount: number;
125
+ collector_account_id: string;
126
+ denominating_token_id: string;
127
+ }
128
+ export interface Timestamp {
129
+ from: string;
130
+ to: string;
131
+ }
132
+ export declare class HederaMirrorNode {
133
+ private network;
134
+ private baseUrl;
135
+ private logger?;
136
+ constructor(network: NetworkType, logger?: Logger);
137
+ private getMirrorNodeUrl;
138
+ getBaseUrl(): string;
139
+ getPublicKey(accountId: string): Promise<PublicKey>;
140
+ getAccountMemo(accountId: string): Promise<string | null>;
141
+ getTopicInfo(topicId: string): Promise<TopicResponse>;
142
+ getTopicFees(topicId: string): Promise<CustomFees | null>;
143
+ getTopicMessages(topicId: string): Promise<HCSMessage[]>;
144
+ requestAccount(accountId: string): Promise<AccountResponse>;
145
+ getAccountInfo(accountId: string): Promise<AccountResponse>;
146
+ }
@@ -0,0 +1,11 @@
1
+ import { PublicKey } from '@hashgraph/sdk';
2
+ import { Logger } from './logger';
3
+ /**
4
+ * Converts account IDs to public keys for fee exemption
5
+ * @param client Hedera client instance
6
+ * @param accountIds Array of account IDs to convert to public keys
7
+ * @param network The network to use for retrieving public keys
8
+ * @param logger Optional logger instance
9
+ * @returns Array of public keys
10
+ */
11
+ export declare function accountIdsToExemptKeys(accountIds: string[], network: string, logger?: Logger): Promise<PublicKey[]>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hashgraphonline/standards-sdk",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "description": "HCS Standards SDK",
5
5
  "type": "module",
6
6
  "files": [
@@ -36,6 +36,7 @@
36
36
  "@types/mime-types": "^2.1.4",
37
37
  "@types/node": "^22.2.0",
38
38
  "rimraf": "^6.0.1",
39
+ "terser": "^5.37.0",
39
40
  "typescript": "^5.5.4",
40
41
  "vite": "^5.4.0",
41
42
  "vite-plugin-dts": "^4.0.2"
@@ -43,7 +44,7 @@
43
44
  "dependencies": {
44
45
  "@google/model-viewer": "^4.0.0",
45
46
  "@hashgraph/hedera-wallet-connect": "^1.5.0",
46
- "@hashgraph/sdk": "^2.56.0",
47
+ "@hashgraph/sdk": "2.61.0-beta.2",
47
48
  "@hashgraphonline/hashinal-wc": "^1.0.96",
48
49
  "@kiloscribe/inscription-sdk": "^1.0.24",
49
50
  "dotenv": "^16.4.7",
@@ -56,5 +57,6 @@
56
57
  "tsx": "^4.19.3",
57
58
  "vite-plugin-node-polyfills": "^0.23.0",
58
59
  "zod": "^3.24.2"
59
- }
60
+ },
61
+ "packageManager": "yarn@3.6.1+sha512.de524adec81a6c3d7a26d936d439d2832e351cdfc5728f9d91f3fc85dd20b04391c038e9b4ecab11cae2b0dd9f0d55fd355af766bc5c1a7f8d25d96bb2a0b2ca"
60
62
  }
@@ -1,150 +0,0 @@
1
- import { Logger, LogLevel } from '../utils/logger';
2
- import { Registration } from './registrations';
3
- export interface AccountResponse {
4
- account: string;
5
- alias: string;
6
- auto_renew_period: number;
7
- balance: Balance;
8
- created_timestamp: string;
9
- decline_reward: boolean;
10
- deleted: boolean;
11
- ethereum_nonce: number;
12
- evm_address: string;
13
- expiry_timestamp: string;
14
- key: Key;
15
- max_automatic_token_associations: number;
16
- memo: string;
17
- pending_reward: number;
18
- receiver_sig_required: boolean;
19
- staked_account_id: string | null;
20
- staked_node_id: string | null;
21
- stake_period_start: string | null;
22
- transactions: Transaction[];
23
- links: Links;
24
- }
25
- export interface Balance {
26
- balance: number;
27
- timestamp: string;
28
- tokens: TokenBalance[];
29
- }
30
- export interface TokenBalance {
31
- token_id: string;
32
- balance: number;
33
- }
34
- export interface Key {
35
- _type: string;
36
- key: string;
37
- }
38
- export interface Transaction {
39
- bytes: string | null;
40
- charged_tx_fee: number;
41
- consensus_timestamp: string;
42
- entity_id: string | null;
43
- max_fee: string;
44
- memo_base64: string;
45
- name: string;
46
- nft_transfers: NftTransfer[];
47
- node: string;
48
- nonce: number;
49
- parent_consensus_timestamp: string | null;
50
- result: string;
51
- scheduled: boolean;
52
- staking_reward_transfers: Transfer[];
53
- token_transfers: TokenTransfer[];
54
- transaction_hash: string;
55
- transaction_id: string;
56
- transfers: Transfer[];
57
- valid_duration_seconds: string;
58
- valid_start_timestamp: string;
59
- }
60
- export interface Transfer {
61
- account: string;
62
- amount: number;
63
- is_approval: boolean;
64
- }
65
- export interface TokenTransfer {
66
- token_id: string;
67
- account: string;
68
- amount: string;
69
- is_approval: boolean;
70
- }
71
- export interface NftTransfer {
72
- receiver_account_id: string;
73
- sender_account_id: string;
74
- serial_number: number;
75
- is_approval: boolean;
76
- }
77
- export interface Links {
78
- next: string;
79
- }
80
- export interface OutboundConfig {
81
- network: 'mainnet' | 'testnet';
82
- logLevel?: LogLevel;
83
- }
84
- export interface TopicInfo {
85
- inboundTopic: string;
86
- outboundTopic: string;
87
- }
88
- export interface HCSMessage {
89
- p: 'hcs-10';
90
- op: 'connection_request' | 'connection_created' | 'message';
91
- data: string;
92
- created?: Date;
93
- consensus_timestamp?: string;
94
- m?: string;
95
- payer: string;
96
- outbound_topic_id?: string;
97
- connection_request_id?: number;
98
- confirmed_request_id?: number;
99
- connection_topic_id?: string;
100
- connected_account_id?: string;
101
- requesting_account_id?: string;
102
- connection_id?: number;
103
- sequence_number: number;
104
- operator_id?: string;
105
- }
106
- export declare abstract class Outbound extends Registration {
107
- private static topicCache;
108
- protected network: string;
109
- protected logger: Logger;
110
- protected validTags: string[];
111
- constructor(config: OutboundConfig);
112
- abstract getAccountAndSigner(): {
113
- accountId: string;
114
- signer: any;
115
- };
116
- protected abstract getMessages(topicId: string): Promise<{
117
- messages: HCSMessage[];
118
- }>;
119
- protected validateTags(metadata: {
120
- tags: string[];
121
- }): {
122
- valid: boolean;
123
- error?: string;
124
- };
125
- protected checkRegistrationStatus(transactionId: string, network: string, baseUrl: string): Promise<{
126
- status: 'pending' | 'success' | 'failed';
127
- }>;
128
- protected waitForRegistrationConfirmation(transactionId: string, network: string, baseUrl: string, maxAttempts: number, delayMs: number): Promise<boolean>;
129
- requestAccount(account: string): Promise<AccountResponse>;
130
- getAccountMemo(accountId: string): Promise<string | null>;
131
- private getTopicInfoFromMemo;
132
- getMirrorNodeUrl(): string;
133
- getTopicInfo(accountId: string): Promise<TopicInfo | null>;
134
- retrieveOutboundConnectTopic(accountId: string): Promise<string | null>;
135
- retrieveOutboundConnectTopicFromNetwork(accountId: string): Promise<TopicInfo>;
136
- retrieveOutboundMessages(agentAccountId: string): Promise<HCSMessage[]>;
137
- hasConnectionCreated(agentAccountId: string, connectionId: number): Promise<boolean>;
138
- clearCache(): void;
139
- }
140
- export declare class OutboundCache {
141
- private static instance;
142
- private cache;
143
- private cacheExpiry;
144
- private readonly CACHE_TTL;
145
- private constructor();
146
- static getInstance(): OutboundCache;
147
- set(key: string, value: TopicInfo): void;
148
- get(key: string): TopicInfo | undefined;
149
- clear(): void;
150
- }
@@ -1,34 +0,0 @@
1
- import { Logger } from '../utils/logger';
2
- import { RegistrationResult } from './types';
3
- /**
4
- * Checks the status of a registration transaction
5
- * @param transactionId Transaction ID
6
- * @param network Network type
7
- * @param baseUrl Base URL of the guarded registry
8
- * @param logger Logger instance
9
- * @returns Registration status
10
- */
11
- export declare function checkRegistrationStatus(transactionId: string, network: string, baseUrl: string, logger?: Logger): Promise<{
12
- status: 'pending' | 'success' | 'failed';
13
- }>;
14
- /**
15
- * Waits for a registration transaction to complete
16
- * @param transactionId Transaction ID
17
- * @param network Network type
18
- * @param baseUrl Base URL of the guarded registry
19
- * @param maxAttempts Maximum number of attempts
20
- * @param delayMs Delay between attempts
21
- * @param logger Logger instance
22
- * @returns Confirmation result
23
- */
24
- export declare function waitForRegistrationConfirmation(transactionId: string, network: string, baseUrl: string, maxAttempts?: number, delayMs?: number, logger?: Logger): Promise<boolean>;
25
- /**
26
- * Executes a registration request
27
- * @param accountId Account ID
28
- * @param inboundTopicId Inbound topic ID
29
- * @param network Network type
30
- * @param guardedRegistryBaseUrl Base URL of the guarded registry
31
- * @param logger Logger instance
32
- * @returns Registration result
33
- */
34
- export declare function executeRegistration(accountId: string, inboundTopicId: string, network: string, guardedRegistryBaseUrl: string, logger: Logger): Promise<RegistrationResult>;
@@ -1,150 +0,0 @@
1
- import { Logger, LogLevel } from '../utils/logger';
2
- import { Registration } from './registrations';
3
- export interface AccountResponse {
4
- account: string;
5
- alias: string;
6
- auto_renew_period: number;
7
- balance: Balance;
8
- created_timestamp: string;
9
- decline_reward: boolean;
10
- deleted: boolean;
11
- ethereum_nonce: number;
12
- evm_address: string;
13
- expiry_timestamp: string;
14
- key: Key;
15
- max_automatic_token_associations: number;
16
- memo: string;
17
- pending_reward: number;
18
- receiver_sig_required: boolean;
19
- staked_account_id: string | null;
20
- staked_node_id: string | null;
21
- stake_period_start: string | null;
22
- transactions: Transaction[];
23
- links: Links;
24
- }
25
- export interface Balance {
26
- balance: number;
27
- timestamp: string;
28
- tokens: TokenBalance[];
29
- }
30
- export interface TokenBalance {
31
- token_id: string;
32
- balance: number;
33
- }
34
- export interface Key {
35
- _type: string;
36
- key: string;
37
- }
38
- export interface Transaction {
39
- bytes: string | null;
40
- charged_tx_fee: number;
41
- consensus_timestamp: string;
42
- entity_id: string | null;
43
- max_fee: string;
44
- memo_base64: string;
45
- name: string;
46
- nft_transfers: NftTransfer[];
47
- node: string;
48
- nonce: number;
49
- parent_consensus_timestamp: string | null;
50
- result: string;
51
- scheduled: boolean;
52
- staking_reward_transfers: Transfer[];
53
- token_transfers: TokenTransfer[];
54
- transaction_hash: string;
55
- transaction_id: string;
56
- transfers: Transfer[];
57
- valid_duration_seconds: string;
58
- valid_start_timestamp: string;
59
- }
60
- export interface Transfer {
61
- account: string;
62
- amount: number;
63
- is_approval: boolean;
64
- }
65
- export interface TokenTransfer {
66
- token_id: string;
67
- account: string;
68
- amount: string;
69
- is_approval: boolean;
70
- }
71
- export interface NftTransfer {
72
- receiver_account_id: string;
73
- sender_account_id: string;
74
- serial_number: number;
75
- is_approval: boolean;
76
- }
77
- export interface Links {
78
- next: string;
79
- }
80
- export interface OutboundConfig {
81
- network: 'mainnet' | 'testnet';
82
- logLevel?: LogLevel;
83
- }
84
- export interface TopicInfo {
85
- inboundTopic: string;
86
- outboundTopic: string;
87
- }
88
- export interface HCSMessage {
89
- p: 'hcs-10';
90
- op: 'connection_request' | 'connection_created' | 'message';
91
- data: string;
92
- created?: Date;
93
- consensus_timestamp?: string;
94
- m?: string;
95
- payer: string;
96
- outbound_topic_id?: string;
97
- connection_request_id?: number;
98
- confirmed_request_id?: number;
99
- connection_topic_id?: string;
100
- connected_account_id?: string;
101
- requesting_account_id?: string;
102
- connection_id?: number;
103
- sequence_number: number;
104
- operator_id?: string;
105
- }
106
- export declare abstract class Outbound extends Registration {
107
- private static topicCache;
108
- protected network: string;
109
- protected logger: Logger;
110
- protected validTags: string[];
111
- constructor(config: OutboundConfig);
112
- abstract getAccountAndSigner(): {
113
- accountId: string;
114
- signer: any;
115
- };
116
- protected abstract getMessages(topicId: string): Promise<{
117
- messages: HCSMessage[];
118
- }>;
119
- protected validateTags(metadata: {
120
- tags: string[];
121
- }): {
122
- valid: boolean;
123
- error?: string;
124
- };
125
- protected checkRegistrationStatus(transactionId: string, network: string, baseUrl: string): Promise<{
126
- status: 'pending' | 'success' | 'failed';
127
- }>;
128
- protected waitForRegistrationConfirmation(transactionId: string, network: string, baseUrl: string, maxAttempts: number, delayMs: number): Promise<boolean>;
129
- requestAccount(account: string): Promise<AccountResponse>;
130
- getAccountMemo(accountId: string): Promise<string | null>;
131
- private getTopicInfoFromMemo;
132
- getMirrorNodeUrl(): string;
133
- getTopicInfo(accountId: string): Promise<TopicInfo | null>;
134
- retrieveOutboundConnectTopic(accountId: string): Promise<string | null>;
135
- retrieveOutboundConnectTopicFromNetwork(accountId: string): Promise<TopicInfo>;
136
- retrieveOutboundMessages(agentAccountId: string): Promise<HCSMessage[]>;
137
- hasConnectionCreated(agentAccountId: string, connectionId: number): Promise<boolean>;
138
- clearCache(): void;
139
- }
140
- export declare class OutboundCache {
141
- private static instance;
142
- private cache;
143
- private cacheExpiry;
144
- private readonly CACHE_TTL;
145
- private constructor();
146
- static getInstance(): OutboundCache;
147
- set(key: string, value: TopicInfo): void;
148
- get(key: string): TopicInfo | undefined;
149
- clear(): void;
150
- }
@@ -1,34 +0,0 @@
1
- import { Logger } from '../utils/logger';
2
- import { RegistrationResult } from './types';
3
- /**
4
- * Checks the status of a registration transaction
5
- * @param transactionId Transaction ID
6
- * @param network Network type
7
- * @param baseUrl Base URL of the guarded registry
8
- * @param logger Logger instance
9
- * @returns Registration status
10
- */
11
- export declare function checkRegistrationStatus(transactionId: string, network: string, baseUrl: string, logger?: Logger): Promise<{
12
- status: 'pending' | 'success' | 'failed';
13
- }>;
14
- /**
15
- * Waits for a registration transaction to complete
16
- * @param transactionId Transaction ID
17
- * @param network Network type
18
- * @param baseUrl Base URL of the guarded registry
19
- * @param maxAttempts Maximum number of attempts
20
- * @param delayMs Delay between attempts
21
- * @param logger Logger instance
22
- * @returns Confirmation result
23
- */
24
- export declare function waitForRegistrationConfirmation(transactionId: string, network: string, baseUrl: string, maxAttempts?: number, delayMs?: number, logger?: Logger): Promise<boolean>;
25
- /**
26
- * Executes a registration request
27
- * @param accountId Account ID
28
- * @param inboundTopicId Inbound topic ID
29
- * @param network Network type
30
- * @param guardedRegistryBaseUrl Base URL of the guarded registry
31
- * @param logger Logger instance
32
- * @returns Registration result
33
- */
34
- export declare function executeRegistration(accountId: string, inboundTopicId: string, network: string, guardedRegistryBaseUrl: string, logger: Logger): Promise<RegistrationResult>;