mirror of
https://github.com/Permissionless-Software-Foundation/bch-dex-taker-v2.git
synced 2026-09-21 16:52:01 -07:00
Merge pull request #3 from Permissionless-Software-Foundation/ct-unstable
Added Buy functionality
This commit is contained in:
Generated
+216
-16
@@ -16,8 +16,11 @@
|
||||
"axios": "0.27.2",
|
||||
"bch-dex-lib": "2.0.2",
|
||||
"bch-message-lib": "2.2.1",
|
||||
"bch-nostr": "1.3.4",
|
||||
"bootstrap": "5.2.0",
|
||||
"crypto-browserify": "3.12.1",
|
||||
"nostr-tools": "2.10.4",
|
||||
"p2wdb": "2.4.1",
|
||||
"process": "0.11.10",
|
||||
"qrcode.react": "4.2.0",
|
||||
"query-string": "7.1.1",
|
||||
@@ -32,6 +35,7 @@
|
||||
"vm-browserify": "1.1.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
|
||||
"minimal-slp-wallet": "5.13.1",
|
||||
"react-app-rewired": "2.2.1",
|
||||
"standard": "17.0.0",
|
||||
@@ -594,8 +598,18 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/plugin-proposal-private-property-in-object": {
|
||||
"version": "7.21.0-placeholder-for-preset-env.2",
|
||||
"version": "7.21.11",
|
||||
"resolved": "http://94.130.170.209:4873/@babel%2fplugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.11.tgz",
|
||||
"integrity": "sha512-0QZ8qP/3RLDVBwBFoWAwCtgcDZJVwA5LUJRZU8x2YFfKNuFq161wK3cuGrALu5yiPu+vzwTAg/sMWVNeWeNyaw==",
|
||||
"deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-private-property-in-object instead.",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@babel/helper-annotate-as-pure": "^7.18.6",
|
||||
"@babel/helper-create-class-features-plugin": "^7.21.0",
|
||||
"@babel/helper-plugin-utils": "^7.20.2",
|
||||
"@babel/plugin-syntax-private-property-in-object": "^7.14.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
},
|
||||
@@ -1749,6 +1763,18 @@
|
||||
"@babel/core": "^7.0.0-0"
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/preset-env/node_modules/@babel/plugin-proposal-private-property-in-object": {
|
||||
"version": "7.21.0-placeholder-for-preset-env.2",
|
||||
"resolved": "http://94.130.170.209:4873/@babel%2fplugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.0-placeholder-for-preset-env.2.tgz",
|
||||
"integrity": "sha512-SOSkfJDddaM7mak6cPEpswyTRnuRltl429hMraQEglW+OkovnCzsiszTmsrlY//qLFjCpQDFRvjdm2wA5pPm9w==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": "^7.0.0-0"
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/preset-env/node_modules/semver": {
|
||||
"version": "6.3.1",
|
||||
"license": "ISC",
|
||||
@@ -1873,6 +1899,7 @@
|
||||
},
|
||||
"node_modules/@chris.troutner/bip32-utils": {
|
||||
"version": "1.0.5",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"keccak": "^3.0.1",
|
||||
@@ -1884,6 +1911,8 @@
|
||||
},
|
||||
"node_modules/@chris.troutner/nostr-tools": {
|
||||
"version": "2.10.4",
|
||||
"resolved": "http://94.130.170.209:4873/@chris.troutner%2fnostr-tools/-/nostr-tools-2.10.4.tgz",
|
||||
"integrity": "sha512-e8AYJ0yQ0O3bvnuXQUIdB+P3W7f06st+TXfmbpd6U7IpJ5jWhczoLGvF0NiCgKB6YHTaTGx4hoRLF2A744PzmQ==",
|
||||
"license": "Unlicense",
|
||||
"dependencies": {
|
||||
"@noble/ciphers": "^0.5.1",
|
||||
@@ -2850,6 +2879,7 @@
|
||||
},
|
||||
"node_modules/@ljharb/resumer": {
|
||||
"version": "0.1.3",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@ljharb/through": "^2.3.13",
|
||||
@@ -2861,6 +2891,7 @@
|
||||
},
|
||||
"node_modules/@ljharb/through": {
|
||||
"version": "2.3.14",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bind": "^1.0.8"
|
||||
@@ -3116,6 +3147,7 @@
|
||||
},
|
||||
"node_modules/@psf/bch-js": {
|
||||
"version": "6.8.0",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@chris.troutner/bip32-utils": "1.0.5",
|
||||
@@ -3146,6 +3178,7 @@
|
||||
},
|
||||
"node_modules/@psf/bch-js/node_modules/axios": {
|
||||
"version": "0.26.1",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"follow-redirects": "^1.14.8"
|
||||
@@ -3153,6 +3186,7 @@
|
||||
},
|
||||
"node_modules/@psf/bch-js/node_modules/randombytes": {
|
||||
"version": "2.0.6",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"safe-buffer": "^5.1.0"
|
||||
@@ -3160,10 +3194,12 @@
|
||||
},
|
||||
"node_modules/@psf/bch-js/node_modules/safe-buffer": {
|
||||
"version": "5.1.2",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@psf/bip21": {
|
||||
"version": "2.0.1",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"qs": "^6.3.0"
|
||||
@@ -3171,10 +3207,12 @@
|
||||
},
|
||||
"node_modules/@psf/bitcoincash-ops": {
|
||||
"version": "2.0.0",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@psf/bitcoincashjs-lib": {
|
||||
"version": "4.0.3",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@psf/bitcoincash-ops": "^2.0.0",
|
||||
@@ -3199,6 +3237,7 @@
|
||||
},
|
||||
"node_modules/@psf/coininfo": {
|
||||
"version": "4.0.0",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"safe-buffer": "^5.1.1"
|
||||
@@ -3206,6 +3245,7 @@
|
||||
},
|
||||
"node_modules/@psf/pushdata-bitcoin": {
|
||||
"version": "1.2.2",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@psf/bitcoincash-ops": "^2.0.0"
|
||||
@@ -4800,6 +4840,7 @@
|
||||
},
|
||||
"node_modules/array.prototype.every": {
|
||||
"version": "1.1.7",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bound": "^1.0.2",
|
||||
@@ -5266,6 +5307,7 @@
|
||||
},
|
||||
"node_modules/base-x": {
|
||||
"version": "3.0.10",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"safe-buffer": "^5.0.1"
|
||||
@@ -5303,6 +5345,7 @@
|
||||
},
|
||||
"node_modules/bc-bip68": {
|
||||
"version": "1.0.5",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": ">=4.5.0"
|
||||
@@ -5310,6 +5353,7 @@
|
||||
},
|
||||
"node_modules/bch-consumer": {
|
||||
"version": "1.6.2",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@psf/bch-js": "6.7.3",
|
||||
@@ -5319,6 +5363,7 @@
|
||||
},
|
||||
"node_modules/bch-consumer/node_modules/@psf/bch-js": {
|
||||
"version": "6.7.3",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@chris.troutner/bip32-utils": "1.0.5",
|
||||
@@ -5349,6 +5394,7 @@
|
||||
},
|
||||
"node_modules/bch-consumer/node_modules/@psf/bch-js/node_modules/axios": {
|
||||
"version": "0.26.1",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"follow-redirects": "^1.14.8"
|
||||
@@ -5356,6 +5402,7 @@
|
||||
},
|
||||
"node_modules/bch-consumer/node_modules/apidoc": {
|
||||
"version": "0.51.0",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"os": [
|
||||
"darwin",
|
||||
@@ -5397,6 +5444,7 @@
|
||||
},
|
||||
"node_modules/bch-consumer/node_modules/axios": {
|
||||
"version": "0.25.0",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"follow-redirects": "^1.14.7"
|
||||
@@ -5404,6 +5452,7 @@
|
||||
},
|
||||
"node_modules/bch-consumer/node_modules/bootstrap": {
|
||||
"version": "3.4.1",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
@@ -5411,10 +5460,12 @@
|
||||
},
|
||||
"node_modules/bch-consumer/node_modules/path-to-regexp": {
|
||||
"version": "6.3.0",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/bch-consumer/node_modules/randombytes": {
|
||||
"version": "2.0.6",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"safe-buffer": "^5.1.0"
|
||||
@@ -5422,10 +5473,13 @@
|
||||
},
|
||||
"node_modules/bch-consumer/node_modules/safe-buffer": {
|
||||
"version": "5.1.2",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/bch-dex-lib": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "http://94.130.170.209:4873/bch-dex-lib/-/bch-dex-lib-2.0.2.tgz",
|
||||
"integrity": "sha512-x639TqYjRucvFrWzr9PMWN5Jdj2+lJkk1m4LC9Zlfm0QNe1PLD4WqyqH1dxMUdA/L9TVpPq1V/HbAiiQZmjV6Q==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@chris.troutner/retry-queue": "1.0.10",
|
||||
@@ -5434,6 +5488,7 @@
|
||||
},
|
||||
"node_modules/bch-donation": {
|
||||
"version": "1.1.2",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"apidoc": "0.51.0"
|
||||
@@ -5441,6 +5496,7 @@
|
||||
},
|
||||
"node_modules/bch-donation/node_modules/apidoc": {
|
||||
"version": "0.51.0",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"os": [
|
||||
"darwin",
|
||||
@@ -5482,6 +5538,7 @@
|
||||
},
|
||||
"node_modules/bch-donation/node_modules/bootstrap": {
|
||||
"version": "3.4.1",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
@@ -5489,6 +5546,7 @@
|
||||
},
|
||||
"node_modules/bch-donation/node_modules/path-to-regexp": {
|
||||
"version": "6.3.0",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/bch-message-lib": {
|
||||
@@ -5500,6 +5558,8 @@
|
||||
},
|
||||
"node_modules/bch-nostr": {
|
||||
"version": "1.3.4",
|
||||
"resolved": "http://94.130.170.209:4873/bch-nostr/-/bch-nostr-1.3.4.tgz",
|
||||
"integrity": "sha512-5R6PtZsP1F+oDs7+sZ5d+DeM3XNhr+3QsyHmTbFdoyNcb3w0vFN3KYNvaXpfPYBUDncXPJBNSR5GOstEDRSCgg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@chris.troutner/nostr-tools": "2.10.4",
|
||||
@@ -5519,6 +5579,7 @@
|
||||
},
|
||||
"node_modules/bchaddrjs-slp": {
|
||||
"version": "0.2.5",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"bs58check": "^2.1.2",
|
||||
@@ -5530,6 +5591,7 @@
|
||||
},
|
||||
"node_modules/bech32": {
|
||||
"version": "1.1.4",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/bfj": {
|
||||
@@ -5548,6 +5610,7 @@
|
||||
},
|
||||
"node_modules/big-integer": {
|
||||
"version": "1.6.52",
|
||||
"dev": true,
|
||||
"license": "Unlicense",
|
||||
"engines": {
|
||||
"node": ">=0.6"
|
||||
@@ -5561,10 +5624,12 @@
|
||||
}
|
||||
},
|
||||
"node_modules/bigi": {
|
||||
"version": "1.4.2"
|
||||
"version": "1.4.2",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/bignumber.js": {
|
||||
"version": "9.0.0",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": "*"
|
||||
@@ -5582,6 +5647,7 @@
|
||||
},
|
||||
"node_modules/bindings": {
|
||||
"version": "1.5.0",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"file-uri-to-path": "1.0.0"
|
||||
@@ -5589,6 +5655,7 @@
|
||||
},
|
||||
"node_modules/bip-schnorr": {
|
||||
"version": "0.3.0",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ecurve": "^1.0.6",
|
||||
@@ -5602,6 +5669,7 @@
|
||||
},
|
||||
"node_modules/bip38": {
|
||||
"version": "2.0.2",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"bigi": "^1.2.0",
|
||||
"browserify-aes": "^1.0.1",
|
||||
@@ -5614,6 +5682,7 @@
|
||||
},
|
||||
"node_modules/bip39": {
|
||||
"version": "3.0.2",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@types/node": "11.11.6",
|
||||
@@ -5624,10 +5693,12 @@
|
||||
},
|
||||
"node_modules/bip39/node_modules/@types/node": {
|
||||
"version": "11.11.6",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/bip66": {
|
||||
"version": "1.1.5",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"safe-buffer": "^5.0.1"
|
||||
@@ -5635,6 +5706,7 @@
|
||||
},
|
||||
"node_modules/bitcoinjs-message": {
|
||||
"version": "2.0.0",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"bs58check": "^2.0.2",
|
||||
@@ -5911,6 +5983,7 @@
|
||||
},
|
||||
"node_modules/bs58": {
|
||||
"version": "4.0.1",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"base-x": "^3.0.2"
|
||||
@@ -5918,6 +5991,7 @@
|
||||
},
|
||||
"node_modules/bs58check": {
|
||||
"version": "2.1.2",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"bs58": "^4.0.0",
|
||||
@@ -5957,6 +6031,7 @@
|
||||
},
|
||||
"node_modules/buffer-equals": {
|
||||
"version": "1.0.4",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
@@ -6156,6 +6231,7 @@
|
||||
},
|
||||
"node_modules/cashaddrjs-slp": {
|
||||
"version": "0.2.12",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"big-integer": "^1.6.34"
|
||||
@@ -6661,6 +6737,7 @@
|
||||
},
|
||||
"node_modules/crypto-js": {
|
||||
"version": "4.0.0",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/crypto-random-string": {
|
||||
@@ -7098,6 +7175,7 @@
|
||||
},
|
||||
"node_modules/deep-equal": {
|
||||
"version": "2.2.3",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"array-buffer-byte-length": "^1.0.0",
|
||||
@@ -7128,6 +7206,7 @@
|
||||
},
|
||||
"node_modules/deep-equal/node_modules/isarray": {
|
||||
"version": "2.0.5",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/deep-is": {
|
||||
@@ -7190,6 +7269,7 @@
|
||||
},
|
||||
"node_modules/defined": {
|
||||
"version": "1.0.1",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
@@ -7457,6 +7537,7 @@
|
||||
},
|
||||
"node_modules/dotignore": {
|
||||
"version": "0.1.2",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"minimatch": "^3.0.4"
|
||||
@@ -7467,6 +7548,7 @@
|
||||
},
|
||||
"node_modules/drbg.js": {
|
||||
"version": "1.0.1",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"browserify-aes": "^1.0.6",
|
||||
@@ -7499,6 +7581,7 @@
|
||||
},
|
||||
"node_modules/ecashaddrjs": {
|
||||
"version": "1.0.7",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"big-integer": "1.6.36"
|
||||
@@ -7506,6 +7589,7 @@
|
||||
},
|
||||
"node_modules/ecashaddrjs/node_modules/big-integer": {
|
||||
"version": "1.6.36",
|
||||
"dev": true,
|
||||
"license": "Unlicense",
|
||||
"engines": {
|
||||
"node": ">=0.6"
|
||||
@@ -7513,6 +7597,7 @@
|
||||
},
|
||||
"node_modules/ecurve": {
|
||||
"version": "1.0.6",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"bigi": "^1.1.0",
|
||||
@@ -7738,6 +7823,7 @@
|
||||
},
|
||||
"node_modules/es-get-iterator": {
|
||||
"version": "1.1.3",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bind": "^1.0.2",
|
||||
@@ -7756,6 +7842,7 @@
|
||||
},
|
||||
"node_modules/es-get-iterator/node_modules/isarray": {
|
||||
"version": "2.0.5",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/es-iterator-helpers": {
|
||||
@@ -8920,6 +9007,7 @@
|
||||
},
|
||||
"node_modules/file-uri-to-path": {
|
||||
"version": "1.0.0",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/filelist": {
|
||||
@@ -9585,6 +9673,7 @@
|
||||
},
|
||||
"node_modules/has-dynamic-import": {
|
||||
"version": "2.1.1",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bind": "^1.0.8",
|
||||
@@ -10393,6 +10482,7 @@
|
||||
},
|
||||
"node_modules/is-arguments": {
|
||||
"version": "1.2.0",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bound": "^1.0.2",
|
||||
@@ -11972,6 +12062,7 @@
|
||||
},
|
||||
"node_modules/js-sha256": {
|
||||
"version": "0.9.0",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/js-tokens": {
|
||||
@@ -12167,6 +12258,7 @@
|
||||
},
|
||||
"node_modules/keccak": {
|
||||
"version": "3.0.4",
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -12180,6 +12272,7 @@
|
||||
},
|
||||
"node_modules/keccak/node_modules/readable-stream": {
|
||||
"version": "3.6.2",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"inherits": "^2.0.3",
|
||||
@@ -12612,6 +12705,7 @@
|
||||
},
|
||||
"node_modules/merkle-lib": {
|
||||
"version": "2.0.10",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/methods": {
|
||||
@@ -12711,6 +12805,7 @@
|
||||
"version": "5.13.1",
|
||||
"resolved": "http://94.130.170.209:4873/minimal-slp-wallet/-/minimal-slp-wallet-5.13.1.tgz",
|
||||
"integrity": "sha512-Hk8o0Wvg+gdFnJrB+dbRKQsQQfOU/0BQq8hECRrj7B1mpvkuC8rUxciMC04JuhBfrB7VfGmN89OyAhLkEfQW5g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@chris.troutner/retry-queue-commonjs": "1.0.8",
|
||||
@@ -12723,6 +12818,7 @@
|
||||
},
|
||||
"node_modules/minimal-slp-wallet/node_modules/apidoc": {
|
||||
"version": "0.51.0",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"os": [
|
||||
"darwin",
|
||||
@@ -12764,6 +12860,7 @@
|
||||
},
|
||||
"node_modules/minimal-slp-wallet/node_modules/bootstrap": {
|
||||
"version": "3.4.1",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
@@ -12771,6 +12868,7 @@
|
||||
},
|
||||
"node_modules/minimal-slp-wallet/node_modules/path-to-regexp": {
|
||||
"version": "6.3.0",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/minimalistic-assert": {
|
||||
@@ -12838,6 +12936,7 @@
|
||||
},
|
||||
"node_modules/mock-property": {
|
||||
"version": "1.1.0",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"define-data-property": "^1.1.4",
|
||||
@@ -12857,6 +12956,7 @@
|
||||
},
|
||||
"node_modules/mock-property/node_modules/isarray": {
|
||||
"version": "2.0.5",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/move-file": {
|
||||
@@ -12933,6 +13033,7 @@
|
||||
},
|
||||
"node_modules/nan": {
|
||||
"version": "2.22.0",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/nanoid": {
|
||||
@@ -13000,6 +13101,7 @@
|
||||
},
|
||||
"node_modules/node-addon-api": {
|
||||
"version": "2.0.2",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/node-fetch": {
|
||||
@@ -13049,6 +13151,7 @@
|
||||
},
|
||||
"node_modules/node-gyp-build": {
|
||||
"version": "4.8.4",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"node-gyp-build": "bin.js",
|
||||
@@ -13143,6 +13246,31 @@
|
||||
"ws": "^8.8.1"
|
||||
}
|
||||
},
|
||||
"node_modules/nostr-tools": {
|
||||
"version": "2.10.4",
|
||||
"resolved": "http://94.130.170.209:4873/nostr-tools/-/nostr-tools-2.10.4.tgz",
|
||||
"integrity": "sha512-biU7sk+jxHgVASfobg2T5ttxOGGSt69wEVBC51sHHOEaKAAdzHBLV/I2l9Rf61UzClhliZwNouYhqIso4a3HYg==",
|
||||
"license": "Unlicense",
|
||||
"dependencies": {
|
||||
"@noble/ciphers": "^0.5.1",
|
||||
"@noble/curves": "1.2.0",
|
||||
"@noble/hashes": "1.3.1",
|
||||
"@scure/base": "1.1.1",
|
||||
"@scure/bip32": "1.3.1",
|
||||
"@scure/bip39": "1.2.1"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"nostr-wasm": "0.1.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": ">=5.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"typescript": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/nostr-wasm": {
|
||||
"version": "0.1.0",
|
||||
"license": "MIT",
|
||||
@@ -13198,6 +13326,7 @@
|
||||
},
|
||||
"node_modules/object-is": {
|
||||
"version": "1.1.6",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bind": "^1.0.7",
|
||||
@@ -13488,6 +13617,76 @@
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/p2wdb": {
|
||||
"version": "2.4.1",
|
||||
"resolved": "http://94.130.170.209:4873/p2wdb/-/p2wdb-2.4.1.tgz",
|
||||
"integrity": "sha512-f4YPl3atOD8BfonSQxasfYaDL/pJ64WJ3rB+BONDARRUfGJZdZ6tE6vp47Xo7nMJ+gKQLNYObLGWBfPMw6SoQg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@chris.troutner/retry-queue-commonjs": "1.0.8",
|
||||
"apidoc": "0.52.0",
|
||||
"axios": "0.24.0"
|
||||
}
|
||||
},
|
||||
"node_modules/p2wdb/node_modules/apidoc": {
|
||||
"version": "0.52.0",
|
||||
"resolved": "http://94.130.170.209:4873/apidoc/-/apidoc-0.52.0.tgz",
|
||||
"integrity": "sha512-k0gaMI7LWxaqKt2D+twC6XpI8X5SHkJalfo8TmF72d2TSNABquqB8LyIrVYzLcadcHuLMRFDaDibOK271gD67w==",
|
||||
"license": "MIT",
|
||||
"os": [
|
||||
"darwin",
|
||||
"freebsd",
|
||||
"linux",
|
||||
"openbsd",
|
||||
"win32"
|
||||
],
|
||||
"dependencies": {
|
||||
"bootstrap": "3.4.1",
|
||||
"commander": "^8.3.0",
|
||||
"diff-match-patch": "^1.0.5",
|
||||
"esbuild-loader": "^2.16.0",
|
||||
"expose-loader": "^3.1.0",
|
||||
"fs-extra": "^10.0.0",
|
||||
"glob": "^7.2.0",
|
||||
"handlebars": "^4.7.7",
|
||||
"iconv-lite": "^0.6.3",
|
||||
"jquery": "^3.6.0",
|
||||
"klaw-sync": "^6.0.0",
|
||||
"lodash": "^4.17.21",
|
||||
"markdown-it": "^12.2.0",
|
||||
"nodemon": "^2.0.15",
|
||||
"prismjs": "^1.25.0",
|
||||
"semver": "^7.3.5",
|
||||
"style-loader": "^3.3.1",
|
||||
"webpack": "^5.64.2",
|
||||
"webpack-cli": "^4.9.1",
|
||||
"winston": "^3.3.3"
|
||||
},
|
||||
"bin": {
|
||||
"apidoc": "bin/apidoc"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/p2wdb/node_modules/axios": {
|
||||
"version": "0.24.0",
|
||||
"resolved": "http://94.130.170.209:4873/axios/-/axios-0.24.0.tgz",
|
||||
"integrity": "sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"follow-redirects": "^1.14.4"
|
||||
}
|
||||
},
|
||||
"node_modules/p2wdb/node_modules/bootstrap": {
|
||||
"version": "3.4.1",
|
||||
"resolved": "http://94.130.170.209:4873/bootstrap/-/bootstrap-3.4.1.tgz",
|
||||
"integrity": "sha512-yN5oZVmRCwe5aKwzRj6736nSmKDX7pLYwsXiCj/EYmo16hODaBiT4En5btW/jhBF/seV+XMx3aYwukYC3A49DA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/package-json-from-dist": {
|
||||
"version": "1.0.1",
|
||||
"license": "BlueOak-1.0.0"
|
||||
@@ -15146,6 +15345,7 @@
|
||||
},
|
||||
"node_modules/qs": {
|
||||
"version": "6.14.0",
|
||||
"dev": true,
|
||||
"license": "BSD-3-Clause",
|
||||
"dependencies": {
|
||||
"side-channel": "^1.1.0"
|
||||
@@ -15257,6 +15457,7 @@
|
||||
},
|
||||
"node_modules/random-bytes": {
|
||||
"version": "1.0.0",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
@@ -16279,6 +16480,7 @@
|
||||
},
|
||||
"node_modules/satoshi-bitcoin": {
|
||||
"version": "1.0.4",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"big.js": "^3.1.3"
|
||||
@@ -16286,6 +16488,7 @@
|
||||
},
|
||||
"node_modules/satoshi-bitcoin/node_modules/big.js": {
|
||||
"version": "3.2.0",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": "*"
|
||||
@@ -16356,10 +16559,12 @@
|
||||
},
|
||||
"node_modules/scryptsy": {
|
||||
"version": "2.1.0",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/secp256k1": {
|
||||
"version": "3.8.1",
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -16378,6 +16583,7 @@
|
||||
},
|
||||
"node_modules/secp256k1/node_modules/bn.js": {
|
||||
"version": "4.12.1",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/select-hose": {
|
||||
@@ -16739,6 +16945,7 @@
|
||||
},
|
||||
"node_modules/slp-mdm": {
|
||||
"version": "0.0.6",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"bignumber.js": "^9.0.0"
|
||||
@@ -16746,6 +16953,7 @@
|
||||
},
|
||||
"node_modules/slp-parser": {
|
||||
"version": "0.0.4",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"bignumber.js": "^9.0.0"
|
||||
@@ -17101,6 +17309,7 @@
|
||||
},
|
||||
"node_modules/stop-iteration-iterator": {
|
||||
"version": "1.1.0",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0",
|
||||
@@ -17707,6 +17916,7 @@
|
||||
},
|
||||
"node_modules/tape": {
|
||||
"version": "5.9.0",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@ljharb/resumer": "^0.1.3",
|
||||
@@ -17741,6 +17951,7 @@
|
||||
},
|
||||
"node_modules/tape/node_modules/resolve": {
|
||||
"version": "2.0.0-next.5",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"is-core-module": "^2.13.0",
|
||||
@@ -18166,22 +18377,9 @@
|
||||
},
|
||||
"node_modules/typeforce": {
|
||||
"version": "1.18.0",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "4.9.5",
|
||||
"resolved": "http://94.130.170.209:4873/typescript/-/typescript-4.9.5.tgz",
|
||||
"integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==",
|
||||
"license": "Apache-2.0",
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4.2.0"
|
||||
}
|
||||
},
|
||||
"node_modules/uc.micro": {
|
||||
"version": "1.0.6",
|
||||
"license": "MIT"
|
||||
@@ -18469,6 +18667,7 @@
|
||||
},
|
||||
"node_modules/varuint-bitcoin": {
|
||||
"version": "1.1.2",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"safe-buffer": "^5.1.1"
|
||||
@@ -19026,6 +19225,7 @@
|
||||
},
|
||||
"node_modules/wif": {
|
||||
"version": "2.0.6",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"bs58check": "<3.0.0"
|
||||
|
||||
@@ -10,8 +10,11 @@
|
||||
"axios": "0.27.2",
|
||||
"bch-dex-lib": "2.0.2",
|
||||
"bch-message-lib": "2.2.1",
|
||||
"bch-nostr": "1.3.4",
|
||||
"bootstrap": "5.2.0",
|
||||
"crypto-browserify": "3.12.1",
|
||||
"nostr-tools": "2.10.4",
|
||||
"p2wdb": "2.4.1",
|
||||
"process": "0.11.10",
|
||||
"qrcode.react": "4.2.0",
|
||||
"query-string": "7.1.1",
|
||||
@@ -50,6 +53,7 @@
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
|
||||
"minimal-slp-wallet": "5.13.1",
|
||||
"react-app-rewired": "2.2.1",
|
||||
"standard": "17.0.0",
|
||||
|
||||
+14
@@ -71,6 +71,20 @@ function App (props) {
|
||||
addToModal('Getting BCH spot price in USD', appData)
|
||||
await asyncLoad.getUSDExchangeRate(walletTemp, appData.updateBchWalletState, appData)
|
||||
|
||||
// Load the P2WDB libraries.
|
||||
addToModal('Loading P2WDB Libraries', appData)
|
||||
const {p2wdbRead, p2wdbWrite} = asyncLoad.getP2WDBLib({bchWallet: walletTemp})
|
||||
|
||||
// Load the DEX library.
|
||||
addToModal('Loading DEX Library', appData)
|
||||
const dexLib = asyncLoad.getDexLib({bchWallet: walletTemp, p2wdbRead, p2wdbWrite})
|
||||
appData.setDexLib(dexLib)
|
||||
|
||||
// Load the Nostr library.
|
||||
addToModal('Loading Nostr Library', appData)
|
||||
const nostrLib = asyncLoad.getNostrLib({bchWallet: walletTemp})
|
||||
appData.setNostr(nostrLib)
|
||||
|
||||
// Update state
|
||||
appData.setShowStartModal(false)
|
||||
appData.setDenyClose(false)
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
This component renders as a button. When clicked, it initiates the
|
||||
purchase of the token. This is the Signal part of the SWaP protocol.
|
||||
*/
|
||||
|
||||
// Global npm libraries
|
||||
import React, { useState } from 'react'
|
||||
import { Button, Modal, Container, Row, Col } from 'react-bootstrap'
|
||||
|
||||
function BuyButton (props) {
|
||||
const { token, appData } = props
|
||||
|
||||
const [show, setShow] = useState(false)
|
||||
|
||||
const handleBuy = async () => {
|
||||
console.log('handleBuy()')
|
||||
console.log('token: ', token)
|
||||
console.log('appData: ', appData)
|
||||
|
||||
const targetOffer = token.nostrEventId
|
||||
console.log('targetOffer: ', targetOffer)
|
||||
|
||||
// TODO: Launch modal to let user know that the purchase is in progress.
|
||||
|
||||
// Generate a counter offer.
|
||||
const bchDexLib = appData.dexLib
|
||||
const { offerData, partialHex } = await bchDexLib.take.takeOffer(targetOffer)
|
||||
|
||||
console.log('offerData: ', offerData)
|
||||
console.log('partialHex: ', partialHex)
|
||||
|
||||
// Upload the counter offer to Nostr.
|
||||
const nostr = appData.nostr
|
||||
const { eventId, noteId } = await nostr.testNostrUpload({ offerData, partialHex })
|
||||
|
||||
console.log(`Counter Offer uploaded to Nostr with this event ID: ${eventId}`)
|
||||
console.log(`https://astral.psfoundation.info/${noteId}`)
|
||||
}
|
||||
|
||||
const handleClose = () => {
|
||||
console.log('handleClose()')
|
||||
setShow(false)
|
||||
// props.instance.setState({ showModal: false })
|
||||
}
|
||||
|
||||
const handleOpen = () => {
|
||||
console.log('handleOpen()')
|
||||
setShow(true)
|
||||
}
|
||||
|
||||
// Replace with dummy button until token data is loaded.
|
||||
if (!props.token.tokenData) {
|
||||
return (
|
||||
<>
|
||||
<Button variant='success'>Buy</Button>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button variant='success' disabled={props.disabled} onClick={handleBuy}>Buy</Button>
|
||||
<Modal show={show} onHide={handleClose}>
|
||||
<Modal.Header closeButton>
|
||||
<Modal.Title>Token Information</Modal.Title>
|
||||
</Modal.Header>
|
||||
<Modal.Body>
|
||||
<Container>
|
||||
<Row>
|
||||
<Col xs={4}><b>Ticker</b>:</Col>
|
||||
<Col xs={8}>{props.token.ticker}</Col>
|
||||
</Row>
|
||||
|
||||
<Row style={{ backgroundColor: '#eee' }}>
|
||||
<Col xs={4}><b>Name</b>:</Col>
|
||||
<Col xs={8}>{props.token.tokenData.genesisData.name}</Col>
|
||||
</Row>
|
||||
|
||||
<Row>
|
||||
<Col xs={4}><b>Token ID</b>:</Col>
|
||||
<Col xs={8} style={{ wordBreak: 'break-all' }}>
|
||||
<a href={`https://explorer.tokentiger.com/?tokenid=${props.token.tokenId}`} target='_blank' rel='noreferrer'>
|
||||
{props.token.tokenId}
|
||||
</a>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
<Row style={{ backgroundColor: '#eee' }}>
|
||||
<Col xs={4}><b>Decimals</b>:</Col>
|
||||
<Col xs={8}>{props.token.tokenData.genesisData.decimals}</Col>
|
||||
</Row>
|
||||
|
||||
<Row>
|
||||
<Col xs={4}><b>Token Type</b>:</Col>
|
||||
<Col xs={8}>{props.token.tokenType}</Col>
|
||||
</Row>
|
||||
|
||||
</Container>
|
||||
</Modal.Body>
|
||||
<Modal.Footer />
|
||||
</Modal>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default BuyButton
|
||||
@@ -205,6 +205,7 @@ function NftsForSale (props) {
|
||||
}
|
||||
return url
|
||||
}
|
||||
|
||||
// This function generates a Token Card for each token in the wallet.
|
||||
function generateCards (offers) {
|
||||
console.log('generateCards() offerData: ', offers)
|
||||
|
||||
@@ -54,7 +54,7 @@ function InfoButton (props) {
|
||||
<Row>
|
||||
<Col xs={4}><b>Token ID</b>:</Col>
|
||||
<Col xs={8} style={{ wordBreak: 'break-all' }}>
|
||||
<a href={`https://token.fullstack.cash/?tokenid=${props.token.tokenId}`} target='_blank' rel='noreferrer'>
|
||||
<a href={`https://explorer.tokentiger.com/?tokenid=${props.token.tokenId}`} target='_blank' rel='noreferrer'>
|
||||
{props.token.tokenId}
|
||||
</a>
|
||||
</Col>
|
||||
|
||||
@@ -5,14 +5,19 @@
|
||||
// Global npm libraries
|
||||
import React, { useState, useEffect } from 'react'
|
||||
import { Container, Row, Col, Card } from 'react-bootstrap'
|
||||
import InfoButton from './info-button'
|
||||
import Jdenticon from '@chris.troutner/react-jdenticon'
|
||||
|
||||
// Local libraries
|
||||
import InfoButton from './info-button'
|
||||
import BuyButton from './buy-button'
|
||||
|
||||
function TokenCard (props) {
|
||||
const { token } = props
|
||||
const { token, appData } = props
|
||||
const [icon, setIcon] = useState(token.icon)
|
||||
const [tokenData, setTokenData] = useState(token.tokenData)
|
||||
|
||||
console.log('TokenCard() appData: ', appData)
|
||||
|
||||
// Update icon state every token.icon and token.tokenData changes
|
||||
useEffect(() => {
|
||||
setIcon(token.icon)
|
||||
@@ -66,7 +71,9 @@ function TokenCard (props) {
|
||||
|
||||
<Col />
|
||||
|
||||
<Col />
|
||||
<Col>
|
||||
<BuyButton token={token} disabled={!token.tokenData} appData={appData} />
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
</Container>
|
||||
|
||||
+7
-2
@@ -23,6 +23,8 @@ function useAppState () {
|
||||
const [menuState, setMenuState] = useState(0)
|
||||
const [wallet, setWallet] = useState(false)
|
||||
const [servers, setServers] = useState([])
|
||||
const [dexLib, setDexLib] = useState(false)
|
||||
const [nostr, setNostr] = useState(false)
|
||||
|
||||
// Startup state management
|
||||
const [asyncInitStarted, setAsyncInitStarted] = useState(false)
|
||||
@@ -125,8 +127,11 @@ function useAppState () {
|
||||
updateLocalStorage,
|
||||
updateBchWalletState,
|
||||
appUtil: new AppUtil(),
|
||||
currentPath: location.pathname
|
||||
|
||||
currentPath: location.pathname,
|
||||
dexLib,
|
||||
setDexLib,
|
||||
nostr,
|
||||
setNostr
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,12 @@
|
||||
|
||||
// Global npm libraries
|
||||
import axios from 'axios'
|
||||
import BchDexLib from 'bch-dex-lib'
|
||||
|
||||
// Local libraries
|
||||
import GistServers from './gist-servers'
|
||||
import Nostr from './nostr'
|
||||
import P2WDB from 'p2wdb'
|
||||
|
||||
class AsyncLoad {
|
||||
constructor () {
|
||||
@@ -195,8 +199,53 @@ class AsyncLoad {
|
||||
return defaultOptions
|
||||
}
|
||||
}
|
||||
|
||||
// Load the BchDexLib library.
|
||||
getDexLib (inObj = {}) {
|
||||
try {
|
||||
const { bchWallet, p2wdbRead, p2wdbWrite } = inObj
|
||||
|
||||
const dexLib = new BchDexLib({bchWallet, p2wdbRead, p2wdbWrite})
|
||||
|
||||
return dexLib
|
||||
} catch (error) {
|
||||
console.error('Error getting DexLib', error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
// Load the Nostr library.
|
||||
getNostrLib (inObj = {}) {
|
||||
try {
|
||||
const { bchWallet } = inObj
|
||||
|
||||
const nostrLib = new Nostr({bchWallet})
|
||||
|
||||
return nostrLib
|
||||
} catch (error) {
|
||||
console.error('Error in getNostrLib', error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
// Load the P2WDB library.
|
||||
getP2WDBLib (inObj = {}) {
|
||||
try {
|
||||
const { bchWallet } = inObj
|
||||
|
||||
const p2wdbRead = new P2WDB.Read()
|
||||
const p2wdbWrite = new P2WDB.Write({bchWallet})
|
||||
|
||||
return {p2wdbRead, p2wdbWrite}
|
||||
} catch (error) {
|
||||
console.error('Error in getP2WDBLib', error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function sleep (ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
Implementing nostr natively in the browser, rather than using a library
|
||||
intended for node.js
|
||||
*/
|
||||
|
||||
// Global npm libraries
|
||||
// import { finalizeEvent } from '@chris.troutner/nostr-tools/pure'
|
||||
// import { Relay } from '@chris.troutner/nostr-tools/relay'
|
||||
// import BchNostr from 'bch-nostr'
|
||||
// import * as nip19 from '@chris.troutner/nostr-tools/nip19'
|
||||
|
||||
import { finalizeEvent } from 'nostr-tools/pure'
|
||||
import { Relay } from 'nostr-tools/relay'
|
||||
import BchNostr from 'bch-nostr'
|
||||
import * as nip19 from 'nostr-tools/nip19'
|
||||
|
||||
class NostrBrowser {
|
||||
constructor (localConfig = {}) {
|
||||
if (!localConfig.bchWallet) {
|
||||
throw new Error('Instance of minimal-slp-wallet must be passed as wallet property when instantiating the bch-dex-lib library.')
|
||||
}
|
||||
|
||||
this.bchWallet = localConfig.bchWallet
|
||||
|
||||
this.bchNostr = new BchNostr({
|
||||
relayWs: 'wss://nostr-relay.psfoundation.info',
|
||||
topic: 'bch-dex-test-topic-01'
|
||||
})
|
||||
}
|
||||
|
||||
async testNostrUpload (inObj = {}) {
|
||||
try {
|
||||
console.log('testNostrUpload() executing.')
|
||||
// console.log('this.bchWallet: ', this.bchWallet)
|
||||
|
||||
const { offerData, partialHex } = inObj
|
||||
console.log('offerData: ', offerData)
|
||||
|
||||
const wif = this.bchWallet.walletInfo.privateKey
|
||||
// const { privKeyBuf, nostrPubKey } =
|
||||
// this.bchNostr.keys.createNostrPubKeyFromWif({ wif })
|
||||
const { privKeyBuf } =
|
||||
this.bchNostr.keys.createNostrPubKeyFromWif({ wif })
|
||||
|
||||
// Scaffold the Counter Offer from the Offer
|
||||
const counterOfferData = Object.assign({}, offerData)
|
||||
counterOfferData.partialTxHex = partialHex
|
||||
delete counterOfferData.nostrEventId
|
||||
delete counterOfferData._id
|
||||
counterOfferData.offerHash = offerData.nostrEventId
|
||||
|
||||
// Add P2WDB specific flag for signaling that this is a new Counter Offer.
|
||||
counterOfferData.dataType = 'counter-offer'
|
||||
console.log(`counterOfferData: ${JSON.stringify(counterOfferData, null, 2)}`)
|
||||
|
||||
const nostrData = {
|
||||
data: counterOfferData
|
||||
}
|
||||
|
||||
const msg = JSON.stringify(nostrData, null, 2)
|
||||
|
||||
// const inObj = {
|
||||
// kind: 867,
|
||||
// privKeyBuf: privKeyBuf,
|
||||
// nostrPubKey: nostrPubKey,
|
||||
// relayWs: 'wss://nostr-relay.psfoundation.info',
|
||||
// msg,
|
||||
// tags: [['t', 'bch-dex-test-topic-01']]
|
||||
// }
|
||||
|
||||
const relayWs = 'wss://nostr-relay.psfoundation.info'
|
||||
const eventTemplate = {
|
||||
kind: 867,
|
||||
created_at: Math.floor(Date.now() / 1000),
|
||||
tags: [['t', 'bch-dex-test-topic-01']],
|
||||
content: msg
|
||||
}
|
||||
|
||||
// Sign the post
|
||||
const signedEvent = finalizeEvent(eventTemplate, privKeyBuf)
|
||||
// console.log('signedEvent: ', signedEvent)
|
||||
const eventId = signedEvent.id
|
||||
|
||||
// Connect to a relay.
|
||||
const relay = await Relay.connect(relayWs, {
|
||||
webSocket: WebSocket
|
||||
})
|
||||
// console.log(`connected to ${relay.url}`)
|
||||
|
||||
// Publish the message to the relay.
|
||||
await relay.publish(signedEvent)
|
||||
|
||||
// Close the connection to the relay.
|
||||
relay.close()
|
||||
|
||||
// const eventId = await this.bchNostr.post.uploadToNostr(inObj)
|
||||
|
||||
const noteId = this.eventId2note(eventId)
|
||||
|
||||
// const eventId = 'test1'
|
||||
// const noteId = 'test2'
|
||||
|
||||
return { eventId, noteId }
|
||||
} catch (err) {
|
||||
console.log('Error in nostr.js/testNostrUpload()')
|
||||
throw err
|
||||
}
|
||||
}
|
||||
|
||||
// Convert an Event ID into a `noteabc..` syntax that Astral expects.
|
||||
// This can be used to generate a link to Astral to display the post.
|
||||
eventId2note (eventId) {
|
||||
return nip19.noteEncode(eventId)
|
||||
}
|
||||
}
|
||||
|
||||
export default NostrBrowser
|
||||
Reference in New Issue
Block a user