Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…to-js into develop
  • Loading branch information
victorholo committed Nov 23, 2022
2 parents afe53f6 + d338119 commit 31c4a29
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/ApiSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export type SessionDefaults = {
emitLiveContractReceipts: boolean;
onlyReceiptsFromContractRequests: boolean;
paymentForContractQuery: number;
tokenCreateTransactionFee: number;
};

const SESSION_CONSTRUCTOR_GUARD = {};
Expand Down
6 changes: 6 additions & 0 deletions lib/StratoContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,12 @@ export class StratoContext {
resolveSessionDefaultValueFor("payment_for_contract_query") ??
"20000000"
),
tokenCreateTransactionFee:
rParams.session?.defaults?.tokenCreateTransactionFee ??
parseInt(
resolveSessionDefaultValueFor("token_create_transaction_fee") ??
"5000000000"
),
};
}
}
16 changes: 16 additions & 0 deletions lib/static/create/Token.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
AccountId,
Hbar,
TokenType as HederaTokenType,
Key,
Timestamp,
Expand Down Expand Up @@ -35,6 +36,7 @@ export type CreateTokenFeatures = TokenFeatures & {
decimals?: number | Long.Long;
customFees?: { feeCollectorAccountId?: string | AccountId | undefined }[];
freezeDefault?: boolean;
maxTransactionFee?: number | Long.Long | Hbar;
};

type TokenKeys = {
Expand Down Expand Up @@ -162,6 +164,20 @@ export class Token extends BasicCreatableEntity<LiveToken> {
const createTokenTransaction = new TokenCreateTransaction(
constructorArgs as unknown
);

let transactionFee: Hbar;
if(this.info.maxTransactionFee) {
transactionFee = this.info.maxTransactionFee instanceof Hbar
? this.info.maxTransactionFee
: new Hbar(this.info.maxTransactionFee)
} else if (session.defaults.tokenCreateTransactionFee > 0) {
transactionFee = Hbar.fromTinybars(
session.defaults.tokenCreateTransactionFee
);
}
if(transactionFee) {
createTokenTransaction.setMaxTransactionFee(transactionFee);
}
const creationReceipt = await session.execute(
createTokenTransaction,
TypeOfExecutionReturn.Receipt,
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 31c4a29

Please sign in to comment.