0.1.3 • Published 2 years ago

@projectsophon/serde v0.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@projectsophon/serde

This package contains serializers and deserializers for converting between various representations of Dark Forest data, for example between raw data received from blockchain calls to Dark Forest contracts and the typescript types used across the client.

Installation

You can install this package using npm or yarn by running:

npm install --save @projectsophon/serde
yarn add @projectsophon/serde

When using this in a plugin, you might want to load it with skypack

import * as serde from 'http://cdn.skypack.dev/@projectsophon/serde'

Table of contents

Functions

Functions

address

address(str): EthAddress

Converts a string to an EthAddress: a 0x-prefixed all lowercase hex string of 40 hex characters. An object of the EthAddress type should only ever be initialized through this constructor-like method. Throws if the provided string cannot be parsed as an Ethereum address.

Parameters

NameTypeDescription
strstringAn address-like string

Returns

EthAddress


hashToInt

hashToInt(hash): number

Parameters

NameType
hashstring

Returns

number


isNetworkEvent

isNetworkEvent(event): event is NetworkEvent

Returns whether or not the given event is an instance of NetworkEvent. Not super stringent but works for now.

Parameters

NameType
eventany

Returns

event is NetworkEvent


isUnconfirmedActivateArtifact

isUnconfirmedActivateArtifact(txIntent): txIntent is UnconfirmedActivateArtifact

Parameters

NameType
txIntentTxIntent

Returns

txIntent is UnconfirmedActivateArtifact


isUnconfirmedActivateArtifactTx

isUnconfirmedActivateArtifactTx(tx): tx is Transaction<UnconfirmedActivateArtifact>

Parameters

NameType
txTransaction<TxIntent>

Returns

tx is Transaction<UnconfirmedActivateArtifact>


isUnconfirmedBuyHat

isUnconfirmedBuyHat(txIntent): txIntent is UnconfirmedBuyHat

Parameters

NameType
txIntentTxIntent

Returns

txIntent is UnconfirmedBuyHat


isUnconfirmedBuyHatTx

isUnconfirmedBuyHatTx(tx): tx is Transaction<UnconfirmedBuyHat>

Parameters

NameType
txTransaction<TxIntent>

Returns

tx is Transaction<UnconfirmedBuyHat>


isUnconfirmedCapturePlanet

isUnconfirmedCapturePlanet(txIntent): txIntent is UnconfirmedCapturePlanet

Parameters

NameType
txIntentTxIntent

Returns

txIntent is UnconfirmedCapturePlanet


isUnconfirmedCapturePlanetTx

isUnconfirmedCapturePlanetTx(tx): tx is Transaction<UnconfirmedCapturePlanet>

Parameters

NameType
txTransaction<TxIntent>

Returns

tx is Transaction<UnconfirmedCapturePlanet>


isUnconfirmedDeactivateArtifact

isUnconfirmedDeactivateArtifact(txIntent): txIntent is UnconfirmedDeactivateArtifact

Parameters

NameType
txIntentTxIntent

Returns

txIntent is UnconfirmedDeactivateArtifact


isUnconfirmedDeactivateArtifactTx

isUnconfirmedDeactivateArtifactTx(tx): tx is Transaction<UnconfirmedDeactivateArtifact>

Parameters

NameType
txTransaction<TxIntent>

Returns

tx is Transaction<UnconfirmedDeactivateArtifact>


isUnconfirmedDepositArtifact

isUnconfirmedDepositArtifact(txIntent): txIntent is UnconfirmedDepositArtifact

Parameters

NameType
txIntentTxIntent

Returns

txIntent is UnconfirmedDepositArtifact


isUnconfirmedDepositArtifactTx

isUnconfirmedDepositArtifactTx(tx): tx is Transaction<UnconfirmedDepositArtifact>

Parameters

NameType
txTransaction<TxIntent>

Returns

tx is Transaction<UnconfirmedDepositArtifact>


isUnconfirmedFindArtifact

isUnconfirmedFindArtifact(txIntent): txIntent is UnconfirmedFindArtifact

Parameters

NameType
txIntentTxIntent

