diff --git a/404.html b/404.html index cf6897d..6096520 100644 --- a/404.html +++ b/404.html @@ -2,15 +2,15 @@ - -AVM Web Provider - - + +AVM Web Provider + + -
Skip to main content

Page Not Found

We could not find what you were looking for.

Please contact the owner of the site that linked you to the original URL and let them know their link is broken.

diff --git a/clients/discover-providers.html b/clients/discover-providers.html index 2bf3016..1142b3b 100644 --- a/clients/discover-providers.html +++ b/clients/discover-providers.html @@ -2,13 +2,13 @@ - -Discover Providers | AVM Web Provider - - + +Discover Providers | AVM Web Provider + + -
Skip to main content

Discover Providers

+

Discover Providers

Overview

Before we can start interacting with a provider, we first need to find out what providers are available and what AVM networks & methods these providers support.

@@ -18,9 +18,9 @@

Di

Discovering a specific provider

If you know the ID of the provider, you can request only a response from that provider.

As before, let's first add a listener and then broadcast, but this time we will specify the provider ID:

-
const providerId = '02657eaf-be17-4efc-b0a4-19d654b2448e';

// initialized client
client.onDiscover(({ error, result }) => {
if (error) {
console.error('error:', error);

return;
}

console.log(result);
/*
{
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',
}
*/
});

// send a discover request
client.discover({ providerId });
diff --git a/clients/enabling-a-client.html b/clients/enabling-a-client.html index b4cd2d9..4e35786 100644 --- a/clients/enabling-a-client.html +++ b/clients/enabling-a-client.html @@ -2,13 +2,13 @@ - -Enabling A Client | AVM Web Provider - - + +Enabling A Client | AVM Web Provider + + -
Skip to main content

Enabling A Client

+

Enabling A Client

Overview

Before we can start interacting with a provider, we need ask the provider to enable the client. This will achieve two things:

@@ -28,9 +28,9 @@

Enabling a client on a specific network

If you want to target a specific network, and any providers support it, you can simply pass the genesis hash of the network in the params:

const genesisHash = 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=';

// initialized client
client.onEnable(({ error, result }) => {
if (error) {
console.error('error:', error);

return;
}

console.log(result);
/*
{
accounts: [
{
address: 'P3AIQVDJ2CTH54KSJE63YWB7IZGS4W4JGC53I6GK72BGZ5BXO2B2PS4M4U',
name: 'Wallet-1',
},
{
address: '6GT6EXFDAHZDZYUOPT725ZRWYBZDCEGYT7SYYXGJKRFUAG5B7JMI7DQRNQ',
name: 'Wallet-2',
},
],
genesisHash: 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=',
genesisId: 'testnet-v1.0',
providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e',
sessionId: 'ab192498-0c63-4028-80fd-f148710611d8',
}
*/
});

// send a enable request
client.enable({ genesisHash });
-
caution

If the network and the provider ID is specified, and the provider does not support the network, then a NetworkNotSupportedError should be thrown.

diff --git a/clients/getting-started.html b/clients/getting-started.html index de272ed..81e0870 100644 --- a/clients/getting-started.html +++ b/clients/getting-started.html @@ -2,13 +2,13 @@ - -Getting Started | AVM Web Provider - - + +Getting Started | AVM Web Provider + + -
Skip to main content

Getting Started

+

Getting Started

Installation

Using a package manager

@@ -20,9 +20,9 @@

Download

Initialization

Firstly, we want to initialize the AVM web client:

const { AVMWebClient } = require('@agoralabs-sh/avm-web-provider');

const client = AVMWebClient.init();
-
note

See IAVMWebClientInitOptions for more information on what options are supported.

diff --git a/clients/posting-transactions.html b/clients/posting-transactions.html index ea77905..da07242 100644 --- a/clients/posting-transactions.html +++ b/clients/posting-transactions.html @@ -2,13 +2,13 @@ - -Posting Transactions | AVM Web Provider - - + +Posting Transactions | AVM Web Provider + + -
Skip to main content

Posting Transactions

+

Posting Transactions

Overview

