Skip to content

Commit

Permalink
Rename
Browse files Browse the repository at this point in the history
  • Loading branch information
rohan-agarwal-coinbase committed Sep 17, 2024
1 parent 36f892a commit 8979f46
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/coinbase/address/wallet_address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ export class WalletAddress extends Address {
* @returns A Promise that resolves to the deployed SmartContract object.
* @throws {Error} If the private key is not loaded when not using server signer.
*/
public async deployERC20(options: CreateERC20Options): Promise<SmartContract> {
public async deployToken(options: CreateERC20Options): Promise<SmartContract> {
if (!Coinbase.useServerSigner && !this.key) {
throw new Error("Cannot deploy ERC20 without private key loaded");
}
Expand Down
4 changes: 2 additions & 2 deletions src/coinbase/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -779,8 +779,8 @@ export class Wallet {
* @returns A Promise that resolves to the deployed SmartContract object.
* @throws {Error} If the private key is not loaded when not using server signer.
*/
public async deployERC20(options: CreateERC20Options): Promise<SmartContract> {
return (await this.getDefaultAddress()).deployERC20(options);
public async deployToken(options: CreateERC20Options): Promise<SmartContract> {
return (await this.getDefaultAddress()).deployToken(options);
}

/**
Expand Down
17 changes: 8 additions & 9 deletions src/tests/wallet_address_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1455,11 +1455,10 @@ describe("WalletAddress", () => {
});
});

describe("#deployERC20", () => {
describe("#deployToken", () => {
let key = ethers.Wallet.createRandom();
let addressModel: AddressModel;
let walletAddress: WalletAddress;
let unsignedPayload = VALID_SMART_CONTRACT_ERC20_MODEL.transaction.unsigned_payload;
let expectedSignedPayload: string;

beforeAll(() => {
Expand Down Expand Up @@ -1498,7 +1497,7 @@ describe("WalletAddress", () => {
wallet_id: walletAddress.getWalletId(),
});

smartContract = await walletAddress.deployERC20({
smartContract = await walletAddress.deployToken({
name: ERC20_NAME,
symbol: ERC20_SYMBOL,
totalSupply: ERC20_TOTAL_SUPPLY,
Expand Down Expand Up @@ -1560,7 +1559,7 @@ describe("WalletAddress", () => {
VALID_SMART_CONTRACT_ERC20_MODEL,
);

smartContract = await walletAddress.deployERC20({
smartContract = await walletAddress.deployToken({
name: ERC20_NAME,
symbol: ERC20_SYMBOL,
totalSupply: ERC20_TOTAL_SUPPLY,
Expand Down Expand Up @@ -1609,7 +1608,7 @@ describe("WalletAddress", () => {

it("throws an error", async () => {
await expect(
walletAddress.deployERC20({
walletAddress.deployToken({
name: ERC20_NAME,
symbol: ERC20_SYMBOL,
totalSupply: ERC20_TOTAL_SUPPLY,
Expand All @@ -1635,7 +1634,7 @@ describe("WalletAddress", () => {

it("throws an error", async () => {
await expect(
walletAddress.deployERC20({
walletAddress.deployToken({
name: ERC20_NAME,
symbol: ERC20_SYMBOL,
totalSupply: ERC20_TOTAL_SUPPLY,
Expand Down Expand Up @@ -1667,7 +1666,7 @@ describe("WalletAddress", () => {

it("throws an error", async () => {
await expect(
walletAddress.deployERC20({
walletAddress.deployToken({
name: ERC20_NAME,
symbol: ERC20_SYMBOL,
totalSupply: ERC20_TOTAL_SUPPLY,
Expand All @@ -1694,7 +1693,7 @@ describe("WalletAddress", () => {
wallet_id: walletAddress.getWalletId(),
});

smartContract = await walletAddress.deployERC20({
smartContract = await walletAddress.deployToken({
name: ERC20_NAME,
symbol: ERC20_SYMBOL,
totalSupply: ERC20_TOTAL_SUPPLY,
Expand Down Expand Up @@ -1741,7 +1740,7 @@ describe("WalletAddress", () => {

it("throws an error", async () => {
await expect(
walletAddress.deployERC20({
walletAddress.deployToken({
name: ERC20_NAME,
symbol: ERC20_SYMBOL,
totalSupply: ERC20_TOTAL_SUPPLY,
Expand Down
10 changes: 5 additions & 5 deletions src/tests/wallet_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ describe("Wallet Class", () => {
});
});

describe("#deployERC20", () => {
describe("#deployToken", () => {
let expectedSmartContract;
let options = {
name: ERC20_NAME,
Expand All @@ -599,16 +599,16 @@ describe("Wallet Class", () => {
beforeEach(async () => {
expectedSmartContract = SmartContract.fromModel(VALID_SMART_CONTRACT_ERC20_MODEL);

(await wallet.getDefaultAddress()).deployERC20 = jest
(await wallet.getDefaultAddress()).deployToken = jest
.fn()
.mockResolvedValue(expectedSmartContract);
});

it("successfully deploys an ERC20 contract on the default address", async () => {
const smartContract = await wallet.deployERC20(options);
const smartContract = await wallet.deployToken(options);

expect((await wallet.getDefaultAddress()).deployERC20).toHaveBeenCalledTimes(1);
expect((await wallet.getDefaultAddress()).deployERC20).toHaveBeenCalledWith(options);
expect((await wallet.getDefaultAddress()).deployToken).toHaveBeenCalledTimes(1);
expect((await wallet.getDefaultAddress()).deployToken).toHaveBeenCalledWith(options);

expect(smartContract).toBeInstanceOf(SmartContract);
expect(smartContract).toEqual(expectedSmartContract);
Expand Down

0 comments on commit 8979f46

Please sign in to comment.