diff --git a/package.json b/package.json index 853e433..7205cce 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@orionprotocol/sdk", - "version": "0.19.58-rc4", + "version": "0.19.58-rc5", "description": "Orion Protocol SDK", "main": "./lib/index.cjs", "module": "./lib/index.js", diff --git a/src/services/Aggregator/index.ts b/src/services/Aggregator/index.ts index 7a220b3..6da1b14 100644 --- a/src/services/Aggregator/index.ts +++ b/src/services/Aggregator/index.ts @@ -196,6 +196,7 @@ class Aggregator { isCreateInternalOrder: boolean, isReversedOrder?: boolean, partnerId?: string, + fromWidget?: boolean, ) => { const headers = { 'Content-Type': 'application/json', @@ -204,6 +205,7 @@ class Aggregator { 'X-Reverse-Order': isReversedOrder ? 'true' : 'false', }, ...(partnerId !== undefined) && { 'X-Partner-Id': partnerId }, + ...(fromWidget !== undefined) && { 'X-From-Widget': fromWidget ? 'true' : 'false' }, ...this.basicAuthHeaders, }; diff --git a/src/services/ReferralSystem/index.ts b/src/services/ReferralSystem/index.ts index 7711906..79d0c0f 100644 --- a/src/services/ReferralSystem/index.ts +++ b/src/services/ReferralSystem/index.ts @@ -1,3 +1,4 @@ +import { z } from 'zod'; import { fetchWithValidation } from 'simple-typed-fetch'; import { errorSchema, @@ -39,6 +40,12 @@ type SignatureType = { signature: string }; +type submitTransactionDataForWidgetPayload = { + partner_domain: string + sender_address: string + tx_hash: string +} + class ReferralSystem { private readonly apiUrl: string @@ -65,6 +72,7 @@ class ReferralSystem { this.getContractsAddresses = this.getContractsAddresses.bind(this); this.getClaimInfo = this.getClaimInfo.bind(this); this.getAggregatedHistory = this.getAggregatedHistory.bind(this); + this.submitTransactionDataForWidget = this.submitTransactionDataForWidget.bind(this); } getLink = (refererAddress: string) => @@ -264,6 +272,20 @@ class ReferralSystem { errorSchema ); }; + + submitTransactionDataForWidget = (payload: submitTransactionDataForWidgetPayload) => { + return fetchWithValidation( + `${this.apiUrl}/referer/widget/submit`, + z.unknown(), + { + headers: { + 'Content-type': 'application/json', + }, + method: 'POST', + body: JSON.stringify(payload) + } + ); + }; } export * as schemas from './schemas/index.js';