Providers, if supported, can commit transactions to the network using their connection to a node.

@@ -16,9 +16,9 @@

note

Posting transactions requires the ID of the provider.

// initialized client
client.onPostTransactions(({ error, result }) => {
if (error) {
console.error('error:', error);

return;
}

console.log(result);
/*
{
providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e',
txnIDs: [
'OKU6A2Q...',
],
}
*/
});

// send a post transactions request
client.postTransactions({
providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e',
stxns: [
'gqNzaWfEQ...',
],
});
caution

If this method is not supported, then a MethodNotSupportedError should be thrown.

-
caution

If the transactions fail to be accepted by the network, then a FailedToPostSomeTransactionsError should be thrown.

diff --git a/clients/signing-a-message.html b/clients/signing-a-message.html index df1ca74..81aa5c4 100644 --- a/clients/signing-a-message.html +++ b/clients/signing-a-message.html @@ -2,22 +2,22 @@ - -Signing A Message | AVM Web Provider - - + +Signing A Message | AVM Web Provider + + -
Skip to main content

Signing A Message

+

Signing A Message

Overview

Providers, if supported, can sign an arbitrary UTF-8 string.

Signing a message

// initialized client
client.onSignMessage(({ error, result }) => {
if (error) {
console.error('error:', error);

return;
}

console.log(result);
/*
{
providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e',
signature: 'gqNzaWfEQ...',
signer: 'P3AIQVDJ2CTH54KSJE63YWB7IZGS4W4JGC53I6GK72BGZ5BXO2B2PS4M4U',
}
*/
});

// send a sign message request
client.signMessage({
message: 'Hello humie!',
providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e',
signer: 'P3AIQVDJ2CTH54KSJE63YWB7IZGS4W4JGC53I6GK72BGZ5BXO2B2PS4M4U',
});
caution

If this method is not supported, then a MethodNotSupportedError will be sent in the error parameter.

-
caution

If the signer is not known, or not authorized, then a UnauthorizedSignerError will be sent in the error parameter.

diff --git a/clients/signing-and-posting-transactions.html b/clients/signing-and-posting-transactions.html index e5ddb89..c4712bd 100644 --- a/clients/signing-and-posting-transactions.html +++ b/clients/signing-and-posting-transactions.html @@ -2,13 +2,13 @@ - -Signing And Posting Transactions | AVM Web Provider - - + +Signing And Posting Transactions | AVM Web Provider + + -
Skip to main content

Signing And Posting Transactions

+

Signing And Posting Transactions

Overview

Providers may have the functionality to both sign & post transactions. This method allows clients to avoid using the previous methods of signing transactions and posting transactions separately and simply performs the functionality of these previous methods within one method.

@@ -18,9 +18,9 @@

caution

If this method is not supported, then a MethodNotSupportedError should be thrown.

caution

If there is a group of atomic transactions, but the computed group ID is invalid, then a InvalidGroupIdError should be thrown.

caution

If any of the transactions are malformed, then a InvalidInputError should be thrown.

-
caution

If the transactions fail to be accepted by the network, then a FailedToPostSomeTransactionsError should be thrown.

diff --git a/clients/signing-transactions.html b/clients/signing-transactions.html index c6c11df..21ac33b 100644 --- a/clients/signing-transactions.html +++ b/clients/signing-transactions.html @@ -2,13 +2,13 @@ - -Signing Transactions | AVM Web Provider - - + +Signing Transactions | AVM Web Provider + + -
Skip to main content

Signing Transactions

+

Signing Transactions

Overview

Providers, if supported, can sign single, atomic or multiple transactions. If the provider also supports it, the provider can also sign transactions using multisigs and re-keyed accounts.

@@ -40,9 +40,9 @@

caution

The provider may not support re-keyed accounts, in which case a MethodNotSupportedError will be thrown.

const algosdk = require('algosdk');

