emblem-vault-sdk 1.9.12 → 1.9.14
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 +96 -43
- package/dist/index.js +28 -40
- package/dist/utils.js +66 -1
- package/docs/bundle.js +96 -43
- package/package.json +1 -1
- package/src/index.ts +25 -46
- package/src/utils.ts +72 -0
- package/types/index.d.ts +1 -15
- package/types/utils.d.ts +8 -0
package/dist/bundle.js
CHANGED
|
@@ -709475,9 +709475,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
709475
709475
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
709476
709476
|
const bignumber_1 = require("@ethersproject/bignumber");
|
|
709477
709477
|
const utils_1 = require("./utils");
|
|
709478
|
-
const sats_connect_1 = require("sats-connect");
|
|
709479
709478
|
const derive_1 = require("./derive");
|
|
709480
|
-
const SDK_VERSION = '1.9.
|
|
709479
|
+
const SDK_VERSION = '1.9.14';
|
|
709481
709480
|
class EmblemVaultSDK {
|
|
709482
709481
|
constructor(apiKey, baseUrl) {
|
|
709483
709482
|
this.apiKey = apiKey;
|
|
@@ -709870,6 +709869,17 @@ class EmblemVaultSDK {
|
|
|
709870
709869
|
value: Number(quote),
|
|
709871
709870
|
gasPrice: gasPrice, // Use the current gas price
|
|
709872
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);
|
|
709873
709883
|
});
|
|
709874
709884
|
if (callback) {
|
|
709875
709885
|
callback('Mint Complete');
|
|
@@ -709897,6 +709907,17 @@ class EmblemVaultSDK {
|
|
|
709897
709907
|
from: accounts[0],
|
|
709898
709908
|
gasPrice: gasPrice,
|
|
709899
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);
|
|
709900
709921
|
});
|
|
709901
709922
|
if (callback) {
|
|
709902
709923
|
callback('Burn Complete');
|
|
@@ -709961,40 +709982,10 @@ class EmblemVaultSDK {
|
|
|
709961
709982
|
return results;
|
|
709962
709983
|
});
|
|
709963
709984
|
}
|
|
709964
|
-
// BTC
|
|
709965
|
-
|
|
709966
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
709967
|
-
return new Promise((resolve, reject) => {
|
|
709968
|
-
(0, sats_connect_1.getAddress)({
|
|
709969
|
-
payload: {
|
|
709970
|
-
purposes: [
|
|
709971
|
-
sats_connect_1.AddressPurpose.Ordinals,
|
|
709972
|
-
sats_connect_1.AddressPurpose.Payment,
|
|
709973
|
-
],
|
|
709974
|
-
message: "My App's Name",
|
|
709975
|
-
network: {
|
|
709976
|
-
type: sats_connect_1.BitcoinNetworkType.Mainnet,
|
|
709977
|
-
},
|
|
709978
|
-
},
|
|
709979
|
-
onFinish: (response) => {
|
|
709980
|
-
const paymentAddressItem = response.addresses.find((address) => address.purpose === sats_connect_1.AddressPurpose.Payment);
|
|
709981
|
-
const ordinalsAddressItem = response.addresses.find((address) => address.purpose === sats_connect_1.AddressPurpose.Ordinals);
|
|
709982
|
-
resolve({
|
|
709983
|
-
paymentAddress: (paymentAddressItem === null || paymentAddressItem === void 0 ? void 0 : paymentAddressItem.address) || "",
|
|
709984
|
-
paymentPublicKey: (paymentAddressItem === null || paymentAddressItem === void 0 ? void 0 : paymentAddressItem.publicKey) || "",
|
|
709985
|
-
ordinalsAddress: (ordinalsAddressItem === null || ordinalsAddressItem === void 0 ? void 0 : ordinalsAddressItem.address) || ""
|
|
709986
|
-
});
|
|
709987
|
-
},
|
|
709988
|
-
onCancel: () => {
|
|
709989
|
-
reject("Request canceled");
|
|
709990
|
-
},
|
|
709991
|
-
});
|
|
709992
|
-
});
|
|
709993
|
-
});
|
|
709994
|
-
}
|
|
709995
|
-
generatePSBT(phrase, satsPerByte = 20) {
|
|
709985
|
+
// BTC
|
|
709986
|
+
sweepVaultUsingPhrase(phrase, satsPerByte = 20, broadcast = false) {
|
|
709996
709987
|
return __awaiter(this, void 0, void 0, function* () {
|
|
709997
|
-
const { paymentAddress, paymentPublicKey, ordinalsAddress } = yield
|
|
709988
|
+
const { paymentAddress, paymentPublicKey, ordinalsAddress } = yield (0, utils_1.getSatsConnectAddress)();
|
|
709998
709989
|
// change this to mainnet
|
|
709999
709990
|
if (window.bitcoin) {
|
|
710000
709991
|
let bitcoin = window.bitcoin;
|
|
@@ -710069,14 +710060,11 @@ class EmblemVaultSDK {
|
|
|
710069
710060
|
// send this to wallet to sign all indexes except the first one
|
|
710070
710061
|
const psbtBase64 = psbt.toBase64();
|
|
710071
710062
|
console.log(psbtBase64);
|
|
710063
|
+
let signedPsbt = yield (0, utils_1.signPSBT)(psbtBase64, paymentAddress, [...Array(paymentUtxos.length).keys()].map(i => i + taprootUtxos.length), broadcast);
|
|
710064
|
+
return signedPsbt;
|
|
710072
710065
|
}
|
|
710073
710066
|
});
|
|
710074
710067
|
}
|
|
710075
|
-
getTaprootAddressFromMnemonic(phrase) {
|
|
710076
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
710077
|
-
return (0, derive_1.generateTaprootAddressFromMnemonic)(phrase);
|
|
710078
|
-
});
|
|
710079
|
-
}
|
|
710080
710068
|
}
|
|
710081
710069
|
if (typeof window !== 'undefined') {
|
|
710082
710070
|
window.EmblemVaultSDK = EmblemVaultSDK;
|
|
@@ -710084,7 +710072,7 @@ if (typeof window !== 'undefined') {
|
|
|
710084
710072
|
exports.default = EmblemVaultSDK;
|
|
710085
710073
|
|
|
710086
710074
|
}).call(this)}).call(this,require("buffer").Buffer)
|
|
710087
|
-
},{"./derive":3,"./utils":5,"@ethersproject/bignumber":58,"buffer":203,"
|
|
710075
|
+
},{"./derive":3,"./utils":5,"@ethersproject/bignumber":58,"buffer":203,"web3":559}],5:[function(require,module,exports){
|
|
710088
710076
|
"use strict";
|
|
710089
710077
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
710090
710078
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
@@ -710099,10 +710087,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
710099
710087
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
710100
710088
|
};
|
|
710101
710089
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
710102
|
-
exports.decryptKeys = exports.getTorusKeys = 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;
|
|
710090
|
+
exports.signPSBT = exports.getSatsConnectAddress = exports.decryptKeys = exports.getTorusKeys = 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;
|
|
710103
710091
|
const crypto_js_1 = __importDefault(require("crypto-js"));
|
|
710104
710092
|
const metadata_json_1 = __importDefault(require("./curated/metadata.json"));
|
|
710105
710093
|
const abi_json_1 = __importDefault(require("./abi/abi.json"));
|
|
710094
|
+
const sats_connect_1 = require("sats-connect");
|
|
710106
710095
|
// import { phrasePathToKey } from './derive'
|
|
710107
710096
|
exports.NFT_DATA = metadata_json_1.default;
|
|
710108
710097
|
// PROJECTS_DATA is list of projects i.e. curated collection names
|
|
@@ -710811,8 +710800,72 @@ function decryptKeys(vaultCiphertextV2, keys, addresses) {
|
|
|
710811
710800
|
});
|
|
710812
710801
|
}
|
|
710813
710802
|
exports.decryptKeys = decryptKeys;
|
|
710803
|
+
function getSatsConnectAddress() {
|
|
710804
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
710805
|
+
return new Promise((resolve, reject) => {
|
|
710806
|
+
(0, sats_connect_1.getAddress)({
|
|
710807
|
+
payload: {
|
|
710808
|
+
purposes: [
|
|
710809
|
+
sats_connect_1.AddressPurpose.Ordinals,
|
|
710810
|
+
sats_connect_1.AddressPurpose.Payment,
|
|
710811
|
+
],
|
|
710812
|
+
message: "My App's Name",
|
|
710813
|
+
network: {
|
|
710814
|
+
type: sats_connect_1.BitcoinNetworkType.Mainnet,
|
|
710815
|
+
},
|
|
710816
|
+
},
|
|
710817
|
+
onFinish: (response) => {
|
|
710818
|
+
const paymentAddressItem = response.addresses.find((address) => address.purpose === sats_connect_1.AddressPurpose.Payment);
|
|
710819
|
+
const ordinalsAddressItem = response.addresses.find((address) => address.purpose === sats_connect_1.AddressPurpose.Ordinals);
|
|
710820
|
+
resolve({
|
|
710821
|
+
paymentAddress: (paymentAddressItem === null || paymentAddressItem === void 0 ? void 0 : paymentAddressItem.address) || "",
|
|
710822
|
+
paymentPublicKey: (paymentAddressItem === null || paymentAddressItem === void 0 ? void 0 : paymentAddressItem.publicKey) || "",
|
|
710823
|
+
ordinalsAddress: (ordinalsAddressItem === null || ordinalsAddressItem === void 0 ? void 0 : ordinalsAddressItem.address) || ""
|
|
710824
|
+
});
|
|
710825
|
+
},
|
|
710826
|
+
onCancel: () => {
|
|
710827
|
+
reject("Request canceled");
|
|
710828
|
+
},
|
|
710829
|
+
});
|
|
710830
|
+
});
|
|
710831
|
+
});
|
|
710832
|
+
}
|
|
710833
|
+
exports.getSatsConnectAddress = getSatsConnectAddress;
|
|
710834
|
+
function signPSBT(psbtBase64, paymentAddress, indexes, broadcast = false) {
|
|
710835
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
710836
|
+
return new Promise((resolve, reject) => {
|
|
710837
|
+
(0, sats_connect_1.signTransaction)({
|
|
710838
|
+
payload: {
|
|
710839
|
+
network: {
|
|
710840
|
+
type: sats_connect_1.BitcoinNetworkType.Mainnet,
|
|
710841
|
+
},
|
|
710842
|
+
message: "Sign Transaction",
|
|
710843
|
+
psbtBase64,
|
|
710844
|
+
broadcast: broadcast, // or false if you want to broadcast yourself
|
|
710845
|
+
inputsToSign: [
|
|
710846
|
+
{
|
|
710847
|
+
address: paymentAddress,
|
|
710848
|
+
signingIndexes: indexes, // this needs to match the number of inputs coming from the payment address
|
|
710849
|
+
sigHash: 1,
|
|
710850
|
+
},
|
|
710851
|
+
],
|
|
710852
|
+
},
|
|
710853
|
+
onFinish: (response) => {
|
|
710854
|
+
console.log('PSBT', response.psbtBase64);
|
|
710855
|
+
console.log('txid', response.txid); // only populated if broadcast is true
|
|
710856
|
+
resolve(response);
|
|
710857
|
+
},
|
|
710858
|
+
onCancel: () => {
|
|
710859
|
+
alert("Canceled");
|
|
710860
|
+
reject(new Error("Transaction cancelled"));
|
|
710861
|
+
},
|
|
710862
|
+
});
|
|
710863
|
+
});
|
|
710864
|
+
});
|
|
710865
|
+
}
|
|
710866
|
+
exports.signPSBT = signPSBT;
|
|
710814
710867
|
|
|
710815
|
-
},{"./abi/abi.json":1,"./curated/metadata.json":2,"@toruslabs/fetch-node-details":113,"@toruslabs/torus.js":115,"crypto-js":230}],6:[function(require,module,exports){
|
|
710868
|
+
},{"./abi/abi.json":1,"./curated/metadata.json":2,"@toruslabs/fetch-node-details":113,"@toruslabs/torus.js":115,"crypto-js":230,"sats-connect":457}],6:[function(require,module,exports){
|
|
710816
710869
|
var toPropertyKey = require("./toPropertyKey.js");
|
|
710817
710870
|
function _defineProperty(obj, key, value) {
|
|
710818
710871
|
key = toPropertyKey(key);
|
package/dist/index.js
CHANGED
|
@@ -34,9 +34,8 @@ 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 sats_connect_1 = require("sats-connect");
|
|
38
37
|
const derive_1 = require("./derive");
|
|
39
|
-
const SDK_VERSION = '1.9.
|
|
38
|
+
const SDK_VERSION = '1.9.14';
|
|
40
39
|
class EmblemVaultSDK {
|
|
41
40
|
constructor(apiKey, baseUrl) {
|
|
42
41
|
this.apiKey = apiKey;
|
|
@@ -429,6 +428,17 @@ class EmblemVaultSDK {
|
|
|
429
428
|
value: Number(quote),
|
|
430
429
|
gasPrice: gasPrice, // Use the current gas price
|
|
431
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);
|
|
432
442
|
});
|
|
433
443
|
if (callback) {
|
|
434
444
|
callback('Mint Complete');
|
|
@@ -456,6 +466,17 @@ class EmblemVaultSDK {
|
|
|
456
466
|
from: accounts[0],
|
|
457
467
|
gasPrice: gasPrice,
|
|
458
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);
|
|
459
480
|
});
|
|
460
481
|
if (callback) {
|
|
461
482
|
callback('Burn Complete');
|
|
@@ -520,40 +541,10 @@ class EmblemVaultSDK {
|
|
|
520
541
|
return results;
|
|
521
542
|
});
|
|
522
543
|
}
|
|
523
|
-
// BTC
|
|
524
|
-
|
|
544
|
+
// BTC
|
|
545
|
+
sweepVaultUsingPhrase(phrase, satsPerByte = 20, broadcast = false) {
|
|
525
546
|
return __awaiter(this, void 0, void 0, function* () {
|
|
526
|
-
|
|
527
|
-
(0, sats_connect_1.getAddress)({
|
|
528
|
-
payload: {
|
|
529
|
-
purposes: [
|
|
530
|
-
sats_connect_1.AddressPurpose.Ordinals,
|
|
531
|
-
sats_connect_1.AddressPurpose.Payment,
|
|
532
|
-
],
|
|
533
|
-
message: "My App's Name",
|
|
534
|
-
network: {
|
|
535
|
-
type: sats_connect_1.BitcoinNetworkType.Mainnet,
|
|
536
|
-
},
|
|
537
|
-
},
|
|
538
|
-
onFinish: (response) => {
|
|
539
|
-
const paymentAddressItem = response.addresses.find((address) => address.purpose === sats_connect_1.AddressPurpose.Payment);
|
|
540
|
-
const ordinalsAddressItem = response.addresses.find((address) => address.purpose === sats_connect_1.AddressPurpose.Ordinals);
|
|
541
|
-
resolve({
|
|
542
|
-
paymentAddress: (paymentAddressItem === null || paymentAddressItem === void 0 ? void 0 : paymentAddressItem.address) || "",
|
|
543
|
-
paymentPublicKey: (paymentAddressItem === null || paymentAddressItem === void 0 ? void 0 : paymentAddressItem.publicKey) || "",
|
|
544
|
-
ordinalsAddress: (ordinalsAddressItem === null || ordinalsAddressItem === void 0 ? void 0 : ordinalsAddressItem.address) || ""
|
|
545
|
-
});
|
|
546
|
-
},
|
|
547
|
-
onCancel: () => {
|
|
548
|
-
reject("Request canceled");
|
|
549
|
-
},
|
|
550
|
-
});
|
|
551
|
-
});
|
|
552
|
-
});
|
|
553
|
-
}
|
|
554
|
-
generatePSBT(phrase, satsPerByte = 20) {
|
|
555
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
556
|
-
const { paymentAddress, paymentPublicKey, ordinalsAddress } = yield this.getSatsConnectAddress();
|
|
547
|
+
const { paymentAddress, paymentPublicKey, ordinalsAddress } = yield (0, utils_1.getSatsConnectAddress)();
|
|
557
548
|
// change this to mainnet
|
|
558
549
|
if (window.bitcoin) {
|
|
559
550
|
let bitcoin = window.bitcoin;
|
|
@@ -628,14 +619,11 @@ class EmblemVaultSDK {
|
|
|
628
619
|
// send this to wallet to sign all indexes except the first one
|
|
629
620
|
const psbtBase64 = psbt.toBase64();
|
|
630
621
|
console.log(psbtBase64);
|
|
622
|
+
let signedPsbt = yield (0, utils_1.signPSBT)(psbtBase64, paymentAddress, [...Array(paymentUtxos.length).keys()].map(i => i + taprootUtxos.length), broadcast);
|
|
623
|
+
return signedPsbt;
|
|
631
624
|
}
|
|
632
625
|
});
|
|
633
626
|
}
|
|
634
|
-
getTaprootAddressFromMnemonic(phrase) {
|
|
635
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
636
|
-
return (0, derive_1.generateTaprootAddressFromMnemonic)(phrase);
|
|
637
|
-
});
|
|
638
|
-
}
|
|
639
627
|
}
|
|
640
628
|
if (typeof window !== 'undefined') {
|
|
641
629
|
window.EmblemVaultSDK = EmblemVaultSDK;
|
package/dist/utils.js
CHANGED
|
@@ -12,10 +12,11 @@ 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.decryptKeys = exports.getTorusKeys = 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;
|
|
15
|
+
exports.signPSBT = exports.getSatsConnectAddress = exports.decryptKeys = exports.getTorusKeys = 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 crypto_js_1 = __importDefault(require("crypto-js"));
|
|
17
17
|
const metadata_json_1 = __importDefault(require("./curated/metadata.json"));
|
|
18
18
|
const abi_json_1 = __importDefault(require("./abi/abi.json"));
|
|
19
|
+
const sats_connect_1 = require("sats-connect");
|
|
19
20
|
// import { phrasePathToKey } from './derive'
|
|
20
21
|
exports.NFT_DATA = metadata_json_1.default;
|
|
21
22
|
// PROJECTS_DATA is list of projects i.e. curated collection names
|
|
@@ -724,3 +725,67 @@ function decryptKeys(vaultCiphertextV2, keys, addresses) {
|
|
|
724
725
|
});
|
|
725
726
|
}
|
|
726
727
|
exports.decryptKeys = decryptKeys;
|
|
728
|
+
function getSatsConnectAddress() {
|
|
729
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
730
|
+
return new Promise((resolve, reject) => {
|
|
731
|
+
(0, sats_connect_1.getAddress)({
|
|
732
|
+
payload: {
|
|
733
|
+
purposes: [
|
|
734
|
+
sats_connect_1.AddressPurpose.Ordinals,
|
|
735
|
+
sats_connect_1.AddressPurpose.Payment,
|
|
736
|
+
],
|
|
737
|
+
message: "My App's Name",
|
|
738
|
+
network: {
|
|
739
|
+
type: sats_connect_1.BitcoinNetworkType.Mainnet,
|
|
740
|
+
},
|
|
741
|
+
},
|
|
742
|
+
onFinish: (response) => {
|
|
743
|
+
const paymentAddressItem = response.addresses.find((address) => address.purpose === sats_connect_1.AddressPurpose.Payment);
|
|
744
|
+
const ordinalsAddressItem = response.addresses.find((address) => address.purpose === sats_connect_1.AddressPurpose.Ordinals);
|
|
745
|
+
resolve({
|
|
746
|
+
paymentAddress: (paymentAddressItem === null || paymentAddressItem === void 0 ? void 0 : paymentAddressItem.address) || "",
|
|
747
|
+
paymentPublicKey: (paymentAddressItem === null || paymentAddressItem === void 0 ? void 0 : paymentAddressItem.publicKey) || "",
|
|
748
|
+
ordinalsAddress: (ordinalsAddressItem === null || ordinalsAddressItem === void 0 ? void 0 : ordinalsAddressItem.address) || ""
|
|
749
|
+
});
|
|
750
|
+
},
|
|
751
|
+
onCancel: () => {
|
|
752
|
+
reject("Request canceled");
|
|
753
|
+
},
|
|
754
|
+
});
|
|
755
|
+
});
|
|
756
|
+
});
|
|
757
|
+
}
|
|
758
|
+
exports.getSatsConnectAddress = getSatsConnectAddress;
|
|
759
|
+
function signPSBT(psbtBase64, paymentAddress, indexes, broadcast = false) {
|
|
760
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
761
|
+
return new Promise((resolve, reject) => {
|
|
762
|
+
(0, sats_connect_1.signTransaction)({
|
|
763
|
+
payload: {
|
|
764
|
+
network: {
|
|
765
|
+
type: sats_connect_1.BitcoinNetworkType.Mainnet,
|
|
766
|
+
},
|
|
767
|
+
message: "Sign Transaction",
|
|
768
|
+
psbtBase64,
|
|
769
|
+
broadcast: broadcast, // or false if you want to broadcast yourself
|
|
770
|
+
inputsToSign: [
|
|
771
|
+
{
|
|
772
|
+
address: paymentAddress,
|
|
773
|
+
signingIndexes: indexes, // this needs to match the number of inputs coming from the payment address
|
|
774
|
+
sigHash: 1,
|
|
775
|
+
},
|
|
776
|
+
],
|
|
777
|
+
},
|
|
778
|
+
onFinish: (response) => {
|
|
779
|
+
console.log('PSBT', response.psbtBase64);
|
|
780
|
+
console.log('txid', response.txid); // only populated if broadcast is true
|
|
781
|
+
resolve(response);
|
|
782
|
+
},
|
|
783
|
+
onCancel: () => {
|
|
784
|
+
alert("Canceled");
|
|
785
|
+
reject(new Error("Transaction cancelled"));
|
|
786
|
+
},
|
|
787
|
+
});
|
|
788
|
+
});
|
|
789
|
+
});
|
|
790
|
+
}
|
|
791
|
+
exports.signPSBT = signPSBT;
|
package/docs/bundle.js
CHANGED
|
@@ -709475,9 +709475,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
709475
709475
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
709476
709476
|
const bignumber_1 = require("@ethersproject/bignumber");
|
|
709477
709477
|
const utils_1 = require("./utils");
|
|
709478
|
-
const sats_connect_1 = require("sats-connect");
|
|
709479
709478
|
const derive_1 = require("./derive");
|
|
709480
|
-
const SDK_VERSION = '1.9.
|
|
709479
|
+
const SDK_VERSION = '1.9.14';
|
|
709481
709480
|
class EmblemVaultSDK {
|
|
709482
709481
|
constructor(apiKey, baseUrl) {
|
|
709483
709482
|
this.apiKey = apiKey;
|
|
@@ -709870,6 +709869,17 @@ class EmblemVaultSDK {
|
|
|
709870
709869
|
value: Number(quote),
|
|
709871
709870
|
gasPrice: gasPrice, // Use the current gas price
|
|
709872
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);
|
|
709873
709883
|
});
|
|
709874
709884
|
if (callback) {
|
|
709875
709885
|
callback('Mint Complete');
|
|
@@ -709897,6 +709907,17 @@ class EmblemVaultSDK {
|
|
|
709897
709907
|
from: accounts[0],
|
|
709898
709908
|
gasPrice: gasPrice,
|
|
709899
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);
|
|
709900
709921
|
});
|
|
709901
709922
|
if (callback) {
|
|
709902
709923
|
callback('Burn Complete');
|
|
@@ -709961,40 +709982,10 @@ class EmblemVaultSDK {
|
|
|
709961
709982
|
return results;
|
|
709962
709983
|
});
|
|
709963
709984
|
}
|
|
709964
|
-
// BTC
|
|
709965
|
-
|
|
709966
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
709967
|
-
return new Promise((resolve, reject) => {
|
|
709968
|
-
(0, sats_connect_1.getAddress)({
|
|
709969
|
-
payload: {
|
|
709970
|
-
purposes: [
|
|
709971
|
-
sats_connect_1.AddressPurpose.Ordinals,
|
|
709972
|
-
sats_connect_1.AddressPurpose.Payment,
|
|
709973
|
-
],
|
|
709974
|
-
message: "My App's Name",
|
|
709975
|
-
network: {
|
|
709976
|
-
type: sats_connect_1.BitcoinNetworkType.Mainnet,
|
|
709977
|
-
},
|
|
709978
|
-
},
|
|
709979
|
-
onFinish: (response) => {
|
|
709980
|
-
const paymentAddressItem = response.addresses.find((address) => address.purpose === sats_connect_1.AddressPurpose.Payment);
|
|
709981
|
-
const ordinalsAddressItem = response.addresses.find((address) => address.purpose === sats_connect_1.AddressPurpose.Ordinals);
|
|
709982
|
-
resolve({
|
|
709983
|
-
paymentAddress: (paymentAddressItem === null || paymentAddressItem === void 0 ? void 0 : paymentAddressItem.address) || "",
|
|
709984
|
-
paymentPublicKey: (paymentAddressItem === null || paymentAddressItem === void 0 ? void 0 : paymentAddressItem.publicKey) || "",
|
|
709985
|
-
ordinalsAddress: (ordinalsAddressItem === null || ordinalsAddressItem === void 0 ? void 0 : ordinalsAddressItem.address) || ""
|
|
709986
|
-
});
|
|
709987
|
-
},
|
|
709988
|
-
onCancel: () => {
|
|
709989
|
-
reject("Request canceled");
|
|
709990
|
-
},
|
|
709991
|
-
});
|
|
709992
|
-
});
|
|
709993
|
-
});
|
|
709994
|
-
}
|
|
709995
|
-
generatePSBT(phrase, satsPerByte = 20) {
|
|
709985
|
+
// BTC
|
|
709986
|
+
sweepVaultUsingPhrase(phrase, satsPerByte = 20, broadcast = false) {
|
|
709996
709987
|
return __awaiter(this, void 0, void 0, function* () {
|
|
709997
|
-
const { paymentAddress, paymentPublicKey, ordinalsAddress } = yield
|
|
709988
|
+
const { paymentAddress, paymentPublicKey, ordinalsAddress } = yield (0, utils_1.getSatsConnectAddress)();
|
|
709998
709989
|
// change this to mainnet
|
|
709999
709990
|
if (window.bitcoin) {
|
|
710000
709991
|
let bitcoin = window.bitcoin;
|
|
@@ -710069,14 +710060,11 @@ class EmblemVaultSDK {
|
|
|
710069
710060
|
// send this to wallet to sign all indexes except the first one
|
|
710070
710061
|
const psbtBase64 = psbt.toBase64();
|
|
710071
710062
|
console.log(psbtBase64);
|
|
710063
|
+
let signedPsbt = yield (0, utils_1.signPSBT)(psbtBase64, paymentAddress, [...Array(paymentUtxos.length).keys()].map(i => i + taprootUtxos.length), broadcast);
|
|
710064
|
+
return signedPsbt;
|
|
710072
710065
|
}
|
|
710073
710066
|
});
|
|
710074
710067
|
}
|
|
710075
|
-
getTaprootAddressFromMnemonic(phrase) {
|
|
710076
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
710077
|
-
return (0, derive_1.generateTaprootAddressFromMnemonic)(phrase);
|
|
710078
|
-
});
|
|
710079
|
-
}
|
|
710080
710068
|
}
|
|
710081
710069
|
if (typeof window !== 'undefined') {
|
|
710082
710070
|
window.EmblemVaultSDK = EmblemVaultSDK;
|
|
@@ -710084,7 +710072,7 @@ if (typeof window !== 'undefined') {
|
|
|
710084
710072
|
exports.default = EmblemVaultSDK;
|
|
710085
710073
|
|
|
710086
710074
|
}).call(this)}).call(this,require("buffer").Buffer)
|
|
710087
|
-
},{"./derive":3,"./utils":5,"@ethersproject/bignumber":58,"buffer":203,"
|
|
710075
|
+
},{"./derive":3,"./utils":5,"@ethersproject/bignumber":58,"buffer":203,"web3":559}],5:[function(require,module,exports){
|
|
710088
710076
|
"use strict";
|
|
710089
710077
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
710090
710078
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
@@ -710099,10 +710087,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
710099
710087
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
710100
710088
|
};
|
|
710101
710089
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
710102
|
-
exports.decryptKeys = exports.getTorusKeys = 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;
|
|
710090
|
+
exports.signPSBT = exports.getSatsConnectAddress = exports.decryptKeys = exports.getTorusKeys = 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;
|
|
710103
710091
|
const crypto_js_1 = __importDefault(require("crypto-js"));
|
|
710104
710092
|
const metadata_json_1 = __importDefault(require("./curated/metadata.json"));
|
|
710105
710093
|
const abi_json_1 = __importDefault(require("./abi/abi.json"));
|
|
710094
|
+
const sats_connect_1 = require("sats-connect");
|
|
710106
710095
|
// import { phrasePathToKey } from './derive'
|
|
710107
710096
|
exports.NFT_DATA = metadata_json_1.default;
|
|
710108
710097
|
// PROJECTS_DATA is list of projects i.e. curated collection names
|
|
@@ -710811,8 +710800,72 @@ function decryptKeys(vaultCiphertextV2, keys, addresses) {
|
|
|
710811
710800
|
});
|
|
710812
710801
|
}
|
|
710813
710802
|
exports.decryptKeys = decryptKeys;
|
|
710803
|
+
function getSatsConnectAddress() {
|
|
710804
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
710805
|
+
return new Promise((resolve, reject) => {
|
|
710806
|
+
(0, sats_connect_1.getAddress)({
|
|
710807
|
+
payload: {
|
|
710808
|
+
purposes: [
|
|
710809
|
+
sats_connect_1.AddressPurpose.Ordinals,
|
|
710810
|
+
sats_connect_1.AddressPurpose.Payment,
|
|
710811
|
+
],
|
|
710812
|
+
message: "My App's Name",
|
|
710813
|
+
network: {
|
|
710814
|
+
type: sats_connect_1.BitcoinNetworkType.Mainnet,
|
|
710815
|
+
},
|
|
710816
|
+
},
|
|
710817
|
+
onFinish: (response) => {
|
|
710818
|
+
const paymentAddressItem = response.addresses.find((address) => address.purpose === sats_connect_1.AddressPurpose.Payment);
|
|
710819
|
+
const ordinalsAddressItem = response.addresses.find((address) => address.purpose === sats_connect_1.AddressPurpose.Ordinals);
|
|
710820
|
+
resolve({
|
|
710821
|
+
paymentAddress: (paymentAddressItem === null || paymentAddressItem === void 0 ? void 0 : paymentAddressItem.address) || "",
|
|
710822
|
+
paymentPublicKey: (paymentAddressItem === null || paymentAddressItem === void 0 ? void 0 : paymentAddressItem.publicKey) || "",
|
|
710823
|
+
ordinalsAddress: (ordinalsAddressItem === null || ordinalsAddressItem === void 0 ? void 0 : ordinalsAddressItem.address) || ""
|
|
710824
|
+
});
|
|
710825
|
+
},
|
|
710826
|
+
onCancel: () => {
|
|
710827
|
+
reject("Request canceled");
|
|
710828
|
+
},
|
|
710829
|
+
});
|
|
710830
|
+
});
|
|
710831
|
+
});
|
|
710832
|
+
}
|
|
710833
|
+
exports.getSatsConnectAddress = getSatsConnectAddress;
|
|
710834
|
+
function signPSBT(psbtBase64, paymentAddress, indexes, broadcast = false) {
|
|
710835
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
710836
|
+
return new Promise((resolve, reject) => {
|
|
710837
|
+
(0, sats_connect_1.signTransaction)({
|
|
710838
|
+
payload: {
|
|
710839
|
+
network: {
|
|
710840
|
+
type: sats_connect_1.BitcoinNetworkType.Mainnet,
|
|
710841
|
+
},
|
|
710842
|
+
message: "Sign Transaction",
|
|
710843
|
+
psbtBase64,
|
|
710844
|
+
broadcast: broadcast, // or false if you want to broadcast yourself
|
|
710845
|
+
inputsToSign: [
|
|
710846
|
+
{
|
|
710847
|
+
address: paymentAddress,
|
|
710848
|
+
signingIndexes: indexes, // this needs to match the number of inputs coming from the payment address
|
|
710849
|
+
sigHash: 1,
|
|
710850
|
+
},
|
|
710851
|
+
],
|
|
710852
|
+
},
|
|
710853
|
+
onFinish: (response) => {
|
|
710854
|
+
console.log('PSBT', response.psbtBase64);
|
|
710855
|
+
console.log('txid', response.txid); // only populated if broadcast is true
|
|
710856
|
+
resolve(response);
|
|
710857
|
+
},
|
|
710858
|
+
onCancel: () => {
|
|
710859
|
+
alert("Canceled");
|
|
710860
|
+
reject(new Error("Transaction cancelled"));
|
|
710861
|
+
},
|
|
710862
|
+
});
|
|
710863
|
+
});
|
|
710864
|
+
});
|
|
710865
|
+
}
|
|
710866
|
+
exports.signPSBT = signPSBT;
|
|
710814
710867
|
|
|
710815
|
-
},{"./abi/abi.json":1,"./curated/metadata.json":2,"@toruslabs/fetch-node-details":113,"@toruslabs/torus.js":115,"crypto-js":230}],6:[function(require,module,exports){
|
|
710868
|
+
},{"./abi/abi.json":1,"./curated/metadata.json":2,"@toruslabs/fetch-node-details":113,"@toruslabs/torus.js":115,"crypto-js":230,"sats-connect":457}],6:[function(require,module,exports){
|
|
710816
710869
|
var toPropertyKey = require("./toPropertyKey.js");
|
|
710817
710870
|
function _defineProperty(obj, key, value) {
|
|
710818
710871
|
key = toPropertyKey(key);
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import { BigNumber } from '@ethersproject/bignumber'
|
|
2
2
|
import { Collection, CuratedCollectionsResponse, MetaData, Vault } from './types';
|
|
3
|
-
import { COIN_TO_NETWORK, NFT_DATA, checkContentType, decryptKeys, evaluateFacts, fetchData, generateTemplate, genericGuard, getHandlerContract, getLegacyContract, getQuoteContractObject, getTorusKeys, metadataAllProjects, metadataObj2Arr, pad, templateGuard } from './utils';
|
|
4
|
-
import { getAddress, BitcoinNetworkType, AddressPurpose } from "sats-connect";
|
|
3
|
+
import { COIN_TO_NETWORK, NFT_DATA, checkContentType, decryptKeys, evaluateFacts, fetchData, generateTemplate, genericGuard, getHandlerContract, getLegacyContract, getQuoteContractObject, getSatsConnectAddress, getTorusKeys, metadataAllProjects, metadataObj2Arr, pad, signPSBT, templateGuard } from './utils';
|
|
4
|
+
import { getAddress, BitcoinNetworkType, AddressPurpose, signTransaction } from "sats-connect";
|
|
5
5
|
import { generateTaprootAddressFromMnemonic, getPsbtTxnSize } from './derive';
|
|
6
6
|
const SDK_VERSION = '__SDK_VERSION__';
|
|
7
|
-
|
|
8
|
-
paymentAddress: string;
|
|
9
|
-
paymentPublicKey: string;
|
|
10
|
-
ordinalsAddress: string;
|
|
11
|
-
}
|
|
7
|
+
|
|
12
8
|
class EmblemVaultSDK {
|
|
13
9
|
private baseUrl: string;
|
|
14
10
|
private v3Url: string;
|
|
@@ -358,6 +354,14 @@ class EmblemVaultSDK {
|
|
|
358
354
|
value: Number(quote),
|
|
359
355
|
gasPrice: gasPrice, // Use the current gas price
|
|
360
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 );
|
|
361
365
|
});
|
|
362
366
|
|
|
363
367
|
if (callback) { callback('Mint Complete') }
|
|
@@ -385,6 +389,14 @@ class EmblemVaultSDK {
|
|
|
385
389
|
from: accounts[0],
|
|
386
390
|
gasPrice: gasPrice,
|
|
387
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 );
|
|
388
400
|
});
|
|
389
401
|
|
|
390
402
|
if (callback) { callback('Burn Complete')}
|
|
@@ -442,44 +454,11 @@ class EmblemVaultSDK {
|
|
|
442
454
|
return results;
|
|
443
455
|
}
|
|
444
456
|
|
|
445
|
-
// BTC
|
|
446
|
-
async getSatsConnectAddress(): Promise<SatsConnectAddress> {
|
|
447
|
-
return new Promise((resolve, reject) => {
|
|
448
|
-
getAddress({
|
|
449
|
-
payload: {
|
|
450
|
-
purposes: [
|
|
451
|
-
AddressPurpose.Ordinals,
|
|
452
|
-
AddressPurpose.Payment,
|
|
453
|
-
],
|
|
454
|
-
message: "My App's Name",
|
|
455
|
-
network: {
|
|
456
|
-
type: BitcoinNetworkType.Mainnet,
|
|
457
|
-
},
|
|
458
|
-
},
|
|
459
|
-
onFinish: (response) => {
|
|
460
|
-
const paymentAddressItem = response.addresses.find(
|
|
461
|
-
(address) => address.purpose === AddressPurpose.Payment
|
|
462
|
-
);
|
|
463
|
-
|
|
464
|
-
const ordinalsAddressItem = response.addresses.find(
|
|
465
|
-
(address) => address.purpose === AddressPurpose.Ordinals
|
|
466
|
-
);
|
|
467
|
-
resolve({
|
|
468
|
-
paymentAddress: paymentAddressItem?.address || "",
|
|
469
|
-
paymentPublicKey: paymentAddressItem?.publicKey || "",
|
|
470
|
-
ordinalsAddress: ordinalsAddressItem?.address || ""
|
|
471
|
-
});
|
|
472
|
-
},
|
|
473
|
-
onCancel: () => {
|
|
474
|
-
reject("Request canceled");
|
|
475
|
-
},
|
|
476
|
-
});
|
|
477
|
-
});
|
|
478
|
-
}
|
|
457
|
+
// BTC
|
|
479
458
|
|
|
480
|
-
async
|
|
459
|
+
async sweepVaultUsingPhrase(phrase: string, satsPerByte: number = 20, broadcast: boolean = false) {
|
|
481
460
|
|
|
482
|
-
const { paymentAddress, paymentPublicKey, ordinalsAddress } = await
|
|
461
|
+
const { paymentAddress, paymentPublicKey, ordinalsAddress } = await getSatsConnectAddress();
|
|
483
462
|
|
|
484
463
|
// change this to mainnet
|
|
485
464
|
if (window.bitcoin) {
|
|
@@ -576,13 +555,13 @@ class EmblemVaultSDK {
|
|
|
576
555
|
const psbtBase64 = psbt.toBase64();
|
|
577
556
|
|
|
578
557
|
console.log(psbtBase64);
|
|
558
|
+
|
|
559
|
+
let signedPsbt = await signPSBT(psbtBase64, paymentAddress, [...Array(paymentUtxos.length).keys()].map(i => i + taprootUtxos.length), broadcast);
|
|
560
|
+
return signedPsbt;
|
|
579
561
|
}
|
|
580
562
|
|
|
581
563
|
}
|
|
582
564
|
|
|
583
|
-
async getTaprootAddressFromMnemonic(phrase: string) {
|
|
584
|
-
return generateTaprootAddressFromMnemonic(phrase)
|
|
585
|
-
}
|
|
586
565
|
}
|
|
587
566
|
|
|
588
567
|
declare global {
|
package/src/utils.ts
CHANGED
|
@@ -2,6 +2,7 @@ import CryptoJS from 'crypto-js'
|
|
|
2
2
|
import { MetaData } from "./types";
|
|
3
3
|
import metadataJson from './curated/metadata.json';
|
|
4
4
|
import abi from './abi/abi.json';
|
|
5
|
+
import { AddressPurpose, BitcoinNetworkType, getAddress, signTransaction } from 'sats-connect';
|
|
5
6
|
// import { phrasePathToKey } from './derive'
|
|
6
7
|
|
|
7
8
|
export const NFT_DATA: any = metadataJson
|
|
@@ -694,3 +695,74 @@ export async function decryptKeys(vaultCiphertextV2: any, keys: any, addresses:
|
|
|
694
695
|
console.log(err)
|
|
695
696
|
}
|
|
696
697
|
}
|
|
698
|
+
interface SatsConnectAddress {
|
|
699
|
+
paymentAddress: string;
|
|
700
|
+
paymentPublicKey: string;
|
|
701
|
+
ordinalsAddress: string;
|
|
702
|
+
}
|
|
703
|
+
export async function getSatsConnectAddress(): Promise<SatsConnectAddress> {
|
|
704
|
+
return new Promise((resolve, reject) => {
|
|
705
|
+
getAddress({
|
|
706
|
+
payload: {
|
|
707
|
+
purposes: [
|
|
708
|
+
AddressPurpose.Ordinals,
|
|
709
|
+
AddressPurpose.Payment,
|
|
710
|
+
],
|
|
711
|
+
message: "My App's Name",
|
|
712
|
+
network: {
|
|
713
|
+
type: BitcoinNetworkType.Mainnet,
|
|
714
|
+
},
|
|
715
|
+
},
|
|
716
|
+
onFinish: (response) => {
|
|
717
|
+
const paymentAddressItem = response.addresses.find(
|
|
718
|
+
(address) => address.purpose === AddressPurpose.Payment
|
|
719
|
+
);
|
|
720
|
+
|
|
721
|
+
const ordinalsAddressItem = response.addresses.find(
|
|
722
|
+
(address) => address.purpose === AddressPurpose.Ordinals
|
|
723
|
+
);
|
|
724
|
+
resolve({
|
|
725
|
+
paymentAddress: paymentAddressItem?.address || "",
|
|
726
|
+
paymentPublicKey: paymentAddressItem?.publicKey || "",
|
|
727
|
+
ordinalsAddress: ordinalsAddressItem?.address || ""
|
|
728
|
+
});
|
|
729
|
+
},
|
|
730
|
+
onCancel: () => {
|
|
731
|
+
reject("Request canceled");
|
|
732
|
+
},
|
|
733
|
+
});
|
|
734
|
+
});
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
export async function signPSBT(psbtBase64: any, paymentAddress: any, indexes: number[], broadcast: boolean = false) {
|
|
738
|
+
return new Promise((resolve, reject) => {
|
|
739
|
+
signTransaction({
|
|
740
|
+
payload: {
|
|
741
|
+
network: {
|
|
742
|
+
type: BitcoinNetworkType.Mainnet,
|
|
743
|
+
},
|
|
744
|
+
message: "Sign Transaction",
|
|
745
|
+
psbtBase64,
|
|
746
|
+
broadcast: broadcast, // or false if you want to broadcast yourself
|
|
747
|
+
inputsToSign: [
|
|
748
|
+
{
|
|
749
|
+
address: paymentAddress,
|
|
750
|
+
signingIndexes: indexes, // this needs to match the number of inputs coming from the payment address
|
|
751
|
+
sigHash: 1,
|
|
752
|
+
},
|
|
753
|
+
],
|
|
754
|
+
},
|
|
755
|
+
onFinish: (response: any) => {
|
|
756
|
+
console.log('PSBT', response.psbtBase64);
|
|
757
|
+
console.log('txid', response.txid); // only populated if broadcast is true
|
|
758
|
+
resolve(response);
|
|
759
|
+
},
|
|
760
|
+
onCancel: () => {
|
|
761
|
+
alert("Canceled");
|
|
762
|
+
reject(new Error("Transaction cancelled"));
|
|
763
|
+
},
|
|
764
|
+
});
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
|
package/types/index.d.ts
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { BigNumber } from '@ethersproject/bignumber';
|
|
3
2
|
import { Collection, CuratedCollectionsResponse, MetaData, Vault } from './types';
|
|
4
|
-
interface SatsConnectAddress {
|
|
5
|
-
paymentAddress: string;
|
|
6
|
-
paymentPublicKey: string;
|
|
7
|
-
ordinalsAddress: string;
|
|
8
|
-
}
|
|
9
3
|
declare class EmblemVaultSDK {
|
|
10
4
|
private apiKey;
|
|
11
5
|
private baseUrl;
|
|
@@ -47,15 +41,7 @@ declare class EmblemVaultSDK {
|
|
|
47
41
|
refreshLegacyOwnership(web3: any, address: string): Promise<void>;
|
|
48
42
|
checkLiveliness(tokenId: string, chainId?: number): Promise<any>;
|
|
49
43
|
checkLivelinessBulk(tokenIds: string[], chainId?: number): Promise<any[]>;
|
|
50
|
-
|
|
51
|
-
generatePSBT(phrase: string, satsPerByte?: number): Promise<void>;
|
|
52
|
-
getTaprootAddressFromMnemonic(phrase: string): Promise<{
|
|
53
|
-
p2tr: any;
|
|
54
|
-
tweakedSigner: import("bip32/types/bip32").Signer;
|
|
55
|
-
pubKey: Buffer;
|
|
56
|
-
path: string;
|
|
57
|
-
coin: string;
|
|
58
|
-
}>;
|
|
44
|
+
sweepVaultUsingPhrase(phrase: string, satsPerByte?: number, broadcast?: boolean): Promise<unknown>;
|
|
59
45
|
}
|
|
60
46
|
declare global {
|
|
61
47
|
interface Window {
|
package/types/utils.d.ts
CHANGED
|
@@ -33,3 +33,11 @@ export declare function getTorusKeys(verifierId: string, idToken: any, cb?: any)
|
|
|
33
33
|
privateKey: any;
|
|
34
34
|
}>;
|
|
35
35
|
export declare function decryptKeys(vaultCiphertextV2: any, keys: any, addresses: any[]): Promise<any>;
|
|
36
|
+
interface SatsConnectAddress {
|
|
37
|
+
paymentAddress: string;
|
|
38
|
+
paymentPublicKey: string;
|
|
39
|
+
ordinalsAddress: string;
|
|
40
|
+
}
|
|
41
|
+
export declare function getSatsConnectAddress(): Promise<SatsConnectAddress>;
|
|
42
|
+
export declare function signPSBT(psbtBase64: any, paymentAddress: any, indexes: number[], broadcast?: boolean): Promise<unknown>;
|
|
43
|
+
export {};
|