@hiero-ledger/sdk
Version:
3 lines (2 loc) • 8.94 kB
JavaScript
import e from"../Hbar.js";import t,{TRANSACTION_REGISTRY as o,DEFAULT_AUTO_RENEW_PERIOD as u}from"../transaction/Transaction.js";import i from"long";import n from"../account/AccountId.js";import s from"../Timestamp.js";import r from"../Duration.js";import l from"./CustomFixedFee.js";import a from"./CustomFractionalFee.js";import y from"./CustomRoyaltyFee.js";import h from"./TokenType.js";import p from"./TokenSupplyType.js";import m from"../Key.js";class _ extends t{constructor(t={}){super(),this._tokenName=null,this._tokenSymbol=null,this._decimals=null,this._initialSupply=null,this._treasuryAccountId=null,this._adminKey=null,this._kycKey=null,this._freezeKey=null,this._pauseKey=null,this._wipeKey=null,this._supplyKey=null,this._feeScheduleKey=null,this._freezeDefault=null,this._autoRenewAccountId=null,this._expirationTime=new s(Math.floor(Date.now()/1e3+u.toNumber()),0),this._autoRenewPeriod=new r(u),this._tokenMemo=null,this._customFees=[],this._tokenType=null,this._supplyType=null,this._maxSupply=null,this._defaultMaxTransactionFee=new e(30),this._metadataKey=null,this._metadata=null,null!=t.tokenName&&this.setTokenName(t.tokenName),null!=t.tokenSymbol&&this.setTokenSymbol(t.tokenSymbol),null!=t.decimals&&this.setDecimals(t.decimals),null!=t.initialSupply&&this.setInitialSupply(t.initialSupply),null!=t.treasuryAccountId&&this.setTreasuryAccountId(t.treasuryAccountId),null!=t.adminKey&&this.setAdminKey(t.adminKey),null!=t.kycKey&&this.setKycKey(t.kycKey),null!=t.freezeKey&&this.setFreezeKey(t.freezeKey),null!=t.pauseKey&&this.setPauseKey(t.pauseKey),null!=t.wipeKey&&this.setWipeKey(t.wipeKey),null!=t.supplyKey&&this.setSupplyKey(t.supplyKey),null!=t.feeScheduleKey&&this.setFeeScheduleKey(t.feeScheduleKey),null!=t.freezeDefault&&this.setFreezeDefault(t.freezeDefault),null!=t.autoRenewAccountId&&this.setAutoRenewAccountId(t.autoRenewAccountId),null!=t.expirationTime&&this.setExpirationTime(t.expirationTime),null!=t.autoRenewPeriod&&this.setAutoRenewPeriod(t.autoRenewPeriod),null!=t.tokenMemo&&this.setTokenMemo(t.tokenMemo),null!=t.customFees&&this.setCustomFees(t.customFees),null!=t.tokenType&&this.setTokenType(t.tokenType),null!=t.supplyType&&this.setSupplyType(t.supplyType),null!=t.maxSupply&&this.setMaxSupply(t.maxSupply),null!=t.metadataKey&&this.setMetadataKey(t.metadataKey),null!=t.metadata&&this.setMetadata(t.metadata)}static _fromProtobuf(e,o,u,i,c){const d=c[0].tokenCreation;return t._fromProtobufTransactions(new _({tokenName:null!=d.name?d.name:void 0,tokenSymbol:null!=d.symbol?d.symbol:void 0,decimals:null!=d.decimals?d.decimals:void 0,initialSupply:null!=d.initialSupply?d.initialSupply:void 0,treasuryAccountId:null!=d.treasury?n._fromProtobuf(d.treasury):void 0,adminKey:null!=d.adminKey?m._fromProtobufKey(d.adminKey):void 0,kycKey:null!=d.kycKey?m._fromProtobufKey(d.kycKey):void 0,freezeKey:null!=d.freezeKey?m._fromProtobufKey(d.freezeKey):void 0,pauseKey:null!=d.pauseKey?m._fromProtobufKey(d.pauseKey):void 0,wipeKey:null!=d.wipeKey?m._fromProtobufKey(d.wipeKey):void 0,supplyKey:null!=d.supplyKey?m._fromProtobufKey(d.supplyKey):void 0,feeScheduleKey:null!=d.feeScheduleKey?m._fromProtobufKey(d.feeScheduleKey):void 0,freezeDefault:null!=d.freezeDefault?d.freezeDefault:void 0,autoRenewAccountId:null!=d.autoRenewAccount?n._fromProtobuf(d.autoRenewAccount):void 0,expirationTime:null!=d.expiry?s._fromProtobuf(d.expiry):void 0,autoRenewPeriod:null!=d.autoRenewPeriod?r._fromProtobuf(d.autoRenewPeriod):void 0,tokenMemo:null!=d.memo?d.memo:void 0,customFees:null!=d.customFees?d.customFees.map((e=>null!=e.fixedFee?l._fromProtobuf(e):null!=e.fractionalFee?a._fromProtobuf(e):y._fromProtobuf(e))):void 0,tokenType:null!=d.tokenType?h._fromCode(d.tokenType):void 0,supplyType:null!=d.supplyType?p._fromCode(d.supplyType):void 0,maxSupply:null!=d.maxSupply?d.maxSupply:void 0,metadataKey:null!=d.metadataKey?m._fromProtobufKey(d.metadataKey):void 0,metadata:null!=d.metadata?d.metadata:void 0}),e,o,u,i,c)}get tokenName(){return this._tokenName}setTokenName(e){return this._requireNotFrozen(),this._tokenName=e,this}get tokenSymbol(){return this._tokenSymbol}setTokenSymbol(e){return this._requireNotFrozen(),this._tokenSymbol=e,this}get decimals(){return this._decimals}setDecimals(e){return this._requireNotFrozen(),this._decimals=e instanceof i?e:i.fromValue(e),this}get initialSupply(){return this._initialSupply}setInitialSupply(e){return this._requireNotFrozen(),this._initialSupply=i.fromValue(e),this}get treasuryAccountId(){return this._treasuryAccountId}setTreasuryAccountId(e){return this._requireNotFrozen(),this._treasuryAccountId="string"==typeof e?n.fromString(e):e.clone(),this}get adminKey(){return this._adminKey}setAdminKey(e){return this._requireNotFrozen(),this._adminKey=e,this}get kycKey(){return this._kycKey}setKycKey(e){return this._requireNotFrozen(),this._kycKey=e,this}get freezeKey(){return this._freezeKey}freezeWith(e){return!this._autoRenewAccountId&&this.transactionId?.accountId&&null!=this.autoRenewPeriod?this.setAutoRenewAccountId(this.transactionId?.accountId):!this._autoRenewAccountId&&e?.operatorAccountId&&null!=this.autoRenewPeriod&&this.setAutoRenewAccountId(e.operatorAccountId),super.freezeWith(e)}setFreezeKey(e){return this._requireNotFrozen(),this._freezeKey=e,this}get pauseKey(){return this._pauseKey}setPauseKey(e){return this._requireNotFrozen(),this._pauseKey=e,this}get wipeKey(){return this._wipeKey}setWipeKey(e){return this._requireNotFrozen(),this._wipeKey=e,this}get supplyKey(){return this._supplyKey}setSupplyKey(e){return this._requireNotFrozen(),this._supplyKey=e,this}get feeScheduleKey(){return this._feeScheduleKey}setFeeScheduleKey(e){return this._requireNotFrozen(),this._feeScheduleKey=e,this}get freezeDefault(){return this._freezeDefault}setFreezeDefault(e){return this._requireNotFrozen(),this._freezeDefault=e,this}get expirationTime(){return this._expirationTime}setExpirationTime(e){return this._requireNotFrozen(),this._expirationTime=e instanceof s?e:s.fromDate(e),this._autoRenewPeriod=null,this}get autoRenewAccountId(){return this._autoRenewAccountId}setAutoRenewAccountId(e){return this._requireNotFrozen(),this._autoRenewAccountId=e instanceof n?e:n.fromString(e),this}get autoRenewPeriod(){return this._autoRenewPeriod}setAutoRenewPeriod(e){return this._requireNotFrozen(),this._autoRenewPeriod=e instanceof r?e:new r(e),this}get tokenMemo(){return this._tokenMemo}setTokenMemo(e){return this._requireNotFrozen(),this._tokenMemo=e,this}get customFees(){return this._customFees}setCustomFees(e){return this._customFees=e,this}get tokenType(){return this._tokenType}setTokenType(e){return this._tokenType=e,this}get supplyType(){return this._supplyType}setSupplyType(e){return this._supplyType=e,this}get maxSupply(){return this._maxSupply}setMaxSupply(e){return this._maxSupply="number"==typeof e?i.fromNumber(e):e,this}get metadataKey(){return this._metadataKey}setMetadataKey(e){return this._requireNotFrozen(),this._metadataKey=e,this}get metadata(){return this._metadata}setMetadata(e){return this._requireNotFrozen(),this._metadata=e,this}_validateChecksums(e){null!=this._treasuryAccountId&&this._treasuryAccountId.validateChecksum(e),null!=this._autoRenewAccountId&&this._autoRenewAccountId.validateChecksum(e)}_execute(e,t){return e.token.createToken(t)}_getTransactionDataCase(){return"tokenCreation"}_makeTransactionData(){return{name:this._tokenName,symbol:this._tokenSymbol,decimals:null!=this._decimals?this._decimals.toInt():null,initialSupply:this._initialSupply,treasury:null!=this._treasuryAccountId?this._treasuryAccountId._toProtobuf():null,adminKey:null!=this._adminKey?this._adminKey._toProtobufKey():null,kycKey:null!=this._kycKey?this._kycKey._toProtobufKey():null,freezeKey:null!=this._freezeKey?this._freezeKey._toProtobufKey():null,pauseKey:null!=this._pauseKey?this._pauseKey._toProtobufKey():null,wipeKey:null!=this._wipeKey?this._wipeKey._toProtobufKey():null,supplyKey:null!=this._supplyKey?this._supplyKey._toProtobufKey():null,feeScheduleKey:null!=this._feeScheduleKey?this._feeScheduleKey._toProtobufKey():null,freezeDefault:this._freezeDefault,autoRenewAccount:null!=this._autoRenewAccountId?this._autoRenewAccountId._toProtobuf():null,expiry:null!=this._expirationTime?this._expirationTime._toProtobuf():null,autoRenewPeriod:null!=this._autoRenewPeriod?this._autoRenewPeriod._toProtobuf():null,memo:this._tokenMemo,customFees:this.customFees.map((e=>e._toProtobuf())),tokenType:null!=this._tokenType?this._tokenType._code:null,supplyType:null!=this._supplyType?this._supplyType._code:null,maxSupply:this.maxSupply,metadataKey:null!=this._metadataKey?this._metadataKey._toProtobufKey():null,metadata:null!=this._metadata?this._metadata:void 0}}_getLogId(){return`TokenCreateTransaction:${this._transactionIds.current.validStart.toString()}`}}o.set("tokenCreation",_._fromProtobuf);export{_ as default};
//# sourceMappingURL=TokenCreateTransaction.js.map