@hiero-ledger/sdk 2.78.0-beta.2 → 2.78.0
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/umd.js +332 -9
- package/dist/umd.min.js +7 -7
- package/lib/Executable.cjs +27 -0
- package/lib/Executable.js +1 -1
- package/lib/Executable.js.map +1 -1
- package/lib/FeeDataType.cjs +10 -1
- package/lib/FeeDataType.d.ts +1 -0
- package/lib/FeeDataType.js +1 -1
- package/lib/FeeDataType.js.map +1 -1
- package/lib/RequestType.cjs +19 -1
- package/lib/RequestType.d.ts +2 -0
- package/lib/RequestType.js +1 -1
- package/lib/RequestType.js.map +1 -1
- package/lib/Status.cjs +262 -1
- package/lib/Status.d.ts +29 -0
- package/lib/Status.js +1 -1
- package/lib/Status.js.map +1 -1
- package/lib/channel/WebChannel.cjs +1 -1
- package/lib/channel/WebChannel.js +1 -1
- package/lib/channel/WebChannel.js.map +1 -1
- package/lib/client/Network.cjs +1 -4
- package/lib/client/Network.js +1 -1
- package/lib/client/Network.js.map +1 -1
- package/lib/client/addressbooks/mainnet.cjs +1 -1
- package/lib/client/addressbooks/mainnet.d.ts +1 -1
- package/lib/client/addressbooks/mainnet.js +1 -1
- package/lib/client/addressbooks/mainnet.js.map +1 -1
- package/lib/client/addressbooks/previewnet.cjs +1 -1
- package/lib/client/addressbooks/previewnet.d.ts +1 -1
- package/lib/client/addressbooks/previewnet.js +1 -1
- package/lib/client/addressbooks/previewnet.js.map +1 -1
- package/lib/client/addressbooks/testnet.cjs +1 -1
- package/lib/client/addressbooks/testnet.d.ts +1 -1
- package/lib/client/addressbooks/testnet.js +1 -1
- package/lib/client/addressbooks/testnet.js.map +1 -1
- package/lib/transaction/Transaction.cjs +1 -0
- package/lib/transaction/Transaction.js +1 -1
- package/lib/transaction/Transaction.js.map +1 -1
- package/lib/version.js +1 -1
- package/package.json +2 -2
- package/src/Executable.js +37 -0
- package/src/FeeDataType.js +9 -0
- package/src/RequestType.js +18 -0
- package/src/Status.js +261 -0
- package/src/channel/WebChannel.js +3 -1
- package/src/client/Network.js +1 -6
- package/src/client/addressbooks/mainnet.js +1 -1
- package/src/client/addressbooks/previewnet.js +1 -1
- package/src/client/addressbooks/testnet.js +1 -1
- package/src/transaction/Transaction.js +1 -0
package/lib/Executable.cjs
CHANGED
|
@@ -684,6 +684,33 @@ class Executable {
|
|
|
684
684
|
// Determine by the executing state what we should do
|
|
685
685
|
switch (shouldRetry) {
|
|
686
686
|
case ExecutionState.Retry:
|
|
687
|
+
// Special handling for INVALID_NODE_ACCOUNT: mark node as unusable
|
|
688
|
+
// and update network to get latest node account IDs
|
|
689
|
+
if (status === _Status.default.InvalidNodeAccount) {
|
|
690
|
+
if (this._logger) {
|
|
691
|
+
this._logger.debug(`[${this._getLogId()}] node with accountId: ${node.accountId.toString()} and proxy IP: ${node.address.toString()} has invalid node account ID, marking as unhealthy and updating network`);
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
// Mark the node as unusable by increasing its backoff and removing it from the healthy nodes list
|
|
695
|
+
client._network.increaseBackoff(node);
|
|
696
|
+
|
|
697
|
+
// Initiate addressbook query and update the client's network
|
|
698
|
+
// This will make the SDK client have the latest node account IDs for subsequent transactions
|
|
699
|
+
try {
|
|
700
|
+
if (client.mirrorNetwork.length > 0) {
|
|
701
|
+
await client.updateNetwork();
|
|
702
|
+
} else {
|
|
703
|
+
if (this._logger) {
|
|
704
|
+
this._logger.warn("Cannot update address book: no mirror network configured. Retrying with existing network configuration.");
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
} catch (error) {
|
|
708
|
+
if (this._logger) {
|
|
709
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
710
|
+
this._logger.trace(`failed to update client address book after INVALID_NODE_ACCOUNT_ID: ${errorMessage}`);
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
}
|
|
687
714
|
await delayForAttempt(isLocalNode, attempt, this._minBackoff, this._maxBackoff);
|
|
688
715
|
continue;
|
|
689
716
|
case ExecutionState.Finished:
|
package/lib/Executable.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import t from"./grpc/GrpcServiceError.js";import e from"./grpc/GrpcStatus.js";import
|
|
1
|
+
import t from"./grpc/GrpcServiceError.js";import e from"./grpc/GrpcStatus.js";import o from"./transaction/List.js";import{encode as n}from"./encoding/hex.js";import r from"./http/HttpError.js";import i from"./Status.js";import s from"./MaxAttemptsOrTimeoutError.js";const a={Finished:"Finished",Retry:"Retry",Error:"Error"},c=/\brst[^0-9a-zA-Z]stream\b/i,h=10;class d{constructor(){this._maxAttempts=10,this._nodeAccountIds=new o,this.transactionNodeIds=[],this._signOnDemand=!1,this._minBackoff=null,this._maxBackoff=8e3,this._operator=null,this._requestTimeout=null,this._grpcDeadline=null,this._logger=null}get nodeAccountIds(){return this._nodeAccountIds.isEmpty?null:(this._nodeAccountIds.setLocked(),this._nodeAccountIds.list)}setNodeAccountIds(t){return this._nodeAccountIds.setList(t).setLocked(),this}get maxRetries(){return console.warn("Deprecated: use maxAttempts instead"),this.maxAttempts}setMaxRetries(t){return console.warn("Deprecated: use setMaxAttempts() instead"),this.setMaxAttempts(t)}get maxAttempts(){return this._maxAttempts}setMaxAttempts(t){return this._maxAttempts=t,this}get grpcDeadline(){return this._grpcDeadline}setGrpcDeadline(t){return this._grpcDeadline=t,this}setMinBackoff(t){if(null==t)throw new Error("minBackoff cannot be null.");if(null!=this._maxBackoff&&t>this._maxBackoff)throw new Error("minBackoff cannot be larger than maxBackoff.");return this._minBackoff=t,this}get minBackoff(){return this._minBackoff}setMaxBackoff(t){if(null==t)throw new Error("maxBackoff cannot be null.");if(null!=this._minBackoff&&t<this._minBackoff)throw new Error("maxBackoff cannot be smaller than minBackoff.");return this._maxBackoff=t,this}get maxBackoff(){return this._maxBackoff}_beforeExecute(t){throw new Error("not implemented")}_makeRequestAsync(){throw new Error("not implemented")}_mapStatusError(t,e,o){throw new Error("not implemented")}_mapResponse(t,e,o){throw new Error("not implemented")}_execute(t,e){throw new Error("not implemented")}_getTransactionId(){throw new Error("not implemented")}_getLogId(){throw new Error("not implemented")}_requestToBytes(t){throw new Error("not implemented")}_responseToBytes(t){throw new Error("not implemented")}_shouldRetry(t,e){throw new Error("not implemented")}_shouldRetryExceptionally(o){return!(o instanceof t)||(o.status._code===e.Timeout._code||o.status._code===e.DeadlineExceeded._code||o.status._code===e.Unavailable._code||o.status._code===e.ResourceExhausted._code||o.status._code===e.GrpcWeb._code||o.status._code===e.Internal._code&&c.test(o.message))}_setOperatorWith(t,e,o){return this._operator={transactionSigner:o,accountId:t,publicKey:e},this}async executeWithSigner(t){return t.call(this)}isBatchedAndNotBatchTransaction(){return!1}async execute(o,c){const h=null!=o.network["127.0.0.1:50211"];if(this.isBatchedAndNotBatchTransaction())throw new Error("Cannot execute batchified transaction outside of BatchTransaction");this._logger=null==this._logger?null!=o._logger?o._logger:null:this._logger,null==this._requestTimeout&&(this._requestTimeout=null!=c?c:o.requestTimeout),null==this._grpcDeadline&&(this._grpcDeadline=o.grpcDeadline),await this._beforeExecute(o),null==this._maxBackoff&&(this._maxBackoff=o.maxBackoff),null==this._minBackoff&&(this._minBackoff=o.minBackoff);const d=Date.now();let g=null;const _=h?1e3:o._maxAttempts??this._maxAttempts;if(this.transactionNodeIds.length){const t=this._nodeAccountIds.list.map(t=>t.toString());if(!this.transactionNodeIds.some(e=>t.includes(e))){const e=t.length>2?`${t.slice(0,2).join(", ")} ...`:t.join(", "),o=1===t.length;throw new Error(`Attempting to execute a transaction against node${o?"":"s"} ${e}, which ${o?"is":"are"} not included in the Client's node list. Please review your Client configuration.`)}}for(let c=1;c<=_;c+=1){if(null!=this._requestTimeout&&d+this._requestTimeout<=Date.now())throw new s("timeout exceeded",this._nodeAccountIds.isEmpty?"No node account ID set":this._nodeAccountIds.current.toString());let m,f;if(this._nodeAccountIds.isEmpty?(f=o._network.getNode(),m=f.accountId,this._nodeAccountIds.setList([m])):(m=this._nodeAccountIds.current,f=o._network.getNode(m)),null==f)throw new Error(`NodeAccountId not recognized: ${m.toString()}`);if(this.transactionNodeIds.length){if(!this.transactionNodeIds.includes(m.toString())){console.error(`Attempting to execute a transaction against node ${m.toString()}, which is not included in the Client's node list. Please review your Client configuration.`),this._nodeAccountIds.advance();continue}}const p=this._getLogId();this._logger&&this._logger.debug(`[${p}] Node AccountID: ${f.accountId.toString()}, IP: ${f.address.toString()}`);const w=f.getChannel();null!=this._grpcDeadline&&w.setGrpcDeadline(this._grpcDeadline);const x=await this._makeRequestAsync();let k;if(!f.isHealthy()){const t=this._nodeAccountIds.index===this._nodeAccountIds.list.length-1;if(u(x)||h){await l(h,c,this._minBackoff,this._maxBackoff);continue}if(t||this._nodeAccountIds.length<=1)throw new Error(`Network connectivity issue: All nodes are unhealthy. Original node list: ${this._nodeAccountIds.list.join(", ")}`);this._logger&&this._logger.debug(`[${p}] Node is not healthy, trying the next node.`),this._nodeAccountIds.advance();continue}this._nodeAccountIds.advance();try{const o=[];null!=this._grpcDeadline&&o.push(new Promise((o,n)=>setTimeout(()=>n(new t(e.DeadlineExceeded)),this._grpcDeadline))),this._logger&&this._logger.trace(`[${this._getLogId()}] sending protobuf ${n(this._requestToBytes(x))}`),o.push(this._execute(w,x)),k=await Promise.race(o)}catch(e){const n=t._fromResponse(e);if(g=n,this._logger&&this._logger.debug(`[${p}] received error ${JSON.stringify(n)}`),(n instanceof t||n instanceof r)&&this._shouldRetryExceptionally(n)&&c<=_){this._logger&&this._logger.debug(`[${this._getLogId()}] node with accountId: ${f.accountId.toString()} and proxy IP: ${f.address.toString()} is unhealthy`),o._network.increaseBackoff(f);continue}throw e}this._logger&&this._logger.trace(`[${this._getLogId()}] sending protobuf ${n(this._responseToBytes(k))}`),o._network.decreaseBackoff(f);const[I,A]=this._shouldRetry(x,k);switch(I.toString()!==i.Ok.toString()&&I.toString()!==i.Success.toString()&&(g=I),A){case a.Retry:if(I===i.InvalidNodeAccount){this._logger&&this._logger.debug(`[${this._getLogId()}] node with accountId: ${f.accountId.toString()} and proxy IP: ${f.address.toString()} has invalid node account ID, marking as unhealthy and updating network`),o._network.increaseBackoff(f);try{o.mirrorNetwork.length>0?await o.updateNetwork():this._logger&&this._logger.warn("Cannot update address book: no mirror network configured. Retrying with existing network configuration.")}catch(t){if(this._logger){const e=t instanceof Error?t.message:String(t);this._logger.trace(`failed to update client address book after INVALID_NODE_ACCOUNT_ID: ${e}`)}}}await l(h,c,this._minBackoff,this._maxBackoff);continue;case a.Finished:return this._mapResponse(k,m,x);case a.Error:throw this._mapStatusError(x,k,m);default:throw new Error("(BUG) non-exhaustive switch statement for `ExecutionState`")}}throw new s(`max attempts of ${_.toString()} was reached for request with last error being: ${null!=g?g.toString():""}`,this._nodeAccountIds.current.toString())}toBytes(){throw new Error("not implemented")}setLogger(t){return this._logger=t,this}get logger(){return this._logger}}function u(t){return"object"==typeof t&&null!==t&&("transactionGetReceipt"in t||"transactionGetRecord"in t)}function l(t,e,o,n){if(t)return new Promise(t=>setTimeout(t,o));const r=Math.min(Math.floor(o*Math.pow(2,e)),n);return new Promise(t=>setTimeout(t,r))}export{h as DEFAULT_MAX_ATTEMPTS,a as ExecutionState,c as RST_STREAM,d as default};
|
|
2
2
|
//# sourceMappingURL=Executable.js.map
|
package/lib/Executable.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Executable.js","sources":["../src/Executable.js"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\nimport GrpcServiceError from \"./grpc/GrpcServiceError.js\";\nimport GrpcStatus from \"./grpc/GrpcStatus.js\";\nimport List from \"./transaction/List.js\";\nimport * as hex from \"./encoding/hex.js\";\nimport HttpError from \"./http/HttpError.js\";\nimport Status from \"./Status.js\";\nimport MaxAttemptsOrTimeoutError from \"./MaxAttemptsOrTimeoutError.js\";\n\n/**\n * @typedef {import(\"./account/AccountId.js\").default} AccountId\n * @typedef {import(\"./channel/Channel.js\").default} Channel\n * @typedef {import(\"./channel/MirrorChannel.js\").default} MirrorChannel\n * @typedef {import(\"./transaction/TransactionId.js\").default} TransactionId\n * @typedef {import(\"./client/Client.js\").ClientOperator} ClientOperator\n * @typedef {import(\"./Signer.js\").Signer} Signer\n * @typedef {import(\"./PublicKey.js\").default} PublicKey\n * @typedef {import(\"./logger/Logger.js\").default} Logger\n */\n\n/**\n * @enum {string}\n */\nexport const ExecutionState = {\n Finished: \"Finished\",\n Retry: \"Retry\",\n Error: \"Error\",\n};\n\nexport const RST_STREAM = /\\brst[^0-9a-zA-Z]stream\\b/i;\nexport const DEFAULT_MAX_ATTEMPTS = 10;\n\n/**\n * @abstract\n * @internal\n * @template RequestT\n * @template ResponseT\n * @template OutputT\n */\nexport default class Executable {\n constructor() {\n /**\n * The number of times we can retry the grpc call\n *\n * @internal\n * @type {number}\n */\n this._maxAttempts = DEFAULT_MAX_ATTEMPTS;\n\n /**\n * List of node account IDs for each transaction that has been\n * built.\n *\n * @internal\n * @type {List<AccountId>}\n */\n this._nodeAccountIds = new List();\n\n /**\n * List of the transaction node account IDs to check if\n * the node account ID of the request is in the list\n *\n * @protected\n * @type {Array<string>}\n */\n this.transactionNodeIds = [];\n\n /**\n * @internal\n */\n this._signOnDemand = false;\n\n /**\n * This is the request's min backoff\n *\n * @internal\n * @type {number | null}\n */\n this._minBackoff = null;\n\n /**\n * This is the request's max backoff\n *\n * @internal\n * @type {number}\n */\n this._maxBackoff = 8000;\n\n /**\n * The operator that was used to execute this request.\n * The reason we save the operator in the request is because of the signing on\n * demand feature. This feature requires us to sign new request on each attempt\n * meaning if a client with an operator was used we'd need to sign with the operator\n * on each attempt.\n *\n * @internal\n * @type {ClientOperator | null}\n */\n this._operator = null;\n\n /**\n * The complete timeout for running the `execute()` method\n *\n * @internal\n * @type {number | null}\n */\n this._requestTimeout = null;\n\n /**\n * The grpc request timeout aka deadline.\n *\n * The reason we have this is because there were times that consensus nodes held the grpc\n * connection, but didn't return anything; not error nor regular response. This resulted\n * in some weird behavior in the SDKs. To fix this we've added a grpc deadline to prevent\n * nodes from stalling the executing of a request.\n *\n * @internal\n * @type {number | null}\n */\n this._grpcDeadline = null;\n\n /**\n * Logger\n *\n * @protected\n * @type {Logger | null}\n */\n this._logger = null;\n }\n\n /**\n * Get the list of node account IDs on the request. If no nodes are set, then null is returned.\n * The reasoning for this is simply \"legacy behavior\".\n *\n * @returns {?AccountId[]}\n */\n get nodeAccountIds() {\n if (this._nodeAccountIds.isEmpty) {\n return null;\n } else {\n this._nodeAccountIds.setLocked();\n return this._nodeAccountIds.list;\n }\n }\n\n /**\n * Set the node account IDs on the request\n *\n * @param {AccountId[]} nodeIds\n * @returns {this}\n */\n setNodeAccountIds(nodeIds) {\n // Set the node account IDs, and lock the list. This will require `execute`\n // to use these nodes instead of random nodes from the network.\n this._nodeAccountIds.setList(nodeIds).setLocked();\n return this;\n }\n\n /**\n * @deprecated\n * @returns {number}\n */\n get maxRetries() {\n console.warn(\"Deprecated: use maxAttempts instead\");\n return this.maxAttempts;\n }\n\n /**\n * @param {number} maxRetries\n * @returns {this}\n */\n setMaxRetries(maxRetries) {\n console.warn(\"Deprecated: use setMaxAttempts() instead\");\n return this.setMaxAttempts(maxRetries);\n }\n\n /**\n * Get the max attempts on the request\n *\n * @returns {number}\n */\n get maxAttempts() {\n return this._maxAttempts;\n }\n\n /**\n * Set the max attempts on the request\n *\n * @param {number} maxAttempts\n * @returns {this}\n */\n setMaxAttempts(maxAttempts) {\n this._maxAttempts = maxAttempts;\n\n return this;\n }\n\n /**\n * Get the grpc deadline\n *\n * @returns {?number}\n */\n get grpcDeadline() {\n return this._grpcDeadline;\n }\n\n /**\n * Set the grpc deadline\n *\n * @param {number} grpcDeadline\n * @returns {this}\n */\n setGrpcDeadline(grpcDeadline) {\n this._grpcDeadline = grpcDeadline;\n\n return this;\n }\n\n /**\n * Set the min backoff for the request\n *\n * @param {number} minBackoff\n * @returns {this}\n */\n setMinBackoff(minBackoff) {\n // Honestly we shouldn't be checking for null since that should be TypeScript's job.\n // Also verify that min backoff is not greater than max backoff.\n if (minBackoff == null) {\n throw new Error(\"minBackoff cannot be null.\");\n } else if (this._maxBackoff != null && minBackoff > this._maxBackoff) {\n throw new Error(\"minBackoff cannot be larger than maxBackoff.\");\n }\n this._minBackoff = minBackoff;\n return this;\n }\n\n /**\n * Get the min backoff\n *\n * @returns {number | null}\n */\n get minBackoff() {\n return this._minBackoff;\n }\n\n /**\n * Set the max backoff for the request\n *\n * @param {?number} maxBackoff\n * @returns {this}\n */\n setMaxBackoff(maxBackoff) {\n // Honestly we shouldn't be checking for null since that should be TypeScript's job.\n // Also verify that max backoff is not less than min backoff.\n if (maxBackoff == null) {\n throw new Error(\"maxBackoff cannot be null.\");\n } else if (this._minBackoff != null && maxBackoff < this._minBackoff) {\n throw new Error(\"maxBackoff cannot be smaller than minBackoff.\");\n }\n this._maxBackoff = maxBackoff;\n return this;\n }\n\n /**\n * Get the max backoff\n *\n * @returns {number}\n */\n get maxBackoff() {\n return this._maxBackoff;\n }\n\n /**\n * This method is responsible for doing any work before the executing process begins.\n * For paid queries this will result in executing a cost query, for transactions this\n * will make sure we save the operator and sign any requests that need to be signed\n * in case signing on demand is disabled.\n *\n * @abstract\n * @protected\n * @param {import(\"./client/Client.js\").default<Channel, *>} client\n * @returns {Promise<void>}\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _beforeExecute(client) {\n throw new Error(\"not implemented\");\n }\n\n /**\n * Create a protobuf request which will be passed into the `_execute()` method\n *\n * @abstract\n * @protected\n * @returns {Promise<RequestT>}\n */\n _makeRequestAsync() {\n throw new Error(\"not implemented\");\n }\n\n /**\n * This name is a bit wrong now, but the purpose of this method is to map the\n * request and response into an error. This method will only be called when\n * `_shouldRetry` returned `ExecutionState.Error`\n *\n * @abstract\n * @internal\n * @param {RequestT} request\n * @param {ResponseT} response\n * @param {AccountId} nodeId\n * @returns {Error}\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _mapStatusError(request, response, nodeId) {\n throw new Error(\"not implemented\");\n }\n\n /**\n * Map the request, response, and the node account ID used for this attempt into a response.\n * This method will only be called when `_shouldRetry` returned `ExecutionState.Finished`\n *\n * @abstract\n * @protected\n * @param {ResponseT} response\n * @param {AccountId} nodeAccountId\n * @param {RequestT} request\n * @returns {Promise<OutputT>}\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _mapResponse(response, nodeAccountId, request) {\n throw new Error(\"not implemented\");\n }\n\n /**\n * Perform a single grpc call with the given request. Each request has it's own\n * required service so we just pass in channel, and it'$ the request's responsiblity\n * to use the right service and call the right grpc method.\n *\n * @abstract\n * @internal\n * @param {Channel} channel\n * @param {RequestT} request\n * @returns {Promise<ResponseT>}\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _execute(channel, request) {\n throw new Error(\"not implemented\");\n }\n\n /**\n * Return the current transaction ID for the request. All requests which are\n * use the same transaction ID for each node, but the catch is that `Transaction`\n * implicitly supports chunked transactions. Meaning there could be multiple\n * transaction IDs stored in the request, and a different transaction ID will be used\n * on subsequent calls to `execute()`\n *\n * FIXME: This method can most likely be removed, although some further inspection\n * is required.\n *\n * @abstract\n * @protected\n * @returns {TransactionId}\n */\n _getTransactionId() {\n throw new Error(\"not implemented\");\n }\n\n /**\n * Return the log ID for this particular request\n *\n * Log IDs are simply a string constructed to make it easy to track each request's\n * execution even when mulitple requests are executing in parallel. Typically, this\n * method returns the format of `[<request type>.<timestamp of the transaction ID>]`\n *\n * Maybe we should deduplicate this using ${this.consturtor.name}\n *\n * @abstract\n * @internal\n * @returns {string}\n */\n _getLogId() {\n throw new Error(\"not implemented\");\n }\n\n /**\n * Serialize the request into bytes\n *\n * @abstract\n * @param {RequestT} request\n * @returns {Uint8Array}\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _requestToBytes(request) {\n throw new Error(\"not implemented\");\n }\n\n /**\n * Serialize the response into bytes\n *\n * @abstract\n * @param {ResponseT} response\n * @returns {Uint8Array}\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _responseToBytes(response) {\n throw new Error(\"not implemented\");\n }\n\n /**\n * Determine if we should continue the execution process, error, or finish.\n *\n * FIXME: This method should really be called something else. Initially it returned\n * a boolean so `shouldRetry` made sense, but now it returns an enum, so the name\n * no longer makes sense.\n *\n * @abstract\n * @protected\n * @param {RequestT} request\n * @param {ResponseT} response\n * @returns {[Status, ExecutionState]}\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _shouldRetry(request, response) {\n throw new Error(\"not implemented\");\n }\n\n /**\n * Determine if we should error based on the gRPC status\n *\n * Unlike `shouldRetry` this method does in fact still return a boolean\n *\n * @protected\n * @param {Error} error\n * @returns {boolean}\n */\n _shouldRetryExceptionally(error) {\n if (error instanceof GrpcServiceError) {\n return (\n error.status._code === GrpcStatus.Timeout._code ||\n error.status._code === GrpcStatus.DeadlineExceeded._code ||\n error.status._code === GrpcStatus.Unavailable._code ||\n error.status._code === GrpcStatus.ResourceExhausted._code ||\n error.status._code === GrpcStatus.GrpcWeb._code ||\n (error.status._code === GrpcStatus.Internal._code &&\n RST_STREAM.test(error.message))\n );\n } else {\n // if we get to the 'else' statement, the 'error' is instanceof 'HttpError'\n // and in this case, we have to retry always\n return true;\n }\n }\n\n /**\n * A helper method for setting the operator on the request\n *\n * @internal\n * @param {AccountId} accountId\n * @param {PublicKey} publicKey\n * @param {(message: Uint8Array) => Promise<Uint8Array>} transactionSigner\n * @returns {this}\n */\n _setOperatorWith(accountId, publicKey, transactionSigner) {\n this._operator = {\n transactionSigner,\n accountId,\n publicKey,\n };\n return this;\n }\n\n /**\n * Execute this request using the signer\n *\n * This method is part of the signature providers feature\n * https://hips.hedera.com/hip/hip-338\n *\n * @param {Signer} signer\n * @returns {Promise<OutputT>}\n */\n async executeWithSigner(signer) {\n return signer.call(this);\n }\n\n /**\n * @returns {boolean}\n * @abstract\n * @protected\n */\n isBatchedAndNotBatchTransaction() {\n return false;\n }\n\n /**\n * Execute the request using a client and an optional request timeout\n *\n * @template {Channel} ChannelT\n * @template {MirrorChannel} MirrorChannelT\n * @param {import(\"./client/Client.js\").default<ChannelT, MirrorChannelT>} client\n * @param {number=} requestTimeout\n * @returns {Promise<OutputT>}\n */\n async execute(client, requestTimeout) {\n // we check if its local node then backoff mechanism should be disabled\n // and we increase the retry attempts\n const isLocalNode = client.network[\"127.0.0.1:50211\"] != null;\n\n if (this.isBatchedAndNotBatchTransaction()) {\n throw new Error(\n \"Cannot execute batchified transaction outside of BatchTransaction\",\n );\n }\n\n // If the logger on the request is not set, use the logger in client\n // (if set, otherwise do not use logger)\n this._logger =\n this._logger == null\n ? client._logger != null\n ? client._logger\n : null\n : this._logger;\n\n // If the request timeout is set on the request we'll prioritize that instead\n // of the parameter provided, and if the parameter isn't provided we'll\n // use the default request timeout on client\n if (this._requestTimeout == null) {\n this._requestTimeout =\n requestTimeout != null ? requestTimeout : client.requestTimeout;\n }\n\n // If the grpc deadline is not set on the request, use the default value from client\n if (this._grpcDeadline == null) {\n this._grpcDeadline = client.grpcDeadline;\n }\n\n // Some request need to perform additional requests before the executing\n // such as paid queries need to fetch the cost of the query before\n // finally executing the actual query.\n await this._beforeExecute(client);\n\n // If the max backoff on the request is not set, use the default value in client\n if (this._maxBackoff == null) {\n this._maxBackoff = client.maxBackoff;\n }\n\n // If the min backoff on the request is not set, use the default value in client\n if (this._minBackoff == null) {\n this._minBackoff = client.minBackoff;\n }\n\n // Save the start time to be used later with request timeout\n const startTime = Date.now();\n\n // Saves each error we get so when we err due to max attempts exceeded we'll have\n // the last error that was returned by the consensus node\n let persistentError = null;\n\n // If the max attempts on the request is not set, use the default value in client\n // If the default value in client is not set, use a default of 10.\n //\n // FIXME: current implementation is wrong, update to follow comment above.\n // ... existing code ...\n const LOCAL_NODE_ATTEMPTS = 1000;\n const maxAttempts = isLocalNode\n ? LOCAL_NODE_ATTEMPTS\n : client._maxAttempts ?? this._maxAttempts;\n\n // Checks if has a valid nodes to which the TX can be sent\n if (this.transactionNodeIds.length) {\n const nodeAccountIds = this._nodeAccountIds.list.map((nodeId) =>\n nodeId.toString(),\n );\n\n const hasValidNodes = this.transactionNodeIds.some((nodeId) =>\n nodeAccountIds.includes(nodeId),\n );\n\n if (!hasValidNodes) {\n const displayNodeAccountIds =\n nodeAccountIds.length > 2\n ? `${nodeAccountIds.slice(0, 2).join(\", \")} ...`\n : nodeAccountIds.join(\", \");\n const isSingleNode = nodeAccountIds.length === 1;\n\n throw new Error(\n `Attempting to execute a transaction against node${\n isSingleNode ? \"\" : \"s\"\n } ${displayNodeAccountIds}, ` +\n `which ${\n isSingleNode ? \"is\" : \"are\"\n } not included in the Client's node list. Please review your Client configuration.`,\n );\n }\n }\n\n // The retry loop\n for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {\n // Determine if we've exceeded request timeout\n if (\n this._requestTimeout != null &&\n startTime + this._requestTimeout <= Date.now()\n ) {\n throw new MaxAttemptsOrTimeoutError(\n `timeout exceeded`,\n this._nodeAccountIds.isEmpty\n ? \"No node account ID set\"\n : this._nodeAccountIds.current.toString(),\n );\n }\n\n let nodeAccountId;\n let node;\n\n if (this._nodeAccountIds.isEmpty) {\n node = client._network.getNode();\n nodeAccountId = node.accountId;\n this._nodeAccountIds.setList([nodeAccountId]);\n } else {\n nodeAccountId = this._nodeAccountIds.current;\n node = client._network.getNode(nodeAccountId);\n }\n\n if (node == null) {\n throw new Error(\n `NodeAccountId not recognized: ${nodeAccountId.toString()}`,\n );\n }\n\n if (this.transactionNodeIds.length) {\n const isNodeAccountIdValid = this.transactionNodeIds.includes(\n nodeAccountId.toString(),\n );\n\n if (!isNodeAccountIdValid) {\n console.error(\n `Attempting to execute a transaction against node ${nodeAccountId.toString()}, which is not included in the Client's node list. Please review your Client configuration.`,\n );\n\n this._nodeAccountIds.advance();\n continue;\n }\n }\n\n // Get the log ID for the request.\n const logId = this._getLogId();\n if (this._logger) {\n this._logger.debug(\n `[${logId}] Node AccountID: ${node.accountId.toString()}, IP: ${node.address.toString()}`,\n );\n }\n\n const channel = node.getChannel();\n\n // Set the gRPC deadline on the channel if this query has a custom deadline\n if (this._grpcDeadline != null) {\n channel.setGrpcDeadline(this._grpcDeadline);\n }\n\n const request = await this._makeRequestAsync();\n\n let response;\n\n if (!node.isHealthy()) {\n const isLastNode =\n this._nodeAccountIds.index ===\n this._nodeAccountIds.list.length - 1;\n\n // Check if the request is a transaction receipt or record\n // request to retry 10 times, because getReceiptQuery/getRecordQuery\n // are single node requests\n if (\n isTransactionReceiptOrRecordRequest(request) ||\n isLocalNode\n ) {\n await delayForAttempt(\n isLocalNode,\n attempt,\n this._minBackoff,\n this._maxBackoff,\n );\n continue;\n }\n\n if (isLastNode || this._nodeAccountIds.length <= 1) {\n throw new Error(\n `Network connectivity issue: All nodes are unhealthy. Original node list: ${this._nodeAccountIds.list.join(\n \", \",\n )}`,\n );\n }\n\n if (this._logger) {\n this._logger.debug(\n `[${logId}] Node is not healthy, trying the next node.`,\n );\n }\n\n this._nodeAccountIds.advance();\n continue;\n }\n\n this._nodeAccountIds.advance();\n\n try {\n // Race the execution promise against the grpc timeout to prevent grpc connections\n // from blocking this request\n const promises = [];\n\n // If a grpc deadline is set, we should race it, otherwise the only thing in the\n // list of promises will be the execution promise.\n if (this._grpcDeadline != null) {\n promises.push(\n // eslint-disable-next-line ie11/no-loop-func\n new Promise((_, reject) =>\n setTimeout(\n // eslint-disable-next-line ie11/no-loop-func\n () =>\n reject(\n new GrpcServiceError(\n GrpcStatus.DeadlineExceeded,\n ),\n ),\n /** @type {number=} */ (this._grpcDeadline),\n ),\n ),\n );\n }\n if (this._logger) {\n this._logger.trace(\n `[${this._getLogId()}] sending protobuf ${hex.encode(\n this._requestToBytes(request),\n )}`,\n );\n }\n\n promises.push(this._execute(channel, request));\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n response = /** @type {ResponseT} */ (\n await Promise.race(promises)\n );\n } catch (err) {\n // If we received a grpc status error we need to determine if\n // we should retry on this error, or err from the request entirely.\n const error = GrpcServiceError._fromResponse(\n /** @type {Error} */ (err),\n );\n\n // Save the error in case we retry\n persistentError = error;\n if (this._logger) {\n this._logger.debug(\n `[${logId}] received error ${JSON.stringify(error)}`,\n );\n }\n\n if (\n (error instanceof GrpcServiceError ||\n error instanceof HttpError) &&\n this._shouldRetryExceptionally(error) &&\n attempt <= maxAttempts\n ) {\n // Increase the backoff for the particular node and remove it from\n // the healthy node list\n if (this._logger) {\n this._logger.debug(\n `[${this._getLogId()}] node with accountId: ${node.accountId.toString()} and proxy IP: ${node.address.toString()} is unhealthy`,\n );\n }\n\n client._network.increaseBackoff(node);\n continue;\n }\n\n throw err;\n }\n if (this._logger) {\n this._logger.trace(\n `[${this._getLogId()}] sending protobuf ${hex.encode(\n this._responseToBytes(response),\n )}`,\n );\n }\n\n // If we didn't receive an error we should decrease the current nodes backoff\n // in case it is a recovering node\n client._network.decreaseBackoff(node);\n\n // Determine what execution state we're in by the response\n // For transactions this would be as simple as checking the response status is `OK`\n // while for _most_ queries it would check if the response status is `SUCCESS`\n // The only odd balls are `TransactionReceiptQuery` and `TransactionRecordQuery`\n const [status, shouldRetry] = this._shouldRetry(request, response);\n if (\n status.toString() !== Status.Ok.toString() &&\n status.toString() !== Status.Success.toString()\n ) {\n persistentError = status;\n }\n\n // Determine by the executing state what we should do\n switch (shouldRetry) {\n case ExecutionState.Retry:\n await delayForAttempt(\n isLocalNode,\n attempt,\n this._minBackoff,\n this._maxBackoff,\n );\n continue;\n case ExecutionState.Finished:\n return this._mapResponse(response, nodeAccountId, request);\n case ExecutionState.Error:\n throw this._mapStatusError(\n request,\n response,\n nodeAccountId,\n );\n default:\n throw new Error(\n \"(BUG) non-exhaustive switch statement for `ExecutionState`\",\n );\n }\n }\n\n // We'll only get here if we've run out of attempts, so we return an error wrapping the\n // persistent error we saved before.\n\n throw new MaxAttemptsOrTimeoutError(\n `max attempts of ${maxAttempts.toString()} was reached for request with last error being: ${\n persistentError != null ? persistentError.toString() : \"\"\n }`,\n this._nodeAccountIds.current.toString(),\n );\n }\n\n /**\n * The current purpose of this method is to easily support signature providers since\n * signature providers need to serialize _any_ request into bytes. `Query` and `Transaction`\n * already implement `toBytes()` so it only made sense to make it available here too.\n *\n * @abstract\n * @returns {Uint8Array}\n */\n toBytes() {\n throw new Error(\"not implemented\");\n }\n\n /**\n * Set logger\n *\n * @param {Logger} logger\n * @returns {this}\n */\n setLogger(logger) {\n this._logger = logger;\n return this;\n }\n\n /**\n * Get logger if set\n *\n * @returns {?Logger}\n */\n get logger() {\n return this._logger;\n }\n}\n\n/**\n * Checks if the request is a transaction receipt or record request\n *\n * @template T\n * @param {T} request - The request to check\n * @returns {boolean} - True if the request is a transaction receipt or record\n */\nfunction isTransactionReceiptOrRecordRequest(request) {\n if (typeof request !== \"object\" || request === null) {\n return false;\n }\n\n return (\n \"transactionGetReceipt\" in request || \"transactionGetRecord\" in request\n );\n}\n\n/**\n * A simple function that returns a promise timeout for a specific period of time\n *\n * @param {boolean} isLocalNode\n * @param {number} attempt\n * @param {number} minBackoff\n * @param {number} maxBackoff\n * @returns {Promise<void>}\n */\nfunction delayForAttempt(isLocalNode, attempt, minBackoff, maxBackoff) {\n if (isLocalNode) {\n return new Promise((resolve) => setTimeout(resolve, minBackoff));\n }\n\n // 0.1s, 0.2s, 0.4s, 0.8s, ...\n const ms = Math.min(\n Math.floor(minBackoff * Math.pow(2, attempt)),\n maxBackoff,\n );\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n"],"names":["ExecutionState","Finished","Retry","Error","RST_STREAM","DEFAULT_MAX_ATTEMPTS","Executable","constructor","this","_maxAttempts","_nodeAccountIds","List","transactionNodeIds","_signOnDemand","_minBackoff","_maxBackoff","_operator","_requestTimeout","_grpcDeadline","_logger","nodeAccountIds","isEmpty","setLocked","list","setNodeAccountIds","nodeIds","setList","maxRetries","console","warn","maxAttempts","setMaxRetries","setMaxAttempts","grpcDeadline","setGrpcDeadline","setMinBackoff","minBackoff","setMaxBackoff","maxBackoff","_beforeExecute","client","_makeRequestAsync","_mapStatusError","request","response","nodeId","_mapResponse","nodeAccountId","_execute","channel","_getTransactionId","_getLogId","_requestToBytes","_responseToBytes","_shouldRetry","_shouldRetryExceptionally","error","GrpcServiceError","status","_code","GrpcStatus","Timeout","DeadlineExceeded","Unavailable","ResourceExhausted","GrpcWeb","Internal","test","message","_setOperatorWith","accountId","publicKey","transactionSigner","executeWithSigner","signer","call","isBatchedAndNotBatchTransaction","execute","requestTimeout","isLocalNode","network","startTime","Date","now","persistentError","length","map","toString","some","includes","displayNodeAccountIds","slice","join","isSingleNode","attempt","MaxAttemptsOrTimeoutError","current","node","_network","getNode","advance","logId","debug","address","getChannel","isHealthy","isLastNode","index","isTransactionReceiptOrRecordRequest","delayForAttempt","promises","push","Promise","_","reject","setTimeout","trace","hex.encode","race","err","_fromResponse","JSON","stringify","HttpError","increaseBackoff","decreaseBackoff","shouldRetry","Status","Ok","Success","toBytes","setLogger","logger","resolve","ms","Math","min","floor","pow"],"mappings":"0QAwBY,MAACA,EAAiB,CAC1BC,SAAU,WACVC,MAAO,QACPC,MAAO,SAGEC,EAAa,6BACbC,EAAuB,GASrB,MAAMC,EACjB,WAAAC,GAOIC,KAAKC,aAjBuB,GA0B5BD,KAAKE,gBAAkB,IAAIC,EAS3BH,KAAKI,mBAAqB,GAK1BJ,KAAKK,eAAgB,EAQrBL,KAAKM,YAAc,KAQnBN,KAAKO,YAAc,IAYnBP,KAAKQ,UAAY,KAQjBR,KAAKS,gBAAkB,KAavBT,KAAKU,cAAgB,KAQrBV,KAAKW,QAAU,IACvB,CAQI,kBAAIC,GACA,OAAIZ,KAAKE,gBAAgBW,QACd,MAEPb,KAAKE,gBAAgBY,YACdd,KAAKE,gBAAgBa,KAExC,CAQI,iBAAAC,CAAkBC,GAId,OADAjB,KAAKE,gBAAgBgB,QAAQD,GAASH,YAC/Bd,IACf,CAMI,cAAImB,GAEA,OADAC,QAAQC,KAAK,uCACNrB,KAAKsB,WACpB,CAMI,aAAAC,CAAcJ,GA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
|
+
{"version":3,"file":"Executable.js","sources":["../src/Executable.js"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\nimport GrpcServiceError from \"./grpc/GrpcServiceError.js\";\nimport GrpcStatus from \"./grpc/GrpcStatus.js\";\nimport List from \"./transaction/List.js\";\nimport * as hex from \"./encoding/hex.js\";\nimport HttpError from \"./http/HttpError.js\";\nimport Status from \"./Status.js\";\nimport MaxAttemptsOrTimeoutError from \"./MaxAttemptsOrTimeoutError.js\";\n\n/**\n * @typedef {import(\"./account/AccountId.js\").default} AccountId\n * @typedef {import(\"./channel/Channel.js\").default} Channel\n * @typedef {import(\"./channel/MirrorChannel.js\").default} MirrorChannel\n * @typedef {import(\"./transaction/TransactionId.js\").default} TransactionId\n * @typedef {import(\"./client/Client.js\").ClientOperator} ClientOperator\n * @typedef {import(\"./Signer.js\").Signer} Signer\n * @typedef {import(\"./PublicKey.js\").default} PublicKey\n * @typedef {import(\"./logger/Logger.js\").default} Logger\n */\n\n/**\n * @enum {string}\n */\nexport const ExecutionState = {\n Finished: \"Finished\",\n Retry: \"Retry\",\n Error: \"Error\",\n};\n\nexport const RST_STREAM = /\\brst[^0-9a-zA-Z]stream\\b/i;\nexport const DEFAULT_MAX_ATTEMPTS = 10;\n\n/**\n * @abstract\n * @internal\n * @template RequestT\n * @template ResponseT\n * @template OutputT\n */\nexport default class Executable {\n constructor() {\n /**\n * The number of times we can retry the grpc call\n *\n * @internal\n * @type {number}\n */\n this._maxAttempts = DEFAULT_MAX_ATTEMPTS;\n\n /**\n * List of node account IDs for each transaction that has been\n * built.\n *\n * @internal\n * @type {List<AccountId>}\n */\n this._nodeAccountIds = new List();\n\n /**\n * List of the transaction node account IDs to check if\n * the node account ID of the request is in the list\n *\n * @protected\n * @type {Array<string>}\n */\n this.transactionNodeIds = [];\n\n /**\n * @internal\n */\n this._signOnDemand = false;\n\n /**\n * This is the request's min backoff\n *\n * @internal\n * @type {number | null}\n */\n this._minBackoff = null;\n\n /**\n * This is the request's max backoff\n *\n * @internal\n * @type {number}\n */\n this._maxBackoff = 8000;\n\n /**\n * The operator that was used to execute this request.\n * The reason we save the operator in the request is because of the signing on\n * demand feature. This feature requires us to sign new request on each attempt\n * meaning if a client with an operator was used we'd need to sign with the operator\n * on each attempt.\n *\n * @internal\n * @type {ClientOperator | null}\n */\n this._operator = null;\n\n /**\n * The complete timeout for running the `execute()` method\n *\n * @internal\n * @type {number | null}\n */\n this._requestTimeout = null;\n\n /**\n * The grpc request timeout aka deadline.\n *\n * The reason we have this is because there were times that consensus nodes held the grpc\n * connection, but didn't return anything; not error nor regular response. This resulted\n * in some weird behavior in the SDKs. To fix this we've added a grpc deadline to prevent\n * nodes from stalling the executing of a request.\n *\n * @internal\n * @type {number | null}\n */\n this._grpcDeadline = null;\n\n /**\n * Logger\n *\n * @protected\n * @type {Logger | null}\n */\n this._logger = null;\n }\n\n /**\n * Get the list of node account IDs on the request. If no nodes are set, then null is returned.\n * The reasoning for this is simply \"legacy behavior\".\n *\n * @returns {?AccountId[]}\n */\n get nodeAccountIds() {\n if (this._nodeAccountIds.isEmpty) {\n return null;\n } else {\n this._nodeAccountIds.setLocked();\n return this._nodeAccountIds.list;\n }\n }\n\n /**\n * Set the node account IDs on the request\n *\n * @param {AccountId[]} nodeIds\n * @returns {this}\n */\n setNodeAccountIds(nodeIds) {\n // Set the node account IDs, and lock the list. This will require `execute`\n // to use these nodes instead of random nodes from the network.\n this._nodeAccountIds.setList(nodeIds).setLocked();\n return this;\n }\n\n /**\n * @deprecated\n * @returns {number}\n */\n get maxRetries() {\n console.warn(\"Deprecated: use maxAttempts instead\");\n return this.maxAttempts;\n }\n\n /**\n * @param {number} maxRetries\n * @returns {this}\n */\n setMaxRetries(maxRetries) {\n console.warn(\"Deprecated: use setMaxAttempts() instead\");\n return this.setMaxAttempts(maxRetries);\n }\n\n /**\n * Get the max attempts on the request\n *\n * @returns {number}\n */\n get maxAttempts() {\n return this._maxAttempts;\n }\n\n /**\n * Set the max attempts on the request\n *\n * @param {number} maxAttempts\n * @returns {this}\n */\n setMaxAttempts(maxAttempts) {\n this._maxAttempts = maxAttempts;\n\n return this;\n }\n\n /**\n * Get the grpc deadline\n *\n * @returns {?number}\n */\n get grpcDeadline() {\n return this._grpcDeadline;\n }\n\n /**\n * Set the grpc deadline\n *\n * @param {number} grpcDeadline\n * @returns {this}\n */\n setGrpcDeadline(grpcDeadline) {\n this._grpcDeadline = grpcDeadline;\n\n return this;\n }\n\n /**\n * Set the min backoff for the request\n *\n * @param {number} minBackoff\n * @returns {this}\n */\n setMinBackoff(minBackoff) {\n // Honestly we shouldn't be checking for null since that should be TypeScript's job.\n // Also verify that min backoff is not greater than max backoff.\n if (minBackoff == null) {\n throw new Error(\"minBackoff cannot be null.\");\n } else if (this._maxBackoff != null && minBackoff > this._maxBackoff) {\n throw new Error(\"minBackoff cannot be larger than maxBackoff.\");\n }\n this._minBackoff = minBackoff;\n return this;\n }\n\n /**\n * Get the min backoff\n *\n * @returns {number | null}\n */\n get minBackoff() {\n return this._minBackoff;\n }\n\n /**\n * Set the max backoff for the request\n *\n * @param {?number} maxBackoff\n * @returns {this}\n */\n setMaxBackoff(maxBackoff) {\n // Honestly we shouldn't be checking for null since that should be TypeScript's job.\n // Also verify that max backoff is not less than min backoff.\n if (maxBackoff == null) {\n throw new Error(\"maxBackoff cannot be null.\");\n } else if (this._minBackoff != null && maxBackoff < this._minBackoff) {\n throw new Error(\"maxBackoff cannot be smaller than minBackoff.\");\n }\n this._maxBackoff = maxBackoff;\n return this;\n }\n\n /**\n * Get the max backoff\n *\n * @returns {number}\n */\n get maxBackoff() {\n return this._maxBackoff;\n }\n\n /**\n * This method is responsible for doing any work before the executing process begins.\n * For paid queries this will result in executing a cost query, for transactions this\n * will make sure we save the operator and sign any requests that need to be signed\n * in case signing on demand is disabled.\n *\n * @abstract\n * @protected\n * @param {import(\"./client/Client.js\").default<Channel, *>} client\n * @returns {Promise<void>}\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _beforeExecute(client) {\n throw new Error(\"not implemented\");\n }\n\n /**\n * Create a protobuf request which will be passed into the `_execute()` method\n *\n * @abstract\n * @protected\n * @returns {Promise<RequestT>}\n */\n _makeRequestAsync() {\n throw new Error(\"not implemented\");\n }\n\n /**\n * This name is a bit wrong now, but the purpose of this method is to map the\n * request and response into an error. This method will only be called when\n * `_shouldRetry` returned `ExecutionState.Error`\n *\n * @abstract\n * @internal\n * @param {RequestT} request\n * @param {ResponseT} response\n * @param {AccountId} nodeId\n * @returns {Error}\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _mapStatusError(request, response, nodeId) {\n throw new Error(\"not implemented\");\n }\n\n /**\n * Map the request, response, and the node account ID used for this attempt into a response.\n * This method will only be called when `_shouldRetry` returned `ExecutionState.Finished`\n *\n * @abstract\n * @protected\n * @param {ResponseT} response\n * @param {AccountId} nodeAccountId\n * @param {RequestT} request\n * @returns {Promise<OutputT>}\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _mapResponse(response, nodeAccountId, request) {\n throw new Error(\"not implemented\");\n }\n\n /**\n * Perform a single grpc call with the given request. Each request has it's own\n * required service so we just pass in channel, and it'$ the request's responsiblity\n * to use the right service and call the right grpc method.\n *\n * @abstract\n * @internal\n * @param {Channel} channel\n * @param {RequestT} request\n * @returns {Promise<ResponseT>}\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _execute(channel, request) {\n throw new Error(\"not implemented\");\n }\n\n /**\n * Return the current transaction ID for the request. All requests which are\n * use the same transaction ID for each node, but the catch is that `Transaction`\n * implicitly supports chunked transactions. Meaning there could be multiple\n * transaction IDs stored in the request, and a different transaction ID will be used\n * on subsequent calls to `execute()`\n *\n * FIXME: This method can most likely be removed, although some further inspection\n * is required.\n *\n * @abstract\n * @protected\n * @returns {TransactionId}\n */\n _getTransactionId() {\n throw new Error(\"not implemented\");\n }\n\n /**\n * Return the log ID for this particular request\n *\n * Log IDs are simply a string constructed to make it easy to track each request's\n * execution even when mulitple requests are executing in parallel. Typically, this\n * method returns the format of `[<request type>.<timestamp of the transaction ID>]`\n *\n * Maybe we should deduplicate this using ${this.consturtor.name}\n *\n * @abstract\n * @internal\n * @returns {string}\n */\n _getLogId() {\n throw new Error(\"not implemented\");\n }\n\n /**\n * Serialize the request into bytes\n *\n * @abstract\n * @param {RequestT} request\n * @returns {Uint8Array}\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _requestToBytes(request) {\n throw new Error(\"not implemented\");\n }\n\n /**\n * Serialize the response into bytes\n *\n * @abstract\n * @param {ResponseT} response\n * @returns {Uint8Array}\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _responseToBytes(response) {\n throw new Error(\"not implemented\");\n }\n\n /**\n * Determine if we should continue the execution process, error, or finish.\n *\n * FIXME: This method should really be called something else. Initially it returned\n * a boolean so `shouldRetry` made sense, but now it returns an enum, so the name\n * no longer makes sense.\n *\n * @abstract\n * @protected\n * @param {RequestT} request\n * @param {ResponseT} response\n * @returns {[Status, ExecutionState]}\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _shouldRetry(request, response) {\n throw new Error(\"not implemented\");\n }\n\n /**\n * Determine if we should error based on the gRPC status\n *\n * Unlike `shouldRetry` this method does in fact still return a boolean\n *\n * @protected\n * @param {Error} error\n * @returns {boolean}\n */\n _shouldRetryExceptionally(error) {\n if (error instanceof GrpcServiceError) {\n return (\n error.status._code === GrpcStatus.Timeout._code ||\n error.status._code === GrpcStatus.DeadlineExceeded._code ||\n error.status._code === GrpcStatus.Unavailable._code ||\n error.status._code === GrpcStatus.ResourceExhausted._code ||\n error.status._code === GrpcStatus.GrpcWeb._code ||\n (error.status._code === GrpcStatus.Internal._code &&\n RST_STREAM.test(error.message))\n );\n } else {\n // if we get to the 'else' statement, the 'error' is instanceof 'HttpError'\n // and in this case, we have to retry always\n return true;\n }\n }\n\n /**\n * A helper method for setting the operator on the request\n *\n * @internal\n * @param {AccountId} accountId\n * @param {PublicKey} publicKey\n * @param {(message: Uint8Array) => Promise<Uint8Array>} transactionSigner\n * @returns {this}\n */\n _setOperatorWith(accountId, publicKey, transactionSigner) {\n this._operator = {\n transactionSigner,\n accountId,\n publicKey,\n };\n return this;\n }\n\n /**\n * Execute this request using the signer\n *\n * This method is part of the signature providers feature\n * https://hips.hedera.com/hip/hip-338\n *\n * @param {Signer} signer\n * @returns {Promise<OutputT>}\n */\n async executeWithSigner(signer) {\n return signer.call(this);\n }\n\n /**\n * @returns {boolean}\n * @abstract\n * @protected\n */\n isBatchedAndNotBatchTransaction() {\n return false;\n }\n\n /**\n * Execute the request using a client and an optional request timeout\n *\n * @template {Channel} ChannelT\n * @template {MirrorChannel} MirrorChannelT\n * @param {import(\"./client/Client.js\").default<ChannelT, MirrorChannelT>} client\n * @param {number=} requestTimeout\n * @returns {Promise<OutputT>}\n */\n async execute(client, requestTimeout) {\n // we check if its local node then backoff mechanism should be disabled\n // and we increase the retry attempts\n const isLocalNode = client.network[\"127.0.0.1:50211\"] != null;\n\n if (this.isBatchedAndNotBatchTransaction()) {\n throw new Error(\n \"Cannot execute batchified transaction outside of BatchTransaction\",\n );\n }\n\n // If the logger on the request is not set, use the logger in client\n // (if set, otherwise do not use logger)\n this._logger =\n this._logger == null\n ? client._logger != null\n ? client._logger\n : null\n : this._logger;\n\n // If the request timeout is set on the request we'll prioritize that instead\n // of the parameter provided, and if the parameter isn't provided we'll\n // use the default request timeout on client\n if (this._requestTimeout == null) {\n this._requestTimeout =\n requestTimeout != null ? requestTimeout : client.requestTimeout;\n }\n\n // If the grpc deadline is not set on the request, use the default value from client\n if (this._grpcDeadline == null) {\n this._grpcDeadline = client.grpcDeadline;\n }\n\n // Some request need to perform additional requests before the executing\n // such as paid queries need to fetch the cost of the query before\n // finally executing the actual query.\n await this._beforeExecute(client);\n\n // If the max backoff on the request is not set, use the default value in client\n if (this._maxBackoff == null) {\n this._maxBackoff = client.maxBackoff;\n }\n\n // If the min backoff on the request is not set, use the default value in client\n if (this._minBackoff == null) {\n this._minBackoff = client.minBackoff;\n }\n\n // Save the start time to be used later with request timeout\n const startTime = Date.now();\n\n // Saves each error we get so when we err due to max attempts exceeded we'll have\n // the last error that was returned by the consensus node\n let persistentError = null;\n\n // If the max attempts on the request is not set, use the default value in client\n // If the default value in client is not set, use a default of 10.\n //\n // FIXME: current implementation is wrong, update to follow comment above.\n // ... existing code ...\n const LOCAL_NODE_ATTEMPTS = 1000;\n const maxAttempts = isLocalNode\n ? LOCAL_NODE_ATTEMPTS\n : client._maxAttempts ?? this._maxAttempts;\n\n // Checks if has a valid nodes to which the TX can be sent\n if (this.transactionNodeIds.length) {\n const nodeAccountIds = this._nodeAccountIds.list.map((nodeId) =>\n nodeId.toString(),\n );\n\n const hasValidNodes = this.transactionNodeIds.some((nodeId) =>\n nodeAccountIds.includes(nodeId),\n );\n\n if (!hasValidNodes) {\n const displayNodeAccountIds =\n nodeAccountIds.length > 2\n ? `${nodeAccountIds.slice(0, 2).join(\", \")} ...`\n : nodeAccountIds.join(\", \");\n const isSingleNode = nodeAccountIds.length === 1;\n\n throw new Error(\n `Attempting to execute a transaction against node${\n isSingleNode ? \"\" : \"s\"\n } ${displayNodeAccountIds}, ` +\n `which ${\n isSingleNode ? \"is\" : \"are\"\n } not included in the Client's node list. Please review your Client configuration.`,\n );\n }\n }\n\n // The retry loop\n for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {\n // Determine if we've exceeded request timeout\n if (\n this._requestTimeout != null &&\n startTime + this._requestTimeout <= Date.now()\n ) {\n throw new MaxAttemptsOrTimeoutError(\n `timeout exceeded`,\n this._nodeAccountIds.isEmpty\n ? \"No node account ID set\"\n : this._nodeAccountIds.current.toString(),\n );\n }\n\n let nodeAccountId;\n let node;\n\n if (this._nodeAccountIds.isEmpty) {\n node = client._network.getNode();\n nodeAccountId = node.accountId;\n this._nodeAccountIds.setList([nodeAccountId]);\n } else {\n nodeAccountId = this._nodeAccountIds.current;\n node = client._network.getNode(nodeAccountId);\n }\n\n if (node == null) {\n throw new Error(\n `NodeAccountId not recognized: ${nodeAccountId.toString()}`,\n );\n }\n\n if (this.transactionNodeIds.length) {\n const isNodeAccountIdValid = this.transactionNodeIds.includes(\n nodeAccountId.toString(),\n );\n\n if (!isNodeAccountIdValid) {\n console.error(\n `Attempting to execute a transaction against node ${nodeAccountId.toString()}, which is not included in the Client's node list. Please review your Client configuration.`,\n );\n\n this._nodeAccountIds.advance();\n continue;\n }\n }\n\n // Get the log ID for the request.\n const logId = this._getLogId();\n if (this._logger) {\n this._logger.debug(\n `[${logId}] Node AccountID: ${node.accountId.toString()}, IP: ${node.address.toString()}`,\n );\n }\n\n const channel = node.getChannel();\n\n // Set the gRPC deadline on the channel if this query has a custom deadline\n if (this._grpcDeadline != null) {\n channel.setGrpcDeadline(this._grpcDeadline);\n }\n\n const request = await this._makeRequestAsync();\n\n let response;\n\n if (!node.isHealthy()) {\n const isLastNode =\n this._nodeAccountIds.index ===\n this._nodeAccountIds.list.length - 1;\n\n // Check if the request is a transaction receipt or record\n // request to retry 10 times, because getReceiptQuery/getRecordQuery\n // are single node requests\n if (\n isTransactionReceiptOrRecordRequest(request) ||\n isLocalNode\n ) {\n await delayForAttempt(\n isLocalNode,\n attempt,\n this._minBackoff,\n this._maxBackoff,\n );\n continue;\n }\n\n if (isLastNode || this._nodeAccountIds.length <= 1) {\n throw new Error(\n `Network connectivity issue: All nodes are unhealthy. Original node list: ${this._nodeAccountIds.list.join(\n \", \",\n )}`,\n );\n }\n\n if (this._logger) {\n this._logger.debug(\n `[${logId}] Node is not healthy, trying the next node.`,\n );\n }\n\n this._nodeAccountIds.advance();\n continue;\n }\n\n this._nodeAccountIds.advance();\n\n try {\n // Race the execution promise against the grpc timeout to prevent grpc connections\n // from blocking this request\n const promises = [];\n\n // If a grpc deadline is set, we should race it, otherwise the only thing in the\n // list of promises will be the execution promise.\n if (this._grpcDeadline != null) {\n promises.push(\n // eslint-disable-next-line ie11/no-loop-func\n new Promise((_, reject) =>\n setTimeout(\n // eslint-disable-next-line ie11/no-loop-func\n () =>\n reject(\n new GrpcServiceError(\n GrpcStatus.DeadlineExceeded,\n ),\n ),\n /** @type {number=} */ (this._grpcDeadline),\n ),\n ),\n );\n }\n if (this._logger) {\n this._logger.trace(\n `[${this._getLogId()}] sending protobuf ${hex.encode(\n this._requestToBytes(request),\n )}`,\n );\n }\n\n promises.push(this._execute(channel, request));\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n response = /** @type {ResponseT} */ (\n await Promise.race(promises)\n );\n } catch (err) {\n // If we received a grpc status error we need to determine if\n // we should retry on this error, or err from the request entirely.\n const error = GrpcServiceError._fromResponse(\n /** @type {Error} */ (err),\n );\n\n // Save the error in case we retry\n persistentError = error;\n if (this._logger) {\n this._logger.debug(\n `[${logId}] received error ${JSON.stringify(error)}`,\n );\n }\n\n if (\n (error instanceof GrpcServiceError ||\n error instanceof HttpError) &&\n this._shouldRetryExceptionally(error) &&\n attempt <= maxAttempts\n ) {\n // Increase the backoff for the particular node and remove it from\n // the healthy node list\n if (this._logger) {\n this._logger.debug(\n `[${this._getLogId()}] node with accountId: ${node.accountId.toString()} and proxy IP: ${node.address.toString()} is unhealthy`,\n );\n }\n\n client._network.increaseBackoff(node);\n continue;\n }\n\n throw err;\n }\n if (this._logger) {\n this._logger.trace(\n `[${this._getLogId()}] sending protobuf ${hex.encode(\n this._responseToBytes(response),\n )}`,\n );\n }\n\n // If we didn't receive an error we should decrease the current nodes backoff\n // in case it is a recovering node\n client._network.decreaseBackoff(node);\n\n // Determine what execution state we're in by the response\n // For transactions this would be as simple as checking the response status is `OK`\n // while for _most_ queries it would check if the response status is `SUCCESS`\n // The only odd balls are `TransactionReceiptQuery` and `TransactionRecordQuery`\n const [status, shouldRetry] = this._shouldRetry(request, response);\n if (\n status.toString() !== Status.Ok.toString() &&\n status.toString() !== Status.Success.toString()\n ) {\n persistentError = status;\n }\n\n // Determine by the executing state what we should do\n switch (shouldRetry) {\n case ExecutionState.Retry:\n // Special handling for INVALID_NODE_ACCOUNT: mark node as unusable\n // and update network to get latest node account IDs\n if (status === Status.InvalidNodeAccount) {\n if (this._logger) {\n this._logger.debug(\n `[${this._getLogId()}] node with accountId: ${node.accountId.toString()} and proxy IP: ${node.address.toString()} has invalid node account ID, marking as unhealthy and updating network`,\n );\n }\n\n // Mark the node as unusable by increasing its backoff and removing it from the healthy nodes list\n client._network.increaseBackoff(node);\n\n // Initiate addressbook query and update the client's network\n // This will make the SDK client have the latest node account IDs for subsequent transactions\n try {\n if (client.mirrorNetwork.length > 0) {\n await client.updateNetwork();\n } else {\n if (this._logger) {\n this._logger.warn(\n \"Cannot update address book: no mirror network configured. Retrying with existing network configuration.\",\n );\n }\n }\n } catch (error) {\n if (this._logger) {\n const errorMessage =\n error instanceof Error\n ? error.message\n : String(error);\n this._logger.trace(\n `failed to update client address book after INVALID_NODE_ACCOUNT_ID: ${errorMessage}`,\n );\n }\n }\n }\n\n await delayForAttempt(\n isLocalNode,\n attempt,\n this._minBackoff,\n this._maxBackoff,\n );\n continue;\n case ExecutionState.Finished:\n return this._mapResponse(response, nodeAccountId, request);\n case ExecutionState.Error:\n throw this._mapStatusError(\n request,\n response,\n nodeAccountId,\n );\n default:\n throw new Error(\n \"(BUG) non-exhaustive switch statement for `ExecutionState`\",\n );\n }\n }\n\n // We'll only get here if we've run out of attempts, so we return an error wrapping the\n // persistent error we saved before.\n\n throw new MaxAttemptsOrTimeoutError(\n `max attempts of ${maxAttempts.toString()} was reached for request with last error being: ${\n persistentError != null ? persistentError.toString() : \"\"\n }`,\n this._nodeAccountIds.current.toString(),\n );\n }\n\n /**\n * The current purpose of this method is to easily support signature providers since\n * signature providers need to serialize _any_ request into bytes. `Query` and `Transaction`\n * already implement `toBytes()` so it only made sense to make it available here too.\n *\n * @abstract\n * @returns {Uint8Array}\n */\n toBytes() {\n throw new Error(\"not implemented\");\n }\n\n /**\n * Set logger\n *\n * @param {Logger} logger\n * @returns {this}\n */\n setLogger(logger) {\n this._logger = logger;\n return this;\n }\n\n /**\n * Get logger if set\n *\n * @returns {?Logger}\n */\n get logger() {\n return this._logger;\n }\n}\n\n/**\n * Checks if the request is a transaction receipt or record request\n *\n * @template T\n * @param {T} request - The request to check\n * @returns {boolean} - True if the request is a transaction receipt or record\n */\nfunction isTransactionReceiptOrRecordRequest(request) {\n if (typeof request !== \"object\" || request === null) {\n return false;\n }\n\n return (\n \"transactionGetReceipt\" in request || \"transactionGetRecord\" in request\n );\n}\n\n/**\n * A simple function that returns a promise timeout for a specific period of time\n *\n * @param {boolean} isLocalNode\n * @param {number} attempt\n * @param {number} minBackoff\n * @param {number} maxBackoff\n * @returns {Promise<void>}\n */\nfunction delayForAttempt(isLocalNode, attempt, minBackoff, maxBackoff) {\n if (isLocalNode) {\n return new Promise((resolve) => setTimeout(resolve, minBackoff));\n }\n\n // 0.1s, 0.2s, 0.4s, 0.8s, ...\n const ms = Math.min(\n Math.floor(minBackoff * Math.pow(2, attempt)),\n maxBackoff,\n );\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n"],"names":["ExecutionState","Finished","Retry","Error","RST_STREAM","DEFAULT_MAX_ATTEMPTS","Executable","constructor","this","_maxAttempts","_nodeAccountIds","List","transactionNodeIds","_signOnDemand","_minBackoff","_maxBackoff","_operator","_requestTimeout","_grpcDeadline","_logger","nodeAccountIds","isEmpty","setLocked","list","setNodeAccountIds","nodeIds","setList","maxRetries","console","warn","maxAttempts","setMaxRetries","setMaxAttempts","grpcDeadline","setGrpcDeadline","setMinBackoff","minBackoff","setMaxBackoff","maxBackoff","_beforeExecute","client","_makeRequestAsync","_mapStatusError","request","response","nodeId","_mapResponse","nodeAccountId","_execute","channel","_getTransactionId","_getLogId","_requestToBytes","_responseToBytes","_shouldRetry","_shouldRetryExceptionally","error","GrpcServiceError","status","_code","GrpcStatus","Timeout","DeadlineExceeded","Unavailable","ResourceExhausted","GrpcWeb","Internal","test","message","_setOperatorWith","accountId","publicKey","transactionSigner","executeWithSigner","signer","call","isBatchedAndNotBatchTransaction","execute","requestTimeout","isLocalNode","network","startTime","Date","now","persistentError","length","map","toString","some","includes","displayNodeAccountIds","slice","join","isSingleNode","attempt","MaxAttemptsOrTimeoutError","current","node","_network","getNode","advance","logId","debug","address","getChannel","isHealthy","isLastNode","index","isTransactionReceiptOrRecordRequest","delayForAttempt","promises","push","Promise","_","reject","setTimeout","trace","hex.encode","race","err","_fromResponse","JSON","stringify","HttpError","increaseBackoff","decreaseBackoff","shouldRetry","Status","Ok","Success","InvalidNodeAccount","mirrorNetwork","updateNetwork","errorMessage","String","toBytes","setLogger","logger","resolve","ms","Math","min","floor","pow"],"mappings":"0QAwBY,MAACA,EAAiB,CAC1BC,SAAU,WACVC,MAAO,QACPC,MAAO,SAGEC,EAAa,6BACbC,EAAuB,GASrB,MAAMC,EACjB,WAAAC,GAOIC,KAAKC,aAjBuB,GA0B5BD,KAAKE,gBAAkB,IAAIC,EAS3BH,KAAKI,mBAAqB,GAK1BJ,KAAKK,eAAgB,EAQrBL,KAAKM,YAAc,KAQnBN,KAAKO,YAAc,IAYnBP,KAAKQ,UAAY,KAQjBR,KAAKS,gBAAkB,KAavBT,KAAKU,cAAgB,KAQrBV,KAAKW,QAAU,IACvB,CAQI,kBAAIC,GACA,OAAIZ,KAAKE,gBAAgBW,QACd,MAEPb,KAAKE,gBAAgBY,YACdd,KAAKE,gBAAgBa,KAExC,CAQI,iBAAAC,CAAkBC,GAId,OADAjB,KAAKE,gBAAgBgB,QAAQD,GAASH,YAC/Bd,IACf,CAMI,cAAImB,GAEA,OADAC,QAAQC,KAAK,uCACNrB,KAAKsB,WACpB,CAMI,aAAAC,CAAcJ,GAEV,OADAC,QAAQC,KAAK,4CACNrB,KAAKwB,eAAeL,EACnC,CAOI,eAAIG,GACA,OAAOtB,KAAKC,YACpB,CAQI,cAAAuB,CAAeF,GAGX,OAFAtB,KAAKC,aAAeqB,EAEbtB,IACf,CAOI,gBAAIyB,GACA,OAAOzB,KAAKU,aACpB,CAQI,eAAAgB,C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,EAAS1D,EAAYE,GACvD,GAAIyC,EACA,OAAO,IAAIiC,QAAS0B,GAAYvB,WAAWuB,EAAStG,IAIxD,MAAMuG,EAAKC,KAAKC,IACZD,KAAKE,MAAM1G,EAAawG,KAAKG,IAAI,EAAGjD,IACpCxD,GAEJ,OAAO,IAAI0E,QAAS0B,GAAYvB,WAAWuB,EAASC,GACxD"}
|
package/lib/FeeDataType.cjs
CHANGED
|
@@ -44,6 +44,8 @@ class FeeDataType {
|
|
|
44
44
|
return "TOPIC_CREATE_WITH_CUSTOM_FEES";
|
|
45
45
|
case FeeDataType.SubmitMessageWithCustomFees:
|
|
46
46
|
return "SUBMIT_MESSAGE_WITH_CUSTOM_FEES";
|
|
47
|
+
case FeeDataType.CryptoTransferWithHooks:
|
|
48
|
+
return "CRYPTO_TRANSFER_WITH_HOOKS";
|
|
47
49
|
default:
|
|
48
50
|
return `UNKNOWN (${this._code})`;
|
|
49
51
|
}
|
|
@@ -72,6 +74,8 @@ class FeeDataType {
|
|
|
72
74
|
return FeeDataType.TopicCreateWithCustomFees;
|
|
73
75
|
case 7:
|
|
74
76
|
return FeeDataType.SubmitMessageWithCustomFees;
|
|
77
|
+
case 8:
|
|
78
|
+
return FeeDataType.CryptoTransferWithHooks;
|
|
75
79
|
}
|
|
76
80
|
throw new Error(`(BUG) SubType.fromCode() does not handle code: ${code}`);
|
|
77
81
|
}
|
|
@@ -125,4 +129,9 @@ FeeDataType.TopicCreateWithCustomFees = new FeeDataType(6);
|
|
|
125
129
|
* The resource cost for the transaction type includes a ConsensusSubmitMessage
|
|
126
130
|
* for a topic with custom fees.
|
|
127
131
|
*/
|
|
128
|
-
FeeDataType.SubmitMessageWithCustomFees = new FeeDataType(7);
|
|
132
|
+
FeeDataType.SubmitMessageWithCustomFees = new FeeDataType(7);
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* The resource cost for the transaction type includes a CryptoTransfer with hook invocations.
|
|
136
|
+
*/
|
|
137
|
+
FeeDataType.CryptoTransferWithHooks = new FeeDataType(8);
|
package/lib/FeeDataType.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ declare namespace FeeDataType {
|
|
|
35
35
|
let ScheduleCreateContractCall: FeeDataType;
|
|
36
36
|
let TopicCreateWithCustomFees: FeeDataType;
|
|
37
37
|
let SubmitMessageWithCustomFees: FeeDataType;
|
|
38
|
+
let CryptoTransferWithHooks: FeeDataType;
|
|
38
39
|
}
|
|
39
40
|
export default FeeDataType;
|
|
40
41
|
export namespace HieroProto {
|
package/lib/FeeDataType.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
class e{constructor(e){this._code=e,Object.freeze(this)}toString(){switch(this){case e.Default:return"DEFAULT";case e.TokenFungibleCommon:return"TOKEN_FUNGIBLE_COMMON";case e.TokenNonFungibleUnique:return"TOKEN_NON_FUNGIBLE_UNIQUE";case e.TokenFungibleCommonWithCustomFees:return"TOKEN_FUNGIBLE_COMMON_WITH_CUSTOM_FEES";case e.TokenNonFungibleUniqueWithCustomFees:return"TOKEN_NON_FUNGIBLE_UNIQUE_WITH_CUSTOM_FEES";case e.ScheduleCreateContractCall:return"SCHEDULE_CREATE_CONTRACT_CALL";case e.TopicCreateWithCustomFees:return"TOPIC_CREATE_WITH_CUSTOM_FEES";case e.SubmitMessageWithCustomFees:return"SUBMIT_MESSAGE_WITH_CUSTOM_FEES";default:return`UNKNOWN (${this._code})`}}static _fromCode(t){switch(t){case 0:return e.Default;case 1:return e.TokenFungibleCommon;case 2:return e.TokenNonFungibleUnique;case 3:return e.TokenFungibleCommonWithCustomFees;case 4:return e.TokenNonFungibleUniqueWithCustomFees;case 5:return e.ScheduleCreateContractCall;case 6:return e.TopicCreateWithCustomFees;case 7:return e.SubmitMessageWithCustomFees}throw new Error(`(BUG) SubType.fromCode() does not handle code: ${t}`)}valueOf(){return this._code}}e.Default=new e(0),e.TokenFungibleCommon=new e(1),e.TokenNonFungibleUnique=new e(2),e.TokenFungibleCommonWithCustomFees=new e(3),e.TokenNonFungibleUniqueWithCustomFees=new e(4),e.ScheduleCreateContractCall=new e(5),e.TopicCreateWithCustomFees=new e(6),e.SubmitMessageWithCustomFees=new e(7);export{e as default};
|
|
1
|
+
class e{constructor(e){this._code=e,Object.freeze(this)}toString(){switch(this){case e.Default:return"DEFAULT";case e.TokenFungibleCommon:return"TOKEN_FUNGIBLE_COMMON";case e.TokenNonFungibleUnique:return"TOKEN_NON_FUNGIBLE_UNIQUE";case e.TokenFungibleCommonWithCustomFees:return"TOKEN_FUNGIBLE_COMMON_WITH_CUSTOM_FEES";case e.TokenNonFungibleUniqueWithCustomFees:return"TOKEN_NON_FUNGIBLE_UNIQUE_WITH_CUSTOM_FEES";case e.ScheduleCreateContractCall:return"SCHEDULE_CREATE_CONTRACT_CALL";case e.TopicCreateWithCustomFees:return"TOPIC_CREATE_WITH_CUSTOM_FEES";case e.SubmitMessageWithCustomFees:return"SUBMIT_MESSAGE_WITH_CUSTOM_FEES";case e.CryptoTransferWithHooks:return"CRYPTO_TRANSFER_WITH_HOOKS";default:return`UNKNOWN (${this._code})`}}static _fromCode(t){switch(t){case 0:return e.Default;case 1:return e.TokenFungibleCommon;case 2:return e.TokenNonFungibleUnique;case 3:return e.TokenFungibleCommonWithCustomFees;case 4:return e.TokenNonFungibleUniqueWithCustomFees;case 5:return e.ScheduleCreateContractCall;case 6:return e.TopicCreateWithCustomFees;case 7:return e.SubmitMessageWithCustomFees;case 8:return e.CryptoTransferWithHooks}throw new Error(`(BUG) SubType.fromCode() does not handle code: ${t}`)}valueOf(){return this._code}}e.Default=new e(0),e.TokenFungibleCommon=new e(1),e.TokenNonFungibleUnique=new e(2),e.TokenFungibleCommonWithCustomFees=new e(3),e.TokenNonFungibleUniqueWithCustomFees=new e(4),e.ScheduleCreateContractCall=new e(5),e.TopicCreateWithCustomFees=new e(6),e.SubmitMessageWithCustomFees=new e(7),e.CryptoTransferWithHooks=new e(8);export{e as default};
|
|
2
2
|
//# sourceMappingURL=FeeDataType.js.map
|
package/lib/FeeDataType.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeeDataType.js","sources":["../src/FeeDataType.js"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * @namespace proto\n * @typedef {import(\"@hiero-ledger/proto\").proto.SubType} HieroProto.proto.SubType\n */\n\nexport default class FeeDataType {\n /**\n * @hideconstructor\n * @internal\n * @param {number} code\n */\n constructor(code) {\n /** @readonly */\n this._code = code;\n\n Object.freeze(this);\n }\n\n /**\n * @returns {string}\n */\n toString() {\n switch (this) {\n case FeeDataType.Default:\n return \"DEFAULT\";\n case FeeDataType.TokenFungibleCommon:\n return \"TOKEN_FUNGIBLE_COMMON\";\n case FeeDataType.TokenNonFungibleUnique:\n return \"TOKEN_NON_FUNGIBLE_UNIQUE\";\n case FeeDataType.TokenFungibleCommonWithCustomFees:\n return \"TOKEN_FUNGIBLE_COMMON_WITH_CUSTOM_FEES\";\n case FeeDataType.TokenNonFungibleUniqueWithCustomFees:\n return \"TOKEN_NON_FUNGIBLE_UNIQUE_WITH_CUSTOM_FEES\";\n case FeeDataType.ScheduleCreateContractCall:\n return \"SCHEDULE_CREATE_CONTRACT_CALL\";\n case FeeDataType.TopicCreateWithCustomFees:\n return \"TOPIC_CREATE_WITH_CUSTOM_FEES\";\n case FeeDataType.SubmitMessageWithCustomFees:\n return \"SUBMIT_MESSAGE_WITH_CUSTOM_FEES\";\n default:\n return `UNKNOWN (${this._code})`;\n }\n }\n\n /**\n * @internal\n * @param {number} code\n * @returns {FeeDataType}\n */\n static _fromCode(code) {\n switch (code) {\n case 0:\n return FeeDataType.Default;\n case 1:\n return FeeDataType.TokenFungibleCommon;\n case 2:\n return FeeDataType.TokenNonFungibleUnique;\n case 3:\n return FeeDataType.TokenFungibleCommonWithCustomFees;\n case 4:\n return FeeDataType.TokenNonFungibleUniqueWithCustomFees;\n case 5:\n return FeeDataType.ScheduleCreateContractCall;\n case 6:\n return FeeDataType.TopicCreateWithCustomFees;\n case 7:\n return FeeDataType.SubmitMessageWithCustomFees;\n }\n\n throw new Error(\n `(BUG) SubType.fromCode() does not handle code: ${code}`,\n );\n }\n\n /**\n * @returns {HieroProto.proto.SubType}\n */\n valueOf() {\n return this._code;\n }\n}\n\n/**\n * The resource prices have no special scope\n */\nFeeDataType.Default = new FeeDataType(0);\n\n/**\n * The resource prices are scoped to an operation on a fungible common token\n */\nFeeDataType.TokenFungibleCommon = new FeeDataType(1);\n\n/**\n * The resource prices are scoped to an operation on a non-fungible unique token\n */\nFeeDataType.TokenNonFungibleUnique = new FeeDataType(2);\n\n/**\n * The resource prices are scoped to an operation on a fungible common token with a custom fee schedule\n */\nFeeDataType.TokenFungibleCommonWithCustomFees = new FeeDataType(3);\n\n/**\n * The resource prices are scoped to an operation on a non-fungible unique token with a custom fee schedule\n */\nFeeDataType.TokenNonFungibleUniqueWithCustomFees = new FeeDataType(4);\n\n/**\n * The resource prices are scoped to a ScheduleCreate containing a ContractCall.\n */\nFeeDataType.ScheduleCreateContractCall = new FeeDataType(5);\n\n/**\n * The resource cost for the transaction type includes a TopicCreate\n * with custom fees.\n */\nFeeDataType.TopicCreateWithCustomFees = new FeeDataType(6);\n\n/**\n * The resource cost for the transaction type includes a ConsensusSubmitMessage\n * for a topic with custom fees.\n */\nFeeDataType.SubmitMessageWithCustomFees = new FeeDataType(7);\n"],"names":["FeeDataType","constructor","code","this","_code","Object","freeze","toString","Default","TokenFungibleCommon","TokenNonFungibleUnique","TokenFungibleCommonWithCustomFees","TokenNonFungibleUniqueWithCustomFees","ScheduleCreateContractCall","TopicCreateWithCustomFees","SubmitMessageWithCustomFees","_fromCode","Error","valueOf"],"mappings":"AAOe,MAAMA,EAMjB,WAAAC,CAAYC,GAERC,KAAKC,MAAQF,EAEbG,OAAOC,OAAOH,KACtB,CAKI,QAAAI,GACI,OAAQJ,MACJ,KAAKH,EAAYQ,QACb,MAAO,UACX,KAAKR,EAAYS,oBACb,MAAO,wBACX,KAAKT,EAAYU,uBACb,MAAO,4BACX,KAAKV,EAAYW,kCACb,MAAO,yCACX,KAAKX,EAAYY,qCACb,MAAO,6CACX,KAAKZ,EAAYa,2BACb,MAAO,gCACX,KAAKb,EAAYc,0BACb,MAAO,gCACX,KAAKd,EAAYe,4BACb,MAAO,kCACX,QACI,MAAO,
|
|
1
|
+
{"version":3,"file":"FeeDataType.js","sources":["../src/FeeDataType.js"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * @namespace proto\n * @typedef {import(\"@hiero-ledger/proto\").proto.SubType} HieroProto.proto.SubType\n */\n\nexport default class FeeDataType {\n /**\n * @hideconstructor\n * @internal\n * @param {number} code\n */\n constructor(code) {\n /** @readonly */\n this._code = code;\n\n Object.freeze(this);\n }\n\n /**\n * @returns {string}\n */\n toString() {\n switch (this) {\n case FeeDataType.Default:\n return \"DEFAULT\";\n case FeeDataType.TokenFungibleCommon:\n return \"TOKEN_FUNGIBLE_COMMON\";\n case FeeDataType.TokenNonFungibleUnique:\n return \"TOKEN_NON_FUNGIBLE_UNIQUE\";\n case FeeDataType.TokenFungibleCommonWithCustomFees:\n return \"TOKEN_FUNGIBLE_COMMON_WITH_CUSTOM_FEES\";\n case FeeDataType.TokenNonFungibleUniqueWithCustomFees:\n return \"TOKEN_NON_FUNGIBLE_UNIQUE_WITH_CUSTOM_FEES\";\n case FeeDataType.ScheduleCreateContractCall:\n return \"SCHEDULE_CREATE_CONTRACT_CALL\";\n case FeeDataType.TopicCreateWithCustomFees:\n return \"TOPIC_CREATE_WITH_CUSTOM_FEES\";\n case FeeDataType.SubmitMessageWithCustomFees:\n return \"SUBMIT_MESSAGE_WITH_CUSTOM_FEES\";\n case FeeDataType.CryptoTransferWithHooks:\n return \"CRYPTO_TRANSFER_WITH_HOOKS\";\n default:\n return `UNKNOWN (${this._code})`;\n }\n }\n\n /**\n * @internal\n * @param {number} code\n * @returns {FeeDataType}\n */\n static _fromCode(code) {\n switch (code) {\n case 0:\n return FeeDataType.Default;\n case 1:\n return FeeDataType.TokenFungibleCommon;\n case 2:\n return FeeDataType.TokenNonFungibleUnique;\n case 3:\n return FeeDataType.TokenFungibleCommonWithCustomFees;\n case 4:\n return FeeDataType.TokenNonFungibleUniqueWithCustomFees;\n case 5:\n return FeeDataType.ScheduleCreateContractCall;\n case 6:\n return FeeDataType.TopicCreateWithCustomFees;\n case 7:\n return FeeDataType.SubmitMessageWithCustomFees;\n case 8:\n return FeeDataType.CryptoTransferWithHooks;\n }\n\n throw new Error(\n `(BUG) SubType.fromCode() does not handle code: ${code}`,\n );\n }\n\n /**\n * @returns {HieroProto.proto.SubType}\n */\n valueOf() {\n return this._code;\n }\n}\n\n/**\n * The resource prices have no special scope\n */\nFeeDataType.Default = new FeeDataType(0);\n\n/**\n * The resource prices are scoped to an operation on a fungible common token\n */\nFeeDataType.TokenFungibleCommon = new FeeDataType(1);\n\n/**\n * The resource prices are scoped to an operation on a non-fungible unique token\n */\nFeeDataType.TokenNonFungibleUnique = new FeeDataType(2);\n\n/**\n * The resource prices are scoped to an operation on a fungible common token with a custom fee schedule\n */\nFeeDataType.TokenFungibleCommonWithCustomFees = new FeeDataType(3);\n\n/**\n * The resource prices are scoped to an operation on a non-fungible unique token with a custom fee schedule\n */\nFeeDataType.TokenNonFungibleUniqueWithCustomFees = new FeeDataType(4);\n\n/**\n * The resource prices are scoped to a ScheduleCreate containing a ContractCall.\n */\nFeeDataType.ScheduleCreateContractCall = new FeeDataType(5);\n\n/**\n * The resource cost for the transaction type includes a TopicCreate\n * with custom fees.\n */\nFeeDataType.TopicCreateWithCustomFees = new FeeDataType(6);\n\n/**\n * The resource cost for the transaction type includes a ConsensusSubmitMessage\n * for a topic with custom fees.\n */\nFeeDataType.SubmitMessageWithCustomFees = new FeeDataType(7);\n\n/**\n * The resource cost for the transaction type includes a CryptoTransfer with hook invocations.\n */\nFeeDataType.CryptoTransferWithHooks = new FeeDataType(8);\n"],"names":["FeeDataType","constructor","code","this","_code","Object","freeze","toString","Default","TokenFungibleCommon","TokenNonFungibleUnique","TokenFungibleCommonWithCustomFees","TokenNonFungibleUniqueWithCustomFees","ScheduleCreateContractCall","TopicCreateWithCustomFees","SubmitMessageWithCustomFees","CryptoTransferWithHooks","_fromCode","Error","valueOf"],"mappings":"AAOe,MAAMA,EAMjB,WAAAC,CAAYC,GAERC,KAAKC,MAAQF,EAEbG,OAAOC,OAAOH,KACtB,CAKI,QAAAI,GACI,OAAQJ,MACJ,KAAKH,EAAYQ,QACb,MAAO,UACX,KAAKR,EAAYS,oBACb,MAAO,wBACX,KAAKT,EAAYU,uBACb,MAAO,4BACX,KAAKV,EAAYW,kCACb,MAAO,yCACX,KAAKX,EAAYY,qCACb,MAAO,6CACX,KAAKZ,EAAYa,2BACb,MAAO,gCACX,KAAKb,EAAYc,0BACb,MAAO,gCACX,KAAKd,EAAYe,4BACb,MAAO,kCACX,KAAKf,EAAYgB,wBACb,MAAO,6BACX,QACI,MAAO,YAAYb,KAAKC,SAExC,CAOI,gBAAOa,CAAUf,GACb,OAAQA,GACJ,KAAK,EACD,OAAOF,EAAYQ,QACvB,KAAK,EACD,OAAOR,EAAYS,oBACvB,KAAK,EACD,OAAOT,EAAYU,uBACvB,KAAK,EACD,OAAOV,EAAYW,kCACvB,KAAK,EACD,OAAOX,EAAYY,qCACvB,KAAK,EACD,OAAOZ,EAAYa,2BACvB,KAAK,EACD,OAAOb,EAAYc,0BACvB,KAAK,EACD,OAAOd,EAAYe,4BACvB,KAAK,EACD,OAAOf,EAAYgB,wBAG3B,MAAM,IAAIE,MACN,kDAAkDhB,IAE9D,CAKI,OAAAiB,GACI,OAAOhB,KAAKC,KACpB,EAMAJ,EAAYQ,QAAU,IAAIR,EAAY,GAKtCA,EAAYS,oBAAsB,IAAIT,EAAY,GAKlDA,EAAYU,uBAAyB,IAAIV,EAAY,GAKrDA,EAAYW,kCAAoC,IAAIX,EAAY,GAKhEA,EAAYY,qCAAuC,IAAIZ,EAAY,GAKnEA,EAAYa,2BAA6B,IAAIb,EAAY,GAMzDA,EAAYc,0BAA4B,IAAId,EAAY,GAMxDA,EAAYe,4BAA8B,IAAIf,EAAY,GAK1DA,EAAYgB,wBAA0B,IAAIhB,EAAY"}
|
package/lib/RequestType.cjs
CHANGED
|
@@ -218,6 +218,10 @@ class RequestType {
|
|
|
218
218
|
return "CrsPublication";
|
|
219
219
|
case RequestType.AtomicBatch:
|
|
220
220
|
return "AtomicBatch";
|
|
221
|
+
case RequestType.LambdaSStore:
|
|
222
|
+
return "LambdaSStore";
|
|
223
|
+
case RequestType.HookDispatch:
|
|
224
|
+
return "HookDispatch";
|
|
221
225
|
default:
|
|
222
226
|
return `UNKNOWN (${this._code})`;
|
|
223
227
|
}
|
|
@@ -420,6 +424,10 @@ class RequestType {
|
|
|
420
424
|
return RequestType.CrsPublication;
|
|
421
425
|
case 108:
|
|
422
426
|
return RequestType.AtomicBatch;
|
|
427
|
+
case 109:
|
|
428
|
+
return RequestType.LambdaSStore;
|
|
429
|
+
case 110:
|
|
430
|
+
return RequestType.HookDispatch;
|
|
423
431
|
}
|
|
424
432
|
throw new Error(`(BUG) RequestType.fromCode() does not handle code: ${code}`);
|
|
425
433
|
}
|
|
@@ -919,4 +927,14 @@ RequestType.HistoryProofVote = new RequestType(106);
|
|
|
919
927
|
/**
|
|
920
928
|
* Sign a particular atomic batch.
|
|
921
929
|
*/
|
|
922
|
-
RequestType.AtomicBatch = new RequestType(108);
|
|
930
|
+
RequestType.AtomicBatch = new RequestType(108);
|
|
931
|
+
|
|
932
|
+
/**
|
|
933
|
+
* lambda s store
|
|
934
|
+
*/
|
|
935
|
+
RequestType.LambdaSStore = new RequestType(109);
|
|
936
|
+
|
|
937
|
+
/**
|
|
938
|
+
* hook dispatch
|
|
939
|
+
*/
|
|
940
|
+
RequestType.HookDispatch = new RequestType(110);
|
package/lib/RequestType.d.ts
CHANGED
|
@@ -122,6 +122,8 @@ declare namespace RequestType {
|
|
|
122
122
|
let HistoryProofVote: RequestType;
|
|
123
123
|
let CrsPublication: RequestType;
|
|
124
124
|
let AtomicBatch: RequestType;
|
|
125
|
+
let LambdaSStore: RequestType;
|
|
126
|
+
let HookDispatch: RequestType;
|
|
125
127
|
}
|
|
126
128
|
export default RequestType;
|
|
127
129
|
export namespace HieroProto {
|
package/lib/RequestType.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
class e{constructor(e){this._code=e,Object.freeze(this)}toString(){switch(this){case e.None:return"NONE";case e.CryptoTransfer:return"CryptoTransfer";case e.CryptoUpdate:return"CryptoUpdate";case e.CryptoDelete:return"CryptoDelete";case e.CryptoAddLiveHash:return"CryptoAddLiveHash";case e.CryptoDeleteLiveHash:return"CryptoDeleteLiveHash";case e.ContractCall:return"ContractCall";case e.ContractCreate:return"ContractCreate";case e.ContractUpdate:return"ContractUpdate";case e.FileCreate:return"FileCreate";case e.FileAppend:return"FileAppend";case e.FileUpdate:return"FileUpdate";case e.FileDelete:return"FileDelete";case e.CryptoGetAccountBalance:return"CryptoGetAccountBalance";case e.CryptoGetAccountRecords:return"CryptoGetAccountRecords";case e.CryptoGetInfo:return"CryptoGetInfo";case e.ContractCallLocal:return"ContractCallLocal";case e.ContractGetInfo:return"ContractGetInfo";case e.ContractGetBytecode:return"ContractGetBytecode";case e.GetBySolidityID:return"GetBySolidityID";case e.GetByKey:return"GetByKey";case e.CryptoGetLiveHash:return"CryptoGetLiveHash";case e.CryptoGetStakers:return"CryptoGetStakers";case e.FileGetContents:return"FileGetContents";case e.FileGetInfo:return"FileGetInfo";case e.TransactionGetRecord:return"TransactionGetRecord";case e.ContractGetRecords:return"ContractGetRecords";case e.CryptoCreate:return"CryptoCreate";case e.SystemDelete:return"SystemDelete";case e.SystemUndelete:return"SystemUndelete";case e.ContractDelete:return"ContractDelete";case e.Freeze:return"Freeze";case e.CreateTransactionRecord:return"CreateTransactionRecord";case e.CryptoAccountAutoRenew:return"CryptoAccountAutoRenew";case e.ContractAutoRenew:return"ContractAutoRenew";case e.GetVersionInfo:return"GetVersionInfo";case e.TransactionGetReceipt:return"TransactionGetReceipt";case e.ConsensusCreateTopic:return"ConsensusCreateTopic";case e.ConsensusUpdateTopic:return"ConsensusUpdateTopic";case e.ConsensusDeleteTopic:return"ConsensusDeleteTopic";case e.ConsensusGetTopicInfo:return"ConsensusGetTopicInfo";case e.ConsensusSubmitMessage:return"ConsensusSubmitMessage";case e.UncheckedSubmit:return"UncheckedSubmit";case e.TokenCreate:return"TokenCreate";case e.TokenGetInfo:return"TokenGetInfo";case e.TokenFreezeAccount:return"TokenFreezeAccount";case e.TokenUnfreezeAccount:return"TokenUnfreezeAccount";case e.TokenGrantKycToAccount:return"TokenGrantKycToAccount";case e.TokenRevokeKycFromAccount:return"TokenRevokeKycFromAccount";case e.TokenDelete:return"TokenDelete";case e.TokenUpdate:return"TokenUpdate";case e.TokenMint:return"TokenMint";case e.TokenBurn:return"TokenBurn";case e.TokenAccountWipe:return"TokenAccountWipe";case e.TokenAssociateToAccount:return"TokenAssociateToAccount";case e.TokenDissociateFromAccount:return"TokenDissociateFromAccount";case e.ScheduleCreate:return"ScheduleCreate";case e.ScheduleDelete:return"ScheduleDelete";case e.ScheduleSign:return"ScheduleSign";case e.ScheduleGetInfo:return"ScheduleGetInfo";case e.TokenGetAccountNftInfos:return"TokenGetAccountNftInfos";case e.TokenGetNftInfo:return"TokenGetNftInfo";case e.TokenGetNftInfos:return"TokenGetNftInfos";case e.TokenFeeScheduleUpdate:return"TokenFeeScheduleUpdate";case e.NetworkGetExecutionTime:return"NetworkGetExecutionTime";case e.TokenPause:return"TokenPause";case e.TokenUnpause:return"TokenUnpause";case e.CryptoApproveAllowance:return"CryptoApproveAllowance";case e.CryptoDeleteAllowance:return"CryptoDeleteAllowance";case e.GetAccountDetails:return"GetAccountDetails";case e.EthereumTransaction:return"EthereumTransaction";case e.NodeStakeUpdate:return"NodeStakeUpdate";case e.Prng:return"UtilPrng";case e.TransactionGetFastRecord:return"TransactionGetFastRecord";case e.TokenUpdateNfts:return"TokenUpdateNfts";case e.NodeCreate:return"NodeCreate";case e.NodeUpdate:return"NodeUpdate";case e.NodeDelete:return"NodeDelete";case e.TokenReject:return"TokenReject";case e.TokenAirdrop:return"TokenAirdrop";case e.TokenCancelAirdrop:return"TokenCancelAirdrop";case e.TokenClaimAirdrop:return"TokenClaimAirdrop";case e.TssMessage:return"TssMessage";case e.TssVote:return"TssVote";case e.TssShareSignature:return"TssShareSignature";case e.TssEncryptionKey:return"TssEncryptionKey";case e.StateSignatureTransaction:return"StateSignatureTransaction";case e.HistoryAssemblySignature:return"HistoryAssemblySignature";case e.HistoryProofKeyPublication:return"HistoryProofKeyPublication";case e.HistoryProofVote:return"HistoryProofVote";case e.HintsKeyPublication:return"HintsKeyPublication";case e.HintsPreprocessingVote:return"HintsPreprocessingVote";case e.HintsPartialSignature:return"HintsPartialSignature";case e.CrsPublication:return"CrsPublication";case e.AtomicBatch:return"AtomicBatch";default:return`UNKNOWN (${this._code})`}}static _fromCode(t){switch(t){case 0:return e.None;case 1:return e.CryptoTransfer;case 2:return e.CryptoUpdate;case 3:return e.CryptoDelete;case 4:return e.CryptoAddLiveHash;case 5:return e.CryptoDeleteLiveHash;case 6:return e.ContractCall;case 7:return e.ContractCreate;case 8:return e.ContractUpdate;case 9:return e.FileCreate;case 10:return e.FileAppend;case 11:return e.FileUpdate;case 12:return e.FileDelete;case 13:return e.CryptoGetAccountBalance;case 14:return e.CryptoGetAccountRecords;case 15:return e.CryptoGetInfo;case 16:return e.ContractCallLocal;case 17:return e.ContractGetInfo;case 18:return e.ContractGetBytecode;case 19:return e.GetBySolidityID;case 20:return e.GetByKey;case 21:return e.CryptoGetLiveHash;case 22:return e.CryptoGetStakers;case 23:return e.FileGetContents;case 24:return e.FileGetInfo;case 25:return e.TransactionGetRecord;case 26:return e.ContractGetRecords;case 27:return e.CryptoCreate;case 28:return e.SystemDelete;case 29:return e.SystemUndelete;case 30:return e.ContractDelete;case 31:return e.Freeze;case 32:return e.CreateTransactionRecord;case 33:return e.CryptoAccountAutoRenew;case 34:return e.ContractAutoRenew;case 35:return e.GetVersionInfo;case 36:return e.TransactionGetReceipt;case 50:return e.ConsensusCreateTopic;case 51:return e.ConsensusUpdateTopic;case 52:return e.ConsensusDeleteTopic;case 53:return e.ConsensusGetTopicInfo;case 54:return e.ConsensusSubmitMessage;case 55:return e.UncheckedSubmit;case 56:return e.TokenCreate;case 58:return e.TokenGetInfo;case 59:return e.TokenFreezeAccount;case 60:return e.TokenUnfreezeAccount;case 61:return e.TokenGrantKycToAccount;case 62:return e.TokenRevokeKycFromAccount;case 63:return e.TokenDelete;case 64:return e.TokenUpdate;case 65:return e.TokenMint;case 66:return e.TokenBurn;case 67:return e.TokenAccountWipe;case 68:return e.TokenAssociateToAccount;case 69:return e.TokenDissociateFromAccount;case 70:return e.ScheduleCreate;case 71:return e.ScheduleDelete;case 72:return e.ScheduleSign;case 73:return e.ScheduleGetInfo;case 74:return e.TokenGetAccountNftInfos;case 75:return e.TokenGetNftInfo;case 76:return e.TokenGetNftInfos;case 77:return e.TokenFeeScheduleUpdate;case 78:return e.NetworkGetExecutionTime;case 79:return e.TokenPause;case 80:return e.TokenUnpause;case 81:return e.CryptoApproveAllowance;case 82:return e.CryptoDeleteAllowance;case 83:return e.GetAccountDetails;case 84:return e.EthereumTransaction;case 85:return e.NodeStakeUpdate;case 86:return e.Prng;case 87:return e.TransactionGetFastRecord;case 88:return e.TokenUpdateNfts;case 89:return e.NodeCreate;case 90:return e.NodeUpdate;case 91:return e.NodeDelete;case 92:return e.TokenReject;case 93:return e.TokenAirdrop;case 94:return e.TokenCancelAirdrop;case 95:return e.TokenClaimAirdrop;case 96:return e.TssMessage;case 97:return e.TssVote;case 98:return e.TssShareSignature;case 99:return e.TssEncryptionKey;case 100:return e.StateSignatureTransaction;case 101:return e.HintsKeyPublication;case 102:return e.HintsPreprocessingVote;case 103:return e.HintsPartialSignature;case 104:return e.HistoryAssemblySignature;case 105:return e.HistoryProofKeyPublication;case 106:return e.HistoryProofVote;case 107:return e.CrsPublication;case 108:return e.AtomicBatch}throw new Error(`(BUG) RequestType.fromCode() does not handle code: ${t}`)}valueOf(){return this._code}}e.None=new e(0),e.CryptoTransfer=new e(1),e.CryptoUpdate=new e(2),e.CryptoDelete=new e(3),e.CryptoAddLiveHash=new e(4),e.CryptoDeleteLiveHash=new e(5),e.ContractCall=new e(6),e.ContractCreate=new e(7),e.ContractUpdate=new e(8),e.FileCreate=new e(9),e.FileAppend=new e(10),e.FileUpdate=new e(11),e.FileDelete=new e(12),e.CryptoGetAccountBalance=new e(13),e.CryptoGetAccountRecords=new e(14),e.CryptoGetInfo=new e(15),e.ContractCallLocal=new e(16),e.ContractGetInfo=new e(17),e.ContractGetBytecode=new e(18),e.GetBySolidityID=new e(19),e.GetByKey=new e(20),e.CryptoGetLiveHash=new e(21),e.CryptoGetStakers=new e(22),e.FileGetContents=new e(23),e.FileGetInfo=new e(24),e.TransactionGetRecord=new e(25),e.ContractGetRecords=new e(26),e.CryptoCreate=new e(27),e.SystemDelete=new e(28),e.SystemUndelete=new e(29),e.ContractDelete=new e(30),e.Freeze=new e(31),e.CreateTransactionRecord=new e(32),e.CryptoAccountAutoRenew=new e(33),e.ContractAutoRenew=new e(34),e.GetVersionInfo=new e(35),e.TransactionGetReceipt=new e(36),e.ConsensusCreateTopic=new e(50),e.ConsensusUpdateTopic=new e(51),e.ConsensusDeleteTopic=new e(52),e.ConsensusGetTopicInfo=new e(53),e.ConsensusSubmitMessage=new e(54),e.UncheckedSubmit=new e(55),e.TokenCreate=new e(56),e.TokenGetInfo=new e(58),e.TokenFreezeAccount=new e(59),e.TokenUnfreezeAccount=new e(60),e.TokenGrantKycToAccount=new e(61),e.TokenRevokeKycFromAccount=new e(62),e.TokenDelete=new e(63),e.TokenUpdate=new e(64),e.TokenMint=new e(65),e.TokenBurn=new e(66),e.TokenAccountWipe=new e(67),e.TokenAssociateToAccount=new e(68),e.TokenDissociateFromAccount=new e(69),e.ScheduleCreate=new e(70),e.ScheduleDelete=new e(71),e.ScheduleSign=new e(72),e.ScheduleGetInfo=new e(73),e.TokenGetAccountNftInfos=new e(74),e.TokenGetNftInfo=new e(75),e.TokenGetNftInfos=new e(76),e.TokenFeeScheduleUpdate=new e(77),e.NetworkGetExecutionTime=new e(78),e.TokenPause=new e(79),e.TokenUnpause=new e(80),e.CryptoApproveAllowance=new e(81),e.CryptoDeleteAllowance=new e(82),e.GetAccountDetails=new e(83),e.EthereumTransaction=new e(84),e.NodeStakeUpdate=new e(85),e.Prng=new e(86),e.TransactionGetFastRecord=new e(87),e.TokenUpdateNfts=new e(88),e.NodeCreate=new e(89),e.NodeUpdate=new e(90),e.NodeDelete=new e(91),e.TokenReject=new e(92),e.TokenAirdrop=new e(93),e.TokenCancelAirdrop=new e(94),e.TokenClaimAirdrop=new e(95),e.TssMessage=new e(96),e.TssVote=new e(97),e.TssShareSignature=new e(98),e.TssEncryptionKey=new e(99),e.StateSignatureTransaction=new e(100),e.HintsKeyPublication=new e(101),e.HintsPreprocessingVote=new e(102),e.HintsPartialSignature=new e(103),e.HistoryAssemblySignature=new e(104),e.HistoryProofKeyPublication=new e(105),e.HistoryProofVote=new e(106),e.CrsPublication=new e(107),e.HistoryAssemblySignature=new e(104),e.HistoryProofKeyPublication=new e(105),e.HistoryProofVote=new e(106),e.AtomicBatch=new e(108);export{e as default};
|
|
1
|
+
class e{constructor(e){this._code=e,Object.freeze(this)}toString(){switch(this){case e.None:return"NONE";case e.CryptoTransfer:return"CryptoTransfer";case e.CryptoUpdate:return"CryptoUpdate";case e.CryptoDelete:return"CryptoDelete";case e.CryptoAddLiveHash:return"CryptoAddLiveHash";case e.CryptoDeleteLiveHash:return"CryptoDeleteLiveHash";case e.ContractCall:return"ContractCall";case e.ContractCreate:return"ContractCreate";case e.ContractUpdate:return"ContractUpdate";case e.FileCreate:return"FileCreate";case e.FileAppend:return"FileAppend";case e.FileUpdate:return"FileUpdate";case e.FileDelete:return"FileDelete";case e.CryptoGetAccountBalance:return"CryptoGetAccountBalance";case e.CryptoGetAccountRecords:return"CryptoGetAccountRecords";case e.CryptoGetInfo:return"CryptoGetInfo";case e.ContractCallLocal:return"ContractCallLocal";case e.ContractGetInfo:return"ContractGetInfo";case e.ContractGetBytecode:return"ContractGetBytecode";case e.GetBySolidityID:return"GetBySolidityID";case e.GetByKey:return"GetByKey";case e.CryptoGetLiveHash:return"CryptoGetLiveHash";case e.CryptoGetStakers:return"CryptoGetStakers";case e.FileGetContents:return"FileGetContents";case e.FileGetInfo:return"FileGetInfo";case e.TransactionGetRecord:return"TransactionGetRecord";case e.ContractGetRecords:return"ContractGetRecords";case e.CryptoCreate:return"CryptoCreate";case e.SystemDelete:return"SystemDelete";case e.SystemUndelete:return"SystemUndelete";case e.ContractDelete:return"ContractDelete";case e.Freeze:return"Freeze";case e.CreateTransactionRecord:return"CreateTransactionRecord";case e.CryptoAccountAutoRenew:return"CryptoAccountAutoRenew";case e.ContractAutoRenew:return"ContractAutoRenew";case e.GetVersionInfo:return"GetVersionInfo";case e.TransactionGetReceipt:return"TransactionGetReceipt";case e.ConsensusCreateTopic:return"ConsensusCreateTopic";case e.ConsensusUpdateTopic:return"ConsensusUpdateTopic";case e.ConsensusDeleteTopic:return"ConsensusDeleteTopic";case e.ConsensusGetTopicInfo:return"ConsensusGetTopicInfo";case e.ConsensusSubmitMessage:return"ConsensusSubmitMessage";case e.UncheckedSubmit:return"UncheckedSubmit";case e.TokenCreate:return"TokenCreate";case e.TokenGetInfo:return"TokenGetInfo";case e.TokenFreezeAccount:return"TokenFreezeAccount";case e.TokenUnfreezeAccount:return"TokenUnfreezeAccount";case e.TokenGrantKycToAccount:return"TokenGrantKycToAccount";case e.TokenRevokeKycFromAccount:return"TokenRevokeKycFromAccount";case e.TokenDelete:return"TokenDelete";case e.TokenUpdate:return"TokenUpdate";case e.TokenMint:return"TokenMint";case e.TokenBurn:return"TokenBurn";case e.TokenAccountWipe:return"TokenAccountWipe";case e.TokenAssociateToAccount:return"TokenAssociateToAccount";case e.TokenDissociateFromAccount:return"TokenDissociateFromAccount";case e.ScheduleCreate:return"ScheduleCreate";case e.ScheduleDelete:return"ScheduleDelete";case e.ScheduleSign:return"ScheduleSign";case e.ScheduleGetInfo:return"ScheduleGetInfo";case e.TokenGetAccountNftInfos:return"TokenGetAccountNftInfos";case e.TokenGetNftInfo:return"TokenGetNftInfo";case e.TokenGetNftInfos:return"TokenGetNftInfos";case e.TokenFeeScheduleUpdate:return"TokenFeeScheduleUpdate";case e.NetworkGetExecutionTime:return"NetworkGetExecutionTime";case e.TokenPause:return"TokenPause";case e.TokenUnpause:return"TokenUnpause";case e.CryptoApproveAllowance:return"CryptoApproveAllowance";case e.CryptoDeleteAllowance:return"CryptoDeleteAllowance";case e.GetAccountDetails:return"GetAccountDetails";case e.EthereumTransaction:return"EthereumTransaction";case e.NodeStakeUpdate:return"NodeStakeUpdate";case e.Prng:return"UtilPrng";case e.TransactionGetFastRecord:return"TransactionGetFastRecord";case e.TokenUpdateNfts:return"TokenUpdateNfts";case e.NodeCreate:return"NodeCreate";case e.NodeUpdate:return"NodeUpdate";case e.NodeDelete:return"NodeDelete";case e.TokenReject:return"TokenReject";case e.TokenAirdrop:return"TokenAirdrop";case e.TokenCancelAirdrop:return"TokenCancelAirdrop";case e.TokenClaimAirdrop:return"TokenClaimAirdrop";case e.TssMessage:return"TssMessage";case e.TssVote:return"TssVote";case e.TssShareSignature:return"TssShareSignature";case e.TssEncryptionKey:return"TssEncryptionKey";case e.StateSignatureTransaction:return"StateSignatureTransaction";case e.HistoryAssemblySignature:return"HistoryAssemblySignature";case e.HistoryProofKeyPublication:return"HistoryProofKeyPublication";case e.HistoryProofVote:return"HistoryProofVote";case e.HintsKeyPublication:return"HintsKeyPublication";case e.HintsPreprocessingVote:return"HintsPreprocessingVote";case e.HintsPartialSignature:return"HintsPartialSignature";case e.CrsPublication:return"CrsPublication";case e.AtomicBatch:return"AtomicBatch";case e.LambdaSStore:return"LambdaSStore";case e.HookDispatch:return"HookDispatch";default:return`UNKNOWN (${this._code})`}}static _fromCode(t){switch(t){case 0:return e.None;case 1:return e.CryptoTransfer;case 2:return e.CryptoUpdate;case 3:return e.CryptoDelete;case 4:return e.CryptoAddLiveHash;case 5:return e.CryptoDeleteLiveHash;case 6:return e.ContractCall;case 7:return e.ContractCreate;case 8:return e.ContractUpdate;case 9:return e.FileCreate;case 10:return e.FileAppend;case 11:return e.FileUpdate;case 12:return e.FileDelete;case 13:return e.CryptoGetAccountBalance;case 14:return e.CryptoGetAccountRecords;case 15:return e.CryptoGetInfo;case 16:return e.ContractCallLocal;case 17:return e.ContractGetInfo;case 18:return e.ContractGetBytecode;case 19:return e.GetBySolidityID;case 20:return e.GetByKey;case 21:return e.CryptoGetLiveHash;case 22:return e.CryptoGetStakers;case 23:return e.FileGetContents;case 24:return e.FileGetInfo;case 25:return e.TransactionGetRecord;case 26:return e.ContractGetRecords;case 27:return e.CryptoCreate;case 28:return e.SystemDelete;case 29:return e.SystemUndelete;case 30:return e.ContractDelete;case 31:return e.Freeze;case 32:return e.CreateTransactionRecord;case 33:return e.CryptoAccountAutoRenew;case 34:return e.ContractAutoRenew;case 35:return e.GetVersionInfo;case 36:return e.TransactionGetReceipt;case 50:return e.ConsensusCreateTopic;case 51:return e.ConsensusUpdateTopic;case 52:return e.ConsensusDeleteTopic;case 53:return e.ConsensusGetTopicInfo;case 54:return e.ConsensusSubmitMessage;case 55:return e.UncheckedSubmit;case 56:return e.TokenCreate;case 58:return e.TokenGetInfo;case 59:return e.TokenFreezeAccount;case 60:return e.TokenUnfreezeAccount;case 61:return e.TokenGrantKycToAccount;case 62:return e.TokenRevokeKycFromAccount;case 63:return e.TokenDelete;case 64:return e.TokenUpdate;case 65:return e.TokenMint;case 66:return e.TokenBurn;case 67:return e.TokenAccountWipe;case 68:return e.TokenAssociateToAccount;case 69:return e.TokenDissociateFromAccount;case 70:return e.ScheduleCreate;case 71:return e.ScheduleDelete;case 72:return e.ScheduleSign;case 73:return e.ScheduleGetInfo;case 74:return e.TokenGetAccountNftInfos;case 75:return e.TokenGetNftInfo;case 76:return e.TokenGetNftInfos;case 77:return e.TokenFeeScheduleUpdate;case 78:return e.NetworkGetExecutionTime;case 79:return e.TokenPause;case 80:return e.TokenUnpause;case 81:return e.CryptoApproveAllowance;case 82:return e.CryptoDeleteAllowance;case 83:return e.GetAccountDetails;case 84:return e.EthereumTransaction;case 85:return e.NodeStakeUpdate;case 86:return e.Prng;case 87:return e.TransactionGetFastRecord;case 88:return e.TokenUpdateNfts;case 89:return e.NodeCreate;case 90:return e.NodeUpdate;case 91:return e.NodeDelete;case 92:return e.TokenReject;case 93:return e.TokenAirdrop;case 94:return e.TokenCancelAirdrop;case 95:return e.TokenClaimAirdrop;case 96:return e.TssMessage;case 97:return e.TssVote;case 98:return e.TssShareSignature;case 99:return e.TssEncryptionKey;case 100:return e.StateSignatureTransaction;case 101:return e.HintsKeyPublication;case 102:return e.HintsPreprocessingVote;case 103:return e.HintsPartialSignature;case 104:return e.HistoryAssemblySignature;case 105:return e.HistoryProofKeyPublication;case 106:return e.HistoryProofVote;case 107:return e.CrsPublication;case 108:return e.AtomicBatch;case 109:return e.LambdaSStore;case 110:return e.HookDispatch}throw new Error(`(BUG) RequestType.fromCode() does not handle code: ${t}`)}valueOf(){return this._code}}e.None=new e(0),e.CryptoTransfer=new e(1),e.CryptoUpdate=new e(2),e.CryptoDelete=new e(3),e.CryptoAddLiveHash=new e(4),e.CryptoDeleteLiveHash=new e(5),e.ContractCall=new e(6),e.ContractCreate=new e(7),e.ContractUpdate=new e(8),e.FileCreate=new e(9),e.FileAppend=new e(10),e.FileUpdate=new e(11),e.FileDelete=new e(12),e.CryptoGetAccountBalance=new e(13),e.CryptoGetAccountRecords=new e(14),e.CryptoGetInfo=new e(15),e.ContractCallLocal=new e(16),e.ContractGetInfo=new e(17),e.ContractGetBytecode=new e(18),e.GetBySolidityID=new e(19),e.GetByKey=new e(20),e.CryptoGetLiveHash=new e(21),e.CryptoGetStakers=new e(22),e.FileGetContents=new e(23),e.FileGetInfo=new e(24),e.TransactionGetRecord=new e(25),e.ContractGetRecords=new e(26),e.CryptoCreate=new e(27),e.SystemDelete=new e(28),e.SystemUndelete=new e(29),e.ContractDelete=new e(30),e.Freeze=new e(31),e.CreateTransactionRecord=new e(32),e.CryptoAccountAutoRenew=new e(33),e.ContractAutoRenew=new e(34),e.GetVersionInfo=new e(35),e.TransactionGetReceipt=new e(36),e.ConsensusCreateTopic=new e(50),e.ConsensusUpdateTopic=new e(51),e.ConsensusDeleteTopic=new e(52),e.ConsensusGetTopicInfo=new e(53),e.ConsensusSubmitMessage=new e(54),e.UncheckedSubmit=new e(55),e.TokenCreate=new e(56),e.TokenGetInfo=new e(58),e.TokenFreezeAccount=new e(59),e.TokenUnfreezeAccount=new e(60),e.TokenGrantKycToAccount=new e(61),e.TokenRevokeKycFromAccount=new e(62),e.TokenDelete=new e(63),e.TokenUpdate=new e(64),e.TokenMint=new e(65),e.TokenBurn=new e(66),e.TokenAccountWipe=new e(67),e.TokenAssociateToAccount=new e(68),e.TokenDissociateFromAccount=new e(69),e.ScheduleCreate=new e(70),e.ScheduleDelete=new e(71),e.ScheduleSign=new e(72),e.ScheduleGetInfo=new e(73),e.TokenGetAccountNftInfos=new e(74),e.TokenGetNftInfo=new e(75),e.TokenGetNftInfos=new e(76),e.TokenFeeScheduleUpdate=new e(77),e.NetworkGetExecutionTime=new e(78),e.TokenPause=new e(79),e.TokenUnpause=new e(80),e.CryptoApproveAllowance=new e(81),e.CryptoDeleteAllowance=new e(82),e.GetAccountDetails=new e(83),e.EthereumTransaction=new e(84),e.NodeStakeUpdate=new e(85),e.Prng=new e(86),e.TransactionGetFastRecord=new e(87),e.TokenUpdateNfts=new e(88),e.NodeCreate=new e(89),e.NodeUpdate=new e(90),e.NodeDelete=new e(91),e.TokenReject=new e(92),e.TokenAirdrop=new e(93),e.TokenCancelAirdrop=new e(94),e.TokenClaimAirdrop=new e(95),e.TssMessage=new e(96),e.TssVote=new e(97),e.TssShareSignature=new e(98),e.TssEncryptionKey=new e(99),e.StateSignatureTransaction=new e(100),e.HintsKeyPublication=new e(101),e.HintsPreprocessingVote=new e(102),e.HintsPartialSignature=new e(103),e.HistoryAssemblySignature=new e(104),e.HistoryProofKeyPublication=new e(105),e.HistoryProofVote=new e(106),e.CrsPublication=new e(107),e.HistoryAssemblySignature=new e(104),e.HistoryProofKeyPublication=new e(105),e.HistoryProofVote=new e(106),e.AtomicBatch=new e(108),e.LambdaSStore=new e(109),e.HookDispatch=new e(110);export{e as default};
|
|
2
2
|
//# sourceMappingURL=RequestType.js.map
|