@super-protocol/sdk-js 0.8.0-beta.8 → 0.8.0-beta.9
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,5 +1,5 @@
|
|
|
1
1
|
import { Transaction } from "web3-core";
|
|
2
|
-
import { TransactionOptions } from "../types/Web3";
|
|
2
|
+
import { TransactionOptions, BlockInfo } from "../types/Web3";
|
|
3
3
|
declare class SuperproToken {
|
|
4
4
|
static address: string;
|
|
5
5
|
private static contract;
|
|
@@ -30,5 +30,9 @@ declare class SuperproToken {
|
|
|
30
30
|
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
31
31
|
*/
|
|
32
32
|
static approve(address: string, amount: string, transactionOptions?: TransactionOptions): Promise<void>;
|
|
33
|
+
static onTokenApprove(callback: onTokenApproveCallback, owner?: string, spender?: string): () => void;
|
|
34
|
+
static onTokenTransfer(callback: onTokenTransferCallback, from?: string, to?: string): () => void;
|
|
33
35
|
}
|
|
36
|
+
export declare type onTokenApproveCallback = (owner: string, spender: string, value: string, block?: BlockInfo) => void;
|
|
37
|
+
export declare type onTokenTransferCallback = (from: string, to: string, value: string, block?: BlockInfo) => void;
|
|
34
38
|
export default SuperproToken;
|
|
@@ -138,6 +138,62 @@ var SuperproToken = /** @class */ (function () {
|
|
|
138
138
|
});
|
|
139
139
|
});
|
|
140
140
|
};
|
|
141
|
+
SuperproToken.onTokenApprove = function (callback, owner, spender) {
|
|
142
|
+
var _this = this;
|
|
143
|
+
var contract = this.checkInit();
|
|
144
|
+
var logger = this.logger.child({ method: "onTokenApprove" });
|
|
145
|
+
var subscription = contract.events
|
|
146
|
+
.Approval()
|
|
147
|
+
.on("data", function (event) { return __awaiter(_this, void 0, void 0, function () {
|
|
148
|
+
return __generator(this, function (_a) {
|
|
149
|
+
if (owner && event.returnValues.owner != owner) {
|
|
150
|
+
return [2 /*return*/];
|
|
151
|
+
}
|
|
152
|
+
if (spender && event.returnValues.spender != spender) {
|
|
153
|
+
return [2 /*return*/];
|
|
154
|
+
}
|
|
155
|
+
callback(event.returnValues.owner, event.returnValues.spender, event.returnValues.value, {
|
|
156
|
+
index: event.blockNumber,
|
|
157
|
+
hash: event.blockHash,
|
|
158
|
+
});
|
|
159
|
+
return [2 /*return*/];
|
|
160
|
+
});
|
|
161
|
+
}); })
|
|
162
|
+
.on("error", function (error, receipt) {
|
|
163
|
+
if (receipt)
|
|
164
|
+
return; // Used to avoid logging of transaction rejected
|
|
165
|
+
logger.warn(error);
|
|
166
|
+
});
|
|
167
|
+
return function () { return subscription.unsubscribe(); };
|
|
168
|
+
};
|
|
169
|
+
SuperproToken.onTokenTransfer = function (callback, from, to) {
|
|
170
|
+
var _this = this;
|
|
171
|
+
var contract = this.checkInit();
|
|
172
|
+
var logger = this.logger.child({ method: "onTokenTransfer" });
|
|
173
|
+
var subscription = contract.events
|
|
174
|
+
.Approval()
|
|
175
|
+
.on("data", function (event) { return __awaiter(_this, void 0, void 0, function () {
|
|
176
|
+
return __generator(this, function (_a) {
|
|
177
|
+
if (from && event.returnValues.from != from) {
|
|
178
|
+
return [2 /*return*/];
|
|
179
|
+
}
|
|
180
|
+
if (to && event.returnValues.to != to) {
|
|
181
|
+
return [2 /*return*/];
|
|
182
|
+
}
|
|
183
|
+
callback(event.returnValues.from, event.returnValues.to, event.returnValues.value, {
|
|
184
|
+
index: event.blockNumber,
|
|
185
|
+
hash: event.blockHash,
|
|
186
|
+
});
|
|
187
|
+
return [2 /*return*/];
|
|
188
|
+
});
|
|
189
|
+
}); })
|
|
190
|
+
.on("error", function (error, receipt) {
|
|
191
|
+
if (receipt)
|
|
192
|
+
return; // Used to avoid logging of transaction rejected
|
|
193
|
+
logger.warn(error);
|
|
194
|
+
});
|
|
195
|
+
return function () { return subscription.unsubscribe(); };
|
|
196
|
+
};
|
|
141
197
|
return SuperproToken;
|
|
142
198
|
}());
|
|
143
199
|
exports.default = SuperproToken;
|