diff --git a/src/ecosys/safe.js b/src/ecosys/safe.js index de7c806..c40f248 100644 --- a/src/ecosys/safe.js +++ b/src/ecosys/safe.js @@ -1,5 +1,6 @@ // import {ethers} from "ethers"; import Safe from "@safe-global/protocol-kit"; +// import {EthersAdapter} from "@safe-global/protocol-kit"; import SafeApiKit from "@safe-global/api-kit"; @@ -59,6 +60,14 @@ async function initSafe(options) { safeAddress: safeWalletAddress, }); + // const provider = new ethers.JsonRpcProvider(chain.rpc); + // const wallet = new ethers.Wallet(signer, provider); + // const ethAdapter = new EthersAdapter({ + // ethers, + // signerOrProvider: wallet, + // }); + // const safeSdk = await Safe.default.create({ethAdapter: ethAdapter, safeAddress: safeWalletAddress}); + console.log(`init safe for chain ${chain.id} with ${safeWalletUrl}`); const safeService = new SafeApiKit.default({ chainId: chain.id, diff --git a/src/register/index.js b/src/register/index.js index 4a95bd4..35d9690 100644 --- a/src/register/index.js +++ b/src/register/index.js @@ -102,6 +102,7 @@ async function refactorConfig(options) { } const includeConfigs = YAML.parse(includeFileContent); if (!includeConfigs) { + console.log(`not found include file ${include}`); return []; } for (const ic of includeConfigs) { @@ -115,6 +116,10 @@ async function refactorConfig(options) { async function handle(options) { const {register} = options; + if (!register.bridge) { + return; + } + const [sourceChainName, targetChainName] = register.bridge.split('->'); let relayerAddress = register.safeWalletAddress ?? register.sourceSafeWalletAddress; diff --git a/src/register/lnv2_default.js b/src/register/lnv2_default.js index eb87092..a45f8c2 100644 --- a/src/register/lnv2_default.js +++ b/src/register/lnv2_default.js @@ -1,7 +1,6 @@ import * as safe from "../ecosys/safe.js"; import * as arg from "../ecosys/arg.js"; import * as tool from '../ecosys/tool.js'; -import {isDisableApprove} from "../ecosys/tool.js"; export async function register(options) { const {register, lifecycle} = options; @@ -177,6 +176,7 @@ async function registerWithSafe(options, callOptions) { }); } + console.log(p0Transactions); if (p0Transactions.length) { const p0 = await safe.propose({ definition, diff --git a/src/register/lnv2_opposite.js b/src/register/lnv2_opposite.js index c02a251..755537f 100644 --- a/src/register/lnv2_opposite.js +++ b/src/register/lnv2_opposite.js @@ -107,20 +107,21 @@ async function registerWithSafe(options, callOptions) { } = options; const {approveFlags, setFeeFlags, withdrawFlags, sourceDeposit, sourceChainId} = callOptions; - const txApprove = await $`cast calldata ${approveFlags}`; - const txSetFee = await $`cast calldata ${setFeeFlags}`; const _signerAddress = await $`cast wallet address ${signer}`.quiet(); const signerAddress = _signerAddress.stdout.trim(); const p0Transactions = []; if (!tool.isDisableApprove({definition, symbol: register.symbol, chainId: sourceChainId})) { + const txApprove = await $`cast calldata ${approveFlags}`; p0Transactions.push({ to: lifecycle.sourceToken.address, value: '0', data: txApprove.stdout.trim(), }); } + + const txSetFee = await $`cast calldata ${setFeeFlags}`; p0Transactions.push({ to: lifecycle.contractAddress, value: lifecycle.sourceToken.type === 'native' diff --git a/yarn.lock b/yarn.lock index ce913a2..55af7d7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -146,7 +146,7 @@ "@safe-global/api-kit@^2.4.3": version "2.4.3" - resolved "https://registry.npmjs.org/@safe-global/api-kit/-/api-kit-2.4.3.tgz" + resolved "https://registry.yarnpkg.com/@safe-global/api-kit/-/api-kit-2.4.3.tgz#5bde12efa15c98e96037880718d86a00d155f7d1" integrity sha512-kIbRMYWQiVUqIpu65GYTiHQgYDne9CZJ7JREmtrLQh11n3K7+LxNmHT6HW1VfVj/5Es8fAQlwrBukbTy0AQwLw== dependencies: "@safe-global/protocol-kit" "^4.0.3"