conseiljs
Advanced tools
Comparing version 5.0.8-1 to 5.0.8-2
@@ -17,2 +17,6 @@ import { KeyStore, Signer } from '../../../types/ExternalInterfaces'; | ||
function getAccountBalance(server: string, mapid: number, account: string): Promise<number>; | ||
function getAccountPoolShare(server: string, address: string, account: string): Promise<{ | ||
token: number; | ||
xtz: number; | ||
}>; | ||
function getAccountAllowance(server: string, mapid: number, account: string, spender: string): Promise<any>; | ||
@@ -19,0 +23,0 @@ function addLiquidity(server: string, signer: Signer, keyStore: KeyStore, contract: string, fee: number, liquidityAmount: number, xtzAmount: number, tokenAmount: number, expiration: Date): Promise<string>; |
@@ -51,9 +51,9 @@ "use strict"; | ||
balanceMap: Number(jsonpath_plus_1.JSONPath({ path: '$.args[0].int', json: storageResult })[0]), | ||
administrator: jsonpath_plus_1.JSONPath({ path: '$.args[1].args[1].args[0].args[0].string', json: storageResult })[0], | ||
token: jsonpath_plus_1.JSONPath({ path: '$.args[1].args[1].args[0].args[1].string', json: storageResult })[0], | ||
tokenBalance: Number(jsonpath_plus_1.JSONPath({ path: '$.args[1].args[1].args[1].args[1].int', json: storageResult })[0]), | ||
xtzBalance: Number(jsonpath_plus_1.JSONPath({ path: '$.args[1].args[1].args[1].args[0].int', json: storageResult })[0]), | ||
selfIsUpdatingTokenPool: (jsonpath_plus_1.JSONPath({ path: '$.args[1].args[0].args[0].prim', json: storageResult })[0]).toString().toLowerCase().startsWith('t'), | ||
freeze_baker: (jsonpath_plus_1.JSONPath({ path: '$.args[1].args[0].args[1].args[0].prim', json: storageResult })[0]).toString().toLowerCase().startsWith('t'), | ||
lqt_total: Number(jsonpath_plus_1.JSONPath({ path: '$.args[1].args[0].args[1].args[1].int', json: storageResult })[0]) | ||
administrator: jsonpath_plus_1.JSONPath({ path: '$.args[2].args[0].string', json: storageResult })[0], | ||
token: jsonpath_plus_1.JSONPath({ path: '$.args[2].args[1].string', json: storageResult })[0], | ||
tokenBalance: Number(jsonpath_plus_1.JSONPath({ path: '$.args[3].int', json: storageResult })[0]), | ||
xtzBalance: Number(jsonpath_plus_1.JSONPath({ path: '$.args[4].int', json: storageResult })[0]), | ||
selfIsUpdatingTokenPool: (jsonpath_plus_1.JSONPath({ path: '$.args[1].args[0].prim', json: storageResult })[0]).toString().toLowerCase().startsWith('t'), | ||
freeze_baker: (jsonpath_plus_1.JSONPath({ path: '$.args[1].args[0].prim', json: storageResult })[0]).toString().toLowerCase().startsWith('t'), | ||
lqt_total: Number(jsonpath_plus_1.JSONPath({ path: '$.args[1].args[2].int', json: storageResult })[0]) | ||
}; | ||
@@ -80,2 +80,23 @@ }); | ||
DexterPoolHelper.getAccountBalance = getAccountBalance; | ||
function getAccountPoolShare(server, address, account) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
try { | ||
const storage = yield getSimpleStorage(server, address); | ||
const packedKey = TezosMessageUtil_1.TezosMessageUtils.encodeBigMapKey(Buffer.from(TezosMessageUtil_1.TezosMessageUtils.writePackedData(account, 'address'), 'hex')); | ||
const mapResult = yield TezosNodeReader_1.TezosNodeReader.getValueForBigMapKey(server, storage.balanceMap, packedKey); | ||
if (mapResult === undefined) { | ||
throw new Error(`Map ${storage.balanceMap} does not contain a record for ${account}`); | ||
} | ||
const poolBalance = big_integer_1.default(jsonpath_plus_1.JSONPath({ path: '$.args[0].int', json: mapResult })[0]); | ||
const poolTotal = big_integer_1.default(storage.lqt_total); | ||
const tokenBalance = big_integer_1.default(storage.tokenBalance); | ||
const xtzBalance = big_integer_1.default(storage.xtzBalance); | ||
return { token: tokenBalance.multiply(poolBalance).divide(poolTotal).toJSNumber(), xtz: xtzBalance.multiply(poolBalance).divide(poolTotal).toJSNumber() }; | ||
} | ||
catch (error) { | ||
return { token: 0, xtz: 0 }; | ||
} | ||
}); | ||
} | ||
DexterPoolHelper.getAccountPoolShare = getAccountPoolShare; | ||
function getAccountAllowance(server, mapid, account, spender) { | ||
@@ -82,0 +103,0 @@ return __awaiter(this, void 0, void 0, function* () { |
@@ -34,3 +34,3 @@ import { KeyStore, Signer } from '../../../types/ExternalInterfaces'; | ||
function getAccountBalance(server: string, mapid: number, account: string): Promise<number>; | ||
function transferBalance(nodeUrl: string, signer: Signer, keystore: KeyStore, tokenContractAddress: string, fee: number, sourceAddress: string, destinationAddress: string, amount: number, gasLimit?: number, storageLimit?: number): Promise<string>; | ||
function transferBalance(nodeUrl: string, signer: Signer, keystore: KeyStore, tokenContractAddress: string, fee: number, sourceAddress: string, destinationAddress: string, amount: number | string, gasLimit?: number, storageLimit?: number): Promise<string>; | ||
function depositToOven(nodeUrl: string, signer: Signer, keystore: KeyStore, ovenAddress: string, fee: number, amountMutez: number, gasLimit?: number, storageLimit?: number): Promise<string>; | ||
@@ -37,0 +37,0 @@ function withdrawFromOven(nodeUrl: string, signer: Signer, keystore: KeyStore, ovenAddress: string, fee: number, amountMutez: number, gasLimit?: number, storageLimit?: number): Promise<string>; |
@@ -435,14 +435,2 @@ "use strict"; | ||
const dipnToJson = d => (d.length > 4) ? `{ "prim": "${d[0]}", "args": [ { "int": "${d[2]}" }, [ ${d[4]} ] ] }` : `{ "prim": "${d[0]}", "args": [ ${d[2]} ] }`; | ||
const dupnToJson = d => { | ||
const n = Number(d[2]); | ||
if (n === 1) { | ||
return '{ "prim": "DUP" }'; | ||
} | ||
else if (n === 2) { | ||
return '[{ "prim": "DIP", "args": [[ {"prim": "DUP"} ]] }, { "prim": "SWAP" }]'; | ||
} | ||
else { | ||
return `[{ "prim": "DIP", "args": [ {"int": "${n - 1}"}, [{ "prim": "DUP" }] ] }, { "prim": "DIG", "args": [ {"int": "${n}"} ] }]`; | ||
} | ||
}; | ||
const dignToJson = d => `{ "prim": "${d[0]}", "args": [ { "int": "${d[2]}" } ] }`; | ||
@@ -686,3 +674,3 @@ const dropnToJson = d => `{ "prim": "${d[0]}", "args": [ { "int": "${d[2]}" } ] }`; | ||
{ "name": "instruction$ebnf$10", "symbols": ["instruction$ebnf$10", /[0-9]/], "postprocess": (d) => d[0].concat([d[1]]) }, | ||
{ "name": "instruction", "symbols": [{ "literal": "DUP" }, "_", "instruction$ebnf$10"], "postprocess": dupnToJson }, | ||
{ "name": "instruction", "symbols": [{ "literal": "DUP" }, "_", "instruction$ebnf$10"], "postprocess": dignToJson }, | ||
{ "name": "instruction", "symbols": [{ "literal": "DUP" }], "postprocess": keywordToJson }, | ||
@@ -689,0 +677,0 @@ { "name": "instruction$ebnf$11$subexpression$1", "symbols": ["_", (lexer.has("annot") ? { type: "annot" } : annot)] }, |
{ | ||
"name": "conseiljs", | ||
"version": "5.0.8-1", | ||
"version": "5.0.8-2", | ||
"description": "Client-side library for Tezos dApp development.", | ||
@@ -101,3 +101,3 @@ "browser": "dist/index-web.js", | ||
"tsconfig-paths-webpack-plugin": "3.3.0", | ||
"typedoc": "0.18.0", | ||
"typedoc": "^0.20.34", | ||
"typedoc-plugin-markdown": "2.4.2", | ||
@@ -104,0 +104,0 @@ "typescript": "3.8.3", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
804613
7697