feature: updated placeOrder and added submitTransactionDataForWidget methods

This commit is contained in:
Mikhail Gladchenko
2023-08-30 15:35:40 +01:00
parent 1de01439d1
commit 6444463e21
3 changed files with 25 additions and 1 deletions

View File

@@ -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",

View File

@@ -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,
};

View File

@@ -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';