try {
const client = new algosdk.Algodv2(
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'http://localhost',
'4001',
);
const encoder = new TextEncoder();
const suggestedParams = await client.getTransactionParams().do();
const transaction = algosdk.makePaymentTxnWithSuggestedParamsFromObject({
amount: algosdk.algosToMicroalgos(1),
from: 'P3AIQVDJ2CTH54KSJE63YWB7IZGS4W4JGC53I6GK72BGZ5BXO2B2PS4M4U',
note: encoder.encode('Hello Human!'),
suggestedParams,
to: '6GT6EXFDAHZDZYUOPT725ZRWYBZDCEGYT7SYYXGJKRFUAG5B7JMI7DQRNQ',
});
const transactionBytes = transaction.toByte();
} catch (error) {
// handle error
}

// initialized client
client.onSignTransactions(({ error, result }) => {
if (error) {
console.error('error:', error);

return;
}

console.log(result);
/*
{
providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e',
stxns: [
'gqNzaWfEQ...',
],
}
*/
});

// send a sign transactions request
client.signTransactions({
providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e',
txns: [
{
authAddr: 'S6V2ITXD3Q4MYATTN5IH75E3KS3WEMB36SVG2LXCQ3XESSH2DYOC3DAXYU', // 'auth-addr' of the re-keyed from account
txn: btoa(String.fromCodePoint(...transactionBytes)), // convert to base64 string
},
],
});
-
caution

If the supplied authAddr is not an authorized signer, then a UnauthorizedSignerError will be thrown.

diff --git a/index.html b/index.html index 516b193..c65f40a 100644 --- a/index.html +++ b/index.html @@ -2,14 +2,13 @@ - -Overview | AVM Web Provider - - + +Overview | AVM Web Provider + + -
Skip to main content

Overview

- +

Overview

Introduction

@@ -25,9 +24,9 @@

How it worksSince the client code and provider code aren’t guaranteed to run in a particular order, the events are designed to handle such race conditions.

Both clients and providers use the window.dispatchEvent function to emit events, and use the window.addEventListener function to observe events.

note

Browser extension providers MUST take advantage of the content scripts that will allow the provider access to the window object.

-

The AVM Web Provider leverages the EventTarget API as a transport layer to deliver messages and allows clients and web-based providers to securely communicate without interfering with other providers.

diff --git a/providers.html b/providers.html index 2a5a1d4..ec6e7b9 100644 --- a/providers.html +++ b/providers.html @@ -2,13 +2,13 @@ - -Providers | AVM Web Provider - - + +Providers | AVM Web Provider + + -
Skip to main content

Providers

+
diff --git a/providers/getting-started.html b/providers/getting-started.html index 47aacd9..32cb780 100644 --- a/providers/getting-started.html +++ b/providers/getting-started.html @@ -2,13 +2,13 @@ - -Getting Started | AVM Web Provider - - + +Getting Started | AVM Web Provider + + -
Skip to main content

Getting Started

+

Getting Started

Installation

Using a package manager

@@ -21,9 +21,9 @@

Initializatio

Firstly, we want to initialize the AVM web provider with an ID:

const { AVMWebProvider } = require('@agoralabs-sh/avm-web-provider');

const provider = AVMWebProvider.init('02657eaf-be17-4efc-b0a4-19d654b2448e');
note

The provider ID is what will identify your provider with clients. It is recommended that you use a UUIDv4 compliant string.

-
note

See IAVMWebProviderInitOptions for more information on what options are supported.

diff --git a/providers/responding-to-disable-requests.html b/providers/responding-to-disable-requests.html index 3d9d025..6a18dee 100644 --- a/providers/responding-to-disable-requests.html +++ b/providers/responding-to-disable-requests.html @@ -2,31 +2,31 @@ - -Responding To Disable Requests | AVM Web Provider - - + +Responding To Disable Requests | AVM Web Provider + + -
Skip to main content

Responding To Disable Requests

- +

Responding To Disable Requests

+

Overview

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

-

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:

-
// initialized provider
provider.onDisable(({ params }) => {
if (!params || !params.providerId) {
// ... remove all sessions

return {
genesisHash: 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=',
genesisId: 'testnet-v1.0',
providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e',
};
}
});
+

Responding to a disable request

+

Once our provider object has been initialized, we can simply listen to events and respond:

+
// initialized provider
provider.onDisable(() => {
// ... remove all sessions

return {
genesisHash: 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=',
genesisId: 'testnet-v1.0',
providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e',
};
});
note

If no network or session IDs have been specified, you can assume all sessions for this client should be removed.

caution

If this method is not supported, then a MethodNotSupportedError should be thrown.

-

Responding to a specific provider and network request

-

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:

-
const { ARC0027NetworkNotSupportedError } = require('@agoralabs-sh/avm-web-provider');

const genesisHash = 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=';
const providerId = '02657eaf-be17-4efc-b0a4-19d654b2448e';

// initialized provider
provider.onDisable(({ params }) => {
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',
providerId,
};
}
});
-
caution

If the network and the provider ID is specified, and the provider does not support the network, then a NetworkNotSupportedError should be thrown.

+

Responding to a disable request with a specific network

+

The disable request allows the client to specify the network. This is denoted in the supplied params.genesisHash parameter.

+
const { ARC0027NetworkNotSupportedError } = require('@agoralabs-sh/avm-web-provider');

const genesisHash = 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=';
const providerId = '02657eaf-be17-4efc-b0a4-19d654b2448e';

// initialized provider
provider.onDisable(({ 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,
});
}

// ... remove all sessions for the network

return {
genesisHash,
genesisId: 'testnet-v1.0',
providerId,
};
});
+
caution

If the network is specified, and the provider does not support the network, then a NetworkNotSupportedError should be thrown.

Responding to specific session IDs

A requesting client can specify the particular session. This can be used instead of specifying the network, or if the provider supports multiple sessions.

-
const providerId = '02657eaf-be17-4efc-b0a4-19d654b2448e';
const sessionId = '2802dff6-930e-4f79-8f67-ba9d41e88cf8';

// initialized provider
provider.onDisable(({ params }) => {
if (params && params.sessionIds.indexOf(sessionId) >= 0) {
// ... remove sessions specified in the session ids list

return {
genesisHash: 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=',
genesisId: 'testnet-v1.0',
providerId,
sessionIds: [sessionId],
};
}
});
-
note

It is recommended that when removing specific session IDs, only return the removed session IDs in the result.

diff --git a/providers/responding-to-discover-requests.html b/providers/responding-to-discover-requests.html index 4264988..c8193bf 100644 --- a/providers/responding-to-discover-requests.html +++ b/providers/responding-to-discover-requests.html @@ -2,24 +2,21 @@ - -Responding To Discover Requests | AVM Web Provider - - + +Responding To Discover Requests | AVM Web Provider + + -
Skip to main content

Responding To Discover Requests

- +

Responding To Discover Requests

+

Overview

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

-

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:

-
// initialized provider
provider.onDiscover(({ params }) => {
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',
};
}
});
-

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:

-
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,
};
}
});
diff --git a/providers/responding-to-enable-requests.html b/providers/responding-to-enable-requests.html index 71d63c7..0854e44 100644 --- a/providers/responding-to-enable-requests.html +++ b/providers/responding-to-enable-requests.html @@ -2,25 +2,26 @@ - -Responding To Enable Requests | AVM Web Provider - - + +Responding To Enable Requests | AVM Web Provider + + -
Skip to main content

Responding To Enable Requests

- +

Responding To Enable Requests

+

Overview

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

-

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:

-
// initialized provider
provider.onEnable(({ params }) => {
if (!params || !params.providerId) {
return {
accounts: [
{
address: 'P3AIQVDJ2CTH54KSJE63YWB7IZGS4W4JGC53I6GK72BGZ5BXO2B2PS4M4U',
name: 'Wallet-1',
},
{
address: '6GT6EXFDAHZDZYUOPT725ZRWYBZDCEGYT7SYYXGJKRFUAG5B7JMI7DQRNQ',
name: 'Wallet-2',
},
],
genesisHash: 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=',
genesisId: 'testnet-v1.0',
providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e',
};
}
});
+

Responding to an enable request

+

Once our provider object has been initialized, we can simply listen to events and respond:

