feat: Broken images and hyperlinks in NPM package readme (#230)

This commit is contained in:
Asia
2022-09-28 12:50:51 +02:00
committed by GitHub
parent 481ca045fa
commit 0b9d32f865

View File

@@ -1,8 +1,8 @@
# Warp SDK # Warp SDK
> ⚠️ Following library has been renamed from **[redstone-smartweave](https://www.npmjs.com/package/redstone-smartweave)** to **warp-contracts** from version **1.0.0**! If you are using older version please read [README-LEGACY](README-LEGACY.md). > ⚠️ Following library has been renamed from **[redstone-smartweave](https://www.npmjs.com/package/redstone-smartweave)** to **warp-contracts** from version **1.0.0**! If you are using older version please read [README-LEGACY](https://github.com/warp-contracts/warp/blob/main/README-LEGACY.md).
Warp SDK is the implementation of the SmartWeave [Protocol](./docs/SMARTWEAVE_PROTOCOL.md). Warp SDK is the implementation of the SmartWeave [Protocol](https://github.com/warp-contracts/warp/blob/main/docs/SMARTWEAVE_PROTOCOL.md).
It works in both web and Node.js environment (requires Node.js 16.5+). It works in both web and Node.js environment (requires Node.js 16.5+).
@@ -35,6 +35,8 @@ If you are interested in the main assumptions for Warp ecosystem as well as its
- [VM2](#vm2) - [VM2](#vm2)
- [Internal writes](#internal-writes) - [Internal writes](#internal-writes)
- [UnsafeClient](#unsafeclient) - [UnsafeClient](#unsafeclient)
- [Cache](#cache)
- [CLI](#cli)
- [Examples](#examples) - [Examples](#examples)
- [Migrations](#migrations) - [Migrations](#migrations)
- [Old factories to WarpFactory](#old-factories-to-warpfactory) - [Old factories to WarpFactory](#old-factories-to-warpfactory)
@@ -44,7 +46,7 @@ If you are interested in the main assumptions for Warp ecosystem as well as its
## Development ## Development
PRs are welcome! :-) Also, feel free to submit [issues](https://github.com/redstone-finance/warp/issues) - with both bugs and feature proposals. PRs are welcome! :-) Also, feel free to submit [issues](https://github.com/warp-contracts/warp/issues) - with both bugs and feature proposals.
In case of creating a PR - please use [semantic commit messages](https://gist.github.com/joshbuchea/6f47e86d2510bce28f8e7f42ae84c716). In case of creating a PR - please use [semantic commit messages](https://gist.github.com/joshbuchea/6f47e86d2510bce28f8e7f42ae84c716).
### Installation ### Installation
@@ -132,7 +134,7 @@ Default parameters (each of them can be adjusted to your needs):
#### forTestnet #### forTestnet
Creates a Warp instance suitable for testing with Warp testnet (https://testnet.redstone.tools/). Creates a Warp instance suitable for testing with [Warp testnet](https://testnet.redstone.tools/).
```typescript ```typescript
warp = WarpFactory.forTestnet(); warp = WarpFactory.forTestnet();
@@ -146,7 +148,7 @@ Default parameters (each of them can be adjusted to your needs):
#### forMainnet #### forMainnet
Creates a Warp instance suitable for use with mainnet. Creates a Warp instance suitable for use with mainnet.
By default, the Warp gateway (https://github.com/warp-contracts/gateway#warp-gateway) is being used for: By default, the [Warp gateway](https://github.com/warp-contracts/gateway#warp-gateway) is being used for:
1. deploying contracts 1. deploying contracts
2. writing new transactions through Warp Sequencer 2. writing new transactions through Warp Sequencer
@@ -282,7 +284,7 @@ const contract = warp.contract('YOUR_CONTRACT_TX_ID').connect(jwk);
function setEvaluationOptions(options: Partial<EvaluationOptions>): Contract<State>; function setEvaluationOptions(options: Partial<EvaluationOptions>): Contract<State>;
``` ```
Allows to set [EvaluationOptions](https://github.com/warp-contracts/warp/blob/main/src/core/modules/StateEvaluator.ts#L123) that will overwrite current configuration. Allows to set [EvaluationOptions](https://github.com/warp-contracts/warp/blob/main/src/core/modules/StateEvaluator.ts#L98) that will overwrite current configuration.
<details> <details>
<summary>Example</summary> <summary>Example</summary>
@@ -301,11 +303,11 @@ const contract = warp.contract('YOUR_CONTRACT_TX_ID').setEvaluationOptions({
#### `readState` #### `readState`
```typescript ```typescript
import {SortKeyCacheResult} from "./SortKeyCache"; import { SortKeyCacheResult } from './SortKeyCache';
async function readState( async function readState(
sortKeyOrBlockHeight?: string | number, sortKeyOrBlockHeight?: string | number,
currentTx?: { contractTxId: string; interactionTxId: string }[] currentTx?: { contractTxId: string; interactionTxId: string }[]
): Promise<SortKeyCacheResult<EvalStateResult<State>>>; ): Promise<SortKeyCacheResult<EvalStateResult<State>>>;
``` ```
@@ -401,7 +403,7 @@ async function writeInteraction<Input = unknown>(
Writes a new "interaction" transaction - i.e. such transaction that stores input for the contract. Writes a new "interaction" transaction - i.e. such transaction that stores input for the contract.
- `input` the interaction input - `input` the interaction input
- `options` - an object with some custom options (see [WriteInteractionOptions](https://github.com/warp-contracts/warp/blob/src/contract/Contract.ts#L46)) - `options` - an object with some custom options (see [WriteInteractionOptions](https://github.com/warp-contracts/warp/blob/main/src/contract/Contract.ts#L49))
By default write interaction transactions are bundled and posted on Arweave using Warp Sequencer. If you want to post transactions directly to Arweave - disable bundling by setting `options.disableBundling` to `true`. By default write interaction transactions are bundled and posted on Arweave using Warp Sequencer. If you want to post transactions directly to Arweave - disable bundling by setting `options.disableBundling` to `true`.
@@ -428,7 +430,7 @@ async function evolve(newSrcTxId: string, options?: WriteInteractionOptions): Pr
Allows to change contract's source code, without having to deploy a new contract. This method effectively evolves the contract to the source. This requires the `save` method to be called first and its transaction to be confirmed by the network. Allows to change contract's source code, without having to deploy a new contract. This method effectively evolves the contract to the source. This requires the `save` method to be called first and its transaction to be confirmed by the network.
- `newSrcTxId` - result of the `save` method call. - `newSrcTxId` - result of the `save` method call.
- `options` - an object with some custom options (see [WriteInteractionOptions](https://github.com/warp-contracts/warp/blob/src/contract/Contract.ts#L46)) - `options` - an object with some custom options (see [WriteInteractionOptions](https://github.com/warp-contracts/warp/blob/main/src/contract/Contract.ts#L49))
By default evolve interaction transactions are bundled and posted on Arweave using Warp Sequencer. If you want to post transactions directly to Arweave - disable bundling by setting `options.disableBundling` to `true`. By default evolve interaction transactions are bundled and posted on Arweave using Warp Sequencer. If you want to post transactions directly to Arweave - disable bundling by setting `options.disableBundling` to `true`.
@@ -502,7 +504,7 @@ A new method has been added to SmartWeave global object. It allows to perform wr
const result = await SmartWeave.contracts.write(contractTxId, { function: 'add' }); const result = await SmartWeave.contracts.write(contractTxId, { function: 'add' });
``` ```
The `result` of the internal write contains the result type (`ok`, `error`, `exception`) and the most current state The `result` of the internal write contains the result type (`ok`, `error`, `exception`) and the most current state
of the callee contract (i.e. after performing a write). of the callee contract (i.e. after performing a write).
If the function called by the `SmartWeave.contracts.write` throws an error, the parent transaction throws a `ContractError` If the function called by the `SmartWeave.contracts.write` throws an error, the parent transaction throws a `ContractError`
by default - so there is no need to manually check the result of the internal write. by default - so there is no need to manually check the result of the internal write.
@@ -518,8 +520,8 @@ const callingContract = smartweave
.connect(wallet); .connect(wallet);
``` ```
A more detailed description of internal writes feature is available [here](docs/INTERNAL_WRITES.md). A more detailed description of internal writes feature is available [here](https://github.com/warp-contracts/warp/blob/main/docs/INTERNAL_WRITES.md).
A list of real life examples are available [here](docs/INTERNAL_WRITES.md#examples). A list of real life examples are available [here](https://github.com/warp-contracts/warp/blob/main/docs/INTERNAL_WRITES.md#examples).
You can also perform internal read to the contract (originally introduced by the protocol): You can also perform internal read to the contract (originally introduced by the protocol):
@@ -552,6 +554,10 @@ In order to reduce the cache size, the oldest entries are automatically pruned.
It is possible to use the in-memory cache instead by setting `cacheOptions.inMemory` to `true` while initializing Warp. `inMemory` cache is used by default in local environment. It is possible to use the in-memory cache instead by setting `cacheOptions.inMemory` to `true` while initializing Warp. `inMemory` cache is used by default in local environment.
### CLI
A dedicated CLI which eases the process of using main methods of the Warp SDK library has been created. Please refer to [`warp-contracts-cli` npm page](https://www.npmjs.com/package/warp-contracts-cli) for more details.
### Migrations ### Migrations
#### old factories to WarpFactory #### old factories to WarpFactory
@@ -615,7 +621,7 @@ Remember that you are always allowed to initialize Warp depending on your needs
#### sqlite to levelDB #### sqlite to levelDB
If you've been using Knex based cache you can now easily migrate your sqlite database to levelDB. Just use our [migration tool](./tools/migrate.ts), set correct path to your sqlite database in this line: If you've been using Knex based cache you can now easily migrate your sqlite database to levelDB. Just use our [migration tool](https://github.com/warp-contracts/warp/blob/main/tools/migrate.ts), set correct path to your sqlite database in this line:
```typescript ```typescript
const result = await warp.migrationTool.migrateSqlite('./tools/sqlite/contracts-3008.sqlite'); const result = await warp.migrationTool.migrateSqlite('./tools/sqlite/contracts-3008.sqlite');
@@ -628,24 +634,26 @@ yarn ts-node -r tsconfig-paths/register tools/migrate.ts
``` ```
#### Additional changes #### Additional changes
1. the type of the result of the readState has changed: https://github.com/warp-contracts/warp#readstate 1. the type of the result of the readState has changed: https://github.com/warp-contracts/warp#readstate
2. the `bundleInteraction` method has been removed. The SDK now decides automatically how the transaction should be posted (based on the environment - i.e. whether the warp instance has been created for mainnet, testnet or local env). 2. the `bundleInteraction` method has been removed. The SDK now decides automatically how the transaction should be posted (based on the environment - i.e. whether the warp instance has been created for mainnet, testnet or local env).
3. the internalWrite, if the write itself fails, now throws the `ContractError` by default. There's no longer need to manually check the result of the write inside the contract code (and throw error manually if result.type != 'ok'). 3. the internalWrite, if the write itself fails, now throws the `ContractError` by default. There's no longer need to manually check the result of the write inside the contract code (and throw error manually if result.type != 'ok').
If you want to leave the check in the contract code - set the If you want to leave the check in the contract code - set the
``` ```
.setEvaluationOptions({ .setEvaluationOptions({
throwOnInternalWriteError: true throwOnInternalWriteError: true
}); });
``` ```
4. The warp instance now contains info about the environment - https://github.com/warp-contracts/warp#warpenvironment . This might be useful for writing deployment scripts, etc. 4. The warp instance now contains info about the environment - https://github.com/warp-contracts/warp#warpenvironment . This might be useful for writing deployment scripts, etc.
5. if the `warp` instance was obtained via `WarpFactor.forLocal` (which should be used for local testing with ArLocal), then: 5. if the `warp` instance was obtained via `WarpFactor.forLocal` (which should be used for local testing with ArLocal), then:
* you can use `warp.testing.generateWallet()` for generating the wallet - it returns both the jwk and wallet address - [example](https://github.com/warp-contracts/warp/blob/main/src/__tests__/integration/internal-writes/internal-write-depth.test.ts#L89). - you can use `warp.testing.generateWallet()` for generating the wallet - it returns both the jwk and wallet address - [example](https://github.com/warp-contracts/warp/blob/main/src/__tests__/integration/internal-writes/internal-write-depth.test.ts#L89).
* you can use `warp.testing.mineBlock()` to manually mine ArLocal blocks - you can use `warp.testing.mineBlock()` to manually mine ArLocal blocks
* the ArLocal blocks are mined automatically after calling `.writeInteraction`. This can be switched off by setting `evaluationOptions.mineArLocalBlocks` to `false` - [example](https://github.com/warp-contracts/warp/blob/main/src/__tests__/integration/internal-writes/internal-write-depth.test.ts#L118). - the ArLocal blocks are mined automatically after calling `.writeInteraction`. This can be switched off by setting `evaluationOptions.mineArLocalBlocks` to `false` - [example](https://github.com/warp-contracts/warp/blob/main/src/__tests__/integration/internal-writes/internal-write-depth.test.ts#L118).
### Examples ### Examples
@@ -655,9 +663,13 @@ The example usages with different web bundlers and in Node.js env are available
A community package - [arweave-jest-fuzzing](https://github.com/Hansa-Network/arweave-jest-fuzzing/blob/master/README.md) has been released thanks to Hansa Network to help SmartWeave developers write fuzzy tests. A community package - [arweave-jest-fuzzing](https://github.com/Hansa-Network/arweave-jest-fuzzing/blob/master/README.md) has been released thanks to Hansa Network to help SmartWeave developers write fuzzy tests.
### Bundled interactions and bundled deployment
Warp gateway bundles transactions underneath. Please refer to [Bundled contract](https://github.com/warp-contracts/warp/blob/main/docs/BUNDLED_CONTRACT.md) and [Bundled interaction](https://github.com/warp-contracts/warp/blob/main/docs/BUNDLED_INTERACTION.md) docs to read the specification.
## Warp transaction lifecycle ## Warp transaction lifecycle
![transactionLifecycle](docs/img/warp_transaction_lifecycle.svg) ![transactionLifecycle](https://svgshare.com/i/n0S.svg)
Warp SDK is just part of the whole Warp smart contracts platform. It makes transactions processing and evaluation easy and effective. Warp SDK is just part of the whole Warp smart contracts platform. It makes transactions processing and evaluation easy and effective.