Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(release): update 17e6a65 #5

Merged
merged 1 commit into from
May 7, 2024
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
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,24 @@
"cSpell.words": [
"abcdefghijklmnopqrxtuvwxyz",
"alexsasharegan",
"Arconnect",
"ario",
"bignumber",
"capturable",
"chargeback",
"Chargebacks",
"Clawback",
"Hodler",
"indep",
"Irys",
"knexfile",
"lamports",
"livemode",
"nvmrc",
"openapi",
"Readables",
"sats",
"solana",
"sslmode",
"trivago",
"typecheck",
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ WORKDIR /usr/src/app
COPY . .
RUN yarn && yarn build

# Clean out dependencies
RUN yarn workspaces focus --production
# Clear cache and install production dependencies
RUN rm -rf node_modules && yarn workspaces focus --production

# Extract dist
FROM gcr.io/distroless/nodejs${NODE_VERSION_SHORT}-debian11
Expand Down
165 changes: 159 additions & 6 deletions docs/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ components:
description: Currency type for a given payment amount
example: usd

TokenType:
type: string
description: Token type for a given transaction
example: arweave

PaymentAmount:
type: integer
description: Payment amount in a given currency's smallest unit value. For example, $10 USD is 1000
Expand All @@ -102,6 +107,71 @@ components:
type: string
description: Comma-separated list of promo codes

DestinationAddress:
type: string
description: Destination wallet address for payment
example: abcdefghijklmnopqrxtuvwxyz123456789ABCDEFGH

DestinationAddressType:
type: string
description: Destination wallet address type
example: arweave

WinstonCreditAmount:
type: string
description: A big number string representing an amount of credits in winc. One credit is equivalent to 10^12 winc
example: "332824926"

PendingPaymentTx:
type: object
description: A payment transaction as our service sees it
properties:
transactionId:
type: string
description: The transaction ID of the pending payment transaction
transactionQuantity:
type: integer
description: The quantity of the pending payment transaction
createdAt:
type: string
description: The date and time the transaction was entered into the service
tokenType:
"$ref": "#/components/schemas/TokenType"
destinationAddress:
"$ref": "#/components/schemas/DestinationAddress"
destinationAddressType:
"$ref": "#/components/schemas/DestinationAddressType"
winstonCreditAmount:
"$ref": "#/components/schemas/WinstonCreditAmount"
adjustments:
"$ref": "#/components/schemas/Adjustment"

CreditedPaymentTx:
type: object
description: A payment transaction as our service sees it
properties:
allOf:
"$ref": "#/components/schemas/PendingPaymentTx"
blockHeight:
type: integer
description: The block height at which the transaction was credited
creditedAt:
type: string
description: The date and time the transaction was credited in the service

FailedPaymentTx:
type: object
description: A payment transaction as our service sees it
properties:
allOf:
"$ref": "#/components/schemas/PendingPaymentTx"
failedAt:
type: string
description: The date and time the transaction failed in the service
failureReason:
type: string
description: The reason the transaction failed in the service

TopUpQuote:
type: object
description: A copy of the top up quote that was saved to the service's database
Expand All @@ -110,11 +180,9 @@ components:
type: string
example: caa8b54a-eb5e-4134-8ae2-a3946a428ec7
destinationAddress:
type: string
example: abcdefghijklmnopqrxtuvwxyz123456789ABCDEFGH
"$ref": "#/components/schemas/DestinationAddress"
destinationAddressType:
type: string
example: arweave
"$ref": "#/components/schemas/DestinationAddressType"
paymentAmount:
"$ref": "#/components/schemas/ActualPaymentAmount"
quotedPaymentAmount:
Expand All @@ -123,8 +191,7 @@ components:
type: string
example: usd
winstonCreditAmount:
type: string
example: 1000000000
"$ref": "#/components/schemas/WinstonCreditAmount"
quoteExpirationDate:
type: string
example: 2023-05-17T21:46:38.404Z
Expand Down Expand Up @@ -618,3 +685,89 @@ paths:
schema:
type: string
default: "Error while redeeming payment receipt. Unable to reach Database!"

/account/balance/{token}:
post:
summary: Post a pending payment transaction
description: Post a transaction ID that has been sent to the payment service's wallet

requestBody:
required: true
description: JSON with `tx_id` key of the pending payment transaction
content:
application/json:
schema:
type: object
properties:
tx_id:
type: string
description: The transaction ID of the pending payment transaction

parameters:
- name: token
in: path
required: true
schema:
"$ref": "#/components/schemas/TokenType"

responses:
"200":
description: OK
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: Transaction credited
creditedTransaction:
"$ref": "#/components/schemas/CreditedPaymentTx"

"202":
description: Accepted
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: Transaction pending
pendingTransaction:
"$ref": "#/components/schemas/PendingPaymentTx"

"400":
description: Bad Request
content:
text/plain:
schema:
type: string
description: "Error message string dependent on cause"
example: "Transaction ID is invalid!"

application/json:
schema:
type: object
properties:
message:
type: string
example: Transaction has already failed!
failedTransaction:
"$ref": "#/components/schemas/FailedPaymentTx"

"404":
description: Not Found
content:
text/plain:
schema:
type: string
default: "Transaction ID not found!"

"500":
description: Internal Server Error
content:
text/plain:
schema:
type: string
default: "Error while processing transaction!"
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
"lint:fix": "eslint . --ext .ts --fix",
"typecheck": "tsc --noEmit",
"test": "nyc mocha --spec='src/**/*.test.ts' --spec='tests/**/*.test.ts'",
"test:local": "yarn db:up && yarn test $* ; yarn db:down",
"test:local": "yarn db:up && yarn test \"$@\" ; yarn db:down",
"test:unit": "nyc mocha --spec='src/**/*.test.ts'",
"test:integration": "nyc mocha --spec='tests/**/*.test.ts'",
"test:integration:local": "yarn db:up && yarn test:integration $* ; yarn db:down",
"test:integration:local": "yarn db:up && yarn test:integration \"$@\" ; yarn db:down",
"test:docker": " docker compose down -v && docker compose up test-runner --exit-code-from test-runner --build",
"ci": "yarn build && yarn test:docker",
"build": "yarn clean && tsc --project ./tsconfig.prod.json",
Expand Down Expand Up @@ -69,11 +69,13 @@
"@aws-sdk/client-secrets-manager": "^3.290.0",
"@aws-sdk/client-ssm": "^3.369.0",
"@koa/cors": "^5.0.0",
"@solana/web3.js": "^1.91.7",
"arweave": "^1.13.4",
"axios": "^1.6.7",
"axios-retry": "^3.4.0",
"bignumber.js": "^9.1.0",
"dotenv": "^16.0.3",
"ethers": "^6.11.1",
"jsonwebtoken": "^9.0.0",
"knex": "^2.5.1",
"koa": "2.13.4",
Expand All @@ -86,6 +88,7 @@
"prom-client": "^14.1.0",
"raw-body": "^2.5.2",
"sinon-chai": "^3.7.0",
"sqs-consumer": "^8.2.0",
"stripe": "^14.11.0",
"validator": "^13.11.0",
"winston": "^3.8.2",
Expand Down
2 changes: 1 addition & 1 deletion resources/license.header.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (C) 2022-2023 Permanent Data Solutions, Inc. All Rights Reserved.
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc. All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
Expand Down
4 changes: 3 additions & 1 deletion src/architecture.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (C) 2022-2023 Permanent Data Solutions, Inc. All Rights Reserved.
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc. All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
Expand All @@ -18,11 +18,13 @@ import Stripe from "stripe";

import { Database } from "./database/database";
import { EmailProvider } from "./emailProvider";
import { GatewayMap } from "./gateway";
import { PricingService } from "./pricing/pricing";

export interface Architecture {
paymentDatabase: Database;
pricingService: PricingService;
stripe: Stripe;
emailProvider?: EmailProvider;
gatewayMap: GatewayMap;
}
2 changes: 1 addition & 1 deletion src/axiosClient.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (C) 2022-2023 Permanent Data Solutions, Inc. All Rights Reserved.
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc. All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
Expand Down
22 changes: 17 additions & 5 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (C) 2022-2023 Permanent Data Solutions, Inc. All Rights Reserved.
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc. All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
Expand All @@ -15,7 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { ByteCount } from "./types/byteCount";
import { SupportedPaymentCurrencyTypes } from "./types/supportedCurrencies";
import { SupportedFiatPaymentCurrencyType } from "./types/supportedCurrencies";

export const isTestEnv = process.env.NODE_ENV === "test";
export const migrateOnStartup = process.env.MIGRATE_ON_STARTUP === "true";
Expand Down Expand Up @@ -107,12 +107,12 @@ export interface ExposedCurrencyLimitation extends CurrencyLimitation {
}

export type ExposedCurrencyLimitations = Record<
SupportedPaymentCurrencyTypes,
SupportedFiatPaymentCurrencyType,
ExposedCurrencyLimitation
>;

export type CurrencyLimitations = Record<
SupportedPaymentCurrencyTypes,
SupportedFiatPaymentCurrencyType,
CurrencyLimitation
>;

Expand Down Expand Up @@ -318,11 +318,23 @@ export const promoCodeBackfills = {
export const maxGiftMessageLength = process.env.MAX_GIFT_MESSAGE_LENGTH ?? 250;

export const giftingEmailAddress =
process.env.GIFTING_EMAILL_ADDRESS ?? "[email protected]";
process.env.GIFTING_EMAIL_ADDRESS ?? "[email protected]";

/** gifting on top up via email depends on GIFTING_ENABLED="true" env var */
export const isGiftingEnabled = process.env.GIFTING_ENABLED === "true";

export const arweaveGatewayUrl = new URL(
process.env.ARWEAVE_GATEWAY || "https://arweave.net:443"
);

export const ethereumGatewayUrl = new URL(
process.env.ETHEREUM_GATEWAY || "https://cloudflare-eth.com/"
);

export const solanaGatewayUrl = new URL(
process.env.SOLANA_GATEWAY || "https://api.mainnet-beta.solana.com/"
);

const thirtyMinutesMs = 1000 * 60 * 30;
export const topUpQuoteExpirationMs = +(
process.env.TOP_UP_QUOTE_EXPIRATION_MS ?? thirtyMinutesMs
Expand Down
Loading