Initial project setup: Add contracts, API definitions, tests, and documentation
- Add Foundry project configuration (foundry.toml, foundry.lock) - Add Solidity contracts (TokenFactory138, BridgeVault138, ComplianceRegistry, etc.) - Add API definitions (OpenAPI, GraphQL, gRPC, AsyncAPI) - Add comprehensive test suite (unit, integration, fuzz, invariants) - Add API services (REST, GraphQL, orchestrator, packet service) - Add documentation (ISO20022 mapping, runbooks, adapter guides) - Add development tools (RBC tool, Swagger UI, mock server) - Update OpenZeppelin submodules to v5.0.0
This commit is contained in:
554
api/packages/graphql/schema.graphql
Normal file
554
api/packages/graphql/schema.graphql
Normal file
@@ -0,0 +1,554 @@
|
||||
# GraphQL Schema for eMoney Token Factory API
|
||||
# This schema provides joined views and subscriptions for complex queries
|
||||
|
||||
scalar DateTime
|
||||
scalar BigInt
|
||||
scalar Bytes32
|
||||
|
||||
type Query {
|
||||
# Token queries
|
||||
token(code: String!): Token
|
||||
tokens(filter: TokenFilter, paging: Paging): TokenConnection!
|
||||
|
||||
# Lien queries
|
||||
lien(lienId: ID!): Lien
|
||||
liens(filter: LienFilter, paging: Paging): LienConnection!
|
||||
accountLiens(accountRefId: Bytes32!, active: Boolean): [Lien!]!
|
||||
accountEncumbrance(accountRefId: Bytes32!, token: String): EncumbranceSummary!
|
||||
|
||||
# Compliance queries
|
||||
compliance(refId: Bytes32!): ComplianceProfile
|
||||
accountCompliance(accountRefId: Bytes32!): ComplianceProfile
|
||||
walletCompliance(walletRefId: Bytes32!): ComplianceProfile
|
||||
|
||||
# Mapping queries
|
||||
account(refId: Bytes32!): Account
|
||||
wallet(refId: Bytes32!): Wallet
|
||||
accountWallets(accountRefId: Bytes32!): [Wallet!]!
|
||||
walletAccounts(walletRefId: Bytes32!): [Account!]!
|
||||
|
||||
# Trigger queries
|
||||
trigger(id: ID!): Trigger
|
||||
triggers(filter: TriggerFilter, paging: Paging): TriggerConnection!
|
||||
|
||||
# Packet queries
|
||||
packet(id: ID!): Packet
|
||||
packets(filter: PacketFilter, paging: Paging): PacketConnection!
|
||||
|
||||
# Bridge queries
|
||||
bridgeLock(lockId: ID!): BridgeLock
|
||||
bridgeLocks(filter: BridgeLockFilter, paging: Paging): BridgeLockConnection!
|
||||
bridgeCorridors: [BridgeCorridor!]!
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
# Token mutations
|
||||
deployToken(input: DeployTokenInput!): Token!
|
||||
updateTokenPolicy(code: String!, input: UpdatePolicyInput!): Token!
|
||||
mintToken(code: String!, input: MintInput!): TransactionResult!
|
||||
burnToken(code: String!, input: BurnInput!): TransactionResult!
|
||||
clawbackToken(code: String!, input: ClawbackInput!): TransactionResult!
|
||||
forceTransferToken(code: String!, input: ForceTransferInput!): TransactionResult!
|
||||
|
||||
# Lien mutations
|
||||
placeLien(input: PlaceLienInput!): Lien!
|
||||
reduceLien(lienId: ID!, reduceBy: BigInt!): Lien!
|
||||
releaseLien(lienId: ID!): Boolean!
|
||||
|
||||
# Compliance mutations
|
||||
setCompliance(refId: Bytes32!, input: SetComplianceInput!): ComplianceProfile!
|
||||
setFreeze(refId: Bytes32!, frozen: Boolean!): ComplianceProfile!
|
||||
|
||||
# Mapping mutations
|
||||
linkAccountWallet(input: LinkAccountWalletInput!): MappingResult!
|
||||
unlinkAccountWallet(accountRefId: Bytes32!, walletRefId: Bytes32!): Boolean!
|
||||
|
||||
# Trigger mutations
|
||||
submitInboundMessage(input: SubmitInboundMessageInput!): Trigger!
|
||||
submitOutboundMessage(input: SubmitOutboundMessageInput!): Trigger!
|
||||
validateAndLockTrigger(triggerId: ID!): Trigger!
|
||||
markTriggerSubmitted(triggerId: ID!, railTxRef: String!): Trigger!
|
||||
confirmTriggerSettled(triggerId: ID!): Trigger!
|
||||
confirmTriggerRejected(triggerId: ID!, reason: String): Trigger!
|
||||
|
||||
# Packet mutations
|
||||
generatePacket(input: GeneratePacketInput!): Packet!
|
||||
dispatchPacket(packetId: ID!, input: DispatchPacketInput!): Packet!
|
||||
acknowledgePacket(packetId: ID!, input: AcknowledgePacketInput!): Packet!
|
||||
|
||||
# Bridge mutations
|
||||
bridgeLock(input: BridgeLockInput!): BridgeLock!
|
||||
bridgeUnlock(input: BridgeUnlockInput!): BridgeLock!
|
||||
}
|
||||
|
||||
type Subscription {
|
||||
# Trigger subscriptions
|
||||
onTriggerStateChanged(triggerId: ID!): Trigger!
|
||||
onTriggerCreated(filter: TriggerFilter): Trigger!
|
||||
|
||||
# Lien subscriptions
|
||||
onLienChanged(debtorRefId: Bytes32!): Lien!
|
||||
onLienPlaced: Lien!
|
||||
onLienReleased: Lien!
|
||||
|
||||
# Packet subscriptions
|
||||
onPacketStatusChanged(packetId: ID!): Packet!
|
||||
onPacketDispatched: Packet!
|
||||
onPacketAcknowledged: Packet!
|
||||
|
||||
# Compliance subscriptions
|
||||
onComplianceChanged(refId: Bytes32!): ComplianceProfile!
|
||||
onFreezeChanged(refId: Bytes32!): ComplianceProfile!
|
||||
|
||||
# Policy subscriptions
|
||||
onPolicyUpdated(token: String!): Token!
|
||||
}
|
||||
|
||||
# Core Types
|
||||
type Token {
|
||||
code: String!
|
||||
address: String!
|
||||
name: String!
|
||||
symbol: String!
|
||||
decimals: Int!
|
||||
issuer: String!
|
||||
policy: TokenPolicy!
|
||||
createdAt: DateTime!
|
||||
}
|
||||
|
||||
type TokenPolicy {
|
||||
paused: Boolean!
|
||||
bridgeOnly: Boolean!
|
||||
bridge: String
|
||||
lienMode: LienMode!
|
||||
forceTransferMode: Boolean!
|
||||
routes: [Rail!]!
|
||||
}
|
||||
|
||||
enum LienMode {
|
||||
OFF
|
||||
HARD_FREEZE
|
||||
ENCUMBERED
|
||||
}
|
||||
|
||||
type Lien {
|
||||
lienId: ID!
|
||||
debtor: String!
|
||||
amount: BigInt!
|
||||
expiry: Int
|
||||
priority: Int!
|
||||
authority: String!
|
||||
reasonCode: ReasonCode!
|
||||
active: Boolean!
|
||||
createdAt: DateTime!
|
||||
updatedAt: DateTime!
|
||||
}
|
||||
|
||||
type ComplianceProfile {
|
||||
refId: Bytes32!
|
||||
allowed: Boolean!
|
||||
frozen: Boolean!
|
||||
riskTier: Int
|
||||
jurisdictionHash: Bytes32
|
||||
updatedAt: DateTime!
|
||||
}
|
||||
|
||||
type Account {
|
||||
refId: Bytes32!
|
||||
provider: AccountProvider!
|
||||
metadata: JSON
|
||||
wallets: [Wallet!]!
|
||||
liens: [Lien!]!
|
||||
compliance: ComplianceProfile
|
||||
createdAt: DateTime!
|
||||
}
|
||||
|
||||
type Wallet {
|
||||
refId: Bytes32!
|
||||
provider: WalletProvider!
|
||||
address: String!
|
||||
metadata: JSON
|
||||
accounts: [Account!]!
|
||||
compliance: ComplianceProfile
|
||||
createdAt: DateTime!
|
||||
}
|
||||
|
||||
enum AccountProvider {
|
||||
BANK
|
||||
FINTECH
|
||||
CUSTODIAN
|
||||
OTHER
|
||||
}
|
||||
|
||||
enum WalletProvider {
|
||||
WALLETCONNECT
|
||||
FIREBLOCKS
|
||||
METAMASK
|
||||
OTHER
|
||||
}
|
||||
|
||||
type Trigger {
|
||||
triggerId: ID!
|
||||
rail: Rail!
|
||||
msgType: String!
|
||||
state: TriggerState!
|
||||
instructionId: Bytes32!
|
||||
endToEndId: Bytes32
|
||||
canonicalMessage: CanonicalMessage
|
||||
payloadHash: Bytes32!
|
||||
amount: BigInt!
|
||||
token: String!
|
||||
accountRefId: Bytes32!
|
||||
counterpartyRefId: Bytes32!
|
||||
railTxRef: String
|
||||
packets: [Packet!]!
|
||||
createdAt: DateTime!
|
||||
updatedAt: DateTime!
|
||||
}
|
||||
|
||||
type CanonicalMessage {
|
||||
msgType: String!
|
||||
instructionId: Bytes32!
|
||||
endToEndId: Bytes32
|
||||
accountRefId: Bytes32!
|
||||
counterpartyRefId: Bytes32!
|
||||
token: String!
|
||||
amount: BigInt!
|
||||
currencyCode: Bytes32!
|
||||
payloadHash: Bytes32!
|
||||
createdAt: DateTime!
|
||||
}
|
||||
|
||||
type Packet {
|
||||
packetId: ID!
|
||||
triggerId: ID!
|
||||
instructionId: Bytes32!
|
||||
payloadHash: Bytes32!
|
||||
channel: PacketChannel!
|
||||
messageRef: String
|
||||
status: PacketStatus!
|
||||
acknowledgements: [Acknowledgement!]!
|
||||
createdAt: DateTime!
|
||||
dispatchedAt: DateTime
|
||||
}
|
||||
|
||||
type Acknowledgement {
|
||||
ackId: String!
|
||||
receivedAt: DateTime!
|
||||
status: AcknowledgementStatus!
|
||||
}
|
||||
|
||||
enum PacketChannel {
|
||||
PDF
|
||||
AS4
|
||||
EMAIL
|
||||
PORTAL
|
||||
}
|
||||
|
||||
enum PacketStatus {
|
||||
GENERATED
|
||||
DISPATCHED
|
||||
DELIVERED
|
||||
ACKNOWLEDGED
|
||||
FAILED
|
||||
}
|
||||
|
||||
enum AcknowledgementStatus {
|
||||
RECEIVED
|
||||
ACCEPTED
|
||||
REJECTED
|
||||
}
|
||||
|
||||
type BridgeLock {
|
||||
lockId: ID!
|
||||
token: String!
|
||||
amount: BigInt!
|
||||
from: String!
|
||||
targetChain: Bytes32!
|
||||
targetRecipient: String!
|
||||
status: BridgeLockStatus!
|
||||
sourceChain: Bytes32
|
||||
sourceTx: Bytes32
|
||||
proof: String
|
||||
createdAt: DateTime!
|
||||
unlockedAt: DateTime
|
||||
}
|
||||
|
||||
enum BridgeLockStatus {
|
||||
LOCKED
|
||||
UNLOCKED
|
||||
PENDING
|
||||
}
|
||||
|
||||
type BridgeCorridor {
|
||||
targetChain: Bytes32!
|
||||
chainId: String!
|
||||
verificationMode: VerificationMode!
|
||||
enabled: Boolean!
|
||||
}
|
||||
|
||||
enum VerificationMode {
|
||||
LIGHT_CLIENT
|
||||
MULTISIG
|
||||
ORACLE
|
||||
}
|
||||
|
||||
enum Rail {
|
||||
FEDWIRE
|
||||
SWIFT
|
||||
SEPA
|
||||
RTGS
|
||||
}
|
||||
|
||||
enum TriggerState {
|
||||
CREATED
|
||||
VALIDATED
|
||||
SUBMITTED_TO_RAIL
|
||||
PENDING
|
||||
SETTLED
|
||||
REJECTED
|
||||
CANCELLED
|
||||
RECALLED
|
||||
}
|
||||
|
||||
enum ReasonCode {
|
||||
OK
|
||||
PAUSED
|
||||
FROM_FROZEN
|
||||
TO_FROZEN
|
||||
FROM_NOT_COMPLIANT
|
||||
TO_NOT_COMPLIANT
|
||||
LIEN_BLOCK
|
||||
INSUFF_FREE_BAL
|
||||
BRIDGE_ONLY
|
||||
NOT_ALLOWED_ROUTE
|
||||
UNAUTHORIZED
|
||||
CONFIG_ERROR
|
||||
}
|
||||
|
||||
# Connection types for pagination
|
||||
type TokenConnection {
|
||||
items: [Token!]!
|
||||
total: Int!
|
||||
limit: Int!
|
||||
offset: Int!
|
||||
}
|
||||
|
||||
type LienConnection {
|
||||
items: [Lien!]!
|
||||
total: Int!
|
||||
limit: Int!
|
||||
offset: Int!
|
||||
}
|
||||
|
||||
type TriggerConnection {
|
||||
items: [Trigger!]!
|
||||
total: Int!
|
||||
limit: Int!
|
||||
offset: Int!
|
||||
}
|
||||
|
||||
type PacketConnection {
|
||||
items: [Packet!]!
|
||||
total: Int!
|
||||
limit: Int!
|
||||
offset: Int!
|
||||
}
|
||||
|
||||
type BridgeLockConnection {
|
||||
items: [BridgeLock!]!
|
||||
total: Int!
|
||||
limit: Int!
|
||||
offset: Int!
|
||||
}
|
||||
|
||||
# Filter types
|
||||
input TokenFilter {
|
||||
code: String
|
||||
issuer: String
|
||||
}
|
||||
|
||||
input LienFilter {
|
||||
debtor: String
|
||||
active: Boolean
|
||||
}
|
||||
|
||||
input TriggerFilter {
|
||||
state: TriggerState
|
||||
rail: Rail
|
||||
msgType: String
|
||||
instructionId: Bytes32
|
||||
}
|
||||
|
||||
input PacketFilter {
|
||||
triggerId: ID
|
||||
instructionId: Bytes32
|
||||
status: PacketStatus
|
||||
}
|
||||
|
||||
input BridgeLockFilter {
|
||||
token: String
|
||||
status: BridgeLockStatus
|
||||
}
|
||||
|
||||
input Paging {
|
||||
limit: Int = 20
|
||||
offset: Int = 0
|
||||
}
|
||||
|
||||
# Input types
|
||||
input DeployTokenInput {
|
||||
name: String!
|
||||
symbol: String!
|
||||
decimals: Int!
|
||||
issuer: String!
|
||||
defaultLienMode: LienMode = ENCUMBERED
|
||||
bridgeOnly: Boolean = false
|
||||
bridge: String
|
||||
}
|
||||
|
||||
input UpdatePolicyInput {
|
||||
paused: Boolean
|
||||
bridgeOnly: Boolean
|
||||
bridge: String
|
||||
lienMode: LienMode
|
||||
forceTransferMode: Boolean
|
||||
routes: [Rail!]
|
||||
}
|
||||
|
||||
input MintInput {
|
||||
to: String!
|
||||
amount: BigInt!
|
||||
reasonCode: ReasonCode
|
||||
}
|
||||
|
||||
input BurnInput {
|
||||
from: String!
|
||||
amount: BigInt!
|
||||
reasonCode: ReasonCode
|
||||
}
|
||||
|
||||
input ClawbackInput {
|
||||
from: String!
|
||||
to: String!
|
||||
amount: BigInt!
|
||||
reasonCode: ReasonCode
|
||||
}
|
||||
|
||||
input ForceTransferInput {
|
||||
from: String!
|
||||
to: String!
|
||||
amount: BigInt!
|
||||
reasonCode: ReasonCode
|
||||
}
|
||||
|
||||
input PlaceLienInput {
|
||||
debtor: String!
|
||||
amount: BigInt!
|
||||
expiry: Int
|
||||
priority: Int
|
||||
reasonCode: ReasonCode
|
||||
}
|
||||
|
||||
input SetComplianceInput {
|
||||
allowed: Boolean!
|
||||
riskTier: Int
|
||||
jurisdictionHash: Bytes32
|
||||
}
|
||||
|
||||
input LinkAccountWalletInput {
|
||||
accountRefId: Bytes32!
|
||||
walletRefId: Bytes32!
|
||||
}
|
||||
|
||||
input SubmitInboundMessageInput {
|
||||
msgType: String!
|
||||
instructionId: Bytes32!
|
||||
endToEndId: Bytes32
|
||||
payloadHash: Bytes32!
|
||||
payload: String!
|
||||
rail: Rail!
|
||||
}
|
||||
|
||||
input SubmitOutboundMessageInput {
|
||||
msgType: String!
|
||||
instructionId: Bytes32!
|
||||
endToEndId: Bytes32
|
||||
payloadHash: Bytes32!
|
||||
payload: String!
|
||||
rail: Rail!
|
||||
token: String!
|
||||
amount: BigInt!
|
||||
accountRefId: Bytes32!
|
||||
counterpartyRefId: Bytes32!
|
||||
}
|
||||
|
||||
input GeneratePacketInput {
|
||||
triggerId: ID!
|
||||
channel: PacketChannel!
|
||||
options: JSON
|
||||
}
|
||||
|
||||
input DispatchPacketInput {
|
||||
channel: PacketChannel!
|
||||
recipient: String
|
||||
}
|
||||
|
||||
input AcknowledgePacketInput {
|
||||
status: AcknowledgementStatus!
|
||||
ackId: String
|
||||
}
|
||||
|
||||
input BridgeLockInput {
|
||||
token: String!
|
||||
amount: BigInt!
|
||||
targetChain: Bytes32!
|
||||
targetRecipient: String!
|
||||
}
|
||||
|
||||
input BridgeUnlockInput {
|
||||
lockId: ID!
|
||||
token: String!
|
||||
to: String!
|
||||
amount: BigInt!
|
||||
sourceChain: Bytes32!
|
||||
sourceTx: Bytes32!
|
||||
proof: String!
|
||||
}
|
||||
|
||||
# Result types
|
||||
type TransactionResult {
|
||||
txHash: Bytes32!
|
||||
status: TransactionStatus!
|
||||
blockNumber: Int
|
||||
}
|
||||
|
||||
enum TransactionStatus {
|
||||
PENDING
|
||||
SUCCESS
|
||||
FAILED
|
||||
}
|
||||
|
||||
type MappingResult {
|
||||
accountRefId: Bytes32!
|
||||
walletRefId: Bytes32!
|
||||
linked: Boolean!
|
||||
createdAt: DateTime!
|
||||
}
|
||||
|
||||
type EncumbranceSummary {
|
||||
accountRefId: Bytes32!
|
||||
encumbrances: [TokenEncumbrance!]!
|
||||
}
|
||||
|
||||
type TokenEncumbrance {
|
||||
token: String!
|
||||
tokenCode: String!
|
||||
balance: BigInt!
|
||||
activeEncumbrance: BigInt!
|
||||
freeBalance: BigInt!
|
||||
}
|
||||
|
||||
# JSON scalar for metadata
|
||||
scalar JSON
|
||||
|
||||
Reference in New Issue
Block a user