Skip to content

Commit

Permalink
fix: use algosdk functions when getting equivalent types from strings
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-makerx committed Jun 14, 2023
1 parent 795da41 commit c2158a6
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions src/client/helpers/get-equivalent-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<SendTransactionResult>'
if (abiTypeStr == 'void') {
return 'void'
}
if (abiTypeIsTransaction(abiTypeStr)) {
return 'TransactionToSign | Transaction | Promise<SendTransactionResult>'
}
if (abiTypeIsReference(abiTypeStr)) {
return 'number | bigint'
}

const abiType = ABIType.from(abiTypeStr)
Expand Down

0 comments on commit c2158a6

Please sign in to comment.