+
// initialized provider
provider.onEnable(({ params }) => {
return {
accounts: [
{
address: 'P3AIQVDJ2CTH54KSJE63YWB7IZGS4W4JGC53I6GK72BGZ5BXO2B2PS4M4U',
name: 'Wallet-1',
},
{
address: '6GT6EXFDAHZDZYUOPT725ZRWYBZDCEGYT7SYYXGJKRFUAG5B7JMI7DQRNQ',
name: 'Wallet-2',
},
],
genesisHash: 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=',
genesisId: 'testnet-v1.0',
providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e',
};
});
caution

If this method is not supported, then a MethodNotSupportedError should be thrown.

-

Responding to a specific provider request

-

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:

-
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,
};
}
});
diff --git a/providers/responding-to-post-transactions-requests.html b/providers/responding-to-post-transactions-requests.html index 4b6ef0f..c00191a 100644 --- a/providers/responding-to-post-transactions-requests.html +++ b/providers/responding-to-post-transactions-requests.html @@ -2,25 +2,25 @@ - -Responding To Post Transactions Requests | AVM Web Provider - - + +Responding To Post Transactions Requests | AVM Web Provider + + -
Skip to main content

Responding To Post Transactions Requests

+

Responding To Post Transactions Requests

Overview

As a provider usually has access to the network, the post_transactions method allows clients to rely on the provider to send transactions to the network.

Responding to a post transactions request

Once our provider object has been initialized, we can simply listen to events and respond:

-
const providerId = '02657eaf-be17-4efc-b0a4-19d654b2448e';

// initialized provider
provider.onPostTransactions(({ params }) => {
if (params.providerId === providerId) {
// ... using the `params.stxns` parameter, the provider posts the transactions to the network and returns the transaction ids

return {
providerId,
txnIDs: [
'OKU6A2Q...',
],
};
}
});
+
const providerId = '02657eaf-be17-4efc-b0a4-19d654b2448e';

// initialized provider
provider.onPostTransactions(({ params }) => {
// ... using the `params.stxns` parameter, the provider posts the transactions to the network and returns the transaction ids

return {
providerId,
txnIDs: [
'OKU6A2Q...',
],
};
});
caution

If this method is not supported, then a MethodNotSupportedError should be thrown.

caution

If there is a group of atomic transactions, but the computed group ID doesn't match the assigned ID, then a InvalidGroupIdError should be thrown.

caution

If any of the transactions are malformed, then a InvalidInputError should be thrown.

-
caution

If the transactions fail to be accepted by the network, then a FailedToPostSomeTransactionsError should be thrown.

diff --git a/providers/responding-to-sign-and-post-transactions-requests.html b/providers/responding-to-sign-and-post-transactions-requests.html index f0456e6..5a296eb 100644 --- a/providers/responding-to-sign-and-post-transactions-requests.html +++ b/providers/responding-to-sign-and-post-transactions-requests.html @@ -2,25 +2,25 @@ - -Responding To Sign And Post Transactions Requests | AVM Web Provider - - + +Responding To Sign And Post Transactions Requests | AVM Web Provider + + -
Skip to main content

Responding To Sign And Post Transactions Requests

+

Responding To Sign And Post Transactions Requests

Overview

If your provider is able to both sign and post transactions, this method can simply be implemented to allow clients to perform both these methods within one method.

Responding to a sign and post transactions request

Once our provider object has been initialized, we can simply listen to events and respond:

-
const providerId = '02657eaf-be17-4efc-b0a4-19d654b2448e';

// initialized provider
provider.onSignAndPostTransactions(({ params }) => {
if (params.providerId === providerId) {
// ... using the `params.txns` parameter, the provider signs and posts the transactions to the network and returns the transaction ids

return {
providerId,
txnIDs: [
'OKU6A2Q...',
],
};
}
});
+
const providerId = '02657eaf-be17-4efc-b0a4-19d654b2448e';

// 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 {
providerId,
txnIDs: [
'OKU6A2Q...',
],
};
});
caution

If this method is not supported, then a MethodNotSupportedError should be thrown.

