@kava-labs/javascript-sdk
Advanced tools
Comparing version 5.3.2 to 9.0.0-beta
@@ -21,3 +21,3 @@ /// <reference types="node" /> | ||
cosmos: { | ||
newStdTx: (msgs: any[], fee?: { | ||
newStdTx: <T = unknown>(msgs: import("./types/Message").Message<T>[], fee?: { | ||
amount: never[]; | ||
@@ -28,3 +28,3 @@ gas: string; | ||
value: { | ||
msg: any[]; | ||
msg: import("./types/Message").Message<T>[]; | ||
fee: { | ||
@@ -54,2 +54,14 @@ amount: never[]; | ||
}; | ||
newMsgTransfer: (sourcePort: string, sourceChannel: string, token: import("./types").Coin, sender: string, receiver: string, timeoutTimestamp: number) => { | ||
type: string; | ||
value: { | ||
source_port: string; | ||
source_channel: string; | ||
token: import("./types").Coin; | ||
sender: string; | ||
receiver: string; | ||
timeoutHeight: number; | ||
timeoutTimestamp: number; | ||
}; | ||
}; | ||
}; | ||
@@ -56,0 +68,0 @@ kava: { |
import { Coin } from '../../types/Coin'; | ||
import { Message } from '../../types/Message'; | ||
import { VoteType } from '../../types/VoteType'; | ||
@@ -11,3 +12,3 @@ /** | ||
*/ | ||
declare function newStdTx(msgs: any[], fee?: { | ||
declare function newStdTx<T = unknown>(msgs: Message<T>[], fee?: { | ||
amount: never[]; | ||
@@ -18,3 +19,3 @@ gas: string; | ||
value: { | ||
msg: any[]; | ||
msg: Message<T>[]; | ||
fee: { | ||
@@ -44,2 +45,24 @@ amount: never[]; | ||
}; | ||
/** | ||
* Creates an IBC transfer | ||
* @param {String} sourcePort the port identifier, we would expect to always be "transfer" * @param {String} sourcePort the port identifier, we would expect to always be "transfer" | ||
* @param {String} source_channel the channel identifier | ||
* @param {Coin} token | ||
* @param {String} sender address of sender on the origin chain | ||
* @param {String} receiver address of recipient on the destination chain | ||
* @param {Integer} timeoutTimestamp nanoseconds to allow transfer to complete | ||
*/ | ||
declare function newMsgTransfer(sourcePort: string, sourceChannel: string, token: Coin, sender: string, receiver: string, timeoutTimestamp: number): { | ||
type: string; | ||
value: { | ||
source_port: string; | ||
source_channel: string; | ||
token: Coin; | ||
sender: string; | ||
receiver: string; | ||
timeoutHeight: number; | ||
timeoutTimestamp: number; | ||
}; | ||
}; | ||
export declare const cosmos: { | ||
@@ -49,3 +72,4 @@ newStdTx: typeof newStdTx; | ||
newMsgVoteGovernance: typeof newMsgVoteGovernance; | ||
newMsgTransfer: typeof newMsgTransfer; | ||
}; | ||
export {}; |
@@ -27,3 +27,2 @@ "use strict"; | ||
} | ||
// newMsgSend creates a new MsgSend | ||
function newMsgSend(address, to, coins) { | ||
@@ -52,2 +51,26 @@ var sendTx = { | ||
} | ||
/** | ||
* Creates an IBC transfer | ||
* @param {String} sourcePort the port identifier, we would expect to always be "transfer" * @param {String} sourcePort the port identifier, we would expect to always be "transfer" | ||
* @param {String} source_channel the channel identifier | ||
* @param {Coin} token | ||
* @param {String} sender address of sender on the origin chain | ||
* @param {String} receiver address of recipient on the destination chain | ||
* @param {Integer} timeoutTimestamp nanoseconds to allow transfer to complete | ||
*/ | ||
function newMsgTransfer(sourcePort, sourceChannel, token, sender, receiver, timeoutTimestamp) { | ||
return { | ||
type: 'cosmos-sdk/MsgTransfer', | ||
value: { | ||
source_port: sourcePort, | ||
source_channel: sourceChannel, | ||
token: token, | ||
sender: sender, | ||
receiver: receiver, | ||
timeoutHeight: 0, | ||
timeoutTimestamp: timeoutTimestamp, | ||
}, | ||
}; | ||
} | ||
exports.cosmos = { | ||
@@ -57,2 +80,3 @@ newStdTx: newStdTx, | ||
newMsgVoteGovernance: newMsgVoteGovernance, | ||
newMsgTransfer: newMsgTransfer, | ||
}; |
@@ -53,2 +53,27 @@ "use strict"; | ||
}); | ||
describe('newMsgTransfer', function () { | ||
it('should generate a well-formed transfer', function () { | ||
var coin = { | ||
denom: 'ukava', | ||
amount: '10000000', | ||
}; | ||
var message = _1.cosmos.newMsgTransfer('transfer', 'channel-0', coin, 'kava1w66puffhccjck70hw75wu3v92tshw5rmdxp8hb', 'kava1a22puffhccjck70hw75wu3v92tshw5rmdxp6xz', 1638988347480000); | ||
var expected = { | ||
type: 'cosmos-sdk/MsgTransfer', | ||
value: { | ||
source_port: 'transfer', | ||
source_channel: 'channel-0', | ||
token: { | ||
denom: 'ukava', | ||
amount: '10000000', | ||
}, | ||
sender: 'kava1w66puffhccjck70hw75wu3v92tshw5rmdxp8hb', | ||
receiver: 'kava1a22puffhccjck70hw75wu3v92tshw5rmdxp6xz', | ||
timeoutHeight: 0, | ||
timeoutTimestamp: 1638988347480000, | ||
}, | ||
}; | ||
expect(message).toEqual(expected); | ||
}); | ||
}); | ||
}); |
export declare const msg: { | ||
cosmos: { | ||
newStdTx: (msgs: any[], fee?: { | ||
newStdTx: <T = unknown>(msgs: import("../types/Message").Message<T>[], fee?: { | ||
amount: never[]; | ||
@@ -9,3 +9,3 @@ gas: string; | ||
value: { | ||
msg: any[]; | ||
msg: import("../types/Message").Message<T>[]; | ||
fee: { | ||
@@ -35,2 +35,14 @@ amount: never[]; | ||
}; | ||
newMsgTransfer: (sourcePort: string, sourceChannel: string, token: import("..").Coin, sender: string, receiver: string, timeoutTimestamp: number) => { | ||
type: string; | ||
value: { | ||
source_port: string; | ||
source_channel: string; | ||
token: import("..").Coin; | ||
sender: string; | ||
receiver: string; | ||
timeoutHeight: number; | ||
timeoutTimestamp: number; | ||
}; | ||
}; | ||
}; | ||
@@ -37,0 +49,0 @@ kava: { |
@@ -1,1 +0,5 @@ | ||
export declare type VoteType = 'Yes' | 'No' | 'Abstain'; | ||
export declare enum VoteType { | ||
YES = 1, | ||
ABSTAIN = 2, | ||
NO = 3 | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.VoteType = void 0; | ||
var VoteType; | ||
(function (VoteType) { | ||
VoteType[VoteType["YES"] = 1] = "YES"; | ||
VoteType[VoteType["ABSTAIN"] = 2] = "ABSTAIN"; | ||
VoteType[VoteType["NO"] = 3] = "NO"; | ||
})(VoteType = exports.VoteType || (exports.VoteType = {})); |
{ | ||
"name": "@kava-labs/javascript-sdk", | ||
"version": "5.3.2", | ||
"version": "9.0.0-beta", | ||
"description": "Supports interaction with the Kava blockchain via a REST api", | ||
@@ -25,2 +25,5 @@ "main": "lib/index.js", | ||
"@binance-chain/javascript-sdk": "^3.0.2", | ||
"@typescript-eslint/eslint-plugin": "^5.6.0", | ||
"@typescript-eslint/parser": "^5.6.0", | ||
"eslint": "^8.4.1", | ||
"husky": "^7.0.1", | ||
@@ -27,0 +30,0 @@ "jest": "^27.3.1", |
@@ -52,2 +52,35 @@ import { cosmos } from '.'; | ||
}); | ||
describe('newMsgTransfer', () => { | ||
it('should generate a well-formed transfer', () => { | ||
const coin = { | ||
denom: 'ukava', | ||
amount: '10000000', | ||
}; | ||
const message = cosmos.newMsgTransfer( | ||
'transfer', | ||
'channel-0', | ||
coin, | ||
'kava1w66puffhccjck70hw75wu3v92tshw5rmdxp8hb', | ||
'kava1a22puffhccjck70hw75wu3v92tshw5rmdxp6xz', | ||
1638988347480000 | ||
); | ||
const expected = { | ||
type: 'cosmos-sdk/MsgTransfer', | ||
value: { | ||
source_port: 'transfer', | ||
source_channel: 'channel-0', | ||
token: { | ||
denom: 'ukava', | ||
amount: '10000000', | ||
}, | ||
sender: 'kava1w66puffhccjck70hw75wu3v92tshw5rmdxp8hb', | ||
receiver: 'kava1a22puffhccjck70hw75wu3v92tshw5rmdxp6xz', | ||
timeoutHeight: 0, | ||
timeoutTimestamp: 1638988347480000, | ||
}, | ||
}; | ||
expect(message).toEqual(expected); | ||
}); | ||
}); | ||
}); |
@@ -1,3 +0,3 @@ | ||
import _ from 'lodash'; | ||
import { Coin } from '../../types/Coin'; | ||
import { Message } from '../../types/Message'; | ||
import { VoteType } from '../../types/VoteType'; | ||
@@ -15,4 +15,4 @@ | ||
*/ | ||
function newStdTx( | ||
msgs: any[], | ||
function newStdTx<T = unknown>( | ||
msgs: Message<T>[], | ||
fee = FEE_DEFAULT, | ||
@@ -33,3 +33,2 @@ memo = '', | ||
// newMsgSend creates a new MsgSend | ||
function newMsgSend(address: string, to: string, coins: Coin[]) { | ||
@@ -64,2 +63,34 @@ const sendTx = { | ||
/** | ||
* Creates an IBC transfer | ||
* @param {String} sourcePort the port identifier, we would expect to always be "transfer" * @param {String} sourcePort the port identifier, we would expect to always be "transfer" | ||
* @param {String} source_channel the channel identifier | ||
* @param {Coin} token | ||
* @param {String} sender address of sender on the origin chain | ||
* @param {String} receiver address of recipient on the destination chain | ||
* @param {Integer} timeoutTimestamp nanoseconds to allow transfer to complete | ||
*/ | ||
function newMsgTransfer( | ||
sourcePort: string, | ||
sourceChannel: string, | ||
token: Coin, | ||
sender: string, | ||
receiver: string, | ||
timeoutTimestamp: number | ||
) { | ||
return { | ||
type: 'cosmos-sdk/MsgTransfer', | ||
value: { | ||
source_port: sourcePort, | ||
source_channel: sourceChannel, | ||
token: token, | ||
sender: sender, | ||
receiver: receiver, | ||
timeoutHeight: 0, | ||
timeoutTimestamp: timeoutTimestamp, | ||
}, | ||
}; | ||
} | ||
export const cosmos = { | ||
@@ -69,2 +100,3 @@ newStdTx, | ||
newMsgVoteGovernance, | ||
newMsgTransfer, | ||
}; |
@@ -1,1 +0,5 @@ | ||
export type VoteType = 'Yes' | 'No' | 'Abstain'; | ||
export enum VoteType { | ||
YES = 1, | ||
ABSTAIN = 2, | ||
NO = 3, | ||
} |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
360843
73
8856
10
1