@secux/app-sui
v1.0.2
Published
SecuX Hardware Wallet SUI API
Downloads
381
Readme
@secux/app-sui
SecuX Hardware Wallet SUI API
Usage
import { SecuxSUI } from "@secux/app-sui";
import { SuiCurve } from "@secux/app-sui/interface";First, create instance of ITransport
Examples
- Get address of bip44 path
const path = "m/44'/784'/0'/0'/0'";
const address = await device.getAddress(path);
/*
// transfer data to hardware wallet by custom transport layer.
const data = SecuxSUI.prepareAddress(path);
const response = await device.Exchange(data);
const address = SecuxSUI.resolveAddress(response);
*/- Sign transaction (Transfer SUI)
const path = "m/44'/784'/0'/0'/0'";
const publickey = await device.getPublickey(path);
const content = {
publickey,
gasPrice: 1000,
gasBudget: 10000000,
gasPayment: [
{
objectId: "0x40375a2f57a9117387a32decab661159392ed0f862ead65fd32e7f3d61180b43",
version: 123,
digest: "6f5GfW6G6VvG88vYg4V9m8V9V8VvG88vYg4V9m8V9V8="
}
],
to: "0x89ad0df73ca35d48721c0ad146e2e50ed685324578b8a531f8f35f1c44ba278d",
amount: 1000000000 // 1 SUI
};
// sign
const { bytes, signature } = await device.sign(path, content);
/*
// transfer data to hardware wallet by custom transport layer.
const { commandData, rawTx } = await SecuxSUI.prepareSign(path, content);
const response = await device.Exchange(commandData);
const { bytes, signature } = SecuxSUI.resolveTransaction(response, {
rawTx,
publickey,
curve: SuiCurve.ED25519
});
*/- Sign transaction (Transfer Token/NFT)
const content = {
publickey,
gasPrice: 1000,
gasBudget: 10000000,
gasPayment: [
{
objectId: "0x40375a2f57a9117387a32decab661159392ed0f862ead65fd32e7f3d61180b43",
version: 123,
digest: "6f5GfW6G6VvG88vYg4V9m8V9V8VvG88vYg4V9m8V9V8="
}
],
to: "0x89ad0df73ca35d48721c0ad146e2e50ed685324578b8a531f8f35f1c44ba278d",
// for tokens
amount: 1000000,
tokens: [
{
objectId: "0x...",
version: 1,
digest: "..."
}
],
// or for nfts
/*
nfts: [
{
objectId: "0x...",
version: 1,
digest: "..."
}
]
*/
};
const { bytes, signature } = await device.sign(path, content);API Reference
SUI package for SecuX device
Kind: global class
- SecuxSUI
- .addressConvert(publickey, curve) ⇒ string
- .prepareAddress(path) ⇒ communicationData
- .resolveAddress(response, curve) ⇒ string
- .preparePublickey(path) ⇒ communicationData
- .resolvePublickey(response) ⇒ string
- .prepareSign(path, content) ⇒ prepared
- .resolveSignature(response) ⇒ string
- .resolveTransaction(response, params) ⇒ string
SecuxSUI.addressConvert(publickey, curve) ⇒ string
Convert bip32-publickey to SUI address.
Returns: string - address
| Param | Type | Description | | --- | --- | --- | | publickey | string | Buffer | ada bip32-publickey | | curve | EllipticCurve | |
SecuxSUI.prepareAddress(path) ⇒ communicationData
Prepare data for address generation.
Returns: communicationData - data for sending to device
| Param | Type | Description | | --- | --- | --- | | path | string | m/1852'/1815'/... |
SecuxSUI.resolveAddress(response, curve) ⇒ string
Resolve address from response data.
Returns: string - address
| Param | Type | Description | | --- | --- | --- | | response | communicationData | data from device | | curve | SuiCurve | |
SecuxSUI.preparePublickey(path) ⇒ communicationData
Prepare data for ed25519 publickey.
Returns: communicationData - data for sending to device
| Param | Type | Description | | --- | --- | --- | | path | string | BIP32 path (hardened child key), ex: m/44'/784'/0'/0'/0' |
SecuxSUI.resolvePublickey(response) ⇒ string
Resove ed25519 publickey from response data.
Returns: string - ed25519 publickey (hex string)
| Param | Type | Description | | --- | --- | --- | | response | communicationData | data from device |
SecuxSUI.prepareSign(path, content) ⇒ prepared
Prepare data for signing.
Returns: prepared - prepared object
| Param | Type | Description | | --- | --- | --- | | path | string | m/44'/195'/... | | content | transferData | transaction object |
SecuxSUI.resolveSignature(response) ⇒ string
Reslove signatures from response data.
Returns: string - signature (base64 encoded)
| Param | Type | Description | | --- | --- | --- | | response | communicationData | data from device |
SecuxSUI.resolveTransaction(response, params) ⇒ string
Resolve transaction for broadcasting.
Returns: string - signed raw transaction
| Param | Type | Description | | --- | --- | --- | | response | communicationData | data from device | | params | TransactionObject | raw transaction |
transferData : object
Properties
| Name | Type | Description | | --- | --- | --- | | from | string | sending address | | to | string | receiving address | | amount | number | transfer amount | | blockID | string | | | blockNumber | number | | | timestamp | number | | | [feeLimit] | number | | | [expiration] | number | |
prepared : object
Properties
| Name | Type | Description | | --- | --- | --- | | commandData | communicationData | data for sending to device | | rawTx | communicationData | unsigned raw transaction |
© 2018-21 SecuX Technology Inc.
authors: [email protected] --
