@soundsright/chain
Version:
soundsright contracts
63 lines (62 loc) • 3.45 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const contracts_1 = require("@soundsright/contracts");
class NFT {
constructor(chain) {
this.chain = chain;
}
buyAndMint(address, tokenId, to, tokenURI, skuInfo, v, r, s, overrides) {
return __awaiter(this, void 0, void 0, function* () {
const contract = this.chain.getContract(address, contracts_1.ERC721Lyrra);
yield this.chain.tryTransaction(contract.payMintAndTransfer(tokenId, to, tokenURI, skuInfo, v, r, s, Object.assign({ gasLimit: 600000 }, overrides)));
});
}
ownerOf(address, tokenId) {
return __awaiter(this, void 0, void 0, function* () {
const contract = this.chain.getContract(address, contracts_1.ERC721Lyrra);
const account = yield this.chain.tryGet(contract.ownerOf(tokenId));
return account;
});
}
approveForAll(address, account, operator) {
return __awaiter(this, void 0, void 0, function* () {
const contract = this.chain.getContract(address, contracts_1.ERC721Lyrra);
const approved = yield this.chain.tryGet(contract.isApprovedForAll(account, operator));
if (approved)
return;
yield this.chain.tryTransaction(contract.setApprovalForAll(operator, true));
});
}
tokenURI(address, tokenId) {
return __awaiter(this, void 0, void 0, function* () {
const contract = this.chain.getContract(address, contracts_1.ERC721Lyrra);
const uri = yield this.chain.tryGet(contract.tokenURI(tokenId));
return uri;
});
}
createArtist(factoryAddress, params, overrides) {
return __awaiter(this, void 0, void 0, function* () {
const contract = this.chain.getContract(factoryAddress, contracts_1.ArtistFactory);
const { signature, name, symbol, contractURI, defaultSigner, platformSigner, platformFeeRecipient, platformFeeValue, fansFeeRecipient, fansFeeValue, } = params;
console.log('执行参数', params);
return this.chain.tryTransaction(contract.createArtist(signature, name, symbol, contractURI, defaultSigner, platformSigner, platformFeeRecipient, platformFeeValue, fansFeeRecipient, fansFeeValue, Object.assign({ gasLimit: 1000000 }, overrides)));
});
}
contractOwner(address) {
return __awaiter(this, void 0, void 0, function* () {
const contract = this.chain.getContract(address, contracts_1.ERC721Lyrra);
const account = yield this.chain.tryGet(contract.owner());
return account;
});
}
}
exports.default = NFT;