import { privateKeyToAccount } from 'viem/accounts' import * as TestFunding from '../../../test/Funding.js' import * as Viem from '../Viem.js' import * as Subsidy from './Subsidy.js' const privateKey = `0x${'11'.repeat(32)}` as const describe('supports', () => { test('accepts only corresponding USD routes within the deposit limit', () => { const route = TestFunding.transferSnapshot() expect({ aboveLimit: Subsidy.supports( { maxAmount: '1' }, { amount: '1000001', destinationToken: route.destinationToken, sourceToken: route.sourceToken, }, ), invalidLimit: Subsidy.supports( { maxAmount: 'invalid' }, { amount: '1000000', destinationToken: route.destinationToken, sourceToken: route.sourceToken, }, ), withinLimit: Subsidy.supports( { maxAmount: '1' }, { amount: '1000000', destinationToken: route.destinationToken, sourceToken: route.sourceToken, }, ), wrongCurrency: Subsidy.supports( { maxAmount: '1' }, { amount: '1000000', destinationToken: { ...route.destinationToken, currency: 'EUR' }, sourceToken: route.sourceToken, }, ), }).toMatchInlineSnapshot(` { "aboveLimit": false, "invalidLimit": false, "withinLimit": true, "wrongCurrency": false, } `) }) }) describe('create', () => { test('exposes the dedicated account and policy without network access', () => { const account = privateKeyToAccount(privateKey) const policy = { maxAmount: '10' } const settler = Subsidy.create({ account, getClient: Viem.createGetClient(), policy, }) expect({ account: settler.account, policy: settler.policy }).toMatchInlineSnapshot(` { "account": "0x19E7E376E7C213B7E7e7e46cc70A5dD086DAff2A", "policy": { "maxAmount": "10", }, } `) }) })