Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vires.finance/dapp

Package Overview
Dependencies
Maintainers
3
Versions
91
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vires.finance/dapp - npm Package Compare versions

Comparing version 0.0.65 to 0.0.66

1

dappErorrs.d.ts
export declare const dappErrorHandler: (e: any) => Promise<never>;
export declare const transferErrorHandler: (e: any) => Promise<never>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.dappErrorHandler = void 0;
exports.transferErrorHandler = exports.dappErrorHandler = void 0;
var errorRegex = /FailedTransactionError\(.*?error\s*=\s*(.*)?,\s*log/gm;

@@ -16,2 +16,6 @@ var dappErrorHandler = function (e) {

exports.dappErrorHandler = dappErrorHandler;
var transferErrorHandler = function (e) {
return Promise.reject(e);
};
exports.transferErrorHandler = transferErrorHandler;
//# sourceMappingURL=dappErorrs.js.map

@@ -37,4 +37,12 @@ import { KeeperAPI } from './keeper';

};
export declare const broadcastInvoke: ({ nodeApi }: IConfig, signerOrKeeper: SignerOrKeeper, { dApp, func, args, fee, feeAssetId, payment }: broadcastInvokeParams, _fetch?: typeof fetch) => Promise<string>;
declare type broadcastTransferParams = {
recipient: string;
assetId: string;
amount: number;
fee: number;
feeAssetId?: string;
};
export declare const broadcastTransfer: ({ nodeApi }: IConfig, signerOrKeeper: SignerOrKeeper, { recipient, assetId, amount, fee, feeAssetId }: broadcastTransferParams, _fetch?: typeof fetch) => Promise<string>;
export declare const signCustomData: (signerOrKeeper: SignerOrKeeper, bytes: string) => Promise<string>;
export declare const broadcastInvoke: ({ nodeApi }: IConfig, signerOrKeeper: SignerOrKeeper, { dApp, func, args, fee, feeAssetId, payment }: broadcastInvokeParams, _fetch?: typeof fetch) => Promise<string>;
export {};

75

generic.js

@@ -50,6 +50,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.broadcastInvoke = exports.signCustomData = void 0;
exports.signCustomData = exports.broadcastTransfer = exports.broadcastInvoke = void 0;
var dappErorrs_1 = require("./dappErorrs");
var waitTx_1 = require("./waitTx");
var isKeeper = function (signerOrKeeper) { return 'initialPromise' in signerOrKeeper; };
var toBase64 = function (bytes) {

@@ -60,11 +59,3 @@ return global.Buffer

};
var signCustomData = function (signerOrKeeper, bytes) {
return isKeeper(signerOrKeeper)
? signerOrKeeper.signCustomData({
version: 1,
binary: 'base64:' + toBase64(bytes),
}).then(function (x) { return x.signature; })
: signerOrKeeper.signMessage(bytes);
};
exports.signCustomData = signCustomData;
var isKeeper = function (signerOrKeeper) { return 'initialPromise' in signerOrKeeper; };
var broadcastInvoke = function (_a, signerOrKeeper, _b, _fetch) {

@@ -88,8 +79,3 @@ var nodeApi = _a.nodeApi;

: signerOrKeeper.invoke(__assign(__assign({}, params), { fee: fee, feeAssetId: feeAssetId })).broadcast()
.then(function (x) {
var _a, _b;
var mayBeArrayMayBeNotMayBeGoFuckYourself = x;
var id = (_b = (_a = mayBeArrayMayBeNotMayBeGoFuckYourself[0]) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : mayBeArrayMayBeNotMayBeGoFuckYourself === null || mayBeArrayMayBeNotMayBeGoFuckYourself === void 0 ? void 0 : mayBeArrayMayBeNotMayBeGoFuckYourself.id;
return id;
})).then(function (txId) { return __awaiter(void 0, void 0, void 0, function () {
.then(extractId)).then(function (txId) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {

@@ -111,2 +97,57 @@ switch (_a.label) {

exports.broadcastInvoke = broadcastInvoke;
var broadcastTransfer = function (_a, signerOrKeeper, _b, _fetch) {
var nodeApi = _a.nodeApi;
var recipient = _b.recipient, assetId = _b.assetId, amount = _b.amount, fee = _b.fee, feeAssetId = _b.feeAssetId;
if (_fetch === void 0) { _fetch = fetch; }
return (isKeeper(signerOrKeeper)
? signerOrKeeper.signAndPublishTransaction({
type: 4,
data: {
recipient: recipient,
amount: { assetId: assetId, amount: amount },
fee: {
amount: fee,
assetId: feeAssetId || 'WAVES',
},
}
}).then(function (x) { return JSON.parse(x).id; })
: signerOrKeeper.transfer({
recipient: recipient,
amount: amount,
assetId: assetId,
fee: fee,
feeAssetId: feeAssetId,
}).broadcast()
.then(extractId)).then(function (txId) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, waitTx_1.waitTx({
txId: txId,
nodeApi: nodeApi,
_fetch: _fetch
})];
case 1:
_a.sent();
return [2 /*return*/, txId];
}
});
}); })
.catch(dappErorrs_1.transferErrorHandler);
};
exports.broadcastTransfer = broadcastTransfer;
var signCustomData = function (signerOrKeeper, bytes) {
return isKeeper(signerOrKeeper)
? signerOrKeeper.signCustomData({
version: 1,
binary: 'base64:' + toBase64(bytes),
}).then(function (x) { return x.signature; })
: signerOrKeeper.signMessage(bytes);
};
exports.signCustomData = signCustomData;
var extractId = function (x) {
var _a, _b;
var y = x;
var id = (_b = (_a = y[0]) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : y === null || y === void 0 ? void 0 : y.id;
return id;
};
//# sourceMappingURL=generic.js.map

@@ -6,3 +6,3 @@ export { onKeeperUserChanged, onKeeperLockedChanged, onKeeperNetworkChanged, loginWithKeeper, keeperErrors, keeperPromise } from './keeper';

import * as dappReadV2 from './dappReadV2/dappReadV2';
export { signCustomData } from './generic';
export { signCustomData, broadcastInvoke, broadcastTransfer } from './generic';
export declare const v2: typeof dappReadV2;

@@ -25,3 +25,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.v2 = exports.signCustomData = exports.signerErrors = exports.loginWithSigner = exports.keeperPromise = exports.keeperErrors = exports.loginWithKeeper = exports.onKeeperNetworkChanged = exports.onKeeperLockedChanged = exports.onKeeperUserChanged = void 0;
exports.v2 = exports.broadcastTransfer = exports.broadcastInvoke = exports.signCustomData = exports.signerErrors = exports.loginWithSigner = exports.keeperPromise = exports.keeperErrors = exports.loginWithKeeper = exports.onKeeperNetworkChanged = exports.onKeeperLockedChanged = exports.onKeeperUserChanged = void 0;
var keeper_1 = require("./keeper");

@@ -42,3 +42,5 @@ Object.defineProperty(exports, "onKeeperUserChanged", { enumerable: true, get: function () { return keeper_1.onKeeperUserChanged; } });

Object.defineProperty(exports, "signCustomData", { enumerable: true, get: function () { return generic_1.signCustomData; } });
Object.defineProperty(exports, "broadcastInvoke", { enumerable: true, get: function () { return generic_1.broadcastInvoke; } });
Object.defineProperty(exports, "broadcastTransfer", { enumerable: true, get: function () { return generic_1.broadcastTransfer; } });
exports.v2 = dappReadV2;
//# sourceMappingURL=index.js.map
{
"name": "@vires.finance/dapp",
"version": "0.0.65",
"version": "0.0.66",
"description": "vires.finance smart contract interactions",

@@ -5,0 +5,0 @@ "keywords": [

@@ -189,2 +189,19 @@ ## Breaking change v0.0.26

}
```
## broadcastTransfer
```typescript
import { loginWithKeeper, broadcastTransfer } from '@vires.finance/dapp'
const loginWithKeeperAndTransfer1Waves = async () => {
const { keeper } = await loginWithKeeper({ chainId: 'R' })
const result = await broadcastTransfer(config, keeper, {
amount: 1 * 10 ** 8, //1 waves
assetId: 'WAVES',
recipient: 'address',
fee: 100000,
})
console.log(result)
}
```

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc