Skip to content

CurvhexORM

The entry point class. Wires your model definitions to a query adapter and exposes per-model clients via orm.models.

Constructor

typescript
new CurvhexORM(options: CurvhexORMOptions)

Options

OptionTypeRequiredDescription
connectionConnectionSolana Connection from @solana/web3.js
programIdstring | PublicKeyYour program's public key
modelsRecord<string, ModelDefinition>Schema definitions
adapterQueryAdapterDefaults to RpcAdapter(connection)

Example

typescript
import { CurvhexORM } from '@curvhex/orm'
import { Connection, PublicKey } from '@solana/web3.js'

const orm = new CurvhexORM({
  connection: new Connection('https://api.mainnet-beta.solana.com'),
  programId:  new PublicKey('YOUR_PROGRAM_ID'),
  models: {
    UserAccount,
    VaultAccount,
  },
})

orm.models

A record of model clients, keyed by camelCase model name. Each client exposes the full query API.

typescript
orm.models.userAccount   // CurvhexClient<typeof UserAccount>
orm.models.vaultAccount  // CurvhexClient<typeof VaultAccount>

Model names are derived from the key passed in models:

typescript
models: {
  UserAccount: UserAccountDef,  // → orm.models.userAccount (camelCase)
}

With a Custom Adapter

typescript
import { HeliusAdapter } from '@curvhex/orm/adapters'

const orm = new CurvhexORM({
  connection,
  programId: 'YOUR_PROGRAM_ID',
  models:    { UserAccount },
  adapter:   new HeliusAdapter({ apiKey: 'YOUR_KEY' }),
})

Released under the Apache 2.0 License.