-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(PSDK-782): allow users to send sponsored transactions immediately (
#357)
- Loading branch information
Showing
8 changed files
with
523 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { Wallet } from "../coinbase/wallet"; | ||
import { WalletAddress } from "../coinbase/address/wallet_address"; | ||
import { newAddressModel } from "./utils"; | ||
import { Coinbase, Transfer } from ".."; | ||
import { FeatureSet, Wallet as WalletModel } from "../client/api"; | ||
|
||
describe("Wallet Transfer", () => { | ||
let wallet: Wallet; | ||
let walletModel: WalletModel; | ||
let defaultAddress: WalletAddress; | ||
const walletId = "test-wallet-id"; | ||
const addressId = "0x123abc..."; | ||
|
||
beforeEach(() => { | ||
const addressModel = newAddressModel(walletId, addressId); | ||
defaultAddress = new WalletAddress(addressModel); | ||
|
||
walletModel = { | ||
id: walletId, | ||
network_id: Coinbase.networks.BaseSepolia, | ||
default_address: addressModel, | ||
feature_set: {} as FeatureSet, | ||
}; | ||
|
||
wallet = Wallet.init(walletModel, ""); | ||
|
||
// Mock getDefaultAddress to return our test address | ||
jest.spyOn(wallet, "getDefaultAddress").mockResolvedValue(defaultAddress); | ||
|
||
// Mock the createTransfer method on the default address | ||
jest.spyOn(defaultAddress, "createTransfer").mockResolvedValue({} as Transfer); | ||
}); | ||
|
||
afterEach(() => { | ||
jest.restoreAllMocks(); | ||
}); | ||
|
||
describe("#createTransfer", () => { | ||
it("should pass through skipBatching to defaultAddress.createTransfer", async () => { | ||
const assetId = "eth"; | ||
|
||
await wallet.createTransfer({ | ||
amount: 1, | ||
assetId, | ||
destination: "0x123abc...", | ||
gasless: true, | ||
skipBatching: true, | ||
}); | ||
|
||
expect(defaultAddress.createTransfer).toHaveBeenCalledWith({ | ||
amount: 1, | ||
assetId, | ||
destination: "0x123abc...", | ||
gasless: true, | ||
skipBatching: true, | ||
}); | ||
|
||
await wallet.createTransfer({ | ||
amount: 1, | ||
assetId, | ||
destination: "0x123abc...", | ||
gasless: true, | ||
skipBatching: false, | ||
}); | ||
|
||
expect(defaultAddress.createTransfer).toHaveBeenCalledWith({ | ||
amount: 1, | ||
assetId, | ||
destination: "0x123abc...", | ||
gasless: true, | ||
skipBatching: false, | ||
}); | ||
}); | ||
}); | ||
}); |