@hiero-ledger/sdk 2.83.0-beta.1 → 2.83.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"EthereumTransactionDataEip7702.js","sources":["../src/EthereumTransactionDataEip7702.js"],"sourcesContent":["import { decodeRlp, encodeRlp } from \"ethers\";\nimport * as hex from \"./encoding/hex.js\";\nimport EthereumTransactionData from \"./EthereumTransactionData.js\";\nimport CACHE from \"./Cache.js\";\n\n/**\n * @typedef {object} EthereumTransactionDataEip7702JSON\n * @property {string} chainId\n * @property {string} nonce\n * @property {string} maxPriorityGas\n * @property {string} maxGas\n * @property {string} gasLimit\n * @property {string} to\n * @property {string} value\n * @property {string} callData\n * @property {Array<[string, string, string, string, string, string]>} authorizationList - Array of [chainId, contractAddress, nonce, yParity, r, s] tuples\n * @property {string[]} accessList\n * @property {string} recId\n * @property {string} r\n * @property {string} s\n */\n\nexport default class EthereumTransactionDataEip7702 extends EthereumTransactionData {\n /**\n * @private\n * @param {object} props\n * @param {Uint8Array} props.chainId\n * @param {Uint8Array} props.nonce\n * @param {Uint8Array} props.maxPriorityGas\n * @param {Uint8Array} props.maxGas\n * @param {Uint8Array} props.gasLimit\n * @param {Uint8Array} props.to\n * @param {Uint8Array} props.value\n * @param {Uint8Array} props.callData\n * @param {Array<[Uint8Array, Uint8Array, Uint8Array, Uint8Array, Uint8Array, Uint8Array]>} props.authorizationList - Array of [chainId, contractAddress, nonce, yParity, r, s] tuples\n * @param {Uint8Array[]} props.accessList\n * @param {Uint8Array} props.recId\n * @param {Uint8Array} props.r\n * @param {Uint8Array} props.s\n */\n constructor(props) {\n super(props);\n\n this.chainId = props.chainId;\n this.nonce = props.nonce;\n this.maxPriorityGas = props.maxPriorityGas;\n this.maxGas = props.maxGas;\n this.gasLimit = props.gasLimit;\n this.to = props.to;\n this.value = props.value;\n this.callData = props.callData;\n this.authorizationList = props.authorizationList;\n this.accessList = props.accessList;\n this.recId = props.recId;\n this.r = props.r;\n this.s = props.s;\n }\n\n /**\n * @param {Uint8Array} bytes\n * @returns {EthereumTransactionData}\n */\n static fromBytes(bytes) {\n if (bytes.length === 0) {\n throw new Error(\"empty bytes\");\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const decoded = /** @type {string[]} */ (decodeRlp(bytes.subarray(1)));\n\n if (!Array.isArray(decoded)) {\n throw new Error(\"ethereum data is not a list\");\n }\n\n if (decoded.length !== 13) {\n throw new Error(\"invalid ethereum transaction data\");\n }\n\n // Decode authorization list: array of [chainId, contractAddress, nonce, yParity, r, s] tuples\n // Authorization list can be empty (empty array is valid)\n if (!Array.isArray(decoded[9])) {\n throw new Error(\"authorization list must be an array\");\n }\n // @ts-ignore\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n const authorizationList = /** @type {string[]} */ (decoded[9]).map(\n (authTuple) => {\n if (!Array.isArray(authTuple) || authTuple.length !== 6) {\n throw new Error(\n \"invalid authorization list entry: must be [chainId, contractAddress, nonce, yParity, r, s]\",\n );\n }\n return [\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n hex.decode(/** @type {string} */ (authTuple[0])), // chainId\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n hex.decode(/** @type {string} */ (authTuple[1])), // contractAddress (20 bytes)\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n hex.decode(/** @type {string} */ (authTuple[2])), // nonce\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n hex.decode(/** @type {string} */ (authTuple[3])), // yParity (0 or 1)\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n hex.decode(/** @type {string} */ (authTuple[4])), // r (32 bytes)\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n hex.decode(/** @type {string} */ (authTuple[5])), // s (32 bytes)\n ];\n },\n );\n\n return new EthereumTransactionDataEip7702({\n chainId: hex.decode(/** @type {string} */ (decoded[0])),\n nonce: hex.decode(/** @type {string} */ (decoded[1])),\n maxPriorityGas: hex.decode(/** @type {string} */ (decoded[2])),\n maxGas: hex.decode(/** @type {string} */ (decoded[3])),\n gasLimit: hex.decode(/** @type {string} */ (decoded[4])),\n to: hex.decode(/** @type {string} */ (decoded[5])),\n value: hex.decode(/** @type {string} */ (decoded[6])),\n callData: hex.decode(/** @type {string} */ (decoded[7])),\n // @ts-ignore\n accessList: /** @type {string[]} */ (decoded[8]).map((v) =>\n hex.decode(v),\n ),\n // @ts-ignore\n authorizationList: authorizationList,\n recId: hex.decode(/** @type {string} */ (decoded[10])),\n r: hex.decode(/** @type {string} */ (decoded[11])),\n s: hex.decode(/** @type {string} */ (decoded[12])),\n });\n }\n\n /**\n * @returns {Uint8Array}\n */\n toBytes() {\n const encoded = encodeRlp([\n this.chainId,\n this.nonce,\n this.maxPriorityGas,\n this.maxGas,\n this.gasLimit,\n this.to,\n this.value,\n this.callData,\n this.accessList,\n this.authorizationList,\n this.recId,\n this.r,\n this.s,\n ]);\n return hex.decode(\"04\" + encoded.substring(2));\n }\n\n /**\n * @returns {string}\n */\n toString() {\n return JSON.stringify(this.toJSON(), null, 2);\n }\n\n /**\n * @returns {EthereumTransactionDataEip7702JSON}\n */\n toJSON() {\n return {\n chainId: hex.encode(this.chainId),\n nonce: hex.encode(this.nonce),\n maxPriorityGas: hex.encode(this.maxPriorityGas),\n maxGas: hex.encode(this.maxGas),\n gasLimit: hex.encode(this.gasLimit),\n to: hex.encode(this.to),\n value: hex.encode(this.value),\n callData: hex.encode(this.callData),\n authorizationList: this.authorizationList.map(\n ([chainId, contractAddress, nonce, yParity, r, s]) => [\n hex.encode(chainId),\n hex.encode(contractAddress),\n hex.encode(nonce),\n hex.encode(yParity),\n hex.encode(r),\n hex.encode(s),\n ],\n ),\n accessList: this.accessList.map((v) => hex.encode(v)),\n recId: hex.encode(this.recId),\n r: hex.encode(this.r),\n s: hex.encode(this.s),\n };\n }\n}\n\nCACHE.setEthereumTransactionDataEip7702FromBytes((bytes) =>\n EthereumTransactionDataEip7702.fromBytes(bytes),\n);\n"],"names":["EthereumTransactionDataEip7702","EthereumTransactionData","constructor","props","super","this","chainId","nonce","maxPriorityGas","maxGas","gasLimit","to","value","callData","authorizationList","accessList","recId","r","s","fromBytes","bytes","length","Error","decoded","decodeRlp","subarray","Array","isArray","map","authTuple","hex.decode","v","toBytes","encoded","encodeRlp","substring","toString","JSON","stringify","toJSON","hex.encode","contractAddress","yParity","CACHE","setEthereumTransactionDataEip7702FromBytes"],"mappings":"+KAsBe,MAAMA,UAAuCC,EAkBxD,WAAAC,CAAYC,GACRC,MAAMD,GAENE,KAAKC,QAAUH,EAAMG,QACrBD,KAAKE,MAAQJ,EAAMI,MACnBF,KAAKG,eAAiBL,EAAMK,eAC5BH,KAAKI,OAASN,EAAMM,OACpBJ,KAAKK,SAAWP,EAAMO,SACtBL,KAAKM,GAAKR,EAAMQ,GAChBN,KAAKO,MAAQT,EAAMS,MACnBP,KAAKQ,SAAWV,EAAMU,SACtBR,KAAKS,kBAAoBX,EAAMW,kBAC/BT,KAAKU,WAAaZ,EAAMY,WACxBV,KAAKW,MAAQb,EAAMa,MACnBX,KAAKY,EAAId,EAAMc,EACfZ,KAAKa,EAAIf,EAAMe,CACnB,CAMA,gBAAOC,CAAUC,GACb,GAAqB,IAAjBA,EAAMC,OACN,MAAM,IAAIC,MAAM,eAIpB,MAAMC,EAAmCC,EAAUJ,EAAMK,SAAS,IAElE,IAAKC,MAAMC,QAAQJ,GACf,MAAM,IAAID,MAAM,+BAGpB,GAAuB,KAAnBC,EAAQF,OACR,MAAM,IAAIC,MAAM,qCAKpB,IAAKI,MAAMC,QAAQJ,EAAQ,IACvB,MAAM,IAAID,MAAM,uCAIpB,MAAMR,EAA6CS,EAAQ,GAAIK,IAC1DC,IACG,IAAKH,MAAMC,QAAQE,IAAmC,IAArBA,EAAUR,OACvC,MAAM,IAAIC,MACN,8FAGR,MAAO,CAEHQ,EAAkCD,EAAU,IAE5CC,E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lC,EAAOmC,EAASzB,EAAGC,KAAO,CAClDsB,EAAWlC,GACXkC,EAAWC,GACXD,EAAWjC,GACXiC,EAAWE,GACXF,EAAWvB,GACXuB,EAAWtB,KAGnBH,WAAYV,KAAKU,WAAWa,IAAKG,GAAMS,EAAWT,IAClDf,MAAOwB,EAAWnC,KAAKW,OACvBC,EAAGuB,EAAWnC,KAAKY,GACnBC,EAAGsB,EAAWnC,KAAKa,GAE3B,EAGJyB,EAAMC,2CAA4CxB,GAC9CpB,EAA+BmB,UAAUC"}
1
+ {"version":3,"file":"EthereumTransactionDataEip7702.js","sources":["../src/EthereumTransactionDataEip7702.js"],"sourcesContent":["import { decodeRlp, encodeRlp } from \"ethers\";\nimport * as hex from \"./encoding/hex.js\";\nimport EthereumTransactionData from \"./EthereumTransactionData.js\";\nimport CACHE from \"./Cache.js\";\n\n/**\n * @typedef {[Uint8Array, Uint8Array[]]} AccessListItem - [address, storageKeys[]]\n */\n\n/**\n * @typedef {[Uint8Array, Uint8Array, Uint8Array, Uint8Array, Uint8Array, Uint8Array]} AuthorizationItem - [chainId, contractAddress, nonce, yParity, r, s]\n */\n\n/**\n * @typedef {object} AccessListItemJSON\n * @property {string} address\n * @property {string[]} storageKeys\n */\n\n/**\n * @typedef {object} EthereumTransactionDataEip7702JSON\n * @property {string} chainId\n * @property {string} nonce\n * @property {string} maxPriorityGas\n * @property {string} maxGas\n * @property {string} gasLimit\n * @property {string} to\n * @property {string} value\n * @property {string} callData\n * @property {Array<[string, string, string, string, string, string]>} authorizationList - Array of [chainId, contractAddress, nonce, yParity, r, s] tuples\n * @property {AccessListItemJSON[]} accessList\n * @property {string} recId\n * @property {string} r\n * @property {string} s\n */\n\nexport default class EthereumTransactionDataEip7702 extends EthereumTransactionData {\n /**\n * @private\n * @param {object} props\n * @param {Uint8Array} props.chainId\n * @param {Uint8Array} props.nonce\n * @param {Uint8Array} props.maxPriorityGas\n * @param {Uint8Array} props.maxGas\n * @param {Uint8Array} props.gasLimit\n * @param {Uint8Array} props.to\n * @param {Uint8Array} props.value\n * @param {Uint8Array} props.callData\n * @param {AuthorizationItem[]} props.authorizationList - Array of [chainId, contractAddress, nonce, yParity, r, s] tuples\n * @param {AccessListItem[]} props.accessList\n * @param {Uint8Array} props.recId\n * @param {Uint8Array} props.r\n * @param {Uint8Array} props.s\n */\n constructor(props) {\n super(props);\n\n this.chainId = props.chainId;\n this.nonce = props.nonce;\n this.maxPriorityGas = props.maxPriorityGas;\n this.maxGas = props.maxGas;\n this.gasLimit = props.gasLimit;\n this.to = props.to;\n this.value = props.value;\n this.callData = props.callData;\n this.authorizationList = props.authorizationList;\n this.accessList = props.accessList;\n this.recId = props.recId;\n this.r = props.r;\n this.s = props.s;\n }\n\n /**\n * @param {Uint8Array} bytes\n * @returns {EthereumTransactionData}\n */\n static fromBytes(bytes) {\n if (bytes.length === 0) {\n throw new Error(\"empty bytes\");\n }\n\n const decoded = /** @type {unknown[]} */ (\n /** @type {unknown} */ (decodeRlp(bytes.subarray(1)))\n );\n\n if (!Array.isArray(decoded)) {\n throw new Error(\"ethereum data is not a list\");\n }\n\n if (decoded.length !== 13) {\n throw new Error(\"invalid ethereum transaction data\");\n }\n\n // Decode authorization list: array of [chainId, contractAddress, nonce, yParity, r, s] tuples\n // Authorization list can be empty (empty array is valid)\n if (!Array.isArray(decoded[9])) {\n throw new Error(\"authorization list must be an array\");\n }\n const authorizationList = /** @type {AuthorizationItem[]} */ (\n /** @type {Array<[string, string, string, string, string, string]>} */ (\n /** @type {unknown} */ (decoded[9])\n ).map((authTuple) => {\n if (!Array.isArray(authTuple) || authTuple.length !== 6) {\n throw new Error(\n \"invalid authorization list entry: must be [chainId, contractAddress, nonce, yParity, r, s]\",\n );\n }\n return [\n hex.decode(authTuple[0]), // chainId\n hex.decode(authTuple[1]), // contractAddress (20 bytes)\n hex.decode(authTuple[2]), // nonce\n hex.decode(authTuple[3]), // yParity (0 or 1)\n hex.decode(authTuple[4]), // r (32 bytes)\n hex.decode(authTuple[5]), // s (32 bytes)\n ];\n })\n );\n\n return new EthereumTransactionDataEip7702({\n chainId: hex.decode(/** @type {string} */ (decoded[0])),\n nonce: hex.decode(/** @type {string} */ (decoded[1])),\n maxPriorityGas: hex.decode(/** @type {string} */ (decoded[2])),\n maxGas: hex.decode(/** @type {string} */ (decoded[3])),\n gasLimit: hex.decode(/** @type {string} */ (decoded[4])),\n to: hex.decode(/** @type {string} */ (decoded[5])),\n value: hex.decode(/** @type {string} */ (decoded[6])),\n callData: hex.decode(/** @type {string} */ (decoded[7])),\n accessList: /** @type {AccessListItem[]} */ (\n /** @type {Array<[string, string[]]>} */ (\n /** @type {unknown} */ (decoded[8])\n ).map((item) => {\n if (!Array.isArray(item) || item.length !== 2) {\n throw new Error(\n \"invalid access list entry: must be [address, storageKeys[]]\",\n );\n }\n return [\n hex.decode(item[0]),\n item[1].map((key) => hex.decode(key)),\n ];\n })\n ),\n authorizationList: authorizationList,\n recId: hex.decode(/** @type {string} */ (decoded[10])),\n r: hex.decode(/** @type {string} */ (decoded[11])),\n s: hex.decode(/** @type {string} */ (decoded[12])),\n });\n }\n\n /**\n * @returns {Uint8Array}\n */\n toBytes() {\n const encoded = encodeRlp([\n this.chainId,\n this.nonce,\n this.maxPriorityGas,\n this.maxGas,\n this.gasLimit,\n this.to,\n this.value,\n this.callData,\n this.accessList,\n this.authorizationList,\n this.recId,\n this.r,\n this.s,\n ]);\n return hex.decode(\"04\" + encoded.substring(2));\n }\n\n /**\n * @returns {string}\n */\n toString() {\n return JSON.stringify(this.toJSON(), null, 2);\n }\n\n /**\n * @returns {EthereumTransactionDataEip7702JSON}\n */\n toJSON() {\n return {\n chainId: hex.encode(this.chainId),\n nonce: hex.encode(this.nonce),\n maxPriorityGas: hex.encode(this.maxPriorityGas),\n maxGas: hex.encode(this.maxGas),\n gasLimit: hex.encode(this.gasLimit),\n to: hex.encode(this.to),\n value: hex.encode(this.value),\n callData: hex.encode(this.callData),\n authorizationList: this.authorizationList.map(\n ([chainId, contractAddress, nonce, yParity, r, s]) => [\n hex.encode(chainId),\n hex.encode(contractAddress),\n hex.encode(nonce),\n hex.encode(yParity),\n hex.encode(r),\n hex.encode(s),\n ],\n ),\n accessList: this.accessList.map(([address, storageKeys]) => ({\n address: hex.encode(address),\n storageKeys: storageKeys.map((key) => hex.encode(key)),\n })),\n recId: hex.encode(this.recId),\n r: hex.encode(this.r),\n s: hex.encode(this.s),\n };\n }\n}\n\nCACHE.setEthereumTransactionDataEip7702FromBytes((bytes) =>\n EthereumTransactionDataEip7702.fromBytes(bytes),\n);\n"],"names":["EthereumTransactionDataEip7702","EthereumTransactionData","constructor","props","super","this","chainId","nonce","maxPriorityGas","maxGas","gasLimit","to","value","callData","authorizationList","accessList","recId","r","s","fromBytes","bytes","length","Error","decoded","decodeRlp","subarray","Array","isArray","map","authTuple","hex.decode","item","key","toBytes","encoded","encodeRlp","substring","toString","JSON","stringify","toJSON","hex.encode","contractAddress","yParity","address","storageKeys","CACHE","setEthereumTransactionDataEip7702FromBytes"],"mappings":"+KAoCe,MAAMA,UAAuCC,EAkBxD,WAAAC,CAAYC,GACRC,MAAMD,GAENE,KAAKC,QAAUH,EAAMG,QACrBD,KAAKE,MAAQJ,EAAMI,MACnBF,KAAKG,eAAiBL,EAAMK,eAC5BH,KAAKI,OAASN,EAAMM,OACpBJ,KAAKK,SAAWP,EAAMO,SACtBL,KAAKM,GAAKR,EAAMQ,GAChBN,KAAKO,MAAQT,EAAMS,MACnBP,KAAKQ,SAAWV,EAAMU,SACtBR,KAAKS,kBAAoBX,EAAMW,kBAC/BT,KAAKU,WAAaZ,EAAMY,WACxBV,KAAKW,MAAQb,EAAMa,MACnBX,KAAKY,EAAId,EAAMc,EACfZ,KAAKa,EAAIf,EAAMe,CACnB,CAMA,gBAAOC,CAAUC,GACb,GAAqB,IAAjBA,EAAMC,OACN,MAAM,IAAIC,MAAM,eAGpB,MAAMC,EACsBC,EAAUJ,EAAMK,SAAS,IAGrD,IAAKC,MAAMC,QAAQJ,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E,UAAU,GAC/C,CAKA,QAAAC,GACI,OAAOC,KAAKC,UAAUlC,KAAKmC,SAAU,KAAM,EAC/C,CAKA,MAAAA,GACI,MAAO,CACHlC,QAASmC,EAAWpC,KAAKC,SACzBC,MAAOkC,EAAWpC,KAAKE,OACvBC,eAAgBiC,EAAWpC,KAAKG,gBAChCC,OAAQgC,EAAWpC,KAAKI,QACxBC,SAAU+B,EAAWpC,KAAKK,UAC1BC,GAAI8B,EAAWpC,KAAKM,IACpBC,MAAO6B,EAAWpC,KAAKO,OACvBC,SAAU4B,EAAWpC,KAAKQ,UAC1BC,kBAAmBT,KAAKS,kBAAkBc,IACtC,EAAEtB,EAASoC,EAAiBnC,EAAOoC,EAAS1B,EAAGC,KAAO,CAClDuB,EAAWnC,GACXmC,EAAWC,GACXD,EAAWlC,GACXkC,EAAWE,GACXF,EAAWxB,GACXwB,EAAWvB,KAGnBH,WAAYV,KAAKU,WAAWa,IAAI,EAAEgB,EAASC,MAAY,CACnDD,QAASH,EAAWG,GACpBC,YAAaA,EAAYjB,IAAKI,GAAQS,EAAWT,OAErDhB,MAAOyB,EAAWpC,KAAKW,OACvBC,EAAGwB,EAAWpC,KAAKY,GACnBC,EAAGuB,EAAWpC,KAAKa,GAE3B,EAGJ4B,EAAMC,2CAA4C3B,GAC9CpB,EAA+BmB,UAAUC"}
@@ -57,9 +57,8 @@ class EthereumTransactionDataLegacy extends _EthereumTransactionData.default {
57
57
  if (bytes.length === 0) {
58
58
  throw new Error("empty bytes");
59
59
  }
60
-
61
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
62
- const decoded = /** @type {string[]} */(0, _ethers.decodeRlp)(bytes);
60
+ const decoded = /** @type {unknown[]} */
61
+ /** @type {unknown} */(0, _ethers.decodeRlp)(bytes);
63
62
  if (decoded.length != 9) {
64
63
  throw new Error("invalid ethereum transaction data");
65
64
  }
@@ -1 +1 @@
1
- {"version":3,"file":"EthereumTransactionDataLegacy.js","sources":["../src/EthereumTransactionDataLegacy.js"],"sourcesContent":["import { decodeRlp, encodeRlp } from \"ethers\";\nimport * as hex from \"./encoding/hex.js\";\nimport EthereumTransactionData from \"./EthereumTransactionData.js\";\nimport CACHE from \"./Cache.js\";\n\n/**\n * @typedef {object} EthereumTransactionDataLegacyJSON\n * @property {string} nonce\n * @property {string} gasPrice\n * @property {string} gasLimit\n * @property {string} to\n * @property {string} value\n * @property {string} callData\n * @property {string} v\n * @property {string} r\n * @property {string} s\n */\n\nexport default class EthereumTransactionDataLegacy extends EthereumTransactionData {\n /**\n * @private\n * @param {object} props\n * @param {Uint8Array} props.nonce\n * @param {Uint8Array} props.gasPrice\n * @param {Uint8Array} props.gasLimit\n * @param {Uint8Array} props.to\n * @param {Uint8Array} props.value\n * @param {Uint8Array} props.callData\n * @param {Uint8Array} props.v\n * @param {Uint8Array} props.r\n * @param {Uint8Array} props.s\n */\n constructor(props) {\n super(props);\n\n this.nonce = props.nonce;\n this.gasPrice = props.gasPrice;\n this.gasLimit = props.gasLimit;\n this.to = props.to;\n this.value = props.value;\n this.v = props.v;\n this.r = props.r;\n this.s = props.s;\n }\n\n /**\n * @param {Uint8Array} bytes\n * @returns {EthereumTransactionData}\n */\n static fromBytes(bytes) {\n if (bytes.length === 0) {\n throw new Error(\"empty bytes\");\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const decoded = /** @type {string[]} */ (decodeRlp(bytes));\n\n if (decoded.length != 9) {\n throw new Error(\"invalid ethereum transaction data\");\n }\n\n return new EthereumTransactionDataLegacy({\n nonce: hex.decode(/** @type {string} */ (decoded[0])),\n gasPrice: hex.decode(/** @type {string} */ (decoded[1])),\n gasLimit: hex.decode(/** @type {string} */ (decoded[2])),\n to: hex.decode(/** @type {string} */ (decoded[3])),\n value: hex.decode(/** @type {string} */ (decoded[4])),\n callData: hex.decode(/** @type {string} */ (decoded[5])),\n v: hex.decode(/** @type {string} */ (decoded[6])),\n r: hex.decode(/** @type {string} */ (decoded[7])),\n s: hex.decode(/** @type {string} */ (decoded[8])),\n });\n }\n\n /**\n * @returns {Uint8Array}\n */\n toBytes() {\n return hex.decode(\n encodeRlp([\n this.nonce,\n this.gasPrice,\n this.gasLimit,\n this.to,\n this.value,\n this.callData,\n this.v,\n this.r,\n this.s,\n ]),\n );\n }\n\n /**\n * @returns {string}\n */\n toString() {\n return JSON.stringify(this.toJSON(), null, 2);\n }\n\n /**\n * @returns {EthereumTransactionDataLegacyJSON}\n */\n toJSON() {\n return {\n nonce: hex.encode(this.nonce),\n gasPrice: hex.encode(this.gasPrice),\n gasLimit: hex.encode(this.gasLimit),\n to: hex.encode(this.to),\n value: hex.encode(this.value),\n callData: hex.encode(this.callData),\n v: hex.encode(this.v),\n r: hex.encode(this.r),\n s: hex.encode(this.s),\n };\n }\n}\n\nCACHE.setEthereumTransactionDataLegacyFromBytes((bytes) =>\n EthereumTransactionDataLegacy.fromBytes(bytes),\n);\n"],"names":["EthereumTransactionDataLegacy","EthereumTransactionData","constructor","props","super","this","nonce","gasPrice","gasLimit","to","value","v","r","s","fromBytes","bytes","length","Error","decoded","decodeRlp","hex.decode","callData","toBytes","encodeRlp","toString","JSON","stringify","toJSON","hex.encode","CACHE","setEthereumTransactionDataLegacyFromBytes"],"mappings":"+KAkBe,MAAMA,UAAsCC,EAcvD,WAAAC,CAAYC,GACRC,MAAMD,GAENE,KAAKC,MAAQH,EAAMG,MACnBD,KAAKE,SAAWJ,EAAMI,SACtBF,KAAKG,SAAWL,EAAMK,SACtBH,KAAKI,GAAKN,EAAMM,GAChBJ,KAAKK,MAAQP,EAAMO,MACnBL,KAAKM,EAAIR,EAAMQ,EACfN,KAAKO,EAAIT,EAAMS,EACfP,KAAKQ,EAAIV,EAAMU,CACnB,CAMA,gBAAOC,CAAUC,GACb,GAAqB,IAAjBA,EAAMC,OACN,MAAM,IAAIC,MAAM,eAIpB,MAAMC,EAAmCC,EAAUJ,GAEnD,GAAsB,GAAlBG,EAAQF,OACR,MAAM,IAAIC,MAAM,qCAGpB,OAAO,IAAIjB,EAA8B,CACrCM,MAAOc,EAAkCF,EAAQ,IACjDX,SAAUa,EAAkCF,EAAQ,IACpDV,SAAUY,EAAkCF,EAAQ,IACpDT,GAAIW,EAAkCF,EAAQ,IAC9CR,MAAOU,EAAkCF,EAAQ,IACjDG,SAAUD,EAAkCF,EAAQ,IACpDP,EAAGS,EAAkCF,EAAQ,IAC7CN,EAAGQ,EAAkCF,EAAQ,IAC7CL,EAAGO,EAAkCF,EAAQ,KAErD,CAKA,OAAAI,GACI,OAAOF,EACHG,EAAU,CACNlB,KAAKC,MACLD,KAAKE,SACLF,KAAKG,SACLH,KAAKI,GACLJ,KAAKK,MACLL,KAAKgB,SACLhB,KAAKM,EACLN,KAAKO,EACLP,KAAKQ,IAGjB,CAKA,QAAAW,GACI,OAAOC,KAAKC,UAAUrB,KAAKsB,SAAU,KAAM,EAC/C,CAKA,MAAAA,GACI,MAAO,CACHrB,MAAOsB,EAAWvB,KAAKC,OACvBC,SAAUqB,EAAWvB,KAAKE,UAC1BC,SAAUoB,EAAWvB,KAAKG,UAC1BC,GAAImB,EAAWvB,KAAKI,IACpBC,MAAOkB,EAAWvB,KAAKK,OACvBW,SAAUO,EAAWvB,KAAKgB,UAC1BV,EAAGiB,EAAWvB,KAAKM,GACnBC,EAAGgB,EAAWvB,KAAKO,GACnBC,EAAGe,EAAWvB,KAAKQ,GAE3B,EAGJgB,EAAMC,0CAA2Cf,GAC7Cf,EAA8Bc,UAAUC"}
1
+ {"version":3,"file":"EthereumTransactionDataLegacy.js","sources":["../src/EthereumTransactionDataLegacy.js"],"sourcesContent":["import { decodeRlp, encodeRlp } from \"ethers\";\nimport * as hex from \"./encoding/hex.js\";\nimport EthereumTransactionData from \"./EthereumTransactionData.js\";\nimport CACHE from \"./Cache.js\";\n\n/**\n * @typedef {object} EthereumTransactionDataLegacyJSON\n * @property {string} nonce\n * @property {string} gasPrice\n * @property {string} gasLimit\n * @property {string} to\n * @property {string} value\n * @property {string} callData\n * @property {string} v\n * @property {string} r\n * @property {string} s\n */\n\nexport default class EthereumTransactionDataLegacy extends EthereumTransactionData {\n /**\n * @private\n * @param {object} props\n * @param {Uint8Array} props.nonce\n * @param {Uint8Array} props.gasPrice\n * @param {Uint8Array} props.gasLimit\n * @param {Uint8Array} props.to\n * @param {Uint8Array} props.value\n * @param {Uint8Array} props.callData\n * @param {Uint8Array} props.v\n * @param {Uint8Array} props.r\n * @param {Uint8Array} props.s\n */\n constructor(props) {\n super(props);\n\n this.nonce = props.nonce;\n this.gasPrice = props.gasPrice;\n this.gasLimit = props.gasLimit;\n this.to = props.to;\n this.value = props.value;\n this.v = props.v;\n this.r = props.r;\n this.s = props.s;\n }\n\n /**\n * @param {Uint8Array} bytes\n * @returns {EthereumTransactionData}\n */\n static fromBytes(bytes) {\n if (bytes.length === 0) {\n throw new Error(\"empty bytes\");\n }\n\n const decoded = /** @type {unknown[]} */ (\n /** @type {unknown} */ (decodeRlp(bytes))\n );\n\n if (decoded.length != 9) {\n throw new Error(\"invalid ethereum transaction data\");\n }\n\n return new EthereumTransactionDataLegacy({\n nonce: hex.decode(/** @type {string} */ (decoded[0])),\n gasPrice: hex.decode(/** @type {string} */ (decoded[1])),\n gasLimit: hex.decode(/** @type {string} */ (decoded[2])),\n to: hex.decode(/** @type {string} */ (decoded[3])),\n value: hex.decode(/** @type {string} */ (decoded[4])),\n callData: hex.decode(/** @type {string} */ (decoded[5])),\n v: hex.decode(/** @type {string} */ (decoded[6])),\n r: hex.decode(/** @type {string} */ (decoded[7])),\n s: hex.decode(/** @type {string} */ (decoded[8])),\n });\n }\n\n /**\n * @returns {Uint8Array}\n */\n toBytes() {\n return hex.decode(\n encodeRlp([\n this.nonce,\n this.gasPrice,\n this.gasLimit,\n this.to,\n this.value,\n this.callData,\n this.v,\n this.r,\n this.s,\n ]),\n );\n }\n\n /**\n * @returns {string}\n */\n toString() {\n return JSON.stringify(this.toJSON(), null, 2);\n }\n\n /**\n * @returns {EthereumTransactionDataLegacyJSON}\n */\n toJSON() {\n return {\n nonce: hex.encode(this.nonce),\n gasPrice: hex.encode(this.gasPrice),\n gasLimit: hex.encode(this.gasLimit),\n to: hex.encode(this.to),\n value: hex.encode(this.value),\n callData: hex.encode(this.callData),\n v: hex.encode(this.v),\n r: hex.encode(this.r),\n s: hex.encode(this.s),\n };\n }\n}\n\nCACHE.setEthereumTransactionDataLegacyFromBytes((bytes) =>\n EthereumTransactionDataLegacy.fromBytes(bytes),\n);\n"],"names":["EthereumTransactionDataLegacy","EthereumTransactionData","constructor","props","super","this","nonce","gasPrice","gasLimit","to","value","v","r","s","fromBytes","bytes","length","Error","decoded","decodeRlp","hex.decode","callData","toBytes","encodeRlp","toString","JSON","stringify","toJSON","hex.encode","CACHE","setEthereumTransactionDataLegacyFromBytes"],"mappings":"+KAkBe,MAAMA,UAAsCC,EAcvD,WAAAC,CAAYC,GACRC,MAAMD,GAENE,KAAKC,MAAQH,EAAMG,MACnBD,KAAKE,SAAWJ,EAAMI,SACtBF,KAAKG,SAAWL,EAAMK,SACtBH,KAAKI,GAAKN,EAAMM,GAChBJ,KAAKK,MAAQP,EAAMO,MACnBL,KAAKM,EAAIR,EAAMQ,EACfN,KAAKO,EAAIT,EAAMS,EACfP,KAAKQ,EAAIV,EAAMU,CACnB,CAMA,gBAAOC,CAAUC,GACb,GAAqB,IAAjBA,EAAMC,OACN,MAAM,IAAIC,MAAM,eAGpB,MAAMC,EACsBC,EAAUJ,GAGtC,GAAsB,GAAlBG,EAAQF,OACR,MAAM,IAAIC,MAAM,qCAGpB,OAAO,IAAIjB,EAA8B,CACrCM,MAAOc,EAAkCF,EAAQ,IACjDX,SAAUa,EAAkCF,EAAQ,IACpDV,SAAUY,EAAkCF,EAAQ,IACpDT,GAAIW,EAAkCF,EAAQ,IAC9CR,MAAOU,EAAkCF,EAAQ,IACjDG,SAAUD,EAAkCF,EAAQ,IACpDP,EAAGS,EAAkCF,EAAQ,IAC7CN,EAAGQ,EAAkCF,EAAQ,IAC7CL,EAAGO,EAAkCF,EAAQ,KAErD,CAKA,OAAAI,GACI,OAAOF,EACHG,EAAU,CACNlB,KAAKC,MACLD,KAAKE,SACLF,KAAKG,SACLH,KAAKI,GACLJ,KAAKK,MACLL,KAAKgB,SACLhB,KAAKM,EACLN,KAAKO,EACLP,KAAKQ,IAGjB,CAKA,QAAAW,GACI,OAAOC,KAAKC,UAAUrB,KAAKsB,SAAU,KAAM,EAC/C,CAKA,MAAAA,GACI,MAAO,CACHrB,MAAOsB,EAAWvB,KAAKC,OACvBC,SAAUqB,EAAWvB,KAAKE,UAC1BC,SAAUoB,EAAWvB,KAAKG,UAC1BC,GAAImB,EAAWvB,KAAKI,IACpBC,MAAOkB,EAAWvB,KAAKK,OACvBW,SAAUO,EAAWvB,KAAKgB,UAC1BV,EAAGiB,EAAWvB,KAAKM,GACnBC,EAAGgB,EAAWvB,KAAKO,GACnBC,EAAGe,EAAWvB,KAAKQ,GAE3B,EAGJgB,EAAMC,0CAA2Cf,GAC7Cf,EAA8Bc,UAAUC"}
@@ -72,6 +72,13 @@ class FileAppendTransaction extends _Transaction.default {
72
72
  this._maxChunks = 20;
73
73
 
74
74
  /**
75
+ * The default chunk size in bytes for file append operations.
76
+ *
77
+ * The network limits total transaction size (SignedTransaction) to 6144 bytes.
78
+ * Each Ed25519 signature adds ~102 bytes of overhead (pubKeyPrefix + signature + wrapping).
79
+ * With 4096-byte chunks, transactions fit within the limit for up to ~19 signatures.
80
+ * For files requiring more signers, callers should use setChunkSize() with a smaller value.
81
+ *
75
82
  * @private
76
83
  * @type {number}
77
84
  */
@@ -63,6 +63,13 @@ export default class FileAppendTransaction extends Transaction {
63
63
  */
64
64
  private _maxChunks;
65
65
  /**
66
+ * The default chunk size in bytes for file append operations.
67
+ *
68
+ * The network limits total transaction size (SignedTransaction) to 6144 bytes.
69
+ * Each Ed25519 signature adds ~102 bytes of overhead (pubKeyPrefix + signature + wrapping).
70
+ * With 4096-byte chunks, transactions fit within the limit for up to ~19 signatures.
71
+ * For files requiring more signers, callers should use setChunkSize() with a smaller value.
72
+ *
66
73
  * @private
67
74
  * @type {number}
68
75
  */
@@ -1 +1 @@
1
- {"version":3,"file":"FileAppendTransaction.js","sources":["../../src/file/FileAppendTransaction.js"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\nimport Hbar from \"../Hbar.js\";\nimport Transaction, {\n TRANSACTION_REGISTRY,\n} from \"../transaction/Transaction.js\";\nimport * as utf8 from \"../encoding/utf8.js\";\nimport FileId from \"./FileId.js\";\nimport TransactionId from \"../transaction/TransactionId.js\";\nimport Timestamp from \"../Timestamp.js\";\nimport List from \"../transaction/List.js\";\nimport AccountId from \"../account/AccountId.js\";\n\n/**\n * @namespace proto\n * @typedef {import(\"@hiero-ledger/proto\").proto.ITransaction} HieroProto.proto.ITransaction\n * @typedef {import(\"@hiero-ledger/proto\").proto.ISignedTransaction} HieroProto.proto.ISignedTransaction\n * @typedef {import(\"@hiero-ledger/proto\").proto.TransactionBody} HieroProto.proto.TransactionBody\n * @typedef {import(\"@hiero-ledger/proto\").proto.ITransactionBody} HieroProto.proto.ITransactionBody\n * @typedef {import(\"@hiero-ledger/proto\").proto.ITransactionResponse} HieroProto.proto.ITransactionResponse\n * @typedef {import(\"@hiero-ledger/proto\").proto.IFileAppendTransactionBody} HieroProto.proto.IFileAppendTransactionBody\n * @typedef {import(\"@hiero-ledger/proto\").proto.IFileID} HieroProto.proto.IFileID\n */\n\n/**\n * @typedef {import(\"../PublicKey.js\").default} PublicKey\n * @typedef {import(\"../channel/Channel.js\").default} Channel\n * @typedef {import(\"../channel/MirrorChannel.js\").default} MirrorChannel\n * @typedef {import(\"../client/Client.js\").default<Channel, MirrorChannel>} Client\n * @typedef {import(\"../transaction/TransactionResponse.js\").default} TransactionResponse\n * @typedef {import(\"../schedule/ScheduleCreateTransaction.js\").default} ScheduleCreateTransaction\n */\n\n/**\n * A transaction specifically to append data to a file on the network.\n *\n * If a file has multiple keys, all keys must sign to modify its contents.\n */\nexport default class FileAppendTransaction extends Transaction {\n /**\n * @param {object} [props]\n * @param {FileId | string} [props.fileId]\n * @param {Uint8Array | string} [props.contents]\n * @param {number} [props.maxChunks]\n * @param {number} [props.chunkSize]\n * @param {number} [props.chunkInterval]\n */\n constructor(props = {}) {\n super();\n\n /**\n * @private\n * @type {?FileId}\n */\n this._fileId = null;\n\n /**\n * @private\n * @type {?Uint8Array}\n */\n this._contents = null;\n\n /**\n * @private\n * @type {number}\n */\n this._maxChunks = 20;\n\n /**\n * @private\n * @type {number}\n */\n this._chunkSize = 4096;\n\n /**\n * @private\n * @type {number}\n */\n this._chunkInterval = 10;\n\n this._defaultMaxTransactionFee = new Hbar(5);\n\n if (props.fileId != null) {\n this.setFileId(props.fileId);\n }\n\n if (props.contents != null) {\n this.setContents(props.contents);\n }\n\n if (props.maxChunks != null) {\n this.setMaxChunks(props.maxChunks);\n }\n\n if (props.chunkSize != null) {\n this.setChunkSize(props.chunkSize);\n }\n\n if (props.chunkInterval != null) {\n this.setChunkInterval(props.chunkInterval);\n }\n\n /** @type {List<TransactionId>} */\n this._transactionIds = new List();\n }\n\n /**\n * @internal\n * @param {HieroProto.proto.ITransaction[]} transactions\n * @param {HieroProto.proto.ISignedTransaction[]} signedTransactions\n * @param {TransactionId[]} transactionIds\n * @param {AccountId[]} nodeIds\n * @param {HieroProto.proto.ITransactionBody[]} bodies\n * @returns {FileAppendTransaction}\n */\n static _fromProtobuf(\n transactions,\n signedTransactions,\n transactionIds,\n nodeIds,\n bodies,\n ) {\n const body = bodies[0];\n const append =\n /** @type {HieroProto.proto.IFileAppendTransactionBody} */ (\n body.fileAppend\n );\n\n let contents;\n\n // The increment value depends on whether the node IDs list is empty or not.\n // The node IDs list is not empty if the transaction has been frozen\n // before serialization and deserialization, otherwise, it's empty.\n const incrementValue = nodeIds.length > 0 ? nodeIds.length : 1;\n\n for (let i = 0; i < bodies.length; i += incrementValue) {\n const fileAppend =\n /** @type {HieroProto.proto.IFileAppendTransactionBody} */ (\n bodies[i].fileAppend\n );\n if (fileAppend.contents == null) {\n break;\n }\n\n if (contents == null) {\n contents = new Uint8Array(\n /** @type {Uint8Array} */ (fileAppend.contents),\n );\n continue;\n }\n\n /** @type {Uint8Array} */\n const concat = new Uint8Array(\n contents.length +\n /** @type {Uint8Array} */ (fileAppend.contents).length,\n );\n concat.set(contents, 0);\n concat.set(\n /** @type {Uint8Array} */ (fileAppend.contents),\n contents.length,\n );\n contents = concat;\n }\n const chunkSize = append.contents?.length || undefined;\n const maxChunks = bodies.length\n ? bodies.length / incrementValue\n : undefined;\n let chunkInterval;\n if (transactionIds.length > 1) {\n const firstValidStart = transactionIds[0].validStart;\n const secondValidStart = transactionIds[1].validStart;\n if (firstValidStart && secondValidStart) {\n chunkInterval = secondValidStart.nanos\n .sub(firstValidStart.nanos)\n .toNumber();\n }\n }\n\n return Transaction._fromProtobufTransactions(\n new FileAppendTransaction({\n fileId:\n append.fileID != null\n ? FileId._fromProtobuf(\n /** @type {HieroProto.proto.IFileID} */ (\n append.fileID\n ),\n )\n : undefined,\n contents,\n chunkSize,\n maxChunks,\n chunkInterval,\n }),\n transactions,\n signedTransactions,\n transactionIds,\n nodeIds,\n bodies,\n );\n }\n\n /**\n * @returns {?FileId}\n */\n get fileId() {\n return this._fileId;\n }\n\n /**\n * Set the keys which must sign any transactions modifying this file. Required.\n *\n * All keys must sign to modify the file's contents or keys. No key is required\n * to sign for extending the expiration time (except the one for the operator account\n * paying for the transaction). Only one key must sign to delete the file, however.\n *\n * To require more than one key to sign to delete a file, add them to a\n * KeyList and pass that here.\n *\n * The network currently requires a file to have at least one key (or key list or threshold key)\n * but this requirement may be lifted in the future.\n *\n * @param {FileId | string} fileId\n * @returns {this}\n */\n setFileId(fileId) {\n this._requireNotFrozen();\n this._fileId =\n typeof fileId === \"string\"\n ? FileId.fromString(fileId)\n : fileId.clone();\n\n return this;\n }\n\n /**\n * @override\n * @returns {number}\n */\n getRequiredChunks() {\n if (this._contents == null) {\n return 1;\n }\n\n const result = Math.ceil(this._contents.length / this._chunkSize);\n\n return result;\n }\n\n /**\n * @returns {?Uint8Array}\n */\n get contents() {\n return this._contents;\n }\n\n /**\n * Set the given byte array as the file's contents.\n *\n * This may be omitted to append an empty file.\n *\n * Note that total size for a given transaction is limited to 6KiB (as of March 2020) by the\n * network; if you exceed this you may receive a HederaPreCheckStatusException\n * with Status#TransactionOversize.\n *\n * In this case, you will need to break the data into chunks of less than ~6KiB and execute this\n * transaction with the first chunk and then use FileAppendTransaction with\n * FileAppendTransaction#setContents(Uint8Array) for the remaining chunks.\n *\n * @param {Uint8Array | string} contents\n * @returns {this}\n */\n setContents(contents) {\n this._requireNotFrozen();\n this._contents =\n contents instanceof Uint8Array ? contents : utf8.encode(contents);\n\n return this;\n }\n\n /**\n * @returns {?number}\n */\n get maxChunks() {\n return this._maxChunks;\n }\n\n /**\n * @param {number} maxChunks\n * @returns {this}\n */\n setMaxChunks(maxChunks) {\n if (maxChunks <= 0) {\n throw new Error(\"Max chunks must be greater than 0\");\n }\n this._requireNotFrozen();\n this._maxChunks = maxChunks;\n return this;\n }\n\n /**\n * @returns {?number}\n */\n get chunkSize() {\n return this._chunkSize;\n }\n\n /**\n * @param {number} chunkSize\n * @returns {this}\n */\n setChunkSize(chunkSize) {\n if (chunkSize <= 0) {\n throw new Error(\"Chunk size must be greater than 0\");\n }\n this._chunkSize = chunkSize;\n return this;\n }\n\n /**\n * @returns {number}\n */\n get chunkInterval() {\n return this._chunkInterval;\n }\n\n /**\n * @param {number} chunkInterval The valid start interval between chunks in nanoseconds\n * @returns {this}\n */\n setChunkInterval(chunkInterval) {\n this._chunkInterval = chunkInterval;\n return this;\n }\n\n /**\n * Freeze this transaction from further modification to prepare for\n * signing or serialization.\n *\n * Will use the `Client`, if available, to generate a default Transaction ID and select 1/3\n * nodes to prepare this transaction for.\n *\n * @param {?Client} client\n * @returns {this}\n */\n freezeWith(client) {\n super.freezeWith(client);\n\n if (this._contents == null) {\n return this;\n }\n\n let nextTransactionId = this._getTransactionId();\n\n // Hack around the locked list. Should refactor a bit to remove such code\n this._transactionIds.locked = false;\n\n this._transactions.clear();\n this._transactionIds.clear();\n this._signedTransactions.clear();\n\n for (let chunk = 0; chunk < this.getRequiredChunks(); chunk++) {\n this._transactionIds.push(nextTransactionId);\n this._transactionIds.advance();\n\n for (const nodeAccountId of this._nodeAccountIds.list) {\n this._signedTransactions.push(\n this._makeSignedTransaction(nodeAccountId),\n );\n }\n\n nextTransactionId = new TransactionId(\n /** @type {AccountId} */ (nextTransactionId.accountId),\n new Timestamp(\n /** @type {Timestamp} */ (\n nextTransactionId.validStart\n ).seconds,\n /** @type {Timestamp} */ (\n nextTransactionId.validStart\n ).nanos.add(this._chunkInterval),\n ),\n );\n }\n\n this._transactionIds.advance();\n this._transactionIds.setLocked();\n\n return this;\n }\n\n /**\n * @returns {ScheduleCreateTransaction}\n */\n schedule() {\n this._requireNotFrozen();\n\n if (this._contents != null && this._contents.length > this._chunkSize) {\n throw new Error(\n `cannot schedule \\`FileAppendTransaction\\` with message over ${this._chunkSize} bytes`,\n );\n }\n\n return super.schedule();\n }\n\n /**\n * @param {Client} client\n * @param {number=} requestTimeout\n * @returns {Promise<TransactionResponse>}\n */\n async execute(client, requestTimeout) {\n return (await this.executeAll(client, requestTimeout))[0];\n }\n\n /**\n * @param {Client} client\n * @param {number=} requestTimeout\n * @returns {Promise<TransactionResponse[]>}\n */\n async executeAll(client, requestTimeout) {\n if (this.maxChunks && this.getRequiredChunks() > this.maxChunks) {\n throw new Error(\n `cannot execute \\`FileAppendTransaction\\` with more than ${this.maxChunks} chunks`,\n );\n }\n\n if (!super._isFrozen()) {\n this.freezeWith(client);\n }\n\n // on execute, sign each transaction with the operator, if present\n // and we are signing a transaction that used the default transaction ID\n\n const transactionId = this._getTransactionId();\n const operatorAccountId = client.operatorAccountId;\n\n if (\n operatorAccountId != null &&\n operatorAccountId.equals(\n /** @type {AccountId} */ (transactionId.accountId),\n )\n ) {\n await super.signWithOperator(client);\n }\n\n const responses = [];\n let remainingTimeout = requestTimeout;\n\n for (let i = 0; i < this._transactionIds.length; i++) {\n const startTimestamp = Date.now();\n const response = await super.execute(client, remainingTimeout);\n\n if (remainingTimeout != null) {\n remainingTimeout = Date.now() - startTimestamp;\n }\n\n await response.getReceipt(client);\n responses.push(response);\n }\n\n return responses;\n }\n\n /**\n * @param {Client} client\n */\n _validateChecksums(client) {\n if (this._fileId != null) {\n this._fileId.validateChecksum(client);\n }\n }\n\n /**\n * @override\n * @internal\n * @param {Channel} channel\n * @param {HieroProto.proto.ITransaction} request\n * @returns {Promise<HieroProto.proto.ITransactionResponse>}\n */\n _execute(channel, request) {\n return channel.file.appendContent(request);\n }\n\n /**\n * @override\n * @protected\n * @returns {NonNullable<HieroProto.proto.TransactionBody[\"data\"]>}\n */\n _getTransactionDataCase() {\n return \"fileAppend\";\n }\n\n /**\n * Build all the transactions\n * when transactions are not complete.\n * @override\n * @internal\n */\n _buildIncompleteTransactions() {\n const dummyAccountId = AccountId.fromString(\"0.0.0\");\n const accountId = this.transactionId?.accountId || dummyAccountId;\n const validStart =\n this.transactionId?.validStart || Timestamp.fromDate(new Date());\n\n if (this.maxChunks && this.getRequiredChunks() > this.maxChunks) {\n throw new Error(\n `cannot build \\`FileAppendTransaction\\` with more than ${this.maxChunks} chunks`,\n );\n }\n\n // Hack around the locked list. Should refactor a bit to remove such code\n this._transactionIds.locked = false;\n\n this._transactions.clear();\n this._transactionIds.clear();\n this._signedTransactions.clear();\n\n for (let chunk = 0; chunk < this.getRequiredChunks(); chunk++) {\n let nextTransactionId = TransactionId.withValidStart(\n accountId,\n validStart.plusNanos(this._chunkInterval * chunk),\n );\n this._transactionIds.push(nextTransactionId);\n this._transactionIds.advance();\n\n if (this._nodeAccountIds.list.length === 0) {\n this._transactions.push(this._makeSignedTransaction(null));\n } else {\n for (const nodeAccountId of this._nodeAccountIds.list) {\n this._transactions.push(\n this._makeSignedTransaction(nodeAccountId),\n );\n }\n }\n }\n\n this._transactionIds.advance();\n this._transactionIds.setLocked();\n }\n\n /**\n * Build all the signed transactions\n * @override\n * @internal\n */\n _buildAllTransactions() {\n if (this.maxChunks && this.getRequiredChunks() > this.maxChunks) {\n throw new Error(\n `cannot build \\`FileAppendTransaction\\` with more than ${this.maxChunks} chunks`,\n );\n }\n for (let i = 0; i < this._signedTransactions.length; i++) {\n this._buildTransaction(i);\n }\n }\n\n /**\n * @returns {string}\n */\n _getLogId() {\n const timestamp = /** @type {import(\"../Timestamp.js\").default} */ (\n this._transactionIds.current.validStart\n );\n return `FileAppendTransaction:${timestamp.toString()}`;\n }\n\n /**\n * @override\n * @protected\n * @returns {HieroProto.proto.IFileAppendTransactionBody}\n */\n _makeTransactionData() {\n const length = this._contents != null ? this._contents.length : 0;\n const startIndex = this._transactionIds.index * this._chunkSize;\n const endIndex = Math.min(startIndex + this._chunkSize, length);\n\n return {\n fileID: this._fileId != null ? this._fileId._toProtobuf() : null,\n contents:\n this._contents != null\n ? this._contents.slice(startIndex, endIndex)\n : null,\n };\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/unbound-method\nTRANSACTION_REGISTRY.set(\"fileAppend\", FileAppendTransaction._fromProtobuf);\n"],"names":["FileAppendTransaction","Transaction","constructor","props","super","this","_fileId","_contents","_maxChunks","_chunkSize","_chunkInterval","_defaultMaxTransactionFee","Hbar","fileId","setFileId","contents","setContents","maxChunks","setMaxChunks","chunkSize","setChunkSize","chunkInterval","setChunkInterval","_transactionIds","List","_fromProtobuf","transactions","signedTransactions","transactionIds","nodeIds","bodies","append","incrementValue","length","i","fileAppend","Uint8Array","concat","set","undefined","firstValidStart","validStart","secondValidStart","nanos","sub","toNumber","_fromProtobufTransactions","fileID","FileId","_requireNotFrozen","fromString","clone","getRequiredChunks","Math","ceil","utf8.encode","Error","freezeWith","client","nextTransactionId","_getTransactionId","locked","_transactions","clear","_signedTransactions","chunk","push","advance","nodeAccountId","_nodeAccountIds","list","_makeSignedTransaction","TransactionId","Timestamp","seconds","add","setLocked","schedule","execute","requestTimeout","executeAll","_isFrozen","transactionId","operatorAccountId","equals","signWithOperator","responses","remainingTimeout","startTimestamp","Date","now","response","getReceipt","_validateChecksums","validateChecksum","_execute","channel","request","file","appendContent","_getTransactionDataCase","_buildIncompleteTransactions","dummyAccountId","AccountId","accountId","fromDate","withValidStart","plusNanos","_buildAllTransactions","_buildTransaction","_getLogId","current","toString","_makeTransactionData","startIndex","index","endIndex","min","_toProtobuf","slice","TRANSACTION_REGISTRY"],"mappings":"qUAsCe,MAAMA,UAA8BC,EAS/C,WAAAC,CAAYC,EAAQ,IAChBC,QAMAC,KAAKC,QAAU,KAMfD,KAAKE,UAAY,KAMjBF,KAAKG,WAAa,GAMlBH,KAAKI,WAAa,KAMlBJ,KAAKK,eAAiB,GAEtBL,KAAKM,0BAA4B,IAAIC,EAAK,GAEtB,MAAhBT,EAAMU,QACNR,KAAKS,UAAUX,EAAMU,QAGH,MAAlBV,EAAMY,UACNV,KAAKW,YAAYb,EAAMY,UAGJ,MAAnBZ,EAAMc,WACNZ,KAAKa,aAAaf,EAAMc,WAGL,MAAnBd,EAAMgB,WACNd,KAAKe,aAAajB,EAAMgB,WAGD,MAAvBhB,EAAMkB,eACNhB,KAAKiB,iBAAiBnB,EAAMkB,eAIhChB,KAAKkB,gBAAkB,IAAIC,CAC/B,CAWA,oBAAOC,CACHC,EACAC,EACAC,EACAC,EACAC,GAEA,MACMC,EADOD,EAAO,GAI5B,WAEQ,IAAIf,EAKJ,MAAMiB,EAAiBH,EAAQI,OAAS,EAAIJ,EAAQI,OAAS,EAE7D,IAAK,IAAIC,EAAI,EAAGA,EAAIJ,EAAOG,OAAQC,GAAKF,EAAgB,CACpD,MAAMG,EAEEL,EAAOI,GAC3B,WACY,GAA2B,MAAvBC,EAAWpB,SACX,MAGJ,GAAgB,MAAZA,EAAkB,CAClBA,EAAW,IAAIqB,WACgBD,EAAmB,UAElD,QACJ,CAGA,MAAME,EAAS,IAAID,WACfrB,EAASkB,OACsBE,EAAmB,SAAEF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KAAKkB,gBAAgB4C,UAEoB,IAArC9D,KAAKgE,gBAAgBC,KAAKrC,OAC1B5B,KAAKyD,cAAcI,KAAK7D,KAAKkE,uBAAuB,YAEpD,IAAK,MAAMH,KAAiB/D,KAAKgE,gBAAgBC,KAC7CjE,KAAKyD,cAAcI,KACf7D,KAAKkE,uBAAuBH,GAI5C,CAEA/D,KAAKkB,gBAAgB4C,UACrB9D,KAAKkB,gBAAgBqD,WACzB,CAOA,qBAAAgC,GACI,GAAIvG,KAAKY,WAAaZ,KAAK+C,oBAAsB/C,KAAKY,UAClD,MAAM,IAAIuC,MACN,yDAAyDnD,KAAKY,oBAGtE,IAAK,IAAIiB,EAAI,EAAGA,EAAI7B,KAAK2D,oBAAoB/B,OAAQC,IACjD7B,KAAKwG,kBAAkB3E,EAE/B,CAKA,SAAA4E,GAII,MAAO,yBAFHzG,KAAKkB,gBAAgBwF,QACjC,WACkDC,YAC9C,CAOA,oBAAAC,GACI,MAAMhF,EAA2B,MAAlB5B,KAAKE,UAAoBF,KAAKE,UAAU0B,OAAS,EAC1DiF,EAAa7G,KAAKkB,gBAAgB4F,MAAQ9G,KAAKI,WAC/C2G,EAAW/D,KAAKgE,IAAIH,EAAa7G,KAAKI,WAAYwB,GAExD,MAAO,CACHc,OAAwB,MAAhB1C,KAAKC,QAAkBD,KAAKC,QAAQgH,cAAgB,KAC5DvG,SACsB,MAAlBV,KAAKE,UACCF,KAAKE,UAAUgH,MAAML,EAAYE,GACjC,KAElB,EAIJI,EAAqBlF,IAAI,aAActC,EAAsByB"}
1
+ {"version":3,"file":"FileAppendTransaction.js","sources":["../../src/file/FileAppendTransaction.js"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\nimport Hbar from \"../Hbar.js\";\nimport Transaction, {\n TRANSACTION_REGISTRY,\n} from \"../transaction/Transaction.js\";\nimport * as utf8 from \"../encoding/utf8.js\";\nimport FileId from \"./FileId.js\";\nimport TransactionId from \"../transaction/TransactionId.js\";\nimport Timestamp from \"../Timestamp.js\";\nimport List from \"../transaction/List.js\";\nimport AccountId from \"../account/AccountId.js\";\n\n/**\n * @namespace proto\n * @typedef {import(\"@hiero-ledger/proto\").proto.ITransaction} HieroProto.proto.ITransaction\n * @typedef {import(\"@hiero-ledger/proto\").proto.ISignedTransaction} HieroProto.proto.ISignedTransaction\n * @typedef {import(\"@hiero-ledger/proto\").proto.TransactionBody} HieroProto.proto.TransactionBody\n * @typedef {import(\"@hiero-ledger/proto\").proto.ITransactionBody} HieroProto.proto.ITransactionBody\n * @typedef {import(\"@hiero-ledger/proto\").proto.ITransactionResponse} HieroProto.proto.ITransactionResponse\n * @typedef {import(\"@hiero-ledger/proto\").proto.IFileAppendTransactionBody} HieroProto.proto.IFileAppendTransactionBody\n * @typedef {import(\"@hiero-ledger/proto\").proto.IFileID} HieroProto.proto.IFileID\n */\n\n/**\n * @typedef {import(\"../PublicKey.js\").default} PublicKey\n * @typedef {import(\"../channel/Channel.js\").default} Channel\n * @typedef {import(\"../channel/MirrorChannel.js\").default} MirrorChannel\n * @typedef {import(\"../client/Client.js\").default<Channel, MirrorChannel>} Client\n * @typedef {import(\"../transaction/TransactionResponse.js\").default} TransactionResponse\n * @typedef {import(\"../schedule/ScheduleCreateTransaction.js\").default} ScheduleCreateTransaction\n */\n\n/**\n * A transaction specifically to append data to a file on the network.\n *\n * If a file has multiple keys, all keys must sign to modify its contents.\n */\nexport default class FileAppendTransaction extends Transaction {\n /**\n * @param {object} [props]\n * @param {FileId | string} [props.fileId]\n * @param {Uint8Array | string} [props.contents]\n * @param {number} [props.maxChunks]\n * @param {number} [props.chunkSize]\n * @param {number} [props.chunkInterval]\n */\n constructor(props = {}) {\n super();\n\n /**\n * @private\n * @type {?FileId}\n */\n this._fileId = null;\n\n /**\n * @private\n * @type {?Uint8Array}\n */\n this._contents = null;\n\n /**\n * @private\n * @type {number}\n */\n this._maxChunks = 20;\n\n /**\n * The default chunk size in bytes for file append operations.\n *\n * The network limits total transaction size (SignedTransaction) to 6144 bytes.\n * Each Ed25519 signature adds ~102 bytes of overhead (pubKeyPrefix + signature + wrapping).\n * With 4096-byte chunks, transactions fit within the limit for up to ~19 signatures.\n * For files requiring more signers, callers should use setChunkSize() with a smaller value.\n *\n * @private\n * @type {number}\n */\n this._chunkSize = 4096;\n\n /**\n * @private\n * @type {number}\n */\n this._chunkInterval = 10;\n\n this._defaultMaxTransactionFee = new Hbar(5);\n\n if (props.fileId != null) {\n this.setFileId(props.fileId);\n }\n\n if (props.contents != null) {\n this.setContents(props.contents);\n }\n\n if (props.maxChunks != null) {\n this.setMaxChunks(props.maxChunks);\n }\n\n if (props.chunkSize != null) {\n this.setChunkSize(props.chunkSize);\n }\n\n if (props.chunkInterval != null) {\n this.setChunkInterval(props.chunkInterval);\n }\n\n /** @type {List<TransactionId>} */\n this._transactionIds = new List();\n }\n\n /**\n * @internal\n * @param {HieroProto.proto.ITransaction[]} transactions\n * @param {HieroProto.proto.ISignedTransaction[]} signedTransactions\n * @param {TransactionId[]} transactionIds\n * @param {AccountId[]} nodeIds\n * @param {HieroProto.proto.ITransactionBody[]} bodies\n * @returns {FileAppendTransaction}\n */\n static _fromProtobuf(\n transactions,\n signedTransactions,\n transactionIds,\n nodeIds,\n bodies,\n ) {\n const body = bodies[0];\n const append =\n /** @type {HieroProto.proto.IFileAppendTransactionBody} */ (\n body.fileAppend\n );\n\n let contents;\n\n // The increment value depends on whether the node IDs list is empty or not.\n // The node IDs list is not empty if the transaction has been frozen\n // before serialization and deserialization, otherwise, it's empty.\n const incrementValue = nodeIds.length > 0 ? nodeIds.length : 1;\n\n for (let i = 0; i < bodies.length; i += incrementValue) {\n const fileAppend =\n /** @type {HieroProto.proto.IFileAppendTransactionBody} */ (\n bodies[i].fileAppend\n );\n if (fileAppend.contents == null) {\n break;\n }\n\n if (contents == null) {\n contents = new Uint8Array(\n /** @type {Uint8Array} */ (fileAppend.contents),\n );\n continue;\n }\n\n /** @type {Uint8Array} */\n const concat = new Uint8Array(\n contents.length +\n /** @type {Uint8Array} */ (fileAppend.contents).length,\n );\n concat.set(contents, 0);\n concat.set(\n /** @type {Uint8Array} */ (fileAppend.contents),\n contents.length,\n );\n contents = concat;\n }\n const chunkSize = append.contents?.length || undefined;\n const maxChunks = bodies.length\n ? bodies.length / incrementValue\n : undefined;\n let chunkInterval;\n if (transactionIds.length > 1) {\n const firstValidStart = transactionIds[0].validStart;\n const secondValidStart = transactionIds[1].validStart;\n if (firstValidStart && secondValidStart) {\n chunkInterval = secondValidStart.nanos\n .sub(firstValidStart.nanos)\n .toNumber();\n }\n }\n\n return Transaction._fromProtobufTransactions(\n new FileAppendTransaction({\n fileId:\n append.fileID != null\n ? FileId._fromProtobuf(\n /** @type {HieroProto.proto.IFileID} */ (\n append.fileID\n ),\n )\n : undefined,\n contents,\n chunkSize,\n maxChunks,\n chunkInterval,\n }),\n transactions,\n signedTransactions,\n transactionIds,\n nodeIds,\n bodies,\n );\n }\n\n /**\n * @returns {?FileId}\n */\n get fileId() {\n return this._fileId;\n }\n\n /**\n * Set the keys which must sign any transactions modifying this file. Required.\n *\n * All keys must sign to modify the file's contents or keys. No key is required\n * to sign for extending the expiration time (except the one for the operator account\n * paying for the transaction). Only one key must sign to delete the file, however.\n *\n * To require more than one key to sign to delete a file, add them to a\n * KeyList and pass that here.\n *\n * The network currently requires a file to have at least one key (or key list or threshold key)\n * but this requirement may be lifted in the future.\n *\n * @param {FileId | string} fileId\n * @returns {this}\n */\n setFileId(fileId) {\n this._requireNotFrozen();\n this._fileId =\n typeof fileId === \"string\"\n ? FileId.fromString(fileId)\n : fileId.clone();\n\n return this;\n }\n\n /**\n * @override\n * @returns {number}\n */\n getRequiredChunks() {\n if (this._contents == null) {\n return 1;\n }\n\n const result = Math.ceil(this._contents.length / this._chunkSize);\n\n return result;\n }\n\n /**\n * @returns {?Uint8Array}\n */\n get contents() {\n return this._contents;\n }\n\n /**\n * Set the given byte array as the file's contents.\n *\n * This may be omitted to append an empty file.\n *\n * Note that total size for a given transaction is limited to 6KiB (as of March 2020) by the\n * network; if you exceed this you may receive a HederaPreCheckStatusException\n * with Status#TransactionOversize.\n *\n * In this case, you will need to break the data into chunks of less than ~6KiB and execute this\n * transaction with the first chunk and then use FileAppendTransaction with\n * FileAppendTransaction#setContents(Uint8Array) for the remaining chunks.\n *\n * @param {Uint8Array | string} contents\n * @returns {this}\n */\n setContents(contents) {\n this._requireNotFrozen();\n this._contents =\n contents instanceof Uint8Array ? contents : utf8.encode(contents);\n\n return this;\n }\n\n /**\n * @returns {?number}\n */\n get maxChunks() {\n return this._maxChunks;\n }\n\n /**\n * @param {number} maxChunks\n * @returns {this}\n */\n setMaxChunks(maxChunks) {\n if (maxChunks <= 0) {\n throw new Error(\"Max chunks must be greater than 0\");\n }\n this._requireNotFrozen();\n this._maxChunks = maxChunks;\n return this;\n }\n\n /**\n * @returns {?number}\n */\n get chunkSize() {\n return this._chunkSize;\n }\n\n /**\n * @param {number} chunkSize\n * @returns {this}\n */\n setChunkSize(chunkSize) {\n if (chunkSize <= 0) {\n throw new Error(\"Chunk size must be greater than 0\");\n }\n this._chunkSize = chunkSize;\n return this;\n }\n\n /**\n * @returns {number}\n */\n get chunkInterval() {\n return this._chunkInterval;\n }\n\n /**\n * @param {number} chunkInterval The valid start interval between chunks in nanoseconds\n * @returns {this}\n */\n setChunkInterval(chunkInterval) {\n this._chunkInterval = chunkInterval;\n return this;\n }\n\n /**\n * Freeze this transaction from further modification to prepare for\n * signing or serialization.\n *\n * Will use the `Client`, if available, to generate a default Transaction ID and select 1/3\n * nodes to prepare this transaction for.\n *\n * @param {?Client} client\n * @returns {this}\n */\n freezeWith(client) {\n super.freezeWith(client);\n\n if (this._contents == null) {\n return this;\n }\n\n let nextTransactionId = this._getTransactionId();\n\n // Hack around the locked list. Should refactor a bit to remove such code\n this._transactionIds.locked = false;\n\n this._transactions.clear();\n this._transactionIds.clear();\n this._signedTransactions.clear();\n\n for (let chunk = 0; chunk < this.getRequiredChunks(); chunk++) {\n this._transactionIds.push(nextTransactionId);\n this._transactionIds.advance();\n\n for (const nodeAccountId of this._nodeAccountIds.list) {\n this._signedTransactions.push(\n this._makeSignedTransaction(nodeAccountId),\n );\n }\n\n nextTransactionId = new TransactionId(\n /** @type {AccountId} */ (nextTransactionId.accountId),\n new Timestamp(\n /** @type {Timestamp} */ (\n nextTransactionId.validStart\n ).seconds,\n /** @type {Timestamp} */ (\n nextTransactionId.validStart\n ).nanos.add(this._chunkInterval),\n ),\n );\n }\n\n this._transactionIds.advance();\n this._transactionIds.setLocked();\n\n return this;\n }\n\n /**\n * @returns {ScheduleCreateTransaction}\n */\n schedule() {\n this._requireNotFrozen();\n\n if (this._contents != null && this._contents.length > this._chunkSize) {\n throw new Error(\n `cannot schedule \\`FileAppendTransaction\\` with message over ${this._chunkSize} bytes`,\n );\n }\n\n return super.schedule();\n }\n\n /**\n * @param {Client} client\n * @param {number=} requestTimeout\n * @returns {Promise<TransactionResponse>}\n */\n async execute(client, requestTimeout) {\n return (await this.executeAll(client, requestTimeout))[0];\n }\n\n /**\n * @param {Client} client\n * @param {number=} requestTimeout\n * @returns {Promise<TransactionResponse[]>}\n */\n async executeAll(client, requestTimeout) {\n if (this.maxChunks && this.getRequiredChunks() > this.maxChunks) {\n throw new Error(\n `cannot execute \\`FileAppendTransaction\\` with more than ${this.maxChunks} chunks`,\n );\n }\n\n if (!super._isFrozen()) {\n this.freezeWith(client);\n }\n\n // on execute, sign each transaction with the operator, if present\n // and we are signing a transaction that used the default transaction ID\n\n const transactionId = this._getTransactionId();\n const operatorAccountId = client.operatorAccountId;\n\n if (\n operatorAccountId != null &&\n operatorAccountId.equals(\n /** @type {AccountId} */ (transactionId.accountId),\n )\n ) {\n await super.signWithOperator(client);\n }\n\n const responses = [];\n let remainingTimeout = requestTimeout;\n\n for (let i = 0; i < this._transactionIds.length; i++) {\n const startTimestamp = Date.now();\n const response = await super.execute(client, remainingTimeout);\n\n if (remainingTimeout != null) {\n remainingTimeout = Date.now() - startTimestamp;\n }\n\n await response.getReceipt(client);\n responses.push(response);\n }\n\n return responses;\n }\n\n /**\n * @param {Client} client\n */\n _validateChecksums(client) {\n if (this._fileId != null) {\n this._fileId.validateChecksum(client);\n }\n }\n\n /**\n * @override\n * @internal\n * @param {Channel} channel\n * @param {HieroProto.proto.ITransaction} request\n * @returns {Promise<HieroProto.proto.ITransactionResponse>}\n */\n _execute(channel, request) {\n return channel.file.appendContent(request);\n }\n\n /**\n * @override\n * @protected\n * @returns {NonNullable<HieroProto.proto.TransactionBody[\"data\"]>}\n */\n _getTransactionDataCase() {\n return \"fileAppend\";\n }\n\n /**\n * Build all the transactions\n * when transactions are not complete.\n * @override\n * @internal\n */\n _buildIncompleteTransactions() {\n const dummyAccountId = AccountId.fromString(\"0.0.0\");\n const accountId = this.transactionId?.accountId || dummyAccountId;\n const validStart =\n this.transactionId?.validStart || Timestamp.fromDate(new Date());\n\n if (this.maxChunks && this.getRequiredChunks() > this.maxChunks) {\n throw new Error(\n `cannot build \\`FileAppendTransaction\\` with more than ${this.maxChunks} chunks`,\n );\n }\n\n // Hack around the locked list. Should refactor a bit to remove such code\n this._transactionIds.locked = false;\n\n this._transactions.clear();\n this._transactionIds.clear();\n this._signedTransactions.clear();\n\n for (let chunk = 0; chunk < this.getRequiredChunks(); chunk++) {\n let nextTransactionId = TransactionId.withValidStart(\n accountId,\n validStart.plusNanos(this._chunkInterval * chunk),\n );\n this._transactionIds.push(nextTransactionId);\n this._transactionIds.advance();\n\n if (this._nodeAccountIds.list.length === 0) {\n this._transactions.push(this._makeSignedTransaction(null));\n } else {\n for (const nodeAccountId of this._nodeAccountIds.list) {\n this._transactions.push(\n this._makeSignedTransaction(nodeAccountId),\n );\n }\n }\n }\n\n this._transactionIds.advance();\n this._transactionIds.setLocked();\n }\n\n /**\n * Build all the signed transactions\n * @override\n * @internal\n */\n _buildAllTransactions() {\n if (this.maxChunks && this.getRequiredChunks() > this.maxChunks) {\n throw new Error(\n `cannot build \\`FileAppendTransaction\\` with more than ${this.maxChunks} chunks`,\n );\n }\n for (let i = 0; i < this._signedTransactions.length; i++) {\n this._buildTransaction(i);\n }\n }\n\n /**\n * @returns {string}\n */\n _getLogId() {\n const timestamp = /** @type {import(\"../Timestamp.js\").default} */ (\n this._transactionIds.current.validStart\n );\n return `FileAppendTransaction:${timestamp.toString()}`;\n }\n\n /**\n * @override\n * @protected\n * @returns {HieroProto.proto.IFileAppendTransactionBody}\n */\n _makeTransactionData() {\n const length = this._contents != null ? this._contents.length : 0;\n const startIndex = this._transactionIds.index * this._chunkSize;\n const endIndex = Math.min(startIndex + this._chunkSize, length);\n\n return {\n fileID: this._fileId != null ? this._fileId._toProtobuf() : null,\n contents:\n this._contents != null\n ? this._contents.slice(startIndex, endIndex)\n : null,\n };\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/unbound-method\nTRANSACTION_REGISTRY.set(\"fileAppend\", FileAppendTransaction._fromProtobuf);\n"],"names":["FileAppendTransaction","Transaction","constructor","props","super","this","_fileId","_contents","_maxChunks","_chunkSize","_chunkInterval","_defaultMaxTransactionFee","Hbar","fileId","setFileId","contents","setContents","maxChunks","setMaxChunks","chunkSize","setChunkSize","chunkInterval","setChunkInterval","_transactionIds","List","_fromProtobuf","transactions","signedTransactions","transactionIds","nodeIds","bodies","append","incrementValue","length","i","fileAppend","Uint8Array","concat","set","undefined","firstValidStart","validStart","secondValidStart","nanos","sub","toNumber","_fromProtobufTransactions","fileID","FileId","_requireNotFrozen","fromString","clone","getRequiredChunks","Math","ceil","utf8.encode","Error","freezeWith","client","nextTransactionId","_getTransactionId","locked","_transactions","clear","_signedTransactions","chunk","push","advance","nodeAccountId","_nodeAccountIds","list","_makeSignedTransaction","TransactionId","Timestamp","seconds","add","setLocked","schedule","execute","requestTimeout","executeAll","_isFrozen","transactionId","operatorAccountId","equals","signWithOperator","responses","remainingTimeout","startTimestamp","Date","now","response","getReceipt","_validateChecksums","validateChecksum","_execute","channel","request","file","appendContent","_getTransactionDataCase","_buildIncompleteTransactions","dummyAccountId","AccountId","accountId","fromDate","withValidStart","plusNanos","_buildAllTransactions","_buildTransaction","_getLogId","current","toString","_makeTransactionData","startIndex","index","endIndex","min","_toProtobuf","slice","TRANSACTION_REGISTRY"],"mappings":"qUAsCe,MAAMA,UAA8BC,EAS/C,WAAAC,CAAYC,EAAQ,IAChBC,QAMAC,KAAKC,QAAU,KAMfD,KAAKE,UAAY,KAMjBF,KAAKG,WAAa,GAalBH,KAAKI,WAAa,KAMlBJ,KAAKK,eAAiB,GAEtBL,KAAKM,0BAA4B,IAAIC,EAAK,GAEtB,MAAhBT,EAAMU,QACNR,KAAKS,UAAUX,EAAMU,QAGH,MAAlBV,EAAMY,UACNV,KAAKW,YAAYb,EAAMY,UAGJ,MAAnBZ,EAAMc,WACNZ,KAAKa,aAAaf,EAAMc,WAGL,MAAnBd,EAAMgB,WACNd,KAAKe,aAAajB,EAAMgB,WAGD,MAAvBhB,EAAMkB,eACNhB,KAAKiB,iBAAiBnB,EAAMkB,eAIhChB,KAAKkB,gBAAkB,IAAIC,CAC/B,CAWA,oBAAOC,CACHC,EACAC,EACAC,EACAC,EACAC,GAEA,MACMC,EADOD,EAAO,GAI5B,WAEQ,IAAIf,EAKJ,MAAMiB,EAAiBH,EAAQI,OAAS,EAAIJ,EAAQI,OAAS,EAE7D,IAAK,IAAIC,EAAI,EAAGA,EAAIJ,EAAOG,OAAQC,GAAKF,EAAgB,CACpD,MAAMG,EAEEL,EAAOI,GAC3B,WACY,GAA2B,MAAvBC,EAAWpB,SACX,MAGJ,GAAgB,MAAZA,EAAkB,CAClBA,EAAW,IAAIqB,WACgBD,EAAmB,UAElD,QACJ,CAGA,MAAME,EAAS,IAAID,WACfrB,EAASkB,OACsBE,EAAmB,SAAEF,QAExDI,EAAOC,IAAIvB,EAAU,GACrBsB,EAAOC,IACwBH,EAAmB,SAC9CpB,EAASkB,QAEblB,EAAWsB,CACf,CACA,MAAMlB,EAAYY,EAAOhB,UAAUkB,aAAUM,EACvCtB,EAAYa,EAAO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C7CjE,KAAKyD,cAAcI,KACf7D,KAAKkE,uBAAuBH,GAI5C,CAEA/D,KAAKkB,gBAAgB4C,UACrB9D,KAAKkB,gBAAgBqD,WACzB,CAOA,qBAAAgC,GACI,GAAIvG,KAAKY,WAAaZ,KAAK+C,oBAAsB/C,KAAKY,UAClD,MAAM,IAAIuC,MACN,yDAAyDnD,KAAKY,oBAGtE,IAAK,IAAIiB,EAAI,EAAGA,EAAI7B,KAAK2D,oBAAoB/B,OAAQC,IACjD7B,KAAKwG,kBAAkB3E,EAE/B,CAKA,SAAA4E,GAII,MAAO,yBAFHzG,KAAKkB,gBAAgBwF,QACjC,WACkDC,YAC9C,CAOA,oBAAAC,GACI,MAAMhF,EAA2B,MAAlB5B,KAAKE,UAAoBF,KAAKE,UAAU0B,OAAS,EAC1DiF,EAAa7G,KAAKkB,gBAAgB4F,MAAQ9G,KAAKI,WAC/C2G,EAAW/D,KAAKgE,IAAIH,EAAa7G,KAAKI,WAAYwB,GAExD,MAAO,CACHc,OAAwB,MAAhB1C,KAAKC,QAAkBD,KAAKC,QAAQgH,cAAgB,KAC5DvG,SACsB,MAAlBV,KAAKE,UACCF,KAAKE,UAAUgH,MAAML,EAAYE,GACjC,KAElB,EAIJI,EAAqBlF,IAAI,aAActC,EAAsByB"}
package/lib/version.js CHANGED
@@ -1,2 +1,2 @@
1
- const e="hiero-sdk-js",o="2.83.0-beta.1";export{e as SDK_NAME,o as SDK_VERSION};
1
+ const e="hiero-sdk-js",o="2.83.0-beta.2";export{e as SDK_NAME,o as SDK_VERSION};
2
2
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hiero-ledger/sdk",
3
- "version": "2.83.0-beta.1",
3
+ "version": "2.83.0-beta.2",
4
4
  "description": "Hiero SDK",
5
5
  "types": "./lib/index.d.ts",
6
6
  "main": "./lib/index.cjs",
@@ -3,6 +3,16 @@ import * as hex from "./encoding/hex.js";
3
3
  import EthereumTransactionData from "./EthereumTransactionData.js";
4
4
  import CACHE from "./Cache.js";
5
5
 
6
+ /**
7
+ * @typedef {[Uint8Array, Uint8Array[]]} AccessListItem - [address, storageKeys[]]
8
+ */
9
+
10
+ /**
11
+ * @typedef {object} AccessListItemJSON
12
+ * @property {string} address
13
+ * @property {string[]} storageKeys
14
+ */
15
+
6
16
  /**
7
17
  * @typedef {object} EthereumTransactionDataEip1559JSON
8
18
  * @property {string} chainId
@@ -13,7 +23,7 @@ import CACHE from "./Cache.js";
13
23
  * @property {string} to
14
24
  * @property {string} value
15
25
  * @property {string} callData
16
- * @property {string[]} accessList
26
+ * @property {AccessListItemJSON[]} accessList
17
27
  * @property {string} recId
18
28
  * @property {string} r
19
29
  * @property {string} s
@@ -31,7 +41,7 @@ export default class EthereumTransactionDataEip1559 extends EthereumTransactionD
31
41
  * @param {Uint8Array} props.to
32
42
  * @param {Uint8Array} props.value
33
43
  * @param {Uint8Array} props.callData
34
- * @param {Uint8Array[]} props.accessList
44
+ * @param {AccessListItem[]} props.accessList
35
45
  * @param {Uint8Array} props.recId
36
46
  * @param {Uint8Array} props.r
37
47
  * @param {Uint8Array} props.s
@@ -61,8 +71,9 @@ export default class EthereumTransactionDataEip1559 extends EthereumTransactionD
61
71
  throw new Error("empty bytes");
62
72
  }
63
73
 
64
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
65
- const decoded = /** @type {string[]} */ (decodeRlp(bytes.subarray(1)));
74
+ const decoded = /** @type {unknown[]} */ (
75
+ /** @type {unknown} */ (decodeRlp(bytes.subarray(1)))
76
+ );
66
77
 
67
78
  if (!Array.isArray(decoded)) {
68
79
  throw new Error("ethereum data is not a list");
@@ -82,9 +93,20 @@ export default class EthereumTransactionDataEip1559 extends EthereumTransactionD
82
93
  to: hex.decode(/** @type {string} */ (decoded[5])),
83
94
  value: hex.decode(/** @type {string} */ (decoded[6])),
84
95
  callData: hex.decode(/** @type {string} */ (decoded[7])),
85
- // @ts-ignore
86
- accessList: /** @type {string[]} */ (decoded[8]).map((v) =>
87
- hex.decode(v),
96
+ accessList: /** @type {AccessListItem[]} */ (
97
+ /** @type {Array<[string, string[]]>} */ (
98
+ /** @type {unknown} */ (decoded[8])
99
+ ).map((item) => {
100
+ if (!Array.isArray(item) || item.length !== 2) {
101
+ throw new Error(
102
+ "invalid access list entry: must be [address, storageKeys[]]",
103
+ );
104
+ }
105
+ return [
106
+ hex.decode(item[0]),
107
+ item[1].map((key) => hex.decode(key)),
108
+ ];
109
+ })
88
110
  ),
89
111
  recId: hex.decode(/** @type {string} */ (decoded[9])),
90
112
  r: hex.decode(/** @type {string} */ (decoded[10])),
@@ -133,7 +155,10 @@ export default class EthereumTransactionDataEip1559 extends EthereumTransactionD
133
155
  to: hex.encode(this.to),
134
156
  value: hex.encode(this.value),
135
157
  callData: hex.encode(this.callData),
136
- accessList: this.accessList.map((v) => hex.encode(v)),
158
+ accessList: this.accessList.map(([address, storageKeys]) => ({
159
+ address: hex.encode(address),
160
+ storageKeys: storageKeys.map((key) => hex.encode(key)),
161
+ })),
137
162
  recId: hex.encode(this.recId),
138
163
  r: hex.encode(this.r),
139
164
  s: hex.encode(this.s),
@@ -3,6 +3,16 @@ import * as hex from "./encoding/hex.js";
3
3
  import EthereumTransactionData from "./EthereumTransactionData.js";
4
4
  import CACHE from "./Cache.js";
5
5
 
6
+ /**
7
+ * @typedef {[Uint8Array, Uint8Array[]]} AccessListItem - [address, storageKeys[]]
8
+ */
9
+
10
+ /**
11
+ * @typedef {object} AccessListItemJSON
12
+ * @property {string} address
13
+ * @property {string[]} storageKeys
14
+ */
15
+
6
16
  /**
7
17
  * @typedef {object} EthereumTransactionDataEip2930JSON
8
18
  * @property {string} chainId
@@ -12,7 +22,7 @@ import CACHE from "./Cache.js";
12
22
  * @property {string} to
13
23
  * @property {string} value
14
24
  * @property {string} callData
15
- * @property {string[]} accessList
25
+ * @property {AccessListItemJSON[]} accessList
16
26
  * @property {string} recId
17
27
  * @property {string} r
18
28
  * @property {string} s
@@ -29,7 +39,7 @@ export default class EthereumTransactionDataEip2930 extends EthereumTransactionD
29
39
  * @param {Uint8Array} props.to
30
40
  * @param {Uint8Array} props.value
31
41
  * @param {Uint8Array} props.callData
32
- * @param {Uint8Array[]} props.accessList
42
+ * @param {AccessListItem[]} props.accessList
33
43
  * @param {Uint8Array} props.recId
34
44
  * @param {Uint8Array} props.r
35
45
  * @param {Uint8Array} props.s
@@ -58,8 +68,9 @@ export default class EthereumTransactionDataEip2930 extends EthereumTransactionD
58
68
  throw new Error("empty bytes");
59
69
  }
60
70
 
61
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
62
- const decoded = /** @type {string[]} */ (decodeRlp(bytes.subarray(1)));
71
+ const decoded = /** @type {unknown[]} */ (
72
+ /** @type {unknown} */ (decodeRlp(bytes.subarray(1)))
73
+ );
63
74
 
64
75
  if (!Array.isArray(decoded)) {
65
76
  throw new Error("ethereum data is not a list");
@@ -78,9 +89,20 @@ export default class EthereumTransactionDataEip2930 extends EthereumTransactionD
78
89
  to: hex.decode(/** @type {string} */ (decoded[4])),
79
90
  value: hex.decode(/** @type {string} */ (decoded[5])),
80
91
  callData: hex.decode(/** @type {string} */ (decoded[6])),
81
- // @ts-ignore
82
- accessList: /** @type {string[]} */ (decoded[7]).map((v) =>
83
- hex.decode(v),
92
+ accessList: /** @type {AccessListItem[]} */ (
93
+ /** @type {Array<[string, string[]]>} */ (
94
+ /** @type {unknown} */ (decoded[7])
95
+ ).map((item) => {
96
+ if (!Array.isArray(item) || item.length !== 2) {
97
+ throw new Error(
98
+ "invalid access list entry: must be [address, storageKeys[]]",
99
+ );
100
+ }
101
+ return [
102
+ hex.decode(item[0]),
103
+ item[1].map((key) => hex.decode(key)),
104
+ ];
105
+ })
84
106
  ),
85
107
  recId: hex.decode(/** @type {string} */ (decoded[8])),
86
108
  r: hex.decode(/** @type {string} */ (decoded[9])),
@@ -127,7 +149,10 @@ export default class EthereumTransactionDataEip2930 extends EthereumTransactionD
127
149
  to: hex.encode(this.to),
128
150
  value: hex.encode(this.value),
129
151
  callData: hex.encode(this.callData),
130
- accessList: this.accessList.map((v) => hex.encode(v)),
152
+ accessList: this.accessList.map(([address, storageKeys]) => ({
153
+ address: hex.encode(address),
154
+ storageKeys: storageKeys.map((key) => hex.encode(key)),
155
+ })),
131
156
  recId: hex.encode(this.recId),
132
157
  r: hex.encode(this.r),
133
158
  s: hex.encode(this.s),
@@ -3,6 +3,20 @@ import * as hex from "./encoding/hex.js";
3
3
  import EthereumTransactionData from "./EthereumTransactionData.js";
4
4
  import CACHE from "./Cache.js";
5
5
 
6
+ /**
7
+ * @typedef {[Uint8Array, Uint8Array[]]} AccessListItem - [address, storageKeys[]]
8
+ */
9
+
10
+ /**
11
+ * @typedef {[Uint8Array, Uint8Array, Uint8Array, Uint8Array, Uint8Array, Uint8Array]} AuthorizationItem - [chainId, contractAddress, nonce, yParity, r, s]
12
+ */
13
+
14
+ /**
15
+ * @typedef {object} AccessListItemJSON
16
+ * @property {string} address
17
+ * @property {string[]} storageKeys
18
+ */
19
+
6
20
  /**
7
21
  * @typedef {object} EthereumTransactionDataEip7702JSON
8
22
  * @property {string} chainId
@@ -14,7 +28,7 @@ import CACHE from "./Cache.js";
14
28
  * @property {string} value
15
29
  * @property {string} callData
16
30
  * @property {Array<[string, string, string, string, string, string]>} authorizationList - Array of [chainId, contractAddress, nonce, yParity, r, s] tuples
17
- * @property {string[]} accessList
31
+ * @property {AccessListItemJSON[]} accessList
18
32
  * @property {string} recId
19
33
  * @property {string} r
20
34
  * @property {string} s
@@ -32,8 +46,8 @@ export default class EthereumTransactionDataEip7702 extends EthereumTransactionD
32
46
  * @param {Uint8Array} props.to
33
47
  * @param {Uint8Array} props.value
34
48
  * @param {Uint8Array} props.callData
35
- * @param {Array<[Uint8Array, Uint8Array, Uint8Array, Uint8Array, Uint8Array, Uint8Array]>} props.authorizationList - Array of [chainId, contractAddress, nonce, yParity, r, s] tuples
36
- * @param {Uint8Array[]} props.accessList
49
+ * @param {AuthorizationItem[]} props.authorizationList - Array of [chainId, contractAddress, nonce, yParity, r, s] tuples
50
+ * @param {AccessListItem[]} props.accessList
37
51
  * @param {Uint8Array} props.recId
38
52
  * @param {Uint8Array} props.r
39
53
  * @param {Uint8Array} props.s
@@ -65,8 +79,9 @@ export default class EthereumTransactionDataEip7702 extends EthereumTransactionD
65
79
  throw new Error("empty bytes");
66
80
  }
67
81
 
68
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
69
- const decoded = /** @type {string[]} */ (decodeRlp(bytes.subarray(1)));
82
+ const decoded = /** @type {unknown[]} */ (
83
+ /** @type {unknown} */ (decodeRlp(bytes.subarray(1)))
84
+ );
70
85
 
71
86
  if (!Array.isArray(decoded)) {
72
87
  throw new Error("ethereum data is not a list");
@@ -81,30 +96,24 @@ export default class EthereumTransactionDataEip7702 extends EthereumTransactionD
81
96
  if (!Array.isArray(decoded[9])) {
82
97
  throw new Error("authorization list must be an array");
83
98
  }
84
- // @ts-ignore
85
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
86
- const authorizationList = /** @type {string[]} */ (decoded[9]).map(
87
- (authTuple) => {
99
+ const authorizationList = /** @type {AuthorizationItem[]} */ (
100
+ /** @type {Array<[string, string, string, string, string, string]>} */ (
101
+ /** @type {unknown} */ (decoded[9])
102
+ ).map((authTuple) => {
88
103
  if (!Array.isArray(authTuple) || authTuple.length !== 6) {
89
104
  throw new Error(
90
105
  "invalid authorization list entry: must be [chainId, contractAddress, nonce, yParity, r, s]",
91
106
  );
92
107
  }
93
108
  return [
94
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
95
- hex.decode(/** @type {string} */ (authTuple[0])), // chainId
96
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
97
- hex.decode(/** @type {string} */ (authTuple[1])), // contractAddress (20 bytes)
98
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
99
- hex.decode(/** @type {string} */ (authTuple[2])), // nonce
100
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
101
- hex.decode(/** @type {string} */ (authTuple[3])), // yParity (0 or 1)
102
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
103
- hex.decode(/** @type {string} */ (authTuple[4])), // r (32 bytes)
104
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
105
- hex.decode(/** @type {string} */ (authTuple[5])), // s (32 bytes)
109
+ hex.decode(authTuple[0]), // chainId
110
+ hex.decode(authTuple[1]), // contractAddress (20 bytes)
111
+ hex.decode(authTuple[2]), // nonce
112
+ hex.decode(authTuple[3]), // yParity (0 or 1)
113
+ hex.decode(authTuple[4]), // r (32 bytes)
114
+ hex.decode(authTuple[5]), // s (32 bytes)
106
115
  ];
107
- },
116
+ })
108
117
  );
109
118
 
110
119
  return new EthereumTransactionDataEip7702({
@@ -116,11 +125,21 @@ export default class EthereumTransactionDataEip7702 extends EthereumTransactionD
116
125
  to: hex.decode(/** @type {string} */ (decoded[5])),
117
126
  value: hex.decode(/** @type {string} */ (decoded[6])),
118
127
  callData: hex.decode(/** @type {string} */ (decoded[7])),
119
- // @ts-ignore
120
- accessList: /** @type {string[]} */ (decoded[8]).map((v) =>
121
- hex.decode(v),
128
+ accessList: /** @type {AccessListItem[]} */ (
129
+ /** @type {Array<[string, string[]]>} */ (
130
+ /** @type {unknown} */ (decoded[8])
131
+ ).map((item) => {
132
+ if (!Array.isArray(item) || item.length !== 2) {
133
+ throw new Error(
134
+ "invalid access list entry: must be [address, storageKeys[]]",
135
+ );
136
+ }
137
+ return [
138
+ hex.decode(item[0]),
139
+ item[1].map((key) => hex.decode(key)),
140
+ ];
141
+ })
122
142
  ),
123
- // @ts-ignore
124
143
  authorizationList: authorizationList,
125
144
  recId: hex.decode(/** @type {string} */ (decoded[10])),
126
145
  r: hex.decode(/** @type {string} */ (decoded[11])),
@@ -180,7 +199,10 @@ export default class EthereumTransactionDataEip7702 extends EthereumTransactionD
180
199
  hex.encode(s),
181
200
  ],
182
201
  ),
183
- accessList: this.accessList.map((v) => hex.encode(v)),
202
+ accessList: this.accessList.map(([address, storageKeys]) => ({
203
+ address: hex.encode(address),
204
+ storageKeys: storageKeys.map((key) => hex.encode(key)),
205
+ })),
184
206
  recId: hex.encode(this.recId),
185
207
  r: hex.encode(this.r),
186
208
  s: hex.encode(this.s),
@@ -52,8 +52,9 @@ export default class EthereumTransactionDataLegacy extends EthereumTransactionDa
52
52
  throw new Error("empty bytes");
53
53
  }
54
54
 
55
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
56
- const decoded = /** @type {string[]} */ (decodeRlp(bytes));
55
+ const decoded = /** @type {unknown[]} */ (
56
+ /** @type {unknown} */ (decodeRlp(bytes))
57
+ );
57
58
 
58
59
  if (decoded.length != 9) {
59
60
  throw new Error("invalid ethereum transaction data");
@@ -67,6 +67,13 @@ export default class FileAppendTransaction extends Transaction {
67
67
  this._maxChunks = 20;
68
68
 
69
69
  /**
70
+ * The default chunk size in bytes for file append operations.
71
+ *
72
+ * The network limits total transaction size (SignedTransaction) to 6144 bytes.
73
+ * Each Ed25519 signature adds ~102 bytes of overhead (pubKeyPrefix + signature + wrapping).
74
+ * With 4096-byte chunks, transactions fit within the limit for up to ~19 signatures.
75
+ * For files requiring more signers, callers should use setChunkSize() with a smaller value.
76
+ *
70
77
  * @private
71
78
  * @type {number}
72
79
  */