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

Configuration and output changes #184

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true

# For use by shfmt for POSIX shells
[*.{sh,bash}]
# Majority of scripts are in bash. Pure POSIX scripts are not common
shell_variant = bash
charset = utf-8
indent_style = space
indent_size = 2
binary_next_line = true
switch_case_indent = true
space_redirects = true
keep_padding = true
function_next_line = false
266 changes: 120 additions & 146 deletions CMDLINE.md

Large diffs are not rendered by default.

13 changes: 5 additions & 8 deletions elv-admin
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
#! /usr/bin/env bash

SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"


if [ -e $SOURCE_DIR/utilities/EluvioCli.js ]
then
exec node $SOURCE_DIR/utilities/EluvioCli.js "$@" 2>&1
elif [ -e $SOURCE_DIR/../lib/node_modules/@eluvio/elv-live-js/utilities/EluvioCli.js ]
then
exec node $SOURCE_DIR/../lib/node_modules/@eluvio/elv-live-js/utilities/EluvioCli.js "$@" 2>&1
if [ -e "${SOURCE_DIR}/utilities/EluvioCli.js" ]; then
exec node "${SOURCE_DIR}/utilities/EluvioCli.js" "$@" 2>&1
elif [ -e "${SOURCE_DIR}/../lib/node_modules/@eluvio/elv-live-js/utilities/EluvioCli.js" ]; then
exec node "${SOURCE_DIR}/../lib/node_modules/@eluvio/elv-live-js/utilities/EluvioCli.js" "$@" 2>&1
else
echo "(elv-live-js) cannot find utilities/EluvioCli.js" 1>&2
exit 1
Expand Down
12 changes: 5 additions & 7 deletions elv-live
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#! /usr/bin/env bash

SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

if [ -e $SOURCE_DIR/utilities/EluvioLiveCli.js ]
then
exec node $SOURCE_DIR/utilities/EluvioLiveCli.js "$@" 2>&1
elif [ -e $SOURCE_DIR/../lib/node_modules/@eluvio/elv-live-js/utilities/EluvioLiveCli.js ]
then
exec node $SOURCE_DIR/../lib/node_modules/@eluvio/elv-live-js/utilities/EluvioLiveCli.js "$@" 2>&1
if [ -e "${SOURCE_DIR}/utilities/EluvioLiveCli.js" ]; then
exec node "${SOURCE_DIR}/utilities/EluvioLiveCli.js" "$@" 2>&1
elif [ -e "${SOURCE_DIR}/../lib/node_modules/@eluvio/elv-live-js/utilities/EluvioLiveCli.js" ]; then
exec node "${SOURCE_DIR}/../lib/node_modules/@eluvio/elv-live-js/utilities/EluvioLiveCli.js" "$@" 2>&1
else
echo "(elv-live-js) cannot find utilities/EluvioLiveCli.js" 1>&2
exit 1
Expand Down
13 changes: 5 additions & 8 deletions elv-stream
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
#! /usr/bin/env bash

SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"


if [ -e $SOURCE_DIR/utilities/EluvioLiveStreamCli.js ]
then
exec node $SOURCE_DIR/utilities/EluvioLiveStreamCli.js "$@" 2>&1
elif [ -e $SOURCE_DIR/../lib/node_modules/@eluvio/elv-live-js/utilities/EluvioLiveStreamCli.js ]
then
exec node $SOURCE_DIR/../lib/node_modules/@eluvio/elv-live-js/utilities/EluvioLiveStreamCli.js "$@" 2>&1
if [ -e "${SOURCE_DIR}/utilities/EluvioLiveStreamCli.js" ]; then
exec node "${SOURCE_DIR}/utilities/EluvioLiveStreamCli.js" "$@" 2>&1
elif [ -e "${SOURCE_DIR}/../lib/node_modules/@eluvio/elv-live-js/utilities/EluvioLiveStreamCli.js" ]; then
exec node "${SOURCE_DIR}/../lib/node_modules/@eluvio/elv-live-js/utilities/EluvioLiveStreamCli.js" "$@" 2>&1
else
echo "(elv-live-js) cannot find utilities/EluvioLiveStreamCli.js" 1>&2
exit 1
Expand Down
30 changes: 19 additions & 11 deletions src/Config.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
const net = "main"; // Set to "main" "demov3" "test" "dev"
const net = "main"; // Set to "main" "dv3" "tv4" "local"

