diff --git a/src/coinbase/address/external_address.ts b/src/coinbase/address/external_address.ts index b7e5e2ec..87f4e980 100644 --- a/src/coinbase/address/external_address.ts +++ b/src/coinbase/address/external_address.ts @@ -3,7 +3,7 @@ import { Amount, StakeOptionsMode } from "../types"; import { Coinbase } from "../coinbase"; import Decimal from "decimal.js"; import { Asset } from "../asset"; -import { StakingOperation } from "../staking_operation"; +import { IStakingOperation, StakingOperation } from "../staking_operation"; export interface IExternalAddress extends IAddress { buildStakeOperation( @@ -11,19 +11,19 @@ export interface IExternalAddress extends IAddress { assetId: string, mode: StakeOptionsMode, options: { [key: string]: string }, - ): Promise; + ): Promise; buildUnstakeOperation( amount: Amount, assetId: string, mode: StakeOptionsMode, options: { [key: string]: string }, - ): Promise; + ): Promise; buildClaimStakeOperation( amount: Amount, assetId: string, mode: StakeOptionsMode, options: { [key: string]: string }, - ): Promise; + ): Promise; } /** diff --git a/src/coinbase/address/wallet_address.ts b/src/coinbase/address/wallet_address.ts index 18bb1303..d9e56989 100644 --- a/src/coinbase/address/wallet_address.ts +++ b/src/coinbase/address/wallet_address.ts @@ -5,9 +5,9 @@ import { Address, IAddress } from "../address"; import { Asset } from "../asset"; import { Coinbase } from "../coinbase"; import { ArgumentError } from "../errors"; -import { Trade } from "../trade"; +import { ITrade, Trade } from "../trade"; import { ITransfer, Transfer } from "../transfer"; -import { ContractInvocation } from "../contract_invocation"; +import { ContractInvocation, IContractInvocation } from "../contract_invocation"; import { Amount, CreateTransferOptions, @@ -21,23 +21,23 @@ import { } from "../types"; import { delay } from "../utils"; import { Wallet as WalletClass } from "../wallet"; -import { StakingOperation } from "../staking_operation"; -import { PayloadSignature } from "../payload_signature"; -import { SmartContract } from "../smart_contract"; +import { IStakingOperation, StakingOperation } from "../staking_operation"; +import { IPayloadSignature, PayloadSignature } from "../payload_signature"; +import { ISmartContract, SmartContract } from "../smart_contract"; export interface IWalletAddress extends IAddress { getWalletId(): string; setKey(key: ethers.Wallet): void; export(): string; canSign(): boolean; - listTrades(): Promise; + listTrades(): Promise; listTransfers(): Promise; createTransfer(options: CreateTransferOptions): Promise; - createTrade(options: CreateTradeOptions): Promise; - invokeContract(options: CreateContractInvocationOptions): Promise; - deployToken(options: CreateERC20Options): Promise; - deployNFT(options: CreateERC721Options): Promise; - deployMultiToken(options: CreateERC1155Options): Promise; + createTrade(options: CreateTradeOptions): Promise; + invokeContract(options: CreateContractInvocationOptions): Promise; + deployToken(options: CreateERC20Options): Promise; + deployNFT(options: CreateERC721Options): Promise; + deployMultiToken(options: CreateERC1155Options): Promise; createStake( amount: Amount, assetId: string, @@ -45,7 +45,7 @@ export interface IWalletAddress extends IAddress { options: { [key: string]: string }, timeoutSeconds: number, intervalSeconds: number, - ): Promise; + ): Promise; createUnstake( amount: Amount, assetId: string, @@ -53,7 +53,7 @@ export interface IWalletAddress extends IAddress { options: { [key: string]: string }, timeoutSeconds: number, intervalSeconds: number, - ): Promise; + ): Promise; createClaimStake( amount: Amount, assetId: string, @@ -61,10 +61,10 @@ export interface IWalletAddress extends IAddress { options: { [key: string]: string }, timeoutSeconds: number, intervalSeconds: number, - ): Promise; - createPayloadSignature(payload: string): Promise; - getPayloadSignature(signatureId: string): Promise; - listPayloadSignatures(): Promise; + ): Promise; + createPayloadSignature(payload: string): Promise; + getPayloadSignature(signatureId: string): Promise; + listPayloadSignatures(): Promise; } /** diff --git a/src/coinbase/contract_invocation.ts b/src/coinbase/contract_invocation.ts index 8d8eb838..d7d28df7 100644 --- a/src/coinbase/contract_invocation.ts +++ b/src/coinbase/contract_invocation.ts @@ -1,6 +1,6 @@ import { Decimal } from "decimal.js"; import { TransactionStatus } from "./types"; -import { Transaction } from "./transaction"; +import { ITransaction, Transaction } from "./transaction"; import { Coinbase } from "./coinbase"; import { ContractInvocation as ContractInvocationModel } from "../client/api"; import { ethers } from "ethers"; @@ -21,9 +21,9 @@ export interface IContractInvocation { getRawTransaction(): ethers.Transaction; sign(key: ethers.Wallet): Promise; getStatus(): TransactionStatus | undefined; - getTransaction(): Transaction; + getTransaction(): ITransaction; getTransactionLink(): string; - broadcast(): Promise; + broadcast(): Promise; wait({ intervalSeconds, timeoutSeconds, diff --git a/src/coinbase/staking_operation.ts b/src/coinbase/staking_operation.ts index d3da20bf..1651394a 100644 --- a/src/coinbase/staking_operation.ts +++ b/src/coinbase/staking_operation.ts @@ -16,6 +16,17 @@ export interface IStakingOperation { isTerminalState(): boolean; isFailedState(): boolean; isCompleteState(): boolean; + getTransactions(): Transaction[]; + getSignedVoluntaryExitMessages(): string[]; + reload(): Promise; + wait({ + intervalSeconds, + timeoutSeconds, + }: { + intervalSeconds: number; + timeoutSeconds: number; + }): Promise; + sign(key: ethers.Wallet): Promise; } /** diff --git a/src/coinbase/wallet.ts b/src/coinbase/wallet.ts index b76e416e..a9370dc5 100644 --- a/src/coinbase/wallet.ts +++ b/src/coinbase/wallet.ts @@ -5,15 +5,15 @@ import { ethers } from "ethers"; import * as fs from "fs"; import * as secp256k1 from "secp256k1"; import { Address as AddressModel, Wallet as WalletModel } from "../client"; -import { Address } from "./address"; +import { Address, IAddress } from "./address"; import { IWalletAddress, WalletAddress } from "./address/wallet_address"; import { Asset } from "./asset"; import { Balance } from "./balance"; import { BalanceMap } from "./balance_map"; import { Coinbase } from "./coinbase"; import { ArgumentError } from "./errors"; -import { FaucetTransaction } from "./faucet_transaction"; -import { Trade } from "./trade"; +import { FaucetTransaction, IFaucetTransaction } from "./faucet_transaction"; +import { ITrade, Trade } from "./trade"; import { ITransfer } from "./transfer"; import { Amount, @@ -33,21 +33,22 @@ import { CreateERC1155Options, } from "./types"; import { convertStringToHex, delay, formatDate, getWeekBackDate } from "./utils"; -import { StakingOperation } from "./staking_operation"; +import { IStakingOperation, StakingOperation } from "./staking_operation"; import { StakingReward } from "./staking_reward"; import { StakingBalance } from "./staking_balance"; -import { PayloadSignature } from "./payload_signature"; -import { ContractInvocation } from "../coinbase/contract_invocation"; -import { SmartContract } from "./smart_contract"; -import { Webhook } from "./webhook"; +import { IPayloadSignature, PayloadSignature } from "./payload_signature"; +import { ContractInvocation, IContractInvocation } from "../coinbase/contract_invocation"; +import { ISmartContract, SmartContract } from "./smart_contract"; +import { IWebhook, Webhook } from "./webhook"; export interface IWallet { getId(): string; getDefaultAddress(): Promise; listAddresses(): Promise; getAddress(addressId: string): Promise; - createAddress(): Promise
; - createTrade(options: CreateTradeOptions): Promise; + createAddress(): Promise; + setSeed(seed: string): void; + createTrade(options: CreateTradeOptions): Promise; stakeableBalance( asset_id: string, mode?: StakeOptionsMode, @@ -84,7 +85,7 @@ export interface IWallet { saveSeed(filePath: string, encrypt?: boolean): string; loadSeed(filePath: string): Promise; canSign(): boolean; - faucet(assetId?: string): Promise; + faucet(assetId?: string): Promise; createTransfer(options: CreateTransferOptions): Promise; createStake( amount: Amount, @@ -93,7 +94,7 @@ export interface IWallet { options?: { [key: string]: string }, timeoutSeconds?: number, intervalSeconds?: number, - ): Promise; + ): Promise; createUnstake( amount: Amount, assetId: string, @@ -101,7 +102,7 @@ export interface IWallet { options?: { [key: string]: string }, timeoutSeconds?: number, intervalSeconds?: number, - ): Promise; + ): Promise; createClaimStake( amount: Amount, assetId: string, @@ -109,14 +110,14 @@ export interface IWallet { options?: { [key: string]: string }, timeoutSeconds?: number, intervalSeconds?: number, - ): Promise; - invokeContract(options: CreateContractInvocationOptions): Promise; + ): Promise; + invokeContract(options: CreateContractInvocationOptions): Promise; export(): WalletData; - createWebhook(notificationUri: string): Promise; - deployToken(options: CreateERC20Options): Promise; - deployNFT(options: CreateERC721Options): Promise; - deployMultiToken(options: CreateERC1155Options): Promise; - createPayloadSignature(unsignedPayload: string): Promise; + createWebhook(notificationUri: string): Promise; + deployToken(options: CreateERC20Options): Promise; + deployNFT(options: CreateERC721Options): Promise; + deployMultiToken(options: CreateERC1155Options): Promise; + createPayloadSignature(unsignedPayload: string): Promise; } /** @@ -293,7 +294,7 @@ export class Wallet implements IWallet { * @returns The new Address. * @throws {APIError} - If the address creation fails. */ - public async createAddress(): Promise
{ + public async createAddress(): Promise { let payload, key; if (!Coinbase.useServerSigner) { // TODO: Coordinate this value with concurrent calls to createAddress. @@ -395,7 +396,7 @@ export class Wallet implements IWallet { * @throws {Error} If the private key is not loaded, or if the asset IDs are unsupported, or if there are insufficient funds. * @returns The created Trade object. */ - public async createTrade(options: CreateTradeOptions): Promise { + public async createTrade(options: CreateTradeOptions): Promise { return (await this.getDefaultAddress()).createTrade(options); } @@ -526,7 +527,7 @@ export class Wallet implements IWallet { options: { [key: string]: string } = {}, timeoutSeconds = 60, intervalSeconds = 0.2, - ): Promise { + ): Promise { return (await this.getDefaultAddress()).createStake( amount, assetId, @@ -556,7 +557,7 @@ export class Wallet implements IWallet { options: { [key: string]: string } = {}, timeoutSeconds = 60, intervalSeconds = 0.2, - ): Promise { + ): Promise { return (await this.getDefaultAddress()).createUnstake( amount, assetId, @@ -586,7 +587,7 @@ export class Wallet implements IWallet { options: { [key: string]: string } = {}, timeoutSeconds = 60, intervalSeconds = 0.2, - ): Promise { + ): Promise { return (await this.getDefaultAddress()).createClaimStake( amount, assetId, @@ -825,7 +826,7 @@ export class Wallet implements IWallet { * @throws {APIError} if the API request to create a Payload Signature fails. * @throws {Error} if the default address is not found. */ - public async createPayloadSignature(unsignedPayload: string): Promise { + public async createPayloadSignature(unsignedPayload: string): Promise { return (await this.getDefaultAddress()).createPayloadSignature(unsignedPayload); } @@ -836,7 +837,7 @@ export class Wallet implements IWallet { * * @returns The newly created webhook instance. */ - public async createWebhook(notificationUri: string): Promise { + public async createWebhook(notificationUri: string): Promise { const result = await Coinbase.apiClients.webhook!.createWalletWebhook(this.getId(), { notification_uri: notificationUri, }); @@ -861,7 +862,7 @@ export class Wallet implements IWallet { */ public async invokeContract( options: CreateContractInvocationOptions, - ): Promise { + ): Promise { return (await this.getDefaultAddress()).invokeContract(options); } @@ -875,7 +876,7 @@ export class Wallet implements IWallet { * @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 deployToken(options: CreateERC20Options): Promise { + public async deployToken(options: CreateERC20Options): Promise { return (await this.getDefaultAddress()).deployToken(options); } @@ -889,7 +890,7 @@ export class Wallet implements IWallet { * @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 deployNFT(options: CreateERC721Options): Promise { + public async deployNFT(options: CreateERC721Options): Promise { return (await this.getDefaultAddress()).deployNFT(options); } @@ -903,7 +904,7 @@ export class Wallet implements IWallet { * @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 deployMultiToken(options: CreateERC1155Options): Promise { + public async deployMultiToken(options: CreateERC1155Options): Promise { return (await this.getDefaultAddress()).deployMultiToken(options); } diff --git a/src/coinbase/webhook.ts b/src/coinbase/webhook.ts index 331563fe..8a7bc54b 100644 --- a/src/coinbase/webhook.ts +++ b/src/coinbase/webhook.ts @@ -21,7 +21,7 @@ export interface IWebhook { /** * A representation of a Webhook, * which provides methods to create, list, update, and delete webhooks that are used to receive notifications of specific events. - */ + */ export class Webhook implements IWebhook { private model: WebhookModel | null;