feat: simplified configuration for redstone gateway

This commit is contained in:
ppedziwiatr
2022-03-09 20:49:33 +01:00
committed by Piotr Pędziwiatr
parent 7fe41f6516
commit bb62c91e16
3 changed files with 95 additions and 112 deletions

View File

@@ -92,7 +92,7 @@ In order to use the [Redstone Gateway](https://github.com/redstone-finance/redst
configure the smartweave instance in the following way: configure the smartweave instance in the following way:
```ts ```ts
const smartweave = SmartWeaveNodeFactory.memCachedBased(arweave) const smartweave = SmartWeaveNodeFactory.memCachedBased(arweave)
.setInteractionsLoader(new RedstoneGatewayInteractionsLoader(gatewayUrl)) .useRedStoneGateway()
.build(); .build();
``` ```
The gateway is currently available under [https://gateway.redstone.finance](https://gateway.redstone.finance) url. The gateway is currently available under [https://gateway.redstone.finance](https://gateway.redstone.finance) url.
@@ -104,7 +104,7 @@ all the interactions. There is a risk of returning [corrupted transactions](http
2. `{confirmed: true}` - returns only confirmed transactions - the most safe mode, eg: 2. `{confirmed: true}` - returns only confirmed transactions - the most safe mode, eg:
```ts ```ts
const smartweave = SmartWeaveNodeFactory.memCachedBased(arweave) const smartweave = SmartWeaveNodeFactory.memCachedBased(arweave)
.setInteractionsLoader(new RedstoneGatewayInteractionsLoader(gatewayUrl, {confirmed: true})) .useRedStoneGateway( {confirmed: true} )
.build(); .build();
``` ```
@@ -112,7 +112,7 @@ const smartweave = SmartWeaveNodeFactory.memCachedBased(arweave)
Not as safe as previous mode, but good if you want combine high level of safety with the most recent data. Not as safe as previous mode, but good if you want combine high level of safety with the most recent data.
```ts ```ts
const smartweave = SmartWeaveNodeFactory.memCachedBased(arweave) const smartweave = SmartWeaveNodeFactory.memCachedBased(arweave)
.setInteractionsLoader(new RedstoneGatewayInteractionsLoader(gatewayUrl, {notCorrupted: true})) .useRedStoneGateway( {notCorrupted: true} )
.build(); .build();
``` ```

View File

@@ -51,9 +51,7 @@ describe.each(chunked)('v1 compare.suite %#', (contracts: string[]) => {
.trim(); .trim();
console.log('readState', contractTxId); console.log('readState', contractTxId);
const result2 = await SmartWeaveNodeFactory.memCachedBased(arweave, 1) const result2 = await SmartWeaveNodeFactory.memCachedBased(arweave, 1)
.setInteractionsLoader( .useRedStoneGateway(null, SourceType.ARWEAVE)
new RedstoneGatewayInteractionsLoader('https://gateway.redstone.finance', null, SourceType.ARWEAVE)
)
.build() .build()
.contract(contractTxId) .contract(contractTxId)
.setEvaluationOptions({ .setEvaluationOptions({
@@ -76,12 +74,7 @@ fdescribe.each(chunkedGw)('gateways compare.suite %#', (contracts: string[]) =>
const blockHeight = 855134; const blockHeight = 855134;
console.log('readState Redstone Gateway', contractTxId); console.log('readState Redstone Gateway', contractTxId);
const smartweaveR = SmartWeaveWebFactory.memCachedBased(arweave, 1) const smartweaveR = SmartWeaveWebFactory.memCachedBased(arweave, 1)
.setInteractionsLoader( .useRedStoneGateway(null, SourceType.ARWEAVE)
new RedstoneGatewayInteractionsLoader('https://gateway.redstone.finance', null, SourceType.ARWEAVE)
)
.setDefinitionLoader(
new RedstoneGatewayContractDefinitionLoader('https://gateway.redstone.finance', arweave, new MemCache())
)
.build(); .build();
const result = await smartweaveR.contract(contractTxId).readState(blockHeight); const result = await smartweaveR.contract(contractTxId).readState(blockHeight);
const resultString = stringify(result.state).trim(); const resultString = stringify(result.state).trim();
@@ -103,12 +96,7 @@ describe('readState', () => {
const resultString = stringify(result).trim(); const resultString = stringify(result).trim();
const result2 = await SmartWeaveNodeFactory.memCachedBased(arweave, 1) const result2 = await SmartWeaveNodeFactory.memCachedBased(arweave, 1)
.setInteractionsLoader( .useRedStoneGateway(null, SourceType.ARWEAVE)
new RedstoneGatewayInteractionsLoader('https://gateway.redstone.finance', null, SourceType.ARWEAVE)
)
.setDefinitionLoader(
new RedstoneGatewayContractDefinitionLoader('https://gateway.redstone.finance', arweave, new MemCache())
)
.build() .build()
.contract(contractTxId) .contract(contractTxId)
.readState(blockHeight); .readState(blockHeight);
@@ -126,12 +114,7 @@ describe('readState', () => {
}); });
const v2Result = await SmartWeaveNodeFactory.memCachedBased(arweave, 1) const v2Result = await SmartWeaveNodeFactory.memCachedBased(arweave, 1)
.setInteractionsLoader( .useRedStoneGateway(null, SourceType.ARWEAVE)
new RedstoneGatewayInteractionsLoader('https://gateway.redstone.finance', null, SourceType.ARWEAVE)
)
.setDefinitionLoader(
new RedstoneGatewayContractDefinitionLoader('https://gateway.redstone.finance', arweave, new MemCache())
)
.build() .build()
.contract(contractTxId) .contract(contractTxId)
.connect(jwk) .connect(jwk)

View File

@@ -28,7 +28,7 @@ export interface RedstoneGatewayInteractions {
message?: string; message?: string;
} }
type ConfirmationStatus = export type ConfirmationStatus =
| { | {
notCorrupted?: boolean; notCorrupted?: boolean;
confirmed?: null; confirmed?: null;