-
Notifications
You must be signed in to change notification settings - Fork 45
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
1 parent
e90ed84
commit 62e1ace
Showing
3 changed files
with
62 additions
and
0 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,29 @@ | ||
import { Address, Chain, PublicClient, Transport, decodeFunctionData, getAbiItem } from 'viem'; | ||
import { createRollupFetchTransactionHash } from './createRollupFetchTransactionHash'; | ||
import { rollupCreator } from './contracts'; | ||
|
||
const createRollupABI = getAbiItem({ abi: rollupCreator.abi, name: 'createRollup' }); | ||
export async function isAnyTrust<TChain extends Chain | undefined>({ | ||
rollup, | ||
publicClient, | ||
}: { | ||
rollup: Address; | ||
publicClient: PublicClient<Transport, TChain>; | ||
}) { | ||
const createRollupTransactionHash = await createRollupFetchTransactionHash({ | ||
rollup, | ||
publicClient, | ||
}); | ||
|
||
const transaction = await publicClient.getTransaction({ | ||
hash: createRollupTransactionHash, | ||
}); | ||
const { | ||
args: [{ config }], | ||
} = decodeFunctionData({ | ||
abi: [createRollupABI], | ||
data: transaction.input, | ||
}); | ||
const chainConfig = JSON.parse(config.chainConfig); | ||
return chainConfig.arbitrum.DataAvailabilityCommittee; | ||
} |
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,30 @@ | ||
import { expect, it } from 'vitest'; | ||
import { isAnyTrust } from './isAnyTrust'; | ||
import { createPublicClient, http } from 'viem'; | ||
import { arbitrumNova, arbitrumSepolia, sepolia } from 'viem/chains'; | ||
|
||
it('should return true for AnyTrust chain', async () => { | ||
const client = createPublicClient({ | ||
chain: arbitrumNova, | ||
transport: http(), | ||
}); | ||
// https://nova.arbiscan.io/tx/0x37be7a29db10d18501dcf4d0243fa6aefeeba21cbc17832ef16ccf288ce58ef2 | ||
const isPlaynanceAnyTrust = await isAnyTrust({ | ||
publicClient: client, | ||
rollup: '0x04ea347cC6A258A7F65D67aFb60B1d487062A1d0', | ||
}); | ||
expect(isPlaynanceAnyTrust).toBeTruthy(); | ||
}); | ||
|
||
it('should return false for non AnyTrust chain', async () => { | ||
const client = createPublicClient({ | ||
chain: arbitrumSepolia, | ||
transport: http(), | ||
}); | ||
// https://sepolia.arbiscan.io/tx/0x0bbb740d8b0286654b3d0f63175ec882dcbb7714cbf5207357a4a72a4d2dc640 | ||
const isAnyTrustChain = await isAnyTrust({ | ||
publicClient: client, | ||
rollup: '0xd0c7b5c4e8f72e0750ed9dc70a10cf6f5afd4787', | ||
}); | ||
expect(isAnyTrustChain).toBeFalsy(); | ||
}); |