/*
* networks:
* Defines the main config URLs for the respective networks.
* There are 3 public networks and 1 private dev network:
* - main: the main Eluvio production fabric
* - dv3: the demo and bleeding edge network
* - tv4: the primary test network
* - local: content-fabric development scripts can create a local dev network
*/
const networks = {
main: "https://main.net955305.contentfabric.io",
demo: "https://demov3.net955210.contentfabric.io",
demov3: "https://demov3.net955210.contentfabric.io",
test: "https://test.net955205.contentfabric.io/config",
dev: "http://localhost:8008/config?qspace=dev&self",
dv3: "https://demov3.net955210.contentfabric.io", // formerly "demo" and "demov3"
tv4: "https://test.net955205.contentfabric.io/config", // formerly "test"
local: "http://localhost:8008/config?qspace=dev&self", // formerly "dev"
};

const mainObjects = {
main: "iq__suqRJUt2vmXsyiWS5ZaSGwtFU9R",
demov3: "iq__2gkNh8CCZqFFnoRpEUmz7P3PaBQG",
test: "NOT YET SET UP",
dev: "NOT YET SET UP"
dv3: "iq__2gkNh8CCZqFFnoRpEUmz7P3PaBQG", // formerly "demov3"
tv4: "NOT YET SET UP", // formerly "test"
local: "NOT YET SET UP" // formerly "dev"
};