caution

If there is a group of atomic transactions, but the computed group ID doesn't match the assigned ID, then a InvalidGroupIdError should be thrown.

caution

If any of the transactions are malformed, then a InvalidInputError should be thrown.

-
caution

If the transactions fail to be accepted by the network, then a FailedToPostSomeTransactionsError should be thrown.

diff --git a/providers/responding-to-sign-message-requests.html b/providers/responding-to-sign-message-requests.html index 7b7fcdb..03b5181 100644 --- a/providers/responding-to-sign-message-requests.html +++ b/providers/responding-to-sign-message-requests.html @@ -2,21 +2,21 @@ - -Responding To Sign Message Requests | AVM Web Provider - - + +Responding To Sign Message Requests | AVM Web Provider + + -
Skip to main content

Responding To Sign Message Requests

+

Responding To Sign Message Requests

Responding to a sign message request

Once our provider object has been initialized, we can simply listen to events and respond:

-
const providerId = '02657eaf-be17-4efc-b0a4-19d654b2448e';

// initialized provider
provider.onSignMessage(({ params }) => {
if (params.providerId === providerId) {
// ... 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 {
providerId,
signature: 'gqNzaWfEQ...', // base64 encoded signature
signer: 'P3AIQVDJ2CTH54KSJE63YWB7IZGS4W4JGC53I6GK72BGZ5BXO2B2PS4M4U',
};
}
});
+
const providerId = '02657eaf-be17-4efc-b0a4-19d654b2448e';

// 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 {
providerId,
signature: 'gqNzaWfEQ...', // base64 encoded signature
signer: 'P3AIQVDJ2CTH54KSJE63YWB7IZGS4W4JGC53I6GK72BGZ5BXO2B2PS4M4U',
};
});
caution

If this method is not supported, then a MethodNotSupportedError should be thrown.

-
caution

If the signer, supplied in the params, is not known, or not authorized, a UnauthorizedSignerError should be thrown.

diff --git a/providers/responding-to-sign-transactions-requests.html b/providers/responding-to-sign-transactions-requests.html index ca317ef..1483115 100644 --- a/providers/responding-to-sign-transactions-requests.html +++ b/providers/responding-to-sign-transactions-requests.html @@ -2,22 +2,22 @@ - -Responding To Sign Transactions Requests | AVM Web Provider - - + +Responding To Sign Transactions Requests | AVM Web Provider + + -
Skip to main content

Responding To Sign Transactions Requests

+

Responding To Sign Transactions Requests

Responding to a sign transactions request

Once our provider object has been initialized, we can simply listen to events and respond:

-
const providerId = '02657eaf-be17-4efc-b0a4-19d654b2448e';

// initialized provider
provider.onSignTransactions(({ params }) => {
if (params.providerId === providerId) {
// ... using the `params.txns` parameter, the provider signs the transactions and returns the base64 encoded signed transactions

return {
providerId,
stxns: [
'gqNzaWfEQ...',
],
};
}
});
+
const providerId = '02657eaf-be17-4efc-b0a4-19d654b2448e';

// initialized provider
provider.onSignTransactions(({ params }) => {
// ... using the `params.txns` parameter, the provider signs the transactions and returns the base64 encoded signed transactions

return {
providerId,
stxns: [
'gqNzaWfEQ...',
],
};
});
caution

If this method is not supported, then a MethodNotSupportedError should be thrown.

caution

If there is a group of atomic transactions, but the computed group ID doesn't match the assigned ID, then a InvalidGroupIdError should be thrown.

-
caution

If any of the transactions are malformed, then a InvalidInputError should be thrown.

diff --git a/providers/throwing-an-error.html b/providers/throwing-an-error.html index d8d0c82..ceb7035 100644 --- a/providers/throwing-an-error.html +++ b/providers/throwing-an-error.html @@ -2,21 +2,21 @@ - -Throwing An Error | AVM Web Provider - - + +Throwing An Error | AVM Web Provider + + -
Skip to main content

Throwing An Error

+

Throwing An Error

Overview

