escrow.gno
1.09 Kb · 29 lines
1package ucs03_zkgm
2
3import (
4 "chain"
5 "chain/banker"
6
7 u256 "gno.land/p/onbloc/math/uint256"
8 zkgm "gno.land/r/onbloc/ibc/union/apps/ucs03_zkgm"
9)
10
11// sendNative releases `amount` of denom from the proxy escrow account to
12// receiver. Escrowed native funds sit at the proxy realm address; under the
13// interrealm borrow rule this banker send executes in the proxy's ownership
14// context even though it is invoked from the impl call frame, so the funds leave
15// the proxy escrow rather than the impl realm.
16func (v *ucs03ZkgmV1) sendNative(_ int, rlm realm, denom string, receiver address, amount *u256.Uint) error {
17 n, err := amountInt64(amount)
18 if err != nil {
19 return err
20 }
21 // rlm.Address() is the proxy escrow account: under the interrealm borrow rule
22 // the impl operates in the proxy's ownership context, so the realm-send banker
23 // draws from the proxy balance where the user's -send funds landed.
24 b := banker.NewBanker(banker.BankerTypeRealmSend, rlm)
25 b.SendCoins(rlm.Address(), receiver, chain.NewCoins(chain.NewCoin(denom, n)))
26 zkgm.EmitNativeReleased(0, rlm, denom, receiver, n)
27
28 return nil
29}