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.3 to 0.0.4

43

dist/cadence/create_list.js
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createListingScript = void 0;
const fcl = __importStar(require("@onflow/fcl"));
exports.createListingScript = fcl.transaction `
exports.createListingScript = `
import FungibleToken from 0xFUNGIBLE_TOKEN_ADDRESS

@@ -38,3 +14,3 @@ import NFTStorefront from 0xNFT_STOREFRONT

let NFTProvider: Capability<&{NonFungibleToken.Provider, NonFungibleToken.CollectionPublic}>
let NFTProvider: Capability<&0xsupportedNFTName.Collection{NonFungibleToken.Provider, NonFungibleToken.CollectionPublic}>

@@ -46,7 +22,12 @@ let tokenReceiver: Capability<&{FungibleToken.Receiver}>

// borrow Storefront resource
self.storefront = acct.borrow<&NFTStorefront.Storefront>(from: NFTStorefront.StorefrontStoragePath) ?? panic("can't borrow storefront")
self.storefront = acct.borrow<&NFTStorefront.Storefront>(from: NFTStorefront.StorefrontPublicPath) ?? panic("can't borrow storefront")
self.NFTProvider = acct.getCapability<&{NonFungibleToken.Provider, NonFungibleToken.CollectionPublic}>(MatrixMarketplaceNFT.CollectionPublicPath)!
assert(self.NFTProvider.borrow() != nil, message: "Missing or mis-typed MatrixMarketplaceNFT.Collection provider")
// to access 0xsupportedNFTName
if acct.getCapability<&0xsupportedNFTName.Collection{NonFungibleToken.Provider, NonFungibleToken.CollectionPublic}>(0xsupportedNFTName.CollectionPublicPath).check() == false {
acct.link<&0xsupportedNFTName.Collection{NonFungibleToken.Provider, NonFungibleToken.CollectionPublic}>(0xsupportedNFTName.CollectionPublicPath, target: 0xsupportedNFTName.CollectionStoragePath)
}
self.NFTProvider = acct.getCapability<&0xsupportedNFTName.Collection{NonFungibleToken.Provider, NonFungibleToken.CollectionPublic}>(0xsupportedNFTName.CollectionPublicPath)!
assert(self.NFTProvider.borrow() != nil, message: "Missing or mis-typed 0xsupportedNFTName.Collection provider")
// receiver flowtoken after NFT sold

@@ -68,4 +49,4 @@ self.tokenReceiver = acct.getCapability<&{FungibleToken.Receiver}>(/public/flowTokenReceiver)!

saleCuts.append(NFTStorefront.SaleCut(
receiver: getAccount(royaltyReceivers[size-1]).getCapability<&{FungibleToken.Receiver}>(/public/flowTokenReceiver)!,
amount: royaltyMount[size-1]
receiver: royaltyReceivers[size],
amount: royaltyMount[size]
))

@@ -72,0 +53,0 @@ size = size - 1

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.purchaseListingScript = void 0;
const fcl = __importStar(require("@onflow/fcl"));
exports.purchaseListingScript = fcl.transaction `
exports.purchaseListingScript = `
import FungibleToken from 0xFUNGIBLE_TOKEN_ADDRESS

@@ -30,0 +6,0 @@ import NFTStorefront from 0xNFT_STOREFRONT

import { FlowEnv } from "./env";
export interface IBindConfigs {
fungibleTokenAddress?: string;
fusdAddress?: string;
flowTokenAddress?: string;
nftStorefront?: string;
nonFungibleTokenAddress?: string;
}
export interface IStorefrontClient {
bindFcl(fcl: any, env: FlowEnv): Promise<void>;
bindFcl(fcl: any, env: FlowEnv, config?: IBindConfigs): Promise<void>;
setupFcl(key: string, value: string): Promise<void>;
checkStorefront(address: string): Promise<boolean>;

@@ -5,0 +13,0 @@ initStorefront(): Promise<string>;

@@ -1,2 +0,2 @@

import { IStorefrontClient } from "./IStorefrontClient";
import { IBindConfigs, IStorefrontClient } from "./IStorefrontClient";
import { FlowEnv } from "./env";

@@ -6,5 +6,4 @@ export declare class StorefrontClient implements IStorefrontClient {

private env;
bindFcl(fcl: any, env: FlowEnv): Promise<void>;
private setupFcl;
private setupScript;
bindFcl(fcl: any, env: FlowEnv, config?: IBindConfigs): Promise<void>;
setupFcl(key: string, value: string): Promise<void>;
checkStorefront(address: string): Promise<boolean>;

@@ -11,0 +10,0 @@ initStorefront(): Promise<string>;

@@ -29,4 +29,4 @@ "use strict";

const init_storefront_1 = require("../cadence/init_storefront");
const create_list_test_1 = require("../cadence/create_list_test");
const purchase_list_test_1 = require("../cadence/purchase_list_test");
const create_list_1 = require("../cadence/create_list");
const purchase_list_1 = require("../cadence/purchase_list");
const remove_list_1 = require("../cadence/remove_list");

@@ -37,3 +37,3 @@ const env_1 = require("./env");

class StorefrontClient {
async bindFcl(fcl, env) {
async bindFcl(fcl, env, config) {
this.env = env;

@@ -47,7 +47,7 @@ this.fcl = fcl;

.put("challenge.handshake", "https://flow-wallet-testnet.blocto.app/authn")
.put("0xFUNGIBLE_TOKEN_ADDRESS", "0x9a0766d93b6608b7")
.put("0xFUSD_ADDRESS", "0xe223d8a629e49c68")
.put("0xFLOW_TOKEN_ADDRESS", "0x7e60df042a9c0868")
.put("0xNFT_STOREFRONT", "0xa56c5e5fd9b9ca22")
.put("0xNON_FUNGIBLE_TOKEN_ADDRESS", "0x631e88ae7f1d7c20");
.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;

@@ -60,7 +60,7 @@ }

.put("challenge.handshake", "https://flow-wallet.blocto.app/authn")
.put("0xFUNGIBLE_TOKEN_ADDRESS", "0xf233dcee88fe0abe")
.put("0xFUSD_ADDRESS", "0x3c5959b568896393")
.put("0xFLOW_TOKEN_ADDRESS", "0x1654653399040a61")
.put("0xNFT_STOREFRONT", "")
.put("0xNON_FUNGIBLE_TOKEN_ADDRESS", "0x1d7e57aa55817448");
.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;

@@ -74,8 +74,7 @@ }

.put("discovery.wallet", "http://localhost:8701/fcl/authn")
.put("0xFUNGIBLE_TOKEN_ADDRESS", "0xee82856bf20e2aa6")
.put("0xFUSD_ADDRESS", "0xf8d6e0586b0a20c7")
.put("0xFLOW_TOKEN_ADDRESS", "0x0ae53cb6e3f42a79")
.put("0xNFT_STOREFRONT", "0xf8d6e0586b0a20c7")
.put("0xNFT_ADDRESS", "0xf8d6e0586b0a20c7")
.put("0xNON_FUNGIBLE_TOKEN_ADDRESS", "0xf8d6e0586b0a20c7");
.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");
}

@@ -105,14 +104,2 @@ }

}
async setupScript(script, contractName, contractAddress) {
switch (this.env) {
case env_1.FlowEnv.flowTestnet: {
script
.replace("0xFUNGIBLE_TOKEN_ADDRESS", "0x9a0766d93b6608b7")
.replace("0xNFT_STOREFRONT", "0xa56c5e5fd9b9ca22")
.replace("0xNON_FUNGIBLE_TOKEN_ADDRESS", "0x1d7e57aa55817448")
.replace("0xsupportedNFTAddress", contractAddress)
.replace("0xsupportedNFTName", contractName);
}
}
}
async checkStorefront(address) {

@@ -154,6 +141,5 @@ try {

try {
await this.setupFcl("0xsupportedNFTName", supportedNFTName);
await this.setupFcl("0xsupportedNFTAddress", supportedNFTAddress);
const response = await this.fcl.send([
this.fcl.transaction(create_list_test_1.createListingScriptTest.replace("0xsupportedNFTName", supportedNFTName)),
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)]),

@@ -165,3 +151,7 @@ this.fcl.proposer(this.fcl.currentUser().authorization),

]);
return response;
const ret = await this.fcl.tx(response).onceSealed();
if (ret.errorMessage !== "" && ret.status != 4) {
return Promise.reject(ret.errorMessage);
}
return response.transactionId;
}

