Skip to content

Commit

Permalink
Merge pull request #27 from algorandfoundation/fix/use-algosdk-for-ab…
Browse files Browse the repository at this point in the history
…i-type

fix: use algosdk functions when getting equivalent types from strings
  • Loading branch information
robdmoore authored Jun 14, 2023
2 parents 795da41 + c2158a6 commit 4f40805
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 4f40805

Please sign in to comment.