@vleap/warps-adapter-fastset 0.1.0-alpha.15 → 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.
- package/dist/index.d.cts +15 -2
- package/dist/index.d.ts +15 -2
- package/dist/index.js +130 -112
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +130 -112
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
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
|
|
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 };
|
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
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -268,9 +268,14 @@ var Wallet = class _Wallet {
|
|
|
268
268
|
BigInt.prototype.toJSON = function() {
|
|
269
269
|
return Number(this);
|
|
270
270
|
};
|
|
271
|
+
var FASTSET_VALIDATOR_URL = "http://157.90.201.117:8765";
|
|
272
|
+
var FASTSET_PROXY_URL = "http://136.243.61.168:44444";
|
|
271
273
|
var FastsetClient = class {
|
|
272
274
|
constructor(config) {
|
|
273
|
-
this.config = config
|
|
275
|
+
this.config = config || {
|
|
276
|
+
validatorUrl: FASTSET_VALIDATOR_URL,
|
|
277
|
+
proxyUrl: FASTSET_PROXY_URL
|
|
278
|
+
};
|
|
274
279
|
}
|
|
275
280
|
async getAccountInfo(address) {
|
|
276
281
|
try {
|
|
@@ -278,9 +283,6 @@ var FastsetClient = class {
|
|
|
278
283
|
const response = await this.requestValidator("set_getAccountInfo", {
|
|
279
284
|
address: Array.from(addressBytes)
|
|
280
285
|
});
|
|
281
|
-
if (response.error) {
|
|
282
|
-
return null;
|
|
283
|
-
}
|
|
284
286
|
return response.result;
|
|
285
287
|
} catch (error) {
|
|
286
288
|
return null;
|
|
@@ -290,15 +292,33 @@ var FastsetClient = class {
|
|
|
290
292
|
const accountInfo = await this.getAccountInfo(senderAddress);
|
|
291
293
|
return accountInfo?.next_nonce ?? 0;
|
|
292
294
|
}
|
|
295
|
+
async getAssetBalance(accountId, assetId) {
|
|
296
|
+
try {
|
|
297
|
+
const response = await this.requestValidator("vsl_getAssetBalance", {
|
|
298
|
+
account_id: accountId,
|
|
299
|
+
assert_id: assetId
|
|
300
|
+
});
|
|
301
|
+
return response.result;
|
|
302
|
+
} catch (error) {
|
|
303
|
+
return null;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
async getAssetBalances(accountId) {
|
|
307
|
+
try {
|
|
308
|
+
const response = await this.requestValidator("vsl_getAssetBalances", {
|
|
309
|
+
account_id: accountId
|
|
310
|
+
});
|
|
311
|
+
return response.result;
|
|
312
|
+
} catch (error) {
|
|
313
|
+
return null;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
293
316
|
async fundFromFaucet(recipientAddress, amount) {
|
|
294
317
|
const recipientBytes = Wallet.decodeBech32Address(recipientAddress);
|
|
295
318
|
const response = await this.requestProxy("faucetDrip", {
|
|
296
319
|
recipient: Array.from(recipientBytes),
|
|
297
320
|
amount
|
|
298
321
|
});
|
|
299
|
-
if (response.error) {
|
|
300
|
-
throw new Error(`Faucet request failed: ${response.error.message}`);
|
|
301
|
-
}
|
|
302
322
|
return response.result;
|
|
303
323
|
}
|
|
304
324
|
async submitTransaction(request) {
|
|
@@ -306,9 +326,6 @@ var FastsetClient = class {
|
|
|
306
326
|
transaction: request.transaction,
|
|
307
327
|
signature: Array.from(request.signature)
|
|
308
328
|
});
|
|
309
|
-
if (response.error) {
|
|
310
|
-
throw new Error(`Transaction submission failed: ${response.error.message}`);
|
|
311
|
-
}
|
|
312
329
|
const result = response.result;
|
|
313
330
|
return {
|
|
314
331
|
transaction_hash: new Uint8Array(result.transaction_hash),
|
|
@@ -317,14 +334,11 @@ var FastsetClient = class {
|
|
|
317
334
|
};
|
|
318
335
|
}
|
|
319
336
|
async submitCertificate(request) {
|
|
320
|
-
|
|
337
|
+
await this.requestValidator("set_submitTransactionCertificate", {
|
|
321
338
|
transaction: request.transaction,
|
|
322
339
|
signature: Array.from(request.signature),
|
|
323
340
|
validator_signatures: request.validator_signatures.map(([validator, signature]) => [Array.from(validator), Array.from(signature)])
|
|
324
341
|
});
|
|
325
|
-
if (response.error) {
|
|
326
|
-
throw new Error(`Certificate submission failed: ${response.error.message}`);
|
|
327
|
-
}
|
|
328
342
|
}
|
|
329
343
|
async executeTransfer(senderPrivateKey, recipient, amount, userData) {
|
|
330
344
|
const senderPublicKey = await (0, import_ed255192.getPublicKey)(senderPrivateKey);
|
|
@@ -385,9 +399,6 @@ var FastsetClient = class {
|
|
|
385
399
|
const response = await this.requestValidator("set_getTransactionStatus", {
|
|
386
400
|
hash: txHash
|
|
387
401
|
});
|
|
388
|
-
if (response.error) {
|
|
389
|
-
return null;
|
|
390
|
-
}
|
|
391
402
|
return response.result;
|
|
392
403
|
} catch (error) {
|
|
393
404
|
return null;
|
|
@@ -398,9 +409,6 @@ var FastsetClient = class {
|
|
|
398
409
|
const response = await this.requestValidator("set_getTransactionInfo", {
|
|
399
410
|
hash: txHash
|
|
400
411
|
});
|
|
401
|
-
if (response.error) {
|
|
402
|
-
return null;
|
|
403
|
-
}
|
|
404
412
|
return response.result;
|
|
405
413
|
} catch (error) {
|
|
406
414
|
return null;
|
|
@@ -409,9 +417,6 @@ var FastsetClient = class {
|
|
|
409
417
|
async getNetworkInfo() {
|
|
410
418
|
try {
|
|
411
419
|
const response = await this.requestValidator("set_getNetworkInfo", {});
|
|
412
|
-
if (response.error) {
|
|
413
|
-
return null;
|
|
414
|
-
}
|
|
415
420
|
return response.result;
|
|
416
421
|
} catch (error) {
|
|
417
422
|
return null;
|
|
@@ -424,21 +429,30 @@ var FastsetClient = class {
|
|
|
424
429
|
return this.request(this.config.proxyUrl, method, params);
|
|
425
430
|
}
|
|
426
431
|
async request(url, method, params) {
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
432
|
+
try {
|
|
433
|
+
const request = {
|
|
434
|
+
jsonrpc: "2.0",
|
|
435
|
+
id: 1,
|
|
436
|
+
method,
|
|
437
|
+
params
|
|
438
|
+
};
|
|
439
|
+
const response = await fetch(url, {
|
|
440
|
+
method: "POST",
|
|
441
|
+
headers: { "Content-Type": "application/json" },
|
|
442
|
+
body: JSON.stringify(request, this.jsonReplacer)
|
|
443
|
+
});
|
|
444
|
+
if (!response.ok) {
|
|
445
|
+
throw new Error(`HTTP request failed: ${response.statusText}`);
|
|
446
|
+
}
|
|
447
|
+
const jsonResponse = await response.json();
|
|
448
|
+
if (jsonResponse.error) {
|
|
449
|
+
throw new Error(`RPC error: ${jsonResponse.error.message}`);
|
|
450
|
+
}
|
|
451
|
+
return jsonResponse;
|
|
452
|
+
} catch (error) {
|
|
453
|
+
console.error(`Fastset RPC request failed: ${error}`);
|
|
454
|
+
throw error;
|
|
440
455
|
}
|
|
441
|
-
return response.json();
|
|
442
456
|
}
|
|
443
457
|
jsonReplacer(key, value) {
|
|
444
458
|
if (value instanceof Uint8Array) {
|
|
@@ -453,108 +467,94 @@ var WarpFastsetDataLoader = class {
|
|
|
453
467
|
constructor(config, chain) {
|
|
454
468
|
this.config = config;
|
|
455
469
|
this.chain = chain;
|
|
456
|
-
|
|
457
|
-
const proxyUrl = this.chain.defaultApiUrl;
|
|
458
|
-
this.client = new FastsetClient({
|
|
459
|
-
validatorUrl,
|
|
460
|
-
proxyUrl
|
|
461
|
-
});
|
|
470
|
+
this.client = new FastsetClient();
|
|
462
471
|
}
|
|
463
472
|
async getAccount(address) {
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
if (!accountInfo) {
|
|
467
|
-
return {
|
|
468
|
-
chain: this.chain.name,
|
|
469
|
-
address,
|
|
470
|
-
balance: BigInt(0)
|
|
471
|
-
};
|
|
472
|
-
}
|
|
473
|
-
return {
|
|
474
|
-
chain: this.chain.name,
|
|
475
|
-
address,
|
|
476
|
-
balance: BigInt(parseInt(accountInfo.balance, 16))
|
|
477
|
-
};
|
|
478
|
-
} catch (error) {
|
|
473
|
+
const accountInfo = await this.client.getAccountInfo(address);
|
|
474
|
+
if (!accountInfo) {
|
|
479
475
|
return {
|
|
480
476
|
chain: this.chain.name,
|
|
481
477
|
address,
|
|
482
478
|
balance: BigInt(0)
|
|
483
479
|
};
|
|
484
480
|
}
|
|
481
|
+
return {
|
|
482
|
+
chain: this.chain.name,
|
|
483
|
+
address,
|
|
484
|
+
balance: BigInt(parseInt(accountInfo.balance, 16))
|
|
485
|
+
};
|
|
485
486
|
}
|
|
486
487
|
async getAccountAssets(address) {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
488
|
+
const accountReq = this.getAccount(address);
|
|
489
|
+
const assetBalancesReq = this.client.getAssetBalances(address);
|
|
490
|
+
const [account, assetBalances] = await Promise.all([accountReq, assetBalancesReq]);
|
|
491
|
+
const assets = [];
|
|
492
|
+
if (account.balance > 0) {
|
|
493
|
+
assets.push({
|
|
494
|
+
chain: this.chain.name,
|
|
495
|
+
identifier: this.chain.nativeToken?.identifier || "SET",
|
|
496
|
+
name: this.chain.nativeToken?.name || "SET",
|
|
497
|
+
decimals: this.chain.nativeToken?.decimals || 6,
|
|
498
|
+
amount: account.balance,
|
|
499
|
+
logoUrl: this.chain.nativeToken?.logoUrl
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
if (assetBalances) {
|
|
503
|
+
for (const [assetId, assetBalance] of Object.entries(assetBalances)) {
|
|
504
|
+
if (assetBalance.balance) {
|
|
505
|
+
const amount = BigInt(assetBalance.balance);
|
|
506
|
+
if (amount > 0) {
|
|
507
|
+
assets.push({
|
|
508
|
+
chain: this.chain.name,
|
|
509
|
+
identifier: assetId,
|
|
510
|
+
name: assetBalance.name || assetId,
|
|
511
|
+
decimals: assetBalance.decimals || 6,
|
|
512
|
+
amount,
|
|
513
|
+
logoUrl: assetBalance.logo_url
|
|
514
|
+
});
|
|
498
515
|
}
|
|
499
|
-
|
|
516
|
+
}
|
|
500
517
|
}
|
|
501
|
-
return [];
|
|
502
|
-
} catch (error) {
|
|
503
|
-
return [];
|
|
504
518
|
}
|
|
519
|
+
return assets;
|
|
505
520
|
}
|
|
506
521
|
async getAccountActions(address, options) {
|
|
507
522
|
return [];
|
|
508
523
|
}
|
|
509
524
|
async getAccountInfo(address) {
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
if (!accountInfo) {
|
|
513
|
-
return null;
|
|
514
|
-
}
|
|
515
|
-
const balanceDecimal = parseInt(accountInfo.balance, 16);
|
|
516
|
-
return {
|
|
517
|
-
address,
|
|
518
|
-
balance: accountInfo.balance,
|
|
519
|
-
balanceDecimal,
|
|
520
|
-
nextNonce: accountInfo.next_nonce,
|
|
521
|
-
sequenceNumber: accountInfo.sequence_number
|
|
522
|
-
};
|
|
523
|
-
} catch (error) {
|
|
524
|
-
console.error("Error getting account info:", error);
|
|
525
|
+
const accountInfo = await this.client.getAccountInfo(address);
|
|
526
|
+
if (!accountInfo) {
|
|
525
527
|
return null;
|
|
526
528
|
}
|
|
529
|
+
const balanceDecimal = parseInt(accountInfo.balance, 16);
|
|
530
|
+
return {
|
|
531
|
+
address,
|
|
532
|
+
balance: accountInfo.balance,
|
|
533
|
+
balanceDecimal,
|
|
534
|
+
nextNonce: accountInfo.next_nonce,
|
|
535
|
+
sequenceNumber: accountInfo.sequence_number
|
|
536
|
+
};
|
|
527
537
|
}
|
|
528
538
|
async getTransactionInfo(txHash) {
|
|
529
|
-
|
|
530
|
-
|
|
539
|
+
return {
|
|
540
|
+
hash: txHash,
|
|
541
|
+
hashHex: txHash.startsWith("0x") ? txHash.slice(2) : txHash,
|
|
542
|
+
status: "submitted",
|
|
543
|
+
details: {
|
|
531
544
|
hash: txHash,
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
hash: txHash,
|
|
536
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
537
|
-
}
|
|
538
|
-
};
|
|
539
|
-
} catch (error) {
|
|
540
|
-
console.error("Error getting transaction info:", error);
|
|
541
|
-
return null;
|
|
542
|
-
}
|
|
545
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
546
|
+
}
|
|
547
|
+
};
|
|
543
548
|
}
|
|
544
549
|
async checkTransferStatus(fromAddress, toAddress, amount) {
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
if (!fromAccount || !toAccount) {
|
|
549
|
-
return false;
|
|
550
|
-
}
|
|
551
|
-
const transferAmount = parseInt(amount);
|
|
552
|
-
const fromBalance = fromAccount.balanceDecimal;
|
|
553
|
-
return fromBalance < transferAmount;
|
|
554
|
-
} catch (error) {
|
|
555
|
-
console.error("Error checking transfer status:", error);
|
|
550
|
+
const fromAccount = await this.getAccountInfo(fromAddress);
|
|
551
|
+
const toAccount = await this.getAccountInfo(toAddress);
|
|
552
|
+
if (!fromAccount || !toAccount) {
|
|
556
553
|
return false;
|
|
557
554
|
}
|
|
555
|
+
const transferAmount = parseInt(amount);
|
|
556
|
+
const fromBalance = fromAccount.balanceDecimal;
|
|
557
|
+
return fromBalance < transferAmount;
|
|
558
558
|
}
|
|
559
559
|
async getAccountBalance(address) {
|
|
560
560
|
const accountInfo = await this.getAccountInfo(address);
|
|
@@ -566,6 +566,24 @@ var WarpFastsetDataLoader = class {
|
|
|
566
566
|
balanceDecimal: accountInfo.balanceDecimal
|
|
567
567
|
};
|
|
568
568
|
}
|
|
569
|
+
async getAssetBalance(address, assetId) {
|
|
570
|
+
const assetBalance = await this.client.getAssetBalance(address, assetId);
|
|
571
|
+
if (!assetBalance || !assetBalance.balance) {
|
|
572
|
+
return null;
|
|
573
|
+
}
|
|
574
|
+
const amount = BigInt(assetBalance.balance);
|
|
575
|
+
if (amount === 0n) {
|
|
576
|
+
return null;
|
|
577
|
+
}
|
|
578
|
+
return {
|
|
579
|
+
chain: this.chain.name,
|
|
580
|
+
identifier: assetId,
|
|
581
|
+
name: assetBalance.name || assetId,
|
|
582
|
+
decimals: assetBalance.decimals || 6,
|
|
583
|
+
amount,
|
|
584
|
+
logoUrl: assetBalance.logo_url
|
|
585
|
+
};
|
|
586
|
+
}
|
|
569
587
|
};
|
|
570
588
|
|
|
571
589
|
// src/WarpFastsetExecutor.ts
|