diff --git a/src/common.ts b/src/common.ts index 81d4fba6..7caa6d2b 100644 --- a/src/common.ts +++ b/src/common.ts @@ -14,6 +14,8 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ +import { ArconnectSigner, ArweaveSigner } from 'arbundles'; + import { ANTRecord, ANTState, @@ -32,13 +34,17 @@ export type SortKey = string; export type WalletAddress = string; // TODO: append this with other configuration options (e.g. local vs. remote evaluation) -export type ContractConfiguration = - | { +export type ArIOSigner = ArweaveSigner | ArconnectSigner; +export type ContractConfiguration = { + signer?: ArIOSigner; // TODO: optionally allow JWK in place of signer +} & ( + | { contract?: SmartWeaveContract; } - | { + | { contractTxId: string; - }; + } + ); export function isContractConfiguration( config: ContractConfiguration, diff --git a/src/common/ant.ts b/src/common/ant.ts index dd3f705e..d5de3259 100644 --- a/src/common/ant.ts +++ b/src/common/ant.ts @@ -29,8 +29,12 @@ import { RemoteContract } from './contracts/remote-contract.js'; export class ANT implements ANTContract { private contract: SmartWeaveContract; + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + private signer: ArIOSigner | undefined; - constructor(config: ContractConfiguration) { + constructor({ signer, ...config }: ContractConfiguration) { + this.signer = signer; if (isContractConfiguration(config)) { this.contract = config.contract; } else if (isContractTxIdConfiguration(config)) { diff --git a/src/common/ar-io.ts b/src/common/ar-io.ts index 0b783fbe..fa25e62f 100644 --- a/src/common/ar-io.ts +++ b/src/common/ar-io.ts @@ -14,8 +14,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -import { ArconnectSigner, ArweaveSigner } from 'arbundles'; - +import { ARNS_TESTNET_REGISTRY_TX } from '../constants.js'; import { ArIOContract, ArIOState, @@ -33,19 +32,6 @@ import { } from '../types.js'; import { RemoteContract } from './contracts/remote-contract.js'; -// TODO: append this with other configuration options (e.g. local vs. remote evaluation) -export type ArIOSigner = ArweaveSigner | ArconnectSigner; -export type ContractConfiguration = { - signer?: ArIOSigner; // TODO: optionally allow JWK in place of signer -} & ( - | { - contract?: SmartWeaveContract; - } - | { - contractTxId: string; - } -); - function isContractConfiguration( config: ContractConfiguration, ): config is { contract: SmartWeaveContract } { @@ -64,7 +50,13 @@ export class ArIO implements ArIOContract { // @ts-ignore private signer: ArIOSigner | undefined; - constructor({ signer, ...config }: ContractConfiguration) { + constructor( + { signer, ...config }: ContractConfiguration = { + contract: new RemoteContract({ + contractTxId: ARNS_TESTNET_REGISTRY_TX, + }), + }, + ) { this.signer = signer; if (isContractConfiguration(config)) { this.contract = config.contract;