Skip to content

Commit

Permalink
build: Fixing linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
robdmoore committed Oct 8, 2024
1 parent 867375e commit 8d13a60
Show file tree
Hide file tree
Showing 11 changed files with 562 additions and 198 deletions.
706 changes: 534 additions & 172 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
},
"overrides": {
"semver": "7.5.2",
"eslint-plugin-prettier": "5.0.0",
"braces": "3.0.3",
"micromatch": "4.0.8"
},
Expand All @@ -73,16 +72,18 @@
"@rollup/plugin-commonjs": "^28.0.0",
"@rollup/plugin-node-resolve": "^15.3.0",
"@rollup/plugin-typescript": "^12.1.0",
"@tsconfig/node18": "^18.2.2",
"@tsconfig/node20": "^20.1.4",
"@types/uuid": "^10.0.0",
"@typescript-eslint/eslint-plugin": "^8.8.1",
"@vitest/coverage-v8": "^2.1.2",
"algosdk": "^3.0.0",
"better-npm-audit": "^3.11.0",
"conventional-changelog-conventionalcommits": "8.0.0",
"cpy-cli": "^5.0.0",
"dotenv-cli": "^7.4.2",
"eslint": "^9.11.1",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"fast-glob": "^3.3.2",
"magic-string": "^0.30.11",
"npm-run-all": "^4.1.5",
Expand Down
11 changes: 2 additions & 9 deletions src/network-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ export function getAlgoClient(config?: AlgoClientConfig): Algodv2 {
* Returns an indexer SDK client that automatically retries transient failures on idempotent calls
*
* @param config The config if you want to override the default (getting config from process.env)
* @param overrideIntDecoding Override the default int decoding for responses, uses MIXED by default to avoid lost precision for big integers
* @example Default (load from environment variables)
*
* ```typescript
Expand All @@ -119,15 +118,9 @@ export function getAlgoClient(config?: AlgoClientConfig): Algodv2 {
* const indexer = getAlgoIndexerClient({server: 'http://localhost', port: '8980', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'})
* await indexer.makeHealthCheck().do()
* ```
* @example Override int decoding for responses
* ```typescript
* const indexer = getAlgoIndexerClient(config, IntDecoding.BIGINT)
* ```
*/
export function getAlgoIndexerClient(config?: AlgoClientConfig, overrideIntDecoding?: IntDecoding): Indexer {
return config
? ClientManager.getIndexerClient(config, overrideIntDecoding)
: ClientManager.getIndexerClientFromEnvironment(overrideIntDecoding)
export function getAlgoIndexerClient(config?: AlgoClientConfig): Indexer {
return config ? ClientManager.getIndexerClient(config) : ClientManager.getIndexerClientFromEnvironment()
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/testing/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export async function getTestAccount(

algorand.setSignerFromAccount(account)

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const address = Address.fromString(account.addr.toString()) as any
address.addr = account.addr
address.sk = account.sk
Expand Down
15 changes: 14 additions & 1 deletion src/transaction/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,9 @@ export async function populateAppCallResources(atc: algosdk.AtomicTransactionCom

if (r.boxes || r.extraBoxRefs) throw Error('Unexpected boxes at the transaction level')
if (r.appLocals) throw Error('Unexpected app local at the transaction level')
if (r.assetHoldings) throw Error('Unexpected asset holding at the transaction level')
if (r.assetHoldings)
throw Error('Unexpected asset holding at the transaction level')
// eslint-disable-next-line @typescript-eslint/no-explicit-any
;(group[i].txn as any)['applicationCall'] = {
...group[i].txn.applicationCall,
accounts: [...(group[i].txn?.applicationCall?.accounts ?? []), ...(r.accounts ?? [])],
Expand Down Expand Up @@ -373,12 +375,14 @@ export async function populateAppCallResources(atc: algosdk.AtomicTransactionCom
if (txnIndex > -1) {
if (type === 'assetHolding') {
const { asset } = reference as algosdk.modelsv2.AssetHoldingReference
// eslint-disable-next-line @typescript-eslint/no-explicit-any
;(txns[txnIndex].txn as any)['applicationCall'] = {
...txns[txnIndex].txn.applicationCall,
foreignAssets: [...(txns[txnIndex].txn?.applicationCall?.foreignAssets ?? []), ...[asset]],
} satisfies Partial<ApplicationTransactionFields>
} else {
const { app } = reference as algosdk.modelsv2.ApplicationLocalReference
// eslint-disable-next-line @typescript-eslint/no-explicit-any
;(txns[txnIndex].txn as any)['applicationCall'] = {
...txns[txnIndex].txn.applicationCall,
foreignApps: [...(txns[txnIndex].txn?.applicationCall?.foreignApps ?? []), ...[app]],
Expand Down Expand Up @@ -406,6 +410,7 @@ export async function populateAppCallResources(atc: algosdk.AtomicTransactionCom
if (txnIndex > -1) {
const { account } = reference as algosdk.modelsv2.AssetHoldingReference | algosdk.modelsv2.ApplicationLocalReference

// eslint-disable-next-line @typescript-eslint/no-explicit-any
;(txns[txnIndex].txn as any)['applicationCall'] = {
...txns[txnIndex].txn.applicationCall,
accounts: [...(txns[txnIndex].txn?.applicationCall?.accounts ?? []), ...[account]],
Expand All @@ -427,6 +432,7 @@ export async function populateAppCallResources(atc: algosdk.AtomicTransactionCom
})

if (txnIndex > -1) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
;(txns[txnIndex].txn as any)['applicationCall'] = {
...txns[txnIndex].txn.applicationCall,
boxes: [...(txns[txnIndex].txn?.applicationCall?.boxes ?? []), ...[{ appIndex: app, name } satisfies TransactionBoxReference]],
Expand Down Expand Up @@ -465,11 +471,13 @@ export async function populateAppCallResources(atc: algosdk.AtomicTransactionCom
}

if (type === 'account') {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
;(txns[txnIndex].txn as any)['applicationCall'] = {
...txns[txnIndex].txn.applicationCall,
accounts: [...(txns[txnIndex].txn?.applicationCall?.accounts ?? []), ...[reference as Address]],
} satisfies Partial<ApplicationTransactionFields>
} else if (type === 'app') {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
;(txns[txnIndex].txn as any)['applicationCall'] = {
...txns[txnIndex].txn.applicationCall,
foreignApps: [
Expand All @@ -479,32 +487,37 @@ export async function populateAppCallResources(atc: algosdk.AtomicTransactionCom
} satisfies Partial<ApplicationTransactionFields>
} else if (type === 'box') {
const { app, name } = reference as algosdk.modelsv2.BoxReference
// eslint-disable-next-line @typescript-eslint/no-explicit-any
;(txns[txnIndex].txn as any)['applicationCall'] = {
...txns[txnIndex].txn.applicationCall,
boxes: [...(txns[txnIndex].txn?.applicationCall?.boxes ?? []), ...[{ appIndex: app, name } satisfies TransactionBoxReference]],
} satisfies Partial<ApplicationTransactionFields>

if (app.toString() !== '0') {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
;(txns[txnIndex].txn as any)['applicationCall'] = {
...txns[txnIndex].txn.applicationCall,
foreignApps: [...(txns[txnIndex].txn?.applicationCall?.foreignApps ?? []), ...[app]],
} satisfies Partial<ApplicationTransactionFields>
}
} else if (type === 'assetHolding') {
const { asset, account } = reference as algosdk.modelsv2.AssetHoldingReference
// eslint-disable-next-line @typescript-eslint/no-explicit-any
;(txns[txnIndex].txn as any)['applicationCall'] = {
...txns[txnIndex].txn.applicationCall,
foreignAssets: [...(txns[txnIndex].txn?.applicationCall?.foreignAssets ?? []), ...[asset]],
accounts: [...(txns[txnIndex].txn?.applicationCall?.accounts ?? []), ...[account]],
} satisfies Partial<ApplicationTransactionFields>
} else if (type === 'appLocal') {
const { app, account } = reference as algosdk.modelsv2.ApplicationLocalReference
// eslint-disable-next-line @typescript-eslint/no-explicit-any
;(txns[txnIndex].txn as any)['applicationCall'] = {
...txns[txnIndex].txn.applicationCall,
foreignApps: [...(txns[txnIndex].txn?.applicationCall?.foreignApps ?? []), ...[app]],
accounts: [...(txns[txnIndex].txn?.applicationCall?.accounts ?? []), ...[account]],
} satisfies Partial<ApplicationTransactionFields>
} else if (type === 'asset') {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
;(txns[txnIndex].txn as any)['applicationCall'] = {
...txns[txnIndex].txn.applicationCall,
foreignAssets: [
Expand Down
1 change: 1 addition & 0 deletions src/types/account-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export class AccountManager {
signer: signer,
}
this._accounts[acc.addr.toString()] = acc
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const addressWithAccount = Address.fromString(acc.addr.toString()) as any
addressWithAccount.account = account
addressWithAccount.addr = acc.addr.toString()
Expand Down
2 changes: 1 addition & 1 deletion src/types/app-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export interface AppClientDeployParams extends AppClientDeployCoreParams, AppCli
schema?: Partial<AppStorageSchema>
}

export interface AppClientCallRawArgs extends RawAppCallArgs {}
export type AppClientCallRawArgs = RawAppCallArgs

export interface AppClientCallABIArgs extends Omit<ABIAppCallArgs, 'method'> {
/** If calling an ABI method then either the name of the method, or the ABI signature */
Expand Down
2 changes: 1 addition & 1 deletion src/types/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export interface AppCallTransactionResultOfType<T> extends SendTransactionResult

/** Result from calling an app */
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface AppCallTransactionResult extends AppCallTransactionResultOfType<ABIReturn> {}
export type AppCallTransactionResult = AppCallTransactionResultOfType<ABIReturn>

/** The return value of an ABI method call */
export type ABIReturn =
Expand Down
1 change: 0 additions & 1 deletion src/types/asset-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { chunkArray } from '../util'
import { AccountAssetInformation } from './account'
import { AlgoKitComposer, CommonTransactionParams, MAX_TRANSACTION_GROUP_SIZE } from './composer'
import { SendParams } from './transaction'
import AssetModel = algosdk.modelsv2.Asset

/** Individual result from performing a bulk opt-in or bulk opt-out for an account against a series of assets. */
export interface BulkAssetOptInOutResult {
Expand Down
12 changes: 3 additions & 9 deletions src/types/client-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,6 @@ export class ClientManager {
* Returns an indexer SDK client that automatically retries on idempotent calls
*
* @param config The config of the client
* @param overrideIntDecoding Override the default int decoding for responses, uses MIXED by default to avoid lost precision for big integers
* @example AlgoNode (testnet)
* ```typescript
* const indexer = ClientManager.getIndexerClient(ClientManager.getAlgoNodeConfig('testnet', 'indexer'))
Expand All @@ -573,12 +572,8 @@ export class ClientManager {
* const indexer = ClientManager.getIndexerClient({server: 'http://localhost', port: '8980', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'})
* await indexer.makeHealthCheck().do()
* ```
* @example Override int decoding for responses
* ```typescript
* const indexer = ClientManager.getIndexerClient(config, IntDecoding.BIGINT)
* ```
*/
public static getIndexerClient(config: AlgoClientConfig, overrideIntDecoding?: IntDecoding): Indexer {
public static getIndexerClient(config: AlgoClientConfig): Indexer {
const { token, server, port } = config
const tokenHeader = typeof token === 'string' ? { 'X-Indexer-API-Token': token } : (token ?? {})
const httpClientWithRetry = new AlgoHttpClientWithRetry(tokenHeader, server, port)
Expand All @@ -588,7 +583,6 @@ export class ClientManager {
/**
* Returns an indexer SDK client that automatically retries on idempotent calls loaded from environment variables (expects to be called from a Node.js environment).
*
* @param overrideIntDecoding Override the default int decoding for responses, uses MIXED by default to avoid lost precision for big integers
* @example
*
* ```typescript
Expand All @@ -597,8 +591,8 @@ export class ClientManager {
* await indexer.makeHealthCheck().do()
* ```
*/
public static getIndexerClientFromEnvironment(overrideIntDecoding?: IntDecoding): Indexer {
return ClientManager.getIndexerClient(ClientManager.getIndexerConfigFromEnvironment(), overrideIntDecoding)
public static getIndexerClientFromEnvironment(): Indexer {
return ClientManager.getIndexerClient(ClientManager.getIndexerConfigFromEnvironment())
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"target": "ES2020",
"moduleResolution": "Bundler",
"esModuleInterop": true,
"types": ["node", "jest"],
"types": ["node"],
"outDir": "dist",
"declaration": true,
"importHelpers": true,
Expand Down

0 comments on commit 8d13a60

Please sign in to comment.