Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move common sdk functions to weavedb-base #125

Merged
merged 1 commit into from Nov 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
56 changes: 56 additions & 0 deletions base/index.js
Expand Up @@ -530,6 +530,62 @@ class Base {
)
return await this._request(func, param, dryWrite, bundle)
}

async getOwner() {
return this.request("getOwner")
}

async addOwner(address, opt) {
return this._write2("addOwner", { address }, opt)
}

async removeOwner(address, opt) {
return this._write2("removeOwner", { address }, opt)
}

async getEvolve() {
return await this.viewState({
function: "getEvolve",
})
}

async evolve(value, opt) {
return this._write2("evolve", { value }, { ...opt, extra: { value } })
}

async setCanEvolve(value, opt) {
return this._write2("setCanEvolve", { value }, opt)
}

async getAddressLink(address) {
return this.viewState({ function: "getAddressLink", query: { address } })
}

async getVersion() {
return await this.viewState({
function: "version",
})
}

async getNonce(addr) {
return (
(await this.viewState({
function: "nonce",
address: addr,
})) + 1
)
}

async getIds(tx) {
return this.viewState({
function: "ids",
tx,
})
}

async mineBlock() {
await this.arweave.api.get("mine")
}
}

module.exports = Base
2 changes: 1 addition & 1 deletion base/package.json
@@ -1,6 +1,6 @@
{
"name": "weavedb-base",
"version": "0.7.0",
"version": "0.7.3",
"description": "A decentralized NoSQL database powered by Arweave.",
"homepage": "https://weavedb.dev",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion node/net/grpc/gateway/weavedb/node-server/package.json
Expand Up @@ -10,6 +10,6 @@
"@grpc/proto-loader": "~0.5.0",
"google-protobuf": "~3.14.0",
"ramda": "^0.28.0",
"weavedb-sdk": "^0.5.8"
"weavedb-sdk": "^0.7.3"
}
}
22 changes: 11 additions & 11 deletions node/net/grpc/gateway/weavedb/node-server/yarn.lock
Expand Up @@ -1516,9 +1516,9 @@ cipher-base@^1.0.0, cipher-base@^1.0.1, cipher-base@^1.0.3:
inherits "^2.0.1"
safe-buffer "^5.0.1"

"circomlibjs@git+https://github.com/InternetMaximalism/circomlibjs#fc534a12d9b34f2694ed0f75a686d080fc7a92d6":
"circomlibjs@git+https://github.com/InternetMaximalism/circomlibjs.git#fc534a12d9b34f2694ed0f75a686d080fc7a92d6":
version "0.1.7"
resolved "git+https://github.com/InternetMaximalism/circomlibjs#fc534a12d9b34f2694ed0f75a686d080fc7a92d6"
resolved "git+https://github.com/InternetMaximalism/circomlibjs.git#fc534a12d9b34f2694ed0f75a686d080fc7a92d6"
dependencies:
blake-hash "^2.0.0"
blake2b "^2.1.3"
Expand Down Expand Up @@ -3301,10 +3301,10 @@ wasmcurves@0.2.0:
dependencies:
wasmbuilder "0.0.16"

weavedb-base@^0.5.11:
version "0.5.11"
resolved "https://registry.yarnpkg.com/weavedb-base/-/weavedb-base-0.5.11.tgz#33625c6abed9b0ebffdb30714a4c07f60ca07315"
integrity sha512-efCzLW1RRgYAE2zpqo+Wsk/OXZCH3MA42lIxdGSOHalL3YwnrB4S4wKIVoc21ZwhqSaGRaCivhZtVonqb8o4XQ==
weavedb-base@^0.7.3:
version "0.7.3"
resolved "https://registry.yarnpkg.com/weavedb-base/-/weavedb-base-0.7.3.tgz#f7172f01e80a5dd5da6606c9637cc4208b048975"
integrity sha512-QYCvvRzueZdxSoP20GzYIVDjm+bZaYMrR4t0lqYVPBocsrWtHFs0xpUyp3SENUnAR9Kh/d1snIPdsHUeg5Xxhw==
dependencies:
"@metamask/eth-sig-util" "^4.0.1"
"@metamask/legacy-web3" "^2.0.0"
Expand All @@ -3313,16 +3313,16 @@ weavedb-base@^0.5.11:
ethereumjs-util "^7.1.5"
ramda "^0.28.0"

weavedb-sdk@^0.5.8:
version "0.5.8"
resolved "https://registry.yarnpkg.com/weavedb-sdk/-/weavedb-sdk-0.5.8.tgz#39740b20ff06b9e60b1fe1d79ab7c6299bc0a93c"
integrity sha512-twCD2/CTWa7jMEfOZApGJvwrcUTO4Vit0C9RXMsK4qm2oE9htBW+dq0ofYwo8TKz6FQgfWxNtUaQVppe7E9Q9A==
weavedb-sdk@^0.7.3:
version "0.7.3"
resolved "https://registry.yarnpkg.com/weavedb-sdk/-/weavedb-sdk-0.7.3.tgz#c220d3805448d900e4958f53889913e8dacb520c"
integrity sha512-uliM3ezYGaue6joZ2mE2JrNLkOm7UtmnSnIEvSm+5Rez4rznG8GPtd6Z/aeWH5Zz8iv47ZgGeGbsojjftW6DOA==
dependencies:
"@metamask/legacy-web3" "^2.0.0"
arweave "^1.11.4"
ramda "^0.28.0"
warp-contracts "1.1.14"
weavedb-base "^0.5.11"
weavedb-base "^0.7.3"

