Skip to content

Commit

Permalink
node address to rpc address
Browse files Browse the repository at this point in the history
  • Loading branch information
gRoussac committed Sep 17, 2024
1 parent 04abe86 commit 7641e6b
Show file tree
Hide file tree
Showing 62 changed files with 613 additions and 629 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-rust-sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
node-version: [20.x]
runs-on: ${{ matrix.os }}
env:
NODE_ADDRESS: http://127.0.0.1:7777/rpc
RPC_ADDRESS: http://127.0.0.1:7777/rpc
EVENT_ADDRESS: http://127.0.0.1:9999/events/main
SPECULTATIVE_ADDRESS: http://127.0.0.1:7778
# WARNING: These accounts, and their private keys, are publicly known.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly-scheduled-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
os: [ubuntu-20.04, ubuntu-22.04]
runs-on: ${{ matrix.os }}
env:
NODE_ADDRESS: http://127.0.0.1:7777/rpc
RPC_ADDRESS: http://127.0.0.1:7777/rpc
EVENT_ADDRESS: http://127.0.0.1:9999/events/main
# WARNING: These accounts, and their private keys, are publicly known.
# Any funds sent to them on Mainnet or any other live network WILL BE LOST.
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM --platform=linux/amd64 node:22.1.0-alpine3.19
ENV NODE_ENV "development"

# /dev/rpc network adress (optional)
ENV NODE_ADDRESS "http://localhost:11101"
ENV RPC_ADDRESS "http://localhost:11101"

WORKDIR /app

