diff --git a/docker/dbinit.sql b/docker/dbinit.sql index 33a515011..72d28611c 100644 --- a/docker/dbinit.sql +++ b/docker/dbinit.sql @@ -13,3 +13,7 @@ ALTER DATABASE wallet_backend OWNER TO wallet_backend; CREATE USER boutique_backend WITH PASSWORD 'boutique_backend'; CREATE DATABASE boutique_backend; ALTER DATABASE boutique_backend OWNER TO boutique_backend; + +CREATE USER kratos WITH PASSWORD 'kratos'; +CREATE DATABASE kratos; +ALTER DATABASE kratos OWNER TO kratos; diff --git a/docker/dev/docker-compose.yml b/docker/dev/docker-compose.yml index 0e4d80b03..a8694aa74 100644 --- a/docker/dev/docker-compose.yml +++ b/docker/dev/docker-compose.yml @@ -50,7 +50,7 @@ services: AUTH_IDENTITY_SERVER_SECRET: ${AUTH_IDENTITY_SERVER_SECRET} SENDGRID_API_KEY: ${SENDGRID_API_KEY} FROM_EMAIL: ${FROM_EMAIL} - SEND_EMAIL: ${SEND_EMAIL} + SEND_EMAIL: ${SEND_EMAIL:-false} RATE_API_KEY: ${RATE_API_KEY} BASE_ASSET_SCALE: 2 MAX_ASSET_SCALE: 9 @@ -90,7 +90,7 @@ services: # Rafiki rafiki-auth: container_name: rafiki-auth - image: ghcr.io/interledger/rafiki-auth:v1.0.0-alpha.13 + image: ghcr.io/interledger/rafiki-auth:v1.0.0-alpha.14 restart: always networks: - testnet @@ -105,8 +105,8 @@ services: AUTH_SERVER_URL: http://localhost:3006 AUTH_DATABASE_URL: postgresql://rafiki_auth:rafiki_auth@postgres/rafiki_auth IDENTITY_SERVER_URL: http://localhost:4003/grant-interactions - IDENTITY_SERVER_SECRET: ${AUTH_IDENTITY_SERVER_SECRET} - COOKIE_KEY: ${AUTH_COOKIE_KEY} + IDENTITY_SERVER_SECRET: ${AUTH_IDENTITY_SERVER_SECRET:-327132b5-99e9-4eb8-8a25-2b7d7738ece1} + COOKIE_KEY: ${AUTH_COOKIE_KEY:-8fd398393c47dd27a3167d9c081c094f} WAIT_SECONDS: 1 REDIS_URL: redis://redis:6379/0 depends_on: @@ -115,7 +115,7 @@ services: rafiki-backend: container_name: rafiki-backend - image: ghcr.io/interledger/rafiki-backend:v1.0.0-alpha.13 + image: ghcr.io/interledger/rafiki-backend:v1.0.0-alpha.14 restart: always privileged: true volumes: @@ -141,6 +141,7 @@ services: AUTH_SERVER_GRANT_URL: http://rafiki-auth:3006 AUTH_SERVER_INTROSPECTION_URL: http://rafiki-auth:3007 ILP_ADDRESS: test.net + ILP_CONNECTOR_URL: http://127.0.0.1:3002 STREAM_SECRET: BjPXtnd00G2mRQwP/8ZpwyZASOch5sUXT5o0iR5b5wU= ADMIN_KEY: admin OPEN_PAYMENTS_URL: http://rafiki-backend @@ -154,6 +155,7 @@ services: AUTO_PEERING_SERVER_PORT: 3005 INSTANCE_NAME: 'Testnet Wallet' SLIPPAGE: 0.01 + KEY_ID: rafiki depends_on: - postgres - redis @@ -161,7 +163,7 @@ services: rafiki-frontend: container_name: rafiki-frontend - image: ghcr.io/interledger/rafiki-frontend:v1.0.0-alpha.13 + image: ghcr.io/interledger/rafiki-frontend:v1.0.0-alpha.14 depends_on: - rafiki-backend restart: always @@ -174,8 +176,28 @@ services: PORT: 3012 GRAPHQL_URL: http://rafiki-backend:3001/graphql OPEN_PAYMENTS_URL: https://rafiki-backend/ + ENABLE_INSECURE_MESSAGE_COOKIE: true + KRATOS_CONTAINER_PUBLIC_URL: 'http://kratos:4433' + KRATOS_BROWSER_PUBLIC_URL: 'http://localhost:4433' + KRATOS_ADMIN_URL: 'http://kratos:4434/admin' <<: *logging + kratos: + image: 'oryd/kratos:v0.13.0' + privileged: true + depends_on: + - postgres + - mailslurper + ports: + - '4433:4433' + volumes: + - ../entrypoint.sh:/entrypoint.sh + - ../identity.schema.json:/etc/config/kratos/identity.schema.json + - ./kratos.yml:/etc/config/kratos/kratos.yml + entrypoint: ['/entrypoint.sh'] + networks: + - testnet + tigerbeetle: image: ghcr.io/tigerbeetle/tigerbeetle:0.15.3 privileged: true @@ -208,6 +230,14 @@ services: networks: - testnet + mailslurper: + image: oryd/mailslurper:latest-smtps + ports: + - '4436:4436' + - '4437:4437' + networks: + - testnet + networks: testnet: driver: bridge diff --git a/docker/dev/kratos.yml b/docker/dev/kratos.yml new file mode 100644 index 000000000..326acfb71 --- /dev/null +++ b/docker/dev/kratos.yml @@ -0,0 +1,91 @@ +version: v0.13.0 + +dsn: postgres://cloud_nine_kratos:kratos_password@shared-database:5432/cloud_nine_kratos?sslmode=disable&max_conns=20&max_idle_conns=4 + +serve: + public: + base_url: http://localhost:4433/ + cors: + enabled: true + admin: + base_url: http://kratos:4434/ + +selfservice: + default_browser_return_url: http://localhost:3010/ + allowed_return_urls: + - http://localhost:3010 + + methods: + link: + config: + lifespan: 1h + base_url: http://localhost:4433 + enabled: true + password: + enabled: true + + flows: + error: + ui_url: http://localhost:3010/error + + settings: + ui_url: http://localhost:3010/settings + privileged_session_max_age: 15m + required_aal: highest_available + + recovery: + enabled: true + ui_url: http://localhost:3010/auth/recovery + use: link + after: + hooks: + - hook: revoke_active_sessions + + verification: + enabled: false + + logout: + after: + default_browser_return_url: http://localhost:3010/auth + + login: + ui_url: http://localhost:3010/auth/login + lifespan: 10m + + registration: + enabled: false + +log: + level: debug + format: json + leak_sensitive_values: true + +secrets: + cookie: + - PLEASE-CHANGE-ME-I-AM-VERY-INSECURE + cipher: + - 32-LONG-SECRET-NOT-SECURE-AT-ALL + +ciphers: + algorithm: xchacha20-poly1305 + +hashers: + algorithm: bcrypt + bcrypt: + cost: 8 + +identity: + schemas: + - id: default + url: file:///etc/config/kratos/identity.schema.json + +courier: + smtp: + connection_uri: smtps://test:test@mailslurper:1025/?skip_ssl_verify=true + +session: + lifespan: 1h + cookie: + persistent: false + same_site: Strict + path: / diff --git a/docker/prod/entrypoint.sh b/docker/entrypoint.sh similarity index 100% rename from docker/prod/entrypoint.sh rename to docker/entrypoint.sh diff --git a/docker/prod/identity.schema.json b/docker/identity.schema.json similarity index 100% rename from docker/prod/identity.schema.json rename to docker/identity.schema.json diff --git a/docker/prod/docker-compose.yml b/docker/prod/docker-compose.yml index e84dadbd3..eb499d987 100644 --- a/docker/prod/docker-compose.yml +++ b/docker/prod/docker-compose.yml @@ -119,7 +119,7 @@ services: <<: *logging rafiki-auth: - image: ghcr.io/interledger/rafiki-auth:v1.0.0-alpha.13 + image: ghcr.io/interledger/rafiki-auth:v1.0.0-alpha.14 container_name: rafiki-auth environment: NODE_ENV: ${NODE_ENV} @@ -145,7 +145,7 @@ services: <<: *logging rafiki-backend: - image: ghcr.io/interledger/rafiki-backend:v1.0.0-alpha.13 + image: ghcr.io/interledger/rafiki-backend:v1.0.0-alpha.14 container_name: rafiki-backend depends_on: - postgres @@ -214,7 +214,7 @@ services: <<: *logging rafiki-frontend: - image: ghcr.io/interledger/rafiki-frontend:v1.0.0-alpha.13 + image: ghcr.io/interledger/rafiki-frontend:v1.0.0-alpha.14 container_name: rafiki-frontend depends_on: - rafiki-backend @@ -271,8 +271,8 @@ services: ports: - '4433:4433' volumes: - - ./entrypoint.sh:/entrypoint.sh - - ./identity.schema.json:/etc/config/kratos/identity.schema.json + - ../entrypoint.sh:/entrypoint.sh + - ../identity.schema.json:/etc/config/kratos/identity.schema.json - ./kratos.yml:/etc/config/kratos/kratos.yml entrypoint: ['/entrypoint.sh'] networks: diff --git a/packages/wallet/backend/src/createContainer.ts b/packages/wallet/backend/src/createContainer.ts index 945cb6789..ae68f488d 100644 --- a/packages/wallet/backend/src/createContainer.ts +++ b/packages/wallet/backend/src/createContainer.ts @@ -114,7 +114,7 @@ export async function createContainer( authGraphQLClient: asFunction(createAuthGraphQLClient).singleton(), rapydClient: asClassSingletonWithLogger(RapydClient, logger), rapydService: asClass(RapydService).singleton(), - rafikiClient: asClassSingletonWithLogger(RafikiClient, logger).singleton(), + rafikiClient: asClass(RafikiClient).singleton(), rafikiAuthService: asClass(RafikiAuthService).singleton(), accountService: asClass(AccountService).singleton(), ratesService: asClass(RatesService).singleton(), diff --git a/packages/wallet/backend/src/rafiki/backend/generated/graphql.ts b/packages/wallet/backend/src/rafiki/backend/generated/graphql.ts index ee39d2c73..a232bdd35 100644 --- a/packages/wallet/backend/src/rafiki/backend/generated/graphql.ts +++ b/packages/wallet/backend/src/rafiki/backend/generated/graphql.ts @@ -90,12 +90,9 @@ export type AssetEdge = { node: Asset; }; -export type AssetMutationResponse = MutationResponse & { +export type AssetMutationResponse = { __typename?: 'AssetMutationResponse'; asset?: Maybe; - code: Scalars['String']['output']; - message: Scalars['String']['output']; - success: Scalars['Boolean']['output']; }; export type AssetsConnection = { @@ -184,12 +181,9 @@ export type CreateOrUpdatePeerByUrlInput = { peerUrl: Scalars['String']['input']; }; -export type CreateOrUpdatePeerByUrlMutationResponse = MutationResponse & { +export type CreateOrUpdatePeerByUrlMutationResponse = { __typename?: 'CreateOrUpdatePeerByUrlMutationResponse'; - code: Scalars['String']['output']; - message: Scalars['String']['output']; peer?: Maybe; - success: Scalars['Boolean']['output']; }; export type CreateOutgoingPaymentFromIncomingPaymentInput = { @@ -257,12 +251,9 @@ export type CreatePeerLiquidityWithdrawalInput = { timeoutSeconds: Scalars['BigInt']['input']; }; -export type CreatePeerMutationResponse = MutationResponse & { +export type CreatePeerMutationResponse = { __typename?: 'CreatePeerMutationResponse'; - code: Scalars['String']['output']; - message: Scalars['String']['output']; peer?: Maybe; - success: Scalars['Boolean']['output']; }; export type CreateQuoteInput = { @@ -293,10 +284,7 @@ export type CreateReceiverInput = { export type CreateReceiverResponse = { __typename?: 'CreateReceiverResponse'; - code: Scalars['String']['output']; - message?: Maybe; receiver?: Maybe; - success: Scalars['Boolean']['output']; }; export type CreateWalletAddressInput = { @@ -320,19 +308,13 @@ export type CreateWalletAddressKeyInput = { walletAddressId: Scalars['String']['input']; }; -export type CreateWalletAddressKeyMutationResponse = MutationResponse & { +export type CreateWalletAddressKeyMutationResponse = { __typename?: 'CreateWalletAddressKeyMutationResponse'; - code: Scalars['String']['output']; - message: Scalars['String']['output']; - success: Scalars['Boolean']['output']; walletAddressKey?: Maybe; }; -export type CreateWalletAddressMutationResponse = MutationResponse & { +export type CreateWalletAddressMutationResponse = { __typename?: 'CreateWalletAddressMutationResponse'; - code: Scalars['String']['output']; - message: Scalars['String']['output']; - success: Scalars['Boolean']['output']; walletAddress?: Maybe; }; @@ -358,11 +340,9 @@ export type DeleteAssetInput = { idempotencyKey?: InputMaybe; }; -export type DeleteAssetMutationResponse = MutationResponse & { +export type DeleteAssetMutationResponse = { __typename?: 'DeleteAssetMutationResponse'; - code: Scalars['String']['output']; - message: Scalars['String']['output']; - success: Scalars['Boolean']['output']; + asset?: Maybe; }; export type DeletePeerInput = { @@ -371,10 +351,8 @@ export type DeletePeerInput = { idempotencyKey?: InputMaybe; }; -export type DeletePeerMutationResponse = MutationResponse & { +export type DeletePeerMutationResponse = { __typename?: 'DeletePeerMutationResponse'; - code: Scalars['String']['output']; - message: Scalars['String']['output']; success: Scalars['Boolean']['output']; }; @@ -531,10 +509,7 @@ export type IncomingPaymentEdge = { export type IncomingPaymentResponse = { __typename?: 'IncomingPaymentResponse'; - code: Scalars['String']['output']; - message?: Maybe; payment?: Maybe; - success: Scalars['Boolean']['output']; }; export enum IncomingPaymentState { @@ -594,11 +569,8 @@ export enum LiquidityError { UnknownWalletAddress = 'UnknownWalletAddress' } -export type LiquidityMutationResponse = MutationResponse & { +export type LiquidityMutationResponse = { __typename?: 'LiquidityMutationResponse'; - code: Scalars['String']['output']; - error?: Maybe; - message: Scalars['String']['output']; success: Scalars['Boolean']['output']; }; @@ -834,12 +806,6 @@ export type MutationWithdrawEventLiquidityArgs = { input: WithdrawEventLiquidityInput; }; -export type MutationResponse = { - code: Scalars['String']['output']; - message: Scalars['String']['output']; - success: Scalars['Boolean']['output']; -}; - export type OutgoingPayment = BasePayment & Model & { __typename?: 'OutgoingPayment'; /** Information about the wallet address of the Open Payments client that created the outgoing payment. */ @@ -884,10 +850,7 @@ export type OutgoingPaymentEdge = { export type OutgoingPaymentResponse = { __typename?: 'OutgoingPaymentResponse'; - code: Scalars['String']['output']; - message?: Maybe; payment?: Maybe; - success: Scalars['Boolean']['output']; }; export enum OutgoingPaymentState { @@ -1148,10 +1111,7 @@ export type QuoteEdge = { export type QuoteResponse = { __typename?: 'QuoteResponse'; - code: Scalars['String']['output']; - message?: Maybe; quote?: Maybe; - success: Scalars['Boolean']['output']; }; export type Receiver = { @@ -1183,11 +1143,8 @@ export type RevokeWalletAddressKeyInput = { idempotencyKey?: InputMaybe; }; -export type RevokeWalletAddressKeyMutationResponse = MutationResponse & { +export type RevokeWalletAddressKeyMutationResponse = { __typename?: 'RevokeWalletAddressKeyMutationResponse'; - code: Scalars['String']['output']; - message: Scalars['String']['output']; - success: Scalars['Boolean']['output']; walletAddressKey?: Maybe; }; @@ -1202,12 +1159,9 @@ export type SetFeeInput = { type: FeeType; }; -export type SetFeeResponse = MutationResponse & { +export type SetFeeResponse = { __typename?: 'SetFeeResponse'; - code: Scalars['String']['output']; fee?: Maybe; - message: Scalars['String']['output']; - success: Scalars['Boolean']['output']; }; export enum SortOrder { @@ -1217,13 +1171,6 @@ export enum SortOrder { Desc = 'DESC' } -export type TransferMutationResponse = MutationResponse & { - __typename?: 'TransferMutationResponse'; - code: Scalars['String']['output']; - message: Scalars['String']['output']; - success: Scalars['Boolean']['output']; -}; - export type TriggerWalletAddressEventsInput = { /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ idempotencyKey?: InputMaybe; @@ -1231,13 +1178,10 @@ export type TriggerWalletAddressEventsInput = { limit: Scalars['Int']['input']; }; -export type TriggerWalletAddressEventsMutationResponse = MutationResponse & { +export type TriggerWalletAddressEventsMutationResponse = { __typename?: 'TriggerWalletAddressEventsMutationResponse'; - code: Scalars['String']['output']; /** Number of events triggered */ count?: Maybe; - message: Scalars['String']['output']; - success: Scalars['Boolean']['output']; }; export type UpdateAssetInput = { @@ -1268,15 +1212,14 @@ export type UpdatePeerInput = { staticIlpAddress?: InputMaybe; }; -export type UpdatePeerMutationResponse = MutationResponse & { +export type UpdatePeerMutationResponse = { __typename?: 'UpdatePeerMutationResponse'; - code: Scalars['String']['output']; - message: Scalars['String']['output']; peer?: Maybe; - success: Scalars['Boolean']['output']; }; export type UpdateWalletAddressInput = { + /** List additional properties associated with this wallet address. */ + additionalProperties?: InputMaybe>; /** ID of wallet address to update */ id: Scalars['ID']['input']; /** Unique key to ensure duplicate or retried requests are processed only once. See [idempotence](https://en.wikipedia.org/wiki/Idempotence) */ @@ -1287,11 +1230,8 @@ export type UpdateWalletAddressInput = { status?: InputMaybe; }; -export type UpdateWalletAddressMutationResponse = MutationResponse & { +export type UpdateWalletAddressMutationResponse = { __typename?: 'UpdateWalletAddressMutationResponse'; - code: Scalars['String']['output']; - message: Scalars['String']['output']; - success: Scalars['Boolean']['output']; walletAddress?: Maybe; }; @@ -1415,12 +1355,8 @@ export type WalletAddressWithdrawal = { walletAddress: WalletAddress; }; -export type WalletAddressWithdrawalMutationResponse = MutationResponse & { +export type WalletAddressWithdrawalMutationResponse = { __typename?: 'WalletAddressWithdrawalMutationResponse'; - code: Scalars['String']['output']; - error?: Maybe; - message: Scalars['String']['output']; - success: Scalars['Boolean']['output']; withdrawal?: Maybe; }; @@ -1470,7 +1406,7 @@ export type CreateAssetMutationVariables = Exact<{ }>; -export type CreateAssetMutation = { __typename?: 'Mutation', createAsset: { __typename?: 'AssetMutationResponse', code: string, success: boolean, message: string, asset?: { __typename?: 'Asset', id: string, code: string, scale: number } | null } }; +export type CreateAssetMutation = { __typename?: 'Mutation', createAsset: { __typename?: 'AssetMutationResponse', asset?: { __typename?: 'Asset', id: string, code: string, scale: number } | null } }; export type GetAssetsQueryVariables = Exact<{ after?: InputMaybe; @@ -1494,7 +1430,7 @@ export type CreateIncomingPaymentMutationVariables = Exact<{ }>; -export type CreateIncomingPaymentMutation = { __typename?: 'Mutation', createIncomingPayment: { __typename?: 'IncomingPaymentResponse', code: string, message?: string | null, success: boolean, payment?: { __typename?: 'IncomingPayment', createdAt: string, metadata?: any | null, expiresAt: string, id: string, walletAddressId: string, state: IncomingPaymentState, incomingAmount?: { __typename?: 'Amount', assetCode: string, assetScale: number, value: bigint } | null, receivedAmount: { __typename?: 'Amount', assetCode: string, assetScale: number, value: bigint } } | null } }; +export type CreateIncomingPaymentMutation = { __typename?: 'Mutation', createIncomingPayment: { __typename?: 'IncomingPaymentResponse', payment?: { __typename?: 'IncomingPayment', createdAt: string, metadata?: any | null, expiresAt: string, id: string, walletAddressId: string, state: IncomingPaymentState, incomingAmount?: { __typename?: 'Amount', assetCode: string, assetScale: number, value: bigint } | null, receivedAmount: { __typename?: 'Amount', assetCode: string, assetScale: number, value: bigint } } | null } }; export type WithdrawLiquidityMutationVariables = Exact<{ eventId: Scalars['String']['input']; @@ -1502,7 +1438,7 @@ export type WithdrawLiquidityMutationVariables = Exact<{ }>; -export type WithdrawLiquidityMutation = { __typename?: 'Mutation', withdrawEventLiquidity?: { __typename?: 'LiquidityMutationResponse', code: string, success: boolean, message: string, error?: LiquidityError | null } | null }; +export type WithdrawLiquidityMutation = { __typename?: 'Mutation', withdrawEventLiquidity?: { __typename?: 'LiquidityMutationResponse', success: boolean } | null }; export type DepositLiquidityMutationVariables = Exact<{ eventId: Scalars['String']['input']; @@ -1510,21 +1446,21 @@ export type DepositLiquidityMutationVariables = Exact<{ }>; -export type DepositLiquidityMutation = { __typename?: 'Mutation', depositEventLiquidity?: { __typename?: 'LiquidityMutationResponse', code: string, success: boolean, message: string, error?: LiquidityError | null } | null }; +export type DepositLiquidityMutation = { __typename?: 'Mutation', depositEventLiquidity?: { __typename?: 'LiquidityMutationResponse', success: boolean } | null }; export type CreateOutgoingPaymentMutationVariables = Exact<{ input: CreateOutgoingPaymentInput; }>; -export type CreateOutgoingPaymentMutation = { __typename?: 'Mutation', createOutgoingPayment: { __typename?: 'OutgoingPaymentResponse', code: string, message?: string | null, success: boolean, payment?: { __typename?: 'OutgoingPayment', createdAt: string, metadata?: any | null, error?: string | null, id: string, walletAddressId: string, receiver: string, state: OutgoingPaymentState, stateAttempts: number, quote?: { __typename?: 'Quote', createdAt: string, expiresAt: string, highEstimatedExchangeRate: number, id: string, lowEstimatedExchangeRate: number, maxPacketAmount: bigint, minExchangeRate: number, walletAddressId: string, receiver: string, receiveAmount: { __typename?: 'Amount', assetCode: string, assetScale: number, value: bigint }, debitAmount: { __typename?: 'Amount', assetCode: string, assetScale: number, value: bigint } } | null, receiveAmount: { __typename?: 'Amount', assetCode: string, assetScale: number, value: bigint }, debitAmount: { __typename?: 'Amount', assetCode: string, assetScale: number, value: bigint }, sentAmount: { __typename?: 'Amount', assetCode: string, assetScale: number, value: bigint } } | null } }; +export type CreateOutgoingPaymentMutation = { __typename?: 'Mutation', createOutgoingPayment: { __typename?: 'OutgoingPaymentResponse', payment?: { __typename?: 'OutgoingPayment', createdAt: string, metadata?: any | null, error?: string | null, id: string, walletAddressId: string, receiver: string, state: OutgoingPaymentState, stateAttempts: number, quote?: { __typename?: 'Quote', createdAt: string, expiresAt: string, highEstimatedExchangeRate: number, id: string, lowEstimatedExchangeRate: number, maxPacketAmount: bigint, minExchangeRate: number, walletAddressId: string, receiver: string, receiveAmount: { __typename?: 'Amount', assetCode: string, assetScale: number, value: bigint }, debitAmount: { __typename?: 'Amount', assetCode: string, assetScale: number, value: bigint } } | null, receiveAmount: { __typename?: 'Amount', assetCode: string, assetScale: number, value: bigint }, debitAmount: { __typename?: 'Amount', assetCode: string, assetScale: number, value: bigint }, sentAmount: { __typename?: 'Amount', assetCode: string, assetScale: number, value: bigint } } | null } }; export type CreateQuoteMutationVariables = Exact<{ input: CreateQuoteInput; }>; -export type CreateQuoteMutation = { __typename?: 'Mutation', createQuote: { __typename?: 'QuoteResponse', code: string, message?: string | null, quote?: { __typename?: 'Quote', createdAt: string, expiresAt: string, highEstimatedExchangeRate: number, id: string, lowEstimatedExchangeRate: number, maxPacketAmount: bigint, minExchangeRate: number, walletAddressId: string, receiver: string, receiveAmount: { __typename?: 'Amount', assetCode: string, assetScale: number, value: bigint }, debitAmount: { __typename?: 'Amount', assetCode: string, assetScale: number, value: bigint } } | null } }; +export type CreateQuoteMutation = { __typename?: 'Mutation', createQuote: { __typename?: 'QuoteResponse', quote?: { __typename?: 'Quote', createdAt: string, expiresAt: string, highEstimatedExchangeRate: number, id: string, lowEstimatedExchangeRate: number, maxPacketAmount: bigint, minExchangeRate: number, walletAddressId: string, receiver: string, receiveAmount: { __typename?: 'Amount', assetCode: string, assetScale: number, value: bigint }, debitAmount: { __typename?: 'Amount', assetCode: string, assetScale: number, value: bigint } } | null } }; export type GetQuoteQueryVariables = Exact<{ quoteId: Scalars['String']['input']; @@ -1538,7 +1474,7 @@ export type CreateReceiverMutationVariables = Exact<{ }>; -export type CreateReceiverMutation = { __typename?: 'Mutation', createReceiver: { __typename?: 'CreateReceiverResponse', code: string, message?: string | null, success: boolean, receiver?: { __typename?: 'Receiver', createdAt: string, metadata?: any | null, expiresAt?: string | null, id: string, walletAddressUrl: string, incomingAmount?: { __typename?: 'Amount', assetCode: string, assetScale: number, value: bigint } | null, receivedAmount: { __typename?: 'Amount', assetCode: string, assetScale: number, value: bigint } } | null } }; +export type CreateReceiverMutation = { __typename?: 'Mutation', createReceiver: { __typename?: 'CreateReceiverResponse', receiver?: { __typename?: 'Receiver', createdAt: string, metadata?: any | null, expiresAt?: string | null, id: string, walletAddressUrl: string, incomingAmount?: { __typename?: 'Amount', assetCode: string, assetScale: number, value: bigint } | null, receivedAmount: { __typename?: 'Amount', assetCode: string, assetScale: number, value: bigint } } | null } }; export type GetReceiverQueryVariables = Exact<{ id: Scalars['String']['input']; @@ -1552,25 +1488,25 @@ export type CreateWalletAddressKeyMutationVariables = Exact<{ }>; -export type CreateWalletAddressKeyMutation = { __typename?: 'Mutation', createWalletAddressKey?: { __typename?: 'CreateWalletAddressKeyMutationResponse', code: string, message: string, success: boolean, walletAddressKey?: { __typename?: 'WalletAddressKey', id: string, walletAddressId: string, revoked: boolean, createdAt: string, jwk: { __typename?: 'Jwk', alg: Alg, crv: Crv, kid: string, kty: Kty, x: string } } | null } | null }; +export type CreateWalletAddressKeyMutation = { __typename?: 'Mutation', createWalletAddressKey?: { __typename?: 'CreateWalletAddressKeyMutationResponse', walletAddressKey?: { __typename?: 'WalletAddressKey', id: string, walletAddressId: string, revoked: boolean, createdAt: string, jwk: { __typename?: 'Jwk', alg: Alg, crv: Crv, kid: string, kty: Kty, x: string } } | null } | null }; export type RevokeWalletAddressKeyMutationVariables = Exact<{ input: RevokeWalletAddressKeyInput; }>; -export type RevokeWalletAddressKeyMutation = { __typename?: 'Mutation', revokeWalletAddressKey?: { __typename?: 'RevokeWalletAddressKeyMutationResponse', code: string, message: string, success: boolean, walletAddressKey?: { __typename?: 'WalletAddressKey', id: string, revoked: boolean, walletAddressId: string, createdAt: string } | null } | null }; +export type RevokeWalletAddressKeyMutation = { __typename?: 'Mutation', revokeWalletAddressKey?: { __typename?: 'RevokeWalletAddressKeyMutationResponse', walletAddressKey?: { __typename?: 'WalletAddressKey', id: string, revoked: boolean, walletAddressId: string, createdAt: string } | null } | null }; export type CreateWalletAddressMutationVariables = Exact<{ input: CreateWalletAddressInput; }>; -export type CreateWalletAddressMutation = { __typename?: 'Mutation', createWalletAddress: { __typename?: 'CreateWalletAddressMutationResponse', code: string, success: boolean, message: string, walletAddress?: { __typename?: 'WalletAddress', id: string, url: string, publicName?: string | null } | null } }; +export type CreateWalletAddressMutation = { __typename?: 'Mutation', createWalletAddress: { __typename?: 'CreateWalletAddressMutationResponse', walletAddress?: { __typename?: 'WalletAddress', id: string, url: string, publicName?: string | null } | null } }; export type UpdateWalletAddressMutationVariables = Exact<{ input: UpdateWalletAddressInput; }>; -export type UpdateWalletAddressMutation = { __typename?: 'Mutation', updateWalletAddress: { __typename?: 'UpdateWalletAddressMutationResponse', code: string, success: boolean, message: string } }; +export type UpdateWalletAddressMutation = { __typename?: 'Mutation', updateWalletAddress: { __typename?: 'UpdateWalletAddressMutationResponse', walletAddress?: { __typename?: 'WalletAddress', id: string, url: string, publicName?: string | null } | null } }; diff --git a/packages/wallet/backend/src/rafiki/backend/request/asset.request.ts b/packages/wallet/backend/src/rafiki/backend/request/asset.request.ts index 773ac54a9..466540dc1 100644 --- a/packages/wallet/backend/src/rafiki/backend/request/asset.request.ts +++ b/packages/wallet/backend/src/rafiki/backend/request/asset.request.ts @@ -3,9 +3,6 @@ import { gql } from 'graphql-request' export const createAssetMutation = gql` mutation CreateAssetMutation($input: CreateAssetInput!) { createAsset(input: $input) { - code - success - message asset { id code diff --git a/packages/wallet/backend/src/rafiki/backend/request/incoming-payment.request.ts b/packages/wallet/backend/src/rafiki/backend/request/incoming-payment.request.ts index c9dc0dd2e..7176be0f6 100644 --- a/packages/wallet/backend/src/rafiki/backend/request/incoming-payment.request.ts +++ b/packages/wallet/backend/src/rafiki/backend/request/incoming-payment.request.ts @@ -3,8 +3,6 @@ import { gql } from 'graphql-request' export const createIncomingPaymentMutation = gql` mutation CreateIncomingPaymentMutation($input: CreateIncomingPaymentInput!) { createIncomingPayment(input: $input) { - code - message payment { createdAt metadata @@ -23,7 +21,6 @@ export const createIncomingPaymentMutation = gql` } state } - success } } ` diff --git a/packages/wallet/backend/src/rafiki/backend/request/liquidity.request.ts b/packages/wallet/backend/src/rafiki/backend/request/liquidity.request.ts index 4a47b808e..ab9248e82 100644 --- a/packages/wallet/backend/src/rafiki/backend/request/liquidity.request.ts +++ b/packages/wallet/backend/src/rafiki/backend/request/liquidity.request.ts @@ -8,10 +8,7 @@ export const withdrawLiquidityMutation = gql` withdrawEventLiquidity( input: { eventId: $eventId, idempotencyKey: $idempotencyKey } ) { - code success - message - error } } ` @@ -24,10 +21,7 @@ export const depositLiquidityMutation = gql` depositEventLiquidity( input: { eventId: $eventId, idempotencyKey: $idempotencyKey } ) { - code success - message - error } } ` diff --git a/packages/wallet/backend/src/rafiki/backend/request/outgoing-payment.request.ts b/packages/wallet/backend/src/rafiki/backend/request/outgoing-payment.request.ts index e686175e7..5e5e62f8f 100644 --- a/packages/wallet/backend/src/rafiki/backend/request/outgoing-payment.request.ts +++ b/packages/wallet/backend/src/rafiki/backend/request/outgoing-payment.request.ts @@ -3,8 +3,6 @@ import { gql } from 'graphql-request' export const createOutgoingPaymentMutation = gql` mutation CreateOutgoingPaymentMutation($input: CreateOutgoingPaymentInput!) { createOutgoingPayment(input: $input) { - code - message payment { createdAt metadata @@ -51,7 +49,6 @@ export const createOutgoingPaymentMutation = gql` state stateAttempts } - success } } ` diff --git a/packages/wallet/backend/src/rafiki/backend/request/quote.request.ts b/packages/wallet/backend/src/rafiki/backend/request/quote.request.ts index 3c233fe29..361041ead 100644 --- a/packages/wallet/backend/src/rafiki/backend/request/quote.request.ts +++ b/packages/wallet/backend/src/rafiki/backend/request/quote.request.ts @@ -3,8 +3,6 @@ import { gql } from 'graphql-request' export const createQuoteMutation = gql` mutation CreateQuoteMutation($input: CreateQuoteInput!) { createQuote(input: $input) { - code - message quote { createdAt expiresAt diff --git a/packages/wallet/backend/src/rafiki/backend/request/receiver.request.ts b/packages/wallet/backend/src/rafiki/backend/request/receiver.request.ts index 5f7cba664..38c82e197 100644 --- a/packages/wallet/backend/src/rafiki/backend/request/receiver.request.ts +++ b/packages/wallet/backend/src/rafiki/backend/request/receiver.request.ts @@ -3,8 +3,6 @@ import { gql } from 'graphql-request' export const createReceiverMutation = gql` mutation CreateReceiverMutation($input: CreateReceiverInput!) { createReceiver(input: $input) { - code - message receiver { createdAt metadata @@ -22,7 +20,6 @@ export const createReceiverMutation = gql` value } } - success } } ` diff --git a/packages/wallet/backend/src/rafiki/backend/request/wallet-address-key.request.ts b/packages/wallet/backend/src/rafiki/backend/request/wallet-address-key.request.ts index dca0a36f9..3509d99fa 100644 --- a/packages/wallet/backend/src/rafiki/backend/request/wallet-address-key.request.ts +++ b/packages/wallet/backend/src/rafiki/backend/request/wallet-address-key.request.ts @@ -5,9 +5,6 @@ export const createWalletAddressKeyMutation = gql` $input: CreateWalletAddressKeyInput! ) { createWalletAddressKey(input: $input) { - code - message - success walletAddressKey { id walletAddressId @@ -30,9 +27,6 @@ export const revokeWalletAddressKeyMutation = gql` $input: RevokeWalletAddressKeyInput! ) { revokeWalletAddressKey(input: $input) { - code - message - success walletAddressKey { id revoked diff --git a/packages/wallet/backend/src/rafiki/backend/request/wallet-address.request.ts b/packages/wallet/backend/src/rafiki/backend/request/wallet-address.request.ts index a1e0a205c..5117e7453 100644 --- a/packages/wallet/backend/src/rafiki/backend/request/wallet-address.request.ts +++ b/packages/wallet/backend/src/rafiki/backend/request/wallet-address.request.ts @@ -3,9 +3,6 @@ import { gql } from 'graphql-request' export const createWalletAddressMutation = gql` mutation CreateWalletAddressMutation($input: CreateWalletAddressInput!) { createWalletAddress(input: $input) { - code - success - message walletAddress { id url @@ -18,9 +15,11 @@ export const createWalletAddressMutation = gql` export const updateWalletAddressMutation = gql` mutation UpdateWalletAddressMutation($input: UpdateWalletAddressInput!) { updateWalletAddress(input: $input) { - code - success - message + walletAddress { + id + url + publicName + } } } ` diff --git a/packages/wallet/backend/src/rafiki/rafiki-client.ts b/packages/wallet/backend/src/rafiki/rafiki-client.ts index 452fa16c6..d7b6c7150 100644 --- a/packages/wallet/backend/src/rafiki/rafiki-client.ts +++ b/packages/wallet/backend/src/rafiki/rafiki-client.ts @@ -1,6 +1,5 @@ import { GraphQLClient } from 'graphql-request' import { v4 as uuid } from 'uuid' -import { Logger } from 'winston' import { Asset, CreateAssetMutation, @@ -97,17 +96,14 @@ export type CreateReceiverParams = { walletAddressUrl: string } & PaymentParams export class RafikiClient implements IRafikiClient { - constructor( - private logger: Logger, - private backendGraphQLClient: GraphQLClient - ) {} + constructor(private backendGraphQLClient: GraphQLClient) {} public async createAsset(code: string, scale: number) { const response = await this.backendGraphQLClient.request< CreateAssetMutation, CreateAssetMutationVariables >(createAssetMutation, { input: { code, scale } }) - if (!response.createAsset.success || !response.createAsset.asset) { + if (!response.createAsset || !response.createAsset.asset) { throw new Error('Data was empty') } @@ -157,8 +153,8 @@ export class RafikiClient implements IRafikiClient { input }) - if (!paymentResponse.success) { - throw new Error(paymentResponse.message ?? 'Empty result') + if (!paymentResponse) { + throw new Error('Empty result') } if (!paymentResponse.payment) { throw new Error('Unable to fetch created incoming payment') @@ -190,8 +186,8 @@ export class RafikiClient implements IRafikiClient { input }) - if (!paymentResponse.success) { - throw new Error(paymentResponse.message ?? 'Empty result') + if (!paymentResponse) { + throw new Error('Empty result') } if (!paymentResponse.receiver) { throw new Error('Unable to fetch created receiver') @@ -219,18 +215,15 @@ export class RafikiClient implements IRafikiClient { }) if (!response.withdrawEventLiquidity?.success) { - if (response.withdrawEventLiquidity?.message === 'Transfer exists') { - return true - } - - if (response.withdrawEventLiquidity?.message === 'Invalid id') { - this.logger.debug(`Nothing to withdraw for event ${eventId}`) - return true - } - throw new BadRequest( - response.withdrawEventLiquidity?.message || - 'Unable to withdrawLiquidity from rafiki' - ) + // if (response.withdrawEventLiquidity?.message === 'Transfer exists') { + // return true + // } + // + // if (response.withdrawEventLiquidity?.message === 'Invalid id') { + // this.logger.debug(`Nothing to withdraw for event ${eventId}`) + // return true + // } + throw new BadRequest('Unable to withdrawLiquidity from rafiki') } return true @@ -246,9 +239,7 @@ export class RafikiClient implements IRafikiClient { }) if (!response.depositEventLiquidity?.success) { - throw new BadRequest( - response.depositEventLiquidity?.message || 'Unable to deposit to rafiki' - ) + throw new BadRequest('Unable to deposit to rafiki') } return true @@ -265,8 +256,8 @@ export class RafikiClient implements IRafikiClient { input }) - if (!paymentResponse.success) { - throw new Error(paymentResponse.message ?? 'Empty result') + if (!paymentResponse) { + throw new Error('Empty result') } if (!paymentResponse.payment) { throw new Error('Unable to fetch created outgoing payment') @@ -291,8 +282,8 @@ export class RafikiClient implements IRafikiClient { } }) - if (!response.createWalletAddress.success) { - throw new Error(response.createWalletAddress.message) + if (!response.createWalletAddress) { + throw new Error('Empty result') } if (!response.createWalletAddress.walletAddress) { throw new Error('Unable to fetch created wallet address') @@ -311,8 +302,8 @@ export class RafikiClient implements IRafikiClient { input: args }) - if (!response.updateWalletAddress.success) { - throw new Error(response.updateWalletAddress.message) + if (!response.updateWalletAddress) { + throw new Error('Empty result') } } @@ -330,8 +321,8 @@ export class RafikiClient implements IRafikiClient { } }) - if (!response.createWalletAddressKey?.success) { - throw new Error(response.createWalletAddressKey?.message) + if (!response.createWalletAddressKey) { + throw new Error('Empty result') } if (!response.createWalletAddressKey.walletAddressKey) { throw new Error('Unable to fetch created wallet address key') @@ -348,8 +339,8 @@ export class RafikiClient implements IRafikiClient { input: { id } }) - if (!response.revokeWalletAddressKey?.success) { - throw new Error(response.revokeWalletAddressKey?.message) + if (!response.revokeWalletAddressKey) { + throw new Error('Empty result') } } @@ -361,15 +352,15 @@ export class RafikiClient implements IRafikiClient { input }) - if ( - createQuote.code === '400' && - createQuote.message === 'invalid amount' - ) { - throw new BadRequest('Fees exceed send amount') - } + // if ( + // createQuote.code === '400' && + // createQuote.message === 'invalid amount' + // ) { + // throw new BadRequest('Fees exceed send amount') + // } if (!createQuote.quote) { - throw new Error(createQuote.message || 'Unable to create Quote') + throw new Error('Unable to create Quote') } return createQuote.quote