UNPKG

@soundsright/sdk

Version:

soundsright chain sdk

61 lines (60 loc) 3.11 kB
"use strict"; 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()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.NftManager = void 0; const ethers_1 = require("ethers"); const base_1 = __importDefault(require("./base")); class NftManager extends base_1.default { createArtist(options) { return __awaiter(this, void 0, void 0, function* () { // 1、调用api,获取合约执行参数,包括签名和其他参数 // 2、执行合约并获取事件中的新合约地址 // 3、将name、symbol、contractURI、合约地址等信息入库 // 先调用 api 获取签名及其他信息 const apiData = { signature: '', name: options.name, symbol: options.symbol, contractURI: options.contractURI, defaultSigner: '0x8BDE9585E2587ca912B05F6A23e929FcE2E1E94b', platformSigner: '0x00000adbED0F0b5A1fbc18a7A4639464C8889628', platformFeeRecipient: '0x2C68316826EBE47cF5131dF5B0a477fb2df52F95', platformFeeValue: '500', fansFeeRecipient: '0x297b47b873520A35224B3c029e36AcC23d19Aa42', fansFeeValue: '1000', }; const domain = { chainId: this.chain.chainId, }; const types = { Deployer: [ { name: 'wallet', type: 'address' }, ], }; const value = { wallet: this.chain.account, }; const eventHash = ethers_1.utils.id('CreatedArtist(uint256,string,string,address)'); console.log('eventHash', eventHash); // 0x23748b43b77f98380e738976c6324996908ffc1989994dd3c68631c87a65a7c0 apiData.signature = yield this.chain.signTypedMessage(domain, types, value); const res = yield this.chain.nft.createArtist(options.factoryAddress, apiData); const event = res.events.find((e) => e.event === 'CreatedArtist'); console.log(event); const address = event.args[3]; console.log('部署后的地址', address); return address; }); } } exports.NftManager = NftManager;