Expand Down
52 changes: 26 additions & 26 deletions examples/desktop/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { DeployStrParams, PaymentStrParams, getTimestamp, SDK, SessionStrParams,
const fs = require('fs').promises;
const http = require('http');

const node_address = 'http://localhost:11101';
const sdk = new SDK(node_address);
const rpc_address = 'http://localhost:11101';
const sdk = new SDK(rpc_address);

// const server = http.createServer(async (req, res) => {
// res.writeHead(200, { 'Content-Type': 'text/plain' });
Expand Down Expand Up @@ -105,8 +105,8 @@ const example5 = async () => {

// transfer_transaction
const example6 = async () => {
const node_address = 'http://127.0.0.1:11101';
const sdk = new SDK(node_address);
const rpc_address = 'http://127.0.0.1:11101';
const sdk = new SDK(rpc_address);
const chain_name = 'casper-net-1';
const secret_key = `-----BEGIN PRIVATE KEY-----
MC4CAQAwBQYDK2VwBCIEII8ULlk1CJ12ZQ+bScjBt/IxMAZNggClWqK56D1/7CbI
Expand Down Expand Up @@ -164,8 +164,8 @@ const example7 = async () => {

// transaction
const example8 = async () => {
const node_address = 'http://127.0.0.1:11101';
const sdk = new SDK(node_address);
const rpc_address = 'http://127.0.0.1:11101';
const sdk = new SDK(rpc_address);
const chain_name = 'casper-net-1';
const secret_key = `-----BEGIN PRIVATE KEY-----
MC4CAQAwBQYDK2VwBCIEII8ULlk1CJ12ZQ+bScjBt/IxMAZNggClWqK56D1/7CbI
Expand All @@ -189,8 +189,8 @@ MC4CAQAwBQYDK2VwBCIEII8ULlk1CJ12ZQ+bScjBt/IxMAZNggClWqK56D1/7CbI

// put_transaction
const example9 = async () => {
const node_address = 'http://127.0.0.1:11101';
const sdk = new SDK(node_address);
const rpc_address = 'http://127.0.0.1:11101';
const sdk = new SDK(rpc_address);
const chain_name = 'casper-net-1';
const secret_key = `-----BEGIN PRIVATE KEY-----
MC4CAQAwBQYDK2VwBCIEII8ULlk1CJ12ZQ+bScjBt/IxMAZNggClWqK56D1/7CbI
Expand Down Expand Up @@ -218,8 +218,8 @@ MC4CAQAwBQYDK2VwBCIEII8ULlk1CJ12ZQ+bScjBt/IxMAZNggClWqK56D1/7CbI

// put_transaction transfer_transaction
const example10 = async () => {
const node_address = 'http://127.0.0.1:11101';
const sdk = new SDK(node_address);
const rpc_address = 'http://127.0.0.1:11101';
const sdk = new SDK(rpc_address);
const chain_name = 'casper-net-1';
const secret_key = `-----BEGIN PRIVATE KEY-----
MC4CAQAwBQYDK2VwBCIEII8ULlk1CJ12ZQ+bScjBt/IxMAZNggClWqK56D1/7CbI
Expand Down Expand Up @@ -249,9 +249,9 @@ MC4CAQAwBQYDK2VwBCIEII8ULlk1CJ12ZQ+bScjBt/IxMAZNggClWqK56D1/7CbI

// install
const example11 = async () => {
const node_address = 'http://127.0.0.1:11101';
const rpc_address = 'http://127.0.0.1:11101';
const events_address = 'http://127.0.0.1:18101/events';
const sdk = new SDK(node_address);
const sdk = new SDK(rpc_address);
const chain_name = 'casper-net-1';
const secret_key = `-----BEGIN PRIVATE KEY-----
MC4CAQAwBQYDK2VwBCIEII8ULlk1CJ12ZQ+bScjBt/IxMAZNggClWqK56D1/7CbI
Expand Down Expand Up @@ -304,9 +304,9 @@ MC4CAQAwBQYDK2VwBCIEII8ULlk1CJ12ZQ+bScjBt/IxMAZNggClWqK56D1/7CbI

// call_entrypoint
const example12 = async () => {
const node_address = 'http://127.0.0.1:11101';
const rpc_address = 'http://127.0.0.1:11101';
const events_address = 'http://127.0.0.1:18101/events';
const sdk = new SDK(node_address);
const sdk = new SDK(rpc_address);
const chain_name = 'casper-net-1';
const secret_key = `-----BEGIN PRIVATE KEY-----
MC4CAQAwBQYDK2VwBCIEII8ULlk1CJ12ZQ+bScjBt/IxMAZNggClWqK56D1/7CbI
Expand Down Expand Up @@ -466,8 +466,8 @@ const example5_legacy = async () => {

// transfer
const example6_legacy = async () => {
const node_address = 'http://127.0.0.1:11101';
const sdk = new SDK(node_address);
const rpc_address = 'http://127.0.0.1:11101';
const sdk = new SDK(rpc_address);
const chain_name = 'casper-net-1';
const secret_key = `-----BEGIN PRIVATE KEY-----
MC4CAQAwBQYDK2VwBCIEII8ULlk1CJ12ZQ+bScjBt/IxMAZNggClWqK56D1/7CbI
Expand Down Expand Up @@ -526,8 +526,8 @@ const example7_legacy = async () => {

// deploy
const example8_legacy = async () => {
const node_address = 'http://127.0.0.1:11101';
const sdk = new SDK(node_address);
const rpc_address = 'http://127.0.0.1:11101';
const sdk = new SDK(rpc_address);
const chain_name = 'casper-net-1';
const secret_key = `-----BEGIN PRIVATE KEY-----
MC4CAQAwBQYDK2VwBCIEII8ULlk1CJ12ZQ+bScjBt/IxMAZNggClWqK56D1/7CbI
Expand All @@ -552,8 +552,8 @@ MC4CAQAwBQYDK2VwBCIEII8ULlk1CJ12ZQ+bScjBt/IxMAZNggClWqK56D1/7CbI

// put_deploy
const example9_legacy = async () => {
const node_address = 'http://127.0.0.1:11101';
const sdk = new SDK(node_address);
const rpc_address = 'http://127.0.0.1:11101';
const sdk = new SDK(rpc_address);
const chain_name = 'casper-net-1';
const secret_key = `-----BEGIN PRIVATE KEY-----
MC4CAQAwBQYDK2VwBCIEII8ULlk1CJ12ZQ+bScjBt/IxMAZNggClWqK56D1/7CbI
Expand Down Expand Up @@ -585,8 +585,8 @@ MC4CAQAwBQYDK2VwBCIEII8ULlk1CJ12ZQ+bScjBt/IxMAZNggClWqK56D1/7CbI

// put_deploy transfer
const example10_legacy = async () => {
const node_address = 'http://127.0.0.1:11101';
const sdk = new SDK(node_address);
const rpc_address = 'http://127.0.0.1:11101';
const sdk = new SDK(rpc_address);
const chain_name = 'casper-net-1';
const secret_key = `-----BEGIN PRIVATE KEY-----
MC4CAQAwBQYDK2VwBCIEII8ULlk1CJ12ZQ+bScjBt/IxMAZNggClWqK56D1/7CbI
Expand Down Expand Up @@ -616,9 +616,9 @@ MC4CAQAwBQYDK2VwBCIEII8ULlk1CJ12ZQ+bScjBt/IxMAZNggClWqK56D1/7CbI

// install_deploy
const example11_legacy = async () => {
const node_address = 'http://127.0.0.1:11101';
const rpc_address = 'http://127.0.0.1:11101';
const events_address = 'http://127.0.0.1:18101/events';
const sdk = new SDK(node_address);
const sdk = new SDK(rpc_address);
const chain_name = 'casper-net-1';
const secret_key = `-----BEGIN PRIVATE KEY-----
MC4CAQAwBQYDK2VwBCIEII8ULlk1CJ12ZQ+bScjBt/IxMAZNggClWqK56D1/7CbI
Expand Down Expand Up @@ -676,9 +676,9 @@ MC4CAQAwBQYDK2VwBCIEII8ULlk1CJ12ZQ+bScjBt/IxMAZNggClWqK56D1/7CbI

// call_entrypoint_deploy
const example12_legacy = async () => {
const node_address = 'http://127.0.0.1:11101';
const rpc_address = 'http://127.0.0.1:11101';
const events_address = 'http://127.0.0.1:18101/events';
const sdk = new SDK(node_address);
const sdk = new SDK(rpc_address);
const chain_name = 'casper-net-1';
const secret_key = `-----BEGIN PRIVATE KEY-----
MC4CAQAwBQYDK2VwBCIEII8ULlk1CJ12ZQ+bScjBt/IxMAZNggClWqK56D1/7CbI
Expand Down
6 changes: 3 additions & 3 deletions examples/frontend/angular/build-proxy-conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ dotenv.config({ path: '../../../.env' });

const templatePath = './proxy.conf.template.json';
const outputPath = './proxy.conf.json';
const node_address = process.env.NODE_ADDRESS || 'http://localhost:11101';
const rpc_address = process.env.RPC_ADDRESS || 'http://localhost:11101';

const template = fs.readFileSync(templatePath, 'utf-8');
const config = template.replace(
/\$\{NODE_ADDRESS\}/g,
node_address.replace(/\/rpc$/, ''),
/\$\{RPC_ADDRESS\}/g,
rpc_address.replace(/\/rpc$/, ''),
);

fs.writeFileSync(outputPath, config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
>
<span
class="badge rounded-pill bg-success mb-2 ellipsis-container px-2 me-xl-3"
e2e-id="node_address"
[hidden]="!node_address"
>{{ node_address }}</span
e2e-id="rpc_address"
[hidden]="!rpc_address"
>{{ rpc_address }}</span
>
</div>
<div class="col-12 col-md-6 col-lg-5">
Expand All @@ -37,16 +37,16 @@
<optgroup label="default">
<option
[value]="network?.name"
[selected]="network.node_address === node_address"
[selected]="network.rpc_address === rpc_address"
*ngFor="let network of networks; index as i"
>
{{ network?.name }} ({{ network.node_address }})
{{ network?.name }} ({{ network.rpc_address }})
</option>
</optgroup>
<optgroup label="fetched" *ngIf="peers">
<option
[value]="changePort(peer)"
[selected]="changePort(peer) === node_address"
[selected]="changePort(peer) === rpc_address"
*ngFor="let peer of peers; index as i"
>
{{ changePort(peer) }} ({{ chain_name }})
Expand All @@ -67,7 +67,7 @@
type="search"
class="form-control form-control-xs"
name="customNetwork"
[value]="node_address || ''"
[value]="rpc_address || ''"
(change)="onCustomNetworkChange($event)"
id="customNetworkElt"
#publicKeyElt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class HeaderComponent implements AfterViewInit {
networks: Network[] = this.config['networks'] as Network[];
network: Network = this.config['network'] as Network;
chain_name: string = this.network.chain_name;
node_address: string = this.network.node_address;
rpc_address: string = this.network.rpc_address;
customNetwork!: string;

private window!: (Window & typeof globalThis) | null;
Expand All @@ -45,15 +45,15 @@ export class HeaderComponent implements AfterViewInit {
}

async ngAfterViewInit() {
if (this.storageService.get('chain_name') && this.storageService.get('node_address')) {
if (this.storageService.get('chain_name') && this.storageService.get('rpc_address')) {
this.chain_name = this.storageService.get('chain_name') || this.chain_name;
this.node_address = this.storageService.get('node_address') || this.node_address;
this.network = this.networks.find(x => x.node_address == this.node_address) || this.network;
this.rpc_address = this.storageService.get('rpc_address') || this.rpc_address;
this.network = this.networks.find(x => x.rpc_address == this.rpc_address) || this.network;
}

this.stateService.setState({
chain_name: this.chain_name,
node_address: this.node_address,
rpc_address: this.rpc_address,
});
this.setNodeAddress();
this.changeDetectorRef.markForCheck();
Expand All @@ -64,13 +64,13 @@ export class HeaderComponent implements AfterViewInit {
network = network && this.networks.find(x => x.name == network);
this.network = network;
this.chain_name = network.chain_name;
this.node_address = network.node_address;
this.rpc_address = network.rpc_address;
this.setNodeAddress();
this.stateService.setState({
chain_name: network.chain_name
});
this.storageService.setState({
node_address: this.node_address,
rpc_address: this.rpc_address,
chain_name: this.chain_name
});
}
Expand All @@ -82,16 +82,16 @@ export class HeaderComponent implements AfterViewInit {
}

onCustomNetworkChange($event: Event) {
this.node_address = ($event.target as HTMLInputElement)?.value || this.network.node_address;
this.rpc_address = ($event.target as HTMLInputElement)?.value || this.network.rpc_address;
const customNetwork = this.networks.find(network => network.name === 'custom');
if (customNetwork) {
customNetwork.node_address = this.node_address;
this.sdk.setNodeAddress(this.node_address);
customNetwork.rpc_address = this.rpc_address;
this.sdk.setNodeAddress(this.rpc_address);
this.stateService.setState({
node_address: this.node_address
rpc_address: this.rpc_address
});
this.storageService.setState({
node_address: this.node_address
rpc_address: this.rpc_address
});
}
}
Expand Down Expand Up @@ -124,11 +124,11 @@ export class HeaderComponent implements AfterViewInit {

private setNodeAddress() {
if ((this.is_electron)) {
this.sdk.setNodeAddress(this.node_address);
this.sdk.setNodeAddress(this.rpc_address);
} else {
const network = this.networks.find(x => x.node_address == this.node_address);
const network = this.networks.find(x => x.rpc_address == this.rpc_address);
if (this.is_production && !this.localhost_to_gateway && network && ['ntcl', 'node-launcher'].includes(network?.name)) {
this.sdk.setNodeAddress(this.node_address);
this.sdk.setNodeAddress(this.rpc_address);
} else {
network && this.sdk.setNodeAddress([this.window?.location?.href, network?.name].join(''));
}
Expand Down
14 changes: 7 additions & 7 deletions examples/frontend/angular/libs/util/config/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,37 +21,37 @@ export const config: EnvironmentConfig = {
action_needs_public_key,
networks: {
'node-launcher': {
node_address: 'http://localhost:7777',
rpc_address: 'http://localhost:7777',
stream_address: 'http://localhost:9999/events/main',
chain_name: 'casper-net-1'
},
'ntcl': {
node_address: 'http://localhost:11101',
rpc_address: 'http://localhost:11101',
stream_address: 'http://localhost:18101/events/main',
chain_name: 'casper-net-1'
},
'integration': {
node_address: 'https://rpc.integration.casperlabs.io',
rpc_address: 'https://rpc.integration.casperlabs.io',
stream_address: 'https://events.integration.casperlabs.io/events/main',
chain_name: 'integration-test'
},
'testnet': {
node_address: 'https://rpc.testnet.casperlabs.io',
rpc_address: 'https://rpc.testnet.casperlabs.io',
stream_address: 'https://events.testnet.casperlabs.io/events/main',
chain_name: 'casper-test'
},
'mainnet': {
node_address: 'https://rpc.mainnet.casperlabs.io',
rpc_address: 'https://rpc.mainnet.casperlabs.io',
stream_address: 'https://events.mainnet.casperlabs.io/events/main',
chain_name: 'casper'
},
'custom': {
node_address: 'http://3.136.227.9:7777',
rpc_address: 'http://3.136.227.9:7777',
stream_address: 'http://3.136.227.9:9999/events/main',
chain_name: 'casper-test'
},
'dev': {
node_address: 'http://localhost:4200',
rpc_address: 'http://localhost:4200',
stream_address: 'http://localhost:4200/events/main',
chain_name: 'casper-net-1'
},
Expand Down
2 changes: 1 addition & 1 deletion examples/frontend/angular/libs/util/config/src/network.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export type Network = {
name: string;
node_address: string;
rpc_address: string;
chain_name: string;
};
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Verbosity } from "casper-sdk";

export type State = {
node_address?: string;
rpc_address?: string;
chain_name?: string;
account_hash?: string;
enity?: string;
Expand Down
Loading

0 comments on commit 7641e6b

Please sign in to comment.