@vleap/warps-adapter-fastset 0.1.0-alpha.14 → 0.1.0-alpha.16

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.
@@ -0,0 +1,376 @@
1
+ import { WarpChainAsset, AdapterFactory, AdapterWarpDataLoader, WarpClientConfig, WarpChainInfo, WarpChainAccount, WarpDataLoaderOptions, WarpChainAction, AdapterWarpExecutor, WarpExecutable, WarpActionInputType, AdapterWarpExplorer, AdapterWarpResults, Warp, WarpExecution, ResolvedInput, WarpExecutionResults, AdapterWarpSerializer, WarpSerializer, WarpNativeValue, BaseWarpActionInputType, WarpAdapterGenericType } from '@vleap/warps';
2
+ import * as _mysten_bcs from '@mysten/bcs';
3
+
4
+ declare const WarpFastsetConstants: {};
5
+
6
+ declare const NativeTokenSet: WarpChainAsset;
7
+ declare const getFastsetAdapter: AdapterFactory;
8
+
9
+ declare const Bytes32: _mysten_bcs.BcsType<number[], Iterable<number> & {
10
+ length: number;
11
+ }>;
12
+ declare const PublicKey: _mysten_bcs.BcsType<number[], Iterable<number> & {
13
+ length: number;
14
+ }>;
15
+ declare const Address: _mysten_bcs.BcsType<{
16
+ External: number[];
17
+ } | {
18
+ FastSet: number[];
19
+ }, {
20
+ External: Iterable<number> & {
21
+ length: number;
22
+ };
23
+ } | {
24
+ FastSet: Iterable<number> & {
25
+ length: number;
26
+ };
27
+ }>;
28
+ declare const Amount: _mysten_bcs.BcsType<string, unknown>;
29
+ declare const UserData: _mysten_bcs.BcsType<number[] | null, (Iterable<number> & {
30
+ length: number;
31
+ }) | null | undefined>;
32
+ declare const Nonce: _mysten_bcs.BcsType<string, string | number | bigint>;
33
+ declare const Transfer: _mysten_bcs.BcsType<{
34
+ recipient: {
35
+ External: number[];
36
+ } | {
37
+ FastSet: number[];
38
+ };
39
+ amount: string;
40
+ user_data: number[] | null;
41
+ }, {
42
+ recipient: {
43
+ External: Iterable<number> & {
44
+ length: number;
45
+ };
46
+ } | {
47
+ FastSet: Iterable<number> & {
48
+ length: number;
49
+ };
50
+ };
51
+ amount: unknown;
52
+ user_data: (Iterable<number> & {
53
+ length: number;
54
+ }) | null | undefined;
55
+ }>;
56
+ declare const ClaimType: _mysten_bcs.BcsType<{
57
+ Transfer: {
58
+ recipient: {
59
+ External: number[];
60
+ } | {
61
+ FastSet: number[];
62
+ };
63
+ amount: string;
64
+ user_data: number[] | null;
65
+ };
66
+ }, {
67
+ Transfer: {
68
+ recipient: {
69
+ External: Iterable<number> & {
70
+ length: number;
71
+ };
72
+ } | {
73
+ FastSet: Iterable<number> & {
74
+ length: number;
75
+ };
76
+ };
77
+ amount: unknown;
78
+ user_data: (Iterable<number> & {
79
+ length: number;
80
+ }) | null | undefined;
81
+ };
82
+ }>;
83
+ declare const BcsTransaction: _mysten_bcs.BcsType<{
84
+ sender: number[];
85
+ nonce: string;
86
+ timestamp_nanos: string;
87
+ claim: {
88
+ Transfer: {
89
+ recipient: {
90
+ External: number[];
91
+ } | {
92
+ FastSet: number[];
93
+ };
94
+ amount: string;
95
+ user_data: number[] | null;
96
+ };
97
+ };
98
+ }, {
99
+ sender: Iterable<number> & {
100
+ length: number;
101
+ };
102
+ nonce: string | number | bigint;
103
+ timestamp_nanos: string | number | bigint;
104
+ claim: {
105
+ Transfer: {
106
+ recipient: {
107
+ External: Iterable<number> & {
108
+ length: number;
109
+ };
110
+ } | {
111
+ FastSet: Iterable<number> & {
112
+ length: number;
113
+ };
114
+ };
115
+ amount: unknown;
116
+ user_data: (Iterable<number> & {
117
+ length: number;
118
+ }) | null | undefined;
119
+ };
120
+ };
121
+ }>;
122
+ interface FastsetTransaction {
123
+ sender: Uint8Array;
124
+ nonce: number;
125
+ timestamp_nanos: bigint;
126
+ claim: {
127
+ Transfer: {
128
+ recipient: {
129
+ FastSet: Uint8Array;
130
+ } | {
131
+ External: Uint8Array;
132
+ };
133
+ amount: string;
134
+ user_data: Uint8Array | null;
135
+ };
136
+ };
137
+ }
138
+ interface FastsetTransferRequest {
139
+ recipient: Uint8Array;
140
+ amount: string;
141
+ user_data?: Uint8Array;
142
+ }
143
+ interface FastsetAccountInfo {
144
+ balance: string;
145
+ next_nonce: number;
146
+ sequence_number: number;
147
+ }
148
+ interface FastsetSubmitTransactionRequest {
149
+ transaction: FastsetTransaction;
150
+ signature: Uint8Array;
151
+ }
152
+ interface FastsetSubmitTransactionResponse {
153
+ transaction_hash: Uint8Array;
154
+ validator: Uint8Array;
155
+ signature: Uint8Array;
156
+ }
157
+ interface FastsetSubmitCertificateRequest {
158
+ transaction: FastsetTransaction;
159
+ signature: Uint8Array;
160
+ validator_signatures: [Uint8Array, Uint8Array][];
161
+ }
162
+ interface FastsetFaucetRequest {
163
+ recipient: Uint8Array;
164
+ amount: string;
165
+ }
166
+ interface FastsetFaucetResponse {
167
+ balance: string;
168
+ }
169
+ interface FastsetJsonRpcRequest {
170
+ jsonrpc: '2.0';
171
+ id: number;
172
+ method: string;
173
+ params: Record<string, unknown>;
174
+ }
175
+ interface FastsetJsonRpcResponse<T = unknown> {
176
+ jsonrpc: '2.0';
177
+ id: number;
178
+ result?: T;
179
+ error?: {
180
+ code: number;
181
+ message: string;
182
+ data?: unknown;
183
+ };
184
+ }
185
+ interface FastsetAssetBalance {
186
+ asset_id: string;
187
+ balance: string;
188
+ name?: string;
189
+ decimals?: number;
190
+ logo_url?: string;
191
+ }
192
+ interface FastsetAssetBalances {
193
+ [assetId: string]: FastsetAssetBalance;
194
+ }
195
+
196
+ interface ClaimData {
197
+ [key: string]: unknown;
198
+ }
199
+ declare abstract class Claim {
200
+ abstract readonly type: string;
201
+ abstract readonly data: ClaimData;
202
+ abstract toTransactionData(): unknown;
203
+ static fromTransaction(transaction: FastsetTransaction): Claim;
204
+ }
205
+ declare class TransferClaim extends Claim {
206
+ readonly type = "Transfer";
207
+ readonly data: {
208
+ recipient: Uint8Array;
209
+ amount: string;
210
+ userData?: Uint8Array;
211
+ };
212
+ constructor(recipient: Uint8Array, amount: string, userData?: Uint8Array);
213
+ toTransactionData(): unknown;
214
+ static fromData(data: any): TransferClaim;
215
+ getRecipient(): Uint8Array;
216
+ getAmount(): string;
217
+ getUserData(): Uint8Array | undefined;
218
+ }
219
+
220
+ interface FastsetClientConfig {
221
+ validatorUrl: string;
222
+ proxyUrl: string;
223
+ }
224
+ declare class FastsetClient {
225
+ private config;
226
+ constructor(config?: FastsetClientConfig);
227
+ getAccountInfo(address: string): Promise<FastsetAccountInfo | null>;
228
+ getNextNonce(senderAddress: string): Promise<number>;
229
+ getAssetBalance(accountId: string, assetId: string): Promise<FastsetAssetBalance | null>;
230
+ getAssetBalances(accountId: string): Promise<FastsetAssetBalances | null>;
231
+ fundFromFaucet(recipientAddress: string, amount: string): Promise<FastsetFaucetResponse>;
232
+ submitTransaction(request: FastsetSubmitTransactionRequest): Promise<FastsetSubmitTransactionResponse>;
233
+ submitCertificate(request: FastsetSubmitCertificateRequest): Promise<void>;
234
+ executeTransfer(senderPrivateKey: Uint8Array, recipient: string, amount: string, userData?: Uint8Array): Promise<Uint8Array>;
235
+ submitClaim(senderPrivateKey: Uint8Array, claim: any): Promise<Uint8Array>;
236
+ signTransaction(transaction: FastsetTransaction, privateKey: Uint8Array): Promise<Uint8Array>;
237
+ getTransactionStatus(txHash: string): Promise<any>;
238
+ getTransactionInfo(txHash: string): Promise<any>;
239
+ getNetworkInfo(): Promise<any>;
240
+ private requestValidator;
241
+ private requestProxy;
242
+ private request;
243
+ private jsonReplacer;
244
+ }
245
+
246
+ interface TransactionOptions {
247
+ timestamp?: bigint;
248
+ }
249
+ declare class Transaction {
250
+ private sender;
251
+ private nonce;
252
+ private claim;
253
+ private timestamp;
254
+ constructor(sender: Uint8Array, nonce: number, claim: Claim, options?: TransactionOptions);
255
+ toTransaction(): FastsetTransaction;
256
+ getSender(): Uint8Array;
257
+ getNonce(): number;
258
+ getClaim(): Claim;
259
+ getTimestamp(): bigint;
260
+ static fromTransaction(transaction: FastsetTransaction): Transaction;
261
+ }
262
+
263
+ interface WalletConfig {
264
+ privateKeyHex: string;
265
+ }
266
+ interface WalletInfo {
267
+ publicKeyHex: string;
268
+ address: string;
269
+ }
270
+ declare class Wallet {
271
+ readonly publicKey: Uint8Array;
272
+ readonly publicKeyHex: string;
273
+ private readonly privateKey;
274
+ constructor(privateKeyHex: string);
275
+ toBech32(): string;
276
+ getWalletInfo(): WalletInfo;
277
+ createTransferClaim(recipientAddress: string, amount: bigint, assetType: 'native' | 'set' | 'usdc' | string): TransferClaim;
278
+ createTransaction(nonce: number, claim: TransferClaim): Transaction;
279
+ signTransaction(transaction: Transaction): Promise<Uint8Array>;
280
+ static decodeBech32Address(address: string): Uint8Array;
281
+ static encodeBech32Address(publicKey: Uint8Array): string;
282
+ static fromPrivateKey(privateKeyHex: string): Wallet;
283
+ static generateNew(): Wallet;
284
+ static fromPrivateKeyFile(filePath: string): Promise<Wallet>;
285
+ }
286
+
287
+ interface FastsetAccountData {
288
+ address: string;
289
+ balance: string;
290
+ balanceDecimal: number;
291
+ nextNonce: number;
292
+ sequenceNumber: number;
293
+ }
294
+ interface FastsetTransactionData {
295
+ hash: string;
296
+ hashHex: string;
297
+ status: string;
298
+ details: any;
299
+ }
300
+ declare class WarpFastsetDataLoader implements AdapterWarpDataLoader {
301
+ private readonly config;
302
+ private readonly chain;
303
+ private client;
304
+ constructor(config: WarpClientConfig, chain: WarpChainInfo);
305
+ getAccount(address: string): Promise<WarpChainAccount>;
306
+ getAccountAssets(address: string): Promise<WarpChainAsset[]>;
307
+ getAccountActions(address: string, options?: WarpDataLoaderOptions): Promise<WarpChainAction[]>;
308
+ getAccountInfo(address: string): Promise<FastsetAccountData | null>;
309
+ getTransactionInfo(txHash: string): Promise<FastsetTransactionData | null>;
310
+ checkTransferStatus(fromAddress: string, toAddress: string, amount: string): Promise<boolean>;
311
+ getAccountBalance(address: string): Promise<{
312
+ balance: string;
313
+ balanceDecimal: number;
314
+ } | null>;
315
+ getAssetBalance(address: string, assetId: string): Promise<WarpChainAsset | null>;
316
+ }
317
+
318
+ declare class WarpFastsetExecutor implements AdapterWarpExecutor {
319
+ private readonly config;
320
+ private readonly chain;
321
+ private readonly serializer;
322
+ private readonly fastsetClient;
323
+ constructor(config: WarpClientConfig, chain: WarpChainInfo);
324
+ createTransaction(executable: WarpExecutable): Promise<any>;
325
+ createTransferTransaction(executable: WarpExecutable): Promise<any>;
326
+ createContractCallTransaction(executable: WarpExecutable): Promise<any>;
327
+ executeQuery(executable: WarpExecutable): Promise<any>;
328
+ preprocessInput(chain: WarpChainInfo, input: string, type: WarpActionInputType, value: string): Promise<string>;
329
+ signMessage(message: string, privateKey: string): Promise<string>;
330
+ executeTransfer(executable: WarpExecutable): Promise<any>;
331
+ executeTransferWithKey(executable: WarpExecutable, privateKey: string): Promise<any>;
332
+ private encodeFunctionData;
333
+ private executeFastsetQuery;
334
+ private isValidFastsetAddress;
335
+ private fromBase64;
336
+ private normalizeAmount;
337
+ }
338
+
339
+ declare class WarpFastsetExplorer implements AdapterWarpExplorer {
340
+ private readonly _chainInfo;
341
+ private readonly _config?;
342
+ private readonly explorerUrl;
343
+ constructor(_chainInfo: WarpChainInfo, _config?: WarpClientConfig | undefined);
344
+ getAccountUrl(address: string): string;
345
+ getTransactionUrl(hash: string): string;
346
+ getAssetUrl(identifier: string): string;
347
+ getContractUrl(address: string): string;
348
+ }
349
+
350
+ declare class WarpFastsetResults implements AdapterWarpResults {
351
+ private readonly config;
352
+ private readonly chain;
353
+ private readonly serializer;
354
+ constructor(config: WarpClientConfig, chain: WarpChainInfo);
355
+ getTransactionExecutionResults(warp: Warp, tx: any): Promise<WarpExecution>;
356
+ extractQueryResults(warp: Warp, typedValues: any[], actionIndex: number, inputs: ResolvedInput[]): Promise<{
357
+ values: any[];
358
+ results: WarpExecutionResults;
359
+ }>;
360
+ private isTransactionSuccessful;
361
+ private extractTransactionHash;
362
+ private extractBlockNumber;
363
+ private extractTimestamp;
364
+ }
365
+
366
+ declare class WarpFastsetSerializer implements AdapterWarpSerializer {
367
+ readonly coreSerializer: WarpSerializer;
368
+ constructor();
369
+ typedToString(value: any): string;
370
+ typedToNative(value: any): [WarpActionInputType, WarpNativeValue];
371
+ nativeToTyped(type: WarpActionInputType, value: WarpNativeValue): any;
372
+ nativeToType(type: BaseWarpActionInputType): WarpAdapterGenericType;
373
+ stringToTyped(value: string): any;
374
+ }
375
+
376
+ export { Address, Amount, BcsTransaction, Bytes32, Claim, type ClaimData, ClaimType, type FastsetAccountData, type FastsetAccountInfo, type FastsetAssetBalance, type FastsetAssetBalances, FastsetClient, type FastsetClientConfig, type FastsetFaucetRequest, type FastsetFaucetResponse, type FastsetJsonRpcRequest, type FastsetJsonRpcResponse, type FastsetSubmitCertificateRequest, type FastsetSubmitTransactionRequest, type FastsetSubmitTransactionResponse, type FastsetTransaction, type FastsetTransactionData, type FastsetTransferRequest, NativeTokenSet, Nonce, PublicKey, Transaction, type TransactionOptions, Transfer, TransferClaim, UserData, Wallet, type WalletConfig, type WalletInfo, WarpFastsetConstants, WarpFastsetDataLoader, WarpFastsetExecutor, WarpFastsetExplorer, WarpFastsetResults, WarpFastsetSerializer, getFastsetAdapter };
package/dist/index.d.ts CHANGED
@@ -182,6 +182,16 @@ interface FastsetJsonRpcResponse<T = unknown> {
182
182
  data?: unknown;
183
183
  };
