@lombardini.io/dapp
Advanced tools
Comparing version 0.0.42 to 0.0.48
@@ -23,3 +23,4 @@ import { IConfig } from './generic'; | ||
aTokenPrice: string; | ||
assetPrice: string; | ||
APR: string; | ||
APY: string; | ||
}; | ||
@@ -26,0 +27,0 @@ export declare type UserState = { |
@@ -71,4 +71,3 @@ "use strict"; | ||
}).then(function (x) { return JSON.parse(x).id; }) | ||
: signerOrKeeper.invoke(__assign(__assign({}, params), { fee: fee, | ||
feeAssetId: feeAssetId })).broadcast() | ||
: signerOrKeeper.invoke(__assign(__assign({}, params), { fee: fee, feeAssetId: feeAssetId })).broadcast() | ||
.then(function (x) { return x[0].id; })).then(function (txId) { return __awaiter(void 0, void 0, void 0, function () { | ||
@@ -78,3 +77,5 @@ return __generator(this, function (_a) { | ||
case 0: return [4 /*yield*/, waitTx_1.waitTx({ | ||
txId: txId, nodeApi: nodeApi, _fetch: _fetch | ||
txId: txId, | ||
nodeApi: nodeApi, | ||
_fetch: _fetch | ||
})]; | ||
@@ -81,0 +82,0 @@ case 1: |
@@ -1,4 +0,4 @@ | ||
export { onKeeperUserChanged, onKeeperLockedChanged, onKeeperNetworkChanged, loginWithKeeper, keeperErrors } from './keeper'; | ||
export { onKeeperUserChanged, onKeeperLockedChanged, onKeeperNetworkChanged, loginWithKeeper, keeperErrors, keeperPromise } from './keeper'; | ||
export { loginWithSigner } from './signer'; | ||
export * from './dappWrite'; | ||
export * from './dappRead'; |
@@ -13,3 +13,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.loginWithSigner = exports.keeperErrors = exports.loginWithKeeper = exports.onKeeperNetworkChanged = exports.onKeeperLockedChanged = exports.onKeeperUserChanged = void 0; | ||
exports.loginWithSigner = exports.keeperPromise = exports.keeperErrors = exports.loginWithKeeper = exports.onKeeperNetworkChanged = exports.onKeeperLockedChanged = exports.onKeeperUserChanged = void 0; | ||
var keeper_1 = require("./keeper"); | ||
@@ -21,2 +21,3 @@ Object.defineProperty(exports, "onKeeperUserChanged", { enumerable: true, get: function () { return keeper_1.onKeeperUserChanged; } }); | ||
Object.defineProperty(exports, "keeperErrors", { enumerable: true, get: function () { return keeper_1.keeperErrors; } }); | ||
Object.defineProperty(exports, "keeperPromise", { enumerable: true, get: function () { return keeper_1.keeperPromise; } }); | ||
var signer_1 = require("./signer"); | ||
@@ -23,0 +24,0 @@ Object.defineProperty(exports, "loginWithSigner", { enumerable: true, get: function () { return signer_1.loginWithSigner; } }); |
@@ -271,3 +271,2 @@ export declare type KeeperAPI = WavesKeeper.API; | ||
}) => any) => Promise<void>; | ||
export declare const onKeeper: (callback: () => any) => Promise<void>; | ||
export declare const loginWithKeeper: ({ chainId }: loginWithKeeperParams) => Promise<{ | ||
@@ -274,0 +273,0 @@ address: string; |
@@ -39,3 +39,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.loginWithKeeper = exports.onKeeper = exports.onKeeperNetworkChanged = exports.onKeeperLockedChanged = exports.onKeeperUserChanged = exports.keeperErrors = exports.keeperPromise = void 0; | ||
exports.loginWithKeeper = exports.onKeeperNetworkChanged = exports.onKeeperLockedChanged = exports.onKeeperUserChanged = exports.keeperErrors = exports.keeperPromise = void 0; | ||
exports.keeperPromise = new Promise(function (resolve) { return setTimeout(resolve, 300); }) | ||
@@ -54,3 +54,3 @@ .then(function () { | ||
var onKeeperUserChanged = function (callback) { return __awaiter(void 0, void 0, void 0, function () { | ||
var keeper, oldUser; | ||
var keeper, oldUser_1; | ||
var _a; | ||
@@ -62,18 +62,18 @@ return __generator(this, function (_b) { | ||
keeper = _b.sent(); | ||
if (!keeper) | ||
throw new Error(exports.keeperErrors.noKeeper); | ||
if (!keeper) return [3 /*break*/, 3]; | ||
return [4 /*yield*/, keeper.publicState()]; | ||
case 2: | ||
oldUser = (_a = (_b.sent()).account) === null || _a === void 0 ? void 0 : _a.address; | ||
oldUser_1 = (_a = (_b.sent()).account) === null || _a === void 0 ? void 0 : _a.address; | ||
keeper.on("update", function (state) { | ||
var _a, _b, _c; | ||
if (oldUser != ((_a = state.account) === null || _a === void 0 ? void 0 : _a.address)) { | ||
if (oldUser_1 != ((_a = state.account) === null || _a === void 0 ? void 0 : _a.address)) { | ||
callback({ | ||
oldUser: oldUser, | ||
oldUser: oldUser_1, | ||
newUser: (_b = state.account) === null || _b === void 0 ? void 0 : _b.address, | ||
}); | ||
oldUser = (_c = state.account) === null || _c === void 0 ? void 0 : _c.address; | ||
oldUser_1 = (_c = state.account) === null || _c === void 0 ? void 0 : _c.address; | ||
} | ||
}); | ||
return [2 /*return*/]; | ||
_b.label = 3; | ||
case 3: return [2 /*return*/]; | ||
} | ||
@@ -84,3 +84,3 @@ }); | ||
var onKeeperLockedChanged = function (callback) { return __awaiter(void 0, void 0, void 0, function () { | ||
var keeper, locked; | ||
var keeper, locked_1; | ||
var _a, _b; | ||
@@ -92,14 +92,14 @@ return __generator(this, function (_c) { | ||
keeper = _c.sent(); | ||
if (!keeper) | ||
throw new Error(exports.keeperErrors.noKeeper); | ||
if (!keeper) return [3 /*break*/, 3]; | ||
return [4 /*yield*/, keeper.publicState()]; | ||
case 2: | ||
locked = (_b = (_a = (_c.sent())) === null || _a === void 0 ? void 0 : _a.locked) !== null && _b !== void 0 ? _b : undefined; | ||
locked_1 = (_b = (_a = (_c.sent())) === null || _a === void 0 ? void 0 : _a.locked) !== null && _b !== void 0 ? _b : undefined; | ||
keeper.on("update", function (state) { | ||
if (locked != state.locked) { | ||
locked = state.locked; | ||
callback({ locked: locked }); | ||
if (locked_1 != state.locked) { | ||
locked_1 = state.locked; | ||
callback({ locked: locked_1 }); | ||
} | ||
}); | ||
return [2 /*return*/]; | ||
_c.label = 3; | ||
case 3: return [2 /*return*/]; | ||
} | ||
@@ -110,3 +110,3 @@ }); | ||
var onKeeperNetworkChanged = function (callback) { return __awaiter(void 0, void 0, void 0, function () { | ||
var keeper, network; | ||
var keeper, network_1; | ||
var _a, _b, _c; | ||
@@ -118,14 +118,14 @@ return __generator(this, function (_d) { | ||
keeper = _d.sent(); | ||
if (!keeper) | ||
throw new Error(exports.keeperErrors.noKeeper); | ||
if (!keeper) return [3 /*break*/, 3]; | ||
return [4 /*yield*/, keeper.publicState()]; | ||
case 2: | ||
network = (_c = (_b = (_a = (_d.sent())) === null || _a === void 0 ? void 0 : _a.network) === null || _b === void 0 ? void 0 : _b.code) !== null && _c !== void 0 ? _c : undefined; | ||
network_1 = (_c = (_b = (_a = (_d.sent())) === null || _a === void 0 ? void 0 : _a.network) === null || _b === void 0 ? void 0 : _b.code) !== null && _c !== void 0 ? _c : undefined; | ||
keeper.on("update", function (state) { | ||
if (network != state.network.code) { | ||
network = state.network.code; | ||
callback({ network: network }); | ||
if (network_1 != state.network.code) { | ||
network_1 = state.network.code; | ||
callback({ network: network_1 }); | ||
} | ||
}); | ||
return [2 /*return*/]; | ||
_d.label = 3; | ||
case 3: return [2 /*return*/]; | ||
} | ||
@@ -135,26 +135,2 @@ }); | ||
exports.onKeeperNetworkChanged = onKeeperNetworkChanged; | ||
var onKeeper = function (callback) { return __awaiter(void 0, void 0, void 0, function () { | ||
var keeper, locked; | ||
var _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, exports.keeperPromise]; | ||
case 1: | ||
keeper = _b.sent(); | ||
if (!keeper) | ||
throw new Error(exports.keeperErrors.noKeeper); | ||
return [4 /*yield*/, keeper.publicState()]; | ||
case 2: | ||
locked = (_a = (_b.sent())) === null || _a === void 0 ? void 0 : _a.locked; | ||
keeper.on("update", function (state) { | ||
if (locked != state.locked) { | ||
callback(); | ||
locked = state.locked; | ||
} | ||
}); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }; | ||
exports.onKeeper = onKeeper; | ||
var loginWithKeeper = function (_a) { | ||
@@ -170,3 +146,3 @@ var chainId = _a.chainId; | ||
if (!keeper) | ||
throw new Error(exports.keeperErrors.noKeeper); | ||
throw exports.keeperErrors.noKeeper; | ||
return [4 /*yield*/, (keeper === null || keeper === void 0 ? void 0 : keeper.publicState().then(function (x) { | ||
@@ -173,0 +149,0 @@ if (chainId !== x.network.code) |
{ | ||
"name": "@lombardini.io/dapp", | ||
"version": "0.0.42", | ||
"version": "0.0.48", | ||
"description": "lombardini.io smart contract interactions", | ||
@@ -34,4 +34,4 @@ "keywords": [ | ||
"@types/ncp": "^2.0.4", | ||
"@types/node": "^14.14.35", | ||
"@types/node-fetch": "^2.5.8", | ||
"@types/node": "^15.12.4", | ||
"@types/node-fetch": "^2.5.10", | ||
"@waves/ts-contract": "0.0.17", | ||
@@ -42,6 +42,6 @@ "@waves/ts-lib-crypto": "1.4.3", | ||
"node-fetch": "^2.6.1", | ||
"ts-loader": "^8.0.18", | ||
"typescript": "^4.2.3", | ||
"webpack": "^5.26.2", | ||
"webpack-cli": "^4.5.0" | ||
"ts-loader": "^9.2.3", | ||
"typescript": "^4.3.4", | ||
"webpack": "^5.39.1", | ||
"webpack-cli": "^4.7.2" | ||
}, | ||
@@ -48,0 +48,0 @@ "dependencies": { |
@@ -135,2 +135,10 @@ ## Breaking change v0.0.26 | ||
``` | ||
## check keeper installed and wait for the instance | ||
```typescript | ||
import { keeperPromise } from '@lombardini.io/dapp' | ||
const keeper: WavesKeeper.API | undefined = await keeperPromise | ||
if(keeper) { | ||
//do something | ||
} | ||
``` | ||
@@ -137,0 +145,0 @@ ## handling keeper events example |
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
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
159
79268
1199