@requestnetwork/payment-detection 0.35.1-next.1755 → 0.35.1-next.1759

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.
@@ -1 +1 @@
1
- {"version":3,"file":"declarative.d.ts","sourceRoot":"","sources":["../src/declarative.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D;;GAEG;AACH,8BAAsB,8BAA8B,CAClD,UAAU,SAAS,cAAc,CAAC,gBAAgB,CAAC,eAAe,EAClE,uBAAuB,SAAS,YAAY,CAAC,kCAAkC,CAC/E,SAAQ,mBAAmB,CAAC,UAAU,EAAE,uBAAuB,CAAC;gBAC7C,iBAAiB,EAAE,YAAY,CAAC,kBAAkB,EAAE,SAAS,EAAE,UAAU;IAI5F;;;;;;OAMG;IACU,+BAA+B,CAC1C,gCAAgC,EAAE,cAAc,CAAC,gBAAgB,CAAC,mBAAmB,GACpF,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC;IAOlC;;;;;OAKG;IACI,4CAA4C,CACjD,UAAU,EAAE,cAAc,CAAC,gBAAgB,CAAC,gCAAgC,GAC3E,cAAc,CAAC,OAAO;IAMzB;;;;;OAKG;IACI,2CAA2C,CAChD,UAAU,EAAE,cAAc,CAAC,gBAAgB,CAAC,+BAA+B,GAC1E,cAAc,CAAC,OAAO;IAMzB;;;;;OAKG;IACI,yCAAyC,CAC9C,UAAU,EAAE,cAAc,CAAC,gBAAgB,CAAC,eAAe,GAC1D,cAAc,CAAC,OAAO;IASzB;;;;;OAKG;IACI,wCAAwC,CAC7C,UAAU,EAAE,cAAc,CAAC,gBAAgB,CAAC,eAAe,GAC1D,cAAc,CAAC,OAAO;IASzB;;;;;OAKG;IACI,6CAA6C,CAClD,UAAU,EAAE,cAAc,CAAC,g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O,CAAC,YAAY,CAAC,gBAAgB,CAAC,YAAY,CAAC,kCAAkC,CAAC,CAAC;CAK3F"}
@@ -24,6 +24,7 @@ class DeclarativePaymentDetectorBase extends payment_detector_base_1.PaymentDete
24
24
  return this.extension.createCreationAction({
25
25
  paymentInfo: paymentNetworkCreationParameters.paymentInfo,
26
26
  refundInfo: paymentNetworkCreationParameters.refundInfo,
27
+ salt: paymentNetworkCreationParameters.salt,
27
28
  });
28
29
  });
29
30
  }
@@ -1 +1 @@
1
- {"version":3,"file":"declarative.js","sourceRoot":"","sources":["../src/declarative.ts"],"names":[],"mappings":";;;;AAAA,iDAK+B;AAC/B,iDAA0C;AAC1C,mEAA8D;AAE9D;;GAEG;AACH,MAAsB,8BAGpB,SAAQ,2CAAwD;IAChE,YAAmB,iBAAkD,EAAE,SAAqB;QAC1F,KAAK,CAAC,iBAAiB,EAAE,SAAS,CAAC,CAAC;IACtC,CAAC;IAED;;;;;;OAMG;IACU,+BAA+B,CAC1C,gCAAqF;;YAErF,OAAO,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC;gBACzC,WAAW,EAAE,gCAAgC,CAAC,WAAW;gBACzD,UAAU,EAAE,gCAAgC,CAAC,UAAU;aACxD,CAAC,CAAC;QACL,CAAC;KAAA;IAED;;;;;OAKG;IACI,4CAA4C,CACjD,UAA4E;QAE5E,OAAO,IAAI,CAAC,SAAS,CAAC,iCAAiC,CAAC;YACtD,WAAW,EAAE,UAAU,CAAC,WAAW;SACpC,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACI,2CAA2C,CAChD,UAA2E;QAE3E,OAAO,IAAI,CAAC,SAAS,CAAC,gCAAgC,CAAC;YACrD,UAAU,EAAE,UAAU,CAAC,UAAU;SAClC,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACI,yCAAyC,CAC9C,UAA2D;QAE3D,OAAO,IAAI,CAAC,SAAS,CAAC,8BAA8B,CAAC;YACnD,MAAM,EAAE,UAAU,CAAC,MAA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,oBAAY,CAAC,YAAY,CAAC,OAAO;gBACnC,CAAC,sBAAc,CAAC,gBAAgB,CAAC,MAAM,CAAC,uBAAuB,CAAC,EAC9D,oBAAY,CAAC,YAAY,CAAC,MAAM;aACnC,CAAC;YAEF,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAChC,IAAI,IAAI,EAAE;gBACR,OAAO;oBACL,MAAM;oBACN,IAAI;oBACJ,UAAU,EAAE;wBACV,MAAM;wBACN,OAAO;wBACP,IAAI;wBACJ,IAAI,EAAE,IAAI,CAAC,IAAI;qBAChB;oBACD,SAAS,EAAE,IAAI,CAAC,SAAS;iBAC1B,CAAC;aACH;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC;aACD,MAAM,CAAC,eAAK,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;CACF;AA7KD,wEA6KC;AAED;;GAEG;AACH,MAAa,0BAA2B,SAAQ,8BAG/C;IACC,YAAY,EAAE,aAAa,EAAwD;QACjF,KAAK,CAAC,oBAAY,CAAC,kBAAkB,CAAC,WAAW,EAAE,aAAa,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAC3F,CAAC;IAEe,SAAS,CACvB,OAAmC;;YAEnC,OAAO;gBACL,aAAa,EAAE,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC;aAClD,CAAC;QACJ,CAAC;KAAA;CACF;AAfD,gEAeC"}
@@ -10,16 +10,43 @@ export declare class SuperFluidPaymentDetector extends ReferenceBasedDetector<Ex
10
10
  constructor({ advancedLogic }: {
11
11
  advancedLogic: AdvancedLogicTypes.IAdvancedLogic;
12
12
  });
