Skip to content

Commit 3000772

Browse files
committed
style: format code for fassetsRedeemAmount.ts and fassetsRedeemWithTag.ts
1 parent ea48204 commit 3000772

2 files changed

Lines changed: 52 additions & 16 deletions

File tree

examples/developer-hub-javascript/fassetsRedeemAmount.ts

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ const REDEEM_AMOUNT_UBA = 5000000n;
88
// 2. Redeemer underlying (XRPL) address that will receive the redeemed XRP.
99
const REDEEMER_UNDERLYING_ADDRESS_STRING = "rSHYuiEvsYsKR8uUHhBTuGP5zjRcGt4nm";
1010
// 3. Executor (not used here, so the zero address).
11-
const EXECUTOR_ZERO_ADDRESS: Address = "0x0000000000000000000000000000000000000000";
11+
const EXECUTOR_ZERO_ADDRESS: Address =
12+
"0x0000000000000000000000000000000000000000";
1213

1314
async function main() {
1415
// 4. Resolve the AssetManagerFXRP address from the Flare Contract Registry.
15-
const assetManagerAddress = await getContractAddressByName("AssetManagerFXRP");
16+
const assetManagerAddress =
17+
await getContractAddressByName("AssetManagerFXRP");
1618
console.log("AssetManagerFXRP address:", assetManagerAddress, "\n");
1719

1820
// 5. Read the protocol-wide minimum redemption amount and assert that the
@@ -22,12 +24,20 @@ async function main() {
2224
abi: coston2.iAssetManagerAbi,
2325
functionName: "minimumRedeemAmountUBA",
2426
});
25-
console.log("minimumRedeemAmountUBA:", minimumRedeemAmountUBA.toString(), "\n");
26-
console.log("Requested redeem amount UBA:", REDEEM_AMOUNT_UBA.toString(), "\n");
27+
console.log(
28+
"minimumRedeemAmountUBA:",
29+
minimumRedeemAmountUBA.toString(),
30+
"\n",
31+
);
32+
console.log(
33+
"Requested redeem amount UBA:",
34+
REDEEM_AMOUNT_UBA.toString(),
35+
"\n",
36+
);
2737

2838
if (REDEEM_AMOUNT_UBA < minimumRedeemAmountUBA) {
2939
throw new Error(
30-
`Redeem amount (${REDEEM_AMOUNT_UBA.toString()}) must be greater than minimumRedeemAmountUBA (${minimumRedeemAmountUBA.toString()}).`
40+
`Redeem amount (${REDEEM_AMOUNT_UBA.toString()}) must be greater than minimumRedeemAmountUBA (${minimumRedeemAmountUBA.toString()}).`,
3141
);
3242
}
3343

@@ -38,15 +48,21 @@ async function main() {
3848
address: assetManagerAddress,
3949
abi: coston2.iAssetManagerAbi,
4050
functionName: "redeemAmount",
41-
args: [REDEEM_AMOUNT_UBA, REDEEMER_UNDERLYING_ADDRESS_STRING, EXECUTOR_ZERO_ADDRESS],
51+
args: [
52+
REDEEM_AMOUNT_UBA,
53+
REDEEMER_UNDERLYING_ADDRESS_STRING,
54+
EXECUTOR_ZERO_ADDRESS,
55+
],
4256
});
4357

4458
// 7. Submit the redemption request transaction on Flare.
4559
const txHash = await walletClient.writeContract(request);
4660
console.log("redeemAmount tx hash:", txHash, "\n");
4761

4862
// 8. Wait for the transaction receipt.
49-
const receipt = await publicClient.waitForTransactionReceipt({ hash: txHash });
63+
const receipt = await publicClient.waitForTransactionReceipt({
64+
hash: txHash,
65+
});
5066
console.log("redeemAmount status:", receipt.status, "\n");
5167

5268
// 9. Decode RedemptionRequested events from the receipt logs and pick the
@@ -62,7 +78,9 @@ async function main() {
6278
);
6379

6480
if (!redemptionEvent) {
65-
throw new Error("RedemptionRequested event not found for this transaction and redeemer");
81+
throw new Error(
82+
"RedemptionRequested event not found for this transaction and redeemer",
83+
);
6684
}
6785

