3 次代码提交

作者 SHA1 备注 提交日期
  nitowa d345e87bf0 Hopefully fix browser websocket issue, npm 0.3.2 11 个月前
  nitowa b5c71753cc npm 0.3.1 11 个月前
  nitowa 5277fbd703 progress callback for treeWrite 11 个月前
共有 8 个文件被更改,包括 1905 次插入1229 次删除
  1. 1859
    1208
      package-lock.json
  2. 5
    3
      package.json
  3. 3
    3
      src/util/types.ts
  4. 3
    6
      src/webpack.js
  5. 5
    7
      src/xrpIO/xrpl-binding.ts
  6. 15
    1
      test/index.html
  7. 7
    0
      test/main.js
  8. 8
    1
      test/primitives.ts

+ 1859
- 1208
package-lock.json
文件差异内容过多而无法显示
查看文件


+ 5
- 3
package.json 查看文件

1
 {
1
 {
2
   "name": "xrpio",
2
   "name": "xrpio",
3
-  "version": "0.3.0",
3
+  "version": "0.3.2",
4
   "repository": {
4
   "repository": {
5
     "type": "git",
5
     "type": "git",
6
     "url": "https://gitea.nitowa.xyz/npm-packages/xrpio.git"
6
     "url": "https://gitea.nitowa.xyz/npm-packages/xrpio.git"
33
   "author": "nitowa",
33
   "author": "nitowa",
34
   "license": "MIT",
34
   "license": "MIT",
35
   "dependencies": {
35
   "dependencies": {
36
-    "axios": "^1.7.7",
37
-    "ripple-lib": "^1.10.0",
38
     "xrpl": "^4.0.0"
36
     "xrpl": "^4.0.0"
39
   },
37
   },
40
   "devDependencies": {
38
   "devDependencies": {
41
     "@types/chai": "^4.2.21",
39
     "@types/chai": "^4.2.21",
42
     "@types/mocha": "^8.2.2",
40
     "@types/mocha": "^8.2.2",
43
     "@types/node": "^14.14.37",
41
     "@types/node": "^14.14.37",
42
+    "assert": "^2.1.0",
43
+    "axios": "^1.7.7",
44
     "base-64": "^1.0.0",
44
     "base-64": "^1.0.0",
45
     "browserify-zlib": "^0.2.0",
45
     "browserify-zlib": "^0.2.0",
46
     "buffer": "^6.0.3",
46
     "buffer": "^6.0.3",
50
     "mocha": "^9.2.0",
50
     "mocha": "^9.2.0",
51
     "net": "^1.0.2",
51
     "net": "^1.0.2",
52
     "node-fetch": "^2.6.2",
52
     "node-fetch": "^2.6.2",
53
+    "node-polyfill-webpack-plugin": "^4.0.0",
53
     "process": "^0.11.10",
54
     "process": "^0.11.10",
54
     "stream-browserify": "^3.0.0",
55
     "stream-browserify": "^3.0.0",
55
     "stream-http": "^3.2.0",
56
     "stream-http": "^3.2.0",
60
     "typescript": "^4.5.0",
61
     "typescript": "^4.5.0",
61
     "url": "^0.11.0",
62
     "url": "^0.11.0",
62
     "utf8": "^3.0.0",
63
     "utf8": "^3.0.0",
64
+    "utils": "^0.3.1",
63
     "webpack": "^5.75.0",
65
     "webpack": "^5.75.0",
64
     "webpack-cli": "^5.0.0",
66
     "webpack-cli": "^5.0.0",
65
     "wtfnode": "^0.9.1"
67
     "wtfnode": "^0.9.1"

+ 3
- 3
src/util/types.ts 查看文件

25
 
25
 
26
 export const defaultOptions: Options = {
26
 export const defaultOptions: Options = {
27
     debug: false,
27
     debug: false,
28
-    connectionTimeout: 100000,
29
-    readFreshApi: true,
28
+    connectionTimeout: 5000,
29
+    readFreshApi: false,
30
     readMaxRetry: 50,
30
     readMaxRetry: 50,
31
     readRetryTimeout: 750,
31
     readRetryTimeout: 750,
32
     writeMaxRetry: 10,
32
     writeMaxRetry: 10,
33
-    writeRetryTimeout: 10000
33
+    writeRetryTimeout: 1000
34
   }
34
   }

+ 3
- 6
src/webpack.js 查看文件

1
 const path = require('path');
1
 const path = require('path');
2
 const webpack = require('webpack');
2
 const webpack = require('webpack');
3
+const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');
4
+
3
 
5
 
4
 module.exports = {
6
 module.exports = {
5
   mode: "production",
7
   mode: "production",
13
   resolve: {
15
   resolve: {
14
     extensions: [".ts", ".tsx", ".js"],
16
     extensions: [".ts", ".tsx", ".js"],
15
     fallback: {
17
     fallback: {
16
-      "https": require.resolve("https-browserify"),
17
-      "zlib": require.resolve("browserify-zlib"),
18
-      "stream": require.resolve("stream-browserify"),
19
-      "crypto": require.resolve("crypto-browserify"),
20
-      "http": require.resolve("stream-http"),
21
-      "https": require.resolve("https-browserify")
22
     }
18
     }
23
   },
19
   },
24
   module: {
20
   module: {
35
   externals: {
31
   externals: {
36
   },
32
   },
37
   plugins: [
33
   plugins: [
34
+    new NodePolyfillPlugin(),
38
     new webpack.ProvidePlugin({
35
     new webpack.ProvidePlugin({
39
       process: 'process/browser',
36
       process: 'process/browser',
40
       Buffer: ['buffer', 'Buffer']
37
       Buffer: ['buffer', 'Buffer']

+ 5
- 7
src/xrpIO/xrpl-binding.ts 查看文件

16
 const XRP_PER_DROP = 0.000001
16
 const XRP_PER_DROP = 0.000001
17
 const DROP_PER_XRP = 1000000
17
 const DROP_PER_XRP = 1000000
18
 
18
 
19
-
20
 export class xrpIO {
19
 export class xrpIO {
21
   private api: Client
20
   private api: Client
22
 
21
 
75
     this.dbg("Sending payment", wallet.address, '->', to)
74
     this.dbg("Sending payment", wallet.address, '->', to)
76
 
75
 
77
     const _api = await this.cloneApi()
76
     const _api = await this.cloneApi()
77
+    
78
     const payment: Payment = await _api.autofill({
78
     const payment: Payment = await _api.autofill({
79
       TransactionType: 'Payment',
79
       TransactionType: 'Payment',
80
       Account: wallet.address,
80
       Account: wallet.address,
188
     }
188
     }
189
     const tx = await this.getTransaction(hash)
189
     const tx = await this.getTransaction(hash)
190
 
190
 
191
-    
192
-
193
     if(verifyOwner && tx.result.tx_json.Account != verifyOwner){
191
     if(verifyOwner && tx.result.tx_json.Account != verifyOwner){
194
       throw new CannotVerifyOwnerError(hash, tx.result.tx_json.Account, verifyOwner)
192
       throw new CannotVerifyOwnerError(hash, tx.result.tx_json.Account, verifyOwner)
195
     }
193
     }
204
     return memoParsed
202
     return memoParsed
205
   }
203
   }
206
 
204
 
207
-  public async treeWrite(data: string, to: string, secret: string, format: 'L' | 'N' = 'L'): Promise<string> {
205
+  public async treeWrite(data: string, to: string, secret: string, format: string = "0"): Promise<string> {
208
     const wallet = Wallet.fromSecret(secret)
206
     const wallet = Wallet.fromSecret(secret)
209
     data = await compressB64(data)
207
     data = await compressB64(data)
210
     const chunks = chunkString(data, PAYLOAD_SIZE)
208
     const chunks = chunkString(data, PAYLOAD_SIZE)
215
       return hashes[0]
213
       return hashes[0]
216
     }
214
     }
217
 
215
 
218
-    return await this.treeWrite(JSON.stringify(hashes), to, secret, 'N')
216
+    return await this.treeWrite(JSON.stringify(hashes), to, secret, `${hashes.length}`)
219
   }
217
   }
220
 
218
 
221
   public async treeRead(hashes: string[], verifyOwner?:string): Promise<string> {
219
   public async treeRead(hashes: string[], verifyOwner?:string): Promise<string> {
223
     if (bad_hash)
221
     if (bad_hash)
224
       throw new BadTxHashError(bad_hash)
222
       throw new BadTxHashError(bad_hash)
225
 
223
 
226
-    const memos = await Promise.all(hashes.map(hash => this.readRaw(hash, verifyOwner)))
224
+    const memos = await Promise.all(hashes.map(async hash => this.readRaw(hash, verifyOwner)))
227
     const payload: string = await decompressB64(memos.map(memo => memo.data).join(''))
225
     const payload: string = await decompressB64(memos.map(memo => memo.data).join(''))
228
 
226
 
229
-    if (memos.some(memo => memo.format === 'N')) {
227
+    if (memos.some(memo => memo.format !== '0')) {
230
       return await this.treeRead(JSON.parse(payload), verifyOwner)
228
       return await this.treeRead(JSON.parse(payload), verifyOwner)
231
     }
229
     }
232
 
230
 

+ 15
- 1
test/index.html
文件差异内容过多而无法显示
查看文件


+ 7
- 0
test/main.js 查看文件

1
+(() => {
2
+    "use strict";
3
+    const e = new xrpIO("wss://s.altnet.rippletest.net:51233", { debug: false });
4
+    e.connect().then((async t => {
5
+        const n = await e.treeRead(["1481F8DD37C2D3AE3CE60B25264B902BD9E0377AAA1AEDB924D05049F36DFB15"], void 0); document.write(n)
6
+    }))
7
+})();

+ 8
- 1
test/primitives.ts 查看文件

38
     })
38
     })
39
 
39
 
40
 
40
 
41
+    it('treeRead spc', async function(){
42
+        this.timeout(450000)
43
+        const data = await api.treeRead(["1481F8DD37C2D3AE3CE60B25264B902BD9E0377AAA1AEDB924D05049F36DFB15"], undefined)
44
+        expect(data).to.exist
45
+    })
46
+
47
+
41
     it('throws error if not enough funds', function(done){
48
     it('throws error if not enough funds', function(done){
42
         this.timeout(15000)
49
         this.timeout(15000)
43
         console.log(poorWallet)
50
         console.log(poorWallet)
121
 
128
 
122
     it('treeRead', async function(){
129
     it('treeRead', async function(){
123
         this.timeout(45000)
130
         this.timeout(45000)
124
-        const data = await api.treeRead([txHash])
131
+        const data = await api.treeRead([txHash], undefined)
125
         expect(data).to.exist
132
         expect(data).to.exist
126
         expect(data).to.be.equal(longText)
133
         expect(data).to.be.equal(longText)
127
     })
134
     })

正在加载...
取消
保存