13
+ protected isSubsequentRequest(request: RequestLogicTypes.IRequest): boolean;
13
14
  /**
14
- * Extracts the balance and events of an address
15
+ * This returns the specific values we store for the ERC777 extensions.
16
+ * @param request The request we are processing
17
+ */
18
+ protected getSubsequentValues(request: RequestLogicTypes.IRequest): ExtensionTypes.PnStreamReferenceBased.ISubsequentRequestCreationParameters;
19
+ /**
20
+ * With streaming requests we have a custom balance computation.
21
+ * It is possible to have only one streaming event, start stream,
22
+ * but have 10 requests being created each month for the same stream.
23
+ * For the original request, the first one, the balance computation is easy because we don't care about previous expected balance.
24
+ * For subsequent requests we must take into consideration how many requests were before this one and then attribute the rest of the balance to this one.
25
+ * At this point we are not detecting overpayment because in case of overpayment we are considering that another request should have been created in the series.
26
+ * @param request The request we are calculating balance for
27
+ * @returns Balance object with balance value and payment/refund events
28
+ */
29
+ getBalance(request: RequestLogicTypes.IRequest): Promise<PaymentTypes.IBalanceWithEvents<PaymentTypes.IERC777PaymentEventParameters | PaymentTypes.IDeclarativePaymentEventParameters>>;
30
+ /**
31
+ * Extracts payment events of an address matching an address and a payment reference
15
32
  *
16
- * @private
17
- * @param address Address to check
18
33
  * @param eventName Indicate if it is an address for payment or refund
19
- * @param network The id of network we want to check
20
- * @param tokenContractAddress the address of the token contract
21
- * @returns The balance and events
34
+ * @param address Address to check
35
+ * @param paymentReference The reference to identify the payment
36
+ * @param requestCurrency The request currency
37
+ * @param paymentChain the payment network
38
+ * @returns List of payment events
22
39
  */
23
40
  protected extractEvents(eventName: PaymentTypes.EVENTS_NAMES, address: string | undefined, paymentReference: string, requestCurrency: RequestLogicTypes.ICurrency, paymentChain: string): Promise<PaymentTypes.AllNetworkEvents<PaymentTypes.IERC777PaymentEventParameters>>;
41
+ /**
42
+ * In the case of the first, original request that starts the streaming,
43
+ * we calculate the payment reference from its own data: requestId, salt, paymentAddress.
44
+ * In the case of subsequent requests we need to have the same payment reference from the original request,
45
+ * so we need to use the original requests requestId, which we have stored in
46
+ * extension values as originalRequestId, the salt and paymentAddress are the same.
47
+ * @param request The request we need payment reference for
48
+ * @returns The payment reference
49
+ */
50
+ protected getPaymentReference(request: RequestLogicTypes.IRequest): string;
24
51
  }
