From ca626cb4ef303880b55c316849096c69e597db25 Mon Sep 17 00:00:00 2001 From: lllwvlvwlll Date: Mon, 24 Jan 2022 17:05:11 -0700 Subject: [PATCH] resolves #16 --- contracts/puppet/props.puppet.py | 230 +++++++--- scripts/initialize.js | 7 - scripts/mint_puppets.js | 28 +- sdk/dist/Generator.d.ts | 20 + sdk/dist/Generator.js | 79 ++++ sdk/dist/Generator.js.map | 1 + sdk/dist/Puppet.d.ts | 42 +- sdk/dist/Puppet.js | 88 ++-- sdk/dist/Puppet.js.map | 2 +- sdk/dist/api/generator.d.ts | 14 + sdk/dist/api/generator.js | 112 +++++ sdk/dist/api/generator.js.map | 1 + sdk/dist/api/index.d.ts | 2 +- sdk/dist/api/index.js | 2 +- sdk/dist/api/index.js.map | 2 +- sdk/dist/api/puppet.d.ts | 91 ++-- sdk/dist/api/puppet.js | 418 ++++++++---------- sdk/dist/api/puppet.js.map | 2 +- sdk/dist/helpers/helpers.js | 2 +- sdk/dist/helpers/helpers.js.map | 2 +- sdk/dist/index.d.ts | 2 +- sdk/dist/index.js | 2 +- sdk/dist/index.js.map | 2 +- sdk/dist/interface/interface.d.ts | 8 + sdk/src/Generator.ts | 2 +- sdk/src/Puppet.ts | 100 +++-- sdk/src/api/generator.ts | 1 - sdk/src/api/puppet.ts | 687 ++++++++++++------------------ sdk/src/helpers/helpers.ts | 2 +- sdk/src/interface/interface.ts | 9 + 30 files changed, 1071 insertions(+), 889 deletions(-) create mode 100644 sdk/dist/Generator.d.ts create mode 100644 sdk/dist/Generator.js create mode 100644 sdk/dist/Generator.js.map create mode 100644 sdk/dist/api/generator.d.ts create mode 100644 sdk/dist/api/generator.js create mode 100644 sdk/dist/api/generator.js.map diff --git a/contracts/puppet/props.puppet.py b/contracts/puppet/props.puppet.py index 92245b2..2960e29 100644 --- a/contracts/puppet/props.puppet.py +++ b/contracts/puppet/props.puppet.py @@ -14,6 +14,7 @@ # METADATA # ------------------------------------------- + @metadata def manifest_metadata() -> NeoMetadata: """ @@ -23,7 +24,7 @@ def manifest_metadata() -> NeoMetadata: meta.author = "COZ, Inc." meta.description = "A public NFT prop with base attributes and interactions" meta.email = "contact@coz.io" - meta.supported_standards= ["NEP-11"] + meta.supported_standards = ["NEP-11"] meta.permissions = [{"contract": "*", "methods": "*"}] return meta @@ -38,9 +39,6 @@ def manifest_metadata() -> NeoMetadata: # Number of decimal places TOKEN_DECIMALS = 0 -# The initial mint fee for a puppet -INITIAL_MINT_FEE: int = 100000000 # GAS - # ------------------------------------------- # Keys # ------------------------------------------- @@ -48,15 +46,15 @@ def manifest_metadata() -> NeoMetadata: # Stores the total token count TOKEN_COUNT: bytes = b'!TOKEN_COUNT' +# Epoch count +EPOCH_COUNT: bytes = b'EPOCH_COUNT' + # Stores the total account count ACCOUNT_COUNT: bytes = b'!ACCOUNT_COUNT' # Stores the current epoch being minted from CURRENT_EPOCH = b'!CURRENT_EPOCH' -# Stores the mint fee -MINT_FEE: bytes = b'!MINT_FEE' - # Stores whether the contract has been deployed(initialized) DEPLOYED = b'!deployed' @@ -301,13 +299,12 @@ def internal_deploy(owner: UInt160) -> bool: put(DEPLOYED, True) put(TOKEN_COUNT, 0) put(ACCOUNT_COUNT, 1) - put(MINT_FEE, INITIAL_MINT_FEE.to_bytes()) super_user_permissions: Dict[str, bool] = { 'offline_mint': True, 'contract_upgrade': True, 'set_mint_fee': True, - 'set_epoch': True, + 'create_epoch': True, 'set_permissions': True } user: User = User() @@ -341,9 +338,12 @@ def onNEP17Payment(from_address: UInt160, amount: int, data: Any): :param data: any pertinent data that might validate the transaction :type data: Any """ - fee: int = get_mint_fee() + epoch_id: bytes = cast(bytes, data) + epoch: Epoch = get_epoch(epoch_id) + + fee: int = epoch.get_mint_fee() if calling_script_hash == GAS and amount == fee: - internal_mint(from_address) + internal_mint(epoch_id, from_address) else: abort() @@ -367,9 +367,9 @@ def total_accounts() -> int: @public -def offline_mint(account: UInt160) -> bytes: +def offline_mint(epoch_id: bytes, account: UInt160) -> bytes: """ - mints a token + mints a token from an epoch :param account: the account to mint to :return: the token_id of the minted token :raise AssertionError: raised if the signer does not have `offline_mint` permission. @@ -377,7 +377,7 @@ def offline_mint(account: UInt160) -> bytes: tx = cast(Transaction, script_container) user: User = get_user(tx.sender) assert user.get_offline_mint(), "User Permission Denied" - return internal_mint(account) + return internal_mint(epoch_id, account) @public @@ -399,9 +399,10 @@ def update(script: bytes, manifest: bytes): @public -def set_mint_fee(amount: bytes) -> bool: +def set_mint_fee(epoch_id: bytes, amount: int) -> bool: """ Updates the mint fee for a puppet + :param epoch_id: the id of the epoch to set the mint fee for :param amount: the GAS cost to charge for the minting of a puppet :raise AssertionError: raised if the signer does not have the 'offline_mint' permission :return: A boolean indicating success @@ -409,39 +410,48 @@ def set_mint_fee(amount: bytes) -> bool: tx = cast(Transaction, script_container) user: User = get_user(tx.sender) assert user.get_set_mint_fee(), "User Permission Denied" - put(MINT_FEE, amount) - return True + epoch: Epoch = get_epoch(epoch_id) + x: bool = epoch.set_fee(amount) + save_epoch(epoch) -@public -def get_mint_fee() -> int: - return get(MINT_FEE).to_int() + return True -def internal_mint(owner: UInt160) -> bytes: +def internal_mint(epoch_id: bytes, owner: UInt160) -> bytes: """ Mint new token - internal + :param epoch_id: the epoch id to mint from :param owner: the address of the account that is minting token :type owner: UInt160 :return: token_id of the token minted """ + mint_epoch: Epoch = get_epoch(epoch_id) + assert mint_epoch.can_mint(), "No available puppets to mint in the selected epoch" + token_id: bytes = (totalSupply() + 1).to_bytes() new_puppet: Puppet = Puppet() - x: bool = new_puppet.generate(owner, token_id) + x: bool = new_puppet.generate(owner, token_id, epoch_id) + save_puppet(new_puppet) put(TOKEN_COUNT, token_id) - user: User = get_user(owner) - x:bool = user.add_owned_token(token_id) + x: int = mint_epoch.increment_supply() + save_epoch(mint_epoch) + + user: User = get_user(owner) + x: bool = user.add_owned_token(token_id) save_user(owner, user) post_transfer(None, owner, token_id, None) return token_id -############################# -############################# +# ############################# +# ########### User ############ +# ############################# + ACCOUNT_PREFIX = b'a' TOKEN_INDEX_PREFIX = b'i' @@ -455,7 +465,7 @@ def __init__(self): 'offline_mint': False, 'contract_upgrade': False, 'set_mint_fee': False, - 'set_epoch': False, + 'create_epoch': False, 'set_permissions': False } @@ -509,8 +519,8 @@ def get_contract_upgrade(self) -> bool: def get_set_mint_fee(self) -> bool: return self._permissions['set_mint_fee'] - def get_set_epoch(self) -> bool: - return self._permissions['set_epoch'] + def get_create_epoch(self) -> bool: + return self._permissions['create_epoch'] @public @@ -583,29 +593,128 @@ def set_user_permissions(user: UInt160, permissions: Dict[str, bool]) -> bool: return x +# ############################# +# ########## Epoch ############ +# ############################# +# ############################# + + +EPOCH_PREFIX = b'e' + + +class Epoch: + def __init__(self, generator_instance_id: bytes, mint_fee: int, max_supply: int, author: UInt160): + self._author: UInt160 = author + self._epoch_id: bytes = (total_epochs() + 1).to_bytes() + self._generator_instance_id: bytes = generator_instance_id + self._mint_fee: int = mint_fee + self._max_supply: int = max_supply + self._total_supply: int = 0 + + def can_mint(self) -> bool: + return self._max_supply > self.get_total_supply() + + def get_id(self) -> bytes: + return self._epoch_id + + def get_author(self) -> UInt160: + return self._author + + def get_generator_instance_id(self) -> bytes: + return self._generator_instance_id + + def get_mint_fee(self) -> int: + return self._mint_fee + + def get_max_supply(self) -> int: + return self._max_supply + + def get_total_supply(self) -> int: + return self._total_supply + + def export(self) -> Dict[str, Any]: + exported: Dict[str, Any] = { + "author": self._author, + "epochId": self._epoch_id, + "generatorInstanceId": self._generator_instance_id, + "mintFee": self._mint_fee, + "maxSupply": self._max_supply, + "totalSupply": self.get_total_supply() + } + return exported + + def increment_supply(self) -> int: + self._total_supply = self._total_supply + 1 + return self._total_supply + + def set_fee(self, new_fee: int) -> bool: + self._mint_fee = new_fee + return True + + @public -def set_current_epoch(epoch_id: bytes) -> bool: +def create_epoch(generator_instance_id: bytes, mint_fee: int, max_supply: int) -> int: + tx = cast(Transaction, script_container) + author: UInt160 = tx.sender + + user: User = get_user(author) + assert user.get_create_epoch(), "User Permission Denied" + + new_epoch: Epoch = Epoch(generator_instance_id, mint_fee, max_supply, author) + epoch_id: bytes = new_epoch.get_id() + epoch_id_int: int = epoch_id.to_int() + + save_epoch(new_epoch) + put(EPOCH_COUNT, epoch_id) + return epoch_id_int + + +@public +def get_epoch_json(epoch_id: bytes) -> Dict[str, Any]: + epoch: Epoch = get_epoch(epoch_id) + return epoch.export() + + +@public +def get_epoch(epoch_id: bytes) -> Epoch: + epoch_bytes: bytes = get_epoch_raw(epoch_id) + return cast(Epoch, deserialize(epoch_bytes)) + + +def get_epoch_raw(epoch_id: bytes) -> bytes: + return get(mk_epoch_key(epoch_id)) + + +@public +def total_epochs() -> int: """ - Sets the current epoch_id to mint from - :param epoch_id: The epoch_id to target when minting a puppet - :return: A boolean indicating success + Gets the total epoch count. No + + Epoch id is an incrementor so users can iterator from 1 - total_epochs() to dump every epoch on the contract. + + :return: the total token epochs deployed in the system. """ - tx = cast(Transaction, script_container) - user: User = get_user(tx.sender) - assert user.get_set_epoch(), "User Permission Denied" - put(CURRENT_EPOCH, epoch_id) + total: bytes = get(EPOCH_COUNT) + if len(total) == 0: + return 0 + return total.to_int() + + +def save_epoch(epoch: Epoch) -> bool: + epoch_id: bytes = epoch.get_id() + put(mk_epoch_key(epoch_id), serialize(epoch)) return True -@public -def get_current_epoch() -> int: - return get(CURRENT_EPOCH).to_int() +def mk_epoch_key(epoch_id: bytes) -> bytes: + return EPOCH_PREFIX + epoch_id -############################# -####### Puppet ########### -############################# -############################# +# ############################# +# ########## Puppet ########### +# ############################# +# ############################# + TOKEN_PREFIX = b't' @@ -639,7 +748,7 @@ class Puppet: def __init__(self): self._token_id: bytes = b'' - self._epoch_instance_id: bytes = b'' + self._epoch_id: bytes = b'' self._charisma: int = 0 self._constitution: int = 0 self._dexterity: int = 0 @@ -664,16 +773,17 @@ def export(self) -> Dict[str, Any]: 'owner': self._owner, 'tokenId': self._token_id, 'traits': self._traits, - 'epochInstanceId': self._epoch_instance_id + 'epochId': self._epoch_id } return exported - def generate(self, owner: UInt160, token_id: bytes) -> bool: + def generate(self, owner: UInt160, token_id: bytes, epoch_id: bytes) -> bool: """ Generates a puppet's core features @return: boolean indicating success """ # generate base attributes + target_epoch: Epoch = get_epoch(epoch_id) initial_roll_collection_id: int = 1 charisma: int = Collection.sample_from_collection(initial_roll_collection_id).to_int() @@ -698,11 +808,11 @@ def generate(self, owner: UInt160, token_id: bytes) -> bool: self._hit_die = hd # mint traits - instance_id: int = get_current_epoch() - instance_id_bytes: bytes = instance_id.to_bytes() - traits: Dict[str, Any] = Epoch.mint_from_instance(instance_id_bytes) + instance_id_bytes: bytes = target_epoch.get_generator_instance_id() + traits: Dict[str, Any] = Generator.mint_from_instance(instance_id_bytes) + self._traits = traits - self._epoch_instance_id = instance_id_bytes + self._epoch_id = epoch_id # Generate a puppet token_id and set the owner self._owner = owner @@ -762,8 +872,10 @@ def get_state(self) -> Dict[str, Any]: token_id_bytes: bytes = self._token_id token_id_int: int = token_id_bytes.to_int() token_id_string: str = itoa(token_id_int, 10) - instance_id_bytes: bytes = self._epoch_instance_id - instance_id_int: int = instance_id_bytes.to_int() + + epoch_id_bytes: bytes = self._epoch_id + epoch_id_int: int = epoch_id_bytes.to_int() + exported: Dict[str, Any] = { 'armorClass': self.get_armor_class(), 'attributes': { @@ -779,7 +891,7 @@ def get_state(self) -> Dict[str, Any]: 'owner': self._owner, 'tokenId': token_id_int, 'tokenURI': 'https://props.coz.io/puppets/' + token_id_string, - 'epochInstanceId': instance_id_int, + 'epochId': epoch_id_int, 'traits': self._traits, } return exported @@ -897,9 +1009,10 @@ def save_puppet(puppet: Puppet) -> bool: def mk_token_key(token_id: bytes) -> bytes: return TOKEN_PREFIX + token_id -############INTERFACES########### -############INTERFACES########### -############INTERFACES########### + +# ############INTERFACES########### +# ############INTERFACES########### +# ############INTERFACES########### @contract('0xa80d045ca80e0421aa855c3a000bfbe5dddadced') @@ -918,10 +1031,9 @@ def rand_between(start: int, end: int) -> int: pass -@contract('0xccff6257a59416028105709bc1e488a36ffeb9b2') +@contract('0x47f945b1028961b539ecebbce8eaf3ef1aa9c084') class Generator: @staticmethod def mint_from_instance(instance_id: bytes) -> Dict[str, Any]: pass - diff --git a/scripts/initialize.js b/scripts/initialize.js index b10620c..ac913b5 100644 --- a/scripts/initialize.js +++ b/scripts/initialize.js @@ -64,13 +64,6 @@ async function main(node, signer, timeConstant) { await sdk.helpers.sleep(timeConstant) result = await sdk.helpers.txDidComplete(node, txid, true) console.log(" response: ", result[0]) - - console.log("setting generator 1 as active") - txid = await puppet.setCurrentGenerator(1, signer) - await sdk.helpers.sleep(2000) - result = await sdk.helpers.txDidComplete(node, txid, true) - console.log(' result: ', result[0]) - } const network = JSON.parse(fs.readFileSync("default.neo-express").toString()); diff --git a/scripts/mint_puppets.js b/scripts/mint_puppets.js index 9e69d79..18f8ea1 100644 --- a/scripts/mint_puppets.js +++ b/scripts/mint_puppets.js @@ -6,6 +6,7 @@ const Neon = require("@cityofzion/neon-core") const NODE = 'http://localhost:50012' const TIME_CONSTANT = 4000 const PuppetArmySize = 100 +const EPOCH_TOTAL_SUPPLY = 100 //load any wallets and network settings we may want later (helpful if we're local) @@ -14,30 +15,47 @@ network.wallets.forEach( (walletObj) => { walletObj.wallet = new Neon.wallet.Account(walletObj.accounts[0]['private-key']) }) -async function main() { +async function main(timeConstant) { - let txid + let txid, result const signer = network.wallets[0].wallet const puppet = await new sdk.Puppet({node: NODE}) await puppet.init() + const generator = await new sdk.Generator({node: NODE}) + await generator.init() + console.log(`Build me an army worthy of ${signer.address} !!!`) console.log(`Minting ${PuppetArmySize} puppets!`) console.log('This may take a while, you can watch the action on neo-express.') + + console.log(`creating a generator instance with generator 1`) + txid = await generator.createInstance(1, signer) + await sdk.helpers.sleep(timeConstant) + result = await sdk.helpers.txDidComplete(NODE, txid, true) + console.log(' result: ', result[0]) + + console.log(`creating an epoch with generator instance ${result[0]}`) + txid = await puppet.createEpoch(result[0], 100000000, EPOCH_TOTAL_SUPPLY, signer) + await sdk.helpers.sleep(timeConstant) + result = await sdk.helpers.txDidComplete(NODE, txid) + console.log(' result: ', result[0]) + + const txids = [] for (let i = 0; i < PuppetArmySize; i++) { - txid = await puppet.offlineMint(signer.address, signer) + txid = await puppet.offlineMint(result[0], signer.address, signer) txids.push(txid) if (i % (PuppetArmySize / 100) === 0) { const totalSupply = await puppet.totalSupply() console.log(totalSupply, " PUPPETS!!!") } } - await sdk.helpers.sleep(TIME_CONSTANT) + await sdk.helpers.sleep(timeConstant) const totalSupply = await puppet.totalSupply() console.log('Puppet Supply: ', totalSupply) @@ -74,4 +92,4 @@ async function main() { fs.writeFileSync('traits.csv', csv) */ } -main() \ No newline at end of file +main(TIME_CONSTANT) \ No newline at end of file diff --git a/sdk/dist/Generator.d.ts b/sdk/dist/Generator.d.ts new file mode 100644 index 0000000..fbeafed --- /dev/null +++ b/sdk/dist/Generator.d.ts @@ -0,0 +1,20 @@ +import { rpc, wallet } from '@cityofzion/neon-core'; +import { GeneratorType, PropConstructorOptions } from "./interface"; +export declare class Generator { + private options; + private networkMagic; + constructor(options?: PropConstructorOptions); + init(): Promise; + get node(): rpc.RPCClient; + get scriptHash(): string; + createGenerator(generator: GeneratorType, signer: wallet.Account, timeConstantMS: number): Promise; + createGeneratorFromFile(path: string, signer: wallet.Account, timeConstantMS: number): Promise; + getGeneratorJSON(generatorId: number, signer?: wallet.Account): Promise; + getGeneratorInstanceJSON(instanceId: number, signer?: wallet.Account): Promise; + createInstance(generatorId: number, signer: wallet.Account): Promise; + mintFromGenerator(generatorId: number, signer: wallet.Account): Promise; + mintFromInstance(instanceId: number, signer: wallet.Account): Promise; + setInstanceAuthorizedUsers(instanceId: number, authorizedUsers: string[], signer: wallet.Account): Promise; + totalGenerators(signer?: wallet.Account): Promise; + totalGeneratorInstances(signer?: wallet.Account): Promise; +} diff --git a/sdk/dist/Generator.js b/sdk/dist/Generator.js new file mode 100644 index 0000000..2672cc5 --- /dev/null +++ b/sdk/dist/Generator.js @@ -0,0 +1,79 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Generator = void 0; +const lodash_1 = require("lodash"); +const neon_core_1 = require("@cityofzion/neon-core"); +const api_1 = require("./api"); +const helpers_1 = require("./helpers"); +const fs_1 = __importDefault(require("fs")); +const DEFAULT_OPTIONS = { + node: 'http://localhost:50012', + scriptHash: '0x47f945b1028961b539ecebbce8eaf3ef1aa9c084' +}; +class Generator { + constructor(options = {}) { + this.networkMagic = -1; + this.options = lodash_1.merge({}, DEFAULT_OPTIONS, options); + } + async init() { + const getVersionRes = await this.node.getVersion(); + this.networkMagic = getVersionRes.protocol.network; + } + get node() { + if (this.options.node) { + return new neon_core_1.rpc.RPCClient(this.options.node); + } + throw new Error('no node selected!'); + } + get scriptHash() { + if (this.options.scriptHash) { + return this.options.scriptHash; + } + throw new Error('node scripthash defined'); + } + async createGenerator(generator, signer, timeConstantMS) { + const txids = []; + let txid = await api_1.GeneratorAPI.createGenerator(this.node.url, this.networkMagic, this.scriptHash, generator.label, signer); + txids.push(txid); + await helpers_1.sleep(timeConstantMS); + const res = await helpers_1.txDidComplete(this.node.url, txid, false); + for await (let trait of generator.traits) { + txid = await api_1.GeneratorAPI.createTrait(this.node.url, this.networkMagic, this.scriptHash, res[0], trait.label, trait.slots, trait.traitLevels, signer); + txids.push(txid); + } + return txids; + } + async createGeneratorFromFile(path, signer, timeConstantMS) { + const localGenerator = JSON.parse(fs_1.default.readFileSync(path).toString()); + return this.createGenerator(localGenerator, signer, timeConstantMS); + } + async getGeneratorJSON(generatorId, signer) { + return api_1.GeneratorAPI.getGeneratorJSON(this.node.url, this.networkMagic, this.scriptHash, generatorId, signer); + } + async getGeneratorInstanceJSON(instanceId, signer) { + return api_1.GeneratorAPI.getGeneratorInstanceJSON(this.node.url, this.networkMagic, this.scriptHash, instanceId, signer); + } + async createInstance(generatorId, signer) { + return api_1.GeneratorAPI.createInstance(this.node.url, this.networkMagic, this.scriptHash, generatorId, signer); + } + async mintFromGenerator(generatorId, signer) { + return api_1.GeneratorAPI.mintFromGenerator(this.node.url, this.networkMagic, this.scriptHash, generatorId, signer); + } + async mintFromInstance(instanceId, signer) { + return api_1.GeneratorAPI.mintFromInstance(this.node.url, this.networkMagic, this.scriptHash, instanceId, signer); + } + async setInstanceAuthorizedUsers(instanceId, authorizedUsers, signer) { + return api_1.GeneratorAPI.setInstanceAuthorizedUsers(this.node.url, this.networkMagic, this.scriptHash, instanceId, authorizedUsers, signer); + } + async totalGenerators(signer) { + return api_1.GeneratorAPI.totalGenerators(this.node.url, this.networkMagic, this.scriptHash, signer); + } + async totalGeneratorInstances(signer) { + return api_1.GeneratorAPI.totalGeneratorInstances(this.node.url, this.networkMagic, this.scriptHash, signer); + } +} +exports.Generator = Generator; +//# sourceMappingURL=Generator.js.map \ No newline at end of file diff --git a/sdk/dist/Generator.js.map b/sdk/dist/Generator.js.map new file mode 100644 index 0000000..3c8a8d2 --- /dev/null +++ b/sdk/dist/Generator.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Generator.js","sourceRoot":"","sources":["../src/Generator.ts"],"names":[],"mappings":";;;;;;AAAA,mCAA8B;AAC9B,qDAAiD;AACjD,+BAAkC;AAElC,uCAA+C;AAC/C,4CAAoB;AAEpB,MAAM,eAAe,GAA2B;IAC9C,IAAI,EAAE,wBAAwB;IAC9B,UAAU,EAAE,4CAA4C;CACzD,CAAA;AAED,MAAa,SAAS;IAIpB,YAAY,UAAkC,EAAE;QAFxC,iBAAY,GAAW,CAAC,CAAC,CAAA;QAG/B,IAAI,CAAC,OAAO,GAAG,cAAK,CAAC,EAAE,EAAE,eAAe,EAAE,OAAO,CAAC,CAAA;IACpD,CAAC;IAED,KAAK,CAAC,IAAI;QACR,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAA;QAClD,IAAI,CAAC,YAAY,GA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AAC,CAAA;IAC/G,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,UAAkB,EAAE,MAAsB;QAC/D,OAAO,kBAAY,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,CAAC,CAAA;IAC7G,CAAC;IAED,KAAK,CAAC,0BAA0B,CAAC,UAAkB,EAAE,eAAyB,EAAE,MAAsB;QACpG,OAAO,kBAAY,CAAC,0BAA0B,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,CAAC,CAAA;IACxI,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,MAAuB;QAC3C,OAAO,kBAAY,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;IAChG,CAAC;IAED,KAAK,CAAC,uBAAuB,CAAC,MAAuB;QACnD,OAAO,kBAAY,CAAC,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;IACxG,CAAC;CACF;AA5ED,8BA4EC"} \ No newline at end of file diff --git a/sdk/dist/Puppet.d.ts b/sdk/dist/Puppet.d.ts index 0ec601c..431dac3 100644 --- a/sdk/dist/Puppet.d.ts +++ b/sdk/dist/Puppet.d.ts @@ -1,5 +1,5 @@ import { rpc, wallet } from '@cityofzion/neon-core'; -import { PropConstructorOptions } from "./interface"; +import { EpochType, PropConstructorOptions, PuppetType } from "./interface"; export declare class Puppet { private options; private networkMagic; @@ -7,23 +7,25 @@ export declare class Puppet { init(): Promise; get node(): rpc.RPCClient; get scriptHash(): string; - balanceOf(address: string): Promise; - decimals(): Promise; - deploy(signer: wallet.Account): Promise; - getAttributeMod(attributeValue: number): Promise; - getPuppetRaw(tokenId: string): Promise; - ownerOf(tokenId: number): Promise; - offlineMint(target: string, signer: wallet.Account): Promise; - properties(tokenId: number): Promise; - purchase(signer: wallet.Account): Promise; - setMintFee(fee: number, signer: wallet.Account): Promise; - symbol(): Promise; - getMintFee(): Promise; - tokens(): Promise; - tokensOf(address: string): Promise; - transfer(to: string, tokenId: number, signer: wallet.Account, data: any): Promise; - totalSupply(): Promise; - update(script: string, manifest: string, signer: wallet.Account): Promise; - setCurrentEpoch(epoch_id: number, signer: wallet.Account): Promise; - getCurrentEpoch(): Promise; + balanceOf(address: string, signer?: wallet.Account): Promise; + createEpoch(generatorId: number, mintFee: number, maxSupply: number, signer: wallet.Account): Promise; + decimals(signer?: wallet.Account): Promise; + deploy(signer: wallet.Account): Promise; + getAttributeMod(attributeValue: number, signer?: wallet.Account): Promise; + getEpochJSON(epochId: number, signer?: wallet.Account): Promise; + getPuppetJSON(tokenId: number, signer?: wallet.Account): Promise; + getPuppetRaw(tokenId: string, signer?: wallet.Account): Promise; + ownerOf(tokenId: number, signer?: wallet.Account): Promise; + offlineMint(epochId: number, owner: string, signer: wallet.Account): Promise; + properties(tokenId: number, signer?: wallet.Account): Promise; + purchase(epochId: number, signer: wallet.Account): Promise; + setMintFee(epochId: number, fee: number, signer: wallet.Account): Promise; + symbol(signer?: wallet.Account): Promise; + tokens(signer?: wallet.Account): Promise; + tokensOf(address: string, signer?: wallet.Account): Promise; + totalAccounts(signer?: wallet.Account): Promise; + totalEpochs(signer?: wallet.Account): Promise; + totalSupply(signer?: wallet.Account): Promise; + transfer(to: string, tokenId: number, signer: wallet.Account, data: any): Promise; + update(script: string, manifest: string, signer: wallet.Account): Promise; } diff --git a/sdk/dist/Puppet.js b/sdk/dist/Puppet.js index 85f46f1..960a6fd 100644 --- a/sdk/dist/Puppet.js +++ b/sdk/dist/Puppet.js @@ -7,7 +7,7 @@ const api_1 = require("./api"); const neon_js_1 = require("@cityofzion/neon-js"); const DEFAULT_OPTIONS = { node: 'http://localhost:50012', - scriptHash: '0xf112cb2412173f890d50e6996b3e65c85f85636a' + scriptHash: '0x58a217883a7771a730d5fd4feb336536f982ad0d' }; class Puppet { constructor(options = {}) { @@ -30,78 +30,88 @@ class Puppet { } throw new Error('node scripthash defined'); } - async balanceOf(address) { - return api_1.PuppetAPI.balanceOf(this.node.url, this.networkMagic, this.scriptHash, address); + async balanceOf(address, signer) { + return api_1.PuppetAPI.balanceOf(this.node.url, this.networkMagic, this.scriptHash, address, signer); } - async decimals() { - return api_1.PuppetAPI.decimals(this.node.url, this.networkMagic, this.scriptHash); + async createEpoch(generatorId, mintFee, maxSupply, signer) { + return api_1.PuppetAPI.createEpoch(this.node.url, this.networkMagic, this.scriptHash, generatorId, mintFee, maxSupply, signer); + } + async decimals(signer) { + return api_1.PuppetAPI.decimals(this.node.url, this.networkMagic, this.scriptHash, signer); } async deploy(signer) { return api_1.PuppetAPI.deploy(this.node.url, this.networkMagic, this.scriptHash, signer); } - async getAttributeMod(attributeValue) { - return api_1.PuppetAPI.getAttributeMod(this.node.url, this.networkMagic, this.scriptHash, attributeValue); + async getAttributeMod(attributeValue, signer) { + return api_1.PuppetAPI.getAttributeMod(this.node.url, this.networkMagic, this.scriptHash, attributeValue, signer); + } + async getEpochJSON(epochId, signer) { + return api_1.PuppetAPI.getEpochJSON(this.node.url, this.networkMagic, this.scriptHash, epochId, signer); + } + async getPuppetJSON(tokenId, signer) { + return api_1.PuppetAPI.getPuppetJSON(this.node.url, this.networkMagic, this.scriptHash, tokenId, signer); } - async getPuppetRaw(tokenId) { - return api_1.PuppetAPI.getPuppetRaw(this.node.url, this.networkMagic, this.scriptHash, tokenId); + async getPuppetRaw(tokenId, signer) { + return api_1.PuppetAPI.getPuppetRaw(this.node.url, this.networkMagic, this.scriptHash, tokenId, signer); } - async ownerOf(tokenId) { - return api_1.PuppetAPI.ownerOf(this.node.url, this.networkMagic, this.scriptHash, tokenId); + async ownerOf(tokenId, signer) { + return api_1.PuppetAPI.ownerOf(this.node.url, this.networkMagic, this.scriptHash, tokenId, signer); } - async offlineMint(target, signer) { - return api_1.PuppetAPI.offlineMint(this.node.url, this.networkMagic, this.scriptHash, target, signer); + async offlineMint(epochId, owner, signer) { + return api_1.PuppetAPI.offlineMint(this.node.url, this.networkMagic, this.scriptHash, epochId, owner, signer); } - async properties(tokenId) { - return api_1.PuppetAPI.properties(this.node.url, this.networkMagic, this.scriptHash, tokenId); + async properties(tokenId, signer) { + return api_1.PuppetAPI.properties(this.node.url, this.networkMagic, this.scriptHash, tokenId, signer); } - async purchase(signer) { + async purchase(epochId, signer) { const method = "transfer"; const GASScriptHash = "0xd2a4cff31913016155e38e474a2c06d08be276cf"; - const purchasePrice = await api_1.PuppetAPI.getMintFee(this.node.url, this.networkMagic, this.scriptHash); + const epoch = await api_1.PuppetAPI.getEpochJSON(this.node.url, this.networkMagic, this.scriptHash, epochId); + const EpochTyped = epoch; + if (EpochTyped.totalSupply === EpochTyped.maxSupply) { + throw new Error(`Epoch is out of Puppets: ${EpochTyped.totalSupply} / ${EpochTyped.maxSupply}`); + } + const purchasePrice = EpochTyped.mintFee; const params = [ neon_js_1.sc.ContractParam.hash160(signer.address), neon_js_1.sc.ContractParam.hash160(this.scriptHash), neon_js_1.sc.ContractParam.integer(purchasePrice), - neon_js_1.sc.ContractParam.any() + neon_js_1.sc.ContractParam.integer(epochId) ]; try { - const res = await api_1.NeoInterface.publishInvoke(this.node.url, this.networkMagic, GASScriptHash, method, params, signer); - return res; + return await api_1.NeoInterface.publishInvoke(this.node.url, this.networkMagic, GASScriptHash, method, params, signer); } catch (e) { throw new Error("Something went wrong: " + e.message); } } - async setMintFee(fee, signer) { - return api_1.PuppetAPI.setMintFee(this.node.url, this.networkMagic, this.scriptHash, fee, signer); + async setMintFee(epochId, fee, signer) { + return api_1.PuppetAPI.setMintFee(this.node.url, this.networkMagic, this.scriptHash, epochId, fee, signer); + } + async symbol(signer) { + return api_1.PuppetAPI.symbol(this.node.url, this.networkMagic, this.scriptHash, signer); } - async symbol() { - return api_1.PuppetAPI.symbol(this.node.url, this.networkMagic, this.scriptHash); + async tokens(signer) { + return api_1.PuppetAPI.tokens(this.node.url, this.networkMagic, this.scriptHash, signer); } - async getMintFee() { - return api_1.PuppetAPI.getMintFee(this.node.url, this.networkMagic, this.scriptHash); + async tokensOf(address, signer) { + return api_1.PuppetAPI.tokensOf(this.node.url, this.networkMagic, this.scriptHash, address, signer); } - async tokens() { - return api_1.PuppetAPI.tokens(this.node.url, this.networkMagic, this.scriptHash); + async totalAccounts(signer) { + return api_1.PuppetAPI.totalAccounts(this.node.url, this.networkMagic, this.scriptHash, signer); } - async tokensOf(address) { - return api_1.PuppetAPI.tokensOf(this.node.url, this.networkMagic, this.scriptHash, address); + async totalEpochs(signer) { + return api_1.PuppetAPI.totalEpochs(this.node.url, this.networkMagic, this.scriptHash, signer); + } + async totalSupply(signer) { + return api_1.PuppetAPI.totalSupply(this.node.url, this.networkMagic, this.scriptHash, signer); } async transfer(to, tokenId, signer, data) { return api_1.PuppetAPI.transfer(this.node.url, this.networkMagic, this.scriptHash, to, tokenId, signer, data); } - async totalSupply() { - return api_1.PuppetAPI.totalSupply(this.node.url, this.networkMagic, this.scriptHash); - } async update(script, manifest, signer) { return api_1.PuppetAPI.update(this.node.url, this.networkMagic, this.scriptHash, script, manifest, signer); } - async setCurrentEpoch(epoch_id, signer) { - return api_1.PuppetAPI.setCurrentEpoch(this.node.url, this.networkMagic, this.scriptHash, epoch_id, signer); - } - async getCurrentEpoch() { - return api_1.PuppetAPI.getCurrentEpoch(this.node.url, this.networkMagic, this.scriptHash); - } } exports.Puppet = Puppet; //# sourceMappingURL=Puppet.js.map \ No newline at end of file diff --git a/sdk/dist/Puppet.js.map b/sdk/dist/Puppet.js.map index ecedfe3..36b95c6 100644 --- a/sdk/dist/Puppet.js.map +++ b/sdk/dist/Puppet.js.map @@ -1 +1 @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AU,EAAE,OAAe,EAAE,MAAsB,EAAE,IAAS;QAC3E,OAAO,eAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,UAAU,EAAC,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,CAAA;IACxG,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,MAAc,EAAE,QAAgB,EAAE,MAAsB;QACnE,OAAO,eAAS,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;IACtG,CAAC;CAEF;AA1ID,wBA0IC"} \ No newline at end of file diff --git a/sdk/dist/api/generator.d.ts b/sdk/dist/api/generator.d.ts new file mode 100644 index 0000000..6720fef --- /dev/null +++ b/sdk/dist/api/generator.d.ts @@ -0,0 +1,14 @@ +import { wallet } from "@cityofzion/neon-core"; +import { GeneratorType, TraitLevel } from "../interface"; +export declare class GeneratorAPI { + static createGenerator(node: string, networkMagic: number, contractHash: string, label: string, signer: wallet.Account): Promise; + static createInstance(node: string, networkMagic: number, contractHash: string, generatorId: number, signer: wallet.Account): Promise; + static createTrait(node: string, networkMagic: number, contractHash: string, generatorId: number, label: string, slots: number, levels: TraitLevel[], signer: wallet.Account): Promise; + static getGeneratorJSON(node: string, networkMagic: number, contractHash: string, generatorId: number, signer?: wallet.Account): Promise; + static getGeneratorInstanceJSON(node: string, networkMagic: number, contractHash: string, instanceId: number, signer?: wallet.Account): Promise; + static mintFromGenerator(node: string, networkMagic: number, contractHash: string, generatorId: number, signer: wallet.Account): Promise; + static mintFromInstance(node: string, networkMagic: number, contractHash: string, instanceId: number, signer: wallet.Account): Promise; + static setInstanceAuthorizedUsers(node: string, networkMagic: number, contractHash: string, instanceId: number, authorizedUsers: string[], signer: wallet.Account): Promise; + static totalGenerators(node: string, networkMagic: number, contractHash: string, signer?: wallet.Account): Promise; + static totalGeneratorInstances(node: string, networkMagic: number, contractHash: string, signer?: wallet.Account): Promise; +} diff --git a/sdk/dist/api/generator.js b/sdk/dist/api/generator.js new file mode 100644 index 0000000..46c5301 --- /dev/null +++ b/sdk/dist/api/generator.js @@ -0,0 +1,112 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.GeneratorAPI = void 0; +const neon_js_1 = require("@cityofzion/neon-js"); +const interface_1 = require("../interface"); +const helpers_1 = require("../helpers"); +class GeneratorAPI { + static async createGenerator(node, networkMagic, contractHash, label, signer) { + const method = "create_generator"; + const param = [ + neon_js_1.sc.ContractParam.string(label) + ]; + return await helpers_1.variableInvoke(node, networkMagic, contractHash, method, param, signer); + } + static async createInstance(node, networkMagic, contractHash, generatorId, signer) { + const method = "create_instance"; + const param = [ + neon_js_1.sc.ContractParam.integer(generatorId) + ]; + return await helpers_1.variableInvoke(node, networkMagic, contractHash, method, param, signer); + } + static async createTrait(node, networkMagic, contractHash, generatorId, label, slots, levels, signer) { + const method = "create_trait"; + const traitLevelsFormatted = levels.map((traitLevel) => { + const traitPointers = traitLevel.traits.map((traitEvent) => { + //need to also have the type in here + switch (traitEvent.type) { + case interface_1.EventTypeEnum.CollectionPointer: + const args = traitEvent.args; + //console.log(traitEvent.type, args.collectionId, args.index) + return neon_js_1.sc.ContractParam.array(neon_js_1.sc.ContractParam.integer(traitEvent.type), neon_js_1.sc.ContractParam.integer(traitEvent.maxMint), neon_js_1.sc.ContractParam.array(neon_js_1.sc.ContractParam.integer(args.collectionId), neon_js_1.sc.ContractParam.integer(args.index))); + default: + throw new Error("unrecognized trait event type"); + } + }); + return neon_js_1.sc.ContractParam.array(neon_js_1.sc.ContractParam.integer(traitLevel.dropScore), neon_js_1.sc.ContractParam.array(...traitPointers)); + }); + const param = [ + neon_js_1.sc.ContractParam.integer(generatorId), + neon_js_1.sc.ContractParam.string(label), + neon_js_1.sc.ContractParam.integer(slots), + neon_js_1.sc.ContractParam.array(...traitLevelsFormatted) + ]; + return await helpers_1.variableInvoke(node, networkMagic, contractHash, method, param, signer); + } + //getGenerator + static async getGeneratorJSON(node, networkMagic, contractHash, generatorId, signer) { + const method = "get_generator_json"; + const param = [ + neon_js_1.sc.ContractParam.integer(generatorId) + ]; + const res = await helpers_1.variableInvoke(node, networkMagic, contractHash, method, param, signer); + if (signer) { + return res; + } + return helpers_1.parseToJSON(res[0].value); + } + //getGeneratorInstance + static async getGeneratorInstanceJSON(node, networkMagic, contractHash, instanceId, signer) { + const method = "get_generator_instance_json"; + const param = [ + neon_js_1.sc.ContractParam.integer(instanceId) + ]; + const res = await helpers_1.variableInvoke(node, networkMagic, contractHash, method, param, signer); + if (signer) { + return res; + } + return helpers_1.parseToJSON(res[0].value); + } + static async mintFromGenerator(node, networkMagic, contractHash, generatorId, signer) { + const method = "mint_from_generator"; + const param = [ + neon_js_1.sc.ContractParam.integer(generatorId) + ]; + return await helpers_1.variableInvoke(node, networkMagic, contractHash, method, param, signer); + } + static async mintFromInstance(node, networkMagic, contractHash, instanceId, signer) { + const method = "mint_from_instance"; + const param = [ + neon_js_1.sc.ContractParam.integer(instanceId) + ]; + return await helpers_1.variableInvoke(node, networkMagic, contractHash, method, param, signer); + } + static async setInstanceAuthorizedUsers(node, networkMagic, contractHash, instanceId, authorizedUsers, signer) { + const method = "set_instance_authorized_users"; + const usersFormatted = authorizedUsers.map((user) => { + return neon_js_1.sc.ContractParam.hash160(user); + }); + const param = [ + neon_js_1.sc.ContractParam.array(...usersFormatted) + ]; + return await helpers_1.variableInvoke(node, networkMagic, contractHash, method, param, signer); + } + static async totalGenerators(node, networkMagic, contractHash, signer) { + const method = "total_generators"; + const res = await helpers_1.variableInvoke(node, networkMagic, contractHash, method, [], signer); + if (signer) { + return res; + } + return parseInt(res[0].value); + } + static async totalGeneratorInstances(node, networkMagic, contractHash, signer) { + const method = "total_generator_instances"; + const res = await helpers_1.variableInvoke(node, networkMagic, contractHash, method, [], signer); + if (signer) { + return res; + } + return parseInt(res[0].value); + } +} +exports.GeneratorAPI = GeneratorAPI; +//# sourceMappingURL=generator.js.map \ No newline at end of file diff --git a/sdk/dist/api/generator.js.map b/sdk/dist/api/generator.js.map new file mode 100644 index 0000000..aa667aa --- /dev/null +++ b/sdk/dist/api/generator.js.map @@ -0,0 +1 @@ +{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../src/api/generator.ts"],"names":[],"mappings":";;;AAAA,iDAAuC;AAEvC,4CAAmG;AACnG,wCAAuD;AAGvD,MAAa,YAAY;IAEvB,MAAM,CAAC,KAAK,CAAC,eAAe,CAC1B,IAAY,EACZ,YAAoB,EACpB,YAAoB,EACpB,KAAa,EACb,MAAsB;QAEtB,MAAM,MAAM,GAAG,kBAAkB,CAAC;QAElC,MAAM,KAAK,GAAG;YACZ,YAAE,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC;SAC/B,CAAA;QAED,OAAO,MAAM,wBAAc,CAAC,IAAI,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;IACtF,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,cAAc,CACzB,IAAY,EACZ,YAAoB,EACpB,YAAoB,EACpB,WAAmB,EACnB,MAAsB;QAEtB,MAAM,MAAM,GAAG,iBAAiB,CAAC;QAEjC,MAAM,KAAK,GAAG;YACZ,YAAE,CAAC,aAAa,CAAC,OAAO,CAAC,WAAW,CAAC;SACtC,CAAA;QAED,OAAO,MAAM,wBAAc,CAAC,IAAI,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;IACtF,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,WAAW,CACtB,IAAY,EACZ,YAAoB,EACpB,YAAoB,EACpB,WAAmB,EACnB,KAAa,EACb,KAAa,EACb,MAAoB,EACpB,MAAsB;QAEtB,MAAM,MAAM,GAAG,cAAc,CAAC;Q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B,MAAuB;QAEvB,MAAM,MAAM,GAAG,kBAAkB,CAAC;QAElC,MAAM,GAAG,GAAG,MAAM,wBAAc,CAAC,IAAI,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,CAAA;QACtF,IAAI,MAAM,EAAE;YACV,OAAO,GAAG,CAAA;SACX;QACD,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAe,CAAC,CAAC;IAC1C,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,uBAAuB,CAClC,IAAY,EACZ,YAAoB,EACpB,YAAoB,EACpB,MAAuB;QAEvB,MAAM,MAAM,GAAG,2BAA2B,CAAC;QAE3C,MAAM,GAAG,GAAG,MAAM,wBAAc,CAAC,IAAI,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,CAAA;QACtF,IAAI,MAAM,EAAE;YACV,OAAO,GAAG,CAAA;SACX;QACD,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAe,CAAC,CAAC;IAC1C,CAAC;CACF;AAhND,oCAgNC"} \ No newline at end of file diff --git a/sdk/dist/api/index.d.ts b/sdk/dist/api/index.d.ts index abba1d0..f7d0729 100644 --- a/sdk/dist/api/index.d.ts +++ b/sdk/dist/api/index.d.ts @@ -2,4 +2,4 @@ export * from "./dice"; export * from "./puppet"; export * from "./interface"; export * from "./collection"; -export * from "./epoch"; +export * from "./generator"; diff --git a/sdk/dist/api/index.js b/sdk/dist/api/index.js index 0d5fa00..8d5138b 100644 --- a/sdk/dist/api/index.js +++ b/sdk/dist/api/index.js @@ -14,5 +14,5 @@ __exportStar(require("./dice"), exports); __exportStar(require("./puppet"), exports); __exportStar(require("./interface"), exports); __exportStar(require("./collection"), exports); -__exportStar(require("./epoch"), exports); +__exportStar(require("./generator"), exports); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/sdk/dist/api/index.js.map b/sdk/dist/api/index.js.map index 8e185ee..890b554 100644 --- a/sdk/dist/api/index.js.map +++ b/sdk/dist/api/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAsB;AACtB,2CAAyB;AACzB,8CAA2B;AAC3B,+CAA4B;AAC5B,0CAAuB"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAsB;AACtB,2CAAyB;AACzB,8CAA2B;AAC3B,+CAA4B;AAC5B,8CAA2B"} \ No newline at end of file diff --git a/sdk/dist/api/puppet.d.ts b/sdk/dist/api/puppet.d.ts index cafad03..cf27dd1 100644 --- a/sdk/dist/api/puppet.d.ts +++ b/sdk/dist/api/puppet.d.ts @@ -1,93 +1,108 @@ import { wallet } from "@cityofzion/neon-core"; -import { PuppetType } from "../interface"; +import { EpochType, PuppetType } from "../interface"; export declare class PuppetAPI { /** - * Returns the token symbol + * Returns the balance of an account * @param node * @param networkMagic * @param contractHash + * @param address + * @param signer */ - static symbol(node: string, networkMagic: number, contractHash: string): Promise; + static balanceOf(node: string, networkMagic: number, contractHash: string, address: string, signer?: wallet.Account): Promise; + static createEpoch(node: string, networkMagic: number, contractHash: string, generatorInstanceId: number, mintFee: number, maxSupply: number, signer: wallet.Account): Promise; /** * Returns the decimals of the token * @param node * @param networkMagic * @param contractHash + * @param signer */ - static decimals(node: string, networkMagic: number, contractHash: string): Promise; + static decimals(node: string, networkMagic: number, contractHash: string, signer?: wallet.Account): Promise; /** - * Returns the total supply of the token + * Initializes the smart contract on first deployment (REQUIRED) * @param node * @param networkMagic * @param contractHash + * @param signer The signing account, which will become the first admin if upgrade == false */ - static totalSupply(node: string, networkMagic: number, contractHash: string): Promise; + static deploy(node: string, networkMagic: number, contractHash: string, signer: wallet.Account): Promise; + static getAttributeMod(node: string, networkMagic: number, contractHash: string, attributeValue: number, signer?: wallet.Account): Promise; + static getPuppetJSON(node: string, networkMagic: number, contractHash: string, tokenId: number, signer?: wallet.Account): Promise; + static getPuppetRaw(node: string, networkMagic: number, contractHash: string, tokenId: string, signer?: wallet.Account): Promise; /** - * Returns the balance of an account + * Gets the owner account of a tokenId * @param node * @param networkMagic * @param contractHash - * @param address + * @param tokenId The tokenId to return the owner of + * @param signer */ - static balanceOf(node: string, networkMagic: number, contractHash: string, address: string): Promise; + static ownerOf(node: string, networkMagic: number, contractHash: string, tokenId: number, signer?: wallet.Account): Promise; + static offlineMint(node: string, networkMagic: number, contractHash: string, epochId: number, owner: string, signer: wallet.Account): Promise; /** - * Gets an array of strings(tokenId) owned by an address + * Gets the properties of a token * @param node * @param networkMagic * @param contractHash - * @param address The string formatted address of an account + * @param tokenId The tokenId of the token being requested + * @param signer An optional signer. Populating this value will publish a transaction and return a txid */ - static tokensOf(node: string, networkMagic: number, contractHash: string, address: string): Promise; + static properties(node: string, networkMagic: number, contractHash: string, tokenId: number, signer?: wallet.Account): Promise; + static setMintFee(node: string, networkMagic: number, contractHash: string, epochId: number, fee: number, signer: wallet.Account): Promise; /** - * Transfers a token to another account + * Returns the token symbol * @param node * @param networkMagic * @param contractHash - * @param toAddress - * @param tokenId * @param signer - * @param data */ - static transfer(node: string, networkMagic: number, contractHash: string, toAddress: string, tokenId: number, signer: wallet.Account, data?: any): Promise; + static symbol(node: string, networkMagic: number, contractHash: string, signer?: wallet.Account): Promise; /** - * Gets the owner account of a tokenId + * Gets and array of strings(tokenIds) representing all the tokens associated with the contract * @param node * @param networkMagic * @param contractHash - * @param tokenId The tokenId to return the owner of + * @param signer */ - static ownerOf(node: string, networkMagic: number, contractHash: string, tokenId: number): Promise; + static tokens(node: string, networkMagic: number, contractHash: string, signer?: wallet.Account): Promise; /** - * Gets and array of strings(tokenIds) representing all the tokens associated with the contract + * Gets an array of strings(tokenId) owned by an address * @param node * @param networkMagic * @param contractHash + * @param address The string formatted address of an account + * @param signer */ - static tokens(node: string, networkMagic: number, contractHash: string): Promise; + static tokensOf(node: string, networkMagic: number, contractHash: string, address: string, signer?: wallet.Account): Promise; /** - * Gets the properties of a token + * Gets the total number of accounts stored in the contract * @param node * @param networkMagic * @param contractHash - * @param tokenId The tokenId of the token being requested + * @param signer */ - static properties(node: string, networkMagic: number, contractHash: string, tokenId: number): Promise; + static totalAccounts(node: string, networkMagic: number, contractHash: string, signer?: wallet.Account): Promise; + static totalEpochs(node: string, networkMagic: number, contractHash: string, signer?: wallet.Account): Promise; /** - * Initializes the smart contract on first deployment (REQUIRED) + * Returns the total supply of the token * @param node * @param networkMagic * @param contractHash - * @param data A pass through variable that is currently not used - * @param upgrade Indicates whether the deployment is an upgrade - * @param account The signing account, which will become the first admin if upgrade == false + * @param signer + */ + static totalSupply(node: string, networkMagic: number, contractHash: string, signer?: wallet.Account): Promise; + /** + * Transfers a token to another account + * @param node + * @param networkMagic + * @param contractHash + * @param toAddress + * @param tokenId + * @param signer + * @param data */ - static deploy(node: string, networkMagic: number, contractHash: string, account: wallet.Account): Promise; - static offlineMint(node: string, networkMagic: number, contractHash: string, owner: string, signer: wallet.Account): Promise; - static update(node: string, networkMagic: number, contractHash: string, script: string, manifest: string, signer: wallet.Account): Promise; - static getPuppetRaw(node: string, networkMagic: number, contractHash: string, tokenId: string): Promise; - static getMintFee(node: string, networkMagic: number, contractHash: string): Promise; - static setMintFee(node: string, networkMagic: number, contractHash: string, fee: number, signer: wallet.Account): Promise; - static getAttributeMod(node: string, networkMagic: number, contractHash: string, attributeValue: number): Promise; - static setCurrentEpoch(node: string, networkMagic: number, contractHash: string, epochId: number, account: wallet.Account): Promise; - static getCurrentEpoch(node: string, networkMagic: number, contractHash: string): Promise; + static transfer(node: string, networkMagic: number, contractHash: string, toAddress: string, tokenId: number, signer: wallet.Account, data?: any): Promise; + static update(node: string, networkMagic: number, contractHash: string, script: string, manifest: string, signer: wallet.Account): Promise; + static getEpochJSON(node: string, networkMagic: number, contractHash: string, epochId: number, signer?: wallet.Account): Promise; } diff --git a/sdk/dist/api/puppet.js b/sdk/dist/api/puppet.js index 5d1f0f1..34ef32d 100644 --- a/sdk/dist/api/puppet.js +++ b/sdk/dist/api/puppet.js @@ -20,138 +20,170 @@ var __importStar = (this && this.__importStar) || function (mod) { }; Object.defineProperty(exports, "__esModule", { value: true }); exports.PuppetAPI = void 0; -const interface_1 = require("./interface"); const neon_js_1 = __importStar(require("@cityofzion/neon-js")); const neon_core_1 = require("@cityofzion/neon-core"); const helpers_1 = require("../helpers"); class PuppetAPI { /** - * Returns the token symbol + * Returns the balance of an account * @param node * @param networkMagic * @param contractHash + * @param address + * @param signer */ - static async symbol(node, networkMagic, contractHash) { - const method = "symbol"; - const res = await interface_1.NeoInterface.testInvoke(node, networkMagic, contractHash, method, []); - if (res === undefined) { - throw new Error("unrecognized response"); + static async balanceOf(node, networkMagic, contractHash, address, signer) { + const method = "balanceOf"; + const params = [neon_js_1.sc.ContractParam.hash160(address)]; + const res = await helpers_1.variableInvoke(node, networkMagic, contractHash, method, params, signer); + if (signer) { + return res; } - return neon_js_1.default.u.HexString.fromBase64(res[0].value).toAscii(); + return parseInt(res[0].value); + } + static async createEpoch(node, networkMagic, contractHash, generatorInstanceId, mintFee, maxSupply, signer) { + const method = "create_epoch"; + const params = [ + neon_js_1.sc.ContractParam.integer(generatorInstanceId), + neon_js_1.sc.ContractParam.integer(mintFee), + neon_js_1.sc.ContractParam.integer(maxSupply) + ]; + return await helpers_1.variableInvoke(node, networkMagic, contractHash, method, params, signer); } /** * Returns the decimals of the token * @param node * @param networkMagic * @param contractHash + * @param signer */ - static async decimals(node, networkMagic, contractHash) { + static async decimals(node, networkMagic, contractHash, signer) { const method = "decimals"; - const res = await interface_1.NeoInterface.testInvoke(node, networkMagic, contractHash, method, []); - if (res === undefined) { - throw new Error("unrecognized response"); + const res = await helpers_1.variableInvoke(node, networkMagic, contractHash, method, [], signer); + if (signer) { + return res; } return parseInt(res[0].value); } /** - * Returns the total supply of the token + * Initializes the smart contract on first deployment (REQUIRED) * @param node * @param networkMagic * @param contractHash + * @param signer The signing account, which will become the first admin if upgrade == false */ - static async totalSupply(node, networkMagic, contractHash) { - const method = "totalSupply"; - const res = await interface_1.NeoInterface.testInvoke(node, networkMagic, contractHash, method, []); - if (res === undefined || res.length === 0) { - throw new Error("unrecognized response"); + static async deploy(node, networkMagic, contractHash, signer) { + const method = "deploy"; + return await helpers_1.variableInvoke(node, networkMagic, contractHash, method, [], signer); + } + static async getAttributeMod(node, networkMagic, contractHash, attributeValue, signer) { + const method = "roll_initial_stat"; + const params = [ + neon_js_1.sc.ContractParam.integer(attributeValue) + ]; + const res = await helpers_1.variableInvoke(node, networkMagic, contractHash, method, params, signer); + if (signer) { + return res; } return parseInt(res[0].value); } - /** - * Returns the balance of an account - * @param node - * @param networkMagic - * @param contractHash - * @param address - */ - static async balanceOf(node, networkMagic, contractHash, address) { - const method = "balanceOf"; - const params = [neon_js_1.sc.ContractParam.hash160(address)]; - const res = await interface_1.NeoInterface.testInvoke(node, networkMagic, contractHash, method, params); - if (res === undefined || res.length === 0) { - throw new Error("unrecognized response"); + static async getPuppetJSON(node, networkMagic, contractHash, tokenId, signer) { + const method = "get_epoch_json"; + const param = [neon_js_1.sc.ContractParam.integer(tokenId)]; + const res = await helpers_1.variableInvoke(node, networkMagic, contractHash, method, param, signer); + if (signer) { + return res; } - return parseInt(res[0].value); + return helpers_1.parseToJSON(res[0].value); + } + static async getPuppetRaw(node, networkMagic, contractHash, tokenId, signer) { + const method = "get_puppet_raw"; + const params = [neon_js_1.sc.ContractParam.string(tokenId)]; + const res = await helpers_1.variableInvoke(node, networkMagic, contractHash, method, params, signer); + if (signer) { + return res; + } + return res[0].value; } /** - * Gets an array of strings(tokenId) owned by an address + * Gets the owner account of a tokenId * @param node * @param networkMagic * @param contractHash - * @param address The string formatted address of an account + * @param tokenId The tokenId to return the owner of + * @param signer */ - static async tokensOf(node, networkMagic, contractHash, address) { - const method = "tokensOf"; - const params = [neon_js_1.sc.ContractParam.hash160(address)]; - const res = await interface_1.NeoInterface.testInvoke(node, networkMagic, contractHash, method, params); - if (res === undefined || res.length === 0) { - throw new Error("unrecognized response"); - } - const iterator = res[0]; - if (iterator.iterator && iterator.iterator.length >= 0) { - return iterator.iterator.map((token) => { - const attrs = token.value; - let bytes = neon_js_1.u.base642hex(attrs[1].value); - return parseInt(neon_js_1.u.reverseHex(bytes), 16); - }); + static async ownerOf(node, networkMagic, contractHash, tokenId, signer) { + const method = "ownerOf"; + const params = [neon_js_1.sc.ContractParam.integer(tokenId)]; + const res = await helpers_1.variableInvoke(node, networkMagic, contractHash, method, params, signer); + if (signer) { + return res; } - throw new Error("unable to resolve respond format"); + const rawValue = neon_js_1.u.base642hex(res[0].value); + return new neon_core_1.wallet.Account(neon_js_1.u.reverseHex(rawValue)); + } + static async offlineMint(node, networkMagic, contractHash, epochId, owner, signer) { + const method = "offline_mint"; + const params = [ + neon_js_1.sc.ContractParam.integer(epochId), + neon_js_1.sc.ContractParam.hash160(owner) + ]; + return await helpers_1.variableInvoke(node, networkMagic, contractHash, method, params, signer); } /** - * Transfers a token to another account + * Gets the properties of a token * @param node * @param networkMagic * @param contractHash - * @param toAddress - * @param tokenId - * @param signer - * @param data + * @param tokenId The tokenId of the token being requested + * @param signer An optional signer. Populating this value will publish a transaction and return a txid */ - static async transfer(node, networkMagic, contractHash, toAddress, tokenId, signer, data) { - const method = "transfer"; + static async properties(node, networkMagic, contractHash, tokenId, signer) { + const method = "properties"; + const params = [neon_js_1.sc.ContractParam.integer(tokenId)]; + const res = await helpers_1.variableInvoke(node, networkMagic, contractHash, method, params, signer); + if (signer) { + return res; + } + return helpers_1.parseToJSON(res[0].value); + } + static async setMintFee(node, networkMagic, contractHash, epochId, fee, signer) { + const method = "set_mint_fee"; const params = [ - neon_js_1.sc.ContractParam.hash160(toAddress), - neon_js_1.sc.ContractParam.integer(tokenId), - data, + neon_js_1.sc.ContractParam.integer(epochId), + neon_js_1.sc.ContractParam.integer(fee) ]; - return await interface_1.NeoInterface.publishInvoke(node, networkMagic, contractHash, method, params, signer); + return await helpers_1.variableInvoke(node, networkMagic, contractHash, method, params, signer); } /** - * Gets the owner account of a tokenId + * Returns the token symbol * @param node * @param networkMagic * @param contractHash - * @param tokenId The tokenId to return the owner of + * @param signer */ - static async ownerOf(node, networkMagic, contractHash, tokenId) { - const method = "ownerOf"; - const params = [neon_js_1.sc.ContractParam.integer(tokenId)]; - const res = await interface_1.NeoInterface.testInvoke(node, networkMagic, contractHash, method, params); - if (res === undefined || res.length === 0) { - throw new Error("unrecognized response"); + static async symbol(node, networkMagic, contractHash, signer) { + const method = "symbol"; + const res = await helpers_1.variableInvoke(node, networkMagic, contractHash, method, [], signer); + if (signer) { + return res; } - const rawValue = neon_js_1.u.base642hex(res[0].value); - return new neon_core_1.wallet.Account(neon_js_1.u.reverseHex(rawValue)); + return neon_js_1.default.u.HexString.fromBase64(res[0].value).toAscii(); } /** * Gets and array of strings(tokenIds) representing all the tokens associated with the contract * @param node * @param networkMagic * @param contractHash + * @param signer */ - static async tokens(node, networkMagic, contractHash) { + static async tokens(node, networkMagic, contractHash, signer) { const method = "tokens"; - const res = await interface_1.NeoInterface.testInvoke(node, networkMagic, contractHash, method, []); + const res = await helpers_1.variableInvoke(node, networkMagic, contractHash, method, [], signer); + if (signer) { + return res; + } if (res === undefined || res.length === 0) { throw new Error("unrecognized response"); } @@ -169,206 +201,104 @@ class PuppetAPI { throw new Error("unable to resolve respond format"); } /** - * Gets the properties of a token + * Gets an array of strings(tokenId) owned by an address * @param node * @param networkMagic * @param contractHash - * @param tokenId The tokenId of the token being requested + * @param address The string formatted address of an account + * @param signer */ - static async properties(node, networkMagic, contractHash, tokenId) { - const method = "properties"; - const params = [neon_js_1.sc.ContractParam.integer(tokenId)]; - const res = await interface_1.NeoInterface.testInvoke(node, networkMagic, contractHash, method, params); - if (res === undefined || res.length === 0) { - throw new Error("unrecognized response"); + static async tokensOf(node, networkMagic, contractHash, address, signer) { + const method = "tokensOf"; + const params = [neon_js_1.sc.ContractParam.hash160(address)]; + const res = await helpers_1.variableInvoke(node, networkMagic, contractHash, method, params, signer); + if (signer) { + return res; } - const puppet = { - armorClass: 0, - attributes: { - charisma: 0, - constitution: 0, - dexterity: 0, - intelligence: 0, - strength: 0, - wisdom: 0, - }, - hitDie: '', - epoch: 0, - name: '', - owner: new neon_core_1.wallet.Account(), - traits: {}, - tokenId: 0, - tokenURI: '', - }; - if (res[0] && res[0].value) { - res[0].value.forEach((entry) => { - let key = neon_js_1.u.hexstring2str(neon_js_1.u.base642hex(entry.key.value)); - let rawValue; - switch (key) { - case "armorClass": - puppet.armorClass = parseInt(entry.value.value); - break; - case "attributes": - let attrs = entry.value.value; - attrs.forEach((attrRaw) => { - let attrKey = neon_js_1.u.hexstring2str(neon_js_1.u.base642hex(attrRaw.key.value)); - switch (attrKey) { - case "charisma": - puppet.attributes.charisma = parseInt(attrRaw.value.value); - break; - case "constitution": - puppet.attributes.constitution = parseInt(attrRaw.value.value); - break; - case "dexterity": - puppet.attributes.dexterity = parseInt(attrRaw.value.value); - break; - case "intelligence": - puppet.attributes.intelligence = parseInt(attrRaw.value.value); - break; - case "strength": - puppet.attributes.strength = parseInt(attrRaw.value.value); - break; - case "wisdom": - puppet.attributes.wisdom = parseInt(attrRaw.value.value); - break; - } - }); - break; - case "hitDie": - puppet.hitDie = neon_js_1.u.hexstring2str(neon_js_1.u.base642hex(entry.value.value)); - break; - case "name": - puppet.name = neon_js_1.u.hexstring2str(neon_js_1.u.base642hex(entry.value.value)); - break; - case "owner": - rawValue = neon_js_1.u.base642hex(entry.value.value); - puppet.owner = new neon_core_1.wallet.Account(neon_js_1.u.reverseHex(rawValue)); - break; - case "traits": - puppet.traits = helpers_1.formatter(entry.value); - break; - case "tokenId": - puppet.tokenId = parseInt(entry.value.value); - break; - case "tokenURI": - puppet.tokenURI = neon_js_1.u.hexstring2str(neon_js_1.u.base642hex(entry.value.value)); - break; - case "epoch": - puppet.epoch = parseInt(entry.value.value); - break; - default: - throw new Error('unrecognized property: ' + key); - } + const iterator = res[0]; + if (iterator.iterator && iterator.iterator.length >= 0) { + return iterator.iterator.map((token) => { + const attrs = token.value; + let bytes = neon_js_1.u.base642hex(attrs[1].value); + return parseInt(neon_js_1.u.reverseHex(bytes), 16); }); } - return puppet; + throw new Error("unable to resolve respond format"); } /** - * Initializes the smart contract on first deployment (REQUIRED) + * Gets the total number of accounts stored in the contract * @param node * @param networkMagic * @param contractHash - * @param data A pass through variable that is currently not used - * @param upgrade Indicates whether the deployment is an upgrade - * @param account The signing account, which will become the first admin if upgrade == false + * @param signer */ - static async deploy(node, networkMagic, contractHash, account) { - const method = "deploy"; - return await interface_1.NeoInterface.publishInvoke(node, networkMagic, contractHash, method, [], account); - } - static async offlineMint(node, networkMagic, contractHash, owner, signer) { - const method = "offline_mint"; - const params = [ - neon_js_1.sc.ContractParam.hash160(owner) - ]; - try { - const res = await interface_1.NeoInterface.publishInvoke(node, networkMagic, contractHash, method, params, signer); - if (res === undefined || res.length === 0) { - throw new Error("unrecognized response"); - } + static async totalAccounts(node, networkMagic, contractHash, signer) { + const method = "total_accounts"; + const res = await helpers_1.variableInvoke(node, networkMagic, contractHash, method, [], signer); + if (signer) { return res; } - catch (e) { - console.log(e); - return; - } + return parseInt(res[0].value); } - static async update(node, networkMagic, contractHash, script, manifest, signer) { - const method = "update"; - const params = [ - neon_js_1.sc.ContractParam.byteArray(script), - neon_js_1.sc.ContractParam.byteArray(manifest) - ]; - try { - const res = await interface_1.NeoInterface.publishInvoke(node, networkMagic, contractHash, method, params, signer); - if (res === undefined || res.length === 0) { - throw new Error("unrecognized response"); - } + static async totalEpochs(node, networkMagic, contractHash, signer) { + const method = "total_epochs"; + const res = await helpers_1.variableInvoke(node, networkMagic, contractHash, method, [], signer); + if (signer) { return res; } - catch (e) { - console.log(e); - return; - } - } - static async getPuppetRaw(node, networkMagic, contractHash, tokenId) { - const method = "get_puppet_raw"; - const params = [neon_js_1.sc.ContractParam.string(tokenId)]; - const res = await interface_1.NeoInterface.testInvoke(node, networkMagic, contractHash, method, params); - if (res === undefined || res.length === 0) { - throw new Error("unrecognized response"); - } - return res[0].value; + return parseInt(res[0].value); } - static async getMintFee(node, networkMagic, contractHash) { - const method = "get_mint_fee"; - const res = await interface_1.NeoInterface.testInvoke(node, networkMagic, contractHash, method, []); - if (res === undefined || res.length === 0) { - throw new Error("unrecognized response"); + /** + * Returns the total supply of the token + * @param node + * @param networkMagic + * @param contractHash + * @param signer + */ + static async totalSupply(node, networkMagic, contractHash, signer) { + const method = "totalSupply"; + const res = await helpers_1.variableInvoke(node, networkMagic, contractHash, method, [], signer); + if (signer) { + return res; } return parseInt(res[0].value); } - static async setMintFee(node, networkMagic, contractHash, fee, signer) { - const method = "set_mint_fee"; + /** + * Transfers a token to another account + * @param node + * @param networkMagic + * @param contractHash + * @param toAddress + * @param tokenId + * @param signer + * @param data + */ + static async transfer(node, networkMagic, contractHash, toAddress, tokenId, signer, data) { + const method = "transfer"; const params = [ - neon_js_1.sc.ContractParam.integer(fee) - ]; - return await interface_1.NeoInterface.publishInvoke(node, networkMagic, contractHash, method, params, signer); - } - static async getAttributeMod(node, networkMagic, contractHash, attributeValue) { - const method = "roll_initial_stat"; - const param = [ - neon_js_1.sc.ContractParam.integer(attributeValue) + neon_js_1.sc.ContractParam.hash160(toAddress), + neon_js_1.sc.ContractParam.integer(tokenId), + data, ]; - try { - const res = await interface_1.NeoInterface.testInvoke(node, networkMagic, contractHash, method, param); - if (res === undefined || res.length === 0) { - throw new Error("unrecognized response"); - } - return res; - } - catch (e) { - console.log(e); - return; - } + return await helpers_1.variableInvoke(node, networkMagic, contractHash, method, params, signer); } - //////////////EPOCHS///////////// - //////////////EPOCHS///////////// - //////////////EPOCHS///////////// - static async setCurrentEpoch(node, networkMagic, contractHash, epochId, account) { - const method = "set_current_epoch"; - const param = [ - neon_js_1.sc.ContractParam.integer(epochId) + static async update(node, networkMagic, contractHash, script, manifest, signer) { + const method = "update"; + const params = [ + neon_js_1.sc.ContractParam.byteArray(script), + neon_js_1.sc.ContractParam.byteArray(manifest) ]; - return await interface_1.NeoInterface.publishInvoke(node, networkMagic, contractHash, method, param, account); + return await helpers_1.variableInvoke(node, networkMagic, contractHash, method, params, signer); } - static async getCurrentEpoch(node, networkMagic, contractHash) { - const method = "get_current_epoch"; - const res = await interface_1.NeoInterface.testInvoke(node, networkMagic, contractHash, method, []); - if (res === undefined || res.length === 0) { - throw new Error("unrecognized response"); + //setUserPermissions + static async getEpochJSON(node, networkMagic, contractHash, epochId, signer) { + const method = "get_epoch_json"; + const param = [neon_js_1.sc.ContractParam.integer(epochId)]; + const res = await helpers_1.variableInvoke(node, networkMagic, contractHash, method, param, signer); + if (signer) { + return res; } - return parseInt(res[0].value); + return helpers_1.parseToJSON(res[0].value); } } exports.PuppetAPI = PuppetAPI; diff --git a/sdk/dist/api/puppet.js.map b/sdk/dist/api/puppet.js.map index e0de7e6..5114115 100644 --- a/sdk/dist/api/puppet.js.map +++ b/sdk/dist/api/puppet.js.map @@ -1 +1 @@ -{"version":3,"file":"puppet.js","sourceRoot":"","sources":["../../src/api/puppet.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA2D;AAC3D,+DAAkD;AAClD,qDAA+C;AAG/C,wCAAqC;AAErC,MAAa,SAAS;IAEpB;;;;;OAKG;IACH,MAAM,CAAC,KAAK,CAAC,MAAM,CACjB,IAAY,EACZ,YAAoB,EACpB,YAAoB;QAEpB,MAAM,MAAM,GAAG,QAAQ,CAAC;QAExB,MAAM,GAAG,GAAG,MAAM,wBAAY,CAAC,UAAU,CACvC,IAAI,EACJ,YAAY,EACZ,YAAY,EACZ,MAAM,EACN,EAAE,CACH,CAAC;QACF,IAAI,GAAG,KAAK,SAAS,EAAE;YACrB,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;SAC1C;QACD,OAAO,iBAAI,CAAC,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,GA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C;QAEF,OAAO,MAAM,wBAAc,CAAC,IAAI,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;IACvF,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,MAAM,CACjB,IAAY,EACZ,YAAoB,EACpB,YAAoB,EACpB,MAAc,EACd,QAAgB,EAChB,MAAsB;QAEtB,MAAM,MAAM,GAAG,QAAQ,CAAC;QACxB,MAAM,MAAM,GAAG;YACb,YAAE,CAAC,aAAa,CAAC,SAAS,CAAC,MAAM,CAAC;YAClC,YAAE,CAAC,aAAa,CAAC,SAAS,CAAC,QAAQ,CAAC;SACrC,CAAA;QACD,OAAO,MAAM,wBAAc,CAAC,IAAI,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;IACvF,CAAC;IAGD,oBAAoB;IAEpB,MAAM,CAAC,KAAK,CAAC,YAAY,CACvB,IAAY,EACZ,YAAoB,EACpB,YAAoB,EACpB,OAAe,EACf,MAAuB;QAEvB,MAAM,MAAM,GAAG,gBAAgB,CAAC;QAChC,MAAM,KAAK,GAAG,CAAC,YAAE,CAAC,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;QAElD,MAAM,GAAG,GAAG,MAAM,wBAAc,CAAC,IAAI,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;QACzF,IAAI,MAAM,EAAE;YACV,OAAO,GAAG,CAAA;SACX;QAED,OAAO,qBAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAc,CAAA;IAC/C,CAAC;CAEF;AA9bD,8BA8bC"} \ No newline at end of file diff --git a/sdk/dist/helpers/helpers.js b/sdk/dist/helpers/helpers.js index 5f95655..71adc26 100644 --- a/sdk/dist/helpers/helpers.js +++ b/sdk/dist/helpers/helpers.js @@ -143,7 +143,7 @@ function parseNotifications(tx, verbose = false) { }; if (verbose) { console.log(`event: ${n.eventname}`); - console.log(` payload: ${notification}`); + console.log(` payload: ${JSON.stringify(notification)}`); } return res; }); diff --git a/sdk/dist/helpers/helpers.js.map b/sdk/dist/helpers/helpers.js.map index 8a0d8e4..2baf49c 100644 --- a/sdk/dist/helpers/helpers.js.map +++ b/sdk/dist/helpers/helpers.js.map @@ -1 +1 @@ -{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/helpers/helpers.ts"],"names":[],"mappings":";;;;;;AAAA,qDAAwD;AACxD,gCAAoC;AACpC,4CAAoB;AACpB,iDAAiD;AAEjD,SAAgB,WAAW,CAAC,OAAc;IACxC,MAAM,MAAM,GAER,EAAE,CAAA;IACN,IAAI,GAAW,CAAA;IACf,IAAI,KAAU,CAAA;IAEd,OAAO,CAAC,OAAO,CAAC,CAAC,KAAU,EAAE,EAAE;QAC7B,GAAG,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAC1B,QAAQ,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE;YACxB,KAAK,KAAK;gBACR,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;gBACtC,MAAK;YACP,KAAK,OAAO;gBACV,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE;oBACvC,OAAO,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;gBAC7B,CAAC,CAAC,CAAA;gBAEF,MAAK;YACP;gBACE,IAAI,GAAG,KAAK,UAAU,EAAE;oBACtB,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;iBACrC;qBAAM;oBACL,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;iBAC/B;gBACD,MAAK;SACR;QACD,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;IACrB,CAAC,CAAC,CAAA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AC,EAAE;YAChB,aAAa;YACb,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;SAClB;aAAM;YACL,aAAa;YACb,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;SACjB;KACF;IAED,kCAAkC;IAClC,IAAI,UAAU,GAAG,CAAC,CAAA;IAClB,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,GAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAA;IACxD,MAAM,IAAI,GAAU,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACrC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAE,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACnC,aAAa;QACb,UAAU,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,QAAQ,CAAA;KAC3D;IACD,OAAO,UAAU,CAAA;AACnB,CAAC;AAvBD,gCAuBC"} \ No newline at end of file +{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/helpers/helpers.ts"],"names":[],"mappings":";;;;;;AAAA,qDAAwD;AACxD,gCAAoC;AACpC,4CAAoB;AACpB,iDAAiD;AAEjD,SAAgB,WAAW,CAAC,OAAc;IACxC,MAAM,MAAM,GAER,EAAE,CAAA;IACN,IAAI,GAAW,CAAA;IACf,IAAI,KAAU,CAAA;IAEd,OAAO,CAAC,OAAO,CAAC,CAAC,KAAU,EAAE,EAAE;QAC7B,GAAG,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAC1B,QAAQ,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE;YACxB,KAAK,KAAK;gBACR,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;gBACtC,MAAK;YACP,KAAK,OAAO;gBACV,KAAK,GAAG,KAAK,CA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sdk/dist/index.d.ts @@ -4,4 +4,4 @@ export * as types from "./interface"; export * from "./Collection"; export * from "./Dice"; export * from "./Puppet"; -export * from "./Epoch"; +export * from "./Generator"; diff --git a/sdk/dist/index.js b/sdk/dist/index.js index f0dab7a..e83c89e 100644 --- a/sdk/dist/index.js +++ b/sdk/dist/index.js @@ -29,5 +29,5 @@ exports.types = __importStar(require("./interface")); __exportStar(require("./Collection"), exports); __exportStar(require("./Dice"), exports); __exportStar(require("./Puppet"), exports); -__exportStar(require("./Epoch"), exports); +__exportStar(require("./Generator"), exports); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/sdk/dist/index.js.map b/sdk/dist/index.js.map index 6c832ad..3c52774 100644 --- a/sdk/dist/index.js.map +++ b/sdk/dist/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA6B;AAC7B,qDAAoC;AACpC,qDAAoC;AACpC,+CAA4B;AAC5B,yCAAsB;AACtB,2CAAwB;AACxB,0CAAuB"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA6B;AAC7B,qDAAoC;AACpC,qDAAoC;AACpC,+CAA4B;AAC5B,yCAAsB;AACtB,2CAAwB;AACxB,8CAA2B"} \ No newline at end of file diff --git a/sdk/dist/interface/interface.d.ts b/sdk/dist/interface/interface.d.ts index cb7656c..8528a9e 100644 --- a/sdk/dist/interface/interface.d.ts +++ b/sdk/dist/interface/interface.d.ts @@ -31,6 +31,14 @@ export interface CollectionType { valuesRaw?: any[]; } export interface EpochType { + author: string; + epochId: number; + generatorInstanceId: number; + mintFee: number; + maxSupply: number; + totalSupply: number; +} +export interface GeneratorType { id?: number; author?: string; label: string; diff --git a/sdk/src/Generator.ts b/sdk/src/Generator.ts index fa31cf9..bc90d72 100644 --- a/sdk/src/Generator.ts +++ b/sdk/src/Generator.ts @@ -7,7 +7,7 @@ import fs from "fs"; const DEFAULT_OPTIONS: PropConstructorOptions = { node: 'http://localhost:50012', - scriptHash: '0xccff6257a59416028105709bc1e488a36ffeb9b2' + scriptHash: '0x47f945b1028961b539ecebbce8eaf3ef1aa9c084' } export class Generator { diff --git a/sdk/src/Puppet.ts b/sdk/src/Puppet.ts index 8d7098a..f8d01a2 100644 --- a/sdk/src/Puppet.ts +++ b/sdk/src/Puppet.ts @@ -2,11 +2,11 @@ import { merge } from 'lodash' import {rpc, wallet} from '@cityofzion/neon-core' import {PuppetAPI, NeoInterface} from './api' import {sc} from "@cityofzion/neon-js"; -import {PropConstructorOptions} from "./interface"; +import {EpochType, PropConstructorOptions, PuppetType} from "./interface"; const DEFAULT_OPTIONS: PropConstructorOptions = { node: 'http://localhost:50012', - scriptHash: '0xf112cb2412173f890d50e6996b3e65c85f85636a' + scriptHash: '0x58a217883a7771a730d5fd4feb336536f982ad0d' } export class Puppet { @@ -36,51 +36,69 @@ export class Puppet { throw new Error('node scripthash defined') } - async balanceOf(address: string): Promise { - return PuppetAPI.balanceOf(this.node.url, this.networkMagic, this.scriptHash, address) + async balanceOf(address: string, signer?: wallet.Account): Promise { + return PuppetAPI.balanceOf(this.node.url, this.networkMagic, this.scriptHash, address, signer) } - async decimals(): Promise { - return PuppetAPI.decimals(this.node.url, this.networkMagic, this.scriptHash) + async createEpoch(generatorId: number, mintFee: number, maxSupply: number, signer: wallet.Account): Promise { + return PuppetAPI.createEpoch(this.node.url, this.networkMagic, this.scriptHash, generatorId, mintFee, maxSupply, signer) } - async deploy(signer: wallet.Account): Promise { + async decimals(signer?: wallet.Account): Promise { + return PuppetAPI.decimals(this.node.url, this.networkMagic, this.scriptHash, signer) + } + + async deploy(signer: wallet.Account): Promise { return PuppetAPI.deploy(this.node.url, this.networkMagic, this.scriptHash, signer) } - async getAttributeMod(attributeValue: number): Promise { - return PuppetAPI.getAttributeMod(this.node.url, this.networkMagic, this.scriptHash, attributeValue) + async getAttributeMod(attributeValue: number, signer?: wallet.Account): Promise { + return PuppetAPI.getAttributeMod(this.node.url, this.networkMagic, this.scriptHash, attributeValue, signer) + } + + async getEpochJSON(epochId: number, signer?: wallet.Account): Promise { + return PuppetAPI.getEpochJSON(this.node.url, this.networkMagic, this.scriptHash, epochId, signer) } - async getPuppetRaw(tokenId: string): Promise { - return PuppetAPI.getPuppetRaw(this.node.url, this.networkMagic, this.scriptHash, tokenId) + async getPuppetJSON(tokenId: number, signer?: wallet.Account): Promise { + return PuppetAPI.getPuppetJSON(this.node.url, this.networkMagic, this.scriptHash, tokenId, signer) } - async ownerOf(tokenId: number): Promise { - return PuppetAPI.ownerOf(this.node.url, this.networkMagic, this.scriptHash, tokenId) + async getPuppetRaw(tokenId: string, signer?: wallet.Account): Promise { + return PuppetAPI.getPuppetRaw(this.node.url, this.networkMagic, this.scriptHash, tokenId, signer) } - async offlineMint(target: string, signer: wallet.Account): Promise { - return PuppetAPI.offlineMint(this.node.url, this.networkMagic, this.scriptHash, target, signer) + async ownerOf(tokenId: number, signer?: wallet.Account): Promise { + return PuppetAPI.ownerOf(this.node.url, this.networkMagic, this.scriptHash, tokenId, signer) } - async properties(tokenId: number): Promise { - return PuppetAPI.properties(this.node.url, this.networkMagic, this.scriptHash, tokenId) + async offlineMint(epochId: number, owner: string, signer: wallet.Account): Promise { + return PuppetAPI.offlineMint(this.node.url, this.networkMagic, this.scriptHash, epochId, owner, signer) } - async purchase(signer: wallet.Account): Promise { + async properties(tokenId: number, signer?: wallet.Account): Promise { + return PuppetAPI.properties(this.node.url, this.networkMagic, this.scriptHash, tokenId, signer) + } + + async purchase(epochId: number, signer: wallet.Account): Promise { const method = "transfer"; const GASScriptHash = "0xd2a4cff31913016155e38e474a2c06d08be276cf" - const purchasePrice = await PuppetAPI.getMintFee(this.node.url, this.networkMagic, this.scriptHash) + const epoch = await PuppetAPI.getEpochJSON(this.node.url, this.networkMagic, this.scriptHash, epochId) + const EpochTyped = epoch as unknown as EpochType + if (EpochTyped.totalSupply === EpochTyped.maxSupply) { + throw new Error(`Epoch is out of Puppets: ${EpochTyped.totalSupply} / ${EpochTyped.maxSupply}`) + } + + const purchasePrice = EpochTyped.mintFee const params = [ sc.ContractParam.hash160(signer.address), sc.ContractParam.hash160(this.scriptHash), sc.ContractParam.integer(purchasePrice), - sc.ContractParam.any() + sc.ContractParam.integer(epochId) ] try { - const res = await NeoInterface.publishInvoke( + return await NeoInterface.publishInvoke( this.node.url, this.networkMagic, GASScriptHash, @@ -88,49 +106,45 @@ export class Puppet { params, signer ); - return res } catch (e) { throw new Error("Something went wrong: " + (e as Error).message) } } - async setMintFee(fee: number, signer: wallet.Account): Promise { - return PuppetAPI.setMintFee(this.node.url, this.networkMagic, this.scriptHash,fee, signer) + async setMintFee(epochId: number, fee: number, signer: wallet.Account): Promise { + return PuppetAPI.setMintFee(this.node.url, this.networkMagic, this.scriptHash, epochId, fee, signer) } - async symbol(): Promise { - return PuppetAPI.symbol(this.node.url, this.networkMagic, this.scriptHash) + async symbol(signer?: wallet.Account): Promise { + return PuppetAPI.symbol(this.node.url, this.networkMagic, this.scriptHash, signer) } - async getMintFee(): Promise { - return PuppetAPI.getMintFee(this.node.url, this.networkMagic, this.scriptHash) + async tokens(signer?: wallet.Account): Promise { + return PuppetAPI.tokens(this.node.url, this.networkMagic, this.scriptHash, signer) } - async tokens(): Promise { - return PuppetAPI.tokens(this.node.url, this.networkMagic, this.scriptHash) + async tokensOf(address: string, signer?: wallet.Account): Promise { + return PuppetAPI.tokensOf(this.node.url, this.networkMagic, this.scriptHash, address, signer) } - async tokensOf(address: string): Promise { - return PuppetAPI.tokensOf(this.node.url, this.networkMagic, this.scriptHash, address) + async totalAccounts(signer?: wallet.Account): Promise { + return PuppetAPI.totalAccounts(this.node.url, this.networkMagic, this.scriptHash, signer) } - async transfer(to: string, tokenId: number, signer: wallet.Account, data: any ): Promise { - return PuppetAPI.transfer(this.node.url, this.networkMagic, this.scriptHash,to, tokenId, signer, data) + async totalEpochs(signer?: wallet.Account): Promise { + return PuppetAPI.totalEpochs(this.node.url, this.networkMagic, this.scriptHash, signer) } - async totalSupply(): Promise { - return PuppetAPI.totalSupply(this.node.url, this.networkMagic, this.scriptHash) + async totalSupply(signer?: wallet.Account): Promise { + return PuppetAPI.totalSupply(this.node.url, this.networkMagic, this.scriptHash, signer) } - async update(script: string, manifest: string, signer: wallet.Account): Promise { - return PuppetAPI.update(this.node.url, this.networkMagic, this.scriptHash, script, manifest, signer) + async transfer(to: string, tokenId: number, signer: wallet.Account, data: any): Promise { + return PuppetAPI.transfer(this.node.url, this.networkMagic, this.scriptHash,to, tokenId, signer, data) } - async setCurrentEpoch(epoch_id: number, signer: wallet.Account): Promise { - return PuppetAPI.setCurrentEpoch(this.node.url, this.networkMagic, this.scriptHash, epoch_id, signer) + async update(script: string, manifest: string, signer: wallet.Account): Promise { + return PuppetAPI.update(this.node.url, this.networkMagic, this.scriptHash, script, manifest, signer) } - async getCurrentEpoch(): Promise { - return PuppetAPI.getCurrentEpoch(this.node.url, this.networkMagic, this.scriptHash) - } } diff --git a/sdk/src/api/generator.ts b/sdk/src/api/generator.ts index 7c4b6c0..9f2f546 100644 --- a/sdk/src/api/generator.ts +++ b/sdk/src/api/generator.ts @@ -105,7 +105,6 @@ export class GeneratorAPI { if (signer) { return res } - console.log(JSON.stringify(res[0].value)) return parseToJSON(res[0].value) as GeneratorType } diff --git a/sdk/src/api/puppet.ts b/sdk/src/api/puppet.ts index 2ecb142..2d7a054 100644 --- a/sdk/src/api/puppet.ts +++ b/sdk/src/api/puppet.ts @@ -1,36 +1,53 @@ -import {InteropInterface, NeoInterface} from "./interface"; +import {InteropInterface} from "./interface"; import Neon, { sc, u } from "@cityofzion/neon-js"; import { wallet } from "@cityofzion/neon-core"; -import {StackItemJson, StackItemLike, StackItemMapLike} from "@cityofzion/neon-core/lib/sc"; -import {PuppetType} from "../interface"; -import {formatter} from "../helpers"; +import {StackItemJson, StackItemMapLike} from "@cityofzion/neon-core/lib/sc"; +import {EpochType, PuppetType} from "../interface"; +import {parseToJSON, variableInvoke} from "../helpers"; export class PuppetAPI { /** - * Returns the token symbol + * Returns the balance of an account * @param node * @param networkMagic * @param contractHash + * @param address + * @param signer */ - static async symbol( + static async balanceOf( node: string, networkMagic: number, - contractHash: string - ): Promise { - const method = "symbol"; + contractHash: string, + address: string, + signer?: wallet.Account + ): Promise { + const method = "balanceOf"; - const res = await NeoInterface.testInvoke( - node, - networkMagic, - contractHash, - method, - [] - ); - if (res === undefined) { - throw new Error("unrecognized response"); + const params = [sc.ContractParam.hash160(address)]; + const res = await variableInvoke(node, networkMagic, contractHash, method, params, signer) + if (signer) { + return res } - return Neon.u.HexString.fromBase64(res[0].value as string).toAscii(); + return parseInt(res[0].value as string); + } + + static async createEpoch( + node: string, + networkMagic: number, + contractHash: string, + generatorInstanceId: number, + mintFee: number, + maxSupply: number, + signer: wallet.Account, + ): Promise { + const method = "create_epoch"; + const params = [ + sc.ContractParam.integer(generatorInstanceId), + sc.ContractParam.integer(mintFee), + sc.ContractParam.integer(maxSupply) + ]; + return await variableInvoke(node, networkMagic, contractHash, method, params, signer) } /** @@ -38,191 +55,198 @@ export class PuppetAPI { * @param node * @param networkMagic * @param contractHash + * @param signer */ static async decimals( node: string, networkMagic: number, - contractHash: string + contractHash: string, + signer?: wallet.Account ): Promise { const method = "decimals"; - const res = await NeoInterface.testInvoke( - node, - networkMagic, - contractHash, - method, - [] - ); - if (res === undefined) { - throw new Error("unrecognized response"); + const res = await variableInvoke(node, networkMagic, contractHash, method, [], signer) + if (signer) { + return res } return parseInt(res[0].value as string); } /** - * Returns the total supply of the token + * Initializes the smart contract on first deployment (REQUIRED) * @param node * @param networkMagic * @param contractHash + * @param signer The signing account, which will become the first admin if upgrade == false */ - static async totalSupply( + static async deploy( node: string, networkMagic: number, - contractHash: string - ): Promise { - const method = "totalSupply"; + contractHash: string, + signer: wallet.Account + ): Promise { + const method = "deploy"; - const res = await NeoInterface.testInvoke( - node, - networkMagic, - contractHash, - method, - [] - ); - if (res === undefined || res.length === 0) { - throw new Error("unrecognized response"); + return await variableInvoke(node, networkMagic, contractHash, method, [], signer) + } + + static async getAttributeMod( + node: string, + networkMagic: number, + contractHash: string, + attributeValue: number, + signer?: wallet.Account + ): Promise { + const method = "roll_initial_stat"; + const params = [ + sc.ContractParam.integer(attributeValue) + ] + const res = await variableInvoke(node, networkMagic, contractHash, method, params, signer) + if (signer) { + return res } return parseInt(res[0].value as string); } - /** - * Returns the balance of an account - * @param node - * @param networkMagic - * @param contractHash - * @param address - */ - static async balanceOf( + static async getPuppetJSON( node: string, networkMagic: number, contractHash: string, - address: string - ): Promise { - const method = "balanceOf"; - - const params = [sc.ContractParam.hash160(address)]; - const res = await NeoInterface.testInvoke( - node, - networkMagic, - contractHash, - method, - params - ); - if (res === undefined || res.length === 0) { - throw new Error("unrecognized response"); + tokenId: number, + signer?: wallet.Account + ): Promise { + const method = "get_epoch_json"; + const param = [sc.ContractParam.integer(tokenId)]; + + const res = await variableInvoke(node, networkMagic, contractHash, method, param, signer) + if (signer) { + return res } - return parseInt(res[0].value as string); + + return parseToJSON(res[0].value) as PuppetType } + static async getPuppetRaw( + node: string, + networkMagic: number, + contractHash: string, + tokenId: string, + signer?: wallet.Account + ): Promise { + const method = "get_puppet_raw"; + + const params = [sc.ContractParam.string(tokenId)]; + const res = await variableInvoke(node, networkMagic, contractHash, method, params, signer) + if (signer) { + return res + } + return res[0].value; + } /** - * Gets an array of strings(tokenId) owned by an address + * Gets the owner account of a tokenId * @param node * @param networkMagic * @param contractHash - * @param address The string formatted address of an account + * @param tokenId The tokenId to return the owner of + * @param signer */ - static async tokensOf( + static async ownerOf( node: string, networkMagic: number, contractHash: string, - address: string - ): Promise { - const method = "tokensOf"; - - const params = [sc.ContractParam.hash160(address)]; - const res = await NeoInterface.testInvoke( - node, - networkMagic, - contractHash, - method, - params - ); - if (res === undefined || res.length === 0) { - throw new Error("unrecognized response"); - } + tokenId: number, + signer?: wallet.Account + ): Promise { + const method = "ownerOf"; - const iterator: InteropInterface = res[0] as InteropInterface - if (iterator.iterator && iterator.iterator.length >= 0) { - return iterator.iterator.map( (token: StackItemJson) => { - const attrs: StackItemJson[] = token.value as StackItemJson[] - let bytes = u.base642hex((attrs[1].value as string)) - return parseInt(u.reverseHex(bytes),16) - }) + const params = [sc.ContractParam.integer(tokenId)]; + const res = await variableInvoke(node, networkMagic, contractHash, method, params, signer) + if (signer) { + return res } + const rawValue = u.base642hex(res[0].value as string) + return new wallet.Account(u.reverseHex(rawValue)) + } + static async offlineMint( + node: string, + networkMagic: number, + contractHash: string, + epochId: number, + owner: string, + signer: wallet.Account + ): Promise { - throw new Error("unable to resolve respond format") - - + const method = "offline_mint"; + const params = [ + sc.ContractParam.integer(epochId), + sc.ContractParam.hash160(owner) + ] + return await variableInvoke(node, networkMagic, contractHash, method, params, signer) } /** - * Transfers a token to another account + * Gets the properties of a token * @param node * @param networkMagic * @param contractHash - * @param toAddress - * @param tokenId - * @param signer - * @param data + * @param tokenId The tokenId of the token being requested + * @param signer An optional signer. Populating this value will publish a transaction and return a txid */ - static async transfer( + static async properties( node: string, networkMagic: number, contractHash: string, - toAddress: string, tokenId: number, + signer?: wallet.Account + ): Promise { + const method = "properties"; + const params = [sc.ContractParam.integer(tokenId)]; + const res = await variableInvoke(node, networkMagic, contractHash, method, params, signer) + if (signer) { + return res + } + return parseToJSON(res[0].value as unknown as StackItemMapLike[]) as PuppetType + } + + static async setMintFee( + node: string, + networkMagic: number, + contractHash: string, + epochId: number, + fee: number, signer: wallet.Account, - data?: any - ): Promise { - const method = "transfer"; + ): Promise { + const method = "set_mint_fee"; const params = [ - sc.ContractParam.hash160(toAddress), - sc.ContractParam.integer(tokenId), - data, + sc.ContractParam.integer(epochId), + sc.ContractParam.integer(fee) ]; - return await NeoInterface.publishInvoke( - node, - networkMagic, - contractHash, - method, - params, - signer - ); + return await variableInvoke(node, networkMagic, contractHash, method, params, signer) } - /** - * Gets the owner account of a tokenId + * Returns the token symbol * @param node * @param networkMagic * @param contractHash - * @param tokenId The tokenId to return the owner of + * @param signer */ - static async ownerOf( + static async symbol( node: string, networkMagic: number, contractHash: string, - tokenId: number - ): Promise { - const method = "ownerOf"; - - const params = [sc.ContractParam.integer(tokenId)]; - const res = await NeoInterface.testInvoke( - node, - networkMagic, - contractHash, - method, - params - ); + signer?: wallet.Account + ): Promise { + const method = "symbol"; - if (res === undefined || res.length === 0) { - throw new Error("unrecognized response"); + const res = await variableInvoke(node, networkMagic, contractHash, method, [], signer) + if (signer) { + return res } - const rawValue = u.base642hex(res[0].value as string) - return new wallet.Account(u.reverseHex(rawValue)) + return Neon.u.HexString.fromBase64(res[0].value as string).toAscii(); } /** @@ -230,21 +254,21 @@ export class PuppetAPI { * @param node * @param networkMagic * @param contractHash + * @param signer */ static async tokens( node: string, networkMagic: number, - contractHash: string - ): Promise { + contractHash: string, + signer?: wallet.Account + ): Promise { const method = "tokens"; - const res = await NeoInterface.testInvoke( - node, - networkMagic, - contractHash, - method, - [] - ); + const res = await variableInvoke(node, networkMagic, contractHash, method, [], signer) + if (signer) { + return res + } + if (res === undefined || res.length === 0) { throw new Error("unrecognized response"); } @@ -265,345 +289,166 @@ export class PuppetAPI { } /** - * Gets the properties of a token + * Gets an array of strings(tokenId) owned by an address * @param node * @param networkMagic * @param contractHash - * @param tokenId The tokenId of the token being requested + * @param address The string formatted address of an account + * @param signer */ - static async properties( + static async tokensOf( node: string, networkMagic: number, contractHash: string, - tokenId: number - ): Promise { - const method = "properties"; - const params = [sc.ContractParam.integer(tokenId)]; - const res = await NeoInterface.testInvoke( - node, - networkMagic, - contractHash, - method, - params - ); - - if (res === undefined || res.length === 0) { - throw new Error("unrecognized response"); - } + address: string, + signer?: wallet.Account + ): Promise { + const method = "tokensOf"; - const puppet: PuppetType = { - armorClass: 0, - attributes: { - charisma: 0, - constitution: 0, - dexterity: 0, - intelligence: 0, - strength: 0, - wisdom: 0, - }, - hitDie: '', - epoch: 0, - name: '', - owner: new wallet.Account(), - traits: {}, - tokenId: 0, - tokenURI: '', + const params = [sc.ContractParam.hash160(address)]; + const res = await variableInvoke(node, networkMagic, contractHash, method, params, signer) + if (signer) { + return res } - if (res[0] && res[0].value) { - (res[0].value as unknown as StackItemMapLike[]).forEach( (entry: StackItemMapLike) => { - let key = u.hexstring2str(u.base642hex(entry.key.value as string)) - let rawValue - switch (key) { - case "armorClass": - puppet.armorClass = parseInt(entry.value.value as string) - break - case "attributes": - let attrs = entry.value.value as unknown as StackItemMapLike[] - attrs.forEach( (attrRaw: StackItemMapLike) => { - let attrKey = u.hexstring2str(u.base642hex(attrRaw.key.value as string)) - switch (attrKey) { - case "charisma": - puppet.attributes.charisma = parseInt(attrRaw.value.value as string) - break - case "constitution": - puppet.attributes.constitution = parseInt(attrRaw.value.value as string) - break - case "dexterity": - puppet.attributes.dexterity = parseInt(attrRaw.value.value as string) - break - case "intelligence": - puppet.attributes.intelligence = parseInt(attrRaw.value.value as string) - break - case "strength": - puppet.attributes.strength = parseInt(attrRaw.value.value as string) - break - case "wisdom": - puppet.attributes.wisdom = parseInt(attrRaw.value.value as string) - break - } - }) - break - case "hitDie": - puppet.hitDie = u.hexstring2str(u.base642hex(entry.value.value as string)) - break - case "name": - puppet.name = u.hexstring2str(u.base642hex(entry.value.value as string)) - break - case "owner": - rawValue = u.base642hex(entry.value.value as string) - puppet.owner = new wallet.Account(u.reverseHex(rawValue)) - break - case "traits": - puppet.traits = formatter(entry.value) - break - case "tokenId": - puppet.tokenId = parseInt(entry.value.value as string) - break - case "tokenURI": - puppet.tokenURI = u.hexstring2str(u.base642hex(entry.value.value as string)) - break - case "epoch": - puppet.epoch = parseInt(entry.value.value as string) - break - default: - throw new Error('unrecognized property: ' + key) - } + const iterator: InteropInterface = res[0] as InteropInterface + if (iterator.iterator && iterator.iterator.length >= 0) { + return iterator.iterator.map( (token: StackItemJson) => { + const attrs: StackItemJson[] = token.value as StackItemJson[] + let bytes = u.base642hex((attrs[1].value as string)) + return parseInt(u.reverseHex(bytes),16) }) } - return puppet - } + throw new Error("unable to resolve respond format") + + + } + /** - * Initializes the smart contract on first deployment (REQUIRED) + * Gets the total number of accounts stored in the contract * @param node * @param networkMagic * @param contractHash - * @param data A pass through variable that is currently not used - * @param upgrade Indicates whether the deployment is an upgrade - * @param account The signing account, which will become the first admin if upgrade == false + * @param signer */ - static async deploy( + static async totalAccounts( node: string, networkMagic: number, contractHash: string, - account: wallet.Account - ): Promise { - const method = "deploy"; + signer?: wallet.Account + ): Promise { + const method = "total_accounts"; - return await NeoInterface.publishInvoke( - node, - networkMagic, - contractHash, - method, - [], - account - ); - } - - static async offlineMint( - node: string, - networkMagic: number, - contractHash: string, - owner: string, - signer: wallet.Account - ): Promise { - - const method = "offline_mint"; - const params = [ - sc.ContractParam.hash160(owner) - ] - try { - const res = await NeoInterface.publishInvoke( - node, - networkMagic, - contractHash, - method, - params, - signer - ); - if (res === undefined || res.length === 0) { - throw new Error("unrecognized response"); - } - return res; - } catch(e){ - console.log(e) - return + const res = await variableInvoke(node, networkMagic, contractHash, method, [], signer) + if (signer) { + return res } + return parseInt(res[0].value as string); } - static async update( + static async totalEpochs( node: string, networkMagic: number, contractHash: string, - script: string, - manifest: string, - signer: wallet.Account - ): Promise { - const method = "update"; - const params = [ - sc.ContractParam.byteArray(script), - sc.ContractParam.byteArray(manifest) - ] - try { - const res = await NeoInterface.publishInvoke( - node, - networkMagic, - contractHash, - method, - params, - signer - ); - if (res === undefined || res.length === 0) { - throw new Error("unrecognized response"); - } - return res; - } catch(e){ - console.log(e) - return + signer?: wallet.Account + ): Promise { + const method = "total_epochs"; + + const res = await variableInvoke(node, networkMagic, contractHash, method, [], signer) + if (signer) { + return res } + return parseInt(res[0].value as string); } - static async getPuppetRaw( + /** + * Returns the total supply of the token + * @param node + * @param networkMagic + * @param contractHash + * @param signer + */ + static async totalSupply( node: string, networkMagic: number, contractHash: string, - tokenId: string - ): Promise { - const method = "get_puppet_raw"; - - const params = [sc.ContractParam.string(tokenId)]; - const res = await NeoInterface.testInvoke( - node, - networkMagic, - contractHash, - method, - params - ); - if (res === undefined || res.length === 0) { - throw new Error("unrecognized response"); - } - return res[0].value; - } + signer?: wallet.Account + ): Promise { + const method = "totalSupply"; - static async getMintFee( - node: string, - networkMagic: number, - contractHash: string - ): Promise { - const method = "get_mint_fee"; - - const res = await NeoInterface.testInvoke( - node, - networkMagic, - contractHash, - method, - [] - ); - if (res === undefined || res.length === 0) { - throw new Error("unrecognized response"); + const res = await variableInvoke(node, networkMagic, contractHash, method, [], signer) + if (signer) { + return res } return parseInt(res[0].value as string); } - static async setMintFee( + /** + * Transfers a token to another account + * @param node + * @param networkMagic + * @param contractHash + * @param toAddress + * @param tokenId + * @param signer + * @param data + */ + static async transfer( node: string, networkMagic: number, contractHash: string, - fee: number, + toAddress: string, + tokenId: number, signer: wallet.Account, - ): Promise { - const method = "set_mint_fee"; + data?: any + ): Promise { + const method = "transfer"; const params = [ - sc.ContractParam.integer(fee) + sc.ContractParam.hash160(toAddress), + sc.ContractParam.integer(tokenId), + data, ]; - return await NeoInterface.publishInvoke( - node, - networkMagic, - contractHash, - method, - params, - signer - ); + return await variableInvoke(node, networkMagic, contractHash, method, params, signer) } - static async getAttributeMod( + static async update( node: string, networkMagic: number, contractHash: string, - attributeValue: number - ): Promise { - const method = "roll_initial_stat"; - const param = [ - sc.ContractParam.integer(attributeValue) + script: string, + manifest: string, + signer: wallet.Account + ): Promise { + const method = "update"; + const params = [ + sc.ContractParam.byteArray(script), + sc.ContractParam.byteArray(manifest) ] - try { - const res = await NeoInterface.testInvoke( - node, - networkMagic, - contractHash, - method, - param - ); - if (res === undefined || res.length === 0) { - throw new Error("unrecognized response"); - } - return res; - } catch(e){ - console.log(e) - return - } + return await variableInvoke(node, networkMagic, contractHash, method, params, signer) } - //////////////EPOCHS///////////// - //////////////EPOCHS///////////// - //////////////EPOCHS///////////// + //setUserPermissions - - static async setCurrentEpoch( + static async getEpochJSON( node: string, networkMagic: number, contractHash: string, epochId: number, - account: wallet.Account - ): Promise { - const method = "set_current_epoch"; - - const param = [ - sc.ContractParam.integer(epochId) - ] - - return await NeoInterface.publishInvoke( - node, - networkMagic, - contractHash, - method, - param, - account - ); - } - - static async getCurrentEpoch( - node: string, - networkMagic: number, - contractHash: string - ): Promise { - const method = "get_current_epoch"; - - const res = await NeoInterface.testInvoke( - node, - networkMagic, - contractHash, - method, - [] - ); - if (res === undefined || res.length === 0) { - throw new Error("unrecognized response"); + signer?: wallet.Account + ): Promise { + const method = "get_epoch_json"; + const param = [sc.ContractParam.integer(epochId)]; + + const res = await variableInvoke(node, networkMagic, contractHash, method, param, signer) + if (signer) { + return res } - return parseInt(res[0].value as string); + + return parseToJSON(res[0].value) as EpochType } } diff --git a/sdk/src/helpers/helpers.ts b/sdk/src/helpers/helpers.ts index 21ec0f6..a3f1bcd 100644 --- a/sdk/src/helpers/helpers.ts +++ b/sdk/src/helpers/helpers.ts @@ -168,7 +168,7 @@ const notification = formatter(n.state) } if (verbose) { console.log(`event: ${n.eventname}`) - console.log(` payload: ${notification}`) + console.log(` payload: ${JSON.stringify(notification)}`) } return res }) diff --git a/sdk/src/interface/interface.ts b/sdk/src/interface/interface.ts index 8aa0727..bfacabb 100644 --- a/sdk/src/interface/interface.ts +++ b/sdk/src/interface/interface.ts @@ -35,6 +35,15 @@ export interface CollectionType { valuesRaw?: any[] } +export interface EpochType { + author: string + epochId: number, + generatorInstanceId: number, + mintFee: number, + maxSupply: number, + totalSupply: number +} + export interface GeneratorType { id?: number, author?: string