Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@matrix-labs/matrix-storefront-sdk

Package Overview
Dependencies
Maintainers
2
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@matrix-labs/matrix-storefront-sdk - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

345

dist/client/StorefrontClient.js

@@ -25,11 +25,2 @@ "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());
});
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -46,195 +37,179 @@ exports.StorefrontClient = void 0;

class StorefrontClient {
bindFcl(fcl, env, config) {
return __awaiter(this, void 0, void 0, function* () {
this.env = env;
this.fcl = fcl;
switch (env) {
case env_1.FlowEnv.flowTestnet: {
yield this.fcl
.config()
.put("accessNode.api", "https://access-testnet.onflow.org")
.put("challenge.handshake", "https://flow-wallet-testnet.blocto.app/authn")
.put("0xFUNGIBLE_TOKEN_ADDRESS", (config === null || config === void 0 ? void 0 : config.fungibleTokenAddress) || "0x9a0766d93b6608b7")
.put("0xFUSD_ADDRESS", (config === null || config === void 0 ? void 0 : config.fusdAddress) || "0xe223d8a629e49c68")
.put("0xFLOW_TOKEN_ADDRESS", (config === null || config === void 0 ? void 0 : config.flowTokenAddress) || "0x7e60df042a9c0868")
.put("0xNFT_STOREFRONT", (config === null || config === void 0 ? void 0 : config.nftStorefront) || "0xa56c5e5fd9b9ca22")
.put("0xNON_FUNGIBLE_TOKEN_ADDRESS", (config === null || config === void 0 ? void 0 : config.nonFungibleTokenAddress) || "0x631e88ae7f1d7c20");
break;
}
case env_1.FlowEnv.flowMainnet: {
yield this.fcl
.config()
.put("accessNode.api", "https://flow-access-mainnet.portto.io")
.put("challenge.handshake", "https://flow-wallet.blocto.app/authn")
.put("0xFUNGIBLE_TOKEN_ADDRESS", (config === null || config === void 0 ? void 0 : config.fungibleTokenAddress) || "0xf233dcee88fe0abe")
.put("0xFUSD_ADDRESS", (config === null || config === void 0 ? void 0 : config.fusdAddress) || "0x3c5959b568896393")
.put("0xFLOW_TOKEN_ADDRESS", (config === null || config === void 0 ? void 0 : config.flowTokenAddress) || "0x1654653399040a61")
.put("0xNFT_STOREFRONT", (config === null || config === void 0 ? void 0 : config.nftStorefront) || "")
.put("0xNON_FUNGIBLE_TOKEN_ADDRESS", (config === null || config === void 0 ? void 0 : config.nonFungibleTokenAddress) || "0x1d7e57aa55817448");
break;
}
case env_1.FlowEnv.localEmulator:
default:
yield this.fcl
.config()
.put("accessNode.api", "http://localhost:8080")
.put("discovery.wallet", "http://localhost:8701/fcl/authn")
.put("0xFUNGIBLE_TOKEN_ADDRESS", (config === null || config === void 0 ? void 0 : config.fungibleTokenAddress) || "0xee82856bf20e2aa6")
.put("0xFUSD_ADDRESS", (config === null || config === void 0 ? void 0 : config.fusdAddress) || "0xf8d6e0586b0a20c7")
.put("0xFLOW_TOKEN_ADDRESS", (config === null || config === void 0 ? void 0 : config.flowTokenAddress) || "0x0ae53cb6e3f42a79")
.put("0xNFT_STOREFRONT", (config === null || config === void 0 ? void 0 : config.nftStorefront) || "0xf8d6e0586b0a20c7")
.put("0xNON_FUNGIBLE_TOKEN_ADDRESS", (config === null || config === void 0 ? void 0 : config.nonFungibleTokenAddress) || "0xf8d6e0586b0a20c7");
async bindFcl(fcl, env, config) {
this.env = env;
this.fcl = fcl;
switch (env) {
case env_1.FlowEnv.flowTestnet: {
await this.fcl
.config()
.put("accessNode.api", "https://access-testnet.onflow.org")
.put("challenge.handshake", "https://flow-wallet-testnet.blocto.app/authn")
.put("0xFUNGIBLE_TOKEN_ADDRESS", config?.fungibleTokenAddress || "0x9a0766d93b6608b7")
.put("0xFUSD_ADDRESS", config?.fusdAddress || "0xe223d8a629e49c68")
.put("0xFLOW_TOKEN_ADDRESS", config?.flowTokenAddress || "0x7e60df042a9c0868")
.put("0xNFT_STOREFRONT", config?.nftStorefront || "0xa56c5e5fd9b9ca22")
.put("0xNON_FUNGIBLE_TOKEN_ADDRESS", config?.nonFungibleTokenAddress || "0x631e88ae7f1d7c20");
break;
}
});
}
setupFcl(key, value) {
return __awaiter(this, void 0, void 0, function* () {
switch (this.env) {
case env_1.FlowEnv.flowTestnet: {
yield this.fcl
.config()
.put(key, value);
break;
}
case env_1.FlowEnv.flowTestnet: {
yield this.fcl
.config()
.put(key, value);
break;
}
case env_1.FlowEnv.flowTestnet: {
yield this.fcl
.config()
.put(key, value);
break;
}
case env_1.FlowEnv.flowMainnet: {
await this.fcl
.config()
.put("accessNode.api", "https://flow-access-mainnet.portto.io")
.put("challenge.handshake", "https://flow-wallet.blocto.app/authn")
.put("0xFUNGIBLE_TOKEN_ADDRESS", config?.fungibleTokenAddress || "0xf233dcee88fe0abe")
.put("0xFUSD_ADDRESS", config?.fusdAddress || "0x3c5959b568896393")
.put("0xFLOW_TOKEN_ADDRESS", config?.flowTokenAddress || "0x1654653399040a61")
.put("0xNFT_STOREFRONT", config?.nftStorefront || "")
.put("0xNON_FUNGIBLE_TOKEN_ADDRESS", config?.nonFungibleTokenAddress || "0x1d7e57aa55817448");
break;
}
});
case env_1.FlowEnv.localEmulator:
default:
await this.fcl
.config()
.put("accessNode.api", "http://localhost:8080")
.put("discovery.wallet", "http://localhost:8701/fcl/authn")
.put("0xFUNGIBLE_TOKEN_ADDRESS", config?.fungibleTokenAddress || "0xee82856bf20e2aa6")
.put("0xFUSD_ADDRESS", config?.fusdAddress || "0xf8d6e0586b0a20c7")
.put("0xFLOW_TOKEN_ADDRESS", config?.flowTokenAddress || "0x0ae53cb6e3f42a79")
.put("0xNFT_STOREFRONT", config?.nftStorefront || "0xf8d6e0586b0a20c7")
.put("0xNON_FUNGIBLE_TOKEN_ADDRESS", config?.nonFungibleTokenAddress || "0xf8d6e0586b0a20c7");
}
}
checkStorefront(address) {
return __awaiter(this, void 0, void 0, function* () {
try {
const response = yield this.fcl.send([
check_storefront_1.checkStorefront,
this.fcl.args([this.fcl.arg(address, t.Address)]),
this.fcl.limit(2000)
]);
return this.fcl.decode(response);
async setupFcl(key, value) {
switch (this.env) {
case env_1.FlowEnv.flowTestnet: {
await this.fcl
.config()
.put(key, value);
break;
}
catch (error) {
console.error(error);
return Promise.reject(error);
case env_1.FlowEnv.flowTestnet: {
await this.fcl
.config()
.put(key, value);
break;
}
});
}
initStorefront() {
return __awaiter(this, void 0, void 0, function* () {
try {
const response = yield this.fcl.send([
init_storefront_1.initStorefront,
this.fcl.proposer(this.fcl.currentUser().authorization),
this.fcl.authorizations([this.fcl.currentUser().authorization]),
this.fcl.limit(2000),
this.fcl.payer(this.fcl.currentUser().authorization)
]);
const ret = yield this.fcl.tx(response).onceSealed();
if (ret.errorMessage !== "" && ret.status != 4) {
return Promise.reject(ret.errorMessage);
}
return response.transactionId;
case env_1.FlowEnv.flowTestnet: {
await this.fcl
.config()
.put(key, value);
break;
}
catch (error) {
console.error(error);
return Promise.reject(error);
}
});
}
}
createList(supportedNFTName, supportedNFTAddress, royaltyReceivers, royaltyMount, nftId, price) {
return __awaiter(this, void 0, void 0, function* () {
try {
yield this.setupFcl("0xsupportedNFTAddress", supportedNFTAddress);
yield this.setupFcl("0xsupportedNFTName", supportedNFTName);
const response = yield this.fcl.send([
this.fcl.transaction(create_list_1.createListingScript.replace("0xsupportedNFTName", supportedNFTName)),
this.fcl.args([this.fcl.arg(royaltyReceivers, t.Array(t.Address)), this.fcl.arg(royaltyMount, t.Array(t.UFix64)), this.fcl.arg(nftId, t.UInt64), this.fcl.arg(price, t.UFix64)]),
this.fcl.proposer(this.fcl.currentUser().authorization),
this.fcl.authorizations([this.fcl.currentUser().authorization]),
this.fcl.limit(3000),
this.fcl.payer(this.fcl.currentUser().authorization)
]);
const ret = yield this.fcl.tx(response).onceSealed();
if (ret.errorMessage !== "" && ret.status != 4) {
return Promise.reject(ret.errorMessage);
}
return response.transactionId;
async checkStorefront(address) {
try {
const response = await this.fcl.send([
check_storefront_1.checkStorefront,
this.fcl.args([this.fcl.arg(address, t.Address)]),
this.fcl.limit(2000)
]);
return this.fcl.decode(response);
}
catch (error) {
console.error(error);
return Promise.reject(error);
}
}
async initStorefront() {
try {
const response = await this.fcl.send([
init_storefront_1.initStorefront,
this.fcl.proposer(this.fcl.currentUser().authorization),
this.fcl.authorizations([this.fcl.currentUser().authorization]),
this.fcl.limit(2000),
this.fcl.payer(this.fcl.currentUser().authorization)
]);
const ret = await this.fcl.tx(response).onceSealed();
if (ret.errorMessage !== "" && ret.status != 4) {
return Promise.reject(ret.errorMessage);
}
catch (error) {
console.error(error);
return Promise.reject(error);
}
});
return response.transactionId;
}
catch (error) {
console.error(error);
return Promise.reject(error);
}
}
purchaseList(supportedNFTName, supportedNFTAddress, listingResourceId, sellerAddress) {
return __awaiter(this, void 0, void 0, function* () {
try {
yield this.setupFcl("0xsupportedNFTAddress", supportedNFTAddress);
yield this.setupFcl("0xsupportedNFTName", supportedNFTName);
const response = yield this.fcl.send([
this.fcl.transaction(purchase_list_1.purchaseListingScript.replace("0xsupportedNFTName", supportedNFTName)),
this.fcl.args([this.fcl.arg(listingResourceId, t.UInt64), this.fcl.arg(sellerAddress, t.Address)]),
this.fcl.proposer(this.fcl.currentUser().authorization),
this.fcl.authorizations([this.fcl.currentUser().authorization]),
this.fcl.limit(2000),
this.fcl.payer(this.fcl.currentUser().authorization)
]);
const ret = yield this.fcl.tx(response).onceSealed();
if (ret.errorMessage !== "" && ret.status != 4) {
return Promise.reject(ret.errorMessage);
}
return response.transactionId;
async createList(supportedNFTName, supportedNFTAddress, royaltyReceivers, royaltyMount, nftId, price) {
try {
await this.setupFcl("0xsupportedNFTAddress", supportedNFTAddress);
await this.setupFcl("0xsupportedNFTName", supportedNFTName);
const response = await this.fcl.send([
this.fcl.transaction(create_list_1.createListingScript.replaceAll("0xsupportedNFTName", supportedNFTName)),
this.fcl.args([this.fcl.arg(royaltyReceivers, t.Array(t.Address)), this.fcl.arg(royaltyMount, t.Array(t.UFix64)), this.fcl.arg(nftId, t.UInt64), this.fcl.arg(price, t.UFix64)]),
this.fcl.proposer(this.fcl.currentUser().authorization),
this.fcl.authorizations([this.fcl.currentUser().authorization]),
this.fcl.limit(3000),
this.fcl.payer(this.fcl.currentUser().authorization)
]);
const ret = await this.fcl.tx(response).onceSealed();
if (ret.errorMessage !== "" && ret.status != 4) {
return Promise.reject(ret.errorMessage);
}
catch (error) {
console.error(error);
return Promise.reject(error);
}
});
return response.transactionId;
}
catch (error) {
console.error(error);
return Promise.reject(error);
}
}
removeList(listingResourceID) {
return __awaiter(this, void 0, void 0, function* () {
try {
const response = yield this.fcl.send([
remove_list_1.removeListingScript,
this.fcl.args([this.fcl.arg(listingResourceID, t.UInt64)]),
this.fcl.proposer(this.fcl.currentUser().authorization),
this.fcl.authorizations([this.fcl.currentUser().authorization]),
this.fcl.limit(2000),
this.fcl.payer(this.fcl.currentUser().authorization)
]);
const ret = yield this.fcl.tx(response).onceSealed();
if (ret.errorMessage !== "" && ret.status != 4) {
return Promise.reject(ret.errorMessage);
}
return response.transactionId;
async purchaseList(supportedNFTName, supportedNFTAddress, listingResourceId, sellerAddress) {
try {
await this.setupFcl("0xsupportedNFTAddress", supportedNFTAddress);
await this.setupFcl("0xsupportedNFTName", supportedNFTName);
const response = await this.fcl.send([
this.fcl.transaction(purchase_list_1.purchaseListingScript.replace("0xsupportedNFTName", supportedNFTName)),
this.fcl.args([this.fcl.arg(listingResourceId, t.UInt64), this.fcl.arg(sellerAddress, t.Address)]),
this.fcl.proposer(this.fcl.currentUser().authorization),
this.fcl.authorizations([this.fcl.currentUser().authorization]),
this.fcl.limit(2000),
this.fcl.payer(this.fcl.currentUser().authorization)
]);
const ret = await this.fcl.tx(response).onceSealed();
if (ret.errorMessage !== "" && ret.status != 4) {
return Promise.reject(ret.errorMessage);
}
catch (error) {
console.error(error);
return Promise.reject(error);
}
});
return response.transactionId;
}
catch (error) {
console.error(error);
return Promise.reject(error);
}
}
getListingIds(account) {
return __awaiter(this, void 0, void 0, function* () {
try {
const response = yield this.fcl.send([get_listing_ids_1.getListingIdsScript, this.fcl.args([this.fcl.arg(account, t.Address)])]);
console.log(response);
return this.fcl.decode(response);
async removeList(listingResourceID) {
try {
const response = await this.fcl.send([
remove_list_1.removeListingScript,
this.fcl.args([this.fcl.arg(listingResourceID, t.UInt64)]),
this.fcl.proposer(this.fcl.currentUser().authorization),
this.fcl.authorizations([this.fcl.currentUser().authorization]),
this.fcl.limit(2000),
this.fcl.payer(this.fcl.currentUser().authorization)
]);
const ret = await this.fcl.tx(response).onceSealed();
if (ret.errorMessage !== "" && ret.status != 4) {
return Promise.reject(ret.errorMessage);
}
catch (error) {
console.error(error);
return Promise.reject(error);
}
});
return response.transactionId;
}
catch (error) {
console.error(error);
return Promise.reject(error);
}
}
async getListingIds(account) {
try {
const response = await this.fcl.send([get_listing_ids_1.getListingIdsScript, this.fcl.args([this.fcl.arg(account, t.Address)])]);
console.log(response);
return this.fcl.decode(response);
}
catch (error) {
console.error(error);
return Promise.reject(error);
}
}
}
exports.StorefrontClient = StorefrontClient;
//# sourceMappingURL=StorefrontClient.js.map
{
"name": "@matrix-labs/matrix-storefront-sdk",
"version": "0.0.5",
"version": "0.0.6",
"main": "./dist/index.js",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -127,3 +127,3 @@ import * as t from "@onflow/types";

const response = await this.fcl.send([
this.fcl.transaction(createListingScript.replace("0xsupportedNFTName", supportedNFTName)),
this.fcl.transaction(createListingScript.replaceAll("0xsupportedNFTName", supportedNFTName)),
this.fcl.args([this.fcl.arg( royaltyReceivers, t.Array(t.Address)), this.fcl.arg(royaltyMount, t.Array(t.UFix64)), this.fcl.arg(nftId, t.UInt64), this.fcl.arg(price, t.UFix64)]),

@@ -130,0 +130,0 @@ this.fcl.proposer(this.fcl.currentUser().authorization),

@@ -5,3 +5,6 @@ {

"incremental": true,
"target": "ES6",
"target": "es2020",
"lib": [
"ES2021.String"
],
"module": "commonjs",

@@ -8,0 +11,0 @@ "declaration": true,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc