Note
This documentation is work in progress and web3-fusion-extend in currently in beta. Please feel free to submit pull request or issues via the edit on github link in the upper right.
fsntx¶
FSNTX commands
personal.unlockAccount( eth.coinbase, "123456" )
var tx = fsntx.buildBuyTicketTx( {from:eth.coinbase} )
tx.from = eth.coinbase
var tx2 = eth.signTransaction( tx )
fsntx.sendRawTransaction(tx2.tx)
sendRawTransaction¶
fsntx.sendRawTransaction()
...
sendRawTransaction
Parameters¶
tx
-*types.Transaction
: Description
Example¶
fsntx.sendRawTransaction()
$scope.recallSwap = async function (swap_id) {
if (walletService.wallet !== null) {
let password = walletService.password;
let accountData = uiFuncs.getTxData($scope);
let walletAddress = accountData.from;
let data = {
from: walletAddress,
SwapID: swap_id
};
if (!$scope.account && ($scope.wallet.hwType !== "ledger")) {
$scope.account = web3.eth.accounts.privateKeyToAccount($scope.toHexString($scope.wallet.getPrivateKey()));
}
try {
await web3.fsntx.buildRecallSwapTx(data).then(function (tx) {
tx.from = walletAddress;
tx.chainId = _CHAINID;
data = tx;
if ($scope.wallet.hwType == "ledger") {
return;
}
return web3.fsn.signAndTransmit(tx, $scope.account.signTransaction).then(txHash => {
console.log(txHash);
$scope.recallSwapSuccess.open()
})
})
} catch (err) {
$scope.errorModal.open();
console.log(err);
}
if ($scope.wallet.hwType == "ledger") {
let ledgerConfig = {
privKey: $scope.wallet.privKey ? $scope.wallet.getPrivateKeyString() : "",
path: $scope.wallet.getPath(),
hwType: $scope.wallet.getHWType(),
hwTransport: $scope.wallet.getHWTransport()
}
let rawTx = data;
var eTx = new ethUtil.Tx(rawTx);
if (ledgerConfig.hwType == "ledger") {
var app = new ledgerEth(ledgerConfig.hwTransport);
var EIP155Supported = true;
var localCallback = async function (result, error) {
if (typeof error != "undefined") {
if (callback !== undefined) callback({
isError: true,
error: error
});
return;
}
var splitVersion = result['version'].split('.');
if (parseInt(splitVersion[0]) > 1) {
EIP155Supported = true;
} else if (parseInt(splitVersion[1]) > 0) {
EIP155Supported = true;
} else if (parseInt(splitVersion[2]) > 2) {
EIP155Supported = true;
}
var oldTx = Object.assign(rawTx, {});
let input = oldTx.input;
return uiFuncs.signed(app, rawTx, ledgerConfig, true, function (res) {
oldTx.r = res.r;
oldTx.s = res.s;
oldTx.v = res.v;
oldTx.input = input;
oldTx.chainId = "0x1";
delete oldTx.isError;
delete oldTx.rawTx;
delete oldTx.signedTx;
web3.fsntx.sendRawTransaction(oldTx).then(function (txHash) {
$scope.recallSwapSuccess.open()
})
})
}
$scope.notifier.info('Please, confirm transaction on Ledger.');
await app.getAppConfiguration(localCallback);
}
}
}
}
buildGenNotationTx¶
fsntx.buildGenNotationTx()
...
buildGenNotationTx
Parameters¶
Object
: Description
from
-String|Number
: The address for the sending accountgas
-Number
: (optional, default: To-Be-Determined) The amount of gas to use for the transaction (unused gas is refunded).gasPrice
-Number|String|BN|BigNumber
: (optional) The price of gas for this transaction in wei.nonce
-Number
: (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.
Example¶
await web3.fsntx.buildGenNotationTx({
from: walletAddress
}).then((tx) => {
tx.chainId = _CHAINID;
data = tx;
tx.from = walletAddress;
if ($scope.wallet.hwType == "ledger"){
return;
}
return web3.fsn.signAndTransmit(tx, $scope.account.signTransaction).then(txHash => {
$scope.requestedSAN = true;
$scope.$apply(function () {
$scope.addressNotation.value = 'USAN Requested';
$scope.addressNotation.value = 'USAN Requested';
});
})
});
genNotation¶
fsntx.genNotation({from:fsn.coinbase},"123456")
...
genNotation gen a notation for a account CP see the top and the “from” ignore from who gen the notation password the account password
Parameters¶
Object
: The transaction object
from
-String|Number
: The address for the sending accountgas
-Number
: (optional, default: To-Be-Determined) The amount of gas to use for the transaction (unused gas is refunded).gasPrice
-Number|String|BN|BigNumber
: (optional) The price of gas for this transaction in wei.nonce
-Number
: (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.
passwd
-string
: Description
Example¶
fsntx.genNotation({from:fsn.coinbase},"123456")
buildGenAssetTx¶
fsntx.buildGenAssetTx()
...
buildGenAssetTx
Parameters¶
Object
: The transaction object
from
-String|Number
: The address for the sending accountgas
-Number
: (optional, default: To-Be-Determined) The amount of gas to use for the transaction (unused gas is refunded).gasPrice
-Number|String|BN|BigNumber
: (optional) The price of gas for this transaction in wei.nonce
-Number
: (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.name
-string
: Descriptionsymbol
-string
: Descriptiondecimals
-Number
: Descriptiontotal
-Number|String|BN|BigNumber
: DescriptioncanChange
-Boolean
: Description
Example¶
try {
await web3.fsntx.buildGenAssetTx(data).then(tx => {
tx.chainId = _CHAINID;
data = tx;
if ($scope.wallet.hwType == "ledger" || $scope.wallet.hwType == "trezor") {
return;
} else {
return web3.fsn.signAndTransmit(tx, $scope.account.signTransaction).then(txHash => {
$scope.$eval(function () {
$scope.assetCreate.errorMessage = '';
$scope.assetCreate.assetHash = txHash;
});
$scope.createAssetFinal.open();
});
}
});
} catch (err) {
$scope.errorModal.open();
}
genAsset¶
fsntx.genAsset({from:fsn.coinbase,name:"FusionTest",symbol:"FST",decimals:1,total:"0x200"},"123456")
fsntx.genAsset({from:"0x91db50f5c36ae7616009d4e94462dca4d4c7e833",name:"JONESY",symbol:"JSY",decimals:1,total:"0x2000000000"},"123123123")
...
genAsset generate a asset CP see the top and the “from” ignore from who gen the asset and the owner of the asset name the name of asset symbol the symbol of asset decimals the asset decimal digit total the total number of the asset and the owner will be get same number asset CanChange whether asset can be incremented or decremented by the owner [optional] password the account password
Parameters¶
Object
: Description
from
-String|Number
: The address for the sending accountgas
-Number
: (optional, default: To-Be-Determined) The amount of gas to use for the transaction (unused gas is refunded).gasPrice
-Number|String|BN|BigNumber
: (optional) The price of gas for this transaction in wei.nonce
-Number
: (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.name
-string
: Descriptionsymbol
-string
: Descriptiondecimals
-Number
: Descriptiontotal
-Number|String|BN|BigNumber
: DescriptioncanChange
-bool
: Description
passwd
-string
: Description
Example¶
fsntx.genAsset({from:fsn.coinbase,name:"FusionTest",symbol:"FST",decimals:1,total:"0x200"},"123456")
fsntx.genAsset({from:"0x91db50f5c36ae7616009d4e94462dca4d4c7e833",name:"JONESY",symbol:"JSY",decimals:1,total:"0x2000000000"},"123123123")
buildSendAssetTx¶
fsntx.buildSendAssetTx()
...
buildSendAssetTx
Parameters¶
Object
: Description
from
-String|Number
: The address for the sending accountgas
-Number
: (optional, default: To-Be-Determined) The amount of gas to use for the transaction (unused gas is refunded).gasPrice
-Number|String|BN|BigNumber
: (optional) The price of gas for this transaction in wei.nonce
-Number
: (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.asset
-String|Number
: Descriptionto
-String|Number
: Descriptionvalue
-Number|String|BN|BigNumber
: Description
Example¶
fsntx.buildSendAssetTx()
$scope.sendAsset = async function () {
$scope.successMessagebool = true;
let accountData = uiFuncs.getTxData($scope);
let from = accountData.from;
let to = $scope.sendAsset.toAddress;
let decimals = '';
let asset = $scope.assetToSend;
let hash = '';
let data = {};
if (to.length < 42) {
await web3.fsn.getAddressByNotation(parseInt(to)).then(function (address) {
to = address;
});
}
await web3.fsn.getAsset(asset).then(function (res) {
decimals = parseInt(res["Decimals"]);
});
let amount = $scope.sendAsset.amountToSend.toString();
amount = $scope.makeBigNumber(amount, decimals);
if ($scope.transactionType == "none") {
if (!$scope.account && ($scope.wallet.hwType !== "ledger") && ($scope.wallet.hwType !== "trezor")) {
$scope.account = web3.eth.accounts.privateKeyToAccount($scope.toHexString($scope.wallet.getPrivateKey()));
}
try {
await web3.fsntx.buildSendAssetTx({
from: from,
to: to,
value: amount.toString(),
asset: asset
}).then((tx) => {
console.log(tx);
tx.from = from;
tx.chainId = _CHAINID;
data = tx;
if ($scope.wallet.hwType == "ledger" || $scope.wallet.hwType == "trezor") {
return;
}
return web3.fsn.signAndTransmit(tx, $scope.account.signTransaction).then(txHash => {
hash = txHash;
$scope.sendAssetFinal.open();
$scope.$eval(function () {
$scope.successHash = hash;
$scope.successHash = hash;
});
})
});
} catch (err) {
console.log(err);
$scope.errorModal.open();
}
sendAsset¶
fsntx.sendAsset({from:fsn.coinbase,to:"0x2b1a3eca81ba03a9a4c95f4a04679c90838d7165",value:"0x1",asset:"0x514a46f34e6eb0a98abb3595c4aec33ca8ddf69f135c8fed89e78d0808047965"},"123456")
fsntx.sendAsset({from:fsn.coinbase,to:"0x91db50F5c36aE7616009d4e94462DcA4D4c7e833",value:"0x2",asset:"0x88d18f81620e5684e880dddcf0b6c167a9154d4c499bc9fad47b98634110eeec"},"123456")
...
sendAsset send asset to other account CSP see the top
Parameters¶
Object
: Description
from
-String|Number
: The address for the sending accountgas
-Number
: (optional, default: To-Be-Determined) The amount of gas to use for the transaction (unused gas is refunded).gasPrice
-Number|String|BN|BigNumber
: (optional) The price of gas for this transaction in wei.nonce
-Number
: (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.asset
-String|Number
: Descriptionto
-String|Number
: Descriptionvalue
-Number|String|BN|BigNumber
: Description
passwd
-string
: Description
Example¶
fsntx.sendAsset({from:fsn.coinbase,to:"0x2b1a3eca81ba03a9a4c95f4a04679c90838d7165",value:"0x1",asset:"0x514a46f34e6eb0a98abb3595c4aec33ca8ddf69f135c8fed89e78d0808047965"},"123456")
fsntx.sendAsset({from:fsn.coinbase,to:"0x91db50F5c36aE7616009d4e94462DcA4D4c7e833",value:"0x2",asset:"0x88d18f81620e5684e880dddcf0b6c167a9154d4c499bc9fad47b98634110eeec"},"123456")
buildAssetToTimeLockTx¶
fsntx.buildAssetToTimeLockTx()
...
buildAssetToTimeLockTx
Parameters¶
Object
: Description
from
-String|Number
: The address for the sending accountgas
-Number
: (optional, default: To-Be-Determined) The amount of gas to use for the transaction (unused gas is refunded).gasPrice
-Number|String|BN|BigNumber
: (optional) The price of gas for this transaction in wei.nonce
-Number
: (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.asset
-String|Number
: Descriptionto
-String|Number
: Descriptionvalue
-Number|String|BN|BigNumber
: Descriptionstart
-Number
: Descriptionend
-Number
: Description
Example¶
fsntx.buildAssetToTimeLockTx()
$scope.sendAsset = async function () {
$scope.successMessagebool = true;
let accountData = uiFuncs.getTxData($scope);
let from = accountData.from;
let to = $scope.sendAsset.toAddress;
let decimals = '';
let asset = $scope.assetToSend;
let hash = '';
let data = {};
if (to.length < 42) {
await web3.fsn.getAddressByNotation(parseInt(to)).then(function (address) {
to = address;
});
}
await web3.fsn.getAsset(asset).then(function (res) {
decimals = parseInt(res["Decimals"]);
});
let amount = $scope.sendAsset.amountToSend.toString();
amount = $scope.makeBigNumber(amount, decimals);
if ($scope.transactionType == "none") {
if (!$scope.account && ($scope.wallet.hwType !== "ledger") && ($scope.wallet.hwType !== "trezor")) {
$scope.account = web3.eth.accounts.privateKeyToAccount($scope.toHexString($scope.wallet.getPrivateKey()));
}
try {
await web3.fsntx.buildSendAssetTx({
from: from,
to: to,
value: amount.toString(),
asset: asset
}).then((tx) => {
console.log(tx);
tx.from = from;
tx.chainId = _CHAINID;
data = tx;
if ($scope.wallet.hwType == "ledger" || $scope.wallet.hwType == "trezor") {
return;
}
return web3.fsn.signAndTransmit(tx, $scope.account.signTransaction).then(txHash => {
hash = txHash;
$scope.sendAssetFinal.open();
$scope.$eval(function () {
$scope.successHash = hash;
$scope.successHash = hash;
});
})
});
} catch (err) {
console.log(err);
$scope.errorModal.open();
}
$scope.$apply(function () {
$scope.successHash = hash;
});
}
if ($scope.transactionType == "daterange") {
if ($scope.sendAsset.fromTime == '') {
$scope.sendAsset.fromTime = new Date();
}
let fromTime = getHexDate(convertDate($scope.sendAsset.fromTime));
let tillTime = getHexDate(convertDate($scope.sendAsset.tillTime));
if (!$scope.account && ($scope.wallet.hwType !== "ledger") && ($scope.wallet.hwType !== "trezor")) {
$scope.account = web3.eth.accounts.privateKeyToAccount($scope.toHexString($scope.wallet.getPrivateKey()));
}
try {
await web3.fsntx.buildAssetToTimeLockTx({
asset: asset,
from: from,
to: to,
start: fromTime,
end: tillTime,
value: amount
}).then((tx) => {
tx.from = from;
tx.chainId = _CHAINID;
data = tx;
if ($scope.wallet.hwType == "ledger" || $scope.wallet.hwType == "trezor") {
return;
}
return web3.fsn.signAndTransmit(tx, $scope.account.signTransaction).then(txHash => {
$scope.sendAssetFinal.open();
$scope.$eval(function () {
$scope.successHash = txHash;
$scope.successHash = txHash;
});
})
});
} catch (err) {
$scope.errorModal.open();
}
}
assetToTimeLock¶
fsntx.assetToTimeLock({asset:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",from:fsn.coinbase,to:"0xa7455DF112c953F3c73c2C25559965e1A8a20024",start:"0x1",end:"0x2A300",value:"0x1400000000000000"},"123456")
fsntx.assetToTimeLock({asset:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",from:fsn.coinbase,to:"0xa7455DF112c953F3c73c2C25559965e1A8a20024",start:"0x2a900",end:"0x3A300",value:"0x1400000000000000"},"123456")
fsntx.assetToTimeLock({asset:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",from:fsn.coinbase,to:"0xa7455DF112c953F3c73c2C25559965e1A8a20024",start: getHexDate('2018-12-01') ,end: getHexDate('2019-01-01'),value:"0x1340000000000000"},"123456")
...
assetToTimeLock send the asset to time lock CSP see the top startTime the start time of the time lock endTime the end time of the time lock password the account password
Parameters¶
Object
: Description
from
-String|Number
: The address for the sending accountgas
-Number
: (optional, default: To-Be-Determined) The amount of gas to use for the transaction (unused gas is refunded).gasPrice
-Number|String|BN|BigNumber
: (optional) The price of gas for this transaction in wei.nonce
-Number
: (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.asset
-String|Number
: Descriptionto
-String|Number
: Descriptionvalue
-Number|String|BN|BigNumber
: Descriptionstart
-Number
: Descriptionend
-Number
: Description
passwd
-string
: Description
Example¶
fsntx.assetToTimeLock({asset:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",from:fsn.coinbase,to:"0xa7455DF112c953F3c73c2C25559965e1A8a20024",start:"0x1",end:"0x2A300",value:"0x1400000000000000"},"123456")
fsntx.assetToTimeLock({asset:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",from:fsn.coinbase,to:"0xa7455DF112c953F3c73c2C25559965e1A8a20024",start:"0x2a900",end:"0x3A300",value:"0x1400000000000000"},"123456")
fsntx.assetToTimeLock({asset:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",from:fsn.coinbase,to:"0xa7455DF112c953F3c73c2C25559965e1A8a20024",start: getHexDate('2018-12-01') ,end: getHexDate('2019-01-01'),value:"0x1340000000000000"},"123456")
buildTimeLockToTimeLockTx¶
fsntx.buildTimeLockToTimeLockTx()
...
buildTimeLockToTimeLockTx
Parameters¶
Object
: Description
from
-String|Number
: The address for the sending accountgas
-Number
: (optional, default: To-Be-Determined) The amount of gas to use for the transaction (unused gas is refunded).gasPrice
-Number|String|BN|BigNumber
: (optional) The price of gas for this transaction in wei.nonce
-Number
: (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.asset
-String|Number
: Descriptionto
-String|Number
: Descriptionvalue
-Number|String|BN|BigNumber
: Descriptionstart
-Number
: Descriptionend
-Number
: Description
Example¶
fsntx.buildTimeLockToTimeLockTx()
if (!$scope.account && ($scope.wallet.hwType !== "ledger") && ($scope.wallet.hwType !== "trezor")) {
$scope.account = web3.eth.accounts.privateKeyToAccount($scope.toHexString($scope.wallet.getPrivateKey()));
}
try {
await web3.fsntx.buildTimeLockToTimeLockTx({
asset: asset,
from: from,
to: to,
start: fromTime,
end: tillTime,
value: amount
}).then((tx) => {
tx.from = from;
tx.chainId = _CHAINID;
data = tx;
if ($scope.wallet.hwType == "ledger" || $scope.wallet.hwType == "trezor") {
return;
}
return web3.fsn.signAndTransmit(tx, $scope.account.signTransaction).then(txHash => {
$scope.$eval(function () {
$scope.sendAssetFinal.open();
$scope.successHash = txHash;
$scope.successHash = txHash;
});
})
});
} catch (err) {
$scope.errorModal.open();
}
timeLockToTimeLock¶
fsntx.timeLockToTimeLock({asset:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",from:fsn.coinbase,to:"0x2b1a3eca81ba03a9a4c95f4a04679c90838d7165",start:"0x101",end:"0x200",value:"0x100"},"123456")
...
timeLockToTimeLock send the time lock CSP see the top startTime the start time of the time lock endTime the end time of the time lock password the account password
Parameters¶
Object
: Description
from
-String|Number
: The address for the sending accountgas
-Number
: (optional, default: To-Be-Determined) The amount of gas to use for the transaction (unused gas is refunded).gasPrice
-Number|String|BN|BigNumber
: (optional) The price of gas for this transaction in wei.nonce
-Number
: (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.asset
-String|Number
: Descriptionto
-String|Number
: Descriptionvalue
-Number|String|BN|BigNumber
: Descriptionstart
-Number
: Descriptionend
-Number
: Description
passwd
-string
: Description
Example¶
fsntx.timeLockToTimeLock({asset:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",from:fsn.coinbase,to:"0x2b1a3eca81ba03a9a4c95f4a04679c90838d7165",start:"0x101",end:"0x200",value:"0x100"},"123456")
buildTimeLockToAssetTx¶
fsntx.buildTimeLockToAssetTx()
...
buildTimeLockToAssetTx
Parameters¶
Object
: Description
from
-String|Number
: The address for the sending accountgas
-Number
: (optional, default: To-Be-Determined) The amount of gas to use for the transaction (unused gas is refunded).gasPrice
-Number|String|BN|BigNumber
: (optional) The price of gas for this transaction in wei.nonce
-Number
: (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.asset
-String|Number
: Descriptionto
- ``String|Number`: Descriptionvalue
-Number|String|BN|BigNumber
: Descriptionstart
-Number
: Descriptionend
-Number
: Description
Example¶
fsntx.buildTimeLockToAssetTx()
$scope.sendBackToAssetsFunction = async function (id) {
let accountData = uiFuncs.getTxData($scope);
id = $scope.timeLockToAssetId;
let tlData = $scope.timeLockList[id];
let from = accountData.from;
if (!$scope.account && ($scope.wallet.hwType !== "ledger") && ($scope.wallet.hwType !== "trezor")) {
$scope.account = web3.eth.accounts.privateKeyToAccount($scope.toHexString($scope.wallet.getPrivateKey()));
}
let startTime = web3.utils.numberToHex(tlData.posixStartTime);
let endTime = web3.utils.numberToHex(tlData.posixEndTime);
// JavaScript / Go incompatibility -1 error
if (tlData.posixEndTime === 18446744073709552000) {
endTime = web3.fsn.consts.TimeForeverStr;
}
let data = {};
try {
await web3.fsntx.buildTimeLockToAssetTx({
asset: tlData.asset,
from: from,
to: from,
start: startTime,
end: endTime,
value: tlData.rawValue
}).then((tx) => {
tx.from = from;
tx.chainId = _CHAINID;
data = tx;
if ($scope.wallet.hwType == "ledger" || $scope.wallet.hwType == "trezor") {
return;
}
return web3.fsn.signAndTransmit(tx, $scope.account.signTransaction).then(txHash => {
$scope.successModal.open();
})
});
} catch (err) {
$scope.errorModal.open();
}
timeLockToAsset¶
fsntx.timeLockToAsset({asset:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",from:fsn.coinbase,to:fsn.coinbase,start:"0x0",end:"0x0",value:"0x100"},"123456")
...
timeLockToAsset send the time lock to asset CSP see the top startTime the start time of the time lock endTime the end time of the time lock password the account password
Parameters¶
Object
: Description
from
-String|Number
: The address for the sending accountgas
-Number
: (optional, default: To-Be-Determined) The amount of gas to use for the transaction (unused gas is refunded).gasPrice
-Number|String|BN|BigNumber
: (optional) The price of gas for this transaction in wei.nonce
-Number
: (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.asset
-String|Number
: Descriptionto
-String|Number
: Descriptionvalue
-Number|String|BN|BigNumber
: Descriptionstart
-Number
: Descriptionend
-Number
: Description
passwd
-string
: Description
Example¶
fsntx.timeLockToAsset({asset:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",from:fsn.coinbase,to:fsn.coinbase,start:"0x0",end:"0x0",value:"0x100"},"123456")
buildBuyTicketTx¶
fsntx.buildBuyTicketTx()
...
buildBuyTicketTx
Parameters¶
Object
: Description
from
-String|Number
: The address for the sending accountgas
-Number
: (optional, default: To-Be-Determined) The amount of gas to use for the transaction (unused gas is refunded).gasPrice
-Number|String|BN|BigNumber
: (optional) The price of gas for this transaction in wei.nonce
-Number
: (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.start
-Number
: Descriptionend
-Number
: Description
Example¶
this._web3.fsntx
.buildBuyTicketTx({ from: this._walletAddress, end: dayHex })
.then(tx => {
console.log(tx);
// tx.gasLimit = this._web3.utils.toWei( 21000, "gwei" )
if (!this._web3 || !this.provider || !this.provider.__connected) {
// reconnecting need to wait
cb(new Error("reconnecting"), "reconnecting");
return;
}
return this._web3.fsn.signAndTransmit(
tx,
currentDataState.data.signInfo.signTransaction
);
})
.then(txHash => {
console.log("buy ticket tx -> ", txHash);
if (!data.activeTicketPurchase) {
cb(null, "asked to leave");
return true;
}
data.lastStatus = "Pending Tx:" + utils.midHashDisplay(txHash);
data.lastCall = "purchaseSubmitTicket";
this.emit("purchaseSubmitTicket", data);
this.checkConnection();
return this.waitForTransactionToComplete(
txHash,
data,
new Date().getTime() + 120000
)
.then(r => {
if (r.status) {
cb(null, "Ticket bought");
} else {
cb(new Error("failed to buy"), "Failed to buy ticket will retry");
}
})
.catch(err => {
cb(err, "Error waiting for ticket to complete");
});
})
.catch(err => {
console.log(err)
cb(err, "unknown err");
});
buyTicket¶
fsntx.buyTicket({from:fsn.coinbase},"123456")
...
buyTicket buy the ticket CP see the top and the “from” ignore from who buy the ticket password the account password
Parameters¶
Object
: Description
from
-String|Number
: The address for the sending accountgas
-Number
: (optional, default: To-Be-Determined) The amount of gas to use for the transaction (unused gas is refunded).gasPrice
-Number|String|BN|BigNumber
: (optional) The price of gas for this transaction in wei.nonce
-Number
: (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.start
-Number
: Descriptionend
-Number
: Description
passwd
-string
: Description
Example¶
fsntx.buyTicket({from:fsn.coinbase},"123456")
buildIncAssetTx¶
fsntx.buildIncAssetTx()
...
buildIncAssetTx
Parameters¶
Object
: Description
from
-String|Number
: The address for the sending accountgas
-Number
: (optional, default: To-Be-Determined) The amount of gas to use for the transaction (unused gas is refunded).gasPrice
-Number|String|BN|BigNumber
: (optional) The price of gas for this transaction in wei.nonce
-Number
: (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.asset
-String|Number
: Descriptionto
-String|Number
: Descriptionvalue
-Number|String|BN|BigNumber
: DescriptionisInc
-Boolean
: DescriptiontransacData
-string
: Description
Example¶
fsntx.buildIncAssetTx()
return web3.fsntx
.buildIncAssetTx({
from: key.address,
to: key.address,
value: "1000000000000000000",
asset: assetId
})
.then(tx => {
tx.gasPrice = web3.utils.toWei( new web3.utils.BN( "3" ), "gwei");
return web3.fsn.signAndTransmit(tx, signInfo.signTransaction).then(tx => {
totalSent += 1
console.log( totalSent + " " + index * subToDo , tx);
transactionList.push(tx);
incAsset(index + 1, numberToDo, done)
});
})
.catch(err => {
console.log("inc asset created the following error", err);
done(err);
});
incAsset¶
fsntx.incAsset({from:fsn.coinbase,to:"0x2b1a3eca81ba03a9a4c95f4a04679c90838d7165",value:"0x1",asset:"0x514a46f34e6eb0a98abb3595c4aec33ca8ddf69f135c8fed89e78d0808047965"},"123456")
...
incAsset increase account asset balance CSP see the top and the “from”,”to” ignore from the asset owner to the inc account password the account password
Parameters¶
Object
: Description
from
-String|Number
: The address for the sending accountgas
-Number
: (optional, default: To-Be-Determined) The amount of gas to use for the transaction (unused gas is refunded).gasPrice
-Number|String|BN|BigNumber
: (optional) The price of gas for this transaction in wei.nonce
-Number
: (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.asset
-String|Number
: Descriptionto
-String|Number
: Descriptionvalue
-Number|String|BN|BigNumber
: DescriptionisInc
-Boolean
: DescriptiontransacData
-string
: Description
passwd
-string
: Description
Example¶
fsntx.incAsset({from:fsn.coinbase,to:"0x2b1a3eca81ba03a9a4c95f4a04679c90838d7165",value:"0x1",asset:"0x514a46f34e6eb0a98abb3595c4aec33ca8ddf69f135c8fed89e78d0808047965"},"123456")
buildDecAssetTx¶
fsntx.buildDecAssetTx()
...
buildDecAssetTx
Parameters¶
Object
: Description
from
-String|Number
: The address for the sending accountgas
-Number
: (optional, default: To-Be-Determined) The amount of gas to use for the transaction (unused gas is refunded).gasPrice
-Number|String|BN|BigNumber
: (optional) The price of gas for this transaction in wei.nonce
-Number
: (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.asset
-String|Number
: Descriptionto
-String|Number
: Descriptionvalue
-Number|String|BN|BigNumber
: DescriptionisInc
-Boolean
: DescriptiontransacData
-string
: Description
Example¶
fsntx.buildDecAssetTx()
decAsset¶
fsntx.decAsset({from:fsn.coinbase,to:"0x2b1a3eca81ba03a9a4c95f4a04679c90838d7165",value:"0x1",asset:"0x514a46f34e6eb0a98abb3595c4aec33ca8ddf69f135c8fed89e78d0808047965"},"123456")
...
decAsset decrease account asset balance CSP see the top and the “from”,”to” ignore from the asset owner to the dec account password the account password
Parameters¶
Object
: Description
from
-String|Number
: The address for the sending accountgas
-Number
: (optional, default: To-Be-Determined) The amount of gas to use for the transaction (unused gas is refunded).gasPrice
-Number|String|BN|BigNumber
: (optional) The price of gas for this transaction in wei.nonce
-Number
: (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.asset
-String|Number
: Descriptionto
-String|Number
: Descriptionvalue
-Number|String|BN|BigNumber
: DescriptionisInc
-Boolean
: DescriptiontransacData
-string
: Description
passwd
-string
: Description
Example¶
fsntx.decAsset({from:fsn.coinbase,to:"0x2b1a3eca81ba03a9a4c95f4a04679c90838d7165",value:"0x1",asset:"0x514a46f34e6eb0a98abb3595c4aec33ca8ddf69f135c8fed89e78d0808047965"},"123456")
buildMakeSwapTx¶
fsntx.buildMakeSwapTx()
...
buildMakeSwapTx
Parameters¶
Object
: Description
from
-String|Number
: The address for the sending accountgas
-Number
: (optional, default: To-Be-Determined) The amount of gas to use for the transaction (unused gas is refunded).gasPrice
-Number|String|BN|BigNumber
: (optional) The price of gas for this transaction in wei.nonce
-Number
: (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.FromAssetID
-String|Number
: DescriptionFromStartTime
-Number
: DescriptionFromEndTime
-Number
: DescriptionMinFromAmount
-Number|String|BN|BigNumber
: DescriptionToAssetID
-String|Number
: DescriptionToStartTime
-Number
: DescriptionToEndTime
-Number
: DescriptionMinToAmount
-Number|String|BN|BigNumber
: DescriptionSwapSize
-Number
: DescriptionTarges
-Array String|Number
: DescriptionTime
-Number
: Description
Example¶
fsntx.buildMakeSwapTx()
$scope.makeSwap = async function () {
targesArray = [];
let password = walletService.password;
let accountData = uiFuncs.getTxData($scope);
let walletAddress = accountData.from;
let fromAsset = [];
let toAsset = [];
try {
await web3.fsn.getAsset($scope.assetToSend).then(function (res) {
fromAsset = res;
});
} catch (err) {
$scope.errorModal.open();
console.log(err);
}
try {
await web3.fsn.getAsset($scope.assetToReceive).then(function (res) {
toAsset = res;
});
} catch (err) {
$scope.errorModal.open();
console.log(err);
}
if ($scope.makeTarges !== '') {
let targesArr = $scope.makeTarges.split(',');
await $scope.processAllTarges(targesArr, 0);
console.log(targesArray);
} else {
targesArray = [];
}
if ($scope.makeMinumumSwap == "" || $scope.makeMinumumSwap <= 0) {
$scope.makeMinumumSwap = 1;
}
//Global
let makeMinimumSwapBN = new BigNumber($scope.makeMinumumSwap);
//Receive Part
BigNumber.config({ DECIMAL_PLACES: parseInt(toAsset["Decimals"]-1) });
let makeReceiveAmountBN = new BigNumber($scope.makeReceiveAmount);
let makeReceiveAmountDiv = makeReceiveAmountBN.div(makeMinimumSwapBN);
let makeReceiveString = makeReceiveAmountDiv.toString();
let makeReceiveFinal = $scope.makeBigNumber(makeReceiveString , parseInt(toAsset["Decimals"]));
//Send Part
BigNumber.config({ DECIMAL_PLACES: parseInt(fromAsset["Decimals"]-1) });
let makeSendAmountBN = new BigNumber($scope.makeSendAmount);
let makeSendAmountDiv = makeSendAmountBN.div(makeMinimumSwapBN);
let makeSendString = makeSendAmountDiv.toString();
let makeSendFinal = $scope.makeBigNumber(makeSendString , parseInt(fromAsset["Decimals"]));
//Convert to Hex
let minToAmountHex = "0x" + makeReceiveFinal.toString(16);
let minFromAmountHex = "0x" + makeSendFinal.toString(16);
let data = {
from: walletAddress,
FromAssetID: $scope.assetToSend,
ToAssetID: $scope.assetToReceive,
MinToAmount: minToAmountHex,
MinFromAmount: minFromAmountHex,
SwapSize: parseInt($scope.makeMinumumSwap),
Targes: targesArray
};
// Send part
if ($scope.showTimeLockSend == true) {
if ($scope.sendTimeLock == 'scheduled') {
let fromStartTime = getHexDate(convertDate($scope.fromStartTime));
let fromEndTime = web3.fsn.consts.TimeForeverStr;
data.FromStartTime = fromStartTime;
data.FromEndTime = fromEndTime;
}
if ($scope.sendTimeLock == 'daterange') {
let fromStartTime = getHexDate(convertDate($scope.todayDate));
let fromEndTime = getHexDate(convertDate($scope.fromEndTime));
data.FromStartTime = fromStartTime;
data.FromEndTime = fromEndTime;
}
}
// Receive part
if ($scope.showTimeLockReceive == true) {
if ($scope.receiveTimeLock == 'scheduled') {
let toStartTime = getHexDate(convertDate($scope.ToStartTime));
let toEndTime = web3.fsn.consts.TimeForeverStr;
data.ToStartTime = toStartTime;
data.ToEndTime = toEndTime;
}
if ($scope.receiveTimeLock == 'daterange') {
let toStartTime = getHexDate(convertDate($scope.todayDate));
let toEndTime = getHexDate(convertDate($scope.ToEndTime));
data.ToStartTime = toStartTime;
data.ToEndTime = toEndTime;
}
}
if (!$scope.account && ($scope.wallet.hwType !== "ledger")) {
$scope.account = web3.eth.accounts.privateKeyToAccount($scope.toHexString($scope.wallet.getPrivateKey()));
}
console.log(data);
try {
await web3.fsntx.buildMakeSwapTx(data).then(function (tx) {
console.log(tx);
tx.from = walletAddress;
tx.chainId = _CHAINID;
data = tx;
if ($scope.wallet.hwType == "ledger") {
return;
}
return web3.fsn.signAndTransmit(tx, $scope.account.signTransaction).then(txHash => {
console.log(txHash);
$scope.makeSwapConfirmation('end');
})
})
} catch (err) {
$scope.errorModal.open();
console.log(err);
}
makeSwap¶
fsntx.makeSwap({from:fsn.coinbase,FromAssetID:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
ToAssetID:"0xffffffffffffffffffffffffffffffffffffffffffff00000000000000000000",MinToAmount:1,MinFromAmount:2,SwapSize:2,Targes:[]},"123456")
...
makeSwap create a quantum swap CP see the top FromAssetID sell asset id MinFromAmount the min amount of the sell asset ToAssetID buy asset id MinToAmount the min amount of the buy asset SwapSize the max sell package size Targes the address list of the “who can buy” can be null password the owner password
Parameters¶
Object
: Description
from
-String|Number
: The address for the sending accountgas
-Number
: (optional, default: To-Be-Determined) The amount of gas to use for the transaction (unused gas is refunded).gasPrice
-Number|String|BN|BigNumber
: (optional) The price of gas for this transaction in wei.nonce
-Number
: (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.FromAssetID
-String|Number
: DescriptionFromStartTime
-Number
: DescriptionFromEndTime
-Number
: DescriptionMinFromAmount
-Number|String|BN|BigNumber
: DescriptionToAssetID
-String|Number
: DescriptionToStartTime
-Number
: DescriptionToEndTime
-Number
: DescriptionMinToAmount
-Number|String|BN|BigNumber
: DescriptionSwapSize
-Number
: DescriptionTarges
-Array String|Number
: DescriptionTime
-Number
: Description
passwd
-string
: Description
Example¶
fsntx.makeSwap({from:fsn.coinbase,FromAssetID:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
ToAssetID:"0xffffffffffffffffffffffffffffffffffffffffffff00000000000000000000",MinToAmount:1,MinFromAmount:2,SwapSize:2,Targes:[]},"123456")
buildRecallSwapTx¶
fsntx.buildRecallSwapTx()
...
buildRecallSwapTx
Parameters¶
Object
: Description
from
-String|Number
: The address for the sending accountgas
-Number
: (optional, default: To-Be-Determined) The amount of gas to use for the transaction (unused gas is refunded).gasPrice
-Number|String|BN|BigNumber
: (optional) The price of gas for this transaction in wei.nonce
-Number
: (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.SwapID
-String|Number
: Description
Example¶
fsntx.buildRecallSwapTx()
$scope.recallSwap = async function (swap_id) {
if (walletService.wallet !== null) {
let password = walletService.password;
let accountData = uiFuncs.getTxData($scope);
let walletAddress = accountData.from;
let data = {
from: walletAddress,
SwapID: swap_id
};
if (!$scope.account && ($scope.wallet.hwType !== "ledger")) {
$scope.account = web3.eth.accounts.privateKeyToAccount($scope.toHexString($scope.wallet.getPrivateKey()));
}
try {
await web3.fsntx.buildRecallSwapTx(data).then(function (tx) {
tx.from = walletAddress;
tx.chainId = _CHAINID;
data = tx;
if ($scope.wallet.hwType == "ledger") {
return;
}
return web3.fsn.signAndTransmit(tx, $scope.account.signTransaction).then(txHash => {
console.log(txHash);
$scope.recallSwapSuccess.open()
})
})
} catch (err) {
$scope.errorModal.open();
console.log(err);
}
if ($scope.wallet.hwType == "ledger") {
let ledgerConfig = {
privKey: $scope.wallet.privKey ? $scope.wallet.getPrivateKeyString() : "",
path: $scope.wallet.getPath(),
hwType: $scope.wallet.getHWType(),
hwTransport: $scope.wallet.getHWTransport()
}
let rawTx = data;
var eTx = new ethUtil.Tx(rawTx);
if (ledgerConfig.hwType == "ledger") {
var app = new ledgerEth(ledgerConfig.hwTransport);
var EIP155Supported = true;
var localCallback = async function (result, error) {
if (typeof error != "undefined") {
if (callback !== undefined) callback({
isError: true,
error: error
});
return;
}
var splitVersion = result['version'].split('.');
if (parseInt(splitVersion[0]) > 1) {
EIP155Supported = true;
} else if (parseInt(splitVersion[1]) > 0) {
EIP155Supported = true;
} else if (parseInt(splitVersion[2]) > 2) {
EIP155Supported = true;
}
var oldTx = Object.assign(rawTx, {});
let input = oldTx.input;
return uiFuncs.signed(app, rawTx, ledgerConfig, true, function (res) {
oldTx.r = res.r;
oldTx.s = res.s;
oldTx.v = res.v;
oldTx.input = input;
oldTx.chainId = "0x1";
delete oldTx.isError;
delete oldTx.rawTx;
delete oldTx.signedTx;
web3.fsntx.sendRawTransaction(oldTx).then(function (txHash) {
$scope.recallSwapSuccess.open()
})
})
}
$scope.notifier.info('Please, confirm transaction on Ledger.');
await app.getAppConfiguration(localCallback);
}
}
}
}
recallSwap¶
fsntx.recallSwap({from:fsn.coinbase,SwapID:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"},"123456")
...
recallSwap destroy a quantum swap and get the asset back CP see the top SwapID the swap ID password the owner password
Parameters¶
Object
: Description
from
-String|Number
: The address for the sending accountgas
-Number
: (optional, default: To-Be-Determined) The amount of gas to use for the transaction (unused gas is refunded).gasPrice
-Number|String|BN|BigNumber
: (optional) The price of gas for this transaction in wei.nonce
-Number
: (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.SwapID
-String|Number
: Description
passwd
-string
: Description
Example¶
fsntx.recallSwap({from:fsn.coinbase,SwapID:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"},"123456")
.. code-block:: javascript
$scope.recallSwap = async function (swap_id) {
if (walletService.wallet !== null) {
let password = walletService.password;
let accountData = uiFuncs.getTxData($scope);
let walletAddress = accountData.from;
let data = {
from: walletAddress,
SwapID: swap_id
};
if (!$scope.account && ($scope.wallet.hwType !== "ledger")) {
$scope.account = web3.eth.accounts.privateKeyToAccount($scope.toHexString($scope.wallet.getPrivateKey()));
}
try {
await web3.fsntx.buildRecallSwapTx(data).then(function (tx) {
tx.from = walletAddress;
tx.chainId = _CHAINID;
data = tx;
if ($scope.wallet.hwType == "ledger") {
return;
}
return web3.fsn.signAndTransmit(tx, $scope.account.signTransaction).then(txHash => {
console.log(txHash);
$scope.recallSwapSuccess.open()
})
})
} catch (err) {
$scope.errorModal.open();
console.log(err);
}
if ($scope.wallet.hwType == "ledger") {
let ledgerConfig = {
privKey: $scope.wallet.privKey ? $scope.wallet.getPrivateKeyString() : "",
path: $scope.wallet.getPath(),
hwType: $scope.wallet.getHWType(),
hwTransport: $scope.wallet.getHWTransport()
}
let rawTx = data;
var eTx = new ethUtil.Tx(rawTx);
if (ledgerConfig.hwType == "ledger") {
var app = new ledgerEth(ledgerConfig.hwTransport);
var EIP155Supported = true;
var localCallback = async function (result, error) {
if (typeof error != "undefined") {
if (callback !== undefined) callback({
isError: true,
error: error
});
return;
}
var splitVersion = result['version'].split('.');
if (parseInt(splitVersion[0]) > 1) {
EIP155Supported = true;
} else if (parseInt(splitVersion[1]) > 0) {
EIP155Supported = true;
} else if (parseInt(splitVersion[2]) > 2) {
EIP155Supported = true;
}
var oldTx = Object.assign(rawTx, {});
let input = oldTx.input;
return uiFuncs.signed(app, rawTx, ledgerConfig, true, function (res) {
oldTx.r = res.r;
oldTx.s = res.s;
oldTx.v = res.v;
oldTx.input = input;
oldTx.chainId = "0x1";
delete oldTx.isError;
delete oldTx.rawTx;
delete oldTx.signedTx;
web3.fsntx.sendRawTransaction(oldTx).then(function (txHash) {
$scope.recallSwapSuccess.open()
})
})
}
$scope.notifier.info('Please, confirm transaction on Ledger.');
await app.getAppConfiguration(localCallback);
}
}
}
}
buildTakeSwapTx¶
fsntx.buildTakeSwapTx()
...
buildTakeSwapTx
Parameters¶
Object
: Description
from
-String|Number
: The address for the sending accountgas
-Number
: (optional, default: To-Be-Determined) The amount of gas to use for the transaction (unused gas is refunded).gasPrice
-Number|String|BN|BigNumber
: (optional) The price of gas for this transaction in wei.nonce
-Number
: (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.SwapID
-String|Number
: DescriptionSize
-Number
: Description
Example¶
$scope.takeSwap = async function (asset_id, swap_id, amount) {
let password = walletService.password;
let accountData = uiFuncs.getTxData($scope);
let walletAddress = accountData.from;
let toAsset = [];
try {
await web3.fsn.getAsset(asset_id).then(function (res) {
toAsset = res;
});
} catch (err) {
console.log(err);
}
let data = {
from: walletAddress,
SwapID: swap_id.swap_id,
Size: $scope.takeAmountSwap
};
console.log(data);
if (!$scope.account && ($scope.wallet.hwType !== "ledger")) {
$scope.account = web3.eth.accounts.privateKeyToAccount($scope.toHexString($scope.wallet.getPrivateKey()));
}
try {
await web3.fsntx.buildTakeSwapTx(data).then(function (tx) {
tx.from = walletAddress;
tx.chainId = _CHAINID;
data = tx;
if ($scope.wallet.hwType == "ledger") {
return;
}
web3.fsn.signAndTransmit(tx, $scope.account.signTransaction).then(txHash => {
console.log(txHash);
})
return $scope.takeSwapEndConfirm.open();
})
} catch (err) {
$scope.errorModal.open();
console.log(err);
}
if ($scope.wallet.hwType == "ledger") {
let ledgerConfig = {
privKey: $scope.wallet.privKey ? $scope.wallet.getPrivateKeyString() : "",
path: $scope.wallet.getPath(),
hwType: $scope.wallet.getHWType(),
hwTransport: $scope.wallet.getHWTransport()
}
let rawTx = data;
var eTx = new ethUtil.Tx(rawTx);
takeSwap¶
fsntx.takeSwap({from:fsn.coinbase,SwapID:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",Size:"0x1"},"123456")
...
takeSwap buy a quantum swap CP see the top SwapID the swap ID Size the package size password the owner password
Parameters¶
Object
: Description
from
-String|Number
: The address for the sending accountgas
-Number
: (optional, default: To-Be-Determined) The amount of gas to use for the transaction (unused gas is refunded).gasPrice
-Number|String|BN|BigNumber
: (optional) The price of gas for this transaction in wei.nonce
-Number
: (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.SwapID
-String|Number
: DescriptionSize
-Number
: Description
passwd
-string
: Description
Example¶
fsntx.takeSwap({from:fsn.coinbase,SwapID:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",Size:"0x1"},"123456")
$scope.takeSwap = async function (asset_id, swap_id, amount) {
let password = walletService.password;
let accountData = uiFuncs.getTxData($scope);
let walletAddress = accountData.from;
let toAsset = [];
try {
await web3.fsn.getAsset(asset_id).then(function (res) {
toAsset = res;
});
} catch (err) {
console.log(err);
}
let data = {
from: walletAddress,
SwapID: swap_id.swap_id,
Size: $scope.takeAmountSwap
};
console.log(data);
if (!$scope.account && ($scope.wallet.hwType !== "ledger")) {
$scope.account = web3.eth.accounts.privateKeyToAccount($scope.toHexString($scope.wallet.getPrivateKey()));
}
try {
await web3.fsntx.buildTakeSwapTx(data).then(function (tx) {
tx.from = walletAddress;
tx.chainId = _CHAINID;
data = tx;
if ($scope.wallet.hwType == "ledger") {
return;
}
web3.fsn.signAndTransmit(tx, $scope.account.signTransaction).then(txHash => {
console.log(txHash);
})
return $scope.takeSwapEndConfirm.open();
})
} catch (err) {
$scope.errorModal.open();
console.log(err);
}
if ($scope.wallet.hwType == "ledger") {
let ledgerConfig = {
privKey: $scope.wallet.privKey ? $scope.wallet.getPrivateKeyString() : "",
path: $scope.wallet.getPath(),
hwType: $scope.wallet.getHWType(),
hwTransport: $scope.wallet.getHWTransport()
}
let rawTx = data;
var eTx = new ethUtil.Tx(rawTx);