@hyr0-xyz/program 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,152 @@
1
+ # @hyro/program
2
+
3
+ TypeScript SDK for building dApps on Hyro Protocol. This SDK provides high-level APIs for interacting with Hyro Protocol's Vault and Transaction systems.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @hyro/program @solana/kit
9
+ # or
10
+ yarn add @hyro/program @solana/kit
11
+ # or
12
+ pnpm add @hyro/program @solana/kit
13
+ ```
14
+
15
+ ## Features
16
+
17
+ - **Vault Operations**: Create, fetch, and manage vaults
18
+ - **Transaction Operations**: Create and execute transactions through vaults
19
+ - **PDA Helpers**: Easy-to-use functions for deriving Program Derived Addresses
20
+ - **Type-Safe**: Full TypeScript support with type-safe APIs
21
+ - **Built on @solana/kit**: Uses the latest Solana TypeScript toolkit
22
+
23
+ ## Quick Start
24
+
25
+ ### Vault Operations
26
+
27
+ ```typescript
28
+ import { VaultSDK } from '@hyro/program';
29
+ import { createSolanaRpc } from '@solana/kit';
30
+
31
+ // Get RPC connection
32
+ const rpc = createSolanaRpc('https://api.mainnet-beta.solana.com');
33
+
34
+ // Get vault PDA from seed
35
+ const [vaultPda, authorityPda] = await VaultSDK.getVaultPda('my-vault-seed');
36
+
37
+ // Fetch vault data
38
+ const vault = await VaultSDK.fetch(rpc, vaultPda[0]);
39
+ console.log('Vault data:', vault.data);
40
+
41
+ // Get related PDAs
42
+ const shareSignerPda = await VaultSDK.getShareSignerPda(vaultPda);
43
+ const shareMintPda = await VaultSDK.getShareMintPda(vaultPda);
44
+ ```
45
+
46
+ ### Transaction Operations
47
+
48
+ ```typescript
49
+ import { TransactionSDK } from '@hyro/program';
50
+
51
+ // Get transaction PDA
52
+ const transactionPda = await TransactionSDK.getTransactionPda(vaultPda, 1);
53
+
54
+ // Fetch transaction data
55
+ const transaction = await TransactionSDK.fetch(rpc, transactionPda[0]);
56
+ console.log('Transaction data:', transaction.data);
57
+
58
+ // Build create transaction instruction
59
+ const createTxIx = await TransactionSDK.buildCreateTxInstruction({
60
+ vault: vaultPda[0],
61
+ nonce: 1,
62
+ programId: 'YourProgramId...',
63
+ accounts: [
64
+ {
65
+ pubkey: 'AccountAddress...',
66
+ isSigner: false,
67
+ isWritable: true,
68
+ },
69
+ ],
70
+ data: new Uint8Array([...]),
71
+ policyAccount: 'PolicyAccount...',
72
+ policyProgram: 'PolicyProgram...',
73
+ signer: yourSigner,
74
+ });
75
+
76
+ // Build execute transaction instruction
77
+ const executeTxIx = await TransactionSDK.buildExecuteTxInstruction({
78
+ vault: vaultPda[0],
79
+ transaction: transactionPda[0],
80
+ policyAccount: 'PolicyAccount...',
81
+ policyProgram: 'PolicyProgram...',
82
+ signer: yourSigner,
83
+ });
84
+ ```
85
+
86
+ ### PDA Helpers
87
+
88
+ ```typescript
89
+ import { getVaultPda, getTransactionPda, getShareSignerPda } from '@hyro/program';
90
+
91
+ // Get vault and authority PDAs
92
+ const [vault, authority] = await getVaultPda('my-seed');
93
+
94
+ // Get transaction PDA
95
+ const txPda = await getTransactionPda(vault, 1);
96
+
97
+ // Get share signer PDA
98
+ const shareSigner = await getShareSignerPda(vault);
99
+ ```
100
+
101
+ ## API Reference
102
+
103
+ ### VaultSDK
104
+
105
+ #### `getVaultPda(seed: string)`
106
+ Get vault PDA and authority PDA from a seed string.
107
+
108
+ #### `fetch(rpc, address)`
109
+ Fetch vault account data from the blockchain.
110
+
111
+ #### `getShareSignerPda(vault)`
112
+ Get the share signer PDA for a vault.
113
+
114
+ #### `getShareMintPda(vault)`
115
+ Get the share mint PDA for a vault.
116
+
117
+ #### `getVaultTokenAccountPda(vault, underlyingMint)`
118
+ Get the vault token account PDA.
119
+
120
+ #### `buildInitializeVaultInstruction(params)`
121
+ Build an instruction to initialize a new vault.
122
+
123
+ ### TransactionSDK
124
+
125
+ #### `getTransactionPda(vault, nonce)`
126
+ Get transaction PDA from vault and nonce.
127
+
128
+ #### `fetch(rpc, address)`
129
+ Fetch transaction account data from the blockchain.
130
+
131
+ #### `buildCreateTxInstruction(params)`
132
+ Build an instruction to create a new transaction.
133
+
134
+ #### `buildExecuteTxInstruction(params)`
135
+ Build an instruction to execute a transaction.
136
+
137
+ ## Development
138
+
139
+ ```bash
140
+ # Install dependencies
141
+ npm install
142
+
143
+ # Build
144
+ npm run build
145
+
146
+ # Type check
147
+ npm run typecheck
148
+ ```
149
+
150
+ ## License
151
+
152
+ ISC