diff --git a/.gitignore b/.gitignore index 65981cd9..a392b837 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ coverage .nyc_output dist .husky/_ +cache # IDEs and editors .vscode diff --git a/README.md b/README.md index 65288f44..e5367776 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ This is the home of [ar.io] SDK. This SDK provides functionality for interacting - [Typescript](#typescript) - [ArIO Contract](#ario-contract) - [APIs](#apis) + - [connect](#connectsigner) - [getBalance](#getbalance-address-evaluationoptions-) - [getBalances](#getbalances-evaluationoptions-) - [getGateway](#getgateway-address-evaluationoptions-) @@ -29,6 +30,7 @@ This is the home of [ar.io] SDK. This SDK provides functionality for interacting - [Custom Contracts](#custom-contracts) - [ANT Contracts](#arweave-name-tokens-ants) - [APIs](#apis-1) + - [connect](#connectsigner) - [getRecords](#getrecords-evaluationoptions-) - [getOwner](#getowner-evaluationoptions-) - [getControllers](#getcontrollers-evaluationoptions-) @@ -171,6 +173,23 @@ The SDK provides TypeScript types. When you import the SDK in a TypeScript proje ### APIs +#### `connect(signer)` + +Connects an `ArweaveSigner` or `ArConnectSigner` instance to the client for performing `writeInteraction` calls. +Supported only on clients configured with a `WarpContract` instance. + +NOTE: if you have a client configured with a `RemoteContract` instance, it will be overriden with a `WarpContract` instance using the existing configuration of the `RemoteContract` instance when `connect` is executed. + +```typescript +const arIO = new ArIO(); + +const browserSigner = new ArConnectSigner(window.arweaveWallet); +arIO.connect(browserSigner); + +const nodeSigner = new ArweaveSigner(JWK); +arIO.connect(nodeSigner); +``` + #### `getBalance({ address, evaluationOptions })` Retrieves the balance of the specified wallet address. @@ -581,6 +600,23 @@ The ANT contract client class exposes APIs relevant to compliant Arweave Name To ### APIs +#### `connect(signer)` + +Connects an `ArweaveSigner` or `ArConnectSigner` instance to the client for performing `writeInteraction` calls. +Supported only on clients configured with a `WarpContract` instance. + +NOTE: if you have a client configured with a `RemoteContract` instance, it will be overriden with a `WarpContract` instance using the existing configuration of the `RemoteContract` instance when `connect` is executed. + +```typescript +const ant = new ANT(); + +const browserSigner = new ArConnectSigner(window.arweaveWallet); +ant.connect(browserSigner); + +const nodeSigner = new ArweaveSigner(JWK); +ant.connect(nodeSigner); +``` + #### `getOwner({ evaluationOptions })` Returns the owner of the configured ANT contract. diff --git a/examples/node/index.cjs b/examples/node/index.cjs index 37177838..d9b2a298 100644 --- a/examples/node/index.cjs +++ b/examples/node/index.cjs @@ -1,10 +1,14 @@ +const Arweave = require('arweave'); const { ArIO, ARNS_TESTNET_REGISTRY_TX, } = require('../../lib/cjs/node/index.js'); +const { ArweaveSigner } = require('arbundles'); (async () => { - const arIO = new ArIO(); + const jwk = await Arweave.init({}).wallets.generate(); + const signer = new ArweaveSigner(jwk); + const arIO = new ArIO({ signer }); // testnet gateways const testnetGateways = await arIO.getGateways(); const protocolBalance = await arIO.getBalance({ diff --git a/examples/node/index.mjs b/examples/node/index.mjs index 49505151..9082191a 100644 --- a/examples/node/index.mjs +++ b/examples/node/index.mjs @@ -1,7 +1,12 @@ +import { ArweaveSigner } from 'arbundles'; +import Arweave from 'arweave'; + import { ARNS_TESTNET_REGISTRY_TX, ArIO } from '../../lib/esm/node/index.js'; (async () => { - const arIO = new ArIO(); + const jwk = await Arweave.init({}).wallets.generate(); + const signer = new ArweaveSigner(jwk); + const arIO = new ArIO({ signer }); // testnet gateways const testnetGateways = await arIO.getGateways(); const protocolBalance = await arIO.getBalance({ diff --git a/examples/web/index.html b/examples/web/index.html index da0c71b6..75cc779b 100644 --- a/examples/web/index.html +++ b/examples/web/index.html @@ -131,10 +131,14 @@

View Distribution Data