emblem-vault-sdk 1.9.5 → 1.9.8

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 CHANGED
@@ -709477,7 +709477,7 @@ const bignumber_1 = require("@ethersproject/bignumber");
709477
709477
  const utils_1 = require("./utils");
709478
709478
  const sats_connect_1 = require("sats-connect");
709479
709479
  const derive_1 = require("./derive");
709480
- const SDK_VERSION = '1.9.5';
709480
+ const SDK_VERSION = '1.9.8';
709481
709481
  class EmblemVaultSDK {
709482
709482
  constructor(apiKey, baseUrl) {
709483
709483
  this.apiKey = apiKey;
@@ -709739,8 +709739,9 @@ class EmblemVaultSDK {
709739
709739
  let collection = yield this.fetchCuratedContractByName(collectionName);
709740
709740
  let mintRequestSig = yield this.requestLocalMintSignature(web3, tokenId, callback);
709741
709741
  let remoteMintSig = yield this.requestRemoteMintSignature(web3, tokenId, mintRequestSig, callback);
709742
- let quote = yield this.getQuote(web3, collection ? collection.price : remoteMintSig._price, callback);
709743
- let mintResponse = yield this.performMint(web3, quote, remoteMintSig, callback);
709742
+ let quote = yield this.getQuote(web3, collection ? collection.price : remoteMintSig._price / 1000000, callback);
709743
+ let ethToSend = quote.mul(bignumber_1.BigNumber.from(10).pow(6));
709744
+ let mintResponse = yield this.performMint(web3, ethToSend, remoteMintSig, callback);
709744
709745
  return { mintResponse };
709745
709746
  });
709746
709747
  }
@@ -709840,7 +709841,7 @@ class EmblemVaultSDK {
709840
709841
  }
709841
709842
  let quoteContract = yield (0, utils_1.getQuoteContractObject)(web3);
709842
709843
  const accounts = yield web3.eth.getAccounts();
709843
- let quote = bignumber_1.BigNumber.from(yield quoteContract.methods.quoteExternalPrice(accounts[0], amount.toString()).call());
709844
+ let quote = bignumber_1.BigNumber.from(yield quoteContract.methods.quoteExternalPrice(accounts[0], Number(amount) / 1000000).call());
709844
709845
  if (callback) {
709845
709846
  callback(`quote`, quote.toString());
709846
709847
  }
@@ -709849,12 +709850,24 @@ class EmblemVaultSDK {
709849
709850
  }
