emblem-vault-sdk 1.7.13 → 1.8.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/abi/abi.json +19 -0
- package/dist/bundle.js +52 -2
- package/dist/index.js +21 -1
- package/dist/utils.js +12 -1
- package/docs/bels.html +2 -2
- package/docs/bundle.js +52 -2
- package/package.json +1 -1
- package/src/abi/abi.json +20 -1
- package/src/index.ts +19 -1
- package/src/utils.ts +8 -0
- package/types/index.d.ts +2 -0
- package/types/utils.d.ts +1 -0
package/dist/abi/abi.json
CHANGED
|
@@ -74,5 +74,24 @@
|
|
|
74
74
|
"stateMutability": "payable",
|
|
75
75
|
"type": "function"
|
|
76
76
|
}
|
|
77
|
+
],
|
|
78
|
+
"legacy": [
|
|
79
|
+
{
|
|
80
|
+
"inputs": [{ "internalType": "address", "name": "_owner", "type": "address" }],
|
|
81
|
+
"name": "getOwnerNFTCount",
|
|
82
|
+
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
|
|
83
|
+
"stateMutability": "view",
|
|
84
|
+
"type": "function"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"inputs": [
|
|
88
|
+
{ "internalType": "address", "name": "_owner", "type": "address" },
|
|
89
|
+
{ "internalType": "uint256", "name": "_index", "type": "uint256" }
|
|
90
|
+
],
|
|
91
|
+
"name": "tokenOfOwnerByIndex",
|
|
92
|
+
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
|
|
93
|
+
"stateMutability": "view",
|
|
94
|
+
"type": "function"
|
|
95
|
+
}
|
|
77
96
|
]
|
|
78
97
|
}
|
package/dist/bundle.js
CHANGED
|
@@ -75,6 +75,25 @@ module.exports={
|
|
|
75
75
|
"stateMutability": "payable",
|
|
76
76
|
"type": "function"
|
|
77
77
|
}
|
|
78
|
+
],
|
|
79
|
+
"legacy": [
|
|
80
|
+
{
|
|
81
|
+
"inputs": [{ "internalType": "address", "name": "_owner", "type": "address" }],
|
|
82
|
+
"name": "getOwnerNFTCount",
|
|
83
|
+
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
|
|
84
|
+
"stateMutability": "view",
|
|
85
|
+
"type": "function"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"inputs": [
|
|
89
|
+
{ "internalType": "address", "name": "_owner", "type": "address" },
|
|
90
|
+
{ "internalType": "uint256", "name": "_index", "type": "uint256" }
|
|
91
|
+
],
|
|
92
|
+
"name": "tokenOfOwnerByIndex",
|
|
93
|
+
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
|
|
94
|
+
"stateMutability": "view",
|
|
95
|
+
"type": "function"
|
|
96
|
+
}
|
|
78
97
|
]
|
|
79
98
|
}
|
|
80
99
|
|
|
@@ -709310,7 +709329,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
709310
709329
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
709311
709330
|
const bignumber_1 = require("@ethersproject/bignumber");
|
|
709312
709331
|
const utils_1 = require("./utils");
|
|
709313
|
-
const SDK_VERSION = '1.
|
|
709332
|
+
const SDK_VERSION = '1.8.0';
|
|
709314
709333
|
class EmblemVaultSDK {
|
|
709315
709334
|
constructor(apiKey, baseUrl) {
|
|
709316
709335
|
this.apiKey = apiKey;
|
|
@@ -709621,6 +709640,26 @@ class EmblemVaultSDK {
|
|
|
709621
709640
|
return yield (0, utils_1.checkContentType)(url);
|
|
709622
709641
|
});
|
|
709623
709642
|
}
|
|
709643
|
+
legacyBalanceFromContractByAddress(web3, address) {
|
|
709644
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
709645
|
+
let legacyContract = yield (0, utils_1.getLegacyContract)(web3);
|
|
709646
|
+
let balance = yield legacyContract.methods.getOwnerNFTCount(address).call();
|
|
709647
|
+
let tokenIds = [];
|
|
709648
|
+
for (let index = 0; index < balance; index++) {
|
|
709649
|
+
let tokenId = yield legacyContract.methods.tokenOfOwnerByIndex(address, index).call();
|
|
709650
|
+
tokenIds.push(Number(tokenId));
|
|
709651
|
+
}
|
|
709652
|
+
return tokenIds;
|
|
709653
|
+
});
|
|
709654
|
+
}
|
|
709655
|
+
refreshLegacyOwnership(web3, address) {
|
|
709656
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
709657
|
+
let myLegacy = yield this.legacyBalanceFromContractByAddress(web3, address);
|
|
709658
|
+
myLegacy.forEach((item) => __awaiter(this, void 0, void 0, function* () {
|
|
709659
|
+
let meta = yield this.fetchMetadata(item.toString());
|
|
709660
|
+
}));
|
|
709661
|
+
});
|
|
709662
|
+
}
|
|
709624
709663
|
}
|
|
709625
709664
|
if (typeof window !== 'undefined') {
|
|
709626
709665
|
window.EmblemVaultSDK = EmblemVaultSDK;
|
|
@@ -709642,7 +709681,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
709642
709681
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
709643
709682
|
};
|
|
709644
709683
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
709645
|
-
exports.COIN_TO_NETWORK = exports.checkContentType = exports.getHandlerContract = exports.getQuoteContractObject = exports.genericGuard = exports.templateGuard = exports.generateTemplate = exports.generateImageTemplate = exports.generateAttributeTemplate = exports.fetchData = exports.metadataAllProjects = exports.metadataObj2Arr = exports.evaluateFacts = exports.pad = exports.NFT_DATA = void 0;
|
|
709684
|
+
exports.COIN_TO_NETWORK = exports.checkContentType = exports.getLegacyContract = exports.getHandlerContract = exports.getQuoteContractObject = exports.genericGuard = exports.templateGuard = exports.generateTemplate = exports.generateImageTemplate = exports.generateAttributeTemplate = exports.fetchData = exports.metadataAllProjects = exports.metadataObj2Arr = exports.evaluateFacts = exports.pad = exports.NFT_DATA = void 0;
|
|
709646
709685
|
const metadata_json_1 = __importDefault(require("./curated/metadata.json"));
|
|
709647
709686
|
const abi_json_1 = __importDefault(require("./abi/abi.json"));
|
|
709648
709687
|
exports.NFT_DATA = metadata_json_1.default;
|
|
@@ -709887,6 +709926,9 @@ function generateTemplate(record) {
|
|
|
709887
709926
|
allowed = _this.nativeAssets.includes(data[0].coin);
|
|
709888
709927
|
}
|
|
709889
709928
|
}
|
|
709929
|
+
else if (recordName == "Bitcoin DeGods") {
|
|
709930
|
+
allowed = data && data.length > 0 && data[0].coin == "ordinalsbtc" && data[0].balance == 1 && data[0].project == "DeGods";
|
|
709931
|
+
}
|
|
709890
709932
|
else if (_this.vaultCollectionType && _this.vaultCollectionType == "protocol") {
|
|
709891
709933
|
allowed = data && data.length > 0 && data[0].coin.toLowerCase() == _this.collectionChain.toLowerCase() && data[0].project && data[0].project == recordName;
|
|
709892
709934
|
}
|
|
@@ -710172,6 +710214,14 @@ function getHandlerContract(web3) {
|
|
|
710172
710214
|
});
|
|
710173
710215
|
}
|
|
710174
710216
|
exports.getHandlerContract = getHandlerContract;
|
|
710217
|
+
function getLegacyContract(web3) {
|
|
710218
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
710219
|
+
let contractAddress = '0x82c7a8f707110f5fbb16184a5933e9f78a34c6ab';
|
|
710220
|
+
const handlerContract = new web3.eth.Contract(abi_json_1.default.legacy, contractAddress);
|
|
710221
|
+
return handlerContract;
|
|
710222
|
+
});
|
|
710223
|
+
}
|
|
710224
|
+
exports.getLegacyContract = getLegacyContract;
|
|
710175
710225
|
function checkContentType(url) {
|
|
710176
710226
|
return new Promise((resolve, reject) => {
|
|
710177
710227
|
let returnVal = { valid: false };
|
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.8.0';
|
|
38
38
|
class EmblemVaultSDK {
|
|
39
39
|
constructor(apiKey, baseUrl) {
|
|
40
40
|
this.apiKey = apiKey;
|
|
@@ -345,6 +345,26 @@ class EmblemVaultSDK {
|
|
|
345
345
|
return yield (0, utils_1.checkContentType)(url);
|
|
346
346
|
});
|
|
347
347
|
}
|
|
348
|
+
legacyBalanceFromContractByAddress(web3, address) {
|
|
349
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
350
|
+
let legacyContract = yield (0, utils_1.getLegacyContract)(web3);
|
|
351
|
+
let balance = yield legacyContract.methods.getOwnerNFTCount(address).call();
|
|
352
|
+
let tokenIds = [];
|
|
353
|
+
for (let index = 0; index < balance; index++) {
|
|
354
|
+
let tokenId = yield legacyContract.methods.tokenOfOwnerByIndex(address, index).call();
|
|
355
|
+
tokenIds.push(Number(tokenId));
|
|
356
|
+
}
|
|
357
|
+
return tokenIds;
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
refreshLegacyOwnership(web3, address) {
|
|
361
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
362
|
+
let myLegacy = yield this.legacyBalanceFromContractByAddress(web3, address);
|
|
363
|
+
myLegacy.forEach((item) => __awaiter(this, void 0, void 0, function* () {
|
|
364
|
+
let meta = yield this.fetchMetadata(item.toString());
|
|
365
|
+
}));
|
|
366
|
+
});
|
|
367
|
+
}
|
|
348
368
|
}
|
|
349
369
|
if (typeof window !== 'undefined') {
|
|
350
370
|
window.EmblemVaultSDK = EmblemVaultSDK;
|
package/dist/utils.js
CHANGED
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.COIN_TO_NETWORK = exports.checkContentType = exports.getHandlerContract = exports.getQuoteContractObject = exports.genericGuard = exports.templateGuard = exports.generateTemplate = exports.generateImageTemplate = exports.generateAttributeTemplate = exports.fetchData = exports.metadataAllProjects = exports.metadataObj2Arr = exports.evaluateFacts = exports.pad = exports.NFT_DATA = void 0;
|
|
15
|
+
exports.COIN_TO_NETWORK = exports.checkContentType = exports.getLegacyContract = exports.getHandlerContract = exports.getQuoteContractObject = exports.genericGuard = exports.templateGuard = exports.generateTemplate = exports.generateImageTemplate = exports.generateAttributeTemplate = exports.fetchData = exports.metadataAllProjects = exports.metadataObj2Arr = exports.evaluateFacts = exports.pad = exports.NFT_DATA = void 0;
|
|
16
16
|
const metadata_json_1 = __importDefault(require("./curated/metadata.json"));
|
|
17
17
|
const abi_json_1 = __importDefault(require("./abi/abi.json"));
|
|
18
18
|
exports.NFT_DATA = metadata_json_1.default;
|
|
@@ -257,6 +257,9 @@ function generateTemplate(record) {
|
|
|
257
257
|
allowed = _this.nativeAssets.includes(data[0].coin);
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
|
+
else if (recordName == "Bitcoin DeGods") {
|
|
261
|
+
allowed = data && data.length > 0 && data[0].coin == "ordinalsbtc" && data[0].balance == 1 && data[0].project == "DeGods";
|
|
262
|
+
}
|
|
260
263
|
else if (_this.vaultCollectionType && _this.vaultCollectionType == "protocol") {
|
|
261
264
|
allowed = data && data.length > 0 && data[0].coin.toLowerCase() == _this.collectionChain.toLowerCase() && data[0].project && data[0].project == recordName;
|
|
262
265
|
}
|
|
@@ -542,6 +545,14 @@ function getHandlerContract(web3) {
|
|
|
542
545
|
});
|
|
543
546
|
}
|
|
544
547
|
exports.getHandlerContract = getHandlerContract;
|
|
548
|
+
function getLegacyContract(web3) {
|
|
549
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
550
|
+
let contractAddress = '0x82c7a8f707110f5fbb16184a5933e9f78a34c6ab';
|
|
551
|
+
const handlerContract = new web3.eth.Contract(abi_json_1.default.legacy, contractAddress);
|
|
552
|
+
return handlerContract;
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
exports.getLegacyContract = getLegacyContract;
|
|
545
556
|
function checkContentType(url) {
|
|
546
557
|
return new Promise((resolve, reject) => {
|
|
547
558
|
let returnVal = { valid: false };
|
package/docs/bels.html
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
</head>
|
|
15
15
|
<body>
|
|
16
16
|
<h1>Embels Emblem Steps</h1>
|
|
17
|
-
<script src="
|
|
17
|
+
<script src="./-bundle.js"></script>
|
|
18
18
|
<script>
|
|
19
19
|
const sdk = new EmblemVaultSDK('demo'); // Instantiate SDK
|
|
20
20
|
|
|
@@ -77,4 +77,4 @@
|
|
|
77
77
|
</script>
|
|
78
78
|
<pre id="log"></pre>
|
|
79
79
|
</body>
|
|
80
|
-
</html>
|
|
80
|
+
</html>
|
package/docs/bundle.js
CHANGED
|
@@ -75,6 +75,25 @@ module.exports={
|
|
|
75
75
|
"stateMutability": "payable",
|
|
76
76
|
"type": "function"
|
|
77
77
|
}
|
|
78
|
+
],
|
|
79
|
+
"legacy": [
|
|
80
|
+
{
|
|
81
|
+
"inputs": [{ "internalType": "address", "name": "_owner", "type": "address" }],
|
|
82
|
+
"name": "getOwnerNFTCount",
|
|
83
|
+
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
|
|
84
|
+
"stateMutability": "view",
|
|
85
|
+
"type": "function"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"inputs": [
|
|
89
|
+
{ "internalType": "address", "name": "_owner", "type": "address" },
|
|
90
|
+
{ "internalType": "uint256", "name": "_index", "type": "uint256" }
|
|
91
|
+
],
|
|
92
|
+
"name": "tokenOfOwnerByIndex",
|
|
93
|
+
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
|
|
94
|
+
"stateMutability": "view",
|
|
95
|
+
"type": "function"
|
|
96
|
+
}
|
|
78
97
|
]
|
|
79
98
|
}
|
|
80
99
|
|
|
@@ -709310,7 +709329,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
709310
709329
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
709311
709330
|
const bignumber_1 = require("@ethersproject/bignumber");
|
|
709312
709331
|
const utils_1 = require("./utils");
|
|
709313
|
-
const SDK_VERSION = '1.
|
|
709332
|
+
const SDK_VERSION = '1.8.0';
|
|
709314
709333
|
class EmblemVaultSDK {
|
|
709315
709334
|
constructor(apiKey, baseUrl) {
|
|
709316
709335
|
this.apiKey = apiKey;
|
|
@@ -709621,6 +709640,26 @@ class EmblemVaultSDK {
|
|
|
709621
709640
|
return yield (0, utils_1.checkContentType)(url);
|
|
709622
709641
|
});
|
|
709623
709642
|
}
|
|
709643
|
+
legacyBalanceFromContractByAddress(web3, address) {
|
|
709644
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
709645
|
+
let legacyContract = yield (0, utils_1.getLegacyContract)(web3);
|
|
709646
|
+
let balance = yield legacyContract.methods.getOwnerNFTCount(address).call();
|
|
709647
|
+
let tokenIds = [];
|
|
709648
|
+
for (let index = 0; index < balance; index++) {
|
|
709649
|
+
let tokenId = yield legacyContract.methods.tokenOfOwnerByIndex(address, index).call();
|
|
709650
|
+
tokenIds.push(Number(tokenId));
|
|
709651
|
+
}
|
|
709652
|
+
return tokenIds;
|
|
709653
|
+
});
|
|
709654
|
+
}
|
|
709655
|
+
refreshLegacyOwnership(web3, address) {
|
|
709656
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
709657
|
+
let myLegacy = yield this.legacyBalanceFromContractByAddress(web3, address);
|
|
709658
|
+
myLegacy.forEach((item) => __awaiter(this, void 0, void 0, function* () {
|
|
709659
|
+
let meta = yield this.fetchMetadata(item.toString());
|
|
709660
|
+
}));
|
|
709661
|
+
});
|
|
709662
|
+
}
|
|
709624
709663
|
}
|
|
709625
709664
|
if (typeof window !== 'undefined') {
|
|
709626
709665
|
window.EmblemVaultSDK = EmblemVaultSDK;
|
|
@@ -709642,7 +709681,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
709642
709681
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
709643
709682
|
};
|
|
709644
709683
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
709645
|
-
exports.COIN_TO_NETWORK = exports.checkContentType = exports.getHandlerContract = exports.getQuoteContractObject = exports.genericGuard = exports.templateGuard = exports.generateTemplate = exports.generateImageTemplate = exports.generateAttributeTemplate = exports.fetchData = exports.metadataAllProjects = exports.metadataObj2Arr = exports.evaluateFacts = exports.pad = exports.NFT_DATA = void 0;
|
|
709684
|
+
exports.COIN_TO_NETWORK = exports.checkContentType = exports.getLegacyContract = exports.getHandlerContract = exports.getQuoteContractObject = exports.genericGuard = exports.templateGuard = exports.generateTemplate = exports.generateImageTemplate = exports.generateAttributeTemplate = exports.fetchData = exports.metadataAllProjects = exports.metadataObj2Arr = exports.evaluateFacts = exports.pad = exports.NFT_DATA = void 0;
|
|
709646
709685
|
const metadata_json_1 = __importDefault(require("./curated/metadata.json"));
|
|
709647
709686
|
const abi_json_1 = __importDefault(require("./abi/abi.json"));
|
|
709648
709687
|
exports.NFT_DATA = metadata_json_1.default;
|
|
@@ -709887,6 +709926,9 @@ function generateTemplate(record) {
|
|
|
709887
709926
|
allowed = _this.nativeAssets.includes(data[0].coin);
|
|
709888
709927
|
}
|
|
709889
709928
|
}
|
|
709929
|
+
else if (recordName == "Bitcoin DeGods") {
|
|
709930
|
+
allowed = data && data.length > 0 && data[0].coin == "ordinalsbtc" && data[0].balance == 1 && data[0].project == "DeGods";
|
|
709931
|
+
}
|
|
709890
709932
|
else if (_this.vaultCollectionType && _this.vaultCollectionType == "protocol") {
|
|
709891
709933
|
allowed = data && data.length > 0 && data[0].coin.toLowerCase() == _this.collectionChain.toLowerCase() && data[0].project && data[0].project == recordName;
|
|
709892
709934
|
}
|
|
@@ -710172,6 +710214,14 @@ function getHandlerContract(web3) {
|
|
|
710172
710214
|
});
|
|
710173
710215
|
}
|
|
710174
710216
|
exports.getHandlerContract = getHandlerContract;
|
|
710217
|
+
function getLegacyContract(web3) {
|
|
710218
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
710219
|
+
let contractAddress = '0x82c7a8f707110f5fbb16184a5933e9f78a34c6ab';
|
|
710220
|
+
const handlerContract = new web3.eth.Contract(abi_json_1.default.legacy, contractAddress);
|
|
710221
|
+
return handlerContract;
|
|
710222
|
+
});
|
|
710223
|
+
}
|
|
710224
|
+
exports.getLegacyContract = getLegacyContract;
|
|
710175
710225
|
function checkContentType(url) {
|
|
710176
710226
|
return new Promise((resolve, reject) => {
|
|
710177
710227
|
let returnVal = { valid: false };
|
package/package.json
CHANGED
package/src/abi/abi.json
CHANGED
|
@@ -74,5 +74,24 @@
|
|
|
74
74
|
"stateMutability": "payable",
|
|
75
75
|
"type": "function"
|
|
76
76
|
}
|
|
77
|
-
]
|
|
77
|
+
],
|
|
78
|
+
"legacy": [
|
|
79
|
+
{
|
|
80
|
+
"inputs": [{"internalType": "address", "name": "_owner", "type": "address"}],
|
|
81
|
+
"name": "getOwnerNFTCount",
|
|
82
|
+
"outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}],
|
|
83
|
+
"stateMutability": "view",
|
|
84
|
+
"type": "function"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"inputs": [
|
|
88
|
+
{"internalType": "address", "name": "_owner", "type": "address"},
|
|
89
|
+
{"internalType": "uint256", "name": "_index", "type": "uint256"}
|
|
90
|
+
],
|
|
91
|
+
"name": "tokenOfOwnerByIndex",
|
|
92
|
+
"outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}],
|
|
93
|
+
"stateMutability": "view",
|
|
94
|
+
"type": "function"
|
|
95
|
+
}
|
|
96
|
+
]
|
|
78
97
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BigNumber } from '@ethersproject/bignumber'
|
|
2
2
|
import { Collection, CuratedCollectionsResponse, MetaData, Vault } from './types';
|
|
3
|
-
import { COIN_TO_NETWORK, NFT_DATA, checkContentType, evaluateFacts, fetchData, generateTemplate, genericGuard, getHandlerContract, getQuoteContractObject, metadataAllProjects, metadataObj2Arr, pad, templateGuard } from './utils';
|
|
3
|
+
import { COIN_TO_NETWORK, NFT_DATA, checkContentType, evaluateFacts, fetchData, generateTemplate, genericGuard, getHandlerContract, getLegacyContract, getQuoteContractObject, metadataAllProjects, metadataObj2Arr, pad, templateGuard } from './utils';
|
|
4
4
|
|
|
5
5
|
const SDK_VERSION = '__SDK_VERSION__';
|
|
6
6
|
class EmblemVaultSDK {
|
|
@@ -279,6 +279,24 @@ class EmblemVaultSDK {
|
|
|
279
279
|
async contentTypeReport(url: string) {
|
|
280
280
|
return await checkContentType(url)
|
|
281
281
|
}
|
|
282
|
+
|
|
283
|
+
async legacyBalanceFromContractByAddress(web3: any, address: string) {
|
|
284
|
+
let legacyContract =await getLegacyContract(web3)
|
|
285
|
+
let balance = await legacyContract.methods.getOwnerNFTCount(address).call();
|
|
286
|
+
let tokenIds = []
|
|
287
|
+
for (let index = 0; index < balance; index++) {
|
|
288
|
+
let tokenId = await legacyContract.methods.tokenOfOwnerByIndex(address, index).call();
|
|
289
|
+
tokenIds.push(Number(tokenId))
|
|
290
|
+
}
|
|
291
|
+
return tokenIds
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
async refreshLegacyOwnership(web3: any, address: string) {
|
|
295
|
+
let myLegacy = await this.legacyBalanceFromContractByAddress(web3, address)
|
|
296
|
+
myLegacy.forEach(async item=>{
|
|
297
|
+
let meta = await this.fetchMetadata(item.toString())
|
|
298
|
+
})
|
|
299
|
+
}
|
|
282
300
|
}
|
|
283
301
|
|
|
284
302
|
declare global {
|
package/src/utils.ts
CHANGED
|
@@ -228,6 +228,8 @@ export function generateTemplate(record: any) {
|
|
|
228
228
|
if (allowed && data && data.length > 0 && data[0].coin) {
|
|
229
229
|
allowed = _this.nativeAssets.includes(data[0].coin)
|
|
230
230
|
}
|
|
231
|
+
} else if (recordName == "Bitcoin DeGods"){
|
|
232
|
+
allowed = data && data.length > 0 && data[0].coin == "ordinalsbtc" && data[0].balance == 1 && data[0].project == "DeGods"
|
|
231
233
|
} else if (_this.vaultCollectionType && _this.vaultCollectionType == "protocol") {
|
|
232
234
|
allowed = data && data.length > 0 && data[0].coin.toLowerCase() == _this.collectionChain.toLowerCase() && data[0].project && data[0].project == recordName
|
|
233
235
|
} else if (_this.vaultCollectionType && _this.vaultCollectionType == "collection" ) {
|
|
@@ -498,6 +500,12 @@ export async function getHandlerContract(web3: any) {
|
|
|
498
500
|
return handlerContract
|
|
499
501
|
}
|
|
500
502
|
|
|
503
|
+
export async function getLegacyContract(web3: any) {
|
|
504
|
+
let contractAddress = '0x82c7a8f707110f5fbb16184a5933e9f78a34c6ab'
|
|
505
|
+
const handlerContract = new web3.eth.Contract(abi.legacy, contractAddress);
|
|
506
|
+
return handlerContract
|
|
507
|
+
}
|
|
508
|
+
|
|
501
509
|
export function checkContentType(url: string) {
|
|
502
510
|
return new Promise((resolve, reject) => {
|
|
503
511
|
// Making a HTTP HEAD request to get only the headers
|
package/types/index.d.ts
CHANGED
|
@@ -25,6 +25,8 @@ declare class EmblemVaultSDK {
|
|
|
25
25
|
getQuote(web3: any, amount: number, callback?: any): Promise<BigNumber>;
|
|
26
26
|
performMint(web3: any, quote: any, remoteMintSig: any, callback?: any): Promise<any>;
|
|
27
27
|
contentTypeReport(url: string): Promise<unknown>;
|
|
28
|
+
legacyBalanceFromContractByAddress(web3: any, address: string): Promise<number[]>;
|
|
29
|
+
refreshLegacyOwnership(web3: any, address: string): Promise<void>;
|
|
28
30
|
}
|
|
29
31
|
declare global {
|
|
30
32
|
interface Window {
|
package/types/utils.d.ts
CHANGED
|
@@ -17,5 +17,6 @@ export declare function templateGuard(input: {
|
|
|
17
17
|
export declare function genericGuard(input: any, type: string, key: string): void;
|
|
18
18
|
export declare function getQuoteContractObject(web3: any): Promise<any>;
|
|
19
19
|
export declare function getHandlerContract(web3: any): Promise<any>;
|
|
20
|
+
export declare function getLegacyContract(web3: any): Promise<any>;
|
|
20
21
|
export declare function checkContentType(url: string): Promise<unknown>;
|
|
21
22
|
export declare const COIN_TO_NETWORK: any;
|