diff --git a/sdk/dist/Chest.d.ts b/sdk/dist/Chest.d.ts index f7146c3..c3e41ab 100644 --- a/sdk/dist/Chest.d.ts +++ b/sdk/dist/Chest.d.ts @@ -33,11 +33,12 @@ export declare class Chest { * Create one of these pass throughs for each method you expose in your smart contract. The goal of this entire class is to * simplify the network configuration steps which can be complicated. */ - createChest(name: string, type: number, eligibilityCases: [EligibilityCase], signer: wallet.Account): Promise; + createChest(name: string, type: number, eligibilityCases: EligibilityCase[], signer: wallet.Account): Promise; isEligible(chestId: number, nftScriptHash: string, tokenId: string, signer?: wallet.Account): Promise; lootChest(chestId: number, nftScriptHash: string, tokenId: string, signer: wallet.Account): Promise; lootChestVerified(chestId: number, nftScriptHash: string, tokenId: string, signer: wallet.Account): Promise; lootChestAsOwner(chestId: number, signer: wallet.Account): Promise; getChestJSON(chestId: number, signer?: wallet.Account): Promise; - totalChests(name: string, type: number, signer?: wallet.Account): Promise; + totalChests(signer?: wallet.Account): Promise; + loadChestFungible(tokenScriptHash: string, chestId: number, transferAmount: number, amountPerReservoirItem: number, signer: wallet.Account): Promise; } diff --git a/sdk/dist/Chest.js b/sdk/dist/Chest.js index f45a198..0a9df82 100644 --- a/sdk/dist/Chest.js +++ b/sdk/dist/Chest.js @@ -106,9 +106,20 @@ class Chest { async getChestJSON(chestId, signer) { return api_1.ChestAPI.getChestJSON(this.node.url, this.networkMagic, this.scriptHash, chestId, signer); } - async totalChests(name, type, signer) { + async totalChests(signer) { return api_1.ChestAPI.totalChests(this.node.url, this.networkMagic, this.scriptHash, signer); } + async loadChestFungible(tokenScriptHash, chestId, transferAmount, amountPerReservoirItem, signer) { + const contractAddress = neon_core_1.wallet.getAddressFromScriptHash(this.scriptHash.slice(2)); + //transfer some GAS + const params = [ + neon_core_1.sc.ContractParam.hash160(signer.address), + neon_core_1.sc.ContractParam.hash160(contractAddress), + neon_core_1.sc.ContractParam.integer(transferAmount), + neon_core_1.sc.ContractParam.array(neon_core_1.sc.ContractParam.integer(chestId), neon_core_1.sc.ContractParam.integer(amountPerReservoirItem)) + ]; + return await (0, helpers_1.variableInvoke)(this.node.url, this.networkMagic, tokenScriptHash, "transfer", params, signer); + } } exports.Chest = Chest; //# sourceMappingURL=Chest.js.map \ No newline at end of file diff --git a/sdk/dist/Chest.js.map b/sdk/dist/Chest.js.map index 27fcc7c..f5d629a 100644 --- a/sdk/dist/Chest.js.map +++ b/sdk/dist/Chest.js.map @@ -1 +1 @@ -{"version":3,"file":"Chest.js","sourceRoot":"","sources":["../src/Chest.ts"],"names":[],"mappings":";;;AAAA,mCAA4B;AAC5B,qDAAoD;AACpD,+BAA2C;AAC3C,2CAAmF;AACnF,uCAA0D;AAE1D,MAAM,eAAe,GAA2B;IAC9C,OAAO,EAAE,yBAAa,CAAC,QAAQ;CAChC,CAAA;AAED;;;;GAIG;AAEH,MAAa,KAAK;IAIhB,iIAAiI;IACjI,0HAA0H;IAC1H,8GAA8G;IAC9G,YAAY,UAAkC,EAAE;QANxC,YAAO,GAA2B,eAAe,CAAA;QACjD,iBAAY,GAAW,CAAC,CAAC,CAAA;QAM/B,QAAO,OAAO,CAAC,OAAO,EAAE;YACtB,KAAK,yBAAa,CAAC,OAAO;gBACxB,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,iCAAiC,CAAA;gBACrD,IAAI,CAAC,OAAO,CAAC,UAAU,GAAG,4CAA4C,CAAA;gBACtE,MAAK;YACP,KAAK,yBAAa,CAAC,OAAO;gBACxB,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,iCAAiC,CAAA;gBACrD,IAAI,CAAC,OAAO,CAAC,UAAU,GAAG,4CAA4C,CAAA;gBACtE,MAAK;YACP;gBACE,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,wBAAwB,CAAA;gBAC5C,IAAI,CAAC,OAAO,CAAC,UAAU,GAAG,4CAA4C,CAAA;gBACtE,MAAK;SACR;QACD,IAAI,CAAC,OAAO,GAAG,IAAA,cAAK,EAAC,EAAE,EAAE,IAAI,CAAC,O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C,OAAO,CAAC,EACjC,cAAE,CAAC,aAAa,CAAC,OAAO,CAAC,sBAAsB,CAAC,CACnD;SACF,CAAA;QACD,OAAO,MAAM,IAAA,wBAAc,EAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,EACxD,eAAe,EACf,UAAU,EACV,MAAM,EACN,MAAM,CACT,CAAC;IACJ,CAAC;CACF;AA9HD,sBA8HC"} \ No newline at end of file diff --git a/sdk/dist/api/chest.d.ts b/sdk/dist/api/chest.d.ts index cda519c..a036f9c 100644 --- a/sdk/dist/api/chest.d.ts +++ b/sdk/dist/api/chest.d.ts @@ -1,7 +1,7 @@ import { wallet } from "@cityofzion/neon-core"; import { EligibilityCase } from "../interface"; export declare class ChestAPI { - static createChest(node: string, networkMagic: number, contractHash: string, name: string, chestType: number, eligibilityCases: [EligibilityCase], signer: wallet.Account): Promise; + static createChest(node: string, networkMagic: number, contractHash: string, name: string, chestType: number, eligibilityCases: EligibilityCase[], signer: wallet.Account): Promise; static isEligible(node: string, networkMagic: number, contractHash: string, chestId: number, nftSriptHash: string, tokenId: string, signer?: wallet.Account): Promise; static lootChest(node: string, networkMagic: number, contractHash: string, chestId: number, nftScriptHash: string, tokenId: string, signer: wallet.Account): Promise; static lootChestAsOwner(node: string, networkMagic: number, contractHash: string, chestId: number, signer: wallet.Account): Promise; diff --git a/sdk/dist/api/chest.js b/sdk/dist/api/chest.js index 397469d..0985958 100644 --- a/sdk/dist/api/chest.js +++ b/sdk/dist/api/chest.js @@ -11,9 +11,10 @@ class ChestAPI { const attributes = eligibilityCase.attributes.map((attr) => { let value = neon_js_1.sc.ContractParam.byteArray(''); switch (typeof attr.value) { - case "string": + case typeof "a": value = neon_js_1.sc.ContractParam.string(attr.value); - case "number": + break; + case typeof 1: value = neon_js_1.sc.ContractParam.integer(attr.value); } return neon_js_1.sc.ContractParam.array(neon_js_1.sc.ContractParam.string(attr.logic), neon_js_1.sc.ContractParam.string(attr.key), value); diff --git a/sdk/dist/api/chest.js.map b/sdk/dist/api/chest.js.map index 6244a7b..17c6c0c 100644 --- a/sdk/dist/api/chest.js.map +++ b/sdk/dist/api/chest.js.map @@ -1 +1 @@ -{"version":3,"file":"chest.js","sourceRoot":"","sources":["../../src/api/chest.ts"],"names":[],"mappings":";;;AAAA,iDAAuC;AACvC,qDAAgD;AAChD,wCAAqD;AAGrD,MAAa,QAAQ;IAEnB,MAAM,CAAC,KAAK,CAAC,WAAW,CACtB,IAAY,EACZ,YAAoB,EACpB,YAAoB,EACpB,IAAY,EACZ,SAAiB,EACjB,gBAAmC,EACnC,MAAsB;QAEtB,MAAM,MAAM,GAAG,cAAc,CAAC;QAE9B,MAAM,KAAK,GAAG,gBAAgB,CAAC,GAAG,CAAE,CAAC,eAAgC,EAAE,EAAE;YAEvE,MAAM,UAAU,GAAG,eAAe,CAAC,UAAU,CAAC,GAAG,CAAE,CAAC,IAA0B,EAAE,EAAE;gBAEhF,IAAI,KAAK,GAAG,YAAE,CAAC,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;gBAC1C,QAAQ,OAAO,IAAI,CAAC,KAAK,EAAE;oBACzB,KAAK,QAAQ;wBACX,KAAK,GAAG,YAAE,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;oBAC7C,KAAK,QAAQ;wBACX,KAAK,GAAG,YAAE,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;iBAC/C;gBAED,OAAO,YAAE,CAAC,aAAa,CAAC,KAAK,CACzB,YAAE,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EACnC,YAAE,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EACjC,KAAK,CACR,CAAA;YACH,CAAC,CAAC,CAAA;YAEF,OAAO,YAAE,CAAC,aAAa,CAAC,KAAK,CACzB,YAAE,CAAC,aAAa,CAAC,OAAO,CAAC,eAA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;QACpC,MAAM,MAAM,GAAG,aAAC,CAAC,UAAU,CAAC,aAAC,CAAC,aAAa,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAA;QACjE,YAAY,CAAC,MAAM,GAAG,IAAI,kBAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QAChD,OAAO,YAAY,CAAA;IACrB,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,WAAW,CACtB,IAAY,EACZ,YAAoB,EACpB,YAAoB,EACpB,MAAuB;QAEvB,MAAM,MAAM,GAAG,cAAc,CAAC;QAE9B,MAAM,GAAG,GAAG,MAAM,IAAA,wBAAc,EAAC,IAAI,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,CAAA;QACtF,IAAI,MAAM,EAAE;YACV,OAAO,GAAG,CAAA;SACX;QACD,OAAO,IAAA,mBAAS,EAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IAC1B,CAAC;CAEF;AA3JD,4BA2JC"} \ No newline at end of file diff --git a/sdk/dist/interface/interface.d.ts b/sdk/dist/interface/interface.d.ts index 18e62c1..92f9185 100644 --- a/sdk/dist/interface/interface.d.ts +++ b/sdk/dist/interface/interface.d.ts @@ -122,5 +122,5 @@ export interface EligibilityAttribute { } export interface EligibilityCase { scriptHash: string; - attributes: [EligibilityAttribute]; + attributes: EligibilityAttribute[]; } diff --git a/sdk/package-lock.json b/sdk/package-lock.json index cf2e191..f2befef 100644 --- a/sdk/package-lock.json +++ b/sdk/package-lock.json @@ -1,12 +1,12 @@ { "name": "@cityofzion/props", - "version": "0.1.9", + "version": "0.2.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@cityofzion/props", - "version": "0.1.9", + "version": "0.2.0", "license": "ISC", "dependencies": { "@cityofzion/neon-core": "^5.0.0-next.16", diff --git a/sdk/package.json b/sdk/package.json index ef2c543..39700c8 100644 --- a/sdk/package.json +++ b/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@cityofzion/props", - "version": "0.2.0", + "version": "0.2.5", "description": "an sdk for interfacing with props to use in decentralized applications", "main": "dist/index", "types": "dist/index", diff --git a/sdk/src/Chest.ts b/sdk/src/Chest.ts index 1af4781..4b6e9a7 100644 --- a/sdk/src/Chest.ts +++ b/sdk/src/Chest.ts @@ -1,8 +1,9 @@ import {merge} from 'lodash' -import {rpc, u, wallet} from '@cityofzion/neon-core' +import {rpc, sc, u, wallet} from '@cityofzion/neon-core' import {ChestAPI, TemplateAPI} from './api' import {EligibilityCase, NetworkOption, PropConstructorOptions} from "./interface"; -import {formatter, sleep, txDidComplete} from "./helpers"; +import {formatter, sleep, txDidComplete, variableInvoke} from "./helpers"; +import Neon from "@cityofzion/neon-js"; const DEFAULT_OPTIONS: PropConstructorOptions = { network: NetworkOption.LocalNet @@ -79,7 +80,7 @@ export class Chest { * Create one of these pass throughs for each method you expose in your smart contract. The goal of this entire class is to * simplify the network configuration steps which can be complicated. */ - async createChest(name: string, type: number, eligibilityCases: [EligibilityCase], signer: wallet.Account): Promise { + async createChest(name: string, type: number, eligibilityCases: EligibilityCase[], signer: wallet.Account): Promise { return ChestAPI.createChest(this.node.url, this.networkMagic, this.scriptHash, name, type, eligibilityCases, signer) } @@ -116,8 +117,28 @@ export class Chest { return ChestAPI.getChestJSON(this.node.url, this.networkMagic, this.scriptHash, chestId, signer) } - async totalChests(name: string, type: number, signer?: wallet.Account): Promise { + async totalChests(signer?: wallet.Account): Promise { return ChestAPI.totalChests(this.node.url, this.networkMagic, this.scriptHash, signer) } + async loadChestFungible(tokenScriptHash: string, chestId: number, transferAmount: number, amountPerReservoirItem: number, signer: wallet.Account): Promise { + const contractAddress = wallet.getAddressFromScriptHash(this.scriptHash.slice(2)) + + //transfer some GAS + const params = [ + sc.ContractParam.hash160(signer.address), + sc.ContractParam.hash160(contractAddress), + sc.ContractParam.integer(transferAmount), + sc.ContractParam.array( + sc.ContractParam.integer(chestId), + sc.ContractParam.integer(amountPerReservoirItem) + ) + ] + return await variableInvoke(this.node.url, this.networkMagic, + tokenScriptHash, + "transfer", + params, + signer + ); + } } diff --git a/sdk/src/api/chest.ts b/sdk/src/api/chest.ts index d5becf8..42975fd 100644 --- a/sdk/src/api/chest.ts +++ b/sdk/src/api/chest.ts @@ -11,7 +11,7 @@ export class ChestAPI { contractHash: string, name: string, chestType: number, - eligibilityCases: [EligibilityCase], + eligibilityCases: EligibilityCase[], signer: wallet.Account, //this field can be optional if you are doing a test invocation(you arent changing contract state and dont rely on block entropy) ): Promise { const method = "create_chest"; diff --git a/sdk/test/integration/chest.js b/sdk/test/integration/chest.js index f81e709..02b05cb 100644 --- a/sdk/test/integration/chest.js +++ b/sdk/test/integration/chest.js @@ -18,6 +18,7 @@ describe("Basic Chest Test Suite", function() { const targetNetwork = sdk.types.NetworkOption.LocalNet chest = await new sdk.Chest({ + scriptHash: "0x9378d9f8add6e1d47e7af4d75c121a11a5e9f929", network: targetNetwork }) puppet = await new sdk.Puppet({ @@ -42,26 +43,28 @@ describe("Basic Chest Test Suite", function() { it("should create a new chest", async () => { this.timeout(0) - const cozWallet = network.wallets[0].wallet + const cozWallet = new Neon.wallet.Account('') + const lizard = '0xa6f144d552cc96103393b9ca4e34cc8fd384f4bf' const oldChestCount = await chest.totalChests() + console.log(oldChestCount) // create a chest and get the json const eligibilityCases = [ { - scriptHash: puppet.scriptHash.slice(2), + scriptHash: lizard.slice(2), attributes: [{ logic: 'e', key: 'traits.color', - value: 'blue' + value: "white" }] } ] - const txid = await chest.createChest("A test chest", 0, eligibilityCases, cozWallet) + console.log(txid) await sdk.helpers.sleep(TIME_CONSTANT) const res = await sdk.helpers.txDidComplete(chest.node.url, txid, true) console.log(res[0])