@hyr0-xyz/client-js 0.0.1 → 0.0.2
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 +96 -107
- package/dist/index.d.ts +5838 -5039
- package/dist/index.js +10268 -9511
- package/dist/index.js.map +1 -1
- package/package.json +5 -6
package/README.md
CHANGED
|
@@ -1,152 +1,141 @@
|
|
|
1
|
-
# @hyr0-xyz/
|
|
1
|
+
# @hyr0-xyz/client-js
|
|
2
2
|
|
|
3
|
-
TypeScript
|
|
3
|
+
Auto-generated TypeScript client for Hyro Protocol programs. This package contains Codama-generated artifacts exported as an npm module.
|
|
4
|
+
|
|
5
|
+
## Packages
|
|
6
|
+
|
|
7
|
+
This repository publishes two separate packages:
|
|
8
|
+
|
|
9
|
+
- **@hyr0-xyz/client-js** - For mainnet/devnet deployment with production program addresses
|
|
10
|
+
- **@hyr0-xyz/client-js-local** - For local development with local program addresses
|
|
4
11
|
|
|
5
12
|
## Installation
|
|
6
13
|
|
|
14
|
+
**For production/mainnet:**
|
|
7
15
|
```bash
|
|
8
|
-
npm install @hyr0-xyz/
|
|
16
|
+
npm install @hyr0-xyz/client-js @solana/kit
|
|
9
17
|
# or
|
|
10
|
-
yarn add @hyr0-xyz/
|
|
18
|
+
yarn add @hyr0-xyz/client-js @solana/kit
|
|
11
19
|
# or
|
|
12
|
-
pnpm add @hyr0-xyz/
|
|
20
|
+
pnpm add @hyr0-xyz/client-js @solana/kit
|
|
13
21
|
```
|
|
14
22
|
|
|
15
|
-
|
|
23
|
+
**For local development:**
|
|
24
|
+
```bash
|
|
25
|
+
npm install @hyr0-xyz/client-js-local @solana/kit
|
|
26
|
+
# or
|
|
27
|
+
yarn add @hyr0-xyz/client-js-local @solana/kit
|
|
28
|
+
# or
|
|
29
|
+
pnpm add @hyr0-xyz/client-js-local @solana/kit
|
|
30
|
+
```
|
|
16
31
|
|
|
17
|
-
|
|
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
|
|
32
|
+
## What's Inside
|
|
22
33
|
|
|
23
|
-
|
|
34
|
+
This package contains auto-generated code for:
|
|
24
35
|
|
|
25
|
-
|
|
36
|
+
- **Instructions**: Functions to create program instructions
|
|
37
|
+
- **Accounts**: Type definitions and fetch helpers for program accounts
|
|
38
|
+
- **Types**: All custom types used by the programs
|
|
39
|
+
- **Errors**: Program error definitions
|
|
40
|
+
- **PDAs**: Helper functions for deriving Program Derived Addresses
|
|
26
41
|
|
|
27
|
-
|
|
28
|
-
import { VaultSDK } from '@hyr0-xyz/program';
|
|
29
|
-
import { createSolanaRpc } from '@solana/kit';
|
|
42
|
+
## Available Programs
|
|
30
43
|
|
|
31
|
-
|
|
32
|
-
const rpc = createSolanaRpc('https://api.mainnet-beta.solana.com');
|
|
44
|
+
The package exports clients for all Hyro Protocol programs:
|
|
33
45
|
|
|
34
|
-
|
|
35
|
-
|
|
46
|
+
- `hyroProtocol` - Core vault and transaction management
|
|
47
|
+
- `policyOwners` - Owner-based policy validation
|
|
48
|
+
- `policyMultisig` - Multisig policy validation
|
|
49
|
+
- `policyManagerAccess` - Manager access control policy
|
|
50
|
+
- `policyLimitTransfer` - Transfer limit policy
|
|
51
|
+
- `policyChallenges` - Trading challenge policy
|
|
52
|
+
- `policyAllowAny` - Permissive policy
|
|
53
|
+
- `policyDenyAll` - Restrictive policy
|
|
54
|
+
- `feeCollection` - Fee collection program
|
|
55
|
+
- `feeCollectionAllInOne` - All-in-one fee collection
|
|
56
|
+
- `feeCollectionFractions` - Fractional fee collection
|
|
57
|
+
- `feeCollectionTimeBased` - Time-based fee collection
|
|
58
|
+
- `dropper` - Airdrop management
|
|
59
|
+
- `revenueGenerator` - Revenue generation
|
|
36
60
|
|
|
37
|
-
|
|
38
|
-
const vault = await VaultSDK.fetch(rpc, vaultPda[0]);
|
|
39
|
-
console.log('Vault data:', vault.data);
|
|
61
|
+
## Usage Example
|
|
40
62
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
```
|
|
63
|
+
```typescript
|
|
64
|
+
import { hyroProtocol } from '@hyr0-xyz/client-js';
|
|
65
|
+
import { createSolanaRpc } from '@solana/kit';
|
|
45
66
|
|
|
46
|
-
|
|
67
|
+
// Get RPC connection
|
|
68
|
+
const rpc = createSolanaRpc('https://api.mainnet-beta.solana.com');
|
|
47
69
|
|
|
48
|
-
|
|
49
|
-
|
|
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,
|
|
70
|
+
// Use generated instruction builders
|
|
71
|
+
const instruction = hyroProtocol.getInitializeVaultInstruction({
|
|
72
|
+
// ... instruction parameters
|
|
74
73
|
});
|
|
75
74
|
|
|
76
|
-
//
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
transaction: transactionPda[0],
|
|
80
|
-
policyAccount: 'PolicyAccount...',
|
|
81
|
-
policyProgram: 'PolicyProgram...',
|
|
82
|
-
signer: yourSigner,
|
|
83
|
-
});
|
|
75
|
+
// Fetch account data
|
|
76
|
+
const vaultAddress = '...';
|
|
77
|
+
const vault = await hyroProtocol.fetchVault(rpc, vaultAddress);
|
|
84
78
|
```
|
|
85
79
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
```typescript
|
|
89
|
-
import { getVaultPda, getTransactionPda, getShareSignerPda } from '@hyr0-xyz/program';
|
|
90
|
-
|
|
91
|
-
// Get vault and authority PDAs
|
|
92
|
-
const [vault, authority] = await getVaultPda('my-seed');
|
|
80
|
+
## Generation
|
|
93
81
|
|
|
94
|
-
|
|
95
|
-
const txPda = await getTransactionPda(vault, 1);
|
|
82
|
+
The packages are automatically generated from the parent repository's Anchor programs:
|
|
96
83
|
|
|
97
|
-
|
|
98
|
-
|
|
84
|
+
**For mainnet/devnet (production):**
|
|
85
|
+
```bash
|
|
86
|
+
# From repository root
|
|
87
|
+
cd ..
|
|
88
|
+
anchor build -- --features mainnet
|
|
89
|
+
cd client-js
|
|
90
|
+
bun create-codama-client.ts
|
|
91
|
+
bun run build
|
|
99
92
|
```
|
|
100
93
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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.
|
|
94
|
+
**For local development:**
|
|
95
|
+
```bash
|
|
96
|
+
# From repository root
|
|
97
|
+
cd ..
|
|
98
|
+
anchor build
|
|
99
|
+
cd client-js
|
|
100
|
+
bun create-codama-client.ts
|
|
101
|
+
bun run build
|
|
102
|
+
```
|
|
119
103
|
|
|
120
|
-
|
|
121
|
-
Build an instruction to initialize a new vault.
|
|
104
|
+
The generation process:
|
|
122
105
|
|
|
123
|
-
|
|
106
|
+
1. Builds all Anchor programs at repository root to generate IDL files (with or without `--features mainnet`)
|
|
107
|
+
2. Reads IDL files from `../target/idl/`
|
|
108
|
+
3. Uses Codama to generate TypeScript clients
|
|
109
|
+
4. Outputs generated code to `src/`
|
|
124
110
|
|
|
125
|
-
|
|
126
|
-
Get transaction PDA from vault and nonce.
|
|
111
|
+
## Publishing
|
|
127
112
|
|
|
128
|
-
|
|
129
|
-
Fetch transaction account data from the blockchain.
|
|
113
|
+
Both packages are automatically published to NPM via GitHub Actions (at repository root `.github/workflows/publish-client-js.yml`) when changes are pushed to the `main` branch:
|
|
130
114
|
|
|
131
|
-
|
|
132
|
-
|
|
115
|
+
1. **Mainnet job**: Builds Anchor programs with mainnet feature → Generates client → Publishes `@hyr0-xyz/client-js`
|
|
116
|
+
2. **Local job**: Builds Anchor programs for localnet → Generates client → Publishes `@hyr0-xyz/client-js-local`
|
|
133
117
|
|
|
134
|
-
|
|
135
|
-
|
|
118
|
+
The workflow is triggered on changes to:
|
|
119
|
+
- `programs/**`
|
|
120
|
+
- `client-js/**`
|
|
121
|
+
- `Anchor.toml`
|
|
122
|
+
- `Cargo.toml`
|
|
136
123
|
|
|
137
124
|
## Development
|
|
138
125
|
|
|
139
126
|
```bash
|
|
140
127
|
# Install dependencies
|
|
141
|
-
|
|
128
|
+
bun install
|
|
142
129
|
|
|
143
|
-
# Build
|
|
144
|
-
|
|
130
|
+
# Build package only (assumes IDL already generated)
|
|
131
|
+
bun run build
|
|
145
132
|
|
|
146
|
-
#
|
|
147
|
-
|
|
133
|
+
# Watch mode for development
|
|
134
|
+
bun run dev
|
|
148
135
|
```
|
|
149
136
|
|
|
137
|
+
**Note:** For generation, use the commands from the "Generation" section above, as they require building the entire Anchor workspace from the repository root.
|
|
138
|
+
|
|
150
139
|
## License
|
|
151
140
|
|
|
152
141
|
ISC
|