25
52
  //# sourceMappingURL=superfluid-detector.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"superfluid-detector.d.ts","sourceRoot":"","sources":["../../src/erc777/superfluid-detector.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,sBAAsB,CACnE,cAAc,CAAC,gBAAgB,CAAC,eAAe,EAC/C,YAAY,CAAC,6BAA6B,CAC3C;IACC;;OAEG;gBACgB,EAAE,aAAa,EAAE,EAAE;QAAE,aAAa,EAAE,kBAAkB,CAAC,cAAc,CAAA;KAAE;IAI1F;;;;;;;;;OASG;cACa,aAAa,CAC3B,SAAS,EAAE,YAAY,CAAC,YAAY,EACpC,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,gBAAgB,EAAE,MAAM,EACxB,eAAe,EAAE,iBAAiB,CAAC,SAAS,EAC5C,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,YAAY,CAAC,gBAAgB,CAAC,YAAY,CAAC,6BAA6B,CAAC,CAAC;CAmBtF"}
1
+ {"version":3,"file":"superfluid-detector.d.ts","sourceRoot":"","sources":["../../src/erc777/superfluid-detector.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAGrE;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,sBAAsB,CACnE,cAAc,CAAC,gBAAgB,CAAC,eAAe,EAC/C,YAAY,CAAC,6BAA6B,CAC3C;IACC;;OAEG;gBACgB,EAAE,aAAa,EAAE,EAAE;QAAE,aAAa,EAAE,kBAAkB,CAAC,cAAc,CAAA;KAAE;IAI1F,SAAS,CAAC,mBAAmB,CAAC,OAAO,EAAE,iBAAiB,CAAC,QAAQ,GAAG,OAAO;IAI3E;;;OAGG;IACH,SAAS,CAAC,mBAAmB,CAC3B,OAAO,EAAE,iBAAiB,CAAC,QAAQ,GAClC,cAAc,CAAC,sBAAsB,CAAC,oCAAoC;IAI7E;;;;;;;;;OASG;IACU,UAAU,CACrB,OAAO,EAAE,iBAAiB,CAAC,QAAQ,GAClC,OAAO,CACR,YAAY,CAAC,kBAAkB,CAC7B,YAAY,CAAC,6BAA6B,GAAG,YAAY,CAAC,kCAAkC,CAC7F,CACF;IAwBD;;;;;;;;;OASG;cACa,aAAa,CAC3B,SAAS,EAAE,YAAY,CAAC,YAAY,EACpC,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,gBAAgB,EAAE,MAAM,EACxB,eAAe,EAAE,iBAAiB,CAAC,SAAS,EAC5C,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,YAAY,CAAC,gBAAgB,CAAC,YAAY,CAAC,6BAA6B,CAAC,CAAC;IAoBrF;;;;;;;;OAQG;IACH,SAAS,CAAC,mBAAmB,CAAC,OAAO,EAAE,iBAAiB,CAAC,QAAQ,GAAG,MAAM;CAS3E"}
@@ -5,6 +5,8 @@ const tslib_1 = require("tslib");
5
5
  const types_1 = require("@requestnetwork/types");
6
6
  const superfluid_retriever_1 = require("./superfluid-retriever");
7
7
  const reference_based_detector_1 = require("../reference-based-detector");
8
+ const payment_reference_calculator_1 = require("../payment-reference-calculator");
9
+ const ethers_1 = require("ethers");
8
10
  /**
9
11
  * Handle payment networks with ERC777 Superfluid streaming extension
10
12
  */
@@ -15,15 +17,61 @@ class SuperFluidPaymentDetector extends reference_based_detector_1.ReferenceBase
15
17
  constructor({ advancedLogic }) {
16
18
  super(types_1.PaymentTypes.PAYMENT_NETWORK_ID.ERC777_STREAM, advancedLogic.extensions.erc777Stream);
17
19
  }
20
+ isSubsequentRequest(request) {
21
+ return !!request.extensions[this.paymentNetworkId].values.originalRequestId;
22
+ }
18
23
  /**
19
- * Extracts the balance and events of an address
24
+ * This returns the specific values we store for the ERC777 extensions.
25
+ * @param request The request we are processing
26
+ */
27
+ getSubsequentValues(request) {
28
+ return request.extensions[this.paymentNetworkId].values;
29
+ }
30
+ /**
31
+ * With streaming requests we have a custom balance computation.
32
+ * It is possible to have only one streaming event, start stream,
33
+ * but have 10 requests being created each month for the same stream.
34
+ * For the original request, the first one, the balance computation is easy because we don't care about previous expected balance.
35
+ * For subsequent requests we must take into consideration how many requests were before this one and then attribute the rest of the balance to this one.
36
+ * At this point we are not detecting overpayment because in case of overpayment we are considering that another request should have been created in the series.
37
+ * @param request The request we are calculating balance for
38
+ * @returns Balance object with balance value and payment/refund events
39
+ */
40
+ getBalance(request) {
41
+ const _super = Object.create(null, {
42
+ getBalance: { get: () => super.getBalance }
43
+ });
44
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
45
+ const totalBalance = yield _super.getBalance.call(this, request);
46
+ if (totalBalance.error) {
47
+ return totalBalance;
48
+ }
49
+ if (totalBalance.balance) {
50
+ const zeroBN = ethers_1.BigNumber.from(0);
51
+ const recurrenceNumber = this.getSubsequentValues(request).recurrenceNumber || 0;
52
+ // This request's balance is the total streamed amount, less all previous requests balance.
53
+ const remainingBalance = ethers_1.BigNumber.from(totalBalance.balance).sub(ethers_1.BigNumber.from(request.expectedAmount).mul(ethers_1.BigNumber.from(recurrenceNumber)));
54
+ // Balance is stricty between 0 and expectedAmount
55
+ const expectedAmount = ethers_1.BigNumber.from(request.expectedAmount);
56
+ const requestBalance = remainingBalance.lt(0)
57
+ ? zeroBN
58
+ : remainingBalance.gt(expectedAmount)
59
+ ? expectedAmount
60
+ : remainingBalance;
61
+ totalBalance.balance = requestBalance.toString();
62
+ }
63
+ return totalBalance;
64
+ });
65
+ }
66
+ /**
67
+ * Extracts payment events of an address matching an address and a payment reference
20
68
  *
21
- * @private
22
- * @param address Address to check
23
69
  * @param eventName Indicate if it is an address for payment or refund
24
- * @param network The id of network we want to check
25
- * @param tokenContractAddress the address of the token contract
26
- * @returns The balance and events
70
+ * @param address Address to check
71
+ * @param paymentReference The reference to identify the payment
72
+ * @param requestCurrency The request currency
73
+ * @param paymentChain the payment network
74
+ * @returns List of payment events
27
75
  */
