emblem-vault-sdk 1.9.13 → 1.9.15
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 +37 -14
- package/dist/index.js +23 -1
- package/dist/utils.js +14 -13
- package/docs/bundle.js +37 -14
- package/package.json +1 -1
- package/src/index.ts +16 -0
- package/src/utils.ts +16 -12
- package/tests/AllowedBells.test.ts +53 -0
- package/tests/AllowedBitcoinDeGods.test.ts +53 -0
- package/tests/AllowedBitcoinOrdinals.test.ts +46 -0
- package/tests/AllowedCounterparty.test.ts +45 -0
- package/tests/AllowedCursedOrdinals.test.ts +68 -0
- package/tests/AllowedEmbells.test.ts +12 -0
- package/tests/AllowedEmbels.test.ts +16 -0
- package/tests/AllowedEmblemOpen.test.ts +20 -0
- package/tests/AllowedEthscriptions.test.ts +39 -0
- package/tests/AllowedHardcodedNfts.test.ts +78 -0
- package/tests/AllowedNamecoin.test.ts +33 -0
- package/tests/AllowedOrdi.test.ts +47 -0
- package/tests/AllowedOxbt.test.ts +47 -0
- package/tests/AllowedProjectlCollection.test.ts +51 -0
- package/tests/AllowedProtocolCollection.test.ts +44 -0
- package/tests/AllowedStamps.test.ts +73 -0
- package/tests/fixtures/bells/balance-with-non-bell-first.json +14 -0
- package/tests/fixtures/bells/balance-with-non-bell.json +14 -0
- package/tests/fixtures/bells/balance.json +9 -0
- package/tests/fixtures/bitcoin-degods/balance-with-non-degods-first.json +57 -0
- package/tests/fixtures/bitcoin-degods/balance-with-non-degods.json +57 -0
- package/tests/fixtures/bitcoin-degods/balance.json +52 -0
- package/tests/fixtures/bitcoin-ordinals/balance-with-native-first.json +17 -0
- package/tests/fixtures/bitcoin-ordinals/balance-with-only-native.json +12 -0
- package/tests/fixtures/bitcoin-ordinals/balance.json +42 -0
- package/tests/fixtures/counterparty/balance-with-multiple.json +47 -0
- package/tests/fixtures/counterparty/balance.json +42 -0
- package/tests/fixtures/cursed-ordinals/balance-with-native-first.json +15 -0
- package/tests/fixtures/cursed-ordinals/balance-with-native.json +15 -0
- package/tests/fixtures/cursed-ordinals/balance.json +11 -0
- package/tests/fixtures/dogeparty/balance-with-non-dogeparty-first.json +16 -0
- package/tests/fixtures/dogeparty/balance-with-non-dogeparty.json +16 -0
- package/tests/fixtures/dogeparty/balance.json +11 -0
- package/tests/fixtures/embels/balance.json +10 -0
- package/tests/fixtures/emblem-open/balance.json +244 -0
- package/tests/fixtures/ethscriptions/balance-with-native-first.json +69 -0
- package/tests/fixtures/ethscriptions/balance-with-native.json +37 -0
- package/tests/fixtures/ethscriptions/balance.json +64 -0
- package/tests/fixtures/hardcoded-nfts/balance-witn-non-hardcoded-first.json +20 -0
- package/tests/fixtures/hardcoded-nfts/balance-witn-non-hardcoded.json +20 -0
- package/tests/fixtures/hardcoded-nfts/balance.json +15 -0
- package/tests/fixtures/megapunks/balance-with-non-megapunk-first.json +48 -0
- package/tests/fixtures/megapunks/balance-with-non-megapunk.json +48 -0
- package/tests/fixtures/megapunks/balance.json +43 -0
- package/tests/fixtures/namecoin/balance-with-native-first.json +109 -0
- package/tests/fixtures/namecoin/balance-with-native.json +109 -0
- package/tests/fixtures/namecoin/balance.json +103 -0
- package/tests/fixtures/ordi/balance-with-native-first.json +13 -0
- package/tests/fixtures/ordi/balance-with-native.json +13 -0
- package/tests/fixtures/ordi/balance.json +8 -0
- package/tests/fixtures/oxbt/balance-with-native-first.json +13 -0
- package/tests/fixtures/oxbt/balance-with-native.json +13 -0
- package/tests/fixtures/oxbt/balance.json +8 -0
- package/tests/fixtures/stamps/balance-with-non-stamps-first.json +23 -0
- package/tests/fixtures/stamps/balance-with-non-stamps.json +23 -0
- package/tests/fixtures/stamps/balance.json +18 -0
package/dist/bundle.js
CHANGED
|
@@ -709476,7 +709476,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
709476
709476
|
const bignumber_1 = require("@ethersproject/bignumber");
|
|
709477
709477
|
const utils_1 = require("./utils");
|
|
709478
709478
|
const derive_1 = require("./derive");
|
|
709479
|
-
const SDK_VERSION = '1.9.
|
|
709479
|
+
const SDK_VERSION = '1.9.15';
|
|
709480
709480
|
class EmblemVaultSDK {
|
|
709481
709481
|
constructor(apiKey, baseUrl) {
|
|
709482
709482
|
this.apiKey = apiKey;
|
|
@@ -709869,6 +709869,17 @@ class EmblemVaultSDK {
|
|
|
709869
709869
|
value: Number(quote),
|
|
709870
709870
|
gasPrice: gasPrice, // Use the current gas price
|
|
709871
709871
|
gas: gasLimit // Use the estimated gas limit
|
|
709872
|
+
}).on('transactionHash', (hash) => {
|
|
709873
|
+
if (callback)
|
|
709874
|
+
callback(`Transaction submitted. Hash`, hash);
|
|
709875
|
+
})
|
|
709876
|
+
.on('confirmation', (confirmationNumber, receipt) => {
|
|
709877
|
+
if (callback)
|
|
709878
|
+
callback(`Mint Complete. Confirmation Number`, confirmationNumber);
|
|
709879
|
+
})
|
|
709880
|
+
.on('error', (error) => {
|
|
709881
|
+
if (callback)
|
|
709882
|
+
callback(`Transaction Error`, error.message);
|
|
709872
709883
|
});
|
|
709873
709884
|
if (callback) {
|
|
709874
709885
|
callback('Mint Complete');
|
|
@@ -709896,6 +709907,17 @@ class EmblemVaultSDK {
|
|
|
709896
709907
|
from: accounts[0],
|
|
709897
709908
|
gasPrice: gasPrice,
|
|
709898
709909
|
gas: estimatedGas
|
|
709910
|
+
}).on('transactionHash', (hash) => {
|
|
709911
|
+
if (callback)
|
|
709912
|
+
callback(`Transaction submitted. Hash`, hash);
|
|
709913
|
+
})
|
|
709914
|
+
.on('confirmation', (confirmationNumber, receipt) => {
|
|
709915
|
+
if (callback)
|
|
709916
|
+
callback(`Burn Complete. Confirmation Number`, confirmationNumber);
|
|
709917
|
+
})
|
|
709918
|
+
.on('error', (error) => {
|
|
709919
|
+
if (callback)
|
|
709920
|
+
callback(`Transaction Error`, error.message);
|
|
709899
709921
|
});
|
|
709900
709922
|
if (callback) {
|
|
709901
709923
|
callback('Burn Complete');
|
|
@@ -710082,7 +710104,7 @@ function projectsFromMetadataJson() {
|
|
|
710082
710104
|
for (var key in exports.NFT_DATA) {
|
|
710083
710105
|
const projectName = exports.NFT_DATA[key]["projectName"];
|
|
710084
710106
|
if (!projects.includes(projectName)) {
|
|
710085
|
-
projects.push();
|
|
710107
|
+
projects.push(projectName);
|
|
710086
710108
|
}
|
|
710087
710109
|
}
|
|
710088
710110
|
return projects;
|
|
@@ -710297,21 +710319,23 @@ function generateTemplate(record) {
|
|
|
710297
710319
|
*
|
|
710298
710320
|
* @param {Array} data - data is a list of balance Value objects
|
|
710299
710321
|
* (see Value's interface definition in emblemvault.io-v3)
|
|
710322
|
+
* @param {_this} _this is one of the curatedContract returned by `fetchCuratedContracts`.
|
|
710323
|
+
* It should be further embellished with tokenId and serialNumber properties.
|
|
710300
710324
|
* @param {function} - msgCallback should be a function that takes a string message
|
|
710301
710325
|
*/
|
|
710302
710326
|
allowed: (data, _this, msgCallback = null) => {
|
|
710303
710327
|
var _a;
|
|
710304
|
-
if (
|
|
710328
|
+
if (recordName == "Embels") {
|
|
710329
|
+
return true;
|
|
710330
|
+
}
|
|
710331
|
+
if ((!data || data.length == 0)) {
|
|
710305
710332
|
return false;
|
|
710306
710333
|
}
|
|
710307
710334
|
let allowed = false;
|
|
710308
710335
|
let firstAsset = data[0];
|
|
710309
710336
|
let assetName = (firstAsset === null || firstAsset === void 0 ? void 0 : firstAsset.name) ? firstAsset.name : "";
|
|
710310
710337
|
let message = null;
|
|
710311
|
-
if (recordName == "
|
|
710312
|
-
allowed = true;
|
|
710313
|
-
}
|
|
710314
|
-
else if (recordName == "Cursed Ordinal") {
|
|
710338
|
+
if (recordName == "Cursed Ordinal") {
|
|
710315
710339
|
if (data && data.length > 0) {
|
|
710316
710340
|
let allowedCoin = firstAsset.content_type != "application/json" && firstAsset.coin == "cursedordinalsbtc";
|
|
710317
710341
|
let pieces = assetName.split(' ');
|
|
@@ -710369,7 +710393,9 @@ function generateTemplate(record) {
|
|
|
710369
710393
|
allowed = firstAsset.coin == "ordinalsbtc" && firstAsset.balance == 1 && firstAsset.project == "DeGods";
|
|
710370
710394
|
}
|
|
710371
710395
|
else if (PROJECTS_DATA.includes(recordName)) { // XCP
|
|
710372
|
-
allowed = !!exports.NFT_DATA[assetName] &&
|
|
710396
|
+
allowed = !!exports.NFT_DATA[assetName] &&
|
|
710397
|
+
exports.NFT_DATA[assetName]["projectName"].toLowerCase() == recordName.toLowerCase() &&
|
|
710398
|
+
firstAsset.project == _this.name && firstAsset.balance == 1;
|
|
710373
710399
|
}
|
|
710374
710400
|
else if (_this.vaultCollectionType && _this.vaultCollectionType == "protocol") {
|
|
710375
710401
|
allowed = firstAsset.coin.toLowerCase() == _this.collectionChain.toLowerCase();
|
|
@@ -710382,15 +710408,12 @@ function generateTemplate(record) {
|
|
|
710382
710408
|
if (!allowedChain) {
|
|
710383
710409
|
message = `Found ${firstAsset.coin} asset, expected ${_this.collectionChain} asset.`;
|
|
710384
710410
|
}
|
|
710385
|
-
const
|
|
710386
|
-
if (!
|
|
710411
|
+
const allowedProject = firstAsset.project == recordName;
|
|
710412
|
+
if (!allowedProject) {
|
|
710387
710413
|
message = (message ? `${message} ` : '') +
|
|
710388
710414
|
`Found asset from ${firstAsset.project} collection, expected asset from ${recordName} collection.`;
|
|
710389
710415
|
}
|
|
710390
|
-
allowed = allowedChain &&
|
|
710391
|
-
}
|
|
710392
|
-
else { // XCP
|
|
710393
|
-
allowed = firstAsset.project == _this.name && firstAsset.balance == 1;
|
|
710416
|
+
allowed = allowedChain && allowedProject;
|
|
710394
710417
|
}
|
|
710395
710418
|
if (message && msgCallback) {
|
|
710396
710419
|
msgCallback(message);
|
package/dist/index.js
CHANGED
|
@@ -35,7 +35,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
35
35
|
const bignumber_1 = require("@ethersproject/bignumber");
|
|
36
36
|
const utils_1 = require("./utils");
|
|
37
37
|
const derive_1 = require("./derive");
|
|
38
|
-
const SDK_VERSION = '1.9.
|
|
38
|
+
const SDK_VERSION = '1.9.15';
|
|
39
39
|
class EmblemVaultSDK {
|
|
40
40
|
constructor(apiKey, baseUrl) {
|
|
41
41
|
this.apiKey = apiKey;
|
|
@@ -428,6 +428,17 @@ class EmblemVaultSDK {
|
|
|
428
428
|
value: Number(quote),
|
|
429
429
|
gasPrice: gasPrice, // Use the current gas price
|
|
430
430
|
gas: gasLimit // Use the estimated gas limit
|
|
431
|
+
}).on('transactionHash', (hash) => {
|
|
432
|
+
if (callback)
|
|
433
|
+
callback(`Transaction submitted. Hash`, hash);
|
|
434
|
+
})
|
|
435
|
+
.on('confirmation', (confirmationNumber, receipt) => {
|
|
436
|
+
if (callback)
|
|
437
|
+
callback(`Mint Complete. Confirmation Number`, confirmationNumber);
|
|
438
|
+
})
|
|
439
|
+
.on('error', (error) => {
|
|
440
|
+
if (callback)
|
|
441
|
+
callback(`Transaction Error`, error.message);
|
|
431
442
|
});
|
|
432
443
|
if (callback) {
|
|
433
444
|
callback('Mint Complete');
|
|
@@ -455,6 +466,17 @@ class EmblemVaultSDK {
|
|
|
455
466
|
from: accounts[0],
|
|
456
467
|
gasPrice: gasPrice,
|
|
457
468
|
gas: estimatedGas
|
|
469
|
+
}).on('transactionHash', (hash) => {
|
|
470
|
+
if (callback)
|
|
471
|
+
callback(`Transaction submitted. Hash`, hash);
|
|
472
|
+
})
|
|
473
|
+
.on('confirmation', (confirmationNumber, receipt) => {
|
|
474
|
+
if (callback)
|
|
475
|
+
callback(`Burn Complete. Confirmation Number`, confirmationNumber);
|
|
476
|
+
})
|
|
477
|
+
.on('error', (error) => {
|
|
478
|
+
if (callback)
|
|
479
|
+
callback(`Transaction Error`, error.message);
|
|
458
480
|
});
|
|
459
481
|
if (callback) {
|
|
460
482
|
callback('Burn Complete');
|
package/dist/utils.js
CHANGED
|
@@ -29,7 +29,7 @@ function projectsFromMetadataJson() {
|
|
|
29
29
|
for (var key in exports.NFT_DATA) {
|
|
30
30
|
const projectName = exports.NFT_DATA[key]["projectName"];
|
|
31
31
|
if (!projects.includes(projectName)) {
|
|
32
|
-
projects.push();
|
|
32
|
+
projects.push(projectName);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
return projects;
|
|
@@ -244,21 +244,23 @@ function generateTemplate(record) {
|
|
|
244
244
|
*
|
|
245
245
|
* @param {Array} data - data is a list of balance Value objects
|
|
246
246
|
* (see Value's interface definition in emblemvault.io-v3)
|
|
247
|
+
* @param {_this} _this is one of the curatedContract returned by `fetchCuratedContracts`.
|
|
248
|
+
* It should be further embellished with tokenId and serialNumber properties.
|
|
247
249
|
* @param {function} - msgCallback should be a function that takes a string message
|
|
248
250
|
*/
|
|
249
251
|
allowed: (data, _this, msgCallback = null) => {
|
|
250
252
|
var _a;
|
|
251
|
-
if (
|
|
253
|
+
if (recordName == "Embels") {
|
|
254
|
+
return true;
|
|
255
|
+
}
|
|
256
|
+
if ((!data || data.length == 0)) {
|
|
252
257
|
return false;
|
|
253
258
|
}
|
|
254
259
|
let allowed = false;
|
|
255
260
|
let firstAsset = data[0];
|
|
256
261
|
let assetName = (firstAsset === null || firstAsset === void 0 ? void 0 : firstAsset.name) ? firstAsset.name : "";
|
|
257
262
|
let message = null;
|
|
258
|
-
if (recordName == "
|
|
259
|
-
allowed = true;
|
|
260
|
-
}
|
|
261
|
-
else if (recordName == "Cursed Ordinal") {
|
|
263
|
+
if (recordName == "Cursed Ordinal") {
|
|
262
264
|
if (data && data.length > 0) {
|
|
263
265
|
let allowedCoin = firstAsset.content_type != "application/json" && firstAsset.coin == "cursedordinalsbtc";
|
|
264
266
|
let pieces = assetName.split(' ');
|
|
@@ -316,7 +318,9 @@ function generateTemplate(record) {
|
|
|
316
318
|
allowed = firstAsset.coin == "ordinalsbtc" && firstAsset.balance == 1 && firstAsset.project == "DeGods";
|
|
317
319
|
}
|
|
318
320
|
else if (PROJECTS_DATA.includes(recordName)) { // XCP
|
|
319
|
-
allowed = !!exports.NFT_DATA[assetName] &&
|
|
321
|
+
allowed = !!exports.NFT_DATA[assetName] &&
|
|
322
|
+
exports.NFT_DATA[assetName]["projectName"].toLowerCase() == recordName.toLowerCase() &&
|
|
323
|
+
firstAsset.project == _this.name && firstAsset.balance == 1;
|
|
320
324
|
}
|
|
321
325
|
else if (_this.vaultCollectionType && _this.vaultCollectionType == "protocol") {
|
|
322
326
|
allowed = firstAsset.coin.toLowerCase() == _this.collectionChain.toLowerCase();
|
|
@@ -329,15 +333,12 @@ function generateTemplate(record) {
|
|
|
329
333
|
if (!allowedChain) {
|
|
330
334
|
message = `Found ${firstAsset.coin} asset, expected ${_this.collectionChain} asset.`;
|
|
331
335
|
}
|
|
332
|
-
const
|
|
333
|
-
if (!
|
|
336
|
+
const allowedProject = firstAsset.project == recordName;
|
|
337
|
+
if (!allowedProject) {
|
|
334
338
|
message = (message ? `${message} ` : '') +
|
|
335
339
|
`Found asset from ${firstAsset.project} collection, expected asset from ${recordName} collection.`;
|
|
336
340
|
}
|
|
337
|
-
allowed = allowedChain &&
|
|
338
|
-
}
|
|
339
|
-
else { // XCP
|
|
340
|
-
allowed = firstAsset.project == _this.name && firstAsset.balance == 1;
|
|
341
|
+
allowed = allowedChain && allowedProject;
|
|
341
342
|
}
|
|
342
343
|
if (message && msgCallback) {
|
|
343
344
|
msgCallback(message);
|
package/docs/bundle.js
CHANGED
|
@@ -709476,7 +709476,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
709476
709476
|
const bignumber_1 = require("@ethersproject/bignumber");
|
|
709477
709477
|
const utils_1 = require("./utils");
|
|
709478
709478
|
const derive_1 = require("./derive");
|
|
709479
|
-
const SDK_VERSION = '1.9.
|
|
709479
|
+
const SDK_VERSION = '1.9.15';
|
|
709480
709480
|
class EmblemVaultSDK {
|
|
709481
709481
|
constructor(apiKey, baseUrl) {
|
|
709482
709482
|
this.apiKey = apiKey;
|
|
@@ -709869,6 +709869,17 @@ class EmblemVaultSDK {
|
|
|
709869
709869
|
value: Number(quote),
|
|
709870
709870
|
gasPrice: gasPrice, // Use the current gas price
|
|
709871
709871
|
gas: gasLimit // Use the estimated gas limit
|
|
709872
|
+
}).on('transactionHash', (hash) => {
|
|
709873
|
+
if (callback)
|
|
709874
|
+
callback(`Transaction submitted. Hash`, hash);
|
|
709875
|
+
})
|
|
709876
|
+
.on('confirmation', (confirmationNumber, receipt) => {
|
|
709877
|
+
if (callback)
|
|
709878
|
+
callback(`Mint Complete. Confirmation Number`, confirmationNumber);
|
|
709879
|
+
})
|
|
709880
|
+
.on('error', (error) => {
|
|
709881
|
+
if (callback)
|
|
709882
|
+
callback(`Transaction Error`, error.message);
|
|
709872
709883
|
});
|
|
709873
709884
|
if (callback) {
|
|
709874
709885
|
callback('Mint Complete');
|
|
@@ -709896,6 +709907,17 @@ class EmblemVaultSDK {
|
|
|
709896
709907
|
from: accounts[0],
|
|
709897
709908
|
gasPrice: gasPrice,
|
|
709898
709909
|
gas: estimatedGas
|
|
709910
|
+
}).on('transactionHash', (hash) => {
|
|
709911
|
+
if (callback)
|
|
709912
|
+
callback(`Transaction submitted. Hash`, hash);
|
|
709913
|
+
})
|
|
709914
|
+
.on('confirmation', (confirmationNumber, receipt) => {
|
|
709915
|
+
if (callback)
|
|
709916
|
+
callback(`Burn Complete. Confirmation Number`, confirmationNumber);
|
|
709917
|
+
})
|
|
709918
|
+
.on('error', (error) => {
|
|
709919
|
+
if (callback)
|
|
709920
|
+
callback(`Transaction Error`, error.message);
|
|
709899
709921
|
});
|
|
709900
709922
|
if (callback) {
|
|
709901
709923
|
callback('Burn Complete');
|
|
@@ -710082,7 +710104,7 @@ function projectsFromMetadataJson() {
|
|
|
710082
710104
|
for (var key in exports.NFT_DATA) {
|
|
710083
710105
|
const projectName = exports.NFT_DATA[key]["projectName"];
|
|
710084
710106
|
if (!projects.includes(projectName)) {
|
|
710085
|
-
projects.push();
|
|
710107
|
+
projects.push(projectName);
|
|
710086
710108
|
}
|
|
710087
710109
|
}
|
|
710088
710110
|
return projects;
|
|
@@ -710297,21 +710319,23 @@ function generateTemplate(record) {
|
|
|
710297
710319
|
*
|
|
710298
710320
|
* @param {Array} data - data is a list of balance Value objects
|
|
710299
710321
|
* (see Value's interface definition in emblemvault.io-v3)
|
|
710322
|
+
* @param {_this} _this is one of the curatedContract returned by `fetchCuratedContracts`.
|
|
710323
|
+
* It should be further embellished with tokenId and serialNumber properties.
|
|
710300
710324
|
* @param {function} - msgCallback should be a function that takes a string message
|
|
710301
710325
|
*/
|
|
710302
710326
|
allowed: (data, _this, msgCallback = null) => {
|
|
710303
710327
|
var _a;
|
|
710304
|
-
if (
|
|
710328
|
+
if (recordName == "Embels") {
|
|
710329
|
+
return true;
|
|
710330
|
+
}
|
|
710331
|
+
if ((!data || data.length == 0)) {
|
|
710305
710332
|
return false;
|
|
710306
710333
|
}
|
|
710307
710334
|
let allowed = false;
|
|
710308
710335
|
let firstAsset = data[0];
|
|
710309
710336
|
let assetName = (firstAsset === null || firstAsset === void 0 ? void 0 : firstAsset.name) ? firstAsset.name : "";
|
|
710310
710337
|
let message = null;
|
|
710311
|
-
if (recordName == "
|
|
710312
|
-
allowed = true;
|
|
710313
|
-
}
|
|
710314
|
-
else if (recordName == "Cursed Ordinal") {
|
|
710338
|
+
if (recordName == "Cursed Ordinal") {
|
|
710315
710339
|
if (data && data.length > 0) {
|
|
710316
710340
|
let allowedCoin = firstAsset.content_type != "application/json" && firstAsset.coin == "cursedordinalsbtc";
|
|
710317
710341
|
let pieces = assetName.split(' ');
|
|
@@ -710369,7 +710393,9 @@ function generateTemplate(record) {
|
|
|
710369
710393
|
allowed = firstAsset.coin == "ordinalsbtc" && firstAsset.balance == 1 && firstAsset.project == "DeGods";
|
|
710370
710394
|
}
|
|
710371
710395
|
else if (PROJECTS_DATA.includes(recordName)) { // XCP
|
|
710372
|
-
allowed = !!exports.NFT_DATA[assetName] &&
|
|
710396
|
+
allowed = !!exports.NFT_DATA[assetName] &&
|
|
710397
|
+
exports.NFT_DATA[assetName]["projectName"].toLowerCase() == recordName.toLowerCase() &&
|
|
710398
|
+
firstAsset.project == _this.name && firstAsset.balance == 1;
|
|
710373
710399
|
}
|
|
710374
710400
|
else if (_this.vaultCollectionType && _this.vaultCollectionType == "protocol") {
|
|
710375
710401
|
allowed = firstAsset.coin.toLowerCase() == _this.collectionChain.toLowerCase();
|
|
@@ -710382,15 +710408,12 @@ function generateTemplate(record) {
|
|
|
710382
710408
|
if (!allowedChain) {
|
|
710383
710409
|
message = `Found ${firstAsset.coin} asset, expected ${_this.collectionChain} asset.`;
|
|
710384
710410
|
}
|
|
710385
|
-
const
|
|
710386
|
-
if (!
|
|
710411
|
+
const allowedProject = firstAsset.project == recordName;
|
|
710412
|
+
if (!allowedProject) {
|
|
710387
710413
|
message = (message ? `${message} ` : '') +
|
|
710388
710414
|
`Found asset from ${firstAsset.project} collection, expected asset from ${recordName} collection.`;
|
|
710389
710415
|
}
|
|
710390
|
-
allowed = allowedChain &&
|
|
710391
|
-
}
|
|
710392
|
-
else { // XCP
|
|
710393
|
-
allowed = firstAsset.project == _this.name && firstAsset.balance == 1;
|
|
710416
|
+
allowed = allowedChain && allowedProject;
|
|
710394
710417
|
}
|
|
710395
710418
|
if (message && msgCallback) {
|
|
710396
710419
|
msgCallback(message);
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -354,6 +354,14 @@ class EmblemVaultSDK {
|
|
|
354
354
|
value: Number(quote),
|
|
355
355
|
gasPrice: gasPrice, // Use the current gas price
|
|
356
356
|
gas: gasLimit // Use the estimated gas limit
|
|
357
|
+
}).on('transactionHash', (hash: any) => {
|
|
358
|
+
if (callback) callback(`Transaction submitted. Hash`, hash);
|
|
359
|
+
})
|
|
360
|
+
.on('confirmation', (confirmationNumber: any, receipt: any) => {
|
|
361
|
+
if (callback) callback(`Mint Complete. Confirmation Number`, confirmationNumber);
|
|
362
|
+
})
|
|
363
|
+
.on('error', (error: { message: any; }) => {
|
|
364
|
+
if (callback) callback(`Transaction Error`, error.message );
|
|
357
365
|
});
|
|
358
366
|
|
|
359
367
|
if (callback) { callback('Mint Complete') }
|
|
@@ -381,6 +389,14 @@ class EmblemVaultSDK {
|
|
|
381
389
|
from: accounts[0],
|
|
382
390
|
gasPrice: gasPrice,
|
|
383
391
|
gas: estimatedGas
|
|
392
|
+
}).on('transactionHash', (hash: any) => {
|
|
393
|
+
if (callback) callback(`Transaction submitted. Hash`, hash);
|
|
394
|
+
})
|
|
395
|
+
.on('confirmation', (confirmationNumber: any, receipt: any) => {
|
|
396
|
+
if (callback) callback(`Burn Complete. Confirmation Number`, confirmationNumber);
|
|
397
|
+
})
|
|
398
|
+
.on('error', (error: { message: any; }) => {
|
|
399
|
+
if (callback) callback(`Transaction Error`, error.message );
|
|
384
400
|
});
|
|
385
401
|
|
|
386
402
|
if (callback) { callback('Burn Complete')}
|
package/src/utils.ts
CHANGED
|
@@ -17,7 +17,7 @@ function projectsFromMetadataJson() {
|
|
|
17
17
|
for (var key in NFT_DATA) {
|
|
18
18
|
const projectName = NFT_DATA[key]["projectName"]
|
|
19
19
|
if (!projects.includes(projectName)) {
|
|
20
|
-
projects.push()
|
|
20
|
+
projects.push(projectName)
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
return projects
|
|
@@ -230,10 +230,16 @@ export function generateTemplate(record: any) {
|
|
|
230
230
|
*
|
|
231
231
|
* @param {Array} data - data is a list of balance Value objects
|
|
232
232
|
* (see Value's interface definition in emblemvault.io-v3)
|
|
233
|
+
* @param {_this} _this is one of the curatedContract returned by `fetchCuratedContracts`.
|
|
234
|
+
* It should be further embellished with tokenId and serialNumber properties.
|
|
233
235
|
* @param {function} - msgCallback should be a function that takes a string message
|
|
234
236
|
*/
|
|
235
237
|
allowed: (data: any[], _this: any, msgCallback: any = null) => {
|
|
236
|
-
if (
|
|
238
|
+
if (recordName == "Embels"){
|
|
239
|
+
return true
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
if ((!data || data.length == 0) ) {
|
|
237
243
|
return false
|
|
238
244
|
}
|
|
239
245
|
|
|
@@ -241,10 +247,8 @@ export function generateTemplate(record: any) {
|
|
|
241
247
|
let firstAsset = data[0]
|
|
242
248
|
let assetName = firstAsset?.name ? firstAsset.name : ""
|
|
243
249
|
let message = null
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
}
|
|
247
|
-
else if (recordName == "Cursed Ordinal") {
|
|
250
|
+
|
|
251
|
+
if (recordName == "Cursed Ordinal") {
|
|
248
252
|
if (data && data.length > 0) {
|
|
249
253
|
let allowedCoin = firstAsset.content_type != "application/json" && firstAsset.coin == "cursedordinalsbtc"
|
|
250
254
|
let pieces = assetName.split(' ')
|
|
@@ -291,7 +295,9 @@ export function generateTemplate(record: any) {
|
|
|
291
295
|
} else if (recordName == "Bitcoin DeGods") {
|
|
292
296
|
allowed = firstAsset.coin == "ordinalsbtc" && firstAsset.balance == 1 && firstAsset.project == "DeGods"
|
|
293
297
|
} else if (PROJECTS_DATA.includes(recordName)) { // XCP
|
|
294
|
-
allowed = !!NFT_DATA[assetName] &&
|
|
298
|
+
allowed = !!NFT_DATA[assetName] &&
|
|
299
|
+
NFT_DATA[assetName]["projectName"].toLowerCase() == recordName.toLowerCase() &&
|
|
300
|
+
firstAsset.project == _this.name && firstAsset.balance == 1;
|
|
295
301
|
} else if (_this.vaultCollectionType && _this.vaultCollectionType == "protocol") {
|
|
296
302
|
allowed = firstAsset.coin.toLowerCase() == _this.collectionChain.toLowerCase()
|
|
297
303
|
if(!allowed){
|
|
@@ -302,14 +308,12 @@ export function generateTemplate(record: any) {
|
|
|
302
308
|
if(!allowedChain) {
|
|
303
309
|
message = `Found ${firstAsset.coin} asset, expected ${_this.collectionChain} asset.`
|
|
304
310
|
}
|
|
305
|
-
const
|
|
306
|
-
if(!
|
|
311
|
+
const allowedProject = firstAsset.project == recordName
|
|
312
|
+
if(!allowedProject){
|
|
307
313
|
message = (message ? `${message} ` : '') +
|
|
308
314
|
`Found asset from ${firstAsset.project} collection, expected asset from ${recordName} collection.`
|
|
309
315
|
}
|
|
310
|
-
allowed = allowedChain &&
|
|
311
|
-
} else { // XCP
|
|
312
|
-
allowed = firstAsset.project == _this.name && firstAsset.balance == 1;
|
|
316
|
+
allowed = allowedChain && allowedProject
|
|
313
317
|
}
|
|
314
318
|
|
|
315
319
|
if (message && msgCallback) {
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import EmblemVaultSDK from '../src/';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
|
|
5
|
+
describe('Allowed Function for Bells', () => {
|
|
6
|
+
const sdk = new EmblemVaultSDK('DEMO_KEY');
|
|
7
|
+
|
|
8
|
+
it('Does not allow empty balance', async () => {
|
|
9
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Bells')
|
|
10
|
+
expect(curatedContract.allowed(null, curatedContract)).toBeFalsy()
|
|
11
|
+
expect(curatedContract.allowed([], curatedContract)).toBeFalsy()
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it('Requires balance to be greater than zero', async () => {
|
|
15
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Bells')
|
|
16
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/bells/balance.json"))
|
|
17
|
+
balanceValues[0].balance = 0
|
|
18
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('Requires balance to be an integer', async () => {
|
|
22
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Bells')
|
|
23
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/bells/balance.json"))
|
|
24
|
+
balanceValues[0].balance = 1.5
|
|
25
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it('Requires name to be `Bel`', async () => {
|
|
29
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Bells')
|
|
30
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/bells/balance.json"))
|
|
31
|
+
balanceValues[0].name = 'invalid name'
|
|
32
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it('Does not allow non-bel assets as first value', async () => {
|
|
36
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Bells')
|
|
37
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/bells/balance-with-non-bell-first.json"))
|
|
38
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('Allows non-bel assets if not first', async () => {
|
|
42
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Bells')
|
|
43
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/bells/balance-with-non-bell.json"))
|
|
44
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
it('Allows valid balances', async () => {
|
|
48
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Bells')
|
|
49
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/bells/balance.json"))
|
|
50
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
)
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import EmblemVaultSDK from '../src/';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
|
|
5
|
+
describe('Allowed Function for Bitcoin DeGods', () => {
|
|
6
|
+
const sdk = new EmblemVaultSDK('DEMO_KEY');
|
|
7
|
+
|
|
8
|
+
it('Does not allow empty balance', async () => {
|
|
9
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Bitcoin DeGods')
|
|
10
|
+
expect(curatedContract.allowed(null, curatedContract)).toBeFalsy()
|
|
11
|
+
expect(curatedContract.allowed([], curatedContract)).toBeFalsy()
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it('Requires coin to be ordinalsbtc', async () => {
|
|
15
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Bitcoin DeGods')
|
|
16
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/bitcoin-degods/balance.json"))
|
|
17
|
+
balanceValues[0].coin = 'invalid value'
|
|
18
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('Requires balance to be 1', async () => {
|
|
22
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Bitcoin DeGods')
|
|
23
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/bitcoin-degods/balance.json"))
|
|
24
|
+
balanceValues[0].balance = 2
|
|
25
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it('Requires project to be DeGods', async () => {
|
|
29
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Bitcoin DeGods')
|
|
30
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/bitcoin-degods/balance.json"))
|
|
31
|
+
balanceValues[0].project = 'invalid project'
|
|
32
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it('Does not allow non-ordinalsbtc as first coin', async () => {
|
|
36
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Bitcoin DeGods')
|
|
37
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/bitcoin-degods/balance-with-non-degods-first.json"))
|
|
38
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('Allows non-ordinalsbtc if not first coin', async () => {
|
|
42
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Bitcoin DeGods')
|
|
43
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/bitcoin-degods/balance-with-non-degods.json"))
|
|
44
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
it('Allows valid balances', async () => {
|
|
48
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Bitcoin DeGods')
|
|
49
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/bitcoin-degods/balance.json"))
|
|
50
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import EmblemVaultSDK from '../src/';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
|
|
5
|
+
describe('Allowed Function for BitcoinOrdinals', () => {
|
|
6
|
+
const sdk = new EmblemVaultSDK('DEMO_KEY');
|
|
7
|
+
|
|
8
|
+
it('Does not allow empty balance', async () => {
|
|
9
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('BitcoinOrdinals')
|
|
10
|
+
expect(curatedContract.allowed(null, curatedContract)).toBeFalsy()
|
|
11
|
+
expect(curatedContract.allowed([], curatedContract)).toBeFalsy()
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it('Allows native balance as first value', async () => {
|
|
15
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('BitcoinOrdinals')
|
|
16
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/bitcoin-ordinals/balance-with-native-first.json"))
|
|
17
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
it('Does not allow only native balances', async () => {
|
|
21
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('BitcoinOrdinals')
|
|
22
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/bitcoin-ordinals/balance-with-only-native.json"))
|
|
23
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
it('Requires first non-native balance to be a bitcoin ordinal', async () => {
|
|
27
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('BitcoinOrdinals')
|
|
28
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/cursed-ordinals/balance-with-native-first.json"))
|
|
29
|
+
balanceValues[1].coin = 'invalid coin'
|
|
30
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it('Does not allow incorrect coin', async () => {
|
|
34
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('BitcoinOrdinals')
|
|
35
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/bitcoin-ordinals/balance.json"))
|
|
36
|
+
balanceValues[0].coin = "invalid coin"
|
|
37
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
it('Allows valid balances', async () => {
|
|
41
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('BitcoinOrdinals')
|
|
42
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/bitcoin-ordinals/balance.json"))
|
|
43
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
)
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import EmblemVaultSDK from '../src/';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
|
|
5
|
+
describe('Allowed Function for Counterparty', () => {
|
|
6
|
+
const sdk = new EmblemVaultSDK('DEMO_KEY');
|
|
7
|
+
|
|
8
|
+
it('Does not allow empty balance', async () => {
|
|
9
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Counterparty')
|
|
10
|
+
expect(curatedContract.allowed(null, curatedContract)).toBeFalsy()
|
|
11
|
+
expect(curatedContract.allowed([], curatedContract)).toBeFalsy()
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it('Does not allow more than one asset', async () => {
|
|
15
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Counterparty')
|
|
16
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/counterparty/balance-with-multiple.json"))
|
|
17
|
+
balanceValues[0].coin = 'invalid coin'
|
|
18
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('Does not allow non-native coin', async () => {
|
|
22
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Counterparty')
|
|
23
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/counterparty/balance.json"))
|
|
24
|
+
balanceValues[0].coin = 'invalid coin'
|
|
25
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeFalsy()
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it('Allows any native coin', async () => {
|
|
29
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Counterparty')
|
|
30
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/counterparty/balance.json"))
|
|
31
|
+
for (var nativeAsset of curatedContract.nativeAssets) {
|
|
32
|
+
balanceValues[0].coin = nativeAsset
|
|
33
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
it('Allows valid balance', async () => {
|
|
38
|
+
const curatedContract: any = await sdk.fetchCuratedContractByName('Counterparty')
|
|
39
|
+
const balanceValues = JSON.parse(fs.readFileSync("tests/fixtures/counterparty/balance.json"))
|
|
40
|
+
expect(curatedContract.allowed(balanceValues, curatedContract)).toBeTruthy()
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
)
|