Skip to content

Commit

Permalink
fix(readme): update quick start
Browse files Browse the repository at this point in the history
  • Loading branch information
atticusofsparta committed Feb 26, 2024
1 parent b595818 commit a60d96a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
24 changes: 7 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,7 @@ yarn add @ar-io/sdk
import { ArIO } from '@ar-io/sdk';

const arIO = new ArIO({});
const address = 'QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ';
const domain = 'ardrive';
const contractTxIds = [
'I-cxQhfh0Zb9UqQNizC9PiLC41KpUeA9hjiVV02rQRw',
'DGWp8_6c1YywKgCgBFhncMglciQyCdfX1swil4qjNSc',
];

const balance = await arIO.mainnet.getBalance({ address });
const gateway = await arIO.mainnet.getGateway({ address });
const record = await arIO.mainnet.getRecord({ domain: 'ar-io' });
const records = await arIO.mainnet.getRecords({});
const gateways = arIO.testnet.getGateways();
```

## Usage
Expand Down Expand Up @@ -98,7 +88,7 @@ Types are exported from `./lib/types/[node/web]/index.d.ts` and should be automa

The contract that the following methods retrieve data from are determined by the `testnet` or `devnet` clients - see examples above for implementation details.

#### [`getBalance({ address })`](#getbalance-address)
#### `getBalance({ address })`

Retrieves the balance of the specified address.

Expand All @@ -108,15 +98,15 @@ const balance = new ArIO({}).testnet.getBalance({
});
```

#### [`getBalances()`](#getbalances)
#### `getBalances()`

Retrieves the balances of the ArIO contract.

```typescript
const balances = new ArIO({}).testnet.getBalances();
```

#### [`getGateway({ address })`](#getgateway-address)
#### `getGateway({ address })`

Retrieves the gateway info of the specified address.

Expand All @@ -126,23 +116,23 @@ const gateway = new ArIO({}).testnet.getGateway({
});
```

#### [`getGateways()`](#getgateways)
#### `getGateways()`

Retrieves the registered gateways of the ArIO contract.

```typescript
const gateways = new ArIO({}).testnet.getGateways();
```

#### [`getRecord({ domain })`](#getrecord-domain)
#### `getRecord({ domain })`

Retrieves the domain info of the specified ArNS record.

```typescript
const record = new ArIO({}).testnet.getRecord({ domain: 'INSERT_ARNS_NAME' });
```

#### [`getRecords()`](#getrecords)
#### `getRecords()`

Retrieves the registered ArNS domains of the ArIO contract.

Expand Down
8 changes: 8 additions & 0 deletions src/common/caches/arns-remote-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ export class ArNSRemoteCache implements ArIOContract {
});
}

private validateContractTxId() {
if (this.contractTxId === undefined) {
throw new Error(
'Contract ID not set. Please set the contract ID before using this method.',
);
}
}

async getGateway({ address }: { address: string }) {
this.logger.debug(`Fetching gateway ${address}`);
const gateway = await this.getGateways().then((gateways) => {
Expand Down

0 comments on commit a60d96a

Please sign in to comment.