|
| 1 | +import { abi, bytecode, config } from '@wagmi/test' |
| 2 | +import { http } from 'viem' |
| 3 | +import { celo, mainnet } from 'viem/chains' |
| 4 | +import { expectTypeOf, test } from 'vitest' |
| 5 | + |
| 6 | +import { createConfig } from '../createConfig.js' |
| 7 | +import { |
| 8 | + type DeployContractParameters, |
| 9 | + deployContract, |
| 10 | +} from './deployContract.js' |
| 11 | + |
| 12 | +test('default', async () => { |
| 13 | + await deployContract(config, { |
| 14 | + abi: abi.bayc, |
| 15 | + bytecode: bytecode.bayc, |
| 16 | + args: ['Bored Ape Wagmi Club', 'BAYC', 69420n, 0n], |
| 17 | + chainId: mainnet.id, |
| 18 | + }) |
| 19 | +}) |
| 20 | + |
| 21 | +test('chain formatters', () => { |
| 22 | + const config = createConfig({ |
| 23 | + chains: [mainnet, celo], |
| 24 | + transports: { [celo.id]: http(), [mainnet.id]: http() }, |
| 25 | + }) |
| 26 | + |
| 27 | + type Result = DeployContractParameters<typeof abi.bayc, typeof config> |
| 28 | + expectTypeOf<Result>().toMatchTypeOf<{ |
| 29 | + chainId?: typeof celo.id | typeof mainnet.id | undefined |
| 30 | + feeCurrency?: `0x${string}` | undefined |
| 31 | + gatewayFee?: bigint | undefined |
| 32 | + gatewayFeeRecipient?: `0x${string}` | undefined |
| 33 | + }>() |
| 34 | + deployContract(config, { |
| 35 | + abi: abi.bayc, |
| 36 | + bytecode: bytecode.bayc, |
| 37 | + args: ['Bored Ape Wagmi Club', 'BAYC', 69420n, 0n], |
| 38 | + feeCurrency: '0x', |
| 39 | + gatewayFee: 100n, |
| 40 | + gatewayFeeRecipient: '0x', |
| 41 | + }) |
| 42 | + |
| 43 | + type Result2 = DeployContractParameters< |
| 44 | + typeof abi.bayc, |
| 45 | + typeof config, |
| 46 | + typeof celo.id |
| 47 | + > |
| 48 | + expectTypeOf<Result2>().toMatchTypeOf<{ |
| 49 | + feeCurrency?: `0x${string}` | undefined |
| 50 | + gatewayFee?: bigint | undefined |
| 51 | + gatewayFeeRecipient?: `0x${string}` | undefined |
| 52 | + }>() |
| 53 | + deployContract(config, { |
| 54 | + chainId: celo.id, |
| 55 | + abi: abi.bayc, |
| 56 | + bytecode: bytecode.bayc, |
| 57 | + args: ['Bored Ape Wagmi Club', 'BAYC', 69420n, 0n], |
| 58 | + feeCurrency: '0x', |
| 59 | + gatewayFee: 100n, |
| 60 | + gatewayFeeRecipient: '0x', |
| 61 | + }) |
| 62 | + |
| 63 | + type Result3 = DeployContractParameters< |
| 64 | + typeof abi.bayc, |
| 65 | + typeof config, |
| 66 | + typeof mainnet.id |
| 67 | + > |
| 68 | + expectTypeOf<Result3>().not.toMatchTypeOf<{ |
| 69 | + feeCurrency?: `0x${string}` | undefined |
| 70 | + gatewayFee?: bigint | undefined |
| 71 | + gatewayFeeRecipient?: `0x${string}` | undefined |
| 72 | + }>() |
| 73 | + deployContract(config, { |
| 74 | + chainId: mainnet.id, |
| 75 | + abi: abi.bayc, |
| 76 | + bytecode: bytecode.bayc, |
| 77 | + args: ['Bored Ape Wagmi Club', 'BAYC', 69420n, 0n], |
| 78 | + // @ts-expect-error |
| 79 | + feeCurrency: '0x', |
| 80 | + gatewayFee: 100n, |
| 81 | + gatewayFeeRecipient: '0x', |
| 82 | + }) |
| 83 | +}) |
0 commit comments