cnft-degn-oracle-sdk
v1.1.0
Published
SDK for CNFT Oracle Degn Backoffice
Maintainers
Readme
CNFT Oracle Degn Backoffice SDK
A TypeScript SDK for interacting with the CNFT Oracle Degn Backoffice Solana program.
🚀 Installation
npm install cnft-degn-backoffice-sdk
# or
yarn add cnft-degn-backoffice-sdk📦 Features
- Oracle Management: Create and update oracle validation rules
- Recipient Management: Add, update, and delete recipients with automatic PDA detection
- TypeScript Support: Full TypeScript support with generated types from Anchor IDL
- Solana Integration: Built on top of
@solana/web3.jsand@coral-xyz/anchor
🔧 Usage
Basic Setup
import { CnftOracleDegnClient } from 'cnft-degn-backoffice-sdk';
import { Connection, Keypair } from '@solana/web3.js';
// Create connection and wallet
const connection = new Connection('https://api.devnet.solana.com');
const wallet = Keypair.generate(); // Your wallet keypair
// Create client
const client = new CnftOracleDegnClient(connection, wallet);
// Load IDL (required before using)
await client.loadIdl();Create Oracle
import { OracleValidation } from 'cnft-degn-backoffice-sdk';
const validation: OracleValidation = {
v1: {
transfer: { approved: {} },
create: { approved: {} },
update: { approved: {} },
burn: { approved: {} }
}
};
const createOracleIx = client.createOracleIx();
// Add to transaction and sendAdd or Update Recipient
import { ExternalValidationResult } from 'cnft-degn-backoffice-sdk';
const recipient = new PublicKey('...');
const status: ExternalValidationResult = { approved: {} };
// Automatically detects if PDA exists and returns appropriate instruction
const addOrUpdateRecipientIx = await client.addOrUpdateRecipientIx(recipient, status);
// Add to transaction and sendUpdate Oracle
const newValidation: OracleValidation = {
v1: {
transfer: { rejected: {} },
create: { approved: {} },
update: { pass: {} },
burn: { approved: {} }
}
};
const updateOracleIx = client.updateOracleIx(newValidation);
// Add to transaction and sendDelete Recipient
const recipient = new PublicKey('...');
const deleteRecipientIx = client.deleteRecipientIx(recipient);
// Add to transaction and send🏗️ Architecture
The SDK follows a clean architecture pattern:
- Client Layer:
CnftOracleDegnClient- Main interface for program interactions - Instruction Layer: Returns
TransactionInstructionobjects for transaction building - IDL Integration: Uses generated types from Anchor IDL for type safety
- PDA Management: Automatic Program Derived Address generation and detection
🔑 Key Methods
| Method | Returns | Description |
|--------|---------|-------------|
| createOracleIx() | TransactionInstruction | Creates oracle instruction |
| updateOracleIx(validation) | TransactionInstruction | Updates oracle validation |
| addOrUpdateRecipientIx(recipient, status) | Promise<TransactionInstruction> | Smart add/update recipient |
| deleteRecipientIx(recipient) | TransactionInstruction | Deletes recipient |
📋 Requirements
- Node.js >= 16.0.0
- Solana Web3.js ^1.91.0
- Anchor ^0.31.1
🤝 Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
📄 License
This project is licensed under the UNLICENSED License - see the LICENSE file for details.
🆘 Support
For support, please open an issue on GitHub or contact the development team.
Built with ❤️ by Synesis
