redstone to warp renaming hell

This commit is contained in:
asiaziola
2022-05-19 17:15:16 +02:00
parent d552a6c13e
commit e0556562d4
27 changed files with 102 additions and 112 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "redstone-smartweave",
"version": "0.5.11",
"name": "warp",
"version": "1.0.0",
"description": "An implementation of the SmartWeave smart contract protocol.",
"main": "./lib/cjs/index.js",
"module": "./lib/esm/index.js",

View File

@@ -1,9 +1,9 @@
/* eslint-disable */
import fs from 'fs';
import path from 'path';
import { interactRead, readContract } from 'warp';
import { interactRead, readContract } from 'smartweave';
import Arweave from 'arweave';
import { LoggerFactory, SmartWeaveNodeFactory, SmartWeaveWebFactory, SourceType } from '@warp';
import { LoggerFactory, WarpNodeFactory, WarpWebFactory, SourceType } from '@warp';
const stringify = require('safe-stable-stringify');
@@ -50,8 +50,8 @@ describe.each(chunked)('v1 compare.suite %#', (contracts: string[]) => {
console.log('readState', contractTxId);
try {
console.log = function () {}; // to hide any logs from contracts...
const result2 = await SmartWeaveNodeFactory.memCachedBased(arweave, 1)
.useRedStoneGateway(null, SourceType.ARWEAVE)
const result2 = await WarpNodeFactory.memCachedBased(arweave, 1)
.useWarpGateway(null, SourceType.ARWEAVE)
.build()
.contract(contractTxId)
.setEvaluationOptions({
@@ -79,8 +79,8 @@ describe.each(chunkedVm)('v1 compare.suite (VM2) %#', (contracts: string[]) => {
.readFileSync(path.join(__dirname, 'test-cases', 'contracts', `${contractTxId}.json`), 'utf-8')
.trim();
console.log('readState', contractTxId);
const result2 = await SmartWeaveNodeFactory.memCachedBased(arweave, 1)
.useRedStoneGateway(null, SourceType.ARWEAVE)
const result2 = await WarpNodeFactory.memCachedBased(arweave, 1)
.useWarpGateway(null, SourceType.ARWEAVE)
.build()
.contract(contractTxId)
.setEvaluationOptions({
@@ -103,15 +103,13 @@ describe.each(chunkedGw)('gateways compare.suite %#', (contracts: string[]) => {
'.test %# %o',
async (contractTxId: string) => {
const blockHeight = 855134;
console.log('readState Redstone Gateway', contractTxId);
const warpR = SmartWeaveWebFactory.memCachedBased(arweave, 1)
.useRedStoneGateway(null, SourceType.ARWEAVE)
.build();
console.log('readState Warp Gateway', contractTxId);
const warpR = WarpWebFactory.memCachedBased(arweave, 1).useWarpGateway(null, SourceType.ARWEAVE).build();
const result = await warpR.contract(contractTxId).readState(blockHeight);
const resultString = stringify(result.state).trim();
console.log('readState Arweave Gateway', contractTxId);
const result2 = await SmartWeaveNodeFactory.memCachedBased(arweave, 1)
const result2 = await WarpNodeFactory.memCachedBased(arweave, 1)
.useArweaveGateway()
.build()
.contract(contractTxId)
@@ -130,8 +128,8 @@ describe('readState', () => {
const result = await readContract(arweave, contractTxId, blockHeight);
const resultString = stringify(result).trim();
const result2 = await SmartWeaveNodeFactory.memCachedBased(arweave, 1)
.useRedStoneGateway(null, SourceType.ARWEAVE)
const result2 = await WarpNodeFactory.memCachedBased(arweave, 1)
.useWarpGateway(null, SourceType.ARWEAVE)
.build()
.contract(contractTxId)
.setEvaluationOptions({
@@ -151,8 +149,8 @@ describe('readState', () => {
target: '6Z-ifqgVi1jOwMvSNwKWs6ewUEQ0gU9eo4aHYC3rN1M'
});
const v2Result = await SmartWeaveNodeFactory.memCachedBased(arweave, 1)
.useRedStoneGateway(null, SourceType.ARWEAVE)
const v2Result = await WarpNodeFactory.memCachedBased(arweave, 1)
.useWarpGateway(null, SourceType.ARWEAVE)
.build()
.contract(contractTxId)
.connect(jwk)

View File

@@ -1,4 +1,4 @@
import { LoggerFactory, RedstoneGatewayInteractionsLoader } from '@warp';
import { LoggerFactory, WarpGatewayInteractionsLoader } from '@warp';
import { GQLEdgeInterface } from '../../legacy/gqlResult';
const responseData = {
@@ -86,20 +86,20 @@ const fetchMock = jest
() => Promise.resolve({ json: () => Promise.resolve(responseData), ok: true, status: 200 }) as Promise<Response>
);
describe('RedstoneGatewayInteractionsLoader -> load', () => {
describe('WarpGatewayInteractionsLoader -> load', () => {
it('should be called with baseUrl devoid of trailing slashes', async () => {
const loader = new RedstoneGatewayInteractionsLoader('http://baseUrl/');
const loader = new WarpGatewayInteractionsLoader('http://baseUrl/');
expect(loader['baseUrl']).toBe('http://baseUrl');
});
it('should return correct number of interactions', async () => {
const loader = new RedstoneGatewayInteractionsLoader('http://baseUrl');
const loader = new WarpGatewayInteractionsLoader('http://baseUrl');
const response: GQLEdgeInterface[] = await loader.load(contractId, fromBlockHeight, toBlockHeight);
expect(fetchMock).toHaveBeenCalled();
expect(response.length).toEqual(2);
});
it('should be called with correct params', async () => {
const loader = new RedstoneGatewayInteractionsLoader('http://baseUrl');
const loader = new WarpGatewayInteractionsLoader('http://baseUrl');
await loader.load(contractId, fromBlockHeight, toBlockHeight);
expect(fetchMock).toBeCalledWith(`${baseUrl}&page=1&minimize=true`);
});
@@ -112,7 +112,7 @@ describe('RedstoneGatewayInteractionsLoader -> load', () => {
status: 200
}) as Promise<Response>
);
const loader = new RedstoneGatewayInteractionsLoader('http://baseUrl');
const loader = new WarpGatewayInteractionsLoader('http://baseUrl');
await loader.load(contractId, fromBlockHeight, toBlockHeight);
expect(fetchMock).toBeCalledWith(`${baseUrl}&page=1&minimize=true`);
expect(fetchMock).toBeCalledWith(`${baseUrl}&page=2&minimize=true`);
@@ -122,33 +122,33 @@ describe('RedstoneGatewayInteractionsLoader -> load', () => {
expect(fetchMock).toHaveBeenCalledTimes(5);
});
it('should be called with confirmationStatus set to "confirmed"', async () => {
const loader = new RedstoneGatewayInteractionsLoader('http://baseUrl', { confirmed: true });
const loader = new WarpGatewayInteractionsLoader('http://baseUrl', { confirmed: true });
await loader.load(contractId, fromBlockHeight, toBlockHeight);
expect(fetchMock).toBeCalledWith(`${baseUrl}&page=1&minimize=true&confirmationStatus=confirmed`);
});
it('should be called with confirmationStatus set to "not_corrupted"', async () => {
const loader = new RedstoneGatewayInteractionsLoader('http://baseUrl', { notCorrupted: true });
const loader = new WarpGatewayInteractionsLoader('http://baseUrl', { notCorrupted: true });
await loader.load(contractId, fromBlockHeight, toBlockHeight);
expect(fetchMock).toBeCalledWith(`${baseUrl}&page=1&minimize=true&confirmationStatus=not_corrupted`);
});
it('should throw an error in case of timeout', async () => {
jest.spyOn(global, 'fetch').mockImplementation(() => Promise.reject({ status: 504, ok: false }));
const loader = new RedstoneGatewayInteractionsLoader('http://baseUrl');
const loader = new WarpGatewayInteractionsLoader('http://baseUrl');
try {
await loader.load(contractId, fromBlockHeight, toBlockHeight);
} catch (e) {
expect(e).toEqual(new Error('Unable to retrieve transactions. Redstone gateway responded with status 504.'));
expect(e).toEqual(new Error('Unable to retrieve transactions. Warp gateway responded with status 504.'));
}
});
it('should throw an error when request fails', async () => {
jest
.spyOn(global, 'fetch')
.mockImplementation(() => Promise.reject({ status: 500, ok: false, body: { message: 'request fails' } }));
const loader = new RedstoneGatewayInteractionsLoader('http://baseUrl');
const loader = new WarpGatewayInteractionsLoader('http://baseUrl');
try {
await loader.load(contractId, fromBlockHeight, toBlockHeight);
} catch (e) {
expect(e).toEqual(new Error('Unable to retrieve transactions. Redstone gateway responded with status 500.'));
expect(e).toEqual(new Error('Unable to retrieve transactions. Warp gateway responded with status 500.'));
}
});
});

View File

@@ -158,8 +158,8 @@ export interface Contract<State = unknown> extends Source {
): Promise<string | null>;
/**
* Creates a new "interaction" transaction using RedStone Sequencer - this, with combination with
* RedStone Gateway, gives instant transaction availability and finality guaranteed by Bundlr.
* Creates a new "interaction" transaction using Warp Sequencer - this, with combination with
* Warp Gateway, gives instant transaction availability and finality guaranteed by Bundlr.
* @param input - new input to the contract that will be assigned with this interactions transaction
* @param options
*/

View File

@@ -405,14 +405,8 @@ export class HandlerBasedContract<State> implements Contract<State> {
forceDefinitionLoad = false,
upToTransactionId: string = undefined
): Promise<ExecutionContext<State, HandlerApi<State>>> {
const {
definitionLoader,
interactionsLoader,
interactionsSorter,
executorFactory,
stateEvaluator,
useRedstoneGwInfo
} = this.warp;
const { definitionLoader, interactionsLoader, interactionsSorter, executorFactory, stateEvaluator, useWarpGwInfo } =
this.warp;
let currentNetworkInfo;
@@ -425,9 +419,7 @@ export class HandlerBasedContract<State> implements Contract<State> {
};
} else {
this.logger.debug('Reading network info for root call');
currentNetworkInfo = useRedstoneGwInfo
? await this._arweaveWrapper.rGwInfo()
: await this._arweaveWrapper.info();
currentNetworkInfo = useWarpGwInfo ? await this._arweaveWrapper.rGwInfo() : await this._arweaveWrapper.info();
this._networkInfo = currentNetworkInfo;
}
} else {
@@ -494,7 +486,7 @@ export class HandlerBasedContract<State> implements Contract<State> {
}
}
const containsInteractionsFromSequencer = interactions.some((i) => i.node.source == SourceType.REDSTONE_SEQUENCER);
const containsInteractionsFromSequencer = interactions.some((i) => i.node.source == SourceType.WARP_SEQUENCER);
this.logger.debug('containsInteractionsFromSequencer', containsInteractionsFromSequencer);
return {
@@ -545,7 +537,7 @@ export class HandlerBasedContract<State> implements Contract<State> {
this.logger.debug('Creating execution context from tx:', benchmark.elapsed());
const containsInteractionsFromSequencer = interactions.some((i) => i.node.source == SourceType.REDSTONE_SEQUENCER);
const containsInteractionsFromSequencer = interactions.some((i) => i.node.source == SourceType.WARP_SEQUENCER);
return {
contractDefinition,

View File

@@ -101,7 +101,7 @@ export class SourceImpl implements Source {
srcTx.addTag(WarpTags.APP_NAME, 'SmartWeaveContractSource');
// TODO: version should be taken from the current package.json version.
srcTx.addTag(WarpTags.APP_VERSION, '0.3.0');
srcTx.addTag(WarpTags.SDK, 'RedStone');
srcTx.addTag(WarpTags.SDK, 'Warp');
srcTx.addTag(WarpTags.CONTENT_TYPE, contractType == 'js' ? 'application/javascript' : 'application/wasm');
if (contractType == 'wasm') {

View File

@@ -29,7 +29,7 @@ export class Warp {
readonly interactionsSorter: InteractionsSorter,
readonly executorFactory: ExecutorFactory<HandlerApi<unknown>>,
readonly stateEvaluator: StateEvaluator,
readonly useRedstoneGwInfo: boolean = false
readonly useWarpGwInfo: boolean = false
) {
this.createContract = new DefaultCreateContract(arweave);
}

View File

@@ -12,8 +12,8 @@ import {
InteractionsSorter,
MemBlockHeightSwCache,
MemCache,
RedstoneGatewayContractDefinitionLoader,
RedstoneGatewayInteractionsLoader,
WarpGatewayContractDefinitionLoader,
WarpGatewayInteractionsLoader,
Warp,
SourceType,
StateEvaluator
@@ -27,7 +27,7 @@ export class WarpBuilder {
private _interactionsSorter?: InteractionsSorter;
private _executorFactory?: ExecutorFactory<HandlerApi<unknown>>;
private _stateEvaluator?: StateEvaluator;
private _useRedstoneGwInfo = false;
private _useWarpGwInfo = false;
constructor(private readonly _arweave: Arweave) {}
@@ -75,14 +75,14 @@ export class WarpBuilder {
return this.build();
}
public useRedStoneGateway(
public useWarpGateway(
confirmationStatus: ConfirmationStatus = null,
source: SourceType = null,
address = R_GW_URL
): WarpBuilder {
this._interactionsLoader = new RedstoneGatewayInteractionsLoader(address, confirmationStatus, source);
this._definitionLoader = new RedstoneGatewayContractDefinitionLoader(address, this._arweave, new MemCache());
this._useRedstoneGwInfo = true;
this._interactionsLoader = new WarpGatewayInteractionsLoader(address, confirmationStatus, source);
this._definitionLoader = new WarpGatewayContractDefinitionLoader(address, this._arweave, new MemCache());
this._useWarpGwInfo = true;
return this;
}
@@ -92,12 +92,12 @@ export class WarpBuilder {
new ArweaveGatewayInteractionsLoader(this._arweave),
new MemBlockHeightSwCache(1)
);
this._useRedstoneGwInfo = false;
this._useWarpGwInfo = false;
return this;
}
public useRedStoneGwInfo(): WarpBuilder {
this._useRedstoneGwInfo = true;
public useWarpGwInfo(): WarpBuilder {
this._useWarpGwInfo = true;
return this;
}
@@ -109,7 +109,7 @@ export class WarpBuilder {
this._interactionsSorter,
this._executorFactory,
this._stateEvaluator,
this._useRedstoneGwInfo
this._useWarpGwInfo
);
}
}

View File

@@ -6,9 +6,9 @@ export * from './modules/StateEvaluator';
export * from './modules/impl/BlockHeightInteractionsSorter';
export * from './modules/impl/ContractDefinitionLoader';
export * from './modules/impl/RedstoneGatewayContractDefinitionLoader';
export * from './modules/impl/WarpGatewayContractDefinitionLoader';
export * from './modules/impl/ArweaveGatewayInteractionsLoader';
export * from './modules/impl/RedstoneGatewayInteractionsLoader';
export * from './modules/impl/WarpGatewayInteractionsLoader';
export * from './modules/impl/DefaultStateEvaluator';
export * from './modules/impl/CacheableStateEvaluator';
export * from './modules/impl/HandlerExecutorFactory';

View File

@@ -68,7 +68,7 @@ export interface StateEvaluator {
flushCache(): Promise<void>;
/**
* allows to syncState with an external state source (like RedStone Distributed Execution Network)
* allows to syncState with an external state source (like Warp Distributed Execution Network)
*/
syncState(contractTxId: string, blockHeight: number, transactionId: string, state: any, validity: any): Promise<void>;
}
@@ -137,7 +137,7 @@ export interface EvaluationOptions {
// - quite often scenario in FCP)
// 2. after evaluating all the contract interactions.
// https://github.com/redstone-finance/redstone-smartcontracts/issues/53
// https://github.com/redstone-finance/warp/issues/53
updateCacheForEachInteraction: boolean;
// a new, experimental enhancement of the protocol that allows for interactWrites from

View File

@@ -9,13 +9,13 @@ import {
InteractionData,
InteractionResult,
LoggerFactory,
RedStoneLogger,
WarpLogger,
SmartWeaveGlobal,
timeout
} from '@warp';
export class ContractHandlerApi<State> implements HandlerApi<State> {
private readonly contractLogger: RedStoneLogger;
private readonly contractLogger: WarpLogger;
private readonly logger = LoggerFactory.INST.create('ContractHandlerApi');
constructor(

View File

@@ -147,7 +147,7 @@ export abstract class DefaultStateEvaluator implements StateEvaluator {
const toCache = new EvalStateResult(currentState, validity);
// TODO: probably a separate hook should be created here
// to fix https://github.com/redstone-finance/redstone-smartcontracts/issues/109
// to fix https://github.com/redstone-finance/warp/issues/109
await this.onStateUpdate<State>(interactionTx, executionContext, toCache);
if (canBeCached(interactionTx)) {
lastConfirmedTxState = {

View File

@@ -23,8 +23,8 @@ export class LexicographicalInteractionsSorter implements InteractionsSorter {
private async addSortKey(txInfo: GQLEdgeInterface) {
const { node } = txInfo;
// might have been already set by the RedStone Sequencer
if (txInfo.node.sortKey !== undefined && txInfo.node.source == SourceType.REDSTONE_SEQUENCER) {
// might have been already set by the Warp Sequencer
if (txInfo.node.sortKey !== undefined && txInfo.node.source == SourceType.WARP_SEQUENCER) {
this.logger.debug('Using sortkey from sequencer', txInfo.node.sortKey);
txInfo.sortKey = txInfo.node.sortKey;
} else {

View File

@@ -7,14 +7,14 @@ import Transaction from 'arweave/node/lib/transaction';
/**
* An extension to {@link ContractDefinitionLoader} that makes use of
* Redstone Gateway ({@link https://github.com/redstone-finance/redstone-sw-gateway})
* Warp Gateway ({@link https://github.com/redstone-finance/warp-gateway})
* to load Contract Data.
*
* If the contract data is not available on RedStone Gateway - it fallbacks to default implementation
* If the contract data is not available on Warp Gateway - it fallbacks to default implementation
* in {@link ContractDefinitionLoader} - i.e. loads the definition from Arweave gateway.
*/
export class RedstoneGatewayContractDefinitionLoader extends ContractDefinitionLoader {
private readonly rLogger = LoggerFactory.INST.create('RedstoneGatewayContractDefinitionLoader');
export class WarpGatewayContractDefinitionLoader extends ContractDefinitionLoader {
private readonly rLogger = LoggerFactory.INST.create('WarpGatewayContractDefinitionLoader');
constructor(
private readonly baseUrl: string,
@@ -38,7 +38,7 @@ export class RedstoneGatewayContractDefinitionLoader extends ContractDefinitionL
this.rLogger.error(error.body.message);
}
throw new Error(
`Unable to retrieve contract data. Redstone gateway responded with status ${error.status}:${error.body?.message}`
`Unable to retrieve contract data. Warp gateway responded with status ${error.status}:${error.body?.message}`
);
});
if (result.srcBinary != null && !(result.srcBinary instanceof Buffer)) {

View File

@@ -24,7 +24,7 @@ interface Interaction {
interaction: GQLNodeInterface;
}
export interface RedstoneGatewayInteractions {
export interface WarpGatewayInteractions {
paging: Paging;
interactions: Interaction[];
message?: string;
@@ -42,12 +42,12 @@ export type ConfirmationStatus =
export const enum SourceType {
ARWEAVE = 'arweave',
REDSTONE_SEQUENCER = 'redstone-sequencer'
WARP_SEQUENCER = 'redstone-sequencer'
}
/**
* The aim of this implementation of the {@link InteractionsLoader} is to make use of
* Redstone Gateway ({@link https://github.com/redstone-finance/redstone-sw-gateway})
* Warp Gateway ({@link https://github.com/redstone-finance/redstone-sw-gateway})
* endpoint and retrieve contracts' interactions.
*
* Optionally - it is possible to pass:
@@ -60,13 +60,13 @@ export const enum SourceType {
*
* Passing no flag is the "backwards compatible" mode (ie. it will behave like the original Arweave GQL gateway endpoint).
* Note that this may result in returning corrupted and/or forked interactions
* - read more {@link https://github.com/redstone-finance/redstone-sw-gateway#corrupted-transactions}.
* - read more {@link https://github.com/redstone-finance/warp-gateway#corrupted-transactions}.
*
* Please note that currently caching (ie. {@link CacheableContractInteractionsLoader} is switched off
* for RedstoneGatewayInteractionsLoader due to the issue mentioned in the
* following comment {@link https://github.com/redstone-finance/redstone-smartcontracts/pull/62#issuecomment-995249264}
* for WarpGatewayInteractionsLoader due to the issue mentioned in the
* following comment {@link https://github.com/redstone-finance/warp/pull/62#issuecomment-995249264}
*/
export class RedstoneGatewayInteractionsLoader implements InteractionsLoader {
export class WarpGatewayInteractionsLoader implements InteractionsLoader {
constructor(
private readonly baseUrl: string,
private readonly confirmationStatus: ConfirmationStatus = null,
@@ -77,7 +77,7 @@ export class RedstoneGatewayInteractionsLoader implements InteractionsLoader {
this.source = source;
}
private readonly logger = LoggerFactory.INST.create('RedstoneGatewayInteractionsLoader');
private readonly logger = LoggerFactory.INST.create('WarpGatewayInteractionsLoader');
async load(
contractId: string,
@@ -123,7 +123,7 @@ export class RedstoneGatewayInteractionsLoader implements InteractionsLoader {
if (error.body?.message) {
this.logger.error(error.body.message);
}
throw new Error(`Unable to retrieve transactions. Redstone gateway responded with status ${error.status}.`);
throw new Error(`Unable to retrieve transactions. Warp gateway responded with status ${error.status}.`);
});
totalPages = response.paging.pages;

View File

@@ -10,13 +10,13 @@ import {
InteractionData,
InteractionResult,
LoggerFactory,
RedStoneLogger,
WarpLogger,
SmartWeaveGlobal
} from '@warp';
import stringify from 'safe-stable-stringify';
export class WasmContractHandlerApi<State> implements HandlerApi<State> {
private readonly contractLogger: RedStoneLogger;
private readonly contractLogger: WarpLogger;
private readonly logger = LoggerFactory.INST.create('WasmContractHandlerApi');
constructor(

View File

@@ -5,7 +5,7 @@
// This file has been modified for use by the TinyGo compiler.
// note: this file has been further modified to be used
// with RedStone SmartWeave SDK.
// with Warp SDK.
/* tslint:disable */
/* eslint-disable */
/* YOLO */

View File

@@ -7,8 +7,8 @@ import {
HandlerExecutorFactory,
LexicographicalInteractionsSorter,
R_GW_URL,
RedstoneGatewayContractDefinitionLoader,
RedstoneGatewayInteractionsLoader,
WarpGatewayContractDefinitionLoader,
WarpGatewayInteractionsLoader,
Warp,
WarpBuilder,
WarpWebFactory
@@ -55,8 +55,8 @@ export class WarpNodeFactory extends WarpWebFactory {
maxStoredInMemoryBlockHeights = 10,
confirmationStatus: ConfirmationStatus = { notCorrupted: true }
): WarpBuilder {
const interactionsLoader = new RedstoneGatewayInteractionsLoader(R_GW_URL, confirmationStatus);
const definitionLoader = new RedstoneGatewayContractDefinitionLoader(R_GW_URL, arweave, new MemCache());
const interactionsLoader = new WarpGatewayInteractionsLoader(R_GW_URL, confirmationStatus);
const definitionLoader = new WarpGatewayContractDefinitionLoader(R_GW_URL, arweave, new MemCache());
const executorFactory = new CacheableExecutorFactory(arweave, new HandlerExecutorFactory(arweave), new MemCache());
const stateEvaluator = new CacheableStateEvaluator(
@@ -70,7 +70,7 @@ export class WarpNodeFactory extends WarpWebFactory {
return Warp.builder(arweave)
.setDefinitionLoader(definitionLoader)
.setInteractionsLoader(interactionsLoader)
.useRedStoneGwInfo()
.useWarpGwInfo()
.setInteractionsSorter(interactionsSorter)
.setExecutorFactory(executorFactory)
.setStateEvaluator(stateEvaluator);
@@ -92,8 +92,8 @@ export class WarpNodeFactory extends WarpWebFactory {
maxStoredInMemoryBlockHeights = 10,
confirmationStatus: ConfirmationStatus = { notCorrupted: true }
): Promise<WarpBuilder> {
const interactionsLoader = new RedstoneGatewayInteractionsLoader(R_GW_URL, confirmationStatus);
const definitionLoader = new RedstoneGatewayContractDefinitionLoader(R_GW_URL, arweave, new MemCache());
const interactionsLoader = new WarpGatewayInteractionsLoader(R_GW_URL, confirmationStatus);
const definitionLoader = new WarpGatewayContractDefinitionLoader(R_GW_URL, arweave, new MemCache());
const executorFactory = new CacheableExecutorFactory(arweave, new HandlerExecutorFactory(arweave), new MemCache());
@@ -108,7 +108,7 @@ export class WarpNodeFactory extends WarpWebFactory {
return Warp.builder(arweave)
.setDefinitionLoader(definitionLoader)
.setInteractionsLoader(interactionsLoader)
.useRedStoneGwInfo()
.useWarpGwInfo()
.setInteractionsSorter(interactionsSorter)
.setExecutorFactory(executorFactory)
.setStateEvaluator(stateEvaluator);

View File

@@ -8,8 +8,8 @@ import {
HandlerExecutorFactory,
LexicographicalInteractionsSorter,
R_GW_URL,
RedstoneGatewayContractDefinitionLoader,
RedstoneGatewayInteractionsLoader,
WarpGatewayContractDefinitionLoader,
WarpGatewayInteractionsLoader,
Warp,
WarpBuilder,
StateCache
@@ -38,8 +38,8 @@ export class WarpWebFactory {
maxStoredBlockHeights = 10,
confirmationStatus: ConfirmationStatus = { notCorrupted: true }
): WarpBuilder {
const interactionsLoader = new RedstoneGatewayInteractionsLoader(R_GW_URL, confirmationStatus);
const definitionLoader = new RedstoneGatewayContractDefinitionLoader(R_GW_URL, arweave, new MemCache());
const interactionsLoader = new WarpGatewayInteractionsLoader(R_GW_URL, confirmationStatus);
const definitionLoader = new WarpGatewayContractDefinitionLoader(R_GW_URL, arweave, new MemCache());
const executorFactory = new CacheableExecutorFactory(arweave, new HandlerExecutorFactory(arweave), new MemCache());
@@ -54,7 +54,7 @@ export class WarpWebFactory {
return Warp.builder(arweave)
.setDefinitionLoader(definitionLoader)
.setInteractionsLoader(interactionsLoader)
.useRedStoneGwInfo()
.useWarpGwInfo()
.setInteractionsSorter(interactionsSorter)
.setExecutorFactory(executorFactory)
.setStateEvaluator(stateEvaluator);

View File

@@ -48,7 +48,7 @@ export async function createTx(
interactionTx.addTag(WarpTags.APP_NAME, 'SmartWeaveAction');
// use real SDK version here?
interactionTx.addTag(WarpTags.APP_VERSION, '0.3.0');
interactionTx.addTag(WarpTags.SDK, 'RedStone');
interactionTx.addTag(WarpTags.SDK, 'Warp');
interactionTx.addTag(WarpTags.CONTRACT_TX_ID, contractId);
interactionTx.addTag(WarpTags.INPUT, JSON.stringify(input));
@@ -59,7 +59,7 @@ export async function createTx(
}
export function createDummyTx(tx: Transaction, from: string, block: BlockData): GQLNodeInterface {
// transactions loaded from gateway (either arweave.net GQL or RedStone) have the tags decoded
// transactions loaded from gateway (either arweave.net GQL or Warp) have the tags decoded
// - so to be consistent, the "dummy" tx, which is used for viewState and dryWrites, also has to have
// the tags decoded.
const decodedTags = unpackTags(tx);

View File

@@ -47,7 +47,7 @@ export interface GQLNodeInterface {
id: string;
};
dry?: boolean;
sortKey?: string; // added dynamically by RedStone Sequencer
sortKey?: string; // added dynamically by Warp Sequencer
confirmationStatus?: string;
source?: string;
bundlerTxId?: string;
@@ -63,7 +63,7 @@ export interface VrfData {
export interface GQLEdgeInterface {
// added dynamically by the LexicographicalInteractionsSorter
// or rewritten from GQLNodeInterface.sortKey (if added there by RedStone Sequencer)
// or rewritten from GQLNodeInterface.sortKey (if added there by Warp Sequencer)
sortKey?: string;
cursor: string;
node: GQLNodeInterface;

View File

@@ -1,4 +1,4 @@
import { LogLevel, RedStoneLogger } from '@warp/logging';
import { LogLevel, WarpLogger } from '@warp/logging';
import { ConsoleLoggerFactory } from './web/ConsoleLoggerFactory';
export interface ILoggerFactory {
@@ -8,7 +8,7 @@ export interface ILoggerFactory {
logLevel(level: LogLevel, moduleName?: string): void;
create(moduleName?: string): RedStoneLogger;
create(moduleName?: string): WarpLogger;
}
export class LoggerFactory implements ILoggerFactory {
@@ -30,7 +30,7 @@ export class LoggerFactory implements ILoggerFactory {
LoggerFactory.INST.logLevel(level, moduleName);
}
create(moduleName?: string): RedStoneLogger {
create(moduleName?: string): WarpLogger {
return LoggerFactory.INST.create(moduleName);
}

View File

@@ -1,5 +1,5 @@
/* eslint-disable */
export interface RedStoneLogger {
export interface WarpLogger {
fatal(message?: any, ...optionalParams: any[]): void;
error(message?: any, ...optionalParams: any[]): void;

View File

@@ -1,6 +1,6 @@
export * from './web/ConsoleLogger';
export * from './web/ConsoleLoggerFactory';
export * from './RedStoneLogger';
export * from './WarpLogger';
export * from './LoggerFactory';
export * from './LoggerSettings';
export * from './Benchmark';

View File

@@ -1,6 +1,6 @@
import path from 'path';
import { ISettingsParam, Logger } from 'tslog';
import { RedStoneLogger } from '../RedStoneLogger';
import { WarpLogger } from '../WarpLogger';
import { ILoggerFactory, LogLevel } from '@warp';
export const defaultLoggerOptions: ISettingsParam = {
@@ -80,7 +80,7 @@ export class TsLogFactory implements ILoggerFactory {
this.setOptions({ minLevel: level }, moduleName);
}
create(moduleName = 'SWC'): RedStoneLogger {
create(moduleName = 'SWC'): WarpLogger {
// in case of passing '__dirname' as moduleName - leaves only the file name without extension.
const normalizedModuleName = path.basename(moduleName, path.extname(moduleName));
if (!this.registeredLoggers[normalizedModuleName]) {
@@ -90,6 +90,6 @@ export class TsLogFactory implements ILoggerFactory {
});
this.registeredLoggers[normalizedModuleName] = logger;
}
return this.registeredLoggers[normalizedModuleName] as RedStoneLogger;
return this.registeredLoggers[normalizedModuleName] as WarpLogger;
}
}

View File

@@ -1,7 +1,7 @@
/* eslint-disable */
import { LoggerSettings, LogLevel, lvlToOrder, RedStoneLogger } from '@warp';
import { LoggerSettings, LogLevel, lvlToOrder, WarpLogger } from '@warp';
export class ConsoleLogger implements RedStoneLogger {
export class ConsoleLogger implements WarpLogger {
constructor(private readonly moduleName, public settings: LoggerSettings) {}
trace(message?: any, ...optionalParams: any[]): void {

View File

@@ -1,4 +1,4 @@
import { ILoggerFactory, LoggerSettings, RedStoneLogger } from '@warp';
import { ILoggerFactory, LoggerSettings, WarpLogger } from '@warp';
import { ConsoleLogger } from './ConsoleLogger';
import { LogLevel } from '../LoggerSettings';
@@ -68,7 +68,7 @@ export class ConsoleLoggerFactory implements ILoggerFactory {
this.setOptions({ minLevel: level }, moduleName);
}
create(moduleName = 'SWC'): RedStoneLogger {
create(moduleName = 'SWC'): WarpLogger {
if (!Object.prototype.hasOwnProperty.call(this.registeredLoggers, moduleName)) {
this.registeredLoggers[moduleName] = new ConsoleLogger(moduleName, this.getOptions(moduleName));
}