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
1 change: 1 addition & 0 deletions config.e2e-local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ token:
symbol: "USDCx"
decimals: 6
instrument_id: "USDCx"
external_transfer: true

# Ethereum JSON-RPC facade (MetaMask compatibility)
eth_rpc:
Expand Down
4 changes: 3 additions & 1 deletion pkg/app/api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,9 @@ func initServices(
g.Go(func() error { return sub.Start(gCtx) })
}

transferSvc := transfer.NewTransferService(cantonClient.Token, userStore, instrumentedCache, cfg.Token, indexerClient)
transferSvc := transfer.NewTransferService(
cantonClient.Token, userStore, instrumentedCache, cfg.Token, indexerClient, cantonClient.Identity,
)
return &services{
evmStore: evmStore,
tokenService: tokenService,
Expand Down
30 changes: 30 additions & 0 deletions pkg/cantonsdk/identity/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ type Identity interface {
AllocateParty(ctx context.Context, hint string) (*Party, error)
AllocateExternalParty(ctx context.Context, hint string, spkiPublicKey []byte, signer ExternalPartyKey) (*Party, error)
ListParties(ctx context.Context) ([]*Party, error) // TODO: add iterator
// PartyExists reports whether the party id is known to the participant's
// topology (which includes parties hosted on other participants connected
// to the same synchronizer).
PartyExists(ctx context.Context, partyID string) (bool, error)
GetParticipantID(ctx context.Context) (string, error)

CreateFingerprintMapping(ctx context.Context, req CreateFingerprintMappingRequest) (*FingerprintMapping, error)
Expand Down Expand Up @@ -250,6 +254,32 @@ func (c *Client) ListParties(ctx context.Context) ([]*Party, error) {
return out, nil
}

// PartyExists reports whether the party id is known to the participant's
// topology. GetParties omits unknown parties from the response rather than
// erroring, so existence is a match in the returned details.
func (c *Client) PartyExists(ctx context.Context, partyID string) (bool, error) {
Comment thread
sadiq1971 marked this conversation as resolved.
authCtx := c.ledger.AuthContext(ctx)

resp, err := c.ledger.PartyAdmin().GetParties(authCtx, &adminv2.GetPartiesRequest{
Parties: []string{partyID},
})
if err != nil {
// A malformed party id string is rejected with InvalidArgument; report it
// as non-existent rather than a lookup failure.
if st, ok := status.FromError(err); ok && st.Code() == codes.InvalidArgument {
return false, nil
}
return false, fmt.Errorf("error getting party %s: %w", partyID, err)
}

for _, p := range resp.PartyDetails {
Comment thread
sadiq1971 marked this conversation as resolved.
if p.Party == partyID {
return true, nil
}
}
return false, nil
}

func (c *Client) GetParticipantID(ctx context.Context) (string, error) {
authCtx := c.ledger.AuthContext(ctx)

Expand Down
1 change: 1 addition & 0 deletions pkg/config/defaults/config.api-server.docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ token:
symbol: "USDCx"
decimals: 6
instrument_id: "USDCx"
external_transfer: true

# Ethereum JSON-RPC facade (MetaMask compatibility)
eth_rpc:
Expand Down
1 change: 1 addition & 0 deletions pkg/config/defaults/config.api-server.local-devnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ token:
symbol: "USDCx"
decimals: 6
instrument_id: "USDCx"
external_transfer: true

# Ethereum JSON-RPC facade (MetaMask compatibility)
eth_rpc:
Expand Down
1 change: 1 addition & 0 deletions pkg/config/defaults/config.api-server.mainnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ token:
symbol: "USDCx"
decimals: 6
instrument_id: "USDCx"
external_transfer: true

eth_rpc:
enabled: true
Expand Down
1 change: 1 addition & 0 deletions pkg/config/tests/minimal.api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ token:
symbol: "USDCx"
decimals: 6
instrument_id: "USDCx"
external_transfer: true

eth_rpc:
chain_id: 31337
Expand Down
4 changes: 4 additions & 0 deletions pkg/token/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ type ERC20Token struct {
Symbol string `yaml:"symbol" validate:"required"`
Decimals int `yaml:"decimals" validate:"gte=0,lte=18"`
InstrumentID string `yaml:"instrument_id" validate:"required"`
// ExternalTransfer marks a token that can be transferred to parties hosted on
// external participant nodes (e.g. USDCx). Tokens without it can only be
// transferred between parties registered with this middleware.
ExternalTransfer bool `yaml:"external_transfer"`
}

// Config holds token metadata indexed by contract address.
Expand Down
93 changes: 93 additions & 0 deletions pkg/transfer/mocks/mock_party_registry.go

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

59 changes: 59 additions & 0 deletions pkg/transfer/mocks/mock_user_store.go

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

Loading
Loading