Skip to content

Commit

Permalink
Fix opposite register
Browse files Browse the repository at this point in the history
  • Loading branch information
fewensa committed Apr 22, 2024
1 parent 3974eff commit 982a077
Showing 1 changed file with 8 additions and 31 deletions.
39 changes: 8 additions & 31 deletions src/register/lnv2_opposite.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,11 @@ async function registerWithCall(options, callOptions) {
const sourceSendFlags = [
`--rpc-url=${lifecycle.sourceChainRpc}`,
];
const targetSendFlags = [
`--rpc-url=${lifecycle.targetChainRpc}`,
];

if (!tool.isDisableApprove({definition, symbol: register.symbol, chainId: targetChainId})) {
approveFlags.unshift(...[
...targetSendFlags,
register.targetTokenAddress,
...sourceSendFlags,
register.sourceTokenAddress,
]);
await $`echo cast send ${approveFlags}`;
approveFlags.unshift(`--private-key=${signer}`);
Expand All @@ -116,7 +113,6 @@ async function registerWithSafe(options, callOptions) {
const {
register, lifecycle, definition,
sourceSafeSdk, sourceSafeService, sourceSigner,
targetSafeSdk, targetSafeService, targetSigner,
} = options;
const {approveFlags, setFeeFlags, withdrawFlags, sourceDeposit, targetChainId} = callOptions;

Expand All @@ -132,38 +128,19 @@ async function registerWithSafe(options, callOptions) {
data: txApprove.stdout.trim(),
});
}

if (p0Transactions.length) {
const p0 = await safe.propose({
definition,
safeSdk: targetSafeSdk,
safeService: targetSafeService,
safeAddress: register.safeWalletAddress,
senderAddress: targetSigner.address,
transactions: p0Transactions,
});
console.log(
chalk.green('proposed approve transaction to'),
`${lifecycle.targetChainName}: ${register.safeWalletAddress} (safe)`
);
if (p0 && arg.isDebug()) {
console.log(p0);
}
}
p0Transactions.push({
to: register.contract,
value: sourceDeposit.toString(),
data: txSetFee.stdout.trim(),
});

const p1 = await safe.propose({
definition,
safeSdk: sourceSafeSdk,
safeService: sourceSafeService,
safeAddress: register.safeWalletAddress,
senderAddress: sourceSigner.address,
transactions: [
{
to: register.contract,
value: sourceDeposit.toString(),
data: txSetFee.stdout.trim(),
}
],
transactions: p0Transactions,
});
console.log(
chalk.green('proposed register transaction to'),
Expand Down

0 comments on commit 982a077

Please sign in to comment.