Skip to content

Commit

Permalink
test safe
Browse files Browse the repository at this point in the history
  • Loading branch information
fewensa committed Aug 2, 2024
1 parent 232682a commit 74c695f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
9 changes: 9 additions & 0 deletions src/ecosys/safe.js
Original file line number Diff line number Diff line change
@@ -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";


Expand Down Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions src/register/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/register/lnv2_default.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -177,6 +176,7 @@ async function registerWithSafe(options, callOptions) {
});
}

console.log(p0Transactions);
if (p0Transactions.length) {
const p0 = await safe.propose({
definition,
Expand Down
5 changes: 3 additions & 2 deletions src/register/lnv2_opposite.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 74c695f

Please sign in to comment.