Skip to content

Commit

Permalink
refactor: fix moved to pascalToSnake
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippeR26 committed Aug 29, 2023
1 parent c871fe6 commit 84aa539
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
8 changes: 2 additions & 6 deletions src/provider/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -457,12 +457,8 @@ export class RpcProvider implements ProviderInterface {
txReceipt = await this.getTransactionReceipt(txHash);

// TODO: Hotfix until Pathfinder release fixed casing
let executionStatus = txReceipt.execution_status;
let finalityStatus = txReceipt.finality_status;
if (/[a-z]/.test(txReceipt.execution_status)) {
executionStatus = pascalToSnake(txReceipt.execution_status);
finalityStatus = pascalToSnake(txReceipt.finality_status);
}
const executionStatus = pascalToSnake(txReceipt.execution_status);
const finalityStatus = pascalToSnake(txReceipt.finality_status);

if (!executionStatus || !finalityStatus) {
// Transaction is potentially REJECTED or NOT_RECEIVED but RPC doesn't have dose statuses
Expand Down
10 changes: 6 additions & 4 deletions src/utils/encode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ export function utf8ToArray(str: string): Uint8Array {
* @returns string
*/
export const pascalToSnake = (text: string) =>
text
.split(/(?=[A-Z])/)
.join('_')
.toUpperCase();
!/[a-z]/.test(text)
? text
.split(/(?=[A-Z])/)
.join('_')
.toUpperCase()
: text;

0 comments on commit 84aa539

Please sign in to comment.