When receiving a request from the client, you can throw errors within the listener function and these errors will propagate back to the client's listener arguments.

Throwing an error

// AVMWebClient
client.onDisable(({ error, result }) => {
if (error) {
console.error(error);
/*
{
code: 4003,
data: {
method: 'disable',
},
message: 'disable method is not supported',
name: 'MethodNotSupportedError',
providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e',
}
*/

return;
}
});

// send a client request
client.disable();

// AVMWebProvider
const { ARC0027MethodSupportedError } = require('@agoralabs-sh/avm-web-provider');

provider.onDisable(({ params }) => {
throw new ARC0027MethodSupportedError({
method: 'disable',
message: 'disable method is not supported',
providerId: '02657eaf-be17-4efc-b0a4-19d654b2448e',
});
});
-
note

The SDK provides several common errors, see errors.

diff --git a/sitemap.xml b/sitemap.xml index 8ea652a..c1affb4 100644 --- a/sitemap.xml +++ b/sitemap.xml @@ -1 +1 @@ -https://avm-web-provider.agoralabs.sh/api-referenceweekly0.5https://avm-web-provider.agoralabs.sh/api-reference/avm-web-clientweekly0.5https://avm-web-provider.agoralabs.sh/api-reference/avm-web-providerweekly0.5https://avm-web-provider.agoralabs.sh/api-reference/errorsweekly0.5https://avm-web-provider.agoralabs.sh/api-reference/typesweekly0.5https://avm-web-provider.agoralabs.sh/clientsweekly0.5https://avm-web-provider.agoralabs.sh/clients/disabling-a-clientweekly0.5https://avm-web-provider.agoralabs.sh/clients/discover-providersweekly0.5https://avm-web-provider.agoralabs.sh/clients/enabling-a-clientweekly0.5https://avm-web-provider.agoralabs.sh/clients/getting-startedweekly0.5https://avm-web-provider.agoralabs.sh/clients/posting-transactionsweekly0.5https://avm-web-provider.agoralabs.sh/clients/signing-a-messageweekly0.5https://avm-web-provider.agoralabs.sh/clients/signing-and-posting-transactionsweekly0.5https://avm-web-provider.agoralabs.sh/clients/signing-transactionsweekly0.5https://avm-web-provider.agoralabs.sh/providersweekly0.5https://avm-web-provider.agoralabs.sh/providers/getting-startedweekly0.5https://avm-web-provider.agoralabs.sh/providers/responding-to-disable-requestsweekly0.5https://avm-web-provider.agoralabs.sh/providers/responding-to-discover-requestsweekly0.5https://avm-web-provider.agoralabs.sh/providers/responding-to-enable-requestsweekly0.5https://avm-web-provider.agoralabs.sh/providers/responding-to-post-transactions-requestsweekly0.5https://avm-web-provider.agoralabs.sh/providers/responding-to-sign-and-post-transactions-requestsweekly0.5https://avm-web-provider.agoralabs.sh/providers/responding-to-sign-message-requestsweekly0.5https://avm-web-provider.agoralabs.sh/providers/responding-to-sign-transactions-requestsweekly0.5https://avm-web-provider.agoralabs.sh/providers/throwing-an-errorweekly0.5https://avm-web-provider.agoralabs.sh/supported-walletsweekly0.5https://avm-web-provider.agoralabs.sh/terminologyweekly0.5https://avm-web-provider.agoralabs.sh/weekly0.5 \ No newline at end of file +https://avm-web-provider.agoralabs.sh/api-referenceweekly0.5https://avm-web-provider.agoralabs.sh/api-reference/avm-web-clientweekly0.5https://avm-web-provider.agoralabs.sh/api-reference/avm-web-providerweekly0.5https://avm-web-provider.agoralabs.sh/api-reference/errorsweekly0.5https://avm-web-provider.agoralabs.sh/api-reference/typesweekly0.5https://avm-web-provider.agoralabs.sh/clientsweekly0.5https://avm-web-provider.agoralabs.sh/clients/disabling-a-clientweekly0.5https://avm-web-provider.agoralabs.sh/clients/discover-providersweekly0.5https://avm-web-provider.agoralabs.sh/clients/enabling-a-clientweekly0.5https://avm-web-provider.agoralabs.sh/clients/getting-startedweekly0.5https://avm-web-provider.agoralabs.sh/clients/posting-transactionsweekly0.5https://avm-web-provider.agoralabs.sh/clients/signing-a-messageweekly0.5https://avm-web-provider.agoralabs.sh/clients/signing-and-posting-transactionsweekly0.5https://avm-web-provider.agoralabs.sh/clients/signing-transactionsweekly0.5https://avm-web-provider.agoralabs.sh/providersweekly0.5https://avm-web-provider.agoralabs.sh/providers/getting-startedweekly0.5https://avm-web-provider.agoralabs.sh/providers/responding-to-disable-requestsweekly0.5https://avm-web-provider.agoralabs.sh/providers/responding-to-discover-requestsweekly0.5https://avm-web-provider.agoralabs.sh/providers/responding-to-enable-requestsweekly0.5https://avm-web-provider.agoralabs.sh/providers/responding-to-post-transactions-requestsweekly0.5https://avm-web-provider.agoralabs.sh/providers/responding-to-sign-and-post-transactions-requestsweekly0.5https://avm-web-provider.agoralabs.sh/providers/responding-to-sign-message-requestsweekly0.5https://avm-web-provider.agoralabs.sh/providers/responding-to-sign-transactions-requestsweekly0.5https://avm-web-provider.agoralabs.sh/providers/throwing-an-errorweekly0.5https://avm-web-provider.agoralabs.sh/supported-walletsweekly0.5https://avm-web-provider.agoralabs.sh/terminologyweekly0.5https://avm-web-provider.agoralabs.sh/usageweekly0.5https://avm-web-provider.agoralabs.sh/usage/clientsweekly0.5https://avm-web-provider.agoralabs.sh/usage/clients/disabling-a-clientweekly0.5https://avm-web-provider.agoralabs.sh/usage/clients/discover-providersweekly0.5https://avm-web-provider.agoralabs.sh/usage/clients/enabling-a-clientweekly0.5https://avm-web-provider.agoralabs.sh/usage/clients/getting-startedweekly0.5https://avm-web-provider.agoralabs.sh/usage/clients/posting-transactionsweekly0.5https://avm-web-provider.agoralabs.sh/usage/clients/signing-a-messageweekly0.5https://avm-web-provider.agoralabs.sh/usage/clients/signing-and-posting-transactionsweekly0.5https://avm-web-provider.agoralabs.sh/usage/clients/signing-transactionsweekly0.5https://avm-web-provider.agoralabs.sh/usage/providersweekly0.5https://avm-web-provider.agoralabs.sh/usage/providers/getting-startedweekly0.5https://avm-web-provider.agoralabs.sh/usage/providers/responding-to-disable-requestsweekly0.5https://avm-web-provider.agoralabs.sh/usage/providers/responding-to-discover-requestsweekly0.5https://avm-web-provider.agoralabs.sh/usage/providers/responding-to-enable-requestsweekly0.5https://avm-web-provider.agoralabs.sh/usage/providers/responding-to-post-transactions-requestsweekly0.5https://avm-web-provider.agoralabs.sh/usage/providers/responding-to-sign-and-post-transactions-requestsweekly0.5https://avm-web-provider.agoralabs.sh/usage/providers/responding-to-sign-message-requestsweekly0.5https://avm-web-provider.agoralabs.sh/usage/providers/responding-to-sign-transactions-requestsweekly0.5https://avm-web-provider.agoralabs.sh/usage/providers/throwing-an-errorweekly0.5https://avm-web-provider.agoralabs.sh/weekly0.5 \ No newline at end of file diff --git a/supported-wallets.html b/supported-wallets.html index e9c7128..986de7c 100644 --- a/supported-wallets.html +++ b/supported-wallets.html @@ -2,16 +2,16 @@ - -Supported Wallets | AVM Web Provider - - + +Supported Wallets | AVM Web Provider + + -
Skip to main content