From f929fc6cecad65014790054a731974217340d6eb Mon Sep 17 00:00:00 2001 From: rabi-siddique Date: Mon, 2 Sep 2024 12:59:18 +0500 Subject: [PATCH 1/4] docs: documenting orchestration --- main/guides/orchestration/orch.md | 109 ++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 main/guides/orchestration/orch.md diff --git a/main/guides/orchestration/orch.md b/main/guides/orchestration/orch.md new file mode 100644 index 000000000..62a417032 --- /dev/null +++ b/main/guides/orchestration/orch.md @@ -0,0 +1,109 @@ +# Orchestration in Blockchain Ecosystems + +Blockchain technology has ushered in an era of decentralized finance, governance, and communication. However, as the ecosystem expands with numerous blockchains specializing in different aspects of decentralized applications, the need for coordination among these disparate networks becomes evident. This is where orchestration plays a vital role. In this blog post, we'll dive deep into what orchestration is, why it's essential, and how it works, especially in the context of the Agoric blockchain. + +## What is Orchestration? + +Orchestration in the blockchain context refers to the automated coordination and management of interactions between different blockchain networks. Just as an orchestra requires a conductor to synchronize the diverse instruments and players, blockchain networks need orchestration to manage and facilitate inter-chain communication, transactions, and data sharing. + +Orchestration enables multiple blockchains to work together seamlessly, allowing users to perform actions across different networks without needing to understand the complexities involved. It is a crucial component for building a scalable, interconnected blockchain ecosystem that can leverage the strengths of various networks. + +## TCP/IP of Blockchains + +The idea of orchestration can be likened to the TCP/IP protocol suite in the traditional internet. Just as TCP/IP enables different computers and networks to communicate over the internet, orchestration protocols allow different blockchains to interact. + +In this analogy: + +- **TCP** (Transmission Control Protocol) is responsible for ensuring reliable communication and data transmission between computers, akin to how Inter-Blockchain Communication (IBC) ensures reliable and secure message passing between blockchains. +- **IP** (Internet Protocol) routes and addresses packets of data to ensure they reach the correct destination. Similarly, orchestration mechanisms in blockchain manage the routing and addressing of transactions and messages between networks. + +By providing a standardized method for inter-chain communication, orchestration protocols like IBC are often referred to as the "TCP/IP of blockchains," enabling interoperability across different blockchain networks. + +## Motivations + +The motivations for developing robust orchestration solutions in blockchain are numerous: + +- **Interoperability**: Different blockchains often serve different purposes. For example, Bitcoin focuses on being a decentralized currency, while Ethereum allows for smart contracts. Orchestration enables these different chains to interact and leverage each other's strengths. +- **Scalability**: As more blockchains are created, the need for them to work together smoothly becomes more pressing. Orchestration provides a scalable solution for managing and coordinating inter-chain activities. + +- **User Experience**: Users want seamless experiences. Orchestration hides the complexities of interacting with multiple chains, making it easier for users to engage with blockchain applications without needing to understand the underlying protocols. + +- **Security**: Proper orchestration ensures that cross-chain operations are secure and that the integrity of transactions and data is maintained. + +# Key components + +To understand how orchestration works in a blockchain environment, it's essential to look at its key components: + +## Chain Object + +The chain object is a fundamental building block in orchestration. It represents an abstraction of a blockchain, encapsulating all the necessary details to interact with it, such as its endpoints, account structures, and transaction formats. This abstraction allows developers to interact with the blockchain without needing to understand its internal workings. + +```js +orchestrator.getChain('agoric'); +``` + +In order, to get access to the chain object, we need `orchestrator` object. Using the `orchestrator` object, we can extract a chain(In cosmos ecosystem). + +## Create Chain Accounts + +Creating chain accounts is a fundamental step in interacting with a blockchain. Each blockchain typically requires its own set of credentials or key pairs to authorize transactions and interact with the network. In the context of orchestration, the process of creating chain accounts involves generating the necessary cryptographic keys and associating them with the desired blockchain network through the chain object. + +In the Agoric SDK, for example, creating a chain account might look like this: + +```js +// Code ... +``` + +## Query blockchains + +Querying blockchains is essential for retrieving information such as account balances, transaction history, smart contract state, and more. The orchestration framework must provide a uniform interface for querying different blockchains, despite the underlying differences in their APIs and data formats. + +For instance, querying the balance of an account on a blockchain might look like this: + +```js +// Code ... +``` + +## Send Transactions + +Sending transactions is a critical function of any blockchain orchestration framework. Transactions could be anything from transferring assets, invoking smart contracts, or even triggering cross-chain operations. + +The orchestration layer needs to handle the nuances of each blockchain's transaction format, signature requirements, and broadcasting mechanisms. Here's a basic example of sending a transaction using the chain object: + +```js +// Code ... +``` + +# Examples + +# Under the Hood: How Orchestration Works + +To understand how orchestration frameworks work under the hood, we need to look at the underlying technologies that make cross-chain communication possible. + +## Inter-Blockchain Communication (IBC) + +The IBC protocol is a standardized framework for inter-chain communication, primarily used in the Cosmos ecosystem but applicable to any blockchain that implements the protocol. IBC allows different blockchains to securely send messages and transactions to each other. + +## Relayers + +Relayers are off-chain processes that facilitate the communication between blockchains in the IBC protocol. They monitor the state of the blockchains involved and relay packets of information, such as transaction data, from one blockchain to another. Relayers play a crucial role in maintaining the integrity and security of cross-chain operations. + +## Channels + +Channels are pathways through which blockchains communicate over IBC. Each channel is associated with a pair of blockchains and a specific application logic. For example, one channel might be dedicated to token transfers, while another might handle smart contract invocations. + +## Connections + +Connections are the underlying transport layer in the IBC protocol. They establish the secure, authenticated links between blockchains over which channels operate. Connections ensure that messages are transmitted reliably and securely, preserving the integrity of cross-chain interactions. + +## Asynchronous Flow + +Blockchain transactions and messages are typically asynchronous, meaning they do not require an immediate response and can be processed at different times. Orchestration frameworks must handle this asynchronicity, ensuring that messages are correctly sequenced and that eventual consistency is achieved across different blockchains. + +In practical terms, this might involve tracking transaction confirmations, handling retries in case of failures, and managing state across different networks. The orchestration layer abstracts these complexities, allowing developers to work with an easier, more synchronous-like interface while the framework handles the asynchronous nature of blockchain operations. + +## Vows + +In the Agoric ecosystem, "Vows" are a concept similar to JavaScript's Promises but tailored for distributed systems and smart contracts. Vows represent a commitment to a future result that might depend on asynchronous operations across multiple chains. + +For example, a vow might represent the promise of a token transfer from one blockchain to another. As the operation progresses, the vow gets resolved, updated, or rejected based on the outcome. Vows provide a powerful abstraction for managing asynchronous workflows in a distributed environment. From c90fd98776bd4aeb74d3fbc177da59f6fb613add Mon Sep 17 00:00:00 2001 From: rabi-siddique Date: Mon, 2 Sep 2024 14:39:21 +0500 Subject: [PATCH 2/4] docs: fundamentals of orchestration --- main/guides/orchestration/orch.md | 118 ++++++------------------------ 1 file changed, 24 insertions(+), 94 deletions(-) diff --git a/main/guides/orchestration/orch.md b/main/guides/orchestration/orch.md index 62a417032..a4d16dd25 100644 --- a/main/guides/orchestration/orch.md +++ b/main/guides/orchestration/orch.md @@ -1,109 +1,39 @@ -# Orchestration in Blockchain Ecosystems +# Fundamentals -Blockchain technology has ushered in an era of decentralized finance, governance, and communication. However, as the ecosystem expands with numerous blockchains specializing in different aspects of decentralized applications, the need for coordination among these disparate networks becomes evident. This is where orchestration plays a vital role. In this blog post, we'll dive deep into what orchestration is, why it's essential, and how it works, especially in the context of the Agoric blockchain. +Blockchain orchestration fundamentally relies on protocols and mechanisms that enable blockchains to communicate and transact with each other securely and efficiently. The primary goals of blockchain orchestration are: -## What is Orchestration? +- **Interoperability:** Allowing different blockchain networks to interact and transact with each other. +- **Scalability:** Enabling multiple blockchains to work together without compromising performance. +- **Security:** Ensuring that cross-chain transactions are secure and trustworthy. -Orchestration in the blockchain context refers to the automated coordination and management of interactions between different blockchain networks. Just as an orchestra requires a conductor to synchronize the diverse instruments and players, blockchain networks need orchestration to manage and facilitate inter-chain communication, transactions, and data sharing. +To achieve these goals, several foundational technologies and protocols have been developed, with the **Inter-Blockchain Communication (IBC) protocol** being one of the most prominent. -Orchestration enables multiple blockchains to work together seamlessly, allowing users to perform actions across different networks without needing to understand the complexities involved. It is a crucial component for building a scalable, interconnected blockchain ecosystem that can leverage the strengths of various networks. +### Inter-Blockchain Communication (IBC) -## TCP/IP of Blockchains +The Inter-Blockchain Communication (IBC) protocol can be thought of as the TCP/IP of the blockchain world. Just like TCP/IP allows different computer networks to communicate over the internet, IBC enables different blockchains to communicate with each other. -The idea of orchestration can be likened to the TCP/IP protocol suite in the traditional internet. Just as TCP/IP enables different computers and networks to communicate over the internet, orchestration protocols allow different blockchains to interact. +#### How IBC Works -In this analogy: +IBC operates on a simple premise: by adhering to a common set of communication protocols, blockchains can securely transfer data and tokens between one another. Here's a high-level overview of how IBC achieves this: -- **TCP** (Transmission Control Protocol) is responsible for ensuring reliable communication and data transmission between computers, akin to how Inter-Blockchain Communication (IBC) ensures reliable and secure message passing between blockchains. -- **IP** (Internet Protocol) routes and addresses packets of data to ensure they reach the correct destination. Similarly, orchestration mechanisms in blockchain manage the routing and addressing of transactions and messages between networks. +- **Light Client Verification:** Each blockchain maintains a "light client" of the other blockchain. A light client is a simplified version of a blockchain client that only retains enough information to verify transactions and proofs, without needing to store the entire blockchain history. +- **Relayer:** A relayer is an off-chain process or entity that listens for transactions on one blockchain and relays them to another. The relayer facilitates communication between blockchains but does not have any special permissions or abilities; it merely passes messages between chains. +- **IBC Handshake:** Before two blockchains can communicate, they must perform a handshake, establishing a trusted channel between them. This involves verifying each other's consensus state through light clients. +- **Packet Transfer:** Once the connection is established, IBC allows the transfer of packets of data. These packets can represent tokens, smart contract commands, or any other type of data. The receiving blockchain uses the light client verification to ensure that the data packet is valid and hasn't been tampered with. +- **Finality and Acknowledgement:** After a packet is successfully received and processed by the receiving blockchain, an acknowledgment is sent back to the originating blockchain, confirming the completion of the transaction. -By providing a standardized method for inter-chain communication, orchestration protocols like IBC are often referred to as the "TCP/IP of blockchains," enabling interoperability across different blockchain networks. +The IBC protocol is highly modular, meaning it can be extended and adapted for various use cases and blockchain types. This modularity is what makes IBC a powerful tool for blockchain orchestration, allowing diverse blockchains to participate in a common ecosystem. -## Motivations +### Interchain Accounts (ICA) -The motivations for developing robust orchestration solutions in blockchain are numerous: +Interchain Accounts (ICA) is a feature built on top of IBC that allows one blockchain to control an account on another blockchain. This is akin to having a remote account that can be operated from a different blockchain. ICA is a critical component of blockchain orchestration, as it enables seamless cross-chain operations and automation. -- **Interoperability**: Different blockchains often serve different purposes. For example, Bitcoin focuses on being a decentralized currency, while Ethereum allows for smart contracts. Orchestration enables these different chains to interact and leverage each other's strengths. -- **Scalability**: As more blockchains are created, the need for them to work together smoothly becomes more pressing. Orchestration provides a scalable solution for managing and coordinating inter-chain activities. +#### How ICA Works -- **User Experience**: Users want seamless experiences. Orchestration hides the complexities of interacting with multiple chains, making it easier for users to engage with blockchain applications without needing to understand the underlying protocols. +- **Account Creation:** One blockchain (let's call it Chain A) creates an account on another blockchain (Chain B) using the IBC protocol. This account is fully owned and controlled by Chain A. +- **Transaction Execution:** Chain A can then send IBC messages to execute transactions on Chain B as if it were a local user. This could include transferring tokens, interacting with smart contracts, or any other blockchain operation. +- **Automation:** By leveraging ICA, Chain A can automate operations on Chain B, creating complex workflows that span multiple blockchains. For example, Chain A could automatically execute a smart contract on Chain B when certain conditions are met. -- **Security**: Proper orchestration ensures that cross-chain operations are secure and that the integrity of transactions and data is maintained. +ICA greatly enhances the flexibility and capability of blockchain orchestration by enabling direct, programmable interactions between blockchains. This opens up a wide range of possibilities for cross-chain applications, from decentralized finance (DeFi) to supply chain management. -# Key components - -To understand how orchestration works in a blockchain environment, it's essential to look at its key components: - -## Chain Object - -The chain object is a fundamental building block in orchestration. It represents an abstraction of a blockchain, encapsulating all the necessary details to interact with it, such as its endpoints, account structures, and transaction formats. This abstraction allows developers to interact with the blockchain without needing to understand its internal workings. - -```js -orchestrator.getChain('agoric'); -``` - -In order, to get access to the chain object, we need `orchestrator` object. Using the `orchestrator` object, we can extract a chain(In cosmos ecosystem). - -## Create Chain Accounts - -Creating chain accounts is a fundamental step in interacting with a blockchain. Each blockchain typically requires its own set of credentials or key pairs to authorize transactions and interact with the network. In the context of orchestration, the process of creating chain accounts involves generating the necessary cryptographic keys and associating them with the desired blockchain network through the chain object. - -In the Agoric SDK, for example, creating a chain account might look like this: - -```js -// Code ... -``` - -## Query blockchains - -Querying blockchains is essential for retrieving information such as account balances, transaction history, smart contract state, and more. The orchestration framework must provide a uniform interface for querying different blockchains, despite the underlying differences in their APIs and data formats. - -For instance, querying the balance of an account on a blockchain might look like this: - -```js -// Code ... -``` - -## Send Transactions - -Sending transactions is a critical function of any blockchain orchestration framework. Transactions could be anything from transferring assets, invoking smart contracts, or even triggering cross-chain operations. - -The orchestration layer needs to handle the nuances of each blockchain's transaction format, signature requirements, and broadcasting mechanisms. Here's a basic example of sending a transaction using the chain object: - -```js -// Code ... -``` - -# Examples - -# Under the Hood: How Orchestration Works - -To understand how orchestration frameworks work under the hood, we need to look at the underlying technologies that make cross-chain communication possible. - -## Inter-Blockchain Communication (IBC) - -The IBC protocol is a standardized framework for inter-chain communication, primarily used in the Cosmos ecosystem but applicable to any blockchain that implements the protocol. IBC allows different blockchains to securely send messages and transactions to each other. - -## Relayers - -Relayers are off-chain processes that facilitate the communication between blockchains in the IBC protocol. They monitor the state of the blockchains involved and relay packets of information, such as transaction data, from one blockchain to another. Relayers play a crucial role in maintaining the integrity and security of cross-chain operations. - -## Channels - -Channels are pathways through which blockchains communicate over IBC. Each channel is associated with a pair of blockchains and a specific application logic. For example, one channel might be dedicated to token transfers, while another might handle smart contract invocations. - -## Connections - -Connections are the underlying transport layer in the IBC protocol. They establish the secure, authenticated links between blockchains over which channels operate. Connections ensure that messages are transmitted reliably and securely, preserving the integrity of cross-chain interactions. - -## Asynchronous Flow - -Blockchain transactions and messages are typically asynchronous, meaning they do not require an immediate response and can be processed at different times. Orchestration frameworks must handle this asynchronicity, ensuring that messages are correctly sequenced and that eventual consistency is achieved across different blockchains. - -In practical terms, this might involve tracking transaction confirmations, handling retries in case of failures, and managing state across different networks. The orchestration layer abstracts these complexities, allowing developers to work with an easier, more synchronous-like interface while the framework handles the asynchronous nature of blockchain operations. - -## Vows - -In the Agoric ecosystem, "Vows" are a concept similar to JavaScript's Promises but tailored for distributed systems and smart contracts. Vows represent a commitment to a future result that might depend on asynchronous operations across multiple chains. - -For example, a vow might represent the promise of a token transfer from one blockchain to another. As the operation progresses, the vow gets resolved, updated, or rejected based on the outcome. Vows provide a powerful abstraction for managing asynchronous workflows in a distributed environment. +# AutoStake From 5a9e656313d080b5888c9d469b2a8db32e459091 Mon Sep 17 00:00:00 2001 From: Mudassir Shabbir Date: Mon, 2 Sep 2024 15:24:43 +0500 Subject: [PATCH 3/4] chore: Autostake Example makeAccount details --- main/guides/orchestration/orch.md | 156 +++++++++++++++++++++++++++++- 1 file changed, 155 insertions(+), 1 deletion(-) diff --git a/main/guides/orchestration/orch.md b/main/guides/orchestration/orch.md index a4d16dd25..138e8916e 100644 --- a/main/guides/orchestration/orch.md +++ b/main/guides/orchestration/orch.md @@ -36,4 +36,158 @@ Interchain Accounts (ICA) is a feature built on top of IBC that allows one block ICA greatly enhances the flexibility and capability of blockchain orchestration by enabling direct, programmable interactions between blockchains. This opens up a wide range of possibilities for cross-chain applications, from decentralized finance (DeFi) to supply chain management. -# AutoStake +# AutoStake Example Walkthrough + +## `makeAccounts` Function + +The main logic of the contract is written in `makeAccounts` function which has the following signature: + +```js +/** + * @satisfies {OrchestrationFlow} + * @param {Orchestrator} orch + * @param {{ + * makeStakingTap: MakeStakingTap; + * makePortfolioHolder: MakePortfolioHolder; + * chainHub: GuestInterface; + * }} ctx + * @param {ZCFSeat} seat + * @param {{ + * chainName: string; + * validator: CosmosValidatorAddress; + * }} offerArgs + */ +export const makeAccounts = async ( + orch, + { makeStakingTap, makePortfolioHolder, chainHub }, + seat, + { chainName, validator }, +) => { + +``` + +- `orch` parameter represents the orchestrator, an entity responsible for managing interactions between different blockchain chains. +- `ctx`is a context object containing: + - `makeStakingTap`: A factory function for creating a staking tap. + - `makePortfolioHolder`: A factory function for creating a portfolio holder. + - `chainHub`: An interface to interact with the chain hub, which manages connections between different chains. +- `seat`: a ZCF Seat (this is unsused in this function). +- `offerArgs`: Contains arguments related to the offer, such as the `chainName` (name of the remote chain) and `validator` (address of the Cosmos validator on that chain). + +```js + const [agoric, remoteChain] = await Promise.all([ + orch.getChain('agoric'), + orch.getChain(chainName), + ]); +``` +- `const [agoric, remoteChain] = await Promise.all([...]);`: +Asynchronously fetches information for both the local chain (`agoric`) and the remote chain specified by `chainName`. The `Promise.all` ensures both operations complete before proceeding. + +```js + const { chainId, stakingTokens } = await remoteChain.getChainInfo(); + const remoteDenom = stakingTokens[0].denom; + remoteDenom || + Fail`${chainId || chainName} does not have stakingTokens in config`; + if (chainId !== validator.chainId) { + Fail`validator chainId ${validator.chainId} does not match remote chainId ${chainId}`; + } +``` +- `const { chainId, stakingTokens } = await remoteChain.getChainInfo();` +Retrieves the chain ID and staking tokens available on the remote chain. +- `const remoteDenom = stakingTokens[0].denom;`: +Extracts the denomination of the staking token from the remote chain. + +```js + const [localAccount, stakingAccount] = await Promise.all([ + agoric.makeAccount(), + /** @type {Promise & StakingAccountActions>} */ ( + remoteChain.makeAccount() + ), + ]); + + const [localChainAddress, remoteChainAddress] = await Promise.all([ + localAccount.getAddress(), + stakingAccount.getAddress(), + ]); +``` + +- `const [localAccount, stakingAccount] = await Promise.all([...]);`: +Creates accounts on both the local (Agoric) and remote chains. These accounts will be used to manage and stake tokens. +- `const [localChainAddress, remoteChainAddress] = await Promise.all([...]);`: +Retrieves the addresses associated with the newly created local and remote accounts. These addresses are essential for directing where tokens should be sent and staked. + +### Setting Up IBC Transfers and Staking Tap + +```js + const agoricChainId = (await agoric.getChainInfo()).chainId; + const { transferChannel } = await chainHub.getConnectionInfo( + agoricChainId, + chainId, + ); + assert(transferChannel.counterPartyChannelId, 'unable to find sourceChannel'); + + const localDenom = `ibc/${denomHash({ denom: remoteDenom, channelId: transferChannel.channelId })}`; +``` +- `const agoricChainId = ...`: +Fetches the chain ID for the Agoric chain to help establish an IBC channel between Agoric and the remote chain. +- `const { transferChannel } = await chainHub.getConnectionInfo(...);`: +Retrieves the transfer channel information necessary for sending tokens between the local and remote chains via IBC. +- `assert(transferChannel.counterPartyChannelId, 'unable to find sourceChannel');`: +Ensures that a valid source channel is found for the IBC transfer. If not, an error is thrown. +- `const localDenom = ...`: +Constructs the IBC denomination identifier (`localDenom`) for the token, which combines the remote token's denomination with the IBC channel ID. This identifier is used to track the tokens on the local chain. + +### Staking Tap and Monitoring: +```js + const tap = makeStakingTap({ + localAccount, + stakingAccount, + validator, + localChainAddress, + remoteChainAddress, + sourceChannel: transferChannel.counterPartyChannelId, + remoteDenom, + localDenom, + }); + + await localAccount.monitorTransfers(tap); +``` +- `const tap = makeStakingTap({...});`: +Creates a "staking tap" using the provided accounts and configuration. This tap automatically handles the receipt and delegation of tokens. +- `await localAccount.monitorTransfers(tap);`: +Sets up the local account to monitor incoming transfers. When tokens matching the specified `remoteDenom` are received, they are automatically delegated to the validator. + +### Final Steps: Portfolio Holder and Return: + +```js + const accountEntries = harden( + /** @type {[string, OrchestrationAccount][]} */ ([ + ['agoric', localAccount], + [chainName, stakingAccount], + ]), + ); + + const publicTopicEntries = harden( + /** @type {[string, ResolvedPublicTopic][]} */ ( + await Promise.all( + accountEntries.map(async ([name, account]) => { + const { account: topicRecord } = await account.getPublicTopics(); + return [name, topicRecord]; + }), + ) + ), + ); + + const portfolioHolder = makePortfolioHolder( + accountEntries, + publicTopicEntries, + ); + + return portfolioHolder.asContinuingOffer(); +}; +harden(makeAccounts); +``` +- `const accountEntries = harden([...]);`: +Creates a hardened (immutable) list of account entries, pairing the chain name with its corresponding orchestration account. This list will be used for managing these accounts in the portfolio holder. + + From 442b08d5469358f7758a436917c53e1d58389ef6 Mon Sep 17 00:00:00 2001 From: Mudassir Shabbir Date: Mon, 2 Sep 2024 18:31:03 +0500 Subject: [PATCH 4/4] docs: autostake --- main/guides/orchestration/orch.md | 62 +++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/main/guides/orchestration/orch.md b/main/guides/orchestration/orch.md index 138e8916e..314805ba3 100644 --- a/main/guides/orchestration/orch.md +++ b/main/guides/orchestration/orch.md @@ -38,6 +38,65 @@ ICA greatly enhances the flexibility and capability of blockchain orchestration # AutoStake Example Walkthrough +## `contract` Function + +First thing we do in the `contract` function is to get orchestration related functionality in our contract as below: +```js +const makePortfolioHolder = preparePortfolioHolder( + zone.subZone('portfolio'), + vowTools, + ); + + const orchFns = orchestrateAll(flows, { makePortfolioHolder }); +``` +Next, we create a `publicFacet` based on several `make*Invitation` as below: +```js +const publicFacet = zone.exo( + 'Basic Flows Public Facet', + M.interface('Basic Flows PF', { + makeOrchAccountInvitation: M.callWhen().returns(InvitationShape), + makePortfolioAccountInvitation: M.callWhen().returns(InvitationShape), + makeSendICQQueryInvitation: M.callWhen().returns(InvitationShape), + makeAccountAndSendBalanceQueryInvitation: + M.callWhen().returns(InvitationShape), + makeSendLocalQueryInvitation: M.callWhen().returns(InvitationShape), + }) +``` + +`make*Invitation` definitions are as below: +```js +makeOrchAccountInvitation() { + return zcf.makeInvitation( + orchFns.makeOrchAccount, + 'Make an Orchestration Account', + ); + }, + makePortfolioAccountInvitation() { + return zcf.makeInvitation( + orchFns.makePortfolioAccount, + 'Make an Orchestration Account', + ); + }, + makeSendICQQueryInvitation() { + return zcf.makeInvitation( + orchFns.sendICQQuery, + 'Submit a query to a remote chain', + ); + }, + makeAccountAndSendBalanceQueryInvitation() { + return zcf.makeInvitation( + orchFns.makeAccountAndSendBalanceQuery, + 'Make an account and submit a balance query', + ); + }, + makeSendLocalQueryInvitation() { + return zcf.makeInvitation( + orchFns.sendLocalQuery, + 'Submit a query to the local chain', + ); + } +``` + ## `makeAccounts` Function The main logic of the contract is written in `makeAccounts` function which has the following signature: @@ -138,6 +197,7 @@ Ensures that a valid source channel is found for the IBC transfer. If not, an er Constructs the IBC denomination identifier (`localDenom`) for the token, which combines the remote token's denomination with the IBC channel ID. This identifier is used to track the tokens on the local chain. ### Staking Tap and Monitoring: + ```js const tap = makeStakingTap({ localAccount, @@ -159,6 +219,8 @@ Sets up the local account to monitor incoming transfers. When tokens matching th ### Final Steps: Portfolio Holder and Return: +Below, we create portfolioHolder of `localAccount` and `stakingAccount`. A portfolio holder stores two or more `OrchestrationAccount`s and combines ContinuingOfferResult's from each into a single result. + ```js const accountEntries = harden( /** @type {[string, OrchestrationAccount][]} */ ([