emblem-vault-sdk 1.8.2 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.js +82 -66
- package/dist/index.js +1 -1
- package/dist/utils.js +81 -65
- package/docs/bundle.js +82 -66
- package/package.json +1 -1
- package/src/utils.ts +91 -58
- package/types/utils.d.ts +9 -0
package/dist/bundle.js
CHANGED
|
@@ -711195,7 +711195,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
711195
711195
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
711196
711196
|
const bignumber_1 = require("@ethersproject/bignumber");
|
|
711197
711197
|
const utils_1 = require("./utils");
|
|
711198
|
-
const SDK_VERSION = '1.
|
|
711198
|
+
const SDK_VERSION = '1.9.0';
|
|
711199
711199
|
class EmblemVaultSDK {
|
|
711200
711200
|
constructor(apiKey, baseUrl) {
|
|
711201
711201
|
this.apiKey = apiKey;
|
|
@@ -711648,8 +711648,21 @@ const metadata_json_1 = __importDefault(require("./curated/metadata.json"));
|
|
|
711648
711648
|
const abi_json_1 = __importDefault(require("./abi/abi.json"));
|
|
711649
711649
|
const derive_1 = require("./derive");
|
|
711650
711650
|
exports.NFT_DATA = metadata_json_1.default;
|
|
711651
|
+
// PROJECTS_DATA is list of projects i.e. curated collection names
|
|
711652
|
+
// that are present in metadataJson file
|
|
711653
|
+
const PROJECTS_DATA = projectsFromMetadataJson();
|
|
711651
711654
|
const TORUS_CLIENT_ID = 'BOqGGv-Yx7Dp5RdvD9R3DgSC8jv66gQGwT3w22L7fj3Fg5WQ8AEUjJzyyEwD-qvq5eUQiVipyzOmRZTWBAxaoj0';
|
|
711652
711655
|
const TORUS_VERIFIER = 'tor-us-signer-vercel';
|
|
711656
|
+
function projectsFromMetadataJson() {
|
|
711657
|
+
let projects = [];
|
|
711658
|
+
for (var key in exports.NFT_DATA) {
|
|
711659
|
+
const projectName = exports.NFT_DATA[key]["projectName"];
|
|
711660
|
+
if (!projects.includes(projectName)) {
|
|
711661
|
+
projects.push();
|
|
711662
|
+
}
|
|
711663
|
+
}
|
|
711664
|
+
return projects;
|
|
711665
|
+
}
|
|
711653
711666
|
const pad = (num, size) => {
|
|
711654
711667
|
if (!num)
|
|
711655
711668
|
return null;
|
|
@@ -711834,6 +711847,15 @@ function generateImageTemplate(record) {
|
|
|
711834
711847
|
return template;
|
|
711835
711848
|
}
|
|
711836
711849
|
exports.generateImageTemplate = generateImageTemplate;
|
|
711850
|
+
/**
|
|
711851
|
+
* generateTemplate defines rules and utilitites for a given curated
|
|
711852
|
+
* collection. This is used by callers, like emblem.finance website
|
|
711853
|
+
* to display vaults belonging to a curated collection with appropriate
|
|
711854
|
+
* data and actions.
|
|
711855
|
+
*
|
|
711856
|
+
* @param record is a curated collection record as defined in
|
|
711857
|
+
* the Emblem database.
|
|
711858
|
+
*/
|
|
711837
711859
|
function generateTemplate(record) {
|
|
711838
711860
|
let addressChain = record.addressChain;
|
|
711839
711861
|
let attributes = generateAttributeTemplate(record);
|
|
@@ -711842,115 +711864,109 @@ function generateTemplate(record) {
|
|
|
711842
711864
|
let balanceQty = record.balanceQty;
|
|
711843
711865
|
let template = {
|
|
711844
711866
|
attributes,
|
|
711867
|
+
/**
|
|
711868
|
+
* allowed function is used by callers, like the Emblem website
|
|
711869
|
+
* to determine if a vault belonging to a curated collection
|
|
711870
|
+
* has assets matching that curated collection. A vault can't be
|
|
711871
|
+
* minted until it has at least one qualifying asset.
|
|
711872
|
+
* Currently, we run qualifying checks only on the first asset in the vault.
|
|
711873
|
+
*
|
|
711874
|
+
* @param {Array} data - data is a list of balance Value objects
|
|
711875
|
+
* (see Value's interface definition in emblemvault.io-v3)
|
|
711876
|
+
* @param {function} - msgCallback should be a function that takes a string message
|
|
711877
|
+
*/
|
|
711845
711878
|
allowed: (data, _this, msgCallback = null) => {
|
|
711846
711879
|
var _a;
|
|
711880
|
+
if (!data || data.length == 0) {
|
|
711881
|
+
return false;
|
|
711882
|
+
}
|
|
711847
711883
|
let allowed = false;
|
|
711884
|
+
let firstAsset = data[0];
|
|
711885
|
+
let assetName = firstAsset.name ? firstAsset.name : "";
|
|
711886
|
+
let message = null;
|
|
711848
711887
|
if (recordName == "Cursed Ordinal") {
|
|
711849
|
-
|
|
711888
|
+
if (data && data.length > 0) {
|
|
711889
|
+
let allowedCoin = firstAsset.content_type != "application/json" && firstAsset.coin == "cursedordinalsbtc";
|
|
711890
|
+
let pieces = assetName.split(' ');
|
|
711891
|
+
let allowedName = assetName.includes(recordName) && pieces.length === 3 && Number(pieces.reverse()[0]) < 0;
|
|
711892
|
+
allowed = allowedCoin && allowedName;
|
|
711893
|
+
}
|
|
711850
711894
|
}
|
|
711851
711895
|
else if (recordName == "BitcoinOrdinals") {
|
|
711852
711896
|
data = _this.filterNativeBalances({ balances: data }, _this);
|
|
711853
711897
|
allowed = data && data.length > 0 && data[0].coin == _this.collectionChain.toLowerCase();
|
|
711854
711898
|
}
|
|
711855
711899
|
else if (recordName == "Ethscription") {
|
|
711856
|
-
allowed =
|
|
711900
|
+
allowed = firstAsset.coin == recordName.toLowerCase();
|
|
711857
711901
|
}
|
|
711858
|
-
else if (
|
|
711859
|
-
|
|
711860
|
-
|
|
711861
|
-
|
|
711862
|
-
}
|
|
711863
|
-
else if (data && data.length > 0 && data[0].balance != balanceQty && msgCallback) {
|
|
711864
|
-
msgCallback ? msgCallback(`Load vault with exactly ${balanceQty} ${recordName}`) : null;
|
|
711865
|
-
allowed = false;
|
|
711902
|
+
else if (balanceQty && balanceQty > 0) { // $ORDI, $OXBT
|
|
711903
|
+
allowed = firstAsset.balance == balanceQty && assetName == `${balanceQty} ${recordName}`;
|
|
711904
|
+
if (!allowed) {
|
|
711905
|
+
message = `Load vault with exactly ${balanceQty} ${recordName}`;
|
|
711866
711906
|
}
|
|
711867
711907
|
}
|
|
711868
711908
|
else if (recordName == "Counterparty") {
|
|
711869
711909
|
let facts = [
|
|
711870
|
-
{
|
|
711910
|
+
{
|
|
711911
|
+
eval: record.nativeAssets.includes((_a = data[0]) === null || _a === void 0 ? void 0 : _a.coin),
|
|
711912
|
+
msg: `Vaults should only contain assets native to ${recordName}`
|
|
711913
|
+
},
|
|
711871
711914
|
{ eval: data.length == 1, msg: `Vaults should only contain a single item` },
|
|
711872
711915
|
// { eval: data[0].projectName && data[0].projectName == recordName, msg: `Vaults should only contain a single item` }
|
|
711873
711916
|
];
|
|
711874
711917
|
allowed = (0, exports.evaluateFacts)(allowed, facts, msgCallback);
|
|
711875
711918
|
}
|
|
711876
711919
|
else if (recordName == "Stamps") {
|
|
711877
|
-
|
|
711920
|
+
let allowedName = assetName.toLowerCase().includes("stamp");
|
|
711921
|
+
allowed = allowedName &&
|
|
711922
|
+
firstAsset.project &&
|
|
711923
|
+
record.nativeAssets.includes(firstAsset.coin) &&
|
|
711924
|
+
(recordName.toLowerCase() == firstAsset.project.toLowerCase() || firstAsset.project.toLowerCase() == "stampunks");
|
|
711878
711925
|
}
|
|
711879
711926
|
else if (recordName == "EmblemOpen") {
|
|
711880
|
-
allowed =
|
|
711927
|
+
allowed = true;
|
|
711881
711928
|
}
|
|
711882
711929
|
else if (recordName == "Bells") {
|
|
711883
|
-
allowed =
|
|
711930
|
+
allowed = assetName == "Bel" && firstAsset.balance > 0 && Number.isInteger(data[0].balance);
|
|
711884
711931
|
}
|
|
711885
711932
|
else if (recordName == "Namecoin") {
|
|
711886
|
-
allowed =
|
|
711933
|
+
allowed = record.nativeAssets.includes(data[0].coin);
|
|
711887
711934
|
}
|
|
711888
711935
|
else if (recordName == "Embels") {
|
|
711889
711936
|
allowed = _this.name.toLowerCase() == recordName.toLowerCase();
|
|
711890
|
-
if (allowed &&
|
|
711937
|
+
if (allowed && firstAsset.coin) {
|
|
711891
711938
|
allowed = _this.nativeAssets.includes(data[0].coin);
|
|
711892
711939
|
}
|
|
711893
711940
|
}
|
|
711894
711941
|
else if (recordName == "Bitcoin DeGods") {
|
|
711895
|
-
allowed =
|
|
711942
|
+
allowed = firstAsset.coin == "ordinalsbtc" && firstAsset.balance == 1 && firstAsset.project == "DeGods";
|
|
711943
|
+
}
|
|
711944
|
+
else if (PROJECTS_DATA.includes(recordName)) { // XCP
|
|
711945
|
+
allowed = !!exports.NFT_DATA[assetName];
|
|
711896
711946
|
}
|
|
711897
711947
|
else if (_this.vaultCollectionType && _this.vaultCollectionType == "protocol") {
|
|
711898
|
-
allowed =
|
|
711948
|
+
allowed = firstAsset.coin.toLowerCase() == _this.collectionChain.toLowerCase() && firstAsset.project && firstAsset.project == recordName;
|
|
711899
711949
|
}
|
|
711900
711950
|
else if (_this.vaultCollectionType && _this.vaultCollectionType == "collection") {
|
|
711901
|
-
allowed =
|
|
711951
|
+
allowed = firstAsset.coin.toLowerCase() == _this.collectionChain.toLowerCase() && firstAsset.project == recordName;
|
|
711902
711952
|
}
|
|
711903
711953
|
else { // XCP
|
|
711904
|
-
allowed =
|
|
711954
|
+
allowed = firstAsset.project == _this.name && firstAsset.balance == 1;
|
|
711955
|
+
}
|
|
711956
|
+
if (message && msgCallback) {
|
|
711957
|
+
msgCallback(message);
|
|
711905
711958
|
}
|
|
711906
711959
|
return allowed;
|
|
711907
711960
|
},
|
|
711961
|
+
/**
|
|
711962
|
+
* allowedName function is deprecated. It used to be called by callers like Emblem website
|
|
711963
|
+
* to determine if an asset with a given name was allowed in a vault.
|
|
711964
|
+
* This functionality is now part of the "allowed" function instead.
|
|
711965
|
+
*
|
|
711966
|
+
* @deprecated
|
|
711967
|
+
*/
|
|
711908
711968
|
allowedName: (asset, msgCallback = null) => {
|
|
711909
|
-
|
|
711910
|
-
if (recordName == "Cursed Ordinal") {
|
|
711911
|
-
let pieces = asset.split(' ');
|
|
711912
|
-
allowedName = asset.includes(recordName) && pieces.length === 3 && Number(pieces.reverse()[0]) < 0;
|
|
711913
|
-
}
|
|
711914
|
-
else if (recordName == "Ethscription") {
|
|
711915
|
-
if (asset) {
|
|
711916
|
-
allowedName = true;
|
|
711917
|
-
}
|
|
711918
|
-
}
|
|
711919
|
-
else if (recordName == "$OXBT" || recordName == "$ORDI") {
|
|
711920
|
-
if (asset == `${balanceQty} ${recordName}`) {
|
|
711921
|
-
allowedName = true;
|
|
711922
|
-
}
|
|
711923
|
-
else {
|
|
711924
|
-
msgCallback ? msgCallback("Incorrect Asset Or Qty In Vault") : null;
|
|
711925
|
-
allowedName = false;
|
|
711926
|
-
}
|
|
711927
|
-
}
|
|
711928
|
-
else if (recordName == "Counterparty") {
|
|
711929
|
-
allowedName = asset ? true : false;
|
|
711930
|
-
}
|
|
711931
|
-
else if (recordName == "Stamps") {
|
|
711932
|
-
allowedName = asset && asset.toLowerCase().includes("stamp") ? true : false;
|
|
711933
|
-
}
|
|
711934
|
-
else if (recordName == "EmblemOpen") {
|
|
711935
|
-
allowedName = asset ? true : false;
|
|
711936
|
-
}
|
|
711937
|
-
else if (recordName == "Bells") {
|
|
711938
|
-
allowedName = asset == "Bel" ? true : false;
|
|
711939
|
-
}
|
|
711940
|
-
else if (recordName == "Namecoin") {
|
|
711941
|
-
allowedName = asset ? true : false;
|
|
711942
|
-
}
|
|
711943
|
-
else if (recordName == "Embels") {
|
|
711944
|
-
allowedName = true;
|
|
711945
|
-
}
|
|
711946
|
-
else if (recordName == "BitcoinOrdinals" || recordName == "BitcoinPunks" || recordName == "filthyFiat" || recordName == "Megapunks" || recordName == "TwelveFold" || recordName == "Bitcoin DeGods" || recordName == "Bitcoin Frogs" || recordName == "Ordinal Maxi Biz" || recordName == "NodeMonkes" || recordName == "Bitmap" || recordName == "Ordinal Punks" || recordName == "Bitcoin Rocks" || recordName == "OnChainMonkey (OCM) Dimentions") {
|
|
711947
|
-
allowedName = true;
|
|
711948
|
-
}
|
|
711949
|
-
else { // XCP
|
|
711950
|
-
let curatedItemFound = exports.NFT_DATA[asset];
|
|
711951
|
-
allowedName = asset && curatedItemFound ? true : false;
|
|
711952
|
-
}
|
|
711953
|
-
return allowedName;
|
|
711969
|
+
return true;
|
|
711954
711970
|
},
|
|
711955
711971
|
allowedJump: (ownership_balances, _this) => {
|
|
711956
711972
|
let hasAnyBalance = ownership_balances && ownership_balances.status != "claimed";
|
package/dist/index.js
CHANGED
|
@@ -34,7 +34,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
35
|
const bignumber_1 = require("@ethersproject/bignumber");
|
|
36
36
|
const utils_1 = require("./utils");
|
|
37
|
-
const SDK_VERSION = '1.
|
|
37
|
+
const SDK_VERSION = '1.9.0';
|
|
38
38
|
class EmblemVaultSDK {
|
|
39
39
|
constructor(apiKey, baseUrl) {
|
|
40
40
|
this.apiKey = apiKey;
|
package/dist/utils.js
CHANGED
|
@@ -18,8 +18,21 @@ const metadata_json_1 = __importDefault(require("./curated/metadata.json"));
|
|
|
18
18
|
const abi_json_1 = __importDefault(require("./abi/abi.json"));
|
|
19
19
|
const derive_1 = require("./derive");
|
|
20
20
|
exports.NFT_DATA = metadata_json_1.default;
|
|
21
|
+
// PROJECTS_DATA is list of projects i.e. curated collection names
|
|
22
|
+
// that are present in metadataJson file
|
|
23
|
+
const PROJECTS_DATA = projectsFromMetadataJson();
|
|
21
24
|
const TORUS_CLIENT_ID = 'BOqGGv-Yx7Dp5RdvD9R3DgSC8jv66gQGwT3w22L7fj3Fg5WQ8AEUjJzyyEwD-qvq5eUQiVipyzOmRZTWBAxaoj0';
|
|
22
25
|
const TORUS_VERIFIER = 'tor-us-signer-vercel';
|
|
26
|
+
function projectsFromMetadataJson() {
|
|
27
|
+
let projects = [];
|
|
28
|
+
for (var key in exports.NFT_DATA) {
|
|
29
|
+
const projectName = exports.NFT_DATA[key]["projectName"];
|
|
30
|
+
if (!projects.includes(projectName)) {
|
|
31
|
+
projects.push();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return projects;
|
|
35
|
+
}
|
|
23
36
|
const pad = (num, size) => {
|
|
24
37
|
if (!num)
|
|
25
38
|
return null;
|
|
@@ -204,6 +217,15 @@ function generateImageTemplate(record) {
|
|
|
204
217
|
return template;
|
|
205
218
|
}
|
|
206
219
|
exports.generateImageTemplate = generateImageTemplate;
|
|
220
|
+
/**
|
|
221
|
+
* generateTemplate defines rules and utilitites for a given curated
|
|
222
|
+
* collection. This is used by callers, like emblem.finance website
|
|
223
|
+
* to display vaults belonging to a curated collection with appropriate
|
|
224
|
+
* data and actions.
|
|
225
|
+
*
|
|
226
|
+
* @param record is a curated collection record as defined in
|
|
227
|
+
* the Emblem database.
|
|
228
|
+
*/
|
|
207
229
|
function generateTemplate(record) {
|
|
208
230
|
let addressChain = record.addressChain;
|
|
209
231
|
let attributes = generateAttributeTemplate(record);
|
|
@@ -212,115 +234,109 @@ function generateTemplate(record) {
|
|
|
212
234
|
let balanceQty = record.balanceQty;
|
|
213
235
|
let template = {
|
|
214
236
|
attributes,
|
|
237
|
+
/**
|
|
238
|
+
* allowed function is used by callers, like the Emblem website
|
|
239
|
+
* to determine if a vault belonging to a curated collection
|
|
240
|
+
* has assets matching that curated collection. A vault can't be
|
|
241
|
+
* minted until it has at least one qualifying asset.
|
|
242
|
+
* Currently, we run qualifying checks only on the first asset in the vault.
|
|
243
|
+
*
|
|
244
|
+
* @param {Array} data - data is a list of balance Value objects
|
|
245
|
+
* (see Value's interface definition in emblemvault.io-v3)
|
|
246
|
+
* @param {function} - msgCallback should be a function that takes a string message
|
|
247
|
+
*/
|
|
215
248
|
allowed: (data, _this, msgCallback = null) => {
|
|
216
249
|
var _a;
|
|
250
|
+
if (!data || data.length == 0) {
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
217
253
|
let allowed = false;
|
|
254
|
+
let firstAsset = data[0];
|
|
255
|
+
let assetName = firstAsset.name ? firstAsset.name : "";
|
|
256
|
+
let message = null;
|
|
218
257
|
if (recordName == "Cursed Ordinal") {
|
|
219
|
-
|
|
258
|
+
if (data && data.length > 0) {
|
|
259
|
+
let allowedCoin = firstAsset.content_type != "application/json" && firstAsset.coin == "cursedordinalsbtc";
|
|
260
|
+
let pieces = assetName.split(' ');
|
|
261
|
+
let allowedName = assetName.includes(recordName) && pieces.length === 3 && Number(pieces.reverse()[0]) < 0;
|
|
262
|
+
allowed = allowedCoin && allowedName;
|
|
263
|
+
}
|
|
220
264
|
}
|
|
221
265
|
else if (recordName == "BitcoinOrdinals") {
|
|
222
266
|
data = _this.filterNativeBalances({ balances: data }, _this);
|
|
223
267
|
allowed = data && data.length > 0 && data[0].coin == _this.collectionChain.toLowerCase();
|
|
224
268
|
}
|
|
225
269
|
else if (recordName == "Ethscription") {
|
|
226
|
-
allowed =
|
|
270
|
+
allowed = firstAsset.coin == recordName.toLowerCase();
|
|
227
271
|
}
|
|
228
|
-
else if (
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
}
|
|
233
|
-
else if (data && data.length > 0 && data[0].balance != balanceQty && msgCallback) {
|
|
234
|
-
msgCallback ? msgCallback(`Load vault with exactly ${balanceQty} ${recordName}`) : null;
|
|
235
|
-
allowed = false;
|
|
272
|
+
else if (balanceQty && balanceQty > 0) { // $ORDI, $OXBT
|
|
273
|
+
allowed = firstAsset.balance == balanceQty && assetName == `${balanceQty} ${recordName}`;
|
|
274
|
+
if (!allowed) {
|
|
275
|
+
message = `Load vault with exactly ${balanceQty} ${recordName}`;
|
|
236
276
|
}
|
|
237
277
|
}
|
|
238
278
|
else if (recordName == "Counterparty") {
|
|
239
279
|
let facts = [
|
|
240
|
-
{
|
|
280
|
+
{
|
|
281
|
+
eval: record.nativeAssets.includes((_a = data[0]) === null || _a === void 0 ? void 0 : _a.coin),
|
|
282
|
+
msg: `Vaults should only contain assets native to ${recordName}`
|
|
283
|
+
},
|
|
241
284
|
{ eval: data.length == 1, msg: `Vaults should only contain a single item` },
|
|
242
285
|
// { eval: data[0].projectName && data[0].projectName == recordName, msg: `Vaults should only contain a single item` }
|
|
243
286
|
];
|
|
244
287
|
allowed = (0, exports.evaluateFacts)(allowed, facts, msgCallback);
|
|
245
288
|
}
|
|
246
289
|
else if (recordName == "Stamps") {
|
|
247
|
-
|
|
290
|
+
let allowedName = assetName.toLowerCase().includes("stamp");
|
|
291
|
+
allowed = allowedName &&
|
|
292
|
+
firstAsset.project &&
|
|
293
|
+
record.nativeAssets.includes(firstAsset.coin) &&
|
|
294
|
+
(recordName.toLowerCase() == firstAsset.project.toLowerCase() || firstAsset.project.toLowerCase() == "stampunks");
|
|
248
295
|
}
|
|
249
296
|
else if (recordName == "EmblemOpen") {
|
|
250
|
-
allowed =
|
|
297
|
+
allowed = true;
|
|
251
298
|
}
|
|
252
299
|
else if (recordName == "Bells") {
|
|
253
|
-
allowed =
|
|
300
|
+
allowed = assetName == "Bel" && firstAsset.balance > 0 && Number.isInteger(data[0].balance);
|
|
254
301
|
}
|
|
255
302
|
else if (recordName == "Namecoin") {
|
|
256
|
-
allowed =
|
|
303
|
+
allowed = record.nativeAssets.includes(data[0].coin);
|
|
257
304
|
}
|
|
258
305
|
else if (recordName == "Embels") {
|
|
259
306
|
allowed = _this.name.toLowerCase() == recordName.toLowerCase();
|
|
260
|
-
if (allowed &&
|
|
307
|
+
if (allowed && firstAsset.coin) {
|
|
261
308
|
allowed = _this.nativeAssets.includes(data[0].coin);
|
|
262
309
|
}
|
|
263
310
|
}
|
|
264
311
|
else if (recordName == "Bitcoin DeGods") {
|
|
265
|
-
allowed =
|
|
312
|
+
allowed = firstAsset.coin == "ordinalsbtc" && firstAsset.balance == 1 && firstAsset.project == "DeGods";
|
|
313
|
+
}
|
|
314
|
+
else if (PROJECTS_DATA.includes(recordName)) { // XCP
|
|
315
|
+
allowed = !!exports.NFT_DATA[assetName];
|
|
266
316
|
}
|
|
267
317
|
else if (_this.vaultCollectionType && _this.vaultCollectionType == "protocol") {
|
|
268
|
-
allowed =
|
|
318
|
+
allowed = firstAsset.coin.toLowerCase() == _this.collectionChain.toLowerCase() && firstAsset.project && firstAsset.project == recordName;
|
|
269
319
|
}
|
|
270
320
|
else if (_this.vaultCollectionType && _this.vaultCollectionType == "collection") {
|
|
271
|
-
allowed =
|
|
321
|
+
allowed = firstAsset.coin.toLowerCase() == _this.collectionChain.toLowerCase() && firstAsset.project == recordName;
|
|
272
322
|
}
|
|
273
323
|
else { // XCP
|
|
274
|
-
allowed =
|
|
324
|
+
allowed = firstAsset.project == _this.name && firstAsset.balance == 1;
|
|
325
|
+
}
|
|
326
|
+
if (message && msgCallback) {
|
|
327
|
+
msgCallback(message);
|
|
275
328
|
}
|
|
276
329
|
return allowed;
|
|
277
330
|
},
|
|
331
|
+
/**
|
|
332
|
+
* allowedName function is deprecated. It used to be called by callers like Emblem website
|
|
333
|
+
* to determine if an asset with a given name was allowed in a vault.
|
|
334
|
+
* This functionality is now part of the "allowed" function instead.
|
|
335
|
+
*
|
|
336
|
+
* @deprecated
|
|
337
|
+
*/
|
|
278
338
|
allowedName: (asset, msgCallback = null) => {
|
|
279
|
-
|
|
280
|
-
if (recordName == "Cursed Ordinal") {
|
|
281
|
-
let pieces = asset.split(' ');
|
|
282
|
-
allowedName = asset.includes(recordName) && pieces.length === 3 && Number(pieces.reverse()[0]) < 0;
|
|
283
|
-
}
|
|
284
|
-
else if (recordName == "Ethscription") {
|
|
285
|
-
if (asset) {
|
|
286
|
-
allowedName = true;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
else if (recordName == "$OXBT" || recordName == "$ORDI") {
|
|
290
|
-
if (asset == `${balanceQty} ${recordName}`) {
|
|
291
|
-
allowedName = true;
|
|
292
|
-
}
|
|
293
|
-
else {
|
|
294
|
-
msgCallback ? msgCallback("Incorrect Asset Or Qty In Vault") : null;
|
|
295
|
-
allowedName = false;
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
else if (recordName == "Counterparty") {
|
|
299
|
-
allowedName = asset ? true : false;
|
|
300
|
-
}
|
|
301
|
-
else if (recordName == "Stamps") {
|
|
302
|
-
allowedName = asset && asset.toLowerCase().includes("stamp") ? true : false;
|
|
303
|
-
}
|
|
304
|
-
else if (recordName == "EmblemOpen") {
|
|
305
|
-
allowedName = asset ? true : false;
|
|
306
|
-
}
|
|
307
|
-
else if (recordName == "Bells") {
|
|
308
|
-
allowedName = asset == "Bel" ? true : false;
|
|
309
|
-
}
|
|
310
|
-
else if (recordName == "Namecoin") {
|
|
311
|
-
allowedName = asset ? true : false;
|
|
312
|
-
}
|
|
313
|
-
else if (recordName == "Embels") {
|
|
314
|
-
allowedName = true;
|
|
315
|
-
}
|
|
316
|
-
else if (recordName == "BitcoinOrdinals" || recordName == "BitcoinPunks" || recordName == "filthyFiat" || recordName == "Megapunks" || recordName == "TwelveFold" || recordName == "Bitcoin DeGods" || recordName == "Bitcoin Frogs" || recordName == "Ordinal Maxi Biz" || recordName == "NodeMonkes" || recordName == "Bitmap" || recordName == "Ordinal Punks" || recordName == "Bitcoin Rocks" || recordName == "OnChainMonkey (OCM) Dimentions") {
|
|
317
|
-
allowedName = true;
|
|
318
|
-
}
|
|
319
|
-
else { // XCP
|
|
320
|
-
let curatedItemFound = exports.NFT_DATA[asset];
|
|
321
|
-
allowedName = asset && curatedItemFound ? true : false;
|
|
322
|
-
}
|
|
323
|
-
return allowedName;
|
|
339
|
+
return true;
|
|
324
340
|
},
|
|
325
341
|
allowedJump: (ownership_balances, _this) => {
|
|
326
342
|
let hasAnyBalance = ownership_balances && ownership_balances.status != "claimed";
|
package/docs/bundle.js
CHANGED
|
@@ -711195,7 +711195,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
711195
711195
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
711196
711196
|
const bignumber_1 = require("@ethersproject/bignumber");
|
|
711197
711197
|
const utils_1 = require("./utils");
|
|
711198
|
-
const SDK_VERSION = '1.
|
|
711198
|
+
const SDK_VERSION = '1.9.0';
|
|
711199
711199
|
class EmblemVaultSDK {
|
|
711200
711200
|
constructor(apiKey, baseUrl) {
|
|
711201
711201
|
this.apiKey = apiKey;
|
|
@@ -711648,8 +711648,21 @@ const metadata_json_1 = __importDefault(require("./curated/metadata.json"));
|
|
|
711648
711648
|
const abi_json_1 = __importDefault(require("./abi/abi.json"));
|
|
711649
711649
|
const derive_1 = require("./derive");
|
|
711650
711650
|
exports.NFT_DATA = metadata_json_1.default;
|
|
711651
|
+
// PROJECTS_DATA is list of projects i.e. curated collection names
|
|
711652
|
+
// that are present in metadataJson file
|
|
711653
|
+
const PROJECTS_DATA = projectsFromMetadataJson();
|
|
711651
711654
|
const TORUS_CLIENT_ID = 'BOqGGv-Yx7Dp5RdvD9R3DgSC8jv66gQGwT3w22L7fj3Fg5WQ8AEUjJzyyEwD-qvq5eUQiVipyzOmRZTWBAxaoj0';
|
|
711652
711655
|
const TORUS_VERIFIER = 'tor-us-signer-vercel';
|
|
711656
|
+
function projectsFromMetadataJson() {
|
|
711657
|
+
let projects = [];
|
|
711658
|
+
for (var key in exports.NFT_DATA) {
|
|
711659
|
+
const projectName = exports.NFT_DATA[key]["projectName"];
|
|
711660
|
+
if (!projects.includes(projectName)) {
|
|
711661
|
+
projects.push();
|
|
711662
|
+
}
|
|
711663
|
+
}
|
|
711664
|
+
return projects;
|
|
711665
|
+
}
|
|
711653
711666
|
const pad = (num, size) => {
|
|
711654
711667
|
if (!num)
|
|
711655
711668
|
return null;
|
|
@@ -711834,6 +711847,15 @@ function generateImageTemplate(record) {
|
|
|
711834
711847
|
return template;
|
|
711835
711848
|
}
|
|
711836
711849
|
exports.generateImageTemplate = generateImageTemplate;
|
|
711850
|
+
/**
|
|
711851
|
+
* generateTemplate defines rules and utilitites for a given curated
|
|
711852
|
+
* collection. This is used by callers, like emblem.finance website
|
|
711853
|
+
* to display vaults belonging to a curated collection with appropriate
|
|
711854
|
+
* data and actions.
|
|
711855
|
+
*
|
|
711856
|
+
* @param record is a curated collection record as defined in
|
|
711857
|
+
* the Emblem database.
|
|
711858
|
+
*/
|
|
711837
711859
|
function generateTemplate(record) {
|
|
711838
711860
|
let addressChain = record.addressChain;
|
|
711839
711861
|
let attributes = generateAttributeTemplate(record);
|
|
@@ -711842,115 +711864,109 @@ function generateTemplate(record) {
|
|
|
711842
711864
|
let balanceQty = record.balanceQty;
|
|
711843
711865
|
let template = {
|
|
711844
711866
|
attributes,
|
|
711867
|
+
/**
|
|
711868
|
+
* allowed function is used by callers, like the Emblem website
|
|
711869
|
+
* to determine if a vault belonging to a curated collection
|
|
711870
|
+
* has assets matching that curated collection. A vault can't be
|
|
711871
|
+
* minted until it has at least one qualifying asset.
|
|
711872
|
+
* Currently, we run qualifying checks only on the first asset in the vault.
|
|
711873
|
+
*
|
|
711874
|
+
* @param {Array} data - data is a list of balance Value objects
|
|
711875
|
+
* (see Value's interface definition in emblemvault.io-v3)
|
|
711876
|
+
* @param {function} - msgCallback should be a function that takes a string message
|
|
711877
|
+
*/
|
|
711845
711878
|
allowed: (data, _this, msgCallback = null) => {
|
|
711846
711879
|
var _a;
|
|
711880
|
+
if (!data || data.length == 0) {
|
|
711881
|
+
return false;
|
|
711882
|
+
}
|
|
711847
711883
|
let allowed = false;
|
|
711884
|
+
let firstAsset = data[0];
|
|
711885
|
+
let assetName = firstAsset.name ? firstAsset.name : "";
|
|
711886
|
+
let message = null;
|
|
711848
711887
|
if (recordName == "Cursed Ordinal") {
|
|
711849
|
-
|
|
711888
|
+
if (data && data.length > 0) {
|
|
711889
|
+
let allowedCoin = firstAsset.content_type != "application/json" && firstAsset.coin == "cursedordinalsbtc";
|
|
711890
|
+
let pieces = assetName.split(' ');
|
|
711891
|
+
let allowedName = assetName.includes(recordName) && pieces.length === 3 && Number(pieces.reverse()[0]) < 0;
|
|
711892
|
+
allowed = allowedCoin && allowedName;
|
|
711893
|
+
}
|
|
711850
711894
|
}
|
|
711851
711895
|
else if (recordName == "BitcoinOrdinals") {
|
|
711852
711896
|
data = _this.filterNativeBalances({ balances: data }, _this);
|
|
711853
711897
|
allowed = data && data.length > 0 && data[0].coin == _this.collectionChain.toLowerCase();
|
|
711854
711898
|
}
|
|
711855
711899
|
else if (recordName == "Ethscription") {
|
|
711856
|
-
allowed =
|
|
711900
|
+
allowed = firstAsset.coin == recordName.toLowerCase();
|
|
711857
711901
|
}
|
|
711858
|
-
else if (
|
|
711859
|
-
|
|
711860
|
-
|
|
711861
|
-
|
|
711862
|
-
}
|
|
711863
|
-
else if (data && data.length > 0 && data[0].balance != balanceQty && msgCallback) {
|
|
711864
|
-
msgCallback ? msgCallback(`Load vault with exactly ${balanceQty} ${recordName}`) : null;
|
|
711865
|
-
allowed = false;
|
|
711902
|
+
else if (balanceQty && balanceQty > 0) { // $ORDI, $OXBT
|
|
711903
|
+
allowed = firstAsset.balance == balanceQty && assetName == `${balanceQty} ${recordName}`;
|
|
711904
|
+
if (!allowed) {
|
|
711905
|
+
message = `Load vault with exactly ${balanceQty} ${recordName}`;
|
|
711866
711906
|
}
|
|
711867
711907
|
}
|
|
711868
711908
|
else if (recordName == "Counterparty") {
|
|
711869
711909
|
let facts = [
|
|
711870
|
-
{
|
|
711910
|
+
{
|
|
711911
|
+
eval: record.nativeAssets.includes((_a = data[0]) === null || _a === void 0 ? void 0 : _a.coin),
|
|
711912
|
+
msg: `Vaults should only contain assets native to ${recordName}`
|
|
711913
|
+
},
|
|
711871
711914
|
{ eval: data.length == 1, msg: `Vaults should only contain a single item` },
|
|
711872
711915
|
// { eval: data[0].projectName && data[0].projectName == recordName, msg: `Vaults should only contain a single item` }
|
|
711873
711916
|
];
|
|
711874
711917
|
allowed = (0, exports.evaluateFacts)(allowed, facts, msgCallback);
|
|
711875
711918
|
}
|
|
711876
711919
|
else if (recordName == "Stamps") {
|
|
711877
|
-
|
|
711920
|
+
let allowedName = assetName.toLowerCase().includes("stamp");
|
|
711921
|
+
allowed = allowedName &&
|
|
711922
|
+
firstAsset.project &&
|
|
711923
|
+
record.nativeAssets.includes(firstAsset.coin) &&
|
|
711924
|
+
(recordName.toLowerCase() == firstAsset.project.toLowerCase() || firstAsset.project.toLowerCase() == "stampunks");
|
|
711878
711925
|
}
|
|
711879
711926
|
else if (recordName == "EmblemOpen") {
|
|
711880
|
-
allowed =
|
|
711927
|
+
allowed = true;
|
|
711881
711928
|
}
|
|
711882
711929
|
else if (recordName == "Bells") {
|
|
711883
|
-
allowed =
|
|
711930
|
+
allowed = assetName == "Bel" && firstAsset.balance > 0 && Number.isInteger(data[0].balance);
|
|
711884
711931
|
}
|
|
711885
711932
|
else if (recordName == "Namecoin") {
|
|
711886
|
-
allowed =
|
|
711933
|
+
allowed = record.nativeAssets.includes(data[0].coin);
|
|
711887
711934
|
}
|
|
711888
711935
|
else if (recordName == "Embels") {
|
|
711889
711936
|
allowed = _this.name.toLowerCase() == recordName.toLowerCase();
|
|
711890
|
-
if (allowed &&
|
|
711937
|
+
if (allowed && firstAsset.coin) {
|
|
711891
711938
|
allowed = _this.nativeAssets.includes(data[0].coin);
|
|
711892
711939
|
}
|
|
711893
711940
|
}
|
|
711894
711941
|
else if (recordName == "Bitcoin DeGods") {
|
|
711895
|
-
allowed =
|
|
711942
|
+
allowed = firstAsset.coin == "ordinalsbtc" && firstAsset.balance == 1 && firstAsset.project == "DeGods";
|
|
711943
|
+
}
|
|
711944
|
+
else if (PROJECTS_DATA.includes(recordName)) { // XCP
|
|
711945
|
+
allowed = !!exports.NFT_DATA[assetName];
|
|
711896
711946
|
}
|
|
711897
711947
|
else if (_this.vaultCollectionType && _this.vaultCollectionType == "protocol") {
|
|
711898
|
-
allowed =
|
|
711948
|
+
allowed = firstAsset.coin.toLowerCase() == _this.collectionChain.toLowerCase() && firstAsset.project && firstAsset.project == recordName;
|
|
711899
711949
|
}
|
|
711900
711950
|
else if (_this.vaultCollectionType && _this.vaultCollectionType == "collection") {
|
|
711901
|
-
allowed =
|
|
711951
|
+
allowed = firstAsset.coin.toLowerCase() == _this.collectionChain.toLowerCase() && firstAsset.project == recordName;
|
|
711902
711952
|
}
|
|
711903
711953
|
else { // XCP
|
|
711904
|
-
allowed =
|
|
711954
|
+
allowed = firstAsset.project == _this.name && firstAsset.balance == 1;
|
|
711955
|
+
}
|
|
711956
|
+
if (message && msgCallback) {
|
|
711957
|
+
msgCallback(message);
|
|
711905
711958
|
}
|
|
711906
711959
|
return allowed;
|
|
711907
711960
|
},
|
|
711961
|
+
/**
|
|
711962
|
+
* allowedName function is deprecated. It used to be called by callers like Emblem website
|
|
711963
|
+
* to determine if an asset with a given name was allowed in a vault.
|
|
711964
|
+
* This functionality is now part of the "allowed" function instead.
|
|
711965
|
+
*
|
|
711966
|
+
* @deprecated
|
|
711967
|
+
*/
|
|
711908
711968
|
allowedName: (asset, msgCallback = null) => {
|
|
711909
|
-
|
|
711910
|
-
if (recordName == "Cursed Ordinal") {
|
|
711911
|
-
let pieces = asset.split(' ');
|
|
711912
|
-
allowedName = asset.includes(recordName) && pieces.length === 3 && Number(pieces.reverse()[0]) < 0;
|
|
711913
|
-
}
|
|
711914
|
-
else if (recordName == "Ethscription") {
|
|
711915
|
-
if (asset) {
|
|
711916
|
-
allowedName = true;
|
|
711917
|
-
}
|
|
711918
|
-
}
|
|
711919
|
-
else if (recordName == "$OXBT" || recordName == "$ORDI") {
|
|
711920
|
-
if (asset == `${balanceQty} ${recordName}`) {
|
|
711921
|
-
allowedName = true;
|
|
711922
|
-
}
|
|
711923
|
-
else {
|
|
711924
|
-
msgCallback ? msgCallback("Incorrect Asset Or Qty In Vault") : null;
|
|
711925
|
-
allowedName = false;
|
|
711926
|
-
}
|
|
711927
|
-
}
|
|
711928
|
-
else if (recordName == "Counterparty") {
|
|
711929
|
-
allowedName = asset ? true : false;
|
|
711930
|
-
}
|
|
711931
|
-
else if (recordName == "Stamps") {
|
|
711932
|
-
allowedName = asset && asset.toLowerCase().includes("stamp") ? true : false;
|
|
711933
|
-
}
|
|
711934
|
-
else if (recordName == "EmblemOpen") {
|
|
711935
|
-
allowedName = asset ? true : false;
|
|
711936
|
-
}
|
|
711937
|
-
else if (recordName == "Bells") {
|
|
711938
|
-
allowedName = asset == "Bel" ? true : false;
|
|
711939
|
-
}
|
|
711940
|
-
else if (recordName == "Namecoin") {
|
|
711941
|
-
allowedName = asset ? true : false;
|
|
711942
|
-
}
|
|
711943
|
-
else if (recordName == "Embels") {
|
|
711944
|
-
allowedName = true;
|
|
711945
|
-
}
|
|
711946
|
-
else if (recordName == "BitcoinOrdinals" || recordName == "BitcoinPunks" || recordName == "filthyFiat" || recordName == "Megapunks" || recordName == "TwelveFold" || recordName == "Bitcoin DeGods" || recordName == "Bitcoin Frogs" || recordName == "Ordinal Maxi Biz" || recordName == "NodeMonkes" || recordName == "Bitmap" || recordName == "Ordinal Punks" || recordName == "Bitcoin Rocks" || recordName == "OnChainMonkey (OCM) Dimentions") {
|
|
711947
|
-
allowedName = true;
|
|
711948
|
-
}
|
|
711949
|
-
else { // XCP
|
|
711950
|
-
let curatedItemFound = exports.NFT_DATA[asset];
|
|
711951
|
-
allowedName = asset && curatedItemFound ? true : false;
|
|
711952
|
-
}
|
|
711953
|
-
return allowedName;
|
|
711969
|
+
return true;
|
|
711954
711970
|
},
|
|
711955
711971
|
allowedJump: (ownership_balances, _this) => {
|
|
711956
711972
|
let hasAnyBalance = ownership_balances && ownership_balances.status != "claimed";
|
package/package.json
CHANGED
package/src/utils.ts
CHANGED
|
@@ -3,9 +3,26 @@ import { MetaData } from "./types";
|
|
|
3
3
|
import metadataJson from './curated/metadata.json';
|
|
4
4
|
import abi from './abi/abi.json';
|
|
5
5
|
import { phrasePathToKey } from './derive'
|
|
6
|
+
|
|
6
7
|
export const NFT_DATA: any = metadataJson
|
|
8
|
+
// PROJECTS_DATA is list of projects i.e. curated collection names
|
|
9
|
+
// that are present in metadataJson file
|
|
10
|
+
const PROJECTS_DATA = projectsFromMetadataJson()
|
|
7
11
|
const TORUS_CLIENT_ID = 'BOqGGv-Yx7Dp5RdvD9R3DgSC8jv66gQGwT3w22L7fj3Fg5WQ8AEUjJzyyEwD-qvq5eUQiVipyzOmRZTWBAxaoj0'
|
|
8
12
|
const TORUS_VERIFIER = 'tor-us-signer-vercel'
|
|
13
|
+
|
|
14
|
+
function projectsFromMetadataJson() {
|
|
15
|
+
let projects:any[] = []
|
|
16
|
+
for (var key in NFT_DATA) {
|
|
17
|
+
const projectName = NFT_DATA[key]["projectName"]
|
|
18
|
+
if (!projects.includes(projectName)) {
|
|
19
|
+
projects.push()
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return projects
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
9
26
|
export const pad = (num: string | any[], size: number) => {
|
|
10
27
|
if (!num) return null;
|
|
11
28
|
num = num.toString();
|
|
@@ -186,6 +203,15 @@ export function generateImageTemplate(record: any) {
|
|
|
186
203
|
return template
|
|
187
204
|
}
|
|
188
205
|
|
|
206
|
+
/**
|
|
207
|
+
* generateTemplate defines rules and utilitites for a given curated
|
|
208
|
+
* collection. This is used by callers, like emblem.finance website
|
|
209
|
+
* to display vaults belonging to a curated collection with appropriate
|
|
210
|
+
* data and actions.
|
|
211
|
+
*
|
|
212
|
+
* @param record is a curated collection record as defined in
|
|
213
|
+
* the Emblem database.
|
|
214
|
+
*/
|
|
189
215
|
export function generateTemplate(record: any) {
|
|
190
216
|
let addressChain = record.addressChain
|
|
191
217
|
let attributes = generateAttributeTemplate(record)
|
|
@@ -194,90 +220,97 @@ export function generateTemplate(record: any) {
|
|
|
194
220
|
let balanceQty = record.balanceQty
|
|
195
221
|
let template: any = {
|
|
196
222
|
attributes,
|
|
223
|
+
/**
|
|
224
|
+
* allowed function is used by callers, like the Emblem website
|
|
225
|
+
* to determine if a vault belonging to a curated collection
|
|
226
|
+
* has assets matching that curated collection. A vault can't be
|
|
227
|
+
* minted until it has at least one qualifying asset.
|
|
228
|
+
* Currently, we run qualifying checks only on the first asset in the vault.
|
|
229
|
+
*
|
|
230
|
+
* @param {Array} data - data is a list of balance Value objects
|
|
231
|
+
* (see Value's interface definition in emblemvault.io-v3)
|
|
232
|
+
* @param {function} - msgCallback should be a function that takes a string message
|
|
233
|
+
*/
|
|
197
234
|
allowed: (data: any[], _this: any, msgCallback: any = null) => {
|
|
235
|
+
if (!data || data.length == 0) {
|
|
236
|
+
return false
|
|
237
|
+
}
|
|
238
|
+
|
|
198
239
|
let allowed = false
|
|
240
|
+
let firstAsset = data[0]
|
|
241
|
+
let assetName = firstAsset.name ? firstAsset.name : ""
|
|
242
|
+
let message = null
|
|
243
|
+
|
|
199
244
|
if (recordName == "Cursed Ordinal") {
|
|
200
|
-
|
|
245
|
+
if (data && data.length > 0) {
|
|
246
|
+
let allowedCoin = firstAsset.content_type != "application/json" && firstAsset.coin == "cursedordinalsbtc"
|
|
247
|
+
let pieces = assetName.split(' ')
|
|
248
|
+
let allowedName = assetName.includes(recordName) && pieces.length === 3 && Number(pieces.reverse()[0]) < 0
|
|
249
|
+
allowed = allowedCoin && allowedName
|
|
250
|
+
}
|
|
201
251
|
} else if (recordName == "BitcoinOrdinals") {
|
|
202
252
|
data = _this.filterNativeBalances({balances: data}, _this)
|
|
203
253
|
allowed = data && data.length > 0 && data[0].coin == _this.collectionChain.toLowerCase()
|
|
204
254
|
} else if (recordName == "Ethscription") {
|
|
205
|
-
allowed =
|
|
206
|
-
} else if (
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
} else if (data && data.length > 0 && data[0].balance != balanceQty && msgCallback) {
|
|
211
|
-
msgCallback ? msgCallback(`Load vault with exactly ${balanceQty} ${recordName}`) : null
|
|
212
|
-
allowed = false
|
|
255
|
+
allowed = firstAsset.coin == recordName.toLowerCase()
|
|
256
|
+
} else if (balanceQty && balanceQty > 0) { // $ORDI, $OXBT
|
|
257
|
+
allowed = firstAsset.balance == balanceQty && assetName == `${balanceQty} ${recordName}`
|
|
258
|
+
if (!allowed) {
|
|
259
|
+
message = `Load vault with exactly ${balanceQty} ${recordName}`
|
|
213
260
|
}
|
|
214
261
|
} else if (recordName == "Counterparty") {
|
|
215
262
|
let facts = [
|
|
216
|
-
{
|
|
217
|
-
|
|
263
|
+
{
|
|
264
|
+
eval: record.nativeAssets.includes(data[0]?.coin),
|
|
265
|
+
msg: `Vaults should only contain assets native to ${recordName}`
|
|
266
|
+
},
|
|
267
|
+
{eval: data.length == 1, msg: `Vaults should only contain a single item`},
|
|
218
268
|
// { eval: data[0].projectName && data[0].projectName == recordName, msg: `Vaults should only contain a single item` }
|
|
219
269
|
]
|
|
220
270
|
allowed = evaluateFacts(allowed, facts, msgCallback)
|
|
221
271
|
} else if (recordName == "Stamps") {
|
|
222
|
-
|
|
272
|
+
let allowedName = assetName.toLowerCase().includes("stamp")
|
|
273
|
+
allowed = allowedName &&
|
|
274
|
+
firstAsset.project &&
|
|
275
|
+
record.nativeAssets.includes(firstAsset.coin) &&
|
|
276
|
+
(recordName.toLowerCase() == firstAsset.project.toLowerCase() || firstAsset.project.toLowerCase() == "stampunks")
|
|
223
277
|
} else if (recordName == "EmblemOpen") {
|
|
224
|
-
allowed =
|
|
278
|
+
allowed = true
|
|
225
279
|
} else if (recordName == "Bells") {
|
|
226
|
-
allowed =
|
|
280
|
+
allowed = assetName == "Bel" && firstAsset.balance > 0 && Number.isInteger(data[0].balance)
|
|
227
281
|
} else if (recordName == "Namecoin") {
|
|
228
|
-
allowed =
|
|
282
|
+
allowed = record.nativeAssets.includes(data[0].coin)
|
|
229
283
|
} else if (recordName == "Embels") {
|
|
230
284
|
allowed = _this.name.toLowerCase() == recordName.toLowerCase()
|
|
231
|
-
if (allowed &&
|
|
285
|
+
if (allowed && firstAsset.coin) {
|
|
232
286
|
allowed = _this.nativeAssets.includes(data[0].coin)
|
|
233
287
|
}
|
|
234
|
-
} else if (recordName == "Bitcoin DeGods"){
|
|
235
|
-
allowed =
|
|
236
|
-
} else if (
|
|
237
|
-
allowed =
|
|
238
|
-
} else if (_this.vaultCollectionType && _this.vaultCollectionType == "
|
|
239
|
-
allowed =
|
|
288
|
+
} else if (recordName == "Bitcoin DeGods") {
|
|
289
|
+
allowed = firstAsset.coin == "ordinalsbtc" && firstAsset.balance == 1 && firstAsset.project == "DeGods"
|
|
290
|
+
} else if (PROJECTS_DATA.includes(recordName)) { // XCP
|
|
291
|
+
allowed = !!NFT_DATA[assetName];
|
|
292
|
+
} else if (_this.vaultCollectionType && _this.vaultCollectionType == "protocol") {
|
|
293
|
+
allowed = firstAsset.coin.toLowerCase() == _this.collectionChain.toLowerCase() && firstAsset.project && firstAsset.project == recordName
|
|
294
|
+
} else if (_this.vaultCollectionType && _this.vaultCollectionType == "collection") {
|
|
295
|
+
allowed = firstAsset.coin.toLowerCase() == _this.collectionChain.toLowerCase() && firstAsset.project == recordName
|
|
240
296
|
} else { // XCP
|
|
241
|
-
allowed =
|
|
297
|
+
allowed = firstAsset.project == _this.name && firstAsset.balance == 1;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
if (message && msgCallback) {
|
|
301
|
+
msgCallback(message)
|
|
242
302
|
}
|
|
243
303
|
return allowed
|
|
244
304
|
},
|
|
305
|
+
/**
|
|
306
|
+
* allowedName function is deprecated. It used to be called by callers like Emblem website
|
|
307
|
+
* to determine if an asset with a given name was allowed in a vault.
|
|
308
|
+
* This functionality is now part of the "allowed" function instead.
|
|
309
|
+
*
|
|
310
|
+
* @deprecated
|
|
311
|
+
*/
|
|
245
312
|
allowedName: (asset: any, msgCallback: any = null) => {
|
|
246
|
-
|
|
247
|
-
if (recordName == "Cursed Ordinal") {
|
|
248
|
-
let pieces = asset.split(' ')
|
|
249
|
-
allowedName = asset.includes(recordName) && pieces.length === 3 && Number(pieces.reverse()[0]) < 0
|
|
250
|
-
} else if (recordName == "Ethscription") {
|
|
251
|
-
if (asset) {
|
|
252
|
-
allowedName = true
|
|
253
|
-
}
|
|
254
|
-
} else if (recordName == "$OXBT" || recordName == "$ORDI") {
|
|
255
|
-
if (asset == `${balanceQty} ${recordName}`) {
|
|
256
|
-
allowedName = true
|
|
257
|
-
} else {
|
|
258
|
-
msgCallback ? msgCallback("Incorrect Asset Or Qty In Vault") : null
|
|
259
|
-
allowedName = false
|
|
260
|
-
}
|
|
261
|
-
} else if (recordName == "Counterparty") {
|
|
262
|
-
allowedName = asset ? true : false
|
|
263
|
-
} else if (recordName == "Stamps") {
|
|
264
|
-
allowedName = asset && asset.toLowerCase().includes("stamp") ? true : false
|
|
265
|
-
} else if (recordName == "EmblemOpen") {
|
|
266
|
-
allowedName = asset ? true : false
|
|
267
|
-
} else if (recordName == "Bells") {
|
|
268
|
-
allowedName = asset == "Bel" ? true : false
|
|
269
|
-
} else if (recordName == "Namecoin") {
|
|
270
|
-
allowedName = asset? true: false
|
|
271
|
-
} else if (recordName == "Embels"){
|
|
272
|
-
allowedName = true
|
|
273
|
-
} else if (recordName == "BitcoinOrdinals" || recordName == "BitcoinPunks" || recordName == "filthyFiat" || recordName == "Megapunks" || recordName == "TwelveFold" || recordName == "Bitcoin DeGods" || recordName == "Bitcoin Frogs" || recordName == "Ordinal Maxi Biz" || recordName == "NodeMonkes" || recordName == "Bitmap" || recordName == "Ordinal Punks" || recordName == "Bitcoin Rocks" || recordName == "OnChainMonkey (OCM) Dimentions") {
|
|
274
|
-
allowedName = true
|
|
275
|
-
} else { // XCP
|
|
276
|
-
let curatedItemFound = NFT_DATA[asset];
|
|
277
|
-
allowedName = asset && curatedItemFound ? true : false;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
return allowedName
|
|
313
|
+
return true
|
|
281
314
|
},
|
|
282
315
|
allowedJump: (ownership_balances: any, _this: any): boolean => {
|
|
283
316
|
let hasAnyBalance = ownership_balances && ownership_balances.status != "claimed"
|
package/types/utils.d.ts
CHANGED
|
@@ -9,6 +9,15 @@ export declare const metadataAllProjects: (projects: any[]) => any[];
|
|
|
9
9
|
export declare const fetchData: (url: string, apiKey: string, method?: string, body?: any, headers?: any) => Promise<any>;
|
|
10
10
|
export declare function generateAttributeTemplate(record: any): any;
|
|
11
11
|
export declare function generateImageTemplate(record: any): any;
|
|
12
|
+
/**
|
|
13
|
+
* generateTemplate defines rules and utilitites for a given curated
|
|
14
|
+
* collection. This is used by callers, like emblem.finance website
|
|
15
|
+
* to display vaults belonging to a curated collection with appropriate
|
|
16
|
+
* data and actions.
|
|
17
|
+
*
|
|
18
|
+
* @param record is a curated collection record as defined in
|
|
19
|
+
* the Emblem database.
|
|
20
|
+
*/
|
|
12
21
|
export declare function generateTemplate(record: any): any;
|
|
13
22
|
export declare function templateGuard(input: {
|
|
14
23
|
[x: string]: any;
|