Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion clients/js/alph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import {
UpdateRefundAddress,
UpgradeTokenBridgeContract,
AddRewards,
Deposit
Deposit,
BridgeRewardRouterV2
} from '@alephium/wormhole-sdk/lib/cjs/alephium-contracts/ts'

export async function deposit(
Expand Down Expand Up @@ -54,6 +55,26 @@ export async function topupRewards(
console.log(`TxId: ${result.txId}`)
}

export async function updateRewardAmount(
attoAlphAmount: bigint,
networkType: NetworkType,
nodeUrl?: string
) {
if (attoAlphAmount < DUST_AMOUNT) {
throw new Error(`The reward amount cannot be less than the dust amount`)
}

const network = CONFIGS[networkType]['alephium']
const signer = getSignerProvider(network, nodeUrl)
const rewardRouterV2Address = addressFromContractId(network.bridgeRewardRouter)
const rewardRouterV2 = BridgeRewardRouterV2.at(rewardRouterV2Address)
const result = await rewardRouterV2.transact.updateRewardAmount({
signer,
args: { newRewardAmount: attoAlphAmount }
})
console.log(`TxId: ${result.txId}`)
}

function getSignerProvider(network: any, nodeUrl?: string) {
const rpc = nodeUrl ?? network.rpc
if (rpc === undefined) {
Expand Down
37 changes: 33 additions & 4 deletions clients/js/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import yargs from "yargs";
import { hideBin } from "yargs/helpers";

import {
setDefaultWasm,
getSignedVAAWithRetry,
ChainId,
VAA,
Expand All @@ -31,11 +30,10 @@ import {
isEVMChain,
toChainId,
} from "@alephium/wormhole-sdk";
import { deposit, executeGovernanceAlph, getNextGovernanceSequence, topupRewards } from "./alph";
import { deposit, executeGovernanceAlph, getNextGovernanceSequence, topupRewards, updateRewardAmount } from "./alph";
import { default as guardianDevnetConfig } from '../../configs/guardian/devnet.json'
import { CONFIGS, NetworkType } from "./configs";

setDefaultWasm("node");
import { convertAlphAmountWithDecimals } from "@alephium/web3";

const GOVERNANCE_CHAIN = guardianDevnetConfig.governanceChainId
const GOVERNANCE_EMITTER = guardianDevnetConfig.governanceEmitterAddress
Expand Down Expand Up @@ -674,6 +672,37 @@ yargs(hideBin(process.argv))
await topupRewards(alphAmount, network, nodeUrl)
}
)
.command(
"update-reward-amount",
"Update the reward amount in the bridge reward contract",
(yargs) => {
return yargs
.option("amount", {
alias: "a",
describe: "ALPH amount",
type: "number",
required: true,
})
.option("network", {
alias: "n",
describe: "network",
type: "string",
choices: ["mainnet", "testnet", "devnet"],
required: true,
})
.option('node-url', {
describe: "full node url",
type: "string",
required: false,
});
},
async (argv) => {
const network = getNetworkType(argv.network)
const alphAmount = convertAlphAmountWithDecimals(argv.amount)
const nodeUrl = argv['node-url']
await updateRewardAmount(alphAmount, network, nodeUrl)
}
)
.command(
"deposit",
"Deposit ALPH into TokenBridgeForChain contract",
Expand Down
Loading
Loading