Skip to content

Commit

Permalink
update readmes
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-roslaniec committed Dec 12, 2023
1 parent 48c46c4 commit 93f9d60
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 18 deletions.
69 changes: 53 additions & 16 deletions packages/adapter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ different types depending on the function being called.)

### 1. Get Account Address

The getAccount method doesn't need any parameters.
The `getAccount` method doesn't need any parameters.

```typescript
async function fetchAccount() {
const result: Result<GetAccountResult> = await getAccount();
if (isSuccess(result)) {
console.log(result.data); // {address: "account address"}
} else {
console.error(result.error);
}
import { getAccount, isSuccess } from 'azero-wallet-adapter';

const result: Result<GetAccountResult> = await getAccount();
if (isSuccess(result)) {
console.log(result.data); // {address: "account address"}
} else {
console.error(result.error);
}
```

Expand All @@ -36,14 +36,22 @@ The payload includes the transaction (hex string) and payload (
SignerPayloadJSON type).

```typescript
import {
signAndSendExtrinsicTransactionPayload,
SignAndSendTransactionRequestParams,
isSuccess
} from 'azero-wallet-adapter';

mport

const txParams: SignAndSendTransactionRequestParams = {transaction: /*...*/, payload: /*...*/}

signAndSendExtrinsicTransactionPayload(txParams).then(result => {
if (isSuccess(result)) {
// handle result transaction
} else {
// handle error
}
if (isSuccess(result)) {
// handle result transaction
} else {
// handle error
}
});
```

Expand All @@ -53,10 +61,20 @@ Like the previous method, but only signs the payload without sending it. This
works with the `SignSignerPayloadRequestParams`.

```typescript
import {
signSignerPayload,
SignSignerPayloadRequestParams,
isSuccess
} from 'azero-wallet-adapter';

const signParams: SignSignerPayloadRequestParams = {payload: /*...*/};

signSignerPayload(signParams).then(result => {
// handle result or error
if (isSuccess(result)) {
// handle result transaction
} else {
// handle error
}
});
```

Expand All @@ -66,10 +84,23 @@ This function requires the `TransferNativeAssetRequestParams` type for its
parameters.

```typescript
const transferParams: TransferNativeAssetRequestParams = {recipient: /*...*/, amount: /*...*/};
import {
transferNativeAsset,
TransferNativeAssetRequestParams,
isSuccess
} from 'azero-wallet-adapter';

const transferParams: TransferNativeAssetRequestParams = {
recipient: /*...*/,
amount: /*...*/
};

transferNativeAsset(transferParams).then(result => {
// handle result or error
if (isSuccess(result)) {
// handle result transaction
} else {
// handle error
}
});
```

Expand All @@ -79,6 +110,12 @@ To set the RPC URL, you can use the `setRpcUrl` with `SetRpcUrlRequestParams` as
its parameters.

```typescript
import {
setRpcUrl,
SetRpcUrlRequestParams,
isSuccess,
} from 'azero-wallet-adapter';

const rpcParams: SetRpcUrlRequestParams = { rpcUrl: 'http://my-rpc-url' };

setRpcUrl(rpcParams).then((result) => {
Expand Down
5 changes: 3 additions & 2 deletions packages/snap/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# `azero-wallet`

## Overview

This package implements an Aleph Zero wallet that can be used to sign and send
arbitrary transactions to the connected network.

Please refer to the [`azero-wallet-adapter`](../adapter) package for Aleph
Wallet snap usage examples.
6 changes: 6 additions & 0 deletions packages/types/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
# `azero-wallet-snap`

This package contains type definitions shared by the
[`azero-wallet-adapter`](../adapter) and [`azero-wallet`](../snap) packages.

Please refer to the [`azero-wallet-adapter`](../adapter) package for Aleph
Wallet snap usage examples.

0 comments on commit 93f9d60

Please sign in to comment.