28
76
  extractEvents(eventName, address, paymentReference, requestCurrency, paymentChain) {
29
77
  return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
@@ -39,6 +87,24 @@ class SuperFluidPaymentDetector extends reference_based_detector_1.ReferenceBase
39
87
  };
40
88
  });
41
89
  }
90
+ /**
91
+ * In the case of the first, original request that starts the streaming,
92
+ * we calculate the payment reference from its own data: requestId, salt, paymentAddress.
93
+ * In the case of subsequent requests we need to have the same payment reference from the original request,
94
+ * so we need to use the original requests requestId, which we have stored in
95
+ * extension values as originalRequestId, the salt and paymentAddress are the same.
96
+ * @param request The request we need payment reference for
97
+ * @returns The payment reference
98
+ */
99
+ getPaymentReference(request) {
100
+ const { paymentAddress, salt } = this.getPaymentExtension(request).values;
101
+ this.checkRequiredParameter(paymentAddress, 'paymentAddress');
102
+ this.checkRequiredParameter(salt, 'salt');
103
+ const requestId = this.isSubsequentRequest(request)
104
+ ? this.getSubsequentValues(request).originalRequestId
105
+ : request.requestId;
106
+ return payment_reference_calculator_1.default.calculate(requestId, salt, paymentAddress);
107
+ }
42
108
  }
43
109
  exports.SuperFluidPaymentDetector = SuperFluidPaymentDetector;
44
110
  //# sourceMappingURL=superfluid-detector.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"superfluid-detector.js","sourceRoot":"","sources":["../../src/erc777/superfluid-detector.ts"],"names":[],"mappings":";;;;AAAA,iDAK+B;AAC/B,iEAAiE;AACjE,0EAAqE;AAErE;;GAEG;AACH,MAAa,yBAA0B,SAAQ,iDAG9C;IACC;;OAEG;IACH,YAAmB,EAAE,aAAa,EAAwD;QACxF,KAAK,CAAC,oBAAY,CAAC,kBAAkB,CAAC,aAAa,EAAE,aAAa,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IAC9F,CAAC;IAED;;;;;;;;;OASG;IACa,aAAa,CAC3B,SAAoC,EACpC,OAA2B,EAC3B,gBAAwB,EACxB,eAA4C,EAC5C,YAAoB;;YAEpB,IAAI,CAAC,OAAO,EAAE;gBACZ,OAAO;oBACL,aAAa,EAAE,EAAE;iBAClB,CAAC;aACH;YAED,MAAM,aAAa,GAAG,IAAI,8CAAuB,CAC/C,gBAAgB,EAChB,eAAe,CAAC,KAAK,EACrB,OAAO,EACP,SAAS,EACT,YAAY,CACb,CAAC;YACF,MAAM,aAAa,GAAG,MAAM,aAAa,CAAC,iBAAiB,EAAE,CAAC;YAC9D,OAAO;gBACL,aAAa;aACd,CAAC;QACJ,CAAC;KAAA;CACF;AA9CD,8DA8CC"}
