@thanpolas/degenking
v1.7.2
Published
Unofficial DeFi Kingdoms SDK.
Downloads
99
Readme
Degenking
Unofficial DeFi Kingdoms SDK
Install
Install the module using NPM:
npm install @thanpolas/degenking --save
Documentation
Quick Start
const { getHeroesChain } = require('@thanpolas/degenking');
const [hero] = await getHeroesChain([10000]);
console.log(hero);
Configuration
Since v1.0.0 DegenKing has been multi-chain so it can support both Serendale and Crystalvale. The way multi-chain is accomplished is through two critical parts:
The "chainId" property on the provider
As you can see bellow on the Configuring RPC section, the property chainId
has been introduced which declares for which network the call will be made. If that property is not valid an error will be thrown.
Multiple Contract Address Modules
Each supported network will have its own, dedicated addresses constants module. As such, DegenKing exposes the following address constants:
ADDRESSES_HARMONY
ADDRESSES_DFKN
ADDRESSES_KLAYTN
It is by convention, that all address constant modules maintain the exact same naming scheme so you can easily get the correct address for the network you want.
Key function to this operation is the getAddresses()
function:
getAddresses(chainId)
Will return the appropriate addresses constant module based on the given chainId.
chainId
{number} The chain id to get the contract addresses for.- Returns {Object} The contract addresses for that network.
const { getAddresses } = require('@thanpolas/degenking');
const addresses = getAddresses(1666600000);
console.log(addresses);
// Prints all the available contract addresses for this network...
Address Constants
All Address constant modules (except noted) will contain the following constants:
UNISWAPV2FACTORY
UNISWAPV2ROUTER
MASTER_GARDENER
JEWEL_TOKEN
XJEWEL_TOKEN
CRYSTAL_TOKEN
- DFKN only.XCRYSTAL_TOKEN
- DFKN only.BASE_TOKEN
- An alias for the corresponding token of each network (i.e. "Jewel" for SD and "CRYSTAL" for CV).BANK
BANKER
AIRDROP
HEROES
TEARS_TOKEN
AUCTION_SALES
AUCTION_SALES_LOWERCASE
PROFILES
RUNES
MEDITATION
SUMMON_V2
QUEST_CORE_V2
QUEST_GARDENING_V1
QUEST_MINING_GOLD_V1
QUEST_MINING_JEWEL_V1
QUEST_FORAGING_V2
QUEST_FISHING_V2
QUEST_WISHING_WELL_V2
QUESTS_REV
TRAINING_QUESTS_AR
QUESTS_HANDLER_NEW
PROFESSIONS_TO_QUESTS
QUEST_WISHING_WELL_V1
- Harmony Only.QUEST_FORAGING_V1
- Harmony Only.QUEST_FISHING_V1
- Harmony Only.QUEST_CORE_V1
- Harmony Only.
Configuring RPC
By default the library will use the Official Harmony RPC. You may override this by configuring degenking:
degenKing.config('getProvider', async (chainId) => {
// getProvider() will be invoked with the chainId indicating which
// network needs to be queried.
return {
name: 'Pokt',
provider: new ethers.providers.JsonRpcProvider('https://....'),
chainId: 1666600000,
};
});
What has been done above is to set the configuration key named getProvider
and
give it a value of a callback function. This function will be invoked by the
library and it expects to receive an object with the following properties:
name
{string} An arbitrary name (label) of the RPC.provider
{Object} An ethers.js instance of a provider.chainId
{number} The chain id the provider belongs to.
ℹ️ The callback function can be a Promise returning function.
Other Configuration Options
maxRetries
{number} Default: 6 - Define how many times the queries will retry on fail until they give up.concurrentBlockChainRequests
{number} Default: 30 - Define how many concurrent blockchain queries the library should perform.
Configuring Using an Object
The config
function accepts an object as well:
degenKing.config({
getProvider: {
name: 'Pokt',
provider: new ethers.providers.JsonRpcProvider('https://....'),
chainId: 1666600000,
},
maxRetries: 8,
concurrentBlockChainRequests: 50,
});
Heroes API
getHeroesChain(chainId, heroIds, params)
Will fetch and normalize heroes from the blockchain using provided hero ids. It will augment the hero object using multiple queries and functions to also include sales data, owner profile and decode all stat and visual genes.
chainId
{number} The chain id to perform the query on.heroIds
{Array<number|string|bigint>} An array with the hero Ids.params
{Object=} Parameters for fetching the hero.params.heroesOwner
{Object=} Pass on the result from thegetProfileByAddress()
function to prevent from performing that query for each hero.params.ownerAddress
{string=} If known, define the owner address to save the extra query for who is the owner of the hero.params.archivalQuery
{boolean=} Set to true to perform an archival query of the heroes' state in the past - NOTE: requiresblockNumber
andblockMinedAt
to perform the archival query correctly.params.blockNumber
{number=} Query hero state at particular block number.params.blockMinedAt
{Date=} Pass a mining date of block to help with stamina and relevant time-sensitive calculations.- Returns {Promise<Array<Object>>} A Promise with an array of the normalized hero data objects.
const { getHeroesChain } = require('@thanpolas/degenking');
const [hero] = await getHeroesChain(1666600000, [10000]);
console.log(hero);
getHeroesAnyChain(heroIds, params)
Available since v1.0.4, wraps around getHeroesChain()
and will query
all available networks for the provided heroes. It will then check which heroes
are on which network based on the owner address field (if they belong to the bridge contract)
and return the appropriate hero state based on the chain they are on.
heroIds
{Array<number|string|bigint>} An array with the hero Ids.params
{Object=} Parameters for fetching the hero.params.heroesOwner
{Object=} Pass on the result from thegetProfileByAddress()
function to prevent from performing that query for each hero.params.ownerAddress
{string=} If known, define the owner address to save the extra query for who is the owner of the hero.params.archivalQuery
{boolean=} Set to true to perform an archival query of the heroes' state in the past - NOTE: requiresblockNumber
andblockMinedAt
to perform the archival query correctly.params.blockNumber
{number=} Query hero state at particular block number.params.blockMinedAt
{Date=} Pass a mining date of block to help with stamina and relevant time-sensitive calculations.- Returns {Promise<Array<Object>>} A Promise with an array of the normalized hero data objects.
const { getHeroesAnyChain } = require('@thanpolas/degenking');
const [hero] = await getHeroesAnyChain([10000]);
console.log(hero);
fetchHeroesByOwnerChain(chainId, ownerAddress)
Fetches and normalizes heroes based on the owner.
chainId
{number} The chain id to perform the query on.ownerAddress
{string} The owner's address.- Returns {Promise<Array<Object>>} A Promise with an array of the normalized hero data objects.
const { fetchHeroesByOwnerChain } = require('@thanpolas/degenking');
const heroes = await fetchHeroesByOwnerChain(myAddress);
console.log(heroes);
fetchHeroIdsByOwnerChain(chainId, ownerAddress)
Fetches hero IDs of all heroes owned by the owner address.
chainId
{number} The chain id to perform the query on.ownerAddress
{string} The owner's address.- Returns {Promise<Array<number>>} A Promise with an array of the hero ids.
const { fetchHeroIdsByOwnerChain } = require('@thanpolas/degenking');
const heroIds = await fetchHeroIdsByOwnerChain(myAddress);
console.log(heroIds);
// [1, 2, 3, 4]
fetchHeroesByOwnerAndProfessionChain(chainId, ownerAddress, profession)
Fetches and normalizes heroes based on the owner and profession.
chainId
{number} The chain id to perform the query on.ownerAddress
{string} The owner's address.profession
{string} The desired profession to filter by, can be one of:mining
,gardening
,fishing
andforaging
.- Returns {Promise<Array<Object>>} A Promise with an array of the normalized hero data objects filtered by profession.
const {
fetchHeroesByOwnerAndProfessionChain,
} = require('@thanpolas/degenking');
const myAddress = '0x....';
const heroes = await fetchHeroesByOwnerAndProfessionChain(myAddress, 'mining');
console.log(heroes);
Note: There is no per-profession filter on the blockchain, all of the address' heroes will be fetched and filter at runtime.
heroToString(hero, params)
Renders the normalized hero object into a string representation.
hero
{Object} The hero to render.params
{Object=} Optionally, define some parameters for the rendering:params.cli
{boolean} Set to true to get a CLI rendering.params.showActivePassive
{boolean} Show active passive genes.params.showStats
{boolean} Show hero stats.params.showParents
{boolean} Show hero's parents.params.showSale
{boolean} Show hero sales information.params.showQuest
{boolean} Show hero quest information.params.short
{boolean} Short version.params.tiny
{boolean} Tiny version.params.stampot
{boolean} Tiny Stamina Potion version.params.quest
{boolean} Optimized for Quest reporting.
- Returns {string} The string representation of the hero.
const { heroToString, getHeroesChain } = require('@thanpolas/degenking');
const [hero] = await getHeroesChain([10000]);
const heroStr = await heroToString(hero, { cli: true });
console.log(heroStr);
Find bellow the different ways the heroToString() renders:
heroToString(hero) Default Rendering
Default Rendering as well as all other renderings will produce a string that can be used on Discord, the **word**
notation you see, will render the text as bold when used on discord.
**Owner**:Ceebs - **10000** - **SD** - **G2** - **⛏️ mining** - **pirate:warrior** - **Rare(2)** - **⛏️ 55%, 👨🌾 11%, 🌳 34%, 🎣 39%** - **CR**:37 - **JM**:32.7488 - **B1**:INT 🌳 - **B2**:DEX 🌳 - **RGMC**:WAR, WIZ, THF - **RGSC**:PIR, WIZ, MON - **RGP**:👨🌾, ⛏️, 🌳 - **XP**:914/2000 - **L**:1 - **PS**:⛏️: 5.9, 🌳: 0.2, 🎣: 2.4 - **SMN**:0/8 - **STA**:25/25 - **HP**:145 - **MP**:30
heroToString(hero, {cli: true}) Default CLI Rendering
All renderings accept the {cli: true}
modifier, which will remove the **word**
notation for use on the CLI or logging.
Owner:Ceebs - 10000 -SD - G2 - ⛏️ mining - pirate:warrior - Rare(2) - ⛏️ 55%, 👨🌾 11%, 🌳 34%, 🎣 39% - CR:37 - JM:32.7488 - B1:INT 🌳 - B2:DEX 🌳 - RGMC:WAR, WIZ, THF - RGSC:PIR, WIZ, MON - RGP:👨🌾, ⛏️, 🌳 - XP:914/2000 - L:1 - PS:⛏️: 5.9, 🌳: 0.2, 🎣: 2.4 - SMN:0/8 - STA:25/25 - HP:145 - MP:30
heroToString(hero, {showActivePassive: true, cli: true}) Show Active & Passive CLI Rendering
Will also render Active/Passive traits
Owner:Ceebs - 10000 - SD - G2 - ⛏️ mining - pirate:warrior - Rare(2) - ⛏️ 55%, 👨🌾 11%, 🌳 34%, 🎣 39% - CR:37 - JM:32.7488 - B1:INT 🌳 - B2:DEX 🌳 - RGMC:WAR, WIZ, THF - RGSC:PIR, WIZ, MON - RGP:👨🌾, ⛏️, 🌳 - XP:914/2000 - L:1 - PS:⛏️: 5.9, 🌳: 0.2, 🎣: 2.4 - SMN:0/8 - A1:B8 - A2:B3 - P1:B5 - P2:B2 - STA:25/25 - HP:145 - MP:30
heroToString(hero, {showStats: true, cli: true}) Show Hero Stats - CLI Rendering
Owner:Ceebs - 10000 - SD - G2 - ⛏️ mining - pirate:warrior - Rare(2) - ⛏️ 55%, 👨🌾 11%, 🌳 34%, 🎣 39% - CR:37 - JM:32.7488 - B1:INT 🌳 - B2:DEX 🌳 - RGMC:WAR, WIZ, THF - RGSC:PIR, WIZ, MON - RGP:👨🌾, ⛏️, 🌳 - XP:914/2000 - L:1 - PS:⛏️: 5.9, 🌳: 0.2, 🎣: 2.4 - SMN:0/8 - STR:10 - AGI:8 - INT:7 - WIS:6 - LCK:10 - VIT:9 - END:7 - DEX:9 - STA:25/25 - HP:145 - MP:30
heroToString(hero, {short: true, cli: true}) Short CLI Rendering
Owner:Ceebs - 10000 - SD - G2 - ⛏️ mining - pirate:warrior - RGMC:WAR, WIZ, THF - RGSC:PIR, WIZ, MON - RGP:👨🌾, ⛏️, 🌳 - XP:914/2000 - L:1 - PS:⛏️: 5.9, 🌳: 0.2, 🎣: 2.4 - SMN:0/8 - STA:25/25 - HP:145 - MP:30
heroToString(hero, {tiny: true, cli: true}) Tiny CLI Rendering
Ceebs - id:10000 - G:2 - ⛏️ mining - pirate:warrior - Rare - 0/8 - L:1
heroToString(hero, {stampot: true, cli: true}) Stampot CLI Rendering
Ceebs - id:10000 - SD - G:2 - ⛏️ - pirate:warrior - Rare - L:1 - STA:25/25 - XP:100/2000
heroToString(hero, {stampotTiny: true, cli: true}) Stampot CLI Rendering
id:10000 - SD - L:1 - STA:25/25 - XP:100/2000
calculateRemainingStamina(hero)
Calculates and returns the remaining stamina of the hero.
hero
{Object} The normalized hero object.- Returns {number} Remaining stamina.
const {
calculateRemainingStamina,
getHeroesChain,
} = require('@thanpolas/degenking');
const [hero] = await getHeroesChain([10000]);
const heroStamina = await calculateRemainingStamina(hero);
console.log(heroStamina);
// 20
calculateRuneRequirements(level)
Calculates the needed runes to level up a hero at the provided level.
level
{number} The level of the hero.- Returns {Array<Object>} An array of rune objects.
const { calculateRuneRequirements } = require('@thanpolas/degenking');
const requiredRunes = calculateRuneRequirements(30);
console.log(requiredRunes);
// [
// { rune: 'courageRune', quantity: 1 },
// { rune: 'hopeRune', quantity: 5 },
// { rune: 'mokshaRune', quantity: 1 },
// { rune: 'shvasRune', quantity: 1 },
// ];
decodeStatGenes(statGenes)
Decodes the raw stat genes string.
statGenes
{string} The raw stat genes string.- Returns {Object} The decoded stat genes as per the example bellow.
const statGenes =
'55595053337262517174437940546058771473513094722680050621928661284030532';
const decodedStatGenes = decodeStatGenes(statGenes);
!!! Breaking Change Since 1.3.0
The return has been further normalized and labeled:
- Default trait names will be their raw numeric values.
- The mutation label will be attached with the suffix
Mut
on each trait. - When the trait has a label the
Descr
suffix will be attached. - The
recessives
property has been introduced, contains the 3 tiers of recessives:r1
,r2
andr3
.
Decoded Stat Genes Full Object
{
recessives: {
r1: {
class: 5,
subClass: 0,
profession: 2,
passive1: 3,
passive2: 2,
active1: 2,
active2: 7,
statBoost1: 10,
statBoost2: 14,
statsUnknown1: 4,
element: 0,
statsUnknown2: 0,
classDescr: 'wizard',
subClassDescr: 'warrior',
professionDescr: 'gardening',
passive1Mut: 'Basic4',
passive2Mut: 'Basic3',
active1Mut: 'Basic3',
active2Mut: 'Basic8',
statsUnknown1Mut: 'Basic5',
statsUnknown2Mut: 'Basic1',
statBoost1Descr: 'VIT',
statBoost2Descr: 'DEX',
elementDescr: 'fire'
},
r2: {
class: 0,
subClass: 6,
profession: 0,
passive1: 3,
passive2: 3,
active1: 4,
active2: 7,
statBoost1: 2,
statBoost2: 14,
statsUnknown1: 5,
element: 10,
statsUnknown2: 10,
classDescr: 'warrior',
subClassDescr: 'monk',
professionDescr: 'mining',
passive1Mut: 'Basic4',
passive2Mut: 'Basic4',
active1Mut: 'Basic5',
active2Mut: 'Basic8',
statsUnknown1Mut: 'Basic6',
statsUnknown2Mut: 'Basic11',
statBoost1Descr: 'AGI',
statBoost2Descr: 'DEX',
elementDescr: 'ice'
},
r3: {
class: 8,
subClass: 8,
profession: 4,
passive1: 1,
passive2: 1,
active1: 0,
active2: 6,
statBoost1: 2,
statBoost2: 6,
statsUnknown1: 6,
element: 10,
statsUnknown2: 6,
classDescr: 'berserker',
subClassDescr: 'berserker',
professionDescr: 'fishing',
passive1Mut: 'Basic2',
passive2Mut: 'Basic2',
active1Mut: 'Basic1',
active2Mut: 'Basic7',
statsUnknown1Mut: 'Basic7',
statsUnknown2Mut: 'Basic7',
statBoost1Descr: 'AGI',
statBoost2Descr: 'WIS',
elementDescr: 'ice'
}
},
class: 8,
subClass: 9,
profession: 4,
passive1: 3,
passive2: 7,
active1: 5,
active2: 3,
statBoost1: 6,
statBoost2: 10,
statsUnknown1: 3,
element: 8,
statsUnknown2: 10,
classDescr: 'berserker',
subClassDescr: 'seer',
professionDescr: 'fishing',
passive1Mut: 'Basic4',
passive2Mut: 'Basic8',
active1Mut: 'Basic6',
active2Mut: 'Basic4',
statsUnknown1Mut: 'Basic4',
statsUnknown2Mut: 'Basic11',
statBoost1Descr: 'WIS',
statBoost2Descr: 'VIT',
elementDescr: 'lightning'
}
decodeVisualGenes(visualGenes)
Decodes the raw visuals genes string.
visualGenes
{string} The raw visual genes string.- Returns {Object} The decoded visual genes as per the example bellow.
const visualGenes =
'170877259497388213840353281232231169976585066888929467746175634464967719';
const decodedVisualGenes = decodeStatGenes(visualGenes);
!!! Breaking Change Since 1.3.0
The return has been further normalized and labeled:
- Default trait names will be their raw numeric values.
- The mutation label will be attached with the suffix
Mut
on each trait. - When the trait has a label the
Descr
suffix will be attached. - When the trait is a color, the
Hex
suffix will be attached. - The
recessives
property has been introduced, contains the 3 tiers of recessives:r1
,r2
andr3
.
Decoded Visual Genes Full Object
const decodedVisualGenes = {
recessives: {
r1: {
gender: 1,
headAppendage: 5,
backAppendage: 2,
background: 6,
hairStyle: 4,
hairColor: 7,
visualUnknown1: 4,
eyeColor: 2,
skinColor: 2,
appendageColor: 6,
backAppendageColor: 6,
visualUnknown2: 7,
genderDescr: 'male',
backgroundDescr: 'island',
headAppendageDescr: 'Cat Ears',
headAppendageMut: 'Basic6',
backAppendageDescr: 'Cat Tail',
backAppendageMut: 'Basic3',
hairStyleDescr: 'Pixel',
hairStyleMut: 'Basic5',
hairColorHex: '62a7e6',
hairColorMut: 'Basic8',
eyeColorHex: '896693',
eyeColorMut: 'Basic3',
skinColorHex: 'f1ca9e',
skinColorMut: 'Basic3',
appendageColorHex: '830e18',
appendageColorMut: 'Basic7',
backAppendageColorHex: '830e18',
backAppendageColorMut: 'Basic7',
visualUnknown1Mut: 'Basic5',
visualUnknown2Mut: 'Basic8',
},
r2: {
gender: 1,
headAppendage: 6,
backAppendage: 6,
background: 10,
hairStyle: 9,
hairColor: 1,
visualUnknown1: 4,
eyeColor: 4,
skinColor: 14,
appendageColor: 4,
backAppendageColor: 8,
visualUnknown2: 2,
genderDescr: 'male',
backgroundDescr: 'mountains',
headAppendageDescr: 'Minotaur Horns',
headAppendageMut: 'Basic7',
backAppendageDescr: 'Kitsune Tail',
backAppendageMut: 'Basic7',
hairStyleDescr: 'Faded Topknot',
hairStyleMut: 'Basic10',
hairColorHex: 'af3853',
hairColorMut: 'Basic2',
eyeColorHex: 'bb3f55',
eyeColorMut: 'Basic5',
skinColorHex: 'aa5c38',
skinColorMut: undefined,
appendageColorHex: '2a386d',
appendageColorMut: 'Basic5',
backAppendageColorHex: 'cddef0',
backAppendageColorMut: 'Basic9',
visualUnknown1Mut: 'Basic5',
visualUnknown2Mut: 'Basic3',
},
r3: {
gender: 1,
headAppendage: 2,
backAppendage: 5,
background: 12,
hairStyle: 4,
hairColor: 4,
visualUnknown1: 4,
eyeColor: 6,
skinColor: 0,
appendageColor: 7,
backAppendageColor: 7,
visualUnknown2: 3,
genderDescr: 'male',
backgroundDescr: 'city',
headAppendageDescr: 'Satyr Horns',
headAppendageMut: 'Basic3',
backAppendageDescr: 'Daishō',
backAppendageMut: 'Basic6',
hairStyleDescr: 'Pixel',
hairStyleMut: 'Basic5',
hairColorHex: '48321e',
hairColorMut: 'Basic5',
eyeColorHex: '0d7634',
eyeColorMut: 'Basic7',
skinColorHex: 'c58135',
skinColorMut: 'Basic1',
appendageColorHex: '6f3a3c',
appendageColorMut: 'Basic8',
backAppendageColorHex: '6f3a3c',
backAppendageColorMut: 'Basic8',
visualUnknown1Mut: 'Basic5',
visualUnknown2Mut: 'Basic4',
},
},
gender: 3,
headAppendage: 6,
backAppendage: 8,
background: 0,
hairStyle: 9,
hairColor: 9,
visualUnknown1: 1,
eyeColor: 2,
skinColor: 4,
appendageColor: 1,
backAppendageColor: 3,
visualUnknown2: 2,
genderDescr: 'female',
backgroundDescr: 'desert',
headAppendageDescr: 'Minotaur Horns',
headAppendageMut: 'Basic7',
backAppendageDescr: 'Skeletal Wings',
backAppendageMut: 'Basic9',
hairStyleDescr: 'Lamia',
hairStyleMut: 'Basic10',
hairColorHex: '326988',
hairColorMut: 'Basic10',
eyeColorHex: '896693',
eyeColorMut: 'Basic3',
skinColorHex: '985e1c',
skinColorMut: 'Basic5',
appendageColorHex: 'a88b47',
appendageColorMut: 'Basic2',
backAppendageColorHex: '566f7d',
backAppendageColorMut: 'Basic4',
visualUnknown1Mut: 'Basic2',
visualUnknown2Mut: 'Basic3',
};
decodeRecessiveGeneAndNormalize(statGenesRaw)
!!! WARNING !!! Deprecated - Use
decodeStatGenes()
ordecodeVisualGenes()
Decodes the raw stat genes to produce recessive genes.
statGenes
{string|bigint} The raw stat genes string or bigint number.- Returns {Object} The decoded stat genes as per the example bellow.
const statGenes =
'119067243983457416993287681075686535166558725967282153752039019969001550';
const recessiveGenes = decodeStatGenes(statGenes);
console.log(recessiveGenes);
// {
// mainClassGenes: ['pirate','warrior','wizard','thief'],
// subClassGenes: ['warrior', 'pirate', 'wizard', 'monk'],
// professionGenes: ['mining','gardening','mining','foraging'],
// }
getProfileByAddress(chainId, address)
Will query the blockchain, profile contract, for the member data that belong to the provided address.
chainId
{number} The chain id to perform the query on.address
{string} The address to query by, accepts both checksum and lowercased addresses.- Returns {Promise<Object|null>} Will return a normalized response or null if not found.
const { getProfileByAddress } = require('@thanpolas/degenking');
const profile = await getProfileByAddress(
'0x67221b267cee49427bAa0974ceac988682192977',
);
console.log(profile);
// {
// id: 0,
// owner: '0x67221b267cee49427baa0974ceac988682192977',
// name: 'Degen Heroes',
// created: new Date('2022-02-11T15:00:57.000Z'),
// picId: 0,
// heroId: 1,
// points: 0,
// }
Hero Data Object
const hero = {
rawHero: { /** Raw hero object as fetched from blockchain **/ },
source: 'chain',
id: 59760,
ownerId: 19192,
ownerName: 'miamiblue',
ownerAddress: '0x6e9426c100dec5abc50bebe309cd85d304209096',
mainClass: 'warrior',
subClass: 'archer',
profession: 'gardening',
generation: 1,
summons: 7,
maxSummons: 10,
statBoost1: 'LCK',
statBoost2: 'DEX',
active1: 'Basic8',
active2: 'Basic3',
passive1: 'Basic6',
passive2: 'Basic4',
rarity: 0,
rarityStr: 'Common',
mining: 0.5,
gardening: 0,
foraging: 0.7,
fishing: 1.1,
craft1: 0,
craft2: 0,
shiny: false,
xp: 1298,
level: 1,
statGenes: {
class: 'warrior',
subClass: 'archer',
profession: 'gardening',
passive1: 'Basic6',
passive2: 'Basic4',
active1: 'Basic8',
active2: 'Basic3',
statBoost1: 'LCK',
statBoost2: 'DEX',
statsUnknown1: 0,
element: 'lightning',
statsUnknown2: undefined
},
visualGenes: {
gender: 'male',
headAppendage: 5,
backAppendage: 5,
background: 'mountains',
hairStyle: 5,
hairColor: '62a7e6',
visualUnknown1: 5,
eyeColor: 'bb3f55',
skinColor: '985e1c',
appendageColor: '566f7d',
backAppendageColor: '566f7d',
visualUnknown2: 0
},
statGenesRaw: '112261588165465148833973414848613658505090605198079167959458376446967944',
visualGenesRaw: '167531060423278867008632326821039556379772927070476330103731967115858144',
summonedTime: 2021-12-07T23:03:23.000Z,
nextSummonTime: 2021-12-21T23:09:05.000Z,
summonerId: 83,
assistantId: 747,
staminaFullAt: 2022-01-17T17:02:16.000Z,
hpFullAt: 1970-01-01T00:00:00.000Z,
mpFullAt: 1970-01-01T00:00:00.000Z,
currentQuest: '0x0000000000000000000000000000000000000000',
isQuesting: false,
sp: 0,
status: 0,
intelligence: 5,
luck: 9,
vitality: 9,
dexterity: 8,
strength: 11,
wisdom: 5,
agility: 7,
endurance: 8,
statsSum: 62,
hp: 150,
mp: 25,
stamina: 25,
onSale: true,
auctionId: 611485,
seller: '0x6e9426c100Dec5AbC50bEbe309Cd85d304209096',
startingPrice: 45,
endingPrice: 45,
startingPriceFormatted: '45',
endingPriceFormatted: '45',
duration: 60,
startedAt: 2022-01-26T15:19:26.000Z,
summonCost: 30,
classTier: 'basic',
summonMinTears: 10,
summonMaxTears: 10,
equipmentEquippedSlots: 1,
equipmentPetId: 2000000022783,
equipmentWeapon1Id: 0,
equipmentWeapon2Id: 0,
equipmentOffhand1Id: 0,
equipmentOffhand2Id: 0,
equipmentArmorId: 0,
equipmentAccessoryId: 0,
equipedPet: {
id: 2000000022783,
originId: 0,
name: '',
season: 1,
eggTypeId: 2,
eggTypeName: 'Green Pet Egg',
rarityId: 4,
rarityName: 'Mythic',
elementId: 6,
elementName: 'Light',
bonusCount: 3,
petProfessionName: 'Gardening',
petProfessionInstanceId: '5',
petHasQuestProfessionBonus: false,
profBonusId: 171,
profBonusName: 'Innate Greenskeeper',
profBonusScalar: 0.1,
craftBonusId: 160,
craftBonusName: 'Unrevealed',
craftBonusScalar: 0,
combatBonusId: 80,
combatBonusName: 'Unrevealed',
combatBonusScalar: 0,
craftingBonusType: 'Enchanting',
appearanceId: 139,
backgroundId: 3,
backgroundName: 'Vithraven Outskirts',
shinyId: 1,
hungryAt: 2021-10-01T00:00:00.000Z,
equippableAt: 1970-01-01T00:00:00.000Z,
equippedTo: 1000000166827,
fedBy: '0x4cc6ba1127c9d84eba64fd86a2c0836b152756aa',
foodTypeId: 3
},
currentStamina: 25,
currentRank: 14,
estJewelPerTick: 0.26188,
estJewelPer100Ticks: 26.1875,
mainClassGenes: [ 'warrior', 'thief', 'knight', 'thief' ],
subClassGenes: [ 'archer', 'warrior', 'knight', 'pirate' ],
professionGenes: [ 'gardening', 'gardening', 'gardening', 'gardening' ],
chainId: 1666600000,
realm: 'SD',
networkName: 'Harmony',
}
consumePotion(chainId, consumableAddress, heroId, privKey, optGasPrice)
Consumes a potion for the given hero. Does not approve consumption, you have to do it manually (for now).
chainId
{number} The chain id to perform the query on.consumableAddress
{string} Address of consumable potion. Use the available constants enumerated bellow.heroId
{string} The hero id that will consume the potion.privKey
{string} The private key to sign the transaction with.optGasPrice
{string=} Optionally, define a custom gas price to consume in wei.- Returns {Promise<Object|void>} A Promise with a normalized data object from the "ItemConsumed" event, or empty if fetching the TX receipt failed (very edge case).
const { getAddresses, consumePotion } = require('@thanpolas/degenking');
const addresses = getAddresses(1666600000);
// Get the stamina vial address, which will be consumed.
const { CONSUMABLE_STAMINA_VIAL } = addresses;
// Invoke consumption
const response = await consumePotion(CONSUMABLE_STAMINA_VIAL, heroId, privKey);
console.log(response);
// {
// playerAddress: '0x.....',
// itemAddress: '0x....',
// itemName: 'CONSUMABLE_STAMINA_VIAL',
// heroId: 100000,
// oldHero: {
// // Normalized hero object representing state
// // of hero before consumption
// },
// newHero: {
// // Normalized hero object representing state
// // of hero after consumption
// }
// }
Consumable Constants
Consumable potion addresses are available as constants on the ADDRESS
constant:
const { getAddresses } = require('@thanpolas/degenking');
const addresses = getAddresses(1666600000);
// All the available potions to consume
const {
CONSUMABLE_HEALTH_VIAL,
CONSUMABLE_FULL_HEALTH_POTION,
CONSUMABLE_MANA_VIAL,
CONSUMABLE_FULL_MANA_POTION,
CONSUMABLE_STAMINA_VIAL,
CONSUMABLE_ANTI_POISON_POTION,
CONSUMABLE_ANTI_BLINDING_POTION,
CONSUMABLE_MAGIC_RESISTANCE_POTION,
CONSUMABLE_TOUGHNESS_POTION,
CONSUMABLE_SWIFTNESS_POTION,
} = addresses;
consumableBalance(chainId, address, consumableAddress)
Get balance of the consumable item for the given address.
chainId
{number} The chain id to perform the query on.address
{string} The address to query for.consumableAddress
{string} The address of the consumable to fetch balance for.- Returns {Promise<number>} A Promise with the balance of potions.
const { getAddresses, consumableBalance } = require('@thanpolas/degenking');
const addresses = getAddresses(1666600000);
// Get the stamina vial address, which will be consumed.
const { CONSUMABLE_STAMINA_VIAL } = addresses;
const myAddress = '0x.....';
const balance = await consumableBalance(myAddress, CONSUMABLE_STAMINA_VIAL);
console.log(balance);
// 10
Auctions API
getSalesAuctionChainByHeroId(heroId)
Queries blockchain and returns auction (sales) data of hero.
heroId
{string|number} The hero's id.- Returns {Promise<Object>} A Promise with an object of the sales data.
const { getSalesAuctionChainByHeroId } = require('@thanpolas/degenking');
const salesData = await getSalesAuctionChainByHeroId(10000);
console.log(salesData);
// {
// onSale: false,
// auctionId: null,
// seller: '',
// startingPrice: 0,
// endingPrice: 0,
// duration: 0,
// startedAt: 0,
// };
DEPRECATION WARN: This function was used to be called
getSalesData()
which will be deprecated by v0.5.0.
getSalesAuctionGqlByAuctionId(auctionId, persist)
Queries the GraphQL API for a sales auction based on auction id.
auctionId
{string|number} The auction id to query for.persist
{boolean=} Optionally, set to true to force the function to keep retrying in case of an empty result. Use in cases when a sale has just happened to give time to the GQL to indexe the auction.- Returns {Promise<Object>} A Promise with a normalized, rich response.
const { getSalesAuctionGqlByAuctionId } = require('@thanpolas/degenking');
const auctionData = await getSalesAuctionGqlByAuctionId(1029620);
console.log(auctionData);
// {
// auctionId: 1029620,
// sellerAddress: '0xcf45c7227db5577dbbefec665821f06981243b63',
// sellerName: 'Introverse',
// heroId: 52261,
// startingPrice: '55000000000000000000',
// endingPrice: '55000000000000000000',
// duration: 60,
// startedAt: new Date('2022-03-21T14:27:36.000Z'),
// endedAt: new Date('2022-03-21T14:27:36.000Z'),
// buyerAddress: '0x9e30ba74500a2a66e7884d623d409563a38ef687',
// buyerName: 'Ariana Sundae',
// open: false,
// purchasePrice: '55000000000000000000',
// }
Game Tokens
"Game Tokens" are the respective tokens used on each chain the same is at, so currently there are:
- Jewel on Serendale.
- Crystal on Crystalvale.
fetchLockedTokensByOwnerChain(chainId, address)
Fetches the locked game tokens of the provided address from the blockchain using the appropriate network as provided by chainId.
chainId
{number} The unique blockchain id.address
{string} The owner's address to fetch locked jewel for.- Returns {Promise<number>} A Promise with the locked jewel in human readable number format.
const { fetchLockedTokensByOwnerChain } = require('@thanpolas/degenking');
const HARMONY_CHAIN_ID = 1666600000;
const lockedJewel = await fetchLockedTokensByOwnerChain(
HARMONY_CHAIN_ID,
'0x....',
);
console.log(lockedJewel);
// 12.9
Questing API
queryQuest(questId)
Fetches rich information from on-chain about a specific quest id. There are a few interesting things happening behind the scenes with this one:
- It will determine if the questId belongs to QuestCoreV1 (gardening and mining) or the newest QuestCoreV2 (Training Quests, foraging, fishing) and normalize accordingly.
- If the quest is Gardening, it will also fetch the pool the quest was on.
- If the quest is V2, it will query for the heroes (not available on the V2 quest query function).
- It will fetch the heroes' data at the time the quest started by performing an archival query.
questId
{string|number} The quest id to query for.- Returns {Promise<Object>} A Promise with the rich normalized quest data.
const { queryQuest } = require('@thanpolas/degenking');
const questData = await queryQuest(100000);
console.log(questData);
queryQuest() Response
{
version: 1, // QuestCore Version
id: 100000, // Quest id
// Quest contract address
questAddress: '0x569E6a4c2e3aF31B337Be00657B4C040C828Dd73',
// Quest contract address lowercased
questAddressLower: '0x569e6a4c2e3af31b337be00657b4c040c828dd73',
// Quest name
questName: 'MINING_GOLD',
// Player's address
playerAddress: '0x0000000000000000000000000000000000000000',
// Player's address lowercase
playerAddressLower: '0x0000000000000000000000000000000000000000',
// In game name of the player (profile)
profileName: 'ingamename'
startBlock: 27383000, // Block number rquest started
startAtTime: 2022-06-04T21:51:23.000Z, // Native JS data
completeAtTime: 2022-06-05T00:01:23.000Z, // Native JS data
attempts: 1, // Quest Attempts
// Quest Status:
// 1: In Progress
// 2: Complete
status: 2,
// Array of hero ids
heroIds: [ 49162, 128862, 146194, 146091, 159853, 173313 ],
// Array of full objects of heroes as fetched from the chain
// at the time of the "startBlock" value.
allHeroes: [{}]
// String representation of heroes optimized for questing, as an Array
heroesQuestAr: [
'id:49162 Stam:14 JPT100:37.76978J R:104 Q:Y',
'id:128862 Stam:14 JPT100:37.02038J R:94 Q:Y',
'id:146194 Stam:13 JPT100:36.27098J R:84 Q:Y',
'id:146091 Stam:13 JPT100:36.1211J R:82 Q:Y',
'id:159853 Stam:13 JPT100:35.82134J R:78 Q:Y',
'id:173313 Stam:26 JPT100:33.4982J R:47 Q:Y'
],
// String representation of heroes optimized for questing, as a string
heroesQuestStr: 'id:49162 Stam:14 JPT100:37.76978J R:104 Q:Y, id:128862 Stam:14 JPT100:37.02038J R:94 Q:Y, id:146194 Stam:13 JPT100:36.27098J R:84 Q:Y, id:146091 Stam:13 JPT100:36.1211J R:82 Q:Y, id:159853 Stam:13 JPT100:35.82134J R:78 Q:Y, id:173313 Stam:26 JPT100:33.4982J R:47 Q:Y',
}
Maintenance and Contributing
Adding a new network
Update the following modules:
- Create a new "addresses" module in
/src/constants
. - Create a new "gardens" module in
/src/constants
. - Populate the networks in the
/src/constants/quests.const.js
module. - Update the
/src/constants/constants.const.js
module. - Update the
/src/constants/all-items.const.js
module from DFK. - Update the
/src/ether/ether.ent.js
module. - Update the
/src/utils/network-helpers.js
module.
Update Node Version
When a new node version is available you need to updated it in the following:
/package.json
/.nvmrc
/.circleci/config.yml
Releasing
- Update the changelog bellow ("Release History").
- Ensure you are on master and your repository is clean.
- Type:
npm run release
for patch version jump.npm run release:minor
for minor version jump.npm run release:major
for major major jump.
Release History
- v1.7.2 , 19/Jul/2023
- Fixed retry function of
getPetChain()
.
- Fixed retry function of
- v1.7.1 , 08/Jun/2023
- Made pet-profession mapping all lowercase for consistency.
- v1.7.0 , 08/Jun/2023
- Now uses Hero V3 contract to fetch the hero object.
- New function for fetching normalized Pets:
getPetChain(chainId, petId)
. - New properties have been populated on the hero object for equipment and craft1 & craft2.
- New ABIs are available:
abiHeroesV3
andabiPetsV2
. - New Pet Mappings constants are available at
PET_MAPPINGS
.
- v1.6.2 , 03/Jun/2023
- Introduced the "doNotLogError" parameter on the retry error handler
- v1.6.1 , 29/May/2023
- Streamlined and exported
normalizeQuestV3()
.
- Streamlined and exported
- v1.6.0 , 29/May/2023
- Quest Core V3 general updates.
- Hero's "currentQuest" now represents the questInstanceId.
- Introduced the
resolveGarden(chainId, questType)
function to resolve Gardening quests from questType. - Introduced the
resolveTraining(questType)
function to resolve Training quests from questType. - Added new Quest Core V3 functions:
getQuestCoreV3()
.
- v1.4.14 , 19/May/2023
- Upgraded Duels to Season 4.
- Added Quest Core V3 ABI and constants.
- More robust
getProfileByAddressAnyChain()
function - will now return an object even if no result was found and will also attempt a second time to fetch the profile if the first one had no results.
- v1.4.13 , 18/Apr/2023
- Added all the newly revealed labels on hero attributes thanks to Zelys-DFKH.
- v1.4.12 , 18/Apr/2023
- Added labels on "statsUnknown1" and "statsUnknown2" thanks to Zelys-DFKH.
- v1.4.11 , 05/Apr/2023
- Added missing classes and a few other mappings of hero attributes.
- v1.4.10 , 28/Feb/2023
- Added the
ITEMS.POWER_TOKENS_PER_NETWORK
constant which is an enumeration of network ids mapped to their respective power token objects as represented from the official DFK data mapping "all-items.json".
- Added the
- v1.4.9 , 23/Feb/2023
- Added Duels Season 3 ABI.
- Replaced address of Duels on CV and SD2.
- v1.4.8 , 20/Feb/2023
- Fixed the quest-query module.
- v1.4.7 , 13/Feb/2023
- Added Harmony network on the
getProfileByAddressAnyChain()
function because there are still a lot of legacy profiles that have not been migrated. - By activating Harmony network again, profiles names got restored on the hero fetching functions, however, the "owner_address" field is no longer updated from the fetched profile as legacy Harmony profiles point to non-player addresses and corrupt the owner_address field.
- Added Harmony network on the
- v1.4.6 , 07/Feb/2023
- Removed Harmony from "Available networks".
- v1.4.5 , 01/Feb/2023
- Added DUEL address for Klaytn.
- v1.4.4 , 30/Jan/2023
- Added the
CONSTANTS.NETWORKS
enumeration to list all available network names.
- Added the
- v1.4.3 , 17/Jan/2023
- Added and exported the
abiHeroAuction
Hero Auction contract's ABI. - Added the
TOKEN_NAMES
enumeration of token names used by DegenKing. - Added the
PROFESSIONS_TO_QUEST_TYPES
enumeration on CONSTANTS that maps the PROFESSIONS enumeration to the QUEST_TYPES one.
- Added and exported the
- v1.4.2 , 16/Dec/2022
- Add Duels S2 contract address.
- v1.4.1 , 12/Dec/2022
- Will suppress known errors when querying for heroes on Klaytn.
- Fixed quest constants for Klaytn.
- v1.4.0 , 09/Dec/2022
- Added support for Klaytn and Serendale 2.0.
- Added a new index by name for all the DFK Raw items as
ITEMS.ITEMS_BY_NAME
.
- v1.3.8 , 08/Dec/2022
- Added Quest Core ABI v2.2 as
abiQuestCoreV2_2
.
- Added Quest Core ABI v2.2 as
- v1.3.7 , 15/Nov/2022
- Removed the wJewel-xJewel pool.
- v1.3.6 , 08/Nov/2022
- Refreshed the all-items list.
- Added script to normalize raw items as imported from DFK.
- v1.3.5 , 03/Nov/2022
- Fetching hero data will now use the
getProfileByAddressAnyChain()
to get profile information of the hero's account holder.
- Fetching hero data will now use the
- v1.3.4 , 31/Oct/2022
- Fixes
getProfileByAddressAnyChain()
.
- Fixes
- v1.3.3 , 31/Oct/2022
- Created the
getProfileByAddressAnyChain()
query to fetch a DFK profile regardless of network. - Added the profile contract address for DFK Chain.
- Fixed get heroes any chain function.
- Created the
- v1.3.2 , 10/Oct/2022
- Added Duels V2 ABI, exposed as
abiDuelsCoreV2
. - Added DUELS_CORE address on DFKC.
- Fixed
getHeroesAnyChain()
function.
- Added Duels V2 ABI, exposed as
- v1.3.1 , 23/Sep/2022
- Added Master Gardener DFK ABI
abiMasterGardenerDfk
. - Added new Gardens on CV.
- Added master gardener address on CV.
- Tweaked Current Rank algo.
- Added Master Gardener DFK ABI
- v1.3.0 , 21/Sep/2022
- Breaking Change For
decodeStatGenes()
anddecodeVisualGenes()
:- Fixed missing properties and labels from new CV classes and traits.
- Normalized even further the values, defined trait naming schemes and pattern.
- Will now also return all the recessive tiers (R1, R2, R3) for both visual and stat genes.
- Deprecated the
decodeRecessiveGeneAndNormalize()
function - no longer needed. - Lowercased all contract addresses of SD and CV.
- Breaking Change For
- v1.2.8 , 18/Sep/2022
- Added and exposed heroes and summoning ABIs V1 and V2 as:
abiHeroesV1
,abiHeroesV2
,abiSummonV1
,abiSummonV2
- Added and exposed heroes and summoning ABIs V1 and V2 as:
- v1.2.7 , 16/Sep/2022
- Indexed gardens by address to, available at
PoolsIndexedByAddress
(viagetPools(chainId)
).
- Indexed gardens by address to, available at
- v1.2.6 , 15/Sep/2022
- Added CV Gardening Pools constants.
- Implemented
getPools(chainId)
to get the appropriate pool constants. - Create reverse quest type lookup on
QUESTS.QUEST_TYPES_REV
. - More robust and faster
getHeroesAnyChain()
. - Renamed Quest ABI from
abiQuestCoreV2U
toabiQuestCoreV2_1
- theabiQuestCoreV2U
property has been deprecated and removed in future versions.
- v1.2.5 , 02/Sep/2022
- Mixed up LCK with INT TQ addresses on CV, fixed.
- v1.2.4 , 24/Aug/2022
- Will filter out zero addressed items when chain id present.
- Fixed duplicate item address with tears.
- v1.2.3 , 24/Aug/2022
- Added Gaia's tears address on harmony.
- Edited New Gaia's tears label to indicate it's the new one.
- v1.2.2 , 24/Aug/2022
- Added Items Bridge ABI and address.
- More explicit bootstraping of library.
- v1.2.1 , 13/Aug/2022
- Fixed TQ addresses of WIS and DEX on CV (was missing a digit).
- v1.2.0 , 11/Aug/2022
- Added new Cystal tokens of CV.
- Added Training Quest addresses and constants for CV.
- Optimized
getHeroChain()
to avoid performing owner and profile queries if those are already provided via the newly introduced propertiesownerAddress
andheroesOwner
. - Override of profile queries to only use Harmony as they are not yet deployed on CV.
- Introduced
archivalQuery
property when querying for heroes to be explicit about performing an archival query.
- v1.1.5 , 31/Jul/2022
- Add the Quest Core V2 Upgradeable and expose it as
abiQuestCoreV2U
. - Added Mining addresses and enums for CV.
- reverse error handler's logging: replace
doNotLogRetries
withlogRetries
.
- Add the Quest Core V2 Upgradeable and expose it as
- v1.1.4 , 29/Jul/2022
- Introduced property
doNotLogRetries
on thecatchErrorRetry()
error retry function, which will allow setting an error message for the ultimate error (after retries exchausted). - Added the
doNotLogRetries
on error-retry functions on all chain performing queries of this package to reduce error logs.
- Introduced property
- v1.1.3 , 28/Jul/2022
- Added and exported the Duels ABIs:
duelsCoreAbi
,duelsRaffleMasterAbi
,duelsGoldpotAbi
. - Added the Duels addresses:
DUELS_CORE
,RAFFLE_MASTER
,GOLD_POT
,RAFFLE_TICKETS
. - Added
DUEL_CONSTS
which contain necessary constant values to operate duels. - Fixed a major bug on error handling. Was awaiting for the retry vs returning the retry which resulted in results not being propagated when a query failed.
- Exposed the
renderParts(parts, isCli)
helper to render complicated and multiple-items log messages.
- Added and exported the Duels ABIs:
- v1.1.2 , 22/Jul/2022
- Tweaked
parseRpcError()
of error handler, to not show the raw TX data.
- Tweaked
- v1.1.1 , 20/Jul/2022
- Added stamina report on
stampot
mode forheroToStr()
. - Added new report
heroToStr()
named:stampotTiny
. - Export the Consumable ABI, available as:
abiConsumable
.
- Added stamina report on
- v1.1.0 , 19/Jul/2022
- BREAKING CHANGE The constant
ITEM_TYPES
has been renamed toITEMS
and all its available properties have been renamed to all capital letters and snakecased. - Added
ITEMS.filterItems()
function to filter all the available items. - Update DFK's "All Items" mappings and added CV items.
- BREAKING CHANGE The constant
- v1.0.6 , 19/Jul/2022
- Added account owner name on tiny and stampot rendition of heroToString().
- v1.0.5 , 19/Jul/2022
- Added Heroes Bridge ABi available as
abiBridgeHeroes
.
- Added Heroes Bridge ABi available as
- v1.0.4 , 17/Jul/2022
- Implemented
getHeroesAnyChain()
to query for heroes regardless on which chain they are on. - Added the
chainIdToRealm(chainId)
andgetBaseTokenName(chainId)
helpers. - Added bridge contract for both networks, available at
addresses.BRIDGE_HEROES
. - Added Meditation contract for DFKN.
- Implemented
- v1.0.3 , 15/Jul/2022
- Will now use the
blockTag
property on queries when only on harmony. - parseRpcError() now catches and handles the
CALL_EXCEPTION
error types.
- Will now use the
- v1.0.2 , 13/Jul/2022
- Lowercase all DFKN addresses.
- If quest not found, default to true on isQuestNew().
- v1.0.1 , 12/Jul/2022
- Fix: Added quest core contracts in "new quest" determination.
- v1.0.0 , 11/Jul/2022
- Implemented multi-chain functionality on all queries. Chain will be determined based on the
chainId
property passed as the provider object. - Added new function
getAddresses()
to get the appropriate addresses constants module. - All heroes fetched from the blockchain will now have new properties:
chainId
{number} The chain id the hero is at.realm
{string} The DFK Realm, one of "SD" or "CV".networkName
{string} Network the hero is on, one of "Harmony" or "DFKN".
- Added the
chainIdToNetwork(chainId)
andchainIdToRealm(chainId)
helpers. - Breaking Changes
- Signatures of all blockchain querying functions have changed, now require chainId definition.
- Function
fetchLockedJewelByOwnerChain()
has been removed and replaced byfetchLockedTokensByOwnerChain()
. - Broke out the "addresses" constants module into per network (for now Harmony and DFK Network) and standardised naming.
PROFESSIONS_TO_QUESTS
will be available from the address constants modules.- Removed the
ADDRESS
constant, has been replaced byADDRESSES_HARMONY
andADDRESSES_DFKN
. - Deprecated address constants in favor of new, standardized contract naming scheme that will be common across all network constants:
HEROES_NFT
,WELL_QUEST_ADDRESS_OLD
,QUEST_WISHING_WELL
,QUEST_FORAGING_OLD
,QUEST_FISHING_OLD
,QUEST_CONTRACT_OLD
,QUEST_CORE_V1_CONTRACT
,QUEST_CONTRACT
,QUEST_FORAGING
,QUEST_FISHING
,QUEST_GARDENING
,QUEST_MINING_GOLD
,QUEST_MINING_JEWEL
,SALE_ADDRESS
,SUMMON_ADDRESS
,NEW_SUMMON_CONTRACT
,MEDITATION_CONTRACT
,WELL_QUEST_ADDRESS
,CONSUMABLE_ADDRESS
,JEWELTOKEN
. - Configured RPC Provider Object must now contain the
chainId
property. - Address constant
AUCTION_SALES
is now capitalized for checksum and new constant created that is all lowercased:AUCTION_SALES_LOWERCASE
. - Constants
QUESTS
and grouped quest constants:QUESTS_GARDENING
,QUESTS_FORAGING
,QUESTS_FISHING
,QUESTS_MINING
, andQUESTS_TRAINING
can now be found from the 'QUEST' constants property.
- Implemented multi-chain functionality on all queries. Chain will be determined based on the
- v0.6.14, 28/Jun/2022
- Added the
calculateRequiredXp()
function. - Added the
stampot
option on heroToString();
- Added the
- v0.6.13, 27/Jun/2022
- Added
RUNES
constant.
- Added
- v0.6.12, 23/Jun/2022
- Added
calculateRuneRequirements()
function. - Add and expose
ITEM_TYPES
constants.
- Added
- v0.6.11, 22/Jun/2022
- More robust hero fetching functions.
- v0.6.10, 22/Jun/2022
- Ensure actual hero objects are returned from
fetchHeroesByOwnerChain()
.
- Ensure actual hero objects are returned from
- v0.6.9, 22/Jun/2022
- Added error handling on getHeroesChain() - more robust handling.
- v0.6.8, 22/Jun/2022
- Integrated all RPC fetching functions with catchErrorRetry function().
- v0.6.7, 22/Jun/2022
- Add the errorDelay() helper
- Better heuristics on RPC error parsing.
- v0.6.6, 22/Jun/2022
- Introduced
catchErrorRetry()
error handling helper. - Added
parseRpcError()
function.
- Introduced
- v0.6.5, 12/Jun/2022
- Added the
heroDbToNorm()
andheroesDbToNorm()
functions, which will be used in the future. - Added some rendering examples of hero-to-string.
- Added the
- v0.6.4, 12/Jun/2022
- A few more enumerations and constants of Quest types.
- v0.6.3, 11/Jun/2022
- Added the
MEDITATION_UPDATE_TYPE_MAP
on CONSTANTS.
- Added the
- v0.6.2, 11/Jun/2022
- Removed the greater crystals from the levelup set as they are too rare to be used and discord will only allow 25 choices (were 27 items with the greater crystals).
- v0.6.1, 10/Jun/2022
- Created the CRYSTALS constants.
- Added the
isQuesting
boolean property on the normalized hero object.
- v0.6.0, 06/Jun/2022
- Added the
queryQuest()
function to fetch data about questing. - Added the "quest" rendering in
heroToString()
function. - Now supports querying for a state of a hero in the past.
- Added the
- v0.5.12, 10/May/2022
- Added and exported
ALL_ITEMS
as fetched from DFK frontend source. - Added and exported
abiItems
(the Items ABI).
- Added and exported
- v0.5.11, 10/May/2022
- Fixed CV hero ranking.
- v0.5.10, 08/May/2022
- Fix ranking tests and lint ranking.
- v0.5.9, 08/May/2022
- More robust assistant when on rental, thanks Anton!
- v0.5.8, 08/May/2022
- Fixed spelling mistake for "seer", thanks cicles!
- Updated ranking system to incorporate seers and berserkers, thanks p2c2e!
- v0.5.7, 05/May/2022
- New classes, traits and choices added (Sheer & Berserker).
- v0.5.6, 03/May/2022
- Exposed the Hero Summoning Utility functions:
heroSummonCost()
,heroSummonMinTears()
,calculateHeroSummonCost()
,getHeroTier()
,getMinTears()
,getMaxTears()
,areHeroesRelated()
. - Upgraded all dependencies to latest.
- Exposed the Hero Summoning Utility functions:
- v0.5.5, 27/Apr/2022
- Fixed broken
isTrainingQuest()
. - Refactoring of address constants and new enumerations on constants.
- Fixed broken
- v0.5.4, 22/Apr/2022
- Introduced quest helpers
questResolve()
,isTrainingQuest()
andisQuestNew()
.
- Introduced quest helpers
- v0.5.3, 22/Apr/2022
- Added new questing contract addresses.
- v0.5.2, 15/Apr/2022
- Implement
queryAssistingAuctionsAllGql()
. - Expose
logality
.
- Implement
- v0.5.1, 15/Apr/2022
- Exposes
normalizeChainHero
function that normalizes raw hero blockchain data.
- Exposes
- v0.5.0, 06/Apr/2022
- Implements
consumePotion()
for potion consumpion by heroes. - Implements
consumableBalance()
for balance of potions.
- Implements
- v0.4.5, 05/Apr/2022
- Implemented
tiny
rendering of hero to string.
- Implemented
- v0.4.4, 30/Mar/2022
- Added "persist" argument on
getSalesAuctionGqlByAuctionId()
function.
- Added "persist" argument on
- v0.4.3, 25/Mar/2022
- Added function to fetch the locked jewel of an address
fetchLockedJewelByOwnerChain()
.
- Added function to fetch the locked jewel of an address
- v0.4.2, 24/Mar/2022
- Implemented the
fetchHeroIdsByOwnerChain()
function.
- Implemented the
- v0.4.0, 21/Mar/2022
- Renamed package from "dfk-hero" to "degenking".
- Renamed
getSalesData()
togetSalesAuctionChainByHeroId()
and deprecatedgetSalesData()
, which will be deleted on v0.5.0.
- v0.3.0, 19/Mar/2022
- Implemented and exported
getProfileByAddress()
function. - Fixed a minor issue on profile propagation when profile not found on hero query.
- Implemented and exported
- v0.2.2, 15/Mar/2022
- Export
decodeStatGenes()
anddecodeVisualGenes()
functions. - Implement and export
decodeRecessiveGeneAndNormalize()
function. - Will not break if hero belongs to an account that does not have a profile in-game.
- Fixed and tweaked tests.
- Export
- v0.2.1, 03/Mar/2022
- Uses profile V2.
- v0.2.0, 07/Feb/2022
- Exported new functions (
getSalesData()
,calculateRemainingStamina()
). - Will no longer log user fetching failure retries, will only log final failure.
- Exported new functions (
- v0.1.1, 02/Feb/2022
- Fixes weird require issue with React Applications and a date-fns function.
- Fixes bug in the
fetchHeroesByOwnerChain()
function.
- v0.1.0, 26/Jan/2022
- Big Bang
License
Copyright © Thanos Polychronakis and Authors, Licensed under ISC.
Tip Jar
thanpolas.eth - 0x67221b267cee49427bAa0974ceac988682192977