UNPKG

@nexex/cli

Version:
51 lines 2.36 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const Base_1 = require("../../Base"); const constants_1 = require("../../constants"); const WalletBase_1 = __importDefault(require("../../WalletBase")); class TokenApprove extends WalletBase_1.default { async run() { const { flags, args: { token } } = this.parse(TokenApprove); const api = await this.initApi(); const [walletAddr, [tokenAddr]] = [await this.readWalletAddr(), await this.tokenToAddr([token])]; const approve = (await this.dex.token.allowanceForGateway(tokenAddr, walletAddr)).gt(constants_1.TOKEN_ALLOWANCE_THRESHOLD); if (approve) { console.log('skip, already approved'); this.exit(1); } const wallet = await this.readWallet(); const tx = await this.dex.token.approveGateway(wallet.connect(api.eth), tokenAddr); await tx.wait(); console.log('Done'); } } TokenApprove.description = 'describe the command here'; TokenApprove.examples = [ `$ nexex-cli hello hello world from ./src/hello.ts! ` ]; TokenApprove.flags = { ...WalletBase_1.default.flags }; TokenApprove.args = [{ name: 'token' }]; __decorate([ Base_1.initDir, __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", Promise) ], TokenApprove.prototype, "run", null); exports.default = TokenApprove; //# sourceMappingURL=approve.js.map