diff --git a/sdk/dist/Chest.d.ts b/sdk/dist/Chest.d.ts index 3ffa0a3..c3e41ab 100644 --- a/sdk/dist/Chest.d.ts +++ b/sdk/dist/Chest.d.ts @@ -40,4 +40,5 @@ export declare class Chest { lootChestAsOwner(chestId: number, signer: wallet.Account): Promise; getChestJSON(chestId: 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 2258a5a..0a9df82 100644 --- a/sdk/dist/Chest.js +++ b/sdk/dist/Chest.js @@ -109,6 +109,17 @@ class Chest { 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 8ec39bc..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,E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EAAE,IAAI,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA;IAClG,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,MAAuB;QACvC,OAAO,cAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;IACxF,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,eAAuB,EAAE,OAAe,EAAE,cAAsB,EAAE,sBAA8B,EAAE,MAAsB;QAC9I,MAAM,eAAe,GAAG,kBAAM,CAAC,wBAAwB,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;QAEjF,mBAAmB;QACnB,MAAM,MAAM,GAAG;YACb,cAAE,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;YACxC,cAAE,CAAC,aAAa,CAAC,OAAO,CAAC,eAAe,CAAC;YACzC,cAAE,CAAC,aAAa,CAAC,OAAO,CAAC,cAAc,CAAC;YACxC,cAAE,CAAC,aAAa,CAAC,KAAK,CAClB,cAAE,CAAC,aAAa,CAAC,OAAO,CAAC,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/package.json b/sdk/package.json index 2370525..39700c8 100644 --- a/sdk/package.json +++ b/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@cityofzion/props", - "version": "0.2.4", + "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 b146ad7..4b6e9a7 100644 --- a/sdk/src/Chest.ts +++ b/sdk/src/Chest.ts @@ -2,9 +2,8 @@ import {merge} from 'lodash' 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"; -import sdk from "../dist"; const DEFAULT_OPTIONS: PropConstructorOptions = { network: NetworkOption.LocalNet @@ -135,7 +134,7 @@ export class Chest { sc.ContractParam.integer(amountPerReservoirItem) ) ] - return await sdk.api.NeoInterface.publishInvoke(this.node.url, this.networkMagic, + return await variableInvoke(this.node.url, this.networkMagic, tokenScriptHash, "transfer", params,