1
+ {"version":3,"file":"superfluid-detector.js","sourceRoot":"","sources":["../../src/erc777/superfluid-detector.ts"],"names":[],"mappings":";;;;AAAA,iDAK+B;AAC/B,iEAAiE;AACjE,0EAAqE;AACrE,kFAAyE;AACzE,mCAAmC;AACnC;;GAEG;AACH,MAAa,yBAA0B,SAAQ,iDAG9C;IACC;;OAEG;IACH,YAAmB,EAAE,aAAa,EAAwD;QACxF,KAAK,CAAC,oBAAY,CAAC,kBAAkB,CAAC,aAAa,EAAE,aAAa,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IAC9F,CAAC;IAES,mBAAmB,CAAC,OAAmC;QAC/D,OAAO,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,MAAM,CAAC,iBAAiB,CAAC;IAC9E,CAAC;IAED;;;OAGG;IACO,mBAAmB,CAC3B,OAAmC;QAEnC,OAAO,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,MAAM,CAAC;IAC1D,CAAC;IAED;;;;;;;;;OASG;IACU,UAAU,CACrB,OAAmC;;;;;YAMnC,MAAM,YAAY,GAAG,MAAM,OAAM,UAAU,YAAC,OAAO,CAAC,CAAC;YACrD,IAAI,YAAY,CAAC,KAAK,EAAE;gBACtB,OAAO,YAAY,CAAC;aACrB;YACD,IAAI,YAAY,CAAC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,CAAC;QACJ,CAAC;KAAA;IAED;;;;;;;;OAQG;IACO,mBAAmB,CAAC,OAAmC;QAC/D,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC;QAC1E,IAAI,CAAC,sBAAsB,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;QAC9D,IAAI,CAAC,sBAAsB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAC1C,MAAM,SAAS,GAAG,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC;YACjD,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,iBAAiB;YACrD,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC;QACtB,OAAO,sCAA0B,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;IAC/E,CAAC;CACF;AAvHD,8DAuHC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@requestnetwork/payment-detection",
3
- "version": "0.35.1-next.1755+bf4bd898",
3
+ "version": "0.35.1-next.1759+79bb1cef",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -41,10 +41,10 @@
41
41
  "codegen": "graphql-codegen --config codegen.yml ; graphql-codegen --config codegen-superfluid.yml; graphql-codegen --config codegen-near.yml"
42
42
  },
43
43
  "dependencies": {
44
- "@requestnetwork/currency": "0.8.1-next.1755+bf4bd898",
45
- "@requestnetwork/smart-contracts": "0.28.1-next.1755+bf4bd898",
46
- "@requestnetwork/types": "0.35.1-next.1755+bf4bd898",
47
- "@requestnetwork/utils": "0.35.1-next.1755+bf4bd898",
44
+ "@requestnetwork/currency": "0.8.1-next.1759+79bb1cef",
45
+ "@requestnetwork/smart-contracts": "0.28.1-next.1759+79bb1cef",
46
+ "@requestnetwork/types": "0.35.1-next.1759+79bb1cef",
47
+ "@requestnetwork/utils": "0.35.1-next.1759+79bb1cef",
48
48
  "axios": "0.27.2",
49
49
  "ethers": "5.5.1",
50
50
  "graphql": "15.5.1",
@@ -60,7 +60,7 @@
60
60
  "@graphql-codegen/typescript-graphql-request": "3.2.1",
61
61
  "@graphql-codegen/typescript-operations": "1.18.0",
62
62
  "@graphql-codegen/typescript-resolvers": "1.19.2",
63
- "@requestnetwork/advanced-logic": "0.34.1-next.1755+bf4bd898",
63
+ "@requestnetwork/advanced-logic": "0.34.1-next.1759+79bb1cef",
64
64
  "@types/jest": "26.0.13",
65
65
  "jest": "26.4.2",
66
66
  "nyc": "15.1.0",
@@ -71,5 +71,5 @@
71
71
  "ts-node": "9.0.0",
72
72
  "typescript": "4.4.4"
73
73
  },
74
- "gitHead": "bf4bd8980b01a17c685d163d71901eceac08f6bb"
74
+ "gitHead": "79bb1cef693223dbd3a4bb13a13ee7c39ffa5938"
75
75
  }