diff --git a/docs/providers/responding-to-disable-requests.mdx b/docs/providers/responding-to-disable-requests.mdx
index 6a47667..5fd898f 100644
--- a/docs/providers/responding-to-disable-requests.mdx
+++ b/docs/providers/responding-to-disable-requests.mdx
@@ -13,9 +13,9 @@ import TOCInline from '@theme/TOCInline';
Providers that implement a session for a client, a disable request can be called by a client that instructs the provider to remove the client's session.
-## Responding to an anonymous request
+## Responding to a disable request
-For clients that have not specified a provider, it means the client would like to disable with all providers. Once our provider object has been initialized, we can simply listen to events and respond:
+Once our provider object has been initialized, we can simply listen to events and respond:
{
- if (!params || !params.providerId) {
- // ... remove all sessions
-
- return {
- genesisHash: 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=',
- genesisId: 'testnet-v1.0',
- providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e',
- };
- }
+ provider.onDisable(() => {
+ // ... remove all sessions
+
+ return {
+ genesisHash: 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=',
+ genesisId: 'testnet-v1.0',
+ providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e',
+ };
});
```
@@ -44,19 +42,15 @@ For clients that have not specified a provider, it means the client would like t
```typescript
- import type { IAVMWebProviderCallbackOptions } from '@agoralabs-sh/avm-web-provider';
-
// initialized provider
- provider.onEnable(({ params }: IAVMWebProviderCallbackOptions) => {
- if (!params || !params.providerId) {
- // ... remove all sessions
-
- return {
- genesisHash: 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=',
- genesisId: 'testnet-v1.0',
- providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e',
- };
- }
+ provider.onDisable(() => {
+ // ... remove all sessions
+
+ return {
+ genesisHash: 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=',
+ genesisId: 'testnet-v1.0',
+ providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e',
+ };
});
```
@@ -75,9 +69,9 @@ If this method is not supported, then a [`MethodNotSupportedError`](../../api-re
:::
-## Responding to a specific provider and network request
+## Responding to a disable request with a specific network
-The `disable` request allows the client to specify the provider and the network. This is denoted in the supplied `params.providerId` and `params.genesisHash` parameters. Providers with the matching ID should respond:
+The `disable` request allows the client to specify the network. This is denoted in the supplied `params.genesisHash` parameter.
{
- if (!params || params.providerId === providerId) {
- // if the genesis hash has been defined, it is recommended that you throw and error
- if (param.genesisHash && param.genesisHash !== genesisHash) {
- throw new ARC0027NetworkNotSupportedError({
- genesisHashes: [param.genesisHash],
- providerId,
- });
- }
-
- // ... remove all sessions for the network
-
- return {
- genesisHash,
- genesisId: 'testnet-v1.0',
+ // if the genesis hash has been defined, it is recommended that you throw and error
+ if (param.genesisHash && param.genesisHash !== genesisHash) {
+ throw new ARC0027NetworkNotSupportedError({
+ genesisHashes: [param.genesisHash],
providerId,
- };
+ });
}
+
+ // ... remove all sessions for the network
+
+ return {
+ genesisHash,
+ genesisId: 'testnet-v1.0',
+ providerId,
+ };
});
```
@@ -122,27 +114,25 @@ The `disable` request allows the client to specify the provider and the network.
import type { ARC0027NetworkNotSupportedError, IAVMWebProviderCallbackOptions } from '@agoralabs-sh/avm-web-provider';
const genesisHash = 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=';
- const providerId: string = '02657eaf-be17-4efc-b0a4-19d654b2448e';
+ const providerId = '02657eaf-be17-4efc-b0a4-19d654b2448e';
// initialized provider
provider.onDisable(({ params }: IAVMWebProviderCallbackOptions) => {
- if (!params || params.providerId === providerId) {
- // if the genesis hash has been defined, it is recommended that you throw and error
- if (param.genesisHash && param.genesisHash !== genesisHash) {
- throw new ARC0027NetworkNotSupportedError({
- genesisHashes: [param.genesisHash],
- providerId,
- });
- }
-
- // ... remove all sessions for the network
-
- return {
- genesisHash,
- genesisId: 'testnet-v1.0',
+ // if the genesis hash has been defined, it is recommended that you throw and error
+ if (param.genesisHash && param.genesisHash !== genesisHash) {
+ throw new ARC0027NetworkNotSupportedError({
+ genesisHashes: [param.genesisHash],
providerId,
- };
+ });
}
+
+ // ... remove all sessions for the network
+
+ return {
+ genesisHash,
+ genesisId: 'testnet-v1.0',
+ providerId,
+ };
});
```
@@ -151,7 +141,7 @@ The `disable` request allows the client to specify the provider and the network.
:::caution
-If the network and the provider ID is specified, and the provider does not support the network, then a [`NetworkNotSupportedError`](../../api-reference/errors#networknotsupportederror) should be thrown.
+If the network is specified, and the provider does not support the network, then a [`NetworkNotSupportedError`](../../api-reference/errors#networknotsupportederror) should be thrown.
:::
@@ -192,8 +182,8 @@ A requesting client can specify the particular session. This can be used instead
```typescript
import type { IAVMWebProviderCallbackOptions } from '@agoralabs-sh/avm-web-provider';
- const providerId: string = '02657eaf-be17-4efc-b0a4-19d654b2448e';
- const sessionId: string = '2802dff6-930e-4f79-8f67-ba9d41e88cf8';
+ const providerId = '02657eaf-be17-4efc-b0a4-19d654b2448e';
+ const sessionId = '2802dff6-930e-4f79-8f67-ba9d41e88cf8';
// initialized provider
provider.onDisable(({ params }: IAVMWebProviderCallbackOptions) => {
diff --git a/docs/providers/responding-to-discover-requests.mdx b/docs/providers/responding-to-discover-requests.mdx
index c6103fe..7a2ceac 100644
--- a/docs/providers/responding-to-discover-requests.mdx
+++ b/docs/providers/responding-to-discover-requests.mdx
@@ -13,9 +13,9 @@ import TOCInline from '@theme/TOCInline';
It is likely that clients will want to find out the capabilities of your provider before they start interacting with it. Therefore, it is good practice to handle discover request from clients, responding with your provider's supported networks & methods.
-## Responding to an anonymous request
+## Responding to a discover request
-For clients that have not specified a provider, it means the client would like to know all available providers. Once our provider object has been initialized, we can simply listen to events and respond:
+Once our provider object has been initialized, we can simply listen to events and respond:
{
- if (!params || !params.providerId) {
- return {
- host: 'https://awesome-wallet.com',
- name: 'Awesome Wallet',
- networks: [
- {
- genesisHash: 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=',
- genesisId: 'testnet-v1.0',
- methods: [
- 'disable',
- 'enable',
- 'post_transactions',
- 'sign_and_post_transactions',
- 'sign_transactions',
- ],
- },
- {
- genesisHash: 'IXnoWtviVVJW5LGivNFc0Dq14V3kqaXuK2u5OQrdVZo=',
- genesisId: 'voitest-v1',
- methods: [
- 'disable',
- 'enable',
- 'post_transactions',
- 'sign_and_post_transactions',
- 'sign_transactions',
- ],
- },
- ],
- providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e',
- };
- }
- });
- ```
-
-
-
-
- ```typescript
- import type { IAVMWebProviderCallbackOptions } from '@agoralabs-sh/avm-web-provider';
-
- // initialized provider
- provider.onDiscover(({ params }: IAVMWebProviderCallbackOptions) => {
- if (!params?.providerId) {
- return {
- host: 'https://awesome-wallet.com',
- name: 'Awesome Wallet',
- networks: [
- {
- genesisHash: 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=',
- genesisId: 'testnet-v1.0',
- methods: [
+ return {
+ host: 'https://awesome-wallet.com',
+ name: 'Awesome Wallet',
+ networks: [
+ {
+ genesisHash: 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=',
+ genesisId: 'testnet-v1.0',
+ methods: [
'disable',
'enable',
'post_transactions',
'sign_and_post_transactions',
'sign_transactions',
- ],
- },
- {
- genesisHash: 'IXnoWtviVVJW5LGivNFc0Dq14V3kqaXuK2u5OQrdVZo=',
- genesisId: 'voitest-v1',
- methods: [
+ ],
+ },
+ {
+ genesisHash: 'IXnoWtviVVJW5LGivNFc0Dq14V3kqaXuK2u5OQrdVZo=',
+ genesisId: 'voitest-v1',
+ methods: [
'disable',
'enable',
'post_transactions',
'sign_and_post_transactions',
'sign_transactions',
- ],
- },
- ],
- providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e',
- };
- }
- });
- ```
-
-
-
-
-## Responding to a specific provider request
-
-The `discover` request allow the client to specify the provider. This is denoted in the supplied `params.providerId` parameter. Providers with the matching ID should respond:
-
-
-
-
- ```js
- const providerId = '02657eaf-be17-4efc-b0a4-19d654b2448e';
-
- // initialized provider
- provider.onDiscover(({ params }) => {
- if (!params || params.providerId === providerId) {
- return {
- host: 'https://awesome-wallet.com',
- name: 'Awesome Wallet',
- networks: [
- {
- genesisHash: 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=',
- genesisId: 'testnet-v1.0',
- methods: [
- 'disable',
- 'enable',
- 'post_transactions',
- 'sign_and_post_transactions',
- 'sign_transactions',
- ],
- },
- {
- genesisHash: 'IXnoWtviVVJW5LGivNFc0Dq14V3kqaXuK2u5OQrdVZo=',
- genesisId: 'voitest-v1',
- methods: [
- 'disable',
- 'enable',
- 'post_transactions',
- 'sign_and_post_transactions',
- 'sign_transactions',
- ],
- },
- ],
- providerId,
- };
- }
+ ],
+ },
+ ],
+ providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e',
+ };
});
```
@@ -164,41 +66,37 @@ The `discover` request allow the client to specify the provider. This is denoted
```typescript
import type { IAVMWebProviderCallbackOptions } from '@agoralabs-sh/avm-web-provider';
- const providerId: string = '02657eaf-be17-4efc-b0a4-19d654b2448e';
-
// initialized provider
provider.onDiscover(({ params }: IAVMWebProviderCallbackOptions) => {
- if (!params || params.providerId === providerId) {
- return {
- host: 'https://awesome-wallet.com',
- name: 'Awesome Wallet',
- networks: [
- {
- genesisHash: 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=',
- genesisId: 'testnet-v1.0',
- methods: [
- 'disable',
- 'enable',
- 'post_transactions',
- 'sign_and_post_transactions',
- 'sign_transactions',
- ],
- },
- {
- genesisHash: 'IXnoWtviVVJW5LGivNFc0Dq14V3kqaXuK2u5OQrdVZo=',
- genesisId: 'voitest-v1',
- methods: [
- 'disable',
- 'enable',
- 'post_transactions',
- 'sign_and_post_transactions',
- 'sign_transactions',
- ],
- },
- ],
- providerId,
- };
- }
+ return {
+ host: 'https://awesome-wallet.com',
+ name: 'Awesome Wallet',
+ networks: [
+ {
+ genesisHash: 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=',
+ genesisId: 'testnet-v1.0',
+ methods: [
+ 'disable',
+ 'enable',
+ 'post_transactions',
+ 'sign_and_post_transactions',
+ 'sign_transactions',
+ ],
+ },
+ {
+ genesisHash: 'IXnoWtviVVJW5LGivNFc0Dq14V3kqaXuK2u5OQrdVZo=',
+ genesisId: 'voitest-v1',
+ methods: [
+ 'disable',
+ 'enable',
+ 'post_transactions',
+ 'sign_and_post_transactions',
+ 'sign_transactions',
+ ],
+ },
+ ],
+ providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e',
+ };
});
```
diff --git a/docs/providers/responding-to-enable-requests.mdx b/docs/providers/responding-to-enable-requests.mdx
index 4bcca77..bffee66 100644
--- a/docs/providers/responding-to-enable-requests.mdx
+++ b/docs/providers/responding-to-enable-requests.mdx
@@ -13,9 +13,9 @@ import TOCInline from '@theme/TOCInline';
The main purpose of an enable request to is for clients to get a list of authorized accounts. However, it can be used to handle sessioning. While it is not enforced through this SDK, it is heavily recommended.
-## Responding to an anonymous request
+## Responding to an enable request
-For clients that have not specified a provider, it means the client would like to enable with all providers. Once our provider object has been initialized, we can simply listen to events and respond:
+Once our provider object has been initialized, we can simply listen to events and respond:
-```js
-// initialized provider
-provider.onEnable(({ params }) => {
- if (!params || !params.providerId) {
+ ```js
+ // initialized provider
+ provider.onEnable(({ params }) => {
return {
accounts: [
{
@@ -44,19 +43,17 @@ provider.onEnable(({ params }) => {
genesisId: 'testnet-v1.0',
providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e',
};
- }
-});
-```
+ });
+ ```
-```typescript
-import type { IAVMWebProviderCallbackOptions } from '@agoralabs-sh/avm-web-provider';
+ ```typescript
+ import type { IAVMWebProviderCallbackOptions } from '@agoralabs-sh/avm-web-provider';
-// initialized provider
-provider.onEnable(({ params }: IAVMWebProviderCallbackOptions) => {
- if (!params || !params.providerId) {
+ // initialized provider
+ provider.onEnable(({ params }: IAVMWebProviderCallbackOptions) => {
return {
accounts: [
{
@@ -72,9 +69,8 @@ provider.onEnable(({ params }: IAVMWebProviderCallbackOptions) => {
genesisId: 'testnet-v1.0',
providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e',
};
- }
-});
-```
+ });
+ ```
@@ -85,9 +81,9 @@ If this method is not supported, then a [`MethodNotSupportedError`](../../api-re
:::
-## Responding to a specific provider request
+## Responding to an enable request with a specific network
-The `enable` request allows the client to specify the provider. This is denoted in the supplied `params.providerId` parameter. Providers with the matching ID should respond:
+The `enable` request allows the client to specify the network. This is denoted in the supplied `params.genesisHash` parameter.
-```js
-const providerId = '02657eaf-be17-4efc-b0a4-19d654b2448e';
-
-// initialized provider
-provider.onEnable(({ params }) => {
- if (!params || params.providerId === providerId) {
- return {
- accounts: [
- {
- address: 'P3AIQVDJ2CTH54KSJE63YWB7IZGS4W4JGC53I6GK72BGZ5BXO2B2PS4M4U',
- name: 'Wallet-1',
- },
- {
- address: '6GT6EXFDAHZDZYUOPT725ZRWYBZDCEGYT7SYYXGJKRFUAG5B7JMI7DQRNQ',
- name: 'Wallet-2',
- },
- ],
- genesisHash: 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=',
- genesisId: 'testnet-v1.0',
- providerId,
- };
- }
-});
-```
+ ```js
+ const { ARC0027NetworkNotSupportedError } = require('@agoralabs-sh/avm-web-provider');
+
+ const genesisHash = 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=';
+ const providerId = '02657eaf-be17-4efc-b0a4-19d654b2448e';
+
+ // initialized provider
+ provider.onEnable(({ params }) => {
+ // if the genesis hash has been defined, it is recommended that you throw and error
+ if (param.genesisHash && param.genesisHash !== genesisHash) {
+ throw new ARC0027NetworkNotSupportedError({
+ genesisHashes: [param.genesisHash],
+ providerId,
+ });
+ }
+
+ return {
+ accounts: [
+ {
+ address: 'P3AIQVDJ2CTH54KSJE63YWB7IZGS4W4JGC53I6GK72BGZ5BXO2B2PS4M4U',
+ name: 'Wallet-1',
+ },
+ {
+ address: '6GT6EXFDAHZDZYUOPT725ZRWYBZDCEGYT7SYYXGJKRFUAG5B7JMI7DQRNQ',
+ name: 'Wallet-2',
+ },
+ ],
+ genesisHash,
+ genesisId: 'testnet-v1.0',
+ providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e',
+ };
+ });
+ ```
-```typescript
-import type { IAVMWebProviderCallbackOptions } from '@agoralabs-sh/avm-web-provider';
-
-const providerId: string = '02657eaf-be17-4efc-b0a4-19d654b2448e';
-
-// initialized provider
-provider.onEnable(({ params }: IAVMWebProviderCallbackOptions) => {
- if (!params || params.providerId === providerId) {
- return {
- accounts: [
- {
- address: 'P3AIQVDJ2CTH54KSJE63YWB7IZGS4W4JGC53I6GK72BGZ5BXO2B2PS4M4U',
- name: 'Wallet-1',
- },
- {
- address: '6GT6EXFDAHZDZYUOPT725ZRWYBZDCEGYT7SYYXGJKRFUAG5B7JMI7DQRNQ',
- name: 'Wallet-2',
- },
- ],
- genesisHash: 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=',
- genesisId: 'testnet-v1.0',
- providerId,
- };
- }
-});
-```
+ ```typescript
+ import type { ARC0027NetworkNotSupportedError, IAVMWebProviderCallbackOptions } from '@agoralabs-sh/avm-web-provider';
+
+ const genesisHash = 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=';
+ const providerId = '02657eaf-be17-4efc-b0a4-19d654b2448e';
+
+ // initialized provider
+ provider.onEnable(({ params }: IAVMWebProviderCallbackOptions) => {
+ // if the genesis hash has been defined, it is recommended that you throw and error
+ if (param.genesisHash && param.genesisHash !== genesisHash) {
+ throw new ARC0027NetworkNotSupportedError({
+ genesisHashes: [param.genesisHash],
+ providerId,
+ });
+ }
+
+ return {
+ accounts: [
+ {
+ address: 'P3AIQVDJ2CTH54KSJE63YWB7IZGS4W4JGC53I6GK72BGZ5BXO2B2PS4M4U',
+ name: 'Wallet-1',
+ },
+ {
+ address: '6GT6EXFDAHZDZYUOPT725ZRWYBZDCEGYT7SYYXGJKRFUAG5B7JMI7DQRNQ',
+ name: 'Wallet-2',
+ },
+ ],
+ genesisHash,
+ genesisId: 'testnet-v1.0',
+ providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e',
+ };
+ });
+ ```
+
+:::caution
+
+If the network is specified, and the provider does not support the network, then a [`NetworkNotSupportedError`](../../api-reference/errors#networknotsupportederror) should be thrown.
+
+:::
diff --git a/docs/providers/responding-to-post-transactions-requests.mdx b/docs/providers/responding-to-post-transactions-requests.mdx
index 2374bcb..feb9382 100644
--- a/docs/providers/responding-to-post-transactions-requests.mdx
+++ b/docs/providers/responding-to-post-transactions-requests.mdx
@@ -25,12 +25,11 @@ Once our provider object has been initialized, we can simply listen to events an
]}>
-```js
-const providerId = '02657eaf-be17-4efc-b0a4-19d654b2448e';
+ ```js
+ const providerId = '02657eaf-be17-4efc-b0a4-19d654b2448e';
-// initialized provider
-provider.onPostTransactions(({ params }) => {
- if (params.providerId === providerId) {
+ // initialized provider
+ provider.onPostTransactions(({ params }) => {
// ... using the `params.stxns` parameter, the provider posts the transactions to the network and returns the transaction ids
return {
@@ -39,21 +38,19 @@ provider.onPostTransactions(({ params }) => {
'OKU6A2Q...',
],
};
- }
-});
-```
+ });
+ ```
-```typescript
-import type { IAVMWebProviderCallbackOptions } from '@agoralabs-sh/avm-web-provider';
+ ```typescript
+ import type { IAVMWebProviderCallbackOptions } from '@agoralabs-sh/avm-web-provider';
-const providerId: string = '02657eaf-be17-4efc-b0a4-19d654b2448e';
+ const providerId = '02657eaf-be17-4efc-b0a4-19d654b2448e';
-// initialized provider
-provider.onPostTransactions(({ params }: IAVMWebProviderCallbackOptions) => {
- if (params.providerId === providerId) {
+ // initialized provider
+ provider.onPostTransactions(({ params }: IAVMWebProviderCallbackOptions) => {
// ... using the `params.stxns` parameter, the provider posts the transactions to the network and returns the transaction ids
return {
@@ -62,9 +59,8 @@ provider.onPostTransactions(({ params }: IAVMWebProviderCallbackOptions) => {
'OKU6A2Q...',
],
};
- }
-});
-```
+ });
+ ```
diff --git a/docs/providers/responding-to-sign-and-post-transactions-requests.mdx b/docs/providers/responding-to-sign-and-post-transactions-requests.mdx
index 7fae5cc..17fb9ad 100644
--- a/docs/providers/responding-to-sign-and-post-transactions-requests.mdx
+++ b/docs/providers/responding-to-sign-and-post-transactions-requests.mdx
@@ -25,12 +25,11 @@ Once our provider object has been initialized, we can simply listen to events an
]}>
-```js
-const providerId = '02657eaf-be17-4efc-b0a4-19d654b2448e';
+ ```js
+ const providerId = '02657eaf-be17-4efc-b0a4-19d654b2448e';
-// initialized provider
-provider.onSignAndPostTransactions(({ params }) => {
- if (params.providerId === providerId) {
+ // initialized provider
+ provider.onSignAndPostTransactions(({ params }) => {
// ... using the `params.txns` parameter, the provider signs and posts the transactions to the network and returns the transaction ids
return {
@@ -39,21 +38,19 @@ provider.onSignAndPostTransactions(({ params }) => {
'OKU6A2Q...',
],
};
- }
-});
-```
+ });
+ ```
-```typescript
-import type { IAVMWebProviderCallbackOptions } from '@agoralabs-sh/avm-web-provider';
+ ```typescript
+ import type { IAVMWebProviderCallbackOptions } from '@agoralabs-sh/avm-web-provider';
-const providerId: string = '02657eaf-be17-4efc-b0a4-19d654b2448e';
+ const providerId = '02657eaf-be17-4efc-b0a4-19d654b2448e';
-// initialized provider
-provider.onSignAndPostTransactions(({ params }: IAVMWebProviderCallbackOptions) => {
- if (params.providerId === providerId) {
+ // initialized provider
+ provider.onSignAndPostTransactions(({ params }: IAVMWebProviderCallbackOptions) => {
// ... using the `params.txns` parameter, the provider signs and posts the transactions to the network and returns the transaction ids
return {
@@ -62,9 +59,8 @@ provider.onSignAndPostTransactions(({ params }: IAVMWebProviderCallbackOptions)
'OKU6A2Q...',
],
};
- }
-});
-```
+ });
+ ```
diff --git a/docs/providers/responding-to-sign-message-requests.mdx b/docs/providers/responding-to-sign-message-requests.mdx
index f53dcca..c8fb84d 100644
--- a/docs/providers/responding-to-sign-message-requests.mdx
+++ b/docs/providers/responding-to-sign-message-requests.mdx
@@ -21,12 +21,11 @@ Once our provider object has been initialized, we can simply listen to events an
]}>
-```js
-const providerId = '02657eaf-be17-4efc-b0a4-19d654b2448e';
+ ```js
+ const providerId = '02657eaf-be17-4efc-b0a4-19d654b2448e';
-// initialized provider
-provider.onSignMessage(({ params }) => {
- if (params.providerId === providerId) {
+ // initialized provider
+ provider.onSignMessage(({ params }) => {
// ... using the `params.message` and the `params.signer` parameters, the provider signs the message with the private key of the signer and, with the signature, encodes as a base64 string
return {
@@ -34,21 +33,19 @@ provider.onSignMessage(({ params }) => {
signature: 'gqNzaWfEQ...', // base64 encoded signature
signer: 'P3AIQVDJ2CTH54KSJE63YWB7IZGS4W4JGC53I6GK72BGZ5BXO2B2PS4M4U',
};
- }
-});
-```
+ });
+ ```
-```typescript
-import type { IAVMWebProviderCallbackOptions } from '@agoralabs-sh/avm-web-provider';
+ ```typescript
+ import type { IAVMWebProviderCallbackOptions } from '@agoralabs-sh/avm-web-provider';
-const providerId: string = '02657eaf-be17-4efc-b0a4-19d654b2448e';
+ const providerId = '02657eaf-be17-4efc-b0a4-19d654b2448e';
-// initialized provider
-provider.onSignMessage(({ params }: IAVMWebProviderCallbackOptions) => {
- if (params.providerId === providerId) {
+ // initialized provider
+ provider.onSignMessage(({ params }: IAVMWebProviderCallbackOptions) => {
// ... using the `params.message` and the `params.signer` parameters, the provider signs the message with the private key of the signer and, with the signature, encodes as a base64 string
return {
@@ -56,9 +53,8 @@ provider.onSignMessage(({ params }: IAVMWebProviderCallbackOptions) => {
signature: 'gqNzaWfEQ...', // base64 encoded signature
signer: 'P3AIQVDJ2CTH54KSJE63YWB7IZGS4W4JGC53I6GK72BGZ5BXO2B2PS4M4U',
};
- }
-});
-```
+ });
+ ```
diff --git a/docs/providers/responding-to-sign-transactions-requests.mdx b/docs/providers/responding-to-sign-transactions-requests.mdx
index b7a7c0f..db34e87 100644
--- a/docs/providers/responding-to-sign-transactions-requests.mdx
+++ b/docs/providers/responding-to-sign-transactions-requests.mdx
@@ -21,12 +21,11 @@ Once our provider object has been initialized, we can simply listen to events an
]}>
-```js
-const providerId = '02657eaf-be17-4efc-b0a4-19d654b2448e';
+ ```js
+ const providerId = '02657eaf-be17-4efc-b0a4-19d654b2448e';
-// initialized provider
-provider.onSignTransactions(({ params }) => {
- if (params.providerId === providerId) {
+ // initialized provider
+ provider.onSignTransactions(({ params }) => {
// ... using the `params.txns` parameter, the provider signs the transactions and returns the base64 encoded signed transactions
return {
@@ -35,21 +34,19 @@ provider.onSignTransactions(({ params }) => {
'gqNzaWfEQ...',
],
};
- }
-});
-```
+ });
+ ```
-```typescript
-import type { IAVMWebProviderCallbackOptions } from '@agoralabs-sh/avm-web-provider';
+ ```typescript
+ import type { IAVMWebProviderCallbackOptions } from '@agoralabs-sh/avm-web-provider';
-const providerId: string = '02657eaf-be17-4efc-b0a4-19d654b2448e';
+ const providerId = '02657eaf-be17-4efc-b0a4-19d654b2448e';
-// initialized provider
-provider.onSignTransactions(({ params }: IAVMWebProviderCallbackOptions) => {
- if (params.providerId === providerId) {
+ // initialized provider
+ provider.onSignTransactions(({ params }: IAVMWebProviderCallbackOptions) => {
// ... using the `params.txns` parameter, the provider signs the transactions and returns the base64 encoded signed transactions
return {
@@ -58,9 +55,8 @@ provider.onSignTransactions(({ params }: IAVMWebProviderCallbackOptions) => {
'gqNzaWfEQ...',
],
};
- }
-});
-```
+ });
+ ```
diff --git a/src/controllers/AVMWebClient.test.ts b/src/controllers/AVMWebClient.test.ts
index cae4016..a1c04db 100644
--- a/src/controllers/AVMWebClient.test.ts
+++ b/src/controllers/AVMWebClient.test.ts
@@ -11,7 +11,7 @@ import { ARC0027MethodEnum } from '@app/enums';
import { ARC0027MethodNotSupportedError } from '@app/errors';
// types
-import {
+import type {
IAVMWebClientConfig,
IDisableResult,
IDiscoverResult,
diff --git a/src/controllers/AVMWebClient.ts b/src/controllers/AVMWebClient.ts
index 4c7df85..48f5dc1 100644
--- a/src/controllers/AVMWebClient.ts
+++ b/src/controllers/AVMWebClient.ts
@@ -46,40 +46,52 @@ import type {
import { createMessageReference } from '@app/utils';
export default class AVMWebClient extends BaseController {
- private requestIds: string[];
+ private _requestIds: string[];
private constructor(config: IAVMWebClientConfig) {
super(config);
- this.requestIds = [];
+ this._requestIds = [];
+ }
+
+ /**
+ * public static methods
+ */
+
+ public static init(
+ { debug }: IAVMWebClientInitOptions = { debug: false }
+ ): AVMWebClient {
+ return new AVMWebClient({
+ debug: debug || false,
+ });
}
/**
* private methods
*/
- private addListener(
+ private _addListener(
method: ARC0027MethodEnum,
callback: TAVMWebClientCallback
): string {
- const _functionName: string = 'addListener';
+ const _functionName = '_addListener';
const listener: TClientCustomEventListener = (event) => {
let detail: ResponseMessageWithError | ResponseMessageWithResult;
try {
detail = JSON.parse(event.detail); // the event.detail should be a stringified object
} catch (error) {
- console.error(`${AVMWebClient.name}#${_functionName}:`, error);
+ this._logger.error(`${AVMWebClient.name}#${_functionName}:`, error);
return;
}
// if the request event is not known, ignore
- if (!this.requestIds.includes(detail.requestId)) {
+ if (!this._requestIds.includes(detail.requestId)) {
return;
}
- this.logger.debug(
+ this._logger.debug(
`${AVMWebClient.name}#${_functionName}: received response event:`,
detail
);
@@ -91,15 +103,15 @@ export default class AVMWebClient extends BaseController {
result: (detail as ResponseMessageWithResult).result || null,
});
};
- const listenerID: string = uuid();
- const reference: string = createMessageReference(
+ const listenerID = uuid();
+ const reference = createMessageReference(
method,
ARC0027MessageTypeEnum.Response
);
// start listening to response events and add the listener to the map
window.addEventListener(reference, listener);
- this.listeners.set(listenerID, {
+ this._listeners.set(listenerID, {
listener,
reference,
});
@@ -107,13 +119,13 @@ export default class AVMWebClient extends BaseController {
return listenerID;
}
- private sendRequestMessage({
+ private _sendRequestMessage({
method,
params,
}: ISendRequestMessageOptions): string {
- const _functionName: string = 'sendRequestMessage';
- const id: string = uuid();
- const reference: string = createMessageReference(
+ const _functionName = '_sendRequestMessage';
+ const id = uuid();
+ const reference = createMessageReference(
method,
ARC0027MessageTypeEnum.Request
);
@@ -132,36 +144,24 @@ export default class AVMWebClient extends BaseController {
// add a timeout to remove the request id and stop handling response messages
window.setTimeout(() => {
- this.requestIds = this.requestIds.filter((value) => value !== id);
+ this._requestIds = this._requestIds.filter((value) => value !== id);
}, DEFAULT_REQUEST_TIMEOUT);
- this.logger.debug(
+ this._logger.debug(
`${AVMWebClient.name}#${_functionName}: posted request message "${reference}" with id "${id}"`
);
// add the id to the internal state
- this.requestIds.push(id);
+ this._requestIds.push(id);
return id;
} catch (error) {
- this.logger.error(error);
+ this._logger.error(error);
throw new ARC0027UnknownError(error.message);
}
}
- /**
- * public static methods
- */
-
- public static init(
- { debug }: IAVMWebClientInitOptions = { debug: false }
- ): AVMWebClient {
- return new AVMWebClient({
- debug: debug || false,
- });
- }
-
/**
* public methods
*/
@@ -172,7 +172,7 @@ export default class AVMWebClient extends BaseController {
* @returns {string} the ID of the request message.
*/
public disable(params?: IDisableParams): string {
- return this.sendRequestMessage({
+ return this._sendRequestMessage({
method: ARC0027MethodEnum.Disable,
params,
});
@@ -185,7 +185,7 @@ export default class AVMWebClient extends BaseController {
* @returns {string} the ID of the request message.
*/
public discover(params?: IDiscoverParams): string {
- return this.sendRequestMessage({
+ return this._sendRequestMessage({
method: ARC0027MethodEnum.Discover,
params,
});
@@ -198,7 +198,7 @@ export default class AVMWebClient extends BaseController {
* @returns {string} the ID of the request message.
*/
public enable(params?: IEnableParams): string {
- return this.sendRequestMessage({
+ return this._sendRequestMessage({
method: ARC0027MethodEnum.Enable,
params,
});
@@ -211,7 +211,7 @@ export default class AVMWebClient extends BaseController {
* @returns {string} the ID of the listener.
*/
public onDisable(callback: TAVMWebClientCallback): string {
- return this.addListener(
+ return this._addListener(
ARC0027MethodEnum.Disable,
callback
);
@@ -224,7 +224,7 @@ export default class AVMWebClient extends BaseController {
* @returns {string} the ID of the listener.
*/
public onDiscover(callback: TAVMWebClientCallback): string {
- return this.addListener(
+ return this._addListener(
ARC0027MethodEnum.Discover,
callback
);
@@ -237,7 +237,7 @@ export default class AVMWebClient extends BaseController {
* @returns {string} the ID of the listener.
*/
public onEnable(callback: TAVMWebClientCallback): string {
- return this.addListener(ARC0027MethodEnum.Enable, callback);
+ return this._addListener(ARC0027MethodEnum.Enable, callback);
}
/**
@@ -249,7 +249,7 @@ export default class AVMWebClient extends BaseController {
public onPostTransactions(
callback: TAVMWebClientCallback
): string {
- return this.addListener(
+ return this._addListener(
ARC0027MethodEnum.PostTransactions,
callback
);
@@ -263,7 +263,7 @@ export default class AVMWebClient extends BaseController {
public onSignAndPostTransactions(
callback: TAVMWebClientCallback
): string {
- return this.addListener(
+ return this._addListener(
ARC0027MethodEnum.SignAndPostTransactions,
callback
);
@@ -278,7 +278,7 @@ export default class AVMWebClient extends BaseController {
public onSignMessage(
callback: TAVMWebClientCallback
): string {
- return this.addListener(
+ return this._addListener(
ARC0027MethodEnum.SignMessage,
callback
);
@@ -293,7 +293,7 @@ export default class AVMWebClient extends BaseController {
public onSignTransactions(
callback: TAVMWebClientCallback
): string {
- return this.addListener(
+ return this._addListener(
ARC0027MethodEnum.SignTransactions,
callback
);
@@ -305,7 +305,7 @@ export default class AVMWebClient extends BaseController {
* @returns {string} the ID of the request message
*/
public postTransactions(params: IPostTransactionsParams): string {
- return this.sendRequestMessage({
+ return this._sendRequestMessage({
method: ARC0027MethodEnum.PostTransactions,
params,
});
@@ -317,7 +317,7 @@ export default class AVMWebClient extends BaseController {
* @returns {string} the ID of the request message
*/
public signAndPostTransactions(params: ISignTransactionsParams): string {
- return this.sendRequestMessage({
+ return this._sendRequestMessage({
method: ARC0027MethodEnum.SignAndPostTransactions,
params,
});
@@ -329,7 +329,7 @@ export default class AVMWebClient extends BaseController {
* @returns {string} the ID of the request message
*/
public signMessage(params: ISignMessageParams): string {
- return this.sendRequestMessage({
+ return this._sendRequestMessage({
method: ARC0027MethodEnum.SignMessage,
params,
});
@@ -341,7 +341,7 @@ export default class AVMWebClient extends BaseController {
* @returns {string} the ID of the request message
*/
public signTransactions(params: ISignTransactionsParams): string {
- return this.sendRequestMessage({
+ return this._sendRequestMessage({
method: ARC0027MethodEnum.SignTransactions,
params,
});
diff --git a/src/controllers/AVMWebProvider.test.ts b/src/controllers/AVMWebProvider.test.ts
index 44f1686..dcb09c8 100644
--- a/src/controllers/AVMWebProvider.test.ts
+++ b/src/controllers/AVMWebProvider.test.ts
@@ -1,4 +1,5 @@
import { randomBytes } from 'crypto';
+import { v4 as uuid } from 'uuid';
// controllers
import AVMWebClient from './AVMWebClient';
@@ -15,7 +16,7 @@ import type {
} from '@app/types';
describe(AVMWebProvider.name, () => {
- const providerId: string = '02657eaf-be17-4efc-b0a4-19d654b2448e';
+ const providerId = '02657eaf-be17-4efc-b0a4-19d654b2448e';
let client: AVMWebClient;
let provider: AVMWebProvider;
@@ -56,7 +57,43 @@ describe(AVMWebProvider.name, () => {
});
describe(`${AVMWebProvider.name}#onDisable`, () => {
- it('should receive the client request', (done) => {
+ it('should not receive the client request, if a different provider id is provided', () => {
+ // arrange
+ const callback = jest.fn();
+
+ provider = AVMWebProvider.init(providerId);
+ client = AVMWebClient.init();
+
+ provider.onDisable(callback);
+
+ // act
+ client.disable({
+ providerId: uuid(), // call random provider
+ });
+
+ // assert
+ expect(callback.mock.calls.length).toBe(0);
+ });
+
+ it('should receive the client request, if the matching provider id is provided', (done) => {
+ // arrange
+ provider = AVMWebProvider.init(providerId);
+ client = AVMWebClient.init();
+
+ // assert
+ provider.onDisable(({ method }) => {
+ expect(method).toBe(ARC0027MethodEnum.Disable);
+
+ return done();
+ });
+
+ // act
+ client.disable({
+ providerId,
+ });
+ });
+
+ it('should receive the client request, if no provider id is provided', (done) => {
// arrange
provider = AVMWebProvider.init(providerId);
client = AVMWebClient.init();
@@ -92,6 +129,42 @@ describe(AVMWebProvider.name, () => {
});
describe(`${AVMWebProvider.name}#onEnable`, () => {
+ it('should not receive the client request, if a different provider id is provided', () => {
+ // arrange
+ const callback = jest.fn();
+
+ provider = AVMWebProvider.init(providerId);
+ client = AVMWebClient.init();
+
+ provider.onEnable(callback);
+
+ // act
+ client.enable({
+ providerId: uuid(), // call random provider
+ });
+
+ // assert
+ expect(callback.mock.calls.length).toBe(0);
+ });
+
+ it('should receive the client request, if the matching provider id is provided', (done) => {
+ // arrange
+ provider = AVMWebProvider.init(providerId);
+ client = AVMWebClient.init();
+
+ // assert
+ provider.onEnable(({ method }) => {
+ expect(method).toBe(ARC0027MethodEnum.Enable);
+
+ return done();
+ });
+
+ // act
+ client.enable({
+ providerId,
+ });
+ });
+
it('should receive the client request', (done) => {
// arrange
provider = AVMWebProvider.init(providerId);
@@ -110,6 +183,26 @@ describe(AVMWebProvider.name, () => {
});
describe(`${AVMWebProvider.name}#onPostTransactions`, () => {
+ it('should not receive the client request, if a different provider id is provided', () => {
+ // arrange
+ const callback = jest.fn();
+ const stxns: string[] = ['gqNzaWfEQ...'];
+
+ provider = AVMWebProvider.init(providerId);
+ client = AVMWebClient.init();
+
+ provider.onPostTransactions(callback);
+
+ // act
+ client.postTransactions({
+ providerId: uuid(), // call random provider
+ stxns,
+ });
+
+ // assert
+ expect(callback.mock.calls.length).toBe(0);
+ });
+
it('should receive the client request', (done) => {
// arrange
const stxns: string[] = ['gqNzaWfEQ...'];
@@ -136,6 +229,34 @@ describe(AVMWebProvider.name, () => {
});
describe(`${AVMWebProvider.name}#onSignAndPostTransactions`, () => {
+ it('should not receive the client request, if a different provider id is provided', () => {
+ // arrange
+ const callback = jest.fn();
+ const txns: IARC0001Transaction[] = [
+ {
+ txn: randomBytes(32).toString('base64'),
+ },
+ {
+ txn: randomBytes(32).toString('base64'),
+ signers: [],
+ },
+ ];
+
+ provider = AVMWebProvider.init(providerId);
+ client = AVMWebClient.init();
+
+ provider.onSignAndPostTransactions(callback);
+
+ // act
+ client.signAndPostTransactions({
+ providerId: uuid(), // call random provider
+ txns,
+ });
+
+ // assert
+ expect(callback.mock.calls.length).toBe(0);
+ });
+
it('should receive the client request', (done) => {
// arrange
const txns: IARC0001Transaction[] = [
@@ -170,6 +291,27 @@ describe(AVMWebProvider.name, () => {
});
describe(`${AVMWebProvider.name}#onSignMessage`, () => {
+ it('should receive the client request', () => {
+ // arrange
+ const callback = jest.fn();
+ const params: ISignMessageParams = {
+ message: 'Hello humie!',
+ providerId: uuid(), // call random provider
+ signer: 'P3AIQVDJ2CTH54KSJE63YWB7IZGS4W4JGC53I6GK72BGZ5BXO2B2PS4M4U',
+ };
+
+ provider = AVMWebProvider.init(providerId);
+ client = AVMWebClient.init();
+
+ provider.onSignMessage(callback);
+
+ // act
+ client.signMessage(params);
+
+ // assert
+ expect(callback.mock.calls.length).toBe(0);
+ });
+
it('should receive the client request', (done) => {
// arrange
const params: ISignMessageParams = {
@@ -196,6 +338,34 @@ describe(AVMWebProvider.name, () => {
});
describe(`${AVMWebProvider.name}#onSignTransactions`, () => {
+ it('should not receive the client request, if a different provider id is provided', () => {
+ // arrange
+ const callback = jest.fn();
+ const txns: IARC0001Transaction[] = [
+ {
+ txn: randomBytes(32).toString('base64'),
+ },
+ {
+ txn: randomBytes(32).toString('base64'),
+ signers: [],
+ },
+ ];
+
+ provider = AVMWebProvider.init(providerId);
+ client = AVMWebClient.init();
+
+ provider.onSignTransactions(callback);
+
+ // act
+ client.signTransactions({
+ providerId: uuid(), // call random provider
+ txns,
+ });
+
+ // assert
+ expect(callback.mock.calls.length).toBe(0);
+ });
+
it('should receive the client request', (done) => {
// arrange
const txns: IARC0001Transaction[] = [
diff --git a/src/controllers/AVMWebProvider.ts b/src/controllers/AVMWebProvider.ts
index 875e58a..f994609 100644
--- a/src/controllers/AVMWebProvider.ts
+++ b/src/controllers/AVMWebProvider.ts
@@ -51,32 +51,35 @@ export default class AVMWebProvider extends BaseController(
+ private _addListener<
+ Params extends TRequestParams,
+ Result extends TResponseResults,
+ >(
method: ARC0027MethodEnum,
callback: TAVMWebProviderCallback
): string {
- const _functionName: string = 'addListener';
- const listener: TProviderCustomEventListener = (event) => {
- this.logger.debug(
- `${AVMWebProvider.name}#${_functionName}: received request event:`,
+ const _functionName = '_addListener';
+ const listener: TProviderCustomEventListener = (event) => {
+ this._logger.debug(
+ `[${this._config.providerId}]${AVMWebProvider.name}#${_functionName}: received request event:`,
event.detail
);
- return this.sendResponseMessage({
+ return this._sendResponseMessage({
callback,
method,
requestMessage: event.detail as RequestMessage,
});
};
- const listenerID: string = uuid();
- const reference: string = createMessageReference(
+ const listenerID = uuid();
+ const reference = createMessageReference(
method,
ARC0027MessageTypeEnum.Request
);
// start listening to request events and add the listener to the map
window.addEventListener(reference, listener);
- this.listeners.set(listenerID, {
+ this._listeners.set(listenerID, {
listener,
reference,
});
@@ -92,22 +95,34 @@ export default class AVMWebProvider extends BaseController({
callback,
method,
requestMessage,
}: ISendResponseMessageOptions): Promise {
- const _functionName: string = 'sendResponseMessage';
- const id: string = uuid();
- const reference: string = createMessageReference(
- method,
- ARC0027MessageTypeEnum.Response
- );
+ const _functionName = '_sendResponseMessage';
+ let id: string;
+ let reference: string;
let result: Result;
+ // if the provider id is supplied in the request, and it does not match the registered provider id, ignore
+ if (
+ requestMessage.params?.providerId &&
+ requestMessage.params.providerId !== this._config.providerId
+ ) {
+ this._logger.debug(
+ `[${this._config.providerId}]${AVMWebProvider.name}#${_functionName}: message "${requestMessage.reference}" is for provider "${requestMessage.params.providerId}", skipping`
+ );
+
+ return;
+ }
+
+ id = uuid();
+ reference = createMessageReference(method, ARC0027MessageTypeEnum.Response);
+
try {
result = await callback({
id: requestMessage.id,
@@ -129,13 +144,13 @@ export default class AVMWebProvider extends BaseController
): string {
- return this.addListener(
+ return this._addListener(
ARC0027MethodEnum.Disable,
callback
);
@@ -218,7 +233,7 @@ export default class AVMWebProvider extends BaseController
): string {
- return this.addListener(
+ return this._addListener(
ARC0027MethodEnum.Discover,
callback
);
@@ -233,7 +248,7 @@ export default class AVMWebProvider extends BaseController
): string {
- return this.addListener(
+ return this._addListener(
ARC0027MethodEnum.Enable,
callback
);
@@ -251,7 +266,7 @@ export default class AVMWebProvider extends BaseController
): string {
- return this.addListener(
+ return this._addListener(
ARC0027MethodEnum.PostTransactions,
callback
);
@@ -269,7 +284,7 @@ export default class AVMWebProvider extends BaseController
): string {
- return this.addListener(
+ return this._addListener(
ARC0027MethodEnum.SignAndPostTransactions,
callback
);
@@ -284,7 +299,7 @@ export default class AVMWebProvider extends BaseController
): string {
- return this.addListener(
+ return this._addListener(
ARC0027MethodEnum.SignMessage,
callback
);
@@ -302,7 +317,7 @@ export default class AVMWebProvider extends BaseController
): string {
- return this.addListener(
+ return this._addListener(
ARC0027MethodEnum.SignTransactions,
callback
);
diff --git a/src/controllers/BaseController.ts b/src/controllers/BaseController.ts
index 1983a56..c45ffbf 100644
--- a/src/controllers/BaseController.ts
+++ b/src/controllers/BaseController.ts
@@ -5,14 +5,14 @@ import Logger from './Logger';
import type { IBaseConfig, IListenerItem } from '@app/types';
export default abstract class BaseController {
- protected readonly config: Config;
- protected readonly listeners: Map;
- protected logger: Logger;
+ protected readonly _config: Config;
+ protected readonly _listeners: Map;
+ protected _logger: Logger;
protected constructor(config: Config) {
- this.config = config;
- this.listeners = new Map();
- this.logger = new Logger(config.debug ? 'debug' : 'error');
+ this._config = config;
+ this._listeners = new Map();
+ this._logger = new Logger(config.debug ? 'debug' : 'error');
}
/**
@@ -24,7 +24,7 @@ export default abstract class BaseController {
* @returns {Config} the current configuration.
*/
public getConfig(): Config {
- return this.config;
+ return this._config;
}
/**
@@ -32,12 +32,12 @@ export default abstract class BaseController {
*/
public removeAllListeners(): void {
// remove all the listeners
- this.listeners.forEach(({ listener, reference }) =>
+ this._listeners.forEach(({ listener, reference }) =>
window.removeEventListener(reference, listener)
);
// clear the map
- this.listeners.clear();
+ this._listeners.clear();
}
/**
@@ -45,7 +45,7 @@ export default abstract class BaseController {
* @param {string} id - the listener ID to remove.
*/
public removeListener(id: string): void {
- const item: IListenerItem | null = this.listeners.get(id) || null;
+ const item: IListenerItem | null = this._listeners.get(id) || null;
if (!item) {
return;
@@ -53,6 +53,6 @@ export default abstract class BaseController {
// remove the listener from the dom and the map
window.removeEventListener(item.reference, item.listener);
- this.listeners.delete(id);
+ this._listeners.delete(id);
}
}
diff --git a/src/controllers/Logger.ts b/src/controllers/Logger.ts
index f2e2185..bdc9c26 100644
--- a/src/controllers/Logger.ts
+++ b/src/controllers/Logger.ts
@@ -4,10 +4,10 @@
import type { TLogLevel } from '@app/types';
export default class Logger {
- private readonly level: TLogLevel;
+ private readonly _level: TLogLevel;
constructor(level: TLogLevel) {
- this.level = level;
+ this._level = level;
}
/**
@@ -15,7 +15,7 @@ export default class Logger {
*/
private canLog(allowedLevel: TLogLevel): boolean {
- switch (this.level) {
+ switch (this._level) {
case 'error':
return allowedLevel === 'error';
case 'warn':
diff --git a/src/types/ISendRequestMessageOptions.ts b/src/types/ISendRequestMessageOptions.ts
index 13c61b6..d1c5fc8 100644
--- a/src/types/ISendRequestMessageOptions.ts
+++ b/src/types/ISendRequestMessageOptions.ts
@@ -4,10 +4,10 @@ import { ARC0027MethodEnum } from '@app/enums';
// types
import type TRequestParams from './TRequestParams';
-interface SendRequestMessageOptions {
+interface ISendRequestMessageOptions {
method: ARC0027MethodEnum;
params?: Params;
timeout?: number;
}
-export default SendRequestMessageOptions;
+export default ISendRequestMessageOptions;
diff --git a/src/types/TAVMWebProviderCallback.ts b/src/types/TAVMWebProviderCallback.ts
index 48c5528..397ff7d 100644
--- a/src/types/TAVMWebProviderCallback.ts
+++ b/src/types/TAVMWebProviderCallback.ts
@@ -5,7 +5,7 @@ import type TResponseResults from './TResponseResults';
type TAVMWebProviderCallback<
Params = TRequestParams,
- Result = TResponseResults,
+ Result = TResponseResults | void,
> = (
options: IAVMWebProviderCallbackOptions
) => Result | Promise;