Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Orchestration: use orchestrated flow as handler for monitorTransfer tap #10047

Open
0xpatrickdev opened this issue Sep 9, 2024 · 1 comment · May be fixed by #10065
Open

Orchestration: use orchestrated flow as handler for monitorTransfer tap #10047

0xpatrickdev opened this issue Sep 9, 2024 · 1 comment · May be fixed by #10065
Labels
enhancement New feature or request

Comments

@0xpatrickdev
Copy link
Member

What is the Problem Being Solved?

monitorTransfers(tap) allows a developer to monitor incoming and outgoing IBC transfers for a LocalChainAccount and react to them. auto-stake-it demonstrates how to do this:

However, if the receiveUpcall handler performs any multichain work, it must be written with vows:

tap: {
/**
* Transfers from localAccount to stakingAccount, then delegates from
* the stakingAccount to `validator` if the expected token (remoteDenom)
* is received.
*
* @param {VTransferIBCEvent} event
*/
receiveUpcall(event) {
trace('receiveUpcall', event);
// ignore packets from unknown channels
if (event.packet.source_channel !== this.state.sourceChannel) {
return;
}
const tx = /** @type {FungibleTokenPacketData} */ (
JSON.parse(atob(event.packet.data))
);
trace('receiveUpcall packet data', tx);
const { remoteDenom, localChainAddress } = this.state;
// ignore outgoing transfers
if (tx.receiver !== localChainAddress.value) {
return;
}
// only interested in transfers of `remoteDenom`
if (tx.denom !== remoteDenom) {
return;
}
const { localAccount, localDenom, remoteChainAddress } = this.state;
return watch(
E(localAccount).transfer(
{
denom: localDenom,
value: BigInt(tx.amount),
},
remoteChainAddress,
),
this.facets.transferWatcher,
BigInt(tx.amount),
);
},
},
transferWatcher: {
/**
* @param {void} _result
* @param {bigint} value the qty of uatom to delegate
*/
onFulfilled(_result, value) {
const { stakingAccount, validator, remoteDenom } = this.state;
return watch(
E(stakingAccount).delegate(validator, {
denom: remoteDenom,
value,
}),
);
},
},

Description of the Design

Demonstrate writing a tap where an orchestrated flow is the handler via auto-stake-it.

Security Considerations

Scaling Considerations

Test Plan

Upgrade Considerations

@0xpatrickdev 0xpatrickdev added the enhancement New feature or request label Sep 9, 2024
@0xpatrickdev
Copy link
Member Author

Brainstorming - is there a path for adding logic to LocalOrchAccount.monitorTransfers that would allow the developer to specify a flow instead of an exo with a receiveUpcall method? If yes, is that helpful towards the goal of concision?

@0xpatrickdev 0xpatrickdev linked a pull request Sep 11, 2024 that will close this issue
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant