Skip to content

Commit

Permalink
Add a libs function to save transaction metadata (#3804)
Browse files Browse the repository at this point in the history
  • Loading branch information
rickyrombo authored Sep 1, 2022
1 parent a475c31 commit de6fc7d
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions libs/src/services/identity/IdentityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,21 @@ type Reaction = {
reactionValue: number
}

enum TransactionMetadataType {
PURCHASE_SOL_AUDIO_SWAP = 'PURCHASE_SOL_AUDIO_SWAP'
}

type InAppAudioPurchaseMetadata = {
discriminator: TransactionMetadataType.PURCHASE_SOL_AUDIO_SWAP
usd: string
sol: string
audio: string
purchaseTransactionId: string
setupTransactionId?: string
swapTransactionId: string
cleanupTransactionId?: string
}

// Only probabilistically capture 50% of relay captchas
const RELAY_CAPTCHA_SAMPLE_RATE = 0.5

Expand Down Expand Up @@ -530,6 +545,17 @@ export class IdentityService {
})
}

async saveUserBankTransactionMetadata(data: InAppAudioPurchaseMetadata) {
const headers = await this._signData()

return await this._makeRequest({
url: '/transaction_metadata',
method: 'post',
data,
headers
})
}

/* ------- INTERNAL FUNCTIONS ------- */

async _makeRequest<T = unknown>(axiosRequestObj: AxiosRequestConfig) {
Expand Down

0 comments on commit de6fc7d

Please sign in to comment.