Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transaction failure reason update #1283

Merged
merged 8 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions bindings/nodejs/lib/types/models/block-metadata.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2023 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

import type { ConflictReason } from './conflict-reason';
import type { TransactionFailureReason } from './transaction-failure-reason';
import type { HexEncodedString } from '../utils/hex-encoding';
import type { LedgerInclusionState } from './ledger-inclusion-state';
/**
Expand Down Expand Up @@ -33,9 +33,9 @@ export interface IBlockMetadata {
*/
ledgerInclusionState?: LedgerInclusionState;
/**
* The conflict reason.
* The transaction failure reason.
*/
conflictReason?: ConflictReason;
transactionFailureReason?: TransactionFailureReason;
/**
* Should the block be promoted.
*/
Expand Down
91 changes: 0 additions & 91 deletions bindings/nodejs/lib/types/models/conflict-reason.ts

This file was deleted.

2 changes: 1 addition & 1 deletion bindings/nodejs/lib/types/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
export * from './api';
export * from './info';

export * from './conflict-reason';
export * from './transaction-failure-reason';
export * from './block-metadata';
export * from './gossip-metrics';
export * from './gossip-heartbeat';
Expand Down
170 changes: 170 additions & 0 deletions bindings/nodejs/lib/types/models/transaction-failure-reason.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
// Copyright 2023 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

/**
* Reason for transaction failure..
Thoralf-M marked this conversation as resolved.
Show resolved Hide resolved
*/
export enum TransactionFailureReason {
/**
* The referenced UTXO was already spent.
*/
inputUTXOAlreadySpent = 1,

/**
* The transaction is conflicting with another transaction.
* Conflicting specifically means a double spend situation that both transactions pass all validation rules,
* eventually losing one(s) should have this reason.
*/
conflictingWithAnotherTx = 2,

/**
* The referenced UTXO is invalid.
*/
invalidReferencedUtxo = 3,

/**
* The transaction is invalid.
*/
invalidTransaction = 4,

/**
* The sum of the inputs and output base token amount does not match.
*/
sumInputsOutputsAmountMismatch = 5,

/**
* The unlock block signature is invalid.
*/
invalidUnlockBlockSignature = 6,

/**
* The configured timelock is not yet expired.
*/
timelockNotExpired = 7,

/**
* The given native tokens are invalid.
*/
invalidNativeTokens = 8,

/**
* The return amount in a transaction is not fulfilled by the output side.
*/
storageDepositReturnUnfulfilled = 9,

/**
* An input unlock was invalid.
*/
invalidInputUnlock = 10,

/**
* The inputs commitment is invalid.
*/
invalidInputsCommitment = 11,

/**
* The output contains a Sender with an ident (address) which is not unlocked.
*/
senderNotUnlocked = 12,

/**
* The chain state transition is invalid.
*/
invalidChainStateTransition = 13,

/**
* The referenced input is created after transaction issuing time.
*/
invalidTransactionIssuingTime = 14,

/**
* The mana amount is invalid.
*/
invalidManaAmount = 15,

/**
* The Block Issuance Credits amount is invalid.
*/
invalidBlockIssuanceCreditsAmount = 16,

/**
* Reward Context Input is invalid.
*/
invalidRewardContextInput = 17,

/**
* Commitment Context Input is invalid.
*/
invalidCommitmentContextInput = 18,

/**
* Staking Feature is not provided in account output when claiming rewards.
*/
missingStakingFeature = 19,

/**
* Failed to claim staking reward.
*/
failedToClaimStakingReward = 20,

/**
* Failed to claim delegation reward.
*/
failedToClaimDelegationReward = 21,

/**
* The semantic validation failed for a reason not covered by the previous variants.
*/
semanticValidationFailed = 255,
}

/**
* Transaction failure reason strings.
*/
export const TRANSACTION_FAILURE_REASON_STRINGS: {
[key in TransactionFailureReason]: string;
} = {
[TransactionFailureReason.inputUTXOAlreadySpent]:
'The referenced UTXO was already spent.',
[TransactionFailureReason.conflictingWithAnotherTx]:
'The transaction is conflicting with another transaction. Conflicting specifically means a double spend situation that both transactions pass all validation rules, eventually losing one(s) should have this reason.',
[TransactionFailureReason.invalidReferencedUtxo]:
'The referenced UTXO is invalid.',
[TransactionFailureReason.invalidTransaction]:
'The transaction is invalid.',
[TransactionFailureReason.sumInputsOutputsAmountMismatch]:
'The sum of the inputs and output base token amount does not match.',
[TransactionFailureReason.invalidUnlockBlockSignature]:
'The unlock block signature is invalid.',
[TransactionFailureReason.timelockNotExpired]:
'The configured timelock is not yet expired.',
[TransactionFailureReason.invalidNativeTokens]:
'The given native tokens are invalid.',
[TransactionFailureReason.storageDepositReturnUnfulfilled]:
'The return amount in a transaction is not fulfilled by the output side.',
[TransactionFailureReason.invalidInputUnlock]:
'An input unlock was invalid.',
[TransactionFailureReason.invalidInputsCommitment]:
'The inputs commitment is invalid.',
[TransactionFailureReason.senderNotUnlocked]:
'The output contains a Sender with an ident (address) which is not unlocked.',
[TransactionFailureReason.invalidChainStateTransition]:
'The chain state transition is invalid.',
[TransactionFailureReason.invalidTransactionIssuingTime]:
'The referenced input is created after transaction issuing time.',
[TransactionFailureReason.invalidManaAmount]: 'The mana amount is invalid.',
[TransactionFailureReason.invalidBlockIssuanceCreditsAmount]:
'The Block Issuance Credits amount is invalid.',
[TransactionFailureReason.invalidRewardContextInput]:
'Reward Context Input is invalid.',
[TransactionFailureReason.invalidCommitmentContextInput]:
'Commitment Context Input is invalid.',
[TransactionFailureReason.missingStakingFeature]:
'Staking Feature is not provided in account output when claiming rewards.',
[TransactionFailureReason.failedToClaimStakingReward]:
'Failed to claim staking reward.',
[TransactionFailureReason.failedToClaimDelegationReward]:
'Failed to claim delegation reward.',
[TransactionFailureReason.semanticValidationFailed]:
'The semantic validation failed for a reason not covered by the previous variants.',
};
Loading