@requestnetwork/payment-detection 0.36.1-next.1886 → 0.36.1-next.1888
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/any/any-to-erc20-proxy.d.ts +1 -1
- package/dist/any/any-to-erc20-proxy.d.ts.map +1 -1
- package/dist/any/any-to-erc20-proxy.js.map +1 -1
- package/dist/any/any-to-eth-proxy.d.ts +1 -1
- package/dist/any/any-to-eth-proxy.d.ts.map +1 -1
- package/dist/any/any-to-eth-proxy.js.map +1 -1
- package/dist/erc20/fee-proxy-contract.d.ts +13 -6
- package/dist/erc20/fee-proxy-contract.d.ts.map +1 -1
- package/dist/erc20/fee-proxy-contract.js +33 -10
- package/dist/erc20/fee-proxy-contract.js.map +1 -1
- package/dist/erc20/proxy-contract.d.ts +1 -1
- package/dist/erc20/proxy-contract.d.ts.map +1 -1
- package/dist/erc20/proxy-contract.js.map +1 -1
- package/dist/erc20/transferable-receivable.d.ts +1 -1
- package/dist/erc20/transferable-receivable.d.ts.map +1 -1
- package/dist/erc20/transferable-receivable.js.map +1 -1
- package/dist/eth/fee-proxy-detector.d.ts +1 -1
- package/dist/eth/fee-proxy-detector.d.ts.map +1 -1
- package/dist/eth/fee-proxy-detector.js.map +1 -1
- package/dist/eth/input-data.d.ts +1 -1
- package/dist/eth/input-data.d.ts.map +1 -1
- package/dist/eth/input-data.js.map +1 -1
- package/dist/native-token-detector.d.ts +4 -2
- package/dist/native-token-detector.d.ts.map +1 -1
- package/dist/native-token-detector.js +3 -1
- package/dist/native-token-detector.js.map +1 -1
- package/dist/near/near-conversion-detector.d.ts +3 -2
- package/dist/near/near-conversion-detector.d.ts.map +1 -1
- package/dist/near/near-conversion-detector.js +20 -8
- package/dist/near/near-conversion-detector.js.map +1 -1
- package/dist/near/near-detector.d.ts.map +1 -1
- package/dist/near/near-detector.js +13 -2
- package/dist/near/near-detector.js.map +1 -1
- package/dist/near/retrievers/near-conversion-info-retriever.d.ts +22 -15
- package/dist/near/retrievers/near-conversion-info-retriever.d.ts.map +1 -1
- package/dist/near/retrievers/near-conversion-info-retriever.js +34 -37
- package/dist/near/retrievers/near-conversion-info-retriever.js.map +1 -1
- package/dist/near/retrievers/near-info-retriever.d.ts +23 -12
- package/dist/near/retrievers/near-info-retriever.d.ts.map +1 -1
- package/dist/near/retrievers/near-info-retriever.js +39 -34
- package/dist/near/retrievers/near-info-retriever.js.map +1 -1
- package/dist/payment-detector-base.d.ts +1 -1
- package/dist/payment-detector-base.d.ts.map +1 -1
- package/dist/payment-network-factory.d.ts +1 -1
- package/dist/payment-network-factory.d.ts.map +1 -1
- package/dist/payment-network-factory.js +11 -6
- package/dist/payment-network-factory.js.map +1 -1
- package/dist/thegraph/client.d.ts +59 -1
- package/dist/thegraph/client.d.ts.map +1 -1
- package/dist/thegraph/client.js +11 -2
- package/dist/thegraph/client.js.map +1 -1
- package/dist/thegraph/generated/graphql-near.d.ts +66 -35
- package/dist/thegraph/generated/graphql-near.d.ts.map +1 -1
- package/dist/thegraph/generated/graphql-near.js +83 -6
- package/dist/thegraph/generated/graphql-near.js.map +1 -1
- package/dist/types.d.ts +12 -9
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +5 -2
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +8 -1
- package/dist/utils.js.map +1 -1
- package/package.json +7 -7
|
@@ -1,28 +1,35 @@
|
|
|
1
|
-
import { PaymentTypes } from '@requestnetwork/types';
|
|
1
|
+
import { CurrencyTypes, PaymentTypes } from '@requestnetwork/types';
|
|
2
2
|
import { CurrencyDefinition } from '@requestnetwork/currency';
|
|
3
|
-
import { NearInfoRetriever } from './near-info-retriever';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import { NearInfoRetriever, NearPaymentEvent } from './near-info-retriever';
|
|
4
|
+
import { TheGraphClient } from '../../thegraph';
|
|
5
|
+
export type TransferEventsParams = {
|
|
6
|
+
/** The reference to identify the payment*/
|
|
7
|
+
paymentReference: string;
|
|
8
|
+
/** Request denomination (usually fiat) */
|
|
9
|
+
requestCurrency: CurrencyDefinition;
|
|
10
|
+
/** The recipient of the transfer */
|
|
11
|
+
toAddress: string;
|
|
12
|
+
/** The address of the payment proxy */
|
|
13
|
+
contractAddress: string;
|
|
14
|
+
/** The chain to check for payment */
|
|
15
|
+
paymentChain: CurrencyTypes.VMChainName;
|
|
16
|
+
/** Indicates if it is an address for payment or refund */
|
|
17
|
+
eventName: PaymentTypes.EVENTS_NAMES;
|
|
18
|
+
/** The maximum span between the time the rate was fetched and the payment */
|
|
19
|
+
maxRateTimespan?: number;
|
|
20
|
+
};
|
|
7
21
|
/**
|
|
8
22
|
* Gets a list of transfer events for a set of Near payment details
|
|
9
23
|
*/
|
|
10
24
|
export declare class NearConversionInfoRetriever extends NearInfoRetriever {
|
|
11
|
-
protected
|
|
12
|
-
protected paymentReference: string;
|
|
13
|
-
protected toAddress: string;
|
|
14
|
-
protected proxyContractName: string;
|
|
15
|
-
protected eventName: PaymentTypes.EVENTS_NAMES;
|
|
16
|
-
protected network: string;
|
|
17
|
-
protected maxRateTimespan: number;
|
|
25
|
+
protected readonly client: TheGraphClient<CurrencyTypes.NearChainName>;
|
|
18
26
|
/**
|
|
19
27
|
* @param paymentReference The reference to identify the payment
|
|
20
28
|
* @param toAddress Address to check
|
|
21
29
|
* @param eventName Indicate if it is an address for payment or refund
|
|
22
30
|
* @param network The id of network we want to check
|
|
23
31
|
*/
|
|
24
|
-
constructor(
|
|
25
|
-
getTransferEvents(): Promise<PaymentTypes.
|
|
32
|
+
constructor(client: TheGraphClient<CurrencyTypes.NearChainName>);
|
|
33
|
+
getTransferEvents(params: TransferEventsParams): Promise<PaymentTypes.AllNetworkEvents<NearPaymentEvent>>;
|
|
26
34
|
}
|
|
27
|
-
export {};
|
|
28
35
|
//# sourceMappingURL=near-conversion-info-retriever.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"near-conversion-info-retriever.d.ts","sourceRoot":"","sources":["../../../src/near/retrievers/near-conversion-info-retriever.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"near-conversion-info-retriever.d.ts","sourceRoot":"","sources":["../../../src/near/retrievers/near-conversion-info-retriever.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,MAAM,oBAAoB,GAAG;IACjC,2CAA2C;IAC3C,gBAAgB,EAAE,MAAM,CAAC;IACzB,0CAA0C;IAC1C,eAAe,EAAE,kBAAkB,CAAC;IACpC,oCAAoC;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,uCAAuC;IACvC,eAAe,EAAE,MAAM,CAAC;IACxB,qCAAqC;IACrC,YAAY,EAAE,aAAa,CAAC,WAAW,CAAC;IACxC,0DAA0D;IAC1D,SAAS,EAAE,YAAY,CAAC,YAAY,CAAC;IACrC,6EAA6E;IAC7E,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF;;GAEG;AACH,qBAAa,2BAA4B,SAAQ,iBAAiB;IAOpD,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC,aAAa,CAAC,aAAa,CAAC;IANlF;;;;;OAKG;gBAC4B,MAAM,EAAE,cAAc,CAAC,aAAa,CAAC,aAAa,CAAC;IAGrE,iBAAiB,CAC5B,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,YAAY,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;CAsC5D"}
|
|
@@ -13,47 +13,44 @@ class NearConversionInfoRetriever extends near_info_retriever_1.NearInfoRetrieve
|
|
|
13
13
|
* @param eventName Indicate if it is an address for payment or refund
|
|
14
14
|
* @param network The id of network we want to check
|
|
15
15
|
*/
|
|
16
|
-
constructor(
|
|
17
|
-
super(
|
|
18
|
-
this.
|
|
19
|
-
this.paymentReference = paymentReference;
|
|
20
|
-
this.toAddress = toAddress;
|
|
21
|
-
this.proxyContractName = proxyContractName;
|
|
22
|
-
this.eventName = eventName;
|
|
23
|
-
this.network = network;
|
|
24
|
-
this.maxRateTimespan = maxRateTimespan;
|
|
16
|
+
constructor(client) {
|
|
17
|
+
super(client);
|
|
18
|
+
this.client = client;
|
|
25
19
|
}
|
|
26
|
-
getTransferEvents() {
|
|
20
|
+
getTransferEvents(params) {
|
|
27
21
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
const { requestCurrency, paymentReference, toAddress, contractAddress, eventName, maxRateTimespan, } = params;
|
|
28
23
|
const payments = yield this.client.GetAnyToNativePayments({
|
|
29
|
-
reference:
|
|
30
|
-
to:
|
|
31
|
-
currency:
|
|
32
|
-
maxRateTimespan:
|
|
33
|
-
contractAddress:
|
|
34
|
-
});
|
|
35
|
-
return payments.payments.map((p) => {
|
|
36
|
-
var _a;
|
|
37
|
-
return ({
|
|
38
|
-
amount: p.amount,
|
|
39
|
-
name: this.eventName,
|
|
40
|
-
parameters: {
|
|
41
|
-
block: p.block,
|
|
42
|
-
feeAddress: p.feeAddress || undefined,
|
|
43
|
-
feeAmount: p.feeAmount,
|
|
44
|
-
feeAmountInCrypto: p.feeAmountInCrypto || undefined,
|
|
45
|
-
amountInCrypto: p.amountInCrypto,
|
|
46
|
-
to: this.toAddress,
|
|
47
|
-
maxRateTimespan: (_a = p.maxRateTimespan) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
48
|
-
from: p.from,
|
|
49
|
-
gasUsed: p.gasUsed,
|
|
50
|
-
gasPrice: p.gasPrice,
|
|
51
|
-
receiptId: p.receiptId,
|
|
52
|
-
currency: p.currency,
|
|
53
|
-
},
|
|
54
|
-
timestamp: Number(p.timestamp),
|
|
55
|
-
});
|
|
24
|
+
reference: paymentReference,
|
|
25
|
+
to: toAddress,
|
|
26
|
+
currency: requestCurrency.symbol,
|
|
27
|
+
maxRateTimespan: maxRateTimespan !== null && maxRateTimespan !== void 0 ? maxRateTimespan : 0,
|
|
28
|
+
contractAddress: contractAddress,
|
|
56
29
|
});
|
|
30
|
+
return {
|
|
31
|
+
paymentEvents: payments.payments.map((p) => {
|
|
32
|
+
var _a;
|
|
33
|
+
return ({
|
|
34
|
+
amount: p.amount,
|
|
35
|
+
name: eventName,
|
|
36
|
+
parameters: {
|
|
37
|
+
block: p.block,
|
|
38
|
+
feeAddress: p.feeAddress || undefined,
|
|
39
|
+
feeAmount: p.feeAmount,
|
|
40
|
+
feeAmountInCrypto: p.feeAmountInCrypto || undefined,
|
|
41
|
+
amountInCrypto: p.amountInCrypto,
|
|
42
|
+
to: toAddress,
|
|
43
|
+
maxRateTimespan: (_a = p.maxRateTimespan) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
44
|
+
from: p.from,
|
|
45
|
+
gasUsed: p.gasUsed,
|
|
46
|
+
gasPrice: p.gasPrice,
|
|
47
|
+
receiptId: p.receiptId,
|
|
48
|
+
currency: p.currency,
|
|
49
|
+
},
|
|
50
|
+
timestamp: Number(p.timestamp),
|
|
51
|
+
});
|
|
52
|
+
}),
|
|
53
|
+
};
|
|
57
54
|
});
|
|
58
55
|
}
|
|
59
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"near-conversion-info-retriever.js","sourceRoot":"","sources":["../../../src/near/retrievers/near-conversion-info-retriever.ts"],"names":[],"mappings":";;;;AAEA,+
|
|
1
|
+
{"version":3,"file":"near-conversion-info-retriever.js","sourceRoot":"","sources":["../../../src/near/retrievers/near-conversion-info-retriever.ts"],"names":[],"mappings":";;;;AAEA,+DAA4E;AAoB5E;;GAEG;AACH,MAAa,2BAA4B,SAAQ,uCAA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AM,CAAC,CAAC,CAAC,SAAS,CAAC;qBAC/B,CAAC,CAAA;iBAAA,CAAC;aACJ,CAAC;QACJ,CAAC;KAAA;CACF;AAlDD,kEAkDC"}
|
|
@@ -1,26 +1,37 @@
|
|
|
1
|
-
import { PaymentTypes } from '@requestnetwork/types';
|
|
1
|
+
import { CurrencyTypes, PaymentTypes } from '@requestnetwork/types';
|
|
2
2
|
import { TheGraphClient } from '../../thegraph';
|
|
3
|
-
|
|
3
|
+
import { ITheGraphBaseInfoRetriever } from 'payment-detection/src/types';
|
|
4
|
+
export interface NearPaymentEvent extends PaymentTypes.IERC20FeePaymentEventParameters {
|
|
4
5
|
receiptId: string;
|
|
5
6
|
}
|
|
7
|
+
export type TransferEventsParams = {
|
|
8
|
+
/** The reference to identify the payment*/
|
|
9
|
+
paymentReference: string;
|
|
10
|
+
/** The recipient of the transfer */
|
|
11
|
+
toAddress: string;
|
|
12
|
+
/** The address of the payment proxy */
|
|
13
|
+
contractAddress: string;
|
|
14
|
+
/** The chain to check for payment */
|
|
15
|
+
paymentChain: CurrencyTypes.VMChainName;
|
|
16
|
+
/** Indicates if it is an address for payment or refund */
|
|
17
|
+
eventName: PaymentTypes.EVENTS_NAMES;
|
|
18
|
+
/** The list of ERC20 tokens addresses accepted for payments and refunds. Set to `undefined` for payments in NEAR token. */
|
|
19
|
+
acceptedTokens?: string[];
|
|
20
|
+
};
|
|
6
21
|
/**
|
|
7
22
|
* Gets a list of transfer events for a set of Near payment details
|
|
23
|
+
* TheGraph-based etriever for ERC20 Fee Proxy and Native token payments.
|
|
8
24
|
*/
|
|
9
|
-
export declare class NearInfoRetriever {
|
|
10
|
-
protected
|
|
11
|
-
protected toAddress: string;
|
|
12
|
-
protected proxyContractName: string;
|
|
13
|
-
protected eventName: PaymentTypes.EVENTS_NAMES;
|
|
14
|
-
protected client: TheGraphClient<'near'>;
|
|
25
|
+
export declare class NearInfoRetriever implements ITheGraphBaseInfoRetriever<NearPaymentEvent> {
|
|
26
|
+
protected readonly client: TheGraphClient<CurrencyTypes.NearChainName>;
|
|
15
27
|
/**
|
|
16
28
|
* @param paymentReference The reference to identify the payment
|
|
17
29
|
* @param toAddress Address to check
|
|
18
30
|
* @param eventName Indicate if it is an address for payment or refund
|
|
19
|
-
* @param network The id of network we want to check
|
|
20
31
|
*
|
|
21
32
|
*/
|
|
22
|
-
constructor(
|
|
23
|
-
getTransferEvents(): Promise<PaymentTypes.
|
|
33
|
+
constructor(client: TheGraphClient<CurrencyTypes.NearChainName>);
|
|
34
|
+
getTransferEvents(params: TransferEventsParams): Promise<PaymentTypes.AllNetworkEvents<NearPaymentEvent>>;
|
|
35
|
+
private mapPaymentEvent;
|
|
24
36
|
}
|
|
25
|
-
export {};
|
|
26
37
|
//# sourceMappingURL=near-info-retriever.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"near-info-retriever.d.ts","sourceRoot":"","sources":["../../../src/near/retrievers/near-info-retriever.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"near-info-retriever.d.ts","sourceRoot":"","sources":["../../../src/near/retrievers/near-info-retriever.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AAGzE,MAAM,WAAW,gBAAiB,SAAQ,YAAY,CAAC,+BAA+B;IACpF,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,2CAA2C;IAC3C,gBAAgB,EAAE,MAAM,CAAC;IACzB,oCAAoC;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,uCAAuC;IACvC,eAAe,EAAE,MAAM,CAAC;IACxB,qCAAqC;IACrC,YAAY,EAAE,aAAa,CAAC,WAAW,CAAC;IACxC,0DAA0D;IAC1D,SAAS,EAAE,YAAY,CAAC,YAAY,CAAC;IACrC,2HAA2H;IAC3H,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B,CAAC;AACF;;;GAGG;AACH,qBAAa,iBAAkB,YAAW,0BAA0B,CAAC,gBAAgB,CAAC;IAOxE,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC,aAAa,CAAC,aAAa,CAAC;IANlF;;;;;OAKG;gBAC4B,MAAM,EAAE,cAAc,CAAC,aAAa,CAAC,aAAa,CAAC;IAErE,iBAAiB,CAC5B,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,YAAY,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;IAsB3D,OAAO,CAAC,eAAe;CAmBxB"}
|
|
@@ -2,54 +2,59 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NearInfoRetriever = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const thegraph_1 = require("../../thegraph");
|
|
6
|
-
const currency_1 = require("@requestnetwork/currency");
|
|
7
5
|
/**
|
|
8
6
|
* Gets a list of transfer events for a set of Near payment details
|
|
7
|
+
* TheGraph-based etriever for ERC20 Fee Proxy and Native token payments.
|
|
9
8
|
*/
|
|
10
9
|
class NearInfoRetriever {
|
|
11
10
|
/**
|
|
12
11
|
* @param paymentReference The reference to identify the payment
|
|
13
12
|
* @param toAddress Address to check
|
|
14
13
|
* @param eventName Indicate if it is an address for payment or refund
|
|
15
|
-
* @param network The id of network we want to check
|
|
16
14
|
*
|
|
17
15
|
*/
|
|
18
|
-
constructor(
|
|
19
|
-
this.
|
|
20
|
-
this.toAddress = toAddress;
|
|
21
|
-
this.proxyContractName = proxyContractName;
|
|
22
|
-
this.eventName = eventName;
|
|
23
|
-
try {
|
|
24
|
-
currency_1.NearChains.assertChainSupported(network);
|
|
25
|
-
}
|
|
26
|
-
catch (_a) {
|
|
27
|
-
throw new Error('Near input data info-retriever only works with Near mainnet and testnet');
|
|
28
|
-
}
|
|
29
|
-
network = network.replace('aurora', 'near');
|
|
30
|
-
this.client = (0, thegraph_1.getTheGraphNearClient)(`https://api.thegraph.com/subgraphs/name/requestnetwork/request-payments-${network}`);
|
|
16
|
+
constructor(client) {
|
|
17
|
+
this.client = client;
|
|
31
18
|
}
|
|
32
|
-
getTransferEvents() {
|
|
19
|
+
getTransferEvents(params) {
|
|
33
20
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
21
|
+
const { paymentReference, toAddress, contractAddress, acceptedTokens } = params;
|
|
22
|
+
if (acceptedTokens && acceptedTokens.length > 1)
|
|
23
|
+
throw new Error(`NearInfoRetriever does not support multiple accepted tokens.`);
|
|
24
|
+
const payments = (acceptedTokens === null || acceptedTokens === void 0 ? void 0 : acceptedTokens.length) === 1
|
|
25
|
+
? yield this.client.GetFungibleTokenPayments({
|
|
26
|
+
reference: paymentReference,
|
|
27
|
+
to: toAddress,
|
|
28
|
+
contractAddress,
|
|
29
|
+
tokenAddress: acceptedTokens[0],
|
|
30
|
+
})
|
|
31
|
+
: yield this.client.GetNearPayments({
|
|
32
|
+
reference: paymentReference,
|
|
33
|
+
to: toAddress,
|
|
34
|
+
contractAddress,
|
|
35
|
+
});
|
|
36
|
+
return {
|
|
37
|
+
paymentEvents: payments.payments.map((p) => this.mapPaymentEvent(p, params)),
|
|
38
|
+
};
|
|
51
39
|
});
|
|
52
40
|
}
|
|
41
|
+
mapPaymentEvent(payment, params) {
|
|
42
|
+
var _a;
|
|
43
|
+
return {
|
|
44
|
+
amount: payment.amount,
|
|
45
|
+
name: params.eventName,
|
|
46
|
+
timestamp: Number(payment.timestamp),
|
|
47
|
+
parameters: {
|
|
48
|
+
feeAmount: payment.feeAmount,
|
|
49
|
+
receiptId: payment.receiptId,
|
|
50
|
+
block: payment.block,
|
|
51
|
+
to: params.toAddress,
|
|
52
|
+
from: payment.from,
|
|
53
|
+
feeAddress: (_a = payment.feeAddress) !== null && _a !== void 0 ? _a : undefined,
|
|
54
|
+
tokenAddress: params.acceptedTokens ? params.acceptedTokens[0] : undefined,
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
53
58
|
}
|
|
54
59
|
exports.NearInfoRetriever = NearInfoRetriever;
|
|
55
60
|
//# sourceMappingURL=near-info-retriever.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"near-info-retriever.js","sourceRoot":"","sources":["../../../src/near/retrievers/near-info-retriever.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"near-info-retriever.js","sourceRoot":"","sources":["../../../src/near/retrievers/near-info-retriever.ts"],"names":[],"mappings":";;;;AAwBA;;;GAGG;AACH,MAAa,iBAAiB;IAC5B;;;;;OAKG;IACH,YAA+B,MAAmD;QAAnD,WAAM,GAAN,MAAM,CAA6C;IAAG,CAAC;IAEzE,iBAAiB,CAC5B,MAA4B;;YAE5B,MAAM,EAAE,gBAAgB,EAAE,SAAS,EAAE,eAAe,EAAE,cAAc,EAAE,GAAG,MAAM,CAAC;YAChF,IAAI,cAAc,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC;gBAC7C,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAC;YAClF,MAAM,QAAQ,GACZ,CAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,MAAM,MAAK,CAAC;gBAC1B,CAAC,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,wBAAwB,CAAC;oBACzC,SAAS,EAAE,gBAAgB;oBAC3B,EAAE,EAAE,SAAS;oBACb,eAAe;oBACf,YAAY,EAAE,cAAc,CAAC,CAAC,CAAC;iBAChC,CAAC;gBACJ,CAAC,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC;oBAChC,SAAS,EAAE,gBAAgB;oBAC3B,EAAE,EAAE,SAAS;oBACb,eAAe;iBAChB,CAAC,CAAC;YACT,OAAO;gBACL,aAAa,EAAE,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;aAC7E,CAAC;QACJ,CAAC;KAAA;IAEO,eAAe,CACrB,OAA4C,EAC5C,MAA4B;;QAE5B,OAAO;YACL,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,IAAI,EAAE,MAAM,CAAC,SAAS;YACtB,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC;YACpC,UAAU,EAAE;gBACV,SAAS,EAAE,OAAO,CAAC,SAAS;gBAC5B,SAAS,EAAE,OAAO,CAAC,SAAS;gBAC5B,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,EAAE,EAAE,MAAM,CAAC,SAAS;gBACpB,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,UAAU,EAAE,MAAA,OAAO,CAAC,UAAU,mCAAI,SAAS;gBAC3C,YAAY,EAAE,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;aAC3E;SACF,CAAC;IACJ,CAAC;CACF;AApDD,8CAoDC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BigNumber } from 'ethers';
|
|
2
2
|
import { ExtensionTypes, PaymentTypes, RequestLogicTypes } from '@requestnetwork/types';
|
|
3
|
-
export declare abstract class PaymentDetectorBase<TExtension extends ExtensionTypes.IExtension, TPaymentEventParameters> implements PaymentTypes.IPaymentNetwork<TPaymentEventParameters> {
|
|
3
|
+
export declare abstract class PaymentDetectorBase<TExtension extends ExtensionTypes.IExtension, TPaymentEventParameters extends PaymentTypes.GenericEventParameters> implements PaymentTypes.IPaymentNetwork<TPaymentEventParameters> {
|
|
4
4
|
readonly paymentNetworkId: ExtensionTypes.PAYMENT_NETWORK_ID;
|
|
5
5
|
readonly extension: TExtension;
|
|
6
6
|
protected constructor(paymentNetworkId: ExtensionTypes.PAYMENT_NETWORK_ID, extension: TExtension);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payment-detector-base.d.ts","sourceRoot":"","sources":["../src/payment-detector-base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAOxF,8BAAsB,mBAAmB,CACvC,UAAU,SAAS,cAAc,CAAC,UAAU,EAC5C,uBAAuB,
|
|
1
|
+
{"version":3,"file":"payment-detector-base.d.ts","sourceRoot":"","sources":["../src/payment-detector-base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAOxF,8BAAsB,mBAAmB,CACvC,UAAU,SAAS,cAAc,CAAC,UAAU,EAC5C,uBAAuB,SAAS,YAAY,CAAC,sBAAsB,CACnE,YAAW,YAAY,CAAC,eAAe,CAAC,uBAAuB,CAAC;aAG9C,gBAAgB,EAAE,cAAc,CAAC,kBAAkB;aACnD,SAAS,EAAE,UAAU;IAFvC,SAAS,aACS,gBAAgB,EAAE,cAAc,CAAC,kBAAkB,EACnD,SAAS,EAAE,UAAU;IAGvC,QAAQ,CAAC,+BAA+B,CACtC,gCAAgC,EAAE,YAAY,CAAC,8BAA8B,CAAC,YAAY,CAAC,GAC1F,OAAO,CAAC,GAAG,CAAC;IACf,QAAQ,CAAC,2CAA2C,CAAC,UAAU,EAAE,GAAG,GAAG,GAAG;IAC1E,QAAQ,CAAC,4CAA4C,CAAC,UAAU,EAAE,GAAG,GAAG,GAAG;IAE3E;;;;;OAKG;IACU,UAAU,CACrB,OAAO,EAAE,iBAAiB,CAAC,QAAQ,GAClC,OAAO,CAAC,YAAY,CAAC,kBAAkB,CAAC,uBAAuB,CAAC,CAAC;IAkBpE;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,SAAS,CAC1B,OAAO,EAAE,iBAAiB,CAAC,QAAQ,GAClC,OAAO,CAAC,YAAY,CAAC,gBAAgB,CAAC,uBAAuB,CAAC,CAAC;IAElE,SAAS,CAAC,mBAAmB,CAC3B,OAAO,EAAE,iBAAiB,CAAC,QAAQ,GAClC,UAAU,SAAS,cAAc,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK;IAW3F,SAAS,CAAC,cAAc,CAAC,MAAM,EAAE,YAAY,CAAC,oBAAoB,CAAC,OAAO,CAAC,EAAE,GAAG,SAAS;IAYzF,SAAS,CAAC,UAAU,CAClB,MAAM,EAAE,YAAY,CAAC,oBAAoB,CAAC,uBAAuB,CAAC,EAAE,GACnE,YAAY,CAAC,oBAAoB,CAAC,uBAAuB,CAAC,EAAE;IAI/D,SAAS,CAAC,gBAAgB,CACxB,MAAM,EAAE,YAAY,CAAC,kBAAkB,EAAE,GACxC,YAAY,CAAC,kBAAkB,EAAE;IAIpC,SAAS,CAAC,sBAAsB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,IAAI,CAAC;CAK5F"}
|
|
@@ -15,7 +15,7 @@ export declare class PaymentNetworkFactory {
|
|
|
15
15
|
constructor(advancedLogic: AdvancedLogicTypes.IAdvancedLogic, currencyManager: ICurrencyManager, options?: Partial<PaymentNetworkOptions>);
|
|
16
16
|
private buildOptions;
|
|
17
17
|
/**
|
|
18
|
-
* Creates a payment network according to payment network creation parameters
|
|
18
|
+
* Creates a payment network interpretor according to payment network creation parameters
|
|
19
19
|
* It throws if the payment network given is not supported by this library
|
|
20
20
|
*
|
|
21
21
|
* @param paymentNetworkId the ID of the payment network to instantiate
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payment-network-factory.d.ts","sourceRoot":"","sources":["../src/payment-network-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,YAAY,EACZ,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAIL,qBAAqB,EACtB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"payment-network-factory.d.ts","sourceRoot":"","sources":["../src/payment-network-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,YAAY,EACZ,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAIL,qBAAqB,EACtB,MAAM,SAAS,CAAC;AA0EjB,+FAA+F;AAC/F,qBAAa,qBAAqB;IAS9B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,eAAe;IATlC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkC;IAC1D;;;;;OAKG;gBAEgB,aAAa,EAAE,kBAAkB,CAAC,cAAc,EAChD,eAAe,EAAE,gBAAgB,EAClD,OAAO,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC;IAK1C,OAAO,CAAC,YAAY;IASpB;;;;;;;;OAQG;IACI,oBAAoB,CACzB,gBAAgB,EAAE,cAAc,CAAC,kBAAkB,EACnD,YAAY,EAAE,iBAAiB,CAAC,QAAQ,EACxC,YAAY,CAAC,EAAE,aAAa,CAAC,SAAS,EACtC,qBAAqB,CAAC,EAAE,MAAM,GAC7B,YAAY,CAAC,eAAe;IAqC/B;;;;;;OAMG;IACI,4BAA4B,CACjC,OAAO,EAAE,iBAAiB,CAAC,QAAQ,GAClC,YAAY,CAAC,eAAe,GAAG,IAAI;CAgBvC"}
|
|
@@ -29,6 +29,15 @@ const supportedPaymentNetwork = {
|
|
|
29
29
|
},
|
|
30
30
|
},
|
|
31
31
|
ERC20: {
|
|
32
|
+
aurora: {
|
|
33
|
+
[PN_ID.ERC20_FEE_PROXY_CONTRACT]: (erc20_1.ERC20FeeProxyPaymentDetector),
|
|
34
|
+
},
|
|
35
|
+
'aurora-testnet': {
|
|
36
|
+
[PN_ID.ERC20_FEE_PROXY_CONTRACT]: (erc20_1.ERC20FeeProxyPaymentDetector),
|
|
37
|
+
},
|
|
38
|
+
'near-testnet': {
|
|
39
|
+
[PN_ID.ERC20_FEE_PROXY_CONTRACT]: (erc20_1.ERC20FeeProxyPaymentDetector),
|
|
40
|
+
},
|
|
32
41
|
'*': {
|
|
33
42
|
[PN_ID.ERC20_ADDRESS_BASED]: erc20_1.ERC20AddressBasedPaymentDetector,
|
|
34
43
|
[PN_ID.ERC20_PROXY_CONTRACT]: erc20_1.ERC20ProxyPaymentDetector,
|
|
@@ -71,18 +80,14 @@ class PaymentNetworkFactory {
|
|
|
71
80
|
}
|
|
72
81
|
buildOptions(options) {
|
|
73
82
|
const defaultOptions = {
|
|
74
|
-
getSubgraphClient:
|
|
75
|
-
return network === 'private'
|
|
76
|
-
? undefined
|
|
77
|
-
: (0, thegraph_1.getTheGraphClient)(`https://api.thegraph.com/subgraphs/name/requestnetwork/request-payments-${network}`);
|
|
78
|
-
},
|
|
83
|
+
getSubgraphClient: thegraph_1.defaultGetTheGraphClient,
|
|
79
84
|
explorerApiKeys: {},
|
|
80
85
|
getRpcProvider: ethers_1.getDefaultProvider,
|
|
81
86
|
};
|
|
82
87
|
return Object.assign(Object.assign({}, defaultOptions), options);
|
|
83
88
|
}
|
|
84
89
|
/**
|
|
85
|
-
* Creates a payment network according to payment network creation parameters
|
|
90
|
+
* Creates a payment network interpretor according to payment network creation parameters
|
|
86
91
|
* It throws if the payment network given is not supported by this library
|
|
87
92
|
*
|
|
88
93
|
* @param paymentNetworkId the ID of the payment network to instantiate
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payment-network-factory.js","sourceRoot":"","sources":["../src/payment-network-factory.ts"],"names":[],"mappings":";;;AAAA,iDAM+B;AAQ/B,+BAAuF;AACvF,+CAA2D;AAC3D,mCAKiB;AACjB,sEAAyE;AACzE,+BAAgF;AAChF,+BAAmF;AACnF,iCAAkG;AAClG,mCAAqD;AACrD,
|
|
1
|
+
{"version":3,"file":"payment-network-factory.js","sourceRoot":"","sources":["../src/payment-network-factory.ts"],"names":[],"mappings":";;;AAAA,iDAM+B;AAQ/B,+BAAuF;AACvF,+CAA2D;AAC3D,mCAKiB;AACjB,sEAAyE;AACzE,+BAAgF;AAChF,+BAAmF;AACnF,iCAAkG;AAClG,mCAAqD;AACrD,yCAAsD;AACtD,mCAA4C;AAE5C,MAAM,KAAK,GAAG,sBAAc,CAAC,kBAAkB,CAAC;AAEhD,wDAAwD;AACxD,MAAM,uBAAuB,GAAuC;IAClE,GAAG,EAAE;QACH,OAAO,EAAE;YACP,CAAC,KAAK,CAAC,qBAAqB,CAAC,EAAE,oCAA8B;SAC9D;QACD,OAAO,EAAE;YACP,CAAC,KAAK,CAAC,6BAA6B,CAAC,EAAE,oCAA8B;SACtE;KACF;IACD,MAAM,EAAE;QACN,GAAG,EAAE;YACH,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE,+CAAyB;SACjD;KACF;IACD,KAAK,EAAE;QACL,MAAM,EAAE;YACN,CAAC,KAAK,CAAC,wBAAwB,CAAC,EAAE,CAAA,oCAAyD,CAAA;SAC5F;QACD,gBAAgB,EAAE;YAChB,CAAC,KAAK,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CACjC,OAAmC;;QAEnC,MAAM,EAAE,GAAG,IAAA,kCAA0B,EAAC,OAAO,CAAC,CAAC;QAC/C,IAAI,CAAC,EAAE,EAAE;YACP,OAAO,IAAI,CAAC;SACb;QAED,MAAM,cAAc,GAAG,MAAA,MAAA,EAAE,CAAC,MAAM,0CAAE,OAAO,mCAAI,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;QAEtE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC;QAC3B,OAAO,IAAI,CAAC,oBAAoB,CAC9B,EAAkD,EAClD,OAAO,CAAC,QAAQ,CAAC,IAAI,EACrB,cAAc,EACd,OAAO,CACR,CAAC;IACJ,CAAC;CACF;AArGD,sDAqGC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { CurrencyTypes } from '@requestnetwork/types';
|
|
1
2
|
/**
|
|
2
3
|
* A GraphQL client to query Request's subgraph.
|
|
3
4
|
*
|
|
4
5
|
* @type TGraphClientVariant: null if no variant, 'near' if native token payments detection on Near
|
|
5
6
|
*/
|
|
6
|
-
export type TheGraphClient<
|
|
7
|
+
export type TheGraphClient<TChain extends CurrencyTypes.VMChainName = CurrencyTypes.EvmChainName> = TChain extends CurrencyTypes.NearChainName ? ReturnType<typeof getTheGraphNearClient> : ReturnType<typeof getTheGraphClient>;
|
|
7
8
|
export type TheGraphClientOptions = {
|
|
8
9
|
timeout?: number;
|
|
9
10
|
};
|
|
@@ -47,10 +48,67 @@ export declare const getTheGraphNearClient: (url: string, options?: TheGraphClie
|
|
|
47
48
|
maxRateTimespan: number;
|
|
48
49
|
contractAddress: string;
|
|
49
50
|
}>, requestHeaders?: (Record<string, string> | import("graphql-request/dist/types.dom").Headers | string[][]) | undefined): Promise<import("./generated/graphql-near").GetAnyToNativePaymentsQuery>;
|
|
51
|
+
GetFungibleTokenPayments(variables: import("./generated/graphql-near").Exact<{
|
|
52
|
+
reference: string;
|
|
53
|
+
to: string;
|
|
54
|
+
contractAddress: string;
|
|
55
|
+
tokenAddress: string;
|
|
56
|
+
}>, requestHeaders?: (Record<string, string> | import("graphql-request/dist/types.dom").Headers | string[][]) | undefined): Promise<import("./generated/graphql-near").GetFungibleTokenPaymentsQuery>;
|
|
50
57
|
GetNearPayments(variables: import("./generated/graphql-near").Exact<{
|
|
51
58
|
reference: string;
|
|
52
59
|
to: string;
|
|
53
60
|
contractAddress: string;
|
|
54
61
|
}>, requestHeaders?: (Record<string, string> | import("graphql-request/dist/types.dom").Headers | string[][]) | undefined): Promise<import("./generated/graphql-near").GetNearPaymentsQuery>;
|
|
55
62
|
};
|
|
63
|
+
export declare const defaultGetTheGraphClient: (network: CurrencyTypes.ChainName) => {
|
|
64
|
+
GetLastSyncedBlock(variables?: import("./generated/graphql").Exact<{
|
|
65
|
+
[key: string]: never;
|
|
66
|
+
}> | undefined, requestHeaders?: (Record<string, string> | import("graphql-request/dist/types.dom").Headers | string[][]) | undefined): Promise<import("./generated/graphql").GetLastSyncedBlockQuery>;
|
|
67
|
+
GetPaymentsAndEscrowState(variables: import("./generated/graphql").Exact<{
|
|
68
|
+
reference: any;
|
|
69
|
+
to: any;
|
|
70
|
+
tokenAddress?: any;
|
|
71
|
+
contractAddress: any;
|
|
72
|
+
}>, requestHeaders?: (Record<string, string> | import("graphql-request/dist/types.dom").Headers | string[][]) | undefined): Promise<import("./generated/graphql").GetPaymentsAndEscrowStateQuery>;
|
|
73
|
+
GetAnyToFungiblePayments(variables: import("./generated/graphql").Exact<{
|
|
74
|
+
reference: any;
|
|
75
|
+
to: any;
|
|
76
|
+
currency: any;
|
|
77
|
+
acceptedTokens?: any;
|
|
78
|
+
contractAddress: any;
|
|
79
|
+
}>, requestHeaders?: (Record<string, string> | import("graphql-request/dist/types.dom").Headers | string[][]) | undefined): Promise<import("./generated/graphql").GetAnyToFungiblePaymentsQuery>;
|
|
80
|
+
GetAnyToNativePayments(variables: import("./generated/graphql").Exact<{
|
|
81
|
+
reference: any;
|
|
82
|
+
to: any;
|
|
83
|
+
currency: any;
|
|
84
|
+
contractAddress: any;
|
|
85
|
+
}>, requestHeaders?: (Record<string, string> | import("graphql-request/dist/types.dom").Headers | string[][]) | undefined): Promise<import("./generated/graphql").GetAnyToNativePaymentsQuery>;
|
|
86
|
+
GetPaymentsAndEscrowStateForReceivables(variables: import("./generated/graphql").Exact<{
|
|
87
|
+
reference: any;
|
|
88
|
+
tokenAddress: any;
|
|
89
|
+
contractAddress: any;
|
|
90
|
+
}>, requestHeaders?: (Record<string, string> | import("graphql-request/dist/types.dom").Headers | string[][]) | undefined): Promise<import("./generated/graphql").GetPaymentsAndEscrowStateForReceivablesQuery>;
|
|
91
|
+
GetSyncedBlock(variables: import("./generated/graphql").Exact<{
|
|
92
|
+
blockHash: any;
|
|
93
|
+
}>, requestHeaders?: (Record<string, string> | import("graphql-request/dist/types.dom").Headers | string[][]) | undefined): Promise<import("./generated/graphql").GetSyncedBlockQuery>;
|
|
94
|
+
} | {
|
|
95
|
+
GetAnyToNativePayments(variables: import("./generated/graphql-near").Exact<{
|
|
96
|
+
reference: string;
|
|
97
|
+
to: string;
|
|
98
|
+
currency: string;
|
|
99
|
+
maxRateTimespan: number;
|
|
100
|
+
contractAddress: string;
|
|
101
|
+
}>, requestHeaders?: (Record<string, string> | import("graphql-request/dist/types.dom").Headers | string[][]) | undefined): Promise<import("./generated/graphql-near").GetAnyToNativePaymentsQuery>;
|
|
102
|
+
GetFungibleTokenPayments(variables: import("./generated/graphql-near").Exact<{
|
|
103
|
+
reference: string;
|
|
104
|
+
to: string;
|
|
105
|
+
contractAddress: string;
|
|
106
|
+
tokenAddress: string;
|
|
107
|
+
}>, requestHeaders?: (Record<string, string> | import("graphql-request/dist/types.dom").Headers | string[][]) | undefined): Promise<import("./generated/graphql-near").GetFungibleTokenPaymentsQuery>;
|
|
108
|
+
GetNearPayments(variables: import("./generated/graphql-near").Exact<{
|
|
109
|
+
reference: string;
|
|
110
|
+
to: string;
|
|
111
|
+
contractAddress: string;
|
|
112
|
+
}>, requestHeaders?: (Record<string, string> | import("graphql-request/dist/types.dom").Headers | string[][]) | undefined): Promise<import("./generated/graphql-near").GetNearPaymentsQuery>;
|
|
113
|
+
} | undefined;
|
|
56
114
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/thegraph/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/thegraph/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAYtD;;;;GAIG;AACH,MAAM,MAAM,cAAc,CAAC,MAAM,SAAS,aAAa,CAAC,WAAW,GAAG,aAAa,CAAC,YAAY,IAC9F,MAAM,SAAS,aAAa,CAAC,aAAa,GACtC,UAAU,CAAC,OAAO,qBAAqB,CAAC,GACxC,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE3C,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,iBAAiB,QAAS,MAAM,YAAY,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACrC,CAAC;AAE1C,eAAO,MAAM,qBAAqB,QAAS,MAAM,YAAY,qBAAqB;;;;;;;;;;;;;;;;;;;CACrC,CAAC;AAE9C,eAAO,MAAM,wBAAwB,YAAa,cAAc,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAMxE,CAAC"}
|
package/dist/thegraph/client.js
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getTheGraphNearClient = exports.getTheGraphClient = void 0;
|
|
4
|
-
|
|
3
|
+
exports.defaultGetTheGraphClient = exports.getTheGraphNearClient = exports.getTheGraphClient = void 0;
|
|
4
|
+
const currency_1 = require("@requestnetwork/currency");
|
|
5
5
|
const graphql_request_1 = require("graphql-request");
|
|
6
6
|
const graphql_1 = require("./generated/graphql");
|
|
7
7
|
const graphql_near_1 = require("./generated/graphql-near");
|
|
8
|
+
const HOSTED_THE_GRAPH_URL = 'https://api.thegraph.com/subgraphs/name/requestnetwork/request-payments-';
|
|
8
9
|
const getTheGraphClient = (url, options) => (0, graphql_1.getSdk)(new graphql_request_1.GraphQLClient(url, options));
|
|
9
10
|
exports.getTheGraphClient = getTheGraphClient;
|
|
10
11
|
const getTheGraphNearClient = (url, options) => (0, graphql_near_1.getSdk)(new graphql_request_1.GraphQLClient(url, options));
|
|
11
12
|
exports.getTheGraphNearClient = getTheGraphNearClient;
|
|
13
|
+
const defaultGetTheGraphClient = (network) => {
|
|
14
|
+
return network === 'private'
|
|
15
|
+
? undefined
|
|
16
|
+
: currency_1.NearChains.isChainSupported(network)
|
|
17
|
+
? (0, exports.getTheGraphNearClient)(`${HOSTED_THE_GRAPH_URL}${network.replace('aurora', 'near')}`)
|
|
18
|
+
: (0, exports.getTheGraphClient)(`${HOSTED_THE_GRAPH_URL}${network}`);
|
|
19
|
+
};
|
|
20
|
+
exports.defaultGetTheGraphClient = defaultGetTheGraphClient;
|
|
12
21
|
//# sourceMappingURL=client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/thegraph/client.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/thegraph/client.ts"],"names":[],"mappings":";;;AAEA,uDAAsD;AACtD,qDAAgD;AAChD,iDAA6C;AAC7C,2DAAgE;AAEhE,MAAM,oBAAoB,GACxB,0EAA0E,CAAC;AAmBtE,MAAM,iBAAiB,GAAG,CAAC,GAAW,EAAE,OAA+B,EAAE,EAAE,CAChF,IAAA,gBAAM,EAAC,IAAI,+BAAa,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AAD7B,QAAA,iBAAiB,qBACY;AAEnC,MAAM,qBAAqB,GAAG,CAAC,GAAW,EAAE,OAA+B,EAAE,EAAE,CACpF,IAAA,qBAAU,EAAC,IAAI,+BAAa,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AADjC,QAAA,qBAAqB,yBACY;AAEvC,MAAM,wBAAwB,GAAG,CAAC,OAAgC,EAAE,EAAE;IAC3E,OAAO,OAAO,KAAK,SAAS;QAC1B,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,qBAAU,CAAC,gBAAgB,CAAC,OAAO,CAAC;YACtC,CAAC,CAAC,IAAA,6BAAqB,EAAC,GAAG,oBAAoB,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,CAAC;YACtF,CAAC,CAAC,IAAA,yBAAiB,EAAC,GAAG,oBAAoB,GAAG,OAAO,EAAE,CAAC,CAAC;AAC7D,CAAC,CAAC;AANW,QAAA,wBAAwB,4BAMnC"}
|