Skip to content

Commit

Permalink
fix(readme): update joinNetwork docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Atticus committed Apr 3, 2024
1 parent 13790c6 commit 9fcf440
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 14 deletions.
22 changes: 13 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -571,26 +571,30 @@ const auctions = await arIO.getAuctions({ evaluationOptions });

#### `joinNetwork({ ...JoinNetworkParams})`

Executes the interaction for the connected gateway wallet to join the ar.io network.
Joins a gateway to the ar.io network via its associated wallet.

```typescript
const params = {
const jointNetworkParams = {
/* initial operator stake */
qty: 4000,
/* delegated staking settings */
allowDelegatedStaking: true,
delegateRewardShareRatio: 1,
fqdn: 'impossible.com',
label: 'john smith',
minDelegatedStake: 100,
note: 'The impossible gateway',
delegateRewardShareRatio: 1,
autoStake: true,
/* gateway metadata info */
label: 'john smith', // min 1, max 64 characters
note: 'The example gateway', // max 256 characters
properties: 'FH1aVetOoulPGqgYukj0VE0wIhDy90WiQoV3U2PeY44', // Arweave transaction ID containing additional properties of the Gateway.
/* gateway info */
fqdn: 'example.com',
port: 443,
properties: 'FH1aVetOoulPGqgYukj0VE0wIhDy90WiQoV3U2PeY44',
protocol: 'https',
autoStake: true,
};
const signer = new ArweaveSigner(jwk);
// connection required for write interactions
const authenticatedArIO = arIO.connect(signer);
const joinNetworkTx = await authenticatedArIO.joinNetwork(params);
const joinNetworkTx = await authenticatedArIO.joinNetwork(joinNetworkParams);

// joinNetworkTx is an Arweave transaction.
// example:
Expand Down
11 changes: 6 additions & 5 deletions src/common/ar-io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
ArNSAuctionData,
ArNSNameData,
BaseContract,
CONTRACT_FUNCTIONS,
ContractConfiguration,
ContractSigner,
EpochDistributionData,
Expand Down Expand Up @@ -145,7 +146,7 @@ export class ArIO implements ArIOContract, BaseContract<ArIOState> {
}: EvaluationParameters<{ address: string }>): Promise<Gateway | undefined> {
return this.contract
.readInteraction<{ target: string }, Gateway>({
functionName: 'gateway',
functionName: CONTRACT_FUNCTIONS.GATEWAY,
inputs: {
target: address,
},
Expand All @@ -163,7 +164,7 @@ export class ArIO implements ArIOContract, BaseContract<ArIOState> {
Record<string, Gateway> | Record<string, never>
> {
return this.contract.readInteraction({
functionName: 'gateways',
functionName: CONTRACT_FUNCTIONS.GATEWAYS,
evaluationOptions,
});
}
Expand All @@ -175,7 +176,7 @@ export class ArIO implements ArIOContract, BaseContract<ArIOState> {
evaluationOptions,
}: EvaluationParameters = {}): Promise<EpochDistributionData> {
return this.contract.readInteraction({
functionName: 'epoch',
functionName: CONTRACT_FUNCTIONS.EPOCH,
evaluationOptions,
});
}
Expand All @@ -193,7 +194,7 @@ export class ArIO implements ArIOContract, BaseContract<ArIOState> {
{ height: number },
EpochDistributionData
>({
functionName: 'epoch',
functionName: CONTRACT_FUNCTIONS.EPOCH,
inputs: {
height: blockHeight,
},
Expand All @@ -208,7 +209,7 @@ export class ArIO implements ArIOContract, BaseContract<ArIOState> {
evaluationOptions,
}: EvaluationParameters = {}): Promise<WeightedObserver[]> {
return this.contract.readInteraction<never, WeightedObserver[]>({
functionName: 'prescribedObservers',
functionName: CONTRACT_FUNCTIONS.PRESCRIBED_OBSERVERS,
evaluationOptions,
});
}
Expand Down
29 changes: 29 additions & 0 deletions src/contract-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,35 @@ import { WalletAddress } from './common.js';

// Gateways

export const CONTRACT_FUNCTIONS = {
GATEWAY: 'getGateway',
GATEWAYS: 'getGateways',
PRESCRIBED_OBSERVERS: 'getPrescribedObservers',
DELEGATE_STAKE: 'delegateStake',
DECREASE_DELEGATE_STAKE: 'decreaseDelegateStake',
JOIN_NETWORK: 'joinNetwork',
LEAVE_NETWORK: 'leaveNetwork',
INCREASE_OPERATOR_STAKE: 'increaseOperatorStake',
DECREASE_OPERATOR_STAKE: 'decreaseOperatorStake',
UPDATE_GATEWAY_SETTINGS: 'updateGatewaySettings',
SAVE_OBSERVATIONS: 'saveObservations',
SUBMIT_AUCTION_BID: 'submitAuctionBid',
BUY_RECORD: 'buyRecord',
EXTEND_RECORD: 'extendRecord',
INCREASE_UNDERNAME_COUNT: 'increaseUndernameCount',
RECORD: 'getRecord',
AUCTION: 'getAuction',
TRANSFER: 'transferTokens',
VAULTED_TRANSFER: 'vaultedTransfer',
CREATE_VAULT: 'createVault',
EXTEND_VAULT: 'extendVault',
INCREASE_VAULT: 'increaseVault',
BALANCE: 'balance',
TICK: 'tick',
PRICE_FOR_INTERACTION: 'getPriceForInteraction',
EPOCH: 'epoch',
};

export type Gateway = {
delegates: Record<string, unknown>;
end: number;
Expand Down

0 comments on commit 9fcf440

Please sign in to comment.