-
Notifications
You must be signed in to change notification settings - Fork 4
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
39 changed files
with
1,361 additions
and
295 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
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,82 @@ | ||
import { | ||
http, | ||
type Address, | ||
type Chain, | ||
type LocalAccount, | ||
type PublicClient, | ||
type WalletClient, | ||
createWalletClient | ||
} from "viem" | ||
import { afterAll, beforeAll, describe, expect, test } from "vitest" | ||
import { toNetwork } from "../../../test/testSetup" | ||
import { | ||
getTestAccount, | ||
killNetwork, | ||
toTestClient | ||
} from "../../../test/testUtils" | ||
import type { MasterClient, NetworkConfig } from "../../../test/testUtils" | ||
import { | ||
type NexusClient, | ||
createSmartAccountClient | ||
} from "../../clients/createSmartAccountClient" | ||
import { | ||
MEE_VALIDATOR_ADDRESS, | ||
RHINESTONE_ATTESTER_ADDRESS, | ||
TEST_ADDRESS_K1_VALIDATOR_ADDRESS, | ||
TEST_ADDRESS_K1_VALIDATOR_FACTORY_ADDRESS | ||
} from "../../constants" | ||
import type { NexusAccount } from "../toNexusAccount" | ||
import { getK1FactoryData, getMeeFactoryData } from "./getFactoryData" | ||
|
||
describe("nexus.account.getFactoryData", async () => { | ||
let network: NetworkConfig | ||
let chain: Chain | ||
let bundlerUrl: string | ||
|
||
// Test utils | ||
let testClient: MasterClient | ||
let eoaAccount: LocalAccount | ||
let nexusAccount: NexusAccount | ||
let walletClient: WalletClient | ||
|
||
beforeAll(async () => { | ||
network = await toNetwork("MAINNET_FROM_ENV_VARS") | ||
|
||
chain = network.chain | ||
bundlerUrl = network.bundlerUrl | ||
eoaAccount = network.account! | ||
testClient = toTestClient(chain, getTestAccount(5)) | ||
}) | ||
afterAll(async () => { | ||
await killNetwork([network?.rpcPort, network?.bundlerPort]) | ||
}) | ||
|
||
test("should check factory data", async () => { | ||
const factoryData = await getK1FactoryData({ | ||
signerAddress: eoaAccount.address, | ||
index: 0n, | ||
attesters: [RHINESTONE_ATTESTER_ADDRESS], | ||
attesterThreshold: 1 | ||
}) | ||
|
||
expect(factoryData).toMatchInlineSnapshot( | ||
`"0x0d51f0b70000000000000000000000003079b249dfde4692d7844aa261f8cf7d927a0da50000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000333034e9f539ce08819e12c1b8cb29084d"` | ||
) | ||
}) | ||
|
||
test("should check factory data with mee", async () => { | ||
const factoryData = await getMeeFactoryData({ | ||
signerAddress: eoaAccount.address, | ||
index: 0n, | ||
attesters: [MEE_VALIDATOR_ADDRESS], | ||
attesterThreshold: 1, | ||
validatorAddress: MEE_VALIDATOR_ADDRESS, | ||
publicClient: testClient as unknown as PublicClient, | ||
walletClient | ||
}) | ||
|
||
expect(factoryData).toMatchInlineSnapshot( | ||
`"0xea6d13ac0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000f5b753fdd20c5ca2d7c1210b3ab1ea59030000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000012401fe9ff2000000000000000000000000068ea3e30788abafdc6fd0b38d20bd38a40a2b3d00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000069e2a187aeffb852bf3ccdc95151b200000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000143079b249dfde4692d7844aa261f8cf7d927a0da50000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000068ea3e30788abafdc6fd0b38d20bd38a40a2b3d00000000000000000000000000000000000000000000000000000000"` | ||
) | ||
}) | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { | ||
http, | ||
type Address, | ||
type Chain, | ||
type LocalAccount, | ||
type PublicClient, | ||
type WalletClient, | ||
createPublicClient | ||
} from "viem" | ||
import { afterAll, beforeAll, describe, expect, test } from "vitest" | ||
import { toNetwork } from "../../../test/testSetup" | ||
import type { NetworkConfig } from "../../../test/testUtils" | ||
import { | ||
MAINNET_ADDRESS_K1_VALIDATOR_FACTORY_ADDRESS, | ||
NEXUS_ACCOUNT_FACTORY | ||
} from "../../constants" | ||
import { getK1NexusAddress, getMeeNexusAddress } from "./getNexusAddress" | ||
|
||
describe("account.getNexusAddress", () => { | ||
let network: NetworkConfig | ||
let chain: Chain | ||
let bundlerUrl: string | ||
|
||
// Test utils | ||
let publicClient: PublicClient | ||
let eoaAccount: LocalAccount | ||
|
||
beforeAll(async () => { | ||
network = await toNetwork("TESTNET_FROM_ENV_VARS") | ||
|
||
chain = network.chain | ||
bundlerUrl = network.bundlerUrl | ||
eoaAccount = network.account! | ||
publicClient = createPublicClient({ | ||
chain, | ||
transport: http(network.rpcUrl) | ||
}) | ||
}) | ||
|
||
test("should check k1 nexus address", async () => { | ||
const customAttesters = [ | ||
"0x1111111111111111111111111111111111111111" as Address, | ||
"0x2222222222222222222222222222222222222222" as Address | ||
] | ||
const customThreshold = 2 | ||
const customIndex = 5n | ||
|
||
const k1AddressWithParams = await getK1NexusAddress({ | ||
publicClient: publicClient as unknown as PublicClient, | ||
signerAddress: eoaAccount.address, | ||
attesters: customAttesters, | ||
threshold: customThreshold, | ||
index: customIndex | ||
}) | ||
|
||
expect(k1AddressWithParams).toMatchInlineSnapshot( | ||
`"0x93828A8f4405F112a65bf1732a4BE8f5B4C99322"` | ||
) | ||
}) | ||
|
||
test("should check mee nexus address", async () => { | ||
const index = 1n | ||
|
||
const meeAddress = await getMeeNexusAddress({ | ||
publicClient: publicClient as unknown as PublicClient, | ||
signerAddress: eoaAccount.address | ||
}) | ||
|
||
expect(meeAddress).toMatchInlineSnapshot( | ||
`"0x1968a6Ab4a542EB22e7452AC25381AE6c0f07826"` | ||
) | ||
}) | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import type { Address, Chain, LocalAccount } from "viem" | ||
import { base } from "viem/chains" | ||
import { beforeAll, describe, expect, it } from "vitest" | ||
import { toNetwork } from "../../../test/testSetup" | ||
import type { NetworkConfig } from "../../../test/testUtils" | ||
import { | ||
type MultichainSmartAccount, | ||
toMultichainNexusAccount | ||
} from "../../account/toMultiChainNexusAccount" | ||
import { type MeeClient, createMeeClient } from "../../clients/createMeeClient" | ||
import { mcUSDC } from "../../constants/tokens" | ||
import { getUnifiedERC20Balance } from "./getUnifiedERC20Balance" | ||
|
||
describe("mee:getUnifiedERC20Balance", () => { | ||
let network: NetworkConfig | ||
let eoaAccount: LocalAccount | ||
let paymentChain: Chain | ||
let paymentToken: Address | ||
let mcNexus: MultichainSmartAccount | ||
let meeClient: MeeClient | ||
|
||
beforeAll(async () => { | ||
network = await toNetwork("MAINNET_FROM_ENV_VARS") | ||
|
||
paymentChain = network.chain | ||
paymentToken = network.paymentToken! | ||
eoaAccount = network.account! | ||
|
||
mcNexus = await toMultichainNexusAccount({ | ||
chains: [base, paymentChain], | ||
signer: eoaAccount | ||
}) | ||
|
||
meeClient = createMeeClient({ account: mcNexus }) | ||
}) | ||
|
||
it("should aggregate balances across chains correctly", async () => { | ||
const unifiedBalance = await getUnifiedERC20Balance({ | ||
deployments: mcNexus.deployments, | ||
mcToken: mcUSDC | ||
}) | ||
|
||
expect(unifiedBalance.balance).toBeGreaterThan(0n) | ||
expect(unifiedBalance.breakdown).toHaveLength(2) | ||
expect(unifiedBalance.decimals).toBe(6) | ||
|
||
expect(unifiedBalance.breakdown[0]).toHaveProperty("balance") | ||
expect(unifiedBalance.breakdown[0]).toHaveProperty("decimals") | ||
expect(unifiedBalance.breakdown[0]).toHaveProperty("chainId") | ||
}) | ||
}) |
Oops, something went wrong.