Skip to content

Commit 0f91380

Browse files
feat(cli): xrpl transfer subcommand to trigger ntt transfers with relay
Co-authored-by: Douglas Galico <douglas.galico@gmail.com>
1 parent 65381b3 commit 0f91380

4 files changed

Lines changed: 334 additions & 9 deletions

File tree

cli/src/commands/manual.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
encoding,
99
isNetwork,
1010
toUniversal,
11+
UniversalAddress,
1112
type Chain,
1213
} from "@wormhole-foundation/sdk";
1314

@@ -20,6 +21,8 @@ import { options } from "./shared";
2021
import { pullChainConfig } from "../index";
2122
import { validatePayerOption } from "../validation";
2223

24+
const isUniversalHex = (address: string): boolean => /^(0x)?[0-9a-fA-F]{64}$/.test(address);
25+
2326
export function createManualCommand(
2427
overrides: WormholeConfigOverrides<Network>
2528
) {
@@ -118,10 +121,15 @@ export function createManualCommand(
118121
`\nSource NTT Manager: ${colors.yellow(sourceConfig.manager)}`
119122
);
120123

121-
// Create peer address object
124+
// Create peer address object. A peer NTT manager address is a raw
125+
// 32-byte universal value, so accept hex directly — routing it
126+
// through the chain-specific parser (toUniversal) fails for chains
127+
// whose native encoding isn't hex (e.g. XRPL base58).
122128
const peerChainAddress = {
123129
chain: peerChain,
124-
address: toUniversal(peerChain, peerAddress),
130+
address: isUniversalHex(peerAddress)
131+
? new UniversalAddress(peerAddress)
132+
: toUniversal(peerChain, peerAddress),
125133
};
126134

127135
// Get signer for the source chain
@@ -337,10 +345,15 @@ export function createManualCommand(
337345
`\nSource NTT Manager: ${colors.yellow(sourceConfig.manager)}`
338346
);
339347

340-
// Create peer address object
348+
// Create peer address object. A transceiver peer is always a raw
349+
// 32-byte universal address, so accept hex directly — routing it
350+
// through the chain-specific parser (toUniversal) fails for chains
351+
// whose native encoding isn't hex (e.g. XRPL base58).
341352
const peerChainAddress = {
342353
chain: peerChain,
343-
address: toUniversal(peerChain, peerAddress),
354+
address: isUniversalHex(peerAddress)
355+
? new UniversalAddress(peerAddress)
356+
: toUniversal(peerChain, peerAddress),
344357
};
345358

346359
// Get signer for the source chain

cli/src/commands/xrpl/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { createXrplParseVaaCommand } from "./parse-vaa";
1717
import { createXrplRelayCommand } from "./relay";
1818
import { createXrplRegisterPeerCommand } from "./register-peer";
1919
import { createXrplRotateAdminCommand } from "./rotate-admin";
20+
import { createXrplTransferCommand } from "./transfer";
2021

2122
/**
2223
* `ntt xrpl <subcommand>` — XRPL commands for preparing and operating an NTT
@@ -66,6 +67,7 @@ export function createXrplCommand(overrides: WormholeConfigOverrides<Network>) {
6667
.command(createXrplRelayCommand(overrides))
6768
.command(createXrplRegisterPeerCommand(overrides))
6869
.command(createXrplRotateAdminCommand(overrides))
70+
.command(createXrplTransferCommand(overrides))
6971
.demandCommand(1, "Specify an xrpl subcommand")
7072
.strict(),
7173
handler: () => {},

cli/src/commands/xrpl/relay.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ export function createXrplRelayCommand(
211211
};
212212
}
213213

214-
async function runRelay(
214+
export async function runRelay(
215215
argv: any,
216216
overrides: WormholeConfigOverrides<Network>
217217
): Promise<void> {
@@ -221,12 +221,12 @@ async function runRelay(
221221
const dstChain = resolveChainId(argv["dst-chain"]);
222222
const requestType: "ern1" | "erv1" = argv["request-type"];
223223
const executor: string = argv.executor;
224-
const executorApi: string = argv["executor-api"];
225-
const guardianApi: string = argv["guardian-api"];
224+
const executorApi: string = argv["executor-api"] ?? DEFAULT_EXECUTOR_API;
225+
const guardianApi: string = argv["guardian-api"] ?? DEFAULT_GUARDIAN_API;
226226
const gasLimit = BigInt(argv["gas-limit"]);
227227
const msgValue = BigInt(argv["msg-value"]);
228-
const pollInterval = argv["poll-interval"];
229-
const pollTimeout = argv["poll-timeout"];
228+
const pollInterval = argv["poll-interval"] ?? 5_000;
229+
const pollTimeout = argv["poll-timeout"] ?? 120_000;
230230

231231
const seed = loadSeed(argv.seed, "seed", "SEED");
232232
const wallet = walletFromSeed(seed, argv.algorithm);

0 commit comments

Comments
 (0)