-
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.
switch from ethers to viem; remove bridgeworld endpoints
- Loading branch information
1 parent
a11fd94
commit 2b636e4
Showing
21 changed files
with
4,865 additions
and
2,690 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,28 @@ | ||
import { FlatCompat } from "@eslint/eslintrc"; | ||
import js from "@eslint/js"; | ||
import jest from "eslint-plugin-jest"; | ||
import path from "node:path"; | ||
import { fileURLToPath } from "node:url"; | ||
|
||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = path.dirname(__filename); | ||
const compat = new FlatCompat({ | ||
baseDirectory: __dirname, | ||
recommendedConfig: js.configs.recommended, | ||
allConfig: js.configs.all, | ||
}); | ||
|
||
export default [ | ||
...compat.extends("prettier"), | ||
{ | ||
plugins: { | ||
jest, | ||
}, | ||
|
||
languageOptions: { | ||
globals: {}, | ||
ecmaVersion: "latest", | ||
sourceType: "script", | ||
}, | ||
}, | ||
]; |
Large diffs are not rendered by default.
Oops, something went wrong.
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,11 +1,15 @@ | ||
const { Contract } = require("@ethersproject/contracts"); | ||
const { CONTRACT_BEACON_PETS_STAKING_RULES } = require("../constants"); | ||
const { arbitrumProvider } = require("../utils/provider"); | ||
const { arbitrumClient } = require("../utils/provider"); | ||
const { parseAbi } = require("viem"); | ||
|
||
const beaconPetsStakingRules = new Contract( | ||
CONTRACT_BEACON_PETS_STAKING_RULES, | ||
["function beaconPetsAmountStaked(address) view returns (uint256)"], | ||
arbitrumProvider | ||
); | ||
const abi = parseAbi([ | ||
"function beaconPetsAmountStaked(address) view returns (uint256)", | ||
]); | ||
|
||
module.exports = beaconPetsStakingRules; | ||
exports.getBeaconPetsAmountStaked = async (address) => | ||
arbitrumClient.readContract({ | ||
address: CONTRACT_BEACON_PETS_STAKING_RULES, | ||
abi, | ||
functionName: "beaconPetsAmountStaked", | ||
args: [address], | ||
}); |
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,11 +1,15 @@ | ||
const { Contract } = require("@ethersproject/contracts"); | ||
const { CONTRACT_BEACON_QUESTING } = require("../constants"); | ||
const { arbitrumProvider } = require("../utils/provider"); | ||
const { arbitrumClient } = require("../utils/provider"); | ||
const { parseAbi } = require("viem"); | ||
|
||
const beaconQuesting = new Contract( | ||
CONTRACT_BEACON_QUESTING, | ||
["function getUserQuests(address) view returns (uint128,uint128,uint128)"], | ||
arbitrumProvider | ||
); | ||
const abi = parseAbi([ | ||
"function getUserQuests(address) view returns (uint128,uint128,uint128)", | ||
]); | ||
|
||
module.exports = beaconQuesting; | ||
exports.getUserQuests = async (address) => | ||
arbitrumClient.readContract({ | ||
address: CONTRACT_BEACON_QUESTING, | ||
abi, | ||
functionName: "getUserQuests", | ||
args: [address], | ||
}); |
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,11 +1,13 @@ | ||
const { Contract } = require("@ethersproject/contracts"); | ||
const { CONTRACT_BEACON_WRIT_OF_PASSAGE } = require("../constants"); | ||
const { arbitrumProvider } = require("../utils/provider"); | ||
const { arbitrumClient } = require("../utils/provider"); | ||
const { parseAbi } = require("viem"); | ||
|
||
const beaconWritOfPassage = new Contract( | ||
CONTRACT_BEACON_WRIT_OF_PASSAGE, | ||
["function balanceOf(address) view returns (uint256)"], | ||
arbitrumProvider | ||
); | ||
const abi = parseAbi(["function balanceOf(address) view returns (uint256)"]); | ||
|
||
module.exports = beaconWritOfPassage; | ||
exports.getWritOfPassageBalance = async (address) => | ||
arbitrumClient.readContract({ | ||
address: CONTRACT_BEACON_WRIT_OF_PASSAGE, | ||
abi, | ||
functionName: "balanceOf", | ||
args: [address], | ||
}); |
This file was deleted.
Oops, something went wrong.
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,21 +1,30 @@ | ||
const { Contract } = require("@ethersproject/contracts"); | ||
const { CONTRACT_MAGIC, CONTRACT_MAGIC_L1 } = require("../constants"); | ||
const { erc20Abi } = require("viem"); | ||
const { CONTRACT_MAGIC_L1, CONTRACT_MAGIC } = require("../constants"); | ||
const { parseNumber } = require("../utils/number"); | ||
const { arbitrumProvider, ethereumProvider } = require("../utils/provider"); | ||
|
||
const erc20Abi = [ | ||
"function balanceOf(address) view returns (uint256)", | ||
"function totalSupply() view returns (uint256)", | ||
]; | ||
|
||
const magic = new Contract(CONTRACT_MAGIC, erc20Abi, arbitrumProvider); | ||
|
||
const magicL1 = new Contract(CONTRACT_MAGIC_L1, erc20Abi, ethereumProvider); | ||
const { arbitrumClient, ethereumClient } = require("../utils/provider"); | ||
|
||
exports.getMagicTotalSupply = async () => | ||
parseNumber(await magicL1.totalSupply()); | ||
parseNumber( | ||
await ethereumClient.readContract({ | ||
address: CONTRACT_MAGIC_L1, | ||
abi: erc20Abi, | ||
functionName: "totalSupply", | ||
}) | ||
); | ||
|
||
exports.getMagicBalanceOf = async (address, isL1 = false) => | ||
parseNumber( | ||
isL1 ? await magicL1.balanceOf(address) : await magic.balanceOf(address) | ||
isL1 | ||
? await ethereumClient.readContract({ | ||
address: CONTRACT_MAGIC_L1, | ||
abi: erc20Abi, | ||
functionName: "balanceOf", | ||
args: [address], | ||
}) | ||
: await arbitrumClient.readContract({ | ||
address: CONTRACT_MAGIC, | ||
abi: erc20Abi, | ||
functionName: "balanceOf", | ||
args: [address], | ||
}) | ||
); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,26 +1,26 @@ | ||
const { Contract } = require("@ethersproject/contracts"); | ||
const { arbitrumProvider } = require("../utils/provider"); | ||
const { arbitrumClient } = require("../utils/provider"); | ||
const { parseAbi } = require("viem"); | ||
|
||
exports.createPairContract = (address) => | ||
new Contract( | ||
address, | ||
[ | ||
"function getReserves() view returns (uint112,uint112,uint32)", | ||
"function totalSupply() view returns (uint256)", | ||
], | ||
arbitrumProvider | ||
); | ||
const abi = parseAbi([ | ||
"function getReserves() view returns (uint112,uint112,uint32)", | ||
"function totalSupply() view returns (uint256)", | ||
]); | ||
|
||
exports.getPairReserves = async (address) => { | ||
const [reserve0, reserve1] = | ||
await this.createPairContract(address).getReserves(); | ||
const [reserve0, reserve1] = await arbitrumClient.readContract({ | ||
address, | ||
abi, | ||
functionName: "getReserves", | ||
}); | ||
return { | ||
reserve0, | ||
reserve1, | ||
}; | ||
}; | ||
|
||
exports.getPairTotalSupply = async (address) => { | ||
const totalSupply = await this.createPairContract(address).totalSupply(); | ||
return totalSupply; | ||
}; | ||
exports.getPairTotalSupply = async (address) => | ||
arbitrumClient.readContract({ | ||
address, | ||
abi, | ||
functionName: "totalSupply", | ||
}); |
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,12 +1,14 @@ | ||
const { Contract } = require("@ethersproject/contracts"); | ||
const { arbitrumProvider } = require("../utils/provider"); | ||
const { parseAbi } = require("viem"); | ||
const { arbitrumClient } = require("../utils/provider"); | ||
|
||
exports.createRouterContract = (address) => | ||
new Contract( | ||
address, | ||
["function quote(uint256,uint256,uint256) view returns (uint256)"], | ||
arbitrumProvider | ||
); | ||
const abi = parseAbi([ | ||
"function quote(uint256,uint256,uint256) view returns (uint256)", | ||
]); | ||
|
||
exports.getQuote = async (address, amount0, reserve0, reserve1) => | ||
await this.createRouterContract(address).quote(amount0, reserve0, reserve1); | ||
arbitrumClient.readContract({ | ||
address, | ||
abi, | ||
functionName: "quote", | ||
args: [amount0, reserve0, reserve1], | ||
}); |
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
Oops, something went wrong.