mirror of
https://github.com/Permissionless-Software-Foundation/bch-js.git
synced 2026-09-22 09:02:01 -07:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b1745d37e0 | ||
|
|
9733c07e04 | ||
|
|
430f5f015e | ||
|
|
9e76b34d05 | ||
|
|
61078b2e91 | ||
|
|
82733a7e1a | ||
|
|
3685ea1541 | ||
|
|
5f217af3e9 | ||
|
|
e2ca3cfb00 |
Generated
+16
-16
@@ -32,7 +32,7 @@
|
||||
"slp-mdm": "0.0.7",
|
||||
"slp-parser": "0.0.4",
|
||||
"wif": "2.0.6",
|
||||
"x402-bch-axios": "2.1.1"
|
||||
"x402-bch-axios": "2.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"apidoc": "1.2.0",
|
||||
@@ -779,9 +779,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@eslint-community/eslint-utils": {
|
||||
"version": "4.9.0",
|
||||
"resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.9.0.tgz",
|
||||
"integrity": "sha512-ayVFHdtZ+hsq1t2Dy24wCmGXGe4q9Gu3smhLYALJrr473ZH27MsnSL+LKUlimp4BWJqMDMLmPpx/Q9R3OAlL4g==",
|
||||
"version": "4.9.1",
|
||||
"resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.9.1.tgz",
|
||||
"integrity": "sha512-phrYmNiYppR7znFEdqgfWHXR6NCkZEK7hwWDHZUjit/2/U0r6XvkDl0SYnoM51Hq7FhCGdLDT6zxCCOY1hexsQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -4298,9 +4298,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/caniuse-lite": {
|
||||
"version": "1.0.30001761",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001761.tgz",
|
||||
"integrity": "sha512-JF9ptu1vP2coz98+5051jZ4PwQgd2ni8A+gYSN7EA7dPKIMf0pDlSUxhdmVOaV3/fYK5uWBkgSXJaRLr4+3A6g==",
|
||||
"version": "1.0.30001762",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001762.tgz",
|
||||
"integrity": "sha512-PxZwGNvH7Ak8WX5iXzoK1KPZttBXNPuaOvI2ZYU7NrlM+d9Ov+TUvlLOBNGzVXAntMSMMlJPd+jY6ovrVjSmUw==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "opencollective",
|
||||
@@ -6277,9 +6277,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/esquery": {
|
||||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npmjs.org/esquery/-/esquery-1.6.0.tgz",
|
||||
"integrity": "sha512-ca9pw9fomFcKPvFLXhBKUK90ZvGibiGOvRJNbjljY7s7uq/5YO4BOzcYtJqExdx99rF6aAcnRxHmcUHcz6sQsg==",
|
||||
"version": "1.7.0",
|
||||
"resolved": "https://registry.npmjs.org/esquery/-/esquery-1.7.0.tgz",
|
||||
"integrity": "sha512-Ap6G0WQwcU/LHsvLwON1fAQX9Zp0A2Y6Y/cJBl9r/JbW90Zyg4/zbG6zzKa2OTALELarYHmKu0GhpM5EO+7T0g==",
|
||||
"dev": true,
|
||||
"license": "BSD-3-Clause",
|
||||
"dependencies": {
|
||||
@@ -13491,9 +13491,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/qs": {
|
||||
"version": "6.14.0",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.14.0.tgz",
|
||||
"integrity": "sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w==",
|
||||
"version": "6.14.1",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.14.1.tgz",
|
||||
"integrity": "sha512-4EK3+xJl8Ts67nLYNwqw/dsFVnCf+qR7RgXSK9jEEm9unao3njwMDdmsdvoKBKHzxd7tCYz5e5M+SnMjdtXGQQ==",
|
||||
"license": "BSD-3-Clause",
|
||||
"dependencies": {
|
||||
"side-channel": "^1.1.0"
|
||||
@@ -16804,9 +16804,9 @@
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/x402-bch-axios": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/x402-bch-axios/-/x402-bch-axios-2.1.1.tgz",
|
||||
"integrity": "sha512-cRUWTpEjwoY7sDVSxS26lSoaxGQ0OxrggQjU+WqUo3aCj00p1TwNeLIxwX6AxX89y4dRPXfuC5Pm/9mxTg058w==",
|
||||
"version": "2.2.1",
|
||||
"resolved": "https://registry.npmjs.org/x402-bch-axios/-/x402-bch-axios-2.2.1.tgz",
|
||||
"integrity": "sha512-N23DpQRA746bqGDTCJYVQ8QL55PoxE6LTSNMFzx5sySsvnBem6H0hQLSf2N9e45O8xPVw3ulSvXncgTcVM8ikw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@chris.troutner/retry-queue": "1.0.11",
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@
|
||||
"slp-mdm": "0.0.7",
|
||||
"slp-parser": "0.0.4",
|
||||
"wif": "2.0.6",
|
||||
"x402-bch-axios": "2.1.1"
|
||||
"x402-bch-axios": "2.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"apidoc": "1.2.0",
|
||||
|
||||
+5
-2
@@ -86,7 +86,10 @@ class BCHJS {
|
||||
} else if (process.env.BCHJSWIF && process.env.BCHJSWIF !== '') {
|
||||
this.wif = process.env.BCHJSWIF
|
||||
}
|
||||
this.paymentAmountSats = (config && config.paymentAmountSats) || 2000 * 5
|
||||
|
||||
// Most TXs cost about 250 sats. So we'll set the default to 25000 sats,
|
||||
// so the mining fee is 1% of the transaction.
|
||||
this.paymentAmountSats = (config && config.paymentAmountSats) || 25000
|
||||
|
||||
// BCH server URL for x402 payments (separate from REST API server)
|
||||
// This is used when broadcasting payment transactions to the blockchain
|
||||
@@ -95,7 +98,7 @@ class BCHJS {
|
||||
} else if (process.env.BCHJSBCHSERVERURL && process.env.BCHJSBCHSERVERURL !== '') {
|
||||
this.bchServerURL = process.env.BCHJSBCHSERVERURL
|
||||
} else {
|
||||
this.bchServerURL = 'https://bch.fullstack.cash/v6/'
|
||||
this.bchServerURL = 'https://bch.fullstack.cash/v6'
|
||||
}
|
||||
|
||||
const libConfig = {
|
||||
|
||||
@@ -66,7 +66,7 @@ class PsfSlpIndexer {
|
||||
)
|
||||
return response.data
|
||||
} catch (error) {
|
||||
if (error.response && error.response.data) throw error.response.data
|
||||
if (error.response && error.response.data && error.response.data.error) throw new Error(error.response.data.error)
|
||||
else throw error
|
||||
}
|
||||
}
|
||||
@@ -134,7 +134,7 @@ class PsfSlpIndexer {
|
||||
}
|
||||
throw new Error('Input address must be a string.')
|
||||
} catch (error) {
|
||||
if (error.response && error.response.data) throw error.response.data
|
||||
if (error.response && error.response.data && error.response.data.error) throw new Error(error.response.data.error)
|
||||
else throw error
|
||||
}
|
||||
}
|
||||
@@ -199,7 +199,7 @@ class PsfSlpIndexer {
|
||||
}
|
||||
throw new Error('Input tokenId must be a string.')
|
||||
} catch (error) {
|
||||
if (error.response && error.response.data) throw error.response.data
|
||||
if (error.response && error.response.data && error.response.data.error) throw new Error(error.response.data.error)
|
||||
else throw error
|
||||
}
|
||||
}
|
||||
@@ -427,7 +427,7 @@ class PsfSlpIndexer {
|
||||
}
|
||||
throw new Error('Input tokenId must be a string.')
|
||||
} catch (error) {
|
||||
if (error.response && error.response.data) throw error.response.data
|
||||
if (error.response && error.response.data && error.response.data.error) throw new Error(error.response.data.error)
|
||||
else throw error
|
||||
}
|
||||
}
|
||||
@@ -522,7 +522,7 @@ class PsfSlpIndexer {
|
||||
throw new Error('Input tokenId must be a string.')
|
||||
} catch (error) {
|
||||
// console.log('error: ', error)
|
||||
if (error.response && error.response.data) throw error.response.data
|
||||
if (error.response && error.response.data && error.response.data.error) throw new Error(error.response.data.error)
|
||||
else throw error
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,14 +43,14 @@ describe('#PsfSlpIndexer', () => {
|
||||
try {
|
||||
// Stub the network call.
|
||||
const testErr = new Error()
|
||||
testErr.response = { data: { status: 422 } }
|
||||
testErr.response = { data: { error: 'Status 422' } }
|
||||
sandbox.stub(axios, 'get').throws(testErr)
|
||||
|
||||
await bchjs.PsfSlpIndexer.status()
|
||||
// console.log(`result: ${JSON.stringify(result, null, 2)}`)
|
||||
assert.equal(true, false, 'Unexpected result!')
|
||||
} catch (err) {
|
||||
assert.equal(err.status, 422)
|
||||
assert.equal(err.message, 'Status 422')
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -103,7 +103,7 @@ describe('#PsfSlpIndexer', () => {
|
||||
try {
|
||||
// Stub the network call.
|
||||
const testErr = new Error()
|
||||
testErr.response = { data: { status: 422 } }
|
||||
testErr.response = { data: { error: 'Status 422' } }
|
||||
sandbox.stub(axios, 'post').throws(testErr)
|
||||
|
||||
const addr = 'bitcoincash:qzmd5vxgh9m22m6fgvm57yd6kjnjl9qnwywsf3583n'
|
||||
@@ -112,7 +112,7 @@ describe('#PsfSlpIndexer', () => {
|
||||
// console.log(`result: ${JSON.stringify(result, null, 2)}`)
|
||||
assert.equal(true, false, 'Unexpected result!')
|
||||
} catch (err) {
|
||||
assert.equal(err.status, 422)
|
||||
assert.equal(err.message, 'Status 422')
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -174,7 +174,7 @@ describe('#PsfSlpIndexer', () => {
|
||||
try {
|
||||
// Stub the network call.
|
||||
const testErr = new Error()
|
||||
testErr.response = { data: { status: 422 } }
|
||||
testErr.response = { data: { error: 'Status 422' } }
|
||||
sandbox.stub(axios, 'post').throws(testErr)
|
||||
|
||||
const tokenId =
|
||||
@@ -182,7 +182,7 @@ describe('#PsfSlpIndexer', () => {
|
||||
await bchjs.PsfSlpIndexer.tokenStats(tokenId)
|
||||
assert.equal(true, false, 'Unexpected result!')
|
||||
} catch (err) {
|
||||
assert.equal(err.status, 422)
|
||||
assert.equal(err.message, 'Status 422')
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -399,7 +399,7 @@ describe('#PsfSlpIndexer', () => {
|
||||
try {
|
||||
// Stub the network call.
|
||||
const testErr = new Error()
|
||||
testErr.response = { data: { status: 422 } }
|
||||
testErr.response = { data: { error: 'Status 422' } }
|
||||
sandbox.stub(axios, 'post').throws(testErr)
|
||||
|
||||
const tokenId =
|
||||
@@ -407,7 +407,7 @@ describe('#PsfSlpIndexer', () => {
|
||||
await bchjs.PsfSlpIndexer.getTokenData(tokenId)
|
||||
assert.equal(true, false, 'Unexpected result!')
|
||||
} catch (err) {
|
||||
assert.equal(err.status, 422)
|
||||
assert.equal(err.message, 'Status 422')
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
+9
-5
@@ -20,8 +20,10 @@ describe('#X402 Integration', () => {
|
||||
})
|
||||
|
||||
assert.strictEqual(bchjs.wif, '')
|
||||
assert.strictEqual(bchjs.paymentAmountSats, 10000)
|
||||
assert.strictEqual(bchjs.bchServerURL, 'https://bch.fullstack.cash/v6/')
|
||||
// assert.strictEqual(bchjs.paymentAmountSats, 10000)
|
||||
assert.strictEqual(typeof bchjs.paymentAmountSats, 'number')
|
||||
assert.ok(Number.isInteger(bchjs.paymentAmountSats) && bchjs.paymentAmountSats > 0)
|
||||
assert.strictEqual(bchjs.bchServerURL, 'https://bch.fullstack.cash/v6')
|
||||
})
|
||||
|
||||
it('should accept wif in config', () => {
|
||||
@@ -59,8 +61,10 @@ describe('#X402 Integration', () => {
|
||||
})
|
||||
|
||||
assert.strictEqual(bchjs.wif, '')
|
||||
assert.strictEqual(bchjs.paymentAmountSats, 10000)
|
||||
assert.strictEqual(bchjs.bchServerURL, 'https://bch.fullstack.cash/v6/')
|
||||
// assert.strictEqual(bchjs.paymentAmountSats, 10000)
|
||||
assert.strictEqual(typeof bchjs.paymentAmountSats, 'number')
|
||||
assert.ok(Number.isInteger(bchjs.paymentAmountSats) && bchjs.paymentAmountSats > 0)
|
||||
assert.strictEqual(bchjs.bchServerURL, 'https://bch.fullstack.cash/v6')
|
||||
})
|
||||
|
||||
it('should read WIF from BCHJSWIF environment variable', () => {
|
||||
@@ -168,7 +172,7 @@ describe('#X402 Integration', () => {
|
||||
})
|
||||
|
||||
assert.strictEqual(bchjs.restURL, customRestURL)
|
||||
assert.strictEqual(bchjs.bchServerURL, 'https://bch.fullstack.cash/v6/')
|
||||
assert.strictEqual(bchjs.bchServerURL, 'https://bch.fullstack.cash/v6')
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user