@ibearua/bitmask-core-dev 1.0.0-beta.11 → 1.0.0-beta.12

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/rgb.js ADDED
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ // Methods meant to work with RGB contracts defined within the web::rgb module from bitmask-core:
3
+ // https://github.com/diba-io/bitmask-core/blob/development/src/web.rs
4
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5
+ if (k2 === undefined) k2 = k;
6
+ var desc = Object.getOwnPropertyDescriptor(m, k);
7
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
8
+ desc = { enumerable: true, get: function() { return m[k]; } };
9
+ }
10
+ Object.defineProperty(o, k2, desc);
11
+ }) : (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ o[k2] = m[k];
14
+ }));
15
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
16
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
17
+ }) : function(o, v) {
18
+ o["default"] = v;
19
+ });
20
+ var __importStar = (this && this.__importStar) || function (mod) {
21
+ if (mod && mod.__esModule) return mod;
22
+ var result = {};
23
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
24
+ __setModuleDefault(result, mod);
25
+ return result;
26
+ };
27
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
28
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
29
+ return new (P || (P = Promise))(function (resolve, reject) {
30
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
31
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
32
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
33
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
34
+ });
35
+ };
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.RgbSwap = exports.toContractPrecision = exports.toContractAmount = exports.toContractAmountStr = exports.toContractAmountRaw = exports.psbtSignAndPublishFile = exports.psbtPublishFile = exports.decodeInvoice = exports.getRgbWallet = exports.restoreWallet = exports.backupWallet = exports.cancelBid = exports.createBid = exports.canCreateBid = exports.cancelOffer = exports.createOffer = exports.canCreateOffer = exports.bidSwapSuppl = exports.offerSwapSuppl = exports.bids = exports.offers = exports.listOffers = exports.verifyTransfers = exports.listTransfers = exports.saveTransfer = exports.listInvoices = exports.removeInvoice = exports.acceptTransfer = exports.createAndPublishTransfer = exports.createTransfer = exports.canCreateTransfer = exports.createInvoice = exports.issueContract = exports.importContract = exports.listContracts = exports.getContract = exports.getVersion = void 0;
38
+ const BMC = __importStar(require("./bitmask_core"));
39
+ const getVersion = () => JSON.parse(BMC.get_rgb_version());
40
+ exports.getVersion = getVersion;
41
+ const getContract = (nostrHexSk, request) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.get_contract(nostrHexSk, request)); });
42
+ exports.getContract = getContract;
43
+ const listContracts = (nostrHexSk, hidden) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.list_contracts(nostrHexSk, hidden)); });
44
+ exports.listContracts = listContracts;
45
+ const importContract = (nostrHexSk, request) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.import_contract(nostrHexSk, request)); });
46
+ exports.importContract = importContract;
47
+ const issueContract = (nostrHexSk, request) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.issue_contract_proxy(nostrHexSk, request)); });
48
+ exports.issueContract = issueContract;
49
+ const createInvoice = (nostrHexSk, request) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.create_rgb_invoice(nostrHexSk, request)); });
50
+ exports.createInvoice = createInvoice;
51
+ const canCreateTransfer = (nostrHexSk, request) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.can_create_transfer_contract(nostrHexSk, request)); });
52
+ exports.canCreateTransfer = canCreateTransfer;
53
+ const createTransfer = (nostrHexSk, request) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.create_rgb_transfer(nostrHexSk, request)); });
54
+ exports.createTransfer = createTransfer;
55
+ const createAndPublishTransfer = (nostrHexSk, request, secrets) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.create_and_publish_rgb_transfer(nostrHexSk, request, secrets)); });
56
+ exports.createAndPublishTransfer = createAndPublishTransfer;
57
+ const acceptTransfer = (nostrHexSk, request) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.accept_transfer(nostrHexSk, request)); });
58
+ exports.acceptTransfer = acceptTransfer;
59
+ const removeInvoice = (nostrHexSk, request) => __awaiter(void 0, void 0, void 0, function* () {
60
+ yield BMC.remove_rgb_invoice(nostrHexSk, request);
61
+ });
62
+ exports.removeInvoice = removeInvoice;
63
+ const listInvoices = (nostrHexSk) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.list_rgb_invoices(nostrHexSk)); });
64
+ exports.listInvoices = listInvoices;
65
+ const saveTransfer = (nostrHexSk, request) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.save_transfer(nostrHexSk, request)); });
66
+ exports.saveTransfer = saveTransfer;
67
+ const listTransfers = (nostrHexSk) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.list_transfers(nostrHexSk)); });
68
+ exports.listTransfers = listTransfers;
69
+ const verifyTransfers = (nostrHexSk) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.verify_transfers(nostrHexSk)); });
70
+ exports.verifyTransfers = verifyTransfers;
71
+ const listOffers = (nostrHexSk) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.list_offers(nostrHexSk)); });
72
+ exports.listOffers = listOffers;
73
+ const offers = (nostrHexSk) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.offers(nostrHexSk)); });
74
+ exports.offers = offers;
75
+ const bids = (nostrHexSk) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.bids(nostrHexSk)); });
76
+ exports.bids = bids;
77
+ const offerSwapSuppl = (nostrHexSk, offerId) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.offer_swap_suppl(nostrHexSk, offerId)); });
78
+ exports.offerSwapSuppl = offerSwapSuppl;
79
+ const bidSwapSuppl = (nostrHexSk, bidId) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.bid_swap_suppl(nostrHexSk, bidId)); });
80
+ exports.bidSwapSuppl = bidSwapSuppl;
81
+ const canCreateOffer = (nostrHexSk, request, secrets) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.can_create_offer(nostrHexSk, request, secrets)); });
82
+ exports.canCreateOffer = canCreateOffer;
83
+ const createOffer = (nostrHexSk, request, secrets) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.create_offer(nostrHexSk, request, secrets)); });
84
+ exports.createOffer = createOffer;
85
+ const cancelOffer = (nostrHexSk, request) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.cancel_offer(nostrHexSk, request)); });
86
+ exports.cancelOffer = cancelOffer;
87
+ const canCreateBid = (nostrHexSk, request, secrets) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.can_create_bid(nostrHexSk, request, secrets)); });
88
+ exports.canCreateBid = canCreateBid;
89
+ const createBid = (nostrHexSk, request, secrets) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.create_bid(nostrHexSk, request, secrets)); });
90
+ exports.createBid = createBid;
91
+ const cancelBid = (nostrHexSk, request) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.cancel_bid(nostrHexSk, request)); });
92
+ exports.cancelBid = cancelBid;
93
+ // BITCOIN
94
+ const backupWallet = (nostrHexSk) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.backup_rgb_data(nostrHexSk)); });
95
+ exports.backupWallet = backupWallet;
96
+ const restoreWallet = (nostrHexSk) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.restore_rgb_data(nostrHexSk)); });
97
+ exports.restoreWallet = restoreWallet;
98
+ const getRgbWallet = (nostrHexSk) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.get_rgb_wallet(nostrHexSk)); });
99
+ exports.getRgbWallet = getRgbWallet;
100
+ const decodeInvoice = (invoice) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.decode_rgb_invoice(invoice)); });
101
+ exports.decodeInvoice = decodeInvoice;
102
+ const psbtPublishFile = (request) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.psbt_publish_file(request)); });
103
+ exports.psbtPublishFile = psbtPublishFile;
104
+ const psbtSignAndPublishFile = (_nostrHexSk, request) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.psbt_sign_and_publish_file(request)); });
105
+ exports.psbtSignAndPublishFile = psbtSignAndPublishFile;
106
+ const toContractAmountRaw = (decimal, precision) => JSON.parse(BMC.convert_contract_amount_raw(decimal, precision));
107
+ exports.toContractAmountRaw = toContractAmountRaw;
108
+ const toContractAmountStr = (amount, precision) => JSON.parse(BMC.convert_contract_amount_string(amount, precision));
109
+ exports.toContractAmountStr = toContractAmountStr;
110
+ const toContractAmount = (amount) => JSON.parse(BMC.parse_contract_amount(amount));
111
+ exports.toContractAmount = toContractAmount;
112
+ const toContractPrecision = (amount, precision) => JSON.parse(BMC.parse_contract_amount_precision(amount, precision));
113
+ exports.toContractPrecision = toContractPrecision;
114
+ var RgbSwap;
115
+ (function (RgbSwap) {
116
+ RgbSwap["auction"] = "auction";
117
+ RgbSwap["p2p"] = "p2p";
118
+ RgbSwap["hotSwap"] = "hotswap";
119
+ RgbSwap["airdrop"] = "airdrop";
120
+ })(RgbSwap || (exports.RgbSwap = RgbSwap = {}));