@rialo/ts-cdk 0.1.2 → 0.1.3
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/dist/index.d.mts +794 -775
- package/dist/index.d.ts +794 -775
- package/dist/index.js +1468 -1538
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1464 -1537
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -135,6 +135,82 @@ declare class RialoError extends Error {
|
|
|
135
135
|
static serialization(message: string): RialoError;
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
+
interface HttpTransportConfig {
|
|
139
|
+
/** Request timeout in milliseconds */
|
|
140
|
+
timeout?: number;
|
|
141
|
+
/** Maximum number of retry attempts */
|
|
142
|
+
maxRetries?: number;
|
|
143
|
+
/** Base delay for exponential backoff (ms) */
|
|
144
|
+
retryBaseDelay?: number;
|
|
145
|
+
/** Maximum retry delay (ms) */
|
|
146
|
+
retryMaxDelay?: number;
|
|
147
|
+
/** Custom headers to include in requests */
|
|
148
|
+
headers?: Record<string, string>;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* HTTP transport with built-in retry logic and timeout handling.
|
|
152
|
+
*
|
|
153
|
+
* Features:
|
|
154
|
+
* - Automatic retries with exponential backoff
|
|
155
|
+
* - Request timeouts using AbortController
|
|
156
|
+
* - Network error recovery
|
|
157
|
+
* - Rate limit handling
|
|
158
|
+
* - Proper HTTP status code handling
|
|
159
|
+
*/
|
|
160
|
+
declare class HttpTransport {
|
|
161
|
+
private readonly url;
|
|
162
|
+
private readonly config;
|
|
163
|
+
constructor(url: string, config?: HttpTransportConfig);
|
|
164
|
+
/**
|
|
165
|
+
* Makes an HTTP request with automatic retry logic.
|
|
166
|
+
*
|
|
167
|
+
* Retries are attempted for network errors and server errors (5xx).
|
|
168
|
+
* Uses exponential backoff between retry attempts.
|
|
169
|
+
*/
|
|
170
|
+
request(body: string, requestDetails?: Record<string, unknown>): Promise<unknown>;
|
|
171
|
+
/**
|
|
172
|
+
* Make a single HTTP request with timeout
|
|
173
|
+
*/
|
|
174
|
+
private makeRequest;
|
|
175
|
+
/**
|
|
176
|
+
* Handle HTTP error responses
|
|
177
|
+
*/
|
|
178
|
+
private handleHttpError;
|
|
179
|
+
/**
|
|
180
|
+
* Returns the configured RPC endpoint URL.
|
|
181
|
+
*/
|
|
182
|
+
getUrl(): string;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
type IdentifierString = `${string}:${string}`;
|
|
186
|
+
type RialoNetwork = "mainnet" | "devnet" | "testnet" | "localnet";
|
|
187
|
+
interface ChainDefinition {
|
|
188
|
+
/** * The Wallet Standard Chain Identifier.
|
|
189
|
+
* e.g., 'rialo:mainnet', 'rialo:devnet'
|
|
190
|
+
*/
|
|
191
|
+
id: IdentifierString;
|
|
192
|
+
/** Human-readable name for UI */
|
|
193
|
+
name: string;
|
|
194
|
+
/** The default RPC URL for this chain */
|
|
195
|
+
rpcUrl: string;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Configuration for the Rialo Client.
|
|
199
|
+
*/
|
|
200
|
+
interface RialoClientConfig {
|
|
201
|
+
/**
|
|
202
|
+
* The Chain Definition.
|
|
203
|
+
* Can be a preset (RIALO_MAINNET) or a custom object.
|
|
204
|
+
*/
|
|
205
|
+
chain: ChainDefinition;
|
|
206
|
+
/**
|
|
207
|
+
* Optional: Override the RPC endpoint.
|
|
208
|
+
* Useful for using QuickNode/Ankr while keeping "Mainnet" identity.
|
|
209
|
+
*/
|
|
210
|
+
endpoint?: string;
|
|
211
|
+
transport?: HttpTransportConfig;
|
|
212
|
+
}
|
|
213
|
+
|
|
138
214
|
/** Default number of accounts to derive in HD wallets */
|
|
139
215
|
declare const DEFAULT_NUM_ACCOUNTS: number;
|
|
140
216
|
/** Rialo mainnet RPC URL */
|
|
@@ -145,6 +221,10 @@ declare const URL_TESTNET: string;
|
|
|
145
221
|
declare const URL_DEVNET: string;
|
|
146
222
|
/** Rialo localnet RPC URL */
|
|
147
223
|
declare const URL_LOCALNET: string;
|
|
224
|
+
declare const RIALO_MAINNET_CHAIN: ChainDefinition;
|
|
225
|
+
declare const RIALO_TESTNET_CHAIN: ChainDefinition;
|
|
226
|
+
declare const RIALO_DEVNET_CHAIN: ChainDefinition;
|
|
227
|
+
declare const RIALO_LOCALNET_CHAIN: ChainDefinition;
|
|
148
228
|
/** System program ID */
|
|
149
229
|
declare const SYSTEM_PROGRAM_ID: string;
|
|
150
230
|
/** Base derivation path for Rialo wallets (BIP44 coin type 756) */
|
|
@@ -154,56 +234,6 @@ declare const KELVIN_PER_RLO: number;
|
|
|
154
234
|
declare const PUBLIC_KEY_LENGTH: number;
|
|
155
235
|
declare const SECRET_KEY_LENGTH: number;
|
|
156
236
|
declare const SIGNATURE_LENGTH: number;
|
|
157
|
-
declare const BLOCKHASH_LENGTH: number;
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Represents a 32-byte blockhash used for transaction replay protection.
|
|
161
|
-
*
|
|
162
|
-
* @example
|
|
163
|
-
* ```typescript
|
|
164
|
-
* // From RPC response
|
|
165
|
-
* const blockhash = Blockhash.fromString(rpcBlockhash);
|
|
166
|
-
*
|
|
167
|
-
* // Comparison
|
|
168
|
-
* if (blockhash1.equals(blockhash2)) {
|
|
169
|
-
* console.log("Same blockhash");
|
|
170
|
-
* }
|
|
171
|
-
* ```
|
|
172
|
-
*/
|
|
173
|
-
declare class Blockhash {
|
|
174
|
-
private readonly bytes;
|
|
175
|
-
private constructor();
|
|
176
|
-
/**
|
|
177
|
-
* Creates a Blockhash from raw bytes.
|
|
178
|
-
*
|
|
179
|
-
* @param bytes - 32-byte blockhash
|
|
180
|
-
* @throws {CryptoError} If bytes length is not 32
|
|
181
|
-
*/
|
|
182
|
-
static fromBytes(bytes: Uint8Array): Blockhash;
|
|
183
|
-
/**
|
|
184
|
-
* Creates a Blockhash from a base58-encoded string.
|
|
185
|
-
*
|
|
186
|
-
* @param str - Base58-encoded blockhash
|
|
187
|
-
* @throws {CryptoError} If string is invalid or decodes to wrong length
|
|
188
|
-
*/
|
|
189
|
-
static fromString(str: string): Blockhash;
|
|
190
|
-
/**
|
|
191
|
-
* Returns a copy of the raw bytes.
|
|
192
|
-
*/
|
|
193
|
-
toBytes(): Uint8Array;
|
|
194
|
-
/**
|
|
195
|
-
* Returns the base58-encoded string representation.
|
|
196
|
-
*/
|
|
197
|
-
toString(): string;
|
|
198
|
-
/**
|
|
199
|
-
* Checks equality with another blockhash using constant-time comparison.
|
|
200
|
-
*/
|
|
201
|
-
equals(other: Blockhash): boolean;
|
|
202
|
-
/**
|
|
203
|
-
* JSON serialization (returns base58 string).
|
|
204
|
-
*/
|
|
205
|
-
toJSON(): string;
|
|
206
|
-
}
|
|
207
237
|
|
|
208
238
|
/**
|
|
209
239
|
* Error codes for cryptographic operations.
|
|
@@ -793,7 +823,6 @@ declare enum SystemInstruction {
|
|
|
793
823
|
*
|
|
794
824
|
* const tx = TransactionBuilder.create()
|
|
795
825
|
* .setPayer(fromPubkey)
|
|
796
|
-
* .setRecentBlockhash(blockhash)
|
|
797
826
|
* .addInstruction(instruction)
|
|
798
827
|
* .build();
|
|
799
828
|
* ```
|
|
@@ -810,922 +839,912 @@ declare function transferInstruction(from: PublicKey, to: PublicKey, amount: big
|
|
|
810
839
|
*/
|
|
811
840
|
declare function createAccount(from: PublicKey, newAccount: PublicKey, lamports: bigint, space: bigint, owner: PublicKey): Instruction;
|
|
812
841
|
|
|
813
|
-
interface HttpTransportConfig {
|
|
814
|
-
/** Request timeout in milliseconds */
|
|
815
|
-
timeout?: number;
|
|
816
|
-
/** Maximum number of retry attempts */
|
|
817
|
-
maxRetries?: number;
|
|
818
|
-
/** Base delay for exponential backoff (ms) */
|
|
819
|
-
retryBaseDelay?: number;
|
|
820
|
-
/** Maximum retry delay (ms) */
|
|
821
|
-
retryMaxDelay?: number;
|
|
822
|
-
/** Custom headers to include in requests */
|
|
823
|
-
headers?: Record<string, string>;
|
|
824
|
-
}
|
|
825
842
|
/**
|
|
826
|
-
*
|
|
843
|
+
* An unsigned transaction message ready to be signed.
|
|
827
844
|
*
|
|
828
|
-
*
|
|
829
|
-
*
|
|
830
|
-
*
|
|
831
|
-
*
|
|
832
|
-
*
|
|
833
|
-
*
|
|
845
|
+
* This is the data that gets signed by transaction signers.
|
|
846
|
+
* It's immutable to prevent accidental modification after creation.
|
|
847
|
+
*
|
|
848
|
+
* @example
|
|
849
|
+
* ```typescript
|
|
850
|
+
* const message = MessageBuilder.create()
|
|
851
|
+
* .setPayer(payer)
|
|
852
|
+
* .setValidFrom(validFrom)
|
|
853
|
+
* .addInstruction(transferInstruction)
|
|
854
|
+
* .build();
|
|
855
|
+
*
|
|
856
|
+
* // Serialize for signing
|
|
857
|
+
* const messageBytes = message.serialize();
|
|
858
|
+
* ```
|
|
834
859
|
*/
|
|
835
|
-
declare class
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
860
|
+
declare class Message {
|
|
861
|
+
/** Message header with signature requirements */
|
|
862
|
+
readonly header: MessageHeader;
|
|
863
|
+
/** All account public keys referenced in the transaction */
|
|
864
|
+
readonly accountKeys: readonly PublicKey[];
|
|
865
|
+
/** Transaction valid from (milliseconds since Unix epoch) */
|
|
866
|
+
validFrom?: bigint;
|
|
867
|
+
/** Compiled instructions with account indices */
|
|
868
|
+
readonly instructions: readonly CompiledInstruction[];
|
|
869
|
+
/** Cached serialized bytes */
|
|
870
|
+
private serializedCache?;
|
|
871
|
+
constructor(header: MessageHeader, accountKeys: readonly PublicKey[], validFrom: bigint, instructions: readonly CompiledInstruction[]);
|
|
839
872
|
/**
|
|
840
|
-
*
|
|
873
|
+
* Serialize message to bytes for signing.
|
|
874
|
+
* Result is cached for performance.
|
|
875
|
+
*/
|
|
876
|
+
serialize(): Uint8Array;
|
|
877
|
+
/**
|
|
878
|
+
* Deserialize a message from wire format.
|
|
841
879
|
*
|
|
842
|
-
*
|
|
843
|
-
*
|
|
880
|
+
* @param data - Serialized message bytes
|
|
881
|
+
* @returns Deserialized Message
|
|
844
882
|
*/
|
|
845
|
-
|
|
883
|
+
static deserialize(data: Uint8Array): Message;
|
|
884
|
+
private serializeInternal;
|
|
885
|
+
private serializeCompactArray;
|
|
886
|
+
private serializeCompactU16;
|
|
846
887
|
/**
|
|
847
|
-
*
|
|
888
|
+
* Get all signers required for this message.
|
|
848
889
|
*/
|
|
849
|
-
|
|
890
|
+
getSigners(): readonly PublicKey[];
|
|
850
891
|
/**
|
|
851
|
-
*
|
|
892
|
+
* Check if a public key is a required signer.
|
|
852
893
|
*/
|
|
853
|
-
|
|
894
|
+
isSignerRequired(pubkey: PublicKey): boolean;
|
|
854
895
|
/**
|
|
855
|
-
*
|
|
896
|
+
* Get the index of a signer in the signers array.
|
|
897
|
+
* Returns -1 if not a signer.
|
|
856
898
|
*/
|
|
857
|
-
|
|
899
|
+
getSignerIndex(pubkey: PublicKey): number;
|
|
858
900
|
}
|
|
859
901
|
|
|
860
902
|
/**
|
|
861
|
-
*
|
|
903
|
+
* Interface for signing messages and transactions.
|
|
862
904
|
*
|
|
863
|
-
*
|
|
905
|
+
* Enables multiple signing strategies:
|
|
906
|
+
* - **KeypairSigner**: Local keypair signing
|
|
907
|
+
* - **Browser Wallet**: Browser extension integration
|
|
908
|
+
* - **Hardware Wallet**: Ledger, Trezor, etc.
|
|
909
|
+
* - **Remote Signer**: API-based signing services
|
|
910
|
+
*
|
|
911
|
+
* @example
|
|
912
|
+
* ```typescript
|
|
913
|
+
* // Browser wallet implementation
|
|
914
|
+
* class BrowserWalletSigner implements Signer {
|
|
915
|
+
* async getPublicKey(): Promise<PublicKey> {
|
|
916
|
+
* const pubkey = await window.rialoWallet.getPublicKey();
|
|
917
|
+
* return PublicKey.fromString(pubkey);
|
|
918
|
+
* }
|
|
919
|
+
*
|
|
920
|
+
* async signMessage(message: Uint8Array): Promise<Signature> {
|
|
921
|
+
* const sig = await window.rialoWallet.signMessage(message);
|
|
922
|
+
* return Signature.fromBytes(sig);
|
|
923
|
+
* }
|
|
924
|
+
* }
|
|
925
|
+
*
|
|
926
|
+
* // Usage
|
|
927
|
+
* const signer = new BrowserWalletSigner();
|
|
928
|
+
* const publicKey = await signer.getPublicKey();
|
|
929
|
+
* const signature = await signer.signMessage(message);
|
|
930
|
+
* ```
|
|
864
931
|
*/
|
|
865
|
-
|
|
866
|
-
protected readonly transport: HttpTransport;
|
|
867
|
-
private requestId;
|
|
868
|
-
constructor(transport: HttpTransport);
|
|
932
|
+
interface Signer {
|
|
869
933
|
/**
|
|
870
|
-
*
|
|
934
|
+
* Retrieves the signer's public key.
|
|
871
935
|
*
|
|
872
|
-
*
|
|
873
|
-
*/
|
|
874
|
-
protected call<T>(method: string, params?: unknown[]): Promise<T>;
|
|
875
|
-
/**
|
|
876
|
-
* Validate JSON-RPC response structure
|
|
936
|
+
* **Note**: May trigger wallet connection prompts for browser wallets.
|
|
877
937
|
*/
|
|
878
|
-
|
|
938
|
+
getPublicKey(): Promise<PublicKey>;
|
|
879
939
|
/**
|
|
880
|
-
*
|
|
940
|
+
* Signs arbitrary message bytes.
|
|
941
|
+
*
|
|
942
|
+
* @param message - Message bytes to sign
|
|
943
|
+
* @returns Ed25519 signature over the message
|
|
881
944
|
*/
|
|
882
|
-
|
|
945
|
+
signMessage(message: Uint8Array): Promise<Signature>;
|
|
883
946
|
}
|
|
884
947
|
|
|
885
948
|
/**
|
|
886
|
-
*
|
|
949
|
+
* Signer implementation using a local Ed25519 keypair.
|
|
950
|
+
*
|
|
951
|
+
* Provides synchronous signing without external dependencies.
|
|
952
|
+
* Suitable for server-side applications, CLIs, and testing.
|
|
953
|
+
*
|
|
954
|
+
* @example
|
|
955
|
+
* ```typescript
|
|
956
|
+
* import { Keypair, KeypairSigner } from '@rialo/ts-cdk';
|
|
957
|
+
*
|
|
958
|
+
* // Generate new keypair
|
|
959
|
+
* const keypair = Keypair.generate();
|
|
960
|
+
* const signer = new KeypairSigner(keypair);
|
|
961
|
+
*
|
|
962
|
+
* // Or from mnemonic
|
|
963
|
+
* const mnemonic = Mnemonic.generate();
|
|
964
|
+
* const keypair = await mnemonic.toKeypair(0);
|
|
965
|
+
* const signer = new KeypairSigner(keypair);
|
|
966
|
+
*
|
|
967
|
+
* // Sign messages
|
|
968
|
+
* const publicKey = await signer.getPublicKey();
|
|
969
|
+
* const signature = await signer.signMessage(message);
|
|
970
|
+
* ```
|
|
887
971
|
*/
|
|
972
|
+
declare class KeypairSigner implements Signer {
|
|
973
|
+
private readonly keypair;
|
|
974
|
+
constructor(keypair: Keypair);
|
|
975
|
+
/**
|
|
976
|
+
* Returns the keypair's public key.
|
|
977
|
+
*/
|
|
978
|
+
getPublicKey(): Promise<PublicKey>;
|
|
979
|
+
/**
|
|
980
|
+
* Signs a message using the keypair's private key.
|
|
981
|
+
*/
|
|
982
|
+
signMessage(message: Uint8Array): Promise<Signature>;
|
|
983
|
+
}
|
|
888
984
|
|
|
889
985
|
/**
|
|
890
|
-
*
|
|
891
|
-
*/
|
|
892
|
-
interface AccountInfo {
|
|
893
|
-
/** Account balance in smallest denomination */
|
|
894
|
-
balance: bigint;
|
|
895
|
-
/** Owner program public key */
|
|
896
|
-
owner: PublicKey;
|
|
897
|
-
/** Account data */
|
|
898
|
-
data: Uint8Array;
|
|
899
|
-
/** Whether the account is executable */
|
|
900
|
-
executable: boolean;
|
|
901
|
-
/** Rent epoch */
|
|
902
|
-
rentEpoch: bigint;
|
|
903
|
-
}
|
|
904
|
-
/**
|
|
905
|
-
* Transaction response.
|
|
906
|
-
*/
|
|
907
|
-
interface TransactionResponse {
|
|
908
|
-
/** Transaction signature */
|
|
909
|
-
signature: string;
|
|
910
|
-
/** Slot in which the transaction was processed */
|
|
911
|
-
slot: bigint;
|
|
912
|
-
/** Block time (Unix timestamp) */
|
|
913
|
-
blockTime?: bigint;
|
|
914
|
-
/** Error message if transaction failed */
|
|
915
|
-
err?: string;
|
|
916
|
-
}
|
|
917
|
-
/**
|
|
918
|
-
* Signature status.
|
|
919
|
-
*/
|
|
920
|
-
interface SignatureStatus {
|
|
921
|
-
/** Slot in which the transaction was processed */
|
|
922
|
-
slot: bigint;
|
|
923
|
-
/** Number of confirmations */
|
|
924
|
-
confirmations?: number;
|
|
925
|
-
/** Error message if transaction failed */
|
|
926
|
-
err?: string;
|
|
927
|
-
}
|
|
928
|
-
/**
|
|
929
|
-
* Options for sending a transaction.
|
|
930
|
-
*/
|
|
931
|
-
interface SendTransactionOptions {
|
|
932
|
-
/** Skip preflight transaction checks */
|
|
933
|
-
skipPreflight?: boolean;
|
|
934
|
-
/** Maximum number of times to retry */
|
|
935
|
-
maxRetries?: number;
|
|
936
|
-
}
|
|
937
|
-
/**
|
|
938
|
-
* Epoch information response.
|
|
939
|
-
*/
|
|
940
|
-
interface EpochInfoResponse {
|
|
941
|
-
/** Current epoch */
|
|
942
|
-
epoch: bigint;
|
|
943
|
-
/** Current slot in the epoch */
|
|
944
|
-
slotIndex: bigint;
|
|
945
|
-
/** Total slots in the epoch */
|
|
946
|
-
slotsInEpoch: bigint;
|
|
947
|
-
/** Absolute slot number */
|
|
948
|
-
absoluteSlot: bigint;
|
|
949
|
-
/** Block height */
|
|
950
|
-
blockHeight: bigint;
|
|
951
|
-
/** Transaction count */
|
|
952
|
-
transactionCount?: bigint;
|
|
953
|
-
}
|
|
954
|
-
/**
|
|
955
|
-
* Fee for message response.
|
|
956
|
-
*/
|
|
957
|
-
interface GetFeeForMessageResponse {
|
|
958
|
-
/** Fee in smallest denomination */
|
|
959
|
-
value: bigint;
|
|
960
|
-
}
|
|
961
|
-
/**
|
|
962
|
-
* Multiple accounts response.
|
|
963
|
-
*/
|
|
964
|
-
interface MultipleAccountsResponse {
|
|
965
|
-
/** Array of account information */
|
|
966
|
-
value: Array<AccountInfo | null>;
|
|
967
|
-
}
|
|
968
|
-
/**
|
|
969
|
-
* Get subscriptions response.
|
|
970
|
-
*/
|
|
971
|
-
interface GetSubscriptionsResponse {
|
|
972
|
-
/** Array of subscription data */
|
|
973
|
-
subscriptions: Array<Record<string, unknown>>;
|
|
974
|
-
}
|
|
975
|
-
/**
|
|
976
|
-
* Get triggered transactions response.
|
|
977
|
-
*/
|
|
978
|
-
interface GetTriggeredTransactionsResponse {
|
|
979
|
-
/** Array of triggered transaction data */
|
|
980
|
-
transactions: Array<Record<string, unknown>>;
|
|
981
|
-
}
|
|
982
|
-
/**
|
|
983
|
-
* Get workflow lineage request.
|
|
984
|
-
*/
|
|
985
|
-
interface GetWorkflowLineageRequest {
|
|
986
|
-
/** Workflow account public key */
|
|
987
|
-
workflowAccount: PublicKey;
|
|
988
|
-
/** Optional limit on results */
|
|
989
|
-
limit?: number;
|
|
990
|
-
}
|
|
991
|
-
/**
|
|
992
|
-
* Get workflow lineage response.
|
|
993
|
-
*/
|
|
994
|
-
interface GetWorkflowLineageResponse {
|
|
995
|
-
/** Workflow lineage data */
|
|
996
|
-
lineage: Array<Record<string, unknown>>;
|
|
997
|
-
}
|
|
998
|
-
/**
|
|
999
|
-
* Get signatures for address configuration.
|
|
1000
|
-
*/
|
|
1001
|
-
interface GetSignaturesForAddressConfig {
|
|
1002
|
-
/** Maximum number of signatures to return */
|
|
1003
|
-
limit?: number;
|
|
1004
|
-
/** Start searching backwards from this signature */
|
|
1005
|
-
before?: string;
|
|
1006
|
-
/** Start searching forwards from this signature */
|
|
1007
|
-
until?: string;
|
|
1008
|
-
}
|
|
1009
|
-
/**
|
|
1010
|
-
* Get signatures for address response.
|
|
1011
|
-
*/
|
|
1012
|
-
interface GetSignaturesForAddressResponse {
|
|
1013
|
-
/** Array of signature information */
|
|
1014
|
-
signatures: Array<{
|
|
1015
|
-
signature: string;
|
|
1016
|
-
slot: bigint;
|
|
1017
|
-
err?: string;
|
|
1018
|
-
memo?: string;
|
|
1019
|
-
blockTime?: bigint;
|
|
1020
|
-
}>;
|
|
1021
|
-
}
|
|
1022
|
-
/**
|
|
1023
|
-
* Is blockhash valid response.
|
|
1024
|
-
*/
|
|
1025
|
-
interface IsBlockhashValidResponse {
|
|
1026
|
-
/** Whether the blockhash is valid */
|
|
1027
|
-
value: boolean;
|
|
1028
|
-
}
|
|
1029
|
-
/**
|
|
1030
|
-
* Get health response.
|
|
1031
|
-
*/
|
|
1032
|
-
type GetHealthResponse = "ok" | string;
|
|
1033
|
-
/**
|
|
1034
|
-
* Get validator health response.
|
|
1035
|
-
*/
|
|
1036
|
-
type GetValidatorHealthResponse = "ok" | string;
|
|
1037
|
-
/**
|
|
1038
|
-
* Get connected full nodes response.
|
|
1039
|
-
*/
|
|
1040
|
-
interface GetConnectedFullNodesResponse {
|
|
1041
|
-
/** Array of connected nodes */
|
|
1042
|
-
nodes: Array<{
|
|
1043
|
-
publicKey: string;
|
|
1044
|
-
connectedTime: bigint;
|
|
1045
|
-
}>;
|
|
1046
|
-
}
|
|
1047
|
-
/**
|
|
1048
|
-
* Get transactions configuration.
|
|
1049
|
-
*/
|
|
1050
|
-
interface GetTransactionsConfig {
|
|
1051
|
-
/** Maximum number of transactions to return */
|
|
1052
|
-
limit?: number;
|
|
1053
|
-
/** Encoding format */
|
|
1054
|
-
encoding?: "json" | "base58" | "base64";
|
|
1055
|
-
}
|
|
1056
|
-
/**
|
|
1057
|
-
* Get transactions response.
|
|
1058
|
-
*/
|
|
1059
|
-
interface GetTransactionsResponse {
|
|
1060
|
-
/** Array of transaction data */
|
|
1061
|
-
transactions: Array<Record<string, unknown>>;
|
|
1062
|
-
}
|
|
1063
|
-
|
|
1064
|
-
/**
|
|
1065
|
-
* Main Rialo RPC client for blockchain interactions.
|
|
1066
|
-
*/
|
|
1067
|
-
|
|
1068
|
-
/**
|
|
1069
|
-
* High-level Rialo RPC client for blockchain interactions.
|
|
986
|
+
* A transaction with zero or more signatures.
|
|
1070
987
|
*
|
|
1071
|
-
*
|
|
1072
|
-
*
|
|
1073
|
-
* (QueryRpcClient, TransactionRpcClient) for modular organization.
|
|
988
|
+
* Transactions are immutable - signing methods return new instances.
|
|
989
|
+
* This prevents accidental modification and signature tampering.
|
|
1074
990
|
*
|
|
1075
991
|
* @example
|
|
1076
992
|
* ```typescript
|
|
1077
|
-
*
|
|
993
|
+
* // Simple signing
|
|
994
|
+
* const tx = builder.build();
|
|
995
|
+
* const signed = tx.sign(keypair);
|
|
1078
996
|
*
|
|
1079
|
-
* //
|
|
1080
|
-
* const
|
|
1081
|
-
*
|
|
997
|
+
* // Method chaining
|
|
998
|
+
* const signed = tx
|
|
999
|
+
* .sign(keypair1)
|
|
1000
|
+
* .sign(keypair2)
|
|
1001
|
+
* .sign(keypair3);
|
|
1082
1002
|
*
|
|
1083
|
-
* //
|
|
1084
|
-
* const
|
|
1003
|
+
* // Multi-sig convenience
|
|
1004
|
+
* const signed = tx.signAll([keypair1, keypair2, keypair3]);
|
|
1085
1005
|
* ```
|
|
1086
1006
|
*/
|
|
1087
|
-
declare class
|
|
1088
|
-
|
|
1089
|
-
private readonly
|
|
1090
|
-
|
|
1091
|
-
|
|
1007
|
+
declare class Transaction {
|
|
1008
|
+
/** The unsigned message */
|
|
1009
|
+
private readonly message;
|
|
1010
|
+
/** Signatures (64 bytes each), aligned with message.header.numRequiredSignatures */
|
|
1011
|
+
private readonly signatures;
|
|
1012
|
+
private constructor();
|
|
1092
1013
|
/**
|
|
1093
|
-
*
|
|
1014
|
+
* Create an unsigned transaction from a message.
|
|
1015
|
+
* All signature slots are initialized to zero.
|
|
1016
|
+
*
|
|
1017
|
+
* @internal - Users should use TransactionBuilder instead
|
|
1094
1018
|
*/
|
|
1095
|
-
|
|
1019
|
+
static fromMessage(message: Message): Transaction;
|
|
1096
1020
|
/**
|
|
1097
|
-
*
|
|
1098
|
-
*
|
|
1099
|
-
* Required for transaction creation and replay protection.
|
|
1021
|
+
* Create transaction from message and existing signatures.
|
|
1022
|
+
* @internal
|
|
1100
1023
|
*/
|
|
1101
|
-
|
|
1024
|
+
static fromMessageAndSignatures(message: Message, signatures: readonly Uint8Array[]): Transaction;
|
|
1102
1025
|
/**
|
|
1103
|
-
*
|
|
1026
|
+
* Deserialize a transaction from wire format.
|
|
1104
1027
|
*/
|
|
1105
|
-
|
|
1028
|
+
static deserialize(data: Uint8Array): Transaction;
|
|
1029
|
+
getMessage(): Message;
|
|
1106
1030
|
/**
|
|
1107
|
-
*
|
|
1031
|
+
* Sign the transaction with a keypair.
|
|
1032
|
+
* Returns a NEW Transaction instance.
|
|
1108
1033
|
*
|
|
1109
|
-
* @
|
|
1034
|
+
* @param keypair - Keypair to sign with
|
|
1035
|
+
* @returns New Transaction instance with signature added
|
|
1036
|
+
*
|
|
1037
|
+
* @example
|
|
1038
|
+
* ```typescript
|
|
1039
|
+
* const signedTx = tx.sign(keypair);
|
|
1040
|
+
* await client.sendTransaction(signedTx.serialize());
|
|
1041
|
+
* ```
|
|
1110
1042
|
*/
|
|
1111
|
-
|
|
1043
|
+
sign(keypair: Keypair): Transaction;
|
|
1112
1044
|
/**
|
|
1113
|
-
*
|
|
1045
|
+
* Sign with multiple keypairs at once.
|
|
1046
|
+
* Returns a NEW Transaction instance.
|
|
1047
|
+
*
|
|
1048
|
+
* @example
|
|
1049
|
+
* ```typescript
|
|
1050
|
+
* const signed = tx.signAll([keypair1, keypair2, keypair3]);
|
|
1051
|
+
* ```
|
|
1114
1052
|
*/
|
|
1115
|
-
|
|
1053
|
+
signAll(keypairs: Keypair[]): Transaction;
|
|
1116
1054
|
/**
|
|
1117
|
-
*
|
|
1055
|
+
* Sign the transaction with a Signer interface (async).
|
|
1056
|
+
* Returns a NEW Transaction instance.
|
|
1118
1057
|
*
|
|
1119
|
-
* @
|
|
1058
|
+
* @example
|
|
1059
|
+
* ```typescript
|
|
1060
|
+
* const signedTx = await tx.signWith(browserWallet);
|
|
1061
|
+
* ```
|
|
1120
1062
|
*/
|
|
1121
|
-
|
|
1063
|
+
signWith(signer: Signer): Promise<Transaction>;
|
|
1122
1064
|
/**
|
|
1123
|
-
*
|
|
1065
|
+
* Sign with multiple signers.
|
|
1066
|
+
* Returns a NEW Transaction instance.
|
|
1124
1067
|
*/
|
|
1125
|
-
|
|
1068
|
+
signAllWith(signers: Signer[]): Promise<Transaction>;
|
|
1126
1069
|
/**
|
|
1127
|
-
*
|
|
1070
|
+
* Partially sign the transaction (for multi-sig transactions).
|
|
1071
|
+
* Returns a NEW Transaction instance.
|
|
1072
|
+
*
|
|
1073
|
+
* @example
|
|
1074
|
+
* ```typescript
|
|
1075
|
+
* const signedTx = tx
|
|
1076
|
+
* .partialSign(signer1)
|
|
1077
|
+
* .partialSign(signer2);
|
|
1078
|
+
* ```
|
|
1128
1079
|
*/
|
|
1129
|
-
|
|
1080
|
+
partialSign(keypair: Keypair): Transaction;
|
|
1130
1081
|
/**
|
|
1131
|
-
*
|
|
1082
|
+
* Partially sign with a Signer interface (async).
|
|
1083
|
+
* Returns a NEW Transaction instance.
|
|
1132
1084
|
*/
|
|
1133
|
-
|
|
1085
|
+
partialSignWith(signer: Signer): Promise<Transaction>;
|
|
1134
1086
|
/**
|
|
1135
|
-
*
|
|
1087
|
+
* Add a signature at a specific index.
|
|
1088
|
+
* Returns a NEW Transaction instance.
|
|
1136
1089
|
*
|
|
1137
|
-
*
|
|
1090
|
+
* Most users should use sign() or signAll() instead.
|
|
1138
1091
|
*/
|
|
1139
|
-
|
|
1092
|
+
addSignature(index: number, signature: Signature | Uint8Array): Transaction;
|
|
1140
1093
|
/**
|
|
1141
|
-
*
|
|
1094
|
+
* Add a signature for a specific public key.
|
|
1095
|
+
* Returns a NEW Transaction instance.
|
|
1142
1096
|
*
|
|
1143
|
-
*
|
|
1144
|
-
* @param options - Transaction submission options
|
|
1145
|
-
* @returns Transaction signature
|
|
1097
|
+
* Most users should use sign() or signAll() instead.
|
|
1146
1098
|
*/
|
|
1147
|
-
|
|
1099
|
+
addSignatureForPubkey(pubkey: PublicKey, signature: Signature | Uint8Array): Transaction;
|
|
1148
1100
|
/**
|
|
1149
|
-
*
|
|
1101
|
+
* Check if transaction is fully signed (all signatures present).
|
|
1102
|
+
*/
|
|
1103
|
+
isSigned(): boolean;
|
|
1104
|
+
/**
|
|
1105
|
+
* Check if a specific signature slot is filled.
|
|
1106
|
+
*/
|
|
1107
|
+
isSignaturePresent(index: number): boolean;
|
|
1108
|
+
/**
|
|
1109
|
+
* Get all signatures (returns copies to prevent mutation).
|
|
1110
|
+
*/
|
|
1111
|
+
getSignatures(): readonly Uint8Array[];
|
|
1112
|
+
/**
|
|
1113
|
+
* Get a specific signature (returns copy).
|
|
1114
|
+
*/
|
|
1115
|
+
getSignature(index: number): Uint8Array;
|
|
1116
|
+
/**
|
|
1117
|
+
* Get a specific signature for a public key.
|
|
1118
|
+
*/
|
|
1119
|
+
getSignatureForPubkey(pubkey: PublicKey): Uint8Array;
|
|
1120
|
+
/**
|
|
1121
|
+
* Get required signers for this transaction.
|
|
1122
|
+
*/
|
|
1123
|
+
getSigners(): readonly PublicKey[];
|
|
1124
|
+
/**
|
|
1125
|
+
* Get the number of required signatures.
|
|
1126
|
+
*/
|
|
1127
|
+
getRequiredSignatureCount(): number;
|
|
1128
|
+
/**
|
|
1129
|
+
* Throw an error if the transaction is not fully signed.
|
|
1150
1130
|
*
|
|
1151
|
-
*
|
|
1131
|
+
* @throws {TransactionError} If transaction is not fully signed
|
|
1152
1132
|
*
|
|
1153
|
-
* @
|
|
1154
|
-
*
|
|
1155
|
-
*
|
|
1133
|
+
* @example
|
|
1134
|
+
* ```typescript
|
|
1135
|
+
* signedTx.ensureSigned(); // Throws if not signed
|
|
1136
|
+
* await client.sendTransaction(signedTx.serialize());
|
|
1137
|
+
* ```
|
|
1156
1138
|
*/
|
|
1157
|
-
|
|
1139
|
+
ensureSigned(): void;
|
|
1140
|
+
/**
|
|
1141
|
+
* Serialize transaction to wire format.
|
|
1142
|
+
*/
|
|
1143
|
+
serialize(): Uint8Array;
|
|
1158
1144
|
}
|
|
1159
1145
|
|
|
1160
1146
|
/**
|
|
1161
|
-
*
|
|
1147
|
+
* Fluent API for building transactions.
|
|
1148
|
+
* Returns Transaction directly (not Message).
|
|
1162
1149
|
*/
|
|
1163
1150
|
|
|
1164
1151
|
/**
|
|
1165
|
-
*
|
|
1152
|
+
* Builder for creating transactions with a fluent API.
|
|
1166
1153
|
*
|
|
1167
|
-
*
|
|
1154
|
+
* Provides an intuitive interface for constructing transactions.
|
|
1155
|
+
* Call build() to get an unsigned Transaction ready for signing.
|
|
1156
|
+
*
|
|
1157
|
+
* @example
|
|
1158
|
+
* ```typescript
|
|
1159
|
+
* // Simple transfer
|
|
1160
|
+
* const tx = TransactionBuilder.create()
|
|
1161
|
+
* .setPayer(payer)
|
|
1162
|
+
* .setValidFrom(validFrom)
|
|
1163
|
+
* .addInstruction(transfer(from, to, 1_000_000n))
|
|
1164
|
+
* .build();
|
|
1165
|
+
*
|
|
1166
|
+
* const signedTx = tx.sign(keypair);
|
|
1167
|
+
* await client.transaction.sendTransaction(signedTx.serialize());
|
|
1168
|
+
* ```
|
|
1169
|
+
*
|
|
1170
|
+
* @example
|
|
1171
|
+
* ```typescript
|
|
1172
|
+
* // Multi-instruction transaction
|
|
1173
|
+
* const tx = TransactionBuilder.create()
|
|
1174
|
+
* .setPayer(payer)
|
|
1175
|
+
* .setValidFrom(validFrom)
|
|
1176
|
+
* .addInstruction(transfer(from, to, 1_000_000n))
|
|
1177
|
+
* .addInstruction(memoInstruction("Payment for invoice #123"))
|
|
1178
|
+
* .build();
|
|
1179
|
+
* ```
|
|
1168
1180
|
*/
|
|
1169
|
-
declare class
|
|
1181
|
+
declare class TransactionBuilder {
|
|
1182
|
+
private payer?;
|
|
1183
|
+
private validFrom?;
|
|
1184
|
+
private readonly instructions;
|
|
1185
|
+
private constructor();
|
|
1170
1186
|
/**
|
|
1171
|
-
*
|
|
1187
|
+
* Create a new transaction builder.
|
|
1172
1188
|
*/
|
|
1173
|
-
|
|
1189
|
+
static create(): TransactionBuilder;
|
|
1174
1190
|
/**
|
|
1175
|
-
*
|
|
1191
|
+
* Set the fee payer for this transaction.
|
|
1192
|
+
*
|
|
1193
|
+
* The payer will be the first account and must sign the transaction.
|
|
1194
|
+
* The payer pays for transaction fees.
|
|
1195
|
+
*
|
|
1196
|
+
* @param payer - Public key of the fee payer
|
|
1176
1197
|
*/
|
|
1177
|
-
|
|
1198
|
+
setPayer(payer: PublicKey): this;
|
|
1178
1199
|
/**
|
|
1179
|
-
*
|
|
1200
|
+
* Set the Transaction valid from.
|
|
1201
|
+
*
|
|
1202
|
+
* This is the time the transaction is valid from, in milliseconds since Unix epoch.
|
|
1203
|
+
* It can be used for additional replay protection or auditing.
|
|
1204
|
+
*
|
|
1205
|
+
* @param validFrom - Transaction valid from in milliseconds since Unix epoch
|
|
1180
1206
|
*/
|
|
1181
|
-
|
|
1207
|
+
setValidFrom(validFrom: bigint): this;
|
|
1182
1208
|
/**
|
|
1183
|
-
*
|
|
1209
|
+
* Add an instruction to the transaction.
|
|
1210
|
+
*
|
|
1211
|
+
* @param instruction - Instruction to add
|
|
1184
1212
|
*/
|
|
1185
|
-
|
|
1213
|
+
addInstruction(instruction: Instruction): this;
|
|
1186
1214
|
/**
|
|
1187
|
-
*
|
|
1215
|
+
* Add multiple instructions at once.
|
|
1216
|
+
*
|
|
1217
|
+
* @param instructions - Array of instructions to add
|
|
1188
1218
|
*/
|
|
1189
|
-
|
|
1219
|
+
addInstructions(instructions: readonly Instruction[]): this;
|
|
1190
1220
|
/**
|
|
1191
|
-
*
|
|
1221
|
+
* Build the transaction (unsigned).
|
|
1222
|
+
*
|
|
1223
|
+
* Returns an unsigned Transaction that's ready to be signed.
|
|
1224
|
+
*
|
|
1225
|
+
* @returns Unsigned Transaction
|
|
1226
|
+
* @throws {TransactionError} If payer, valid_from, or instructions are missing
|
|
1227
|
+
*
|
|
1228
|
+
* @example
|
|
1229
|
+
* ```typescript
|
|
1230
|
+
* const tx = builder.build();
|
|
1231
|
+
* const signedTx = tx.sign(keypair);
|
|
1232
|
+
* ```
|
|
1192
1233
|
*/
|
|
1193
|
-
|
|
1234
|
+
build(): Transaction;
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
/**
|
|
1238
|
+
* Base client with JSON-RPC protocol handling.
|
|
1239
|
+
*
|
|
1240
|
+
* All specific clients (QueryClient, TransactionClient) extend this.
|
|
1241
|
+
*/
|
|
1242
|
+
declare class BaseRpcClient {
|
|
1243
|
+
protected readonly transport: HttpTransport;
|
|
1244
|
+
private requestId;
|
|
1245
|
+
constructor(transport: HttpTransport);
|
|
1194
1246
|
/**
|
|
1195
|
-
*
|
|
1247
|
+
* Makes a JSON-RPC 2.0 method call with type safety.
|
|
1248
|
+
*
|
|
1249
|
+
* Handles request serialization, response validation, and error mapping.
|
|
1196
1250
|
*/
|
|
1197
|
-
|
|
1251
|
+
protected call<T>(method: string, params?: unknown[]): Promise<T>;
|
|
1198
1252
|
/**
|
|
1199
|
-
*
|
|
1253
|
+
* Validate JSON-RPC response structure
|
|
1200
1254
|
*/
|
|
1201
|
-
|
|
1255
|
+
private isValidJsonRpcResponse;
|
|
1202
1256
|
/**
|
|
1203
|
-
*
|
|
1257
|
+
* Returns the configured RPC endpoint URL.
|
|
1204
1258
|
*/
|
|
1205
|
-
|
|
1259
|
+
getUrl(): string;
|
|
1206
1260
|
}
|
|
1207
1261
|
|
|
1208
1262
|
/**
|
|
1209
|
-
*
|
|
1263
|
+
* RPC type definitions for the Rialo blockchain.
|
|
1210
1264
|
*/
|
|
1211
1265
|
|
|
1212
1266
|
/**
|
|
1213
|
-
*
|
|
1214
|
-
*
|
|
1215
|
-
* Handles all transaction operations like sending transactions, requesting airdrops, etc.
|
|
1267
|
+
* Account information response.
|
|
1216
1268
|
*/
|
|
1217
|
-
|
|
1218
|
-
/**
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
/**
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1269
|
+
interface AccountInfo {
|
|
1270
|
+
/** Account balance in smallest denomination */
|
|
1271
|
+
balance: bigint;
|
|
1272
|
+
/** Owner program public key */
|
|
1273
|
+
owner: PublicKey;
|
|
1274
|
+
/** Account data */
|
|
1275
|
+
data: Uint8Array;
|
|
1276
|
+
/** Whether the account is executable */
|
|
1277
|
+
executable: boolean;
|
|
1278
|
+
/** Rent epoch */
|
|
1279
|
+
rentEpoch: bigint;
|
|
1226
1280
|
}
|
|
1227
|
-
|
|
1228
1281
|
/**
|
|
1229
|
-
*
|
|
1282
|
+
* Transaction response.
|
|
1230
1283
|
*/
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
INTERNAL_ERROR = "INTERNAL_ERROR",
|
|
1241
|
-
TRANSACTION_REJECTED = "TRANSACTION_REJECTED",
|
|
1242
|
-
INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS",
|
|
1243
|
-
ACCOUNT_NOT_FOUND = "ACCOUNT_NOT_FOUND",
|
|
1244
|
-
BLOCKHASH_NOT_FOUND = "BLOCKHASH_NOT_FOUND",
|
|
1245
|
-
RATE_LIMIT_EXCEEDED = "RATE_LIMIT_EXCEEDED",
|
|
1246
|
-
NODE_UNHEALTHY = "NODE_UNHEALTHY"
|
|
1284
|
+
interface TransactionResponse {
|
|
1285
|
+
/** Transaction signature */
|
|
1286
|
+
signature: string;
|
|
1287
|
+
/** Slot in which the transaction was processed */
|
|
1288
|
+
slot: bigint;
|
|
1289
|
+
/** Block time (Unix timestamp) */
|
|
1290
|
+
blockTime?: bigint;
|
|
1291
|
+
/** Error message if transaction failed */
|
|
1292
|
+
err?: string;
|
|
1247
1293
|
}
|
|
1248
1294
|
/**
|
|
1249
|
-
*
|
|
1295
|
+
* Signature status.
|
|
1250
1296
|
*/
|
|
1251
|
-
interface
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
timeout?: number;
|
|
1259
|
-
attempts?: number;
|
|
1260
|
-
[key: string]: unknown;
|
|
1297
|
+
interface SignatureStatus {
|
|
1298
|
+
/** Slot in which the transaction was processed */
|
|
1299
|
+
slot: bigint;
|
|
1300
|
+
/** Number of confirmations */
|
|
1301
|
+
confirmations?: number;
|
|
1302
|
+
/** Error message if transaction failed */
|
|
1303
|
+
err?: string;
|
|
1261
1304
|
}
|
|
1262
1305
|
/**
|
|
1263
|
-
*
|
|
1264
|
-
*
|
|
1265
|
-
* Provides actionable error messages and indicates whether errors are retryable.
|
|
1306
|
+
* Options for sending a transaction.
|
|
1266
1307
|
*/
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
static requestTimeout(timeoutMs: number, details: RpcErrorDetails): RpcError;
|
|
1273
|
-
static networkError(message: string, details: RpcErrorDetails): RpcError;
|
|
1274
|
-
static invalidResponse(details: RpcErrorDetails): RpcError;
|
|
1275
|
-
static accountNotFound(pubkey: string): RpcError;
|
|
1276
|
-
static rateLimitExceeded(details: RpcErrorDetails): RpcError;
|
|
1277
|
-
static fromRpcCode(rpcCode: number, message: string, details: RpcErrorDetails): RpcError;
|
|
1278
|
-
toJSON(): {
|
|
1279
|
-
code: RpcErrorCode;
|
|
1280
|
-
message: string;
|
|
1281
|
-
details?: Record<string, unknown>;
|
|
1282
|
-
retryable: boolean;
|
|
1283
|
-
};
|
|
1308
|
+
interface SendTransactionOptions {
|
|
1309
|
+
/** Skip preflight transaction checks */
|
|
1310
|
+
skipPreflight?: boolean;
|
|
1311
|
+
/** Maximum number of times to retry */
|
|
1312
|
+
maxRetries?: number;
|
|
1284
1313
|
}
|
|
1285
|
-
|
|
1286
1314
|
/**
|
|
1287
|
-
*
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
*
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1315
|
+
* Epoch information response.
|
|
1316
|
+
*/
|
|
1317
|
+
interface EpochInfoResponse {
|
|
1318
|
+
/** Current epoch */
|
|
1319
|
+
epoch: bigint;
|
|
1320
|
+
/** Current slot in the epoch */
|
|
1321
|
+
slotIndex: bigint;
|
|
1322
|
+
/** Total slots in the epoch */
|
|
1323
|
+
slotsInEpoch: bigint;
|
|
1324
|
+
/** Absolute slot number */
|
|
1325
|
+
absoluteSlot: bigint;
|
|
1326
|
+
/** Block height */
|
|
1327
|
+
blockHeight: bigint;
|
|
1328
|
+
/** Transaction count */
|
|
1329
|
+
transactionCount?: bigint;
|
|
1330
|
+
}
|
|
1331
|
+
/**
|
|
1332
|
+
* Fee for message response.
|
|
1333
|
+
*/
|
|
1334
|
+
interface GetFeeForMessageResponse {
|
|
1335
|
+
/** Fee in smallest denomination */
|
|
1336
|
+
value: bigint;
|
|
1337
|
+
}
|
|
1338
|
+
/**
|
|
1339
|
+
* Multiple accounts response.
|
|
1340
|
+
*/
|
|
1341
|
+
interface MultipleAccountsResponse {
|
|
1342
|
+
/** Array of account information */
|
|
1343
|
+
value: Array<AccountInfo | null>;
|
|
1344
|
+
}
|
|
1345
|
+
/**
|
|
1346
|
+
* Get subscriptions response.
|
|
1347
|
+
*/
|
|
1348
|
+
interface GetSubscriptionsResponse {
|
|
1349
|
+
/** Array of subscription data */
|
|
1350
|
+
subscriptions: Array<Record<string, unknown>>;
|
|
1351
|
+
}
|
|
1352
|
+
/**
|
|
1353
|
+
* Get triggered transactions response.
|
|
1354
|
+
*/
|
|
1355
|
+
interface GetTriggeredTransactionsResponse {
|
|
1356
|
+
/** Array of triggered transaction data */
|
|
1357
|
+
transactions: Array<Record<string, unknown>>;
|
|
1358
|
+
}
|
|
1359
|
+
/**
|
|
1360
|
+
* Get workflow lineage request.
|
|
1361
|
+
*/
|
|
1362
|
+
interface GetWorkflowLineageRequest {
|
|
1363
|
+
/** Workflow account public key */
|
|
1364
|
+
workflowAccount: PublicKey;
|
|
1365
|
+
/** Optional limit on results */
|
|
1366
|
+
limit?: number;
|
|
1367
|
+
}
|
|
1368
|
+
/**
|
|
1369
|
+
* Get workflow lineage response.
|
|
1370
|
+
*/
|
|
1371
|
+
interface GetWorkflowLineageResponse {
|
|
1372
|
+
/** Workflow lineage data */
|
|
1373
|
+
lineage: Array<Record<string, unknown>>;
|
|
1374
|
+
}
|
|
1375
|
+
/**
|
|
1376
|
+
* Get signatures for address configuration.
|
|
1377
|
+
*/
|
|
1378
|
+
interface GetSignaturesForAddressConfig {
|
|
1379
|
+
/** Maximum number of signatures to return */
|
|
1380
|
+
limit?: number;
|
|
1381
|
+
/** Start searching backwards from this signature */
|
|
1382
|
+
before?: string;
|
|
1383
|
+
/** Start searching forwards from this signature */
|
|
1384
|
+
until?: string;
|
|
1385
|
+
}
|
|
1386
|
+
/**
|
|
1387
|
+
* Get signatures for address response.
|
|
1388
|
+
*/
|
|
1389
|
+
interface GetSignaturesForAddressResponse {
|
|
1390
|
+
/** Array of signature information */
|
|
1391
|
+
signatures: Array<{
|
|
1392
|
+
signature: string;
|
|
1393
|
+
slot: bigint;
|
|
1394
|
+
err?: string;
|
|
1395
|
+
memo?: string;
|
|
1396
|
+
blockTime?: bigint;
|
|
1397
|
+
}>;
|
|
1398
|
+
}
|
|
1399
|
+
/**
|
|
1400
|
+
* Is blockhash valid response.
|
|
1401
|
+
*/
|
|
1402
|
+
interface IsBlockhashValidResponse {
|
|
1403
|
+
/** Whether the blockhash is valid */
|
|
1404
|
+
value: boolean;
|
|
1405
|
+
}
|
|
1406
|
+
/**
|
|
1407
|
+
* Get health response.
|
|
1408
|
+
*/
|
|
1409
|
+
type GetHealthResponse = "ok" | string;
|
|
1410
|
+
/**
|
|
1411
|
+
* Get validator health response.
|
|
1309
1412
|
*/
|
|
1310
|
-
|
|
1413
|
+
type GetValidatorHealthResponse = "ok" | string;
|
|
1311
1414
|
/**
|
|
1312
|
-
*
|
|
1313
|
-
*
|
|
1314
|
-
* @param url - RPC endpoint URL (e.g., URL_DEVNET, URL_MAINNET)
|
|
1315
|
-
* @param config - Transport configuration (timeout, retries, headers)
|
|
1316
|
-
* @returns Configured RialoClient instance
|
|
1415
|
+
* Get connected full nodes response.
|
|
1317
1416
|
*/
|
|
1318
|
-
|
|
1319
|
-
|
|
1417
|
+
interface GetConnectedFullNodesResponse {
|
|
1418
|
+
/** Array of connected nodes */
|
|
1419
|
+
nodes: Array<{
|
|
1420
|
+
publicKey: string;
|
|
1421
|
+
connectedTime: bigint;
|
|
1422
|
+
}>;
|
|
1423
|
+
}
|
|
1320
1424
|
/**
|
|
1321
|
-
*
|
|
1322
|
-
*
|
|
1323
|
-
* This is the data that gets signed by transaction signers.
|
|
1324
|
-
* It's immutable to prevent accidental modification after creation.
|
|
1325
|
-
*
|
|
1326
|
-
* @example
|
|
1327
|
-
* ```typescript
|
|
1328
|
-
* const message = MessageBuilder.create()
|
|
1329
|
-
* .setPayer(payer)
|
|
1330
|
-
* .setRecentBlockhash(blockhash)
|
|
1331
|
-
* .setCreationTime(txCreationTime)
|
|
1332
|
-
* .addInstruction(transferInstruction)
|
|
1333
|
-
* .build();
|
|
1334
|
-
*
|
|
1335
|
-
* // Serialize for signing
|
|
1336
|
-
* const messageBytes = message.serialize();
|
|
1337
|
-
* ```
|
|
1425
|
+
* Get transactions configuration.
|
|
1338
1426
|
*/
|
|
1339
|
-
|
|
1340
|
-
/**
|
|
1341
|
-
|
|
1342
|
-
/**
|
|
1343
|
-
|
|
1344
|
-
/** Recent blockhash for replay protection */
|
|
1345
|
-
readonly recentBlockhash: Blockhash;
|
|
1346
|
-
/** Transaction creation timestamp (milliseconds since Unix epoch) */
|
|
1347
|
-
txCreationTime?: bigint;
|
|
1348
|
-
/** Compiled instructions with account indices */
|
|
1349
|
-
readonly instructions: readonly CompiledInstruction[];
|
|
1350
|
-
/** Cached serialized bytes */
|
|
1351
|
-
private serializedCache?;
|
|
1352
|
-
constructor(header: MessageHeader, accountKeys: readonly PublicKey[], recentBlockhash: Blockhash, txCreationTime: bigint, instructions: readonly CompiledInstruction[]);
|
|
1353
|
-
/**
|
|
1354
|
-
* Serialize message to bytes for signing.
|
|
1355
|
-
* Result is cached for performance.
|
|
1356
|
-
*/
|
|
1357
|
-
serialize(): Uint8Array;
|
|
1358
|
-
/**
|
|
1359
|
-
* Deserialize a message from wire format.
|
|
1360
|
-
*
|
|
1361
|
-
* @param data - Serialized message bytes
|
|
1362
|
-
* @returns Deserialized Message
|
|
1363
|
-
*/
|
|
1364
|
-
static deserialize(data: Uint8Array): Message;
|
|
1365
|
-
private serializeInternal;
|
|
1366
|
-
private serializeCompactArray;
|
|
1367
|
-
private serializeCompactU16;
|
|
1368
|
-
/**
|
|
1369
|
-
* Get all signers required for this message.
|
|
1370
|
-
*/
|
|
1371
|
-
getSigners(): readonly PublicKey[];
|
|
1372
|
-
/**
|
|
1373
|
-
* Check if a public key is a required signer.
|
|
1374
|
-
*/
|
|
1375
|
-
isSignerRequired(pubkey: PublicKey): boolean;
|
|
1376
|
-
/**
|
|
1377
|
-
* Get the index of a signer in the signers array.
|
|
1378
|
-
* Returns -1 if not a signer.
|
|
1379
|
-
*/
|
|
1380
|
-
getSignerIndex(pubkey: PublicKey): number;
|
|
1427
|
+
interface GetTransactionsConfig {
|
|
1428
|
+
/** Maximum number of transactions to return */
|
|
1429
|
+
limit?: number;
|
|
1430
|
+
/** Encoding format */
|
|
1431
|
+
encoding?: "json" | "base58" | "base64";
|
|
1381
1432
|
}
|
|
1382
|
-
|
|
1383
1433
|
/**
|
|
1384
|
-
*
|
|
1385
|
-
*
|
|
1386
|
-
* Enables multiple signing strategies:
|
|
1387
|
-
* - **KeypairSigner**: Local keypair signing
|
|
1388
|
-
* - **Browser Wallet**: Browser extension integration
|
|
1389
|
-
* - **Hardware Wallet**: Ledger, Trezor, etc.
|
|
1390
|
-
* - **Remote Signer**: API-based signing services
|
|
1391
|
-
*
|
|
1392
|
-
* @example
|
|
1393
|
-
* ```typescript
|
|
1394
|
-
* // Browser wallet implementation
|
|
1395
|
-
* class BrowserWalletSigner implements Signer {
|
|
1396
|
-
* async getPublicKey(): Promise<PublicKey> {
|
|
1397
|
-
* const pubkey = await window.rialoWallet.getPublicKey();
|
|
1398
|
-
* return PublicKey.fromString(pubkey);
|
|
1399
|
-
* }
|
|
1400
|
-
*
|
|
1401
|
-
* async signMessage(message: Uint8Array): Promise<Signature> {
|
|
1402
|
-
* const sig = await window.rialoWallet.signMessage(message);
|
|
1403
|
-
* return Signature.fromBytes(sig);
|
|
1404
|
-
* }
|
|
1405
|
-
* }
|
|
1406
|
-
*
|
|
1407
|
-
* // Usage
|
|
1408
|
-
* const signer = new BrowserWalletSigner();
|
|
1409
|
-
* const publicKey = await signer.getPublicKey();
|
|
1410
|
-
* const signature = await signer.signMessage(message);
|
|
1411
|
-
* ```
|
|
1434
|
+
* Get transactions response.
|
|
1412
1435
|
*/
|
|
1413
|
-
interface
|
|
1414
|
-
/**
|
|
1415
|
-
|
|
1416
|
-
*
|
|
1417
|
-
* **Note**: May trigger wallet connection prompts for browser wallets.
|
|
1418
|
-
*/
|
|
1419
|
-
getPublicKey(): Promise<PublicKey>;
|
|
1420
|
-
/**
|
|
1421
|
-
* Signs arbitrary message bytes.
|
|
1422
|
-
*
|
|
1423
|
-
* @param message - Message bytes to sign
|
|
1424
|
-
* @returns Ed25519 signature over the message
|
|
1425
|
-
*/
|
|
1426
|
-
signMessage(message: Uint8Array): Promise<Signature>;
|
|
1436
|
+
interface GetTransactionsResponse {
|
|
1437
|
+
/** Array of transaction data */
|
|
1438
|
+
transactions: Array<Record<string, unknown>>;
|
|
1427
1439
|
}
|
|
1428
1440
|
|
|
1429
1441
|
/**
|
|
1430
|
-
*
|
|
1431
|
-
*
|
|
1432
|
-
* Provides synchronous signing without external dependencies.
|
|
1433
|
-
* Suitable for server-side applications, CLIs, and testing.
|
|
1434
|
-
*
|
|
1435
|
-
* @example
|
|
1436
|
-
* ```typescript
|
|
1437
|
-
* import { Keypair, KeypairSigner } from '@rialo/ts-cdk';
|
|
1438
|
-
*
|
|
1439
|
-
* // Generate new keypair
|
|
1440
|
-
* const keypair = Keypair.generate();
|
|
1441
|
-
* const signer = new KeypairSigner(keypair);
|
|
1442
|
-
*
|
|
1443
|
-
* // Or from mnemonic
|
|
1444
|
-
* const mnemonic = Mnemonic.generate();
|
|
1445
|
-
* const keypair = await mnemonic.toKeypair(0);
|
|
1446
|
-
* const signer = new KeypairSigner(keypair);
|
|
1447
|
-
*
|
|
1448
|
-
* // Sign messages
|
|
1449
|
-
* const publicKey = await signer.getPublicKey();
|
|
1450
|
-
* const signature = await signer.signMessage(message);
|
|
1451
|
-
* ```
|
|
1442
|
+
* Main Rialo RPC client for blockchain interactions.
|
|
1452
1443
|
*/
|
|
1453
|
-
declare class KeypairSigner implements Signer {
|
|
1454
|
-
private readonly keypair;
|
|
1455
|
-
constructor(keypair: Keypair);
|
|
1456
|
-
/**
|
|
1457
|
-
* Returns the keypair's public key.
|
|
1458
|
-
*/
|
|
1459
|
-
getPublicKey(): Promise<PublicKey>;
|
|
1460
|
-
/**
|
|
1461
|
-
* Signs a message using the keypair's private key.
|
|
1462
|
-
*/
|
|
1463
|
-
signMessage(message: Uint8Array): Promise<Signature>;
|
|
1464
|
-
}
|
|
1465
1444
|
|
|
1466
1445
|
/**
|
|
1467
|
-
*
|
|
1446
|
+
* High-level Rialo RPC client for blockchain interactions.
|
|
1468
1447
|
*
|
|
1469
|
-
*
|
|
1470
|
-
*
|
|
1448
|
+
* Provides a unified interface for querying blockchain state and
|
|
1449
|
+
* sending transactions. Internally delegates to specialized clients
|
|
1450
|
+
* (QueryRpcClient, TransactionRpcClient) for modular organization.
|
|
1471
1451
|
*
|
|
1472
1452
|
* @example
|
|
1473
1453
|
* ```typescript
|
|
1474
|
-
*
|
|
1475
|
-
* const tx = builder.build();
|
|
1476
|
-
* const signed = tx.sign(keypair);
|
|
1454
|
+
* import { createRialoClient, RIALO_DEVNET_CHAIN } from '@rialo/ts-cdk';
|
|
1477
1455
|
*
|
|
1478
|
-
*
|
|
1479
|
-
* const signed = tx
|
|
1480
|
-
* .sign(keypair1)
|
|
1481
|
-
* .sign(keypair2)
|
|
1482
|
-
* .sign(keypair3);
|
|
1456
|
+
* const client = createRialoClient({ chain: RIALO_DEVNET_CHAIN });
|
|
1483
1457
|
*
|
|
1484
|
-
* //
|
|
1485
|
-
* const
|
|
1458
|
+
* // Query operations
|
|
1459
|
+
* const balance = await client.getBalance(publicKey);
|
|
1460
|
+
* const chainId = client.getChainIdentifier();
|
|
1461
|
+
*
|
|
1462
|
+
* // Transaction operations
|
|
1463
|
+
* const signature = await client.sendTransaction(signedTx);
|
|
1486
1464
|
* ```
|
|
1487
1465
|
*/
|
|
1488
|
-
declare class
|
|
1489
|
-
|
|
1490
|
-
private readonly
|
|
1491
|
-
|
|
1492
|
-
private readonly
|
|
1493
|
-
|
|
1466
|
+
declare class RialoClient {
|
|
1467
|
+
private readonly queryClient;
|
|
1468
|
+
private readonly transactionClient;
|
|
1469
|
+
private readonly transport;
|
|
1470
|
+
private readonly chain;
|
|
1471
|
+
constructor(transport: HttpTransport, chain: ChainDefinition);
|
|
1494
1472
|
/**
|
|
1495
|
-
*
|
|
1496
|
-
* All signature slots are initialized to zero.
|
|
1497
|
-
*
|
|
1498
|
-
* @internal - Users should use TransactionBuilder instead
|
|
1473
|
+
* Returns the configured RPC endpoint URL.
|
|
1499
1474
|
*/
|
|
1500
|
-
|
|
1475
|
+
getUrl(): string;
|
|
1501
1476
|
/**
|
|
1502
|
-
*
|
|
1503
|
-
* @internal
|
|
1477
|
+
* Returns the chain identifier.
|
|
1504
1478
|
*/
|
|
1505
|
-
|
|
1479
|
+
getChainIdentifier(): IdentifierString;
|
|
1506
1480
|
/**
|
|
1507
|
-
*
|
|
1481
|
+
* Retrieves the balance of an account in kelvins (smallest unit).
|
|
1508
1482
|
*/
|
|
1509
|
-
|
|
1510
|
-
getMessage(): Message;
|
|
1483
|
+
getBalance(pubkey: PublicKey): Promise<bigint>;
|
|
1511
1484
|
/**
|
|
1512
|
-
*
|
|
1513
|
-
* Returns a NEW Transaction instance.
|
|
1514
|
-
*
|
|
1515
|
-
* @param keypair - Keypair to sign with
|
|
1516
|
-
* @returns New Transaction instance with signature added
|
|
1485
|
+
* Retrieves detailed information about an account.
|
|
1517
1486
|
*
|
|
1518
|
-
* @
|
|
1519
|
-
* ```typescript
|
|
1520
|
-
* const signedTx = tx.sign(keypair);
|
|
1521
|
-
* await client.sendTransaction(signedTx.serialize());
|
|
1522
|
-
* ```
|
|
1487
|
+
* @returns Account info or null if account doesn't exist
|
|
1523
1488
|
*/
|
|
1524
|
-
|
|
1489
|
+
getAccountInfo(pubkey: PublicKey): Promise<AccountInfo | null>;
|
|
1525
1490
|
/**
|
|
1526
|
-
*
|
|
1527
|
-
* Returns a NEW Transaction instance.
|
|
1528
|
-
*
|
|
1529
|
-
* @example
|
|
1530
|
-
* ```typescript
|
|
1531
|
-
* const signed = tx.signAll([keypair1, keypair2, keypair3]);
|
|
1532
|
-
* ```
|
|
1491
|
+
* Retrieves the current block height.
|
|
1533
1492
|
*/
|
|
1534
|
-
|
|
1493
|
+
getBlockHeight(): Promise<bigint>;
|
|
1535
1494
|
/**
|
|
1536
|
-
*
|
|
1537
|
-
* Returns a NEW Transaction instance.
|
|
1495
|
+
* Retrieves detailed information about a transaction.
|
|
1538
1496
|
*
|
|
1539
|
-
* @
|
|
1540
|
-
* ```typescript
|
|
1541
|
-
* const signedTx = await tx.signWith(browserWallet);
|
|
1542
|
-
* ```
|
|
1497
|
+
* @returns Transaction info or null if transaction not found
|
|
1543
1498
|
*/
|
|
1544
|
-
|
|
1499
|
+
getTransaction(signature: string): Promise<TransactionResponse | null>;
|
|
1545
1500
|
/**
|
|
1546
|
-
*
|
|
1547
|
-
* Returns a NEW Transaction instance.
|
|
1501
|
+
* Retrieves the total number of transactions processed since genesis.
|
|
1548
1502
|
*/
|
|
1549
|
-
|
|
1503
|
+
getTransactionCount(): Promise<bigint>;
|
|
1550
1504
|
/**
|
|
1551
|
-
*
|
|
1552
|
-
* Returns a NEW Transaction instance.
|
|
1553
|
-
*
|
|
1554
|
-
* @example
|
|
1555
|
-
* ```typescript
|
|
1556
|
-
* const signedTx = tx
|
|
1557
|
-
* .partialSign(signer1)
|
|
1558
|
-
* .partialSign(signer2);
|
|
1559
|
-
* ```
|
|
1505
|
+
* Retrieves the status of multiple transaction signatures.
|
|
1560
1506
|
*/
|
|
1561
|
-
|
|
1507
|
+
getSignatureStatuses(signatures: string[]): Promise<(SignatureStatus | null)[]>;
|
|
1508
|
+
/**
|
|
1509
|
+
* Retrieves current epoch information.
|
|
1510
|
+
*/
|
|
1511
|
+
getEpochInfo(): Promise<EpochInfoResponse>;
|
|
1562
1512
|
/**
|
|
1563
|
-
*
|
|
1564
|
-
*
|
|
1513
|
+
* Checks the health status of the RPC node.
|
|
1514
|
+
*
|
|
1515
|
+
* @returns "ok" if healthy, error message otherwise
|
|
1565
1516
|
*/
|
|
1566
|
-
|
|
1517
|
+
getHealth(): Promise<"ok" | string>;
|
|
1567
1518
|
/**
|
|
1568
|
-
*
|
|
1569
|
-
* Returns a NEW Transaction instance.
|
|
1519
|
+
* Submits a signed transaction to the blockchain.
|
|
1570
1520
|
*
|
|
1571
|
-
*
|
|
1521
|
+
* @param transaction - Serialized signed transaction bytes
|
|
1522
|
+
* @param options - Transaction submission options
|
|
1523
|
+
* @returns Transaction signature
|
|
1572
1524
|
*/
|
|
1573
|
-
|
|
1525
|
+
sendTransaction(transaction: Uint8Array, options?: SendTransactionOptions): Promise<string>;
|
|
1574
1526
|
/**
|
|
1575
|
-
*
|
|
1576
|
-
* Returns a NEW Transaction instance.
|
|
1527
|
+
* Requests an airdrop of tokens to an account.
|
|
1577
1528
|
*
|
|
1578
|
-
*
|
|
1529
|
+
* **Note**: Only available on devnet and testnet.
|
|
1530
|
+
*
|
|
1531
|
+
* @param pubkey - Account to receive the airdrop
|
|
1532
|
+
* @param amount - Amount in kelvins (smallest unit)
|
|
1533
|
+
* @returns Transaction signature
|
|
1579
1534
|
*/
|
|
1580
|
-
|
|
1535
|
+
requestAirdrop(pubkey: PublicKey, amount: bigint): Promise<string>;
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1538
|
+
/**
|
|
1539
|
+
* Query client for read-only RPC operations.
|
|
1540
|
+
*/
|
|
1541
|
+
|
|
1542
|
+
/**
|
|
1543
|
+
* Client for querying blockchain state.
|
|
1544
|
+
*
|
|
1545
|
+
* Handles all read-only operations like getting balances, account info, etc.
|
|
1546
|
+
*/
|
|
1547
|
+
declare class QueryRpcClient extends BaseRpcClient {
|
|
1581
1548
|
/**
|
|
1582
|
-
*
|
|
1549
|
+
* Get the balance of an account
|
|
1583
1550
|
*/
|
|
1584
|
-
|
|
1551
|
+
getBalance(pubkey: PublicKey): Promise<bigint>;
|
|
1585
1552
|
/**
|
|
1586
|
-
*
|
|
1553
|
+
* Get detailed information about an account
|
|
1587
1554
|
*/
|
|
1588
|
-
|
|
1555
|
+
getAccountInfo(pubkey: PublicKey): Promise<AccountInfo | null>;
|
|
1589
1556
|
/**
|
|
1590
|
-
* Get
|
|
1557
|
+
* Get the current block height
|
|
1591
1558
|
*/
|
|
1592
|
-
|
|
1559
|
+
getBlockHeight(): Promise<bigint>;
|
|
1593
1560
|
/**
|
|
1594
|
-
* Get
|
|
1561
|
+
* Get detailed information about a transaction
|
|
1595
1562
|
*/
|
|
1596
|
-
|
|
1563
|
+
getTransaction(signature: string): Promise<TransactionResponse | null>;
|
|
1597
1564
|
/**
|
|
1598
|
-
* Get
|
|
1565
|
+
* Get the total number of transactions processed since genesis
|
|
1599
1566
|
*/
|
|
1600
|
-
|
|
1567
|
+
getTransactionCount(): Promise<bigint>;
|
|
1601
1568
|
/**
|
|
1602
|
-
* Get
|
|
1569
|
+
* Get the status of multiple transaction signatures
|
|
1603
1570
|
*/
|
|
1604
|
-
|
|
1571
|
+
getSignatureStatuses(signatures: string[]): Promise<(SignatureStatus | null)[]>;
|
|
1605
1572
|
/**
|
|
1606
|
-
* Get
|
|
1573
|
+
* Get epoch information
|
|
1607
1574
|
*/
|
|
1608
|
-
|
|
1575
|
+
getEpochInfo(): Promise<EpochInfoResponse>;
|
|
1609
1576
|
/**
|
|
1610
|
-
*
|
|
1611
|
-
*
|
|
1612
|
-
* @throws {TransactionError} If transaction is not fully signed
|
|
1613
|
-
*
|
|
1614
|
-
* @example
|
|
1615
|
-
* ```typescript
|
|
1616
|
-
* signedTx.ensureSigned(); // Throws if not signed
|
|
1617
|
-
* await client.sendTransaction(signedTx.serialize());
|
|
1618
|
-
* ```
|
|
1577
|
+
* Get the health status of the node
|
|
1619
1578
|
*/
|
|
1620
|
-
|
|
1579
|
+
getHealth(): Promise<"ok" | string>;
|
|
1580
|
+
}
|
|
1581
|
+
|
|
1582
|
+
/**
|
|
1583
|
+
* Query client for read-only RPC operations.
|
|
1584
|
+
*/
|
|
1585
|
+
|
|
1586
|
+
/**
|
|
1587
|
+
* Client for sending/simulating transactions and requesting airdrops.
|
|
1588
|
+
*
|
|
1589
|
+
* Handles all transaction operations like sending transactions, requesting airdrops, etc.
|
|
1590
|
+
*/
|
|
1591
|
+
declare class TransactionRpcClient extends BaseRpcClient {
|
|
1621
1592
|
/**
|
|
1622
|
-
*
|
|
1593
|
+
* Submit a signed transaction to the blockchain
|
|
1623
1594
|
*/
|
|
1624
|
-
|
|
1595
|
+
sendTransaction(transaction: Uint8Array, options?: SendTransactionOptions): Promise<string>;
|
|
1596
|
+
/**
|
|
1597
|
+
* Request an airdrop of tokens to an account (devnet/testnet only)
|
|
1598
|
+
*/
|
|
1599
|
+
requestAirdrop(pubkey: PublicKey, amount: bigint): Promise<string>;
|
|
1625
1600
|
}
|
|
1626
1601
|
|
|
1627
1602
|
/**
|
|
1628
|
-
*
|
|
1629
|
-
|
|
1603
|
+
* Error codes for RPC operations, categorized by type.
|
|
1604
|
+
*/
|
|
1605
|
+
declare enum RpcErrorCode {
|
|
1606
|
+
REQUEST_TIMEOUT = "REQUEST_TIMEOUT",
|
|
1607
|
+
NETWORK_ERROR = "NETWORK_ERROR",
|
|
1608
|
+
CONNECTION_REFUSED = "CONNECTION_REFUSED",
|
|
1609
|
+
INVALID_NETWORK = "INVALID_NETWORK",
|
|
1610
|
+
INVALID_RESPONSE = "INVALID_RESPONSE",
|
|
1611
|
+
PARSE_ERROR = "PARSE_ERROR",
|
|
1612
|
+
INVALID_REQUEST = "INVALID_REQUEST",
|
|
1613
|
+
METHOD_NOT_FOUND = "METHOD_NOT_FOUND",
|
|
1614
|
+
INVALID_PARAMS = "INVALID_PARAMS",
|
|
1615
|
+
INTERNAL_ERROR = "INTERNAL_ERROR",
|
|
1616
|
+
TRANSACTION_REJECTED = "TRANSACTION_REJECTED",
|
|
1617
|
+
INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS",
|
|
1618
|
+
ACCOUNT_NOT_FOUND = "ACCOUNT_NOT_FOUND",
|
|
1619
|
+
RATE_LIMIT_EXCEEDED = "RATE_LIMIT_EXCEEDED",
|
|
1620
|
+
NODE_UNHEALTHY = "NODE_UNHEALTHY"
|
|
1621
|
+
}
|
|
1622
|
+
/**
|
|
1623
|
+
* Detailed error context for debugging and error handling.
|
|
1624
|
+
*/
|
|
1625
|
+
interface RpcErrorDetails {
|
|
1626
|
+
method?: string;
|
|
1627
|
+
params?: unknown;
|
|
1628
|
+
requestId?: number;
|
|
1629
|
+
url?: string;
|
|
1630
|
+
httpStatus?: number;
|
|
1631
|
+
rpcCode?: number;
|
|
1632
|
+
timeout?: number;
|
|
1633
|
+
attempts?: number;
|
|
1634
|
+
[key: string]: unknown;
|
|
1635
|
+
}
|
|
1636
|
+
/**
|
|
1637
|
+
* Error class for RPC operations with structured error information.
|
|
1638
|
+
*
|
|
1639
|
+
* Provides actionable error messages and indicates whether errors are retryable.
|
|
1630
1640
|
*/
|
|
1641
|
+
declare class RpcError extends Error {
|
|
1642
|
+
readonly code: RpcErrorCode;
|
|
1643
|
+
readonly details: RpcErrorDetails;
|
|
1644
|
+
readonly retryable: boolean;
|
|
1645
|
+
constructor(code: RpcErrorCode, message: string, details?: RpcErrorDetails, retryable?: boolean);
|
|
1646
|
+
static requestTimeout(timeoutMs: number, details: RpcErrorDetails): RpcError;
|
|
1647
|
+
static networkError(message: string, details: RpcErrorDetails): RpcError;
|
|
1648
|
+
static invalidResponse(details: RpcErrorDetails): RpcError;
|
|
1649
|
+
static accountNotFound(pubkey: string): RpcError;
|
|
1650
|
+
static rateLimitExceeded(details: RpcErrorDetails): RpcError;
|
|
1651
|
+
static fromRpcCode(rpcCode: number, message: string, details: RpcErrorDetails): RpcError;
|
|
1652
|
+
toJSON(): {
|
|
1653
|
+
code: RpcErrorCode;
|
|
1654
|
+
message: string;
|
|
1655
|
+
details?: Record<string, unknown>;
|
|
1656
|
+
retryable: boolean;
|
|
1657
|
+
};
|
|
1658
|
+
}
|
|
1631
1659
|
|
|
1632
1660
|
/**
|
|
1633
|
-
*
|
|
1661
|
+
* RPC client module for communicating with Rialo blockchain nodes.
|
|
1634
1662
|
*
|
|
1635
|
-
* Provides
|
|
1636
|
-
*
|
|
1663
|
+
* Provides a high-level client interface with automatic retry logic,
|
|
1664
|
+
* connection management, and type-safe RPC methods.
|
|
1637
1665
|
*
|
|
1638
1666
|
* @example
|
|
1639
1667
|
* ```typescript
|
|
1640
|
-
*
|
|
1641
|
-
*
|
|
1642
|
-
*
|
|
1643
|
-
*
|
|
1644
|
-
*
|
|
1645
|
-
*
|
|
1646
|
-
*
|
|
1668
|
+
* import { createRialoClient, RIALO_DEVNET_CHAIN } from '@rialo/ts-cdk';
|
|
1669
|
+
*
|
|
1670
|
+
* // Create client with chain definition and custom transport config
|
|
1671
|
+
* const client = createRialoClient({
|
|
1672
|
+
* chain: RIALO_DEVNET_CHAIN,
|
|
1673
|
+
* transport: {
|
|
1674
|
+
* timeout: 30000,
|
|
1675
|
+
* maxRetries: 3,
|
|
1676
|
+
* }
|
|
1677
|
+
* });
|
|
1647
1678
|
*
|
|
1648
|
-
*
|
|
1649
|
-
* await client.
|
|
1679
|
+
* // Query blockchain state
|
|
1680
|
+
* const balance = await client.getBalance(publicKey);
|
|
1681
|
+
* const blockHeight = await client.getBlockHeight();
|
|
1682
|
+
*
|
|
1683
|
+
* // Send transactions
|
|
1684
|
+
* const signature = await client.sendTransaction(signedTx);
|
|
1650
1685
|
* ```
|
|
1686
|
+
*/
|
|
1687
|
+
|
|
1688
|
+
/**
|
|
1689
|
+
* Creates an RPC client with automatic retry and timeout handling.
|
|
1690
|
+
*
|
|
1691
|
+
* @param config - Client configuration with chain definition and optional transport settings
|
|
1692
|
+
* @param config.chain - Chain definition (e.g., RIALO_DEVNET_CHAIN, RIALO_MAINNET_CHAIN)
|
|
1693
|
+
* @param config.endpoint - Optional RPC endpoint override (useful for custom RPC providers)
|
|
1694
|
+
* @param config.transport - Optional transport configuration (timeout, retries, headers)
|
|
1695
|
+
* @returns Configured RialoClient instance
|
|
1651
1696
|
*
|
|
1652
1697
|
* @example
|
|
1653
1698
|
* ```typescript
|
|
1654
|
-
* //
|
|
1655
|
-
* const
|
|
1656
|
-
*
|
|
1657
|
-
*
|
|
1658
|
-
*
|
|
1659
|
-
*
|
|
1660
|
-
*
|
|
1661
|
-
*
|
|
1699
|
+
* // Basic usage with preset chain
|
|
1700
|
+
* const client = createRialoClient({ chain: RIALO_DEVNET_CHAIN });
|
|
1701
|
+
*
|
|
1702
|
+
* // With custom transport config
|
|
1703
|
+
* const client = createRialoClient({
|
|
1704
|
+
* chain: RIALO_MAINNET_CHAIN,
|
|
1705
|
+
* transport: { timeout: 30000, maxRetries: 5 }
|
|
1706
|
+
* });
|
|
1707
|
+
*
|
|
1708
|
+
* // With custom RPC endpoint
|
|
1709
|
+
* const client = createRialoClient({
|
|
1710
|
+
* chain: RIALO_MAINNET_CHAIN,
|
|
1711
|
+
* endpoint: 'https://custom-rpc.example.com'
|
|
1712
|
+
* });
|
|
1662
1713
|
* ```
|
|
1663
1714
|
*/
|
|
1664
|
-
declare
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
*
|
|
1698
|
-
* @param txCreationTime - Transaction creation time in milliseconds since Unix epoch
|
|
1699
|
-
*/
|
|
1700
|
-
setTxCreationTime(txCreationTime: bigint): this;
|
|
1701
|
-
/**
|
|
1702
|
-
* Add an instruction to the transaction.
|
|
1703
|
-
*
|
|
1704
|
-
* @param instruction - Instruction to add
|
|
1705
|
-
*/
|
|
1706
|
-
addInstruction(instruction: Instruction): this;
|
|
1707
|
-
/**
|
|
1708
|
-
* Add multiple instructions at once.
|
|
1709
|
-
*
|
|
1710
|
-
* @param instructions - Array of instructions to add
|
|
1711
|
-
*/
|
|
1712
|
-
addInstructions(instructions: readonly Instruction[]): this;
|
|
1713
|
-
/**
|
|
1714
|
-
* Build the transaction (unsigned).
|
|
1715
|
-
*
|
|
1716
|
-
* Returns an unsigned Transaction that's ready to be signed.
|
|
1717
|
-
*
|
|
1718
|
-
* @returns Unsigned Transaction
|
|
1719
|
-
* @throws {TransactionError} If payer, blockhash, or instructions are missing
|
|
1720
|
-
*
|
|
1721
|
-
* @example
|
|
1722
|
-
* ```typescript
|
|
1723
|
-
* const tx = builder.build();
|
|
1724
|
-
* const signedTx = tx.sign(keypair);
|
|
1725
|
-
* ```
|
|
1726
|
-
*/
|
|
1727
|
-
build(): Transaction;
|
|
1728
|
-
}
|
|
1715
|
+
declare function createRialoClient(config: RialoClientConfig): RialoClient;
|
|
1716
|
+
/**
|
|
1717
|
+
* Returns a default RialoClientConfig for a given network.
|
|
1718
|
+
*
|
|
1719
|
+
* Provides preset chain configurations for standard Rialo networks, making it easy
|
|
1720
|
+
* to connect to mainnet, devnet, testnet, or localnet without manual configuration.
|
|
1721
|
+
*
|
|
1722
|
+
* @param network - Network identifier: "mainnet", "devnet", "testnet", or "localnet"
|
|
1723
|
+
* @returns Default RialoClientConfig for the specified network
|
|
1724
|
+
* @throws {RpcError} With code INVALID_NETWORK if an unknown network is provided
|
|
1725
|
+
*
|
|
1726
|
+
* @example
|
|
1727
|
+
* ```typescript
|
|
1728
|
+
* // Get devnet config and create client
|
|
1729
|
+
* const config = getDefaultRialoClientConfig('devnet');
|
|
1730
|
+
* const client = createRialoClient(config);
|
|
1731
|
+
*
|
|
1732
|
+
* // Customize the config with transport options
|
|
1733
|
+
* const config = getDefaultRialoClientConfig('mainnet');
|
|
1734
|
+
* const client = createRialoClient({
|
|
1735
|
+
* ...config,
|
|
1736
|
+
* transport: { timeout: 60000, maxRetries: 5 }
|
|
1737
|
+
* });
|
|
1738
|
+
*
|
|
1739
|
+
* // Use custom endpoint while preserving network identity
|
|
1740
|
+
* const config = getDefaultRialoClientConfig('mainnet');
|
|
1741
|
+
* const client = createRialoClient({
|
|
1742
|
+
* ...config,
|
|
1743
|
+
* endpoint: 'https://my-rpc-provider.com'
|
|
1744
|
+
* });
|
|
1745
|
+
* ```
|
|
1746
|
+
*/
|
|
1747
|
+
declare function getDefaultRialoClientConfig(network: RialoNetwork): RialoClientConfig;
|
|
1729
1748
|
|
|
1730
1749
|
/**
|
|
1731
1750
|
* Converts bytes to base64 string.
|
|
@@ -1771,4 +1790,4 @@ declare function getMainnetUrl(): string;
|
|
|
1771
1790
|
*/
|
|
1772
1791
|
declare function getLocalnetUrl(): string;
|
|
1773
1792
|
|
|
1774
|
-
export { type AccountInfo, type AccountMeta, AccountMetaTable, BASE_DERIVATION_PATH,
|
|
1793
|
+
export { type AccountInfo, type AccountMeta, AccountMetaTable, BASE_DERIVATION_PATH, BaseRpcClient, type ChainDefinition, type CompiledInstruction, CryptoError, CryptoErrorCode, DEFAULT_NUM_ACCOUNTS, type EpochInfoResponse, type GetConnectedFullNodesResponse, type GetFeeForMessageResponse, type GetHealthResponse, type GetSignaturesForAddressConfig, type GetSignaturesForAddressResponse, type GetSubscriptionsResponse, type GetTransactionsConfig, type GetTransactionsResponse, type GetTriggeredTransactionsResponse, type GetValidatorHealthResponse, type GetWorkflowLineageRequest, type GetWorkflowLineageResponse, HttpTransport, type HttpTransportConfig, type IdentifierString, type Instruction, type IsBlockhashValidResponse, KELVIN_PER_RLO, Keypair, KeypairSigner, Message, type MessageHeader, Mnemonic, type MnemonicStrength, type MultipleAccountsResponse, PUBLIC_KEY_LENGTH, PublicKey, QueryRpcClient, RIALO_DEVNET_CHAIN, RIALO_LOCALNET_CHAIN, RIALO_MAINNET_CHAIN, RIALO_TESTNET_CHAIN, RialoClient, type RialoClientConfig, RialoError, RialoErrorType, type RialoNetwork, RpcError, RpcErrorCode, type RpcErrorDetails$1 as RpcErrorDetails, SECRET_KEY_LENGTH, SIGNATURE_LENGTH, SYSTEM_PROGRAM_ID, type SendTransactionOptions, Signature, type SignatureStatus, type Signer, SystemInstruction, Transaction, TransactionBuilder, TransactionError, TransactionErrorCode, type TransactionResponse, TransactionRpcClient, URL_DEVNET, URL_LOCALNET, URL_MAINNET, URL_TESTNET, calculateBackoff, createAccount, createBorshInstruction, createRialoClient, encodeBorshData, fromBase64, getDefaultRialoClientConfig, getDevnetUrl, getLocalnetUrl, getMainnetUrl, getTestnetUrl, sleep, toBase64, transferInstruction };
|