crypto-ducatus-wallet-core
Version:
A multi-currency support library for address derivation, private key creation, and transaction creation
61 lines • 2.62 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var web3_1 = __importDefault(require("web3"));
var abi_1 = require("./abi");
var ducx_1 = require("../ducx");
var ERC721TxProvider = (function (_super) {
__extends(ERC721TxProvider, _super);
function ERC721TxProvider() {
return _super !== null && _super.apply(this, arguments) || this;
}
ERC721TxProvider.prototype.getERC721Contract = function (tokenContractAddress) {
var web3 = new web3_1.default();
var contract = new web3.eth.Contract(abi_1.ERC721Abi, tokenContractAddress);
return contract;
};
ERC721TxProvider.prototype.create = function (params) {
var tokenAddress = params.tokenAddress;
var data = this.encodeData(params);
var recipients = [{ address: tokenAddress, amount: '0' }];
var newParams = __assign({}, params, { recipients: recipients, data: data });
return _super.prototype.create.call(this, newParams);
};
ERC721TxProvider.prototype.encodeData = function (params) {
var address = params.recipients[0].address;
var tokenAddress = params.tokenAddress, from = params.from, tokenId = params.tokenId;
var data = this.getERC721Contract(tokenAddress)
.methods.transferFrom(from, address, tokenId)
.encodeABI();
return data;
};
return ERC721TxProvider;
}(ducx_1.DUCXTxProvider));
exports.ERC721TxProvider = ERC721TxProvider;
//# sourceMappingURL=index.js.map