Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs improvements #1560

Merged
merged 16 commits into from
Jun 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 5 additions & 21 deletions src/AeSdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ export default class AeSdk extends AeSdkBase {

/**
* Get accounts addresses
* @alias module:@aeternity/aepp-sdk/es/accounts/multiple
* @function
* @rtype () => String[]
* @return {String[]}
* @example addresses()
*/
addresses (): Array<EncodedData<'ak'>> {
Expand All @@ -31,14 +27,9 @@ export default class AeSdk extends AeSdkBase {

/**
* Add specific account
* @alias module:@aeternity/aepp-sdk/es/accounts/multiple
* @function
* @category async
* @rtype (account: Account, { select: Boolean }) => void
* @param {Object} account - Account instance
* @param {Object} [options={}] - Options
* @param {Boolean} [options.select] - Select account
* @return {void}
* @param account - Account instance
* @param options - Options
* @param options.select - Select account
* @example addAccount(account)
*/
async addAccount (account: AccountBase, { select }: { select?: boolean } = {}): Promise<void> {
Expand All @@ -49,11 +40,7 @@ export default class AeSdk extends AeSdkBase {

/**
* Remove specific account
* @alias module:@aeternity/aepp-sdk/es/accounts/multiple
* @function
* @rtype (address: String) => void
* @param {String} address - Address of account to remove
* @return {void}
* @param address - Address of account to remove
* @example removeAccount(address)
*/
removeAccount (address: EncodedData<'ak'>): void {
Expand All @@ -67,10 +54,7 @@ export default class AeSdk extends AeSdkBase {

/**
* Select specific account
* @alias module:@aeternity/aepp-sdk/es/account/selector
* @instance
* @rtype (address: String) => void
* @param {String} address - Address of account to select
* @param address - Address of account to select
* @example selectAccount('ak_xxxxxxxx')
*/
selectAccount (address: EncodedData<'ak'>): void {
Expand Down
37 changes: 14 additions & 23 deletions src/AeSdkAepp.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
/**
* RPC handler for AEPP side
*
* @module @aeternity/aepp-sdk/es/utils/aepp-wallet-communication/rpc/aepp-rpc
* @export AeppRpc
* @example
* import AeppRpc
* from '@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/rpc/aepp-rpc'
*/
import AeSdkBase, { Account } from './AeSdkBase'
import AccountBase from './account/base'
import AccountRpc from './account/rpc'
Expand All @@ -27,11 +18,11 @@ import BrowserConnection from './utils/aepp-wallet-communication/connection/Brow
/**
* RPC handler for AEPP side
* Contain functionality for wallet interaction and connect it to sdk
* @param param Init params object
* @param param.name Aepp name
* @param param.onAddressChange Call-back function for update address event
* @param param.onDisconnect Call-back function for disconnect event
* @param param.onNetworkChange Call-back function for update network event
* @param param - Init params object
* @param param.name - Aepp name
* @param param.onAddressChange - Call-back function for update address event
* @param param.onDisconnect - Call-back function for disconnect event
* @param param.onNetworkChange - Call-back function for update network event
*/
export default class AeSdkAepp extends AeSdkBase {
name: string
Expand Down Expand Up @@ -81,11 +72,11 @@ export default class AeSdkAepp extends AeSdkBase {

/**
* Connect to wallet
* @param connection Wallet connection object
* @param [options={}]
* @param [options.connectNode=true] - Request wallet to bind node
* @param [options.name=wallet-node] - Node name
* @param [options.select=false] - Select this node as current
* @param connection - Wallet connection object
* @param options
* @param options.connectNode - Request wallet to bind node
* @param options.name - Node name
* @param options.select - Select this node as current
*/
async connectToWallet (
connection: BrowserConnection,
Expand Down Expand Up @@ -139,7 +130,7 @@ export default class AeSdkAepp extends AeSdkBase {

/**
* Ask addresses from wallet
* @return Addresses from wallet
* @returns Addresses from wallet
*/
async askAddresses (): Promise<Array<EncodedData<'ak'>>> {
this._ensureAccountAccess()
Expand All @@ -148,9 +139,9 @@ export default class AeSdkAepp extends AeSdkBase {

/**
* Subscribe for addresses from wallet
* @param type Subscription type
* @param value Should be one of 'current' (the selected account), 'connected' (all)
* @return Accounts from wallet
* @param type - Subscription type
* @param value - Should be one of 'current' (the selected account), 'connected' (all)
* @returns Accounts from wallet
*/
async subscribeAddress (
type: SUBSCRIPTION_TYPES, value: 'current' | 'connected'
Expand Down
17 changes: 3 additions & 14 deletions src/AeSdkBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,8 @@ function getValueOrErrorProxy<Value extends object> (valueCb: () => Value): Valu
* Only by providing the joint functionality of those three, most more advanced
* operations, i.e. the ones with actual use value on the chain, become
* available.
* @function
* @alias module:@aeternity/aepp-sdk/es/ae
* @rtype Stamp
* @param {Object} [options={}] - Initializer object
* @param {String} [options.compilerUrl] compilerUrl - Url for compiler API
* @return {Object} Ae instance
* @param options - Initializer object
* @param options.compilerUrl - compilerUrl - Url for compiler API
*/
class AeSdkBase {
_options = {
Expand Down Expand Up @@ -98,7 +94,6 @@ class AeSdkBase {

/**
* Add Node
* @alias module:@aeternity/aepp-sdk/es/node-pool
* @param name - Node name
* @param node - Node instance
* @param select - Select this node as current
Expand All @@ -117,7 +112,6 @@ class AeSdkBase {

/**
* Select Node
* @alias module:@aeternity/aepp-sdk/es/node-pool
* @param name - Node name
* @example
* nodePool.selectNode('testNode')
Expand All @@ -129,15 +123,13 @@ class AeSdkBase {

/**
* Get NetworkId of current Node
* @alias module:@aeternity/aepp-sdk/es/node-pool
* @example
* nodePool.getNetworkId()
*/
readonly getNetworkId = getNetworkId

/**
* Check if you have selected node
* @alias module:@aeternity/aepp-sdk/es/node-pool
* @example
* nodePool.isNodeConnected()
*/
Expand All @@ -153,7 +145,6 @@ class AeSdkBase {

/**
* Get information about node
* @alias module:@aeternity/aepp-sdk/es/node-pool
* @example
* nodePool.getNodeInfo() // { name, version, networkId, protocol, ... }
*/
Expand All @@ -167,7 +158,6 @@ class AeSdkBase {

/**
* Get array of available nodes
* @alias module:@aeternity/aepp-sdk/es/node-pool
* @example
* nodePool.getNodesInPool()
*/
Expand Down Expand Up @@ -219,8 +209,7 @@ class AeSdkBase {

/**
* Resolves an account
* @param {Object} account ak-address, instance of AccountBase, or keypair
* @returns {AccountBase}
* @param account - ak-address, instance of AccountBase, or keypair
* @private
*/
_resolveAccount (account?: Account): AccountBase {
Expand Down
36 changes: 14 additions & 22 deletions src/AeSdkWallet.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
/**
* RPC handler for WAELLET side
*
* @module @aeternity/aepp-sdk/es/utils/aepp-wallet-communication/rpc/wallet-rpc
* @export WalletRpc
* @example
* import WalletRpc from '@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/rpc/wallet-rpc'
*/
import { v4 as uuid } from '@aeternity/uuid'
import AeSdk from './AeSdk'
import { Account } from './AeSdkBase'
Expand Down Expand Up @@ -65,15 +57,15 @@ interface RpcClientsInfo {

/**
* Contain functionality for aepp interaction and managing multiple aepps
* @param param Init params object
* @param param.name Wallet name
* @param onConnection Call-back function for incoming AEPP connection
* @param onSubscription Call-back function for incoming AEPP account subscription
* @param onSign Call-back function for incoming AEPP sign request
* @param onAskAccounts Call-back function for incoming AEPP get address request
* @param onMessageSign Call-back function for incoming AEPP sign message request
* @param param - Init params object
* @param param.name - Wallet name
* @param onConnection - Call-back function for incoming AEPP connection
* @param onSubscription - Call-back function for incoming AEPP account subscription
* @param onSign - Call-back function for incoming AEPP sign request
* @param onAskAccounts - Call-back function for incoming AEPP get address request
* @param onMessageSign - Call-back function for incoming AEPP sign message request
* Second argument of incoming call-backs contain function for accept/deny request
* @param onDisconnect Call-back function for disconnect event
* @param onDisconnect - Call-back function for disconnect event
*/
export default class AeSdkWallet extends AeSdk {
id: string
Expand Down Expand Up @@ -186,7 +178,7 @@ export default class AeSdkWallet extends AeSdk {

/**
* Remove specific RpcClient by ID
* @param id Client ID
* @param id - Client ID
*/
removeRpcClient (id: string): void {
this._disconnectRpcClient(id)
Expand All @@ -195,8 +187,8 @@ export default class AeSdkWallet extends AeSdk {

/**
* Add new client by AEPP connection
* @param clientConnection AEPP connection object
* @return Client ID
* @param clientConnection - AEPP connection object
* @returns Client ID
*/
addRpcClient (clientConnection: BrowserConnection): string {
// @TODO detect if aepp has some history based on origin????
Expand Down Expand Up @@ -299,15 +291,15 @@ export default class AeSdkWallet extends AeSdk {

/**
* Send shareWalletInfo message to notify AEPP about wallet
* @param clientId ID of RPC client send message to
* @param clientId - ID of RPC client send message to
*/
async shareWalletInfo (clientId: string): Promise<void> {
this._getClient(clientId).rpc.notify(METHODS.readyToConnect, await this.getWalletInfo())
}

/**
* Get Wallet info object
* @return Object with wallet information
* @returns Object with wallet information
*/
async getWalletInfo (): Promise<WalletInfo> {
return {
Expand All @@ -321,7 +313,7 @@ export default class AeSdkWallet extends AeSdk {

/**
* Get Wallet accounts
* @return Object with accounts information ({ connected: Object, current: Object })
* @returns Object with accounts information ({ connected: Object, current: Object })
*/
getAccounts (): Accounts {
return {
Expand Down
Loading