Package Exports
- @secux/app-luna
- @secux/app-luna/lib/app-luna.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@secux/app-luna) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
;
/*
// transfer data to hardware wallet by custom transport layer
const data = SecuxLUNA.prepareAddress(path);
const response = await device.Exchange(data);
const address = SecuxLUNA.resolveAddress(response);
*/
Sign transaction
- transfer asset (MsgSend)
const signer = { path: "m/44'/330'/0'/0/0", accountNumber: 12345, sequence: 1, }; const params = { fee: { uluna: 3000 }, gasLimit: 12345, }; const send = new SecuxLUNA.MsgSend(from, to, { uluna: 1e6 }); const { multi_command, serialized } = await device.sign( [signer], [send], params ); const responseList = []; for (const data of multi_command) { const rsp = await device.Exchange(data); responseList.push(rsp); } const raw_tx = SecuxLUNA.resolveTransaction(responseList, serialized); /* // transfer data to hardware wallet by custom transport layer. const { commands, serialized } = SecuxLUNA.prepareSign( [ { ...signer, publickey: "02acb4bc267db7774614bf6011c59929b006c2554386a3090baff0b3fc418ec044" } ], [send], params }); const responseList = []; for (const data of commands) { const rsp = await device.Exchange(data); responseList.push(rsp); } const raw_tx = SecuxLUNA.resolveTransaction(responseList, serialized); */
- execute contract
const swap = new SecuxLUNA.MsgExecuteContract( "terra1amdttz2937a3dytmxmkany53pp6ma6dy4vsllv", "terra156v8s539wtz0sjpn8y8a8lfg8fhmwa7fy22aff", { swap: { offer_asset: { amount: 1e6, info: { native_token: { denom: "uluna" }, }, }, }, }, { uluna: 1e6 } ); const { multi_command, serialized } = await device.sign( [signer], [swap], params ); // ... (same as above)
- delegate
const delegate = new SecuxLUNA.MsgDelegate( "terra1amdttz2937a3dytmxmkany53pp6ma6dy4vsllv", "terravaloper1vf2209f5y7s4a66n5ng7wmup5gcc2kghhzy89w", "1000000" ); const { multi_command, serialized } = await device.sign( [signer], [delegate], params ); // ... (same as above)
- withdraw
const withdraw = new SecuxLUNA.MsgWithdrawDelegatorReward( "terra1amdttz2937a3dytmxmkany53pp6ma6dy4vsllv", "terravaloper1vf2209f5y7s4a66n5ng7wmup5gcc2kghhzy89w" ); const { multi_command, serialized } = await device.sign( [signer], [withdraw], params ); // ... (same as above)
- undelegate
const undelegate = new SecuxLUNA.MsgUndelegate( "terra1amdttz2937a3dytmxmkany53pp6ma6dy4vsllv", "terravaloper1vf2209f5y7s4a66n5ng7wmup5gcc2kghhzy89w", "1000000" ); const { multi_command, serialized } = await device.sign( [signer], [undelegate], params ); // ... (same as above)
- redelegate
const redelegate = new SecuxLUNA.MsgBeginRedelegate( "terra1amdttz2937a3dytmxmkany53pp6ma6dy4vsllv", "terravaloper1vf2209f5y7s4a66n5ng7wmup5gcc2kghhzy89w", "terravaloper1vk20anceu6h9s00d27pjlvslz3avetkvnwmr35", "1000000" ); const { multi_command, serialized } = await device.sign( [signer], [redelegate], params ); // ... (same as above)
API Reference
LUNA package for SecuX device
Kind: global class
- SecuxLUNA
- .addressConvert(publickey, type) ⇒
string
- .prepareAddress(path) ⇒
communicationData
- .resolveAddress(response, type) ⇒
string
- .preparePublickey(path) ⇒
communicationData
- .resolvePublickey(response) ⇒
string
- .prepareXPublickey(path) ⇒
communicationData
- .resolveXPublickey(response, path) ⇒
string
- .prepareSign(signers, messages, params) ⇒
prepared
- .resolveSignatureList(response) ⇒
Array.<string>
- .resolveTransaction(response, serialized) ⇒
string
- .simulate(signers, messages, [params]) ⇒
string
- .addressConvert(publickey, type) ⇒
SecuxLUNA.addressConvert(publickey, type) ⇒ string
Convert secp256k1 publickey to LUNA address.
Returns: string
- LUNA address
Param | Type | Description |
---|---|---|
publickey | string | Buffer |
secp256k1 publickey |
type | AddressType |
account/validator/pubkey address |
SecuxLUNA.prepareAddress(path) ⇒ communicationData
Prepare data for address generation.
Returns: communicationData
- data for sending to device
Param | Type | Description |
---|---|---|
path | string |
BIP32 path, ex: m/44'/330'/0'/0/0 |
SecuxLUNA.resolveAddress(response, type) ⇒ string
Generate address from response data.
Returns: string
- LUNA address
Param | Type | Description |
---|---|---|
response | communicationData |
data from device |
type | AddressType |
account/validator/pubkey address |
SecuxLUNA.preparePublickey(path) ⇒ communicationData
Prepare data for secp256k1 publickey.
Returns: communicationData
- data for sending to device
Param | Type | Description |
---|---|---|
path | string |
BIP32 path, ex: m/44'/330'/0'/0/0 |
SecuxLUNA.resolvePublickey(response) ⇒ string
Resolve secp256k1 publickey from response data.
Returns: string
- secp256k1 publickey (base64-encoded string)
Param | Type | Description |
---|---|---|
response | communicationData |
data from device |
SecuxLUNA.prepareXPublickey(path) ⇒ communicationData
Prepare data for xpub.
Returns: communicationData
- data for sending to device
Param | Type | Description |
---|---|---|
path | string |
BIP32 path, ex: m/44'/330'/0'/0/0 |
SecuxLUNA.resolveXPublickey(response, path) ⇒ string
Resolve xpub from response data.
Returns: string
- xpub
Param | Type | Description |
---|---|---|
response | communicationData |
data from device |
path | string |
BIP32 path, ex: m/44'/330'/0'/0/0 |
SecuxLUNA.prepareSign(signers, messages, params) ⇒ prepared
Prepare data for signing.
Param | Type | Description |
---|---|---|
signers | Signer |
array of signer |
messages | Array.<IMessage> |
each message represents a instruction |
params | TxOption |
SecuxLUNA.resolveSignatureList(response) ⇒ Array.<string>
Reslove signature from response data.
Returns: Array.<string>
- signature array of base64-encoded string
Param | Type | Description |
---|---|---|
response | communicationData |
data from device |
SecuxLUNA.resolveTransaction(response, serialized) ⇒ string
Serialize transaction wtih signature for broadcasting.
Returns: string
- signed raw transaction
Param | Type | Description |
---|---|---|
response | communicationData | Array.<communicationData> |
data from device |
serialized | communicationData |
SecuxLUNA.simulate(signers, messages, [params]) ⇒ string
Simulate a transaction for estimating gas.
Returns: string
- simulated transaction
Param | Type | Description |
---|---|---|
signers | Array.<Signer> |
array of signer |
messages | Array.<IMessage> |
each message represents a instruction |
[params] | TxOption |
AddressType : enum
Properties
Name | Type | Description |
---|---|---|
account | string |
account |
validator | string |
validator |
pubkey | string |
pubkey |
Signer : object
Properties
Name | Type | Description |
---|---|---|
path | string |
BIP32 path, ex: m/44'/330'/0'/0/0 |
publickey | string | Buffer |
secp256k1 publickey from path |
sequence | number |
the number of transactions sent from this address |
accountNumber | number |
the account number from blockchain |
IMessage : interface
Properties
Name | Type |
---|---|
toAmino | function |
toData | function |
toProto | function |
packAny | function |
TxOption : object
Properties
Name | Type | Description |
---|---|---|
fee | string | Coins |
the amount of coins to be paid as a fee |
gasLimit | number |
the maximum gas that can be used in transaction processing |
[chainId] | string |
blockchain network identifier |
[memo] | string |
|
[timeoutHeight] | string |
timeout height relative to the current block height |
[payer] | string |
payer’s account address |
[granter] | string |
granter’s account address |
prepared : object
Properties
Name | Type | Description |
---|---|---|
commands | Array.<communicationData> |
data for sending to device |
serialized | communicationData |
unsigned raw transaction |
© 2018-22 SecuX Technology Inc.
authors:
andersonwu@secuxtech.com