emblem-vault-sdk 1.9.3 → 1.9.5
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 +4 -3
- package/dist/derive.js +2 -1
- package/dist/index.js +2 -2
- package/docs/bundle.js +4 -3
- package/package.json +1 -1
- package/readme.md +37 -66
- package/src/derive.ts +5 -3
- package/src/index.ts +1 -1
package/dist/bundle.js
CHANGED
|
@@ -709352,9 +709352,9 @@ const bip39 = __importStar(require("bip39"));
|
|
|
709352
709352
|
// import bitcoin from "bitcoinjs-lib";
|
|
709353
709353
|
const ecc = __importStar(require("@bitcoin-js/tiny-secp256k1-asmjs"));
|
|
709354
709354
|
const bip32 = (0, bip32_1.BIP32Factory)(ecc);
|
|
709355
|
-
let mainnet = { "messagePrefix": "\u0018Bitcoin Signed Message:\n", "bech32": "bc", "bip32": { "public": 76067358, "private": 76066276 }, "pubKeyHash": 0, "scriptHash": 5, "wif": 128 };
|
|
709356
709355
|
const generateTaprootAddressFromMnemonic = (phrase) => __awaiter(void 0, void 0, void 0, function* () {
|
|
709357
709356
|
let bitcoin = window.bitcoin;
|
|
709357
|
+
let mainnet = bitcoin.networks.mainnet;
|
|
709358
709358
|
bitcoin.initEccLib(ecc);
|
|
709359
709359
|
const seed = bip39.mnemonicToSeedSync(phrase);
|
|
709360
709360
|
const rootKey = bip32.fromSeed(seed, mainnet);
|
|
@@ -709376,6 +709376,7 @@ exports.generateTaprootAddressFromMnemonic = generateTaprootAddressFromMnemonic;
|
|
|
709376
709376
|
const getPsbtTxnSize = (phrase, psbtBase64) => {
|
|
709377
709377
|
var _a, _b;
|
|
709378
709378
|
let bitcoin = window.bitcoin;
|
|
709379
|
+
let mainnet = bitcoin.networks.mainnet;
|
|
709379
709380
|
const parsedPsbt = bitcoin.Psbt.fromBase64(psbtBase64);
|
|
709380
709381
|
const psbt = new bitcoin.Psbt();
|
|
709381
709382
|
const seed = bip39.mnemonicToSeedSync(phrase);
|
|
@@ -709476,7 +709477,7 @@ const bignumber_1 = require("@ethersproject/bignumber");
|
|
|
709476
709477
|
const utils_1 = require("./utils");
|
|
709477
709478
|
const sats_connect_1 = require("sats-connect");
|
|
709478
709479
|
const derive_1 = require("./derive");
|
|
709479
|
-
const SDK_VERSION = '1.9.
|
|
709480
|
+
const SDK_VERSION = '1.9.5';
|
|
709480
709481
|
class EmblemVaultSDK {
|
|
709481
709482
|
constructor(apiKey, baseUrl) {
|
|
709482
709483
|
this.apiKey = apiKey;
|
|
@@ -709738,7 +709739,7 @@ class EmblemVaultSDK {
|
|
|
709738
709739
|
let collection = yield this.fetchCuratedContractByName(collectionName);
|
|
709739
709740
|
let mintRequestSig = yield this.requestLocalMintSignature(web3, tokenId, callback);
|
|
709740
709741
|
let remoteMintSig = yield this.requestRemoteMintSignature(web3, tokenId, mintRequestSig, callback);
|
|
709741
|
-
let quote = yield this.getQuote(web3, collection ? collection.price :
|
|
709742
|
+
let quote = yield this.getQuote(web3, collection ? collection.price : remoteMintSig._price, callback);
|
|
709742
709743
|
let mintResponse = yield this.performMint(web3, quote, remoteMintSig, callback);
|
|
709743
709744
|
return { mintResponse };
|
|
709744
709745
|
});
|
package/dist/derive.js
CHANGED
|
@@ -38,9 +38,9 @@ const bip39 = __importStar(require("bip39"));
|
|
|
38
38
|
// import bitcoin from "bitcoinjs-lib";
|
|
39
39
|
const ecc = __importStar(require("@bitcoin-js/tiny-secp256k1-asmjs"));
|
|
40
40
|
const bip32 = (0, bip32_1.BIP32Factory)(ecc);
|
|
41
|
-
let mainnet = { "messagePrefix": "\u0018Bitcoin Signed Message:\n", "bech32": "bc", "bip32": { "public": 76067358, "private": 76066276 }, "pubKeyHash": 0, "scriptHash": 5, "wif": 128 };
|
|
42
41
|
const generateTaprootAddressFromMnemonic = (phrase) => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
42
|
let bitcoin = window.bitcoin;
|
|
43
|
+
let mainnet = bitcoin.networks.mainnet;
|
|
44
44
|
bitcoin.initEccLib(ecc);
|
|
45
45
|
const seed = bip39.mnemonicToSeedSync(phrase);
|
|
46
46
|
const rootKey = bip32.fromSeed(seed, mainnet);
|
|
@@ -62,6 +62,7 @@ exports.generateTaprootAddressFromMnemonic = generateTaprootAddressFromMnemonic;
|
|
|
62
62
|
const getPsbtTxnSize = (phrase, psbtBase64) => {
|
|
63
63
|
var _a, _b;
|
|
64
64
|
let bitcoin = window.bitcoin;
|
|
65
|
+
let mainnet = bitcoin.networks.mainnet;
|
|
65
66
|
const parsedPsbt = bitcoin.Psbt.fromBase64(psbtBase64);
|
|
66
67
|
const psbt = new bitcoin.Psbt();
|
|
67
68
|
const seed = bip39.mnemonicToSeedSync(phrase);
|
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.
|
|
39
|
+
const SDK_VERSION = '1.9.5';
|
|
40
40
|
class EmblemVaultSDK {
|
|
41
41
|
constructor(apiKey, baseUrl) {
|
|
42
42
|
this.apiKey = apiKey;
|
|
@@ -298,7 +298,7 @@ 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 :
|
|
301
|
+
let quote = yield this.getQuote(web3, collection ? collection.price : remoteMintSig._price, callback);
|
|
302
302
|
let mintResponse = yield this.performMint(web3, quote, remoteMintSig, callback);
|
|
303
303
|
return { mintResponse };
|
|
304
304
|
});
|
package/docs/bundle.js
CHANGED
|
@@ -709352,9 +709352,9 @@ const bip39 = __importStar(require("bip39"));
|
|
|
709352
709352
|
// import bitcoin from "bitcoinjs-lib";
|
|
709353
709353
|
const ecc = __importStar(require("@bitcoin-js/tiny-secp256k1-asmjs"));
|
|
709354
709354
|
const bip32 = (0, bip32_1.BIP32Factory)(ecc);
|
|
709355
|
-
let mainnet = { "messagePrefix": "\u0018Bitcoin Signed Message:\n", "bech32": "bc", "bip32": { "public": 76067358, "private": 76066276 }, "pubKeyHash": 0, "scriptHash": 5, "wif": 128 };
|
|
709356
709355
|
const generateTaprootAddressFromMnemonic = (phrase) => __awaiter(void 0, void 0, void 0, function* () {
|
|
709357
709356
|
let bitcoin = window.bitcoin;
|
|
709357
|
+
let mainnet = bitcoin.networks.mainnet;
|
|
709358
709358
|
bitcoin.initEccLib(ecc);
|
|
709359
709359
|
const seed = bip39.mnemonicToSeedSync(phrase);
|
|
709360
709360
|
const rootKey = bip32.fromSeed(seed, mainnet);
|
|
@@ -709376,6 +709376,7 @@ exports.generateTaprootAddressFromMnemonic = generateTaprootAddressFromMnemonic;
|
|
|
709376
709376
|
const getPsbtTxnSize = (phrase, psbtBase64) => {
|
|
709377
709377
|
var _a, _b;
|
|
709378
709378
|
let bitcoin = window.bitcoin;
|
|
709379
|
+
let mainnet = bitcoin.networks.mainnet;
|
|
709379
709380
|
const parsedPsbt = bitcoin.Psbt.fromBase64(psbtBase64);
|
|
709380
709381
|
const psbt = new bitcoin.Psbt();
|
|
709381
709382
|
const seed = bip39.mnemonicToSeedSync(phrase);
|
|
@@ -709476,7 +709477,7 @@ const bignumber_1 = require("@ethersproject/bignumber");
|
|
|
709476
709477
|
const utils_1 = require("./utils");
|
|
709477
709478
|
const sats_connect_1 = require("sats-connect");
|
|
709478
709479
|
const derive_1 = require("./derive");
|
|
709479
|
-
const SDK_VERSION = '1.9.
|
|
709480
|
+
const SDK_VERSION = '1.9.5';
|
|
709480
709481
|
class EmblemVaultSDK {
|
|
709481
709482
|
constructor(apiKey, baseUrl) {
|
|
709482
709483
|
this.apiKey = apiKey;
|
|
@@ -709738,7 +709739,7 @@ class EmblemVaultSDK {
|
|
|
709738
709739
|
let collection = yield this.fetchCuratedContractByName(collectionName);
|
|
709739
709740
|
let mintRequestSig = yield this.requestLocalMintSignature(web3, tokenId, callback);
|
|
709740
709741
|
let remoteMintSig = yield this.requestRemoteMintSignature(web3, tokenId, mintRequestSig, callback);
|
|
709741
|
-
let quote = yield this.getQuote(web3, collection ? collection.price :
|
|
709742
|
+
let quote = yield this.getQuote(web3, collection ? collection.price : remoteMintSig._price, callback);
|
|
709742
709743
|
let mintResponse = yield this.performMint(web3, quote, remoteMintSig, callback);
|
|
709743
709744
|
return { mintResponse };
|
|
709744
709745
|
});
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -1,78 +1,49 @@
|
|
|
1
1
|
# Emblem Vault SDK
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## Overview
|
|
4
|
+
The EmblemVault SDK provides developers with the tools needed to interact with the EmblemVault API, facilitating the seamless integration of EmblemVault functionalities into applications.
|
|
4
5
|
|
|
5
|
-
##
|
|
6
|
+
## Getting Started
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
npm
|
|
9
|
-
|
|
8
|
+
### Installation
|
|
9
|
+
Install via npm or yarn:
|
|
10
|
+
- `npm install emblemvault-sdk`
|
|
11
|
+
- `yarn add emblemvault-sdk`
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
### Initialization
|
|
14
|
+
Initialize with your API key:
|
|
15
|
+
```javascript
|
|
16
|
+
import EmblemVaultSDK from 'emblemvault-sdk';
|
|
17
|
+
const emblemVaultSDK = new EmblemVaultSDK('YOUR_API_KEY');
|
|
12
18
|
```
|
|
13
|
-
const EmblemVaultSDK = require('emblem-vault-sdk');
|
|
14
|
-
// import EmblemVaultSDK from 'emblem-vault-sdk'
|
|
15
|
-
const apiKey = 'YOUR_API_KEY'; // replace with your actual API key
|
|
16
19
|
|
|
17
|
-
|
|
18
|
-
```
|
|
20
|
+
## API Reference
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
// Fetch Vaults of type ____ owned by ____
|
|
47
|
-
const TEST_ADDRESS = "0x9dE9ffB62c159A10cbcC19BdAc7962e9C19a1baa"
|
|
48
|
-
sdk.fetchVaultsOfType("created", TEST_ADDRESS).then(vaults => {
|
|
49
|
-
console.log(vaults);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
// Get all projects that contain Asset Metadata
|
|
53
|
-
projects = sdk.getAllProjects()
|
|
54
|
-
// [
|
|
55
|
-
// "Emblem Test",
|
|
56
|
-
// "Age of Chains",
|
|
57
|
-
// "Age of Rust",
|
|
58
|
-
// "..."
|
|
59
|
-
// ]
|
|
60
|
-
|
|
61
|
-
// Get asset metadata
|
|
62
|
-
const projectName = projects[1]; // valid item from getAllProjects() above
|
|
63
|
-
assets = sdk.getAssetMetadata(projectName)
|
|
64
|
-
console.log(assets)
|
|
65
|
-
// [
|
|
66
|
-
// {
|
|
67
|
-
// "image":"ELECTRUMCARD.jpg",
|
|
68
|
-
// "projectName":"Age of Chains",
|
|
69
|
-
// "projectLogo":"age-of-chains.jpg",
|
|
70
|
-
// "projectSite":"https://www.ageofchains.com/",
|
|
71
|
-
// "assetName":"ELECTRUMCARD"
|
|
72
|
-
// },...
|
|
73
|
-
// ]
|
|
22
|
+
### Asset Metadata Methods
|
|
23
|
+
- **getAssetMetadata(projectName, strict = false)**: Fetch metadata for assets by project name.
|
|
24
|
+
- **getAllAssetMetadata()**: Retrieve metadata for all assets.
|
|
25
|
+
- **getAllProjects()**: Get a list of all projects.
|
|
26
|
+
|
|
27
|
+
### Curated Collections Methods
|
|
28
|
+
- **fetchCuratedContracts(hideUnMintable = false, overrideFunc = false)**: Fetch curated contracts, with optional parameters to hide unmintable contracts or override the fetching function.
|
|
29
|
+
- **fetchCuratedContractByName(name, contracts = false)**: Fetch a curated contract by its name.
|
|
30
|
+
|
|
31
|
+
### Web3 Integration Methods
|
|
32
|
+
- **loadWeb3()**: Dynamically load Web3 and connect to MetaMask.
|
|
33
|
+
|
|
34
|
+
### Minting, Burning, and Claiming Methods
|
|
35
|
+
- **performMintChain(web3, tokenId, collectionName, callback = null)**: Perform the minting process for a specific token in a collection.
|
|
36
|
+
- **performBurn(web3, tokenId, callback = null)**: Burn a token.
|
|
37
|
+
- **performClaimChain(web3, tokenId, serialNumber, callback = null)**: Claim ownership of a token.
|
|
38
|
+
|
|
39
|
+
### Bitcoin Network Methods
|
|
40
|
+
- **getSatsConnectAddress()**: Generate a SatsConnect address for Bitcoin transactions.
|
|
41
|
+
- **generatePSBT(phrase, satsPerByte = 20)**: Generate a Partially Signed Bitcoin Transaction (PSBT).
|
|
42
|
+
- **getTaprootAddressFromMnemonic(phrase)**: Generate a Taproot address from a mnemonic phrase.
|
|
43
|
+
|
|
44
|
+
## Global Declaration
|
|
45
|
+
The `EmblemVaultSDK` is available globally in web applications through the `window` object.
|
|
74
46
|
|
|
75
|
-
```
|
|
76
47
|
|
|
77
48
|
## Simple Html Demo
|
|
78
49
|
|
package/src/derive.ts
CHANGED
|
@@ -6,14 +6,15 @@ import * as ecc from '@bitcoin-js/tiny-secp256k1-asmjs'
|
|
|
6
6
|
|
|
7
7
|
const bip32 = BIP32Factory(ecc);
|
|
8
8
|
|
|
9
|
-
let mainnet: any = {"messagePrefix":"\u0018Bitcoin Signed Message:\n","bech32":"bc","bip32":{"public":76067358,"private":76066276},"pubKeyHash":0,"scriptHash":5,"wif":128}
|
|
9
|
+
// let mainnet: any = {"messagePrefix":"\u0018Bitcoin Signed Message:\n","bech32":"bc","bip32":{"public":76067358,"private":76066276},"pubKeyHash":0,"scriptHash":5,"wif":128}
|
|
10
10
|
declare global {
|
|
11
11
|
interface Window {
|
|
12
12
|
bitcoin: any;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
export const generateTaprootAddressFromMnemonic = async (phrase: string) => {
|
|
16
|
-
let bitcoin = window.bitcoin;
|
|
16
|
+
let bitcoin = window.bitcoin;
|
|
17
|
+
let mainnet = bitcoin.networks.mainnet;
|
|
17
18
|
bitcoin.initEccLib(ecc);
|
|
18
19
|
const seed = bip39.mnemonicToSeedSync(phrase);
|
|
19
20
|
|
|
@@ -39,7 +40,8 @@ export const generateTaprootAddressFromMnemonic = async (phrase: string) => {
|
|
|
39
40
|
// we sign it with a dummy key and then extract the transaction
|
|
40
41
|
// it should be very close to 100% accurate
|
|
41
42
|
export const getPsbtTxnSize = (phrase: string, psbtBase64: string) => {
|
|
42
|
-
let bitcoin = window.bitcoin;
|
|
43
|
+
let bitcoin = window.bitcoin;
|
|
44
|
+
let mainnet = bitcoin.networks.mainnet;
|
|
43
45
|
const parsedPsbt = bitcoin.Psbt.fromBase64(psbtBase64);
|
|
44
46
|
|
|
45
47
|
const psbt = new bitcoin.Psbt();
|
package/src/index.ts
CHANGED
|
@@ -253,7 +253,7 @@ 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:
|
|
256
|
+
let quote = await this.getQuote(web3, collection? collection.price: remoteMintSig._price, callback);
|
|
257
257
|
let mintResponse = await this.performMint(web3, quote, remoteMintSig, callback);
|
|
258
258
|
return {mintResponse}
|
|
259
259
|
}
|