forked from Team-Kujira/crank
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
454 additions
and
324 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# flyctl launch added from .gitignore | ||
**/node_modules | ||
**/bin | ||
**/.env | ||
**/.DS_Store | ||
fly.toml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# See https://fly.io/docs/app-guides/continuous-deployment-with-github-actions/ | ||
|
||
name: Fly Deploy | ||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
deploy: | ||
name: Deploy app | ||
runs-on: ubuntu-latest | ||
concurrency: deploy-group # optional: ensure only one action runs at a time | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: superfly/flyctl-actions/setup-flyctl@master | ||
- run: flyctl deploy --remote-only | ||
env: | ||
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM oven/bun:latest | ||
|
||
WORKDIR /app | ||
|
||
COPY . . | ||
|
||
RUN apt-get -y update | ||
RUN apt-get install -y procps && rm -rf /var/lib/apt/lists/* | ||
|
||
RUN bun install --verbose | ||
|
||
ENTRYPOINT ["sh", "-c", "bun run --bun start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,60 @@ | ||
import { Contract, NETWORK } from "config.js"; | ||
import { client, signAndBroadcast } from "wallet.js"; | ||
import { msg } from "kujira.js"; | ||
import { HUBS } from "@entropic-labs/quark.js"; | ||
|
||
export const registry = { | ||
"kaiyo-1": [ | ||
{ address: "kujira1eulxny0ffvhkkec9l2s44tg9a868ly0fgg86raduypku735zyeyqv7lsun", interval: 86400 }, | ||
{ address: "kujira17nsll5xs4ak8lsguqelhh0etvvfe2cw6lmhg0jpja28zedunddkq0d4jv4", interval: 86400 }, | ||
{ address: "kujira1y52rf2kv6t9yvev7g3s5jvxutw7jxj3a87p3yydrh4dxtdglkssq06sjy2", interval: 86400 } | ||
], | ||
"harpoon-4": [ | ||
{ address: "kujira1jhmfj3avt2dlswrqlgx7fssvgrqfqzyj9m5cvgavuwekquxhu27ql88enu", interval: 60 }, | ||
{ address: "kujira16t7wlfluk27c7emzvxfcqxzged7tkne9p7rrwexzc7gdg6dvk4psxm5waf", interval: 60 } | ||
] | ||
"kaiyo-1": Object.values(HUBS["kaiyo-1"]).map((x) => ({ | ||
address: x!.address, | ||
interval: 86400, | ||
})), | ||
"harpoon-4": Object.keys(HUBS["harpoon-4"]).map((address) => ({ | ||
address, | ||
interval: 60, | ||
})), | ||
}; | ||
|
||
export const contracts = [ | ||
...registry[NETWORK].map(({ address }) => ({ | ||
address, | ||
contract: Contract.HUB, | ||
})), | ||
...registry[NETWORK].map(({ address }) => ({ | ||
address, | ||
contract: Contract.HUB, | ||
})), | ||
]; | ||
|
||
/// We need to run the "{ crank: {} }" message on the hub to: | ||
/// 1. Claim and redistribute rewards | ||
/// 2. Vote on proposals | ||
/// 3. Queue unbondings, etc. | ||
export async function run(address: string, idx: number) { | ||
const config = registry[NETWORK].find((x) => x.address === address); | ||
if (!config) throw new Error(`${address} hub not found`); | ||
const config = registry[NETWORK].find((x) => x.address === address); | ||
if (!config) throw new Error(`${address} hub not found`); | ||
|
||
try { | ||
const w = await client(idx); | ||
try { | ||
const w = await client(idx); | ||
|
||
const msgs = [ | ||
msg.wasm.msgExecuteContract({ | ||
sender: w[1], | ||
contract: address, | ||
msg: Buffer.from( | ||
JSON.stringify({ | ||
crank: {}, | ||
}) | ||
), | ||
funds: [], | ||
}), | ||
]; | ||
try { | ||
console.debug(`[HUB:${address}] Cranking...`); | ||
const res = await signAndBroadcast(w, msgs, "auto"); | ||
console.info(`[HUB:${address}] Cranked: ${res.transactionHash}`); | ||
} catch (e: any) { | ||
console.error(`[HUB:${address}] ${e}`); | ||
} | ||
} catch (error: any) { | ||
console.error(`[HUB:${address}] ${error.message}`); | ||
} finally { | ||
await new Promise((resolve) => setTimeout(resolve, config.interval * 1000)); | ||
await run(address, idx); | ||
const msgs = [ | ||
msg.wasm.msgExecuteContract({ | ||
sender: w[1], | ||
contract: address, | ||
msg: Buffer.from( | ||
JSON.stringify({ | ||
crank: "empty", | ||
}) | ||
), | ||
funds: [], | ||
}), | ||
]; | ||
try { | ||
console.debug(`[HUB:${address}] Cranking...`); | ||
const res = await signAndBroadcast(w, msgs, "auto"); | ||
console.info(`[HUB:${address}] Cranked: ${res.transactionHash}`); | ||
} catch (e: any) { | ||
console.error(`[HUB:${address}] ${e}`); | ||
} | ||
} catch (error: any) { | ||
console.error(`[HUB:${address}] ${error.message}`); | ||
} finally { | ||
await new Promise((resolve) => setTimeout(resolve, config.interval * 1000)); | ||
await run(address, idx); | ||
} | ||
} |
Oops, something went wrong.