Skip to content

Commit 0d37df1

Browse files
committed
apply prettier
1 parent 4ccf63f commit 0d37df1

18 files changed

Lines changed: 233 additions & 120 deletions

cli/src/__tests__/xrpl-helpers.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ describe("validateMptIssuanceParams", () => {
8282
});
8383

8484
test("rejects out-of-range asset scale", () => {
85-
expect(() =>
86-
validateMptIssuanceParams({ ...ok, assetScale: 256 })
87-
).toThrow(/asset-scale/);
85+
expect(() => validateMptIssuanceParams({ ...ok, assetScale: 256 })).toThrow(
86+
/asset-scale/
87+
);
8888
});
8989

9090
test("rejects out-of-range transfer fee", () => {
@@ -107,9 +107,9 @@ describe("validateMptIssuanceParams", () => {
107107
expect(() =>
108108
validateMptIssuanceParams({ ...ok, maxAmount: "1000000" })
109109
).not.toThrow();
110-
expect(() =>
111-
validateMptIssuanceParams({ ...ok, maxAmount: "0" })
112-
).toThrow(/greater than 0/);
110+
expect(() => validateMptIssuanceParams({ ...ok, maxAmount: "0" })).toThrow(
111+
/greater than 0/
112+
);
113113
expect(() =>
114114
validateMptIssuanceParams({ ...ok, maxAmount: "1.5" })
115115
).toThrow(/non-negative integer/);

cli/src/__tests__/xrpl-onboarding.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ describe("buildInitData", () => {
4242
const issuerHex = Buffer.from(decodeAccountID(ADMIN)).toString("hex");
4343
// 1 (decimals) + 42 (token_id padded) = 43 bytes => 86 hex chars
4444
expect(out.length).toBe(86);
45-
expect(out.startsWith("09" + "01" + FOO_CURRENCY.toLowerCase() + issuerHex)).toBe(
46-
true
47-
);
45+
expect(
46+
out.startsWith("09" + "01" + FOO_CURRENCY.toLowerCase() + issuerHex)
47+
).toBe(true);
4848
// trailing byte is zero padding (41 bytes of data -> padded to 42)
4949
expect(out.endsWith("00")).toBe(true);
5050
});
@@ -64,7 +64,9 @@ describe("buildInitData", () => {
6464
});
6565

6666
test("rejects decimals out of byte range", () => {
67-
expect(() => buildInitData(256, { type: "xrp" })).toThrow(/one unsigned byte/);
67+
expect(() => buildInitData(256, { type: "xrp" })).toThrow(
68+
/one unsigned byte/
69+
);
6870
});
6971
});
7072

cli/src/__tests__/xrpl-payloads.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function buildOnboardingHex(
1414
admin: string,
1515
initialTicket: number,
1616
ticketCount: number,
17-
initDataHex: string,
17+
initDataHex: string
1818
): string {
1919
return (
2020
"5852504C" + // "XRPL"
@@ -41,7 +41,12 @@ describe("parseOnboarding — round-trips xrpl_accounts/init.ts encoding", () =>
4141
});
4242

4343
it("dispatch via parsePayload tags it Onboarding", () => {
44-
const hex = buildOnboardingHex("rypanhdnNhrtnDMGq6RRr497oDBLJnPeA", 1, 2, "06");
44+
const hex = buildOnboardingHex(
45+
"rypanhdnNhrtnDMGq6RRr497oDBLJnPeA",
46+
1,
47+
2,
48+
"06"
49+
);
4550
const parsed = parsePayload(Buffer.from(hex, "hex"));
4651
expect(parsed.kind).toBe("Onboarding");
4752
});

cli/src/__tests__/xrpl-tokenId.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,44 +18,44 @@ describe("computeEmitterAddress — known testnet vectors", () => {
1818
it("XRP deployment (manager rfeMQr71KJQwNUbRwGTgCfVLoUVdWuvyny)", () => {
1919
const emitter = computeEmitterAddressFromRAddress(
2020
"rfeMQr71KJQwNUbRwGTgCfVLoUVdWuvyny",
21-
xrpToken(),
21+
xrpToken()
2222
);
2323
expect(emitter.toString("hex")).toBe(
24-
"3f7582b4a9df3bfd4f5b8b6634b1d1eaa4a4b96f33f0a56184a1c7584641e5e2",
24+
"3f7582b4a9df3bfd4f5b8b6634b1d1eaa4a4b96f33f0a56184a1c7584641e5e2"
2525
);
2626
});
2727

2828
it("IOU FOO deployment (manager+issuer rnv8uG8r7mewUqTZ7us3KESFE4cAEqsjm1)", () => {
2929
const emitter = computeEmitterAddressFromRAddress(
3030
"rnv8uG8r7mewUqTZ7us3KESFE4cAEqsjm1",
31-
iouToken("FOO", "rnv8uG8r7mewUqTZ7us3KESFE4cAEqsjm1"),
31+
iouToken("FOO", "rnv8uG8r7mewUqTZ7us3KESFE4cAEqsjm1")
3232
);
3333
expect(emitter.toString("hex")).toBe(
34-
"23779ce2426c7ec8ef398cdf44bd6fc4d744aa80d0018cc34e7b86d6a30cd0e0",
34+
"23779ce2426c7ec8ef398cdf44bd6fc4d744aa80d0018cc34e7b86d6a30cd0e0"
3535
);
3636
});
3737

3838
it("MPT deployment (manager rf6VeCw74SzN9RQXm6qZUcUdJ1zziGRzU3)", () => {
3939
const emitter = computeEmitterAddressFromRAddress(
4040
"rf6VeCw74SzN9RQXm6qZUcUdJ1zziGRzU3",
41-
mptToken("00F069F049794EF254FE5B399DBBC2622A50AE8747707B18"),
41+
mptToken("00F069F049794EF254FE5B399DBBC2622A50AE8747707B18")
4242
);
4343
expect(emitter.toString("hex")).toBe(
44-
"b97ab26d22bf8688ce7466aac3031abfde0af2ab86ca57854d773f485c3cbb8a",
44+
"b97ab26d22bf8688ce7466aac3031abfde0af2ab86ca57854d773f485c3cbb8a"
4545
);
4646
});
4747
});
4848

4949
describe("buildTokenIdForEmitter — type discriminants", () => {
5050
it("XRP is 32 zero bytes", () => {
5151
expect(buildTokenIdForEmitter(xrpToken()).toString("hex")).toBe(
52-
"00".repeat(32),
52+
"00".repeat(32)
5353
);
5454
});
5555

5656
it("IOU starts with 0x01", () => {
5757
const id = buildTokenIdForEmitter(
58-
iouToken("FOO", "rnv8uG8r7mewUqTZ7us3KESFE4cAEqsjm1"),
58+
iouToken("FOO", "rnv8uG8r7mewUqTZ7us3KESFE4cAEqsjm1")
5959
);
6060
expect(id[0]).toBe(0x01);
6161
expect(id.length).toBe(32);

cli/src/commands/xrpl/create-mpt.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ export function createCreateMptCommand(
6161
runXrpl(async () => {
6262
const network = argv.network as Network;
6363
const endpoint = resolveXrplEndpoint(network, argv.rpc, overrides);
64-
const seed = loadSeed(argv["issuer-seed"], "issuer-seed", "ISSUER_SEED");
64+
const seed = loadSeed(
65+
argv["issuer-seed"],
66+
"issuer-seed",
67+
"ISSUER_SEED"
68+
);
6569
const wallet = walletFromSeed(seed, argv.algorithm);
6670
const flags = parseMptFlags(argv.flags);
6771
const metadata = loadMetadataHex(argv["metadata-json"]);
@@ -90,7 +94,9 @@ export function createCreateMptCommand(
9094
if (metadata !== undefined) tx.MPTokenMetadata = metadata;
9195

9296
console.log(
93-
colors.blue(`Creating MPT issuance from ${wallet.address} (${network})`)
97+
colors.blue(
98+
`Creating MPT issuance from ${wallet.address} (${network})`
99+
)
94100
);
95101
const result = await withXrplClient(endpoint, (client) =>
96102
submitTx(client, wallet, tx)

cli/src/commands/xrpl/enable-rippling.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,16 @@ export function createEnableRipplingCommand(
3434
runXrpl(async () => {
3535
const network = argv.network as Network;
3636
const endpoint = resolveXrplEndpoint(network, argv.rpc, overrides);
37-
const seed = loadSeed(argv["issuer-seed"], "issuer-seed", "ISSUER_SEED");
37+
const seed = loadSeed(
38+
argv["issuer-seed"],
39+
"issuer-seed",
40+
"ISSUER_SEED"
41+
);
3842
const wallet = walletFromSeed(seed, argv.algorithm);
3943
console.log(
40-
colors.blue(`Enabling DefaultRipple on ${wallet.address} (${network})`)
44+
colors.blue(
45+
`Enabling DefaultRipple on ${wallet.address} (${network})`
46+
)
4147
);
4248
const result = await withXrplClient(endpoint, (client) =>
4349
submitTx(client, wallet, {

cli/src/commands/xrpl/fund.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ export function createXrplFundCommand(
3333
builder: (yargs: any) =>
3434
withCommon(yargs)
3535
.option("account", {
36-
describe: "Account to fund (defaults to xrpl.manager from the deployment file)",
36+
describe:
37+
"Account to fund (defaults to xrpl.manager from the deployment file)",
3738
type: "string",
3839
})
3940
.option("amount", {
@@ -106,7 +107,9 @@ export function createXrplFundCommand(
106107
Math.ceil(Number(argv.amount ?? requiredXrp))
107108
);
108109
console.log(
109-
colors.blue(`Funding ${target} via faucet (${xrpAmount} XRP requested)`)
110+
colors.blue(
111+
`Funding ${target} via faucet (${xrpAmount} XRP requested)`
112+
)
110113
);
111114
// The faucet funds the `destination` address directly — no key needed.
112115
const res = await fetch(`https://${host}/accounts`, {

cli/src/commands/xrpl/init.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ export function createXrplInitCommand(
9696
type: "string",
9797
})
9898
.option("core-account", {
99-
describe: "Wormhole Core (GMP) account to send the onboarding message to",
99+
describe:
100+
"Wormhole Core (GMP) account to send the onboarding message to",
100101
type: "string",
101102
default: DEFAULT_TESTNET_CORE_ACCOUNT,
102103
})
@@ -121,7 +122,11 @@ export function createXrplInitCommand(
121122
runXrpl(async () => {
122123
const network = argv.network as Network;
123124
const endpoint = resolveXrplEndpoint(network, argv.rpc, overrides);
124-
const seed = loadSeed(argv["issuer-seed"], "issuer-seed", "ISSUER_SEED");
125+
const seed = loadSeed(
126+
argv["issuer-seed"],
127+
"issuer-seed",
128+
"ISSUER_SEED"
129+
);
125130
const wallet = walletFromSeed(seed, argv.algorithm);
126131

127132
const token = resolveTokenInit(argv);

cli/src/commands/xrpl/relay.ts

Lines changed: 72 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,16 @@ import {
1515
walletFromSeed,
1616
withXrplClient,
1717
} from "../../xrpl/helpers";
18-
import { DEFAULT_EXECUTOR_API, fetchQuote, submitStatusTx } from "../../xrpl/executor";
19-
import { CHAIN_ID_XRPL, DEFAULT_GUARDIAN_API, pollSignedVaa } from "../../xrpl/guardian";
18+
import {
19+
DEFAULT_EXECUTOR_API,
20+
fetchQuote,
21+
submitStatusTx,
22+
} from "../../xrpl/executor";
23+
import {
24+
CHAIN_ID_XRPL,
25+
DEFAULT_GUARDIAN_API,
26+
pollSignedVaa,
27+
} from "../../xrpl/guardian";
2028
import {
2129
RequestPrefix,
2230
buildGasInstructionHex,
@@ -83,7 +91,10 @@ function buildRequest(opts: {
8391
request: {
8492
prefix: RequestPrefix.ERN1,
8593
srcChain: CHAIN_ID_XRPL,
86-
srcManager: ethers.zeroPadValue(srcManager as `0x${string}`, 32) as `0x${string}`,
94+
srcManager: ethers.zeroPadValue(
95+
srcManager as `0x${string}`,
96+
32
97+
) as `0x${string}`,
8798
messageId: opts.messageId,
8899
},
89100
};
@@ -231,55 +242,65 @@ async function runRelay(
231242
// export.ts): a core VAA (erv1: onboarding / admin / register-peer) uses the
232243
// left-padded SENDER account, while an NTT transfer (ern1) uses the keccak
233244
// transceiver emitter keccak256("ntt" || custody || token).
234-
const { emitterHex, sequence } = await withXrplClient(endpoint, async (client) => {
235-
const resp = await client.request({ command: "tx", transaction: txHash });
236-
const tx: any = resp.result;
237-
const ledgerIndex = tx.ledger_index;
238-
if (!ledgerIndex) throw new Error("Transaction not validated (no ledger_index)");
239-
const meta = tx.meta ?? tx.metaData;
240-
if (typeof meta !== "object" || meta === null || !("TransactionIndex" in meta)) {
241-
throw new Error("Transaction metadata missing TransactionIndex");
242-
}
243-
const txIndex = (meta as any).TransactionIndex as number;
244-
const sequence = (BigInt(ledgerIndex) << 32n) | BigInt(txIndex);
245-
246-
let emitterHex: string;
247-
if (requestType === "erv1") {
248-
// Core VAA: emitter = the publishing (SENDER) account, left-padded to 32B.
249-
const sender: string | undefined = tx.Account ?? tx.tx_json?.Account;
250-
if (!sender) {
251-
throw new Error("Could not determine the publishing account (tx.Account)");
252-
}
253-
emitterHex = xrplAccountToEmitter(Buffer.from(decodeAccountID(sender)));
254-
} else {
255-
// NTT transfer: emitter = keccak256("ntt" || custody || token), where the
256-
// custody account is the tx destination and the token is the delivered asset.
257-
const destination: string | undefined =
258-
tx.Destination ?? tx.tx_json?.Destination;
259-
if (!destination) {
260-
throw new Error("Could not determine destination/custody address");
245+
const { emitterHex, sequence } = await withXrplClient(
246+
endpoint,
247+
async (client) => {
248+
const resp = await client.request({ command: "tx", transaction: txHash });
249+
const tx: any = resp.result;
250+
const ledgerIndex = tx.ledger_index;
251+
if (!ledgerIndex)
252+
throw new Error("Transaction not validated (no ledger_index)");
253+
const meta = tx.meta ?? tx.metaData;
254+
if (
255+
typeof meta !== "object" ||
256+
meta === null ||
257+
!("TransactionIndex" in meta)
258+
) {
259+
throw new Error("Transaction metadata missing TransactionIndex");
261260
}
262-
const deliveredAmount = (meta as any).delivered_amount;
263-
let token: TokenId;
264-
if (argv.token) {
265-
token = tokenIdFromFlags({
266-
type: argv.token,
267-
currency: argv.currency,
268-
issuer: argv.issuer,
269-
mptId: argv["mpt-id"],
270-
});
271-
} else if (deliveredAmount) {
272-
token = tokenIdFromXrplAmount(deliveredAmount);
261+
const txIndex = (meta as any).TransactionIndex as number;
262+
const sequence = (BigInt(ledgerIndex) << 32n) | BigInt(txIndex);
263+
264+
let emitterHex: string;
265+
if (requestType === "erv1") {
266+
// Core VAA: emitter = the publishing (SENDER) account, left-padded to 32B.
267+
const sender: string | undefined = tx.Account ?? tx.tx_json?.Account;
268+
if (!sender) {
269+
throw new Error(
270+
"Could not determine the publishing account (tx.Account)"
271+
);
272+
}
273+
emitterHex = xrplAccountToEmitter(Buffer.from(decodeAccountID(sender)));
273274
} else {
274-
token = { type: "XRP" };
275+
// NTT transfer: emitter = keccak256("ntt" || custody || token), where the
276+
// custody account is the tx destination and the token is the delivered asset.
277+
const destination: string | undefined =
278+
tx.Destination ?? tx.tx_json?.Destination;
279+
if (!destination) {
280+
throw new Error("Could not determine destination/custody address");
281+
}
282+
const deliveredAmount = (meta as any).delivered_amount;
283+
let token: TokenId;
284+
if (argv.token) {
285+
token = tokenIdFromFlags({
286+
type: argv.token,
287+
currency: argv.currency,
288+
issuer: argv.issuer,
289+
mptId: argv["mpt-id"],
290+
});
291+
} else if (deliveredAmount) {
292+
token = tokenIdFromXrplAmount(deliveredAmount);
293+
} else {
294+
token = { type: "XRP" };
295+
}
296+
emitterHex = computeEmitterAddress(
297+
Buffer.from(decodeAccountID(destination)),
298+
token
299+
).toString("hex");
275300
}
276-
emitterHex = computeEmitterAddress(
277-
Buffer.from(decodeAccountID(destination)),
278-
token
279-
).toString("hex");
301+
return { emitterHex, sequence };
280302
}
281-
return { emitterHex, sequence };
282-
});
303+
);
283304

284305
const messageId = ethers.toBeHex(sequence, 32) as `0x${string}`;
285306
console.log(` emitter: ${colors.gray(emitterHex)}`);
@@ -353,7 +374,9 @@ async function runRelay(
353374
console.log(` dst addr: ${colors.gray(dstAddr)}`);
354375
console.log(` refund addr: ${colors.gray(refundAddr)}`);
355376
console.log(` relay instructions: ${colors.gray(relayInstructions)}`);
356-
console.log(` request (${requestType}): ${colors.gray(serializeRequest(request))}`);
377+
console.log(
378+
` request (${requestType}): ${colors.gray(serializeRequest(request))}`
379+
);
357380
console.log(` RequestForExecution: ${colors.gray(serialized)}`);
358381

359382
// ── 5. Submit the XRPL Payment carrying the executor-request memo ──

cli/src/commands/xrpl/reserve-tickets.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,24 @@ export function createXrplReserveTicketsCommand(
4141
runXrpl(async () => {
4242
const count: number = argv.count;
4343
if (!Number.isInteger(count) || count < 1 || count > MAX_TICKETS) {
44-
throw new Error(`--count must be an integer between 1 and ${MAX_TICKETS}`);
44+
throw new Error(
45+
`--count must be an integer between 1 and ${MAX_TICKETS}`
46+
);
4547
}
4648

4749
const network = argv.network as Network;
4850
const endpoint = resolveXrplEndpoint(network, argv.rpc, overrides);
49-
const seed = loadSeed(argv["issuer-seed"], "issuer-seed", "ISSUER_SEED");
51+
const seed = loadSeed(
52+
argv["issuer-seed"],
53+
"issuer-seed",
54+
"ISSUER_SEED"
55+
);
5056
const wallet = walletFromSeed(seed, argv.algorithm);
5157

5258
console.log(
53-
colors.blue(`Creating ${count} tickets on ${wallet.address} (${network})`)
59+
colors.blue(
60+
`Creating ${count} tickets on ${wallet.address} (${network})`
61+
)
5462
);
5563
const result = await withXrplClient(endpoint, (client) =>
5664
submitTx(client, wallet, {

0 commit comments

Comments
 (0)