0.6.29 • Published 3 years ago

@kronoverse/run v0.6.29

Weekly downloads
42
License
-
Repository
-
Last release
3 years ago

0.6 Preview

Please don't share it or talk about it yet. We want to surprise people.

Thank you!

To use, copy dist files into your project. Setup is the same as 0.5.


New Features

  • Base protocol complete
  • Upgrade code
  • Classes are jigs (You can call methods on them!)
  • New Token class
  • New Transaction API
  • New Blockchain API
  • Async Owner API (Better for wallets)
  • Destroy jigs (And still load and reference them)
  • Auth jigs (Spends them)
  • Sealed code (Control who can extend from your class)
  • Trusted code
  • Parallel loads and broadcasts
  • Security fixes
  • New presets format
  • Global timeout
  • Browser cache

Status

  • Protocol stable
  • API stable
  • Testing: 90% (Protocol: 95%, Run: 90%, Modules: 90%, Extras: 95%)
  • No docs, examples, deploy tool, or explorer
  • Uses old bsv 1.x library

API Changes

class Run { deploy(T): Code // not async anymore. call sync if needed static install(T): Code // gets you a code jig but doesn't deploy it

trust(txid) // txid or '*' for all

async import(rawtx): Transaction // shorthand for Run.Transaction.import transaction(callback): any // shorthand for new Transaction(callback).publish() static Transaction // access Transaction class. may have multiple now.

payload(rawtx): object // extract run payload from tx unify(...jigs) // advanced. ensures jigs will work together in a transaction

timeout: number // global timeout for loads, publish, sync. default: 30000 networkTimeout: number // timeout specifically for network calls. default 10000 networkRetries: number // number of times to retry network calls. default: 2 client: boolean // client mode. requires loads to come from cache. default: false

static Code // to check instanceof Code for code jigs }

class Transaction { constructor() // creates a new batch

update(callback: function) // updates the batch with new actions

async publish(options) // publishes async export(options) // exports the tx. options: pay and sign booleans

rollback() // undo the transaction's changes. recommended after export.

outputs: Jig|Code deletes: Jig|Code }

class Jig { destroy() // new! makes a jig immutable and removes its output auth() // new! forces owner to approve an update }

class Code { // all installed code has the following functions upgrade(T) // replace class/func with new code destroy() // same as Jig.destroy auth() // same as Jig.destroy sync() // updates code like jigs }

class Token { constructor(...tokens) // combine static mint(amount) // mint. replaces new MyToken(amount) send(to, amount): Token // returns current token now not change }

class Blockchain { async broadcast (rawtx: string): string // accepts raw hex, returns txid async fetch (txid): rawtx // returns raw hex async utxos (script): [] // utxo.script is hex string now async time (txid): number // ms since unix epoch async spends (txid, vout): ?string // spend hex txid or null }

class Owner { async nextOwner() // async now, renamed from owner() }


Breaking changes

  • Token class
  • run.sync() does not sync the inventory anymore. Call run.inventory.sync()
  • Transaction API
  • Static methods on jig classes are recorded
  • New presets format
  • Owner property may not always be accessible now, esp in constructor. It is secure.
  • Getters and setters no longer supported on classes (security hole)
  • Anonymous functions no longer supported as args
  • Move to raw hex transactions and raw hex scripts wherever used
  • Code must be trusted to load. During development, use new Run({ trust: '*' })

Protocol

Every Run transaction is an atomic program on jigs.

Inputs -> Computation -> Outputs

Inputs and outputs are jigs. Computation is stored as Run opcodes in an OP_RETURN.

There are 6 opcodes supported by Run in 0.6:

DEPLOY - Create a new code jig NEW - Instantiate a class CALL - Call a method on a jig DESTROY - Delete code or object AUTH - Prove ownership with a spend UPGRADE - Replace code with new code

They are stored in the "exec" part of the OP_RETURN payload:

{ "in": 0, "ref": "native://Jig" , "out": "e494cd3d0c33615620c22f44cddf85f2bf613fd608dbfc53822664581205d198", "9a99596f417e8925cb25f2acf99abe28f014aaad47ce93c427ee3afd3bcc5084" , "del": [], "cre": "mhhHzeLjRTD4cjuygJFjqmCHCFpDKGrp75", "mhhHzeLjRTD4cjuygJFjqmCHCFpDKGrp75" , "exec": [ { "op": "DEPLOY", "data": "class A extends Jig { }", { "deps": { "Jig": { "$jig": 0 } } } }, { "op": "NEW", "data": [{ "$jig": 1 }, []] } ] }

The other parts of this OP_RETURN are:

in - Number of jig inputs ref - Array of references to jigs used but not spent out - State hashes of jigs in transaction outputs del - State hashes of jigs deleted cre - New owners of jigs created

This JSON payload is stored in the first output. The OP_RETURN format is:

OP_FALSE OP_RETURN "run" 0x05 "" ""

It can be accessed via the payload function available on Run:

const tx = await run.blockchain.fetch(txid) const payload = run.payload(tx) console.log(payload)

The rest of the protocol will be documented in a coming spec. Reach out for questions!

0.6.29

3 years ago

0.6.28

3 years ago

0.6.27

3 years ago

0.6.26

3 years ago

0.6.25

3 years ago

0.6.24

3 years ago

0.6.23

3 years ago

0.6.22

4 years ago

0.6.21

4 years ago

0.6.20

4 years ago

0.6.19

4 years ago

0.6.18

4 years ago

0.6.17

4 years ago

0.6.16

4 years ago

0.6.15

4 years ago

0.6.14

4 years ago

0.6.13

4 years ago

0.6.12

4 years ago

0.6.10

4 years ago

0.6.11

4 years ago

0.6.9

4 years ago

0.6.8

4 years ago

0.6.7

4 years ago

0.6.6

4 years ago

0.6.5

4 years ago

0.6.3

4 years ago

0.6.4

4 years ago

0.6.2

4 years ago

0.6.1

4 years ago

0.6.0-4

4 years ago

0.6.0-3

4 years ago

0.6.0-2

4 years ago

0.5.35-1

4 years ago

0.6.0-1

4 years ago

0.6.0

4 years ago

0.5.35-alpha

4 years ago