@bosonprotocol/core-sdk
Advanced tools
Comparing version 1.2.1 to 1.3.0-alpha.0
@@ -5,2 +5,7 @@ import { RawSellerFromSubgraph } from "./types"; | ||
export declare function getSellerByOperator(subgraphUrl: string, operatorAddress: string): Promise<RawSellerFromSubgraph>; | ||
export declare const getSellerByAdminQuery: string; | ||
export declare function getSellerByAdmin(subgraphUrl: string, adminAddress: string): Promise<RawSellerFromSubgraph>; | ||
export declare const getSellerByClerkQuery: string; | ||
export declare function getSellerByClerk(subgraphUrl: string, clerkAddress: string): Promise<RawSellerFromSubgraph>; | ||
export declare function getSellerByAddress(subgraphUrl: string, address: string): Promise<RawSellerFromSubgraph>; | ||
//# sourceMappingURL=subgraph.d.ts.map |
@@ -12,3 +12,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getSellerByOperator = exports.getSellerByOperatorQuery = exports.sellerFieldsFragment = void 0; | ||
exports.getSellerByAddress = exports.getSellerByClerk = exports.getSellerByClerkQuery = exports.getSellerByAdmin = exports.getSellerByAdminQuery = exports.getSellerByOperator = exports.getSellerByOperatorQuery = exports.sellerFieldsFragment = void 0; | ||
const subgraph_1 = require("../utils/subgraph"); | ||
@@ -42,2 +42,47 @@ exports.sellerFieldsFragment = ` | ||
exports.getSellerByOperator = getSellerByOperator; | ||
exports.getSellerByAdminQuery = ` | ||
query GetSellersByAdmin($admin: String!) { | ||
sellers(where: { | ||
admin: $admin | ||
}) { | ||
...sellerFields | ||
} | ||
} | ||
${exports.sellerFieldsFragment} | ||
`; | ||
function getSellerByAdmin(subgraphUrl, adminAddress) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { sellers } = yield (0, subgraph_1.fetchSubgraph)(subgraphUrl, exports.getSellerByOperatorQuery, { admin: adminAddress }); | ||
return sellers[0]; | ||
}); | ||
} | ||
exports.getSellerByAdmin = getSellerByAdmin; | ||
exports.getSellerByClerkQuery = ` | ||
query GetSellersByOperator($clerk: String!) { | ||
sellers(where: { | ||
clerk: $clerk | ||
}) { | ||
...sellerFields | ||
} | ||
} | ||
${exports.sellerFieldsFragment} | ||
`; | ||
function getSellerByClerk(subgraphUrl, clerkAddress) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { sellers } = yield (0, subgraph_1.fetchSubgraph)(subgraphUrl, exports.getSellerByOperatorQuery, { clerk: clerkAddress }); | ||
return sellers[0]; | ||
}); | ||
} | ||
exports.getSellerByClerk = getSellerByClerk; | ||
function getSellerByAddress(subgraphUrl, address) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const [operator, admin, clerk] = yield Promise.all([ | ||
getSellerByOperator(subgraphUrl, address), | ||
getSellerByAdmin(subgraphUrl, address), | ||
getSellerByClerk(subgraphUrl, address) | ||
]); | ||
return operator || admin || clerk; | ||
}); | ||
} | ||
exports.getSellerByAddress = getSellerByAddress; | ||
//# sourceMappingURL=subgraph.js.map |
@@ -29,2 +29,3 @@ import { Web3LibAdapter, TransactionResponse, MetadataStorage, AnyMetadata, Log } from "@bosonprotocol/common"; | ||
getSellerByOperator(operator: string): Promise<accounts.RawSellerFromSubgraph>; | ||
getSellerByAddress(address: string): Promise<accounts.RawSellerFromSubgraph>; | ||
createSellerAndOffer(sellerToCreate: accounts.CreateSellerArgs, offerToCreate: offers.CreateOfferArgs, overrides?: Partial<{ | ||
@@ -31,0 +32,0 @@ contractAddress: string; |
@@ -85,2 +85,7 @@ "use strict"; | ||
} | ||
getSellerByAddress(address) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return accounts.subgraph.getSellerByAddress(this._subgraphUrl, address); | ||
}); | ||
} | ||
createSellerAndOffer(sellerToCreate, offerToCreate, overrides = {}) { | ||
@@ -87,0 +92,0 @@ return __awaiter(this, void 0, void 0, function* () { |
@@ -5,2 +5,7 @@ import { RawSellerFromSubgraph } from "./types"; | ||
export declare function getSellerByOperator(subgraphUrl: string, operatorAddress: string): Promise<RawSellerFromSubgraph>; | ||
export declare const getSellerByAdminQuery: string; | ||
export declare function getSellerByAdmin(subgraphUrl: string, adminAddress: string): Promise<RawSellerFromSubgraph>; | ||
export declare const getSellerByClerkQuery: string; | ||
export declare function getSellerByClerk(subgraphUrl: string, clerkAddress: string): Promise<RawSellerFromSubgraph>; | ||
export declare function getSellerByAddress(subgraphUrl: string, address: string): Promise<RawSellerFromSubgraph>; | ||
//# sourceMappingURL=subgraph.d.ts.map |
@@ -26,2 +26,38 @@ import { fetchSubgraph } from "../utils/subgraph"; | ||
} | ||
export const getSellerByAdminQuery = ` | ||
query GetSellersByAdmin($admin: String!) { | ||
sellers(where: { | ||
admin: $admin | ||
}) { | ||
...sellerFields | ||
} | ||
} | ||
${sellerFieldsFragment} | ||
`; | ||
export async function getSellerByAdmin(subgraphUrl, adminAddress) { | ||
const { sellers } = await fetchSubgraph(subgraphUrl, getSellerByOperatorQuery, { admin: adminAddress }); | ||
return sellers[0]; | ||
} | ||
export const getSellerByClerkQuery = ` | ||
query GetSellersByOperator($clerk: String!) { | ||
sellers(where: { | ||
clerk: $clerk | ||
}) { | ||
...sellerFields | ||
} | ||
} | ||
${sellerFieldsFragment} | ||
`; | ||
export async function getSellerByClerk(subgraphUrl, clerkAddress) { | ||
const { sellers } = await fetchSubgraph(subgraphUrl, getSellerByOperatorQuery, { clerk: clerkAddress }); | ||
return sellers[0]; | ||
} | ||
export async function getSellerByAddress(subgraphUrl, address) { | ||
const [operator, admin, clerk] = await Promise.all([ | ||
getSellerByOperator(subgraphUrl, address), | ||
getSellerByAdmin(subgraphUrl, address), | ||
getSellerByClerk(subgraphUrl, address) | ||
]); | ||
return operator || admin || clerk; | ||
} | ||
//# sourceMappingURL=subgraph.js.map |
@@ -29,2 +29,3 @@ import { Web3LibAdapter, TransactionResponse, MetadataStorage, AnyMetadata, Log } from "@bosonprotocol/common"; | ||
getSellerByOperator(operator: string): Promise<accounts.RawSellerFromSubgraph>; | ||
getSellerByAddress(address: string): Promise<accounts.RawSellerFromSubgraph>; | ||
createSellerAndOffer(sellerToCreate: accounts.CreateSellerArgs, offerToCreate: offers.CreateOfferArgs, overrides?: Partial<{ | ||
@@ -31,0 +32,0 @@ contractAddress: string; |
@@ -49,2 +49,5 @@ import { getDefaultConfig } from "@bosonprotocol/common"; | ||
} | ||
async getSellerByAddress(address) { | ||
return accounts.subgraph.getSellerByAddress(this._subgraphUrl, address); | ||
} | ||
async createSellerAndOffer(sellerToCreate, offerToCreate, overrides = {}) { | ||
@@ -51,0 +54,0 @@ return orchestration.handler.createOfferAndSeller({ |
{ | ||
"name": "@bosonprotocol/core-sdk", | ||
"version": "1.2.1", | ||
"version": "1.3.0-alpha.0", | ||
"description": "> TODO: description", | ||
@@ -49,3 +49,3 @@ "main": "./dist/cjs/index.js", | ||
}, | ||
"gitHead": "12fbc8b83540bcc3229c1069beb6f98956d70e8f" | ||
"gitHead": "226aa10cbe962316a70c20ec170b4695620f7165" | ||
} |
@@ -38,1 +38,62 @@ import { fetchSubgraph } from "../utils/subgraph"; | ||
} | ||
export const getSellerByAdminQuery = ` | ||
query GetSellersByAdmin($admin: String!) { | ||
sellers(where: { | ||
admin: $admin | ||
}) { | ||
...sellerFields | ||
} | ||
} | ||
${sellerFieldsFragment} | ||
`; | ||
export async function getSellerByAdmin( | ||
subgraphUrl: string, | ||
adminAddress: string | ||
): Promise<RawSellerFromSubgraph> { | ||
const { sellers } = await fetchSubgraph<{ sellers: RawSellerFromSubgraph }>( | ||
subgraphUrl, | ||
getSellerByOperatorQuery, | ||
{ admin: adminAddress } | ||
); | ||
return sellers[0]; | ||
} | ||
export const getSellerByClerkQuery = ` | ||
query GetSellersByOperator($clerk: String!) { | ||
sellers(where: { | ||
clerk: $clerk | ||
}) { | ||
...sellerFields | ||
} | ||
} | ||
${sellerFieldsFragment} | ||
`; | ||
export async function getSellerByClerk( | ||
subgraphUrl: string, | ||
clerkAddress: string | ||
): Promise<RawSellerFromSubgraph> { | ||
const { sellers } = await fetchSubgraph<{ sellers: RawSellerFromSubgraph }>( | ||
subgraphUrl, | ||
getSellerByOperatorQuery, | ||
{ clerk: clerkAddress } | ||
); | ||
return sellers[0]; | ||
} | ||
export async function getSellerByAddress( | ||
subgraphUrl: string, | ||
address: string | ||
): Promise<RawSellerFromSubgraph> { | ||
const [operator, admin, clerk] = await Promise.all([ | ||
getSellerByOperator(subgraphUrl, address), | ||
getSellerByAdmin(subgraphUrl, address), | ||
getSellerByClerk(subgraphUrl, address) | ||
]); | ||
return operator || admin || clerk; | ||
} |
@@ -83,2 +83,8 @@ import { | ||
public async getSellerByAddress( | ||
address: string | ||
): Promise<accounts.RawSellerFromSubgraph> { | ||
return accounts.subgraph.getSellerByAddress(this._subgraphUrl, address); | ||
} | ||
public async createSellerAndOffer( | ||
@@ -85,0 +91,0 @@ sellerToCreate: accounts.CreateSellerArgs, |
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
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
205146
3070
2