From c2158a6817af206beff511424bc60ef7a05ad8d5 Mon Sep 17 00:00:00 2001 From: Daniel McGregor Date: Wed, 14 Jun 2023 09:33:58 +0800 Subject: [PATCH] fix: use algosdk functions when getting equivalent types from strings --- src/client/helpers/get-equivalent-type.ts | 24 ++++++++++------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/client/helpers/get-equivalent-type.ts b/src/client/helpers/get-equivalent-type.ts index c3c8b08..fbb021a 100644 --- a/src/client/helpers/get-equivalent-type.ts +++ b/src/client/helpers/get-equivalent-type.ts @@ -9,23 +9,19 @@ import { ABIType, ABIUfixedType, ABIUintType, + abiTypeIsReference, + abiTypeIsTransaction, } from 'algosdk' export function getEquivalentType(abiTypeStr: string, ioType: 'input' | 'output'): string { - switch (abiTypeStr) { - case 'void': - return 'void' - case 'asset': - return 'number | bigint' - case 'txn': - case 'pay': - case 'keyreg': - case 'acfg': - case 'axfer': - case 'afrz': - case 'appl': - case 'application': - return 'TransactionToSign | Transaction | Promise' + if (abiTypeStr == 'void') { + return 'void' + } + if (abiTypeIsTransaction(abiTypeStr)) { + return 'TransactionToSign | Transaction | Promise' + } + if (abiTypeIsReference(abiTypeStr)) { + return 'number | bigint' } const abiType = ABIType.from(abiTypeStr)