UNPKG

glip-wallet-sdk

Version:

Guide for installation and usage of Glip's Web3 Wallet.\ Glip Wallet through its SDK provides a signer using which a user's transaction can be signed.\ It also contains a iframe based UI element which can be embedded into any webpage.\ The UI contains

68 lines (67 loc) 2.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.NFTMarketplaceUtils = void 0; class NFTMarketplaceUtils { constructor(iWin) { this.iWin = iWin; } fetchNFTs() { const that = this; return new Promise(function (resolve, reject) { that.fetchNFTCB = resolve; that.fetchNFTRejectCB = reject; that.iWin.postMessage({ call: 'fetchNFTs', params: {} }, '*'); }); } transferNFT(walletId, tokenId, amount) { const that = this; return new Promise(function (resolve, reject) { that.transferNFTCB = resolve; that.transferNFTRejectCB = reject; that.iWin.postMessage({ call: 'transferNFT', params: { walletId, tokenId, amount } }, '*'); }); } sellNFT(tokenId, amount, currencyId, currencyAmount) { const that = this; return new Promise(function (resolve, reject) { that.sellNFTCB = resolve; that.sellNFTRejectCB = reject; that.iWin.postMessage({ call: 'sellNFT', params: { tokenId, amount, currencyId, currencyAmount } }, '*'); }); } buyNFT(sellOrderId) { const that = this; return new Promise(function (resolve, reject) { that.buyNFTCB = resolve; that.buyNFTRejectCB = reject; that.iWin.postMessage({ call: 'buyNFT', params: { sellOrderId } }, '*'); }); } // handles messages from the iFrame handleMessage(event) { if (event.data.call === "fetchNFTs") { this.fetchNFTCB(event.data.retVal); } else if (event.data.call === "transferNFT") { this.transferNFTCB(event.data.retVal); } else if (event.data.call === "sellNFT") { this.sellNFTCB(event.data.retVal); } else if (event.data.call === "buyNFT") { this.buyNFTCB(event.data.retVal); } } } exports.NFTMarketplaceUtils = NFTMarketplaceUtils;