Skip to content

get

Plugin for getting and parsing ABIs from Aptos network.

Import

ts
import { get } from '@khizab/cli/plugins'
import { get } from '@khizab/cli/plugins'

Usage

ts
import { defineConfig } from '@khizab/cli'
import { get } from '@khizab/cli/plugins'

export default defineConfig({
  plugins: [
    get({
      contracts: [
        {
          address: '0x99f1f75c37ad8f455c4af147494c49d8122e37bb5b7544d4b320ddb1c9a9106d',
          module: 'increase',
        },
      ],
    }),
  ],
})
import { defineConfig } from '@khizab/cli'
import { get } from '@khizab/cli/plugins'

export default defineConfig({
  plugins: [
    get({
      contracts: [
        {
          address: '0x99f1f75c37ad8f455c4af147494c49d8122e37bb5b7544d4b320ddb1c9a9106d',
          module: 'increase',
        },
      ],
    }),
  ],
})

Configuration

network

Network.TESTNET | Network.MAINNET | Network.DEVNET | undefined

  • Network to get ABIs from
  • Defaults to 'Network.MAINNET'.
ts
import { defineConfig, Network } from '@khizab/cli' 
import { get } from '@khizab/cli/plugins'

export default defineConfig({
  plugins: [
    get({
      network:  Network.TESTNET, 
      contracts: [
        {
          address: '0x99f1f75c37ad8f455c4af147494c49d8122e37bb5b7544d4b320ddb1c9a9106d',
          module: 'increase',
        },
      ]
    }),
  ],
})
import { defineConfig, Network } from '@khizab/cli' 
import { get } from '@khizab/cli/plugins'

export default defineConfig({
  plugins: [
    get({
      network:  Network.TESTNET, 
      contracts: [
        {
          address: '0x99f1f75c37ad8f455c4af147494c49d8122e37bb5b7544d4b320ddb1c9a9106d',
          module: 'increase',
        },
      ]
    }),
  ],
})
ts
import { type GetConfig } from '@khizab/cli/plugins'
import { type GetConfig } from '@khizab/cli/plugins'

cacheDuration

number | undefined

  • Duration in milliseconds to cache ABIs.
  • Defaults to 1_800_000 (30 minutes).
ts
import { defineConfig } from '@khizab/cli'
import { get } from '@khizab/cli/plugins'

export default defineConfig({
  plugins: [
    get({
      cacheDuration: 300_000, 
      contracts: [
        {
          address: '0x99f1f75c37ad8f455c4af147494c49d8122e37bb5b7544d4b320ddb1c9a9106d',
          module: 'increase',
        },
      ],
    }),
  ],
})
import { defineConfig } from '@khizab/cli'
import { get } from '@khizab/cli/plugins'

export default defineConfig({
  plugins: [
    get({
      cacheDuration: 300_000, 
      contracts: [
        {
          address: '0x99f1f75c37ad8f455c4af147494c49d8122e37bb5b7544d4b320ddb1c9a9106d',
          module: 'increase',
        },
      ],
    }),
  ],
})

contracts

{ name?: string; address: 0x${string}; module: string }[]

name is optional, use it if you want to override the module name in generated code

Contracts to get ABIs for.

ts
import { defineConfig } from '@khizab/cli'
import { get } from '@khizab/cli/plugins'

export default defineConfig({
  plugins: [
    get({
      contracts: [ 
        { 
          name: 'inc', //optional 
          address: '0x99f1f75c37ad8f455c4af147494c49d8122e37bb5b7544d4b320ddb1c9a9106d', 
          module: 'increase', 
        }, 
      ], 
    }),
  ],
})
import { defineConfig } from '@khizab/cli'
import { get } from '@khizab/cli/plugins'

export default defineConfig({
  plugins: [
    get({
      contracts: [ 
        { 
          name: 'inc', //optional 
          address: '0x99f1f75c37ad8f455c4af147494c49d8122e37bb5b7544d4b320ddb1c9a9106d', 
          module: 'increase', 
        }, 
      ], 
    }),
  ],
})

getCacheKey

((config: { contract: { address: name?: string, address: 0x${string}, module: string } }) => string) | undefined

  • Function for creating a cache key for contract. Contract data is cached at ~/.khizab-cli/plugins/get/cache/.
  • Defaults to ${contract.address}__${contract.module}${contract.name ? __${contract.name} : ''}.
ts
import { defineConfig } from '@khizab/cli'
import { get } from '@khizab/cli/plugins'

export default defineConfig({
  plugins: [
    get({
      contracts: [
        {
          address: '0x99f1f75c37ad8f455c4af147494c49d8122e37bb5b7544d4b320ddb1c9a9106d',
          module: 'increase',
        },
      ],
      getCacheKey({ contract }) { 
        return `${contract.address}:${contract.module}` 
      }, 
    }),
  ],
})
import { defineConfig } from '@khizab/cli'
import { get } from '@khizab/cli/plugins'

export default defineConfig({
  plugins: [
    get({
      contracts: [
        {
          address: '0x99f1f75c37ad8f455c4af147494c49d8122e37bb5b7544d4b320ddb1c9a9106d',
          module: 'increase',
        },
      ],
      getCacheKey({ contract }) { 
        return `${contract.address}:${contract.module}` 
      }, 
    }),
  ],
})

name

string

  • Name of your collection.
  • Defaults to 'Get'.
ts
import { defineConfig } from '@khizab/cli'
import { get } from '@khizab/cli/plugins'

export default defineConfig({
  plugins: [
    get({
      contracts: [
        {
          address: '0x99f1f75c37ad8f455c4af147494c49d8122e37bb5b7544d4b320ddb1c9a9106d',
          module: 'increase',
        },
      ],
      name: 'FooApp', 
    }),
  ],
})
import { defineConfig } from '@khizab/cli'
import { get } from '@khizab/cli/plugins'

export default defineConfig({
  plugins: [
    get({
      contracts: [
        {
          address: '0x99f1f75c37ad8f455c4af147494c49d8122e37bb5b7544d4b320ddb1c9a9106d',
          module: 'increase',
        },
      ],
      name: 'FooApp', 
    }),
  ],
})

Released under the MIT License.