Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
parity
txwrapper
Commits
d480fb9d
Unverified
Commit
d480fb9d
authored
Dec 02, 2019
by
Amaury Martiny
Committed by
GitHub
Dec 02, 2019
Browse files
feat: Add balances::transfer_keep_alive (#4)
* feat: Add balances::transfer_keep_alive * Fix logic
parent
9e2988f2
Changes
11
Show whitespace changes
Inline
Side-by-side
docs/README.md
View file @
d480fb9d
...
...
@@ -2,6 +2,18 @@
# @amaurymartiny/txwrapper
# txwrapper
# @amaurymartiny/txwrapper
```
bash
yarn add @amaurymartiny/txwrapper
```
In a JS file:
```
typescript
import
{
generateKeypair
}
from
'
@amaurymartiny/txwrapper
'
;
console
.
log
(
generateKeypair
().
address
);
```
Go to
[
documentation
](
https://github.com/amaurymartiny/txwrapper/tree/master/docs/globals.md
)
.
Go to
[
documentation
](
https://github.com/amaurymartiny/txwrapper/tree/master/docs/globals.md
)
for all the functions
.
docs/interfaces/_balancetransfer_.txinfo.md
View file @
d480fb9d
...
...
@@ -15,6 +15,7 @@
*
[
blockHash
](
_balancetransfer_.txinfo.md#blockhash
)
*
[
blockNumber
](
_balancetransfer_.txinfo.md#blocknumber
)
*
[
genesisHash
](
_balancetransfer_.txinfo.md#genesishash
)
*
[
keepAlive
](
_balancetransfer_.txinfo.md#optional-keepalive
)
*
[
metadataRpc
](
_balancetransfer_.txinfo.md#metadatarpc
)
*
[
nonce
](
_balancetransfer_.txinfo.md#nonce
)
*
[
specVersion
](
_balancetransfer_.txinfo.md#specversion
)
...
...
@@ -28,7 +29,7 @@
•
**address**
:
*string*
*Defined in [src/balanceTransfer.ts:22](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
6203cdc
/src/balanceTransfer.ts#L22)*
*Defined in [src/balanceTransfer.ts:22](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
9e2988f
/src/balanceTransfer.ts#L22)*
The ss-58 encoded address
...
...
@@ -38,7 +39,7 @@ ___
•
**amount**
:
*number*
*Defined in [src/balanceTransfer.ts:26](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
6203cdc
/src/balanceTransfer.ts#L26)*
*Defined in [src/balanceTransfer.ts:26](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
9e2988f
/src/balanceTransfer.ts#L26)*
The amount to send
...
...
@@ -48,7 +49,7 @@ ___
•
**blockHash**
:
*string*
*Defined in [src/balanceTransfer.ts:30](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
6203cdc
/src/balanceTransfer.ts#L30)*
*Defined in [src/balanceTransfer.ts:30](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
9e2988f
/src/balanceTransfer.ts#L30)*
The checkpoint hash of the block, in hex
...
...
@@ -58,7 +59,7 @@ ___
•
**blockNumber**
:
*number*
*Defined in [src/balanceTransfer.ts:34](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
6203cdc
/src/balanceTransfer.ts#L34)*
*Defined in [src/balanceTransfer.ts:34](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
9e2988f
/src/balanceTransfer.ts#L34)*
The checkpoint block number (u32), in hex
...
...
@@ -68,17 +69,27 @@ ___
•
**genesisHash**
:
*string*
*Defined in [src/balanceTransfer.ts:38](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
6203cdc
/src/balanceTransfer.ts#L38)*
*Defined in [src/balanceTransfer.ts:38](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
9e2988f
/src/balanceTransfer.ts#L38)*
The genesis hash of the chain, in hex
__
_
### `Optional` keepAlive
•
**keepAlive**
? :
*undefined | false | true*
*Defined in [src/balanceTransfer.ts:42](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/9e2988f/src/balanceTransfer.ts#L42)*
Use balances::transfer_keep_alive instead of balances::transfer
__
_
### metadataRpc
•
**metadataRpc**
:
*string*
*Defined in [src/balanceTransfer.ts:4
3
](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
6203cdc
/src/balanceTransfer.ts#L4
3
)*
*Defined in [src/balanceTransfer.ts:4
7
](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
9e2988f
/src/balanceTransfer.ts#L4
7
)*
The SCALE-encoded metadata, as a hex string. Can be retrieved via the RPC
call
`state_getMetadata`
...
...
@@ -89,7 +100,7 @@ ___
•
**nonce**
:
*number*
*Defined in [src/balanceTransfer.ts:
47
](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
6203cdc
/src/balanceTransfer.ts#L
47
)*
*Defined in [src/balanceTransfer.ts:
51
](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
9e2988f
/src/balanceTransfer.ts#L
51
)*
The nonce for this transaction,
...
...
@@ -99,7 +110,7 @@ ___
•
**specVersion**
:
*number*
*Defined in [src/balanceTransfer.ts:5
1
](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
6203cdc
/src/balanceTransfer.ts#L5
1
)*
*Defined in [src/balanceTransfer.ts:5
5
](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
9e2988f
/src/balanceTransfer.ts#L5
5
)*
The current spec version for the runtime
...
...
@@ -109,7 +120,7 @@ ___
•
**tip**
:
*number*
*Defined in [src/balanceTransfer.ts:5
5
](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
6203cdc
/src/balanceTransfer.ts#L5
5
)*
*Defined in [src/balanceTransfer.ts:5
9
](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
9e2988f
/src/balanceTransfer.ts#L5
9
)*
The tip for this transaction, in hex
...
...
@@ -119,7 +130,7 @@ ___
•
**to**
:
*string*
*Defined in [src/balanceTransfer.ts:
59
](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
6203cdc
/src/balanceTransfer.ts#L
59
)*
*Defined in [src/balanceTransfer.ts:
63
](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
9e2988f
/src/balanceTransfer.ts#L
63
)*
The recipient address, ss-58 encoded
...
...
@@ -129,7 +140,7 @@ ___
•
**validityPeriod**
:
*number*
*Defined in [src/balanceTransfer.ts:6
4
](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
6203cdc
/src/balanceTransfer.ts#L6
4
)*
*Defined in [src/balanceTransfer.ts:6
8
](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
9e2988f
/src/balanceTransfer.ts#L6
8
)*
The amount of time (in second) the transaction is valid for. Will be
translated into a mortal era
docs/interfaces/_balancetransfer_.unsignedtransaction.md
View file @
d480fb9d
...
...
@@ -92,7 +92,7 @@ ___
•
**metadataRpc**
:
*string*
*Defined in [src/balanceTransfer.ts:15](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
6203cdc
/src/balanceTransfer.ts#L15)*
*Defined in [src/balanceTransfer.ts:15](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
9e2988f
/src/balanceTransfer.ts#L15)*
The SCALE-encoded metadata, as a hex string. Can be retrieved via the RPC
call
`state_getMetadata`
...
...
docs/modules/_balancetransfer_.md
View file @
d480fb9d
...
...
@@ -24,7 +24,7 @@
•
**BLOCKTIME**
:
*6*
= 6
*Defined in [src/balanceTransfer.ts:
68
](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
6203cdc
/src/balanceTransfer.ts#L
68
)*
*Defined in [src/balanceTransfer.ts:
72
](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
9e2988f
/src/balanceTransfer.ts#L
72
)*
__
_
...
...
@@ -32,7 +32,7 @@ ___
•
**ONE_SECOND**
:
*number*
= 1 / BLOCKTIME
*Defined in [src/balanceTransfer.ts:
69
](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
6203cdc
/src/balanceTransfer.ts#L
69
)*
*Defined in [src/balanceTransfer.ts:
73
](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
9e2988f
/src/balanceTransfer.ts#L
73
)*
## Functions
...
...
@@ -40,7 +40,7 @@ ___
▸
**balanceTransfer**
(
`info`
:
[
TxInfo
](
../interfaces/_balancetransfer_.txinfo.md
)
):
*[UnsignedTransaction](../interfaces/_balancetransfer_.unsignedtransaction.md)*
*Defined in [src/balanceTransfer.ts:
7
8](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
6203cdc
/src/balanceTransfer.ts#L
7
8)*
*Defined in [src/balanceTransfer.ts:8
2
](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
9e2988f
/src/balanceTransfer.ts#L8
2
)*
Construct a balance transfer transaction offline. Transactions can be
constructed in such a way that it is valid for at least 240 minutes
...
...
docs/modules/_createsignedtx_.md
View file @
d480fb9d
...
...
@@ -14,7 +14,7 @@
▸
**createSignedTx**
(
`unsigned`
:
[
UnsignedTransaction
](
../interfaces/_balancetransfer_.unsignedtransaction.md
)
,
`signature`
: string):
*string*
*Defined in [src/createSignedTx.ts:14](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
6203cdc
/src/createSignedTx.ts#L14)*
*Defined in [src/createSignedTx.ts:14](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
9e2988f
/src/createSignedTx.ts#L14)*
Serialize a signed transaction in a format that can be submitted over the
Node RPC Interface from the signing payload and signature produced by the
...
...
docs/modules/_createsigningpayload_.md
View file @
d480fb9d
...
...
@@ -14,7 +14,7 @@
▸
**createSigningPayload**
(
`unsigned`
:
[
UnsignedTransaction
](
../interfaces/_balancetransfer_.unsignedtransaction.md
)
):
*string*
*Defined in [src/createSigningPayload.ts:11](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
6203cdc
/src/createSigningPayload.ts#L11)*
*Defined in [src/createSigningPayload.ts:11](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
9e2988f
/src/createSigningPayload.ts#L11)*
Construct the signing payload from an unsigned transaction and export it to
a remote signer (this is often called "detached signing")
...
...
docs/modules/_decodetx_.md
View file @
d480fb9d
...
...
@@ -14,7 +14,7 @@
▸
**decodeTx**
(
`signedTx`
: string,
`metadataRpc`
: string):
*Partial‹[TxInfo](../interfaces/_balancetransfer_.txinfo.md)›*
*Defined in [src/decodeTx.ts:17](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
6203cdc
/src/decodeTx.ts#L17)*
*Defined in [src/decodeTx.ts:17](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
9e2988f
/src/decodeTx.ts#L17)*
Parse the transaction information from an unsigned and signed transaction
offline
...
...
docs/modules/_deriveaddress_.md
View file @
d480fb9d
...
...
@@ -14,7 +14,7 @@
▸
**deriveAddress**
(
`publicKey`
: string | Uint8Array,
`ss58Format`
: number):
*string*
*Defined in [src/deriveAddress.ts:11](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
6203cdc
/src/deriveAddress.ts#L11)*
*Defined in [src/deriveAddress.ts:11](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
9e2988f
/src/deriveAddress.ts#L11)*
Derive an address from a cryptographic public key offline
...
...
docs/modules/_generatekeypair_.md
View file @
d480fb9d
...
...
@@ -18,7 +18,7 @@
▸
**generateKeypair**
():
*[KeyringPair](../interfaces/_generatekeypair_.keyringpair.md)*
*Defined in [src/generateKeypair.ts:15](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
6203cdc
/src/generateKeypair.ts#L15)*
*Defined in [src/generateKeypair.ts:15](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
9e2988f
/src/generateKeypair.ts#L15)*
Generate a valid public/private keypair offline
...
...
docs/modules/_util_constants_.md
View file @
d480fb9d
...
...
@@ -15,7 +15,7 @@
•
**EXTRINSIC_VERSION**
:
*4*
= 4
*Defined in [src/util/constants.ts:3](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
6203cdc
/src/util/constants.ts#L3)*
*Defined in [src/util/constants.ts:3](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
9e2988f
/src/util/constants.ts#L3)*
__
_
...
...
@@ -23,4 +23,4 @@ ___
•
**KUSAMA_SS58_FORMAT**
:
*2*
= 2
*Defined in [src/util/constants.ts:1](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
6203cdc
/src/util/constants.ts#L1)*
*Defined in [src/util/constants.ts:1](https://github.com/amaurymartiny/polkadotjs-wrapper/blob/
9e2988f
/src/util/constants.ts#L1)*
src/balanceTransfer.ts
View file @
d480fb9d
...
...
@@ -36,6 +36,10 @@ export interface TxInfo {
* The genesis hash of the chain, in hex
*/
genesisHash
:
string
;
/**
* Use balances::transfer_keep_alive instead of balances::transfer
*/
keepAlive
?:
boolean
;
/**
* The SCALE-encoded metadata, as a hex string. Can be retrieved via the RPC
* call `state_getMetadata`
...
...
@@ -79,7 +83,10 @@ export function balanceTransfer(info: TxInfo): UnsignedTransaction {
const
registry
=
new
TypeRegistry
();
const
metadata
=
new
Metadata
(
registry
,
info
.
metadataRpc
);
const
method
=
metadata
.
tx
.
balances
.
transfer
(
info
.
to
,
info
.
amount
).
toHex
();
const
transfer
=
info
.
keepAlive
?
metadata
.
tx
.
balances
.
transferKeepAlivetransfer
:
metadata
.
tx
.
balances
.
transfer
;
const
method
=
transfer
(
info
.
to
,
info
.
amount
).
toHex
();
return
{
address
:
info
.
address
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment