@hiero-ledger/sdk 2.71.0-beta.0 → 2.71.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 +142 -40
- package/dist/umd.min.js +2 -2
- package/lib/LedgerId.cjs +4 -4
- package/lib/LedgerId.js +1 -1
- package/lib/LedgerId.js.map +1 -1
- package/lib/channel/NativeChannel.cjs +3 -2
- package/lib/channel/NativeChannel.js +1 -1
- package/lib/channel/NativeChannel.js.map +1 -1
- package/lib/channel/NodeMirrorChannel.cjs +0 -2
- package/lib/channel/NodeMirrorChannel.js +1 -1
- package/lib/channel/NodeMirrorChannel.js.map +1 -1
- package/lib/client/Client.cjs +3 -2
- package/lib/client/Client.d.ts +2 -2
- package/lib/client/Client.js +1 -1
- package/lib/client/Client.js.map +1 -1
- package/lib/client/NativeClient.cjs +141 -44
- package/lib/client/NativeClient.d.ts +48 -16
- package/lib/client/NativeClient.js +1 -1
- package/lib/client/NativeClient.js.map +1 -1
- package/lib/client/NodeClient.cjs +63 -2
- package/lib/client/NodeClient.d.ts +42 -0
- package/lib/client/NodeClient.js +1 -1
- package/lib/client/NodeClient.js.map +1 -1
- package/lib/client/WebClient.cjs +64 -34
- package/lib/client/WebClient.d.ts +35 -15
- package/lib/client/WebClient.js +1 -1
- package/lib/client/WebClient.js.map +1 -1
- package/lib/constants/ClientConstants.cjs +22 -7
- package/lib/constants/ClientConstants.d.ts +12 -6
- package/lib/constants/ClientConstants.js +1 -1
- package/lib/constants/ClientConstants.js.map +1 -1
- package/lib/contract/ContractCreateTransaction.cjs +5 -0
- package/lib/contract/ContractCreateTransaction.js +1 -1
- package/lib/contract/ContractCreateTransaction.js.map +1 -1
- package/lib/contract/ContractDeleteTransaction.cjs +35 -2
- package/lib/contract/ContractDeleteTransaction.d.ts +18 -0
- package/lib/contract/ContractDeleteTransaction.js +1 -1
- package/lib/contract/ContractDeleteTransaction.js.map +1 -1
- package/lib/contract/ContractUpdateTransaction.cjs +2 -1
- package/lib/contract/ContractUpdateTransaction.js +1 -1
- package/lib/contract/ContractUpdateTransaction.js.map +1 -1
- package/lib/encoding/hex.cjs +11 -0
- package/lib/encoding/hex.js +1 -1
- package/lib/encoding/hex.js.map +1 -1
- package/lib/native.cjs +2 -2
- package/lib/native.d.ts +1 -1
- package/lib/native.js +1 -1
- package/lib/version.js +1 -1
- package/package.json +2 -2
- package/src/LedgerId.js +4 -4
- package/src/channel/NativeChannel.js +9 -1
- package/src/channel/NodeMirrorChannel.js +0 -2
- package/src/client/Client.js +4 -2
- package/src/client/NativeClient.js +151 -47
- package/src/client/NodeClient.js +56 -3
- package/src/client/WebClient.js +63 -44
- package/src/constants/ClientConstants.js +26 -8
- package/src/contract/ContractCreateTransaction.js +5 -3
- package/src/contract/ContractDeleteTransaction.js +34 -0
- package/src/contract/ContractUpdateTransaction.js +4 -1
- package/src/encoding/hex.js +20 -0
- package/src/native.js +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import t from"../Hbar.js";import e from"../account/AccountId.js";import o from"../file/FileId.js";import n from"./ContractFunctionParameters.js";import i,{TRANSACTION_REGISTRY as r,DEFAULT_AUTO_RENEW_PERIOD as s}from"../transaction/Transaction.js";import a from"long";import c from"../Duration.js";import u from"../Key.js";class d extends i{constructor(e={}){super(),this._bytecodeFileId=null,this._bytecode=null,this._adminKey=null,this._gas=null,this._initialBalance=null,this._proxyAccountId=null,this._autoRenewPeriod=new c(s),this._constructorParameters=null,this._contractMemo=null,this._maxAutomaticTokenAssociations=null,this._defaultMaxTransactionFee=new t(20),this._stakedAccountId=null,this._stakedNodeId=null,this._declineStakingReward=!1,this._autoRenewAccountId=null,null!=e.bytecodeFileId&&this.setBytecodeFileId(e.bytecodeFileId),null!=e.bytecode&&this.setBytecode(e.bytecode),null!=e.adminKey&&this.setAdminKey(e.adminKey),null!=e.gas&&this.setGas(e.gas),null!=e.initialBalance&&this.setInitialBalance(e.initialBalance),null!=e.proxyAccountId&&this.setProxyAccountId(e.proxyAccountId),null!=e.autoRenewPeriod&&this.setAutoRenewPeriod(e.autoRenewPeriod),null!=e.constructorParameters&&this.setConstructorParameters(e.constructorParameters),null!=e.contractMemo&&this.setContractMemo(e.contractMemo),null!=e.maxAutomaticTokenAssociations&&this.setMaxAutomaticTokenAssociations(e.maxAutomaticTokenAssociations),null!=e.stakedAccountId&&this.setStakedAccountId(e.stakedAccountId),null!=e.stakedNodeId&&this.setStakedNodeId(e.stakedNodeId),null!=e.declineStakingReward&&this.setDeclineStakingReward(e.declineStakingReward),null!=e.autoRenewAccountId&&this.setAutoRenewAccountId(e.autoRenewAccountId)}static _fromProtobuf(n,r,s,a,c){const l=c[0].contractCreateInstance;return i._fromProtobufTransactions(new d({bytecodeFileId:null!=l.fileID?o._fromProtobuf(l.fileID):void 0,adminKey:null!=l.adminKey?u._fromProtobufKey(l.adminKey):void 0,gas:null!=l.gas?l.gas:void 0,initialBalance:null!=l.initialBalance?t.fromTinybars(l.initialBalance):void 0,proxyAccountId:null!=l.proxyAccountID?e._fromProtobuf(l.proxyAccountID):void 0,autoRenewPeriod:null!=l.autoRenewPeriod&&null!=l.autoRenewPeriod.seconds?l.autoRenewPeriod.seconds:void 0,constructorParameters:null!=l.constructorParameters?l.constructorParameters:void 0,contractMemo:null!=l.memo?l.memo:void 0,maxAutomaticTokenAssociations:null!=l.maxAutomaticTokenAssociations?l.maxAutomaticTokenAssociations:void 0,stakedAccountId:null!=l.stakedAccountId?e._fromProtobuf(l.stakedAccountId):void 0,stakedNodeId:null!=l.stakedNodeId?l.stakedNodeId:void 0,declineStakingReward:1==l.declineReward,autoRenewAccountId:null!=l.autoRenewAccountId?e._fromProtobuf(l.autoRenewAccountId):void 0}),n,r,s,a,c)}get bytecodeFileId(){return this._bytecodeFileId}setBytecodeFileId(t){return this._requireNotFrozen(),this._bytecodeFileId="string"==typeof t?o.fromString(t):t.clone(),this._bytecode=null,this}get bytecode(){return this._bytecode}setBytecode(t){return this._requireNotFrozen(),this._bytecode=t,this._bytecodeFileId=null,this}get adminKey(){return this._adminKey}setAdminKey(t){return this._requireNotFrozen(),this._adminKey=t,this}get gas(){return this._gas}setGas(t){
|
|
1
|
+
import t from"../Hbar.js";import e from"../account/AccountId.js";import o from"../file/FileId.js";import n from"./ContractFunctionParameters.js";import i,{TRANSACTION_REGISTRY as r,DEFAULT_AUTO_RENEW_PERIOD as s}from"../transaction/Transaction.js";import a from"long";import c from"../Duration.js";import u from"../Key.js";class d extends i{constructor(e={}){super(),this._bytecodeFileId=null,this._bytecode=null,this._adminKey=null,this._gas=null,this._initialBalance=null,this._proxyAccountId=null,this._autoRenewPeriod=new c(s),this._constructorParameters=null,this._contractMemo=null,this._maxAutomaticTokenAssociations=null,this._defaultMaxTransactionFee=new t(20),this._stakedAccountId=null,this._stakedNodeId=null,this._declineStakingReward=!1,this._autoRenewAccountId=null,null!=e.bytecodeFileId&&this.setBytecodeFileId(e.bytecodeFileId),null!=e.bytecode&&this.setBytecode(e.bytecode),null!=e.adminKey&&this.setAdminKey(e.adminKey),null!=e.gas&&this.setGas(e.gas),null!=e.initialBalance&&this.setInitialBalance(e.initialBalance),null!=e.proxyAccountId&&this.setProxyAccountId(e.proxyAccountId),null!=e.autoRenewPeriod&&this.setAutoRenewPeriod(e.autoRenewPeriod),null!=e.constructorParameters&&this.setConstructorParameters(e.constructorParameters),null!=e.contractMemo&&this.setContractMemo(e.contractMemo),null!=e.maxAutomaticTokenAssociations&&this.setMaxAutomaticTokenAssociations(e.maxAutomaticTokenAssociations),null!=e.stakedAccountId&&this.setStakedAccountId(e.stakedAccountId),null!=e.stakedNodeId&&this.setStakedNodeId(e.stakedNodeId),null!=e.declineStakingReward&&this.setDeclineStakingReward(e.declineStakingReward),null!=e.autoRenewAccountId&&this.setAutoRenewAccountId(e.autoRenewAccountId)}static _fromProtobuf(n,r,s,a,c){const l=c[0].contractCreateInstance;return i._fromProtobufTransactions(new d({bytecodeFileId:null!=l.fileID?o._fromProtobuf(l.fileID):void 0,adminKey:null!=l.adminKey?u._fromProtobufKey(l.adminKey):void 0,gas:null!=l.gas?l.gas:void 0,initialBalance:null!=l.initialBalance?t.fromTinybars(l.initialBalance):void 0,proxyAccountId:null!=l.proxyAccountID?e._fromProtobuf(l.proxyAccountID):void 0,autoRenewPeriod:null!=l.autoRenewPeriod&&null!=l.autoRenewPeriod.seconds?l.autoRenewPeriod.seconds:void 0,constructorParameters:null!=l.constructorParameters?l.constructorParameters:void 0,contractMemo:null!=l.memo?l.memo:void 0,maxAutomaticTokenAssociations:null!=l.maxAutomaticTokenAssociations?l.maxAutomaticTokenAssociations:void 0,stakedAccountId:null!=l.stakedAccountId?e._fromProtobuf(l.stakedAccountId):void 0,stakedNodeId:null!=l.stakedNodeId?l.stakedNodeId:void 0,declineStakingReward:1==l.declineReward,autoRenewAccountId:null!=l.autoRenewAccountId?e._fromProtobuf(l.autoRenewAccountId):void 0}),n,r,s,a,c)}get bytecodeFileId(){return this._bytecodeFileId}setBytecodeFileId(t){return this._requireNotFrozen(),this._bytecodeFileId="string"==typeof t?o.fromString(t):t.clone(),this._bytecode=null,this}get bytecode(){return this._bytecode}setBytecode(t){return this._requireNotFrozen(),this._bytecode=t,this._bytecodeFileId=null,this}get adminKey(){return this._adminKey}setAdminKey(t){return this._requireNotFrozen(),this._adminKey=t,this}get gas(){return this._gas}setGas(t){if(this._requireNotFrozen(),this._gas=t instanceof a?t:a.fromValue(t),this._gas.lessThan(0))throw new Error("Gas cannot be negative number");return this}get initialBalance(){return this._initialBalance}setInitialBalance(e){return this._requireNotFrozen(),this._initialBalance=e instanceof t?e:new t(e),this}get proxyAccountId(){return this._proxyAccountId}setProxyAccountId(t){return this._requireNotFrozen(),this._proxyAccountId=t instanceof e?t:e.fromString(t),this}get autoRenewPeriod(){return this._autoRenewPeriod}setAutoRenewPeriod(t){return this._requireNotFrozen(),this._autoRenewPeriod=t instanceof c?t:new c(t),this}get constructorParameters(){return this._constructorParameters}setConstructorParameters(t){return this._requireNotFrozen(),this._constructorParameters=t instanceof n?t._build():t,this}get contractMemo(){return this._contractMemo}setContractMemo(t){return this._requireNotFrozen(),this._contractMemo=t,this}get maxAutomaticTokenAssociations(){return this._maxAutomaticTokenAssociations}setMaxAutomaticTokenAssociations(t){return this._maxAutomaticTokenAssociations=t,this}get stakedAccountId(){return this._stakedAccountId}setStakedAccountId(t){return this._requireNotFrozen(),this._stakedAccountId="string"==typeof t?e.fromString(t):t,this._stakedNodeId=null,this}get stakedNodeId(){return this._stakedNodeId}setStakedNodeId(t){return this._requireNotFrozen(),this._stakedNodeId=a.fromValue(t),this._stakedAccountId=null,this}get declineStakingRewards(){return this._declineStakingReward}setDeclineStakingReward(t){return this._requireNotFrozen(),this._declineStakingReward=t,this}get autoRenewAccountId(){return this._autoRenewAccountId}setAutoRenewAccountId(t){return this._requireNotFrozen(),this._autoRenewAccountId="string"==typeof t?e.fromString(t):t,this}_validateChecksums(t){null!=this._bytecodeFileId&&this._bytecodeFileId.validateChecksum(t),null!=this._proxyAccountId&&this._proxyAccountId.validateChecksum(t)}_execute(t,e){return t.smartContract.createContract(e)}_getTransactionDataCase(){return"contractCreateInstance"}_makeTransactionData(){return{fileID:null!=this._bytecodeFileId?this._bytecodeFileId._toProtobuf():null,initcode:this._bytecode,adminKey:null!=this._adminKey?this._adminKey._toProtobufKey():null,gas:this._gas,initialBalance:null!=this._initialBalance?this._initialBalance.toTinybars():null,proxyAccountID:null!=this._proxyAccountId?this._proxyAccountId._toProtobuf():null,autoRenewPeriod:this._autoRenewPeriod._toProtobuf(),constructorParameters:this._constructorParameters,memo:this._contractMemo,maxAutomaticTokenAssociations:this._maxAutomaticTokenAssociations,stakedAccountId:null!=this.stakedAccountId?this.stakedAccountId._toProtobuf():null,stakedNodeId:this.stakedNodeId,declineReward:this.declineStakingRewards,autoRenewAccountId:null!=this._autoRenewAccountId?this._autoRenewAccountId._toProtobuf():null}}_getLogId(){return`ContractCreateTransaction:${this._transactionIds.current.validStart.toString()}`}}r.set("contractCreateInstance",d._fromProtobuf);export{d as default};
|
|
2
2
|
//# sourceMappingURL=ContractCreateTransaction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContractCreateTransaction.js","sources":["../../src/contract/ContractCreateTransaction.js"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\nimport Hbar from \"../Hbar.js\";\nimport AccountId from \"../account/AccountId.js\";\nimport FileId from \"../file/FileId.js\";\nimport ContractFunctionParameters from \"./ContractFunctionParameters.js\";\nimport Transaction, {\n DEFAULT_AUTO_RENEW_PERIOD,\n TRANSACTION_REGISTRY,\n} from \"../transaction/Transaction.js\";\nimport Long from \"long\";\nimport Duration from \"../Duration.js\";\nimport Key from \"../Key.js\";\n\n/**\n * @namespace proto\n * @typedef {import(\"@hashgraph/proto\").proto.ITransaction} HieroProto.proto.ITransaction\n * @typedef {import(\"@hashgraph/proto\").proto.ISignedTransaction} HieroProto.proto.ISignedTransaction\n * @typedef {import(\"@hashgraph/proto\").proto.TransactionBody} HieroProto.proto.TransactionBody\n * @typedef {import(\"@hashgraph/proto\").proto.ITransactionBody} HieroProto.proto.ITransactionBody\n * @typedef {import(\"@hashgraph/proto\").proto.ITransactionResponse} HieroProto.proto.ITransactionResponse\n * @typedef {import(\"@hashgraph/proto\").proto.IContractCreateTransactionBody} HieroProto.proto.IContractCreateTransactionBody\n * @typedef {import(\"@hashgraph/proto\").proto.IAccountID} HieroProto.proto.IAccountID\n * @typedef {import(\"@hashgraph/proto\").proto.IFileID} HieroProto.proto.IFileID\n */\n\n/**\n * @typedef {import(\"bignumber.js\").default} BigNumber\n * @typedef {import(\"../channel/Channel.js\").default} Channel\n * @typedef {import(\"../client/Client.js\").default<*, *>} Client\n * @typedef {import(\"../transaction/TransactionId.js\").default} TransactionId\n */\n\n/**\n * Create a new smart contract.\n *\n * If this transaction succeeds, the `ContractID` for the new smart contract\n * SHALL be set in the transaction receipt.<br/>\n * The contract is defined by the initial bytecode (or `initcode`). The\n * `initcode` SHALL be stored either in a previously created file, or in the\n * transaction body itself for very small contracts.\n *\n * As part of contract creation, the constructor defined for the new smart\n * contract SHALL run with the parameters provided in the\n * `constructorParameters` field.<br/>\n * The gas to \"power\" that constructor MUST be provided via the `gas` field,\n * and SHALL be charged to the payer for this transaction.<br/>\n * If the contract _constructor_ stores information, it is charged gas for that\n * storage. There is a separate fee in HBAR to maintain that storage until the\n * expiration, and that fee SHALL be added to this transaction as part of the\n * _transaction fee_, rather than gas.\n *\n */\n\nexport default class ContractCreateTransaction extends Transaction {\n /**\n * @param {object} [props]\n * @param {FileId | string} [props.bytecodeFileId]\n * @param {Uint8Array} [props.bytecode]\n * @param {Key} [props.adminKey]\n * @param {number | Long} [props.gas]\n * @param {number | string | Long | BigNumber | Hbar} [props.initialBalance]\n * @param {AccountId | string} [props.proxyAccountId]\n * @param {Duration | Long | number} [props.autoRenewPeriod]\n * @param {Uint8Array} [props.constructorParameters]\n * @param {string} [props.contractMemo]\n * @param {number} [props.maxAutomaticTokenAssociations]\n * @param {AccountId | string} [props.stakedAccountId]\n * @param {Long | number} [props.stakedNodeId]\n * @param {boolean} [props.declineStakingReward]\n * @param {AccountId} [props.autoRenewAccountId]\n */\n constructor(props = {}) {\n super();\n\n /**\n * @private\n * @type {?FileId}\n */\n this._bytecodeFileId = null;\n\n /**\n * @private\n * @type {?Uint8Array}\n */\n this._bytecode = null;\n\n /**\n * @private\n * @type {?Key}\n */\n this._adminKey = null;\n\n /**\n * @private\n * @type {?Long}\n */\n this._gas = null;\n\n /**\n * @private\n * @type {?Hbar}\n */\n this._initialBalance = null;\n\n /**\n * @private\n * @type {?AccountId}\n */\n this._proxyAccountId = null;\n\n /**\n * @private\n * @type {Duration}\n */\n this._autoRenewPeriod = new Duration(DEFAULT_AUTO_RENEW_PERIOD);\n\n /**\n * @private\n * @type {?Uint8Array}\n */\n this._constructorParameters = null;\n\n /**\n * @private\n * @type {?string}\n */\n this._contractMemo = null;\n\n /**\n * @private\n * @type {?number}\n */\n this._maxAutomaticTokenAssociations = null;\n\n this._defaultMaxTransactionFee = new Hbar(20);\n\n /**\n * @private\n * @type {?AccountId}\n */\n this._stakedAccountId = null;\n\n /**\n * @private\n * @type {?Long}\n */\n this._stakedNodeId = null;\n\n /**\n * @private\n * @type {boolean}\n */\n this._declineStakingReward = false;\n\n /**\n * @type {?AccountId}\n */\n this._autoRenewAccountId = null;\n\n if (props.bytecodeFileId != null) {\n this.setBytecodeFileId(props.bytecodeFileId);\n }\n\n if (props.bytecode != null) {\n this.setBytecode(props.bytecode);\n }\n\n if (props.adminKey != null) {\n this.setAdminKey(props.adminKey);\n }\n\n if (props.gas != null) {\n this.setGas(props.gas);\n }\n\n if (props.initialBalance != null) {\n this.setInitialBalance(props.initialBalance);\n }\n\n if (props.proxyAccountId != null) {\n // eslint-disable-next-line deprecation/deprecation\n this.setProxyAccountId(props.proxyAccountId);\n }\n\n if (props.autoRenewPeriod != null) {\n this.setAutoRenewPeriod(props.autoRenewPeriod);\n }\n\n if (props.constructorParameters != null) {\n this.setConstructorParameters(props.constructorParameters);\n }\n\n if (props.contractMemo != null) {\n this.setContractMemo(props.contractMemo);\n }\n\n if (props.maxAutomaticTokenAssociations != null) {\n this.setMaxAutomaticTokenAssociations(\n props.maxAutomaticTokenAssociations,\n );\n }\n\n if (props.stakedAccountId != null) {\n this.setStakedAccountId(props.stakedAccountId);\n }\n\n if (props.stakedNodeId != null) {\n this.setStakedNodeId(props.stakedNodeId);\n }\n\n if (props.declineStakingReward != null) {\n this.setDeclineStakingReward(props.declineStakingReward);\n }\n\n if (props.autoRenewAccountId != null) {\n this.setAutoRenewAccountId(props.autoRenewAccountId);\n }\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 {ContractCreateTransaction}\n */\n static _fromProtobuf(\n transactions,\n signedTransactions,\n transactionIds,\n nodeIds,\n bodies,\n ) {\n const body = bodies[0];\n const create =\n /** @type {HieroProto.proto.IContractCreateTransactionBody} */ (\n body.contractCreateInstance\n );\n\n return Transaction._fromProtobufTransactions(\n new ContractCreateTransaction({\n bytecodeFileId:\n create.fileID != null\n ? FileId._fromProtobuf(\n /** @type {HieroProto.proto.IFileID} */ (\n create.fileID\n ),\n )\n : undefined,\n adminKey:\n create.adminKey != null\n ? Key._fromProtobufKey(create.adminKey)\n : undefined,\n gas: create.gas != null ? create.gas : undefined,\n initialBalance:\n create.initialBalance != null\n ? Hbar.fromTinybars(create.initialBalance)\n : undefined,\n proxyAccountId:\n create.proxyAccountID != null\n ? AccountId._fromProtobuf(\n /** @type {HieroProto.proto.IAccountID} */ (\n create.proxyAccountID\n ),\n )\n : undefined,\n autoRenewPeriod:\n create.autoRenewPeriod != null\n ? create.autoRenewPeriod.seconds != null\n ? create.autoRenewPeriod.seconds\n : undefined\n : undefined,\n constructorParameters:\n create.constructorParameters != null\n ? create.constructorParameters\n : undefined,\n contractMemo: create.memo != null ? create.memo : undefined,\n maxAutomaticTokenAssociations:\n create.maxAutomaticTokenAssociations != null\n ? create.maxAutomaticTokenAssociations\n : undefined,\n stakedAccountId:\n create.stakedAccountId != null\n ? AccountId._fromProtobuf(create.stakedAccountId)\n : undefined,\n stakedNodeId:\n create.stakedNodeId != null\n ? create.stakedNodeId\n : undefined,\n declineStakingReward: create.declineReward == true,\n autoRenewAccountId:\n create.autoRenewAccountId != null\n ? AccountId._fromProtobuf(create.autoRenewAccountId)\n : undefined,\n }),\n transactions,\n signedTransactions,\n transactionIds,\n nodeIds,\n bodies,\n );\n }\n\n /**\n * @returns {?FileId}\n */\n get bytecodeFileId() {\n return this._bytecodeFileId;\n }\n\n /**\n * @param {FileId | string} bytecodeFileId\n * @returns {this}\n */\n setBytecodeFileId(bytecodeFileId) {\n this._requireNotFrozen();\n this._bytecodeFileId =\n typeof bytecodeFileId === \"string\"\n ? FileId.fromString(bytecodeFileId)\n : bytecodeFileId.clone();\n this._bytecode = null;\n\n return this;\n }\n\n /**\n * @returns {?Uint8Array}\n */\n get bytecode() {\n return this._bytecode;\n }\n\n /**\n * @param {Uint8Array} bytecode\n * @returns {this}\n */\n setBytecode(bytecode) {\n this._requireNotFrozen();\n this._bytecode = bytecode;\n this._bytecodeFileId = null;\n\n return this;\n }\n\n /**\n * @returns {?Key}\n */\n get adminKey() {\n return this._adminKey;\n }\n\n /**\n * @param {Key} adminKey\n * @returns {this}\n */\n setAdminKey(adminKey) {\n this._requireNotFrozen();\n this._adminKey = adminKey;\n\n return this;\n }\n\n /**\n * @returns {?Long}\n */\n get gas() {\n return this._gas;\n }\n\n /**\n * @param {number | Long} gas\n * @returns {this}\n */\n setGas(gas) {\n this._requireNotFrozen();\n this._gas = gas instanceof Long ? gas : Long.fromValue(gas);\n\n return this;\n }\n\n /**\n * @returns {?Hbar}\n */\n get initialBalance() {\n return this._initialBalance;\n }\n\n /**\n * Set the initial amount to transfer into this contract.\n *\n * @param {number | string | Long | BigNumber | Hbar} initialBalance\n * @returns {this}\n */\n setInitialBalance(initialBalance) {\n this._requireNotFrozen();\n this._initialBalance =\n initialBalance instanceof Hbar\n ? initialBalance\n : new Hbar(initialBalance);\n\n return this;\n }\n\n /**\n * @deprecated\n * @returns {?AccountId}\n */\n get proxyAccountId() {\n return this._proxyAccountId;\n }\n\n /**\n * @deprecated\n * @param {AccountId | string} proxyAccountId\n * @returns {this}\n */\n setProxyAccountId(proxyAccountId) {\n this._requireNotFrozen();\n this._proxyAccountId =\n proxyAccountId instanceof AccountId\n ? proxyAccountId\n : AccountId.fromString(proxyAccountId);\n\n return this;\n }\n\n /**\n * @returns {Duration}\n */\n get autoRenewPeriod() {\n return this._autoRenewPeriod;\n }\n\n /**\n * An account to charge for auto-renewal of this contract. If not set, or set to an\n * account with zero hbar balance, the contract's own hbar balance will be used to\n * cover auto-renewal fees.\n *\n * @param {Duration | Long | number} autoRenewPeriod\n * @returns {this}\n */\n setAutoRenewPeriod(autoRenewPeriod) {\n this._requireNotFrozen();\n this._autoRenewPeriod =\n autoRenewPeriod instanceof Duration\n ? autoRenewPeriod\n : new Duration(autoRenewPeriod);\n\n return this;\n }\n\n /**\n * @returns {?Uint8Array}\n */\n get constructorParameters() {\n return this._constructorParameters;\n }\n\n /**\n * @param {Uint8Array | ContractFunctionParameters} constructorParameters\n * @returns {this}\n */\n setConstructorParameters(constructorParameters) {\n this._requireNotFrozen();\n this._constructorParameters =\n constructorParameters instanceof ContractFunctionParameters\n ? constructorParameters._build()\n : constructorParameters;\n\n return this;\n }\n\n /**\n * @returns {?string}\n */\n get contractMemo() {\n return this._contractMemo;\n }\n\n /**\n * @param {string} contractMemo\n * @returns {this}\n */\n setContractMemo(contractMemo) {\n this._requireNotFrozen();\n this._contractMemo = contractMemo;\n\n return this;\n }\n\n /**\n * @returns {?number}\n */\n get maxAutomaticTokenAssociations() {\n return this._maxAutomaticTokenAssociations;\n }\n\n /**\n * @param {number} maxAutomaticTokenAssociations\n * @returns {this}\n */\n setMaxAutomaticTokenAssociations(maxAutomaticTokenAssociations) {\n this._maxAutomaticTokenAssociations = maxAutomaticTokenAssociations;\n\n return this;\n }\n\n /**\n * @returns {?AccountId}\n */\n get stakedAccountId() {\n return this._stakedAccountId;\n }\n\n /**\n * @param {AccountId | string} stakedAccountId\n * @returns {this}\n */\n setStakedAccountId(stakedAccountId) {\n this._requireNotFrozen();\n this._stakedAccountId =\n typeof stakedAccountId === \"string\"\n ? AccountId.fromString(stakedAccountId)\n : stakedAccountId;\n\n return this;\n }\n\n /**\n * @returns {?Long}\n */\n get stakedNodeId() {\n return this._stakedNodeId;\n }\n\n /**\n * @param {Long | number} stakedNodeId\n * @returns {this}\n */\n setStakedNodeId(stakedNodeId) {\n this._requireNotFrozen();\n this._stakedNodeId = Long.fromValue(stakedNodeId);\n\n return this;\n }\n\n /**\n * @returns {boolean}\n */\n get declineStakingRewards() {\n return this._declineStakingReward;\n }\n\n /**\n * @param {boolean} declineStakingReward\n * @returns {this}\n */\n setDeclineStakingReward(declineStakingReward) {\n this._requireNotFrozen();\n this._declineStakingReward = declineStakingReward;\n\n return this;\n }\n\n /**\n * @returns {?AccountId}\n */\n get autoRenewAccountId() {\n return this._autoRenewAccountId;\n }\n\n /**\n * @param {string | AccountId} autoRenewAccountId\n * @returns {this}\n */\n setAutoRenewAccountId(autoRenewAccountId) {\n this._requireNotFrozen();\n this._autoRenewAccountId =\n typeof autoRenewAccountId === \"string\"\n ? AccountId.fromString(autoRenewAccountId)\n : autoRenewAccountId;\n\n return this;\n }\n\n /**\n * @param {Client} client\n */\n _validateChecksums(client) {\n if (this._bytecodeFileId != null) {\n this._bytecodeFileId.validateChecksum(client);\n }\n\n if (this._proxyAccountId != null) {\n this._proxyAccountId.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.smartContract.createContract(request);\n }\n\n /**\n * @override\n * @protected\n * @returns {NonNullable<HieroProto.proto.TransactionBody[\"data\"]>}\n */\n _getTransactionDataCase() {\n return \"contractCreateInstance\";\n }\n\n /**\n * @override\n * @protected\n * @returns {HieroProto.proto.IContractCreateTransactionBody}\n */\n _makeTransactionData() {\n return {\n fileID:\n this._bytecodeFileId != null\n ? this._bytecodeFileId._toProtobuf()\n : null,\n initcode: this._bytecode,\n adminKey:\n this._adminKey != null ? this._adminKey._toProtobufKey() : null,\n gas: this._gas,\n initialBalance:\n this._initialBalance != null\n ? this._initialBalance.toTinybars()\n : null,\n proxyAccountID:\n this._proxyAccountId != null\n ? this._proxyAccountId._toProtobuf()\n : null,\n autoRenewPeriod: this._autoRenewPeriod._toProtobuf(),\n constructorParameters: this._constructorParameters,\n memo: this._contractMemo,\n maxAutomaticTokenAssociations: this._maxAutomaticTokenAssociations,\n stakedAccountId:\n this.stakedAccountId != null\n ? this.stakedAccountId._toProtobuf()\n : null,\n stakedNodeId: this.stakedNodeId,\n declineReward: this.declineStakingRewards,\n autoRenewAccountId:\n this._autoRenewAccountId != null\n ? this._autoRenewAccountId._toProtobuf()\n : null,\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 `ContractCreateTransaction:${timestamp.toString()}`;\n }\n}\n\nTRANSACTION_REGISTRY.set(\n \"contractCreateInstance\",\n // eslint-disable-next-line @typescript-eslint/unbound-method\n ContractCreateTransaction._fromProtobuf,\n);\n"],"names":["ContractCreateTransaction","Transaction","constructor","props","super","this","_bytecodeFileId","_bytecode","_adminKey","_gas","_initialBalance","_proxyAccountId","_autoRenewPeriod","Duration","DEFAULT_AUTO_RENEW_PERIOD","_constructorParameters","_contractMemo","_maxAutomaticTokenAssociations","_defaultMaxTransactionFee","Hbar","_stakedAccountId","_stakedNodeId","_declineStakingReward","_autoRenewAccountId","bytecodeFileId","setBytecodeFileId","bytecode","setBytecode","adminKey","setAdminKey","gas","setGas","initialBalance","setInitialBalance","proxyAccountId","setProxyAccountId","autoRenewPeriod","setAutoRenewPeriod","constructorParameters","setConstructorParameters","contractMemo","setContractMemo","maxAutomaticTokenAssociations","setMaxAutomaticTokenAssociations","stakedAccountId","setStakedAccountId","stakedNodeId","setStakedNodeId","declineStakingReward","setDeclineStakingReward","autoRenewAccountId","setAutoRenewAccountId","_fromProtobuf","transactions","signedTransactions","transactionIds","nodeIds","bodies","create","_fromProtobufTransactions","fileID","FileId","undefined","Key","_fromProtobufKey","fromTinybars","proxyAccountID","AccountId","seconds","memo","declineReward","_requireNotFrozen","fromString","clone","Long","fromValue","ContractFunctionParameters","_build","declineStakingRewards","_validateChecksums","client","validateChecksum","_execute","channel","request","smartContract","createContract","_getTransactionDataCase","_makeTransactionData","_toProtobuf","initcode","_toProtobufKey","toTinybars","_getLogId","_transactionIds","current","toString","TRANSACTION_REG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ACCL,KAAKK,gBAAgBkF,aACrB,KACV1B,eAC4B,MAAxB7D,KAAKM,gBACCN,KAAKM,gBAAgB8E,cACrB,KACVrD,gBAAiB/B,KAAKO,iBAAiB6E,cACvCnD,sBAAuBjC,KAAKU,uBAC5BsD,KAAMhE,KAAKW,cACX0B,8BAA+BrC,KAAKY,+BACpC2B,gBAC4B,MAAxBvC,KAAKuC,gBACCvC,KAAKuC,gBAAgB6C,cACrB,KACV3C,aAAczC,KAAKyC,aACnBwB,cAAejE,KAAKyE,sBACpB5B,mBACgC,MAA5B7C,KAAKkB,oBACClB,KAAKkB,oBAAoBkE,cACzB,KAEtB,CAKI,SAAAI,GAII,MAAO,6BAFHxF,KAAKyF,gBAAgBC,QACxB,WAC6CC,YACtD,EAGAC,EAAqBC,IACjB,yBAEAlG,EAA0BoD"}
|
|
1
|
+
{"version":3,"file":"ContractCreateTransaction.js","sources":["../../src/contract/ContractCreateTransaction.js"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\nimport Hbar from \"../Hbar.js\";\nimport AccountId from \"../account/AccountId.js\";\nimport FileId from \"../file/FileId.js\";\nimport ContractFunctionParameters from \"./ContractFunctionParameters.js\";\nimport Transaction, {\n DEFAULT_AUTO_RENEW_PERIOD,\n TRANSACTION_REGISTRY,\n} from \"../transaction/Transaction.js\";\nimport Long from \"long\";\nimport Duration from \"../Duration.js\";\nimport Key from \"../Key.js\";\n\n/**\n * @namespace proto\n * @typedef {import(\"@hashgraph/proto\").proto.ITransaction} HieroProto.proto.ITransaction\n * @typedef {import(\"@hashgraph/proto\").proto.ISignedTransaction} HieroProto.proto.ISignedTransaction\n * @typedef {import(\"@hashgraph/proto\").proto.TransactionBody} HieroProto.proto.TransactionBody\n * @typedef {import(\"@hashgraph/proto\").proto.ITransactionBody} HieroProto.proto.ITransactionBody\n * @typedef {import(\"@hashgraph/proto\").proto.ITransactionResponse} HieroProto.proto.ITransactionResponse\n * @typedef {import(\"@hashgraph/proto\").proto.IContractCreateTransactionBody} HieroProto.proto.IContractCreateTransactionBody\n * @typedef {import(\"@hashgraph/proto\").proto.IAccountID} HieroProto.proto.IAccountID\n * @typedef {import(\"@hashgraph/proto\").proto.IFileID} HieroProto.proto.IFileID\n */\n\n/**\n * @typedef {import(\"bignumber.js\").default} BigNumber\n * @typedef {import(\"../channel/Channel.js\").default} Channel\n * @typedef {import(\"../client/Client.js\").default<*, *>} Client\n * @typedef {import(\"../transaction/TransactionId.js\").default} TransactionId\n */\n\n/**\n * Create a new smart contract.\n *\n * If this transaction succeeds, the `ContractID` for the new smart contract\n * SHALL be set in the transaction receipt.<br/>\n * The contract is defined by the initial bytecode (or `initcode`). The\n * `initcode` SHALL be stored either in a previously created file, or in the\n * transaction body itself for very small contracts.\n *\n * As part of contract creation, the constructor defined for the new smart\n * contract SHALL run with the parameters provided in the\n * `constructorParameters` field.<br/>\n * The gas to \"power\" that constructor MUST be provided via the `gas` field,\n * and SHALL be charged to the payer for this transaction.<br/>\n * If the contract _constructor_ stores information, it is charged gas for that\n * storage. There is a separate fee in HBAR to maintain that storage until the\n * expiration, and that fee SHALL be added to this transaction as part of the\n * _transaction fee_, rather than gas.\n *\n */\n\nexport default class ContractCreateTransaction extends Transaction {\n /**\n * @param {object} [props]\n * @param {FileId | string} [props.bytecodeFileId]\n * @param {Uint8Array} [props.bytecode]\n * @param {Key} [props.adminKey]\n * @param {number | Long} [props.gas]\n * @param {number | string | Long | BigNumber | Hbar} [props.initialBalance]\n * @param {AccountId | string} [props.proxyAccountId]\n * @param {Duration | Long | number} [props.autoRenewPeriod]\n * @param {Uint8Array} [props.constructorParameters]\n * @param {string} [props.contractMemo]\n * @param {number} [props.maxAutomaticTokenAssociations]\n * @param {AccountId | string} [props.stakedAccountId]\n * @param {Long | number} [props.stakedNodeId]\n * @param {boolean} [props.declineStakingReward]\n * @param {AccountId} [props.autoRenewAccountId]\n */\n constructor(props = {}) {\n super();\n\n /**\n * @private\n * @type {?FileId}\n */\n this._bytecodeFileId = null;\n\n /**\n * @private\n * @type {?Uint8Array}\n */\n this._bytecode = null;\n\n /**\n * @private\n * @type {?Key}\n */\n this._adminKey = null;\n\n /**\n * @private\n * @type {?Long}\n */\n this._gas = null;\n\n /**\n * @private\n * @type {?Hbar}\n */\n this._initialBalance = null;\n\n /**\n * @private\n * @type {?AccountId}\n */\n this._proxyAccountId = null;\n\n /**\n * @private\n * @type {Duration}\n */\n this._autoRenewPeriod = new Duration(DEFAULT_AUTO_RENEW_PERIOD);\n\n /**\n * @private\n * @type {?Uint8Array}\n */\n this._constructorParameters = null;\n\n /**\n * @private\n * @type {?string}\n */\n this._contractMemo = null;\n\n /**\n * @private\n * @type {?number}\n */\n this._maxAutomaticTokenAssociations = null;\n\n this._defaultMaxTransactionFee = new Hbar(20);\n\n /**\n * @private\n * @type {?AccountId}\n */\n this._stakedAccountId = null;\n\n /**\n * @private\n * @type {?Long}\n */\n this._stakedNodeId = null;\n\n /**\n * @private\n * @type {boolean}\n */\n this._declineStakingReward = false;\n\n /**\n * @type {?AccountId}\n */\n this._autoRenewAccountId = null;\n\n if (props.bytecodeFileId != null) {\n this.setBytecodeFileId(props.bytecodeFileId);\n }\n\n if (props.bytecode != null) {\n this.setBytecode(props.bytecode);\n }\n\n if (props.adminKey != null) {\n this.setAdminKey(props.adminKey);\n }\n\n if (props.gas != null) {\n this.setGas(props.gas);\n }\n\n if (props.initialBalance != null) {\n this.setInitialBalance(props.initialBalance);\n }\n\n if (props.proxyAccountId != null) {\n // eslint-disable-next-line deprecation/deprecation\n this.setProxyAccountId(props.proxyAccountId);\n }\n\n if (props.autoRenewPeriod != null) {\n this.setAutoRenewPeriod(props.autoRenewPeriod);\n }\n\n if (props.constructorParameters != null) {\n this.setConstructorParameters(props.constructorParameters);\n }\n\n if (props.contractMemo != null) {\n this.setContractMemo(props.contractMemo);\n }\n\n if (props.maxAutomaticTokenAssociations != null) {\n this.setMaxAutomaticTokenAssociations(\n props.maxAutomaticTokenAssociations,\n );\n }\n\n if (props.stakedAccountId != null) {\n this.setStakedAccountId(props.stakedAccountId);\n }\n\n if (props.stakedNodeId != null) {\n this.setStakedNodeId(props.stakedNodeId);\n }\n\n if (props.declineStakingReward != null) {\n this.setDeclineStakingReward(props.declineStakingReward);\n }\n\n if (props.autoRenewAccountId != null) {\n this.setAutoRenewAccountId(props.autoRenewAccountId);\n }\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 {ContractCreateTransaction}\n */\n static _fromProtobuf(\n transactions,\n signedTransactions,\n transactionIds,\n nodeIds,\n bodies,\n ) {\n const body = bodies[0];\n const create =\n /** @type {HieroProto.proto.IContractCreateTransactionBody} */ (\n body.contractCreateInstance\n );\n\n return Transaction._fromProtobufTransactions(\n new ContractCreateTransaction({\n bytecodeFileId:\n create.fileID != null\n ? FileId._fromProtobuf(\n /** @type {HieroProto.proto.IFileID} */ (\n create.fileID\n ),\n )\n : undefined,\n adminKey:\n create.adminKey != null\n ? Key._fromProtobufKey(create.adminKey)\n : undefined,\n gas: create.gas != null ? create.gas : undefined,\n initialBalance:\n create.initialBalance != null\n ? Hbar.fromTinybars(create.initialBalance)\n : undefined,\n proxyAccountId:\n create.proxyAccountID != null\n ? AccountId._fromProtobuf(\n /** @type {HieroProto.proto.IAccountID} */ (\n create.proxyAccountID\n ),\n )\n : undefined,\n autoRenewPeriod:\n create.autoRenewPeriod != null\n ? create.autoRenewPeriod.seconds != null\n ? create.autoRenewPeriod.seconds\n : undefined\n : undefined,\n constructorParameters:\n create.constructorParameters != null\n ? create.constructorParameters\n : undefined,\n contractMemo: create.memo != null ? create.memo : undefined,\n maxAutomaticTokenAssociations:\n create.maxAutomaticTokenAssociations != null\n ? create.maxAutomaticTokenAssociations\n : undefined,\n stakedAccountId:\n create.stakedAccountId != null\n ? AccountId._fromProtobuf(create.stakedAccountId)\n : undefined,\n stakedNodeId:\n create.stakedNodeId != null\n ? create.stakedNodeId\n : undefined,\n declineStakingReward: create.declineReward == true,\n autoRenewAccountId:\n create.autoRenewAccountId != null\n ? AccountId._fromProtobuf(create.autoRenewAccountId)\n : undefined,\n }),\n transactions,\n signedTransactions,\n transactionIds,\n nodeIds,\n bodies,\n );\n }\n\n /**\n * @returns {?FileId}\n */\n get bytecodeFileId() {\n return this._bytecodeFileId;\n }\n\n /**\n * @param {FileId | string} bytecodeFileId\n * @returns {this}\n */\n setBytecodeFileId(bytecodeFileId) {\n this._requireNotFrozen();\n this._bytecodeFileId =\n typeof bytecodeFileId === \"string\"\n ? FileId.fromString(bytecodeFileId)\n : bytecodeFileId.clone();\n this._bytecode = null;\n\n return this;\n }\n\n /**\n * @returns {?Uint8Array}\n */\n get bytecode() {\n return this._bytecode;\n }\n\n /**\n * @param {Uint8Array} bytecode\n * @returns {this}\n */\n setBytecode(bytecode) {\n this._requireNotFrozen();\n this._bytecode = bytecode;\n this._bytecodeFileId = null;\n\n return this;\n }\n\n /**\n * @returns {?Key}\n */\n get adminKey() {\n return this._adminKey;\n }\n\n /**\n * @param {Key} adminKey\n * @returns {this}\n */\n setAdminKey(adminKey) {\n this._requireNotFrozen();\n this._adminKey = adminKey;\n\n return this;\n }\n\n /**\n * @returns {?Long}\n */\n get gas() {\n return this._gas;\n }\n\n /**\n * @param {number | Long} gas\n * @returns {this}\n */\n setGas(gas) {\n this._requireNotFrozen();\n this._gas = gas instanceof Long ? gas : Long.fromValue(gas);\n if (this._gas.lessThan(0)) {\n throw new Error(\"Gas cannot be negative number\");\n }\n return this;\n }\n\n /**\n * @returns {?Hbar}\n */\n get initialBalance() {\n return this._initialBalance;\n }\n\n /**\n * Set the initial amount to transfer into this contract.\n *\n * @param {number | string | Long | BigNumber | Hbar} initialBalance\n * @returns {this}\n */\n setInitialBalance(initialBalance) {\n this._requireNotFrozen();\n this._initialBalance =\n initialBalance instanceof Hbar\n ? initialBalance\n : new Hbar(initialBalance);\n\n return this;\n }\n\n /**\n * @deprecated\n * @returns {?AccountId}\n */\n get proxyAccountId() {\n return this._proxyAccountId;\n }\n\n /**\n * @deprecated\n * @param {AccountId | string} proxyAccountId\n * @returns {this}\n */\n setProxyAccountId(proxyAccountId) {\n this._requireNotFrozen();\n this._proxyAccountId =\n proxyAccountId instanceof AccountId\n ? proxyAccountId\n : AccountId.fromString(proxyAccountId);\n\n return this;\n }\n\n /**\n * @returns {Duration}\n */\n get autoRenewPeriod() {\n return this._autoRenewPeriod;\n }\n\n /**\n * An account to charge for auto-renewal of this contract. If not set, or set to an\n * account with zero hbar balance, the contract's own hbar balance will be used to\n * cover auto-renewal fees.\n *\n * @param {Duration | Long | number} autoRenewPeriod\n * @returns {this}\n */\n setAutoRenewPeriod(autoRenewPeriod) {\n this._requireNotFrozen();\n this._autoRenewPeriod =\n autoRenewPeriod instanceof Duration\n ? autoRenewPeriod\n : new Duration(autoRenewPeriod);\n\n return this;\n }\n\n /**\n * @returns {?Uint8Array}\n */\n get constructorParameters() {\n return this._constructorParameters;\n }\n\n /**\n * @param {Uint8Array | ContractFunctionParameters} constructorParameters\n * @returns {this}\n */\n setConstructorParameters(constructorParameters) {\n this._requireNotFrozen();\n this._constructorParameters =\n constructorParameters instanceof ContractFunctionParameters\n ? constructorParameters._build()\n : constructorParameters;\n\n return this;\n }\n\n /**\n * @returns {?string}\n */\n get contractMemo() {\n return this._contractMemo;\n }\n\n /**\n * @param {string} contractMemo\n * @returns {this}\n */\n setContractMemo(contractMemo) {\n this._requireNotFrozen();\n this._contractMemo = contractMemo;\n\n return this;\n }\n\n /**\n * @returns {?number}\n */\n get maxAutomaticTokenAssociations() {\n return this._maxAutomaticTokenAssociations;\n }\n\n /**\n * @param {number} maxAutomaticTokenAssociations\n * @returns {this}\n */\n setMaxAutomaticTokenAssociations(maxAutomaticTokenAssociations) {\n this._maxAutomaticTokenAssociations = maxAutomaticTokenAssociations;\n\n return this;\n }\n\n /**\n * @returns {?AccountId}\n */\n get stakedAccountId() {\n return this._stakedAccountId;\n }\n\n /**\n * @param {AccountId | string} stakedAccountId\n * @returns {this}\n */\n setStakedAccountId(stakedAccountId) {\n this._requireNotFrozen();\n this._stakedAccountId =\n typeof stakedAccountId === \"string\"\n ? AccountId.fromString(stakedAccountId)\n : stakedAccountId;\n this._stakedNodeId = null;\n return this;\n }\n\n /**\n * @returns {?Long}\n */\n get stakedNodeId() {\n return this._stakedNodeId;\n }\n\n /**\n * @param {Long | number} stakedNodeId\n * @returns {this}\n */\n setStakedNodeId(stakedNodeId) {\n this._requireNotFrozen();\n this._stakedNodeId = Long.fromValue(stakedNodeId);\n this._stakedAccountId = null;\n return this;\n }\n\n /**\n * @returns {boolean}\n */\n get declineStakingRewards() {\n return this._declineStakingReward;\n }\n\n /**\n * @param {boolean} declineStakingReward\n * @returns {this}\n */\n setDeclineStakingReward(declineStakingReward) {\n this._requireNotFrozen();\n this._declineStakingReward = declineStakingReward;\n\n return this;\n }\n\n /**\n * @returns {?AccountId}\n */\n get autoRenewAccountId() {\n return this._autoRenewAccountId;\n }\n\n /**\n * @param {string | AccountId} autoRenewAccountId\n * @returns {this}\n */\n setAutoRenewAccountId(autoRenewAccountId) {\n this._requireNotFrozen();\n this._autoRenewAccountId =\n typeof autoRenewAccountId === \"string\"\n ? AccountId.fromString(autoRenewAccountId)\n : autoRenewAccountId;\n\n return this;\n }\n\n /**\n * @param {Client} client\n */\n _validateChecksums(client) {\n if (this._bytecodeFileId != null) {\n this._bytecodeFileId.validateChecksum(client);\n }\n\n if (this._proxyAccountId != null) {\n this._proxyAccountId.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.smartContract.createContract(request);\n }\n\n /**\n * @override\n * @protected\n * @returns {NonNullable<HieroProto.proto.TransactionBody[\"data\"]>}\n */\n _getTransactionDataCase() {\n return \"contractCreateInstance\";\n }\n\n /**\n * @override\n * @protected\n * @returns {HieroProto.proto.IContractCreateTransactionBody}\n */\n _makeTransactionData() {\n return {\n fileID:\n this._bytecodeFileId != null\n ? this._bytecodeFileId._toProtobuf()\n : null,\n initcode: this._bytecode,\n adminKey:\n this._adminKey != null ? this._adminKey._toProtobufKey() : null,\n gas: this._gas,\n initialBalance:\n this._initialBalance != null\n ? this._initialBalance.toTinybars()\n : null,\n proxyAccountID:\n this._proxyAccountId != null\n ? this._proxyAccountId._toProtobuf()\n : null,\n autoRenewPeriod: this._autoRenewPeriod._toProtobuf(),\n constructorParameters: this._constructorParameters,\n memo: this._contractMemo,\n maxAutomaticTokenAssociations: this._maxAutomaticTokenAssociations,\n stakedAccountId:\n this.stakedAccountId != null\n ? this.stakedAccountId._toProtobuf()\n : null,\n stakedNodeId: this.stakedNodeId,\n declineReward: this.declineStakingRewards,\n autoRenewAccountId:\n this._autoRenewAccountId != null\n ? this._autoRenewAccountId._toProtobuf()\n : null,\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 `ContractCreateTransaction:${timestamp.toString()}`;\n }\n}\n\nTRANSACTION_REGISTRY.set(\n \"contractCreateInstance\",\n // eslint-disable-next-line @typescript-eslint/unbound-method\n ContractCreateTransaction._fromProtobuf,\n);\n"],"names":["ContractCreateTransaction","Transaction","constructor","props","super","this","_bytecodeFileId","_bytecode","_adminKey","_gas","_initialBalance","_proxyAccountId","_autoRenewPeriod","Duration","DEFAULT_AUTO_RENEW_PERIOD","_constructorParameters","_contractMemo","_maxAutomaticTokenAssociations","_defaultMaxTransactionFee","Hbar","_stakedAccountId","_stakedNodeId","_declineStakingReward","_autoRenewAccountId","bytecodeFileId","setBytecodeFileId","bytecode","setBytecode","adminKey","setAdminKey","gas","setGas","initialBalance","setInitialBalance","proxyAccountId","setProxyAccountId","autoRenewPeriod","setAutoRenewPeriod","constructorParameters","setConstructorParameters","contractMemo","setContractMemo","maxAutomaticTokenAssociations","setMaxAutomaticTokenAssociations","stakedAccountId","setStakedAccountId","stakedNodeId","setStakedNodeId","declineStakingReward","setDeclineStakingReward","autoRenewAccountId","setAutoRenewAccountId","_fromProtobuf","transactions","signedTransactions","transactionIds","nodeIds","bodies","create","_fromProtobufTransactions","fileID","FileId","undefined","Key","_fromProtobufKey","fromTinybars","proxyAccountID","AccountId","seconds","memo","declineReward","_requireNotFrozen","fromString","clone","Long","fromValue","lessThan","Error","ContractFunctionParameters","_build","declineStakingRewards","_validateChecksums","client","validateChecksum","_execute","channel","request","smartContract","createContract","_getTransactionDataCase","_makeTransactionData","_toProtobuf","initcode","_toProtobufKey","toTinybars","_getLogId","_transactionIds","current","toString","TRANSACTION_REGISTRY","set"],"mappings":"mUAsDe,MAAMA,UAAkCC,EAkBnD,WAAAC,CAAYC,EAAQ,IAChBC,QAMAC,KAAKC,gBAAkB,KAMvBD,KAAKE,UAAY,KAMjBF,KAAKG,UAAY,KAMjBH,KAAKI,KAAO,KAMZJ,KAAKK,gBAAkB,KAMvBL,KAAKM,gBAAkB,KAMvBN,KAAKO,iBAAmB,IAAIC,EAASC,GAMrCT,KAAKU,uBAAyB,KAM9BV,KAAKW,cAAgB,KAMrBX,KAAKY,+BAAiC,KAEtCZ,KAAKa,0BAA4B,IAAIC,EAAK,IAM1Cd,KAAKe,iBAAmB,KAMxBf,KAAKgB,cAAgB,KAMrBhB,KAAKiB,uBAAwB,EAK7BjB,KAAKkB,oBAAsB,KAEC,MAAxBpB,EAAMqB,gBACNnB,KAAKoB,kBAAkBtB,EAAMqB,gBAGX,MAAlBrB,EAAMuB,UACNrB,KAAKsB,YAAYxB,EAAMuB,UAGL,MAAlBvB,EAAMyB,UACNvB,KAAKwB,YAAY1B,EAAMyB,UAGV,MAAbzB,EAAM2B,KACNzB,KAAK0B,OAAO5B,EAAM2B,KAGM,MAAxB3B,EAAM6B,gBACN3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,KAAKkB,mBACpB,CAMI,qBAAA4B,CAAsBD,GAOlB,OANA7C,KAAKkE,oBACLlE,KAAKkB,oBAC6B,iBAAvB2B,EACDiB,EAAUK,WAAWtB,GACrBA,EAEH7C,IACf,CAKI,kBAAA4E,CAAmBC,GACa,MAAxB7E,KAAKC,iBACLD,KAAKC,gBAAgB6E,iBAAiBD,GAGd,MAAxB7E,KAAKM,iBACLN,KAAKM,gBAAgBwE,iBAAiBD,EAElD,CASI,QAAAE,CAASC,EAASC,GACd,OAAOD,EAAQE,cAAcC,eAAeF,EACpD,CAOI,uBAAAG,GACI,MAAO,wBACf,CAOI,oBAAAC,GACI,MAAO,CACH9B,OAC4B,MAAxBvD,KAAKC,gBACCD,KAAKC,gBAAgBqF,cACrB,KACVC,SAAUvF,KAAKE,UACfqB,SACsB,MAAlBvB,KAAKG,UAAoBH,KAAKG,UAAUqF,iBAAmB,KAC/D/D,IAAKzB,KAAKI,KACVuB,eAC4B,MAAxB3B,KAAKK,gBACCL,KAAKK,gBAAgBoF,aACrB,KACV5B,eAC4B,MAAxB7D,KAAKM,gBACCN,KAAKM,gBAAgBgF,cACrB,KACVvD,gBAAiB/B,KAAKO,iBAAiB+E,cACvCrD,sBAAuBjC,KAAKU,uBAC5BsD,KAAMhE,KAAKW,cACX0B,8BAA+BrC,KAAKY,+BACpC2B,gBAC4B,MAAxBvC,KAAKuC,gBACCvC,KAAKuC,gBAAgB+C,cACrB,KACV7C,aAAczC,KAAKyC,aACnBwB,cAAejE,KAAK2E,sBACpB9B,mBACgC,MAA5B7C,KAAKkB,oBACClB,KAAKkB,oBAAoBoE,cACzB,KAEtB,CAKI,SAAAI,GAII,MAAO,6BAFH1F,KAAK2F,gBAAgBC,QACxB,WAC6CC,YACtD,EAGAC,EAAqBC,IACjB,yBAEApG,EAA0BoD"}
|
|
@@ -60,6 +60,7 @@ class ContractDeleteTransaction extends _Transaction.default {
|
|
|
60
60
|
* @param {ContractId | string} [props.contractId]
|
|
61
61
|
* @param {ContractId | string} [props.transferContractId]
|
|
62
62
|
* @param {AccountId | string} [props.transferAccountId]
|
|
63
|
+
* @param {boolean} [props.permanentRemoval]
|
|
63
64
|
*/
|
|
64
65
|
constructor(props = {}) {
|
|
65
66
|
super();
|
|
@@ -81,6 +82,12 @@ class ContractDeleteTransaction extends _Transaction.default {
|
|
|
81
82
|
* @type {?ContractId}
|
|
82
83
|
*/
|
|
83
84
|
this._transferContractId = null;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* @private
|
|
88
|
+
* @type {boolean}
|
|
89
|
+
*/
|
|
90
|
+
this._permanentRemoval = false;
|
|
84
91
|
if (props.contractId != null) {
|
|
85
92
|
this.setContractId(props.contractId);
|
|
86
93
|
}
|
|
@@ -90,6 +97,9 @@ class ContractDeleteTransaction extends _Transaction.default {
|
|
|
90
97
|
if (props.transferContractId != null) {
|
|
91
98
|
this.setTransferContractId(props.transferContractId);
|
|
92
99
|
}
|
|
100
|
+
if (props.permanentRemoval != null) {
|
|
101
|
+
this.setPermanentRemoval(props.permanentRemoval);
|
|
102
|
+
}
|
|
93
103
|
}
|
|
94
104
|
|
|
95
105
|
/**
|
|
@@ -111,7 +121,8 @@ class ContractDeleteTransaction extends _Transaction.default {
|
|
|
111
121
|
transferAccountId: contractDelete.transferAccountID != null ? _AccountId.default._fromProtobuf(/** @type {HieroProto.proto.IAccountID} */
|
|
112
122
|
contractDelete.transferAccountID) : undefined,
|
|
113
123
|
transferContractId: contractDelete.transferContractID != null ? _ContractId.default._fromProtobuf(/** @type {HieroProto.proto.IContractID} */
|
|
114
|
-
contractDelete.transferContractID) : undefined
|
|
124
|
+
contractDelete.transferContractID) : undefined,
|
|
125
|
+
permanentRemoval: contractDelete.permanentRemoval ?? false
|
|
115
126
|
}), transactions, signedTransactions, transactionIds, nodeIds, bodies);
|
|
116
127
|
}
|
|
117
128
|
|
|
@@ -150,6 +161,7 @@ class ContractDeleteTransaction extends _Transaction.default {
|
|
|
150
161
|
setTransferContractId(transferContractId) {
|
|
151
162
|
this._requireNotFrozen();
|
|
152
163
|
this._transferContractId = transferContractId instanceof _ContractId.default ? transferContractId : _ContractId.default.fromString(transferContractId);
|
|
164
|
+
this._transferAccountId = null;
|
|
153
165
|
return this;
|
|
154
166
|
}
|
|
155
167
|
|
|
@@ -169,6 +181,26 @@ class ContractDeleteTransaction extends _Transaction.default {
|
|
|
169
181
|
setTransferAccountId(transferAccountId) {
|
|
170
182
|
this._requireNotFrozen();
|
|
171
183
|
this._transferAccountId = transferAccountId instanceof _AccountId.default ? transferAccountId : _AccountId.default.fromString(transferAccountId);
|
|
184
|
+
this._transferContractId = null;
|
|
185
|
+
return this;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* @returns {boolean}
|
|
190
|
+
*/
|
|
191
|
+
get permanentRemoval() {
|
|
192
|
+
return this._permanentRemoval;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Sets the permanent removal flag.
|
|
197
|
+
*
|
|
198
|
+
* @param {boolean} permanentRemoval
|
|
199
|
+
* @returns {ContractDeleteTransaction}
|
|
200
|
+
*/
|
|
201
|
+
setPermanentRemoval(permanentRemoval) {
|
|
202
|
+
this._requireNotFrozen();
|
|
203
|
+
this._permanentRemoval = permanentRemoval;
|
|
172
204
|
return this;
|
|
173
205
|
}
|
|
174
206
|
|
|
@@ -216,7 +248,8 @@ class ContractDeleteTransaction extends _Transaction.default {
|
|
|
216
248
|
return {
|
|
217
249
|
contractID: this._contractId != null ? this._contractId._toProtobuf() : null,
|
|
218
250
|
transferAccountID: this._transferAccountId ? this._transferAccountId._toProtobuf() : null,
|
|
219
|
-
transferContractID: this._transferContractId != null ? this._transferContractId._toProtobuf() : null
|
|
251
|
+
transferContractID: this._transferContractId != null ? this._transferContractId._toProtobuf() : null,
|
|
252
|
+
permanentRemoval: this._permanentRemoval
|
|
220
253
|
};
|
|
221
254
|
}
|
|
222
255
|
|
|
@@ -54,11 +54,13 @@ export default class ContractDeleteTransaction extends Transaction {
|
|
|
54
54
|
* @param {ContractId | string} [props.contractId]
|
|
55
55
|
* @param {ContractId | string} [props.transferContractId]
|
|
56
56
|
* @param {AccountId | string} [props.transferAccountId]
|
|
57
|
+
* @param {boolean} [props.permanentRemoval]
|
|
57
58
|
*/
|
|
58
59
|
constructor(props?: {
|
|
59
60
|
contractId?: string | ContractId | undefined;
|
|
60
61
|
transferContractId?: string | ContractId | undefined;
|
|
61
62
|
transferAccountId?: string | AccountId | undefined;
|
|
63
|
+
permanentRemoval?: boolean | undefined;
|
|
62
64
|
});
|
|
63
65
|
/**
|
|
64
66
|
* @private
|
|
@@ -75,6 +77,11 @@ export default class ContractDeleteTransaction extends Transaction {
|
|
|
75
77
|
* @type {?ContractId}
|
|
76
78
|
*/
|
|
77
79
|
private _transferContractId;
|
|
80
|
+
/**
|
|
81
|
+
* @private
|
|
82
|
+
* @type {boolean}
|
|
83
|
+
*/
|
|
84
|
+
private _permanentRemoval;
|
|
78
85
|
/**
|
|
79
86
|
* @returns {?ContractId}
|
|
80
87
|
*/
|
|
@@ -108,6 +115,17 @@ export default class ContractDeleteTransaction extends Transaction {
|
|
|
108
115
|
* @returns {ContractDeleteTransaction}
|
|
109
116
|
*/
|
|
110
117
|
setTransferAccountId(transferAccountId: AccountId | string): ContractDeleteTransaction;
|
|
118
|
+
/**
|
|
119
|
+
* @returns {boolean}
|
|
120
|
+
*/
|
|
121
|
+
get permanentRemoval(): boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Sets the permanent removal flag.
|
|
124
|
+
*
|
|
125
|
+
* @param {boolean} permanentRemoval
|
|
126
|
+
* @returns {ContractDeleteTransaction}
|
|
127
|
+
*/
|
|
128
|
+
setPermanentRemoval(permanentRemoval: boolean): ContractDeleteTransaction;
|
|
111
129
|
/**
|
|
112
130
|
* @override
|
|
113
131
|
* @protected
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import t,{TRANSACTION_REGISTRY as r}from"../transaction/Transaction.js";import n from"./ContractId.js";import
|
|
1
|
+
import t,{TRANSACTION_REGISTRY as r}from"../transaction/Transaction.js";import n from"./ContractId.js";import e from"../account/AccountId.js";class a extends t{constructor(t={}){super(),this._contractId=null,this._transferAccountId=null,this._transferContractId=null,this._permanentRemoval=!1,null!=t.contractId&&this.setContractId(t.contractId),null!=t.transferAccountId&&this.setTransferAccountId(t.transferAccountId),null!=t.transferContractId&&this.setTransferContractId(t.transferContractId),null!=t.permanentRemoval&&this.setPermanentRemoval(t.permanentRemoval)}static _fromProtobuf(r,o,c,s,u){const i=u[0].contractDeleteInstance;return t._fromProtobufTransactions(new a({contractId:null!=i.contractID?n._fromProtobuf(i.contractID):void 0,transferAccountId:null!=i.transferAccountID?e._fromProtobuf(i.transferAccountID):void 0,transferContractId:null!=i.transferContractID?n._fromProtobuf(i.transferContractID):void 0,permanentRemoval:i.permanentRemoval??!1}),r,o,c,s,u)}get contractId(){return this._contractId}setContractId(t){return this._requireNotFrozen(),this._contractId="string"==typeof t?n.fromString(t):t.clone(),this}get transferContractId(){return this._transferContractId}setTransferContractId(t){return this._requireNotFrozen(),this._transferContractId=t instanceof n?t:n.fromString(t),this._transferAccountId=null,this}get transferAccountId(){return this._transferAccountId}setTransferAccountId(t){return this._requireNotFrozen(),this._transferAccountId=t instanceof e?t:e.fromString(t),this._transferContractId=null,this}get permanentRemoval(){return this._permanentRemoval}setPermanentRemoval(t){return this._requireNotFrozen(),this._permanentRemoval=t,this}_validateChecksums(t){null!=this._contractId&&this._contractId.validateChecksum(t),null!=this._transferAccountId&&this._transferAccountId.validateChecksum(t),null!=this._transferContractId&&this._transferContractId.validateChecksum(t)}_execute(t,r){return t.smartContract.deleteContract(r)}_getTransactionDataCase(){return"contractDeleteInstance"}_makeTransactionData(){return{contractID:null!=this._contractId?this._contractId._toProtobuf():null,transferAccountID:this._transferAccountId?this._transferAccountId._toProtobuf():null,transferContractID:null!=this._transferContractId?this._transferContractId._toProtobuf():null,permanentRemoval:this._permanentRemoval}}_getLogId(){return`ContractDeleteTransaction:${this._transactionIds.current.validStart.toString()}`}}r.set("contractDeleteInstance",a._fromProtobuf);export{a as default};
|
|
2
2
|
//# sourceMappingURL=ContractDeleteTransaction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContractDeleteTransaction.js","sources":["../../src/contract/ContractDeleteTransaction.js"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\nimport Transaction, {\n TRANSACTION_REGISTRY,\n} from \"../transaction/Transaction.js\";\nimport ContractId from \"./ContractId.js\";\nimport AccountId from \"../account/AccountId.js\";\n\n/**\n * @namespace proto\n * @typedef {import(\"@hashgraph/proto\").proto.ITransaction} HieroProto.proto.ITransaction\n * @typedef {import(\"@hashgraph/proto\").proto.ISignedTransaction} HieroProto.proto.ISignedTransaction\n * @typedef {import(\"@hashgraph/proto\").proto.TransactionBody} HieroProto.proto.TransactionBody\n * @typedef {import(\"@hashgraph/proto\").proto.ITransactionBody} HieroProto.proto.ITransactionBody\n * @typedef {import(\"@hashgraph/proto\").proto.ITransactionResponse} HieroProto.proto.ITransactionResponse\n * @typedef {import(\"@hashgraph/proto\").proto.IContractDeleteTransactionBody} HieroProto.proto.IContractDeleteTransactionBody\n * @typedef {import(\"@hashgraph/proto\").proto.IContractID} HieroProto.proto.IContractID\n * @typedef {import(\"@hashgraph/proto\").proto.IAccountID} HieroProto.proto.IAccountID\n */\n\n/**\n * @typedef {import(\"../channel/Channel.js\").default} Channel\n * @typedef {import(\"../client/Client.js\").default<*, *>} Client\n * @typedef {import(\"../transaction/TransactionId.js\").default} TransactionId\n */\n\n/**\n * Delete a smart contract, and transfer any remaining HBAR balance to a\n * designated account.\n *\n * If this call succeeds then all subsequent calls to that smart contract\n * SHALL execute the `0x0` opcode, as required for EVM equivalence.\n *\n * ### Requirements\n * - An account or smart contract MUST be designated to receive all remaining\n * account balances.\n * - The smart contract MUST have an admin key set. If the contract does not\n * have `admin_key` set, then this transaction SHALL fail and response code\n * `MODIFYING_IMMUTABLE_CONTRACT` SHALL be set.\n * - If `admin_key` is, or contains, an empty `KeyList` key, it SHALL be\n * treated the same as an admin key that is not set.\n * - The `Key` set for `admin_key` on the smart contract MUST have a valid\n * signature set on this transaction.\n * - The designated receiving account MAY have `receiver_sig_required` set. If\n * that field is set, the receiver account MUST also sign this transaction.\n * - The field `permanent_removal` MUST NOT be set. That field is reserved for\n * internal system use when purging the smart contract from state. Any user\n * transaction with that field set SHALL be rejected and a response code\n * `PERMANENT_REMOVAL_REQUIRES_SYSTEM_INITIATION` SHALL be set.\n */\nexport default class ContractDeleteTransaction extends Transaction {\n /**\n * @param {object} [props]\n * @param {ContractId | string} [props.contractId]\n * @param {ContractId | string} [props.transferContractId]\n * @param {AccountId | string} [props.transferAccountId]\n */\n constructor(props = {}) {\n super();\n\n /**\n * @private\n * @type {?ContractId}\n */\n this._contractId = null;\n\n /**\n * @private\n * @type {?AccountId}\n */\n this._transferAccountId = null;\n\n /**\n * @private\n * @type {?ContractId}\n */\n this._transferContractId = null;\n\n if (props.contractId != null) {\n this.setContractId(props.contractId);\n }\n\n if (props.transferAccountId != null) {\n this.setTransferAccountId(props.transferAccountId);\n }\n\n if (props.transferContractId != null) {\n this.setTransferContractId(props.transferContractId);\n }\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 {ContractDeleteTransaction}\n */\n static _fromProtobuf(\n transactions,\n signedTransactions,\n transactionIds,\n nodeIds,\n bodies,\n ) {\n const body = bodies[0];\n const contractDelete =\n /** @type {HieroProto.proto.IContractDeleteTransactionBody} */ (\n body.contractDeleteInstance\n );\n\n return Transaction._fromProtobufTransactions(\n new ContractDeleteTransaction({\n contractId:\n contractDelete.contractID != null\n ? ContractId._fromProtobuf(\n /** @type {HieroProto.proto.IContractID} */ (\n contractDelete.contractID\n ),\n )\n : undefined,\n transferAccountId:\n contractDelete.transferAccountID != null\n ? AccountId._fromProtobuf(\n /** @type {HieroProto.proto.IAccountID} */ (\n contractDelete.transferAccountID\n ),\n )\n : undefined,\n transferContractId:\n contractDelete.transferContractID != null\n ? ContractId._fromProtobuf(\n /** @type {HieroProto.proto.IContractID} */ (\n contractDelete.transferContractID\n ),\n )\n : undefined,\n }),\n transactions,\n signedTransactions,\n transactionIds,\n nodeIds,\n bodies,\n );\n }\n\n /**\n * @returns {?ContractId}\n */\n get contractId() {\n return this._contractId;\n }\n\n /**\n * Sets the contract ID which is being deleted in this transaction.\n *\n * @param {ContractId | string} contractId\n * @returns {ContractDeleteTransaction}\n */\n setContractId(contractId) {\n this._requireNotFrozen();\n this._contractId =\n typeof contractId === \"string\"\n ? ContractId.fromString(contractId)\n : contractId.clone();\n\n return this;\n }\n\n /**\n * @returns {?ContractId}\n */\n get transferContractId() {\n return this._transferContractId;\n }\n\n /**\n * Sets the contract ID which will receive all remaining hbars.\n *\n * @param {ContractId | string} transferContractId\n * @returns {ContractDeleteTransaction}\n */\n setTransferContractId(transferContractId) {\n this._requireNotFrozen();\n this._transferContractId =\n transferContractId instanceof ContractId\n ? transferContractId\n : ContractId.fromString(transferContractId);\n\n return this;\n }\n\n /**\n * @returns {?AccountId}\n */\n get transferAccountId() {\n return this._transferAccountId;\n }\n\n /**\n * Sets the account ID which will receive all remaining hbars.\n *\n * @param {AccountId | string} transferAccountId\n * @returns {ContractDeleteTransaction}\n */\n setTransferAccountId(transferAccountId) {\n this._requireNotFrozen();\n this._transferAccountId =\n transferAccountId instanceof AccountId\n ? transferAccountId\n : AccountId.fromString(transferAccountId);\n\n return this;\n }\n\n /**\n * @param {Client} client\n */\n _validateChecksums(client) {\n if (this._contractId != null) {\n this._contractId.validateChecksum(client);\n }\n\n if (this._transferAccountId != null) {\n this._transferAccountId.validateChecksum(client);\n }\n\n if (this._transferContractId != null) {\n this._transferContractId.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.smartContract.deleteContract(request);\n }\n\n /**\n * @override\n * @protected\n * @returns {NonNullable<HieroProto.proto.TransactionBody[\"data\"]>}\n */\n _getTransactionDataCase() {\n return \"contractDeleteInstance\";\n }\n\n /**\n * @override\n * @protected\n * @returns {HieroProto.proto.IContractDeleteTransactionBody}\n */\n _makeTransactionData() {\n return {\n contractID:\n this._contractId != null\n ? this._contractId._toProtobuf()\n : null,\n transferAccountID: this._transferAccountId\n ? this._transferAccountId._toProtobuf()\n : null,\n transferContractID:\n this._transferContractId != null\n ? this._transferContractId._toProtobuf()\n : null,\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 `ContractDeleteTransaction:${timestamp.toString()}`;\n }\n}\n\nTRANSACTION_REGISTRY.set(\n \"contractDeleteInstance\",\n // eslint-disable-next-line @typescript-eslint/unbound-method\n ContractDeleteTransaction._fromProtobuf,\n);\n"],"names":["ContractDeleteTransaction","Transaction","constructor","props","super","this","_contractId","_transferAccountId","_transferContractId","contractId","setContractId","transferAccountId","setTransferAccountId","transferContractId","setTransferContractId","_fromProtobuf","transactions","signedTransactions","transactionIds","nodeIds","bodies","contractDelete","_fromProtobufTransactions","contractID","ContractId","undefined","transferAccountID","AccountId","transferContractID","_requireNotFrozen","fromString","clone","_validateChecksums","client","validateChecksum","_execute","channel","request","smartContract","deleteContract","_getTransactionDataCase","_makeTransactionData","_toProtobuf","_getLogId","_transactionIds","current","toString","TRANSACTION_REGISTRY","set"],"mappings":"8IAkDe,MAAMA,UAAkCC,EAOnD,WAAAC,CAAYC,EAAQ,IAChBC,QAMAC,KAAKC,YAAc,KAMnBD,KAAKE,mBAAqB,KAM1BF,KAAKG,oBAAsB,KAE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,OAAOD,EAAQE,cAAcC,eAAeF,EACpD,CAOI,uBAAAG,GACI,MAAO,wBACf,CAOI,oBAAAC,GACI,MAAO,CACHlB,WACwB,MAApBlB,KAAKC,YACCD,KAAKC,YAAYoC,cACjB,KACVhB,kBAAmBrB,KAAKE,mBAClBF,KAAKE,mBAAmBmC,cACxB,KACNd,mBACgC,MAA5BvB,KAAKG,oBACCH,KAAKG,oBAAoBkC,cACzB,KAEtB,CAKI,SAAAC,GAII,MAAO,6BAFHtC,KAAKuC,gBAAgBC,QACxB,WAC6CC,YACtD,EAGAC,EAAqBC,IACjB,yBAEAhD,EAA0Be"}
|
|
1
|
+
{"version":3,"file":"ContractDeleteTransaction.js","sources":["../../src/contract/ContractDeleteTransaction.js"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\nimport Transaction, {\n TRANSACTION_REGISTRY,\n} from \"../transaction/Transaction.js\";\nimport ContractId from \"./ContractId.js\";\nimport AccountId from \"../account/AccountId.js\";\n\n/**\n * @namespace proto\n * @typedef {import(\"@hashgraph/proto\").proto.ITransaction} HieroProto.proto.ITransaction\n * @typedef {import(\"@hashgraph/proto\").proto.ISignedTransaction} HieroProto.proto.ISignedTransaction\n * @typedef {import(\"@hashgraph/proto\").proto.TransactionBody} HieroProto.proto.TransactionBody\n * @typedef {import(\"@hashgraph/proto\").proto.ITransactionBody} HieroProto.proto.ITransactionBody\n * @typedef {import(\"@hashgraph/proto\").proto.ITransactionResponse} HieroProto.proto.ITransactionResponse\n * @typedef {import(\"@hashgraph/proto\").proto.IContractDeleteTransactionBody} HieroProto.proto.IContractDeleteTransactionBody\n * @typedef {import(\"@hashgraph/proto\").proto.IContractID} HieroProto.proto.IContractID\n * @typedef {import(\"@hashgraph/proto\").proto.IAccountID} HieroProto.proto.IAccountID\n */\n\n/**\n * @typedef {import(\"../channel/Channel.js\").default} Channel\n * @typedef {import(\"../client/Client.js\").default<*, *>} Client\n * @typedef {import(\"../transaction/TransactionId.js\").default} TransactionId\n */\n\n/**\n * Delete a smart contract, and transfer any remaining HBAR balance to a\n * designated account.\n *\n * If this call succeeds then all subsequent calls to that smart contract\n * SHALL execute the `0x0` opcode, as required for EVM equivalence.\n *\n * ### Requirements\n * - An account or smart contract MUST be designated to receive all remaining\n * account balances.\n * - The smart contract MUST have an admin key set. If the contract does not\n * have `admin_key` set, then this transaction SHALL fail and response code\n * `MODIFYING_IMMUTABLE_CONTRACT` SHALL be set.\n * - If `admin_key` is, or contains, an empty `KeyList` key, it SHALL be\n * treated the same as an admin key that is not set.\n * - The `Key` set for `admin_key` on the smart contract MUST have a valid\n * signature set on this transaction.\n * - The designated receiving account MAY have `receiver_sig_required` set. If\n * that field is set, the receiver account MUST also sign this transaction.\n * - The field `permanent_removal` MUST NOT be set. That field is reserved for\n * internal system use when purging the smart contract from state. Any user\n * transaction with that field set SHALL be rejected and a response code\n * `PERMANENT_REMOVAL_REQUIRES_SYSTEM_INITIATION` SHALL be set.\n */\nexport default class ContractDeleteTransaction extends Transaction {\n /**\n * @param {object} [props]\n * @param {ContractId | string} [props.contractId]\n * @param {ContractId | string} [props.transferContractId]\n * @param {AccountId | string} [props.transferAccountId]\n * @param {boolean} [props.permanentRemoval]\n */\n constructor(props = {}) {\n super();\n\n /**\n * @private\n * @type {?ContractId}\n */\n this._contractId = null;\n\n /**\n * @private\n * @type {?AccountId}\n */\n this._transferAccountId = null;\n\n /**\n * @private\n * @type {?ContractId}\n */\n this._transferContractId = null;\n\n /**\n * @private\n * @type {boolean}\n */\n this._permanentRemoval = false;\n\n if (props.contractId != null) {\n this.setContractId(props.contractId);\n }\n\n if (props.transferAccountId != null) {\n this.setTransferAccountId(props.transferAccountId);\n }\n\n if (props.transferContractId != null) {\n this.setTransferContractId(props.transferContractId);\n }\n\n if (props.permanentRemoval != null) {\n this.setPermanentRemoval(props.permanentRemoval);\n }\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 {ContractDeleteTransaction}\n */\n static _fromProtobuf(\n transactions,\n signedTransactions,\n transactionIds,\n nodeIds,\n bodies,\n ) {\n const body = bodies[0];\n const contractDelete =\n /** @type {HieroProto.proto.IContractDeleteTransactionBody} */ (\n body.contractDeleteInstance\n );\n\n return Transaction._fromProtobufTransactions(\n new ContractDeleteTransaction({\n contractId:\n contractDelete.contractID != null\n ? ContractId._fromProtobuf(\n /** @type {HieroProto.proto.IContractID} */ (\n contractDelete.contractID\n ),\n )\n : undefined,\n transferAccountId:\n contractDelete.transferAccountID != null\n ? AccountId._fromProtobuf(\n /** @type {HieroProto.proto.IAccountID} */ (\n contractDelete.transferAccountID\n ),\n )\n : undefined,\n transferContractId:\n contractDelete.transferContractID != null\n ? ContractId._fromProtobuf(\n /** @type {HieroProto.proto.IContractID} */ (\n contractDelete.transferContractID\n ),\n )\n : undefined,\n permanentRemoval: contractDelete.permanentRemoval ?? false,\n }),\n transactions,\n signedTransactions,\n transactionIds,\n nodeIds,\n bodies,\n );\n }\n\n /**\n * @returns {?ContractId}\n */\n get contractId() {\n return this._contractId;\n }\n\n /**\n * Sets the contract ID which is being deleted in this transaction.\n *\n * @param {ContractId | string} contractId\n * @returns {ContractDeleteTransaction}\n */\n setContractId(contractId) {\n this._requireNotFrozen();\n this._contractId =\n typeof contractId === \"string\"\n ? ContractId.fromString(contractId)\n : contractId.clone();\n\n return this;\n }\n\n /**\n * @returns {?ContractId}\n */\n get transferContractId() {\n return this._transferContractId;\n }\n\n /**\n * Sets the contract ID which will receive all remaining hbars.\n *\n * @param {ContractId | string} transferContractId\n * @returns {ContractDeleteTransaction}\n */\n setTransferContractId(transferContractId) {\n this._requireNotFrozen();\n this._transferContractId =\n transferContractId instanceof ContractId\n ? transferContractId\n : ContractId.fromString(transferContractId);\n this._transferAccountId = null;\n\n return this;\n }\n\n /**\n * @returns {?AccountId}\n */\n get transferAccountId() {\n return this._transferAccountId;\n }\n\n /**\n * Sets the account ID which will receive all remaining hbars.\n *\n * @param {AccountId | string} transferAccountId\n * @returns {ContractDeleteTransaction}\n */\n setTransferAccountId(transferAccountId) {\n this._requireNotFrozen();\n this._transferAccountId =\n transferAccountId instanceof AccountId\n ? transferAccountId\n : AccountId.fromString(transferAccountId);\n this._transferContractId = null;\n\n return this;\n }\n\n /**\n * @returns {boolean}\n */\n get permanentRemoval() {\n return this._permanentRemoval;\n }\n\n /**\n * Sets the permanent removal flag.\n *\n * @param {boolean} permanentRemoval\n * @returns {ContractDeleteTransaction}\n */\n setPermanentRemoval(permanentRemoval) {\n this._requireNotFrozen();\n this._permanentRemoval = permanentRemoval;\n return this;\n }\n\n /**\n * @param {Client} client\n */\n _validateChecksums(client) {\n if (this._contractId != null) {\n this._contractId.validateChecksum(client);\n }\n\n if (this._transferAccountId != null) {\n this._transferAccountId.validateChecksum(client);\n }\n\n if (this._transferContractId != null) {\n this._transferContractId.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.smartContract.deleteContract(request);\n }\n\n /**\n * @override\n * @protected\n * @returns {NonNullable<HieroProto.proto.TransactionBody[\"data\"]>}\n */\n _getTransactionDataCase() {\n return \"contractDeleteInstance\";\n }\n\n /**\n * @override\n * @protected\n * @returns {HieroProto.proto.IContractDeleteTransactionBody}\n */\n _makeTransactionData() {\n return {\n contractID:\n this._contractId != null\n ? this._contractId._toProtobuf()\n : null,\n transferAccountID: this._transferAccountId\n ? this._transferAccountId._toProtobuf()\n : null,\n transferContractID:\n this._transferContractId != null\n ? this._transferContractId._toProtobuf()\n : null,\n permanentRemoval: this._permanentRemoval,\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 `ContractDeleteTransaction:${timestamp.toString()}`;\n }\n}\n\nTRANSACTION_REGISTRY.set(\n \"contractDeleteInstance\",\n // eslint-disable-next-line @typescript-eslint/unbound-method\n ContractDeleteTransaction._fromProtobuf,\n);\n"],"names":["ContractDeleteTransaction","Transaction","constructor","props","super","this","_contractId","_transferAccountId","_transferContractId","_permanentRemoval","contractId","setContractId","transferAccountId","setTransferAccountId","transferContractId","setTransferContractId","permanentRemoval","setPermanentRemoval","_fromProtobuf","transactions","signedTransactions","transactionIds","nodeIds","bodies","contractDelete","_fromProtobufTransactions","contractID","ContractId","undefined","transferAccountID","AccountId","transferContractID","_requireNotFrozen","fromString","clone","_validateChecksums","client","validateChecksum","_execute","channel","request","smartContract","deleteContract","_getTransactionDataCase","_makeTransactionData","_toProtobuf","_getLogId","_transactionIds","current","toString","TRANSACTION_REGISTRY","set"],"mappings":"8IAkDe,MAAMA,UAAkCC,EAQnD,WAAAC,CAAYC,EAAQ,IAChBC,QAMAC,KAAKC,YAAc,KAMnBD,KAAKE,mBAAqB,KAM1BF,KAAKG,oBAAsB,KAM3BH,KAAKI,mBAAoB,EAED,MAApBN,EAAMO,YACNL,KAAKM,cAAcR,EAAMO,YAGE,MAA3BP,EAAMS,mBACNP,KAAKQ,qBAAqBV,EAAMS,mBAGJ,MAA5BT,EAAMW,oBACNT,KAAKU,sBAAsBZ,EAAMW,oBAGP,MAA1BX,EAAMa,kBACNX,KAAKY,oBAAoBd,EAAMa,iBAE3C,CAWI,oBAAOE,CACHC,EACAC,EACAC,EACAC,EACAC,GAEA,MACMC,EADOD,EAAO,GAIf,uBAEL,OAAOtB,EAAYwB,0BACf,IAAIzB,EAA0B,CAC1BU,WACiC,MAA7Bc,EAAeE,WACTC,EAAWT,cAEHM,EAClC,iBAE0BI,EACVhB,kBACwC,MAApCY,EAAeK,kBACTC,EAAUZ,cAEFM,EAClC,wBAE0BI,EACVd,mBACyC,MAArCU,EAAeO,mBACTJ,EAAWT,cAEHM,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qC,cACzB,KACV7B,iBAAkBX,KAAKI,kBAEnC,CAKI,SAAAqC,GAII,MAAO,6BAFHzC,KAAK0C,gBAAgBC,QACxB,WAC6CC,YACtD,EAGAC,EAAqBC,IACjB,yBAEAnD,EAA0BkB"}
|
|
@@ -12,6 +12,7 @@ var _Duration = _interopRequireDefault(require("../Duration.cjs"));
|
|
|
12
12
|
var _Timestamp = _interopRequireDefault(require("../Timestamp.cjs"));
|
|
13
13
|
var _Key = _interopRequireDefault(require("../Key.cjs"));
|
|
14
14
|
var _long = _interopRequireDefault(require("long"));
|
|
15
|
+
var Proto = _interopRequireWildcard(require("@hashgraph/proto"));
|
|
15
16
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
16
17
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
17
18
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -506,7 +507,7 @@ class ContractUpdateTransaction extends _Transaction.default {
|
|
|
506
507
|
declineReward: this.declineStakingRewards != null ? {
|
|
507
508
|
value: this.declineStakingRewards
|
|
508
509
|
} : null,
|
|
509
|
-
autoRenewAccountId: this._autoRenewAccountId != null ? this._autoRenewAccountId._toProtobuf() : null
|
|
510
|
+
autoRenewAccountId: this._autoRenewAccountId != null ? this._autoRenewAccountId.toString() == "0.0.0" ? Proto.proto.AccountID.create() : this._autoRenewAccountId._toProtobuf() : null
|
|
510
511
|
};
|
|
511
512
|
}
|
|
512
513
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import t from"../account/AccountId.js";import e from"./ContractId.js";import o from"../file/FileId.js";import n,{TRANSACTION_REGISTRY as i}from"../transaction/Transaction.js";import r from"../Duration.js";import a from"../Timestamp.js";import
|
|
1
|
+
import t from"../account/AccountId.js";import e from"./ContractId.js";import o from"../file/FileId.js";import n,{TRANSACTION_REGISTRY as i}from"../transaction/Transaction.js";import r from"../Duration.js";import a from"../Timestamp.js";import c from"../Key.js";import s from"long";import*as u from"@hashgraph/proto";class d extends n{constructor(t={}){super(),this._contractId=null,this._expirationTime=null,this._adminKey=null,this._proxyAccountId=null,this._autoRenewPeriod=null,this._bytecodeFileId=null,this._contractMemo=null,this._maxAutomaticTokenAssociations=null,this._stakedAccountId=null,this._stakedNodeId=null,this._declineStakingReward=null,this._autoRenewAccountId=null,null!=t.contractId&&this.setContractId(t.contractId),null!=t.expirationTime&&this.setExpirationTime(t.expirationTime),null!=t.adminKey&&this.setAdminKey(t.adminKey),null!=t.proxyAccountId&&this.setProxyAccountId(t.proxyAccountId),null!=t.autoRenewPeriod&&this.setAutoRenewPeriod(t.autoRenewPeriod),null!=t.bytecodeFileId&&this.setBytecodeFileId(t.bytecodeFileId),null!=t.contractMemo&&this.setContractMemo(t.contractMemo),null!=t.maxAutomaticTokenAssociations&&this.setMaxAutomaticTokenAssociations(t.maxAutomaticTokenAssociations),null!=t.stakedAccountId&&this.setStakedAccountId(t.stakedAccountId),null!=t.stakedNodeId&&this.setStakedNodeId(t.stakedNodeId),null!=t.declineStakingReward&&this.setDeclineStakingReward(t.declineStakingReward),null!=t.autoRenewAccountId&&this.setAutoRenewAccountId(t.autoRenewAccountId)}static _fromProtobuf(i,r,s,u,l){const m=l[0].contractUpdateInstance;let h,I,_;return null!=m.autoRenewPeriod&&null!=m.autoRenewPeriod.seconds&&(h=m.autoRenewPeriod.seconds),null!=m.memoWrapper&&Object.hasOwn(m.memoWrapper,"value")&&null!=m.memoWrapper.value&&(I=m.memoWrapper.value),null!=m.maxAutomaticTokenAssociations&&null!=m.maxAutomaticTokenAssociations.value&&(_=m.maxAutomaticTokenAssociations.value),n._fromProtobufTransactions(new d({contractId:null!=m.contractID?e._fromProtobuf(m.contractID):void 0,bytecodeFileId:null!=m.fileID?o._fromProtobuf(m.fileID):void 0,expirationTime:null!=m.expirationTime?a._fromProtobuf(m.expirationTime):void 0,adminKey:null!=m.adminKey?c._fromProtobufKey(m.adminKey):void 0,proxyAccountId:null!=m.proxyAccountID?t._fromProtobuf(m.proxyAccountID):void 0,autoRenewPeriod:h,contractMemo:I,maxAutomaticTokenAssociations:_,stakedAccountId:null!=m.stakedAccountId?t._fromProtobuf(m.stakedAccountId):void 0,stakedNodeId:null!=m.stakedNodeId?m.stakedNodeId:void 0,declineStakingReward:null!=m.declineReward&&1==Boolean(m.declineReward),autoRenewAccountId:null!=m.autoRenewAccountId?t._fromProtobuf(m.autoRenewAccountId):void 0}),i,r,s,u,l)}get contractId(){return this._contractId}setContractId(t){return this._requireNotFrozen(),this._contractId="string"==typeof t?e.fromString(t):t.clone(),this}get expirationTime(){return this._expirationTime}setExpirationTime(t){return this._requireNotFrozen(),this._expirationTime=t instanceof a?t:a.fromDate(t),this}get adminKey(){return this._adminKey}setAdminKey(t){return this._requireNotFrozen(),this._adminKey=t,this}get proxyAccountId(){return this._proxyAccountId}setProxyAccountId(e){return this._requireNotFrozen(),this._proxyAccountId="string"==typeof e?t.fromString(e):e.clone(),this}get autoRenewPeriod(){return this._autoRenewPeriod}setAutoRenewPeriod(t){return this._requireNotFrozen(),this._autoRenewPeriod=t instanceof r?t:new r(t),this}get bytecodeFileId(){return this._bytecodeFileId}setBytecodeFileId(t){return console.warn("Deprecated: there is no replacement"),this._requireNotFrozen(),this._bytecodeFileId="string"==typeof t?o.fromString(t):t.clone(),this}get contractMemo(){return this._contractMemo}setContractMemo(t){return this._requireNotFrozen(),this._contractMemo=t,this}clearContractMemo(){return this._requireNotFrozen(),this._contractMemo=null,this}get maxAutomaticTokenAssociations(){return this._maxAutomaticTokenAssociations}setMaxAutomaticTokenAssociations(t){return this._requireNotFrozen(),this._maxAutomaticTokenAssociations=t,this}get stakedAccountId(){return this._stakedAccountId}setStakedAccountId(e){return this._requireNotFrozen(),this._stakedAccountId="string"==typeof e?t.fromString(e):e,this}get stakedNodeId(){return this._stakedNodeId}setStakedNodeId(t){return this._requireNotFrozen(),this._stakedNodeId=s.fromValue(t),this}get declineStakingRewards(){return this._declineStakingReward}setDeclineStakingReward(t){return this._requireNotFrozen(),this._declineStakingReward=t,this}get autoRenewAccountId(){return this._autoRenewAccountId}setAutoRenewAccountId(e){return this._requireNotFrozen(),this._autoRenewAccountId="string"==typeof e?t.fromString(e):e,this}clearAutoRenewAccountId(){return this._autoRenewAccountId=new t(0),this}_validateChecksums(t){null!=this._contractId&&this._contractId.validateChecksum(t),null!=this._bytecodeFileId&&this._bytecodeFileId.validateChecksum(t),null!=this._proxyAccountId&&this._proxyAccountId.validateChecksum(t)}_execute(t,e){return t.smartContract.updateContract(e)}_getTransactionDataCase(){return"contractUpdateInstance"}_makeTransactionData(){return{contractID:null!=this._contractId?this._contractId._toProtobuf():null,expirationTime:null!=this._expirationTime?this._expirationTime._toProtobuf():null,adminKey:null!=this._adminKey?this._adminKey._toProtobufKey():null,proxyAccountID:null!=this._proxyAccountId?this._proxyAccountId._toProtobuf():null,autoRenewPeriod:null!=this._autoRenewPeriod?this._autoRenewPeriod._toProtobuf():null,fileID:this._bytecodeFileId?this._bytecodeFileId._toProtobuf():null,memoWrapper:null!=this._contractMemo?{value:this._contractMemo}:null,maxAutomaticTokenAssociations:null!=this._maxAutomaticTokenAssociations?{value:this._maxAutomaticTokenAssociations}:null,stakedAccountId:null!=this.stakedAccountId?this.stakedAccountId._toProtobuf():null,stakedNodeId:this.stakedNodeId,declineReward:null!=this.declineStakingRewards?{value:this.declineStakingRewards}:null,autoRenewAccountId:null!=this._autoRenewAccountId?"0.0.0"==this._autoRenewAccountId.toString()?u.proto.AccountID.create():this._autoRenewAccountId._toProtobuf():null}}_getLogId(){return`ContractUpdateTransaction:${this._transactionIds.current.validStart.toString()}`}}i.set("contractUpdateInstance",d._fromProtobuf);export{d as default};
|
|
2
2
|
//# sourceMappingURL=ContractUpdateTransaction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContractUpdateTransaction.js","sources":["../../src/contract/ContractUpdateTransaction.js"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\nimport AccountId from \"../account/AccountId.js\";\nimport ContractId from \"./ContractId.js\";\nimport FileId from \"../file/FileId.js\";\nimport Transaction, {\n TRANSACTION_REGISTRY,\n} from \"../transaction/Transaction.js\";\nimport Duration from \"../Duration.js\";\nimport Timestamp from \"../Timestamp.js\";\nimport Key from \"../Key.js\";\nimport Long from \"long\";\n\n/**\n * @namespace proto\n * @typedef {import(\"@hashgraph/proto\").proto.ITransaction} HieroProto.proto.ITransaction\n * @typedef {import(\"@hashgraph/proto\").proto.ISignedTransaction} HieroProto.proto.ISignedTransaction\n * @typedef {import(\"@hashgraph/proto\").proto.TransactionBody} HieroProto.proto.TransactionBody\n * @typedef {import(\"@hashgraph/proto\").proto.ITransactionBody} HieroProto.proto.ITransactionBody\n * @typedef {import(\"@hashgraph/proto\").proto.ITransactionResponse} HieroProto.proto.ITransactionResponse\n * @typedef {import(\"@hashgraph/proto\").proto.IContractUpdateTransactionBody} HieroProto.proto.IContractUpdateTransactionBody\n * @typedef {import(\"@hashgraph/proto\").proto.IAccountID} HieroProto.proto.IAccountID\n * @typedef {import(\"@hashgraph/proto\").proto.IContractID} HieroProto.proto.IContractID\n * @typedef {import(\"@hashgraph/proto\").proto.IFileID} HieroProto.proto.IFileID\n */\n\n/**\n * @typedef {import(\"../channel/Channel.js\").default} Channel\n * @typedef {import(\"../client/Client.js\").default<*, *>} Client\n * @typedef {import(\"../transaction/TransactionId.js\").default} TransactionId\n */\n\n/**\n * Modify a smart contract.<br/>\n * Any change other than updating the expiration time requires that the\n * contract be modifiable (has a valid `adminKey`) and that the\n * transaction be signed by the `adminKey`\n * <p>\n * Fields _not set_ on the request SHALL NOT be modified.\n */\nexport default class ContractUpdateTransaction extends Transaction {\n /**\n * @param {object} props\n * @param {ContractId | string} [props.contractId]\n * @param {FileId | string} [props.bytecodeFileId]\n * @param {Timestamp | Date} [props.expirationTime]\n * @param {Key} [props.adminKey]\n * @param {AccountId | string} [props.proxyAccountId]\n * @param {Duration | Long | number} [props.autoRenewPeriod]\n * @param {string} [props.contractMemo]\n * @param {number} [props.maxAutomaticTokenAssociations]\n * @param {AccountId | string} [props.stakedAccountId]\n * @param {Long | number} [props.stakedNodeId]\n * @param {boolean} [props.declineStakingReward]\n * @param {AccountId} [props.autoRenewAccountId]\n */\n constructor(props = {}) {\n super();\n\n /**\n * @private\n * @type {?ContractId}\n */\n this._contractId = null;\n\n /**\n * @private\n * @type {?Timestamp}\n */\n this._expirationTime = null;\n\n /**\n * @private\n * @type {?Key}\n */\n this._adminKey = null;\n\n /**\n * @private\n * @type {?AccountId}\n */\n this._proxyAccountId = null;\n\n /**\n * @private\n * @type {?Duration}\n */\n this._autoRenewPeriod = null;\n\n /**\n * @private\n * @type {?FileId}\n */\n this._bytecodeFileId = null;\n\n /**\n * @private\n * @type {?string}\n */\n this._contractMemo = null;\n\n /**\n * @private\n * @type {?number}\n */\n this._maxAutomaticTokenAssociations = null;\n\n /**\n * @private\n * @type {?AccountId}\n */\n this._stakedAccountId = null;\n\n /**\n * @private\n * @type {?Long}\n */\n this._stakedNodeId = null;\n\n /**\n * @private\n * @type {?boolean}\n */\n this._declineStakingReward = null;\n\n /**\n * @type {?AccountId}\n */\n this._autoRenewAccountId = null;\n\n if (props.contractId != null) {\n this.setContractId(props.contractId);\n }\n\n if (props.expirationTime != null) {\n this.setExpirationTime(props.expirationTime);\n }\n\n if (props.adminKey != null) {\n this.setAdminKey(props.adminKey);\n }\n\n if (props.proxyAccountId != null) {\n // eslint-disable-next-line deprecation/deprecation\n this.setProxyAccountId(props.proxyAccountId);\n }\n\n if (props.autoRenewPeriod != null) {\n this.setAutoRenewPeriod(props.autoRenewPeriod);\n }\n\n if (props.bytecodeFileId != null) {\n this.setBytecodeFileId(props.bytecodeFileId);\n }\n\n if (props.contractMemo != null) {\n this.setContractMemo(props.contractMemo);\n }\n\n if (props.maxAutomaticTokenAssociations != null) {\n this.setMaxAutomaticTokenAssociations(\n props.maxAutomaticTokenAssociations,\n );\n }\n\n if (props.stakedAccountId != null) {\n this.setStakedAccountId(props.stakedAccountId);\n }\n\n if (props.stakedNodeId != null) {\n this.setStakedNodeId(props.stakedNodeId);\n }\n\n if (props.declineStakingReward != null) {\n this.setDeclineStakingReward(props.declineStakingReward);\n }\n\n if (props.autoRenewAccountId != null) {\n this.setAutoRenewAccountId(props.autoRenewAccountId);\n }\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 {ContractUpdateTransaction}\n */\n static _fromProtobuf(\n transactions,\n signedTransactions,\n transactionIds,\n nodeIds,\n bodies,\n ) {\n const body = bodies[0];\n const update =\n /** @type {HieroProto.proto.IContractUpdateTransactionBody} */ (\n body.contractUpdateInstance\n );\n\n let autoRenewPeriod = undefined;\n if (\n update.autoRenewPeriod != null &&\n update.autoRenewPeriod.seconds != null\n ) {\n autoRenewPeriod = update.autoRenewPeriod.seconds;\n }\n\n let contractMemo = undefined;\n if (\n update.memoWrapper != null &&\n Object.hasOwn(update.memoWrapper, \"value\") &&\n update.memoWrapper.value != null\n ) {\n contractMemo = update.memoWrapper.value;\n }\n\n let maxAutomaticTokenAssociations = undefined;\n if (\n update.maxAutomaticTokenAssociations != null &&\n update.maxAutomaticTokenAssociations.value != null\n ) {\n maxAutomaticTokenAssociations =\n update.maxAutomaticTokenAssociations.value;\n }\n\n return Transaction._fromProtobufTransactions(\n new ContractUpdateTransaction({\n contractId:\n update.contractID != null\n ? ContractId._fromProtobuf(\n /** @type {HieroProto.proto.IContractID} */ (\n update.contractID\n ),\n )\n : undefined,\n bytecodeFileId:\n update.fileID != null\n ? FileId._fromProtobuf(\n /** @type {HieroProto.proto.IFileID} */ (\n update.fileID\n ),\n )\n : undefined,\n expirationTime:\n update.expirationTime != null\n ? Timestamp._fromProtobuf(update.expirationTime)\n : undefined,\n adminKey:\n update.adminKey != null\n ? Key._fromProtobufKey(update.adminKey)\n : undefined,\n proxyAccountId:\n update.proxyAccountID != null\n ? AccountId._fromProtobuf(\n /** @type {HieroProto.proto.IAccountID} */ (\n update.proxyAccountID\n ),\n )\n : undefined,\n autoRenewPeriod,\n contractMemo,\n maxAutomaticTokenAssociations,\n stakedAccountId:\n update.stakedAccountId != null\n ? AccountId._fromProtobuf(update.stakedAccountId)\n : undefined,\n stakedNodeId:\n update.stakedNodeId != null\n ? update.stakedNodeId\n : undefined,\n declineStakingReward:\n update.declineReward != null &&\n Boolean(update.declineReward) == true,\n autoRenewAccountId:\n update.autoRenewAccountId != null\n ? AccountId._fromProtobuf(update.autoRenewAccountId)\n : undefined,\n }),\n transactions,\n signedTransactions,\n transactionIds,\n nodeIds,\n bodies,\n );\n }\n\n /**\n * @returns {?ContractId}\n */\n get contractId() {\n return this._contractId;\n }\n\n /**\n * Sets the contract ID which is being deleted in this transaction.\n *\n * @param {ContractId | string} contractId\n * @returns {ContractUpdateTransaction}\n */\n setContractId(contractId) {\n this._requireNotFrozen();\n this._contractId =\n typeof contractId === \"string\"\n ? ContractId.fromString(contractId)\n : contractId.clone();\n\n return this;\n }\n\n /**\n * @returns {?Timestamp}\n */\n get expirationTime() {\n return this._expirationTime;\n }\n\n /**\n * Sets the contract ID which is being deleted in this transaction.\n *\n * @param {Timestamp | Date} expirationTime\n * @returns {ContractUpdateTransaction}\n */\n setExpirationTime(expirationTime) {\n this._requireNotFrozen();\n this._expirationTime =\n expirationTime instanceof Timestamp\n ? expirationTime\n : Timestamp.fromDate(expirationTime);\n\n return this;\n }\n\n /**\n * @returns {?Key}\n */\n get adminKey() {\n return this._adminKey;\n }\n\n /**\n * @param {Key} adminKey\n * @returns {this}\n */\n setAdminKey(adminKey) {\n this._requireNotFrozen();\n this._adminKey = adminKey;\n\n return this;\n }\n\n /**\n * @deprecated\n * @returns {?AccountId}\n */\n get proxyAccountId() {\n return this._proxyAccountId;\n }\n\n /**\n * @deprecated\n * @param {AccountId | string} proxyAccountId\n * @returns {this}\n */\n setProxyAccountId(proxyAccountId) {\n this._requireNotFrozen();\n this._proxyAccountId =\n typeof proxyAccountId === \"string\"\n ? AccountId.fromString(proxyAccountId)\n : proxyAccountId.clone();\n\n return this;\n }\n\n /**\n * @returns {?Duration}\n */\n get autoRenewPeriod() {\n return this._autoRenewPeriod;\n }\n\n /**\n * @param {Duration | Long | number} autoRenewPeriod\n * @returns {this}\n */\n setAutoRenewPeriod(autoRenewPeriod) {\n this._requireNotFrozen();\n this._autoRenewPeriod =\n autoRenewPeriod instanceof Duration\n ? autoRenewPeriod\n : new Duration(autoRenewPeriod);\n\n return this;\n }\n\n /**\n * @returns {?FileId}\n */\n get bytecodeFileId() {\n return this._bytecodeFileId;\n }\n\n /**\n * @param {FileId | string} bytecodeFileId\n * @returns {this}\n */\n setBytecodeFileId(bytecodeFileId) {\n console.warn(\"Deprecated: there is no replacement\");\n this._requireNotFrozen();\n this._bytecodeFileId =\n typeof bytecodeFileId === \"string\"\n ? FileId.fromString(bytecodeFileId)\n : bytecodeFileId.clone();\n\n return this;\n }\n\n /**\n * @returns {?string}\n */\n get contractMemo() {\n return this._contractMemo;\n }\n\n /**\n * @param {string} contractMemo\n * @returns {this}\n */\n setContractMemo(contractMemo) {\n this._requireNotFrozen();\n this._contractMemo = contractMemo;\n\n return this;\n }\n\n /**\n * @returns {this}\n */\n clearContractMemo() {\n this._requireNotFrozen();\n this._contractMemo = null;\n\n return this;\n }\n\n /**\n * @returns {number | null}\n */\n get maxAutomaticTokenAssociations() {\n return this._maxAutomaticTokenAssociations;\n }\n\n /**\n * @param {number} maxAutomaticTokenAssociations\n * @returns {this}\n */\n setMaxAutomaticTokenAssociations(maxAutomaticTokenAssociations) {\n this._requireNotFrozen();\n this._maxAutomaticTokenAssociations = maxAutomaticTokenAssociations;\n\n return this;\n }\n\n /**\n * @returns {?AccountId}\n */\n get stakedAccountId() {\n return this._stakedAccountId;\n }\n\n /**\n * @param {AccountId | string} stakedAccountId\n * @returns {this}\n */\n setStakedAccountId(stakedAccountId) {\n this._requireNotFrozen();\n this._stakedAccountId =\n typeof stakedAccountId === \"string\"\n ? AccountId.fromString(stakedAccountId)\n : stakedAccountId;\n\n return this;\n }\n\n /**\n * @returns {?Long}\n */\n get stakedNodeId() {\n return this._stakedNodeId;\n }\n\n /**\n * @param {Long | number} stakedNodeId\n * @returns {this}\n */\n setStakedNodeId(stakedNodeId) {\n this._requireNotFrozen();\n this._stakedNodeId = Long.fromValue(stakedNodeId);\n\n return this;\n }\n\n /**\n * @returns {?boolean}\n */\n get declineStakingRewards() {\n return this._declineStakingReward;\n }\n\n /**\n * @param {boolean} declineStakingReward\n * @returns {this}\n */\n setDeclineStakingReward(declineStakingReward) {\n this._requireNotFrozen();\n this._declineStakingReward = declineStakingReward;\n\n return this;\n }\n\n /**\n * @returns {?AccountId}\n */\n get autoRenewAccountId() {\n return this._autoRenewAccountId;\n }\n\n /**\n * If set to the sentinel <tt>0.0.0</tt> AccountID, this field removes the contract's auto-renew\n * account. Otherwise it updates the contract's auto-renew account to the referenced account.\n *\n * @param {string | AccountId} autoRenewAccountId\n * @returns {this}\n */\n setAutoRenewAccountId(autoRenewAccountId) {\n this._requireNotFrozen();\n this._autoRenewAccountId =\n typeof autoRenewAccountId === \"string\"\n ? AccountId.fromString(autoRenewAccountId)\n : autoRenewAccountId;\n\n return this;\n }\n\n /**\n * @returns {this}\n */\n clearAutoRenewAccountId() {\n this._autoRenewAccountId = new AccountId(0);\n return this;\n }\n\n /**\n * @param {Client} client\n */\n _validateChecksums(client) {\n if (this._contractId != null) {\n this._contractId.validateChecksum(client);\n }\n\n if (this._bytecodeFileId != null) {\n this._bytecodeFileId.validateChecksum(client);\n }\n\n if (this._proxyAccountId != null) {\n this._proxyAccountId.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.smartContract.updateContract(request);\n }\n\n /**\n * @override\n * @protected\n * @returns {NonNullable<HieroProto.proto.TransactionBody[\"data\"]>}\n */\n _getTransactionDataCase() {\n return \"contractUpdateInstance\";\n }\n\n /**\n * @override\n * @protected\n * @returns {HieroProto.proto.IContractUpdateTransactionBody}\n */\n _makeTransactionData() {\n return {\n contractID:\n this._contractId != null\n ? this._contractId._toProtobuf()\n : null,\n expirationTime:\n this._expirationTime != null\n ? this._expirationTime._toProtobuf()\n : null,\n adminKey:\n this._adminKey != null ? this._adminKey._toProtobufKey() : null,\n proxyAccountID:\n this._proxyAccountId != null\n ? this._proxyAccountId._toProtobuf()\n : null,\n autoRenewPeriod:\n this._autoRenewPeriod != null\n ? this._autoRenewPeriod._toProtobuf()\n : null,\n fileID: this._bytecodeFileId\n ? this._bytecodeFileId._toProtobuf()\n : null,\n memoWrapper:\n this._contractMemo != null\n ? {\n value: this._contractMemo,\n }\n : null,\n maxAutomaticTokenAssociations:\n this._maxAutomaticTokenAssociations != null\n ? {\n value: this._maxAutomaticTokenAssociations,\n }\n : null,\n stakedAccountId:\n this.stakedAccountId != null\n ? this.stakedAccountId._toProtobuf()\n : null,\n stakedNodeId: this.stakedNodeId,\n declineReward:\n this.declineStakingRewards != null\n ? { value: this.declineStakingRewards }\n : null,\n autoRenewAccountId:\n this._autoRenewAccountId != null\n ? this._autoRenewAccountId._toProtobuf()\n : null,\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 `ContractUpdateTransaction:${timestamp.toString()}`;\n }\n}\n\nTRANSACTION_REGISTRY.set(\n \"contractUpdateInstance\",\n // eslint-disable-next-line @typescript-eslint/unbound-method\n ContractUpdateTransaction._fromProtobuf,\n);\n"],"names":["ContractUpdateTransaction","Transaction","constructor","props","super","this","_contractId","_expirationTime","_adminKey","_proxyAccountId","_autoRenewPeriod","_bytecodeFileId","_contractMemo","_maxAutomaticTokenAssociations","_stakedAccountId","_stakedNodeId","_declineStakingReward","_autoRenewAccountId","contractId","setContractId","expirationTime","setExpirationTime","adminKey","setAdminKey","proxyAccountId","setProxyAccountId","autoRenewPeriod","setAutoRenewPeriod","bytecodeFileId","setBytecodeFileId","contractMemo","setContractMemo","maxAutomaticTokenAssociations","setMaxAutomaticTokenAssociations","stakedAccountId","setStakedAccountId","stakedNodeId","setStakedNodeId","declineStakingReward","setDeclineStakingReward","autoRenewAccountId","setAutoRenewAccountId","_fromProtobuf","transactions","signedTransactions","transactionIds","nodeIds","bodies","update","seconds","memoWrapper","Object","hasOwn","value","_fromProtobufTransactions","contractID","ContractId","undefined","fileID","FileId","Timestamp","Key","_fromProtobufKey","proxyAccountID","AccountId","declineReward","Boolean","_requireNotFrozen","fromString","clone","fromDate","Duration","console","warn","clearContractMemo","Long","fromValue","declineStakingRewards","clearAutoRenewAccountId","_validateChecksums","client","validateChecksum","_execute","channel","request","smartContract","updateContract","_getTransactionDataCase","_makeTransactionData","_toProtobuf","_toProtobufKey","_getLogId","_transactionIds","current","toString","TRANSACTION_REGISTRY","set"],"mappings":"yRAwCe,MAAMA,UAAkCC,EAgBnD,WAAAC,CAAYC,EAAQ,IAChBC,QAMAC,KAAKC,YAAc,KAMnBD,KAAKE,gBAAkB,KAMvBF,KAAKG,UAAY,KAMjBH,KAAKI,gBAAkB,KAMvBJ,KAAKK,iBAAmB,KAMxBL,KA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AA9B5D,KAAKwE,sBACC,CAAExB,MAAOhD,KAAKwE,uBACd,KACVrC,mBACgC,MAA5BnC,KAAKY,oBACCZ,KAAKY,oBAAoBwE,cACzB,KAEtB,CAKI,SAAAE,GAII,MAAO,6BAFHtF,KAAKuF,gBAAgBC,QACxB,WAC6CC,YACtD,EAGAC,EAAqBC,IACjB,yBAEAhG,EAA0B0C"}
|
|
1
|
+
{"version":3,"file":"ContractUpdateTransaction.js","sources":["../../src/contract/ContractUpdateTransaction.js"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\nimport AccountId from \"../account/AccountId.js\";\nimport ContractId from \"./ContractId.js\";\nimport FileId from \"../file/FileId.js\";\nimport Transaction, {\n TRANSACTION_REGISTRY,\n} from \"../transaction/Transaction.js\";\nimport Duration from \"../Duration.js\";\nimport Timestamp from \"../Timestamp.js\";\nimport Key from \"../Key.js\";\nimport Long from \"long\";\nimport * as Proto from \"@hashgraph/proto\";\n\n/**\n * @namespace proto\n * @typedef {import(\"@hashgraph/proto\").proto.ITransaction} HieroProto.proto.ITransaction\n * @typedef {import(\"@hashgraph/proto\").proto.ISignedTransaction} HieroProto.proto.ISignedTransaction\n * @typedef {import(\"@hashgraph/proto\").proto.TransactionBody} HieroProto.proto.TransactionBody\n * @typedef {import(\"@hashgraph/proto\").proto.ITransactionBody} HieroProto.proto.ITransactionBody\n * @typedef {import(\"@hashgraph/proto\").proto.ITransactionResponse} HieroProto.proto.ITransactionResponse\n * @typedef {import(\"@hashgraph/proto\").proto.IContractUpdateTransactionBody} HieroProto.proto.IContractUpdateTransactionBody\n * @typedef {import(\"@hashgraph/proto\").proto.IAccountID} HieroProto.proto.IAccountID\n * @typedef {import(\"@hashgraph/proto\").proto.IContractID} HieroProto.proto.IContractID\n * @typedef {import(\"@hashgraph/proto\").proto.IFileID} HieroProto.proto.IFileID\n */\n\n/**\n * @typedef {import(\"../channel/Channel.js\").default} Channel\n * @typedef {import(\"../client/Client.js\").default<*, *>} Client\n * @typedef {import(\"../transaction/TransactionId.js\").default} TransactionId\n */\n\n/**\n * Modify a smart contract.<br/>\n * Any change other than updating the expiration time requires that the\n * contract be modifiable (has a valid `adminKey`) and that the\n * transaction be signed by the `adminKey`\n * <p>\n * Fields _not set_ on the request SHALL NOT be modified.\n */\nexport default class ContractUpdateTransaction extends Transaction {\n /**\n * @param {object} props\n * @param {ContractId | string} [props.contractId]\n * @param {FileId | string} [props.bytecodeFileId]\n * @param {Timestamp | Date} [props.expirationTime]\n * @param {Key} [props.adminKey]\n * @param {AccountId | string} [props.proxyAccountId]\n * @param {Duration | Long | number} [props.autoRenewPeriod]\n * @param {string} [props.contractMemo]\n * @param {number} [props.maxAutomaticTokenAssociations]\n * @param {AccountId | string} [props.stakedAccountId]\n * @param {Long | number} [props.stakedNodeId]\n * @param {boolean} [props.declineStakingReward]\n * @param {AccountId} [props.autoRenewAccountId]\n */\n constructor(props = {}) {\n super();\n\n /**\n * @private\n * @type {?ContractId}\n */\n this._contractId = null;\n\n /**\n * @private\n * @type {?Timestamp}\n */\n this._expirationTime = null;\n\n /**\n * @private\n * @type {?Key}\n */\n this._adminKey = null;\n\n /**\n * @private\n * @type {?AccountId}\n */\n this._proxyAccountId = null;\n\n /**\n * @private\n * @type {?Duration}\n */\n this._autoRenewPeriod = null;\n\n /**\n * @private\n * @type {?FileId}\n */\n this._bytecodeFileId = null;\n\n /**\n * @private\n * @type {?string}\n */\n this._contractMemo = null;\n\n /**\n * @private\n * @type {?number}\n */\n this._maxAutomaticTokenAssociations = null;\n\n /**\n * @private\n * @type {?AccountId}\n */\n this._stakedAccountId = null;\n\n /**\n * @private\n * @type {?Long}\n */\n this._stakedNodeId = null;\n\n /**\n * @private\n * @type {?boolean}\n */\n this._declineStakingReward = null;\n\n /**\n * @type {?AccountId}\n */\n this._autoRenewAccountId = null;\n\n if (props.contractId != null) {\n this.setContractId(props.contractId);\n }\n\n if (props.expirationTime != null) {\n this.setExpirationTime(props.expirationTime);\n }\n\n if (props.adminKey != null) {\n this.setAdminKey(props.adminKey);\n }\n\n if (props.proxyAccountId != null) {\n // eslint-disable-next-line deprecation/deprecation\n this.setProxyAccountId(props.proxyAccountId);\n }\n\n if (props.autoRenewPeriod != null) {\n this.setAutoRenewPeriod(props.autoRenewPeriod);\n }\n\n if (props.bytecodeFileId != null) {\n this.setBytecodeFileId(props.bytecodeFileId);\n }\n\n if (props.contractMemo != null) {\n this.setContractMemo(props.contractMemo);\n }\n\n if (props.maxAutomaticTokenAssociations != null) {\n this.setMaxAutomaticTokenAssociations(\n props.maxAutomaticTokenAssociations,\n );\n }\n\n if (props.stakedAccountId != null) {\n this.setStakedAccountId(props.stakedAccountId);\n }\n\n if (props.stakedNodeId != null) {\n this.setStakedNodeId(props.stakedNodeId);\n }\n\n if (props.declineStakingReward != null) {\n this.setDeclineStakingReward(props.declineStakingReward);\n }\n\n if (props.autoRenewAccountId != null) {\n this.setAutoRenewAccountId(props.autoRenewAccountId);\n }\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 {ContractUpdateTransaction}\n */\n static _fromProtobuf(\n transactions,\n signedTransactions,\n transactionIds,\n nodeIds,\n bodies,\n ) {\n const body = bodies[0];\n const update =\n /** @type {HieroProto.proto.IContractUpdateTransactionBody} */ (\n body.contractUpdateInstance\n );\n\n let autoRenewPeriod = undefined;\n if (\n update.autoRenewPeriod != null &&\n update.autoRenewPeriod.seconds != null\n ) {\n autoRenewPeriod = update.autoRenewPeriod.seconds;\n }\n\n let contractMemo = undefined;\n if (\n update.memoWrapper != null &&\n Object.hasOwn(update.memoWrapper, \"value\") &&\n update.memoWrapper.value != null\n ) {\n contractMemo = update.memoWrapper.value;\n }\n\n let maxAutomaticTokenAssociations = undefined;\n if (\n update.maxAutomaticTokenAssociations != null &&\n update.maxAutomaticTokenAssociations.value != null\n ) {\n maxAutomaticTokenAssociations =\n update.maxAutomaticTokenAssociations.value;\n }\n\n return Transaction._fromProtobufTransactions(\n new ContractUpdateTransaction({\n contractId:\n update.contractID != null\n ? ContractId._fromProtobuf(\n /** @type {HieroProto.proto.IContractID} */ (\n update.contractID\n ),\n )\n : undefined,\n bytecodeFileId:\n update.fileID != null\n ? FileId._fromProtobuf(\n /** @type {HieroProto.proto.IFileID} */ (\n update.fileID\n ),\n )\n : undefined,\n expirationTime:\n update.expirationTime != null\n ? Timestamp._fromProtobuf(update.expirationTime)\n : undefined,\n adminKey:\n update.adminKey != null\n ? Key._fromProtobufKey(update.adminKey)\n : undefined,\n proxyAccountId:\n update.proxyAccountID != null\n ? AccountId._fromProtobuf(\n /** @type {HieroProto.proto.IAccountID} */ (\n update.proxyAccountID\n ),\n )\n : undefined,\n autoRenewPeriod,\n contractMemo,\n maxAutomaticTokenAssociations,\n stakedAccountId:\n update.stakedAccountId != null\n ? AccountId._fromProtobuf(update.stakedAccountId)\n : undefined,\n stakedNodeId:\n update.stakedNodeId != null\n ? update.stakedNodeId\n : undefined,\n declineStakingReward:\n update.declineReward != null &&\n Boolean(update.declineReward) == true,\n autoRenewAccountId:\n update.autoRenewAccountId != null\n ? AccountId._fromProtobuf(update.autoRenewAccountId)\n : undefined,\n }),\n transactions,\n signedTransactions,\n transactionIds,\n nodeIds,\n bodies,\n );\n }\n\n /**\n * @returns {?ContractId}\n */\n get contractId() {\n return this._contractId;\n }\n\n /**\n * Sets the contract ID which is being deleted in this transaction.\n *\n * @param {ContractId | string} contractId\n * @returns {ContractUpdateTransaction}\n */\n setContractId(contractId) {\n this._requireNotFrozen();\n this._contractId =\n typeof contractId === \"string\"\n ? ContractId.fromString(contractId)\n : contractId.clone();\n\n return this;\n }\n\n /**\n * @returns {?Timestamp}\n */\n get expirationTime() {\n return this._expirationTime;\n }\n\n /**\n * Sets the contract ID which is being deleted in this transaction.\n *\n * @param {Timestamp | Date} expirationTime\n * @returns {ContractUpdateTransaction}\n */\n setExpirationTime(expirationTime) {\n this._requireNotFrozen();\n this._expirationTime =\n expirationTime instanceof Timestamp\n ? expirationTime\n : Timestamp.fromDate(expirationTime);\n\n return this;\n }\n\n /**\n * @returns {?Key}\n */\n get adminKey() {\n return this._adminKey;\n }\n\n /**\n * @param {Key} adminKey\n * @returns {this}\n */\n setAdminKey(adminKey) {\n this._requireNotFrozen();\n this._adminKey = adminKey;\n\n return this;\n }\n\n /**\n * @deprecated\n * @returns {?AccountId}\n */\n get proxyAccountId() {\n return this._proxyAccountId;\n }\n\n /**\n * @deprecated\n * @param {AccountId | string} proxyAccountId\n * @returns {this}\n */\n setProxyAccountId(proxyAccountId) {\n this._requireNotFrozen();\n this._proxyAccountId =\n typeof proxyAccountId === \"string\"\n ? AccountId.fromString(proxyAccountId)\n : proxyAccountId.clone();\n\n return this;\n }\n\n /**\n * @returns {?Duration}\n */\n get autoRenewPeriod() {\n return this._autoRenewPeriod;\n }\n\n /**\n * @param {Duration | Long | number} autoRenewPeriod\n * @returns {this}\n */\n setAutoRenewPeriod(autoRenewPeriod) {\n this._requireNotFrozen();\n this._autoRenewPeriod =\n autoRenewPeriod instanceof Duration\n ? autoRenewPeriod\n : new Duration(autoRenewPeriod);\n\n return this;\n }\n\n /**\n * @returns {?FileId}\n */\n get bytecodeFileId() {\n return this._bytecodeFileId;\n }\n\n /**\n * @param {FileId | string} bytecodeFileId\n * @returns {this}\n */\n setBytecodeFileId(bytecodeFileId) {\n console.warn(\"Deprecated: there is no replacement\");\n this._requireNotFrozen();\n this._bytecodeFileId =\n typeof bytecodeFileId === \"string\"\n ? FileId.fromString(bytecodeFileId)\n : bytecodeFileId.clone();\n\n return this;\n }\n\n /**\n * @returns {?string}\n */\n get contractMemo() {\n return this._contractMemo;\n }\n\n /**\n * @param {string} contractMemo\n * @returns {this}\n */\n setContractMemo(contractMemo) {\n this._requireNotFrozen();\n this._contractMemo = contractMemo;\n\n return this;\n }\n\n /**\n * @returns {this}\n */\n clearContractMemo() {\n this._requireNotFrozen();\n this._contractMemo = null;\n\n return this;\n }\n\n /**\n * @returns {number | null}\n */\n get maxAutomaticTokenAssociations() {\n return this._maxAutomaticTokenAssociations;\n }\n\n /**\n * @param {number} maxAutomaticTokenAssociations\n * @returns {this}\n */\n setMaxAutomaticTokenAssociations(maxAutomaticTokenAssociations) {\n this._requireNotFrozen();\n this._maxAutomaticTokenAssociations = maxAutomaticTokenAssociations;\n\n return this;\n }\n\n /**\n * @returns {?AccountId}\n */\n get stakedAccountId() {\n return this._stakedAccountId;\n }\n\n /**\n * @param {AccountId | string} stakedAccountId\n * @returns {this}\n */\n setStakedAccountId(stakedAccountId) {\n this._requireNotFrozen();\n this._stakedAccountId =\n typeof stakedAccountId === \"string\"\n ? AccountId.fromString(stakedAccountId)\n : stakedAccountId;\n\n return this;\n }\n\n /**\n * @returns {?Long}\n */\n get stakedNodeId() {\n return this._stakedNodeId;\n }\n\n /**\n * @param {Long | number} stakedNodeId\n * @returns {this}\n */\n setStakedNodeId(stakedNodeId) {\n this._requireNotFrozen();\n this._stakedNodeId = Long.fromValue(stakedNodeId);\n\n return this;\n }\n\n /**\n * @returns {?boolean}\n */\n get declineStakingRewards() {\n return this._declineStakingReward;\n }\n\n /**\n * @param {boolean} declineStakingReward\n * @returns {this}\n */\n setDeclineStakingReward(declineStakingReward) {\n this._requireNotFrozen();\n this._declineStakingReward = declineStakingReward;\n\n return this;\n }\n\n /**\n * @returns {?AccountId}\n */\n get autoRenewAccountId() {\n return this._autoRenewAccountId;\n }\n\n /**\n * If set to the sentinel <tt>0.0.0</tt> AccountID, this field removes the contract's auto-renew\n * account. Otherwise it updates the contract's auto-renew account to the referenced account.\n *\n * @param {string | AccountId} autoRenewAccountId\n * @returns {this}\n */\n setAutoRenewAccountId(autoRenewAccountId) {\n this._requireNotFrozen();\n this._autoRenewAccountId =\n typeof autoRenewAccountId === \"string\"\n ? AccountId.fromString(autoRenewAccountId)\n : autoRenewAccountId;\n\n return this;\n }\n\n /**\n * @returns {this}\n */\n clearAutoRenewAccountId() {\n this._autoRenewAccountId = new AccountId(0);\n return this;\n }\n\n /**\n * @param {Client} client\n */\n _validateChecksums(client) {\n if (this._contractId != null) {\n this._contractId.validateChecksum(client);\n }\n\n if (this._bytecodeFileId != null) {\n this._bytecodeFileId.validateChecksum(client);\n }\n\n if (this._proxyAccountId != null) {\n this._proxyAccountId.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.smartContract.updateContract(request);\n }\n\n /**\n * @override\n * @protected\n * @returns {NonNullable<HieroProto.proto.TransactionBody[\"data\"]>}\n */\n _getTransactionDataCase() {\n return \"contractUpdateInstance\";\n }\n\n /**\n * @override\n * @protected\n * @returns {HieroProto.proto.IContractUpdateTransactionBody}\n */\n _makeTransactionData() {\n return {\n contractID:\n this._contractId != null\n ? this._contractId._toProtobuf()\n : null,\n expirationTime:\n this._expirationTime != null\n ? this._expirationTime._toProtobuf()\n : null,\n adminKey:\n this._adminKey != null ? this._adminKey._toProtobufKey() : null,\n proxyAccountID:\n this._proxyAccountId != null\n ? this._proxyAccountId._toProtobuf()\n : null,\n autoRenewPeriod:\n this._autoRenewPeriod != null\n ? this._autoRenewPeriod._toProtobuf()\n : null,\n fileID: this._bytecodeFileId\n ? this._bytecodeFileId._toProtobuf()\n : null,\n memoWrapper:\n this._contractMemo != null\n ? {\n value: this._contractMemo,\n }\n : null,\n maxAutomaticTokenAssociations:\n this._maxAutomaticTokenAssociations != null\n ? {\n value: this._maxAutomaticTokenAssociations,\n }\n : null,\n stakedAccountId:\n this.stakedAccountId != null\n ? this.stakedAccountId._toProtobuf()\n : null,\n stakedNodeId: this.stakedNodeId,\n declineReward:\n this.declineStakingRewards != null\n ? { value: this.declineStakingRewards }\n : null,\n autoRenewAccountId:\n this._autoRenewAccountId != null\n ? this._autoRenewAccountId.toString() == \"0.0.0\"\n ? Proto.proto.AccountID.create()\n : this._autoRenewAccountId._toProtobuf()\n : null,\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 `ContractUpdateTransaction:${timestamp.toString()}`;\n }\n}\n\nTRANSACTION_REGISTRY.set(\n \"contractUpdateInstance\",\n // eslint-disable-next-line @typescript-eslint/unbound-method\n ContractUpdateTransaction._fromProtobuf,\n);\n"],"names":["ContractUpdateTransaction","Transaction","constructor","props","super","this","_contractId","_expirationTime","_adminKey","_proxyAccountId","_autoRenewPeriod","_bytecodeFileId","_contractMemo","_maxAutomaticTokenAssociations","_stakedAccountId","_stakedNodeId","_declineStakingReward","_autoRenewAccountId","contractId","setContractId","expirationTime","setExpirationTime","adminKey","setAdminKey","proxyAccountId","setProxyAccountId","autoRenewPeriod","setAutoRenewPeriod","bytecodeFileId","setBytecodeFileId","contractMemo","setContractMemo","maxAutomaticTokenAssociations","setMaxAutomaticTokenAssociations","stakedAccountId","setStakedAccountId","stakedNodeId","setStakedNodeId","declineStakingReward","setDeclineStakingReward","autoRenewAccountId","setAutoRenewAccountId","_fromProtobuf","transactions","signedTransactions","transactionIds","nodeIds","bodies","update","seconds","memoWrapper","Object","hasOwn","value","_fromProtobufTransactions","contractID","ContractId","undefined","fileID","FileId","Timestamp","Key","_fromProtobufKey","proxyAccountID","AccountId","declineReward","Boolean","_requireNotFrozen","fromString","clone","fromDate","Duration","console","warn","clearContractMemo","Long","fromValue","declineStakingRewards","clearAutoRenewAccountId","_validateChecksums","client","validateChecksum","_execute","channel","request","smartContract","updateContract","_getTransactionDataCase","_makeTransactionData","_toProtobuf","_toProtobufKey","toString","Proto","proto","AccountID","create","_getLogId","_transactionIds","current","TRANSACTION_REGISTRY","set"],"mappings":"4TAyCe,MAAMA,UAAkCC,EAgBnD,WAAAC,CAAYC,EAAQ,IAChBC,QAMAC,KAA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gCAEhB,KACVqB,gBAC4B,MAAxB7B,KAAK6B,gBACC7B,KAAK6B,gBAAgBuD,cACrB,KACVrD,aAAc/B,KAAK+B,aACnB6B,cACkC,MAA9B5D,KAAKwE,sBACC,CAAExB,MAAOhD,KAAKwE,uBACd,KACVrC,mBACgC,MAA5BnC,KAAKY,oBACwC,SAAvCZ,KAAKY,oBAAoB0E,WACrBC,EAAMC,MAAMC,UAAUC,SACtB1F,KAAKY,oBAAoBwE,cAC7B,KAEtB,CAKI,SAAAO,GAII,MAAO,6BAFH3F,KAAK4F,gBAAgBC,QACxB,WAC6CP,YACtD,EAGAQ,EAAqBC,IACjB,yBAEApG,EAA0B0C"}
|
package/lib/encoding/hex.cjs
CHANGED
|
@@ -23,6 +23,17 @@ function encode(data) {
|
|
|
23
23
|
*/
|
|
24
24
|
function decode(text) {
|
|
25
25
|
const str = text.startsWith("0x") ? text.substring(2) : text;
|
|
26
|
+
if (str.length % 2 !== 0) {
|
|
27
|
+
throw new Error("Invalid hex string: Must have an even number of characters.");
|
|
28
|
+
}
|
|
29
|
+
if (/[^0-9a-fA-F]/.test(str)) {
|
|
30
|
+
throw new Error("Invalid hex string: Contains non-hexadecimal characters.");
|
|
31
|
+
}
|
|
32
|
+
const bytes = new Uint8Array(str.length / 2);
|
|
33
|
+
for (let i = 0; i < str.length; i += 2) {
|
|
34
|
+
const byte = parseInt(str.substring(i, i + 2), 16);
|
|
35
|
+
bytes[i / 2] = byte;
|
|
36
|
+
}
|
|
26
37
|
return Buffer.from(str, "hex");
|
|
27
38
|
}
|
|
28
39
|
|
package/lib/encoding/hex.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function t(t){return Buffer.from(t).toString("hex")}function r(t){const r=t.startsWith("0x")?t.substring(2):t;return Buffer.from(r,"hex")}function n(t){if("string"!=typeof t)return!1;const r=t.startsWith("0x")?t.substring(2):t;if(0===r.length)return!1;if(r.length%2!=0)return!1;return/^[0-9a-fA-F]+$/.test(r)}export{r as decode,t as encode,n as isHexString};
|
|
1
|
+
function t(t){return Buffer.from(t).toString("hex")}function r(t){const r=t.startsWith("0x")?t.substring(2):t;if(r.length%2!=0)throw new Error("Invalid hex string: Must have an even number of characters.");if(/[^0-9a-fA-F]/.test(r))throw new Error("Invalid hex string: Contains non-hexadecimal characters.");const n=new Uint8Array(r.length/2);for(let t=0;t<r.length;t+=2){const e=parseInt(r.substring(t,t+2),16);n[t/2]=e}return Buffer.from(r,"hex")}function n(t){if("string"!=typeof t)return!1;const r=t.startsWith("0x")?t.substring(2):t;if(0===r.length)return!1;if(r.length%2!=0)return!1;return/^[0-9a-fA-F]+$/.test(r)}export{r as decode,t as encode,n as isHexString};
|
|
2
2
|
//# sourceMappingURL=hex.js.map
|