const consts = {
Expand All @@ -26,22 +34,22 @@ const consts = {
notificationService: "https://appsvc.svc.eluv.io/push/main"

},
demov3: {
dv3: { // formerly "demov3"
tokenUriStart: "https://demov3.net955210.contentfabric.io/s/demov3/q/",
tokenUriEnd: "/meta/public/nft",
kmsAddress: "0x501382e5f15501427d1fc3d93e949c96b25a2224",
spaceAddress: "0x9b29360efb1169c801bbcbe8e50d0664dcbc78d3",
claimerAddress: "0x",
notificationService: "https://appsvc.svc.eluv.io/push/dv3"
},
test: {
tv4: { // formerly "test"
tokenUriStart: "https://test.net955205.contentfabric.io/s/test/q/",
tokenUriEnd: "/meta/public/nft",
kmsAddress: "0x567f76e552cfea5a81945a87133867f45fafc418",
spaceAddress: "0x8e5935ca87ad11779e3aec4adcb48a5cb7c2abb4",
claimerAddress: "0xdB9241496785241f0727D3f2BbB12a5B75dEb3E9",
},
dev: {
local: { // formerly "dev"
spaceAddress: "0x96d03f6476f478f99017aec366c874004020899f",
kmsAddress: "0xd9dc97b58c5f2584062cf69775d160ed9a3bfbc4",
}
Expand Down
26 changes: 14 additions & 12 deletions src/ElvContracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ class ElvContracts {
* @namedParams
* @param {string} configUrl - The Content Fabric configuration URL
* @param {string} mainObjectId - The top-level Eluvio Live object ID
* @param {string} netName - The Fabric Network Name
*/
constructor({ configUrl, mainObjectId }) {
constructor({ configUrl, mainObjectId, netName }) {
this.configUrl = configUrl || ElvClient.main;
this.mainObjectId = mainObjectId;
this.netName = netName;

this.debug = false;
}
Expand Down Expand Up @@ -47,7 +49,7 @@ class ElvContracts {
var epochTime = new Date(String(expirationDate).replaceAll("_", "/")).getTime() / 1000;

var res = await this.client.CallContractMethodAndWait({
contractAddress: Config.consts[Config.net].claimerAddress,
contractAddress: Config.consts[this.netName].claimerAddress,
abi: JSON.parse(abi),
methodName: "allocate",
methodArgs: [address, amount, epochTime],
Expand All @@ -67,7 +69,7 @@ class ElvContracts {
);

var res = await this.client.CallContractMethodAndWait({
contractAddress: Config.consts[Config.net].claimerAddress,
contractAddress: Config.consts[this.netName].claimerAddress,
abi: JSON.parse(abi),
methodName: "claim",
methodArgs: [ amount ],
Expand All @@ -87,7 +89,7 @@ class ElvContracts {
);

var res = await this.client.CallContractMethodAndWait({
contractAddress: Config.consts[Config.net].claimerAddress,
contractAddress: Config.consts[this.netName].claimerAddress,
abi: JSON.parse(abi),
methodName: "burn",
methodArgs: [ amount ],
Expand All @@ -107,7 +109,7 @@ class ElvContracts {
);

var res = await this.client.CallContractMethodAndWait({
contractAddress: Config.consts[Config.net].claimerAddress,
contractAddress: Config.consts[this.netName].claimerAddress,
abi: JSON.parse(abi),
methodName: "addAuthorizedAddr",
methodArgs: [ address ],
Expand All @@ -127,7 +129,7 @@ class ElvContracts {
);

var res = await this.client.CallContractMethodAndWait({
contractAddress: Config.consts[Config.net].claimerAddress,
contractAddress: Config.consts[this.netName].claimerAddress,
abi: JSON.parse(abi),
methodName: "rmAuthorizedAddr",
methodArgs: [ address ],
Expand All @@ -148,7 +150,7 @@ class ElvContracts {
);

var res = await this.client.CallContractMethodAndWait({
contractAddress: Config.consts[Config.net].claimerAddress,
contractAddress: Config.consts[this.netName].claimerAddress,
abi: JSON.parse(abi),
methodName: "clearAllocations",
methodArgs: [ address ],
Expand All @@ -170,7 +172,7 @@ class ElvContracts {
await this.ClaimerClearAllocations({address});

var lengthList = await this.client.CallContractMethod({
contractAddress: Config.consts[Config.net].claimerAddress,
contractAddress: Config.consts[this.netName].claimerAddress,
abi: JSON.parse(abi),
methodName: "getNumAllocations",
methodArgs: [ address ],
Expand All @@ -183,15 +185,15 @@ class ElvContracts {
var idx = i.toString();
try {
var elemAmount = await this.client.CallContractMethod({
contractAddress: Config.consts[Config.net].claimerAddress,
contractAddress: Config.consts[this.netName].claimerAddress,
abi: JSON.parse(abi),
methodName: "getAllocationAmount",
methodArgs: [ address, idx ],
formatArguments: true,
});

var elemExpirationDate = await this.client.CallContractMethod({
contractAddress: Config.consts[Config.net].claimerAddress,
contractAddress: Config.consts[this.netName].claimerAddress,
abi: JSON.parse(abi),
methodName: "getAllocationExpirationDate",
methodArgs: [ address, idx ],
Expand All @@ -217,7 +219,7 @@ class ElvContracts {
);

var res = await this.client.CallContractMethod({
contractAddress: Config.consts[Config.net].claimerAddress,
contractAddress: Config.consts[this.netName].claimerAddress,
abi: JSON.parse(abi),
methodName: "balanceOf",
methodArgs: [ address ],
Expand All @@ -237,7 +239,7 @@ class ElvContracts {
);

var res = await this.client.CallContractMethod({
contractAddress: Config.consts[Config.net].claimerAddress,
contractAddress: Config.consts[this.netName].claimerAddress,
abi: JSON.parse(abi),
methodName: "burnOf",
methodArgs: [ address ],
Expand Down
7 changes: 4 additions & 3 deletions src/LiveStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@ class EluvioLiveStream {
*
* @namedParams
* @param {string} url - Optional node endpoint URL (overwrites config URL)
* @param {string} network - Optional network name
* @param {bool} debugLogging - Optional debug logging flag
* @return {EluvioLive} - New EluvioLive object connected to the specified content fabric and blockchain
*/
constructor({ url, debugLogging = false }) {
constructor({ url, network = Config.net, debugLogging = false }) {

if (url) {
this.configUrl = url+"/config?self&qspace="+Config.net;
this.configUrl = url+"/config?self&qspace="+network;
} else {
this.configUrl = Config.networks[Config.net];
this.configUrl = Config.networks[network];
}
this.debug = debugLogging;
}
Expand Down
Loading