Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This repository implements the off-chain backend of AgentPay. Before changing co
Companion repos are wired in via the filesystem MCP server. The canonical roots are:

- `agent-pay-docs` — protocol architecture (`agentpay-architecture/`). Required reading for protocol-sensitive work. The `state-guardian-network/` subtree is **not** required background; read it only when the task is explicitly about SGN behavior or SGN-related profile wiring.
- `agent-pay-contracts` — Solidity contracts (CelerLedger, PayResolver, PayRegistry, RouterRegistry, EthPool, Wallet). Optional background; read only when the task touches on-chain contract logic, event semantics, generated bindings under `chain/channel-eth-go/`, or profile/address wiring that depends on contract behavior.
- `agent-pay-contracts` — Solidity contracts (CelerLedger, PayResolver, PayRegistry, RouterRegistry, Wallet, plus the chain-canonical wrapped-native / WETH-style contract that CelerLedger references for native-token funding flows). Optional background; read only when the task touches on-chain contract logic, event semantics, generated bindings under `chain/channel-eth-go/`, or profile/address wiring that depends on contract behavior.
- `agent-pay-x402` — downstream integration that consumes this repo via WebAPI gRPC + Admin HTTP. Useful as an "external consumer" reference, not required reading.

`.mcp.json` is gitignored per-developer. Copy `.mcp.json.example` to `.mcp.json` and fill in absolute paths to your local sibling clones. If a path is unavailable when needed, ask the user before guessing on protocol-sensitive work.
Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ The protocol-and-contract design lives in the companion `agent-pay-docs` repo (`
`.mcp.json` is gitignored per-developer — each contributor wires their own absolute paths. The current wiring exposes three filesystem MCP roots:

- **agent-pay-docs** — protocol architecture + SGN docs. Read `agentpay-architecture/`. Skip `state-guardian-network/` unless the task is explicitly about SGN behavior or SGN-related profile wiring.
- **agent-pay-contracts** — Solidity contracts (CelerLedger, PayResolver, PayRegistry, RouterRegistry, EthPool, Wallet, ). Foundry project. Read only when the task touches on-chain contract logic, event semantics, or generated bindings under [chain/channel-eth-go/](chain/channel-eth-go/).
- **agent-pay-contracts** — Solidity contracts (CelerLedger, PayResolver, PayRegistry, RouterRegistry, Wallet, plus the chain-canonical wrapped-native / WETH-style contract that CelerLedger references for native-token funding flows). Foundry project. Read only when the task touches on-chain contract logic, event semantics, or generated bindings under [chain/channel-eth-go/](chain/channel-eth-go/).
- **agent-pay-x402** — downstream Go integration that layers x402 HTTP payment over AgentPay state channels. Useful as an "external consumer" reference: it talks to this repo's WebAPI gRPC (clients) and Admin HTTP (OSP) only, never `CelerStream` directly. Friction observed there is logged in that repo's `docs/agent-pay-feedback.md`.

If a path is unavailable in your MCP roots, ask the user before guessing — do not silently proceed on protocol-sensitive work.
Expand Down
24 changes: 12 additions & 12 deletions celersdk/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ func (mc *Client) Destroy() {
mc.c = nil
}

func (mc *Client) OpenETHChannel(dep *Deposit, cb ClientCallback) {
func (mc *Client) OpenNativeChannel(dep *Deposit, cb ClientCallback) {
mc.c.OpenChannel(&entity.TokenInfo{
TokenType: entity.TokenType_ETH,
TokenAddress: ctype.EthTokenAddr.Bytes(),
TokenType: entity.TokenType_NATIVE,
TokenAddress: ctype.NativeTokenAddr.Bytes(),
}, utils.Wei2BigInt(dep.Myamtwei), utils.Wei2BigInt(dep.Peeramtwei), cb)
}

Expand All @@ -115,9 +115,9 @@ func (mc *Client) OpenTokenChannel(tk *Token, dep *Deposit, cb ClientCallback) {
}, utils.Wei2BigInt(dep.Myamtwei), utils.Wei2BigInt(dep.Peeramtwei), cb)
}

func (mc *Client) TcbOpenETHChannel(peerAmtWei string, cb ClientCallback) {
func (mc *Client) TcbOpenNativeChannel(peerAmtWei string, cb ClientCallback) {
mc.c.TcbOpenChannel(&entity.TokenInfo{
TokenType: entity.TokenType_ETH,
TokenType: entity.TokenType_NATIVE,
}, utils.Wei2BigInt(peerAmtWei), cb)
}

Expand All @@ -134,12 +134,12 @@ func (mc *Client) InstantiateChannelForToken(tk *Token, cb ClientCallback) {
}, cb)
}

func (mc *Client) DepositETH(amount string, callback DepositCallback) (string, error) {
func (mc *Client) DepositNative(amount string, callback DepositCallback) (string, error) {
amtInt, ok := new(big.Int).SetString(amount, 10)
if !ok {
return "", common.ErrInvalidArg
}
return mc.c.Deposit(ctype.EthTokenAddr, amtInt, callback)
return mc.c.Deposit(ctype.NativeTokenAddr, amtInt, callback)
}

func (mc *Client) DepositERC20(
Expand All @@ -163,12 +163,12 @@ func (mc *Client) RemoveDepositJob(jobID string) {
mc.c.RemoveDepositJob(jobID)
}

func (mc *Client) WithdrawETH(amount string, callback CooperativeWithdrawCallback) (string, error) {
func (mc *Client) WithdrawNative(amount string, callback CooperativeWithdrawCallback) (string, error) {
amtInt, ok := new(big.Int).SetString(amount, 10)
if !ok {
return "", common.ErrInvalidArg
}
return mc.c.CooperativeWithdraw(ctype.EthTokenAddr, amtInt, callback)
return mc.c.CooperativeWithdraw(ctype.NativeTokenAddr, amtInt, callback)
}

func (mc *Client) WithdrawERC20(
Expand Down Expand Up @@ -220,7 +220,7 @@ func (mc *Client) HasPendingOpenChanRequest(tk *Token) bool {
// If the given address has not joined Celer, an empty string will
// be returned.
func (mc *Client) QueryReceivingCapacity(addr string) (*CelerStatus, error) {
joinStatus, freeBalance, err := mc.c.IsConnectedToCeler(ctype.EthTokenAddrStr, addr)
joinStatus, freeBalance, err := mc.c.IsConnectedToCeler(ctype.NativeTokenAddrStr, addr)
return &CelerStatus{
JoinStatus: int32(joinStatus),
FreeBalance: freeBalance}, err
Expand All @@ -243,9 +243,9 @@ func (mc *Client) QueryReceivingCapacityOnToken(tokenAddr string, addr string) (
FreeBalance: freeBalance}, err
}

// Get celer offchain ETH balance
// Get celer offchain native-token balance
func (mc *Client) GetBalance() (*Balance, error) {
return mc.GetBalanceERC20(ctype.EthTokenAddrStr)
return mc.GetBalanceERC20(ctype.NativeTokenAddrStr)
}

// GetBalanceERC20 gets celer offchain tokenAddr balance
Expand Down
8 changes: 4 additions & 4 deletions celersdk/pay.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ const cPayTimeout = 600 // timeout in seconds for cpay ie. no app channel condit

// noteTypeUrl should be type url of any.Any.
// noteStr should be string representation of []byte in note (any.Any)
func (mc *Client) SendETH(receiver string, amtWei string, noteTypeUrl string, noteValueByte []byte) (string, error) {
func (mc *Client) SendNative(receiver string, amtWei string, noteTypeUrl string, noteValueByte []byte) (string, error) {
return mc.SendToken(nil, receiver, amtWei, noteTypeUrl, noteValueByte)
}

// SendETH sends ERC20/ETH token to receiver. Caller can optionally add a note in the pay.
// SendToken sends an ERC20 or native token to receiver. Caller can optionally add a note in the pay.
func (mc *Client) SendToken(tk *Token, receiver string, amtWei string, noteTypeUrl string, noteValueByte []byte) (string, error) {

xfer := createXfer(tk, receiver, amtWei)
Expand Down Expand Up @@ -55,7 +55,7 @@ func (mc *Client) RejectPay(payID string) error {
return mc.c.RejectBooleanPay(ctype.Hex2PayID(payID))
}

// RemoveExpiredPays clears pending pays that have expired, if tk is nil, means ETH
// RemoveExpiredPays clears pending pays that have expired, if tk is nil, means native token
func (mc *Client) RemoveExpiredPays(tk *Token) error {
token := sdkToken2entityToken(tk)
return mc.c.SettleExpiredPays(token)
Expand All @@ -76,7 +76,7 @@ func (mc *Client) ResolvePayOnChain(payID string) error {
return mc.c.SettleOnChainResolvedPay(ctype.Hex2PayID(payID))
}

// ConfirmOnChainResolvedPays confirms pays that have been onchain resolved, if tk is nil, means ETH
// ConfirmOnChainResolvedPays confirms pays that have been onchain resolved, if tk is nil, means native token
func (mc *Client) ConfirmOnChainResolvedPays(tk *Token) error {
token := sdkToken2entityToken(tk)
return mc.c.ConfirmOnChainResolvedPays(token)
Expand Down
4 changes: 2 additions & 2 deletions celersdk/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ func createXfer(tk *Token, receiver, amtWei string) *entity.TokenTransfer {

func sdkToken2entityToken(tk *Token) *entity.TokenInfo {
var token *entity.TokenInfo
if tk == nil { // ETH case
if tk == nil { // native-token case
token = &entity.TokenInfo{
TokenType: entity.TokenType_ETH,
TokenType: entity.TokenType_NATIVE,
}
} else {
token = &entity.TokenInfo{
Expand Down
2 changes: 1 addition & 1 deletion chain/channel-eth-go/balancelimit/balancelimit.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading