Skip to content

Commit

Permalink
add deposit eth example(fix #151)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fred0327 committed Dec 21, 2023
1 parent 085842b commit b6721ee
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
19 changes: 19 additions & 0 deletions examples/Javascript/node-example/7_depoist.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,24 @@ global.Response = fetch.Response;
// @ts-ignore
global.AbortController = AbortController;

async function testDepositEth() {
const private_key = "0xb32593e347bf09436b058fbeabc17ebd2c7c1fa42e542f5f78fc3580faef83b7";
const eth_rpc_url = "https://linea-goerli.blockpi.network/v1/rpc/0348a3ff6425076c6c8e9b26cc7dbbdb8a6ff3f0";
const zklink_address = "0x63A7Dd7B68f569eDA9bFefd1041b8e56b885e5E9";
const sub_account_id = 10;
// which one?
const deposit_to = "0x9e372368c25056D44045e445d72d7B91cE3eE3B1";
try {
let approve_option = new EthTxOption(true, zklink_address, null, null, null, null);
let wallet = new Wallet(eth_rpc_url, private_key);
console.log(wallet);
let hash = await wallet.depositETH(sub_account_id, deposit_to, approve_option, false)
console.log(hash);
} catch(error) {
console.log(error)
}
}

async function testDepositErc20() {
const private_key = "0xb32593e347bf09436b058fbeabc17ebd2c7c1fa42e542f5f78fc3580faef83b7";
const avax_rpc_url = "https://avalanche-fuji.blockpi.network/v1/rpc/383a4619d008fe876a25060ff8e66a0f6465c3de";
Expand Down Expand Up @@ -64,6 +82,7 @@ async function main() {
console.log(global);
await testDepositErc20();
await testDepositErc20ToGateway();
await testDepositEth();
}

main();
2 changes: 2 additions & 0 deletions provider/tests/test_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ mod test {
expect_base_amount: BigUint::from(10000000000000000u64),
fee: BigUint::from(100000000000000u64),
maker,
contract_prices: vec![],
margin_prices: vec![],
expect_quote_amount: BigUint::from(100000000000000u64),
};
let mut order_matching = builder.build();
Expand Down

0 comments on commit b6721ee

Please sign in to comment.