Returns

txIntent is UnconfirmedFindArtifact


isUnconfirmedFindArtifactTx

isUnconfirmedFindArtifactTx(tx): tx is Transaction<UnconfirmedFindArtifact>

Parameters

NameType
txTransaction<TxIntent>

Returns

tx is Transaction<UnconfirmedFindArtifact>


isUnconfirmedGetShips

isUnconfirmedGetShips(txIntent): txIntent is UnconfirmedGetShips

Parameters

NameType
txIntentTxIntent

Returns

txIntent is UnconfirmedGetShips


isUnconfirmedGetShipsTx

isUnconfirmedGetShipsTx(tx): tx is Transaction<UnconfirmedGetShips>

Parameters

NameType
txTransaction<TxIntent>

Returns

tx is Transaction<UnconfirmedGetShips>


isUnconfirmedInit

isUnconfirmedInit(txIntent): txIntent is UnconfirmedInit

Parameters

NameType
txIntentTxIntent

Returns

txIntent is UnconfirmedInit


isUnconfirmedInitTx

isUnconfirmedInitTx(tx): tx is Transaction<UnconfirmedInit>

Parameters

NameType
txTransaction<TxIntent>

Returns

tx is Transaction<UnconfirmedInit>


isUnconfirmedInvadePlanet

isUnconfirmedInvadePlanet(txIntent): txIntent is UnconfirmedInvadePlanet

Parameters

NameType
txIntentTxIntent

Returns

txIntent is UnconfirmedInvadePlanet


isUnconfirmedInvadePlanetTx

isUnconfirmedInvadePlanetTx(tx): tx is Transaction<UnconfirmedInvadePlanet>

Parameters

NameType
txTransaction<TxIntent>

Returns

tx is Transaction<UnconfirmedInvadePlanet>


isUnconfirmedMove

isUnconfirmedMove(txIntent): txIntent is UnconfirmedMove

Parameters

NameType
txIntentTxIntent

Returns

txIntent is UnconfirmedMove


isUnconfirmedMoveTx

isUnconfirmedMoveTx(tx): tx is Transaction<UnconfirmedMove>

Parameters

NameType
txTransaction<TxIntent>

Returns

tx is Transaction<UnconfirmedMove>


isUnconfirmedProspectPlanet

isUnconfirmedProspectPlanet(txIntent): txIntent is UnconfirmedProspectPlanet

Parameters

NameType
txIntentTxIntent

Returns

txIntent is UnconfirmedProspectPlanet


isUnconfirmedProspectPlanetTx

isUnconfirmedProspectPlanetTx(tx): tx is Transaction<UnconfirmedProspectPlanet>

Parameters

NameType
txTransaction<TxIntent>

Returns

tx is Transaction<UnconfirmedProspectPlanet>


isUnconfirmedRelease

isUnconfirmedRelease(txIntent): txIntent is UnconfirmedMove

Parameters

NameType
txIntentTxIntent

Returns

txIntent is UnconfirmedMove


isUnconfirmedReleaseTx

isUnconfirmedReleaseTx(tx): tx is Transaction<UnconfirmedMove>

Parameters

NameType
txTransaction<TxIntent>

Returns

tx is Transaction<UnconfirmedMove>


isUnconfirmedReveal

isUnconfirmedReveal(txIntent): txIntent is UnconfirmedReveal

Parameters

NameType
txIntentTxIntent

Returns

txIntent is UnconfirmedReveal


isUnconfirmedRevealTx

isUnconfirmedRevealTx(tx): tx is Transaction<UnconfirmedReveal>

Parameters

NameType
txTransaction<TxIntent>

Returns

tx is Transaction<UnconfirmedReveal>


isUnconfirmedTransfer

isUnconfirmedTransfer(txIntent): txIntent is UnconfirmedPlanetTransfer

Parameters

NameType
txIntentTxIntent

Returns

txIntent is UnconfirmedPlanetTransfer


isUnconfirmedTransferTx

isUnconfirmedTransferTx(tx): tx is Transaction<UnconfirmedPlanetTransfer>

Parameters

