ChainMovers / suibase

Sui development environment and cookbook.
https://suibase.io
Apache License 2.0
35 stars 6 forks source link

Addition of RPC/WS URL to Rust SDK Helper #21

Closed mario4tier closed 1 year ago

mario4tier commented 1 year ago

RPC link information for every workdir will be provided by a .state/links JSON file.

The file provides:

Implementation details: The file can change at anytime (using a safe atomic filesystem mv, not a risky in-place file/inode modifications). From a helper perspective, you just open/read/close the file, use the primary and secondary recommendation. Re-open the file again for a new set of recommendation.

mario4tier commented 1 year ago

Feature is work-in-progress, but already by default the Rust sui-base helper provides URL that are same as the default Mysten client.yaml.

There are two files. One is the user configuration (sui-base.yaml) and the other is .state/links which is controlled by sui-base (for now the scripts, later a background "link health monitoring" process).

Example of user configuration sui-base.yaml

links:
  - alias: "sui.io"
    rpc: "https://fullnode.testnet.sui.io:443"
    ws: "wss://fullnode.testnet.sui.io:443"
  - alias: "vincagame.com"
    rpc: "https://fullnode.testnet.vincagame.com:443"
    ws: "wss://fullnode.testnet.vincagame.com:443"

Example of .state/links

{
"selection": { "primary": 0, "secondary": 1, "n_links": 2 },
"links": [
    {
      "id": 0,
      "alias": "sui.io",
      "rpc": "https://fullnode.devnet.sui.io:443",
      "ws": "wss://fullnode.devnet.sui.io:443"
    },
    {
      "id": 1,
      "alias": "vincagame.com",
      "rpc": "https://fullnode.devnet.vincagame.com:443",
      "ws": "wss://fullnode.devnet.vincagame.com:443"
    }
  ]
}