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:
```ts
const smartweave = SmartWeaveNodeFactory.memCachedBased(arweave)
.setInteractionsLoader(new RedstoneGatewayInteractionsLoader(gatewayUrl))
.useRedStoneGateway()
.build();
```
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:
```ts
const smartweave = SmartWeaveNodeFactory.memCachedBased(arweave)
.setInteractionsLoader(new RedstoneGatewayInteractionsLoader(gatewayUrl, {confirmed: true}))
.useRedStoneGateway( {confirmed: true} )
.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.
```ts
const smartweave = SmartWeaveNodeFactory.memCachedBased(arweave)
.setInteractionsLoader(new RedstoneGatewayInteractionsLoader(gatewayUrl, {notCorrupted: true}))
.useRedStoneGateway( {notCorrupted: true} )
.build();
```

View File

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

View File

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