709850
709851
  performMint(web3, quote, remoteMintSig, callback = null) {
709851
709852
  return __awaiter(this, void 0, void 0, function* () {
709853
+ // async performMint(web3, quote, remoteMintSig, callback = null) {
709852
709854
  if (callback) {
709853
709855
  callback('performing Mint');
709854
709856
  }
709855
709857
  const accounts = yield web3.eth.getAccounts();
709856
709858
  let handlerContract = yield (0, utils_1.getHandlerContract)(web3);
709857
- let mintResponse = yield handlerContract.methods.buyWithQuote(remoteMintSig._nftAddress, remoteMintSig._price, remoteMintSig._to, remoteMintSig._tokenId, remoteMintSig._nonce, remoteMintSig._signature, remoteMintSig.serialNumber, 1).send({ from: accounts[0], value: quote.toString() });
709859
+ // Get current gas price from the network
709860
+ const gasPrice = yield web3.eth.getGasPrice();
709861
+ let createdTxObject = handlerContract.methods.buyWithQuote(remoteMintSig._nftAddress, remoteMintSig._price, remoteMintSig._to, remoteMintSig._tokenId, remoteMintSig._nonce, remoteMintSig._signature, remoteMintSig.serialNumber, 1);
709862
+ // Estimate gas limit for the transaction
709863
+ const gasLimit = yield createdTxObject.estimateGas({ from: accounts[0], value: Number(quote) });
709864
+ // Execute the transaction with the specified gas price and estimated gas limit
709865
+ let mintResponse = yield createdTxObject.send({
709866
+ from: accounts[0],
709867
+ value: Number(quote),
709868
+ gasPrice: gasPrice, // Use the current gas price
709869
+ gas: gasLimit // Use the estimated gas limit
709870
+ });
709858
709871
  if (callback) {
709859
709872
  callback('Mint Complete');
709860
709873
  }
@@ -709872,7 +709885,16 @@ class EmblemVaultSDK {
709872
709885
  const accounts = yield web3.eth.getAccounts();
709873
709886
  const chainId = yield web3.eth.getChainId();
709874
709887
  let handlerContract = yield (0, utils_1.getHandlerContract)(web3);
709875
- let burnResponse = yield handlerContract.methods.claim(targetContract[chainId], targetContract.collectionType == 'ERC721a' ? tokenId : targetContract.tokenId).send({ from: accounts[0] });
709888
+ // Dynamically fetch the current gas price
709889
+ const gasPrice = yield web3.eth.getGasPrice();
709890
+ let createdTxObject = handlerContract.methods.claim(targetContract[chainId], targetContract.collectionType == 'ERC721a' ? tokenId : targetContract.tokenId);
709891
+ // Estimate gas limit for the transaction
709892
+ const estimatedGas = yield createdTxObject.estimateGas({ from: accounts[0] });
709893
+ let burnResponse = yield createdTxObject.send({
709894
+ from: accounts[0],
709895
+ gasPrice: gasPrice,
709896
+ gas: estimatedGas
709897
+ });
709876
709898
  if (callback) {
709877
709899
  callback('Burn Complete');
709878
709900
  }
package/dist/index.js CHANGED
@@ -36,7 +36,7 @@ const bignumber_1 = require("@ethersproject/bignumber");
36
36
  const utils_1 = require("./utils");
37
37
  const sats_connect_1 = require("sats-connect");
38
38
  const derive_1 = require("./derive");
39
- const SDK_VERSION = '1.9.5';
39
+ const SDK_VERSION = '1.9.8';
40
40
  class EmblemVaultSDK {
41
41
  constructor(apiKey, baseUrl) {
42
42
  this.apiKey = apiKey;
@@ -298,8 +298,9 @@ class EmblemVaultSDK {
298
298
  let collection = yield this.fetchCuratedContractByName(collectionName);
299
299
  let mintRequestSig = yield this.requestLocalMintSignature(web3, tokenId, callback);
300
300
  let remoteMintSig = yield this.requestRemoteMintSignature(web3, tokenId, mintRequestSig, callback);
301
- let quote = yield this.getQuote(web3, collection ? collection.price : remoteMintSig._price, callback);
302
- let mintResponse = yield this.performMint(web3, quote, remoteMintSig, callback);
301
+ let quote = yield this.getQuote(web3, collection ? collection.price : remoteMintSig._price / 1000000, callback);
302
+ let ethToSend = quote.mul(bignumber_1.BigNumber.from(10).pow(6));
303
+ let mintResponse = yield this.performMint(web3, ethToSend, remoteMintSig, callback);
303
304
  return { mintResponse };
304
305
  });
305
306
  }
@@ -399,7 +400,7 @@ class EmblemVaultSDK {
399
400
  }
400
401
  let quoteContract = yield (0, utils_1.getQuoteContractObject)(web3);
401
402
  const accounts = yield web3.eth.getAccounts();
402
- let quote = bignumber_1.BigNumber.from(yield quoteContract.methods.quoteExternalPrice(accounts[0], amount.toString()).call());
403
+ let quote = bignumber_1.BigNumber.from(yield quoteContract.methods.quoteExternalPrice(accounts[0], Number(amount) / 1000000).call());
403
404
  if (callback) {
404
405
  callback(`quote`, quote.toString());
405
406
  }
@@ -408,12 +409,24 @@ class EmblemVaultSDK {
408
409
  }
409
410
  performMint(web3, quote, remoteMintSig, callback = null) {
410
411
  return __awaiter(this, void 0, void 0, function* () {
412
+ // async performMint(web3, quote, remoteMintSig, callback = null) {
411
413
  if (callback) {
412
414
  callback('performing Mint');
413
415
  }
414
416
  const accounts = yield web3.eth.getAccounts();
415
417
  let handlerContract = yield (0, utils_1.getHandlerContract)(web3);
416
- let mintResponse = yield handlerContract.methods.buyWithQuote(remoteMintSig._nftAddress, remoteMintSig._price, remoteMintSig._to, remoteMintSig._tokenId, remoteMintSig._nonce, remoteMintSig._signature, remoteMintSig.serialNumber, 1).send({ from: accounts[0], value: quote.toString() });
418
+ // Get current gas price from the network
419
+ const gasPrice = yield web3.eth.getGasPrice();
420
+ let createdTxObject = handlerContract.methods.buyWithQuote(remoteMintSig._nftAddress, remoteMintSig._price, remoteMintSig._to, remoteMintSig._tokenId, remoteMintSig._nonce, remoteMintSig._signature, remoteMintSig.serialNumber, 1);
421
+ // Estimate gas limit for the transaction
422
+ const gasLimit = yield createdTxObject.estimateGas({ from: accounts[0], value: Number(quote) });
423
+ // Execute the transaction with the specified gas price and estimated gas limit
424
+ let mintResponse = yield createdTxObject.send({
425
+ from: accounts[0],
426
+ value: Number(quote),
427
+ gasPrice: gasPrice, // Use the current gas price
428
+ gas: gasLimit // Use the estimated gas limit
429
+ });
417
430
  if (callback) {
418
431
  callback('Mint Complete');
419
432
  }
@@ -431,7 +444,16 @@ class EmblemVaultSDK {
431
444
  const accounts = yield web3.eth.getAccounts();
432
445
  const chainId = yield web3.eth.getChainId();
433
446
  let handlerContract = yield (0, utils_1.getHandlerContract)(web3);
434
- let burnResponse = yield handlerContract.methods.claim(targetContract[chainId], targetContract.collectionType == 'ERC721a' ? tokenId : targetContract.tokenId).send({ from: accounts[0] });
447
+ // Dynamically fetch the current gas price
448
+ const gasPrice = yield web3.eth.getGasPrice();
449
+ let createdTxObject = handlerContract.methods.claim(targetContract[chainId], targetContract.collectionType == 'ERC721a' ? tokenId : targetContract.tokenId);
450
+ // Estimate gas limit for the transaction
451
+ const estimatedGas = yield createdTxObject.estimateGas({ from: accounts[0] });
452
+ let burnResponse = yield createdTxObject.send({
453
+ from: accounts[0],
454
+ gasPrice: gasPrice,
455
+ gas: estimatedGas
456
+ });
435
457
  if (callback) {
436
458
  callback('Burn Complete');
437
459
  }
package/docs/bundle.js CHANGED
@@ -709477,7 +709477,7 @@ const bignumber_1 = require("@ethersproject/bignumber");
709477
709477
  const utils_1 = require("./utils");
709478
709478
  const sats_connect_1 = require("sats-connect");
709479
709479
  const derive_1 = require("./derive");
709480
- const SDK_VERSION = '1.9.5';
709480
+ const SDK_VERSION = '1.9.8';
709481
709481
  class EmblemVaultSDK {
709482
709482
  constructor(apiKey, baseUrl) {
709483
709483
  this.apiKey = apiKey;
@@ -709739,8 +709739,9 @@ class EmblemVaultSDK {
709739
709739
  let collection = yield this.fetchCuratedContractByName(collectionName);
709740
709740
  let mintRequestSig = yield this.requestLocalMintSignature(web3, tokenId, callback);
709741
709741
  let remoteMintSig = yield this.requestRemoteMintSignature(web3, tokenId, mintRequestSig, callback);
709742
- let quote = yield this.getQuote(web3, collection ? collection.price : remoteMintSig._price, callback);
709743
- let mintResponse = yield this.performMint(web3, quote, remoteMintSig, callback);
709742
+ let quote = yield this.getQuote(web3, collection ? collection.price : remoteMintSig._price / 1000000, callback);
709743
+ let ethToSend = quote.mul(bignumber_1.BigNumber.from(10).pow(6));
709744
+ let mintResponse = yield this.performMint(web3, ethToSend, remoteMintSig, callback);
709744
709745
  return { mintResponse };
709745
709746
  });
709746
709747
  }
@@ -709840,7 +709841,7 @@ class EmblemVaultSDK {
709840
709841
  }
709841
709842
  let quoteContract = yield (0, utils_1.getQuoteContractObject)(web3);
709842
709843
  const accounts = yield web3.eth.getAccounts();
709843
- let quote = bignumber_1.BigNumber.from(yield quoteContract.methods.quoteExternalPrice(accounts[0], amount.toString()).call());
709844
+ let quote = bignumber_1.BigNumber.from(yield quoteContract.methods.quoteExternalPrice(accounts[0], Number(amount) / 1000000).call());
709844
709845
  if (callback) {
709845
709846
  callback(`quote`, quote.toString());
709846
709847
  }
@@ -709849,12 +709850,24 @@ class EmblemVaultSDK {
709849
709850
  }
709850
709851
  performMint(web3, quote, remoteMintSig, callback = null) {
709851
709852
  return __awaiter(this, void 0, void 0, function* () {
709853
+ // async performMint(web3, quote, remoteMintSig, callback = null) {
709852
709854
  if (callback) {
709853
709855
  callback('performing Mint');
709854
709856
  }
709855
709857
  const accounts = yield web3.eth.getAccounts();
709856
709858
  let handlerContract = yield (0, utils_1.getHandlerContract)(web3);
709857
- let mintResponse = yield handlerContract.methods.buyWithQuote(remoteMintSig._nftAddress, remoteMintSig._price, remoteMintSig._to, remoteMintSig._tokenId, remoteMintSig._nonce, remoteMintSig._signature, remoteMintSig.serialNumber, 1).send({ from: accounts[0], value: quote.toString() });
709859
+ // Get current gas price from the network
709860
+ const gasPrice = yield web3.eth.getGasPrice();
709861
+ let createdTxObject = handlerContract.methods.buyWithQuote(remoteMintSig._nftAddress, remoteMintSig._price, remoteMintSig._to, remoteMintSig._tokenId, remoteMintSig._nonce, remoteMintSig._signature, remoteMintSig.serialNumber, 1);
709862
+ // Estimate gas limit for the transaction
709863
+ const gasLimit = yield createdTxObject.estimateGas({ from: accounts[0], value: Number(quote) });
709864
+ // Execute the transaction with the specified gas price and estimated gas limit
709865
+ let mintResponse = yield createdTxObject.send({
709866
+ from: accounts[0],
709867
+ value: Number(quote),
709868
+ gasPrice: gasPrice, // Use the current gas price
709869
+ gas: gasLimit // Use the estimated gas limit
709870
+ });
709858
709871
  if (callback) {
709859
709872
  callback('Mint Complete');
709860
709873
  }
@@ -709872,7 +709885,16 @@ class EmblemVaultSDK {
709872
709885
  const accounts = yield web3.eth.getAccounts();
709873
709886
  const chainId = yield web3.eth.getChainId();
709874
709887
  let handlerContract = yield (0, utils_1.getHandlerContract)(web3);
709875
- let burnResponse = yield handlerContract.methods.claim(targetContract[chainId], targetContract.collectionType == 'ERC721a' ? tokenId : targetContract.tokenId).send({ from: accounts[0] });
709888
+ // Dynamically fetch the current gas price
709889
+ const gasPrice = yield web3.eth.getGasPrice();
709890
+ let createdTxObject = handlerContract.methods.claim(targetContract[chainId], targetContract.collectionType == 'ERC721a' ? tokenId : targetContract.tokenId);
709891
+ // Estimate gas limit for the transaction
709892
+ const estimatedGas = yield createdTxObject.estimateGas({ from: accounts[0] });
709893
+ let burnResponse = yield createdTxObject.send({
709894
+ from: accounts[0],
709895
+ gasPrice: gasPrice,
709896
+ gas: estimatedGas
709897
+ });
709876
709898
  if (callback) {
709877
709899
  callback('Burn Complete');
709878
709900
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "emblem-vault-sdk",
3
- "version": "1.9.5",
3
+ "version": "1.9.8",
4
4
  "description": "Emblem Vault Software Development Kit",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/src/index.ts CHANGED
@@ -253,8 +253,9 @@ class EmblemVaultSDK {
253
253
  let collection = await this.fetchCuratedContractByName(collectionName);
254
254
  let mintRequestSig = await this.requestLocalMintSignature(web3, tokenId, callback);
255
255
  let remoteMintSig = await this.requestRemoteMintSignature(web3, tokenId, mintRequestSig, callback);
256
- let quote = await this.getQuote(web3, collection? collection.price: remoteMintSig._price, callback);
257
- let mintResponse = await this.performMint(web3, quote, remoteMintSig, callback);
256
+ let quote = await this.getQuote(web3, collection? collection.price: remoteMintSig._price/1000000, callback);
257
+ let ethToSend = quote.mul(BigNumber.from(10).pow(6))
258
+ let mintResponse = await this.performMint(web3, ethToSend, remoteMintSig, callback);
258
259
  return {mintResponse}
259
260
  }
260
261
 
@@ -320,20 +321,47 @@ class EmblemVaultSDK {
320
321
  if (callback) { callback('requesting Quote')}
321
322
  let quoteContract = await getQuoteContractObject(web3);
322
323
  const accounts = await web3.eth.getAccounts();
323
- let quote = BigNumber.from(await quoteContract.methods.quoteExternalPrice(accounts[0], amount.toString()).call());
324
+ let quote = BigNumber.from(await quoteContract.methods.quoteExternalPrice(accounts[0], Number(amount)/1000000).call());
324
325
  if (callback) { callback(`quote`, quote.toString())}
325
326
  return quote
326
327
  }
327
328
 
328
329
  async performMint(web3: any, quote: any, remoteMintSig: any, callback: any = null) {
329
- if (callback) { callback('performing Mint')}
330
+ // async performMint(web3, quote, remoteMintSig, callback = null) {
331
+ if (callback) { callback('performing Mint') }
330
332
  const accounts = await web3.eth.getAccounts();
331
333
  let handlerContract = await getHandlerContract(web3);
332
- let mintResponse = await handlerContract.methods.buyWithQuote(remoteMintSig._nftAddress, remoteMintSig._price, remoteMintSig._to, remoteMintSig._tokenId, remoteMintSig._nonce, remoteMintSig._signature, remoteMintSig.serialNumber, 1).send({from: accounts[0], value: quote.toString()});
333
- if (callback) { callback('Mint Complete')}
334
+
335
+ // Get current gas price from the network
336
+ const gasPrice = await web3.eth.getGasPrice();
337
+
338
+ let createdTxObject = handlerContract.methods.buyWithQuote(
339
+ remoteMintSig._nftAddress,
340
+ remoteMintSig._price,
341
+ remoteMintSig._to,
342
+ remoteMintSig._tokenId,
343
+ remoteMintSig._nonce,
344
+ remoteMintSig._signature,
345
+ remoteMintSig.serialNumber,
346
+ 1
347
+ )
348
+
349
+ // Estimate gas limit for the transaction
350
+ const gasLimit = await createdTxObject.estimateGas({ from: accounts[0], value: Number(quote) });
351
+
352
+ // Execute the transaction with the specified gas price and estimated gas limit
353
+ let mintResponse = await createdTxObject.send({
354
+ from: accounts[0],
355
+ value: Number(quote),
356
+ gasPrice: gasPrice, // Use the current gas price
357
+ gas: gasLimit // Use the estimated gas limit
358
+ });
359
+
360
+ if (callback) { callback('Mint Complete') }
334
361
  await this.fetchMetadata(remoteMintSig._tokenId);
335
362
  return mintResponse
336
363
  }
364
+
337
365
 
338
366
  async performBurn(web3: any, tokenId: any, callback: any = null) {
339
367
  let metadata: any = await this.fetchMetadata(tokenId);
@@ -342,10 +370,24 @@ class EmblemVaultSDK {
342
370
  const accounts = await web3.eth.getAccounts();
343
371
  const chainId = await web3.eth.getChainId();
344
372
  let handlerContract = await getHandlerContract(web3);
345
- let burnResponse = await handlerContract.methods.claim(targetContract[chainId], targetContract.collectionType == 'ERC721a'? tokenId: targetContract.tokenId).send({from: accounts[0]});
373
+
374
+ // Dynamically fetch the current gas price
375
+ const gasPrice = await web3.eth.getGasPrice();
376
+
377
+ let createdTxObject = handlerContract.methods.claim(targetContract[chainId], targetContract.collectionType == 'ERC721a' ? tokenId : targetContract.tokenId)
378
+ // Estimate gas limit for the transaction
379
+ const estimatedGas = await createdTxObject.estimateGas({from: accounts[0]});
380
+
381
+ let burnResponse = await createdTxObject.send({
382
+ from: accounts[0],
383
+ gasPrice: gasPrice,
384
+ gas: estimatedGas
385
+ });
386
+
346
387
  if (callback) { callback('Burn Complete')}
347
- return burnResponse
388
+ return burnResponse;
348
389
  }
390
+
349
391
 
350
392
  async contentTypeReport(url: string) {
351
393
  return await checkContentType(url)