Skip to content
This repository has been archived by the owner on May 8, 2023. It is now read-only.

Commit

Permalink
Adjust to new Colony RPC endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
chmanie committed Dec 22, 2022
1 parent 75bf7b5 commit 354832f
Show file tree
Hide file tree
Showing 14 changed files with 93 additions and 21 deletions.
1 change: 1 addition & 0 deletions docs/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

- [ColonyLabelSuffix](enums/ColonyLabelSuffix.md)
- [ColonyRole](enums/ColonyRole.md)
- [ColonyRpcEndpoint](enums/ColonyRpcEndpoint.md)
- [Extension](enums/Extension.md)
- [Id](enums/Id.md)
- [MetaTxBroadCasterEndpoint](enums/MetaTxBroadCasterEndpoint.md)
Expand Down
2 changes: 1 addition & 1 deletion docs/api/classes/ColonyNetwork.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ import { providers } from 'ethers';
import { ColonyNetwork, Tokens } from '@colony/sdk';

// Connect directly to the deployed Colony Network on Gnosis Chain
const provider = new providers.JsonRpcProvider('https://xdai.colony.io/rpc2/');
const provider = new providers.JsonRpcProvider('https://xdai.colony.io/rpc/');
// Immediately executing async function
(async function() {
const colonyNetwork = await ColonyNetwork.init(provider);
Expand Down
49 changes: 49 additions & 0 deletions docs/api/enums/ColonyRpcEndpoint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Enumeration: ColonyRpcEndpoint

## Enumeration Members

### Custom

**Custom** = ``""``

Colony's own RPC2 endpoint for a custom network

___

### Gnosis

**Gnosis** = ``"https://xdai.colony.io/rpc/"``

Colony's own RPC2 endpoint for Gnosis chain

___

### Goerli

**Goerli** = ``""``

Colony's own RPC2 endpoint for Goerli testnet

___

### Mainnet

**Mainnet** = ``""``

Colony's own RPC2 endpoint for Mainnet

___

### Xdai

**Xdai** = ``"https://xdai.colony.io/rpc/"``

Colony's own RPC2 endpoint for Gnosis chain (alias)

___

### XdaiQa

**XdaiQa** = ``"https://xdai.colony.io/rpc/"``

Colony's own RPC2 endpoint for Gnosis chain (QA environment)
6 changes: 3 additions & 3 deletions docs/api/enums/MetaTxBroadCasterEndpoint.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ___

**Gnosis** = ``"https://xdai.colony.io/metatransaction/xdai"``

The metatransaction broadcaster endpointon Gnosis chain
The metatransaction broadcaster endpoint on Gnosis Chain

___

Expand All @@ -38,12 +38,12 @@ ___

**Xdai** = ``"https://xdai.colony.io/metatransaction/xdai"``

The metatransaction broadcaster endpointon Gnosis chain (alias)
The metatransaction broadcaster endpoint on Gnosis Chain (alias)

___

### XdaiQa

**XdaiQa** = ``"https://xdai.colony.io/metatransaction/xdai"``

The metatransaction broadcaster endpointaddress on Gnosis chain
The metatransaction broadcaster endpoint on Gnosis Chain (QA environment)
2 changes: 1 addition & 1 deletion docs/getting-started/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Include the resulting bundle in an HTML file and open it in you favorite browser
const { providers, Wallet } = require('ethers');
const { ColonyNetwork } = require('@colony/sdk');

const provider = new providers.JsonRpcProvider('https://xdai.colony.io/rpc2/');
const provider = new providers.JsonRpcProvider('https://xdai.colony.io/rpc/');
const wallet = Wallet.createRandom().connect(provider);

// Get the Colony's XDAI funding in the ROOT pot (id 1)
Expand Down
4 changes: 2 additions & 2 deletions examples/browser/src/basic.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { providers, utils } from 'ethers';

import { ColonyNetwork, Tokens } from '../../../src';
import { ColonyNetwork, ColonyRpcEndpoint, Tokens } from '../../../src';

const { formatEther, isAddress } = utils;

const provider = new providers.JsonRpcProvider('https://xdai.colony.io/rpc2/');
const provider = new providers.JsonRpcProvider(ColonyRpcEndpoint.Gnosis);

// Get the Colony's CLNY funding in the root domain (on Gnosis chain)
const getColonyFunding = async (colonyAddress: string) => {
Expand Down
8 changes: 6 additions & 2 deletions examples/browser/src/events.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { providers, utils } from 'ethers';

import { ColonyEventManager, MetadataType } from '../../../src';
import {
ColonyEventManager,
ColonyRpcEndpoint,
MetadataType,
} from '../../../src';
import type { ColonyEvent } from '../../../src';

const provider = new providers.JsonRpcProvider('https://xdai.colony.io/rpc2/');
const provider = new providers.JsonRpcProvider(ColonyRpcEndpoint.Gnosis);
const { isAddress } = utils;

// This event listener will only list for the `DomainAdded` event in the Colony of the user's choice. Run this and then create a Team in that Colony, to see it being picked up here
Expand Down
4 changes: 3 additions & 1 deletion examples/browser/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { ColonyRpcEndpoint } from '../../../src';

const addColonyRPC = () => {
// If MetaMask is installed there will be an `ethereum` object on the `window`
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand All @@ -12,7 +14,7 @@ const addColonyRPC = () => {
symbol: 'XDAI',
decimals: 18,
},
rpcUrls: ['https://xdai.colony.io/rpc2/'],
rpcUrls: [ColonyRpcEndpoint.Gnosis],
blockExplorerUrls: ['https://blockscout.com/xdai/mainnet'],
},
],
Expand Down
4 changes: 2 additions & 2 deletions examples/node/automation.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { providers, Wallet } from 'ethers';

import { ColonyNetwork, w } from '../../src';
import { ColonyNetwork, ColonyRpcEndpoint, w } from '../../src';

const provider = new providers.JsonRpcProvider('https://xdai.colony.io/rpc2/');
const provider = new providers.JsonRpcProvider(ColonyRpcEndpoint.Gnosis);

const start = async () => {
// Create a new wallet from a private key. This key is stored in an environment variable called `PRIATE_KEY`
Expand Down
4 changes: 2 additions & 2 deletions examples/node/basic.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { providers } from 'ethers';

import { ColonyNetwork, toEth } from '../../src';
import { ColonyNetwork, ColonyRpcEndpoint, toEth } from '../../src';

const provider = new providers.JsonRpcProvider('https://xdai.colony.io/rpc2/');
const provider = new providers.JsonRpcProvider(ColonyRpcEndpoint.Gnosis);

// Get the Colony's CLNY funding in the ROOT team (id 1)
const start = async () => {
Expand Down
3 changes: 2 additions & 1 deletion examples/node/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import { providers, Wallet } from 'ethers';
import {
ColonyNetwork,
ColonyRole,
ColonyRpcEndpoint,
ColonyToken,
SupportedExtension,
} from '../../src';

const provider = new providers.JsonRpcProvider('https://xdai.colony.io/rpc2/');
const provider = new providers.JsonRpcProvider(ColonyRpcEndpoint.Gnosis);

// Deploy a Colony with everything that's needed
const start = async () => {
Expand Down
4 changes: 2 additions & 2 deletions examples/node/metatx.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { constants, providers, Wallet } from 'ethers';

import { ColonyNetwork } from '../../src';
import { ColonyNetwork, ColonyRpcEndpoint } from '../../src';

const provider = new providers.JsonRpcProvider('https://xdai.colony.io/rpc2/');
const provider = new providers.JsonRpcProvider(ColonyRpcEndpoint.Gnosis);

// Claim ETH for the MetaColony using a Metatransaction
const start = async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/ColonyNetwork/ColonyNetwork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export class ColonyNetwork {
* import { ColonyNetwork, Tokens } from '@colony/sdk';
*
* // Connect directly to the deployed Colony Network on Gnosis Chain
* const provider = new providers.JsonRpcProvider('https://xdai.colony.io/rpc2/');
* const provider = new providers.JsonRpcProvider('https://xdai.colony.io/rpc/');
* // Immediately executing async function
* (async function() {
* const colonyNetwork = await ColonyNetwork.init(provider);
Expand Down
21 changes: 18 additions & 3 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,31 @@ export enum MetaTxBroadCasterEndpoint {
Mainnet = '',
/** The metatransaction broadcaster endpoint on the Görli testnet */
Goerli = '',
/** The metatransaction broadcaster endpointon Gnosis chain */
/** The metatransaction broadcaster endpoint on Gnosis Chain */
Gnosis = 'https://xdai.colony.io/metatransaction/xdai',
/** The metatransaction broadcaster endpointon Gnosis chain (alias) */
/** The metatransaction broadcaster endpoint on Gnosis Chain (alias) */
Xdai = 'https://xdai.colony.io/metatransaction/xdai',
/** The metatransaction broadcaster endpointaddress on Gnosis chain */
/** The metatransaction broadcaster endpoint on Gnosis Chain (QA environment) */
XdaiQa = 'https://xdai.colony.io/metatransaction/xdai',
/** The metatransaction broadcaster endpoint for a custom network */
Custom = '',
}

export enum ColonyRpcEndpoint {
/** Colony's own RPC2 endpoint for Mainnet */
Mainnet = '',
/** Colony's own RPC2 endpoint for Goerli testnet */
Goerli = '',
/** Colony's own RPC2 endpoint for Gnosis chain */
Gnosis = 'https://xdai.colony.io/rpc/',
/** Colony's own RPC2 endpoint for Gnosis chain (alias) */
Xdai = 'https://xdai.colony.io/rpc/',
/** Colony's own RPC2 endpoint for Gnosis chain (QA environment) */
XdaiQa = 'https://xdai.colony.io/rpc/',
/** Colony's own RPC2 endpoint for a custom network */
Custom = '',
}

// TODO: Consider moving this to the metadata-parser
export enum TeamColor {
LightPink,
Expand Down

0 comments on commit 354832f

Please sign in to comment.