This repository has been archived by the owner on Feb 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(chain): Arweave integration (#262)
* feat(chain): add basic arweave types * feat(global): register arweave typeIds * chore(types): use Bytes for BigInt types * feat(chain): update typeId and type of Arweave block * feat(chain): add TransactionWithBlockPtr in arweave * feat(global): register Arweave types in id_of_type * fix(global): clean typo * test(test.js): imports chain/arweave.ts in test.js * chore(global): update annotations of arweave types * chore(linter): make linter happy * chore(chain): imports Bytes from collection.ts
- Loading branch information
Showing
4 changed files
with
117 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import '../common/eager_offset' | ||
import { Bytes } from '../common/collections' | ||
|
||
// Most types from this namespace are direct mappings or adaptations from: | ||
// https://github.com/ChainSafe/firehose-arweave/blob/master/proto/sf/arweave/type/v1/type.proto | ||
export namespace arweave { | ||
/** | ||
* A key-value pair for arbitrary metadata | ||
*/ | ||
export class Tag { | ||
constructor(public name: Bytes, public value: Bytes) {} | ||
} | ||
|
||
export class ProofOfAccess { | ||
constructor( | ||
public option: string, | ||
public txPath: Bytes, | ||
public dataPath: Bytes, | ||
public chunk: Bytes, | ||
) {} | ||
} | ||
|
||
/** | ||
* An Arweave block. | ||
*/ | ||
export class Block { | ||
constructor( | ||
public timestamp: u64, | ||
public lastRetarget: u64, | ||
public height: u64, | ||
public indepHash: Bytes, | ||
public nonce: Bytes, | ||
public previousBlock: Bytes, | ||
public diff: Bytes, | ||
public hash: Bytes, | ||
public txRoot: Bytes, | ||
public txs: Bytes[], | ||
public walletList: Bytes, | ||
public rewardAddr: Bytes, | ||
public tags: Tag[], | ||
public rewardPool: Bytes, | ||
public weaveSize: Bytes, | ||
public blockSize: Bytes, | ||
public cumulativeDiff: Bytes, | ||
public hashListMerkle: Bytes, | ||
public poa: ProofOfAccess, | ||
) {} | ||
} | ||
|
||
/** | ||
* An Arweave transaction | ||
*/ | ||
export class Transaction { | ||
constructor( | ||
public format: u32, | ||
public id: Bytes, | ||
public lastTx: Bytes, | ||
public owner: Bytes, | ||
public tags: Tag[], | ||
public target: Bytes, | ||
public quantity: Bytes, | ||
public data: Bytes, | ||
public dataSize: Bytes, | ||
public dataRoot: Bytes, | ||
public signature: Bytes, | ||
public reward: Bytes, | ||
) {} | ||
} | ||
|
||
/** | ||
* An Arweave transaction with block ptr | ||
*/ | ||
export class TransactionWithBlockPtr { | ||
constructor(public tx: Transaction, public block: Block) {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters