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

Update /paymentTxParams and /submitPaymentTx endpoints to work with Slice payloads #12

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

justin-lee-cb
Copy link
Collaborator

No description provided.

import { http } from 'viem';

// Create a Wagmi config, and get the relayed slice data
export const wagmiConfig = createConfig({
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need more mappings? or does Slice only support 8453 right now?

Comment on lines +11 to +16
let value = txMessage.rpcProxySubmissionParams.typedData.message.value;
if (txMessage.additionalPayload.cartParams && txMessage.additionalPayload.slicerId) {
// construct the cart using the slicekit to calculate the total amount
value = await getSliceCartUsdcPrice({ cartParams: txMessage.additionalPayload.cartParams, slicerId: txMessage.additionalPayload.slicerId });
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's move this logic to a formatSliceTxMessageReponse helper as well

allProducts,
});

console.log({ cart });
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remember to remove the console logs after we're sure implementation is the correct one

Comment on lines +46 to +62
if (additionalPayload) {
const { txHash } = await relayPayWithAuthorization({
cartParams: additionalPayload.cartParams,
slicerId: additionalPayload.slicerId,
totalUsdcPrice: value,
buyer: from,
chainId,
signature,
authorizationParams: {
from,
nonce,
to,
validAfter,
validBefore,
value,
},
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

As discussed during Sync: Let's move this to a new endpoint called submitSlicePaymentTx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants