@rialo/ts-cdk 0.1.10 → 0.2.0-alpha.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 +62 -0
- package/dist/index.d.mts +1979 -770
- package/dist/index.d.ts +1979 -770
- package/dist/index.js +7095 -4576
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7059 -4577
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -216,6 +216,30 @@ const airdropResult = await client.requestAirdropAndConfirm(
|
|
|
216
216
|
publicKey,
|
|
217
217
|
1_000_000_000n
|
|
218
218
|
);
|
|
219
|
+
|
|
220
|
+
// Get minimum balance for rent exemption
|
|
221
|
+
const minBalance = await client.getMinimumBalanceForRentExemption(128);
|
|
222
|
+
|
|
223
|
+
// Get fee for a message
|
|
224
|
+
const fee = await client.getFeeForMessage(base64Message);
|
|
225
|
+
|
|
226
|
+
// Batch query multiple accounts
|
|
227
|
+
const accounts = await client.getMultipleAccounts([pubkey1, pubkey2]);
|
|
228
|
+
|
|
229
|
+
// Get accounts by owner/program with pagination
|
|
230
|
+
const result = await client.getAccountsByOwner(programId, { type: "programAccounts" });
|
|
231
|
+
|
|
232
|
+
// Workflow lineage traversal
|
|
233
|
+
const lineage = await client.getWorkflowLineage({
|
|
234
|
+
signature: rootTxSignature,
|
|
235
|
+
maxDepth: 5,
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
// Get subscription for an account and nonce
|
|
239
|
+
const sub = await client.getSubscription(accountPubkey, "my-nonce");
|
|
240
|
+
|
|
241
|
+
// Get transactions triggered by a subscription
|
|
242
|
+
const triggered = await client.getTriggeredTransactions(subscriptionPubkey);
|
|
219
243
|
```
|
|
220
244
|
|
|
221
245
|
### Signers
|
|
@@ -245,6 +269,44 @@ class CustomSigner implements Signer {
|
|
|
245
269
|
|
|
246
270
|
## Advanced Features
|
|
247
271
|
|
|
272
|
+
### Program Derived Addresses (PDAs)
|
|
273
|
+
|
|
274
|
+
PDAs are deterministic addresses derived from seeds and a program ID. They are off the Ed25519 curve, meaning no private key exists for them - only the program can sign on their behalf.
|
|
275
|
+
|
|
276
|
+
```typescript
|
|
277
|
+
import { PublicKey } from "@rialo/ts-cdk";
|
|
278
|
+
|
|
279
|
+
// Find a PDA with automatic bump seed discovery
|
|
280
|
+
const [vaultPda, vaultBump] = PublicKey.findProgramAddress(
|
|
281
|
+
["vault", userPubkey.toBytes()],
|
|
282
|
+
programId
|
|
283
|
+
);
|
|
284
|
+
|
|
285
|
+
console.log(`Vault: ${vaultPda}, Bump: ${vaultBump}`);
|
|
286
|
+
|
|
287
|
+
// Create PDA with known bump (more efficient for verification)
|
|
288
|
+
const pda = PublicKey.createProgramAddress(
|
|
289
|
+
["metadata", mintPubkey.toBytes(), new Uint8Array([254])],
|
|
290
|
+
metadataProgramId
|
|
291
|
+
);
|
|
292
|
+
|
|
293
|
+
// Create derived address from base key (CAN be on curve)
|
|
294
|
+
const derivedAddress = PublicKey.createWithSeed(
|
|
295
|
+
userPubkey,
|
|
296
|
+
"savings-account",
|
|
297
|
+
systemProgramId
|
|
298
|
+
);
|
|
299
|
+
|
|
300
|
+
// Check if an address is on the Ed25519 curve
|
|
301
|
+
const isOnCurve = pubkey.isOnCurve();
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
**Seed Constraints:**
|
|
305
|
+
|
|
306
|
+
- Maximum 16 seeds per derivation
|
|
307
|
+
- Each seed maximum 32 bytes
|
|
308
|
+
- Seeds can be strings (UTF-8 encoded) or `Uint8Array`
|
|
309
|
+
|
|
248
310
|
### Hierarchical Deterministic Wallets
|
|
249
311
|
|
|
250
312
|
The SDK uses SLIP-0010 for Ed25519 key derivation with BIP44 paths.
|