web-worker@^1.2.0:
version "1.2.0"
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "weavedb",
"version": "0.5.0",
"version": "0.7.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
Expand Down
6 changes: 3 additions & 3 deletions sdk-exm-web/package.json
@@ -1,6 +1,6 @@
{
"name": "weavedb-exm-sdk-web",
"version": "0.7.2",
"version": "0.7.3",
"description": "Web Client for WeaveDB on Execution Machine",
"homepage": "https://weavedb.dev",
"repository": {
Expand All @@ -13,12 +13,12 @@
"node": "16"
},
"dependencies": {
"arweave": "^1.11.4",
"fpjson-lang": "^0.1.1",
"isomorphic-fetch": "^3.0.0",
"json-logic-js": "^2.0.2",
"arweave": "^1.11.4",
"ramda": "^0.28.0",
"weavedb-base": "^0.5.11"
"weavedb-base": "^0.7.3"
},
"devDependencies": {
"esbuild": "^0.14.50",
Expand Down
8 changes: 4 additions & 4 deletions sdk-exm-web/yarn.lock
Expand Up @@ -2258,10 +2258,10 @@ wasmcurves@0.2.0:
dependencies:
wasmbuilder "0.0.16"

weavedb-base@^0.5.11:
version "0.5.11"
resolved "https://registry.yarnpkg.com/weavedb-base/-/weavedb-base-0.5.11.tgz#33625c6abed9b0ebffdb30714a4c07f60ca07315"
integrity sha512-efCzLW1RRgYAE2zpqo+Wsk/OXZCH3MA42lIxdGSOHalL3YwnrB4S4wKIVoc21ZwhqSaGRaCivhZtVonqb8o4XQ==
weavedb-base@^0.7.3:
version "0.7.3"
resolved "https://registry.yarnpkg.com/weavedb-base/-/weavedb-base-0.7.3.tgz#f7172f01e80a5dd5da6606c9637cc4208b048975"
integrity sha512-QYCvvRzueZdxSoP20GzYIVDjm+bZaYMrR4t0lqYVPBocsrWtHFs0xpUyp3SENUnAR9Kh/d1snIPdsHUeg5Xxhw==
dependencies:
"@metamask/eth-sig-util" "^4.0.1"
"@metamask/legacy-web3" "^2.0.0"
Expand Down
4 changes: 0 additions & 4 deletions sdk-exm/index.js
Expand Up @@ -63,10 +63,6 @@ class SDK extends Base {
}
return tx
}

async evolve(value, opt) {
return this._write2("evolve", { value }, opt)
}
}

