Skip to content

Commit

Permalink
fix: prettier warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
brianUtn98 committed Dec 14, 2023
1 parent a46536b commit 3bd3da4
Show file tree
Hide file tree
Showing 53 changed files with 1,555 additions and 1,069 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = {
env: {
browser: true,
es2021: true,
node: true
node: true,
},
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
overrides: [],
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
- name: typecheck
run: npm run build
- name: test
run: npm test
run: npm test
296 changes: 159 additions & 137 deletions README.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions examples-d/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ services:
image: grafana/grafana:latest
container_name: wallet-manager-d_grafana
ports:
- '4000:3000'
- "4000:3000"
environment:
GF_SECURITY_ADMIN_PASSWORD: 1234
volumes:
Expand All @@ -24,7 +24,7 @@ services:
image: prom/prometheus
container_name: wallet-monitor-d_prometheus
ports:
- '9090:9090'
- "9090:9090"
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
command: "--config.file=/etc/prometheus/prometheus.yml"
16 changes: 8 additions & 8 deletions examples-d/grafana/dashboards/dashboards.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
apiVersion: 1
providers:
- name: 'default'
orgId: 1
folder: ''
type: file
disableDeletion: false
updateIntervalSeconds: 10
options:
path: /etc/grafana/provisioning/dashboards
- name: "default"
orgId: 1
folder: ""
type: file
disableDeletion: false
updateIntervalSeconds: 10
options:
path: /etc/grafana/provisioning/dashboards
16 changes: 8 additions & 8 deletions examples-d/grafana/datasources/datasources.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
access: proxy
url: http://prometheus:9090
jsonData:
timeInterval: "5s"
httpMethod: "GET"
editable: true
- name: Prometheus
type: prometheus
access: proxy
url: http://prometheus:9090
jsonData:
timeInterval: "5s"
httpMethod: "GET"
editable: true
8 changes: 4 additions & 4 deletions examples-d/prometheus.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
scrape_configs:
- job_name: wallet-monitor-d
scrape_interval: 10s
static_configs:
- targets: ['host.docker.internal:9091']
- job_name: wallet-monitor-d
scrape_interval: 10s
static_configs:
- targets: ["host.docker.internal:9091"]
20 changes: 10 additions & 10 deletions examples-d/remote-wallet-manager.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import * as fs from 'fs';
import * as fs from "fs";
import { WalletInterface } from "wallet-monitor";
import {buildWalletManager} from "../src";
import { buildWalletManager } from "../src";

function readConfig() {
const filePath = './config.json'
const fileData = fs.readFileSync(filePath, 'utf-8')
const filePath = "./config.json";
const fileData = fs.readFileSync(filePath, "utf-8");

return JSON.parse(fileData)
return JSON.parse(fileData);
}

const fileConfig = readConfig()
const fileConfig = readConfig();

const walletManager = buildWalletManager(fileConfig)
const walletManager = buildWalletManager(fileConfig);

// perform an action with any wallet available in the pool:
const doSomethingWithWallet = async (wallet: WalletInterface) => {
Expand All @@ -28,14 +28,14 @@ const doSomethingWithWallet = async (wallet: WalletInterface) => {
};

// perform an action with any wallet available in the pool:
walletManager.withWallet('ethereum', doSomethingWithWallet);
walletManager.withWallet("ethereum", doSomethingWithWallet);

// perform an action with one particular wallet:
walletManager.withWallet('ethereum', doSomethingWithWallet, {
walletManager.withWallet("ethereum", doSomethingWithWallet, {
// address: '0x80C67432656d59144cEFf962E8fAF8926599bCF8',
});

// configure the timeout for acquiring the wallet to use:
walletManager.withWallet('solana', doSomethingWithWallet, {
walletManager.withWallet("solana", doSomethingWithWallet, {
leaseTimeout: 10_000,
});
4 changes: 2 additions & 2 deletions examples/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
image: grafana/grafana:latest
container_name: wallet-manager_grafana
ports:
- '4000:3000'
- "4000:3000"
environment:
GF_SECURITY_ADMIN_PASSWORD: 1234
volumes:
Expand All @@ -15,7 +15,7 @@ services:
image: prom/prometheus
container_name: wallet-monitor_prometheus
ports:
- '9090:9090'
- "9090:9090"
volumes:
- ../examples-d/prometheus.yml:/etc/prometheus/prometheus.yml
command: "--config.file=/etc/prometheus/prometheus.yml"
151 changes: 120 additions & 31 deletions examples/rebalancing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,46 @@ const allChainWallets: WalletManagerConfig = {
gasLimit: 1000000,
},
wallets: [
{ privateKey: '0xf9fdbcbcdb4c7c72642be9fe7c09ad5869a961a8ae3c3374841cb6ead5fd34b1' },
{ privateKey: '0x5da88a1c7df3490d040792fcca4676e709fdd3e6f6e0142accc96cb7e205e1e0' },
{ privateKey: '0xa2c984f6a752ee05af03dac0bb65f3ec93f1498d43d23ebe6c31cf988d771423' },
{ privateKey: '0xe0c1c809d0e80dcaaf200b3aec2a91cd00ed05134f10026113219d89d2f6a9b2' },
{ privateKey: '0x3500084e268b862df23a229f268510cdee92623102c4786b0ade6203fa59f421' },
{ privateKey: '0x49692cfecfb48cee7ce8a14273bda6996b832149ff7260bca09c2ea159e9147f' },
{ privateKey: '0xb2868bd9090dcfbc9d6f3012c98039ee20d778f8ef2d8cb721c56b69578934f3' },
{ privateKey: '0x50156cc51cb7ae4f5e6e2cb14a75fc177a1917fbab1a8675db25619567515ddd' },
{ privateKey: '0x6790f27fec85575792c7d1fab8de9955aff171b24329eacf2a279defa596c5d3' },
{ privateKey: '0xe94000d730b9655850afc8e39facb7058678f11e765075d4806d27ed619f258c' },
{
privateKey:
"0xf9fdbcbcdb4c7c72642be9fe7c09ad5869a961a8ae3c3374841cb6ead5fd34b1",
},
{
privateKey:
"0x5da88a1c7df3490d040792fcca4676e709fdd3e6f6e0142accc96cb7e205e1e0",
},
{
privateKey:
"0xa2c984f6a752ee05af03dac0bb65f3ec93f1498d43d23ebe6c31cf988d771423",
},
{
privateKey:
"0xe0c1c809d0e80dcaaf200b3aec2a91cd00ed05134f10026113219d89d2f6a9b2",
},
{
privateKey:
"0x3500084e268b862df23a229f268510cdee92623102c4786b0ade6203fa59f421",
},
{
privateKey:
"0x49692cfecfb48cee7ce8a14273bda6996b832149ff7260bca09c2ea159e9147f",
},
{
privateKey:
"0xb2868bd9090dcfbc9d6f3012c98039ee20d778f8ef2d8cb721c56b69578934f3",
},
{
privateKey:
"0x50156cc51cb7ae4f5e6e2cb14a75fc177a1917fbab1a8675db25619567515ddd",
},
{
privateKey:
"0x6790f27fec85575792c7d1fab8de9955aff171b24329eacf2a279defa596c5d3",
},
{
privateKey:
"0xe94000d730b9655850afc8e39facb7058678f11e765075d4806d27ed619f258c",
},
],
},
polygon: {
Expand All @@ -64,16 +94,46 @@ const allChainWallets: WalletManagerConfig = {
gasLimit: 1000000,
},
wallets: [
{ privateKey: '0xf9fdbcbcdb4c7c72642be9fe7c09ad5869a961a8ae3c3374841cb6ead5fd34b1' },
{ privateKey: '0x5da88a1c7df3490d040792fcca4676e709fdd3e6f6e0142accc96cb7e205e1e0' },
{ privateKey: '0xa2c984f6a752ee05af03dac0bb65f3ec93f1498d43d23ebe6c31cf988d771423' },
{ privateKey: '0xe0c1c809d0e80dcaaf200b3aec2a91cd00ed05134f10026113219d89d2f6a9b2' },
{ privateKey: '0x3500084e268b862df23a229f268510cdee92623102c4786b0ade6203fa59f421' },
{ privateKey: '0x49692cfecfb48cee7ce8a14273bda6996b832149ff7260bca09c2ea159e9147f' },
{ privateKey: '0xb2868bd9090dcfbc9d6f3012c98039ee20d778f8ef2d8cb721c56b69578934f3' },
{ privateKey: '0x50156cc51cb7ae4f5e6e2cb14a75fc177a1917fbab1a8675db25619567515ddd' },
{ privateKey: '0x6790f27fec85575792c7d1fab8de9955aff171b24329eacf2a279defa596c5d3' },
{ privateKey: '0xe94000d730b9655850afc8e39facb7058678f11e765075d4806d27ed619f258c' },
{
privateKey:
"0xf9fdbcbcdb4c7c72642be9fe7c09ad5869a961a8ae3c3374841cb6ead5fd34b1",
},
{
privateKey:
"0x5da88a1c7df3490d040792fcca4676e709fdd3e6f6e0142accc96cb7e205e1e0",
},
{
privateKey:
"0xa2c984f6a752ee05af03dac0bb65f3ec93f1498d43d23ebe6c31cf988d771423",
},
{
privateKey:
"0xe0c1c809d0e80dcaaf200b3aec2a91cd00ed05134f10026113219d89d2f6a9b2",
},
{
privateKey:
"0x3500084e268b862df23a229f268510cdee92623102c4786b0ade6203fa59f421",
},
{
privateKey:
"0x49692cfecfb48cee7ce8a14273bda6996b832149ff7260bca09c2ea159e9147f",
},
{
privateKey:
"0xb2868bd9090dcfbc9d6f3012c98039ee20d778f8ef2d8cb721c56b69578934f3",
},
{
privateKey:
"0x50156cc51cb7ae4f5e6e2cb14a75fc177a1917fbab1a8675db25619567515ddd",
},
{
privateKey:
"0x6790f27fec85575792c7d1fab8de9955aff171b24329eacf2a279defa596c5d3",
},
{
privateKey:
"0xe94000d730b9655850afc8e39facb7058678f11e765075d4806d27ed619f258c",
},
],
},
avalanche: {
Expand All @@ -89,23 +149,52 @@ const allChainWallets: WalletManagerConfig = {
gasLimit: 1000000,
},
wallets: [
{ privateKey: '0xf9fdbcbcdb4c7c72642be9fe7c09ad5869a961a8ae3c3374841cb6ead5fd34b1' },
{ privateKey: '0x5da88a1c7df3490d040792fcca4676e709fdd3e6f6e0142accc96cb7e205e1e0' },
{ privateKey: '0xa2c984f6a752ee05af03dac0bb65f3ec93f1498d43d23ebe6c31cf988d771423' },
{ privateKey: '0xe0c1c809d0e80dcaaf200b3aec2a91cd00ed05134f10026113219d89d2f6a9b2' },
{ privateKey: '0x3500084e268b862df23a229f268510cdee92623102c4786b0ade6203fa59f421' },
{ privateKey: '0x49692cfecfb48cee7ce8a14273bda6996b832149ff7260bca09c2ea159e9147f' },
{ privateKey: '0xb2868bd9090dcfbc9d6f3012c98039ee20d778f8ef2d8cb721c56b69578934f3' },
{ privateKey: '0x50156cc51cb7ae4f5e6e2cb14a75fc177a1917fbab1a8675db25619567515ddd' },
{ privateKey: '0x6790f27fec85575792c7d1fab8de9955aff171b24329eacf2a279defa596c5d3' },
{ privateKey: '0xe94000d730b9655850afc8e39facb7058678f11e765075d4806d27ed619f258c' },
{
privateKey:
"0xf9fdbcbcdb4c7c72642be9fe7c09ad5869a961a8ae3c3374841cb6ead5fd34b1",
},
{
privateKey:
"0x5da88a1c7df3490d040792fcca4676e709fdd3e6f6e0142accc96cb7e205e1e0",
},
{
privateKey:
"0xa2c984f6a752ee05af03dac0bb65f3ec93f1498d43d23ebe6c31cf988d771423",
},
{
privateKey:
"0xe0c1c809d0e80dcaaf200b3aec2a91cd00ed05134f10026113219d89d2f6a9b2",
},
{
privateKey:
"0x3500084e268b862df23a229f268510cdee92623102c4786b0ade6203fa59f421",
},
{
privateKey:
"0x49692cfecfb48cee7ce8a14273bda6996b832149ff7260bca09c2ea159e9147f",
},
{
privateKey:
"0xb2868bd9090dcfbc9d6f3012c98039ee20d778f8ef2d8cb721c56b69578934f3",
},
{
privateKey:
"0x50156cc51cb7ae4f5e6e2cb14a75fc177a1917fbab1a8675db25619567515ddd",
},
{
privateKey:
"0x6790f27fec85575792c7d1fab8de9955aff171b24329eacf2a279defa596c5d3",
},
{
privateKey:
"0xe94000d730b9655850afc8e39facb7058678f11e765075d4806d27ed619f258c",
},
],
},
};

export const manager = buildWalletManager({ config: allChainWallets, options });


for (let i = 0; i < 10; i++) {
// perform an action with any wallet available in the pool:
manager.withWallet("ethereum", async wallet => {
Expand Down
41 changes: 20 additions & 21 deletions examples/wallet-acquire.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,29 +81,28 @@ export const manager = buildWalletManager({
},
});

async function main(){
async function main() {
const timeout = 5000;
console.log(`Waiting ${timeout}ms for wallets to be ready...`);
await wait(timeout);
console.log("Done waiting");
for (let i = 0; i < 10; i++) {
// perform an action with any wallet available in the pool:
try {
manager.withWallet("ethereum", async wallet => {
// do what you need with the wallet
wallet.walletToolbox.pullBalances();

const timeout = 5000
console.log(`Waiting ${timeout}ms for wallets to be ready...`)
await wait(timeout)
console.log("Done waiting")
for (let i = 0; i < 10; i++) {
// perform an action with any wallet available in the pool:
try {
manager.withWallet("ethereum", async wallet => {
// do what you need with the wallet
wallet.walletToolbox.pullBalances()

console.log({
address: wallet.address,
chainName: wallet.walletToolbox.chainName,
console.log({
address: wallet.address,
chainName: wallet.walletToolbox.chainName,
});
await wait(3000);
});
await wait(3000);
});
} catch (e) {
console.log(printError(e));
} catch (e) {
console.log(printError(e));
}
}
}
}

main()
main();
Loading

0 comments on commit 3bd3da4

Please sign in to comment.