Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/fee-payer/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ALLOWED_ORIGINS=*
TEMPO_RPC_CREDENTIALS=
# testnet | devnet
TEMPO_ENV=testnet
TEMPO_RPC_URL=https://rpc.testnet.tempo.xyz
TEMPO_RPC_URL=https://rpc.moderato.tempo.xyz
SPONSOR_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80

# for /usage endpoint
Expand Down
38 changes: 34 additions & 4 deletions apps/fee-payer/test/e2e.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { env, SELF } from 'cloudflare:test'
import { Mnemonic } from 'ox'
import { createClient, custom } from 'viem'
import { createClient, custom, http, parseUnits } from 'viem'
import { sendTransactionSync } from 'viem/actions'
import { tempoLocalnet } from 'viem/chains'
import { Account, withFeePayer } from 'viem/tempo'
import { describe, expect, it } from 'vitest'
import { Account, Actions, withFeePayer } from 'viem/tempo'
import { beforeAll, describe, expect, it } from 'vitest'

const testMnemonic =
'test test test test test test test test test test test junk'
Expand Down Expand Up @@ -74,6 +74,36 @@ function createTempoTransport() {
})
}

// Mint liquidity for fee tokens.
beforeAll(async () => {
const sponsorAccount = Account.fromSecp256k1(
Mnemonic.toPrivateKey(testMnemonic, {
as: 'Hex',
path: Mnemonic.path({ account: 0 }),
}),
)

const client = createClient({
account: sponsorAccount,
chain: tempoLocalnet,
transport: http(env.TEMPO_RPC_URL),
})

await Promise.all(
[1n, 2n, 3n].map((id) =>
Actions.amm.mintSync(client, {
account: sponsorAccount,
feeToken: '0x20c0000000000000000000000000000000000000',
nonceKey: 'expiring',
userTokenAddress: id,
validatorTokenAddress: '0x20c0000000000000000000000000000000000000',
validatorTokenAmount: parseUnits('1000', 6),
to: sponsorAccount.address,
}),
),
)
})

describe('fee-payer integration', () => {
describe('request handling', () => {
it('returns error for unsupported method', async () => {
Expand Down Expand Up @@ -161,7 +191,7 @@ describe('fee-payer integration', () => {

const receipt = await sendTransactionSync(client, {
feePayer: true,
to: '0x0000000000000000000000000000000000000000',
to: '0x0000000000000000000000000000000000000001',
value: 0n,
})

Expand Down
4 changes: 2 additions & 2 deletions apps/fee-payer/test/setup.global.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { createPublicClient, http } from 'viem'
import { tempoTestnet } from 'viem/chains'
import { tempoModerato } from 'viem/chains'
import { createServer, port } from './prool.js'

async function getCurrentTempoTestnetTag(): Promise<string> {
const client = createPublicClient({
chain: tempoTestnet,
chain: tempoModerato,
transport: http(),
})
const clientVersion = await client.request({ method: 'web3_clientVersion' })
Expand Down
Loading
Loading