Skip to content

Commit

Permalink
resolves #16
Browse files Browse the repository at this point in the history
  • Loading branch information
lllwvlvwlll committed Jan 25, 2022
1 parent bc19212 commit ca626cb
Show file tree
Hide file tree
Showing 30 changed files with 1,071 additions and 889 deletions.
230 changes: 171 additions & 59 deletions contracts/puppet/props.puppet.py

Large diffs are not rendered by default.

7 changes: 0 additions & 7 deletions scripts/initialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
28 changes: 23 additions & 5 deletions scripts/mint_puppets.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -74,4 +92,4 @@ async function main() {
fs.writeFileSync('traits.csv', csv)
*/
}
main()
main(TIME_CONSTANT)
20 changes: 20 additions & 0 deletions sdk/dist/Generator.d.ts
Original file line number Diff line number Diff line change
@@ -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<void>;
get node(): rpc.RPCClient;
get scriptHash(): string;
createGenerator(generator: GeneratorType, signer: wallet.Account, timeConstantMS: number): Promise<string[]>;
createGeneratorFromFile(path: string, signer: wallet.Account, timeConstantMS: number): Promise<string[]>;
getGeneratorJSON(generatorId: number, signer?: wallet.Account): Promise<GeneratorType | string>;
getGeneratorInstanceJSON(instanceId: number, signer?: wallet.Account): Promise<any>;
createInstance(generatorId: number, signer: wallet.Account): Promise<string>;
mintFromGenerator(generatorId: number, signer: wallet.Account): Promise<string>;
mintFromInstance(instanceId: number, signer: wallet.Account): Promise<string>;
setInstanceAuthorizedUsers(instanceId: number, authorizedUsers: string[], signer: wallet.Account): Promise<string>;
totalGenerators(signer?: wallet.Account): Promise<number | string>;
totalGeneratorInstances(signer?: wallet.Account): Promise<number | string>;
}
79 changes: 79 additions & 0 deletions sdk/dist/Generator.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions sdk/dist/Generator.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 22 additions & 20 deletions sdk/dist/Puppet.d.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
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;
constructor(options?: PropConstructorOptions);
init(): Promise<void>;
get node(): rpc.RPCClient;
get scriptHash(): string;
balanceOf(address: string): Promise<number>;
decimals(): Promise<number>;
deploy(signer: wallet.Account): Promise<any>;
getAttributeMod(attributeValue: number): Promise<any>;
getPuppetRaw(tokenId: string): Promise<string | undefined>;
ownerOf(tokenId: number): Promise<wallet.Account | undefined>;
offlineMint(target: string, signer: wallet.Account): Promise<string | undefined>;
properties(tokenId: number): Promise<any>;
purchase(signer: wallet.Account): Promise<string | undefined>;
setMintFee(fee: number, signer: wallet.Account): Promise<number>;
symbol(): Promise<string>;
getMintFee(): Promise<number>;
tokens(): Promise<number[]>;
tokensOf(address: string): Promise<number[]>;
transfer(to: string, tokenId: number, signer: wallet.Account, data: any): Promise<boolean | undefined>;
totalSupply(): Promise<number>;
update(script: string, manifest: string, signer: wallet.Account): Promise<boolean>;
setCurrentEpoch(epoch_id: number, signer: wallet.Account): Promise<boolean | undefined>;
getCurrentEpoch(): Promise<number | undefined>;
balanceOf(address: string, signer?: wallet.Account): Promise<number>;
createEpoch(generatorId: number, mintFee: number, maxSupply: number, signer: wallet.Account): Promise<string>;
decimals(signer?: wallet.Account): Promise<number>;
deploy(signer: wallet.Account): Promise<string>;
getAttributeMod(attributeValue: number, signer?: wallet.Account): Promise<number | string>;
getEpochJSON(epochId: number, signer?: wallet.Account): Promise<EpochType | string>;
getPuppetJSON(tokenId: number, signer?: wallet.Account): Promise<PuppetType | string>;
getPuppetRaw(tokenId: string, signer?: wallet.Account): Promise<string>;
ownerOf(tokenId: number, signer?: wallet.Account): Promise<wallet.Account | string>;
offlineMint(epochId: number, owner: string, signer: wallet.Account): Promise<string>;
properties(tokenId: number, signer?: wallet.Account): Promise<PuppetType | string>;
purchase(epochId: number, signer: wallet.Account): Promise<string | undefined>;
setMintFee(epochId: number, fee: number, signer: wallet.Account): Promise<string>;
symbol(signer?: wallet.Account): Promise<string>;
tokens(signer?: wallet.Account): Promise<number[] | string>;
tokensOf(address: string, signer?: wallet.Account): Promise<number[] | string>;
totalAccounts(signer?: wallet.Account): Promise<number | string>;
totalEpochs(signer?: wallet.Account): Promise<number | string>;
totalSupply(signer?: wallet.Account): Promise<number | string>;
transfer(to: string, tokenId: number, signer: wallet.Account, data: any): Promise<string>;
update(script: string, manifest: string, signer: wallet.Account): Promise<string>;
}
Loading

0 comments on commit ca626cb

Please sign in to comment.