Skip to content

Commit

Permalink
Merge pull request #490 from warp-contracts/szynek/seq-test-net
Browse files Browse the repository at this point in the history
SeqTestnet with decentralized sequencer
  • Loading branch information
szynwelski authored Dec 11, 2023
2 parents 672c620 + 0f0aaa0 commit a4342a6
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ interface ExampleContractState {
counter: number;
}

// FIXME: change to the address of the sequencer on dev
const DECENTRALIZED_SEQUENCER_URL = 'http://sequencer-0.warp.cc:1317';
const GW_URL = 'http://34.141.17.15:5666/';
const DECENTRALIZED_SEQUENCER_URLS = ['http://sequencer-0.testnet.warp.cc:1317',
'http://sequencer-1.testnet.warp.cc:1317',
'http://sequencer-2.testnet.warp.cc:1317'];
const GW_URL = 'http://35.242.203.146:5666/';

describe('Testing sending of interactions to a decentralized sequencer', () => {
let contractSrc: string;
Expand All @@ -42,13 +43,13 @@ describe('Testing sending of interactions to a decentralized sequencer', () => {
if (req.url === '/gateway/sequencer/address') {
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({
url: centralizedSequencerType ? mockGwUrl : DECENTRALIZED_SEQUENCER_URL,
urls: centralizedSequencerType ? [mockGwUrl] : DECENTRALIZED_SEQUENCER_URLS,
type: centralizedSequencerType ? 'centralized' : 'decentralized'
}));
return;
} else if (req.url === '/gateway/v2/sequencer/register') {
centralizedSequencerType = false;
res.writeHead(301, { Location: DECENTRALIZED_SEQUENCER_URL });
res.writeHead(301, { Location: DECENTRALIZED_SEQUENCER_URLS[0] });
res.end();
return;
} else if (req.url?.startsWith('/gateway/interactions/')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ import { WarpFetchWrapper } from '../../../core/WarpFetchWrapper';
import { Signature } from '../../../contract/Signature';
import { SequencerClient } from '../../../contract/sequencer/SequencerClient';

// FIXME: change to the address of the sequencer on dev
const SEQUENCER_URL = 'http://sequencer-0.warp.cc:1317';
const GW_URL = 'http://34.141.17.15:5666/';
const SEQUENCER_URL = 'http://sequencer-0.testnet.warp.cc:1317';
const GW_URL = 'https://gw-testnet.warp.cc';

describe('Testing a decentralized sequencer client', () => {

Expand Down
2 changes: 1 addition & 1 deletion src/core/Warp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { SourceData } from '../contract/deploy/Source';
import { Signer, DataItem } from 'warp-arbundles';
import { BasicSortKeyCache } from '../cache/BasicSortKeyCache';

export type WarpEnvironment = 'local' | 'testnet' | 'mainnet' | 'custom';
export type WarpEnvironment = 'local' | 'testnet' | 'seqtestnet' | 'mainnet' | 'custom';
export type KVStorageFactory = (contractTxId: string) => SortKeyCache<unknown>;

/**
Expand Down
27 changes: 26 additions & 1 deletion src/core/WarpFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,15 @@ export const defaultWarpGwOptions: GatewayOptions = {
};

/**
* @Deprecated - will be removed soon, left for backwards compatibility with deploy plugin
* Default Warp Gateway URL
*/
export const WARP_GW_URL = 'https://gw.warp.cc';

/**
* The URL of the Warp Gateway that works with a test network of decentralized sequencers
*/
export const WARP_GW_TESTNET_URL = 'https://gw-testnet.warp.cc';

export const DEFAULT_LEVEL_DB_LOCATION = './cache/warp';

export const defaultCacheOptions: CacheOptions = {
Expand Down Expand Up @@ -82,6 +87,26 @@ export class WarpFactory {
}
}

/**
* creates a Warp instance suitable for testing the decentralized Warp Sequencer
* (https://github.com/warp-contracts/sequencer)
*/
static forSeqTestnet(
cacheOptions = defaultCacheOptions,
useArweaveGw = false,
arweave = Arweave.init({
host: 'arweave.net',
port: 443,
protocol: 'https'
})
): Warp {
if (useArweaveGw) {
return this.customArweaveGw(arweave, cacheOptions, 'seqtestnet');
} else {
return this.customWarpGw(arweave, defaultWarpGwOptions, cacheOptions, 'seqtestnet').useGwUrl(WARP_GW_TESTNET_URL);
}
}

/**
* creates a Warp instance suitable for use with mainnet.
* By default, the Warp gateway (https://github.com/warp-contracts/gateway#warp-gateway)
Expand Down

0 comments on commit a4342a6

Please sign in to comment.