weavedb-node-client 0.8.0 → 0.9.0

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.
Files changed (2) hide show
  1. package/index.js +25 -2
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -34,17 +34,40 @@ class SDK extends Base {
34
34
  rpc,
35
35
  contractTxId,
36
36
  wallet,
37
- name,
38
- version,
37
+ name = "weavedb",
38
+ version = "1",
39
39
  EthWallet,
40
40
  web3,
41
41
  arweave,
42
42
  arweave_wallet,
43
+ network = "mainnet",
44
+ port = 1820,
43
45
  }) {
44
46
  super()
45
47
  this.contractTxId = contractTxId
46
48
  this.arweave_wallet = arweave_wallet
49
+ if (isNil(arweave)) {
50
+ if (network === "localhost") {
51
+ arweave = {
52
+ host: "localhost",
53
+ port,
54
+ protocol: "http",
55
+ }
56
+ } else {
57
+ arweave = {
58
+ host: "arweave.net",
59
+ port: 443,
60
+ protocol: "https",
61
+ }
62
+ }
63
+ }
47
64
  this.arweave = Arweave.init(arweave)
65
+ this.network =
66
+ network ||
67
+ (arweave.host === "host.docker.internal" || arweave.host === "localhost"
68
+ ? "localhost"
69
+ : "mainnet")
70
+
48
71
  this.client = new weavedb_proto.DB(rpc, grpc.credentials.createInsecure())
49
72
  if (typeof window === "object") {
50
73
  require("@metamask/legacy-web3")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "weavedb-node-client",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "engines": {