NameType
txTransaction<TxIntent>

Returns

tx is Transaction<UnconfirmedPlanetTransfer>


isUnconfirmedUpgrade

isUnconfirmedUpgrade(txIntent): txIntent is UnconfirmedUpgrade

Parameters

NameType
txIntentTxIntent

Returns

txIntent is UnconfirmedUpgrade


isUnconfirmedUpgradeTx

isUnconfirmedUpgradeTx(tx): tx is Transaction<UnconfirmedUpgrade>

Parameters

NameType
txTransaction<TxIntent>

Returns

tx is Transaction<UnconfirmedUpgrade>


isUnconfirmedWithdrawArtifact

isUnconfirmedWithdrawArtifact(txIntent): txIntent is UnconfirmedWithdrawArtifact

Parameters

NameType
txIntentTxIntent

Returns

txIntent is UnconfirmedWithdrawArtifact


isUnconfirmedWithdrawArtifactTx

isUnconfirmedWithdrawArtifactTx(tx): tx is Transaction<UnconfirmedWithdrawArtifact>

Parameters

NameType
txTransaction<TxIntent>

Returns

tx is Transaction<UnconfirmedWithdrawArtifact>


isUnconfirmedWithdrawSilver

isUnconfirmedWithdrawSilver(txIntent): txIntent is UnconfirmedWithdrawSilver

Parameters

NameType
txIntentTxIntent

Returns

txIntent is UnconfirmedWithdrawSilver


isUnconfirmedWithdrawSilverTx

isUnconfirmedWithdrawSilverTx(tx): tx is Transaction<UnconfirmedWithdrawSilver>

Parameters

NameType
txTransaction<TxIntent>

Returns

tx is Transaction<UnconfirmedWithdrawSilver>


locationIdFromBigInt

locationIdFromBigInt(location): LocationId

Converts a BigInteger representation of location ID into a LocationID: a non-0x-prefixed all lowercase hex string of exactly 64 hex characters (0-padded). LocationIDs should only be instantiated through locationIdFromHexStr, locationIdFromDecStr, locationIdFromBigInt, and locationIdFromEthersBN.

Parameters

NameTypeDescription
locationbigintBigInteger representation of a location ID.

Returns

LocationId


locationIdFromDecStr

locationIdFromDecStr(location): LocationId

Converts a string representing a decimal number into a LocationID: a non-0x-prefixed all lowercase hex string of exactly 64 hex characters (0-padded if necessary). LocationIDs should only be instantiated through locationIdFromHexStr, locationIdFromDecStr, locationIdFromBigInt, and locationIdFromEthersBN.

Parameters

NameTypeDescription
locationstringstring of decimal digits, the base 10 representation of a location ID.

Returns

LocationId


locationIdFromEthersBN

locationIdFromEthersBN(location): LocationId

Converts an ethers.js BigNumber (type aliased here as EthersBN) representation of a location ID into a LocationID: a non-0x-prefixed all lowercase hex string of exactly 64 hex characters (0-padded). LocationIDs should only be instantiated through locationIdFromHexStr, locationIdFromDecStr, locationIdFromBigInt, and locationIdFromEthersBN.

Parameters

NameTypeDescription
locationBigNumberethers.js BigNumber representation of a locationID.

Returns

LocationId


locationIdFromHexStr

locationIdFromHexStr(location): LocationId

Converts a possibly 0x-prefixed string of hex digits to a LocationId: a non-0x-prefixed all lowercase hex string of exactly 64 hex characters (0-padded if necessary). LocationIDs should only be instantiated through locationIdFromHexStr, locationIdFromDecStr, locationIdFromBigInt, and locationIdFromEthersBN.

Parameters

NameTypeDescription
locationstringA possibly 0x-prefixed string of hex digits representing a location ID.

Returns

LocationId


locationIdToDecStr

locationIdToDecStr(locationId): string

Converts a LocationID to a decimal string with the same numerical value; can be used if you need to pass an artifact ID into a web3 call.

Parameters

NameTypeDescription
locationIdLocationIdLocationID to convert into a string of decimal digits

Returns

string