Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

types.gno

4.43 Kb · 105 lines
  1package ucs03_zkgm
  2
  3import (
  4	types "gno.land/p/onbloc/ibc/union/types"
  5	tb "gno.land/p/onbloc/ibc/union/zkgm/tokenbucket"
  6	u256 "gno.land/p/onbloc/math/uint256"
  7
  8	z "gno.land/p/onbloc/ibc/union/zkgm"
  9)
 10
 11const Version = z.PROTOCOL_VERSION
 12
 13type IApp interface {
 14	// IApp
 15	OnChannelOpenInit(_ int, rlm realm, connectionId types.ConnectionId, channelId types.ChannelId, version string, relayer address)
 16	OnChannelOpenTry(_ int, rlm realm, connectionId types.ConnectionId, channelId types.ChannelId, version string, counterpartyVersion string, relayer address)
 17	OnChannelOpenAck(_ int, rlm realm, channelId types.ChannelId, counterpartyChannelId types.ChannelId, counterpartyVersion string, relayer address)
 18	OnChannelOpenConfirm(_ int, rlm realm, channelId types.ChannelId, relayer address)
 19	OnChannelCloseInit(_ int, rlm realm, channelId types.ChannelId, relayer address)
 20	OnChannelCloseConfirm(_ int, rlm realm, channelId types.ChannelId, relayer address)
 21	OnRecvPacket(_ int, rlm realm, packet types.Packet, relayer address, relayerMsg []byte) types.RecvPacketResult
 22	OnAcknowledgementPacket(_ int, rlm realm, packet types.Packet, acknowledgement []byte, relayer address)
 23	OnTimeoutPacket(_ int, rlm realm, packet types.Packet, relayer address)
 24
 25	// IIntentApp
 26	IAppIntent
 27
 28	IAppTransfer
 29
 30	IAppVoucher
 31
 32	// Read-only relayer/tooling query surface.
 33	IAppGetter
 34}
 35
 36type IAppIntent interface {
 37	OnIntentRecvPacket(_ int, rlm realm, packet types.Packet, marketMaker address, marketMakerMsg []byte) types.RecvPacketResult
 38}
 39
 40// IAppTransfer is the user-initiated send surface. zkgm is a general instruction
 41// protocol (token order / batch / call / forward), so Send takes a raw
 42// Instruction rather than a token-transfer shaped argument list.
 43type IAppTransfer interface {
 44	Send(_ int, rlm realm, channelId types.ChannelId, timeoutTimestamp types.Timestamp, salt [32]byte, instruction z.Instruction) types.Packet
 45}
 46
 47// IAppVoucher is the wrapped-voucher self-service surface: it lets a holder
 48// grant an allowance or move their own balance directly, without exposing the
 49// mint/burn capability that Store's Voucher.Ledger() carries.
 50type IAppVoucher interface {
 51	VoucherApprove(_ int, rlm realm, ibcDenom string, spender address, amount int64) error
 52	VoucherTransfer(_ int, rlm realm, ibcDenom string, to address, amount int64) error
 53}
 54
 55// IAppGetter is the read-only query surface implemented by the impl and exposed
 56// by the proxy's getters.gno.
 57type IAppGetter interface {
 58	GetTokenBucket(denom string) (*tb.TokenBucket, error)
 59	GetChannelBalanceV2(channelId types.ChannelId, path *u256.Uint, baseToken string, quoteToken []byte) (*u256.Uint, error)
 60	GetLockedTokenAmount(denom string) (*u256.Uint, error)
 61	GetVoucherList(offset, count int) ([]VoucherInfo, error)
 62	GetVoucherSize() (int, error)
 63	GetVoucherInfo(ibcDenom string) (VoucherInfo, error)
 64}
 65
 66type IStore interface {
 67	SetTokenOrigin(_ int, rlm realm, denom string, path *u256.Uint)
 68	GetTokenOrigin(denom string) (*u256.Uint, bool)
 69
 70	SetChannelBalanceV2(_ int, rlm realm, key string, amount *u256.Uint)
 71	RemoveChannelBalanceV2(_ int, rlm realm, key string)
 72	GetChannelBalanceV2(key string) (*u256.Uint, bool)
 73
 74	SetMetadataImageOf(_ int, rlm realm, denom string, image [32]byte)
 75	GetMetadataImageOf(denom string) ([32]byte, bool)
 76
 77	SetForeignToken(_ int, rlm realm, denom string, token []byte)
 78	GetForeignToken(denom string) ([]byte, bool)
 79
 80	SetInFlightPacket(_ int, rlm realm, packetHash string, parent types.Packet)
 81	GetInFlightPacket(packetHash string) (types.Packet, bool)
 82	RemoveInFlightPacket(_ int, rlm realm, packetHash string)
 83
 84	SetTokenBucket(_ int, rlm realm, denom string, bucket *tb.TokenBucket)
 85	GetTokenBucket(denom string) (*tb.TokenBucket, bool)
 86	RemoveTokenBucket(_ int, rlm realm, denom string)
 87
 88	SetVoucher(_ int, rlm realm, ibcDenom string, v *Voucher)
 89	GetVoucher(ibcDenom string) (*Voucher, bool)
 90	GetVoucherList(offset, count int) []VoucherInfo
 91	GetVoucherSize() int
 92	HasVoucher(ibcDenom string) bool
 93
 94	// AddLockedTokenAmount/GetLockedTokenAmount are managed alongside the
 95	// voucher methods above: both cover non-escrow custody of a base token
 96	// (native or grc20) that zkgm cannot supply-burn the way it burns vouchers.
 97	AddLockedTokenAmount(_ int, rlm realm, denom string, amount *u256.Uint)
 98	GetLockedTokenAmount(denom string) (*u256.Uint, bool)
 99
100	SetReceiver(_ int, rlm realm, path string, receiver z.Zkgmable)
101	GetReceiver(path string) (z.Zkgmable, bool)
102
103	SetRateLimitDisabled(_ int, rlm realm, disabled bool)
104	RateLimitDisabled() bool
105}