@@ -175,6 +165,5 @@ catch (error) {

try {
await this.setupFcl("0xsupportedNFTName", supportedNFTName);
await this.setupFcl("0xsupportedNFTAddress", supportedNFTAddress);
const response = await this.fcl.send([
purchase_list_test_1.purchaseListingScriptTest,
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)]),

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

{
"name": "@matrix-labs/matrix-storefront-sdk",
"version": "0.0.3",
"version": "0.0.4",
"main": "./dist/index.js",

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

@@ -13,7 +13,22 @@ ### Install

* @param env: import FlowEnv from "@matrix-labs/matrix-marketplace-nft-sdk"
* @param config: optional
export interface IBindConfigs {
fungibleTokenAddress?:string;
fusdAddress?:string;
flowTokenAddress?:string;
nftStorefront?:string;
nonFungibleTokenAddress?:string;
}
* @example import * as fcl from "@onflow/fcl"; const client = new MatrixMarketplaceNFTClient(); client.bindFcl(fcl, FlowEnv.flowTestnet);
*/
bindFcl(fcl: any, env: FlowEnv): Promise<void>;
bindFcl(fcl: any, env: FlowEnv, config?: IBindConfigs): Promise<void>;
/**
* setup for fcl
* @async
* @param key: fcl config, keyword must start with '0x'
*/
setupFcl(key: string, value: string): Promise<void>;
/**
* before createList or removeList

@@ -20,0 +35,0 @@ * @async

import {FlowEnv} from "./env";
export interface IBindConfigs {
fungibleTokenAddress?:string;
fusdAddress?:string;
flowTokenAddress?:string;
nftStorefront?:string;
nonFungibleTokenAddress?:string;
}
export interface IStorefrontClient {
bindFcl(fcl: any, env: FlowEnv): Promise<void>;
bindFcl(fcl: any, env: FlowEnv, config?: IBindConfigs): Promise<void>;
setupFcl(key: string, value: string): Promise<void>;
checkStorefront(address: string): Promise<boolean>;

@@ -7,0 +15,0 @@ initStorefront(): Promise<string>;

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

import {removeListingScript} from "../cadence/remove_list";
import {IStorefrontClient} from "./IStorefrontClient";
import {IBindConfigs, IStorefrontClient} from "./IStorefrontClient";
import {FlowEnv} from "./env";

@@ -17,3 +17,3 @@ import {getListingIdsScript} from "../cadence/get_listing_ids";

public async bindFcl(fcl: any, env: FlowEnv): Promise<void> {
public async bindFcl(fcl: any, env: FlowEnv, config?: IBindConfigs): Promise<void> {
this.env = env;

@@ -27,7 +27,7 @@ this.fcl = fcl;

.put("challenge.handshake", "https://flow-wallet-testnet.blocto.app/authn") // use Blocto testnet wallet
.put("0xFUNGIBLE_TOKEN_ADDRESS", "0x9a0766d93b6608b7")
.put("0xFUSD_ADDRESS", "0xe223d8a629e49c68")
.put("0xFLOW_TOKEN_ADDRESS", "0x7e60df042a9c0868")
.put("0xNFT_STOREFRONT", "0xa56c5e5fd9b9ca22")
.put("0xNON_FUNGIBLE_TOKEN_ADDRESS", "0x631e88ae7f1d7c20");
.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;

@@ -40,7 +40,7 @@ }

.put("challenge.handshake", "https://flow-wallet.blocto.app/authn") // use Blocto wallet
.put("0xFUNGIBLE_TOKEN_ADDRESS", "0xf233dcee88fe0abe")
.put("0xFUSD_ADDRESS", "0x3c5959b568896393")
.put("0xFLOW_TOKEN_ADDRESS", "0x1654653399040a61")
.put("0xNFT_STOREFRONT", "")
.put("0xNON_FUNGIBLE_TOKEN_ADDRESS", "0x1d7e57aa55817448");
.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;

@@ -54,8 +54,7 @@ }

.put("discovery.wallet", "http://localhost:8701/fcl/authn")
.put("0xFUNGIBLE_TOKEN_ADDRESS", "0xee82856bf20e2aa6")
.put("0xFUSD_ADDRESS", "0xf8d6e0586b0a20c7")
.put("0xFLOW_TOKEN_ADDRESS", "0x0ae53cb6e3f42a79")
.put("0xNFT_STOREFRONT", "0xf8d6e0586b0a20c7")
.put("0xNFT_ADDRESS", "0xf8d6e0586b0a20c7")
.put("0xNON_FUNGIBLE_TOKEN_ADDRESS", "0xf8d6e0586b0a20c7");
.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");
}

@@ -71,3 +70,3 @@ }

*/
private async setupFcl(key: string, value: string): Promise<void> {
public async setupFcl(key: string, value: string): Promise<void> {
switch (this.env) {

@@ -131,3 +130,2 @@ case FlowEnv.flowTestnet: {

try {
await this.setupFcl("0xsupportedNFTName", supportedNFTName);
await this.setupFcl("0xsupportedNFTAddress", supportedNFTAddress);

@@ -155,3 +153,2 @@ const response = await this.fcl.send([

try {
await this.setupFcl("0xsupportedNFTName", supportedNFTName);
await this.setupFcl("0xsupportedNFTAddress", supportedNFTAddress);

@@ -158,0 +155,0 @@ const response = await this.fcl.send([

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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