Skip to content

Commit

Permalink
add type comments; rename to address
Browse files Browse the repository at this point in the history
  • Loading branch information
avidreder committed Aug 30, 2024
1 parent 73b8986 commit ae21793
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/api/buildPayTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type {
} from './types';

export async function buildPayTransaction({
payerAddress,
address,
chainId,
chargeId,
}: BuildPayTransactionParams): Promise<BuildPayTransactionResponse> {
Expand All @@ -27,7 +27,7 @@ export async function buildPayTransaction({
BuildPayTransactionResponse
>(PAY_HYDRATE_CHARGE, [
{
sender: payerAddress,
sender: address,
chainId: chainId,
chargeId,
},
Expand Down
8 changes: 4 additions & 4 deletions src/api/bulidPayTransaction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('buildPayTransaction', () => {

it('should return a Pay Transaction', async () => {
const mockParams: BuildPayTransactionParams = {
payerAddress: MOCK_VALID_PAYER_ADDRESS,
address: MOCK_VALID_PAYER_ADDRESS,
chainId: base.id,
chargeId: MOCK_VALID_CHARGE_ID,
};
Expand All @@ -56,7 +56,7 @@ describe('buildPayTransaction', () => {

it('should return an error for chains other than Base', async () => {
const mockParams: BuildPayTransactionParams = {
payerAddress: MOCK_VALID_PAYER_ADDRESS,
address: MOCK_VALID_PAYER_ADDRESS,
chainId: mainnet.id,
chargeId: MOCK_VALID_CHARGE_ID,
};
Expand All @@ -75,7 +75,7 @@ describe('buildPayTransaction', () => {

it('should return an error if sendRequest fails', async () => {
const mockParams: BuildPayTransactionParams = {
payerAddress: MOCK_VALID_PAYER_ADDRESS,
address: MOCK_VALID_PAYER_ADDRESS,
chainId: base.id,
chargeId: MOCK_VALID_CHARGE_ID,
};
Expand Down Expand Up @@ -108,7 +108,7 @@ describe('buildPayTransaction', () => {

it('should return an error object from buildPayTransaction', async () => {
const mockParams: BuildPayTransactionParams = {
payerAddress: MOCK_VALID_PAYER_ADDRESS,
address: MOCK_VALID_PAYER_ADDRESS,
chainId: base.id,
chargeId: MOCK_INVALID_CHARGE_ID,
};
Expand Down
34 changes: 18 additions & 16 deletions src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export type SwapAPIParams = GetQuoteAPIParams | GetSwapAPIParams;
* Note: exported as public Type
*/
export type BuildPayTransactionParams = {
payerAddress: Address; // The address of the wallet paying
address: Address; // The address of the wallet paying
chainId: number; // The Chain ID of the payment Network (only Base is supported)
chargeId: string; // The ID of the Commerce Charge to be paid
};
Expand All @@ -96,24 +96,26 @@ export type HydrateChargeAPIParams = {
};

export type HydratedCharge = {
id: string;
id: string; // The id of the Commerce Charge to be paid
callData: {
deadline: string;
feeAmount: string;
id: string;
operator: Address;
prefix: Address;
recipient: Address;
recipientAmount: string;
recipientCurrency: Address;
refundDestination: Address;
signature: Address;
// Collection of fields used to make the contract call to the Payment contract
deadline: string; // Timestamp of when the payment will expire and be unpayable
feeAmount: string; // The amount of the processing fee in the recipient currency
id: string; // The id of the prepared transaction
operator: Address; // The address of the operator of the Payment contract
prefix: Address; // The prefix of the signature generated by Commerce
recipient: Address; // The address funds will settle in
recipientAmount: string; // The amount the recipient will get in the recipient currency
recipientCurrency: Address; // The address of the currency being paid (always USDC)
refundDestination: Address; // The wallet address of the payer
signature: Address; // The signature generated by the Payment contract operator, encoding the payment details
};
metaData: {
chainId: number;
contractAddress: Address;
sender: Address;
settlementCurrencyAddress: Address;
// Collection of metadata needed to make the contract call to the Payment Contract
chainId: number; // The chain this prepared transaction can be paid on
contractAddress: Address; // The address of the Payment contract
sender: Address; // The wallet address of the payer
settlementCurrencyAddress: Address; // The address of the currency being paid (always USDC)
};
};

Expand Down

0 comments on commit ae21793

Please sign in to comment.