Skip to content

Commit

Permalink
chore: update argon variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
blakebyrnes committed Sep 19, 2024
1 parent ae0935d commit e56c5bf
Show file tree
Hide file tree
Showing 30 changed files with 1,509 additions and 2,122 deletions.
6 changes: 3 additions & 3 deletions client/main/lib/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface IClientConfig
Pick<IQueryOptions, 'authentication' | 'affiliateId' | 'onQueryResult' | 'queryId'>
> {
paymentService?: IPaymentService;
mainchainUrl?: string;
argonMainchainUrl?: string;
}

export default class ClientForRemote {
Expand Down Expand Up @@ -63,7 +63,7 @@ export default class ClientForRemote {
// see if this is a domain
DataDomainStore.parse(this.host);

if (!config?.mainchainUrl)
if (!config?.argonMainchainUrl)
throw new Error('No mainchain url provided to lookup this datastore host');
this.domainLookupPromise = this.lookupDomain(uriOrObject);
} catch (err) {
Expand Down Expand Up @@ -156,7 +156,7 @@ export default class ClientForRemote {
private async lookupDomain(domainName: string): Promise<void> {
const lookup = await DatastoreApiClient.lookupDatastoreHost(
domainName,
this.config.mainchainUrl,
this.config.argonMainchainUrl,
);

this.datastoreId = lookup.datastoreId;
Expand Down
14 changes: 7 additions & 7 deletions cloud/main/.env.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,19 @@ ULX_ENABLE_GLOBAL_CONFIG=true
## Localchain Configuration

# Path to the localchain
ULX_LOCALCHAIN_PATH=
ARGON_LOCALCHAIN_PATH=
# Default Argon mainchain host TODO: fill in once mainchain is up#
ULX_MAINCHAIN_URL=
ARGON_MAINCHAIN_URL=
# A vote output address for the localchain (activates vote creation)
ULX_VOTES_ADDRESS=
ARGON_VOTES_ADDRESS=
# The preferred notary to use
ULX_NOTARY_ID=1
ARGON_NOTARY_ID=1
# Prompt for an interactive password on the cli
ULX_LOCALCHAIN_PASSWORD_INTERACTIVE_CLI=
ARGON_LOCALCHAIN_PASSWORD_INTERACTIVE_CLI=
# Path to the localchain password file
ULX_LOCALCHAIN_PASSWORD_FILE=
ARGON_LOCALCHAIN_PASSWORD_FILE=
# The localchain password loaded into memory (unsafe)
ULX_LOCALCHAIN_PASSWORD=
ARGON_LOCALCHAIN_PASSWORD=

## Hero
ULX_DATA_DIR=<TMP>/.ulixee
Expand Down
10 changes: 5 additions & 5 deletions datastore/broker-admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"lodash.kebabcase": "^4.1.1",
"moment": "^2.29.4",
"param-case": "^3.0.4",
"sass": "^1.56.1",
"tailwindcss": "^3.0.24",
"sass": "^1.79.1",
"tailwindcss": "^3.4.12",
"vue": "^3.2.45",
"vue-router": "^4.0.0-0"
},
Expand All @@ -45,11 +45,11 @@
"@vitejs/plugin-vue": "^1.6.1",
"@vue/eslint-config-prettier": "^7.0.0",
"@vue/eslint-config-typescript": "^10.0.0",
"typescript": "^5.3.3",
"typescript": "^5.6.2",
"vite": "^2.5.4",
"vite-plugin-checker": "^0.6.4",
"vite-plugin-checker": "^0.8.0",
"vite-svg-loader": "^5.1.0",
"vue-tsc": "^1.8.27"
"vue-tsc": "^2.1.6"
},
"nohoist": [
"**/@typescript-eslint",
Expand Down
2 changes: 1 addition & 1 deletion datastore/broker/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default function cliCommands(): Command {
'--localchain-path <path>',
'The path to the localchain data directory. You can also configure this using the .env file',
)
.env('ULX_LOCALCHAIN_PATH'),
.env('ARGON_LOCALCHAIN_PATH'),
)
.allowUnknownOption(true)
.action(async opts => {
Expand Down
22 changes: 11 additions & 11 deletions datastore/broker/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,24 @@ export default {
};

function getLocalchainConfig(): ILocalchainConfig | undefined {
if (!env.ULX_LOCALCHAIN_PATH && !env.ULX_MAINCHAIN_URL) return;
if (!env.ARGON_LOCALCHAIN_PATH && !env.ARGON_MAINCHAIN_URL) return;
let keystorePassword: Buffer | undefined;
if (env.ULX_LOCALCHAIN_PASSWORD) {
keystorePassword = Buffer.from(env.ULX_LOCALCHAIN_PASSWORD, 'utf8');
delete process.env.ULX_LOCALCHAIN_PASSWORD;
if (env.ARGON_LOCALCHAIN_PASSWORD) {
keystorePassword = Buffer.from(env.ARGON_LOCALCHAIN_PASSWORD, 'utf8');
delete process.env.ARGON_LOCALCHAIN_PASSWORD;
}
if (env.ULX_LOCALCHAIN_PASSWORD_FILE)
env.ULX_LOCALCHAIN_PASSWORD_FILE = parseEnvPath(env.ULX_LOCALCHAIN_PASSWORD_FILE);
if (env.ULX_LOCALCHAIN_PATH) env.ULX_LOCALCHAIN_PATH = parseEnvPath(env.ULX_LOCALCHAIN_PATH);
if (env.ARGON_LOCALCHAIN_PASSWORD_FILE)
env.ARGON_LOCALCHAIN_PASSWORD_FILE = parseEnvPath(env.ARGON_LOCALCHAIN_PASSWORD_FILE);
if (env.ARGON_LOCALCHAIN_PATH) env.ARGON_LOCALCHAIN_PATH = parseEnvPath(env.ARGON_LOCALCHAIN_PATH);

return <ILocalchainConfig>{
localchainPath: env.ULX_LOCALCHAIN_PATH,
mainchainUrl: env.ULX_MAINCHAIN_URL,
localchainPath: env.ARGON_LOCALCHAIN_PATH,
argonMainchainUrl: env.ARGON_MAINCHAIN_URL,
notaryId: parseEnvInt(env.NOTARY_ID),
keystorePassword: {
interactiveCli: parseEnvBool(env.ULX_LOCALCHAIN_PASSWORD_INTERACTIVE_CLI),
interactiveCli: parseEnvBool(env.ARGON_LOCALCHAIN_PASSWORD_INTERACTIVE_CLI),
password: keystorePassword,
passwordFile: env.ULX_LOCALCHAIN_PASSWORD_FILE,
passwordFile: env.ARGON_LOCALCHAIN_PASSWORD_FILE,
},
};
}
14 changes: 7 additions & 7 deletions datastore/core/.env.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ ULX_ENABLE_GLOBAL_CONFIG=true
## Localchain Configuration

# Path to the localchain
ULX_LOCALCHAIN_PATH=
ARGON_LOCALCHAIN_PATH=
# Default Argon mainchain host TODO: fill in once mainchain is up#
ULX_MAINCHAIN_URL=
ARGON_MAINCHAIN_URL=
# A vote output address for the localchain (activates vote creation)
ULX_VOTES_ADDRESS=
ARGON_VOTES_ADDRESS=
# The preferred notary to use
ULX_NOTARY_ID=1
ARGON_NOTARY_ID=1
# Prompt for an interactive password on the cli
ULX_LOCALCHAIN_PASSWORD_INTERACTIVE_CLI=
ARGON_LOCALCHAIN_PASSWORD_INTERACTIVE_CLI=
# Path to the localchain password file
ULX_LOCALCHAIN_PASSWORD_FILE=
ARGON_LOCALCHAIN_PASSWORD_FILE=
# The localchain password loaded into memory (unsafe)
ULX_LOCALCHAIN_PASSWORD=
ARGON_LOCALCHAIN_PASSWORD=
24 changes: 12 additions & 12 deletions datastore/core/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,25 @@ export default {
};

function getLocalchainConfig(): ILocalchainConfig | undefined {
if (!env.ULX_LOCALCHAIN_PATH && !env.ULX_MAINCHAIN_URL) return;
if (!env.ARGON_LOCALCHAIN_PATH && !env.ARGON_MAINCHAIN_URL) return;
let keystorePassword: Buffer | undefined;
if (env.ULX_LOCALCHAIN_PASSWORD) {
keystorePassword = Buffer.from(env.ULX_LOCALCHAIN_PASSWORD, 'utf8');
delete process.env.ULX_LOCALCHAIN_PASSWORD;
if (env.ARGON_LOCALCHAIN_PASSWORD) {
keystorePassword = Buffer.from(env.ARGON_LOCALCHAIN_PASSWORD, 'utf8');
delete process.env.ARGON_LOCALCHAIN_PASSWORD;
}
if (env.ULX_LOCALCHAIN_PASSWORD_FILE)
env.ULX_LOCALCHAIN_PASSWORD_FILE = parseEnvPath(env.ULX_LOCALCHAIN_PASSWORD_FILE);
if (env.ULX_LOCALCHAIN_PATH) env.ULX_LOCALCHAIN_PATH = parseEnvPath(env.ULX_LOCALCHAIN_PATH);
if (env.ARGON_LOCALCHAIN_PASSWORD_FILE)
env.ARGON_LOCALCHAIN_PASSWORD_FILE = parseEnvPath(env.ARGON_LOCALCHAIN_PASSWORD_FILE);
if (env.ARGON_LOCALCHAIN_PATH) env.ARGON_LOCALCHAIN_PATH = parseEnvPath(env.ARGON_LOCALCHAIN_PATH);

return <ILocalchainConfig>{
localchainPath: env.ULX_LOCALCHAIN_PATH,
mainchainUrl: env.ULX_MAINCHAIN_URL,
votesAddress: parseAddress(env.ULX_VOTES_ADDRESS, 'Votes Address'),
localchainPath: env.ARGON_LOCALCHAIN_PATH,
argonMainchainUrl: env.ARGON_MAINCHAIN_URL,
votesAddress: parseAddress(env.ARGON_VOTES_ADDRESS, 'Votes Address'),
notaryId: parseEnvInt(env.NOTARY_ID),
keystorePassword: {
interactiveCli: parseEnvBool(env.ULX_LOCALCHAIN_PASSWORD_INTERACTIVE_CLI),
interactiveCli: parseEnvBool(env.ARGON_LOCALCHAIN_PASSWORD_INTERACTIVE_CLI),
password: keystorePassword,
passwordFile: env.ULX_LOCALCHAIN_PASSWORD_FILE,
passwordFile: env.ARGON_LOCALCHAIN_PASSWORD_FILE,
},
};
}
Expand Down
8 changes: 4 additions & 4 deletions datastore/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,10 @@ export default class DatastoreCore extends TypedEventEmitter<{
} else {
this.upstreamDatastorePaymentService = new EmbeddedPaymentService();
if (!this.datastoreHostLookup) {
const mainchainUrl =
this.options.localchainConfig?.mainchainUrl ?? Env.localchainConfig?.mainchainUrl;
const mainchainClient = mainchainUrl
? await MainchainClient.connect(mainchainUrl, 10e3)
const argonMainchainUrl =
this.options.localchainConfig?.argonMainchainUrl ?? Env.localchainConfig?.argonMainchainUrl;
const mainchainClient = argonMainchainUrl
? await MainchainClient.connect(argonMainchainUrl, 10e3)
: null;
this.datastoreHostLookup = new DatastoreLookup(mainchainClient);
}
Expand Down
6 changes: 3 additions & 3 deletions datastore/docpage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
"remark-html": "^15.0.1",
"remark-parse": "^10.0.1",
"remark-rehype": "^10.1.0",
"sass": "^1.56.1",
"tailwindcss": "^3.0.24",
"sass": "^1.79.1",
"tailwindcss": "^3.4.12",
"unified": "^10.1.2",
"unified-stream": "^2.0.0",
"unist-util-visit": "^4.1.0",
Expand All @@ -51,7 +51,7 @@
"devDependencies": {
"@ulixee/datastore-packager": "2.0.0-alpha.29",
"@vitejs/plugin-vue": "^1.6.1",
"typescript": "^5.3.3",
"typescript": "^5.6.2",
"vite": "^2.5.4",
"vite-plugin-prismjs": "^0.0.11",
"vite-svg-loader": "^5.1.0"
Expand Down
10 changes: 5 additions & 5 deletions datastore/main/.env.defaults
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ULX_MAINCHAIN_URL=#ws://127.0.0.1:9944
ULX_GENESIS_UTC_TIME=1708041600000
ULX_TICK_DURATION_MILLIS=60000
ULX_NTP_SERVER=#pool.ntp.org
ULX_ESCROW_EXPIRATION_TICKS=60
ARGON_MAINCHAIN_URL=#ws://127.0.0.1:9944
ARGON_GENESIS_UTC_TIME=1708041600000
ARGON_TICK_DURATION_MILLIS=60000
ARGON_NTP_SERVER=#pool.ntp.org
ARGON_ESCROW_EXPIRATION_TICKS=60
4 changes: 2 additions & 2 deletions datastore/main/.env.test
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ULX_TICK_DURATION_MILLIS=2000
ULX_ESCROW_EXPIRATION_TICKS=2
ARGON_TICK_DURATION_MILLIS=2000
ARGON_ESCROW_EXPIRATION_TICKS=2
4 changes: 2 additions & 2 deletions datastore/main/cli/cloneDatastore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ clonedPackageJson.devDependencies['@ulixee/datastore-packager'] = version;
export default async function cloneDatastore(
url: string,
directoryPath?: string,
options: { embedCredits?: { id: string; secret: string }; mainchainUrl?: string } = {},
options: { embedCredits?: { id: string; secret: string }; argonMainchainUrl?: string } = {},
): Promise<{ datastoreFilePath: string }> {
const {
datastoreId,
version: datastoreVersion,
host,
} = await DatastoreApiClient.lookupDatastoreHost(url, options.mainchainUrl);
} = await DatastoreApiClient.lookupDatastoreHost(url, options.argonMainchainUrl);
if (url.includes('/free-credit')) {
const credit = new URL(url).search.split(':');
options.embedCredits = { id: credit[0], secret: credit[1] };
Expand Down
18 changes: 9 additions & 9 deletions datastore/main/cli/creditsCli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ export default function creditsCli(): Command {
'ULX_IDENTITY_PATH',
),
)
.option('-m, --mainchain-url <url>', 'The mainchain url to use.')
.option('-m, --argon-mainchain-url <url>', 'The mainchain url to use.')
.addOption(identityPrivateKeyPassphraseOption)
.action(async (url, { identityPath, identityPassphrase, argons, mainchainUrl }) => {
.action(async (url, { identityPath, identityPassphrase, argons, argonMainchainUrl }) => {
const microgons = ArgonUtils.milligonsToMicrogons(
parseFloat(argons) * Number(ArgonUtils.MilligonsPerArgon),
);
const identity = Identity.loadFromFile(identityPath, { keyPassphrase: identityPassphrase });
const { datastoreId, version, host } = await DatastoreApiClient.lookupDatastoreHost(
url,
mainchainUrl,
argonMainchainUrl,
);
const client = new DatastoreApiClient(host);
try {
Expand All @@ -64,12 +64,12 @@ export default function creditsCli(): Command {
.command('install')
.description('Save to a local wallet.')
.argument('<url>', 'The url of the Credit.')
.option('-m, --mainchain-url [url]', 'The mainchain url to use.')
.option('-m, --argon-mainchain-url [url]', 'The mainchain url to use.')
.option('-d, --credit-dir [path]', 'The directory to store credits in.', CreditPaymentManager.defaultBasePath)
.action(async (url, { creditDir, mainchainUrl }) => {
.action(async (url, { creditDir, argonMainchainUrl }) => {
const { datastoreId, version, host } = await DatastoreApiClient.lookupDatastoreHost(
url,
mainchainUrl,
argonMainchainUrl,
);
const client = new DatastoreApiClient(host);
try {
Expand Down Expand Up @@ -102,11 +102,11 @@ export default function creditsCli(): Command {
.command('get')
.description('Get the current balance.')
.argument('<url>', 'The url of the Datastore Credit.')
.option('-m, --mainchain-url <url>', 'The mainchain url to use.')
.action(async (url, { mainchainUrl }) => {
.option('-m, --argon-mainchain-url <url>', 'The mainchain url to use.')
.action(async (url, { argonMainchainUrl }) => {
const { datastoreId, version, host } = await DatastoreApiClient.lookupDatastoreHost(
url,
mainchainUrl,
argonMainchainUrl,
);
const client = new DatastoreApiClient(host);
try {
Expand Down
10 changes: 5 additions & 5 deletions datastore/main/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ loadEnv(__dirname);
const env = process.env;

export default {
mainchainUrl: env.ULX_MAINCHAIN_URL,
genesisUtcTime: parseEnvInt(env.ULX_GENESIS_UTC_TIME),
tickDurationMillis: parseEnvInt(env.ULX_TICK_DURATION_MILLIS),
escrowExpirationTicks: parseEnvInt(env.ULX_ESCROW_EXPIRATION_TICKS),
ntpPoolUrl: env.ULX_NTP_SERVER,
argonMainchainUrl: env.ARGON_MAINCHAIN_URL,
genesisUtcTime: parseEnvInt(env.ARGON_GENESIS_UTC_TIME),
tickDurationMillis: parseEnvInt(env.ARGON_TICK_DURATION_MILLIS),
escrowExpirationTicks: parseEnvInt(env.ARGON_ESCROW_EXPIRATION_TICKS),
ntpPoolUrl: env.ARGON_NTP_SERVER,
defaultDataDir: env.ULX_DATA_DIR,
};
2 changes: 1 addition & 1 deletion datastore/main/interfaces/ILocalchainConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { KeystorePasswordOption } from '@argonprotocol/localchain';
import { IEscrowAllocationStrategy } from '../payments/ArgonReserver';

export default interface ILocalchainConfig {
mainchainUrl?: string;
argonMainchainUrl?: string;
notaryId?: number;
localchainPath?: string;
/**
Expand Down
4 changes: 2 additions & 2 deletions datastore/main/lib/DatastoreApiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,9 +476,9 @@ export default class DatastoreApiClient {

public static async lookupDatastoreHost(
datastoreUrl: string,
mainchainUrl: string,
argonMainchainUrl: string,
): Promise<IDatastoreHost> {
const mainchainClient = mainchainUrl ? await MainchainClient.connect(mainchainUrl, 10e3) : null;
const mainchainClient = argonMainchainUrl ? await MainchainClient.connect(argonMainchainUrl, 10e3) : null;
try {
return await new DatastoreLookup(mainchainClient).getHostInfo(datastoreUrl);
} finally {
Expand Down
4 changes: 2 additions & 2 deletions datastore/main/payments/DefaultPaymentService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ export default class DefaultPaymentService
datastoreLookup?: IDatastoreHostLookup,
): Promise<void> {
this.#datastoreLookup ??= datastoreLookup ?? (await this.argonReserver.datastoreLookup);
if (!this.#datastoreLookup && Env.mainchainUrl) {
const mainchainClient = await MainchainClient.connect(Env.mainchainUrl, 10e3);
if (!this.#datastoreLookup && Env.argonMainchainUrl) {
const mainchainClient = await MainchainClient.connect(Env.argonMainchainUrl, 10e3);
this.#datastoreLookup = new DatastoreLookup(mainchainClient);
}
const service = await CreditReserver.lookup(
Expand Down
12 changes: 6 additions & 6 deletions datastore/main/payments/LocalchainWithSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,22 @@ export default class LocalchainWithSync extends TypedEventEmitter<{ sync: Balanc
}

public async load(): Promise<void> {
const { mainchainUrl, localchainPath } = this.localchainConfig;
const { argonMainchainUrl, localchainPath } = this.localchainConfig;

let defaultPath = localchainPath ?? Localchain.getDefaultPath();
if (!defaultPath.endsWith('.db')) {
defaultPath = Path.join(defaultPath, 'primary.db');
}

log.info(`Loading ${mainchainUrl ? 'online' : 'offline'} localchain`, {
log.info(`Loading ${argonMainchainUrl ? 'online' : 'offline'} localchain`, {
localchainPath: defaultPath,
} as any);
const keystorePassword = this.getPassword();

if (mainchainUrl) {
if (argonMainchainUrl) {
this.#localchain = await Localchain.load({
path: localchainPath,
mainchainUrl,
mainchainUrl: argonMainchainUrl,
keystorePassword,
});
this.datastoreLookup = new DatastoreLookup(await this.#localchain.mainchainClient);
Expand All @@ -104,8 +104,8 @@ export default class LocalchainWithSync extends TypedEventEmitter<{ sync: Balanc
this.#localchain = null;
}

public async connectToMainchain(mainchainUrl: string, timeoutMs = 10e3): Promise<void> {
const mainchain = await MainchainClient.connect(mainchainUrl, timeoutMs);
public async connectToMainchain(argonMainchainUrl: string, timeoutMs = 10e3): Promise<void> {
const mainchain = await MainchainClient.connect(argonMainchainUrl, timeoutMs);
await this.#localchain.attachMainchain(mainchain);
}

Expand Down
Loading

0 comments on commit e56c5bf

Please sign in to comment.