6886
console.log("RedemptionRequested event:", redemptionEvent, "\n");

examples/developer-hub-javascript/fassetsRedeemWithTag.ts

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@ const REDEEM_AMOUNT_UBA = 5000000n;
88
// 2. Redeemer underlying (XRPL) address that will receive the redeemed XRP.
99
const REDEEMER_UNDERLYING_ADDRESS_STRING = "rSHYuiEvsYsKR8uUHhBTuGP5zjRcGt4nm";
1010
// 3. Executor (not used here, so the zero address).
11-
const EXECUTOR_ZERO_ADDRESS: Address = "0x0000000000000000000000000000000000000000";
11+
const EXECUTOR_ZERO_ADDRESS: Address =
12+
"0x0000000000000000000000000000000000000000";
1213
// 4. XRPL destination tag the agent must include in the redemption payment
1314
// (must fit in 32 bits; e.g. an exchange deposit tag).
1415
const REDEMPTION_DESTINATION_TAG = 72n;
1516

1617
async function main() {
1718
// 5. Resolve the AssetManagerFXRP address from the Flare Contract Registry.
18-
const assetManagerAddress = await getContractAddressByName("AssetManagerFXRP");
19+
const assetManagerAddress =
20+
await getContractAddressByName("AssetManagerFXRP");
1921
console.log("AssetManagerFXRP address:", assetManagerAddress, "\n");
2022

2123
// 6. Read the protocol-wide minimum redemption amount and assert that the
@@ -25,13 +27,25 @@ async function main() {
2527
abi: coston2.iAssetManagerAbi,
2628
functionName: "minimumRedeemAmountUBA",
2729
});
28-
console.log("minimumRedeemAmountUBA:", minimumRedeemAmountUBA.toString(), "\n");
29-
console.log("Requested redeem amount UBA:", REDEEM_AMOUNT_UBA.toString(), "\n");
30-
console.log("Redemption destination tag:", REDEMPTION_DESTINATION_TAG.toString(), "\n");
30+
console.log(
31+
"minimumRedeemAmountUBA:",
32+
minimumRedeemAmountUBA.toString(),
33+
"\n",
34+
);
35+
console.log(
36+
"Requested redeem amount UBA:",
37+
REDEEM_AMOUNT_UBA.toString(),
38+
"\n",
39+
);
40+
console.log(
41+
"Redemption destination tag:",
42+
REDEMPTION_DESTINATION_TAG.toString(),
43+
"\n",
44+
);
3145

3246
if (REDEEM_AMOUNT_UBA < minimumRedeemAmountUBA) {
3347
throw new Error(
34-
`Redeem amount (${REDEEM_AMOUNT_UBA.toString()}) must be greater than minimumRedeemAmountUBA (${minimumRedeemAmountUBA.toString()}).`
48+
`Redeem amount (${REDEEM_AMOUNT_UBA.toString()}) must be greater than minimumRedeemAmountUBA (${minimumRedeemAmountUBA.toString()}).`,
3549
);
3650
}
3751

@@ -55,7 +69,9 @@ async function main() {
5569
console.log("redeemWithTag tx hash:", txHash, "\n");
5670

5771
// 9. Wait for the transaction receipt.
58-
const receipt = await publicClient.waitForTransactionReceipt({ hash: txHash });
72+
const receipt = await publicClient.waitForTransactionReceipt({
73+
hash: txHash,
74+
});
5975
console.log("redeemWithTag status:", receipt.status, "\n");
6076

6177
// 10. Decode RedemptionWithTagRequested events from the receipt logs and
@@ -71,7 +87,9 @@ async function main() {
7187
);
7288

7389
if (!redemptionEvent) {
74-
throw new Error("RedemptionWithTagRequested event not found for this transaction and redeemer");
90+
throw new Error(
91+
"RedemptionWithTagRequested event not found for this transaction and redeemer",
92+
);
7593
}
7694

7795
console.log("RedemptionWithTagRequested event:", redemptionEvent, "\n");

0 commit comments

Comments
 (0)