pnpm add azero-wallet-adapter
Follow the integration guide below for method usage and parameter handling.
(Note: For all methods, params
is the data required by each method. It has
different types depending on the function being called.)
The getAccount
method doesn't need any parameters.
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);
}
This method requires the SignAndSendTransactionRequestParams
type for its
params. The response type is Result<SignAndSendExtrinsicTransactionResult>
.
The payload includes the transaction (hex string) and payload (
SignerPayloadJSON type).
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
}
});
Like the previous method, but only signs the payload without sending it. This
works with the SignSignerPayloadRequestParams
.
import {
signSignerPayload,
SignSignerPayloadRequestParams,
isSuccess
} from 'azero-wallet-adapter';
const signParams: SignSignerPayloadRequestParams = {payload: /*...*/};
signSignerPayload(signParams).then(result => {
if (isSuccess(result)) {
// handle result transaction
} else {
// handle error
}
});
This function requires the TransferNativeAssetRequestParams
type for its
parameters.
import {
transferNativeAsset,
TransferNativeAssetRequestParams,
isSuccess
} from 'azero-wallet-adapter';
const transferParams: TransferNativeAssetRequestParams = {
recipient: /*...*/,
amount: /*...*/
};
transferNativeAsset(transferParams).then(result => {
if (isSuccess(result)) {
// handle result transaction
} else {
// handle error
}
});
To set the RPC URL, you can use the setRpcUrl
with SetRpcUrlRequestParams
as
its parameters.
import {
setRpcUrl,
SetRpcUrlRequestParams,
isSuccess,
} from 'azero-wallet-adapter';
const rpcParams: SetRpcUrlRequestParams = { rpcUrl: 'http://my-rpc-url' };
setRpcUrl(rpcParams).then((result) => {
if (isSuccess(result)) {
// execute callback after RPC URL is set
} else {
// handle error
}
});
This project is licensed under the GPL-3.0 License.