Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: added USDC gasless transfer e2e test #369

Merged
merged 3 commits into from
Jan 28, 2025
Merged
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

### Added
- Add E2E test for gasless transfers `Wallet.createTransfer({..., gasless: true})`

### Fixed
- Fixed a bug where non-checksummed asset IDs were throwing an error.

Expand Down
41 changes: 41 additions & 0 deletions src/tests/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,47 @@ describe("Coinbase SDK E2E Test", () => {
networkId: exportedWallet.networkId,
});
}, 60000);

it("should be able to make gasless transfers", async () => {
// Import wallet with balance
const seedFile = JSON.parse(process.env.WALLET_DATA || "");
const walletId = Object.keys(seedFile)[0];
const seed = seedFile[walletId].seed;

const sourceWallet = await Wallet.import({
seed,
walletId,
networkId: Coinbase.networks.BaseSepolia,
});

// Create destination wallet
const destinationWallet = await Wallet.create();

// Initialize transfer amount
const transferAmount = 0.000001;

console.log(`Making gasless transfer of ${transferAmount} USDC...`);
const transfer = await sourceWallet.createTransfer({
amount: transferAmount,
assetId: Coinbase.assets.Usdc,
destination: destinationWallet,
gasless: true,
});

await transfer.wait();

expect(transfer.toString()).toBeDefined();
expect(await transfer.getStatus()).toBe(TransferStatus.COMPLETE);
console.log(`Completed gasless transfer from ${sourceWallet} to ${destinationWallet}`);

// Verify balances
const sourceBalance = await sourceWallet.listBalances();
const destBalance = await destinationWallet.listBalances();
expect(sourceBalance.get(Coinbase.assets.Usdc)).not.toEqual("0");
expect(destBalance.get(Coinbase.assets.Usdc)?.toString()).toEqual(`${transferAmount}`);
console.log(`Source balance: ${sourceBalance}`);
console.log(`Destination balance: ${destBalance}`);
}, 200000);
});

describe("Coinbase SDK Stake E2E Test", () => {
Expand Down
Loading