Skip to content
This repository has been archived by the owner on Jan 7, 2025. It is now read-only.

Commit

Permalink
Final deployment changes
Browse files Browse the repository at this point in the history
  • Loading branch information
harshasomisetty committed Aug 5, 2023
1 parent 285e4f5 commit 5ab098e
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 17 deletions.
2 changes: 2 additions & 0 deletions apps/backend-serverless/serverless.purple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ package:
- 'node_modules/.prisma/client/libquery_engine-linux-arm64-*'
- '!node_modules/prisma/libquery_engine-*'
- '!node_modules/@prisma/engines/**'
- 'node_modules/@project-serum/**'
functions:
install:
handler: src/handlers/shopify-handlers/install.install
Expand Down Expand Up @@ -306,6 +307,7 @@ functions:
Resource: ${self:resources.Outputs.ShopifyQueueArn.Value}
process-message:
handler: src/handlers/webhooks/sqs/process-transaction-message.processTransactionMessage
timeout: 30
events:
- sqs:
arn: ${self:resources.Outputs.ProcessQueueArn.Value}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ export const customerData = Sentry.AWSLambda.wrapHandler(
Sentry.captureEvent({
message: 'in customerData',
level: 'info',
extra: {
event,
},
});

const paymentRecordService = new PaymentRecordService(prisma);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ export const createCustomerResponse = async (
let customerOwns =
currentTier && currentTier.mint ? await customerOwnsTier(customerWallet, currentTier.mint) : false;

console.log('tier status', currentTier, nextPossibleTier, isFirstTier, customerOwns);
// console.log('tier status', currentTier, nextPossibleTier, isFirstTier, customerOwns);
let customerNfts = (await createProductsNftResponse(merchant)).customerView[customerWallet];

console.log('customer nfts', customerNfts);
// console.log('customer nfts', customerNfts);
return {
amountSpent: customer.amountSpent,
tier: currentTier,
Expand Down
3 changes: 0 additions & 3 deletions apps/merchant-ui/src/components/ProductsCard/TreeSetup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,6 @@ export default function TreeSetup(props: Props) {
<Button pending={loading} onClick={handleSave}>
Setup
</Button>
<Button variant="outline" onClick={disconnect}>
Disconnect Wallet
</Button>
</CardFooter>
</Card>
);
Expand Down
11 changes: 6 additions & 5 deletions apps/merchant-ui/src/components/TiersCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export function TiersCard(props: Props) {
tiers: {
...newTier,
...(data.mintAddress && { mint: data.mintAddress }),
active: true,
},
});

Expand Down Expand Up @@ -244,7 +245,7 @@ export function TiersCard(props: Props) {
<TableHead>$ Threshold</TableHead>
<TableHead>% Back</TableHead>
<TableHead>Active</TableHead>
{/* <TableHead>Frozen</TableHead> */}
<TableHead>Frozen</TableHead>
<TableHead></TableHead>
</TableRow>
</TableHeader>
Expand Down Expand Up @@ -309,9 +310,9 @@ export function TiersCard(props: Props) {
<TableCell>
<Switch checked={tier.active} onCheckedChange={() => handleToggle(tier.id)} />
</TableCell>
{/* <TableCell>
<Switch checked={false} />
</TableCell> */}
<TableCell>
<Switch checked={true} />
</TableCell>
<TableCell className="flex flex-row space-x-1">
{editing === tier.id ? (
<Button variant="outline" onClick={() => handleSave(tier.id)}>
Expand Down Expand Up @@ -371,7 +372,7 @@ export function TiersCard(props: Props) {
/>
</TableCell>
<TableCell></TableCell>
{/* <TableCell></TableCell> */}
<TableCell></TableCell>
<TableCell className="flex flex-row space-x-1">
<Button
variant="outline"
Expand Down
4 changes: 2 additions & 2 deletions apps/mock-shopify-serverless/src/handlers/payment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ export const payment = async (event: APIGatewayProxyEventV2): Promise<APIGateway
id: id,
gid: gid,
group: group,
amount: 5,
amount: 11,
currency: 'USD',
test: false,
test: true,
merchant_locale: 'en',
payment_method: {
type: 'type',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const PaymentView: React.FC = () => {
<div className="w-full h-full flex flex-col items-center">
<div className="flex flex-col items-center">
<QRCode />
<div className="text-gray-600 text-xs pt-4">Scan this code to pay with your Solana wallet</div>
<p className="text-gray-600 text-xs pt-4">Scan this code to pay with your Solana wallet</p>
</div>
</div>
)}
Expand Down
13 changes: 9 additions & 4 deletions apps/payment-ui/src/components/PayToLabel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,18 @@ export const PayToLabel = () => {
const calculateDiscount = (cart: number, discountRate: number) => (discountRate * cart) / 100;

useEffect(() => {
if (customerTier !== null && paymentDetails !== null) {
let cart = Number(paymentDetails.totalAmountFiatDisplay.substring(1));
if (paymentDetails !== null) {
let cart = Number(paymentDetails.usdcSize);
setCart(cart);
setDiscount(calculateDiscount(cart, customerTier.discount));
setIsLoading(false);
}
}, [customerTier, paymentDetails]);
}, [paymentDetails]);

useEffect(() => {
if (customerTier !== null && cart > 0) {
setDiscount(calculateDiscount(cart, customerTier.discount));
}
}, [customerTier, cart]);

function calculateFinalAmount(): number {
if (!loyaltyDetails || !customer || !paymentDetails || !customerTier) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
createAssociatedTokenAccountInstruction,
createBurnInstruction,
createCloseAccountInstruction,
createFreezeAccountInstruction,
createMintToInstruction,
getAccount,
getAssociatedTokenAddress,
Expand Down Expand Up @@ -226,6 +227,9 @@ export class PaymentTransactionBuilder {
transaction = transaction.add(
createMintToInstruction(this.nextTier, newCustomerTokenAddress, this.feePayer, 1)
);
transaction = transaction.add(
createFreezeAccountInstruction(newCustomerTokenAddress, this.nextTier, this.feePayer)
);
} else if (this.currentTier && !this.nextTier && !this.customerOwnsTier) {
let newCustomerTokenAddress = await getAssociatedTokenAddress(this.currentTier, this.sender);

Expand All @@ -241,6 +245,10 @@ export class PaymentTransactionBuilder {
transaction = transaction.add(
createMintToInstruction(this.currentTier, newCustomerTokenAddress, this.feePayer, 1)
);

transaction = transaction.add(
createFreezeAccountInstruction(newCustomerTokenAddress, this.currentTier, this.feePayer)
);
} else {
console.log('hit else case');
}
Expand Down

1 comment on commit 5ab098e

@vercel
Copy link

@vercel vercel bot commented on 5ab098e Aug 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.