module.exports = SDK
4 changes: 2 additions & 2 deletions sdk-exm/package.json
@@ -1,6 +1,6 @@
{
"name": "weavedb-exm-sdk",
"version": "0.7.2",
"version": "0.7.3",
"description": "WeaveDB on Execution Machine.",
"homepage": "https://weavedb.dev",
"repository": {
Expand All @@ -16,7 +16,7 @@
"@execution-machine/sdk": "^0.1.6",
"arweave": "^1.11.4",
"ramda": "^0.28.0",
"weavedb-base": "^0.5.11"
"weavedb-base": "^0.7.3"
},
"devDependencies": {
"esbuild": "^0.14.50",
Expand Down
12 changes: 6 additions & 6 deletions sdk-exm/yarn.lock
Expand Up @@ -2304,9 +2304,9 @@ cipher-base@^1.0.0, cipher-base@^1.0.1, cipher-base@^1.0.3:
inherits "^2.0.1"
safe-buffer "^5.0.1"

"circomlibjs@git+https://github.com/InternetMaximalism/circomlibjs#fc534a12d9b34f2694ed0f75a686d080fc7a92d6":
"circomlibjs@git+https://github.com/InternetMaximalism/circomlibjs.git#fc534a12d9b34f2694ed0f75a686d080fc7a92d6":
version "0.1.7"
resolved "git+https://github.com/InternetMaximalism/circomlibjs#fc534a12d9b34f2694ed0f75a686d080fc7a92d6"
resolved "git+https://github.com/InternetMaximalism/circomlibjs.git#fc534a12d9b34f2694ed0f75a686d080fc7a92d6"
dependencies:
blake-hash "^2.0.0"
blake2b "^2.1.3"
Expand Down Expand Up @@ -5102,10 +5102,10 @@ wasmcurves@0.2.0:
dependencies:
wasmbuilder "0.0.16"

weavedb-base@^0.5.11:
version "0.5.11"
resolved "https://registry.yarnpkg.com/weavedb-base/-/weavedb-base-0.5.11.tgz#33625c6abed9b0ebffdb30714a4c07f60ca07315"
integrity sha512-efCzLW1RRgYAE2zpqo+Wsk/OXZCH3MA42lIxdGSOHalL3YwnrB4S4wKIVoc21ZwhqSaGRaCivhZtVonqb8o4XQ==
weavedb-base@^0.7.3:
version "0.7.3"
resolved "https://registry.yarnpkg.com/weavedb-base/-/weavedb-base-0.7.3.tgz#f7172f01e80a5dd5da6606c9637cc4208b048975"
integrity sha512-QYCvvRzueZdxSoP20GzYIVDjm+bZaYMrR4t0lqYVPBocsrWtHFs0xpUyp3SENUnAR9Kh/d1snIPdsHUeg5Xxhw==
dependencies:
"@metamask/eth-sig-util" "^4.0.1"
"@metamask/legacy-web3" "^2.0.0"
Expand Down
57 changes: 0 additions & 57 deletions sdk/index.js
Expand Up @@ -2,7 +2,6 @@ const { all, complement, isNil } = require("ramda")
let Arweave = require("arweave")
Arweave = isNil(Arweave.default) ? Arweave : Arweave.default
const Base = require("weavedb-base")

const {
Warp,
WarpNodeFactory,
Expand Down Expand Up @@ -57,18 +56,6 @@ class SDK extends Base {
if (!isNil(EthWallet)) this.setEthWallet(EthWallet)
}

async getOwner() {
return this.request("getOwner")
}

async getAddressLink(address) {
return this.viewState({ function: "getAddressLink", query: { address } })
}

async mineBlock() {
await this.arweave.api.get("mine")
}

async request(func, ...query) {
return this.viewState({
function: func,
Expand All @@ -81,34 +68,6 @@ class SDK extends Base {
return res.result
}

async getVersion() {
return await this.viewState({
function: "version",
})
}

async getNonce(addr) {
return (
(await this.viewState({
function: "nonce",
address: addr,
})) + 1
)
}

async getIds(tx) {
return this.viewState({
function: "ids",
tx,
})
}

async getEvolve() {
return await this.viewState({
function: "getEvolve",
})
}

async _request(func, param, dryWrite, bundle) {
if (dryWrite) {
let dryState = await this.db.dryWrite(param)
Expand All @@ -124,22 +83,6 @@ class SDK extends Base {
if (this.network === "localhost") await this.mineBlock()
return tx
}

async evolve(value, opt) {
return this._write2("evolve", { value }, { ...opt, extra: { value } })
}

async setCanEvolve(value, opt) {
return this._write2("setCanEvolve", { value }, opt)
}

async addOwner(address, opt) {
return this._write2("addOwner", { address }, opt)
}

async removeOwner(address, opt) {
return this._write2("removeOwner", { address }, opt)
}
}

module.exports = SDK
4 changes: 2 additions & 2 deletions sdk/package.json
@@ -1,6 +1,6 @@
{
"name": "weavedb-sdk",
"version": "0.7.1",
"version": "0.7.3",
"description": "A decentralized NoSQL database powered by Arweave.",
"homepage": "https://weavedb.dev",
"repository": {
Expand All @@ -17,7 +17,7 @@
"arweave": "^1.11.4",
"ramda": "^0.28.0",
"warp-contracts": "1.1.14",
"weavedb-base": "^0.7.0"
"weavedb-base": "^0.7.3"
},
"devDependencies": {
"esbuild": "^0.14.50",
Expand Down
8 changes: 4 additions & 4 deletions sdk/yarn.lock
Expand Up @@ -3139,10 +3139,10 @@ wasmcurves@0.2.0:
dependencies:
wasmbuilder "0.0.16"

weavedb-base@^0.7.0:
version "0.7.0"
resolved "https://registry.yarnpkg.com/weavedb-base/-/weavedb-base-0.7.0.tgz#beeb01b27b30cf7a23ad789ce01a76b025b0bc27"
integrity sha512-fLGXCUZSW/bIZBALP7xmDnUkuxoGiEusXiTAg4cEJwzFG2/Dz6iPHd9TQ0u6C7g/bkkeSBKc73rtFhQCjG3YXg==
weavedb-base@^0.7.3:
version "0.7.3"
resolved "https://registry.yarnpkg.com/weavedb-base/-/weavedb-base-0.7.3.tgz#f7172f01e80a5dd5da6606c9637cc4208b048975"
integrity sha512-QYCvvRzueZdxSoP20GzYIVDjm+bZaYMrR4t0lqYVPBocsrWtHFs0xpUyp3SENUnAR9Kh/d1snIPdsHUeg5Xxhw==
dependencies:
"@metamask/eth-sig-util" "^4.0.1"
"@metamask/legacy-web3" "^2.0.0"
Expand Down