@hashgraphonline/standards-sdk 0.0.93 → 0.0.95
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/hcs-10/base-client.d.ts +14 -2
- package/dist/es/hcs-10/base-client.d.ts.map +1 -1
- package/dist/es/inscribe/inscriber.d.ts +2 -0
- package/dist/es/inscribe/inscriber.d.ts.map +1 -1
- package/dist/es/standards-sdk.es.js +8 -5
- package/dist/es/standards-sdk.es.js.map +1 -1
- package/dist/es/standards-sdk.es100.js +13 -16
- package/dist/es/standards-sdk.es100.js.map +1 -1
- package/dist/es/standards-sdk.es101.js +13 -5
- package/dist/es/standards-sdk.es101.js.map +1 -1
- package/dist/es/standards-sdk.es102.js +30 -37
- package/dist/es/standards-sdk.es102.js.map +1 -1
- package/dist/es/standards-sdk.es103.js +15 -40
- package/dist/es/standards-sdk.es103.js.map +1 -1
- package/dist/es/standards-sdk.es104.js +4 -37
- package/dist/es/standards-sdk.es104.js.map +1 -1
- package/dist/es/standards-sdk.es105.js +4 -78
- package/dist/es/standards-sdk.es105.js.map +1 -1
- package/dist/es/standards-sdk.es106.js +13 -7133
- package/dist/es/standards-sdk.es106.js.map +1 -1
- package/dist/es/standards-sdk.es107.js +5 -3
- package/dist/es/standards-sdk.es107.js.map +1 -1
- package/dist/es/standards-sdk.es108.js +39 -2
- package/dist/es/standards-sdk.es108.js.map +1 -1
- package/dist/es/standards-sdk.es109.js +40 -2
- package/dist/es/standards-sdk.es109.js.map +1 -1
- package/dist/es/standards-sdk.es110.js +37 -34
- package/dist/es/standards-sdk.es110.js.map +1 -1
- package/dist/es/standards-sdk.es111.js +74 -29
- package/dist/es/standards-sdk.es111.js.map +1 -1
- package/dist/es/standards-sdk.es112.js +3 -9
- package/dist/es/standards-sdk.es112.js.map +1 -1
- package/dist/es/standards-sdk.es113.js +2 -34
- package/dist/es/standards-sdk.es113.js.map +1 -1
- package/dist/es/standards-sdk.es114.js +2 -419
- package/dist/es/standards-sdk.es114.js.map +1 -1
- package/dist/es/standards-sdk.es115.js +34 -2
- package/dist/es/standards-sdk.es115.js.map +1 -1
- package/dist/es/standards-sdk.es116.js +29 -116
- package/dist/es/standards-sdk.es116.js.map +1 -1
- package/dist/es/standards-sdk.es117.js +9 -4
- package/dist/es/standards-sdk.es117.js.map +1 -1
- package/dist/es/standards-sdk.es118.js +37 -0
- package/dist/es/standards-sdk.es118.js.map +1 -0
- package/dist/es/standards-sdk.es13.js +5 -5
- package/dist/es/standards-sdk.es15.js +1 -1
- package/dist/es/standards-sdk.es16.js +1 -1
- package/dist/es/standards-sdk.es18.js +134 -384
- package/dist/es/standards-sdk.es18.js.map +1 -1
- package/dist/es/standards-sdk.es19.js +386 -315
- package/dist/es/standards-sdk.es19.js.map +1 -1
- package/dist/es/standards-sdk.es20.js +310 -128
- package/dist/es/standards-sdk.es20.js.map +1 -1
- package/dist/es/standards-sdk.es21.js +155 -7
- package/dist/es/standards-sdk.es21.js.map +1 -1
- package/dist/es/standards-sdk.es22.js +7 -1041
- package/dist/es/standards-sdk.es22.js.map +1 -1
- package/dist/es/standards-sdk.es23.js +966 -1692
- package/dist/es/standards-sdk.es23.js.map +1 -1
- package/dist/es/standards-sdk.es24.js +1767 -36
- package/dist/es/standards-sdk.es24.js.map +1 -1
- package/dist/es/standards-sdk.es25.js +7163 -21
- package/dist/es/standards-sdk.es25.js.map +1 -1
- package/dist/es/standards-sdk.es26.js +3 -7190
- package/dist/es/standards-sdk.es26.js.map +1 -1
- package/dist/es/standards-sdk.es27.js +2 -3
- package/dist/es/standards-sdk.es27.js.map +1 -1
- package/dist/es/standards-sdk.es28.js +4167 -2
- package/dist/es/standards-sdk.es28.js.map +1 -1
- package/dist/es/standards-sdk.es29.js +36 -4167
- package/dist/es/standards-sdk.es29.js.map +1 -1
- package/dist/es/standards-sdk.es30.js +48 -5
- package/dist/es/standards-sdk.es30.js.map +1 -1
- package/dist/es/standards-sdk.es31.js +5 -2
- package/dist/es/standards-sdk.es31.js.map +1 -1
- package/dist/es/standards-sdk.es32.js +2 -364
- package/dist/es/standards-sdk.es32.js.map +1 -1
- package/dist/es/standards-sdk.es33.js +100 -5
- package/dist/es/standards-sdk.es33.js.map +1 -1
- package/dist/es/standards-sdk.es34.js +2 -179
- package/dist/es/standards-sdk.es34.js.map +1 -1
- package/dist/es/standards-sdk.es35.js +15 -80
- package/dist/es/standards-sdk.es35.js.map +1 -1
- package/dist/es/standards-sdk.es36.js +400 -105
- package/dist/es/standards-sdk.es36.js.map +1 -1
- package/dist/es/standards-sdk.es37.js +190 -47
- package/dist/es/standards-sdk.es37.js.map +1 -1
- package/dist/es/standards-sdk.es38.js +438 -10
- package/dist/es/standards-sdk.es38.js.map +1 -1
- package/dist/es/standards-sdk.es39.js +19 -91
- package/dist/es/standards-sdk.es39.js.map +1 -1
- package/dist/es/standards-sdk.es4.js +1 -1
- package/dist/es/standards-sdk.es40.js +138 -3
- package/dist/es/standards-sdk.es40.js.map +1 -1
- package/dist/es/standards-sdk.es41.js +18 -2
- package/dist/es/standards-sdk.es41.js.map +1 -1
- package/dist/es/standards-sdk.es42.js +22 -106
- package/dist/es/standards-sdk.es42.js.map +1 -1
- package/dist/es/standards-sdk.es43.js +26 -71
- package/dist/es/standards-sdk.es43.js.map +1 -1
- package/dist/es/standards-sdk.es44.js +20 -5
- package/dist/es/standards-sdk.es44.js.map +1 -1
- package/dist/es/standards-sdk.es45.js +43 -4
- package/dist/es/standards-sdk.es45.js.map +1 -1
- package/dist/es/standards-sdk.es46.js +13 -216
- package/dist/es/standards-sdk.es46.js.map +1 -1
- package/dist/es/standards-sdk.es47.js +57 -54
- package/dist/es/standards-sdk.es47.js.map +1 -1
- package/dist/es/standards-sdk.es48.js +1287 -67
- package/dist/es/standards-sdk.es48.js.map +1 -1
- package/dist/es/standards-sdk.es49.js +131 -67
- package/dist/es/standards-sdk.es49.js.map +1 -1
- package/dist/es/standards-sdk.es5.js +42 -18
- package/dist/es/standards-sdk.es5.js.map +1 -1
- package/dist/es/standards-sdk.es50.js +90 -22
- package/dist/es/standards-sdk.es50.js.map +1 -1
- package/dist/es/standards-sdk.es51.js +67 -131
- package/dist/es/standards-sdk.es51.js.map +1 -1
- package/dist/es/standards-sdk.es52.js +27 -86
- package/dist/es/standards-sdk.es52.js.map +1 -1
- package/dist/es/standards-sdk.es53.js +5 -194
- package/dist/es/standards-sdk.es53.js.map +1 -1
- package/dist/es/standards-sdk.es54.js +140 -419
- package/dist/es/standards-sdk.es54.js.map +1 -1
- package/dist/es/standards-sdk.es55.js +22 -24
- package/dist/es/standards-sdk.es55.js.map +1 -1
- package/dist/es/standards-sdk.es56.js +777 -123
- package/dist/es/standards-sdk.es56.js.map +1 -1
- package/dist/es/standards-sdk.es57.js +169 -13
- package/dist/es/standards-sdk.es57.js.map +1 -1
- package/dist/es/standards-sdk.es58.js +2282 -29
- package/dist/es/standards-sdk.es58.js.map +1 -1
- package/dist/es/standards-sdk.es59.js +160 -25
- package/dist/es/standards-sdk.es59.js.map +1 -1
- package/dist/es/standards-sdk.es60.js +137 -15
- package/dist/es/standards-sdk.es60.js.map +1 -1
- package/dist/es/standards-sdk.es61.js +7128 -36
- package/dist/es/standards-sdk.es61.js.map +1 -1
- package/dist/es/standards-sdk.es62.js +14 -11
- package/dist/es/standards-sdk.es62.js.map +1 -1
- package/dist/es/standards-sdk.es63.js +25 -59
- package/dist/es/standards-sdk.es63.js.map +1 -1
- package/dist/es/standards-sdk.es64.js +26 -1289
- package/dist/es/standards-sdk.es64.js.map +1 -1
- package/dist/es/standards-sdk.es65.js +35 -29
- package/dist/es/standards-sdk.es65.js.map +1 -1
- package/dist/es/standards-sdk.es66.js +418 -5
- package/dist/es/standards-sdk.es66.js.map +1 -1
- package/dist/es/standards-sdk.es67.js +2 -159
- package/dist/es/standards-sdk.es67.js.map +1 -1
- package/dist/es/standards-sdk.es68.js +113 -786
- package/dist/es/standards-sdk.es68.js.map +1 -1
- package/dist/es/standards-sdk.es69.js +3 -143
- package/dist/es/standards-sdk.es69.js.map +1 -1
- package/dist/es/standards-sdk.es7.js +4 -4
- package/dist/es/standards-sdk.es70.js +3 -173
- package/dist/es/standards-sdk.es70.js.map +1 -1
- package/dist/es/standards-sdk.es71.js +364 -3
- package/dist/es/standards-sdk.es71.js.map +1 -1
- package/dist/es/standards-sdk.es72.js +5 -163
- package/dist/es/standards-sdk.es72.js.map +1 -1
- package/dist/es/standards-sdk.es73.js +173 -26
- package/dist/es/standards-sdk.es73.js.map +1 -1
- package/dist/es/standards-sdk.es74.js +73 -55
- package/dist/es/standards-sdk.es74.js.map +1 -1
- package/dist/es/standards-sdk.es75.js +109 -45
- package/dist/es/standards-sdk.es75.js.map +1 -1
- package/dist/es/standards-sdk.es76.js +50 -8
- package/dist/es/standards-sdk.es76.js.map +1 -1
- package/dist/es/standards-sdk.es77.js +9 -64
- package/dist/es/standards-sdk.es77.js.map +1 -1
- package/dist/es/standards-sdk.es78.js +97 -6
- package/dist/es/standards-sdk.es78.js.map +1 -1
- package/dist/es/standards-sdk.es79.js +3 -14
- package/dist/es/standards-sdk.es79.js.map +1 -1
- package/dist/es/standards-sdk.es8.js +4 -4
- package/dist/es/standards-sdk.es80.js +2 -7
- package/dist/es/standards-sdk.es80.js.map +1 -1
- package/dist/es/standards-sdk.es81.js +109 -41
- package/dist/es/standards-sdk.es81.js.map +1 -1
- package/dist/es/standards-sdk.es82.js +74 -2
- package/dist/es/standards-sdk.es82.js.map +1 -1
- package/dist/es/standards-sdk.es83.js +6 -136
- package/dist/es/standards-sdk.es83.js.map +1 -1
- package/dist/es/standards-sdk.es84.js +5 -172
- package/dist/es/standards-sdk.es84.js.map +1 -1
- package/dist/es/standards-sdk.es85.js +208 -88
- package/dist/es/standards-sdk.es85.js.map +1 -1
- package/dist/es/standards-sdk.es86.js +58 -2
- package/dist/es/standards-sdk.es86.js.map +1 -1
- package/dist/es/standards-sdk.es87.js +69 -16
- package/dist/es/standards-sdk.es87.js.map +1 -1
- package/dist/es/standards-sdk.es88.js +27 -404
- package/dist/es/standards-sdk.es88.js.map +1 -1
- package/dist/es/standards-sdk.es89.js +58 -16
- package/dist/es/standards-sdk.es89.js.map +1 -1
- package/dist/es/standards-sdk.es9.js +1 -1
- package/dist/es/standards-sdk.es90.js +47 -24
- package/dist/es/standards-sdk.es90.js.map +1 -1
- package/dist/es/standards-sdk.es91.js +8 -24
- package/dist/es/standards-sdk.es91.js.map +1 -1
- package/dist/es/standards-sdk.es92.js +63 -36
- package/dist/es/standards-sdk.es92.js.map +1 -1
- package/dist/es/standards-sdk.es93.js +5 -12
- package/dist/es/standards-sdk.es93.js.map +1 -1
- package/dist/es/standards-sdk.es94.js +15 -13
- package/dist/es/standards-sdk.es94.js.map +1 -1
- package/dist/es/standards-sdk.es95.js +6 -31
- package/dist/es/standards-sdk.es95.js.map +1 -1
- package/dist/es/standards-sdk.es96.js +44 -14
- package/dist/es/standards-sdk.es96.js.map +1 -1
- package/dist/es/standards-sdk.es97.js +2 -4
- package/dist/es/standards-sdk.es97.js.map +1 -1
- package/dist/es/standards-sdk.es98.js +136 -4
- package/dist/es/standards-sdk.es98.js.map +1 -1
- package/dist/es/standards-sdk.es99.js +171 -2281
- package/dist/es/standards-sdk.es99.js.map +1 -1
- package/dist/es/utils/hrl-resolver.d.ts +53 -0
- package/dist/es/utils/hrl-resolver.d.ts.map +1 -0
- package/dist/es/utils/index.d.ts +1 -0
- package/dist/es/utils/index.d.ts.map +1 -1
- package/dist/umd/hcs-10/base-client.d.ts +14 -2
- package/dist/umd/hcs-10/base-client.d.ts.map +1 -1
- package/dist/umd/inscribe/inscriber.d.ts +2 -0
- package/dist/umd/inscribe/inscriber.d.ts.map +1 -1
- package/dist/umd/standards-sdk.umd.js +2 -2
- package/dist/umd/standards-sdk.umd.js.map +1 -1
- package/dist/umd/utils/hrl-resolver.d.ts +53 -0
- package/dist/umd/utils/hrl-resolver.d.ts.map +1 -0
- package/dist/umd/utils/index.d.ts +1 -0
- package/dist/umd/utils/index.d.ts.map +1 -1
- package/package.json +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-sdk.es5.js","sources":["../../src/hcs-10/base-client.ts"],"sourcesContent":["import { Logger, LogLevel } from '../utils/logger';\nimport { Registration } from './registrations';\nimport { HCS11Client } from '../hcs-11/client';\nimport { AccountResponse, TopicResponse } from '../services/types';\nimport { TopicInfo } from '../services/types';\nimport { TransactionReceipt, PrivateKey, PublicKey } from '@hashgraph/sdk';\nimport axios from 'axios';\nimport { NetworkType } from '../utils/types';\nimport { HederaMirrorNode } from '../services';\nimport { WaitForConnectionConfirmationResponse } from './types';\n\nexport enum Hcs10MemoType {\n INBOUND = 'inbound',\n OUTBOUND = 'outbound',\n CONNECTION = 'connection',\n}\n\nexport interface HCS10Config {\n network: 'mainnet' | 'testnet';\n logLevel?: LogLevel;\n prettyPrint?: boolean;\n feeAmount?: number;\n}\n\nexport interface HCSMessage {\n p: 'hcs-10';\n op:\n | 'connection_request'\n | 'connection_created'\n | 'message'\n | 'close_connection';\n data: string;\n created?: Date;\n consensus_timestamp?: string;\n m?: string;\n payer: string;\n outbound_topic_id?: string;\n connection_request_id?: number;\n confirmed_request_id?: number;\n connection_topic_id?: string;\n connected_account_id?: string;\n requesting_account_id?: string;\n connection_id?: number;\n sequence_number: number;\n operator_id?: string;\n reason?: string;\n close_method?: string;\n}\n\nexport interface ProfileResponse {\n profile: any;\n topicInfo?: TopicInfo;\n success: boolean;\n error?: string;\n}\n\nexport abstract class HCS10BaseClient extends Registration {\n protected network: string;\n protected logger: Logger;\n protected mirrorNode: HederaMirrorNode;\n protected feeAmount: number;\n\n protected operatorId: string;\n\n constructor(config: HCS10Config) {\n super();\n this.network = config.network;\n this.logger = Logger.getInstance({\n level: config.logLevel || 'info',\n module: 'HCS10-BaseClient',\n prettyPrint: config.prettyPrint,\n });\n this.mirrorNode = new HederaMirrorNode(\n config.network as NetworkType,\n this.logger\n );\n this.feeAmount = config.feeAmount || 0.001;\n }\n\n abstract submitPayload(\n topicId: string,\n payload: object | string,\n submitKey?: PrivateKey,\n requiresFee?: boolean\n ): Promise<TransactionReceipt>;\n\n abstract getAccountAndSigner(): { accountId: string; signer: any };\n\n public extractTopicFromOperatorId(operatorId: string): string {\n if (!operatorId) {\n return '';\n }\n const parts = operatorId.split('@');\n if (parts.length > 0) {\n return parts[0];\n }\n return '';\n }\n\n public extractAccountFromOperatorId(operatorId: string): string {\n if (!operatorId) {\n return '';\n }\n const parts = operatorId.split('@');\n if (parts.length > 1) {\n return parts[1];\n }\n return '';\n }\n\n /**\n * Get a stream of messages from a connection topic\n * @param topicId The connection topic ID to get messages from\n * @returns A stream of filtered messages valid for connection topics\n */\n public async getMessageStream(\n topicId: string\n ): Promise<{ messages: HCSMessage[] }> {\n try {\n const messages = await this.mirrorNode.getTopicMessages(topicId);\n const validOps = ['message', 'close_connection'];\n\n const filteredMessages = messages.filter((msg) => {\n if (msg.p !== 'hcs-10' || !validOps.includes(msg.op)) {\n return false;\n }\n\n if (msg.op === 'message') {\n if (!msg.data) {\n return false;\n }\n\n if (!msg.operator_id) {\n return false;\n }\n\n if (!this.isValidOperatorId(msg.operator_id)) {\n return false;\n }\n }\n\n if (msg.op === 'close_connection') {\n if (!msg.operator_id) {\n return false;\n }\n\n if (!this.isValidOperatorId(msg.operator_id)) {\n return false;\n }\n }\n\n return true;\n });\n\n return {\n messages: filteredMessages,\n };\n } catch (error: any) {\n if (this.logger) {\n this.logger.error(`Error fetching messages: ${error.message}`);\n }\n return { messages: [] };\n }\n }\n\n /**\n * Public method to retrieve topic information using the internal mirror node client.\n *\n * @param topicId The ID of the topic to query.\n * @returns Topic information or null if not found or an error occurs.\n */\n async getPublicTopicInfo(topicId: string): Promise<TopicResponse | null> {\n try {\n return await this.mirrorNode.getTopicInfo(topicId);\n } catch (error) {\n this.logger.error(\n `Error getting public topic info for ${topicId}:`,\n error\n );\n return null;\n }\n }\n\n /**\n * Checks if a user can submit to a topic and determines if a fee is required\n * @param topicId The topic ID to check\n * @param userAccountId The account ID of the user attempting to submit\n * @returns Object with canSubmit, requiresFee, and optional reason\n */\n public async canSubmitToTopic(\n topicId: string,\n userAccountId: string\n ): Promise<{ canSubmit: boolean; requiresFee: boolean; reason?: string }> {\n try {\n const topicInfo = await this.mirrorNode.getTopicInfo(topicId);\n\n if (!topicInfo) {\n return {\n canSubmit: false,\n requiresFee: false,\n reason: 'Topic does not exist',\n };\n }\n\n if (!topicInfo.submit_key?.key) {\n return { canSubmit: true, requiresFee: false };\n }\n\n try {\n const userPublicKey = await this.mirrorNode.getPublicKey(userAccountId);\n\n if (topicInfo.submit_key._type === 'ProtobufEncoded') {\n const keyBytes = Buffer.from(topicInfo.submit_key.key, 'hex');\n const hasAccess = await this.mirrorNode.checkKeyListAccess(\n keyBytes,\n userPublicKey\n );\n\n if (hasAccess) {\n return { canSubmit: true, requiresFee: false };\n }\n } else {\n const topicSubmitKey = PublicKey.fromString(topicInfo.submit_key.key);\n if (userPublicKey.toString() === topicSubmitKey.toString()) {\n return { canSubmit: true, requiresFee: false };\n }\n }\n } catch (error) {\n this.logger.error(\n `Key validation error: ${\n error instanceof Error ? error.message : String(error)\n }`\n );\n }\n\n if (\n topicInfo.fee_schedule_key?.key &&\n topicInfo.custom_fees?.fixed_fees?.length > 0\n ) {\n return {\n canSubmit: true,\n requiresFee: true,\n reason: 'Requires fee payment via HIP-991',\n };\n }\n\n return {\n canSubmit: false,\n requiresFee: false,\n reason: 'User does not have submit permission for this topic',\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n this.logger.error(`Topic submission validation error: ${errorMessage}`);\n return {\n canSubmit: false,\n requiresFee: false,\n reason: `Error: ${errorMessage}`,\n };\n }\n }\n\n /**\n * Get all messages from a topic\n * @param topicId The topic ID to get messages from\n * @returns All messages from the topic\n */\n public async getMessages(\n topicId: string\n ): Promise<{ messages: HCSMessage[] }> {\n try {\n const messages = await this.mirrorNode.getTopicMessages(topicId);\n\n const validatedMessages = messages.filter((msg) => {\n if (msg.p !== 'hcs-10') {\n return false;\n }\n\n if (msg.op === 'message') {\n if (!msg.data) {\n return false;\n }\n\n if (msg.operator_id) {\n if (!this.isValidOperatorId(msg.operator_id)) {\n return false;\n }\n }\n }\n\n return true;\n });\n\n return {\n messages: validatedMessages,\n };\n } catch (error: any) {\n if (this.logger) {\n this.logger.error(`Error fetching messages: ${error.message}`);\n }\n return { messages: [] };\n }\n }\n\n /**\n * Requests an account from the mirror node\n * @param account The account ID to request\n * @returns The account response\n */\n public async requestAccount(account: string): Promise<AccountResponse> {\n try {\n return await this.mirrorNode.requestAccount(account);\n } catch (e) {\n this.logger.error('Failed to fetch account', e);\n throw e;\n }\n }\n\n /**\n * Retrieves the memo for an account\n * @param accountId The account ID to retrieve the memo for\n * @returns The memo\n */\n public async getAccountMemo(accountId: string): Promise<string | null> {\n return await this.mirrorNode.getAccountMemo(accountId);\n }\n\n /**\n * Retrieves the profile for an account\n * @param accountId The account ID to retrieve the profile for\n * @param disableCache Whether to disable caching of the result\n * @returns The profile\n */\n public async retrieveProfile(\n accountId: string,\n disableCache?: boolean\n ): Promise<ProfileResponse> {\n this.logger.debug(`Retrieving profile for account: ${accountId}`);\n\n const cacheKey = `${accountId}-${this.network}`;\n\n if (!disableCache) {\n const cachedProfileResponse = HCS10Cache.getInstance().get(cacheKey);\n if (cachedProfileResponse) {\n this.logger.debug(`Cache hit for profile: ${accountId}`);\n return cachedProfileResponse;\n }\n }\n try {\n const hcs11Client = new HCS11Client({\n network: this.network as 'mainnet' | 'testnet',\n auth: {\n operatorId: '0.0.0', // Read-only operations only\n },\n logLevel: 'info',\n });\n\n const profileResult = await hcs11Client.fetchProfileByAccountId(\n accountId,\n this.network\n );\n\n if (!profileResult?.success) {\n this.logger.error(\n `Failed to retrieve profile for account ID: ${accountId}`,\n profileResult?.error\n );\n return {\n profile: null,\n success: false,\n error:\n profileResult?.error ||\n `Failed to retrieve profile for account ID: ${accountId}`,\n };\n }\n\n const profile = profileResult.profile;\n let topicInfo: TopicInfo | null = null;\n\n if (\n profileResult.topicInfo?.inboundTopic &&\n profileResult.topicInfo?.outboundTopic &&\n profileResult.topicInfo?.profileTopicId\n ) {\n topicInfo = {\n inboundTopic: profileResult.topicInfo.inboundTopic,\n outboundTopic: profileResult.topicInfo.outboundTopic,\n profileTopicId: profileResult.topicInfo.profileTopicId,\n };\n }\n\n const responseToCache: ProfileResponse = {\n profile,\n topicInfo,\n success: true,\n };\n HCS10Cache.getInstance().set(cacheKey, responseToCache);\n return responseToCache;\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Failed to retrieve profile: ${error.message}`;\n this.logger.error(logMessage);\n return {\n profile: null,\n success: false,\n error: logMessage,\n };\n }\n }\n\n /**\n * @deprecated Use retrieveCommunicationTopics instead\n * @param accountId The account ID to retrieve the outbound connect topic for\n * @returns {TopicInfo} Topic Info from target profile.\n */\n public async retrieveOutboundConnectTopic(\n accountId: string\n ): Promise<TopicInfo> {\n return await this.retrieveCommunicationTopics(accountId, true);\n }\n\n /**\n * Retrieves the communication topics for an account\n * @param accountId The account ID to retrieve the communication topics for\n * @param disableCache Whether to disable caching of the result\n * @returns {TopicInfo} Topic Info from target profile.\n */\n public async retrieveCommunicationTopics(\n accountId: string,\n disableCache?: boolean\n ): Promise<TopicInfo> {\n try {\n const profileResponse = await this.retrieveProfile(\n accountId,\n disableCache\n );\n\n if (!profileResponse?.success) {\n throw new Error(profileResponse.error || 'Failed to retrieve profile');\n }\n\n const profile = profileResponse.profile;\n\n if (!profile.inboundTopicId || !profile.outboundTopicId) {\n throw new Error(\n `Invalid HCS-11 profile for HCS-10 agent: missing inboundTopicId or outboundTopicId`\n );\n }\n\n if (!profileResponse.topicInfo) {\n throw new Error(\n `TopicInfo is missing in the profile for account ${accountId}`\n );\n }\n\n return profileResponse.topicInfo;\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Failed to retrieve topic info: ${error.message}`;\n this.logger.error(logMessage);\n throw error;\n }\n }\n\n /**\n * Retrieves outbound messages for an agent\n * @param agentAccountId The account ID of the agent\n * @returns The outbound messages\n */\n public async retrieveOutboundMessages(\n agentAccountId: string\n ): Promise<HCSMessage[]> {\n try {\n const topicInfo = await this.retrieveCommunicationTopics(agentAccountId);\n if (!topicInfo) {\n this.logger.warn(\n `No outbound connect topic found for agentAccountId: ${agentAccountId}`\n );\n return [];\n }\n const response = await this.getMessages(topicInfo.outboundTopic);\n return response.messages.filter(\n (msg) =>\n msg.p === 'hcs-10' &&\n (msg.op === 'connection_request' ||\n msg.op === 'connection_created' ||\n msg.op === 'message')\n );\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Failed to retrieve outbound messages: ${error.message}`;\n this.logger.error(logMessage);\n return [];\n }\n }\n\n /**\n * Checks if a connection has been created for an agent\n * @param agentAccountId The account ID of the agent\n * @param connectionId The ID of the connection\n * @returns True if the connection has been created, false otherwise\n */\n public async hasConnectionCreated(\n agentAccountId: string,\n connectionId: number\n ): Promise<boolean> {\n try {\n const outBoundTopic = await this.retrieveCommunicationTopics(\n agentAccountId\n );\n const messages = await this.retrieveOutboundMessages(\n outBoundTopic.outboundTopic\n );\n return messages.some(\n (msg) =>\n msg.op === 'connection_created' && msg.connection_id === connectionId\n );\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Failed to check connection created: ${error.message}`;\n this.logger.error(logMessage);\n return false;\n }\n }\n\n /**\n * Gets message content, resolving any HRL references if needed\n * @param data The message data which might be an HRL reference\n * @returns The resolved content\n */\n async getMessageContent(data: string): Promise<string> {\n const hrlPattern = /^hcs:\\/\\/(\\d+)\\/([0-9.]+)$/;\n const match = data.match(hrlPattern);\n\n if (!match) {\n return data;\n }\n\n const [_, standard, topicId] = match;\n\n this.logger.info(\n `Resolving HRL reference: standard=${standard}, topicId=${topicId}`\n );\n\n try {\n const cdnUrl = `https://kiloscribe.com/api/inscription-cdn/${topicId}?network=${this.network}`;\n const response = await axios.get(cdnUrl);\n\n if (!response.data) {\n throw new Error(`Failed to fetch content from topic: ${topicId}`);\n }\n\n return (\n response.data.content ||\n response.data.text ||\n JSON.stringify(response.data)\n );\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Error resolving HRL reference: ${error.message}`;\n this.logger.error(logMessage);\n throw new Error(logMessage);\n }\n }\n\n /**\n * Submits a connection request to an inbound topic\n * @param inboundTopicId The ID of the inbound topic\n * @param memo An optional memo for the message\n * @returns The transaction receipt\n */\n async submitConnectionRequest(\n inboundTopicId: string,\n memo: string\n ): Promise<TransactionReceipt> {\n const accountResponse = this.getAccountAndSigner();\n if (!accountResponse?.accountId) {\n throw new Error('Operator account ID is not set');\n }\n const operatorId = await this.getOperatorId();\n const accountId = accountResponse.accountId;\n\n const submissionCheck = await this.canSubmitToTopic(\n inboundTopicId,\n accountId\n );\n\n if (!submissionCheck?.canSubmit) {\n throw new Error(`Cannot submit to topic: ${submissionCheck.reason}`);\n }\n\n const inboundAccountOwner = await this.retrieveInboundAccountId(\n inboundTopicId\n );\n\n if (!inboundAccountOwner) {\n throw new Error('Failed to retrieve topic info account ID');\n }\n\n const connectionRequestMessage = {\n p: 'hcs-10',\n op: 'connection_request',\n operator_id: operatorId,\n m: memo,\n };\n\n const requiresFee = submissionCheck.requiresFee;\n const response = await this.submitPayload(\n inboundTopicId,\n connectionRequestMessage,\n undefined,\n requiresFee\n );\n\n this.logger.info(\n `Submitted connection request to topic ID: ${inboundTopicId}`\n );\n\n const outboundTopic = await this.retrieveCommunicationTopics(accountId);\n\n if (!outboundTopic) {\n throw new Error('Failed to retrieve outbound topic');\n }\n\n const responseSequenceNumber = response.topicSequenceNumber?.toNumber();\n\n if (!responseSequenceNumber) {\n throw new Error('Failed to get response sequence number');\n }\n\n const requestorOperatorId = `${inboundTopicId}@${inboundAccountOwner}`;\n\n await this.submitPayload(outboundTopic.outboundTopic, {\n ...connectionRequestMessage,\n outbound_topic_id: outboundTopic.outboundTopic,\n connection_request_id: responseSequenceNumber,\n operator_id: requestorOperatorId,\n });\n\n return response;\n }\n\n /**\n * Records an outbound connection confirmation\n * @param outboundTopicId The ID of the outbound topic\n * @param connectionRequestId The ID of the connection request\n * @param confirmedRequestId The ID of the confirmed request\n * @param connectionTopicId The ID of the connection topic\n * @param operatorId The operator ID of the original message sender.\n * @param memo An optional memo for the message\n */\n public async recordOutboundConnectionConfirmation({\n outboundTopicId,\n requestorOutboundTopicId,\n connectionRequestId,\n confirmedRequestId,\n connectionTopicId,\n operatorId,\n memo,\n }: {\n outboundTopicId: string;\n requestorOutboundTopicId: string;\n connectionRequestId: number;\n confirmedRequestId: number;\n connectionTopicId: string;\n operatorId: string;\n memo: string;\n }): Promise<TransactionReceipt> {\n const payload = {\n p: 'hcs-10',\n op: 'connection_created',\n connection_topic_id: connectionTopicId,\n outbound_topic_id: outboundTopicId,\n requestor_outbound_topic_id: requestorOutboundTopicId,\n confirmed_request_id: confirmedRequestId,\n connection_request_id: connectionRequestId,\n operator_id: operatorId,\n m: memo,\n };\n return await this.submitPayload(outboundTopicId, payload);\n }\n\n /**\n * Waits for confirmation of a connection request\n * @param inboundTopicId Inbound topic ID\n * @param connectionRequestId Connection request ID\n * @param maxAttempts Maximum number of attempts\n * @param delayMs Delay between attempts in milliseconds\n * @returns Connection confirmation details\n */\n async waitForConnectionConfirmation(\n inboundTopicId: string,\n connectionRequestId: number,\n maxAttempts = 60,\n delayMs = 2000,\n recordConfirmation = true\n ): Promise<WaitForConnectionConfirmationResponse> {\n this.logger.info(\n `Waiting for connection confirmation on inbound topic ${inboundTopicId} for request ID ${connectionRequestId}`\n );\n\n for (let attempt = 0; attempt < maxAttempts; attempt++) {\n this.logger.info(\n `Attempt ${attempt + 1}/${maxAttempts} to find connection confirmation`\n );\n const messages = await this.mirrorNode.getTopicMessages(inboundTopicId);\n\n const connectionCreatedMessages = messages.filter(\n (m) => m.op === 'connection_created'\n );\n\n this.logger.info(\n `Found ${connectionCreatedMessages.length} connection_created messages`\n );\n\n if (connectionCreatedMessages.length > 0) {\n for (const message of connectionCreatedMessages) {\n if (Number(message.connection_id) === Number(connectionRequestId)) {\n const confirmationResult = {\n connectionTopicId: message.connection_topic_id,\n sequence_number: Number(message.sequence_number),\n confirmedBy: message.operator_id,\n memo: message.m,\n };\n\n const confirmedByAccountId = this.extractAccountFromOperatorId(\n confirmationResult.confirmedBy\n );\n\n const account = this.getAccountAndSigner();\n const confirmedByConnectionTopics =\n await this.retrieveCommunicationTopics(confirmedByAccountId);\n\n const agentConnectionTopics =\n await this.retrieveCommunicationTopics(account.accountId);\n\n this.logger.info(\n 'Connection confirmation found',\n confirmationResult\n );\n\n if (recordConfirmation) {\n /**\n * Record's the confirmation of the connection request from the\n * confirmedBy account to the agent account.\n */\n await this.recordOutboundConnectionConfirmation({\n requestorOutboundTopicId:\n confirmedByConnectionTopics.outboundTopic,\n outboundTopicId: agentConnectionTopics.outboundTopic,\n connectionRequestId,\n confirmedRequestId: confirmationResult.sequence_number,\n connectionTopicId: confirmationResult.connectionTopicId,\n operatorId: confirmationResult.confirmedBy,\n memo: confirmationResult.memo || 'Connection confirmed',\n });\n }\n\n return confirmationResult;\n }\n }\n }\n\n if (attempt < maxAttempts - 1) {\n this.logger.info(\n `No matching confirmation found, waiting ${delayMs}ms before retrying...`\n );\n await new Promise((resolve) => setTimeout(resolve, delayMs));\n }\n }\n\n throw new Error(\n `Connection confirmation not found after ${maxAttempts} attempts for request ID ${connectionRequestId}`\n );\n }\n\n /**\n * Retrieves the operator ID for the current agent\n * @param disableCache Whether to disable caching of the result\n * @returns The operator ID\n */\n public async getOperatorId(disableCache?: boolean): Promise<string> {\n if (this.operatorId && !disableCache) {\n return this.operatorId;\n }\n\n const accountResponse = this.getAccountAndSigner();\n\n if (!accountResponse.accountId) {\n throw new Error('Operator ID not found');\n }\n\n const profile = await this.retrieveProfile(accountResponse.accountId);\n\n if (!profile.success) {\n throw new Error('Failed to retrieve profile');\n }\n\n const operatorId = `${profile.topicInfo?.inboundTopic}@${accountResponse.accountId}`;\n this.operatorId = operatorId;\n return operatorId;\n }\n\n /**\n * Retrieves the account ID of the owner of an inbound topic\n * @param inboundTopicId The ID of the inbound topic\n * @returns The account ID of the owner of the inbound topic\n */\n public async retrieveInboundAccountId(\n inboundTopicId: string\n ): Promise<string> {\n const topicInfo = await this.mirrorNode.getTopicInfo(inboundTopicId);\n\n if (!topicInfo?.memo) {\n throw new Error('Failed to retrieve topic info');\n }\n\n const topicInfoMemo = topicInfo.memo.toString();\n const topicInfoParts = topicInfoMemo.split(':');\n const inboundAccountOwner = topicInfoParts?.[4];\n\n if (!inboundAccountOwner) {\n throw new Error('Failed to retrieve topic info account ID');\n }\n\n return inboundAccountOwner;\n }\n\n public clearCache(): void {\n HCS10Cache.getInstance().clear();\n }\n\n /**\n * Generates a standard HCS-10 memo string.\n * @param type The type of topic memo ('inbound', 'outbound', 'connection').\n * @param options Configuration options for the memo.\n * @returns The formatted memo string.\n * @protected\n */\n protected _generateHcs10Memo(\n type: Hcs10MemoType,\n options: {\n ttl?: number;\n accountId?: string;\n inboundTopicId?: string;\n connectionId?: number;\n }\n ): string {\n const ttl = options.ttl ?? 60; // Default TTL to 60 if not provided\n\n switch (type) {\n case Hcs10MemoType.INBOUND:\n if (!options.accountId) {\n throw new Error('accountId is required for inbound memo');\n }\n return `hcs-10:0:${ttl}:0:${options.accountId}`;\n case Hcs10MemoType.OUTBOUND:\n return `hcs-10:0:${ttl}:1`;\n case Hcs10MemoType.CONNECTION:\n if (!options.inboundTopicId || options.connectionId === undefined) {\n throw new Error(\n 'inboundTopicId and connectionId are required for connection memo'\n );\n }\n return `hcs-10:1:${ttl}:2:${options.inboundTopicId}:${options.connectionId}`;\n default:\n throw new Error(`Invalid HCS-10 memo type: ${type}`);\n }\n }\n\n protected async checkRegistrationStatus(\n transactionId: string,\n network: string,\n baseUrl: string\n ): Promise<{ status: 'pending' | 'success' | 'failed' }> {\n try {\n const response = await fetch(`${baseUrl}/api/request-confirm`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'X-Network': network,\n },\n body: JSON.stringify({ transaction_id: transactionId }),\n });\n\n if (!response.ok) {\n throw new Error(\n `Failed to confirm registration: ${response.statusText}`\n );\n }\n\n return await response.json();\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Error checking registration status: ${error.message}`;\n this.logger.error(logMessage);\n throw error;\n }\n }\n\n /**\n * Validates if an operator_id follows the correct format (agentTopicId@accountId)\n * @param operatorId The operator ID to validate\n * @returns True if the format is valid, false otherwise\n */\n protected isValidOperatorId(operatorId: string): boolean {\n if (!operatorId) {\n return false;\n }\n\n const parts = operatorId.split('@');\n\n if (parts.length !== 2) {\n return false;\n }\n\n const agentTopicId = parts[0];\n const accountId = parts[1];\n\n if (!agentTopicId) {\n return false;\n }\n\n if (!accountId) {\n return false;\n }\n\n const hederaIdPattern = /^[0-9]+\\.[0-9]+\\.[0-9]+$/;\n\n if (!hederaIdPattern.test(accountId)) {\n return false;\n }\n\n if (!hederaIdPattern.test(agentTopicId)) {\n return false;\n }\n\n return true;\n }\n}\n\nexport class HCS10Cache {\n private static instance: HCS10Cache;\n private cache: Map<string, ProfileResponse>;\n private cacheExpiry: Map<string, number>;\n private readonly CACHE_TTL = 3600000;\n\n private constructor() {\n this.cache = new Map();\n this.cacheExpiry = new Map();\n }\n\n static getInstance(): HCS10Cache {\n if (!HCS10Cache.instance) {\n HCS10Cache.instance = new HCS10Cache();\n }\n return HCS10Cache.instance;\n }\n\n set(key: string, value: ProfileResponse): void {\n this.cache.set(key, value);\n this.cacheExpiry.set(key, Date.now() + this.CACHE_TTL);\n }\n\n get(key: string): ProfileResponse | undefined {\n const expiry = this.cacheExpiry.get(key);\n if (expiry && expiry > Date.now()) {\n return this.cache.get(key);\n }\n if (expiry) {\n this.cache.delete(key);\n this.cacheExpiry.delete(key);\n }\n return undefined;\n }\n\n clear(): void {\n this.cache.clear();\n this.cacheExpiry.clear();\n }\n}\n"],"names":["Hcs10MemoType"],"mappings":";;;;;;;;AAWY,IAAA,kCAAAA,mBAAL;AACLA,iBAAA,SAAU,IAAA;AAC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"file":"standards-sdk.es5.js","sources":["../../src/hcs-10/base-client.ts"],"sourcesContent":["import { Logger, LogLevel } from '../utils/logger';\nimport { Registration } from './registrations';\nimport { HCS11Client } from '../hcs-11/client';\nimport { AccountResponse, TopicResponse } from '../services/types';\nimport { TopicInfo } from '../services/types';\nimport { TransactionReceipt, PrivateKey, PublicKey } from '@hashgraph/sdk';\nimport axios from 'axios';\nimport { NetworkType } from '../utils/types';\nimport { HederaMirrorNode } from '../services';\nimport { WaitForConnectionConfirmationResponse } from './types';\nimport { HRLResolver } from '../utils/hrl-resolver';\n\nexport enum Hcs10MemoType {\n INBOUND = 'inbound',\n OUTBOUND = 'outbound',\n CONNECTION = 'connection',\n}\n\nexport interface HCS10Config {\n network: 'mainnet' | 'testnet';\n logLevel?: LogLevel;\n prettyPrint?: boolean;\n feeAmount?: number;\n}\n\nexport interface HCSMessage {\n p: 'hcs-10';\n op:\n | 'connection_request'\n | 'connection_created'\n | 'message'\n | 'close_connection';\n data: string;\n created?: Date;\n consensus_timestamp?: string;\n m?: string;\n payer: string;\n outbound_topic_id?: string;\n connection_request_id?: number;\n confirmed_request_id?: number;\n connection_topic_id?: string;\n connected_account_id?: string;\n requesting_account_id?: string;\n connection_id?: number;\n sequence_number: number;\n operator_id?: string;\n reason?: string;\n close_method?: string;\n}\n\nexport interface ProfileResponse {\n profile: any;\n topicInfo?: TopicInfo;\n success: boolean;\n error?: string;\n}\n\nexport abstract class HCS10BaseClient extends Registration {\n protected network: string;\n protected logger: Logger;\n protected mirrorNode: HederaMirrorNode;\n protected feeAmount: number;\n\n protected operatorId: string;\n\n constructor(config: HCS10Config) {\n super();\n this.network = config.network;\n this.logger = Logger.getInstance({\n level: config.logLevel || 'info',\n module: 'HCS10-BaseClient',\n prettyPrint: config.prettyPrint,\n });\n this.mirrorNode = new HederaMirrorNode(\n config.network as NetworkType,\n this.logger\n );\n this.feeAmount = config.feeAmount || 0.001;\n }\n\n abstract submitPayload(\n topicId: string,\n payload: object | string,\n submitKey?: PrivateKey,\n requiresFee?: boolean\n ): Promise<TransactionReceipt>;\n\n abstract getAccountAndSigner(): { accountId: string; signer: any };\n\n public extractTopicFromOperatorId(operatorId: string): string {\n if (!operatorId) {\n return '';\n }\n const parts = operatorId.split('@');\n if (parts.length > 0) {\n return parts[0];\n }\n return '';\n }\n\n public extractAccountFromOperatorId(operatorId: string): string {\n if (!operatorId) {\n return '';\n }\n const parts = operatorId.split('@');\n if (parts.length > 1) {\n return parts[1];\n }\n return '';\n }\n\n /**\n * Get a stream of messages from a connection topic\n * @param topicId The connection topic ID to get messages from\n * @returns A stream of filtered messages valid for connection topics\n */\n public async getMessageStream(\n topicId: string\n ): Promise<{ messages: HCSMessage[] }> {\n try {\n const messages = await this.mirrorNode.getTopicMessages(topicId);\n const validOps = ['message', 'close_connection'];\n\n const filteredMessages = messages.filter((msg) => {\n if (msg.p !== 'hcs-10' || !validOps.includes(msg.op)) {\n return false;\n }\n\n if (msg.op === 'message') {\n if (!msg.data) {\n return false;\n }\n\n if (!msg.operator_id) {\n return false;\n }\n\n if (!this.isValidOperatorId(msg.operator_id)) {\n return false;\n }\n }\n\n if (msg.op === 'close_connection') {\n if (!msg.operator_id) {\n return false;\n }\n\n if (!this.isValidOperatorId(msg.operator_id)) {\n return false;\n }\n }\n\n return true;\n });\n\n return {\n messages: filteredMessages,\n };\n } catch (error: any) {\n if (this.logger) {\n this.logger.error(`Error fetching messages: ${error.message}`);\n }\n return { messages: [] };\n }\n }\n\n /**\n * Public method to retrieve topic information using the internal mirror node client.\n *\n * @param topicId The ID of the topic to query.\n * @returns Topic information or null if not found or an error occurs.\n */\n async getPublicTopicInfo(topicId: string): Promise<TopicResponse | null> {\n try {\n return await this.mirrorNode.getTopicInfo(topicId);\n } catch (error) {\n this.logger.error(\n `Error getting public topic info for ${topicId}:`,\n error\n );\n return null;\n }\n }\n\n /**\n * Checks if a user can submit to a topic and determines if a fee is required\n * @param topicId The topic ID to check\n * @param userAccountId The account ID of the user attempting to submit\n * @returns Object with canSubmit, requiresFee, and optional reason\n */\n public async canSubmitToTopic(\n topicId: string,\n userAccountId: string\n ): Promise<{ canSubmit: boolean; requiresFee: boolean; reason?: string }> {\n try {\n const topicInfo = await this.mirrorNode.getTopicInfo(topicId);\n\n if (!topicInfo) {\n return {\n canSubmit: false,\n requiresFee: false,\n reason: 'Topic does not exist',\n };\n }\n\n if (!topicInfo.submit_key?.key) {\n return { canSubmit: true, requiresFee: false };\n }\n\n try {\n const userPublicKey = await this.mirrorNode.getPublicKey(userAccountId);\n\n if (topicInfo.submit_key._type === 'ProtobufEncoded') {\n const keyBytes = Buffer.from(topicInfo.submit_key.key, 'hex');\n const hasAccess = await this.mirrorNode.checkKeyListAccess(\n keyBytes,\n userPublicKey\n );\n\n if (hasAccess) {\n return { canSubmit: true, requiresFee: false };\n }\n } else {\n const topicSubmitKey = PublicKey.fromString(topicInfo.submit_key.key);\n if (userPublicKey.toString() === topicSubmitKey.toString()) {\n return { canSubmit: true, requiresFee: false };\n }\n }\n } catch (error) {\n this.logger.error(\n `Key validation error: ${\n error instanceof Error ? error.message : String(error)\n }`\n );\n }\n\n if (\n topicInfo.fee_schedule_key?.key &&\n topicInfo.custom_fees?.fixed_fees?.length > 0\n ) {\n return {\n canSubmit: true,\n requiresFee: true,\n reason: 'Requires fee payment via HIP-991',\n };\n }\n\n return {\n canSubmit: false,\n requiresFee: false,\n reason: 'User does not have submit permission for this topic',\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n this.logger.error(`Topic submission validation error: ${errorMessage}`);\n return {\n canSubmit: false,\n requiresFee: false,\n reason: `Error: ${errorMessage}`,\n };\n }\n }\n\n /**\n * Get all messages from a topic\n * @param topicId The topic ID to get messages from\n * @returns All messages from the topic\n */\n public async getMessages(\n topicId: string\n ): Promise<{ messages: HCSMessage[] }> {\n try {\n const messages = await this.mirrorNode.getTopicMessages(topicId);\n\n const validatedMessages = messages.filter((msg) => {\n if (msg.p !== 'hcs-10') {\n return false;\n }\n\n if (msg.op === 'message') {\n if (!msg.data) {\n return false;\n }\n\n if (msg.operator_id) {\n if (!this.isValidOperatorId(msg.operator_id)) {\n return false;\n }\n }\n }\n\n return true;\n });\n\n return {\n messages: validatedMessages,\n };\n } catch (error: any) {\n if (this.logger) {\n this.logger.error(`Error fetching messages: ${error.message}`);\n }\n return { messages: [] };\n }\n }\n\n /**\n * Requests an account from the mirror node\n * @param account The account ID to request\n * @returns The account response\n */\n public async requestAccount(account: string): Promise<AccountResponse> {\n try {\n return await this.mirrorNode.requestAccount(account);\n } catch (e) {\n this.logger.error('Failed to fetch account', e);\n throw e;\n }\n }\n\n /**\n * Retrieves the memo for an account\n * @param accountId The account ID to retrieve the memo for\n * @returns The memo\n */\n public async getAccountMemo(accountId: string): Promise<string | null> {\n return await this.mirrorNode.getAccountMemo(accountId);\n }\n\n /**\n * Retrieves the profile for an account\n * @param accountId The account ID to retrieve the profile for\n * @param disableCache Whether to disable caching of the result\n * @returns The profile\n */\n public async retrieveProfile(\n accountId: string,\n disableCache?: boolean\n ): Promise<ProfileResponse> {\n this.logger.debug(`Retrieving profile for account: ${accountId}`);\n\n const cacheKey = `${accountId}-${this.network}`;\n\n if (!disableCache) {\n const cachedProfileResponse = HCS10Cache.getInstance().get(cacheKey);\n if (cachedProfileResponse) {\n this.logger.debug(`Cache hit for profile: ${accountId}`);\n return cachedProfileResponse;\n }\n }\n try {\n const hcs11Client = new HCS11Client({\n network: this.network as 'mainnet' | 'testnet',\n auth: {\n operatorId: '0.0.0', // Read-only operations only\n },\n logLevel: 'info',\n });\n\n const profileResult = await hcs11Client.fetchProfileByAccountId(\n accountId,\n this.network\n );\n\n if (!profileResult?.success) {\n this.logger.error(\n `Failed to retrieve profile for account ID: ${accountId}`,\n profileResult?.error\n );\n return {\n profile: null,\n success: false,\n error:\n profileResult?.error ||\n `Failed to retrieve profile for account ID: ${accountId}`,\n };\n }\n\n const profile = profileResult.profile;\n let topicInfo: TopicInfo | null = null;\n\n if (\n profileResult.topicInfo?.inboundTopic &&\n profileResult.topicInfo?.outboundTopic &&\n profileResult.topicInfo?.profileTopicId\n ) {\n topicInfo = {\n inboundTopic: profileResult.topicInfo.inboundTopic,\n outboundTopic: profileResult.topicInfo.outboundTopic,\n profileTopicId: profileResult.topicInfo.profileTopicId,\n };\n }\n\n const responseToCache: ProfileResponse = {\n profile,\n topicInfo,\n success: true,\n };\n HCS10Cache.getInstance().set(cacheKey, responseToCache);\n return responseToCache;\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Failed to retrieve profile: ${error.message}`;\n this.logger.error(logMessage);\n return {\n profile: null,\n success: false,\n error: logMessage,\n };\n }\n }\n\n /**\n * @deprecated Use retrieveCommunicationTopics instead\n * @param accountId The account ID to retrieve the outbound connect topic for\n * @returns {TopicInfo} Topic Info from target profile.\n */\n public async retrieveOutboundConnectTopic(\n accountId: string\n ): Promise<TopicInfo> {\n return await this.retrieveCommunicationTopics(accountId, true);\n }\n\n /**\n * Retrieves the communication topics for an account\n * @param accountId The account ID to retrieve the communication topics for\n * @param disableCache Whether to disable caching of the result\n * @returns {TopicInfo} Topic Info from target profile.\n */\n public async retrieveCommunicationTopics(\n accountId: string,\n disableCache?: boolean\n ): Promise<TopicInfo> {\n try {\n const profileResponse = await this.retrieveProfile(\n accountId,\n disableCache\n );\n\n if (!profileResponse?.success) {\n throw new Error(profileResponse.error || 'Failed to retrieve profile');\n }\n\n const profile = profileResponse.profile;\n\n if (!profile.inboundTopicId || !profile.outboundTopicId) {\n throw new Error(\n `Invalid HCS-11 profile for HCS-10 agent: missing inboundTopicId or outboundTopicId`\n );\n }\n\n if (!profileResponse.topicInfo) {\n throw new Error(\n `TopicInfo is missing in the profile for account ${accountId}`\n );\n }\n\n return profileResponse.topicInfo;\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Failed to retrieve topic info: ${error.message}`;\n this.logger.error(logMessage);\n throw error;\n }\n }\n\n /**\n * Retrieves outbound messages for an agent\n * @param agentAccountId The account ID of the agent\n * @returns The outbound messages\n */\n public async retrieveOutboundMessages(\n agentAccountId: string\n ): Promise<HCSMessage[]> {\n try {\n const topicInfo = await this.retrieveCommunicationTopics(agentAccountId);\n if (!topicInfo) {\n this.logger.warn(\n `No outbound connect topic found for agentAccountId: ${agentAccountId}`\n );\n return [];\n }\n const response = await this.getMessages(topicInfo.outboundTopic);\n return response.messages.filter(\n (msg) =>\n msg.p === 'hcs-10' &&\n (msg.op === 'connection_request' ||\n msg.op === 'connection_created' ||\n msg.op === 'message')\n );\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Failed to retrieve outbound messages: ${error.message}`;\n this.logger.error(logMessage);\n return [];\n }\n }\n\n /**\n * Checks if a connection has been created for an agent\n * @param agentAccountId The account ID of the agent\n * @param connectionId The ID of the connection\n * @returns True if the connection has been created, false otherwise\n */\n public async hasConnectionCreated(\n agentAccountId: string,\n connectionId: number\n ): Promise<boolean> {\n try {\n const outBoundTopic = await this.retrieveCommunicationTopics(\n agentAccountId\n );\n const messages = await this.retrieveOutboundMessages(\n outBoundTopic.outboundTopic\n );\n return messages.some(\n (msg) =>\n msg.op === 'connection_created' && msg.connection_id === connectionId\n );\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Failed to check connection created: ${error.message}`;\n this.logger.error(logMessage);\n return false;\n }\n }\n\n /**\n * Gets message content, resolving any HRL references if needed\n * @param data The data string that may contain an HRL reference\n * @param forceRaw Whether to force returning raw binary data\n * @returns The resolved content\n */\n async getMessageContent(\n data: string,\n forceRaw = false\n ): Promise<string | ArrayBuffer> {\n if (!data.match(/^hcs:\\/\\/(\\d+)\\/([0-9]+\\.[0-9]+\\.[0-9]+)$/)) {\n return data;\n }\n\n try {\n const resolver = new HRLResolver(this.logger.getLevel());\n\n if (!resolver.isValidHRL(data)) {\n return data;\n }\n\n const result = await resolver.resolveHRL(data, {\n network: this.network as 'mainnet' | 'testnet',\n returnRaw: forceRaw,\n });\n\n return result.content;\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Error resolving HRL reference: ${error.message}`;\n this.logger.error(logMessage);\n throw new Error(logMessage);\n }\n }\n\n /**\n * Gets message content with its content type, resolving any HRL references if needed\n * @param data The data string that may contain an HRL reference\n * @param forceRaw Whether to force returning raw binary data\n * @returns The resolved content along with content type information\n */\n async getMessageContentWithType(\n data: string,\n forceRaw = false\n ): Promise<{\n content: string | ArrayBuffer;\n contentType: string;\n isBinary: boolean;\n }> {\n if (!data.match(/^hcs:\\/\\/(\\d+)\\/([0-9]+\\.[0-9]+\\.[0-9]+)$/)) {\n return {\n content: data,\n contentType: 'text/plain',\n isBinary: false,\n };\n }\n\n try {\n const resolver = new HRLResolver(this.logger.getLevel());\n\n return await resolver.getContentWithType(data, {\n network: this.network as 'mainnet' | 'testnet',\n returnRaw: forceRaw,\n });\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Error resolving HRL reference with type: ${error.message}`;\n this.logger.error(logMessage);\n throw new Error(logMessage);\n }\n }\n\n /**\n * Submits a connection request to an inbound topic\n * @param inboundTopicId The ID of the inbound topic\n * @param memo An optional memo for the message\n * @returns The transaction receipt\n */\n async submitConnectionRequest(\n inboundTopicId: string,\n memo: string\n ): Promise<TransactionReceipt> {\n const accountResponse = this.getAccountAndSigner();\n if (!accountResponse?.accountId) {\n throw new Error('Operator account ID is not set');\n }\n const operatorId = await this.getOperatorId();\n const accountId = accountResponse.accountId;\n\n const submissionCheck = await this.canSubmitToTopic(\n inboundTopicId,\n accountId\n );\n\n if (!submissionCheck?.canSubmit) {\n throw new Error(`Cannot submit to topic: ${submissionCheck.reason}`);\n }\n\n const inboundAccountOwner = await this.retrieveInboundAccountId(\n inboundTopicId\n );\n\n if (!inboundAccountOwner) {\n throw new Error('Failed to retrieve topic info account ID');\n }\n\n const connectionRequestMessage = {\n p: 'hcs-10',\n op: 'connection_request',\n operator_id: operatorId,\n m: memo,\n };\n\n const requiresFee = submissionCheck.requiresFee;\n const response = await this.submitPayload(\n inboundTopicId,\n connectionRequestMessage,\n undefined,\n requiresFee\n );\n\n this.logger.info(\n `Submitted connection request to topic ID: ${inboundTopicId}`\n );\n\n const outboundTopic = await this.retrieveCommunicationTopics(accountId);\n\n if (!outboundTopic) {\n throw new Error('Failed to retrieve outbound topic');\n }\n\n const responseSequenceNumber = response.topicSequenceNumber?.toNumber();\n\n if (!responseSequenceNumber) {\n throw new Error('Failed to get response sequence number');\n }\n\n const requestorOperatorId = `${inboundTopicId}@${inboundAccountOwner}`;\n\n await this.submitPayload(outboundTopic.outboundTopic, {\n ...connectionRequestMessage,\n outbound_topic_id: outboundTopic.outboundTopic,\n connection_request_id: responseSequenceNumber,\n operator_id: requestorOperatorId,\n });\n\n return response;\n }\n\n /**\n * Records an outbound connection confirmation\n * @param outboundTopicId The ID of the outbound topic\n * @param connectionRequestId The ID of the connection request\n * @param confirmedRequestId The ID of the confirmed request\n * @param connectionTopicId The ID of the connection topic\n * @param operatorId The operator ID of the original message sender.\n * @param memo An optional memo for the message\n */\n public async recordOutboundConnectionConfirmation({\n outboundTopicId,\n requestorOutboundTopicId,\n connectionRequestId,\n confirmedRequestId,\n connectionTopicId,\n operatorId,\n memo,\n }: {\n outboundTopicId: string;\n requestorOutboundTopicId: string;\n connectionRequestId: number;\n confirmedRequestId: number;\n connectionTopicId: string;\n operatorId: string;\n memo: string;\n }): Promise<TransactionReceipt> {\n const payload = {\n p: 'hcs-10',\n op: 'connection_created',\n connection_topic_id: connectionTopicId,\n outbound_topic_id: outboundTopicId,\n requestor_outbound_topic_id: requestorOutboundTopicId,\n confirmed_request_id: confirmedRequestId,\n connection_request_id: connectionRequestId,\n operator_id: operatorId,\n m: memo,\n };\n return await this.submitPayload(outboundTopicId, payload);\n }\n\n /**\n * Waits for confirmation of a connection request\n * @param inboundTopicId Inbound topic ID\n * @param connectionRequestId Connection request ID\n * @param maxAttempts Maximum number of attempts\n * @param delayMs Delay between attempts in milliseconds\n * @returns Connection confirmation details\n */\n async waitForConnectionConfirmation(\n inboundTopicId: string,\n connectionRequestId: number,\n maxAttempts = 60,\n delayMs = 2000,\n recordConfirmation = true\n ): Promise<WaitForConnectionConfirmationResponse> {\n this.logger.info(\n `Waiting for connection confirmation on inbound topic ${inboundTopicId} for request ID ${connectionRequestId}`\n );\n\n for (let attempt = 0; attempt < maxAttempts; attempt++) {\n this.logger.info(\n `Attempt ${attempt + 1}/${maxAttempts} to find connection confirmation`\n );\n const messages = await this.mirrorNode.getTopicMessages(inboundTopicId);\n\n const connectionCreatedMessages = messages.filter(\n (m) => m.op === 'connection_created'\n );\n\n this.logger.info(\n `Found ${connectionCreatedMessages.length} connection_created messages`\n );\n\n if (connectionCreatedMessages.length > 0) {\n for (const message of connectionCreatedMessages) {\n if (Number(message.connection_id) === Number(connectionRequestId)) {\n const confirmationResult = {\n connectionTopicId: message.connection_topic_id,\n sequence_number: Number(message.sequence_number),\n confirmedBy: message.operator_id,\n memo: message.m,\n };\n\n const confirmedByAccountId = this.extractAccountFromOperatorId(\n confirmationResult.confirmedBy\n );\n\n const account = this.getAccountAndSigner();\n const confirmedByConnectionTopics =\n await this.retrieveCommunicationTopics(confirmedByAccountId);\n\n const agentConnectionTopics =\n await this.retrieveCommunicationTopics(account.accountId);\n\n this.logger.info(\n 'Connection confirmation found',\n confirmationResult\n );\n\n if (recordConfirmation) {\n /**\n * Record's the confirmation of the connection request from the\n * confirmedBy account to the agent account.\n */\n await this.recordOutboundConnectionConfirmation({\n requestorOutboundTopicId:\n confirmedByConnectionTopics.outboundTopic,\n outboundTopicId: agentConnectionTopics.outboundTopic,\n connectionRequestId,\n confirmedRequestId: confirmationResult.sequence_number,\n connectionTopicId: confirmationResult.connectionTopicId,\n operatorId: confirmationResult.confirmedBy,\n memo: confirmationResult.memo || 'Connection confirmed',\n });\n }\n\n return confirmationResult;\n }\n }\n }\n\n if (attempt < maxAttempts - 1) {\n this.logger.info(\n `No matching confirmation found, waiting ${delayMs}ms before retrying...`\n );\n await new Promise((resolve) => setTimeout(resolve, delayMs));\n }\n }\n\n throw new Error(\n `Connection confirmation not found after ${maxAttempts} attempts for request ID ${connectionRequestId}`\n );\n }\n\n /**\n * Retrieves the operator ID for the current agent\n * @param disableCache Whether to disable caching of the result\n * @returns The operator ID\n */\n public async getOperatorId(disableCache?: boolean): Promise<string> {\n if (this.operatorId && !disableCache) {\n return this.operatorId;\n }\n\n const accountResponse = this.getAccountAndSigner();\n\n if (!accountResponse.accountId) {\n throw new Error('Operator ID not found');\n }\n\n const profile = await this.retrieveProfile(accountResponse.accountId);\n\n if (!profile.success) {\n throw new Error('Failed to retrieve profile');\n }\n\n const operatorId = `${profile.topicInfo?.inboundTopic}@${accountResponse.accountId}`;\n this.operatorId = operatorId;\n return operatorId;\n }\n\n /**\n * Retrieves the account ID of the owner of an inbound topic\n * @param inboundTopicId The ID of the inbound topic\n * @returns The account ID of the owner of the inbound topic\n */\n public async retrieveInboundAccountId(\n inboundTopicId: string\n ): Promise<string> {\n const topicInfo = await this.mirrorNode.getTopicInfo(inboundTopicId);\n\n if (!topicInfo?.memo) {\n throw new Error('Failed to retrieve topic info');\n }\n\n const topicInfoMemo = topicInfo.memo.toString();\n const topicInfoParts = topicInfoMemo.split(':');\n const inboundAccountOwner = topicInfoParts?.[4];\n\n if (!inboundAccountOwner) {\n throw new Error('Failed to retrieve topic info account ID');\n }\n\n return inboundAccountOwner;\n }\n\n public clearCache(): void {\n HCS10Cache.getInstance().clear();\n }\n\n /**\n * Generates a standard HCS-10 memo string.\n * @param type The type of topic memo ('inbound', 'outbound', 'connection').\n * @param options Configuration options for the memo.\n * @returns The formatted memo string.\n * @protected\n */\n protected _generateHcs10Memo(\n type: Hcs10MemoType,\n options: {\n ttl?: number;\n accountId?: string;\n inboundTopicId?: string;\n connectionId?: number;\n }\n ): string {\n const ttl = options.ttl ?? 60; // Default TTL to 60 if not provided\n\n switch (type) {\n case Hcs10MemoType.INBOUND:\n if (!options.accountId) {\n throw new Error('accountId is required for inbound memo');\n }\n return `hcs-10:0:${ttl}:0:${options.accountId}`;\n case Hcs10MemoType.OUTBOUND:\n return `hcs-10:0:${ttl}:1`;\n case Hcs10MemoType.CONNECTION:\n if (!options.inboundTopicId || options.connectionId === undefined) {\n throw new Error(\n 'inboundTopicId and connectionId are required for connection memo'\n );\n }\n return `hcs-10:1:${ttl}:2:${options.inboundTopicId}:${options.connectionId}`;\n default:\n throw new Error(`Invalid HCS-10 memo type: ${type}`);\n }\n }\n\n protected async checkRegistrationStatus(\n transactionId: string,\n network: string,\n baseUrl: string\n ): Promise<{ status: 'pending' | 'success' | 'failed' }> {\n try {\n const response = await fetch(`${baseUrl}/api/request-confirm`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'X-Network': network,\n },\n body: JSON.stringify({ transaction_id: transactionId }),\n });\n\n if (!response.ok) {\n throw new Error(\n `Failed to confirm registration: ${response.statusText}`\n );\n }\n\n return await response.json();\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Error checking registration status: ${error.message}`;\n this.logger.error(logMessage);\n throw error;\n }\n }\n\n /**\n * Validates if an operator_id follows the correct format (agentTopicId@accountId)\n * @param operatorId The operator ID to validate\n * @returns True if the format is valid, false otherwise\n */\n protected isValidOperatorId(operatorId: string): boolean {\n if (!operatorId) {\n return false;\n }\n\n const parts = operatorId.split('@');\n\n if (parts.length !== 2) {\n return false;\n }\n\n const agentTopicId = parts[0];\n const accountId = parts[1];\n\n if (!agentTopicId) {\n return false;\n }\n\n if (!accountId) {\n return false;\n }\n\n const hederaIdPattern = /^[0-9]+\\.[0-9]+\\.[0-9]+$/;\n\n if (!hederaIdPattern.test(accountId)) {\n return false;\n }\n\n if (!hederaIdPattern.test(agentTopicId)) {\n return false;\n }\n\n return true;\n }\n}\n\nexport class HCS10Cache {\n private static instance: HCS10Cache;\n private cache: Map<string, ProfileResponse>;\n private cacheExpiry: Map<string, number>;\n private readonly CACHE_TTL = 3600000;\n\n private constructor() {\n this.cache = new Map();\n this.cacheExpiry = new Map();\n }\n\n static getInstance(): HCS10Cache {\n if (!HCS10Cache.instance) {\n HCS10Cache.instance = new HCS10Cache();\n }\n return HCS10Cache.instance;\n }\n\n set(key: string, value: ProfileResponse): void {\n this.cache.set(key, value);\n this.cacheExpiry.set(key, Date.now() + this.CACHE_TTL);\n }\n\n get(key: string): ProfileResponse | undefined {\n const expiry = this.cacheExpiry.get(key);\n if (expiry && expiry > Date.now()) {\n return this.cache.get(key);\n }\n if (expiry) {\n this.cache.delete(key);\n this.cacheExpiry.delete(key);\n }\n return undefined;\n }\n\n clear(): void {\n this.cache.clear();\n this.cacheExpiry.clear();\n }\n}\n"],"names":["Hcs10MemoType"],"mappings":";;;;;;;AAYY,IAAA,kCAAAA,mBAAL;AACLA,iBAAA,SAAU,IAAA;AACVA,iBAAA,UAAW,IAAA;AACXA,iBAAA,YAAa,IAAA;AAHHA,SAAAA;AAAA,GAAA,iBAAA,CAAA,CAAA;AA6CL,MAAe,wBAAwB,aAAa;AAAA,EAQzD,YAAY,QAAqB;AACzB,UAAA;AACN,SAAK,UAAU,OAAO;AACjB,SAAA,SAAS,OAAO,YAAY;AAAA,MAC/B,OAAO,OAAO,YAAY;AAAA,MAC1B,QAAQ;AAAA,MACR,aAAa,OAAO;AAAA,IAAA,CACrB;AACD,SAAK,aAAa,IAAI;AAAA,MACpB,OAAO;AAAA,MACP,KAAK;AAAA,IACP;AACK,SAAA,YAAY,OAAO,aAAa;AAAA,EAAA;AAAA,EAYhC,2BAA2B,YAA4B;AAC5D,QAAI,CAAC,YAAY;AACR,aAAA;AAAA,IAAA;AAEH,UAAA,QAAQ,WAAW,MAAM,GAAG;AAC9B,QAAA,MAAM,SAAS,GAAG;AACpB,aAAO,MAAM,CAAC;AAAA,IAAA;AAET,WAAA;AAAA,EAAA;AAAA,EAGF,6BAA6B,YAA4B;AAC9D,QAAI,CAAC,YAAY;AACR,aAAA;AAAA,IAAA;AAEH,UAAA,QAAQ,WAAW,MAAM,GAAG;AAC9B,QAAA,MAAM,SAAS,GAAG;AACpB,aAAO,MAAM,CAAC;AAAA,I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AAGF,WAAA;AAAA,EAAA;AAEX;AAEO,MAAM,WAAW;AAAA,EAMd,cAAc;AAFtB,SAAiB,YAAY;AAGtB,SAAA,4BAAY,IAAI;AAChB,SAAA,kCAAkB,IAAI;AAAA,EAAA;AAAA,EAG7B,OAAO,cAA0B;AAC3B,QAAA,CAAC,WAAW,UAAU;AACb,iBAAA,WAAW,IAAI,WAAW;AAAA,IAAA;AAEvC,WAAO,WAAW;AAAA,EAAA;AAAA,EAGpB,IAAI,KAAa,OAA8B;AACxC,SAAA,MAAM,IAAI,KAAK,KAAK;AACzB,SAAK,YAAY,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,SAAS;AAAA,EAAA;AAAA,EAGvD,IAAI,KAA0C;AAC5C,UAAM,SAAS,KAAK,YAAY,IAAI,GAAG;AACvC,QAAI,UAAU,SAAS,KAAK,IAAA,GAAO;AAC1B,aAAA,KAAK,MAAM,IAAI,GAAG;AAAA,IAAA;AAE3B,QAAI,QAAQ;AACL,WAAA,MAAM,OAAO,GAAG;AAChB,WAAA,YAAY,OAAO,GAAG;AAAA,IAAA;AAEtB,WAAA;AAAA,EAAA;AAAA,EAGT,QAAc;AACZ,SAAK,MAAM,MAAM;AACjB,SAAK,YAAY,MAAM;AAAA,EAAA;AAE3B;"}
|
|
@@ -1,26 +1,94 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
function keccak256(_data) {
|
|
9
|
-
const data = getBytes(_data, "data");
|
|
10
|
-
return hexlify(__keccak256(data));
|
|
11
|
-
}
|
|
12
|
-
keccak256._ = _keccak256;
|
|
13
|
-
keccak256.lock = function() {
|
|
14
|
-
locked = true;
|
|
15
|
-
};
|
|
16
|
-
keccak256.register = function(func) {
|
|
17
|
-
if (locked) {
|
|
18
|
-
throw new TypeError("keccak256 is locked");
|
|
1
|
+
import { assert, assertArgument } from "./standards-sdk.es49.js";
|
|
2
|
+
function _getBytes(value, name, copy) {
|
|
3
|
+
if (value instanceof Uint8Array) {
|
|
4
|
+
if (copy) {
|
|
5
|
+
return new Uint8Array(value);
|
|
6
|
+
}
|
|
7
|
+
return value;
|
|
19
8
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
9
|
+
if (typeof value === "string" && value.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)) {
|
|
10
|
+
const result = new Uint8Array((value.length - 2) / 2);
|
|
11
|
+
let offset = 2;
|
|
12
|
+
for (let i = 0; i < result.length; i++) {
|
|
13
|
+
result[i] = parseInt(value.substring(offset, offset + 2), 16);
|
|
14
|
+
offset += 2;
|
|
15
|
+
}
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
assertArgument(false, "invalid BytesLike value", name || "value", value);
|
|
19
|
+
}
|
|
20
|
+
function getBytes(value, name) {
|
|
21
|
+
return _getBytes(value, name, false);
|
|
22
|
+
}
|
|
23
|
+
function getBytesCopy(value, name) {
|
|
24
|
+
return _getBytes(value, name, true);
|
|
25
|
+
}
|
|
26
|
+
function isHexString(value, length) {
|
|
27
|
+
if (typeof value !== "string" || !value.match(/^0x[0-9A-Fa-f]*$/)) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
if (typeof length === "number" && value.length !== 2 + 2 * length) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
if (length === true && value.length % 2 !== 0) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
const HexCharacters = "0123456789abcdef";
|
|
39
|
+
function hexlify(data) {
|
|
40
|
+
const bytes = getBytes(data);
|
|
41
|
+
let result = "0x";
|
|
42
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
43
|
+
const v = bytes[i];
|
|
44
|
+
result += HexCharacters[(v & 240) >> 4] + HexCharacters[v & 15];
|
|
45
|
+
}
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
function concat(datas) {
|
|
49
|
+
return "0x" + datas.map((d) => hexlify(d).substring(2)).join("");
|
|
50
|
+
}
|
|
51
|
+
function dataSlice(data, start, end) {
|
|
52
|
+
const bytes = getBytes(data);
|
|
53
|
+
if (end != null && end > bytes.length) {
|
|
54
|
+
assert(false, "cannot slice beyond data bounds", "BUFFER_OVERRUN", {
|
|
55
|
+
buffer: bytes,
|
|
56
|
+
length: bytes.length,
|
|
57
|
+
offset: end
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return hexlify(bytes.slice(start == null ? 0 : start, end == null ? bytes.length : end));
|
|
61
|
+
}
|
|
62
|
+
function zeroPad(data, length, left) {
|
|
63
|
+
const bytes = getBytes(data);
|
|
64
|
+
assert(length >= bytes.length, "padding exceeds data length", "BUFFER_OVERRUN", {
|
|
65
|
+
buffer: new Uint8Array(bytes),
|
|
66
|
+
length,
|
|
67
|
+
offset: length + 1
|
|
68
|
+
});
|
|
69
|
+
const result = new Uint8Array(length);
|
|
70
|
+
result.fill(0);
|
|
71
|
+
if (left) {
|
|
72
|
+
result.set(bytes, length - bytes.length);
|
|
73
|
+
} else {
|
|
74
|
+
result.set(bytes, 0);
|
|
75
|
+
}
|
|
76
|
+
return hexlify(result);
|
|
77
|
+
}
|
|
78
|
+
function zeroPadValue(data, length) {
|
|
79
|
+
return zeroPad(data, length, true);
|
|
80
|
+
}
|
|
81
|
+
function zeroPadBytes(data, length) {
|
|
82
|
+
return zeroPad(data, length, false);
|
|
83
|
+
}
|
|
23
84
|
export {
|
|
24
|
-
|
|
85
|
+
concat,
|
|
86
|
+
dataSlice,
|
|
87
|
+
getBytes,
|
|
88
|
+
getBytesCopy,
|
|
89
|
+
hexlify,
|
|
90
|
+
isHexString,
|
|
91
|
+
zeroPadBytes,
|
|
92
|
+
zeroPadValue
|
|
25
93
|
};
|
|
26
94
|
//# sourceMappingURL=standards-sdk.es50.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-sdk.es50.js","sources":["../../node_modules/ethers/lib.esm/
|
|
1
|
+
{"version":3,"file":"standards-sdk.es50.js","sources":["../../node_modules/ethers/lib.esm/utils/data.js"],"sourcesContent":["/**\n * Some data helpers.\n *\n *\n * @_subsection api/utils:Data Helpers [about-data]\n */\nimport { assert, assertArgument } from \"./errors.js\";\nfunction _getBytes(value, name, copy) {\n if (value instanceof Uint8Array) {\n if (copy) {\n return new Uint8Array(value);\n }\n return value;\n }\n if (typeof (value) === \"string\" && value.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)) {\n const result = new Uint8Array((value.length - 2) / 2);\n let offset = 2;\n for (let i = 0; i < result.length; i++) {\n result[i] = parseInt(value.substring(offset, offset + 2), 16);\n offset += 2;\n }\n return result;\n }\n assertArgument(false, \"invalid BytesLike value\", name || \"value\", value);\n}\n/**\n * Get a typed Uint8Array for %%value%%. If already a Uint8Array\n * the original %%value%% is returned; if a copy is required use\n * [[getBytesCopy]].\n *\n * @see: getBytesCopy\n */\nexport function getBytes(value, name) {\n return _getBytes(value, name, false);\n}\n/**\n * Get a typed Uint8Array for %%value%%, creating a copy if necessary\n * to prevent any modifications of the returned value from being\n * reflected elsewhere.\n *\n * @see: getBytes\n */\nexport function getBytesCopy(value, name) {\n return _getBytes(value, name, true);\n}\n/**\n * Returns true if %%value%% is a valid [[HexString]].\n *\n * If %%length%% is ``true`` or a //number//, it also checks that\n * %%value%% is a valid [[DataHexString]] of %%length%% (if a //number//)\n * bytes of data (e.g. ``0x1234`` is 2 bytes).\n */\nexport function isHexString(value, length) {\n if (typeof (value) !== \"string\" || !value.match(/^0x[0-9A-Fa-f]*$/)) {\n return false;\n }\n if (typeof (length) === \"number\" && value.length !== 2 + 2 * length) {\n return false;\n }\n if (length === true && (value.length % 2) !== 0) {\n return false;\n }\n return true;\n}\n/**\n * Returns true if %%value%% is a valid representation of arbitrary\n * data (i.e. a valid [[DataHexString]] or a Uint8Array).\n */\nexport function isBytesLike(value) {\n return (isHexString(value, true) || (value instanceof Uint8Array));\n}\nconst HexCharacters = \"0123456789abcdef\";\n/**\n * Returns a [[DataHexString]] representation of %%data%%.\n */\nexport function hexlify(data) {\n const bytes = getBytes(data);\n let result = \"0x\";\n for (let i = 0; i < bytes.length; i++) {\n const v = bytes[i];\n result += HexCharacters[(v & 0xf0) >> 4] + HexCharacters[v & 0x0f];\n }\n return result;\n}\n/**\n * Returns a [[DataHexString]] by concatenating all values\n * within %%data%%.\n */\nexport function concat(datas) {\n return \"0x\" + datas.map((d) => hexlify(d).substring(2)).join(\"\");\n}\n/**\n * Returns the length of %%data%%, in bytes.\n */\nexport function dataLength(data) {\n if (isHexString(data, true)) {\n return (data.length - 2) / 2;\n }\n return getBytes(data).length;\n}\n/**\n * Returns a [[DataHexString]] by slicing %%data%% from the %%start%%\n * offset to the %%end%% offset.\n *\n * By default %%start%% is 0 and %%end%% is the length of %%data%%.\n */\nexport function dataSlice(data, start, end) {\n const bytes = getBytes(data);\n if (end != null && end > bytes.length) {\n assert(false, \"cannot slice beyond data bounds\", \"BUFFER_OVERRUN\", {\n buffer: bytes, length: bytes.length, offset: end\n });\n }\n return hexlify(bytes.slice((start == null) ? 0 : start, (end == null) ? bytes.length : end));\n}\n/**\n * Return the [[DataHexString]] result by stripping all **leading**\n ** zero bytes from %%data%%.\n */\nexport function stripZerosLeft(data) {\n let bytes = hexlify(data).substring(2);\n while (bytes.startsWith(\"00\")) {\n bytes = bytes.substring(2);\n }\n return \"0x\" + bytes;\n}\nfunction zeroPad(data, length, left) {\n const bytes = getBytes(data);\n assert(length >= bytes.length, \"padding exceeds data length\", \"BUFFER_OVERRUN\", {\n buffer: new Uint8Array(bytes),\n length: length,\n offset: length + 1\n });\n const result = new Uint8Array(length);\n result.fill(0);\n if (left) {\n result.set(bytes, length - bytes.length);\n }\n else {\n result.set(bytes, 0);\n }\n return hexlify(result);\n}\n/**\n * Return the [[DataHexString]] of %%data%% padded on the **left**\n * to %%length%% bytes.\n *\n * If %%data%% already exceeds %%length%%, a [[BufferOverrunError]] is\n * thrown.\n *\n * This pads data the same as **values** are in Solidity\n * (e.g. ``uint128``).\n */\nexport function zeroPadValue(data, length) {\n return zeroPad(data, length, true);\n}\n/**\n * Return the [[DataHexString]] of %%data%% padded on the **right**\n * to %%length%% bytes.\n *\n * If %%data%% already exceeds %%length%%, a [[BufferOverrunError]] is\n * thrown.\n *\n * This pads data the same as **bytes** are in Solidity\n * (e.g. ``bytes16``).\n */\nexport function zeroPadBytes(data, length) {\n return zeroPad(data, length, false);\n}\n//# sourceMappingURL=data.js.map"],"names":[],"mappings":";AAOA,SAAS,UAAU,OAAO,MAAM,MAAM;AAClC,MAAI,iBAAiB,YAAY;AAC7B,QAAI,MAAM;AACN,aAAO,IAAI,WAAW,KAAK;AAAA,IACvC;AACQ,WAAO;AAAA,EACf;AACI,MAAI,OAAQ,UAAW,YAAY,MAAM,MAAM,4BAA4B,GAAG;AAC1E,UAAM,SAAS,IAAI,YAAY,MAAM,SAAS,KAAK,CAAC;AACpD,QAAI,SAAS;AACb,aAAS,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;AACpC,aAAO,CAAC,IAAI,SAAS,MAAM,UAAU,QAAQ,SAAS,CAAC,GAAG,EAAE;AAC5D,gBAAU;AAAA,IACtB;AACQ,WAAO;AAAA,EACf;AACI,iBAAe,OAAO,2BAA2B,QAAQ,SAAS,KAAK;AAC3E;AAQO,SAAS,SAAS,OAAO,MAAM;AAClC,SAAO,UAAU,OAAO,MAAM,KAAK;AACvC;AAQO,SAAS,aAAa,OAAO,MAAM;AACtC,SAAO,UAAU,OAAO,MAAM,IAAI;AACtC;AAQO,SAAS,YAAY,OAAO,QAAQ;AACvC,MAAI,OAAQ,UAAW,YAAY,CAAC,MAAM,MAAM,kBAAkB,GAAG;AACjE,WAAO;AAAA,EACf;AACI,MAAI,OAAQ,WAAY,YAAY,MAAM,WAAW,IAAI,IAAI,QAAQ;AACjE,WAAO;AAAA,EACf;AACI,MAAI,WAAW,QAAS,MAAM,SAAS,M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QAAQ;AACvC,SAAO,QAAQ,MAAM,QAAQ,IAAI;AACrC;AAWO,SAAS,aAAa,MAAM,QAAQ;AACvC,SAAO,QAAQ,MAAM,QAAQ,KAAK;AACtC;","x_google_ignoreList":[0]}
|
|
@@ -1,151 +1,87 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { keccak256 } from "./standards-sdk.es55.js";
|
|
2
|
+
import { assertArgument } from "./standards-sdk.es49.js";
|
|
3
|
+
import { getBytes } from "./standards-sdk.es50.js";
|
|
4
|
+
const BN_0 = BigInt(0);
|
|
5
|
+
const BN_36 = BigInt(36);
|
|
6
|
+
function getChecksumAddress(address) {
|
|
7
|
+
address = address.toLowerCase();
|
|
8
|
+
const chars = address.substring(2).split("");
|
|
9
|
+
const expanded = new Uint8Array(40);
|
|
10
|
+
for (let i = 0; i < 40; i++) {
|
|
11
|
+
expanded[i] = chars[i].charCodeAt(0);
|
|
6
12
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const HEX = "0123456789abcdef";
|
|
12
|
-
let result = "0x";
|
|
13
|
-
for (let i = 0; i < value.length; i++) {
|
|
14
|
-
result += HEX[value[i] >> 4];
|
|
15
|
-
result += HEX[value[i] & 15];
|
|
13
|
+
const hashed = getBytes(keccak256(expanded));
|
|
14
|
+
for (let i = 0; i < 40; i += 2) {
|
|
15
|
+
if (hashed[i >> 1] >> 4 >= 8) {
|
|
16
|
+
chars[i] = chars[i].toUpperCase();
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (typeof value === "object" && typeof value.toJSON === "function") {
|
|
20
|
-
return stringify(value.toJSON());
|
|
21
|
-
}
|
|
22
|
-
switch (typeof value) {
|
|
23
|
-
case "boolean":
|
|
24
|
-
case "symbol":
|
|
25
|
-
return value.toString();
|
|
26
|
-
case "bigint":
|
|
27
|
-
return BigInt(value).toString();
|
|
28
|
-
case "number":
|
|
29
|
-
return value.toString();
|
|
30
|
-
case "string":
|
|
31
|
-
return JSON.stringify(value);
|
|
32
|
-
case "object": {
|
|
33
|
-
const keys = Object.keys(value);
|
|
34
|
-
keys.sort();
|
|
35
|
-
return "{ " + keys.map((k) => `${stringify(k)}: ${stringify(value[k])}`).join(", ") + " }";
|
|
18
|
+
if ((hashed[i >> 1] & 15) >= 8) {
|
|
19
|
+
chars[i + 1] = chars[i + 1].toUpperCase();
|
|
36
20
|
}
|
|
37
21
|
}
|
|
38
|
-
return
|
|
22
|
+
return "0x" + chars.join("");
|
|
39
23
|
}
|
|
40
|
-
|
|
41
|
-
|
|
24
|
+
const ibanLookup = {};
|
|
25
|
+
for (let i = 0; i < 10; i++) {
|
|
26
|
+
ibanLookup[String(i)] = String(i);
|
|
42
27
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
{
|
|
46
|
-
const details = [];
|
|
47
|
-
if (info) {
|
|
48
|
-
if ("message" in info || "code" in info || "name" in info) {
|
|
49
|
-
throw new Error(`value will overwrite populated values: ${stringify(info)}`);
|
|
50
|
-
}
|
|
51
|
-
for (const key in info) {
|
|
52
|
-
if (key === "shortMessage") {
|
|
53
|
-
continue;
|
|
54
|
-
}
|
|
55
|
-
const value = info[key];
|
|
56
|
-
details.push(key + "=" + stringify(value));
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
details.push(`code=${code}`);
|
|
60
|
-
details.push(`version=${version}`);
|
|
61
|
-
if (details.length) {
|
|
62
|
-
message += " (" + details.join(", ") + ")";
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
let error;
|
|
66
|
-
switch (code) {
|
|
67
|
-
case "INVALID_ARGUMENT":
|
|
68
|
-
error = new TypeError(message);
|
|
69
|
-
break;
|
|
70
|
-
case "NUMERIC_FAULT":
|
|
71
|
-
case "BUFFER_OVERRUN":
|
|
72
|
-
error = new RangeError(message);
|
|
73
|
-
break;
|
|
74
|
-
default:
|
|
75
|
-
error = new Error(message);
|
|
76
|
-
}
|
|
77
|
-
defineProperties(error, { code });
|
|
78
|
-
if (info) {
|
|
79
|
-
Object.assign(error, info);
|
|
80
|
-
}
|
|
81
|
-
if (error.shortMessage == null) {
|
|
82
|
-
defineProperties(error, { shortMessage });
|
|
83
|
-
}
|
|
84
|
-
return error;
|
|
28
|
+
for (let i = 0; i < 26; i++) {
|
|
29
|
+
ibanLookup[String.fromCharCode(65 + i)] = String(10 + i);
|
|
85
30
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
31
|
+
const safeDigits = 15;
|
|
32
|
+
function ibanChecksum(address) {
|
|
33
|
+
address = address.toUpperCase();
|
|
34
|
+
address = address.substring(4) + address.substring(0, 2) + "00";
|
|
35
|
+
let expanded = address.split("").map((c) => {
|
|
36
|
+
return ibanLookup[c];
|
|
37
|
+
}).join("");
|
|
38
|
+
while (expanded.length >= safeDigits) {
|
|
39
|
+
let block = expanded.substring(0, safeDigits);
|
|
40
|
+
expanded = parseInt(block, 10) % 97 + expanded.substring(block.length);
|
|
89
41
|
}
|
|
42
|
+
let checksum = String(98 - parseInt(expanded, 10) % 97);
|
|
43
|
+
while (checksum.length < 2) {
|
|
44
|
+
checksum = "0" + checksum;
|
|
45
|
+
}
|
|
46
|
+
return checksum;
|
|
90
47
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
message = "";
|
|
48
|
+
const Base36 = function() {
|
|
49
|
+
const result = {};
|
|
50
|
+
for (let i = 0; i < 36; i++) {
|
|
51
|
+
const key = "0123456789abcdefghijklmnopqrstuvwxyz"[i];
|
|
52
|
+
result[key] = BigInt(i);
|
|
97
53
|
}
|
|
98
|
-
|
|
99
|
-
|
|
54
|
+
return result;
|
|
55
|
+
}();
|
|
56
|
+
function fromBase36(value) {
|
|
57
|
+
value = value.toLowerCase();
|
|
58
|
+
let result = BN_0;
|
|
59
|
+
for (let i = 0; i < value.length; i++) {
|
|
60
|
+
result = result * BN_36 + Base36[value[i]];
|
|
100
61
|
}
|
|
101
|
-
|
|
102
|
-
count,
|
|
103
|
-
expectedCount
|
|
104
|
-
});
|
|
105
|
-
assert(count <= expectedCount, "too many arguments" + message, "UNEXPECTED_ARGUMENT", {
|
|
106
|
-
count,
|
|
107
|
-
expectedCount
|
|
108
|
-
});
|
|
62
|
+
return result;
|
|
109
63
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
64
|
+
function getAddress(address) {
|
|
65
|
+
assertArgument(typeof address === "string", "invalid address", "address", address);
|
|
66
|
+
if (address.match(/^(0x)?[0-9a-fA-F]{40}$/)) {
|
|
67
|
+
if (!address.startsWith("0x")) {
|
|
68
|
+
address = "0x" + address;
|
|
114
69
|
}
|
|
115
|
-
;
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
const expected = String.fromCharCode(101, 769);
|
|
119
|
-
if (check !== expected) {
|
|
120
|
-
throw new Error("broken");
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
accum.push(form);
|
|
124
|
-
} catch (error) {
|
|
125
|
-
}
|
|
126
|
-
return accum;
|
|
127
|
-
}, []);
|
|
128
|
-
function assertPrivate(givenGuard, guard, className) {
|
|
129
|
-
if (className == null) {
|
|
130
|
-
className = "";
|
|
70
|
+
const result = getChecksumAddress(address);
|
|
71
|
+
assertArgument(!address.match(/([A-F].*[a-f])|([a-f].*[A-F])/) || result === address, "bad address checksum", "address", address);
|
|
72
|
+
return result;
|
|
131
73
|
}
|
|
132
|
-
if (
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
74
|
+
if (address.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) {
|
|
75
|
+
assertArgument(address.substring(2, 4) === ibanChecksum(address), "bad icap checksum", "address", address);
|
|
76
|
+
let result = fromBase36(address.substring(4)).toString(16);
|
|
77
|
+
while (result.length < 40) {
|
|
78
|
+
result = "0" + result;
|
|
137
79
|
}
|
|
138
|
-
|
|
139
|
-
operation
|
|
140
|
-
});
|
|
80
|
+
return getChecksumAddress("0x" + result);
|
|
141
81
|
}
|
|
82
|
+
assertArgument(false, "invalid address", "address", address);
|
|
142
83
|
}
|
|
143
84
|
export {
|
|
144
|
-
|
|
145
|
-
assertArgument,
|
|
146
|
-
assertArgumentCount,
|
|
147
|
-
assertPrivate,
|
|
148
|
-
isError,
|
|
149
|
-
makeError
|
|
85
|
+
getAddress
|
|
150
86
|
};
|
|
151
87
|
//# sourceMappingURL=standards-sdk.es51.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-sdk.es51.js","sources":["../../node_modules/ethers/lib.esm/utils/errors.js"],"sourcesContent":["/**\n * All errors in ethers include properties to ensure they are both\n * human-readable (i.e. ``.message``) and machine-readable (i.e. ``.code``).\n *\n * The [[isError]] function can be used to check the error ``code`` and\n * provide a type guard for the properties present on that error interface.\n *\n * @_section: api/utils/errors:Errors [about-errors]\n */\nimport { version } from \"../_version.js\";\nimport { defineProperties } from \"./properties.js\";\nfunction stringify(value) {\n if (value == null) {\n return \"null\";\n }\n if (Array.isArray(value)) {\n return \"[ \" + (value.map(stringify)).join(\", \") + \" ]\";\n }\n if (value instanceof Uint8Array) {\n const HEX = \"0123456789abcdef\";\n let result = \"0x\";\n for (let i = 0; i < value.length; i++) {\n result += HEX[value[i] >> 4];\n result += HEX[value[i] & 0xf];\n }\n return result;\n }\n if (typeof (value) === \"object\" && typeof (value.toJSON) === \"function\") {\n return stringify(value.toJSON());\n }\n switch (typeof (value)) {\n case \"boolean\":\n case \"symbol\":\n return value.toString();\n case \"bigint\":\n return BigInt(value).toString();\n case \"number\":\n return (value).toString();\n case \"string\":\n return JSON.stringify(value);\n case \"object\": {\n const keys = Object.keys(value);\n keys.sort();\n return \"{ \" + keys.map((k) => `${stringify(k)}: ${stringify(value[k])}`).join(\", \") + \" }\";\n }\n }\n return `[ COULD NOT SERIALIZE ]`;\n}\n/**\n * Returns true if the %%error%% matches an error thrown by ethers\n * that matches the error %%code%%.\n *\n * In TypeScript environments, this can be used to check that %%error%%\n * matches an EthersError type, which means the expected properties will\n * be set.\n *\n * @See [ErrorCodes](api:ErrorCode)\n * @example\n * try {\n * // code....\n * } catch (e) {\n * if (isError(e, \"CALL_EXCEPTION\")) {\n * // The Type Guard has validated this object\n * console.log(e.data);\n * }\n * }\n */\nexport function isError(error, code) {\n return (error && error.code === code);\n}\n/**\n * Returns true if %%error%% is a [[CallExceptionError].\n */\nexport function isCallException(error) {\n return isError(error, \"CALL_EXCEPTION\");\n}\n/**\n * Returns a new Error configured to the format ethers emits errors, with\n * the %%message%%, [[api:ErrorCode]] %%code%% and additional properties\n * for the corresponding EthersError.\n *\n * Each error in ethers includes the version of ethers, a\n * machine-readable [[ErrorCode]], and depending on %%code%%, additional\n * required properties. The error message will also include the %%message%%,\n * ethers version, %%code%% and all additional properties, serialized.\n */\nexport function makeError(message, code, info) {\n let shortMessage = message;\n {\n const details = [];\n if (info) {\n if (\"message\" in info || \"code\" in info || \"name\" in info) {\n throw new Error(`value will overwrite populated values: ${stringify(info)}`);\n }\n for (const key in info) {\n if (key === \"shortMessage\") {\n continue;\n }\n const value = (info[key]);\n // try {\n details.push(key + \"=\" + stringify(value));\n // } catch (error: any) {\n // console.log(\"MMM\", error.message);\n // details.push(key + \"=[could not serialize object]\");\n // }\n }\n }\n details.push(`code=${code}`);\n details.push(`version=${version}`);\n if (details.length) {\n message += \" (\" + details.join(\", \") + \")\";\n }\n }\n let error;\n switch (code) {\n case \"INVALID_ARGUMENT\":\n error = new TypeError(message);\n break;\n case \"NUMERIC_FAULT\":\n case \"BUFFER_OVERRUN\":\n error = new RangeError(message);\n break;\n default:\n error = new Error(message);\n }\n defineProperties(error, { code });\n if (info) {\n Object.assign(error, info);\n }\n if (error.shortMessage == null) {\n defineProperties(error, { shortMessage });\n }\n return error;\n}\n/**\n * Throws an EthersError with %%message%%, %%code%% and additional error\n * %%info%% when %%check%% is falsish..\n *\n * @see [[api:makeError]]\n */\nexport function assert(check, message, code, info) {\n if (!check) {\n throw makeError(message, code, info);\n }\n}\n/**\n * A simple helper to simply ensuring provided arguments match expected\n * constraints, throwing if not.\n *\n * In TypeScript environments, the %%check%% has been asserted true, so\n * any further code does not need additional compile-time checks.\n */\nexport function assertArgument(check, message, name, value) {\n assert(check, message, \"INVALID_ARGUMENT\", { argument: name, value: value });\n}\nexport function assertArgumentCount(count, expectedCount, message) {\n if (message == null) {\n message = \"\";\n }\n if (message) {\n message = \": \" + message;\n }\n assert(count >= expectedCount, \"missing argument\" + message, \"MISSING_ARGUMENT\", {\n count: count,\n expectedCount: expectedCount\n });\n assert(count <= expectedCount, \"too many arguments\" + message, \"UNEXPECTED_ARGUMENT\", {\n count: count,\n expectedCount: expectedCount\n });\n}\nconst _normalizeForms = [\"NFD\", \"NFC\", \"NFKD\", \"NFKC\"].reduce((accum, form) => {\n try {\n // General test for normalize\n /* c8 ignore start */\n if (\"test\".normalize(form) !== \"test\") {\n throw new Error(\"bad\");\n }\n ;\n /* c8 ignore stop */\n if (form === \"NFD\") {\n const check = String.fromCharCode(0xe9).normalize(\"NFD\");\n const expected = String.fromCharCode(0x65, 0x0301);\n /* c8 ignore start */\n if (check !== expected) {\n throw new Error(\"broken\");\n }\n /* c8 ignore stop */\n }\n accum.push(form);\n }\n catch (error) { }\n return accum;\n}, []);\n/**\n * Throws if the normalization %%form%% is not supported.\n */\nexport function assertNormalize(form) {\n assert(_normalizeForms.indexOf(form) >= 0, \"platform missing String.prototype.normalize\", \"UNSUPPORTED_OPERATION\", {\n operation: \"String.prototype.normalize\", info: { form }\n });\n}\n/**\n * Many classes use file-scoped values to guard the constructor,\n * making it effectively private. This facilitates that pattern\n * by ensuring the %%givenGaurd%% matches the file-scoped %%guard%%,\n * throwing if not, indicating the %%className%% if provided.\n */\nexport function assertPrivate(givenGuard, guard, className) {\n if (className == null) {\n className = \"\";\n }\n if (givenGuard !== guard) {\n let method = className, operation = \"new\";\n if (className) {\n method += \".\";\n operation += \" \" + className;\n }\n assert(false, `private constructor; use ${method}from* methods`, \"UNSUPPORTED_OPERATION\", {\n operation\n });\n }\n}\n//# sourceMappingURL=errors.js.map"],"names":[],"mappings":";;AAWA,SAAS,UAAU,OAAO;AACtB,MAAI,SAAS,MAAM;AACf,WAAO;AAAA,EACf;AACI,MAAI,MAAM,QAAQ,KAAK,GAAG;AACtB,WAAO,OAAQ,MAAM,IAAI,SAAS,EAAG,KAAK,IAAI,IAAI;AAAA,EAC1D;AACI,MAAI,iBAAiB,YAAY;AAC7B,UAAM,MAAM;AACZ,QAAI,SAAS;AACb,aAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACnC,gBAAU,IAAI,MAAM,CAAC,KAAK,CAAC;AAC3B,gBAAU,IAAI,MAAM,CAAC,IAAI,EAAG;AAAA,IACxC;AACQ,WAAO;AAAA,EACf;AACI,MAAI,OAAQ,UAAW,YAAY,OAAQ,MAAM,WAAY,YAAY;AACrE,WAAO,UAAU,MAAM,QAAQ;AAAA,EACvC;AACI,UAAQ,OAAQ,OAAM;AAAA,IAClB,KAAK;AAAA,IACL,KAAK;AACD,aAAO,MAAM,SAAU;AAAA,IAC3B,KAAK;AACD,aAAO,OAAO,KAAK,EAAE,SAAU;AAAA,IACnC,KAAK;AACD,aAAQ,MAAO,SAAU;AAAA,IAC7B,KAAK;AACD,aAAO,KAAK,UAAU,KAAK;AAAA,IAC/B,KAAK,UAAU;AACX,YAAM,OAAO,OAAO,KAAK,KAAK;AAC9B,WAAK,KAAM;AACX,aAAO,OAAO,KAAK,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,CAAC,KAAK,UAAU,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,KAAK,IAAI,IAAI;AAAA,IAClG;AAAA,EACA;AACI,SAAO;AACX;AAoBO,SAAS,QAAQ,OAAO,MAAM;AACjC,SAAQ,SAAS,MAAM,SAAS;AACpC;AAiBO,SAAS,UAAU,SAAS,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cAAU;AAAA,EAClB;AACI,MAAI,SAAS;AACT,cAAU,OAAO;AAAA,EACzB;AACI,SAAO,SAAS,eAAe,qBAAqB,SAAS,oBAAoB;AAAA,IAC7E;AAAA,IACA;AAAA,EACR,CAAK;AACD,SAAO,SAAS,eAAe,uBAAuB,SAAS,uBAAuB;AAAA,IAClF;AAAA,IACA;AAAA,EACR,CAAK;AACL;AACwB,CAAC,OAAO,OAAO,QAAQ,MAAM,EAAE,OAAO,CAAC,OAAO,SAAS;AAC3E,MAAI;AAGA,QAAI,OAAO,UAAU,IAAI,MAAM,QAAQ;AACnC,YAAM,IAAI,MAAM,KAAK;AAAA,IACjC;AACQ;AAEA,QAAI,SAAS,OAAO;AAChB,YAAM,QAAQ,OAAO,aAAa,GAAI,EAAE,UAAU,KAAK;AACvD,YAAM,WAAW,OAAO,aAAa,KAAM,GAAM;AAEjD,UAAI,UAAU,UAAU;AACpB,cAAM,IAAI,MAAM,QAAQ;AAAA,MACxC;AAAA,IAEA;AACQ,UAAM,KAAK,IAAI;AAAA,EACvB,SACW,OAAO;AAAA,EAAA;AACd,SAAO;AACX,GAAG,CAAE,CAAA;AAeE,SAAS,cAAc,YAAY,OAAO,WAAW;AACxD,MAAI,aAAa,MAAM;AACnB,gBAAY;AAAA,EACpB;AACI,MAAI,eAAe,OAAO;AACtB,QAAI,SAAS,WAAW,YAAY;AACpC,QAAI,WAAW;AACX,gBAAU;AACV,mBAAa,MAAM;AAAA,IAC/B;AACQ,WAAO,OAAO,4BAA4B,MAAM,iBAAiB,yBAAyB;AAAA,MACtF;AAAA,IACZ,CAAS;AAAA,EACT;AACA;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"standards-sdk.es51.js","sources":["../../node_modules/ethers/lib.esm/address/address.js"],"sourcesContent":["import { keccak256 } from \"../crypto/index.js\";\nimport { getBytes, assertArgument } from \"../utils/index.js\";\nconst BN_0 = BigInt(0);\nconst BN_36 = BigInt(36);\nfunction getChecksumAddress(address) {\n // if (!isHexString(address, 20)) {\n // logger.throwArgumentError(\"invalid address\", \"address\", address);\n // }\n address = address.toLowerCase();\n const chars = address.substring(2).split(\"\");\n const expanded = new Uint8Array(40);\n for (let i = 0; i < 40; i++) {\n expanded[i] = chars[i].charCodeAt(0);\n }\n const hashed = getBytes(keccak256(expanded));\n for (let i = 0; i < 40; i += 2) {\n if ((hashed[i >> 1] >> 4) >= 8) {\n chars[i] = chars[i].toUpperCase();\n }\n if ((hashed[i >> 1] & 0x0f) >= 8) {\n chars[i + 1] = chars[i + 1].toUpperCase();\n }\n }\n return \"0x\" + chars.join(\"\");\n}\n// See: https://en.wikipedia.org/wiki/International_Bank_Account_Number\n// Create lookup table\nconst ibanLookup = {};\nfor (let i = 0; i < 10; i++) {\n ibanLookup[String(i)] = String(i);\n}\nfor (let i = 0; i < 26; i++) {\n ibanLookup[String.fromCharCode(65 + i)] = String(10 + i);\n}\n// How many decimal digits can we process? (for 64-bit float, this is 15)\n// i.e. Math.floor(Math.log10(Number.MAX_SAFE_INTEGER));\nconst safeDigits = 15;\nfunction ibanChecksum(address) {\n address = address.toUpperCase();\n address = address.substring(4) + address.substring(0, 2) + \"00\";\n let expanded = address.split(\"\").map((c) => { return ibanLookup[c]; }).join(\"\");\n // Javascript can handle integers safely up to 15 (decimal) digits\n while (expanded.length >= safeDigits) {\n let block = expanded.substring(0, safeDigits);\n expanded = parseInt(block, 10) % 97 + expanded.substring(block.length);\n }\n let checksum = String(98 - (parseInt(expanded, 10) % 97));\n while (checksum.length < 2) {\n checksum = \"0\" + checksum;\n }\n return checksum;\n}\n;\nconst Base36 = (function () {\n ;\n const result = {};\n for (let i = 0; i < 36; i++) {\n const key = \"0123456789abcdefghijklmnopqrstuvwxyz\"[i];\n result[key] = BigInt(i);\n }\n return result;\n})();\nfunction fromBase36(value) {\n value = value.toLowerCase();\n let result = BN_0;\n for (let i = 0; i < value.length; i++) {\n result = result * BN_36 + Base36[value[i]];\n }\n return result;\n}\n/**\n * Returns a normalized and checksumed address for %%address%%.\n * This accepts non-checksum addresses, checksum addresses and\n * [[getIcapAddress]] formats.\n *\n * The checksum in Ethereum uses the capitalization (upper-case\n * vs lower-case) of the characters within an address to encode\n * its checksum, which offers, on average, a checksum of 15-bits.\n *\n * If %%address%% contains both upper-case and lower-case, it is\n * assumed to already be a checksum address and its checksum is\n * validated, and if the address fails its expected checksum an\n * error is thrown.\n *\n * If you wish the checksum of %%address%% to be ignore, it should\n * be converted to lower-case (i.e. ``.toLowercase()``) before\n * being passed in. This should be a very rare situation though,\n * that you wish to bypass the safegaurds in place to protect\n * against an address that has been incorrectly copied from another\n * source.\n *\n * @example:\n * // Adds the checksum (via upper-casing specific letters)\n * getAddress(\"0x8ba1f109551bd432803012645ac136ddd64dba72\")\n * //_result:\n *\n * // Converts ICAP address and adds checksum\n * getAddress(\"XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK36\");\n * //_result:\n *\n * // Throws an error if an address contains mixed case,\n * // but the checksum fails\n * getAddress(\"0x8Ba1f109551bD432803012645Ac136ddd64DBA72\")\n * //_error:\n */\nexport function getAddress(address) {\n assertArgument(typeof (address) === \"string\", \"invalid address\", \"address\", address);\n if (address.match(/^(0x)?[0-9a-fA-F]{40}$/)) {\n // Missing the 0x prefix\n if (!address.startsWith(\"0x\")) {\n address = \"0x\" + address;\n }\n const result = getChecksumAddress(address);\n // It is a checksummed address with a bad checksum\n assertArgument(!address.match(/([A-F].*[a-f])|([a-f].*[A-F])/) || result === address, \"bad address checksum\", \"address\", address);\n return result;\n }\n // Maybe ICAP? (we only support direct mode)\n if (address.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) {\n // It is an ICAP address with a bad checksum\n assertArgument(address.substring(2, 4) === ibanChecksum(address), \"bad icap checksum\", \"address\", address);\n let result = fromBase36(address.substring(4)).toString(16);\n while (result.length < 40) {\n result = \"0\" + result;\n }\n return getChecksumAddress(\"0x\" + result);\n }\n assertArgument(false, \"invalid address\", \"address\", address);\n}\n/**\n * The [ICAP Address format](link-icap) format is an early checksum\n * format which attempts to be compatible with the banking\n * industry [IBAN format](link-wiki-iban) for bank accounts.\n *\n * It is no longer common or a recommended format.\n *\n * @example:\n * getIcapAddress(\"0x8ba1f109551bd432803012645ac136ddd64dba72\");\n * //_result:\n *\n * getIcapAddress(\"XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK36\");\n * //_result:\n *\n * // Throws an error if the ICAP checksum is wrong\n * getIcapAddress(\"XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK37\");\n * //_error:\n */\nexport function getIcapAddress(address) {\n //let base36 = _base16To36(getAddress(address).substring(2)).toUpperCase();\n let base36 = BigInt(getAddress(address)).toString(36).toUpperCase();\n while (base36.length < 30) {\n base36 = \"0\" + base36;\n }\n return \"XE\" + ibanChecksum(\"XE00\" + base36) + base36;\n}\n//# sourceMappingURL=address.js.map"],"names":[],"mappings":";;;AAEA,MAAM,OAAO,OAAO,CAAC;AACrB,MAAM,QAAQ,OAAO,EAAE;AACvB,SAAS,mBAAmB,SAAS;AAIjC,YAAU,QAAQ,YAAa;AAC/B,QAAM,QAAQ,QAAQ,UAAU,CAAC,EAAE,MAAM,EAAE;AAC3C,QAAM,WAAW,IAAI,WAAW,EAAE;AAClC,WAAS,IAAI,GAAG,IAAI,IAAI,KAAK;AACzB,aAAS,CAAC,IAAI,MAAM,CAAC,EAAE,WAAW,CAAC;AAAA,EAC3C;AACI,QAAM,SAAS,SAAS,UAAU,QAAQ,CAAC;AAC3C,WAAS,IAAI,GAAG,IAAI,IAAI,KAAK,GAAG;AAC5B,QAAK,OAAO,KAAK,CAAC,KAAK,KAAM,GAAG;AAC5B,YAAM,CAAC,IAAI,MAAM,CAAC,EAAE,YAAa;AAAA,IAC7C;AACQ,SAAK,OAAO,KAAK,CAAC,IAAI,OAAS,GAAG;AAC9B,YAAM,IAAI,CAAC,IAAI,MAAM,IAAI,CAAC,EAAE,YAAa;AAAA,IACrD;AAAA,EACA;AACI,SAAO,OAAO,MAAM,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