Skip to content

Commit

Permalink
fix(types): rename signer to ContractSigner
Browse files Browse the repository at this point in the history
  • Loading branch information
Atticus committed Mar 22, 2024
1 parent 2c02e90 commit 87d6c90
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ export type SortKey = string;
export type WalletAddress = string;

// TODO: append this with other configuration options (e.g. local vs. remote evaluation)
export type ArIOSigner = ArweaveSigner | ArconnectSigner;
export type ContractSigner = ArweaveSigner | ArconnectSigner;
export type ContractConfiguration = {
signer?: ArIOSigner; // TODO: optionally allow JWK in place of signer
signer?: ContractSigner; // TODO: optionally allow JWK in place of signer
} & (
| {
contract?: ContractInteractionProvider<unknown>;
Expand Down Expand Up @@ -72,7 +72,7 @@ export type EvaluationParameters<T = NonNullable<unknown>> = {

export interface BaseContract<T> {
getState(params: EvaluationParameters): Promise<T>;
connect(signer: ArIOSigner): this;
connect(signer: ContractSigner): this;
}

export interface ReadContract {
Expand Down
6 changes: 3 additions & 3 deletions src/common/ant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import {
ANTContract,
ANTRecord,
ANTState,
ArIOSigner,
BaseContract,
ContractConfiguration,
ContractInteractionProvider,
ContractSigner,
EvaluationOptions,
EvaluationParameters,
isContractConfiguration,
Expand All @@ -34,7 +34,7 @@ export class ANT implements ANTContract, BaseContract<ANTState> {
private contract: ContractInteractionProvider<ANTState>;
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
private signer: ArIOSigner | undefined;
private signer: ContractSigner | undefined;

constructor({ signer, ...config }: ContractConfiguration) {
this.signer = signer;
Expand All @@ -47,7 +47,7 @@ export class ANT implements ANTContract, BaseContract<ANTState> {
}
}

connect(signer: ArIOSigner): this {
connect(signer: ContractSigner): this {
this.signer = signer;
if (this.contract instanceof RemoteContract) {
this.contract = new WarpContract<ANTState>({
Expand Down
6 changes: 3 additions & 3 deletions src/common/ar-io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
import { ARNS_TESTNET_REGISTRY_TX } from '../constants.js';
import {
ArIOContract,
ArIOSigner,
ArIOState,
ArNSAuctionData,
ArNSNameData,
BaseContract,
ContractConfiguration,
ContractInteractionProvider,
ContractSigner,
EpochDistributionData,
EvaluationOptions,
EvaluationParameters,
Expand All @@ -41,7 +41,7 @@ export class ArIO implements ArIOContract, BaseContract<ArIOState> {
private contract: ContractInteractionProvider<ArIOState>;
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
private signer: ArIOSigner | undefined;
private signer: ContractSigner | undefined;

constructor(
{ signer, ...config }: ContractConfiguration = {
Expand All @@ -63,7 +63,7 @@ export class ArIO implements ArIOContract, BaseContract<ArIOState> {
}
}

connect(signer: ArIOSigner): this {
connect(signer: ContractSigner): this {
this.signer = signer;
if (this.contract instanceof RemoteContract) {
this.contract = new WarpContract<ArIOState>({
Expand Down
4 changes: 2 additions & 2 deletions src/common/contracts/remote-contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import {
ArIOSigner,
BaseContract,
ContractSigner,
EvaluationParameters,
HTTPClient,
Logger,
Expand Down Expand Up @@ -49,7 +49,7 @@ export class RemoteContract<T> implements BaseContract<T>, ReadContract {

/* eslint-disable */
// @ts-ignore
connect(signer: ArIOSigner): this {
connect(signer: ContractSigner): this {
/* eslint-enable */
throw new Error('Cannot connect to a remote contract');
}
Expand Down
6 changes: 3 additions & 3 deletions src/common/contracts/warp-contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import {
} from 'warp-contracts';

import {
ArIOSigner,
BaseContract,
ContractSigner,
EvaluationParameters,
ReadContract,
} from '../../types.js';
Expand All @@ -51,15 +51,15 @@ export class WarpContract<T> implements BaseContract<T>, ReadContract {
contractTxId: string;
cacheUrl?: string;
warp?: Warp;
signer?: ArIOSigner;
signer?: ContractSigner;
}) {
this.contract = warp.contract<T>(contractTxId);
this.cacheUrl = cacheUrl;
}

// base contract methods

connect(signer: ArIOSigner) {
connect(signer: ContractSigner) {
this.contract = this.contract.connect(signer as Signer);
return this;
}
Expand Down

0 comments on commit 87d6c90

Please sign in to comment.