Skip to content
This repository has been archived by the owner on Jan 1, 2025. It is now read-only.

Commit

Permalink
Release for V2.0.1
Browse files Browse the repository at this point in the history
Merge pull request #19 from argoapp-live/dev
  • Loading branch information
rekpero authored Oct 6, 2022
2 parents 95f4869 + 45dbd77 commit d5928fd
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 12 deletions.
2 changes: 1 addition & 1 deletion build/subscription.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default class extends Deployed {
getStakedTokenAddress(): Promise<string>;
getDiscountSlabs(): Promise<any>;
getDataContract(): Promise<any>;
makeCharge(u: string, d: Array<SubscriptionParameters>): Promise<TxResponse>;
makeCharge(u: string, d: Array<SubscriptionParameters>, gp?: string): Promise<TxResponse>;
addTokens(d: Array<TokenData>): Promise<TxResponse>;
removeTokens(d: Array<string>): Promise<TxResponse>;
changeUsdPrecision(n: number): Promise<TxResponse>;
Expand Down
13 changes: 10 additions & 3 deletions build/subscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,16 +264,23 @@ class default_1 extends deployed_1.default {
return this.vendor.parseDiscountSlabs(slabs);
});
}
makeCharge(u, d) {
var _a, _b;
makeCharge(u, d, gp) {
var _a, _b, _c, _d;
return __awaiter(this, void 0, void 0, function* () {
const paramArray = [];
const paramValue = [];
for (let i = 0; i < d.length; i++) {
paramArray.push(d[i].param);
paramValue.push(this.vendor.convertToBN(d[i].value.toString()));
}
return yield ((_a = this.subscriptionPaymentContract) === null || _a === void 0 ? void 0 : _a.functions.chargeUser(u, paramArray, paramValue, ((_b = this.erc20Contract) === null || _b === void 0 ? void 0 : _b.address) || ''));
if (gp) {
return yield ((_a = this.subscriptionPaymentContract) === null || _a === void 0 ? void 0 : _a.functions.chargeUser(u, paramArray, paramValue, ((_b = this.erc20Contract) === null || _b === void 0 ? void 0 : _b.address) || '', {
gasPrice: this.vendor.convertToBN(gp),
}));
}
else {
return yield ((_c = this.subscriptionPaymentContract) === null || _c === void 0 ? void 0 : _c.functions.chargeUser(u, paramArray, paramValue, ((_d = this.erc20Contract) === null || _d === void 0 ? void 0 : _d.address) || ''));
}
});
}
addTokens(d) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@spheron/desub-js",
"version": "2.0.0",
"version": "2.0.1",
"description": "Typescript library for working with the decentralised subscription contracts in Spheron",
"main": "build/index.js",
"types": "build/index.d.ts",
Expand Down
28 changes: 21 additions & 7 deletions src/subscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,20 +384,34 @@ export default class extends Deployed {
* this method is used when we want to charge user for the subscrption he will be buying.
* @param u - address of user
* @param d - array of parameters and their values
* @param mf - max gas fee
* @param m - max priority fee
*/
async makeCharge(u: string, d: Array<SubscriptionParameters>): Promise<TxResponse> {
async makeCharge(u: string, d: Array<SubscriptionParameters>, gp?: string): Promise<TxResponse> {
const paramArray: Array<string> = []
const paramValue: Array<number> = []
for (let i = 0; i < d.length; i++) {
paramArray.push(d[i].param)
paramValue.push(this.vendor.convertToBN(d[i].value.toString()))
}
return await this.subscriptionPaymentContract?.functions.chargeUser(
u,
paramArray,
paramValue,
this.erc20Contract?.address || '',
)
if (gp) {
return await this.subscriptionPaymentContract?.functions.chargeUser(
u,
paramArray,
paramValue,
this.erc20Contract?.address || '',
{
gasPrice: this.vendor.convertToBN(gp),
},
)
} else {
return await this.subscriptionPaymentContract?.functions.chargeUser(
u,
paramArray,
paramValue,
this.erc20Contract?.address || '',
)
}
}
/**
* @remarks
Expand Down

0 comments on commit d5928fd

Please sign in to comment.