Skip to content

Commit a3651cb

Browse files
committed
fix: tiny fix
1 parent ba338af commit a3651cb

File tree

3 files changed

+24
-24
lines changed

3 files changed

+24
-24
lines changed

tests/paymaster.spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {describe, expect, test} from '@jest/globals'
22
import {
3-
paymasterProvider,
3+
paymasterClient,
44
wallet,
55
tokenAbi,
66
transformIsSponsorableResponse,
@@ -22,7 +22,7 @@ describe('paymasterQuery', () => {
2222
*/
2323
describe('chainID', () => {
2424
test('chainID should return the expected value', async () => {
25-
const res = await paymasterProvider.chainID()
25+
const res = await paymasterClient.chainID()
2626
expect(res).toEqual('0x61')
2727
})
2828
})
@@ -34,7 +34,7 @@ describe('paymasterQuery', () => {
3434
test('should successfully determine if transaction is sponsorable', async () => {
3535
const tokenContract = new ethers.Contract(TOKEN_CONTRACT_ADDRESS, tokenAbi, wallet)
3636
const tokenAmount = ethers.parseUnits('0', 18)
37-
const nonce = await paymasterProvider.getTransactionCount(wallet.address, 'pending')
37+
const nonce = await paymasterClient.getTransactionCount(wallet.address, 'pending')
3838

3939
const transaction = await tokenContract.transfer.populateTransaction(RECIPIENT_ADDRESS.toLowerCase(), tokenAmount)
4040
transaction.from = wallet.address
@@ -51,13 +51,13 @@ describe('paymasterQuery', () => {
5151
}
5252

5353
console.log('Prepared transaction:', safeTransaction)
54-
const resRaw = await paymasterProvider.isSponsorable(safeTransaction)
54+
const resRaw = await paymasterClient.isSponsorable(safeTransaction)
5555
const res = transformIsSponsorableResponse(resRaw)
5656
expect(res.Sponsorable).toEqual(true)
5757

5858
const signedTx = await wallet.signTransaction(safeTransaction)
5959
try {
60-
const tx = await paymasterProvider.sendRawTransaction(signedTx)
60+
const tx = await paymasterClient.sendRawTransaction(signedTx)
6161
TX_HASH = tx
6262
console.log('Transaction hash received:', TX_HASH)
6363
} catch (error) {
@@ -74,23 +74,23 @@ describe('paymasterQuery', () => {
7474
console.log('Waiting for transaction confirmation...')
7575
await delay(8000)
7676
console.log('Querying gasless transaction by hash:', TX_HASH)
77-
const resRaw = await paymasterProvider.getGaslessTransactionByHash(TX_HASH)
77+
const resRaw = await paymasterClient.getGaslessTransactionByHash(TX_HASH)
7878
const res = transformToGaslessTransaction(resRaw)
7979
expect(res.ToAddress).toEqual(TOKEN_CONTRACT_ADDRESS.toLowerCase())
8080
console.log('Querying gasless transaction', res)
8181

8282
console.log('Retrieving sponsor transaction by bundle UUID:', res.BundleUUID)
83-
const txRaw = await paymasterProvider.getSponsorTxByBundleUuid(res.BundleUUID)
83+
const txRaw = await paymasterClient.getSponsorTxByBundleUuid(res.BundleUUID)
8484
const tx = transformSponsorTxResponse(txRaw)
8585
expect(txRaw).not.toBeNull()
8686
console.log('Sponsor transaction details:', tx)
8787

88-
const bundleRaw = await paymasterProvider.getBundleByUuid(res.BundleUUID)
88+
const bundleRaw = await paymasterClient.getBundleByUuid(res.BundleUUID)
8989
const bundle = transformBundleResponse(bundleRaw)
9090
expect(bundle.BundleUUID).toEqual(res.BundleUUID)
9191
console.log('Bundle details:', bundle)
9292

93-
const sponsorTxRaw = await paymasterProvider.getSponsorTxByTxHash(tx.TxHash)
93+
const sponsorTxRaw = await paymasterClient.getSponsorTxByTxHash(tx.TxHash)
9494
const sponsorTx = transformSponsorTxResponse(sponsorTxRaw)
9595
console.log('Sponsor transaction:', sponsorTx)
9696
expect(sponsorTx.TxHash).toEqual(tx.TxHash)

tests/sponsor.spec.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {describe, expect, test} from '@jest/globals'
2-
import {client} from './utils'
2+
import {sponsorClient} from './utils'
33
import {WhitelistType} from '../src'
44
import {POLICY_UUID, ACCOUNT_ADDRESS, CONTRACT_METHOD} from './env'
55

@@ -12,7 +12,7 @@ describe('sponsorQuery', () => {
1212
*/
1313
describe('addToWhitelist FromAccountWhitelist', () => {
1414
test('should add an account address to FromAccountWhitelist successfully', async () => {
15-
const res = await client.addToWhitelist({
15+
const res = await sponsorClient.addToWhitelist({
1616
PolicyUUID: POLICY_UUID,
1717
WhitelistType: WhitelistType.FromAccountWhitelist,
1818
Values: [ACCOUNT_ADDRESS],
@@ -28,7 +28,7 @@ describe('sponsorQuery', () => {
2828
*/
2929
describe('addToWhitelist ToAccountWhitelist', () => {
3030
test('should add an account address to ToAccountWhitelist successfully', async () => {
31-
const res = await client.addToWhitelist({
31+
const res = await sponsorClient.addToWhitelist({
3232
PolicyUUID: POLICY_UUID,
3333
WhitelistType: WhitelistType.ToAccountWhitelist,
3434
Values: [ACCOUNT_ADDRESS],
@@ -44,7 +44,7 @@ describe('sponsorQuery', () => {
4444
*/
4545
describe('addToWhitelist BEP20ReceiverWhiteList', () => {
4646
test('should add an account address to BEP20ReceiverWhiteList successfully', async () => {
47-
const res = await client.addToWhitelist({
47+
const res = await sponsorClient.addToWhitelist({
4848
PolicyUUID: POLICY_UUID,
4949
WhitelistType: WhitelistType.BEP20ReceiverWhiteList,
5050
Values: [ACCOUNT_ADDRESS],
@@ -60,7 +60,7 @@ describe('sponsorQuery', () => {
6060
*/
6161
describe('addToWhitelist ContractMethodSigWhitelist', () => {
6262
test('should add a contract method signature to ContractMethodSigWhitelist successfully', async () => {
63-
const res = await client.addToWhitelist({
63+
const res = await sponsorClient.addToWhitelist({
6464
PolicyUUID: POLICY_UUID,
6565
WhitelistType: WhitelistType.ContractMethodSigWhitelist,
6666
Values: [CONTRACT_METHOD],
@@ -76,7 +76,7 @@ describe('sponsorQuery', () => {
7676
*/
7777
describe('getWhitelist', () => {
7878
test('should retrieve contract method signatures successfully', async () => {
79-
const res = await client.getWhitelist({
79+
const res = await sponsorClient.getWhitelist({
8080
PolicyUUID: POLICY_UUID,
8181
WhitelistType: WhitelistType.ContractMethodSigWhitelist,
8282
Offset: 0,
@@ -93,7 +93,7 @@ describe('sponsorQuery', () => {
9393
*/
9494
describe('removeFromWhitelist', () => {
9595
test('should remove an account address from FromAccountWhitelist successfully', async () => {
96-
const res = await client.removeFromWhitelist({
96+
const res = await sponsorClient.removeFromWhitelist({
9797
PolicyUUID: POLICY_UUID,
9898
WhitelistType: WhitelistType.FromAccountWhitelist,
9999
Values: [ACCOUNT_ADDRESS],
@@ -109,7 +109,7 @@ describe('sponsorQuery', () => {
109109
*/
110110
describe('getWhitelist', () => {
111111
test('should not contain account address post-removal', async () => {
112-
const res = await client.getWhitelist({
112+
const res = await sponsorClient.getWhitelist({
113113
PolicyUUID: POLICY_UUID,
114114
WhitelistType: WhitelistType.FromAccountWhitelist,
115115
Offset: 0,
@@ -127,7 +127,7 @@ describe('sponsorQuery', () => {
127127
*/
128128
describe('emptyWhitelist', () => {
129129
test('should clear all entries from BEP20ReceiverWhiteList successfully', async () => {
130-
const res = await client.emptyWhitelist({
130+
const res = await sponsorClient.emptyWhitelist({
131131
PolicyUUID: POLICY_UUID,
132132
WhitelistType: WhitelistType.BEP20ReceiverWhiteList,
133133
})
@@ -142,7 +142,7 @@ describe('sponsorQuery', () => {
142142
*/
143143
describe('getWhitelist', () => {
144144
test('should confirm the whitelist is empty', async () => {
145-
const res = await client.getWhitelist({
145+
const res = await sponsorClient.getWhitelist({
146146
PolicyUUID: POLICY_UUID,
147147
WhitelistType: WhitelistType.BEP20ReceiverWhiteList,
148148
Offset: 0,
@@ -159,7 +159,7 @@ describe('sponsorQuery', () => {
159159
*/
160160
describe('getUserSpendData', () => {
161161
test('should return null for spend data when user has none', async () => {
162-
const res = await client.getUserSpendData(ACCOUNT_ADDRESS, POLICY_UUID)
162+
const res = await sponsorClient.getUserSpendData(ACCOUNT_ADDRESS, POLICY_UUID)
163163

164164
expect(res).toBeNull()
165165
console.log('User spend data:', res)
@@ -171,7 +171,7 @@ describe('sponsorQuery', () => {
171171
*/
172172
describe('getPolicySpendData', () => {
173173
test('should retrieve policy spend data successfully', async () => {
174-
const res = await client.getPolicySpendData(POLICY_UUID)
174+
const res = await sponsorClient.getPolicySpendData(POLICY_UUID)
175175
expect(res.ChainID).not.toBeNull()
176176
console.log('Policy spend data:', res)
177177
})
@@ -182,7 +182,7 @@ describe('sponsorQuery', () => {
182182
*/
183183
describe('addToWhitelist FromAccountWhitelist', () => {
184184
test('should re-add an account address to FromAccountWhitelist successfully after removal', async () => {
185-
const res = await client.addToWhitelist({
185+
const res = await sponsorClient.addToWhitelist({
186186
PolicyUUID: POLICY_UUID,
187187
WhitelistType: WhitelistType.FromAccountWhitelist,
188188
Values: [ACCOUNT_ADDRESS],

tests/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import {
1010
import {CHAIN_ID, SPONSOR_URL, CHAIN_URL, PAYMASTER_URL, PRIVATE_KEY, TOKEN_CONTRACT_ADDRESS} from './env'
1111
import {ethers} from 'ethers'
1212

13-
export const client = new SponsorClient(SPONSOR_URL, undefined, {staticNetwork: ethers.Network.from(Number(CHAIN_ID))})
13+
export const sponsorClient = new SponsorClient(SPONSOR_URL, undefined, {staticNetwork: ethers.Network.from(Number(CHAIN_ID))})
1414

1515
// Provider for assembling the transaction (e.g., testnet)
1616
export const assemblyProvider = new ethers.JsonRpcProvider(CHAIN_URL)
1717

1818
// Provider for sending the transaction (e.g., could be a different network or provider)
19-
export const paymasterProvider = new PaymasterClient(PAYMASTER_URL)
19+
export const paymasterClient = new PaymasterClient(PAYMASTER_URL)
2020

2121
export const wallet = new ethers.Wallet(PRIVATE_KEY, assemblyProvider)
2222
// ERC20 token ABI (only including the transfer function)

0 commit comments

Comments
 (0)