184
184
  }
185
+ interface FastsetAssetBalance {
186
+ asset_id: string;
187
+ balance: string;
188
+ name?: string;
189
+ decimals?: number;
190
+ logo_url?: string;
191
+ }
192
+ interface FastsetAssetBalances {
193
+ [assetId: string]: FastsetAssetBalance;
194
+ }
185
195
 
186
196
  interface ClaimData {
187
197
  [key: string]: unknown;
@@ -213,9 +223,11 @@ interface FastsetClientConfig {
213
223
  }
214
224
  declare class FastsetClient {
215
225
  private config;
216
- constructor(config: FastsetClientConfig);
226
+ constructor(config?: FastsetClientConfig);
217
227
  getAccountInfo(address: string): Promise<FastsetAccountInfo | null>;
218
228
  getNextNonce(senderAddress: string): Promise<number>;
229
+ getAssetBalance(accountId: string, assetId: string): Promise<FastsetAssetBalance | null>;
230
+ getAssetBalances(accountId: string): Promise<FastsetAssetBalances | null>;
219
231
  fundFromFaucet(recipientAddress: string, amount: string): Promise<FastsetFaucetResponse>;
220
232
  submitTransaction(request: FastsetSubmitTransactionRequest): Promise<FastsetSubmitTransactionResponse>;
221
233
  submitCertificate(request: FastsetSubmitCertificateRequest): Promise<void>;
@@ -300,6 +312,7 @@ declare class WarpFastsetDataLoader implements AdapterWarpDataLoader {
300
312
  balance: string;
301
313
  balanceDecimal: number;
302
314
  } | null>;
315
+ getAssetBalance(address: string, assetId: string): Promise<WarpChainAsset | null>;
303
316
  }
304
317
 
305
318
  declare class WarpFastsetExecutor implements AdapterWarpExecutor {
@@ -360,4 +373,4 @@ declare class WarpFastsetSerializer implements AdapterWarpSerializer {
360
373
  stringToTyped(value: string): any;
361
374
  }
362
375
 
363
- export { Address, Amount, BcsTransaction, Bytes32, Claim, type ClaimData, ClaimType, type FastsetAccountData, type FastsetAccountInfo, FastsetClient, type FastsetClientConfig, type FastsetFaucetRequest, type FastsetFaucetResponse, type FastsetJsonRpcRequest, type FastsetJsonRpcResponse, type FastsetSubmitCertificateRequest, type FastsetSubmitTransactionRequest, type FastsetSubmitTransactionResponse, type FastsetTransaction, type FastsetTransactionData, type FastsetTransferRequest, NativeTokenSet, Nonce, PublicKey, Transaction, type TransactionOptions, Transfer, TransferClaim, UserData, Wallet, type WalletConfig, type WalletInfo, WarpFastsetConstants, WarpFastsetDataLoader, WarpFastsetExecutor, WarpFastsetExplorer, WarpFastsetResults, WarpFastsetSerializer, getFastsetAdapter };
376
+ export { Address, Amount, BcsTransaction, Bytes32, Claim, type ClaimData, ClaimType, type FastsetAccountData, type FastsetAccountInfo, type FastsetAssetBalance, type FastsetAssetBalances, FastsetClient, type FastsetClientConfig, type FastsetFaucetRequest, type FastsetFaucetResponse, type FastsetJsonRpcRequest, type FastsetJsonRpcResponse, type FastsetSubmitCertificateRequest, type FastsetSubmitTransactionRequest, type FastsetSubmitTransactionResponse, type FastsetTransaction, type FastsetTransactionData, type FastsetTransferRequest, NativeTokenSet, Nonce, PublicKey, Transaction, type TransactionOptions, Transfer, TransferClaim, UserData, Wallet, type WalletConfig, type WalletInfo, WarpFastsetConstants, WarpFastsetDataLoader, WarpFastsetExecutor, WarpFastsetExplorer, WarpFastsetResults, WarpFastsetSerializer, getFastsetAdapter };